blob: a931c384d49d1de4b85d6f9335fde5a9147d988e [file] [log] [blame]
Philipp Zabele5c271e2007-11-22 17:59:11 +01001/*
2 * Support for HTC Magician PDA phones:
3 * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110
4 * and T-Mobile MDA Compact.
5 *
6 * Copyright (c) 2006-2007 Philipp Zabel
7 *
8 * Based on hx4700.c, spitz.c and others.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 */
15
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/platform_device.h>
19#include <linux/gpio_keys.h>
20#include <linux/input.h>
Philipp Zabel70e357f2008-04-09 19:22:57 +010021#include <linux/mfd/htc-egpio.h>
Philipp Zabele5c271e2007-11-22 17:59:11 +010022#include <linux/mtd/mtd.h>
23#include <linux/mtd/map.h>
24#include <linux/mtd/physmap.h>
25
26#include <asm/gpio.h>
27#include <asm/hardware.h>
28#include <asm/mach-types.h>
29#include <asm/mach/arch.h>
30#include <asm/arch/magician.h>
31#include <asm/arch/pxa-regs.h>
32#include <asm/arch/pxafb.h>
Philipp Zabele6816f32008-04-09 19:14:15 +010033#include <asm/arch/i2c.h>
Philipp Zabelbdb0c162008-04-09 19:24:55 +010034#include <asm/arch/mmc.h>
Philipp Zabele5c271e2007-11-22 17:59:11 +010035#include <asm/arch/irda.h>
36#include <asm/arch/ohci.h>
37
38#include "generic.h"
39
40/*
41 * IRDA
42 */
43
44static void magician_irda_transceiver_mode(struct device *dev, int mode)
45{
46 gpio_set_value(GPIO83_MAGICIAN_nIR_EN, mode & IR_OFF);
47}
48
49static struct pxaficp_platform_data magician_ficp_info = {
50 .transceiver_cap = IR_SIRMODE | IR_OFF,
51 .transceiver_mode = magician_irda_transceiver_mode,
52};
53
54/*
55 * GPIO Keys
56 */
57
58static struct gpio_keys_button magician_button_table[] = {
59 {KEY_POWER, GPIO0_MAGICIAN_KEY_POWER, 0, "Power button"},
60 {KEY_ESC, GPIO37_MAGICIAN_KEY_HANGUP, 0, "Hangup button"},
61 {KEY_F10, GPIO38_MAGICIAN_KEY_CONTACTS, 0, "Contacts button"},
62 {KEY_CALENDAR, GPIO90_MAGICIAN_KEY_CALENDAR, 0, "Calendar button"},
63 {KEY_CAMERA, GPIO91_MAGICIAN_KEY_CAMERA, 0, "Camera button"},
64 {KEY_UP, GPIO93_MAGICIAN_KEY_UP, 0, "Up button"},
65 {KEY_DOWN, GPIO94_MAGICIAN_KEY_DOWN, 0, "Down button"},
66 {KEY_LEFT, GPIO95_MAGICIAN_KEY_LEFT, 0, "Left button"},
67 {KEY_RIGHT, GPIO96_MAGICIAN_KEY_RIGHT, 0, "Right button"},
68 {KEY_KPENTER, GPIO97_MAGICIAN_KEY_ENTER, 0, "Action button"},
69 {KEY_RECORD, GPIO98_MAGICIAN_KEY_RECORD, 0, "Record button"},
70 {KEY_VOLUMEUP, GPIO100_MAGICIAN_KEY_VOL_UP, 0, "Volume up"},
71 {KEY_VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, 0, "Volume down"},
72 {KEY_PHONE, GPIO102_MAGICIAN_KEY_PHONE, 0, "Phone button"},
73 {KEY_PLAY, GPIO99_MAGICIAN_HEADPHONE_IN, 0, "Headset button"},
74};
75
76static struct gpio_keys_platform_data gpio_keys_data = {
77 .buttons = magician_button_table,
78 .nbuttons = ARRAY_SIZE(magician_button_table),
79};
80
81static struct platform_device gpio_keys = {
82 .name = "gpio-keys",
83 .dev = {
84 .platform_data = &gpio_keys_data,
85 },
86 .id = -1,
87};
88
Philipp Zabel70e357f2008-04-09 19:22:57 +010089
90/*
91 * EGPIO (Xilinx CPLD)
92 *
93 * 7 32-bit aligned 8-bit registers: 3x output, 1x irq, 3x input
94 */
95
96static struct resource egpio_resources[] = {
97 [0] = {
98 .start = PXA_CS3_PHYS,
99 .end = PXA_CS3_PHYS + 0x20,
100 .flags = IORESOURCE_MEM,
101 },
102 [1] = {
103 .start = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ),
104 .end = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ),
105 .flags = IORESOURCE_IRQ,
106 },
107};
108
109static struct htc_egpio_chip egpio_chips[] = {
110 [0] = {
111 .reg_start = 0,
112 .gpio_base = MAGICIAN_EGPIO(0, 0),
113 .num_gpios = 24,
114 .direction = HTC_EGPIO_OUTPUT,
115 .initial_values = 0x40, /* EGPIO_MAGICIAN_GSM_RESET */
116 },
117 [1] = {
118 .reg_start = 4,
119 .gpio_base = MAGICIAN_EGPIO(4, 0),
120 .num_gpios = 24,
121 .direction = HTC_EGPIO_INPUT,
122 },
123};
124
125static struct htc_egpio_platform_data egpio_info = {
126 .reg_width = 8,
127 .bus_width = 32,
128 .irq_base = IRQ_BOARD_START,
129 .num_irqs = 4,
130 .ack_register = 3,
131 .chip = egpio_chips,
132 .num_chips = ARRAY_SIZE(egpio_chips),
133};
134
135static struct platform_device egpio = {
136 .name = "htc-egpio",
137 .id = -1,
138 .resource = egpio_resources,
139 .num_resources = ARRAY_SIZE(egpio_resources),
140 .dev = {
141 .platform_data = &egpio_info,
142 },
143};
144
Philipp Zabele5c271e2007-11-22 17:59:11 +0100145/*
146 * LCD - Toppoly TD028STEB1
147 */
148
149static struct pxafb_mode_info toppoly_modes[] = {
150 {
151 .pixclock = 96153,
152 .bpp = 16,
153 .xres = 240,
154 .yres = 320,
155 .hsync_len = 11,
156 .vsync_len = 3,
157 .left_margin = 19,
158 .upper_margin = 2,
159 .right_margin = 10,
160 .lower_margin = 2,
161 .sync = 0,
162 },
163};
164
165static struct pxafb_mach_info toppoly_info = {
166 .modes = toppoly_modes,
167 .num_modes = 1,
168 .fixed_modes = 1,
169 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
170 .lccr3 = LCCR3_PixRsEdg,
171};
172
173/*
174 * Backlight
175 */
176
177static void magician_set_bl_intensity(int intensity)
178{
179 if (intensity) {
180 PWM_CTRL0 = 1;
181 PWM_PERVAL0 = 0xc8;
182 PWM_PWDUTY0 = intensity;
183 pxa_set_cken(CKEN_PWM0, 1);
184 } else {
185 pxa_set_cken(CKEN_PWM0, 0);
186 }
187}
188
189static struct generic_bl_info backlight_info = {
190 .default_intensity = 0x64,
191 .limit_mask = 0x0b,
192 .max_intensity = 0xc7,
193 .set_bl_intensity = magician_set_bl_intensity,
194};
195
196static struct platform_device backlight = {
Philipp Zabeldf56eac2008-04-08 19:36:06 +0100197 .name = "generic-bl",
Philipp Zabele5c271e2007-11-22 17:59:11 +0100198 .dev = {
199 .platform_data = &backlight_info,
200 },
201 .id = -1,
202};
203
204
205/*
Philipp Zabelbdb0c162008-04-09 19:24:55 +0100206 * MMC/SD
207 */
208
209static int magician_mci_init(struct device *dev,
210 irq_handler_t detect_irq, void *data)
211{
212 return request_irq(IRQ_MAGICIAN_SD, detect_irq,
213 IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
214 "MMC card detect", data);
215}
216
217static void magician_mci_setpower(struct device *dev, unsigned int vdd)
218{
219 struct pxamci_platform_data *pdata = dev->platform_data;
220
221 gpio_set_value(EGPIO_MAGICIAN_SD_POWER, (1 << vdd) & pdata->ocr_mask);
222}
223
224static int magician_mci_get_ro(struct device *dev)
225{
226 return (!gpio_get_value(EGPIO_MAGICIAN_nSD_READONLY));
227}
228
229static void magician_mci_exit(struct device *dev, void *data)
230{
231 free_irq(IRQ_MAGICIAN_SD, data);
232}
233
234static struct pxamci_platform_data magician_mci_info = {
235 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
236 .init = magician_mci_init,
237 .get_ro = magician_mci_get_ro,
238 .setpower = magician_mci_setpower,
239 .exit = magician_mci_exit,
240};
241
242
243/*
Philipp Zabele5c271e2007-11-22 17:59:11 +0100244 * USB OHCI
245 */
246
247static int magician_ohci_init(struct device *dev)
248{
249 UHCHR = (UHCHR | UHCHR_SSEP2 | UHCHR_PCPL | UHCHR_CGR) &
250 ~(UHCHR_SSEP1 | UHCHR_SSEP3 | UHCHR_SSE);
251
252 return 0;
253}
254
255static struct pxaohci_platform_data magician_ohci_info = {
256 .port_mode = PMM_PERPORT_MODE,
257 .init = magician_ohci_init,
258 .power_budget = 0,
259};
260
261
262/*
263 * StrataFlash
264 */
265
Philipp Zabelaa797592008-04-09 19:24:05 +0100266static void magician_set_vpp(struct map_info *map, int vpp)
267{
268 gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp);
269}
270
Philipp Zabele5c271e2007-11-22 17:59:11 +0100271#define PXA_CS_SIZE 0x04000000
272
273static struct resource strataflash_resource = {
274 .start = PXA_CS0_PHYS,
275 .end = PXA_CS0_PHYS + PXA_CS_SIZE - 1,
276 .flags = IORESOURCE_MEM,
277};
278
279static struct physmap_flash_data strataflash_data = {
280 .width = 4,
Philipp Zabelaa797592008-04-09 19:24:05 +0100281 .set_vpp = magician_set_vpp,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100282};
283
284static struct platform_device strataflash = {
285 .name = "physmap-flash",
286 .id = -1,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100287 .resource = &strataflash_resource,
Philipp Zabel70e357f2008-04-09 19:22:57 +0100288 .num_resources = 1,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100289 .dev = {
290 .platform_data = &strataflash_data,
291 },
292};
293
294/*
295 * Platform devices
296 */
297
298static struct platform_device *devices[] __initdata = {
299 &gpio_keys,
Philipp Zabel70e357f2008-04-09 19:22:57 +0100300 &egpio,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100301 &backlight,
302 &strataflash,
303};
304
305static void __init magician_init(void)
306{
307 platform_add_devices(devices, ARRAY_SIZE(devices));
Philipp Zabele6816f32008-04-09 19:14:15 +0100308 pxa_set_i2c_info(NULL);
Philipp Zabelbdb0c162008-04-09 19:24:55 +0100309 pxa_set_mci_info(&magician_mci_info);
Philipp Zabele5c271e2007-11-22 17:59:11 +0100310 pxa_set_ohci_info(&magician_ohci_info);
311 pxa_set_ficp_info(&magician_ficp_info);
312 set_pxa_fb_info(&toppoly_info);
313}
314
315
316MACHINE_START(MAGICIAN, "HTC Magician")
317 .phys_io = 0x40000000,
318 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
319 .boot_params = 0xa0000100,
320 .map_io = pxa_map_io,
321 .init_irq = pxa27x_init_irq,
322 .init_machine = magician_init,
323 .timer = &pxa_timer,
324MACHINE_END