Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a3e97b0 authored by Santosh Yaraganavi's avatar Santosh Yaraganavi Committed by James Bottomley
Browse files

[SCSI] ufshcd: UFS Host controller driver



This patch adds support for Universal Flash Storage(UFS)
host controllers. The UFS host controller driver
includes host controller initialization method.

The Initialization process involves following steps:
 - Initiate UFS Host Controller initialization process by writing
   to Host controller enable register
 - Configure UFS Host controller registers with host memory space
   datastructure offsets.
 - Unipro link startup procedure
 - Check for connected device
 - Configure UFS host controller to process requests
 - Enable required interrupts
 - Configure interrupt aggregation

[jejb: fix warnings in 32 bit compile]
Signed-off-by: default avatarSantosh Yaraganavi <santoshsy@gmail.com>
Signed-off-by: default avatarVinayak Holikatti <vinholikatti@gmail.com>
Reviewed-by: default avatarArnd Bergmann <arnd@linaro.org>
Reviewed-by: default avatarVishak G <vishak.g@samsung.com>
Reviewed-by: default avatarGirish K S <girish.shivananjappa@linaro.org>
Reviewed-by: default avatarNamjae Jeon <linkinjeon@gmail.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 0bd7f842
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -94,3 +94,5 @@ sym53c8xx_2.txt
	- info on second generation driver for sym53c8xx based adapters
tmscsim.txt
	- info on driver for AM53c974 based adapters
ufs.txt
	- info on Universal Flash Storage(UFS) and UFS host controller driver.
+133 −0
Original line number Diff line number Diff line
                       Universal Flash Storage
                       =======================


Contents
--------

1. Overview
2. UFS Architecture Overview
  2.1 Application Layer
  2.2 UFS Transport Protocol(UTP) layer
  2.3 UFS Interconnect(UIC) Layer
3. UFSHCD Overview
  3.1 UFS controller initialization
  3.2 UTP Transfer requests
  3.3 UFS error handling
  3.4 SCSI Error handling


1. Overview
-----------

Universal Flash Storage(UFS) is a storage specification for flash devices.
It is aimed to provide a universal storage interface for both
embedded and removable flash memory based storage in mobile
devices such as smart phones and tablet computers. The specification
is defined by JEDEC Solid State Technology Association. UFS is based
on MIPI M-PHY physical layer standard. UFS uses MIPI M-PHY as the
physical layer and MIPI Unipro as the link layer.

The main goals of UFS is to provide,
 * Optimized performance:
   For UFS version 1.0 and 1.1 the target performance is as follows,
   Support for Gear1 is mandatory (rate A: 1248Mbps, rate B: 1457.6Mbps)
   Support for Gear2 is optional (rate A: 2496Mbps, rate B: 2915.2Mbps)
   Future version of the standard,
   Gear3 (rate A: 4992Mbps, rate B: 5830.4Mbps)
 * Low power consumption
 * High random IOPs and low latency


2. UFS Architecture Overview
----------------------------

UFS has a layered communication architecture which is based on SCSI
SAM-5 architectural model.

UFS communication architecture consists of following layers,

2.1 Application Layer

  The Application layer is composed of UFS command set layer(UCS),
  Task Manager and Device manager. The UFS interface is designed to be
  protocol agnostic, however SCSI has been selected as a baseline
  protocol for versions 1.0 and 1.1 of UFS protocol  layer.
  UFS supports subset of SCSI commands defined by SPC-4 and SBC-3.
  * UCS: It handles SCSI commands supported by UFS specification.
  * Task manager: It handles task management functions defined by the
     UFS which are meant for command queue control.
  * Device manager: It handles device level operations and device
     configuration operations. Device level operations mainly involve
     device power management operations and commands to Interconnect
     layers. Device level configurations involve handling of query
     requests which are used to modify and retrieve configuration
     information of the device.

2.2 UFS Transport Protocol(UTP) layer

  UTP layer provides services for
  the higher layers through Service Access Points. UTP defines 3
  service access points for higher layers.
  * UDM_SAP: Device manager service access point is exposed to device
    manager for device level operations. These device level operations
    are done through query requests.
  * UTP_CMD_SAP: Command service access point is exposed to UFS command
    set layer(UCS) to transport commands.
  * UTP_TM_SAP: Task management service access point is exposed to task
    manager to transport task management functions.
  UTP transports messages through UFS protocol information unit(UPIU).

2.3 UFS Interconnect(UIC) Layer

  UIC is the lowest layer of UFS layered architecture. It handles
  connection between UFS host and UFS device. UIC consists of
  MIPI UniPro and MIPI M-PHY. UIC provides 2 service access points
  to upper layer,
  * UIC_SAP: To transport UPIU between UFS host and UFS device.
  * UIO_SAP: To issue commands to Unipro layers.


3. UFSHCD Overview
------------------

The UFS host controller driver is based on Linux SCSI Framework.
UFSHCD is a low level device driver which acts as an interface between
SCSI Midlayer and PCIe based UFS host controllers.

The current UFSHCD implementation supports following functionality,

3.1 UFS controller initialization

  The initialization module brings UFS host controller to active state
  and prepares the controller to transfer commands/response between
  UFSHCD and UFS device.

3.2 UTP Transfer requests

  Transfer request handling module of UFSHCD receives SCSI commands
  from SCSI Midlayer, forms UPIUs and issues the UPIUs to UFS Host
  controller. Also, the module decodes, responses received from UFS
  host controller in the form of UPIUs and intimates the SCSI Midlayer
  of the status of the command.

3.3 UFS error handling

  Error handling module handles Host controller fatal errors,
  Device fatal errors and UIC interconnect layer related errors.

3.4 SCSI Error handling

  This is done through UFSHCD SCSI error handling routines registered
  with SCSI Midlayer. Examples of some of the error handling commands
  issues by SCSI Midlayer are Abort task, Lun reset and host reset.
  UFSHCD Routines to perform these tasks are registered with
  SCSI Midlayer through .eh_abort_handler, .eh_device_reset_handler and
  .eh_host_reset_handler.

In this version of UFSHCD Query requests and power management
functionality are not implemented.

UFS Specifications can be found at,
UFS - http://www.jedec.org/sites/default/files/docs/JESD220.pdf
UFSHCI - http://www.jedec.org/sites/default/files/docs/JESD223.pdf
+1 −0
Original line number Diff line number Diff line
@@ -619,6 +619,7 @@ config SCSI_ARCMSR

source "drivers/scsi/megaraid/Kconfig.megaraid"
source "drivers/scsi/mpt2sas/Kconfig"
source "drivers/scsi/ufs/Kconfig"

config SCSI_HPTIOP
	tristate "HighPoint RocketRAID 3xxx/4xxx Controller support"
+1 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ obj-$(CONFIG_MEGARAID_LEGACY) += megaraid.o
obj-$(CONFIG_MEGARAID_NEWGEN)	+= megaraid/
obj-$(CONFIG_MEGARAID_SAS)	+= megaraid/
obj-$(CONFIG_SCSI_MPT2SAS)	+= mpt2sas/
obj-$(CONFIG_SCSI_UFSHCD)	+= ufs/
obj-$(CONFIG_SCSI_ACARD)	+= atp870u.o
obj-$(CONFIG_SCSI_SUNESP)	+= esp_scsi.o	sun_esp.o
obj-$(CONFIG_SCSI_GDTH)		+= gdth.o
+49 −0
Original line number Diff line number Diff line
#
# Kernel configuration file for the UFS Host Controller
#
# This code is based on drivers/scsi/ufs/Kconfig
# Copyright (C) 2011  Samsung Samsung India Software Operations
#
# Santosh Yaraganavi <santosh.sy@samsung.com>
# Vinayak Holikatti <h.vinayak@samsung.com>

# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# NO WARRANTY
# THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
# LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
# solely responsible for determining the appropriateness of using and
# distributing the Program and assumes all risks associated with its
# exercise of rights under this Agreement, including but not limited to
# the risks and costs of program errors, damage to or loss of data,
# programs or equipment, and unavailability or interruption of operations.

# DISCLAIMER OF LIABILITY
# NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
# HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
# USA.

config SCSI_UFSHCD
	tristate "Universal Flash Storage host controller driver"
	depends on PCI && SCSI
	---help---
	This is a generic driver which supports PCIe UFS Host controllers.
Loading