aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2018-12-04 03:31:29 -0500
committerPeter Chen <peter.chen@nxp.com>2018-12-10 20:13:09 -0500
commita82bf696aa39b08c0dfce5569525e61368c6827f (patch)
treed0ba4531a37914d623c79d9d1f6730518519ac44 /drivers/usb/chipidea
parent4dddb862d3e3438129927bfcce6ee2c2c7064eaf (diff)
usb: chipidea: imx: support configuring for active low oc signal
The status quo on i.MX6 is that if "over-current-active-high" is specified in the device tree this is configured as expected. If the property is missing polarity isn't changed and so the polarity is kept as setup by the bootloader. Reset default is active high, so active low can only be used with help by the bootloader. On i.MX7 it is similar, but there disabling of over current detection has a similar inconsistency. This patch introduces a new property that allows to explicitly configure for active low over current detection and consistently sets this up. In the absence of an explicit configuration the bit is kept as is. On i.MX7 over current detection is used unless disabled in the device tree. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Peter Chen <peter.chen@nxp.com>
Diffstat (limited to 'drivers/usb/chipidea')
-rw-r--r--drivers/usb/chipidea/ci_hdrc_imx.c16
-rw-r--r--drivers/usb/chipidea/ci_hdrc_imx.h8
-rw-r--r--drivers/usb/chipidea/usbmisc_imx.c28
3 files changed, 40 insertions, 12 deletions
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 56781c329db0..1951b37aa39d 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -136,11 +136,19 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
136 136
137 data->dev = &misc_pdev->dev; 137 data->dev = &misc_pdev->dev;
138 138
139 if (of_find_property(np, "disable-over-current", NULL)) 139 /*
140 * Check the various over current related properties. If over current
141 * detection is disabled we're not interested in the polarity.
142 */
143 if (of_find_property(np, "disable-over-current", NULL)) {
140 data->disable_oc = 1; 144 data->disable_oc = 1;
141 145 } else if (of_find_property(np, "over-current-active-high", NULL)) {
142 if (of_find_property(np, "over-current-active-high", NULL)) 146 data->oc_pol_active_low = 0;
143 data->oc_polarity = 1; 147 data->oc_pol_configured = 1;
148 } else if (of_find_property(np, "over-current-active-low", NULL)) {
149 data->oc_pol_active_low = 1;
150 data->oc_pol_configured = 1;
151 }
144 152
145 if (of_find_property(np, "external-vbus-divider", NULL)) 153 if (of_find_property(np, "external-vbus-divider", NULL))
146 data->evdo = 1; 154 data->evdo = 1;
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h
index fcecab478934..7cc53e2ce564 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.h
+++ b/drivers/usb/chipidea/ci_hdrc_imx.h
@@ -11,7 +11,13 @@ struct imx_usbmisc_data {
11 int index; 11 int index;
12 12
13 unsigned int disable_oc:1; /* over current detect disabled */ 13 unsigned int disable_oc:1; /* over current detect disabled */
14 unsigned int oc_polarity:1; /* over current polarity if oc enabled */ 14
15 /* true if over-current polarity is active low */
16 unsigned int oc_pol_active_low:1;
17
18 /* true if dt specifies polarity */
19 unsigned int oc_pol_configured:1;
20
15 unsigned int evdo:1; /* set external vbus divider option */ 21 unsigned int evdo:1; /* set external vbus divider option */
16 unsigned int ulpi:1; /* connected to an ULPI phy */ 22 unsigned int ulpi:1; /* connected to an ULPI phy */
17 unsigned int hsic:1; /* HSIC controlller */ 23 unsigned int hsic:1; /* HSIC controlller */
diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 43a15a6e86f5..4c3839d345cd 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -356,11 +356,17 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
356 reg = readl(usbmisc->base + data->index * 4); 356 reg = readl(usbmisc->base + data->index * 4);
357 if (data->disable_oc) { 357 if (data->disable_oc) {
358 reg |= MX6_BM_OVER_CUR_DIS; 358 reg |= MX6_BM_OVER_CUR_DIS;
359 } else if (data->oc_polarity == 1) {
360 /* High active */
361 reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY);
362 } else { 359 } else {
363 reg &= ~(MX6_BM_OVER_CUR_DIS); 360 reg &= ~MX6_BM_OVER_CUR_DIS;
361
362 /*
363 * If the polarity is not configured keep it as setup by the
364 * bootloader.
365 */
366 if (data->oc_pol_configured && data->oc_pol_active_low)
367 reg |= MX6_BM_OVER_CUR_POLARITY;
368 else if (data->oc_pol_configured)
369 reg &= ~MX6_BM_OVER_CUR_POLARITY;
364 } 370 }
365 writel(reg, usbmisc->base + data->index * 4); 371 writel(reg, usbmisc->base + data->index * 4);
366 372
@@ -552,9 +558,17 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)
552 reg = readl(usbmisc->base); 558 reg = readl(usbmisc->base);
553 if (data->disable_oc) { 559 if (data->disable_oc) {
554 reg |= MX6_BM_OVER_CUR_DIS; 560 reg |= MX6_BM_OVER_CUR_DIS;
555 } else if (data->oc_polarity == 1) { 561 } else {
556 /* High active */ 562 reg &= ~MX6_BM_OVER_CUR_DIS;
557 reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY); 563
564 /*
565 * If the polarity is not configured keep it as setup by the
566 * bootloader.
567 */
568 if (data->oc_pol_configured && data->oc_pol_active_low)
569 reg |= MX6_BM_OVER_CUR_POLARITY;
570 else if (data->oc_pol_configured)
571 reg &= ~MX6_BM_OVER_CUR_POLARITY;
558 } 572 }
559 writel(reg, usbmisc->base); 573 writel(reg, usbmisc->base);
560 574