diff mbox

[V3,5/8] ata: ahci platform: Add phy hooks to make it more generic

Message ID f82b7b246b8bedb153de5d360638ce79f13d61f0.1391077731.git.mohit.kumar@st.com
State Not Applicable
Delegated to: David Miller
Headers show

Commit Message

Mohit KUMAR DCG Jan. 30, 2014, 10:48 a.m. UTC
From: Pratyush Anand <pratyush.anand@st.com>

Few platform does only phy specific work in platform callbacks. It is
better to use standard phy callbacks for such platform in stead of
platform callbacks.

This patch does not break any platform callbacks. It adds phy plugins
on top of that.

It has been assumed that no platform will need both phy plugins as well
as platform callbacks.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Cc: Mohit Kumar <mohit.kumar@st.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: spear-devel@list.st.com
Cc: linux-ide@vger.kernel.org
---
 .../devicetree/bindings/ata/ahci-platform.txt      |    2 ++
 drivers/ata/ahci.h                                 |    2 ++
 drivers/ata/ahci_platform.c                        |   20 ++++++++++++++++++++
 3 files changed, 24 insertions(+), 0 deletions(-)

Comments

Arnd Bergmann Jan. 30, 2014, 1:06 p.m. UTC | #1
On Thursday 30 January 2014, Mohit Kumar wrote:
> From: Pratyush Anand <pratyush.anand@st.com>
> 
> Few platform does only phy specific work in platform callbacks. It is
> better to use standard phy callbacks for such platform in stead of
> platform callbacks.
> 
> This patch does not break any platform callbacks. It adds phy plugins
> on top of that.
> 
> It has been assumed that no platform will need both phy plugins as well
> as platform callbacks.
> 
> Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
> Cc: Mohit Kumar <mohit.kumar@st.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: spear-devel@list.st.com
> Cc: linux-ide@vger.kernel.org

This patch looks good to me, but as I mentioned, there has
been some related work recently. Please see the patch from
Roger Quadros posted at http://lkml.org/lkml/2014/1/8/142

One of the two should be enough.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pratyush ANAND Jan. 31, 2014, 3:52 a.m. UTC | #2
On Thu, Jan 30, 2014 at 09:06:14PM +0800, Arnd Bergmann wrote:
> On Thursday 30 January 2014, Mohit Kumar wrote:
> > From: Pratyush Anand <pratyush.anand@st.com>
> > 
> > Few platform does only phy specific work in platform callbacks. It is
> > better to use standard phy callbacks for such platform in stead of
> > platform callbacks.
> > 
> > This patch does not break any platform callbacks. It adds phy plugins
> > on top of that.
> > 
> > It has been assumed that no platform will need both phy plugins as well
> > as platform callbacks.
> > 
> > Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
> > Cc: Mohit Kumar <mohit.kumar@st.com>
> > Cc: Tejun Heo <tj@kernel.org>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: spear-devel@list.st.com
> > Cc: linux-ide@vger.kernel.org
> 
> This patch looks good to me, but as I mentioned, there has
> been some related work recently. Please see the patch from
> Roger Quadros posted at http://lkml.org/lkml/2014/1/8/142

I am not subscribed to ide list and I did not see that patch :(.

Will test our platform with above patch.

Regards
Pratyush
> 
> One of the two should be enough.
> 
> 	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/ata/ahci-platform.txt b/Documentation/devicetree/bindings/ata/ahci-platform.txt
index 89de156..73dff5a 100644
--- a/Documentation/devicetree/bindings/ata/ahci-platform.txt
+++ b/Documentation/devicetree/bindings/ata/ahci-platform.txt
@@ -10,6 +10,8 @@  Required properties:
 
 Optional properties:
 - dma-coherent      : Present if dma operations are coherent
+- phys		    : phandle to phy node associated with ahci controller
+- phy-names	    : must be "ahci-phy"
 
 Example:
         sata@ffe08000 {
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 2289efd..77d1412 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -37,6 +37,7 @@ 
 
 #include <linux/clk.h>
 #include <linux/libata.h>
+#include <linux/phy/phy.h>
 
 /* Enclosure Management Control */
 #define EM_CTRL_MSG_TYPE              0x000f0000
@@ -322,6 +323,7 @@  struct ahci_host_priv {
 	u32			em_buf_sz;	/* EM buffer size in byte */
 	u32			em_msg_type;	/* EM message type */
 	struct clk		*clk;		/* Only for platforms supporting clk */
+	struct phy		*phy;		/* associated phy struct */
 	void			*plat_data;	/* Other platform data */
 };
 
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index f955431..4253c03 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -123,6 +123,12 @@  static int ahci_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	/*
+	 * all ahci platform may not have phy node. So no need to
+	 * check return value of devm_phy_get.
+	 */
+	hpriv->phy = devm_phy_get(dev, "ahci-phy");
+
 	hpriv->flags |= (unsigned long)pi.private_data;
 
 	hpriv->mmio = devm_ioremap(dev, mem->start, resource_size(mem));
@@ -152,6 +158,10 @@  static int ahci_probe(struct platform_device *pdev)
 		rc = pdata->init(dev, hpriv->mmio);
 		if (rc)
 			goto disable_unprepare_clk;
+	} else if (hpriv->phy && hpriv->phy->ops->init) {
+		rc = hpriv->phy->ops->init(hpriv->phy);
+		if (rc)
+			goto disable_unprepare_clk;
 	}
 
 	ahci_save_initial_config(dev, hpriv,
@@ -221,6 +231,8 @@  static int ahci_probe(struct platform_device *pdev)
 pdata_exit:
 	if (pdata && pdata->exit)
 		pdata->exit(dev);
+	else if (hpriv->phy && hpriv->phy->ops->exit)
+		hpriv->phy->ops->exit(hpriv->phy);
 disable_unprepare_clk:
 	if (!IS_ERR(hpriv->clk))
 		clk_disable_unprepare(hpriv->clk);
@@ -238,6 +250,8 @@  static void ahci_host_stop(struct ata_host *host)
 
 	if (pdata && pdata->exit)
 		pdata->exit(dev);
+	else if (hpriv->phy && hpriv->phy->ops->exit)
+		hpriv->phy->ops->exit(hpriv->phy);
 
 	if (!IS_ERR(hpriv->clk)) {
 		clk_disable_unprepare(hpriv->clk);
@@ -276,6 +290,8 @@  static int ahci_suspend(struct device *dev)
 
 	if (pdata && pdata->suspend)
 		return pdata->suspend(dev);
+	else if (hpriv->phy && hpriv->phy->ops->power_off)
+		return hpriv->phy->ops->power_off(hpriv->phy);
 
 	if (!IS_ERR(hpriv->clk))
 		clk_disable_unprepare(hpriv->clk);
@@ -302,6 +318,10 @@  static int ahci_resume(struct device *dev)
 		rc = pdata->resume(dev);
 		if (rc)
 			goto disable_unprepare_clk;
+	} else if (hpriv->phy && hpriv->phy->ops->power_on) {
+		rc = hpriv->phy->ops->power_on(hpriv->phy);
+		if (rc)
+			goto disable_unprepare_clk;
 	}
 
 	if (dev->power.power_state.event == PM_EVENT_SUSPEND) {