add ahci_platform_get_of_property
A message that is not in the archive (sent off-list or not yet received): [email protected], [email protected],
cover add ahci_platform_get_of_property
Instead of setting hflags in different files, ahci_platform_get_of_property set hpriv->flags when ahci_platform_init_host
Any other property required?
Zhangfei Gao (2):
libahci_platform: add ahci_platform_get_of_property
ahci: remove AHCI_HFLAG_NO_FBS setting
.../devicetree/bindings/ata/ahci-platform.txt | 9 +++++ drivers/ata/ahci_platform.c | 3 -- drivers/ata/libahci_platform.c | 39 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.9.5
RFC PATCH 1/2 libahci_platform: add ahci_platform_get_of_property
Instead of setting hflags in different files, ahci_platform_get_of_property set hpriv->flags when ahci_platform_init_host according to property in dts.
--- .../devicetree/bindings/ata/ahci-platform.txt | 9 +++++ drivers/ata/libahci_platform.c | 39 ++++++++++++++++++++ 2 files changed, 48 insertions(+)
Documentation/devicetree/bindings/ata/ahci-platform.txt +9 -0
@@ -26,6 +26,15 @@ Optional properties: - clocks : must contain the sata, sata_ref and ahb clocks - clock-names : must contain "ahb" for the ahb clock +- no-ncq: when present, controller can't do NCQ, turning off CAP_NCQ +- 32bit-only: when present, controller can't do 64bit DMA, forcing 32bit +- no-msi: when present, no PCI MSI +- no-pmp: when present, controller can't do PMP, turning off CAP_PMP +- yes-ncq: when present,controller can do NCQ, turning on CAP_NCQ +- no-suspend: when present, controller can't do suspend +- yes-fbs: when present, controller can do FBS, turning on CAP_FBS +- no-fbs: when present, controller can't do FBS, turning off CAP_FBS + Examples: sata at ffe08000 { compatible = "snps,spear-ahci";
drivers/ata/libahci_platform.c +39 -0
@@ -278,6 +278,44 @@ err_out: }EXPORT_SYMBOL_GPL (ahci_platform_get_resources); +#ifdef CONFIG_OF +static void ahci_platform_get_of_property (struct platform_device *pdev, +struct ahci_host_priv *hpriv) +{ +struct device_node *np = pdev->dev.of_node; + +if (of_device_is_available (np)) { +if (of_get_property (np,"no-ncq" ,NULL )) + hpriv->flags |=AHCI_HFLAG_NO_NCQ ; + +if (of_get_property (np,"32bit-only" ,NULL )) + hpriv->flags |=AHCI_HFLAG_32BIT_ONLY ; + +if (of_get_property (np,"no-msi" ,NULL )) + hpriv->flags |=AHCI_HFLAG_NO_MSI ; + +if (of_get_property (np,"no-pmp" ,NULL )) + hpriv->flags |=AHCI_HFLAG_NO_PMP ; + +if (of_get_property (np,"yes-ncq" ,NULL )) + hpriv->flags |=AHCI_HFLAG_YES_NCQ ; + +if (of_get_property (np,"no-suspend" ,NULL )) + hpriv->flags |=AHCI_HFLAG_NO_SUSPEND ; + +if (of_get_property (np,"yes-fbs" ,NULL )) + hpriv->flags |=AHCI_HFLAG_YES_FBS ; + +if (of_get_property (np,"no-fbs" ,NULL )) + hpriv->flags |=AHCI_HFLAG_NO_FBS ; + } +} +#else +static void ahci_platform_get_of_property (struct platform_device *pdev, +struct ahci_host_priv *hpriv) +{} +#endif /* CONFIG_OF */ +/** * ahci_platform_init_host - Bring up an ahci-platform host * @pdev: platform device pointer for the host
@@ -316,6 +354,7 @@ int ahci_platform_init_host(struct platform_device *pdev,/* prepare host */ pi.private_data = (void *)host_flags; hpriv->flags |= host_flags; +ahci_platform_get_of_property (pdev, hpriv);ahci_save_initial_config (dev, hpriv, force_port_map, mask_port_map);
Signature · 1 line
1.7.9.5
RFC PATCH 1/2 libahci_platform: add ahci_platform_get_of_property
Hi,
Quoted 17 lines · Zhangfei Gao
Instead of setting hflags in different files,
ahci_platform_get_of_propertysethpriv->flagswhenahci_platform_init_hostaccording to property in dts.Signed-off-by Zhangfei Gao <[email protected]>--- .../devicetree/bindings/ata/ahci-platform.txt | 9 +++++ drivers/ata/libahci_platform.c | 39 ++++++++++++++++++++ 2 files changed, 48 insertions(+)Documentation/devicetree/bindings/ata/ahci-platform.txt +0
-0@@ -26,6 +26,15 @@ Optional properties: - clocks : must contain the sata, sata_ref and ahb clocks - clock-names : must contain "ahb" for the ahb clock
Documentation/devicetree/bindings/ata/ahci-platform.txt Optional properties: · line 37
Quoted 10 lines
Documentation/devicetree/bindings/ata/ahci-platform.txt +9
-0+- no-ncq: when present, controller can't do NCQ, turning off CAP_NCQ +- 32bit-only: when present, controller can't do 64bit DMA, forcing 32bit +- no-msi: when present, no PCI MSI +- no-pmp: when present, controller can't do PMP, turning off CAP_PMP +- yes-ncq: when present,controller can do NCQ, turning on CAP_NCQ +- no-suspend: when present, controller can't do suspend +- yes-fbs: when present, controller can do FBS, turning on CAP_FBS +- no-fbs: when present, controller can't do FBS, turning off CAP_FBS +
'yes-...' sounds a bit silly to me.
What about 'force-...'?
That's also what the comment to the flag definitions in drivers/ata/ahci.h says:
|AHCI_HFLAG_YES_NCQ = (1 << 9), /* force NCQ cap on */ |AHCI_HFLAG_YES_FBS = (1 << 14), /* force FBS cap on */
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | [email protected] ___________________________________________________________
RFC PATCH 1/2 libahci_platform: add ahci_platform_get_of_property
Quoted 21 lines · Lothar Wa?mann
Hi,
Quoted 18 lines · Zhangfei Gao
Instead of setting hflags in different files,
ahci_platform_get_of_propertysethpriv->flagswhenahci_platform_init_hostaccording to property in dts.Signed-off-by Zhangfei Gao <[email protected]>--- .../devicetree/bindings/ata/ahci-platform.txt | 9 +++++ drivers/ata/libahci_platform.c | 39 ++++++++++++++++++++ 2 files changed, 48 insertions(+)Documentation/devicetree/bindings/ata/ahci-platform.txt +0
-0@@ -26,6 +26,15 @@ Optional properties: - clocks : must contain the sata, sata_ref and ahb clocks - clock-names : must contain "ahb" for the ahb clock
Quoted 11 lines
Documentation/devicetree/bindings/ata/ahci-platform.txt Optional properties: · line 37
Quoted 9 lines
Documentation/devicetree/bindings/ata/ahci-platform.txt +9
-0+- no-ncq: when present, controller can't do NCQ, turning off CAP_NCQ +- 32bit-only: when present, controller can't do 64bit DMA, forcing 32bit +- no-msi: when present, no PCI MSI +- no-pmp: when present, controller can't do PMP, turning off CAP_PMP +- yes-ncq: when present,controller can do NCQ, turning on CAP_NCQ +- no-suspend: when present, controller can't do suspend +- yes-fbs: when present, controller can do FBS, turning on CAP_FBS +- no-fbs: when present, controller can't do FBS, turning off CAP_FBS +'yes-...' sounds a bit silly to me.
What about 'force-...'?
Yes, good idea, thanks for the suggestion.
Quoted 8 lines
That's also what the comment to the flag definitions in
drivers/ata/ahci.hsays:|AHCI_HFLAG_YES_NCQ = (1 << 9), /* force NCQ cap on */ |AHCI_HFLAG_YES_FBS = (1 << 14), /* force FBS cap on */Lothar Wa?mann
RFC PATCH 1/2 libahci_platform: add ahci_platform_get_of_property
In reply to Zhangfei GaoQuoted 3 lines · Zhangfei Gao
Instead of setting hflags in different files,
ahci_platform_get_of_propertysethpriv->flagswhenahci_platform_init_hostaccording to property in dts.
The AHCI_HFLAGS are a Linux implementation detail, so it would be nice to have a good justification for each of these being turned into DT properties.
Quoted 13 lines
Signed-off-by Zhangfei Gao <[email protected]>--- .../devicetree/bindings/ata/ahci-platform.txt | 9 +++++ drivers/ata/libahci_platform.c | 39 ++++++++++++++++++++ 2 files changed, 48 insertions(+)Documentation/devicetree/bindings/ata/ahci-platform.txt +0
-0@@ -26,6 +26,15 @@ Optional properties: - clocks : must contain the sata, sata_ref and ahb clocks
Documentation/devicetree/bindings/ata/ahci-platform.txt Optional properties: · line 36
Quoted 10 lines
Documentation/devicetree/bindings/ata/ahci-platform.txt +8
-0- clock-names : must contain "ahb" for the ahb clock +- no-ncq: when present, controller can't do NCQ, turning off CAP_NCQ +- 32bit-only: when present, controller can't do 64bit DMA, forcing 32bit +- no-msi: when present, no PCI MSI +- no-pmp: when present, controller can't do PMP, turning off CAP_PMP +- yes-ncq: when present,controller can do NCQ, turning on CAP_NCQ +- no-suspend: when present, controller can't do suspend +- yes-fbs: when present, controller can do FBS, turning on CAP_FBS +- no-fbs: when present, controller can't do FBS, turning off CAP_FBS
There is absolutely no reason to mention CAP_* here; the DT should describe the HW, not Linux internals.
Do these all make sense to be placed in DT?
I worry that for other quirks we may need more flags in future. For that reason I'd rather figure this out in the driver based on the compatible string.
Quoted 11 lines
Documentation/devicetree/bindings/ata/ahci-platform.txt +1
-0+ Examples: sata at ffe08000 { compatible = "snps,spear-ahci";drivers/ata/libahci_platform.c +0
-0@@ -278,6 +278,44 @@ err_out: }EXPORT_SYMBOL_GPL (ahci_platform_get_resources);
drivers/ata/libahci_platform.c err_out: · line 289
Quoted 10 lines
drivers/ata/libahci_platform.c +9
-0+#ifdef CONFIG_OF +static void ahci_platform_get_of_property (struct platform_device *pdev, +struct ahci_host_priv *hpriv) +{ +struct device_node *np = pdev->dev.of_node; + +if (of_device_is_available (np)) { +if (of_get_property (np,"no-ncq" ,NULL )) + hpriv->flags |=AHCI_HFLAG_NO_NCQ ;
For boolean flags please use of_property_read_bool.
Mark.
RFC PATCH 1/2 libahci_platform: add ahci_platform_get_of_property
Hi Mark,
Quoted 8 lines · Mark Rutland
Quoted 3 lines · Zhangfei Gao
Instead of setting hflags in different files,
ahci_platform_get_of_propertysethpriv->flagswhenahci_platform_init_hostaccording to property in dts.The
AHCI_HFLAGSare a Linux implementation detail, so it would be nice to have a good justification for each of these being turned into DT properties.
Do you mean only add required property now?
Add ahci_platform_get_of_property is considering sharing drivers/ata/ahci_platform.c, refering sdhci_get_of_property in drivers/mmc/host/sdhci-pltfm.c.
The problem we met is different AHCI_HFLAGS required even in one soc series, for example, current version of "hisilicon,hisi-ahci" requires AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ, while next version solve the limitation, and no HFLAG required.
We may need different compatible, or it may simplier just state in dts. What's more, one common compatible can be used instead of adding specific compatible string.
Quoted 16 lines
Quoted 16 lines
Signed-off-by Zhangfei Gao <[email protected]>--- .../devicetree/bindings/ata/ahci-platform.txt | 9 +++++ drivers/ata/libahci_platform.c | 39 ++++++++++++++++++++ 2 files changed, 48 insertions(+)Documentation/devicetree/bindings/ata/ahci-platform.txt +0
-0@@ -26,6 +26,15 @@ Optional properties: - clocks : must contain the sata, sata_ref and ahb clocks - clock-names : must contain "ahb" for the ahb clock
Quoted 11 lines
Documentation/devicetree/bindings/ata/ahci-platform.txt Optional properties: · line 36
Quoted 8 lines
Documentation/devicetree/bindings/ata/ahci-platform.txt +8
-0+- no-ncq: when present, controller can't do NCQ, turning off CAP_NCQ +- 32bit-only: when present, controller can't do 64bit DMA, forcing 32bit +- no-msi: when present, no PCI MSI +- no-pmp: when present, controller can't do PMP, turning off CAP_PMP +- yes-ncq: when present,controller can do NCQ, turning on CAP_NCQ +- no-suspend: when present, controller can't do suspend +- yes-fbs: when present, controller can do FBS, turning on CAP_FBS +- no-fbs: when present, controller can't do FBS, turning off CAP_FBSThere is absolutely no reason to mention CAP_* here; the DT should describe the HW, not Linux internals.
Yes, got it, will remove CAP*.
Quoted 2 lines
Do these all make sense to be placed in DT?
Currently, "hisilicon,hisi-ahci" only need AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ.
Just grep AHCI_HFLAG under ata.
Quoted 4 lines
I worry that for other quirks we may need more flags in future. For that reason I'd rather figure this out in the driver based on the compatible string.
So do we just add no-ncq & no-fbs now?
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/ata/ahci-platform.txt +1
-0+ Examples: sata at ffe08000 { compatible = "snps,spear-ahci";drivers/ata/libahci_platform.c +0
-0@@ -278,6 +278,44 @@ err_out: }EXPORT_SYMBOL_GPL (ahci_platform_get_resources);
Quoted 11 lines
drivers/ata/libahci_platform.c err_out: · line 289
Quoted 9 lines
drivers/ata/libahci_platform.c +9
-0+#ifdef CONFIG_OF +static void ahci_platform_get_of_property (struct platform_device *pdev, +struct ahci_host_priv *hpriv) +{ +struct device_node *np = pdev->dev.of_node; + +if (of_device_is_available (np)) { +if (of_get_property (np,"no-ncq" ,NULL )) + hpriv->flags |=AHCI_HFLAG_NO_NCQ ;For boolean flags please use
of_property_read_bool.
Yes, it's more accurate.
Thanks for advices.
Quoted 3 lines
Mark.
RFC PATCH 1/2 libahci_platform: add ahci_platform_get_of_property
Hi,
Quoted 8 lines · zhangfei
Hi Mark,
Quoted 5 lines · Mark Rutland
Quoted 3 lines · Zhangfei Gao
Instead of setting hflags in different files,
ahci_platform_get_of_propertysethpriv->flagswhenahci_platform_init_hostaccording to property in dts.
Quoted 5 lines
Quoted 3 lines
The
AHCI_HFLAGSare a Linux implementation detail, so it would be nice to have a good justification for each of these being turned into DT properties.Do you mean only add required property now?
No you should not add any properties at all using properties to set SoC specific quirks is just wrong, if a device is not 100% ahci compatible you should use a SoC specific compatible string for it, and set quirks in the kernel driver based on that.
Devicetree is supposed to describe hardware, in this case the quirks are a property of the specific model of the hardware, so this should be expressed through the compatible string. Extra properties in devicetree are meant to be used for board specific things, like having a gpio to enable power to the sata target device. Extra properties should not be used in the way you are proposing to use them now.
Regards,
Hans
RFC PATCH 1/2 libahci_platform: add ahci_platform_get_of_property
Quoted 21 lines · Hans de Goede
Hi,
Quoted 8 lines · zhangfei
Hi Mark,
Quoted 5 lines · Mark Rutland
Quoted 3 lines · Zhangfei Gao
Instead of setting hflags in different files,
ahci_platform_get_of_propertysethpriv->flagswhenahci_platform_init_hostaccording to property in dts.Quoted 5 lines
Quoted 3 lines
The
AHCI_HFLAGSare a Linux implementation detail, so it would be nice to have a good justification for each of these being turned into DT properties.Do you mean only add required property now?
No you should not add any properties at all using properties to set SoC specific quirks is just wrong, if a device is not 100% ahci compatible you should use a SoC specific compatible string for it, and set quirks in the kernel driver based on that.
Quoted 6 lines
Devicetree is supposed to describe hardware, in this case the quirks are a property of the specific model of the hardware, so this should be expressed through the compatible string. Extra properties in devicetree are meant to be used for board specific things, like having a gpio to enable power to the sata target device. Extra properties should not be used in the way you are proposing to use them now.
OK, got it.
What I thoutht is using ahci_platform_get_of_property could make ahci_platform.c more shareable, adding the chance of removing specific compatible.
Just refer mmc_of_parse and sdhci_get_of_property, they are parsing property directly from dts.
Anyway, it is fine, here is not so many cases like mmc.
Thanks
RFC PATCH 1/2 libahci_platform: add ahci_platform_get_of_property
Hi,
Quoted 31 lines · zhangfei
Quoted 21 lines · Hans de Goede
Hi,
Quoted 8 lines · zhangfei
Hi Mark,
Quoted 5 lines · Mark Rutland
Quoted 3 lines · Zhangfei Gao
Instead of setting hflags in different files,
ahci_platform_get_of_propertysethpriv->flagswhenahci_platform_init_hostaccording to property in dts.Quoted 5 lines
Quoted 3 lines
The
AHCI_HFLAGSare a Linux implementation detail, so it would be nice to have a good justification for each of these being turned into DT properties.Do you mean only add required property now?
No you should not add any properties at all using properties to set SoC specific quirks is just wrong, if a device is not 100% ahci compatible you should use a SoC specific compatible string for it, and set quirks in the kernel driver based on that.
Quoted 6 lines
Devicetree is supposed to describe hardware, in this case the quirks are a property of the specific model of the hardware, so this should be expressed through the compatible string. Extra properties in devicetree are meant to be used for board specific things, like having a gpio to enable power to the sata target device. Extra properties should not be used in the way you are proposing to use them now.
Quoted 4 lines
OK, got it.
What I thoutht is using
ahci_platform_get_of_propertycould makeahci_platform.cmore shareable, adding the chance of removing specific compatible. Just refermmc_of_parseandsdhci_get_of_property, they are parsing property directly from dts.
I'm not familiar with sdhci_get_of_property, but mmc_of_parse is all about describing the board, not controller specific quirks. It sets things like how many bits the sdcard slot has (just because the controller has x bits does not mean they are all wired up), things like max speed (which again is not only a host but also a board property), things like which gpio to use for card detect, or if the mmc/sdio device is always present as it is soldered onto the board, etc.
Regards,
Hans
RFC PATCH 2/2 ahci: remove AHCI_HFLAG_NO_FBS setting
In reply to Zhangfei GaoAHCI_HFLAG can be set directly in dts.
For example
ahci:sata at f9900000 {
no-fbs;
no-ncq;
};--- drivers/ata/ahci_platform.c | 3 --- 1 file changed, 3 deletions(-)
drivers/ata/ahci_platform.c +0 -3
@@ -57,9 +57,6 @@ static int ahci_probe(struct platform_device *pdev) goto disable_resources; } -if (of_device_is_compatible (dev->of_node,"hisilicon,hisi-ahci" )) - hflags |=AHCI_HFLAG_NO_FBS ; - rc =ahci_platform_init_host (pdev, hpriv, &ahci_port_info, hflags,0 ,0 );if (rc)
Signature · 1 line
1.7.9.5
RFC PATCH 2/2 ahci: remove AHCI_HFLAG_NO_FBS setting
AHCI_HFLAG can be set directly in dts.
For example
ahci:sata at f9900000 {
no-fbs;
no-ncq;
};--- drivers/ata/ahci_platform.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/ata/ahci_platform.c +1 -6
@@ -34,7 +34,6 @@ static int ahci_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct ahci_platform_data *pdata =dev_get_platdata (dev);struct ahci_host_priv *hpriv; -unsigned long hflags =0 ;int rc; hpriv =ahci_platform_get_resources (pdev);
@@ -57,11 +56,7 @@ static int ahci_probe(struct platform_device *pdev) goto disable_resources; } -if (of_device_is_compatible (dev->of_node,"hisilicon,hisi-ahci" )) - hflags |=AHCI_HFLAG_NO_FBS ; - - rc =ahci_platform_init_host (pdev, hpriv, &ahci_port_info, - hflags,0 ,0 ); + rc =ahci_platform_init_host (pdev, hpriv, &ahci_port_info,0 ,0 ,0 );if (rc) goto pdata_exit;
Signature · 1 line
1.7.9.5