Pavankumar Kondeti | f35ab2a | 2013-11-08 20:16:57 +0530 | [diff] [blame] | 1 | Introduction |
| 2 | ============ |
| 3 | |
| 4 | This feature requires supporting Mass Storage and Integrated Circuit Card |
| 5 | interfaces exposed by the UICC (Universal Integrated Circuit Card) device. |
| 6 | The MSM acts as a USB host and UICC acts as a peripheral. The UICC device |
| 7 | that is used here is also referred to as Mega-SIM. This feature will be |
| 8 | supported on MSM8x26. |
| 9 | |
| 10 | Hardware description |
| 11 | ==================== |
| 12 | |
| 13 | The USB3503 HSIC (High Speed Inter Chip) hub's down stream port is modified |
| 14 | to support Inter-Chip USB for connecting the UICC device. The USB3503 is |
| 15 | connected to MSM via HSIC interface. The UICC device operates in Full Speed |
| 16 | mode. |
| 17 | |
| 18 | The UICC device will support CCID (Integrated Circuit Card interface Device) |
| 19 | specification. This interface supports 1 Bulk In, 1 Bulk Out and 1 Interrupt |
| 20 | endpoint. The Interrupt endpoint is used by the device to send asynchronous |
| 21 | notifications like card insertion/removal and hardware error events. |
| 22 | The Bulk endpoints are used for the data communication. |
| 23 | |
| 24 | The UICC device will support the Mass Storage Bulk Only 1.0 specification. |
| 25 | It supports SCSI Transparent subclass '06', corresponding to support of the |
| 26 | SCSI Primary Command set. It implements SCSI Peripheral Device Type '00' |
| 27 | (TYPE_DISK) corresponding to a direct access SCSI block device. |
| 28 | |
| 29 | Software description |
| 30 | ==================== |
| 31 | |
| 32 | The MSM HSIC controller driver(drivers/usb/host/ehci-msm-hsic.c) takes care |
| 33 | of HSIC PHY and link management. The USB3503 HSIC hub is managed by the SMSC |
| 34 | hub driver(drivers/misc/smsc_hubc.c). Both these drivers are well tested on |
| 35 | APQ8074 dragon board and are re-used to support this feature. |
| 36 | |
| 37 | The mass storage interface is managed by the standard Linux USB storage driver. |
| 38 | This driver interfaces with SCSI and block layers to export the disk to |
| 39 | user space. |
| 40 | |
| 41 | A new USB driver is implemented to manage the CCID interface. This driver is |
| 42 | referred to as USB CCID driver in this document. This driver is implemented |
| 43 | as a pass-through module and provides the character device interface to |
| 44 | user space. The CCID specification is implemented in the user space. |
| 45 | |
| 46 | The CCID command and responses are exchanged over the Bulk endpoints. The |
| 47 | user space application uses write() and read() calls to send commands and |
| 48 | receive responses. |
| 49 | |
| 50 | The CCID class specific requests are sent over the control endpoint. As |
| 51 | control requests have a specific format, ioctls are implemented. |
| 52 | |
| 53 | The UICC device sends asynchronous notifications over the interrupt endpoint. |
| 54 | The card insertion/removal and hardware error events are sent to user space |
| 55 | via an ioctl(). |
| 56 | |
| 57 | Design Goals: |
| 58 | ============ |
| 59 | |
| 60 | 1. Re-use the existing services available in user space. This is achieved |
| 61 | by implementing the kernel USB CCID driver as a pass-through module. |
| 62 | |
| 63 | 2. Support runtime card insertion/removal. |
| 64 | |
| 65 | 3. Support runtime power management. |
| 66 | |
| 67 | 4. Support Multiple card configuration. More than 1 IC can be connected to |
| 68 | the USB UICC device. |
| 69 | |
| 70 | Power Management |
| 71 | ================ |
| 72 | |
| 73 | The USB core uses the runtime PM framework to auto suspend the USB devices that |
| 74 | are not in use. The Auto-suspend is forbidden for all devices except hub class |
| 75 | devices. The USB CCID driver enables auto-suspend for the UICC device. |
| 76 | |
| 77 | An USB device can be suspended only when all of its interfaces are suspended. |
| 78 | The USB storage interface device acts as a parent device to the underlying |
| 79 | SCSI host, target and block devices. Runtime PM must be enabled for the |
| 80 | SCSI device to allow USB storage interface suspend. The SCSI device runtime |
| 81 | suspend and auto-suspend timeout will be configured from user space via sysfs |
| 82 | files. |
| 83 | |
| 84 | The HSIC platform device and USB3503 HUB device will be runtime suspended |
| 85 | only after the USB UICC device is suspended. |
| 86 | |
| 87 | SMP/multi-core |
| 88 | ============== |
| 89 | |
| 90 | The USB CCID driver does not allow multiple clients to open the device file |
| 91 | concurrently. -EBUSY will be returned if open() is attempted when the |
| 92 | file is already opened. |
| 93 | |
| 94 | The write() and read() methods are implemented synchronously. If another |
| 95 | write() is called when a previous write() is in progress, -EBUSY is |
| 96 | returned. The same is applicable to read(). |
| 97 | |
| 98 | Mutexes will be used to prevent concurrent open(), read() and write() access. |
| 99 | |
| 100 | Interface |
| 101 | ========= |
| 102 | |
| 103 | A character device file (/dev/ccid_bridge) will be exposed by the USB CCID |
| 104 | driver. open(), read(), write(), ioctl() and close() methods are implemented. |
| 105 | This device node is accessible only to the root by default. User space init |
| 106 | or udev scripts should change the permissions of this device file if it needs |
| 107 | to be accessed by non-root applications. |
| 108 | |
| 109 | open(): The open() is blocked until the UICC device is detected and the CCID |
| 110 | interface probe is completed. Returns the appropriate error code in case of |
| 111 | failure. |
| 112 | |
| 113 | read(): An URB is submitted on the Bulk In endpoint. The read() is blocked |
| 114 | until the URB is completed and the data is copied to the user space buffer |
| 115 | upon success. An appropriate error code is returned in case of failure. |
| 116 | -ENODEV must be treated as a serious error and no further I/O will be |
| 117 | attempted. |
| 118 | |
| 119 | write(): An URB is submitted on the Bulk Out endpoint. The write() is blocked |
| 120 | until the URB is completed. An appropriate error code is returned in case of |
| 121 | failure. -ENODEV must be treated as a serious error and no further I/O will be |
| 122 | attempted. |
| 123 | |
| 124 | ioctl(): The ioctl() method is required for facilitating Control transfers and |
| 125 | Interrupt transfers. |
| 126 | |
| 127 | USB_CCID_GET_CLASS_DESC: This read-only ioctl returns the smart card class |
| 128 | descriptor as described in the 5.1 section of USB smart card class spec. |
| 129 | |
| 130 | USB_CCID_ABORT: This write-only ioctl sends A ABORT class specific request on |
| 131 | control endpoint. The class request details are mentioned in section 5.3.1. |
| 132 | |
| 133 | USB_CCID_GET_CLOCK_FREQUENCIES: This read and write ioctl returns the clock |
| 134 | frequencies supported by the CCID device. A GET_CLOCK_FREQUENCIES class request |
| 135 | is sent on the control endpoint. The class request details are mentioned in |
| 136 | section 5.3.2. |
| 137 | |
| 138 | USB_CCID_GET_DATA_RATES: This read and write ioctl returns the data rates |
| 139 | supported by the CCID device. A GET_DATA_RATES class request is sent on the |
| 140 | control endpoint. The class request details are mentioned in section 5.3.3. |
| 141 | |
| 142 | USB_CCID_GET_EVENT: This read-only ioctl returns the asynchronous event sent |
| 143 | by the UICC device. The ioctl() is blocked until such event is received from |
| 144 | the UICC device. This ioctl() returns -ENOENT error code when the device |
| 145 | does not have an interrupt endpoint and does not support remote wakeup |
| 146 | capability. |
| 147 | |
| 148 | close(): Cancels any ongoing I/O before it returns. |
| 149 | |
| 150 | Config options |
| 151 | ============== |
| 152 | |
| 153 | Turn on USB_EHCI_MSM_HSIC, USB_HSIC_SMSC_HUB and USB_CCID_BRIDGE configs to |
| 154 | enable this feature. |
| 155 | |
| 156 | References |
| 157 | ========== |
| 158 | |
| 159 | Specification for Integrated Circuit(s) Cards Interface Devices |
| 160 | |
| 161 | Smart Cards; UICC-Terminal interface; Physical and logical characteristics |