avr32: Add platform data for AC97C platform device

This patch adds platform data to the AC97C platform device. This will
let the board add a GPIO line which is connected to the external codecs
reset line.

The platform data, ac97c_platform_data, must also contain the DMA
controller ID, RX channel ID and TX channel ID.

Tested with Wolfson WM9712 and AP7000.

Signed-off-by: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>

authored by

Hans-Christian Egtvedt and committed by
Haavard Skinnemoen
218df4a2 fbfca4b8

+36 -8
+27 -7
arch/avr32/mach-at32ap/at32ap700x.c
··· 1883 .index = 10, 1884 }; 1885 1886 - struct platform_device *__init at32_add_device_ac97c(unsigned int id) 1887 { 1888 struct platform_device *pdev; 1889 1890 if (id != 0) 1891 return NULL; ··· 1898 1899 if (platform_device_add_resources(pdev, atmel_ac97c0_resource, 1900 ARRAY_SIZE(atmel_ac97c0_resource))) 1901 - goto err_add_resources; 1902 1903 - select_peripheral(PB(20), PERIPH_B, 0); /* SYNC */ 1904 - select_peripheral(PB(21), PERIPH_B, 0); /* SDO */ 1905 - select_peripheral(PB(22), PERIPH_B, 0); /* SDI */ 1906 - select_peripheral(PB(23), PERIPH_B, 0); /* SCLK */ 1907 1908 atmel_ac97c0_pclk.dev = &pdev->dev; 1909 1910 platform_device_add(pdev); 1911 return pdev; 1912 1913 - err_add_resources: 1914 platform_device_put(pdev); 1915 return NULL; 1916 }
··· 1883 .index = 10, 1884 }; 1885 1886 + struct platform_device *__init 1887 + at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data) 1888 { 1889 struct platform_device *pdev; 1890 + struct ac97c_platform_data _data; 1891 1892 if (id != 0) 1893 return NULL; ··· 1896 1897 if (platform_device_add_resources(pdev, atmel_ac97c0_resource, 1898 ARRAY_SIZE(atmel_ac97c0_resource))) 1899 + goto fail; 1900 1901 + if (!data) { 1902 + data = &_data; 1903 + memset(data, 0, sizeof(struct ac97c_platform_data)); 1904 + data->reset_pin = GPIO_PIN_NONE; 1905 + } 1906 + 1907 + data->dma_rx_periph_id = 3; 1908 + data->dma_tx_periph_id = 4; 1909 + data->dma_controller_id = 0; 1910 + 1911 + if (platform_device_add_data(pdev, data, 1912 + sizeof(struct ac97c_platform_data))) 1913 + goto fail; 1914 + 1915 + select_peripheral(PB(20), PERIPH_B, 0); /* SDO */ 1916 + select_peripheral(PB(21), PERIPH_B, 0); /* SYNC */ 1917 + select_peripheral(PB(22), PERIPH_B, 0); /* SCLK */ 1918 + select_peripheral(PB(23), PERIPH_B, 0); /* SDI */ 1919 + 1920 + /* TODO: gpio_is_valid(data->reset_pin) with kernel 2.6.26. */ 1921 + if (data->reset_pin != GPIO_PIN_NONE) 1922 + at32_select_gpio(data->reset_pin, 0); 1923 1924 atmel_ac97c0_pclk.dev = &pdev->dev; 1925 1926 platform_device_add(pdev); 1927 return pdev; 1928 1929 + fail: 1930 platform_device_put(pdev); 1931 return NULL; 1932 }
+9 -1
include/asm-avr32/arch-at32ap/board.h
··· 82 struct platform_device * 83 at32_add_device_mci(unsigned int id, struct mci_platform_data *data); 84 85 - struct platform_device *at32_add_device_ac97c(unsigned int id); 86 struct platform_device *at32_add_device_abdac(unsigned int id); 87 struct platform_device *at32_add_device_psif(unsigned int id); 88
··· 82 struct platform_device * 83 at32_add_device_mci(unsigned int id, struct mci_platform_data *data); 84 85 + struct ac97c_platform_data { 86 + unsigned short dma_rx_periph_id; 87 + unsigned short dma_tx_periph_id; 88 + unsigned short dma_controller_id; 89 + int reset_pin; 90 + }; 91 + struct platform_device * 92 + at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data); 93 + 94 struct platform_device *at32_add_device_abdac(unsigned int id); 95 struct platform_device *at32_add_device_psif(unsigned int id); 96