Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Subject: [PATCH] [MIPS] Add platform MTD support for the WGT634U machine
Date: Thu, 7 Feb 2008 03:17:16 +0100	[thread overview]
Message-ID: <20080207021716.GA3350@volta.aurel32.net> (raw)

The patch below adds MTD support for the WGT634U machine by defining a
new platform_device for the flash.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 arch/mips/bcm47xx/wgt634u.c |   69 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/arch/mips/bcm47xx/wgt634u.c b/arch/mips/bcm47xx/wgt634u.c
index 5a017ea..997e540 100644
--- a/arch/mips/bcm47xx/wgt634u.c
+++ b/arch/mips/bcm47xx/wgt634u.c
@@ -9,6 +9,7 @@
 #include <linux/platform_device.h>
 #include <linux/module.h>
 #include <linux/leds.h>
+#include <linux/mtd/physmap.h>
 #include <linux/ssb/ssb.h>
 #include <asm/mach-bcm47xx/bcm47xx.h>
 
@@ -43,6 +44,61 @@ static struct platform_device wgt634u_gpio_leds = {
 	}
 };
 
+
+/* 8MiB flash. The struct mtd_partition matches original Netgear WGT634U
+   firmware. */
+static struct mtd_partition wgt634u_partitions[] = {
+	{
+		.name       = "cfe",
+		.offset     = 0,
+		.size       = 0x60000,		/* 384k */
+		.mask_flags = MTD_WRITEABLE 	/* force read-only */
+	},
+	{
+		.name   = "config",
+		.offset = 0x60000,
+		.size   = 0x20000		/* 128k */
+	},
+	{
+		.name   = "linux",
+		.offset = 0x80000,
+		.size   = 0x140000 		/* 1280k */
+	},
+	{
+		.name   = "jffs",
+		.offset = 0x1c0000,
+		.size   = 0x620000 		/* 6272k */
+	},
+	{
+		.name   = "nvram",
+		.offset = 0x7e0000,
+		.size   = 0x20000		/* 128k */
+	},
+};
+
+static struct physmap_flash_data wgt634u_flash_data = {
+	.parts    = wgt634u_partitions,
+	.nr_parts = ARRAY_SIZE(wgt634u_partitions)
+};
+
+static struct resource wgt634u_flash_resource = {
+	.flags = IORESOURCE_MEM,
+};
+
+static struct platform_device wgt634u_flash = {
+	.name          = "physmap-flash",
+	.id            = 0,
+	.dev           = { .platform_data = &wgt634u_flash_data, },
+	.resource      = &wgt634u_flash_resource,
+	.num_resources = 1,
+};
+
+/* Platform devices */
+static struct platform_device *wgt634u_devices[] __initdata = {
+	&wgt634u_flash,
+	&wgt634u_gpio_leds,
+};
+
 static int __init wgt634u_init(void)
 {
 	/* There is no easy way to detect that we are running on a WGT634U
@@ -54,9 +110,16 @@ static int __init wgt634u_init(void)
 
 	if (et0mac[0] == 0x00 &&
 	    ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) ||
-	     (et0mac[1] == 0x0f && et0mac[2] == 0xb5)))
-		return platform_device_register(&wgt634u_gpio_leds);
-	else
+	     (et0mac[1] == 0x0f && et0mac[2] == 0xb5))) {
+		struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
+		wgt634u_flash_data.width = mcore->flash_buswidth;
+		wgt634u_flash_resource.start = mcore->flash_window;
+		wgt634u_flash_resource.end = mcore->flash_window
+					   + mcore->flash_window_size
+					   - 1;
+		return platform_add_devices(wgt634u_devices,
+					    ARRAY_SIZE(wgt634u_devices));
+	} else
 		return -ENODEV;
 }
 

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

             reply	other threads:[~2008-02-07  2:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-07  2:17 Aurelien Jarno [this message]
2008-02-19 16:56 ` [PATCH] [MIPS] Add platform MTD support for the WGT634U machine Ralf Baechle

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=20080207021716.GA3350@volta.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.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