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