diff mbox

[1/3] phy: rockchip-usb: should be a child device of the GRF

Message ID 1459431812-6286-2-git-send-email-heiko@sntech.de (mailing list archive)
State New, archived
Headers show

Commit Message

Heiko Stuebner March 31, 2016, 1:43 p.m. UTC
The usb-phy is fully enclosed in the general register files (GRF).
Therefore as seen from the device-tree it shouldn't be a separate platform-
device but instead a sub-device of the GRF - using the simply-mfd mechanism.

As the usb-phy is part of the kernel for some releases now, we keep
the old (and now deprecated) binding for compatibility purposes.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 .../devicetree/bindings/phy/rockchip-usb-phy.txt   | 27 ++++++++++++++--------
 drivers/phy/phy-rockchip-usb.c                     | 14 ++++++++---
 2 files changed, 28 insertions(+), 13 deletions(-)

Comments

Heiko Stuebner April 19, 2016, 6:13 a.m. UTC | #1
Hi Kishon.

Am Donnerstag, 31. März 2016, 15:43:30 schrieb Heiko Stuebner:
> The usb-phy is fully enclosed in the general register files (GRF).
> Therefore as seen from the device-tree it shouldn't be a separate platform-
> device but instead a sub-device of the GRF - using the simply-mfd mechanism.
> 
> As the usb-phy is part of the kernel for some releases now, we keep
> the old (and now deprecated) binding for compatibility purposes.
> 
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>

could you look into picking this patch up for 4.7?

Same principle as for the other phy drivers, but it's already in the kernel 
for a while, so it gets a fallback for the old binding and can go through the 
normal way.

The other two (devicetree-)patches I would then simply queue for 4.8 myself 
after you're fine with the driver-side.


Thanks
Heiko

> ---
>  .../devicetree/bindings/phy/rockchip-usb-phy.txt   | 27
> ++++++++++++++-------- drivers/phy/phy-rockchip-usb.c                     |
> 14 ++++++++--- 2 files changed, 28 insertions(+), 13 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
> b/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt index
> 68498d5..cc6be96 100644
> --- a/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
> +++ b/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
> @@ -5,11 +5,13 @@ Required properties:
>       "rockchip,rk3066a-usb-phy"
>       "rockchip,rk3188-usb-phy"
>       "rockchip,rk3288-usb-phy"
> - - rockchip,grf : phandle to the syscon managing the "general
> -   register files"
>   - #address-cells: should be 1
>   - #size-cells: should be 0
> 
> +Deprecated properties:
> + - rockchip,grf : phandle to the syscon managing the "general
> +   register files" - phy should be a child of the GRF instead
> +
>  Sub-nodes:
>  Each PHY should be represented as a sub-node.
> 
> @@ -28,14 +30,19 @@ Optional Properties:
> 
>  Example:
> 
> -usbphy: phy {
> -	compatible = "rockchip,rk3288-usb-phy";
> -	rockchip,grf = <&grf>;
> -	#address-cells = <1>;
> -	#size-cells = <0>;
> +grf: syscon@ff770000 {
> +	compatible = "rockchip,rk3288-grf", "syscon", "simple-mfd";
> +
> +...
> +
> +	usbphy: phy {
> +		compatible = "rockchip,rk3288-usb-phy";
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> 
> -	usbphy0: usb-phy0 {
> -		#phy-cells = <0>;
> -		reg = <0x320>;
> +		usbphy0: usb-phy0 {
> +			#phy-cells = <0>;
> +			reg = <0x320>;
> +		};
>  	};
>  };
> diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c
> index f62d899..23f33db 100644
> --- a/drivers/phy/phy-rockchip-usb.c
> +++ b/drivers/phy/phy-rockchip-usb.c
> @@ -397,8 +397,12 @@ static int rockchip_usb_phy_probe(struct
> platform_device *pdev) phy_base->pdata = match->data;
> 
>  	phy_base->dev = dev;
> -	phy_base->reg_base = syscon_regmap_lookup_by_phandle(dev->of_node,
> -							     "rockchip,grf");
> +	phy_base->reg_base = ERR_PTR(-ENODEV);
> +	if (dev->parent && dev->parent->of_node)
> +		phy_base->reg_base = syscon_node_to_regmap(dev->parent->of_node);
> +	if (IS_ERR(phy_base->reg_base))
> +		phy_base->reg_base = syscon_regmap_lookup_by_phandle(
> +						dev->of_node, "rockchip,grf");
>  	if (IS_ERR(phy_base->reg_base)) {
>  		dev_err(&pdev->dev, "Missing rockchip,grf property\n");
>  		return PTR_ERR(phy_base->reg_base);
> @@ -463,7 +467,11 @@ static int __init rockchip_init_usb_uart(void)
>  		return -ENOTSUPP;
>  	}
> 
> -	grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
> +	grf = ERR_PTR(-ENODEV);
> +	if (np->parent)
> +		grf = syscon_node_to_regmap(np->parent);
> +	if (IS_ERR(grf))
> +		grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
>  	if (IS_ERR(grf)) {
>  		pr_err("%s: Missing rockchip,grf property, %lu\n",
>  		       __func__, PTR_ERR(grf));
Heiko Stuebner April 30, 2016, 8:07 p.m. UTC | #2
Hi Kishon,

Am Dienstag, 19. April 2016, 08:13:47 schrieb Heiko Stübner:
> Hi Kishon.
> 
> Am Donnerstag, 31. März 2016, 15:43:30 schrieb Heiko Stuebner:
> > The usb-phy is fully enclosed in the general register files (GRF).
> > Therefore as seen from the device-tree it shouldn't be a separate
> > platform-
> > device but instead a sub-device of the GRF - using the simply-mfd
> > mechanism.
> > 
> > As the usb-phy is part of the kernel for some releases now, we keep
> > the old (and now deprecated) binding for compatibility purposes.
> > 
> > Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> 
> could you look into picking this patch up for 4.7?
> 
> Same principle as for the other phy drivers, but it's already in the kernel
> for a while, so it gets a fallback for the old binding and can go through
> the normal way.
> 
> The other two (devicetree-)patches I would then simply queue for 4.8 myself
> after you're fine with the driver-side.

just saw that you already have a tag for 4.7-related phy changes since this 
afternoon, but no phy pull to Greg on lkml yet.

So maybe there is still a way for this phy conversion (to be under the 
Rockchip GRF node) to make it in for 4.7 :-) ?


Thanks
Heiko
Kishon Vijay Abraham I May 3, 2016, 10:58 a.m. UTC | #3
On Sunday 01 May 2016 01:37 AM, Heiko Stübner wrote:
> Hi Kishon,
> 
> Am Dienstag, 19. April 2016, 08:13:47 schrieb Heiko Stübner:
>> Hi Kishon.
>>
>> Am Donnerstag, 31. März 2016, 15:43:30 schrieb Heiko Stuebner:
>>> The usb-phy is fully enclosed in the general register files (GRF).
>>> Therefore as seen from the device-tree it shouldn't be a separate
>>> platform-
>>> device but instead a sub-device of the GRF - using the simply-mfd
>>> mechanism.
>>>
>>> As the usb-phy is part of the kernel for some releases now, we keep
>>> the old (and now deprecated) binding for compatibility purposes.
>>>
>>> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
>>
>> could you look into picking this patch up for 4.7?
>>
>> Same principle as for the other phy drivers, but it's already in the kernel
>> for a while, so it gets a fallback for the old binding and can go through
>> the normal way.
>>
>> The other two (devicetree-)patches I would then simply queue for 4.8 myself
>> after you're fine with the driver-side.
> 
> just saw that you already have a tag for 4.7-related phy changes since this 
> afternoon, but no phy pull to Greg on lkml yet.
> 
> So maybe there is still a way for this phy conversion (to be under the 
> Rockchip GRF node) to make it in for 4.7 :-) ?

Looks like I've missed this before sending the pull request. Sorry about that.
Is it okay if the PHY changes also go in 4.8?

-Kishon
Heiko Stuebner May 3, 2016, 11:02 a.m. UTC | #4
Hi Kishon,

Am Dienstag, 3. Mai 2016, 16:28:35 schrieb Kishon Vijay Abraham I:
> On Sunday 01 May 2016 01:37 AM, Heiko Stübner wrote:
> > Am Dienstag, 19. April 2016, 08:13:47 schrieb Heiko Stübner:
> >> Am Donnerstag, 31. März 2016, 15:43:30 schrieb Heiko Stuebner:
> >>> The usb-phy is fully enclosed in the general register files (GRF).
> >>> Therefore as seen from the device-tree it shouldn't be a separate
> >>> platform-
> >>> device but instead a sub-device of the GRF - using the simply-mfd
> >>> mechanism.
> >>> 
> >>> As the usb-phy is part of the kernel for some releases now, we keep
> >>> the old (and now deprecated) binding for compatibility purposes.
> >>> 
> >>> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> >> 
> >> could you look into picking this patch up for 4.7?
> >> 
> >> Same principle as for the other phy drivers, but it's already in the
> >> kernel
> >> for a while, so it gets a fallback for the old binding and can go through
> >> the normal way.
> >> 
> >> The other two (devicetree-)patches I would then simply queue for 4.8
> >> myself
> >> after you're fine with the driver-side.
> > 
> > just saw that you already have a tag for 4.7-related phy changes since
> > this
> > afternoon, but no phy pull to Greg on lkml yet.
> > 
> > So maybe there is still a way for this phy conversion (to be under the
> > Rockchip GRF node) to make it in for 4.7 :-) ?
> 
> Looks like I've missed this before sending the pull request. Sorry about
> that. Is it okay if the PHY changes also go in 4.8?

yep, 4.8 is no problem as well. We have the current binding in the kernel for 
so long, that waiting one more kernel release won't be a problem.


Heiko
Kishon Vijay Abraham I June 17, 2016, 12:35 p.m. UTC | #5
Hi Heiko,

On Tuesday 03 May 2016 04:32 PM, Heiko Stübner wrote:
> Hi Kishon,
> 
> Am Dienstag, 3. Mai 2016, 16:28:35 schrieb Kishon Vijay Abraham I:
>> On Sunday 01 May 2016 01:37 AM, Heiko Stübner wrote:
>>> Am Dienstag, 19. April 2016, 08:13:47 schrieb Heiko Stübner:
>>>> Am Donnerstag, 31. März 2016, 15:43:30 schrieb Heiko Stuebner:
>>>>> The usb-phy is fully enclosed in the general register files (GRF).
>>>>> Therefore as seen from the device-tree it shouldn't be a separate
>>>>> platform-
>>>>> device but instead a sub-device of the GRF - using the simply-mfd
>>>>> mechanism.
>>>>>
>>>>> As the usb-phy is part of the kernel for some releases now, we keep
>>>>> the old (and now deprecated) binding for compatibility purposes.
>>>>>
>>>>> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
>>>>
>>>> could you look into picking this patch up for 4.7?
>>>>
>>>> Same principle as for the other phy drivers, but it's already in the
>>>> kernel
>>>> for a while, so it gets a fallback for the old binding and can go through
>>>> the normal way.
>>>>
>>>> The other two (devicetree-)patches I would then simply queue for 4.8
>>>> myself
>>>> after you're fine with the driver-side.
>>>
>>> just saw that you already have a tag for 4.7-related phy changes since
>>> this
>>> afternoon, but no phy pull to Greg on lkml yet.
>>>
>>> So maybe there is still a way for this phy conversion (to be under the
>>> Rockchip GRF node) to make it in for 4.7 :-) ?
>>
>> Looks like I've missed this before sending the pull request. Sorry about
>> that. Is it okay if the PHY changes also go in 4.8?
> 
> yep, 4.8 is no problem as well. We have the current binding in the kernel for 
> so long, that waiting one more kernel release won't be a problem.

Can you resend the patch after fixing these checkpatch warnings?
WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#52:
device but instead a sub-device of the GRF - using the simply-mfd mechanism.

WARNING: line over 80 characters
#123: FILE: drivers/phy/phy-rockchip-usb.c:402:
+		phy_base->reg_base = syscon_node_to_regmap(dev->parent->of_node);

total: 0 errors, 2 warnings, 68 lines checked

After that I'll take them in my -next.

Thanks
Kishon
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt b/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
index 68498d5..cc6be96 100644
--- a/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
+++ b/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
@@ -5,11 +5,13 @@  Required properties:
      "rockchip,rk3066a-usb-phy"
      "rockchip,rk3188-usb-phy"
      "rockchip,rk3288-usb-phy"
- - rockchip,grf : phandle to the syscon managing the "general
-   register files"
  - #address-cells: should be 1
  - #size-cells: should be 0
 
+Deprecated properties:
+ - rockchip,grf : phandle to the syscon managing the "general
+   register files" - phy should be a child of the GRF instead
+
 Sub-nodes:
 Each PHY should be represented as a sub-node.
 
@@ -28,14 +30,19 @@  Optional Properties:
 
 Example:
 
-usbphy: phy {
-	compatible = "rockchip,rk3288-usb-phy";
-	rockchip,grf = <&grf>;
-	#address-cells = <1>;
-	#size-cells = <0>;
+grf: syscon@ff770000 {
+	compatible = "rockchip,rk3288-grf", "syscon", "simple-mfd";
+
+...
+
+	usbphy: phy {
+		compatible = "rockchip,rk3288-usb-phy";
+		#address-cells = <1>;
+		#size-cells = <0>;
 
-	usbphy0: usb-phy0 {
-		#phy-cells = <0>;
-		reg = <0x320>;
+		usbphy0: usb-phy0 {
+			#phy-cells = <0>;
+			reg = <0x320>;
+		};
 	};
 };
diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c
index f62d899..23f33db 100644
--- a/drivers/phy/phy-rockchip-usb.c
+++ b/drivers/phy/phy-rockchip-usb.c
@@ -397,8 +397,12 @@  static int rockchip_usb_phy_probe(struct platform_device *pdev)
 	phy_base->pdata = match->data;
 
 	phy_base->dev = dev;
-	phy_base->reg_base = syscon_regmap_lookup_by_phandle(dev->of_node,
-							     "rockchip,grf");
+	phy_base->reg_base = ERR_PTR(-ENODEV);
+	if (dev->parent && dev->parent->of_node)
+		phy_base->reg_base = syscon_node_to_regmap(dev->parent->of_node);
+	if (IS_ERR(phy_base->reg_base))
+		phy_base->reg_base = syscon_regmap_lookup_by_phandle(
+						dev->of_node, "rockchip,grf");
 	if (IS_ERR(phy_base->reg_base)) {
 		dev_err(&pdev->dev, "Missing rockchip,grf property\n");
 		return PTR_ERR(phy_base->reg_base);
@@ -463,7 +467,11 @@  static int __init rockchip_init_usb_uart(void)
 		return -ENOTSUPP;
 	}
 
-	grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
+	grf = ERR_PTR(-ENODEV);
+	if (np->parent)
+		grf = syscon_node_to_regmap(np->parent);
+	if (IS_ERR(grf))
+		grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
 	if (IS_ERR(grf)) {
 		pr_err("%s: Missing rockchip,grf property, %lu\n",
 		       __func__, PTR_ERR(grf));