diff options
Diffstat (limited to 'arch/avr32/mach-at32ap')
-rw-r--r-- | arch/avr32/mach-at32ap/at32ap700x.c | 112 | ||||
-rw-r--r-- | arch/avr32/mach-at32ap/include/mach/at32ap700x.h | 52 | ||||
-rw-r--r-- | arch/avr32/mach-at32ap/include/mach/board.h | 24 |
3 files changed, 133 insertions, 55 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 @@ #include <mach/portmux.h> #include <mach/sram.h> +#include <sound/atmel-abdac.h> +#include <sound/atmel-ac97c.h> + #include <video/atmel_lcdc.h> #include "clock.h" @@ -963,56 +966,68 @@ static struct resource atmel_usart3_resource[] = { DEFINE_DEV_DATA(atmel_usart, 3); DEV_CLK(usart, atmel_usart3, pba, 6); -static inline void configure_usart0_pins(void) +static inline void configure_usart0_pins(int flags) { u32 pin_mask = (1 << 8) | (1 << 9); /* RXD & TXD */ + if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 6); + if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 7); + if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 10); select_peripheral(PIOA, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP); } -static inline void configure_usart1_pins(void) +static inline void configure_usart1_pins(int flags) { u32 pin_mask = (1 << 17) | (1 << 18); /* RXD & TXD */ + if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 19); + if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 20); + if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 16); select_peripheral(PIOA, pin_mask, PERIPH_A, AT32_GPIOF_PULLUP); } -static inline void configure_usart2_pins(void) +static inline void configure_usart2_pins(int flags) { u32 pin_mask = (1 << 26) | (1 << 27); /* RXD & TXD */ + if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 30); + if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 29); + if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 28); select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP); } -static inline void configure_usart3_pins(void) +static inline void configure_usart3_pins(int flags) { u32 pin_mask = (1 << 18) | (1 << 17); /* RXD & TXD */ + if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 16); + if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 15); + if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 19); select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP); } static struct platform_device *__initdata at32_usarts[4]; -void __init at32_map_usart(unsigned int hw_id, unsigned int line) +void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags) { struct platform_device *pdev; switch (hw_id) { case 0: pdev = &atmel_usart0_device; - configure_usart0_pins(); + configure_usart0_pins(flags); break; case 1: pdev = &atmel_usart1_device; - configure_usart1_pins(); + configure_usart1_pins(flags); break; case 2: pdev = &atmel_usart2_device; - configure_usart2_pins(); + configure_usart2_pins(flags); break; case 3: pdev = &atmel_usart3_device; - configure_usart3_pins(); + configure_usart3_pins(flags); break; default: return; @@ -1753,7 +1768,7 @@ at32_add_device_usba(unsigned int id, struct usba_platform_data *data) if (platform_device_add_data(pdev, data, sizeof(usba_data))) goto out_free_pdev; - if (data->vbus_pin >= 0) + if (gpio_is_valid(data->vbus_pin)) at32_select_gpio(data->vbus_pin, 0); usba0_pclk.dev = &pdev->dev; @@ -1980,11 +1995,14 @@ static struct clk atmel_ac97c0_pclk = { }; struct platform_device *__init -at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data) +at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data, + unsigned int flags) { - struct platform_device *pdev; - struct ac97c_platform_data _data; - u32 pin_mask; + struct platform_device *pdev; + struct dw_dma_slave *rx_dws; + struct dw_dma_slave *tx_dws; + struct ac97c_platform_data _data; + u32 pin_mask; if (id != 0) return NULL; @@ -1995,37 +2013,52 @@ at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data) if (platform_device_add_resources(pdev, atmel_ac97c0_resource, ARRAY_SIZE(atmel_ac97c0_resource))) - goto fail; + goto out_free_resources; if (!data) { data = &_data; memset(data, 0, sizeof(struct ac97c_platform_data)); - data->reset_pin = GPIO_PIN_NONE; + data->reset_pin = -ENODEV; } - data->dma_rx_periph_id = 3; - data->dma_tx_periph_id = 4; - data->dma_controller_id = 0; + rx_dws = &data->rx_dws; + tx_dws = &data->tx_dws; + + /* Check if DMA slave interface for capture should be configured. */ + if (flags & AC97C_CAPTURE) { + rx_dws->dma_dev = &dw_dmac0_device.dev; + rx_dws->reg_width = DW_DMA_SLAVE_WIDTH_16BIT; + rx_dws->cfg_hi = DWC_CFGH_SRC_PER(3); + rx_dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL); + } + + /* Check if DMA slave interface for playback should be configured. */ + if (flags & AC97C_PLAYBACK) { + tx_dws->dma_dev = &dw_dmac0_device.dev; + tx_dws->reg_width = DW_DMA_SLAVE_WIDTH_16BIT; + tx_dws->cfg_hi = DWC_CFGH_DST_PER(4); + tx_dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL); + } if (platform_device_add_data(pdev, data, sizeof(struct ac97c_platform_data))) - goto fail; + goto out_free_resources; - pin_mask = (1 << 20) | (1 << 21); /* SDO & SYNC */ - pin_mask |= (1 << 22) | (1 << 23); /* SCLK & SDI */ + /* SDO | SYNC | SCLK | SDI */ + pin_mask = (1 << 20) | (1 << 21) | (1 << 22) | (1 << 23); select_peripheral(PIOB, pin_mask, PERIPH_B, 0); - /* TODO: gpio_is_valid(data->reset_pin) with kernel 2.6.26. */ - if (data->reset_pin != GPIO_PIN_NONE) - at32_select_gpio(data->reset_pin, 0); + if (gpio_is_valid(data->reset_pin)) + at32_select_gpio(data->reset_pin, AT32_GPIOF_OUTPUT + | AT32_GPIOF_HIGH); atmel_ac97c0_pclk.dev = &pdev->dev; platform_device_add(pdev); return pdev; -fail: +out_free_resources: platform_device_put(pdev); return NULL; } @@ -2053,21 +2086,34 @@ static struct clk abdac0_sample_clk = { .index = 6, }; -struct platform_device *__init at32_add_device_abdac(unsigned int id) +struct platform_device *__init +at32_add_device_abdac(unsigned int id, struct atmel_abdac_pdata *data) { - struct platform_device *pdev; - u32 pin_mask; + struct platform_device *pdev; + struct dw_dma_slave *dws; + u32 pin_mask; - if (id != 0) + if (id != 0 || !data) return NULL; - pdev = platform_device_alloc("abdac", id); + pdev = platform_device_alloc("atmel_abdac", id); if (!pdev) return NULL; if (platform_device_add_resources(pdev, abdac0_resource, ARRAY_SIZE(abdac0_resource))) - goto err_add_resources; + goto out_free_resources; + + dws = &data->dws; + + dws->dma_dev = &dw_dmac0_device.dev; + dws->reg_width = DW_DMA_SLAVE_WIDTH_32BIT; + dws->cfg_hi = DWC_CFGH_DST_PER(2); + dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL); + + if (platform_device_add_data(pdev, data, + sizeof(struct atmel_abdac_pdata))) + goto out_free_resources; pin_mask = (1 << 20) | (1 << 22); /* DATA1 & DATAN1 */ pin_mask |= (1 << 21) | (1 << 23); /* DATA0 & DATAN0 */ @@ -2080,7 +2126,7 @@ struct platform_device *__init at32_add_device_abdac(unsigned int id) platform_device_add(pdev); return pdev; -err_add_resources: +out_free_resources: platform_device_put(pdev); return NULL; } diff --git a/arch/avr32/mach-at32ap/include/mach/at32ap700x.h b/arch/avr32/mach-at32ap/include/mach/at32ap700x.h index 5c4c971eed8e..b9222bf895bc 100644 --- a/arch/avr32/mach-at32ap/include/mach/at32ap700x.h +++ b/arch/avr32/mach-at32ap/include/mach/at32ap700x.h @@ -171,25 +171,49 @@ ATMEL_LCDC(PE, DATA20) | ATMEL_LCDC(PE, DATA21) | \ ATMEL_LCDC(PD, DATA22) | ATMEL_LCDC(PD, DATA23)) -#define ATMEL_LCDC_PRI_15B_DATA ( \ - ATMEL_LCDC(PC, DATA0) | ATMEL_LCDC(PC, DATA1) | \ +#define ATMEL_LCDC_PRI_18B_DATA ( \ ATMEL_LCDC(PC, DATA2) | ATMEL_LCDC(PC, DATA3) | \ ATMEL_LCDC(PC, DATA4) | ATMEL_LCDC(PC, DATA5) | \ - ATMEL_LCDC(PD, DATA8) | ATMEL_LCDC(PD, DATA9) | \ + ATMEL_LCDC(PD, DATA6) | ATMEL_LCDC(PD, DATA7) | \ ATMEL_LCDC(PD, DATA10) | ATMEL_LCDC(PD, DATA11) | \ - ATMEL_LCDC(PD, DATA12) | ATMEL_LCDC(PD, DATA16) | \ - ATMEL_LCDC(PD, DATA17) | ATMEL_LCDC(PD, DATA18) | \ - ATMEL_LCDC(PD, DATA19) | ATMEL_LCDC(PD, DATA20)) + ATMEL_LCDC(PD, DATA12) | ATMEL_LCDC(PD, DATA13) | \ + ATMEL_LCDC(PD, DATA14) | ATMEL_LCDC(PD, DATA15) | \ + ATMEL_LCDC(PD, DATA18) | ATMEL_LCDC(PD, DATA19) | \ + ATMEL_LCDC(PD, DATA20) | ATMEL_LCDC(PD, DATA21) | \ + ATMEL_LCDC(PD, DATA22) | ATMEL_LCDC(PD, DATA23)) -#define ATMEL_LCDC_ALT_15B_DATA ( \ - ATMEL_LCDC(PE, DATA0) | ATMEL_LCDC(PE, DATA1) | \ +#define ATMEL_LCDC_ALT_18B_DATA ( \ ATMEL_LCDC(PE, DATA2) | ATMEL_LCDC(PE, DATA3) | \ ATMEL_LCDC(PE, DATA4) | ATMEL_LCDC(PC, DATA5) | \ - ATMEL_LCDC(PE, DATA8) | ATMEL_LCDC(PE, DATA9) | \ + ATMEL_LCDC(PD, DATA6) | ATMEL_LCDC(PD, DATA7) | \ ATMEL_LCDC(PE, DATA10) | ATMEL_LCDC(PE, DATA11) | \ - ATMEL_LCDC(PE, DATA12) | ATMEL_LCDC(PE, DATA16) | \ - ATMEL_LCDC(PE, DATA17) | ATMEL_LCDC(PE, DATA18) | \ - ATMEL_LCDC(PE, DATA19) | ATMEL_LCDC(PE, DATA20)) + ATMEL_LCDC(PE, DATA12) | ATMEL_LCDC(PD, DATA13) | \ + ATMEL_LCDC(PD, DATA14) | ATMEL_LCDC(PD, DATA15) | \ + ATMEL_LCDC(PE, DATA18) | ATMEL_LCDC(PE, DATA19) | \ + ATMEL_LCDC(PE, DATA20) | ATMEL_LCDC(PE, DATA21) | \ + ATMEL_LCDC(PD, DATA22) | ATMEL_LCDC(PD, DATA23)) + +#define ATMEL_LCDC_PRI_15B_DATA ( \ + ATMEL_LCDC(PC, DATA3) | ATMEL_LCDC(PC, DATA4) | \ + ATMEL_LCDC(PC, DATA5) | ATMEL_LCDC(PD, DATA6) | \ + ATMEL_LCDC(PD, DATA7) | \ + ATMEL_LCDC(PD, DATA11) | ATMEL_LCDC(PD, DATA12) | \ + ATMEL_LCDC(PD, DATA13) | ATMEL_LCDC(PD, DATA14) | \ + ATMEL_LCDC(PD, DATA15) | \ + ATMEL_LCDC(PD, DATA19) | ATMEL_LCDC(PD, DATA20) | \ + ATMEL_LCDC(PD, DATA21) | ATMEL_LCDC(PD, DATA22) | \ + ATMEL_LCDC(PD, DATA23)) + +#define ATMEL_LCDC_ALT_15B_DATA ( \ + ATMEL_LCDC(PE, DATA3) | ATMEL_LCDC(PE, DATA4) | \ + ATMEL_LCDC(PC, DATA5) | ATMEL_LCDC(PD, DATA6) | \ + ATMEL_LCDC(PD, DATA7) | \ + ATMEL_LCDC(PE, DATA11) | ATMEL_LCDC(PE, DATA12) | \ + ATMEL_LCDC(PD, DATA13) | ATMEL_LCDC(PD, DATA14) | \ + ATMEL_LCDC(PD, DATA15) | \ + ATMEL_LCDC(PE, DATA19) | ATMEL_LCDC(PE, DATA20) | \ + ATMEL_LCDC(PE, DATA21) | ATMEL_LCDC(PD, DATA22) | \ + ATMEL_LCDC(PD, DATA23)) #define ATMEL_LCDC_PRI_CONTROL ( \ ATMEL_LCDC(PC, CC) | ATMEL_LCDC(PC, DVAL) | \ @@ -207,6 +231,10 @@ #define ATMEL_LCDC_ALT_24BIT (ATMEL_LCDC_CONTROL | ATMEL_LCDC_ALT_24B_DATA) +#define ATMEL_LCDC_PRI_18BIT (ATMEL_LCDC_CONTROL | ATMEL_LCDC_PRI_18B_DATA) + +#define ATMEL_LCDC_ALT_18BIT (ATMEL_LCDC_CONTROL | ATMEL_LCDC_ALT_18B_DATA) + #define ATMEL_LCDC_PRI_15BIT (ATMEL_LCDC_CONTROL | ATMEL_LCDC_PRI_15B_DATA) #define ATMEL_LCDC_ALT_15BIT (ATMEL_LCDC_CONTROL | ATMEL_LCDC_ALT_15B_DATA) diff --git a/arch/avr32/mach-at32ap/include/mach/board.h b/arch/avr32/mach-at32ap/include/mach/board.h index cff8e84f78f2..0b8164281899 100644 --- a/arch/avr32/mach-at32ap/include/mach/board.h +++ b/arch/avr32/mach-at32ap/include/mach/board.h @@ -13,7 +13,7 @@ * in this array is chip-dependent. */ extern unsigned long at32_board_osc_rates[]; - + /* * This used to add essential system devices, but this is now done * automatically. Please don't use it in new board code. @@ -26,12 +26,17 @@ static inline void __deprecated at32_add_system_devices(void) #define ATMEL_MAX_UART 4 extern struct platform_device *atmel_default_console_device; +/* Flags for selecting USART extra pins */ +#define ATMEL_USART_RTS 0x01 +#define ATMEL_USART_CTS 0x02 +#define ATMEL_USART_CLK 0x03 + struct atmel_uart_data { short use_dma_tx; /* use transmit DMA? */ short use_dma_rx; /* use receive DMA? */ void __iomem *regs; /* virtual base address, if any */ }; -void at32_map_usart(unsigned int hw_id, unsigned int line); +void at32_map_usart(unsigned int hw_id, unsigned int line, int flags); struct platform_device *at32_add_device_usart(unsigned int id); struct eth_platform_data { @@ -88,16 +93,15 @@ struct mci_platform_data; struct platform_device * at32_add_device_mci(unsigned int id, struct mci_platform_data *data); -struct ac97c_platform_data { - unsigned short dma_rx_periph_id; - unsigned short dma_tx_periph_id; - unsigned short dma_controller_id; - int reset_pin; -}; +struct ac97c_platform_data; +struct platform_device * +at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data, + unsigned int flags); + +struct atmel_abdac_pdata; struct platform_device * -at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data); +at32_add_device_abdac(unsigned int id, struct atmel_abdac_pdata *data); -struct platform_device *at32_add_device_abdac(unsigned int id); struct platform_device *at32_add_device_psif(unsigned int id); struct cf_platform_data { |