aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea/usbmisc_imx.c
diff options
context:
space:
mode:
authorMichael Grzeschik <m.grzeschik@pengutronix.de>2013-03-30 06:54:00 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-30 11:13:58 -0400
commitf0c910b63cc273c239964776fae1aaa58ed4ad2b (patch)
tree96b64c34bf5c6cc39b0ba39b899646e2575b2eac /drivers/usb/chipidea/usbmisc_imx.c
parente609108a5ba70ecf3b1b6a7e09e5a56244e92926 (diff)
usb: chipidea: usbmisc: add mx53 support
This adds mx53 as the next user of the usbmisc driver and makes it possible to disable the overcurrent-detection of the internal phy. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> [Alex: fixed another set of line-too-long and void pointer cast] Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/chipidea/usbmisc_imx.c')
-rw-r--r--drivers/usb/chipidea/usbmisc_imx.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 08b046f9491b..746013d7d391 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -19,6 +19,13 @@
19 19
20#define USB_DEV_MAX 4 20#define USB_DEV_MAX 4
21 21
22#define MX53_USB_OTG_PHY_CTRL_0_OFFSET 0x08
23#define MX53_USB_UH2_CTRL_OFFSET 0x14
24#define MX53_USB_UH3_CTRL_OFFSET 0x18
25#define MX53_BM_OVER_CUR_DIS_H1 BIT(5)
26#define MX53_BM_OVER_CUR_DIS_OTG BIT(8)
27#define MX53_BM_OVER_CUR_DIS_UHx BIT(30)
28
22#define MX6_BM_OVER_CUR_DIS BIT(7) 29#define MX6_BM_OVER_CUR_DIS BIT(7)
23 30
24struct imx_usbmisc { 31struct imx_usbmisc {
@@ -52,6 +59,45 @@ static struct usbmisc_usb_device *get_usbdev(struct device *dev)
52 return &usbmisc->usbdev[i]; 59 return &usbmisc->usbdev[i];
53} 60}
54 61
62static int usbmisc_imx53_init(struct device *dev)
63{
64 struct usbmisc_usb_device *usbdev;
65 void __iomem *reg = NULL;
66 unsigned long flags;
67 u32 val = 0;
68
69 usbdev = get_usbdev(dev);
70 if (IS_ERR(usbdev))
71 return PTR_ERR(usbdev);
72
73 if (usbdev->disable_oc) {
74 spin_lock_irqsave(&usbmisc->lock, flags);
75 switch (usbdev->index) {
76 case 0:
77 reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
78 val = readl(reg) | MX53_BM_OVER_CUR_DIS_OTG;
79 break;
80 case 1:
81 reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
82 val = readl(reg) | MX53_BM_OVER_CUR_DIS_H1;
83 break;
84 case 2:
85 reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET;
86 val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
87 break;
88 case 3:
89 reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET;
90 val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
91 break;
92 }
93 if (reg && val)
94 writel(val, reg);
95 spin_unlock_irqrestore(&usbmisc->lock, flags);
96 }
97
98 return 0;
99}
100
55static int usbmisc_imx6q_init(struct device *dev) 101static int usbmisc_imx6q_init(struct device *dev)
56{ 102{
57 103
@@ -74,12 +120,20 @@ static int usbmisc_imx6q_init(struct device *dev)
74 return 0; 120 return 0;
75} 121}
76 122
123static const struct usbmisc_ops imx53_usbmisc_ops = {
124 .init = usbmisc_imx53_init,
125};
126
77static const struct usbmisc_ops imx6q_usbmisc_ops = { 127static const struct usbmisc_ops imx6q_usbmisc_ops = {
78 .init = usbmisc_imx6q_init, 128 .init = usbmisc_imx6q_init,
79}; 129};
80 130
81static const struct of_device_id usbmisc_imx_dt_ids[] = { 131static const struct of_device_id usbmisc_imx_dt_ids[] = {
82 { 132 {
133 .compatible = "fsl,imx53-usbmisc",
134 .data = &imx53_usbmisc_ops,
135 },
136 {
83 .compatible = "fsl,imx6q-usbmisc", 137 .compatible = "fsl,imx6q-usbmisc",
84 .data = &imx6q_usbmisc_ops, 138 .data = &imx6q_usbmisc_ops,
85 }, 139 },