小弟今天看linux内核希望能够找到有用的程序去配置 spi 模式的LCD,, 结果还真的给找到了,,不过一个人看了一个下午都没有看懂,,现在请教论坛中牛人,看有谁研究过这东西。。
/* parse the mtdset= option given to the kernel command line */
263__setup("mtdset=", jive_mtdset);
264
265/* LCD timing and setup */
266
267#define LCD_XRES (240)
268#define LCD_YRES (320)
269#define LCD_LEFT_MARGIN (12)
270#define LCD_RIGHT_MARGIN (12)
271#define LCD_LOWER_MARGIN (12)
272#define LCD_UPPER_MARGIN (12)
273#define LCD_VSYNC (2)
274#define LCD_HSYNC (2)
275
276#define LCD_REFRESH (60)
277
278#define LCD_HTOT (LCD_HSYNC + LCD_LEFT_MARGIN + LCD_XRES + LCD_RIGHT_MARGIN)
279#define LCD_VTOT (LCD_VSYNC + LCD_LOWER_MARGIN + LCD_YRES + LCD_UPPER_MARGIN)
280
281struct s3c2410fb_display jive_vgg2432a4_display[] = {
282 [0] = {
283 .width = LCD_XRES,
284 .height = LCD_YRES,
285 .xres = LCD_XRES,
286 .yres = LCD_YRES,
287 .left_margin = LCD_LEFT_MARGIN,
288 .right_margin = LCD_RIGHT_MARGIN,
289 .upper_margin = LCD_UPPER_MARGIN,
290 .lower_margin = LCD_LOWER_MARGIN,
291 .hsync_len = LCD_HSYNC,
292 .vsync_len = LCD_VSYNC,
293
294 .pixclock = (1000000000000LL /
295 (LCD_REFRESH * LCD_HTOT * LCD_VTOT)),
296
297 .bpp = 16,
298 .type = (S3C2410_LCDCON1_TFT16BPP |
299 S3C2410_LCDCON1_TFT),
300
301 .lcdcon5 = (S3C2410_LCDCON5_FRM565 |
302 S3C2410_LCDCON5_INVVLINE |
303 S3C2410_LCDCON5_INVVFRAME |
304 S3C2410_LCDCON5_INVVDEN |
305 S3C2410_LCDCON5_PWREN),
306 },
307};
308
309/* todo - put into gpio header */
310
311#define S3C2410_GPCCON_MASK(x) (3 << ((x) * 2))
312#define S3C2410_GPDCON_MASK(x) (3 << ((x) * 2))
313
314struct s3c2410fb_mach_info jive_lcd_config = {
315 .displays = jive_vgg2432a4_display,
316 .num_displays = ARRAY_SIZE(jive_vgg2432a4_display),
317 .default_display = 0,
318
319 /* Enable VD[2..7], VD[10..15], VD[18..23] and VCLK, syncs, VDEN
320 * and disable the pull down resistors on pins we are using for LCD
321 * data. */
322
323 .gpcup = (0xf << 1) | (0x3f << 10),
324
325 .gpccon = (S3C2410_GPC1_VCLK | S3C2410_GPC2_VLINE |
326 S3C2410_GPC3_VFRAME | S3C2410_GPC4_VM |
327 S3C2410_GPC10_VD2 | S3C2410_GPC11_VD3 |
328 S3C2410_GPC12_VD4 | S3C2410_GPC13_VD5 |
329 S3C2410_GPC14_VD6 | S3C2410_GPC15_VD7),
330
331 .gpccon_mask = (S3C2410_GPCCON_MASK(1) | S3C2410_GPCCON_MASK(2) |
332 S3C2410_GPCCON_MASK(3) | S3C2410_GPCCON_MASK(4) |
333 S3C2410_GPCCON_MASK(10) | S3C2410_GPCCON_MASK(11) |
334 S3C2410_GPCCON_MASK(12) | S3C2410_GPCCON_MASK(13) |
335 S3C2410_GPCCON_MASK(14) | S3C2410_GPCCON_MASK(15)),
336
337 .gpdup = (0x3f << 2) | (0x3f << 10),
338
339 .gpdcon = (S3C2410_GPD2_VD10 | S3C2410_GPD3_VD11 |
340 S3C2410_GPD4_VD12 | S3C2410_GPD5_VD13 |
341 S3C2410_GPD6_VD14 | S3C2410_GPD7_VD15 |
342 S3C2410_GPD10_VD18 | S3C2410_GPD11_VD19 |
343 S3C2410_GPD12_VD20 | S3C2410_GPD13_VD21 |
344 S3C2410_GPD14_VD22 | S3C2410_GPD15_VD23),
345
346 .gpdcon_mask = (S3C2410_GPDCON_MASK(2) | S3C2410_GPDCON_MASK(3) |
347 S3C2410_GPDCON_MASK(4) | S3C2410_GPDCON_MASK(5) |
348 S3C2410_GPDCON_MASK(6) | S3C2410_GPDCON_MASK(7) |
349 S3C2410_GPDCON_MASK(10) | S3C2410_GPDCON_MASK(11)|
350 S3C2410_GPDCON_MASK(12) | S3C2410_GPDCON_MASK(13)|
351 S3C2410_GPDCON_MASK(14) | S3C2410_GPDCON_MASK(15)),
352};
353
354/* ILI9320 support. */
355
356static void jive_lcm_reset(unsigned int set)
357{
358 printk(KERN_DEBUG "%s(%d)\n", __func__, set);
359
360 s3c2410_gpio_setpin(S3C2410_GPG13, set);
361 s3c2410_gpio_cfgpin(S3C2410_GPG13, S3C2410_GPIO_OUTPUT);
362}
363
364#undef LCD_UPPER_MARGIN
365#define LCD_UPPER_MARGIN 2
366
367static struct ili9320_platdata jive_lcm_config = {
368 .hsize = LCD_XRES,
369 .vsize = LCD_YRES,
370
371 .reset = jive_lcm_reset,
372 .suspend = ILI9320_SUSPEND_DEEP,
373
374 .entry_mode = ILI9320_ENTRYMODE_ID(3) | ILI9320_ENTRYMODE_BGR,
375 .display2 = (ILI9320_DISPLAY2_FP(LCD_UPPER_MARGIN) |
376 ILI9320_DISPLAY2_BP(LCD_LOWER_MARGIN)),
377 .display3 = 0x0,
378 .display4 = 0x0,
379 .rgb_if1 = (ILI9320_RGBIF1_RIM_RGB18 |
380 ILI9320_RGBIF1_RM | ILI9320_RGBIF1_CLK_RGBIF),
381 .rgb_if2 = ILI9320_RGBIF2_DPL,
382 .interface2 = 0x0,
383 .interface3 = 0x3,
384 .interface4 = (ILI9320_INTERFACE4_RTNE(16) |
385 ILI9320_INTERFACE4_DIVE(1)),
386 .interface5 = 0x0,
387 .interface6 = 0x0,
388};
389
390/* LCD SPI support */
391
392static void jive_lcd_spi_chipselect(struct s3c2410_spigpio_info *spi, int cs)
393{
394 s3c2410_gpio_setpin(S3C2410_GPB7, cs ? 0 : 1);
395}
396
397static struct s3c2410_spigpio_info jive_lcd_spi = {
398 .bus_num = 1,
399 .pin_clk = S3C2410_GPG8,
400 .pin_mosi = S3C2410_GPB8,
401 .num_chipselect = 1,
402 .chip_select = jive_lcd_spi_chipselect,
403};
404
405static struct platform_device jive_device_lcdspi = {
406 .name = "spi_s3c24xx_gpio",
407 .id = 1,
408 .num_resources = 0,
409 .dev.platform_data = &jive_lcd_spi,
410};
另外还有ILI9320.C 和ILI9320.h这两个文件哦,, 想要配置I80 模式和SPI下code 的兄弟们,我们可以好好研究下哦。。。