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