All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT
@ 2019-03-29  5:52 Sergio Paracuellos
  2019-03-29  5:52 ` [PATCH v2 1/3] staging: mt7621-dts: simplify pcie phy bindings Sergio Paracuellos
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sergio Paracuellos @ 2019-03-29  5:52 UTC (permalink / raw)
  To: neil; +Cc: gregkh, driverdev-devel

This series change both bindings and driver to don't use child nodes in the device tree.

This changes are inspired after Rob's bindings review which can be found here:

http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2019-March/133123.html

Changes in v2:
    - Use #phy_cells=1 into pcie1_phy also.
    - Update bindings documentation with this change.
    - Assume the cost of allocating MAX_PHYS phy's for both ports in driver code.

Hope this helps.

Best regards,
    Sergio Paracuellos

Sergio Paracuellos (3):
  staging: mt7621-dts: simplify pcie phy bindings
  staging: mt7621-pci-phy: update bindings documentation
  staging: mt7621-pci-phy: change driver to don't use child nodes

 drivers/staging/mt7621-dts/mt7621.dtsi        | 23 ++--------
 .../mediatek,mt7621-pci-phy.txt               | 44 ++++---------------
 .../staging/mt7621-pci-phy/pci-mt7621-phy.c   | 26 ++++++++---
 3 files changed, 32 insertions(+), 61 deletions(-)

-- 
2.19.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] staging: mt7621-dts: simplify pcie phy bindings
  2019-03-29  5:52 [PATCH v2 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT Sergio Paracuellos
@ 2019-03-29  5:52 ` Sergio Paracuellos
  2019-03-29  5:52 ` [PATCH v2 2/3] staging: mt7621-pci-phy: update bindings documentation Sergio Paracuellos
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Sergio Paracuellos @ 2019-03-29  5:52 UTC (permalink / raw)
  To: neil; +Cc: gregkh, driverdev-devel

If each phy port doesn't have its own resources, then we don't need
child nodes. Handle it using #phy-cells to 1 for both phy's.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: NeilBrown <neil@brown.name>
---
 drivers/staging/mt7621-dts/mt7621.dtsi | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi
index 17020e24abd2..280ec33c8540 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -491,7 +491,7 @@
 		reset-names = "pcie", "pcie0", "pcie1", "pcie2";
 		clocks = <&clkctrl 24 &clkctrl 25 &clkctrl 26>;
 		clock-names = "pcie0", "pcie1", "pcie2";
-		phys = <&pcie0_port>, <&pcie1_port>, <&pcie2_port>;
+		phys = <&pcie0_phy 0>, <&pcie0_phy 1>, <&pcie1_phy 0>;
 		phy-names = "pcie-phy0", "pcie-phy1", "pcie-phy2";
 
 		pcie@0,0 {
@@ -522,29 +522,12 @@
 	pcie0_phy: pcie-phy@1e149000 {
 		compatible = "mediatek,mt7621-pci-phy";
 		reg = <0x1e149000 0x0700>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		pcie0_port: pcie-phy@0 {
-			reg = <0>;
-			#phy-cells = <0>;
-		};
-
-		pcie1_port: pcie-phy@1 {
-			reg = <1>;
-			#phy-cells = <0>;
-		};
+		#phy-cells = <1>;
 	};
 
 	pcie1_phy: pcie-phy@1e14a000 {
 		compatible = "mediatek,mt7621-pci-phy";
 		reg = <0x1e14a000 0x0700>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		pcie2_port: pcie-phy@0 {
-			reg = <0>;
-			#phy-cells = <0>;
-		};
+		#phy-cells = <1>;
 	};
 };
-- 
2.19.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] staging: mt7621-pci-phy: update bindings documentation
  2019-03-29  5:52 [PATCH v2 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT Sergio Paracuellos
  2019-03-29  5:52 ` [PATCH v2 1/3] staging: mt7621-dts: simplify pcie phy bindings Sergio Paracuellos
@ 2019-03-29  5:52 ` Sergio Paracuellos
  2019-03-29  5:52 ` [PATCH v2 3/3] staging: mt7621-pci-phy: change driver to don't use child nodes Sergio Paracuellos
  2019-03-29  6:09 ` [PATCH v2 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT NeilBrown
  3 siblings, 0 replies; 5+ messages in thread
From: Sergio Paracuellos @ 2019-03-29  5:52 UTC (permalink / raw)
  To: neil; +Cc: gregkh, driverdev-devel

Device tree has been simplified to use phy-cells instead of
using child nodes. Update documentation accordly.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: NeilBrown <neil@brown.name>
---
 .../mediatek,mt7621-pci-phy.txt               | 44 ++++---------------
 1 file changed, 9 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/mt7621-pci-phy/mediatek,mt7621-pci-phy.txt b/drivers/staging/mt7621-pci-phy/mediatek,mt7621-pci-phy.txt
index 33a8a698bdd0..a369d715378b 100644
--- a/drivers/staging/mt7621-pci-phy/mediatek,mt7621-pci-phy.txt
+++ b/drivers/staging/mt7621-pci-phy/mediatek,mt7621-pci-phy.txt
@@ -3,45 +3,19 @@ Mediatek Mt7621 PCIe PHY
 Required properties:
 - compatible: must be "mediatek,mt7621-pci-phy"
 - reg: base address and length of the PCIe PHY block
-- #address-cells: must be 1
-- #size-cells: must be 0
-
-Each PCIe PHY should be represented by a child node
-
-Required properties For the child node:
-- reg: the PHY ID
-0 - PCIe RC 0
-1 - PCIe RC 1
-- #phy-cells: must be 0
+- #phy-cells: must be <1> for pcie0_phy and for pcie1_phy.
 
 Example:
-	pcie0_phy: pcie-phy@1a149000 {
+	pcie0_phy: pcie-phy@1e149000 {
 		compatible = "mediatek,mt7621-pci-phy";
-		reg = <0x1a149000 0x0700>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		pcie0_port: pcie-phy@0 {
-			reg = <0>;
-			#phy-cells = <0>;
-		};
-
-		pcie1_port: pcie-phy@1 {
-			reg = <1>;
-			#phy-cells = <0>;
-		};
+		reg = <0x1e149000 0x0700>;
+		#phy-cells = <1>;
 	};
 
-	pcie1_phy: pcie-phy@1a14a000 {
+	pcie1_phy: pcie-phy@1e14a000 {
 		compatible = "mediatek,mt7621-pci-phy";
-		reg = <0x1a14a000 0x0700>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		pcie2_port: pcie-phy@0 {
-			reg = <0>;
-			#phy-cells = <0>;
-		};
+		reg = <0x1e14a000 0x0700>;
+		#phy-cells = <1>;
 	};
 
 	/* users of the PCIe phy */
@@ -49,6 +23,6 @@ Example:
 	pcie: pcie@1e140000 {
 		...
 		...
-		phys = <&pcie0_port>, <&pcie1_port>, <&pcie2_port>;
+		phys = <&pcie0_phy 0>, <&pcie0_phy 1>, <&pcie1_phy 0>;
 		phy-names = "pcie-phy0", "pcie-phy1", "pcie-phy2";
-	};
\ No newline at end of file
+	};
-- 
2.19.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] staging: mt7621-pci-phy: change driver to don't use child nodes
  2019-03-29  5:52 [PATCH v2 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT Sergio Paracuellos
  2019-03-29  5:52 ` [PATCH v2 1/3] staging: mt7621-dts: simplify pcie phy bindings Sergio Paracuellos
  2019-03-29  5:52 ` [PATCH v2 2/3] staging: mt7621-pci-phy: update bindings documentation Sergio Paracuellos
@ 2019-03-29  5:52 ` Sergio Paracuellos
  2019-03-29  6:09 ` [PATCH v2 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT NeilBrown
  3 siblings, 0 replies; 5+ messages in thread
From: Sergio Paracuellos @ 2019-03-29  5:52 UTC (permalink / raw)
  To: neil; +Cc: gregkh, driverdev-devel

Device tree has been simplified to don't use child nodes and use
the #phy-cells property instead. Change the driver accordly implementing
custom 'xlate' function to return the correct phy for each port.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: NeilBrown <neil@brown.name>
---
 .../staging/mt7621-pci-phy/pci-mt7621-phy.c   | 26 ++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c b/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c
index 98c06308143c..118302c122ee 100644
--- a/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c
+++ b/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c
@@ -78,6 +78,8 @@
 
 #define RG_PE1_FRC_MSTCKDIV			BIT(5)
 
+#define MAX_PHYS	2
+
 /**
  * struct mt7621_pci_phy_instance - Mt7621 Pcie PHY device
  * @phy: pointer to the kernel PHY device
@@ -289,6 +291,20 @@ static const struct phy_ops mt7621_pci_phy_ops = {
 	.owner		= THIS_MODULE,
 };
 
+static struct phy *mt7621_pcie_phy_of_xlate(struct device *dev,
+					    struct of_phandle_args *args)
+{
+	struct mt7621_pci_phy *mt7621_phy = dev_get_drvdata(dev);
+
+	if (args->args_count == 0)
+		return mt7621_phy->phys[0]->phy;
+
+	if (WARN_ON(args->args[0] >= MAX_PHYS))
+		return ERR_PTR(-ENODEV);
+
+	return mt7621_phy->phys[args->args[0]]->phy;
+}
+
 static int mt7621_pci_phy_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -304,7 +320,7 @@ static int mt7621_pci_phy_probe(struct platform_device *pdev)
 	if (!phy)
 		return -ENOMEM;
 
-	phy->nphys = of_get_child_count(np);
+	phy->nphys = MAX_PHYS;
 	phy->phys = devm_kcalloc(dev, phy->nphys,
 				 sizeof(*phy->phys), GFP_KERNEL);
 	if (!phy->phys)
@@ -325,8 +341,7 @@ static int mt7621_pci_phy_probe(struct platform_device *pdev)
 		return PTR_ERR(port_base);
 	}
 
-	port = 0;
-	for_each_child_of_node(np, child_np) {
+	for (port = 0; port < MAX_PHYS; port++) {
 		struct mt7621_pci_phy_instance *instance;
 		struct phy *pphy;
 
@@ -338,7 +353,7 @@ static int mt7621_pci_phy_probe(struct platform_device *pdev)
 
 		phy->phys[port] = instance;
 
-		pphy = devm_phy_create(dev, child_np, &mt7621_pci_phy_ops);
+		pphy = devm_phy_create(dev, dev->of_node, &mt7621_pci_phy_ops);
 		if (IS_ERR(phy)) {
 			dev_err(dev, "failed to create phy\n");
 			ret = PTR_ERR(phy);
@@ -349,10 +364,9 @@ static int mt7621_pci_phy_probe(struct platform_device *pdev)
 		instance->phy = pphy;
 		instance->index = port;
 		phy_set_drvdata(pphy, instance);
-		port++;
 	}
 
-	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+	provider = devm_of_phy_provider_register(dev, mt7621_pcie_phy_of_xlate);
 
 	return PTR_ERR_OR_ZERO(provider);
 
-- 
2.19.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT
  2019-03-29  5:52 [PATCH v2 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT Sergio Paracuellos
                   ` (2 preceding siblings ...)
  2019-03-29  5:52 ` [PATCH v2 3/3] staging: mt7621-pci-phy: change driver to don't use child nodes Sergio Paracuellos
@ 2019-03-29  6:09 ` NeilBrown
  3 siblings, 0 replies; 5+ messages in thread
From: NeilBrown @ 2019-03-29  6:09 UTC (permalink / raw)
  To: Sergio Paracuellos; +Cc: gregkh, driverdev-devel


[-- Attachment #1.1: Type: text/plain, Size: 1193 bytes --]

On Fri, Mar 29 2019, Sergio Paracuellos wrote:

> This series change both bindings and driver to don't use child nodes in the device tree.
>
> This changes are inspired after Rob's bindings review which can be found here:
>
> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2019-March/133123.html
>
> Changes in v2:
>     - Use #phy_cells=1 into pcie1_phy also.
>     - Update bindings documentation with this change.
>     - Assume the cost of allocating MAX_PHYS phy's for both ports in driver code.
>
> Hope this helps.

Thanks.  Works correctly now.
  Reviewed-by: NeilBrown <neil@brown.name>

NeilBrown


>
> Best regards,
>     Sergio Paracuellos
>
> Sergio Paracuellos (3):
>   staging: mt7621-dts: simplify pcie phy bindings
>   staging: mt7621-pci-phy: update bindings documentation
>   staging: mt7621-pci-phy: change driver to don't use child nodes
>
>  drivers/staging/mt7621-dts/mt7621.dtsi        | 23 ++--------
>  .../mediatek,mt7621-pci-phy.txt               | 44 ++++---------------
>  .../staging/mt7621-pci-phy/pci-mt7621-phy.c   | 26 ++++++++---
>  3 files changed, 32 insertions(+), 61 deletions(-)
>
> -- 
> 2.19.1

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 169 bytes --]

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-29  6:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-29  5:52 [PATCH v2 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT Sergio Paracuellos
2019-03-29  5:52 ` [PATCH v2 1/3] staging: mt7621-dts: simplify pcie phy bindings Sergio Paracuellos
2019-03-29  5:52 ` [PATCH v2 2/3] staging: mt7621-pci-phy: update bindings documentation Sergio Paracuellos
2019-03-29  5:52 ` [PATCH v2 3/3] staging: mt7621-pci-phy: change driver to don't use child nodes Sergio Paracuellos
2019-03-29  6:09 ` [PATCH v2 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT NeilBrown

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.