/
board-dm365-evm.c
976 lines (836 loc) · 22.4 KB
/
board-dm365-evm.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
/*
* TI DaVinci DM365 EVM board support
*
* Copyright (C) 2009 Texas Instruments Incorporated
*
* 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 version 2.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
* kind, whether express or implied; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/i2c/at24.h>
#include <linux/leds.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/slab.h>
#include <linux/mtd/nand.h>
#include <linux/input.h>
#include <linux/spi/spi.h>
#include <linux/spi/eeprom.h>
#include <linux/delay.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <mach/mux.h>
#include <mach/common.h>
#include <linux/platform_data/i2c-davinci.h>
#include <mach/serial.h>
#include <linux/platform_data/mmc-davinci.h>
#include <linux/platform_data/mtd-davinci.h>
#include <linux/platform_data/keyscan-davinci.h>
#include <linux/platform_data/usb-davinci.h>
#include <mach/time.h>
#include <mach/gpio.h>
#include <mach/rto.h>
#include <linux/w1-gpio.h>
#include "davinci.h"
#include "dm365_spi.h"
#include <linux/usb/g_hid.h>
#include "hid_struct.h"
#include "board-virt2real-dm365.h"
//#ifdef CONFIG_V2R_PARSE_CMDLINE
//static void __init v2r_parse_cmdline(char * string);
//#endif
static struct i2c_board_info i2c_info[] = {
};
static struct davinci_i2c_platform_data i2c_pdata = {
.bus_freq = 100 /* kHz */, //was 400
.bus_delay = 0 /* usec */,
.sda_pin = 21,
.scl_pin = 20,
};
/* Input available at the ov7690 */
//Shadrin camera
static struct v4l2_input ov2643_inputs[] = {
{
.index = 0,
.name = "Camera",
.type = V4L2_INPUT_TYPE_CAMERA,
}
};
static struct vpfe_subdev_info vpfe_sub_devs[] = {
{
//Clock for camera????
.module_name = "ov2643",
.is_camera = 1,
.grp_id = VPFE_SUBDEV_OV2643,
.num_inputs = ARRAY_SIZE(ov2643_inputs),
.inputs = ov2643_inputs,
.ccdc_if_params = {
#ifdef CONFIG_VIDEO_YCBCR
.if_type = VPFE_YCBCR_SYNC_8,
#else
.if_type = VPFE_RAW_BAYER,
#endif
.hdpol = VPFE_PINPOL_POSITIVE,
.vdpol = VPFE_PINPOL_POSITIVE,
},
.board_info = {
I2C_BOARD_INFO("ov2643", 0x30),
/* this is for PCLK rising edge */
.platform_data = (void *)1,
},
}
};
static struct vpfe_config vpfe_cfg = {
.num_subdevs = ARRAY_SIZE(vpfe_sub_devs),
.sub_devs = vpfe_sub_devs,
.card_name = "DM365 Leopard",
.ccdc = "DM365 ISIF",
.num_clocks = 1,
.clocks = {"vpss_master"},
};
static void w1_enable_external_pullup(int enable);
static inline int have_imager(void)
{
#if defined(CONFIG_SOC_CAMERA_OV2643) || \
defined(CONFIG_SOC_CAMERA_OV2643_MODULE)
return 1;
#else
return 0;
#endif
}
static void dm365_camera_configure(void){
davinci_cfg_reg(DM365_CAM_OFF);
gpio_request(98, "CAMERA_OFF");
gpio_direction_output(98, 0);
davinci_cfg_reg(DM365_CAM_RESET);
gpio_request(99, "CAMERA_RESET");
gpio_direction_output(99, 1);
davinci_cfg_reg(DM365_GPIO37);//Disable clk at gpio37
davinci_cfg_reg(DM365_EXTCLK);
}
/* software PWM */
#ifdef CONFIG_V2R_SWPWM
static struct resource davinci_timer3_resources[] = {
{
.start = DAVINCI_TIMER3_BASE,
.end = DAVINCI_TIMER3_BASE + SZ_1K - 1,
.flags = IORESOURCE_MEM,
},
{
.start = IRQ_DM365_TINT6,
.flags = IORESOURCE_IRQ,
}
};
static struct platform_device davinci_timer3_device = {
.name = "davinci_swpwm_driver",
.id = -1,
.num_resources = ARRAY_SIZE(davinci_timer3_resources),
.resource = davinci_timer3_resources
};
#endif
/* end software PWM */
/* software RTO */
//#ifdef CONFIG_V2R_SWPWM
static struct resource davinci_rto_resources[] = {
{
.start = DAVINCI_TIMER3_BASE,
.end = DAVINCI_TIMER3_BASE + SZ_1K - 1,
.flags = IORESOURCE_MEM,
},
{
.start = DAVINCI_RTO_PHIS,
.end = DAVINCI_RTO_PHIS + SZ_1K - 1,
.flags = IORESOURCE_MEM,
},
{
.start = IRQ_DM365_TINT6,
.flags = IORESOURCE_IRQ,
},
{
.start = 0,
.end = 0,
.flags = IORESOURCE_DMA,
}
};
static struct platform_device davinci_rto_device = {
.name = "davinci_rto_driver",
.id = -1,
.num_resources = ARRAY_SIZE(davinci_rto_resources),
.resource = davinci_rto_resources
};
//#endif
/* end software PWM */
//#define DM365_EVM_PHY_ID "davinci_mdio-0:01" // replaced by Gol
#define DM365_EVM_PHY_ID "davinci_mdio-0:00"
/* NOTE: this is geared for the standard config, with a socketed
* 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors. If you
* swap chips with a different block size, partitioning will
* need to be changed. This NAND chip MT29F16G08FAA is the default
* NAND shipped with the Spectrum Digital DM365 EVM
*/
/*define NAND_BLOCK_SIZE SZ_128K*/
/* For Samsung 4K NAND (K9KAG08U0M) with 256K sectors */
/*#define NAND_BLOCK_SIZE SZ_256K*/
/* For Micron 4K NAND with 512K sectors */
#define NAND_BLOCK_SIZE SZ_512K
#define DM365_ASYNC_EMIF_CONTROL_BASE 0x01d10000
static struct mtd_partition davinci_nand_partitions[] = {
{
/* UBL (a few copies) plus U-Boot */
.name = "bootloader",
.offset = 0,
//.size = 30 * NAND_BLOCK_SIZE,
.size = 0x400000,
.mask_flags = 0, // MTD_WRITEABLE, /* force read-only */
},
{
.name = "kernel",
//.offset = MTDPART_OFS_APPEND,
.offset = 0x400000,
.size = SZ_4M,
.mask_flags = 0, // MTD_WRITEABLE, /* force read-only */
}, {
.name = "fs",
//.offset = MTDPART_OFS_APPEND,
.offset = 0x900000,
.size = MTDPART_SIZ_FULL,
.mask_flags = 0, // MTD_WRITEABLE, /* force read-only */
}
/* two blocks with bad block table (and mirror) at the end */
};
static struct davinci_nand_pdata davinci_nand_data = {
.mask_chipsel = 0,
.parts = davinci_nand_partitions,
.nr_parts = ARRAY_SIZE(davinci_nand_partitions),
.ecc_mode = NAND_ECC_HW,
.bbt_options = NAND_BBT_USE_FLASH,
.ecc_bits = 4,
};
#define DM365_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
#define DM365_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
static struct resource davinci_nand_resources[] = {
{
.start = DM365_ASYNC_EMIF_DATA_CE0_BASE,
.end = DM365_ASYNC_EMIF_DATA_CE0_BASE + SZ_32M - 1,
.flags = IORESOURCE_MEM,
}, {
.start = DM365_ASYNC_EMIF_CONTROL_BASE,
.end = DM365_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
};
static struct platform_device davinci_nand_device = {
.name = "davinci_nand",
.id = 0,
.num_resources = ARRAY_SIZE(davinci_nand_resources),
.resource = davinci_nand_resources,
.dev = {
.platform_data = &davinci_nand_data,
},
};
static struct snd_platform_data dm365_evm_snd_data = {
.asp_chan_q = EVENTQ_3,
.ram_chan_q = EVENTQ_3,
//.sram_size_capture = 0x100000000, /* CMEM/H.264 uses TCM from 0x1000 */
};
//SD card configuration functions
//May be used dynamically
static int mmc_get_cd(int module)
{
//1 = card present
//0 = card not present
return 1;
}
static int mmc_get_ro(int module)
{
//1 = device is read-only
//0 = device is mot read only
return 0;
}
static struct davinci_mmc_config dm365evm_mmc_config = {
.get_cd = mmc_get_cd,
.get_ro = mmc_get_ro,
.wires = 4,
.max_freq = 50000000,
.caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
};
static struct davinci_mmc_config dm365evm_mmc1_config = {
//.get_cd = mmc_get_cd,
//.get_ro = mmc_get_ro,
.wires = 4,
.max_freq = 50000000,
.caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | MMC_BUS_WIDTH_4 | MMC_CAP_NONREMOVABLE | MMC_CAP_4_BIT_DATA,
};
static void dm365evm_emac_configure(void)
{
/*
* EMAC pins are multiplexed with GPIO and UART
* Further details are available at the DM365 ARM
* Subsystem Users Guide(sprufg5.pdf) pages 125 - 127
*/
davinci_cfg_reg(DM365_EMAC_TX_EN);
davinci_cfg_reg(DM365_EMAC_TX_CLK);
davinci_cfg_reg(DM365_EMAC_COL);
davinci_cfg_reg(DM365_EMAC_TXD3);
davinci_cfg_reg(DM365_EMAC_TXD2);
davinci_cfg_reg(DM365_EMAC_TXD1);
davinci_cfg_reg(DM365_EMAC_TXD0);
davinci_cfg_reg(DM365_EMAC_RXD3);
davinci_cfg_reg(DM365_EMAC_RXD2);
davinci_cfg_reg(DM365_EMAC_RXD1);
davinci_cfg_reg(DM365_EMAC_RXD0);
davinci_cfg_reg(DM365_EMAC_RX_CLK);
davinci_cfg_reg(DM365_EMAC_RX_DV);
davinci_cfg_reg(DM365_EMAC_RX_ER);
davinci_cfg_reg(DM365_EMAC_CRS);
davinci_cfg_reg(DM365_EMAC_MDIO);
davinci_cfg_reg(DM365_EMAC_MDCLK);
/*
* EMAC interrupts are multiplexed with GPIO interrupts
* Details are available at the DM365 ARM
* Subsystem Users Guide(sprufg5.pdf) pages 133 - 134
*/
davinci_cfg_reg(DM365_INT_EMAC_RXTHRESH);
davinci_cfg_reg(DM365_INT_EMAC_RXPULSE);
davinci_cfg_reg(DM365_INT_EMAC_TXPULSE);
davinci_cfg_reg(DM365_INT_EMAC_MISCPULSE);
davinci_cfg_reg(DM365_GPIO29);
printk("reseting EMAC\n");
gpio_request(29, "emac-reset");
gpio_direction_output(29, 1);
msleep(20);
gpio_direction_output(29, 0);
msleep(100);
gpio_direction_output(29, 1);
}
static void dm365evm_mmc_configure(void)
{
/*
* MMC/SD pins are multiplexed with GPIO and EMIF
* Further details are available at the DM365 ARM
* Subsystem Users Guide(sprufg5.pdf) pages 118, 128 - 131
*/
davinci_cfg_reg(DM365_SD1_CLK);
davinci_cfg_reg(DM365_SD1_CMD);
davinci_cfg_reg(DM365_SD1_DATA3);
davinci_cfg_reg(DM365_SD1_DATA2);
davinci_cfg_reg(DM365_SD1_DATA1);
davinci_cfg_reg(DM365_SD1_DATA0);
}
//to support usb
__init static void dm365_usb_configure(void)
{
davinci_cfg_reg(DM365_GPIO66);
gpio_request(66, "usb");
gpio_direction_output(66, 1);
davinci_setup_usb(500, 8);
}
static void dm365_ks8851_init(void){
gpio_request(0, "KSZ8851");
gpio_direction_input(0);
davinci_cfg_reg(DM365_INT_SPI3);
davinci_cfg_reg(DM365_EVT18_SPI3_TX);
davinci_cfg_reg(DM365_EVT19_SPI3_RX);
}
static void __init v2r_init_i2c(void)
{
davinci_cfg_reg(DM365_GPIO20);
gpio_request(20, "i2c-scl");
gpio_direction_output(20, 0);
davinci_cfg_reg(DM365_I2C_SCL);
davinci_init_i2c(&i2c_pdata);
i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
}
static struct platform_device *dm365_evm_nand_devices[] __initdata = {
&davinci_nand_device,
&davinci_rto_device
#ifdef CONFIG_V2R_SWPWM
,&davinci_timer3_device
#endif
};
static struct davinci_uart_config uart_config __initdata = {
.enabled_uarts = (1 << 0) | (1 << 1),
};
static void __init dm365_evm_map_io(void)
{
/* setup input configuration for VPFE input devices */
dm365_set_vpfe_config(&vpfe_cfg);
dm365_init();
}
static struct davinci_spi_config ksz8851_mcspi_config = {
.io_type = SPI_IO_TYPE_DMA,
.c2tdelay = 0,
.t2cdelay = 0
};
static struct spi_board_info ksz8851_snl_info[] __initdata = {
{
.modalias = "ks8851",
.bus_num = 3,
.chip_select = 0,
.max_speed_hz = 40000000,
.controller_data = &ksz8851_mcspi_config,
.irq = IRQ_DM365_GPIO0
}
};
static struct davinci_spi_unit_desc dm365_evm_spi_udesc_KSZ8851 = {
.spi_hwunit = 3,
.chipsel = BIT(0),
.irq = IRQ_DM365_SPIINT3_0,
.dma_tx_chan = 18,
.dma_rx_chan = 19,
.dma_evtq = EVENTQ_3,
.pdata = {
.version = SPI_VERSION_1,
.num_chipselect = 2,
.intr_line = 0,
.chip_sel = 0,
.cshold_bug = 0,
.dma_event_q = EVENTQ_3,
}
};
/* SPI0 init */
static struct davinci_spi_config v2rdac_config = {
.io_type = SPI_IO_TYPE_DMA,
.c2tdelay = 0,
.t2cdelay = 0
};
static struct spi_board_info v2rdac_info[] __initdata = {
{
.modalias = "spidev",
.bus_num = 0,
.chip_select = 1,
.max_speed_hz = 1000000,
.controller_data = &v2rdac_config,
.mode = SPI_MODE_1
}
};
static struct davinci_spi_unit_desc v2rdac_spi_udesc = {
.spi_hwunit = 0,
.chipsel = BIT(1),
.irq = IRQ_DM365_SPIINT0_0,
.dma_tx_chan = 16,
.dma_rx_chan = 17,
.dma_evtq = EVENTQ_3,
.pdata = {
.version = SPI_VERSION_1,
.num_chipselect = 2,
.intr_line = 0,
.chip_sel = 0,
.cshold_bug = 0,
.dma_event_q = EVENTQ_3,
}
};
/* end SPI0 init */
/* 1-wire init block */
static struct w1_gpio_platform_data w1_gpio_pdata = {
.pin = 26,
.is_open_drain = 0,
.enable_external_pullup = w1_enable_external_pullup,
.ext_pullup_enable_pin = 27
};
static struct platform_device w1_device = {
.name = "w1-gpio",
.id = -1,
.dev.platform_data = &w1_gpio_pdata,
};
static void w1_enable_external_pullup(int enable) {
gpio_set_value(w1_gpio_pdata.ext_pullup_enable_pin, enable);
}
static void w1_gpio_init(void) {
int err;
err = platform_device_register(&w1_device);
if (err)
printk(KERN_INFO "Failed to register w1-gpio\n");
else
printk(KERN_INFO "w1-gpio conected to GPIO22\n");
}
/* end 1-wire init block */
/* LED triggers block */
#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
static struct gpio_led v2r_led[] = {
{
.name = "v2r:red:user",
.default_trigger = "none",
.gpio = 74,
.active_low = 0,
},
{
.name = "v2r:green:user",
.default_trigger = "none",
.gpio = 73,
.active_low = 0,
},
{
.name = "lan:green:user",
.default_trigger = "none",
.gpio = 85,
.active_low = 0,
},
{
.name = "lan:yellow:user",
.default_trigger = "none",
.gpio = 86,
.active_low = 0,
},
{
.name = "debug:red:user",
.default_trigger = "none",
.gpio = 49,
.active_low = 0,
},
{
.name = "debug:green:user",
.default_trigger = "none",
.gpio = 47,
.active_low = 0,
},
{
.name = "debug:blue:user",
.default_trigger = "none",
.gpio = 46,
.active_low = 0,
},
{
.name = "debug:yellow:user",
.default_trigger = "none",
.gpio = 44,
.active_low = 0,
},
};
static struct gpio_led_platform_data v2r_led_data = {
.num_leds = ARRAY_SIZE(v2r_led),
.leds = v2r_led
};
static struct platform_device v2r_led_dev = {
.name = "leds-gpio",
.id = -1,
.dev = {
.platform_data = &v2r_led_data,
},
};
static void led_init(void) {
int err;
err = platform_device_register(&v2r_led_dev);
if (err)
printk(KERN_INFO "Failed to register LED triggers\n");
else
printk(KERN_INFO "LED triggers init success\n");
}
#endif /* CONFIG_LEDS_GPIO */
/* end LED triggers block */
static void ghid_k_init(void) {
int err;
err = platform_device_register(&my_keybord_hid);
if (err)
printk("HID Gadget keybord registration failed\n");
else
printk("HID Gadget keybord registration success\n");
}
static void ghid_m_init(void) {
int err;
err = platform_device_register(&my_mouse_hid);
if (err)
printk("HID Gadget mouse registration failed\n");
else
printk("HID Gadget mouse registration success\n");
}
static __init void dm365_evm_init(void)
{
struct davinci_soc_info *soc_info = &davinci_soc_info;
struct clk *aemif_clk;
w1_run = 0;
lan0_run = 0;
lan1_run = 0;
lan1_mac_run = 0;
wlan_run = 0;
spi0_run = 0;
led_run = 0;
camera_run = 0;
uart1_run = 0;
ghid_k_run=0;
ghid_m_run=0;
#ifdef CONFIG_V2R_PARSE_CMDLINE
v2r_parse_cmdline(saved_command_line);
#endif
aemif_clk = clk_get(NULL, "aemif");
if (IS_ERR(aemif_clk)) return;
clk_prepare_enable(aemif_clk);
// try to init NAND
platform_add_devices(dm365_evm_nand_devices, ARRAY_SIZE(dm365_evm_nand_devices));
v2r_init_i2c();
// try to init camera
if (camera_run) dm365_camera_configure();
// set up UART1 GPIO
if (uart1_run) {
davinci_cfg_reg(DM365_UART1_RXD);
davinci_cfg_reg(DM365_UART1_TXD);
}
// try to init UARTs
davinci_serial_init(&uart_config);
dm365evm_mmc_configure();
// try to init LED-triggers
#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
if (led_run) led_init();
#endif
// try to init MMC0 (microSD)
davinci_setup_mmc(0, &dm365evm_mmc_config);
// try to init VoiceCodec
dm365_init_vc(&dm365_evm_snd_data);
// try to init Real Time Clock
dm365_init_rtc();
// try to init USB
dm365_usb_configure();
// try to init LAN module
if (lan0_run) {
dm365_ks8851_init();
davinci_init_spi(&dm365_evm_spi_udesc_KSZ8851, ARRAY_SIZE(ksz8851_snl_info), ksz8851_snl_info);
}
// try to init EMAC LAN
if (lan1_run) {
if (lan1_mac_run) {
soc_info->emac_pdata->mac_addr[0] = lan1_mac[0];
soc_info->emac_pdata->mac_addr[1] = lan1_mac[1];
soc_info->emac_pdata->mac_addr[2] = lan1_mac[2];
soc_info->emac_pdata->mac_addr[3] = lan1_mac[3];
soc_info->emac_pdata->mac_addr[4] = lan1_mac[4];
soc_info->emac_pdata->mac_addr[5] = lan1_mac[5];
}
soc_info->emac_pdata->phy_id = DM365_EVM_PHY_ID;
dm365evm_emac_configure();
}
// try to init 1-Wire
if (w1_run)
w1_gpio_init(); // run 1-wire master
// try to init SPI0
if (spi0_run)
davinci_init_spi(&v2rdac_spi_udesc, ARRAY_SIZE(v2rdac_info), v2rdac_info); // run SPI0 init
// try to init G_HID
if (ghid_k_run)
ghid_k_init();
if (ghid_m_run)
ghid_m_init();
// try to init wlan
if (wlan_run) {
gpio_request(59, "wlan-pwdn");
gpio_direction_output(59, 1);
msleep(20);
gpio_request(59, "wlan-reset");
gpio_direction_output(60, 1);
msleep(20);
gpio_direction_output(60, 0);
msleep(1000);
gpio_direction_output(60, 1);
davinci_setup_mmc(1, &dm365evm_mmc1_config);
}
// set USB prioruty,
// see http://e2e.ti.com/support/embedded/linux/f/354/t/94930.aspx
// and http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/100/t/150995.aspx
// davinci_writel(0x0, 0x1c40040); //master priority1 register1 - to set USB
return;
}
/* Virt2real board devices init functions */
#ifdef CONFIG_V2R_PARSE_CMDLINE
static void v2r_parse_cmdline(char * string)
{
char *p;
char *temp_string;
char *temp_param;
char *param_name;
char *param_value;
printk(KERN_INFO "Parse kernel cmdline:\n");
temp_string = kstrdup(string, GFP_KERNEL);
do
{
p = strsep(&temp_string, " ");
if (p) {
// split param string into two parts
temp_param = kstrdup(p, GFP_KERNEL);
param_name = strsep(&temp_param, "=");
if (!param_name) continue;
//printk(KERN_INFO "%s\n", temp_value);
param_value = strsep(&temp_param, " ");
if (!param_value) continue;
//printk(KERN_INFO "%s\n", param_value);
//printk (KERN_INFO "param %s = %s\n", param_name, param_value);
// i'd like to use switch, but fig tam
if (!strcmp(param_name, "pwrled")) {
if (!strcmp(param_value, "on")) {
// turn on blue led
u8 result = 0;
printk(KERN_INFO "Power LED set ON\n");
result = davinci_rtcss_read(0x00);
result |= (1<<3);
davinci_rtcss_write(result, 0x00);
}
}
#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
if (!strcmp(param_name, "redled")) {
v2r_led[0].default_trigger = param_value;
led_run = 1;
}
if (!strcmp(param_name, "greenled")) {
v2r_led[1].default_trigger = param_value;
led_run = 1;
}
if (!strcmp(param_name, "led1")) {
v2r_led[2].default_trigger = param_value;
led_run = 1;
}
if (!strcmp(param_name, "led2")) {
v2r_led[3].default_trigger = param_value;
led_run = 1;
}
if (!strcmp(param_name, "led3")) {
v2r_led[4].default_trigger = param_value;
led_run = 1;
}
if (!strcmp(param_name, "led4")) {
v2r_led[5].default_trigger = param_value;
led_run = 1;
}
if (!strcmp(param_name, "led5")) {
v2r_led[6].default_trigger = param_value;
led_run = 1;
}
if (!strcmp(param_name, "led6")) {
v2r_led[7].default_trigger = param_value;
led_run = 1;
}
if (!strcmp(param_name, "led1gpio")) {
int temp;
kstrtoint(param_value, 10, &temp);
v2r_led[2].gpio = (u8)temp;
led_run = 1;
}
if (!strcmp(param_name, "led2gpio")) {
int temp;
kstrtoint(param_value, 10, &temp);
v2r_led[3].gpio = (u8)temp;
led_run = 1;
}
if (!strcmp(param_name, "led3gpio")) {
int temp;
kstrtoint(param_value, 10, &temp);
v2r_led[4].gpio = (u8)temp;
led_run = 1;
}
if (!strcmp(param_name, "led4gpio")) {
int temp;
kstrtoint(param_value, 10, &temp);
v2r_led[5].gpio = (u8)temp;
led_run = 1;
}
if (!strcmp(param_name, "led5gpio")) {
int temp;
kstrtoint(param_value, 10, &temp);
v2r_led[6].gpio = (u8)temp;
led_run = 1;
}
if (!strcmp(param_name, "led6gpio")) {
int temp;
kstrtoint(param_value, 10, &temp);
v2r_led[7].gpio = (u8)temp;
led_run = 1;
}
#endif
if (!strcmp(param_name, "wifi")) {
if (!strcmp(param_value, "on")) {
printk(KERN_INFO "Wi-Fi board enabled\n");
wlan_run = 1;
}
}
if (!strcmp(param_name, "lan0")) {
if (!strcmp(param_value, "on")) {
printk(KERN_INFO "LAN enabled\n");
lan0_run = 1;
}
}
if (!strcmp(param_name, "lan1")) {
if (!strcmp(param_value, "on")) {
printk(KERN_INFO "EMAC LAN enabled\n");
lan1_run = 1;
}
}
if (!strcmp(param_name, "lan1hwaddr")) {
ParseMACaddr(param_value);
lan1_mac_run = 1;
}
if (!strcmp(param_name, "spi0")) {
if (!strcmp(param_value, "on")) {
printk(KERN_INFO "SPI0 enabled\n");
spi0_run = 1;
}
}
if (!strcmp(param_name, "uart1")) {
if (!strcmp(param_value, "on")) {
printk(KERN_INFO "UART1 enabled\n");
uart1_run = 1;
}
}
if (!strcmp(param_name, "1wire")) {
int temp;
kstrtoint(param_value, 10, &temp);
w1_gpio_pdata.pin = temp;
printk(KERN_INFO "Use 1-wire on GPIO%d\n", temp);
w1_run = 1;
}
if (!strcmp(param_name, "1wirepullup")) {
int temp;
kstrtoint(param_value, 10, &temp);
w1_gpio_pdata.ext_pullup_enable_pin = temp;
printk(KERN_INFO "Use 1-wire pullup resistor on GPIO%d\n", temp);
}
if (!strcmp(param_name, "camera")) {
if (!strcmp(param_value, "ov2643")) {
printk(KERN_INFO "Use camera OmniVision OV2643\n");
camera_run = 1;
}
if (!strcmp(param_value, "ov5642")) {
printk(KERN_INFO "Use camera OmniVision OV5642\n");
camera_run = 1;
}
if (!strcmp(param_value, "ov7675")) {
printk(KERN_INFO "Use camera OmniVision OV7675\n");
camera_run = 1;
}
if (!strcmp(param_value, "ov9710")) {
printk(KERN_INFO "Use camera OmniVision OV9710\n");
camera_run = 1;
}
}
if (!strcmp(param_name, "ghid")) {
if (strchr(param_value, 'k')) {
printk("HID gadget keybord enabled\n");
ghid_k_run = 1;
}
if (strchr(param_value, 'm')) {
printk("HID gadget mouse enabled\n");
ghid_m_run = 1;
}
}
}
} while(p);
}
#endif
/* End virt2real board devices init functions */
MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM365 EVM")
.atag_offset = 0x100,
.map_io = dm365_evm_map_io,
.init_irq = davinci_irq_init,
.init_time = davinci_timer_init,
.init_machine = dm365_evm_init,
.init_late = davinci_init_late,
.dma_zone_size = SZ_128M,
.restart = davinci_restart,
MACHINE_END