ata: ahci_platform: Add PHY support and OMAP support
v5 cover ata: ahci_platform: Add PHY support and OMAP support
Hi,
Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the Generic PHY framework in PATCH 3.
In order to support SATA on the OMAP platforms we need to runtime resume the device before use. PATCH 4 takes care of that.
PATCH 1 & 2 updates the DT compatible list.
Changelog:
v5:
- Don't use break after goto in switch case. Rebased on v3.13
v4:
- Tackle error conditions while using PHY framework APIs.
v3:
- Addressed review comments and rebased on 3.13-rc7
- DT binding update moved to new patch.
v2:
- got rid of Texas Instruments SATA wrapper driver
- adressed review comments
cheers,
-roger
---
Balaji T K (1):
ata: ahci_platform: Manage SATA PHY
Roger Quadros (3):
ata: ahci_platform: Add DT compatible for Synopsis DWC AHCI controller
ata: ahci_platform: Update DT compatible list
ata: ahci_platform: runtime resume the device before use
.../devicetree/bindings/ata/ahci-platform.txt | 4 +- drivers/ata/ahci.h | 2 + drivers/ata/ahci_platform.c | 57 +++++++++++++++++++++- 3 files changed, 61 insertions(+), 2 deletions(-)
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 1/4 ata: ahci_platform: Add DT compatible for Synopsis DWC AHCI controller
Add compatible string "snps,dwc-ahci", which should be used for Synopsis Designware SATA cores. e.g. on TI OMAP5 and DRA7 platforms.
--- drivers/ata/ahci_platform.c | 1 + 1 file changed, 1 insertion(+)
drivers/ata/ahci_platform.c +1 -0
@@ -330,6 +330,7 @@ static const struct of_device_id ahci_of_match[] = { { .compatible = "snps,spear-ahci", }, { .compatible = "snps,exynos5440-ahci", }, { .compatible = "ibm,476gtr-ahci", }, + { .compatible = "snps,dwc-ahci", }, {}, }; MODULE_DEVICE_TABLE(of, ahci_of_match);
Signature · 1 line
1.8.3.2
PATCH v5 2/4 ata: ahci_platform: Update DT compatible list
In reply to Roger QuadrosThe ahci_platform driver supports "snps,exynos5440-ahci", "ibm,476gtr-ahci" and "snps,dwc-ahci". Add this to the DT binding information.
--- Documentation/devicetree/bindings/ata/ahci-platform.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/ata/ahci-platform.txt +3 -1
@@ -4,7 +4,9 @@ SATA nodes are defined to describe on-chip Serial ATA controllers. Each SATA controller should have its own node. Required properties: -- compatible : compatible list, contains "snps,spear-ahci" +- compatible : compatible list, contains "snps,spear-ahci", + "snps,exynos5440-ahci", "ibm,476gtr-ahci", + or "snps,dwc-ahci" - interrupts : <interrupt mapping for SATA IRQ> - reg : <registers mapping>
Signature · 1 line
1.8.3.2
Re: [PATCH v5 2/4] ata: ahci_platform: Update DT compatible list
Quoted 5 lines · Roger Quadros
The
ahci_platformdriver supports "snps,exynos5440-ahci", "ibm,476gtr-ahci" and "snps,dwc-ahci". Add this to the DT binding information.Signed-off-by Roger Quadros <[email protected]>Reviewed-by Bartlomiej Zolnierkiewicz <[email protected]>
Quoted 26 lines
--- Documentation/devicetree/bindings/ata/ahci-platform.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/ata/ahci-platform.txt +3
-2@@ -4,7 +4,9 @@ SATA nodes are defined to describe on-chip Serial ATA controllers. Each SATA controller should have its own node. Required properties: -- compatible : compatible list, contains "snps,spear-ahci" +- compatible : compatible list, contains "snps,spear-ahci", + "snps,exynos5440-ahci", "ibm,476gtr-ahci", + or "snps,dwc-ahci" - interrupts : <interrupt mapping for SATA IRQ> - reg : <registers mapping> --1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 3/4 ata: ahci_platform: Manage SATA PHY
In reply to Roger QuadrosFrom: Balaji T K <[email protected]>
Some platforms have a PHY hooked up to the
SATA controller. The PHY needs to be initialized
and powered up for SATA to work. We do that
using the PHY framework.
[Roger Q] Cleaned up.
--- drivers/ata/ahci.h | 2 ++ drivers/ata/ahci_platform.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-)
drivers/ata/ahci.h +2 -0
@@ -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;/* If platform uses phy */ void *plat_data;/* Other platform data */ };
drivers/ata/ahci_platform.c +43 -1
68 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH v5 4/4 ata: ahci_platform: runtime resume the device before use
In reply to Roger QuadrosOn OMAP platforms the device needs to be runtime resumed before it can be accessed. The OMAP HWMOD framework takes care of enabling the module and its resources based on the device's runtime PM state.
In this patch we runtime resume during .probe() and runtime suspend during .remove() (i.e. ahci_host_stop()).
We also update the runtime PM state during .resume().
--- drivers/ata/ahci_platform.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/ata/ahci_platform.c +12 -0
@@ -23,6 +23,7 @@#include <linux/platform_device.h> #include <linux/libata.h> #include <linux/ahci_platform.h> +#include <linux/pm_runtime.h> #include "ahci.h" static void ahci_host_stop (struct ata_host *host);
@@ -142,6 +143,9 @@ static int ahci_probe(struct platform_device *pdev) } } +pm_runtime_enable (dev); +pm_runtime_get_sync (dev); + hpriv->phy =devm_phy_get (dev,"sata-phy" );if (IS_ERR (hpriv->phy)) { rc =PTR_ERR (hpriv->phy);
@@ -285,6 +289,9 @@ static void ahci_host_stop(struct ata_host *host)clk_disable_unprepare (hpriv->clk);clk_put (hpriv->clk); } + +pm_runtime_put_sync (dev); +pm_runtime_disable (dev); }#ifdef CONFIG_PM_SLEEP
@@ -356,6 +363,11 @@ static int ahci_resume(struct device *dev)ata_host_resume (host); +/* We resumed so update PM runtime state */ +pm_runtime_disable (dev); +pm_runtime_set_active (dev); +pm_runtime_enable (dev); +return 0 ; disable_unprepare_clk:
Signature · 1 line
1.8.3.2
Hi,
Quoted 8 lines · Roger Quadros
Hi,
Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the Generic PHY framework in PATCH 3.
In order to support SATA on the OMAP platforms we need to runtime resume the device before use. PATCH 4 takes care of that.
Thanks for keeping me in the loop on this. I'm afraid this conflicts quite a bit with my recent ahci_platform.c work, not a big problem really, the series can go in either way.
Your phy support will slot nicely into the new ahci_platform_get_resources and ahci_platform_enable_resources functions my refactoring introduces, looking at it from this pov it might be better / easier to rebase your series on top of the v4 of my series I've just send.
Which brings me to one comment about your series why are you not doing phy_exit and phy_init on suspend resp. resume ? The phy can use quite a bit of power, if the phy init / exit end up in ahci_platform_enable_resources / ahci_platform_disable_resources, this will happen automatically for better or worse. So it would be good to test if this would work or not ...
Thanks & Regards,
Hans
Quoted 21 lines · Hans de Goede
Hi,
Quoted 8 lines · Roger Quadros
Hi,
Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the Generic PHY framework in PATCH 3.
In order to support SATA on the OMAP platforms we need to runtime resume the device before use. PATCH 4 takes care of that.
Thanks for keeping me in the loop on this. I'm afraid this conflicts quite a bit with my recent
ahci_platform.cwork, not a big problem really, the series can go in either way.Your phy support will slot nicely into the new
ahci_platform_get_resourcesandahci_platform_enable_resourcesfunctions my refactoring introduces, looking at it from this pov it might be better / easier to rebase your series on top of the v4 of my series I've just send.
Quoted 5 lines
Which brings me to one comment about your series why are you not doing
phy_exitandphy_initon suspend resp. resume ? The phy can use quite a bit of power, if the phy init / exit end up inahci_platform_enable_resources/ahci_platform_disable_resources, this will happen automatically for better or worse. So it would be good to test if this would work or not ...
Right. Bartlomiej had pointed this out earlier, but I just wasn't very sure about it.
Is it sufficient to just call phy_power_off() in suspend and phy_power_on() in resume? Or do we call phy_exit() and phy_init() respectively as well.
Kishon, any suggestions?
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 28 lines · Roger Quadros
Quoted 21 lines · Hans de Goede
Hi,
Quoted 8 lines · Roger Quadros
Hi,
Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the Generic PHY framework in PATCH 3.
In order to support SATA on the OMAP platforms we need to runtime resume the device before use. PATCH 4 takes care of that.
Thanks for keeping me in the loop on this. I'm afraid this conflicts quite a bit with my recent
ahci_platform.cwork, not a big problem really, the series can go in either way.Your phy support will slot nicely into the new
ahci_platform_get_resourcesandahci_platform_enable_resourcesfunctions my refactoring introduces, looking at it from this pov it might be better / easier to rebase your series on top of the v4 of my series I've just send.Quoted 5 lines
Which brings me to one comment about your series why are you not doing
phy_exitandphy_initon suspend resp. resume ? The phy can use quite a bit of power, if the phy init / exit end up inahci_platform_enable_resources/ahci_platform_disable_resources, this will happen automatically for better or worse. So it would be good to test if this would work or not ...
Quoted 6 lines
Right. Bartlomiej had pointed this out earlier, but I just wasn't very sure about it.
Is it sufficient to just call
phy_power_off()in suspend andphy_power_on()in resume? Or do we callphy_exit()andphy_init()respectively as well.Kishon, any suggestions?
OK. Answering my own question.
On OMAP platform we power down the phy in phy_power_off() and idle the DPLL in phy_exit(), so my guess is both should be called in suspend() to save the most power.
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
Quoted 34 lines · Roger Quadros
Quoted 33 lines · Roger Quadros
Quoted 21 lines · Hans de Goede
Hi,
Quoted 8 lines · Roger Quadros
Hi,
Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the Generic PHY framework in PATCH 3.
In order to support SATA on the OMAP platforms we need to runtime resume the device before use. PATCH 4 takes care of that.
Thanks for keeping me in the loop on this. I'm afraid this conflicts quite a bit with my recent
ahci_platform.cwork, not a big problem really, the series can go in either way.Your phy support will slot nicely into the new
ahci_platform_get_resourcesandahci_platform_enable_resourcesfunctions my refactoring introduces, looking at it from this pov it might be better / easier to rebase your series on top of the v4 of my series I've just send.Quoted 5 lines
Which brings me to one comment about your series why are you not doing
phy_exitandphy_initon suspend resp. resume ? The phy can use quite a bit of power, if the phy init / exit end up inahci_platform_enable_resources/ahci_platform_disable_resources, this will happen automatically for better or worse. So it would be good to test if this would work or not ...Right. Bartlomiej had pointed this out earlier, but I just wasn't very sure about it.
Is it sufficient to just call
phy_power_off()in suspend andphy_power_on()in resume? Or do we callphy_exit()andphy_init()respectively as well.
Quoted 6 lines
Quoted 1 line
Kishon, any suggestions?
OK. Answering my own question.
On OMAP platform we power down the phy in
phy_power_off()and idle the DPLL inphy_exit(), so my guess is both should be called insuspend()to save the most power.
Right, this would also match nicely with putting both the phy_init and the phy_power_on call in ahci_platform_enable_resources in ahci_platform.c as it looks after v4 of my ahci_platform rework patch-set, see:
https://github.com/jwrdegoede/linux-sunxi/blob/sunxi-devel/drivers/ata/ahci_platform.c
If this goes there it will be automatically called on both probe and resume (and the counterparts should go to ahci_platform_disable_resources, which will be called on suspend and remove).
As said before I don't really have a preference for in which order these patches go upstream, but can you please check that calling phy_poweroff + phy_exit on suspend and undo on resume does not cause issues ? If it does I need to rethink how things will work after my refactoring, because currently all the clks / optional regulator and now also optional phy get en/disabled in one go through ahci_platform_en/disable_resources.
Thanks & Regards,
Hans
Hi,
Quoted 49 lines · Hans de Goede
Hi,
Quoted 34 lines · Roger Quadros
Quoted 33 lines · Roger Quadros
Quoted 21 lines · Hans de Goede
Hi,
Quoted 8 lines · Roger Quadros
Hi,
Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the Generic PHY framework in PATCH 3.
In order to support SATA on the OMAP platforms we need to runtime resume the device before use. PATCH 4 takes care of that.
Thanks for keeping me in the loop on this. I'm afraid this conflicts quite a bit with my recent
ahci_platform.cwork, not a big problem really, the series can go in either way.Your phy support will slot nicely into the new
ahci_platform_get_resourcesandahci_platform_enable_resourcesfunctions my refactoring introduces, looking at it from this pov it might be better / easier to rebase your series on top of the v4 of my series I've just send.Quoted 5 lines
Which brings me to one comment about your series why are you not doing
phy_exitandphy_initon suspend resp. resume ? The phy can use quite a bit of power, if the phy init / exit end up inahci_platform_enable_resources/ahci_platform_disable_resources, this will happen automatically for better or worse. So it would be good to test if this would work or not ...Right. Bartlomiej had pointed this out earlier, but I just wasn't very sure about it.
Is it sufficient to just call
phy_power_off()in suspend andphy_power_on()in resume? Or do we callphy_exit()andphy_init()respectively as well.Quoted 6 lines
Quoted 1 line
Kishon, any suggestions?
OK. Answering my own question.
On OMAP platform we power down the phy in
phy_power_off()and idle the DPLL inphy_exit(), so my guess is both should be called insuspend()to save the most power.Right, this would also match nicely with putting both the
phy_initand thephy_power_oncall inahci_platform_enable_resourcesinahci_platform.cas it looks after v4 of myahci_platformrework patch-set, see:
https://github.com/jwrdegoede/linux-sunxi/blob/sunxi-devel/drivers/ata/ahci_platform.c
Quoted 8 lines
If this goes there it will be automatically called on both probe and resume (and the counterparts should go to
ahci_platform_disable_resources, which will be called on suspend and remove).As said before I don't really have a preference for in which order these patches go upstream, but can you please check that calling
phy_poweroff+phy_exiton suspend and undo on resume does not cause issues ? If it does I need to rethink how things will work after my refactoring, because currently all the clks / optional regulator and now also optional phy get en/disabled in one go through ahci_platform_en/disable_resources.
I too don't have any preference of the upstream path. Maybe i'll repost this series based on your v4 an then you can include them in your series if you like. BTW why is your series still RFC at v4?
As far as OMAP platform is concerned, calling phy_power_off() + phy_exit() shouldn't be a problem for suspend. Not sure about other platforms as we can't really know for sure what they do in phy_exit().
If phy_power_on/off() and phy_init()/phy_exit() are always meant to be called together then what is the point of having 2 functions each for power up/down.
cheers,
-roger
Hi,
Quoted 55 lines · Roger Quadros
Hi,
Quoted 52 lines · Hans de Goede
Hi,
Quoted 34 lines · Roger Quadros
Quoted 33 lines · Roger Quadros
Quoted 21 lines · Hans de Goede
Hi,
Quoted 8 lines · Roger Quadros
Hi,
Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the Generic PHY framework in PATCH 3.
In order to support SATA on the OMAP platforms we need to runtime resume the device before use. PATCH 4 takes care of that.
Thanks for keeping me in the loop on this. I'm afraid this conflicts quite a bit with my recent
ahci_platform.cwork, not a big problem really, the series can go in either way.Your phy support will slot nicely into the new
ahci_platform_get_resourcesandahci_platform_enable_resourcesfunctions my refactoring introduces, looking at it from this pov it might be better / easier to rebase your series on top of the v4 of my series I've just send.Quoted 5 lines
Which brings me to one comment about your series why are you not doing
phy_exitandphy_initon suspend resp. resume ? The phy can use quite a bit of power, if the phy init / exit end up inahci_platform_enable_resources/ahci_platform_disable_resources, this will happen automatically for better or worse. So it would be good to test if this would work or not ...Right. Bartlomiej had pointed this out earlier, but I just wasn't very sure about it.
Is it sufficient to just call
phy_power_off()in suspend andphy_power_on()in resume? Or do we callphy_exit()andphy_init()respectively as well.Quoted 6 lines
Quoted 1 line
Kishon, any suggestions?
OK. Answering my own question.
On OMAP platform we power down the phy in
phy_power_off()and idle the DPLL inphy_exit(), so my guess is both should be called insuspend()to save the most power.Right, this would also match nicely with putting both the
phy_initand thephy_power_oncall inahci_platform_enable_resourcesinahci_platform.cas it looks after v4 of myahci_platformrework patch-set, see:
https://github.com/jwrdegoede/linux-sunxi/blob/sunxi-devel/drivers/ata/ahci_platform.cIf this goes there it will be automatically called on both probe and resume (and the counterparts should go to
ahci_platform_disable_resources, which will be called on suspend and remove).
Quoted 7 lines
Quoted 5 lines
As said before I don't really have a preference for in which order these patches go upstream, but can you please check that calling
phy_poweroff+phy_exiton suspend and undo on resume does not cause issues ? If it does I need to rethink how things will work after my refactoring, because currently all the clks / optional regulator and now also optional phy get en/disabled in one go through ahci_platform_en/disable_resources.I too don't have any preference of the upstream path. Maybe i'll repost this series based on your v4 an then you can include them in your series if you like.
As indicated doing things in that order has my preference as rebase-conflict resolution should be a lot easier that way then the other way around. So if you could do that, that would be great.
Quoted 1 line
BTW why is your series still RFC at v4?
It was not RFC at v1 and v2, it became RFC at v3 because at that point it included changes which would also impact ahci_imx, and I did not have hardware to verify those changes. The wandboard I ordered for this has arrived yesterday, so my next version should not be RFC anymore :)
Quoted 2 lines
As far as OMAP platform is concerned, calling
phy_power_off()+phy_exit()shouldn't be a problem for suspend. Not sure about other platforms as we can't really know for sure what they do inphy_exit().
Good, after the rework my patch-series does, platforms which need something else can always override the ahci_platform_disable_resources behavior (by doing that part themselves) while still using other parts of ahci_platform.c as is, that is the whole idea of the rework.
Thanks & Regards,
Hans