1 /* 2 * Hardware definitions for Compaq iPAQ H3xxx Handheld Computers 3 * 4 * Copyright 2000,1 Compaq Computer Corporation. 5 * 6 * Use consistent with the GNU GPL is permitted, 7 * provided that this copyright notice is 8 * preserved in its entirety in all copies and derived works. 9 * 10 * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED, 11 * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS 12 * FITNESS FOR ANY PARTICULAR PURPOSE. 13 * 14 * Author: Jamey Hicks. 15 * 16 * History: 17 * 18 * 2001-10-?? Andrew Christian Added support for iPAQ H3800 19 * and abstracted EGPIO interface. 20 * 21 */ 22 #include <linux/module.h> 23 #include <linux/init.h> 24 #include <linux/kernel.h> 25 #include <linux/tty.h> 26 #include <linux/pm.h> 27 #include <linux/device.h> 28 #include <linux/mfd/htc-egpio.h> 29 #include <linux/mtd/mtd.h> 30 #include <linux/mtd/partitions.h> 31 #include <linux/serial_core.h> 32 #include <linux/gpio.h> 33 #include <linux/platform_device.h> 34 35 #include <asm/irq.h> 36 #include <mach/hardware.h> 37 #include <asm/mach-types.h> 38 #include <asm/setup.h> 39 40 #include <asm/mach/irq.h> 41 #include <asm/mach/arch.h> 42 #include <asm/mach/flash.h> 43 #include <asm/mach/irda.h> 44 #include <asm/mach/map.h> 45 #include <asm/mach/serial_sa1100.h> 46 47 #include <mach/h3xxx.h> 48 49 #include "generic.h" 50 51 /* 52 * helper for sa1100fb 53 */ 54 static void h3600_lcd_power(int enable) 55 { 56 if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power")) 57 goto err1; 58 if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control")) 59 goto err2; 60 if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v")) 61 goto err3; 62 if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v")) 63 goto err4; 64 65 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable); 66 gpio_direction_output(H3600_EGPIO_LCD_PCI, enable); 67 gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable); 68 gpio_direction_output(H3600_EGPIO_LVDD_ON, enable); 69 70 gpio_free(H3600_EGPIO_LVDD_ON); 71 err4: gpio_free(H3600_EGPIO_LCD_5V_ON); 72 err3: gpio_free(H3600_EGPIO_LCD_PCI); 73 err2: gpio_free(H3XXX_EGPIO_LCD_ON); 74 err1: return; 75 } 76 77 static void __init h3600_map_io(void) 78 { 79 h3xxx_map_io(); 80 81 sa1100fb_lcd_power = h3600_lcd_power; 82 } 83 84 /* 85 * This turns the IRDA power on or off on the Compaq H3600 86 */ 87 static int h3600_irda_set_power(struct device *dev, unsigned int state) 88 { 89 gpio_set_value(H3600_EGPIO_IR_ON, state); 90 return 0; 91 } 92 93 static void h3600_irda_set_speed(struct device *dev, unsigned int speed) 94 { 95 gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000)); 96 } 97 98 static int h3600_irda_startup(struct device *dev) 99 { 100 int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power"); 101 if (err) 102 goto err1; 103 err = gpio_direction_output(H3600_EGPIO_IR_ON, 0); 104 if (err) 105 goto err2; 106 err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel"); 107 if (err) 108 goto err2; 109 err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0); 110 if (err) 111 goto err3; 112 return 0; 113 114 err3: gpio_free(H3600_EGPIO_IR_FSEL); 115 err2: gpio_free(H3600_EGPIO_IR_ON); 116 err1: return err; 117 } 118 119 static void h3600_irda_shutdown(struct device *dev) 120 { 121 gpio_free(H3600_EGPIO_IR_ON); 122 gpio_free(H3600_EGPIO_IR_FSEL); 123 } 124 125 static struct irda_platform_data h3600_irda_data = { 126 .set_power = h3600_irda_set_power, 127 .set_speed = h3600_irda_set_speed, 128 .startup = h3600_irda_startup, 129 .shutdown = h3600_irda_shutdown, 130 }; 131 132 static struct gpio_default_state h3600_default_gpio[] = { 133 { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, 134 { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, 135 { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, 136 }; 137 138 static void __init h3600_mach_init(void) 139 { 140 h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio)); 141 h3xxx_mach_init(); 142 sa11x0_register_irda(&h3600_irda_data); 143 } 144 145 MACHINE_START(H3600, "Compaq iPAQ H3600") 146 .phys_io = 0x80000000, 147 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc, 148 .boot_params = 0xc0000100, 149 .map_io = h3600_map_io, 150 .init_irq = sa1100_init_irq, 151 .timer = &sa1100_timer, 152 .init_machine = h3600_mach_init, 153 MACHINE_END 154 155