]> Pileus Git - ~andy/linux/blob - arch/arm/mach-at91/board-dt.c
ATMEL: fix nand ecc support
[~andy/linux] / arch / arm / mach-at91 / board-dt.c
1 /*
2  *  Setup code for AT91SAM Evaluation Kits with Device Tree support
3  *
4  *  Covers: * AT91SAM9G45-EKES  board
5  *          * AT91SAM9M10-EKES  board
6  *          * AT91SAM9M10G45-EK board
7  *
8  *  Copyright (C) 2011 Atmel,
9  *                2011 Nicolas Ferre <nicolas.ferre@atmel.com>
10  *
11  * Licensed under GPLv2 or later.
12  */
13
14 #include <linux/types.h>
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/gpio.h>
18 #include <linux/of.h>
19 #include <linux/of_irq.h>
20 #include <linux/of_platform.h>
21
22 #include <mach/hardware.h>
23 #include <mach/board.h>
24 #include <mach/system_rev.h>
25 #include <mach/at91sam9_smc.h>
26
27 #include <asm/setup.h>
28 #include <asm/irq.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31 #include <asm/mach/irq.h>
32
33 #include "sam9_smc.h"
34 #include "generic.h"
35
36
37 static void __init ek_init_early(void)
38 {
39         /* Initialize processor: 12.000 MHz crystal */
40         at91_initialize(12000000);
41 }
42
43 /* det_pin is not connected */
44 static struct atmel_nand_data __initdata ek_nand_data = {
45         .ale            = 21,
46         .cle            = 22,
47         .det_pin        = -EINVAL,
48         .rdy_pin        = AT91_PIN_PC8,
49         .enable_pin     = AT91_PIN_PC14,
50         .ecc_mode       = NAND_ECC_SOFT,
51 };
52
53 static struct sam9_smc_config __initdata ek_nand_smc_config = {
54         .ncs_read_setup         = 0,
55         .nrd_setup              = 2,
56         .ncs_write_setup        = 0,
57         .nwe_setup              = 2,
58
59         .ncs_read_pulse         = 4,
60         .nrd_pulse              = 4,
61         .ncs_write_pulse        = 4,
62         .nwe_pulse              = 4,
63
64         .read_cycle             = 7,
65         .write_cycle            = 7,
66
67         .mode                   = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
68         .tdf_cycles             = 3,
69 };
70
71 static void __init ek_add_device_nand(void)
72 {
73         ek_nand_data.bus_width_16 = board_have_nand_16bit();
74         /* setup bus-width (8 or 16) */
75         if (ek_nand_data.bus_width_16)
76                 ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
77         else
78                 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
79
80         /* configure chip-select 3 (NAND) */
81         sam9_smc_configure(0, 3, &ek_nand_smc_config);
82
83         at91_add_device_nand(&ek_nand_data);
84 }
85
86 static const struct of_device_id irq_of_match[] __initconst = {
87
88         { .compatible = "atmel,at91rm9200-aic", .data = at91_aic_of_init },
89         { .compatible = "atmel,at91rm9200-gpio", .data = at91_gpio_of_irq_setup },
90         { .compatible = "atmel,at91sam9x5-gpio", .data = at91_gpio_of_irq_setup },
91         { /*sentinel*/ }
92 };
93
94 static void __init at91_dt_init_irq(void)
95 {
96         of_irq_init(irq_of_match);
97 }
98
99 static void __init at91_dt_device_init(void)
100 {
101         of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
102
103         /* NAND */
104         ek_add_device_nand();
105 }
106
107 static const char *at91_dt_board_compat[] __initdata = {
108         "atmel,at91sam9m10g45ek",
109         "atmel,at91sam9x5ek",
110         "calao,usb-a9g20",
111         NULL
112 };
113
114 DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM (Device Tree)")
115         /* Maintainer: Atmel */
116         .timer          = &at91sam926x_timer,
117         .map_io         = at91_map_io,
118         .init_early     = ek_init_early,
119         .init_irq       = at91_dt_init_irq,
120         .init_machine   = at91_dt_device_init,
121         .dt_compat      = at91_dt_board_compat,
122 MACHINE_END