20 Jul, 2017
1 commit
-
After the chipidea driver introduce extcon for id and vbus, it's able
to wakeup from another irq source, in case the system with extcon ID
cable, wakeup from usb ID cable and device removal, the usb device
disconnect irq may come firstly before the extcon notifier while system
resume, so we will get 2 "wakeup" irq, one for usb device disconnect;
and one for extcon ID cable change(real wakeup event), current driver
treat them as 2 successive wakeup irq so can't handle it correctly, then
finially the usb irq can't be enabled. This patch adds a check to bypass
further usb events before controller resume finished to fix it.Reviewed-by: Peter Chen
Signed-off-by: Li Jun
14 Jun, 2017
2 commits
-
This patch uses the resource-managed extcon API for extcon_register_notifier()
and replaces the deprecated extcon API as following:
- extcon_get_cable_state_() -> extcon_get_state()Signed-off-by: Chanwoo Choi
Signed-off-by: Peter Chen
(cherry picked from commit 3f991aa0b665c8e9bb702421a4e5005c3588fb62) -
commit 916e43e1d6fb ("MLK-13570-3 usb: chipidea: core: change extcon
usage for imx_4.1.y") is directly cherry-picked from 4.1.y, but which
is not valid anymore on 4.y kernel, so revert most part and only keep
the irq check after resume.Reviewed-by: Peter Chen
Signed-off-by: Li Jun
(cherry picked from commit 9e8e32042df9e0a43574cb222070ec2f1051007d)
09 Jun, 2017
4 commits
-
If there is no UDC available, the msg register will fail and this
flag will not be set, but the driver is already added into pending
driver list, then the module removal modprobe -r can not remove
the driver from the pending list. Next time load the same gadget
driver will generate below kernel panic:root@imx6qdlsolo:~# modprobe g_mass_storage file=/dev/mmcblk3p2 removable=1
[ 125.607920] Unable to handle kernel paging request at virtual address 7f0976f4
[ 125.615282] pgd = a89c4000
[ 125.617999] [7f0976f4] *pgd=a93e0811, *pte=00000000, *ppte=00000000
[ 125.624756] Internal error: Oops: 807 [#1] PREEMPT SMP ARM
[ 125.630247] Modules linked in: g_mass_storage(+) usb_f_mass_storage libcomposite configfs mxc_vadc mxc_dcic mx6s_capture ov5640_camera [last unloaded: configfs]
[ 125.644730] CPU: 0 PID: 841 Comm: modprobe Not tainted 4.9.11-02066-g6c99655 #106
[ 125.652217] Hardware name: Freescale i.MX6 SoloX (Device Tree)
[ 125.658052] task: a8821080 task.stack: a9b8e000
[ 125.662600] PC is at usb_gadget_probe_driver+0x130/0x144
[ 125.667920] LR is at usb_gadget_probe_driver+0x3c/0x144
[ 125.673152] pc : [] lr : [] psr: 600f0013
[ 125.673152] sp : a9b8fde8 ip : 80f44910 fp : 5653cc1c
[ 125.684633] r10: 00000000 r9 : a9ac3400 r8 : 80f448f0
[ 125.689860] r7 : 7f0ce68c r6 : 00000000 r5 : 80f44908 r4 : 00000000
[ 125.696390] r3 : 00000000 r2 : 7f0976f4 r1 : 7f0ce6f4 r0 : 80c8d21c
[ 125.702922] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
[ 125.710060] Control: 10c53c7d Table: a89c404a DAC: 00000051
[ 125.715808] Process modprobe (pid: 841, stack limit = 0xa9b8e210)
[ 125.721904] Stack: (0xa9b8fde8 to 0xa9b90000)
[ 125.726268] fde0: 7f0ce740 7f0d1000 a9ac35c0 7f0ce788 00000001 801017f0
[ 125.734452] fe00: 00000001 8040003e 00000001 8040003f a8fcb600 7f0ce788 abc7e2c0 a9b8e000
[ 125.742636] fe20: 5653cc1c 8040003e abc7e2c0 a9b8e000 a9396740 a8001f00 a9b8fe48 abc7e2c0
[ 125.750821] fe40: a9b8e000 a9396700 a8001f00 a9b8fe60 7f0ce740 a9ac3408 a9ac35c0 7f0ce788
[ 125.759004] fe60: 00000001 a9ac3400 00000001 801b6a24 7f0ce740 7f0ce788 a9b8ff4c a9ac3408
[ 125.767187] fe80: 7f0ce740 8019a658 7f0ce74c 00007fff 7f0ce740 80197fec 7f0ce788 00000000
[ 125.775371] fea0: 7f0ce968 c0e7db20 7f0ce8fc a8fcbb40 a9b8ff3c 000032d4 00000000 80203968
[ 125.783553] fec0: 000032d4 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 125.791735] fee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 125.799918] ff00: 7fffffff 00000000 00000006 01ee1e78 0000017b 7fffffff 00000000 00000000
[ 125.808101] ff20: 01ee23d8 8019af50 7fffffff 00000000 00000003 000032d4 00000000 c0e7c000
[ 125.816284] ff40: 000032d4 00000000 7ecc49cc c0e7c000 000032d4 c0e7d6c0 c0e7d59f c0e7e9d8
[ 125.824467] ff60: 00000968 00000db8 00000000 00000000 00000000 00001328 0000001c 0000001d
[ 125.832650] ff80: 00000011 00000015 0000000a 00000000 01ee1e78 0000001f 00000000 80107a04
[ 125.840833] ffa0: a9b8e000 80107840 01ee1e78 0000001f 00000006 01ee1e78 00000000 00000000
[ 125.849015] ffc0: 01ee1e78 0000001f 00000000 0000017b 01ee1f70 00000000 0000001f 01ee23d8
[ 125.857200] ffe0: 7ecc49d0 7ecc49c0 0001f2e0 76e76e90 60070010 00000006 abf5e861 abf5ec61
[ 125.865397] [] (usb_gadget_probe_driver) from [] (do_one_initcall+0x40/0x170)
[ 125.874286] [] (do_one_initcall) from [] (do_init_module+0x60/0x1c8)
[ 125.882391] [] (do_init_module) from [] (load_module+0x183c/0x1f60)
[ 125.890405] [] (load_module) from [] (SyS_finit_module+0x8c/0x9c)
[ 125.898249] [] (SyS_finit_module) from [] (ret_fast_syscall+0x0/0x3c)
[ 125.906433] Code: e5881024 e587206c e1a04003 e587c068 (e5821000)
[ 125.912995] ---[ end trace bbcab73c5c07119d ]---
Segmentation fault
root@imx6qdlsolo:~#Acked-by: Peter Chen
Signed-off-by: Li Jun -
We only have below cases to disconnect line when suspend:
1. Device mode without connection to any host/charger(no vbus).
2. Device mode connect to a charger(w/ vbus), usb suspend when
system is entering suspend.
This patch can fix usb phy wrongly does disconnect line in case
some usb host enters suspend but vbus is off.Signed-off-by: Li Jun
(cherry picked from commit 2af48913f77cec3658f5863b13f63619d8101279) -
After enters one specific role, notify usb phy driver.
Signed-off-by: Li Jun
(cherry picked from commit d3aa2a13f4e47bc7fae7f2eee1e86291d7513312) -
Enable ID change wakeup for OTG; and VBUS wakeup for OTG and
peripheral only mode.Acked-by: Peter Chen
Signed-off-by: Li Jun
08 Jun, 2017
19 commits
-
The ci_handle_id_switch is called at two places, at very rare situations,
it may be running at the same time. Eg, when the system is back from
the resume, the id event is occurred from extcon driver, as well as
power_lost work item is called due to the controller is poweroff at
the suspend.Signed-off-by: Peter Chen
-
Gadget state is set to be suspended when bus suspened, but not updated
after resume, this patch saves the gadget state before suspend and
restores it after resume.Acked-by: Peter Chen
Signed-off-by: Li Jun -
The ret is assigned as 0, but never changed afterwards, fix this
"Logically dead code" warning.Fixes: 385c47481600 ("usb: chipidea: Only read/write OTGSC from one place")
Signed-off-by: Peter Chen -
After commit 49670184289e ("usb: chipidea: otg: change workqueue
ci_otg as freezable"), we have fixed the bug that ID removed
wakeup (ID: 0->1) will lock up system resume, we delete the
workaround code in this commit.Signed-off-by: Peter Chen
-
When the vbus is off during the suspend controller is powered off, if we
do not want to see disconnection from USB core, we need to make sure the
device pulls DP up before USB core resume runs. However, several devices
are slow to pull DP up when see vbus (maybe it needs vbus to power up
system), so we need to wait connection at platform code.Signed-off-by: Peter Chen
-
For imx7ulp, the power of USB controller may be lost, add power_lost_check
API for USB recovery.Signed-off-by: Peter Chen
-
For all imx Socs later than imx6 (including imx6), the USB_nSBUSCFG.AHBBRST
will be set as 0 at dtsi file, so the non-burst setting needs to be
set at non-core register, or there will be no burst for USB AHB/AXI
transfer.Signed-off-by: Peter Chen
-
At imx7ulp, if the system enters idle, it will close some clocks and affect
USB transfer. In order to avoid it, we request pmqos to avoid system
entering idle when the USB is in use.Signed-off-by: Peter Chen
-
imx7ulp non core register mapping is similar with imx7d, and the
initialization is the same, but lacks of USB charger detection support.Signed-off-by: Peter Chen
-
At v4.1 kernel, we can't get cable type at notifier, but at
extcon-usb-gpio.c notifies both VBUS and ID event, we had to
do special handling for ID event, and omit VBUS event. Current
implementation only supports ID extcon event.If wakeup event occurs by extcon, it needs to call ci_irq again since the
first ci_irq calling at extcon notifier only wakes up controller, but
do noop for event handling.Signed-off-by: Peter Chen
-
At imx7ulp, the USB related analog register is located in PHY register
region too, so we need to control PLL at PHY driver directly.Signed-off-by: Peter Chen
-
The two extcon notifiers are almost the same except for the
variable name for the cable structure and the id notifier inverts
the cable->state logic. Make it the same and replace two
functions with one to save some lines. This also makes it so that
the id cable state is true when the id pin is pulled low, so we
change the name of ->state to ->connected to properly reflect
that we're interested in the cable being connected.Cc: Peter Chen
Cc: Greg Kroah-Hartman
Cc: "Ivan T. Ivanov"
Signed-off-by: Stephen Boyd
Signed-off-by: Peter Chen -
We're currently emulating the vbus and id interrupts in the OTGSC
read API, but we also need to make sure that if we're handling
the events with extcon that we don't enable the interrupts for
those events in the hardware. Therefore, properly emulate this
register if we're using extcon, but don't enable the interrupts.
This allows me to get my cable connect/disconnect working
properly without getting spurious interrupts on my device that
uses an extcon for these two events.Acked-by: Peter Chen
Cc: Greg Kroah-Hartman
Cc: "Ivan T. Ivanov"
Fixes: 3ecb3e09b042 ("usb: chipidea: Use extcon framework for VBUS and ID detect")
Signed-off-by: Stephen Boyd
Signed-off-by: Peter Chen -
With the id and vbus detection done via extcon we need to make
sure we poll the status of OTGSC properly by considering what the
extcon is saying, and not just what the register is saying. Let's
move this hw_wait_reg() function to the only place it's used and
simplify it for polling the OTGSC register. Then we can make
certain we only use the hw_read_otgsc() API to read OTGSC, which
will make sure we properly handle extcon events.Acked-by: Peter Chen
Cc: Greg Kroah-Hartman
Cc: "Ivan T. Ivanov"
Fixes: 3ecb3e09b042 ("usb: chipidea: Use extcon framework for VBUS and ID detect")
Signed-off-by: Stephen Boyd
Signed-off-by: Peter Chen -
For mxs PHY, if there is a vbus but the bus is not enumerated,
force the dp/dm as SE0 from the consider side. If not, there
is possible USB wakeup due to unstable dp/dm, since there is
possible no pull on dp/dm, eg, there is a USB charger on the
port. Note, the vbus event is only occurred at device mode,
and sent by udc driver.Signed-off-by: Peter Chen
-
Add USB PHY event for below situation:
- vbus connect
- vbus disconnect
- gadget driver is enumeratedUSB PHY driver can get the last event after above situation
occurs.Signed-off-by: Peter Chen
-
For imx6ul PHY, when the system enters suspend, its 1p1 is off by default,
that may cause the PHY get inaccurate USB DP/DM value. If the USB wakeup
is enabled at this time, the unexpected wakeup may occur when the system
enters suspend.In this patch, when the vbus is there, we enable weak 1p1 during the PHY
suspend API, in that case, the USB DP/DM will be accurate for USB PHY,
then unexpected usb wakeup will not be occurred, especially for the USB
charger is connected scenario. The user needs to enable PHY wakeup for
USB wakeup function using below setting.echo enabled > /sys/devices/platform/soc/2000000.aips-bus/20c9000.usbphy
/power/wakeupCc: Shaojun Wang
Cc: Anson Huang
Signed-off-by: Peter Chen -
Add HSIC support for imx7d. We have not supported HSIC as system
wakeup as well as HSIC remote wakeup function at DSM mode, since
the 24M OSC can't be off and the SoC internal regulators can't be
off at this mode, that will keep power consumption much higher.Signed-off-by: Peter Chen
-
This piece of code is existed at imx_3.10, but missing at imx_3.14 and
imx_4.1, port it from imx_3.10.Signed-off-by: Peter Chen
23 Feb, 2017
14 commits
-
Fix chipidea usb driver compile warning if CONFIG_USB_CHIPIDEA_HOST
is disabled:
In file included from drivers/usb/chipidea/otg.c:26:0:
drivers/usb/chipidea/host.h:23:13: warning: 'ci_hdrc_host_driver_init'
defined but not used [-Wunused-function]
static void ci_hdrc_host_driver_init(void)
^
CC drivers/usb/chipidea/otg_fsm.o
In file included from drivers/usb/chipidea/otg_fsm.c:34:0:
drivers/usb/chipidea/host.h:23:13: warning: 'ci_hdrc_host_driver_init'
defined but not used [-Wunused-function]
static void ci_hdrc_host_driver_init(void)
^Signed-off-by: Li Jun
-
After we put gadget disconnect and connect in id switch handling,
update power lost work accordingly.Acked-by: Peter Chen
Signed-off-by: Li Jun
(cherry picked from commit fd49596eceeb4e61267f35fb74bf0c04056f2ed7) -
During system sleep, if we switch otg role from gadget to host, and host
vbus is directly controlled by ID signal, we will lose vbus drop event
after resume because the vbus is on both at system suspend and resume, so
we will miss gadget disconnect handling before start host role. This patch
is to fix it by adding gadget disconnect for this case.Acked-by: Peter Chen
Signed-off-by: Li Jun
(cherry picked from commit 79aab6fc3c9fca1fa4f83f25a5050ea4afc90f0a) -
During system sleep, if we switch otg role from host to gadget, because
the vbus is on both at system suspend and resume, we will lose vbus
connect event after system resume, thus, no chance to setup vbus session
for gadget so enumeration will not happen. This patch is to fix it by
adding vbus connect handling for this case.Acked-by: Peter Chen
Signed-off-by: Li Jun
(cherry picked from commit bd54eea0f74c40fd801aa632787f05ec1b7407ea) -
Fix coverity CID 17601 uninitialized scalar variable: vbus_value.
Signed-off-by: Li Jun
-
Move FSL_UTP to be under USB_MASS_STORAGE since it depends on it.
Signed-off-by: Li Jun
-
It is better we disconnect (pulldown dp) host when the system enters
suspend if the host did not suspend bus beforehand, it can avoid
unnecessary udc suspend irq during usb enters suspend. This unexpected
suspend irq occurs due to the udc still pulls up dp, but the host
suspends bus due to it finds the device has disconnected. The device
turns off high speed terminal will be considered a disconnection event
from the host.It also fixes the bug ENGR00325724 describes.
Signed-off-by: Peter Chen
(cherry picked from commit 9d9ddd142cdbfb4bcbaae161a452596668441b1a) -
Check if data->usbmisc_data is NULL before dereference it in probe.
Acked-by: Peter Chen
Signed-off-by: Li Jun -
Dereference data pointer after its NULL check.
Signed-off-by: Li Jun
-
Fix the coverity check complains although there is no function issue
with current code.Signed-off-by: Li Jun
-
In MLK-11272, we introduce a workaround to resolve data pulse detection
IC issue in i.MX7D, but did not disable the term select override after
the A device becomes B device in some cases: a_idle --> enable term
select override --> b_idle, which cause the B device cannot be enumerated
in b_peripheral mode. This patch is to fix it by disable the term select
and data pulse when A device becomes B device.Signed-off-by: Li Jun
(cherry picked from commit 2df52fcaded838a572c2ee8f93d6cc827a2ebc60) -
When the usb in idle, it calls release_bus_req.
When the usb is going to use, it calls request_bus_req.
This is a rework patch of ENGR00286459 and ENGR00286926.Signed-off-by: Peter Chen
Signed-off-by: Li Jun -
LDO2p5 cannot be disabled in low power idle mode when the USB driver
enables VBUS wakeup. To identify when LDO2p5 can be disabled add a dummy
regulator that the USB driver will enable when VBUS wakeup is required.Signed-off-by: Ranjani Vaidyanathan
Signed-off-by: Li Jun -
When allocating large memory, such as 128K,
vmalloc() uses single page for the allocation process,
while kzalloc() has to consume a continuous pages for the allocation.In low memory case, the kzalloc() may fails.
So use the vmalloc() instead.Also add some sanity check for the NULL pointer.
Add missed line for ENGR00161643-3 UTP : bugfix
Signed-off-by: Huang Shijie