blob: f23e7d0b2fba3d3ed0d2e4a27fdca0e33f596f7e [file] [log] [blame]
Dmitry Artamonow86e5e382009-11-27 12:10:55 +01001/*
Dmitry Artamonow6e23fcb2009-11-27 12:11:48 +01002 * Support for Compaq iPAQ H3100 handheld computer
Dmitry Artamonow86e5e382009-11-27 12:10:55 +01003 *
Dmitry Artamonow6e23fcb2009-11-27 12:11:48 +01004 * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
5 * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru>
Dmitry Artamonow86e5e382009-11-27 12:10:55 +01006 *
Dmitry Artamonow6e23fcb2009-11-27 12:11:48 +01007 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010010 *
11 */
Dmitry Artamonow6e23fcb2009-11-27 12:11:48 +010012
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010013#include <linux/init.h>
14#include <linux/kernel.h>
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010015#include <linux/gpio.h>
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010016
Russell Kinge1b7a722012-01-14 11:50:04 +000017#include <video/sa1100fb.h>
18
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010019#include <asm/mach-types.h>
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010020#include <asm/mach/arch.h>
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010021#include <asm/mach/irda.h>
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010022
23#include <mach/h3xxx.h>
24
25#include "generic.h"
26
27/*
28 * helper for sa1100fb
29 */
30static void h3100_lcd_power(int enable)
31{
32 if (!gpio_request(H3XXX_EGPIO_LCD_ON, "LCD ON")) {
33 gpio_set_value(H3100_GPIO_LCD_3V_ON, enable);
34 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
35 gpio_free(H3XXX_EGPIO_LCD_ON);
Dmitry Artamonow729fae42009-11-27 12:22:32 +010036 } else {
37 pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__);
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010038 }
39}
40
Russell Kinge1b7a722012-01-14 11:50:04 +000041static struct sa1100fb_mach_info h3100_lcd_info = {
42 .pixclock = 406977, .bpp = 4,
43 .xres = 320, .yres = 240,
44
45 .hsync_len = 26, .vsync_len = 41,
46 .left_margin = 4, .upper_margin = 0,
47 .right_margin = 4, .lower_margin = 0,
48
49 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
50 .cmap_greyscale = 1,
51 .cmap_inverse = 1,
52
53 .lccr0 = LCCR0_Mono | LCCR0_4PixMono | LCCR0_Sngl | LCCR0_Pas,
54 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
Russell King086ada52012-01-14 12:03:22 +000055
56 .lcd_power = h3100_lcd_power,
Russell Kinge1b7a722012-01-14 11:50:04 +000057};
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010058
59static void __init h3100_map_io(void)
60{
61 h3xxx_map_io();
62
Dmitry Artamonow86e5e382009-11-27 12:10:55 +010063 /* Older bootldrs put GPIO2-9 in alternate mode on the
64 assumption that they are used for video */
65 GAFR &= ~0x000001fb;
66}
67
68/*
69 * This turns the IRDA power on or off on the Compaq H3100
70 */
71static int h3100_irda_set_power(struct device *dev, unsigned int state)
72{
73 gpio_set_value(H3100_GPIO_IR_ON, state);
74 return 0;
75}
76
77static void h3100_irda_set_speed(struct device *dev, unsigned int speed)
78{
79 gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000));
80}
81
82static struct irda_platform_data h3100_irda_data = {
83 .set_power = h3100_irda_set_power,
84 .set_speed = h3100_irda_set_speed,
85};
86
87static struct gpio_default_state h3100_default_gpio[] = {
88 { H3100_GPIO_IR_ON, GPIO_MODE_OUT0, "IrDA power" },
89 { H3100_GPIO_IR_FSEL, GPIO_MODE_OUT0, "IrDA fsel" },
90 { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
91 { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
92 { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
93 { H3100_GPIO_LCD_3V_ON, GPIO_MODE_OUT0, "LCD 3v" },
94};
95
96static void __init h3100_mach_init(void)
97{
98 h3xxx_init_gpio(h3100_default_gpio, ARRAY_SIZE(h3100_default_gpio));
99 h3xxx_mach_init();
Russell Kinge1b7a722012-01-14 11:50:04 +0000100
Russell Kinge1b7a722012-01-14 11:50:04 +0000101 sa11x0_register_lcd(&h3100_lcd_info);
Dmitry Artamonow86e5e382009-11-27 12:10:55 +0100102 sa11x0_register_irda(&h3100_irda_data);
103}
104
105MACHINE_START(H3100, "Compaq iPAQ H3100")
Nicolas Pitre17f44252011-07-05 22:38:17 -0400106 .atag_offset = 0x100,
Dmitry Artamonow86e5e382009-11-27 12:10:55 +0100107 .map_io = h3100_map_io,
108 .init_irq = sa1100_init_irq,
109 .timer = &sa1100_timer,
110 .init_machine = h3100_mach_init,
Russell Kingd9ca5832011-11-05 10:28:50 +0000111 .restart = sa11x0_restart,
Dmitry Artamonow86e5e382009-11-27 12:10:55 +0100112MACHINE_END
113