diff options
author | Nicolas Royer <nicolas@eukrea.com> | 2012-07-01 13:19:43 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-07-10 23:06:16 -0400 |
commit | 815e972110052e8da68b5b5298ca2cd69cb7c3c0 (patch) | |
tree | b5dcd05654224dd65faa1f83a590e5fffe4f41b7 /arch/arm/mach-at91 | |
parent | 6c79294f44fd7d1122cbaabff3b9815b074c0dd0 (diff) |
ARM: AT91SAM9G45: add crypto peripherals
Signed-off-by: Nicolas Royer <nicolas@eukrea.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Eric Bénard <eric@eukrea.com>
Tested-by: Eric Bénard <eric@eukrea.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'arch/arm/mach-at91')
-rw-r--r-- | arch/arm/mach-at91/at91sam9g45.c | 13 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9g45_devices.c | 128 | ||||
-rw-r--r-- | arch/arm/mach-at91/include/mach/at91sam9g45.h | 2 |
3 files changed, 142 insertions, 1 deletions
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c index 4792682d52b9..da6dc0f29657 100644 --- a/arch/arm/mach-at91/at91sam9g45.c +++ b/arch/arm/mach-at91/at91sam9g45.c | |||
@@ -182,6 +182,13 @@ static struct clk adc_op_clk = { | |||
182 | .rate_hz = 13200000, | 182 | .rate_hz = 13200000, |
183 | }; | 183 | }; |
184 | 184 | ||
185 | /* AES/TDES/SHA clock - Only for sam9m11/sam9g56 */ | ||
186 | static struct clk aestdessha_clk = { | ||
187 | .name = "aestdessha_clk", | ||
188 | .pmc_mask = 1 << AT91SAM9G45_ID_AESTDESSHA, | ||
189 | .type = CLK_TYPE_PERIPHERAL, | ||
190 | }; | ||
191 | |||
185 | static struct clk *periph_clocks[] __initdata = { | 192 | static struct clk *periph_clocks[] __initdata = { |
186 | &pioA_clk, | 193 | &pioA_clk, |
187 | &pioB_clk, | 194 | &pioB_clk, |
@@ -211,6 +218,7 @@ static struct clk *periph_clocks[] __initdata = { | |||
211 | &udphs_clk, | 218 | &udphs_clk, |
212 | &mmc1_clk, | 219 | &mmc1_clk, |
213 | &adc_op_clk, | 220 | &adc_op_clk, |
221 | &aestdessha_clk, | ||
214 | // irq0 | 222 | // irq0 |
215 | }; | 223 | }; |
216 | 224 | ||
@@ -231,6 +239,9 @@ static struct clk_lookup periph_clocks_lookups[] = { | |||
231 | CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), | 239 | CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), |
232 | CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), | 240 | CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), |
233 | CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk), | 241 | CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk), |
242 | CLKDEV_CON_DEV_ID(NULL, "atmel_sha", &aestdessha_clk), | ||
243 | CLKDEV_CON_DEV_ID(NULL, "atmel_tdes", &aestdessha_clk), | ||
244 | CLKDEV_CON_DEV_ID(NULL, "atmel_aes", &aestdessha_clk), | ||
234 | /* more usart lookup table for DT entries */ | 245 | /* more usart lookup table for DT entries */ |
235 | CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck), | 246 | CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck), |
236 | CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk), | 247 | CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk), |
@@ -387,7 +398,7 @@ static unsigned int at91sam9g45_default_irq_priority[NR_AIC_IRQS] __initdata = { | |||
387 | 3, /* Ethernet */ | 398 | 3, /* Ethernet */ |
388 | 0, /* Image Sensor Interface */ | 399 | 0, /* Image Sensor Interface */ |
389 | 2, /* USB Device High speed port */ | 400 | 2, /* USB Device High speed port */ |
390 | 0, | 401 | 0, /* AESTDESSHA Crypto HW Accelerators */ |
391 | 0, /* Multimedia Card Interface 1 */ | 402 | 0, /* Multimedia Card Interface 1 */ |
392 | 0, | 403 | 0, |
393 | 0, /* Advanced Interrupt Controller (IRQ0) */ | 404 | 0, /* Advanced Interrupt Controller (IRQ0) */ |
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c index 933fc9afe7d0..7102f62b64ef 100644 --- a/arch/arm/mach-at91/at91sam9g45_devices.c +++ b/arch/arm/mach-at91/at91sam9g45_devices.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/i2c-gpio.h> | 19 | #include <linux/i2c-gpio.h> |
20 | #include <linux/atmel-mci.h> | 20 | #include <linux/atmel-mci.h> |
21 | #include <linux/platform_data/atmel-aes.h> | ||
21 | 22 | ||
22 | #include <linux/platform_data/at91_adc.h> | 23 | #include <linux/platform_data/at91_adc.h> |
23 | 24 | ||
@@ -1830,6 +1831,130 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} | |||
1830 | void __init at91_add_device_serial(void) {} | 1831 | void __init at91_add_device_serial(void) {} |
1831 | #endif | 1832 | #endif |
1832 | 1833 | ||
1834 | /* -------------------------------------------------------------------- | ||
1835 | * SHA1/SHA256 | ||
1836 | * -------------------------------------------------------------------- */ | ||
1837 | |||
1838 | #if defined(CONFIG_CRYPTO_DEV_ATMEL_SHA) || defined(CONFIG_CRYPTO_DEV_ATMEL_SHA_MODULE) | ||
1839 | static struct resource sha_resources[] = { | ||
1840 | { | ||
1841 | .start = AT91SAM9G45_BASE_SHA, | ||
1842 | .end = AT91SAM9G45_BASE_SHA + SZ_16K - 1, | ||
1843 | .flags = IORESOURCE_MEM, | ||
1844 | }, | ||
1845 | [1] = { | ||
1846 | .start = AT91SAM9G45_ID_AESTDESSHA, | ||
1847 | .end = AT91SAM9G45_ID_AESTDESSHA, | ||
1848 | .flags = IORESOURCE_IRQ, | ||
1849 | }, | ||
1850 | }; | ||
1851 | |||
1852 | static struct platform_device at91sam9g45_sha_device = { | ||
1853 | .name = "atmel_sha", | ||
1854 | .id = -1, | ||
1855 | .resource = sha_resources, | ||
1856 | .num_resources = ARRAY_SIZE(sha_resources), | ||
1857 | }; | ||
1858 | |||
1859 | static void __init at91_add_device_sha(void) | ||
1860 | { | ||
1861 | platform_device_register(&at91sam9g45_sha_device); | ||
1862 | } | ||
1863 | #else | ||
1864 | static void __init at91_add_device_sha(void) {} | ||
1865 | #endif | ||
1866 | |||
1867 | /* -------------------------------------------------------------------- | ||
1868 | * DES/TDES | ||
1869 | * -------------------------------------------------------------------- */ | ||
1870 | |||
1871 | #if defined(CONFIG_CRYPTO_DEV_ATMEL_TDES) || defined(CONFIG_CRYPTO_DEV_ATMEL_TDES_MODULE) | ||
1872 | static struct resource tdes_resources[] = { | ||
1873 | [0] = { | ||
1874 | .start = AT91SAM9G45_BASE_TDES, | ||
1875 | .end = AT91SAM9G45_BASE_TDES + SZ_16K - 1, | ||
1876 | .flags = IORESOURCE_MEM, | ||
1877 | }, | ||
1878 | [1] = { | ||
1879 | .start = AT91SAM9G45_ID_AESTDESSHA, | ||
1880 | .end = AT91SAM9G45_ID_AESTDESSHA, | ||
1881 | .flags = IORESOURCE_IRQ, | ||
1882 | }, | ||
1883 | }; | ||
1884 | |||
1885 | static struct platform_device at91sam9g45_tdes_device = { | ||
1886 | .name = "atmel_tdes", | ||
1887 | .id = -1, | ||
1888 | .resource = tdes_resources, | ||
1889 | .num_resources = ARRAY_SIZE(tdes_resources), | ||
1890 | }; | ||
1891 | |||
1892 | static void __init at91_add_device_tdes(void) | ||
1893 | { | ||
1894 | platform_device_register(&at91sam9g45_tdes_device); | ||
1895 | } | ||
1896 | #else | ||
1897 | static void __init at91_add_device_tdes(void) {} | ||
1898 | #endif | ||
1899 | |||
1900 | /* -------------------------------------------------------------------- | ||
1901 | * AES | ||
1902 | * -------------------------------------------------------------------- */ | ||
1903 | |||
1904 | #if defined(CONFIG_CRYPTO_DEV_ATMEL_AES) || defined(CONFIG_CRYPTO_DEV_ATMEL_AES_MODULE) | ||
1905 | static struct aes_platform_data aes_data; | ||
1906 | static u64 aes_dmamask = DMA_BIT_MASK(32); | ||
1907 | |||
1908 | static struct resource aes_resources[] = { | ||
1909 | [0] = { | ||
1910 | .start = AT91SAM9G45_BASE_AES, | ||
1911 | .end = AT91SAM9G45_BASE_AES + SZ_16K - 1, | ||
1912 | .flags = IORESOURCE_MEM, | ||
1913 | }, | ||
1914 | [1] = { | ||
1915 | .start = AT91SAM9G45_ID_AESTDESSHA, | ||
1916 | .end = AT91SAM9G45_ID_AESTDESSHA, | ||
1917 | .flags = IORESOURCE_IRQ, | ||
1918 | }, | ||
1919 | }; | ||
1920 | |||
1921 | static struct platform_device at91sam9g45_aes_device = { | ||
1922 | .name = "atmel_aes", | ||
1923 | .id = -1, | ||
1924 | .dev = { | ||
1925 | .dma_mask = &aes_dmamask, | ||
1926 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
1927 | .platform_data = &aes_data, | ||
1928 | }, | ||
1929 | .resource = aes_resources, | ||
1930 | .num_resources = ARRAY_SIZE(aes_resources), | ||
1931 | }; | ||
1932 | |||
1933 | static void __init at91_add_device_aes(void) | ||
1934 | { | ||
1935 | struct at_dma_slave *atslave; | ||
1936 | struct aes_dma_data *alt_atslave; | ||
1937 | |||
1938 | alt_atslave = kzalloc(sizeof(struct aes_dma_data), GFP_KERNEL); | ||
1939 | |||
1940 | /* DMA TX slave channel configuration */ | ||
1941 | atslave = &alt_atslave->txdata; | ||
1942 | atslave->dma_dev = &at_hdmac_device.dev; | ||
1943 | atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE | ATC_SRC_H2SEL_HW | | ||
1944 | ATC_SRC_PER(AT_DMA_ID_AES_RX); | ||
1945 | |||
1946 | /* DMA RX slave channel configuration */ | ||
1947 | atslave = &alt_atslave->rxdata; | ||
1948 | atslave->dma_dev = &at_hdmac_device.dev; | ||
1949 | atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE | ATC_DST_H2SEL_HW | | ||
1950 | ATC_DST_PER(AT_DMA_ID_AES_TX); | ||
1951 | |||
1952 | aes_data.dma_slave = alt_atslave; | ||
1953 | platform_device_register(&at91sam9g45_aes_device); | ||
1954 | } | ||
1955 | #else | ||
1956 | static void __init at91_add_device_aes(void) {} | ||
1957 | #endif | ||
1833 | 1958 | ||
1834 | /* -------------------------------------------------------------------- */ | 1959 | /* -------------------------------------------------------------------- */ |
1835 | /* | 1960 | /* |
@@ -1847,6 +1972,9 @@ static int __init at91_add_standard_devices(void) | |||
1847 | at91_add_device_trng(); | 1972 | at91_add_device_trng(); |
1848 | at91_add_device_watchdog(); | 1973 | at91_add_device_watchdog(); |
1849 | at91_add_device_tc(); | 1974 | at91_add_device_tc(); |
1975 | at91_add_device_sha(); | ||
1976 | at91_add_device_tdes(); | ||
1977 | at91_add_device_aes(); | ||
1850 | return 0; | 1978 | return 0; |
1851 | } | 1979 | } |
1852 | 1980 | ||
diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45.h b/arch/arm/mach-at91/include/mach/at91sam9g45.h index 3a4da24d5911..8eba1021f533 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9g45.h +++ b/arch/arm/mach-at91/include/mach/at91sam9g45.h | |||
@@ -136,6 +136,8 @@ | |||
136 | #define AT_DMA_ID_SSC1_RX 8 | 136 | #define AT_DMA_ID_SSC1_RX 8 |
137 | #define AT_DMA_ID_AC97_TX 9 | 137 | #define AT_DMA_ID_AC97_TX 9 |
138 | #define AT_DMA_ID_AC97_RX 10 | 138 | #define AT_DMA_ID_AC97_RX 10 |
139 | #define AT_DMA_ID_AES_TX 11 | ||
140 | #define AT_DMA_ID_AES_RX 12 | ||
139 | #define AT_DMA_ID_MCI1 13 | 141 | #define AT_DMA_ID_MCI1 13 |
140 | 142 | ||
141 | #endif | 143 | #endif |