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/mtd/physmap.h>
26 #include <linux/types.h>
27 #include <linux/i2c.h>
28 #include <linux/errno.h>
30 #include <mach/hardware.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
35 #include <mach/gpio.h>
36 #include <plat/flash.h>
39 #include <plat/irda.h>
42 #include <plat/board.h>
43 #include <plat/common.h>
44 #include <plat/keypad.h>
45 #include <plat/board-sx1.h>
47 /* Write to I2C device */
48 int sx1_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);
65 i2c_put_adapter(adap
);
71 /* Read from I2C device */
72 int sx1_i2c_read_byte(u8 devaddr
, u8 regoffset
, u8
*value
)
74 struct i2c_adapter
*adap
;
76 struct i2c_msg msg
[1];
77 unsigned char data
[2];
79 adap
= i2c_get_adapter(0);
83 msg
->addr
= devaddr
; /* I2C address of chip */
87 data
[0] = regoffset
; /* register num */
88 err
= i2c_transfer(adap
, msg
, 1);
90 msg
->addr
= devaddr
; /* I2C address */
91 msg
->flags
= I2C_M_RD
;
94 err
= i2c_transfer(adap
, msg
, 1);
96 i2c_put_adapter(adap
);
102 /* set keyboard backlight intensity */
103 int sx1_setkeylight(u8 keylight
)
105 if (keylight
> SOFIA_MAX_LIGHT_VAL
)
106 keylight
= SOFIA_MAX_LIGHT_VAL
;
107 return sx1_i2c_write_byte(SOFIA_I2C_ADDR
, SOFIA_KEYLIGHT_REG
, keylight
);
109 /* get current keylight intensity */
110 int sx1_getkeylight(u8
* keylight
)
112 return sx1_i2c_read_byte(SOFIA_I2C_ADDR
, SOFIA_KEYLIGHT_REG
, keylight
);
114 /* set LCD backlight intensity */
115 int sx1_setbacklight(u8 backlight
)
117 if (backlight
> SOFIA_MAX_LIGHT_VAL
)
118 backlight
= SOFIA_MAX_LIGHT_VAL
;
119 return sx1_i2c_write_byte(SOFIA_I2C_ADDR
, SOFIA_BACKLIGHT_REG
,
122 /* get current LCD backlight intensity */
123 int sx1_getbacklight (u8
* backlight
)
125 return sx1_i2c_read_byte(SOFIA_I2C_ADDR
, SOFIA_BACKLIGHT_REG
,
128 /* set LCD backlight power on/off */
129 int sx1_setmmipower(u8 onoff
)
133 err
= sx1_i2c_read_byte(SOFIA_I2C_ADDR
, SOFIA_POWER1_REG
, &dat
);
137 dat
|= SOFIA_MMILIGHT_POWER
;
139 dat
&= ~SOFIA_MMILIGHT_POWER
;
140 return sx1_i2c_write_byte(SOFIA_I2C_ADDR
, SOFIA_POWER1_REG
, dat
);
143 /* set USB power on/off */
144 int sx1_setusbpower(u8 onoff
)
148 err
= sx1_i2c_read_byte(SOFIA_I2C_ADDR
, SOFIA_POWER1_REG
, &dat
);
152 dat
|= SOFIA_USB_POWER
;
154 dat
&= ~SOFIA_USB_POWER
;
155 return sx1_i2c_write_byte(SOFIA_I2C_ADDR
, SOFIA_POWER1_REG
, dat
);
158 EXPORT_SYMBOL(sx1_setkeylight
);
159 EXPORT_SYMBOL(sx1_getkeylight
);
160 EXPORT_SYMBOL(sx1_setbacklight
);
161 EXPORT_SYMBOL(sx1_getbacklight
);
162 EXPORT_SYMBOL(sx1_setmmipower
);
163 EXPORT_SYMBOL(sx1_setusbpower
);
165 /*----------- Keypad -------------------------*/
167 static int sx1_keymap
[] = {
168 KEY(5, 3, GROUP_0
| 117), /* camera Qt::Key_F17 */
169 KEY(0, 4, GROUP_0
| 114), /* voice memo Qt::Key_F14 */
170 KEY(1, 4, GROUP_2
| 114), /* voice memo */
171 KEY(2, 4, GROUP_3
| 114), /* voice memo */
172 KEY(0, 0, GROUP_1
| KEY_F12
), /* red button Qt::Key_Hangup */
173 KEY(4, 3, GROUP_1
| KEY_LEFT
),
174 KEY(2, 3, GROUP_1
| KEY_DOWN
),
175 KEY(1, 3, GROUP_1
| KEY_RIGHT
),
176 KEY(0, 3, GROUP_1
| KEY_UP
),
177 KEY(3, 3, GROUP_1
| KEY_POWER
), /* joystick press or Qt::Key_Select */
178 KEY(5, 0, GROUP_1
| KEY_1
),
179 KEY(4, 0, GROUP_1
| KEY_2
),
180 KEY(3, 0, GROUP_1
| KEY_3
),
181 KEY(3, 4, GROUP_1
| KEY_4
),
182 KEY(4, 4, GROUP_1
| KEY_5
),
183 KEY(5, 4, GROUP_1
| KEY_KPASTERISK
),/* "*" */
184 KEY(4, 1, GROUP_1
| KEY_6
),
185 KEY(5, 1, GROUP_1
| KEY_7
),
186 KEY(3, 1, GROUP_1
| KEY_8
),
187 KEY(3, 2, GROUP_1
| KEY_9
),
188 KEY(5, 2, GROUP_1
| KEY_0
),
189 KEY(4, 2, GROUP_1
| 113), /* # F13 Toggle input method Qt::Key_F13 */
190 KEY(0, 1, GROUP_1
| KEY_F11
), /* green button Qt::Key_Call */
191 KEY(1, 2, GROUP_1
| KEY_YEN
), /* left soft Qt::Key_Context1 */
192 KEY(2, 2, GROUP_1
| KEY_F8
), /* right soft Qt::Key_Back */
193 KEY(2, 1, GROUP_1
| KEY_LEFTSHIFT
), /* shift */
194 KEY(1, 1, GROUP_1
| KEY_BACKSPACE
), /* C (clear) */
195 KEY(0, 2, GROUP_1
| KEY_F7
), /* menu Qt::Key_Menu */
199 static struct resource sx1_kp_resources
[] = {
201 .start
= INT_KEYBOARD
,
203 .flags
= IORESOURCE_IRQ
,
207 static struct omap_kp_platform_data sx1_kp_data
= {
210 .keymap
= sx1_keymap
,
211 .keymapsize
= ARRAY_SIZE(sx1_keymap
),
215 static struct platform_device sx1_kp_device
= {
216 .name
= "omap-keypad",
219 .platform_data
= &sx1_kp_data
,
221 .num_resources
= ARRAY_SIZE(sx1_kp_resources
),
222 .resource
= sx1_kp_resources
,
225 /*----------- IRDA -------------------------*/
227 static struct omap_irda_config sx1_irda_data
= {
228 .transceiver_cap
= IR_SIRMODE
,
229 .rx_channel
= OMAP_DMA_UART3_RX
,
230 .tx_channel
= OMAP_DMA_UART3_TX
,
231 .dest_start
= UART3_THR
,
232 .src_start
= UART3_RHR
,
237 static struct resource sx1_irda_resources
[] = {
241 .flags
= IORESOURCE_IRQ
,
245 static u64 irda_dmamask
= 0xffffffff;
247 static struct platform_device sx1_irda_device
= {
251 .platform_data
= &sx1_irda_data
,
252 .dma_mask
= &irda_dmamask
,
254 .num_resources
= ARRAY_SIZE(sx1_irda_resources
),
255 .resource
= sx1_irda_resources
,
258 /*----------- MTD -------------------------*/
260 static struct mtd_partition sx1_partitions
[] = {
261 /* bootloader (U-Boot, etc) in first sector */
263 .name
= "bootloader",
264 .offset
= 0x01800000,
266 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
268 /* bootloader params in the next sector */
271 .offset
= MTDPART_OFS_APPEND
,
278 .offset
= MTDPART_OFS_APPEND
,
279 .size
= SZ_2M
- 2 * SZ_128K
,
284 .name
= "filesystem",
285 .offset
= MTDPART_OFS_APPEND
,
286 .size
= MTDPART_SIZ_FULL
,
291 static struct physmap_flash_data sx1_flash_data
= {
293 .set_vpp
= omap1_set_vpp
,
294 .parts
= sx1_partitions
,
295 .nr_parts
= ARRAY_SIZE(sx1_partitions
),
298 #ifdef CONFIG_SX1_OLD_FLASH
299 /* MTD Intel StrataFlash - old flashes */
300 static struct resource sx1_old_flash_resource
[] = {
302 .start
= OMAP_CS0_PHYS
, /* Physical */
303 .end
= OMAP_CS0_PHYS
+ SZ_16M
- 1,,
304 .flags
= IORESOURCE_MEM
,
307 .start
= OMAP_CS1_PHYS
,
308 .end
= OMAP_CS1_PHYS
+ SZ_8M
- 1,
309 .flags
= IORESOURCE_MEM
,
313 static struct platform_device sx1_flash_device
= {
314 .name
= "physmap-flash",
317 .platform_data
= &sx1_flash_data
,
320 .resource
= &sx1_old_flash_resource
,
323 /* MTD Intel 4000 flash - new flashes */
324 static struct resource sx1_new_flash_resource
= {
325 .start
= OMAP_CS0_PHYS
,
326 .end
= OMAP_CS0_PHYS
+ SZ_32M
- 1,
327 .flags
= IORESOURCE_MEM
,
330 static struct platform_device sx1_flash_device
= {
331 .name
= "physmap-flash",
334 .platform_data
= &sx1_flash_data
,
337 .resource
= &sx1_new_flash_resource
,
341 /*----------- USB -------------------------*/
343 static struct omap_usb_config sx1_usb_config __initdata
= {
353 /*----------- LCD -------------------------*/
355 static struct platform_device sx1_lcd_device
= {
360 static struct omap_lcd_config sx1_lcd_config __initdata
= {
361 .ctrl_name
= "internal",
364 /*-----------------------------------------*/
365 static struct platform_device
*sx1_devices
[] __initdata
= {
371 /*-----------------------------------------*/
373 static struct omap_board_config_kernel sx1_config
[] __initdata
= {
374 { OMAP_TAG_LCD
, &sx1_lcd_config
},
377 /*-----------------------------------------*/
379 static void __init
omap_sx1_init(void)
381 /* mux pins for uarts */
382 omap_cfg_reg(UART1_TX
);
383 omap_cfg_reg(UART1_RTS
);
384 omap_cfg_reg(UART2_TX
);
385 omap_cfg_reg(UART2_RTS
);
386 omap_cfg_reg(UART3_TX
);
387 omap_cfg_reg(UART3_RX
);
389 platform_add_devices(sx1_devices
, ARRAY_SIZE(sx1_devices
));
391 omap_board_config
= sx1_config
;
392 omap_board_config_size
= ARRAY_SIZE(sx1_config
);
394 omap_register_i2c_bus(1, 100, NULL
, 0);
395 omap1_usb_init(&sx1_usb_config
);
398 /* turn on USB power */
399 /* sx1_setusbpower(1); cant do it here because i2c is not ready */
400 gpio_request(1, "A_IRDA_OFF");
401 gpio_request(11, "A_SWITCH");
402 gpio_request(15, "A_USB_ON");
403 gpio_direction_output(1, 1); /*A_IRDA_OFF = 1 */
404 gpio_direction_output(11, 0); /*A_SWITCH = 0 */
405 gpio_direction_output(15, 0); /*A_USB_ON = 0 */
407 /*----------------------------------------*/
408 static void __init
omap_sx1_init_irq(void)
410 omap1_init_common_hw();
414 /*----------------------------------------*/
416 static void __init
omap_sx1_map_io(void)
418 omap1_map_common_io();
421 MACHINE_START(SX1
, "OMAP310 based Siemens SX1")
422 .boot_params
= 0x10000100,
423 .map_io
= omap_sx1_map_io
,
424 .reserve
= omap_reserve
,
425 .init_irq
= omap_sx1_init_irq
,
426 .init_machine
= omap_sx1_init
,
427 .timer
= &omap_timer
,