aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/mach-mx5/board-mx53_smd.c
blob: 18bca4f1073c2738da75da975c40a748afee31d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
/*
 * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
 */

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <linux/init.h>
#include <linux/clk.h>
#include <linux/fec.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/i2c/mpr.h>
#include <linux/fsl_devices.h>
#include <linux/ahci_platform.h>
#include <linux/regulator/consumer.h>

#include <linux/pwm_backlight.h>
#include <linux/mxcfb.h>
#include <linux/ipu.h>

#include <mach/common.h>
#include <mach/hardware.h>
#include <mach/ipu-v3.h>
#include <mach/imx-uart.h>
#include <mach/iomux-mx53.h>
#include <mach/ahci_sata.h>
#include <mach/imx_rfkill.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/mach/time.h>

#include "crm_regs.h"
#include "devices-imx53.h"
#include "devices.h"
#include "usb.h"


#define SMD_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
#define MX53_SMD_SD1_CD         IMX_GPIO_NR(3, 13)
#define MX53_SMD_SD1_WP         IMX_GPIO_NR(4, 11)
#define MX53_SMD_HDMI_RESET_B   IMX_GPIO_NR(5, 0)
#define MX53_SMD_MODEM_RESET_B  IMX_GPIO_NR(5, 2)
#define MX53_SMD_KEY_INT	IMX_GPIO_NR(5, 4)
#define MX53_SMD_HDMI_INT	IMX_GPIO_NR(6, 12)
#define MX53_SMD_CAP_TCH_INT1	IMX_GPIO_NR(3, 20)
#define MX53_SMD_SATA_PWR_EN	IMX_GPIO_NR(3, 3)
#define MX53_SMD_OTG_VBUS	IMX_GPIO_NR(7, 8)
#define MX53_SMD_NONKEY		IMX_GPIO_NR(1, 8)
#define MX53_SMD_UI1		IMX_GPIO_NR(2, 14)
#define MX53_SMD_UI2		IMX_GPIO_NR(2, 15)
#define MX53_SMD_HEADPHONE_DEC	IMX_GPIO_NR(2, 5)
#define MX53_SMD_OSC_CKIH1_EN	IMX_GPIO_NR(6, 11)
#define MX53_SMD_DCDC1V8_EN	IMX_GPIO_NR(3, 1)
#define MX53_SMD_DCDC5V_BB_EN	IMX_GPIO_NR(4, 14)
#define MX53_SMD_ALS_INT 	IMX_GPIO_NR(3, 22)
#define MX53_SMD_BT_RESET	IMX_GPIO_NR(3, 28)

extern int mx53_smd_init_da9052(void);

static iomux_v3_cfg_t mx53_smd_pads[] = {
	MX53_PAD_CSI0_DAT10__UART1_TXD_MUX,
	MX53_PAD_CSI0_DAT11__UART1_RXD_MUX,

	MX53_PAD_PATA_BUFFER_EN__UART2_RXD_MUX,
	MX53_PAD_PATA_DMARQ__UART2_TXD_MUX,

	MX53_PAD_PATA_CS_0__UART3_TXD_MUX,
	MX53_PAD_PATA_CS_1__UART3_RXD_MUX,
	MX53_PAD_PATA_DA_1__UART3_CTS,
	MX53_PAD_PATA_DA_2__UART3_RTS,
	/* I2C1 */
	MX53_PAD_CSI0_DAT8__I2C1_SDA,
	MX53_PAD_CSI0_DAT9__I2C1_SCL,
	/* I2C2 */
	MX53_PAD_KEY_COL3__I2C2_SCL,
	MX53_PAD_KEY_ROW3__I2C2_SDA,
	/* I2C3 */
	MX53_PAD_GPIO_3__I2C3_SCL,
	MX53_PAD_GPIO_6__I2C3_SDA,

	/* SD1 */
	MX53_PAD_SD1_CMD__ESDHC1_CMD,
	MX53_PAD_SD1_CLK__ESDHC1_CLK,
	MX53_PAD_SD1_DATA0__ESDHC1_DAT0,
	MX53_PAD_SD1_DATA1__ESDHC1_DAT1,
	MX53_PAD_SD1_DATA2__ESDHC1_DAT2,
	MX53_PAD_SD1_DATA3__ESDHC1_DAT3,
	/* SD1_CD */
	MX53_PAD_EIM_DA13__GPIO3_13,
	/* SD1_WP */
	MX53_PAD_KEY_ROW2__GPIO4_11,

	/* SD2 */
	MX53_PAD_SD2_CMD__ESDHC2_CMD,
	MX53_PAD_SD2_CLK__ESDHC2_CLK,
	MX53_PAD_SD2_DATA0__ESDHC2_DAT0,
	MX53_PAD_SD2_DATA1__ESDHC2_DAT1,
	MX53_PAD_SD2_DATA2__ESDHC2_DAT2,
	MX53_PAD_SD2_DATA3__ESDHC2_DAT3,

	/* SD3 */
	MX53_PAD_PATA_DATA8__ESDHC3_DAT0,
	MX53_PAD_PATA_DATA9__ESDHC3_DAT1,
	MX53_PAD_PATA_DATA10__ESDHC3_DAT2,
	MX53_PAD_PATA_DATA11__ESDHC3_DAT3,
	MX53_PAD_PATA_DATA0__ESDHC3_DAT4,
	MX53_PAD_PATA_DATA1__ESDHC3_DAT5,
	MX53_PAD_PATA_DATA2__ESDHC3_DAT6,
	MX53_PAD_PATA_DATA3__ESDHC3_DAT7,
	MX53_PAD_PATA_IORDY__ESDHC3_CLK,
	MX53_PAD_PATA_RESET_B__ESDHC3_CMD,

	/* SATA_PWR_EN */
	MX53_PAD_EIM_DA3__GPIO3_3,

	/* USB_OTG_OC */
	MX53_PAD_EIM_DA12__GPIO3_12,
	/* USB_HUB_RESET_B */
	MX53_PAD_EIM_DA14__GPIO3_14,
	/* USB_OTG_PWR_EN */
	MX53_PAD_PATA_DA_2__GPIO7_8,

	/* OSC_CKIH1_EN, for audio codec clk */
	MX53_PAD_NANDF_CS0__GPIO6_11,

	/* AUDMUX3 */
	MX53_PAD_CSI0_DAT4__AUDMUX_AUD3_TXC,
	MX53_PAD_CSI0_DAT5__AUDMUX_AUD3_TXD,
	MX53_PAD_CSI0_DAT6__AUDMUX_AUD3_TXFS,
	MX53_PAD_CSI0_DAT7__AUDMUX_AUD3_RXD,

	/* AUDMUX5 */
	MX53_PAD_KEY_COL0__AUDMUX_AUD5_TXC,
	MX53_PAD_KEY_ROW0__AUDMUX_AUD5_TXD,
	MX53_PAD_KEY_COL1__AUDMUX_AUD5_TXFS,
	MX53_PAD_KEY_ROW1__AUDMUX_AUD5_RXD,

	/* AUD_AMP_STBY_B */
	MX53_PAD_EIM_DA2__GPIO3_2,

	/* DCDC1V8_EN */
	MX53_PAD_EIM_DA1__GPIO3_1,
	/* DCDC5V_BB_EN */
	MX53_PAD_KEY_COL4__GPIO4_14,
	/* PWM */
	MX53_PAD_GPIO_1__PWM2_PWMO,

	/* LDVS */
	MX53_PAD_LVDS0_TX3_P__LDB_LVDS0_TX3,
	MX53_PAD_LVDS0_CLK_P__LDB_LVDS0_CLK,
	MX53_PAD_LVDS0_TX2_P__LDB_LVDS0_TX2,
	MX53_PAD_LVDS0_TX1_P__LDB_LVDS0_TX1,
	MX53_PAD_LVDS0_TX0_P__LDB_LVDS0_TX0,
	MX53_PAD_LVDS1_TX3_P__LDB_LVDS1_TX3,
	MX53_PAD_LVDS1_TX2_P__LDB_LVDS1_TX2,
	MX53_PAD_LVDS1_CLK_P__LDB_LVDS1_CLK,
	MX53_PAD_LVDS1_TX1_P__LDB_LVDS1_TX1,
	MX53_PAD_LVDS1_TX0_P__LDB_LVDS1_TX0,
};

#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
#define GPIO_BUTTON(gpio_num, ev_code, act_low, descr, wake)    \
{                                                               \
	.gpio           = gpio_num,                             \
	.type           = EV_KEY,                               \
	.code           = ev_code,                              \
	.active_low     = act_low,                              \
	.desc           = "btn " descr,                         \
	.wakeup         = wake,                                 \
}

static struct gpio_keys_button smd_buttons[] = {
	GPIO_BUTTON(MX53_SMD_NONKEY, KEY_POWER, 1, "power", 0),
	GPIO_BUTTON(MX53_SMD_UI1, KEY_VOLUMEUP, 1, "volume-up", 0),
	GPIO_BUTTON(MX53_SMD_UI2, KEY_VOLUMEDOWN, 1, "volume-down", 0),
};

static struct gpio_keys_platform_data smd_button_data = {
	.buttons        = smd_buttons,
	.nbuttons       = ARRAY_SIZE(smd_buttons),
};

static struct platform_device smd_button_device = {
	.name           = "gpio-keys",
	.id             = -1,
	.num_resources  = 0,
	.dev            = {
		.platform_data = &smd_button_data,
		}
};

static void __init smd_add_device_buttons(void)
{
	platform_device_register(&smd_button_device);
}
#else
static void __init smd_add_device_buttons(void) {}
#endif

static const struct imxuart_platform_data mx53_smd_uart_data __initconst = {
	.flags = IMXUART_HAVE_RTSCTS,
};

static inline void mx53_smd_init_uart(void)
{
	imx53_add_imx_uart(0, NULL);
	imx53_add_imx_uart(1, NULL);
	imx53_add_imx_uart(2, &mx53_smd_uart_data);
}

static inline void mx53_smd_fec_reset(void)
{
	int ret;

	/* reset FEC PHY */
	ret = gpio_request(SMD_FEC_PHY_RST, "fec-phy-reset");
	if (ret) {
		printk(KERN_ERR"failed to get GPIO_FEC_PHY_RESET: %d\n", ret);
		return;
	}
	gpio_direction_output(SMD_FEC_PHY_RST, 0);
	msleep(1);
	gpio_set_value(SMD_FEC_PHY_RST, 1);
}

static struct fec_platform_data mx53_smd_fec_data = {
	.phy = PHY_INTERFACE_MODE_RMII,
};

static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = {
	.bitrate = 100000,
};

static void smd_suspend_enter(void)
{
	/* da9053 suspend preparation */
}

static void smd_suspend_exit(void)
{
	/*clear the EMPGC0/1 bits */
	__raw_writel(0, MXC_SRPG_EMPGC0_SRPGCR);
	__raw_writel(0, MXC_SRPG_EMPGC1_SRPGCR);
	/* da9053 resmue resore */
}

static struct mxc_pm_platform_data smd_pm_data = {
	.suspend_enter = smd_suspend_enter,
	.suspend_exit = smd_suspend_exit,
};


static const struct esdhc_platform_data mx53_smd_sd1_data __initconst = {
	.cd_gpio = MX53_SMD_SD1_CD,
	.wp_gpio = MX53_SMD_SD1_WP,
};

static const struct esdhc_platform_data mx53_smd_sd2_data __initconst = {
	.always_present = 1,
};

static const struct esdhc_platform_data mx53_smd_sd3_data __initconst = {
	.always_present = 1,
};

static struct fsl_mxc_camera_platform_data camera_data = {
	.analog_regulator = "DA9052_LDO7",
	.core_regulator = "DA9052_LDO9",
	.mclk = 24000000,
	.csi = 0,
};

static struct fsl_mxc_lightsensor_platform_data ls_data = {
	.rext = 700,    /* calibration: 499K->700K */
};

static struct i2c_board_info mxc_i2c0_board_info[] __initdata = {
	{
	.type = "mma8451",
	.addr = 0x1C,
	},
	{
	.type = "ov3640",
	.addr = 0x3C,
	.platform_data = (void *)&camera_data,
	},

};

static u16 smd_touchkey_martix[4] = {
	KEY_BACK, KEY_HOME, KEY_MENU, KEY_SEARCH,
};

static struct mpr121_platform_data mpr121_keyboard_platdata = {
	.keycount = ARRAY_SIZE(smd_touchkey_martix),
	.vdd_uv = 3300000,
	.matrix = smd_touchkey_martix,
};

static struct i2c_board_info mxc_i2c1_board_info[] __initdata = {
	{
	.type = "sgtl5000",
	.addr = 0x0a,
	},
	{
	.type = "mpr121_touchkey",
	.addr = 0x5a,
	.irq = gpio_to_irq(MX53_SMD_KEY_INT),
	.platform_data = &mpr121_keyboard_platdata,
	},
};

static void mxc_iim_enable_fuse(void)
{
	u32 reg;
	if (!ccm_base)
		return;
	/* enable fuse blown */
	reg = readl(ccm_base + 0x64);
	reg |= 0x10;
	writel(reg, ccm_base + 0x64);
}

static void mxc_iim_disable_fuse(void)
{
	u32 reg;
	if (!ccm_base)
		return;
	/* enable fuse blown */
	reg = readl(ccm_base + 0x64);
	reg &= ~0x10;
	writel(reg, ccm_base + 0x64);
}


static struct mxc_iim_platform_data iim_data = {
	.bank_start = MXC_IIM_MX53_BANK_START_ADDR,
	.bank_end   = MXC_IIM_MX53_BANK_END_ADDR,
	.enable_fuse = mxc_iim_enable_fuse,
	.disable_fuse = mxc_iim_disable_fuse,
};


static void sii9022_hdmi_reset(void)
{
	gpio_set_value(MX53_SMD_HDMI_RESET_B, 0);
	msleep(10);
	gpio_set_value(MX53_SMD_HDMI_RESET_B, 1);
	msleep(10);
}

static struct fsl_mxc_lcd_platform_data sii902x_hdmi_data = {
	.reset = sii9022_hdmi_reset,
	.analog_reg = "DA9052_LDO2",
	.boot_enable = 1,
};

static struct i2c_board_info mxc_i2c2_board_info[] __initdata = {
	{
	.type = "sii902x",
	.addr = 0x39,
	.irq = gpio_to_irq(MX53_SMD_HDMI_INT),
	.platform_data = &sii902x_hdmi_data,
	},
	{
		I2C_BOARD_INFO("p1003_ts", 0x41),
		.irq = gpio_to_irq(MX53_SMD_CAP_TCH_INT1),
	},
	{
	.type = "isl29023",
	.addr = 0x44,
	.irq  = gpio_to_irq(MX53_SMD_ALS_INT),
	.platform_data = &ls_data,
	},

};

/* HW Initialization, if return 0, initialization is successful. */
static int sata_init(struct device *dev, void __iomem *addr)
{
	void __iomem *mmio;
	struct clk *clk;
	int ret = 0;
	u32 tmpdata;

	/* Enable SATA PWR  */
	ret = gpio_request(MX53_SMD_SATA_PWR_EN, "ahci-sata-pwr");
	if (ret) {
		printk(KERN_ERR "failed to get SATA_PWR_EN: %d\n", ret);
		return ret;
	}
	gpio_direction_output(MX53_SMD_SATA_PWR_EN, 1);

	clk = clk_get(dev, "imx_sata_clk");
	ret = IS_ERR(clk);
	if (ret) {
		printk(KERN_ERR "AHCI can't get clock.\n");
		return ret;
	}
	ret = clk_enable(clk);
	if (ret) {
		printk(KERN_ERR "AHCI can't enable clock.\n");
		clk_put(clk);
		return ret;
	}

	/* Get the AHB clock rate, and configure the TIMER1MS reg later */
	clk = clk_get(NULL, "ahb_clk");
	ret = IS_ERR(clk);
	if (ret) {
		printk(KERN_ERR "AHCI can't get AHB clock.\n");
		goto no_ahb_clk;
	}

	mmio = ioremap(MX53_SATA_BASE_ADDR, SZ_2K);
	if (mmio == NULL) {
		printk(KERN_ERR "Failed to map SATA REGS\n");
		goto no_ahb_clk;
	}

	tmpdata = readl(mmio + HOST_CAP);
	if (!(tmpdata & HOST_CAP_SSS)) {
		tmpdata |= HOST_CAP_SSS;
		writel(tmpdata, mmio + HOST_CAP);
	}

	if (!(readl(mmio + HOST_PORTS_IMPL) & 0x1))
		writel((readl(mmio + HOST_PORTS_IMPL) | 0x1),
			mmio + HOST_PORTS_IMPL);

	tmpdata = clk_get_rate(clk) / 1000;
	writel(tmpdata, mmio + HOST_TIMER1MS);

	clk = clk_get(dev, "usb_phy1_clk");
	ret = IS_ERR(clk);
	if (ret) {
		printk(KERN_ERR "AHCI can't get USB PHY1 CLK.\n");
		goto no_ahb_clk;
	}
	ret = clk_enable(clk);
	if (ret) {
		printk(KERN_ERR "AHCI Can't enable USB PHY1 clock.\n");
		clk_put(clk);
		goto no_ahb_clk;
	}

	/* Release resources when there is no device on the port */
	if ((readl(mmio + PORT_SATA_SR) & 0xF) == 0) {
		iounmap(mmio);
		ret = -ENODEV;
		goto no_device;
	}

	iounmap(mmio);

	return ret;

no_device:
	printk(KERN_INFO "NO SATA device is found, relase resource!\n");
	clk = clk_get(dev, "usb_phy1_clk");
	if (IS_ERR(clk)) {
		clk = NULL;
		printk(KERN_ERR "AHCI can't get USB PHY1 CLK.\n");
	} else {
		clk_disable(clk);
		clk_put(clk);
	}

no_ahb_clk:
	clk = clk_get(dev, "imx_sata_clk");
	if (IS_ERR(clk)) {
		clk = NULL;
		printk(KERN_ERR "IMX SATA can't get clock.\n");
	} else {
		clk_disable(clk);
		clk_put(clk);
	}

	return ret;
}

static void sata_exit(struct device *dev)
{
	struct clk *clk;

	clk = clk_get(dev, "usb_phy1_clk");
	if (IS_ERR(clk)) {
		clk = NULL;
		printk(KERN_ERR "AHCI can't get USB PHY1 CLK.\n");
	} else {
		clk_disable(clk);
		clk_put(clk);
	}

	clk = clk_get(dev, "imx_sata_clk");
	if (IS_ERR(clk)) {
		clk = NULL;
		printk(KERN_ERR "IMX SATA can't get clock.\n");
	} else {
		clk_disable(clk);
		clk_put(clk);
	}
}

static struct ahci_platform_data sata_data = {
	.init = sata_init,
	.exit = sata_exit,
};

static void mx53_smd_usbotg_vbus(bool on)
{
	if (on)
		gpio_set_value(MX53_SMD_OTG_VBUS, 1);
	else
		gpio_set_value(MX53_SMD_OTG_VBUS, 0);
}

static void __init mx53_smd_init_usb(void)
{
	int ret = 0;

	imx_otg_base = MX53_IO_ADDRESS(MX53_OTG_BASE_ADDR);
	ret = gpio_request(MX53_SMD_OTG_VBUS, "usb-pwr");
	if (ret) {
		printk(KERN_ERR"failed to get GPIO SMD_OTG_VBUS: %d\n", ret);
		return;
	}
	gpio_direction_output(MX53_SMD_OTG_VBUS, 0);

	mx5_set_otghost_vbus_func(mx53_smd_usbotg_vbus);
	mx5_usb_dr_init();
	mx5_usbh1_init();
}

static void mx53_smd_bt_reset(void)
{
	gpio_request(MX53_SMD_BT_RESET, "bt-reset");
	gpio_direction_output(MX53_SMD_BT_RESET, 0);
	/* pull down reset pin at least >5ms */
	mdelay(6);
	/* pull up after power supply BT */
	gpio_set_value(MX53_SMD_BT_RESET, 1);
	gpio_free(MX53_SMD_BT_RESET);
	msleep(100);
	/* Bluetooth need some time to reset */
}

static int mx53_smd_bt_power_change(int status)
{
	struct regulator *wifi_bt_pwren;

	wifi_bt_pwren = regulator_get(NULL, "wifi_bt");
	if (IS_ERR(wifi_bt_pwren)) {
		printk(KERN_ERR "%s: regulator_get error\n", __func__);
		return -1;
	}

	if (status) {
		regulator_enable(wifi_bt_pwren);
		mx53_smd_bt_reset();
	} else
		regulator_disable(wifi_bt_pwren);

	return 0;
}

static struct platform_device imx_bt_rfkill = {
	.name = "imx_bt_rfkill",
};

static struct imx_bt_rfkill_platform_data imx_bt_rfkill_data = {
	.power_change = mx53_smd_bt_power_change,
};

static struct mxc_audio_platform_data smd_audio_data;

static int smd_sgtl5000_init(void)
{
	smd_audio_data.sysclk = 22579200;

	/* Enable OSC_CKIH1_EN for audio */
	gpio_request(MX53_SMD_OSC_CKIH1_EN, "osc-en");
	gpio_direction_output(MX53_SMD_OSC_CKIH1_EN, 1);
	return 0;
}

static struct mxc_audio_platform_data smd_audio_data = {
	.ssi_num = 1,
	.src_port = 2,
	.ext_port = 5,
	.init = smd_sgtl5000_init,
	.hp_gpio = MX53_SMD_HEADPHONE_DEC,
	.hp_active_low = 1,
};

static struct platform_device smd_audio_device = {
	.name = "imx-sgtl5000",
};

static struct imx_ssi_platform_data smd_ssi_pdata = {
	.flags = IMX_SSI_DMA,
};

static struct fb_videomode video_modes[] = {
	{
	/* 800x480 @ 57 Hz , pixel clk @ 27MHz */
	"CLAA-WVGA", 57, 800, 480, 37037, 40, 60, 10, 10, 20, 10,
	FB_SYNC_CLK_LAT_FALL,
	FB_VMODE_NONINTERLACED,
	0,},
	{
	/* 800x480 @ 60 Hz , pixel clk @ 32MHz */
	"SEIKO-WVGA", 60, 800, 480, 29850, 89, 164, 23, 10, 10, 10,
	FB_SYNC_CLK_LAT_FALL,
	FB_VMODE_NONINTERLACED,
	0,},
	{
	/* 1600x1200 @ 60 Hz 162M pixel clk*/
	"UXGA", 60, 1600, 1200, 6172,
	304, 64,
	1, 46,
	192, 3,
	FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
	FB_VMODE_NONINTERLACED,
	0,},
};

static struct ipuv3_fb_platform_data smd_fb_di0_data = {
	.interface_pix_fmt = IPU_PIX_FMT_RGB24,
	.mode_str = "1024x768M-16@60",
	.modes = video_modes,
	.num_modes = ARRAY_SIZE(video_modes),
};

static struct ipuv3_fb_platform_data smd_fb_di1_data = {
	.interface_pix_fmt = IPU_PIX_FMT_RGB666,
	.mode_str = "XGA",
	.modes = video_modes,
	.num_modes = ARRAY_SIZE(video_modes),
};

static struct imx_ipuv3_platform_data ipu_data = {
	.rev = 3,
	.fb_head0_platform_data = &smd_fb_di0_data,
	.fb_head1_platform_data = &smd_fb_di1_data,
	.primary_di = MXC_PRI_DI1,
};

static struct platform_pwm_backlight_data mxc_pwm_backlight_data = {
	.pwm_id = 1,
	.max_brightness = 255,
	.dft_brightness = 128,
	.pwm_period_ns = 50000,
};

static struct fsl_mxc_ldb_platform_data ldb_data = {
	.ext_ref = 1,
	.boot_enable = MXC_LDBDI1,
};

static void __init mx53_smd_board_init(void)
{
	mxc_iomux_v3_setup_multiple_pads(mx53_smd_pads,
					ARRAY_SIZE(mx53_smd_pads));
	mx53_smd_init_uart();
	mx53_smd_fec_reset();
	mxc_register_device(&mxc_pm_device, &smd_pm_data);
	imx53_add_fec(&mx53_smd_fec_data);
	imx53_add_imx2_wdt(0, NULL);
	imx53_add_srtc();
	imx53_add_imx_i2c(0, &mx53_smd_i2c_data);
	imx53_add_imx_i2c(1, &mx53_smd_i2c_data);
	imx53_add_imx_i2c(2, &mx53_smd_i2c_data);

	imx53_add_ipuv3(&ipu_data);
	imx53_add_vpu();
	imx53_add_ldb(&ldb_data);
	imx53_add_v4l2_output(0);
	imx53_add_mxc_pwm(1);
	imx53_add_mxc_pwm_backlight(0, &mxc_pwm_backlight_data);
	imx53_add_sdhci_esdhc_imx(0, &mx53_smd_sd1_data);
	imx53_add_sdhci_esdhc_imx(1, &mx53_smd_sd2_data);
	imx53_add_sdhci_esdhc_imx(2, &mx53_smd_sd3_data);
	imx53_add_ahci_imx(0, &sata_data);

	mx53_smd_init_usb();
	imx53_add_iim(&iim_data);
	smd_add_device_buttons();

	mx53_smd_init_da9052();
	i2c_register_board_info(0, mxc_i2c0_board_info,
				ARRAY_SIZE(mxc_i2c0_board_info));
	i2c_register_board_info(1, mxc_i2c1_board_info,
				ARRAY_SIZE(mxc_i2c1_board_info));
	i2c_register_board_info(2, mxc_i2c2_board_info,
				ARRAY_SIZE(mxc_i2c2_board_info));


	gpio_request(MX53_SMD_DCDC1V8_EN, "dcdc1v8-en");
	gpio_direction_output(MX53_SMD_DCDC1V8_EN, 1);

	/* ambient light sensor */
	gpio_request(MX53_SMD_ALS_INT, "als int");
	gpio_direction_input(MX53_SMD_ALS_INT);

	mxc_register_device(&smd_audio_device, &smd_audio_data);
	mxc_register_device(&imx_bt_rfkill, &imx_bt_rfkill_data);
	imx53_add_imx_ssi(1, &smd_ssi_pdata);

	/* this call required to release SCC RAM partition held by ROM
	  * during boot, even if SCC2 driver is not part of the image
	  */
	imx53_add_mxc_scc2();
}

static void __init mx53_smd_timer_init(void)
{
	mx53_clocks_init(32768, 24000000, 22579200, 0);
}

static struct sys_timer mx53_smd_timer = {
	.init	= mx53_smd_timer_init,
};

MACHINE_START(MX53_SMD, "Freescale MX53 SMD Board")
	.map_io = mx53_map_io,
	.init_early = imx53_init_early,
	.init_irq = mx53_init_irq,
	.timer = &mx53_smd_timer,
	.init_machine = mx53_smd_board_init,
MACHINE_END