support other fsl SoCs with usbmisc + small fixes
Subsystems (4)
v2 cover support other fsl SoCs with usbmisc + small fixes
Nearly every SoC from Freescale has this non-core usb registers. This series adds support for more users of this driver.
This series is based on Peter Chen's work. Its needed to merge his master branch before applying this series:
https://github.com/hzpeterchen/linux-usb.git
Thanks,
Michael
Marc Kleine-Budde (4):
usb: chipidea: usbmisc: unset global varibale usbmisc on driver remove
usb: chipidea: usbmisc: fix a potential race condition
usb: chipidea: usbmisc: prepare driver to handle more than one soc
usb: chipidea: usbmisc: add support for ahb, ipg and per clock
Michael Grzeschik (3):
usb: chipidea: usbmisc: rename file, struct and functions to usbmisc_imx
usb: chipidea: usbmisc: add mx53 support
usb: chipidea: usbmisc: add post handling and errata fix for mx25
.../devicetree/bindings/usb/ci13xxx-imx.txt | 2 + drivers/usb/chipidea/Makefile | 2 +- drivers/usb/chipidea/ci13xxx_imx.c | 12 + drivers/usb/chipidea/ci13xxx_imx.h | 3 + drivers/usb/chipidea/usbmisc_imx.c | 256 ++++++++++++++++++++ drivers/usb/chipidea/usbmisc_imx6q.c | 162 ------------- 6 files changed, 274 insertions(+), 163 deletions(-) create mode 100644 drivers/usb/chipidea/usbmisc_imx.c delete mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c
Signature · 1 line
1.7.10.4
PATCH v2 1/7 usb: chipidea: usbmisc: rename file, struct and functions to usbmisc_imx
This driver will be used for every Freescale SoC which has this misc memory layout to control the basic usb handling. So better name this driver, function and struct names in a more generic way.
---
Changes since v1:
* added Makefile change to be build as well
* moved this patch infront all other
drivers/usb/chipidea/Makefile | 2 +-
.../chipidea/{usbmisc_imx6q.c => usbmisc_imx.c} | 38 ++++++++++----------
2 files changed, 20 insertions(+), 20 deletions(-)
rename drivers/usb/chipidea/{usbmisc_imx6q.c => usbmisc_imx.c} (75%)drivers/usb/chipidea/Makefile +1 -1
@@ -17,5 +17,5 @@ ifneq ($(CONFIG_PCI),) endif ifneq ($(CONFIG_OF_DEVICE),) - obj-$(CONFIG_USB_CHIPIDEA) += ci13xxx_imx.o usbmisc_imx6q.o + obj-$(CONFIG_USB_CHIPIDEA) += ci13xxx_imx.o usbmisc_imx.o endif
drivers/usb/chipidea/usbmisc_imx.c renamed from drivers/usb/chipidea/usbmisc_imx6q.c +19 -19
@@ -21,14 +21,14 @@#define BM_OVER_CUR_DIS BIT(7) -struct imx6q_usbmisc { +struct imx_usbmisc {void __iomem *base;spinlock_t lock;struct clk *clk;struct usbmisc_usb_device usbdev[USB_DEV_MAX ]; }; -static struct imx6q_usbmisc *usbmisc; +static struct imx_usbmisc *usbmisc;static struct usbmisc_usb_device *get_usbdev (struct device *dev) {
@@ -77,15 +77,15 @@ static const struct usbmisc_ops imx6q_usbmisc_ops = { .init = usbmisc_imx6q_init, }; -static const struct of_device_id usbmisc_imx6q_dt_ids[] = { +static const struct of_device_id usbmisc_imx_dt_ids[] = { { .compatible ="fsl,imx6q-usbmisc" }, {/* sentinel */ } }; -static int __devinit usbmisc_imx6q_probe (struct platform_device *pdev) +static int __devinit usbmisc_imx_probe (struct platform_device *pdev) {struct resource *res; -struct imx6q_usbmisc *data; +struct imx_usbmisc *data;int ret;if (usbmisc)
@@ -127,36 +127,36 @@ static int __devinit usbmisc_imx6q_probe(struct platform_device *pdev)return 0 ; } -static int __devexit usbmisc_imx6q_remove(struct platform_device *pdev) +static int __devexit usbmisc_imx_remove(struct platform_device *pdev) {usbmisc_unset_ops (&imx6q_usbmisc_ops);clk_disable_unprepare (usbmisc->clk);return 0 ; } -static struct platform_driver usbmisc_imx6q_driver = { - .probe = usbmisc_imx6q_probe, - .remove =__devexit_p (usbmisc_imx6q_remove), +static struct platform_driver usbmisc_imx_driver = { + .probe = usbmisc_imx_probe, + .remove =__devexit_p (usbmisc_imx_remove), .driver = { - .name ="usbmisc_imx6q" , + .name ="usbmisc_imx" , .owner =THIS_MODULE , - .of_match_table = usbmisc_imx6q_dt_ids, + .of_match_table = usbmisc_imx_dt_ids, }, }; -int __init usbmisc_imx6q_drv_init (void ) +int __init usbmisc_imx_drv_init (void ) { -return platform_driver_register (&usbmisc_imx6q_driver); +return platform_driver_register (&usbmisc_imx_driver); } -subsys_initcall (usbmisc_imx6q_drv_init); +subsys_initcall (usbmisc_imx_drv_init); -void __exit usbmisc_imx6q_drv_exit(void) +void __exit usbmisc_imx_drv_exit(void) { -platform_driver_unregister (&usbmisc_imx6q_driver); +platform_driver_unregister (&usbmisc_imx_driver); } -module_exit (usbmisc_imx6q_drv_exit); +module_exit (usbmisc_imx_drv_exit); -MODULE_ALIAS ("platform:usbmisc-imx6q" ); +MODULE_ALIAS ("platform:usbmisc-imx" );MODULE_LICENSE ("GPL v2" ); -MODULE_DESCRIPTION ("driver for imx6q usb non-core registers" ); +MODULE_DESCRIPTION ("driver for imx usb non-core registers" );MODULE_AUTHOR ("Richard Zhao <[email protected]>" );
Signature · 1 line
1.7.10.4
PATCH v2 2/7 usb: chipidea: usbmisc: unset global varibale usbmisc on driver remove
In reply to Michael GrzeschikFrom: Marc Kleine-Budde <[email protected]>
The probe function checks usbmisc to be NULL in the beginning. Without this patch the can only be loaded once.
---
Changes since v1:
* split previous patch into two seperate.
drivers/usb/chipidea/usbmisc_imx.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/chipidea/usbmisc_imx.c +1 -0
@@ -131,6 +131,7 @@ static int __devexit usbmisc_imx_remove(struct platform_device *pdev) {usbmisc_unset_ops (&imx6q_usbmisc_ops);clk_disable_unprepare (usbmisc->clk); + usbmisc =NULL ;return 0 ; }
Signature · 1 line
1.7.10.4
PATCH v2 3/7 usb: chipidea: usbmisc: fix a potential race condition
In reply to Michael GrzeschikFrom: Marc Kleine-Budde <[email protected]>
This fixes a potential race condition where the ci13xxx_imx glue code could be fast enough to call one of the usbmisc_ops before he got a valid value on the static usbmisc pointer. To fix that we first set usbmisc, then call usbmisc_set_ops().
---
Changes since v1:
* split previous patch into two seperate.
drivers/usb/chipidea/usbmisc_imx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/chipidea/usbmisc_imx.c +2 -2
@@ -116,14 +116,14 @@ static int __devinit usbmisc_imx_probe(struct platform_device *pdev)return ret; } + usbmisc = data; ret =usbmisc_set_ops (&imx6q_usbmisc_ops);if (ret) { + usbmisc =NULL ;clk_disable_unprepare (data->clk);return ret; } - usbmisc = data; -return 0 ; }
Signature · 1 line
1.7.10.4
PATCH v2 4/7 usb: chipidea: usbmisc: prepare driver to handle more than one soc
In reply to Michael GrzeschikFrom: Marc Kleine-Budde <[email protected]>
This attaches the usbmisc_ops to the of_device_id data and makes it possible to define special functions per soc.
--- drivers/usb/chipidea/usbmisc_imx.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/usb/chipidea/usbmisc_imx.c +8 -3
@@ -26,6 +26,7 @@ struct imx_usbmisc {spinlock_t lock;struct clk *clk;struct usbmisc_usb_device usbdev[USB_DEV_MAX ]; +const struct usbmisc_ops *ops; };static struct imx_usbmisc *usbmisc;
@@ -78,7 +79,7 @@ static const struct usbmisc_ops imx6q_usbmisc_ops = { };static const struct of_device_id usbmisc_imx_dt_ids[] = { - { .compatible ="fsl,imx6q-usbmisc" }, + { .compatible ="fsl,imx6q-usbmisc" , .data = (void *)&imx6q_usbmisc_ops }, {/* sentinel */ } };
@@ -87,6 +88,7 @@ static int __devinit usbmisc_imx_probe(struct platform_device *pdev)struct resource *res;struct imx_usbmisc *data;int ret; +struct of_device_id *tmp_dev;if (usbmisc)return -EBUSY ;
@@ -116,8 +118,11 @@ static int __devinit usbmisc_imx_probe(struct platform_device *pdev)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; - ret =usbmisc_set_ops (&imx6q_usbmisc_ops); + ret =usbmisc_set_ops (data->ops);if (ret) { usbmisc =NULL ;clk_disable_unprepare (data->clk);
@@ -129,7 +134,7 @@ static int __devinit usbmisc_imx_probe(struct platform_device *pdev) static int __devexit usbmisc_imx_remove(struct platform_device *pdev) { -usbmisc_unset_ops (&imx6q_usbmisc_ops); +usbmisc_unset_ops (usbmisc->ops);clk_disable_unprepare (usbmisc->clk); usbmisc =NULL ;return 0 ;
Signature · 1 line
1.7.10.4
PATCH v2 5/7 usb: chipidea: usbmisc: add support for ahb, ipg and per clock
In reply to Michael GrzeschikFrom: Marc Kleine-Budde <[email protected]>
This patch adds support for a second and third clock to the usbmisc driver. On modern freescale ARM cores like the imx51, imx53 and imx6q three clocks ("ahb", "ipg" and "per") must be enabled in order to access the USB core.
ahb - AMBA High-Performance Bus clock domain
ipg - IP-Bus Gate clock domain
per - Peripheral clock domain
---
Changes since v1:
* changed patch description
drivers/usb/chipidea/usbmisc_imx.c | 60 +++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 15 deletions(-)
drivers/usb/chipidea/usbmisc_imx.c +45 -15
@@ -24,7 +24,9 @@struct imx_usbmisc {void __iomem *base;spinlock_t lock; -struct clk *clk; +struct clk *clk_ahb; +struct clk *clk_ipg; +struct clk *clk_per;struct usbmisc_usb_device usbdev[USB_DEV_MAX ];const struct usbmisc_ops *ops; };
@@ -104,38 +106,66 @@ static int __devinit usbmisc_imx_probe(struct platform_device *pdev)if (!data->base)return -EADDRNOTAVAIL ; - data->clk =devm_clk_get (&pdev->dev,NULL ); -if (IS_ERR (data->clk)) { + data->clk_ahb =devm_clk_get (&pdev->dev,"ahb" ); +if (IS_ERR (data->clk_ahb)) {dev_err (&pdev->dev, -"failed to get clock, err=%ld\n" ,PTR_ERR (data->clk)); -return PTR_ERR (data->clk); +"failed to get ahb clock, err=%ld\n" ,PTR_ERR (data->clk_ahb)); +return PTR_ERR (data->clk_ahb); } - ret =clk_prepare_enable (data->clk); -if (ret) { + data->clk_ipg =devm_clk_get (&pdev->dev,"ipg" ); +if (IS_ERR (data->clk_ipg)) {dev_err (&pdev->dev, -"clk_prepare_enable failed, err=%d\n" , ret); -return ret; +"failed to get ipg clock, err=%ld\n" ,PTR_ERR (data->clk_ipg)); +return PTR_ERR (data->clk_ipg); } + data->clk_per =devm_clk_get (&pdev->dev,"per" ); +if (IS_ERR (data->clk_per)) { +dev_err (&pdev->dev, +"failed to get per clock, err=%ld\n" ,PTR_ERR (data->clk_per)); +return PTR_ERR (data->clk_per); + } + + ret =clk_prepare_enable (data->clk_ahb); +if (ret) +return ret; + + ret =clk_prepare_enable (data->clk_ipg); +if (ret) + goto err_ipg_failed; + + ret =clk_prepare_enable (data->clk_per); +if (ret) + goto err_per_failed; + 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; ret =usbmisc_set_ops (data->ops); -if (ret) { - usbmisc =NULL ; -clk_disable_unprepare (data->clk); -return ret; - } +if (ret) + goto err_set_ops_failed;return 0 ; + + err_set_ops_failed: + usbmisc =NULL ; +clk_disable_unprepare (data->clk_per); + err_per_failed: +clk_disable_unprepare (data->clk_ipg); + err_ipg_failed: +clk_disable_unprepare (data->clk_ahb); + +return ret; } static int __devexit usbmisc_imx_remove(struct platform_device *pdev) {usbmisc_unset_ops (usbmisc->ops); -clk_disable_unprepare (usbmisc->clk); +clk_disable_unprepare (usbmisc->clk_per); +clk_disable_unprepare (usbmisc->clk_ipg); +clk_disable_unprepare (usbmisc->clk_ahb); usbmisc =NULL ;return 0 ; }
Signature · 1 line
1.7.10.4
PATCH v2 5/7 usb: chipidea: usbmisc: add support for ahb, ipg and per clock
Quoted 9 lines · Michael Grzeschik
From: Marc Kleine-Budde <[email protected]>
This patch adds support for a second and third clock to the usbmisc driver. On modern freescale ARM cores like the imx51, imx53 and imx6q three clocks ("ahb", "ipg" and "per") must be enabled in order to access the USB core.
ahb - AMBA High-Performance Bus clock domain
ipg - IP-Bus Gate clock domain
per - Peripheral clock domain
Looks like usbmisc_imx and ci13xxx_imx are growing more and more common code.
Btw, shouldn't there be a way to specify platform's clock tree configuration via devicetree or whatnot so that each platform driver didn't have to request platform specific clocks?
Regards,
--
Alex
Sascha Hauer
maintainerPATCH v2 5/7 usb: chipidea: usbmisc: add support for ahb, ipg and per clock
Quoted 12 lines · Alexander Shishkin
Quoted 9 lines · Michael Grzeschik
From: Marc Kleine-Budde <[email protected]>
This patch adds support for a second and third clock to the usbmisc driver. On modern freescale ARM cores like the imx51, imx53 and imx6q three clocks ("ahb", "ipg" and "per") must be enabled in order to access the USB core.
ahb - AMBA High-Performance Bus clock domain
ipg - IP-Bus Gate clock domain
per - Peripheral clock domain
Quoted 5 lines
Looks like
usbmisc_imxandci13xxx_imxare growing more and more common code.
Btw, shouldn't there be a way to specify platform's clock tree configuration via devicetree or whatnot so that each platform driver didn't have to request platform specific clocks?
In theory that is the case. The clocks should be modeled after the input clocks of the device (ci13xxx). Every SoC should have them, but on some SoCs some of them may not be software controllable, so they have to provide dummy clocks for these.
So when everyting is done correctly in the driver, the calls to clk_get could be in the core instead of ci13xxx_imx. That said, we do not have good insights into the SoC, so we do not know exactly which clock inputs the ci13xx has and where they are connected in the SoCs clock module. There are some guesses in there.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v2 6/7 usb: chipidea: usbmisc: add mx53 support
In reply to Michael GrzeschikThis adds mx53 as the next user of the usbmisc driver and makes it possible to disable the overcurrent-detection of the internal phy.
--- drivers/usb/chipidea/usbmisc_imx.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/usb/chipidea/usbmisc_imx.c +28 -0
@@ -54,6 +54,29 @@ static struct usbmisc_usb_device *get_usbdev(struct device *dev)return &usbmisc->usbdev[i]; } +static int usbmisc_imx53_init (struct device *dev) +{ +struct usbmisc_usb_device *usbdev; +void __iomem *reg; +unsigned long flags; +u32 val; + + usbdev =get_usbdev (dev); +if (IS_ERR (usbdev)) +return PTR_ERR (usbdev); + + reg = usbmisc->base + usbdev->index *8 ; + +if (usbdev->disable_oc) { +spin_lock_irqsave (&usbmisc->lock, flags); + val =readl (reg); +writel (val | (1 <<5 ), reg); +spin_unlock_irqrestore (&usbmisc->lock, flags); + } + +return 0 ; +} +static int usbmisc_imx6q_init (struct device *dev) {
@@ -76,11 +99,16 @@ static int usbmisc_imx6q_init(struct device *dev)return 0 ; } +static const struct usbmisc_ops imx53_usbmisc_ops = { + .init = usbmisc_imx53_init, +}; +static const struct usbmisc_ops imx6q_usbmisc_ops = { .init = usbmisc_imx6q_init, };static const struct of_device_id usbmisc_imx_dt_ids[] = { + { .compatible ="fsl,imx53-usbmisc" , .data = (void *)&imx53_usbmisc_ops }, { .compatible ="fsl,imx6q-usbmisc" , .data = (void *)&imx6q_usbmisc_ops }, {/* sentinel */ } };
Signature · 1 line
1.7.10.4
PATCH v2 6/7 usb: chipidea: usbmisc: add mx53 support
Quoted 24 lines · Michael Grzeschik
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 <[email protected]>Signed-off-by Marc Kleine-Budde <[email protected]>--- drivers/usb/chipidea/usbmisc_imx.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/usb/chipidea/usbmisc_imx.c +7
-0@@ -54,6 +54,29 @@ static struct usbmisc_usb_device *get_usbdev(struct device *dev)return &usbmisc->usbdev[i]; } +static int usbmisc_imx53_init (struct device *dev) +{ +struct usbmisc_usb_device *usbdev; +void __iomem *reg; +unsigned long flags; +u32 val; +
drivers/usb/chipidea/usbmisc_imx.c static struct usbmisc_usb_device *get_usbdev(struct device *dev) · line 73
Quoted 10 lines
drivers/usb/chipidea/usbmisc_imx.c +10
-0+ usbdev =get_usbdev (dev); +if (IS_ERR (usbdev)) +return PTR_ERR (usbdev); + + reg = usbmisc->base + usbdev->index *8 ; + +if (usbdev->disable_oc) { +spin_lock_irqsave (&usbmisc->lock, flags); + val =readl (reg); +writel (val | (1 <<5 ), reg);
We know now that (1 << 5) probably means "disable overcurrent detection", but is there a definition for this register's bits somewhere?
Regards,
--
Alex
PATCH v2 6/7 usb: chipidea: usbmisc: add mx53 support
Quoted 32 lines · Alexander Shishkin
Quoted 30 lines · Michael Grzeschik
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 <[email protected]>Signed-off-by Marc Kleine-Budde <[email protected]>--- drivers/usb/chipidea/usbmisc_imx.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/usb/chipidea/usbmisc_imx.c +13
-0@@ -54,6 +54,29 @@ static struct usbmisc_usb_device *get_usbdev(struct device *dev)return &usbmisc->usbdev[i]; } +static int usbmisc_imx53_init (struct device *dev) +{ +struct usbmisc_usb_device *usbdev; +void __iomem *reg; +unsigned long flags; +u32 val; + + usbdev =get_usbdev (dev); +if (IS_ERR (usbdev)) +return PTR_ERR (usbdev); + + reg = usbmisc->base + usbdev->index *8 ; +
Quoted 8 lines
drivers/usb/chipidea/usbmisc_imx.c static struct usbmisc_usb_device *get_usbdev(struct device *dev) · line 73
Quoted 4 lines
drivers/usb/chipidea/usbmisc_imx.c +4
-0+if (usbdev->disable_oc) { +spin_lock_irqsave (&usbmisc->lock, flags); + val =readl (reg); +writel (val | (1 <<5 ), reg);We know now that (1 << 5) probably means "disable overcurrent detection", but is there a definition for this register's bits somewhere?
Will add defines for the magic numbers used.
Thanks,
Michael
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v2 7/7 usb: chipidea: usbmisc: add post handling and errata fix for mx25
In reply to Michael GrzeschikThis adds a post handling routine which is called after ci13xxx_add_device was called. The first user is the mx25, which has to disable the external-vbus-divider after the udc has started.
--- .../devicetree/bindings/usb/ci13xxx-imx.txt | 2 ++ drivers/usb/chipidea/ci13xxx_imx.c | 12 ++++++++ drivers/usb/chipidea/ci13xxx_imx.h | 3 ++ drivers/usb/chipidea/usbmisc_imx.c | 30 ++++++++++++++++++++ 4 files changed, 47 insertions(+)
Documentation/devicetree/bindings/usb/ci13xxx-imx.txt +2 -0
@@ -11,6 +11,7 @@ Optional properties: that indicate usb controller index - vbus-supply: regulator for vbus - disable-over-current: disable over current detect +- external-vbus-divider: enables off-chip resistor divider for Vbus Examples: usb at 02184000 { /* USB OTG */
@@ -20,4 +21,5 @@ usb at 02184000 { /* USB OTG */ fsl,usbphy = <&usbphy1>; fsl,usbmisc = <&usbmisc 0>; disable-over-current; + external-vbus-divider; };
drivers/usb/chipidea/ci13xxx_imx.c +12 -0
@@ -79,6 +79,9 @@ int usbmisc_get_init_data(struct device *dev, struct usbmisc_usb_device *usbdev)if (of_find_property (np,"disable-over-current" ,NULL )) usbdev->disable_oc =1 ; +if (of_find_property (np,"external-vbus-divider" ,NULL )) + usbdev->evdo =1 ; +return 0 ; }EXPORT_SYMBOL_GPL (usbmisc_get_init_data);
@@ -213,6 +216,15 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) goto put_np; } +if (usbmisc_ops && usbmisc_ops->post) { + ret = usbmisc_ops->post (&pdev->dev); +if (ret) { +dev_err (&pdev->dev, +"usbmisc post failed, ret=%d\n" , ret); + goto put_np; + } + } + data->ci_pdev = plat_ci;platform_set_drvdata (pdev, data);
drivers/usb/chipidea/ci13xxx_imx.h +3 -0
@@ -13,6 +13,8 @@struct usbmisc_ops {/* It's called once when probe a usb device */ int (*init)(struct device *dev); +/* It's called once after adding a usb device */ +int (*post)(struct device *dev); };struct usbmisc_usb_device {
@@ -20,6 +22,7 @@ struct usbmisc_usb_device {int index; int disable_oc:1; /* over current detect disabled */ + int evdo:1; /* set external vbus divider option */ };int usbmisc_set_ops (const struct usbmisc_ops *ops);
drivers/usb/chipidea/usbmisc_imx.c +30 -0
@@ -14,6 +14,7 @@#include <linux/clk.h> #include <linux/err.h> #include <linux/io.h> +#include <linux/delay.h> #include "ci13xxx_imx.h"
@@ -54,6 +55,30 @@ static struct usbmisc_usb_device *get_usbdev(struct device *dev)return &usbmisc->usbdev[i]; } +static int usbmisc_imx25_post (struct device *dev) +{ +struct usbmisc_usb_device *usbdev; +void __iomem *reg; +unsigned long flags; +u32 val; + + usbdev =get_usbdev (dev); +if (IS_ERR (usbdev)) +return PTR_ERR (usbdev); + + reg = usbmisc->base +0x08 ; + +if (usbdev->evdo) { +spin_lock_irqsave (&usbmisc->lock, flags); + val =readl (reg); +writel (val | (1 <<23 ), reg); +spin_unlock_irqrestore (&usbmisc->lock, flags); +mdelay (5 );/* needed to stabilize voltage */ + } + +return 0 ; +} +static int usbmisc_imx53_init (struct device *dev) {struct usbmisc_usb_device *usbdev;
@@ -99,6 +124,10 @@ static int usbmisc_imx6q_init(struct device *dev)return 0 ; } +static const struct usbmisc_ops imx25_usbmisc_ops = { + .post = usbmisc_imx25_post, +}; +static const struct usbmisc_ops imx53_usbmisc_ops = { .init = usbmisc_imx53_init, };
@@ -108,6 +137,7 @@ static const struct usbmisc_ops imx6q_usbmisc_ops = { };static const struct of_device_id usbmisc_imx_dt_ids[] = { + { .compatible ="fsl,imx25-usbmisc" , .data = (void *)&imx25_usbmisc_ops }, { .compatible ="fsl,imx53-usbmisc" , .data = (void *)&imx53_usbmisc_ops }, { .compatible ="fsl,imx6q-usbmisc" , .data = (void *)&imx6q_usbmisc_ops }, {/* sentinel */ }
Signature · 1 line
1.7.10.4