Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH][2/2] TANBAC TB0193 (L-Card+)
@ 2003-02-17  4:32 TAKANO Ryousei
  2003-02-17  9:21 ` Juan Quintela
  0 siblings, 1 reply; 3+ messages in thread
From: TAKANO Ryousei @ 2003-02-17  4:32 UTC (permalink / raw)
  To: linux-mips; +Cc: takano

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

Hi,

This mail attaches tanbac-tb0193-drivers.patch.

Thanks,
TAKANO Ryousei

[-- Attachment #2: tanbac-tb0193-drivers.patch --]
[-- Type: application/octet-stream, Size: 8936 bytes --]

diff -Nru --exclude=CVS --exclude=.cvsignore linux.orig/drivers/mtd/maps/Config.in linux/drivers/mtd/maps/Config.in
--- linux.orig/drivers/mtd/maps/Config.in	Sun Oct  6 13:01:40 2002
+++ linux/drivers/mtd/maps/Config.in	Sun Feb 16 05:52:41 2003
@@ -60,6 +60,7 @@
    fi
    dep_tristate '  Momenco Ocelot boot flash device' CONFIG_MTD_OCELOT $CONFIG_MOMENCO_OCELOT
    dep_tristate '  LASAT flash device' CONFIG_MTD_LASAT $CONFIG_MTD_CFI $CONFIG_LASAT
+   dep_tristate '  TANBAC TB0193(L-Card+) flash device' CONFIG_MTD_TB0193 $CONFIG_MTD_CFI $CONFIG_TANBAC_TB0193 $CONFIG_MTD_PARTITIONS
 fi
 
 if [ "$CONFIG_SUPERH" = "y" ]; then
diff -Nru --exclude=CVS --exclude=.cvsignore linux.orig/drivers/mtd/maps/Makefile linux/drivers/mtd/maps/Makefile
--- linux.orig/drivers/mtd/maps/Makefile	Sun Oct  6 13:01:40 2002
+++ linux/drivers/mtd/maps/Makefile	Sun Feb 16 05:52:57 2003
@@ -41,5 +41,6 @@
 obj-$(CONFIG_MTD_PB1500)        += pb1xxx-flash.o
 obj-$(CONFIG_MTD_LASAT)     	+= lasat.o
 obj-$(CONFIG_MTD_AUTCPU12)	+= autcpu12-nvram.o
+obj-$(CONFIG_MTD_TB0193)     	+= tb0193-flash.o
 
 include $(TOPDIR)/Rules.make
diff -Nru --exclude=CVS --exclude=.cvsignore linux.orig/drivers/mtd/maps/tb0193-flash.c linux/drivers/mtd/maps/tb0193-flash.c
--- linux.orig/drivers/mtd/maps/tb0193-flash.c	Thu Jan  1 09:00:00 1970
+++ linux/drivers/mtd/maps/tb0193-flash.c	Sun Feb 16 05:51:44 2003
@@ -0,0 +1,261 @@
+/*
+ * Flash memory access on TANBAC TB0193 board
+ * 
+ * (C) 2000 Nicolas Pitre <nico@cam.org>
+ * 
+ * $Id: sa1100-flash.c,v 1.22 2001/10/02 10:04:52 rmk Exp $
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/vr4181/vr4181.h>
+#include <asm/io.h>
+
+
+#define WINDOW_ADDR 0xbf000000
+#define A23_BIT	0x00800000
+#define WINDOW_SWITCH (WINDOW_ADDR|A23_BIT)
+
+/*
+	flash ROM memory mapping
+
+	A23	imaginary address	boot time
+	---------------------------------------------
+	0	bf800000 - bfffffff	bf800000 - bfffffff
+	1	bf000000 - bf7fffff	not seen
+*/
+
+static inline void switch_a23 ( unsigned long a )
+{
+	if ( a & A23_BIT ) {
+		*VR4181_GPDATLREG  &= ~(1<<7);
+	} else {
+		*VR4181_GPDATLREG  |= (1<<7);
+	}
+}
+
+static inline void *addr2bus ( unsigned long addr )
+{
+	return (void *)(addr|A23_BIT);
+}
+
+static __u8 tb0193_read8(struct map_info *map, unsigned long ofs)
+{
+	unsigned long addr = map->map_priv_1 + ofs;
+
+	switch_a23 ( addr );
+	return readb ( addr2bus(addr) );
+}
+
+static __u16 tb0193_read16(struct map_info *map, unsigned long ofs)
+{
+	unsigned long addr = map->map_priv_1 + ofs;
+
+	switch_a23 ( addr );
+	return readw ( addr2bus(addr) );
+}
+
+static __u32 tb0193_read32(struct map_info *map, unsigned long ofs)
+{
+	unsigned long addr = map->map_priv_1 + ofs;
+
+	switch_a23 ( addr );
+	return readl ( addr2bus(addr) );
+}
+
+static void tb0193_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
+{
+	unsigned long addr_f = map->map_priv_1 + from;
+	unsigned long addr_l = map->map_priv_1 + from + len;
+
+	if ( (addr_f & A23_BIT) != (addr_l & A23_BIT) ) {
+		/* contains boundary area */
+		unsigned long byte = WINDOW_SWITCH - addr_f;
+
+		switch_a23 ( addr_f );
+		memcpy ( to, addr2bus(addr_f), byte );
+		switch_a23 ( WINDOW_SWITCH );
+		memcpy ( to + byte, addr2bus(WINDOW_SWITCH), len - byte );
+	} else {
+		/* not contains boundary area */
+		switch_a23 ( addr_f );
+		memcpy(to, addr2bus(addr_f|A23_BIT), len);
+	}
+}
+
+static void tb0193_write8(struct map_info *map, __u8 d, unsigned long adr)
+{
+	unsigned long addr = map->map_priv_1 + adr;
+
+	switch_a23 ( addr );
+	writeb(d, addr2bus(addr) );
+}
+
+static void tb0193_write16(struct map_info *map, __u16 d, unsigned long adr)
+{
+	unsigned long addr = map->map_priv_1 + adr;
+
+	switch_a23 ( addr );
+	writew(d, addr2bus(addr) );
+}
+
+static void tb0193_write32(struct map_info *map, __u32 d, unsigned long adr)
+{
+	unsigned long addr = map->map_priv_1 + adr;
+
+	switch_a23 ( addr );
+	writel(d, addr2bus(addr) );
+}
+
+static void tb0193_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
+{
+	unsigned long addr_t = map->map_priv_1 + to;
+	unsigned long addr_l = map->map_priv_1 + to + len;
+
+	if ( (addr_t & A23_BIT) != (addr_l & A23_BIT) ) {
+		/* contains boundary area */
+		unsigned long byte = WINDOW_SWITCH - addr_t;
+
+		switch_a23 ( addr_t );
+		memcpy ( addr2bus(addr_t), from, byte );
+		switch_a23 ( WINDOW_SWITCH );
+		memcpy ( addr2bus(WINDOW_SWITCH), from + byte, len - byte );
+	} else {
+		/* not contains boundary area */
+		switch_a23 ( addr_t );
+		memcpy( addr2bus(addr_t), from, len );
+	}
+}
+
+static struct map_info tb0193_map = {
+	name:		"TANBAC TB0193 flash",
+	read8:		tb0193_read8,
+	read16:		tb0193_read16,
+	read32:		tb0193_read32,
+	copy_from:	tb0193_copy_from,
+	write8:		tb0193_write8,
+	write16:	tb0193_write16,
+	write32:	tb0193_write32,
+	copy_to:	tb0193_copy_to,
+
+	map_priv_1:	WINDOW_ADDR,
+};
+
+
+/*
+ * Here are partition information for all known TB0193-based devices.
+ * See include/linux/mtd/partitions.h for definition of the mtd_partition
+ * structure.
+ * 
+ * The *_max_flash_size is the maximum possible mapped flash size which
+ * is not necessarily the actual flash size.  It must correspond to the 
+ * value specified in the mapping definition defined by the
+ * "struct map_desc *_io_desc" for the corresponding machine.
+ */
+
+static unsigned long lcard_max_flash_size = 0x01000000;
+static struct mtd_partition lcard_partitions[] = {
+	{ 
+		name:		"root file system",
+		offset:		0x00000000,
+		size:		0x00c00000,
+	},{
+		name:		"monitor",
+		offset:		0x00c00000,
+		size:		0x00020000,
+                mask_flags:	MTD_WRITEABLE,
+	},{
+		name:		"reserved",
+		offset:		0x00c20000,
+		size:		0x000e0000,
+	},{
+		name:		"kernel",
+		offset:		0x00d00000,
+		size:		0x00300000,
+	},
+};
+
+#define NB_OF(x)  (sizeof(x)/sizeof(x[0]))
+
+
+extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts);
+extern int parse_bootldr_partitions(struct mtd_info *master, struct mtd_partition **pparts);
+
+static struct mtd_partition *parsed_parts;
+static struct mtd_info *mymtd;
+
+int __init tb0193_mtd_init(void)
+{
+	struct mtd_partition *parts;
+	int nb_parts = 0;
+	int parsed_nr_parts = 0;
+	char *part_type;
+	
+	/* Default flash buswidth */
+	int gpio;
+	
+	tb0193_map.buswidth = 2;
+
+	gpio = *VR4181_GPMD0REG;
+	gpio = (gpio & 0x3fff) | (2<<14);
+	*VR4181_GPMD0REG = gpio;
+
+	/*
+	 * Static partition definition selection
+	 */
+	part_type = "static";
+	parts = lcard_partitions;
+	nb_parts = NB_OF(lcard_partitions);
+	tb0193_map.size = lcard_max_flash_size;
+
+	/*
+	 * Now let's probe for the actual flash.  Do it here since
+	 * specific machine settings might have been set above.
+	 */
+	printk(KERN_NOTICE "TANBAC TB0193 flash: probing %d-bit flash bus\n", tb0193_map.buswidth*8);
+	mymtd = do_map_probe("cfi_probe", &tb0193_map);
+	if (!mymtd)
+		return -ENXIO;
+	mymtd->module = THIS_MODULE;
+
+	if (parsed_nr_parts > 0) {
+		parts = parsed_parts;
+		nb_parts = parsed_nr_parts;
+	}
+
+	if (nb_parts == 0) {
+		printk(KERN_NOTICE "TANBAC TB0193 flash: no partition info available, registering whole flash at once\n");
+		add_mtd_device(mymtd);
+	} else {
+		printk(KERN_NOTICE "Using %s partition definition\n", part_type);
+		add_mtd_partitions(mymtd, parts, nb_parts);
+	}
+	return 0;
+}
+
+static void __exit tb0193_mtd_cleanup(void)
+{
+	if (mymtd) {
+		del_mtd_partitions(mymtd);
+		map_destroy(mymtd);
+		if (parsed_parts)
+			kfree(parsed_parts);
+	}
+	*VR4181_GPMD0REG &= 0x3fff;
+
+	*(unsigned char *)WINDOW_SWITCH = 0xff;	/* force array mode */
+}
+
+module_init(tb0193_mtd_init);
+module_exit(tb0193_mtd_cleanup);
+
+MODULE_AUTHOR("Nicolas Pitre");
+MODULE_DESCRIPTION("TANBAC TB0193 MTD map driver");
+MODULE_LICENSE("GPL");
diff -Nru --exclude=CVS --exclude=.cvsignore linux.orig/drivers/net/cs89x0.c linux/drivers/net/cs89x0.c
--- linux.orig/drivers/net/cs89x0.c	Thu Jun 27 07:35:51 2002
+++ linux/drivers/net/cs89x0.c	Sun Feb 16 02:55:17 2003
@@ -132,6 +132,9 @@
 #if ALLOW_DMA
 #include <asm/dma.h>
 #endif
+#ifdef CONFIG_TANBAC_TB0193
+#include <asm/vr4181/vr4181.h>
+#endif
 #include <linux/errno.h>
 #include <linux/spinlock.h>
 
@@ -163,6 +166,10 @@
 static unsigned int netcard_portlist[] __initdata =
    { 0x0300, 0};
 static unsigned int cs8900_irq_map[] = {1,0,0,0};
+#elif defined(CONFIG_TANBAC_TB0193)
+static unsigned int netcard_portlist[] __initdata =
+   { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};
+static unsigned int cs8900_irq_map[] = {VR4181_IRQ_GPIO4,0,0,0};
 #else
 static unsigned int netcard_portlist[] __initdata =
    { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};

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

* Re: [PATCH][2/2] TANBAC TB0193 (L-Card+)
  2003-02-17  4:32 [PATCH][2/2] TANBAC TB0193 (L-Card+) TAKANO Ryousei
@ 2003-02-17  9:21 ` Juan Quintela
  2003-02-17 14:13   ` TAKANO Ryousei
  0 siblings, 1 reply; 3+ messages in thread
From: Juan Quintela @ 2003-02-17  9:21 UTC (permalink / raw)
  To: TAKANO Ryousei; +Cc: linux-mips

>>>>> "takano" == TAKANO Ryousei <takano@os-omicron.org> writes:

takano> Hi,
takano> This mail attaches tanbac-tb0193-drivers.patch.

a cople of comments:

+static __u32 tb0193_read32(struct map_info *map, unsigned long ofs)
        ^^^^^

plain uXX instead of __uXX should work on kernel land.

+static struct map_info tb0193_map = {
+	name:		"TANBAC TB0193 flash",
+	read8:		tb0193_read8,
+	read16:		tb0193_read16,
+	read32:		tb0193_read32,
+	copy_from:	tb0193_copy_from,
+	write8:		tb0193_write8,
+	write16:	tb0193_write16,
+	write32:	tb0193_write32,
+	copy_to:	tb0193_copy_to,
+
+	map_priv_1:	WINDOW_ADDR,
+};

Please, use C99 initializers.

+static unsigned long lcard_max_flash_size = 0x01000000;
+static struct mtd_partition lcard_partitions[] = {
+	{ 
+		name:		"root file system",
+		offset:		0x00000000,
+		size:		0x00c00000,
+	},{
+		name:		"monitor",
+		offset:		0x00c00000,
+		size:		0x00020000,
+                mask_flags:	MTD_WRITEABLE,
+	},{
+		name:		"reserved",
+		offset:		0x00c20000,
+		size:		0x000e0000,
+	},{
+		name:		"kernel",
+		offset:		0x00d00000,
+		size:		0x00300000,
+	},
+};

at least for the structs use the C99 initializers.

Later, Juan.

-- 
In theory, practice and theory are the same, but in practice they 
are different -- Larry McVoy

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

* Re: [PATCH][2/2] TANBAC TB0193 (L-Card+)
  2003-02-17  9:21 ` Juan Quintela
@ 2003-02-17 14:13   ` TAKANO Ryousei
  0 siblings, 0 replies; 3+ messages in thread
From: TAKANO Ryousei @ 2003-02-17 14:13 UTC (permalink / raw)
  To: linux-mips

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

Hi, Juan

On Mon, 17 Feb 2003 10:21:31 +0100
Juan Quintela <quintela@mandrakesoft.com> wrote:

> plain uXX instead of __uXX should work on kernel land.
 (snip) 
> Please, use C99 initializers.
> 

I fixed __uXX staffs adn C99 initializers.

Thanks,
TAKANO Ryousei

[-- Attachment #2: tanbac-tb0193-drivers2.patch --]
[-- Type: application/octet-stream, Size: 3792 bytes --]

diff -Nru --exclude=CVS --exclude=.cvsignore linux.orig/arch/mips/vr4181/tanbac-tb0193/ide-tb0193.c linux/arch/mips/vr4181/tanbac-tb0193/ide-tb0193.c
--- linux.orig/drivers/mtd/maps/tb0193-flash.c	Mon Feb 17 22:41:53 2003
+++ linux/drivers/mtd/maps/tb0193-flash.c	Mon Feb 17 19:09:01 2003
@@ -46,7 +46,7 @@
 	return (void *)(addr|A23_BIT);
 }
 
-static __u8 tb0193_read8(struct map_info *map, unsigned long ofs)
+static u8 tb0193_read8(struct map_info *map, unsigned long ofs)
 {
 	unsigned long addr = map->map_priv_1 + ofs;
 
@@ -54,7 +54,7 @@
 	return readb ( addr2bus(addr) );
 }
 
-static __u16 tb0193_read16(struct map_info *map, unsigned long ofs)
+static u16 tb0193_read16(struct map_info *map, unsigned long ofs)
 {
 	unsigned long addr = map->map_priv_1 + ofs;
 
@@ -62,7 +62,7 @@
 	return readw ( addr2bus(addr) );
 }
 
-static __u32 tb0193_read32(struct map_info *map, unsigned long ofs)
+static u32 tb0193_read32(struct map_info *map, unsigned long ofs)
 {
 	unsigned long addr = map->map_priv_1 + ofs;
 
@@ -90,7 +90,7 @@
 	}
 }
 
-static void tb0193_write8(struct map_info *map, __u8 d, unsigned long adr)
+static void tb0193_write8(struct map_info *map, u8 d, unsigned long adr)
 {
 	unsigned long addr = map->map_priv_1 + adr;
 
@@ -98,7 +98,7 @@
 	writeb(d, addr2bus(addr) );
 }
 
-static void tb0193_write16(struct map_info *map, __u16 d, unsigned long adr)
+static void tb0193_write16(struct map_info *map, u16 d, unsigned long adr)
 {
 	unsigned long addr = map->map_priv_1 + adr;
 
@@ -106,7 +106,7 @@
 	writew(d, addr2bus(addr) );
 }
 
-static void tb0193_write32(struct map_info *map, __u32 d, unsigned long adr)
+static void tb0193_write32(struct map_info *map, u32 d, unsigned long adr)
 {
 	unsigned long addr = map->map_priv_1 + adr;
 
@@ -135,17 +135,17 @@
 }
 
 static struct map_info tb0193_map = {
-	name:		"TANBAC TB0193 flash",
-	read8:		tb0193_read8,
-	read16:		tb0193_read16,
-	read32:		tb0193_read32,
-	copy_from:	tb0193_copy_from,
-	write8:		tb0193_write8,
-	write16:	tb0193_write16,
-	write32:	tb0193_write32,
-	copy_to:	tb0193_copy_to,
+	.name =		"TANBAC TB0193 flash",
+	.read8 =	tb0193_read8,
+	.read16 =	tb0193_read16,
+	.read32 =	tb0193_read32,
+	.copy_from =	tb0193_copy_from,
+	.write8 =	tb0193_write8,
+	.write16 =	tb0193_write16,
+	.write32 =	tb0193_write32,
+	.copy_to =	tb0193_copy_to,
 
-	map_priv_1:	WINDOW_ADDR,
+	.map_priv_1 =	WINDOW_ADDR,
 };
 
 
@@ -160,25 +160,25 @@
  * "struct map_desc *_io_desc" for the corresponding machine.
  */
 
-static unsigned long lcard_max_flash_size = 0x01000000;
-static struct mtd_partition lcard_partitions[] = {
+static unsigned long tb0193_max_flash_size = 0x01000000;
+static struct mtd_partition tb0193_partitions[] = {
 	{ 
-		name:		"root file system",
-		offset:		0x00000000,
-		size:		0x00c00000,
+		.name =		"root file system",
+		.offset =	0x00000000,
+		.size =		0x00c00000,
 	},{
-		name:		"monitor",
-		offset:		0x00c00000,
-		size:		0x00020000,
-                mask_flags:	MTD_WRITEABLE,
+		.name =		"monitor",
+		.offset =	0x00c00000,
+		.size =		0x00020000,
+                .mask_flags =	MTD_WRITEABLE,
 	},{
-		name:		"reserved",
-		offset:		0x00c20000,
-		size:		0x000e0000,
+		.name =		"reserved",
+		.offset =	0x00c20000,
+		.size =		0x000e0000,
 	},{
-		name:		"kernel",
-		offset:		0x00d00000,
-		size:		0x00300000,
+		.name =		"kernel",
+		.offset =	0x00d00000,
+		.size =		0x00300000,
 	},
 };
 
@@ -211,9 +211,9 @@
 	 * Static partition definition selection
 	 */
 	part_type = "static";
-	parts = lcard_partitions;
-	nb_parts = NB_OF(lcard_partitions);
-	tb0193_map.size = lcard_max_flash_size;
+	parts = tb0193_partitions;
+	nb_parts = NB_OF(tb0193_partitions);
+	tb0193_map.size = tb0193_max_flash_size;
 
 	/*
 	 * Now let's probe for the actual flash.  Do it here since

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

end of thread, other threads:[~2003-02-17 14:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-17  4:32 [PATCH][2/2] TANBAC TB0193 (L-Card+) TAKANO Ryousei
2003-02-17  9:21 ` Juan Quintela
2003-02-17 14:13   ` TAKANO Ryousei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox