]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/avr32/boards/atngw100/flash.c
b07ae63aa54802eaa47b700c009da90c83f31a9a
[linux-2.6-omap-h63xx.git] / arch / avr32 / boards / atngw100 / flash.c
1 /*
2  * ATNGW100 board-specific flash initialization
3  *
4  * Copyright (C) 2005-2006 Atmel Corporation
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #include <linux/init.h>
11 #include <linux/platform_device.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/mtd/physmap.h>
15
16 #include <asm/arch/smc.h>
17
18 static struct smc_timing flash_timing __initdata = {
19         .ncs_read_setup         = 0,
20         .nrd_setup              = 40,
21         .ncs_write_setup        = 0,
22         .nwe_setup              = 10,
23
24         .ncs_read_pulse         = 80,
25         .nrd_pulse              = 40,
26         .ncs_write_pulse        = 65,
27         .nwe_pulse              = 55,
28
29         .read_cycle             = 120,
30         .write_cycle            = 120,
31 };
32
33 static struct smc_config flash_config __initdata = {
34         .bus_width              = 2,
35         .nrd_controlled         = 1,
36         .nwe_controlled         = 1,
37         .byte_write             = 1,
38 };
39
40 static struct mtd_partition flash_parts[] = {
41         {
42                 .name           = "u-boot",
43                 .offset         = 0x00000000,
44                 .size           = 0x00020000,           /* 128 KiB */
45                 .mask_flags     = MTD_WRITEABLE,
46         },
47         {
48                 .name           = "root",
49                 .offset         = 0x00020000,
50                 .size           = 0x007d0000,
51         },
52         {
53                 .name           = "env",
54                 .offset         = 0x007f0000,
55                 .size           = 0x00010000,
56                 .mask_flags     = MTD_WRITEABLE,
57         },
58 };
59
60 static struct physmap_flash_data flash_data = {
61         .width          = 2,
62         .nr_parts       = ARRAY_SIZE(flash_parts),
63         .parts          = flash_parts,
64 };
65
66 static struct resource flash_resource = {
67         .start          = 0x00000000,
68         .end            = 0x007fffff,
69         .flags          = IORESOURCE_MEM,
70 };
71
72 static struct platform_device flash_device = {
73         .name           = "physmap-flash",
74         .id             = 0,
75         .resource       = &flash_resource,
76         .num_resources  = 1,
77         .dev            = {
78                 .platform_data = &flash_data,
79         },
80 };
81
82 /* This needs to be called after the SMC has been initialized */
83 static int __init atngw100_flash_init(void)
84 {
85         int ret;
86
87         smc_set_timing(&flash_config, &flash_timing);
88         ret = smc_set_configuration(0, &flash_config);
89         if (ret < 0) {
90                 printk(KERN_ERR "atngw100: failed to set NOR flash timing\n");
91                 return ret;
92         }
93
94         platform_device_register(&flash_device);
95
96         return 0;
97 }
98 device_initcall(atngw100_flash_init);