1
|
/*
|
2
|
* Critical Link MityOMAP-L138 SoM Baseboard initializtaion file
|
3
|
*
|
4
|
*/
|
5
|
#include <linux/kernel.h>
|
6
|
#include <linux/init.h>
|
7
|
#include <linux/gpio.h>
|
8
|
#include <linux/platform_device.h>
|
9
|
#include <linux/spi/spi.h>
|
10
|
#include <linux/delay.h>
|
11
|
#include <linux/mtd/mtd.h>
|
12
|
#include <linux/usb/musb.h>
|
13
|
|
14
|
#include <asm/mach-types.h>
|
15
|
#include <asm/mach/arch.h>
|
16
|
#include <asm/setup.h>
|
17
|
#include <mach/mux.h>
|
18
|
#include <mach/da8xx.h>
|
19
|
#include <linux/can/platform/mcp251x.h>
|
20
|
|
21
|
#define BASEBOARD_NAME "IndustrialIO"
|
22
|
#define MSTPRI2_LCD_MASK 0x70000000
|
23
|
#define MSTPRI2_LCD_SHIFT 28
|
24
|
#define LCD_PRIORITY 0 /* make video output highest priority */
|
25
|
|
26
|
#define MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
|
27
|
#define MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
|
28
|
#define SYSTEM_RESET GPIO_TO_PIN(5, 14)
|
29
|
#define ADF4158_CS_N GPIO_TO_PIN(2, 15) /* FOR US IS TO SELECT CHIP ADF4158 */
|
30
|
#define ADF4360_CS_N GPIO_TO_PIN(0, 8) /* FOR US IS TO SELECT CHIP ADF4360 */
|
31
|
#define CAN_INT_PIN GPIO_TO_PIN(2, 12)
|
32
|
//#define DSD1791_CS_N GPIO_TO_PIN(0, 8) /* COMMENTED OUT */
|
33
|
#define DAC8551_CS_N GPIO_TO_PIN(0, 15)
|
34
|
#define ADS5560_CS_N GPIO_TO_PIN(0, 6)
|
35
|
|
36
|
static int baseboard_mmc_get_ro(int index)
|
37
|
{
|
38
|
return gpio_get_value(MMCSD_WP_PIN);
|
39
|
}
|
40
|
|
41
|
static int baseboard_mmc_get_cd(int index)
|
42
|
{
|
43
|
return !gpio_get_value(MMCSD_CD_PIN);
|
44
|
}
|
45
|
|
46
|
static struct davinci_mmc_config da850_mmc_config = {
|
47
|
.get_ro = baseboard_mmc_get_ro,
|
48
|
.get_cd = baseboard_mmc_get_cd,
|
49
|
.wires = 4,
|
50
|
.max_freq = 50000000,
|
51
|
.caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
|
52
|
.version = MMC_CTLR_VERSION_2,
|
53
|
};
|
54
|
|
55
|
static const short da850_mmcsd0_pins[] __initconst = {
|
56
|
DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
|
57
|
DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
|
58
|
DA850_GPIO4_0, DA850_GPIO4_1,
|
59
|
-1
|
60
|
};
|
61
|
|
62
|
static __init void baseboard_setup_mmc(void)
|
63
|
{
|
64
|
int ret;
|
65
|
|
66
|
ret = davinci_cfg_reg_list(da850_mmcsd0_pins);
|
67
|
if (ret)
|
68
|
pr_warning("%s: mmcsd0 mux setup failed: %d\n", __func__, ret);
|
69
|
|
70
|
ret = gpio_request(MMCSD_CD_PIN, "MMC CD\n");
|
71
|
if (ret)
|
72
|
pr_warning("%s: can not open GPIO %d\n", __func__,
|
73
|
MMCSD_CD_PIN);
|
74
|
gpio_direction_input(MMCSD_CD_PIN);
|
75
|
|
76
|
ret = gpio_request(MMCSD_WP_PIN, "MMC WP\n");
|
77
|
if (ret)
|
78
|
pr_warning("%s: can not open GPIO %d\n", __func__,
|
79
|
MMCSD_WP_PIN);
|
80
|
gpio_direction_input(MMCSD_WP_PIN);
|
81
|
|
82
|
ret = da8xx_register_mmcsd0(&da850_mmc_config);
|
83
|
if (ret)
|
84
|
pr_warning("%s: mmcsd0 registration failed: %d\n", __func__,
|
85
|
ret);
|
86
|
}
|
87
|
|
88
|
/*
|
89
|
* GPIO pins, this is an exhaustive list which may be overridden by
|
90
|
* other devices
|
91
|
*/
|
92
|
static short baseboard_gpio_pins[] __initdata = {
|
93
|
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_3,
|
94
|
DA850_GPIO0_4, DA850_GPIO0_5, DA850_GPIO0_6, DA850_GPIO0_7,
|
95
|
DA850_GPIO0_8, DA850_GPIO0_9, DA850_GPIO0_10, DA850_GPIO0_11,
|
96
|
DA850_GPIO0_12, DA850_GPIO0_13, DA850_GPIO0_14, DA850_GPIO0_15,
|
97
|
DA850_GPIO2_12, DA850_GPIO2_15, -1,
|
98
|
};
|
99
|
|
100
|
/* davinci da850 evm audio machine driver */
|
101
|
static u8 da850_iis_serializer_direction[] = {
|
102
|
INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
|
103
|
INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
|
104
|
INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
|
105
|
INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
|
106
|
};
|
107
|
|
108
|
static struct snd_platform_data baseboard_snd_data = {
|
109
|
.tx_dma_offset = 0x2000,
|
110
|
.rx_dma_offset = 0x2000,
|
111
|
.op_mode = DAVINCI_MCASP_IIS_MODE,
|
112
|
.num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
|
113
|
.tdm_slots = 0,
|
114
|
.serial_dir = da850_iis_serializer_direction,
|
115
|
.asp_chan_q = EVENTQ_1,
|
116
|
.version = MCASP_VERSION_2,
|
117
|
.txnumevt = 0,
|
118
|
.rxnumevt = 0,
|
119
|
};
|
120
|
|
121
|
static short baseboard_mcasp_pins[21] __initdata = {
|
122
|
DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
|
123
|
DA850_AHCLKR,
|
124
|
-1, -1, -1, -1,
|
125
|
-1, -1, -1, -1,
|
126
|
-1, -1, -1, -1,
|
127
|
-1, -1, -1, -1,
|
128
|
-1
|
129
|
};
|
130
|
|
131
|
static __init int baseboard_setup_mcasp(void)
|
132
|
{
|
133
|
int ret;
|
134
|
|
135
|
baseboard_mcasp_pins[4+0] = DA850_AXR_15;
|
136
|
da850_iis_serializer_direction[15] = TX_MODE;
|
137
|
|
138
|
ret = davinci_cfg_reg_list(baseboard_mcasp_pins);
|
139
|
if (ret)
|
140
|
pr_warning("%s: mcasp mux setup failed: %d\n", __func__, ret);
|
141
|
|
142
|
ret = gpio_request(SYSTEM_RESET, "SYSTEM RESET\n");
|
143
|
if (ret)
|
144
|
pr_warning("%s: can't open GPIO %d\n", __func__, SYSTEM_RESET);
|
145
|
msleep(20);
|
146
|
gpio_direction_output(SYSTEM_RESET, 0);
|
147
|
msleep(20);
|
148
|
gpio_set_value(SYSTEM_RESET, 1);
|
149
|
|
150
|
baseboard_snd_data.tdm_slots = 2;
|
151
|
baseboard_snd_data.txnumevt = 1;
|
152
|
|
153
|
da8xx_register_mcasp(0, &baseboard_snd_data);
|
154
|
|
155
|
return ret;
|
156
|
}
|
157
|
|
158
|
static const struct display_panel disp_panel = {
|
159
|
QVGA,
|
160
|
16,
|
161
|
16,
|
162
|
COLOR_ACTIVE,
|
163
|
};
|
164
|
|
165
|
static struct lcd_ctrl_config lcd_cfg = {
|
166
|
&disp_panel,
|
167
|
.ac_bias = 255,
|
168
|
.ac_bias_intrpt = 0,
|
169
|
.dma_burst_sz = 16,
|
170
|
.bpp = 16,
|
171
|
.fdd = 255,
|
172
|
.tft_alt_mode = 0,
|
173
|
.stn_565_mode = 0,
|
174
|
.mono_8bit_mode = 0,
|
175
|
.invert_line_clock = 0,
|
176
|
.invert_frm_clock = 0,
|
177
|
.sync_edge = 0,
|
178
|
.sync_ctrl = 1,
|
179
|
.raster_order = 0,
|
180
|
};
|
181
|
|
182
|
static struct da8xx_lcdc_platform_data sharp_lq035q7dh06_pdata = {
|
183
|
.manu_name = "sharp",
|
184
|
.controller_data = &lcd_cfg,
|
185
|
.type = "Sharp_LQ035Q7DH06",
|
186
|
};
|
187
|
|
188
|
static struct da8xx_lcdc_platform_data chimei_p0430wqlb_pdata = {
|
189
|
.manu_name = "ChiMei",
|
190
|
.controller_data = &lcd_cfg,
|
191
|
.type = "ChiMei_P0430WQLB",
|
192
|
};
|
193
|
|
194
|
static struct da8xx_lcdc_platform_data vga_640x480_pdata = {
|
195
|
.manu_name = "VGA",
|
196
|
.controller_data = &lcd_cfg,
|
197
|
.type = "vga_640x480",
|
198
|
};
|
199
|
|
200
|
static struct da8xx_lcdc_platform_data wvga_800x480_pdata = {
|
201
|
.manu_name = "WVGA",
|
202
|
.controller_data = &lcd_cfg,
|
203
|
.type = "wvga_800x480",
|
204
|
};
|
205
|
|
206
|
static struct da8xx_lcdc_platform_data svga_800x600_pdata = {
|
207
|
.manu_name = "SVGA",
|
208
|
.controller_data = &lcd_cfg,
|
209
|
.type = "svga_800x600",
|
210
|
};
|
211
|
|
212
|
static struct da8xx_lcdc_platform_data nec_nl4827hc19_pdata = {
|
213
|
.manu_name = "NEC",
|
214
|
.controller_data = &lcd_cfg,
|
215
|
.type = "NEC_NL4827HC19-05B",
|
216
|
};
|
217
|
|
218
|
static __init void baseboard_setup_lcd(const char *panel)
|
219
|
{
|
220
|
int ret;
|
221
|
struct da8xx_lcdc_platform_data *pdata;
|
222
|
|
223
|
u32 prio;
|
224
|
|
225
|
/* set peripheral master priority up to 1 */
|
226
|
prio = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG));
|
227
|
prio &= ~MSTPRI2_LCD_MASK;
|
228
|
prio |= LCD_PRIORITY<<MSTPRI2_LCD_SHIFT;
|
229
|
__raw_writel(prio, DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG));
|
230
|
|
231
|
if (!strcmp("Sharp_LQ035Q7DH06", panel))
|
232
|
pdata = &sharp_lq035q7dh06_pdata;
|
233
|
else if (!strcmp("ChiMei_P0430WQLB", panel))
|
234
|
pdata = &chimei_p0430wqlb_pdata;
|
235
|
else if (!strcmp("vga_640x480", panel))
|
236
|
pdata = &vga_640x480_pdata;
|
237
|
else if (!strcmp("wvga_800x480", panel))
|
238
|
pdata = &wvga_800x480_pdata;
|
239
|
else if (!strcmp("svga_800x600", panel))
|
240
|
pdata = &svga_800x600_pdata;
|
241
|
else if (!strcmp("NEC_NL4827HC19-05B", panel)) {
|
242
|
pdata = &nec_nl4827hc19_pdata;
|
243
|
lcd_cfg.invert_line_clock = 1;
|
244
|
lcd_cfg.invert_frm_clock = 1;
|
245
|
} else {
|
246
|
pr_warning("%s: unknown LCD type : %s\n", __func__,
|
247
|
panel);
|
248
|
return;
|
249
|
}
|
250
|
|
251
|
ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
|
252
|
if (ret) {
|
253
|
pr_warning("%s: lcd pinmux failed : %d\n", __func__,
|
254
|
ret);
|
255
|
return;
|
256
|
}
|
257
|
|
258
|
ret = da8xx_register_lcdc(pdata);
|
259
|
}
|
260
|
|
261
|
#ifdef CONFIG_MTD
|
262
|
#define OFFSET_LCDCONFIG 176
|
263
|
#define LCDCONFIG_LEN 33
|
264
|
static void baseboard_mtd_notify(struct mtd_info *mtd)
|
265
|
{
|
266
|
int retlen;
|
267
|
char buf[LCDCONFIG_LEN]; /* enable, manufacturer name */
|
268
|
if (!strcmp(mtd->name, "periph-config")) {
|
269
|
mtd->read(mtd, OFFSET_LCDCONFIG, LCDCONFIG_LEN, &retlen,
|
270
|
buf);
|
271
|
if (retlen == LCDCONFIG_LEN) {
|
272
|
if (buf[0]) {
|
273
|
buf[LCDCONFIG_LEN-1] = 0;
|
274
|
pr_info("Using LCD panel: %s\n", &buf[1]);
|
275
|
baseboard_setup_lcd(&buf[1]);
|
276
|
} else
|
277
|
pr_info("No LCD configured\n");
|
278
|
}
|
279
|
}
|
280
|
}
|
281
|
|
282
|
static struct mtd_notifier baseboard_spi_notifier = {
|
283
|
.add = baseboard_mtd_notify,
|
284
|
};
|
285
|
|
286
|
static void baseboard_mtd_notify_add(void)
|
287
|
{
|
288
|
register_mtd_user(&baseboard_spi_notifier);
|
289
|
}
|
290
|
#else
|
291
|
static void baseboard_mtd_notify_add(void) { }
|
292
|
#endif
|
293
|
|
294
|
/* MODIFIED. Commented out */
|
295
|
/*
|
296
|
static struct mcp251x_platform_data mcp2515_pdata = {
|
297
|
.oscillator_frequency = 20000000,
|
298
|
};
|
299
|
*/
|
300
|
|
301
|
static struct davinci_spi_config spi_adf4158_config = {
|
302
|
.io_type = SPI_IO_TYPE_POLL, /* MODIFIED. Default value SPI_IO_TYPE_DMA */
|
303
|
.c2tdelay = 0,
|
304
|
.t2cdelay = 0,
|
305
|
};
|
306
|
|
307
|
static struct davinci_spi_config spi_adf4360_config = { /* ADDED */
|
308
|
.io_type = SPI_IO_TYPE_POLL,
|
309
|
.c2tdelay = 0,
|
310
|
.t2cdelay = 0,
|
311
|
};
|
312
|
/* COMMENTED OUT
|
313
|
static struct davinci_spi_config spi_dsd1791_config = {
|
314
|
.io_type = SPI_IO_TYPE_DMA,
|
315
|
.c2tdelay = 0,
|
316
|
.t2cdelay = 0,
|
317
|
}; */
|
318
|
|
319
|
#ifdef CONFIG_INDIO_EXPANSION_ANALOGIO
|
320
|
static struct davinci_spi_config spi_dac8554_config = {
|
321
|
.io_type = SPI_IO_TYPE_DMA,
|
322
|
.c2tdelay = 0,
|
323
|
.t2cdelay = 0,
|
324
|
};
|
325
|
static struct davinci_spi_config spi_ads5560_config = {
|
326
|
.io_type = SPI_IO_TYPE_DMA,
|
327
|
.c2tdelay = 0,
|
328
|
.t2cdelay = 0,
|
329
|
};
|
330
|
#endif
|
331
|
|
332
|
static struct spi_board_info baseboard_spi1_info[] = {
|
333
|
{
|
334
|
.modalias = "spidev", /* MODIFIED. Default value mcp2515 */
|
335
|
/* .platform_data = &mcp2515_pdata, */ /* COMMENTED OUT */
|
336
|
.controller_data = &spi_adf4158_config,
|
337
|
.max_speed_hz = 750000, /* MODIFIED. Default value 10000000 */
|
338
|
.bus_num = 1,
|
339
|
.chip_select = 1,
|
340
|
.mode = SPI_MODE_0, /* ADDED. Default value nothing means SPI_MODE_3*/
|
341
|
},
|
342
|
/* COMMENTED OUT
|
343
|
{
|
344
|
.modalias = "dsd1791",
|
345
|
.controller_data = &spi_dsd1791_config,
|
346
|
.max_speed_hz = 1000000,
|
347
|
.bus_num = 1,
|
348
|
.chip_select = 2,
|
349
|
},
|
350
|
*/
|
351
|
{
|
352
|
.modalias = "spidev", /* ADDED */
|
353
|
.controller_data = &spi_adf4360_config, /* ADDED */
|
354
|
.max_speed_hz = 750000, /* ADDED */
|
355
|
.bus_num = 1, /* ADDED */
|
356
|
.chip_select = 2, /* ADDED */
|
357
|
.mode = SPI_MODE_0, /* ADDED */
|
358
|
},
|
359
|
#ifdef CONFIG_INDIO_EXPANSION_ANALOGIO
|
360
|
{
|
361
|
.modalias = "spidev",
|
362
|
.controller_data = &spi_dac8554_config,
|
363
|
.max_speed_hz = 10000000,
|
364
|
.bus_num = 1,
|
365
|
.chip_select = 3,
|
366
|
},
|
367
|
{
|
368
|
.modalias = "spidev",
|
369
|
.controller_data = &spi_ads5560_config,
|
370
|
.max_speed_hz = 10000000,
|
371
|
.bus_num = 1,
|
372
|
.chip_select = 4,
|
373
|
},
|
374
|
#endif
|
375
|
};
|
376
|
|
377
|
#ifdef CONFIG_INDIO_EXPANSION_ANALOGIO
|
378
|
static struct spi_board_info baseboard_spi3_info[] = {
|
379
|
{
|
380
|
.modalias = "spidev",
|
381
|
.max_speed_hz = 10000000,
|
382
|
.bus_num = 3,
|
383
|
.chip_select = 0,
|
384
|
},
|
385
|
};
|
386
|
#endif
|
387
|
|
388
|
static u8 spi1_cs[] = {
|
389
|
SPI_INTERN_CS,
|
390
|
ADF4158_CS_N, /* MODIFIED */
|
391
|
/* DSD1791_CS_N, COMMENTED OUT */
|
392
|
ADF4360_CS_N, /* ADDED */
|
393
|
#ifdef CONFIG_INDIO_EXPANSION_ANALOGIO
|
394
|
DAC8551_CS_N,
|
395
|
ADS5560_CS_N,
|
396
|
#endif
|
397
|
};
|
398
|
|
399
|
static void __init baseboard_setup_spi(void)
|
400
|
{
|
401
|
int ret;
|
402
|
|
403
|
/*MODIFIED. Default was CAN_CS_N */
|
404
|
ret = gpio_request(ADF4158_CS_N, "ADF4158 CS\n");
|
405
|
if (ret)
|
406
|
pr_warning("%s: can not open ADF4158 CS %d\n", __func__, ADF4158_CS_N);
|
407
|
|
408
|
/* COMMENTED OUT
|
409
|
ret = gpio_request(DSD1791_CS_N, "DSD1791 CS\n");
|
410
|
if (ret)
|
411
|
pr_warning("%s: can not open DSD1791 CS %d\n", __func__,
|
412
|
DSD1791_CS_N);
|
413
|
*/
|
414
|
|
415
|
/* ADDED */
|
416
|
ret = gpio_request(ADF4360_CS_N, "ADF4360 CS\n");
|
417
|
if (ret)
|
418
|
pr_warning("%s: can not open ADF4360 CS %d\n", __func__, ADF4360_CS_N);
|
419
|
|
420
|
|
421
|
#ifdef CONFIG_INDIO_EXPANSION_ANALOGIO
|
422
|
ret = gpio_request(DAC8551_CS_N, "DAC8551 LDAC\n");
|
423
|
if (ret)
|
424
|
pr_warning("%s: can not open DAC8551 LDAC %d\n", __func__, ret);
|
425
|
|
426
|
ret = gpio_request(ADS5560_CS_N, "ADS5560 CS\n");
|
427
|
if (ret)
|
428
|
pr_warning("%s: can not open ADS5560 CS %d\n", __func__, ret);
|
429
|
|
430
|
ret = spi_register_board_info(baseboard_spi3_info,
|
431
|
ARRAY_SIZE(baseboard_spi3_info));
|
432
|
if (ret)
|
433
|
pr_warning("%s: Unable to register SPI3 Info: %d\n", __func__,
|
434
|
ret);
|
435
|
#endif
|
436
|
|
437
|
/* DELETED OUT */
|
438
|
//baseboard_spi1_info[0].irq = gpio_to_irq(CAN_INT_PIN);
|
439
|
|
440
|
ret = spi_register_board_info(baseboard_spi1_info,
|
441
|
ARRAY_SIZE(baseboard_spi1_info));
|
442
|
if (ret)
|
443
|
pr_warning("%s: Unable to register SPI1 Info: %d\n", __func__,
|
444
|
ret);
|
445
|
}
|
446
|
|
447
|
static int __init baseboard_pre_init(void)
|
448
|
{
|
449
|
pr_info("%s: Entered\n", __func__);
|
450
|
da8xx_spi_pdata[1].chip_sel = spi1_cs;
|
451
|
da8xx_spi_pdata[1].num_chipselect = ARRAY_SIZE(spi1_cs);
|
452
|
davinci_soc_info.emac_pdata->phy_id = "0:03";
|
453
|
return 0;
|
454
|
}
|
455
|
postcore_initcall_sync(baseboard_pre_init);
|
456
|
|
457
|
static int __init baseboard_init(void)
|
458
|
{
|
459
|
pr_info("%s [%s]...\n", __func__, BASEBOARD_NAME);
|
460
|
|
461
|
davinci_cfg_reg_list(baseboard_gpio_pins);
|
462
|
|
463
|
baseboard_setup_mmc();
|
464
|
|
465
|
baseboard_setup_spi();
|
466
|
|
467
|
baseboard_setup_mcasp();
|
468
|
|
469
|
baseboard_mtd_notify_add();
|
470
|
|
471
|
mityomapl138_usb_init(MUSB_OTG);
|
472
|
|
473
|
return 0;
|
474
|
}
|
475
|
arch_initcall_sync(baseboard_init);
|