From nobody Thu Nov 14 06:44:14 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 1C6B5C61DA4 for ; Mon, 6 Mar 2023 17:23:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjCFRXX (ORCPT ); Mon, 6 Mar 2023 12:23:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbjCFRXQ (ORCPT ); Mon, 6 Mar 2023 12:23:16 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2086.outbound.protection.outlook.com [40.107.93.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF79F241FF; Mon, 6 Mar 2023 09:22:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EUxa3HuKo+9pPyaEiCVxVHxtkSQyVz3W2koirnphTsqfEej8CtkuAR7bson9xrow/qmCX+U+39H0VA7JsWkYskzIQHHx7E3GHRpPNB4NYkHUlE621yuoqCvJLf5tIOquJg7fzMG9cloGHSK7b2o5Sy3jvLvjrkW1QEPaxA/C6i8CcStniOhCxRLkCX6/BiTAYiU5dvH1INFMOoXdzbRDTR2rYWYRLV85L44lLe5bOP2ykMddD9TIADTrS306/HjJEW/BvoQg9C+u4DAygW+umnTlHPDJPAMpmuF/IwX5h7LMwnwhljrWpPNiTkgdDrtx5b63cbEbca8PtxxaC8S+qg== 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=YREE40HDO+gVeY8ivPI1whPer9dC+VgwIRxFR7usEVk=; b=AS2jelBLNuoGnLdo1Hb8uEGGnfV+E4ALlmKd2z67r9/iKN6PobqL/Ry+3JPJyZsUko5r277xA7UqS1dOKBcwHY7YNGGWMOYeBofJeDT82NJMQHGWrOXCHRUE8Qjy7GSpeX8V01Nvbsrvlwwkc02ZirzydyJNhRT+PyqMNV6lg7EInfGjYWTYgVZCXfSTPBFgJ5dVG2Nz3CJd3a3Ffbnt/dX9BqWUt7+WqS+HWo8rXz9MgnvQWIFaVITBZ1RZQM8RVFU271E2g6dCs2OjaQZkkvmfXVAH3BNwPM1uk8s6juaVlZMi9v0vFKCsDZSnEnToKGIDv/0b377OGVLNy71jzA== 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=YREE40HDO+gVeY8ivPI1whPer9dC+VgwIRxFR7usEVk=; b=pIVHfnZH1c5aZlT9MrJxYNT3fTXdDmA0VtJRMoaWt0OAc7veUmC7DPyMg3WtRe4FkIfes7aaepUs2LSuOcIwD0E26RdbXZRj3cLiMUf/4d9c1WYnl4qBHeig8xFLVfdLyXKn4ZsGA6fXWuEGX7cJ0CJ2rZLuH6xzbSEBsy7pIGA= Received: from DS7PR03CA0295.namprd03.prod.outlook.com (2603:10b6:5:3ad::30) by CH3PR12MB8210.namprd12.prod.outlook.com (2603:10b6:610:129::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:22:28 +0000 Received: from DM6NAM11FT111.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::b6) by DS7PR03CA0295.outlook.office365.com (2603:10b6:5:3ad::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:22:28 +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 DM6NAM11FT111.mail.protection.outlook.com (10.13.173.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:22:28 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 6 Mar 2023 11:22:26 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:21:59 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Dhruva Gole , Patrice Chotard Subject: [PATCH V5 01/15] spi: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Mon, 6 Mar 2023 22:50:55 +0530 Message-ID: <20230306172109.595464-2-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: DM6NAM11FT111:EE_|CH3PR12MB8210:EE_ X-MS-Office365-Filtering-Correlation-Id: ae413132-1a2c-4943-c727-08db1e675c7d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tUwDmsEu3u4jcrGGSL5qN3rwQYL7AJ7gpNrQKne6JVPWwp092CtZLPmR+GfpisaekXFP3HU0orrU1QIhIhC+BVYpiJETfzblAaUJ1wwPE9Wy7oHN2VSLdVGehUG3Ml4UspKprHN71y4EIONYOy++uKZMAeAadtO+7P2/kQyA2g/R9Ouwtbxt1J3UEJE04TD0suu2UHmHKml7YqpkfsjTreoDGKlkK6J0xD/pV6Ej1yBjwkM0VpOoOd0/t/xcz6LRf9HQli590r9l3wXwDNoQzQRwBNDAw0sJMCKJAw6LgftxmWv0Nzeed3bmprpyL85Hj8cFNkjAH3B/bki9PRIuzgQwlv6SZudV89t2iQM/XV0qNZZcoLxhCAiI2sxg2MmQUWK7+jzEyhWM27yKtP5kgfVGc7nGWipWDx5AgHJklT+yauyIOUNnPAZu4jiHvooMMUMf23szszl3H6T5lkix2V3lNp3n6PGOqImm1C72jv4bFuygeRznI1gyMKy8WvUYzIU0ATzMYJ5Qpd88BUXRVrRmEioceCUNgiZE1+wC5b4F3WYiIpu9JWlGRB0qp5f28KQCwJ+rCG/QV168m2j3wUDFDXgUrVwKhNZrdIS50cl2PaULpmFufnGlI6uLiPQaVedRVcLU9/VGaq4wT6/j3NZo97tsr/yY9uEVrr0gnYt4O88gevxPnpywXCIWor+BbkPE+eXAaqD7i7sEo6ouu6Y5x+uoF8Oo+dq3ZboAWBlHZ1gaoPLuaq0xCSN+xjZiB4FAH9LYlqpVk8FmUNLPgzvoxjob35eqcTLCq5dnB0BoU2tYh9etArcbdsmqKpZl49kl2w7R3M1HVGxJCE5fdvHTj5KtTcVWXYIVMb7RQlw= 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)(39860400002)(346002)(376002)(136003)(396003)(451199018)(46966006)(36840700001)(40470700004)(2906002)(921005)(356005)(36860700001)(81166007)(336012)(82740400003)(186003)(26005)(1076003)(66899018)(2616005)(316002)(6666004)(30864003)(40460700003)(82310400005)(70586007)(478600001)(70206006)(7276002)(8936002)(5660300002)(7336002)(7366002)(7406005)(7416002)(40480700001)(41300700001)(47076005)(426003)(66574015)(1191002)(110136005)(54906003)(86362001)(36756003)(4326008)(8676002)(83380400001)(83996005)(84006005)(2101003)(41080700001)(36900700001)(579004)(559001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:22:28.3706 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae413132-1a2c-4943-c727-08db1e675c7d 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: DM6NAM11FT111.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8210 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-100k.c | 2 +- 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 +++++----- 93 files changed, 334 insertions(+), 329 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 4a6ecaa0a9c9..41ef6cf5c585 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 4d554b948d71..8584045fc17b 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 873ff2cf72c9..b7a9ec550ba1 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 fab9d223e24a..ca05c42ae4a5 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 795e88dbef1b..6c2001cfa3d1 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 5c5678f065f3..7b17604a7760 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 e008761298da..da713cdfe087 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 80c3e38f5c1b..1ff28784cfbb 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 e28521922330..a3d8f6108477 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 cd0a6478f5e7..d1aeae29fab9 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 3686d78c44a6..787625ce700c 100644 --- a/drivers/spi/spi-bcm63xx.c +++ b/drivers/spi/spi-bcm63xx.c @@ -292,7 +292,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 3f9e6131ad86..2306bf879784 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 64b6a460d739..fb6d85fd2e86 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 6a7f7df1e776..4ec778de5baf 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 263ce9047327..18e4fd86b2f2 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 d112c2cac042..55c9abcb8e3b 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 0a1fb2bc9e54..5e60e3d5822e 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 26c40ea6dd12..d511da766ce8 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 e419642eb10e..0f9a97ee2e77 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 f7066bef7b06..b593055e3d6d 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 34488de55587..fe69ec8c9d68 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 85cc71ba624a..4f16d4676650 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 93152144fd2e..08fa6e38f4eb 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 e1b2e0b65779..a99bdab00ed2 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 257046f843ff..1575e78f8b09 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 aae26f62ea87..6b191cefb0d4 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 d47f2623a60f..0d45cf8a2e72 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 aeaa1da88f39..1a90fcfe6015 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 03630359ce70..dc72f4c5b816 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -127,13 +127,13 @@ 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)) { if (mps->cs_control) /* boardfile override */ mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 1 : 0); else /* gpiolib will deal with the inversion */ - gpiod_set_value(spi->cs_gpiod, 1); + gpiod_set_value(spi_get_csgpiod(spi, 0), 1); } } =20 @@ -141,13 +141,13 @@ static void mpc512x_psc_spi_deactivate_cs(struct spi_= device *spi) { struct mpc512x_psc_spi *mps =3D spi_master_get_devdata(spi->master); =20 - if (spi->cs_gpiod) { + if (spi_get_csgpiod(spi, 0)) { if (mps->cs_control) /* boardfile override */ mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 0 : 1); else /* 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 7b64e64c65cf..c474a767fc48 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 a3dba17390eb..52bd2c49c34e 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 55178579f3c6..98076aa4b1c7 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 559d3a5b4062..86e3978883fe 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 1c1991a26c15..e9baf93aef7e 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-100k.c b/drivers/spi/spi-omap-100k.c index 061f7394e5b9..ec05778216a1 100644 --- a/drivers/spi/spi-omap-100k.c +++ b/drivers/spi/spi-omap-100k.c @@ -268,7 +268,7 @@ static int omap1_spi100k_setup(struct spi_device *spi) cs =3D devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL); if (!cs) return -ENOMEM; - cs->base =3D spi100k->base + spi->chip_select * 0x14; + cs->base =3D spi100k->base + spi_get_chipselect(spi, 0) * 0x14; spi->controller_state =3D cs; } =20 diff --git a/drivers/spi/spi-omap-uwire.c b/drivers/spi/spi-omap-uwire.c index 29198e6815b2..7f9fe9147e61 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 6ba9b0d7710b..5e404da112a2 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 565cd4c48d7b..13e60976692c 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 86ad17597f5f..ed02d17897d1 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 7e5c09a7d489..387673694f91 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 32cc82a89ec1..abcdc1eb1a40 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 c334dfec4117..33c056fd5f4b 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 9f97d18a05c1..3c79a5d85ac2 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 bd87d3c92dd3..246e81453ec3 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 79242dc5272d..adc5638eff4b 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 411b1307b7fd..4d4b98f8eb80 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 71d324ec9a70..f6682bfe484c 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 9bca3d076f05..87cb975ce9dc 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 8f30531e1418..3003dd7c72c8 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 e29e85cee88a..7840ef940ff8 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 333b22dfd8db..11717cae5121 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 843be803696b..57aaae39e5f8 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 9131660c1afb..b9e61372dcfb 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 6000d0761206..1e3b1922059e 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 23ad052528db..46e7c446503a 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 dc188f9202c9..733dc8c52b08 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 d9be80e3e1bc..e334183241d7 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 220ee08c4a06..f67d0aafa744 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 148043d0c2b8..0afba7dbd93a 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 0b9bc3b7f53a..80c3bd9f8bc1 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 cbb60198a7f0..11cfe84714e7 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 1411548f4255..a2422c1636f4 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 78f31b61a2aa..debb53ef19a0 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 95ff15665d44..319cdd5a0bdc 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:44:14 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 B0CBFC6FD1D for ; Mon, 6 Mar 2023 17:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229624AbjCFRYR (ORCPT ); Mon, 6 Mar 2023 12:24:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbjCFRYN (ORCPT ); Mon, 6 Mar 2023 12:24:13 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2067.outbound.protection.outlook.com [40.107.92.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB55D664E2; Mon, 6 Mar 2023 09:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JdE4+wCCcWkCYX+TDwu2FB1CdzzqtYszvIjavZSHNxw3i1NqzqAkJCPf8NEAWiAdz/u9g85jjfWJ1sY5AjqdpILeonKkC3viY2scCMwTgSF/mXt+5kc0bF/UgWqh+nmT6yGThWqyHfeddHFjoFejYJxYv99bdoqWtJqPd5Gc59jZ4yLpxyJSRVSPvtztJbRCbe7OvapY+MIE8BKGemhkZ5dlOo+eKsYqO3ShhiXSbOOH3OFua2xO03mZTBxzn0xTv+Lu9620jtFKeKRSULbkAy4gygAA+9jFt4p5SkyS6nVxBoKoliRRI6XbEmAb8SlVWbjLpGjwFRrgkByLcBHbaQ== 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=JdrkNOVN6eoC1Yo3IPRQEfXByN0pZoIOt54GZowv0CA=; b=WDCR6fD7yh+Mf0QDqncAjtVYLP0RYcQFW1XoMc/1hMqZEEFz3IS3O8elNIcobZHaPPNyf2Ya2imh22DGgip8xOr3C6U2p62ToWytVk4pEfWWtFaXA+WH9KvhgiQtnWSNdrc2ZRbWDR/5SHCmXMVLYLw7wsPCEIflERh3HMpxz+3krCmCOnepiZc407W3AssRdjbUOFzILfmIf40K9729DSSPwnqUDhfkM86U8cxrJGK70Gx2hoFj+9JqprqS7xfrGHFw+H389yfv4vjNjcWuQvn9jd1Td4LHKBXktUBvTXyByy9RNoLfLFR0kD6VjkI4Lx4UxTzCuVahMs1DxQs8cQ== 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=JdrkNOVN6eoC1Yo3IPRQEfXByN0pZoIOt54GZowv0CA=; b=RAfFNNSnAZ98j9nGTHQIAwVOLUeZA1eCQC8twDgmVKMabMtz1aSa4R8xw4wAqnbYNtmkcuFRS35AbAvtE+04gO8VNAkCo2AIy2B1Idtwa7DzTnI49T+Fo2y/rujyAIOdX4/NAvJlEnK8M+n3Vg+db/klK4L3AtQDqUopCRqvOfs= Received: from DS7PR07CA0010.namprd07.prod.outlook.com (2603:10b6:5:3af::29) by SN7PR12MB7810.namprd12.prod.outlook.com (2603:10b6:806:34c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:22:56 +0000 Received: from DM6NAM11FT093.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::d2) by DS7PR07CA0010.outlook.office365.com (2603:10b6:5:3af::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:22:55 +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 DM6NAM11FT093.mail.protection.outlook.com (10.13.172.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:22:55 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 11:22:54 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:22:27 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 02/15] net: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Mon, 6 Mar 2023 22:50:56 +0530 Message-ID: <20230306172109.595464-3-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: DM6NAM11FT093:EE_|SN7PR12MB7810:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bf985b3-e298-4ce6-bb72-08db1e676cc0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PEr3s0+6pYBxQKl0wMUTMZWduZIRbFC5P/QyrPGDO+fAnIsP3h7D07IB1a8u4B+kpW29hvckzV5NYhgpPlI8//vz/ecmfSN/6oPwkbCplVNz+F+3GUuGqJkjVlt5QbFvlK3fciXSeQsaolQJBUIezPNyNM2KkbRnVMdIihgA1eD4RcK0SdTaoij7k7Yf3IkjaTGqFZomKBE0XzBuPmfRooEBvYrSzRxpjXLNd+Bwq1XgxAGUXg75IDgBmIlOqc+c8Mmj77rpwiatMQYzRJfFNl8JK7/jh1IWX6LBM0qKAdGjAkN30j74EkyxEIgDudU1Hcnl9QdY1ydlYrVO3R/XtqSbNpXdHCCMQxTXXyToWXQlRVg+9mO7GuCPbMpiYz5clj2f2qVKi3f+P5y8sI9EzKBQcXlCwhJuUdpugLrc0QoMW+/ynsZva9IUnr9gQoabKBEofMm96CSWwiPpNa4cQc7NutajGUzK55761L0lJlegJn+bHw5/DW+KMyl4NkG9LSqjCcDUWCqLRuWkmS5rf13BQECyka79Evf4Zd5Ob5GfUmR6dsytH8tZIU9lt2fQLdLmdn5cNs97FcarogR6RXTP6xGGCvjMW4hazy0aC7BKu6DHmOvCErHSMi24/Ma8pHkEBfrqzRL5MCsluPr/cEGik2tBKwPKoC1W5fgZxBy0Sccn3go3TGx6Avc5Ae7qfVKZA5Ea4O3odEusbmhACCm5SGu4Y/vGHexGWOB9J7MPNzBRN0z3sTkJ8B5U6y/b+Ai1zT1XZhIRr0HJrwTzn1n1Gk2okvY2Zs8h/KSjDgd8DzZS9U0Jo4mp8CN0ATHqGiOAlYMgqGaMhbE0hait/TLZ/f/RSeH3uKoY8hE+5vg= 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)(396003)(39860400002)(376002)(346002)(451199018)(36840700001)(46966006)(40470700004)(1076003)(36860700001)(6666004)(36756003)(47076005)(426003)(82310400005)(83380400001)(921005)(356005)(40460700003)(86362001)(1191002)(81166007)(40480700001)(82740400003)(186003)(336012)(26005)(2616005)(41300700001)(70206006)(70586007)(8676002)(4326008)(2906002)(7276002)(7336002)(7366002)(5660300002)(7416002)(7406005)(8936002)(478600001)(316002)(54906003)(110136005)(41080700001)(84006005)(83996005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:22:55.6529 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6bf985b3-e298-4ce6-bb72-08db1e676cc0 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: DM6NAM11FT093.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7810 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 0805f249fff2..aee7a98725ba 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:44:14 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 C9A79C6FD1F for ; Mon, 6 Mar 2023 17:29:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbjCFR3p (ORCPT ); Mon, 6 Mar 2023 12:29:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbjCFR3j (ORCPT ); Mon, 6 Mar 2023 12:29:39 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20614.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::614]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 061A9305DA; Mon, 6 Mar 2023 09:29:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N6YGpgHBDHvRycEB6+KUIAsGfroKCfjWvzpvaPavdr7jA55qpmht8GkPuMeFMVSXyRqpk5ZChnyQzAoH/gHp+0ZLkiTfeBZFqpQK1wq6Pw38v+w5gMALkg1M8DdoWbYFiAIYR+sFB6UoFyZeEiSwgDweIecMyipcJZGZu+6Wah171nuEoUcFFhK71LUf3TYGR/s5PsSI4jA9Azc8/rtvQhsioxR4DhXefDE7QY3CkPfPpV4UqUDbZPaKy7Ds2f1cBXzl3yDjCWbNaHshrZ5kw+KP61IaXaBDmDEYZc9xBfloohE2XdDFE1RejP15bbsbqp0rTxfIMx9sSAsy1ZgGnA== 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=EYbdS+z+4q5kbPWSvct1DGTpyEbAHudrOCPMI6RV8pasSVlKUTPXSCLPwLAyNrkXIqLcmBPTwplq7P6gnTCSnKhJfpRi4R/xx+A2HUthlN4MpaA/lwX06feIQvtZfr9NuKY+iy5aOSX8cejJ9/SgIQzjHw3lBsnXmbshuxoOilIGHTqJV3APxS+6TLuuB3pfzTtlIBb7zPm32cqbJ0RwAFxuxSnc+c1XJ1cbKmh+48Jv3PlGvMb3dbAmTJombKoYi4pCExaFnab9wWtDWiQwS9dZOCcaqYr1N90Aqdsg2TWHsJdShTuucmDMvZTHgxFyXBS/N0gKIdVdFB/cAQ5CVg== 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=PGTDv9j62eqAAUbZYCqOwhh6o6pzCwATcSrO/Vzqvog=; b=gyb72RDfK3PZLmQj8NAkUr5dmIQ4w0H43FbOrw4j19dLKuQD3KAl6yb9cmQE1MmVvyS+yZ4TpY49BrobgzKAfmDxolBjwppp8cuRQDen2hC3D7LABqgaUr4elf5qV0nsblJWEzxzmTeeNFmjKZqdCSNdP0BL+VQXP0y25OKahc8= Received: from DM6PR13CA0002.namprd13.prod.outlook.com (2603:10b6:5:bc::15) by SN7PR12MB6981.namprd12.prod.outlook.com (2603:10b6:806:263::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:23:24 +0000 Received: from DM6NAM11FT101.eop-nam11.prod.protection.outlook.com (2603:10b6:5:bc:cafe::1a) by DM6PR13CA0002.outlook.office365.com (2603:10b6:5:bc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:23:24 +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 DM6NAM11FT101.mail.protection.outlook.com (10.13.172.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:23:23 +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; Mon, 6 Mar 2023 11:23:22 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 09:23:22 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:22:55 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH V5 03/15] iio: imu: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Mon, 6 Mar 2023 22:50:57 +0530 Message-ID: <20230306172109.595464-4-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: DM6NAM11FT101:EE_|SN7PR12MB6981:EE_ X-MS-Office365-Filtering-Correlation-Id: 954b412e-aeb1-4463-5242-08db1e677d99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hAxI5cOLO6UatMmskGIBY8ep3ogPcooC+TYmckB7fs7obYaL93mX+40jRxComK0TS9MmaBzxrEgGiZEjb+aEX/Qyz5NrQ3zloPXEzn5uqX97nqxV/VAY5fV8jKjH2ync2vr1uZ4jR7v8bNX09/OAoF9n46w2RCkltEsHjS2201q1cpUKVMOhjV/dQ1fS3fYc7Ln55hk18+Rhla2AEry3V02HoCNXonv493P0teU95c+O8wvd7e9IOO3h2GLG113c2Ek7xHCcvktIIJUdx8GA0VqHHDvOXcgfBG+4R832k18Kj5tU5sIi8730ZY8lsWpMjqpKW0phb7gGQiMOufdl31Ycydwcdr3xX7eKyRJOZi5rm/NBsAx4cTC+RxEm9Npd/tnVDdQKXupiUvhI3TTnnWhEytMQBty5A7fm3L346cCoEhGr/qTp0N+Uj74d5Rg+fi4TSdxBpRfKSU8iWMz5/I+q17B+8zAAncCHlJHiWhG3PdXr61B+cDRjMrjsChJIuKRZ3LNF49yH+ZFWs448Rgx7jn38R+/VTSLeMfYdrHaVyvwOZ9n++ANBlYml0T/ezY8t7wX2Ecx+xSRcvhK60gZ8O7We+QuMAE01KTzlUEx7Ob+bEOmkO6tiajtB89LXHIOwEjogrCWiaGNDU6f8G6ftX0LQMqK6jP10aVgbBO/N+s4ZILrOyJ1KGjgXF2Ii+EaQAl85IUtMg9M/ip/h1QJYWB4ysdTQj3RB5pRF+qDxrU5vvw65M/VSGQwBT59hsI1D+8/UMTD5y5YvSCo55mki3HTRkRDtLE5M/Dk0aZkuWTETaqBYzGsQi8GVi6wTl6xPlMef0G2WKZCDjPGoI9AM5sxlJ1RKnIAYE06Re2g= 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)(346002)(396003)(136003)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(8936002)(7366002)(7276002)(7336002)(5660300002)(7416002)(7406005)(70586007)(70206006)(2906002)(8676002)(4326008)(54906003)(110136005)(316002)(478600001)(36756003)(426003)(47076005)(36860700001)(1076003)(26005)(2616005)(41300700001)(40480700001)(81166007)(1191002)(82740400003)(83380400001)(82310400005)(921005)(356005)(86362001)(40460700003)(186003)(336012)(84006005)(83996005)(36900700001)(41080700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:23:23.9159 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 954b412e-aeb1-4463-5242-08db1e677d99 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: DM6NAM11FT101.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6981 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:44:14 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 CE4D5C6FD19 for ; Mon, 6 Mar 2023 17:24:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230105AbjCFRYn (ORCPT ); Mon, 6 Mar 2023 12:24:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbjCFRYc (ORCPT ); Mon, 6 Mar 2023 12:24:32 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20628.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::628]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7017B38003; Mon, 6 Mar 2023 09:24:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B8bA6ZosL7Qrsm3FBjRIYYrOWzfMKJbHJupOJu/7XypxViuGZedICGfB80cWBrLvF9KlY06WADhULSTqQiGsz3qxrwbLf3Wewt97yeUQO22NAxD0SR45Jz5fOfoOi7WxCfi5CllZR3FjBz7rw48xSUxrFoeZ1I3387QCM5dkjdVsOy+9Iw/kcta5zMWYMbZvDg/4df5mAwZNiTYF0Ad+7Khuyij199Bve9IZym1NvFP4t18YB8IBZKzDQvfgJQ5kfHn0iThhyUUPz87pRuuYbOSA1SUFUyu3Q5A47Wi6VpiUTMCIHQebq4zG+jW48jZSfWIMMrZkBTv/7LDf7nAgFQ== 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=H/Yet+5rsiDfnRUIoBGZ5uihYT2ozvs6P0wK1Jad2Yk=; b=COePP2rSJvZEAnA7SUpAtk2qNBBYQynRdj1iy6C0D66bRi5qhs5TIvL353ML3hN0noV8aA4lhAQoBe9zzlmy3+GFeX+NmnmZ9S3Q+VTvo6ECyyKxL463Or+7Xc25Otkg13AHhUaElt462QqjinZpdq02h42JH/czX+t3Tq4CcmDeZoMEcgcKrE4wcGa7XUzvEQY9vXwQol4ihAIFWvsWRh+U09epHMp0oswlBRxZ1YgG53ONa1O66GeWt0YQWP1CVbLS/9moEHakEZs0cKcOmDNSHlGqjq/nLqEUKnW95yPydFR+HcRrb76ML/j0fqONVUjpBATK7PjgTe8GdqsSHw== 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=H/Yet+5rsiDfnRUIoBGZ5uihYT2ozvs6P0wK1Jad2Yk=; b=NMVbCvT2ImjI6/nvHTOPJLmpkMxwRxa3ZjA2EIszdNtShgbkab1CnKZBs8nIH7s7vAQFO4eCGi5hCpT1GcE4ftzscsSBXHabUpTh2lVO1T7KQUsy6/PpWGJs1co5Mz9LpVjjfT0gsvrlnPerU/hu3Z104jlh06p+ibPa5Fep2QY= Received: from DM6PR17CA0013.namprd17.prod.outlook.com (2603:10b6:5:1b3::26) by IA1PR12MB6113.namprd12.prod.outlook.com (2603:10b6:208:3eb::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.23; Mon, 6 Mar 2023 17:23:51 +0000 Received: from DM6NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b3:cafe::a1) by DM6PR17CA0013.outlook.office365.com (2603:10b6:5:1b3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:23:50 +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 DM6NAM11FT052.mail.protection.outlook.com (10.13.172.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:23:50 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 11:23:49 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:23:22 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 04/15] mtd: devices: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Mon, 6 Mar 2023 22:50:58 +0530 Message-ID: <20230306172109.595464-5-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: DM6NAM11FT052:EE_|IA1PR12MB6113:EE_ X-MS-Office365-Filtering-Correlation-Id: 89d477de-1e4f-4c1b-304e-08db1e678d96 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GNUlIYo5lzyrXRmU+5KFUSFPwz0KD4QSfbFfN1tjKkxbFuUOMIXEU28XmWMdMJGHWTajT5OmqLu2k0R8iVQzUfr+eQuLC8fHiYT5Os5aLiaRCBBKOuGpwpXPoalWiogSxVv8qPGLAVnGhJ4ZNAdTBcDP8Isq3NwGBSE0yDKDLGXjPjV//0ulsj9dUkvcEMncrNch87xZw9jeNyqOumupRzeEJnxGwIlgBcEsx9vzDVha57QfEF09JOjXLq+KyQytRN40GBh0nnLv+kqHJ/RnKx3MMzBchwvXiclkLLkknbt/H4zeqlSE2S9uw1kiZNn2hrrsmWU9+IoOdHsri44UZycXmMxCx/MKGuCTteKfN158ooWJ/HJmStuymZamPTSB9XStX7hff8IvWPUY1csurUFE82OQtP7mIX1j5IEIz6S1UWAOIgExhbfhELGop3uoIeZrL6XJ42BK8Zb26f/8FofW9T8MsU3tfMKN/OvVDJNirYm7+emDkLp3OMH9oIcofqWexkTdvuDVEpOD9xK5Aiz/TCAu4+v0HKY8q4W4X0Py+ydPhPN1H4hyGGdRDf37z8IgHvNSkEpF8JbzwWbInMNfrPckB4IEo+zdC5j8zE41DVDtwzuZ17/rdl2NhG8/vSsyg3Uk+S1WibMwS0IpUVSIiwykdKc10Vav3/Tgg51S9PLk1gCXflOsZkKUVte0mKU9x75Jf62VM8x93kFYjw+KvHCL3HF+ohpxxwJ79CEnO7LFRKMdPtaFktzUMET1XGSHxSf/6gHt2RoM5aUjqZbzlESOorvc/0ao+UgB8ld3r+rGbIADJhTqjWIhX+8Zqebs55B+Mdi1O96ZzcdmbjaMYBO5We9QONssJV9/0ro= 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)(346002)(376002)(396003)(136003)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(8936002)(7276002)(7416002)(7406005)(7336002)(7366002)(5660300002)(70206006)(70586007)(41300700001)(2906002)(4326008)(8676002)(54906003)(110136005)(316002)(478600001)(82310400005)(36860700001)(36756003)(426003)(47076005)(6666004)(26005)(1076003)(336012)(2616005)(40480700001)(82740400003)(86362001)(83380400001)(356005)(1191002)(40460700003)(186003)(921005)(81166007)(41080700001)(2101003)(84006005)(83996005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:23:50.7389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89d477de-1e4f-4c1b-304e-08db1e678d96 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: DM6NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6113 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 25bad4318305..34d7a0c4807b 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c @@ -646,7 +646,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:44:14 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 BF05BC6FD1B for ; Mon, 6 Mar 2023 17:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230433AbjCFRa3 (ORCPT ); Mon, 6 Mar 2023 12:30:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230510AbjCFRaJ (ORCPT ); Mon, 6 Mar 2023 12:30:09 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20604.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::604]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7013369CE0; Mon, 6 Mar 2023 09:29:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XgrGUvyhJbFcj5MzUD/66qXHmhtJhcU8FmT41WKUTGTJdy0pgrmSANNN6FwxGaEniwzg6LRvMBdavYfM6w/iy9WsYN8dsH9AI9MD4RxlYlHEV2UwEKjwwwVXG/5yB4/h6ymg9dAr12gaS1hCl4vxRNkO6CtPjrHK55+8glzZ+QQV08XoqtS+8u5V7i5Odq+gY/vTVbjTZdj2coyyaxrsOE/nDWAdNU83Z6KIvHnhX0PgKzPXkAu1zmr2mjZUzy13D0Fe3ypwvEhSfd+rNCHfO4r/U+Dls6ZBnr0vEwBWSWTLZgH4sFXZtCk+4xNo4oSEy3BU3rQ50MUO9rPUGMl29w== 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=MdudOHzdJ8vp9nBrJJCRoVVaTeL849iAzAyxRmMLb+q/X5rlJYEJj1f9MvaDMj8yRSfUpVn4Ri9Lm+QImIrC4jjEQRpPoPKkB1vq/j9U0JMtJazCks8s6zdgJRn+aIocsp8KT28Ez/Q1QAfCP0KDp5KgiYWjgnGlM6bxsDERGkTB4ttRSBcvH4hhOP6rIib09JRYN5Jj6dtMymtXOuHw/mSlC1h6N3JDyvGdlkdXZGAKF7PgU8AMBLe9DupdPZXg9aDS/tAi3H3LxdysM8sJcgmv7eZYvxPHIhqM8KeszhfrhDsP/mb2T2T34MDc7ZMGtnNAnpZBeK4ce907qtg3fg== 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=RFaekxbvmDB+9KP4yuK13kMPh2S1/2y5uzJ34uumuc2UdKAJlozc/GoKDQjszWM1YH3LZWG3beBVwlfCItQnKK7uSGGN2goj0cDXapxowwyDI8X2rNSFL8WoKs8nSFs9kPBNh5imqgnZMnOojbAKBB6vcnjqa6bBTgK5G6MNaJY= Received: from DM6PR12CA0011.namprd12.prod.outlook.com (2603:10b6:5:1c0::24) by PH7PR12MB6881.namprd12.prod.outlook.com (2603:10b6:510:1b7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:24:19 +0000 Received: from DM6NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1c0:cafe::c) by DM6PR12CA0011.outlook.office365.com (2603:10b6:5:1c0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:24:18 +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 DM6NAM11FT047.mail.protection.outlook.com (10.13.172.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.21 via Frontend Transport; Mon, 6 Mar 2023 17:24:18 +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; Mon, 6 Mar 2023 11:24:18 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 11:24:17 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:23:50 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , "Greg Kroah-Hartman" Subject: [PATCH V5 05/15] staging: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Mon, 6 Mar 2023 22:50:59 +0530 Message-ID: <20230306172109.595464-6-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: DM6NAM11FT047:EE_|PH7PR12MB6881:EE_ X-MS-Office365-Filtering-Correlation-Id: dfa8d561-d899-415d-e0da-08db1e679e4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fw6WCUPPqJQqlCLuiUrp7L90PuzUF61/koSWI6LXiBIFKVkTA3cT8Z2iZcajGYZN7+bGA0zc31vRDMAD8Euo9gB2ZxCe3MFFA8T7n20BLCjQXRU1IflYiDXwuCIneLLjlcEzAtdN113AGbAcYDPHBpZuy3VjZ9EioY21FaFOcn7S/RHd9qDN+Es7qoftg0rhjID8m59mgadSqzXxpTyyEEpKd3fwu5DEnQOV5BoDAsx01EvYlZ2oPpHLqeATqigIHlJhPFOKLWHPfNh53N3e5WyiZO6gaQ5XQTlCOYQXZVoGllpBe+GdJoKdfjaxmPi2T7BbZ0Zo3foyS2Lh58C+0OL6WAt0l5NHG674GFpbBcrRbXMCqfyUgrtmrUgCfJMj4ZjV9OHkryMoQBEy/QiPrpTjNBpBieWoRTsX1oHYfi6MQLUNqgsRKLtmpISOsLA4FujhpP4GKja4CgRT4DmDU/cPLTCbOsL1tzC0ZkyjVSyayH7+Ceje6e69IHoJcNLWt+V4lc3UaRRmI+jBCW8nFkaJ3x1HK0VkNz7Q+0XmOMe/TickbLWRWU/k5ceeukOCk3N/LdPv6nC0FILokCo5+10zkdVFEWVjJXm3bKea0g5bf1zsk9rqT8Rv03InmFlZxep91wLjFGEUox+T5HOLgM+dERi7S0kdiVSz/KlvlbX+8On5ub/7FBTehJr0efE5m9AJwhd2k2y8l7sTxalr8rX/IGDzHZD5vdlZRypAN6lWceWMgTMD0KWwcdOtwBnguMR/jWlrFNaxq/3MuMUtl8bimBf9MB2rL+01HGVJpyOiPFilT8AoGiMSemU5MD+gEMSii3qqP6oxeJnekL+MDx2cSnk0YzOAd5FGP3Ar+b4= 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)(346002)(39860400002)(136003)(396003)(451199018)(40470700004)(46966006)(36840700001)(40460700003)(70206006)(8676002)(54906003)(83380400001)(4326008)(70586007)(110136005)(316002)(8936002)(5660300002)(36860700001)(41300700001)(26005)(1076003)(2616005)(426003)(478600001)(47076005)(186003)(336012)(40480700001)(36756003)(82310400005)(1191002)(7406005)(82740400003)(2906002)(81166007)(7366002)(7336002)(7276002)(356005)(921005)(86362001)(7416002)(36900700001)(41080700001)(84006005)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:24:18.7419 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dfa8d561-d899-415d-e0da-08db1e679e4b 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: DM6NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6881 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:44:14 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 78F28C6FD1C for ; Mon, 6 Mar 2023 17:26:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229568AbjCFR0T (ORCPT ); Mon, 6 Mar 2023 12:26:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbjCFR0Q (ORCPT ); Mon, 6 Mar 2023 12:26:16 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2062f.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eb2::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22FB967836; Mon, 6 Mar 2023 09:25:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NbkIQmHMlenYVDylNHa9tky1MAScGo8S4D9ijGji6DghHAn+OpUBfeoA2vc1oeUEu8KdCxpqnlSg5H5E411AfyMa4Djb9HncGMrt7/odOlFemHUl5hHw3OCVoB1dPXBcMc12KasZ/WlF8kmEwmbkvguTD3CaRAyRQSFYy9ZKa86MXyYJL5mIyXxwNcNeiJ/xtm/3JnonClIefj+rz92BYbDVB5i0cv2IUlaLq2DwX5cy5MtyHKmqr25gI16M1XYtINuWZLls255CI8Qjv/L1pF3ocdZKESMf63GS+DkwCa37hQp6a3X7C8YpSN59IwW4102+EI5scEtGjzHzHF2iug== 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=naPIQEFxrNPys9YdoIfl+H7zsQYlL7TUOZs/XXcgRrksOdKqOXiKyJqwSOCDxv1/TLz/sS/mCLvD6njgl302wWeJTCbjJCnNnwHK8biBSPivzTKzwGl0YQE9pda/S+HR0qzm8ahW+5vdBCRgf9lm7do1ViFDm9qpNkHBCicH8pGMkvg5Oj9x7xIhsyo9uFMI7UGQ7zQqE8n6RCbVi20rp7yXnJ3bEqGLiy4JkQhBVWYr2R+ait41g1zI85TpEiovzkhtPNMu0nM56EHBcJmvc4ToyMEuW9vZlC9Rdw2XgEfmnahfJ2ZigF4NkufgfuBOZgXfWgU1PNTi9JU90ROmOg== 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=nEGTy0kPmXAoPmOXA6Rc8k8XsTJeV1NoQcbyyWC6BfEG1ix3R4dqNtoKDyNm0wVuocmc+xF0HGCIuaF+UUSutHL4o5D/hcw0B1YoSBiaoEmvl0AcvDfQa/YMCtkswzV4kMEAfwKJ5HAyCWM/ksx2/P/GF3seTJzRj1ZYnHn4v7E= Received: from DS7PR03CA0059.namprd03.prod.outlook.com (2603:10b6:5:3b5::34) by BY5PR12MB4147.namprd12.prod.outlook.com (2603:10b6:a03:205::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:25:08 +0000 Received: from DM6NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b5:cafe::d5) by DS7PR03CA0059.outlook.office365.com (2603:10b6:5:3b5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:25:08 +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 DM6NAM11FT006.mail.protection.outlook.com (10.13.173.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:25:08 +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; Mon, 6 Mar 2023 11:25:05 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 09:24:45 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:24:17 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 06/15] platform/x86: serial-multi-instantiate: Replace all spi->chip_select and spi->cs_gpiod references with function call Date: Mon, 6 Mar 2023 22:51:00 +0530 Message-ID: <20230306172109.595464-7-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: DM6NAM11FT006:EE_|BY5PR12MB4147:EE_ X-MS-Office365-Filtering-Correlation-Id: 1422a481-6afc-4b20-fdb4-08db1e67bbf1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AzzSJUjobRyMuwK7pspBvT8itA3MpfoIsUnk6QlJ+jW6NaqPAv9xdxXpXr0Foe4qaWvX4J6+01u1XrVYGultnpZNyYePaDI2KxaedeepviAeTRUGX2rshWu68hdS7d7/u/morW4/WVgFBMwB84eyNqKznARBpSA2SACs99Kr9tsHnG/TFmUTpFFZ7vV6VGYlthkKFLd88He+gFA1O8cQsmF91HqZVeE8oBVxeITAWxuItQ452sLqy+9uJX0jCa5gmFuB3rPoqPsZr5IcDjAANZ8EbvofKaTLXCbqXWjoWyR4X/3uJ0U/Gt/pFweaPCH30XfzG6jY7TNfwetiQFHoZlieO7eH0G5F7qqT0AEAgsT7kqWe88sEROr+qzcR9wr7NZs1Is11qSRuU1mJErtwp46QQygpz0DM5qeoRkzbjXgS7I29m/nYu9nAV0ilSJhXUlGB1b75t4XSD9+3WhnCNxuQq6wWaAtivqI6VuxM8MkquyZy0o1K93+ux7kqkRpUAPode0ryFB0bzx9M44ZzruKKHSDa1O3rbYIVQqlOQC4t7F2fBd6RF8tE4+zx9qjkyzNxkdnTEcllXAhpLzWXfuESzsVcZ+IXzrFumwoQIy0djF1abnlev6tmQXDwbVpg0PuSHpwIMdD7u4YnNDQhc7xSbPd6eElzlwQhO6GmZ36W7DQ58Dzj4cJjVcGwvU5364yZYDbiDd/ejwN2b7wqVWGXyB9yeGKH+9BZdn/vPvi/KrYJugYRQ1vbqkez6T1F4JZccnCWFAZVnSMP9GQjvdQ5a1TVgRz5jQ21xBgrXxPvzAh2kjO+ScQ0GyQaX6B0ygIB1GKPNIp8buJiWN63rPHBZpZiHBzQxvqEj7NBHJg= 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)(39860400002)(396003)(376002)(346002)(136003)(451199018)(36840700001)(46966006)(40470700004)(36860700001)(921005)(86362001)(82740400003)(81166007)(356005)(5660300002)(36756003)(7416002)(7276002)(7336002)(7366002)(2906002)(7406005)(4326008)(70586007)(70206006)(40480700001)(8676002)(8936002)(41300700001)(1191002)(82310400005)(2616005)(336012)(26005)(40460700003)(186003)(83380400001)(47076005)(426003)(54906003)(110136005)(478600001)(316002)(1076003)(6666004)(41080700001)(2101003)(36900700001)(83996005)(84006005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:25:08.3283 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1422a481-6afc-4b20-fdb4-08db1e67bbf1 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: DM6NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4147 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:44:14 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 AE8D8C6FD20 for ; Mon, 6 Mar 2023 17:26:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbjCFR0h (ORCPT ); Mon, 6 Mar 2023 12:26:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbjCFR0c (ORCPT ); Mon, 6 Mar 2023 12:26:32 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::61e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 980D967028; Mon, 6 Mar 2023 09:25:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qii9Fo9sIj8ztSq74xIx9izh4U+72RNm/6VAWIX12KvbAxSViwJ8krZV6dGlF/I7o3BEapKx9LTIAbulbssCkiGj9q1czTbRNRvfi3jBgG7LKnLveRuTu4tlXPcxiD3LvGMdJ1TepAnq7T3cEUonSy6trIGKQc8K5GI99xamuXg2At909ErpPr38/lS2mwdbM91EfhrZIdtelwr9gLH3pjLWIDCwkZngxPhaoq0bac7PpXGC0SdNsKZXvYLYKUR2rCGgV5RydURUE04dkGqdtUeUIpaF4iCyogm1vAlXCxfebGV9cJ6XhsMcKucGAL96Z2KtpEgL6L4V8uvpyrqKPA== 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=AhWlh/2sF0MBbf+m2pxpmV9EMG1hYfOgWeaiwcMhyip+VIbBi+9laS8gxw87mBX5wmljy62DCmuLcQvTPinUur+ua1x6D+ZowVZnlgfCIL1xLLMg+1cas/8xlE1HHRE2avVu1ceSAdjD5/+1NgIZtPvTCwIWUerdASbN04idUWpjxCvhSNi0U0fN+IVpxnupjiW0znLp8DFvWrlJYx6yVrkaf89UKZMRp3aKAx0pTErWQ1rLyrhprYol0zZ3kswJ+F/FVh+9vBUIsx3fXcV/pNY1QA4c1XqApWUphjBS7lK9RtXWxPW/oA8Yoiv42uIzdXZ5mqt61B3f5T/fF26xIA== 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=06xXfuzrT+GMR4J/BagtpVJpPrEX8NAbiFuU8jYxc9Jt6TJUe01ZoVy9GG3n80F6Csmi4f9u296sOy9K6Ly/zhBOHYJj8rQS4tv8369iUoyPjcPjaoH5L5ZoKVZalUQ0EI7qn8Mt06X84HdrYPWvyLbZOlrdQ/4cVxlGl4EUn+c= Received: from BN9PR03CA0917.namprd03.prod.outlook.com (2603:10b6:408:107::22) by PH7PR12MB8155.namprd12.prod.outlook.com (2603:10b6:510:2b2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.23; Mon, 6 Mar 2023 17:25:13 +0000 Received: from BN8NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::11) by BN9PR03CA0917.outlook.office365.com (2603:10b6:408:107::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27 via Frontend Transport; Mon, 6 Mar 2023 17:25:13 +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 BN8NAM11FT045.mail.protection.outlook.com (10.13.177.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:25:13 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 11:25:12 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:24:45 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 07/15] powerpc/83xx/mpc832x_rdb: Replace all spi->chip_select references with function call Date: Mon, 6 Mar 2023 22:51:01 +0530 Message-ID: <20230306172109.595464-8-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: BN8NAM11FT045:EE_|PH7PR12MB8155:EE_ X-MS-Office365-Filtering-Correlation-Id: 1537cbf0-0c77-4281-2019-08db1e67beba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ClrZL3mq4MiDm/KQrQWyRr7xwycSL454yU35XAFJVx2GmOYnWphJieXBmmn/jvC8iOoIGcV3cSP1fiUADV3s+8MGk1ZxGIyMbBSoUPw2TRRkspbhSSY+bQLdNjNVTMfHunsiAYRDko3pgTiJRAw8lQgge7jNRgpLGpQr2T+mMlXmh3s1m8L6zDX5SgkqJRkt+3STH+kgLr4DpESKhAKGuQLtF/WMr08VUq+ayZN6ZYxIyQxsBjQTTjZsfjbwqkEtyVzAtskQZBW8ovuID5xBwf/VvXf3FSOdxy3DagqCRNg2e2lHMEzfGJ29MGzm0RoEJavCog3s5nZ4mg1aFh/p2Kab3ABk+7tuJVCP0O1js9UoeIFc4GHTLzSeuPKDKTyu/0Goh2f8g4WtY4blZ/1rUSkc/BupmktRoja8BljlRRqJvYEvhhUe8w94eG8ak8fnUY5IDT7iJXmsu9q2EmPw/QHm1VaemdVIjMsbPO9GFz7rJ0+zonXerEa/xeBYpZw1DuFpa6i0QX+8vKYWgXTRa5B2H6b1UEqo1UR501dc1rrtWkLlIdLigs3eJjjmsjtxsoRokq9Efapdi9nrVvp8iEmxSaLbP2F50yWmE1zEC/PpLryTaA3dH4qlGgLLA2isytYYc+e1v1jljK5wAuFjKboBkww0z8gXwTX6oH2eWRwHMUSwMR+4pnIY/TXsDsJ/TskLaPu8RtpTJG3SFMYsEpMVBuel1a1mUcadlcaPsBwEyZZXRd6W9npSb6kzKUI6TfvRvHIAj9nkUP03J1FrOybEe6IgJqwxNNShcQI2HVKTKkAbZSeE3Uk9bHL+JeyfKreZK1YgpZl57xvddtZ08iYNTrPJdqQtlE/IjFNZxr8= 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)(376002)(346002)(136003)(451199018)(40470700004)(36840700001)(46966006)(1191002)(478600001)(36860700001)(6666004)(47076005)(83380400001)(426003)(82310400005)(36756003)(40460700003)(356005)(110136005)(82740400003)(921005)(54906003)(316002)(1076003)(186003)(26005)(336012)(5660300002)(2616005)(41300700001)(7276002)(8676002)(81166007)(7416002)(7366002)(7336002)(70586007)(7406005)(86362001)(8936002)(70206006)(40480700001)(4326008)(2906002)(36900700001)(2101003)(83996005)(84006005)(41080700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:25:13.1828 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1537cbf0-0c77-4281-2019-08db1e67beba 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: BN8NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8155 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:44:14 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 9D66CC6FD1F for ; Mon, 6 Mar 2023 17:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229520AbjCFR2C (ORCPT ); Mon, 6 Mar 2023 12:28:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjCFR17 (ORCPT ); Mon, 6 Mar 2023 12:27:59 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20630.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D380D67800; Mon, 6 Mar 2023 09:27:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dkKs7MFJ6lLn3QS1d7HcYF3xT9c19SXAloM+N2jjtepkDOLObJ4nwIIfbYD2bWDOQkzQHA+igntMSj5ad73IeEBIwX4rSC9/BVEuEQoC776MsCMB56IsBvAFL7inFR5sd4UR/sUb1z+DPTNqCcFv73pheXqGpsCqIz1LdmYxLiZty6u5OPpeKn9t2+nev6sv8ncFkPe4HDbi7o5DsApZ/kSj+Z1m5m42btzcfsKKONKZCTfBVYQ/KGtSNTF2du+5qVNctUSEa7iQNc6dLbIufeRRGOUBs3iucF3q+1te/h+a/0USVpDsrkX+wZc7Nt4+lcO3+f8f/TUdggPIbav9VA== 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=OL17X8W0R+rStOrB683dD+fR2ZVe2cak/gEIj+ZyaRtbL5Gk265oaHWKlfADpLSJY+/W1g9GKCEyGamzXVg3LCaczV04wct7BANboOiOZrTodkRztSInLvv+hz/hzMv0Wynnct+pUMHizdJRF4TpETIArcC1Wr3/w3nozSjWHYOprS1gtKkZ8K+UaGwcYoBUWGFlWX4ryaX7EG8PFZ8woCnbiuYNobm+UQvCJrRP/LL3XByYyeCNRYTw7VjbFOkgRYXd4uPoVtL+3eDhXLs6vHrwDQjqCtSSetKcaAF8W5X+79I18q7+JaJ/tIRx50GBrX3BYiQYEGZwT/6nRg+LCA== 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=LBfJ4yQdcwQhpyR2SBTZLifq71GvqQlqkJWjDVggCDk4hsH5ECG1ZBzTNOLXOxYtegK/ayLXRwEpEOBdy1qKdhxplFLrEh0JdzA4wwMya05XF26/YDm9SYU78GEeZFTqVP0+dTVkZ4/EmvMWbT0WpzI9Odvtzva8tiifPZ+52JQ= Received: from DM6PR18CA0019.namprd18.prod.outlook.com (2603:10b6:5:15b::32) by IA1PR12MB6236.namprd12.prod.outlook.com (2603:10b6:208:3e4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.23; Mon, 6 Mar 2023 17:26:50 +0000 Received: from CY4PEPF0000B8EE.namprd05.prod.outlook.com (2603:10b6:5:15b:cafe::12) by DM6PR18CA0019.outlook.office365.com (2603:10b6:5:15b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:26:50 +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 CY4PEPF0000B8EE.mail.protection.outlook.com (10.167.241.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.4 via Frontend Transport; Mon, 6 Mar 2023 17:26:50 +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; Mon, 6 Mar 2023 11:26:26 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 09:26:26 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:25:12 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 08/15] ALSA: hda: cs35l41: Replace all spi->chip_select references with function call Date: Mon, 6 Mar 2023 22:51:02 +0530 Message-ID: <20230306172109.595464-9-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: CY4PEPF0000B8EE:EE_|IA1PR12MB6236:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c5d14a7-9df0-4573-c683-08db1e67f8b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mi+5nM/+f2DSJc+eHNVwefPOhh2OqhereBaPkZzNI/RQIduxpMT/FLX42UYDSwIhUfLsH/0fOVLEESCyzu4HUvSqNsbhCzO9peHK5BOOqFrQB4wPsIHcJc7I3uX49eNbht+QfZFohvAvy4Al/KR75H7etwAXJnKO9lQXShUaha5onxJw2Oqan3e/ol+KcW+uqK1Lpard1qa8cu9ssT4oSZa/dIyMxWxyEAY1HTtbqSJTaMiwaq7Mor3JTDWb1CVDHHJBjt+i+JqpcqCtnVRPxYngBOyuLFF34hNcqg7RQlGdTTVUgdDjBcBjn3KhhPq5s/uOFV6NiEzDZpSxFbjywZy24ZgBqPkFwRwsUhWHSEC9fTrTm4CnfhxjjGJNonjkD+YvfpHYYniJXTcCGoCWRcdkeOaaEcQKrxogk/nYmxzCGOSxR0jRC8GqScu4lrOdIfuviignc+9VsPDQPhg6BumoeBANuPYnZF2KwDWGCcjdfrB/dGsZHRiW+HNlR9YdPMdBXhgyFtqeK8kMvuifmSYwLt4vo2fA+Y/lRVR1dC7a9n1gGkOFXAmCvavfXsmQIxWE9W3pYFba16e78owWFeq8zehpK2UIgd0KKZk224G3Hl31hut/2TSIblqfuLTlLEKL1cUfLyLtu16cIT4y3FoyR+1W8vakLvqOsSoAy7NfQk9gSAwZJEmXvg6schpFvh55ttEe7G4EC7/XK2SsvmNeQlLNcyAluyXtOT9kli9IQdMNivqF8efBjY8bWGVdOyYZb74QGUxDus4VF3dbYeK1BiU3wSHeMoSJIYZ+uwuAHUYigrkLSTwO6MYKF3AGUwoIU3e8aYhMlXFg6UrtD+x9mbVD37CnA1PB/ryaDuo= 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)(396003)(39860400002)(376002)(346002)(451199018)(40470700004)(46966006)(36840700001)(7336002)(7276002)(7406005)(7416002)(5660300002)(8936002)(7366002)(41300700001)(70206006)(2906002)(70586007)(4326008)(8676002)(110136005)(54906003)(316002)(478600001)(36860700001)(36756003)(47076005)(426003)(6666004)(1076003)(336012)(2616005)(26005)(1191002)(86362001)(356005)(82740400003)(83380400001)(40460700003)(82310400005)(921005)(40480700001)(81166007)(186003)(83996005)(84006005)(41080700001)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:26:50.2056 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c5d14a7-9df0-4573-c683-08db1e67f8b4 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: CY4PEPF0000B8EE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6236 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:44:14 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 66317C74A44 for ; Mon, 6 Mar 2023 17:29:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230199AbjCFR26 (ORCPT ); Mon, 6 Mar 2023 12:28:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230086AbjCFR2y (ORCPT ); Mon, 6 Mar 2023 12:28:54 -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 2F8F828875; Mon, 6 Mar 2023 09:28:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OYZH0arJdiVGVTE13KQAsk/aKUBqU5XneUw84skBL7pqUAduLoqZMBRBpWolRywqGLqRnHfvT0qjI1JVHPezUxH9vvPTMapHKIEhl2f4c3cU7KNcqNWVnkFypsYlfm2WoIB66iND15neUBEaC0OXBFWdANg4H4shSmA0gFo6J7LHuWhT94GZYjQSNCCNqox5VGv55RKdGld66Hcjw9EfiT7WCNf8ClOY36iJS9txs9uz9AuvxqXfuH2XbQ/AIrVqwf+fgzj030vYXbZh7/DsOxlHyvpMyL0hl37dSx5tZioG7TlcEb0uvPl2nsL2V+jXEfzuGZDeOEEzOzaKXx5WCA== 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=14VR+G5XqJNGsnj0+uaAtX2EQ0NMUGOmpb9/B0J2w2A=; b=TE522A79EAKMGLIo1pFA8s+WAIe996QVkzYEjVFhnKO7H8+/e/1l6o2Xx6wRjO6xvF0VMEpQmegA9mzkI//qMBFYLENeN6G2iDhlUFRLWR67pS0xYQxlA70zDC/gPgsWNsKjqoCaD4I1PJIu2Gm2uvECnUVAhzbk5/wZ8t/18uxI4FH7R0H/QHZxtRyeGkwYPP72ih7pZ244lId9XOiPAmN63wMOL6SjI90Q95PQnFm14rGVXzFIuD2L+DQ7gAC8zfAMny9zOXy2O1je6Q6zEU8InMSyBJ5l4XeBa1OPWAMdNcXlXXQvMNsFHE29oX+elTzzCDp19qYfY38ytvgY3A== 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=14VR+G5XqJNGsnj0+uaAtX2EQ0NMUGOmpb9/B0J2w2A=; b=Yp7FL77SDj/W4MoXTQ57c0LSnxVy829uJap9Sa9ewxoyqym5X0EFp7iY9+gl8iGrzXAbtNUkHVEbS9Fm1qos4aQGzqef2e9Mdnbp2W/FLDdhDtJ0BZtKWxbbqLOKw4omovbSM2awY7tnviqLBaZxLpyScfoJ7x+8UZHR35vcwq0= Received: from BN9P221CA0001.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::16) by MW5PR12MB5684.namprd12.prod.outlook.com (2603:10b6:303:1a1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.27; Mon, 6 Mar 2023 17:26:55 +0000 Received: from BN8NAM11FT075.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10a:cafe::7f) by BN9P221CA0001.outlook.office365.com (2603:10b6:408:10a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:26:54 +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 BN8NAM11FT075.mail.protection.outlook.com (10.13.176.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:26:54 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 11:26:53 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:26:26 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 09/15] spi: Add stacked and parallel memories support in SPI core Date: Mon, 6 Mar 2023 22:51:03 +0530 Message-ID: <20230306172109.595464-10-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: BN8NAM11FT075:EE_|MW5PR12MB5684:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a85550c-2f5c-4257-fd8a-08db1e67faf2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NZfDjJx2qG5J//2Ae0bPh4G1qhdHAuhEoRXBQilJOkmmb0Nmrln3nPPHQ3AIMTxwrbjFoTCWzSJ8EScWhzQVaDC0BymXASz6dgA2sdljw9uUXx7wGrzid7c061LuR3UXipzC2Zu6PfWhh/t0aDXIBb5AEjEiO3nbbzkmlxhmeqsYOJrAXcot0uHfd3urw2/4CZlPNcrVpQXYxn78Ce/vFJVhrfAsPXLnAdcBRgJDua8Mpl8W/IewBl1xwHJXEh6rU0FnBT5HlK8Xh45GAA2fE8cJGY7zk4yUJVChVIIegVli5cZ4l07EAqWgOVlaaKh+7ilMYxlKpLolZq+D+lgJ2WAxOawDv6ORa/yyc4gwbcJOOqRt9flADKcgY3flvEPOwAuiMpxFOHh+LZP5SQgJynkHToaVX2QZcqOZiObca5znJ4nUkm2F7j5/7lCLDHTd3ZwZhv26Ky2jwfgODsleKLv4ygD7BMN3jx7lawczr7oMSGoFsfbJWZUAgloSXwWEUIPe4lbsCnbmEcGKVRyqjwCgsKqYG47i6D2zcgBe8r3kjn/cRjHpuGtt/FDElqpWe6eAGr+UGcADaEU+d5gOWXM2DSGVX9kNxdizlkxwTdU3xfIHjjffftE8GASoL2UOeDYpV89E/Lv26x3/FB6xAJtw724wZQY6hETEH97T1hiuKIUJil24qZBKuCkso9JEgB/uATz0ouNjJ53ZBF9u30rU3MPw1EhHkLZdWbS2/WI8NSAW2yzdYoDS/uHvAXD1fdTcy6a6DugX0hxPTQMZ04ifARUUh/kQfYGXsAR8TxWMfB0CCU6TjEJhvrchpvfCNpaYfszXnAsm5Ck+B7stRMolzPRKHygUK/PSpMds2YA= 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)(39860400002)(136003)(346002)(396003)(451199018)(40470700004)(46966006)(36840700001)(8936002)(7416002)(7276002)(7336002)(7366002)(7406005)(5660300002)(30864003)(70586007)(2906002)(70206006)(4326008)(8676002)(110136005)(54906003)(316002)(478600001)(47076005)(36756003)(426003)(6666004)(36860700001)(1076003)(26005)(2616005)(41300700001)(81166007)(1191002)(40480700001)(86362001)(82740400003)(82310400005)(40460700003)(83380400001)(921005)(356005)(186003)(336012)(36900700001)(41080700001)(84006005)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:26:54.2344 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a85550c-2f5c-4257-fd8a-08db1e67faf2 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: BN8NAM11FT075.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5684 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 | 213 +++++++++++++++++++++++++++------------- include/linux/spi/spi.h | 34 +++++-- 2 files changed, 173 insertions(+), 74 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 5866bf5813a4..8ec7f58fa111 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -613,7 +613,8 @@ static int spi_dev_check(struct device *dev, void *data) struct spi_device *new_spi =3D data; =20 if (spi->controller =3D=3D new_spi->controller && - spi_get_chipselect(spi, 0) =3D=3D spi_get_chipselect(new_spi, 0)) + spi_get_chipselect(spi, 0) =3D=3D spi_get_chipselect(new_spi, 0) && + spi_get_chipselect(spi, 1) =3D=3D spi_get_chipselect(new_spi, 1)) return -EBUSY; return 0; } @@ -628,7 +629,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 @@ -637,8 +638,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 @@ -648,8 +648,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 @@ -689,13 +691,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 */ @@ -712,12 +716,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 */ @@ -965,58 +972,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 @@ -2245,8 +2313,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")) @@ -2319,13 +2387,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)) @@ -3845,6 +3921,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; @@ -3857,7 +3934,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 a08c20bd833b..1fa37baeffa9 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:44:14 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 8A3F4C64EC4 for ; Mon, 6 Mar 2023 17:28:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229977AbjCFR2m (ORCPT ); Mon, 6 Mar 2023 12:28:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229707AbjCFR2j (ORCPT ); Mon, 6 Mar 2023 12:28:39 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::601]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D01C41A4; Mon, 6 Mar 2023 09:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cZg5AT2puwJrpoS2k1CFA7Fof0gXKgyATrEQcuRv2N5b9TX0CvUl16MfuEzEvr5XUTXr/98YZTBFri3oaPs1bVdmFU41s6N3qiKp9SeD8exwy7gFS5kNHGkTtQMI6zceFY/m2rwCtISmsImnD15r1vfHFtCMGsZAtm1GSEO5tWXlGUxXGYQMMJtyY0njO6mvwdZdn7R9j+PRdhIPV8pFk2Uk6ieU2AvbcSZvexyXd/4p+jm/lUcQFdrfpBzqG+8qHXHPL+OwE4fMFRNcJ4qxHEidLhWlm4KjX5w0G1M4naMf9BG0aEu1zXzCHCB+ql1sekS1WXrOiEahJyHNZdLPsQ== 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=GP+bj0l0i7ptKMwT8OM0vzvTCbQKt0sRPXZqeZcamqsZUjsUzmi6zvs4gbDQlguERV5uaP5/6ttiM6uscAaF80dy4L6wrdgymaSYdeedrDwpNjcyv1SV5XJMfcRcKZHIJ5MbAuCsBoC7+tTmmee0kBcLsu5IfQteAHdhR0q+CKmbKYbzMp5+oa/KA/jGJESmTfqPUiWU8O1tWeZ9Prlgrhr2qHJkoEvja0fCvkuScWqm+vp6qd9t41nhobG+G2E0zfLvWzwT5ghTL3XKqhpUUSZSMngJNAoFE1totcSJQVcNbMVLfBv2FRW0E6hisEW6cr4413GeJ70xRrtD8Q2eGQ== 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=WGqp0HW8qHtBghSW8V3nIAlRRvNH1SjEUolBjgZa+g5Ea2utzEg0zHFYwflWXzLxNIIMGFmrsoH0YYhvSVVeJmVE/LZTupOUuErUk0N1JCl7pNwJ0L+bJ3tj1xLr82w81PhbkcTJ7SccrdgZiIl0w0x3FFJaIS9YjayQQG2Zd/o= Received: from DS7PR03CA0152.namprd03.prod.outlook.com (2603:10b6:5:3b2::7) by SA0PR12MB4445.namprd12.prod.outlook.com (2603:10b6:806:95::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:27:24 +0000 Received: from CY4PEPF0000B8E9.namprd05.prod.outlook.com (2603:10b6:5:3b2:cafe::a7) by DS7PR03CA0152.outlook.office365.com (2603:10b6:5:3b2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:27:24 +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 CY4PEPF0000B8E9.mail.protection.outlook.com (10.167.241.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.4 via Frontend Transport; Mon, 6 Mar 2023 17:27:23 +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; Mon, 6 Mar 2023 11:27:22 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 11:27:20 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:26:53 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 10/15] mtd: spi-nor: Convert macros with inline functions Date: Mon, 6 Mar 2023 22:51:04 +0530 Message-ID: <20230306172109.595464-11-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: CY4PEPF0000B8E9:EE_|SA0PR12MB4445:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f0c3563-0db1-4e00-970e-08db1e680cb3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hETlFU7BbPuy59QUdy4OEMz4eK35Z6y1CnZe66eZ30R79RPx2YJ524efSpUr4NcbyckGiqnMLdYWRsCxpiImYlmCwojrVI5f3oZUhTuogdccWRWLZkxAjYa+HCMTmKx9QgJV8ld2HgPgYENqo1CxlDVV4P8yWnNDihig3C2l1DUkgRDf40UkaiLXwvkVn583Mpo1akvOUxs4+B4zt9InRuepzz4s4/qZmtBvh5Mk7TtQ0T5qd5GZ1mKQsis0eiVzugOHlQCxuiuQDaIPuHV0uotmTK6/LSR7TO7slZ4IzJTapsAn1nFR2BmXRVV7vO6Z2fRbSh+TeJthkzzel0YWWEC/qoTPWw0N9FeWWfGtDw9YxNNPqowAi5kWYttLlO9qd6Ha1Y5LdRzSuLdFMkQ9OZtQISF0eg7zKXeyz5YTUIxXSshzOkS5TpGZu08mhMTi4ZRmSkq7d1/Y6otoTMG6ztBx6mTgcZD+3kayq/2RTVwq6O0PXZFFzpivSSXEs3j7uYeyttLigWIw3FIpbmYRwyYfC8xLPiVmfzSTgjHoDWYtaK6QA2ChUhYK88t60/+uCDOyzFv5nmq+fdf70Ar1I8QC/6j2yeurmCoMjtpvEm4AsADCb753QSGGs2JdUJ6yCqZIODUpjz29PClE4ujKlCuXKn2aexxxJgCm9NGRArlk7tp+sttxYM0plTNgUL/zbMRxyMDjkW9QoZRpOhOtQbwG6w6e4aGXQYlyB+XELcyE8W16OT5yGbm+iu9lR+bRjJvYY/wLq6Xpsvnsnc3U40raxhFRCTL5/bQHFeXSc+uaBQV2937p8z04E2gxg2qwC52/7zF9MX2CV/X0Xl9Tf/lBGJ/4vC85zgDKQI7uiVw= 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)(136003)(396003)(346002)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(1076003)(36860700001)(6666004)(36756003)(47076005)(426003)(82310400005)(83380400001)(921005)(356005)(40460700003)(86362001)(1191002)(81166007)(40480700001)(82740400003)(186003)(336012)(26005)(2616005)(41300700001)(70206006)(70586007)(8676002)(4326008)(2906002)(5660300002)(7276002)(7336002)(7366002)(7406005)(7416002)(8936002)(478600001)(316002)(54906003)(110136005)(41080700001)(84006005)(83996005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:27:23.7679 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f0c3563-0db1-4e00-970e-08db1e680cb3 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: CY4PEPF0000B8E9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4445 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:44:14 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 40174C6FD1F for ; Mon, 6 Mar 2023 17:35:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230525AbjCFRfj (ORCPT ); Mon, 6 Mar 2023 12:35:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230373AbjCFRff (ORCPT ); Mon, 6 Mar 2023 12:35:35 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20621.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::621]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E4369218; Mon, 6 Mar 2023 09:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KjNRcNHb59+WAoE5OI1xd8bevFZkKpiuAhlxGVCwc9z3UMMGLEYk4QCHWWbbX5nUcpuWlUXeCQ2JRLfC/a9MdMqpGK5a7Exsxi9E80LlXkWoFCigdI2r+VnlpEaJ7XhjS1GIEjbqWrcFlwi/2v3F6M4sbLr5hWS4tkUG5GJ4nDhuaFdJJY8mfvq7eaAorjZG1IeV3h1G9x9bsz21YXPoS3yQklnUn4x1cUg0EpJk7ZtgFV4zViORBl8fEdpWsR6E/xWOUJIABJf9cQWDnato0kiYrzfsZMOUlDQnCau9XDTIroZUDAjf4TTVJTfKzcwfUvG62KQcJscQpBtlQts4cQ== 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=oftp4s23ROlIj9/OkQ+pi8TJcpelkfto8C8grnhKfN4=; b=gF+enmYo2ZZjoHK/qEksfbNHDBZjy0Yr1sVqbVOmtiPARvVvBcO6y1zC4VIZ5LWV/rS+GOvZUuUiWUKiKuJEfsRmNJy8RbB3lVFkvOhk3faZWi3chd65CIhOOZ9M4nLHhjqXB28Ebf8wLLkAvsF8KQVQxkAcPigThlPkGD8KqFRpd+X+ghoY+EBETU/0sOWGQW6GEvN4h5zo8UzJiO4MVTzbm02QaSEM2FJ5RAmOCL1G1VTCzbpNuDQJOfVDpTUm+lLU2bJaWTSO8ENjwSr9r13s2GzVmngEYfyWnjkAiBW5h5eZeBSRyof2s8j6TIwXRYmY95tzNM0mcJBMW9f4Dg== 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=oftp4s23ROlIj9/OkQ+pi8TJcpelkfto8C8grnhKfN4=; b=fPInuDwGLzjLo7j64OFWkUGOcr3+UGGRcFaGIomXqmaacWFG2f/xWJ8DZjsJ/uFr4191yoS/IjcAA/1Fz8Kj3k51CVDmoCdfuRr9/RlsvH+fvt0zVSVV3X83xgQwWQ+sEOX3l2oQKcGOArQw9lpsJqC3BBBvil8q2k3OXQPdPYg= Received: from CY5PR15CA0140.namprd15.prod.outlook.com (2603:10b6:930:67::10) by SA3PR12MB8047.namprd12.prod.outlook.com (2603:10b6:806:31b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:27:51 +0000 Received: from CY4PEPF0000B8E8.namprd05.prod.outlook.com (2603:10b6:930:67:cafe::9f) by CY5PR15CA0140.outlook.office365.com (2603:10b6:930:67::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:27:51 +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 CY4PEPF0000B8E8.mail.protection.outlook.com (10.167.241.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.4 via Frontend Transport; Mon, 6 Mar 2023 17:27:50 +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; Mon, 6 Mar 2023 11:27:50 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 09:27:49 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:27:22 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 11/15] mtd: spi-nor: Add APIs to set/get nor->params Date: Mon, 6 Mar 2023 22:51:05 +0530 Message-ID: <20230306172109.595464-12-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: CY4PEPF0000B8E8:EE_|SA3PR12MB8047:EE_ X-MS-Office365-Filtering-Correlation-Id: abfac7ac-efec-4e97-20f3-08db1e681ce1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sIP5RBMW0vhtK/yeinT4Oi/D8J9HDa1jebTQIg/QT0PE/iaRUDi8p1JdzeFX2lyUxd8Rl6Xbke65z3j0ky39kyIyIcb3l1xAUdCulltsTjSTJ9vo7Bzb55bq3SeezEWg7pi8b1cq5Tki0URpoepIEbej0iPS7UXQsILbkQEpHrB2MJRszidqw6X58JlXQPZI961vF2fVVj8LFIQZROqifTq9c+8JYqtYQ3LGMOsYPhFCIPV4Q8cB28tuRMIu1kDeTsZvCHKlMaPrvK1TDUcMHFrL0FX5XYM7Q/R5cHYZcFqpP3YvGEVcedeqiWrH7NxVPqgmBHToSsUUgxsVbpTKtewTbfaiu0fyLpPI6H0mYmbijJ+hn7gR37oUrkT6H+FmbKljcwjaAo1N8lRz/4ctresGm9a23pDZV4iIi68VejOVIPzMdBhnWVA0YR7itY5mMndjCjdvQMRSm0956MPw6qvGzUlT2d9WlPdGj3rjy5YYeUxoXRxN1XJ6mjJAr/kmyleHlhWeMyYBNc5bd83nXb7XyUHsp2XgkYxjq/Lyrc/LZZspZzm7LM9MDKOg9MAIip2sT38VnwBolTKg2eapt3N2xw1rxmgF7wMvGifucnquUbjzvxVGTm+3NXUPCAFEPkZ/cGzMuE6pLjX49gNAPyw8mcuKAk+jN0AqZMwbbBZfkxpQLHaCRgnlzr1PHbZmpXtV7xHPsG+QzY7hiJcC2aIye6mFli1UeqWJRLLTG1SRft6rbZh1XjuT6CTvdtqBDCdCNz5Xkjf9bAMB4/flHoE1TNNJJOlF+Pu068fHy0sGc9j1ptkc2iqadHIWEnvDlU6EAp+uhQlmt6u1RCdRxqJDLxiGeUNLoCyLOkN/TGC8gya/aVGxC5HbgHDdqJ1F 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)(396003)(376002)(346002)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(36756003)(47076005)(83380400001)(82740400003)(36860700001)(1076003)(6666004)(26005)(41300700001)(186003)(336012)(2616005)(40460700003)(5660300002)(8936002)(70586007)(2906002)(40480700001)(86362001)(4326008)(8676002)(70206006)(7416002)(7406005)(7336002)(30864003)(7276002)(7366002)(426003)(316002)(921005)(356005)(478600001)(110136005)(54906003)(81166007)(1191002)(82310400005)(36900700001)(2101003)(83996005)(41080700001)(84006005)(559001)(579004)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:27:50.8630 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: abfac7ac-efec-4e97-20f3-08db1e681ce1 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: CY4PEPF0000B8E8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8047 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 d8703d7dfd0a..8a4a54bf2d0e 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. */ @@ -2067,6 +2084,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) @@ -2076,7 +2094,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 @@ -2097,6 +2115,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 @@ -2107,7 +2126,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; @@ -2176,7 +2195,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; @@ -2225,7 +2245,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 @@ -2285,8 +2305,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 @@ -2307,7 +2329,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; } @@ -2329,10 +2351,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) @@ -2367,7 +2390,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; @@ -2492,6 +2515,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); @@ -2506,7 +2531,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 @@ -2520,12 +2545,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; } } @@ -2560,7 +2586,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 @@ -2646,12 +2672,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) { @@ -2679,9 +2708,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 && @@ -2691,7 +2721,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 @@ -2711,18 +2741,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); @@ -2764,7 +2797,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; } @@ -2880,12 +2913,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 @@ -2957,6 +2992,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 @@ -2972,9 +3008,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) @@ -3028,7 +3064,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. */ @@ -3099,13 +3135,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 @@ -3130,13 +3167,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 @@ -3159,6 +3197,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; @@ -3205,13 +3244,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 ff895f6758ea..5689bfda1f2c 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 a0ddad2afffc..ccd13b73a75f 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[BFPT_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 d81a4cb2812b..b78d0f57075c 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 8434f654eca1..09814adf8620 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[0] & 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[0] & 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 @@ -1182,8 +1187,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 @@ -1191,7 +1196,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 b621cdfd506f..30bfe9db6210 100644 --- a/drivers/mtd/spi-nor/spansion.c +++ b/drivers/mtd/spi-nor/spansion.c @@ -46,10 +46,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_CFR2V_MEMLAT_11_24; @@ -136,8 +137,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 @@ -195,8 +197,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; @@ -206,9 +209,9 @@ static int cypress_nor_set_page_size(struct spi_nor *no= r) return ret; =20 if (nor->bouncebuf[0] & SPINOR_REG_CYPRESS_CFR3V_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; } @@ -218,16 +221,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 /* @@ -250,7 +256,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; @@ -283,22 +289,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 /* @@ -306,7 +314,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, @@ -318,8 +326,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 { @@ -333,13 +343,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; } @@ -541,7 +553,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; @@ -549,7 +563,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 25765556223a..728674ea3c22 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -421,6 +421,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:44:14 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 B49F9C6FD19 for ; Mon, 6 Mar 2023 17:30:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230365AbjCFRaX (ORCPT ); Mon, 6 Mar 2023 12:30:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbjCFRaP (ORCPT ); Mon, 6 Mar 2023 12:30:15 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2040.outbound.protection.outlook.com [40.107.94.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B373BBB0; Mon, 6 Mar 2023 09:29:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GPqGOeaUO08rgLqWMbLgzL4yX4WrEkUvedetWr6/4m2BKTBCvfKgNYYLXL6DRimuqvIr4/oAjQfPqwGCm/lFbWogxQ4rmQqrwhj+1chvIdkFZtpNGWkwNS5ZbKn7+bqWWMyae7vmPoIbx0iZTSNibXczV9VAybvsAo1EQ5VWa7D3vU0cY68HuPXsyONqD5n/ZRB2ZFMs9hustJ8M26MH2pO96eJdAtiAvCAvUGfaSoofq+guVwMkw3+zWK4XBCnRe0MZxO+SYS/E3Eoec/a35bu2exNjJfMf7AsWPiX/hqEkt2BV4cqTSecgL3QTPgkGC5zNoUHxDsAi4dlRiWn0zw== 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=OgO4Y1hQP6qJn0ylulPlZiAg4zwkUsqUf66sHia2XoM=; b=gI28sqinWAzcrhPiGKPOjzpWUAzqNrljHS1Ux1jx0uvg8bQhmhsN05J87dOJllLLU/IhmQGmfY78we5rq/Nx3tn3O931SKy7QlH7lkNTxAZiQwC+B56OPGEiHs7hAElovG4ysUopX+DRAuZlJQ1SXAqbUtvbiezuooMJfSiQL6hlnyDKBoVLKjh1BjywCSs2tY5dSNywaQW4ioXOx4NFPQD4HxxATk2Z235FHXGAaJCrJxOPV+PTj975afYSCDy11/3TwOAKYQlECwBoMOwtxfBUI/Y7Gqlkp0vjX/MlZ7bvRpV/t+L8oZ1oePEBqgIzY6KymuqZYzBGI8Qk2/qpXA== 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=OgO4Y1hQP6qJn0ylulPlZiAg4zwkUsqUf66sHia2XoM=; b=bc4ugRNdqTDt2Q5HRVMwlWQs7XJ9K8Sv9I5FME831tHeGoHsLkgPnzxYhaszjqKvqavqzFcFYJUEUZQ4xNaTUIhCLtpI5VcDqOZy3rl74GVefEVcaUTWoUvT94/b+f4skS07eTZar2P76uEBUxlCzXeP9S8NzG/bUFpc1TZynds= Received: from DM6PR18CA0026.namprd18.prod.outlook.com (2603:10b6:5:15b::39) by MW3PR12MB4539.namprd12.prod.outlook.com (2603:10b6:303:59::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:28:50 +0000 Received: from CY4PEPF0000B8EE.namprd05.prod.outlook.com (2603:10b6:5:15b:cafe::34) by DM6PR18CA0026.outlook.office365.com (2603:10b6:5:15b::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:28:49 +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 CY4PEPF0000B8EE.mail.protection.outlook.com (10.167.241.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.4 via Frontend Transport; Mon, 6 Mar 2023 17:28:49 +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; Mon, 6 Mar 2023 11:28:40 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 09:28:16 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:27:49 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 12/15] mtd: spi-nor: Add stacked memories support in spi-nor Date: Mon, 6 Mar 2023 22:51:06 +0530 Message-ID: <20230306172109.595464-13-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: CY4PEPF0000B8EE:EE_|MW3PR12MB4539:EE_ X-MS-Office365-Filtering-Correlation-Id: ad21891c-79d1-41f9-b289-08db1e683fb5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VMB4RxG6an4E1P5su1x7/G4OUlTodFQs8gE1PnlxoueIFcs5AI/RB5GTOPSRVVLlsH2lokLSKRv6PtwXBVgOX7pqNywFsrlLzW5nVYog9StoUQXROo+E5OKzym+75V6cn1vWztT56FbZ2ZAdQb5T+XDsSGddENwes4CUwkBjsCD27I/g1c2CeDWjSzrefcmK1P86pax7sFKbxZUq8Ye8sTz5zvmQM+09VOFB7IYpypyU7NE9f7ILWwPuYKG5pjRHGUB8mwgo3xNmCrNUZlmIf4Qo2dfDt6mb97z4IrX78wRGgf/KqHKAC2R9+S5kXniX/OZHC6B9DjG1LIOI78quv2uNfeHrpw+JdOHRT69Gq1jZ+CWlaGbGzGSL9hS86afJ0jPU7S0JSdLTpJG3E5gtBfMpHhU9FmV57gtV61Xb1ScE9kPwEiPK8yuILrmAFZZqmHQT4zSrH/IVi5Bv9LzRazt4vAMpW6UTFcl007XNDpj1bElYlC8mfWsJhm2aeJ//3wOdpmURAkAbsVnnoXIMCk3ottNs6GZxy6pPJqIK1DXSgWBeDokBap1SrzvssGMQTCLkyMT7xdR1rDFXIND/YfC9/8esdkztyvJNlm8CY6K3ilvl0vkEuuMOg952+XE2VuevglOMV+aWqAAi0+XV1sduwItu6UpT2frb85uNkO4jYy/AfLlPf1BeJ5TXNyxew7eKqzFN5B+udiPDBtMGJrrcxmaLTpcDk4k+9nS4ax+U8NgmfX/smThEaSwvD/XCA35A+LCdD77oyBlzuexD/kQuaS63dsLO0V+HC1q4adC35dgVHv/KDBLoah7F5Y80i1x/KRt/21rkaefFttFevhA1eNKK9d4+AflJcqW0BP4= 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)(39860400002)(346002)(136003)(376002)(396003)(451199018)(40470700004)(36840700001)(46966006)(7406005)(7416002)(7366002)(5660300002)(7276002)(7336002)(8936002)(30864003)(70586007)(70206006)(2906002)(8676002)(4326008)(54906003)(110136005)(316002)(478600001)(36860700001)(36756003)(426003)(47076005)(6666004)(1076003)(26005)(2616005)(41300700001)(81166007)(40480700001)(86362001)(356005)(82740400003)(1191002)(921005)(83380400001)(82310400005)(40460700003)(186003)(336012)(83996005)(41080700001)(2101003)(84006005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:28:49.2049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad21891c-79d1-41f9-b289-08db1e683fb5 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: CY4PEPF0000B8EE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4539 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 8a4a54bf2d0e..bb7326dc8b70 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 */ @@ -2516,6 +2619,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) @@ -2533,6 +2640,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 /** @@ -2741,22 +2878,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) { @@ -2797,9 +2948,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; @@ -2915,19 +3076,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) @@ -2995,6 +3168,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); @@ -3010,7 +3185,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 f03b55cf7e6f..e94107cc465e 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 728674ea3c22..79be5d50a509 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -128,6 +128,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 @@ -400,7 +406,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; @@ -423,13 +429,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:44:14 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 BD664C6FD1F for ; Mon, 6 Mar 2023 17:36:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230471AbjCFRgM (ORCPT ); Mon, 6 Mar 2023 12:36:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230496AbjCFRgC (ORCPT ); Mon, 6 Mar 2023 12:36:02 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20611.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::611]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E4B937569; Mon, 6 Mar 2023 09:35:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AIN69o9oBiVAT3VNV3ZHy8Sx8JTGTGBWrhhUUbatp0K+QWxGmn1imFd5PRFQvubiZhDlDwzhfK5Hsn6xut34uiX9EvTkc4XhbzmlHRZ+oi+N5nVMDIooXTCiSE8jOBCtDORhE93re7FX2GfsdwX0JfftfjaPoVIIi0uOwtLMy+iX3KkULg7LaM3fKCRJAJ6xHpeZZuRXKom3z3p0t7luRCPZuZvseYAaJdUe6F9PbrVPG/PXszdd4SJKHlmyemw7u0WbDwdOL4BiQ56MhKXLsbUBuyKbAEdUX2GjAomLrGTIl+f/wTDzvI1N7LBvGwFcOAb3KtV66cnfKEs/oynHFQ== 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=SAhIOHKu4HJGlav21Dv/GMi46fbF1Mnp5ITBekjHuvY=; b=Tfk95eLD00TMfzdxkjXbbuGX97NZUQ/qVp9F4flB9JBQ0YawHkcUlXMTxeQ0o1/ViiZKX31iSiF8YYGYN4GEfNXQai/WhaK34GCAb76OAeoubwGt7EVbO1xx4jsSx3HwNvqo2UBhcl6VeLx67A2kfvFvKjHxl3Z+vo0hwIxDV9xqn9u55A7YzB8PfhlqXommTK7CY7Y4sAfQOG0XkkJJDPyuDZhh6RZjDjMSi76RaUrVls1kwt/DOj7eJcyVcWSxJkP+B9+XD1HylAcFWwFIx/eFyD2ddHjKTrFwiBLFFFh7IF///TfB7wV0A6VQmUKq6AgsZcIgKVorJq+pg3xXzQ== 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=SAhIOHKu4HJGlav21Dv/GMi46fbF1Mnp5ITBekjHuvY=; b=FF+PhqyQct0vzVRiLc7t9NZ/76RfrsygXf9klSr1SWz62z3pEYTfaSWwCB4oBNA1I9nHwzA/EtIPrqPbP5YJU6JeaKDJ8jEQyum0kXZMDyhxrVauyI7z6QZNMv7vXcxrH2lUt/95IiC8JGXpfhkS9vrLKGR7ZMJSW2Afzjwjs94= Received: from BN1PR13CA0012.namprd13.prod.outlook.com (2603:10b6:408:e2::17) by DM6PR12MB4529.namprd12.prod.outlook.com (2603:10b6:5:2ab::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:28:48 +0000 Received: from BN8NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e2:cafe::ca) by BN1PR13CA0012.outlook.office365.com (2603:10b6:408:e2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:28: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 BN8NAM11FT098.mail.protection.outlook.com (10.13.177.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:28:47 +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; Mon, 6 Mar 2023 11:28:45 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 09:28:44 -0800 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:28:17 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 13/15] spi: spi-zynqmp-gqspi: Add stacked memories support in GQSPI driver Date: Mon, 6 Mar 2023 22:51:07 +0530 Message-ID: <20230306172109.595464-14-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: BN8NAM11FT098:EE_|DM6PR12MB4529:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e543323-77a1-40d0-fe52-08db1e683e99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wNN0f5aBHSJGYW/4EONAHS2DiM1o/bERWIV1enovAdVhAjbae1kdi6cjrWFS7OoCNEJryfmS+5M3XWOgyRrqX1IdVb3zeHXZIUqLiS6B86hV1K2chC0ViKQrhM9fTPb9DHoR1PXz6rZfFX+jq07oC/lF7FKiXPLtG1UtuQg3YRYKNiK/H3oaOIzBNskUUQuTc5p8iIjoSEwMxFzIhWm2TtXjXOr8zuGAG53jhZNQ6AnjDlY72hRbBBhCnYrRU+FIVZ+xDQtyo93Rn/ECCSf/jbFFtLR3uI/obIpcRWvpSLMZu0zMoNqxRpaoPfhYy08ROrWQ+1FjOhfcfHm/bocuq61pozOIjAmO6R85Zhd3xHxLNJrX2CUB0zDB04mWCiOocFxOurk7bk7ZpyNqgBCKDfdiLoYOd/HtE4HAgujsmTQqHy8q82Y84Gp4SdNVQIzrQOCg9yIB5/Tkpj56cjyOW9g6WwZKHnR9GGC3o/4xO/mPuwsI/ywAWdg3OntATl34XMr0TWRsN95p/OHN0a+rXfjSA6Bn8TmEgWAgY1F6dofX94uxI9uMuZW5rVQxAeroQefZIx4OnlUcCY7TR0AL+fO9G+CK4ARdzkUxMONDAS/OdKm2ac4tDyo25U+J9mz6+hBvBwyfJ1C4NqG+mUh88NmPmF6NyFqYRMkYrcrheNfMIYTRq1SDSDVEVC/oAyphefcvdXJK2fQ0XV0mtqP5vg1lXSASSUz5/9UBosLBd3+Jf23Ruj4dzxWGPDx9MzoSzM4TAoKODIPaIGg40B0yc60mb8uLPHE8AVxBEo6p4bGrb8LT1yKaTAggyzaziUuvIRy4ng7ddqMOSN5YFt4LLuH4rKCxvfEe4F4WmkvLu6c= 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)(136003)(346002)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(36860700001)(86362001)(356005)(82740400003)(81166007)(921005)(36756003)(7336002)(7276002)(5660300002)(7366002)(7406005)(2906002)(70206006)(40480700001)(4326008)(70586007)(8936002)(8676002)(7416002)(41300700001)(82310400005)(1191002)(336012)(2616005)(186003)(26005)(83380400001)(47076005)(426003)(40460700003)(110136005)(54906003)(478600001)(316002)(1076003)(6666004)(84006005)(41080700001)(2101003)(83996005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:28:47.7362 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e543323-77a1-40d0-fe52-08db1e683e99 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: BN8NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4529 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 319cdd5a0bdc..4759f704bf5c 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:44:14 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 62DCFC6FD1D for ; Mon, 6 Mar 2023 17:30:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbjCFRaU (ORCPT ); Mon, 6 Mar 2023 12:30:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbjCFRaM (ORCPT ); Mon, 6 Mar 2023 12:30:12 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2062f.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e83::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 085344C04; Mon, 6 Mar 2023 09:29:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PE+6jGtt9K/KGNtW9rCo6vHf7ZErleLB//ttOMuolNS3LLvwQ+stYDCF4nUtfp4yAaRtvmYqC4qct5WW5/X7/0W+Ala9ZXAAGkvMTzTLKxbc1vACJyxfCirIl36Ft76dnHWzTn2b93xHTt/y7AlenleF9bAXZvBhv9kxUQXdTvL2eSvvYLGIilpQkUU/jRf/bsVFmmMfurbq2gouGh+spoG/mwlh5ZD1bv3i/e+ImUeyLfY53Z48gDkR0QWUwdA1rF6esDSOkKsN6F/hskS+h66Mw0JQjYB40yHjfTKg2qXYHCTJ0itjU3fiHoKsM+G0GrErM6ttowVCBdX176uCcA== 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=UjJw4Ews/fFST2W29oEA8nKlTYGBH/MUSfqfglbjQRc=; b=Mloa4wL5OsqbaxMR0npASGiCK5ZRXIJ8Q86Ex0ySf6ntHArQpwu2fDXHo1E1DKmhhrpBOhIXBHNQZN71UnHbLkLC/GVPFUw5WcNxqudqTHC2rSuQ8fu4CIOi+cEL5GR+vOz9P0QEOQoj4oPs2Gbbm1rw1IWJ0L0uwavGEBvd4Ex1itkVqTxZWnyEfqgJUNTBjfeS8nAYXUex8e8YVQqmzYy+ISkl6KZccNvisrclbQsUsJjYPETtSti5fQLXxQl5vRiKPQJT+7QSxQs/Iq017KMgSlk0GOQZ1yPynM841EpByU89z/npDR1KmaQSKIFJHF4t5EctGhotn0HAh+KhZA== 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=UjJw4Ews/fFST2W29oEA8nKlTYGBH/MUSfqfglbjQRc=; b=CqmvLfpsQYAEnP0qKgXDtME3ETtBorBHCLUGomGF17OvyAbNa1GJVlBkUOFzWYBtgo6OA6f4CbM64Pic/BnMDIArxE0ciSy2wu9KqU/CtqLCO2bVjVForaYfWZyVBeOz8560C6pbQwHo4LuCA3Suqj32k3RUsnjPfIbbov/cqHo= Received: from DM6PR18CA0009.namprd18.prod.outlook.com (2603:10b6:5:15b::22) by PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:29:13 +0000 Received: from CY4PEPF0000B8EE.namprd05.prod.outlook.com (2603:10b6:5:15b:cafe::44) by DM6PR18CA0009.outlook.office365.com (2603:10b6:5:15b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:29:13 +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 CY4PEPF0000B8EE.mail.protection.outlook.com (10.167.241.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.4 via Frontend Transport; Mon, 6 Mar 2023 17:29:12 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 6 Mar 2023 11:29:11 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:28:44 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 14/15] mtd: spi-nor: Add parallel memories support in spi-nor Date: Mon, 6 Mar 2023 22:51:08 +0530 Message-ID: <20230306172109.595464-15-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: CY4PEPF0000B8EE:EE_|PH7PR12MB5685:EE_ X-MS-Office365-Filtering-Correlation-Id: 59f4d31e-4041-4ab3-a484-08db1e684ddd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qcZGAE+Q/a89mkr9bFVlG6WGzJd9+s7/Dvd4Iwon1jefC1Q38an94UBfE/dcrPYv5ThLk5AiTjEOzXIFuWwpr3iZO683BTIqyvgNhv/HuWucc21U22FIQ2K2i1djxE/AKncYwl3inCezmsha5QscOHJvDCReFXJRRsHNXb1Hhb2HbEemyhvWWruk1ZXWAmAMwT3BYqjt47PcqheyXqUyORVpla4ll/KjXaNzs+HpG+GXwQRNzevLkcO+c1XpH/9EeQnoWFVkLUGGDhbkFo97sRG7vXqPM2CysbEvPFDBkR4fY7S0CY7Bt1VgoQk5I2UyqS5ntXLM2vFFIZkGz8DICh6Gj5s0s9Iac7wYe98zBaA6TQKZ1Pv5VCsJsVf6GCer4hNu08rMED5f1OZ8EQdZC6g6tYR4pjPEwYtOGPedkmlqLvfDotWFNGGQkKVPfzEH27aki0xCalp4oBUwzdPz1CfrH47AXm3a+DpnEMbCeHhY8M5p+OEwg4GRhiRTenmAm/UmkHKHcGviigsoD38rUQwuggVXXin/GXAvyGnOpEzl2cpPL7obSsC9K5OnwY4k4zA9U6BzhW13vL5C3bimKTEYbusDVVqlpoh/4rExZdli1O2MAtNg+3Xj9cC77dJHg65Iy1Hi8FWnoJr1wp9exS3G9N+h5Y+GZKQzuFnwvuCODzdYdqLOfC5tcluiQYVbx/QwTRQ3sWJ4GugEv8zrhThHuomHYgH49GCVcxknzxgbMJVdytrZVW6vzIXQjOBHFv8IdBnmXbQnthFZD9RtnbYZ5x+E25G1YYA2yoDKxvEBVDhD9nXN7uhlqShwnMGYnrs+bsh3rRxfoDwSjCwh2VLvdih7AX+9Q1kKARNZkzo= 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)(136003)(346002)(376002)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(1076003)(26005)(6666004)(36756003)(36860700001)(47076005)(426003)(82310400005)(921005)(356005)(40460700003)(86362001)(81166007)(40480700001)(1191002)(82740400003)(83380400001)(186003)(2616005)(336012)(70206006)(70586007)(41300700001)(8676002)(4326008)(2906002)(30864003)(8936002)(7276002)(7336002)(7366002)(7406005)(7416002)(5660300002)(478600001)(316002)(110136005)(54906003)(2101003)(36900700001)(84006005)(83996005)(41080700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:29:12.9391 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59f4d31e-4041-4ab3-a484-08db1e684ddd 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: CY4PEPF0000B8EE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5685 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 bb7326dc8b70..367cbb36ef69 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 @@ -2323,7 +2470,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 @@ -2341,7 +2496,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 @@ -2659,7 +2822,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); @@ -2881,24 +3059,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; @@ -2948,17 +3144,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; + } } } } @@ -3081,20 +3289,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", @@ -3184,7 +3411,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 e94107cc465e..4aedc9fbef32 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:44:14 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 9AA82C6FD1E for ; Mon, 6 Mar 2023 17:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbjCFRbo (ORCPT ); Mon, 6 Mar 2023 12:31:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230058AbjCFRb2 (ORCPT ); Mon, 6 Mar 2023 12:31:28 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F1436A1D5; Mon, 6 Mar 2023 09:30:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MQbl4zoj1kcPriEAKRrLdlNcHjMXgyhIil+/bNAOclk+SIA2yPqHZmZBGIGDgajLFVKf3Vs6GxIGg6MyYP6WwhlQge146ucEzvN8qiDmcim1Q2WOe2vSuKhldMR0wNnmoom9BDzEOlLMr8ifx2EgDuwV/vcrn3DbH4szTDkaWD5Z2rea2v6Cc0fhW+3cuA0hv3n/V76GYClgO3lRK0eiDlE9We0vjGXuHBqzE2AJm+BXcxTr6PYWlDJCdXUxITNuY6Tu+QS04beARN0lBkZip5ojWffMyXBWBaT93AAMB4oaqVViVkLM0uh31ElrRDg1a7Wiwjko34tsIKYAt/fSrA== 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=2pEjyARU/iDHF4qEL808MswcLI+5ZEPTvCc976Kw1g4=; b=YUtwnU1CjkFz45a0ldiWrzaVKLyTcT1rZSzuBlhhEQbFr/zNVL3N8TcGgQqFyhJMKbJfMCTfK6qCwdxH4/3goEV137WOHhOIHb5uqHOM24ddBSHnKP7shaLMQqV2MHnYQB3NX0XWD9UOkx10Ln/h4rCwiswtU9opF4QRudgWDPhIv5dJi+XMuyMYCiCEw8d2iG4B9r5qmgxr2K1F4J2bovaGsKqdFVUT5dqYR/AABqMRsdxn+JzGK0BDYH/1xRhjDd7azs3ooOne0gdEjOfdlhWOcEqrkEhpzxdafpSqW3jBVu1fImjK4bj6q+OeURajZz3NWp0TPhgTGHQf+1xlWg== 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=2pEjyARU/iDHF4qEL808MswcLI+5ZEPTvCc976Kw1g4=; b=m40pqWBebs4l0rN1O3v5vWW+xl8drhkuYDRot59GYbmX5C81OPbhBSwVJdBonrB4WsG5T1m4j6hy9aqWL+KSDWiMP6Dl2jTkEX0RyKekUmE5hxkolBuQqlCnhb0dYvHA4WsJo1DpnYnn8wM3OIl+aLDzlYCshsc61Uu9cAiods8= Received: from BN7PR06CA0048.namprd06.prod.outlook.com (2603:10b6:408:34::25) by CY8PR12MB8299.namprd12.prod.outlook.com (2603:10b6:930:6c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:29:40 +0000 Received: from BN8NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:408:34:cafe::b6) by BN7PR06CA0048.outlook.office365.com (2603:10b6:408:34::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:29:40 +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 BN8NAM11FT063.mail.protection.outlook.com (10.13.177.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:29:40 +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; Mon, 6 Mar 2023 11:29:39 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Mon, 6 Mar 2023 11:29:39 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:29:12 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 15/15] spi: spi-zynqmp-gqspi: Add parallel memories support in GQSPI driver Date: Mon, 6 Mar 2023 22:51:09 +0530 Message-ID: <20230306172109.595464-16-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-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: BN8NAM11FT063:EE_|CY8PR12MB8299:EE_ X-MS-Office365-Filtering-Correlation-Id: 3affa16c-80ce-4c67-a23b-08db1e685e05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LgLhUNXgl6Yy+nBga6v7THj/EQbJve9kHETbxJj2RP9lIl6OMXq2gnVea0m7qaksalEfXA2Q+2UrsV4Rwzr+YdrUF/iwyn5CfMdIY6SXcLI55rJ5er08hLMpDSLDPa3ggzgxQY/ftohClc7P69ed0ntwnG6aUiP30G2m0e/Y17mZV+f20HWwvvtcfsEvPTOiPIiwWhbnh9OgDE0OEYDbCj1HKbeUVupP7WANl+Dt66kNmgodsJ41H16vBPvswsVFdIoO0gXCwYa0Ucpd2RPc0j5tC7Cskv8+zsaS8+IWdGQuSRATr3F08PGjFHW3h3Yrwa07Pconvr85fXTE3Ogkk5SbnOEXxO7fywAV3TONYQhem610wQtXNTNxwdO2Ils01oiYvZ/jrKJ3PyWiQvIktUmJQjsT5A1MP6d1KegS2tBpuelflMyGzHLqr1Nwj7EQBhodcGwGKowvYkIGeCoHYnGO/HzyKi3ogvbri2gvcQRlj3QmPfUY/uz+jUsug/MHSVVpTJXJzJVqj/jAVli+0S3RSiPnCprqmT3QpQ8fz15HEoPoH9JXPXXjlA/QjIw2i/PDDrQ6crfckUN7BwsFFvxw9oSrGW4Px9U0/ZeSD1NyxwjxLHnCI2d+UKDXqmyV0ZBY8UStmq1+SSC66lbW08ceAfLYnCSh7LMbutHLi9J3+JmA9B1pGNK8mcQAXoY9CVa7sgYHw1xtPTKtImM4xmxfHomSQKGGMkwPO7JZYf7wpXvsKSv8jyKexWspO5yHuM3UyVpZOHylhXAj+f0voFS+s1gefXjqpYtIOPJnGCRUdkIZozoBW1Gs2VrVvmyGAC3ZGQ0Eze5PoXcOZ/ZwNh34eZYejbFDR7SmyAAuF3U= 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)(376002)(346002)(39860400002)(396003)(451199018)(40470700004)(46966006)(36840700001)(40460700003)(186003)(6666004)(81166007)(356005)(921005)(8936002)(36860700001)(41300700001)(8676002)(2906002)(82740400003)(5660300002)(70206006)(70586007)(4326008)(7366002)(7276002)(7416002)(7406005)(7336002)(426003)(478600001)(2616005)(1076003)(47076005)(26005)(36756003)(316002)(110136005)(54906003)(40480700001)(82310400005)(86362001)(1191002)(83380400001)(336012)(41080700001)(2101003)(36900700001)(84006005)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:29:40.4510 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3affa16c-80ce-4c67-a23b-08db1e685e05 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: BN8NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8299 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 4759f704bf5c..9e44371bfda2 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