Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 1 | /* |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 2 | * linux/arch/arm/mach-pxa/cm-x2xx.c |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 3 | * |
Mike Rapoport | 4adc5fb | 2008-10-05 10:26:10 +0100 | [diff] [blame] | 4 | * Copyright (C) 2008 CompuLab, Ltd. |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 5 | * Mike Rapoport <mike@compulab.co.il> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 12 | #include <linux/platform_device.h> |
Rafael J. Wysocki | 2eaa03b | 2011-04-22 22:03:11 +0200 | [diff] [blame] | 13 | #include <linux/syscore_ops.h> |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 14 | #include <linux/irq.h> |
| 15 | #include <linux/gpio.h> |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 16 | |
| 17 | #include <linux/dm9000.h> |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 18 | #include <linux/leds.h> |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 19 | |
| 20 | #include <asm/mach/arch.h> |
| 21 | #include <asm/mach-types.h> |
| 22 | #include <asm/mach/map.h> |
| 23 | |
Eric Miao | ca0e687 | 2011-05-18 21:19:04 +0800 | [diff] [blame] | 24 | #include <mach/pxa25x.h> |
Arnd Bergmann | e0347c5 | 2012-04-30 13:34:49 +0000 | [diff] [blame] | 25 | #undef GPIO24_SSP1_SFRM |
Eric Miao | ca0e687 | 2011-05-18 21:19:04 +0800 | [diff] [blame] | 26 | #include <mach/pxa27x.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 27 | #include <mach/audio.h> |
Arnd Bergmann | 293b2da | 2012-08-24 15:16:48 +0200 | [diff] [blame] | 28 | #include <linux/platform_data/video-pxafb.h> |
Marek Vasut | ad68bb9 | 2010-11-03 16:29:35 +0100 | [diff] [blame] | 29 | #include <mach/smemc.h> |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 30 | |
| 31 | #include <asm/hardware/it8152.h> |
| 32 | |
| 33 | #include "generic.h" |
Mike Rapoport | 7d76e3f | 2008-10-07 11:58:25 +0100 | [diff] [blame] | 34 | #include "cm-x2xx-pci.h" |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 35 | |
Mike Rapoport | a7f3f03 | 2008-10-05 10:26:55 +0100 | [diff] [blame] | 36 | extern void cmx255_init(void); |
Mike Rapoport | 4adc5fb | 2008-10-05 10:26:10 +0100 | [diff] [blame] | 37 | extern void cmx270_init(void); |
| 38 | |
Haojian Zhuang | 6ac6b81 | 2010-08-20 15:23:59 +0800 | [diff] [blame] | 39 | /* reserve IRQs for IT8152 */ |
| 40 | #define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40) |
| 41 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 42 | /* virtual addresses for statically mapped regions */ |
Arnd Bergmann | 97b09da | 2011-10-01 22:03:45 +0200 | [diff] [blame] | 43 | #define CMX2XX_VIRT_BASE (void __iomem *)(0xe8000000) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 44 | #define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 45 | |
Mike Rapoport | 4adc5fb | 2008-10-05 10:26:10 +0100 | [diff] [blame] | 46 | /* physical address if local-bus attached devices */ |
Mike Rapoport | a7f3f03 | 2008-10-05 10:26:55 +0100 | [diff] [blame] | 47 | #define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22)) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 48 | #define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22)) |
| 49 | |
| 50 | /* leds */ |
Mike Rapoport | a7f3f03 | 2008-10-05 10:26:55 +0100 | [diff] [blame] | 51 | #define CMX255_GPIO_RED (27) |
| 52 | #define CMX255_GPIO_GREEN (32) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 53 | #define CMX270_GPIO_RED (93) |
| 54 | #define CMX270_GPIO_GREEN (94) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 55 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 56 | /* GPIO IRQ usage */ |
Mike Rapoport | a7f3f03 | 2008-10-05 10:26:55 +0100 | [diff] [blame] | 57 | #define GPIO22_ETHIRQ (22) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 58 | #define GPIO10_ETHIRQ (10) |
Mike Rapoport | a7f3f03 | 2008-10-05 10:26:55 +0100 | [diff] [blame] | 59 | #define CMX255_GPIO_IT8152_IRQ (0) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 60 | #define CMX270_GPIO_IT8152_IRQ (22) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 61 | |
Haojian Zhuang | 6384fda | 2011-10-10 14:21:08 +0800 | [diff] [blame] | 62 | #define CMX255_ETHIRQ PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ) |
| 63 | #define CMX270_ETHIRQ PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 64 | |
| 65 | #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) |
Mike Rapoport | a7f3f03 | 2008-10-05 10:26:55 +0100 | [diff] [blame] | 66 | static struct resource cmx255_dm9000_resource[] = { |
| 67 | [0] = { |
| 68 | .start = CMX255_DM9000_PHYS_BASE, |
| 69 | .end = CMX255_DM9000_PHYS_BASE + 3, |
| 70 | .flags = IORESOURCE_MEM, |
| 71 | }, |
| 72 | [1] = { |
| 73 | .start = CMX255_DM9000_PHYS_BASE + 4, |
| 74 | .end = CMX255_DM9000_PHYS_BASE + 4 + 500, |
| 75 | .flags = IORESOURCE_MEM, |
| 76 | }, |
| 77 | [2] = { |
| 78 | .start = CMX255_ETHIRQ, |
| 79 | .end = CMX255_ETHIRQ, |
| 80 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
| 81 | } |
| 82 | }; |
| 83 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 84 | static struct resource cmx270_dm9000_resource[] = { |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 85 | [0] = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 86 | .start = CMX270_DM9000_PHYS_BASE, |
| 87 | .end = CMX270_DM9000_PHYS_BASE + 3, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 88 | .flags = IORESOURCE_MEM, |
| 89 | }, |
| 90 | [1] = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 91 | .start = CMX270_DM9000_PHYS_BASE + 8, |
| 92 | .end = CMX270_DM9000_PHYS_BASE + 8 + 500, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 93 | .flags = IORESOURCE_MEM, |
| 94 | }, |
| 95 | [2] = { |
| 96 | .start = CMX270_ETHIRQ, |
| 97 | .end = CMX270_ETHIRQ, |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 98 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 99 | } |
| 100 | }; |
| 101 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 102 | static struct dm9000_plat_data cmx270_dm9000_platdata = { |
Mike Rapoport | bff22c9 | 2009-02-23 18:01:12 +0200 | [diff] [blame] | 103 | .flags = DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 104 | }; |
| 105 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 106 | static struct platform_device cmx2xx_dm9000_device = { |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 107 | .name = "dm9000", |
| 108 | .id = 0, |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 109 | .num_resources = ARRAY_SIZE(cmx270_dm9000_resource), |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 110 | .dev = { |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 111 | .platform_data = &cmx270_dm9000_platdata, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 112 | } |
| 113 | }; |
| 114 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 115 | static void __init cmx2xx_init_dm9000(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 116 | { |
Mike Rapoport | a7f3f03 | 2008-10-05 10:26:55 +0100 | [diff] [blame] | 117 | if (cpu_is_pxa25x()) |
| 118 | cmx2xx_dm9000_device.resource = cmx255_dm9000_resource; |
| 119 | else |
| 120 | cmx2xx_dm9000_device.resource = cmx270_dm9000_resource; |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 121 | platform_device_register(&cmx2xx_dm9000_device); |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 122 | } |
| 123 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 124 | static inline void cmx2xx_init_dm9000(void) {} |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 125 | #endif |
| 126 | |
| 127 | /* UCB1400 touchscreen controller */ |
| 128 | #if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 129 | static struct platform_device cmx2xx_ts_device = { |
Marek Vasut | 50f6bb0 | 2009-04-01 22:30:07 +0800 | [diff] [blame] | 130 | .name = "ucb1400_core", |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 131 | .id = -1, |
| 132 | }; |
| 133 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 134 | static void __init cmx2xx_init_touchscreen(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 135 | { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 136 | platform_device_register(&cmx2xx_ts_device); |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 137 | } |
| 138 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 139 | static inline void cmx2xx_init_touchscreen(void) {} |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 140 | #endif |
| 141 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 142 | /* CM-X270 LEDs */ |
| 143 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 144 | static struct gpio_led cmx2xx_leds[] = { |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 145 | [0] = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 146 | .name = "cm-x2xx:red", |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 147 | .default_trigger = "nand-disk", |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 148 | .active_low = 1, |
| 149 | }, |
| 150 | [1] = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 151 | .name = "cm-x2xx:green", |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 152 | .default_trigger = "heartbeat", |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 153 | .active_low = 1, |
| 154 | }, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 155 | }; |
| 156 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 157 | static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = { |
| 158 | .num_leds = ARRAY_SIZE(cmx2xx_leds), |
| 159 | .leds = cmx2xx_leds, |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 160 | }; |
| 161 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 162 | static struct platform_device cmx2xx_led_device = { |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 163 | .name = "leds-gpio", |
| 164 | .id = -1, |
| 165 | .dev = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 166 | .platform_data = &cmx2xx_gpio_led_pdata, |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 167 | }, |
| 168 | }; |
| 169 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 170 | static void __init cmx2xx_init_leds(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 171 | { |
Mike Rapoport | a7f3f03 | 2008-10-05 10:26:55 +0100 | [diff] [blame] | 172 | if (cpu_is_pxa25x()) { |
| 173 | cmx2xx_leds[0].gpio = CMX255_GPIO_RED; |
| 174 | cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN; |
| 175 | } else { |
| 176 | cmx2xx_leds[0].gpio = CMX270_GPIO_RED; |
| 177 | cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN; |
| 178 | } |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 179 | platform_device_register(&cmx2xx_led_device); |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 180 | } |
| 181 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 182 | static inline void cmx2xx_init_leds(void) {} |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 183 | #endif |
| 184 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 185 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 186 | /* |
| 187 | Display definitions |
| 188 | keep these for backwards compatibility, although symbolic names (as |
| 189 | e.g. in lpd270.c) looks better |
| 190 | */ |
| 191 | #define MTYPE_STN320x240 0 |
| 192 | #define MTYPE_TFT640x480 1 |
| 193 | #define MTYPE_CRT640x480 2 |
| 194 | #define MTYPE_CRT800x600 3 |
| 195 | #define MTYPE_TFT320x240 6 |
| 196 | #define MTYPE_STN640x480 7 |
| 197 | |
| 198 | static struct pxafb_mode_info generic_stn_320x240_mode = { |
| 199 | .pixclock = 76923, |
| 200 | .bpp = 8, |
| 201 | .xres = 320, |
| 202 | .yres = 240, |
| 203 | .hsync_len = 3, |
| 204 | .vsync_len = 2, |
| 205 | .left_margin = 3, |
| 206 | .upper_margin = 0, |
| 207 | .right_margin = 3, |
| 208 | .lower_margin = 0, |
| 209 | .sync = (FB_SYNC_HOR_HIGH_ACT | |
| 210 | FB_SYNC_VERT_HIGH_ACT), |
| 211 | .cmap_greyscale = 0, |
| 212 | }; |
| 213 | |
| 214 | static struct pxafb_mach_info generic_stn_320x240 = { |
| 215 | .modes = &generic_stn_320x240_mode, |
| 216 | .num_modes = 1, |
Eric Miao | 9587319 | 2008-12-07 17:49:01 +0800 | [diff] [blame] | 217 | .lcd_conn = LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\ |
| 218 | LCD_AC_BIAS_FREQ(0xff), |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 219 | .cmap_inverse = 0, |
| 220 | .cmap_static = 0, |
| 221 | }; |
| 222 | |
| 223 | static struct pxafb_mode_info generic_tft_640x480_mode = { |
| 224 | .pixclock = 38461, |
| 225 | .bpp = 8, |
| 226 | .xres = 640, |
| 227 | .yres = 480, |
| 228 | .hsync_len = 60, |
| 229 | .vsync_len = 2, |
| 230 | .left_margin = 70, |
| 231 | .upper_margin = 10, |
| 232 | .right_margin = 70, |
| 233 | .lower_margin = 5, |
| 234 | .sync = 0, |
| 235 | .cmap_greyscale = 0, |
| 236 | }; |
| 237 | |
| 238 | static struct pxafb_mach_info generic_tft_640x480 = { |
| 239 | .modes = &generic_tft_640x480_mode, |
| 240 | .num_modes = 1, |
Eric Miao | 9587319 | 2008-12-07 17:49:01 +0800 | [diff] [blame] | 241 | .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\ |
| 242 | LCD_AC_BIAS_FREQ(0xff), |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 243 | .cmap_inverse = 0, |
| 244 | .cmap_static = 0, |
| 245 | }; |
| 246 | |
| 247 | static struct pxafb_mode_info generic_crt_640x480_mode = { |
| 248 | .pixclock = 38461, |
| 249 | .bpp = 8, |
| 250 | .xres = 640, |
| 251 | .yres = 480, |
| 252 | .hsync_len = 63, |
| 253 | .vsync_len = 2, |
| 254 | .left_margin = 81, |
| 255 | .upper_margin = 33, |
| 256 | .right_margin = 16, |
| 257 | .lower_margin = 10, |
| 258 | .sync = (FB_SYNC_HOR_HIGH_ACT | |
| 259 | FB_SYNC_VERT_HIGH_ACT), |
| 260 | .cmap_greyscale = 0, |
| 261 | }; |
| 262 | |
| 263 | static struct pxafb_mach_info generic_crt_640x480 = { |
| 264 | .modes = &generic_crt_640x480_mode, |
| 265 | .num_modes = 1, |
Eric Miao | 9587319 | 2008-12-07 17:49:01 +0800 | [diff] [blame] | 266 | .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff), |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 267 | .cmap_inverse = 0, |
| 268 | .cmap_static = 0, |
| 269 | }; |
| 270 | |
| 271 | static struct pxafb_mode_info generic_crt_800x600_mode = { |
| 272 | .pixclock = 28846, |
| 273 | .bpp = 8, |
| 274 | .xres = 800, |
| 275 | .yres = 600, |
| 276 | .hsync_len = 63, |
| 277 | .vsync_len = 2, |
| 278 | .left_margin = 26, |
| 279 | .upper_margin = 21, |
| 280 | .right_margin = 26, |
| 281 | .lower_margin = 11, |
| 282 | .sync = (FB_SYNC_HOR_HIGH_ACT | |
| 283 | FB_SYNC_VERT_HIGH_ACT), |
| 284 | .cmap_greyscale = 0, |
| 285 | }; |
| 286 | |
| 287 | static struct pxafb_mach_info generic_crt_800x600 = { |
| 288 | .modes = &generic_crt_800x600_mode, |
| 289 | .num_modes = 1, |
Eric Miao | 9587319 | 2008-12-07 17:49:01 +0800 | [diff] [blame] | 290 | .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff), |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 291 | .cmap_inverse = 0, |
| 292 | .cmap_static = 0, |
| 293 | }; |
| 294 | |
| 295 | static struct pxafb_mode_info generic_tft_320x240_mode = { |
| 296 | .pixclock = 134615, |
| 297 | .bpp = 16, |
| 298 | .xres = 320, |
| 299 | .yres = 240, |
| 300 | .hsync_len = 63, |
| 301 | .vsync_len = 7, |
| 302 | .left_margin = 75, |
| 303 | .upper_margin = 0, |
| 304 | .right_margin = 15, |
| 305 | .lower_margin = 15, |
| 306 | .sync = 0, |
| 307 | .cmap_greyscale = 0, |
| 308 | }; |
| 309 | |
| 310 | static struct pxafb_mach_info generic_tft_320x240 = { |
| 311 | .modes = &generic_tft_320x240_mode, |
| 312 | .num_modes = 1, |
Eric Miao | 9587319 | 2008-12-07 17:49:01 +0800 | [diff] [blame] | 313 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff), |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 314 | .cmap_inverse = 0, |
| 315 | .cmap_static = 0, |
| 316 | }; |
| 317 | |
| 318 | static struct pxafb_mode_info generic_stn_640x480_mode = { |
| 319 | .pixclock = 57692, |
| 320 | .bpp = 8, |
| 321 | .xres = 640, |
| 322 | .yres = 480, |
| 323 | .hsync_len = 4, |
| 324 | .vsync_len = 2, |
| 325 | .left_margin = 10, |
| 326 | .upper_margin = 5, |
| 327 | .right_margin = 10, |
| 328 | .lower_margin = 5, |
| 329 | .sync = (FB_SYNC_HOR_HIGH_ACT | |
| 330 | FB_SYNC_VERT_HIGH_ACT), |
| 331 | .cmap_greyscale = 0, |
| 332 | }; |
| 333 | |
| 334 | static struct pxafb_mach_info generic_stn_640x480 = { |
| 335 | .modes = &generic_stn_640x480_mode, |
| 336 | .num_modes = 1, |
Eric Miao | 9587319 | 2008-12-07 17:49:01 +0800 | [diff] [blame] | 337 | .lcd_conn = LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff), |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 338 | .cmap_inverse = 0, |
| 339 | .cmap_static = 0, |
| 340 | }; |
| 341 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 342 | static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 343 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 344 | static int __init cmx2xx_set_display(char *str) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 345 | { |
| 346 | int disp_type = simple_strtol(str, NULL, 0); |
| 347 | switch (disp_type) { |
| 348 | case MTYPE_STN320x240: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 349 | cmx2xx_display = &generic_stn_320x240; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 350 | break; |
| 351 | case MTYPE_TFT640x480: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 352 | cmx2xx_display = &generic_tft_640x480; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 353 | break; |
| 354 | case MTYPE_CRT640x480: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 355 | cmx2xx_display = &generic_crt_640x480; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 356 | break; |
| 357 | case MTYPE_CRT800x600: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 358 | cmx2xx_display = &generic_crt_800x600; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 359 | break; |
| 360 | case MTYPE_TFT320x240: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 361 | cmx2xx_display = &generic_tft_320x240; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 362 | break; |
| 363 | case MTYPE_STN640x480: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 364 | cmx2xx_display = &generic_stn_640x480; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 365 | break; |
| 366 | default: /* fallback to CRT 640x480 */ |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 367 | cmx2xx_display = &generic_crt_640x480; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 368 | break; |
| 369 | } |
| 370 | return 1; |
| 371 | } |
| 372 | |
| 373 | /* |
| 374 | This should be done really early to get proper configuration for |
| 375 | frame buffer. |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 376 | Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 377 | has limitied line length for kernel command line, and also it will |
| 378 | break compatibitlty with proprietary releases already in field. |
| 379 | */ |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 380 | __setup("monitor=", cmx2xx_set_display); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 381 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 382 | static void __init cmx2xx_init_display(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 383 | { |
Russell King - ARM Linux | 4321e1a | 2011-02-15 15:37:30 +0800 | [diff] [blame] | 384 | pxa_set_fb_info(NULL, cmx2xx_display); |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 385 | } |
| 386 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 387 | static inline void cmx2xx_init_display(void) {} |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 388 | #endif |
| 389 | |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 390 | #ifdef CONFIG_PM |
| 391 | static unsigned long sleep_save_msc[10]; |
| 392 | |
Rafael J. Wysocki | 2eaa03b | 2011-04-22 22:03:11 +0200 | [diff] [blame] | 393 | static int cmx2xx_suspend(void) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 394 | { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 395 | cmx2xx_pci_suspend(); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 396 | |
| 397 | /* save MSC registers */ |
Marek Vasut | ad68bb9 | 2010-11-03 16:29:35 +0100 | [diff] [blame] | 398 | sleep_save_msc[0] = __raw_readl(MSC0); |
| 399 | sleep_save_msc[1] = __raw_readl(MSC1); |
| 400 | sleep_save_msc[2] = __raw_readl(MSC2); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 401 | |
| 402 | /* setup power saving mode registers */ |
| 403 | PCFR = 0x0; |
| 404 | PSLR = 0xff400000; |
| 405 | PMCR = 0x00000005; |
| 406 | PWER = 0x80000000; |
| 407 | PFER = 0x00000000; |
| 408 | PRER = 0x00000000; |
| 409 | PGSR0 = 0xC0018800; |
| 410 | PGSR1 = 0x004F0002; |
| 411 | PGSR2 = 0x6021C000; |
| 412 | PGSR3 = 0x00020000; |
| 413 | |
| 414 | return 0; |
| 415 | } |
| 416 | |
Rafael J. Wysocki | 2eaa03b | 2011-04-22 22:03:11 +0200 | [diff] [blame] | 417 | static void cmx2xx_resume(void) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 418 | { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 419 | cmx2xx_pci_resume(); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 420 | |
| 421 | /* restore MSC registers */ |
Marek Vasut | ad68bb9 | 2010-11-03 16:29:35 +0100 | [diff] [blame] | 422 | __raw_writel(sleep_save_msc[0], MSC0); |
| 423 | __raw_writel(sleep_save_msc[1], MSC1); |
| 424 | __raw_writel(sleep_save_msc[2], MSC2); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 425 | } |
| 426 | |
Rafael J. Wysocki | 2eaa03b | 2011-04-22 22:03:11 +0200 | [diff] [blame] | 427 | static struct syscore_ops cmx2xx_pm_syscore_ops = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 428 | .resume = cmx2xx_resume, |
| 429 | .suspend = cmx2xx_suspend, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 430 | }; |
| 431 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 432 | static int __init cmx2xx_pm_init(void) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 433 | { |
Rafael J. Wysocki | 2eaa03b | 2011-04-22 22:03:11 +0200 | [diff] [blame] | 434 | register_syscore_ops(&cmx2xx_pm_syscore_ops); |
| 435 | |
| 436 | return 0; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 437 | } |
| 438 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 439 | static int __init cmx2xx_pm_init(void) { return 0; } |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 440 | #endif |
| 441 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 442 | #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 443 | static void __init cmx2xx_init_ac97(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 444 | { |
| 445 | pxa_set_ac97_info(NULL); |
| 446 | } |
| 447 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 448 | static inline void cmx2xx_init_ac97(void) {} |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 449 | #endif |
| 450 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 451 | static void __init cmx2xx_init(void) |
| 452 | { |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 453 | pxa_set_ffuart_info(NULL); |
| 454 | pxa_set_btuart_info(NULL); |
| 455 | pxa_set_stuart_info(NULL); |
| 456 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 457 | cmx2xx_pm_init(); |
| 458 | |
Mike Rapoport | a7f3f03 | 2008-10-05 10:26:55 +0100 | [diff] [blame] | 459 | if (cpu_is_pxa25x()) |
| 460 | cmx255_init(); |
| 461 | else |
| 462 | cmx270_init(); |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 463 | |
| 464 | cmx2xx_init_dm9000(); |
| 465 | cmx2xx_init_display(); |
| 466 | cmx2xx_init_ac97(); |
| 467 | cmx2xx_init_touchscreen(); |
| 468 | cmx2xx_init_leds(); |
| 469 | } |
| 470 | |
| 471 | static void __init cmx2xx_init_irq(void) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 472 | { |
Mike Rapoport | a7f3f03 | 2008-10-05 10:26:55 +0100 | [diff] [blame] | 473 | if (cpu_is_pxa25x()) { |
| 474 | pxa25x_init_irq(); |
| 475 | cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ); |
| 476 | } else { |
| 477 | pxa27x_init_irq(); |
| 478 | cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ); |
| 479 | } |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 480 | } |
| 481 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 482 | #ifdef CONFIG_PCI |
| 483 | /* Map PCI companion statically */ |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 484 | static struct map_desc cmx2xx_io_desc[] __initdata = { |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 485 | [0] = { /* PCI bridge */ |
Arnd Bergmann | 97b09da | 2011-10-01 22:03:45 +0200 | [diff] [blame] | 486 | .virtual = (unsigned long)CMX2XX_IT8152_VIRT, |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 487 | .pfn = __phys_to_pfn(PXA_CS4_PHYS), |
| 488 | .length = SZ_64M, |
| 489 | .type = MT_DEVICE |
| 490 | }, |
| 491 | }; |
| 492 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 493 | static void __init cmx2xx_map_io(void) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 494 | { |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame] | 495 | if (cpu_is_pxa25x()) |
| 496 | pxa25x_map_io(); |
| 497 | |
| 498 | if (cpu_is_pxa27x()) |
| 499 | pxa27x_map_io(); |
| 500 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 501 | iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc)); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 502 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 503 | it8152_base_address = CMX2XX_IT8152_VIRT; |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 504 | } |
| 505 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 506 | static void __init cmx2xx_map_io(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 507 | { |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame] | 508 | if (cpu_is_pxa25x()) |
| 509 | pxa25x_map_io(); |
| 510 | |
| 511 | if (cpu_is_pxa27x()) |
| 512 | pxa27x_map_io(); |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 513 | } |
| 514 | #endif |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 515 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 516 | MACHINE_START(ARMCORE, "Compulab CM-X2XX") |
Nicolas Pitre | 7375aba | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 517 | .atag_offset = 0x100, |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 518 | .map_io = cmx2xx_map_io, |
Haojian Zhuang | 6ac6b81 | 2010-08-20 15:23:59 +0800 | [diff] [blame] | 519 | .nr_irqs = CMX2XX_NR_IRQS, |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 520 | .init_irq = cmx2xx_init_irq, |
Eric Miao | 8a97ae2 | 2011-05-18 21:30:04 +0800 | [diff] [blame] | 521 | /* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */ |
| 522 | .handle_irq = pxa25x_handle_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 523 | .init_time = pxa_timer_init, |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 524 | .init_machine = cmx2xx_init, |
Nicolas Pitre | 805e88d | 2011-07-05 22:28:09 -0400 | [diff] [blame] | 525 | #ifdef CONFIG_PCI |
| 526 | .dma_zone_size = SZ_64M, |
| 527 | #endif |
Russell King | 271a74f | 2011-11-04 14:15:53 +0000 | [diff] [blame] | 528 | .restart = pxa_restart, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 529 | MACHINE_END |