2 * DWC SATA platform driver
5 * Texas Instruments Incorporated, <www.ti.com>
7 * Author: Mugunthan V N <mugunthanvnm@ti.com>
9 * SPDX-License-Identifier: GPL-2.0+
17 #include <asm/arch/sata.h>
19 #include <generic-phy.h>
21 struct dwc_ahci_priv {
26 static int dwc_ahci_bind(struct udevice *dev)
28 struct udevice *scsi_dev;
30 return ahci_bind_scsi(dev, &scsi_dev);
33 static int dwc_ahci_ofdata_to_platdata(struct udevice *dev)
35 struct dwc_ahci_priv *priv = dev_get_priv(dev);
38 priv->base = map_physmem(devfdt_get_addr(dev), sizeof(void *),
41 addr = devfdt_get_addr_index(dev, 1);
42 if (addr != FDT_ADDR_T_NONE) {
43 priv->wrapper_base = map_physmem(addr, sizeof(void *),
46 priv->wrapper_base = NULL;
52 static int dwc_ahci_probe(struct udevice *dev)
54 struct dwc_ahci_priv *priv = dev_get_priv(dev);
58 ret = generic_phy_get_by_name(dev, "sata-phy", &phy);
60 pr_err("can't get the phy from DT\n");
64 ret = generic_phy_init(&phy);
66 pr_err("unable to initialize the sata phy\n");
70 ret = generic_phy_power_on(&phy);
72 pr_err("unable to power on the sata phy\n");
76 if (priv->wrapper_base) {
77 u32 val = TI_SATA_IDLE_NO | TI_SATA_STANDBY_NO;
79 /* Enable SATA module, No Idle, No Standby */
80 writel(val, priv->wrapper_base + TI_SATA_SYSCONFIG);
83 return ahci_probe_scsi(dev, (ulong)priv->base);
86 static const struct udevice_id dwc_ahci_ids[] = {
87 { .compatible = "snps,dwc-ahci" },
91 U_BOOT_DRIVER(dwc_ahci) = {
94 .of_match = dwc_ahci_ids,
95 .bind = dwc_ahci_bind,
96 .ofdata_to_platdata = dwc_ahci_ofdata_to_platdata,
98 .probe = dwc_ahci_probe,
99 .priv_auto_alloc_size = sizeof(struct dwc_ahci_priv),