19 #include <linux/kernel.h>
21 #include <linux/module.h>
23 #include <linux/types.h>
27 #include <linux/device.h>
35 #include <linux/export.h>
38 #define CPHY_MAP(dev, addr) ((((dev) & 0x1f) << 7) | (((addr) >> 9) & 0x7f))
39 #define CPHY_ADDR(addr) (((addr) & 0x1ff) << 2)
40 #define SERDES_CR_CTL 0x80a0
41 #define SERDES_CR_ADDR 0x80a1
42 #define SERDES_CR_DATA 0x80a2
43 #define CR_BUSY 0x0001
44 #define CR_START 0x0001
45 #define CR_WR_RDN 0x0002
46 #define CPHY_RX_INPUT_STS 0x2002
47 #define CPHY_SATA_OVERRIDE 0x4000
48 #define CPHY_OVERRIDE 0x2005
49 #define SPHY_LANE 0x100
50 #define SPHY_HALF_RATE 0x0001
51 #define CPHY_SATA_DPLL_MODE 0x0700
52 #define CPHY_SATA_DPLL_SHIFT 8
53 #define CPHY_SATA_DPLL_RESET (1 << 11)
54 #define CPHY_PHY_COUNT 6
55 #define CPHY_LANE_COUNT 4
56 #define CPHY_PORT_COUNT (CPHY_PHY_COUNT * CPHY_LANE_COUNT)
72 u8 dev = port_data[sata_port].phy_devs;
73 spin_lock(&cphy_lock);
76 spin_unlock(&cphy_lock);
80 static void __combo_phy_reg_write(
u8 sata_port,
u32 addr,
u32 data)
82 u8 dev = port_data[sata_port].phy_devs;
83 spin_lock(&cphy_lock);
86 spin_unlock(&cphy_lock);
89 static void combo_phy_wait_for_ready(
u8 sata_port)
95 static u32 combo_phy_read(
u8 sata_port,
u32 addr)
97 combo_phy_wait_for_ready(sata_port);
100 combo_phy_wait_for_ready(sata_port);
104 static void combo_phy_write(
u8 sata_port,
u32 addr,
u32 data)
106 combo_phy_wait_for_ready(sata_port);
112 static void highbank_cphy_disable_overrides(
u8 sata_port)
114 u8 lane = port_data[sata_port].lane_mapping;
123 static void cphy_override_rx_mode(
u8 sata_port,
u32 val)
125 u8 lane = port_data[sata_port].lane_mapping;
147 static void highbank_cphy_override_lane(
u8 sata_port)
149 u8 lane = port_data[sata_port].lane_mapping;
158 cphy_override_rx_mode(sata_port, 3);
161 static int highbank_initialize_phys(
struct device *dev,
void __iomem *addr)
164 int phy_count = 0,
phy,
port = 0;
174 "calxeda,port-phys",
"#phy-cells",
178 if (phy_nodes[
phy] == phy_data.np)
182 phy_nodes[
phy] = phy_data.np;
189 port_data[
port].lane_mapping = phy_data.args[0];
190 of_property_read_u32(phy_nodes[
phy],
"phydev", &tmp);
191 port_data[
port].phy_devs =
tmp;
192 port_data[
port].phy_base = cphy_base[
phy];
193 of_node_put(phy_data.np);
199 static int ahci_highbank_hardreset(
struct ata_link *
link,
unsigned int *
class,
200 unsigned long deadline)
220 highbank_cphy_disable_overrides(link->
ap->port_no);
222 highbank_cphy_override_lane(link->
ap->port_no);
229 if (!(sstatus & 0x3))
231 }
while (!online && retry--);
236 *
class = ahci_dev_classify(ap);
243 .hardreset = ahci_highbank_hardreset,
246 static const struct ata_port_info ahci_highbank_port_info = {
250 .port_ops = &ahci_highbank_ops,
258 { .compatible =
"calxeda,hb-ahci" },
278 dev_err(dev,
"no mmio space\n");
290 dev_err(dev,
"can't alloc ahci_host_priv\n");
298 dev_err(dev,
"can't map %pR\n", mem);
302 rc = highbank_initialize_phys(dev, hpriv->
mmio);
339 for (i = 0; i < host->
n_ports; i++) {
362 &ahci_highbank_platform_sht);
381 #ifdef CONFIG_PM_SLEEP
382 static int ahci_highbank_suspend(
struct device *dev)
391 dev_err(dev,
"firmware update required for suspend/resume\n");
412 static int ahci_highbank_resume(
struct device *dev)
425 ata_host_resume(host);
432 ahci_highbank_suspend, ahci_highbank_resume);
437 .name =
"highbank-ahci",
439 .of_match_table = ahci_of_match,
440 .pm = &ahci_highbank_pm_ops,
442 .probe = ahci_highbank_probe,