]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap1/board-h6300.c
h63xx: tsc2101 alsa sound support
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap1 / board-h6300.c
1 /*
2  * linux/arch/arm/mach-omap1/board-h6300.c
3  *
4  * Modified from board-innovator.c
5  *
6  * Board specific inits for OMAP-1510 based iPAQ h63xx series of mobile phones.
7  * (h6315, h6340 and h6365)
8  *
9  * Copyright (C) 2009 Mika Laitio
10  * Copyright (C) 2009 Husam Senussi
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2 as
14  * published by the Free Software Foundation.
15  */
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/delay.h>
20 #include <linux/input.h>
21
22 #include <asm/hardware.h>
23 #include <asm/mach-types.h>
24 #include <asm/mach/arch.h>
25 #include <asm/mach/map.h>
26
27 #include <asm/arch/gpio.h>
28 #include <asm/arch/tc.h>
29 #include <asm/arch/usb.h>
30 #include <asm/arch/keypad.h>
31 #include <asm/arch/common.h>
32 #include <asm/arch/mcbsp.h>
33 #include <asm/arch/omap-alsa.h>
34 #include <asm/arch/h6300_uart_info.h>
35
36 #define _h6300_KEY_CALENDAR     67      // xmodmap 75 aka F9
37 #define _H6300_KEY_TELEPHONE    68      // xmodmap 76 aka F10
38 #define _H6300_KEY_HOMEPAGE     87      // xmodmap 87 aka Num_Lock
39 #define _H6300_KEY_MAIL         88      // xmodmap 88 aka Scroll_Lock
40
41 /*
42  * When joypad is pressed on h63xx to up, right, down or left direction, 
43  * it does not send keypress events directly from those directions.
44  * Instead we receive multiple events from the keypresses on directions 
45  * up_right, down_right, down_left, up_left and ok.
46  * Therefore we are summing those events in kernel level and then
47  * making a decision which event is send to userspace. (up, right, down or left)
48  */
49 #define _H6300_JOYPAD_UP_RIGHT          1       // 00001
50 #define _H6300_JOYPAD_DOWN_RIGHT        2       // 00010
51 #define _h6300_JOYPAD_DOWN_LEFT         4       // 00100
52 #define _h6300_JOYPAD_UP_LEFT           8       // 01000
53 #define _H6300_JOYPAD_KEY_OK            16      // 10000
54
55 static int h6300_keymap[] = {
56         KEY(2, 0, _h6300_KEY_CALENDAR),         // address button in the bottom left of iPAQ keypad
57         KEY(2, 3, _H6300_KEY_TELEPHONE),        // start call button in the bottom of iPAQ keypad
58         KEY(3, 1, _H6300_KEY_HOMEPAGE),         // stop call button in the bottom of iPAQ keypad
59         KEY(3, 4, _H6300_KEY_MAIL),             // messaging button in the bottom right of iPAQ keypad
60
61         KEY(0, 0, KEY_VOLUMEUP),                // volume up button in the right side of iPAQ keypad
62         KEY(0, 1, KEY_VOLUMEDOWN),              // volume down button in the right side of iPAQ keypad
63         KEY(3, 2, KEY_RECORD),                  // record button in the left side of iPAQ keypad
64         
65         KEY(1, 0, _h6300_JOYPAD_UP_LEFT),       
66         KEY(1, 1, _h6300_JOYPAD_DOWN_LEFT),     
67         KEY(1, 2, _H6300_JOYPAD_KEY_OK),                
68         KEY(1, 3, _H6300_JOYPAD_DOWN_RIGHT),
69         KEY(1, 4, _H6300_JOYPAD_UP_RIGHT),      
70         
71         KEY(4, 0, KEY_RIGHT),
72         KEY(4, 1, KEY_DOWN),
73         KEY(4, 2, KEY_LEFT),            
74         KEY(4, 3, KEY_UP),
75         KEY(4, 4, KEY_ENTER),
76
77         0
78 };
79
80 static struct platform_device h6300_lcd_device = {
81         .name   = "lcd_h6300",
82         .id     = -1,
83 };
84
85 static struct resource h6300_kp_resources[] = {
86         [0] = {
87                 .start  = INT_KEYBOARD,
88                 .end    = INT_KEYBOARD,
89                 .flags  = IORESOURCE_IRQ,
90         },
91 };
92
93 static struct omap_kp_platform_data h6300_kp_data = {
94         .rows   = 8,
95         .cols   = 8,
96         .keymap = h6300_keymap,
97         .rep    = 1,    // turns repeat bit on
98 };
99
100 static struct platform_device h6300_kp_device = {
101         .name           = "omap-keypad",
102         .id             = -1,
103         .dev            = {
104                 .platform_data = &h6300_kp_data,
105         },
106         .num_resources  = ARRAY_SIZE(h6300_kp_resources),
107         .resource       = h6300_kp_resources,
108 };
109
110 /*
111  * Bluetooth - Relies on h6300_bt module,
112  * so make the calls indirectly through pointers. Requires that the
113  * h6300_bt bluetooth module be loaded before any attempt to use
114  * bluetooth (obviously).
115  */
116 static struct platform_omap_serial_funcs h6300_omap_platform__uart_bt_funcs = {
117         .configure      = NULL,
118         .set_txrx       = NULL,
119         .get_txrx       = NULL,
120 };
121
122 struct platform_device h63xx_uart_bt_device = {
123         .name   = "h6300_bt",
124         .id     = 1,
125 };
126 EXPORT_SYMBOL(h63xx_uart_bt_device);
127
128 static struct omap_mcbsp_reg_cfg mcbsp_regs = { 
129         .spcr2  = 0x0000,
130         .spcr1  = 0x0000,
131         .rcr2   = 0x8041,
132         .rcr1   = 0x0040,
133         .xcr2   = 0x00a1,
134         .xcr1   = 0x00a0,
135         .srgr2  = 0xb000,
136         .srgr1  = 0x0000,
137         .pcr0   = 0x0081,
138 };
139
140 static struct omap_alsa_codec_config alsa_config = {
141         .name                   = "iPAQ h6300 TSC2101",
142         .mcbsp_regs_alsa        = &mcbsp_regs,
143         .codec_configure_dev    = NULL, //tsc2101_configure,
144         .codec_set_samplerate   = NULL, //tsc2101_set_samplerate,
145         .codec_clock_setup      = NULL, //tsc2101_clock_setup,
146         .codec_clock_on         = NULL, //tsc2101_clock_on,
147         .codec_clock_off        = NULL, //tsc2101_clock_off,
148         .get_default_samplerate = NULL, //tsc2101_get_default_samplerate,
149 };
150
151 static struct platform_device h6300_mcbsp1_sound_device = {
152         .name   = "omap_alsa_mcbsp",
153         .id     = 1,
154         .dev = {
155                 .platform_data  = &alsa_config,
156         },
157 };
158
159 static struct platform_device *h6300_devices[] __initdata = {
160         &h6300_lcd_device,
161         &h6300_kp_device,
162         &h63xx_uart_bt_device,
163         &h6300_mcbsp1_sound_device,
164 };
165
166 static struct omap_lcd_config h6300_lcd_config __initdata = {
167         .ctrl_name      = "internal",
168 };
169
170 static struct omap_uart_config h6300_uart_config __initdata = {
171         .enabled_uarts  = ((1 << 0) | (1 << 1) | (1 << 2)),
172 };
173
174 /* assume no Mini-AB port */
175 static struct omap_usb_config h6300_usb_config __initdata = {
176         .hmc_mode       = 0,
177         .register_dev   = 1,
178         .pins[0]        = 0,
179 };
180
181 static struct omap_mmc_config h6300_mmc_config __initdata = {
182         .mmc [0] = {
183                 .enabled        = 1,
184                 .wire4          = 1,
185                 .wp_pin         = OMAP_GPIO_IRQ(13),
186                 .power_pin      = -1, // tps65010 ?
187                 .switch_pin     = -1, // OMAP_MPUIO(1), // = -1, // ARMIO2?
188         },
189 };
190
191 static struct omap_board_config_kernel h6300_config[] = {
192         { OMAP_TAG_LCD,         &h6300_lcd_config },
193         { OMAP_TAG_UART,        &h6300_uart_config },
194         { OMAP_TAG_USB,         &h6300_usb_config },
195         { OMAP_TAG_MMC,         &h6300_mmc_config },
196 };
197
198 static void __init h6300_init_irq(void)
199 {
200         omap1_init_common_hw();
201         omap_init_irq();
202         omap_gpio_init();
203 /* touchscreen gpio setup is now done in the drivers/input/touschreen/omap/ts_hx.c
204         omap_request_gpio(2);
205         omap_set_gpio_direction(2, 0);
206         omap_set_gpio_dataout(2, 1);
207 */
208 }
209
210 static void __init h6300_init(void)
211 {
212         int ret;
213         
214         ret = platform_add_devices(h6300_devices, ARRAY_SIZE(h6300_devices));
215         if (ret) {
216                 printk(KERN_WARNING "Unable to add h6300 platform devices.");
217         }
218         omap_board_config       = h6300_config;
219         omap_board_config_size  = ARRAY_SIZE(h6300_config);
220         omap_serial_init();
221 }
222
223 static void __init h6300_map_io(void)
224 {
225         omap1_map_common_io();
226
227         h63xx_uart_bt_device.dev.platform_data  = &h6300_omap_platform__uart_bt_funcs;
228 }
229
230 MACHINE_START(OMAP_H6300, "HP iPAQ h6300")
231         /* MAINTAINER("Mika Laitio <lamikr at pilppa dot org>") */
232         .phys_io        = 0xfff00000,
233         .io_pg_offst    = ((0xfef00000) >> 18) & 0xfffc,
234         .boot_params    = 0x10000100,
235         .map_io         = h6300_map_io,
236         .init_irq       = h6300_init_irq,
237         .init_machine   = h6300_init,
238         .timer          = &omap_timer,
239 MACHINE_END