1 // SPDX-License-Identifier: GPL-2.0+
3 * DWC SATA platform driver
6 * Texas Instruments Incorporated, <www.ti.com>
16 #include <asm/arch/sata.h>
18 #include <generic-phy.h>
20 struct dwc_ahci_priv {
25 static int dwc_ahci_bind(struct udevice *dev)
27 struct udevice *scsi_dev;
29 return ahci_bind_scsi(dev, &scsi_dev);
32 static int dwc_ahci_ofdata_to_platdata(struct udevice *dev)
34 struct dwc_ahci_priv *priv = dev_get_priv(dev);
37 priv->base = map_physmem(devfdt_get_addr(dev), sizeof(void *),
40 addr = devfdt_get_addr_index(dev, 1);
41 if (addr != FDT_ADDR_T_NONE) {
42 priv->wrapper_base = map_physmem(addr, sizeof(void *),
45 priv->wrapper_base = NULL;
51 static int dwc_ahci_probe(struct udevice *dev)
53 struct dwc_ahci_priv *priv = dev_get_priv(dev);
57 ret = generic_phy_get_by_name(dev, "sata-phy", &phy);
59 pr_err("can't get the phy from DT\n");
63 ret = generic_phy_init(&phy);
65 pr_err("unable to initialize the sata phy\n");
69 ret = generic_phy_power_on(&phy);
71 pr_err("unable to power on the sata phy\n");
75 if (priv->wrapper_base) {
76 u32 val = TI_SATA_IDLE_NO | TI_SATA_STANDBY_NO;
78 /* Enable SATA module, No Idle, No Standby */
79 writel(val, priv->wrapper_base + TI_SATA_SYSCONFIG);
82 return ahci_probe_scsi(dev, (ulong)priv->base);
85 static const struct udevice_id dwc_ahci_ids[] = {
86 { .compatible = "snps,dwc-ahci" },
90 U_BOOT_DRIVER(dwc_ahci) = {
93 .of_match = dwc_ahci_ids,
94 .bind = dwc_ahci_bind,
95 .ofdata_to_platdata = dwc_ahci_ofdata_to_platdata,
97 .probe = dwc_ahci_probe,
98 .priv_auto_alloc_size = sizeof(struct dwc_ahci_priv),