Merge branch 'intelfb-patches' of master.kernel.org:/pub/scm/linux/kernel/git/airlied...
[linux-2.6] / arch / avr32 / boards / atstk1000 / flash.c
1 /*
2  * ATSTK1000 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_config flash_config __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         .bus_width              = 2,
33         .nrd_controlled         = 1,
34         .nwe_controlled         = 1,
35         .byte_write             = 1,
36 };
37
38 static struct mtd_partition flash_parts[] = {
39         {
40                 .name           = "u-boot",
41                 .offset         = 0x00000000,
42                 .size           = 0x00020000,           /* 128 KiB */
43                 .mask_flags     = MTD_WRITEABLE,
44         },
45         {
46                 .name           = "root",
47                 .offset         = 0x00020000,
48                 .size           = 0x007d0000,
49         },
50         {
51                 .name           = "env",
52                 .offset         = 0x007f0000,
53                 .size           = 0x00010000,
54                 .mask_flags     = MTD_WRITEABLE,
55         },
56 };
57
58 static struct physmap_flash_data flash_data = {
59         .width          = 2,
60         .nr_parts       = ARRAY_SIZE(flash_parts),
61         .parts          = flash_parts,
62 };
63
64 static struct resource flash_resource = {
65         .start          = 0x00000000,
66         .end            = 0x007fffff,
67         .flags          = IORESOURCE_MEM,
68 };
69
70 static struct platform_device flash_device = {
71         .name           = "physmap-flash",
72         .id             = 0,
73         .resource       = &flash_resource,
74         .num_resources  = 1,
75         .dev            = {
76                 .platform_data = &flash_data,
77         },
78 };
79
80 /* This needs to be called after the SMC has been initialized */
81 static int __init atstk1000_flash_init(void)
82 {
83         int ret;
84
85         ret = smc_set_configuration(0, &flash_config);
86         if (ret < 0) {
87                 printk(KERN_ERR "atstk1000: failed to set NOR flash timing\n");
88                 return ret;
89         }
90
91         platform_device_register(&flash_device);
92
93         return 0;
94 }
95 device_initcall(atstk1000_flash_init);