Lines Matching +full:phy +full:- +full:sata3
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Broadcom SATA3 AHCI Controller Driver
5 * Copyright © 2009-2015 Broadcom Corporation
24 #define DRV_NAME "brcm-ahci"
28 #define MMIO_ENDIAN_SHIFT 0 /* CPU->AHCI */
29 #define DMADESC_ENDIAN_SHIFT 2 /* AHCI->DDR */
30 #define DMADATA_ENDIAN_SHIFT 4 /* AHCI->DDR */
51 /* On big-endian MIPS, buses are reversed to big endian, so switch them back */
53 #define DATA_ENDIAN 2 /* AHCI->DDR inbound accesses */
54 #define MMIO_ENDIAN 2 /* CPU->AHCI outbound accesses */
96 * bus endianness (i.e., big-endian CPU + big endian bus ==> native in brcm_sata_readreg()
119 struct brcm_ahci_priv *priv = hpriv->plat_data; in brcm_sata_alpm_init()
124 host_caps = readl(hpriv->mmio + HOST_CAP); in brcm_sata_alpm_init()
126 hpriv->flags |= AHCI_HFLAG_YES_ALPM; in brcm_sata_alpm_init()
135 if (priv->port_mask & BIT(i)) in brcm_sata_alpm_init()
137 hpriv->mmio + SATA_PORT_PCTRL6(port_ctrl)); in brcm_sata_alpm_init()
143 void __iomem *phyctrl = priv->top_ctrl + SATA_TOP_CTRL_PHY_CTRL + in brcm_sata_phy_enable()
148 if (priv->quirks & BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE) in brcm_sata_phy_enable()
157 /* reset the PHY digital logic */ in brcm_sata_phy_enable()
175 void __iomem *phyctrl = priv->top_ctrl + SATA_TOP_CTRL_PHY_CTRL + in brcm_sata_phy_disable()
180 if (priv->quirks & BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE) in brcm_sata_phy_disable()
183 /* power-off the PHY digital logic */ in brcm_sata_phy_disable()
203 if (priv->port_mask & BIT(i)) in brcm_sata_phys_enable()
212 if (priv->port_mask & BIT(i)) in brcm_sata_phys_disable()
221 impl = readl(hpriv->mmio + HOST_PORTS_IMPL); in brcm_ahci_get_portmask()
224 dev_warn(priv->dev, "warning: more ports than PHYs (%#x)\n", in brcm_ahci_get_portmask()
227 dev_info(priv->dev, "no ports found\n"); in brcm_ahci_get_portmask()
234 void __iomem *ctrl = priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL; in brcm_sata_init()
240 if (priv->version == BRCM_SATA_NSP) in brcm_sata_init()
250 struct ata_port *ap = dev->link->ap; in brcm_ahci_read_id()
251 struct ata_host *host = ap->host; in brcm_ahci_read_id()
252 struct ahci_host_priv *hpriv = host->private_data; in brcm_ahci_read_id()
253 struct brcm_ahci_priv *priv = hpriv->plat_data; in brcm_ahci_read_id()
254 void __iomem *mmio = hpriv->mmio; in brcm_ahci_read_id()
268 spin_lock_irqsave(&host->lock, flags); in brcm_ahci_read_id()
273 spin_unlock_irqrestore(&host->lock, flags); in brcm_ahci_read_id()
275 /* Perform the SATA PHY reset sequence */ in brcm_ahci_read_id()
276 brcm_sata_phy_disable(priv, ap->port_no); in brcm_ahci_read_id()
285 /* Bring the PHY back on */ in brcm_ahci_read_id()
286 brcm_sata_phy_enable(priv, ap->port_no); in brcm_ahci_read_id()
288 /* Re-initialize and calibrate the PHY */ in brcm_ahci_read_id()
289 for (i = 0; i < hpriv->nports; i++) { in brcm_ahci_read_id()
290 rc = phy_init(hpriv->phys[i]); in brcm_ahci_read_id()
294 rc = phy_calibrate(hpriv->phys[i]); in brcm_ahci_read_id()
296 phy_exit(hpriv->phys[i]); in brcm_ahci_read_id()
301 /* Re-enable host interrupts */ in brcm_ahci_read_id()
302 spin_lock_irqsave(&host->lock, flags); in brcm_ahci_read_id()
307 spin_unlock_irqrestore(&host->lock, flags); in brcm_ahci_read_id()
312 while (--i >= 0) { in brcm_ahci_read_id()
313 phy_power_off(hpriv->phys[i]); in brcm_ahci_read_id()
314 phy_exit(hpriv->phys[i]); in brcm_ahci_read_id()
322 struct ahci_host_priv *hpriv = host->private_data; in brcm_ahci_host_stop()
344 struct ahci_host_priv *hpriv = host->private_data; in brcm_ahci_suspend()
345 struct brcm_ahci_priv *priv = hpriv->plat_data; in brcm_ahci_suspend()
355 if (priv->version != BRCM_SATA_BCM7216) in brcm_ahci_suspend()
356 reset_control_assert(priv->rcdev); in brcm_ahci_suspend()
364 struct ahci_host_priv *hpriv = host->private_data; in brcm_ahci_resume()
365 struct brcm_ahci_priv *priv = hpriv->plat_data; in brcm_ahci_resume()
368 if (priv->version == BRCM_SATA_BCM7216) in brcm_ahci_resume()
369 ret = reset_control_reset(priv->rcdev); in brcm_ahci_resume()
371 ret = reset_control_deassert(priv->rcdev); in brcm_ahci_resume()
375 /* Make sure clocks are turned on before re-configuration */ in brcm_ahci_resume()
389 * ahci_platform_resume() as-is since a second call to in brcm_ahci_resume()
424 {.compatible = "brcm,bcm7425-ahci", .data = (void *)BRCM_SATA_BCM7425},
425 {.compatible = "brcm,bcm7445-ahci", .data = (void *)BRCM_SATA_BCM7445},
426 {.compatible = "brcm,bcm63138-ahci", .data = (void *)BRCM_SATA_BCM7445},
427 {.compatible = "brcm,bcm-nsp-ahci", .data = (void *)BRCM_SATA_NSP},
428 {.compatible = "brcm,bcm7216-ahci", .data = (void *)BRCM_SATA_BCM7216},
436 struct device *dev = &pdev->dev; in brcm_ahci_probe()
445 return -ENOMEM; in brcm_ahci_probe()
447 of_id = of_match_node(ahci_of_match, pdev->dev.of_node); in brcm_ahci_probe()
449 return -ENODEV; in brcm_ahci_probe()
451 priv->version = (enum brcm_ahci_version)of_id->data; in brcm_ahci_probe()
452 priv->dev = dev; in brcm_ahci_probe()
454 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "top-ctrl"); in brcm_ahci_probe()
455 priv->top_ctrl = devm_ioremap_resource(dev, res); in brcm_ahci_probe()
456 if (IS_ERR(priv->top_ctrl)) in brcm_ahci_probe()
457 return PTR_ERR(priv->top_ctrl); in brcm_ahci_probe()
460 if (priv->version == BRCM_SATA_BCM7216) in brcm_ahci_probe()
465 priv->rcdev = devm_reset_control_get_optional(&pdev->dev, reset_name); in brcm_ahci_probe()
466 if (IS_ERR(priv->rcdev)) in brcm_ahci_probe()
467 return PTR_ERR(priv->rcdev); in brcm_ahci_probe()
473 hpriv->plat_data = priv; in brcm_ahci_probe()
474 hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP | AHCI_HFLAG_NO_WRITE_TO_RO; in brcm_ahci_probe()
476 switch (priv->version) { in brcm_ahci_probe()
478 hpriv->flags |= AHCI_HFLAG_DELAY_ENGINE; in brcm_ahci_probe()
481 hpriv->flags |= AHCI_HFLAG_NO_NCQ; in brcm_ahci_probe()
482 priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE; in brcm_ahci_probe()
488 if (priv->version == BRCM_SATA_BCM7216) in brcm_ahci_probe()
489 ret = reset_control_reset(priv->rcdev); in brcm_ahci_probe()
491 ret = reset_control_deassert(priv->rcdev); in brcm_ahci_probe()
508 /* Initializes priv->port_mask which is used below */ in brcm_ahci_probe()
509 priv->port_mask = brcm_ahci_get_portmask(hpriv, priv); in brcm_ahci_probe()
510 if (!priv->port_mask) { in brcm_ahci_probe()
511 ret = -ENODEV; in brcm_ahci_probe()
529 dev_info(dev, "Broadcom AHCI SATA3 registered\n"); in brcm_ahci_probe()
542 if (priv->version != BRCM_SATA_BCM7216) in brcm_ahci_probe()
543 reset_control_assert(priv->rcdev); in brcm_ahci_probe()
549 struct ata_host *host = dev_get_drvdata(&pdev->dev); in brcm_ahci_remove()
550 struct ahci_host_priv *hpriv = host->private_data; in brcm_ahci_remove()
551 struct brcm_ahci_priv *priv = hpriv->plat_data; in brcm_ahci_remove()
572 ret = brcm_ahci_suspend(&pdev->dev); in brcm_ahci_shutdown()
574 dev_err(&pdev->dev, "failed to shutdown\n"); in brcm_ahci_shutdown()
591 MODULE_DESCRIPTION("Broadcom SATA3 AHCI Controller Driver");
594 MODULE_ALIAS("platform:sata-brcmstb");