Commit 9dba516e authored by Li Jun's avatar Li Jun Committed by Peter Chen

usb: chipidea: imx: set over current polarity per dts setting

imx usb over current polarity is low active by default, with
over-current-active-high property added, user can config it to be high
active. Meanwhile keep this setting unchanged for existing platforms
so new platform must set the right value for active low by its usbmisc
init function if over current is enabled.
Signed-off-by: default avatarLi Jun <jun.li@nxp.com>
Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
parent e5b3253d
...@@ -140,6 +140,9 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) ...@@ -140,6 +140,9 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
if (of_find_property(np, "disable-over-current", NULL)) if (of_find_property(np, "disable-over-current", NULL))
data->disable_oc = 1; data->disable_oc = 1;
if (of_find_property(np, "over-current-active-high", NULL))
data->oc_polarity = 1;
if (of_find_property(np, "external-vbus-divider", NULL)) if (of_find_property(np, "external-vbus-divider", NULL))
data->evdo = 1; data->evdo = 1;
......
...@@ -17,6 +17,7 @@ struct imx_usbmisc_data { ...@@ -17,6 +17,7 @@ struct imx_usbmisc_data {
int index; int index;
unsigned int disable_oc:1; /* over current detect disabled */ 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 */ unsigned int evdo:1; /* set external vbus divider option */
}; };
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#define MX6_BM_NON_BURST_SETTING BIT(1) #define MX6_BM_NON_BURST_SETTING BIT(1)
#define MX6_BM_OVER_CUR_DIS BIT(7) #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_WAKEUP_ENABLE BIT(10)
#define MX6_BM_ID_WAKEUP BIT(16) #define MX6_BM_ID_WAKEUP BIT(16)
#define MX6_BM_VBUS_WAKEUP BIT(17) #define MX6_BM_VBUS_WAKEUP BIT(17)
...@@ -266,11 +267,14 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) ...@@ -266,11 +267,14 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
spin_lock_irqsave(&usbmisc->lock, flags); spin_lock_irqsave(&usbmisc->lock, flags);
reg = readl(usbmisc->base + data->index * 4);
if (data->disable_oc) { if (data->disable_oc) {
reg = readl(usbmisc->base + data->index * 4); reg |= MX6_BM_OVER_CUR_DIS;
writel(reg | MX6_BM_OVER_CUR_DIS, } else if (data->oc_polarity == 1) {
usbmisc->base + data->index * 4); /* High active */
reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY);
} }
writel(reg, usbmisc->base + data->index * 4);
/* SoC non-burst setting */ /* SoC non-burst setting */
reg = readl(usbmisc->base + data->index * 4); reg = readl(usbmisc->base + data->index * 4);
...@@ -365,10 +369,14 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data) ...@@ -365,10 +369,14 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&usbmisc->lock, flags); spin_lock_irqsave(&usbmisc->lock, flags);
reg = readl(usbmisc->base);
if (data->disable_oc) { if (data->disable_oc) {
reg = readl(usbmisc->base); reg |= MX6_BM_OVER_CUR_DIS;
writel(reg | MX6_BM_OVER_CUR_DIS, usbmisc->base); } else if (data->oc_polarity == 1) {
/* High active */
reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY);
} }
writel(reg, usbmisc->base);
reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK; reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK;
...@@ -492,6 +500,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = { ...@@ -492,6 +500,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
.compatible = "fsl,imx6ul-usbmisc", .compatible = "fsl,imx6ul-usbmisc",
.data = &imx6sx_usbmisc_ops, .data = &imx6sx_usbmisc_ops,
}, },
{
.compatible = "fsl,imx7d-usbmisc",
.data = &imx7d_usbmisc_ops,
},
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids); MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment