blob: 382bf18843002264c64b1237ba4fcffbd4b89c12 [file] [log] [blame]
Magnus Damme7d16512009-07-22 16:20:54 +00001/*
2 * KFR2R09 board support code
3 *
4 * Copyright (C) 2009 Magnus Damm
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/platform_device.h>
12#include <linux/interrupt.h>
Magnus Damma366aa642009-07-22 16:22:28 +000013#include <linux/mtd/physmap.h>
Magnus Damme7d16512009-07-22 16:20:54 +000014#include <linux/delay.h>
15#include <linux/clk.h>
16#include <linux/gpio.h>
17#include <asm/clock.h>
18#include <asm/machvec.h>
19#include <asm/io.h>
20#include <cpu/sh7724.h>
21
Magnus Damma366aa642009-07-22 16:22:28 +000022static struct mtd_partition kfr2r09_nor_flash_partitions[] =
23{
24 {
25 .name = "boot",
26 .offset = 0,
27 .size = (4 * 1024 * 1024),
28 .mask_flags = MTD_WRITEABLE, /* Read-only */
29 },
30 {
31 .name = "other",
32 .offset = MTDPART_OFS_APPEND,
33 .size = MTDPART_SIZ_FULL,
34 },
35};
36
37static struct physmap_flash_data kfr2r09_nor_flash_data = {
38 .width = 2,
39 .parts = kfr2r09_nor_flash_partitions,
40 .nr_parts = ARRAY_SIZE(kfr2r09_nor_flash_partitions),
41};
42
43static struct resource kfr2r09_nor_flash_resources[] = {
44 [0] = {
45 .name = "NOR Flash",
46 .start = 0x00000000,
47 .end = 0x03ffffff,
48 .flags = IORESOURCE_MEM,
49 }
50};
51
52static struct platform_device kfr2r09_nor_flash_device = {
53 .name = "physmap-flash",
54 .resource = kfr2r09_nor_flash_resources,
55 .num_resources = ARRAY_SIZE(kfr2r09_nor_flash_resources),
56 .dev = {
57 .platform_data = &kfr2r09_nor_flash_data,
58 },
59};
60
61static struct platform_device *kfr2r09_devices[] __initdata = {
62 &kfr2r09_nor_flash_device,
63};
64
65#define BSC_CS0BCR 0xfec10004
66#define BSC_CS0WCR 0xfec10024
67
Magnus Damme7d16512009-07-22 16:20:54 +000068static int __init kfr2r09_devices_setup(void)
69{
70 /* enable SCIF1 serial port for YC401 console support */
71 gpio_request(GPIO_FN_SCIF1_RXD, NULL);
72 gpio_request(GPIO_FN_SCIF1_TXD, NULL);
73
Magnus Damma366aa642009-07-22 16:22:28 +000074 /* setup NOR flash at CS0 */
75 ctrl_outl(0x36db0400, BSC_CS0BCR);
76 ctrl_outl(0x00000500, BSC_CS0WCR);
77
78 return platform_add_devices(kfr2r09_devices,
79 ARRAY_SIZE(kfr2r09_devices));
Magnus Damme7d16512009-07-22 16:20:54 +000080}
81device_initcall(kfr2r09_devices_setup);
82
83/* Return the board specific boot mode pin configuration */
84static int kfr2r09_mode_pins(void)
85{
86 /* MD0=1, MD1=1, MD2=0: Clock Mode 3
87 * MD3=0: 16-bit Area0 Bus Width
88 * MD5=1: Little Endian
89 * MD8=1: Test Mode Disabled
90 */
91 return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8;
92}
93
94/*
95 * The Machine Vector
96 */
97static struct sh_machine_vector mv_kfr2r09 __initmv = {
98 .mv_name = "kfr2r09",
99 .mv_mode_pins = kfr2r09_mode_pins,
100};