1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/cm-x2xx.c
5 * Copyright (C) 2008 CompuLab, Ltd.
6 * Mike Rapoport <mike@compulab.co.il>
9 #include <linux/platform_device.h>
10 #include <linux/syscore_ops.h>
11 #include <linux/irq.h>
12 #include <linux/gpio.h>
13 #include <linux/regulator/machine.h>
15 #include <linux/dm9000.h>
16 #include <linux/leds.h>
18 #include <asm/mach/arch.h>
19 #include <asm/mach-types.h>
20 #include <asm/mach/map.h>
23 #undef GPIO24_SSP1_SFRM
29 #undef GPIO24_SSP1_SFRM
34 #include <mach/audio.h>
35 #include <linux/platform_data/video-pxafb.h>
36 #include <mach/smemc.h>
38 #include <asm/hardware/it8152.h>
41 #include "cm-x2xx-pci.h"
43 extern void cmx255_init(void);
44 extern void cmx270_init(void);
46 /* reserve IRQs for IT8152 */
47 #define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
49 /* virtual addresses for statically mapped regions */
50 #define CMX2XX_VIRT_BASE (void __iomem *)(0xe8000000)
51 #define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
53 /* physical address if local-bus attached devices */
54 #define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
55 #define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
58 #define CMX255_GPIO_RED (27)
59 #define CMX255_GPIO_GREEN (32)
60 #define CMX270_GPIO_RED (93)
61 #define CMX270_GPIO_GREEN (94)
64 #define GPIO22_ETHIRQ (22)
65 #define GPIO10_ETHIRQ (10)
66 #define CMX255_GPIO_IT8152_IRQ (0)
67 #define CMX270_GPIO_IT8152_IRQ (22)
69 #define CMX255_ETHIRQ PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ)
70 #define CMX270_ETHIRQ PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ)
72 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
73 static struct resource cmx255_dm9000_resource
[] = {
75 .start
= CMX255_DM9000_PHYS_BASE
,
76 .end
= CMX255_DM9000_PHYS_BASE
+ 3,
77 .flags
= IORESOURCE_MEM
,
80 .start
= CMX255_DM9000_PHYS_BASE
+ 4,
81 .end
= CMX255_DM9000_PHYS_BASE
+ 4 + 500,
82 .flags
= IORESOURCE_MEM
,
85 .start
= CMX255_ETHIRQ
,
87 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
91 static struct resource cmx270_dm9000_resource
[] = {
93 .start
= CMX270_DM9000_PHYS_BASE
,
94 .end
= CMX270_DM9000_PHYS_BASE
+ 3,
95 .flags
= IORESOURCE_MEM
,
98 .start
= CMX270_DM9000_PHYS_BASE
+ 8,
99 .end
= CMX270_DM9000_PHYS_BASE
+ 8 + 500,
100 .flags
= IORESOURCE_MEM
,
103 .start
= CMX270_ETHIRQ
,
104 .end
= CMX270_ETHIRQ
,
105 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
109 static struct dm9000_plat_data cmx270_dm9000_platdata
= {
110 .flags
= DM9000_PLATF_32BITONLY
| DM9000_PLATF_NO_EEPROM
,
113 static struct platform_device cmx2xx_dm9000_device
= {
116 .num_resources
= ARRAY_SIZE(cmx270_dm9000_resource
),
118 .platform_data
= &cmx270_dm9000_platdata
,
122 static void __init
cmx2xx_init_dm9000(void)
125 cmx2xx_dm9000_device
.resource
= cmx255_dm9000_resource
;
127 cmx2xx_dm9000_device
.resource
= cmx270_dm9000_resource
;
128 platform_device_register(&cmx2xx_dm9000_device
);
131 static inline void cmx2xx_init_dm9000(void) {}
134 /* UCB1400 touchscreen controller */
135 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
136 static struct platform_device cmx2xx_ts_device
= {
137 .name
= "ucb1400_core",
141 static void __init
cmx2xx_init_touchscreen(void)
143 platform_device_register(&cmx2xx_ts_device
);
146 static inline void cmx2xx_init_touchscreen(void) {}
150 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
151 static struct gpio_led cmx2xx_leds
[] = {
153 .name
= "cm-x2xx:red",
154 .default_trigger
= "nand-disk",
158 .name
= "cm-x2xx:green",
159 .default_trigger
= "heartbeat",
164 static struct gpio_led_platform_data cmx2xx_gpio_led_pdata
= {
165 .num_leds
= ARRAY_SIZE(cmx2xx_leds
),
169 static struct platform_device cmx2xx_led_device
= {
173 .platform_data
= &cmx2xx_gpio_led_pdata
,
177 static void __init
cmx2xx_init_leds(void)
179 if (cpu_is_pxa25x()) {
180 cmx2xx_leds
[0].gpio
= CMX255_GPIO_RED
;
181 cmx2xx_leds
[1].gpio
= CMX255_GPIO_GREEN
;
183 cmx2xx_leds
[0].gpio
= CMX270_GPIO_RED
;
184 cmx2xx_leds
[1].gpio
= CMX270_GPIO_GREEN
;
186 platform_device_register(&cmx2xx_led_device
);
189 static inline void cmx2xx_init_leds(void) {}
192 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
195 keep these for backwards compatibility, although symbolic names (as
196 e.g. in lpd270.c) looks better
198 #define MTYPE_STN320x240 0
199 #define MTYPE_TFT640x480 1
200 #define MTYPE_CRT640x480 2
201 #define MTYPE_CRT800x600 3
202 #define MTYPE_TFT320x240 6
203 #define MTYPE_STN640x480 7
205 static struct pxafb_mode_info generic_stn_320x240_mode
= {
216 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
217 FB_SYNC_VERT_HIGH_ACT
),
221 static struct pxafb_mach_info generic_stn_320x240
= {
222 .modes
= &generic_stn_320x240_mode
,
224 .lcd_conn
= LCD_COLOR_STN_8BPP
| LCD_PCLK_EDGE_FALL
|\
225 LCD_AC_BIAS_FREQ(0xff),
230 static struct pxafb_mode_info generic_tft_640x480_mode
= {
245 static struct pxafb_mach_info generic_tft_640x480
= {
246 .modes
= &generic_tft_640x480_mode
,
248 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_PCLK_EDGE_FALL
|\
249 LCD_AC_BIAS_FREQ(0xff),
254 static struct pxafb_mode_info generic_crt_640x480_mode
= {
265 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
266 FB_SYNC_VERT_HIGH_ACT
),
270 static struct pxafb_mach_info generic_crt_640x480
= {
271 .modes
= &generic_crt_640x480_mode
,
273 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_AC_BIAS_FREQ(0xff),
278 static struct pxafb_mode_info generic_crt_800x600_mode
= {
289 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
290 FB_SYNC_VERT_HIGH_ACT
),
294 static struct pxafb_mach_info generic_crt_800x600
= {
295 .modes
= &generic_crt_800x600_mode
,
297 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_AC_BIAS_FREQ(0xff),
302 static struct pxafb_mode_info generic_tft_320x240_mode
= {
317 static struct pxafb_mach_info generic_tft_320x240
= {
318 .modes
= &generic_tft_320x240_mode
,
320 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_AC_BIAS_FREQ(0xff),
325 static struct pxafb_mode_info generic_stn_640x480_mode
= {
336 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
337 FB_SYNC_VERT_HIGH_ACT
),
341 static struct pxafb_mach_info generic_stn_640x480
= {
342 .modes
= &generic_stn_640x480_mode
,
344 .lcd_conn
= LCD_COLOR_STN_8BPP
| LCD_AC_BIAS_FREQ(0xff),
349 static struct pxafb_mach_info
*cmx2xx_display
= &generic_crt_640x480
;
351 static int __init
cmx2xx_set_display(char *str
)
353 int disp_type
= simple_strtol(str
, NULL
, 0);
355 case MTYPE_STN320x240
:
356 cmx2xx_display
= &generic_stn_320x240
;
358 case MTYPE_TFT640x480
:
359 cmx2xx_display
= &generic_tft_640x480
;
361 case MTYPE_CRT640x480
:
362 cmx2xx_display
= &generic_crt_640x480
;
364 case MTYPE_CRT800x600
:
365 cmx2xx_display
= &generic_crt_800x600
;
367 case MTYPE_TFT320x240
:
368 cmx2xx_display
= &generic_tft_320x240
;
370 case MTYPE_STN640x480
:
371 cmx2xx_display
= &generic_stn_640x480
;
373 default: /* fallback to CRT 640x480 */
374 cmx2xx_display
= &generic_crt_640x480
;
381 This should be done really early to get proper configuration for
383 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
384 has limitied line length for kernel command line, and also it will
385 break compatibitlty with proprietary releases already in field.
387 __setup("monitor=", cmx2xx_set_display
);
389 static void __init
cmx2xx_init_display(void)
391 pxa_set_fb_info(NULL
, cmx2xx_display
);
394 static inline void cmx2xx_init_display(void) {}
398 static unsigned long sleep_save_msc
[10];
400 static int cmx2xx_suspend(void)
402 cmx2xx_pci_suspend();
404 /* save MSC registers */
405 sleep_save_msc
[0] = __raw_readl(MSC0
);
406 sleep_save_msc
[1] = __raw_readl(MSC1
);
407 sleep_save_msc
[2] = __raw_readl(MSC2
);
409 /* setup power saving mode registers */
424 static void cmx2xx_resume(void)
428 /* restore MSC registers */
429 __raw_writel(sleep_save_msc
[0], MSC0
);
430 __raw_writel(sleep_save_msc
[1], MSC1
);
431 __raw_writel(sleep_save_msc
[2], MSC2
);
434 static struct syscore_ops cmx2xx_pm_syscore_ops
= {
435 .resume
= cmx2xx_resume
,
436 .suspend
= cmx2xx_suspend
,
439 static int __init
cmx2xx_pm_init(void)
441 register_syscore_ops(&cmx2xx_pm_syscore_ops
);
446 static int __init
cmx2xx_pm_init(void) { return 0; }
449 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
450 static void __init
cmx2xx_init_ac97(void)
452 pxa_set_ac97_info(NULL
);
455 static inline void cmx2xx_init_ac97(void) {}
458 static void __init
cmx2xx_init(void)
460 pxa_set_ffuart_info(NULL
);
461 pxa_set_btuart_info(NULL
);
462 pxa_set_stuart_info(NULL
);
471 cmx2xx_init_dm9000();
472 cmx2xx_init_display();
474 cmx2xx_init_touchscreen();
477 regulator_has_full_constraints();
480 static void __init
cmx2xx_init_irq(void)
482 if (cpu_is_pxa25x()) {
484 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ
);
487 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ
);
492 /* Map PCI companion statically */
493 static struct map_desc cmx2xx_io_desc
[] __initdata
= {
494 [0] = { /* PCI bridge */
495 .virtual = (unsigned long)CMX2XX_IT8152_VIRT
,
496 .pfn
= __phys_to_pfn(PXA_CS4_PHYS
),
502 static void __init
cmx2xx_map_io(void)
510 iotable_init(cmx2xx_io_desc
, ARRAY_SIZE(cmx2xx_io_desc
));
512 it8152_base_address
= CMX2XX_IT8152_VIRT
;
515 static void __init
cmx2xx_map_io(void)
525 MACHINE_START(ARMCORE
, "Compulab CM-X2XX")
526 .atag_offset
= 0x100,
527 .map_io
= cmx2xx_map_io
,
528 .nr_irqs
= CMX2XX_NR_IRQS
,
529 .init_irq
= cmx2xx_init_irq
,
530 /* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
531 .handle_irq
= pxa25x_handle_irq
,
532 .init_time
= pxa_timer_init
,
533 .init_machine
= cmx2xx_init
,
535 .dma_zone_size
= SZ_64M
,
537 .restart
= pxa_restart
,