xref: /linux/arch/arm/mach-sa1100/h3600.c (revision e7d759f31ca295d589f7420719c311870bb3166f)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Support for Compaq iPAQ H3600 handheld computer
4  *
5  * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
6  * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru>
7  */
8 
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/gpio.h>
12 
13 #include <video/sa1100fb.h>
14 
15 #include <asm/mach-types.h>
16 #include <asm/mach/arch.h>
17 
18 #include <mach/h3xxx.h>
19 #include <mach/irqs.h>
20 
21 #include "generic.h"
22 
23 /*
24  * helper for sa1100fb
25  */
26 static struct gpio h3600_lcd_gpio[] = {
27 	{ H3XXX_EGPIO_LCD_ON,	GPIOF_OUT_INIT_LOW,	"LCD power" },
28 	{ H3600_EGPIO_LCD_PCI,	GPIOF_OUT_INIT_LOW,	"LCD control" },
29 	{ H3600_EGPIO_LCD_5V_ON, GPIOF_OUT_INIT_LOW,	"LCD 5v" },
30 	{ H3600_EGPIO_LVDD_ON,	GPIOF_OUT_INIT_LOW,	"LCD 9v/-6.5v" },
31 };
32 
33 static bool h3600_lcd_request(void)
34 {
35 	static bool h3600_lcd_ok;
36 	int rc;
37 
38 	if (h3600_lcd_ok)
39 		return true;
40 
41 	rc = gpio_request_array(h3600_lcd_gpio, ARRAY_SIZE(h3600_lcd_gpio));
42 	if (rc)
43 		pr_err("%s: can't request GPIOs\n", __func__);
44 	else
45 		h3600_lcd_ok = true;
46 
47 	return h3600_lcd_ok;
48 }
49 
50 static void h3600_lcd_power(int enable)
51 {
52 	if (!h3600_lcd_request())
53 		return;
54 
55 	gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
56 	gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
57 	gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
58 	gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
59 }
60 
61 static const struct sa1100fb_rgb h3600_rgb_16 = {
62 	.red	= { .offset = 12, .length = 4, },
63 	.green	= { .offset = 7,  .length = 4, },
64 	.blue	= { .offset = 1,  .length = 4, },
65 	.transp	= { .offset = 0,  .length = 0, },
66 };
67 
68 static struct sa1100fb_mach_info h3600_lcd_info = {
69 	.pixclock	= 174757, 	.bpp		= 16,
70 	.xres		= 320,		.yres		= 240,
71 
72 	.hsync_len	= 3,		.vsync_len	= 3,
73 	.left_margin	= 12,		.upper_margin	= 10,
74 	.right_margin	= 17,		.lower_margin	= 1,
75 
76 	.cmap_static	= 1,
77 
78 	.lccr0		= LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
79 	.lccr3		= LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
80 
81 	.rgb[RGB_16] = &h3600_rgb_16,
82 
83 	.lcd_power = h3600_lcd_power,
84 };
85 
86 
87 static void __init h3600_map_io(void)
88 {
89 	h3xxx_map_io();
90 }
91 
92 static void __init h3600_mach_init(void)
93 {
94 	h3xxx_mach_init();
95 
96 	sa11x0_register_lcd(&h3600_lcd_info);
97 }
98 
99 MACHINE_START(H3600, "Compaq iPAQ H3600")
100 	.atag_offset	= 0x100,
101 	.map_io		= h3600_map_io,
102 	.nr_irqs	= SA1100_NR_IRQS,
103 	.init_irq	= sa1100_init_irq,
104 	.init_time	= sa1100_timer_init,
105 	.init_machine	= h3600_mach_init,
106 	.init_late	= sa11x0_init_late,
107 	.restart	= sa11x0_restart,
108 MACHINE_END
109 
110