Path: blob/master/arch/avr32/boards/merisc/flash.c
10819 views
/*1* Merisc board-specific flash initialization2*3* Copyright (C) 2008 Martinsson Elektronik AB4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License version 2 as7* published by the Free Software Foundation.8*/9#include <linux/init.h>10#include <linux/platform_device.h>11#include <linux/mtd/mtd.h>12#include <linux/mtd/partitions.h>13#include <linux/mtd/physmap.h>14#include <mach/smc.h>1516/* Will be translated to units of 14.3 ns, rounded up */17static struct smc_timing flash_timing __initdata = {18.ncs_read_setup = 1 * 14,19.nrd_setup = 5 * 14,20.ncs_write_setup = 1 * 14,21.nwe_setup = 2 * 14,2223.ncs_read_pulse = 12 * 14,24.nrd_pulse = 7 * 14,25.ncs_write_pulse = 8 * 14,26.nwe_pulse = 4 * 14,2728.read_cycle = 14 * 14,29.write_cycle = 10 * 14,30};3132static struct smc_config flash_config __initdata = {33.bus_width = 2,34.nrd_controlled = 1,35.nwe_controlled = 1,36.byte_write = 1,37.tdf_cycles = 3,38};3940static struct mtd_partition flash_0_parts[] = {41{42.name = "boot",43.offset = 0x00000000,44.size = 0x00060000,45.mask_flags = 0,46},47{48.name = "kernel",49.offset = 0x00060000,50.size = 0x00200000,51.mask_flags = 0,52},53{54.name = "root",55.offset = 0x00260000,56.size = MTDPART_SIZ_FULL,57.mask_flags = 0,58},59};6061static struct mtd_partition flash_1_parts[] = {62{63.name = "2ndflash",64.offset = 0x00000000,65.size = MTDPART_SIZ_FULL,66.mask_flags = 0,67},68};6970static struct physmap_flash_data flash_data[] = {71{72.width = 2,73.nr_parts = ARRAY_SIZE(flash_0_parts),74.parts = flash_0_parts,75},76{77.width = 2,78.nr_parts = ARRAY_SIZE(flash_1_parts),79.parts = flash_1_parts,80}81};8283static struct resource flash_resource[] = {84{85.start = 0x00000000,86.end = 0x03ffffff,87.flags = IORESOURCE_MEM,88},89{90.start = 0x04000000,91.end = 0x07ffffff,92.flags = IORESOURCE_MEM,93},94};9596static struct platform_device flash_device[] = {97{98.name = "physmap-flash",99.id = 0,100.resource = &flash_resource[0],101.num_resources = 1,102.dev = {103.platform_data = &flash_data[0],104},105},106{107.name = "physmap-flash",108.id = 1,109.resource = &flash_resource[1],110.num_resources = 1,111.dev = {112.platform_data = &flash_data[1],113},114},115};116117static int __init merisc_flash_init(void)118{119int ret;120smc_set_timing(&flash_config, &flash_timing);121122ret = smc_set_configuration(0, &flash_config);123if (ret < 0) {124printk(KERN_ERR "Merisc: failed to set NOR flash timing #0\n");125return ret;126}127128ret = smc_set_configuration(4, &flash_config);129if (ret < 0) {130printk(KERN_ERR "Merisc: failed to set NOR flash timing #1\n");131return ret;132}133134platform_device_register(&flash_device[0]);135platform_device_register(&flash_device[1]);136return 0;137}138device_initcall(merisc_flash_init);139140141