blob: b2a4b41626efbb3f920efd6ea99fa35205b6e7a3 [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001/*
2 * linux/arch/arm/mach-sa1100/cerf.c
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Apr-2003 : Removed some old PDA crud [FB]
9 * Oct-2003 : Added uart2 resource [FB]
10 * Jan-2004 : Removed io map for flash [FB]
11 */
12
13#include <linux/init.h>
14#include <linux/gpio/machine.h>
15#include <linux/kernel.h>
16#include <linux/tty.h>
17#include <linux/platform_data/sa11x0-serial.h>
18#include <linux/platform_device.h>
19#include <linux/irq.h>
20#include <linux/mtd/mtd.h>
21#include <linux/mtd/partitions.h>
22#include <linux/gpio.h>
23#include <linux/leds.h>
24
25#include <mach/hardware.h>
26#include <asm/setup.h>
27
28#include <asm/mach-types.h>
29#include <asm/mach/arch.h>
30#include <asm/mach/flash.h>
31#include <asm/mach/map.h>
32
33#include <mach/cerf.h>
34#include <linux/platform_data/mfd-mcp-sa11x0.h>
35#include <mach/irqs.h>
36#include "generic.h"
37
38static struct resource cerfuart2_resources[] = {
39 [0] = DEFINE_RES_MEM(0x80030000, SZ_64K),
40};
41
42static struct platform_device cerfuart2_device = {
43 .name = "sa11x0-uart",
44 .id = 2,
45 .num_resources = ARRAY_SIZE(cerfuart2_resources),
46 .resource = cerfuart2_resources,
47};
48
49/* Compact Flash */
50static struct gpiod_lookup_table cerf_cf_gpio_table = {
51 .dev_id = "sa11x0-pcmcia.1",
52 .table = {
53 GPIO_LOOKUP("gpio", 19, "bvd2", GPIO_ACTIVE_HIGH),
54 GPIO_LOOKUP("gpio", 20, "bvd1", GPIO_ACTIVE_HIGH),
55 GPIO_LOOKUP("gpio", 21, "reset", GPIO_ACTIVE_HIGH),
56 GPIO_LOOKUP("gpio", 22, "ready", GPIO_ACTIVE_HIGH),
57 GPIO_LOOKUP("gpio", 23, "detect", GPIO_ACTIVE_LOW),
58 { },
59 },
60};
61
62/* LEDs */
63struct gpio_led cerf_gpio_leds[] = {
64 {
65 .name = "cerf:d0",
66 .default_trigger = "heartbeat",
67 .gpio = 0,
68 },
69 {
70 .name = "cerf:d1",
71 .default_trigger = "cpu0",
72 .gpio = 1,
73 },
74 {
75 .name = "cerf:d2",
76 .default_trigger = "default-on",
77 .gpio = 2,
78 },
79 {
80 .name = "cerf:d3",
81 .default_trigger = "default-on",
82 .gpio = 3,
83 },
84
85};
86
87static struct gpio_led_platform_data cerf_gpio_led_info = {
88 .leds = cerf_gpio_leds,
89 .num_leds = ARRAY_SIZE(cerf_gpio_leds),
90};
91
92static struct platform_device cerf_leds = {
93 .name = "leds-gpio",
94 .id = -1,
95 .dev = {
96 .platform_data = &cerf_gpio_led_info,
97 }
98};
99
100
101static struct platform_device *cerf_devices[] __initdata = {
102 &cerfuart2_device,
103 &cerf_leds,
104};
105
106#ifdef CONFIG_SA1100_CERF_FLASH_32MB
107# define CERF_FLASH_SIZE 0x02000000
108#elif defined CONFIG_SA1100_CERF_FLASH_16MB
109# define CERF_FLASH_SIZE 0x01000000
110#elif defined CONFIG_SA1100_CERF_FLASH_8MB
111# define CERF_FLASH_SIZE 0x00800000
112#else
113# error "Undefined flash size for CERF"
114#endif
115
116static struct mtd_partition cerf_partitions[] = {
117 {
118 .name = "Bootloader",
119 .size = 0x00020000,
120 .offset = 0x00000000,
121 }, {
122 .name = "Params",
123 .size = 0x00040000,
124 .offset = 0x00020000,
125 }, {
126 .name = "Kernel",
127 .size = 0x00100000,
128 .offset = 0x00060000,
129 }, {
130 .name = "Filesystem",
131 .size = CERF_FLASH_SIZE-0x00160000,
132 .offset = 0x00160000,
133 }
134};
135
136static struct flash_platform_data cerf_flash_data = {
137 .map_name = "cfi_probe",
138 .parts = cerf_partitions,
139 .nr_parts = ARRAY_SIZE(cerf_partitions),
140};
141
142static struct resource cerf_flash_resource =
143 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
144
145static void __init cerf_init_irq(void)
146{
147 sa1100_init_irq();
148 irq_set_irq_type(CERF_ETH_IRQ, IRQ_TYPE_EDGE_RISING);
149}
150
151static struct map_desc cerf_io_desc[] __initdata = {
152 { /* Crystal Ethernet Chip */
153 .virtual = 0xf0000000,
154 .pfn = __phys_to_pfn(0x08000000),
155 .length = 0x00100000,
156 .type = MT_DEVICE
157 }
158};
159
160static void __init cerf_map_io(void)
161{
162 sa1100_map_io();
163 iotable_init(cerf_io_desc, ARRAY_SIZE(cerf_io_desc));
164
165 sa1100_register_uart(0, 3);
166 sa1100_register_uart(1, 2); /* disable this and the uart2 device for sa1100_fir */
167 sa1100_register_uart(2, 1);
168}
169
170static struct mcp_plat_data cerf_mcp_data = {
171 .mccr0 = MCCR0_ADM,
172 .sclk_rate = 11981000,
173};
174
175static void __init cerf_init(void)
176{
177 sa11x0_ppc_configure_mcp();
178 platform_add_devices(cerf_devices, ARRAY_SIZE(cerf_devices));
179 sa11x0_register_mtd(&cerf_flash_data, &cerf_flash_resource, 1);
180 sa11x0_register_mcp(&cerf_mcp_data);
181 sa11x0_register_pcmcia(1, &cerf_cf_gpio_table);
182}
183
184MACHINE_START(CERF, "Intrinsyc CerfBoard/CerfCube")
185 /* Maintainer: support@intrinsyc.com */
186 .map_io = cerf_map_io,
187 .nr_irqs = SA1100_NR_IRQS,
188 .init_irq = cerf_init_irq,
189 .init_time = sa1100_timer_init,
190 .init_machine = cerf_init,
191 .init_late = sa11x0_init_late,
192 .restart = sa11x0_restart,
193MACHINE_END