1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/cm-x270.c
5 * Copyright (C) 2007, 2008 CompuLab, Ltd.
6 * Mike Rapoport <mike@compulab.co.il>
9 #include <linux/platform_device.h>
10 #include <linux/irq.h>
11 #include <linux/gpio.h>
12 #include <linux/gpio/machine.h>
13 #include <linux/delay.h>
15 #include <linux/platform_data/rtc-v3020.h>
16 #include <video/mbxfb.h>
18 #include <linux/spi/spi.h>
19 #include <linux/spi/pxa2xx_spi.h>
20 #include <linux/spi/libertas_spi.h>
23 #include <linux/platform_data/usb-ohci-pxa27x.h>
24 #include <linux/platform_data/mmc-pxamci.h>
28 /* physical address if local-bus attached devices */
29 #define RTC_PHYS_BASE (PXA_CS1_PHYS + (5 << 22))
32 #define GPIO83_MMC_IRQ (83)
34 #define CMX270_MMC_IRQ PXA_GPIO_TO_IRQ(GPIO83_MMC_IRQ)
36 /* MMC power enable */
37 #define GPIO105_MMC_POWER (105)
40 #define GPIO19_WLAN_STRAP (19)
41 #define GPIO102_WLAN_RST (102)
43 static unsigned long cmx270_pin_config
[] = {
46 GPIO29_AC97_SDATA_IN_0
,
47 GPIO30_AC97_SDATA_OUT
,
84 GPIO19_GPIO
, /* SSP2 clock is used as GPIO for Libertas pin-strap */
100 /* SDRAM and local bus */
110 GPIO0_GPIO
| WAKEUP_ON_EDGE_BOTH
,
111 GPIO105_GPIO
| MFP_LPM_DRIVE_HIGH
, /* MMC/SD power */
112 GPIO53_GPIO
, /* PC card reset */
113 GPIO102_GPIO
, /* WLAN reset */
116 GPIO11_GPIO
| MFP_LPM_DRIVE_HIGH
, /* NAND CE# */
117 GPIO89_GPIO
, /* NAND Ready/Busy */
120 GPIO10_GPIO
, /* DM9000 interrupt */
121 GPIO83_GPIO
, /* MMC card detect */
122 GPIO95_GPIO
, /* WLAN interrupt */
126 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
127 static struct resource cmx270_v3020_resource
[] = {
129 .start
= RTC_PHYS_BASE
,
130 .end
= RTC_PHYS_BASE
+ 4,
131 .flags
= IORESOURCE_MEM
,
135 struct v3020_platform_data cmx270_v3020_pdata
= {
139 static struct platform_device cmx270_rtc_device
= {
141 .num_resources
= ARRAY_SIZE(cmx270_v3020_resource
),
142 .resource
= cmx270_v3020_resource
,
145 .platform_data
= &cmx270_v3020_pdata
,
149 static void __init
cmx270_init_rtc(void)
151 platform_device_register(&cmx270_rtc_device
);
154 static inline void cmx270_init_rtc(void) {}
158 #if defined(CONFIG_FB_MBX) || defined(CONFIG_FB_MBX_MODULE)
159 static u64 fb_dma_mask
= ~(u64
)0;
161 static struct resource cmx270_2700G_resource
[] = {
162 /* frame buffer memory including ODFB and External SDRAM */
164 .start
= PXA_CS2_PHYS
,
165 .end
= PXA_CS2_PHYS
+ 0x01ffffff,
166 .flags
= IORESOURCE_MEM
,
168 /* Marathon registers */
170 .start
= PXA_CS2_PHYS
+ 0x03fe0000,
171 .end
= PXA_CS2_PHYS
+ 0x03ffffff,
172 .flags
= IORESOURCE_MEM
,
176 static unsigned long cmx270_marathon_on
[] = {
199 static unsigned long cmx270_marathon_off
[] = {
200 GPIOxx_LCD_TFT_16BPP
,
203 static int cmx270_marathon_probe(struct fb_info
*fb
)
207 for (gpio
= 58; gpio
<= 77; gpio
++) {
208 err
= gpio_request(gpio
, "LCD");
211 gpio_direction_input(gpio
);
214 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_marathon_on
));
218 static int cmx270_marathon_remove(struct fb_info
*fb
)
222 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_marathon_off
));
224 for (gpio
= 58; gpio
<= 77; gpio
++)
230 static struct mbxfb_platform_data cmx270_2700G_data
= {
246 .memsize
= 8*1024*1024,
247 .probe
= cmx270_marathon_probe
,
248 .remove
= cmx270_marathon_remove
,
251 static struct platform_device cmx270_2700G
= {
254 .platform_data
= &cmx270_2700G_data
,
255 .dma_mask
= &fb_dma_mask
,
256 .coherent_dma_mask
= 0xffffffff,
258 .num_resources
= ARRAY_SIZE(cmx270_2700G_resource
),
259 .resource
= cmx270_2700G_resource
,
263 static void __init
cmx270_init_2700G(void)
265 platform_device_register(&cmx270_2700G
);
268 static inline void cmx270_init_2700G(void) {}
271 /* PXA27x OHCI controller setup */
272 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
273 static struct pxaohci_platform_data cmx270_ohci_platform_data
= {
274 .port_mode
= PMM_PERPORT_MODE
,
275 .flags
= ENABLE_PORT1
| ENABLE_PORT2
| POWER_CONTROL_LOW
,
278 static void __init
cmx270_init_ohci(void)
280 pxa_set_ohci_info(&cmx270_ohci_platform_data
);
283 static inline void cmx270_init_ohci(void) {}
286 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
287 static struct pxamci_platform_data cmx270_mci_platform_data
= {
288 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
291 static struct gpiod_lookup_table cmx270_mci_gpio_table
= {
292 .dev_id
= "pxa2xx-mci.0",
294 /* Card detect on GPIO 83 */
295 GPIO_LOOKUP("gpio-pxa", GPIO83_MMC_IRQ
, "cd", GPIO_ACTIVE_LOW
),
296 /* Power on GPIO 105 */
297 GPIO_LOOKUP("gpio-pxa", GPIO105_MMC_POWER
,
298 "power", GPIO_ACTIVE_LOW
),
303 static void __init
cmx270_init_mmc(void)
305 gpiod_add_lookup_table(&cmx270_mci_gpio_table
);
306 pxa_set_mci_info(&cmx270_mci_platform_data
);
309 static inline void cmx270_init_mmc(void) {}
312 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
313 static struct pxa2xx_spi_controller cm_x270_spi_info
= {
318 static struct pxa2xx_spi_chip cm_x270_libertas_chip
= {
325 static unsigned long cm_x270_libertas_pin_config
[] = {
334 static int cm_x270_libertas_setup(struct spi_device
*spi
)
336 int err
= gpio_request(GPIO19_WLAN_STRAP
, "WLAN STRAP");
340 err
= gpio_request(GPIO102_WLAN_RST
, "WLAN RST");
344 err
= gpio_direction_output(GPIO102_WLAN_RST
, 0);
349 err
= gpio_direction_output(GPIO19_WLAN_STRAP
, 1);
354 pxa2xx_mfp_config(ARRAY_AND_SIZE(cm_x270_libertas_pin_config
));
356 gpio_set_value(GPIO102_WLAN_RST
, 1);
359 spi
->bits_per_word
= 16;
365 gpio_free(GPIO19_WLAN_STRAP
);
370 static int cm_x270_libertas_teardown(struct spi_device
*spi
)
372 gpio_set_value(GPIO102_WLAN_RST
, 0);
373 gpio_free(GPIO102_WLAN_RST
);
374 gpio_free(GPIO19_WLAN_STRAP
);
379 struct libertas_spi_platform_data cm_x270_libertas_pdata
= {
380 .use_dummy_writes
= 1,
381 .setup
= cm_x270_libertas_setup
,
382 .teardown
= cm_x270_libertas_teardown
,
385 static struct spi_board_info cm_x270_spi_devices
[] __initdata
= {
387 .modalias
= "libertas_spi",
388 .max_speed_hz
= 13000000,
390 .irq
= PXA_GPIO_TO_IRQ(95),
392 .controller_data
= &cm_x270_libertas_chip
,
393 .platform_data
= &cm_x270_libertas_pdata
,
397 static void __init
cmx270_init_spi(void)
399 pxa2xx_set_spi_info(2, &cm_x270_spi_info
);
400 spi_register_board_info(ARRAY_AND_SIZE(cm_x270_spi_devices
));
403 static inline void cmx270_init_spi(void) {}
406 void __init
cmx270_init(void)
408 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_pin_config
));
411 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP
);