blob: b9d6d4f92c034c461ee04af9f3632c6342feeb54 [file] [log] [blame]
Ben Dooks9d529c62008-07-03 11:24:39 +01001/* linux/arch/arm/mach-s3c2410/nor-simtec.c
2 *
3 * Copyright (c) 2008 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * Simtec NOR mapping
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#include <linux/module.h>
15#include <linux/types.h>
16#include <linux/init.h>
17#include <linux/kernel.h>
18#include <linux/platform_device.h>
19
20#include <linux/mtd/mtd.h>
21#include <linux/mtd/map.h>
22#include <linux/mtd/physmap.h>
23#include <linux/mtd/partitions.h>
24
25#include <asm/mach/arch.h>
26#include <asm/mach/map.h>
27#include <asm/mach/irq.h>
28
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/map.h>
30#include <mach/bast-map.h>
31#include <mach/bast-cpld.h>
Ben Dooks9d529c62008-07-03 11:24:39 +010032
Heiko Stuebnerec2cc752012-03-07 01:47:11 -080033#include "simtec.h"
Ben Dooks9d529c62008-07-03 11:24:39 +010034
Marc Zyngier667f3902011-05-18 10:51:55 +010035static void simtec_nor_vpp(struct platform_device *pdev, int vpp)
Ben Dooks9d529c62008-07-03 11:24:39 +010036{
37 unsigned int val;
Ben Dooks9d529c62008-07-03 11:24:39 +010038
Ben Dooks9d529c62008-07-03 11:24:39 +010039 val = __raw_readb(BAST_VA_CTRL3);
40
41 printk(KERN_DEBUG "%s(%d)\n", __func__, vpp);
42
43 if (vpp)
44 val |= BAST_CPLD_CTRL3_ROMWEN;
45 else
46 val &= ~BAST_CPLD_CTRL3_ROMWEN;
47
48 __raw_writeb(val, BAST_VA_CTRL3);
Ben Dooks9d529c62008-07-03 11:24:39 +010049}
50
Ben Dooksec829232008-08-26 22:54:02 +010051static struct physmap_flash_data simtec_nor_pdata = {
Ben Dooks9d529c62008-07-03 11:24:39 +010052 .width = 2,
53 .set_vpp = simtec_nor_vpp,
54 .nr_parts = 0,
55};
56
57static struct resource simtec_nor_resource[] = {
58 [0] = {
59 .start = S3C2410_CS1 + 0x4000000,
60 .end = S3C2410_CS1 + 0x4000000 + SZ_8M - 1,
61 .flags = IORESOURCE_MEM,
62 }
63};
64
65static struct platform_device simtec_device_nor = {
66 .name = "physmap-flash",
67 .id = -1,
68 .num_resources = ARRAY_SIZE(simtec_nor_resource),
69 .resource = simtec_nor_resource,
70 .dev = {
71 .platform_data = &simtec_nor_pdata,
72 },
73};
74
75void __init nor_simtec_init(void)
76{
77 int ret;
78
79 ret = platform_device_register(&simtec_device_nor);
80 if (ret < 0)
81 printk(KERN_ERR "failed to register physmap-flash device\n");
82 else
83 simtec_nor_vpp(NULL, 1);
84}