Skip to content

Commit

Permalink
atmel/nand: add DT support
Browse files Browse the repository at this point in the history
Use a local copy of board informatin and fill with DT data.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
  • Loading branch information
Jean-Christophe PLAGNIOL-VILLARD committed Mar 15, 2012
1 parent 770d7c3 commit d6a0166
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 78 deletions.
41 changes: 41 additions & 0 deletions Documentation/devicetree/bindings/mtd/atmel-nand.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Atmel NAND flash

Required properties:
- compatible : "atmel,at91rm9200-nand".
- reg : should specify localbus address and size used for the chip,
and if availlable the ECC.
- atmel,nand-addr-offset : offset for the address latch.
- atmel,nand-cmd-offset : offset for the command latch.
- #address-cells, #size-cells : Must be present if the device has sub-nodes
representing partitions.

- gpios : specifies the gpio pins to control the NAND device. detect is an
optional gpio and may be set to 0 if not present.

Optional properties:
- nand-ecc-mode : String, operation mode of the NAND ecc mode, soft by default.
Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
"soft_bch".
- nand-bus-width : 8 or 16 bus width if not present 8
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false

Examples:
nand0: nand@40000000,0 {
compatible = "atmel,at91rm9200-nand";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x40000000 0x10000000
0xffffe800 0x200
>;
atmel,nand-addr-offset = <21>;
atmel,nand-cmd-offset = <22>;
nand-on-flash-bbt;
nand-ecc-mode = "soft";
gpios = <&pioC 13 0
&pioC 14 0
0
>;
partition@0 {
...
};
};
16 changes: 16 additions & 0 deletions arch/arm/boot/dts/at91sam9g20.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,21 @@
status = "disabled";
};
};

nand0: nand@40000000 {
compatible = "atmel,at91rm9200-nand";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x40000000 0x10000000
0xffffe800 0x200
>;
atmel,nand-addr-offset = <21>;
atmel,nand-cmd-offset = <22>;
gpios = <&pioC 13 0
&pioC 14 0
0
>;
status = "disabled";
};
};
};
16 changes: 16 additions & 0 deletions arch/arm/boot/dts/at91sam9g45.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,21 @@
status = "disabled";
};
};

nand0: nand@40000000 {
compatible = "atmel,at91rm9200-nand";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x40000000 0x10000000
0xffffe200 0x200
>;
atmel,nand-addr-offset = <21>;
atmel,nand-cmd-offset = <22>;
gpios = <&pioC 8 0
&pioC 14 0
0
>;
status = "disabled";
};
};
};
25 changes: 24 additions & 1 deletion arch/arm/boot/dts/at91sam9m10g45ek.dts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
compatible = "atmel,at91sam9m10g45ek", "atmel,at91sam9g45", "atmel,at91sam9";

chosen {
bootargs = "mem=64M console=ttyS0,115200 mtdparts=atmel_nand:4M(bootstrap/uboot/kernel)ro,60M(rootfs),-(data) root=/dev/mtdblock1 rw rootfstype=jffs2";
bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2";
};

memory@70000000 {
Expand All @@ -36,6 +36,29 @@
status = "okay";
};
};

nand0: nand@40000000 {
nand-bus-width = <8>;
nand-ecc-mode = "soft";
nand-on-flash-bbt;
status = "okay";

boot@0 {
label = "bootstrap/uboot/kernel";
reg = <0x0 0x400000>;
};

rootfs@400000 {
label = "rootfs";
reg = <0x400000 0x3C00000>;
};

data@4000000 {
label = "data";
reg = <0x4000000 0xC000000>;
};

};
};

leds {
Expand Down
44 changes: 43 additions & 1 deletion arch/arm/boot/dts/usb_a9g20.dts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
compatible = "calao,usb-a9g20", "atmel,at91sam9g20", "atmel,at91sam9";

chosen {
bootargs = "mem=64M console=ttyS0,115200 mtdparts=atmel_nand:128k(at91bootstrap),256k(barebox)ro,128k(bareboxenv),128k(bareboxenv2),4M(kernel),120M(rootfs),-(data) root=/dev/mtdblock5 rw rootfstype=ubifs";
bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock5 rw rootfstype=ubifs";
};

memory@20000000 {
Expand All @@ -31,6 +31,48 @@
status = "okay";
};
};

nand0: nand@40000000 {
nand-bus-width = <8>;
nand-ecc-mode = "soft";
nand-on-flash-bbt;
status = "okay";

at91bootstrap@0 {
label = "at91bootstrap";
reg = <0x0 0x20000>;
};

barebox@20000 {
label = "barebox";
reg = <0x20000 0x40000>;
};

bareboxenv@60000 {
label = "bareboxenv";
reg = <0x60000 0x20000>;
};

bareboxenv2@80000 {
label = "bareboxenv2";
reg = <0x80000 0x20000>;
};

kernel@a0000 {
label = "kernel";
reg = <0xa0000 0x400000>;
};

rootfs@4a0000 {
label = "rootfs";
reg = <0x4a0000 0x7800000>;
};

data@7ca0000 {
label = "data";
reg = <0x7ca0000 0x8360000>;
};
};
};

leds {
Expand Down
5 changes: 0 additions & 5 deletions arch/arm/mach-at91/at91sam9x5.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,6 @@ void __init at91sam9x5_initialize(void)
at91_gpio_init(NULL, 0);
}

/* --------------------------------------------------------------------
* AT91SAM9x5 devices (temporary before modification of code)
* -------------------------------------------------------------------- */
void __init at91_add_device_nand(struct atmel_nand_data *data) {}

/* --------------------------------------------------------------------
* Interrupt initialization
* -------------------------------------------------------------------- */
Expand Down
51 changes: 0 additions & 51 deletions arch/arm/mach-at91/board-dt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,14 @@
#include <linux/of_irq.h>
#include <linux/of_platform.h>

#include <mach/hardware.h>
#include <mach/board.h>
#include <mach/system_rev.h>
#include <mach/at91sam9_smc.h>

#include <asm/setup.h>
#include <asm/irq.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>

#include "sam9_smc.h"
#include "generic.h"


Expand All @@ -40,50 +36,6 @@ static void __init ek_init_early(void)
at91_initialize(12000000);
}

/* det_pin is not connected */
static struct atmel_nand_data __initdata ek_nand_data = {
.ale = 21,
.cle = 22,
.det_pin = -EINVAL,
.rdy_pin = AT91_PIN_PC8,
.enable_pin = AT91_PIN_PC14,
.ecc_mode = NAND_ECC_SOFT,
.on_flash_bbt = 1,
};

static struct sam9_smc_config __initdata ek_nand_smc_config = {
.ncs_read_setup = 0,
.nrd_setup = 2,
.ncs_write_setup = 0,
.nwe_setup = 2,

.ncs_read_pulse = 4,
.nrd_pulse = 4,
.ncs_write_pulse = 4,
.nwe_pulse = 4,

.read_cycle = 7,
.write_cycle = 7,

.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
.tdf_cycles = 3,
};

static void __init ek_add_device_nand(void)
{
ek_nand_data.bus_width_16 = board_have_nand_16bit();
/* setup bus-width (8 or 16) */
if (ek_nand_data.bus_width_16)
ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
else
ek_nand_smc_config.mode |= AT91_SMC_DBW_8;

/* configure chip-select 3 (NAND) */
sam9_smc_configure(0, 3, &ek_nand_smc_config);

at91_add_device_nand(&ek_nand_data);
}

static const struct of_device_id irq_of_match[] __initconst = {

{ .compatible = "atmel,at91rm9200-aic", .data = at91_aic_of_init },
Expand All @@ -100,9 +52,6 @@ static void __init at91_dt_init_irq(void)
static void __init at91_dt_device_init(void)
{
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);

/* NAND */
ek_add_device_nand();
}

static const char *at91_dt_board_compat[] __initdata = {
Expand Down
Loading

0 comments on commit d6a0166

Please sign in to comment.