Path: blob/master/arch/avr32/boards/mimc200/flash.c
10818 views
/*1* MIMC200 board-specific flash initialization2*3* Copyright (C) 2008 Mercury IMC Ltd4*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>1415#include <mach/smc.h>1617static struct smc_timing flash_timing __initdata = {18.ncs_read_setup = 0,19.nrd_setup = 15,20.ncs_write_setup = 0,21.nwe_setup = 0,2223.ncs_read_pulse = 115,24.nrd_pulse = 110,25.ncs_write_pulse = 60,26.nwe_pulse = 60,2728.read_cycle = 115,29.write_cycle = 100,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};3839/* system flash definition */4041static struct mtd_partition flash_parts_system[] = {42{43.name = "u-boot",44.offset = 0x00000000,45.size = 0x00020000, /* 128 KiB */46.mask_flags = MTD_WRITEABLE,47},48{49.name = "root",50.offset = 0x00020000,51.size = 0x007c0000,52},53{54.name = "splash",55.offset = 0x007e0000,56.size = 0x00010000, /* 64KiB */57},58{59.name = "env",60.offset = 0x007f0000,61.size = 0x00010000,62.mask_flags = MTD_WRITEABLE,63},64};6566static struct physmap_flash_data flash_system = {67.width = 2,68.nr_parts = ARRAY_SIZE(flash_parts_system),69.parts = flash_parts_system,70};7172static struct resource flash_resource_system = {73.start = 0x00000000,74.end = 0x007fffff,75.flags = IORESOURCE_MEM,76};7778static struct platform_device flash_device_system = {79.name = "physmap-flash",80.id = 0,81.resource = &flash_resource_system,82.num_resources = 1,83.dev = {84.platform_data = &flash_system,85},86};8788/* data flash definition */8990static struct mtd_partition flash_parts_data[] = {91{92.name = "data",93.offset = 0x00000000,94.size = 0x00800000,95},96};9798static struct physmap_flash_data flash_data = {99.width = 2,100.nr_parts = ARRAY_SIZE(flash_parts_data),101.parts = flash_parts_data,102};103104static struct resource flash_resource_data = {105.start = 0x08000000,106.end = 0x087fffff,107.flags = IORESOURCE_MEM,108};109110static struct platform_device flash_device_data = {111.name = "physmap-flash",112.id = 1,113.resource = &flash_resource_data,114.num_resources = 1,115.dev = {116.platform_data = &flash_data,117},118};119120/* This needs to be called after the SMC has been initialized */121static int __init mimc200_flash_init(void)122{123int ret;124125smc_set_timing(&flash_config, &flash_timing);126ret = smc_set_configuration(0, &flash_config);127if (ret < 0) {128printk(KERN_ERR "mimc200: failed to set 'System' NOR flash timing\n");129return ret;130}131ret = smc_set_configuration(1, &flash_config);132if (ret < 0) {133printk(KERN_ERR "mimc200: failed to set 'Data' NOR flash timing\n");134return ret;135}136137platform_device_register(&flash_device_system);138platform_device_register(&flash_device_data);139140return 0;141}142device_initcall(mimc200_flash_init);143144145