From patchwork Mon Apr 10 18:45:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Larson X-Patchwork-Id: 13206610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5205EC77B74 for ; Mon, 10 Apr 2023 18:48:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbjDJSr6 (ORCPT ); Mon, 10 Apr 2023 14:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbjDJSrx (ORCPT ); Mon, 10 Apr 2023 14:47:53 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 573852703; Mon, 10 Apr 2023 11:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JmkvIcrFQllf3lmXNlQ9ob+6HAApevhyxK8bvixm0Qi3qR8Py5ZOqn9LuPqbptbkmEFNFk6WFwBl3B2OWbPmti5M37Qs/uMOVClY4saWGw8kl/N/+MVAD0KKA2+22YDrPHl28CpFu9ZmmbzRNpaubT7Mg04vTcc+ocFMLhQl/nb+1DqH8a1coeYvJYEa3ym4dBxmo553NaZDNjtmrTycKndPrS4oxd7tMByz4rfcEGEL88GWGHZpVNprhPrSujYweBgxWLRU7CCfbaFO7PTE9dp/YWnD/IjJFNpIWQbLh2gF3PtID+NqpM5nGBD1XchuNueCA4Nve8URE/CgZS0GVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ymfACAjSLWbCk+4U3bvrCLTQlZYsf0VDrwtsvVsOjLE=; b=CIpMNyhDRfjj8DahqKmM5912EYVHDNfJs6XJZBeDkod8Ia0NM7yg4n65RsR9+Pn4s8Zfv+Gxhg74S0Ctc+PIcAsn2Ad+e3hITIOjdzNjXG9uxzc6YwfVEt8bpqxsKWRgQbuu2QMf/zAYS0XtQcEFQaD7WrE7YlEIbTJCZxoVSskIXsMYhGW9xA5RAao+eLI5nAKLgOIMfJN7Vk6fHx/Yd2GR1+FAx5cjYwqTcqHS5v1XaIK7NiiHClO3G8lB5MEaeG2/ixT+BtR69U+Xm4hFgGg7dIG6SliLhQHzp8VQqD5d+9PZfwGUs7xM43WtfGLVdPxIxEiMALcnH5WYNS0dNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ymfACAjSLWbCk+4U3bvrCLTQlZYsf0VDrwtsvVsOjLE=; b=zK8NCDneqNk5x3r4uwAFEGdofqFOitdf+xqi78j1T9M6oF0kD7cQMwJ82bCeWKi+wfbl7FK05p1/+VlHqFNFw++rV1T0zWkobvn+DGH4x44/uc29UU1Cvc/q4AZ9IfMyNC6IYXN2mjbdPqFdjuwoW0tNK8LhldfpSBkYYI19zok= Received: from DM6PR21CA0027.namprd21.prod.outlook.com (2603:10b6:5:174::37) by CO6PR12MB5425.namprd12.prod.outlook.com (2603:10b6:303:13e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.33; Mon, 10 Apr 2023 18:47:32 +0000 Received: from DM6NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:5:174:cafe::8c) by DM6PR21CA0027.outlook.office365.com (2603:10b6:5:174::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.2 via Frontend Transport; Mon, 10 Apr 2023 18:47:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT038.mail.protection.outlook.com (10.13.173.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.25 via Frontend Transport; Mon, 10 Apr 2023 18:47:31 +0000 Received: from platform-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 10 Apr 2023 13:47:28 -0500 From: Brad Larson To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 11/15] mmc: sdhci-cadence: Enable device specific override of writel() Date: Mon, 10 Apr 2023 11:45:22 -0700 Message-ID: <20230410184526.15990-12-blarson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230410184526.15990-1-blarson@amd.com> References: <20230410184526.15990-1-blarson@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT038:EE_|CO6PR12MB5425:EE_ X-MS-Office365-Filtering-Correlation-Id: 9df2f4cd-d3fa-490a-a878-08db39f40aab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Thg55SxbMHMDJYLE1U7b+FlHe5S49Sqz/2dOuk7f8xBJfhXS+fERg7sqwImvsBgmr6zc7iO5KnG8VIsQCs6Y0RF6K4o8waha8ZwBIx32zs4qYxUsQX8mvPN2uJ5SD1eoVZNjk7T8LMawE8z65kXFAmkLDSbYPKs0WjKxSgvJXLUlX/tKPYj8Ot/Lcu2FjTAj//jBpVKlwN6AOFPWWtk5iC6fp9EhULwNk6fwNBxfW/n4ZQOaqirL5tzVFx3Gk/KFK5swW691hmVo1zfA9bg2+mkt/k1vPnBCdZbFJuAoV6iJh2vS6c5erAtsMMh5umkHwOdjkuzHeQyAUg6dtEzLR1cT9VjGxGIXxlnsRc2r0etCHNaBWFzGXZl4Un8nnbGcOwycn/J10BwvSku5ph3LNNVrOfy+TcvVLOdaVziknuwcBvs6k2vKggx9FWdogOvVIwGWxMjyIjknnkN46FQXXBMuF9Z7GTdTDVYwmbAlDNDeTlBlLBHSOfJqHQD/bmxuw4MxCXDo+bwPvpFHXYrsh83AjKZ0dcMXc/waRU2MA5/p6vEPuY2DAUciGMMfo2FNIwPi8e7KuDCOafCTOB1maDplhRUYTUaodgn3hNDqZHd6lga3JmN3pWy8sngndq5Km7sgo34O/cx75m45kxqZZz+il+sA/o2IOuqiIfUH8obf5dGyeVt3LhHKm0Lk9Q4y3SJS229xa6jLMlButSyRr97R1wiUodOtZKGbNW7pvLk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(396003)(39860400002)(376002)(451199021)(46966006)(40470700004)(36840700001)(316002)(40480700001)(81166007)(6666004)(36756003)(41300700001)(82310400005)(8936002)(47076005)(40460700003)(7406005)(7416002)(83380400001)(2616005)(54906003)(16526019)(186003)(336012)(426003)(26005)(82740400003)(356005)(1076003)(5660300002)(36860700001)(2906002)(70586007)(478600001)(70206006)(6916009)(4326008)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2023 18:47:31.6101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9df2f4cd-d3fa-490a-a878-08db39f40aab X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5425 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org SoCs with device specific Cadence implementation, such as setting byte-enables before the write, need to override writel(). Add a callback where the default is writel() for all existing chips. Signed-off-by: Brad Larson Acked-by: Adrian Hunter --- v10 changes: - The 1st patch adding private writel() is unchanged. The 2nd patch is split into two patches to provide for device specific init in one patch with no effect on existing designs. Then add the pensando support into the next patch. Then the 4th patch is mmc hardware reset support which is unchanged. v9 changes: - No change to this patch but as some patches are deleted and this is a respin the three successive patches to sdhci-cadence.c are patches 12, 13, and 14 which do the following: 1. Add ability for Cadence specific design to have priv writel(). 2. Add Elba SoC support that requires its own priv writel() for byte-lane control . 3. Add support for mmc hardware reset. --- drivers/mmc/host/sdhci-cadence.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c index 6f2de54a5987..708d4297f241 100644 --- a/drivers/mmc/host/sdhci-cadence.c +++ b/drivers/mmc/host/sdhci-cadence.c @@ -67,6 +67,7 @@ struct sdhci_cdns_phy_param { struct sdhci_cdns_priv { void __iomem *hrs_addr; bool enhanced_strobe; + void (*priv_writel)(struct sdhci_cdns_priv *priv, u32 val, void __iomem *reg); unsigned int nr_phy_params; struct sdhci_cdns_phy_param phy_params[]; }; @@ -90,6 +91,12 @@ static const struct sdhci_cdns_phy_cfg sdhci_cdns_phy_cfgs[] = { { "cdns,phy-dll-delay-strobe", SDHCI_CDNS_PHY_DLY_STROBE, }, }; +static inline void cdns_writel(struct sdhci_cdns_priv *priv, u32 val, + void __iomem *reg) +{ + writel(val, reg); +} + static int sdhci_cdns_write_phy_reg(struct sdhci_cdns_priv *priv, u8 addr, u8 data) { @@ -104,17 +111,17 @@ static int sdhci_cdns_write_phy_reg(struct sdhci_cdns_priv *priv, tmp = FIELD_PREP(SDHCI_CDNS_HRS04_WDATA, data) | FIELD_PREP(SDHCI_CDNS_HRS04_ADDR, addr); - writel(tmp, reg); + priv->priv_writel(priv, tmp, reg); tmp |= SDHCI_CDNS_HRS04_WR; - writel(tmp, reg); + priv->priv_writel(priv, tmp, reg); ret = readl_poll_timeout(reg, tmp, tmp & SDHCI_CDNS_HRS04_ACK, 0, 10); if (ret) return ret; tmp &= ~SDHCI_CDNS_HRS04_WR; - writel(tmp, reg); + priv->priv_writel(priv, tmp, reg); ret = readl_poll_timeout(reg, tmp, !(tmp & SDHCI_CDNS_HRS04_ACK), 0, 10); @@ -191,7 +198,7 @@ static void sdhci_cdns_set_emmc_mode(struct sdhci_cdns_priv *priv, u32 mode) tmp = readl(priv->hrs_addr + SDHCI_CDNS_HRS06); tmp &= ~SDHCI_CDNS_HRS06_MODE; tmp |= FIELD_PREP(SDHCI_CDNS_HRS06_MODE, mode); - writel(tmp, priv->hrs_addr + SDHCI_CDNS_HRS06); + priv->priv_writel(priv, tmp, priv->hrs_addr + SDHCI_CDNS_HRS06); } static u32 sdhci_cdns_get_emmc_mode(struct sdhci_cdns_priv *priv) @@ -223,7 +230,7 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host *host, unsigned int val) */ for (i = 0; i < 2; i++) { tmp |= SDHCI_CDNS_HRS06_TUNE_UP; - writel(tmp, reg); + priv->priv_writel(priv, tmp, reg); ret = readl_poll_timeout(reg, tmp, !(tmp & SDHCI_CDNS_HRS06_TUNE_UP), @@ -386,6 +393,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev) priv->nr_phy_params = nr_phy_params; priv->hrs_addr = host->ioaddr; priv->enhanced_strobe = false; + priv->priv_writel = cdns_writel; host->ioaddr += SDHCI_CDNS_SRS_BASE; host->mmc_host_ops.hs400_enhanced_strobe = sdhci_cdns_hs400_enhanced_strobe;