From: Yogesh Gaur <yogeshnarayan.gaur@nxp.com>
To: linux-mtd@lists.infradead.org, boris.brezillon@bootlin.com,
marek.vasut@gmail.com, linux-spi@vger.kernel.org,
devicetree@vger.kernel.org
Cc: robh@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org,
linux-arm-kernel@lists.infradead.org,
computersforpeace@gmail.com, frieder.schrempf@exceet.de,
linux-kernel@vger.kernel.org,
Yogesh Gaur <yogeshnarayan.gaur@nxp.com>
Subject: [PATCH 1/7] spi: add slave device size in spi_device struct
Date: Fri, 31 Aug 2018 15:59:58 +0530 [thread overview]
Message-ID: <1535711404-29528-2-git-send-email-yogeshnarayan.gaur@nxp.com> (raw)
In-Reply-To: <1535711404-29528-1-git-send-email-yogeshnarayan.gaur@nxp.com>
Add 'size' data variable in spi_device struct.
This is to save the size of the connected slave device.
After slave device scan, spi_nor_scan, size being assigned to this
from MTD layer.
SFDP read is being requested before completion of spi_nor_scan()
routine, thus populate device size before making read request
to the SPI controller.
Signed-off-by: Yogesh Gaur <yogeshnarayan.gaur@nxp.com>
---
drivers/mtd/devices/m25p80.c | 6 ++++++
drivers/mtd/spi-nor/spi-nor.c | 2 ++
include/linux/spi/spi.h | 2 ++
3 files changed, 10 insertions(+)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index fe260cc..6c7ad86 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -124,6 +124,10 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
/* convert the dummy cycles to the number of bytes */
op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) / 8;
+ /* for case of SFDP header read commands, populate spi device size */
+ if (flash->spimem->spi->size == 0)
+ flash->spimem->spi->size = nor->mtd.size;
+
while (remaining) {
op.data.nbytes = remaining < UINT_MAX ? remaining : UINT_MAX;
ret = spi_mem_adjust_op_size(flash->spimem, &op);
@@ -215,6 +219,8 @@ static int m25p_probe(struct spi_mem *spimem)
if (ret)
return ret;
+ spi->size = nor->mtd.size;
+
return mtd_device_register(&nor->mtd, data ? data->parts : NULL,
data ? data->nr_parts : 0);
}
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 6042df8..b066bed 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -2864,6 +2864,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
if (info->flags & SPI_S3AN)
nor->flags |= SNOR_F_READY_XSR_RDY;
+ mtd->size = info->sector_size * info->n_sectors;
+
/* Parse the Serial Flash Discoverable Parameters table. */
ret = spi_nor_init_params(nor, info, ¶ms);
if (ret)
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index a64235e..558aeed 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -127,6 +127,7 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats,
* for driver coldplugging, and in uevents used for hotplugging
* @cs_gpio: gpio number of the chipselect line (optional, -ENOENT when
* not using a GPIO line)
+ * @size: size of the connected slave device
*
* @statistics: statistics for the spi_device
*
@@ -168,6 +169,7 @@ struct spi_device {
void *controller_data;
char modalias[SPI_NAME_SIZE];
int cs_gpio; /* chip select gpio */
+ u32 size; /* size of slave device */
/* the statistics */
struct spi_statistics statistics;
--
2.7.4
next prev parent reply other threads:[~2018-08-31 10:29 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 10:29 [PATCH 0/7] spi: spi-mem: Add a driver for NXP FlexSPI controller Yogesh Gaur
2018-08-31 10:29 ` Yogesh Gaur [this message]
2018-08-31 11:41 ` [PATCH 1/7] spi: add slave device size in spi_device struct Geert Uytterhoeven
2018-08-31 11:58 ` Lothar Waßmann
2018-09-03 4:47 ` Yogesh Narayan Gaur
2018-09-03 8:36 ` Boris Brezillon
2018-08-31 10:29 ` [PATCH 2/7] spi: add flags for octal I/O data transfer Yogesh Gaur
2018-08-31 10:30 ` [PATCH 3/7] spi: spi-mem: Add a driver for NXP FlexSPI controller Yogesh Gaur
2018-09-04 14:58 ` Boris Brezillon
2018-09-05 10:07 ` Yogesh Narayan Gaur
2018-09-06 8:26 ` Frieder Schrempf
2018-09-06 11:35 ` Yogesh Narayan Gaur
2018-09-06 11:43 ` Boris Brezillon
2018-09-06 12:23 ` Yogesh Narayan Gaur
2018-08-31 10:30 ` [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driver Yogesh Gaur
2018-09-03 9:54 ` Prabhakar Kushwaha
2018-09-04 5:37 ` Yogesh Narayan Gaur
2018-09-04 12:46 ` Boris Brezillon
2018-09-06 7:08 ` Jagdish Gediya
2018-09-04 1:33 ` Rob Herring
2018-08-31 10:30 ` [PATCH 5/7] arm64: dts: lx2160a: add fspi node property Yogesh Gaur
2018-09-03 3:01 ` Shawn Guo
2018-08-31 10:30 ` [PATCH 6/7] arm64: defconfig: enable NXP FlexSPI driver Yogesh Gaur
2018-08-31 10:30 ` [PATCH 7/7] MAINTAINERS: add maintainers for the " Yogesh Gaur
2018-09-04 12:43 ` [PATCH 0/7] spi: spi-mem: Add a driver for NXP FlexSPI controller Boris Brezillon
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=1535711404-29528-2-git-send-email-yogeshnarayan.gaur@nxp.com \
--to=yogeshnarayan.gaur@nxp.com \
--cc=boris.brezillon@bootlin.com \
--cc=computersforpeace@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=frieder.schrempf@exceet.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=marek.vasut@gmail.com \
--cc=mark.rutland@arm.com \
--cc=robh@kernel.org \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).