Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 //
0003 // Copyright (c) 2008 Simtec Electronics
0004 //  http://armlinux.simtec.co.uk/
0005 //  Ben Dooks <ben@simtec.co.uk>
0006 //
0007 // Simtec NOR mapping
0008 
0009 #include <linux/module.h>
0010 #include <linux/types.h>
0011 #include <linux/init.h>
0012 #include <linux/kernel.h>
0013 #include <linux/platform_device.h>
0014 
0015 #include <linux/mtd/mtd.h>
0016 #include <linux/mtd/map.h>
0017 #include <linux/mtd/physmap.h>
0018 #include <linux/mtd/partitions.h>
0019 
0020 #include <asm/mach/arch.h>
0021 #include <asm/mach/map.h>
0022 #include <asm/mach/irq.h>
0023 
0024 #include "map.h"
0025 
0026 #include "bast.h"
0027 #include "simtec.h"
0028 
0029 static void simtec_nor_vpp(struct platform_device *pdev, int vpp)
0030 {
0031     unsigned int val;
0032 
0033     val = __raw_readb(BAST_VA_CTRL3);
0034 
0035     printk(KERN_DEBUG "%s(%d)\n", __func__, vpp);
0036 
0037     if (vpp)
0038         val |= BAST_CPLD_CTRL3_ROMWEN;
0039     else
0040         val &= ~BAST_CPLD_CTRL3_ROMWEN;
0041 
0042     __raw_writeb(val, BAST_VA_CTRL3);
0043 }
0044 
0045 static struct physmap_flash_data simtec_nor_pdata = {
0046     .width      = 2,
0047     .set_vpp    = simtec_nor_vpp,
0048     .nr_parts   = 0,
0049 };
0050 
0051 static struct resource simtec_nor_resource[] = {
0052     [0] = DEFINE_RES_MEM(S3C2410_CS1 + 0x4000000, SZ_8M),
0053 };
0054 
0055 static struct platform_device simtec_device_nor = {
0056     .name       = "physmap-flash",
0057     .id     = -1,
0058     .num_resources  = ARRAY_SIZE(simtec_nor_resource),
0059     .resource   = simtec_nor_resource,
0060     .dev        = {
0061         .platform_data = &simtec_nor_pdata,
0062     },
0063 };
0064 
0065 void __init nor_simtec_init(void)
0066 {
0067     int ret;
0068 
0069     ret = platform_device_register(&simtec_device_nor);
0070     if (ret < 0)
0071         printk(KERN_ERR "failed to register physmap-flash device\n");
0072     else
0073         simtec_nor_vpp(NULL, 1);
0074 }