diff mbox series

[V3,04/13] phy: rcar-gen3-usb2: Add support for r8a77470

Message ID 1554287324-22312-5-git-send-email-biju.das@bp.renesas.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series Add USB2.0 support | expand

Commit Message

Biju Das April 3, 2019, 10:28 a.m. UTC
This patch adds support for r8a77470 (RZ/G1C). We can reuse this driver for
initializing timing/interrupt generation registers.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
V1-->V2
 * Incorporated shimoda-san's review comment
 Ref: https://patchwork.kernel.org/patch/10655855/
---
 drivers/phy/renesas/Kconfig              |  2 +-
 drivers/phy/renesas/phy-rcar-gen3-usb2.c | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

Comments

Kishon Vijay Abraham I April 9, 2019, 10:28 a.m. UTC | #1
Hi Biju,

On 03/04/19 3:58 PM, Biju Das wrote:
> This patch adds support for r8a77470 (RZ/G1C). We can reuse this driver for
> initializing timing/interrupt generation registers.
> 
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> ---
> V1-->V2
>  * Incorporated shimoda-san's review comment
>  Ref: https://patchwork.kernel.org/patch/10655855/
> ---
>  drivers/phy/renesas/Kconfig              |  2 +-
>  drivers/phy/renesas/phy-rcar-gen3-usb2.c | 19 ++++++++++++++++++-
>  2 files changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig
> index e340a92..961ccb1 100644
> --- a/drivers/phy/renesas/Kconfig
> +++ b/drivers/phy/renesas/Kconfig
> @@ -19,7 +19,7 @@ config PHY_RCAR_GEN3_PCIE
>  config PHY_RCAR_GEN3_USB2
>  	tristate "Renesas R-Car generation 3 USB 2.0 PHY driver"
>  	depends on ARCH_RENESAS
> -	depends on EXTCON
> +	depends on EXTCON || ARCH_R8A77470
>  	depends on USB_SUPPORT
>  	select GENERIC_PHY
>  	select USB_COMMON
> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> index 0a34782..ac33a02 100644
> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> @@ -22,6 +22,7 @@
>  #include <linux/regulator/consumer.h>
>  #include <linux/usb/of.h>
>  #include <linux/workqueue.h>
> +#include <linux/sys_soc.h>
>  
>  /******* USB2.0 Host registers (original offset is +0x200) *******/
>  #define USB2_INT_ENABLE		0x000
> @@ -393,6 +394,12 @@ static const struct phy_ops rcar_gen3_phy_usb2_ops = {
>  	.owner		= THIS_MODULE,
>  };
>  
> +static const struct phy_ops rz_g1c_phy_usb2_ops = {
> +	.init		= rcar_gen3_phy_usb2_init,
> +	.exit		= rcar_gen3_phy_usb2_exit,
> +	.owner		= THIS_MODULE,
> +};
> +
>  static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
>  {
>  	struct rcar_gen3_chan *ch = _ch;
> @@ -411,6 +418,7 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
>  }
>  
>  static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = {
> +	{ .compatible = "renesas,usb2-phy-r8a77470" },
>  	{ .compatible = "renesas,usb2-phy-r8a7795" },
>  	{ .compatible = "renesas,usb2-phy-r8a7796" },
>  	{ .compatible = "renesas,usb2-phy-r8a77965" },
> @@ -425,12 +433,18 @@ static const unsigned int rcar_gen3_phy_cable[] = {
>  	EXTCON_NONE,
>  };
>  
> +static struct soc_device_attribute soc_r8a77470[] = {
> +	{ .soc_id = "r8a77470" },
> +	{ /* sentinel */ }
> +};
> +
>  static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct rcar_gen3_chan *channel;
>  	struct phy_provider *provider;
>  	struct resource *res;
> +	const struct phy_ops *phy_usb2_ops = &rcar_gen3_phy_usb2_ops;
>  	int irq, ret = 0;
>  
>  	if (!dev->of_node) {
> @@ -481,7 +495,10 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
>  	 * And then, phy-core will manage runtime pm for this device.
>  	 */
>  	pm_runtime_enable(dev);
> -	channel->phy = devm_phy_create(dev, NULL, &rcar_gen3_phy_usb2_ops);
> +	if (soc_device_match(soc_r8a77470))
> +		phy_usb2_ops = &rz_g1c_phy_usb2_ops;

Why not have the phy_ops in driver_data since you anyways have a new compatible
for r8a77470?

Thanks
Kishon
Yoshihiro Shimoda April 9, 2019, 10:37 a.m. UTC | #2
Hi Biju-san,

Thank you for the patch!

> From: Biju Das, Sent: Wednesday, April 3, 2019 7:29 PM
> 
> This patch adds support for r8a77470 (RZ/G1C). We can reuse this driver for
> initializing timing/interrupt generation registers.
> 
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> ---

It seems good to me. However, since Fabrizio-san and I have submitted patch(es)
for the driver around the same time, I'm confusing how to handle this patch.

< At March 1, 2019, 11:05 a.m. UTC >
https://patchwork.kernel.org/patch/10834975/

- Kishon-san said "merged" at April 1, but I mentioned this patch breaks R-Car D3.
- I checked today's his repo, but it doesn't seem to merge it.
- I don't get any feedback.

< At April 1, 2019, 12:01 p.m. UTC >
https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=99561

- Got Simon-san and Fabrizio-san's review.

and then, 

< At April 3, 2019, 10:28 a.m. UTC >
https://patchwork.kernel.org/patch/10883265/

> V1-->V2
>  * Incorporated shimoda-san's review comment
>  Ref: https://patchwork.kernel.org/patch/10655855/
> ---
>  drivers/phy/renesas/Kconfig              |  2 +-
>  drivers/phy/renesas/phy-rcar-gen3-usb2.c | 19 ++++++++++++++++++-
>  2 files changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig
> index e340a92..961ccb1 100644
> --- a/drivers/phy/renesas/Kconfig
> +++ b/drivers/phy/renesas/Kconfig
> @@ -19,7 +19,7 @@ config PHY_RCAR_GEN3_PCIE
>  config PHY_RCAR_GEN3_USB2
>  	tristate "Renesas R-Car generation 3 USB 2.0 PHY driver"
>  	depends on ARCH_RENESAS
> -	depends on EXTCON
> +	depends on EXTCON || ARCH_R8A77470

If EXTCON=m, build error might happen like below.
https://marc.info/?l=linux-renesas-soc&m=154220057305761&w=2

Is it enough about "depends on EXTCON || !EXTCON" for your environment?

Best regards,
Yoshihiro Shimoda
Biju Das April 9, 2019, 11:20 a.m. UTC | #3
Hi Kishon,

Thanks for the feedback.

> Subject: Re: [PATCH V3 04/13] phy: rcar-gen3-usb2: Add support for r8a77470
> 
> Hi Biju,
> 
> On 03/04/19 3:58 PM, Biju Das wrote:
> > This patch adds support for r8a77470 (RZ/G1C). We can reuse this
> > driver for initializing timing/interrupt generation registers.
> >
> > Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> > ---
> > V1-->V2
> >  * Incorporated shimoda-san's review comment
> >  Ref: https://patchwork.kernel.org/patch/10655855/
> > ---
> >  drivers/phy/renesas/Kconfig              |  2 +-
> >  drivers/phy/renesas/phy-rcar-gen3-usb2.c | 19 ++++++++++++++++++-
> >  2 files changed, 19 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig
> > index e340a92..961ccb1 100644
> > --- a/drivers/phy/renesas/Kconfig
> > +++ b/drivers/phy/renesas/Kconfig
> > @@ -19,7 +19,7 @@ config PHY_RCAR_GEN3_PCIE  config
> PHY_RCAR_GEN3_USB2
> >  	tristate "Renesas R-Car generation 3 USB 2.0 PHY driver"
> >  	depends on ARCH_RENESAS
> > -	depends on EXTCON
> > +	depends on EXTCON || ARCH_R8A77470
> >  	depends on USB_SUPPORT
> >  	select GENERIC_PHY
> >  	select USB_COMMON
> > diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > index 0a34782..ac33a02 100644
> > --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > @@ -22,6 +22,7 @@
> >  #include <linux/regulator/consumer.h>  #include <linux/usb/of.h>
> > #include <linux/workqueue.h>
> > +#include <linux/sys_soc.h>
> >
> >  /******* USB2.0 Host registers (original offset is +0x200) *******/
> >  #define USB2_INT_ENABLE		0x000
> > @@ -393,6 +394,12 @@ static const struct phy_ops
> rcar_gen3_phy_usb2_ops = {
> >  	.owner		= THIS_MODULE,
> >  };
> >
> > +static const struct phy_ops rz_g1c_phy_usb2_ops = {
> > +	.init		= rcar_gen3_phy_usb2_init,
> > +	.exit		= rcar_gen3_phy_usb2_exit,
> > +	.owner		= THIS_MODULE,
> > +};
> > +
> >  static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)  {
> >  	struct rcar_gen3_chan *ch = _ch;
> > @@ -411,6 +418,7 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq,
> > void *_ch)  }
> >
> >  static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = {
> > +	{ .compatible = "renesas,usb2-phy-r8a77470" },
> >  	{ .compatible = "renesas,usb2-phy-r8a7795" },
> >  	{ .compatible = "renesas,usb2-phy-r8a7796" },
> >  	{ .compatible = "renesas,usb2-phy-r8a77965" }, @@ -425,12 +433,18
> @@
> > static const unsigned int rcar_gen3_phy_cable[] = {
> >  	EXTCON_NONE,
> >  };
> >
> > +static struct soc_device_attribute soc_r8a77470[] = {
> > +	{ .soc_id = "r8a77470" },
> > +	{ /* sentinel */ }
> > +};
> > +
> >  static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)  {
> >  	struct device *dev = &pdev->dev;
> >  	struct rcar_gen3_chan *channel;
> >  	struct phy_provider *provider;
> >  	struct resource *res;
> > +	const struct phy_ops *phy_usb2_ops = &rcar_gen3_phy_usb2_ops;
> >  	int irq, ret = 0;
> >
> >  	if (!dev->of_node) {
> > @@ -481,7 +495,10 @@ static int rcar_gen3_phy_usb2_probe(struct
> platform_device *pdev)
> >  	 * And then, phy-core will manage runtime pm for this device.
> >  	 */
> >  	pm_runtime_enable(dev);
> > -	channel->phy = devm_phy_create(dev, NULL,
> &rcar_gen3_phy_usb2_ops);
> > +	if (soc_device_match(soc_r8a77470))
> > +		phy_usb2_ops = &rz_g1c_phy_usb2_ops;
> 
> Why not have the phy_ops in driver_data since you anyways have a new
> compatible for r8a77470?

SoC device match will take care of SoC revision. We have multiple revision of SoC variants like ES1.0, ES1.1
There is another  SoC similar to RZ/G1C known as R-Car E2X.   If you add it in compatible, it takes care only about the SoC , not the SoC revisions.

Regards,
Biju
Kishon Vijay Abraham I April 9, 2019, 11:28 a.m. UTC | #4
Hi,

On 09/04/19 4:50 PM, Biju Das wrote:
> Hi Kishon,
> 
> Thanks for the feedback.
> 
>> Subject: Re: [PATCH V3 04/13] phy: rcar-gen3-usb2: Add support for r8a77470
>>
>> Hi Biju,
>>
>> On 03/04/19 3:58 PM, Biju Das wrote:
>>> This patch adds support for r8a77470 (RZ/G1C). We can reuse this
>>> driver for initializing timing/interrupt generation registers.
>>>
>>> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
>>> ---
>>> V1-->V2
>>>  * Incorporated shimoda-san's review comment
>>>  Ref: https://patchwork.kernel.org/patch/10655855/
>>> ---
>>>  drivers/phy/renesas/Kconfig              |  2 +-
>>>  drivers/phy/renesas/phy-rcar-gen3-usb2.c | 19 ++++++++++++++++++-
>>>  2 files changed, 19 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig
>>> index e340a92..961ccb1 100644
>>> --- a/drivers/phy/renesas/Kconfig
>>> +++ b/drivers/phy/renesas/Kconfig
>>> @@ -19,7 +19,7 @@ config PHY_RCAR_GEN3_PCIE  config
>> PHY_RCAR_GEN3_USB2
>>>  	tristate "Renesas R-Car generation 3 USB 2.0 PHY driver"
>>>  	depends on ARCH_RENESAS
>>> -	depends on EXTCON
>>> +	depends on EXTCON || ARCH_R8A77470
>>>  	depends on USB_SUPPORT
>>>  	select GENERIC_PHY
>>>  	select USB_COMMON
>>> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
>>> b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
>>> index 0a34782..ac33a02 100644
>>> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
>>> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
>>> @@ -22,6 +22,7 @@
>>>  #include <linux/regulator/consumer.h>  #include <linux/usb/of.h>
>>> #include <linux/workqueue.h>
>>> +#include <linux/sys_soc.h>
>>>
>>>  /******* USB2.0 Host registers (original offset is +0x200) *******/
>>>  #define USB2_INT_ENABLE		0x000
>>> @@ -393,6 +394,12 @@ static const struct phy_ops
>> rcar_gen3_phy_usb2_ops = {
>>>  	.owner		= THIS_MODULE,
>>>  };
>>>
>>> +static const struct phy_ops rz_g1c_phy_usb2_ops = {
>>> +	.init		= rcar_gen3_phy_usb2_init,
>>> +	.exit		= rcar_gen3_phy_usb2_exit,
>>> +	.owner		= THIS_MODULE,
>>> +};
>>> +
>>>  static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)  {
>>>  	struct rcar_gen3_chan *ch = _ch;
>>> @@ -411,6 +418,7 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq,
>>> void *_ch)  }
>>>
>>>  static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = {
>>> +	{ .compatible = "renesas,usb2-phy-r8a77470" },
>>>  	{ .compatible = "renesas,usb2-phy-r8a7795" },
>>>  	{ .compatible = "renesas,usb2-phy-r8a7796" },
>>>  	{ .compatible = "renesas,usb2-phy-r8a77965" }, @@ -425,12 +433,18
>> @@
>>> static const unsigned int rcar_gen3_phy_cable[] = {
>>>  	EXTCON_NONE,
>>>  };
>>>
>>> +static struct soc_device_attribute soc_r8a77470[] = {
>>> +	{ .soc_id = "r8a77470" },
>>> +	{ /* sentinel */ }
>>> +};
>>> +
>>>  static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)  {
>>>  	struct device *dev = &pdev->dev;
>>>  	struct rcar_gen3_chan *channel;
>>>  	struct phy_provider *provider;
>>>  	struct resource *res;
>>> +	const struct phy_ops *phy_usb2_ops = &rcar_gen3_phy_usb2_ops;
>>>  	int irq, ret = 0;
>>>
>>>  	if (!dev->of_node) {
>>> @@ -481,7 +495,10 @@ static int rcar_gen3_phy_usb2_probe(struct
>> platform_device *pdev)
>>>  	 * And then, phy-core will manage runtime pm for this device.
>>>  	 */
>>>  	pm_runtime_enable(dev);
>>> -	channel->phy = devm_phy_create(dev, NULL,
>> &rcar_gen3_phy_usb2_ops);
>>> +	if (soc_device_match(soc_r8a77470))
>>> +		phy_usb2_ops = &rz_g1c_phy_usb2_ops;
>>
>> Why not have the phy_ops in driver_data since you anyways have a new
>> compatible for r8a77470?
> 
> SoC device match will take care of SoC revision. We have multiple revision of SoC variants like ES1.0, ES1.1
> There is another  SoC similar to RZ/G1C known as R-Car E2X.   If you add it in compatible, it takes care only about the SoC , not the SoC revisions.

We should add that when there's really a configuration change between ES1.0 and
ES1.1. Even the phy_ops can be the same with power_on/power_off return for
r8a77470 unless you have planned to add something later.

Thanks
Kishon
Biju Das April 9, 2019, 1:09 p.m. UTC | #5
Hi Shimoda-San,

Thanks for the feedback.

> Subject: RE: [PATCH V3 04/13] phy: rcar-gen3-usb2: Add support for r8a77470
> 
> Hi Biju-san,
> 
> Thank you for the patch!
> 
> > From: Biju Das, Sent: Wednesday, April 3, 2019 7:29 PM
> >
> > This patch adds support for r8a77470 (RZ/G1C). We can reuse this
> > driver for initializing timing/interrupt generation registers.
> >
> > Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> > ---
> 
> It seems good to me. However, since Fabrizio-san and I have submitted
> patch(es) for the driver around the same time, I'm confusing how to handle
> this patch.
> 
> < At March 1, 2019, 11:05 a.m. UTC >
> https://patchwork.kernel.org/patch/10834975/
> 
> - Kishon-san said "merged" at April 1, but I mentioned this patch breaks R-Car
> D3.
> - I checked today's his repo, but it doesn't seem to merge it.
> - I don't get any feedback.
> 
> < At April 1, 2019, 12:01 p.m. UTC >
> https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=99561
> 
> - Got Simon-san and Fabrizio-san's review.
> 
> and then,
> 
> < At April 3, 2019, 10:28 a.m. UTC >
> https://patchwork.kernel.org/patch/10883265/
> 
> > V1-->V2
> >  * Incorporated shimoda-san's review comment
> >  Ref: https://patchwork.kernel.org/patch/10655855/
> > ---
> >  drivers/phy/renesas/Kconfig              |  2 +-
> >  drivers/phy/renesas/phy-rcar-gen3-usb2.c | 19 ++++++++++++++++++-
> >  2 files changed, 19 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig
> > index e340a92..961ccb1 100644
> > --- a/drivers/phy/renesas/Kconfig
> > +++ b/drivers/phy/renesas/Kconfig
> > @@ -19,7 +19,7 @@ config PHY_RCAR_GEN3_PCIE  config
> PHY_RCAR_GEN3_USB2
> >  	tristate "Renesas R-Car generation 3 USB 2.0 PHY driver"
> >  	depends on ARCH_RENESAS
> > -	depends on EXTCON
> > +	depends on EXTCON || ARCH_R8A77470
> 
> If EXTCON=m, build error might happen like below.
> https://marc.info/?l=linux-renesas-soc&m=154220057305761&w=2
> 
> Is it enough about "depends on EXTCON || !EXTCON" for your environment?

Yes, it is fine. I will send V4 with this change along with kishon's review comment.

Regards,
Biju
Biju Das April 9, 2019, 1:11 p.m. UTC | #6
Hi Kishon,

Thanks for the feedback.

> >> Subject: Re: [PATCH V3 04/13] phy: rcar-gen3-usb2: Add support for
> >> r8a77470
> >>
> >> Hi Biju,
> >>
> >> On 03/04/19 3:58 PM, Biju Das wrote:
> >>> This patch adds support for r8a77470 (RZ/G1C). We can reuse this
> >>> driver for initializing timing/interrupt generation registers.
> >>>
> >>> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> >>> ---
> >>> V1-->V2
> >>>  * Incorporated shimoda-san's review comment
> >>>  Ref: https://patchwork.kernel.org/patch/10655855/
> >>> ---
> >>>  drivers/phy/renesas/Kconfig              |  2 +-
> >>>  drivers/phy/renesas/phy-rcar-gen3-usb2.c | 19 ++++++++++++++++++-
> >>>  2 files changed, 19 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/phy/renesas/Kconfig
> >>> b/drivers/phy/renesas/Kconfig index e340a92..961ccb1 100644
> >>> --- a/drivers/phy/renesas/Kconfig
> >>> +++ b/drivers/phy/renesas/Kconfig
> >>> @@ -19,7 +19,7 @@ config PHY_RCAR_GEN3_PCIE  config
> >> PHY_RCAR_GEN3_USB2
> >>>  	tristate "Renesas R-Car generation 3 USB 2.0 PHY driver"
> >>>  	depends on ARCH_RENESAS
> >>> -	depends on EXTCON
> >>> +	depends on EXTCON || ARCH_R8A77470
> >>>  	depends on USB_SUPPORT
> >>>  	select GENERIC_PHY
> >>>  	select USB_COMMON
> >>> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> >>> b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> >>> index 0a34782..ac33a02 100644
> >>> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> >>> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> >>> @@ -22,6 +22,7 @@
> >>>  #include <linux/regulator/consumer.h>  #include <linux/usb/of.h>
> >>> #include <linux/workqueue.h>
> >>> +#include <linux/sys_soc.h>
> >>>
> >>>  /******* USB2.0 Host registers (original offset is +0x200) *******/
> >>>  #define USB2_INT_ENABLE		0x000
> >>> @@ -393,6 +394,12 @@ static const struct phy_ops
> >> rcar_gen3_phy_usb2_ops = {
> >>>  	.owner		= THIS_MODULE,
> >>>  };
> >>>
> >>> +static const struct phy_ops rz_g1c_phy_usb2_ops = {
> >>> +	.init		= rcar_gen3_phy_usb2_init,
> >>> +	.exit		= rcar_gen3_phy_usb2_exit,
> >>> +	.owner		= THIS_MODULE,
> >>> +};
> >>> +
> >>>  static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)  {
> >>>  	struct rcar_gen3_chan *ch = _ch;
> >>> @@ -411,6 +418,7 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int
> >>> irq, void *_ch)  }
> >>>
> >>>  static const struct of_device_id rcar_gen3_phy_usb2_match_table[] =
> >>> {
> >>> +	{ .compatible = "renesas,usb2-phy-r8a77470" },
> >>>  	{ .compatible = "renesas,usb2-phy-r8a7795" },
> >>>  	{ .compatible = "renesas,usb2-phy-r8a7796" },
> >>>  	{ .compatible = "renesas,usb2-phy-r8a77965" }, @@ -425,12 +433,18
> >> @@
> >>> static const unsigned int rcar_gen3_phy_cable[] = {
> >>>  	EXTCON_NONE,
> >>>  };
> >>>
> >>> +static struct soc_device_attribute soc_r8a77470[] = {
> >>> +	{ .soc_id = "r8a77470" },
> >>> +	{ /* sentinel */ }
> >>> +};
> >>> +
> >>>  static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)  {
> >>>  	struct device *dev = &pdev->dev;
> >>>  	struct rcar_gen3_chan *channel;
> >>>  	struct phy_provider *provider;
> >>>  	struct resource *res;
> >>> +	const struct phy_ops *phy_usb2_ops = &rcar_gen3_phy_usb2_ops;
> >>>  	int irq, ret = 0;
> >>>
> >>>  	if (!dev->of_node) {
> >>> @@ -481,7 +495,10 @@ static int rcar_gen3_phy_usb2_probe(struct
> >> platform_device *pdev)
> >>>  	 * And then, phy-core will manage runtime pm for this device.
> >>>  	 */
> >>>  	pm_runtime_enable(dev);
> >>> -	channel->phy = devm_phy_create(dev, NULL,
> >> &rcar_gen3_phy_usb2_ops);
> >>> +	if (soc_device_match(soc_r8a77470))
> >>> +		phy_usb2_ops = &rz_g1c_phy_usb2_ops;
> >>
> >> Why not have the phy_ops in driver_data since you anyways have a new
> >> compatible for r8a77470?
> >
> > SoC device match will take care of SoC revision. We have multiple revision
> of SoC variants like ES1.0, ES1.1
> > There is another  SoC similar to RZ/G1C known as R-Car E2X.   If you add it in
> compatible, it takes care only about the SoC , not the SoC revisions.
> 
> We should add that when there's really a configuration change between
> ES1.0 and ES1.1. Even the phy_ops can be the same with
> power_on/power_off return for
> r8a77470 unless you have planned to add something later.

OK. I will add phy_ops in driver_data and remove soc_device_match.

On future if there is a configuration change/need for a quirks between SoC versions
will add the same.

Regards,
Biju
diff mbox series

Patch

diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig
index e340a92..961ccb1 100644
--- a/drivers/phy/renesas/Kconfig
+++ b/drivers/phy/renesas/Kconfig
@@ -19,7 +19,7 @@  config PHY_RCAR_GEN3_PCIE
 config PHY_RCAR_GEN3_USB2
 	tristate "Renesas R-Car generation 3 USB 2.0 PHY driver"
 	depends on ARCH_RENESAS
-	depends on EXTCON
+	depends on EXTCON || ARCH_R8A77470
 	depends on USB_SUPPORT
 	select GENERIC_PHY
 	select USB_COMMON
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 0a34782..ac33a02 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -22,6 +22,7 @@ 
 #include <linux/regulator/consumer.h>
 #include <linux/usb/of.h>
 #include <linux/workqueue.h>
+#include <linux/sys_soc.h>
 
 /******* USB2.0 Host registers (original offset is +0x200) *******/
 #define USB2_INT_ENABLE		0x000
@@ -393,6 +394,12 @@  static const struct phy_ops rcar_gen3_phy_usb2_ops = {
 	.owner		= THIS_MODULE,
 };
 
+static const struct phy_ops rz_g1c_phy_usb2_ops = {
+	.init		= rcar_gen3_phy_usb2_init,
+	.exit		= rcar_gen3_phy_usb2_exit,
+	.owner		= THIS_MODULE,
+};
+
 static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
 {
 	struct rcar_gen3_chan *ch = _ch;
@@ -411,6 +418,7 @@  static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
 }
 
 static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = {
+	{ .compatible = "renesas,usb2-phy-r8a77470" },
 	{ .compatible = "renesas,usb2-phy-r8a7795" },
 	{ .compatible = "renesas,usb2-phy-r8a7796" },
 	{ .compatible = "renesas,usb2-phy-r8a77965" },
@@ -425,12 +433,18 @@  static const unsigned int rcar_gen3_phy_cable[] = {
 	EXTCON_NONE,
 };
 
+static struct soc_device_attribute soc_r8a77470[] = {
+	{ .soc_id = "r8a77470" },
+	{ /* sentinel */ }
+};
+
 static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct rcar_gen3_chan *channel;
 	struct phy_provider *provider;
 	struct resource *res;
+	const struct phy_ops *phy_usb2_ops = &rcar_gen3_phy_usb2_ops;
 	int irq, ret = 0;
 
 	if (!dev->of_node) {
@@ -481,7 +495,10 @@  static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 	 * And then, phy-core will manage runtime pm for this device.
 	 */
 	pm_runtime_enable(dev);
-	channel->phy = devm_phy_create(dev, NULL, &rcar_gen3_phy_usb2_ops);
+	if (soc_device_match(soc_r8a77470))
+		phy_usb2_ops = &rz_g1c_phy_usb2_ops;
+
+	channel->phy = devm_phy_create(dev, NULL, phy_usb2_ops);
 	if (IS_ERR(channel->phy)) {
 		dev_err(dev, "Failed to create USB2 PHY\n");
 		ret = PTR_ERR(channel->phy);