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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EB0BCC4332F for ; Thu, 15 Dec 2022 15:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:CC:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gu1/ugXW1D/YVL+dR2D186pZmLEm7OdRo++oiWsD0uk=; b=KfeGXNv/1i0UI3 luZp5g+iw2vE4/lHrkiYq7dM6sLcT7vP6mPaRXK0+kCLi35DlX/3tZ7NaBOcHQX62gPyBSMnSzuxr VQQb0ssrdRwgSjomJNtXVNtZf/ZBSDgJkyKcbKCUfe9NgkWWirgU/sWgCgSiK4ftGM8YRvJpuNYZb 1AP1TyhDIkrc9x+wTmDxK8yeC6zFE+MMs6Z8c/mdmL9wUJULrTzqvqk5C82WIiopBWNBaNqZLl6NE MzyPRVPk2GdOIJnM0xz5LOKjzMGGkYtQbpyKGbzbuMlhnIYjDyLae4E9jUkKmkUSCG1Id5blVfvRf SWAZwhYi7uej9gsoSbZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p5qT9-00A81q-EX; Thu, 15 Dec 2022 15:48:23 +0000 Received: from mail-bn1nam02on2073.outbound.protection.outlook.com ([40.107.212.73] helo=NAM02-BN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p5qT6-00A80l-B2 for linux-arm-kernel@lists.infradead.org; Thu, 15 Dec 2022 15:48:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HdA2mVhiSRvuMl8mIqycHeQ4u9pvgPMlVdsm2NesYdNpjkOHjsAZ6KM8espovpwzFO2O6yPqynLdA1skBCuBnF2uM4JRmEzzzVfodOW39olsyZuOSlUPn3YWJ9rIoD4mcCl/GnMtQ788lJqQoohoI/+vus2WEdNbuRk0bNxaFEMldy00YmjSWByIa8ZZKkkW6KQx5POS8Wq1Ef5WWVe1ZijlgL0HYqmdv6ogRkhJOftaa9q6uHEhqmzWjAaMCIM+IVxZ5wBj2p5Uv+fG3vXs63ar9X/+XmxX2z72Lv9ojY/qM5Zbd0efkLpbRSHNk7cxg3yx8mxRepIU9QgKwGjfkQ== 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=Hk4S25CEi2m18BI9M2DI1EyUMRx022m6Nvdl/z6xDEQ=; b=hXdYAMYhV/IG/ly9j6kb+ES1ZokmiARbj8UYiw2MRD2NfRiXk5HT3vv8dDfDv6Z6RrTkFwYqYMgV/cgBlQOf1u5JKskJdIWny5/V64aDHaycs4h1Bs0Hy9FgmEhXjT6/cPWDpSQVtlOB5H33S9VX3Pp5oGEP/m9DtBHnF2vTqEjgBEet61zg3hzOLw9E6U/Uf9Au+XEGvJLV2ku4trI0D6ae+kiBIkqoKUoqpa54BIX9yxVWNDOW1peMCkHXfQ4/GeeJmRRxEJXL5Tbg1lB5c9BiK3W4xiMxI/tcxnNxn1xoFSQh7B3Ztm/rXoUWlqe3P/pph+cmNSGxyFcHGkD3PQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=denx.de 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=Hk4S25CEi2m18BI9M2DI1EyUMRx022m6Nvdl/z6xDEQ=; b=q1mPUZr0xJSbKgJ9GGWdQTC31iem8vjzI2EfaiNnT+r7wPtdEbRqgpxsJf1tTPLtcFWDdhkHhuu8nywDsGAO/y1N0QXjeTuhJ5YPAP4md7qu2CPSQSiuPABxzpApIbpaby9IO3KBDf/Mjq9S/X90FVbdnDBu4zN6pA80UCVCrmM= Received: from MN2PR05CA0009.namprd05.prod.outlook.com (2603:10b6:208:c0::22) by PH7PR12MB7985.namprd12.prod.outlook.com (2603:10b6:510:27b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Thu, 15 Dec 2022 15:48:15 +0000 Received: from BL02EPF0000EE3E.namprd05.prod.outlook.com (2603:10b6:208:c0:cafe::11) by MN2PR05CA0009.outlook.office365.com (2603:10b6:208:c0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.5 via Frontend Transport; Thu, 15 Dec 2022 15:48:15 +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 BL02EPF0000EE3E.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Thu, 15 Dec 2022 15:48:15 +0000 Received: from [10.254.241.50] (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; Thu, 15 Dec 2022 09:48:12 -0600 Message-ID: <4a8a49fa-aca9-e356-b918-aad36566845e@amd.com> Date: Thu, 15 Dec 2022 16:48:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v3] firmware: xilinx: Clear IOCTL_SET_SD_TAPDELAY using PM_MMIO_WRITE Content-Language: en-US To: Marek Vasut , CC: Abhyuday Godhasara , Harsha , Rajan Vaja , Ronak Jain , Tanmay Shah References: <20221215152023.8387-1-marex@denx.de> From: Michal Simek In-Reply-To: <20221215152023.8387-1-marex@denx.de> 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: BL02EPF0000EE3E:EE_|PH7PR12MB7985:EE_ X-MS-Office365-Filtering-Correlation-Id: 3de5c833-bc85-4070-7998-08dadeb3c766 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gBvwWR6G/YM6hHoj24U4wxK+RwWkR4uY97iaW7S1CV1CY9/a5kb1YvuvxYq+Jmh9jvQvLN0krXFo516+pjmAFRokiI0ipX89J4sDVKJcofZCK0/lgW2tLzMuxtRRDRdVjJ8JGvsxHR/hVe2bzy1vU+sOMHaEHSv1xejQ0TKLnNzNWtnNn7VejPb92Gw1yciywaOYmp6EUcPGfq+a4POJ6Tgulttj4JagVLDkNZRfKCc9i9cUoR0cmjztCIDaTmAogGp+tM47OHM3geg9BRnbWS7xkg60BxnGVO/vfmmPR7YsJdQPejT2oiGiwn+Q5sQZxTy/d8GTx9DwumRU9y0DbVAirkjs7PhFCBDdfgbX0Kv1KYDH/yxga8S0a0Oel9Zf4x1qtgqxpOBm7V3uTkCHfPd54Oi4dDGZxP9fcjv2bfQzRJLhOFQr3Y/NNaFJE+w2fT6hkDLTk6NSI+MLNSCLsqciFHxQrsgY4ZCJ2bKToy6p5OAerOtSGFsdwGv9M55FH/t4HO+z3eWDRHAN0GYHHzOxqg1K8X26FltPJ1jIRlm4YxnpPFRp7qLQ+H7Oq3NRswpscWqquRYRR4CxQT06fbqLB8aA27Ckf84SNVBLB4GYBmYRcAYzQ/W1CAUsS3o0hXnVRdkyjPobzga6ZqCjzUnaWehAOzHRWh4YgFLthhxH/axbFfg9BklHtlUvemaCa9Q6cAbwddj88FnC77QqiIJSl9MHV+6wxb2A5fNA/kwAe5TKd81ODe2q2bJWdwYRejveDVJYJUbmXQLmcB2ozw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:CA;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199015)(46966006)(36840700001)(40470700004)(36756003)(356005)(2906002)(82740400003)(81166007)(40480700001)(8936002)(82310400005)(5660300002)(41300700001)(40460700003)(47076005)(83380400001)(36860700001)(426003)(31696002)(86362001)(31686004)(478600001)(54906003)(110136005)(44832011)(4326008)(53546011)(6666004)(107886003)(8676002)(70586007)(316002)(2616005)(70206006)(16576012)(26005)(186003)(336012)(16526019)(43740500002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2022 15:48:15.1771 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3de5c833-bc85-4070-7998-08dadeb3c766 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: BL02EPF0000EE3E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7985 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221215_074820_416833_614C91F5 X-CRM114-Status: GOOD ( 25.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 12/15/22 16:20, Marek Vasut wrote: > In case the tap delay required by Arasan SDHCI is set to 0, the current > embeddedsw firmware unconditionally writes IOU_SLCR SD_ITAPDLY to 0x100 > (SD0_ITAPDLYENA=1, SD0_ITAPDLYSEL=0). Previous behavior was to keep the > IOU_SLCR SD_ITAPDLY set to 0x0. There is some sort of difference in the > behavior between SD0_ITAPDLYENA=1/0 with the same SD0_ITAPDLYSEL=0, even > though the behavior should be identical -- zero delay added to rxclk_in > line. The former breaks HS200 training in low temperature conditions. > > Write IOU_SLCR SD_ITAPDLY register to 0 using PM_MMIO_WRITE which seem > to allow unrestricted WRITE access (and PM_MMIO_READ which allows read > access) to the entire address space. This way, it is possible to work > around the defect in IOCTL_SET_SD_TAPDELAY design which does not permit > clearing SDx_ITAPDLYENA bit. > > Note that the embeddedsw firmware does not permit clearing the SD_ITAPDLY > SD0_ITAPDLYENA bit, this bit can only ever be set by the firmware and it > is often impossible to update the possibly broken firmware. > > Signed-off-by: Marek Vasut > --- > Cc: Abhyuday Godhasara > Cc: Harsha > Cc: Michal Simek > Cc: Rajan Vaja > Cc: Ronak Jain > Cc: Tanmay Shah > To: linux-arm-kernel@lists.infradead.org > --- > V2: - Use PM_MMIO_WRITE to clear SD_xTAPDLYx bitfields and work around > the IOCTL_SET_SD_TAPDELAY design defect. > - Update commit message accordingly. > V3: - Move SD_ITAPDLY, SD_OTAPDLYSEL to include/linux/firmware/xlnx-zynqmp.h > --- > drivers/firmware/xilinx/zynqmp.c | 27 +++++++++++++++++++++++++-- > include/linux/firmware/xlnx-zynqmp.h | 4 ++++ > 2 files changed, 29 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c > index 129f68d7a6f53..acd83d29c8667 100644 > --- a/drivers/firmware/xilinx/zynqmp.c > +++ b/drivers/firmware/xilinx/zynqmp.c > @@ -738,8 +738,31 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_get_pll_frac_data); > */ > int zynqmp_pm_set_sd_tapdelay(u32 node_id, u32 type, u32 value) > { > - return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, IOCTL_SET_SD_TAPDELAY, > - type, value, NULL); > + u32 reg = (type == PM_TAPDELAY_INPUT) ? SD_ITAPDLY : SD_OTAPDLYSEL; > + u32 mask = (node_id == NODE_SD_0) ? GENMASK(15, 0) : GENMASK(31, 16); > + > + if (value) { > + return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, > + IOCTL_SET_SD_TAPDELAY, > + type, value, NULL); > + } > + > + /* > + * Work around completely misdesigned firmware API on Xilinx ZynqMP. > + * The IOCTL_SET_SD_TAPDELAY firmware call allows the caller to only > + * ever set IOU_SLCR SD_ITAPDLY Register SD0_ITAPDLYENA/SD1_ITAPDLYENA > + * bits, but there is no matching call to clear those bits. If those > + * bits are not cleared, SDMMC tuning may fail. > + * > + * Luckily, there are PM_MMIO_READ/PM_MMIO_WRITE calls which seem to > + * allow complete unrestricted access to all address space, including > + * IOU_SLCR SD_ITAPDLY Register and all the other registers, access > + * to which was supposed to be protected by the current firmware API. > + * > + * Use PM_MMIO_READ/PM_MMIO_WRITE to re-implement the missing counter > + * part of IOCTL_SET_SD_TAPDELAY which clears SDx_ITAPDLYENA bits. > + */ > + return zynqmp_pm_invoke_fn(PM_MMIO_WRITE, reg, mask, 0, 0, NULL); > } > EXPORT_SYMBOL_GPL(zynqmp_pm_set_sd_tapdelay); > > diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h > index b986e267d149b..eb88b4ba62f98 100644 > --- a/include/linux/firmware/xlnx-zynqmp.h > +++ b/include/linux/firmware/xlnx-zynqmp.h > @@ -79,6 +79,10 @@ > #define EVENT_ERROR_PSM_ERR1 (0x28108000U) > #define EVENT_ERROR_PSM_ERR2 (0x2810C000U) > > +/* ZynqMP SD tap delay tuning */ > +#define SD_ITAPDLY 0xFF180314 > +#define SD_OTAPDLYSEL 0xFF180318 > + > enum pm_api_cb_id { > PM_INIT_SUSPEND_CB = 30, > PM_ACKNOWLEDGE_CB = 31, Applied. M _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel