public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [OMAP1] use gen_nand
@ 2009-11-23 12:45 Ladislav Michl
  2009-11-23 17:24 ` Tony Lindgren
  2009-12-04 23:28 ` [APPLIED] " Tony Lindgren
  0 siblings, 2 replies; 5+ messages in thread
From: Ladislav Michl @ 2009-11-23 12:45 UTC (permalink / raw)
  To: linux-omap; +Cc: Imre Deak, Brian Swetland, Kevin Hilman

Since omapnand driver never find its way into mainline, switch to gen_nand instead.
Following patch is compile tested only, but it is based on code I wrote for
NetStar board and runtime tested it there.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Cc: Imre Deak <imre.deak@nokia.com>
Cc: Brian Swetland <swetland@google.com>
Cc: Kevin Hilman <kjh@hilman.org>

diff --git a/arch/arm/mach-omap1/board-fsample.c b/arch/arm/mach-omap1/board-fsample.c
index f4b72c1..8da8c64 100644
--- a/arch/arm/mach-omap1/board-fsample.c
+++ b/arch/arm/mach-omap1/board-fsample.c
@@ -30,7 +30,6 @@
 #include <mach/gpio.h>
 #include <plat/mux.h>
 #include <plat/fpga.h>
-#include <plat/nand.h>
 #include <plat/keypad.h>
 #include <plat/common.h>
 #include <plat/board.h>
@@ -167,8 +166,40 @@ static struct platform_device nor_device = {
 	.resource	= &nor_resource,
 };
 
-static struct omap_nand_platform_data nand_data = {
-	.options	= NAND_SAMSUNG_LP_OPTIONS,
+static void nand_cmd_ctl(struct mtd_info *mtd, int cmd,	unsigned int ctrl)
+{
+	struct nand_chip *this = mtd->priv;
+	unsigned long mask;
+
+	if (cmd == NAND_CMD_NONE)
+		return;
+
+	mask = (ctrl & NAND_CLE) ? 0x02 : 0;
+	if (ctrl & NAND_ALE)
+		mask |= 0x04;
+	writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
+}
+
+#define FSAMPLE_NAND_RB_GPIO_PIN	62
+
+static int nand_dev_ready(struct mtd_info *mtd)
+{
+	return gpio_get_value(FSAMPLE_NAND_RB_GPIO_PIN);
+}
+
+static const char *part_probes[] = { "cmdlinepart", NULL };
+
+static struct platform_nand_data nand_data = {
+	.chip	= {
+		.nr_chips		= 1,
+		.chip_offset		= 0,
+		.options		= NAND_SAMSUNG_LP_OPTIONS,
+		.part_probe_types	= part_probes,
+	},
+	.ctrl	= {
+		.cmd_ctrl	= nand_cmd_ctl,
+		.dev_ready	= nand_dev_ready,
+	},
 };
 
 static struct resource nand_resource = {
@@ -178,7 +209,7 @@ static struct resource nand_resource = {
 };
 
 static struct platform_device nand_device = {
-	.name		= "omapnand",
+	.name		= "gen_nand",
 	.id		= 0,
 	.dev		= {
 		.platform_data	= &nand_data,
@@ -233,13 +264,6 @@ static struct platform_device *devices[] __initdata = {
 	&lcd_device,
 };
 
-#define P2_NAND_RB_GPIO_PIN	62
-
-static int nand_dev_ready(struct omap_nand_platform_data *data)
-{
-	return gpio_get_value(P2_NAND_RB_GPIO_PIN);
-}
-
 static struct omap_lcd_config fsample_lcd_config __initdata = {
 	.ctrl_name	= "internal",
 };
@@ -250,9 +274,9 @@ static struct omap_board_config_kernel fsample_config[] = {
 
 static void __init omap_fsample_init(void)
 {
-	if (gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0)
+	if (gpio_request(FSAMPLE_NAND_RB_GPIO_PIN, "NAND ready") < 0)
 		BUG();
-	nand_data.dev_ready = nand_dev_ready;
+	gpio_direction_input(FSAMPLE_NAND_RB_GPIO_PIN);
 
 	omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
 	omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 89ba8ec..283a6f2 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -40,7 +40,6 @@
 #include <plat/mux.h>
 #include <plat/dma.h>
 #include <plat/tc.h>
-#include <plat/nand.h>
 #include <plat/irda.h>
 #include <plat/usb.h>
 #include <plat/keypad.h>
@@ -179,11 +178,43 @@ static struct mtd_partition h2_nand_partitions[] = {
 	},
 };
 
-/* dip switches control NAND chip access:  8 bit, 16 bit, or neither */
-static struct omap_nand_platform_data h2_nand_data = {
-	.options	= NAND_SAMSUNG_LP_OPTIONS,
-	.parts		= h2_nand_partitions,
-	.nr_parts	= ARRAY_SIZE(h2_nand_partitions),
+static void h2_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
+{
+	struct nand_chip *this = mtd->priv;
+	unsigned long mask;
+
+	if (cmd == NAND_CMD_NONE)
+		return;
+
+	mask = (ctrl & NAND_CLE) ? 0x02 : 0;
+	if (ctrl & NAND_ALE)
+		mask |= 0x04;
+	writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
+}
+
+#define H2_NAND_RB_GPIO_PIN	62
+
+static int h2_nand_dev_ready(struct mtd_info *mtd)
+{
+	return gpio_get_value(H2_NAND_RB_GPIO_PIN);
+}
+
+static const char *h2_part_probes[] = { "cmdlinepart", NULL };
+
+struct platform_nand_data h2_nand_platdata = {
+	.chip	= {
+		.nr_chips		= 1,
+		.chip_offset		= 0,
+		.nr_partitions		= ARRAY_SIZE(h2_nand_partitions),
+		.partitions		= h2_nand_partitions,
+		.options		= NAND_SAMSUNG_LP_OPTIONS,
+		.part_probe_types	= h2_part_probes,
+	},
+	.ctrl	= {
+		.cmd_ctrl	= h2_nand_cmd_ctl,
+		.dev_ready	= h2_nand_dev_ready,
+
+	},
 };
 
 static struct resource h2_nand_resource = {
@@ -191,10 +222,10 @@ static struct resource h2_nand_resource = {
 };
 
 static struct platform_device h2_nand_device = {
-	.name		= "omapnand",
+	.name		= "gen_nand",
 	.id		= 0,
 	.dev		= {
-		.platform_data	= &h2_nand_data,
+		.platform_data	= &h2_nand_platdata,
 	},
 	.num_resources	= 1,
 	.resource	= &h2_nand_resource,
@@ -368,8 +399,6 @@ static struct omap_board_config_kernel h2_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&h2_lcd_config },
 };
 
-#define H2_NAND_RB_GPIO_PIN	62
-
 static void __init h2_init(void)
 {
 	/* Here we assume the NOR boot config:  NOR on CS3 (possibly swapped
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index f5cc0a7..f96cd1e 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -42,7 +42,6 @@
 #include <mach/irqs.h>
 #include <plat/mux.h>
 #include <plat/tc.h>
-#include <plat/nand.h>
 #include <plat/usb.h>
 #include <plat/keypad.h>
 #include <plat/dma.h>
@@ -181,11 +180,43 @@ static struct mtd_partition nand_partitions[] = {
 	},
 };
 
-/* dip switches control NAND chip access:  8 bit, 16 bit, or neither */
-static struct omap_nand_platform_data nand_data = {
-	.options	= NAND_SAMSUNG_LP_OPTIONS,
-	.parts		= nand_partitions,
-	.nr_parts	= ARRAY_SIZE(nand_partitions),
+static void nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
+{
+	struct nand_chip *this = mtd->priv;
+	unsigned long mask;
+
+	if (cmd == NAND_CMD_NONE)
+		return;
+
+	mask = (ctrl & NAND_CLE) ? 0x02 : 0;
+	if (ctrl & NAND_ALE)
+		mask |= 0x04;
+	writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
+}
+
+#define H3_NAND_RB_GPIO_PIN	10
+
+static int nand_dev_ready(struct mtd_info *mtd)
+{
+	return gpio_get_value(H3_NAND_RB_GPIO_PIN);
+}
+
+static const char *part_probes[] = { "cmdlinepart", NULL };
+
+struct platform_nand_data nand_platdata = {
+	.chip	= {
+		.nr_chips		= 1,
+		.chip_offset		= 0,
+		.nr_partitions		= ARRAY_SIZE(nand_partitions),
+		.partitions		= nand_partitions,
+		.options		= NAND_SAMSUNG_LP_OPTIONS,
+		.part_probe_types	= part_probes,
+	},
+	.ctrl	= {
+		.cmd_ctrl	= nand_cmd_ctl,
+		.dev_ready	= nand_dev_ready,
+
+	},
 };
 
 static struct resource nand_resource = {
@@ -193,10 +224,10 @@ static struct resource nand_resource = {
 };
 
 static struct platform_device nand_device = {
-	.name		= "omapnand",
+	.name		= "gen_nand",
 	.id		= 0,
 	.dev		= {
-		.platform_data	= &nand_data,
+		.platform_data	= &nand_platdata,
 	},
 	.num_resources	= 1,
 	.resource	= &nand_resource,
@@ -332,13 +363,6 @@ static struct i2c_board_info __initdata h3_i2c_board_info[] = {
 	},
 };
 
-#define H3_NAND_RB_GPIO_PIN	10
-
-static int nand_dev_ready(struct omap_nand_platform_data *data)
-{
-	return gpio_get_value(H3_NAND_RB_GPIO_PIN);
-}
-
 static void __init h3_init(void)
 {
 	/* Here we assume the NOR boot config:  NOR on CS3 (possibly swapped
@@ -356,7 +380,7 @@ static void __init h3_init(void)
 	nand_resource.end += SZ_4K - 1;
 	if (gpio_request(H3_NAND_RB_GPIO_PIN, "NAND ready") < 0)
 		BUG();
-	nand_data.dev_ready = nand_dev_ready;
+	gpio_direction_input(H3_NAND_RB_GPIO_PIN);
 
 	/* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
 	/* GPIO10 pullup/down register, Enable pullup on GPIO10 */
diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c
index ca7df1e..dba0f7b 100644
--- a/arch/arm/mach-omap1/board-perseus2.c
+++ b/arch/arm/mach-omap1/board-perseus2.c
@@ -30,7 +30,6 @@
 #include <mach/gpio.h>
 #include <plat/mux.h>
 #include <plat/fpga.h>
-#include <plat/nand.h>
 #include <plat/keypad.h>
 #include <plat/common.h>
 #include <plat/board.h>
@@ -134,8 +133,40 @@ static struct platform_device nor_device = {
 	.resource	= &nor_resource,
 };
 
-static struct omap_nand_platform_data nand_data = {
-	.options	= NAND_SAMSUNG_LP_OPTIONS,
+static void nand_cmd_ctl(struct mtd_info *mtd, int cmd,	unsigned int ctrl)
+{
+	struct nand_chip *this = mtd->priv;
+	unsigned long mask;
+
+	if (cmd == NAND_CMD_NONE)
+		return;
+
+	mask = (ctrl & NAND_CLE) ? 0x02 : 0;
+	if (ctrl & NAND_ALE)
+		mask |= 0x04;
+	writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
+}
+
+#define P2_NAND_RB_GPIO_PIN	62
+
+static int nand_dev_ready(struct mtd_info *mtd)
+{
+	return gpio_get_value(P2_NAND_RB_GPIO_PIN);
+}
+
+static const char *part_probes[] = { "cmdlinepart", NULL };
+
+static struct platform_nand_data nand_data = {
+	.chip	= {
+		.nr_chips		= 1,
+		.chip_offset		= 0,
+		.options		= NAND_SAMSUNG_LP_OPTIONS,
+		.part_probe_types	= part_probes,
+	},
+	.ctrl	= {
+		.cmd_ctrl	= nand_cmd_ctl,
+		.dev_ready	= nand_dev_ready,
+	},
 };
 
 static struct resource nand_resource = {
@@ -145,7 +176,7 @@ static struct resource nand_resource = {
 };
 
 static struct platform_device nand_device = {
-	.name		= "omapnand",
+	.name		= "gen_nand",
 	.id		= 0,
 	.dev		= {
 		.platform_data	= &nand_data,
@@ -201,13 +232,6 @@ static struct platform_device *devices[] __initdata = {
 	&lcd_device,
 };
 
-#define P2_NAND_RB_GPIO_PIN	62
-
-static int nand_dev_ready(struct omap_nand_platform_data *data)
-{
-	return gpio_get_value(P2_NAND_RB_GPIO_PIN);
-}
-
 static struct omap_lcd_config perseus2_lcd_config __initdata = {
 	.ctrl_name	= "internal",
 };
@@ -220,7 +244,7 @@ static void __init omap_perseus2_init(void)
 {
 	if (gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0)
 		BUG();
-	nand_data.dev_ready = nand_dev_ready;
+	gpio_direction_input(P2_NAND_RB_GPIO_PIN);
 
 	omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
 	omap_cfg_reg(M8_1610_FLASH_CS2B_WE);

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

* Re: [PATCH] [OMAP1] use gen_nand
  2009-11-23 12:45 [PATCH] [OMAP1] use gen_nand Ladislav Michl
@ 2009-11-23 17:24 ` Tony Lindgren
  2009-11-30 20:23   ` Ladislav Michl
  2009-12-04 23:28 ` [APPLIED] " Tony Lindgren
  1 sibling, 1 reply; 5+ messages in thread
From: Tony Lindgren @ 2009-11-23 17:24 UTC (permalink / raw)
  To: Ladislav Michl; +Cc: linux-omap, Imre Deak, Brian Swetland, Kevin Hilman

* Ladislav Michl <Ladislav.Michl@seznam.cz> [091123 03:45]:
> Since omapnand driver never find its way into mainline, switch to gen_nand instead.
> Following patch is compile tested only, but it is based on code I wrote for
> NetStar board and runtime tested it there.

Nice patch, and totally the way to go!

Regards,

Tony
 
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> Cc: Imre Deak <imre.deak@nokia.com>
> Cc: Brian Swetland <swetland@google.com>
> Cc: Kevin Hilman <kjh@hilman.org>
> 
> diff --git a/arch/arm/mach-omap1/board-fsample.c b/arch/arm/mach-omap1/board-fsample.c
> index f4b72c1..8da8c64 100644
> --- a/arch/arm/mach-omap1/board-fsample.c
> +++ b/arch/arm/mach-omap1/board-fsample.c
> @@ -30,7 +30,6 @@
>  #include <mach/gpio.h>
>  #include <plat/mux.h>
>  #include <plat/fpga.h>
> -#include <plat/nand.h>
>  #include <plat/keypad.h>
>  #include <plat/common.h>
>  #include <plat/board.h>
> @@ -167,8 +166,40 @@ static struct platform_device nor_device = {
>  	.resource	= &nor_resource,
>  };
>  
> -static struct omap_nand_platform_data nand_data = {
> -	.options	= NAND_SAMSUNG_LP_OPTIONS,
> +static void nand_cmd_ctl(struct mtd_info *mtd, int cmd,	unsigned int ctrl)
> +{
> +	struct nand_chip *this = mtd->priv;
> +	unsigned long mask;
> +
> +	if (cmd == NAND_CMD_NONE)
> +		return;
> +
> +	mask = (ctrl & NAND_CLE) ? 0x02 : 0;
> +	if (ctrl & NAND_ALE)
> +		mask |= 0x04;
> +	writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
> +}
> +
> +#define FSAMPLE_NAND_RB_GPIO_PIN	62
> +
> +static int nand_dev_ready(struct mtd_info *mtd)
> +{
> +	return gpio_get_value(FSAMPLE_NAND_RB_GPIO_PIN);
> +}
> +
> +static const char *part_probes[] = { "cmdlinepart", NULL };
> +
> +static struct platform_nand_data nand_data = {
> +	.chip	= {
> +		.nr_chips		= 1,
> +		.chip_offset		= 0,
> +		.options		= NAND_SAMSUNG_LP_OPTIONS,
> +		.part_probe_types	= part_probes,
> +	},
> +	.ctrl	= {
> +		.cmd_ctrl	= nand_cmd_ctl,
> +		.dev_ready	= nand_dev_ready,
> +	},
>  };
>  
>  static struct resource nand_resource = {
> @@ -178,7 +209,7 @@ static struct resource nand_resource = {
>  };
>  
>  static struct platform_device nand_device = {
> -	.name		= "omapnand",
> +	.name		= "gen_nand",
>  	.id		= 0,
>  	.dev		= {
>  		.platform_data	= &nand_data,
> @@ -233,13 +264,6 @@ static struct platform_device *devices[] __initdata = {
>  	&lcd_device,
>  };
>  
> -#define P2_NAND_RB_GPIO_PIN	62
> -
> -static int nand_dev_ready(struct omap_nand_platform_data *data)
> -{
> -	return gpio_get_value(P2_NAND_RB_GPIO_PIN);
> -}
> -
>  static struct omap_lcd_config fsample_lcd_config __initdata = {
>  	.ctrl_name	= "internal",
>  };
> @@ -250,9 +274,9 @@ static struct omap_board_config_kernel fsample_config[] = {
>  
>  static void __init omap_fsample_init(void)
>  {
> -	if (gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0)
> +	if (gpio_request(FSAMPLE_NAND_RB_GPIO_PIN, "NAND ready") < 0)
>  		BUG();
> -	nand_data.dev_ready = nand_dev_ready;
> +	gpio_direction_input(FSAMPLE_NAND_RB_GPIO_PIN);
>  
>  	omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
>  	omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
> diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
> index 89ba8ec..283a6f2 100644
> --- a/arch/arm/mach-omap1/board-h2.c
> +++ b/arch/arm/mach-omap1/board-h2.c
> @@ -40,7 +40,6 @@
>  #include <plat/mux.h>
>  #include <plat/dma.h>
>  #include <plat/tc.h>
> -#include <plat/nand.h>
>  #include <plat/irda.h>
>  #include <plat/usb.h>
>  #include <plat/keypad.h>
> @@ -179,11 +178,43 @@ static struct mtd_partition h2_nand_partitions[] = {
>  	},
>  };
>  
> -/* dip switches control NAND chip access:  8 bit, 16 bit, or neither */
> -static struct omap_nand_platform_data h2_nand_data = {
> -	.options	= NAND_SAMSUNG_LP_OPTIONS,
> -	.parts		= h2_nand_partitions,
> -	.nr_parts	= ARRAY_SIZE(h2_nand_partitions),
> +static void h2_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
> +{
> +	struct nand_chip *this = mtd->priv;
> +	unsigned long mask;
> +
> +	if (cmd == NAND_CMD_NONE)
> +		return;
> +
> +	mask = (ctrl & NAND_CLE) ? 0x02 : 0;
> +	if (ctrl & NAND_ALE)
> +		mask |= 0x04;
> +	writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
> +}
> +
> +#define H2_NAND_RB_GPIO_PIN	62
> +
> +static int h2_nand_dev_ready(struct mtd_info *mtd)
> +{
> +	return gpio_get_value(H2_NAND_RB_GPIO_PIN);
> +}
> +
> +static const char *h2_part_probes[] = { "cmdlinepart", NULL };
> +
> +struct platform_nand_data h2_nand_platdata = {
> +	.chip	= {
> +		.nr_chips		= 1,
> +		.chip_offset		= 0,
> +		.nr_partitions		= ARRAY_SIZE(h2_nand_partitions),
> +		.partitions		= h2_nand_partitions,
> +		.options		= NAND_SAMSUNG_LP_OPTIONS,
> +		.part_probe_types	= h2_part_probes,
> +	},
> +	.ctrl	= {
> +		.cmd_ctrl	= h2_nand_cmd_ctl,
> +		.dev_ready	= h2_nand_dev_ready,
> +
> +	},
>  };
>  
>  static struct resource h2_nand_resource = {
> @@ -191,10 +222,10 @@ static struct resource h2_nand_resource = {
>  };
>  
>  static struct platform_device h2_nand_device = {
> -	.name		= "omapnand",
> +	.name		= "gen_nand",
>  	.id		= 0,
>  	.dev		= {
> -		.platform_data	= &h2_nand_data,
> +		.platform_data	= &h2_nand_platdata,
>  	},
>  	.num_resources	= 1,
>  	.resource	= &h2_nand_resource,
> @@ -368,8 +399,6 @@ static struct omap_board_config_kernel h2_config[] __initdata = {
>  	{ OMAP_TAG_LCD,		&h2_lcd_config },
>  };
>  
> -#define H2_NAND_RB_GPIO_PIN	62
> -
>  static void __init h2_init(void)
>  {
>  	/* Here we assume the NOR boot config:  NOR on CS3 (possibly swapped
> diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
> index f5cc0a7..f96cd1e 100644
> --- a/arch/arm/mach-omap1/board-h3.c
> +++ b/arch/arm/mach-omap1/board-h3.c
> @@ -42,7 +42,6 @@
>  #include <mach/irqs.h>
>  #include <plat/mux.h>
>  #include <plat/tc.h>
> -#include <plat/nand.h>
>  #include <plat/usb.h>
>  #include <plat/keypad.h>
>  #include <plat/dma.h>
> @@ -181,11 +180,43 @@ static struct mtd_partition nand_partitions[] = {
>  	},
>  };
>  
> -/* dip switches control NAND chip access:  8 bit, 16 bit, or neither */
> -static struct omap_nand_platform_data nand_data = {
> -	.options	= NAND_SAMSUNG_LP_OPTIONS,
> -	.parts		= nand_partitions,
> -	.nr_parts	= ARRAY_SIZE(nand_partitions),
> +static void nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
> +{
> +	struct nand_chip *this = mtd->priv;
> +	unsigned long mask;
> +
> +	if (cmd == NAND_CMD_NONE)
> +		return;
> +
> +	mask = (ctrl & NAND_CLE) ? 0x02 : 0;
> +	if (ctrl & NAND_ALE)
> +		mask |= 0x04;
> +	writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
> +}
> +
> +#define H3_NAND_RB_GPIO_PIN	10
> +
> +static int nand_dev_ready(struct mtd_info *mtd)
> +{
> +	return gpio_get_value(H3_NAND_RB_GPIO_PIN);
> +}
> +
> +static const char *part_probes[] = { "cmdlinepart", NULL };
> +
> +struct platform_nand_data nand_platdata = {
> +	.chip	= {
> +		.nr_chips		= 1,
> +		.chip_offset		= 0,
> +		.nr_partitions		= ARRAY_SIZE(nand_partitions),
> +		.partitions		= nand_partitions,
> +		.options		= NAND_SAMSUNG_LP_OPTIONS,
> +		.part_probe_types	= part_probes,
> +	},
> +	.ctrl	= {
> +		.cmd_ctrl	= nand_cmd_ctl,
> +		.dev_ready	= nand_dev_ready,
> +
> +	},
>  };
>  
>  static struct resource nand_resource = {
> @@ -193,10 +224,10 @@ static struct resource nand_resource = {
>  };
>  
>  static struct platform_device nand_device = {
> -	.name		= "omapnand",
> +	.name		= "gen_nand",
>  	.id		= 0,
>  	.dev		= {
> -		.platform_data	= &nand_data,
> +		.platform_data	= &nand_platdata,
>  	},
>  	.num_resources	= 1,
>  	.resource	= &nand_resource,
> @@ -332,13 +363,6 @@ static struct i2c_board_info __initdata h3_i2c_board_info[] = {
>  	},
>  };
>  
> -#define H3_NAND_RB_GPIO_PIN	10
> -
> -static int nand_dev_ready(struct omap_nand_platform_data *data)
> -{
> -	return gpio_get_value(H3_NAND_RB_GPIO_PIN);
> -}
> -
>  static void __init h3_init(void)
>  {
>  	/* Here we assume the NOR boot config:  NOR on CS3 (possibly swapped
> @@ -356,7 +380,7 @@ static void __init h3_init(void)
>  	nand_resource.end += SZ_4K - 1;
>  	if (gpio_request(H3_NAND_RB_GPIO_PIN, "NAND ready") < 0)
>  		BUG();
> -	nand_data.dev_ready = nand_dev_ready;
> +	gpio_direction_input(H3_NAND_RB_GPIO_PIN);
>  
>  	/* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
>  	/* GPIO10 pullup/down register, Enable pullup on GPIO10 */
> diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c
> index ca7df1e..dba0f7b 100644
> --- a/arch/arm/mach-omap1/board-perseus2.c
> +++ b/arch/arm/mach-omap1/board-perseus2.c
> @@ -30,7 +30,6 @@
>  #include <mach/gpio.h>
>  #include <plat/mux.h>
>  #include <plat/fpga.h>
> -#include <plat/nand.h>
>  #include <plat/keypad.h>
>  #include <plat/common.h>
>  #include <plat/board.h>
> @@ -134,8 +133,40 @@ static struct platform_device nor_device = {
>  	.resource	= &nor_resource,
>  };
>  
> -static struct omap_nand_platform_data nand_data = {
> -	.options	= NAND_SAMSUNG_LP_OPTIONS,
> +static void nand_cmd_ctl(struct mtd_info *mtd, int cmd,	unsigned int ctrl)
> +{
> +	struct nand_chip *this = mtd->priv;
> +	unsigned long mask;
> +
> +	if (cmd == NAND_CMD_NONE)
> +		return;
> +
> +	mask = (ctrl & NAND_CLE) ? 0x02 : 0;
> +	if (ctrl & NAND_ALE)
> +		mask |= 0x04;
> +	writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
> +}
> +
> +#define P2_NAND_RB_GPIO_PIN	62
> +
> +static int nand_dev_ready(struct mtd_info *mtd)
> +{
> +	return gpio_get_value(P2_NAND_RB_GPIO_PIN);
> +}
> +
> +static const char *part_probes[] = { "cmdlinepart", NULL };
> +
> +static struct platform_nand_data nand_data = {
> +	.chip	= {
> +		.nr_chips		= 1,
> +		.chip_offset		= 0,
> +		.options		= NAND_SAMSUNG_LP_OPTIONS,
> +		.part_probe_types	= part_probes,
> +	},
> +	.ctrl	= {
> +		.cmd_ctrl	= nand_cmd_ctl,
> +		.dev_ready	= nand_dev_ready,
> +	},
>  };
>  
>  static struct resource nand_resource = {
> @@ -145,7 +176,7 @@ static struct resource nand_resource = {
>  };
>  
>  static struct platform_device nand_device = {
> -	.name		= "omapnand",
> +	.name		= "gen_nand",
>  	.id		= 0,
>  	.dev		= {
>  		.platform_data	= &nand_data,
> @@ -201,13 +232,6 @@ static struct platform_device *devices[] __initdata = {
>  	&lcd_device,
>  };
>  
> -#define P2_NAND_RB_GPIO_PIN	62
> -
> -static int nand_dev_ready(struct omap_nand_platform_data *data)
> -{
> -	return gpio_get_value(P2_NAND_RB_GPIO_PIN);
> -}
> -
>  static struct omap_lcd_config perseus2_lcd_config __initdata = {
>  	.ctrl_name	= "internal",
>  };
> @@ -220,7 +244,7 @@ static void __init omap_perseus2_init(void)
>  {
>  	if (gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0)
>  		BUG();
> -	nand_data.dev_ready = nand_dev_ready;
> +	gpio_direction_input(P2_NAND_RB_GPIO_PIN);
>  
>  	omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
>  	omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] [OMAP1] use gen_nand
  2009-11-30 20:23   ` Ladislav Michl
@ 2009-11-30 19:38     ` Brian Swetland
  0 siblings, 0 replies; 5+ messages in thread
From: Brian Swetland @ 2009-11-30 19:38 UTC (permalink / raw)
  To: Ladislav Michl; +Cc: Tony Lindgren, linux-omap, Imre Deak, Kevin Hilman

On Mon, Nov 30, 2009 at 12:23 PM, Ladislav Michl
<Ladislav.Michl@seznam.cz> wrote:
> On Mon, Nov 23, 2009 at 09:24:16AM -0800, Tony Lindgren wrote:
>> * Ladislav Michl <Ladislav.Michl@seznam.cz> [091123 03:45]:
>> > Since omapnand driver never find its way into mainline, switch to gen_nand instead.
>> > Following patch is compile tested only, but it is based on code I wrote for
>> > NetStar board and runtime tested it there.
>>
>> Nice patch, and totally the way to go!
>
> Well, after one week of silence... Anything else I could do to get it merged?
> Btw, these boards could probably use physmap-flash, so we could get rid of
> omap_nor as well.

No objections here.  We haven't used f-sample boards since 2005, so
there's no side-effects to cleanup that I'm worried about.

Brian

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

* Re: [PATCH] [OMAP1] use gen_nand
  2009-11-23 17:24 ` Tony Lindgren
@ 2009-11-30 20:23   ` Ladislav Michl
  2009-11-30 19:38     ` Brian Swetland
  0 siblings, 1 reply; 5+ messages in thread
From: Ladislav Michl @ 2009-11-30 20:23 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, Imre Deak, Brian Swetland, Kevin Hilman

On Mon, Nov 23, 2009 at 09:24:16AM -0800, Tony Lindgren wrote:
> * Ladislav Michl <Ladislav.Michl@seznam.cz> [091123 03:45]:
> > Since omapnand driver never find its way into mainline, switch to gen_nand instead.
> > Following patch is compile tested only, but it is based on code I wrote for
> > NetStar board and runtime tested it there.
> 
> Nice patch, and totally the way to go!

Well, after one week of silence... Anything else I could do to get it merged?
Btw, these boards could probably use physmap-flash, so we could get rid of
omap_nor as well.

Best regards,
	ladis

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

* [APPLIED] [PATCH] [OMAP1] use gen_nand
  2009-11-23 12:45 [PATCH] [OMAP1] use gen_nand Ladislav Michl
  2009-11-23 17:24 ` Tony Lindgren
@ 2009-12-04 23:28 ` Tony Lindgren
  1 sibling, 0 replies; 5+ messages in thread
From: Tony Lindgren @ 2009-12-04 23:28 UTC (permalink / raw)
  To: linux-omap

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Branch in linux-omap: for-next-vol2

Initial commit ID (Likely to change): d6ebf3557861e5d023e11e027cd321b5e39f885b

PatchWorks
http://patchwork.kernel.org/patch/62142/

Git (Likely to change, and takes a while to get mirrored)
http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git;a=commit;h=d6ebf3557861e5d023e11e027cd321b5e39f885b



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

end of thread, other threads:[~2009-12-04 23:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-23 12:45 [PATCH] [OMAP1] use gen_nand Ladislav Michl
2009-11-23 17:24 ` Tony Lindgren
2009-11-30 20:23   ` Ladislav Michl
2009-11-30 19:38     ` Brian Swetland
2009-12-04 23:28 ` [APPLIED] " Tony Lindgren

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