1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  *  linux/arch/arm/mach-pxa/pcm027.c
4  *  Support for the Phytec phyCORE-PXA270 CPU card (aka PCM-027).
5  *
6  *  Refer
7  *   http://www.phytec.com/products/sbc/ARM-XScale/phyCORE-XScale-PXA270.html
8  *  for additional hardware info
9  *
10  *  Author:	Juergen Kilb
11  *  Created:	April 05, 2005
12  *  Copyright:	Phytec Messtechnik GmbH
13  *  e-Mail:	armlinux@phytec.de
14  *
15  *  based on Intel Mainstone Board
16  *
17  *  Copyright 2007 Juergen Beisert @ Pengutronix (j.beisert@pengutronix.de)
18  */
19 
20 #include <linux/irq.h>
21 #include <linux/platform_device.h>
22 #include <linux/mtd/physmap.h>
23 #include <linux/spi/spi.h>
24 #include <linux/spi/max7301.h>
25 #include <linux/spi/pxa2xx_spi.h>
26 #include <linux/leds.h>
27 
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include "pxa27x.h"
31 #include "pcm027.h"
32 #include "generic.h"
33 
34 /*
35  * ABSTRACT:
36  *
37  * The PXA270 processor comes with a bunch of hardware on its silicon.
38  * Not all of this hardware can be used at the same time and not all
39  * is routed to module's connectors. Also it depends on the baseboard, what
40  * kind of hardware can be used in which way.
41  * -> So this file supports the main devices on the CPU card only!
42  * Refer pcm990-baseboard.c how to extend this features to get a full
43  * blown system with many common interfaces.
44  *
45  * The PCM-027 supports the following interfaces through its connectors and
46  * will be used in pcm990-baseboard.c:
47  *
48  * - LCD support
49  * - MMC support
50  * - IDE/CF card
51  * - FFUART
52  * - BTUART
53  * - IRUART
54  * - AC97
55  * - SSP
56  * - SSP3
57  *
58  * Claimed GPIOs:
59  * GPIO0 -> IRQ input from RTC
60  * GPIO2 -> SYS_ENA*)
61  * GPIO3 -> PWR_SCL
62  * GPIO4 -> PWR_SDA
63  * GPIO5 -> PowerCap0*)
64  * GPIO6 -> PowerCap1*)
65  * GPIO7 -> PowerCap2*)
66  * GPIO8 -> PowerCap3*)
67  * GPIO15 -> /CS1
68  * GPIO20 -> /CS2
69  * GPIO21 -> /CS3
70  * GPIO33 -> /CS5 network controller select
71  * GPIO52 -> IRQ from network controller
72  * GPIO78 -> /CS2
73  * GPIO80 -> /CS4
74  * GPIO90 -> LED0
75  * GPIO91 -> LED1
76  * GPIO114 -> IRQ from CAN controller
77  * GPIO117 -> SCL
78  * GPIO118 -> SDA
79  *
80  * *) CPU internal use only
81  */
82 
83 static unsigned long pcm027_pin_config[] __initdata = {
84 	/* Chip Selects */
85 	GPIO20_nSDCS_2,
86 	GPIO21_nSDCS_3,
87 	GPIO15_nCS_1,
88 	GPIO78_nCS_2,
89 	GPIO80_nCS_4,
90 	GPIO33_nCS_5,	/* Ethernet */
91 
92 	/* I2C */
93 	GPIO117_I2C_SCL,
94 	GPIO118_I2C_SDA,
95 
96 	/* GPIO */
97 	GPIO52_GPIO,	/* IRQ from network controller */
98 #ifdef CONFIG_LEDS_GPIO
99 	GPIO90_GPIO,	/* PCM027_LED_CPU */
100 	GPIO91_GPIO,	/* PCM027_LED_HEART_BEAT */
101 #endif
102 	GPIO114_GPIO,	/* IRQ from CAN controller */
103 };
104 
105 /*
106  * SMC91x network controller specific stuff
107  */
108 static struct resource smc91x_resources[] = {
109 	[0] = {
110 		.start	= PCM027_ETH_PHYS + 0x300,
111 		.end	= PCM027_ETH_PHYS + PCM027_ETH_SIZE,
112 		.flags	= IORESOURCE_MEM,
113 	},
114 	[1] = {
115 		.start	= PCM027_ETH_IRQ,
116 		.end	= PCM027_ETH_IRQ,
117 		/* note: smc91x's driver doesn't use the trigger bits yet */
118 		.flags	= IORESOURCE_IRQ | PCM027_ETH_IRQ_EDGE,
119 	}
120 };
121 
122 static struct platform_device smc91x_device = {
123 	.name		= "smc91x",
124 	.id		= 0,
125 	.num_resources	= ARRAY_SIZE(smc91x_resources),
126 	.resource	= smc91x_resources,
127 };
128 
129 /*
130  * SPI host and devices
131  */
132 static struct pxa2xx_spi_controller pxa_ssp_master_info = {
133 	.num_chipselect	= 1,
134 };
135 
136 static struct max7301_platform_data max7301_info = {
137 	.base = -1,
138 };
139 
140 /* bus_num must match id in pxa2xx_set_spi_info() call */
141 static struct spi_board_info spi_board_info[] __initdata = {
142 	{
143 		.modalias	= "max7301",
144 		.platform_data	= &max7301_info,
145 		.max_speed_hz	= 13000000,
146 		.bus_num	= 1,
147 		.chip_select	= 0,
148 		.mode		= SPI_MODE_0,
149 	},
150 };
151 
152 /*
153  * NOR flash
154  */
155 static struct physmap_flash_data pcm027_flash_data = {
156 	.width  = 4,
157 };
158 
159 static struct resource pcm027_flash_resource = {
160 	.start          = PCM027_FLASH_PHYS,
161 	.end            = PCM027_FLASH_PHYS + PCM027_FLASH_SIZE - 1 ,
162 	.flags          = IORESOURCE_MEM,
163 };
164 
165 static struct platform_device pcm027_flash = {
166 	.name           = "physmap-flash",
167 	.id             = 0,
168 	.dev            = {
169 		.platform_data  = &pcm027_flash_data,
170 	},
171 	.resource       = &pcm027_flash_resource,
172 	.num_resources  = 1,
173 };
174 
175 #ifdef CONFIG_LEDS_GPIO
176 
177 static struct gpio_led pcm027_led[] = {
178 	{
179 		.name = "led0:red",	/* FIXME */
180 		.gpio = PCM027_LED_CPU
181 	},
182 	{
183 		.name = "led1:green",	/* FIXME */
184 		.gpio = PCM027_LED_HEARD_BEAT
185 	},
186 };
187 
188 static struct gpio_led_platform_data pcm027_led_data = {
189 	.num_leds	= ARRAY_SIZE(pcm027_led),
190 	.leds		= pcm027_led
191 };
192 
193 static struct platform_device pcm027_led_dev = {
194 	.name		= "leds-gpio",
195 	.id		= 0,
196 	.dev		= {
197 		.platform_data	= &pcm027_led_data,
198 	},
199 };
200 
201 #endif /* CONFIG_LEDS_GPIO */
202 
203 /*
204  * declare the available device resources on this board
205  */
206 static struct platform_device *devices[] __initdata = {
207 	&smc91x_device,
208 	&pcm027_flash,
209 #ifdef CONFIG_LEDS_GPIO
210 	&pcm027_led_dev
211 #endif
212 };
213 
214 /*
215  * pcm027_init - breath some life into the board
216  */
pcm027_init(void)217 static void __init pcm027_init(void)
218 {
219 	/* system bus arbiter setting
220 	 * - Core_Park
221 	 * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
222 	 */
223 	ARB_CNTRL = ARB_CORE_PARK | 0x234;
224 
225 	pxa2xx_mfp_config(pcm027_pin_config, ARRAY_SIZE(pcm027_pin_config));
226 
227 	pxa_set_ffuart_info(NULL);
228 	pxa_set_btuart_info(NULL);
229 	pxa_set_stuart_info(NULL);
230 
231 	platform_add_devices(devices, ARRAY_SIZE(devices));
232 
233 	/* at last call the baseboard to initialize itself */
234 #ifdef CONFIG_MACH_PCM990_BASEBOARD
235 	pcm990_baseboard_init();
236 #endif
237 
238 	pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
239 	spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
240 }
241 
pcm027_map_io(void)242 static void __init pcm027_map_io(void)
243 {
244 	pxa27x_map_io();
245 
246 	/* initialize sleep mode regs (wake-up sources, etc) */
247 	PGSR0 = 0x01308000;
248 	PGSR1 = 0x00CF0002;
249 	PGSR2 = 0x0E294000;
250 	PGSR3 = 0x0000C000;
251 	PWER  = 0x40000000 | PWER_GPIO0 | PWER_GPIO1;
252 	PRER  = 0x00000000;
253 	PFER  = 0x00000003;
254 }
255 
256 MACHINE_START(PCM027, "Phytec Messtechnik GmbH phyCORE-PXA270")
257 	/* Maintainer: Pengutronix */
258 	.atag_offset	= 0x100,
259 	.map_io		= pcm027_map_io,
260 	.nr_irqs	= PCM027_NR_IRQS,
261 	.init_irq	= pxa27x_init_irq,
262 	.handle_irq	= pxa27x_handle_irq,
263 	.init_time	= pxa_timer_init,
264 	.init_machine	= pcm027_init,
265 	.restart	= pxa_restart,
266 MACHINE_END
267