Commit e609108a authored by Marc Kleine-Budde's avatar Marc Kleine-Budde Committed by Greg Kroah-Hartman

usb: chipidea: usbmisc: prepare driver to handle more than one soc

This attaches the usbmisc_ops to the of_device_id data and
makes it possible to define special functions per soc.
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: default avatarMichael Grzeschik <m.grzeschik@pengutronix.de>
[Alex: fixed one case of line-too-long and one bogus cast to void ptr]
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 00b9a1f9
...@@ -19,13 +19,14 @@ ...@@ -19,13 +19,14 @@
#define USB_DEV_MAX 4 #define USB_DEV_MAX 4
#define BM_OVER_CUR_DIS BIT(7) #define MX6_BM_OVER_CUR_DIS BIT(7)
struct imx_usbmisc { struct imx_usbmisc {
void __iomem *base; void __iomem *base;
spinlock_t lock; spinlock_t lock;
struct clk *clk; struct clk *clk;
struct usbmisc_usb_device usbdev[USB_DEV_MAX]; struct usbmisc_usb_device usbdev[USB_DEV_MAX];
const struct usbmisc_ops *ops;
}; };
static struct imx_usbmisc *usbmisc; static struct imx_usbmisc *usbmisc;
...@@ -65,7 +66,7 @@ static int usbmisc_imx6q_init(struct device *dev) ...@@ -65,7 +66,7 @@ static int usbmisc_imx6q_init(struct device *dev)
if (usbdev->disable_oc) { if (usbdev->disable_oc) {
spin_lock_irqsave(&usbmisc->lock, flags); spin_lock_irqsave(&usbmisc->lock, flags);
reg = readl(usbmisc->base + usbdev->index * 4); reg = readl(usbmisc->base + usbdev->index * 4);
writel(reg | BM_OVER_CUR_DIS, writel(reg | MX6_BM_OVER_CUR_DIS,
usbmisc->base + usbdev->index * 4); usbmisc->base + usbdev->index * 4);
spin_unlock_irqrestore(&usbmisc->lock, flags); spin_unlock_irqrestore(&usbmisc->lock, flags);
} }
...@@ -78,7 +79,10 @@ static const struct usbmisc_ops imx6q_usbmisc_ops = { ...@@ -78,7 +79,10 @@ static const struct usbmisc_ops imx6q_usbmisc_ops = {
}; };
static const struct of_device_id usbmisc_imx_dt_ids[] = { static const struct of_device_id usbmisc_imx_dt_ids[] = {
{ .compatible = "fsl,imx6q-usbmisc"}, {
.compatible = "fsl,imx6q-usbmisc",
.data = &imx6q_usbmisc_ops,
},
{ /* sentinel */ } { /* sentinel */ }
}; };
...@@ -87,6 +91,7 @@ static int usbmisc_imx_probe(struct platform_device *pdev) ...@@ -87,6 +91,7 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
struct imx_usbmisc *data; struct imx_usbmisc *data;
int ret; int ret;
struct of_device_id *tmp_dev;
if (usbmisc) if (usbmisc)
return -EBUSY; return -EBUSY;
...@@ -116,8 +121,11 @@ static int usbmisc_imx_probe(struct platform_device *pdev) ...@@ -116,8 +121,11 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
return ret; return ret;
} }
tmp_dev = (struct of_device_id *)
of_match_device(usbmisc_imx_dt_ids, &pdev->dev);
data->ops = (const struct usbmisc_ops *)tmp_dev->data;
usbmisc = data; usbmisc = data;
ret = usbmisc_set_ops(&imx6q_usbmisc_ops); ret = usbmisc_set_ops(data->ops);
if (ret) { if (ret) {
usbmisc = NULL; usbmisc = NULL;
clk_disable_unprepare(data->clk); clk_disable_unprepare(data->clk);
...@@ -129,7 +137,7 @@ static int usbmisc_imx_probe(struct platform_device *pdev) ...@@ -129,7 +137,7 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
static int usbmisc_imx_remove(struct platform_device *pdev) static int usbmisc_imx_remove(struct platform_device *pdev)
{ {
usbmisc_unset_ops(&imx6q_usbmisc_ops); usbmisc_unset_ops(usbmisc->ops);
clk_disable_unprepare(usbmisc->clk); clk_disable_unprepare(usbmisc->clk);
usbmisc = NULL; usbmisc = NULL;
return 0; return 0;
......
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