Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2752958ybx; Fri, 8 Nov 2019 08:51:29 -0800 (PST) X-Google-Smtp-Source: APXvYqyC3RGBDxt7pD6Q+8bN6+kpV6y+2Wj6UXn9x+alTFgYLHcVXN7CwQnN/0KTwiHcSKoOujy5 X-Received: by 2002:a17:906:448e:: with SMTP id y14mr9902711ejo.136.1573231889820; Fri, 08 Nov 2019 08:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573231889; cv=none; d=google.com; s=arc-20160816; b=W22ICbLJ/TSnDWonWa6NlZ70GTvr7uIpn8DL63D5W/xF60WfqWX7BSoP54eBmhjVDV Odm4uh9ANBnQ16sGi0U5Dpus4HyNv+nheGylLGomxe+WnrkN6uUVFPbkPO/qYGnh7mAw E2j7gK2EJ3gdzyG6pA2ihxHpJc/7uISFUa0FXgwX9O91fTmnNSctPfOuicmahWZrKDhH QDEu45bZLsxA7Mb5Rbz575vbnPWvnHwMY4HZIg6Qf/GyRvC9RPKHK1fKui2GzuJ0FwDw DikDNB1N3PDNl921C+cv8xf/ixkMo6PSpsgLgF2Cb8hGHTeged+D4DFDq4bh6aEPO/TW eUcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o9Re+UzpULs5A8BbZ3ZyVKC4aYlAQDX3ssPklT78j/c=; b=cx39fbhchJxgcaLcCKPcmjHaDM4tnYMSfLfd9e2sXOi3H9HxxHNg5QYyHQz4MjjLvZ +pvF1YHdm14NqT4HjgJSAS8mgD2EcaxnXesFgE/lg09En4SnwZVQnoHJY+kYZ0YYVXuY Oo3UyZKujUwnO+DeuLphtBTRjwLe1qShmb0EawfZWFN9Gucf/o1aGWCU7o3wfcN8MKXn caUfqDHuDPmxxMlC+LKBhLfmGEkmeDUy15HtGNMuQB4NfSSf9Yf3NCyK+s0p8HF3MD+n Hk5wzIKJ5X4vYRVticJIptG26XOt7RwCbvIqfLJOliR+c/tF0q6gmrD4S/NysLe+dM4e 7ayg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="CrVu/pUl"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c31si4535190edb.56.2019.11.08.08.51.06; Fri, 08 Nov 2019 08:51:29 -0800 (PST) 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=@ti.com header.s=ti-com-17Q1 header.b="CrVu/pUl"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727655AbfKHQu1 (ORCPT + 99 others); Fri, 8 Nov 2019 11:50:27 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:52194 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbfKHQu1 (ORCPT ); Fri, 8 Nov 2019 11:50:27 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA8GmZbO127315; Fri, 8 Nov 2019 10:48:35 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1573231715; bh=o9Re+UzpULs5A8BbZ3ZyVKC4aYlAQDX3ssPklT78j/c=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CrVu/pUlSTZ0ENgL1iFhIn7vVe2Dmw8sRYDAGFR3jbQDZCIItvQgY2rweT6p1uJT+ ocVaOxzzJIed0AFx997jqhPSmUcsMuZKZnb/OiHNcmC6cR3nN4NAiwZClhPaYd4Srn 2KaMVHzQzZcAS/o4ArPCs3Y3JHgx2pDCoj8vUkVs= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA8GmYQY050379 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 8 Nov 2019 10:48:35 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 8 Nov 2019 10:48:34 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Fri, 8 Nov 2019 10:48:18 -0600 Received: from a0132425.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA8GmNLY117597; Fri, 8 Nov 2019 10:48:31 -0600 From: Vignesh Raghavendra To: "James E . J . Bottomley" , "Martin K . Petersen" CC: Rob Herring , Mark Rutland , Alim Akhtar , Avri Altman , Pedro Sousa , Vignesh Raghavendra , Janek Kotas , , , Subject: [PATCH v3 2/2] scsi: ufs: Add driver for TI wrapper for Cadence UFS IP Date: Fri, 8 Nov 2019 22:18:57 +0530 Message-ID: <20191108164857.11466-3-vigneshr@ti.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108164857.11466-1-vigneshr@ti.com> References: <20191108164857.11466-1-vigneshr@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org TI's J721e SoC has a Cadence UFS IP with a TI specific wrapper. This is a minimal driver to configure the wrapper. It releases the UFS slave device out of reset and sets up registers to indicate PHY reference clock input frequency before probing child Cadence UFS driver. Signed-off-by: Vignesh Raghavendra --- v3: Fix macros to have TI_* prefix v2: No change drivers/scsi/ufs/Kconfig | 10 ++++ drivers/scsi/ufs/Makefile | 1 + drivers/scsi/ufs/ti-j721e-ufs.c | 90 +++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 drivers/scsi/ufs/ti-j721e-ufs.c diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig index 0b845ab7c3bf..d14c2243e02a 100644 --- a/drivers/scsi/ufs/Kconfig +++ b/drivers/scsi/ufs/Kconfig @@ -132,6 +132,16 @@ config SCSI_UFS_HISI Select this if you have UFS controller on Hisilicon chipset. If unsure, say N. +config SCSI_UFS_TI_J721E + tristate "TI glue layer for Cadence UFS Controller" + depends on OF && HAS_IOMEM && (ARCH_K3 || COMPILE_TEST) + help + This selects driver for TI glue layer for Cadence UFS Host + Controller IP. + + Selects this if you have TI platform with UFS controller. + If unsure, say N. + config SCSI_UFS_BSG bool "Universal Flash Storage BSG device node" depends on SCSI_UFSHCD diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile index 2a9097939bcb..94c6c5d7334b 100644 --- a/drivers/scsi/ufs/Makefile +++ b/drivers/scsi/ufs/Makefile @@ -11,3 +11,4 @@ obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o obj-$(CONFIG_SCSI_UFS_MEDIATEK) += ufs-mediatek.o +obj-$(CONFIG_SCSI_UFS_TI_J721E) += ti-j721e-ufs.o diff --git a/drivers/scsi/ufs/ti-j721e-ufs.c b/drivers/scsi/ufs/ti-j721e-ufs.c new file mode 100644 index 000000000000..5216d228cdd9 --- /dev/null +++ b/drivers/scsi/ufs/ti-j721e-ufs.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ +// + +#include +#include +#include +#include +#include +#include +#include + +#define TI_UFS_SS_CTRL 0x4 +#define TI_UFS_SS_RST_N_PCS BIT(0) +#define TI_UFS_SS_CLK_26MHZ BIT(4) + +static int ti_j721e_ufs_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + unsigned long clk_rate; + void __iomem *regbase; + struct clk *clk; + u32 reg = 0; + int ret; + + regbase = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(regbase)) + return PTR_ERR(regbase); + + pm_runtime_enable(dev); + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put_noidle(dev); + return ret; + } + + /* Select MPHY refclk frequency */ + clk = devm_clk_get(dev, NULL); + if (IS_ERR(clk)) { + dev_err(dev, "Cannot claim MPHY clock.\n"); + return PTR_ERR(clk); + } + clk_rate = clk_get_rate(clk); + if (clk_rate == 26000000) + reg |= TI_UFS_SS_CLK_26MHZ; + devm_clk_put(dev, clk); + + /* Take UFS slave device out of reset */ + reg |= TI_UFS_SS_RST_N_PCS; + writel(reg, regbase + TI_UFS_SS_CTRL); + + ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, + dev); + if (ret) { + dev_err(dev, "failed to populate child nodes %d\n", ret); + pm_runtime_put_sync(dev); + } + + return ret; +} + +static int ti_j721e_ufs_remove(struct platform_device *pdev) +{ + of_platform_depopulate(&pdev->dev); + pm_runtime_put_sync(&pdev->dev); + + return 0; +} + +static const struct of_device_id ti_j721e_ufs_of_match[] = { + { + .compatible = "ti,j721e-ufs", + }, + { }, +}; + +static struct platform_driver ti_j721e_ufs_driver = { + .probe = ti_j721e_ufs_probe, + .remove = ti_j721e_ufs_remove, + .driver = { + .name = "ti-j721e-ufs", + .of_match_table = ti_j721e_ufs_of_match, + }, +}; +module_platform_driver(ti_j721e_ufs_driver); + +MODULE_AUTHOR("Vignesh Raghavendra "); +MODULE_DESCRIPTION("TI UFS host controller glue driver"); +MODULE_LICENSE("GPL v2"); -- 2.24.0