]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-at91/board-sam9261ek.c
Merge branch 'omap3-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind...
[linux-2.6-omap-h63xx.git] / arch / arm / mach-at91 / board-sam9261ek.c
index 43dfbd0d543a07c7aeb7689354e3ea506bff60b1..d5266da553112651228679c4beb42944b89a2d42 100644 (file)
@@ -35,7 +35,6 @@
 
 #include <video/atmel_lcdc.h>
 
-#include <asm/hardware.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
 #include <asm/irq.h>
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
 
-#include <asm/arch/board.h>
-#include <asm/arch/gpio.h>
-#include <asm/arch/at91sam9_smc.h>
+#include <mach/hardware.h>
+#include <mach/board.h>
+#include <mach/gpio.h>
+#include <mach/at91sam9_smc.h>
+#include <mach/at91_shdwc.h>
 
+#include "sam9_smc.h"
 #include "generic.h"
 
 
@@ -76,7 +78,7 @@ static void __init ek_init_irq(void)
  * DM9000 ethernet device
  */
 #if defined(CONFIG_DM9000)
-static struct resource at91sam9261_dm9000_resource[] = {
+static struct resource dm9000_resource[] = {
        [0] = {
                .start  = AT91_CHIPSELECT_2,
                .end    = AT91_CHIPSELECT_2 + 3,
@@ -98,27 +100,42 @@ static struct dm9000_plat_data dm9000_platdata = {
        .flags          = DM9000_PLATF_16BITONLY,
 };
 
-static struct platform_device at91sam9261_dm9000_device = {
+static struct platform_device dm9000_device = {
        .name           = "dm9000",
        .id             = 0,
-       .num_resources  = ARRAY_SIZE(at91sam9261_dm9000_resource),
-       .resource       = at91sam9261_dm9000_resource,
+       .num_resources  = ARRAY_SIZE(dm9000_resource),
+       .resource       = dm9000_resource,
        .dev            = {
                .platform_data  = &dm9000_platdata,
        }
 };
 
+/*
+ * SMC timings for the DM9000.
+ * Note: These timings were calculated for MASTER_CLOCK = 100000000 according to the DM9000 timings.
+ */
+static struct sam9_smc_config __initdata dm9000_smc_config = {
+       .ncs_read_setup         = 0,
+       .nrd_setup              = 2,
+       .ncs_write_setup        = 0,
+       .nwe_setup              = 2,
+
+       .ncs_read_pulse         = 8,
+       .nrd_pulse              = 4,
+       .ncs_write_pulse        = 8,
+       .nwe_pulse              = 4,
+
+       .read_cycle             = 16,
+       .write_cycle            = 16,
+
+       .mode                   = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16,
+       .tdf_cycles             = 1,
+};
+
 static void __init ek_add_device_dm9000(void)
 {
-       /*
-        * Configure Chip-Select 2 on SMC for the DM9000.
-        * Note: These timings were calculated for MASTER_CLOCK = 100000000
-        *  according to the DM9000 timings.
-        */
-       at91_sys_write(AT91_SMC_SETUP(2), AT91_SMC_NWESETUP_(2) | AT91_SMC_NCS_WRSETUP_(0) | AT91_SMC_NRDSETUP_(2) | AT91_SMC_NCS_RDSETUP_(0));
-       at91_sys_write(AT91_SMC_PULSE(2), AT91_SMC_NWEPULSE_(4) | AT91_SMC_NCS_WRPULSE_(8) | AT91_SMC_NRDPULSE_(4) | AT91_SMC_NCS_RDPULSE_(8));
-       at91_sys_write(AT91_SMC_CYCLE(2), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16));
-       at91_sys_write(AT91_SMC_MODE(2), AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16 | AT91_SMC_TDF_(1));
+       /* Configure chip-select 2 (DM9000) */
+       sam9_smc_configure(2, &dm9000_smc_config);
 
        /* Configure Reset signal as output */
        at91_set_gpio_output(AT91_PIN_PC10, 0);
@@ -126,7 +143,7 @@ static void __init ek_add_device_dm9000(void)
        /* Configure Interrupt pin as input, no pull-up */
        at91_set_gpio_input(AT91_PIN_PC11, 0);
 
-       platform_device_register(&at91sam9261_dm9000_device);
+       platform_device_register(&dm9000_device);
 }
 #else
 static void __init ek_add_device_dm9000(void) {}
@@ -168,11 +185,11 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
        {
                .name   = "Partition 1",
                .offset = 0,
-               .size   = 256 * 1024,
+               .size   = SZ_256K,
        },
        {
                .name   = "Partition 2",
-               .offset = 256 * 1024 ,
+               .offset = MTDPART_OFS_NXTBLK,
                .size   = MTDPART_SIZ_FULL,
        },
 };
@@ -190,13 +207,46 @@ static struct atmel_nand_data __initdata ek_nand_data = {
        .rdy_pin        = AT91_PIN_PC15,
        .enable_pin     = AT91_PIN_PC14,
        .partition_info = nand_partitions,
-#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
+#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
        .bus_width_16   = 1,
 #else
        .bus_width_16   = 0,
 #endif
 };
 
+static struct sam9_smc_config __initdata ek_nand_smc_config = {
+       .ncs_read_setup         = 0,
+       .nrd_setup              = 1,
+       .ncs_write_setup        = 0,
+       .nwe_setup              = 1,
+
+       .ncs_read_pulse         = 3,
+       .nrd_pulse              = 3,
+       .ncs_write_pulse        = 3,
+       .nwe_pulse              = 3,
+
+       .read_cycle             = 5,
+       .write_cycle            = 5,
+
+       .mode                   = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
+       .tdf_cycles             = 2,
+};
+
+static void __init ek_add_device_nand(void)
+{
+       /* 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(3, &ek_nand_smc_config);
+
+       at91_add_device_nand(&ek_nand_data);
+}
+
+
 /*
  * ADS7846 Touchscreen
  */
@@ -435,24 +485,28 @@ static struct gpio_keys_button ek_buttons[] = {
                .code           = BTN_0,
                .desc           = "Button 0",
                .active_low     = 1,
+               .wakeup         = 1,
        },
        {
                .gpio           = AT91_PIN_PA26,
                .code           = BTN_1,
                .desc           = "Button 1",
                .active_low     = 1,
+               .wakeup         = 1,
        },
        {
                .gpio           = AT91_PIN_PA25,
                .code           = BTN_2,
                .desc           = "Button 2",
                .active_low     = 1,
+               .wakeup         = 1,
        },
        {
                .gpio           = AT91_PIN_PA24,
                .code           = BTN_3,
                .desc           = "Button 3",
                .active_low     = 1,
+               .wakeup         = 1,
        }
 };
 
@@ -472,13 +526,13 @@ static struct platform_device ek_button_device = {
 
 static void __init ek_add_device_buttons(void)
 {
-       at91_set_gpio_input(AT91_PIN_PA27, 0);  /* btn0 */
+       at91_set_gpio_input(AT91_PIN_PA27, 1);  /* btn0 */
        at91_set_deglitch(AT91_PIN_PA27, 1);
-       at91_set_gpio_input(AT91_PIN_PA26, 0);  /* btn1 */
+       at91_set_gpio_input(AT91_PIN_PA26, 1);  /* btn1 */
        at91_set_deglitch(AT91_PIN_PA26, 1);
-       at91_set_gpio_input(AT91_PIN_PA25, 0);  /* btn2 */
+       at91_set_gpio_input(AT91_PIN_PA25, 1);  /* btn2 */
        at91_set_deglitch(AT91_PIN_PA25, 1);
-       at91_set_gpio_input(AT91_PIN_PA24, 0);  /* btn3 */
+       at91_set_gpio_input(AT91_PIN_PA24, 1);  /* btn3 */
        at91_set_deglitch(AT91_PIN_PA24, 1);
 
        platform_device_register(&ek_button_device);
@@ -521,7 +575,7 @@ static void __init ek_board_init(void)
        /* I2C */
        at91_add_device_i2c(NULL, 0);
        /* NAND */
-       at91_add_device_nand(&ek_nand_data);
+       ek_add_device_nand();
        /* DM9000 ethernet */
        ek_add_device_dm9000();