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