blob: 0160cd8f6c653eac614e966b1fff19856083edc9 [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>
21#include <linux/mtd/mtd.h>
22#include <linux/mtd/map.h>
23#include <linux/mtd/physmap.h>
24
25#include <asm/gpio.h>
26#include <asm/hardware.h>
27#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29#include <asm/arch/magician.h>
30#include <asm/arch/pxa-regs.h>
31#include <asm/arch/pxafb.h>
Philipp Zabele6816f32008-04-09 19:14:15 +010032#include <asm/arch/i2c.h>
Philipp Zabele5c271e2007-11-22 17:59:11 +010033#include <asm/arch/irda.h>
34#include <asm/arch/ohci.h>
35
36#include "generic.h"
37
38/*
39 * IRDA
40 */
41
42static void magician_irda_transceiver_mode(struct device *dev, int mode)
43{
44 gpio_set_value(GPIO83_MAGICIAN_nIR_EN, mode & IR_OFF);
45}
46
47static struct pxaficp_platform_data magician_ficp_info = {
48 .transceiver_cap = IR_SIRMODE | IR_OFF,
49 .transceiver_mode = magician_irda_transceiver_mode,
50};
51
52/*
53 * GPIO Keys
54 */
55
56static struct gpio_keys_button magician_button_table[] = {
57 {KEY_POWER, GPIO0_MAGICIAN_KEY_POWER, 0, "Power button"},
58 {KEY_ESC, GPIO37_MAGICIAN_KEY_HANGUP, 0, "Hangup button"},
59 {KEY_F10, GPIO38_MAGICIAN_KEY_CONTACTS, 0, "Contacts button"},
60 {KEY_CALENDAR, GPIO90_MAGICIAN_KEY_CALENDAR, 0, "Calendar button"},
61 {KEY_CAMERA, GPIO91_MAGICIAN_KEY_CAMERA, 0, "Camera button"},
62 {KEY_UP, GPIO93_MAGICIAN_KEY_UP, 0, "Up button"},
63 {KEY_DOWN, GPIO94_MAGICIAN_KEY_DOWN, 0, "Down button"},
64 {KEY_LEFT, GPIO95_MAGICIAN_KEY_LEFT, 0, "Left button"},
65 {KEY_RIGHT, GPIO96_MAGICIAN_KEY_RIGHT, 0, "Right button"},
66 {KEY_KPENTER, GPIO97_MAGICIAN_KEY_ENTER, 0, "Action button"},
67 {KEY_RECORD, GPIO98_MAGICIAN_KEY_RECORD, 0, "Record button"},
68 {KEY_VOLUMEUP, GPIO100_MAGICIAN_KEY_VOL_UP, 0, "Volume up"},
69 {KEY_VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, 0, "Volume down"},
70 {KEY_PHONE, GPIO102_MAGICIAN_KEY_PHONE, 0, "Phone button"},
71 {KEY_PLAY, GPIO99_MAGICIAN_HEADPHONE_IN, 0, "Headset button"},
72};
73
74static struct gpio_keys_platform_data gpio_keys_data = {
75 .buttons = magician_button_table,
76 .nbuttons = ARRAY_SIZE(magician_button_table),
77};
78
79static struct platform_device gpio_keys = {
80 .name = "gpio-keys",
81 .dev = {
82 .platform_data = &gpio_keys_data,
83 },
84 .id = -1,
85};
86
87/*
88 * LCD - Toppoly TD028STEB1
89 */
90
91static struct pxafb_mode_info toppoly_modes[] = {
92 {
93 .pixclock = 96153,
94 .bpp = 16,
95 .xres = 240,
96 .yres = 320,
97 .hsync_len = 11,
98 .vsync_len = 3,
99 .left_margin = 19,
100 .upper_margin = 2,
101 .right_margin = 10,
102 .lower_margin = 2,
103 .sync = 0,
104 },
105};
106
107static struct pxafb_mach_info toppoly_info = {
108 .modes = toppoly_modes,
109 .num_modes = 1,
110 .fixed_modes = 1,
111 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
112 .lccr3 = LCCR3_PixRsEdg,
113};
114
115/*
116 * Backlight
117 */
118
119static void magician_set_bl_intensity(int intensity)
120{
121 if (intensity) {
122 PWM_CTRL0 = 1;
123 PWM_PERVAL0 = 0xc8;
124 PWM_PWDUTY0 = intensity;
125 pxa_set_cken(CKEN_PWM0, 1);
126 } else {
127 pxa_set_cken(CKEN_PWM0, 0);
128 }
129}
130
131static struct generic_bl_info backlight_info = {
132 .default_intensity = 0x64,
133 .limit_mask = 0x0b,
134 .max_intensity = 0xc7,
135 .set_bl_intensity = magician_set_bl_intensity,
136};
137
138static struct platform_device backlight = {
Philipp Zabeldf56eac2008-04-08 19:36:06 +0100139 .name = "generic-bl",
Philipp Zabele5c271e2007-11-22 17:59:11 +0100140 .dev = {
141 .platform_data = &backlight_info,
142 },
143 .id = -1,
144};
145
146
147/*
148 * USB OHCI
149 */
150
151static int magician_ohci_init(struct device *dev)
152{
153 UHCHR = (UHCHR | UHCHR_SSEP2 | UHCHR_PCPL | UHCHR_CGR) &
154 ~(UHCHR_SSEP1 | UHCHR_SSEP3 | UHCHR_SSE);
155
156 return 0;
157}
158
159static struct pxaohci_platform_data magician_ohci_info = {
160 .port_mode = PMM_PERPORT_MODE,
161 .init = magician_ohci_init,
162 .power_budget = 0,
163};
164
165
166/*
167 * StrataFlash
168 */
169
170#define PXA_CS_SIZE 0x04000000
171
172static struct resource strataflash_resource = {
173 .start = PXA_CS0_PHYS,
174 .end = PXA_CS0_PHYS + PXA_CS_SIZE - 1,
175 .flags = IORESOURCE_MEM,
176};
177
178static struct physmap_flash_data strataflash_data = {
179 .width = 4,
180};
181
182static struct platform_device strataflash = {
183 .name = "physmap-flash",
184 .id = -1,
185 .num_resources = 1,
186 .resource = &strataflash_resource,
187 .dev = {
188 .platform_data = &strataflash_data,
189 },
190};
191
192/*
193 * Platform devices
194 */
195
196static struct platform_device *devices[] __initdata = {
197 &gpio_keys,
198 &backlight,
199 &strataflash,
200};
201
202static void __init magician_init(void)
203{
204 platform_add_devices(devices, ARRAY_SIZE(devices));
Philipp Zabele6816f32008-04-09 19:14:15 +0100205 pxa_set_i2c_info(NULL);
Philipp Zabele5c271e2007-11-22 17:59:11 +0100206 pxa_set_ohci_info(&magician_ohci_info);
207 pxa_set_ficp_info(&magician_ficp_info);
208 set_pxa_fb_info(&toppoly_info);
209}
210
211
212MACHINE_START(MAGICIAN, "HTC Magician")
213 .phys_io = 0x40000000,
214 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
215 .boot_params = 0xa0000100,
216 .map_io = pxa_map_io,
217 .init_irq = pxa27x_init_irq,
218 .init_machine = magician_init,
219 .timer = &pxa_timer,
220MACHINE_END