]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
avr32: at32ap700x: setup DMA for AC97C in the machine code
authorHans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Tue, 24 Mar 2009 12:59:23 +0000 (13:59 +0100)
committerHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
Fri, 27 Mar 2009 15:15:39 +0000 (16:15 +0100)
This patch will adjust the setup the DMA controller for the AC97
Controller in the at32ap700x machine code. This setup matches the new
ALSA driver for the AC97C.

The struct ac97c_platform_data has been moved into its own header file
located in the sound include path.

Tested on ATSTK1006 + ATSTK1000.

This patch will setup the AC97 controller properly for the adjusted
machine code. Both EVKLCD10x and Hammerhead board has been updated.

Tested on EVKLCD10x, and copied to Hammerhead board.

Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
[haavard.skinnemoen@atmel.com: fold with board code update]
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
arch/avr32/boards/atngw100/evklcd10x.c
arch/avr32/boards/hammerhead/setup.c
arch/avr32/mach-at32ap/at32ap700x.c
arch/avr32/mach-at32ap/include/mach/board.h

index ae6991205409d9f804840b162e32ee0fb7fae7de..00337112c5ac13e3fdc761f4a887d3757a72cb65 100644 (file)
 #include <mach/portmux.h>
 #include <mach/board.h>
 
+#include <sound/atmel-ac97c.h>
+
 static struct ac97c_platform_data __initdata ac97c0_data = {
-       .dma_rx_periph_id       = 3,
-       .dma_tx_periph_id       = 4,
-       .dma_controller_id      = 0,
-       .reset_pin              = GPIO_PIN_PB(19),
+       .reset_pin = GPIO_PIN_PB(19),
 };
 
 #ifdef CONFIG_BOARD_ATNGW100_EVKLCD10X_VGA
@@ -167,7 +166,7 @@ static int __init atevklcd10x_init(void)
                        fbmem_start, fbmem_size,
                        ATMEL_LCDC_ALT_18BIT | ATMEL_LCDC_PE_DVAL);
 
-       at32_add_device_ac97c(0, &ac97c0_data);
+       at32_add_device_ac97c(0, &ac97c0_data, AC97C_BOTH);
 
        return 0;
 }
index 4d2fe82b20291c67a143b431b5cf45ea0ff8dc5f..a5c2da25c4fe801b7d47368e58c4f2c13615b200 100644 (file)
@@ -29,6 +29,8 @@
 #include <mach/init.h>
 #include <mach/portmux.h>
 
+#include <sound/atmel-ac97c.h>
+
 #include "../../mach-at32ap/clock.h"
 #include "flash.h"
 
@@ -233,7 +235,7 @@ static int __init hammerhead_init(void)
        i2c_register_board_info(0, i2c_info, ARRAY_SIZE(i2c_info));
 
 #ifdef CONFIG_BOARD_HAMMERHEAD_SND
-       at32_add_device_ac97c(0, &ac97c_data);
+       at32_add_device_ac97c(0, &ac97c_data, AC97C_BOTH);
 #endif
 
        /* Select the Touchscreen interrupt pin mode */
index 1bc6389b20b062a180976e563d61ac00f52a3b4b..62501d64322c4720a13b7841afed8a5e24f89dc0 100644 (file)
@@ -27,6 +27,7 @@
 #include <mach/sram.h>
 
 #include <sound/atmel-abdac.h>
+#include <sound/atmel-ac97c.h>
 
 #include <video/atmel_lcdc.h>
 
@@ -1982,11 +1983,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;
@@ -1997,37 +2001,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;
 }
index 63ec4008b2533b1241a3601d18a0991b85377808..b363b067b0a4412c88c48f84e073aa76c1c2d60b 100644 (file)
@@ -88,14 +88,10 @@ 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);
+at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data,
+                     unsigned int flags);
 
 struct atmel_abdac_pdata;
 struct platform_device *