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 | 4adc5fb6 | 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> |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 13 | #include <linux/sysdev.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 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/pxa2xx-regs.h> |
| 25 | #include <mach/mfp-pxa27x.h> |
| 26 | #include <mach/pxa-regs.h> |
| 27 | #include <mach/audio.h> |
| 28 | #include <mach/pxafb.h> |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 29 | |
| 30 | #include <asm/hardware/it8152.h> |
| 31 | |
| 32 | #include "generic.h" |
Mike Rapoport | 7d76e3f | 2008-10-07 11:58:25 +0100 | [diff] [blame] | 33 | #include "cm-x2xx-pci.h" |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 34 | |
Mike Rapoport | 4adc5fb6 | 2008-10-05 10:26:10 +0100 | [diff] [blame^] | 35 | extern void cmx270_init(void); |
| 36 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 37 | /* virtual addresses for statically mapped regions */ |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 38 | #define CMX2XX_VIRT_BASE (0xe8000000) |
| 39 | #define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 40 | |
Mike Rapoport | 4adc5fb6 | 2008-10-05 10:26:10 +0100 | [diff] [blame^] | 41 | /* physical address if local-bus attached devices */ |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 42 | #define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22)) |
| 43 | |
| 44 | /* leds */ |
| 45 | #define CMX270_GPIO_RED (93) |
| 46 | #define CMX270_GPIO_GREEN (94) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 47 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 48 | /* GPIO IRQ usage */ |
| 49 | #define GPIO10_ETHIRQ (10) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 50 | #define CMX270_GPIO_IT8152_IRQ (22) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 51 | |
| 52 | #define CMX270_ETHIRQ IRQ_GPIO(GPIO10_ETHIRQ) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 53 | |
| 54 | #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) |
| 55 | static struct resource cmx270_dm9000_resource[] = { |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 56 | [0] = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 57 | .start = CMX270_DM9000_PHYS_BASE, |
| 58 | .end = CMX270_DM9000_PHYS_BASE + 3, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 59 | .flags = IORESOURCE_MEM, |
| 60 | }, |
| 61 | [1] = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 62 | .start = CMX270_DM9000_PHYS_BASE + 8, |
| 63 | .end = CMX270_DM9000_PHYS_BASE + 8 + 500, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 64 | .flags = IORESOURCE_MEM, |
| 65 | }, |
| 66 | [2] = { |
| 67 | .start = CMX270_ETHIRQ, |
| 68 | .end = CMX270_ETHIRQ, |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 69 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 70 | } |
| 71 | }; |
| 72 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 73 | static struct dm9000_plat_data cmx270_dm9000_platdata = { |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 74 | .flags = DM9000_PLATF_32BITONLY, |
| 75 | }; |
| 76 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 77 | static struct platform_device cmx2xx_dm9000_device = { |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 78 | .name = "dm9000", |
| 79 | .id = 0, |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 80 | .num_resources = ARRAY_SIZE(cmx270_dm9000_resource), |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 81 | .dev = { |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 82 | .platform_data = &cmx270_dm9000_platdata, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 83 | } |
| 84 | }; |
| 85 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 86 | static void __init cmx2xx_init_dm9000(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 87 | { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 88 | cmx2xx_dm9000_device.resource = cmx270_dm9000_resource, |
| 89 | platform_device_register(&cmx2xx_dm9000_device); |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 90 | } |
| 91 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 92 | static inline void cmx2xx_init_dm9000(void) {} |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 93 | #endif |
| 94 | |
| 95 | /* UCB1400 touchscreen controller */ |
| 96 | #if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 97 | static struct platform_device cmx2xx_ts_device = { |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 98 | .name = "ucb1400_ts", |
| 99 | .id = -1, |
| 100 | }; |
| 101 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 102 | static void __init cmx2xx_init_touchscreen(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 103 | { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 104 | platform_device_register(&cmx2xx_ts_device); |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 105 | } |
| 106 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 107 | static inline void cmx2xx_init_touchscreen(void) {} |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 108 | #endif |
| 109 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 110 | /* CM-X270 LEDs */ |
| 111 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 112 | static struct gpio_led cmx2xx_leds[] = { |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 113 | [0] = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 114 | .name = "cm-x2xx:red", |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 115 | .default_trigger = "nand-disk", |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 116 | .active_low = 1, |
| 117 | }, |
| 118 | [1] = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 119 | .name = "cm-x2xx:green", |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 120 | .default_trigger = "heartbeat", |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 121 | .active_low = 1, |
| 122 | }, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 123 | }; |
| 124 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 125 | static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = { |
| 126 | .num_leds = ARRAY_SIZE(cmx2xx_leds), |
| 127 | .leds = cmx2xx_leds, |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 128 | }; |
| 129 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 130 | static struct platform_device cmx2xx_led_device = { |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 131 | .name = "leds-gpio", |
| 132 | .id = -1, |
| 133 | .dev = { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 134 | .platform_data = &cmx2xx_gpio_led_pdata, |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 135 | }, |
| 136 | }; |
| 137 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 138 | static void __init cmx2xx_init_leds(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 139 | { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 140 | cmx2xx_leds[0].gpio = CMX270_GPIO_RED; |
| 141 | cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN; |
| 142 | platform_device_register(&cmx2xx_led_device); |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 143 | } |
| 144 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 145 | static inline void cmx2xx_init_leds(void) {} |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 146 | #endif |
| 147 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 148 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 149 | /* |
| 150 | Display definitions |
| 151 | keep these for backwards compatibility, although symbolic names (as |
| 152 | e.g. in lpd270.c) looks better |
| 153 | */ |
| 154 | #define MTYPE_STN320x240 0 |
| 155 | #define MTYPE_TFT640x480 1 |
| 156 | #define MTYPE_CRT640x480 2 |
| 157 | #define MTYPE_CRT800x600 3 |
| 158 | #define MTYPE_TFT320x240 6 |
| 159 | #define MTYPE_STN640x480 7 |
| 160 | |
| 161 | static struct pxafb_mode_info generic_stn_320x240_mode = { |
| 162 | .pixclock = 76923, |
| 163 | .bpp = 8, |
| 164 | .xres = 320, |
| 165 | .yres = 240, |
| 166 | .hsync_len = 3, |
| 167 | .vsync_len = 2, |
| 168 | .left_margin = 3, |
| 169 | .upper_margin = 0, |
| 170 | .right_margin = 3, |
| 171 | .lower_margin = 0, |
| 172 | .sync = (FB_SYNC_HOR_HIGH_ACT | |
| 173 | FB_SYNC_VERT_HIGH_ACT), |
| 174 | .cmap_greyscale = 0, |
| 175 | }; |
| 176 | |
| 177 | static struct pxafb_mach_info generic_stn_320x240 = { |
| 178 | .modes = &generic_stn_320x240_mode, |
| 179 | .num_modes = 1, |
| 180 | .lccr0 = 0, |
| 181 | .lccr3 = (LCCR3_PixClkDiv(0x03) | |
| 182 | LCCR3_Acb(0xff) | |
| 183 | LCCR3_PCP), |
| 184 | .cmap_inverse = 0, |
| 185 | .cmap_static = 0, |
| 186 | }; |
| 187 | |
| 188 | static struct pxafb_mode_info generic_tft_640x480_mode = { |
| 189 | .pixclock = 38461, |
| 190 | .bpp = 8, |
| 191 | .xres = 640, |
| 192 | .yres = 480, |
| 193 | .hsync_len = 60, |
| 194 | .vsync_len = 2, |
| 195 | .left_margin = 70, |
| 196 | .upper_margin = 10, |
| 197 | .right_margin = 70, |
| 198 | .lower_margin = 5, |
| 199 | .sync = 0, |
| 200 | .cmap_greyscale = 0, |
| 201 | }; |
| 202 | |
| 203 | static struct pxafb_mach_info generic_tft_640x480 = { |
| 204 | .modes = &generic_tft_640x480_mode, |
| 205 | .num_modes = 1, |
| 206 | .lccr0 = (LCCR0_PAS), |
| 207 | .lccr3 = (LCCR3_PixClkDiv(0x01) | |
| 208 | LCCR3_Acb(0xff) | |
| 209 | LCCR3_PCP), |
| 210 | .cmap_inverse = 0, |
| 211 | .cmap_static = 0, |
| 212 | }; |
| 213 | |
| 214 | static struct pxafb_mode_info generic_crt_640x480_mode = { |
| 215 | .pixclock = 38461, |
| 216 | .bpp = 8, |
| 217 | .xres = 640, |
| 218 | .yres = 480, |
| 219 | .hsync_len = 63, |
| 220 | .vsync_len = 2, |
| 221 | .left_margin = 81, |
| 222 | .upper_margin = 33, |
| 223 | .right_margin = 16, |
| 224 | .lower_margin = 10, |
| 225 | .sync = (FB_SYNC_HOR_HIGH_ACT | |
| 226 | FB_SYNC_VERT_HIGH_ACT), |
| 227 | .cmap_greyscale = 0, |
| 228 | }; |
| 229 | |
| 230 | static struct pxafb_mach_info generic_crt_640x480 = { |
| 231 | .modes = &generic_crt_640x480_mode, |
| 232 | .num_modes = 1, |
| 233 | .lccr0 = (LCCR0_PAS), |
| 234 | .lccr3 = (LCCR3_PixClkDiv(0x01) | |
| 235 | LCCR3_Acb(0xff)), |
| 236 | .cmap_inverse = 0, |
| 237 | .cmap_static = 0, |
| 238 | }; |
| 239 | |
| 240 | static struct pxafb_mode_info generic_crt_800x600_mode = { |
| 241 | .pixclock = 28846, |
| 242 | .bpp = 8, |
| 243 | .xres = 800, |
| 244 | .yres = 600, |
| 245 | .hsync_len = 63, |
| 246 | .vsync_len = 2, |
| 247 | .left_margin = 26, |
| 248 | .upper_margin = 21, |
| 249 | .right_margin = 26, |
| 250 | .lower_margin = 11, |
| 251 | .sync = (FB_SYNC_HOR_HIGH_ACT | |
| 252 | FB_SYNC_VERT_HIGH_ACT), |
| 253 | .cmap_greyscale = 0, |
| 254 | }; |
| 255 | |
| 256 | static struct pxafb_mach_info generic_crt_800x600 = { |
| 257 | .modes = &generic_crt_800x600_mode, |
| 258 | .num_modes = 1, |
| 259 | .lccr0 = (LCCR0_PAS), |
| 260 | .lccr3 = (LCCR3_PixClkDiv(0x02) | |
| 261 | LCCR3_Acb(0xff)), |
| 262 | .cmap_inverse = 0, |
| 263 | .cmap_static = 0, |
| 264 | }; |
| 265 | |
| 266 | static struct pxafb_mode_info generic_tft_320x240_mode = { |
| 267 | .pixclock = 134615, |
| 268 | .bpp = 16, |
| 269 | .xres = 320, |
| 270 | .yres = 240, |
| 271 | .hsync_len = 63, |
| 272 | .vsync_len = 7, |
| 273 | .left_margin = 75, |
| 274 | .upper_margin = 0, |
| 275 | .right_margin = 15, |
| 276 | .lower_margin = 15, |
| 277 | .sync = 0, |
| 278 | .cmap_greyscale = 0, |
| 279 | }; |
| 280 | |
| 281 | static struct pxafb_mach_info generic_tft_320x240 = { |
| 282 | .modes = &generic_tft_320x240_mode, |
| 283 | .num_modes = 1, |
| 284 | .lccr0 = (LCCR0_PAS), |
| 285 | .lccr3 = (LCCR3_PixClkDiv(0x06) | |
| 286 | LCCR3_Acb(0xff) | |
| 287 | LCCR3_PCP), |
| 288 | .cmap_inverse = 0, |
| 289 | .cmap_static = 0, |
| 290 | }; |
| 291 | |
| 292 | static struct pxafb_mode_info generic_stn_640x480_mode = { |
| 293 | .pixclock = 57692, |
| 294 | .bpp = 8, |
| 295 | .xres = 640, |
| 296 | .yres = 480, |
| 297 | .hsync_len = 4, |
| 298 | .vsync_len = 2, |
| 299 | .left_margin = 10, |
| 300 | .upper_margin = 5, |
| 301 | .right_margin = 10, |
| 302 | .lower_margin = 5, |
| 303 | .sync = (FB_SYNC_HOR_HIGH_ACT | |
| 304 | FB_SYNC_VERT_HIGH_ACT), |
| 305 | .cmap_greyscale = 0, |
| 306 | }; |
| 307 | |
| 308 | static struct pxafb_mach_info generic_stn_640x480 = { |
| 309 | .modes = &generic_stn_640x480_mode, |
| 310 | .num_modes = 1, |
| 311 | .lccr0 = 0, |
| 312 | .lccr3 = (LCCR3_PixClkDiv(0x02) | |
| 313 | LCCR3_Acb(0xff)), |
| 314 | .cmap_inverse = 0, |
| 315 | .cmap_static = 0, |
| 316 | }; |
| 317 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 318 | static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 319 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 320 | static int __init cmx2xx_set_display(char *str) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 321 | { |
| 322 | int disp_type = simple_strtol(str, NULL, 0); |
| 323 | switch (disp_type) { |
| 324 | case MTYPE_STN320x240: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 325 | cmx2xx_display = &generic_stn_320x240; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 326 | break; |
| 327 | case MTYPE_TFT640x480: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 328 | cmx2xx_display = &generic_tft_640x480; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 329 | break; |
| 330 | case MTYPE_CRT640x480: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 331 | cmx2xx_display = &generic_crt_640x480; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 332 | break; |
| 333 | case MTYPE_CRT800x600: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 334 | cmx2xx_display = &generic_crt_800x600; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 335 | break; |
| 336 | case MTYPE_TFT320x240: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 337 | cmx2xx_display = &generic_tft_320x240; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 338 | break; |
| 339 | case MTYPE_STN640x480: |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 340 | cmx2xx_display = &generic_stn_640x480; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 341 | break; |
| 342 | default: /* fallback to CRT 640x480 */ |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 343 | cmx2xx_display = &generic_crt_640x480; |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 344 | break; |
| 345 | } |
| 346 | return 1; |
| 347 | } |
| 348 | |
| 349 | /* |
| 350 | This should be done really early to get proper configuration for |
| 351 | frame buffer. |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 352 | Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 353 | has limitied line length for kernel command line, and also it will |
| 354 | break compatibitlty with proprietary releases already in field. |
| 355 | */ |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 356 | __setup("monitor=", cmx2xx_set_display); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 357 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 358 | static void __init cmx2xx_init_display(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 359 | { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 360 | set_pxa_fb_info(cmx2xx_display); |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 361 | } |
| 362 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 363 | static inline void cmx2xx_init_display(void) {} |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 364 | #endif |
| 365 | |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 366 | #ifdef CONFIG_PM |
| 367 | static unsigned long sleep_save_msc[10]; |
| 368 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 369 | static int cmx2xx_suspend(struct sys_device *dev, pm_message_t state) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 370 | { |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 371 | cmx2xx_pci_suspend(); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 372 | |
| 373 | /* save MSC registers */ |
| 374 | sleep_save_msc[0] = MSC0; |
| 375 | sleep_save_msc[1] = MSC1; |
| 376 | sleep_save_msc[2] = MSC2; |
| 377 | |
| 378 | /* setup power saving mode registers */ |
| 379 | PCFR = 0x0; |
| 380 | PSLR = 0xff400000; |
| 381 | PMCR = 0x00000005; |
| 382 | PWER = 0x80000000; |
| 383 | PFER = 0x00000000; |
| 384 | PRER = 0x00000000; |
| 385 | PGSR0 = 0xC0018800; |
| 386 | PGSR1 = 0x004F0002; |
| 387 | PGSR2 = 0x6021C000; |
| 388 | PGSR3 = 0x00020000; |
| 389 | |
| 390 | return 0; |
| 391 | } |
| 392 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 393 | static int cmx2xx_resume(struct sys_device *dev) |
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_resume(); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 396 | |
| 397 | /* restore MSC registers */ |
| 398 | MSC0 = sleep_save_msc[0]; |
| 399 | MSC1 = sleep_save_msc[1]; |
| 400 | MSC2 = sleep_save_msc[2]; |
| 401 | |
| 402 | return 0; |
| 403 | } |
| 404 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 405 | static struct sysdev_class cmx2xx_pm_sysclass = { |
Kay Sievers | af5ca3f | 2007-12-20 02:09:39 +0100 | [diff] [blame] | 406 | .name = "pm", |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 407 | .resume = cmx2xx_resume, |
| 408 | .suspend = cmx2xx_suspend, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 409 | }; |
| 410 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 411 | static struct sys_device cmx2xx_pm_device = { |
| 412 | .cls = &cmx2xx_pm_sysclass, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 413 | }; |
| 414 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 415 | static int __init cmx2xx_pm_init(void) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 416 | { |
| 417 | int error; |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 418 | error = sysdev_class_register(&cmx2xx_pm_sysclass); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 419 | if (error == 0) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 420 | error = sysdev_register(&cmx2xx_pm_device); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 421 | return error; |
| 422 | } |
| 423 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 424 | static int __init cmx2xx_pm_init(void) { return 0; } |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 425 | #endif |
| 426 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 427 | #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE) |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 428 | static void __init cmx2xx_init_ac97(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 429 | { |
| 430 | pxa_set_ac97_info(NULL); |
| 431 | } |
| 432 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 433 | static inline void cmx2xx_init_ac97(void) {} |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 434 | #endif |
| 435 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 436 | static void __init cmx2xx_init(void) |
| 437 | { |
| 438 | cmx2xx_pm_init(); |
| 439 | |
| 440 | cmx270_init(); |
| 441 | |
| 442 | cmx2xx_init_dm9000(); |
| 443 | cmx2xx_init_display(); |
| 444 | cmx2xx_init_ac97(); |
| 445 | cmx2xx_init_touchscreen(); |
| 446 | cmx2xx_init_leds(); |
| 447 | } |
| 448 | |
| 449 | static void __init cmx2xx_init_irq(void) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 450 | { |
| 451 | pxa27x_init_irq(); |
| 452 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 453 | cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 454 | } |
| 455 | |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 456 | #ifdef CONFIG_PCI |
| 457 | /* Map PCI companion statically */ |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 458 | static struct map_desc cmx2xx_io_desc[] __initdata = { |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 459 | [0] = { /* PCI bridge */ |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 460 | .virtual = CMX2XX_IT8152_VIRT, |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 461 | .pfn = __phys_to_pfn(PXA_CS4_PHYS), |
| 462 | .length = SZ_64M, |
| 463 | .type = MT_DEVICE |
| 464 | }, |
| 465 | }; |
| 466 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 467 | static void __init cmx2xx_map_io(void) |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 468 | { |
| 469 | pxa_map_io(); |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 470 | iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc)); |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 471 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 472 | it8152_base_address = CMX2XX_IT8152_VIRT; |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 473 | } |
| 474 | #else |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 475 | static void __init cmx2xx_map_io(void) |
Mike Rapoport | 2f01a97 | 2008-06-17 12:29:58 +0100 | [diff] [blame] | 476 | { |
| 477 | pxa_map_io(); |
| 478 | } |
| 479 | #endif |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 480 | |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 481 | MACHINE_START(ARMCORE, "Compulab CM-X2XX") |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 482 | .boot_params = 0xa0000100, |
| 483 | .phys_io = 0x40000000, |
| 484 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 485 | .map_io = cmx2xx_map_io, |
| 486 | .init_irq = cmx2xx_init_irq, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 487 | .timer = &pxa_timer, |
Mike Rapoport | da59193 | 2008-10-05 10:25:44 +0100 | [diff] [blame] | 488 | .init_machine = cmx2xx_init, |
Mike Rapoport | 3696a8a | 2007-09-23 15:59:26 +0100 | [diff] [blame] | 489 | MACHINE_END |