2 * Merisc board-specific flash initialization
4 * Copyright (C) 2008 Martinsson Elektronik AB
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.
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>
17 /* Will be translated to units of 14.3 ns, rounded up */
18 static struct smc_timing flash_timing __initdata = {
19 .ncs_read_setup = 1 * 14,
21 .ncs_write_setup = 1 * 14,
24 .ncs_read_pulse = 12 * 14,
26 .ncs_write_pulse = 8 * 14,
29 .read_cycle = 14 * 14,
30 .write_cycle = 10 * 14,
33 static struct smc_config flash_config __initdata = {
41 static struct mtd_partition flash_0_parts[] = {
57 .size = MTDPART_SIZ_FULL,
62 static struct mtd_partition flash_1_parts[] = {
66 .size = MTDPART_SIZ_FULL,
71 static struct physmap_flash_data flash_data[] = {
74 .nr_parts = ARRAY_SIZE(flash_0_parts),
75 .parts = flash_0_parts,
79 .nr_parts = ARRAY_SIZE(flash_1_parts),
80 .parts = flash_1_parts,
84 static struct resource flash_resource[] = {
88 .flags = IORESOURCE_MEM,
93 .flags = IORESOURCE_MEM,
97 static struct platform_device flash_device[] = {
99 .name = "physmap-flash",
101 .resource = &flash_resource[0],
104 .platform_data = &flash_data[0],
108 .name = "physmap-flash",
110 .resource = &flash_resource[1],
113 .platform_data = &flash_data[1],
118 static int __init merisc_flash_init(void)
121 smc_set_timing(&flash_config, &flash_timing);
123 ret = smc_set_configuration(0, &flash_config);
125 printk(KERN_ERR "Merisc: failed to set NOR flash timing #0\n");
129 ret = smc_set_configuration(4, &flash_config);
131 printk(KERN_ERR "Merisc: failed to set NOR flash timing #1\n");
135 platform_device_register(&flash_device[0]);
136 platform_device_register(&flash_device[1]);
139 device_initcall(merisc_flash_init);