21 #include <mach/irqs.h>
26 #define SATA_CTRL0 0x0
28 #define SATA_CTRL1 0x4
30 #define SATA_PHY_STATUS 0x8
32 #define SATA_CTRL0_RX_DATA_VALID(x) (x << 27)
33 #define SATA_CTRL0_SPEED_MODE (1 << 26)
34 #define SATA_CTRL0_M_PHY_CAL (1 << 19)
35 #define SATA_CTRL0_PHY_CMU_RST_N (1 << 10)
36 #define SATA_CTRL0_M_PHY_LN_RST_N (1 << 9)
37 #define SATA_CTRL0_PHY_POR_N (1 << 8)
39 #define SATA_CTRL1_RST_PMALIVE_N (1 << 8)
40 #define SATA_CTRL1_RST_RXOOB_N (1 << 7)
41 #define SATA_CTRL1_RST_RX_N (1 << 6)
42 #define SATA_CTRL1_RST_TX_N (1 << 5)
44 #define SATA_PHY_STATUS_CMU_OK (1 << 18)
45 #define SATA_PHY_STATUS_LANE_OK (1 << 16)
48 #define COM_LANE 0xA00
50 #define HOST_PORTS_IMPL 0xC
51 #define SCLK_SATA_FREQ (67 * MHZ)
53 static void __iomem *phy_base, *phy_ctrl;
61 static const struct phy_reg exynos4_sataphy_cmu[] = {
62 { 0x00, 0x06 }, { 0x02, 0x80 }, { 0x22, 0xa0 }, { 0x23, 0x42 },
63 { 0x2e, 0x04 }, { 0x2f, 0x50 }, { 0x30, 0x70 }, { 0x31, 0x02 },
64 { 0x32, 0x25 }, { 0x33, 0x40 }, { 0x34, 0x01 }, { 0x35, 0x40 },
65 { 0x61, 0x2e }, { 0x63, 0x5e }, { 0x65, 0x42 }, { 0x66, 0xd1 },
66 { 0x67, 0x20 }, { 0x68, 0x28 }, { 0x69, 0x78 }, { 0x6a, 0x04 },
67 { 0x6b, 0xc8 }, { 0x6c, 0x06 },
70 static const struct phy_reg exynos4_sataphy_lane[] = {
71 { 0x00, 0x02 }, { 0x05, 0x10 }, { 0x06, 0x84 }, { 0x07, 0x04 },
72 { 0x08, 0xe0 }, { 0x10, 0x23 }, { 0x13, 0x05 }, { 0x14, 0x30 },
73 { 0x15, 0x00 }, { 0x17, 0x70 }, { 0x18, 0xf2 }, { 0x19, 0x1e },
74 { 0x1a, 0x18 }, { 0x1b, 0x0d }, { 0x1c, 0x08 }, { 0x50, 0x60 },
78 static const struct phy_reg exynos4_sataphy_comlane[] = {
79 { 0x01, 0x20 }, { 0x03, 0x40 }, { 0x04, 0x3c }, { 0x05, 0x7d },
80 { 0x06, 0x1d }, { 0x07, 0xcf }, { 0x08, 0x05 }, { 0x09, 0x63 },
81 { 0x0a, 0x29 }, { 0x0b, 0xc4 }, { 0x0c, 0x01 }, { 0x0d, 0x03 },
82 { 0x0e, 0x28 }, { 0x0f, 0x98 }, { 0x10, 0x19 }, { 0x13, 0x80 },
83 { 0x14, 0xf0 }, { 0x15, 0xd0 }, { 0x39, 0xa0 }, { 0x3a, 0xa0 },
84 { 0x3b, 0xa0 }, { 0x3c, 0xa0 }, { 0x3d, 0xa0 }, { 0x3e, 0xa0 },
85 { 0x3f, 0xa0 }, { 0x40, 0x42 }, { 0x42, 0x80 }, { 0x43, 0x58 },
86 { 0x45, 0x44 }, { 0x46, 0x5c }, { 0x47, 0x86 }, { 0x48, 0x8d },
87 { 0x49, 0xd0 }, { 0x4a, 0x09 }, { 0x4b, 0x90 }, { 0x4c, 0x07 },
88 { 0x4d, 0x40 }, { 0x51, 0x20 }, { 0x52, 0x32 }, { 0x7f, 0xd8 },
89 { 0x80, 0x1a }, { 0x81, 0xff }, { 0x82, 0x11 }, { 0x83, 0x00 },
90 { 0x87, 0xf0 }, { 0x87, 0xff }, { 0x87, 0xff }, { 0x87, 0xff },
91 { 0x87, 0xff }, { 0x8c, 0x1c }, { 0x8d, 0xc2 }, { 0x8e, 0xc3 },
92 { 0x8f, 0x3f }, { 0x90, 0x0a }, { 0x96, 0xf8 },
95 static int wait_for_phy_ready(
void __iomem *
reg,
unsigned long bit)
109 static int ahci_phy_init(
void __iomem *mmio)
113 for (i = 0; i <
ARRAY_SIZE(exynos4_sataphy_cmu); i++)
115 phy_base + (exynos4_sataphy_cmu[i].reg * 4));
117 for (i = 0; i <
ARRAY_SIZE(exynos4_sataphy_lane); i++)
119 phy_base + (
LANE0 + exynos4_sataphy_lane[i].reg) * 4);
121 for (i = 0; i <
ARRAY_SIZE(exynos4_sataphy_comlane); i++)
123 phy_base + (
COM_LANE + exynos4_sataphy_comlane[i].reg) * 4);
158 struct clk *clk_sata, *clk_sataphy, *clk_sclk_sata;
163 dev_err(dev,
"failed to allocate memory for SATA PHY\n");
169 dev_err(dev,
"failed to allocate memory for SATA PHY CTRL\n");
174 clk_sata =
clk_get(dev,
"sata");
175 if (IS_ERR(clk_sata)) {
176 dev_err(dev,
"failed to get sata clock\n");
177 ret = PTR_ERR(clk_sata);
184 clk_sataphy =
clk_get(dev,
"sataphy");
185 if (IS_ERR(clk_sataphy)) {
186 dev_err(dev,
"failed to get sataphy clock\n");
187 ret = PTR_ERR(clk_sataphy);
193 clk_sclk_sata =
clk_get(dev,
"sclk_sata");
194 if (IS_ERR(clk_sclk_sata)) {
195 dev_err(dev,
"failed to get sclk_sata\n");
196 ret = PTR_ERR(clk_sclk_sata);
197 clk_sclk_sata =
NULL;
218 return ahci_phy_init(mmio);
235 .init = exynos4_ahci_init,
238 static struct resource exynos4_ahci_resource[] = {
248 .resource = exynos4_ahci_resource,
249 .num_resources =
ARRAY_SIZE(exynos4_ahci_resource),
251 .platform_data = &exynos4_ahci_pdata,
252 .dma_mask = &exynos4_ahci_dmamask,