Ben Dooks | 9d529c6 | 2008-07-03 11:24:39 +0100 | [diff] [blame] | 1 | /* 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 King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 29 | #include <mach/map.h> |
Ben Dooks | 9d529c6 | 2008-07-03 11:24:39 +0100 | [diff] [blame] | 30 | |
Kukjin Kim | bbd7e5e | 2013-01-01 19:56:20 -0800 | [diff] [blame] | 31 | #include "bast.h" |
Heiko Stuebner | ec2cc75 | 2012-03-07 01:47:11 -0800 | [diff] [blame] | 32 | #include "simtec.h" |
Ben Dooks | 9d529c6 | 2008-07-03 11:24:39 +0100 | [diff] [blame] | 33 | |
Marc Zyngier | 667f390 | 2011-05-18 10:51:55 +0100 | [diff] [blame] | 34 | static void simtec_nor_vpp(struct platform_device *pdev, int vpp) |
Ben Dooks | 9d529c6 | 2008-07-03 11:24:39 +0100 | [diff] [blame] | 35 | { |
| 36 | unsigned int val; |
Ben Dooks | 9d529c6 | 2008-07-03 11:24:39 +0100 | [diff] [blame] | 37 | |
Ben Dooks | 9d529c6 | 2008-07-03 11:24:39 +0100 | [diff] [blame] | 38 | val = __raw_readb(BAST_VA_CTRL3); |
| 39 | |
| 40 | printk(KERN_DEBUG "%s(%d)\n", __func__, vpp); |
| 41 | |
| 42 | if (vpp) |
| 43 | val |= BAST_CPLD_CTRL3_ROMWEN; |
| 44 | else |
| 45 | val &= ~BAST_CPLD_CTRL3_ROMWEN; |
| 46 | |
| 47 | __raw_writeb(val, BAST_VA_CTRL3); |
Ben Dooks | 9d529c6 | 2008-07-03 11:24:39 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Ben Dooks | ec82923 | 2008-08-26 22:54:02 +0100 | [diff] [blame] | 50 | static struct physmap_flash_data simtec_nor_pdata = { |
Ben Dooks | 9d529c6 | 2008-07-03 11:24:39 +0100 | [diff] [blame] | 51 | .width = 2, |
| 52 | .set_vpp = simtec_nor_vpp, |
| 53 | .nr_parts = 0, |
| 54 | }; |
| 55 | |
| 56 | static struct resource simtec_nor_resource[] = { |
Tushar Behera | 3d52cad | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 57 | [0] = DEFINE_RES_MEM(S3C2410_CS1 + 0x4000000, SZ_8M), |
Ben Dooks | 9d529c6 | 2008-07-03 11:24:39 +0100 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | static struct platform_device simtec_device_nor = { |
| 61 | .name = "physmap-flash", |
| 62 | .id = -1, |
| 63 | .num_resources = ARRAY_SIZE(simtec_nor_resource), |
| 64 | .resource = simtec_nor_resource, |
| 65 | .dev = { |
| 66 | .platform_data = &simtec_nor_pdata, |
| 67 | }, |
| 68 | }; |
| 69 | |
| 70 | void __init nor_simtec_init(void) |
| 71 | { |
| 72 | int ret; |
| 73 | |
| 74 | ret = platform_device_register(&simtec_device_nor); |
| 75 | if (ret < 0) |
| 76 | printk(KERN_ERR "failed to register physmap-flash device\n"); |
| 77 | else |
| 78 | simtec_nor_vpp(NULL, 1); |
| 79 | } |