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

    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)

    Chanwoo Choi
     
  • 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)

    Li Jun
     

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

    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)

    Li Jun
     
  • After enters one specific role, notify usb phy driver.

    Signed-off-by: Li Jun
    (cherry picked from commit d3aa2a13f4e47bc7fae7f2eee1e86291d7513312)

    Li Jun
     
  • Enable ID change wakeup for OTG; and VBUS wakeup for OTG and
    peripheral only mode.

    Acked-by: Peter Chen
    Signed-off-by: Li Jun

    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

    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

    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

    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

    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

    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

    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

    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

    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

    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

    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

    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

    Stephen Boyd
     
  • 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

    Stephen Boyd
     
  • 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

    Stephen Boyd
     
  • 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

    Peter Chen
     
  • Add USB PHY event for below situation:
    - vbus connect
    - vbus disconnect
    - gadget driver is enumerated

    USB PHY driver can get the last event after above situation
    occurs.

    Signed-off-by: Peter Chen

    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/wakeup

    Cc: Shaojun Wang
    Cc: Anson Huang
    Signed-off-by: Peter Chen

    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

    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

    Peter Chen
     

23 Feb, 2017

14 commits