Linux 5.7.6
[linux/fpc-iii.git] / arch / arm / mach-sa1100 / h3100.c
blob51eaeeaf3f10d73255c08642bff28095f4c0da66
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Support for Compaq iPAQ H3100 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 h3100_lcd_gpio[] = {
28 { H3100_GPIO_LCD_3V_ON, GPIOF_OUT_INIT_LOW, "LCD 3V" },
29 { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD ON" },
32 static bool h3100_lcd_request(void)
34 static bool h3100_lcd_ok;
35 int rc;
37 if (h3100_lcd_ok)
38 return true;
40 rc = gpio_request_array(h3100_lcd_gpio, ARRAY_SIZE(h3100_lcd_gpio));
41 if (rc)
42 pr_err("%s: can't request GPIOs\n", __func__);
43 else
44 h3100_lcd_ok = true;
46 return h3100_lcd_ok;
49 static void h3100_lcd_power(int enable)
51 if (!h3100_lcd_request())
52 return;
54 gpio_set_value(H3100_GPIO_LCD_3V_ON, enable);
55 gpio_set_value(H3XXX_EGPIO_LCD_ON, enable);
58 static struct sa1100fb_mach_info h3100_lcd_info = {
59 .pixclock = 406977, .bpp = 4,
60 .xres = 320, .yres = 240,
62 .hsync_len = 26, .vsync_len = 41,
63 .left_margin = 4, .upper_margin = 0,
64 .right_margin = 4, .lower_margin = 0,
66 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
67 .cmap_greyscale = 1,
68 .cmap_inverse = 1,
70 .lccr0 = LCCR0_Mono | LCCR0_4PixMono | LCCR0_Sngl | LCCR0_Pas,
71 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
73 .lcd_power = h3100_lcd_power,
76 static void __init h3100_map_io(void)
78 h3xxx_map_io();
80 /* Older bootldrs put GPIO2-9 in alternate mode on the
81 assumption that they are used for video */
82 GAFR &= ~0x000001fb;
86 * This turns the IRDA power on or off on the Compaq H3100
88 static struct gpio h3100_irda_gpio[] = {
89 { H3100_GPIO_IR_ON, GPIOF_OUT_INIT_LOW, "IrDA power" },
90 { H3100_GPIO_IR_FSEL, GPIOF_OUT_INIT_LOW, "IrDA fsel" },
93 static int h3100_irda_set_power(struct device *dev, unsigned int state)
95 gpio_set_value(H3100_GPIO_IR_ON, state);
96 return 0;
99 static void h3100_irda_set_speed(struct device *dev, unsigned int speed)
101 gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000));
104 static int h3100_irda_startup(struct device *dev)
106 return gpio_request_array(h3100_irda_gpio, sizeof(h3100_irda_gpio));
109 static void h3100_irda_shutdown(struct device *dev)
111 return gpio_free_array(h3100_irda_gpio, sizeof(h3100_irda_gpio));
114 static struct irda_platform_data h3100_irda_data = {
115 .set_power = h3100_irda_set_power,
116 .set_speed = h3100_irda_set_speed,
117 .startup = h3100_irda_startup,
118 .shutdown = h3100_irda_shutdown,
121 static void __init h3100_mach_init(void)
123 h3xxx_mach_init();
125 sa11x0_register_pcmcia(-1, NULL);
126 sa11x0_register_lcd(&h3100_lcd_info);
127 sa11x0_register_irda(&h3100_irda_data);
130 MACHINE_START(H3100, "Compaq iPAQ H3100")
131 .atag_offset = 0x100,
132 .map_io = h3100_map_io,
133 .nr_irqs = SA1100_NR_IRQS,
134 .init_irq = sa1100_init_irq,
135 .init_time = sa1100_timer_init,
136 .init_machine = h3100_mach_init,
137 .init_late = sa11x0_init_late,
138 .restart = sa11x0_restart,
139 MACHINE_END