提交 0f48debd 编写于 作者: M Mans Rullgard 提交者: Tejun Heo

ata: sata_dwc_460ex: add phy support

This adds support for powering on an optional PHY when activating the
device.
Tested-by: NChristian Lamparter <chunkeey@googlemail.com>
Signed-off-by: NMans Rullgard <mans@mansr.com>
Signed-off-by: NTejun Heo <tj@kernel.org>
上级 50b43375
...@@ -305,6 +305,7 @@ config ATA_PIIX ...@@ -305,6 +305,7 @@ config ATA_PIIX
config SATA_DWC config SATA_DWC
tristate "DesignWare Cores SATA support" tristate "DesignWare Cores SATA support"
select GENERIC_PHY
help help
This option enables support for the on-chip SATA controller of the This option enables support for the on-chip SATA controller of the
AppliedMicro processor 460EX. AppliedMicro processor 460EX.
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/phy/phy.h>
#include <linux/libata.h> #include <linux/libata.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -145,6 +146,7 @@ struct sata_dwc_device { ...@@ -145,6 +146,7 @@ struct sata_dwc_device {
struct ata_host *host; struct ata_host *host;
u8 __iomem *reg_base; u8 __iomem *reg_base;
struct sata_dwc_regs *sata_dwc_regs; /* DW Synopsys SATA specific */ struct sata_dwc_regs *sata_dwc_regs; /* DW Synopsys SATA specific */
struct phy *phy;
#ifdef CONFIG_SATA_DWC_OLD_DMA #ifdef CONFIG_SATA_DWC_OLD_DMA
struct dw_dma_chip *dma; struct dw_dma_chip *dma;
#endif #endif
...@@ -948,6 +950,10 @@ static int sata_dwc_port_start(struct ata_port *ap) ...@@ -948,6 +950,10 @@ static int sata_dwc_port_start(struct ata_port *ap)
if (err) if (err)
goto CLEANUP_ALLOC; goto CLEANUP_ALLOC;
err = phy_power_on(hsdev->phy);
if (err)
goto CLEANUP_ALLOC;
for (i = 0; i < SATA_DWC_QCMD_MAX; i++) for (i = 0; i < SATA_DWC_QCMD_MAX; i++)
hsdevp->cmd_issued[i] = SATA_DWC_CMD_ISSUED_NOT; hsdevp->cmd_issued[i] = SATA_DWC_CMD_ISSUED_NOT;
...@@ -983,11 +989,13 @@ static int sata_dwc_port_start(struct ata_port *ap) ...@@ -983,11 +989,13 @@ static int sata_dwc_port_start(struct ata_port *ap)
static void sata_dwc_port_stop(struct ata_port *ap) static void sata_dwc_port_stop(struct ata_port *ap)
{ {
struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap); struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap);
struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap);
dev_dbg(ap->dev, "%s: ap->id = %d\n", __func__, ap->print_id); dev_dbg(ap->dev, "%s: ap->id = %d\n", __func__, ap->print_id);
dmaengine_terminate_all(hsdevp->chan); dmaengine_terminate_all(hsdevp->chan);
dma_release_channel(hsdevp->chan); dma_release_channel(hsdevp->chan);
phy_power_off(hsdev->phy);
kfree(hsdevp); kfree(hsdevp);
ap->private_data = NULL; ap->private_data = NULL;
...@@ -1321,6 +1329,17 @@ static int sata_dwc_probe(struct platform_device *ofdev) ...@@ -1321,6 +1329,17 @@ static int sata_dwc_probe(struct platform_device *ofdev)
} }
#endif #endif
hsdev->phy = devm_phy_optional_get(hsdev->dev, "sata-phy");
if (IS_ERR(hsdev->phy)) {
err = PTR_ERR(hsdev->phy);
hsdev->phy = NULL;
goto error_out;
}
err = phy_init(hsdev->phy);
if (err)
goto error_out;
/* /*
* Now, register with libATA core, this will also initiate the * Now, register with libATA core, this will also initiate the
* device discovery process, invoking our port_start() handler & * device discovery process, invoking our port_start() handler &
...@@ -1334,6 +1353,7 @@ static int sata_dwc_probe(struct platform_device *ofdev) ...@@ -1334,6 +1353,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
return 0; return 0;
error_out: error_out:
phy_exit(hsdev->phy);
iounmap(base); iounmap(base);
return err; return err;
} }
...@@ -1346,6 +1366,8 @@ static int sata_dwc_remove(struct platform_device *ofdev) ...@@ -1346,6 +1366,8 @@ static int sata_dwc_remove(struct platform_device *ofdev)
ata_host_detach(host); ata_host_detach(host);
phy_exit(hsdev->phy);
#ifdef CONFIG_SATA_DWC_OLD_DMA #ifdef CONFIG_SATA_DWC_OLD_DMA
/* Free SATA DMA resources */ /* Free SATA DMA resources */
sata_dwc_dma_exit_old(hsdev); sata_dwc_dma_exit_old(hsdev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册