aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/mach-at32ap/at32ap700x.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/avr32/mach-at32ap/at32ap700x.c')
-rw-r--r--arch/avr32/mach-at32ap/at32ap700x.c112
1 files changed, 79 insertions, 33 deletions
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
index 3fbfd1e32a9e..7cc653798327 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -26,6 +26,9 @@
26#include <mach/portmux.h> 26#include <mach/portmux.h>
27#include <mach/sram.h> 27#include <mach/sram.h>
28 28
29#include <sound/atmel-abdac.h>
30#include <sound/atmel-ac97c.h>
31
29#include <video/atmel_lcdc.h> 32#include <video/atmel_lcdc.h>
30 33
31#include "clock.h" 34#include "clock.h"
@@ -963,56 +966,68 @@ static struct resource atmel_usart3_resource[] = {
963DEFINE_DEV_DATA(atmel_usart, 3); 966DEFINE_DEV_DATA(atmel_usart, 3);
964DEV_CLK(usart, atmel_usart3, pba, 6); 967DEV_CLK(usart, atmel_usart3, pba, 6);
965 968
966static inline void configure_usart0_pins(void) 969static inline void configure_usart0_pins(int flags)
967{ 970{
968 u32 pin_mask = (1 << 8) | (1 << 9); /* RXD & TXD */ 971 u32 pin_mask = (1 << 8) | (1 << 9); /* RXD & TXD */
972 if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 6);
973 if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 7);
974 if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 10);
969 975
970 select_peripheral(PIOA, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP); 976 select_peripheral(PIOA, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP);
971} 977}
972 978
973static inline void configure_usart1_pins(void) 979static inline void configure_usart1_pins(int flags)
974{ 980{
975 u32 pin_mask = (1 << 17) | (1 << 18); /* RXD & TXD */ 981 u32 pin_mask = (1 << 17) | (1 << 18); /* RXD & TXD */
982 if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 19);
983 if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 20);
984 if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 16);
976 985
977 select_peripheral(PIOA, pin_mask, PERIPH_A, AT32_GPIOF_PULLUP); 986 select_peripheral(PIOA, pin_mask, PERIPH_A, AT32_GPIOF_PULLUP);
978} 987}
979 988
980static inline void configure_usart2_pins(void) 989static inline void configure_usart2_pins(int flags)
981{ 990{
982 u32 pin_mask = (1 << 26) | (1 << 27); /* RXD & TXD */ 991 u32 pin_mask = (1 << 26) | (1 << 27); /* RXD & TXD */
992 if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 30);
993 if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 29);
994 if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 28);
983 995
984 select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP); 996 select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP);
985} 997}
986 998
987static inline void configure_usart3_pins(void) 999static inline void configure_usart3_pins(int flags)
988{ 1000{
989 u32 pin_mask = (1 << 18) | (1 << 17); /* RXD & TXD */ 1001 u32 pin_mask = (1 << 18) | (1 << 17); /* RXD & TXD */
1002 if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 16);
1003 if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 15);
1004 if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 19);
990 1005
991 select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP); 1006 select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP);
992} 1007}
993 1008
994static struct platform_device *__initdata at32_usarts[4]; 1009static struct platform_device *__initdata at32_usarts[4];
995 1010
996void __init at32_map_usart(unsigned int hw_id, unsigned int line) 1011void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
997{ 1012{
998 struct platform_device *pdev; 1013 struct platform_device *pdev;
999 1014
1000 switch (hw_id) { 1015 switch (hw_id) {
1001 case 0: 1016 case 0:
1002 pdev = &atmel_usart0_device; 1017 pdev = &atmel_usart0_device;
1003 configure_usart0_pins(); 1018 configure_usart0_pins(flags);
1004 break; 1019 break;
1005 case 1: 1020 case 1:
1006 pdev = &atmel_usart1_device; 1021 pdev = &atmel_usart1_device;
1007 configure_usart1_pins(); 1022 configure_usart1_pins(flags);
1008 break; 1023 break;
1009 case 2: 1024 case 2:
1010 pdev = &atmel_usart2_device; 1025 pdev = &atmel_usart2_device;
1011 configure_usart2_pins(); 1026 configure_usart2_pins(flags);
1012 break; 1027 break;
1013 case 3: 1028 case 3:
1014 pdev = &atmel_usart3_device; 1029 pdev = &atmel_usart3_device;
1015 configure_usart3_pins(); 1030 configure_usart3_pins(flags);
1016 break; 1031 break;
1017 default: 1032 default:
1018 return; 1033 return;
@@ -1753,7 +1768,7 @@ at32_add_device_usba(unsigned int id, struct usba_platform_data *data)
1753 if (platform_device_add_data(pdev, data, sizeof(usba_data))) 1768 if (platform_device_add_data(pdev, data, sizeof(usba_data)))
1754 goto out_free_pdev; 1769 goto out_free_pdev;
1755 1770
1756 if (data->vbus_pin >= 0) 1771 if (gpio_is_valid(data->vbus_pin))
1757 at32_select_gpio(data->vbus_pin, 0); 1772 at32_select_gpio(data->vbus_pin, 0);
1758 1773
1759 usba0_pclk.dev = &pdev->dev; 1774 usba0_pclk.dev = &pdev->dev;
@@ -1980,11 +1995,14 @@ static struct clk atmel_ac97c0_pclk = {
1980}; 1995};
1981 1996
1982struct platform_device *__init 1997struct platform_device *__init
1983at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data) 1998at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data,
1999 unsigned int flags)
1984{ 2000{
1985 struct platform_device *pdev; 2001 struct platform_device *pdev;
1986 struct ac97c_platform_data _data; 2002 struct dw_dma_slave *rx_dws;
1987 u32 pin_mask; 2003 struct dw_dma_slave *tx_dws;
2004 struct ac97c_platform_data _data;
2005 u32 pin_mask;
1988 2006
1989 if (id != 0) 2007 if (id != 0)
1990 return NULL; 2008 return NULL;
@@ -1995,37 +2013,52 @@ at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data)
1995 2013
1996 if (platform_device_add_resources(pdev, atmel_ac97c0_resource, 2014 if (platform_device_add_resources(pdev, atmel_ac97c0_resource,
1997 ARRAY_SIZE(atmel_ac97c0_resource))) 2015 ARRAY_SIZE(atmel_ac97c0_resource)))
1998 goto fail; 2016 goto out_free_resources;
1999 2017
2000 if (!data) { 2018 if (!data) {
2001 data = &_data; 2019 data = &_data;
2002 memset(data, 0, sizeof(struct ac97c_platform_data)); 2020 memset(data, 0, sizeof(struct ac97c_platform_data));
2003 data->reset_pin = GPIO_PIN_NONE; 2021 data->reset_pin = -ENODEV;
2004 } 2022 }
2005 2023
2006 data->dma_rx_periph_id = 3; 2024 rx_dws = &data->rx_dws;
2007 data->dma_tx_periph_id = 4; 2025 tx_dws = &data->tx_dws;
2008 data->dma_controller_id = 0; 2026
2027 /* Check if DMA slave interface for capture should be configured. */
2028 if (flags & AC97C_CAPTURE) {
2029 rx_dws->dma_dev = &dw_dmac0_device.dev;
2030 rx_dws->reg_width = DW_DMA_SLAVE_WIDTH_16BIT;
2031 rx_dws->cfg_hi = DWC_CFGH_SRC_PER(3);
2032 rx_dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL);
2033 }
2034
2035 /* Check if DMA slave interface for playback should be configured. */
2036 if (flags & AC97C_PLAYBACK) {
2037 tx_dws->dma_dev = &dw_dmac0_device.dev;
2038 tx_dws->reg_width = DW_DMA_SLAVE_WIDTH_16BIT;
2039 tx_dws->cfg_hi = DWC_CFGH_DST_PER(4);
2040 tx_dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL);
2041 }
2009 2042
2010 if (platform_device_add_data(pdev, data, 2043 if (platform_device_add_data(pdev, data,
2011 sizeof(struct ac97c_platform_data))) 2044 sizeof(struct ac97c_platform_data)))
2012 goto fail; 2045 goto out_free_resources;
2013 2046
2014 pin_mask = (1 << 20) | (1 << 21); /* SDO & SYNC */ 2047 /* SDO | SYNC | SCLK | SDI */
2015 pin_mask |= (1 << 22) | (1 << 23); /* SCLK & SDI */ 2048 pin_mask = (1 << 20) | (1 << 21) | (1 << 22) | (1 << 23);
2016 2049
2017 select_peripheral(PIOB, pin_mask, PERIPH_B, 0); 2050 select_peripheral(PIOB, pin_mask, PERIPH_B, 0);
2018 2051
2019 /* TODO: gpio_is_valid(data->reset_pin) with kernel 2.6.26. */ 2052 if (gpio_is_valid(data->reset_pin))
2020 if (data->reset_pin != GPIO_PIN_NONE) 2053 at32_select_gpio(data->reset_pin, AT32_GPIOF_OUTPUT
2021 at32_select_gpio(data->reset_pin, 0); 2054 | AT32_GPIOF_HIGH);
2022 2055
2023 atmel_ac97c0_pclk.dev = &pdev->dev; 2056 atmel_ac97c0_pclk.dev = &pdev->dev;
2024 2057
2025 platform_device_add(pdev); 2058 platform_device_add(pdev);
2026 return pdev; 2059 return pdev;
2027 2060
2028fail: 2061out_free_resources:
2029 platform_device_put(pdev); 2062 platform_device_put(pdev);
2030 return NULL; 2063 return NULL;
2031} 2064}
@@ -2053,21 +2086,34 @@ static struct clk abdac0_sample_clk = {
2053 .index = 6, 2086 .index = 6,
2054}; 2087};
2055 2088
2056struct platform_device *__init at32_add_device_abdac(unsigned int id) 2089struct platform_device *__init
2090at32_add_device_abdac(unsigned int id, struct atmel_abdac_pdata *data)
2057{ 2091{
2058 struct platform_device *pdev; 2092 struct platform_device *pdev;
2059 u32 pin_mask; 2093 struct dw_dma_slave *dws;
2094 u32 pin_mask;
2060 2095
2061 if (id != 0) 2096 if (id != 0 || !data)
2062 return NULL; 2097 return NULL;
2063 2098
2064 pdev = platform_device_alloc("abdac", id); 2099 pdev = platform_device_alloc("atmel_abdac", id);
2065 if (!pdev) 2100 if (!pdev)
2066 return NULL; 2101 return NULL;
2067 2102
2068 if (platform_device_add_resources(pdev, abdac0_resource, 2103 if (platform_device_add_resources(pdev, abdac0_resource,
2069 ARRAY_SIZE(abdac0_resource))) 2104 ARRAY_SIZE(abdac0_resource)))
2070 goto err_add_resources; 2105 goto out_free_resources;
2106
2107 dws = &data->dws;
2108
2109 dws->dma_dev = &dw_dmac0_device.dev;
2110 dws->reg_width = DW_DMA_SLAVE_WIDTH_32BIT;
2111 dws->cfg_hi = DWC_CFGH_DST_PER(2);
2112 dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL);
2113
2114 if (platform_device_add_data(pdev, data,
2115 sizeof(struct atmel_abdac_pdata)))
2116 goto out_free_resources;
2071 2117
2072 pin_mask = (1 << 20) | (1 << 22); /* DATA1 & DATAN1 */ 2118 pin_mask = (1 << 20) | (1 << 22); /* DATA1 & DATAN1 */
2073 pin_mask |= (1 << 21) | (1 << 23); /* DATA0 & DATAN0 */ 2119 pin_mask |= (1 << 21) | (1 << 23); /* DATA0 & DATAN0 */
@@ -2080,7 +2126,7 @@ struct platform_device *__init at32_add_device_abdac(unsigned int id)
2080 platform_device_add(pdev); 2126 platform_device_add(pdev);
2081 return pdev; 2127 return pdev;
2082 2128
2083err_add_resources: 2129out_free_resources:
2084 platform_device_put(pdev); 2130 platform_device_put(pdev);
2085 return NULL; 2131 return NULL;
2086} 2132}