diff options
Diffstat (limited to 'arch/avr32/mach-at32ap/at32ap700x.c')
-rw-r--r-- | arch/avr32/mach-at32ap/at32ap700x.c | 135 |
1 files changed, 104 insertions, 31 deletions
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c index 021d51217184..1617048c86c5 100644 --- a/arch/avr32/mach-at32ap/at32ap700x.c +++ b/arch/avr32/mach-at32ap/at32ap700x.c | |||
@@ -7,10 +7,12 @@ | |||
7 | */ | 7 | */ |
8 | #include <linux/clk.h> | 8 | #include <linux/clk.h> |
9 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
10 | #include <linux/dw_dmac.h> | ||
10 | #include <linux/fb.h> | 11 | #include <linux/fb.h> |
11 | #include <linux/init.h> | 12 | #include <linux/init.h> |
12 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
13 | #include <linux/dma-mapping.h> | 14 | #include <linux/dma-mapping.h> |
15 | #include <linux/gpio.h> | ||
14 | #include <linux/spi/spi.h> | 16 | #include <linux/spi/spi.h> |
15 | #include <linux/usb/atmel_usba_udc.h> | 17 | #include <linux/usb/atmel_usba_udc.h> |
16 | 18 | ||
@@ -594,6 +596,17 @@ static void __init genclk_init_parent(struct clk *clk) | |||
594 | clk->parent = parent; | 596 | clk->parent = parent; |
595 | } | 597 | } |
596 | 598 | ||
599 | static struct dw_dma_platform_data dw_dmac0_data = { | ||
600 | .nr_channels = 3, | ||
601 | }; | ||
602 | |||
603 | static struct resource dw_dmac0_resource[] = { | ||
604 | PBMEM(0xff200000), | ||
605 | IRQ(2), | ||
606 | }; | ||
607 | DEFINE_DEV_DATA(dw_dmac, 0); | ||
608 | DEV_CLK(hclk, dw_dmac0, hsb, 10); | ||
609 | |||
597 | /* -------------------------------------------------------------------- | 610 | /* -------------------------------------------------------------------- |
598 | * System peripherals | 611 | * System peripherals |
599 | * -------------------------------------------------------------------- */ | 612 | * -------------------------------------------------------------------- */ |
@@ -708,17 +721,6 @@ static struct clk pico_clk = { | |||
708 | .users = 1, | 721 | .users = 1, |
709 | }; | 722 | }; |
710 | 723 | ||
711 | static struct resource dmaca0_resource[] = { | ||
712 | { | ||
713 | .start = 0xff200000, | ||
714 | .end = 0xff20ffff, | ||
715 | .flags = IORESOURCE_MEM, | ||
716 | }, | ||
717 | IRQ(2), | ||
718 | }; | ||
719 | DEFINE_DEV(dmaca, 0); | ||
720 | DEV_CLK(hclk, dmaca0, hsb, 10); | ||
721 | |||
722 | /* -------------------------------------------------------------------- | 724 | /* -------------------------------------------------------------------- |
723 | * HMATRIX | 725 | * HMATRIX |
724 | * -------------------------------------------------------------------- */ | 726 | * -------------------------------------------------------------------- */ |
@@ -831,7 +833,7 @@ void __init at32_add_system_devices(void) | |||
831 | platform_device_register(&at32_eic0_device); | 833 | platform_device_register(&at32_eic0_device); |
832 | platform_device_register(&smc0_device); | 834 | platform_device_register(&smc0_device); |
833 | platform_device_register(&pdc_device); | 835 | platform_device_register(&pdc_device); |
834 | platform_device_register(&dmaca0_device); | 836 | platform_device_register(&dw_dmac0_device); |
835 | 837 | ||
836 | platform_device_register(&at32_tcb0_device); | 838 | platform_device_register(&at32_tcb0_device); |
837 | platform_device_register(&at32_tcb1_device); | 839 | platform_device_register(&at32_tcb1_device); |
@@ -1284,7 +1286,6 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) | |||
1284 | { | 1286 | { |
1285 | struct mci_platform_data _data; | 1287 | struct mci_platform_data _data; |
1286 | struct platform_device *pdev; | 1288 | struct platform_device *pdev; |
1287 | struct dw_dma_slave *dws; | ||
1288 | 1289 | ||
1289 | if (id != 0) | 1290 | if (id != 0) |
1290 | return NULL; | 1291 | return NULL; |
@@ -1299,7 +1300,9 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) | |||
1299 | 1300 | ||
1300 | if (!data) { | 1301 | if (!data) { |
1301 | data = &_data; | 1302 | data = &_data; |
1302 | memset(data, 0, sizeof(struct mci_platform_data)); | 1303 | memset(data, -1, sizeof(struct mci_platform_data)); |
1304 | data->detect_pin = GPIO_PIN_NONE; | ||
1305 | data->wp_pin = GPIO_PIN_NONE; | ||
1303 | } | 1306 | } |
1304 | 1307 | ||
1305 | if (platform_device_add_data(pdev, data, | 1308 | if (platform_device_add_data(pdev, data, |
@@ -1313,12 +1316,10 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) | |||
1313 | select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */ | 1316 | select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */ |
1314 | select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */ | 1317 | select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */ |
1315 | 1318 | ||
1316 | if (data) { | 1319 | if (gpio_is_valid(data->detect_pin)) |
1317 | if (data->detect_pin != GPIO_PIN_NONE) | 1320 | at32_select_gpio(data->detect_pin, 0); |
1318 | at32_select_gpio(data->detect_pin, 0); | 1321 | if (gpio_is_valid(data->wp_pin)) |
1319 | if (data->wp_pin != GPIO_PIN_NONE) | 1322 | at32_select_gpio(data->wp_pin, 0); |
1320 | at32_select_gpio(data->wp_pin, 0); | ||
1321 | } | ||
1322 | 1323 | ||
1323 | atmel_mci0_pclk.dev = &pdev->dev; | 1324 | atmel_mci0_pclk.dev = &pdev->dev; |
1324 | 1325 | ||
@@ -1852,11 +1853,11 @@ at32_add_device_cf(unsigned int id, unsigned int extint, | |||
1852 | if (at32_init_ide_or_cf(pdev, data->cs, extint)) | 1853 | if (at32_init_ide_or_cf(pdev, data->cs, extint)) |
1853 | goto fail; | 1854 | goto fail; |
1854 | 1855 | ||
1855 | if (data->detect_pin != GPIO_PIN_NONE) | 1856 | if (gpio_is_valid(data->detect_pin)) |
1856 | at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH); | 1857 | at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH); |
1857 | if (data->reset_pin != GPIO_PIN_NONE) | 1858 | if (gpio_is_valid(data->reset_pin)) |
1858 | at32_select_gpio(data->reset_pin, 0); | 1859 | at32_select_gpio(data->reset_pin, 0); |
1859 | if (data->vcc_pin != GPIO_PIN_NONE) | 1860 | if (gpio_is_valid(data->vcc_pin)) |
1860 | at32_select_gpio(data->vcc_pin, 0); | 1861 | at32_select_gpio(data->vcc_pin, 0); |
1861 | /* READY is used as extint, so we can't select it as gpio */ | 1862 | /* READY is used as extint, so we can't select it as gpio */ |
1862 | 1863 | ||
@@ -1870,6 +1871,58 @@ fail: | |||
1870 | #endif | 1871 | #endif |
1871 | 1872 | ||
1872 | /* -------------------------------------------------------------------- | 1873 | /* -------------------------------------------------------------------- |
1874 | * NAND Flash / SmartMedia | ||
1875 | * -------------------------------------------------------------------- */ | ||
1876 | static struct resource smc_cs3_resource[] __initdata = { | ||
1877 | { | ||
1878 | .start = 0x0c000000, | ||
1879 | .end = 0x0fffffff, | ||
1880 | .flags = IORESOURCE_MEM, | ||
1881 | }, { | ||
1882 | .start = 0xfff03c00, | ||
1883 | .end = 0xfff03fff, | ||
1884 | .flags = IORESOURCE_MEM, | ||
1885 | }, | ||
1886 | }; | ||
1887 | |||
1888 | struct platform_device *__init | ||
1889 | at32_add_device_nand(unsigned int id, struct atmel_nand_data *data) | ||
1890 | { | ||
1891 | struct platform_device *pdev; | ||
1892 | |||
1893 | if (id != 0 || !data) | ||
1894 | return NULL; | ||
1895 | |||
1896 | pdev = platform_device_alloc("atmel_nand", id); | ||
1897 | if (!pdev) | ||
1898 | goto fail; | ||
1899 | |||
1900 | if (platform_device_add_resources(pdev, smc_cs3_resource, | ||
1901 | ARRAY_SIZE(smc_cs3_resource))) | ||
1902 | goto fail; | ||
1903 | |||
1904 | if (platform_device_add_data(pdev, data, | ||
1905 | sizeof(struct atmel_nand_data))) | ||
1906 | goto fail; | ||
1907 | |||
1908 | set_ebi_sfr_bits(HMATRIX_BIT(CS3A)); | ||
1909 | if (data->enable_pin) | ||
1910 | at32_select_gpio(data->enable_pin, | ||
1911 | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); | ||
1912 | if (data->rdy_pin) | ||
1913 | at32_select_gpio(data->rdy_pin, 0); | ||
1914 | if (data->det_pin) | ||
1915 | at32_select_gpio(data->det_pin, 0); | ||
1916 | |||
1917 | platform_device_add(pdev); | ||
1918 | return pdev; | ||
1919 | |||
1920 | fail: | ||
1921 | platform_device_put(pdev); | ||
1922 | return NULL; | ||
1923 | } | ||
1924 | |||
1925 | /* -------------------------------------------------------------------- | ||
1873 | * AC97C | 1926 | * AC97C |
1874 | * -------------------------------------------------------------------- */ | 1927 | * -------------------------------------------------------------------- */ |
1875 | static struct resource atmel_ac97c0_resource[] __initdata = { | 1928 | static struct resource atmel_ac97c0_resource[] __initdata = { |
@@ -1884,9 +1937,11 @@ static struct clk atmel_ac97c0_pclk = { | |||
1884 | .index = 10, | 1937 | .index = 10, |
1885 | }; | 1938 | }; |
1886 | 1939 | ||
1887 | struct platform_device *__init at32_add_device_ac97c(unsigned int id) | 1940 | struct platform_device *__init |
1941 | at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data) | ||
1888 | { | 1942 | { |
1889 | struct platform_device *pdev; | 1943 | struct platform_device *pdev; |
1944 | struct ac97c_platform_data _data; | ||
1890 | 1945 | ||
1891 | if (id != 0) | 1946 | if (id != 0) |
1892 | return NULL; | 1947 | return NULL; |
@@ -1897,19 +1952,37 @@ struct platform_device *__init at32_add_device_ac97c(unsigned int id) | |||
1897 | 1952 | ||
1898 | if (platform_device_add_resources(pdev, atmel_ac97c0_resource, | 1953 | if (platform_device_add_resources(pdev, atmel_ac97c0_resource, |
1899 | ARRAY_SIZE(atmel_ac97c0_resource))) | 1954 | ARRAY_SIZE(atmel_ac97c0_resource))) |
1900 | goto err_add_resources; | 1955 | goto fail; |
1956 | |||
1957 | if (!data) { | ||
1958 | data = &_data; | ||
1959 | memset(data, 0, sizeof(struct ac97c_platform_data)); | ||
1960 | data->reset_pin = GPIO_PIN_NONE; | ||
1961 | } | ||
1901 | 1962 | ||
1902 | select_peripheral(PB(20), PERIPH_B, 0); /* SYNC */ | 1963 | data->dma_rx_periph_id = 3; |
1903 | select_peripheral(PB(21), PERIPH_B, 0); /* SDO */ | 1964 | data->dma_tx_periph_id = 4; |
1904 | select_peripheral(PB(22), PERIPH_B, 0); /* SDI */ | 1965 | data->dma_controller_id = 0; |
1905 | select_peripheral(PB(23), PERIPH_B, 0); /* SCLK */ | 1966 | |
1967 | if (platform_device_add_data(pdev, data, | ||
1968 | sizeof(struct ac97c_platform_data))) | ||
1969 | goto fail; | ||
1970 | |||
1971 | select_peripheral(PB(20), PERIPH_B, 0); /* SDO */ | ||
1972 | select_peripheral(PB(21), PERIPH_B, 0); /* SYNC */ | ||
1973 | select_peripheral(PB(22), PERIPH_B, 0); /* SCLK */ | ||
1974 | select_peripheral(PB(23), PERIPH_B, 0); /* SDI */ | ||
1975 | |||
1976 | /* TODO: gpio_is_valid(data->reset_pin) with kernel 2.6.26. */ | ||
1977 | if (data->reset_pin != GPIO_PIN_NONE) | ||
1978 | at32_select_gpio(data->reset_pin, 0); | ||
1906 | 1979 | ||
1907 | atmel_ac97c0_pclk.dev = &pdev->dev; | 1980 | atmel_ac97c0_pclk.dev = &pdev->dev; |
1908 | 1981 | ||
1909 | platform_device_add(pdev); | 1982 | platform_device_add(pdev); |
1910 | return pdev; | 1983 | return pdev; |
1911 | 1984 | ||
1912 | err_add_resources: | 1985 | fail: |
1913 | platform_device_put(pdev); | 1986 | platform_device_put(pdev); |
1914 | return NULL; | 1987 | return NULL; |
1915 | } | 1988 | } |
@@ -2032,7 +2105,7 @@ struct clk *at32_clock_list[] = { | |||
2032 | &smc0_mck, | 2105 | &smc0_mck, |
2033 | &pdc_hclk, | 2106 | &pdc_hclk, |
2034 | &pdc_pclk, | 2107 | &pdc_pclk, |
2035 | &dmaca0_hclk, | 2108 | &dw_dmac0_hclk, |
2036 | &pico_clk, | 2109 | &pico_clk, |
2037 | &pio0_mck, | 2110 | &pio0_mck, |
2038 | &pio1_mck, | 2111 | &pio1_mck, |