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