Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
On Mon, Feb 29, 2016 at 3:20 AM, Petr Kulhavy wrote: > > > On 26.02.2016 15:23, Bin Liu wrote: >> >> Hi, >> >> On Fri, Feb 26, 2016 at 10:29:12AM +0100, Petr Kulhavy wrote: >>> >>> On 26.02.2016 04:15, Bin Liu wrote: On Thu, Feb 25, 2016 at 01:04:13PM +0100, Petr Kulhavy wrote: > Well, so we're still at the same point - there is a fundamental > mismatch in the different developers' view how the "power" parameter > should be represented. > There already 3 opinions at the moment: > 1) hard code - Felipe, Rob > 2) use the "mentor,power" - Sergei, Petr > 3) use a regulator - Rob > > So unless this conflict is resolved it is slightly difficult to > submit a patch that would get accepted. > How can we resolve this conflict ? This power property is used by core to control the hub port power budget, which is sourced by vbus. But vbus is not coming from musb, but a board power rail. So hardcode it does not make sense. Regards, -Bin. >>> >>> So what would be your take then? >> >> Don't hardcode in 5/5, and drop musb_get_power() in this patch. > > > Hi Bin, > > I will drop the musb_get_power and use the "mentor,power" property. > However Rob is not willing to accept that, he's insisting on a regulator. I believe I said setting it in the driver is fine as the list above says. If you have 10 boards and 10 different current limits, then yes it should be in DT (as a regulator). Rob -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
Hi, On Mon, Feb 29, 2016 at 12:23:46PM -0600, Bin Liu wrote: > Hi, > > On Mon, Feb 29, 2016 at 10:20:55AM +0100, Petr Kulhavy wrote: > > > > > > On 26.02.2016 15:23, Bin Liu wrote: > > >Hi, > > > > > >On Fri, Feb 26, 2016 at 10:29:12AM +0100, Petr Kulhavy wrote: > > >>On 26.02.2016 04:15, Bin Liu wrote: > > >>>On Thu, Feb 25, 2016 at 01:04:13PM +0100, Petr Kulhavy wrote: > > >>> > > Well, so we're still at the same point - there is a fundamental > > mismatch in the different developers' view how the "power" parameter > > should be represented. > > There already 3 opinions at the moment: > > 1) hard code - Felipe, Rob > > 2) use the "mentor,power" - Sergei, Petr > > 3) use a regulator - Rob > > > > So unless this conflict is resolved it is slightly difficult to > > submit a patch that would get accepted. > > How can we resolve this conflict ? > > >>>This power property is used by core to control the hub port power > > >>>budget, which is sourced by vbus. But vbus is not coming from musb, but > > >>>a board power rail. So hardcode it does not make sense. > > >>> > > >>>Regards, > > >>>-Bin. > > >>So what would be your take then? > > >Don't hardcode in 5/5, and drop musb_get_power() in this patch. > > > > Hi Bin, > > > > I will drop the musb_get_power and use the "mentor,power" property. > > However Rob is not willing to accept that, he's insisting on a regulator. > > Can you please point me to the link to Rob's comments? I failed to find > it in this list. Petr, thanks for the pointers, I forgot Rob commented on PATCH 1/5. I've pinged Rob again, let's see his final comments. Regards, -Bin. > > Thanks, > -Bin. > > > > > Regards > > Petr -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
Hi, On Mon, Feb 29, 2016 at 10:20:55AM +0100, Petr Kulhavy wrote: > > > On 26.02.2016 15:23, Bin Liu wrote: > >Hi, > > > >On Fri, Feb 26, 2016 at 10:29:12AM +0100, Petr Kulhavy wrote: > >>On 26.02.2016 04:15, Bin Liu wrote: > >>>On Thu, Feb 25, 2016 at 01:04:13PM +0100, Petr Kulhavy wrote: > >>> > Well, so we're still at the same point - there is a fundamental > mismatch in the different developers' view how the "power" parameter > should be represented. > There already 3 opinions at the moment: > 1) hard code - Felipe, Rob > 2) use the "mentor,power" - Sergei, Petr > 3) use a regulator - Rob > > So unless this conflict is resolved it is slightly difficult to > submit a patch that would get accepted. > How can we resolve this conflict ? > >>>This power property is used by core to control the hub port power > >>>budget, which is sourced by vbus. But vbus is not coming from musb, but > >>>a board power rail. So hardcode it does not make sense. > >>> > >>>Regards, > >>>-Bin. > >>So what would be your take then? > >Don't hardcode in 5/5, and drop musb_get_power() in this patch. > > Hi Bin, > > I will drop the musb_get_power and use the "mentor,power" property. > However Rob is not willing to accept that, he's insisting on a regulator. Can you please point me to the link to Rob's comments? I failed to find it in this list. Thanks, -Bin. > > Regards > Petr -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
On 26.02.2016 15:23, Bin Liu wrote: Hi, On Fri, Feb 26, 2016 at 10:29:12AM +0100, Petr Kulhavy wrote: On 26.02.2016 04:15, Bin Liu wrote: On Thu, Feb 25, 2016 at 01:04:13PM +0100, Petr Kulhavy wrote: Well, so we're still at the same point - there is a fundamental mismatch in the different developers' view how the "power" parameter should be represented. There already 3 opinions at the moment: 1) hard code - Felipe, Rob 2) use the "mentor,power" - Sergei, Petr 3) use a regulator - Rob So unless this conflict is resolved it is slightly difficult to submit a patch that would get accepted. How can we resolve this conflict ? This power property is used by core to control the hub port power budget, which is sourced by vbus. But vbus is not coming from musb, but a board power rail. So hardcode it does not make sense. Regards, -Bin. So what would be your take then? Don't hardcode in 5/5, and drop musb_get_power() in this patch. Hi Bin, I will drop the musb_get_power and use the "mentor,power" property. However Rob is not willing to accept that, he's insisting on a regulator. Regards Petr -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
Hi, On Fri, Feb 26, 2016 at 10:29:12AM +0100, Petr Kulhavy wrote: > > On 26.02.2016 04:15, Bin Liu wrote: > >On Thu, Feb 25, 2016 at 01:04:13PM +0100, Petr Kulhavy wrote: > > > >>Well, so we're still at the same point - there is a fundamental > >>mismatch in the different developers' view how the "power" parameter > >>should be represented. > >>There already 3 opinions at the moment: > >>1) hard code - Felipe, Rob > >>2) use the "mentor,power" - Sergei, Petr > >>3) use a regulator - Rob > >> > >>So unless this conflict is resolved it is slightly difficult to > >>submit a patch that would get accepted. > >>How can we resolve this conflict ? > >This power property is used by core to control the hub port power > >budget, which is sourced by vbus. But vbus is not coming from musb, but > >a board power rail. So hardcode it does not make sense. > > > >Regards, > >-Bin. > So what would be your take then? Don't hardcode in 5/5, and drop musb_get_power() in this patch. Regards, -Bin. > > Petr -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
On 26.02.2016 04:15, Bin Liu wrote: On Thu, Feb 25, 2016 at 01:04:13PM +0100, Petr Kulhavy wrote: Well, so we're still at the same point - there is a fundamental mismatch in the different developers' view how the "power" parameter should be represented. There already 3 opinions at the moment: 1) hard code - Felipe, Rob 2) use the "mentor,power" - Sergei, Petr 3) use a regulator - Rob So unless this conflict is resolved it is slightly difficult to submit a patch that would get accepted. How can we resolve this conflict ? This power property is used by core to control the hub port power budget, which is sourced by vbus. But vbus is not coming from musb, but a board power rail. So hardcode it does not make sense. Regards, -Bin. So what would be your take then? Petr -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
Hi, On Wed, Feb 24, 2016 at 04:27:15PM +0100, Petr Kulhavy wrote: > This adds two functions to get DT properties "mentor,power" and "dr_mode": > musb_get_power() and musb_get_mode() Sorry for my late comments, but I don't see the value of adding musb_get_power() into musb core. It is just a wraper, I don't think other glues will use it. Regards, -Bin. > > Signed-off-by: Petr Kulhavy > --- > v4: > - created musb_get_dr_mode() > > v5: > - musb_get_dr_mode() renamed to musb_get_mode() > - added musb_get_power() > > v6: > - musb_get_power() : added missing boundary check for the maximum value 510mA > - formatting > - added empty implementation of musb_get_power() > > v7: > - removed empty implementation of musb_get_power() > - musb_get_mode() returns MUSB_OTG if the property is not found > > drivers/usb/musb/musb_core.c | 37 + > drivers/usb/musb/musb_core.h | 15 +++ > 2 files changed, 52 insertions(+) > > diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c > index c3791a0..ff7f5d0 100644 > --- a/drivers/usb/musb/musb_core.c > +++ b/drivers/usb/musb/musb_core.c > @@ -100,6 +100,7 @@ > #include > #include > #include > +#include > > #include "musb_core.h" > > @@ -129,6 +130,42 @@ static inline struct musb *dev_to_musb(struct device > *dev) > return dev_get_drvdata(dev); > } > > +enum musb_mode musb_get_mode(struct device *dev) > +{ > + enum usb_dr_mode mode; > + > + mode = usb_get_dr_mode(dev); > + switch (mode) { > + case USB_DR_MODE_HOST: > + return MUSB_HOST; > + case USB_DR_MODE_PERIPHERAL: > + return MUSB_PERIPHERAL; > + case USB_DR_MODE_OTG: > + case USB_DR_MODE_UNKNOWN: > + default: > + return MUSB_OTG; > + } > +} > +EXPORT_SYMBOL_GPL(musb_get_mode); > + > +#ifdef CONFIG_OF > +u8 musb_get_power(struct device *dev) > +{ > + int ret; > + unsigned power_ma; > + > + /* the "mentor,power" value is in milliamperes, whereas > + * the mentor configuration is in 2mA units > + */ > + ret = of_property_read_u32(dev->of_node, "mentor,power", &power_ma); > + if (ret) > + return 0; > + > + return power_ma > 510 ? 255 : power_ma / 2; > +} > +EXPORT_SYMBOL_GPL(musb_get_power); > +#endif > + > /*-*/ > > #ifndef CONFIG_BLACKFIN > diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h > index fd215fb..c2ee702 100644 > --- a/drivers/usb/musb/musb_core.h > +++ b/drivers/usb/musb/musb_core.h > @@ -614,4 +614,19 @@ static inline void > musb_platform_post_root_reset_end(struct musb *musb) > musb->ops->post_root_reset_end(musb); > } > > +/* gets the "dr_mode" property from DT and converts it into musb_mode > + * if the property is not found or not recognized returns MUSB_OTG > + */ > +extern enum musb_mode musb_get_mode(struct device *dev); > + > +#if IS_ENABLED(CONFIG_OF) > +/* gets the "mentor,power" property from DT > + * and converts it from mA to 2mA units for the "power" parameter > + * in struct musb_hdrc_platform_data > + * > + * in case the property is not found returns 0 > + */ > +extern u8 musb_get_power(struct device *dev); > +#endif > + > #endif /* __MUSB_CORE_H__ */ > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
Hi, On Thu, Feb 25, 2016 at 01:04:13PM +0100, Petr Kulhavy wrote: > On 25.02.2016 12:53, Sergei Shtylyov wrote: > > > >>> I then fail to understand the logic behind hard coding. > >> > >>And I fail to understand your plans with the other drivers. > >>Are you trying to say that the "mentor,power" (or "power" in OMAP2430) > >>property should be completely abandoned and the values hard > >>coded in _all_ > >>drivers? > > > > Contrariwise, I don't think it should be hard-coded anywhere. > > Well, so we're still at the same point - there is a fundamental > mismatch in the different developers' view how the "power" parameter > should be represented. > There already 3 opinions at the moment: > 1) hard code - Felipe, Rob > 2) use the "mentor,power" - Sergei, Petr > 3) use a regulator - Rob > > So unless this conflict is resolved it is slightly difficult to > submit a patch that would get accepted. > How can we resolve this conflict ? This power property is used by core to control the hub port power budget, which is sourced by vbus. But vbus is not coming from musb, but a board power rail. So hardcode it does not make sense. Regards, -Bin. > > Regards > Petr > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
On 25.02.2016 12:53, Sergei Shtylyov wrote: I then fail to understand the logic behind hard coding. And I fail to understand your plans with the other drivers. Are you trying to say that the "mentor,power" (or "power" in OMAP2430) property should be completely abandoned and the values hard coded in _all_ drivers? Contrariwise, I don't think it should be hard-coded anywhere. Well, so we're still at the same point - there is a fundamental mismatch in the different developers' view how the "power" parameter should be represented. There already 3 opinions at the moment: 1) hard code - Felipe, Rob 2) use the "mentor,power" - Sergei, Petr 3) use a regulator - Rob So unless this conflict is resolved it is slightly difficult to submit a patch that would get accepted. How can we resolve this conflict ? Regards Petr -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
Hello. On 2/25/2016 11:55 AM, Petr Kulhavy wrote: +#if IS_ENABLED(CONFIG_OF) +/* gets the "mentor,power" property from DT + * and converts it from mA to 2mA units for the "power" parameter + * in struct musb_hdrc_platform_data + * + * in case the property is not found returns 0 + */ +extern u8 musb_get_power(struct device *dev); +#endif + Now that you hard-coded the value, you don't need this function any more. I have left it there so it can be used by the other drivers. I then fail to understand the logic behind hard coding. And I fail to understand your plans with the other drivers. Are you trying to say that the "mentor,power" (or "power" in OMAP2430) property should be completely abandoned and the values hard coded in _all_ drivers? Contrariwise, I don't think it should be hard-coded anywhere. Petr MBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
On 24.02.2016 18:30, Sergei Shtylyov wrote: On 02/24/2016 08:10 PM, Petr Kulhavy wrote: +#if IS_ENABLED(CONFIG_OF) +/* gets the "mentor,power" property from DT + * and converts it from mA to 2mA units for the "power" parameter + * in struct musb_hdrc_platform_data + * + * in case the property is not found returns 0 + */ +extern u8 musb_get_power(struct device *dev); +#endif + Now that you hard-coded the value, you don't need this function any more. I have left it there so it can be used by the other drivers. I then fail to understand the logic behind hard coding. And I fail to understand your plans with the other drivers. Are you trying to say that the "mentor,power" (or "power" in OMAP2430) property should be completely abandoned and the values hard coded in _all_ drivers? Petr -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
On 02/24/2016 08:10 PM, Petr Kulhavy wrote: +#if IS_ENABLED(CONFIG_OF) +/* gets the "mentor,power" property from DT + * and converts it from mA to 2mA units for the "power" parameter + * in struct musb_hdrc_platform_data + * + * in case the property is not found returns 0 + */ +extern u8 musb_get_power(struct device *dev); +#endif + Now that you hard-coded the value, you don't need this function any more. I have left it there so it can be used by the other drivers. I then fail to understand the logic behind hard coding. Petr MBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
On 24.02.2016 18:00, Sergei Shtylyov wrote: +#if IS_ENABLED(CONFIG_OF) +/* gets the "mentor,power" property from DT + * and converts it from mA to 2mA units for the "power" parameter + * in struct musb_hdrc_platform_data + * + * in case the property is not found returns 0 + */ +extern u8 musb_get_power(struct device *dev); +#endif + Now that you hard-coded the value, you don't need this function any more. I have left it there so it can be used by the other drivers. Petr -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
Hello. On 02/24/2016 06:27 PM, Petr Kulhavy wrote: This adds two functions to get DT properties "mentor,power" and "dr_mode": musb_get_power() and musb_get_mode() Signed-off-by: Petr Kulhavy --- v4: - created musb_get_dr_mode() v5: - musb_get_dr_mode() renamed to musb_get_mode() - added musb_get_power() v6: - musb_get_power() : added missing boundary check for the maximum value 510mA - formatting - added empty implementation of musb_get_power() v7: - removed empty implementation of musb_get_power() - musb_get_mode() returns MUSB_OTG if the property is not found [...] diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index fd215fb..c2ee702 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -614,4 +614,19 @@ static inline void musb_platform_post_root_reset_end(struct musb *musb) musb->ops->post_root_reset_end(musb); } +/* gets the "dr_mode" property from DT and converts it into musb_mode + * if the property is not found or not recognized returns MUSB_OTG + */ +extern enum musb_mode musb_get_mode(struct device *dev); + +#if IS_ENABLED(CONFIG_OF) +/* gets the "mentor,power" property from DT + * and converts it from mA to 2mA units for the "power" parameter + * in struct musb_hdrc_platform_data + * + * in case the property is not found returns 0 + */ +extern u8 musb_get_power(struct device *dev); +#endif + Now that you hard-coded the value, you don't need this function any more. [...] MBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
Hi, Petr Kulhavy writes: > This adds two functions to get DT properties "mentor,power" and "dr_mode": > musb_get_power() and musb_get_mode() > > Signed-off-by: Petr Kulhavy Bin, is this okay for you ? > --- > v4: > - created musb_get_dr_mode() > > v5: > - musb_get_dr_mode() renamed to musb_get_mode() > - added musb_get_power() > > v6: > - musb_get_power() : added missing boundary check for the maximum value 510mA > - formatting > - added empty implementation of musb_get_power() > > v7: > - removed empty implementation of musb_get_power() > - musb_get_mode() returns MUSB_OTG if the property is not found > > drivers/usb/musb/musb_core.c | 37 + > drivers/usb/musb/musb_core.h | 15 +++ > 2 files changed, 52 insertions(+) > > diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c > index c3791a0..ff7f5d0 100644 > --- a/drivers/usb/musb/musb_core.c > +++ b/drivers/usb/musb/musb_core.c > @@ -100,6 +100,7 @@ > #include > #include > #include > +#include > > #include "musb_core.h" > > @@ -129,6 +130,42 @@ static inline struct musb *dev_to_musb(struct device > *dev) > return dev_get_drvdata(dev); > } > > +enum musb_mode musb_get_mode(struct device *dev) > +{ > + enum usb_dr_mode mode; > + > + mode = usb_get_dr_mode(dev); > + switch (mode) { > + case USB_DR_MODE_HOST: > + return MUSB_HOST; > + case USB_DR_MODE_PERIPHERAL: > + return MUSB_PERIPHERAL; > + case USB_DR_MODE_OTG: > + case USB_DR_MODE_UNKNOWN: > + default: > + return MUSB_OTG; > + } > +} > +EXPORT_SYMBOL_GPL(musb_get_mode); > + > +#ifdef CONFIG_OF > +u8 musb_get_power(struct device *dev) > +{ > + int ret; > + unsigned power_ma; > + > + /* the "mentor,power" value is in milliamperes, whereas > + * the mentor configuration is in 2mA units > + */ > + ret = of_property_read_u32(dev->of_node, "mentor,power", &power_ma); > + if (ret) > + return 0; > + > + return power_ma > 510 ? 255 : power_ma / 2; > +} > +EXPORT_SYMBOL_GPL(musb_get_power); > +#endif > + > /*-*/ > > #ifndef CONFIG_BLACKFIN > diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h > index fd215fb..c2ee702 100644 > --- a/drivers/usb/musb/musb_core.h > +++ b/drivers/usb/musb/musb_core.h > @@ -614,4 +614,19 @@ static inline void > musb_platform_post_root_reset_end(struct musb *musb) > musb->ops->post_root_reset_end(musb); > } > > +/* gets the "dr_mode" property from DT and converts it into musb_mode > + * if the property is not found or not recognized returns MUSB_OTG > + */ > +extern enum musb_mode musb_get_mode(struct device *dev); > + > +#if IS_ENABLED(CONFIG_OF) > +/* gets the "mentor,power" property from DT > + * and converts it from mA to 2mA units for the "power" parameter > + * in struct musb_hdrc_platform_data > + * > + * in case the property is not found returns 0 > + */ > +extern u8 musb_get_power(struct device *dev); > +#endif > + > #endif /* __MUSB_CORE_H__ */ > -- > 1.9.1 > -- balbi signature.asc Description: PGP signature
[PATCH 2/5 v7] usb: musb: core: added helper functions for parsing DT
This adds two functions to get DT properties "mentor,power" and "dr_mode": musb_get_power() and musb_get_mode() Signed-off-by: Petr Kulhavy --- v4: - created musb_get_dr_mode() v5: - musb_get_dr_mode() renamed to musb_get_mode() - added musb_get_power() v6: - musb_get_power() : added missing boundary check for the maximum value 510mA - formatting - added empty implementation of musb_get_power() v7: - removed empty implementation of musb_get_power() - musb_get_mode() returns MUSB_OTG if the property is not found drivers/usb/musb/musb_core.c | 37 + drivers/usb/musb/musb_core.h | 15 +++ 2 files changed, 52 insertions(+) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index c3791a0..ff7f5d0 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -100,6 +100,7 @@ #include #include #include +#include #include "musb_core.h" @@ -129,6 +130,42 @@ static inline struct musb *dev_to_musb(struct device *dev) return dev_get_drvdata(dev); } +enum musb_mode musb_get_mode(struct device *dev) +{ + enum usb_dr_mode mode; + + mode = usb_get_dr_mode(dev); + switch (mode) { + case USB_DR_MODE_HOST: + return MUSB_HOST; + case USB_DR_MODE_PERIPHERAL: + return MUSB_PERIPHERAL; + case USB_DR_MODE_OTG: + case USB_DR_MODE_UNKNOWN: + default: + return MUSB_OTG; + } +} +EXPORT_SYMBOL_GPL(musb_get_mode); + +#ifdef CONFIG_OF +u8 musb_get_power(struct device *dev) +{ + int ret; + unsigned power_ma; + + /* the "mentor,power" value is in milliamperes, whereas +* the mentor configuration is in 2mA units +*/ + ret = of_property_read_u32(dev->of_node, "mentor,power", &power_ma); + if (ret) + return 0; + + return power_ma > 510 ? 255 : power_ma / 2; +} +EXPORT_SYMBOL_GPL(musb_get_power); +#endif + /*-*/ #ifndef CONFIG_BLACKFIN diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index fd215fb..c2ee702 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -614,4 +614,19 @@ static inline void musb_platform_post_root_reset_end(struct musb *musb) musb->ops->post_root_reset_end(musb); } +/* gets the "dr_mode" property from DT and converts it into musb_mode + * if the property is not found or not recognized returns MUSB_OTG + */ +extern enum musb_mode musb_get_mode(struct device *dev); + +#if IS_ENABLED(CONFIG_OF) +/* gets the "mentor,power" property from DT + * and converts it from mA to 2mA units for the "power" parameter + * in struct musb_hdrc_platform_data + * + * in case the property is not found returns 0 + */ +extern u8 musb_get_power(struct device *dev); +#endif + #endif /* __MUSB_CORE_H__ */ -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html