linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Arctic-2 MTD driver
@ 2002-12-16  2:09 David Gibson
  2002-12-16  8:46 ` Marius Groeger
  2002-12-16 14:43 ` Tom Rini
  0 siblings, 2 replies; 7+ messages in thread
From: David Gibson @ 2002-12-16  2:09 UTC (permalink / raw)
  To: linuxppc-embedded


Having committed the core support code for the Arctic-2, here come
some drivers for it.  Below is an MTD map for the Arctic-2, derived
from beech-mtd.c.  Essentially all it does is provide suitable
hardwired partitions.

Again, any comments before I commit this?

diff -urN /home/dgibson/kernel/linuxppc_2_4_devel/drivers/mtd/maps/Config.in linux-bartholomew/drivers/mtd/maps/Config.in
--- /home/dgibson/kernel/linuxppc_2_4_devel/drivers/mtd/maps/Config.in	2002-09-13 16:01:34.000000000 +1000
+++ linux-bartholomew/drivers/mtd/maps/Config.in	2002-12-12 15:28:27.000000000 +1100
@@ -57,6 +57,9 @@
    if [ "$CONFIG_BEECH" = "y" ]; then
       dep_tristate '  CFI Flash device mapped on IBM Beech' CONFIG_MTD_BEECH $CONFIG_MTD_CFI
    fi
+   if [ "$CONFIG_ARCTIC2" = "y" ]; then
+      dep_tristate '  CFI Flash device mapped on IBM Arctic' CONFIG_MTD_ARCTIC $CONFIG_MTD_CFI
+   fi
    dep_tristate '  CFI Flash device mapped on D-Box2' CONFIG_MTD_DBOX2 $CONFIG_MTD_CFI
    dep_tristate '  CFI Flash device mapping on FlagaDM' CONFIG_MTD_CFI_FLAGADM $CONFIG_MTD_CFI
 fi
diff -urN /home/dgibson/kernel/linuxppc_2_4_devel/drivers/mtd/maps/Makefile linux-bartholomew/drivers/mtd/maps/Makefile
--- /home/dgibson/kernel/linuxppc_2_4_devel/drivers/mtd/maps/Makefile	2002-09-13 16:08:05.000000000 +1000
+++ linux-bartholomew/drivers/mtd/maps/Makefile	2002-12-12 15:28:08.000000000 +1100
@@ -44,5 +44,6 @@
 obj-$(CONFIG_MTD_MOT_MVP)	+= mot-mvp.o
 obj-$(CONFIG_MTD_EBONY)		+= ebony.o
 obj-$(CONFIG_MTD_BEECH)         += beech-mtd.o
+obj-$(CONFIG_MTD_ARCTIC)        += arctic-mtd.o

 include $(TOPDIR)/Rules.make
diff -urN /home/dgibson/kernel/linuxppc_2_4_devel/drivers/mtd/maps/arctic-mtd.c linux-bartholomew/drivers/mtd/maps/arctic-mtd.c
--- /home/dgibson/kernel/linuxppc_2_4_devel/drivers/mtd/maps/arctic-mtd.c	Thu Jan 01 10:00:00 1970
+++ linux-bartholomew/drivers/mtd/maps/arctic-mtd.c	Mon Dec 16 13:08:02 2002
@@ -0,0 +1,168 @@
+/*
+ * drivers/mtd/maps/arctic-mtd.c MTD mappings and partition tables for
+ *                              IBM 405LP Arctic boards.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) 2002, International Business Machines Corporation
+ * All Rights Reserved.
+ *
+ * Bishop Brock
+ * IBM Research, Austin Center for Low-Power Computing
+ * bcbrock@us.ibm.com
+ * March 2002
+ *
+ * modified for Arctic by,
+ * David Gibson
+ * IBM OzLabs, Canberra, Australia
+ * <arctic@gibson.dropbear.id.au>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/io.h>
+#include <asm/ibm4xx.h>
+
+#define ARCTIC_FFS_SIZE	0x1a00000 /* 26 M */
+
+#define NAME     "Arctic Linux Flash"
+#define PADDR    SUBZERO_BOOTFLASH_PADDR
+#define SIZE     SUBZERO_BOOTFLASH_SIZE
+#define BUSWIDTH 2
+
+/* Flash memories on these boards are memory resources, accessed big-endian. */
+
+static u8
+arctic_mtd_read8(struct map_info *map, unsigned long offset)
+{
+	return __raw_readb(map->map_priv_1 + offset);
+}
+
+static u16
+arctic_mtd_read16(struct map_info *map, unsigned long offset)
+{
+	return __raw_readw(map->map_priv_1 + offset);
+}
+
+static u32
+arctic_mtd_read32(struct map_info *map, unsigned long offset)
+{
+	return __raw_readl(map->map_priv_1 + offset);
+}
+
+static void
+arctic_mtd_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
+{
+	memcpy_fromio(to, (void *) (map->map_priv_1 + from), len);
+}
+
+static void
+arctic_mtd_write8(struct map_info *map, u8 data, unsigned long address)
+{
+	__raw_writeb(data, map->map_priv_1 + address);
+	mb();
+}
+
+static void
+arctic_mtd_write16(struct map_info *map, u16 data, unsigned long address)
+{
+	__raw_writew(data, map->map_priv_1 + address);
+	mb();
+}
+
+static void
+arctic_mtd_write32(struct map_info *map, u32 data, unsigned long address)
+{
+	__raw_writel(data, map->map_priv_1 + address);
+	mb();
+}
+
+static void
+arctic_mtd_copy_to(struct map_info *map,
+		  unsigned long to, const void *from, ssize_t len)
+{
+	memcpy_toio((void *) (map->map_priv_1 + to), from, len);
+}
+
+static struct map_info arctic_mtd_map = {
+	.name		= NAME,
+	.size		= SIZE,
+	.buswidth	= BUSWIDTH,
+	.read8		= arctic_mtd_read8,
+	.read16		= arctic_mtd_read16,
+	.read32		= arctic_mtd_read32,
+	.copy_from	= arctic_mtd_copy_from,
+	.write8		= arctic_mtd_write8,
+	.write16	= arctic_mtd_write16,
+	.write32	= arctic_mtd_write32,
+	.copy_to	= arctic_mtd_copy_to,
+};
+
+static struct mtd_info *arctic_mtd;
+
+static struct mtd_partition arctic_partitions[2] = {
+	{ .name		= "Arctic FFS",
+	  .size		= ARCTIC_FFS_SIZE,
+	  .offset	= 0,},
+	{ .name		= "Kernel & firmware",
+	  .size		= (SUBZERO_BOOTFLASH_SIZE - ARCTIC_FFS_SIZE),
+	  .offset	= ARCTIC_FFS_SIZE,},
+};
+
+static int __init
+init_arctic_mtd(void)
+{
+	printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR);
+
+	arctic_mtd_map.map_priv_1 = (unsigned long) ioremap(PADDR, SIZE);
+
+	if (!arctic_mtd_map.map_priv_1) {
+		printk("%s: failed to ioremap 0x%x\n", NAME, PADDR);
+		return -EIO;
+	}
+
+	printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8);
+	arctic_mtd = do_map_probe("cfi_probe", &arctic_mtd_map);
+
+	if (!arctic_mtd)
+		return -ENXIO;
+
+	arctic_mtd->module = THIS_MODULE;
+
+	return add_mtd_partitions(arctic_mtd, arctic_partitions, 2);
+}
+
+static void __exit
+cleanup_arctic_mtd(void)
+{
+	if (arctic_mtd) {
+		del_mtd_partitions(arctic_mtd);
+		map_destroy(arctic_mtd);
+		iounmap((void *) arctic_mtd_map.map_priv_1);
+	}
+}
+
+module_init(init_arctic_mtd);
+module_exit(cleanup_arctic_mtd);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("David Gibson <arctic@gibson.dropbear.id.au>");
+MODULE_DESCRIPTION("MTD map and partitions for IBM 405LP Arctic boards");


--
David Gibson			| For every complex problem there is a
david@gibson.dropbear.id.au	| solution which is simple, neat and
				| wrong.
http://www.ozlabs.org/people/dgibson

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Arctic-2 MTD driver
  2002-12-16  2:09 Arctic-2 MTD driver David Gibson
@ 2002-12-16  8:46 ` Marius Groeger
  2002-12-16 15:01   ` Tom Rini
  2002-12-16 14:43 ` Tom Rini
  1 sibling, 1 reply; 7+ messages in thread
From: Marius Groeger @ 2002-12-16  8:46 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-embedded


Hello David,

On Mon, 16 Dec 2002, David Gibson wrote:

> Having committed the core support code for the Arctic-2, here come
> some drivers for it.  Below is an MTD map for the Arctic-2, derived
> from beech-mtd.c.  Essentially all it does is provide suitable
> hardwired partitions.

Can you also post this to the linux-mtd folks?

Thanks,
Marius

-----------------------------------------------------------------------------
Marius Groeger           SYSGO Real-Time Solutions AG       mgroeger@sysgo.de
Software Engineering     Embedded and Real-Time Software    www.sysgo.de
Voice: +49-6136-9948-0   Am Pfaffenstein 14                 www.osek.de
FAX:   +49-6136-9948-10  55270 Klein-Winternheim, Germany   www.elinos.com


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Arctic-2 MTD driver
  2002-12-16  2:09 Arctic-2 MTD driver David Gibson
  2002-12-16  8:46 ` Marius Groeger
@ 2002-12-16 14:43 ` Tom Rini
  2002-12-17  4:16   ` David Gibson
  1 sibling, 1 reply; 7+ messages in thread
From: Tom Rini @ 2002-12-16 14:43 UTC (permalink / raw)
  To: linuxppc-embedded


On Mon, Dec 16, 2002 at 01:09:22PM +1100, David Gibson wrote:

> Having committed the core support code for the Arctic-2, here come
> some drivers for it.  Below is an MTD map for the Arctic-2, derived
> from beech-mtd.c.  Essentially all it does is provide suitable
> hardwired partitions.
>
> Again, any comments before I commit this?

Only that it reminded me that drivers/mtd/maps/Config.in needs some
cleanups for PPC32, I'll be commiting those momentarily.  But other than
that, it looks fine.

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Arctic-2 MTD driver
  2002-12-16  8:46 ` Marius Groeger
@ 2002-12-16 15:01   ` Tom Rini
  2002-12-16 15:28     ` Marius Groeger
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Rini @ 2002-12-16 15:01 UTC (permalink / raw)
  To: Marius Groeger; +Cc: David Gibson, linuxppc-embedded


On Mon, Dec 16, 2002 at 09:46:50AM +0100, Marius Groeger wrote:
>
> Hello David,
>
> On Mon, 16 Dec 2002, David Gibson wrote:
>
> > Having committed the core support code for the Arctic-2, here come
> > some drivers for it.  Below is an MTD map for the Arctic-2, derived
> > from beech-mtd.c.  Essentially all it does is provide suitable
> > hardwired partitions.
>
> Can you also post this to the linux-mtd folks?

No point in doing that yet, as the underlying support code for the
Arctic-2 won't be making Marcelo's tree for a while yet.

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Arctic-2 MTD driver
  2002-12-16 15:01   ` Tom Rini
@ 2002-12-16 15:28     ` Marius Groeger
  2002-12-16 15:31       ` Tom Rini
  0 siblings, 1 reply; 7+ messages in thread
From: Marius Groeger @ 2002-12-16 15:28 UTC (permalink / raw)
  To: Tom Rini; +Cc: David Gibson, linuxppc-embedded


On Mon, 16 Dec 2002, Tom Rini wrote:

> On Mon, Dec 16, 2002 at 09:46:50AM +0100, Marius Groeger wrote:
> >
> > Hello David,
> >
> > On Mon, 16 Dec 2002, David Gibson wrote:
> >
> > > Having committed the core support code for the Arctic-2, here come
> > > some drivers for it.  Below is an MTD map for the Arctic-2, derived
> > > from beech-mtd.c.  Essentially all it does is provide suitable
> > > hardwired partitions.
> >
> > Can you also post this to the linux-mtd folks?
>
> No point in doing that yet, as the underlying support code for the
> Arctic-2 won't be making Marcelo's tree for a while yet.

I don't see a point in NOT doing this. It will have to be done anyway,
so David might as well do it now and be done with it.

Regards
Marius

-----------------------------------------------------------------------------
Marius Groeger           SYSGO Real-Time Solutions AG       mgroeger@sysgo.de
Software Engineering     Embedded and Real-Time Software    www.sysgo.de
Voice: +49-6136-9948-0   Am Pfaffenstein 14                 www.osek.de
FAX:   +49-6136-9948-10  55270 Klein-Winternheim, Germany   www.elinos.com


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Arctic-2 MTD driver
  2002-12-16 15:28     ` Marius Groeger
@ 2002-12-16 15:31       ` Tom Rini
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2002-12-16 15:31 UTC (permalink / raw)
  To: Marius Groeger; +Cc: David Gibson, linuxppc-embedded


On Mon, Dec 16, 2002 at 04:28:06PM +0100, Marius Groeger wrote:
> On Mon, 16 Dec 2002, Tom Rini wrote:
>
> > On Mon, Dec 16, 2002 at 09:46:50AM +0100, Marius Groeger wrote:
> > >
> > > Hello David,
> > >
> > > On Mon, 16 Dec 2002, David Gibson wrote:
> > >
> > > > Having committed the core support code for the Arctic-2, here come
> > > > some drivers for it.  Below is an MTD map for the Arctic-2, derived
> > > > from beech-mtd.c.  Essentially all it does is provide suitable
> > > > hardwired partitions.
> > >
> > > Can you also post this to the linux-mtd folks?
> >
> > No point in doing that yet, as the underlying support code for the
> > Arctic-2 won't be making Marcelo's tree for a while yet.
>
> I don't see a point in NOT doing this. It will have to be done anyway,
> so David might as well do it now and be done with it.

Unusable, untestable code which may or may not need minor changes before
going upstream? (For example, I need to go and do similar changes to an
upstream version of maps/Config.in like I just did to the _devel ones).

There's no real advantage to doing it now or later, in other words. :)

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Arctic-2 MTD driver
  2002-12-16 14:43 ` Tom Rini
@ 2002-12-17  4:16   ` David Gibson
  0 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2002-12-17  4:16 UTC (permalink / raw)
  To: Tom Rini; +Cc: linuxppc-embedded


On Mon, Dec 16, 2002 at 07:43:49AM -0700, Tom Rini wrote:
>
> On Mon, Dec 16, 2002 at 01:09:22PM +1100, David Gibson wrote:
>
> > Having committed the core support code for the Arctic-2, here come
> > some drivers for it.  Below is an MTD map for the Arctic-2, derived
> > from beech-mtd.c.  Essentially all it does is provide suitable
> > hardwired partitions.
> >
> > Again, any comments before I commit this?
>
> Only that it reminded me that drivers/mtd/maps/Config.in needs some
> cleanups for PPC32, I'll be commiting those momentarily.  But other than
> that, it looks fine.

Ok, updated for your changes, and committed.

--
David Gibson			| For every complex problem there is a
david@gibson.dropbear.id.au	| solution which is simple, neat and
				| wrong.
http://www.ozlabs.org/people/dgibson

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-12-17  4:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-16  2:09 Arctic-2 MTD driver David Gibson
2002-12-16  8:46 ` Marius Groeger
2002-12-16 15:01   ` Tom Rini
2002-12-16 15:28     ` Marius Groeger
2002-12-16 15:31       ` Tom Rini
2002-12-16 14:43 ` Tom Rini
2002-12-17  4:16   ` David Gibson

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).