aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/chipidea/core.c
AgeCommit message (Collapse)AuthorFilesLines
2013-10-30usb: chipidea: only get vbus regulator for non-peripheral modePeter Chen1-12/+15
If the user chooses peripheral mode for this controller, the vbus regulator doesn't need to get, since the host will supply the vbus, it can save one vbus pin for other usage. Signed-off-by: Peter Chen <[email protected]> Tested-by: Frank Li <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-09-30usb: chipidea: add ci_hdrc_enter_lpm APIPeter Chen1-0/+24
This API is used to let the PHY enter/leave low power mode. Before the controller going to work(at probe/resume), it needs to let the PHY leave low power mode. After the controller stopping working(at remove/suspend), it needs to let the PHY enter low power mode to save power consumption. Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-09-30usb: chipidea: move PHY operation to corePeter Chen1-6/+51
PHY operations are common, so move them to core. Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-09-29Merge 3.12-rc3 into usb-nextGreg Kroah-Hartman1-0/+1
We want the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-09-25usb: chipidea: Fix memleak for ci->hw_bank.regmap when removalPeter Chen1-0/+1
It needs to free ci->hw_bank.regmap explicitly since it is not managed resource. Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-09-25usb: chipidea: move platform related things to ci_get_platdataPeter Chen1-10/+9
Like vbus, the dr_mode and phy_mode are also got from glue layer's platform data or device node. Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: add wait vbus lower than OTGSC_BSV before role startsPeter Chen1-0/+32
When the gadget role starts, we need to make sure the vbus is lower than OTGSC_BSV, or there will be an vbus interrupt since we use B_SESSION_VALID as vbus interrupt to indicate connect and disconnect. When the host role starts, it may not be useful to wait vbus to lower than OTGSC_BSV, but it can indicate some hardware problems like the vbus is still higher than OTGSC_BSV after we disconnect to host some time later (5000 milliseconds currently), which is obvious not correct. Tested-by: Marek Vasut <[email protected]> Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: add vbus interrupt handlerPeter Chen1-5/+23
We add vbus interrupt handler at ci_otg_work, it uses OTGSC_BSV(at otgsc) to know it is connect or disconnet event. Meanwhile, we introduce two flags id_event and b_sess_valid_event to indicate it is an id interrupt or a vbus interrupt. Tested-by: Marek Vasut <[email protected]> Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: move otg related things to otg filePeter Chen1-50/+13
Move otg related things to otg file. Tested-by: Marek Vasut <[email protected]> Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: disable all interrupts and clear all interrupts statusPeter Chen1-1/+10
During the initialization, it needs to disable all interrupts enable bit as well as clear all interrupts status bits to avoid exceptional interrupt. Tested-by: Marek Vasut <[email protected]> Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: add flag CI_HDRC_DUAL_ROLE_NOT_OTGPeter Chen1-7/+30
Since we need otgsc to know vbus's status at some chipidea controllers even it is peripheral-only mode. Besides, some SoCs (eg, AR9331 SoC) don't have otgsc register even the DCCPARAMS_DC and DCCPARAMS_HC are both 1 at CAP_DCCPARAMS. We inroduce flag CI_HDRC_DUAL_ROLE_NOT_OTG to indicate if the controller is dual role, but not supports OTG. If this flag is not set, we follow the rule that if DCCPARAMS_DC and DCCPARAMS_HC are both 1 at CAP_DCCPARAMS, then this controller is otg capable. Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: add role init and destroy APIsPeter Chen1-2/+8
- The role's init will be called at probe procedure. - The role's destroy will be called at fail patch at probe and driver's removal. - The role's start/stop will be called when specific role has started. Tested-by: Marek Vasut <[email protected]> Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: otg: add otg file used to access otgscPeter Chen1-1/+2
This file is mainly used to access otgsc currently, it may add otg related things in the future. Tested-by: Marek Vasut <[email protected]> Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: move vbus regulator operation to corePeter Chen1-0/+23
The vbus regulator is a common element for USB vbus operation, So, move it from glue layer to core. Tested-by: Marek Vasut <[email protected]> Signed-off-by: Michael Grzeschik <[email protected]> Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: remove previous MODULE_ALIASFabio Estevam1-1/+0
After the rename to ci_hdrc we ended up with two MODULE_ALIAS entries, so remove the old one. Signed-off-by: Fabio Estevam <[email protected]> Reviewed-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: prevent endless loop registering platform_devices when probe ↵Lothar Waßmann1-5/+3
fails Commit 40dcd0e ("usb: chipidea: add PTW, PTS and STS handling") introduced the following code to the ci_hdrc_probe() function: + if (!dev->of_node && dev->parent) + dev->of_node = dev->parent->of_node; This inadvertently associates the ci_hdrc device with the ci_hdrc_imx driver (which created the ci_hdrc device in the first place). This results in ci_hdrc_imx_probe() being run for the ci_hdrc device if ci_hdrc_probe() fails for some reason. ci_hdrc_imx_probe() will happily create a new ci_hdrc platform_device whose probing will likewise fail and trigger a new invocation of ci_hdrc_imx_probe() ... ad nauseam. Signed-off-by: Lothar Waßmann <[email protected]> Reviewed-and-tested-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: don't clobber return value of ci_role_start()Lothar Waßmann1-1/+0
If a role fails to start, propagate the error code up the call stack from probe. Signed-off-by: Lothar Waßmann <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-08-14usb: chipidea: move hw_phymode_configure() into probeFabio Estevam1-2/+2
Currently hw_phymode_configure() is located inside hw_device_reset(), which is only called by chipidea udc driver. When operating in host mode, we also need to call hw_phymode_configure() in order to properly configure the PHY mode, so move this function into probe. After this change, USB Host1 port on mx53qsb board is functional. Signed-off-by: Fabio Estevam <[email protected]> Tested-by: Arnaud Patard <[email protected]> Reviewed-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-06-24usb: chipidea: drop "13xxx" infixAlexander Shishkin1-18/+18
"ci13xxx" is bad for at least the following reasons: * people often mistype it * it doesn't add any informational value to the names it's used in * it needlessly attracts mail filters This patch replaces it with "ci_hdrc", "ci_udc" or "ci_hw", depending on the situation. Modules with ci13xxx prefix are also renamed accordingly and aliases are added for compatibility. Otherwise, no functional changes. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-06-17usb: chipidea: introduce dual role mode pdata flagsSascha Hauer1-6/+18
Even if a chipidea core is otg capable the board may not be. This allows to explicitly set the core to host/peripheral mode. Without these flags the driver falls back to the old behaviour. Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-06-17usb: chipidea: add PTW, PTS and STS handlingMichael Grzeschik1-0/+48
This patch makes it possible to configure the PTW, PTS and STS bits inside the portsc register for host and device mode before the driver starts and the phy can be addressed as hardware implementation is designed. Signed-off-by: Michael Grzeschik <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-06-17usb: chipidea: udc: add multiple td support to hardware_{en,de}queueMichael Grzeschik1-1/+0
This patch removes the restriction of having a limited amount of only four active tds on one endpoint. We use the linked list implementation to manage all tds which get added and removed by hardware_{en,de}queue. The removal of this restriction adds the driver to run into a hardware errata. It's possible that the hardware will still address an transfer descriptor that already got cleaned up. To solve this the patch also postpone the cleanup of processed tds by one. Signed-off-by: Michael Grzeschik <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-06-17usb: chipidea: udc: configure iso endpointsMichael Grzeschik1-1/+1
This patch adds iso endpoint support to the device controller. It makes use of the multiplication bits in the maxpacket field of the endpoint and calculates the multiplier bits for each transfer description on every request. Signed-off-by: Michael Grzeschik <[email protected]> Reviewed-by: Peter Chen <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-06-11usb: chipidea: fix id change handlingAlexander Shishkin1-1/+2
Re-enable chipidea irq even if there's no role changing to do. This is a problem since b183c19f ("USB: chipidea: re-order irq handling to avoid unhandled irqs"); when it manifests, chipidea irq gets disabled for good. Cc: [email protected] # v3.7 Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-05-18drivers/usb/chipidea: don't check resource with devm_ioremap_resourceWolfram Sang1-5/+0
devm_ioremap_resource does sanity checks on the given resource. No need to duplicate this in the driver. Signed-off-by: Wolfram Sang <[email protected]> Acked-by: Alexander Shishkin <[email protected]>
2013-03-30usb: chipidea: big-endian supportSvetoslav Neykov1-1/+1
Convert between big-endian and little-endian format when accessing the usb controller structures which are little-endian by specification. Fix cases where the little-endian memory layout is taken for granted. The patch doesn't have any effect on the already supported little-endian architectures. Signed-off-by: Svetoslav Neykov <[email protected]> [Alex: minor cosmetic fixes] Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-03-30usb: chipidea: don't redefine __ffs()Felipe Balbi1-4/+4
chipidea's ffs_nr() is pretty much what __ffs() does. Use that one instead. Signed-off-by: Felipe Balbi <[email protected]> [rebased on top of debug infrastructure rework] Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-03-30usb: chipidea: move debug files creation/removal to the coreAlexander Shishkin1-1/+5
Create and remove debugfs entries in hdrc probe/remove instead of start/stop of the device controller. Gadget specific will not export anything while the controller is in host mode. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-03-30usb: chipidea: move role to debugfsAlexander Shishkin1-39/+0
Manual role switching function is there for debugging purposes, so has to move to debugfs. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-03-29usb: chipidea: core: switch over to devm_ioremap_resourceFelipe Balbi1-5/+3
switch over to the newly added devm_ioremap_resource which provides more consistent error messages. Signed-off-by: Felipe Balbi <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-03-29usb: chipidea: trim include list in the coreAlexander Shishkin1-3/+0
Some headers included in the chipidea controller core are not needed, remove them. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-01-21drivers/usb/chipidea/core.c: adjust duplicate testJulia Lawall1-1/+1
Delete successive tests to the same location. In this case res has already been tested for being NULL, and calling devm_request_and_ioremap will not make it NULL. On the other hand, devm_request_and_ioremap can return NULL on failure. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @s exists@ local idexpression y; expression x,e; @@ *if ( \(x == NULL\|IS_ERR(x)\|y != 0\) ) { ... when forall return ...; } ... when != \(y = e\|y += e\|y -= e\|y |= e\|y &= e\|y++\|y--\|&y\) when != \(XT_GETPAGE(...,y)\|WMI_CMD_BUF(...)\) *if ( \(x == NULL\|IS_ERR(x)\|y != 0\) ) { ... when forall return ...; } // </smpl> Signed-off-by: Julia Lawall <[email protected]> Cc: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-11-26USB: chipidea: fix use after free bugLothar Waßmann1-1/+2
The pointer to a platform_device struct must not be dereferenced after the device has been unregistered. This bug produces a crash when unloading the ci13xxx kernel module compiled with CONFIG_PAGE_POISONING enabled. Signed-off-by: Lothar Waßmann <[email protected]> Cc: stable <[email protected]> # 3.6 Acked-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-11-21usb: remove use of __devexitBill Pemberton1-1/+1
CONFIG_HOTPLUG is going away as an option so __devexit is no longer needed. Signed-off-by: Bill Pemberton <[email protected]> Cc: Peter Korsgaard <[email protected]> Cc: Alexander Shishkin <[email protected]> Acked-by: Felipe Balbi <[email protected]> Cc: Li Yang <[email protected]> Cc: Alan Stern <[email protected]> Cc: Wan ZongShun <[email protected]> Cc: Ben Dooks <[email protected]> Cc: Kukjin Kim <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-11-21usb: remove use of __devinitBill Pemberton1-1/+1
CONFIG_HOTPLUG is going away as an option so __devinit is no longer needed. Signed-off-by: Bill Pemberton <[email protected]> Cc: Peter Korsgaard <[email protected]> Cc: Alexander Shishkin <[email protected]> Acked-by: Felipe Balbi <[email protected]> Cc: Li Yang <[email protected]> Acked-by: Alan Stern <[email protected]> Cc: Geoff Levand <[email protected]> Cc: Wan ZongShun <[email protected]> Cc: Olav Kongas <[email protected]> Cc: Lennert Buytenhek <[email protected]> Cc: Ben Dooks <[email protected]> Cc: Kukjin Kim <[email protected]> Acked-by: Nicolas Ferre <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-11-21usb: remove use of __devexit_pBill Pemberton1-1/+1
CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer needed. Signed-off-by: Bill Pemberton <[email protected]> Cc: Peter Korsgaard <[email protected]> Cc: Alexander Shishkin <[email protected]> Acked-by: Felipe Balbi <[email protected]> Cc: Li Yang <[email protected]> Cc: Alan Stern <[email protected]> Cc: Wan ZongShun <[email protected]> Cc: Ben Dooks <[email protected]> Cc: Kukjin Kim <[email protected]> Acked-by: Nicolas Ferre <[email protected]> Acked-by: Peter Korsgaard <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-09-12USB: chipidea: re-order irq handling to avoid unhandled irqsRichard Zhao1-8/+13
- let role driver handle irq before ID change check; this gives the role driver a chance to handle disconnect; - disable irq during switch role; no role driver to handle irq in the period. Tested-by: Michael Grzeschik <[email protected]> Tested-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Richard Zhao <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-09-12USB: chipidea: acknowledge ID change interrupt in irq handlerRichard Zhao1-2/+1
In order to avoid re-queueing of the role changing work, we need to clear the ID change interrupt bit right in the irq handler. Tested-by: Michael Grzeschik <[email protected]> Tested-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Richard Zhao <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-09-12USB: chipidea: delay 2ms before read ID status at probe timeRichard Zhao1-0/+2
The ID pin needs 1ms debounce time, even at probe time. We delay 2ms to be on the safe side. Tested-by: Michael Grzeschik <[email protected]> Tested-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Richard Zhao <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-07-09usb: chipidea: permit driver bindings pass phy pointerRichard Zhao1-0/+4
Sometimes, the driver bindings may know what phy they use. For example, when using device tree, the usb controller may have a phandler pointing to usb phy. Signed-off-by: Richard Zhao <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Acked-by: Felipe Balbi <[email protected]> Tested-by: Subodh Nijsure <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-07-09USB: Chipidea: add ci13xxx device id managementRichard Zhao1-5/+16
We use ida_simple_get and ida_simple_remove to manage the ids. Signed-off-by: Richard Zhao <[email protected]> Reviewed-by: Felipe Balbi <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-07-09USB: Chipidea: add unified ci13xxx_{add,remove}_device for platform driversRichard Zhao1-0/+43
Platform drivers do the similar things to add/remove ci13xxx device, so create a unified one. Signed-off-by: Richard Zhao <[email protected]> Reviewed-by: Felipe Balbi <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-07-06USB: Chipidea: rename struct ci13xxx_udc_driver to struct ci13xxx_platform_dataRichard Zhao1-6/+6
This patch rename struct ci13xxx_udc_driver and var with the type. ci13xxx_platform_data reflect it's passed from platfrom driver. Signed-off-by: Richard Zhao <[email protected]> Reviewed-by: Felipe Balbi <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-05-15usb: chipidea: remove zero check of hw_ep_maxRichard Zhao1-1/+1
It's 0 for host only device. Signed-off-by: Richard Zhao <[email protected]> Cc: Marek Vasut <[email protected]> Cc: Alan Stern <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Felipe Balbi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-05-11usb: chipidea: add host roleAlexander Shishkin1-4/+11
This adds EHCI host support to the chipidea driver. We want it to be part of the hdrc driver and not a standalone (sub-)driver module, as the structure of ehci-hcd.c suggests, so for chipidea controller we hack it to not provide platform-related code, but only the ehci hcd. The ehci-platform driver won't work for us here too, because the controller uses the same registers for both device and host mode and also otg-related bits, so it's not really possible to put ehci registers into a separate resource. This is not a pretty solution, but the alternative is exporting symbols from the chipidea driver to a ehci-chipidea driver and doing all the module refcounting. Signed-off-by: Alexander Shishkin <[email protected]> Cc: Alan Stern <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-05-11usb: chipidea: use common definition for USBMODE bitsAlexander Shishkin1-3/+3
Some of the bits of USBMODE register are defined in <usb/ehci_def.h>, use them instead of having our own definitions. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-05-11usb: chipidea: drop unused msm register definitionsAlexander Shishkin1-3/+0
These definitions are unused, and the same registers are also defined in <linux/usb/msm_hsusb_hw.h>. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-05-11usb: chipidea: add support for rolesAlexander Shishkin1-52/+198
Add some generic code for roles and implement simple role switching based on ID pin state and/or a sysfs file. At this, we also rename the device to ci_hdrc, which is what it is. The "manual" switch is made into a sysfs file and not debugfs, because it might be useful even in non-debug context. For some boards, like sheevaplug, it seems to be the only way to switch roles without modifying the hardware, since the ID pin is always grounded. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-05-11usb: chipidea: split the driver code into unitsAlexander Shishkin1-0/+324
Split the driver into the following parts: * core -- resources, register access, capabilities, etc; * udc -- device controller functionality; * debug -- logging events. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>