doc: usb: usbmisc-imx: add imx7d compatible string
Subsystems (4)
PATCH 1/4 doc: usb: usbmisc-imx: add imx7d compatible string
Add compatible string for imx7d-usbmisc.
--- Documentation/devicetree/bindings/usb/usbmisc-imx.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/usbmisc-imx.txt +1 -0
@@ -6,6 +6,7 @@ Required properties: "fsl,imx6q-usbmisc" for imx6q "fsl,vf610-usbmisc" for Vybrid vf610 "fsl,imx6sx-usbmisc" for imx6sx + "fsl,imx7d-usbmisc" for imx7d - reg: Should contain registers location and length Examples:
Signature · 1 line
1.9.1
PATCH 2/4 doc: usb: ci-hdrc-usb2: add property over-current-polarity
Adding over-current-polarity to indicate the over current flag is low active or high active.
--- Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2 -0
@@ -81,6 +81,8 @@ i.mx specific properties - fsl,usbmisc: phandler of non-core register device, with one argument that indicate usb controller index - disable-over-current: disable over current detect +- over-current-polarity: 0 if the over current signal polarity is low active, + 1 if the over current signal polarity is high active. - external-vbus-divider: enables off-chip resistor divider for Vbus Example:
Signature · 1 line
1.9.1
PATCH 2/4 doc: usb: ci-hdrc-usb2: add property over-current-polarity
Greetings,
Quoted 13 lines · Li Jun
Adding over-current-polarity to indicate the over current flag is low active or high active.
Signed-off-by Li Jun <[email protected]>--- Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +0
-0
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt i.mx specific properties · line 88
Quoted 8 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2
-0@@ -81,6 +81,8 @@ i.mx specific properties - fsl,usbmisc: phandler of non-core register device, with one argument that indicate usb controller index - disable-over-current: disable over current detect +- over-current-polarity: 0 if the over current signal polarity is low active, + 1 if the over current signal polarity is high active. - external-vbus-divider: enables off-chip resistor divider for Vbus Example:
The gpio device bindings already have active low/ active high. Could that be used here?
In the imx SPI subsystem, for instance, the developers used gpio rather than MUXED spi chipselect lines for exactly this kind of flexibility.
If there is no magic happening in silicon (which would seem to be the case if we can handle inverting polarity in the driver), I would suggest going the gpiod route.
Thanks,
Joshua
PATCH 2/4 doc: usb: ci-hdrc-usb2: add property over-current-polarity
Quoted 22 lines · Joshua Clayton
Greetings,
Quoted 20 lines · Li Jun
Adding over-current-polarity to indicate the over current flag is low active or high active.
Signed-off-by Li Jun <[email protected]>--- Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2
-0@@ -81,6 +81,8 @@ i.mx specific properties - fsl,usbmisc: phandler of non-core register device, with one argument that indicate usb controller index - disable-over-current: disable over current detect +- over-current-polarity: 0 if the over current signal polarity is low active, + 1 if the over current signal polarity is high active. - external-vbus-divider: enables off-chip resistor divider for Vbus
Quoted 4 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt i.mx specific properties · line 88
Quoted 1 line
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +0
-0Example:The gpio device bindings already have active low/ active high. Could that be used here?
No, the over current pin is a dedicated pin for USB, you need to configure it through pinmux. If we are using a gpio (even the same pin as OC pin), the USB subsystem will not know OC event. The polarity is for OC pin and configured through USB register.
Quoted 6 lines
In the imx SPI subsystem, for instance, the developers used gpio rather than MUXED spi chipselect lines for exactly this kind of flexibility.
If there is no magic happening in silicon (which would seem to be the case if we can handle inverting polarity in the driver), I would suggest going the gpiod route.
Signature · 2 lines
Best Regards, Peter Chen
PATCH 2/4 doc: usb: ci-hdrc-usb2: add property over-current-polarity
Hi,
Quoted 40 lines
-----Original Message-----
From: Peter Chen [mailto:hzpeterchen at gmail.com]
Sent: Tuesday, July 19, 2016 9:47 AM
To: Joshua Clayton <[email protected]>
Cc: Jun Li <[email protected]>; Peter Chen <[email protected]>; robh+dt at kernel.org; shawnguo at kernel.org; devicetree at vger.kernel.org; linux-usb at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH 2/4] doc: usb: ci-hdrc-usb2: add property over- current-polarityQuoted 24 lines · Joshua Clayton
Greetings,
Quoted 22 lines · Li Jun
Adding over-current-polarity to indicate the over current flag is low active or high active.
Signed-off-by Li Jun <[email protected]>--- Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +3
-0@@ -81,6 +81,8 @@ i.mx specific properties - fsl,usbmisc: phandler of non-core register device, with one argument that indicate usb controller index - disable-over-current: disable over current detect +- over-current-polarity: 0 if the over current signal polarity is +low active, + 1 if the over current signal polarity is high active. - external-vbus-divider: enables off-chip resistor divider for VbusQuoted 4 lines
Quoted 1 line
Example:
The gpio device bindings already have active low/ active high. Could that be used here?
Quoted 4 lines
No, the over current pin is a dedicated pin for USB, you need to configure it through pinmux. If we are using a gpio (even the same pin as OC pin), the USB subsystem will not know OC event. The polarity is for OC pin and configured through USB register.
Agree with Peter, there is do have magic in silicon of usb controller, which is part of ehci spec so ehci host driver can take care of it as a standard usb event.
Quoted 4 lines
Quoted 3 lines
In the imx SPI subsystem, for instance, the developers used gpio rather than MUXED spi chipselect lines for exactly this kind of
flexibility.
I guess your SPI example is not a normal usage, but by that way to workaround some silicon issue.
Li Jun
Quoted 10 lines
Quoted 3 lines
If there is no magic happening in silicon (which would seem to be the case if we can handle inverting polarity in the driver), I would suggest
going the gpiod route.
Quoted 1 line
--
Best Regards,
Peter Chen
Rob Herring
maintainerPATCH 2/4 doc: usb: ci-hdrc-usb2: add property over-current-polarity
In reply to Li JunQuoted 13 lines · Li Jun
Adding over-current-polarity to indicate the over current flag is low active or high active.
Signed-off-by Li Jun <[email protected]>--- Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +0
-0
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt i.mx specific properties · line 85
Quoted 5 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2
-0@@ -81,6 +81,8 @@ i.mx specific properties - fsl,usbmisc: phandler of non-core register device, with one argument that indicate usb controller index - disable-over-current: disable over current detect +- over-current-polarity: 0 if the over current signal polarity is low active, + 1 if the over current signal polarity is high active.
Make the common case be no property and make this bool. So if typically active high, the property is "over-current-active-low".
Rob
PATCH 3/4 ARM: dts: imx7d-sdb: Set OTG2 oc polarity to be active low
In reply to Li JunSet OTG2 over current flag to be active low, OTG1 OC is not used by default.
--- arch/arm/boot/dts/imx7d-sdb.dts | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/imx7d-sdb.dts +8 -0
@@ -287,7 +287,9 @@ &usbotg2 { vbus-supply = <®_usb_otg2_vbus>; + pinctrl-0 = <&pinctrl_usbotg2>; dr_mode = "host"; + over-current-polarity = <0>; status = "okay"; };
@@ -415,6 +417,12 @@ >; }; + pinctrl_usbotg2: usbotg2grp { + fsl,pins = < + MX7D_PAD_GPIO1_IO06__USB_OTG2_OC 0x59 + >; + }; + pinctrl_usdhc1: usdhc1grp { fsl,pins = < MX7D_PAD_SD1_CMD__SD1_CMD 0x59
Signature · 1 line
1.9.1
PATCH 4/4 usb: chipidea: imx: set over current polarity per dts setting
In reply to Li JunWith over-current-polarity property added, imx usb over current polarity can be configed to be low or high active, since the default setting value(0) is for active high, so keep this setting for those legacy platforms without this property specified.
--- drivers/usb/chipidea/ci_hdrc_imx.c | 9 +++++++++ drivers/usb/chipidea/ci_hdrc_imx.h | 1 + drivers/usb/chipidea/usbmisc_imx.c | 30 +++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-)
drivers/usb/chipidea/ci_hdrc_imx.c +9 -0
@@ -140,6 +140,15 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)if (of_find_property (np,"disable-over-current" ,NULL )) data->disable_oc =1 ; +if (!of_property_read_u32 (np,"over-current-polarity" , &ret)) + data->oc_polarity = ret ?1 :0 ; +else +/* +* Keep the oc polarity setting of legacy +* platforms unchanged. +*/ + data->oc_polarity =1 ; +if (of_find_property (np,"external-vbus-divider" ,NULL )) data->evdo =1 ;
drivers/usb/chipidea/ci_hdrc_imx.h +1 -0
@@ -17,6 +17,7 @@ struct imx_usbmisc_data {int index; unsigned int disable_oc:1; /* over current detect disabled */ + unsigned int oc_polarity:1; /* over current polarity if oc enabled */ unsigned int evdo:1; /* set external vbus divider option */ };
drivers/usb/chipidea/usbmisc_imx.c +25 -5
@@ -56,6 +56,7 @@#define MX6_BM_NON_BURST_SETTING BIT(1)#define MX6_BM_OVER_CUR_DIS BIT(7) +#define MX6_BM_OVER_CUR_POLARITY BIT(8)#define MX6_BM_WAKEUP_ENABLE BIT(10)#define MX6_BM_ID_WAKEUP BIT(16)#define MX6_BM_VBUS_WAKEUP BIT(17)
@@ -266,11 +267,18 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)spin_lock_irqsave (&usbmisc->lock, flags); + reg =readl (usbmisc->base + data->index *4 );if (data->disable_oc) { - reg =readl (usbmisc->base + data->index *4 ); -writel (reg |MX6_BM_OVER_CUR_DIS , - usbmisc->base + data->index *4 ); + reg |=MX6_BM_OVER_CUR_DIS ; + }else if (data->oc_polarity ==1 ) { +/* High active */ + reg &= ~(MX6_BM_OVER_CUR_DIS |MX6_BM_OVER_CUR_POLARITY ); + }else { +/* Low active */ + reg &= ~MX6_BM_OVER_CUR_DIS ; + reg |=MX6_BM_OVER_CUR_POLARITY ; } +writel (reg, usbmisc->base + data->index *4 );/* SoC non-burst setting */ reg =readl (usbmisc->base + data->index *4 );
@@ -365,10 +373,18 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)return -EINVAL ;spin_lock_irqsave (&usbmisc->lock, flags); + reg =readl (usbmisc->base);if (data->disable_oc) { - reg =readl (usbmisc->base); -writel (reg |MX6_BM_OVER_CUR_DIS , usbmisc->base); + reg |=MX6_BM_OVER_CUR_DIS ; + }else if (data->oc_polarity ==1 ) { +/* High active */ + reg &= ~(MX6_BM_OVER_CUR_DIS |MX6_BM_OVER_CUR_POLARITY ); + }else { +/* Low active */ + reg &= ~MX6_BM_OVER_CUR_DIS ; + reg |=MX6_BM_OVER_CUR_POLARITY ; } +writel (reg, usbmisc->base); reg =readl (usbmisc->base +MX7D_USBNC_USB_CTRL2 ); reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK ;
@@ -492,6 +508,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = { .compatible = "fsl,imx6ul-usbmisc", .data = &imx6sx_usbmisc_ops, }, + { + .compatible = "fsl,imx7d-usbmisc", + .data = &imx7d_usbmisc_ops, + }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, usbmisc_imx_dt_ids);
Signature · 1 line
1.9.1
PATCH 4/4 usb: chipidea: imx: set over current polarity per dts setting
Quoted 18 lines · Li Jun
With over-current-polarity property added, imx usb over current polarity can be configed to be low or high active, since the default setting value(0) is for active high, so keep this setting for those legacy platforms without this property specified.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/ci_hdrc_imx.c | 9 +++++++++ drivers/usb/chipidea/ci_hdrc_imx.h | 1 + drivers/usb/chipidea/usbmisc_imx.c | 30 +++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-)drivers/usb/chipidea/ci_hdrc_imx.c +0
-0@@ -140,6 +140,15 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)if (of_find_property (np,"disable-over-current" ,NULL ))
drivers/usb/chipidea/ci_hdrc_imx.c static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) · line 150
Quoted 10 lines
drivers/usb/chipidea/ci_hdrc_imx.c +8
-0data->disable_oc =1 ; +if (!of_property_read_u32 (np,"over-current-polarity" , &ret)) + data->oc_polarity = ret ?1 :0 ; +else +/* +* Keep the oc polarity setting of legacy +* platforms unchanged. +*/ + data->oc_polarity =1 ;
We may can't ensure that, since there are lots of i.mx platforms, eg from imx27 to imx7.
If the user does not assign oc polarity at DT, we need to read it from register.
Peter
Quoted 90 lines
drivers/usb/chipidea/ci_hdrc_imx.c +1
-0+if (of_find_property (np,"external-vbus-divider" ,NULL )) data->evdo =1 ;drivers/usb/chipidea/ci_hdrc_imx.h +1
-0@@ -17,6 +17,7 @@ struct imx_usbmisc_data {int index; unsigned int disable_oc:1; /* over current detect disabled */ + unsigned int oc_polarity:1; /* over current polarity if oc enabled */ unsigned int evdo:1; /* set external vbus divider option */ };drivers/usb/chipidea/usbmisc_imx.c +25
-5@@ -56,6 +56,7 @@#define MX6_BM_NON_BURST_SETTING BIT(1)#define MX6_BM_OVER_CUR_DIS BIT(7) +#define MX6_BM_OVER_CUR_POLARITY BIT(8)#define MX6_BM_WAKEUP_ENABLE BIT(10)#define MX6_BM_ID_WAKEUP BIT(16)#define MX6_BM_VBUS_WAKEUP BIT(17)@@ -266,11 +267,18 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)spin_lock_irqsave (&usbmisc->lock, flags); + reg =readl (usbmisc->base + data->index *4 );if (data->disable_oc) { - reg =readl (usbmisc->base + data->index *4 ); -writel (reg |MX6_BM_OVER_CUR_DIS , - usbmisc->base + data->index *4 ); + reg |=MX6_BM_OVER_CUR_DIS ; + }else if (data->oc_polarity ==1 ) { +/* High active */ + reg &= ~(MX6_BM_OVER_CUR_DIS |MX6_BM_OVER_CUR_POLARITY ); + }else { +/* Low active */ + reg &= ~MX6_BM_OVER_CUR_DIS ; + reg |=MX6_BM_OVER_CUR_POLARITY ; } +writel (reg, usbmisc->base + data->index *4 );/* SoC non-burst setting */ reg =readl (usbmisc->base + data->index *4 );@@ -365,10 +373,18 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)return -EINVAL ;spin_lock_irqsave (&usbmisc->lock, flags); + reg =readl (usbmisc->base);if (data->disable_oc) { - reg =readl (usbmisc->base); -writel (reg |MX6_BM_OVER_CUR_DIS , usbmisc->base); + reg |=MX6_BM_OVER_CUR_DIS ; + }else if (data->oc_polarity ==1 ) { +/* High active */ + reg &= ~(MX6_BM_OVER_CUR_DIS |MX6_BM_OVER_CUR_POLARITY ); + }else { +/* Low active */ + reg &= ~MX6_BM_OVER_CUR_DIS ; + reg |=MX6_BM_OVER_CUR_POLARITY ; } +writel (reg, usbmisc->base); reg =readl (usbmisc->base +MX7D_USBNC_USB_CTRL2 ); reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK ;@@ -492,6 +508,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = { .compatible = "fsl,imx6ul-usbmisc", .data = &imx6sx_usbmisc_ops, }, + { + .compatible = "fsl,imx7d-usbmisc", + .data = &imx7d_usbmisc_ops, + }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, usbmisc_imx_dt_ids);Signature · 7 lines
1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 2 lines
Best Regards, Peter Chen
PATCH 4/4 usb: chipidea: imx: set over current polarity per dts setting
Hi
Quoted 45 lines
-----Original Message-----
From: Peter Chen [mailto:hzpeterchen at gmail.com]
Sent: Tuesday, July 19, 2016 9:57 AM
To: Jun Li <[email protected]>
Cc: Peter Chen <[email protected]>; robh+dt at kernel.org;
shawnguo at kernel.org; devicetree at vger.kernel.org; linux-usb at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH 4/4] usb: chipidea: imx: set over current polarity per dts settingdrivers/usb/chipidea/ci_hdrc_imx.c static struct imx_usbmisc_data
Quoted 18 lines · Li Jun
With over-current-polarity property added, imx usb over current polarity can be configed to be low or high active, since the default setting value(0) is for active high, so keep this setting for those legacy platforms without this property specified.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/ci_hdrc_imx.c | 9 +++++++++ drivers/usb/chipidea/ci_hdrc_imx.h | 1 + drivers/usb/chipidea/usbmisc_imx.c | 30 +++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-)drivers/usb/chipidea/ci_hdrc_imx.c +0
-0@@ -140,6 +140,15 @@ static struct imx_usbmisc_data*usbmisc_get_init_data(struct device *dev)
drivers/usb/chipidea/ci_hdrc_imx.c static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) · line 150
Quoted 11 lines
drivers/usb/chipidea/ci_hdrc_imx.c +8
-0if (of_find_property (np,"disable-over-current" ,NULL )) data->disable_oc =1 ; +if (!of_property_read_u32 (np,"over-current-polarity" , &ret)) + data->oc_polarity = ret ?1 :0 ; +else +/* +* Keep the oc polarity setting of legacy +* platforms unchanged. +*/ + data->oc_polarity =1 ;We may can't ensure that, since there are lots of i.mx platforms, eg from imx27 to imx7.
Quoted 2 lines
If the user does not assign oc polarity at DT, we need to read it from register.
I suppose old platforms (other than i.mx6&7) should set either "over-current-polarity" or "disable-over-current" if want to use "data->oc_polarity".
Do you mean read the register value before set "data->oc_polarity" here? Even with that, as I still can't ensure all i.mx platforms have the same mapping:
0 <--> active high.
1 <--> active low.
How should I set "data->oc_polarity" accordingly?
Li Jun
Quoted 101 lines
Peter
drivers/usb/chipidea/usbmisc_imx.c static const struct of_device_id
Quoted 75 lines
drivers/usb/chipidea/ci_hdrc_imx.c +1
-0+if (of_find_property (np,"external-vbus-divider" ,NULL )) data->evdo =1 ;drivers/usb/chipidea/ci_hdrc_imx.h +2
-0@@ -17,6 +17,7 @@ struct imx_usbmisc_data {int index; unsigned int disable_oc:1; /* over current detect disabled */ + unsigned int oc_polarity:1; /* over current polarity if oc enabled +*/ unsigned int evdo:1; /* set external vbus divider option */ };drivers/usb/chipidea/usbmisc_imx.c +11
-3@@ -56,6 +56,7 @@#define MX6_BM_NON_BURST_SETTING BIT(1)#define MX6_BM_OVER_CUR_DIS BIT(7) +#define MX6_BM_OVER_CUR_POLARITY BIT(8)#define MX6_BM_WAKEUP_ENABLE BIT(10)#define MX6_BM_ID_WAKEUP BIT(16)#define MX6_BM_VBUS_WAKEUP BIT(17)@@ -266,11 +267,18 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) spin_lock_irqsave(&usbmisc->lock, flags); + reg =readl (usbmisc->base + data->index *4 );if (data->disable_oc) { - reg =readl (usbmisc->base + data->index *4 ); -writel (reg |MX6_BM_OVER_CUR_DIS , - usbmisc->base + data->index *4 ); + reg |=MX6_BM_OVER_CUR_DIS ; + }else if (data->oc_polarity ==1 ) { +/* High active */ + reg &= ~(MX6_BM_OVER_CUR_DIS |MX6_BM_OVER_CUR_POLARITY ); + }else { +/* Low active */ + reg &= ~MX6_BM_OVER_CUR_DIS ; + reg |=MX6_BM_OVER_CUR_POLARITY ; } +writel (reg, usbmisc->base + data->index *4 );/* SoC non-burst setting */ reg =
readl(usbmisc->base + data->index * 4); @@ -365,10 +373,18 @@
static intusbmisc_imx7d_init(struct imx_usbmisc_data *data)drivers/usb/chipidea/usbmisc_imx.c +10
-2return -EINVAL ;spin_lock_irqsave (&usbmisc->lock, flags); + reg =readl (usbmisc->base);if (data->disable_oc) { - reg =readl (usbmisc->base); -writel (reg |MX6_BM_OVER_CUR_DIS , usbmisc->base); + reg |=MX6_BM_OVER_CUR_DIS ; + }else if (data->oc_polarity ==1 ) { +/* High active */ + reg &= ~(MX6_BM_OVER_CUR_DIS |MX6_BM_OVER_CUR_POLARITY ); + }else { +/* Low active */ + reg &= ~MX6_BM_OVER_CUR_DIS ; + reg |=MX6_BM_OVER_CUR_POLARITY ; } +writel (reg, usbmisc->base); reg =readl (usbmisc->base +MX7D_USBNC_USB_CTRL2 ); reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK ;@@ -492,6 +508,10 @@ static const struct of_device_idusbmisc_imx_dt_ids[] = {
Quoted 14 lines
drivers/usb/chipidea/usbmisc_imx.c +4
-1.compatible = "fsl,imx6ul-usbmisc", .data = &imx6sx_usbmisc_ops, }, + { + .compatible = "fsl,imx7d-usbmisc", + .data = &imx7d_usbmisc_ops, + }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, usbmisc_imx_dt_ids); --1.9.1
Quoted 4 lines
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel--
Best Regards,
Peter Chen
PATCH 4/4 usb: chipidea: imx: set over current polarity per dts setting
Quoted 47 lines · Jun Li
Hi
Quoted 45 lines
-----Original Message-----
From: Peter Chen [mailto:hzpeterchen at gmail.com]
Sent: Tuesday, July 19, 2016 9:57 AM
To: Jun Li <[email protected]>
Cc: Peter Chen <[email protected]>; robh+dt at kernel.org;
shawnguo at kernel.org; devicetree at vger.kernel.org; linux-usb at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH 4/4] usb: chipidea: imx: set over current polarity per dts settingdrivers/usb/chipidea/ci_hdrc_imx.c static struct imx_usbmisc_data
Quoted 18 lines · Li Jun
With over-current-polarity property added, imx usb over current polarity can be configed to be low or high active, since the default setting value(0) is for active high, so keep this setting for those legacy platforms without this property specified.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/ci_hdrc_imx.c | 9 +++++++++ drivers/usb/chipidea/ci_hdrc_imx.h | 1 + drivers/usb/chipidea/usbmisc_imx.c | 30 +++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-)drivers/usb/chipidea/ci_hdrc_imx.c +0
-0@@ -140,6 +140,15 @@ static struct imx_usbmisc_data*usbmisc_get_init_data(struct device *dev)
drivers/usb/chipidea/ci_hdrc_imx.c static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) · line 150
Quoted 11 lines
drivers/usb/chipidea/ci_hdrc_imx.c +8
-0if (of_find_property (np,"disable-over-current" ,NULL )) data->disable_oc =1 ; +if (!of_property_read_u32 (np,"over-current-polarity" , &ret)) + data->oc_polarity = ret ?1 :0 ; +else +/* +* Keep the oc polarity setting of legacy +* platforms unchanged. +*/ + data->oc_polarity =1 ;We may can't ensure that, since there are lots of i.mx platforms, eg from imx27 to imx7.
Quoted 7 lines
Quoted 2 lines
If the user does not assign oc polarity at DT, we need to read it from register.
I suppose old platforms (other than i.mx6&7) should set either "over-current-polarity" or "disable-over-current" if want to use "
data->oc_polarity".
The user may use old dtb and the latest kernel, so the introduced DT property should not affect old dtb platforms.
Quoted 1 line
Do you mean read the register value before set "
data->oc_polarity" here?
yes, if there is a dts property, read it from DT; else, read it from the register.
if (!of_property_read_u32(np, "over-current-polarity", &ret))
data->oc_polarity = ret ? 1 : 0; else /* * Keep the oc polarity setting of legacy * platforms unchanged. */ data->oc_polarity = readl(oc_polarity);
Then, when you set register for oc polarity, you can depend on the flag.
reg = readl(usbmisc->base + data->index * 4); value = data->oc_polarity ? MX6_BM_OVER_CUR_POLARITY : 0; writel(reg | value, usbmisc->base + data->index * 4);
Quoted 5 lines
Even with that, as I still can't ensure all i.mx platforms have the same mapping:
0 <--> active high.
1 <--> active low.
How should I set "data->oc_polarity" accordingly?
Just keep current register value unchanging if there is no dts property.
Peter
Quoted 102 lines
Li Jun
Quoted 101 lines
Peter
drivers/usb/chipidea/usbmisc_imx.c static const struct of_device_id
Quoted 75 lines
drivers/usb/chipidea/ci_hdrc_imx.c +1
-0+if (of_find_property (np,"external-vbus-divider" ,NULL )) data->evdo =1 ;drivers/usb/chipidea/ci_hdrc_imx.h +2
-0@@ -17,6 +17,7 @@ struct imx_usbmisc_data {int index; unsigned int disable_oc:1; /* over current detect disabled */ + unsigned int oc_polarity:1; /* over current polarity if oc enabled +*/ unsigned int evdo:1; /* set external vbus divider option */ };drivers/usb/chipidea/usbmisc_imx.c +11
-3@@ -56,6 +56,7 @@#define MX6_BM_NON_BURST_SETTING BIT(1)#define MX6_BM_OVER_CUR_DIS BIT(7) +#define MX6_BM_OVER_CUR_POLARITY BIT(8)#define MX6_BM_WAKEUP_ENABLE BIT(10)#define MX6_BM_ID_WAKEUP BIT(16)#define MX6_BM_VBUS_WAKEUP BIT(17)@@ -266,11 +267,18 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) spin_lock_irqsave(&usbmisc->lock, flags); + reg =readl (usbmisc->base + data->index *4 );if (data->disable_oc) { - reg =readl (usbmisc->base + data->index *4 ); -writel (reg |MX6_BM_OVER_CUR_DIS , - usbmisc->base + data->index *4 ); + reg |=MX6_BM_OVER_CUR_DIS ; + }else if (data->oc_polarity ==1 ) { +/* High active */ + reg &= ~(MX6_BM_OVER_CUR_DIS |MX6_BM_OVER_CUR_POLARITY ); + }else { +/* Low active */ + reg &= ~MX6_BM_OVER_CUR_DIS ; + reg |=MX6_BM_OVER_CUR_POLARITY ; } +writel (reg, usbmisc->base + data->index *4 );/* SoC non-burst setting */ reg =
readl(usbmisc->base + data->index * 4); @@ -365,10 +373,18 @@
static intusbmisc_imx7d_init(struct imx_usbmisc_data *data)drivers/usb/chipidea/usbmisc_imx.c +10
-2return -EINVAL ;spin_lock_irqsave (&usbmisc->lock, flags); + reg =readl (usbmisc->base);if (data->disable_oc) { - reg =readl (usbmisc->base); -writel (reg |MX6_BM_OVER_CUR_DIS , usbmisc->base); + reg |=MX6_BM_OVER_CUR_DIS ; + }else if (data->oc_polarity ==1 ) { +/* High active */ + reg &= ~(MX6_BM_OVER_CUR_DIS |MX6_BM_OVER_CUR_POLARITY ); + }else { +/* Low active */ + reg &= ~MX6_BM_OVER_CUR_DIS ; + reg |=MX6_BM_OVER_CUR_POLARITY ; } +writel (reg, usbmisc->base); reg =readl (usbmisc->base +MX7D_USBNC_USB_CTRL2 ); reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK ;@@ -492,6 +508,10 @@ static const struct of_device_idusbmisc_imx_dt_ids[] = {
Quoted 14 lines
drivers/usb/chipidea/usbmisc_imx.c +4
-1.compatible = "fsl,imx6ul-usbmisc", .data = &imx6sx_usbmisc_ops, }, + { + .compatible = "fsl,imx7d-usbmisc", + .data = &imx7d_usbmisc_ops, + }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, usbmisc_imx_dt_ids); --1.9.1
Quoted 4 lines
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel--
Best Regards,
Peter Chen
Signature · 2 lines
Best Regards, Peter Chen
Rob Herring
maintainerPATCH 1/4 doc: usb: usbmisc-imx: add imx7d compatible string
In reply to Li JunQuoted 6 lines · Li Jun
Add compatible string for imx7d-usbmisc.
Signed-off-by Li Jun <[email protected]>--- Documentation/devicetree/bindings/usb/usbmisc-imx.txt | 1 + 1 file changed, 1 insertion(+)