From: Andrew Lunn <andrew@lunn.ch> To: Jason Cooper <jason@lakedaemon.net>, kishon@ti.com Cc: devicetree@vger.kernel.org, linux-ide@vger.kernel.org, Gregory Clement <gregory.clement@free-electrons.com>, Sebastian Hesselbarth <sebastian.hesselbarth@googlemail.com>, linux ARM <linux-arm-kernel@lists.infradead.org>, Andrew Lunn <andrew@lunn.ch> Subject: [PATCH v2 3/4] SATA: MV: Add support for the optional PHYs Date: Thu, 5 Dec 2013 17:51:02 +0100 [thread overview] Message-ID: <1386262263-18956-4-git-send-email-andrew@lunn.ch> (raw) In-Reply-To: <1386262263-18956-1-git-send-email-andrew@lunn.ch> Some Marvell SoCs have a SATA PHY which can be powered off, in order to save power. Make use of the generic phy framework to control these phys. Signed-off-by: Andrew Lunn <andrew@lunn.ch> --- drivers/ata/sata_mv.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 56be31819897..9a728bcfbb9a 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c @@ -60,6 +60,7 @@ #include <linux/dma-mapping.h> #include <linux/device.h> #include <linux/clk.h> +#include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/ata_platform.h> #include <linux/mbus.h> @@ -563,6 +564,12 @@ struct mv_host_priv { struct clk *clk; struct clk **port_clks; /* + * Some devices have a SATA PHY which can be enabled/disabled + * in order to save power. These are optional: if the platform + * devices does not have any phy, they won't be used. + */ + struct phy **port_phys; + /* * These consistent DMA memory pools give us guaranteed * alignment for hardware-accessed data structures, * and less memory waste in accomplishing the alignment. @@ -4076,6 +4083,11 @@ static int mv_platform_probe(struct platform_device *pdev) GFP_KERNEL); if (!hpriv->port_clks) return -ENOMEM; + hpriv->port_phys = devm_kzalloc(&pdev->dev, + sizeof(struct phy *) * n_ports, + GFP_KERNEL); + if (!hpriv->port_phys) + return -ENOMEM; host->private_data = hpriv; hpriv->n_ports = n_ports; hpriv->board_idx = chip_soc; @@ -4097,6 +4109,9 @@ static int mv_platform_probe(struct platform_device *pdev) hpriv->port_clks[port] = clk_get(&pdev->dev, port_number); if (!IS_ERR(hpriv->port_clks[port])) clk_prepare_enable(hpriv->port_clks[port]); + hpriv->port_phys[port] = devm_phy_get(&pdev->dev, port_number); + if (!IS_ERR(hpriv->port_phys[port])) + phy_power_on(hpriv->port_phys[port]); } /* @@ -4132,6 +4147,8 @@ err: clk_disable_unprepare(hpriv->port_clks[port]); clk_put(hpriv->port_clks[port]); } + if (!IS_ERR(hpriv->port_phys[port])) + phy_power_off(hpriv->port_phys[port]); } return rc; @@ -4161,6 +4178,8 @@ static int mv_platform_remove(struct platform_device *pdev) clk_disable_unprepare(hpriv->port_clks[port]); clk_put(hpriv->port_clks[port]); } + if (!IS_ERR(hpriv->port_phys[port])) + phy_power_off(hpriv->port_phys[port]); } return 0; } -- 1.8.5
WARNING: multiple messages have this Message-ID (diff)
From: andrew@lunn.ch (Andrew Lunn) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/4] SATA: MV: Add support for the optional PHYs Date: Thu, 5 Dec 2013 17:51:02 +0100 [thread overview] Message-ID: <1386262263-18956-4-git-send-email-andrew@lunn.ch> (raw) In-Reply-To: <1386262263-18956-1-git-send-email-andrew@lunn.ch> Some Marvell SoCs have a SATA PHY which can be powered off, in order to save power. Make use of the generic phy framework to control these phys. Signed-off-by: Andrew Lunn <andrew@lunn.ch> --- drivers/ata/sata_mv.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 56be31819897..9a728bcfbb9a 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c @@ -60,6 +60,7 @@ #include <linux/dma-mapping.h> #include <linux/device.h> #include <linux/clk.h> +#include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/ata_platform.h> #include <linux/mbus.h> @@ -563,6 +564,12 @@ struct mv_host_priv { struct clk *clk; struct clk **port_clks; /* + * Some devices have a SATA PHY which can be enabled/disabled + * in order to save power. These are optional: if the platform + * devices does not have any phy, they won't be used. + */ + struct phy **port_phys; + /* * These consistent DMA memory pools give us guaranteed * alignment for hardware-accessed data structures, * and less memory waste in accomplishing the alignment. @@ -4076,6 +4083,11 @@ static int mv_platform_probe(struct platform_device *pdev) GFP_KERNEL); if (!hpriv->port_clks) return -ENOMEM; + hpriv->port_phys = devm_kzalloc(&pdev->dev, + sizeof(struct phy *) * n_ports, + GFP_KERNEL); + if (!hpriv->port_phys) + return -ENOMEM; host->private_data = hpriv; hpriv->n_ports = n_ports; hpriv->board_idx = chip_soc; @@ -4097,6 +4109,9 @@ static int mv_platform_probe(struct platform_device *pdev) hpriv->port_clks[port] = clk_get(&pdev->dev, port_number); if (!IS_ERR(hpriv->port_clks[port])) clk_prepare_enable(hpriv->port_clks[port]); + hpriv->port_phys[port] = devm_phy_get(&pdev->dev, port_number); + if (!IS_ERR(hpriv->port_phys[port])) + phy_power_on(hpriv->port_phys[port]); } /* @@ -4132,6 +4147,8 @@ err: clk_disable_unprepare(hpriv->port_clks[port]); clk_put(hpriv->port_clks[port]); } + if (!IS_ERR(hpriv->port_phys[port])) + phy_power_off(hpriv->port_phys[port]); } return rc; @@ -4161,6 +4178,8 @@ static int mv_platform_remove(struct platform_device *pdev) clk_disable_unprepare(hpriv->port_clks[port]); clk_put(hpriv->port_clks[port]); } + if (!IS_ERR(hpriv->port_phys[port])) + phy_power_off(hpriv->port_phys[port]); } return 0; } -- 1.8.5
next prev parent reply other threads:[~2013-12-05 16:51 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-12-05 16:50 [PATCH v2 0/4] PHY driver for Marvell SATA Andrew Lunn 2013-12-05 16:50 ` Andrew Lunn [not found] ` <1386262263-18956-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org> 2013-12-05 16:51 ` [PATCH v2 1/4] Phy: DT binding documentation for Marvell MVEBU SATA phy Andrew Lunn 2013-12-05 16:51 ` Andrew Lunn 2013-12-05 18:16 ` Jason Cooper 2013-12-05 18:16 ` Jason Cooper 2013-12-05 16:51 ` [PATCH v2 2/4] Phy: Add a PHY driver for Marvell MVEBU SATA PHY Andrew Lunn 2013-12-05 16:51 ` Andrew Lunn 2013-12-05 16:51 ` Andrew Lunn [this message] 2013-12-05 16:51 ` [PATCH v2 3/4] SATA: MV: Add support for the optional PHYs Andrew Lunn 2013-12-05 16:51 ` [PATCH v2 4/4] Phy: Add DT nodes on kirkwood and Dove for the SATA PHY Andrew Lunn 2013-12-05 16:51 ` Andrew Lunn 2013-12-05 18:18 ` Jason Cooper 2013-12-05 18:18 ` Jason Cooper 2013-12-08 1:09 ` [PATCH v2 0/4] PHY driver for Marvell SATA Jason Cooper 2013-12-08 1:09 ` Jason Cooper
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1386262263-18956-4-git-send-email-andrew@lunn.ch \ --to=andrew@lunn.ch \ --cc=devicetree@vger.kernel.org \ --cc=gregory.clement@free-electrons.com \ --cc=jason@lakedaemon.net \ --cc=kishon@ti.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-ide@vger.kernel.org \ --cc=sebastian.hesselbarth@googlemail.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.