summaryrefslogtreecommitdiffstats
path: root/drivers/usb/imx
Commit message (Collapse)AuthorAgeFilesLines
* usb: i.MX: Use usb_register_otg_device()Sascha Hauer2019-11-212-73/+13
| | | | | | | We now have usb_register_otg_device() to register an "otg" device. Use it and drop the custom code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx-usb-phy: select syscon driverSascha Hauer2019-07-111-0/+1
| | | | | | | | | Since b904eca92f we depend on syscon once the "fsl,anatop" property is found. select MFD_SYSCON to make sure it is available. Fixes: b904eca92f ("usb: imx-usb-phy: Disable charger detect during initialization") Cc: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx-usb-phy: Disable charger detect during initializationAndrey Smirnov2019-05-271-0/+37
| | | | | | | | | | | | | | | | | | | | I can't find any erratas this is in refernce to, but apparently external changer detector needs to be disabled to prevent poor USB data signal quality. The problem manifest itself as a intermittent USB transfer corruption that happens to some device under and only under specific circumstances. In my case the failure was observed with Transcent SD/micro-SD card reader (05e3:0745 Genesys Logic, Inc. Logilink CR0012) when connected directly to front panel USB of ZII RDU2 board (the problem would go away if device was conntecte via a hub/USB-analyzer/male-female type A extender cable). Note that this fix is present in Linux kernel as well as some abandoned Barebox code removed in the next patch. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx-usb-phy: Use stmp_reset_block() to reset PHYAndrey Smirnov2019-05-272-10/+6
| | | | | | | | | Upstream kernel driver uses stmp_reset_block() to reset the PHY, so convert the code to do so as well to save some code and sync both drivers. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx-usb-phy: Wrap lines to silence checkpatchAndrey Smirnov2019-05-211-2/+4
| | | | | | | | Those two line are the only thing that checkpatch is complaining about. Wrap them to slince it. No functional change intended. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx-usb-phy: Import register definitions from Linux driverAndrey Smirnov2019-05-211-17/+18
| | | | | | | | Import register definitions from Linux driver to simplify comparing/sharing code a bit. No functional change intended. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: Do not disable VBUS on ehci_register()'s successAndrey Smirnov2019-02-271-3/+3
| | | | | | | | | | | | | Original code was written to exit early on ehci_register()'s success. As a part of e3eb0c729b, however, it was modified to to early exit on failure instead. This resulted in VBUS being erroneously disabled after EHCI controller was added, thus breaking USB on some i.MX boards (confirmed on ZII's RDU2). Fixes: e3eb0c729b ("usb: host: ehci: add ehci_unregister()") Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Vivien Didelot <vivien.didelot@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fsl_udc: pass controller instance to unregisterSascha Hauer2018-10-291-3/+10
| | | | | | | | | | | | | ci_udc_unregister() used to unregister "the controller". Since we may register multiple chipidea devices we called ci_udc_unregister() for each of them. This led to messages like: ERROR: imx-usb 53f80000.usb: gadget not registered. Fix this by returning the registered controller. This allows us to call ci_udc_unregister() only when we actually registered one before. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: unregister ehci controller on device removalSascha Hauer2018-10-291-0/+5
| | | | | | | | ehci does DMA and hence must be properly quiesced before we leave barebox. Call ehci_unregister() on device removal when we previously registered a ehci controller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: host: ehci: do not use dev->privSascha Hauer2018-10-291-0/+10
| | | | | | | | | | | | | | An ehci can be registered with ehci_register which is passed a struct device_d *. In that case the priv pointer may already be used by the caller, so we must not use it in the ehci code. At least for the Atmel ehci driver this fixes a bug, here dev->priv is set two times to different values. Since we need dev->priv in the ehci code to get the controller in ehci_detect() we can no longer implement that without the help of the caller, hence we eport ehci_detect() and epect it to be called by the code which registers a ehci host. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: host: ehci: add ehci_unregister()Sascha Hauer2018-10-291-3/+8
| | | | | | | | | ehci_register() allocates data and registers a ehci host. Add ehci_unregister() to properly halt the controller and to free the memory again.. To do so, change ehci_register() to return the ehci host rather than an error code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: implement support for limiting host to full speedNikita Yushchenko2018-06-261-0/+13
| | | | | | | | | | | | | | | | | | This is needed when host is known to not work properly in high speed mode. In linux, chipidea driver supports 'maximum-speed' device tree property. When that is set to "full-speed", driver sets PFSC bit in PORTSC register, which disallows use of high speed mode. This patch implements same support for barebox. Important technical detail is that PFSC bit is cleared by port reset, thus setting it has to be done in ehci->init() callback which is called after ehci_reset(). Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: implement support for "over-current-active-high" propertyUwe Kleine-König2017-10-271-0/+4
| | | | | | | | | | | | | | | This property is already documented in the bindings and supported by Linux. As on i.MX25 the HW default is active high and up to now barebox didn't force this to low (which is the default for e.g. i.MX6), add the property to barebox' imx25.dtsi to keep existing behaviour. If on a board the OC pin is active low, you need to add /delete-property/ over-current-active-high; in the board.dts. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: Only use clock when it existsSascha Hauer2017-05-231-4/+2
| | | | | | | | | | | | Fixes: bbe0df90b8e2463dd8db651e9f1dd57702985d2d I assumed all chipidea devices actually have a clock. This is true when looking at the device tree, but in barebox not all i.MX SoCs use the clocks provided by the device tree. Most instead use clkdev_add_physbase() to attach a clocks to devices. For these the chipidea device does not have a clock. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: Fix setting of dev->privSascha Hauer2017-03-091-1/+3
| | | | | | | | | Since fc10539f7d the usbmisc pointer must be stored in dev->priv, but dev->priv has never been set. Fix this. Fixes: fc10539f7d usb: imx: Make usb-misc multi instance safe Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: role_registered contains roleSascha Hauer2017-03-091-2/+2
| | | | | | | role_registered contains the role, it's not a bool indicating that a role is registered. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: Add clock supportSascha Hauer2017-01-191-0/+13
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: Add usbmisc support for i.MX7Sascha Hauer2017-01-191-0/+53
| | | | | | Taken directly from Linux-4.10-rc3 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: Make usb-misc multi instance safeSascha Hauer2017-01-192-15/+28
| | | | | | | i.MX7 has two usbmisc devices, so we cannot use global instance variables anymore. Create a driver private data struct for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: imx-usb-misc: Add Vybrid supportAndrey Smirnov2017-01-121-0/+28
| | | | | | | | Add code to do usbmisc initialization on VF610 family of SoCs. Based on analogous code from Linux kernel. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: Default CONFIG_USB_IMX_PHY to 'y' on VybridAndrey Smirnov2017-01-121-1/+1
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: imx-usb-phy: Add VF610 OF compatiblity stringAndrey Smirnov2017-01-121-0/+2
| | | | | | | | | | From looking at analogous Linux driver code it seems that all of the differences between code "imx23-usbphy" and "vf610-usbphy" pertain to suspend/resume functionality, which shouldn't affetct Barebox. As a result this commit just adds a compatiblity string and no other code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx-us-phy: implement notify_(dis)concectSascha Hauer2016-09-291-0/+27
| | | | | | | | | | | The i.MX6 USB phy does not recognize disconnects of high speed devices when the USBPHY_CTRL_ENHOSTDISCONDETECT is not set. The phy does not work properly though when this bit is always set, so implement the notify_(dis)concect() callbacks to set this bit whenever a high speed device is connected and to clear it again when the device is disconnected. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx-us-phy: Convert driver to generic phy supportSascha Hauer2016-09-293-4/+66
| | | | | | | The generic phy layer now supports USB phys, so convert the driver over to use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx-usb-phy: Drop unnecessary read/modify/writeSascha Hauer2016-09-291-5/+2
| | | | | | | When writing to the USBPHY_CTRL register read/modify/write is unncessary since we are writing to the associated bit set register anyway. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX drivers: enable i.MX50 where already supportedAlexander Kurz2016-09-121-0/+6
| | | | | | | | The i.MX50 SOC includes one ESDHCv3, three ESDHCv2, one cspi and two ecspi instances which are supported by existing drivers. Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: i.MX chipidea: Enable VBUS regulator when neededSascha Hauer2016-09-051-4/+13
| | | | | | | We should enable VBUS only in host mode, not unconditionally during probe(). Fix that. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: chipidea i.MX: Do not return unnecessary errorSascha Hauer2016-08-291-3/+8
| | | | | | | | | We only allow to setup the host/peripheral role once, when it's already set then we return -EBUSY. Return 0 instead when we set the same role again and only return -EBUSY when we actually try to change the role. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/driver'Sascha Hauer2016-03-113-9/+15
|\
| * driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-073-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * driver: Fix return check of dev_request_mem_regionSascha Hauer2016-02-232-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region returns an ERR_PTR, fix places which check for a NULL pointer instead. This patch has been generated with this semantic patch, written by me and improved by Andrey Smirnov: // <smpl> @@ expression e; expression e1; @@ e = dev_request_mem_region(...); ... -if (!e) - return e1; +if (IS_ERR(e)) + return PTR_ERR(e); @ rule1 @ expression e; @@ e = dev_request_mem_region(...); @@ expression rule1.e; identifier ret, label; constant errno; @@ if (!e) { ... ( - ret = -errno; + ret = PTR_ERR(e); ... goto label; | - return -errno; + return PTR_ERR(e); ) } @depends on rule1@ expression rule1.e; @@ - if (e == NULL) + if (IS_ERR(e)) { ... } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
* | USB: imx-usb-phy: Fix uninitialized use of variableSascha Hauer2016-03-101-0/+1
|/ | | | | | ret may no be initialized in the error path when clk_get fails. Fix it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: chipidea-imx: check return value of regulator_get()David Jander2016-01-081-1/+2
| | | | | | | | | | The VBUS regulator is optional for the chipidea-imx glue, so it must be checked if regulator_get provided a valid regulator handle before trying to enable the regulator. Signed-off-by: David Jander <david@protonic.nl> Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: mx25: fix bit position of "Host power mask"Uwe Kleine-König2015-11-091-1/+1
| | | | | | | | | | | | | | | | | The bit MX25_H1_PM_BIT value is handled for port 1 as MX25_OTG_PM_BIT is for port 0. The latter is called "OPM: OTG power mask" in the i.MX25 reference manual. Its description matches the description of "HPM: Host power mask" for the host port which is bit 16, not 8. The Linux kernel (as of 4.3) also has #define MX25_H1_PM_BIT BIT(16) . Fixes: a4076ddf6577 ("USB i.MX: Add chipidea driver support") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb'Sascha Hauer2015-10-071-0/+7
|\
| * usb: chipidea: Add udc unregister for device removalMarkus Pargmann2015-09-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | The host may assume that the usb device is still up and running after booting if we do not deregister the udc here. I observed issues when the linux kernel was using a usb gadget directly where the complete USB Hub got disconnected through this. This patch adds a proper USB disconnect for gadget devices. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2015-10-071-1/+1
|\ \
| * | introduce strerrorpSascha Hauer2015-09-231-1/+1
| |/ | | | | | | | | | | | | | | | | | | putting an error pointer into strerror can be a bit confusing since strerror takes a positive error code but PTR_ERR returns a negative number, so we have to do strerror(-PTR_ERR(errp)). Some places got this wrong already, so introduce a strerrorp function which directly takes an error pointer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / chipidea-imx: allow phymode configuration in pdataEric Bénard2015-09-291-0/+1
|/ | | | | | | | | it's currently only handled through DT and for i.MX25 OTG port (at least), we need to configure portsc to get host mode working but it actually fails as ci->phymode is 0 which is USBPHY_INTERFACE_MODE_UNKNOWN Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 2011 barebox' of_device_id struct uses unsigned long type for data field: struct of_device_id { char *compatible; unsigned long data; }; Almost always struct of_device_id.data field are used as pointer and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output: drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = { drivers/ata/sata-imx.c- { drivers/ata/sata-imx.c- .compatible = "fsl,imx6q-ahci", drivers/ata/sata-imx.c- .data = (unsigned long)&data_imx6, drivers/ata/sata-imx.c- }, { Here is of_device_id struct in linux kernel v4.0: struct of_device_id { char name[32]; char type[32]; char compatible[128]; const void *data; }; Changing of_device_id.data type to 'const void *data' will increase barebox' linux kernel compatibility and decrease number of 'unsigned long' casts. Part of the patch was done using the 'coccinelle' tool with the following semantic patch: @rule1@ identifier dev; identifier type; identifier func; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type) + dev_get_drvdata(dev, (const void **)&type) ...> } @rule2@ identifier dev; identifier type; identifier func; identifier data; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type->data) + dev_get_drvdata(dev, (const void **)&type->data) ...> } Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/resource-err-ptr'Sascha Hauer2014-10-021-2/+3
|\
| * resource: Let dev_request_mem_region return an error pointerSascha Hauer2014-09-161-2/+3
| | | | | | | | | | | | For all users fix or add the error check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | USB: add usb phy header fileSascha Hauer2014-09-261-0/+1
|/ | | | | | | Mostly taken from the Linux Kernel to ease porting phy handling code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* USB: i.MX chipidea: Implement OTG support for the poorSascha Hauer2014-07-181-9/+92
| | | | | | | | For situations when we don't know the desired mode for the OTG port we register a otg device which has a mode parameter to specifiy the desired mode on the command line. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: chipidea i.MX: relax phy_type requirementsSascha Hauer2014-05-221-9/+10
| | | | | | | | Some USB ports only have one possiblitly for the phy_type and the type is not specified in the devicetree in this case. Rely on the reset default instead of failing. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: chipidea i.MX: add some delay after ulpi_setupSascha Hauer2014-01-071-0/+1
| | | | | | | | On the pcm038 the ULPI phy is found correctly, but after a power cycle the attached devices are not found. Adding some delay fixes this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: chipidea i.MX: always print an error message when ULPI failsSascha Hauer2014-01-071-0/+3
| | | | | | | | The ULPI code does not print a message when the operation times out. Add one to the caller so that he gets an idea that something is going wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: chipidea i.MX: limit port init to HSIC modeSascha Hauer2014-01-071-1/+2
| | | | | | | | imx_chipidea_port_init() will be called during startup from the ehci driver. Calling it before setting up the PORTSC register is only necessary in HSIC mode. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: chipidea i.MX: remove unused pdata->init hookSascha Hauer2014-01-071-5/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Add missing includesSascha Hauer2013-11-083-0/+6
| | | | | | | | A lot of files rely on include/driver.h including include/of.h (and this including include/errno.h. include the files explicitly so we can eventually get rid of including of.h from driver.h Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>