Path: blob/master/arch/avr32/boards/favr-32/flash.c
10818 views
/*1* Favr-32 board-specific flash initialization2*3* Copyright (C) 2008 Atmel Corporation4*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 = 40,20.ncs_write_setup = 0,21.nwe_setup = 10,2223.ncs_read_pulse = 80,24.nrd_pulse = 40,25.ncs_write_pulse = 65,26.nwe_pulse = 55,2728.read_cycle = 120,29.write_cycle = 120,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};3839static struct mtd_partition flash_parts[] = {40{41.name = "u-boot",42.offset = 0x00000000,43.size = 0x00020000, /* 128 KiB */44.mask_flags = MTD_WRITEABLE,45},46{47.name = "root",48.offset = 0x00020000,49.size = 0x007d0000,50},51{52.name = "env",53.offset = 0x007f0000,54.size = 0x00010000,55.mask_flags = MTD_WRITEABLE,56},57};5859static struct physmap_flash_data flash_data = {60.width = 2,61.nr_parts = ARRAY_SIZE(flash_parts),62.parts = flash_parts,63};6465static struct resource flash_resource = {66.start = 0x00000000,67.end = 0x007fffff,68.flags = IORESOURCE_MEM,69};7071static struct platform_device flash_device = {72.name = "physmap-flash",73.id = 0,74.resource = &flash_resource,75.num_resources = 1,76.dev = {77.platform_data = &flash_data,78},79};8081/* This needs to be called after the SMC has been initialized */82static int __init favr32_flash_init(void)83{84int ret;8586smc_set_timing(&flash_config, &flash_timing);87ret = smc_set_configuration(0, &flash_config);88if (ret < 0) {89printk(KERN_ERR "Favr-32: failed to set NOR flash timing\n");90return ret;91}9293platform_device_register(&flash_device);9495return 0;96}97device_initcall(favr32_flash_init);9899100