public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: linux-mtd@lists.infradead.org
Cc: tglx@linutronix.de
Subject: Re: [PATCH] MTD: Add P3P440 MTD support
Date: Thu, 24 Nov 2005 21:44:59 +0100	[thread overview]
Message-ID: <200511242145.00013.sr@denx.de> (raw)
In-Reply-To: <1132831796.32542.183.camel@tglx.tec.linutronix.de>

[-- Attachment #1: Type: text/plain, Size: 4070 bytes --]

On Thursday 24 November 2005 12:29, Thomas Gleixner wrote:
> On Wed, 2005-11-23 at 13:11 +0100, Stefan Roese wrote:
> > This patch adds MTD support (NOR FLASH) for the Prodrive P3P440
> > (440GP) PMC module.
> >
> > Signed-off-by: Stefan Roese <sr@denx.de>
> >
> > +config MTD_P3P440
> > +       tristate "Flash devices mapped on Prodrive P3P440"
> > +       depends on MTD_CFI && P3P440
> > +       help
> > +         This enables access routined for the flash chips on the
> > Prodrive
>
> routined ?

Fixed.

> > +         P3P440 board.  If you have this board and would like to use the
> > +         flash chips on it, say 'Y'.
> > +
> > +#define RW_PART0_OF    0
> > +#define RW_PART0_SZ    0x180000
> > +#define RW_PART1_OF    RW_PART0_OF + RW_PART0_SZ
> > +#define RW_PART1_SZ    0x280000
> > +#define RW_PART2_OF    RW_PART1_OF + RW_PART1_SZ
> > +/* Partition 2 will be autosized dynamically... */
> > +#define RW_PART3_SZ    0x40000
> > +#define RW_PART4_SZ    0x40000
> > +
> > +static struct mtd_partition p3p440_flash_partitions[] = {
> > +       {
> > +               .name = "kernel",
> > +               .offset = RW_PART0_OF,
> > +               .size = RW_PART0_SZ
> > +       },
> > +       {
> > +               .name = "root",
> > +               .offset = RW_PART1_OF,
>
> Please use .offset = MTDPART_OFS_APPEND,

Done. Thanks for the tip.

<snip>

> > +               .size = RW_PART4_SZ,
> > +       }
> > +};
> > +
> > +struct map_info p3p440_flash_map = {
>
> static

Done.

> > +       .name = "p3p440-flash",
> > +       .bankwidth = 2,
> > +};
> > +
> > +static struct mtd_info *p3p440_mtd;
> > +
> > +int __init init_p3p440_flash(void)
>
> static

Dito.

> > +{
> > +       unsigned long long flash_base;
> > +       unsigned long flash_size;
> > +
> > +       flash_base = __res.bi_flashstart | 0x0000000100000000LL;
> > +       flash_size = __res.bi_flashsize;
> > +
> > +       p3p440_flash_map.size = flash_size;
> > +       p3p440_flash_map.phys = flash_base;
> > +       p3p440_flash_map.virt = ioremap64(flash_base,
> > +                                         p3p440_flash_map.size);
> > +
> > +
> > +       if (!p3p440_flash_map.virt) {
> > +               printk("init_p3p440_flash: failed to ioremap\n");
>
> printk log level missing

Done.

> > +               return -EIO;
> > +       }
> > +
> > +       /*
> > +        * Adjust partitions to flash size
> > +        */
> > +       p3p440_flash_partitions[2].size = p3p440_flash_map.size -
> > +               RW_PART0_SZ - RW_PART1_SZ - RW_PART3_SZ - RW_PART4_SZ;
>
> <NOT_NECESSARY_WITH_MTD_OFS_APPEND>
>
> > +       p3p440_flash_partitions[3].offset =
> > p3p440_flash_partitions[2].size + +               RW_PART2_OF;
> > +       p3p440_flash_partitions[4].offset =
> > p3p440_flash_partitions[3].size + +              
> > p3p440_flash_partitions[3].offset;
> > +
>
> </NOT_NECESSARY_WITH_MTD_OFS_APPEND>

Removed.

> > +       simple_map_init(&p3p440_flash_map);
> > +
> > +       p3p440_mtd = do_map_probe("cfi_probe", &p3p440_flash_map);
> > +
> > +       if (p3p440_mtd) {
> > +               p3p440_mtd->owner = THIS_MODULE;
> > +               return add_mtd_partitions(p3p440_mtd,
> > +                                         p3p440_flash_partitions,
> > +                                        
> > ARRAY_SIZE(p3p440_flash_partitions)); +       }
> > +
> > +       return -ENXIO;
> > +}
> > +
> > +static void __exit cleanup_p3p440_flash(void)
> > +{
> > +       if (p3p440_mtd) {
> > +               del_mtd_partitions(p3p440_mtd);
> > +               /* moved iounmap after map_destroy - armin */
>
> Is this comment relevant for understanding the code ?

Relict from "copy and paste". Removed.

> > +               map_destroy(p3p440_mtd);
> > +               iounmap((void *)p3p440_flash_map.virt);
>
> Bogus type cast	of void* to void*

Fixed.

Please let me know, if this version is still not acceptable:

This patch adds MTD support (NOR FLASH) for the Prodrive P3P440
(440GP) PMC module.

Signed-off-by: Stefan Roese <sr@denx.de>

Best regards,
Stefan

[-- Attachment #2: add-p3p440-mtd-support-2.patch --]
[-- Type: text/x-diff, Size: 4240 bytes --]

diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 846a533..97c37ec 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -339,6 +339,14 @@ config MTD_OCOTEA
 	  Ocotea board. If you have one of these boards and would like to
 	  use the flash chips on it, say 'Y'.
 
+config MTD_P3P440
+	tristate "Flash devices mapped on Prodrive P3P440"
+	depends on MTD_CFI && P3P440
+	help
+	  This enables access routines for the flash chips on the Prodrive
+	  P3P440 board.  If you have this board and would like to use the
+	  flash chips on it, say 'Y'.
+
 config MTD_REDWOOD
 	tristate "CFI Flash devices mapped on IBM Redwood"
 	depends on MTD_CFI && ( REDWOOD_4 || REDWOOD_5 || REDWOOD_6 )
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 7d9e940..73a681a 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -73,3 +73,4 @@ obj-$(CONFIG_MTD_OMAP_NOR)	+= omap_nor.o
 obj-$(CONFIG_MTD_PQ2FADS)	+= pq2fads.o
 obj-$(CONFIG_MTD_MTX1)		+= mtx-1_flash.o
 obj-$(CONFIG_MTD_TQM834x)	+= tqm834x.o
+obj-$(CONFIG_MTD_P3P440)	+= p3p440.o
diff --git a/drivers/mtd/maps/p3p440.c b/drivers/mtd/maps/p3p440.c
new file mode 100644
index 0000000..54be1e1
--- /dev/null
+++ b/drivers/mtd/maps/p3p440.c
@@ -0,0 +1,126 @@
+/*
+ * $Id: $
+ *
+ * drivers/mtd/maps/p3p440.c
+ *
+ * Mapping for Prodrive P3P440 flash
+ *
+ * Copyright (c) 2005 DENX Software Engineering
+ * Stefan Roese <sr@denx.de>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/io.h>
+#include <asm/ibm4xx.h>
+#include <asm/ppcboot.h>
+
+extern bd_t __res;
+
+#define RW_PART0_OF	0
+#define RW_PART0_SZ	0x180000
+#define RW_PART1_SZ	0x280000
+/* Partition 2 will be autosized dynamically... */
+#define RW_PART3_SZ	0x40000
+#define RW_PART4_SZ	0x40000
+
+static struct mtd_partition p3p440_flash_partitions[] = {
+	{
+		.name = "kernel",
+		.offset = RW_PART0_OF,
+		.size = RW_PART0_SZ
+	},
+	{
+		.name = "root",
+		.offset = MTDPART_OFS_APPEND,
+		.size = RW_PART1_SZ,
+	},
+	{
+		.name = "user",
+		.offset = MTDPART_OFS_APPEND,
+/*		.size = RW_PART2_SZ */ /* will be adjusted dynamically */
+	},
+	{
+		.name = "env",
+		.offset = MTDPART_OFS_APPEND,
+		.size = RW_PART3_SZ,
+	},
+	{
+		.name = "u-boot",
+		.offset = MTDPART_OFS_APPEND,
+		.size = RW_PART4_SZ,
+	}
+};
+
+static struct map_info p3p440_flash_map = {
+	.name = "p3p440-flash",
+	.bankwidth = 2,
+};
+
+static struct mtd_info *p3p440_mtd;
+
+static int __init init_p3p440_flash(void)
+{
+	unsigned long long flash_base;
+	unsigned long flash_size;
+
+	flash_base = __res.bi_flashstart | 0x0000000100000000LL;
+	flash_size = __res.bi_flashsize;
+
+	p3p440_flash_map.size = flash_size;
+	p3p440_flash_map.phys = flash_base;
+	p3p440_flash_map.virt = ioremap64(flash_base, p3p440_flash_map.size);
+
+	if (!p3p440_flash_map.virt) {
+		printk(KERN_NOTICE "init_p3p440_flash: failed to ioremap\n");
+		return -EIO;
+	}
+
+	/*
+	 * Adjust partitions to flash size
+	 */
+	p3p440_flash_partitions[2].size = p3p440_flash_map.size -
+		RW_PART0_SZ - RW_PART1_SZ - RW_PART3_SZ - RW_PART4_SZ;
+
+	simple_map_init(&p3p440_flash_map);
+
+	p3p440_mtd = do_map_probe("cfi_probe", &p3p440_flash_map);
+
+	if (p3p440_mtd) {
+		p3p440_mtd->owner = THIS_MODULE;
+		return add_mtd_partitions(p3p440_mtd,
+					  p3p440_flash_partitions,
+					  ARRAY_SIZE(p3p440_flash_partitions));
+	}
+
+	return -ENXIO;
+}
+
+static void __exit cleanup_p3p440_flash(void)
+{
+	if (p3p440_mtd) {
+		del_mtd_partitions(p3p440_mtd);
+		map_destroy(p3p440_mtd);
+		iounmap(p3p440_flash_map.virt);
+	}
+}
+
+module_init(init_p3p440_flash);
+module_exit(cleanup_p3p440_flash);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Stefan Roese <sr@denx.de>");
+MODULE_DESCRIPTION("MTD map and partitions for Prodrive P3P440 board");

  reply	other threads:[~2005-11-24 21:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-21 10:34 [PATCH] MTD: Add support for the PM82x Boards Heiko Schocher
2005-11-21 20:29 ` David Woodhouse
2005-11-22  6:18   ` Heiko Schocher
2005-11-23 10:39     ` Thomas Gleixner
2005-11-23 12:11 ` [PATCH] MTD: Add P3P440 MTD support Stefan Roese
2005-11-24 11:29   ` Thomas Gleixner
2005-11-24 20:44     ` Stefan Roese [this message]
2005-11-24 21:24       ` Thomas Gleixner

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=200511242145.00013.sr@denx.de \
    --to=sr@denx.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=tglx@linutronix.de \
    /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