1. 01 Oct, 2014 14 commits
    • Sahitya Tummala's avatar
      ufs: Add support for clock gating · 1ab27c9c
      Sahitya Tummala authored
      The UFS controller clocks can be gated after certain period of
      inactivity, which is typically less than runtime suspend timeout.
      In addition to clocks the link will also be put into Hibern8 mode
      to save more power.
      
      The clock gating can be turned on by enabling the capability
      UFSHCD_CAP_CLK_GATING. To enable entering into Hibern8 mode as part of
      clock gating, set the capability UFSHCD_CAP_HIBERN8_WITH_CLK_GATING.
      
      The tracing events for clock gating can be enabled through debugfs as:
      echo 1 > /sys/kernel/debug/tracing/events/ufs/ufshcd_clk_gating/enable
      cat /sys/kernel/debug/tracing/trace_pipe
      Signed-off-by: default avatarSahitya Tummala <stummala@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      1ab27c9c
    • Dolev Raviv's avatar
      ufs: refactor configuring power mode · 7eb584db
      Dolev Raviv authored
      Sometimes, the device shall report its maximum power and speed
      capabilities, but we might not wish to configure it to use those
      maximum capabilities.
      This change adds support for the vendor specific host driver to
      implement power change notify callback.
      
      To enable configuring different power modes (number of lanes,
      gear number and fast/slow modes) it is necessary to split the
      configuration stage from the stage that reads the device max power mode.
      In addition, it is not required to read the configuration more than
      once, thus the configuration is stored after reading it once.
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarYaniv Gardi <ygardi@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      7eb584db
    • Subhash Jadavani's avatar
      ufs: add UFS power management support · 57d104c1
      Subhash Jadavani authored
      This patch adds support for UFS device and UniPro link power management
      during runtime/system PM.
      
      Main idea is to define multiple UFS low power levels based on UFS device
      and UFS link power states. This would allow any specific platform or pci
      driver to choose the best suited low power level during runtime and
      system suspend based on their power goals.
      
      bkops handlig:
      To put the UFS device in sleep state when bkops is disabled, first query
      the bkops status from the device and enable bkops on device only if
      device needs time to perform the bkops.
      
      START_STOP handling:
      Before sending START_STOP_UNIT to the device well-known logical unit
      (w-lun) to make sure that the device w-lun unit attention condition is
      cleared.
      
      Write protection:
      UFS device specification allows LUs to be write protected, either
      permanently or power on write protected. If any LU is power on write
      protected and if the card is power cycled (by powering off VCCQ and/or
      VCC rails), LU's write protect status would be lost. So this means those
      LUs can be written now. To ensures that UFS device is power cycled only
      if the power on protect is not set for any of the LUs, check if power on
      write protect is set and if device is in sleep/power-off state & link in
      inactive state (Hibern8 or OFF state).
      If none of the Logical Units on UFS device is power on write protected
      then all UFS device power rails (VCC, VCCQ & VCCQ2) can be turned off if
      UFS device is in power-off state and UFS link is in OFF state. But current
      implementation would disable all device power rails even if UFS link is
      not in OFF state.
      
      Low power mode:
      If UFS link is in OFF state then UFS host controller can be power collapsed
      to avoid leakage current from it. Note that if UFS host controller is power
      collapsed, full UFS reinitialization will be required on resume to
      re-establish the link between host and device.
      Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarSujit Reddy Thumma <sthumma@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      57d104c1
    • Subhash Jadavani's avatar
      ufs: introduce well known logical unit in ufs · 0ce147d4
      Subhash Jadavani authored
      UFS device may have standard LUs and LUN id could be from 0x00 to 0x7F.
      UFS device specification use "Peripheral Device Addressing Format"
      (SCSI SAM-5) for standard LUs.
      
      UFS device may also have the Well Known LUs (also referred as W-LU) which
      again could be from 0x00 to 0x7F. For W-LUs, UFS device specification only
      allows the "Extended Addressing Format" (SCSI SAM-5) which means the W-LUNs
      would start from 0xC100 onwards.
      
      This means max. LUN number reported from UFS device could be 0xC17F hence
      this patch advertise the "max_lun" as 0xC17F which will allow SCSI mid
      layer to detect the W-LUs as well.
      
      But once the W-LUs are detected, UFSHCD driver may get the commands with
      SCSI LUN id upto 0xC17F but UPIU LUN id field is only 8-bit wide so it
      requires the mapping of SCSI LUN id to UPIU LUN id. This patch also add
      support for this mapping.
      Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarSujit Reddy Thumma <sthumma@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      0ce147d4
    • Subhash Jadavani's avatar
      ufs: manually add well known logical units · 2a8fa600
      Subhash Jadavani authored
      UFS device specification requires the UFS devices to support 4 well known
      logical units:
      	"REPORT_LUNS" (address: 01h)
      	"UFS Device" (address: 50h)
      	"RPMB" (address: 44h)
      	"BOOT" (address: 30h)
      
      UFS device's power management needs to be controlled by "POWER CONDITION"
      field of SSU (START STOP UNIT) command. But this "power condition" field
      will take effect only when its sent to "UFS device" well known logical unit
      hence we require the scsi_device instance to represent this logical unit in
      order for the UFS host driver to send the SSU command for power management.
      
      We also require the scsi_device instance for "RPMB" (Replay Protected
      Memory Block) LU so user space process can control this LU. User space may
      also want to have access to BOOT LU.
      
      This patch adds the scsi device instances for each of all well known LUs
      (except "REPORT LUNS" LU).
      Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      2a8fa600
    • Yaniv Gardi's avatar
      ufs: Active Power Mode - configuring bActiveICCLevel · 3a4bf06d
      Yaniv Gardi authored
      The maximum power consumption in active is determined by bActiveICCLevel.
      The configuration is done by reading max current supported by the
      regulators connected to VCC, VCCQ and VCCQ2 rails on the boards, and
      reading the current consumption levels from the device for each rails
      (vcc/vccq/vccq2) using power descriptor.
      We configure the bActiveICCLevel attribute, with the max value that
      correspond to the minimum-of(VCC-current-level,VCCQ-current-level,
      VCCQ2-current-level).
      In order to minimize resume latency, pre-fetch icc levels and reference
      clock during initialization and avoid reading them each link startup
      during resume.
      Signed-off-by: default avatarRaviv Shvili <rshvili@codeaurora.org>
      Signed-off-by: default avatarYaniv Gardi <ygardi@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      3a4bf06d
    • Sujit Reddy Thumma's avatar
      ufs: improve init sequence · 1d337ec2
      Sujit Reddy Thumma authored
      In ->hce_enable_notify() callback the vendor specific initialization
      may carry out additional DME configuration using UIC commands and
      hence the UIC command completion interrupt enable bit should be set
      before the post reset notification.
      Add retries if the link-startup fails. This is required since due to
      hardware timing issues, the Uni-Pro link-startup might fail. The UFS
      HCI recovery procedure contradicts the Uni-Pro sequence. The UFS HCI
      specifies to resend DME_LINKSTARTUP command after IS.ULLS (link-lost
      interrupt) is received. The Uni-Pro specifies that if link-startup
      fails the link is in "down" state. The link-lost is indicated to the
      DME user only when the link is up. Hence, the UFS HCI recovery procedure
      of waiting for IS.ULLS and retrying link-startup may not work properly.
      
      At the end, if detection fails, power off (disable clocks, regulators,
      phy) if the UFS device detection fails. This saves power while UFS device
      is not embedded into the system.
      Signed-off-by: default avatarSujit Reddy Thumma <sthumma@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      1d337ec2
    • Subhash Jadavani's avatar
      ufs: refactor query descriptor API support · da461cec
      Subhash Jadavani authored
      Currently reading query descriptor is more tightened to each
      descriptor type. This patch generalize the approach and allows
      reading any parameter from any query descriptor.
      Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      da461cec
    • Raviv Shvili's avatar
      ufs: add voting support for host controller power · 6a771a65
      Raviv Shvili authored
      Add the support for voting of the regulator powering the
      host controller logic.
      Signed-off-by: default avatarRaviv Shvili <rshvili@codeaurora.org>
      Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      6a771a65
    • Sujit Reddy Thumma's avatar
      ufs: Add clock initialization support · c6e79dac
      Sujit Reddy Thumma authored
      Add generic clock initialization support for UFSHCD platform
      driver. The clock info is read from device tree using standard
      clock bindings. A generic max-clock-frequency-hz property is
      defined to save information on maximum operating clock frequency
      the h/w supports.
      Signed-off-by: default avatarSujit Reddy Thumma <sthumma@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      c6e79dac
    • Sujit Reddy Thumma's avatar
      ufs: Add regulator enable support · aa497613
      Sujit Reddy Thumma authored
      UFS devices are powered by at most three external power supplies -
      - VCC - The flash memory core power supply, 2.7V to 3.6V or 1.70V to 1.95V
      - VCCQ - The controller and I/O power supply, 1.1V to 1.3V
      - VCCQ2 - Secondary controller and/or I/O power supply, 1.65V to 1.95V
      
      For some devices VCCQ or VCCQ2 are optional as they can be
      generated using internal LDO inside the UFS device.
      
      Add DT bindings for voltage regulators that can be controlled
      from host driver.
      Signed-off-by: default avatarSujit Reddy Thumma <sthumma@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      aa497613
    • Sujit Reddy Thumma's avatar
      ufs: Allow vendor specific initialization · 5c0c28a8
      Sujit Reddy Thumma authored
      Some vendor specific controller versions might need to configure
      vendor specific - registers, clocks, voltage regulators etc. to
      initialize the host controller UTP layer and Uni-Pro stack.
      Provide some common initialization operations that can be used
      to configure vendor specifics. The methods can be extended in
      future, for example, for power mode transitions.
      
      The operations are vendor/board specific and hence determined with
      the help of compatible property in device tree.
      Signed-off-by: default avatarSujit Reddy Thumma <sthumma@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      5c0c28a8
    • Subhash Jadavani's avatar
      scsi: don't add scsi_device if its already visible · 693ad5ba
      Subhash Jadavani authored
      If LLD has added scsi device (by calling scsi_add_device) before scheduling
      async scsi_scan_host then scsi_finish_async_scan() will end up calling
      scsi_sysfs_add_sdev for scsi device which was already added by LLD.
      This patch fixes this issue by skipping the call to scsi_sysfs_add_sdev()
      if it's already visible to rest of the kernel.
      Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
      Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      693ad5ba
    • Subhash Jadavani's avatar
      scsi: fix the type for well known LUs · 45341ca3
      Subhash Jadavani authored
      Some devices may respond with wrong type for well-known logical units.
      This patch forces well-known type for devices which doesn't report it
      correct.
      Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
      Signed-off-by: default avatarSujit Reddy Thumma <sthumma@codeaurora.org>
      Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      45341ca3
  2. 30 Sep, 2014 7 commits
  3. 26 Sep, 2014 1 commit
  4. 25 Sep, 2014 18 commits