forked from nemomobile/kernel-adaptation-n950-n9
-
Notifications
You must be signed in to change notification settings - Fork 5
/
board-rm680.c
3030 lines (2581 loc) · 72.3 KB
/
board-rm680.c
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
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Board support file for Nokia RM-680/696.
*
* Copyright (C) 2010 Nokia
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/io.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <plat/mux.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/i2c/twl.h>
#include <linux/input/atmel_mxt.h>
#include <linux/input/eci.h>
#include <linux/platform_device.h>
#include <linux/omapfb.h>
#include <linux/opp.h>
#include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/consumer.h>
#include <linux/wl12xx.h>
#include <linux/spi/spi.h>
#include <linux/spi/vibra.h>
#include <linux/cpu.h>
#include <linux/opp.h>
#include <linux/hsi/hsi.h>
#include <linux/cmt.h>
#include <linux/lis3lv02d.h>
#include <linux/leds-lp5521.h> //RM696
#include <linux/leds-lp5523.h> //RM680
#include <linux/usb/musb.h>
#include <linux/mfd/wl1273-core.h>
#include <linux/mfd/aci.h>
#include <sound/tpa6130a2-plat.h>
#include <sound/tlv320dac33-plat.h>
//ALS / PS
#include <linux/i2c/apds990x.h> //RM696
#include <linux/i2c/bhsfh.h> //RM680
//MAGNETOMETERS
#include <linux/i2c/ak8975.h> //RM696
#include <linux/i2c/ak8974.h> //RM680
//NFC
#include <linux/nfc/pn544.h> //RM696
#include <linux/i2c/bcm4751-gps.h>
#include <asm/mach/arch.h>
#include <asm/mach-types.h>
#include <asm/system_info.h>
#include <plat/i2c.h>
#include <plat/mmc.h>
#include <plat/usb.h>
#include <plat/gpmc.h>
#include "common.h"
#include <plat/onenand.h>
#include <plat/display.h>
#include <plat/panel-nokia-dsi.h>
#include <plat/vram.h>
#include <plat/board-nokia.h>
#include <plat/omap-pm.h>
#include <linux/pvr.h>
#include <linux/printk.h>
#include <plat/mcspi.h>
#include <plat/omap_device.h>
#include <plat/ssi.h>
#include "mux.h"
#include "hsmmc.h"
#include "sdram-nokia.h"
#include "common-board-devices.h"
#include "atmel_mxt_config.h"
#include "pm.h"
#include "dss.h"
#if defined(CONFIG_SND_OMAP_SOC_DFL61_TWL4030) || \
defined(CONFIG_SND_OMAP_SOC_DFL61_TWL4030_MODULE)
#include <plat/dfl61-audio.h>
#include <linux/mfd/twl4030-audio.h>
#endif
#include <media/v4l2-subdev.h>
#include "../../../drivers/media/video/omap3isp/isp.h"
#include "../../../drivers/media/video/omap3isp/ispreg.h"
#include "../../../drivers/media/video/omap3isp/ispcsi2.h"
#include <media/smiapp.h>
#include <plat/control.h>
#include <media/ad58xx.h>
#include <media/as3645a.h> /* Senna Flash driver */
#include "devices.h"
#define ATMEL_MXT_IRQ_GPIO 61
#define ATMEL_MXT_RESET_GPIO 81
#define LIS302_IRQ1_GPIO 180
#define LIS302_IRQ2_GPIO 181
#define RM696_FM_RESET_GPIO1 179
#define RM696_FM_RESET_GPIO2 178
#define RM696_FMRX_IRQ_GPIO 43
#define NFC_HOST_INT_GPIO 76
#define NFC_ENABLE_GPIO 77
#define NFC_FW_RESET_GPIO 78
#define RM696_DAC33_RESET_GPIO 60 //same for RM680
#define RM696_DAC33_IRQ_GPIO 53 //same for RM680
#define RM696_VIBRA_POWER_GPIO 182
#define RM696_VIBRA_POWER_UP_TIME 1000 /* usecs */
#define RM696_TVOUT_EN_GPIO 40
#define RM696_JACK_GPIO (OMAP_MAX_GPIO_LINES + 0)
#define RM696_LP5521_CHIP_EN_GPIO 41 //RM696
#define RM680_LP5523_CHIP_EN_GPIO 41 //RM680
#define APDS990X_GPIO 83 //RM696
#define BHSFH_GPIO 83 //RM680
#define RM696_BCM4751_GPS_IRQ_GPIO 95
#define RM696_BCM4751_GPS_ENABLE_GPIO 94
#define RM696_BCM4751_GPS_WAKEUP_GPIO 91
#define SEC_CAMERA_RESET_GPIO 97
#define RM696_PRI_SENSOR 1
#define RM696_PRI_LENS 2
#define RM696_SEC_SENSOR 3
#define MAIN_CAMERA_XCLK ISP_XCLK_A
#define SEC_CAMERA_XCLK ISP_XCLK_B
static uint32_t rm696_keymap[] = {
/* row, col, event */
KEY(6, 8, KEY_VOLUMEUP),
KEY(7, 8, KEY_VOLUMEDOWN),
};
static struct matrix_keymap_data rm696_keymap_data = {
.keymap = rm696_keymap,
.keymap_size = ARRAY_SIZE(rm696_keymap),
};
static struct twl4030_keypad_data rm696_kp_data = {
.keymap_data = &rm696_keymap_data,
.rows = 8, /* Two last rows are used */
.cols = 8,
.rep = 1,
};
/* CMT init data */
static struct cmt_platform_data rm696_cmt_pdata = {
.cmt_rst_ind_gpio = 34,
.cmt_rst_ind_flags = IRQF_TRIGGER_RISING,
};
static struct platform_device rm696_cmt_device = {
.name = "cmt",
.id = -1,
.dev = {
.platform_data = &rm696_cmt_pdata,
},
};
static struct eci_platform_data rm696_eci_platform_data = {
#if defined(CONFIG_SND_OMAP_SOC_DFL61_TWL4030) || \
defined(CONFIG_SND_OMAP_SOC_DFL61_TWL4030_MODULE)
.register_hsmic_event_cb = dfl61_register_hsmic_event_cb,
.jack_report = dfl61_jack_report,
#endif
};
static struct platform_device rm696_eci_device = {
.name = "ECI_accessory",
.dev = {
.platform_data = &rm696_eci_platform_data,
},
};
/* SSI init data */
static struct omap_ssi_port_config __initdata rm696_ssi_port_config[] = {
[0] = {
.cawake_gpio = 151,
.ready_rx_gpio = 154,
},
};
static struct omap_ssi_board_config __initdata rm696_ssi_config = {
.num_ports = ARRAY_SIZE(rm696_ssi_port_config),
.port_config = rm696_ssi_port_config,
};
static struct hsi_board_info __initdata rm696_ssi_cl[] = {
[0] = {
.name = "hsi_char",
.hsi_id = 0,
.port = 0,
},
[1] = {
.name = "ssi_protocol",
.hsi_id = 0,
.port = 0,
.tx_cfg = {
.mode = HSI_MODE_FRAME,
.channels = 4,
.speed = 96000,
.arb_mode = HSI_ARB_RR,
},
.rx_cfg = {
.mode = HSI_MODE_FRAME,
.channels = 4,
},
},
[2] = {
.name = "cmt_speech",
.hsi_id = 0,
.port = 0,
},
};
static void __init rm696_ssi_init(void)
{
omap_ssi_config(&rm696_ssi_config);
hsi_register_board_info(rm696_ssi_cl, ARRAY_SIZE(rm696_ssi_cl));
}
/* CPU table initialization */
static int __init rm696_opp_init(void)
{
int r = 0;
struct device *mpu_dev, *iva_dev;
r = omap3_opp_init();
if (IS_ERR_VALUE(r) && (r != -EEXIST)) {
pr_err("opp default init failed\n");
return r;
}
mpu_dev = omap_device_get_by_hwmod_name("mpu");
iva_dev = omap_device_get_by_hwmod_name("iva");
if (IS_ERR(mpu_dev) || IS_ERR(iva_dev)) {
pr_err("no mpu_dev/iva_dev error\n");
return -ENODEV;
}
/* Enable MPU 800MHz and lower opps */
r = opp_enable(mpu_dev, 800000000);
if (r)
pr_err("failed to enable higher (800MHz) opp\n");
/* Enable MPU 1GHz and lower opps */
r = opp_enable(mpu_dev, 1000000000);
if (r)
pr_err("failed to enable higher (1GHz) opp\n");
r = opp_enable(iva_dev, 660000000);
if (r)
pr_err("failed to enable higher (660MHz) opp on DSP\n");
r = opp_enable(iva_dev, 800000000);
if (r)
pr_err("failed to enable higher (800MHz) opp on DSP\n");
return 0;
}
device_initcall(rm696_opp_init);
/* WL1271 SDIO/SPI */
#define RM696_WL1271_POWER_GPIO 35
#define RM696_WL1271_IRQ_GPIO 42
#define RM696_WL1271_REF_CLOCK 2
static void rm696_wl1271_set_power(bool enable)
{
gpio_set_value(RM696_WL1271_POWER_GPIO, enable);
}
static struct wl12xx_platform_data wl1271_pdata = {
.set_power = rm696_wl1271_set_power,
.board_ref_clock = RM696_WL1271_REF_CLOCK,
};
static inline bool board_is_rm680(void)
{
return (system_rev & 0x00f0) == 0x0020;
}
static bool board_has_sdio_wlan(void)
{
/* RM-696 - N950 using SPI */
if (board_is_rm680())
return false;
return system_rev > 0x0301;
}
/* SPI for wl1271 */
static struct omap2_mcspi_device_config wl1271_mcspi_config = {
.turbo_mode = 1,
};
static struct spi_board_info rm696_peripherals_spi_board_info[] = {
[0] = {
.modalias = "wl1271_spi",
.bus_num = 4,
.chip_select = 0,
.max_speed_hz = 48000000,
.mode = SPI_MODE_0,
.controller_data = &wl1271_mcspi_config,
.platform_data = &wl1271_pdata,
},
};
/* SDIO fixed regulator for WLAN */
static struct regulator_consumer_supply rm696_vsdio_consumers[] = {
REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
};
static struct regulator_init_data rm696_vsdio_data = {
.constraints = {
.valid_ops_mask = REGULATOR_CHANGE_STATUS
| REGULATOR_CHANGE_MODE,
},
.num_consumer_supplies = ARRAY_SIZE(rm696_vsdio_consumers),
.consumer_supplies = rm696_vsdio_consumers,
};
static struct fixed_voltage_config rm696_vsdio_config = {
.supply_name = "vwl1271",
.microvolts = 1800000,
.gpio = RM696_WL1271_POWER_GPIO,
.startup_delay = 1000,
.enable_high = 1,
.enabled_at_boot = 0,
.init_data = &rm696_vsdio_data,
};
static struct platform_device rm696_vsdio_device = {
.name = "reg-fixed-voltage",
.id = 1,
.dev = {
.platform_data = &rm696_vsdio_config,
},
};
/* Fixed regulator for internal eMMC */
static struct regulator_consumer_supply rm680_vemmc_consumers[] = {
REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
};
static struct regulator_init_data rm680_vemmc = {
.constraints = {
.name = "rm680_vemmc",
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_STATUS
| REGULATOR_CHANGE_MODE,
},
.num_consumer_supplies = ARRAY_SIZE(rm680_vemmc_consumers),
.consumer_supplies = rm680_vemmc_consumers,
};
static struct fixed_voltage_config rm680_vemmc_config = {
.supply_name = "VEMMC",
.microvolts = 2900000,
.gpio = 157,
.startup_delay = 150,
.enable_high = 1,
.init_data = &rm680_vemmc,
};
static struct platform_device rm680_vemmc_device = {
.name = "reg-fixed-voltage",
.dev = {
.platform_data = &rm680_vemmc_config,
},
};
static void __init rm680_init_wl1271(void)
{
int irq, ret;
if (board_has_sdio_wlan()) {
pr_info("wl1271 SDIO\n");
platform_device_register(&rm696_vsdio_device);
ret = gpio_request(RM696_WL1271_IRQ_GPIO, "wl1271 irq");
if (ret < 0)
goto sdio_err;
ret = gpio_direction_input(RM696_WL1271_IRQ_GPIO);
if (ret < 0)
goto sdio_err_irq;
irq = gpio_to_irq(RM696_WL1271_IRQ_GPIO);
if (ret < 0)
goto sdio_err_irq;
wl1271_pdata.irq = irq;
wl12xx_set_platform_data(&wl1271_pdata);
/* Set high power gpio - mmc3 need to be detected.
Next wl12xx driver will set this low */
rm696_wl1271_set_power(true);
omap_mux_init_signal("sdmmc2_dat4.sdmmc3_dat0",
OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("sdmmc2_dat5.sdmmc3_dat1",
OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("sdmmc2_dat6.sdmmc3_dat2",
OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("sdmmc2_dat7.sdmmc3_dat3",
OMAP_PIN_INPUT_PULLUP);
return;
sdio_err:
gpio_free(RM696_WL1271_IRQ_GPIO);
sdio_err_irq:
pr_err("wl1271 sdio board initialisation failed\n");
wl1271_pdata.set_power = NULL;
} else {
pr_info("wl1271 SPI\n");
ret = gpio_request(RM696_WL1271_POWER_GPIO, "wl1271 power");
if (ret < 0)
goto spi_err;
ret = gpio_direction_output(RM696_WL1271_POWER_GPIO, 0);
if (ret < 0)
goto spi_err_power;
ret = gpio_request(RM696_WL1271_IRQ_GPIO, "wl1271 irq");
if (ret < 0)
goto spi_err_power;
ret = gpio_direction_input(RM696_WL1271_IRQ_GPIO);
if (ret < 0)
goto spi_err_irq;
irq = gpio_to_irq(RM696_WL1271_IRQ_GPIO);
if (irq < 0)
goto spi_err_irq;
rm696_peripherals_spi_board_info[0].irq = irq;
spi_register_board_info(rm696_peripherals_spi_board_info,
ARRAY_SIZE(rm696_peripherals_spi_board_info));
return;
spi_err_irq:
gpio_free(RM696_WL1271_IRQ_GPIO);
spi_err_power:
gpio_free(RM696_WL1271_POWER_GPIO);
spi_err:
pr_err("wl1271 spi board initialisation failed\n");
wl1271_pdata.set_power = NULL;
}
}
/* GPIO0 AvPlugDet */
#define TWL_GPIOS_HIGH BIT(0)
#define TWL_GPIOS_LOW (BIT(2) | BIT(6) | BIT(8) | BIT(13) | BIT(15))
static int twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
{
int err;
err = gpio_request(gpio + 1, "TMP303_SOH");
if (err) {
printk(KERN_ERR "twl4030_gpio: gpio request failed\n");
goto out;
}
err = gpio_direction_output(gpio + 1, 0);
if (err)
printk(KERN_ERR "twl4030_gpio: set gpio direction failed\n");
out:
return 0;
}
static int twlgpio_teardown(struct device *dev, unsigned gpio, unsigned n)
{
gpio_free(gpio + 1);
return 0;
}
/* TWL */
static struct twl4030_gpio_platform_data rm680_gpio_data = {
.gpio_base = OMAP_MAX_GPIO_LINES,
.irq_base = TWL4030_GPIO_IRQ_BASE,
.irq_end = TWL4030_GPIO_IRQ_END,
.pullups = TWL_GPIOS_HIGH,
.pulldowns = TWL_GPIOS_LOW,
.setup = twlgpio_setup,
.teardown = twlgpio_teardown,
};
static struct twl4030_codec_data rm680_codec_data;
static struct twl4030_audio_data rm680_audio_data = {
.audio_mclk = 38400000,
.codec = &rm680_codec_data,
/*FIXME: vibra*/
};
static struct regulator_consumer_supply rm696_vio_consumers[] = {
REGULATOR_SUPPLY("DVDD", "2-0019"), /* TLV320DAC33 */
REGULATOR_SUPPLY("IOVDD", "2-0019"), /* TLV320DAC33 */
REGULATOR_SUPPLY("VDDI", "display0"), /* Himalaya */
REGULATOR_SUPPLY("Vdd", "2-004b"), /* Atmel mxt */
REGULATOR_SUPPLY("vonenand", "omap2-onenand"), /* OneNAND flash */
REGULATOR_SUPPLY("Vdd_IO", "3-001d"), /* LIS302 */
REGULATOR_SUPPLY("DVdd", "3-000f"), /* AK8975 on RM696, AK8974 on RM680 */
REGULATOR_SUPPLY("Vdd_IO", "3-002b"), /* PN544 */
REGULATOR_SUPPLY("vmmc_aux", "mmci-omap-hs.1"),
REGULATOR_SUPPLY("Vbat", "3-a1fa"), /* BCM4751_GPS */
REGULATOR_SUPPLY("Vddio", "3-a1fa"), /* BCM4751_GPS */
};
static struct regulator_init_data rm696_vio_data = {
.constraints = {
.name = "rm696_vio",
.min_uV = 1800000,
.max_uV = 1800000,
.apply_uV = true,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_STATUS
| REGULATOR_CHANGE_MODE,
},
.num_consumer_supplies = ARRAY_SIZE(rm696_vio_consumers),
.consumer_supplies = rm696_vio_consumers,
};
static struct regulator_consumer_supply rm696_vsim_consumers[] = {
REGULATOR_SUPPLY("VSim", "3-002b"), /* PN544 */
};
static struct regulator_init_data rm696_vsim_data = {
.constraints = {
.name = "rm696_vsim",
.min_uV = 1800000,
.max_uV = 1800000,
.apply_uV = true,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_STATUS
| REGULATOR_CHANGE_MODE,
},
.num_consumer_supplies = ARRAY_SIZE(rm696_vsim_consumers),
.consumer_supplies = rm696_vsim_consumers,
};
static struct regulator_consumer_supply rm680_vbat_consumers[] = {
REGULATOR_SUPPLY("Vleds", "2-0038"), /* BHSFH */
REGULATOR_SUPPLY("AVdd", "2-0060"), /* TPA6140A2 */
};
static struct regulator_init_data rm680_vbat_data = {
.num_consumer_supplies = ARRAY_SIZE(rm680_vbat_consumers),
.consumer_supplies = rm680_vbat_consumers,
.constraints = {
.always_on = 1,
},
};
static struct fixed_voltage_config rm680_vbat_config = {
.supply_name = "vbat",
.microvolts = 3700000,
.gpio = -1,
.init_data = &rm680_vbat_data,
};
static struct platform_device rm680_vbat = {
.name = "reg-fixed-voltage",
.id = -1,
.dev = {
.platform_data = &rm680_vbat_config,
},
};
static struct regulator_consumer_supply rm696_vbat_consumers[] = {
REGULATOR_SUPPLY("Vled", "2-0039"), /* APDS990x */
REGULATOR_SUPPLY("AVdd", "2-0060"), /* TPA6140A2 */
REGULATOR_SUPPLY("VBat", "3-002b"), /* PN544 */
};
static struct regulator_init_data rm696_vbat_data = {
.num_consumer_supplies = ARRAY_SIZE(rm696_vbat_consumers),
.consumer_supplies = rm696_vbat_consumers,
.constraints = {
.always_on = 1,
},
};
static struct fixed_voltage_config rm696_vbat_config = {
.supply_name = "vbat",
.microvolts = 3700000,
.gpio = -1,
.init_data = &rm696_vbat_data,
};
static struct platform_device rm696_vbat = {
.name = "reg-fixed-voltage",
.id = -1,
.dev = {
.platform_data = &rm696_vbat_config,
},
};
/*
* According to public N9 schematics VPNL comes from battery not from
* TWL MMC2
*/
static struct regulator_consumer_supply rm696_vmmc2_consumers[] = {
REGULATOR_SUPPLY("VPNL", "display0"), /* Himalaya */
};
static struct regulator_init_data rm696_vmmc2_data = {
.constraints = {
.name = "rm696_vmmc2",
.min_uV = 3000000,
.max_uV = 3000000,
.apply_uV = true,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_STATUS
| REGULATOR_CHANGE_MODE,
},
.num_consumer_supplies = ARRAY_SIZE(rm696_vmmc2_consumers),
.consumer_supplies = rm696_vmmc2_consumers,
};
static struct regulator_consumer_supply rm680_vaux1_consumers[] = {
REGULATOR_SUPPLY("AVdd", "3-000f"), /* AK8974 */
REGULATOR_SUPPLY("Vdd", "3-001d"), /* LIS302 */
REGULATOR_SUPPLY("Vcc", "2-0038"), /* BHSFH */
REGULATOR_SUPPLY("AVdd", "2-004b"), /* Atmel mxt */
REGULATOR_SUPPLY("v28", "twl5031_aci"),
};
static struct regulator_consumer_supply rm696_vaux1_consumers[] = {
REGULATOR_SUPPLY("AVdd", "2-004b"), /* Atmel mxt */
REGULATOR_SUPPLY("Vdd", "3-001d"), /* LIS302 */
REGULATOR_SUPPLY("v28", "twl5031_aci"),
REGULATOR_SUPPLY("Vdd", "2-0039"), /* APDS990x */
REGULATOR_SUPPLY("AVdd", "3-000f"), /* AK8975 on RM696 */
};
static struct regulator_init_data rm680_vaux1_data = {
.constraints = {
.name = "rm680_vaux1",
.min_uV = 2800000,
.max_uV = 2800000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
},
.num_consumer_supplies = ARRAY_SIZE(rm680_vaux1_consumers),
.consumer_supplies = rm680_vaux1_consumers,
};
static struct regulator_init_data rm696_vaux1_data = {
.constraints = {
.name = "rm696_vaux1",
.min_uV = 2800000,
.max_uV = 2800000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
},
.num_consumer_supplies = ARRAY_SIZE(rm696_vaux1_consumers),
.consumer_supplies = rm696_vaux1_consumers,
};
static struct regulator_consumer_supply rm696_vaux2_consumers[] = {
REGULATOR_SUPPLY("VDD_CSIPHY1", "omap3isp"), /* OMAP ISP */
REGULATOR_SUPPLY("VDD_CSIPHY2", "omap3isp"), /* OMAP ISP */
};
static struct regulator_init_data rm696_vaux2_data = {
.constraints = {
.name = "rm696_vaux2",
.min_uV = 1800000,
.max_uV = 1800000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
},
.num_consumer_supplies = ARRAY_SIZE(rm696_vaux2_consumers),
.consumer_supplies = rm696_vaux2_consumers,
};
static struct regulator_consumer_supply rm696_vaux3_consumers[] = {
REGULATOR_SUPPLY("VANA", "2-0037"), /* Main Camera Sensor */
REGULATOR_SUPPLY("VANA", "2-000e"), /* Main Camera Lens */
REGULATOR_SUPPLY("VANA", "2-0010"), /* Front Camera */
};
static struct regulator_init_data rm696_vaux3_data = {
.constraints = {
.name = "rm696_vaux3",
.min_uV = 2800000,
.max_uV = 2800000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
},
.num_consumer_supplies = ARRAY_SIZE(rm696_vaux3_consumers),
.consumer_supplies = rm696_vaux3_consumers,
};
static struct regulator_consumer_supply rm696_vaux4_consumers[] = {
REGULATOR_SUPPLY("AVDD", "2-0019"), /* TLV320DAC33 */
};
static struct regulator_init_data rm696_vaux4_data = {
.constraints = {
.name = "rm696_vaux4",
.min_uV = 2800000,
.max_uV = 2800000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
},
.num_consumer_supplies = ARRAY_SIZE(rm696_vaux4_consumers),
.consumer_supplies = rm696_vaux4_consumers,
};
static struct platform_device *rm680_peripherals_devices[] __initdata = {
&rm680_vbat,
&rm680_vemmc_device,
&rm696_cmt_device,
&rm696_eci_device,
};
static struct platform_device *rm696_peripherals_devices[] __initdata = {
&rm696_vbat,
&rm680_vemmc_device,
&rm696_cmt_device,
&rm696_eci_device,
};
/* ACI */
static struct regulator *rm696plug_regulator;
static bool rm696plug_regulator_enabled;
static int rm696_plug_resource_reserve(struct device *dev)
{
rm696plug_regulator = regulator_get(dev, "v28");
if (IS_ERR(rm696plug_regulator)) {
dev_err(dev, "Unable to get v28 regulator for plug switch");
return PTR_ERR(rm696plug_regulator);
}
rm696plug_regulator_enabled = 0;
return 0;
}
static int rm696_plug_set_state(struct device *dev, bool plugged)
{
int ret;
if (rm696plug_regulator_enabled == plugged)
return 0;
if (plugged) {
ret = regulator_enable(rm696plug_regulator);
if (ret)
dev_err(dev, "Failed to enable v28 regulator");
else
rm696plug_regulator_enabled = 1;
} else {
ret = regulator_disable(rm696plug_regulator);
if (ret)
dev_err(dev, "Failed to disable v28 regulator");
else
rm696plug_regulator_enabled = 0;
}
return ret;
}
static void rm696_plug_resource_release(void)
{
if (rm696plug_regulator_enabled)
regulator_disable(rm696plug_regulator);
regulator_put(rm696plug_regulator);
rm696plug_regulator = NULL;
}
static struct twl5031_aci_platform_data rm696_aci_data = {
.tvout_gpio = RM696_TVOUT_EN_GPIO,
.jack_gpio = RM696_JACK_GPIO,
.avplugdet_plugged = AVPLUGDET_WHEN_PLUGGED_HIGH,
.hw_plug_set_state = rm696_plug_set_state,
.hw_plug_resource_reserve = rm696_plug_resource_reserve,
.hw_plug_resource_release = rm696_plug_resource_release,
};
static struct twl4030_platform_data rm680_twl_data = {
.gpio = &rm680_gpio_data,
.audio = &rm680_audio_data,
.aci = &rm696_aci_data,
.keypad = &rm696_kp_data,
/* add rest of the children here */
/* LDOs */
.vio = &rm696_vio_data,
.vmmc2 = &rm696_vmmc2_data,
.vsim = &rm696_vsim_data,
.vaux1 = &rm680_vaux1_data,
.vaux2 = &rm696_vaux2_data,
.vaux3 = &rm696_vaux3_data,
.vaux4 = &rm696_vaux4_data,
};
static struct twl4030_platform_data rm696_twl_data = {
.gpio = &rm680_gpio_data,
.audio = &rm680_audio_data,
.aci = &rm696_aci_data,
.keypad = &rm696_kp_data,
/* add rest of the children here */
/* LDOs */
.vio = &rm696_vio_data,
.vmmc2 = &rm696_vmmc2_data,
.vsim = &rm696_vsim_data,
.vaux1 = &rm696_vaux1_data,
.vaux2 = &rm696_vaux2_data,
.vaux3 = &rm696_vaux3_data,
.vaux4 = &rm696_vaux4_data,
};
#if defined(CONFIG_RADIO_WL1273) || defined(CONFIG_RADIO_WL1273_MODULE)
static unsigned int wl1273_fm_reset_gpio;
static int rm696_wl1273_fm_request_resources(struct i2c_client *client)
{
if (gpio_request(RM696_FMRX_IRQ_GPIO, "wl1273_fm irq gpio") < 0) {
dev_err(&client->dev, "Request IRQ GPIO fails.\n");
return -1;
}
if (system_rev < 0x0501)
wl1273_fm_reset_gpio = RM696_FM_RESET_GPIO1;
else
wl1273_fm_reset_gpio = RM696_FM_RESET_GPIO2;
if (gpio_request(wl1273_fm_reset_gpio, "wl1273_fm reset gpio") < 0) {
dev_err(&client->dev, "Request for GPIO %d fails.\n",
wl1273_fm_reset_gpio);
return -1;
}
if (gpio_direction_output(wl1273_fm_reset_gpio, 0)) {
dev_err(&client->dev, "Set GPIO Direction fails.\n");
return -1;
}
client->irq = gpio_to_irq(RM696_FMRX_IRQ_GPIO);
return 0;
}
static void rm696_wl1273_fm_free_resources(void)
{
gpio_free(RM696_FMRX_IRQ_GPIO);
gpio_free(wl1273_fm_reset_gpio);
}
static void rm696_wl1273_fm_enable(void)
{
gpio_set_value(wl1273_fm_reset_gpio, 1);
}
static void rm696_wl1273_fm_disable(void)
{
gpio_set_value(wl1273_fm_reset_gpio, 0);
}
static struct wl1273_fm_platform_data rm696_fm_data = {
.request_resources = rm696_wl1273_fm_request_resources,
.free_resources = rm696_wl1273_fm_free_resources,
.enable = rm696_wl1273_fm_enable,
.disable = rm696_wl1273_fm_disable,
#if defined(CONFIG_SND_SOC_WL1273) || defined(CONFIG_SND_SOC_WL1273_MODULE)
.children = WL1273_CODEC_CHILD | WL1273_RADIO_CHILD,
#else
.children = WL1273_RADIO_CHILD,
#endif
};
static struct platform_device rm696_wl1273_core_device = {
.name = "dfl61audio-wl1273",
.id = -1,
.dev = {
.platform_data = &rm696_fm_data,
},
};
static void __init rm696_wl1273_init(void)
{
platform_device_register(&rm696_wl1273_core_device);
}
#else
static void __init rm696_wl1273_init(void)
{
}
#endif
#if defined(CONFIG_BHSFH) || defined(CONFIG_BHSFH_MODULE)
static int bhsfh_setup(void)
{
int err;
int irq = BHSFH_GPIO;
/* gpio for interrupt pin */
err = gpio_request(irq, "bhsfh_irq");
if (err) {
printk(KERN_ERR "bhsfh: gpio request failed\n");
goto fail;
}
gpio_direction_input(irq);
fail:
return err;
}
static int bhsfh_release(void)
{
gpio_free(BHSFH_GPIO);
return 0;
}
static struct bhsfh_platform_data rm680_bhsfh_data = {
.leds = BHSFH_LED1,
.led_max_curr = BHSFH_LED_100mA,
.led_def_curr = BHSFH_LED_50mA,
.glass_attenuation = (16384 * 385) / 100, /* about 3.85x filtering */
.setup_resources = bhsfh_setup,
.release_resources = bhsfh_release,
};
#endif
#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
#define RM680_LED_MAX_CURR 130 /* 13 mA */
#define RM680_LED_DEF_CURR 50 /* 5.0 mA */
static struct lp5523_led_config rm680_lp5523_led_config[] = {
{
.chan_nr = 0,
.led_current = RM680_LED_DEF_CURR,
.max_current = RM680_LED_MAX_CURR,
}, {
.chan_nr = 1,
.led_current = RM680_LED_DEF_CURR,
.max_current = RM680_LED_MAX_CURR,
}, {
.chan_nr = 2,
.led_current = RM680_LED_DEF_CURR,
.max_current = RM680_LED_MAX_CURR,
}, {
.chan_nr = 3,
.led_current = RM680_LED_DEF_CURR,
.max_current = RM680_LED_MAX_CURR,
}, {
.chan_nr = 4,
.led_current = RM680_LED_DEF_CURR,
.max_current = RM680_LED_MAX_CURR,
}, {
.chan_nr = 5,
.led_current = RM680_LED_DEF_CURR,
.max_current = RM680_LED_MAX_CURR,
}, {
.chan_nr = 6,
.led_current = 0,
}, {
.chan_nr = 7,
.led_current = 0,