2 * linux/arch/arm/mach-omap1/board-sx1.c
4 * Modified from board-generic.c
6 * Support for the Siemens SX1 mobile phone.
8 * Original version : Vladimir Ananiev (Vovan888-at-gmail com)
10 * Maintainters : Vladimir Ananiev (aka Vovan888), Sergge
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/input.h>
21 #include <linux/platform_device.h>
22 #include <linux/notifier.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/partitions.h>
25 #include <linux/types.h>
26 #include <linux/i2c.h>
27 #include <linux/errno.h>
29 #include <asm/hardware.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/flash.h>
33 #include <asm/mach/map.h>
35 #include <asm/arch/gpio.h>
36 #include <asm/arch/gpio-switch.h>
37 #include <asm/arch/mux.h>
38 #include <asm/arch/irda.h>
39 #include <asm/arch/usb.h>
40 #include <asm/arch/tc.h>
41 #include <asm/arch/board.h>
42 #include <asm/arch/common.h>
43 #include <asm/arch/mcbsp.h>
44 #include <asm/arch/omap-alsa.h>
45 #include <asm/arch/keypad.h>
47 /* Write to I2C device */
48 int i2c_write_byte(u8 devaddr, u8 regoffset, u8 value)
50 struct i2c_adapter *adap;
52 struct i2c_msg msg[1];
53 unsigned char data[2];
55 adap = i2c_get_adapter(0);
58 msg->addr = devaddr; /* I2C address of chip */
62 data[0] = regoffset; /* register num */
63 data[1] = value; /* register data */
64 err = i2c_transfer(adap, msg, 1);
70 /* Read from I2C device */
71 int i2c_read_byte(u8 devaddr, u8 regoffset, u8 * value)
73 struct i2c_adapter *adap;
75 struct i2c_msg msg[1];
76 unsigned char data[2];
78 adap = i2c_get_adapter(0);
82 msg->addr = devaddr; /* I2C address of chip */
86 data[0] = regoffset; /* register num */
87 err = i2c_transfer(adap, msg, 1);
89 msg->addr = devaddr; /* I2C address */
90 msg->flags = I2C_M_RD;
93 err = i2c_transfer(adap, msg, 1);
100 /* set keyboard backlight intensity */
101 int sx1_setkeylight(u8 keylight)
103 if (keylight > SOFIA_MAX_LIGHT_VAL)
104 keylight = SOFIA_MAX_LIGHT_VAL;
105 return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_KEYLIGHT_REG, keylight);
107 /* get current keylight intensity */
108 int sx1_getkeylight(u8 * keylight)
110 return i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_KEYLIGHT_REG, keylight);
112 /* set LCD backlight intensity */
113 int sx1_setbacklight(u8 backlight)
115 if (backlight > SOFIA_MAX_LIGHT_VAL)
116 backlight = SOFIA_MAX_LIGHT_VAL;
117 return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_BACKLIGHT_REG, backlight);
119 /* get current LCD backlight intensity */
120 int sx1_getbacklight (u8 * backlight)
122 return i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_BACKLIGHT_REG, backlight);
124 /* set LCD backlight power on/off */
125 int sx1_setmmipower(u8 onoff)
129 err = i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
133 dat |= SOFIA_MMILIGHT_POWER;
135 dat &= ~SOFIA_MMILIGHT_POWER;
136 return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
139 /* set USB power on/off */
140 int sx1_setusbpower(u8 onoff)
144 err = i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
148 dat |= SOFIA_USB_POWER;
150 dat &= ~SOFIA_USB_POWER;
151 return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
154 EXPORT_SYMBOL(sx1_setkeylight);
155 EXPORT_SYMBOL(sx1_getkeylight);
156 EXPORT_SYMBOL(sx1_setbacklight);
157 EXPORT_SYMBOL(sx1_getbacklight);
158 EXPORT_SYMBOL(sx1_setmmipower);
159 EXPORT_SYMBOL(sx1_setusbpower);
161 /*----------- Keypad -------------------------*/
163 static int sx1_keymap[] = {
164 KEY(5, 3, GROUP_0 | 117), /* camera Qt::Key_F17 */
165 KEY(0, 4, GROUP_0 | 114), /* voice memo Qt::Key_F14 */
166 KEY(1, 4, GROUP_2 | 114), /* voice memo */
167 KEY(2, 4, GROUP_3 | 114), /* voice memo */
168 KEY(0, 0, GROUP_1 | KEY_F12), /* red button Qt::Key_Hangup */
169 KEY(4, 3, GROUP_1 | KEY_LEFT),
170 KEY(2, 3, GROUP_1 | KEY_DOWN),
171 KEY(1, 3, GROUP_1 | KEY_RIGHT),
172 KEY(0, 3, GROUP_1 | KEY_UP),
173 KEY(3, 3, GROUP_1 | KEY_POWER), /* joystick press or Qt::Key_Select */
174 KEY(5, 0, GROUP_1 | KEY_1),
175 KEY(4, 0, GROUP_1 | KEY_2),
176 KEY(3, 0, GROUP_1 | KEY_3),
177 KEY(3, 4, GROUP_1 | KEY_4),
178 KEY(4, 4, GROUP_1 | KEY_5),
179 KEY(5, 4, GROUP_1 | KEY_KPASTERISK),/* "*" */
180 KEY(4, 1, GROUP_1 | KEY_6),
181 KEY(5, 1, GROUP_1 | KEY_7),
182 KEY(3, 1, GROUP_1 | KEY_8),
183 KEY(3, 2, GROUP_1 | KEY_9),
184 KEY(5, 2, GROUP_1 | KEY_0),
185 KEY(4, 2, GROUP_1 | 113), /* # F13 Toggle input method Qt::Key_F13 */
186 KEY(0, 1, GROUP_1 | KEY_F11), /* green button Qt::Key_Call */
187 KEY(1, 2, GROUP_1 | KEY_YEN), /* left soft Qt::Key_Context1 */
188 KEY(2, 2, GROUP_1 | KEY_F8), /* right soft Qt::Key_Back */
189 KEY(2, 1, GROUP_1 | KEY_LEFTSHIFT), /* shift */
190 KEY(1, 1, GROUP_1 | KEY_BACKSPACE), /* C (clear) */
191 KEY(0, 2, GROUP_1 | KEY_F7), /* menu Qt::Key_Menu */
195 static struct resource sx1_kp_resources[] = {
197 .start = INT_KEYBOARD,
199 .flags = IORESOURCE_IRQ,
203 static struct omap_kp_platform_data sx1_kp_data = {
206 .keymap = sx1_keymap,
207 .keymapsize = ARRAY_SIZE(sx1_keymap),
211 static struct platform_device sx1_kp_device = {
212 .name = "omap-keypad",
215 .platform_data = &sx1_kp_data,
217 .num_resources = ARRAY_SIZE(sx1_kp_resources),
218 .resource = sx1_kp_resources,
221 /*----------- IRDA -------------------------*/
223 static struct omap_irda_config sx1_irda_data = {
224 .transceiver_cap = IR_SIRMODE,
225 .rx_channel = OMAP_DMA_UART3_RX,
226 .tx_channel = OMAP_DMA_UART3_TX,
227 .dest_start = UART3_THR,
228 .src_start = UART3_RHR,
233 static struct resource sx1_irda_resources[] = {
237 .flags = IORESOURCE_IRQ,
241 static u64 irda_dmamask = 0xffffffff;
243 static struct platform_device sx1_irda_device = {
247 .platform_data = &sx1_irda_data,
248 .dma_mask = &irda_dmamask,
250 .num_resources = ARRAY_SIZE(sx1_irda_resources),
251 .resource = sx1_irda_resources,
254 /*----------- McBSP & Sound -------------------------*/
256 /* Playback interface - McBSP1 */
257 static struct omap_mcbsp_reg_cfg mcbsp1_regs = {
258 .spcr2 = XINTM(3), /* SPCR2=30 */
259 .spcr1 = RINTM(3), /* SPCR1=30 */
260 .rcr2 = 0, /* RCR2 =00 */
261 .rcr1 = RFRLEN1(1) | RWDLEN1(OMAP_MCBSP_WORD_16), /* RCR1=140 */
262 .xcr2 = 0, /* XCR2 = 0 */
263 .xcr1 = XFRLEN1(1) | XWDLEN1(OMAP_MCBSP_WORD_16), /* XCR1 = 140 */
264 .srgr1 = FWID(15) | CLKGDV(12), /* SRGR1=0f0c */
265 .srgr2 = FSGM | FPER(31), /* SRGR2=101f */
266 .pcr0 = FSXM | FSRM | CLKXM | CLKRM | FSXP | FSRP | CLKXP | CLKRP,
270 static struct omap_alsa_codec_config sx1_alsa_config = {
272 .mcbsp_regs_alsa = &mcbsp1_regs,
275 static struct platform_device sx1_mcbsp1_device = {
276 .name = "omap_alsa_mcbsp",
279 .platform_data = &sx1_alsa_config,
283 /*----------- MTD -------------------------*/
285 static struct mtd_partition sx1_partitions[] = {
286 /* bootloader (U-Boot, etc) in first sector */
288 .name = "bootloader",
289 .offset = 0x01800000,
291 .mask_flags = MTD_WRITEABLE, /* force read-only */
293 /* bootloader params in the next sector */
296 .offset = MTDPART_OFS_APPEND,
303 .offset = MTDPART_OFS_APPEND,
304 .size = SZ_2M - 2 * SZ_128K,
309 .name = "filesystem",
310 .offset = MTDPART_OFS_APPEND,
311 .size = MTDPART_SIZ_FULL,
316 static struct flash_platform_data sx1_flash_data = {
317 .map_name = "cfi_probe",
319 .parts = sx1_partitions,
320 .nr_parts = ARRAY_SIZE(sx1_partitions),
323 #ifdef CONFIG_SX1_OLD_FLASH
324 /* MTD Intel StrataFlash - old flashes */
325 static struct resource sx1_old_flash_resource[] = {
327 .start = OMAP_CS0_PHYS, /* Physical */
328 .end = OMAP_CS0_PHYS + SZ_16M - 1,,
329 .flags = IORESOURCE_MEM,
332 .start = OMAP_CS1_PHYS,
333 .end = OMAP_CS1_PHYS + SZ_8M - 1,
334 .flags = IORESOURCE_MEM,
338 static struct platform_device sx1_flash_device = {
342 .platform_data = &sx1_flash_data,
345 .resource = &sx1_old_flash_resource,
348 /* MTD Intel 4000 flash - new flashes */
349 static struct resource sx1_new_flash_resource = {
350 .start = OMAP_CS0_PHYS,
351 .end = OMAP_CS0_PHYS + SZ_32M - 1,
352 .flags = IORESOURCE_MEM,
355 static struct platform_device sx1_flash_device = {
359 .platform_data = &sx1_flash_data,
362 .resource = &sx1_new_flash_resource,
366 /*----------- USB -------------------------*/
368 static struct omap_usb_config sx1_usb_config __initdata = {
378 /*----------- MMC -------------------------*/
380 static struct omap_mmc_config sx1_mmc_config __initdata = {
387 /*----------- LCD -------------------------*/
389 static struct platform_device sx1_lcd_device = {
394 static struct omap_lcd_config sx1_lcd_config __initdata = {
395 .ctrl_name = "internal",
398 /*-----------------------------------------*/
399 static struct platform_device *sx1_devices[] __initdata = {
406 /*-----------------------------------------*/
408 static struct omap_uart_config sx1_uart_config __initdata = {
409 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
412 static struct omap_board_config_kernel sx1_config[] __initdata = {
413 { OMAP_TAG_USB, &sx1_usb_config },
414 { OMAP_TAG_MMC, &sx1_mmc_config },
415 { OMAP_TAG_LCD, &sx1_lcd_config },
416 { OMAP_TAG_UART, &sx1_uart_config },
419 static struct omap_gpio_switch sx1_gpio_switches[] __initdata = {
422 .gpio = OMAP_MPUIO(3),
423 .type = OMAP_GPIO_SWITCH_TYPE_COVER,
424 .debounce_rising = 100,
425 .debounce_falling = 0,
426 .notify = sx1_mmc_slot_cover_handler,
431 /*-----------------------------------------*/
433 extern void __init sx1_mmc_init(void);
435 static void __init omap_sx1_init(void)
437 platform_add_devices(sx1_devices, ARRAY_SIZE(sx1_devices));
439 omap_board_config = sx1_config;
440 omap_board_config_size = ARRAY_SIZE(sx1_config);
442 omap_register_i2c_bus(1, 100, NULL, 0);
444 omap_register_gpio_switches(sx1_gpio_switches,
445 ARRAY_SIZE(sx1_gpio_switches));
447 /* turn on USB power */
448 /* sx1_setusbpower(1); cant do it here because i2c is not ready */
449 omap_request_gpio(1); /* A_IRDA_OFF */
450 omap_request_gpio(11); /* A_SWITCH */
451 omap_request_gpio(15); /* A_USB_ON */
452 omap_set_gpio_direction(1, 0);/* gpio1 -> output */
453 omap_set_gpio_direction(11, 0);/* gpio11 -> output */
454 omap_set_gpio_direction(15, 0);/* gpio15 -> output */
456 omap_set_gpio_dataout(1, 1);/*A_IRDA_OFF = 1 */
457 omap_set_gpio_dataout(11, 0);/*A_SWITCH = 0 */
458 omap_set_gpio_dataout(15, 0);/*A_USB_ON = 0 */
461 /*----------------------------------------*/
462 static void __init omap_sx1_init_irq(void)
464 omap1_init_common_hw();
468 /*----------------------------------------*/
470 static void __init omap_sx1_map_io(void)
472 omap1_map_common_io();
475 MACHINE_START(SX1, "OMAP310 based Siemens SX1")
476 .phys_io = 0xfff00000,
477 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
478 .boot_params = 0x10000100,
479 .map_io = omap_sx1_map_io,
480 .init_irq = omap_sx1_init_irq,
481 .init_machine = omap_sx1_init,
482 .timer = &omap_timer,