LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mingkai Hu <Mingkai.hu@freescale.com>
To: linuxppc-dev@ozlabs.org, spi-devel-general@lists.sourceforge.net
Cc: kumar.gala@freescale.com, Mingkai Hu <Mingkai.hu@freescale.com>
Subject: [PATCH v2 3/6] mtd: m25p80: add support to parse the SPI flash's partitions
Date: Mon, 2 Aug 2010 15:52:01 +0800	[thread overview]
Message-ID: <1280735524-17547-4-git-send-email-Mingkai.hu@freescale.com> (raw)
In-Reply-To: <1280735524-17547-3-git-send-email-Mingkai.hu@freescale.com>

Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
---

v2:
 - Move the flash partition function from of_spi.c to MTD driver

 drivers/mtd/devices/m25p80.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 81e49a9..5f00075 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -752,6 +752,31 @@ static const struct spi_device_id *__devinit jedec_probe(struct spi_device *spi)
 	return NULL;
 }
 
+/*
+ * parse_flash_partition - Parse the flash partition on the SPI bus
+ * @spi: Pointer to spi_device device
+ */
+void parse_flash_partition(struct spi_device *spi)
+{
+	struct mtd_partition *parts;
+	struct flash_platform_data *pdata;
+	int nr_parts = 0;
+	struct device_node *np = spi->dev.of_node;
+
+	nr_parts = of_mtd_parse_partitions(&spi->dev, np, &parts);
+	if (!nr_parts)
+		return;
+
+	pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return;
+
+	pdata->parts = parts;
+	pdata->nr_parts = nr_parts;
+	spi->dev.platform_data = pdata;
+
+	return;
+}
 
 /*
  * board specific setup should have ensured the SPI clock used here
@@ -771,6 +796,10 @@ static int __devinit m25p_probe(struct spi_device *spi)
 	 * a chip ID, try the JEDEC id commands; they'll work for most
 	 * newer chips, even if we don't recognize the particular chip.
 	 */
+
+	/* Parse the flash partition */
+	parse_flash_partition(spi);
+
 	data = spi->dev.platform_data;
 	if (data && data->type) {
 		const struct spi_device_id *plat_id;
-- 
1.6.4

  reply	other threads:[~2010-08-02  8:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-02  7:51 [PATCH v2 0/6] refactor spi_mpc8xxx.c and add eSPI controller support Mingkai Hu
2010-08-02  7:51 ` [PATCH v2 1/6] spi/mpc8xxx: refactor the common code for SPI/eSPI controller Mingkai Hu
2010-08-02  7:52   ` [PATCH v2 2/6] eSPI: add eSPI controller support Mingkai Hu
2010-08-02  7:52     ` Mingkai Hu [this message]
2010-08-02  7:52       ` [PATCH v2 4/6] mtd: m25p80: add a read function to read page by page Mingkai Hu
2010-08-02  7:52         ` [PATCH v2 5/6] powerpc/of: add eSPI controller dts bindings Mingkai Hu
2010-08-02  7:52           ` [PATCH v2 6/6] DTS: add SPI flash(s25fl128p01) support on p4080ds and mpc8536ds board Mingkai Hu
2010-08-10  7:10             ` Grant Likely
2010-09-02  8:30               ` Hu Mingkai-B21284
2010-08-10  7:00         ` [PATCH v2 4/6] mtd: m25p80: add a read function to read page by page Grant Likely
2010-08-10 13:44           ` [spi-devel-general] " David Brownell
2010-09-02  9:04           ` Hu Mingkai-B21284
2010-08-10  6:56       ` [PATCH v2 3/6] mtd: m25p80: add support to parse the SPI flash's partitions Grant Likely
2010-08-10  7:14         ` [spi-devel-general] " David Brownell
2010-08-10  7:16           ` Grant Likely
2010-08-10  6:44     ` [PATCH v2 2/6] eSPI: add eSPI controller support Grant Likely
2010-09-02  8:28       ` Hu Mingkai-B21284
2010-08-10  6:40   ` [PATCH v2 1/6] spi/mpc8xxx: refactor the common code for SPI/eSPI controller Grant Likely
2010-09-02  8:27     ` Hu Mingkai-B21284

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=1280735524-17547-4-git-send-email-Mingkai.hu@freescale.com \
    --to=mingkai.hu@freescale.com \
    --cc=kumar.gala@freescale.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=spi-devel-general@lists.sourceforge.net \
    /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