1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/saar.c
5 * Support for the Marvell PXA930 Handheld Platform (aka SAAR)
7 * Copyright (C) 2007-2008 Marvell International Ltd.
10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/interrupt.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/clk.h>
16 #include <linux/gpio.h>
17 #include <linux/delay.h>
19 #include <linux/i2c.h>
20 #include <linux/platform_data/i2c-pxa.h>
21 #include <linux/smc91x.h>
22 #include <linux/mfd/da903x.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/partitions.h>
25 #include <linux/mtd/onenand.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/flash.h>
32 #include <linux/platform_data/video-pxafb.h>
37 #define GPIO_LCD_RESET (16)
39 /* SAAR MFP configurations */
40 static mfp_cfg_t saar_mfp_cfg[] __initdata = {
55 GPIO16_GPIO, /* LCD reset */
62 DF_INT_RnB_ND_INT_RnB,
87 #define SAAR_ETH_PHYS (0x14000000)
89 static struct resource smc91x_resources[] = {
91 .start = (SAAR_ETH_PHYS + 0x300),
92 .end = (SAAR_ETH_PHYS + 0xfffff),
93 .flags = IORESOURCE_MEM,
96 .start = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO97)),
97 .end = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO97)),
98 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
102 static struct smc91x_platdata saar_smc91x_info = {
103 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT | SMC91X_USE_DMA,
106 static struct platform_device smc91x_device = {
109 .num_resources = ARRAY_SIZE(smc91x_resources),
110 .resource = smc91x_resources,
112 .platform_data = &saar_smc91x_info,
116 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
117 static uint16_t lcd_power_on[] = {
135 /* calibration control */
142 /*Power-On Init sequence*/
143 SMART_CMD(0x00), /* output ctrl */
147 SMART_CMD(0x00), /* wave ctrl */
152 SMART_CMD(0x03), /* entry mode */
156 SMART_CMD(0x08), /* display ctrl 2 */
160 SMART_CMD(0x09), /* display ctrl 3 */
164 SMART_CMD(0x0A), /* display ctrl 4 */
168 SMART_CMD(0x0D), /* Frame Marker position */
172 SMART_CMD(0x60), /* Driver output control */
176 SMART_CMD(0x61), /* Base image display control */
180 SMART_CMD(0x30), /* Y settings 30h-3Dh */
188 SMART_CMD(0x32), /* Timing(3), ASW HOLD=0.5CLK */
192 SMART_CMD(0x33), /* Timing(4), CKV ST=0CLK, CKV ED=1CLK */
235 SMART_CMD(0x00), /* Display control 1 */
239 SMART_CMD(0x00), /* Power control 5 */
243 SMART_CMD(0x00), /* Power control 1 */
247 SMART_CMD(0x00), /* Power control 2 */
251 SMART_CMD(0x00), /* Power control 3 */
255 SMART_CMD(0x00), /* Power control 4 */
259 SMART_CMD(0x00), /* Power control 3 */
265 /* display mode : 240*320 */
266 SMART_CMD(0x00), /* RAM address set(H) 0*/
270 SMART_CMD(0x00), /* RAM address set(V) 4*/
274 SMART_CMD(0x00), /* Start of Window RAM address set(H) 8*/
278 SMART_CMD(0x00), /* End of Window RAM address set(H) 12*/
282 SMART_CMD(0x00), /* Start of Window RAM address set(V) 16*/
286 SMART_CMD(0x00), /* End of Window RAM address set(V) 20*/
290 SMART_CMD(0x00), /* Panel interface control 1 */
294 SMART_CMD(0x00), /* Panel interface control 2 */
298 SMART_CMD(0x00), /* Panel interface control 3 */
305 static uint16_t lcd_panel_on[] = {
325 static uint16_t lcd_panel_off[] = {
345 static uint16_t lcd_power_off[] = {
368 static uint16_t update_framedata[] = {
369 /* set display ram: 240*320 */
370 SMART_CMD(0x00), /* RAM address set(H) 0*/
374 SMART_CMD(0x00), /* RAM address set(V) 4*/
378 SMART_CMD(0x00), /* Start of Window RAM address set(H) 8 */
382 SMART_CMD(0x00), /* End of Window RAM address set(H) 12 */
386 SMART_CMD(0x00), /* Start of Window RAM address set(V) 16 */
390 SMART_CMD(0x00), /* End of Window RAM address set(V) 20 */
395 /* wait for vsync cmd before transferring frame data */
396 SMART_CMD_WAIT_FOR_VSYNC,
402 /* write frame data */
403 SMART_CMD_WRITE_FRAME,
406 static void ltm022a97a_lcd_power(int on, struct fb_var_screeninfo *var)
408 static int pin_requested = 0;
409 struct fb_info *info = container_of(var, struct fb_info, var);
412 if (!pin_requested) {
413 err = gpio_request(GPIO_LCD_RESET, "lcd reset");
415 pr_err("failed to request gpio for LCD reset\n");
419 gpio_direction_output(GPIO_LCD_RESET, 0);
424 gpio_set_value(GPIO_LCD_RESET, 0); msleep(100);
425 gpio_set_value(GPIO_LCD_RESET, 1); msleep(10);
427 pxafb_smart_queue(info, ARRAY_AND_SIZE(lcd_power_on));
428 pxafb_smart_queue(info, ARRAY_AND_SIZE(lcd_panel_on));
430 pxafb_smart_queue(info, ARRAY_AND_SIZE(lcd_panel_off));
431 pxafb_smart_queue(info, ARRAY_AND_SIZE(lcd_power_off));
434 err = pxafb_smart_flush(info);
436 pr_err("%s: timed out\n", __func__);
439 static void ltm022a97a_update(struct fb_info *info)
441 pxafb_smart_queue(info, ARRAY_AND_SIZE(update_framedata));
442 pxafb_smart_flush(info);
445 static struct pxafb_mode_info toshiba_ltm022a97a_modes[] = {
450 .a0csrd_set_hld = 30,
451 .a0cswr_set_hld = 30,
452 .wr_pulse_width = 30,
453 .rd_pulse_width = 30,
457 /* L_LCLK_A0 and L_LCLK_RD active low */
458 .sync = FB_SYNC_HOR_HIGH_ACT |
459 FB_SYNC_VERT_HIGH_ACT,
463 static struct pxafb_mach_info saar_lcd_info = {
464 .modes = toshiba_ltm022a97a_modes,
466 .lcd_conn = LCD_SMART_PANEL_8BPP | LCD_PCLK_EDGE_FALL,
467 .pxafb_lcd_power = ltm022a97a_lcd_power,
468 .smart_update = ltm022a97a_update,
471 static void __init saar_init_lcd(void)
473 pxa_set_fb_info(NULL, &saar_lcd_info);
476 static inline void saar_init_lcd(void) {}
479 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
480 static struct da9034_backlight_pdata saar_da9034_backlight = {
481 .output_current = 4, /* 4mA */
484 static struct da903x_subdev_info saar_da9034_subdevs[] = {
486 .name = "da903x-backlight",
487 .id = DA9034_ID_WLED,
488 .platform_data = &saar_da9034_backlight,
492 static struct da903x_platform_data saar_da9034_info = {
493 .num_subdevs = ARRAY_SIZE(saar_da9034_subdevs),
494 .subdevs = saar_da9034_subdevs,
497 static struct i2c_board_info saar_i2c_info[] = {
501 .platform_data = &saar_da9034_info,
502 .irq = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO83)),
506 static void __init saar_init_i2c(void)
508 pxa_set_i2c_info(NULL);
509 i2c_register_board_info(0, ARRAY_AND_SIZE(saar_i2c_info));
512 static inline void saar_init_i2c(void) {}
515 #if defined(CONFIG_MTD_ONENAND) || defined(CONFIG_MTD_ONENAND_MODULE)
516 static struct mtd_partition saar_onenand_partitions[] = {
518 .name = "bootloader",
521 .mask_flags = MTD_WRITEABLE,
524 .offset = MTDPART_OFS_APPEND,
526 .mask_flags = MTD_WRITEABLE,
529 .offset = MTDPART_OFS_APPEND,
531 .mask_flags = MTD_WRITEABLE,
534 .offset = MTDPART_OFS_APPEND,
535 .size = (SZ_2M + SZ_1M),
538 .name = "filesystem",
539 .offset = MTDPART_OFS_APPEND,
540 .size = SZ_32M + SZ_16M,
545 static struct onenand_platform_data saar_onenand_info = {
546 .parts = saar_onenand_partitions,
547 .nr_parts = ARRAY_SIZE(saar_onenand_partitions),
550 #define SMC_CS0_PHYS_BASE (0x10000000)
552 static struct resource saar_resource_onenand[] = {
554 .start = SMC_CS0_PHYS_BASE,
555 .end = SMC_CS0_PHYS_BASE + SZ_1M,
556 .flags = IORESOURCE_MEM,
560 static struct platform_device saar_device_onenand = {
561 .name = "onenand-flash",
564 .platform_data = &saar_onenand_info,
566 .resource = saar_resource_onenand,
567 .num_resources = ARRAY_SIZE(saar_resource_onenand),
570 static void __init saar_init_onenand(void)
572 platform_device_register(&saar_device_onenand);
575 static void __init saar_init_onenand(void) {}
578 static void __init saar_init(void)
580 /* initialize MFP configurations */
581 pxa3xx_mfp_config(ARRAY_AND_SIZE(saar_mfp_cfg));
583 pxa_set_ffuart_info(NULL);
584 pxa_set_btuart_info(NULL);
585 pxa_set_stuart_info(NULL);
587 platform_device_register(&smc91x_device);
594 MACHINE_START(SAAR, "PXA930 Handheld Platform (aka SAAR)")
595 /* Maintainer: Eric Miao <eric.miao@marvell.com> */
596 .atag_offset = 0x100,
597 .map_io = pxa3xx_map_io,
598 .nr_irqs = PXA_NR_IRQS,
599 .init_irq = pxa3xx_init_irq,
600 .handle_irq = pxa3xx_handle_irq,
601 .init_time = pxa_timer_init,
602 .init_machine = saar_init,
603 .restart = pxa_restart,