Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Nicolas Royer and committed by
Herbert Xu
815e9721 6c79294f

+164 -1
+12 -1
arch/arm/mach-at91/at91sam9g45.c
··· 182 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 192 static struct clk *periph_clocks[] __initdata = { 186 193 &pioA_clk, 187 194 &pioB_clk, ··· 218 211 &udphs_clk, 219 212 &mmc1_clk, 220 213 &adc_op_clk, 214 + &aestdessha_clk, 221 215 // irq0 222 216 }; 223 217 ··· 239 231 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), 240 232 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), 241 233 CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk), 234 + CLKDEV_CON_DEV_ID(NULL, "atmel_sha", &aestdessha_clk), 235 + CLKDEV_CON_DEV_ID(NULL, "atmel_tdes", &aestdessha_clk), 236 + CLKDEV_CON_DEV_ID(NULL, "atmel_aes", &aestdessha_clk), 242 237 /* more usart lookup table for DT entries */ 243 238 CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck), 244 239 CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk), ··· 398 387 3, /* Ethernet */ 399 388 0, /* Image Sensor Interface */ 400 389 2, /* USB Device High speed port */ 401 - 0, 390 + 0, /* AESTDESSHA Crypto HW Accelerators */ 402 391 0, /* Multimedia Card Interface 1 */ 403 392 0, 404 393 0, /* Advanced Interrupt Controller (IRQ0) */
+128
arch/arm/mach-at91/at91sam9g45_devices.c
··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/i2c-gpio.h> 20 20 #include <linux/atmel-mci.h> 21 + #include <linux/platform_data/atmel-aes.h> 21 22 22 23 #include <linux/platform_data/at91_adc.h> 23 24 ··· 1831 1830 void __init at91_add_device_serial(void) {} 1832 1831 #endif 1833 1832 1833 + /* -------------------------------------------------------------------- 1834 + * SHA1/SHA256 1835 + * -------------------------------------------------------------------- */ 1836 + 1837 + #if defined(CONFIG_CRYPTO_DEV_ATMEL_SHA) || defined(CONFIG_CRYPTO_DEV_ATMEL_SHA_MODULE) 1838 + static struct resource sha_resources[] = { 1839 + { 1840 + .start = AT91SAM9G45_BASE_SHA, 1841 + .end = AT91SAM9G45_BASE_SHA + SZ_16K - 1, 1842 + .flags = IORESOURCE_MEM, 1843 + }, 1844 + [1] = { 1845 + .start = AT91SAM9G45_ID_AESTDESSHA, 1846 + .end = AT91SAM9G45_ID_AESTDESSHA, 1847 + .flags = IORESOURCE_IRQ, 1848 + }, 1849 + }; 1850 + 1851 + static struct platform_device at91sam9g45_sha_device = { 1852 + .name = "atmel_sha", 1853 + .id = -1, 1854 + .resource = sha_resources, 1855 + .num_resources = ARRAY_SIZE(sha_resources), 1856 + }; 1857 + 1858 + static void __init at91_add_device_sha(void) 1859 + { 1860 + platform_device_register(&at91sam9g45_sha_device); 1861 + } 1862 + #else 1863 + static void __init at91_add_device_sha(void) {} 1864 + #endif 1865 + 1866 + /* -------------------------------------------------------------------- 1867 + * DES/TDES 1868 + * -------------------------------------------------------------------- */ 1869 + 1870 + #if defined(CONFIG_CRYPTO_DEV_ATMEL_TDES) || defined(CONFIG_CRYPTO_DEV_ATMEL_TDES_MODULE) 1871 + static struct resource tdes_resources[] = { 1872 + [0] = { 1873 + .start = AT91SAM9G45_BASE_TDES, 1874 + .end = AT91SAM9G45_BASE_TDES + SZ_16K - 1, 1875 + .flags = IORESOURCE_MEM, 1876 + }, 1877 + [1] = { 1878 + .start = AT91SAM9G45_ID_AESTDESSHA, 1879 + .end = AT91SAM9G45_ID_AESTDESSHA, 1880 + .flags = IORESOURCE_IRQ, 1881 + }, 1882 + }; 1883 + 1884 + static struct platform_device at91sam9g45_tdes_device = { 1885 + .name = "atmel_tdes", 1886 + .id = -1, 1887 + .resource = tdes_resources, 1888 + .num_resources = ARRAY_SIZE(tdes_resources), 1889 + }; 1890 + 1891 + static void __init at91_add_device_tdes(void) 1892 + { 1893 + platform_device_register(&at91sam9g45_tdes_device); 1894 + } 1895 + #else 1896 + static void __init at91_add_device_tdes(void) {} 1897 + #endif 1898 + 1899 + /* -------------------------------------------------------------------- 1900 + * AES 1901 + * -------------------------------------------------------------------- */ 1902 + 1903 + #if defined(CONFIG_CRYPTO_DEV_ATMEL_AES) || defined(CONFIG_CRYPTO_DEV_ATMEL_AES_MODULE) 1904 + static struct aes_platform_data aes_data; 1905 + static u64 aes_dmamask = DMA_BIT_MASK(32); 1906 + 1907 + static struct resource aes_resources[] = { 1908 + [0] = { 1909 + .start = AT91SAM9G45_BASE_AES, 1910 + .end = AT91SAM9G45_BASE_AES + SZ_16K - 1, 1911 + .flags = IORESOURCE_MEM, 1912 + }, 1913 + [1] = { 1914 + .start = AT91SAM9G45_ID_AESTDESSHA, 1915 + .end = AT91SAM9G45_ID_AESTDESSHA, 1916 + .flags = IORESOURCE_IRQ, 1917 + }, 1918 + }; 1919 + 1920 + static struct platform_device at91sam9g45_aes_device = { 1921 + .name = "atmel_aes", 1922 + .id = -1, 1923 + .dev = { 1924 + .dma_mask = &aes_dmamask, 1925 + .coherent_dma_mask = DMA_BIT_MASK(32), 1926 + .platform_data = &aes_data, 1927 + }, 1928 + .resource = aes_resources, 1929 + .num_resources = ARRAY_SIZE(aes_resources), 1930 + }; 1931 + 1932 + static void __init at91_add_device_aes(void) 1933 + { 1934 + struct at_dma_slave *atslave; 1935 + struct aes_dma_data *alt_atslave; 1936 + 1937 + alt_atslave = kzalloc(sizeof(struct aes_dma_data), GFP_KERNEL); 1938 + 1939 + /* DMA TX slave channel configuration */ 1940 + atslave = &alt_atslave->txdata; 1941 + atslave->dma_dev = &at_hdmac_device.dev; 1942 + atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE | ATC_SRC_H2SEL_HW | 1943 + ATC_SRC_PER(AT_DMA_ID_AES_RX); 1944 + 1945 + /* DMA RX slave channel configuration */ 1946 + atslave = &alt_atslave->rxdata; 1947 + atslave->dma_dev = &at_hdmac_device.dev; 1948 + atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE | ATC_DST_H2SEL_HW | 1949 + ATC_DST_PER(AT_DMA_ID_AES_TX); 1950 + 1951 + aes_data.dma_slave = alt_atslave; 1952 + platform_device_register(&at91sam9g45_aes_device); 1953 + } 1954 + #else 1955 + static void __init at91_add_device_aes(void) {} 1956 + #endif 1834 1957 1835 1958 /* -------------------------------------------------------------------- */ 1836 1959 /* ··· 1972 1847 at91_add_device_trng(); 1973 1848 at91_add_device_watchdog(); 1974 1849 at91_add_device_tc(); 1850 + at91_add_device_sha(); 1851 + at91_add_device_tdes(); 1852 + at91_add_device_aes(); 1975 1853 return 0; 1976 1854 } 1977 1855
+2
arch/arm/mach-at91/include/mach/at91sam9g45.h
··· 136 136 #define AT_DMA_ID_SSC1_RX 8 137 137 #define AT_DMA_ID_AC97_TX 9 138 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 141 #define AT_DMA_ID_MCI1 13 140 142 141 143 #endif
+22
include/linux/platform_data/atmel-aes.h
··· 1 + #ifndef __LINUX_ATMEL_AES_H 2 + #define __LINUX_ATMEL_AES_H 3 + 4 + #include <mach/at_hdmac.h> 5 + 6 + /** 7 + * struct aes_dma_data - DMA data for AES 8 + */ 9 + struct aes_dma_data { 10 + struct at_dma_slave txdata; 11 + struct at_dma_slave rxdata; 12 + }; 13 + 14 + /** 15 + * struct aes_platform_data - board-specific AES configuration 16 + * @dma_slave: DMA slave interface to use in data transfers. 17 + */ 18 + struct aes_platform_data { 19 + struct aes_dma_data *dma_slave; 20 + }; 21 + 22 + #endif /* __LINUX_ATMEL_AES_H */