xref: /linux/arch/arm/mach-omap1/board-sx1.c (revision c79ed1940ca9a4af5e9c182ac51f28dadd32956d)
1*c79ed194SVladimir Ananiev /*
2*c79ed194SVladimir Ananiev * linux/arch/arm/mach-omap1/board-sx1.c
3*c79ed194SVladimir Ananiev *
4*c79ed194SVladimir Ananiev * Modified from board-generic.c
5*c79ed194SVladimir Ananiev *
6*c79ed194SVladimir Ananiev * Support for the Siemens SX1 mobile phone.
7*c79ed194SVladimir Ananiev *
8*c79ed194SVladimir Ananiev * Original version : Vladimir Ananiev (Vovan888-at-gmail com)
9*c79ed194SVladimir Ananiev *
10*c79ed194SVladimir Ananiev * Maintainters : Vladimir Ananiev (aka Vovan888), Sergge
11*c79ed194SVladimir Ananiev *		oslik.ru
12*c79ed194SVladimir Ananiev *
13*c79ed194SVladimir Ananiev * This program is free software; you can redistribute it and/or modify
14*c79ed194SVladimir Ananiev * it under the terms of the GNU General Public License version 2 as
15*c79ed194SVladimir Ananiev * published by the Free Software Foundation.
16*c79ed194SVladimir Ananiev */
17*c79ed194SVladimir Ananiev 
18*c79ed194SVladimir Ananiev #include <linux/kernel.h>
19*c79ed194SVladimir Ananiev #include <linux/init.h>
20*c79ed194SVladimir Ananiev #include <linux/input.h>
21*c79ed194SVladimir Ananiev #include <linux/platform_device.h>
22*c79ed194SVladimir Ananiev #include <linux/notifier.h>
23*c79ed194SVladimir Ananiev #include <linux/mtd/mtd.h>
24*c79ed194SVladimir Ananiev #include <linux/mtd/partitions.h>
25*c79ed194SVladimir Ananiev #include <linux/types.h>
26*c79ed194SVladimir Ananiev #include <linux/i2c.h>
27*c79ed194SVladimir Ananiev #include <linux/errno.h>
28*c79ed194SVladimir Ananiev 
29*c79ed194SVladimir Ananiev #include <asm/hardware.h>
30*c79ed194SVladimir Ananiev #include <asm/mach-types.h>
31*c79ed194SVladimir Ananiev #include <asm/mach/arch.h>
32*c79ed194SVladimir Ananiev #include <asm/mach/flash.h>
33*c79ed194SVladimir Ananiev #include <asm/mach/map.h>
34*c79ed194SVladimir Ananiev 
35*c79ed194SVladimir Ananiev #include <asm/arch/gpio.h>
36*c79ed194SVladimir Ananiev #include <asm/arch/mux.h>
37*c79ed194SVladimir Ananiev #include <asm/arch/irda.h>
38*c79ed194SVladimir Ananiev #include <asm/arch/usb.h>
39*c79ed194SVladimir Ananiev #include <asm/arch/tc.h>
40*c79ed194SVladimir Ananiev #include <asm/arch/board.h>
41*c79ed194SVladimir Ananiev #include <asm/arch/common.h>
42*c79ed194SVladimir Ananiev #include <asm/arch/mcbsp.h>
43*c79ed194SVladimir Ananiev #include <asm/arch/omap-alsa.h>
44*c79ed194SVladimir Ananiev #include <asm/arch/keypad.h>
45*c79ed194SVladimir Ananiev 
46*c79ed194SVladimir Ananiev /* Write to I2C device */
47*c79ed194SVladimir Ananiev int i2c_write_byte(u8 devaddr, u8 regoffset, u8 value)
48*c79ed194SVladimir Ananiev {
49*c79ed194SVladimir Ananiev 	struct i2c_adapter *adap;
50*c79ed194SVladimir Ananiev 	int err;
51*c79ed194SVladimir Ananiev 	struct i2c_msg msg[1];
52*c79ed194SVladimir Ananiev 	unsigned char data[2];
53*c79ed194SVladimir Ananiev 
54*c79ed194SVladimir Ananiev 	adap = i2c_get_adapter(0);
55*c79ed194SVladimir Ananiev 	if (!adap)
56*c79ed194SVladimir Ananiev 		return -ENODEV;
57*c79ed194SVladimir Ananiev 	msg->addr = devaddr;	/* I2C address of chip */
58*c79ed194SVladimir Ananiev 	msg->flags = 0;
59*c79ed194SVladimir Ananiev 	msg->len = 2;
60*c79ed194SVladimir Ananiev 	msg->buf = data;
61*c79ed194SVladimir Ananiev 	data[0] = regoffset;	/* register num */
62*c79ed194SVladimir Ananiev 	data[1] = value;		/* register data */
63*c79ed194SVladimir Ananiev 	err = i2c_transfer(adap, msg, 1);
64*c79ed194SVladimir Ananiev 	if (err >= 0)
65*c79ed194SVladimir Ananiev 		return 0;
66*c79ed194SVladimir Ananiev 	return err;
67*c79ed194SVladimir Ananiev }
68*c79ed194SVladimir Ananiev 
69*c79ed194SVladimir Ananiev /* Read from I2C device */
70*c79ed194SVladimir Ananiev int i2c_read_byte(u8 devaddr, u8 regoffset, u8 * value)
71*c79ed194SVladimir Ananiev {
72*c79ed194SVladimir Ananiev 	struct i2c_adapter *adap;
73*c79ed194SVladimir Ananiev 	int err;
74*c79ed194SVladimir Ananiev 	struct i2c_msg msg[1];
75*c79ed194SVladimir Ananiev 	unsigned char data[2];
76*c79ed194SVladimir Ananiev 
77*c79ed194SVladimir Ananiev 	adap = i2c_get_adapter(0);
78*c79ed194SVladimir Ananiev 	if (!adap)
79*c79ed194SVladimir Ananiev 		return -ENODEV;
80*c79ed194SVladimir Ananiev 
81*c79ed194SVladimir Ananiev 	msg->addr = devaddr;	/* I2C address of chip */
82*c79ed194SVladimir Ananiev 	msg->flags = 0;
83*c79ed194SVladimir Ananiev 	msg->len = 1;
84*c79ed194SVladimir Ananiev 	msg->buf = data;
85*c79ed194SVladimir Ananiev 	data[0] = regoffset;	/* register num */
86*c79ed194SVladimir Ananiev 	err = i2c_transfer(adap, msg, 1);
87*c79ed194SVladimir Ananiev 
88*c79ed194SVladimir Ananiev 	msg->addr = devaddr;	/* I2C address */
89*c79ed194SVladimir Ananiev 	msg->flags = I2C_M_RD;
90*c79ed194SVladimir Ananiev 	msg->len = 1;
91*c79ed194SVladimir Ananiev 	msg->buf = data;
92*c79ed194SVladimir Ananiev 	err = i2c_transfer(adap, msg, 1);
93*c79ed194SVladimir Ananiev 	*value = data[0];
94*c79ed194SVladimir Ananiev 
95*c79ed194SVladimir Ananiev 	if (err >= 0)
96*c79ed194SVladimir Ananiev 		return 0;
97*c79ed194SVladimir Ananiev 	return err;
98*c79ed194SVladimir Ananiev }
99*c79ed194SVladimir Ananiev /* set keyboard backlight intensity */
100*c79ed194SVladimir Ananiev int sx1_setkeylight(u8 keylight)
101*c79ed194SVladimir Ananiev {
102*c79ed194SVladimir Ananiev 	if (keylight > SOFIA_MAX_LIGHT_VAL)
103*c79ed194SVladimir Ananiev 		keylight = SOFIA_MAX_LIGHT_VAL;
104*c79ed194SVladimir Ananiev 	return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_KEYLIGHT_REG, keylight);
105*c79ed194SVladimir Ananiev }
106*c79ed194SVladimir Ananiev /* get current keylight intensity */
107*c79ed194SVladimir Ananiev int sx1_getkeylight(u8 * keylight)
108*c79ed194SVladimir Ananiev {
109*c79ed194SVladimir Ananiev 	return i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_KEYLIGHT_REG, keylight);
110*c79ed194SVladimir Ananiev }
111*c79ed194SVladimir Ananiev /* set LCD backlight intensity */
112*c79ed194SVladimir Ananiev int sx1_setbacklight(u8 backlight)
113*c79ed194SVladimir Ananiev {
114*c79ed194SVladimir Ananiev 	if (backlight > SOFIA_MAX_LIGHT_VAL)
115*c79ed194SVladimir Ananiev 		backlight = SOFIA_MAX_LIGHT_VAL;
116*c79ed194SVladimir Ananiev 	return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_BACKLIGHT_REG, backlight);
117*c79ed194SVladimir Ananiev }
118*c79ed194SVladimir Ananiev /* get current LCD backlight intensity */
119*c79ed194SVladimir Ananiev int sx1_getbacklight (u8 * backlight)
120*c79ed194SVladimir Ananiev {
121*c79ed194SVladimir Ananiev 	return i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_BACKLIGHT_REG, backlight);
122*c79ed194SVladimir Ananiev }
123*c79ed194SVladimir Ananiev /* set LCD backlight power on/off */
124*c79ed194SVladimir Ananiev int sx1_setmmipower(u8 onoff)
125*c79ed194SVladimir Ananiev {
126*c79ed194SVladimir Ananiev 	int err;
127*c79ed194SVladimir Ananiev 	u8 dat = 0;
128*c79ed194SVladimir Ananiev 	err = i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
129*c79ed194SVladimir Ananiev 	if (err < 0)
130*c79ed194SVladimir Ananiev 		return err;
131*c79ed194SVladimir Ananiev 	if (onoff)
132*c79ed194SVladimir Ananiev 		dat |= SOFIA_MMILIGHT_POWER;
133*c79ed194SVladimir Ananiev 	else
134*c79ed194SVladimir Ananiev 		dat &= ~SOFIA_MMILIGHT_POWER;
135*c79ed194SVladimir Ananiev 	return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
136*c79ed194SVladimir Ananiev }
137*c79ed194SVladimir Ananiev /* set MMC power on/off */
138*c79ed194SVladimir Ananiev int sx1_setmmcpower(u8 onoff)
139*c79ed194SVladimir Ananiev {
140*c79ed194SVladimir Ananiev 	int err;
141*c79ed194SVladimir Ananiev 	u8 dat = 0;
142*c79ed194SVladimir Ananiev 	err = i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
143*c79ed194SVladimir Ananiev 	if (err < 0)
144*c79ed194SVladimir Ananiev 		return err;
145*c79ed194SVladimir Ananiev 	if (onoff)
146*c79ed194SVladimir Ananiev 		dat |= SOFIA_MMC_POWER;
147*c79ed194SVladimir Ananiev 	else
148*c79ed194SVladimir Ananiev 		dat &= ~SOFIA_MMC_POWER;
149*c79ed194SVladimir Ananiev 	return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
150*c79ed194SVladimir Ananiev }
151*c79ed194SVladimir Ananiev /* set USB power on/off */
152*c79ed194SVladimir Ananiev int sx1_setusbpower(u8 onoff)
153*c79ed194SVladimir Ananiev {
154*c79ed194SVladimir Ananiev 	int err;
155*c79ed194SVladimir Ananiev 	u8 dat = 0;
156*c79ed194SVladimir Ananiev 	err = i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
157*c79ed194SVladimir Ananiev 	if (err < 0)
158*c79ed194SVladimir Ananiev 		return err;
159*c79ed194SVladimir Ananiev 	if (onoff)
160*c79ed194SVladimir Ananiev 		dat |= SOFIA_USB_POWER;
161*c79ed194SVladimir Ananiev 	else
162*c79ed194SVladimir Ananiev 		dat &= ~SOFIA_USB_POWER;
163*c79ed194SVladimir Ananiev 	return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
164*c79ed194SVladimir Ananiev }
165*c79ed194SVladimir Ananiev 
166*c79ed194SVladimir Ananiev EXPORT_SYMBOL(sx1_setkeylight);
167*c79ed194SVladimir Ananiev EXPORT_SYMBOL(sx1_getkeylight);
168*c79ed194SVladimir Ananiev EXPORT_SYMBOL(sx1_setbacklight);
169*c79ed194SVladimir Ananiev EXPORT_SYMBOL(sx1_getbacklight);
170*c79ed194SVladimir Ananiev EXPORT_SYMBOL(sx1_setmmipower);
171*c79ed194SVladimir Ananiev EXPORT_SYMBOL(sx1_setmmcpower);
172*c79ed194SVladimir Ananiev EXPORT_SYMBOL(sx1_setusbpower);
173*c79ed194SVladimir Ananiev 
174*c79ed194SVladimir Ananiev /*----------- Keypad -------------------------*/
175*c79ed194SVladimir Ananiev 
176*c79ed194SVladimir Ananiev static int sx1_keymap[] = {
177*c79ed194SVladimir Ananiev 	KEY(5, 3, GROUP_0 | 117), /* camera Qt::Key_F17 */
178*c79ed194SVladimir Ananiev 	KEY(0, 4, GROUP_0 | 114), /* voice memo Qt::Key_F14 */
179*c79ed194SVladimir Ananiev 	KEY(1, 4, GROUP_2 | 114), /* voice memo */
180*c79ed194SVladimir Ananiev 	KEY(2, 4, GROUP_3 | 114), /* voice memo */
181*c79ed194SVladimir Ananiev 	KEY(0, 0, GROUP_1 | KEY_F12),	/* red button Qt::Key_Hangup */
182*c79ed194SVladimir Ananiev 	KEY(4, 3, GROUP_1 | KEY_LEFT),
183*c79ed194SVladimir Ananiev 	KEY(2, 3, GROUP_1 | KEY_DOWN),
184*c79ed194SVladimir Ananiev 	KEY(1, 3, GROUP_1 | KEY_RIGHT),
185*c79ed194SVladimir Ananiev 	KEY(0, 3, GROUP_1 | KEY_UP),
186*c79ed194SVladimir Ananiev 	KEY(3, 3, GROUP_1 | KEY_POWER), /* joystick press or Qt::Key_Select */
187*c79ed194SVladimir Ananiev 	KEY(5, 0, GROUP_1 | KEY_1),
188*c79ed194SVladimir Ananiev 	KEY(4, 0, GROUP_1 | KEY_2),
189*c79ed194SVladimir Ananiev 	KEY(3, 0, GROUP_1 | KEY_3),
190*c79ed194SVladimir Ananiev 	KEY(3, 4, GROUP_1 | KEY_4),
191*c79ed194SVladimir Ananiev 	KEY(4, 4, GROUP_1 | KEY_5),
192*c79ed194SVladimir Ananiev 	KEY(5, 4, GROUP_1 | KEY_KPASTERISK),/* "*" */
193*c79ed194SVladimir Ananiev 	KEY(4, 1, GROUP_1 | KEY_6),
194*c79ed194SVladimir Ananiev 	KEY(5, 1, GROUP_1 | KEY_7),
195*c79ed194SVladimir Ananiev 	KEY(3, 1, GROUP_1 | KEY_8),
196*c79ed194SVladimir Ananiev 	KEY(3, 2, GROUP_1 | KEY_9),
197*c79ed194SVladimir Ananiev 	KEY(5, 2, GROUP_1 | KEY_0),
198*c79ed194SVladimir Ananiev 	KEY(4, 2, GROUP_1 | 113),	/* # F13 Toggle input method Qt::Key_F13 */
199*c79ed194SVladimir Ananiev 	KEY(0, 1, GROUP_1 | KEY_F11),	/* green button Qt::Key_Call */
200*c79ed194SVladimir Ananiev 	KEY(1, 2, GROUP_1 | KEY_YEN),	/* left soft Qt::Key_Context1 */
201*c79ed194SVladimir Ananiev 	KEY(2, 2, GROUP_1 | KEY_F8),	/* right soft Qt::Key_Back */
202*c79ed194SVladimir Ananiev 	KEY(2, 1, GROUP_1 | KEY_LEFTSHIFT), /* shift */
203*c79ed194SVladimir Ananiev 	KEY(1, 1, GROUP_1 | KEY_BACKSPACE), /* C (clear) */
204*c79ed194SVladimir Ananiev 	KEY(0, 2, GROUP_1 | KEY_F7),	/* menu Qt::Key_Menu */
205*c79ed194SVladimir Ananiev 	0
206*c79ed194SVladimir Ananiev };
207*c79ed194SVladimir Ananiev 
208*c79ed194SVladimir Ananiev static struct resource sx1_kp_resources[] = {
209*c79ed194SVladimir Ananiev 	[0] = {
210*c79ed194SVladimir Ananiev 		.start	= INT_KEYBOARD,
211*c79ed194SVladimir Ananiev 		.end	= INT_KEYBOARD,
212*c79ed194SVladimir Ananiev 		.flags	= IORESOURCE_IRQ,
213*c79ed194SVladimir Ananiev 	},
214*c79ed194SVladimir Ananiev };
215*c79ed194SVladimir Ananiev 
216*c79ed194SVladimir Ananiev static struct omap_kp_platform_data sx1_kp_data = {
217*c79ed194SVladimir Ananiev 	.rows		= 6,
218*c79ed194SVladimir Ananiev 	.cols		= 6,
219*c79ed194SVladimir Ananiev 	.keymap	= sx1_keymap,
220*c79ed194SVladimir Ananiev 	.keymapsize = ARRAY_SIZE(sx1_keymap),
221*c79ed194SVladimir Ananiev 	.delay	= 80,
222*c79ed194SVladimir Ananiev };
223*c79ed194SVladimir Ananiev 
224*c79ed194SVladimir Ananiev static struct platform_device sx1_kp_device = {
225*c79ed194SVladimir Ananiev 	.name		= "omap-keypad",
226*c79ed194SVladimir Ananiev 	.id		= -1,
227*c79ed194SVladimir Ananiev 	.dev		= {
228*c79ed194SVladimir Ananiev 		.platform_data = &sx1_kp_data,
229*c79ed194SVladimir Ananiev 	},
230*c79ed194SVladimir Ananiev 	.num_resources	= ARRAY_SIZE(sx1_kp_resources),
231*c79ed194SVladimir Ananiev 	.resource	= sx1_kp_resources,
232*c79ed194SVladimir Ananiev };
233*c79ed194SVladimir Ananiev 
234*c79ed194SVladimir Ananiev /*----------- IRDA -------------------------*/
235*c79ed194SVladimir Ananiev 
236*c79ed194SVladimir Ananiev static struct omap_irda_config sx1_irda_data = {
237*c79ed194SVladimir Ananiev 	.transceiver_cap	= IR_SIRMODE,
238*c79ed194SVladimir Ananiev 	.rx_channel		= OMAP_DMA_UART3_RX,
239*c79ed194SVladimir Ananiev 	.tx_channel		= OMAP_DMA_UART3_TX,
240*c79ed194SVladimir Ananiev 	.dest_start		= UART3_THR,
241*c79ed194SVladimir Ananiev 	.src_start		= UART3_RHR,
242*c79ed194SVladimir Ananiev 	.tx_trigger		= 0,
243*c79ed194SVladimir Ananiev 	.rx_trigger		= 0,
244*c79ed194SVladimir Ananiev };
245*c79ed194SVladimir Ananiev 
246*c79ed194SVladimir Ananiev static struct resource sx1_irda_resources[] = {
247*c79ed194SVladimir Ananiev 	[0] = {
248*c79ed194SVladimir Ananiev 		.start	= INT_UART3,
249*c79ed194SVladimir Ananiev 		.end	= INT_UART3,
250*c79ed194SVladimir Ananiev 		.flags	= IORESOURCE_IRQ,
251*c79ed194SVladimir Ananiev 	},
252*c79ed194SVladimir Ananiev };
253*c79ed194SVladimir Ananiev 
254*c79ed194SVladimir Ananiev static u64 irda_dmamask = 0xffffffff;
255*c79ed194SVladimir Ananiev 
256*c79ed194SVladimir Ananiev static struct platform_device sx1_irda_device = {
257*c79ed194SVladimir Ananiev 	.name		= "omapirda",
258*c79ed194SVladimir Ananiev 	.id		= 0,
259*c79ed194SVladimir Ananiev 	.dev		= {
260*c79ed194SVladimir Ananiev 		.platform_data	= &sx1_irda_data,
261*c79ed194SVladimir Ananiev 		.dma_mask	= &irda_dmamask,
262*c79ed194SVladimir Ananiev 	},
263*c79ed194SVladimir Ananiev 	.num_resources	= ARRAY_SIZE(sx1_irda_resources),
264*c79ed194SVladimir Ananiev 	.resource	= sx1_irda_resources,
265*c79ed194SVladimir Ananiev };
266*c79ed194SVladimir Ananiev 
267*c79ed194SVladimir Ananiev /*----------- McBSP & Sound -------------------------*/
268*c79ed194SVladimir Ananiev 
269*c79ed194SVladimir Ananiev /* Playback interface - McBSP1 */
270*c79ed194SVladimir Ananiev static struct omap_mcbsp_reg_cfg mcbsp1_regs = {
271*c79ed194SVladimir Ananiev 	.spcr2	= XINTM(3),	/* SPCR2=30 */
272*c79ed194SVladimir Ananiev 	.spcr1	= RINTM(3),	/* SPCR1=30 */
273*c79ed194SVladimir Ananiev 	.rcr2	= 0,	/* RCR2 =00 */
274*c79ed194SVladimir Ananiev 	.rcr1	= RFRLEN1(1) | RWDLEN1(OMAP_MCBSP_WORD_16),	/* RCR1=140 */
275*c79ed194SVladimir Ananiev 	.xcr2	= 0,	/* XCR2 = 0 */
276*c79ed194SVladimir Ananiev 	.xcr1	= XFRLEN1(1) | XWDLEN1(OMAP_MCBSP_WORD_16),	/* XCR1 = 140 */
277*c79ed194SVladimir Ananiev 	.srgr1	= FWID(15) | CLKGDV(12),	/* SRGR1=0f0c */
278*c79ed194SVladimir Ananiev 	.srgr2	= FSGM | FPER(31),	/* SRGR2=101f */
279*c79ed194SVladimir Ananiev 	.pcr0	= FSXM | FSRM | CLKXM | CLKRM | FSXP | FSRP | CLKXP | CLKRP,
280*c79ed194SVladimir Ananiev 						/* PCR0 =0f0f */
281*c79ed194SVladimir Ananiev };
282*c79ed194SVladimir Ananiev 
283*c79ed194SVladimir Ananiev /* TODO: PCM interface - McBSP2 */
284*c79ed194SVladimir Ananiev static struct omap_mcbsp_reg_cfg mcbsp2_regs = {
285*c79ed194SVladimir Ananiev 	.spcr2	= FRST | GRST | XRST | XINTM(3),	/* SPCR2=F1 */
286*c79ed194SVladimir Ananiev 	.spcr1	= RINTM(3) | RRST,	/* SPCR1=30 */
287*c79ed194SVladimir Ananiev 	.rcr2	= 0,	/* RCR2 =00 */
288*c79ed194SVladimir Ananiev 	.rcr1	= RFRLEN1(1) | RWDLEN1(OMAP_MCBSP_WORD_16), /* RCR1 = 140 */
289*c79ed194SVladimir Ananiev 	.xcr2	= 0,	/* XCR2 = 0 */
290*c79ed194SVladimir Ananiev 	.xcr1	= XFRLEN1(1) | XWDLEN1(OMAP_MCBSP_WORD_16), /* XCR1 = 140 */
291*c79ed194SVladimir Ananiev 	.srgr1	= FWID(15) | CLKGDV(12),	/* SRGR1=0f0c */
292*c79ed194SVladimir Ananiev 	.srgr2	= FSGM | FPER(31),	/* SRGR2=101f */
293*c79ed194SVladimir Ananiev 	.pcr0	= FSXM | FSRM | CLKXM | CLKRM | FSXP | FSRP | CLKXP | CLKRP,
294*c79ed194SVladimir Ananiev 						/* PCR0=0f0f */
295*c79ed194SVladimir Ananiev 	/* mcbsp: slave */
296*c79ed194SVladimir Ananiev };
297*c79ed194SVladimir Ananiev 
298*c79ed194SVladimir Ananiev static struct omap_alsa_codec_config sx1_alsa_config = {
299*c79ed194SVladimir Ananiev 	.name			= "SX1 EGold",
300*c79ed194SVladimir Ananiev 	.mcbsp_regs_alsa	= &mcbsp1_regs,
301*c79ed194SVladimir Ananiev };
302*c79ed194SVladimir Ananiev 
303*c79ed194SVladimir Ananiev static struct platform_device sx1_mcbsp1_device = {
304*c79ed194SVladimir Ananiev 	.name	= "omap_alsa_mcbsp",
305*c79ed194SVladimir Ananiev 	.id	= 1,
306*c79ed194SVladimir Ananiev 	.dev = {
307*c79ed194SVladimir Ananiev 		.platform_data	= &sx1_alsa_config,
308*c79ed194SVladimir Ananiev 	},
309*c79ed194SVladimir Ananiev };
310*c79ed194SVladimir Ananiev 
311*c79ed194SVladimir Ananiev /*----------- MTD -------------------------*/
312*c79ed194SVladimir Ananiev 
313*c79ed194SVladimir Ananiev static struct mtd_partition sx1_partitions[] = {
314*c79ed194SVladimir Ananiev 	/* bootloader (U-Boot, etc) in first sector */
315*c79ed194SVladimir Ananiev 	{
316*c79ed194SVladimir Ananiev 		.name		= "bootloader",
317*c79ed194SVladimir Ananiev 		.offset		= 0x01800000,
318*c79ed194SVladimir Ananiev 		.size		= SZ_128K,
319*c79ed194SVladimir Ananiev 		.mask_flags	= MTD_WRITEABLE, /* force read-only */
320*c79ed194SVladimir Ananiev 	},
321*c79ed194SVladimir Ananiev 	/* bootloader params in the next sector */
322*c79ed194SVladimir Ananiev 	{
323*c79ed194SVladimir Ananiev 		.name		= "params",
324*c79ed194SVladimir Ananiev 		.offset		= MTDPART_OFS_APPEND,
325*c79ed194SVladimir Ananiev 		.size		= SZ_128K,
326*c79ed194SVladimir Ananiev 		.mask_flags	= 0,
327*c79ed194SVladimir Ananiev 	},
328*c79ed194SVladimir Ananiev 	/* kernel */
329*c79ed194SVladimir Ananiev 	{
330*c79ed194SVladimir Ananiev 		.name		= "kernel",
331*c79ed194SVladimir Ananiev 		.offset		= MTDPART_OFS_APPEND,
332*c79ed194SVladimir Ananiev 		.size		= SZ_2M - 2 * SZ_128K,
333*c79ed194SVladimir Ananiev 		.mask_flags	= 0
334*c79ed194SVladimir Ananiev 	},
335*c79ed194SVladimir Ananiev 	/* file system */
336*c79ed194SVladimir Ananiev 	{
337*c79ed194SVladimir Ananiev 		.name		= "filesystem",
338*c79ed194SVladimir Ananiev 		.offset		= MTDPART_OFS_APPEND,
339*c79ed194SVladimir Ananiev 		.size		= MTDPART_SIZ_FULL,
340*c79ed194SVladimir Ananiev 		.mask_flags	= 0
341*c79ed194SVladimir Ananiev 	}
342*c79ed194SVladimir Ananiev };
343*c79ed194SVladimir Ananiev 
344*c79ed194SVladimir Ananiev static struct flash_platform_data sx1_flash_data = {
345*c79ed194SVladimir Ananiev 	.map_name	= "cfi_probe",
346*c79ed194SVladimir Ananiev 	.width		= 2,
347*c79ed194SVladimir Ananiev 	.parts		= sx1_partitions,
348*c79ed194SVladimir Ananiev 	.nr_parts	= ARRAY_SIZE(sx1_partitions),
349*c79ed194SVladimir Ananiev };
350*c79ed194SVladimir Ananiev 
351*c79ed194SVladimir Ananiev #ifdef CONFIG_SX1_OLD_FLASH
352*c79ed194SVladimir Ananiev /* MTD Intel StrataFlash - old flashes */
353*c79ed194SVladimir Ananiev static struct resource sx1_old_flash_resource[] = {
354*c79ed194SVladimir Ananiev 	[0] = {
355*c79ed194SVladimir Ananiev 		.start	= OMAP_CS0_PHYS,	/* Physical */
356*c79ed194SVladimir Ananiev 		.end	= OMAP_CS0_PHYS + SZ_16M - 1,,
357*c79ed194SVladimir Ananiev 		.flags	= IORESOURCE_MEM,
358*c79ed194SVladimir Ananiev 	},
359*c79ed194SVladimir Ananiev 	[1] = {
360*c79ed194SVladimir Ananiev 		.start	= OMAP_CS1_PHYS,
361*c79ed194SVladimir Ananiev 		.end	= OMAP_CS1_PHYS + SZ_8M - 1,
362*c79ed194SVladimir Ananiev 		.flags	= IORESOURCE_MEM,
363*c79ed194SVladimir Ananiev 	},
364*c79ed194SVladimir Ananiev };
365*c79ed194SVladimir Ananiev 
366*c79ed194SVladimir Ananiev static struct platform_device sx1_flash_device = {
367*c79ed194SVladimir Ananiev 	.name		= "omapflash",
368*c79ed194SVladimir Ananiev 	.id		= 0,
369*c79ed194SVladimir Ananiev 	.dev		= {
370*c79ed194SVladimir Ananiev 		.platform_data	= &sx1_flash_data,
371*c79ed194SVladimir Ananiev 	},
372*c79ed194SVladimir Ananiev 	.num_resources	= 2,
373*c79ed194SVladimir Ananiev 	.resource	= &sx1_old_flash_resource,
374*c79ed194SVladimir Ananiev };
375*c79ed194SVladimir Ananiev #else
376*c79ed194SVladimir Ananiev /* MTD Intel 4000 flash - new flashes */
377*c79ed194SVladimir Ananiev static struct resource sx1_new_flash_resource = {
378*c79ed194SVladimir Ananiev 	.start		= OMAP_CS0_PHYS,
379*c79ed194SVladimir Ananiev 	.end		= OMAP_CS0_PHYS + SZ_32M - 1,
380*c79ed194SVladimir Ananiev 	.flags		= IORESOURCE_MEM,
381*c79ed194SVladimir Ananiev };
382*c79ed194SVladimir Ananiev 
383*c79ed194SVladimir Ananiev static struct platform_device sx1_flash_device = {
384*c79ed194SVladimir Ananiev 	.name		= "omapflash",
385*c79ed194SVladimir Ananiev 	.id		= 0,
386*c79ed194SVladimir Ananiev 	.dev		= {
387*c79ed194SVladimir Ananiev 		.platform_data	= &sx1_flash_data,
388*c79ed194SVladimir Ananiev 	},
389*c79ed194SVladimir Ananiev 	.num_resources	= 1,
390*c79ed194SVladimir Ananiev 	.resource	= &sx1_new_flash_resource,
391*c79ed194SVladimir Ananiev };
392*c79ed194SVladimir Ananiev #endif
393*c79ed194SVladimir Ananiev 
394*c79ed194SVladimir Ananiev /*----------- USB -------------------------*/
395*c79ed194SVladimir Ananiev 
396*c79ed194SVladimir Ananiev static struct omap_usb_config sx1_usb_config __initdata = {
397*c79ed194SVladimir Ananiev 	.otg		= 0,
398*c79ed194SVladimir Ananiev 	.register_dev	= 1,
399*c79ed194SVladimir Ananiev 	.register_host	= 0,
400*c79ed194SVladimir Ananiev 	.hmc_mode	= 0,
401*c79ed194SVladimir Ananiev 	.pins[0]	= 2,
402*c79ed194SVladimir Ananiev 	.pins[1]	= 0,
403*c79ed194SVladimir Ananiev 	.pins[2]	= 0,
404*c79ed194SVladimir Ananiev };
405*c79ed194SVladimir Ananiev 
406*c79ed194SVladimir Ananiev /*----------- MMC -------------------------*/
407*c79ed194SVladimir Ananiev 
408*c79ed194SVladimir Ananiev static struct omap_mmc_config sx1_mmc_config __initdata = {
409*c79ed194SVladimir Ananiev 	.mmc [0] = {
410*c79ed194SVladimir Ananiev 		.enabled 	= 1,
411*c79ed194SVladimir Ananiev 		.wire4		= 0,
412*c79ed194SVladimir Ananiev 		.wp_pin		= -1,
413*c79ed194SVladimir Ananiev 		.power_pin	= -1, /* power is in Sofia */
414*c79ed194SVladimir Ananiev 		.switch_pin	= OMAP_MPUIO(3),
415*c79ed194SVladimir Ananiev 	},
416*c79ed194SVladimir Ananiev };
417*c79ed194SVladimir Ananiev 
418*c79ed194SVladimir Ananiev /*----------- LCD -------------------------*/
419*c79ed194SVladimir Ananiev 
420*c79ed194SVladimir Ananiev static struct platform_device sx1_lcd_device = {
421*c79ed194SVladimir Ananiev 	.name		= "lcd_sx1",
422*c79ed194SVladimir Ananiev 	.id		= -1,
423*c79ed194SVladimir Ananiev };
424*c79ed194SVladimir Ananiev 
425*c79ed194SVladimir Ananiev static struct omap_lcd_config sx1_lcd_config __initdata = {
426*c79ed194SVladimir Ananiev 	.ctrl_name	= "internal",
427*c79ed194SVladimir Ananiev };
428*c79ed194SVladimir Ananiev 
429*c79ed194SVladimir Ananiev /*-----------------------------------------*/
430*c79ed194SVladimir Ananiev static struct platform_device *sx1_devices[] __initdata = {
431*c79ed194SVladimir Ananiev 	&sx1_flash_device,
432*c79ed194SVladimir Ananiev 	&sx1_kp_device,
433*c79ed194SVladimir Ananiev 	&sx1_lcd_device,
434*c79ed194SVladimir Ananiev 	&sx1_mcbsp1_device,
435*c79ed194SVladimir Ananiev 	&sx1_irda_device,
436*c79ed194SVladimir Ananiev };
437*c79ed194SVladimir Ananiev /*-----------------------------------------*/
438*c79ed194SVladimir Ananiev 
439*c79ed194SVladimir Ananiev static struct omap_uart_config sx1_uart_config __initdata = {
440*c79ed194SVladimir Ananiev 	.enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
441*c79ed194SVladimir Ananiev };
442*c79ed194SVladimir Ananiev 
443*c79ed194SVladimir Ananiev static struct omap_board_config_kernel sx1_config[] = {
444*c79ed194SVladimir Ananiev 	{ OMAP_TAG_USB,	&sx1_usb_config },
445*c79ed194SVladimir Ananiev 	{ OMAP_TAG_MMC,	&sx1_mmc_config },
446*c79ed194SVladimir Ananiev 	{ OMAP_TAG_LCD,	&sx1_lcd_config },
447*c79ed194SVladimir Ananiev 	{ OMAP_TAG_UART,	&sx1_uart_config },
448*c79ed194SVladimir Ananiev };
449*c79ed194SVladimir Ananiev /*-----------------------------------------*/
450*c79ed194SVladimir Ananiev static void __init omap_sx1_init(void)
451*c79ed194SVladimir Ananiev {
452*c79ed194SVladimir Ananiev 	platform_add_devices(sx1_devices, ARRAY_SIZE(sx1_devices));
453*c79ed194SVladimir Ananiev 
454*c79ed194SVladimir Ananiev 	omap_board_config = sx1_config;
455*c79ed194SVladimir Ananiev 	omap_board_config_size = ARRAY_SIZE(sx1_config);
456*c79ed194SVladimir Ananiev 	omap_serial_init();
457*c79ed194SVladimir Ananiev 
458*c79ed194SVladimir Ananiev 	/* turn on USB power */
459*c79ed194SVladimir Ananiev 	/* sx1_setusbpower(1); cant do it here because i2c is not ready */
460*c79ed194SVladimir Ananiev 	omap_request_gpio(1);	/* A_IRDA_OFF */
461*c79ed194SVladimir Ananiev 	omap_request_gpio(11);	/* A_SWITCH */
462*c79ed194SVladimir Ananiev 	omap_request_gpio(15);	/* A_USB_ON */
463*c79ed194SVladimir Ananiev 	omap_set_gpio_direction(1, 0);/* gpio1 -> output */
464*c79ed194SVladimir Ananiev 	omap_set_gpio_direction(11, 0);/* gpio11 -> output */
465*c79ed194SVladimir Ananiev 	omap_set_gpio_direction(15, 0);/* gpio15 -> output */
466*c79ed194SVladimir Ananiev 	/* set GPIO data */
467*c79ed194SVladimir Ananiev 	omap_set_gpio_dataout(1, 1);/*A_IRDA_OFF = 1 */
468*c79ed194SVladimir Ananiev 	omap_set_gpio_dataout(11, 0);/*A_SWITCH = 0 */
469*c79ed194SVladimir Ananiev 	omap_set_gpio_dataout(15, 0);/*A_USB_ON = 0 */
470*c79ed194SVladimir Ananiev 
471*c79ed194SVladimir Ananiev }
472*c79ed194SVladimir Ananiev /*----------------------------------------*/
473*c79ed194SVladimir Ananiev static void __init omap_sx1_init_irq(void)
474*c79ed194SVladimir Ananiev {
475*c79ed194SVladimir Ananiev 	omap1_init_common_hw();
476*c79ed194SVladimir Ananiev 	omap_init_irq();
477*c79ed194SVladimir Ananiev 	omap_gpio_init();
478*c79ed194SVladimir Ananiev }
479*c79ed194SVladimir Ananiev /*----------------------------------------*/
480*c79ed194SVladimir Ananiev 
481*c79ed194SVladimir Ananiev static void __init omap_sx1_map_io(void)
482*c79ed194SVladimir Ananiev {
483*c79ed194SVladimir Ananiev 	omap1_map_common_io();
484*c79ed194SVladimir Ananiev }
485*c79ed194SVladimir Ananiev 
486*c79ed194SVladimir Ananiev MACHINE_START(SX1, "OMAP310 based Siemens SX1")
487*c79ed194SVladimir Ananiev 	.phys_io	= 0xfff00000,
488*c79ed194SVladimir Ananiev 	.io_pg_offst	= ((0xfef00000) >> 18) & 0xfffc,
489*c79ed194SVladimir Ananiev 	.boot_params	= 0x10000100,
490*c79ed194SVladimir Ananiev 	.map_io		= omap_sx1_map_io,
491*c79ed194SVladimir Ananiev 	.init_irq		= omap_sx1_init_irq,
492*c79ed194SVladimir Ananiev 	.init_machine	= omap_sx1_init,
493*c79ed194SVladimir Ananiev 	.timer		= &omap_timer,
494*c79ed194SVladimir Ananiev MACHINE_END
495