Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-btrfs-devel.git] / arch / avr32 / boards / favr-32 / flash.c
blob604bbd5e41d9b6c6c98dd7ceec835a345e1b22fd
1 /*
2 * Favr-32 board-specific flash initialization
4 * Copyright (C) 2008 Atmel Corporation
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>
16 #include <mach/smc.h>
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,
24 .ncs_read_pulse = 80,
25 .nrd_pulse = 40,
26 .ncs_write_pulse = 65,
27 .nwe_pulse = 55,
29 .read_cycle = 120,
30 .write_cycle = 120,
33 static struct smc_config flash_config __initdata = {
34 .bus_width = 2,
35 .nrd_controlled = 1,
36 .nwe_controlled = 1,
37 .byte_write = 1,
40 static struct mtd_partition flash_parts[] = {
42 .name = "u-boot",
43 .offset = 0x00000000,
44 .size = 0x00020000, /* 128 KiB */
45 .mask_flags = MTD_WRITEABLE,
48 .name = "root",
49 .offset = 0x00020000,
50 .size = 0x007d0000,
53 .name = "env",
54 .offset = 0x007f0000,
55 .size = 0x00010000,
56 .mask_flags = MTD_WRITEABLE,
60 static struct physmap_flash_data flash_data = {
61 .width = 2,
62 .nr_parts = ARRAY_SIZE(flash_parts),
63 .parts = flash_parts,
66 static struct resource flash_resource = {
67 .start = 0x00000000,
68 .end = 0x007fffff,
69 .flags = IORESOURCE_MEM,
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,
82 /* This needs to be called after the SMC has been initialized */
83 static int __init favr32_flash_init(void)
85 int ret;
87 smc_set_timing(&flash_config, &flash_timing);
88 ret = smc_set_configuration(0, &flash_config);
89 if (ret < 0) {
90 printk(KERN_ERR "Favr-32: failed to set NOR flash timing\n");
91 return ret;
94 platform_device_register(&flash_device);
96 return 0;
98 device_initcall(favr32_flash_init);