Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 1 | /* |
Dmitry Artamonow | 6e23fcb | 2009-11-27 12:11:48 +0100 | [diff] [blame] | 2 | * Support for Compaq iPAQ H3100 handheld computer |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 3 | * |
Dmitry Artamonow | 6e23fcb | 2009-11-27 12:11:48 +0100 | [diff] [blame] | 4 | * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks) |
| 5 | * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru> |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 6 | * |
Dmitry Artamonow | 6e23fcb | 2009-11-27 12:11:48 +0100 | [diff] [blame] | 7 | * 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 Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 10 | * |
| 11 | */ |
Dmitry Artamonow | 6e23fcb | 2009-11-27 12:11:48 +0100 | [diff] [blame] | 12 | |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 13 | #include <linux/init.h> |
| 14 | #include <linux/kernel.h> |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 15 | #include <linux/gpio.h> |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 16 | |
Russell King | e1b7a72 | 2012-01-14 11:50:04 +0000 | [diff] [blame] | 17 | #include <video/sa1100fb.h> |
| 18 | |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 19 | #include <asm/mach-types.h> |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 20 | #include <asm/mach/arch.h> |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 21 | #include <asm/mach/irda.h> |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 22 | |
| 23 | #include <mach/h3xxx.h> |
Rob Herring | f314f33 | 2012-02-24 00:06:51 +0100 | [diff] [blame] | 24 | #include <mach/irqs.h> |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 25 | |
| 26 | #include "generic.h" |
| 27 | |
| 28 | /* |
| 29 | * helper for sa1100fb |
| 30 | */ |
Dmitry Eremin-Solenikov | 5f72d85e | 2013-11-26 11:09:01 +0100 | [diff] [blame] | 31 | static struct gpio h3100_lcd_gpio[] = { |
| 32 | { H3100_GPIO_LCD_3V_ON, GPIOF_OUT_INIT_LOW, "LCD 3V" }, |
| 33 | { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD ON" }, |
| 34 | }; |
| 35 | |
| 36 | static bool h3100_lcd_request(void) |
| 37 | { |
| 38 | static bool h3100_lcd_ok; |
| 39 | int rc; |
| 40 | |
| 41 | if (h3100_lcd_ok) |
| 42 | return true; |
| 43 | |
| 44 | rc = gpio_request_array(h3100_lcd_gpio, ARRAY_SIZE(h3100_lcd_gpio)); |
| 45 | if (rc) |
| 46 | pr_err("%s: can't request GPIOs\n", __func__); |
| 47 | else |
| 48 | h3100_lcd_ok = true; |
| 49 | |
| 50 | return h3100_lcd_ok; |
| 51 | } |
| 52 | |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 53 | static void h3100_lcd_power(int enable) |
| 54 | { |
Dmitry Eremin-Solenikov | 5f72d85e | 2013-11-26 11:09:01 +0100 | [diff] [blame] | 55 | if (!h3100_lcd_request()) |
| 56 | return; |
| 57 | |
| 58 | gpio_set_value(H3100_GPIO_LCD_3V_ON, enable); |
| 59 | gpio_set_value(H3XXX_EGPIO_LCD_ON, enable); |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 60 | } |
| 61 | |
Russell King | e1b7a72 | 2012-01-14 11:50:04 +0000 | [diff] [blame] | 62 | static struct sa1100fb_mach_info h3100_lcd_info = { |
| 63 | .pixclock = 406977, .bpp = 4, |
| 64 | .xres = 320, .yres = 240, |
| 65 | |
| 66 | .hsync_len = 26, .vsync_len = 41, |
| 67 | .left_margin = 4, .upper_margin = 0, |
| 68 | .right_margin = 4, .lower_margin = 0, |
| 69 | |
| 70 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 71 | .cmap_greyscale = 1, |
| 72 | .cmap_inverse = 1, |
| 73 | |
| 74 | .lccr0 = LCCR0_Mono | LCCR0_4PixMono | LCCR0_Sngl | LCCR0_Pas, |
| 75 | .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2), |
Russell King | 086ada5 | 2012-01-14 12:03:22 +0000 | [diff] [blame] | 76 | |
| 77 | .lcd_power = h3100_lcd_power, |
Russell King | e1b7a72 | 2012-01-14 11:50:04 +0000 | [diff] [blame] | 78 | }; |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 79 | |
| 80 | static void __init h3100_map_io(void) |
| 81 | { |
| 82 | h3xxx_map_io(); |
| 83 | |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 84 | /* Older bootldrs put GPIO2-9 in alternate mode on the |
| 85 | assumption that they are used for video */ |
| 86 | GAFR &= ~0x000001fb; |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | * This turns the IRDA power on or off on the Compaq H3100 |
| 91 | */ |
Dmitry Eremin-Solenikov | d8eec82 | 2013-11-26 11:10:10 +0100 | [diff] [blame] | 92 | static struct gpio h3100_irda_gpio[] = { |
| 93 | { H3100_GPIO_IR_ON, GPIOF_OUT_INIT_LOW, "IrDA power" }, |
| 94 | { H3100_GPIO_IR_FSEL, GPIOF_OUT_INIT_LOW, "IrDA fsel" }, |
| 95 | }; |
| 96 | |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 97 | static int h3100_irda_set_power(struct device *dev, unsigned int state) |
| 98 | { |
| 99 | gpio_set_value(H3100_GPIO_IR_ON, state); |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | static void h3100_irda_set_speed(struct device *dev, unsigned int speed) |
| 104 | { |
| 105 | gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000)); |
| 106 | } |
| 107 | |
Dmitry Eremin-Solenikov | d8eec82 | 2013-11-26 11:10:10 +0100 | [diff] [blame] | 108 | static int h3100_irda_startup(struct device *dev) |
| 109 | { |
| 110 | return gpio_request_array(h3100_irda_gpio, sizeof(h3100_irda_gpio)); |
| 111 | } |
| 112 | |
| 113 | static void h3100_irda_shutdown(struct device *dev) |
| 114 | { |
| 115 | return gpio_free_array(h3100_irda_gpio, sizeof(h3100_irda_gpio)); |
| 116 | } |
| 117 | |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 118 | static struct irda_platform_data h3100_irda_data = { |
| 119 | .set_power = h3100_irda_set_power, |
| 120 | .set_speed = h3100_irda_set_speed, |
Dmitry Eremin-Solenikov | d8eec82 | 2013-11-26 11:10:10 +0100 | [diff] [blame] | 121 | .startup = h3100_irda_startup, |
| 122 | .shutdown = h3100_irda_shutdown, |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | static struct gpio_default_state h3100_default_gpio[] = { |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 126 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, |
| 127 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, |
| 128 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | static void __init h3100_mach_init(void) |
| 132 | { |
| 133 | h3xxx_init_gpio(h3100_default_gpio, ARRAY_SIZE(h3100_default_gpio)); |
| 134 | h3xxx_mach_init(); |
Russell King | e1b7a72 | 2012-01-14 11:50:04 +0000 | [diff] [blame] | 135 | |
Russell King | e1b7a72 | 2012-01-14 11:50:04 +0000 | [diff] [blame] | 136 | sa11x0_register_lcd(&h3100_lcd_info); |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 137 | sa11x0_register_irda(&h3100_irda_data); |
| 138 | } |
| 139 | |
| 140 | MACHINE_START(H3100, "Compaq iPAQ H3100") |
Nicolas Pitre | 17f4425 | 2011-07-05 22:38:17 -0400 | [diff] [blame] | 141 | .atag_offset = 0x100, |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 142 | .map_io = h3100_map_io, |
Rob Herring | f314f33 | 2012-02-24 00:06:51 +0100 | [diff] [blame] | 143 | .nr_irqs = SA1100_NR_IRQS, |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 144 | .init_irq = sa1100_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 145 | .init_time = sa1100_timer_init, |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 146 | .init_machine = h3100_mach_init, |
Shawn Guo | 7fea1ba | 2012-04-26 21:22:45 +0800 | [diff] [blame] | 147 | .init_late = sa11x0_init_late, |
Russell King | d9ca583 | 2011-11-05 10:28:50 +0000 | [diff] [blame] | 148 | .restart = sa11x0_restart, |
Dmitry Artamonow | 86e5e38 | 2009-11-27 12:10:55 +0100 | [diff] [blame] | 149 | MACHINE_END |
| 150 | |