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.
17 #include <linux/gpio.h>
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>
29 #include <linux/export.h>
30 #include <linux/omapfb.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
36 #include <plat/flash.h>
39 #include <plat/irda.h>
41 #include <plat/board.h>
42 #include <plat/keypad.h>
43 #include <plat/board-sx1.h>
45 #include <mach/hardware.h>
50 /* Write to I2C device */
51 int sx1_i2c_write_byte(u8 devaddr
, u8 regoffset
, u8 value
)
53 struct i2c_adapter
*adap
;
55 struct i2c_msg msg
[1];
56 unsigned char data
[2];
58 adap
= i2c_get_adapter(0);
61 msg
->addr
= devaddr
; /* I2C address of chip */
65 data
[0] = regoffset
; /* register num */
66 data
[1] = value
; /* register data */
67 err
= i2c_transfer(adap
, msg
, 1);
68 i2c_put_adapter(adap
);
74 /* Read from I2C device */
75 int sx1_i2c_read_byte(u8 devaddr
, u8 regoffset
, u8
*value
)
77 struct i2c_adapter
*adap
;
79 struct i2c_msg msg
[1];
80 unsigned char data
[2];
82 adap
= i2c_get_adapter(0);
86 msg
->addr
= devaddr
; /* I2C address of chip */
90 data
[0] = regoffset
; /* register num */
91 err
= i2c_transfer(adap
, msg
, 1);
93 msg
->addr
= devaddr
; /* I2C address */
94 msg
->flags
= I2C_M_RD
;
97 err
= i2c_transfer(adap
, msg
, 1);
99 i2c_put_adapter(adap
);
105 /* set keyboard backlight intensity */
106 int sx1_setkeylight(u8 keylight
)
108 if (keylight
> SOFIA_MAX_LIGHT_VAL
)
109 keylight
= SOFIA_MAX_LIGHT_VAL
;
110 return sx1_i2c_write_byte(SOFIA_I2C_ADDR
, SOFIA_KEYLIGHT_REG
, keylight
);
112 /* get current keylight intensity */
113 int sx1_getkeylight(u8
* keylight
)
115 return sx1_i2c_read_byte(SOFIA_I2C_ADDR
, SOFIA_KEYLIGHT_REG
, keylight
);
117 /* set LCD backlight intensity */
118 int sx1_setbacklight(u8 backlight
)
120 if (backlight
> SOFIA_MAX_LIGHT_VAL
)
121 backlight
= SOFIA_MAX_LIGHT_VAL
;
122 return sx1_i2c_write_byte(SOFIA_I2C_ADDR
, SOFIA_BACKLIGHT_REG
,
125 /* get current LCD backlight intensity */
126 int sx1_getbacklight (u8
* backlight
)
128 return sx1_i2c_read_byte(SOFIA_I2C_ADDR
, SOFIA_BACKLIGHT_REG
,
131 /* set LCD backlight power on/off */
132 int sx1_setmmipower(u8 onoff
)
136 err
= sx1_i2c_read_byte(SOFIA_I2C_ADDR
, SOFIA_POWER1_REG
, &dat
);
140 dat
|= SOFIA_MMILIGHT_POWER
;
142 dat
&= ~SOFIA_MMILIGHT_POWER
;
143 return sx1_i2c_write_byte(SOFIA_I2C_ADDR
, SOFIA_POWER1_REG
, dat
);
146 /* set USB power on/off */
147 int sx1_setusbpower(u8 onoff
)
151 err
= sx1_i2c_read_byte(SOFIA_I2C_ADDR
, SOFIA_POWER1_REG
, &dat
);
155 dat
|= SOFIA_USB_POWER
;
157 dat
&= ~SOFIA_USB_POWER
;
158 return sx1_i2c_write_byte(SOFIA_I2C_ADDR
, SOFIA_POWER1_REG
, dat
);
161 EXPORT_SYMBOL(sx1_setkeylight
);
162 EXPORT_SYMBOL(sx1_getkeylight
);
163 EXPORT_SYMBOL(sx1_setbacklight
);
164 EXPORT_SYMBOL(sx1_getbacklight
);
165 EXPORT_SYMBOL(sx1_setmmipower
);
166 EXPORT_SYMBOL(sx1_setusbpower
);
168 /*----------- Keypad -------------------------*/
170 static const unsigned int sx1_keymap
[] = {
171 KEY(3, 5, GROUP_0
| 117), /* camera Qt::Key_F17 */
172 KEY(4, 0, GROUP_0
| 114), /* voice memo Qt::Key_F14 */
173 KEY(4, 1, GROUP_2
| 114), /* voice memo */
174 KEY(4, 2, GROUP_3
| 114), /* voice memo */
175 KEY(0, 0, GROUP_1
| KEY_F12
), /* red button Qt::Key_Hangup */
176 KEY(3, 4, GROUP_1
| KEY_LEFT
),
177 KEY(3, 2, GROUP_1
| KEY_DOWN
),
178 KEY(3, 1, GROUP_1
| KEY_RIGHT
),
179 KEY(3, 0, GROUP_1
| KEY_UP
),
180 KEY(3, 3, GROUP_1
| KEY_POWER
), /* joystick press or Qt::Key_Select */
181 KEY(0, 5, GROUP_1
| KEY_1
),
182 KEY(0, 4, GROUP_1
| KEY_2
),
183 KEY(0, 3, GROUP_1
| KEY_3
),
184 KEY(4, 3, GROUP_1
| KEY_4
),
185 KEY(4, 4, GROUP_1
| KEY_5
),
186 KEY(4, 5, GROUP_1
| KEY_KPASTERISK
),/* "*" */
187 KEY(1, 4, GROUP_1
| KEY_6
),
188 KEY(1, 5, GROUP_1
| KEY_7
),
189 KEY(1, 3, GROUP_1
| KEY_8
),
190 KEY(2, 3, GROUP_1
| KEY_9
),
191 KEY(2, 5, GROUP_1
| KEY_0
),
192 KEY(2, 4, GROUP_1
| 113), /* # F13 Toggle input method Qt::Key_F13 */
193 KEY(1, 0, GROUP_1
| KEY_F11
), /* green button Qt::Key_Call */
194 KEY(2, 1, GROUP_1
| KEY_YEN
), /* left soft Qt::Key_Context1 */
195 KEY(2, 2, GROUP_1
| KEY_F8
), /* right soft Qt::Key_Back */
196 KEY(1, 2, GROUP_1
| KEY_LEFTSHIFT
), /* shift */
197 KEY(1, 1, GROUP_1
| KEY_BACKSPACE
), /* C (clear) */
198 KEY(2, 0, GROUP_1
| KEY_F7
), /* menu Qt::Key_Menu */
201 static struct resource sx1_kp_resources
[] = {
203 .start
= INT_KEYBOARD
,
205 .flags
= IORESOURCE_IRQ
,
209 static const struct matrix_keymap_data sx1_keymap_data
= {
210 .keymap
= sx1_keymap
,
211 .keymap_size
= ARRAY_SIZE(sx1_keymap
),
214 static struct omap_kp_platform_data sx1_kp_data
= {
217 .keymap_data
= &sx1_keymap_data
,
221 static struct platform_device sx1_kp_device
= {
222 .name
= "omap-keypad",
225 .platform_data
= &sx1_kp_data
,
227 .num_resources
= ARRAY_SIZE(sx1_kp_resources
),
228 .resource
= sx1_kp_resources
,
231 /*----------- IRDA -------------------------*/
233 static struct omap_irda_config sx1_irda_data
= {
234 .transceiver_cap
= IR_SIRMODE
,
235 .rx_channel
= OMAP_DMA_UART3_RX
,
236 .tx_channel
= OMAP_DMA_UART3_TX
,
237 .dest_start
= UART3_THR
,
238 .src_start
= UART3_RHR
,
243 static struct resource sx1_irda_resources
[] = {
247 .flags
= IORESOURCE_IRQ
,
251 static u64 irda_dmamask
= 0xffffffff;
253 static struct platform_device sx1_irda_device
= {
257 .platform_data
= &sx1_irda_data
,
258 .dma_mask
= &irda_dmamask
,
260 .num_resources
= ARRAY_SIZE(sx1_irda_resources
),
261 .resource
= sx1_irda_resources
,
264 /*----------- MTD -------------------------*/
266 static struct mtd_partition sx1_partitions
[] = {
267 /* bootloader (U-Boot, etc) in first sector */
269 .name
= "bootloader",
270 .offset
= 0x01800000,
272 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
274 /* bootloader params in the next sector */
277 .offset
= MTDPART_OFS_APPEND
,
284 .offset
= MTDPART_OFS_APPEND
,
285 .size
= SZ_2M
- 2 * SZ_128K
,
290 .name
= "filesystem",
291 .offset
= MTDPART_OFS_APPEND
,
292 .size
= MTDPART_SIZ_FULL
,
297 static struct physmap_flash_data sx1_flash_data
= {
299 .set_vpp
= omap1_set_vpp
,
300 .parts
= sx1_partitions
,
301 .nr_parts
= ARRAY_SIZE(sx1_partitions
),
304 #ifdef CONFIG_SX1_OLD_FLASH
305 /* MTD Intel StrataFlash - old flashes */
306 static struct resource sx1_old_flash_resource
[] = {
308 .start
= OMAP_CS0_PHYS
, /* Physical */
309 .end
= OMAP_CS0_PHYS
+ SZ_16M
- 1,,
310 .flags
= IORESOURCE_MEM
,
313 .start
= OMAP_CS1_PHYS
,
314 .end
= OMAP_CS1_PHYS
+ SZ_8M
- 1,
315 .flags
= IORESOURCE_MEM
,
319 static struct platform_device sx1_flash_device
= {
320 .name
= "physmap-flash",
323 .platform_data
= &sx1_flash_data
,
326 .resource
= &sx1_old_flash_resource
,
329 /* MTD Intel 4000 flash - new flashes */
330 static struct resource sx1_new_flash_resource
= {
331 .start
= OMAP_CS0_PHYS
,
332 .end
= OMAP_CS0_PHYS
+ SZ_32M
- 1,
333 .flags
= IORESOURCE_MEM
,
336 static struct platform_device sx1_flash_device
= {
337 .name
= "physmap-flash",
340 .platform_data
= &sx1_flash_data
,
343 .resource
= &sx1_new_flash_resource
,
347 /*----------- USB -------------------------*/
349 static struct omap_usb_config sx1_usb_config __initdata
= {
359 /*----------- LCD -------------------------*/
361 static struct omap_lcd_config sx1_lcd_config __initdata
= {
362 .ctrl_name
= "internal",
365 /*-----------------------------------------*/
366 static struct platform_device
*sx1_devices
[] __initdata
= {
372 /*-----------------------------------------*/
374 static void __init
omap_sx1_init(void)
376 /* mux pins for uarts */
377 omap_cfg_reg(UART1_TX
);
378 omap_cfg_reg(UART1_RTS
);
379 omap_cfg_reg(UART2_TX
);
380 omap_cfg_reg(UART2_RTS
);
381 omap_cfg_reg(UART3_TX
);
382 omap_cfg_reg(UART3_RX
);
384 platform_add_devices(sx1_devices
, ARRAY_SIZE(sx1_devices
));
387 omap_register_i2c_bus(1, 100, NULL
, 0);
388 omap1_usb_init(&sx1_usb_config
);
391 /* turn on USB power */
392 /* sx1_setusbpower(1); can't do it here because i2c is not ready */
393 gpio_request(1, "A_IRDA_OFF");
394 gpio_request(11, "A_SWITCH");
395 gpio_request(15, "A_USB_ON");
396 gpio_direction_output(1, 1); /*A_IRDA_OFF = 1 */
397 gpio_direction_output(11, 0); /*A_SWITCH = 0 */
398 gpio_direction_output(15, 0); /*A_USB_ON = 0 */
400 omapfb_set_lcd_config(&sx1_lcd_config
);
403 MACHINE_START(SX1
, "OMAP310 based Siemens SX1")
404 .atag_offset
= 0x100,
405 .map_io
= omap15xx_map_io
,
406 .init_early
= omap1_init_early
,
407 .reserve
= omap_reserve
,
408 .init_irq
= omap1_init_irq
,
409 .init_machine
= omap_sx1_init
,
410 .init_late
= omap1_init_late
,
411 .timer
= &omap1_timer
,
412 .restart
= omap1_restart
,