blob: a6fba056a7475a3dd43a5fd15f814e131b6674e0 [file] [log] [blame]
Krzysztof Kozlowski84b21702017-12-25 20:54:32 +01001// SPDX-License-Identifier: GPL-2.0
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
Ben Dooks9d529c62008-07-03 11:24:39 +01008
9#include <linux/module.h>
10#include <linux/types.h>
11#include <linux/init.h>
12#include <linux/kernel.h>
13#include <linux/platform_device.h>
14
15#include <linux/mtd/mtd.h>
16#include <linux/mtd/map.h>
17#include <linux/mtd/physmap.h>
18#include <linux/mtd/partitions.h>
19
20#include <asm/mach/arch.h>
21#include <asm/mach/map.h>
22#include <asm/mach/irq.h>
23
Arnd Bergmannc6ff1322019-09-02 18:37:30 +020024#include "map.h"
Ben Dooks9d529c62008-07-03 11:24:39 +010025
Kukjin Kimbbd7e5e2013-01-01 19:56:20 -080026#include "bast.h"
Heiko Stuebnerec2cc752012-03-07 01:47:11 -080027#include "simtec.h"
Ben Dooks9d529c62008-07-03 11:24:39 +010028
Marc Zyngier667f3902011-05-18 10:51:55 +010029static void simtec_nor_vpp(struct platform_device *pdev, int vpp)
Ben Dooks9d529c62008-07-03 11:24:39 +010030{
31 unsigned int val;
Ben Dooks9d529c62008-07-03 11:24:39 +010032
Ben Dooks9d529c62008-07-03 11:24:39 +010033 val = __raw_readb(BAST_VA_CTRL3);
34
35 printk(KERN_DEBUG "%s(%d)\n", __func__, vpp);
36
37 if (vpp)
38 val |= BAST_CPLD_CTRL3_ROMWEN;
39 else
40 val &= ~BAST_CPLD_CTRL3_ROMWEN;
41
42 __raw_writeb(val, BAST_VA_CTRL3);
Ben Dooks9d529c62008-07-03 11:24:39 +010043}
44
Ben Dooksec829232008-08-26 22:54:02 +010045static struct physmap_flash_data simtec_nor_pdata = {
Ben Dooks9d529c62008-07-03 11:24:39 +010046 .width = 2,
47 .set_vpp = simtec_nor_vpp,
48 .nr_parts = 0,
49};
50
51static struct resource simtec_nor_resource[] = {
Tushar Behera3d52cad2012-05-12 16:12:25 +090052 [0] = DEFINE_RES_MEM(S3C2410_CS1 + 0x4000000, SZ_8M),
Ben Dooks9d529c62008-07-03 11:24:39 +010053};
54
55static struct platform_device simtec_device_nor = {
56 .name = "physmap-flash",
57 .id = -1,
58 .num_resources = ARRAY_SIZE(simtec_nor_resource),
59 .resource = simtec_nor_resource,
60 .dev = {
61 .platform_data = &simtec_nor_pdata,
62 },
63};
64
65void __init nor_simtec_init(void)
66{
67 int ret;
68
69 ret = platform_device_register(&simtec_device_nor);
70 if (ret < 0)
71 printk(KERN_ERR "failed to register physmap-flash device\n");
72 else
73 simtec_nor_vpp(NULL, 1);
74}