diff options
Diffstat (limited to 'arch/arm/mach-davinci/devices-da8xx.c')
-rw-r--r-- | arch/arm/mach-davinci/devices-da8xx.c | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index fc4e98ea7543..2f7e719636f1 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/dma-mapping.h> | 15 | #include <linux/dma-mapping.h> |
16 | #include <linux/serial_8250.h> | 16 | #include <linux/serial_8250.h> |
17 | #include <linux/ahci_platform.h> | ||
18 | #include <linux/clk.h> | ||
17 | 19 | ||
18 | #include <mach/cputype.h> | 20 | #include <mach/cputype.h> |
19 | #include <mach/common.h> | 21 | #include <mach/common.h> |
@@ -33,6 +35,7 @@ | |||
33 | #define DA8XX_SPI0_BASE 0x01c41000 | 35 | #define DA8XX_SPI0_BASE 0x01c41000 |
34 | #define DA830_SPI1_BASE 0x01e12000 | 36 | #define DA830_SPI1_BASE 0x01e12000 |
35 | #define DA8XX_LCD_CNTRL_BASE 0x01e13000 | 37 | #define DA8XX_LCD_CNTRL_BASE 0x01e13000 |
38 | #define DA850_SATA_BASE 0x01e18000 | ||
36 | #define DA850_MMCSD1_BASE 0x01e1b000 | 39 | #define DA850_MMCSD1_BASE 0x01e1b000 |
37 | #define DA8XX_EMAC_CPPI_PORT_BASE 0x01e20000 | 40 | #define DA8XX_EMAC_CPPI_PORT_BASE 0x01e20000 |
38 | #define DA8XX_EMAC_CPGMACSS_BASE 0x01e22000 | 41 | #define DA8XX_EMAC_CPGMACSS_BASE 0x01e22000 |
@@ -842,3 +845,126 @@ int __init da8xx_register_spi(int instance, struct spi_board_info *info, | |||
842 | 845 | ||
843 | return platform_device_register(&da8xx_spi_device[instance]); | 846 | return platform_device_register(&da8xx_spi_device[instance]); |
844 | } | 847 | } |
848 | |||
849 | #ifdef CONFIG_ARCH_DAVINCI_DA850 | ||
850 | |||
851 | static struct resource da850_sata_resources[] = { | ||
852 | { | ||
853 | .start = DA850_SATA_BASE, | ||
854 | .end = DA850_SATA_BASE + 0x1fff, | ||
855 | .flags = IORESOURCE_MEM, | ||
856 | }, | ||
857 | { | ||
858 | .start = IRQ_DA850_SATAINT, | ||
859 | .flags = IORESOURCE_IRQ, | ||
860 | }, | ||
861 | }; | ||
862 | |||
863 | /* SATA PHY Control Register offset from AHCI base */ | ||
864 | #define SATA_P0PHYCR_REG 0x178 | ||
865 | |||
866 | #define SATA_PHY_MPY(x) ((x) << 0) | ||
867 | #define SATA_PHY_LOS(x) ((x) << 6) | ||
868 | #define SATA_PHY_RXCDR(x) ((x) << 10) | ||
869 | #define SATA_PHY_RXEQ(x) ((x) << 13) | ||
870 | #define SATA_PHY_TXSWING(x) ((x) << 19) | ||
871 | #define SATA_PHY_ENPLL(x) ((x) << 31) | ||
872 | |||
873 | static struct clk *da850_sata_clk; | ||
874 | static unsigned long da850_sata_refclkpn; | ||
875 | |||
876 | /* Supported DA850 SATA crystal frequencies */ | ||
877 | #define KHZ_TO_HZ(freq) ((freq) * 1000) | ||
878 | static unsigned long da850_sata_xtal[] = { | ||
879 | KHZ_TO_HZ(300000), | ||
880 | KHZ_TO_HZ(250000), | ||
881 | 0, /* Reserved */ | ||
882 | KHZ_TO_HZ(187500), | ||
883 | KHZ_TO_HZ(150000), | ||
884 | KHZ_TO_HZ(125000), | ||
885 | KHZ_TO_HZ(120000), | ||
886 | KHZ_TO_HZ(100000), | ||
887 | KHZ_TO_HZ(75000), | ||
888 | KHZ_TO_HZ(60000), | ||
889 | }; | ||
890 | |||
891 | static int da850_sata_init(struct device *dev, void __iomem *addr) | ||
892 | { | ||
893 | int i, ret; | ||
894 | unsigned int val; | ||
895 | |||
896 | da850_sata_clk = clk_get(dev, NULL); | ||
897 | if (IS_ERR(da850_sata_clk)) | ||
898 | return PTR_ERR(da850_sata_clk); | ||
899 | |||
900 | ret = clk_enable(da850_sata_clk); | ||
901 | if (ret) | ||
902 | goto err0; | ||
903 | |||
904 | /* Enable SATA clock receiver */ | ||
905 | val = __raw_readl(DA8XX_SYSCFG1_VIRT(DA8XX_PWRDN_REG)); | ||
906 | val &= ~BIT(0); | ||
907 | __raw_writel(val, DA8XX_SYSCFG1_VIRT(DA8XX_PWRDN_REG)); | ||
908 | |||
909 | /* Get the multiplier needed for 1.5GHz PLL output */ | ||
910 | for (i = 0; i < ARRAY_SIZE(da850_sata_xtal); i++) | ||
911 | if (da850_sata_xtal[i] == da850_sata_refclkpn) | ||
912 | break; | ||
913 | |||
914 | if (i == ARRAY_SIZE(da850_sata_xtal)) { | ||
915 | ret = -EINVAL; | ||
916 | goto err1; | ||
917 | } | ||
918 | |||
919 | val = SATA_PHY_MPY(i + 1) | | ||
920 | SATA_PHY_LOS(1) | | ||
921 | SATA_PHY_RXCDR(4) | | ||
922 | SATA_PHY_RXEQ(1) | | ||
923 | SATA_PHY_TXSWING(3) | | ||
924 | SATA_PHY_ENPLL(1); | ||
925 | |||
926 | __raw_writel(val, addr + SATA_P0PHYCR_REG); | ||
927 | |||
928 | return 0; | ||
929 | |||
930 | err1: | ||
931 | clk_disable(da850_sata_clk); | ||
932 | err0: | ||
933 | clk_put(da850_sata_clk); | ||
934 | return ret; | ||
935 | } | ||
936 | |||
937 | static void da850_sata_exit(struct device *dev) | ||
938 | { | ||
939 | clk_disable(da850_sata_clk); | ||
940 | clk_put(da850_sata_clk); | ||
941 | } | ||
942 | |||
943 | static struct ahci_platform_data da850_sata_pdata = { | ||
944 | .init = da850_sata_init, | ||
945 | .exit = da850_sata_exit, | ||
946 | }; | ||
947 | |||
948 | static u64 da850_sata_dmamask = DMA_BIT_MASK(32); | ||
949 | |||
950 | static struct platform_device da850_sata_device = { | ||
951 | .name = "ahci", | ||
952 | .id = -1, | ||
953 | .dev = { | ||
954 | .platform_data = &da850_sata_pdata, | ||
955 | .dma_mask = &da850_sata_dmamask, | ||
956 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
957 | }, | ||
958 | .num_resources = ARRAY_SIZE(da850_sata_resources), | ||
959 | .resource = da850_sata_resources, | ||
960 | }; | ||
961 | |||
962 | int __init da850_register_sata(unsigned long refclkpn) | ||
963 | { | ||
964 | da850_sata_refclkpn = refclkpn; | ||
965 | if (!da850_sata_refclkpn) | ||
966 | return -EINVAL; | ||
967 | |||
968 | return platform_device_register(&da850_sata_device); | ||
969 | } | ||
970 | #endif | ||