From nobody Thu Nov 14 06:33:22 2024 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 5C008C74A44 for ; Fri, 10 Mar 2023 17:34:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbjCJReE (ORCPT ); Fri, 10 Mar 2023 12:34:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbjCJRd6 (ORCPT ); Fri, 10 Mar 2023 12:33:58 -0500 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 5EEE2DCF5C; Fri, 10 Mar 2023 09:33:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D3nCgRiO+VLFFMLCL64AUfGPR5enu0Uof8KusySYpxDBoQ+ajb8S1fbGsJZLU76mGTEyB3hi2LfyCb/mXddCn83eiaNEyRQH6Ib/V3SLDVOV30DKzG/eRnyu6PFGij8B/dUKR8cQDu6VC1tzH6UI814LdPX+2kipZgOPBApOAJNQ7zsPsDV1umR52LYSO8DU0JOWbxDu/X7sdsf98NJIKTOd+JS+0EzBg5gXK5LRi8DCMIoMYnqYKbTpydJywiO00A6bkybFP4MoC4lJlPRzot+V8o2572suMaTHSCIAOhVEPCVBD97AMcxWpOLQKw3SqNE6TUGoVsFnuqkhBmN3TA== 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=nv8+oWjcWnCe+wKRIrL9kxNDudJ6IAchcSOB+HvCxUM=; b=cfEr6Dpo9iRVWq29+z6jrYZ+6M76LaqvqTrOD/XUkJePkkvpEtS8lyiHplfYec7CwJLuglaGjqErab673vUzIKI3+GBMVMjlWtNmQvyZ6+4vbSIbxJumDaK/zyEd8YK3WHxXDM/kacwzMeGouZE0QefKtxtYJCGf+BwJVaLtGKD9vGMeI4CswMr0mq97FGxxgkBuH1SmaoYR5/TYZowF+S9Gmwqn+pyDWATbqTfMb2QjMN5BhaexcZWG3loUxLfqoio3kru6qghPEFKL7MwnWkWAf8fC2OJoGvCnV0Swp10lfw0V+pQVJ9tL95pTUMGHO9F5XPj+iYXksadQQZBV2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=temperror 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=nv8+oWjcWnCe+wKRIrL9kxNDudJ6IAchcSOB+HvCxUM=; b=X6dlcPyYgj/aJy6zmITsOaJxQoCeTVAsZu2cNr16kFAnvzBWhQYXNeDRD9nkgo6AKN7Yso9eMqW3QiA52GUgpaO232K6fmvRA7FCZrysUv7RMs1Nzz3qgmiXEsH7EkigCle+/Q+MeFajlZ9XACjlz0epCLHHP2hD7oEBIonfL60= Received: from DM6PR01CA0025.prod.exchangelabs.com (2603:10b6:5:296::30) by SN7PR12MB7273.namprd12.prod.outlook.com (2603:10b6:806:2ac::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:33:41 +0000 Received: from DM6NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:5:296:cafe::79) by DM6PR01CA0025.outlook.office365.com (2603:10b6:5:296::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:33:41 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT042.mail.protection.outlook.com (10.13.173.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Fri, 10 Mar 2023 17:33:39 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Fri, 10 Mar 2023 11:33:39 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 09:33:38 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:33:10 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Dhruva Gole , Patrice Chotard Subject: [PATCH V6 01/15] spi: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Fri, 10 Mar 2023 23:02:03 +0530 Message-ID: <20230310173217.3429788-2-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT042:EE_|SN7PR12MB7273:EE_ X-MS-Office365-Filtering-Correlation-Id: ac94897c-6977-43d1-f7b8-08db218d9671 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XoT/aZNn11RGKTamJJof7YVETFhTdGuq6227rrLmP0oThX+eo+Jmt2Mbt8mil8kDDJDTuYjyPp6Vm9l29ystGYEnFH7/0x1/WoTFc9ZGJ5b9VWha90PAMlyWeHtIq6ZPVyARy2n8Q7CHfSlcDZY/sZkMYuF/i7/QE44rHev4eVhnlMZzWql6uPXp7ztc4SFqn1TDw8In9vSsb+hlFFab/Ht9v1Z8Pen3VJ+xQupzjtLpjcaiyndwUqr6b1sAlD4O1UUGNj37/eD3Sh5u0LZ0mvzqCF03v2FPE1mkgZATG9vh7bLCx4UPvbq0xX6Q6uiqyqdijeaBW8R9hfc5wJpkAXZIOtycPYtMEGo15ahKHGJSvj0wo2SVROzxdi6O89m8SimxepWBTvmWzQmd02I44HqH/t6b+ua32I1H1LP0lHHsL9rspns60Mnw4n0cjr/68Xqs8QbepuvaIl6zrckcSagvHe9J1nT7yeRbup60phX2pZMjAsOco5udcgarkA5TGeHk/vebeMbi8KU/FSICkVdT/opQQI/QPdK84Zwt15jmVxeh7W4tMayVlrg7S0DmGAu1N0unNuxrGsQ+m+hIVtv+VxMtSuhhlYZbAb0R0wg/iEVCYAwjkkNPmFe3zV5F+LRIWGo2yH7Y09DNx93EgpVWGLEk1c1yNjQj3G6f0hC3N5XFB+EvfGrLrAk69ttoZOFAjjONXarD9GteTIzgK0TjXSBpMdQfRU48cKdiZyb7kf7/KjWc1ca2vDaU1T+PN1hkKBsZavbyjpxS2F7zGbrGg+zZBU1tYX5NtXboFkx/TPLiygQXVOd1EZx+vi64GuO59gSJy+gL3PhbUAISfsEohEKsrfTbLl93WxdnaAg= 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:(13230025)(4636009)(136003)(346002)(396003)(39860400002)(376002)(451199018)(46966006)(36840700001)(40470700004)(356005)(921005)(1191002)(40460700003)(40480700001)(36756003)(478600001)(86362001)(82310400005)(83380400001)(63350400001)(66574015)(63370400001)(2616005)(426003)(70586007)(8676002)(70206006)(110136005)(54906003)(186003)(6666004)(316002)(336012)(1076003)(26005)(2906002)(7406005)(7416002)(30864003)(7366002)(7276002)(47076005)(7336002)(66899018)(82740400003)(81166007)(8936002)(36860700001)(4326008)(41300700001)(5660300002)(41080700001)(36900700001)(84006005)(2101003)(83996005)(579004)(559001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:33:39.9495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac94897c-6977-43d1-f7b8-08db218d9671 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: DM6NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7273 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra Acked-by: Heiko Stuebner # Rockchip drivers Reviewed-by: Michal Simek Reviewed-by: C=C3=A9dric Le Goater # Aspeed driver Reviewed-by: Dhruva Gole # SPI Cadence QSPI Reviewed-by: Patrice Chotard # spi-stm32-qspi Acked-by: William Zhang # bcm63xx-hsspi driver Reviewed-by: Serge Semin # DW SSI part --- drivers/spi/spi-altera-core.c | 2 +- drivers/spi/spi-amd.c | 4 ++-- drivers/spi/spi-ar934x.c | 2 +- drivers/spi/spi-armada-3700.c | 4 ++-- drivers/spi/spi-aspeed-smc.c | 13 +++++++------ drivers/spi/spi-at91-usart.c | 2 +- drivers/spi/spi-ath79.c | 4 ++-- drivers/spi/spi-atmel.c | 26 +++++++++++++------------- drivers/spi/spi-au1550.c | 4 ++-- drivers/spi/spi-axi-spi-engine.c | 2 +- drivers/spi/spi-bcm-qspi.c | 10 +++++----- drivers/spi/spi-bcm2835.c | 19 ++++++++++--------- drivers/spi/spi-bcm2835aux.c | 4 ++-- drivers/spi/spi-bcm63xx-hsspi.c | 30 +++++++++++++++--------------- drivers/spi/spi-bcm63xx.c | 2 +- drivers/spi/spi-bcmbca-hsspi.c | 30 +++++++++++++++--------------- drivers/spi/spi-cadence-quadspi.c | 5 +++-- drivers/spi/spi-cadence-xspi.c | 4 ++-- drivers/spi/spi-cadence.c | 4 ++-- drivers/spi/spi-cavium.c | 8 ++++---- drivers/spi/spi-coldfire-qspi.c | 8 ++++---- drivers/spi/spi-davinci.c | 18 +++++++++--------- drivers/spi/spi-dln2.c | 6 +++--- drivers/spi/spi-dw-core.c | 2 +- drivers/spi/spi-dw-mmio.c | 4 ++-- drivers/spi/spi-falcon.c | 2 +- drivers/spi/spi-fsi.c | 2 +- drivers/spi/spi-fsl-dspi.c | 16 ++++++++-------- drivers/spi/spi-fsl-espi.c | 6 +++--- drivers/spi/spi-fsl-lpspi.c | 2 +- drivers/spi/spi-fsl-qspi.c | 6 +++--- drivers/spi/spi-fsl-spi.c | 2 +- drivers/spi/spi-geni-qcom.c | 6 +++--- drivers/spi/spi-gpio.c | 4 ++-- drivers/spi/spi-gxp.c | 4 ++-- drivers/spi/spi-hisi-sfc-v3xx.c | 2 +- drivers/spi/spi-img-spfi.c | 14 +++++++------- drivers/spi/spi-imx.c | 30 +++++++++++++++--------------- drivers/spi/spi-ingenic.c | 4 ++-- drivers/spi/spi-intel.c | 2 +- drivers/spi/spi-jcore.c | 4 ++-- drivers/spi/spi-lantiq-ssc.c | 6 +++--- drivers/spi/spi-mem.c | 4 ++-- drivers/spi/spi-meson-spicc.c | 2 +- drivers/spi/spi-microchip-core.c | 6 +++--- drivers/spi/spi-mpc512x-psc.c | 8 ++++---- drivers/spi/spi-mpc52xx.c | 2 +- drivers/spi/spi-mt65xx.c | 6 +++--- drivers/spi/spi-mt7621.c | 2 +- drivers/spi/spi-mux.c | 8 ++++---- drivers/spi/spi-mxic.c | 10 +++++----- drivers/spi/spi-mxs.c | 2 +- drivers/spi/spi-npcm-fiu.c | 20 ++++++++++---------- drivers/spi/spi-nxp-fspi.c | 10 +++++----- drivers/spi/spi-omap-uwire.c | 8 ++++---- drivers/spi/spi-omap2-mcspi.c | 24 ++++++++++++------------ drivers/spi/spi-orion.c | 4 ++-- drivers/spi/spi-pci1xxxx.c | 4 ++-- drivers/spi/spi-pic32-sqi.c | 2 +- drivers/spi/spi-pic32.c | 4 ++-- drivers/spi/spi-pl022.c | 4 ++-- drivers/spi/spi-pxa2xx.c | 6 +++--- drivers/spi/spi-qcom-qspi.c | 2 +- drivers/spi/spi-rb4xx.c | 2 +- drivers/spi/spi-rockchip-sfc.c | 2 +- drivers/spi/spi-rockchip.c | 26 ++++++++++++++------------ drivers/spi/spi-rspi.c | 10 +++++----- drivers/spi/spi-s3c64xx.c | 2 +- drivers/spi/spi-sc18is602.c | 4 ++-- drivers/spi/spi-sh-msiof.c | 6 +++--- drivers/spi/spi-sh-sci.c | 2 +- drivers/spi/spi-sifive.c | 6 +++--- drivers/spi/spi-sn-f-ospi.c | 2 +- drivers/spi/spi-st-ssc4.c | 2 +- drivers/spi/spi-stm32-qspi.c | 12 ++++++------ drivers/spi/spi-sun4i.c | 2 +- drivers/spi/spi-sun6i.c | 2 +- drivers/spi/spi-synquacer.c | 6 +++--- drivers/spi/spi-tegra114.c | 28 ++++++++++++++-------------- drivers/spi/spi-tegra20-sflash.c | 2 +- drivers/spi/spi-tegra20-slink.c | 6 +++--- drivers/spi/spi-tegra210-quad.c | 8 ++++---- drivers/spi/spi-ti-qspi.c | 16 ++++++++-------- drivers/spi/spi-topcliff-pch.c | 4 ++-- drivers/spi/spi-wpcm-fiu.c | 12 ++++++------ drivers/spi/spi-xcomm.c | 2 +- drivers/spi/spi-xilinx.c | 6 +++--- drivers/spi/spi-xlp.c | 4 ++-- drivers/spi/spi-zynq-qspi.c | 2 +- drivers/spi/spi-zynqmp-gqspi.c | 2 +- drivers/spi/spidev.c | 6 +++--- include/trace/events/spi.h | 10 +++++----- 92 files changed, 333 insertions(+), 328 deletions(-) diff --git a/drivers/spi/spi-altera-core.c b/drivers/spi/spi-altera-core.c index 94fe6bf1b9a6..87e37f48f196 100644 --- a/drivers/spi/spi-altera-core.c +++ b/drivers/spi/spi-altera-core.c @@ -80,7 +80,7 @@ static void altera_spi_set_cs(struct spi_device *spi, boo= l is_high) altr_spi_writel(hw, ALTERA_SPI_TARGET_SEL, 0); } else { altr_spi_writel(hw, ALTERA_SPI_TARGET_SEL, - BIT(spi->chip_select)); + BIT(spi_get_chipselect(spi, 0))); hw->imr |=3D ALTERA_SPI_CONTROL_SSO_MSK; altr_spi_writel(hw, ALTERA_SPI_CONTROL, hw->imr); } diff --git a/drivers/spi/spi-amd.c b/drivers/spi/spi-amd.c index bfc3ab5f39ea..fecead757a3c 100644 --- a/drivers/spi/spi-amd.c +++ b/drivers/spi/spi-amd.c @@ -347,7 +347,7 @@ static inline int amd_spi_fifo_xfer(struct amd_spi *amd= _spi, case AMD_SPI_V1: break; case AMD_SPI_V2: - amd_spi_clear_chip(amd_spi, message->spi->chip_select); + amd_spi_clear_chip(amd_spi, spi_get_chipselect(message->spi, 0)); break; default: return -ENODEV; @@ -364,7 +364,7 @@ static int amd_spi_master_transfer(struct spi_master *m= aster, struct amd_spi *amd_spi =3D spi_master_get_devdata(master); struct spi_device *spi =3D msg->spi; =20 - amd_spi_select_chip(amd_spi, spi->chip_select); + amd_spi_select_chip(amd_spi, spi_get_chipselect(spi, 0)); =20 /* * Extract spi_transfers from the spi message and diff --git a/drivers/spi/spi-ar934x.c b/drivers/spi/spi-ar934x.c index c71c8348eeaa..9dcada8c4cb9 100644 --- a/drivers/spi/spi-ar934x.c +++ b/drivers/spi/spi-ar934x.c @@ -125,7 +125,7 @@ static int ar934x_spi_transfer_one_message(struct spi_c= ontroller *ctlr, iowrite32(reg, sp->base + AR934X_SPI_DATAOUT); } =20 - reg =3D AR934X_SPI_SHIFT_VAL(spi->chip_select, term, + reg =3D AR934X_SPI_SHIFT_VAL(spi_get_chipselect(spi, 0), term, trx_cur * 8); iowrite32(reg, sp->base + AR934X_SPI_REG_SHIFT_CTRL); stat =3D readl_poll_timeout( diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c index 6a7e605f73bf..a7fb7c94e70e 100644 --- a/drivers/spi/spi-armada-3700.c +++ b/drivers/spi/spi-armada-3700.c @@ -437,9 +437,9 @@ static void a3700_spi_set_cs(struct spi_device *spi, bo= ol enable) struct a3700_spi *a3700_spi =3D spi_controller_get_devdata(spi->controlle= r); =20 if (!enable) - a3700_spi_activate_cs(a3700_spi, spi->chip_select); + a3700_spi_activate_cs(a3700_spi, spi_get_chipselect(spi, 0)); else - a3700_spi_deactivate_cs(a3700_spi, spi->chip_select); + a3700_spi_deactivate_cs(a3700_spi, spi_get_chipselect(spi, 0)); } =20 static void a3700_spi_header_set(struct a3700_spi *a3700_spi) diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c index 3f2548860317..e75b0d51f06a 100644 --- a/drivers/spi/spi-aspeed-smc.c +++ b/drivers/spi/spi-aspeed-smc.c @@ -296,7 +296,7 @@ static const struct aspeed_spi_data ast2400_spi_data; static int do_aspeed_spi_exec_op(struct spi_mem *mem, const struct spi_mem= _op *op) { struct aspeed_spi *aspi =3D spi_controller_get_devdata(mem->spi->master); - struct aspeed_spi_chip *chip =3D &aspi->chips[mem->spi->chip_select]; + struct aspeed_spi_chip *chip =3D &aspi->chips[spi_get_chipselect(mem->spi= , 0)]; u32 addr_mode, addr_mode_backup; u32 ctl_val; int ret =3D 0; @@ -377,7 +377,8 @@ static const char *aspeed_spi_get_name(struct spi_mem *= mem) struct aspeed_spi *aspi =3D spi_controller_get_devdata(mem->spi->master); struct device *dev =3D aspi->dev; =20 - return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev), mem->spi->= chip_select); + return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev), + spi_get_chipselect(mem->spi, 0)); } =20 struct aspeed_spi_window { @@ -553,7 +554,7 @@ static int aspeed_spi_do_calibration(struct aspeed_spi_= chip *chip); static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc) { struct aspeed_spi *aspi =3D spi_controller_get_devdata(desc->mem->spi->ma= ster); - struct aspeed_spi_chip *chip =3D &aspi->chips[desc->mem->spi->chip_select= ]; + struct aspeed_spi_chip *chip =3D &aspi->chips[spi_get_chipselect(desc->me= m->spi, 0)]; struct spi_mem_op *op =3D &desc->info.op_tmpl; u32 ctl_val; int ret =3D 0; @@ -620,7 +621,7 @@ static ssize_t aspeed_spi_dirmap_read(struct spi_mem_di= rmap_desc *desc, u64 offset, size_t len, void *buf) { struct aspeed_spi *aspi =3D spi_controller_get_devdata(desc->mem->spi->ma= ster); - struct aspeed_spi_chip *chip =3D &aspi->chips[desc->mem->spi->chip_select= ]; + struct aspeed_spi_chip *chip =3D &aspi->chips[spi_get_chipselect(desc->me= m->spi, 0)]; =20 /* Switch to USER command mode if mapping window is too small */ if (chip->ahb_window_size < offset + len) { @@ -670,7 +671,7 @@ static int aspeed_spi_setup(struct spi_device *spi) { struct aspeed_spi *aspi =3D spi_controller_get_devdata(spi->master); const struct aspeed_spi_data *data =3D aspi->data; - unsigned int cs =3D spi->chip_select; + unsigned int cs =3D spi_get_chipselect(spi, 0); struct aspeed_spi_chip *chip =3D &aspi->chips[cs]; =20 chip->aspi =3D aspi; @@ -697,7 +698,7 @@ static int aspeed_spi_setup(struct spi_device *spi) static void aspeed_spi_cleanup(struct spi_device *spi) { struct aspeed_spi *aspi =3D spi_controller_get_devdata(spi->master); - unsigned int cs =3D spi->chip_select; + unsigned int cs =3D spi_get_chipselect(spi, 0); =20 aspeed_spi_chip_enable(aspi, cs, false); =20 diff --git a/drivers/spi/spi-at91-usart.c b/drivers/spi/spi-at91-usart.c index 4fb3653b5941..7854d9790fe9 100644 --- a/drivers/spi/spi-at91-usart.c +++ b/drivers/spi/spi-at91-usart.c @@ -390,7 +390,7 @@ static int at91_usart_spi_setup(struct spi_device *spi) =20 dev_dbg(&spi->dev, "setup: bpw %u mode 0x%x -> mr %d %08x\n", - spi->bits_per_word, spi->mode, spi->chip_select, mr); + spi->bits_per_word, spi->mode, spi_get_chipselect(spi, 0), mr); =20 return 0; } diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c index b4d25b3bee19..d3dd21386f12 100644 --- a/drivers/spi/spi-ath79.c +++ b/drivers/spi/spi-ath79.c @@ -71,7 +71,7 @@ static void ath79_spi_chipselect(struct spi_device *spi, = int is_active) { struct ath79_spi *sp =3D ath79_spidev_to_sp(spi); int cs_high =3D (spi->mode & SPI_CS_HIGH) ? is_active : !is_active; - u32 cs_bit =3D AR71XX_SPI_IOC_CS(spi->chip_select); + u32 cs_bit =3D AR71XX_SPI_IOC_CS(spi_get_chipselect(spi, 0)); =20 if (cs_high) sp->ioc_base |=3D cs_bit; @@ -140,7 +140,7 @@ static int ath79_exec_mem_op(struct spi_mem *mem, struct ath79_spi *sp =3D ath79_spidev_to_sp(mem->spi); =20 /* Ensures that reading is performed on device connected to hardware cs0 = */ - if (mem->spi->chip_select || mem->spi->cs_gpiod) + if (spi_get_chipselect(mem->spi, 0) || spi_get_csgpiod(mem->spi, 0)) return -ENOTSUPP; =20 /* Only use for fast-read op. */ diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 73f80c8ac2ff..7f06305e16cb 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -327,10 +327,10 @@ static void cs_activate(struct atmel_spi *as, struct = spi_device *spi) int chip_select; u32 mr; =20 - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) chip_select =3D as->native_cs_for_gpio; else - chip_select =3D spi->chip_select; + chip_select =3D spi_get_chipselect(spi, 0); =20 if (atmel_spi_is_v2(as)) { spi_writel(as, CSR0 + 4 * chip_select, asd->csr); @@ -378,10 +378,10 @@ static void cs_deactivate(struct atmel_spi *as, struc= t spi_device *spi) int chip_select; u32 mr; =20 - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) chip_select =3D as->native_cs_for_gpio; else - chip_select =3D spi->chip_select; + chip_select =3D spi_get_chipselect(spi, 0); =20 /* only deactivate *this* device; sometimes transfers to * another device may be active when this routine is called. @@ -394,7 +394,7 @@ static void cs_deactivate(struct atmel_spi *as, struct = spi_device *spi) =20 dev_dbg(&spi->dev, "DEactivate NPCS, mr %08x\n", mr); =20 - if (!spi->cs_gpiod) + if (!spi_get_csgpiod(spi, 0)) spi_writel(as, CR, SPI_BIT(LASTXFER)); } =20 @@ -800,10 +800,10 @@ static int atmel_spi_set_xfer_speed(struct atmel_spi = *as, unsigned long bus_hz; int chip_select; =20 - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) chip_select =3D as->native_cs_for_gpio; else - chip_select =3D spi->chip_select; + chip_select =3D spi_get_chipselect(spi, 0); =20 /* v1 chips start out at half the peripheral bus speed. */ bus_hz =3D as->spi_clk; @@ -1189,7 +1189,7 @@ static int atmel_spi_setup(struct spi_device *spi) as =3D spi_controller_get_devdata(spi->controller); =20 /* see notes above re chipselect */ - if (!spi->cs_gpiod && (spi->mode & SPI_CS_HIGH)) { + if (!spi_get_csgpiod(spi, 0) && (spi->mode & SPI_CS_HIGH)) { dev_warn(&spi->dev, "setup: non GPIO CS can't be active-high\n"); return -EINVAL; } @@ -1201,16 +1201,16 @@ static int atmel_spi_setup(struct spi_device *spi) */ initialize_native_cs_for_gpio(as); =20 - if (spi->cs_gpiod && as->native_cs_free) { + if (spi_get_csgpiod(spi, 0) && as->native_cs_free) { dev_err(&spi->dev, "No native CS available to support this GPIO CS\n"); return -EBUSY; } =20 - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) chip_select =3D as->native_cs_for_gpio; else - chip_select =3D spi->chip_select; + chip_select =3D spi_get_chipselect(spi, 0); =20 csr =3D SPI_BF(BITS, bits - 8); if (spi->mode & SPI_CPOL) @@ -1218,7 +1218,7 @@ static int atmel_spi_setup(struct spi_device *spi) if (!(spi->mode & SPI_CPHA)) csr |=3D SPI_BIT(NCPHA); =20 - if (!spi->cs_gpiod) + if (!spi_get_csgpiod(spi, 0)) csr |=3D SPI_BIT(CSAAT); csr |=3D SPI_BF(DLYBS, 0); =20 @@ -1244,7 +1244,7 @@ static int atmel_spi_setup(struct spi_device *spi) =20 dev_dbg(&spi->dev, "setup: bpw %u mode 0x%x -> csr%d %08x\n", - bits, spi->mode, spi->chip_select, csr); + bits, spi->mode, spi_get_chipselect(spi, 0), csr); =20 if (!atmel_spi_is_v2(as)) spi_writel(as, CSR0 + 4 * chip_select, csr); diff --git a/drivers/spi/spi-au1550.c b/drivers/spi/spi-au1550.c index 8151bed8a117..0b57e6afce0f 100644 --- a/drivers/spi/spi-au1550.c +++ b/drivers/spi/spi-au1550.c @@ -166,7 +166,7 @@ static void au1550_spi_chipsel(struct spi_device *spi, = int value) switch (value) { case BITBANG_CS_INACTIVE: if (hw->pdata->deactivate_cs) - hw->pdata->deactivate_cs(hw->pdata, spi->chip_select, + hw->pdata->deactivate_cs(hw->pdata, spi_get_chipselect(spi, 0), cspol); break; =20 @@ -211,7 +211,7 @@ static void au1550_spi_chipsel(struct spi_device *spi, = int value) } while ((stat & PSC_SPISTAT_DR) =3D=3D 0); =20 if (hw->pdata->activate_cs) - hw->pdata->activate_cs(hw->pdata, spi->chip_select, + hw->pdata->activate_cs(hw->pdata, spi_get_chipselect(spi, 0), cspol); break; } diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-eng= ine.c index c5a3a3189164..89661f3b0d44 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -193,7 +193,7 @@ static void spi_engine_gen_cs(struct spi_engine_program= *p, bool dry, unsigned int mask =3D 0xff; =20 if (assert) - mask ^=3D BIT(spi->chip_select); + mask ^=3D BIT(spi_get_chipselect(spi, 0)); =20 spi_engine_program_add_cmd(p, dry, SPI_ENGINE_CMD_ASSERT(1, mask)); } diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c index 0eee574d3e1f..7c2f1d1fb3f7 100644 --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -986,7 +986,7 @@ static int write_to_hw(struct bcm_qspi *qspi, struct sp= i_device *spi) if (has_bspi(qspi)) mspi_cdram &=3D ~1; else - mspi_cdram |=3D (~(1 << spi->chip_select) & + mspi_cdram |=3D (~(1 << spi_get_chipselect(spi, 0)) & MSPI_CDRAM_PCS); =20 write_cdram_slot(qspi, slot, mspi_cdram); @@ -1046,8 +1046,8 @@ static int bcm_qspi_bspi_exec_mem_op(struct spi_devic= e *spi, return -EIO; =20 from =3D op->addr.val; - if (!spi->cs_gpiod) - bcm_qspi_chip_select(qspi, spi->chip_select); + if (!spi_get_csgpiod(spi, 0)) + bcm_qspi_chip_select(qspi, spi_get_chipselect(spi, 0)); bcm_qspi_write(qspi, MSPI, MSPI_WRITE_LOCK, 0); =20 /* @@ -1126,8 +1126,8 @@ static int bcm_qspi_transfer_one(struct spi_master *m= aster, int slots; unsigned long timeo =3D msecs_to_jiffies(100); =20 - if (!spi->cs_gpiod) - bcm_qspi_chip_select(qspi, spi->chip_select); + if (!spi_get_csgpiod(spi, 0)) + bcm_qspi_chip_select(qspi, spi_get_chipselect(spi, 0)); qspi->trans_pos.trans =3D trans; qspi->trans_pos.byte =3D 0; =20 diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index 747e03228c48..6b7a3fa93fdf 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -1274,9 +1274,9 @@ static int bcm2835_spi_setup(struct spi_device *spi) * The SPI core has successfully requested the CS GPIO line from the * device tree, so we are done. */ - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) return 0; - if (spi->chip_select > 1) { + if (spi_get_chipselect(spi, 0) > 1) { /* error in the case of native CS requested with CS > 1 * officially there is a CS2, but it is not documented * which GPIO is connected with that... @@ -1301,18 +1301,19 @@ static int bcm2835_spi_setup(struct spi_device *spi) if (!chip) return 0; =20 - spi->cs_gpiod =3D gpiochip_request_own_desc(chip, 8 - spi->chip_select, - DRV_NAME, - GPIO_LOOKUP_FLAGS_DEFAULT, - GPIOD_OUT_LOW); - if (IS_ERR(spi->cs_gpiod)) { - ret =3D PTR_ERR(spi->cs_gpiod); + spi_set_csgpiod(spi, 0, gpiochip_request_own_desc(chip, + 8 - (spi_get_chipselect(spi, 0)), + DRV_NAME, + GPIO_LOOKUP_FLAGS_DEFAULT, + GPIOD_OUT_LOW)); + if (IS_ERR(spi_get_csgpiod(spi, 0))) { + ret =3D PTR_ERR(spi_get_csgpiod(spi, 0)); goto err_cleanup; } =20 /* and set up the "mode" and level */ dev_info(&spi->dev, "setting up native-CS%i to use GPIO\n", - spi->chip_select); + spi_get_chipselect(spi, 0)); =20 return 0; =20 diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c index 7f2546fd900a..288f7b994b36 100644 --- a/drivers/spi/spi-bcm2835aux.c +++ b/drivers/spi/spi-bcm2835aux.c @@ -448,7 +448,7 @@ static int bcm2835aux_spi_setup(struct spi_device *spi) if (spi->mode & SPI_NO_CS) return 0; =20 - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) return 0; =20 /* for dt-backwards compatibility: only support native on CS0 @@ -465,7 +465,7 @@ static int bcm2835aux_spi_setup(struct spi_device *spi) dev_warn(&spi->dev, "Native CS is not supported - please configure cs-gpio in device-tree\n= "); =20 - if (spi->chip_select =3D=3D 0) + if (spi_get_chipselect(spi, 0) =3D=3D 0) return 0; =20 dev_warn(&spi->dev, "Native CS is not working for cs > 0\n"); diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hssp= i.c index f2708caa2f33..ee2528dad02d 100644 --- a/drivers/spi/spi-bcm63xx-hsspi.c +++ b/drivers/spi/spi-bcm63xx-hsspi.c @@ -349,7 +349,7 @@ static int bcm63xx_hsspi_do_prepend_txrx(struct spi_dev= ice *spi, struct spi_transfer *t) { struct bcm63xx_hsspi *bs =3D spi_master_get_devdata(spi->master); - unsigned int chip_select =3D spi->chip_select; + unsigned int chip_select =3D spi_get_chipselect(spi, 0); u16 opcode =3D 0, val; const u8 *tx =3D t->tx_buf; u8 *rx =3D t->rx_buf; @@ -441,7 +441,7 @@ static void bcm63xx_hsspi_set_cs(struct bcm63xx_hsspi *= bs, unsigned int cs, static void bcm63xx_hsspi_set_clk(struct bcm63xx_hsspi *bs, struct spi_device *spi, int hz) { - unsigned int profile =3D spi->chip_select; + unsigned int profile =3D spi_get_chipselect(spi, 0); u32 reg; =20 reg =3D DIV_ROUND_UP(2048, DIV_ROUND_UP(bs->speed_hz, hz)); @@ -468,7 +468,7 @@ static void bcm63xx_hsspi_set_clk(struct bcm63xx_hsspi = *bs, static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transf= er *t) { struct bcm63xx_hsspi *bs =3D spi_master_get_devdata(spi->master); - unsigned int chip_select =3D spi->chip_select; + unsigned int chip_select =3D spi_get_chipselect(spi, 0); u16 opcode =3D 0, val; int pending =3D t->len; int step_size =3D HSSPI_BUFFER_LEN; @@ -478,7 +478,7 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi= , struct spi_transfer *t) =20 bcm63xx_hsspi_set_clk(bs, spi, t->speed_hz); if (!t->cs_off) - bcm63xx_hsspi_set_cs(bs, spi->chip_select, true); + bcm63xx_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), true); =20 if (tx && rx) opcode =3D HSSPI_OP_READ_WRITE; @@ -545,14 +545,14 @@ static int bcm63xx_hsspi_setup(struct spi_device *spi) u32 reg; =20 reg =3D __raw_readl(bs->regs + - HSSPI_PROFILE_SIGNAL_CTRL_REG(spi->chip_select)); + HSSPI_PROFILE_SIGNAL_CTRL_REG(spi_get_chipselect(spi, 0))); reg &=3D ~(SIGNAL_CTRL_LAUNCH_RISING | SIGNAL_CTRL_LATCH_RISING); if (spi->mode & SPI_CPHA) reg |=3D SIGNAL_CTRL_LAUNCH_RISING; else reg |=3D SIGNAL_CTRL_LATCH_RISING; __raw_writel(reg, bs->regs + - HSSPI_PROFILE_SIGNAL_CTRL_REG(spi->chip_select)); + HSSPI_PROFILE_SIGNAL_CTRL_REG(spi_get_chipselect(spi, 0))); =20 mutex_lock(&bs->bus_mutex); reg =3D __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG); @@ -560,16 +560,16 @@ static int bcm63xx_hsspi_setup(struct spi_device *spi) /* only change actual polarities if there is no transfer */ if ((reg & GLOBAL_CTRL_CS_POLARITY_MASK) =3D=3D bs->cs_polarity) { if (spi->mode & SPI_CS_HIGH) - reg |=3D BIT(spi->chip_select); + reg |=3D BIT(spi_get_chipselect(spi, 0)); else - reg &=3D ~BIT(spi->chip_select); + reg &=3D ~BIT(spi_get_chipselect(spi, 0)); __raw_writel(reg, bs->regs + HSSPI_GLOBAL_CTRL_REG); } =20 if (spi->mode & SPI_CS_HIGH) - bs->cs_polarity |=3D BIT(spi->chip_select); + bs->cs_polarity |=3D BIT(spi_get_chipselect(spi, 0)); else - bs->cs_polarity &=3D ~BIT(spi->chip_select); + bs->cs_polarity &=3D ~BIT(spi_get_chipselect(spi, 0)); =20 mutex_unlock(&bs->bus_mutex); =20 @@ -600,7 +600,7 @@ static int bcm63xx_hsspi_do_dummy_cs_txrx(struct spi_de= vice *spi, * e. At the end restore the polarities again to their default values. */ =20 - dummy_cs =3D !spi->chip_select; + dummy_cs =3D !spi_get_chipselect(spi, 0); bcm63xx_hsspi_set_cs(bs, dummy_cs, true); =20 list_for_each_entry(t, &msg->transfers, transfer_list) { @@ -633,22 +633,22 @@ static int bcm63xx_hsspi_do_dummy_cs_txrx(struct spi_= device *spi, keep_cs =3D true; } else { if (!t->cs_off) - bcm63xx_hsspi_set_cs(bs, spi->chip_select, false); + bcm63xx_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false); =20 spi_transfer_cs_change_delay_exec(msg, t); =20 if (!list_next_entry(t, transfer_list)->cs_off) - bcm63xx_hsspi_set_cs(bs, spi->chip_select, true); + bcm63xx_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), true); } } else if (!list_is_last(&t->transfer_list, &msg->transfers) && t->cs_off !=3D list_next_entry(t, transfer_list)->cs_off) { - bcm63xx_hsspi_set_cs(bs, spi->chip_select, t->cs_off); + bcm63xx_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), t->cs_off); } } =20 bcm63xx_hsspi_set_cs(bs, dummy_cs, false); if (status || !keep_cs) - bcm63xx_hsspi_set_cs(bs, spi->chip_select, false); + bcm63xx_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false); =20 return status; } diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c index 77b8328c8a6d..96633a0051b1 100644 --- a/drivers/spi/spi-bcm63xx.c +++ b/drivers/spi/spi-bcm63xx.c @@ -282,7 +282,7 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, st= ruct spi_transfer *first, /* Issue the transfer */ cmd =3D SPI_CMD_START_IMMEDIATE; cmd |=3D (prepend_len << SPI_CMD_PREPEND_BYTE_CNT_SHIFT); - cmd |=3D (spi->chip_select << SPI_CMD_DEVICE_ID_SHIFT); + cmd |=3D (spi_get_chipselect(spi, 0) << SPI_CMD_DEVICE_ID_SHIFT); bcm_spi_writew(bs, cmd, SPI_CMD); =20 /* Enable the CMD_DONE interrupt */ diff --git a/drivers/spi/spi-bcmbca-hsspi.c b/drivers/spi/spi-bcmbca-hsspi.c index c7a44832bc9c..8cbd01619789 100644 --- a/drivers/spi/spi-bcmbca-hsspi.c +++ b/drivers/spi/spi-bcmbca-hsspi.c @@ -193,7 +193,7 @@ static void bcmbca_hsspi_set_cs(struct bcmbca_hsspi *bs= , unsigned int cs, static void bcmbca_hsspi_set_clk(struct bcmbca_hsspi *bs, struct spi_device *spi, int hz) { - unsigned int profile =3D spi->chip_select; + unsigned int profile =3D spi_get_chipselect(spi, 0); u32 reg; =20 reg =3D DIV_ROUND_UP(2048, DIV_ROUND_UP(bs->speed_hz, hz)); @@ -251,7 +251,7 @@ static int bcmbca_hsspi_do_txrx(struct spi_device *spi,= struct spi_transfer *t, struct spi_message *msg) { struct bcmbca_hsspi *bs =3D spi_master_get_devdata(spi->master); - unsigned int chip_select =3D spi->chip_select; + unsigned int chip_select =3D spi_get_chipselect(spi, 0); u16 opcode =3D 0, val; int pending =3D t->len; int step_size =3D HSSPI_BUFFER_LEN; @@ -312,7 +312,7 @@ static int bcmbca_hsspi_do_txrx(struct spi_device *spi,= struct spi_transfer *t, PINGPONG_COMMAND_START_NOW; __raw_writel(reg, bs->regs + HSSPI_PINGPONG_COMMAND_REG(0)); =20 - if (bcmbca_hsspi_wait_cmd(bs, spi->chip_select)) + if (bcmbca_hsspi_wait_cmd(bs, spi_get_chipselect(spi, 0))) return -ETIMEDOUT; =20 pending -=3D curr_step; @@ -332,33 +332,33 @@ static int bcmbca_hsspi_setup(struct spi_device *spi) u32 reg; =20 reg =3D __raw_readl(bs->regs + - HSSPI_PROFILE_SIGNAL_CTRL_REG(spi->chip_select)); + HSSPI_PROFILE_SIGNAL_CTRL_REG(spi_get_chipselect(spi, 0))); reg &=3D ~(SIGNAL_CTRL_LAUNCH_RISING | SIGNAL_CTRL_LATCH_RISING); if (spi->mode & SPI_CPHA) reg |=3D SIGNAL_CTRL_LAUNCH_RISING; else reg |=3D SIGNAL_CTRL_LATCH_RISING; __raw_writel(reg, bs->regs + - HSSPI_PROFILE_SIGNAL_CTRL_REG(spi->chip_select)); + HSSPI_PROFILE_SIGNAL_CTRL_REG(spi_get_chipselect(spi, 0))); =20 mutex_lock(&bs->bus_mutex); reg =3D __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG); =20 if (spi->mode & SPI_CS_HIGH) - reg |=3D BIT(spi->chip_select); + reg |=3D BIT(spi_get_chipselect(spi, 0)); else - reg &=3D ~BIT(spi->chip_select); + reg &=3D ~BIT(spi_get_chipselect(spi, 0)); __raw_writel(reg, bs->regs + HSSPI_GLOBAL_CTRL_REG); =20 if (spi->mode & SPI_CS_HIGH) - bs->cs_polarity |=3D BIT(spi->chip_select); + bs->cs_polarity |=3D BIT(spi_get_chipselect(spi, 0)); else - bs->cs_polarity &=3D ~BIT(spi->chip_select); + bs->cs_polarity &=3D ~BIT(spi_get_chipselect(spi, 0)); =20 reg =3D __raw_readl(bs->spim_ctrl); - reg &=3D ~BIT(spi->chip_select + SPIM_CTRL_CS_OVERRIDE_VAL_SHIFT); + reg &=3D ~BIT(spi_get_chipselect(spi, 0) + SPIM_CTRL_CS_OVERRIDE_VAL_SHIF= T); if (spi->mode & SPI_CS_HIGH) - reg |=3D BIT(spi->chip_select + SPIM_CTRL_CS_OVERRIDE_VAL_SHIFT); + reg |=3D BIT(spi_get_chipselect(spi, 0) + SPIM_CTRL_CS_OVERRIDE_VAL_SHIF= T); __raw_writel(reg, bs->spim_ctrl); =20 mutex_unlock(&bs->bus_mutex); @@ -388,16 +388,16 @@ static int bcmbca_hsspi_transfer_one(struct spi_maste= r *master, keep_cs =3D true; } else { if (!t->cs_off) - bcmbca_hsspi_set_cs(bs, spi->chip_select, false); + bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false); =20 spi_transfer_cs_change_delay_exec(msg, t); =20 if (!list_next_entry(t, transfer_list)->cs_off) - bcmbca_hsspi_set_cs(bs, spi->chip_select, true); + bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), true); } } else if (!list_is_last(&t->transfer_list, &msg->transfers) && t->cs_off !=3D list_next_entry(t, transfer_list)->cs_off) { - bcmbca_hsspi_set_cs(bs, spi->chip_select, t->cs_off); + bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), t->cs_off); } =20 msg->actual_length +=3D t->len; @@ -406,7 +406,7 @@ static int bcmbca_hsspi_transfer_one(struct spi_master = *master, mutex_unlock(&bs->msg_mutex); =20 if (status || !keep_cs) - bcmbca_hsspi_set_cs(bs, spi->chip_select, false); + bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false); =20 msg->status =3D status; spi_finalize_current_message(master); diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 463fd49f4f80..79ab7e309644 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1355,7 +1355,7 @@ static int cqspi_mem_process(struct spi_mem *mem, con= st struct spi_mem_op *op) struct cqspi_st *cqspi =3D spi_master_get_devdata(mem->spi->master); struct cqspi_flash_pdata *f_pdata; =20 - f_pdata =3D &cqspi->f_pdata[mem->spi->chip_select]; + f_pdata =3D &cqspi->f_pdata[spi_get_chipselect(mem->spi, 0)]; cqspi_configure(f_pdata, mem->spi->max_speed_hz); =20 if (op->data.dir =3D=3D SPI_MEM_DATA_IN && op->data.buf.in) { @@ -1561,7 +1561,8 @@ static const char *cqspi_get_name(struct spi_mem *mem) struct cqspi_st *cqspi =3D spi_master_get_devdata(mem->spi->master); struct device *dev =3D &cqspi->pdev->dev; =20 - return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev), mem->spi->= chip_select); + return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev), + spi_get_chipselect(mem->spi, 0)); } =20 static const struct spi_controller_mem_ops cqspi_mem_ops =3D { diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c index 91db3c973167..ce4a3145f065 100644 --- a/drivers/spi/spi-cadence-xspi.c +++ b/drivers/spi/spi-cadence-xspi.c @@ -409,8 +409,8 @@ static int cdns_xspi_mem_op(struct cdns_xspi_dev *cdns_= xspi, { enum spi_mem_data_dir dir =3D op->data.dir; =20 - if (cdns_xspi->cur_cs !=3D mem->spi->chip_select) - cdns_xspi->cur_cs =3D mem->spi->chip_select; + if (cdns_xspi->cur_cs !=3D spi_get_chipselect(mem->spi, 0)) + cdns_xspi->cur_cs =3D spi_get_chipselect(mem->spi, 0); =20 return cdns_xspi_send_stig_command(cdns_xspi, op, (dir !=3D SPI_MEM_NO_DATA)); diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c index 1ad86e5d2b2f..49936237e583 100644 --- a/drivers/spi/spi-cadence.c +++ b/drivers/spi/spi-cadence.c @@ -185,11 +185,11 @@ static void cdns_spi_chipselect(struct spi_device *sp= i, bool is_high) /* Select the slave */ ctrl_reg &=3D ~CDNS_SPI_CR_SSCTRL; if (!(xspi->is_decoded_cs)) - ctrl_reg |=3D ((~(CDNS_SPI_SS0 << spi->chip_select)) << + ctrl_reg |=3D ((~(CDNS_SPI_SS0 << spi_get_chipselect(spi, 0))) << CDNS_SPI_SS_SHIFT) & CDNS_SPI_CR_SSCTRL; else - ctrl_reg |=3D (spi->chip_select << CDNS_SPI_SS_SHIFT) & + ctrl_reg |=3D (spi_get_chipselect(spi, 0) << CDNS_SPI_SS_SHIFT) & CDNS_SPI_CR_SSCTRL; } =20 diff --git a/drivers/spi/spi-cavium.c b/drivers/spi/spi-cavium.c index 6854c3ce423b..dfe224defd6e 100644 --- a/drivers/spi/spi-cavium.c +++ b/drivers/spi/spi-cavium.c @@ -57,8 +57,8 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, mpi_cfg.s.cslate =3D cpha ? 1 : 0; mpi_cfg.s.enable =3D 1; =20 - if (spi->chip_select < 4) - p->cs_enax |=3D 1ull << (12 + spi->chip_select); + if (spi_get_chipselect(spi, 0) < 4) + p->cs_enax |=3D 1ull << (12 + spi_get_chipselect(spi, 0)); mpi_cfg.u64 |=3D p->cs_enax; =20 if (mpi_cfg.u64 !=3D p->last_cfg) { @@ -78,7 +78,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, writeq(d, p->register_base + OCTEON_SPI_DAT0(p) + (8 * i)); } mpi_tx.u64 =3D 0; - mpi_tx.s.csid =3D spi->chip_select; + mpi_tx.s.csid =3D spi_get_chipselect(spi, 0); mpi_tx.s.leavecs =3D 1; mpi_tx.s.txnum =3D tx_buf ? OCTEON_SPI_MAX_BYTES : 0; mpi_tx.s.totnum =3D OCTEON_SPI_MAX_BYTES; @@ -103,7 +103,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, } =20 mpi_tx.u64 =3D 0; - mpi_tx.s.csid =3D spi->chip_select; + mpi_tx.s.csid =3D spi_get_chipselect(spi, 0); if (last_xfer) mpi_tx.s.leavecs =3D xfer->cs_change; else diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qsp= i.c index d98e74c6e4b2..b1bd8a6b5bf9 100644 --- a/drivers/spi/spi-coldfire-qspi.c +++ b/drivers/spi/spi-coldfire-qspi.c @@ -290,9 +290,9 @@ static void mcfqspi_set_cs(struct spi_device *spi, bool= enable) bool cs_high =3D spi->mode & SPI_CS_HIGH; =20 if (enable) - mcfqspi_cs_select(mcfqspi, spi->chip_select, cs_high); + mcfqspi_cs_select(mcfqspi, spi_get_chipselect(spi, 0), cs_high); else - mcfqspi_cs_deselect(mcfqspi, spi->chip_select, cs_high); + mcfqspi_cs_deselect(mcfqspi, spi_get_chipselect(spi, 0), cs_high); } =20 static int mcfqspi_transfer_one(struct spi_master *master, @@ -324,11 +324,11 @@ static int mcfqspi_transfer_one(struct spi_master *ma= ster, static int mcfqspi_setup(struct spi_device *spi) { mcfqspi_cs_deselect(spi_master_get_devdata(spi->master), - spi->chip_select, spi->mode & SPI_CS_HIGH); + spi_get_chipselect(spi, 0), spi->mode & SPI_CS_HIGH); =20 dev_dbg(&spi->dev, "bits per word %d, chip select %d, speed %d KHz\n", - spi->bits_per_word, spi->chip_select, + spi->bits_per_word, spi_get_chipselect(spi, 0), (MCFQSPI_BUSCLK / mcfqspi_qmr_baud(spi->max_speed_hz)) / 1000); =20 diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index add1e198a439..b04811c911e2 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -199,7 +199,7 @@ static void davinci_spi_chipselect(struct spi_device *s= pi, int value) { struct davinci_spi *dspi; struct davinci_spi_config *spicfg =3D spi->controller_data; - u8 chip_sel =3D spi->chip_select; + u8 chip_sel =3D spi_get_chipselect(spi, 0); u16 spidat1 =3D CS_DEFAULT; =20 dspi =3D spi_master_get_devdata(spi->master); @@ -212,11 +212,11 @@ static void davinci_spi_chipselect(struct spi_device = *spi, int value) * Board specific chip select logic decides the polarity and cs * line for the controller */ - if (spi->cs_gpiod) { + if (spi_get_csgpiod(spi, 0)) { if (value =3D=3D BITBANG_CS_ACTIVE) - gpiod_set_value(spi->cs_gpiod, 1); + gpiod_set_value(spi_get_csgpiod(spi, 0), 1); else - gpiod_set_value(spi->cs_gpiod, 0); + gpiod_set_value(spi_get_csgpiod(spi, 0), 0); } else { if (value =3D=3D BITBANG_CS_ACTIVE) { if (!(spi->mode & SPI_CS_WORD)) @@ -293,11 +293,11 @@ static int davinci_spi_setup_transfer(struct spi_devi= ce *spi, if (bits_per_word <=3D 8) { dspi->get_rx =3D davinci_spi_rx_buf_u8; dspi->get_tx =3D davinci_spi_tx_buf_u8; - dspi->bytes_per_word[spi->chip_select] =3D 1; + dspi->bytes_per_word[spi_get_chipselect(spi, 0)] =3D 1; } else { dspi->get_rx =3D davinci_spi_rx_buf_u16; dspi->get_tx =3D davinci_spi_tx_buf_u16; - dspi->bytes_per_word[spi->chip_select] =3D 2; + dspi->bytes_per_word[spi_get_chipselect(spi, 0)] =3D 2; } =20 if (!hz) @@ -415,11 +415,11 @@ static int davinci_spi_setup(struct spi_device *spi) dspi =3D spi_master_get_devdata(spi->master); =20 if (!(spi->mode & SPI_NO_CS)) { - if (np && spi->cs_gpiod) + if (np && spi_get_csgpiod(spi, 0)) internal_cs =3D false; =20 if (internal_cs) - set_io_bits(dspi->base + SPIPC0, 1 << spi->chip_select); + set_io_bits(dspi->base + SPIPC0, 1 << spi_get_chipselect(spi, 0)); } =20 if (spi->mode & SPI_READY) @@ -579,7 +579,7 @@ static int davinci_spi_bufs(struct spi_device *spi, str= uct spi_transfer *t) spicfg =3D &davinci_spi_default_cfg; =20 /* convert len to words based on bits_per_word */ - data_type =3D dspi->bytes_per_word[spi->chip_select]; + data_type =3D dspi->bytes_per_word[spi_get_chipselect(spi, 0)]; =20 dspi->tx =3D t->tx_buf; dspi->rx =3D t->rx_buf; diff --git a/drivers/spi/spi-dln2.c b/drivers/spi/spi-dln2.c index 821bfc6b0dd6..6bd93c47853c 100644 --- a/drivers/spi/spi-dln2.c +++ b/drivers/spi/spi-dln2.c @@ -596,12 +596,12 @@ static int dln2_spi_prepare_message(struct spi_master= *master, struct dln2_spi *dln2 =3D spi_master_get_devdata(master); struct spi_device *spi =3D message->spi; =20 - if (dln2->cs !=3D spi->chip_select) { - ret =3D dln2_spi_cs_set_one(dln2, spi->chip_select); + if (dln2->cs !=3D spi_get_chipselect(spi, 0)) { + ret =3D dln2_spi_cs_set_one(dln2, spi_get_chipselect(spi, 0)); if (ret < 0) return ret; =20 - dln2->cs =3D spi->chip_select; + dln2->cs =3D spi_get_chipselect(spi, 0); } =20 return 0; diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index c3bfb6c84cab..ae3108c70f50 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -103,7 +103,7 @@ void dw_spi_set_cs(struct spi_device *spi, bool enable) * support active-high or active-low CS level. */ if (cs_high =3D=3D enable) - dw_writel(dws, DW_SPI_SER, BIT(spi->chip_select)); + dw_writel(dws, DW_SPI_SER, BIT(spi_get_chipselect(spi, 0))); else dw_writel(dws, DW_SPI_SER, 0); } diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index 6ae124c30969..328541b5fb52 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -65,7 +65,7 @@ static void dw_spi_mscc_set_cs(struct spi_device *spi, bo= ol enable) struct dw_spi *dws =3D spi_master_get_devdata(spi->master); struct dw_spi_mmio *dwsmmio =3D container_of(dws, struct dw_spi_mmio, dws= ); struct dw_spi_mscc *dwsmscc =3D dwsmmio->priv; - u32 cs =3D spi->chip_select; + u32 cs =3D spi_get_chipselect(spi, 0); =20 if (cs < 4) { u32 sw_mode =3D MSCC_SPI_MST_SW_MODE_SW_PIN_CTRL_MODE; @@ -138,7 +138,7 @@ static void dw_spi_sparx5_set_cs(struct spi_device *spi= , bool enable) struct dw_spi *dws =3D spi_master_get_devdata(spi->master); struct dw_spi_mmio *dwsmmio =3D container_of(dws, struct dw_spi_mmio, dws= ); struct dw_spi_mscc *dwsmscc =3D dwsmmio->priv; - u8 cs =3D spi->chip_select; + u8 cs =3D spi_get_chipselect(spi, 0); =20 if (!enable) { /* CS override drive enable */ diff --git a/drivers/spi/spi-falcon.c b/drivers/spi/spi-falcon.c index a7d4dffac66b..4c103dff0d44 100644 --- a/drivers/spi/spi-falcon.c +++ b/drivers/spi/spi-falcon.c @@ -131,7 +131,7 @@ int falcon_sflash_xfer(struct spi_device *spi, struct s= pi_transfer *t, * especially alen and dumlen. */ =20 - priv->sfcmd =3D ((spi->chip_select + priv->sfcmd =3D ((spi_get_chipselect(spi, 0) << SFCMD_CS_OFFSET) & SFCMD_CS_MASK); priv->sfcmd |=3D SFCMD_KEEP_CS_KEEP_SELECTED; diff --git a/drivers/spi/spi-fsi.c b/drivers/spi/spi-fsi.c index cf1e4f9ebd72..ba3b17d7c9ec 100644 --- a/drivers/spi/spi-fsi.c +++ b/drivers/spi/spi-fsi.c @@ -425,7 +425,7 @@ static int fsi_spi_transfer_one_message(struct spi_cont= roller *ctlr, struct spi_message *mesg) { int rc; - u8 seq_slave =3D SPI_FSI_SEQUENCE_SEL_SLAVE(mesg->spi->chip_select + 1); + u8 seq_slave =3D SPI_FSI_SEQUENCE_SEL_SLAVE(spi_get_chipselect(mesg->spi,= 0) + 1); unsigned int len; struct spi_transfer *transfer; struct fsi_spi *ctx =3D spi_controller_get_devdata(ctlr); diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 49df00f52ea4..ee42285b5c52 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -902,19 +902,19 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_= id) =20 static void dspi_assert_cs(struct spi_device *spi, bool *cs) { - if (!spi->cs_gpiod || *cs) + if (!spi_get_csgpiod(spi, 0) || *cs) return; =20 - gpiod_set_value_cansleep(spi->cs_gpiod, true); + gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), true); *cs =3D true; } =20 static void dspi_deassert_cs(struct spi_device *spi, bool *cs) { - if (!spi->cs_gpiod || !*cs) + if (!spi_get_csgpiod(spi, 0) || !*cs) return; =20 - gpiod_set_value_cansleep(spi->cs_gpiod, false); + gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), false); *cs =3D false; } =20 @@ -938,8 +938,8 @@ static int dspi_transfer_one_message(struct spi_control= ler *ctlr, =20 /* Prepare command word for CMD FIFO */ dspi->tx_cmd =3D SPI_PUSHR_CMD_CTAS(0); - if (!spi->cs_gpiod) - dspi->tx_cmd |=3D SPI_PUSHR_CMD_PCS(spi->chip_select); + if (!spi_get_csgpiod(spi, 0)) + dspi->tx_cmd |=3D SPI_PUSHR_CMD_PCS(spi_get_chipselect(spi, 0)); =20 if (list_is_last(&dspi->cur_transfer->transfer_list, &dspi->cur_msg->transfers)) { @@ -1058,7 +1058,7 @@ static int dspi_setup(struct spi_device *spi) chip->ctar_val |=3D SPI_CTAR_LSBFE; } =20 - gpiod_direction_output(spi->cs_gpiod, false); + gpiod_direction_output(spi_get_csgpiod(spi, 0), false); dspi_deassert_cs(spi, &cs); =20 spi_set_ctldata(spi, chip); @@ -1071,7 +1071,7 @@ static void dspi_cleanup(struct spi_device *spi) struct chip_data *chip =3D spi_get_ctldata((struct spi_device *)spi); =20 dev_dbg(&spi->dev, "spi_device %u.%u cleanup\n", - spi->controller->bus_num, spi->chip_select); + spi->controller->bus_num, spi_get_chipselect(spi, 0)); =20 kfree(chip); } diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 42a3ed79e7dc..b3d2d3db5850 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -345,7 +345,7 @@ static void fsl_espi_setup_transfer(struct spi_device *= spi, =20 /* don't write the mode register if the mode doesn't change */ if (cs->hw_mode !=3D hw_mode_old) - fsl_espi_write_reg(espi, ESPI_SPMODEx(spi->chip_select), + fsl_espi_write_reg(espi, ESPI_SPMODEx(spi_get_chipselect(spi, 0)), cs->hw_mode); } =20 @@ -359,7 +359,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct= spi_transfer *t) reinit_completion(&espi->done); =20 /* Set SPCOM[CS] and SPCOM[TRANLEN] field */ - spcom =3D SPCOM_CS(spi->chip_select); + spcom =3D SPCOM_CS(spi_get_chipselect(spi, 0)); spcom |=3D SPCOM_TRANLEN(t->len - 1); =20 /* configure RXSKIP mode */ @@ -492,7 +492,7 @@ static int fsl_espi_setup(struct spi_device *spi) =20 pm_runtime_get_sync(espi->dev); =20 - cs->hw_mode =3D fsl_espi_read_reg(espi, ESPI_SPMODEx(spi->chip_select)); + cs->hw_mode =3D fsl_espi_read_reg(espi, ESPI_SPMODEx(spi_get_chipselect(s= pi, 0))); /* mask out bits we are going to set */ cs->hw_mode &=3D ~(CSMODE_CP_BEGIN_EDGECLK | CSMODE_CI_INACTIVEHIGH | CSMODE_REV); diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c index b9e8b7b241a4..f2341ab99556 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -425,7 +425,7 @@ static int fsl_lpspi_setup_transfer(struct spi_controll= er *controller, if (fsl_lpspi->is_only_cs1) fsl_lpspi->config.chip_select =3D 1; else - fsl_lpspi->config.chip_select =3D spi->chip_select; + fsl_lpspi->config.chip_select =3D spi_get_chipselect(spi, 0); =20 if (!fsl_lpspi->config.speed_hz) fsl_lpspi->config.speed_hz =3D spi->max_speed_hz; diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c index bacc54836959..8ade61e5ebc0 100644 --- a/drivers/spi/spi-fsl-qspi.c +++ b/drivers/spi/spi-fsl-qspi.c @@ -528,7 +528,7 @@ static void fsl_qspi_select_mem(struct fsl_qspi *q, str= uct spi_device *spi) unsigned long rate =3D spi->max_speed_hz; int ret; =20 - if (q->selected =3D=3D spi->chip_select) + if (q->selected =3D=3D spi_get_chipselect(spi, 0)) return; =20 if (needs_4x_clock(q)) @@ -544,7 +544,7 @@ static void fsl_qspi_select_mem(struct fsl_qspi *q, str= uct spi_device *spi) if (ret) return; =20 - q->selected =3D spi->chip_select; + q->selected =3D spi_get_chipselect(spi, 0); =20 fsl_qspi_invalidate(q); } @@ -823,7 +823,7 @@ static const char *fsl_qspi_get_name(struct spi_mem *me= m) =20 name =3D devm_kasprintf(dev, GFP_KERNEL, "%s-%d", dev_name(q->dev), - mem->spi->chip_select); + spi_get_chipselect(mem->spi, 0)); =20 if (!name) { dev_err(dev, "failed to get memory for custom flash name\n"); diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 725d043488a1..702756c25aa7 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -503,7 +503,7 @@ static void fsl_spi_grlib_cs_control(struct spi_device = *spi, bool on) struct mpc8xxx_spi *mpc8xxx_spi =3D spi_master_get_devdata(spi->master); struct fsl_spi_reg __iomem *reg_base =3D mpc8xxx_spi->reg_base; u32 slvsel; - u16 cs =3D spi->chip_select; + u16 cs =3D spi_get_chipselect(spi, 0); =20 if (cs < mpc8xxx_spi->native_chipselects) { slvsel =3D mpc8xxx_spi_read_reg(®_base->slvsel); diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index f80635532b4d..ba7be505ec4e 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -391,9 +391,9 @@ static int setup_fifo_params(struct spi_device *spi_slv, cpha =3D CPHA; =20 if (spi_slv->mode & SPI_CS_HIGH) - demux_output_inv =3D BIT(spi_slv->chip_select); + demux_output_inv =3D BIT(spi_get_chipselect(spi_slv, 0)); =20 - demux_sel =3D spi_slv->chip_select; + demux_sel =3D spi_get_chipselect(spi_slv, 0); mas->cur_bits_per_word =3D spi_slv->bits_per_word; =20 spi_setup_word_len(mas, spi_slv->mode, spi_slv->bits_per_word); @@ -469,7 +469,7 @@ static int setup_gsi_xfer(struct spi_transfer *xfer, st= ruct spi_geni_master *mas peripheral.loopback_en =3D !!(spi_slv->mode & SPI_LOOP); peripheral.clock_pol_high =3D !!(spi_slv->mode & SPI_CPOL); peripheral.data_pol_high =3D !!(spi_slv->mode & SPI_CPHA); - peripheral.cs =3D spi_slv->chip_select; + peripheral.cs =3D spi_get_chipselect(spi_slv, 0); peripheral.pack_en =3D true; peripheral.word_len =3D xfer->bits_per_word - MIN_WORD_LEN; =20 diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c index 9c8c7948044e..092afc7679d4 100644 --- a/drivers/spi/spi-gpio.c +++ b/drivers/spi/spi-gpio.c @@ -230,7 +230,7 @@ static void spi_gpio_chipselect(struct spi_device *spi,= int is_active) =20 /* Drive chip select line, if we have one */ if (spi_gpio->cs_gpios) { - struct gpio_desc *cs =3D spi_gpio->cs_gpios[spi->chip_select]; + struct gpio_desc *cs =3D spi_gpio->cs_gpios[spi_get_chipselect(spi, 0)]; =20 /* SPI chip selects are normally active-low */ gpiod_set_value_cansleep(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is= _active); @@ -248,7 +248,7 @@ static int spi_gpio_setup(struct spi_device *spi) * initialized from the descriptor lookup. */ if (spi_gpio->cs_gpios) { - cs =3D spi_gpio->cs_gpios[spi->chip_select]; + cs =3D spi_gpio->cs_gpios[spi_get_chipselect(spi, 0)]; if (!spi->controller_state && cs) status =3D gpiod_direction_output(cs, !(spi->mode & SPI_CS_HIGH)); diff --git a/drivers/spi/spi-gxp.c b/drivers/spi/spi-gxp.c index c900c2f39b57..684d63f402f3 100644 --- a/drivers/spi/spi-gxp.c +++ b/drivers/spi/spi-gxp.c @@ -201,7 +201,7 @@ static ssize_t gxp_spi_write(struct gxp_spi_chip *chip,= const struct spi_mem_op static int do_gxp_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op= *op) { struct gxp_spi *spifi =3D spi_controller_get_devdata(mem->spi->master); - struct gxp_spi_chip *chip =3D &spifi->chips[mem->spi->chip_select]; + struct gxp_spi_chip *chip =3D &spifi->chips[spi_get_chipselect(mem->spi, = 0)]; int ret; =20 if (op->data.dir =3D=3D SPI_MEM_DATA_IN) { @@ -237,7 +237,7 @@ static const struct spi_controller_mem_ops gxp_spi_mem_= ops =3D { static int gxp_spi_setup(struct spi_device *spi) { struct gxp_spi *spifi =3D spi_controller_get_devdata(spi->master); - unsigned int cs =3D spi->chip_select; + unsigned int cs =3D spi_get_chipselect(spi, 0); struct gxp_spi_chip *chip =3D &spifi->chips[cs]; =20 chip->spifi =3D spifi; diff --git a/drivers/spi/spi-hisi-sfc-v3xx.c b/drivers/spi/spi-hisi-sfc-v3x= x.c index f07d1045a30a..7cbcb065bb44 100644 --- a/drivers/spi/spi-hisi-sfc-v3xx.c +++ b/drivers/spi/spi-hisi-sfc-v3xx.c @@ -361,7 +361,7 @@ static int hisi_sfc_v3xx_exec_op(struct spi_mem *mem, { struct hisi_sfc_v3xx_host *host; struct spi_device *spi =3D mem->spi; - u8 chip_select =3D spi->chip_select; + u8 chip_select =3D spi_get_chipselect(spi, 0); =20 host =3D spi_controller_get_devdata(spi->master); =20 diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c index c64e4fd3fdf0..d775f87770e3 100644 --- a/drivers/spi/spi-img-spfi.c +++ b/drivers/spi/spi-img-spfi.c @@ -413,15 +413,15 @@ static int img_spfi_prepare(struct spi_master *master= , struct spi_message *msg) val =3D spfi_readl(spfi, SPFI_PORT_STATE); val &=3D ~(SPFI_PORT_STATE_DEV_SEL_MASK << SPFI_PORT_STATE_DEV_SEL_SHIFT); - val |=3D msg->spi->chip_select << SPFI_PORT_STATE_DEV_SEL_SHIFT; + val |=3D spi_get_chipselect(msg->spi, 0) << SPFI_PORT_STATE_DEV_SEL_SHIFT; if (msg->spi->mode & SPI_CPHA) - val |=3D SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select); + val |=3D SPFI_PORT_STATE_CK_PHASE(spi_get_chipselect(msg->spi, 0)); else - val &=3D ~SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select); + val &=3D ~SPFI_PORT_STATE_CK_PHASE(spi_get_chipselect(msg->spi, 0)); if (msg->spi->mode & SPI_CPOL) - val |=3D SPFI_PORT_STATE_CK_POL(msg->spi->chip_select); + val |=3D SPFI_PORT_STATE_CK_POL(spi_get_chipselect(msg->spi, 0)); else - val &=3D ~SPFI_PORT_STATE_CK_POL(msg->spi->chip_select); + val &=3D ~SPFI_PORT_STATE_CK_POL(spi_get_chipselect(msg->spi, 0)); spfi_writel(spfi, val, SPFI_PORT_STATE); =20 return 0; @@ -450,11 +450,11 @@ static void img_spfi_config(struct spi_master *master= , struct spi_device *spi, div =3D DIV_ROUND_UP(clk_get_rate(spfi->spfi_clk), xfer->speed_hz); div =3D clamp(512 / (1 << get_count_order(div)), 1, 128); =20 - val =3D spfi_readl(spfi, SPFI_DEVICE_PARAMETER(spi->chip_select)); + val =3D spfi_readl(spfi, SPFI_DEVICE_PARAMETER(spi_get_chipselect(spi, 0)= )); val &=3D ~(SPFI_DEVICE_PARAMETER_BITCLK_MASK << SPFI_DEVICE_PARAMETER_BITCLK_SHIFT); val |=3D div << SPFI_DEVICE_PARAMETER_BITCLK_SHIFT; - spfi_writel(spfi, val, SPFI_DEVICE_PARAMETER(spi->chip_select)); + spfi_writel(spfi, val, SPFI_DEVICE_PARAMETER(spi_get_chipselect(spi, 0))); =20 spfi_writel(spfi, xfer->len << SPFI_TRANSACTION_TSIZE_SHIFT, SPFI_TRANSACTION); diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index e4ccd0c329d0..620bce96b1f9 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -528,7 +528,7 @@ static int mx51_ecspi_prepare_message(struct spi_imx_da= ta *spi_imx, ctrl |=3D MX51_ECSPI_CTRL_DRCTL(spi_imx->spi_drctl); =20 /* set chip select to use */ - ctrl |=3D MX51_ECSPI_CTRL_CS(spi->chip_select); + ctrl |=3D MX51_ECSPI_CTRL_CS(spi_get_chipselect(spi, 0)); =20 /* * The ctrl register must be written first, with the EN bit set other @@ -549,22 +549,22 @@ static int mx51_ecspi_prepare_message(struct spi_imx_= data *spi_imx, * BURST_LENGTH + 1 bits are received */ if (spi_imx->slave_mode && is_imx53_ecspi(spi_imx)) - cfg &=3D ~MX51_ECSPI_CONFIG_SBBCTRL(spi->chip_select); + cfg &=3D ~MX51_ECSPI_CONFIG_SBBCTRL(spi_get_chipselect(spi, 0)); else - cfg |=3D MX51_ECSPI_CONFIG_SBBCTRL(spi->chip_select); + cfg |=3D MX51_ECSPI_CONFIG_SBBCTRL(spi_get_chipselect(spi, 0)); =20 if (spi->mode & SPI_CPOL) { - cfg |=3D MX51_ECSPI_CONFIG_SCLKPOL(spi->chip_select); - cfg |=3D MX51_ECSPI_CONFIG_SCLKCTL(spi->chip_select); + cfg |=3D MX51_ECSPI_CONFIG_SCLKPOL(spi_get_chipselect(spi, 0)); + cfg |=3D MX51_ECSPI_CONFIG_SCLKCTL(spi_get_chipselect(spi, 0)); } else { - cfg &=3D ~MX51_ECSPI_CONFIG_SCLKPOL(spi->chip_select); - cfg &=3D ~MX51_ECSPI_CONFIG_SCLKCTL(spi->chip_select); + cfg &=3D ~MX51_ECSPI_CONFIG_SCLKPOL(spi_get_chipselect(spi, 0)); + cfg &=3D ~MX51_ECSPI_CONFIG_SCLKCTL(spi_get_chipselect(spi, 0)); } =20 if (spi->mode & SPI_CS_HIGH) - cfg |=3D MX51_ECSPI_CONFIG_SSBPOL(spi->chip_select); + cfg |=3D MX51_ECSPI_CONFIG_SSBPOL(spi_get_chipselect(spi, 0)); else - cfg &=3D ~MX51_ECSPI_CONFIG_SSBPOL(spi->chip_select); + cfg &=3D ~MX51_ECSPI_CONFIG_SSBPOL(spi_get_chipselect(spi, 0)); =20 if (cfg =3D=3D current_cfg) return 0; @@ -614,9 +614,9 @@ static void mx51_configure_cpha(struct spi_imx_data *sp= i_imx, cpha ^=3D flip_cpha; =20 if (cpha) - cfg |=3D MX51_ECSPI_CONFIG_SCLKPHA(spi->chip_select); + cfg |=3D MX51_ECSPI_CONFIG_SCLKPHA(spi_get_chipselect(spi, 0)); else - cfg &=3D ~MX51_ECSPI_CONFIG_SCLKPHA(spi->chip_select); + cfg &=3D ~MX51_ECSPI_CONFIG_SCLKPHA(spi_get_chipselect(spi, 0)); =20 writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG); } @@ -768,8 +768,8 @@ static int mx31_prepare_transfer(struct spi_imx_data *s= pi_imx, reg |=3D MX31_CSPICTRL_POL; if (spi->mode & SPI_CS_HIGH) reg |=3D MX31_CSPICTRL_SSPOL; - if (!spi->cs_gpiod) - reg |=3D (spi->chip_select) << + if (!spi_get_csgpiod(spi, 0)) + reg |=3D (spi_get_chipselect(spi, 0)) << (is_imx35_cspi(spi_imx) ? MX35_CSPICTRL_CS_SHIFT : MX31_CSPICTRL_CS_SHIFT); =20 @@ -868,8 +868,8 @@ static int mx21_prepare_transfer(struct spi_imx_data *s= pi_imx, reg |=3D MX21_CSPICTRL_POL; if (spi->mode & SPI_CS_HIGH) reg |=3D MX21_CSPICTRL_SSPOL; - if (!spi->cs_gpiod) - reg |=3D spi->chip_select << MX21_CSPICTRL_CS_SHIFT; + if (!spi_get_csgpiod(spi, 0)) + reg |=3D spi_get_chipselect(spi, 0) << MX21_CSPICTRL_CS_SHIFT; =20 writel(reg, spi_imx->base + MXC_CSPICTRL); =20 diff --git a/drivers/spi/spi-ingenic.c b/drivers/spi/spi-ingenic.c index 713a238bee63..7d4b515a160d 100644 --- a/drivers/spi/spi-ingenic.c +++ b/drivers/spi/spi-ingenic.c @@ -263,7 +263,7 @@ static int spi_ingenic_prepare_message(struct spi_contr= oller *ctlr, { struct ingenic_spi *priv =3D spi_controller_get_devdata(ctlr); struct spi_device *spi =3D message->spi; - unsigned int cs =3D REG_SSICR1_FRMHL << spi->chip_select; + unsigned int cs =3D REG_SSICR1_FRMHL << spi_get_chipselect(spi, 0); unsigned int ssicr0_mask =3D REG_SSICR0_LOOP | REG_SSICR0_FSEL; unsigned int ssicr1_mask =3D REG_SSICR1_PHA | REG_SSICR1_POL | cs; unsigned int ssicr0 =3D 0, ssicr1 =3D 0; @@ -282,7 +282,7 @@ static int spi_ingenic_prepare_message(struct spi_contr= oller *ctlr, =20 if (spi->mode & SPI_LOOP) ssicr0 |=3D REG_SSICR0_LOOP; - if (spi->chip_select) + if (spi_get_chipselect(spi, 0)) ssicr0 |=3D REG_SSICR0_FSEL; =20 if (spi->mode & SPI_CPHA) diff --git a/drivers/spi/spi-intel.c b/drivers/spi/spi-intel.c index f4679868c49f..bc6d22149e7e 100644 --- a/drivers/spi/spi-intel.c +++ b/drivers/spi/spi-intel.c @@ -451,7 +451,7 @@ static u32 intel_spi_chip_addr(const struct intel_spi *= ispi, /* Pick up the correct start address */ if (!mem) return 0; - return mem->spi->chip_select =3D=3D 1 ? ispi->chip0_size : 0; + return (spi_get_chipselect(mem->spi, 0) =3D=3D 1) ? ispi->chip0_size : 0; } =20 static int intel_spi_read_reg(struct intel_spi *ispi, const struct spi_mem= *mem, diff --git a/drivers/spi/spi-jcore.c b/drivers/spi/spi-jcore.c index 74c8319c29f1..c42a3358e8c9 100644 --- a/drivers/spi/spi-jcore.c +++ b/drivers/spi/spi-jcore.c @@ -68,9 +68,9 @@ static void jcore_spi_program(struct jcore_spi *hw) static void jcore_spi_chipsel(struct spi_device *spi, bool value) { struct jcore_spi *hw =3D spi_master_get_devdata(spi->master); - u32 csbit =3D 1U << (2 * spi->chip_select); + u32 csbit =3D 1U << (2 * spi_get_chipselect(spi, 0)); =20 - dev_dbg(hw->master->dev.parent, "chipselect %d\n", spi->chip_select); + dev_dbg(hw->master->dev.parent, "chipselect %d\n", spi_get_chipselect(spi= , 0)); =20 if (value) hw->cs_reg |=3D csbit; diff --git a/drivers/spi/spi-lantiq-ssc.c b/drivers/spi/spi-lantiq-ssc.c index 76cf2a66f874..8d6ecc5d6f70 100644 --- a/drivers/spi/spi-lantiq-ssc.c +++ b/drivers/spi/spi-lantiq-ssc.c @@ -388,11 +388,11 @@ static int lantiq_ssc_setup(struct spi_device *spidev) { struct spi_master *master =3D spidev->master; struct lantiq_ssc_spi *spi =3D spi_master_get_devdata(master); - unsigned int cs =3D spidev->chip_select; + unsigned int cs =3D spi_get_chipselect(spidev, 0); u32 gpocon; =20 /* GPIOs are used for CS */ - if (spidev->cs_gpiod) + if (spi_get_csgpiod(spidev, 0)) return 0; =20 dev_dbg(spi->dev, "using internal chipselect %u\n", cs); @@ -796,7 +796,7 @@ static void lantiq_ssc_handle_err(struct spi_master *ma= ster, static void lantiq_ssc_set_cs(struct spi_device *spidev, bool enable) { struct lantiq_ssc_spi *spi =3D spi_master_get_devdata(spidev->master); - unsigned int cs =3D spidev->chip_select; + unsigned int cs =3D spi_get_chipselect(spidev, 0); u32 fgpo; =20 if (!!(spidev->mode & SPI_CS_HIGH) =3D=3D enable) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 701838b6f0c4..edd7430d4c05 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -325,7 +325,7 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct s= pi_mem_op *op) if (!spi_mem_internal_supports_op(mem, op)) return -ENOTSUPP; =20 - if (ctlr->mem_ops && ctlr->mem_ops->exec_op && !mem->spi->cs_gpiod) { + if (ctlr->mem_ops && ctlr->mem_ops->exec_op && !spi_get_csgpiod(mem->spi,= 0)) { ret =3D spi_mem_access_start(mem); if (ret) return ret; @@ -808,7 +808,7 @@ int spi_mem_poll_status(struct spi_mem *mem, op->data.dir !=3D SPI_MEM_DATA_IN) return -EINVAL; =20 - if (ctlr->mem_ops && ctlr->mem_ops->poll_status && !mem->spi->cs_gpiod) { + if (ctlr->mem_ops && ctlr->mem_ops->poll_status && !spi_get_csgpiod(mem->= spi, 0)) { ret =3D spi_mem_access_start(mem); if (ret) return ret; diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c index b9f812837cd6..141562c882f1 100644 --- a/drivers/spi/spi-meson-spicc.c +++ b/drivers/spi/spi-meson-spicc.c @@ -505,7 +505,7 @@ static int meson_spicc_prepare_message(struct spi_maste= r *master, conf |=3D FIELD_PREP(SPICC_DRCTL_MASK, SPICC_DRCTL_IGNORE); =20 /* Select CS */ - conf |=3D FIELD_PREP(SPICC_CS_MASK, spi->chip_select); + conf |=3D FIELD_PREP(SPICC_CS_MASK, spi_get_chipselect(spi, 0)); =20 /* Default 8bit word */ conf |=3D FIELD_PREP(SPICC_BITLENGTH_MASK, 8 - 1); diff --git a/drivers/spi/spi-microchip-core.c b/drivers/spi/spi-microchip-c= ore.c index e6cf6ff08061..b59e8a0c5b97 100644 --- a/drivers/spi/spi-microchip-core.c +++ b/drivers/spi/spi-microchip-core.c @@ -247,8 +247,8 @@ static void mchp_corespi_set_cs(struct spi_device *spi,= bool disable) struct mchp_corespi *corespi =3D spi_master_get_devdata(spi->master); =20 reg =3D mchp_corespi_read(corespi, REG_SLAVE_SELECT); - reg &=3D ~BIT(spi->chip_select); - reg |=3D !disable << spi->chip_select; + reg &=3D ~BIT(spi_get_chipselect(spi, 0)); + reg |=3D !disable << spi_get_chipselect(spi, 0); =20 mchp_corespi_write(corespi, REG_SLAVE_SELECT, reg); } @@ -265,7 +265,7 @@ static int mchp_corespi_setup(struct spi_device *spi) */ if (spi->mode & SPI_CS_HIGH) { reg =3D mchp_corespi_read(corespi, REG_SLAVE_SELECT); - reg |=3D BIT(spi->chip_select); + reg |=3D BIT(spi_get_chipselect(spi, 0)); mchp_corespi_write(corespi, REG_SLAVE_SELECT, reg); } return 0; diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 0b86f1804682..99aeef28a477 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -121,17 +121,17 @@ static void mpc512x_psc_spi_activate_cs(struct spi_de= vice *spi) out_be32(psc_addr(mps, ccr), ccr); mps->bits_per_word =3D cs->bits_per_word; =20 - if (spi->cs_gpiod) { + if (spi_get_csgpiod(spi, 0)) { /* gpiolib will deal with the inversion */ - gpiod_set_value(spi->cs_gpiod, 1); + gpiod_set_value(spi_get_csgpiod(spi, 0), 1); } } =20 static void mpc512x_psc_spi_deactivate_cs(struct spi_device *spi) { - if (spi->cs_gpiod) { + if (spi_get_csgpiod(spi, 0)) { /* gpiolib will deal with the inversion */ - gpiod_set_value(spi->cs_gpiod, 0); + gpiod_set_value(spi_get_csgpiod(spi, 0), 0); } } =20 diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c index b652fb196622..ab7df5f64342 100644 --- a/drivers/spi/spi-mpc52xx.c +++ b/drivers/spi/spi-mpc52xx.c @@ -101,7 +101,7 @@ static void mpc52xx_spi_chipsel(struct mpc52xx_spi *ms,= int value) int cs; =20 if (ms->gpio_cs_count > 0) { - cs =3D ms->message->spi->chip_select; + cs =3D spi_get_chipselect(ms->message->spi, 0); gpiod_set_value(ms->gpio_cs[cs], value); } else { out_8(ms->regs + SPI_PORTDATA, value ? 0 : 0x08); diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 9eab6c20dbc5..21c321f43766 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -421,7 +421,7 @@ static int mtk_spi_hw_init(struct spi_master *master, =20 /* pad select */ if (mdata->dev_comp->need_pad_sel) - writel(mdata->pad_sel[spi->chip_select], + writel(mdata->pad_sel[spi_get_chipselect(spi, 0)], mdata->base + SPI_PAD_SEL_REG); =20 /* tick delay */ @@ -735,9 +735,9 @@ static int mtk_spi_setup(struct spi_device *spi) if (!spi->controller_data) spi->controller_data =3D (void *)&mtk_default_chip_info; =20 - if (mdata->dev_comp->need_pad_sel && spi->cs_gpiod) + if (mdata->dev_comp->need_pad_sel && spi_get_csgpiod(spi, 0)) /* CS de-asserted, gpiolib will handle inversion */ - gpiod_direction_output(spi->cs_gpiod, 0); + gpiod_direction_output(spi_get_csgpiod(spi, 0), 0); =20 return 0; } diff --git a/drivers/spi/spi-mt7621.c b/drivers/spi/spi-mt7621.c index c4cc8e2f85e2..3e9d396b33bd 100644 --- a/drivers/spi/spi-mt7621.c +++ b/drivers/spi/spi-mt7621.c @@ -76,7 +76,7 @@ static inline void mt7621_spi_write(struct mt7621_spi *rs= , u32 reg, u32 val) static void mt7621_spi_set_cs(struct spi_device *spi, int enable) { struct mt7621_spi *rs =3D spidev_to_mt7621_spi(spi); - int cs =3D spi->chip_select; + int cs =3D spi_get_chipselect(spi, 0); u32 polar =3D 0; u32 master; =20 diff --git a/drivers/spi/spi-mux.c b/drivers/spi/spi-mux.c index 0709e987bd5a..fa8c1f740c70 100644 --- a/drivers/spi/spi-mux.c +++ b/drivers/spi/spi-mux.c @@ -51,22 +51,22 @@ static int spi_mux_select(struct spi_device *spi) struct spi_mux_priv *priv =3D spi_controller_get_devdata(spi->controller); int ret; =20 - ret =3D mux_control_select(priv->mux, spi->chip_select); + ret =3D mux_control_select(priv->mux, spi_get_chipselect(spi, 0)); if (ret) return ret; =20 - if (priv->current_cs =3D=3D spi->chip_select) + if (priv->current_cs =3D=3D spi_get_chipselect(spi, 0)) return 0; =20 dev_dbg(&priv->spi->dev, "setting up the mux for cs %d\n", - spi->chip_select); + spi_get_chipselect(spi, 0)); =20 /* copy the child device's settings except for the cs */ priv->spi->max_speed_hz =3D spi->max_speed_hz; priv->spi->mode =3D spi->mode; priv->spi->bits_per_word =3D spi->bits_per_word; =20 - priv->current_cs =3D spi->chip_select; + priv->current_cs =3D spi_get_chipselect(spi, 0); =20 return 0; } diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c index 10727ea53043..00617fd4b2c3 100644 --- a/drivers/spi/spi-mxic.c +++ b/drivers/spi/spi-mxic.c @@ -306,8 +306,8 @@ static u32 mxic_spi_prep_hc_cfg(struct spi_device *spi,= u32 flags) nio =3D 2; =20 return flags | HC_CFG_NIO(nio) | - HC_CFG_TYPE(spi->chip_select, HC_CFG_TYPE_SPI_NOR) | - HC_CFG_SLV_ACT(spi->chip_select) | HC_CFG_IDLE_SIO_LVL(1); + HC_CFG_TYPE(spi_get_chipselect(spi, 0), HC_CFG_TYPE_SPI_NOR) | + HC_CFG_SLV_ACT(spi_get_chipselect(spi, 0)) | HC_CFG_IDLE_SIO_LVL(1= ); } =20 static u32 mxic_spi_mem_prep_op_cfg(const struct spi_mem_op *op, @@ -405,7 +405,7 @@ static ssize_t mxic_spi_mem_dirmap_read(struct spi_mem_= dirmap_desc *desc, len =3D min_t(size_t, len, mxic->linear.size); writel(len, mxic->regs + LRD_RANGE); writel(LMODE_CMD0(desc->info.op_tmpl.cmd.opcode) | - LMODE_SLV_ACT(desc->mem->spi->chip_select) | + LMODE_SLV_ACT(spi_get_chipselect(desc->mem->spi, 0)) | LMODE_EN, mxic->regs + LRD_CTRL); =20 @@ -449,7 +449,7 @@ static ssize_t mxic_spi_mem_dirmap_write(struct spi_mem= _dirmap_desc *desc, len =3D min_t(size_t, len, mxic->linear.size); writel(len, mxic->regs + LWR_RANGE); writel(LMODE_CMD0(desc->info.op_tmpl.cmd.opcode) | - LMODE_SLV_ACT(desc->mem->spi->chip_select) | + LMODE_SLV_ACT(spi_get_chipselect(desc->mem->spi, 0)) | LMODE_EN, mxic->regs + LWR_CTRL); =20 @@ -524,7 +524,7 @@ static int mxic_spi_mem_exec_op(struct spi_mem *mem, writel(HC_EN_BIT, mxic->regs + HC_EN); =20 writel(mxic_spi_mem_prep_op_cfg(op, op->data.nbytes), - mxic->regs + SS_CTRL(mem->spi->chip_select)); + mxic->regs + SS_CTRL(spi_get_chipselect(mem->spi, 0))); =20 writel(readl(mxic->regs + HC_CFG) | HC_CFG_MAN_CS_ASSERT, mxic->regs + HC_CFG); diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c index 10fb31a5e409..963a53dd680b 100644 --- a/drivers/spi/spi-mxs.c +++ b/drivers/spi/spi-mxs.c @@ -369,7 +369,7 @@ static int mxs_spi_transfer_one(struct spi_master *mast= er, /* Program CS register bits here, it will be used for all transfers. */ writel(BM_SSP_CTRL0_WAIT_FOR_CMD | BM_SSP_CTRL0_WAIT_FOR_IRQ, ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR); - writel(mxs_spi_cs_to_reg(m->spi->chip_select), + writel(mxs_spi_cs_to_reg(spi_get_chipselect(m->spi, 0)), ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET); =20 list_for_each_entry(t, &m->transfers, transfer_list) { diff --git a/drivers/spi/spi-npcm-fiu.c b/drivers/spi/spi-npcm-fiu.c index 8d7698d167ef..eb353561509a 100644 --- a/drivers/spi/spi-npcm-fiu.c +++ b/drivers/spi/spi-npcm-fiu.c @@ -288,7 +288,7 @@ static ssize_t npcm_fiu_direct_read(struct spi_mem_dirm= ap_desc *desc, { struct npcm_fiu_spi *fiu =3D spi_controller_get_devdata(desc->mem->spi->master); - struct npcm_fiu_chip *chip =3D &fiu->chip[desc->mem->spi->chip_select]; + struct npcm_fiu_chip *chip =3D &fiu->chip[spi_get_chipselect(desc->mem->s= pi, 0)]; void __iomem *src =3D (void __iomem *)(chip->flash_region_mapped_ptr + offs); u8 *buf_rx =3D buf; @@ -315,7 +315,7 @@ static ssize_t npcm_fiu_direct_write(struct spi_mem_dir= map_desc *desc, { struct npcm_fiu_spi *fiu =3D spi_controller_get_devdata(desc->mem->spi->master); - struct npcm_fiu_chip *chip =3D &fiu->chip[desc->mem->spi->chip_select]; + struct npcm_fiu_chip *chip =3D &fiu->chip[spi_get_chipselect(desc->mem->s= pi, 0)]; void __iomem *dst =3D (void __iomem *)(chip->flash_region_mapped_ptr + offs); const u8 *buf_tx =3D buf; @@ -344,7 +344,7 @@ static int npcm_fiu_uma_read(struct spi_mem *mem, =20 regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CTS, NPCM_FIU_UMA_CTS_DEV_NUM, - (mem->spi->chip_select << + (spi_get_chipselect(mem->spi, 0) << NPCM_FIU_UMA_CTS_DEV_NUM_SHIFT)); regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CMD, NPCM_FIU_UMA_CMD_CMD, op->cmd.opcode); @@ -398,7 +398,7 @@ static int npcm_fiu_uma_write(struct spi_mem *mem, =20 regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CTS, NPCM_FIU_UMA_CTS_DEV_NUM, - (mem->spi->chip_select << + (spi_get_chipselect(mem->spi, 0) << NPCM_FIU_UMA_CTS_DEV_NUM_SHIFT)); =20 regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CMD, @@ -451,7 +451,7 @@ static int npcm_fiu_manualwrite(struct spi_mem *mem, =20 regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CTS, NPCM_FIU_UMA_CTS_DEV_NUM, - (mem->spi->chip_select << + (spi_get_chipselect(mem->spi, 0) << NPCM_FIU_UMA_CTS_DEV_NUM_SHIFT)); regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CTS, NPCM_FIU_UMA_CTS_SW_CS, 0); @@ -545,7 +545,7 @@ static int npcm_fiu_exec_op(struct spi_mem *mem, const = struct spi_mem_op *op) { struct npcm_fiu_spi *fiu =3D spi_controller_get_devdata(mem->spi->master); - struct npcm_fiu_chip *chip =3D &fiu->chip[mem->spi->chip_select]; + struct npcm_fiu_chip *chip =3D &fiu->chip[spi_get_chipselect(mem->spi, 0)= ]; int ret =3D 0; u8 *buf; =20 @@ -605,7 +605,7 @@ static int npcm_fiu_dirmap_create(struct spi_mem_dirmap= _desc *desc) { struct npcm_fiu_spi *fiu =3D spi_controller_get_devdata(desc->mem->spi->master); - struct npcm_fiu_chip *chip =3D &fiu->chip[desc->mem->spi->chip_select]; + struct npcm_fiu_chip *chip =3D &fiu->chip[spi_get_chipselect(desc->mem->s= pi, 0)]; struct regmap *gcr_regmap; =20 if (!fiu->res_mem) { @@ -624,7 +624,7 @@ static int npcm_fiu_dirmap_create(struct spi_mem_dirmap= _desc *desc) chip->flash_region_mapped_ptr =3D devm_ioremap(fiu->dev, (fiu->res_mem->start + (fiu->info->max_map_size * - desc->mem->spi->chip_select)), + spi_get_chipselect(desc->mem->spi, 0))), (u32)desc->info.length); if (!chip->flash_region_mapped_ptr) { dev_warn(fiu->dev, "Error mapping memory region, direct read disabled\n= "); @@ -669,9 +669,9 @@ static int npcm_fiu_setup(struct spi_device *spi) struct npcm_fiu_spi *fiu =3D spi_controller_get_devdata(ctrl); struct npcm_fiu_chip *chip; =20 - chip =3D &fiu->chip[spi->chip_select]; + chip =3D &fiu->chip[spi_get_chipselect(spi, 0)]; chip->fiu =3D fiu; - chip->chipselect =3D spi->chip_select; + chip->chipselect =3D spi_get_chipselect(spi, 0); chip->clkrate =3D spi->max_speed_hz; =20 fiu->clkrate =3D clk_get_rate(fiu->clk); diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c index 71be1ec3fbde..76168cc1e00d 100644 --- a/drivers/spi/spi-nxp-fspi.c +++ b/drivers/spi/spi-nxp-fspi.c @@ -663,7 +663,7 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, str= uct spi_device *spi) * Return, if previously selected slave device is same as current * requested slave device. */ - if (f->selected =3D=3D spi->chip_select) + if (f->selected =3D=3D spi_get_chipselect(spi, 0)) return; =20 /* Reset FLSHxxCR0 registers */ @@ -676,9 +676,9 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, str= uct spi_device *spi) size_kb =3D FSPI_FLSHXCR0_SZ(f->memmap_phy_size); =20 fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0 + - 4 * spi->chip_select); + 4 * spi_get_chipselect(spi, 0)); =20 - dev_dbg(f->dev, "Slave device [CS:%x] selected\n", spi->chip_select); + dev_dbg(f->dev, "Slave device [CS:%x] selected\n", spi_get_chipselect(spi= , 0)); =20 nxp_fspi_clk_disable_unprep(f); =20 @@ -690,7 +690,7 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, str= uct spi_device *spi) if (ret) return; =20 - f->selected =3D spi->chip_select; + f->selected =3D spi_get_chipselect(spi, 0); } =20 static int nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *= op) @@ -1055,7 +1055,7 @@ static const char *nxp_fspi_get_name(struct spi_mem *= mem) =20 name =3D devm_kasprintf(dev, GFP_KERNEL, "%s-%d", dev_name(f->dev), - mem->spi->chip_select); + spi_get_chipselect(mem->spi, 0)); =20 if (!name) { dev_err(dev, "failed to get memory for custom flash name\n"); diff --git a/drivers/spi/spi-omap-uwire.c b/drivers/spi/spi-omap-uwire.c index 6da77de19e2b..902d2e0c1f2f 100644 --- a/drivers/spi/spi-omap-uwire.c +++ b/drivers/spi/spi-omap-uwire.c @@ -179,7 +179,7 @@ static void uwire_chipselect(struct spi_device *spi, in= t value) =20 w =3D uwire_read_reg(UWIRE_CSR); old_cs =3D (w >> 10) & 0x03; - if (value =3D=3D BITBANG_CS_INACTIVE || old_cs !=3D spi->chip_select) { + if (value =3D=3D BITBANG_CS_INACTIVE || old_cs !=3D spi_get_chipselect(sp= i, 0)) { /* Deselect this CS, or the previous CS */ w &=3D ~CS_CMD; uwire_write_reg(UWIRE_CSR, w); @@ -193,7 +193,7 @@ static void uwire_chipselect(struct spi_device *spi, in= t value) else uwire_write_reg(UWIRE_SR4, 0); =20 - w =3D spi->chip_select << 10; + w =3D spi_get_chipselect(spi, 0) << 10; w |=3D CS_CMD; uwire_write_reg(UWIRE_CSR, w); } @@ -210,7 +210,7 @@ static int uwire_txrx(struct spi_device *spi, struct sp= i_transfer *t) if (!t->tx_buf && !t->rx_buf) return 0; =20 - w =3D spi->chip_select << 10; + w =3D spi_get_chipselect(spi, 0) << 10; w |=3D CS_CMD; =20 if (t->tx_buf) { @@ -408,7 +408,7 @@ static int uwire_setup_transfer(struct spi_device *spi,= struct spi_transfer *t) rate /=3D 8; break; } - omap_uwire_configure_mode(spi->chip_select, flags); + omap_uwire_configure_mode(spi_get_chipselect(spi, 0), flags); pr_debug("%s: uwire flags %02x, armxor %lu KHz, SCK %lu KHz\n", __func__, flags, clk_get_rate(uwire->ck) / 1000, diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index ce3cdd540420..1a967930f4e5 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -379,7 +379,7 @@ static void omap2_mcspi_rx_callback(void *data) { struct spi_device *spi =3D data; struct omap2_mcspi *mcspi =3D spi_master_get_devdata(spi->master); - struct omap2_mcspi_dma *mcspi_dma =3D &mcspi->dma_channels[spi->chip_sele= ct]; + struct omap2_mcspi_dma *mcspi_dma =3D &mcspi->dma_channels[spi_get_chipse= lect(spi, 0)]; =20 /* We must disable the DMA RX request */ omap2_mcspi_set_dma_req(spi, 1, 0); @@ -391,7 +391,7 @@ static void omap2_mcspi_tx_callback(void *data) { struct spi_device *spi =3D data; struct omap2_mcspi *mcspi =3D spi_master_get_devdata(spi->master); - struct omap2_mcspi_dma *mcspi_dma =3D &mcspi->dma_channels[spi->chip_sele= ct]; + struct omap2_mcspi_dma *mcspi_dma =3D &mcspi->dma_channels[spi_get_chipse= lect(spi, 0)]; =20 /* We must disable the DMA TX request */ omap2_mcspi_set_dma_req(spi, 0, 0); @@ -408,7 +408,7 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi, struct dma_async_tx_descriptor *tx; =20 mcspi =3D spi_master_get_devdata(spi->master); - mcspi_dma =3D &mcspi->dma_channels[spi->chip_select]; + mcspi_dma =3D &mcspi->dma_channels[spi_get_chipselect(spi, 0)]; =20 dmaengine_slave_config(mcspi_dma->dma_tx, &cfg); =20 @@ -446,7 +446,7 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_t= ransfer *xfer, struct dma_async_tx_descriptor *tx; =20 mcspi =3D spi_master_get_devdata(spi->master); - mcspi_dma =3D &mcspi->dma_channels[spi->chip_select]; + mcspi_dma =3D &mcspi->dma_channels[spi_get_chipselect(spi, 0)]; count =3D xfer->len; =20 /* @@ -591,7 +591,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi= _transfer *xfer) int wait_res; =20 mcspi =3D spi_master_get_devdata(spi->master); - mcspi_dma =3D &mcspi->dma_channels[spi->chip_select]; + mcspi_dma =3D &mcspi->dma_channels[spi_get_chipselect(spi, 0)]; =20 if (cs->word_len <=3D 8) { width =3D DMA_SLAVE_BUSWIDTH_1_BYTE; @@ -1062,8 +1062,8 @@ static int omap2_mcspi_setup(struct spi_device *spi) cs =3D kzalloc(sizeof(*cs), GFP_KERNEL); if (!cs) return -ENOMEM; - cs->base =3D mcspi->base + spi->chip_select * 0x14; - cs->phys =3D mcspi->phys + spi->chip_select * 0x14; + cs->base =3D mcspi->base + spi_get_chipselect(spi, 0) * 0x14; + cs->phys =3D mcspi->phys + spi_get_chipselect(spi, 0) * 0x14; cs->mode =3D 0; cs->chconf0 =3D 0; cs->chctrl0 =3D 0; @@ -1142,7 +1142,7 @@ static int omap2_mcspi_transfer_one(struct spi_master= *master, u32 chconf; =20 mcspi =3D spi_master_get_devdata(master); - mcspi_dma =3D mcspi->dma_channels + spi->chip_select; + mcspi_dma =3D mcspi->dma_channels + spi_get_chipselect(spi, 0); cs =3D spi->controller_state; cd =3D spi->controller_data; =20 @@ -1158,7 +1158,7 @@ static int omap2_mcspi_transfer_one(struct spi_master= *master, =20 omap2_mcspi_set_enable(spi, 0); =20 - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) omap2_mcspi_set_cs(spi, spi->mode & SPI_CS_HIGH); =20 if (par_override || @@ -1247,7 +1247,7 @@ static int omap2_mcspi_transfer_one(struct spi_master= *master, =20 omap2_mcspi_set_enable(spi, 0); =20 - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) omap2_mcspi_set_cs(spi, !(spi->mode & SPI_CS_HIGH)); =20 if (mcspi->fifo_depth > 0 && t) @@ -1289,7 +1289,7 @@ static bool omap2_mcspi_can_dma(struct spi_master *ma= ster, { struct omap2_mcspi *mcspi =3D spi_master_get_devdata(spi->master); struct omap2_mcspi_dma *mcspi_dma =3D - &mcspi->dma_channels[spi->chip_select]; + &mcspi->dma_channels[spi_get_chipselect(spi, 0)]; =20 if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) return false; @@ -1307,7 +1307,7 @@ static size_t omap2_mcspi_max_xfer_size(struct spi_de= vice *spi) { struct omap2_mcspi *mcspi =3D spi_master_get_devdata(spi->master); struct omap2_mcspi_dma *mcspi_dma =3D - &mcspi->dma_channels[spi->chip_select]; + &mcspi->dma_channels[spi_get_chipselect(spi, 0)]; =20 if (mcspi->max_xfer_len && mcspi_dma->dma_rx) return mcspi->max_xfer_len; diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index e79d1fe0bca4..bb244b596143 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -346,7 +346,7 @@ static void orion_spi_set_cs(struct spi_device *spi, bo= ol enable) * as it is handled by a GPIO, but that doesn't matter. What we need * is to deassert the old chip select and assert some other chip select. */ - val |=3D ORION_SPI_CS(spi->chip_select); + val |=3D ORION_SPI_CS(spi_get_chipselect(spi, 0)); =20 /* * Chip select logic is inverted from spi_set_cs(). For lines using a @@ -470,7 +470,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi= _transfer *xfer) unsigned int count; int word_len; struct orion_spi *orion_spi; - int cs =3D spi->chip_select; + int cs =3D spi_get_chipselect(spi, 0); void __iomem *vaddr; =20 word_len =3D spi->bits_per_word; diff --git a/drivers/spi/spi-pci1xxxx.c b/drivers/spi/spi-pci1xxxx.c index a31c3b612a43..1c5731641a04 100644 --- a/drivers/spi/spi-pci1xxxx.c +++ b/drivers/spi/spi-pci1xxxx.c @@ -116,11 +116,11 @@ static void pci1xxxx_spi_set_cs(struct spi_device *sp= i, bool enable) regval =3D readl(par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst)); if (enable) { regval &=3D ~SPI_MST_CTL_DEVSEL_MASK; - regval |=3D (spi->chip_select << 25); + regval |=3D (spi_get_chipselect(spi, 0) << 25); writel(regval, par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst)); } else { - regval &=3D ~(spi->chip_select << 25); + regval &=3D ~(spi_get_chipselect(spi, 0) << 25); writel(regval, par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst)); =20 diff --git a/drivers/spi/spi-pic32-sqi.c b/drivers/spi/spi-pic32-sqi.c index 4c8493f34fca..51dfb49523f3 100644 --- a/drivers/spi/spi-pic32-sqi.c +++ b/drivers/spi/spi-pic32-sqi.c @@ -267,7 +267,7 @@ static int pic32_sqi_one_transfer(struct pic32_sqi *sqi, u32 nbits; =20 /* Device selection */ - bd_ctrl =3D spi->chip_select << BD_DEVSEL_SHIFT; + bd_ctrl =3D spi_get_chipselect(spi, 0) << BD_DEVSEL_SHIFT; =20 /* half-duplex: select transfer buffer, direction and lane */ if (xfer->rx_buf) { diff --git a/drivers/spi/spi-pic32.c b/drivers/spi/spi-pic32.c index 5a64ad0c94fe..8a02073a354d 100644 --- a/drivers/spi/spi-pic32.c +++ b/drivers/spi/spi-pic32.c @@ -591,7 +591,7 @@ static int pic32_spi_setup(struct spi_device *spi) * unreliable/erroneous SPI transactions. * To avoid that we will always handle /CS by toggling GPIO. */ - if (!spi->cs_gpiod) + if (!spi_get_csgpiod(spi, 0)) return -EINVAL; =20 return 0; @@ -600,7 +600,7 @@ static int pic32_spi_setup(struct spi_device *spi) static void pic32_spi_cleanup(struct spi_device *spi) { /* de-activate cs-gpio, gpiolib will handle inversion */ - gpiod_direction_output(spi->cs_gpiod, 0); + gpiod_direction_output(spi_get_csgpiod(spi, 0), 0); } =20 static int pic32_spi_dma_prep(struct pic32_spi *pic32s, struct device *dev) diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index a17ff839117f..982407bc5d9f 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -1587,9 +1587,9 @@ static int pl022_transfer_one_message(struct spi_mast= er *master, =20 /* Setup the SPI using the per chip configuration */ pl022->cur_chip =3D spi_get_ctldata(msg->spi); - pl022->cur_cs =3D msg->spi->chip_select; + pl022->cur_cs =3D spi_get_chipselect(msg->spi, 0); /* This is always available but may be set to -ENOENT */ - pl022->cur_gpiod =3D msg->spi->cs_gpiod; + pl022->cur_gpiod =3D spi_get_csgpiod(msg->spi, 0); =20 restore_state(pl022); flush(pl022); diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index a75ba2993f3c..d04e8cb987e9 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -368,7 +368,7 @@ static void lpss_ssp_select_cs(struct spi_device *spi, =20 value =3D __lpss_ssp_read_priv(drv_data, config->reg_cs_ctrl); =20 - cs =3D spi->chip_select; + cs =3D spi_get_chipselect(spi, 0); cs <<=3D config->cs_sel_shift; if (cs !=3D (value & config->cs_sel_mask)) { /* @@ -429,7 +429,7 @@ static void cs_assert(struct spi_device *spi) spi_controller_get_devdata(spi->controller); =20 if (drv_data->ssp_type =3D=3D CE4100_SSP) { - pxa2xx_spi_write(drv_data, SSSR, spi->chip_select); + pxa2xx_spi_write(drv_data, SSSR, spi_get_chipselect(spi, 0)); return; } =20 @@ -1217,7 +1217,7 @@ static int setup(struct spi_device *spi) return -ENOMEM; =20 if (drv_data->ssp_type =3D=3D CE4100_SSP) { - if (spi->chip_select > 4) { + if (spi_get_chipselect(spi, 0) > 4) { dev_err(&spi->dev, "failed setup: cs number must not be > 4.\n"); kfree(chip); diff --git a/drivers/spi/spi-qcom-qspi.c b/drivers/spi/spi-qcom-qspi.c index 15c4e21cd562..aa91a6c9ab55 100644 --- a/drivers/spi/spi-qcom-qspi.c +++ b/drivers/spi/spi-qcom-qspi.c @@ -311,7 +311,7 @@ static int qcom_qspi_prepare_message(struct spi_master = *master, =20 mstr_cfg =3D readl(ctrl->base + MSTR_CONFIG); mstr_cfg &=3D ~CHIP_SELECT_NUM; - if (message->spi->chip_select) + if (spi_get_chipselect(message->spi, 0)) mstr_cfg |=3D CHIP_SELECT_NUM; =20 mstr_cfg |=3D FB_CLK_EN | PIN_WPN | PIN_HOLDN | SBL_EN | FULL_CYCLE_MODE; diff --git a/drivers/spi/spi-rb4xx.c b/drivers/spi/spi-rb4xx.c index e312b30b733b..5073736d3d1f 100644 --- a/drivers/spi/spi-rb4xx.c +++ b/drivers/spi/spi-rb4xx.c @@ -107,7 +107,7 @@ static int rb4xx_transfer_one(struct spi_master *master, * command set was designed to almost not clash with that of the * boot flash. */ - if (spi->chip_select =3D=3D 2) + if (spi_get_chipselect(spi, 0) =3D=3D 2) /* MMC */ spi_ioc =3D AR71XX_SPI_IOC_CS0; else diff --git a/drivers/spi/spi-rockchip-sfc.c b/drivers/spi/spi-rockchip-sfc.c index 80e1ee110d31..4fabd2e0439f 100644 --- a/drivers/spi/spi-rockchip-sfc.c +++ b/drivers/spi/spi-rockchip-sfc.c @@ -346,7 +346,7 @@ static int rockchip_sfc_xfer_setup(struct rockchip_sfc = *sfc, =20 /* set the Controller */ ctrl |=3D SFC_CTRL_PHASE_SEL_NEGETIVE; - cmd |=3D mem->spi->chip_select << SFC_CMD_CS_SHIFT; + cmd |=3D spi_get_chipselect(mem->spi, 0) << SFC_CMD_CS_SHIFT; =20 dev_dbg(sfc->dev, "sfc addr.nbytes=3D%x(x%d) dummy.nbytes=3D%x(x%d)\n", op->addr.nbytes, op->addr.buswidth, diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index a66fff0ee20e..143ede958ac1 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -246,28 +246,30 @@ static void rockchip_spi_set_cs(struct spi_device *sp= i, bool enable) bool cs_asserted =3D spi->mode & SPI_CS_HIGH ? enable : !enable; =20 /* Return immediately for no-op */ - if (cs_asserted =3D=3D rs->cs_asserted[spi->chip_select]) + if (cs_asserted =3D=3D rs->cs_asserted[spi_get_chipselect(spi, 0)]) return; =20 if (cs_asserted) { /* Keep things powered as long as CS is asserted */ pm_runtime_get_sync(rs->dev); =20 - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) ROCKCHIP_SPI_SET_BITS(rs->regs + ROCKCHIP_SPI_SER, 1); else - ROCKCHIP_SPI_SET_BITS(rs->regs + ROCKCHIP_SPI_SER, BIT(spi->chip_select= )); + ROCKCHIP_SPI_SET_BITS(rs->regs + ROCKCHIP_SPI_SER, + BIT(spi_get_chipselect(spi, 0))); } else { - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) ROCKCHIP_SPI_CLR_BITS(rs->regs + ROCKCHIP_SPI_SER, 1); else - ROCKCHIP_SPI_CLR_BITS(rs->regs + ROCKCHIP_SPI_SER, BIT(spi->chip_select= )); + ROCKCHIP_SPI_CLR_BITS(rs->regs + ROCKCHIP_SPI_SER, + BIT(spi_get_chipselect(spi, 0))); =20 /* Drop reference from when we first asserted CS */ pm_runtime_put(rs->dev); } =20 - rs->cs_asserted[spi->chip_select] =3D cs_asserted; + rs->cs_asserted[spi_get_chipselect(spi, 0)] =3D cs_asserted; } =20 static void rockchip_spi_handle_err(struct spi_controller *ctlr, @@ -541,7 +543,7 @@ static int rockchip_spi_config(struct rockchip_spi *rs, if (spi->mode & SPI_LSB_FIRST) cr0 |=3D CR0_FBM_LSB << CR0_FBM_OFFSET; if (spi->mode & SPI_CS_HIGH) - cr0 |=3D BIT(spi->chip_select) << CR0_SOI_OFFSET; + cr0 |=3D BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET; =20 if (xfer->rx_buf && xfer->tx_buf) cr0 |=3D CR0_XFM_TR << CR0_XFM_OFFSET; @@ -724,7 +726,7 @@ static int rockchip_spi_setup(struct spi_device *spi) struct rockchip_spi *rs =3D spi_controller_get_devdata(spi->controller); u32 cr0; =20 - if (!spi->cs_gpiod && (spi->mode & SPI_CS_HIGH) && !rs->cs_high_supported= ) { + if (!spi_get_csgpiod(spi, 0) && (spi->mode & SPI_CS_HIGH) && !rs->cs_high= _supported) { dev_warn(&spi->dev, "setup: non GPIO CS can't be active-high\n"); return -EINVAL; } @@ -735,10 +737,10 @@ static int rockchip_spi_setup(struct spi_device *spi) =20 cr0 &=3D ~(0x3 << CR0_SCPH_OFFSET); cr0 |=3D ((spi->mode & 0x3) << CR0_SCPH_OFFSET); - if (spi->mode & SPI_CS_HIGH && spi->chip_select <=3D 1) - cr0 |=3D BIT(spi->chip_select) << CR0_SOI_OFFSET; - else if (spi->chip_select <=3D 1) - cr0 &=3D ~(BIT(spi->chip_select) << CR0_SOI_OFFSET); + if (spi->mode & SPI_CS_HIGH && spi_get_chipselect(spi, 0) <=3D 1) + cr0 |=3D BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET; + else if (spi_get_chipselect(spi, 0) <=3D 1) + cr0 &=3D ~(BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET); =20 writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0); =20 diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index f494c86bafea..f50a39efaf96 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c @@ -950,7 +950,7 @@ static int rspi_setup(struct spi_device *spi) struct rspi_data *rspi =3D spi_controller_get_devdata(spi->controller); u8 sslp; =20 - if (spi->cs_gpiod) + if (spi_get_csgpiod(spi, 0)) return 0; =20 pm_runtime_get_sync(&rspi->pdev->dev); @@ -958,9 +958,9 @@ static int rspi_setup(struct spi_device *spi) =20 sslp =3D rspi_read8(rspi, RSPI_SSLP); if (spi->mode & SPI_CS_HIGH) - sslp |=3D SSLP_SSLP(spi->chip_select); + sslp |=3D SSLP_SSLP(spi_get_chipselect(spi, 0)); else - sslp &=3D ~SSLP_SSLP(spi->chip_select); + sslp &=3D ~SSLP_SSLP(spi_get_chipselect(spi, 0)); rspi_write8(rspi, sslp, RSPI_SSLP); =20 spin_unlock_irq(&rspi->lock); @@ -1001,8 +1001,8 @@ static int rspi_prepare_message(struct spi_controller= *ctlr, rspi->spcmd |=3D SPCMD_LSBF; =20 /* Configure slave signal to assert */ - rspi->spcmd |=3D SPCMD_SSLA(spi->cs_gpiod ? rspi->ctlr->unused_native_cs - : spi->chip_select); + rspi->spcmd |=3D SPCMD_SSLA(spi_get_csgpiod(spi, 0) ? rspi->ctlr->unused_= native_cs + : spi_get_chipselect(spi, 0)); =20 /* CMOS output mode and MOSI signal from previous transfer */ rspi->sppcr =3D 0; diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index cc69f8ffdbdc..7ac17f0d18a9 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -891,7 +891,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi) =20 /* NULL is fine, we just avoid using the FB delay (=3D0) */ if (IS_ERR(cs)) { - dev_err(&spi->dev, "No CS for SPI(%d)\n", spi->chip_select); + dev_err(&spi->dev, "No CS for SPI(%d)\n", spi_get_chipselect(spi, 0)); return -ENODEV; } =20 diff --git a/drivers/spi/spi-sc18is602.c b/drivers/spi/spi-sc18is602.c index 983b3621bc2a..a12adc68731b 100644 --- a/drivers/spi/spi-sc18is602.c +++ b/drivers/spi/spi-sc18is602.c @@ -70,7 +70,7 @@ static int sc18is602_txrx(struct sc18is602 *hw, struct sp= i_message *msg, =20 if (hw->tlen =3D=3D 0) { /* First byte (I2C command) is chip select */ - hw->buffer[0] =3D 1 << msg->spi->chip_select; + hw->buffer[0] =3D 1 << spi_get_chipselect(msg->spi, 0); hw->tlen =3D 1; hw->rindex =3D 0; } @@ -229,7 +229,7 @@ static int sc18is602_setup(struct spi_device *spi) struct sc18is602 *hw =3D spi_master_get_devdata(spi->master); =20 /* SC18IS602 does not support CS2 */ - if (hw->id =3D=3D sc18is602 && spi->chip_select =3D=3D 2) + if (hw->id =3D=3D sc18is602 && (spi_get_chipselect(spi, 0) =3D=3D 2)) return -ENXIO; =20 return 0; diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index d828a3b370b8..50498c4eb661 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c @@ -554,7 +554,7 @@ static int sh_msiof_spi_setup(struct spi_device *spi) spi_controller_get_devdata(spi->controller); u32 clr, set, tmp; =20 - if (spi->cs_gpiod || spi_controller_is_slave(p->ctlr)) + if (spi_get_csgpiod(spi, 0) || spi_controller_is_slave(p->ctlr)) return 0; =20 if (p->native_cs_inited && @@ -587,11 +587,11 @@ static int sh_msiof_prepare_message(struct spi_contro= ller *ctlr, u32 ss, cs_high; =20 /* Configure pins before asserting CS */ - if (spi->cs_gpiod) { + if (spi_get_csgpiod((struct spi_device *)spi, 0)) { ss =3D ctlr->unused_native_cs; cs_high =3D p->native_cs_high; } else { - ss =3D spi->chip_select; + ss =3D spi_get_chipselect((struct spi_device *)spi, 0); cs_high =3D !!(spi->mode & SPI_CS_HIGH); } sh_msiof_spi_set_pin_regs(p, ss, !!(spi->mode & SPI_CPOL), diff --git a/drivers/spi/spi-sh-sci.c b/drivers/spi/spi-sh-sci.c index 0fdfec2de47a..92ca3f2d61ba 100644 --- a/drivers/spi/spi-sh-sci.c +++ b/drivers/spi/spi-sh-sci.c @@ -108,7 +108,7 @@ static void sh_sci_spi_chipselect(struct spi_device *de= v, int value) struct sh_sci_spi *sp =3D spi_master_get_devdata(dev->master); =20 if (sp->info->chip_select) - (sp->info->chip_select)(sp->info, dev->chip_select, value); + (sp->info->chip_select)(sp->info, spi_get_chipselect(dev, 0), value); } =20 static int sh_sci_spi_probe(struct platform_device *dev) diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c index 055de44e0d22..dae9e097c333 100644 --- a/drivers/spi/spi-sifive.c +++ b/drivers/spi/spi-sifive.c @@ -135,13 +135,13 @@ sifive_spi_prepare_message(struct spi_master *master,= struct spi_message *msg) =20 /* Update the chip select polarity */ if (device->mode & SPI_CS_HIGH) - spi->cs_inactive &=3D ~BIT(device->chip_select); + spi->cs_inactive &=3D ~BIT(spi_get_chipselect(device, 0)); else - spi->cs_inactive |=3D BIT(device->chip_select); + spi->cs_inactive |=3D BIT(spi_get_chipselect(device, 0)); sifive_spi_write(spi, SIFIVE_SPI_REG_CSDEF, spi->cs_inactive); =20 /* Select the correct device */ - sifive_spi_write(spi, SIFIVE_SPI_REG_CSID, device->chip_select); + sifive_spi_write(spi, SIFIVE_SPI_REG_CSID, spi_get_chipselect(device, 0)); =20 /* Set clock mode */ sifive_spi_write(spi, SIFIVE_SPI_REG_SCKMODE, diff --git a/drivers/spi/spi-sn-f-ospi.c b/drivers/spi/spi-sn-f-ospi.c index 644ae34f623b..d64100f88181 100644 --- a/drivers/spi/spi-sn-f-ospi.c +++ b/drivers/spi/spi-sn-f-ospi.c @@ -267,7 +267,7 @@ static void f_ospi_config_indir_protocol(struct f_ospi = *ospi, int unit; =20 /* Set one chip select */ - writel(BIT(spi->chip_select), ospi->base + OSPI_SSEL); + writel(BIT(spi_get_chipselect(spi, 0)), ospi->base + OSPI_SSEL); =20 mode =3D f_ospi_get_mode(ospi, op->cmd.buswidth, 1); prot |=3D FIELD_PREP(OSPI_PROT_MODE_CODE_MASK, mode); diff --git a/drivers/spi/spi-st-ssc4.c b/drivers/spi/spi-st-ssc4.c index 9141f19c7f8e..7fcff9c539e2 100644 --- a/drivers/spi/spi-st-ssc4.c +++ b/drivers/spi/spi-st-ssc4.c @@ -183,7 +183,7 @@ static int spi_st_setup(struct spi_device *spi) return -EINVAL; } =20 - if (!spi->cs_gpiod) { + if (!spi_get_csgpiod(spi, 0)) { dev_err(&spi->dev, "no valid gpio assigned\n"); return -EINVAL; } diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c index 29125af0afdb..2b6804aa6901 100644 --- a/drivers/spi/spi-stm32-qspi.c +++ b/drivers/spi/spi-stm32-qspi.c @@ -359,7 +359,7 @@ static int stm32_qspi_get_mode(u8 buswidth) static int stm32_qspi_send(struct spi_device *spi, const struct spi_mem_op= *op) { struct stm32_qspi *qspi =3D spi_controller_get_devdata(spi->master); - struct stm32_qspi_flash *flash =3D &qspi->flash[spi->chip_select]; + struct stm32_qspi_flash *flash =3D &qspi->flash[spi_get_chipselect(spi, 0= )]; u32 ccr, cr; int timeout, err =3D 0, err_poll_status =3D 0; =20 @@ -564,7 +564,7 @@ static int stm32_qspi_transfer_one_message(struct spi_c= ontroller *ctrl, struct spi_mem_op op; int ret =3D 0; =20 - if (!spi->cs_gpiod) + if (!spi_get_csgpiod(spi, 0)) return -EOPNOTSUPP; =20 ret =3D pm_runtime_resume_and_get(qspi->dev); @@ -573,7 +573,7 @@ static int stm32_qspi_transfer_one_message(struct spi_c= ontroller *ctrl, =20 mutex_lock(&qspi->lock); =20 - gpiod_set_value_cansleep(spi->cs_gpiod, true); + gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), true); =20 list_for_each_entry(transfer, &msg->transfers, transfer_list) { u8 dummy_bytes =3D 0; @@ -626,7 +626,7 @@ static int stm32_qspi_transfer_one_message(struct spi_c= ontroller *ctrl, } =20 end_of_transfer: - gpiod_set_value_cansleep(spi->cs_gpiod, false); + gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), false); =20 mutex_unlock(&qspi->lock); =20 @@ -669,8 +669,8 @@ static int stm32_qspi_setup(struct spi_device *spi) =20 presc =3D DIV_ROUND_UP(qspi->clk_rate, spi->max_speed_hz) - 1; =20 - flash =3D &qspi->flash[spi->chip_select]; - flash->cs =3D spi->chip_select; + flash =3D &qspi->flash[spi_get_chipselect(spi, 0)]; + flash->cs =3D spi_get_chipselect(spi, 0); flash->presc =3D presc; =20 mutex_lock(&qspi->lock); diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c index 994d0fb50e68..b8947265d329 100644 --- a/drivers/spi/spi-sun4i.c +++ b/drivers/spi/spi-sun4i.c @@ -167,7 +167,7 @@ static void sun4i_spi_set_cs(struct spi_device *spi, bo= ol enable) reg =3D sun4i_spi_read(sspi, SUN4I_CTL_REG); =20 reg &=3D ~SUN4I_CTL_CS_MASK; - reg |=3D SUN4I_CTL_CS(spi->chip_select); + reg |=3D SUN4I_CTL_CS(spi_get_chipselect(spi, 0)); =20 /* We want to control the chip select manually */ reg |=3D SUN4I_CTL_CS_MANUAL; diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c index 43c29afea6bb..7532c85a352c 100644 --- a/drivers/spi/spi-sun6i.c +++ b/drivers/spi/spi-sun6i.c @@ -174,7 +174,7 @@ static void sun6i_spi_set_cs(struct spi_device *spi, bo= ol enable) =20 reg =3D sun6i_spi_read(sspi, SUN6I_TFR_CTL_REG); reg &=3D ~SUN6I_TFR_CTL_CS_MASK; - reg |=3D SUN6I_TFR_CTL_CS(spi->chip_select); + reg |=3D SUN6I_TFR_CTL_CS(spi_get_chipselect(spi, 0)); =20 if (enable) reg |=3D SUN6I_TFR_CTL_CS_LEVEL; diff --git a/drivers/spi/spi-synquacer.c b/drivers/spi/spi-synquacer.c index 3a92f722a6c5..aeaf7db022f0 100644 --- a/drivers/spi/spi-synquacer.c +++ b/drivers/spi/spi-synquacer.c @@ -250,7 +250,7 @@ static int synquacer_spi_config(struct spi_master *mast= er, } =20 mode =3D spi->mode; - cs =3D spi->chip_select; + cs =3D spi_get_chipselect(spi, 0); speed =3D xfer->speed_hz; bpw =3D xfer->bits_per_word; =20 @@ -344,7 +344,7 @@ static int synquacer_spi_config(struct spi_master *mast= er, sspi->bpw =3D bpw; sspi->mode =3D mode; sspi->speed =3D speed; - sspi->cs =3D spi->chip_select; + sspi->cs =3D spi_get_chipselect(spi, 0); sspi->bus_width =3D bus_width; =20 return 0; @@ -488,7 +488,7 @@ static void synquacer_spi_set_cs(struct spi_device *spi= , bool enable) val =3D readl(sspi->regs + SYNQUACER_HSSPI_REG_DMSTART); val &=3D ~(SYNQUACER_HSSPI_DMPSEL_CS_MASK << SYNQUACER_HSSPI_DMPSEL_CS_SHIFT); - val |=3D spi->chip_select << SYNQUACER_HSSPI_DMPSEL_CS_SHIFT; + val |=3D spi_get_chipselect(spi, 0) << SYNQUACER_HSSPI_DMPSEL_CS_SHIFT; =20 if (!enable) val |=3D SYNQUACER_HSSPI_DMSTOP_STOP; diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c index b6bee922a92c..9e7d762d0ee6 100644 --- a/drivers/spi/spi-tegra114.c +++ b/drivers/spi/spi-tegra114.c @@ -747,7 +747,7 @@ static int tegra_spi_set_hw_cs_timing(struct spi_device= *spi) if (setup_dly && hold_dly) { setup_hold =3D SPI_SETUP_HOLD(setup_dly - 1, hold_dly - 1); spi_cs_timing =3D SPI_CS_SETUP_HOLD(tspi->spi_cs_timing1, - spi->chip_select, + spi_get_chipselect(spi, 0), setup_hold); if (tspi->spi_cs_timing1 !=3D spi_cs_timing) { tspi->spi_cs_timing1 =3D spi_cs_timing; @@ -760,9 +760,9 @@ static int tegra_spi_set_hw_cs_timing(struct spi_device= *spi) inactive_cycles--; cs_state =3D inactive_cycles ? 0 : 1; spi_cs_timing =3D tspi->spi_cs_timing2; - SPI_SET_CS_ACTIVE_BETWEEN_PACKETS(spi_cs_timing, spi->chip_select, + SPI_SET_CS_ACTIVE_BETWEEN_PACKETS(spi_cs_timing, spi_get_chipselect(spi, = 0), cs_state); - SPI_SET_CYCLES_BETWEEN_PACKETS(spi_cs_timing, spi->chip_select, + SPI_SET_CYCLES_BETWEEN_PACKETS(spi_cs_timing, spi_get_chipselect(spi, 0), inactive_cycles); if (tspi->spi_cs_timing2 !=3D spi_cs_timing) { tspi->spi_cs_timing2 =3D spi_cs_timing; @@ -831,8 +831,8 @@ static u32 tegra_spi_setup_transfer_one(struct spi_devi= ce *spi, tegra_spi_writel(tspi, command1, SPI_COMMAND1); =20 /* GPIO based chip select control */ - if (spi->cs_gpiod) - gpiod_set_value(spi->cs_gpiod, 1); + if (spi_get_csgpiod(spi, 0)) + gpiod_set_value(spi_get_csgpiod(spi, 0), 1); =20 if (is_single_xfer && !(t->cs_change)) { tspi->use_hw_based_cs =3D true; @@ -846,7 +846,7 @@ static u32 tegra_spi_setup_transfer_one(struct spi_devi= ce *spi, command1 &=3D ~SPI_CS_SW_VAL; } =20 - if (tspi->last_used_cs !=3D spi->chip_select) { + if (tspi->last_used_cs !=3D spi_get_chipselect(spi, 0)) { if (cdata && cdata->tx_clk_tap_delay) tx_tap =3D cdata->tx_clk_tap_delay; if (cdata && cdata->rx_clk_tap_delay) @@ -855,7 +855,7 @@ static u32 tegra_spi_setup_transfer_one(struct spi_devi= ce *spi, SPI_RX_TAP_DELAY(rx_tap); if (command2 !=3D tspi->def_command2_reg) tegra_spi_writel(tspi, command2, SPI_COMMAND2); - tspi->last_used_cs =3D spi->chip_select; + tspi->last_used_cs =3D spi_get_chipselect(spi, 0); } =20 } else { @@ -896,7 +896,7 @@ static int tegra_spi_start_transfer_one(struct spi_devi= ce *spi, command1 |=3D SPI_TX_EN; tspi->cur_direction |=3D DATA_DIR_TX; } - command1 |=3D SPI_CS_SEL(spi->chip_select); + command1 |=3D SPI_CS_SEL(spi_get_chipselect(spi, 0)); tegra_spi_writel(tspi, command1, SPI_COMMAND1); tspi->command1_reg =3D command1; =20 @@ -980,14 +980,14 @@ static int tegra_spi_setup(struct spi_device *spi) =20 spin_lock_irqsave(&tspi->lock, flags); /* GPIO based chip select control */ - if (spi->cs_gpiod) - gpiod_set_value(spi->cs_gpiod, 0); + if (spi_get_csgpiod(spi, 0)) + gpiod_set_value(spi_get_csgpiod(spi, 0), 0); =20 val =3D tspi->def_command1_reg; if (spi->mode & SPI_CS_HIGH) - val &=3D ~SPI_CS_POL_INACTIVE(spi->chip_select); + val &=3D ~SPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0)); else - val |=3D SPI_CS_POL_INACTIVE(spi->chip_select); + val |=3D SPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0)); tspi->def_command1_reg =3D val; tegra_spi_writel(tspi, tspi->def_command1_reg, SPI_COMMAND1); spin_unlock_irqrestore(&tspi->lock, flags); @@ -1002,8 +1002,8 @@ static void tegra_spi_transfer_end(struct spi_device = *spi) int cs_val =3D (spi->mode & SPI_CS_HIGH) ? 0 : 1; =20 /* GPIO based chip select control */ - if (spi->cs_gpiod) - gpiod_set_value(spi->cs_gpiod, 0); + if (spi_get_csgpiod(spi, 0)) + gpiod_set_value(spi_get_csgpiod(spi, 0), 0); =20 if (!tspi->use_hw_based_cs) { if (cs_val) diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sfl= ash.c index ed82530ea64b..4286310628a2 100644 --- a/drivers/spi/spi-tegra20-sflash.c +++ b/drivers/spi/spi-tegra20-sflash.c @@ -280,7 +280,7 @@ static int tegra_sflash_start_transfer_one(struct spi_d= evice *spi, command |=3D SPI_ACTIVE_SCLK_DRIVE_HIGH; else command |=3D SPI_ACTIVE_SCLK_DRIVE_LOW; - command |=3D SPI_CS0_EN << spi->chip_select; + command |=3D SPI_CS0_EN << spi_get_chipselect(spi, 0); } else { command =3D tsd->command_reg; command &=3D ~SPI_BIT_LENGTH(~0); diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slin= k.c index ac7933bc03e2..c2915f7672cc 100644 --- a/drivers/spi/spi-tegra20-slink.c +++ b/drivers/spi/spi-tegra20-slink.c @@ -758,9 +758,9 @@ static int tegra_slink_setup(struct spi_device *spi) spin_lock_irqsave(&tspi->lock, flags); val =3D tspi->def_command_reg; if (spi->mode & SPI_CS_HIGH) - val |=3D cs_pol_bit[spi->chip_select]; + val |=3D cs_pol_bit[spi_get_chipselect(spi, 0)]; else - val &=3D ~cs_pol_bit[spi->chip_select]; + val &=3D ~cs_pol_bit[spi_get_chipselect(spi, 0)]; tspi->def_command_reg =3D val; tegra_slink_writel(tspi, tspi->def_command_reg, SLINK_COMMAND); spin_unlock_irqrestore(&tspi->lock, flags); @@ -781,7 +781,7 @@ static int tegra_slink_prepare_message(struct spi_maste= r *master, tspi->command_reg |=3D SLINK_CS_SW | SLINK_CS_VALUE; =20 tspi->command2_reg =3D tspi->def_command2_reg; - tspi->command2_reg |=3D SLINK_SS_EN_CS(spi->chip_select); + tspi->command2_reg |=3D SLINK_SS_EN_CS(spi_get_chipselect(spi, 0)); =20 tspi->command_reg &=3D ~SLINK_MODES; if (spi->mode & SPI_CPHA) diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-qua= d.c index fd0d532364e2..325b4427491c 100644 --- a/drivers/spi/spi-tegra210-quad.c +++ b/drivers/spi/spi-tegra210-quad.c @@ -829,7 +829,7 @@ static u32 tegra_qspi_setup_transfer_one(struct spi_dev= ice *spi, struct spi_tran tegra_qspi_mask_clear_irq(tqspi); =20 command1 =3D tqspi->def_command1_reg; - command1 |=3D QSPI_CS_SEL(spi->chip_select); + command1 |=3D QSPI_CS_SEL(spi_get_chipselect(spi, 0)); command1 |=3D QSPI_BIT_LENGTH(bits_per_word - 1); =20 command1 &=3D ~QSPI_CONTROL_MODE_MASK; @@ -960,11 +960,11 @@ static int tegra_qspi_setup(struct spi_device *spi) =20 /* keep default cs state to inactive */ val =3D tqspi->def_command1_reg; - val |=3D QSPI_CS_SEL(spi->chip_select); + val |=3D QSPI_CS_SEL(spi_get_chipselect(spi, 0)); if (spi->mode & SPI_CS_HIGH) - val &=3D ~QSPI_CS_POL_INACTIVE(spi->chip_select); + val &=3D ~QSPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0)); else - val |=3D QSPI_CS_POL_INACTIVE(spi->chip_select); + val |=3D QSPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0)); =20 tqspi->def_command1_reg =3D val; tegra_qspi_writel(tqspi, tqspi->def_command1_reg, QSPI_COMMAND1); diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c index 60086869bcae..5914335ff63d 100644 --- a/drivers/spi/spi-ti-qspi.c +++ b/drivers/spi/spi-ti-qspi.c @@ -533,10 +533,10 @@ static void ti_qspi_enable_memory_map(struct spi_devi= ce *spi) if (qspi->ctrl_base) { regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg, MEM_CS_MASK, - MEM_CS_EN(spi->chip_select)); + MEM_CS_EN(spi_get_chipselect(spi, 0))); } qspi->mmap_enabled =3D true; - qspi->current_cs =3D spi->chip_select; + qspi->current_cs =3D spi_get_chipselect(spi, 0); } =20 static void ti_qspi_disable_memory_map(struct spi_device *spi) @@ -572,7 +572,7 @@ static void ti_qspi_setup_mmap_read(struct spi_device *= spi, u8 opcode, memval |=3D ((addr_width - 1) << QSPI_SETUP_ADDR_SHIFT | dummy_bytes << QSPI_SETUP_DUMMY_SHIFT); ti_qspi_write(qspi, memval, - QSPI_SPI_SETUP_REG(spi->chip_select)); + QSPI_SPI_SETUP_REG(spi_get_chipselect(spi, 0))); } =20 static int ti_qspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *= op) @@ -623,7 +623,7 @@ static int ti_qspi_exec_mem_op(struct spi_mem *mem, =20 mutex_lock(&qspi->list_lock); =20 - if (!qspi->mmap_enabled || qspi->current_cs !=3D mem->spi->chip_select) { + if (!qspi->mmap_enabled || qspi->current_cs !=3D spi_get_chipselect(mem->= spi, 0)) { ti_qspi_setup_clk(qspi, mem->spi->max_speed_hz); ti_qspi_enable_memory_map(mem->spi); } @@ -673,11 +673,11 @@ static int ti_qspi_start_transfer_one(struct spi_mast= er *master, qspi->dc =3D 0; =20 if (spi->mode & SPI_CPHA) - qspi->dc |=3D QSPI_CKPHA(spi->chip_select); + qspi->dc |=3D QSPI_CKPHA(spi_get_chipselect(spi, 0)); if (spi->mode & SPI_CPOL) - qspi->dc |=3D QSPI_CKPOL(spi->chip_select); + qspi->dc |=3D QSPI_CKPOL(spi_get_chipselect(spi, 0)); if (spi->mode & SPI_CS_HIGH) - qspi->dc |=3D QSPI_CSPOL(spi->chip_select); + qspi->dc |=3D QSPI_CSPOL(spi_get_chipselect(spi, 0)); =20 frame_len_words =3D 0; list_for_each_entry(t, &m->transfers, transfer_list) @@ -686,7 +686,7 @@ static int ti_qspi_start_transfer_one(struct spi_master= *master, =20 /* setup command reg */ qspi->cmd =3D 0; - qspi->cmd |=3D QSPI_EN_CS(spi->chip_select); + qspi->cmd |=3D QSPI_EN_CS(spi_get_chipselect(spi, 0)); qspi->cmd |=3D QSPI_FLEN(frame_len_words); =20 ti_qspi_write(qspi, qspi->dc, QSPI_SPI_DC_REG); diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index 1679a0ba3d62..af5846cfe5e9 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -499,7 +499,7 @@ static inline void pch_spi_select_chip(struct pch_spi_d= ata *data, struct spi_device *pspi) { if (data->current_chip !=3D NULL) { - if (pspi->chip_select !=3D data->n_curnt_chip) { + if (spi_get_chipselect(pspi, 0) !=3D data->n_curnt_chip) { dev_dbg(&pspi->dev, "%s : different slave\n", __func__); data->current_chip =3D NULL; } @@ -507,7 +507,7 @@ static inline void pch_spi_select_chip(struct pch_spi_d= ata *data, =20 data->current_chip =3D pspi; =20 - data->n_curnt_chip =3D data->current_chip->chip_select; + data->n_curnt_chip =3D spi_get_chipselect(data->current_chip, 0); =20 dev_dbg(&pspi->dev, "%s :Invoking pch_spi_setup_transfer\n", __func__); pch_spi_setup_transfer(pspi); diff --git a/drivers/spi/spi-wpcm-fiu.c b/drivers/spi/spi-wpcm-fiu.c index ab33710d50ac..f15312fdcdaf 100644 --- a/drivers/spi/spi-wpcm-fiu.c +++ b/drivers/spi/spi-wpcm-fiu.c @@ -158,7 +158,7 @@ static int wpcm_fiu_normal_exec(struct spi_mem *mem, co= nst struct spi_mem_op *op if (op->data.dir =3D=3D SPI_MEM_DATA_OUT) wpcm_fiu_set_data(fiu, op->data.buf.out, op->data.nbytes); =20 - ret =3D wpcm_fiu_do_uma(fiu, mem->spi->chip_select, op->addr.nbytes =3D= =3D 3, + ret =3D wpcm_fiu_do_uma(fiu, spi_get_chipselect(mem->spi, 0), op->addr.nb= ytes =3D=3D 3, op->data.dir =3D=3D SPI_MEM_DATA_OUT, op->data.nbytes); =20 if (op->data.dir =3D=3D SPI_MEM_DATA_IN) @@ -196,7 +196,7 @@ static bool wpcm_fiu_4ba_match(const struct spi_mem_op = *op) static int wpcm_fiu_4ba_exec(struct spi_mem *mem, const struct spi_mem_op = *op) { struct wpcm_fiu_spi *fiu =3D spi_controller_get_devdata(mem->spi->control= ler); - int cs =3D mem->spi->chip_select; + int cs =3D spi_get_chipselect(mem->spi, 0); =20 wpcm_fiu_ects_assert(fiu, cs); =20 @@ -241,7 +241,7 @@ static bool wpcm_fiu_rdid_match(const struct spi_mem_op= *op) static int wpcm_fiu_rdid_exec(struct spi_mem *mem, const struct spi_mem_op= *op) { struct wpcm_fiu_spi *fiu =3D spi_controller_get_devdata(mem->spi->control= ler); - int cs =3D mem->spi->chip_select; + int cs =3D spi_get_chipselect(mem->spi, 0); =20 /* First transfer */ wpcm_fiu_set_opcode(fiu, op->cmd.opcode); @@ -278,7 +278,7 @@ static bool wpcm_fiu_dummy_match(const struct spi_mem_o= p *op) static int wpcm_fiu_dummy_exec(struct spi_mem *mem, const struct spi_mem_o= p *op) { struct wpcm_fiu_spi *fiu =3D spi_controller_get_devdata(mem->spi->control= ler); - int cs =3D mem->spi->chip_select; + int cs =3D spi_get_chipselect(mem->spi, 0); =20 wpcm_fiu_ects_assert(fiu, cs); =20 @@ -376,7 +376,7 @@ static int wpcm_fiu_adjust_op_size(struct spi_mem *mem,= struct spi_mem_op *op) static int wpcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc) { struct wpcm_fiu_spi *fiu =3D spi_controller_get_devdata(desc->mem->spi->c= ontroller); - int cs =3D desc->mem->spi->chip_select; + int cs =3D spi_get_chipselect(desc->mem->spi, 0); =20 if (desc->info.op_tmpl.data.dir !=3D SPI_MEM_DATA_IN) return -ENOTSUPP; @@ -400,7 +400,7 @@ static int wpcm_fiu_dirmap_create(struct spi_mem_dirmap= _desc *desc) static ssize_t wpcm_fiu_direct_read(struct spi_mem_dirmap_desc *desc, u64 = offs, size_t len, void *buf) { struct wpcm_fiu_spi *fiu =3D spi_controller_get_devdata(desc->mem->spi->c= ontroller); - int cs =3D desc->mem->spi->chip_select; + int cs =3D spi_get_chipselect(desc->mem->spi, 0); =20 if (offs >=3D MAX_MEMORY_SIZE_PER_CS) return -ENOTSUPP; diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c index 8628241ec99e..5d23411f2a3e 100644 --- a/drivers/spi/spi-xcomm.c +++ b/drivers/spi/spi-xcomm.c @@ -58,7 +58,7 @@ static int spi_xcomm_sync_config(struct spi_xcomm *spi_xc= omm, unsigned int len) static void spi_xcomm_chipselect(struct spi_xcomm *spi_xcomm, struct spi_device *spi, int is_active) { - unsigned long cs =3D spi->chip_select; + unsigned long cs =3D spi_get_chipselect(spi, 0); uint16_t chipselect =3D spi_xcomm->chipselect; =20 if (is_active) diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index d2f9eea5e093..5dd3d1901412 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c @@ -213,7 +213,7 @@ static void xilinx_spi_chipselect(struct spi_device *sp= i, int is_on) */ =20 cs =3D xspi->cs_inactive; - cs ^=3D BIT(spi->chip_select); + cs ^=3D BIT(spi_get_chipselect(spi, 0)); =20 /* Activate the chip select */ xspi->write_fn(cs, xspi->regs + XSPI_SSR_OFFSET); @@ -228,9 +228,9 @@ static int xilinx_spi_setup_transfer(struct spi_device = *spi, struct xilinx_spi *xspi =3D spi_master_get_devdata(spi->master); =20 if (spi->mode & SPI_CS_HIGH) - xspi->cs_inactive &=3D ~BIT(spi->chip_select); + xspi->cs_inactive &=3D ~BIT(spi_get_chipselect(spi, 0)); else - xspi->cs_inactive |=3D BIT(spi->chip_select); + xspi->cs_inactive |=3D BIT(spi_get_chipselect(spi, 0)); =20 return 0; } diff --git a/drivers/spi/spi-xlp.c b/drivers/spi/spi-xlp.c index e5707fe5c8f1..3b91cdd5ae21 100644 --- a/drivers/spi/spi-xlp.c +++ b/drivers/spi/spi-xlp.c @@ -139,7 +139,7 @@ static int xlp_spi_setup(struct spi_device *spi) int cs; =20 xspi =3D spi_master_get_devdata(spi->master); - cs =3D spi->chip_select; + cs =3D spi_get_chipselect(spi, 0); /* * The value of fdiv must be between 4 and 65535. */ @@ -350,7 +350,7 @@ static int xlp_spi_transfer_one(struct spi_master *mast= er, struct xlp_spi_priv *xspi =3D spi_master_get_devdata(master); int ret =3D 0; =20 - xspi->cs =3D spi->chip_select; + xspi->cs =3D spi_get_chipselect(spi, 0); xspi->dev =3D spi->dev; =20 if (spi_transfer_is_last(master, t)) diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c index 8558c0fe3775..ee1995b91287 100644 --- a/drivers/spi/spi-zynq-qspi.c +++ b/drivers/spi/spi-zynq-qspi.c @@ -296,7 +296,7 @@ static void zynq_qspi_chipselect(struct spi_device *spi= , bool assert) /* Select the lower (CS0) or upper (CS1) memory */ if (ctlr->num_chipselect > 1) { config_reg =3D zynq_qspi_read(xqspi, ZYNQ_QSPI_LINEAR_CFG_OFFSET); - if (!spi->chip_select) + if (!spi_get_chipselect(spi, 0)) config_reg &=3D ~ZYNQ_QSPI_LCFG_U_PAGE; else config_reg |=3D ZYNQ_QSPI_LCFG_U_PAGE; diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index 270d28a3f8eb..fb2ca9b90eab 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -468,7 +468,7 @@ static void zynqmp_qspi_chipselect(struct spi_device *q= spi, bool is_high) genfifoentry |=3D GQSPI_GENFIFO_MODE_SPI; =20 if (!is_high) { - if (!qspi->chip_select) { + if (!spi_get_chipselect(qspi, 0)) { xqspi->genfifobus =3D GQSPI_GENFIFO_BUS_LOWER; xqspi->genfifocs =3D GQSPI_GENFIFO_CS_LOWER; } else { diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 5a038c667401..a399c617ca25 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -393,7 +393,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsig= ned long arg) struct spi_controller *ctlr =3D spi->controller; =20 if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods && - ctlr->cs_gpiods[spi->chip_select]) + ctlr->cs_gpiods[spi_get_chipselect(spi, 0)]) tmp &=3D ~SPI_CS_HIGH; } =20 @@ -432,7 +432,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsig= ned long arg) } =20 if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods && - ctlr->cs_gpiods[spi->chip_select]) + ctlr->cs_gpiods[spi_get_chipselect(spi, 0)]) tmp |=3D SPI_CS_HIGH; =20 tmp |=3D spi->mode & ~SPI_MODE_MASK; @@ -805,7 +805,7 @@ static int spidev_probe(struct spi_device *spi) spidev->devt =3D MKDEV(SPIDEV_MAJOR, minor); dev =3D device_create(spidev_class, &spi->dev, spidev->devt, spidev, "spidev%d.%d", - spi->master->bus_num, spi->chip_select); + spi->master->bus_num, spi_get_chipselect(spi, 0)); status =3D PTR_ERR_OR_ZERO(dev); } else { dev_dbg(&spi->dev, "no minor number available!\n"); diff --git a/include/trace/events/spi.h b/include/trace/events/spi.h index c0d9844befd7..c0248a8fa79c 100644 --- a/include/trace/events/spi.h +++ b/include/trace/events/spi.h @@ -57,7 +57,7 @@ TRACE_EVENT(spi_setup, =20 TP_fast_assign( __entry->bus_num =3D spi->controller->bus_num; - __entry->chip_select =3D spi->chip_select; + __entry->chip_select =3D spi_get_chipselect(spi, 0); __entry->mode =3D spi->mode; __entry->bits_per_word =3D spi->bits_per_word; __entry->max_speed_hz =3D spi->max_speed_hz; @@ -88,7 +88,7 @@ TRACE_EVENT(spi_set_cs, =20 TP_fast_assign( __entry->bus_num =3D spi->controller->bus_num; - __entry->chip_select =3D spi->chip_select; + __entry->chip_select =3D spi_get_chipselect(spi, 0); __entry->mode =3D spi->mode; __entry->enable =3D enable; ), @@ -113,7 +113,7 @@ DECLARE_EVENT_CLASS(spi_message, =20 TP_fast_assign( __entry->bus_num =3D msg->spi->controller->bus_num; - __entry->chip_select =3D msg->spi->chip_select; + __entry->chip_select =3D spi_get_chipselect(msg->spi, 0); __entry->msg =3D msg; ), =20 @@ -154,7 +154,7 @@ TRACE_EVENT(spi_message_done, =20 TP_fast_assign( __entry->bus_num =3D msg->spi->controller->bus_num; - __entry->chip_select =3D msg->spi->chip_select; + __entry->chip_select =3D spi_get_chipselect(msg->spi, 0); __entry->msg =3D msg; __entry->frame =3D msg->frame_length; __entry->actual =3D msg->actual_length; @@ -197,7 +197,7 @@ DECLARE_EVENT_CLASS(spi_transfer, =20 TP_fast_assign( __entry->bus_num =3D msg->spi->controller->bus_num; - __entry->chip_select =3D msg->spi->chip_select; + __entry->chip_select =3D spi_get_chipselect(msg->spi, 0); __entry->xfer =3D xfer; __entry->len =3D xfer->len; =20 --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 F1A2CC7618A for ; Fri, 10 Mar 2023 17:34:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230240AbjCJRel (ORCPT ); Fri, 10 Mar 2023 12:34:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230041AbjCJReb (ORCPT ); Fri, 10 Mar 2023 12:34:31 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2089.outbound.protection.outlook.com [40.107.237.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75190120EAB; Fri, 10 Mar 2023 09:34:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UtIb/v/UGk5nJL+pzs0c0LWa5+sO5iASGHR9GWviUERfUy/cnFl1ddq5Kb2lQx7aGjJA1si2qNt9PZ1onwofLLceGnCkUv1b2zG9VD2OUwOOs34kWB+2nRw+A5VMMVuqj6UxUslo9disxFAoegRfFyCZuwQyQDsWotsqyphFJOS+b4Sn7tql2uFzwjCflP6ZDBb278I+9t1hos2bfX1IUnqOsFOfeRH8pWbOfqPXUPFwGfBQywyYO/aYrbuKiWVM3vDPw60bpWydo605S37LqEl9vcX61iurJgiZ4lwu35wf75GqXQeRebj83plmbsdE9IaQjqfplaYLbPgC9pE/zg== 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=l/FkuphY6bwHQcB7w+5PPDqXWPlYdqqVovHuVQJsw7k=; b=Iv1/pDGo4GXYzjAmT2VF4NeQpKDiDE/sSztb/iUTrmiFjTNoKMWlKOC6lOJKlLVtX6TLg873C0D918TsL3bBCjfs8zJr5f9L8UrxhLHt5yYrF5YJenCIyKSQMO2jGiS2wwfJUaz02zLnYnL/nRulM8U3bK6tNUFvgB9/5ooas4K6sytKKFrRT1ua/hBodc0g9sp2SAKSKtUWdMLo2tmtmtkECz4w+couohVVpIrRN7+wCRc5EfPz8RBt2clbLrXbxAPWPLxM3SpQPNnW7n2fQcFSB1nZON/R7iBCh1lZN4N4mvHR0aitfCiEERYF/PPFCIuduvukekjsFHotBEXDZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=temperror 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=l/FkuphY6bwHQcB7w+5PPDqXWPlYdqqVovHuVQJsw7k=; b=fNlQ27ojAUnwzazpZkc5Sy7HriL3XHmfr255qShQs50mckcLZEHU1p4zJzgQxHCE4crrz0sJk66vlZmBL3IGZzmGee5TDsDssmRvHINsWpAOoOfpc++Ve7doV2oRwkePLzbg0a5J3W1v0f8Msg2a3pylmnJ/TK/gRDVjYTJrlaY= Received: from DS7PR03CA0176.namprd03.prod.outlook.com (2603:10b6:5:3b2::31) by CY8PR12MB7099.namprd12.prod.outlook.com (2603:10b6:930:61::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:34:10 +0000 Received: from DM6NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b2:cafe::f5) by DS7PR03CA0176.outlook.office365.com (2603:10b6:5:3b2::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:34:10 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT032.mail.protection.outlook.com (10.13.173.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:34:09 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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; Fri, 10 Mar 2023 11:34:06 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:34:06 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:33:39 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 02/15] net: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Fri, 10 Mar 2023 23:02:04 +0530 Message-ID: <20230310173217.3429788-3-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT032:EE_|CY8PR12MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a99c183-284c-4367-e132-08db218da7d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gV7hkcCGuLYxXSo0U11n5Vczs1ZH3w8xV52NCmVJsdgDIn7/rnnYxjg2CGY1wL8SP1ZJ0F/suTZw49HmDTiYT2jWlJ+2b1vip0RxKAcgIcqesohPTBvlhEAb+7YRGpjUs+02bgealk0387aYH0CGhPBpf0nFUyP//W0UjaKkraovJLuQ7dmaU053zgXNjkJoCTUsvV6G4sZeD3WDTGHcVVJ3e8V3Cp199kBgb83nne/fKV5hFzOVqMmqjOCDu7v4uleMXLFkOd7Q95415IznqcNhtyYCBiwez86vRPmEGp+AvoLysWcSo8ucxbbKeQ8yy/SqwkmhUoxQHnPwK6sITS6R2+/4v40vdtTLzAT0Y4DLYpVZsNxX/56iTgYsKn72ctpKU6GYw9EP9b2CfugyIyC9tqHVS6ODEURtcFFIsQlja7YKfU9ZHUTwbDJ0PQ4OjFhxJWTBcB79HZrngTeeE+jwgjId/NhnHV6z4KyWn6mk5YpWz3HuzcWTmPko7gKTNfKnAJtmgGlMiyatEFAZT5du6z35Non804lpPw7GhIuiptsiK58agUBghcAeNbo37rDkvUsRbUEwcS+jRaIz6A+dIHlLgTl7LDKCkSYQb70UwMGKnsL85phrZuSWui0+9kJ8dM94pieg/ASZjJJ7c9gflBeWQXunjrZ0cogOK59pyY8yO1kBEIUs0ZC+nxh/S3vUwzVwRl8FZ5CYgzT+Jf4NwxEr/5dbzeepIQcZU1iCwmjYReUPW4811UvzqKQBsq5GqqY2Pwfe7PzWB/TB9yqwQqSvyBoI7bzBEf+8hWS3S/5+bEFB75ONN2iWKlFKGtHsqR1Swp6Evln48ckpfendPW0KdUc0e3LLyDVr0R0= 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:(13230025)(4636009)(346002)(376002)(39860400002)(136003)(396003)(451199018)(36840700001)(40470700004)(46966006)(40460700003)(36756003)(2616005)(186003)(54906003)(110136005)(478600001)(7276002)(2906002)(7366002)(316002)(7416002)(5660300002)(70586007)(70206006)(8676002)(7336002)(4326008)(41300700001)(8936002)(7406005)(26005)(1191002)(81166007)(356005)(921005)(86362001)(36860700001)(6666004)(40480700001)(82740400003)(1076003)(63370400001)(82310400005)(63350400001)(83380400001)(336012)(47076005)(426003)(36900700001)(84006005)(83996005)(2101003)(41080700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:34:09.1411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a99c183-284c-4367-e132-08db218da7d5 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: DM6NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7099 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra Reviewed-by: Michal Simek Reviewed-by: Lukasz Stelmach --- drivers/net/ethernet/adi/adin1110.c | 2 +- drivers/net/ethernet/asix/ax88796c_main.c | 2 +- drivers/net/ethernet/davicom/dm9051.c | 2 +- drivers/net/ethernet/qualcomm/qca_debug.c | 2 +- drivers/net/ieee802154/ca8210.c | 2 +- drivers/net/wan/slic_ds26522.c | 2 +- drivers/net/wireless/marvell/libertas/if_spi.c | 2 +- drivers/net/wireless/silabs/wfx/bus_spi.c | 2 +- drivers/net/wireless/st/cw1200/cw1200_spi.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/adi/adin1110.c b/drivers/net/ethernet/adi= /adin1110.c index 3f316a0f4158..f5c2d7a9abc1 100644 --- a/drivers/net/ethernet/adi/adin1110.c +++ b/drivers/net/ethernet/adi/adin1110.c @@ -515,7 +515,7 @@ static int adin1110_register_mdiobus(struct adin1110_pr= iv *priv, return -ENOMEM; =20 snprintf(priv->mii_bus_name, MII_BUS_ID_SIZE, "%s-%u", - priv->cfg->name, priv->spidev->chip_select); + priv->cfg->name, spi_get_chipselect(priv->spidev, 0)); =20 mii_bus->name =3D priv->mii_bus_name; mii_bus->read =3D adin1110_mdio_read; diff --git a/drivers/net/ethernet/asix/ax88796c_main.c b/drivers/net/ethern= et/asix/ax88796c_main.c index 21376c79f671..e551ffaed20d 100644 --- a/drivers/net/ethernet/asix/ax88796c_main.c +++ b/drivers/net/ethernet/asix/ax88796c_main.c @@ -1006,7 +1006,7 @@ static int ax88796c_probe(struct spi_device *spi) ax_local->mdiobus->parent =3D &spi->dev; =20 snprintf(ax_local->mdiobus->id, MII_BUS_ID_SIZE, - "ax88796c-%s.%u", dev_name(&spi->dev), spi->chip_select); + "ax88796c-%s.%u", dev_name(&spi->dev), spi_get_chipselect(spi, 0)); =20 ret =3D devm_mdiobus_register(&spi->dev, ax_local->mdiobus); if (ret < 0) { diff --git a/drivers/net/ethernet/davicom/dm9051.c b/drivers/net/ethernet/d= avicom/dm9051.c index de7105a84747..70728b2e5f18 100644 --- a/drivers/net/ethernet/davicom/dm9051.c +++ b/drivers/net/ethernet/davicom/dm9051.c @@ -1123,7 +1123,7 @@ static int dm9051_mdio_register(struct board_info *db) db->mdiobus->phy_mask =3D (u32)~BIT(1); db->mdiobus->parent =3D &spi->dev; snprintf(db->mdiobus->id, MII_BUS_ID_SIZE, - "dm9051-%s.%u", dev_name(&spi->dev), spi->chip_select); + "dm9051-%s.%u", dev_name(&spi->dev), spi_get_chipselect(spi, 0)); =20 ret =3D devm_mdiobus_register(&spi->dev, db->mdiobus); if (ret) diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethern= et/qualcomm/qca_debug.c index f62c39544e08..6f2fa2a42770 100644 --- a/drivers/net/ethernet/qualcomm/qca_debug.c +++ b/drivers/net/ethernet/qualcomm/qca_debug.c @@ -119,7 +119,7 @@ qcaspi_info_show(struct seq_file *s, void *what) seq_printf(s, "SPI mode : %x\n", qca->spi_dev->mode); seq_printf(s, "SPI chip select : %u\n", - (unsigned int)qca->spi_dev->chip_select); + (unsigned int)spi_get_chipselect(qca->spi_dev, 0)); seq_printf(s, "SPI legacy mode : %u\n", (unsigned int)qca->legacy_mode); seq_printf(s, "SPI burst length : %u\n", diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca821= 0.c index e1a569b99e4a..7093a07141bb 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -2967,7 +2967,7 @@ static int ca8210_test_interface_init(struct ca8210_p= riv *priv) sizeof(node_name), "ca8210@%d_%d", priv->spi->master->bus_num, - priv->spi->chip_select + spi_get_chipselect(priv->spi, 0) ); =20 test->ca8210_dfs_spi_int =3D debugfs_create_file( diff --git a/drivers/net/wan/slic_ds26522.c b/drivers/net/wan/slic_ds26522.c index 6063552cea9b..8a51cfcff99e 100644 --- a/drivers/net/wan/slic_ds26522.c +++ b/drivers/net/wan/slic_ds26522.c @@ -211,7 +211,7 @@ static int slic_ds26522_probe(struct spi_device *spi) =20 ret =3D slic_ds26522_init_configure(spi); if (ret =3D=3D 0) - pr_info("DS26522 cs%d configured\n", spi->chip_select); + pr_info("DS26522 cs%d configured\n", spi_get_chipselect(spi, 0)); =20 return ret; } diff --git a/drivers/net/wireless/marvell/libertas/if_spi.c b/drivers/net/w= ireless/marvell/libertas/if_spi.c index ff1c7ec8c450..1225fc0e3352 100644 --- a/drivers/net/wireless/marvell/libertas/if_spi.c +++ b/drivers/net/wireless/marvell/libertas/if_spi.c @@ -1051,7 +1051,7 @@ static int if_spi_init_card(struct if_spi_card *card) "spi->max_speed_hz=3D%d\n", card->card_id, card->card_rev, card->spi->master->bus_num, - card->spi->chip_select, + spi_get_chipselect(card->spi, 0), card->spi->max_speed_hz); err =3D if_spi_prog_helper_firmware(card, helper); if (err) diff --git a/drivers/net/wireless/silabs/wfx/bus_spi.c b/drivers/net/wirele= ss/silabs/wfx/bus_spi.c index 7fb1afb8ed31..160b90114aad 100644 --- a/drivers/net/wireless/silabs/wfx/bus_spi.c +++ b/drivers/net/wireless/silabs/wfx/bus_spi.c @@ -208,7 +208,7 @@ static int wfx_spi_probe(struct spi_device *func) =20 /* Trace below is also displayed by spi_setup() if compiled with DEBUG */ dev_dbg(&func->dev, "SPI params: CS=3D%d, mode=3D%d bits/word=3D%d speed= =3D%d\n", - func->chip_select, func->mode, func->bits_per_word, func->max_speed_hz); + spi_get_chipselect(func, 0), func->mode, func->bits_per_word, func->max_= speed_hz); if (func->bits_per_word !=3D 16 && func->bits_per_word !=3D 8) dev_warn(&func->dev, "unusual bits/word value: %d\n", func->bits_per_wor= d); if (func->max_speed_hz > 50000000) diff --git a/drivers/net/wireless/st/cw1200/cw1200_spi.c b/drivers/net/wire= less/st/cw1200/cw1200_spi.c index fe0d220da44d..c82c0688b549 100644 --- a/drivers/net/wireless/st/cw1200/cw1200_spi.c +++ b/drivers/net/wireless/st/cw1200/cw1200_spi.c @@ -378,7 +378,7 @@ static int cw1200_spi_probe(struct spi_device *func) func->mode =3D SPI_MODE_0; =20 pr_info("cw1200_wlan_spi: Probe called (CS %d M %d BPW %d CLK %d)\n", - func->chip_select, func->mode, func->bits_per_word, + spi_get_chipselect(func, 0), func->mode, func->bits_per_word, func->max_speed_hz); =20 if (cw1200_spi_on(plat_data)) { --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 4F478C76186 for ; Fri, 10 Mar 2023 17:35:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230486AbjCJRfR (ORCPT ); Fri, 10 Mar 2023 12:35:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbjCJRfN (ORCPT ); Fri, 10 Mar 2023 12:35:13 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2044.outbound.protection.outlook.com [40.107.243.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FC6AF31F0; Fri, 10 Mar 2023 09:34:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VGnpyLYpSSbnKhKkZHaDMeFceCxDNaOH1FBmKch0Yo6SS5qf1f4fs4S6CNWzhajuWHpW3sQmCkFU57CvRyx2qw55J7iZy2Wfa/06HD5/yg+1csduMU4SQcRmmm5flKIU3Bqk1zEdCkrMaINw1C+U5tk2jRiAJbElUiPnABEfiWtkMRwPngQTq24c+GwzQNkT9vW0oRvqZqErJPUA4ghuoNDmfGsdNhCEHUujzFIhLuVIISPJqUjnTsEd3VmtUbc70o7W9U/R1KU89/FjNZ6kmlDCxJ421+YpR9/Mv4PJZ9Hx8r3aoQCTkm2WeQSBXuvjGE/2f8qOPAELJJ0aTLmooA== 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=PGTDv9j62eqAAUbZYCqOwhh6o6pzCwATcSrO/Vzqvog=; b=nDdiZGsXMImFPNUTrIcuhQkYs4v09i1Q7G5Fc8TJnyqMV7QgvTaVPMGOSO3cnhiuoeZUFiqrFaHjIqO7Z0Zrb+kOEO8BWI0h3EzW0fkXffHTdGdMXX51mIVqFGQgIjMd9p9K5tBMEXdkTdDlqNG7IwF9JtKiPrqnniF/16AvMwo4cVZt6OsbVrL12TGDIBa/FGdE2L2GO3bhNLSbkDxUyc7YLXrXxUPiZz8ye/wy5dAAZ+dBn2/cMn0g2qP0m1e2Ef2nARjhYVJUBezwM70QijdfBs5xLTfUp+G5Myu6pAEJZbSDK59a+Iwf2yDPLslU+tp8WxexmoXFFIYowh22gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=temperror 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=PGTDv9j62eqAAUbZYCqOwhh6o6pzCwATcSrO/Vzqvog=; b=ywYxtFHuYI3a7wiJBXwoHFW8zHURijvDZVZapy9NHFdCF+9zFZa/9TmluHqKVZs/+9Pq8DYAib7deOUhgscw+YDRoM3k1haJ+ceJ4BLXypiCPu/SHg5tMSXn/TFemK/wf7o+5nAlN4UJDk3YC9zOswwqqZZbVVhtN7UlhIsiMuo= Received: from DM6PR01CA0030.prod.exchangelabs.com (2603:10b6:5:296::35) by BL1PR12MB5224.namprd12.prod.outlook.com (2603:10b6:208:319::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.20; Fri, 10 Mar 2023 17:34:36 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:5:296:cafe::fe) by DM6PR01CA0030.outlook.office365.com (2603:10b6:5:296::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:34:35 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:34:35 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) 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; Fri, 10 Mar 2023 11:34:33 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 09:34:33 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:34:06 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH V6 03/15] iio: imu: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Fri, 10 Mar 2023 23:02:05 +0530 Message-ID: <20230310173217.3429788-4-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT049:EE_|BL1PR12MB5224:EE_ X-MS-Office365-Filtering-Correlation-Id: daa8f0e0-27f8-4b28-ca0b-08db218db74e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fzSPlN4fWA9/JhlR+c1dMnXMqVbOtQ3yVwzWxZ6boJ813Nh2jCBJmpdoZw5FV7heOYd88TbhEmc46tT+lfpHe5v+PZT5FLuzvVf6Klab3gdtnUC7axUMFo9uAB7i0EQq5dA0XlbwMu9YklYgVgTGuvN0sRVXc8mChHCxKrjMe6jdwOaqdz1vi8E1JsUW3gTxBzsZtgC4g59pUH4AsI1ae13Rt4gPimtSNRwZrJucgg7jJd68C2pPPEzU4+NKt6MxX0l8QrJJRxiG2SiAfGlYuMyVhoLj8cyL5KUoLN1U9c2R7EreZ+qE7n45i3SeY22YGDb0dmPSKSAGCPc3t/zR+uHLUi8AUXwf0WZ+RUFB79ZjdtJSnBJk9vG9xeZK6pH1QUr5BI7Dr4smak9MIdxfdnzLUXHrRi5a3y57lWvODzMEYq+T8yZQ9lJkHlrD1h9enuhfr0xjvTa5Reo4llsd3JE65r4D8l0gk+9FT39axvrIbqH8u6uuQGgatIDGVK5YuUyS72FMaIi99neGXNgGxWW8qRZzRohGZPZSa9+hUO0MRXce53oosXRKIuE9r73wDJtuR2XgCZKmQQ+/gXsMLYrAEGrKUOkAsf2rZxtumlTsf3G5Eo89Fs8AX626GUR6UaGgZMgmHALGXJ40Su485H8Khz7M9qmO1f2HJPY40CIl8HOrESyQ6YFFt6UyX327SsF92mJZZTZOScC2nFmVF410Qnad4I/8q2UmBTgEDZyJr/FWCAq5jzb12HhesjoDVI8ECP7cbyZ54EcfhSxeZCEmOPtIxPI+kLD/Y+Qhw8YZHWT8E5n0LqfitHa0KDrWNwqnxKTkHXdk8A5e/pW0hzT0b6RAwd4oOHPWehcu0+o= 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:(13230025)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199018)(36840700001)(46966006)(40470700004)(36860700001)(356005)(86362001)(921005)(81166007)(82740400003)(36756003)(2906002)(41300700001)(7276002)(7416002)(7366002)(7336002)(7406005)(8936002)(5660300002)(40460700003)(40480700001)(1191002)(4326008)(82310400005)(63370400001)(186003)(26005)(1076003)(83380400001)(63350400001)(336012)(2616005)(426003)(47076005)(54906003)(316002)(110136005)(70206006)(8676002)(70586007)(478600001)(36900700001)(41080700001)(2101003)(84006005)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:34:35.0994 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: daa8f0e0-27f8-4b28-ca0b-08db218db74e 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: DM6NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5224 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra Acked-by: Jonathan Cameron Reviewed-by: Michal Simek --- drivers/iio/imu/adis16400.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c index c02fc35dceb4..3eda32e12a53 100644 --- a/drivers/iio/imu/adis16400.c +++ b/drivers/iio/imu/adis16400.c @@ -466,7 +466,7 @@ static int adis16400_initial_setup(struct iio_dev *indi= o_dev) =20 dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n", indio_dev->name, prod_id, - st->adis.spi->chip_select, st->adis.spi->irq); + spi_get_chipselect(st->adis.spi, 0), st->adis.spi->irq); } /* use high spi speed if possible */ if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) { --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 F0098C76186 for ; Fri, 10 Mar 2023 17:35:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230063AbjCJRf4 (ORCPT ); Fri, 10 Mar 2023 12:35:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230050AbjCJRft (ORCPT ); Fri, 10 Mar 2023 12:35:49 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D62F7DD11; Fri, 10 Mar 2023 09:35:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aanLT9ZFyPF0DDqLmeuL5c/vsUTAGsCQ3ZjoxPyse5CGNgpWY1fiAAjKliqoQ/6TrrCEq2jIcZ0BHZwf+o8a7yq/o0mVjuhhNw4DEvlts1aTH9pnYCfkcr/CvHZBcCXIu1AH7zTUNdh63xR/LyjRBfkw+oSMGEmP/beM3NAb4UiKRSdCAHqvX4+txixXULnuhkcko2RVRrYQFGEa1eCUft3YzLuG2av0030S9TwcrxqUJgYwcHb5D/hAlx0rYM2PVVXBipS/zHLvJv3i0q1rA9z8NHp0yYH3MCs4qkO/4ewuU4bfA612BwohsKCmSxpZ7Lq8UQ1ExwA6bvO6tVZ7lQ== 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=u0SjpM/Jdk6oe9dWyUvfwsJIXdYePKsDAv1sJ/FnmC8=; b=JyacWG5WtzaPNa5hoA0hONjTIO78vXfhwmhq+tpLzslDPv5KsKNrg6MIgJQFDHdd0tpuR+QkARQQd9OEmsaCFFi0e7lKB2iWm000i7bOLlTv0WVoLmX/leGg/37khxRPHUqJxCE9fMizfoASjQCkGgaWHcMiRUu08yYTY0XJ7+dL+0WOTwWOrXgeyL9SqSFWYJeIlM3NQvUxoEmMEQcji9UT7u36TqwGo6zVtUAT+L8nOkYERa3juCHAE3zsZ7LUHZJN3KtYfDBviiL4WnqU2gjg8eJRMQsADrSF6Ns3GP65Y5oF8THHIm1obIM6Oky/vJVFhWgKNjEcHHf8adzshg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=u0SjpM/Jdk6oe9dWyUvfwsJIXdYePKsDAv1sJ/FnmC8=; b=VCdj2ugvSmUu9IJxoKaKFzgXsZBhpz+LLKzsyO8nHJPUd67MZmoPWOlUATLPIHXO5+j6gF3IJQa87G2+rhrpSnz6I4+w/aO+gmMntfFY78q+P2QR7N8/KswEyqmdv0MCajO7frqWb12doDu+iadcx30yAIc9G/p855tRJUI6iAg= Received: from BN1PR10CA0027.namprd10.prod.outlook.com (2603:10b6:408:e0::32) by MN0PR12MB5978.namprd12.prod.outlook.com (2603:10b6:208:37d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:35:02 +0000 Received: from BN8NAM11FT116.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e0:cafe::44) by BN1PR10CA0027.outlook.office365.com (2603:10b6:408:e0::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:35:02 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT116.mail.protection.outlook.com (10.13.176.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.21 via Frontend Transport; Fri, 10 Mar 2023 17:35:02 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:35:01 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 09:35:00 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:34:34 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 04/15] mtd: devices: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Fri, 10 Mar 2023 23:02:06 +0530 Message-ID: <20230310173217.3429788-5-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT116:EE_|MN0PR12MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: e8a39af0-74f8-46ad-0166-08db218dc75a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xUo5uxVLV/Gkgn5tSJnXpvfgI4bFJyRIlwHXRA1t5VMN0fYyIIN7b3nkSQcayiKIttv5+dT72BT19z4z1yGHCL1hhoJzPK7DQskIewn6iGTOQecmoJe1rSGWd3Z//7JHk0nqogqaxjj3+Sl3xkASiteyKc0TZL9aZcnPHuAO5jofaqhZjr/jKbYoj3pkoUrEWzlmyaCHUJicch7fB+94cYIxZfMf6dtBPpviZn/lygCu325qZHvhPogTV/51T771gb51UvTSGJJ5ELcy83SD16XKZSqWCHWsssUFjNi62KWQeFrieN9vaRyyOPm5X0OcntCUc6c3DKkq0jG1wmRVk5wZZ0z6IVNKyc5J6IZ4xIqYrNrZx8FYXI4OseC70k0azP7AAYNMXd5xO9xX2PxnMfYN+iLTJFh7FkicG993tzvCEPQE86Y75Ph3dlPowyexKVlZ66CMYy47qJNmF7CBZaA67Ose4APLnR8+lu9A/g7TsQl0I0wXhmaOKLlcFa4P0/kLzw5ji9sC+t2t7CY8q55P7jQumx6B6/Tj9UOgU/kGXKCMLsWhIGnXae5F3DVvQf3DZJlzHdBKC3JL5kCK5y2mLUr8x/3viLPc8fbMp3nUwIm3VL+/18bAzJ6cfnz1/OmwrfpRdI//5c0UdLcR/5We9eBO3TGU7jZUBKnoT7uO/K70t4BwmorP5fPKPAosAFh3GOnDxlr+c4AtitrxeaI7ABkARABvA4ImB+xym5WFMu0dxp5avkmgqsX7+oaceC/b/04OCPn/6ZNJYButBfwGSOWvCZRGJxSFIYjrEXr+2VfKOiwhDsRfnyTNppSyUBJ097nlNlTBihEkFrHvhrJXjNYmyvyOZNW1RKkXer8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(396003)(376002)(346002)(39860400002)(136003)(451199018)(46966006)(36840700001)(40470700004)(336012)(47076005)(426003)(921005)(110136005)(186003)(40460700003)(36756003)(54906003)(81166007)(40480700001)(356005)(86362001)(36860700001)(1076003)(26005)(83380400001)(82310400005)(82740400003)(6666004)(7416002)(2616005)(1191002)(8936002)(2906002)(7276002)(5660300002)(316002)(7336002)(478600001)(70206006)(7366002)(7406005)(4326008)(41300700001)(8676002)(70586007)(36900700001)(83996005)(2101003)(41080700001)(84006005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:35:02.0320 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e8a39af0-74f8-46ad-0166-08db218dc75a 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT116.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5978 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra Reviewed-by: Michal Simek --- drivers/mtd/devices/mtd_dataflash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_= dataflash.c index 3bbaa590c768..1d3b2a94581f 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c @@ -639,7 +639,7 @@ static int add_dataflash_otp(struct spi_device *spi, ch= ar *name, int nr_pages, =20 /* name must be usable with cmdlinepart */ sprintf(priv->name, "spi%d.%d-%s", - spi->master->bus_num, spi->chip_select, + spi->master->bus_num, spi_get_chipselect(spi, 0), name); =20 device =3D &priv->mtd; --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 A0F1CC76186 for ; Fri, 10 Mar 2023 17:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbjCJRgl (ORCPT ); Fri, 10 Mar 2023 12:36:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbjCJRgg (ORCPT ); Fri, 10 Mar 2023 12:36:36 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38908120867; Fri, 10 Mar 2023 09:35:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VuTgskPW7/J+dDDNKAo0s8HTRPEMj95aGaulhCerl+7slwVK5HXwGr+KgaOGOmGju9KFDgkjai94nqcZRFDEm0zdHU7nybxph4lSmkKbDOJOJsxM8TD7a+QLOa5upSHpPFgNsqJpF6M0ZVbhJOz4EV8nqrcPlka+hzDDlQs0szEQTnqeLa7IiM6ri7lrzLZkvjOOaURX88Rxl3AqlpSvcatSqe7KEhKffxUKUKCfEkJQMIHegE8xly7wU2RKxFjBBo/KhkCQ1U0LnAL2TbT4B7NAQVZqY5NtM+HFUGB7R96ZmvZup/jAyNfjjjQn40IpE54MCf8V0zfAL1wcys00yA== 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=JrN+S0no9tJJWOPy0MesAGh9gOiwa6v7pOuBcPHrftY=; b=k5WRHNlVSwQWyKK8Sxb/VOSMHFjtouPl5Tmc5YyGx25Eu009zVdF6TLzCbktHSRPaQkFaZKT/9iKaCxfUwaMN0QQ8JBVDpnNv6ew4aGYEHZUiDS2k7LvaUa/PbxjK8p/yFvvVlzvubVWdT3NuKSxJPAbBIbUTexrjCubqGN8ehRiISnCR7w0YTgCtk0qSmNv+2wr331lSpMFRj411AiF7T82I2R5iD40TqBno4aPVdcrn633awbkNnITQj5NWHaZm1vyyI6XbTXa15LeB6q9PmAMmn3WH86Nj+4ePXeZ+BXnAoDVGry2BI4PoVlYrblX73jzC6CWVuanW+a6Z6xjag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=JrN+S0no9tJJWOPy0MesAGh9gOiwa6v7pOuBcPHrftY=; b=hpauHXnNjR9YkcOju+Vs7fQx7GGP1Q3mJxT+9kcfuSH0kc3wkgjr/qDqyidKsOWmzZ0Bc7+bJcasthQ94xlwrRiQP+/IkaNVIr54pVJauxEygOxNrQj5nparjpGxcdnWe6fbNKa1vELQZgbR7rJDKvmktlXRvL+9FG1vwUZ0Iz4= Received: from BN9PR03CA0128.namprd03.prod.outlook.com (2603:10b6:408:fe::13) by BY5PR12MB4276.namprd12.prod.outlook.com (2603:10b6:a03:20f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:35:30 +0000 Received: from BN8NAM11FT089.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::7d) by BN9PR03CA0128.outlook.office365.com (2603:10b6:408:fe::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:35:30 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT089.mail.protection.outlook.com (10.13.176.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:35:29 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:35:29 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:35:28 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:35:01 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , "Greg Kroah-Hartman" Subject: [PATCH V6 05/15] staging: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Fri, 10 Mar 2023 23:02:07 +0530 Message-ID: <20230310173217.3429788-6-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT089:EE_|BY5PR12MB4276:EE_ X-MS-Office365-Filtering-Correlation-Id: 5511b961-59c9-48e2-391e-08db218dd7ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vHo5wxM5reV23mqh37RuO4W9vdK1162YScRMwW6IXSCUqIhLeJAUyo6+UUQAM1tT8Mf3Rh2hPXHFVkmYqicje7bEVpMAhXA8i966WmnMM2OVXpsD1fn/uagsWACXHcD/P+YfttBCrjYQ3aXiyQqCYx8jhA/mT0wBwlGItyC/nUTBnUN9rrrIZchBWv7AJAQ1yHtaR64aSU4voIWytCM8izN9G7zGRKc+4rNPMdPZd5KCMPg390FDuLriisSlOrWzvlaPZMXIyGllczhrUUVV0yQOTpNUlHH7SZTdUZKQdYzo4x4F1BKgmU5yvLOAbcljNLOAoYtQYyWADFeAtQIg5xaWjmRiCRR4prNHjRf4GvQFZofSlKUnkCh1k8xAI7me9k2t4LJgQ4llUzc02frGEglIO+Ls2LzolcetcYJY1QfLGxTWCEtYgybsGg8H+5SJ6EM4g1a0LbSWCaAAYU90O1g4EbT2JtvRUQQNOwpcl8HJyYR4uzo5XV6tX+DM8oRzxb4NCYeAvP0hHaD0J7MpcTpwgdM/NqTfgMElw5XfBVfDPBIJmeYVHeaOmPJsoivbuqg1NDtTxc2CMlnUHOghELKBdRHgG++gVKpfSnxQXM9Kf1Lk0OkVhjBFMfCHQrnlf+6AMYV977QZSNRfTP3BnJBXN+OPEr47dNfs4NS35ERJ2Ta2BQMCX+DvN5BHH3oPHhyarb3gM8VGHfa+nN2+d8QDerNW8LLpZZVHiYb4YbTXiJCu4FmKnNC3r3Ik2+RukBOP9aXJzI14PSN/eagsccY65zlJMzbR37Cw4CFL7ISzgSdE/LfLCg/nsMLBLSIvi4xfBaUnJFuemZrvwqpRX0IL70t5xfi7DCH82LJlkso= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199018)(36840700001)(40470700004)(46966006)(36756003)(186003)(82740400003)(36860700001)(336012)(41300700001)(40460700003)(1076003)(2616005)(426003)(47076005)(83380400001)(26005)(4326008)(70206006)(8676002)(2906002)(70586007)(7336002)(5660300002)(7366002)(8936002)(7276002)(7406005)(7416002)(40480700001)(81166007)(356005)(110136005)(921005)(86362001)(316002)(478600001)(54906003)(82310400005)(1191002)(41080700001)(2101003)(36900700001)(83996005)(84006005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:35:29.8207 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5511b961-59c9-48e2-391e-08db218dd7ea 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT089.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4276 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra Reviewed-by: Greg Kroah-Hartman Reviewed-by: Michal Simek --- drivers/staging/fbtft/fbtft-core.c | 2 +- drivers/staging/greybus/spilib.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbt= ft-core.c index afaba94d1d1c..3a4abf3bae40 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -840,7 +840,7 @@ int fbtft_register_framebuffer(struct fb_info *fb_info) sprintf(text1, ", %zu KiB buffer memory", par->txbuf.len >> 10); if (spi) sprintf(text2, ", spi%d.%d at %d MHz", spi->master->bus_num, - spi->chip_select, spi->max_speed_hz / 1000000); + spi_get_chipselect(spi, 0), spi->max_speed_hz / 1000000); dev_info(fb_info->dev, "%s frame buffer, %dx%d, %d KiB video memory%s, fps=3D%lu%s\n", fb_info->fix.id, fb_info->var.xres, fb_info->var.yres, diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spi= lib.c index ad0700a0bb81..efb3bec58e15 100644 --- a/drivers/staging/greybus/spilib.c +++ b/drivers/staging/greybus/spilib.c @@ -237,7 +237,7 @@ static struct gb_operation *gb_spi_operation_create(str= uct gb_spilib *spi, request =3D operation->request->payload; request->count =3D cpu_to_le16(count); request->mode =3D dev->mode; - request->chip_select =3D dev->chip_select; + request->chip_select =3D spi_get_chipselect(dev, 0); =20 gb_xfer =3D &request->transfers[0]; tx_data =3D gb_xfer + count; /* place tx data after last gb_xfer */ --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 4E018C76188 for ; Fri, 10 Mar 2023 17:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbjCJRhM (ORCPT ); Fri, 10 Mar 2023 12:37:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230203AbjCJRhJ (ORCPT ); Fri, 10 Mar 2023 12:37:09 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2044.outbound.protection.outlook.com [40.107.220.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B85B129732; Fri, 10 Mar 2023 09:36:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mMw0Dcn4i2lMHSuR94HBa8W0W8xL9ZGK8zZccEDcEcZy/NBmtThvHaWqUxP52SxYNCIzzn+qZWqcJASIYM2zfYzzwWBwsQHn2oJYV3cNF3kKUU4tecy6iqxnWiKS51Ia4epHbvyONoWAVuu4YcBO9HbC/BUCeIh7eA56bYOpmg5kFeamKTj20ZFOeit0KjLjrwMH3AWhcH7oe1CR9+F+EsbYCiluLMqzM2aOPC7v+YIvdVHAoT27tp82gMVEqb8yE7DQyA8l7CEG4FP3q0MZNg2B6Y3DNejqvGaBjE6tSODUO6nz972ldyXOgPA7juEa0/MFr5eVeQuaLWwxKYFWXg== 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=XxTTaX0RvNIuGzXe79JJPMl4YfA6n1vchK0hnLsPc6A=; b=Ex3c01p3cFHEUQttEwX5xSPmMxaetY8325KAx2LX14MR2IusC/msw3MBfIWNOvpP+rwoOB5V+6RZSXocGz6O2v4+KRaFQFgYBs4cqw2bQucd3TkKTgJEzHDpI/y7nAjEXpmCbx6IhJEGS9TJbVHW1dlh7eJTQF+EYMeIvVgk94jigSciRWY4fcCict03JwYv0axDfI2TZCXUr9Eh8ivkyqKAGXKDbgmneM0ZdKdGHBchF4VKOxzJTHb8TGJNbwvGP1mWOPoIDj7ZsUEP5Ra6w71oKlqP9JyEhydLSxopFC42gOU4QlM6Mmp1ljFYoqBflzU5p/S3eqKuamMl8S6k5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=XxTTaX0RvNIuGzXe79JJPMl4YfA6n1vchK0hnLsPc6A=; b=QRKYOAcIzWqQDjSSZlZxk3IYX4qupJgbBbm2TkkFYJ+W693rvPFxbtU1z4V8IyUYZUxDxQl37mPLd8MAV3sBYR2r0caKJzO+YlCSxtcsob1DK0dWzrGrn3ufHsQpX5EZfwpc2/VS44SyDcHyEJGVCYU183WlF/6EF2stg7dVx1s= Received: from BN9PR03CA0161.namprd03.prod.outlook.com (2603:10b6:408:f4::16) by PH7PR12MB5688.namprd12.prod.outlook.com (2603:10b6:510:130::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:35:58 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f4:cafe::19) by BN9PR03CA0161.outlook.office365.com (2603:10b6:408:f4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:35:57 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:35:57 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:35:56 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:35:29 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 06/15] platform/x86: serial-multi-instantiate: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Fri, 10 Mar 2023 23:02:08 +0530 Message-ID: <20230310173217.3429788-7-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT039:EE_|PH7PR12MB5688:EE_ X-MS-Office365-Filtering-Correlation-Id: 25b2370d-7b69-4441-85d1-08db218de874 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HgzjGDTgQNd50moAmQMrWv1cZh62MM1NJ7CJQBdDrrX2ZZwPX3OLTEj812joHmQPb8dtNatvdqGFgzqbqIUEGH4zdSrTASsuIZlzxqCjTHjd4HU/1CGPSfd5cdhU5zgQfDPbd5gsNF3ZjySpsNi98F7iksfvQdbavrNCi3RwoS+yKS/WeieOwkHdSHkIrhquiRC2s75pkjUiJGBajRAX5eu7O8HdfGH5klUNqakFKAFhm/VqbQOaaNSNsO1QkJuAMAEhjcQfynzYjc9sFoIqnQlKBtU0epqp1BF50Pr07qk7FJ4PtU1lJWWD+mbAXggXLl22BN0FpwNqwzZQ7mHJAm9fOIFlKU653CCBwr+x6dxiwjwPuGmWIrOjXHA2kaoEBFRj40n0QTe3RovjG4wt67kUXf7aVLzF7DMBFoe0MG/ba07GGzvXQCjDS8gb/spDKcr1GVvroPyS+bPNZyohmHgHcJfNQAtLLHKTsxDuQGew9XHrmUEvcpGENpserZYyBRNZThif4wq+VQ8fUsurB+1Q+yoNtgecaU1rZWXjHNtTRJt+zrJA7U9v5JjcEkq++2vkkc42iBs11KuafwVAd+oCTBrwLo0l7V0stOpf1/fji/1zJpCSQw+0I7QSI8gSRNBbEPivBVz2i7qGLLAzSvmmnUQ+fCCRA7xNVxTUDzud+NlovWFctyyFOMilbmp8xpkG6/zlSgzvmXljN7RuBY1zWkIoZZvnLUhIT8mWFc4XdLSRvWeIAf59/0sH4kRa57zc8DFhfgACUEeylZWweFh+K79T6Ml2u3sqrt6YR4E0VnnM1DpsaKYetoFA3P016IcwASFI/ZBRiwEZxOCUHlQhTceHg+W1VYvqv6aamsw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199018)(40470700004)(46966006)(36840700001)(47076005)(336012)(426003)(186003)(110136005)(54906003)(36756003)(40460700003)(356005)(40480700001)(7366002)(86362001)(26005)(1076003)(81166007)(82740400003)(36860700001)(1191002)(82310400005)(83380400001)(478600001)(2906002)(6666004)(2616005)(316002)(7336002)(7406005)(7416002)(5660300002)(7276002)(4326008)(921005)(8936002)(70206006)(41300700001)(70586007)(8676002)(84006005)(2101003)(83996005)(41080700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:35:57.5706 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25b2370d-7b69-4441-85d1-08db218de874 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5688 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra Reviewed-by: Michal Simek --- drivers/platform/x86/serial-multi-instantiate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/serial-multi-instantiate.c b/drivers/plat= form/x86/serial-multi-instantiate.c index 5362f1a7b77c..270a4700d25d 100644 --- a/drivers/platform/x86/serial-multi-instantiate.c +++ b/drivers/platform/x86/serial-multi-instantiate.c @@ -139,7 +139,8 @@ static int smi_spi_probe(struct platform_device *pdev, = struct smi *smi, goto error; } =20 - dev_dbg(dev, "SPI device %s using chip select %u", name, spi_dev->chip_s= elect); + dev_dbg(dev, "SPI device %s using chip select %u", name, + spi_get_chipselect(spi_dev, 0)); =20 smi->spi_devs[i] =3D spi_dev; smi->spi_num++; --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 070C6C76186 for ; Fri, 10 Mar 2023 17:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230383AbjCJRhg (ORCPT ); Fri, 10 Mar 2023 12:37:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbjCJRhd (ORCPT ); Fri, 10 Mar 2023 12:37:33 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2053.outbound.protection.outlook.com [40.107.94.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5671A12A153; Fri, 10 Mar 2023 09:36:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GQfbxHp5Vc2GSHRqjVVgaA5YOtmEFVin/bcEUztu7TpZADZ1VAE8SvCffMzlq6jRTZAZe4p6Og1a9IHCD6v0j8MEfXfpIBMzWlUi3azLZOiy7MFVbhB87Fz8g5rN9GdpLXHXjhu0pJrDToa3H/0BvabJDGSnDwiY+gkme3pa3xrqMGD4VgCkWhJEx8Ku8ZEY3yTp6VEfgXkjFteLclnIscch20LlL/vQ0neRSkthyAL6GfQeeRSqzDcK7Q7d1r9o9v9w9tbghzO+zftqXp8BJYYJEtUw/Cd0g96bJW7FOY1WOPPHJYjFDqUF+cIzo47K8nJQZ2aihlK6azf0BN2TXQ== 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=3M3Cb03rj/nbO1yn3yzEnhmtHVCZH2EXdqX8XhwSkZA=; b=TQbkxOYpDSH3e+rLYj1W6+l6TR6S1IVlMa4GwhkbY88HW7WERXR851TM/zeS8FIbDvPG/VFW1+rN5iZo1PA02fbu3EDGu/LvkD23MaiRSOutBgGJTg24mhFaMkv7IgTnB8ghbm0dDjZJkPdfDlh8yvnN4tNbZjbc1o/0i0zomg+/biYxY4W69kC52q0Fk5a/1e9a3T3T0XFUZzoCF+YLNbdAXDkUAT0vseuZao/41J+nSxnlznI8iT5mRNZtJ51WQJbcj4oZb7/qGkKQ7eBS8TUrQWrhQ91s2s07vIBD8sQzqMqnTbd83ZqD1g5gLRWERixw2oNmnx1XsM3hP4KW7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=3M3Cb03rj/nbO1yn3yzEnhmtHVCZH2EXdqX8XhwSkZA=; b=e1N5ghpGgCsCs7ADFSMwGy7Ne2CZAKvHPUbUhHhcmjokhh61N0QhzPos9sgZNPS4R5ClMclwLTVriLvROuZVZS74ewOQgma3RtIHwjtm5w6VEZq/volWVhgeI/CnyLAJ6mF+T5pRerZAZXyT8er/56Zd9QxHqsAv+zo1RW+jYas= Received: from BN9PR03CA0531.namprd03.prod.outlook.com (2603:10b6:408:131::26) by CYYPR12MB8964.namprd12.prod.outlook.com (2603:10b6:930:bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:36:26 +0000 Received: from BN8NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::8c) by BN9PR03CA0531.outlook.office365.com (2603:10b6:408:131::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:36:25 +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 BN8NAM11FT068.mail.protection.outlook.com (10.13.177.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:36:25 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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; Fri, 10 Mar 2023 11:36:23 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:35:56 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 07/15] powerpc/83xx/mpc832x_rdb: Replace all spi->chip_select references with function call Date: Fri, 10 Mar 2023 23:02:09 +0530 Message-ID: <20230310173217.3429788-8-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT068:EE_|CYYPR12MB8964:EE_ X-MS-Office365-Filtering-Correlation-Id: f916c9be-3095-4d72-ad14-08db218df938 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NApZi2qplQmy+/25v2NUv7zHdOppC3TdmZQq4vtW+ysec+sFp4YWJqP173YVMA2+7zzv3E4tn7ypTPdgyTqdKlKXXeyQFWwdMsDgppdEvKKlRsICahQ4Rc9efVzatfI5D4Lr5KN8JoyWDgmOvnP3QMUecyjtaQjMR40UbeX0+SDmQnb58p7KJh4eeWhxi0OziTcGq30pKwiTJvSTmdsZw+j7mpdesQHTleDqH5JHAj7PxxA0dpMd4+zC33Wmmm/Ia5RxTT2eAVOEQFWNA9O+yQpirYuzqIBK8CvnZDsJoOgBUJYJtZwvfi6KDu52vgTSgLvw5gZz3FqdDGaiTNHdUAc+EubbuyVJBIGGbmA+O4KZFQAweOllMbe/YaCHv5UbuxDiAsxsa15ZPSSMSb25zF+/s1tFzV/HTb1GUDgllSSTa7KZZyiUdVe3+j83kuK3EWER3ZXDswcIMr27NCpggxROwH62SkBHtXqYoWuFSsfeRd4pXPLqD+gaqLsiPOoa1bk8JxqKP+OxydpJ9PqI5gakZRb4Gn5Aj1UyWhz1aVuOrIbaTfRFAHpiaAT7xmzJaLJUgIBKC6aIynTdbLHQc6lH0LFWYI2EBb1WzRyI3y0GxWpJwbHSe+BsjXYrRyEN3kId2DstTQD1WdmCQcPvtrmnc6E3O3/hcfC5GjUQkUhge44/Z2MQXhKDOqC4N7LLQvarNM+BjT+1vxYb0HRql6SFRRznL1zHhMjaMGmA+GaG4CtIHWpZDOrh00o6lJ9tu2LLlET0kLe9QK3OrazfAK8CN+gDzNq2uLRLZbTTFTB3r32yjgHkt6r6OejLKN2uAH/K4Q6eauoz2EGMY3yK0ekuS8zDhFhzYHaEq4iGD7w= 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:(13230025)(4636009)(136003)(346002)(376002)(39860400002)(396003)(451199018)(46966006)(36840700001)(40470700004)(426003)(47076005)(336012)(186003)(54906003)(110136005)(36756003)(40460700003)(316002)(1191002)(921005)(40480700001)(356005)(26005)(86362001)(478600001)(5660300002)(82740400003)(36860700001)(1076003)(6666004)(83380400001)(82310400005)(2616005)(81166007)(8936002)(7336002)(7416002)(7366002)(7276002)(7406005)(41300700001)(2906002)(70586007)(8676002)(70206006)(4326008)(2101003)(84006005)(83996005)(41080700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:36:25.6841 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f916c9be-3095-4d72-ad14-08db218df938 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: BN8NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8964 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra --- arch/powerpc/platforms/83xx/mpc832x_rdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/83xx/mpc832x_rdb.c b/arch/powerpc/platf= orms/83xx/mpc832x_rdb.c index caa96edf0e72..4ab1d48cd229 100644 --- a/arch/powerpc/platforms/83xx/mpc832x_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc832x_rdb.c @@ -144,7 +144,7 @@ static int __init fsl_spi_init(struct spi_board_info *b= oard_infos, =20 static void mpc83xx_spi_cs_control(struct spi_device *spi, bool on) { - pr_debug("%s %d %d\n", __func__, spi->chip_select, on); + pr_debug("%s %d %d\n", __func__, spi_get_chipselect(spi, 0), on); par_io_data_set(3, 13, on); } =20 --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 B1743C76188 for ; Fri, 10 Mar 2023 17:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231346AbjCJRhz (ORCPT ); Fri, 10 Mar 2023 12:37:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbjCJRhv (ORCPT ); Fri, 10 Mar 2023 12:37:51 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20602.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8d::602]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8DB8128027; Fri, 10 Mar 2023 09:37:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fDRNQfAeBMsXvxLpEyufBkTljpAjB62YDYa9RYwlK0YKPvuapqQ17AIDfTzJ2kcSUA+FZZdrQKUEtWqloHO67hQlyNlUdiO2YShmb9aKyNJhlrkCkLQj85fDPUIia8wrjlC7PLLF2GuHnel8QwIn9qUpLJaOzP6TtbiMjZBDVLXVF+IRuBGjZMG7YZRzv+/BwwUM4ymeDFtXsc1hrwyg/vcRh2VI54D8+THIPovfrhhV6dEQeJ7l8+VWCeQe60/m4vZHgbVY8la3TJS1bOhDOMPFCA7ayRkZEGUsXO/SYjR04DRE+VAe5ffmDiu6HBaPXCW9VlLT8seFGhijin4y9g== 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=TNYJPkJ8aaPK5awYxnsnKWkYB0u9T5qlqGRNHD3pdtg=; b=e947nPG59j9p0X4xa/4COFk6qswBkYRsXUuNWBp6av8fkTAU/p3j3OCOAJmDlbDnLFttMj8WkUtrxRZaG0V9QC/llHn3OSoW/GHzHk1nOatbE0h/Mqe0i3PVyi0fXpH6nq/MGLmvn/uXwaxKVPrC357YjAuF1/0hasMGidgsIvkVTq2sEnEWF5TUS4Jf+PjlYgwfCcgi46wDjj/Am8k9tUMFdmSMIRgHFujBpD+KK5ZMWLtD1DwrAM4D7xQcEWoyZWlRyjBraOSO/awXdDiN4CirQwhldwAK2Xu8riYBeRac+Na/gp+4swUmwaS3nKrNyuUGKWMwlV6JFeH3DCB5KQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=TNYJPkJ8aaPK5awYxnsnKWkYB0u9T5qlqGRNHD3pdtg=; b=UMmMZbcBWItbrIBaBOta5O/k2bX3+xyUZrN07VP0ZW4Ks53SYj2K5Q+O5daGC5AZmW/Qq3MzqoMBa0VPOBwF9U5CN+UCZpSFb/IR3tiAmwHq3rhG+es5e4OpqDVJXU5mXlwXN0P97UWuP5b45mTm/3zAVD3VgdyzbKBNEF8Ek7s= Received: from BN8PR04CA0023.namprd04.prod.outlook.com (2603:10b6:408:70::36) by BN9PR12MB5290.namprd12.prod.outlook.com (2603:10b6:408:103::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:36:52 +0000 Received: from BN8NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::c6) by BN8PR04CA0023.outlook.office365.com (2603:10b6:408:70::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:36:52 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT082.mail.protection.outlook.com (10.13.176.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:36:52 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:36:51 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 09:36:51 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:36:24 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 08/15] ALSA: hda: cs35l41: Replace all spi->chip_select references with function call Date: Fri, 10 Mar 2023 23:02:10 +0530 Message-ID: <20230310173217.3429788-9-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT082:EE_|BN9PR12MB5290:EE_ X-MS-Office365-Filtering-Correlation-Id: a9861984-9939-4d87-1435-08db218e0955 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bdnGfZoG9qzd2wnQn8OFchhoKOS+sgoSCITP3ZeO4aNDSx44PjwjLeJYnAPLo3ZEVtW3N6LCJ+veH6LPWomsyGBuYgEdbAMAuMq6fuCIM49t8Bm247zTDNIYJNNfoCLHQkpxa3amxxZC5k9FTgU8tKSni9DMdQuXpt7kv6dTkMbtl/sd5XvhX3v2w/clW3/wQcveHEEPGF13YrDFq792cwDj6OavXgd2CFdEiSHRky4YizeS9ylEe+m2amd60i7+h6vPBGpXGCH2aRoHfraNbnXWtBfjGbTzUqksUsoaoFWCZB7ynIYwbguT9Ju4LjIXlN4fRBQFPyNin7w/bAe25+LQGhq7CYr87+GUYKWEyDfTw79+zuyIBAhErzAtGjQjOlhzKLBG58ECb04uhdlz1IQnImSc2nDFy1DEm/Z9tL71oHSE8ehZlsjuKQ27KcVPbBIZ2YEZKXY2lr6L+vnQpAPWY6E/thYSwn1+n5W1Leb8AdNwm1Bu38o9nJcr5qBHIyVqA6cWo8iGmsrO4g8a+KBrNJaYmXtOJFMzymB75oTQIoEAxIN9zi0gcCG1/maSfoK0JV8MahRIq1agAGa+bp5zBm13IshtUmxPuqFnEAr1Lagm4qX9rDT8OWu7v2U1aE4TpSuHTPKYmkIlZ3iJv/LhLng9vjtEgQLsergEeDmAEs2qEBNWQ3hB8ctRTrvkdBHUymDj24KGCjphaDHVL9U8SgNpiMNtn87dNLVYO10iCD5oFKgvQ85/NHeN6NZWuHTG5Ixa3phUqCqFiNvZ+SJkPJRtdH+JwNaAIp10eWVuDhSsom4xe95LTh2hp7bFl1y8AfpoBGkGQTs0vx63oR3MPMgTjC26gcIMwCanaAA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199018)(46966006)(36840700001)(40470700004)(36756003)(82740400003)(36860700001)(186003)(40460700003)(26005)(426003)(2616005)(6666004)(41300700001)(83380400001)(110136005)(47076005)(8676002)(70586007)(8936002)(2906002)(70206006)(4326008)(1076003)(40480700001)(7336002)(7416002)(7276002)(5660300002)(7366002)(7406005)(316002)(54906003)(356005)(86362001)(336012)(478600001)(81166007)(82310400005)(921005)(1191002)(2101003)(41080700001)(83996005)(84006005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:36:52.7138 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9861984-9939-4d87-1435-08db218e0955 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5290 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra --- sound/pci/hda/cs35l41_hda_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/hda/cs35l41_hda_spi.c b/sound/pci/hda/cs35l41_hda_sp= i.c index 71979cfb4d7e..eb287aa5f782 100644 --- a/sound/pci/hda/cs35l41_hda_spi.c +++ b/sound/pci/hda/cs35l41_hda_spi.c @@ -25,7 +25,7 @@ static int cs35l41_hda_spi_probe(struct spi_device *spi) else return -ENODEV; =20 - return cs35l41_hda_probe(&spi->dev, device_name, spi->chip_select, spi->i= rq, + return cs35l41_hda_probe(&spi->dev, device_name, spi_get_chipselect(spi, = 0), spi->irq, devm_regmap_init_spi(spi, &cs35l41_regmap_spi)); } =20 --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 449E9C76186 for ; Fri, 10 Mar 2023 17:38:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229636AbjCJRib (ORCPT ); Fri, 10 Mar 2023 12:38:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbjCJRi2 (ORCPT ); Fri, 10 Mar 2023 12:38:28 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2088.outbound.protection.outlook.com [40.107.220.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C27C812B7C7; Fri, 10 Mar 2023 09:37:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CGkIbSGNcJza+Y1xkaEwQAvW9FQG7vzeI8PMimKHu+M7ZnwPPIFyzSw30oG4kZdPHwvUkBrL9wH98crAgz8sw/d8LxRZv/rawBIC4GPoscGxLywjHtA0cLoRj7R5n2n5pErWP2jMCwvkD/Mm/xTZNACmcIb7Aw5gyTwUN8EdholnYlkOdLYAyEPMoiNwAgegz7z1xdhUyKNbMKwY8/u4hOhDIAWopqAiv5Uj0tL4c8/wPGYu3OtlPRM7kFJ7Aymp4uLHpxYzSUbSgm3qWG0jBKtBSIE2U9J2z5VQ908LbeBUj8TUlxZsP4S/dpXtq5uuQfGDftDnhqF1R5Lu5MGHRQ== 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=EZQfbZ5FzUGArPzG189cp70Lfibg+Yt+jh/mWzqe+DM=; b=a0AenT56x6tjpxWw4uo5yZk9KcO6ti63jeIwFuQmo/2ZwMi2Uxb7up+a9Xy7aRMHopHKe5lHTXWIJXtvRWygNMKE3MAbGGVahJuPa2ZvR+kt7I9g7hSU2cZ08relQ4koBPnMbILLoTwk906I5KDaFSnbL8WNH0jQzG413ha4VinVrwalBd/W0IvvIj0X9dn74O58l1GsgGSsYCfxRelchPifeoUOld3KMUPsnkJRIoq21iavcbJRw1uzKqJOAWjhJBpHtHZsSFN/KGMz1HGXN8/bXURiHO6GzGWd3fGXvSQtXELSIPo/Mr4xqu4eXABkSGW6SYD4roAJOeFtDP24lQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=EZQfbZ5FzUGArPzG189cp70Lfibg+Yt+jh/mWzqe+DM=; b=IzOygvy7dPOadp5B5g4Zg5XhjrmSax/2fkz3tkado9leisc1iCIjLiPBll9WNCiNWAMJSLGZ2YCfK0xfbRa7z6DFZrLZXD8m6Y7esbLnurEB7VCo8oy4oDRfEkNYHJgs7u53fv24JrpSszjuNgqlSEDsxpxEVifCk9qiYd2V+Zc= Received: from BN9PR03CA0542.namprd03.prod.outlook.com (2603:10b6:408:138::7) by DM4PR12MB7526.namprd12.prod.outlook.com (2603:10b6:8:112::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:37:20 +0000 Received: from BN8NAM11FT083.eop-nam11.prod.protection.outlook.com (2603:10b6:408:138:cafe::6b) by BN9PR03CA0542.outlook.office365.com (2603:10b6:408:138::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:37:19 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT083.mail.protection.outlook.com (10.13.177.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:37:19 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:37:18 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:36:51 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 09/15] spi: Add stacked and parallel memories support in SPI core Date: Fri, 10 Mar 2023 23:02:11 +0530 Message-ID: <20230310173217.3429788-10-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT083:EE_|DM4PR12MB7526:EE_ X-MS-Office365-Filtering-Correlation-Id: 34ca561a-2a31-4aea-fd1b-08db218e1947 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E40U9os0GvRbj5VSH8FqggcYIcmpWQuhFgkkYCdQR7TRXAmABSIt6Kz0gl3W1tTW+MQGCArzVzYxyynO0oeCdyAbmoiMXQSNIICu355tINqmCgBfzENYk2qjfUm1+g+tfyk9UzM3p4XAnepYGBKvCGT9QGnubYyk5zvVzHxWyPp0KkvCM8L8AOwAntaF/qhdFdhExg8JyEqrUNQWZAcZp35Jz26cFTRCF6KOzXTZaeM04WDdb4qKPmfbHOuOCXcwoTqkwlmvYA5bfv2EBsT4eQmFsyGVBtu2Xw+ok5JktBPf8f9NxZjWvhMqtNbiobEYG8WYrSt2k/p0HqMyA1rYZujmVDkfvt2OOt3zLzPa1xmo6vvMCgUpXuwUdVYkNqJyMK6k4I+w84bDMINA/MfLEYrX78jWCQtc1u/5TPo+rM2BVizmOf6lysBJyl95osdRh3Wzr4pB1sPgphAi/9QSnH8BEgiodBWp2opFZugaWm+41Dd+m8wlRPIusOuMPFE5Qi/IVPEo8tP4q3hm3s3XSn3B3gNtal/lvAgYcBdKEW0CCM+uf77GfUolqueyO/ABq94DM2IloRf6iHWbXtMUsVbtjlg6OBkV1LlU3BG4R893qWyepeMQzg3bk1hOOK1zvslMTLnXa9HJnvRM10aPd0XhOpkbczdraY5Clx8VZr7pFSpqyhEVvsJDcV6+XtBk88ziCjkmxuNIcxJUeOJ2R9WcUs0k5AxsOFBJuhixZO5XmP/V2MDbRAqfqqNefTHeVgm0f9hJnSfgKqhsLdTcqu31PLaL/sRZ/veCo2+x8GqVUbwtDKXohY/661zVN9yLrHRKGUMwfSmnL0ibEaI4/RcZ62F5jGfAUexvy882+Vs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(136003)(39860400002)(376002)(346002)(396003)(451199018)(40470700004)(36840700001)(46966006)(47076005)(336012)(426003)(54906003)(110136005)(40460700003)(36756003)(316002)(478600001)(921005)(86362001)(186003)(1076003)(81166007)(82740400003)(36860700001)(6666004)(82310400005)(83380400001)(26005)(356005)(1191002)(2616005)(40480700001)(8936002)(5660300002)(7416002)(7276002)(7366002)(7336002)(7406005)(41300700001)(2906002)(70206006)(30864003)(4326008)(8676002)(70586007)(36900700001)(41080700001)(84006005)(2101003)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:37:19.4715 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34ca561a-2a31-4aea-fd1b-08db218e1947 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT083.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7526 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" For supporting multiple CS the SPI device need to be aware of all the CS values. So, the "chip_select" member in the spi_device structure is now an array that holds all the CS values. spi_device structure now has a "cs_index_mask" member. This acts as an index to the chip_select array. If nth bit of spi->cs_index_mask is set then the driver would assert spi->chip_select[n]. In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A "multi-cs-cap" flag is added in the spi controntroller data, through ctlr->multi-cs-cap the spi core will make sure that the controller is capable of handling multiple chip selects at once. For supporting multiple CS via GPIO the cs_gpiod member of the spi_device structure is now an array that holds the gpio descriptor for each chipselect. Multi CS support using GPIO is not tested due to unavailability of necessary hardware setup. Signed-off-by: Amit Kumar Mahapatra --- drivers/spi/spi.c | 225 +++++++++++++++++++++++++++------------- include/linux/spi/spi.h | 34 ++++-- 2 files changed, 182 insertions(+), 77 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index c725b4bab7af..742bd688381c 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -612,10 +612,17 @@ static int spi_dev_check(struct device *dev, void *da= ta) { struct spi_device *spi =3D to_spi_device(dev); struct spi_device *new_spi =3D data; - - if (spi->controller =3D=3D new_spi->controller && - spi_get_chipselect(spi, 0) =3D=3D spi_get_chipselect(new_spi, 0)) - return -EBUSY; + int idx, nw_idx; + + if (spi->controller =3D=3D new_spi->controller) { + for (idx =3D 0; idx < SPI_CS_CNT_MAX; idx++) { + for (nw_idx =3D 0; nw_idx < SPI_CS_CNT_MAX; nw_idx++) { + if (spi_get_chipselect(spi, idx) =3D=3D + spi_get_chipselect(new_spi, nw_idx)) + return -EBUSY; + } + } + } return 0; } =20 @@ -629,7 +636,7 @@ static int __spi_add_device(struct spi_device *spi) { struct spi_controller *ctlr =3D spi->controller; struct device *dev =3D ctlr->dev.parent; - int status; + int status, idx; =20 /* * We need to make sure there's no other device with this @@ -638,8 +645,7 @@ static int __spi_add_device(struct spi_device *spi) */ status =3D bus_for_each_dev(&spi_bus_type, NULL, spi, spi_dev_check); if (status) { - dev_err(dev, "chipselect %d already in use\n", - spi_get_chipselect(spi, 0)); + dev_err(dev, "chipselect %d already in use\n", spi_get_chipselect(spi, 0= )); return status; } =20 @@ -649,8 +655,10 @@ static int __spi_add_device(struct spi_device *spi) return -ENODEV; } =20 - if (ctlr->cs_gpiods) - spi_set_csgpiod(spi, 0, ctlr->cs_gpiods[spi_get_chipselect(spi, 0)]); + if (ctlr->cs_gpiods) { + for (idx =3D 0; idx < SPI_CS_CNT_MAX; idx++) + spi_set_csgpiod(spi, idx, ctlr->cs_gpiods[spi_get_chipselect(spi, idx)]= ); + } =20 /* * Drivers may modify this initial i/o setup, but will @@ -690,13 +698,15 @@ int spi_add_device(struct spi_device *spi) { struct spi_controller *ctlr =3D spi->controller; struct device *dev =3D ctlr->dev.parent; - int status; + int status, idx; =20 - /* Chipselects are numbered 0..max; validate. */ - if (spi_get_chipselect(spi, 0) >=3D ctlr->num_chipselect) { - dev_err(dev, "cs%d >=3D max %d\n", spi_get_chipselect(spi, 0), - ctlr->num_chipselect); - return -EINVAL; + for (idx =3D 0; idx < SPI_CS_CNT_MAX; idx++) { + /* Chipselects are numbered 0..max; validate. */ + if (spi_get_chipselect(spi, idx) >=3D ctlr->num_chipselect) { + dev_err(dev, "cs%d >=3D max %d\n", spi_get_chipselect(spi, idx), + ctlr->num_chipselect); + return -EINVAL; + } } =20 /* Set the bus ID string */ @@ -713,12 +723,15 @@ static int spi_add_device_locked(struct spi_device *s= pi) { struct spi_controller *ctlr =3D spi->controller; struct device *dev =3D ctlr->dev.parent; + int idx; =20 - /* Chipselects are numbered 0..max; validate. */ - if (spi_get_chipselect(spi, 0) >=3D ctlr->num_chipselect) { - dev_err(dev, "cs%d >=3D max %d\n", spi_get_chipselect(spi, 0), - ctlr->num_chipselect); - return -EINVAL; + for (idx =3D 0; idx < SPI_CS_CNT_MAX; idx++) { + /* Chipselects are numbered 0..max; validate. */ + if (spi_get_chipselect(spi, idx) >=3D ctlr->num_chipselect) { + dev_err(dev, "cs%d >=3D max %d\n", spi_get_chipselect(spi, idx), + ctlr->num_chipselect); + return -EINVAL; + } } =20 /* Set the bus ID string */ @@ -966,58 +979,119 @@ static void spi_res_release(struct spi_controller *c= tlr, struct spi_message *mes static void spi_set_cs(struct spi_device *spi, bool enable, bool force) { bool activate =3D enable; + u32 cs_num =3D __ffs(spi->cs_index_mask); + int idx; =20 /* - * Avoid calling into the driver (or doing delays) if the chip select - * isn't actually changing from the last time this was called. + * In parallel mode all the chip selects are asserted/de-asserted + * at once */ - if (!force && ((enable && spi->controller->last_cs =3D=3D spi_get_chipsel= ect(spi, 0)) || - (!enable && spi->controller->last_cs !=3D spi_get_chipselect(spi,= 0))) && - (spi->controller->last_cs_mode_high =3D=3D (spi->mode & SPI_CS_HIGH))) - return; - - trace_spi_set_cs(spi, activate); - - spi->controller->last_cs =3D enable ? spi_get_chipselect(spi, 0) : -1; - spi->controller->last_cs_mode_high =3D spi->mode & SPI_CS_HIGH; - - if ((spi_get_csgpiod(spi, 0) || !spi->controller->set_cs_timing) && !acti= vate) - spi_delay_exec(&spi->cs_hold, NULL); - - if (spi->mode & SPI_CS_HIGH) - enable =3D !enable; + if ((spi->cs_index_mask & SPI_PARALLEL_CS_MASK) =3D=3D SPI_PARALLEL_CS_MA= SK) { + spi->controller->last_cs_mode_high =3D spi->mode & SPI_CS_HIGH; + + if ((spi_get_csgpiod(spi, 0) || !spi->controller->set_cs_timing) && !act= ivate) + spi_delay_exec(&spi->cs_hold, NULL); + + if (spi->mode & SPI_CS_HIGH) + enable =3D !enable; + + if (spi_get_csgpiod(spi, 0) && spi_get_csgpiod(spi, 1)) { + if (!(spi->mode & SPI_NO_CS)) { + /* + * Historically ACPI has no means of the GPIO polarity and + * thus the SPISerialBus() resource defines it on the per-chip + * basis. In order to avoid a chain of negations, the GPIO + * polarity is considered being Active High. Even for the cases + * when _DSD() is involved (in the updated versions of ACPI) + * the GPIO CS polarity must be defined Active High to avoid + * ambiguity. That's why we use enable, that takes SPI_CS_HIGH + * into account. + */ + if (has_acpi_companion(&spi->dev)) { + for (idx =3D 0; idx < SPI_CS_CNT_MAX; idx++) + gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx), + !enable); + } else { + for (idx =3D 0; idx < SPI_CS_CNT_MAX; idx++) + /* Polarity handled by GPIO library */ + gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx), + activate); + } + } + /* Some SPI masters need both GPIO CS & slave_select */ + if ((spi->controller->flags & SPI_MASTER_GPIO_SS) && + spi->controller->set_cs) + spi->controller->set_cs(spi, !enable); + else if (spi->controller->set_cs) + spi->controller->set_cs(spi, !enable); + } =20 - if (spi_get_csgpiod(spi, 0)) { - if (!(spi->mode & SPI_NO_CS)) { - /* - * Historically ACPI has no means of the GPIO polarity and - * thus the SPISerialBus() resource defines it on the per-chip - * basis. In order to avoid a chain of negations, the GPIO - * polarity is considered being Active High. Even for the cases - * when _DSD() is involved (in the updated versions of ACPI) - * the GPIO CS polarity must be defined Active High to avoid - * ambiguity. That's why we use enable, that takes SPI_CS_HIGH - * into account. - */ - if (has_acpi_companion(&spi->dev)) - gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), !enable); - else - /* Polarity handled by GPIO library */ - gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), activate); + for (idx =3D 0; idx < SPI_CS_CNT_MAX; idx++) { + if (spi_get_csgpiod(spi, idx) || !spi->controller->set_cs_timing) { + if (activate) + spi_delay_exec(&spi->cs_setup, NULL); + else + spi_delay_exec(&spi->cs_inactive, NULL); + } } - /* Some SPI masters need both GPIO CS & slave_select */ - if ((spi->controller->flags & SPI_MASTER_GPIO_SS) && - spi->controller->set_cs) + } else { + /* + * Avoid calling into the driver (or doing delays) if the chip select + * isn't actually changing from the last time this was called. + */ + if (!force && ((enable && spi->controller->last_cs =3D=3D + spi_get_chipselect(spi, cs_num)) || + (!enable && spi->controller->last_cs !=3D + spi_get_chipselect(spi, cs_num))) && + (spi->controller->last_cs_mode_high =3D=3D + (spi->mode & SPI_CS_HIGH))) + return; + + trace_spi_set_cs(spi, activate); + + spi->controller->last_cs =3D enable ? spi_get_chipselect(spi, cs_num) : = -1; + spi->controller->last_cs_mode_high =3D spi->mode & SPI_CS_HIGH; + + if ((spi_get_csgpiod(spi, cs_num) || !spi->controller->set_cs_timing) &&= !activate) + spi_delay_exec(&spi->cs_hold, NULL); + + if (spi->mode & SPI_CS_HIGH) + enable =3D !enable; + + if (spi_get_csgpiod(spi, cs_num)) { + if (!(spi->mode & SPI_NO_CS)) { + /* + * Historically ACPI has no means of the GPIO polarity and + * thus the SPISerialBus() resource defines it on the per-chip + * basis. In order to avoid a chain of negations, the GPIO + * polarity is considered being Active High. Even for the cases + * when _DSD() is involved (in the updated versions of ACPI) + * the GPIO CS polarity must be defined Active High to avoid + * ambiguity. That's why we use enable, that takes SPI_CS_HIGH + * into account. + */ + if (has_acpi_companion(&spi->dev)) + gpiod_set_value_cansleep(spi_get_csgpiod(spi, cs_num), + !enable); + else + /* Polarity handled by GPIO library */ + gpiod_set_value_cansleep(spi_get_csgpiod(spi, cs_num), + activate); + } + /* Some SPI masters need both GPIO CS & slave_select */ + if ((spi->controller->flags & SPI_MASTER_GPIO_SS) && + spi->controller->set_cs) + spi->controller->set_cs(spi, !enable); + } else if (spi->controller->set_cs) { spi->controller->set_cs(spi, !enable); - } else if (spi->controller->set_cs) { - spi->controller->set_cs(spi, !enable); - } + } =20 - if (spi_get_csgpiod(spi, 0) || !spi->controller->set_cs_timing) { - if (activate) - spi_delay_exec(&spi->cs_setup, NULL); - else - spi_delay_exec(&spi->cs_inactive, NULL); + if (spi_get_csgpiod(spi, cs_num) || !spi->controller->set_cs_timing) { + if (activate) + spi_delay_exec(&spi->cs_setup, NULL); + else + spi_delay_exec(&spi->cs_inactive, NULL); + } } } =20 @@ -2246,8 +2320,8 @@ static void of_spi_parse_dt_cs_delay(struct device_no= de *nc, static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device = *spi, struct device_node *nc) { - u32 value; - int rc; + u32 value, cs[SPI_CS_CNT_MAX] =3D {0}; + int rc, idx; =20 /* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool(nc, "spi-cpha")) @@ -2320,13 +2394,21 @@ static int of_spi_parse_dt(struct spi_controller *c= tlr, struct spi_device *spi, } =20 /* Device address */ - rc =3D of_property_read_u32(nc, "reg", &value); - if (rc) { + rc =3D of_property_read_variable_u32_array(nc, "reg", &cs[0], 1, + SPI_CS_CNT_MAX); + if (rc < 0 || rc > ctlr->num_chipselect) { dev_err(&ctlr->dev, "%pOF has no valid 'reg' property (%d)\n", nc, rc); return rc; + } else if ((of_property_read_bool(nc, "parallel-memories")) && + (!ctlr->multi_cs_cap)) { + dev_err(&ctlr->dev, "SPI controller doesn't support multi CS\n"); + return -EINVAL; } - spi_set_chipselect(spi, 0, value); + for (idx =3D 0; idx < rc; idx++) + spi_set_chipselect(spi, idx, cs[idx]); + /* By default set the spi->cs_index_mask as 1 */ + spi->cs_index_mask =3D 0x01; =20 /* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency", &value)) @@ -3846,6 +3928,7 @@ static int __spi_validate(struct spi_device *spi, str= uct spi_message *message) struct spi_controller *ctlr =3D spi->controller; struct spi_transfer *xfer; int w_size; + u32 cs_num =3D __ffs(spi->cs_index_mask); =20 if (list_empty(&message->transfers)) return -EINVAL; @@ -3858,7 +3941,7 @@ static int __spi_validate(struct spi_device *spi, str= uct spi_message *message) * cs_change is set for each transfer. */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits & SPI_CS_WORD) || - spi_get_csgpiod(spi, 0))) { + spi_get_csgpiod(spi, cs_num))) { size_t maxsize; int ret; =20 diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index bdb35a91b4bf..452682aa1a39 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -19,6 +19,11 @@ #include #include =20 +/* Max no. of CS supported per spi device */ +#define SPI_CS_CNT_MAX 2 + +/* chip select mask */ +#define SPI_PARALLEL_CS_MASK (BIT(0) | BIT(1)) struct dma_chan; struct software_node; struct ptp_system_timestamp; @@ -166,6 +171,7 @@ extern void spi_transfer_cs_change_delay_exec(struct sp= i_message *msg, * deasserted. If @cs_change_delay is used from @spi_transfer, then the * two delays will be added up. * @pcpu_statistics: statistics for the spi_device + * @cs_index_mask: Bit mask of the active chipselect(s) in the chipselect = array * * A @spi_device is used to interchange data between an SPI slave * (usually a discrete chip) and CPU memory. @@ -181,7 +187,7 @@ struct spi_device { struct spi_controller *controller; struct spi_controller *master; /* Compatibility layer */ u32 max_speed_hz; - u8 chip_select; + u8 chip_select[SPI_CS_CNT_MAX]; u8 bits_per_word; bool rt; #define SPI_NO_TX BIT(31) /* No transmit wire */ @@ -202,7 +208,7 @@ struct spi_device { void *controller_data; char modalias[SPI_NAME_SIZE]; const char *driver_override; - struct gpio_desc *cs_gpiod; /* Chip select gpio desc */ + struct gpio_desc *cs_gpiod[SPI_CS_CNT_MAX]; /* Chip select gpio desc */ struct spi_delay word_delay; /* Inter-word delay */ /* CS delays */ struct spi_delay cs_setup; @@ -212,6 +218,13 @@ struct spi_device { /* The statistics */ struct spi_statistics __percpu *pcpu_statistics; =20 + /* Bit mask of the chipselect(s) that the driver need to use from + * the chipselect array.When the controller is capable to handle + * multiple chip selects & memories are connected in parallel + * then more than one bit need to be set in cs_index_mask. + */ + u32 cs_index_mask : 2; + /* * likely need more hooks for more protocol options affecting how * the controller talks to each chip, like: @@ -268,22 +281,22 @@ static inline void *spi_get_drvdata(struct spi_device= *spi) =20 static inline u8 spi_get_chipselect(struct spi_device *spi, u8 idx) { - return spi->chip_select; + return spi->chip_select[idx]; } =20 static inline void spi_set_chipselect(struct spi_device *spi, u8 idx, u8 c= hipselect) { - spi->chip_select =3D chipselect; + spi->chip_select[idx] =3D chipselect; } =20 static inline struct gpio_desc *spi_get_csgpiod(struct spi_device *spi, u8= idx) { - return spi->cs_gpiod; + return spi->cs_gpiod[idx]; } =20 static inline void spi_set_csgpiod(struct spi_device *spi, u8 idx, struct = gpio_desc *csgpiod) { - spi->cs_gpiod =3D csgpiod; + spi->cs_gpiod[idx] =3D csgpiod; } =20 /** @@ -388,6 +401,8 @@ extern struct spi_device *spi_new_ancillary_device(stru= ct spi_device *spi, u8 ch * @bus_lock_spinlock: spinlock for SPI bus locking * @bus_lock_mutex: mutex for exclusion of multiple callers * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use + * @multi_cs_cap: indicates that the SPI Controller can assert/de-assert + * more than one chip select at once. * @setup: updates the device mode and clocking records used by a * device's SPI controller; protocol code may call this. This * must fail if an unrecognized or unsupported mode is requested. @@ -585,6 +600,13 @@ struct spi_controller { /* Flag indicating that the SPI bus is locked for exclusive use */ bool bus_lock_flag; =20 + /* + * Flag indicating that the spi-controller has multi chip select + * capability and can assert/de-assert more than one chip select + * at once. + */ + bool multi_cs_cap; + /* Setup mode and clock, etc (spi driver may call many times). * * IMPORTANT: this may be called when transfers to another --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 E8E25C6FA99 for ; Fri, 10 Mar 2023 17:39:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231656AbjCJRjm (ORCPT ); Fri, 10 Mar 2023 12:39:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbjCJRja (ORCPT ); Fri, 10 Mar 2023 12:39:30 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F7421A4A7; Fri, 10 Mar 2023 09:38:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KeLakNGNekktQ9oH29ROiRoBrn5Fy8JMa+Ixr9JNlq6Mcz/p766bsSWfvQgeSzLmiwaqi5rLerlq885EtAabapDFFR06LpAZGCpBkBo+C49yGzC0ubMgmYkMs4rkaztKJXRyGHsOiUOKmdsi5eAicZvD55jnSU99SdnRFr8vzSSPtNG69znKTauNCJ6hZPRhNHno9jAIQblL6Fpo0zprBIVEUoB5FvxlRU3UAGInf59/nm4LXnJTwF4kmN53PbbVA3PN05Y0TLFcV9yVr5hl89YZD+LEZDDbKGGsBYmGcQ5mAl/ZoZDRkzzjIPv7LLorZpeXOdJjSbr+PBKwLlIdug== 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=81s+8TCJ7jCbm+CdMdkkcrMQFPnQni896CqX3sAY8EM=; b=LvwHtEPmgof7fsDnf/6UG+CZvMdV7kVEZ617+02yb8IOeZYaWqXzxFkXtVULD+jTr2JuCDxGP1ev6ZvVBwN4oxF1IyRoPK0+BOu+SLQD+wdVdVK4tCNS32hL7f8i+xQH204ogdTZ/BKTOhE/ifboaTQFcgCnEH1O6dT8ptkgE9wf7xtR2bfEQV5t7qQa2YBHg2jjCAs93ak5zbMckhHV6hUuVcE2/Iszrka3kbPtYc1WI7IiYPKZGwbW+MQQ0pwsq2B7fl9guCdbTXHBhPxyQYoHDbGDeM8vQiM5I9yE7uvJ4PKcy0KqOFglrsKPhH+8QETnTHk98WLAY3Vm8PfSQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=81s+8TCJ7jCbm+CdMdkkcrMQFPnQni896CqX3sAY8EM=; b=QlVtaqUmf8kADsI1gF1aBW5cbbezrae44CYVjuxs7DW36rHYfBzgRM6JVh1mBK7r/WlCJ9GPAtcSI/Ijn53GWyzRUXDq+c6glCy02iUGX4B+3VMs+6H7FbVodFf9NdygegJVeNAo+aq2oR5V4KcUQWj6K3lMRB4tGfVVQJFgGXA= Received: from BN9PR03CA0295.namprd03.prod.outlook.com (2603:10b6:408:f5::30) by MN0PR12MB6080.namprd12.prod.outlook.com (2603:10b6:208:3c8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Fri, 10 Mar 2023 17:37:47 +0000 Received: from BN8NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f5:cafe::44) by BN9PR03CA0295.outlook.office365.com (2603:10b6:408:f5::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:37:47 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT008.mail.protection.outlook.com (10.13.177.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:37:47 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:37:46 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:37:46 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:37:19 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 10/15] mtd: spi-nor: Convert macros with inline functions Date: Fri, 10 Mar 2023 23:02:12 +0530 Message-ID: <20230310173217.3429788-11-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT008:EE_|MN0PR12MB6080:EE_ X-MS-Office365-Filtering-Correlation-Id: fd36cdfe-4339-4904-33a6-08db218e29d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +7AdhxKj+IbKYweXW5YhHmvXoMT0r8zLxWe0ZY5RkP66vsRzRROiPjf1wnS6n++7geWeya8KbrcVP6JhZcglyd0QWt9lGoEtHS1BTUAjUtYZqELbw69plm3+9YB34fMKoQpNxzq590jBXYpzqqkOL1Wo1BPRvGF26jvEDWrpphxd/A87bYyRA6+yEo2WMdkIPz39BJyBNpczVG4oPa6AkOL/W/dYYzqcGygxBi3eLdO5PTykQHROOZ6lrHQYXvKdTmJPNtNHlMtG7vo4tHJpgqRFCKMKrKBSGQNZ2S3pO7DLdImURPOkXFMkIciaBJOOWGHORyPMvFMiFM+ySrheAyTiOi3HqtNS8KhDI2m5oKLiPQctcR0R3mLPJ53hGqKbHpAAdmmeLuD+nbR1S83dYA9Q5XlkPBCt2f68qFLZlqTowy5e780MWScvikXMH6lJIdLUg03+YcXClBRQAGwrXOu4ailsv4cPkkfP4STf1UG7tfyXaRMS+ApgT3c06+NyL7hNzhw7wLpqZBHMMZX6yTZ/Q/z90hindfodh+/849Hd/Ejr45UUGZwxcUgD0MIxp2v1EjzO3LKqQzHJ/gKJl9LjGZZeSF7IpCoFKIRC77xPvTWGwSvNVbVmZLlzY2898bGKohfE8G4etGFU2cyPB9rarVRK1WUk7Kw5DiJdHe/Xg1fOaP60ODAMj1Tj5zxJMJ22sV9bPBqD45YEb1cJwzobo81vsdDMt+y11UCd2XPEfLGSxzg6nwk6k/tVonvPU1Hvu5Caxoth4hKvs1ymYzh5DkIveYebQ0a6yP8cAi21cTJ5TgdUSu7SWCanK48HjHu9kKrJ0o5bi0eOYaBAb0Y23QTEHImO3yh9SMpmlKM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(136003)(346002)(376002)(451199018)(36840700001)(46966006)(40470700004)(336012)(36756003)(426003)(110136005)(54906003)(7366002)(40460700003)(7276002)(7406005)(186003)(356005)(7336002)(478600001)(1076003)(7416002)(921005)(82310400005)(2906002)(2616005)(26005)(40480700001)(1191002)(6666004)(86362001)(8936002)(81166007)(82740400003)(5660300002)(83380400001)(8676002)(70586007)(70206006)(4326008)(36860700001)(41300700001)(316002)(47076005)(41080700001)(36900700001)(2101003)(83996005)(84006005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:37:47.2758 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fd36cdfe-4339-4904-33a6-08db218e29d8 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6080 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In further patches the nor->params references in spi_nor_otp_region_len(nor) & spi_nor_otp_n_regions(nor) macros will be replaced with spi_nor_get_params() API. To make the transition smoother, first converting the macros into static inline functions. Suggested-by: Michal Simek Signed-off-by: Amit Kumar Mahapatra --- drivers/mtd/spi-nor/otp.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/otp.c b/drivers/mtd/spi-nor/otp.c index 00ab0d2d6d2f..3d75899de303 100644 --- a/drivers/mtd/spi-nor/otp.c +++ b/drivers/mtd/spi-nor/otp.c @@ -11,8 +11,27 @@ =20 #include "core.h" =20 -#define spi_nor_otp_region_len(nor) ((nor)->params->otp.org->len) -#define spi_nor_otp_n_regions(nor) ((nor)->params->otp.org->n_regions) +/** + * spi_nor_otp_region_len() - get size of one OTP region in bytes + * @nor: pointer to 'struct spi_nor' + * + * Return: size of one OTP region in bytes + */ +static inline unsigned int spi_nor_otp_region_len(struct spi_nor *nor) +{ + return nor->params->otp.org->len; +} + +/** + * spi_nor_otp_n_regions() - get number of individual OTP regions + * @nor: pointer to 'struct spi_nor' + * + * Return: number of individual OTP regions + */ +static inline unsigned int spi_nor_otp_n_regions(struct spi_nor *nor) +{ + return nor->params->otp.org->n_regions; +} =20 /** * spi_nor_otp_read_secr() - read security register --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 1D4F0C76186 for ; Fri, 10 Mar 2023 17:39:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231339AbjCJRjc (ORCPT ); Fri, 10 Mar 2023 12:39:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231522AbjCJRjS (ORCPT ); Fri, 10 Mar 2023 12:39:18 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2062a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C74E11EE8A; Fri, 10 Mar 2023 09:38:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dk0HcEswYB+9We/eQ/HVB/vnr74sciBzT+DDJ0Wix06MDKh8LoTdJEB9YparYNbNMrEvOMoyZMZ3Bry0c1RF561qeGiAvyDazH+sy+ObCfDI8gSEO95TkjT/ygUQWsDFpJeVduLGebt+MZqPWj+c26soBIych4e9LLhHucwwVxRkkGvEqazfSZojDC7wUkeYlyJYg50TKooUpq7qZj+0StiIrNLXbvhRQ2/IcQ8ZGb0PbkRIWa/NfJ+5F8IJA7hNlUdokIFcczg4Ay446gT054OCDXkZhbrKXThLvTTXMAhm1jKi9awL3GvAT/DJYoIdH93613k/RIfhTFPFh68nlA== 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=Ej3Oqt4wSMRivVnbvplCVfSOZCgg8Uz5j9eaTeADlbI=; b=fcotui9EIILVtg+RVMxGVJQZsukiwGaFXFDbD1MxTU2GuFQ9eFIRO+rI/Y+B377Pa9rqbJUfj+Ip4Sz1RqujIXiLT1HuI4mOozTC8NP4aVSgnnHjU1NppW+QTZNGQcq6d8ii4HYFIzH4xILSv+GmtZriUwBNAXOTRRtK4673UqlEKOMt8MrGV3efuB0D+um+YSrwq4a92ZzxtItKZeMA1zfjDHDGgbb9B6RvHcPDU1SFAlcF64qvxJBSEokLVMYhiGYWOONs2Ii6tAi+K9E97hqOi4oG2bv+y8Ac0F9Z9Ck7CPnre7uKA0ORWh2ym4GY1TGNBTXZjyT0E49WeBpWow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=Ej3Oqt4wSMRivVnbvplCVfSOZCgg8Uz5j9eaTeADlbI=; b=F86grKOFk092PC91BG2Q20Rn2fgxheUfs49PQViHs7fztGtyT8sFYmLB+vBTBTzE1gUYzfY14BeCb3C6bj/UZZ5mUltq8lBVt+b2fISH0+C+nVEm5BJg3qiZaUIQm/810+OgyVd89x5p0ElJSerjSd0RtnWeu9gBUpk+A592gPs= Received: from BN9PR03CA0904.namprd03.prod.outlook.com (2603:10b6:408:107::9) by PH7PR12MB8794.namprd12.prod.outlook.com (2603:10b6:510:27d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:38:15 +0000 Received: from BN8NAM11FT099.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::75) by BN9PR03CA0904.outlook.office365.com (2603:10b6:408:107::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.18 via Frontend Transport; Fri, 10 Mar 2023 17:38: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 BN8NAM11FT099.mail.protection.outlook.com (10.13.177.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:38:14 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Fri, 10 Mar 2023 11:38:14 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 09:38:13 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:37:46 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 11/15] mtd: spi-nor: Add APIs to set/get nor->params Date: Fri, 10 Mar 2023 23:02:13 +0530 Message-ID: <20230310173217.3429788-12-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT099:EE_|PH7PR12MB8794:EE_ X-MS-Office365-Filtering-Correlation-Id: 43f7ba8c-7342-470c-dd0e-08db218e3a4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nKZcZVPKJFMdVeZJ+qv/+fKaHtBsgFDb/ADv5GI0QeOPUnBecXVKZHyJLtqHlRxZDmflNzP8IYb7II4CEr2dhZKmEIhwHs5ycsHpkyJ7QTt8KmsqiBIHXhtIAivTpusrONvXmtoC/+XOldIEg5O/QxR6cd07EYTZTAt8wuDcYzPfyG7iHBtI/io5PRpT3n2t0rF2+n1L4FzQ4D1ezIbiCA/DDR0+wrFkGJPfXYW3mccYMVW80xqt9hU4/wWvvBuibzo5rLY5MeuMW3SPVNur1qXOyP45KRHlHoluSSp8YTp2rTAqiHLp1YeBDdVZ2Ks+3sH5+Gr8trO7bQBmNvBvaPIiYz/UUgSJuxHz9zao8SfRuMuUzdP6Y8XTdgA5WX9eq1JLOxxy6toEYJ9BeVuhuDfgATnIdn5h4en5FNjB+qq4JD1kPGMUqu4AsmCbSjshA/doB5w5CbDul9bMlMka8V2wqCAVgdNlTuHC/ngVDWMAf7wo99u/nnqVoLMCf/DTwpNe1Y0vqEvxnc1CIN2KIUip9vx4uubOvvmUbpIySPIZgU4UdUt3S3ugqgVkQ0Q2oZiPqGb9aPi+COC5vWzuFiYuGRgc874jqaEsNW6vgXBvQy5KXND4EidRTAna3GZvKO9+j0q9uAYQGos+n6QJdVsnYerZXV25d8Hs9Y4W1mW1skS/bwLZ9dvCKQ8xoFzDs1cmdJQKulfoinY7omnlzvNRdk/w6xtSSP3v6dSYP5zTjqANwsbh3ns4G2xLO4HsseIb7UBt8laHZjvZNqZvxKHrrQSZQhjgE7ui3uJB0l9JItL3GTmuYyu1kVJqCISqkfMjmCLOYINA/w3xqDY+BafZyvdjnB15lPc7KymAJuDm/vdornZVZbqcxMwsz+lC 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:(13230025)(4636009)(396003)(39860400002)(136003)(346002)(376002)(451199018)(36840700001)(40470700004)(46966006)(47076005)(336012)(426003)(110136005)(54906003)(40460700003)(36756003)(356005)(40480700001)(921005)(86362001)(82740400003)(186003)(36860700001)(81166007)(1076003)(26005)(83380400001)(82310400005)(6666004)(5660300002)(1191002)(2616005)(7336002)(70586007)(7416002)(7366002)(316002)(7276002)(478600001)(7406005)(41300700001)(4326008)(30864003)(8936002)(2906002)(8676002)(70206006)(41080700001)(84006005)(2101003)(83996005)(36900700001)(579004)(559001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:38:14.8879 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43f7ba8c-7342-470c-dd0e-08db218e3a4f 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: BN8NAM11FT099.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8794 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Supporting multi-cs in spi-nor would require the *params member of struct spi_nor to be an array. To make the transition smoother introduced spi_nor_get_params() & spi_nor_set_params() APIs to get & set nor->params, added a new local variable (struct spi_nor_flash_parameter *params) to hold the return value of the spi_nor_get_params() function call and replaced all nor->params references with the "params". While adding multi-cs support in further patches the *params member of the spi_nor structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., nor->params[idx]. Signed-off-by: Amit Kumar Mahapatra --- drivers/mtd/spi-nor/atmel.c | 17 ++-- drivers/mtd/spi-nor/core.c | 129 ++++++++++++++++++++----------- drivers/mtd/spi-nor/debugfs.c | 4 +- drivers/mtd/spi-nor/gigadevice.c | 4 +- drivers/mtd/spi-nor/issi.c | 11 ++- drivers/mtd/spi-nor/macronix.c | 6 +- drivers/mtd/spi-nor/micron-st.c | 34 +++++--- drivers/mtd/spi-nor/otp.c | 29 ++++--- drivers/mtd/spi-nor/sfdp.c | 29 ++++--- drivers/mtd/spi-nor/spansion.c | 50 +++++++----- drivers/mtd/spi-nor/sst.c | 7 +- drivers/mtd/spi-nor/swp.c | 22 ++++-- drivers/mtd/spi-nor/winbond.c | 10 ++- drivers/mtd/spi-nor/xilinx.c | 18 +++-- include/linux/mtd/spi-nor.h | 10 +++ 15 files changed, 254 insertions(+), 126 deletions(-) diff --git a/drivers/mtd/spi-nor/atmel.c b/drivers/mtd/spi-nor/atmel.c index 656dd80a0be7..57ca9f5ee205 100644 --- a/drivers/mtd/spi-nor/atmel.c +++ b/drivers/mtd/spi-nor/atmel.c @@ -23,10 +23,11 @@ static int at25fs_nor_lock(struct spi_nor *nor, loff_t = ofs, uint64_t len) =20 static int at25fs_nor_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; =20 /* We only support unlocking the whole flash array */ - if (ofs || len !=3D nor->params->size) + if (ofs || len !=3D params->size) return -EINVAL; =20 /* Write 0x00 to the status register to disable write protection */ @@ -50,7 +51,9 @@ static const struct spi_nor_locking_ops at25fs_nor_lockin= g_ops =3D { =20 static void at25fs_nor_late_init(struct spi_nor *nor) { - nor->params->locking_ops =3D &at25fs_nor_locking_ops; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + params->locking_ops =3D &at25fs_nor_locking_ops; } =20 static const struct spi_nor_fixups at25fs_nor_fixups =3D { @@ -69,11 +72,12 @@ static const struct spi_nor_fixups at25fs_nor_fixups = =3D { static int atmel_nor_set_global_protection(struct spi_nor *nor, loff_t ofs, uint64_t len, bool is_protect) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; u8 sr; =20 /* We only support locking the whole flash array */ - if (ofs || len !=3D nor->params->size) + if (ofs || len !=3D params->size) return -EINVAL; =20 ret =3D spi_nor_read_sr(nor, nor->bouncebuf); @@ -131,9 +135,10 @@ static int atmel_nor_global_unprotect(struct spi_nor *= nor, loff_t ofs, static int atmel_nor_is_global_protected(struct spi_nor *nor, loff_t ofs, uint64_t len) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; =20 - if (ofs >=3D nor->params->size || (ofs + len) > nor->params->size) + if (ofs >=3D params->size || (ofs + len) > params->size) return -EINVAL; =20 ret =3D spi_nor_read_sr(nor, nor->bouncebuf); @@ -151,7 +156,9 @@ static const struct spi_nor_locking_ops atmel_nor_globa= l_protection_ops =3D { =20 static void atmel_nor_global_protection_late_init(struct spi_nor *nor) { - nor->params->locking_ops =3D &atmel_nor_global_protection_ops; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + params->locking_ops =3D &atmel_nor_global_protection_ops; } =20 static const struct spi_nor_fixups atmel_nor_global_protection_fixups =3D { diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 0a78045ca1d9..66b6934b4465 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -448,14 +448,15 @@ int spi_nor_read_id(struct spi_nor *nor, u8 naddr, u8= ndummy, u8 *id, */ int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; =20 if (nor->spimem) { struct spi_mem_op op =3D SPI_NOR_RDSR_OP(sr); =20 if (nor->reg_proto =3D=3D SNOR_PROTO_8_8_8_DTR) { - op.addr.nbytes =3D nor->params->rdsr_addr_nbytes; - op.dummy.nbytes =3D nor->params->rdsr_dummy; + op.addr.nbytes =3D params->rdsr_addr_nbytes; + op.dummy.nbytes =3D params->rdsr_dummy; /* * We don't want to read only one byte in DTR mode. So, * read 2 and then discard the second byte. @@ -596,9 +597,11 @@ int spi_nor_sr_ready(struct spi_nor *nor) */ static int spi_nor_ready(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + /* Flashes might override the standard routine. */ - if (nor->params->ready) - return nor->params->ready(nor); + if (params->ready) + return params->ready(nor); =20 return spi_nor_sr_ready(nor); } @@ -760,6 +763,7 @@ static int spi_nor_write_sr1_and_check(struct spi_nor *= nor, u8 sr1) */ static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 sr1) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; u8 *sr_cr =3D nor->bouncebuf; u8 cr_written; @@ -769,7 +773,7 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_= nor *nor, u8 sr1) ret =3D spi_nor_read_cr(nor, &sr_cr[1]); if (ret) return ret; - } else if (nor->params->quad_enable) { + } else if (params->quad_enable) { /* * If the Status Register 2 Read command (35h) is not * supported, we should at least be sure we don't @@ -777,7 +781,7 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_= nor *nor, u8 sr1) * * We can safely assume that when the Quad Enable method is * set, the value of the QE bit is one, as a consequence of the - * nor->params->quad_enable() call. + * params->quad_enable() call. * * We can safely assume that the Quad Enable bit is present in * the Status Register 2 at BIT(1). According to the JESD216 @@ -1048,17 +1052,21 @@ static u8 spi_nor_convert_3to4_erase(u8 opcode) =20 static bool spi_nor_has_uniform_erase(const struct spi_nor *nor) { - return !!nor->params->erase_map.uniform_erase_type; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + return !!params->erase_map.uniform_erase_type; } =20 static void spi_nor_set_4byte_opcodes(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + nor->read_opcode =3D spi_nor_convert_3to4_read(nor->read_opcode); nor->program_opcode =3D spi_nor_convert_3to4_program(nor->program_opcode); nor->erase_opcode =3D spi_nor_convert_3to4_erase(nor->erase_opcode); =20 if (!spi_nor_has_uniform_erase(nor)) { - struct spi_nor_erase_map *map =3D &nor->params->erase_map; + struct spi_nor_erase_map *map =3D ¶ms->erase_map; struct spi_nor_erase_type *erase; int i; =20 @@ -1095,10 +1103,12 @@ void spi_nor_unlock_and_unprep(struct spi_nor *nor) =20 static u32 spi_nor_convert_addr(struct spi_nor *nor, loff_t addr) { - if (!nor->params->convert_addr) + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + if (!params->convert_addr) return addr; =20 - return nor->params->convert_addr(nor, addr); + return params->convert_addr(nor, addr); } =20 /* @@ -1318,7 +1328,8 @@ static int spi_nor_init_erase_cmd_list(struct spi_nor= *nor, struct list_head *erase_list, u64 addr, u32 len) { - const struct spi_nor_erase_map *map =3D &nor->params->erase_map; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + const struct spi_nor_erase_map *map =3D ¶ms->erase_map; const struct spi_nor_erase_type *erase, *prev_erase =3D NULL; struct spi_nor_erase_region *region; struct spi_nor_erase_command *cmd =3D NULL; @@ -1746,12 +1757,16 @@ static int spi_nor_write(struct mtd_info *mtd, loff= _t to, size_t len, size_t *retlen, const u_char *buf) { struct spi_nor *nor =3D mtd_to_spi_nor(mtd); + struct spi_nor_flash_parameter *params; size_t page_offset, page_remain, i; ssize_t ret; - u32 page_size =3D nor->params->page_size; + u32 page_size; =20 dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len); =20 + params =3D spi_nor_get_params(nor, 0); + page_size =3D params->page_size; + ret =3D spi_nor_lock_and_prep(nor); if (ret) return ret; @@ -1903,6 +1918,8 @@ int spi_nor_hwcaps_pp2cmd(u32 hwcaps) static int spi_nor_spimem_check_op(struct spi_nor *nor, struct spi_mem_op *op) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + /* * First test with 4 address bytes. The opcode itself might * be a 3B addressing opcode but we don't care, because @@ -1911,7 +1928,7 @@ static int spi_nor_spimem_check_op(struct spi_nor *no= r, */ op->addr.nbytes =3D 4; if (!spi_mem_supports_op(nor->spimem, op)) { - if (nor->params->size > SZ_16M) + if (params->size > SZ_16M) return -EOPNOTSUPP; =20 /* If flash size <=3D 16MB, 3 address bytes are sufficient */ @@ -1975,7 +1992,7 @@ static int spi_nor_spimem_check_pp(struct spi_nor *no= r, static void spi_nor_spimem_adjust_hwcaps(struct spi_nor *nor, u32 *hwcaps) { - struct spi_nor_flash_parameter *params =3D nor->params; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); unsigned int cap; =20 /* X-X-X modes are not supported yet, mask them all. */ @@ -2076,6 +2093,7 @@ static int spi_nor_select_read(struct spi_nor *nor, u32 shared_hwcaps) { int cmd, best_match =3D fls(shared_hwcaps & SNOR_HWCAPS_READ_MASK) - 1; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); const struct spi_nor_read_command *read; =20 if (best_match < 0) @@ -2085,7 +2103,7 @@ static int spi_nor_select_read(struct spi_nor *nor, if (cmd < 0) return -EINVAL; =20 - read =3D &nor->params->reads[cmd]; + read =3D ¶ms->reads[cmd]; nor->read_opcode =3D read->opcode; nor->read_proto =3D read->proto; =20 @@ -2106,6 +2124,7 @@ static int spi_nor_select_read(struct spi_nor *nor, static int spi_nor_select_pp(struct spi_nor *nor, u32 shared_hwcaps) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int cmd, best_match =3D fls(shared_hwcaps & SNOR_HWCAPS_PP_MASK) - 1; const struct spi_nor_pp_command *pp; =20 @@ -2116,7 +2135,7 @@ static int spi_nor_select_pp(struct spi_nor *nor, if (cmd < 0) return -EINVAL; =20 - pp =3D &nor->params->page_programs[cmd]; + pp =3D ¶ms->page_programs[cmd]; nor->program_opcode =3D pp->opcode; nor->write_proto =3D pp->proto; return 0; @@ -2185,7 +2204,8 @@ spi_nor_select_uniform_erase(struct spi_nor_erase_map= *map, =20 static int spi_nor_select_erase(struct spi_nor *nor) { - struct spi_nor_erase_map *map =3D &nor->params->erase_map; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + struct spi_nor_erase_map *map =3D ¶ms->erase_map; const struct spi_nor_erase_type *erase =3D NULL; struct mtd_info *mtd =3D &nor->mtd; u32 wanted_size =3D nor->info->sector_size; @@ -2234,7 +2254,7 @@ static int spi_nor_select_erase(struct spi_nor *nor) static int spi_nor_default_setup(struct spi_nor *nor, const struct spi_nor_hwcaps *hwcaps) { - struct spi_nor_flash_parameter *params =3D nor->params; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); u32 ignored_mask, shared_mask; int err; =20 @@ -2294,8 +2314,10 @@ static int spi_nor_default_setup(struct spi_nor *nor, =20 static int spi_nor_set_addr_nbytes(struct spi_nor *nor) { - if (nor->params->addr_nbytes) { - nor->addr_nbytes =3D nor->params->addr_nbytes; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + if (params->addr_nbytes) { + nor->addr_nbytes =3D params->addr_nbytes; } else if (nor->read_proto =3D=3D SNOR_PROTO_8_8_8_DTR) { /* * In 8D-8D-8D mode, one byte takes half a cycle to transfer. So @@ -2316,7 +2338,7 @@ static int spi_nor_set_addr_nbytes(struct spi_nor *no= r) nor->addr_nbytes =3D 3; } =20 - if (nor->addr_nbytes =3D=3D 3 && nor->params->size > 0x1000000) { + if (nor->addr_nbytes =3D=3D 3 && params->size > 0x1000000) { /* enable 4-byte addressing if the device exceeds 16MiB */ nor->addr_nbytes =3D 4; } @@ -2338,10 +2360,11 @@ static int spi_nor_set_addr_nbytes(struct spi_nor *= nor) static int spi_nor_setup(struct spi_nor *nor, const struct spi_nor_hwcaps *hwcaps) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; =20 - if (nor->params->setup) - ret =3D nor->params->setup(nor, hwcaps); + if (params->setup) + ret =3D params->setup(nor, hwcaps); else ret =3D spi_nor_default_setup(nor, hwcaps); if (ret) @@ -2376,7 +2399,7 @@ static void spi_nor_manufacturer_init_params(struct s= pi_nor *nor) */ static void spi_nor_no_sfdp_init_params(struct spi_nor *nor) { - struct spi_nor_flash_parameter *params =3D nor->params; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_nor_erase_map *map =3D ¶ms->erase_map; const u8 no_sfdp_flags =3D nor->info->no_sfdp_flags; u8 i, erase_mask; @@ -2501,6 +2524,8 @@ static void spi_nor_init_fixup_flags(struct spi_nor *= nor) */ static void spi_nor_late_init_params(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + if (nor->manufacturer && nor->manufacturer->fixups && nor->manufacturer->fixups->late_init) nor->manufacturer->fixups->late_init(nor); @@ -2515,7 +2540,7 @@ static void spi_nor_late_init_params(struct spi_nor *= nor) * NOR protection support. When locking_ops are not provided, we pick * the default ones. */ - if (nor->flags & SNOR_F_HAS_LOCK && !nor->params->locking_ops) + if (nor->flags & SNOR_F_HAS_LOCK && !params->locking_ops) spi_nor_init_default_locking_ops(nor); } =20 @@ -2529,12 +2554,13 @@ static void spi_nor_late_init_params(struct spi_nor= *nor) */ static void spi_nor_sfdp_init_params_deprecated(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_nor_flash_parameter sfdp_params; =20 - memcpy(&sfdp_params, nor->params, sizeof(sfdp_params)); + memcpy(&sfdp_params, params, sizeof(sfdp_params)); =20 if (spi_nor_parse_sfdp(nor)) { - memcpy(nor->params, &sfdp_params, sizeof(*nor->params)); + memcpy(params, &sfdp_params, sizeof(*params)); nor->flags &=3D ~SNOR_F_4B_OPCODES; } } @@ -2569,7 +2595,7 @@ static void spi_nor_init_params_deprecated(struct spi= _nor *nor) */ static void spi_nor_init_default_params(struct spi_nor *nor) { - struct spi_nor_flash_parameter *params =3D nor->params; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); const struct flash_info *info =3D nor->info; struct device_node *np =3D spi_nor_get_flash_node(nor); =20 @@ -2655,12 +2681,15 @@ static void spi_nor_init_default_params(struct spi_= nor *nor) */ static int spi_nor_init_params(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; =20 - nor->params =3D devm_kzalloc(nor->dev, sizeof(*nor->params), GFP_KERNEL); - if (!nor->params) + params =3D devm_kzalloc(nor->dev, sizeof(*params), GFP_KERNEL); + if (!params) return -ENOMEM; =20 + spi_nor_set_params(nor, 0, params); + spi_nor_init_default_params(nor); =20 if (nor->info->parse_sfdp) { @@ -2688,9 +2717,10 @@ static int spi_nor_init_params(struct spi_nor *nor) */ static int spi_nor_octal_dtr_enable(struct spi_nor *nor, bool enable) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; =20 - if (!nor->params->octal_dtr_enable) + if (!params->octal_dtr_enable) return 0; =20 if (!(nor->read_proto =3D=3D SNOR_PROTO_8_8_8_DTR && @@ -2700,7 +2730,7 @@ static int spi_nor_octal_dtr_enable(struct spi_nor *n= or, bool enable) if (!(nor->flags & SNOR_F_IO_MODE_EN_VOLATILE)) return 0; =20 - ret =3D nor->params->octal_dtr_enable(nor, enable); + ret =3D params->octal_dtr_enable(nor, enable); if (ret) return ret; =20 @@ -2720,18 +2750,21 @@ static int spi_nor_octal_dtr_enable(struct spi_nor = *nor, bool enable) */ static int spi_nor_quad_enable(struct spi_nor *nor) { - if (!nor->params->quad_enable) + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + if (!params->quad_enable) return 0; =20 if (!(spi_nor_get_protocol_width(nor->read_proto) =3D=3D 4 || spi_nor_get_protocol_width(nor->write_proto) =3D=3D 4)) return 0; =20 - return nor->params->quad_enable(nor); + return params->quad_enable(nor); } =20 static int spi_nor_init(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int err; =20 err =3D spi_nor_octal_dtr_enable(nor, true); @@ -2773,7 +2806,7 @@ static int spi_nor_init(struct spi_nor *nor) */ WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET, "enabling reset hack; may not recover from unexpected reboots\n"); - err =3D nor->params->set_4byte_addr_mode(nor, true); + err =3D params->set_4byte_addr_mode(nor, true); if (err && err !=3D -ENOTSUPP) return err; } @@ -2889,12 +2922,14 @@ static void spi_nor_put_device(struct mtd_info *mtd) =20 void spi_nor_restore(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params; int ret; =20 /* restore the addressing mode */ if (nor->addr_nbytes =3D=3D 4 && !(nor->flags & SNOR_F_4B_OPCODES) && nor->flags & SNOR_F_BROKEN_RESET) { - ret =3D nor->params->set_4byte_addr_mode(nor, false); + params =3D spi_nor_get_params(nor, 0); + ret =3D params->set_4byte_addr_mode(nor, false); if (ret) /* * Do not stop the execution in the hope that the flash @@ -2966,6 +3001,7 @@ static const struct flash_info *spi_nor_get_flash_inf= o(struct spi_nor *nor, =20 static void spi_nor_set_mtd_info(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct mtd_info *mtd =3D &nor->mtd; struct device *dev =3D nor->dev; =20 @@ -2981,9 +3017,9 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor) mtd->flags |=3D MTD_NO_ERASE; else mtd->_erase =3D spi_nor_erase; - mtd->writesize =3D nor->params->writesize; - mtd->writebufsize =3D nor->params->page_size; - mtd->size =3D nor->params->size; + mtd->writesize =3D params->writesize; + mtd->writebufsize =3D params->page_size; + mtd->size =3D params->size; mtd->_read =3D spi_nor_read; /* Might be already set by some SST flashes. */ if (!mtd->_write) @@ -3037,7 +3073,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *nam= e, * We need the bounce buffer early to read/write registers when going * through the spi-mem layer (buffers have to be DMA-able). * For spi-mem drivers, we'll reallocate a new buffer if - * nor->params->page_size turns out to be greater than PAGE_SIZE (which + * params->page_size turns out to be greater than PAGE_SIZE (which * shouldn't happen before long since NOR pages are usually less * than 1KB) after spi_nor_scan() returns. */ @@ -3108,13 +3144,14 @@ EXPORT_SYMBOL_GPL(spi_nor_scan); =20 static int spi_nor_create_read_dirmap(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_mem_dirmap_info info =3D { .op_tmpl =3D SPI_MEM_OP(SPI_MEM_OP_CMD(nor->read_opcode, 0), SPI_MEM_OP_ADDR(nor->addr_nbytes, 0, 0), SPI_MEM_OP_DUMMY(nor->read_dummy, 0), SPI_MEM_OP_DATA_IN(0, NULL, 0)), .offset =3D 0, - .length =3D nor->params->size, + .length =3D params->size, }; struct spi_mem_op *op =3D &info.op_tmpl; =20 @@ -3139,13 +3176,14 @@ static int spi_nor_create_read_dirmap(struct spi_no= r *nor) =20 static int spi_nor_create_write_dirmap(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_mem_dirmap_info info =3D { .op_tmpl =3D SPI_MEM_OP(SPI_MEM_OP_CMD(nor->program_opcode, 0), SPI_MEM_OP_ADDR(nor->addr_nbytes, 0, 0), SPI_MEM_OP_NO_DUMMY, SPI_MEM_OP_DATA_OUT(0, NULL, 0)), .offset =3D 0, - .length =3D nor->params->size, + .length =3D params->size, }; struct spi_mem_op *op =3D &info.op_tmpl; =20 @@ -3168,6 +3206,7 @@ static int spi_nor_create_write_dirmap(struct spi_nor= *nor) =20 static int spi_nor_probe(struct spi_mem *spimem) { + struct spi_nor_flash_parameter *params; struct spi_device *spi =3D spimem->spi; struct flash_platform_data *data =3D dev_get_platdata(&spi->dev); struct spi_nor *nor; @@ -3214,13 +3253,15 @@ static int spi_nor_probe(struct spi_mem *spimem) =20 spi_nor_debugfs_register(nor); =20 + params =3D spi_nor_get_params(nor, 0); + /* * None of the existing parts have > 512B pages, but let's play safe * and add this logic so that if anyone ever adds support for such * a NOR we don't end up with buffer overflows. */ - if (nor->params->page_size > PAGE_SIZE) { - nor->bouncebuf_size =3D nor->params->page_size; + if (params->page_size > PAGE_SIZE) { + nor->bouncebuf_size =3D params->page_size; devm_kfree(nor->dev, nor->bouncebuf); nor->bouncebuf =3D devm_kmalloc(nor->dev, nor->bouncebuf_size, diff --git a/drivers/mtd/spi-nor/debugfs.c b/drivers/mtd/spi-nor/debugfs.c index 845b78c7ecc7..1ba86fc6166a 100644 --- a/drivers/mtd/spi-nor/debugfs.c +++ b/drivers/mtd/spi-nor/debugfs.c @@ -73,7 +73,7 @@ static void spi_nor_print_flags(struct seq_file *s, unsig= ned long flags, static int spi_nor_params_show(struct seq_file *s, void *data) { struct spi_nor *nor =3D s->private; - struct spi_nor_flash_parameter *params =3D nor->params; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_nor_erase_map *erase_map =3D ¶ms->erase_map; struct spi_nor_erase_region *region; const struct flash_info *info =3D nor->info; @@ -181,7 +181,7 @@ static void spi_nor_print_pp_cmd(struct seq_file *s, static int spi_nor_capabilities_show(struct seq_file *s, void *data) { struct spi_nor *nor =3D s->private; - struct spi_nor_flash_parameter *params =3D nor->params; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); u32 hwcaps =3D params->hwcaps.mask; int i, cmd; =20 diff --git a/drivers/mtd/spi-nor/gigadevice.c b/drivers/mtd/spi-nor/gigadev= ice.c index d57ddaf1525b..643f131d3916 100644 --- a/drivers/mtd/spi-nor/gigadevice.c +++ b/drivers/mtd/spi-nor/gigadevice.c @@ -13,6 +13,8 @@ gd25q256_post_bfpt(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + /* * GD25Q256C supports the first version of JESD216 which does not define * the Quad Enable methods. Overwrite the default Quad Enable method. @@ -24,7 +26,7 @@ gd25q256_post_bfpt(struct spi_nor *nor, */ if (bfpt_header->major =3D=3D SFDP_JESD216_MAJOR && bfpt_header->minor =3D=3D SFDP_JESD216_MINOR) - nor->params->quad_enable =3D spi_nor_sr1_bit6_quad_enable; + params->quad_enable =3D spi_nor_sr1_bit6_quad_enable; =20 return 0; } diff --git a/drivers/mtd/spi-nor/issi.c b/drivers/mtd/spi-nor/issi.c index 400e2b42f45a..7785ba347526 100644 --- a/drivers/mtd/spi-nor/issi.c +++ b/drivers/mtd/spi-nor/issi.c @@ -13,6 +13,8 @@ is25lp256_post_bfpt_fixups(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + /* * IS25LP256 supports 4B opcodes, but the BFPT advertises * BFPT_DWORD1_ADDRESS_BYTES_3_ONLY. @@ -20,7 +22,7 @@ is25lp256_post_bfpt_fixups(struct spi_nor *nor, */ if ((bfpt->dwords[SFDP_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) =3D=3D BFPT_DWORD1_ADDRESS_BYTES_3_ONLY) - nor->params->addr_nbytes =3D 4; + params->addr_nbytes =3D 4; =20 return 0; } @@ -31,7 +33,8 @@ static const struct spi_nor_fixups is25lp256_fixups =3D { =20 static void pm25lv_nor_late_init(struct spi_nor *nor) { - struct spi_nor_erase_map *map =3D &nor->params->erase_map; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + struct spi_nor_erase_map *map =3D ¶ms->erase_map; int i; =20 /* The PM25LV series has a different 4k sector erase opcode */ @@ -91,7 +94,9 @@ static const struct flash_info issi_nor_parts[] =3D { =20 static void issi_nor_default_init(struct spi_nor *nor) { - nor->params->quad_enable =3D spi_nor_sr1_bit6_quad_enable; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + params->quad_enable =3D spi_nor_sr1_bit6_quad_enable; } =20 static const struct spi_nor_fixups issi_fixups =3D { diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c index 6853ec9ae65d..85d3f5b04f74 100644 --- a/drivers/mtd/spi-nor/macronix.c +++ b/drivers/mtd/spi-nor/macronix.c @@ -104,8 +104,10 @@ static const struct flash_info macronix_nor_parts[] = =3D { =20 static void macronix_nor_default_init(struct spi_nor *nor) { - nor->params->quad_enable =3D spi_nor_sr1_bit6_quad_enable; - nor->params->set_4byte_addr_mode =3D spi_nor_set_4byte_addr_mode; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + params->quad_enable =3D spi_nor_sr1_bit6_quad_enable; + params->set_4byte_addr_mode =3D spi_nor_set_4byte_addr_mode; } =20 static const struct spi_nor_fixups macronix_nor_fixups =3D { diff --git a/drivers/mtd/spi-nor/micron-st.c b/drivers/mtd/spi-nor/micron-s= t.c index 7bb86df52f0b..b93e16094b6c 100644 --- a/drivers/mtd/spi-nor/micron-st.c +++ b/drivers/mtd/spi-nor/micron-st.c @@ -49,10 +49,11 @@ =20 static int micron_st_nor_octal_dtr_en(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_mem_op op; u8 *buf =3D nor->bouncebuf; int ret; - u8 addr_mode_nbytes =3D nor->params->addr_mode_nbytes; + u8 addr_mode_nbytes =3D params->addr_mode_nbytes; =20 /* Use 20 dummy cycles for memory array reads. */ *buf =3D 20; @@ -128,27 +129,31 @@ static int micron_st_nor_octal_dtr_enable(struct spi_= nor *nor, bool enable) =20 static void mt35xu512aba_default_init(struct spi_nor *nor) { - nor->params->octal_dtr_enable =3D micron_st_nor_octal_dtr_enable; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + params->octal_dtr_enable =3D micron_st_nor_octal_dtr_enable; } =20 static void mt35xu512aba_post_sfdp_fixup(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + /* Set the Fast Read settings. */ - nor->params->hwcaps.mask |=3D SNOR_HWCAPS_READ_8_8_8_DTR; - spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_8_8_8_DTR], + params->hwcaps.mask |=3D SNOR_HWCAPS_READ_8_8_8_DTR; + spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_8_8_8_DTR], 0, 20, SPINOR_OP_MT_DTR_RD, SNOR_PROTO_8_8_8_DTR); =20 nor->cmd_ext_type =3D SPI_NOR_EXT_REPEAT; - nor->params->rdsr_dummy =3D 8; - nor->params->rdsr_addr_nbytes =3D 0; + params->rdsr_dummy =3D 8; + params->rdsr_addr_nbytes =3D 0; =20 /* * The BFPT quad enable field is set to a reserved value so the quad * enable function is ignored by spi_nor_parse_bfpt(). Make sure we * disable it. */ - nor->params->quad_enable =3D NULL; + params->quad_enable =3D NULL; } =20 static const struct spi_nor_fixups mt35xu512aba_fixups =3D { @@ -336,14 +341,15 @@ static int micron_st_nor_set_4byte_addr_mode(struct s= pi_nor *nor, bool enable) */ static int micron_st_nor_read_fsr(struct spi_nor *nor, u8 *fsr) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; =20 if (nor->spimem) { struct spi_mem_op op =3D MICRON_ST_RDFSR_OP(fsr); =20 if (nor->reg_proto =3D=3D SNOR_PROTO_8_8_8_DTR) { - op.addr.nbytes =3D nor->params->rdsr_addr_nbytes; - op.dummy.nbytes =3D nor->params->rdsr_dummy; + op.addr.nbytes =3D params->rdsr_addr_nbytes; + op.dummy.nbytes =3D params->rdsr_dummy; /* * We don't want to read only one byte in DTR mode. So, * read 2 and then discard the second byte. @@ -446,16 +452,20 @@ static int micron_st_nor_ready(struct spi_nor *nor) =20 static void micron_st_nor_default_init(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + nor->flags |=3D SNOR_F_HAS_LOCK; nor->flags &=3D ~SNOR_F_HAS_16BIT_SR; - nor->params->quad_enable =3D NULL; - nor->params->set_4byte_addr_mode =3D micron_st_nor_set_4byte_addr_mode; + params->quad_enable =3D NULL; + params->set_4byte_addr_mode =3D micron_st_nor_set_4byte_addr_mode; } =20 static void micron_st_nor_late_init(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + if (nor->info->mfr_flags & USE_FSR) - nor->params->ready =3D micron_st_nor_ready; + params->ready =3D micron_st_nor_ready; } =20 static const struct spi_nor_fixups micron_st_nor_fixups =3D { diff --git a/drivers/mtd/spi-nor/otp.c b/drivers/mtd/spi-nor/otp.c index 3d75899de303..5b0319ea7f96 100644 --- a/drivers/mtd/spi-nor/otp.c +++ b/drivers/mtd/spi-nor/otp.c @@ -19,7 +19,9 @@ */ static inline unsigned int spi_nor_otp_region_len(struct spi_nor *nor) { - return nor->params->otp.org->len; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + return params->otp.org->len; } =20 /** @@ -30,7 +32,9 @@ static inline unsigned int spi_nor_otp_region_len(struct = spi_nor *nor) */ static inline unsigned int spi_nor_otp_n_regions(struct spi_nor *nor) { - return nor->params->otp.org->n_regions; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + return params->otp.org->n_regions; } =20 /** @@ -241,7 +245,8 @@ int spi_nor_otp_is_locked_sr2(struct spi_nor *nor, unsi= gned int region) =20 static loff_t spi_nor_otp_region_start(const struct spi_nor *nor, unsigned= int region) { - const struct spi_nor_otp_organization *org =3D nor->params->otp.org; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + const struct spi_nor_otp_organization *org =3D params->otp.org; =20 return org->base + region * org->offset; } @@ -266,7 +271,8 @@ static int spi_nor_mtd_otp_info(struct mtd_info *mtd, s= ize_t len, size_t *retlen, struct otp_info *buf) { struct spi_nor *nor =3D mtd_to_spi_nor(mtd); - const struct spi_nor_otp_ops *ops =3D nor->params->otp.ops; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + const struct spi_nor_otp_ops *ops =3D params->otp.ops; unsigned int n_regions =3D spi_nor_otp_n_regions(nor); unsigned int i; int ret, locked; @@ -303,7 +309,8 @@ static int spi_nor_mtd_otp_info(struct mtd_info *mtd, s= ize_t len, static int spi_nor_mtd_otp_range_is_locked(struct spi_nor *nor, loff_t ofs, size_t len) { - const struct spi_nor_otp_ops *ops =3D nor->params->otp.ops; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + const struct spi_nor_otp_ops *ops =3D params->otp.ops; unsigned int region; int locked; =20 @@ -328,7 +335,8 @@ static int spi_nor_mtd_otp_read_write(struct mtd_info *= mtd, loff_t ofs, const u8 *buf, bool is_write) { struct spi_nor *nor =3D mtd_to_spi_nor(mtd); - const struct spi_nor_otp_ops *ops =3D nor->params->otp.ops; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + const struct spi_nor_otp_ops *ops =3D params->otp.ops; const size_t rlen =3D spi_nor_otp_region_len(nor); loff_t rstart, rofs; unsigned int region; @@ -414,7 +422,8 @@ static int spi_nor_mtd_otp_write(struct mtd_info *mtd, = loff_t to, size_t len, static int spi_nor_mtd_otp_erase(struct mtd_info *mtd, loff_t from, size_t= len) { struct spi_nor *nor =3D mtd_to_spi_nor(mtd); - const struct spi_nor_otp_ops *ops =3D nor->params->otp.ops; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + const struct spi_nor_otp_ops *ops =3D params->otp.ops; const size_t rlen =3D spi_nor_otp_region_len(nor); unsigned int region; loff_t rstart; @@ -467,7 +476,8 @@ static int spi_nor_mtd_otp_erase(struct mtd_info *mtd, = loff_t from, size_t len) static int spi_nor_mtd_otp_lock(struct mtd_info *mtd, loff_t from, size_t = len) { struct spi_nor *nor =3D mtd_to_spi_nor(mtd); - const struct spi_nor_otp_ops *ops =3D nor->params->otp.ops; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + const struct spi_nor_otp_ops *ops =3D params->otp.ops; const size_t rlen =3D spi_nor_otp_region_len(nor); unsigned int region; int ret; @@ -501,9 +511,10 @@ static int spi_nor_mtd_otp_lock(struct mtd_info *mtd, = loff_t from, size_t len) =20 void spi_nor_set_mtd_otp_ops(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct mtd_info *mtd =3D &nor->mtd; =20 - if (!nor->params->otp.ops) + if (!params->otp.ops) return; =20 if (WARN_ON(!is_power_of_2(spi_nor_otp_region_len(nor)))) diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index 298ab5e53a8c..da96d3d27cb4 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -431,7 +431,7 @@ static void spi_nor_regions_sort_erase_types(struct spi= _nor_erase_map *map) static int spi_nor_parse_bfpt(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header) { - struct spi_nor_flash_parameter *params =3D nor->params; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_nor_erase_map *map =3D ¶ms->erase_map; struct spi_nor_erase_type *erase_type =3D map->erase_type; struct sfdp_bfpt bfpt; @@ -645,6 +645,8 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, */ static u8 spi_nor_smpt_addr_nbytes(const struct spi_nor *nor, const u32 se= ttings) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + switch (settings & SMPT_CMD_ADDRESS_LEN_MASK) { case SMPT_CMD_ADDRESS_LEN_0: return 0; @@ -654,7 +656,7 @@ static u8 spi_nor_smpt_addr_nbytes(const struct spi_nor= *nor, const u32 settings return 4; case SMPT_CMD_ADDRESS_LEN_USE_CURRENT: default: - return nor->params->addr_mode_nbytes; + return params->addr_mode_nbytes; } } =20 @@ -806,7 +808,8 @@ spi_nor_region_check_overlay(struct spi_nor_erase_regio= n *region, static int spi_nor_init_non_uniform_erase_map(struct spi_nor *nor, const u32 *smpt) { - struct spi_nor_erase_map *map =3D &nor->params->erase_map; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + struct spi_nor_erase_map *map =3D ¶ms->erase_map; struct spi_nor_erase_type *erase =3D map->erase_type; struct spi_nor_erase_region *region; u64 offset; @@ -894,6 +897,7 @@ static int spi_nor_init_non_uniform_erase_map(struct sp= i_nor *nor, static int spi_nor_parse_smpt(struct spi_nor *nor, const struct sfdp_parameter_header *smpt_header) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); const u32 *sector_map; u32 *smpt; size_t len; @@ -924,7 +928,7 @@ static int spi_nor_parse_smpt(struct spi_nor *nor, if (ret) goto out; =20 - spi_nor_regions_sort_erase_types(&nor->params->erase_map); + spi_nor_regions_sort_erase_types(¶ms->erase_map); /* fall through */ out: kfree(smpt); @@ -964,7 +968,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, { 0u /* not used */, BIT(11) }, { 0u /* not used */, BIT(12) }, }; - struct spi_nor_flash_parameter *params =3D nor->params; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_nor_pp_command *params_pp =3D params->page_programs; struct spi_nor_erase_map *map =3D ¶ms->erase_map; struct spi_nor_erase_type *erase_type =3D map->erase_type; @@ -1127,6 +1131,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, static int spi_nor_parse_profile1(struct spi_nor *nor, const struct sfdp_parameter_header *profile1_header) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); u32 *dwords, addr; size_t len; int ret; @@ -1149,14 +1154,14 @@ static int spi_nor_parse_profile1(struct spi_nor *n= or, =20 /* Set the Read Status Register dummy cycles and dummy address bytes. */ if (dwords[SFDP_DWORD(1)] & PROFILE1_DWORD1_RDSR_DUMMY) - nor->params->rdsr_dummy =3D 8; + params->rdsr_dummy =3D 8; else - nor->params->rdsr_dummy =3D 4; + params->rdsr_dummy =3D 4; =20 if (dwords[SFDP_DWORD(1)] & PROFILE1_DWORD1_RDSR_ADDR_BYTES) - nor->params->rdsr_addr_nbytes =3D 4; + params->rdsr_addr_nbytes =3D 4; else - nor->params->rdsr_addr_nbytes =3D 0; + params->rdsr_addr_nbytes =3D 0; =20 /* * We don't know what speed the controller is running at. Find the @@ -1185,8 +1190,8 @@ static int spi_nor_parse_profile1(struct spi_nor *nor, dummy =3D round_up(dummy, 2); =20 /* Update the fast read settings. */ - nor->params->hwcaps.mask |=3D SNOR_HWCAPS_READ_8_8_8_DTR; - spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_8_8_8_DTR], + params->hwcaps.mask |=3D SNOR_HWCAPS_READ_8_8_8_DTR; + spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_8_8_8_DTR], 0, dummy, opcode, SNOR_PROTO_8_8_8_DTR); =20 @@ -1194,7 +1199,7 @@ static int spi_nor_parse_profile1(struct spi_nor *nor, * Page Program is "Required Command" in the xSPI Profile 1.0. Update * the params->hwcaps.mask here. */ - nor->params->hwcaps.mask |=3D SNOR_HWCAPS_PP_8_8_8_DTR; + params->hwcaps.mask |=3D SNOR_HWCAPS_PP_8_8_8_DTR; =20 out: kfree(dwords); diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c index 12a256c0ef4c..fe3293c597c9 100644 --- a/drivers/mtd/spi-nor/spansion.c +++ b/drivers/mtd/spi-nor/spansion.c @@ -51,10 +51,11 @@ =20 static int cypress_nor_octal_dtr_en(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_mem_op op; u8 *buf =3D nor->bouncebuf; int ret; - u8 addr_mode_nbytes =3D nor->params->addr_mode_nbytes; + u8 addr_mode_nbytes =3D params->addr_mode_nbytes; =20 /* Use 24 dummy cycles for memory array reads. */ *buf =3D SPINOR_REG_CYPRESS_CFR2_MEMLAT_11_24; @@ -141,8 +142,9 @@ static int cypress_nor_octal_dtr_dis(struct spi_nor *no= r) */ static int cypress_nor_quad_enable_volatile(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_mem_op op; - u8 addr_mode_nbytes =3D nor->params->addr_mode_nbytes; + u8 addr_mode_nbytes =3D params->addr_mode_nbytes; u8 cfr1v_written; int ret; =20 @@ -200,8 +202,9 @@ static int cypress_nor_quad_enable_volatile(struct spi_= nor *nor) */ static int cypress_nor_set_page_size(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_mem_op op =3D - CYPRESS_NOR_RD_ANY_REG_OP(nor->params->addr_mode_nbytes, + CYPRESS_NOR_RD_ANY_REG_OP(params->addr_mode_nbytes, SPINOR_REG_CYPRESS_CFR3V, nor->bouncebuf); int ret; @@ -211,9 +214,9 @@ static int cypress_nor_set_page_size(struct spi_nor *no= r) return ret; =20 if (nor->bouncebuf[0] & SPINOR_REG_CYPRESS_CFR3_PGSZ) - nor->params->page_size =3D 512; + params->page_size =3D 512; else - nor->params->page_size =3D 256; + params->page_size =3D 256; =20 return 0; } @@ -223,16 +226,19 @@ s25hx_t_post_bfpt_fixup(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + /* Replace Quad Enable with volatile version */ - nor->params->quad_enable =3D cypress_nor_quad_enable_volatile; + params->quad_enable =3D cypress_nor_quad_enable_volatile; =20 return cypress_nor_set_page_size(nor); } =20 static void s25hx_t_post_sfdp_fixup(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct spi_nor_erase_type *erase_type =3D - nor->params->erase_map.erase_type; + params->erase_map.erase_type; unsigned int i; =20 /* @@ -255,7 +261,7 @@ static void s25hx_t_post_sfdp_fixup(struct spi_nor *nor) =20 static void s25hx_t_late_init(struct spi_nor *nor) { - struct spi_nor_flash_parameter *params =3D nor->params; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); =20 /* Fast Read 4B requires mode cycles */ params->reads[SNOR_CMD_READ_FAST].num_mode_clocks =3D 8; @@ -288,22 +294,24 @@ static int cypress_nor_octal_dtr_enable(struct spi_no= r *nor, bool enable) =20 static void s28hx_t_post_sfdp_fixup(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + /* * On older versions of the flash the xSPI Profile 1.0 table has the * 8D-8D-8D Fast Read opcode as 0x00. But it actually should be 0xEE. */ - if (nor->params->reads[SNOR_CMD_READ_8_8_8_DTR].opcode =3D=3D 0) - nor->params->reads[SNOR_CMD_READ_8_8_8_DTR].opcode =3D + if (params->reads[SNOR_CMD_READ_8_8_8_DTR].opcode =3D=3D 0) + params->reads[SNOR_CMD_READ_8_8_8_DTR].opcode =3D SPINOR_OP_CYPRESS_RD_FAST; =20 /* This flash is also missing the 4-byte Page Program opcode bit. */ - spi_nor_set_pp_settings(&nor->params->page_programs[SNOR_CMD_PP], + spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP], SPINOR_OP_PP_4B, SNOR_PROTO_1_1_1); /* * Since xSPI Page Program opcode is backward compatible with * Legacy SPI, use Legacy SPI opcode there as well. */ - spi_nor_set_pp_settings(&nor->params->page_programs[SNOR_CMD_PP_8_8_8_DTR= ], + spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP_8_8_8_DTR], SPINOR_OP_PP_4B, SNOR_PROTO_8_8_8_DTR); =20 /* @@ -311,7 +319,7 @@ static void s28hx_t_post_sfdp_fixup(struct spi_nor *nor) * address bytes needed for Read Status Register command as 0 but the * actual value for that is 4. */ - nor->params->rdsr_addr_nbytes =3D 4; + params->rdsr_addr_nbytes =3D 4; } =20 static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor, @@ -323,8 +331,10 @@ static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor, =20 static void s28hx_t_late_init(struct spi_nor *nor) { - nor->params->octal_dtr_enable =3D cypress_nor_octal_dtr_enable; - nor->params->writesize =3D 16; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + params->octal_dtr_enable =3D cypress_nor_octal_dtr_enable; + params->writesize =3D 16; } =20 static const struct spi_nor_fixups s28hx_t_fixups =3D { @@ -338,13 +348,15 @@ s25fs_s_nor_post_bfpt_fixups(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + /* * The S25FS-S chip family reports 512-byte pages in BFPT but * in reality the write buffer still wraps at the safe default * of 256 bytes. Overwrite the page size advertised by BFPT * to get the writes working. */ - nor->params->page_size =3D 256; + params->page_size =3D 256; =20 return 0; } @@ -546,7 +558,9 @@ static int spansion_nor_sr_ready_and_clear(struct spi_n= or *nor) =20 static void spansion_nor_late_init(struct spi_nor *nor) { - if (nor->params->size > SZ_16M) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + if (params->size > SZ_16M) { nor->flags |=3D SNOR_F_4B_OPCODES; /* No small sector erase for 4-byte command set */ nor->erase_opcode =3D SPINOR_OP_SE; @@ -554,7 +568,7 @@ static void spansion_nor_late_init(struct spi_nor *nor) } =20 if (nor->info->mfr_flags & USE_CLSR) - nor->params->ready =3D spansion_nor_sr_ready_and_clear; + params->ready =3D spansion_nor_sr_ready_and_clear; } =20 static const struct spi_nor_fixups spansion_nor_fixups =3D { diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c index 63bcc97bf978..6b91a32804ad 100644 --- a/drivers/mtd/spi-nor/sst.c +++ b/drivers/mtd/spi-nor/sst.c @@ -20,10 +20,11 @@ static int sst26vf_nor_lock(struct spi_nor *nor, loff_t= ofs, uint64_t len) =20 static int sst26vf_nor_unlock(struct spi_nor *nor, loff_t ofs, uint64_t le= n) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; =20 /* We only support unlocking the entire flash array. */ - if (ofs !=3D 0 || len !=3D nor->params->size) + if (ofs !=3D 0 || len !=3D params->size) return -EINVAL; =20 ret =3D spi_nor_read_cr(nor, nor->bouncebuf); @@ -51,7 +52,9 @@ static const struct spi_nor_locking_ops sst26vf_nor_locki= ng_ops =3D { =20 static void sst26vf_nor_late_init(struct spi_nor *nor) { - nor->params->locking_ops =3D &sst26vf_nor_locking_ops; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + params->locking_ops =3D &sst26vf_nor_locking_ops; } =20 static const struct spi_nor_fixups sst26vf_nor_fixups =3D { diff --git a/drivers/mtd/spi-nor/swp.c b/drivers/mtd/spi-nor/swp.c index 1f178313ba8f..88eaed2c40fe 100644 --- a/drivers/mtd/spi-nor/swp.c +++ b/drivers/mtd/spi-nor/swp.c @@ -340,11 +340,14 @@ static const struct spi_nor_locking_ops spi_nor_sr_lo= cking_ops =3D { =20 void spi_nor_init_default_locking_ops(struct spi_nor *nor) { - nor->params->locking_ops =3D &spi_nor_sr_locking_ops; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + params->locking_ops =3D &spi_nor_sr_locking_ops; } =20 static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) { + struct spi_nor_flash_parameter *params; struct spi_nor *nor =3D mtd_to_spi_nor(mtd); int ret; =20 @@ -352,7 +355,8 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t of= s, uint64_t len) if (ret) return ret; =20 - ret =3D nor->params->locking_ops->lock(nor, ofs, len); + params =3D spi_nor_get_params(nor, 0); + ret =3D params->locking_ops->lock(nor, ofs, len); =20 spi_nor_unlock_and_unprep(nor); return ret; @@ -360,6 +364,7 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t of= s, uint64_t len) =20 static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) { + struct spi_nor_flash_parameter *params; struct spi_nor *nor =3D mtd_to_spi_nor(mtd); int ret; =20 @@ -367,7 +372,8 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t = ofs, uint64_t len) if (ret) return ret; =20 - ret =3D nor->params->locking_ops->unlock(nor, ofs, len); + params =3D spi_nor_get_params(nor, 0); + ret =3D params->locking_ops->unlock(nor, ofs, len); =20 spi_nor_unlock_and_unprep(nor); return ret; @@ -375,6 +381,7 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t = ofs, uint64_t len) =20 static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t le= n) { + struct spi_nor_flash_parameter *params; struct spi_nor *nor =3D mtd_to_spi_nor(mtd); int ret; =20 @@ -382,7 +389,8 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff= _t ofs, uint64_t len) if (ret) return ret; =20 - ret =3D nor->params->locking_ops->is_locked(nor, ofs, len); + params =3D spi_nor_get_params(nor, 0); + ret =3D params->locking_ops->is_locked(nor, ofs, len); =20 spi_nor_unlock_and_unprep(nor); return ret; @@ -402,6 +410,7 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff= _t ofs, uint64_t len) */ void spi_nor_try_unlock_all(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); int ret; =20 if (!(nor->flags & SNOR_F_HAS_LOCK)) @@ -409,16 +418,17 @@ void spi_nor_try_unlock_all(struct spi_nor *nor) =20 dev_dbg(nor->dev, "Unprotecting entire flash array\n"); =20 - ret =3D spi_nor_unlock(&nor->mtd, 0, nor->params->size); + ret =3D spi_nor_unlock(&nor->mtd, 0, params->size); if (ret) dev_dbg(nor->dev, "Failed to unlock the entire flash memory array\n"); } =20 void spi_nor_set_mtd_locking_ops(struct spi_nor *nor) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct mtd_info *mtd =3D &nor->mtd; =20 - if (!nor->params->locking_ops) + if (!params->locking_ops) return; =20 mtd->_lock =3D spi_nor_lock; diff --git a/drivers/mtd/spi-nor/winbond.c b/drivers/mtd/spi-nor/winbond.c index ca39acf4112c..ce321e40d2f4 100644 --- a/drivers/mtd/spi-nor/winbond.c +++ b/drivers/mtd/spi-nor/winbond.c @@ -218,13 +218,17 @@ static const struct spi_nor_otp_ops winbond_nor_otp_o= ps =3D { =20 static void winbond_nor_default_init(struct spi_nor *nor) { - nor->params->set_4byte_addr_mode =3D winbond_nor_set_4byte_addr_mode; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + params->set_4byte_addr_mode =3D winbond_nor_set_4byte_addr_mode; } =20 static void winbond_nor_late_init(struct spi_nor *nor) { - if (nor->params->otp.org->n_regions) - nor->params->otp.ops =3D &winbond_nor_otp_ops; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + if (params->otp.org->n_regions) + params->otp.ops =3D &winbond_nor_otp_ops; } =20 static const struct spi_nor_fixups winbond_nor_fixups =3D { diff --git a/drivers/mtd/spi-nor/xilinx.c b/drivers/mtd/spi-nor/xilinx.c index 5723157739fc..6c5da0e0f9a4 100644 --- a/drivers/mtd/spi-nor/xilinx.c +++ b/drivers/mtd/spi-nor/xilinx.c @@ -55,7 +55,8 @@ static const struct flash_info xilinx_nor_parts[] =3D { */ static u32 s3an_nor_convert_addr(struct spi_nor *nor, u32 addr) { - u32 page_size =3D nor->params->page_size; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + u32 page_size =3D params->page_size; u32 offset, page; =20 offset =3D addr % page_size; @@ -115,6 +116,7 @@ static int xilinx_nor_sr_ready(struct spi_nor *nor) static int xilinx_nor_setup(struct spi_nor *nor, const struct spi_nor_hwcaps *hwcaps) { + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); u32 page_size; int ret; =20 @@ -140,14 +142,14 @@ static int xilinx_nor_setup(struct spi_nor *nor, */ if (nor->bouncebuf[0] & XSR_PAGESIZE) { /* Flash in Power of 2 mode */ - page_size =3D (nor->params->page_size =3D=3D 264) ? 256 : 512; - nor->params->page_size =3D page_size; + page_size =3D (params->page_size =3D=3D 264) ? 256 : 512; + params->page_size =3D page_size; nor->mtd.writebufsize =3D page_size; - nor->params->size =3D 8 * page_size * nor->info->n_sectors; + params->size =3D 8 * page_size * nor->info->n_sectors; nor->mtd.erasesize =3D 8 * page_size; } else { /* Flash in Default addressing mode */ - nor->params->convert_addr =3D s3an_nor_convert_addr; + params->convert_addr =3D s3an_nor_convert_addr; nor->mtd.erasesize =3D nor->info->sector_size; } =20 @@ -156,8 +158,10 @@ static int xilinx_nor_setup(struct spi_nor *nor, =20 static void xilinx_nor_late_init(struct spi_nor *nor) { - nor->params->setup =3D xilinx_nor_setup; - nor->params->ready =3D xilinx_nor_sr_ready; + struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + + params->setup =3D xilinx_nor_setup; + params->ready =3D xilinx_nor_sr_ready; } =20 static const struct spi_nor_fixups xilinx_nor_fixups =3D { diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index a3f8cdca90c8..338b73125131 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -420,6 +420,16 @@ static inline struct device_node *spi_nor_get_flash_no= de(struct spi_nor *nor) return mtd_get_of_node(&nor->mtd); } =20 +static inline struct spi_nor_flash_parameter *spi_nor_get_params(const str= uct spi_nor *nor, u8 idx) +{ + return nor->params; +} + +static inline void spi_nor_set_params(struct spi_nor *nor, u8 idx, + struct spi_nor_flash_parameter *params) +{ + nor->params =3D params; +} /** * spi_nor_scan() - scan the SPI NOR * @nor: the spi_nor structure --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 6F8E8C64EC4 for ; Fri, 10 Mar 2023 17:40:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231676AbjCJRkL (ORCPT ); Fri, 10 Mar 2023 12:40:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbjCJRjn (ORCPT ); Fri, 10 Mar 2023 12:39:43 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20611.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::611]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 171CA509AA; Fri, 10 Mar 2023 09:39:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PAODitFKg+vzhtn4QobmDfQBs8TYmkDfGPnMfFAhgyUsdiuf+fwwaNdQiDb4KadWcwIZ8Gqfjp+hVRXda8tq2ktrPTs27aK2ZhnydRUYqtzxQWizAF4gtgUKlKGMhF5D/+7OwTo9nAU2JMTZDGDmoyPqvnD8jhJMGnF5Y5zwhg6E3hba5eUBH8g5w8Ns/piiyJWykA1HSKvPWnZ8hAik+QM8gEkTFygnn6Q5NSwi/Ro8yu/vVP00oRkzozSR5SVc8AlKMP89W9ldAu70pyDKWhEpk8qwjrgF07NQ2ibXM8LgEYgGXXz+chBOpdF7mJeaDY81whW98CdnsmLLthg0gw== 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=+IVXn/mM4AsDZB1DevEXYDSMwH8y5/7rgv4q8dO9l10=; b=O8w3H8yDu8GYSIhUaDRE/1uh8+HIo5R38Y0j1WnDTJbB4Xb68YoARRqxkr+2muWPtM3LwF+nPdIfL8lF3OPSHKnDnvf6+vVC4rmNGHSSlLR1zLncvSJjJ4jN/bo/MXI0jLjM0z9ol0gioB4aAjjP0FlCuEj06v+2br8yHURd5lko4ed+iX6VYz0SO4qyAjq9VBdFaLXuk6AzZ92Yae2B6RX4wcSx5wGEU5p7ebBBXpT5kljxM85j2xP7vYSiD/0fasp9jJeBk8kUWnRn19ahbvb4knvKgyizh+Ohnr91PDWQ/3ZLW05rQbepz3gScXk2mREoNtkcEzzOpFG1A3VKyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=+IVXn/mM4AsDZB1DevEXYDSMwH8y5/7rgv4q8dO9l10=; b=2NWKP6UrjT63U8rQIyfFLjvg3jbHMvfF4k6oAsjS/91JFhfRWRW2Ogidk/MZBerbbmd6OAHguGurj/v4NXfZPgk6s3H4eeIu4wtrEMs54YRgIERmedupkEqggkq+zN1V27rGewYBfXB2Ma1/48SFyfTFHwW+UwB+Z6MLSF8ezzc= Received: from BN0PR07CA0026.namprd07.prod.outlook.com (2603:10b6:408:141::26) by MN0PR12MB6368.namprd12.prod.outlook.com (2603:10b6:208:3d2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:38:42 +0000 Received: from BN8NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:408:141:cafe::7f) by BN0PR07CA0026.outlook.office365.com (2603:10b6:408:141::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:38:42 +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 BN8NAM11FT035.mail.protection.outlook.com (10.13.177.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:38:42 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Fri, 10 Mar 2023 11:38:41 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 09:38:41 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:38:14 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 12/15] mtd: spi-nor: Add stacked memories support in spi-nor Date: Fri, 10 Mar 2023 23:02:14 +0530 Message-ID: <20230310173217.3429788-13-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT035:EE_|MN0PR12MB6368:EE_ X-MS-Office365-Filtering-Correlation-Id: da304ee8-f7f6-4b69-99ac-08db218e4aa4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RZ7wEpBwB8AYaG4uqPtGJxZcSAYU3ErAH0n0oSbRQQ8y7hgLsniVttKV25ML8WW7ijR2iCJfmLWh97t9DaGNvjTrIb/YlECkp2/AUU8LbOXoNZK9TcSqKJNih53hdGF8SmePBn4VW48WEzTl4C7H8Td9RuwMtPH6ssM9ANbPO40P3O1CQvPdI2Rmcrepy/IUeV8Xswl4xbwN7lpGKEZl530uY0i1NI+Qwq9mQDl3R0loIzYPLa2WBZpTbCL9PaMqzhs8IunP6Bultl14TAaz0Num2f3WtYZf8L6kd3UmkRV4/gkSisH6uIeBghmSEe9FmBEk+s4sAUfyJySvwuQ6V+aNO+Xgqiu1fpWv3sgKL9NzQDBQz+EXbBt4dCz2+XYijERzAnwKr7r+S0b5jdUr4RAXV8eY6A5jBQ+ehcoKRM/1meVo1h+oAAbbL4OignaMVI8nNQ/tBT4PyqyxtCFghWhHChUWJ/a4ZHA3fc7dJG9BygkyChFTFurKP7Q9fqq9lw4DsU0qdX3N4LiLqYxVn0EGXJ95ZuGykPkNRUf36xHExSF9GJ8nM9M+aq+M/YY43B/diiwY1bPumzYhsO3HnrDjfGBRwGmgD0KN3ONZakBObWwviiEZM41+c3VnfYou4LXB7D7BxR8l4GeXa4pZz5U43iiWmcByMutURBKVo/L5TV1Ejqn/xPhx04+xnHkKSZuxk4Tn1NmA+mGBbSBXLeFR5t3w5nobwj+QR2AdDXJjVUSPbppCoSX6BRz9YjQ1TaoohAzv7Du0BTC+bt+pzyX9VLSQphF9usRY9eWc4ZGMnAAnfo4uGnp9PjDfz3CHWvugDGWhXUithP6ejQXm/pkfQerJlrBft7gdJakr47A= 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:(13230025)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199018)(46966006)(36840700001)(40470700004)(40460700003)(36756003)(110136005)(54906003)(5660300002)(7276002)(7366002)(7336002)(7416002)(316002)(7406005)(2906002)(8936002)(70206006)(30864003)(70586007)(8676002)(41300700001)(4326008)(40480700001)(26005)(1191002)(81166007)(36860700001)(186003)(1076003)(921005)(356005)(86362001)(2616005)(82740400003)(478600001)(83380400001)(47076005)(336012)(426003)(82310400005)(2101003)(36900700001)(84006005)(41080700001)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:38:42.3024 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da304ee8-f7f6-4b69-99ac-08db218e4aa4 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: BN8NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6368 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Each flash that is connected in stacked mode should have a separate parameter structure. So, the flash parameter member(*params) of the spi_nor structure is changed to an array (*params[2]). The array is used to store the parameters of each flash connected in stacked configuration. The current implementation assumes that a maximum of two flashes are connected in stacked mode and both the flashes are of same make but can differ in sizes. So, except the sizes all other flash parameters of both the flashes are identical. SPI-NOR is not aware of the chip_select values, for any incoming request SPI-NOR will decide the flash index with the help of individual flash size and the configuration type (single/stacked). SPI-NOR will pass on the flash index information to the SPI core & SPI driver by setting the appropriate bit in nor->spimem->spi->cs_index_mask. For example, if nth bit of nor->spimem->spi->cs_index_mask is set then the driver would assert/de-assert spi->chip_slect[n]. Signed-off-by: Amit Kumar Mahapatra --- drivers/mtd/spi-nor/core.c | 282 +++++++++++++++++++++++++++++------- drivers/mtd/spi-nor/core.h | 4 + include/linux/mtd/spi-nor.h | 12 +- 3 files changed, 244 insertions(+), 54 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 66b6934b4465..0bc6b42f276c 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -1441,13 +1441,18 @@ static int spi_nor_erase_multi_sectors(struct spi_n= or *nor, u64 addr, u32 len) static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) { struct spi_nor *nor =3D mtd_to_spi_nor(mtd); - u32 addr, len; + struct spi_nor_flash_parameter *params; + u32 addr, len, offset, cur_cs_num =3D 0; uint32_t rem; int ret; + u64 sz; =20 dev_dbg(nor->dev, "at 0x%llx, len %lld\n", (long long)instr->addr, (long long)instr->len); =20 + params =3D spi_nor_get_params(nor, 0); + sz =3D params->size; + if (spi_nor_has_uniform_erase(nor)) { div_u64_rem(instr->len, mtd->erasesize, &rem); if (rem) @@ -1465,26 +1470,30 @@ static int spi_nor_erase(struct mtd_info *mtd, stru= ct erase_info *instr) if (len =3D=3D mtd->size && !(nor->flags & SNOR_F_NO_OP_CHIP_ERASE)) { unsigned long timeout; =20 - ret =3D spi_nor_write_enable(nor); - if (ret) - goto erase_err; + while (cur_cs_num < SNOR_FLASH_CNT_MAX && params) { + nor->spimem->spi->cs_index_mask =3D 0x01 << cur_cs_num; + ret =3D spi_nor_write_enable(nor); + if (ret) + goto erase_err; =20 - ret =3D spi_nor_erase_chip(nor); - if (ret) - goto erase_err; + ret =3D spi_nor_erase_chip(nor); + if (ret) + goto erase_err; =20 - /* - * Scale the timeout linearly with the size of the flash, with - * a minimum calibrated to an old 2MB flash. We could try to - * pull these from CFI/SFDP, but these values should be good - * enough for now. - */ - timeout =3D max(CHIP_ERASE_2MB_READY_WAIT_JIFFIES, - CHIP_ERASE_2MB_READY_WAIT_JIFFIES * - (unsigned long)(mtd->size / SZ_2M)); - ret =3D spi_nor_wait_till_ready_with_timeout(nor, timeout); - if (ret) - goto erase_err; + /* + * Scale the timeout linearly with the size of the flash, with + * a minimum calibrated to an old 2MB flash. We could try to + * pull these from CFI/SFDP, but these values should be good + * enough for now. + */ + timeout =3D max(CHIP_ERASE_2MB_READY_WAIT_JIFFIES, + CHIP_ERASE_2MB_READY_WAIT_JIFFIES * + (unsigned long)(params->size / SZ_2M)); + ret =3D spi_nor_wait_till_ready_with_timeout(nor, timeout); + if (ret) + goto erase_err; + cur_cs_num++; + } =20 /* REVISIT in some cases we could speed up erasing large regions * by using SPINOR_OP_SE instead of SPINOR_OP_BE_4K. We may have set up @@ -1493,12 +1502,26 @@ static int spi_nor_erase(struct mtd_info *mtd, stru= ct erase_info *instr) =20 /* "sector"-at-a-time erase */ } else if (spi_nor_has_uniform_erase(nor)) { + /* Determine the flash from which the operation need to start */ + while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && (addr > sz - 1) && params) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } + while (len) { + nor->spimem->spi->cs_index_mask =3D 0x01 << cur_cs_num; ret =3D spi_nor_write_enable(nor); if (ret) goto erase_err; =20 - ret =3D spi_nor_erase_sector(nor, addr); + offset =3D addr; + if (nor->flags & SNOR_F_HAS_STACKED) { + params =3D spi_nor_get_params(nor, cur_cs_num); + offset -=3D (sz - params->size); + } + + ret =3D spi_nor_erase_sector(nor, offset); if (ret) goto erase_err; =20 @@ -1508,13 +1531,45 @@ static int spi_nor_erase(struct mtd_info *mtd, stru= ct erase_info *instr) =20 addr +=3D mtd->erasesize; len -=3D mtd->erasesize; + + /* + * Flash cross over condition in stacked mode. + */ + if ((nor->flags & SNOR_F_HAS_STACKED) && (addr > sz - 1)) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } } =20 /* erase multiple sectors */ } else { - ret =3D spi_nor_erase_multi_sectors(nor, addr, len); - if (ret) - goto erase_err; + u64 erase_len =3D 0; + + /* Determine the flash from which the operation need to start */ + while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && (addr > sz - 1) && params) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } + /* perform multi sector erase onec per Flash*/ + while (len) { + erase_len =3D (len > (sz - addr)) ? (sz - addr) : len; + offset =3D addr; + nor->spimem->spi->cs_index_mask =3D 0x01 << cur_cs_num; + if (nor->flags & SNOR_F_HAS_STACKED) { + params =3D spi_nor_get_params(nor, cur_cs_num); + offset -=3D (sz - params->size); + } + ret =3D spi_nor_erase_multi_sectors(nor, offset, erase_len); + if (ret) + goto erase_err; + len -=3D erase_len; + addr +=3D erase_len; + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } } =20 ret =3D spi_nor_write_disable(nor); @@ -1713,7 +1768,10 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t= from, size_t len, size_t *retlen, u_char *buf) { struct spi_nor *nor =3D mtd_to_spi_nor(mtd); - ssize_t ret; + struct spi_nor_flash_parameter *params; + ssize_t ret, read_len; + u32 cur_cs_num =3D 0; + u64 sz; =20 dev_dbg(nor->dev, "from 0x%08x, len %zd\n", (u32)from, len); =20 @@ -1721,9 +1779,23 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t= from, size_t len, if (ret) return ret; =20 + params =3D spi_nor_get_params(nor, 0); + sz =3D params->size; + + /* Determine the flash from which the operation need to start */ + while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && (from > sz - 1) && params) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } while (len) { loff_t addr =3D from; =20 + nor->spimem->spi->cs_index_mask =3D 0x01 << cur_cs_num; + read_len =3D (len > (sz - addr)) ? (sz - addr) : len; + params =3D spi_nor_get_params(nor, cur_cs_num); + addr -=3D (sz - params->size); + addr =3D spi_nor_convert_addr(nor, addr); =20 ret =3D spi_nor_read_data(nor, addr, len, buf); @@ -1735,11 +1807,22 @@ static int spi_nor_read(struct mtd_info *mtd, loff_= t from, size_t len, if (ret < 0) goto read_err; =20 - WARN_ON(ret > len); + WARN_ON(ret > read_len); *retlen +=3D ret; buf +=3D ret; from +=3D ret; len -=3D ret; + + /* + * Flash cross over condition in stacked mode. + * + */ + if ((nor->flags & SNOR_F_HAS_STACKED) && (from > sz - 1)) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } + } ret =3D 0; =20 @@ -1759,13 +1842,22 @@ static int spi_nor_write(struct mtd_info *mtd, loff= _t to, size_t len, struct spi_nor *nor =3D mtd_to_spi_nor(mtd); struct spi_nor_flash_parameter *params; size_t page_offset, page_remain, i; + u32 page_size, cur_cs_num =3D 0; ssize_t ret; - u32 page_size; + u64 sz; =20 dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len); =20 params =3D spi_nor_get_params(nor, 0); page_size =3D params->page_size; + sz =3D params->size; + + /* Determine the flash from which the operation need to start */ + while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && (to > sz - 1) && params) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } =20 ret =3D spi_nor_lock_and_prep(nor); if (ret) @@ -1790,6 +1882,10 @@ static int spi_nor_write(struct mtd_info *mtd, loff_= t to, size_t len, /* the size of data remaining on the first page */ page_remain =3D min_t(size_t, page_size - page_offset, len - i); =20 + nor->spimem->spi->cs_index_mask =3D 0x01 << cur_cs_num; + params =3D spi_nor_get_params(nor, cur_cs_num); + addr -=3D (sz - params->size); + addr =3D spi_nor_convert_addr(nor, addr); =20 ret =3D spi_nor_write_enable(nor); @@ -1806,6 +1902,15 @@ static int spi_nor_write(struct mtd_info *mtd, loff_= t to, size_t len, goto write_err; *retlen +=3D written; i +=3D written; + + /* + * Flash cross over condition in stacked mode. + */ + if ((nor->flags & SNOR_F_HAS_STACKED) && ((to + i) > sz - 1)) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } } =20 write_err: @@ -1918,8 +2023,6 @@ int spi_nor_hwcaps_pp2cmd(u32 hwcaps) static int spi_nor_spimem_check_op(struct spi_nor *nor, struct spi_mem_op *op) { - struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); - /* * First test with 4 address bytes. The opcode itself might * be a 3B addressing opcode but we don't care, because @@ -1928,7 +2031,7 @@ static int spi_nor_spimem_check_op(struct spi_nor *no= r, */ op->addr.nbytes =3D 4; if (!spi_mem_supports_op(nor->spimem, op)) { - if (params->size > SZ_16M) + if (nor->mtd.size > SZ_16M) return -EOPNOTSUPP; =20 /* If flash size <=3D 16MB, 3 address bytes are sufficient */ @@ -2525,6 +2628,10 @@ static void spi_nor_init_fixup_flags(struct spi_nor = *nor) static void spi_nor_late_init_params(struct spi_nor *nor) { struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + struct device_node *np =3D spi_nor_get_flash_node(nor); + u64 flash_size[SNOR_FLASH_CNT_MAX]; + u32 idx =3D 0, i =3D 0; + int rc; =20 if (nor->manufacturer && nor->manufacturer->fixups && nor->manufacturer->fixups->late_init) @@ -2542,6 +2649,36 @@ static void spi_nor_late_init_params(struct spi_nor = *nor) */ if (nor->flags & SNOR_F_HAS_LOCK && !params->locking_ops) spi_nor_init_default_locking_ops(nor); + /* + * The flashes that are connected in stacked mode should be of same make. + * Except the flash size all other properties are identical for all the + * flashes connected in stacked mode. + * The flashes that are connected in parallel mode should be identical. + */ + while (i < SNOR_FLASH_CNT_MAX) { + rc =3D of_property_read_u64_index(np, "stacked-memories", idx, &flash_si= ze[i]); + if (rc =3D=3D -EINVAL) { + break; + } else if (rc =3D=3D -EOVERFLOW) { + idx++; + } else { + idx++; + i++; + if (!(nor->flags & SNOR_F_HAS_STACKED)) + nor->flags |=3D SNOR_F_HAS_STACKED; + } + } + if (nor->flags & SNOR_F_HAS_STACKED) { + for (idx =3D 1; idx < SNOR_FLASH_CNT_MAX; idx++) { + params =3D spi_nor_get_params(nor, idx); + params =3D devm_kzalloc(nor->dev, sizeof(*params), GFP_KERNEL); + if (params) { + memcpy(params, spi_nor_get_params(nor, 0), sizeof(*params)); + params->size =3D flash_size[idx]; + spi_nor_set_params(nor, idx, params); + } + } + } } =20 /** @@ -2750,22 +2887,36 @@ static int spi_nor_octal_dtr_enable(struct spi_nor = *nor, bool enable) */ static int spi_nor_quad_enable(struct spi_nor *nor) { - struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); + struct spi_nor_flash_parameter *params; + int err, idx; =20 - if (!params->quad_enable) - return 0; + for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { + params =3D spi_nor_get_params(nor, idx); + if (params) { + if (!params->quad_enable) + return 0; =20 - if (!(spi_nor_get_protocol_width(nor->read_proto) =3D=3D 4 || - spi_nor_get_protocol_width(nor->write_proto) =3D=3D 4)) - return 0; + if (!(spi_nor_get_protocol_width(nor->read_proto) =3D=3D 4 || + spi_nor_get_protocol_width(nor->write_proto) =3D=3D 4)) + return 0; + /* + * Set the appropriate CS index before + * issuing the command. + */ + nor->spimem->spi->cs_index_mask =3D 0x01 << idx; =20 - return params->quad_enable(nor); + err =3D params->quad_enable(nor); + if (err) + return err; + } + } + return err; } =20 static int spi_nor_init(struct spi_nor *nor) { - struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); - int err; + struct spi_nor_flash_parameter *params; + int err, idx; =20 err =3D spi_nor_octal_dtr_enable(nor, true); if (err) { @@ -2806,9 +2957,19 @@ static int spi_nor_init(struct spi_nor *nor) */ WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET, "enabling reset hack; may not recover from unexpected reboots\n"); - err =3D params->set_4byte_addr_mode(nor, true); - if (err && err !=3D -ENOTSUPP) - return err; + for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { + params =3D spi_nor_get_params(nor, idx); + if (params) { + /* + * Select the appropriate CS index before + * issuing the command. + */ + nor->spimem->spi->cs_index_mask =3D 0x01 << idx; + err =3D params->set_4byte_addr_mode(nor, true); + if (err && err !=3D -ENOTSUPP) + return err; + } + } } =20 return 0; @@ -2924,19 +3085,31 @@ void spi_nor_restore(struct spi_nor *nor) { struct spi_nor_flash_parameter *params; int ret; + int idx; =20 /* restore the addressing mode */ if (nor->addr_nbytes =3D=3D 4 && !(nor->flags & SNOR_F_4B_OPCODES) && nor->flags & SNOR_F_BROKEN_RESET) { - params =3D spi_nor_get_params(nor, 0); - ret =3D params->set_4byte_addr_mode(nor, false); - if (ret) - /* - * Do not stop the execution in the hope that the flash - * will default to the 3-byte address mode after the - * software reset. - */ - dev_err(nor->dev, "Failed to exit 4-byte address mode, err =3D %d\n", r= et); + for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { + params =3D spi_nor_get_params(nor, idx); + if (params) { + /* + * Select the appropriate CS index before + * issuing the command. + */ + nor->spimem->spi->cs_index_mask =3D 0x01 << idx; + ret =3D params->set_4byte_addr_mode(nor, false); + if (ret) + /* + * Do not stop the execution in the hope that the flash + * will default to the 3-byte address mode after the + * software reset. + */ + dev_err(nor->dev, + "Failed to exit 4-byte address mode, err =3D %d\n", + ret); + } + } } =20 if (nor->flags & SNOR_F_SOFT_RESET) @@ -3004,6 +3177,8 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor) struct spi_nor_flash_parameter *params =3D spi_nor_get_params(nor, 0); struct mtd_info *mtd =3D &nor->mtd; struct device *dev =3D nor->dev; + u64 total_sz =3D 0; + int idx; =20 spi_nor_set_mtd_locking_ops(nor); spi_nor_set_mtd_otp_ops(nor); @@ -3019,7 +3194,12 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor) mtd->_erase =3D spi_nor_erase; mtd->writesize =3D params->writesize; mtd->writebufsize =3D params->page_size; - mtd->size =3D params->size; + for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { + params =3D spi_nor_get_params(nor, idx); + if (params) + total_sz +=3D params->size; + } + mtd->size =3D total_sz; mtd->_read =3D spi_nor_read; /* Might be already set by some SST flashes. */ if (!mtd->_write) diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 25423225c29d..cff2f9c389b8 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -11,6 +11,9 @@ =20 #define SPI_NOR_MAX_ID_LEN 6 =20 +/* In single configuration enable CS0 */ +#define SPI_NOR_ENABLE_CS0 BIT(0) + /* Standard SPI NOR flash operations. */ #define SPI_NOR_READID_OP(naddr, ndummy, buf, len) \ SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDID, 0), \ @@ -130,6 +133,7 @@ enum spi_nor_option_flags { SNOR_F_IO_MODE_EN_VOLATILE =3D BIT(11), SNOR_F_SOFT_RESET =3D BIT(12), SNOR_F_SWP_IS_VOLATILE =3D BIT(13), + SNOR_F_HAS_STACKED =3D BIT(14), }; =20 struct spi_nor_read_command { diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 338b73125131..99f0f2ede444 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -127,6 +127,12 @@ #define SR2_LB3 BIT(5) /* Security Register Lock Bit 3 */ #define SR2_QUAD_EN_BIT7 BIT(7) =20 +/* + * Maximum number of flashes that can be connected + * in stacked/parallel configuration + */ +#define SNOR_FLASH_CNT_MAX 2 + /* Supported SPI protocols */ #define SNOR_PROTO_INST_MASK GENMASK(23, 16) #define SNOR_PROTO_INST_SHIFT 16 @@ -399,7 +405,7 @@ struct spi_nor { =20 const struct spi_nor_controller_ops *controller_ops; =20 - struct spi_nor_flash_parameter *params; + struct spi_nor_flash_parameter *params[SNOR_FLASH_CNT_MAX]; =20 struct { struct spi_mem_dirmap_desc *rdesc; @@ -422,13 +428,13 @@ static inline struct device_node *spi_nor_get_flash_n= ode(struct spi_nor *nor) =20 static inline struct spi_nor_flash_parameter *spi_nor_get_params(const str= uct spi_nor *nor, u8 idx) { - return nor->params; + return nor->params[idx]; } =20 static inline void spi_nor_set_params(struct spi_nor *nor, u8 idx, struct spi_nor_flash_parameter *params) { - nor->params =3D params; + nor->params[idx] =3D params; } /** * spi_nor_scan() - scan the SPI NOR --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 D8111C74A5B for ; Fri, 10 Mar 2023 17:40:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231868AbjCJRkp (ORCPT ); Fri, 10 Mar 2023 12:40:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231712AbjCJRkN (ORCPT ); Fri, 10 Mar 2023 12:40:13 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060d.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::60d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26C3512BAE2; Fri, 10 Mar 2023 09:39:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AFuFER+LWwUAYPT0HAJvKrlXYyCClbIIUVpdsEbv6S1Ludb6KRAd2hDm2K0fVc6nXxVPjYRYzdNElZgB0Bwn0B7l7mDz9yKKn7vD44lLzqBwJudXNFxnMecrVtB0ULmmSh7P+wvnHkIV+k5NEnSFvN3VLKf3Sxo53Sm2/11abldX6+onRamWw7ubgrEULZ7ar8NAPr0UanMvYHUEskNXBfkg9idCBA0bVli9TKrkG9pTn9lMMRrTcbOj3Cqb2/udUE7S46tvoT61/va7iQz660jG9j2Vs62mBxy2BGNLIG5aMu8iVUZucU2WXCvDp6ttBPhWADoNHxuqXGAKvULDFA== 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=vKxfkb4YbG5w9Tm8mG5YGBxw1K7w2rVJ374cq5bsNis=; b=CDta0rtI9WgjlisAR/PERpjoARqNsfqwaHFxN8CROpINR1m/A8Is/mXbO83yS3ik0rUG+lI7aNvpRoPOAN1RFgbo/dOhrGH/dCCfj2MKXWJeysfHvgLQ1oUN+47kLaTttffe5DakPtn0jMID8BuLg3Z1byBgDYrFL+DiJirq6AifSaxED53pBYMI8s+dnzAX6OdfsBwGPxdcLVhqTsu5C4qQkWNQReOhjv+DGppaPudF+dqEIW5GOiStJotHK/L7x6djUilrqRwP70d2FDiw1SpCQSuhs2id/Ne9aVZ/+t5zk2bTGNsiyZbu0O7DFB4uOhP+TlDs/6T/EuTpBU0CPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=vKxfkb4YbG5w9Tm8mG5YGBxw1K7w2rVJ374cq5bsNis=; b=doqsFrkE1iz98njnNv4CRbMC126Hd7FD3UZAfwIQn+nqKWIX1eZkY7PoXPfY2mtxXb51w/VkH1Ix1R6asG3U6UN1teBXS/mRSssRrK3kq7Yc0cXEDPS5leVJW52ha4BaqEbTxhnFB1S/xQhOpq8pX8q+5f9TR4p/CoTqdR4ZcVI= Received: from BN9PR03CA0765.namprd03.prod.outlook.com (2603:10b6:408:13a::20) by SJ0PR12MB6902.namprd12.prod.outlook.com (2603:10b6:a03:484::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:39:10 +0000 Received: from BN8NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13a:cafe::e3) by BN9PR03CA0765.outlook.office365.com (2603:10b6:408:13a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:39:09 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT055.mail.protection.outlook.com (10.13.177.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:39:09 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:39:09 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 09:39:08 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:38:41 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 13/15] spi: spi-zynqmp-gqspi: Add stacked memories support in GQSPI driver Date: Fri, 10 Mar 2023 23:02:15 +0530 Message-ID: <20230310173217.3429788-14-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT055:EE_|SJ0PR12MB6902:EE_ X-MS-Office365-Filtering-Correlation-Id: 4050f504-4ad2-40e2-763c-08db218e5aee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x7jQaumCjZR0T9S11MlzIybBELHPA+OmuGtU11G0PLWh/cB9MmUWlp49ftfqyjtd52Pg4JyZYX0Z/hz552N3XB/+la3MdalEs7XG6X5wVvqRJU0Di9oDgZ5QrKk5lo211hTZ1R7e7rRdGlO5Zzh50T1igJqBeQ4LdXF8ii0bBkv6ALqpsTWRXf4PzruORKvAjbuQ9cDJR7eHFXc/rs33xcyNhaLpeFXXBwdysYyZNm2zsOwpCuIpm2agDean3r7lCufM6EuQybB6fnk6Da4kH9ReaTWXBCsepKVjfLDSaUTjECxUjCQNIMGI10FBGlZL/OCIoNropjucaYZiByMKXSTYfyxk6/ZYSoyM2nNjq7aTKohEG56TwZOe5fSnpHRWC2B9pmNo28zVdwnRLf9qup1oD5BcVMbhu4NUwfm+mvbDmeeeMZNES5vOqQvN3YoDdLTwPavrTDQpHUYyhyUntBO6LVpehwvrhIClOrNnqtwtyj7Qf4rwd+N2EkGTxen2v7yl6393b8RZC+6amEUMZc2pLax9DY1FlaUDjofODK+EAFec/RtQzSVHdaYXEPorAeJZ6Gr7UCtviu+CaBfu+cqjGIzrDvfeT+akg+T+k5FoEC87QhOD9MoTYbnOv6ij3Q2L9NYKP879p+9AmSTYEXZUfX6eWWh34X/pMZ2qeNCKwuUE2Jf1sDV1hBE0yRSsCHxVFNpJ/5cbak/tIrcgmdyzH4XV8ARsKOfwsXdDHNTpOt145LnSqZuJszLbJKVxk9P6HdlqPDMs0d5MRJDr0JhleSzWSLYuFJ1FXywbOltLlMDvPSNnDKZ5wJEsrw53Mw4KQ4KTtI57hIZNq5TiCJgb0k7L1HACxhS9pLD4ckg= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(136003)(346002)(396003)(39860400002)(376002)(451199018)(36840700001)(40470700004)(46966006)(921005)(1191002)(40460700003)(40480700001)(36756003)(82310400005)(86362001)(478600001)(356005)(2616005)(47076005)(426003)(54906003)(8676002)(70206006)(110136005)(70586007)(336012)(186003)(316002)(6666004)(26005)(1076003)(2906002)(7416002)(7406005)(7276002)(7336002)(7366002)(83380400001)(81166007)(36860700001)(8936002)(82740400003)(4326008)(41300700001)(5660300002)(41080700001)(36900700001)(84006005)(2101003)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:39:09.6300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4050f504-4ad2-40e2-763c-08db218e5aee 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6902 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" GQSPI supports two chip select CS0 & CS1. Update the driver to assert/de-assert the appropriate chip select as per the bits set in qspi->cs_index_mask. Signed-off-by: Amit Kumar Mahapatra --- drivers/spi/spi-zynqmp-gqspi.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index fb2ca9b90eab..3d2b92a88e8a 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -156,6 +156,9 @@ #define GQSPI_FREQ_100MHZ 100000000 #define GQSPI_FREQ_150MHZ 150000000 =20 +#define GQSPI_SELECT_LOWER_CS BIT(0) +#define GQSPI_SELECT_UPPER_CS BIT(1) + #define SPI_AUTOSUSPEND_TIMEOUT 3000 enum mode_type {GQSPI_MODE_IO, GQSPI_MODE_DMA}; =20 @@ -467,15 +470,17 @@ static void zynqmp_qspi_chipselect(struct spi_device = *qspi, bool is_high) =20 genfifoentry |=3D GQSPI_GENFIFO_MODE_SPI; =20 + if (qspi->cs_index_mask & GQSPI_SELECT_UPPER_CS) { + zynqmp_gqspi_selectslave(xqspi, + GQSPI_SELECT_FLASH_CS_UPPER, + GQSPI_SELECT_FLASH_BUS_LOWER); + } else if (qspi->cs_index_mask & GQSPI_SELECT_LOWER_CS) { + zynqmp_gqspi_selectslave(xqspi, + GQSPI_SELECT_FLASH_CS_LOWER, + GQSPI_SELECT_FLASH_BUS_LOWER); + } + genfifoentry |=3D xqspi->genfifobus; if (!is_high) { - if (!spi_get_chipselect(qspi, 0)) { - xqspi->genfifobus =3D GQSPI_GENFIFO_BUS_LOWER; - xqspi->genfifocs =3D GQSPI_GENFIFO_CS_LOWER; - } else { - xqspi->genfifobus =3D GQSPI_GENFIFO_BUS_UPPER; - xqspi->genfifocs =3D GQSPI_GENFIFO_CS_UPPER; - } - genfifoentry |=3D xqspi->genfifobus; genfifoentry |=3D xqspi->genfifocs; genfifoentry |=3D GQSPI_GENFIFO_CS_SETUP; } else { --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 1A4E7C74A44 for ; Fri, 10 Mar 2023 17:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbjCJRmQ (ORCPT ); Fri, 10 Mar 2023 12:42:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231672AbjCJRlu (ORCPT ); Fri, 10 Mar 2023 12:41:50 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2087.outbound.protection.outlook.com [40.107.94.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3B5112BAF7; Fri, 10 Mar 2023 09:41:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RaiGM4vg3f1IPoMn6LwSZWgRxEwiZt351HBlAzY6vRHCHEiuehX+sfgn+qF5e/vxb/BzvWQdZwl+Fs2kv388h5IEJjpCeuKIFqRqnjMxtNbQcmtCvBjJ3+ZKOp+W5R2fHXutNyrvwl5+uoC50h0Q4yYFVVp+ve9XSKx5egCDJWV5ZZVstAGIlZAqpBMe243EWFZrHq6XgurpmhNkO5Uzm0FjayHLq8ZlJPghilLA7NlmcTJpVUTefEji6+nfxWp3XzBq4FlPOjIo67P/+V2bM37d0UBgXzkMbYcsJvKQ6MjQyD9aevnx7ltDNe1glfNa/U6NIYbSTuQappCn0T/fVQ== 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=y+OBoxRbyFTf/PmCWxHBBhKULvrDM6FbjS8ugtklqYw=; b=QCYWRhjtQduDLmcwnFi4Xhw7gFAWBTNHiK2fd6BGG9HuZq4F9YoxVSbLCKWoSLj9cXoCgyExEjwj4JbX4Ft0Yai6qk9De71bOyCYviuG2MJIjzt3gQ60xMB7bBrIGBxH3Q66DUIVMjT3V3lEAOOhG6TSGPBmyU3IO2A42R9Df1ADGveDpDRYZMhqy0YRRoXk3LJvwGdBJJ9bRARJJq+cmhI+5YCLV5DizJCAJ3xWd7Ip6VEU4l8j6iwsdcWW6BKLODb0NTn+uxzVx+eM3JPplP+N0qmbJQ6TpukzsW96Q3LtXTjxitis7ZuwVDoCYhsCPv3owXbcvs1OSI21pUgSvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=y+OBoxRbyFTf/PmCWxHBBhKULvrDM6FbjS8ugtklqYw=; b=4XhPTqLWk5F9ue9Vznei9o1YFvvTrLxst8zNQC8f+f9QhWCnXWgezfeXY/Xr8sPqiAKNPafc+b+pTGiA/vDbVNx2BuY1/aIuFbuebWWY4cZ+xRLfRH3M9VFOVBbc+6mbk1eOr991JjNGz32ItReR/GZplFHCMpHxjmbfFd1/iF4= Received: from BN9PR03CA0181.namprd03.prod.outlook.com (2603:10b6:408:f9::6) by IA0PR12MB8982.namprd12.prod.outlook.com (2603:10b6:208:481::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 17:39:37 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f9:cafe::19) by BN9PR03CA0181.outlook.office365.com (2603:10b6:408:f9::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:39:37 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.20 via Frontend Transport; Fri, 10 Mar 2023 17:39:37 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 11:39:36 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 10 Mar 2023 09:39:35 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:39:09 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 14/15] mtd: spi-nor: Add parallel memories support in spi-nor Date: Fri, 10 Mar 2023 23:02:16 +0530 Message-ID: <20230310173217.3429788-15-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT058:EE_|IA0PR12MB8982:EE_ X-MS-Office365-Filtering-Correlation-Id: ce1aef50-8ac1-474c-bec3-08db218e6b59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KQeY8G2CR0DAQne6bxawotKCe68GH5Yg0e1F36Ze/O+YYyBGLNH9fHm5OU55yqLBodn/KUMhGrUxCVcqMJ8NkwHEww3LxQ8S3J0U8TTrZQTI7l+eAvIpZkPIYUkovCUANxPnu7tNHSpytpnOzRIFCEGlI4P4x5cSbznxQl9sltB+kQuQDD0fry0YwLm8VXSSBw67XJ11CbDfjRH+CoLsjZOm7zDqnU+vQCzAIWh8tXtDlVQdD3KLYvPUu4Au2KTYuPz3NiTAL4X8CjeLOdL/tr1Gpso94H8m6bzIhNJvxpQL403BE7Su0+Yn39cxhyYJdu3oSUEAiRWNtfpQom+iKh3E239odk88CnA6AElqYGhQNTWZmJRDE/0upb5KhnN7ojq8kNY6g2LEpdPemFk4g3UimGE5rYINZ+qQguWLF4efMAN4ZY6HtzoU1uyxnCgJkUrXr3XV3tYPSIUEIHi/DbKjzvKQJBDIPRdRJa2kkQTMR2Od6Ow5fXvcd7USL6aHhiEsWjmexo0RohavEDPkcTEjdIHtWu6oBdDwOBgIeZncVrJrNuRV7EYgmk0DjHDFTgWCyapM2ddlBPh2lllz9q1ey/9lcEzkzPGUmqtwlfS1MM6AOLHDlcIjeNVWNV3IF/wlzy2+7rJOhviF6jhhoi4QYMZa6/JprSBg8vkMSP4wuAk7zWrLQ2DVY2ZKqOBtlAJDMVGDVniIAZtdXYGXD+Pfc3WKnFG6p1ux54yyW8zMCJxvJxsMYO0rbkapScFiHv5KkISi8dJQZtWTiF37qpouiXV9gLcUIu0wVB1n546fek1Tyb6b1zkU4D8QAC4R+cAg8BT53tkQpz8iWyo55VaMu1H73G+kc0jDroFcKIU= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(396003)(136003)(346002)(376002)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(40460700003)(36756003)(54906003)(110136005)(478600001)(5660300002)(356005)(316002)(7406005)(7366002)(7416002)(7336002)(7276002)(2906002)(8936002)(8676002)(70586007)(70206006)(30864003)(4326008)(41300700001)(26005)(1191002)(36860700001)(40480700001)(86362001)(921005)(186003)(81166007)(2616005)(6666004)(1076003)(82740400003)(83380400001)(82310400005)(336012)(426003)(47076005)(2101003)(84006005)(41080700001)(36900700001)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:39:37.1767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce1aef50-8ac1-474c-bec3-08db218e6b59 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8982 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The current implementation assumes that a maximum of two flashes are connected in parallel mode. The QSPI controller splits the data evenly between both the flashes so, both the flashes that are connected in parallel mode should be identical. During each operation SPI-NOR sets 0th bit for CS0 & 1st bit for CS1 in nor->spimem->spi->cs_index_mask. The QSPI driver will then assert/de-assert CS0 & CS1. Write operation in parallel mode are performed in page size * 2 chunks as each write operation results in writing both the flashes. For doubling the address space each operation is performed at addr/2 flash offset, where addr is the address specified by the user. Signed-off-by: Amit Kumar Mahapatra --- drivers/mtd/spi-nor/core.c | 514 +++++++++++++++++++++++--------- drivers/mtd/spi-nor/core.h | 4 + drivers/mtd/spi-nor/micron-st.c | 5 + 3 files changed, 384 insertions(+), 139 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 0bc6b42f276c..18fc4a1c28d4 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -464,17 +464,29 @@ int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) op.data.nbytes =3D 2; } =20 + if (nor->flags & SNOR_F_HAS_PARALLEL) + op.data.nbytes =3D 2; + spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); =20 ret =3D spi_mem_exec_op(nor->spimem, &op); } else { - ret =3D spi_nor_controller_ops_read_reg(nor, SPINOR_OP_RDSR, sr, - 1); + if (nor->flags & SNOR_F_HAS_PARALLEL) + ret =3D spi_nor_controller_ops_read_reg(nor, + SPINOR_OP_RDSR, + sr, 2); + else + ret =3D spi_nor_controller_ops_read_reg(nor, + SPINOR_OP_RDSR, + sr, 1); } =20 if (ret) dev_dbg(nor->dev, "error %d reading SR\n", ret); =20 + if (nor->flags & SNOR_F_HAS_PARALLEL) + sr[0] |=3D sr[1]; + return ret; } =20 @@ -1466,12 +1478,122 @@ static int spi_nor_erase(struct mtd_info *mtd, str= uct erase_info *instr) if (ret) return ret; =20 - /* whole-chip erase? */ - if (len =3D=3D mtd->size && !(nor->flags & SNOR_F_NO_OP_CHIP_ERASE)) { - unsigned long timeout; + if (!(nor->flags & SNOR_F_HAS_PARALLEL)) { + /* whole-chip erase? */ + if (len =3D=3D mtd->size && !(nor->flags & SNOR_F_NO_OP_CHIP_ERASE)) { + unsigned long timeout; + + while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && params) { + nor->spimem->spi->cs_index_mask =3D 1 << cur_cs_num; + ret =3D spi_nor_write_enable(nor); + if (ret) + goto erase_err; + + ret =3D spi_nor_erase_chip(nor); + if (ret) + goto erase_err; + + /* + * Scale the timeout linearly with the size of the flash, with + * a minimum calibrated to an old 2MB flash. We could try to + * pull these from CFI/SFDP, but these values should be good + * enough for now. + */ + timeout =3D max(CHIP_ERASE_2MB_READY_WAIT_JIFFIES, + CHIP_ERASE_2MB_READY_WAIT_JIFFIES * + (unsigned long)(params->size / + SZ_2M)); + ret =3D spi_nor_wait_till_ready_with_timeout(nor, timeout); + if (ret) + goto erase_err; + + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + } + + /* REVISIT in some cases we could speed up erasing large regions + * by using SPINOR_OP_SE instead of SPINOR_OP_BE_4K. We may have set up + * to use "small sector erase", but that's not always optimal. + */ + + /* "sector"-at-a-time erase */ + } else if (spi_nor_has_uniform_erase(nor)) { + /* Determine the flash from which the operation need to start */ + while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && + (addr > sz - 1) && params) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } + while (len) { + nor->spimem->spi->cs_index_mask =3D 1 << cur_cs_num; + ret =3D spi_nor_write_enable(nor); + if (ret) + goto erase_err; + + offset =3D addr; + if (nor->flags & SNOR_F_HAS_STACKED) { + params =3D spi_nor_get_params(nor, cur_cs_num); + offset -=3D (sz - params->size); + } + ret =3D spi_nor_erase_sector(nor, offset); + if (ret) + goto erase_err; + + ret =3D spi_nor_wait_till_ready(nor); + if (ret) + goto erase_err; + + addr +=3D mtd->erasesize; + len -=3D mtd->erasesize; + + /* + * Flash cross over condition in stacked mode. + */ + if ((nor->flags & SNOR_F_HAS_STACKED) && (addr > sz - 1)) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } + } + + /* erase multiple sectors */ + } else { + u64 erase_len =3D 0; + + /* Determine the flash from which the operation need to start */ + while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && + (addr > sz - 1) && params) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } + /* perform multi sector erase onec per Flash*/ + while (len) { + erase_len =3D (len > (sz - addr)) ? (sz - addr) : len; + offset =3D addr; + nor->spimem->spi->cs_index_mask =3D 1 << cur_cs_num; + if (nor->flags & SNOR_F_HAS_STACKED) { + params =3D spi_nor_get_params(nor, cur_cs_num); + offset -=3D (sz - params->size); + } + ret =3D spi_nor_erase_multi_sectors(nor, offset, erase_len); + if (ret) + goto erase_err; + len -=3D erase_len; + addr +=3D erase_len; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } + } + } else { + nor->spimem->spi->cs_index_mask =3D SPI_NOR_ENABLE_MULTI_CS; + + /* whole-chip erase? */ + if (len =3D=3D mtd->size && !(nor->flags & + SNOR_F_NO_OP_CHIP_ERASE)) { + unsigned long timeout; =20 - while (cur_cs_num < SNOR_FLASH_CNT_MAX && params) { - nor->spimem->spi->cs_index_mask =3D 0x01 << cur_cs_num; ret =3D spi_nor_write_enable(nor); if (ret) goto erase_err; @@ -1488,90 +1610,45 @@ static int spi_nor_erase(struct mtd_info *mtd, stru= ct erase_info *instr) */ timeout =3D max(CHIP_ERASE_2MB_READY_WAIT_JIFFIES, CHIP_ERASE_2MB_READY_WAIT_JIFFIES * - (unsigned long)(params->size / SZ_2M)); + (unsigned long)(mtd->size / SZ_2M)); ret =3D spi_nor_wait_till_ready_with_timeout(nor, timeout); if (ret) goto erase_err; - cur_cs_num++; - } - - /* REVISIT in some cases we could speed up erasing large regions - * by using SPINOR_OP_SE instead of SPINOR_OP_BE_4K. We may have set up - * to use "small sector erase", but that's not always optimal. - */ =20 - /* "sector"-at-a-time erase */ - } else if (spi_nor_has_uniform_erase(nor)) { - /* Determine the flash from which the operation need to start */ - while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && (addr > sz - 1) && params) { - cur_cs_num++; - params =3D spi_nor_get_params(nor, cur_cs_num); - sz +=3D params->size; - } + /* REVISIT in some cases we could speed up erasing large regions + * by using SPINOR_OP_SE instead of SPINOR_OP_BE_4K. We may have set up + * to use "small sector erase", but that's not always optimal. + */ =20 - while (len) { - nor->spimem->spi->cs_index_mask =3D 0x01 << cur_cs_num; - ret =3D spi_nor_write_enable(nor); - if (ret) - goto erase_err; + /* "sector"-at-a-time erase */ + } else if (spi_nor_has_uniform_erase(nor)) { + while (len) { + ret =3D spi_nor_write_enable(nor); + if (ret) + goto erase_err; =20 - offset =3D addr; - if (nor->flags & SNOR_F_HAS_STACKED) { - params =3D spi_nor_get_params(nor, cur_cs_num); - offset -=3D (sz - params->size); - } + offset =3D addr / 2; =20 - ret =3D spi_nor_erase_sector(nor, offset); - if (ret) - goto erase_err; - - ret =3D spi_nor_wait_till_ready(nor); - if (ret) - goto erase_err; + ret =3D spi_nor_erase_sector(nor, offset); + if (ret) + goto erase_err; =20 - addr +=3D mtd->erasesize; - len -=3D mtd->erasesize; + ret =3D spi_nor_wait_till_ready(nor); + if (ret) + goto erase_err; =20 - /* - * Flash cross over condition in stacked mode. - */ - if ((nor->flags & SNOR_F_HAS_STACKED) && (addr > sz - 1)) { - cur_cs_num++; - params =3D spi_nor_get_params(nor, cur_cs_num); - sz +=3D params->size; + addr +=3D mtd->erasesize; + len -=3D mtd->erasesize; } - } - - /* erase multiple sectors */ - } else { - u64 erase_len =3D 0; =20 - /* Determine the flash from which the operation need to start */ - while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && (addr > sz - 1) && params) { - cur_cs_num++; - params =3D spi_nor_get_params(nor, cur_cs_num); - sz +=3D params->size; - } - /* perform multi sector erase onec per Flash*/ - while (len) { - erase_len =3D (len > (sz - addr)) ? (sz - addr) : len; - offset =3D addr; - nor->spimem->spi->cs_index_mask =3D 0x01 << cur_cs_num; - if (nor->flags & SNOR_F_HAS_STACKED) { - params =3D spi_nor_get_params(nor, cur_cs_num); - offset -=3D (sz - params->size); - } - ret =3D spi_nor_erase_multi_sectors(nor, offset, erase_len); + /* erase multiple sectors */ + } else { + offset =3D addr / 2; + ret =3D spi_nor_erase_multi_sectors(nor, offset, len); if (ret) goto erase_err; - len -=3D erase_len; - addr +=3D erase_len; - cur_cs_num++; - params =3D spi_nor_get_params(nor, cur_cs_num); - sz +=3D params->size; } } - ret =3D spi_nor_write_disable(nor); =20 erase_err: @@ -1771,34 +1848,59 @@ static int spi_nor_read(struct mtd_info *mtd, loff_= t from, size_t len, struct spi_nor_flash_parameter *params; ssize_t ret, read_len; u32 cur_cs_num =3D 0; - u64 sz; + u_char *readbuf; + bool is_ofst_odd =3D false; + u64 sz =3D 0; =20 dev_dbg(nor->dev, "from 0x%08x, len %zd\n", (u32)from, len); =20 - ret =3D spi_nor_lock_and_prep(nor); - if (ret) - return ret; - params =3D spi_nor_get_params(nor, 0); sz =3D params->size; =20 - /* Determine the flash from which the operation need to start */ - while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && (from > sz - 1) && params) { - cur_cs_num++; - params =3D spi_nor_get_params(nor, cur_cs_num); - sz +=3D params->size; + /* + * Cannot read from odd offset in parallel mode, so read + * len + 1 from offset + 1 and ignore offset[0] data. + */ + if ((nor->flags & SNOR_F_HAS_PARALLEL) && (from & 0x01)) { + from =3D (loff_t)(from - 1); + len =3D (size_t)(len + 1); + is_ofst_odd =3D true; + readbuf =3D kmalloc(len, GFP_KERNEL); + if (!readbuf) + return -ENOMEM; + } else { + readbuf =3D buf; + } + + if (!(nor->flags & SNOR_F_HAS_PARALLEL)) { + /* Determine the flash from which the operation need to start */ + while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && (from > sz - 1) && params) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } } + ret =3D spi_nor_lock_and_prep(nor); + if (ret) + return ret; + while (len) { loff_t addr =3D from; =20 - nor->spimem->spi->cs_index_mask =3D 0x01 << cur_cs_num; - read_len =3D (len > (sz - addr)) ? (sz - addr) : len; - params =3D spi_nor_get_params(nor, cur_cs_num); - addr -=3D (sz - params->size); + if (nor->flags & SNOR_F_HAS_PARALLEL) { + nor->spimem->spi->cs_index_mask =3D SPI_NOR_ENABLE_MULTI_CS; + read_len =3D len; + addr /=3D 2; + } else { + nor->spimem->spi->cs_index_mask =3D 1 << cur_cs_num; + read_len =3D (len > (sz - addr)) ? (sz - addr) : len; + params =3D spi_nor_get_params(nor, cur_cs_num); + addr -=3D (sz - params->size); + } =20 addr =3D spi_nor_convert_addr(nor, addr); =20 - ret =3D spi_nor_read_data(nor, addr, len, buf); + ret =3D spi_nor_read_data(nor, addr, read_len, readbuf); if (ret =3D=3D 0) { /* We shouldn't see 0-length reads */ ret =3D -EIO; @@ -1808,8 +1910,20 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t= from, size_t len, goto read_err; =20 WARN_ON(ret > read_len); - *retlen +=3D ret; + if (is_ofst_odd) { + /* + * Cannot read from odd offset in parallel mode. + * So read len + 1 from offset + 1 from the flash + * and copy len data from readbuf[1]. + */ + memcpy(buf, (readbuf + 1), (len - 1)); + *retlen +=3D (ret - 1); + } else { + *retlen +=3D ret; + } buf +=3D ret; + if (!is_ofst_odd) + readbuf +=3D ret; from +=3D ret; len -=3D ret; =20 @@ -1827,6 +1941,9 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t = from, size_t len, ret =3D 0; =20 read_err: + if (is_ofst_odd) + kfree(readbuf); + spi_nor_unlock_and_unprep(nor); return ret; } @@ -1852,13 +1969,38 @@ static int spi_nor_write(struct mtd_info *mtd, loff= _t to, size_t len, page_size =3D params->page_size; sz =3D params->size; =20 - /* Determine the flash from which the operation need to start */ - while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && (to > sz - 1) && params) { - cur_cs_num++; - params =3D spi_nor_get_params(nor, cur_cs_num); - sz +=3D params->size; - } + if (nor->flags & SNOR_F_HAS_PARALLEL) { + /* + * Cannot write to odd offset in parallel mode, + * so write 2 byte first. + */ + if (to & 0x01) { + u8 two[2] =3D {0xff, buf[0]}; + size_t written_len; + + ret =3D spi_nor_write(mtd, to & ~1, 2, &written_len, two); + if (ret < 0) + return ret; + *retlen +=3D 1; /* We've written only one actual byte */ + ++buf; + --len; + ++to; + } + /* + * Write operation are performed in page size chunks and in + * parallel memories both the flashes are written simultaneously, + * hence doubled the page_size. + */ + page_size <<=3D 1; =20 + } else { + /* Determine the flash from which the operation need to start */ + while ((cur_cs_num < SNOR_FLASH_CNT_MAX) && (to > sz - 1) && params) { + cur_cs_num++; + params =3D spi_nor_get_params(nor, cur_cs_num); + sz +=3D params->size; + } + } ret =3D spi_nor_lock_and_prep(nor); if (ret) return ret; @@ -1882,9 +2024,14 @@ static int spi_nor_write(struct mtd_info *mtd, loff_= t to, size_t len, /* the size of data remaining on the first page */ page_remain =3D min_t(size_t, page_size - page_offset, len - i); =20 - nor->spimem->spi->cs_index_mask =3D 0x01 << cur_cs_num; - params =3D spi_nor_get_params(nor, cur_cs_num); - addr -=3D (sz - params->size); + if (nor->flags & SNOR_F_HAS_PARALLEL) { + nor->spimem->spi->cs_index_mask =3D SPI_NOR_ENABLE_MULTI_CS; + addr /=3D 2; + } else { + nor->spimem->spi->cs_index_mask =3D 1 << cur_cs_num; + params =3D spi_nor_get_params(nor, cur_cs_num); + addr -=3D (sz - params->size); + } =20 addr =3D spi_nor_convert_addr(nor, addr); =20 @@ -2332,7 +2479,15 @@ static int spi_nor_select_erase(struct spi_nor *nor) if (!erase) return -EINVAL; nor->erase_opcode =3D erase->opcode; - mtd->erasesize =3D erase->size; + /* + * In parallel-memories the erase operation is + * performed on both the flashes simultaneously + * so, double the erasesize. + */ + if (nor->flags & SNOR_F_HAS_PARALLEL) + mtd->erasesize =3D erase->size * 2; + else + mtd->erasesize =3D erase->size; return 0; } =20 @@ -2350,7 +2505,15 @@ static int spi_nor_select_erase(struct spi_nor *nor) if (!erase) return -EINVAL; =20 - mtd->erasesize =3D erase->size; + /* + * In parallel-memories the erase operation is + * performed on both the flashes simultaneously + * so, double the erasesize. + */ + if (nor->flags & SNOR_F_HAS_PARALLEL) + mtd->erasesize =3D erase->size * 2; + else + mtd->erasesize =3D erase->size; return 0; } =20 @@ -2668,7 +2831,22 @@ static void spi_nor_late_init_params(struct spi_nor = *nor) nor->flags |=3D SNOR_F_HAS_STACKED; } } - if (nor->flags & SNOR_F_HAS_STACKED) { + i =3D 0; + idx =3D 0; + while (i < SNOR_FLASH_CNT_MAX) { + rc =3D of_property_read_u64_index(np, "parallel-memories", idx, &flash_s= ize[i]); + if (rc =3D=3D -EINVAL) { + break; + } else if (rc =3D=3D -EOVERFLOW) { + idx++; + } else { + idx++; + i++; + if (!(nor->flags & SNOR_F_HAS_PARALLEL)) + nor->flags |=3D SNOR_F_HAS_PARALLEL; + } + } + if (nor->flags & (SNOR_F_HAS_STACKED | SNOR_F_HAS_PARALLEL)) { for (idx =3D 1; idx < SNOR_FLASH_CNT_MAX; idx++) { params =3D spi_nor_get_params(nor, idx); params =3D devm_kzalloc(nor->dev, sizeof(*params), GFP_KERNEL); @@ -2890,24 +3068,42 @@ static int spi_nor_quad_enable(struct spi_nor *nor) struct spi_nor_flash_parameter *params; int err, idx; =20 - for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { - params =3D spi_nor_get_params(nor, idx); - if (params) { - if (!params->quad_enable) - return 0; + if (nor->flags & SNOR_F_HAS_PARALLEL) { + params =3D spi_nor_get_params(nor, 0); + if (!params->quad_enable) + return 0; =20 - if (!(spi_nor_get_protocol_width(nor->read_proto) =3D=3D 4 || - spi_nor_get_protocol_width(nor->write_proto) =3D=3D 4)) - return 0; - /* - * Set the appropriate CS index before - * issuing the command. - */ - nor->spimem->spi->cs_index_mask =3D 0x01 << idx; + if (!(spi_nor_get_protocol_width(nor->read_proto) =3D=3D 4 || + spi_nor_get_protocol_width(nor->write_proto) =3D=3D 4)) + return 0; + /* + * In parallel mode both chip selects i.e., CS0 & + * CS1 need to be asserted simulatneously. + */ + nor->spimem->spi->cs_index_mask =3D SPI_NOR_ENABLE_MULTI_CS; + err =3D params->quad_enable(nor); + if (err) + return err; + } else { + for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { + params =3D spi_nor_get_params(nor, idx); + if (params) { + if (!params->quad_enable) + return 0; =20 - err =3D params->quad_enable(nor); - if (err) - return err; + if (!(spi_nor_get_protocol_width(nor->read_proto) =3D=3D 4 || + spi_nor_get_protocol_width(nor->write_proto) =3D=3D 4)) + return 0; + /* + * Set the appropriate CS index before + * issuing the command. + */ + nor->spimem->spi->cs_index_mask =3D 1 << idx; + + err =3D params->quad_enable(nor); + if (err) + return err; + } } } return err; @@ -2957,17 +3153,29 @@ static int spi_nor_init(struct spi_nor *nor) */ WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET, "enabling reset hack; may not recover from unexpected reboots\n"); - for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { - params =3D spi_nor_get_params(nor, idx); - if (params) { - /* - * Select the appropriate CS index before - * issuing the command. - */ - nor->spimem->spi->cs_index_mask =3D 0x01 << idx; - err =3D params->set_4byte_addr_mode(nor, true); - if (err && err !=3D -ENOTSUPP) - return err; + if (nor->flags & SNOR_F_HAS_PARALLEL) { + /* + * In parallel mode both chip selects i.e., CS0 & + * CS1 need to be asserted simulatneously. + */ + nor->spimem->spi->cs_index_mask =3D SPI_NOR_ENABLE_MULTI_CS; + params =3D spi_nor_get_params(nor, 0); + err =3D params->set_4byte_addr_mode(nor, true); + if (err && err !=3D -ENOTSUPP) + return err; + } else { + for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { + params =3D spi_nor_get_params(nor, idx); + if (params) { + /* + * Select the appropriate CS index before + * issuing the command. + */ + nor->spimem->spi->cs_index_mask =3D 1 << idx; + err =3D params->set_4byte_addr_mode(nor, true); + if (err && err !=3D -ENOTSUPP) + return err; + } } } } @@ -3090,20 +3298,39 @@ void spi_nor_restore(struct spi_nor *nor) /* restore the addressing mode */ if (nor->addr_nbytes =3D=3D 4 && !(nor->flags & SNOR_F_4B_OPCODES) && nor->flags & SNOR_F_BROKEN_RESET) { - for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { - params =3D spi_nor_get_params(nor, idx); - if (params) { + if (nor->flags & SNOR_F_HAS_PARALLEL) { + /* + * In parallel mode both chip selects i.e., CS0 & + * CS1 need to be asserted simulatneously. + */ + nor->spimem->spi->cs_index_mask =3D SPI_NOR_ENABLE_MULTI_CS; + params =3D spi_nor_get_params(nor, 0); + ret =3D params->set_4byte_addr_mode(nor, false); + if (ret) + /* + * Do not stop the execution in the hope that the flash + * will default to the 3-byte address mode after the + * software reset. + */ + dev_err(nor->dev, + "Failed to exit 4-byte address mode, err =3D %d\n", + ret); + } else { + for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { + params =3D spi_nor_get_params(nor, idx); + if (!params) + break; /* * Select the appropriate CS index before * issuing the command. */ - nor->spimem->spi->cs_index_mask =3D 0x01 << idx; + nor->spimem->spi->cs_index_mask =3D 1 << idx; ret =3D params->set_4byte_addr_mode(nor, false); if (ret) /* - * Do not stop the execution in the hope that the flash - * will default to the 3-byte address mode after the - * software reset. + * Do not stop the execution in the hope that the + * flash will default to the 3-byte address mode + * after the software reset. */ dev_err(nor->dev, "Failed to exit 4-byte address mode, err =3D %d\n", @@ -3193,7 +3420,16 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor) else mtd->_erase =3D spi_nor_erase; mtd->writesize =3D params->writesize; - mtd->writebufsize =3D params->page_size; + /* + * In parallel-memories the write operation is + * performed on both the flashes simultaneously + * one page per flash, so double the writebufsize. + */ + if (nor->flags & SNOR_F_HAS_PARALLEL) + mtd->writebufsize =3D params->page_size << 1; + else + mtd->writebufsize =3D params->page_size; + for (idx =3D 0; idx < SNOR_FLASH_CNT_MAX; idx++) { params =3D spi_nor_get_params(nor, idx); if (params) diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index cff2f9c389b8..6c6df417a9c6 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -14,6 +14,9 @@ /* In single configuration enable CS0 */ #define SPI_NOR_ENABLE_CS0 BIT(0) =20 +/* In parallel configuration enable multiple CS */ +#define SPI_NOR_ENABLE_MULTI_CS (BIT(0) | BIT(1)) + /* Standard SPI NOR flash operations. */ #define SPI_NOR_READID_OP(naddr, ndummy, buf, len) \ SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDID, 0), \ @@ -134,6 +137,7 @@ enum spi_nor_option_flags { SNOR_F_SOFT_RESET =3D BIT(12), SNOR_F_SWP_IS_VOLATILE =3D BIT(13), SNOR_F_HAS_STACKED =3D BIT(14), + SNOR_F_HAS_PARALLEL =3D BIT(15), }; =20 struct spi_nor_read_command { diff --git a/drivers/mtd/spi-nor/micron-st.c b/drivers/mtd/spi-nor/micron-s= t.c index b93e16094b6c..9be39f237dfc 100644 --- a/drivers/mtd/spi-nor/micron-st.c +++ b/drivers/mtd/spi-nor/micron-st.c @@ -357,6 +357,9 @@ static int micron_st_nor_read_fsr(struct spi_nor *nor, = u8 *fsr) op.data.nbytes =3D 2; } =20 + if (nor->flags & SNOR_F_HAS_PARALLEL) + op.data.nbytes =3D 2; + spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); =20 ret =3D spi_mem_exec_op(nor->spimem, &op); @@ -368,6 +371,8 @@ static int micron_st_nor_read_fsr(struct spi_nor *nor, = u8 *fsr) if (ret) dev_dbg(nor->dev, "error %d reading FSR\n", ret); =20 + if (nor->flags & SNOR_F_HAS_PARALLEL) + fsr[0] &=3D fsr[1]; return ret; } =20 --=20 2.25.1 From nobody Thu Nov 14 06:33:22 2024 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 662C6C76188 for ; Fri, 10 Mar 2023 17:42:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231546AbjCJRmJ (ORCPT ); Fri, 10 Mar 2023 12:42:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbjCJRlp (ORCPT ); Fri, 10 Mar 2023 12:41:45 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2054.outbound.protection.outlook.com [40.107.243.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55EB512D411; Fri, 10 Mar 2023 09:40:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VvOCvcU1esDFNcdTp9fMTiP9YrJ27WtckgNuuQ/M0J4iK2Q4ijcgzDqYIYSSe165HTS2tNZ2tjYj4aM7kQ0UzA1irErWBB9Dnho707qv5nrGxysvCTC/AQW+yjED8xHWA4JUFunWqNwzFEtfN7znPjemgJAA7dyRJAvUzn550ciyaJZj3O74w+N+xP9EqFlKBcq6Mh+PqpBB8ftWDodVwZiUF+kM43dqXB7sXlV4iDvq8p9djZta/QikpwSomc98+TN61iSeuh3ifW1GmR5Obe7EpjnLlKbetSp9x1H2DNWv+qxf29ljOnl2RtnTRjTA+tQ02uxJozFCjbkujhAIcw== 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=KaUhyoeEK1tG4Jq20ydCTjifKBTSA159AvAfZW0MjkQ=; b=HTuF/IcpRCGVLCnYF04aGY9I6AvwqUop50bUv2x44FWfCPyqI9NjEIJpuKXJb0RHG8LQCGV1Qi59cW/FnWqj0bXnK6W6kAYA4+WJQMB/WYJC32MlfHc7/BbR5hPdYSMM/NwqkRFTeNtZUDNrJhCwjM0phRE3FWhiDaFwbu2gZCYA0JCjoB/Z7Bx0b7JO8xNeRJ7+aP6bVNN00OOS+ZZOY/Ixb6sB3ZsRp4FNxE/G1KJn9uRbJHhDsP775z49wJTk6rGHg9JNJq7CHCOAkPhNrKiaKrhULHQzFh36IkBH6XK6PQLWS5HVeQWseg/eXEJSkO9vtusEAsi9TQXJRoX5lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=KaUhyoeEK1tG4Jq20ydCTjifKBTSA159AvAfZW0MjkQ=; b=OdrPcG0RPVLwrF5qKa+S3KNhS0bIJuUtmwjwgs6V1QBAN6Z+xN8kTmhfGO1HGcKpOUTkXCT6rdQGvj/lnh9GUEJcPwzVtwps0DAkHLR7KoLy/K7wVgughFMbxCS9QdM/ZvcljsOGRgmwUNTXysNVbkfzFAe8pgof1SCzoiXE6sQ= Received: from MW4PR04CA0200.namprd04.prod.outlook.com (2603:10b6:303:86::25) by BN9PR12MB5338.namprd12.prod.outlook.com (2603:10b6:408:103::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.20; Fri, 10 Mar 2023 17:40:10 +0000 Received: from CO1NAM11FT074.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::52) by MW4PR04CA0200.outlook.office365.com (2603:10b6:303:86::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29 via Frontend Transport; Fri, 10 Mar 2023 17:40:10 +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 CO1NAM11FT074.mail.protection.outlook.com (10.13.174.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.19 via Frontend Transport; Fri, 10 Mar 2023 17:40:10 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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; Fri, 10 Mar 2023 11:40:03 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 10 Mar 2023 11:39:36 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V6 15/15] spi: spi-zynqmp-gqspi: Add parallel memories support in GQSPI driver Date: Fri, 10 Mar 2023 23:02:17 +0530 Message-ID: <20230310173217.3429788-16-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> References: <20230310173217.3429788-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT074:EE_|BN9PR12MB5338:EE_ X-MS-Office365-Filtering-Correlation-Id: 82a898d3-01dc-46cf-1621-08db218e7f22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xt7TUEmhxJkG3uhUkGG89AnqA6rHXB2b1oBhbxumHhtWcnd2jUGpN0Q0HWHBfycuejtZ6LXt1TqMJvuYAsrKGP1+WuWryVzQtzdfFYCpEMfAcC0MV5BwoBUD6h4KSv/BDw2UeH/1mb5K2zfHk81eqUKAnb0+ZESBftRz7hxRZNVrze+8TgKYBj16bkdtEPgnf5CuakBOWoScoxkhtWbbEQb3I67slwNJLGIBFzmkdq/lxolX8/CHR3lbR+C32LP6ET5jxOB7c73GCv7YUoERmKCQCx6EUgnLm9ar7tTpfPDQak1vlkLYqPNJT/L9DSaJVnjCpLZUB1joIVtelqkV3FyOjSz+8+ZL+nj/QvH5mbzzWIEzKPC78N43lcgWLogk5OnKPd81ZllRwfOEkmpjsUSo/TU6ZK4zwbC22jfOdPKxmfsfjZMSMzl5BwbqyEkzfkHoG/okqPORgpb/p82BswKWG9hjg/rx87+0mhuVUxUOC7p+iWG8p5T7zXhqD+AoNqQJymlvwK6qONtCbFxqVLrFMGEmP5F0ElvEBvVvYl17GvgekYXP7edQ/+OUXiLug0ZN92dvILCd+OJjq5xWBeALWCHLQBdboneaQj6UzMwJvyjeR70tP1rSOAgb9dRrb/62Rz7hnB5bExgMeQJhvrfj6hCHcF1MBkDm6U08A9j9nVRxw6RRT9Zdbrb6f5hsDcplt4WFgtXxNTa3puNv2gkMhNn4G/f7o7eRv6MFOg6onDbuRNSlKnLucDWdeXca5fpwtyKOE6meHTurpmIGWDHEcSZbYnLIhRoPkXXiQFj/0fCmkRhAsKgxz3TPNsDO1/Yq3idIzNTxcbtQbrZieRm2cQwXMjIsBk0QM6qZkMs= 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:(13230025)(4636009)(136003)(376002)(346002)(396003)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(6666004)(83380400001)(82740400003)(1191002)(81166007)(478600001)(54906003)(110136005)(82310400005)(36860700001)(8936002)(40480700001)(186003)(5660300002)(40460700003)(316002)(1076003)(26005)(36756003)(7336002)(7416002)(7276002)(7366002)(7406005)(426003)(8676002)(921005)(356005)(47076005)(336012)(70206006)(70586007)(41300700001)(86362001)(2616005)(4326008)(2906002)(41080700001)(84006005)(83996005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 17:40:10.3038 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82a898d3-01dc-46cf-1621-08db218e7f22 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: CO1NAM11FT074.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5338 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" During GQSPI driver probe set ctlr->multi-cs-cap for enabling multi CS capability of the controller. In parallel mode the controller can either split the data between both the flash or can send the same data to both the flashes, this is determined by the STRIPE bit. While sending commands to the flashes the GQSPI driver send the same command to both the flashes by resetting the STRIPE bit, but while writing/reading data to & from the flash the GQSPI driver splits the data evenly between both the flashes by setting the STRIPE bit. Signed-off-by: Amit Kumar Mahapatra --- drivers/spi/spi-zynqmp-gqspi.c | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index 3d2b92a88e8a..d795d17d2541 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -23,6 +23,7 @@ #include #include #include +#include =20 /* Generic QSPI register offsets */ #define GQSPI_CONFIG_OFST 0x00000100 @@ -192,6 +193,7 @@ struct qspi_platform_data { * @op_lock: Operational lock * @speed_hz: Current SPI bus clock speed in hz * @has_tapdelay: Used for tapdelay register available in qspi + * @is_parallel: Used for multi CS support */ struct zynqmp_qspi { struct spi_controller *ctlr; @@ -214,8 +216,33 @@ struct zynqmp_qspi { struct mutex op_lock; u32 speed_hz; bool has_tapdelay; + bool is_parallel; }; =20 +/** + * zynqmp_gqspi_update_stripe - For GQSPI controller data stripe capabilit= ies + * @op: Pointer to mem ops + * Return: Status of the data stripe + * + * Returns true if data stripe need to be enabled, else returns false + */ +bool zynqmp_gqspi_update_stripe(const struct spi_mem_op *op) +{ + if (op->cmd.opcode =3D=3D SPINOR_OP_BE_4K || + op->cmd.opcode =3D=3D SPINOR_OP_BE_32K || + op->cmd.opcode =3D=3D SPINOR_OP_CHIP_ERASE || + op->cmd.opcode =3D=3D SPINOR_OP_SE || + op->cmd.opcode =3D=3D SPINOR_OP_BE_32K_4B || + op->cmd.opcode =3D=3D SPINOR_OP_SE_4B || + op->cmd.opcode =3D=3D SPINOR_OP_BE_4K_4B || + op->cmd.opcode =3D=3D SPINOR_OP_WRSR || + op->cmd.opcode =3D=3D SPINOR_OP_BRWR || + (op->cmd.opcode =3D=3D SPINOR_OP_WRSR2 && !op->addr.nbytes)) + return false; + + return true; +} + /** * zynqmp_gqspi_read - For GQSPI controller read operation * @xqspi: Pointer to the zynqmp_qspi structure @@ -470,7 +497,14 @@ static void zynqmp_qspi_chipselect(struct spi_device *= qspi, bool is_high) =20 genfifoentry |=3D GQSPI_GENFIFO_MODE_SPI; =20 - if (qspi->cs_index_mask & GQSPI_SELECT_UPPER_CS) { + if ((qspi->cs_index_mask & GQSPI_SELECT_LOWER_CS) && + (qspi->cs_index_mask & GQSPI_SELECT_UPPER_CS)) { + zynqmp_gqspi_selectslave(xqspi, + GQSPI_SELECT_FLASH_CS_BOTH, + GQSPI_SELECT_FLASH_BUS_BOTH); + if (!xqspi->is_parallel) + xqspi->is_parallel =3D true; + } else if (qspi->cs_index_mask & GQSPI_SELECT_UPPER_CS) { zynqmp_gqspi_selectslave(xqspi, GQSPI_SELECT_FLASH_CS_UPPER, GQSPI_SELECT_FLASH_BUS_LOWER); @@ -1139,6 +1173,8 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, } =20 if (op->data.nbytes) { + if (xqspi->is_parallel && zynqmp_gqspi_update_stripe(op)) + genfifoentry |=3D GQSPI_GENFIFO_STRIPE; reinit_completion(&xqspi->data_completion); if (op->data.dir =3D=3D SPI_MEM_DATA_OUT) { xqspi->txbuf =3D (u8 *)op->data.buf.out; @@ -1334,6 +1370,7 @@ static int zynqmp_qspi_probe(struct platform_device *= pdev) ctlr->bits_per_word_mask =3D SPI_BPW_MASK(8); ctlr->dev.of_node =3D np; ctlr->auto_runtime_pm =3D true; + ctlr->multi_cs_cap =3D true; =20 ret =3D devm_spi_register_controller(&pdev->dev, ctlr); if (ret) { --=20 2.25.1