From patchwork Wed Aug 28 19:17:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 172422 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1183911ily; Wed, 28 Aug 2019 12:18:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfWOykOeu/NnTTf+7kiph7hB1s9RKWnFY63ldsLiZstFq19V8BAhp5TZHMuav3TBl8tP8j X-Received: by 2002:a17:902:7d8b:: with SMTP id a11mr5898704plm.306.1567019884781; Wed, 28 Aug 2019 12:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567019884; cv=none; d=google.com; s=arc-20160816; b=wIO5QhU91TfC3ao+FdLREWPPuy0ftUIu1ZDrAbfplQtT8L36atFDV9P9VCP2DBuir6 vTjxEAuvaq6vEjL3eG5Ii2I770cMAJ4sbe+lH1jIb1jFBrBSXjl2CGGLVC6e3dGptNMP FnqvGgp5LjMPVT6wvJAoR0/Kd+hK2HSEiHnAc38GTZIQ9hT3akxY6oxqXyrhViaApa4J F6Cv2B3iKxCx4jcRmt50nqj/h98bJWNMsBUjeS+cw0noyRVWtQU9enn9ucGT7n2DPUa+ 64q8W7zVwqu4AlnXlSTKwUTeMyTfLRZtvnfd6RSuEEI3a6lUnx+IRAudgLwGFuX4pvFm KYsg== 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=frRCVqPEFMbhw8WqpjXDJar8k8pcOq5o3U1C6HdWuBw=; b=uV4kTsPhzJqShCm0dsuQ/dqf/ooS36hQzNJ7ZCUglGHzYO3+zgup8nh651HJfnNk83 bf+VuEUszEntv5n+Jj+G2PMzKr5l2tR+4Rvm37rGeKAkr97UEvZmHvj5f63QvmMTpMbl yP6PysOicGqu8MqB3iBKn4vR1Y9U/cLWT6K8rSPhqTxC1HDG0xim4pXBau9KRKGAB0ji 3IugW67kMgVNodrkZklhpW6jopHZnLtW/ZkfLuaokoaa9Rg1DkNKJwtD7GlK+j64IK8Z Sm/Fw8qP/Hf+VU4s3VkThDxfnyaTiQGTG/CAwBzkbXG7BaPS32HV9/4VBHe79B7TbaSY u1gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yjb6U4UM; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 f7si94309pfq.93.2019.08.28.12.18.04 for ; Wed, 28 Aug 2019 12:18:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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=Yjb6U4UM; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 S1726911AbfH1TSE (ORCPT ); Wed, 28 Aug 2019 15:18:04 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42990 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726887AbfH1TSD (ORCPT ); Wed, 28 Aug 2019 15:18:03 -0400 Received: by mail-pg1-f195.google.com with SMTP id p3so226395pgb.9 for ; Wed, 28 Aug 2019 12:18:02 -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=frRCVqPEFMbhw8WqpjXDJar8k8pcOq5o3U1C6HdWuBw=; b=Yjb6U4UM55j8Qd5lit9icVMiTabO3K/CK55xecjtlEFvjf+4Pdftmlehf2ZPI1XIYc XrzRw9OqguPYP/qHWihbXPRn6ybHx6rhep7dXtDjlsOroLX5AKsTmUPW7cm/2xjS/Hp6 dw/ffiytgOzt9ZYxOZAGv7I+35KMp+ivU2u9dlKLMgz6xEtf26Wysin8jIrSgFYnq3Jb C3i14S5BW5mrcB8yH9ljDgWNGHe4oAX3+91T+dNOO1xbJK+SMB6UxpfRUikAymXzARuy Gv5nYSbgbCB8hb+Ruc8hubVmChEAiViAlTyrKPrLdvfCuzC5B9R6HU1RSuen7bquT3Dg Rgpw== 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=frRCVqPEFMbhw8WqpjXDJar8k8pcOq5o3U1C6HdWuBw=; b=oWS/K2pzNxluduBBBKVj8hlfZknYJO5cJBFKd1zaM3AMcMTLpa1kdrEd64BLP5keNN QGM6phRgOitslusIrB3lJx8/3mfTKyXRgMMfdoZQ/vO0a/WHB0A/qoqbNSYV+uSS9L8A GnmfbGc8aSS8sm94TAII7Bwg+OqmBj47ZyCYZTL7aohXpHtg9h4smBynIk9ZR4q4KCTG uPL6jlVa/04VWDqItSl+1xBBp9JyF/hT9dRroxOprNuBL5Vnu87GGKOTtTv1wFDashwS 9vnzsGOMi8I/qy8maYAODOcvmYylYkzRjbGLgqT1q+NZJGpX1YMmbbpboPSy2qofzQMd F+0Q== X-Gm-Message-State: APjAAAVCwfMrFP+hLyKk4wHoX+did2dw4Ym5VdUGZWVouiS2iNPphcLM VknFCRCisGZOqZkB/X/qpKy3eg== X-Received: by 2002:a63:e948:: with SMTP id q8mr4686361pgj.93.1567019882331; Wed, 28 Aug 2019 12:18:02 -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.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Aug 2019 12:18:01 -0700 (PDT) From: Bjorn Andersson To: Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Rob Herring , Mark Rutland , 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 1/3] scsi: ufs: Introduce vops for resetting device Date: Wed, 28 Aug 2019 12:17:54 -0700 Message-Id: <20190828191756.24312-2-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Some UFS memory devices needs their reset line toggled in order to get them into a good state for initialization. Provide a new vops to allow the platform driver to implement this operation. Reviewed-by: Alim Akhtar Signed-off-by: Bjorn Andersson --- Changes since v3: - None drivers/scsi/ufs/ufshcd.c | 6 ++++++ drivers/scsi/ufs/ufshcd.h | 8 ++++++++ 2 files changed, 14 insertions(+) -- 2.18.0 Reviewed-by: Bean Huo diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 219c435d69a7..0fb4bfdd7943 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6235,6 +6235,9 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba) int retries = MAX_HOST_RESET_RETRIES; do { + /* Reset the attached device */ + ufshcd_vops_device_reset(hba); + err = ufshcd_host_reset_and_restore(hba); } while (err && --retries); @@ -8371,6 +8374,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) goto exit_gating; } + /* Reset the attached device */ + ufshcd_vops_device_reset(hba); + /* Host controller enable */ err = ufshcd_hba_enable(hba); if (err) { diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 9f61550abc7f..c94cfda52829 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -298,6 +298,7 @@ struct ufs_pwr_mode_info { * @resume: called during host controller PM callback * @dbg_register_dump: used to dump controller debug information * @phy_initialization: used to initialize phys + * @device_reset: called to issue a reset pulse on the UFS device */ struct ufs_hba_variant_ops { const char *name; @@ -326,6 +327,7 @@ struct ufs_hba_variant_ops { int (*resume)(struct ufs_hba *, enum ufs_pm_op); void (*dbg_register_dump)(struct ufs_hba *hba); int (*phy_initialization)(struct ufs_hba *); + void (*device_reset)(struct ufs_hba *hba); }; /* clock gating state */ @@ -1070,6 +1072,12 @@ static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) hba->vops->dbg_register_dump(hba); } +static inline void ufshcd_vops_device_reset(struct ufs_hba *hba) +{ + if (hba->vops && hba->vops->device_reset) + hba->vops->device_reset(hba); +} + extern struct ufs_pm_lvl_states ufs_pm_lvl_states[]; /*