xref: /OK3568_Linux_fs/kernel/arch/arm/mach-sa1100/h3600.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Support for Compaq iPAQ H3600 handheld computer
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
6*4882a593Smuzhiyun  * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru>
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <linux/init.h>
10*4882a593Smuzhiyun #include <linux/kernel.h>
11*4882a593Smuzhiyun #include <linux/gpio.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include <video/sa1100fb.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include <asm/mach-types.h>
16*4882a593Smuzhiyun #include <asm/mach/arch.h>
17*4882a593Smuzhiyun #include <linux/platform_data/irda-sa11x0.h>
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #include <mach/h3xxx.h>
20*4882a593Smuzhiyun #include <mach/irqs.h>
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #include "generic.h"
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun /*
25*4882a593Smuzhiyun  * helper for sa1100fb
26*4882a593Smuzhiyun  */
27*4882a593Smuzhiyun static struct gpio h3600_lcd_gpio[] = {
28*4882a593Smuzhiyun 	{ H3XXX_EGPIO_LCD_ON,	GPIOF_OUT_INIT_LOW,	"LCD power" },
29*4882a593Smuzhiyun 	{ H3600_EGPIO_LCD_PCI,	GPIOF_OUT_INIT_LOW,	"LCD control" },
30*4882a593Smuzhiyun 	{ H3600_EGPIO_LCD_5V_ON, GPIOF_OUT_INIT_LOW,	"LCD 5v" },
31*4882a593Smuzhiyun 	{ H3600_EGPIO_LVDD_ON,	GPIOF_OUT_INIT_LOW,	"LCD 9v/-6.5v" },
32*4882a593Smuzhiyun };
33*4882a593Smuzhiyun 
h3600_lcd_request(void)34*4882a593Smuzhiyun static bool h3600_lcd_request(void)
35*4882a593Smuzhiyun {
36*4882a593Smuzhiyun 	static bool h3600_lcd_ok;
37*4882a593Smuzhiyun 	int rc;
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun 	if (h3600_lcd_ok)
40*4882a593Smuzhiyun 		return true;
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun 	rc = gpio_request_array(h3600_lcd_gpio, ARRAY_SIZE(h3600_lcd_gpio));
43*4882a593Smuzhiyun 	if (rc)
44*4882a593Smuzhiyun 		pr_err("%s: can't request GPIOs\n", __func__);
45*4882a593Smuzhiyun 	else
46*4882a593Smuzhiyun 		h3600_lcd_ok = true;
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun 	return h3600_lcd_ok;
49*4882a593Smuzhiyun }
50*4882a593Smuzhiyun 
h3600_lcd_power(int enable)51*4882a593Smuzhiyun static void h3600_lcd_power(int enable)
52*4882a593Smuzhiyun {
53*4882a593Smuzhiyun 	if (!h3600_lcd_request())
54*4882a593Smuzhiyun 		return;
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun 	gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
57*4882a593Smuzhiyun 	gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
58*4882a593Smuzhiyun 	gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
59*4882a593Smuzhiyun 	gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
60*4882a593Smuzhiyun }
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun static const struct sa1100fb_rgb h3600_rgb_16 = {
63*4882a593Smuzhiyun 	.red	= { .offset = 12, .length = 4, },
64*4882a593Smuzhiyun 	.green	= { .offset = 7,  .length = 4, },
65*4882a593Smuzhiyun 	.blue	= { .offset = 1,  .length = 4, },
66*4882a593Smuzhiyun 	.transp	= { .offset = 0,  .length = 0, },
67*4882a593Smuzhiyun };
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun static struct sa1100fb_mach_info h3600_lcd_info = {
70*4882a593Smuzhiyun 	.pixclock	= 174757, 	.bpp		= 16,
71*4882a593Smuzhiyun 	.xres		= 320,		.yres		= 240,
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun 	.hsync_len	= 3,		.vsync_len	= 3,
74*4882a593Smuzhiyun 	.left_margin	= 12,		.upper_margin	= 10,
75*4882a593Smuzhiyun 	.right_margin	= 17,		.lower_margin	= 1,
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun 	.cmap_static	= 1,
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun 	.lccr0		= LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
80*4882a593Smuzhiyun 	.lccr3		= LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun 	.rgb[RGB_16] = &h3600_rgb_16,
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun 	.lcd_power = h3600_lcd_power,
85*4882a593Smuzhiyun };
86*4882a593Smuzhiyun 
87*4882a593Smuzhiyun 
h3600_map_io(void)88*4882a593Smuzhiyun static void __init h3600_map_io(void)
89*4882a593Smuzhiyun {
90*4882a593Smuzhiyun 	h3xxx_map_io();
91*4882a593Smuzhiyun }
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun /*
94*4882a593Smuzhiyun  * This turns the IRDA power on or off on the Compaq H3600
95*4882a593Smuzhiyun  */
96*4882a593Smuzhiyun static struct gpio h3600_irda_gpio[] = {
97*4882a593Smuzhiyun 	{ H3600_EGPIO_IR_ON,	GPIOF_OUT_INIT_LOW, "IrDA power" },
98*4882a593Smuzhiyun 	{ H3600_EGPIO_IR_FSEL,	GPIOF_OUT_INIT_LOW, "IrDA fsel" },
99*4882a593Smuzhiyun };
100*4882a593Smuzhiyun 
h3600_irda_set_power(struct device * dev,unsigned int state)101*4882a593Smuzhiyun static int h3600_irda_set_power(struct device *dev, unsigned int state)
102*4882a593Smuzhiyun {
103*4882a593Smuzhiyun 	gpio_set_value(H3600_EGPIO_IR_ON, state);
104*4882a593Smuzhiyun 	return 0;
105*4882a593Smuzhiyun }
106*4882a593Smuzhiyun 
h3600_irda_set_speed(struct device * dev,unsigned int speed)107*4882a593Smuzhiyun static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
108*4882a593Smuzhiyun {
109*4882a593Smuzhiyun 	gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
110*4882a593Smuzhiyun }
111*4882a593Smuzhiyun 
h3600_irda_startup(struct device * dev)112*4882a593Smuzhiyun static int h3600_irda_startup(struct device *dev)
113*4882a593Smuzhiyun {
114*4882a593Smuzhiyun 	return gpio_request_array(h3600_irda_gpio, sizeof(h3600_irda_gpio));
115*4882a593Smuzhiyun }
116*4882a593Smuzhiyun 
h3600_irda_shutdown(struct device * dev)117*4882a593Smuzhiyun static void h3600_irda_shutdown(struct device *dev)
118*4882a593Smuzhiyun {
119*4882a593Smuzhiyun 	return gpio_free_array(h3600_irda_gpio, sizeof(h3600_irda_gpio));
120*4882a593Smuzhiyun }
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun static struct irda_platform_data h3600_irda_data = {
123*4882a593Smuzhiyun 	.set_power	= h3600_irda_set_power,
124*4882a593Smuzhiyun 	.set_speed	= h3600_irda_set_speed,
125*4882a593Smuzhiyun 	.startup	= h3600_irda_startup,
126*4882a593Smuzhiyun 	.shutdown	= h3600_irda_shutdown,
127*4882a593Smuzhiyun };
128*4882a593Smuzhiyun 
h3600_mach_init(void)129*4882a593Smuzhiyun static void __init h3600_mach_init(void)
130*4882a593Smuzhiyun {
131*4882a593Smuzhiyun 	h3xxx_mach_init();
132*4882a593Smuzhiyun 
133*4882a593Smuzhiyun 	sa11x0_register_lcd(&h3600_lcd_info);
134*4882a593Smuzhiyun 	sa11x0_register_irda(&h3600_irda_data);
135*4882a593Smuzhiyun }
136*4882a593Smuzhiyun 
137*4882a593Smuzhiyun MACHINE_START(H3600, "Compaq iPAQ H3600")
138*4882a593Smuzhiyun 	.atag_offset	= 0x100,
139*4882a593Smuzhiyun 	.map_io		= h3600_map_io,
140*4882a593Smuzhiyun 	.nr_irqs	= SA1100_NR_IRQS,
141*4882a593Smuzhiyun 	.init_irq	= sa1100_init_irq,
142*4882a593Smuzhiyun 	.init_time	= sa1100_timer_init,
143*4882a593Smuzhiyun 	.init_machine	= h3600_mach_init,
144*4882a593Smuzhiyun 	.init_late	= sa11x0_init_late,
145*4882a593Smuzhiyun 	.restart	= sa11x0_restart,
146*4882a593Smuzhiyun MACHINE_END
147*4882a593Smuzhiyun 
148