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 DECLARE_GLOBAL_DATA_PTR;
23 struct dwc_ahci_priv {
28 static int dwc_ahci_bind(struct udevice *dev)
30 struct udevice *scsi_dev;
32 return ahci_bind_scsi(dev, &scsi_dev);
35 static int dwc_ahci_ofdata_to_platdata(struct udevice *dev)
37 struct dwc_ahci_priv *priv = dev_get_priv(dev);
40 priv->base = map_physmem(devfdt_get_addr(dev), sizeof(void *),
43 addr = devfdt_get_addr_index(dev, 1);
44 if (addr != FDT_ADDR_T_NONE) {
45 priv->wrapper_base = map_physmem(addr, sizeof(void *),
48 priv->wrapper_base = NULL;
54 static int dwc_ahci_probe(struct udevice *dev)
56 struct dwc_ahci_priv *priv = dev_get_priv(dev);
60 ret = generic_phy_get_by_name(dev, "sata-phy", &phy);
62 pr_err("can't get the phy from DT\n");
66 ret = generic_phy_init(&phy);
68 pr_err("unable to initialize the sata phy\n");
72 ret = generic_phy_power_on(&phy);
74 pr_err("unable to power on the sata phy\n");
78 if (priv->wrapper_base) {
79 u32 val = TI_SATA_IDLE_NO | TI_SATA_STANDBY_NO;
81 /* Enable SATA module, No Idle, No Standby */
82 writel(val, priv->wrapper_base + TI_SATA_SYSCONFIG);
85 return ahci_probe_scsi(dev, (ulong)priv->base);
88 static const struct udevice_id dwc_ahci_ids[] = {
89 { .compatible = "snps,dwc-ahci" },
93 U_BOOT_DRIVER(dwc_ahci) = {
96 .of_match = dwc_ahci_ids,
97 .bind = dwc_ahci_bind,
98 .ofdata_to_platdata = dwc_ahci_ofdata_to_platdata,
100 .probe = dwc_ahci_probe,
101 .priv_auto_alloc_size = sizeof(struct dwc_ahci_priv),