1
|
/*
|
2
|
* Critical Link MityOMAP-L138 SoM Baseboard initializtaion file
|
3
|
* Modified for Hawker Siddeley Switchgear Demo Board
|
4
|
*
|
5
|
*/
|
6
|
#include <linux/kernel.h>
|
7
|
#include <linux/init.h>
|
8
|
#include <linux/gpio.h>
|
9
|
#include <linux/platform_device.h>
|
10
|
#include <linux/spi/spi.h>
|
11
|
#include <linux/delay.h>
|
12
|
#include <linux/mtd/mtd.h>
|
13
|
#include <linux/usb/musb.h>
|
14
|
|
15
|
#include <asm/mach-types.h>
|
16
|
#include <asm/mach/arch.h>
|
17
|
#include <asm/setup.h>
|
18
|
#include <mach/mux.h>
|
19
|
#include <mach/da8xx.h>
|
20
|
#include <linux/can/platform/mcp251x.h>
|
21
|
|
22
|
//#define BASEBOARD_NAME "IndustrialIO"
|
23
|
#define BASEBOARD_NAME "Hawker Siddeley Switchgear Demo Board"
|
24
|
#define MSTPRI2_LCD_MASK 0x70000000
|
25
|
#define MSTPRI2_LCD_SHIFT 28
|
26
|
#define LCD_PRIORITY 0 /* make video output highest priority */
|
27
|
|
28
|
#define MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
|
29
|
#define MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
|
30
|
#define SYSTEM_RESET GPIO_TO_PIN(5, 14)
|
31
|
#define CAN_CS_N GPIO_TO_PIN(2, 15)
|
32
|
#define CAN_INT_PIN GPIO_TO_PIN(2, 12)
|
33
|
#define DSD1791_CS_N GPIO_TO_PIN(0, 8)
|
34
|
#define KS8995_CS GPIO_TO_PIN(0, 15)
|
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, //used for CS on KSZ8995MA
|
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[25] __initdata = {
|
122
|
DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
|
123
|
DA850_AHCLKR, DA850_ACLKR, DA850_AFSR,
|
124
|
DA850_AMUTE, DA850_GPIO5_14,
|
125
|
-1, -1, -1, -1,
|
126
|
-1, -1, -1, -1,
|
127
|
-1, -1, -1, -1,
|
128
|
-1, -1, -1, -1,
|
129
|
-1
|
130
|
};
|
131
|
|
132
|
static __init int baseboard_setup_mcasp(void)
|
133
|
{
|
134
|
int ret;
|
135
|
|
136
|
baseboard_mcasp_pins[8+0] = DA850_AXR_15;
|
137
|
da850_iis_serializer_direction[15] = TX_MODE;
|
138
|
|
139
|
ret = davinci_cfg_reg_list(baseboard_mcasp_pins);
|
140
|
if (ret)
|
141
|
pr_warning("%s: mcasp mux setup failed: %d\n", __func__, ret);
|
142
|
|
143
|
ret = gpio_request(SYSTEM_RESET, "SYSTEM RESET\n");
|
144
|
if (ret)
|
145
|
pr_warning("%s: can't open GPIO %d\n", __func__, SYSTEM_RESET);
|
146
|
msleep(20);
|
147
|
gpio_direction_output(SYSTEM_RESET, 0);
|
148
|
msleep(20);
|
149
|
gpio_set_value(SYSTEM_RESET, 1);
|
150
|
|
151
|
baseboard_snd_data.tdm_slots = 2;
|
152
|
baseboard_snd_data.txnumevt = 1;
|
153
|
|
154
|
da8xx_register_mcasp(0, &baseboard_snd_data);
|
155
|
|
156
|
return ret;
|
157
|
}
|
158
|
|
159
|
static const struct display_panel disp_panel = {
|
160
|
QVGA,
|
161
|
16,
|
162
|
16,
|
163
|
COLOR_ACTIVE,
|
164
|
};
|
165
|
|
166
|
static struct lcd_ctrl_config lcd_cfg = {
|
167
|
&disp_panel,
|
168
|
.ac_bias = 255,
|
169
|
.ac_bias_intrpt = 0,
|
170
|
.dma_burst_sz = 16,
|
171
|
.bpp = 16,
|
172
|
.fdd = 255,
|
173
|
.tft_alt_mode = 0,
|
174
|
.stn_565_mode = 0,
|
175
|
.mono_8bit_mode = 0,
|
176
|
.invert_line_clock = 0,
|
177
|
.invert_frm_clock = 0,
|
178
|
.sync_edge = 0,
|
179
|
.sync_ctrl = 1,
|
180
|
.raster_order = 0,
|
181
|
};
|
182
|
|
183
|
static struct da8xx_lcdc_platform_data sharp_lq035q7dh06_pdata = {
|
184
|
.manu_name = "sharp",
|
185
|
.controller_data = &lcd_cfg,
|
186
|
.type = "Sharp_LQ035Q7DH06",
|
187
|
};
|
188
|
|
189
|
static struct da8xx_lcdc_platform_data chimei_p0430wqlb_pdata = {
|
190
|
.manu_name = "ChiMei",
|
191
|
.controller_data = &lcd_cfg,
|
192
|
.type = "ChiMei_P0430WQLB",
|
193
|
};
|
194
|
|
195
|
static struct da8xx_lcdc_platform_data vga_640x480_pdata = {
|
196
|
.manu_name = "VGA",
|
197
|
.controller_data = &lcd_cfg,
|
198
|
.type = "vga_640x480",
|
199
|
};
|
200
|
|
201
|
static struct da8xx_lcdc_platform_data wvga_800x480_pdata = {
|
202
|
.manu_name = "WVGA",
|
203
|
.controller_data = &lcd_cfg,
|
204
|
.type = "wvga_800x480",
|
205
|
};
|
206
|
|
207
|
static struct da8xx_lcdc_platform_data svga_800x600_pdata = {
|
208
|
.manu_name = "SVGA",
|
209
|
.controller_data = &lcd_cfg,
|
210
|
.type = "svga_800x600",
|
211
|
};
|
212
|
|
213
|
static struct da8xx_lcdc_platform_data nec_nl4827hc19_pdata = {
|
214
|
.manu_name = "NEC",
|
215
|
.controller_data = &lcd_cfg,
|
216
|
.type = "NEC_NL4827HC19-05B",
|
217
|
};
|
218
|
|
219
|
static __init void baseboard_setup_lcd(const char *panel)
|
220
|
{
|
221
|
int ret;
|
222
|
struct da8xx_lcdc_platform_data *pdata;
|
223
|
|
224
|
u32 prio;
|
225
|
|
226
|
/* set peripheral master priority up to 1 */
|
227
|
prio = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG));
|
228
|
prio &= ~MSTPRI2_LCD_MASK;
|
229
|
prio |= LCD_PRIORITY<<MSTPRI2_LCD_SHIFT;
|
230
|
__raw_writel(prio, DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG));
|
231
|
|
232
|
if (!strcmp("Sharp_LQ035Q7DH06", panel))
|
233
|
pdata = &sharp_lq035q7dh06_pdata;
|
234
|
else if (!strcmp("ChiMei_P0430WQLB", panel))
|
235
|
pdata = &chimei_p0430wqlb_pdata;
|
236
|
else if (!strcmp("vga_640x480", panel))
|
237
|
pdata = &vga_640x480_pdata;
|
238
|
else if (!strcmp("wvga_800x480", panel))
|
239
|
pdata = &wvga_800x480_pdata;
|
240
|
else if (!strcmp("svga_800x600", panel))
|
241
|
pdata = &svga_800x600_pdata;
|
242
|
else if (!strcmp("NEC_NL4827HC19-05B", panel)) {
|
243
|
pdata = &nec_nl4827hc19_pdata;
|
244
|
lcd_cfg.invert_line_clock = 1;
|
245
|
lcd_cfg.invert_frm_clock = 1;
|
246
|
} else {
|
247
|
pr_warning("%s: unknown LCD type : %s\n", __func__,
|
248
|
panel);
|
249
|
return;
|
250
|
}
|
251
|
|
252
|
ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
|
253
|
if (ret) {
|
254
|
pr_warning("%s: lcd pinmux failed : %d\n", __func__,
|
255
|
ret);
|
256
|
return;
|
257
|
}
|
258
|
|
259
|
ret = da8xx_register_lcdc(pdata);
|
260
|
}
|
261
|
|
262
|
#ifdef CONFIG_MTD
|
263
|
#define OFFSET_LCDCONFIG 0260
|
264
|
#define LCDCONFIG_LEN 33
|
265
|
static void baseboard_mtd_notify(struct mtd_info *mtd)
|
266
|
{
|
267
|
int retlen;
|
268
|
char buf[LCDCONFIG_LEN]; /* enable, manufacturer name */
|
269
|
if (!strcmp(mtd->name, "periph-config")) {
|
270
|
mtd->_read(mtd, OFFSET_LCDCONFIG, LCDCONFIG_LEN, &retlen,
|
271
|
buf);
|
272
|
if (retlen == LCDCONFIG_LEN) {
|
273
|
if (buf[0]) {
|
274
|
buf[LCDCONFIG_LEN-1] = 0;
|
275
|
pr_info("Using LCD panel: %s\n", &buf[1]);
|
276
|
baseboard_setup_lcd(&buf[1]);
|
277
|
} else
|
278
|
pr_info("No LCD configured\n");
|
279
|
}
|
280
|
}
|
281
|
}
|
282
|
|
283
|
static struct mtd_notifier baseboard_spi_notifier = {
|
284
|
.add = baseboard_mtd_notify,
|
285
|
};
|
286
|
|
287
|
static void baseboard_mtd_notify_add(void)
|
288
|
{
|
289
|
register_mtd_user(&baseboard_spi_notifier);
|
290
|
}
|
291
|
#else
|
292
|
static void baseboard_mtd_notify_add(void) { }
|
293
|
#endif
|
294
|
|
295
|
static struct mcp251x_platform_data mcp2515_pdata = {
|
296
|
.oscillator_frequency = 20000000,
|
297
|
};
|
298
|
|
299
|
static struct davinci_spi_config spi_mcp2515_config = {
|
300
|
.io_type = SPI_IO_TYPE_DMA,
|
301
|
.c2tdelay = 0,
|
302
|
.t2cdelay = 0,
|
303
|
};
|
304
|
|
305
|
static struct davinci_spi_config spi_dsd1791_config = {
|
306
|
.io_type = SPI_IO_TYPE_DMA,
|
307
|
.c2tdelay = 0,
|
308
|
.t2cdelay = 0,
|
309
|
};
|
310
|
static struct davinci_spi_config spi_ks8995_config = {
|
311
|
.io_type = SPI_IO_TYPE_DMA,
|
312
|
.c2tdelay = 0,
|
313
|
.t2cdelay = 0,
|
314
|
};
|
315
|
|
316
|
static struct spi_board_info baseboard_spi1_info[] = {
|
317
|
[0] = {
|
318
|
.modalias = "mcp2515",
|
319
|
.platform_data = &mcp2515_pdata,
|
320
|
.controller_data = &spi_mcp2515_config,
|
321
|
.max_speed_hz = 10000000,
|
322
|
.bus_num = 1,
|
323
|
.chip_select = 1,
|
324
|
},
|
325
|
[1] = {
|
326
|
.modalias = "dsd1791",
|
327
|
.controller_data = &spi_dsd1791_config,
|
328
|
.max_speed_hz = 1000000,
|
329
|
.bus_num = 1,
|
330
|
.chip_select = 2,
|
331
|
},
|
332
|
[2] = {
|
333
|
.modalias = "spi-ks8995",
|
334
|
.controller_data = &spi_ks8995_config,
|
335
|
.max_speed_hz = 1000000, //5000000,
|
336
|
.bus_num = 1,
|
337
|
.chip_select = 3,
|
338
|
},
|
339
|
};
|
340
|
|
341
|
static u8 spi1_cs[] = {
|
342
|
SPI_INTERN_CS,
|
343
|
CAN_CS_N,
|
344
|
DSD1791_CS_N,
|
345
|
KS8995_CS,
|
346
|
};
|
347
|
|
348
|
static void __init baseboard_setup_spi(void)
|
349
|
{
|
350
|
int ret;
|
351
|
|
352
|
pr_info("%s: Entered\n", __func__);
|
353
|
|
354
|
ret = gpio_request(CAN_CS_N, "CAN CS\n");
|
355
|
if (ret)
|
356
|
pr_warning("%s: can not open CAN CS %d\n", __func__, CAN_CS_N);
|
357
|
|
358
|
ret = gpio_request(DSD1791_CS_N, "DSD1791 CS\n");
|
359
|
if (ret)
|
360
|
pr_warning("%s: can not open DSD1791 CS %d\n", __func__, DSD1791_CS_N);
|
361
|
|
362
|
ret = gpio_request(KS8995_CS, "KS8995 CS\n");
|
363
|
if (ret)
|
364
|
pr_warning("%s: can not open KS8995 CS %d\n", __func__, KS8995_CS);
|
365
|
// gpio_direction_output(KS8995_CS,0);
|
366
|
// gpio_set_value(KS8995_CS,1);
|
367
|
|
368
|
baseboard_spi1_info[0].irq = gpio_to_irq(CAN_INT_PIN);
|
369
|
|
370
|
ret = spi_register_board_info(baseboard_spi1_info, ARRAY_SIZE(baseboard_spi1_info));
|
371
|
if (ret)
|
372
|
pr_warning("%s: Unable to register SPI1 Info: %d\n", __func__,
|
373
|
ret);
|
374
|
pr_info("%s: Exit\n", __func__);
|
375
|
}
|
376
|
|
377
|
static int __init baseboard_pre_init(void)
|
378
|
{
|
379
|
pr_info("%s: Entered\n", __func__);
|
380
|
da8xx_spi_pdata[1].chip_sel = spi1_cs;
|
381
|
da8xx_spi_pdata[1].num_chipselect = ARRAY_SIZE(spi1_cs);
|
382
|
davinci_soc_info.emac_pdata->phy_id = "";
|
383
|
return 0;
|
384
|
}
|
385
|
postcore_initcall_sync(baseboard_pre_init);
|
386
|
|
387
|
static int __init baseboard_init(void)
|
388
|
{
|
389
|
pr_info("%s [%s]...\n", __func__, BASEBOARD_NAME);
|
390
|
|
391
|
davinci_cfg_reg_list(baseboard_gpio_pins);
|
392
|
|
393
|
baseboard_setup_mmc();
|
394
|
|
395
|
baseboard_setup_spi();
|
396
|
|
397
|
baseboard_setup_mcasp();
|
398
|
|
399
|
baseboard_mtd_notify_add();
|
400
|
|
401
|
mityomapl138_usb_init(MUSB_OTG);
|
402
|
|
403
|
return 0;
|
404
|
}
|
405
|
arch_initcall_sync(baseboard_init);
|
406
|
|