From: "Heiko Stübner" <heiko@sntech•de>
To: broonie@kernel•org, miquel.raynal@bootlin•com, richard@nod•at,
vigneshr@ti•com, jic23@kernel•org, tudor.ambarus@microchip•com,
pratyush@kernel•org, sanju.mehta@amd•com,
chin-ting_kuo@aspeedtech•com, clg@kaod•org, kdasu.kdev@gmail•com,
f.fainelli@gmail•com, rjui@broadcom•com, sbranden@broadcom•com,
eajames@linux•ibm.com, olteanv@gmail•com, han.xu@nxp•com,
john.garry@huawei•com, shawnguo@kernel•org,
s.hauer@pengutronix•de, narmstrong@baylibre•com,
khilman@baylibre•com, matthias.bgg@gmail•com, haibo.chen@nxp•com,
linus.walleij@linaro•org, daniel@zonque•org,
haojian.zhuang@gmail•com, robert.jarzmik@free•fr,
agross@kernel•org, bjorn.andersson@linaro•org,
krzysztof.kozlowski@linaro•org, andi@etezian•org,
mcoquelin.stm32@gmail•com, alexandre.torgue@foss•st.com,
wens@csie•org, jernej.skrabec@gmail•com, samuel@sholland•org,
masahisa.kojima@linaro•org, jaswinder.singh@linaro•org,
rostedt@goodmis•org, mingo@redhat•com, l.stelmach@samsung•com,
davem@davemloft•net, edumazet@google•com, kuba@kernel•org,
pabeni@redhat•com, alex.aring@gmail•com,
stefan@datenfreihafen•org, kvalo@kernel•org,
thierry.reding@gmail•com, jonathanh@nvidia•com,
skomatineni@nvidia•com, sumit.semwal@linaro•org,
christian.koenig@amd•com, j.neuschaefer@gmx•net,
vireshk@kernel•org, rmfrfs@gmail•com, johan@kernel•org,
elder@kernel•org, gregkh@linuxfoundation•org,
Amit Kumar Mahapatra <amit.kumar-mahapatra@amd•com>
Cc: git@amd•com, linux-spi@vger•kernel.org,
linux-kernel@vger•kernel.org, joel@jms•id.au, andrew@aj•id.au,
radu_nicolae.pirea@upb•ro, nicolas.ferre@microchip•com,
alexandre.belloni@bootlin•com, claudiu.beznea@microchip•com,
bcm-kernel-feedback-list@broadcom•com, fancer.lancer@gmail•com,
kernel@pengutronix•de, festevam@gmail•com, linux-imx@nxp•com,
jbrunet@baylibre•com, martin.blumenstingl@googlemail•com,
avifishman70@gmail•com, tmaimon77@gmail•com,
tali.perry1@gmail•com, venture@google•com, yuenn@google•com,
benjaminfair@google•com, yogeshgaur.83@gmail•com,
konrad.dybcio@somainline•org, alim.akhtar@samsung•com,
ldewangan@nvidia•com, michal.simek@amd•com,
linux-aspeed@lists•ozlabs.org, openbmc@lists•ozlabs.org,
linux-arm-kernel@lists•infradead.org,
linux-rpi-kernel@lists•infradead.org,
linux-amlogic@lists•infradead.org,
linux-mediatek@lists•infradead.org,
linux-arm-msm@vger•kernel.org,
linux-rockchip@lists•infradead.org,
linux-samsung-soc@vger•kernel.org,
linux-stm32@st-md-mailman•stormreply.com,
linux-sunxi@lists•linux.dev, linux-tegra@vger•kernel.org,
netdev@vger•kernel.org, linux-wpan@vger•kernel.org,
libertas-dev@lists•infradead.org, linux-wireless@vger•kernel.org,
linux-mtd@lists•infradead.org, lars@metafoo•de,
Michael.Hennerich@analog•com, linux-iio@vger•kernel.org,
michael@walle•cc, palmer@dabbelt•com,
linux-riscv@lists•infradead.org, linux-media@vger•kernel.org,
dri-devel@lists•freedesktop.org, greybus-dev@lists•linaro.org,
linux-staging@lists•linux.dev, amitrkcian2002@gmail•com
Subject: Re: [PATCH v2 02/13] spi: Replace all spi->chip_select and spi->cs_gpiod references with function call
Date: Fri, 20 Jan 2023 10:47:37 +0100 [thread overview]
Message-ID: <3658396.MHq7AAxBmi@diego> (raw)
In-Reply-To: <20230119185342.2093323-3-amit.kumar-mahapatra@amd.com>
Am Donnerstag, 19. Januar 2023, 19:53:31 CET schrieb Amit Kumar Mahapatra:
> 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 <amit.kumar-mahapatra@amd•com>
> ---
> 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,
>
> /* set the Controller */
> ctrl |= SFC_CTRL_PHASE_SEL_NEGETIVE;
> - cmd |= mem->spi->chip_select << SFC_CMD_CS_SHIFT;
> + cmd |= spi_get_chipselect(mem->spi, 0) << SFC_CMD_CS_SHIFT;
>
> dev_dbg(sfc->dev, "sfc addr.nbytes=%x(x%d) dummy.nbytes=%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 *spi, bool enable)
> bool cs_asserted = spi->mode & SPI_CS_HIGH ? enable : !enable;
>
> /* Return immediately for no-op */
> - if (cs_asserted == rs->cs_asserted[spi->chip_select])
> + if (cs_asserted == rs->cs_asserted[spi_get_chipselect(spi, 0)])
> return;
>
> if (cs_asserted) {
> /* Keep things powered as long as CS is asserted */
> pm_runtime_get_sync(rs->dev);
>
> - 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)));
>
> /* Drop reference from when we first asserted CS */
> pm_runtime_put(rs->dev);
> }
>
> - rs->cs_asserted[spi->chip_select] = cs_asserted;
> + rs->cs_asserted[spi_get_chipselect(spi, 0)] = cs_asserted;
> }
>
> 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 |= CR0_FBM_LSB << CR0_FBM_OFFSET;
> if (spi->mode & SPI_CS_HIGH)
> - cr0 |= BIT(spi->chip_select) << CR0_SOI_OFFSET;
> + cr0 |= BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET;
>
> if (xfer->rx_buf && xfer->tx_buf)
> cr0 |= CR0_XFM_TR << CR0_XFM_OFFSET;
> @@ -724,7 +726,7 @@ static int rockchip_spi_setup(struct spi_device *spi)
> struct rockchip_spi *rs = spi_controller_get_devdata(spi->controller);
> u32 cr0;
>
> - 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)
>
> cr0 &= ~(0x3 << CR0_SCPH_OFFSET);
> cr0 |= ((spi->mode & 0x3) << CR0_SCPH_OFFSET);
> - if (spi->mode & SPI_CS_HIGH && spi->chip_select <= 1)
> - cr0 |= BIT(spi->chip_select) << CR0_SOI_OFFSET;
> - else if (spi->chip_select <= 1)
> - cr0 &= ~(BIT(spi->chip_select) << CR0_SOI_OFFSET);
> + if (spi->mode & SPI_CS_HIGH && spi_get_chipselect(spi, 0) <= 1)
> + cr0 |= BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET;
> + else if (spi_get_chipselect(spi, 0) <= 1)
> + cr0 &= ~(BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET);
>
> writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0);
for the two Rockchip drivers
Acked-by: Heiko Stuebner <heiko@sntech•de>
next prev parent reply other threads:[~2023-01-20 9:49 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-19 18:53 [PATCH v2 00/13] spi: Add support for stacked/parallel memories Amit Kumar Mahapatra
2023-01-19 18:53 ` [PATCH v2 01/13] spi: Add APIs in spi core to set/get spi->chip_select and spi->cs_gpiod Amit Kumar Mahapatra
2023-01-23 12:44 ` Michal Simek
2023-01-19 18:53 ` [PATCH v2 02/13] spi: Replace all spi->chip_select and spi->cs_gpiod references with function call Amit Kumar Mahapatra
2023-01-20 9:47 ` Heiko Stübner [this message]
2023-01-23 12:46 ` Michal Simek
2023-01-23 13:10 ` Cédric Le Goater
2023-01-23 14:20 ` Dhruva Gole
2023-01-23 15:04 ` Serge Semin
2023-01-23 17:16 ` Patrice CHOTARD
2023-01-25 0:57 ` William Zhang
2023-02-01 15:15 ` Mark Brown
2023-01-19 18:53 ` [PATCH v2 03/13] net: " Amit Kumar Mahapatra
2023-01-20 10:30 ` Lukasz Stelmach
2023-01-23 12:46 ` Michal Simek
2023-01-19 18:53 ` [PATCH v2 04/13] iio: imu: " Amit Kumar Mahapatra
2023-01-21 16:52 ` Jonathan Cameron
2023-01-23 12:47 ` Michal Simek
2023-01-19 18:53 ` [PATCH v2 05/13] mtd: devices: " Amit Kumar Mahapatra
2023-01-23 12:47 ` Michal Simek
2023-01-19 18:53 ` [PATCH v2 06/13] staging: " Amit Kumar Mahapatra
2023-01-20 10:09 ` Greg KH
2023-01-23 12:47 ` Michal Simek
2023-01-19 18:53 ` [PATCH v2 07/13] platform/x86: serial-multi-instantiate: " Amit Kumar Mahapatra
2023-01-23 12:48 ` Michal Simek
2023-01-19 18:53 ` [PATCH v2 08/13] spi: Add stacked and parallel memories support in SPI core Amit Kumar Mahapatra
2023-01-19 18:53 ` [PATCH v2 09/13] mtd: spi-nor: Add APIs to set/get nor->params Amit Kumar Mahapatra
2023-01-19 18:53 ` [PATCH v2 10/13] mtd: spi-nor: Add stacked memories support in spi-nor Amit Kumar Mahapatra
2023-01-23 12:40 ` Michal Simek
2023-01-19 18:53 ` [PATCH v2 11/13] spi: spi-zynqmp-gqspi: Add stacked memories support in GQSPI driver Amit Kumar Mahapatra
2023-01-19 18:53 ` [PATCH v2 12/13] mtd: spi-nor: Add parallel memories support in spi-nor Amit Kumar Mahapatra
2023-01-19 18:53 ` [PATCH v2 13/13] spi: spi-zynqmp-gqspi: Add parallel memories support in GQSPI driver Amit Kumar Mahapatra
2023-02-01 16:57 ` (subset) [PATCH v2 00/13] spi: Add support for stacked/parallel memories Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3658396.MHq7AAxBmi@diego \
--to=heiko@sntech$(echo .)de \
--cc=Michael.Hennerich@analog$(echo .)com \
--cc=agross@kernel$(echo .)org \
--cc=alex.aring@gmail$(echo .)com \
--cc=alexandre.belloni@bootlin$(echo .)com \
--cc=alexandre.torgue@foss$(echo .)st.com \
--cc=alim.akhtar@samsung$(echo .)com \
--cc=amit.kumar-mahapatra@amd$(echo .)com \
--cc=amitrkcian2002@gmail$(echo .)com \
--cc=andi@etezian$(echo .)org \
--cc=andrew@aj$(echo .)id.au \
--cc=avifishman70@gmail$(echo .)com \
--cc=bcm-kernel-feedback-list@broadcom$(echo .)com \
--cc=benjaminfair@google$(echo .)com \
--cc=bjorn.andersson@linaro$(echo .)org \
--cc=broonie@kernel$(echo .)org \
--cc=chin-ting_kuo@aspeedtech$(echo .)com \
--cc=christian.koenig@amd$(echo .)com \
--cc=claudiu.beznea@microchip$(echo .)com \
--cc=clg@kaod$(echo .)org \
--cc=daniel@zonque$(echo .)org \
--cc=davem@davemloft$(echo .)net \
--cc=dri-devel@lists$(echo .)freedesktop.org \
--cc=eajames@linux$(echo .)ibm.com \
--cc=edumazet@google$(echo .)com \
--cc=elder@kernel$(echo .)org \
--cc=f.fainelli@gmail$(echo .)com \
--cc=fancer.lancer@gmail$(echo .)com \
--cc=festevam@gmail$(echo .)com \
--cc=git@amd$(echo .)com \
--cc=gregkh@linuxfoundation$(echo .)org \
--cc=greybus-dev@lists$(echo .)linaro.org \
--cc=haibo.chen@nxp$(echo .)com \
--cc=han.xu@nxp$(echo .)com \
--cc=haojian.zhuang@gmail$(echo .)com \
--cc=j.neuschaefer@gmx$(echo .)net \
--cc=jaswinder.singh@linaro$(echo .)org \
--cc=jbrunet@baylibre$(echo .)com \
--cc=jernej.skrabec@gmail$(echo .)com \
--cc=jic23@kernel$(echo .)org \
--cc=joel@jms$(echo .)id.au \
--cc=johan@kernel$(echo .)org \
--cc=john.garry@huawei$(echo .)com \
--cc=jonathanh@nvidia$(echo .)com \
--cc=kdasu.kdev@gmail$(echo .)com \
--cc=kernel@pengutronix$(echo .)de \
--cc=khilman@baylibre$(echo .)com \
--cc=konrad.dybcio@somainline$(echo .)org \
--cc=krzysztof.kozlowski@linaro$(echo .)org \
--cc=kuba@kernel$(echo .)org \
--cc=kvalo@kernel$(echo .)org \
--cc=l.stelmach@samsung$(echo .)com \
--cc=lars@metafoo$(echo .)de \
--cc=ldewangan@nvidia$(echo .)com \
--cc=libertas-dev@lists$(echo .)infradead.org \
--cc=linus.walleij@linaro$(echo .)org \
--cc=linux-amlogic@lists$(echo .)infradead.org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-arm-msm@vger$(echo .)kernel.org \
--cc=linux-aspeed@lists$(echo .)ozlabs.org \
--cc=linux-iio@vger$(echo .)kernel.org \
--cc=linux-imx@nxp$(echo .)com \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-media@vger$(echo .)kernel.org \
--cc=linux-mediatek@lists$(echo .)infradead.org \
--cc=linux-mtd@lists$(echo .)infradead.org \
--cc=linux-riscv@lists$(echo .)infradead.org \
--cc=linux-rockchip@lists$(echo .)infradead.org \
--cc=linux-rpi-kernel@lists$(echo .)infradead.org \
--cc=linux-samsung-soc@vger$(echo .)kernel.org \
--cc=linux-spi@vger$(echo .)kernel.org \
--cc=linux-staging@lists$(echo .)linux.dev \
--cc=linux-stm32@st-md-mailman$(echo .)stormreply.com \
--cc=linux-sunxi@lists$(echo .)linux.dev \
--cc=linux-tegra@vger$(echo .)kernel.org \
--cc=linux-wireless@vger$(echo .)kernel.org \
--cc=linux-wpan@vger$(echo .)kernel.org \
--cc=martin.blumenstingl@googlemail$(echo .)com \
--cc=masahisa.kojima@linaro$(echo .)org \
--cc=matthias.bgg@gmail$(echo .)com \
--cc=mcoquelin.stm32@gmail$(echo .)com \
--cc=michael@walle$(echo .)cc \
--cc=michal.simek@amd$(echo .)com \
--cc=mingo@redhat$(echo .)com \
--cc=miquel.raynal@bootlin$(echo .)com \
--cc=narmstrong@baylibre$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nicolas.ferre@microchip$(echo .)com \
--cc=olteanv@gmail$(echo .)com \
--cc=openbmc@lists$(echo .)ozlabs.org \
--cc=pabeni@redhat$(echo .)com \
--cc=palmer@dabbelt$(echo .)com \
--cc=pratyush@kernel$(echo .)org \
--cc=radu_nicolae.pirea@upb$(echo .)ro \
--cc=richard@nod$(echo .)at \
--cc=rjui@broadcom$(echo .)com \
--cc=rmfrfs@gmail$(echo .)com \
--cc=robert.jarzmik@free$(echo .)fr \
--cc=rostedt@goodmis$(echo .)org \
--cc=s.hauer@pengutronix$(echo .)de \
--cc=samuel@sholland$(echo .)org \
--cc=sanju.mehta@amd$(echo .)com \
--cc=sbranden@broadcom$(echo .)com \
--cc=shawnguo@kernel$(echo .)org \
--cc=skomatineni@nvidia$(echo .)com \
--cc=stefan@datenfreihafen$(echo .)org \
--cc=sumit.semwal@linaro$(echo .)org \
--cc=tali.perry1@gmail$(echo .)com \
--cc=thierry.reding@gmail$(echo .)com \
--cc=tmaimon77@gmail$(echo .)com \
--cc=tudor.ambarus@microchip$(echo .)com \
--cc=venture@google$(echo .)com \
--cc=vigneshr@ti$(echo .)com \
--cc=vireshk@kernel$(echo .)org \
--cc=wens@csie$(echo .)org \
--cc=yogeshgaur.83@gmail$(echo .)com \
--cc=yuenn@google$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox