This patch fixes a possible interrupt storm condition by
the USB wake IRQ, which can cause a dog timeout crash.
The USB wake IRQ detects USB bus suspend on USB D+ line.
This can be done by a rising edge triggered interrupt,
rather than level triggered interrupt.
Change-Id: Ia5451c3847285d38dde893856680a011674bd1e3
Signed-off-by: Amit Blay <ablay@codeaurora.org>
commit e879990 (USB: EHCI: remove usages of hcd->state) removed the
hcd->state usage in EHCI driver. Instead rh_state field of ehci_hcd
struct should be used. But the current code is still using
hcd->state. This bug is introduced during 3.4 kernel porting.
If rh_state field is not updated to SUSPEND during root hub suspend,
the root hub will not be resumed upon device connection or remote wakeup.
Change-Id: Id47e7c650c03cda2e7be00be4e8b92a47257fc6a
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
The endpoints fail to enable if they are not configured. Hence configure
the IN and OUT endpoints in eth_stop() function before enabling them.
Change-Id: I936c5c492054cbc16bde6f1d0414712d8a0048d7
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
This change add support in ci13xxx_msm_hsic driver and
ehci-msm-hsic driver for VDDCX corner voting.
In case a VDDCX corner resource is supported by the platform,
it will be used. Else, the legacy voting for specific voltage
level will be used.
Change-Id: Iae91d1c945f9b61340628b2fc7c7727e4cca6a1e
CRs-Fixed: 354458
Signed-off-by: Amit Blay <ablay@codeaurora.org>
Signed-off-by: David Collins <collinsd@codeaurora.org>
This fix handles two race conditions:-
1) Unlinking rx URBs during interface suspend races with completion
of a rx urb, which may cause successful completion of an urb with
actual data with a status of -ECONNRESET. Avoid this race by
anchoring the urb while submission and unlink only anchored urbs
during suspend.
2) Race between write and resume with the possibility of data write
submitting urb immediately before the delayed urbs are played back
during resume. This results in data written by tty driver getting
submitted out of order to HSIC controller.
CRs-Fixed: 371929
Change-Id: I4e9c7e994d643978b9889316b899f0251be807b6
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Replace calls to platform_device_del with platform_device_unregister
which calls device_put to properly free the device structure.
CRs-fixed: 366005
Change-Id: Ic3d82e50383fa475f50c73e5982ef718a9eaa26f
Signed-off-by: Jack Pham <jackp@codeaurora.org>
This change is compliant with the following commit:
usb: dwc3: convert TRBs into bitshifts
f6bafc6a1c
Change-Id: Iffac2549f6bc966156920de7f1947d72f43efd81
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
Use usb generic routines instead of dwc3 specific.
Change-Id: Iacbcc1fb0285a646bf1eb306d8cd4b5a7cd920a1
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
Re-push the following commit due to merge conflict problem:
usb: dwc3: USB_DWC3_MSM not auto select USB_GADGET_SUPERSPEED
7f989ac838faa0a68abd0162c77aff273df2012a
Change-Id: I17e8e2ee5af9fc136b749f282a91f16c45d6fa68
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
As part of kernel 3.4 merge, this driver was modified such
that TRB of size 0 points to DMA_ADDR_INVALID. This causes
infinite SPS transfer to fail after a single transfer.
The fix changes the TRB to point to 0.
Change-Id: I772631f79582db69dccc7aa1801e69695505b958
Signed-off-by: Amit Blay <ablay@codeaurora.org>
Use the usb_interface's dev member for dev_printk instead of the
usb_device's, as this will help improve kernel logging clarity by
displaying the interface name and number as well as just the USB
bus/device numbers.
Change-Id: I677558fd6c33ee658ef03fdcbb25bb5c0782f77b
Signed-off-by: Jack Pham <jackp@codeaurora.org>
usb_autopm_get_interface() returns an error if runtime PM is disabled,
yet this should not impede the ability to submit URBs. This can happen
just as the device is removed but the interface driver's disconnect()
routine has not been called. Thus any client wishing to call read or
write may errorneously continue to call and might eventually flood the
console with excessive printks which could cause a watchdog timeout. So
treat -EAGAIN and -EACCES as okay and only bail on other error values.
Also, rate-limit the printks associated with reading/writing on the
bridge to further avoid the possibility of excessive logging during
similar corner cases.
Finally, use -ENODEV as an indicator that read/write should halt. This
will handle the case when an URB fails to submit late in the device
disconnect stage, and the client should not attempt any more submissions.
CRs-fixed: 370694
Change-Id: Ia5f4a4bd7ed620eedd2cd00c117066b8c7eb4f8c
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Increment the refcount on diag_bridge_open() and decrement it when
closing, as well as within read() and write(). This will ensure that
the bridge structure object won't be accidentally freed before the
diag client is done using the bridge. Also, although the client should
have the responsibility of not calling read or write after the bridge
is closed, protect against improper access by checking the structure
pointers for NULL.
CRs-fixed: 370666
Change-Id: I2697fc6e6a7eddd5d95a9dea4b980b8aaea74d2c
Signed-off-by: Jack Pham <jackp@codeaurora.org>
User space writes USB serial number to a sysfs file. Strim the
buffer before copying to USB string descriptor, otherwise
serial number may contain white spaces or new line characters.
Change-Id: If0dc699f53b92d80beaa099148f085d6c63af9a6
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
DWC3 has two PHYs for both super-speed and high-speed
mode of operations. Add voting for the regulators which
are required by both the PHYs in the driver.
As of now, these regulators are turned ON when driver's
probe routine gets called and stays ON. Later as part of
low power mode support in the driver these regulators would
be selectively disabled depending on the PHY under use.
Change-Id: I218c5b06adf2d5af297cba2d64e9427be9bb48f8
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Currently otg driver is voting to allow TCXO shutdown in host
bus suspend due to which devices connected in system suspend
are not getting detected. Hence don't allow TCXO shutdown in
host bus suspend.
As long term solution, need HW rework for detecting connecting
devices in host mode during system suspend. This is required to
route D+ and D- lines to MPM for monitoring interrupt during
system suspend.
CRs-Fixed: 366111
Change-Id: Ic478a0e327b104eec64b5cfe2bd1f9369f8ef72e
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
OTG driver should not be using power_supply_get_by_name in IRQ context
and calling this api for every USB cable insertion/removal is very
inefficient.
CRs-Fixed: 363098
Change-Id: Iae7f63c755fbb177abd23cbff0b81d3cd76f95b8
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
This change adds the ability of the msm_otg to go to LPM when
USB cable is connected and bus is suspended.
This ability is enabled by a board file parameter.
The msm_otg is notified about SUSPEND/RESUME events via the
UDC layer. New event for RESUME was defined for that.
Change-Id: Ic508f1898cc3b57ab76eccd379bea38ed363570b
Signed-off-by: Amit Blay <ablay@codeaurora.org>
While turning on the OTG, the charger should be configured to not draw
any current from the usb before turning on the 5V boost. While turning
off the OTG, the boost should be turned off before configuring the
charger to draw current from usb.
Fix this ordering.
Change-Id: Iebd9bf166334e34d92b2ada623dec71a5f0326eb
CRs-Fixed: 338648
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Part of commit d44455a0b838b1d691e63913f0b159552ac01803 introduced
a regression affecting resume behavior in that the controller's system
resume callback is being followed by an immediate runtime suspend; if
the system resume was caused by an OTG event, there would be a pending
runtime resume in the state machine function, which might fail due to
this race, causing the PHY to be unnecessarily reset.
This patch limits the actual hardware resumes to happen only when needed.
If a possible wakeup event such as VBUS or ID interrupt occurs while
in system suspend, don't allow runtime resume to execute in the wakeup
handler but rather defer the resuming to the system resume callback.
Also by incrementing the PM runtime usage counter within the system
resume, it may help prevent the premature runtime suspend from happening
immediately afterward. Otherwise, if there is no such OTG event, and
the controller is not a suspended host, do nothing.
If the bus is instead runtime suspended (and not system suspended) when
a wakeup event occurs, then normal runtime resume will bring the
hardware out of low power mode.
CRs-fixed: 358761
Change-Id: I4249690485949ecb3072e258859608ecea52ec9b
Signed-off-by: Jack Pham <jackp@codeaurora.org>
To enable better power management and entering CPU idle states while
USB cable is connected and no USB SW involvement is required
(MSM BAM2BAM mode) a new SysFS was added.
This SysFS allow controlling USB voting and gives the ability
to save power consumption while USB is active.
default behavior is high QoS. to change the new SysFS
echo high/low to /sys/class/android_usb/android0/pm_qos
Change-Id: Ia73491cfddc3968e1d04423a1750c89fab5fefeb
Signed-off-by: Ofir Cohen <ofirc@codeaurora.org>
Enable VDD CX regulator voltage setting even for kernel configs
without PM_SLEEP enabled. This is required so that USB functions
without power management.
Previously disabling power management also incorrectly disables USB.
Change-Id: I81d04cbca2e956e12fe40eeb97fbaab8c2ec1fd2
Signed-off-by: David Ng <dave@codeaurora.org>
Disable PHY VBUS comparator if otg driver depends on PMIC
for VBUS and ID notifications. If enabled, VBUS comparator is
creating some noise to SESSVLD comparator and causing SESSVLD
comparator to trigger low due to which link state machine becomes
stuck as it operates solely on that value.
CRs-Fixed: 355991
Change-Id: Ieb8101f3063ebf9898da3ec9fd158c248a6cb15a
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
New platform uses RBCPR hardware feature, with that voting for
absolute voltage of VDD CX is not required. Hence vote for corner of
VDD CX which uses nominal corner voltage on VDD CX.
CRs-Fixed: 355399
Change-ID: I22a73c5a439c98195b907ff3d032eb675a557612
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
The USB alt_core_clk is only enabled during reset sequence, since PHY
does not supply it during the reset and link needed a free running clock
during the reset. This clock is not present on SoCs, where link uses
an asynchronous reset methodology.
Change-Id: I124e705c6e2d26fc2c7fccc1877e2c80e1e8e945
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
If clk_get on core_clk fails in probe function, the return value
is incorrectly assigned. Assign the ret variable to the error
code returned for core_clk not alt_core_clk.
Change-Id: Icca82e8e44cd40149205c246f427ab82e4656268
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Fix the bug where charger type and state are set after notifying to PMIC
in B_IDLE and B_PERIPHERAL otg states.
Change-Id: Ia5f7b62b61bb3d8c239690c5e37f74c60a383096
CRs-Fixed: 353711
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
This reverts commit 34b874562012c3453da20059094992140ca1ea61.
Revert the removal of the set_usb_power_supply_type to allow
customized charger drivers to leverage off of the information
provided by the usb driver.
Change-Id: I3629202ac65793a8c5819d4371048c212030ae47
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
According to the commit text of "PM: Limit race conditions between
runtime PM and system sleep (v2)", a driver should not call
pm_runtime_suspend() from its .suspend() callback, as that creates
a recursive call into the subsystem.
This fixes msm_otg_pm_suspend() from doing just that. Instead, call
the helper function to explicitly suspend, without depending on the
runtime PM call. Likewise, the system resume callback should actually
resume the device.
Change-Id: I6ef0609dc4979ad31ef338e1eee3d21af47c256b
Signed-off-by: Jack Pham <jackp@codeaurora.org>
PHY retention and HV interrupts are not enabled while entering into low
power mode with wall charger connected. But PHY is put into suspend mode.
If PMIC notifications are unavailable, enable asynchronous interrupt to
detect wall charger disconnection. If it is not enabled, no further
interrupts are triggered by PHY.
CRs-fixed: 352210
Change-Id: I107e1c91a29d65594a603a5651cd0bfe5b792bcc
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
The current ACA ID timer period is 2 sec. If charger is plugged
in or removed, the UI update will take 2 sec in the worst case.
Reduce the current period from 2 sec to 500 msec for better
UI experience.
CRs-Fixed: 346923
Change-Id: I933b22aa8d4dc517eb5a5bf3fa25ba7ce693411c
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
This reverts commit 7dd2266ae3d3f1d2cb93d1d3bb40aecf23821e76.
It was a mistake to move the usb driver to the clock apis for XO
buffer voting. Due to an RPM design CXO and D0 are the same but
we would like to hide that from the users of the buffers.
Therefore the msm_xo driver itself remaps the D0 buffer request
to the cxo clock until the RPM is fixed.
Change-Id: I230de55d30a49fa5bcf0d07f40453f1e09c4a9b1
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Clean up some error paths and simplify the code by
moving to devm_regulator_get().
Change-Id: I782569d2d5aec077ea18516db7eba92897698bce
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Currently writing 0x0 into AHBMODE register which means both data
transactions and QH and TD descriptors are non-posted writes to
system memory. As per HW team recommendation, should write 0x08 value
to set AHB HPROT mode into the AHBMODE register which allows posted
data writes to system memory and will improve the throughput numbers.
Change-Id: Ib44a8cfe11c6ff96ff712643227532e24548e706
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
This change add's support for reading the otg_state of the device
through debugfs.
CRs-Fixed: 346906
Change-Id: Ifc0d28aa8626827f10740b97642946a564f78ca6
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
This custom notifier is no longer required to determine
wether a wall charger is connected to the PM8921 charger
or not.
The pm8921-charger driver determines AC charging solely
dependent upon maximum input current from the charging
device.
CRs-Fixed: 339841
Change-Id: I564fa01c61286d013be6b263d038e87568a297f2
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
This patch changes OTG driver to support different
OTG statemachine states for OTG2.0 complaince. It will
also enable to swap Host role between two OTG devices
via HNP and enable B device to request A device to start
VBUS session via SRP.
Change-Id: Ibe2519ff1570768f51e879af483a6f5c23b38d8f
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
OTG driver requests for high bus bandwidth as long as USB cable is
connected to improve USB throughput. This vote causes scaling up of
fabric frequencies and increase in the over system power consumption.
Some users might not be interested in this feature or may want to
disable this at runtime for profiling the system performance with USB
cable attached.
Hence, add a debugfs entry to allow users to disable this voting.
By default this feature is enabled.
Command to disable BUS voting from USB:
echo "disable" > <debugfs>/msm_otg/bus_voting
Change-Id: Icdd9c56623a9c91ff3a130d80983c3ddeb0f91c4
CRs-fixed: 341452
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Clock framework now provides two new APIs: clk_prepare and
clk_unprepare which can be called from non-atomic context only.
Other clk_enable and clk_disable APIs can be called from atomic
context.
To enable a clock drivers need to call both clk_prepare and
clk_enable. Similarly for disabling a clock - clk_disable and
clk_unprepare should be called.
Change-Id: I1ec0764e34619b92d811e1dadd2bb49b5cf36f5c
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
PMIC internal pullup resistor to be between 75k - 480k. The ACA
pulldown resistor can range from 36k - 220k. So leaving the PMIC
internal pullup on while the PHY does ACA detection would cause
problems.
Change-Id: I70e68094ce96a79531b7d3173c9a23fdcc52840d
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Battery charging spec 1.2 mandates portable devices to enable
VDP_SRC while charging from dedicated charger port. Enable
VDP_SRC after detecting the charger as wall charger and enter
low power mode. PHY can not drive VDP_SRC in retention. Vote
against PHY retention and PHY power collapse.
Disable primary detection circuit and wait for 20msec before
enabling secondary detection circuit. This would allow complete
discharge of voltage on the DM.
The DP/DM voltage source on time is taken as 40msec. The spec
allows any value greater than 40msec. Increase this timeout value
to 50msec for passing compliance tests correctly.
CRs-fixed: 330227
Change-Id: I0bc72b2098ff52644daab3a902b5ba099bb83667
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Drivers need to specify their bandwidth requirements to
bus-scaling driver to get guaranteed bandwidth on fabrics.
USB hardware uses a single buffer to transfer data across the
bus. As a result USB performance is highly dependent on system
fabric frequency as USB controller continuously sends NAKs on
the USB BUS unless complete buffer is filled/drained to the memory.
Hence, request for high bus bandwidth as long as USB cable is
connected to improve USB throughput.
While testing with Class-10 Extreme III SD cards, this patch
seems to improve the IN performance from 15MBps to 24MBps and
OUT performance from 11MBps to 16MBps.
CRs-Fixed: 327557
Change-Id: I21c284c611a09b1b12df9ae7a6f39e0b1bff45ef
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Use the clock APIs instead of the msm_xo APIs to vote on CXO.
This removes one more msm specific api from this driver and will
allow us to move XO control into the rpm clock driver.
Change-Id: Ie9344aad20651002e98f13cd3adb39680fbd93bd
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
USB battery charging specification defines that device should
not start charging from SDP (or host port) before connecting
i.e. pulling high data line.
Hence, instead of charging immediately after performing detection,
wait till device configuration is selected by host.
Change-Id: I77dd29d1b4fbb57bc2f4362ef77d6a9c73ab6653
CRs-Fixed: 333556
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
vbus power routine can be different based on platform. If vbus power
sequence is provided using platform data(pdata), disconnect of OTG cable
doesn't turn off the VBUS related regulators and required other
interfaces. This issue is seen as vbus_is_on variable remains always zero
for pdata based vbus routine, and msm_hsusb_vbus_power(motg, 0) doesn't
invoke the required vbus power routine. Hence update the vbus_is_on
variable based on return value of pdata based vbus routine. With this
change, it is mandatory that pdata based vbus routine should return the
success/failure result.
CRs-Fixed: 332434
Change-Id: I4c7ce48057f65227b09aac788d0ad24d0f30ed7e
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Till now, we are communicating only the amount of the current that
should be drawn by the PMIC for charging from the OTG driver through
power supply class driver. With this change, we notify the type of the
charger connected as well, so that userspace can benefit for dispalying
the charger type in the UI.
CRs-Fixed: 329868
Change-Id: Ibe92c4450bc9b4b023b9aceab57b624bde39a4fe
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>