1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun.. include:: <isonum.txt> 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun================ 6*4882a593SmuzhiyunUsing Linux CAIF 7*4882a593Smuzhiyun================ 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun:Copyright: |copy| ST-Ericsson AB 2010 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun:Author: Sjur Brendeland/ sjur.brandeland@stericsson.com 13*4882a593Smuzhiyun 14*4882a593SmuzhiyunStart 15*4882a593Smuzhiyun===== 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunIf you have compiled CAIF for modules do:: 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun $modprobe crc_ccitt 20*4882a593Smuzhiyun $modprobe caif 21*4882a593Smuzhiyun $modprobe caif_socket 22*4882a593Smuzhiyun $modprobe chnl_net 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunPreparing the setup with a STE modem 26*4882a593Smuzhiyun==================================== 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunIf you are working on integration of CAIF you should make sure 29*4882a593Smuzhiyunthat the kernel is built with module support. 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunThere are some things that need to be tweaked to get the host TTY correctly 32*4882a593Smuzhiyunset up to talk to the modem. 33*4882a593SmuzhiyunSince the CAIF stack is running in the kernel and we want to use the existing 34*4882a593SmuzhiyunTTY, we are installing our physical serial driver as a line discipline above 35*4882a593Smuzhiyunthe TTY device. 36*4882a593Smuzhiyun 37*4882a593SmuzhiyunTo achieve this we need to install the N_CAIF ldisc from user space. 38*4882a593SmuzhiyunThe benefit is that we can hook up to any TTY. 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunThe use of Start-of-frame-extension (STX) must also be set as 41*4882a593Smuzhiyunmodule parameter "ser_use_stx". 42*4882a593Smuzhiyun 43*4882a593SmuzhiyunNormally Frame Checksum is always used on UART, but this is also provided as a 44*4882a593Smuzhiyunmodule parameter "ser_use_fcs". 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun:: 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun $ modprobe caif_serial ser_ttyname=/dev/ttyS0 ser_use_stx=yes 49*4882a593Smuzhiyun $ ifconfig caif_ttyS0 up 50*4882a593Smuzhiyun 51*4882a593SmuzhiyunPLEASE NOTE: 52*4882a593Smuzhiyun There is a limitation in Android shell. 53*4882a593Smuzhiyun It only accepts one argument to insmod/modprobe! 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunTrouble shooting 56*4882a593Smuzhiyun================ 57*4882a593Smuzhiyun 58*4882a593SmuzhiyunThere are debugfs parameters provided for serial communication. 59*4882a593Smuzhiyun/sys/kernel/debug/caif_serial/<tty-name>/ 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun* ser_state: Prints the bit-mask status where 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun - 0x02 means SENDING, this is a transient state. 64*4882a593Smuzhiyun - 0x10 means FLOW_OFF_SENT, i.e. the previous frame has not been sent 65*4882a593Smuzhiyun and is blocking further send operation. Flow OFF has been propagated 66*4882a593Smuzhiyun to all CAIF Channels using this TTY. 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun* tty_status: Prints the bit-mask tty status information 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun - 0x01 - tty->warned is on. 71*4882a593Smuzhiyun - 0x02 - tty->low_latency is on. 72*4882a593Smuzhiyun - 0x04 - tty->packed is on. 73*4882a593Smuzhiyun - 0x08 - tty->flow_stopped is on. 74*4882a593Smuzhiyun - 0x10 - tty->hw_stopped is on. 75*4882a593Smuzhiyun - 0x20 - tty->stopped is on. 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun* last_tx_msg: Binary blob Prints the last transmitted frame. 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun This can be printed with:: 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun $od --format=x1 /sys/kernel/debug/caif_serial/<tty>/last_rx_msg. 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun The first two tx messages sent look like this. Note: The initial 84*4882a593Smuzhiyun byte 02 is start of frame extension (STX) used for re-syncing 85*4882a593Smuzhiyun upon errors. 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun - Enumeration:: 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun 0000000 02 05 00 00 03 01 d2 02 90*4882a593Smuzhiyun | | | | | | 91*4882a593Smuzhiyun STX(1) | | | | 92*4882a593Smuzhiyun Length(2)| | | 93*4882a593Smuzhiyun Control Channel(1) 94*4882a593Smuzhiyun Command:Enumeration(1) 95*4882a593Smuzhiyun Link-ID(1) 96*4882a593Smuzhiyun Checksum(2) 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun - Channel Setup:: 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun 0000000 02 07 00 00 00 21 a1 00 48 df 101*4882a593Smuzhiyun | | | | | | | | 102*4882a593Smuzhiyun STX(1) | | | | | | 103*4882a593Smuzhiyun Length(2)| | | | | 104*4882a593Smuzhiyun Control Channel(1) 105*4882a593Smuzhiyun Command:Channel Setup(1) 106*4882a593Smuzhiyun Channel Type(1) 107*4882a593Smuzhiyun Priority and Link-ID(1) 108*4882a593Smuzhiyun Endpoint(1) 109*4882a593Smuzhiyun Checksum(2) 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun* last_rx_msg: Prints the last transmitted frame. 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun The RX messages for LinkSetup look almost identical but they have the 114*4882a593Smuzhiyun bit 0x20 set in the command bit, and Channel Setup has added one byte 115*4882a593Smuzhiyun before Checksum containing Channel ID. 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun NOTE: 118*4882a593Smuzhiyun Several CAIF Messages might be concatenated. The maximum debug 119*4882a593Smuzhiyun buffer size is 128 bytes. 120*4882a593Smuzhiyun 121*4882a593SmuzhiyunError Scenarios 122*4882a593Smuzhiyun=============== 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun- last_tx_msg contains channel setup message and last_rx_msg is empty -> 125*4882a593Smuzhiyun The host seems to be able to send over the UART, at least the CAIF ldisc get 126*4882a593Smuzhiyun notified that sending is completed. 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun- last_tx_msg contains enumeration message and last_rx_msg is empty -> 129*4882a593Smuzhiyun The host is not able to send the message from UART, the tty has not been 130*4882a593Smuzhiyun able to complete the transmit operation. 131*4882a593Smuzhiyun 132*4882a593Smuzhiyun- if /sys/kernel/debug/caif_serial/<tty>/tty_status is non-zero there 133*4882a593Smuzhiyun might be problems transmitting over UART. 134*4882a593Smuzhiyun 135*4882a593Smuzhiyun E.g. host and modem wiring is not correct you will typically see 136*4882a593Smuzhiyun tty_status = 0x10 (hw_stopped) and ser_state = 0x10 (FLOW_OFF_SENT). 137*4882a593Smuzhiyun 138*4882a593Smuzhiyun You will probably see the enumeration message in last_tx_message 139*4882a593Smuzhiyun and empty last_rx_message. 140