1                       Universal Flash Storage
2                       =======================
3
4
5Contents
6--------
7
81. Overview
92. UFS Architecture Overview
10  2.1 Application Layer
11  2.2 UFS Transport Protocol(UTP) layer
12  2.3 UFS Interconnect(UIC) Layer
133. UFSHCD Overview
14  3.1 UFS controller initialization
15  3.2 UTP Transfer requests
16  3.3 UFS error handling
17  3.4 SCSI Error handling
18
19
201. Overview
21-----------
22
23Universal Flash Storage(UFS) is a storage specification for flash devices.
24It is aimed to provide a universal storage interface for both
25embedded and removable flash memory based storage in mobile
26devices such as smart phones and tablet computers. The specification
27is defined by JEDEC Solid State Technology Association. UFS is based
28on MIPI M-PHY physical layer standard. UFS uses MIPI M-PHY as the
29physical layer and MIPI Unipro as the link layer.
30
31The main goals of UFS is to provide,
32 * Optimized performance:
33   For UFS version 1.0 and 1.1 the target performance is as follows,
34   Support for Gear1 is mandatory (rate A: 1248Mbps, rate B: 1457.6Mbps)
35   Support for Gear2 is optional (rate A: 2496Mbps, rate B: 2915.2Mbps)
36   Future version of the standard,
37   Gear3 (rate A: 4992Mbps, rate B: 5830.4Mbps)
38 * Low power consumption
39 * High random IOPs and low latency
40
41
422. UFS Architecture Overview
43----------------------------
44
45UFS has a layered communication architecture which is based on SCSI
46SAM-5 architectural model.
47
48UFS communication architecture consists of following layers,
49
502.1 Application Layer
51
52  The Application layer is composed of UFS command set layer(UCS),
53  Task Manager and Device manager. The UFS interface is designed to be
54  protocol agnostic, however SCSI has been selected as a baseline
55  protocol for versions 1.0 and 1.1 of UFS protocol  layer.
56  UFS supports subset of SCSI commands defined by SPC-4 and SBC-3.
57  * UCS: It handles SCSI commands supported by UFS specification.
58  * Task manager: It handles task management functions defined by the
59     UFS which are meant for command queue control.
60  * Device manager: It handles device level operations and device
61     configuration operations. Device level operations mainly involve
62     device power management operations and commands to Interconnect
63     layers. Device level configurations involve handling of query
64     requests which are used to modify and retrieve configuration
65     information of the device.
66
672.2 UFS Transport Protocol(UTP) layer
68
69  UTP layer provides services for
70  the higher layers through Service Access Points. UTP defines 3
71  service access points for higher layers.
72  * UDM_SAP: Device manager service access point is exposed to device
73    manager for device level operations. These device level operations
74    are done through query requests.
75  * UTP_CMD_SAP: Command service access point is exposed to UFS command
76    set layer(UCS) to transport commands.
77  * UTP_TM_SAP: Task management service access point is exposed to task
78    manager to transport task management functions.
79  UTP transports messages through UFS protocol information unit(UPIU).
80
812.3 UFS Interconnect(UIC) Layer
82
83  UIC is the lowest layer of UFS layered architecture. It handles
84  connection between UFS host and UFS device. UIC consists of
85  MIPI UniPro and MIPI M-PHY. UIC provides 2 service access points
86  to upper layer,
87  * UIC_SAP: To transport UPIU between UFS host and UFS device.
88  * UIO_SAP: To issue commands to Unipro layers.
89
90
913. UFSHCD Overview
92------------------
93
94The UFS host controller driver is based on Linux SCSI Framework.
95UFSHCD is a low level device driver which acts as an interface between
96SCSI Midlayer and PCIe based UFS host controllers.
97
98The current UFSHCD implementation supports following functionality,
99
1003.1 UFS controller initialization
101
102  The initialization module brings UFS host controller to active state
103  and prepares the controller to transfer commands/response between
104  UFSHCD and UFS device.
105
1063.2 UTP Transfer requests
107
108  Transfer request handling module of UFSHCD receives SCSI commands
109  from SCSI Midlayer, forms UPIUs and issues the UPIUs to UFS Host
110  controller. Also, the module decodes, responses received from UFS
111  host controller in the form of UPIUs and intimates the SCSI Midlayer
112  of the status of the command.
113
1143.3 UFS error handling
115
116  Error handling module handles Host controller fatal errors,
117  Device fatal errors and UIC interconnect layer related errors.
118
1193.4 SCSI Error handling
120
121  This is done through UFSHCD SCSI error handling routines registered
122  with SCSI Midlayer. Examples of some of the error handling commands
123  issues by SCSI Midlayer are Abort task, Lun reset and host reset.
124  UFSHCD Routines to perform these tasks are registered with
125  SCSI Midlayer through .eh_abort_handler, .eh_device_reset_handler and
126  .eh_host_reset_handler.
127
128In this version of UFSHCD Query requests and power management
129functionality are not implemented.
130
131UFS Specifications can be found at,
132UFS - http://www.jedec.org/sites/default/files/docs/JESD220.pdf
133UFSHCI - http://www.jedec.org/sites/default/files/docs/JESD223.pdf
134