1 // SPDX-License-Identifier: GPL-2.0+
3 * DWC SATA platform driver
6 * Texas Instruments Incorporated, <www.ti.com>
15 #ifdef CONFIG_ARCH_OMAP2PLUS
16 #include <asm/arch/sata.h>
19 #include <generic-phy.h>
20 #include <linux/printk.h>
22 struct dwc_ahci_priv {
27 static int dwc_ahci_bind(struct udevice *dev)
29 struct udevice *scsi_dev;
31 return ahci_bind_scsi(dev, &scsi_dev);
34 static int dwc_ahci_of_to_plat(struct udevice *dev)
36 struct dwc_ahci_priv *priv = dev_get_priv(dev);
39 priv->base = map_physmem(dev_read_addr(dev), sizeof(void *),
42 addr = devfdt_get_addr_index(dev, 1);
43 if (addr != FDT_ADDR_T_NONE) {
44 priv->wrapper_base = map_physmem(addr, sizeof(void *),
47 priv->wrapper_base = NULL;
53 static int dwc_ahci_probe(struct udevice *dev)
55 struct dwc_ahci_priv *priv = dev_get_priv(dev);
59 ret = generic_phy_get_by_name(dev, "sata-phy", &phy);
61 pr_err("can't get the phy from DT\n");
65 ret = generic_phy_init(&phy);
67 pr_debug("unable to initialize the sata phy\n");
71 ret = generic_phy_power_on(&phy);
73 pr_debug("unable to power on the sata phy\n");
77 #ifdef CONFIG_ARCH_OMAP2PLUS
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);
86 return ahci_probe_scsi(dev, (ulong)priv->base);
89 static const struct udevice_id dwc_ahci_ids[] = {
90 { .compatible = "snps,dwc-ahci" },
94 U_BOOT_DRIVER(dwc_ahci) = {
97 .of_match = dwc_ahci_ids,
98 .bind = dwc_ahci_bind,
99 .of_to_plat = dwc_ahci_of_to_plat,
101 .probe = dwc_ahci_probe,
102 .priv_auto = sizeof(struct dwc_ahci_priv),