From patchwork Wed Aug 28 19:17:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 172424 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1184023ily; Wed, 28 Aug 2019 12:18:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyL95nmcVdOfgfMbo5FQQAyXlVHo+JbEQszEHHe7bdItjB8rlhQ+WmIp+TspYDWMZUBHva2 X-Received: by 2002:a17:902:9895:: with SMTP id s21mr5823830plp.255.1567019891463; Wed, 28 Aug 2019 12:18:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567019891; cv=none; d=google.com; s=arc-20160816; b=kqBM1tLm0nbgcrqDkdo/MZKiw9C2zYqUan7x3taGsjGSqfYc+bepceGe6+f2F5vUGP 2czHwu1DnxchJY/Qzz/irvFxiTpGX9YaiUz4EMsLbIgzeMVymP4YCyJUFlRvvCGQ5VhT E1pj7yfO3WCd9IzD5AOpRWs7rZRMxGObRl8br4bqLdcD3A7bd5mqnsgn6jKjdBoC3RGN MRSrLvgpTpl0mTwrDlC0ibEk7M/qkY+1mhLk+7gHMiFJA7hI+2ZA62Q9fYybSxqNAJJh mYtE/AU1wZrW1kh6CeCwrCHv9kE3P1T+tC8+PpMa9rm5n8NntHK1YumPX1HEJ4hV/NL6 nu+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=peYkc8bpnDp6jFbXtkwKHOUEOwA9yyWEoa4Q9aEgSqo=; b=JzzDNy5AsWA8tWzixG6cV23xU81WfdJMx4PkIogZGeFfNqVmAwCUkb0/w988lt0Img Vn2/vm19vGMvv50VsBO3LUwCgyJEb2okxokvvnfg3xGUhVd1URkv196r7tCwoh2E8lMG 1zsxAXuugvwCGgrhDjHoPfoiXmlQLrWRb3RSJLIO+1XxrSLxilcnN4R+MkvWk+Cy+mZy yxwEz5nR5nDg3fU9x5Pre+18G88U5kGE5zFVeleQ8uNeh5V4TLofHWPM9E+G1SHcb/VX 5WUGV1MfEDOho5+XmMkBOBti4DLbF6Xv7CTrEOSC6ahgkll8an5ENMMSWR4jIqhWdYBp w9WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AFwFkCbw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8si2800956pgt.548.2019.08.28.12.18.11; Wed, 28 Aug 2019 12:18:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AFwFkCbw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbfH1TSH (ORCPT + 28 others); Wed, 28 Aug 2019 15:18:07 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:32782 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726887AbfH1TSE (ORCPT ); Wed, 28 Aug 2019 15:18:04 -0400 Received: by mail-pl1-f193.google.com with SMTP id go14so424471plb.0 for ; Wed, 28 Aug 2019 12:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=peYkc8bpnDp6jFbXtkwKHOUEOwA9yyWEoa4Q9aEgSqo=; b=AFwFkCbwz63sJkbk32teOrITW/PxPxz4IF3E60WGCC6OIkYgPjzJSp1x7aiVGloV89 A4uKhTR4+72TgIhhMk3aWziPHvzqP0HeYcmoHdfilhX66Y1mMr9h8pFru1N4BoVW+TI3 0bTriWTQ9pTYyp4T40Ovwi8X0YboAI2w8vwO3wVWVR2ZmNP1uTjxRccGoZGnvCOI1tQN N184XnZqBtgT/eO0a37h7hSBchxRf+7/0PDYYjjmHqzqGjtfC8/8HN6mpqOE9jpA3smd 5X1x8XQLUJXnd8RDqF7+6RztHUb74CDvTbltYi6eRQjdu2uciJ+H5xMQqgc26X9PQt2d 79pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=peYkc8bpnDp6jFbXtkwKHOUEOwA9yyWEoa4Q9aEgSqo=; b=PYZraEYHoSM+gAsVKAUwQUMz189OZJ9saG4i8SdnDXapxycgzuxCCVroqoMA63IlDg lMi3Ji0XVW3i0aUU32KpPjNYfYlbmZoXwfDnLDNLV4WgG2Eo/snwzmdro1w5WPQOhVJB VSi1r4q1g0HmbOb2dVYROhv564rggpuMbazdLlK7t/Bh+I4An9ZpfXh0z8ZBodtlFomD hNclI9yjMr0A7xakBTUc1anoJtvCy7mReeF1ei9BdsZ2qfxmBqKh6zqR69X5yHyDEJOx hsgizfd/TIS0SJxZ9s/oetuDKFURFdKP2PxdcwXqLrMA/0iDM5tlpVFcyFqtAU/8SK7A X/YQ== X-Gm-Message-State: APjAAAXIBaJz7FcicymxsjsHFc3ZAOP7ix4SjWz8lnRC+oo2+UK5jop9 mTTkZxihkjeK3969QDnFl8CvPg== X-Received: by 2002:a17:902:96a:: with SMTP id 97mr5909479plm.264.1567019883819; Wed, 28 Aug 2019 12:18:03 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id n128sm122717pfn.46.2019.08.28.12.18.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Aug 2019 12:18:03 -0700 (PDT) From: Bjorn Andersson To: Rob Herring , Mark Rutland , Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Andy Gross , Bean Huo , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, Linus Walleij Subject: [PATCH v4 2/3] scsi: ufs-qcom: Implement device_reset vops Date: Wed, 28 Aug 2019 12:17:55 -0700 Message-Id: <20190828191756.24312-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190828191756.24312-1-bjorn.andersson@linaro.org> References: <20190828191756.24312-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The UFS_RESET pin on Qualcomm SoCs are controlled by TLMM and exposed through the GPIO framework. Acquire the device-reset GPIO and use this to implement the device_reset vops, to allow resetting the attached memory. Based on downstream support implemented by Subhash Jadavani . Signed-off-by: Bjorn Andersson --- Changes since v3: - Renamed device-reset-gpios to just reset-gpios. - Explicitly bail on !host->device_reset, to not rely on passing NULL to gpiod_set_value_cansleep() .../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++ drivers/scsi/ufs/ufs-qcom.c | 36 +++++++++++++++++++ drivers/scsi/ufs/ufs-qcom.h | 4 +++ 3 files changed, 42 insertions(+) -- 2.18.0 diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt index a74720486ee2..d78ef63935f9 100644 --- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt @@ -54,6 +54,8 @@ Optional properties: PHY reset from the UFS controller. - resets : reset node register - reset-names : describe reset node register, the "rst" corresponds to reset the whole UFS IP. +- reset-gpios : A phandle and gpio specifier denoting the GPIO connected + to the RESET pin of the UFS memory device. Note: If above properties are not defined it can be assumed that the supply regulators or clocks are always on. diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 4473f339cbc0..2200c8434ef3 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "ufshcd.h" @@ -1140,6 +1141,15 @@ static int ufs_qcom_init(struct ufs_hba *hba) } } + host->device_reset = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(host->device_reset)) { + err = PTR_ERR(host->device_reset); + if (err != -EPROBE_DEFER) + dev_err(dev, "failed to acquire reset gpio: %d\n", err); + goto out_variant_clear; + } + err = ufs_qcom_bus_register(host); if (err) goto out_variant_clear; @@ -1545,6 +1555,31 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba) usleep_range(1000, 1100); } +/** + * ufs_qcom_device_reset() - toggle the (optional) device reset line + * @hba: per-adapter instance + * + * Toggles the (optional) reset line to reset the attached device. + */ +static void ufs_qcom_device_reset(struct ufs_hba *hba) +{ + struct ufs_qcom_host *host = ufshcd_get_variant(hba); + + /* reset gpio is optional */ + if (!host->device_reset) + return; + + /* + * The UFS device shall detect reset pulses of 1us, sleep for 10us to + * be on the safe side. + */ + gpiod_set_value_cansleep(host->device_reset, 1); + usleep_range(10, 15); + + gpiod_set_value_cansleep(host->device_reset, 0); + usleep_range(10, 15); +} + /** * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations * @@ -1565,6 +1600,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .suspend = ufs_qcom_suspend, .resume = ufs_qcom_resume, .dbg_register_dump = ufs_qcom_dump_dbg_regs, + .device_reset = ufs_qcom_device_reset, }; /** diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h index 001915d1e0e4..d401f174bb70 100644 --- a/drivers/scsi/ufs/ufs-qcom.h +++ b/drivers/scsi/ufs/ufs-qcom.h @@ -195,6 +195,8 @@ struct ufs_qcom_testbus { u8 select_minor; }; +struct gpio_desc; + struct ufs_qcom_host { /* * Set this capability if host controller supports the QUniPro mode @@ -232,6 +234,8 @@ struct ufs_qcom_host { struct ufs_qcom_testbus testbus; struct reset_controller_dev rcdev; + + struct gpio_desc *device_reset; }; static inline u32