Role switch issue with iMX6UL

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Role switch issue with iMX6UL

3,162 Views
ranjan_kumar
Contributor I

Hi,

We are using iMX6UL and using usb1 as otg port to connect to Apple device.I have enabled hnp and srp in device tree.We are trying to achieve role switch on usb1 port .Host to device is happening and we are able communicate with apple device.But when communication is not happening on usb1 then we want role switch to happen from Device to host and iMX should start charging Apple device.It is showing role switch has happened to Host mode

 cat /sys/kernel/debug/ci_hdrc.0/role -> Host

But the problem is Apple device is not getting charged or more specific Apple device is not getting enumerated on iMX side.

We are using Linux 4.9.11 version . Can any body have any patch or solution to this problem.

UART2 Serial Port Initializing

  Module Controller UARTt port tymxc1 Opened Successfully
  Bau
 len 35
dRate = 115200
using random self ethernet address

  Parity   = noneStarting Module Controller Read thread
 Starting Module Controller Send Command thread
 Moodule controller UART Init End
initTransducerDetectionSystem Entry
 Test Writusing random host ethernet address
e function testing

 iap_host_register_device_ready_callback called

iAP2_Host_bfnHostInitiusb0: HOST MAC b2:43:27:12:8e:80
alization called
iAP2_Host_bfnHostInitialization start
iAP2_Host_SetConfig start
  using hiddev: /dev/usb/hiddev0
  using i2cdev: /dev/i2c-1
  using i2caddrusb0: MAC 22:73:55:4b:40:80
: 17

 Open /dev/mfi-ffs/ep0
g_ffs gadget: g_ffs ready

 Send USB descriptors

 Send USB strings
  UART2 Read Thread Entry

 Allocate buffer for endpoint
 CREATED [ep0_thread] SUCCESSFULLY.
ep0_thread_function(): EVENT BIND
VID: 0x5ac
PID: 0x12ab
USB Apple Device Detected

 usb_mfi_request_role_switch

  iAP2_USB_Device : Send role switch USB request using received value
usb 1-1: USB disconnect, device number 2
Debug: Closing libusb ci_hdrc ci_hdrc.0: remove, state 1

usb usb1: USB disconnect, device number 1

Debug: Switching to device mode
ci_hdrc ci_hdrc.0: USB bus 1 deregistered
USB MFI role switch status: 0

Starting iAP_USBDev_init_usb_gffs_device

oen FFS_OUT /dev/mfi-ffs/ep1 12

oen FFS_IN /dev/mfi-ffs/ep2 13

oen FFS_NATIVE_OUT /dev/mfi-ffs/ep3 14

oen FFS_NATIVE_IN /dev/mfi-ffs/ep4 15
iAP2_Host_vfStateMachineDriver start

iAP_USBDev_read_thread_native started

iap_usb_device_read_native_enable 1

iAP_USBDev_read_thread started
g_ffs gadget: high-speed config #1: FunctionFS + NCM
ep0_thread_function(): EVENT ENABLE
  iAP2_Link_vfnSendSyncPayload
iAP2_Sessions_vfnStateMachine started
iAP2_Link_vfnTask start
iAP_Auth_vfnStateMachine started

 iAP2_Link_vfnReleaseMemReqId 0
iAP Host Initialization completeci_hdrc ci_hdrc.0: EHCI Host Controller


Inside IF block of main app

 Inside transducer_charger_checkInside IF block of ChargerDetectionThread
 SWITCHING TO USB HOST MODE..
ERROR: iAP_USBDev_read_native, errno: 108 ret -1
ep0_thread_function(): EVENT DISABLE
SWITCHING TO USB HOST MODE..
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: EHCI Host Controller
usb usb1: Manufacturer: Linux 4.9.11-02215-g5aba4a9 ehci_hcd
usb usb1: SerialNumber: ci_hdrc.0
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
USB BOARD SET TO HOST MODE.
ep0_thread_function. ENDED

Waiting for reply.

Thanks and Regards

Ranjan

Labels (4)
0 Kudos
4 Replies

2,610 Views
abdulredwan
Contributor III

Hi @ranjan_kumar @igorpadykov ,

We are using chipidea controller's usbotg1 of imx8qm mek board where we could send roleswitch command to iphone (from gadget to host) and switching MEK to gadget but then we lose vbus (as expected). We are trying to enable vbus through soft_connect without any luck

getting error logs as "soft-connect without a gadget driver" also ci_hdrc.0 device no response

Any pointers will be very much appreciated

0 Kudos

2,767 Views
igorpadykov
NXP Employee
NXP Employee

Hi Ranjan

one can check linux documentation, also patch was sent you via mail.

chipidea.txt\usb\Documentation - linux-imx - i.MX Linux kernel 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,693 Views
emb-vikapat
Contributor II

Hello Igor,

We are facing same issue on IMX8QM MEK board, with usbotg1 which is located on base board and using same driver(chipidea).

Do you guys have specific patch for IMX8QM MEK?

If you have any information please help me with that.

 

Thanks,

Vikas

0 Kudos

2,767 Views
ranjan_kumar
Contributor I

Hi Igor,

Thanks for the patch. After applying the patch role switch is happening .As as per the log given below

Module Controller UARTt port tymxc1 Opened Successfully
  BaudRate = 115200
  StopBits = 1
  Parity   = noneStarting Module Controller Read thread
 Starting Module Controller Send Command thread
 Moodule controller UART Init End
initTransducerDetectionSystem Entry
 Command sent to UART MC
 UART2 Read Thread Entry
Initializing packet manager from pid 200 Test Write function testing

 iap_host_register_devic
 len 35
e_ready_callback called

iAP2_using random self ethernet address
Host_bfnHostInitialization called
iAP2_Host_bfnHostInitializatiousing random host ethernet address
n start
iAP2_Host_SetConfig start
  using hiddev: /dev/usb/hiddusb0: HOST MAC 8e:73:9f:1d:b7:fd
ev0
  using i2cdev: /dev/i2c-1
  using i2caddr: 17

 Open /dev/mfi-ffs/ep0

 Send USB descriptors

usb0: MAC 7e:59:29:de:1b:c8

g_ffs gadget: g_ffs ready

 Allocate buffer for endpoint
 CREATED [ep0_thread] SUCCESSFULLY.
ep0_thread_function(): EVENT BIND
VID: 0x5ac
PID: 0x12ab
USB Apple Device Detected

 usb_mfi_request_role_switch

  iAP2_USB_Device : Send role switch USB request using received value
usb 1-1: USB disconnect, device number 2
Debug: Closing libusb ci_hdrc ci_hdrc.0: remove, state 1

usb usb1: USB disconnect, device number 1

Debug: Switching to device mode
Bytes received from Moudule Controller UART = 17
ci_hdrc ci_hdrc.0: USB bus 1 deregistered
USB MFI role switch status: 0

---------------------

But when i am doing role switch it is showing role switching is happening from gadget to Host. As  Imx6 is in host mode it should enumerate Apple again after role switch as Imx6 is host and Apple is in device mode.But the enumeration is not happening. Do you have any idea where exactly the vbus is getting disable while going from gadget to Host.

I am putting the log below.

root@imx6ulevk:~# cat /sys/bus/platform/devices/ci_hdrc.0/role
Ranjan inside ci_role_show role : host
host
root@imx6ulevk:~# echo gadget >  /sys/bus/platform/devices/ci_hdrc.0/role
ci_hdrc ci_hdrc.0: remove, state 4
usb usb1: USB disconnect, device number 1
ci_hdrc ci_hdrc.0: USB bus 1 deregistered
Ranjan Inside ci_role_store IF block
root@imx6ulevk:~# cat /sys/bus/platform/devices/ci_hdrc.0/role
Ranjan inside ci_role_show role : gadget
gadget
root@imx6ulevk:~# echo host >  /sys/bus/platform/devices/ci_ci_hdrc ci_hdrc.0: EHCI Host Controller
hdrc.0/role
ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: EHCI Host Controller
usb usb1: Manufacturer: Linux 4.9.11-02216-gfff505b-dirty ehci_hcd
usb usb1: SerialNumber: ci_hdrc.0
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected

-------

As you can see while doing role switch device-> host  ,apple device not showing.

Please provide any input.

Waiting for your response.

Thanks and Regards

Ranjan

0 Kudos