2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-04-24 09:51:31 +00:00
|
|
|
/*
|
|
|
|
* DWC SATA platform driver
|
|
|
|
*
|
|
|
|
* (C) Copyright 2016
|
|
|
|
* Texas Instruments Incorporated, <www.ti.com>
|
|
|
|
*
|
|
|
|
* Author: Mugunthan V N <mugunthanvnm@ti.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <ahci.h>
|
|
|
|
#include <scsi.h>
|
|
|
|
#include <sata.h>
|
|
|
|
#include <asm/arch/sata.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <generic-phy.h>
|
|
|
|
|
|
|
|
struct dwc_ahci_priv {
|
|
|
|
void *base;
|
|
|
|
void *wrapper_base;
|
|
|
|
};
|
|
|
|
|
2018-04-06 09:13:53 +00:00
|
|
|
static int dwc_ahci_bind(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct udevice *scsi_dev;
|
|
|
|
|
|
|
|
return ahci_bind_scsi(dev, &scsi_dev);
|
|
|
|
}
|
|
|
|
|
2017-04-24 09:51:31 +00:00
|
|
|
static int dwc_ahci_ofdata_to_platdata(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct dwc_ahci_priv *priv = dev_get_priv(dev);
|
|
|
|
fdt_addr_t addr;
|
|
|
|
|
2017-05-17 23:18:05 +00:00
|
|
|
priv->base = map_physmem(devfdt_get_addr(dev), sizeof(void *),
|
2017-04-24 09:51:31 +00:00
|
|
|
MAP_NOCACHE);
|
|
|
|
|
2017-05-17 23:18:05 +00:00
|
|
|
addr = devfdt_get_addr_index(dev, 1);
|
2017-04-24 09:51:31 +00:00
|
|
|
if (addr != FDT_ADDR_T_NONE) {
|
|
|
|
priv->wrapper_base = map_physmem(addr, sizeof(void *),
|
|
|
|
MAP_NOCACHE);
|
|
|
|
} else {
|
|
|
|
priv->wrapper_base = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc_ahci_probe(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct dwc_ahci_priv *priv = dev_get_priv(dev);
|
|
|
|
int ret;
|
|
|
|
struct phy phy;
|
|
|
|
|
|
|
|
ret = generic_phy_get_by_name(dev, "sata-phy", &phy);
|
|
|
|
if (ret) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("can't get the phy from DT\n");
|
2017-04-24 09:51:31 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = generic_phy_init(&phy);
|
|
|
|
if (ret) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("unable to initialize the sata phy\n");
|
2017-04-24 09:51:31 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = generic_phy_power_on(&phy);
|
|
|
|
if (ret) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("unable to power on the sata phy\n");
|
2017-04-24 09:51:31 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->wrapper_base) {
|
|
|
|
u32 val = TI_SATA_IDLE_NO | TI_SATA_STANDBY_NO;
|
|
|
|
|
|
|
|
/* Enable SATA module, No Idle, No Standby */
|
|
|
|
writel(val, priv->wrapper_base + TI_SATA_SYSCONFIG);
|
|
|
|
}
|
|
|
|
|
2018-04-06 09:13:53 +00:00
|
|
|
return ahci_probe_scsi(dev, (ulong)priv->base);
|
2017-04-24 09:51:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct udevice_id dwc_ahci_ids[] = {
|
|
|
|
{ .compatible = "snps,dwc-ahci" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(dwc_ahci) = {
|
|
|
|
.name = "dwc_ahci",
|
2018-04-06 09:13:53 +00:00
|
|
|
.id = UCLASS_AHCI,
|
2017-04-24 09:51:31 +00:00
|
|
|
.of_match = dwc_ahci_ids,
|
2018-04-06 09:13:53 +00:00
|
|
|
.bind = dwc_ahci_bind,
|
2017-04-24 09:51:31 +00:00
|
|
|
.ofdata_to_platdata = dwc_ahci_ofdata_to_platdata,
|
2017-06-15 03:28:43 +00:00
|
|
|
.ops = &scsi_ops,
|
2017-04-24 09:51:31 +00:00
|
|
|
.probe = dwc_ahci_probe,
|
|
|
|
.priv_auto_alloc_size = sizeof(struct dwc_ahci_priv),
|
|
|
|
};
|