Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1 | /* |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 2 | * Front panel driver for Linux |
| 3 | * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu> |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 4 | * Copyright (C) 2016-2017 Glider bvba |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 5 | * |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 10 | * |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 11 | * This code drives an LCD module (/dev/lcd), and a keypad (/dev/keypad) |
| 12 | * connected to a parallel printer port. |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 13 | * |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 14 | * The LCD module may either be an HD44780-like 8-bit parallel LCD, or a 1-bit |
| 15 | * serial module compatible with Samsung's KS0074. The pins may be connected in |
| 16 | * any combination, everything is programmable. |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 17 | * |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 18 | * The keypad consists in a matrix of push buttons connecting input pins to |
| 19 | * data output pins or to the ground. The combinations have to be hard-coded |
| 20 | * in the driver, though several profiles exist and adding new ones is easy. |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 21 | * |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 22 | * Several profiles are provided for commonly found LCD+keypad modules on the |
| 23 | * market, such as those found in Nexcom's appliances. |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 24 | * |
| 25 | * FIXME: |
| 26 | * - the initialization/deinitialization process is very dirty and should |
| 27 | * be rewritten. It may even be buggy. |
| 28 | * |
| 29 | * TODO: |
| 30 | * - document 24 keys keyboard (3 rows of 8 cols, 32 diodes + 2 inputs) |
| 31 | * - make the LCD a part of a virtual screen of Vx*Vy |
| 32 | * - make the inputs list smp-safe |
| 33 | * - change the keyboard to a double mapping : signals -> key_id -> values |
| 34 | * so that applications can change values without knowing signals |
| 35 | * |
| 36 | */ |
| 37 | |
Toshiaki Yamane | 493aa89 | 2012-07-12 22:01:00 +0900 | [diff] [blame] | 38 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 39 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 40 | #include <linux/module.h> |
| 41 | |
| 42 | #include <linux/types.h> |
| 43 | #include <linux/errno.h> |
| 44 | #include <linux/signal.h> |
| 45 | #include <linux/sched.h> |
| 46 | #include <linux/spinlock.h> |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 47 | #include <linux/interrupt.h> |
| 48 | #include <linux/miscdevice.h> |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 49 | #include <linux/slab.h> |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 50 | #include <linux/ioport.h> |
| 51 | #include <linux/fcntl.h> |
| 52 | #include <linux/init.h> |
| 53 | #include <linux/delay.h> |
Andy Shevchenko | d85170e | 2010-07-22 19:57:08 +0300 | [diff] [blame] | 54 | #include <linux/kernel.h> |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 55 | #include <linux/ctype.h> |
| 56 | #include <linux/parport.h> |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 57 | #include <linux/list.h> |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 58 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 59 | #include <linux/io.h> |
Takanori Suzuki | 48f658b | 2010-05-08 22:56:24 +0900 | [diff] [blame] | 60 | #include <linux/uaccess.h> |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 61 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 62 | #include <misc/charlcd.h> |
| 63 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 64 | #define KEYPAD_MINOR 185 |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 65 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 66 | #define LCD_MAXBYTES 256 /* max burst write */ |
| 67 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 68 | #define KEYPAD_BUFFER 64 |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 69 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 70 | /* poll the keyboard this every second */ |
Sirnam Swetha | 2b3c9eb | 2015-10-27 14:54:51 +0530 | [diff] [blame] | 71 | #define INPUT_POLL_TIME (HZ / 50) |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 72 | /* a key starts to repeat after this times INPUT_POLL_TIME */ |
| 73 | #define KEYPAD_REP_START (10) |
| 74 | /* a key repeats this times INPUT_POLL_TIME */ |
| 75 | #define KEYPAD_REP_DELAY (2) |
| 76 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 77 | /* converts an r_str() input to an active high, bits string : 000BAOSE */ |
| 78 | #define PNL_PINPUT(a) ((((unsigned char)(a)) ^ 0x7F) >> 3) |
| 79 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 80 | #define PNL_PBUSY 0x80 /* inverted input, active low */ |
| 81 | #define PNL_PACK 0x40 /* direct input, active low */ |
| 82 | #define PNL_POUTPA 0x20 /* direct input, active high */ |
| 83 | #define PNL_PSELECD 0x10 /* direct input, active high */ |
| 84 | #define PNL_PERRORP 0x08 /* direct input, active low */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 85 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 86 | #define PNL_PBIDIR 0x20 /* bi-directional ports */ |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 87 | /* high to read data in or-ed with data out */ |
| 88 | #define PNL_PINTEN 0x10 |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 89 | #define PNL_PSELECP 0x08 /* inverted output, active low */ |
| 90 | #define PNL_PINITP 0x04 /* direct output, active low */ |
| 91 | #define PNL_PAUTOLF 0x02 /* inverted output, active low */ |
| 92 | #define PNL_PSTROBE 0x01 /* inverted output */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 93 | |
| 94 | #define PNL_PD0 0x01 |
| 95 | #define PNL_PD1 0x02 |
| 96 | #define PNL_PD2 0x04 |
| 97 | #define PNL_PD3 0x08 |
| 98 | #define PNL_PD4 0x10 |
| 99 | #define PNL_PD5 0x20 |
| 100 | #define PNL_PD6 0x40 |
| 101 | #define PNL_PD7 0x80 |
| 102 | |
| 103 | #define PIN_NONE 0 |
| 104 | #define PIN_STROBE 1 |
| 105 | #define PIN_D0 2 |
| 106 | #define PIN_D1 3 |
| 107 | #define PIN_D2 4 |
| 108 | #define PIN_D3 5 |
| 109 | #define PIN_D4 6 |
| 110 | #define PIN_D5 7 |
| 111 | #define PIN_D6 8 |
| 112 | #define PIN_D7 9 |
| 113 | #define PIN_AUTOLF 14 |
| 114 | #define PIN_INITP 16 |
| 115 | #define PIN_SELECP 17 |
| 116 | #define PIN_NOT_SET 127 |
| 117 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 118 | #define NOT_SET -1 |
| 119 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 120 | /* macros to simplify use of the parallel port */ |
| 121 | #define r_ctr(x) (parport_read_control((x)->port)) |
| 122 | #define r_dtr(x) (parport_read_data((x)->port)) |
| 123 | #define r_str(x) (parport_read_status((x)->port)) |
Toshiaki Yamane | 6ebb56d | 2012-07-25 12:18:12 +0900 | [diff] [blame] | 124 | #define w_ctr(x, y) (parport_write_control((x)->port, (y))) |
| 125 | #define w_dtr(x, y) (parport_write_data((x)->port, (y))) |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 126 | |
| 127 | /* this defines which bits are to be used and which ones to be ignored */ |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 128 | /* logical or of the output bits involved in the scan matrix */ |
| 129 | static __u8 scan_mask_o; |
| 130 | /* logical or of the input bits involved in the scan matrix */ |
| 131 | static __u8 scan_mask_i; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 132 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 133 | enum input_type { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 134 | INPUT_TYPE_STD, |
| 135 | INPUT_TYPE_KBD, |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | enum input_state { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 139 | INPUT_ST_LOW, |
| 140 | INPUT_ST_RISING, |
| 141 | INPUT_ST_HIGH, |
| 142 | INPUT_ST_FALLING, |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | struct logical_input { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 146 | struct list_head list; |
Ksenija Stanojevic | 35fe087 | 2016-01-03 20:40:58 +0100 | [diff] [blame] | 147 | __u64 mask; |
| 148 | __u64 value; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 149 | enum input_type type; |
| 150 | enum input_state state; |
| 151 | __u8 rise_time, fall_time; |
| 152 | __u8 rise_timer, fall_timer, high_timer; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 153 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 154 | union { |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 155 | struct { /* valid when type == INPUT_TYPE_STD */ |
Monam Agarwal | 68d386b | 2014-02-25 19:40:49 +0530 | [diff] [blame] | 156 | void (*press_fct)(int); |
| 157 | void (*release_fct)(int); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 158 | int press_data; |
| 159 | int release_data; |
| 160 | } std; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 161 | struct { /* valid when type == INPUT_TYPE_KBD */ |
| 162 | /* strings can be non null-terminated */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 163 | char press_str[sizeof(void *) + sizeof(int)]; |
| 164 | char repeat_str[sizeof(void *) + sizeof(int)]; |
| 165 | char release_str[sizeof(void *) + sizeof(int)]; |
| 166 | } kbd; |
| 167 | } u; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 168 | }; |
| 169 | |
Peter Huewe | 36d2041 | 2013-02-15 13:47:05 +0100 | [diff] [blame] | 170 | static LIST_HEAD(logical_inputs); /* list of all defined logical inputs */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 171 | |
| 172 | /* physical contacts history |
| 173 | * Physical contacts are a 45 bits string of 9 groups of 5 bits each. |
| 174 | * The 8 lower groups correspond to output bits 0 to 7, and the 9th group |
| 175 | * corresponds to the ground. |
| 176 | * Within each group, bits are stored in the same order as read on the port : |
| 177 | * BAPSE (busy=4, ack=3, paper empty=2, select=1, error=0). |
Ksenija Stanojevic | 35fe087 | 2016-01-03 20:40:58 +0100 | [diff] [blame] | 178 | * So, each __u64 is represented like this : |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 179 | * 0000000000000000000BAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSE |
| 180 | * <-----unused------><gnd><d07><d06><d05><d04><d03><d02><d01><d00> |
| 181 | */ |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 182 | |
| 183 | /* what has just been read from the I/O ports */ |
Ksenija Stanojevic | 35fe087 | 2016-01-03 20:40:58 +0100 | [diff] [blame] | 184 | static __u64 phys_read; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 185 | /* previous phys_read */ |
Ksenija Stanojevic | 35fe087 | 2016-01-03 20:40:58 +0100 | [diff] [blame] | 186 | static __u64 phys_read_prev; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 187 | /* stabilized phys_read (phys_read|phys_read_prev) */ |
Ksenija Stanojevic | 35fe087 | 2016-01-03 20:40:58 +0100 | [diff] [blame] | 188 | static __u64 phys_curr; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 189 | /* previous phys_curr */ |
Ksenija Stanojevic | 35fe087 | 2016-01-03 20:40:58 +0100 | [diff] [blame] | 190 | static __u64 phys_prev; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 191 | /* 0 means that at least one logical signal needs be computed */ |
| 192 | static char inputs_stable; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 193 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 194 | /* these variables are specific to the keypad */ |
Mariusz Gorski | a8b2580 | 2014-11-27 22:36:49 +0100 | [diff] [blame] | 195 | static struct { |
| 196 | bool enabled; |
| 197 | } keypad; |
| 198 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 199 | static char keypad_buffer[KEYPAD_BUFFER]; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 200 | static int keypad_buflen; |
| 201 | static int keypad_start; |
| 202 | static char keypressed; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 203 | static wait_queue_head_t keypad_read_wait; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 204 | |
| 205 | /* lcd-specific variables */ |
Mariusz Gorski | a8b2580 | 2014-11-27 22:36:49 +0100 | [diff] [blame] | 206 | static struct { |
| 207 | bool enabled; |
Mariusz Gorski | 6d8b588 | 2014-11-27 22:36:53 +0100 | [diff] [blame] | 208 | bool initialized; |
Mariusz Gorski | 6d8b588 | 2014-11-27 22:36:53 +0100 | [diff] [blame] | 209 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 210 | int charset; |
| 211 | int proto; |
Geert Uytterhoeven | fda4ae1 | 2017-02-06 15:38:10 +0100 | [diff] [blame] | 212 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 213 | /* TODO: use union here? */ |
| 214 | struct { |
| 215 | int e; |
| 216 | int rs; |
| 217 | int rw; |
| 218 | int cl; |
| 219 | int da; |
| 220 | int bl; |
| 221 | } pins; |
Mariusz Gorski | 6d8b588 | 2014-11-27 22:36:53 +0100 | [diff] [blame] | 222 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 223 | struct charlcd *charlcd; |
Mariusz Gorski | a8b2580 | 2014-11-27 22:36:49 +0100 | [diff] [blame] | 224 | } lcd; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 225 | |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 226 | /* Needed only for init */ |
| 227 | static int selected_lcd_type = NOT_SET; |
| 228 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 229 | /* |
| 230 | * Bit masks to convert LCD signals to parallel port outputs. |
| 231 | * _d_ are values for data port, _c_ are for control port. |
| 232 | * [0] = signal OFF, [1] = signal ON, [2] = mask |
| 233 | */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 234 | #define BIT_CLR 0 |
| 235 | #define BIT_SET 1 |
| 236 | #define BIT_MSK 2 |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 237 | #define BIT_STATES 3 |
| 238 | /* |
| 239 | * one entry for each bit on the LCD |
| 240 | */ |
| 241 | #define LCD_BIT_E 0 |
| 242 | #define LCD_BIT_RS 1 |
| 243 | #define LCD_BIT_RW 2 |
| 244 | #define LCD_BIT_BL 3 |
| 245 | #define LCD_BIT_CL 4 |
| 246 | #define LCD_BIT_DA 5 |
| 247 | #define LCD_BITS 6 |
| 248 | |
| 249 | /* |
| 250 | * each bit can be either connected to a DATA or CTRL port |
| 251 | */ |
| 252 | #define LCD_PORT_C 0 |
| 253 | #define LCD_PORT_D 1 |
| 254 | #define LCD_PORTS 2 |
| 255 | |
| 256 | static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; |
| 257 | |
| 258 | /* |
| 259 | * LCD protocols |
| 260 | */ |
| 261 | #define LCD_PROTO_PARALLEL 0 |
| 262 | #define LCD_PROTO_SERIAL 1 |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 263 | #define LCD_PROTO_TI_DA8XX_LCD 2 |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 264 | |
| 265 | /* |
| 266 | * LCD character sets |
| 267 | */ |
| 268 | #define LCD_CHARSET_NORMAL 0 |
| 269 | #define LCD_CHARSET_KS0074 1 |
| 270 | |
| 271 | /* |
| 272 | * LCD types |
| 273 | */ |
| 274 | #define LCD_TYPE_NONE 0 |
Sudip Mukherjee | 2c20d92 | 2015-03-24 16:29:32 +0530 | [diff] [blame] | 275 | #define LCD_TYPE_CUSTOM 1 |
| 276 | #define LCD_TYPE_OLD 2 |
| 277 | #define LCD_TYPE_KS0074 3 |
| 278 | #define LCD_TYPE_HANTRONIX 4 |
| 279 | #define LCD_TYPE_NEXCOM 5 |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 280 | |
| 281 | /* |
| 282 | * keypad types |
| 283 | */ |
| 284 | #define KEYPAD_TYPE_NONE 0 |
| 285 | #define KEYPAD_TYPE_OLD 1 |
| 286 | #define KEYPAD_TYPE_NEW 2 |
| 287 | #define KEYPAD_TYPE_NEXCOM 3 |
| 288 | |
| 289 | /* |
| 290 | * panel profiles |
| 291 | */ |
| 292 | #define PANEL_PROFILE_CUSTOM 0 |
| 293 | #define PANEL_PROFILE_OLD 1 |
| 294 | #define PANEL_PROFILE_NEW 2 |
| 295 | #define PANEL_PROFILE_HANTRONIX 3 |
| 296 | #define PANEL_PROFILE_NEXCOM 4 |
| 297 | #define PANEL_PROFILE_LARGE 5 |
| 298 | |
| 299 | /* |
| 300 | * Construct custom config from the kernel's configuration |
| 301 | */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 302 | #define DEFAULT_PARPORT 0 |
Mariusz Gorski | fe4d7e2 | 2014-11-12 02:08:06 +0100 | [diff] [blame] | 303 | #define DEFAULT_PROFILE PANEL_PROFILE_LARGE |
Mariusz Gorski | 98fac3d | 2014-11-12 02:08:09 +0100 | [diff] [blame] | 304 | #define DEFAULT_KEYPAD_TYPE KEYPAD_TYPE_OLD |
| 305 | #define DEFAULT_LCD_TYPE LCD_TYPE_OLD |
Mariusz Gorski | fe4d7e2 | 2014-11-12 02:08:06 +0100 | [diff] [blame] | 306 | #define DEFAULT_LCD_HEIGHT 2 |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 307 | #define DEFAULT_LCD_WIDTH 40 |
| 308 | #define DEFAULT_LCD_BWIDTH 40 |
| 309 | #define DEFAULT_LCD_HWIDTH 64 |
Mariusz Gorski | fe4d7e2 | 2014-11-12 02:08:06 +0100 | [diff] [blame] | 310 | #define DEFAULT_LCD_CHARSET LCD_CHARSET_NORMAL |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 311 | #define DEFAULT_LCD_PROTO LCD_PROTO_PARALLEL |
| 312 | |
| 313 | #define DEFAULT_LCD_PIN_E PIN_AUTOLF |
| 314 | #define DEFAULT_LCD_PIN_RS PIN_SELECP |
| 315 | #define DEFAULT_LCD_PIN_RW PIN_INITP |
| 316 | #define DEFAULT_LCD_PIN_SCL PIN_STROBE |
| 317 | #define DEFAULT_LCD_PIN_SDA PIN_D0 |
| 318 | #define DEFAULT_LCD_PIN_BL PIN_NOT_SET |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 319 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 320 | #ifdef CONFIG_PANEL_PARPORT |
| 321 | #undef DEFAULT_PARPORT |
| 322 | #define DEFAULT_PARPORT CONFIG_PANEL_PARPORT |
| 323 | #endif |
| 324 | |
Mariusz Gorski | 1e13e8a | 2014-11-12 02:08:07 +0100 | [diff] [blame] | 325 | #ifdef CONFIG_PANEL_PROFILE |
| 326 | #undef DEFAULT_PROFILE |
| 327 | #define DEFAULT_PROFILE CONFIG_PANEL_PROFILE |
| 328 | #endif |
| 329 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 330 | #if DEFAULT_PROFILE == 0 /* custom */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 331 | #ifdef CONFIG_PANEL_KEYPAD |
Mariusz Gorski | 98fac3d | 2014-11-12 02:08:09 +0100 | [diff] [blame] | 332 | #undef DEFAULT_KEYPAD_TYPE |
| 333 | #define DEFAULT_KEYPAD_TYPE CONFIG_PANEL_KEYPAD |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 334 | #endif |
| 335 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 336 | #ifdef CONFIG_PANEL_LCD |
Mariusz Gorski | 98fac3d | 2014-11-12 02:08:09 +0100 | [diff] [blame] | 337 | #undef DEFAULT_LCD_TYPE |
| 338 | #define DEFAULT_LCD_TYPE CONFIG_PANEL_LCD |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 339 | #endif |
| 340 | |
Mariusz Gorski | 1e13e8a | 2014-11-12 02:08:07 +0100 | [diff] [blame] | 341 | #ifdef CONFIG_PANEL_LCD_HEIGHT |
| 342 | #undef DEFAULT_LCD_HEIGHT |
| 343 | #define DEFAULT_LCD_HEIGHT CONFIG_PANEL_LCD_HEIGHT |
| 344 | #endif |
| 345 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 346 | #ifdef CONFIG_PANEL_LCD_WIDTH |
| 347 | #undef DEFAULT_LCD_WIDTH |
| 348 | #define DEFAULT_LCD_WIDTH CONFIG_PANEL_LCD_WIDTH |
| 349 | #endif |
| 350 | |
| 351 | #ifdef CONFIG_PANEL_LCD_BWIDTH |
| 352 | #undef DEFAULT_LCD_BWIDTH |
| 353 | #define DEFAULT_LCD_BWIDTH CONFIG_PANEL_LCD_BWIDTH |
| 354 | #endif |
| 355 | |
| 356 | #ifdef CONFIG_PANEL_LCD_HWIDTH |
| 357 | #undef DEFAULT_LCD_HWIDTH |
| 358 | #define DEFAULT_LCD_HWIDTH CONFIG_PANEL_LCD_HWIDTH |
| 359 | #endif |
| 360 | |
Mariusz Gorski | 1e13e8a | 2014-11-12 02:08:07 +0100 | [diff] [blame] | 361 | #ifdef CONFIG_PANEL_LCD_CHARSET |
| 362 | #undef DEFAULT_LCD_CHARSET |
| 363 | #define DEFAULT_LCD_CHARSET CONFIG_PANEL_LCD_CHARSET |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 364 | #endif |
| 365 | |
| 366 | #ifdef CONFIG_PANEL_LCD_PROTO |
| 367 | #undef DEFAULT_LCD_PROTO |
| 368 | #define DEFAULT_LCD_PROTO CONFIG_PANEL_LCD_PROTO |
| 369 | #endif |
| 370 | |
| 371 | #ifdef CONFIG_PANEL_LCD_PIN_E |
| 372 | #undef DEFAULT_LCD_PIN_E |
| 373 | #define DEFAULT_LCD_PIN_E CONFIG_PANEL_LCD_PIN_E |
| 374 | #endif |
| 375 | |
| 376 | #ifdef CONFIG_PANEL_LCD_PIN_RS |
| 377 | #undef DEFAULT_LCD_PIN_RS |
| 378 | #define DEFAULT_LCD_PIN_RS CONFIG_PANEL_LCD_PIN_RS |
| 379 | #endif |
| 380 | |
| 381 | #ifdef CONFIG_PANEL_LCD_PIN_RW |
| 382 | #undef DEFAULT_LCD_PIN_RW |
| 383 | #define DEFAULT_LCD_PIN_RW CONFIG_PANEL_LCD_PIN_RW |
| 384 | #endif |
| 385 | |
| 386 | #ifdef CONFIG_PANEL_LCD_PIN_SCL |
| 387 | #undef DEFAULT_LCD_PIN_SCL |
| 388 | #define DEFAULT_LCD_PIN_SCL CONFIG_PANEL_LCD_PIN_SCL |
| 389 | #endif |
| 390 | |
| 391 | #ifdef CONFIG_PANEL_LCD_PIN_SDA |
| 392 | #undef DEFAULT_LCD_PIN_SDA |
| 393 | #define DEFAULT_LCD_PIN_SDA CONFIG_PANEL_LCD_PIN_SDA |
| 394 | #endif |
| 395 | |
| 396 | #ifdef CONFIG_PANEL_LCD_PIN_BL |
| 397 | #undef DEFAULT_LCD_PIN_BL |
| 398 | #define DEFAULT_LCD_PIN_BL CONFIG_PANEL_LCD_PIN_BL |
| 399 | #endif |
| 400 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 401 | #endif /* DEFAULT_PROFILE == 0 */ |
| 402 | |
| 403 | /* global variables */ |
Mariusz Gorski | f4757af | 2014-11-04 22:47:19 +0100 | [diff] [blame] | 404 | |
| 405 | /* Device single-open policy control */ |
Mariusz Gorski | f4757af | 2014-11-04 22:47:19 +0100 | [diff] [blame] | 406 | static atomic_t keypad_available = ATOMIC_INIT(1); |
| 407 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 408 | static struct pardevice *pprt; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 409 | |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 410 | static int keypad_initialized; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 411 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 412 | static DEFINE_SPINLOCK(pprt_lock); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 413 | static struct timer_list scan_timer; |
| 414 | |
Willy Tarreau | 63023177 | 2008-11-22 12:52:18 +0100 | [diff] [blame] | 415 | MODULE_DESCRIPTION("Generic parallel port LCD/Keypad driver"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 416 | |
Mariusz Gorski | 59a66a2 | 2014-11-27 22:36:45 +0100 | [diff] [blame] | 417 | static int parport = DEFAULT_PARPORT; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 418 | module_param(parport, int, 0000); |
| 419 | MODULE_PARM_DESC(parport, "Parallel port index (0=lpt1, 1=lpt2, ...)"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 420 | |
Mariusz Gorski | 98e0e76 | 2014-11-12 02:08:08 +0100 | [diff] [blame] | 421 | static int profile = DEFAULT_PROFILE; |
| 422 | module_param(profile, int, 0000); |
| 423 | MODULE_PARM_DESC(profile, |
| 424 | "1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; " |
| 425 | "4=16x2 nexcom; default=40x2, old kp"); |
| 426 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 427 | static int keypad_type = NOT_SET; |
Mariusz Gorski | 98e0e76 | 2014-11-12 02:08:08 +0100 | [diff] [blame] | 428 | module_param(keypad_type, int, 0000); |
| 429 | MODULE_PARM_DESC(keypad_type, |
| 430 | "Keypad type: 0=none, 1=old 6 keys, 2=new 6+1 keys, 3=nexcom 4 keys"); |
| 431 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 432 | static int lcd_type = NOT_SET; |
Mariusz Gorski | 98e0e76 | 2014-11-12 02:08:08 +0100 | [diff] [blame] | 433 | module_param(lcd_type, int, 0000); |
| 434 | MODULE_PARM_DESC(lcd_type, |
Sudip Mukherjee | 2c20d92 | 2015-03-24 16:29:32 +0530 | [diff] [blame] | 435 | "LCD type: 0=none, 1=compiled-in, 2=old, 3=serial ks0074, 4=hantronix, 5=nexcom"); |
Mariusz Gorski | 98e0e76 | 2014-11-12 02:08:08 +0100 | [diff] [blame] | 436 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 437 | static int lcd_height = NOT_SET; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 438 | module_param(lcd_height, int, 0000); |
| 439 | MODULE_PARM_DESC(lcd_height, "Number of lines on the LCD"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 440 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 441 | static int lcd_width = NOT_SET; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 442 | module_param(lcd_width, int, 0000); |
| 443 | MODULE_PARM_DESC(lcd_width, "Number of columns on the LCD"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 444 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 445 | static int lcd_bwidth = NOT_SET; /* internal buffer width (usually 40) */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 446 | module_param(lcd_bwidth, int, 0000); |
| 447 | MODULE_PARM_DESC(lcd_bwidth, "Internal LCD line width (40)"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 448 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 449 | static int lcd_hwidth = NOT_SET; /* hardware buffer width (usually 64) */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 450 | module_param(lcd_hwidth, int, 0000); |
| 451 | MODULE_PARM_DESC(lcd_hwidth, "LCD line hardware address (64)"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 452 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 453 | static int lcd_charset = NOT_SET; |
Mariusz Gorski | 98e0e76 | 2014-11-12 02:08:08 +0100 | [diff] [blame] | 454 | module_param(lcd_charset, int, 0000); |
| 455 | MODULE_PARM_DESC(lcd_charset, "LCD character set: 0=standard, 1=KS0074"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 456 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 457 | static int lcd_proto = NOT_SET; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 458 | module_param(lcd_proto, int, 0000); |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 459 | MODULE_PARM_DESC(lcd_proto, |
Dominique van den Broeck | fdf4a494 | 2014-05-21 14:10:00 +0200 | [diff] [blame] | 460 | "LCD communication: 0=parallel (//), 1=serial, 2=TI LCD Interface"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 461 | |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 462 | /* |
| 463 | * These are the parallel port pins the LCD control signals are connected to. |
| 464 | * Set this to 0 if the signal is not used. Set it to its opposite value |
| 465 | * (negative) if the signal is negated. -MAXINT is used to indicate that the |
| 466 | * pin has not been explicitly specified. |
| 467 | * |
Willy Tarreau | 63023177 | 2008-11-22 12:52:18 +0100 | [diff] [blame] | 468 | * WARNING! no check will be performed about collisions with keypad ! |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 469 | */ |
| 470 | |
| 471 | static int lcd_e_pin = PIN_NOT_SET; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 472 | module_param(lcd_e_pin, int, 0000); |
| 473 | MODULE_PARM_DESC(lcd_e_pin, |
Monam Agarwal | fe5d2e0 | 2014-02-25 19:42:46 +0530 | [diff] [blame] | 474 | "# of the // port pin connected to LCD 'E' signal, with polarity (-17..17)"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 475 | |
| 476 | static int lcd_rs_pin = PIN_NOT_SET; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 477 | module_param(lcd_rs_pin, int, 0000); |
| 478 | MODULE_PARM_DESC(lcd_rs_pin, |
Monam Agarwal | fe5d2e0 | 2014-02-25 19:42:46 +0530 | [diff] [blame] | 479 | "# of the // port pin connected to LCD 'RS' signal, with polarity (-17..17)"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 480 | |
| 481 | static int lcd_rw_pin = PIN_NOT_SET; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 482 | module_param(lcd_rw_pin, int, 0000); |
| 483 | MODULE_PARM_DESC(lcd_rw_pin, |
Monam Agarwal | fe5d2e0 | 2014-02-25 19:42:46 +0530 | [diff] [blame] | 484 | "# of the // port pin connected to LCD 'RW' signal, with polarity (-17..17)"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 485 | |
Mariusz Gorski | 98e0e76 | 2014-11-12 02:08:08 +0100 | [diff] [blame] | 486 | static int lcd_cl_pin = PIN_NOT_SET; |
| 487 | module_param(lcd_cl_pin, int, 0000); |
| 488 | MODULE_PARM_DESC(lcd_cl_pin, |
| 489 | "# of the // port pin connected to serial LCD 'SCL' signal, with polarity (-17..17)"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 490 | |
| 491 | static int lcd_da_pin = PIN_NOT_SET; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 492 | module_param(lcd_da_pin, int, 0000); |
| 493 | MODULE_PARM_DESC(lcd_da_pin, |
Monam Agarwal | fe5d2e0 | 2014-02-25 19:42:46 +0530 | [diff] [blame] | 494 | "# of the // port pin connected to serial LCD 'SDA' signal, with polarity (-17..17)"); |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 495 | |
Mariusz Gorski | 98e0e76 | 2014-11-12 02:08:08 +0100 | [diff] [blame] | 496 | static int lcd_bl_pin = PIN_NOT_SET; |
| 497 | module_param(lcd_bl_pin, int, 0000); |
| 498 | MODULE_PARM_DESC(lcd_bl_pin, |
| 499 | "# of the // port pin connected to LCD backlight, with polarity (-17..17)"); |
| 500 | |
| 501 | /* Deprecated module parameters - consider not using them anymore */ |
| 502 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 503 | static int lcd_enabled = NOT_SET; |
Mariusz Gorski | 98e0e76 | 2014-11-12 02:08:08 +0100 | [diff] [blame] | 504 | module_param(lcd_enabled, int, 0000); |
| 505 | MODULE_PARM_DESC(lcd_enabled, "Deprecated option, use lcd_type instead"); |
| 506 | |
Mariusz Gorski | 36277d4 | 2014-11-27 22:36:47 +0100 | [diff] [blame] | 507 | static int keypad_enabled = NOT_SET; |
Mariusz Gorski | 98e0e76 | 2014-11-12 02:08:08 +0100 | [diff] [blame] | 508 | module_param(keypad_enabled, int, 0000); |
| 509 | MODULE_PARM_DESC(keypad_enabled, "Deprecated option, use keypad_type instead"); |
| 510 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 511 | /* for some LCD drivers (ks0074) we need a charset conversion table. */ |
Peter Huewe | 36d2041 | 2013-02-15 13:47:05 +0100 | [diff] [blame] | 512 | static const unsigned char lcd_char_conv_ks0074[256] = { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 513 | /* 0|8 1|9 2|A 3|B 4|C 5|D 6|E 7|F */ |
| 514 | /* 0x00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 515 | /* 0x08 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 516 | /* 0x10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, |
| 517 | /* 0x18 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, |
| 518 | /* 0x20 */ 0x20, 0x21, 0x22, 0x23, 0xa2, 0x25, 0x26, 0x27, |
| 519 | /* 0x28 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, |
| 520 | /* 0x30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, |
| 521 | /* 0x38 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, |
| 522 | /* 0x40 */ 0xa0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, |
| 523 | /* 0x48 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, |
| 524 | /* 0x50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, |
| 525 | /* 0x58 */ 0x58, 0x59, 0x5a, 0xfa, 0xfb, 0xfc, 0x1d, 0xc4, |
| 526 | /* 0x60 */ 0x96, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, |
| 527 | /* 0x68 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, |
| 528 | /* 0x70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, |
| 529 | /* 0x78 */ 0x78, 0x79, 0x7a, 0xfd, 0xfe, 0xff, 0xce, 0x20, |
| 530 | /* 0x80 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, |
| 531 | /* 0x88 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, |
| 532 | /* 0x90 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, |
| 533 | /* 0x98 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, |
| 534 | /* 0xA0 */ 0x20, 0x40, 0xb1, 0xa1, 0x24, 0xa3, 0xfe, 0x5f, |
| 535 | /* 0xA8 */ 0x22, 0xc8, 0x61, 0x14, 0x97, 0x2d, 0xad, 0x96, |
| 536 | /* 0xB0 */ 0x80, 0x8c, 0x82, 0x83, 0x27, 0x8f, 0x86, 0xdd, |
| 537 | /* 0xB8 */ 0x2c, 0x81, 0x6f, 0x15, 0x8b, 0x8a, 0x84, 0x60, |
| 538 | /* 0xC0 */ 0xe2, 0xe2, 0xe2, 0x5b, 0x5b, 0xae, 0xbc, 0xa9, |
| 539 | /* 0xC8 */ 0xc5, 0xbf, 0xc6, 0xf1, 0xe3, 0xe3, 0xe3, 0xe3, |
| 540 | /* 0xD0 */ 0x44, 0x5d, 0xa8, 0xe4, 0xec, 0xec, 0x5c, 0x78, |
| 541 | /* 0xD8 */ 0xab, 0xa6, 0xe5, 0x5e, 0x5e, 0xe6, 0xaa, 0xbe, |
| 542 | /* 0xE0 */ 0x7f, 0xe7, 0xaf, 0x7b, 0x7b, 0xaf, 0xbd, 0xc8, |
| 543 | /* 0xE8 */ 0xa4, 0xa5, 0xc7, 0xf6, 0xa7, 0xe8, 0x69, 0x69, |
| 544 | /* 0xF0 */ 0xed, 0x7d, 0xa8, 0xe4, 0xec, 0x5c, 0x5c, 0x25, |
| 545 | /* 0xF8 */ 0xac, 0xa6, 0xea, 0xef, 0x7e, 0xeb, 0xb2, 0x79, |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 546 | }; |
| 547 | |
Peter Huewe | 36d2041 | 2013-02-15 13:47:05 +0100 | [diff] [blame] | 548 | static const char old_keypad_profile[][4][9] = { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 549 | {"S0", "Left\n", "Left\n", ""}, |
| 550 | {"S1", "Down\n", "Down\n", ""}, |
| 551 | {"S2", "Up\n", "Up\n", ""}, |
| 552 | {"S3", "Right\n", "Right\n", ""}, |
| 553 | {"S4", "Esc\n", "Esc\n", ""}, |
| 554 | {"S5", "Ret\n", "Ret\n", ""}, |
| 555 | {"", "", "", ""} |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 556 | }; |
| 557 | |
| 558 | /* signals, press, repeat, release */ |
Peter Huewe | 36d2041 | 2013-02-15 13:47:05 +0100 | [diff] [blame] | 559 | static const char new_keypad_profile[][4][9] = { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 560 | {"S0", "Left\n", "Left\n", ""}, |
| 561 | {"S1", "Down\n", "Down\n", ""}, |
| 562 | {"S2", "Up\n", "Up\n", ""}, |
| 563 | {"S3", "Right\n", "Right\n", ""}, |
| 564 | {"S4s5", "", "Esc\n", "Esc\n"}, |
| 565 | {"s4S5", "", "Ret\n", "Ret\n"}, |
| 566 | {"S4S5", "Help\n", "", ""}, |
| 567 | /* add new signals above this line */ |
| 568 | {"", "", "", ""} |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 569 | }; |
| 570 | |
| 571 | /* signals, press, repeat, release */ |
Peter Huewe | 36d2041 | 2013-02-15 13:47:05 +0100 | [diff] [blame] | 572 | static const char nexcom_keypad_profile[][4][9] = { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 573 | {"a-p-e-", "Down\n", "Down\n", ""}, |
| 574 | {"a-p-E-", "Ret\n", "Ret\n", ""}, |
| 575 | {"a-P-E-", "Esc\n", "Esc\n", ""}, |
| 576 | {"a-P-e-", "Up\n", "Up\n", ""}, |
| 577 | /* add new signals above this line */ |
| 578 | {"", "", "", ""} |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 579 | }; |
| 580 | |
Peter Huewe | 36d2041 | 2013-02-15 13:47:05 +0100 | [diff] [blame] | 581 | static const char (*keypad_profile)[4][9] = old_keypad_profile; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 582 | |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 583 | static DECLARE_BITMAP(bits, LCD_BITS); |
| 584 | |
| 585 | static void lcd_get_bits(unsigned int port, int *val) |
| 586 | { |
| 587 | unsigned int bit, state; |
| 588 | |
| 589 | for (bit = 0; bit < LCD_BITS; bit++) { |
| 590 | state = test_bit(bit, bits) ? BIT_SET : BIT_CLR; |
| 591 | *val &= lcd_bits[port][bit][BIT_MSK]; |
| 592 | *val |= lcd_bits[port][bit][state]; |
| 593 | } |
| 594 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 595 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 596 | /* sets data port bits according to current signals values */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 597 | static int set_data_bits(void) |
| 598 | { |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 599 | int val; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 600 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 601 | val = r_dtr(pprt); |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 602 | lcd_get_bits(LCD_PORT_D, &val); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 603 | w_dtr(pprt, val); |
| 604 | return val; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | /* sets ctrl port bits according to current signals values */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 608 | static int set_ctrl_bits(void) |
| 609 | { |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 610 | int val; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 611 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 612 | val = r_ctr(pprt); |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 613 | lcd_get_bits(LCD_PORT_C, &val); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 614 | w_ctr(pprt, val); |
| 615 | return val; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | /* sets ctrl & data port bits according to current signals values */ |
Sachin P. Sant | 6136ac8 | 2009-02-03 21:10:58 +0530 | [diff] [blame] | 619 | static void panel_set_bits(void) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 620 | { |
| 621 | set_data_bits(); |
| 622 | set_ctrl_bits(); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | /* |
| 626 | * Converts a parallel port pin (from -25 to 25) to data and control ports |
| 627 | * masks, and data and control port bits. The signal will be considered |
| 628 | * unconnected if it's on pin 0 or an invalid pin (<-25 or >25). |
| 629 | * |
| 630 | * Result will be used this way : |
| 631 | * out(dport, in(dport) & d_val[2] | d_val[signal_state]) |
| 632 | * out(cport, in(cport) & c_val[2] | c_val[signal_state]) |
| 633 | */ |
Peter Huewe | 36d2041 | 2013-02-15 13:47:05 +0100 | [diff] [blame] | 634 | static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 635 | { |
| 636 | int d_bit, c_bit, inv; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 637 | |
Dominique van den Broeck | 2d53426 | 2014-05-24 01:35:24 +0200 | [diff] [blame] | 638 | d_val[0] = 0; |
| 639 | c_val[0] = 0; |
| 640 | d_val[1] = 0; |
| 641 | c_val[1] = 0; |
| 642 | d_val[2] = 0xFF; |
| 643 | c_val[2] = 0xFF; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 644 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 645 | if (pin == 0) |
| 646 | return; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 647 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 648 | inv = (pin < 0); |
| 649 | if (inv) |
| 650 | pin = -pin; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 651 | |
Dominique van den Broeck | 2d53426 | 2014-05-24 01:35:24 +0200 | [diff] [blame] | 652 | d_bit = 0; |
| 653 | c_bit = 0; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 654 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 655 | switch (pin) { |
| 656 | case PIN_STROBE: /* strobe, inverted */ |
| 657 | c_bit = PNL_PSTROBE; |
| 658 | inv = !inv; |
| 659 | break; |
| 660 | case PIN_D0...PIN_D7: /* D0 - D7 = 2 - 9 */ |
| 661 | d_bit = 1 << (pin - 2); |
| 662 | break; |
| 663 | case PIN_AUTOLF: /* autofeed, inverted */ |
| 664 | c_bit = PNL_PAUTOLF; |
| 665 | inv = !inv; |
| 666 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 667 | case PIN_INITP: /* init, direct */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 668 | c_bit = PNL_PINITP; |
| 669 | break; |
| 670 | case PIN_SELECP: /* select_in, inverted */ |
| 671 | c_bit = PNL_PSELECP; |
| 672 | inv = !inv; |
| 673 | break; |
| 674 | default: /* unknown pin, ignore */ |
| 675 | break; |
| 676 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 677 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 678 | if (c_bit) { |
| 679 | c_val[2] &= ~c_bit; |
| 680 | c_val[!inv] = c_bit; |
| 681 | } else if (d_bit) { |
| 682 | d_val[2] &= ~d_bit; |
| 683 | d_val[!inv] = d_bit; |
| 684 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 685 | } |
| 686 | |
Alex Wilson | 881bf281 | 2015-07-31 11:08:29 -0600 | [diff] [blame] | 687 | /* |
| 688 | * send a serial byte to the LCD panel. The caller is responsible for locking |
| 689 | * if needed. |
| 690 | */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 691 | static void lcd_send_serial(int byte) |
| 692 | { |
| 693 | int bit; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 694 | |
Alex Wilson | 881bf281 | 2015-07-31 11:08:29 -0600 | [diff] [blame] | 695 | /* |
| 696 | * the data bit is set on D0, and the clock on STROBE. |
| 697 | * LCD reads D0 on STROBE's rising edge. |
| 698 | */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 699 | for (bit = 0; bit < 8; bit++) { |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 700 | clear_bit(LCD_BIT_CL, bits); /* CLK low */ |
Sachin P. Sant | 6136ac8 | 2009-02-03 21:10:58 +0530 | [diff] [blame] | 701 | panel_set_bits(); |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 702 | if (byte & 1) { |
| 703 | set_bit(LCD_BIT_DA, bits); |
| 704 | } else { |
| 705 | clear_bit(LCD_BIT_DA, bits); |
| 706 | } |
| 707 | |
Sachin P. Sant | 6136ac8 | 2009-02-03 21:10:58 +0530 | [diff] [blame] | 708 | panel_set_bits(); |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 709 | udelay(2); /* maintain the data during 2 us before CLK up */ |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 710 | set_bit(LCD_BIT_CL, bits); /* CLK high */ |
Sachin P. Sant | 6136ac8 | 2009-02-03 21:10:58 +0530 | [diff] [blame] | 711 | panel_set_bits(); |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 712 | udelay(1); /* maintain the strobe during 1 us */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 713 | byte >>= 1; |
| 714 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | /* turn the backlight on or off */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 718 | static void lcd_backlight(struct charlcd *charlcd, int on) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 719 | { |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 720 | if (lcd.pins.bl == PIN_NONE) |
| 721 | return; |
| 722 | |
Justin P. Mattock | 6975e18 | 2012-03-19 08:17:52 -0700 | [diff] [blame] | 723 | /* The backlight is activated by setting the AUTOFEED line to +5V */ |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 724 | spin_lock_irq(&pprt_lock); |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 725 | if (on) |
| 726 | set_bit(LCD_BIT_BL, bits); |
| 727 | else |
| 728 | clear_bit(LCD_BIT_BL, bits); |
Sachin P. Sant | 6136ac8 | 2009-02-03 21:10:58 +0530 | [diff] [blame] | 729 | panel_set_bits(); |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 730 | spin_unlock_irq(&pprt_lock); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 731 | } |
| 732 | |
| 733 | /* send a command to the LCD panel in serial mode */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 734 | static void lcd_write_cmd_s(struct charlcd *charlcd, int cmd) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 735 | { |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 736 | spin_lock_irq(&pprt_lock); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 737 | lcd_send_serial(0x1F); /* R/W=W, RS=0 */ |
| 738 | lcd_send_serial(cmd & 0x0F); |
| 739 | lcd_send_serial((cmd >> 4) & 0x0F); |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 740 | udelay(40); /* the shortest command takes at least 40 us */ |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 741 | spin_unlock_irq(&pprt_lock); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | /* send data to the LCD panel in serial mode */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 745 | static void lcd_write_data_s(struct charlcd *charlcd, int data) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 746 | { |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 747 | spin_lock_irq(&pprt_lock); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 748 | lcd_send_serial(0x5F); /* R/W=W, RS=1 */ |
| 749 | lcd_send_serial(data & 0x0F); |
| 750 | lcd_send_serial((data >> 4) & 0x0F); |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 751 | udelay(40); /* the shortest data takes at least 40 us */ |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 752 | spin_unlock_irq(&pprt_lock); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | /* send a command to the LCD panel in 8 bits parallel mode */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 756 | static void lcd_write_cmd_p8(struct charlcd *charlcd, int cmd) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 757 | { |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 758 | spin_lock_irq(&pprt_lock); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 759 | /* present the data to the data port */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 760 | w_dtr(pprt, cmd); |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 761 | udelay(20); /* maintain the data during 20 us before the strobe */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 762 | |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 763 | set_bit(LCD_BIT_E, bits); |
| 764 | clear_bit(LCD_BIT_RS, bits); |
| 765 | clear_bit(LCD_BIT_RW, bits); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 766 | set_ctrl_bits(); |
| 767 | |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 768 | udelay(40); /* maintain the strobe during 40 us */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 769 | |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 770 | clear_bit(LCD_BIT_E, bits); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 771 | set_ctrl_bits(); |
| 772 | |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 773 | udelay(120); /* the shortest command takes at least 120 us */ |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 774 | spin_unlock_irq(&pprt_lock); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 775 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 776 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 777 | /* send data to the LCD panel in 8 bits parallel mode */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 778 | static void lcd_write_data_p8(struct charlcd *charlcd, int data) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 779 | { |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 780 | spin_lock_irq(&pprt_lock); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 781 | /* present the data to the data port */ |
| 782 | w_dtr(pprt, data); |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 783 | udelay(20); /* maintain the data during 20 us before the strobe */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 784 | |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 785 | set_bit(LCD_BIT_E, bits); |
| 786 | set_bit(LCD_BIT_RS, bits); |
| 787 | clear_bit(LCD_BIT_RW, bits); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 788 | set_ctrl_bits(); |
| 789 | |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 790 | udelay(40); /* maintain the strobe during 40 us */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 791 | |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 792 | clear_bit(LCD_BIT_E, bits); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 793 | set_ctrl_bits(); |
| 794 | |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 795 | udelay(45); /* the shortest data takes at least 45 us */ |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 796 | spin_unlock_irq(&pprt_lock); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 797 | } |
| 798 | |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 799 | /* send a command to the TI LCD panel */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 800 | static void lcd_write_cmd_tilcd(struct charlcd *charlcd, int cmd) |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 801 | { |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 802 | spin_lock_irq(&pprt_lock); |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 803 | /* present the data to the control port */ |
| 804 | w_ctr(pprt, cmd); |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 805 | udelay(60); |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 806 | spin_unlock_irq(&pprt_lock); |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | /* send data to the TI LCD panel */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 810 | static void lcd_write_data_tilcd(struct charlcd *charlcd, int data) |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 811 | { |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 812 | spin_lock_irq(&pprt_lock); |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 813 | /* present the data to the data port */ |
| 814 | w_dtr(pprt, data); |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 815 | udelay(60); |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 816 | spin_unlock_irq(&pprt_lock); |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 817 | } |
| 818 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 819 | /* fills the display with spaces and resets X/Y */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 820 | static void lcd_clear_fast_s(struct charlcd *charlcd) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 821 | { |
| 822 | int pos; |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 823 | |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 824 | spin_lock_irq(&pprt_lock); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 825 | for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 826 | lcd_send_serial(0x5F); /* R/W=W, RS=1 */ |
| 827 | lcd_send_serial(' ' & 0x0F); |
| 828 | lcd_send_serial((' ' >> 4) & 0x0F); |
Ricardo Ruedas | df44f15 | 2015-12-08 22:30:40 +0100 | [diff] [blame] | 829 | /* the shortest data takes at least 40 us */ |
Greg Kroah-Hartman | 4cff7ad | 2016-02-01 12:50:26 -0800 | [diff] [blame] | 830 | udelay(40); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 831 | } |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 832 | spin_unlock_irq(&pprt_lock); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | /* fills the display with spaces and resets X/Y */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 836 | static void lcd_clear_fast_p8(struct charlcd *charlcd) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 837 | { |
| 838 | int pos; |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 839 | |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 840 | spin_lock_irq(&pprt_lock); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 841 | for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 842 | /* present the data to the data port */ |
| 843 | w_dtr(pprt, ' '); |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 844 | |
| 845 | /* maintain the data during 20 us before the strobe */ |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 846 | udelay(20); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 847 | |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 848 | set_bit(LCD_BIT_E, bits); |
| 849 | set_bit(LCD_BIT_RS, bits); |
| 850 | clear_bit(LCD_BIT_RW, bits); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 851 | set_ctrl_bits(); |
| 852 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 853 | /* maintain the strobe during 40 us */ |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 854 | udelay(40); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 855 | |
Daniel Chromik | bea7433 | 2016-02-11 13:29:23 +0100 | [diff] [blame] | 856 | clear_bit(LCD_BIT_E, bits); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 857 | set_ctrl_bits(); |
| 858 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 859 | /* the shortest data takes at least 45 us */ |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 860 | udelay(45); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 861 | } |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 862 | spin_unlock_irq(&pprt_lock); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 863 | } |
| 864 | |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 865 | /* fills the display with spaces and resets X/Y */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 866 | static void lcd_clear_fast_tilcd(struct charlcd *charlcd) |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 867 | { |
| 868 | int pos; |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 869 | |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 870 | spin_lock_irq(&pprt_lock); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 871 | for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 872 | /* present the data to the data port */ |
| 873 | w_dtr(pprt, ' '); |
Sudip Mukherjee | b64a1cb | 2016-01-23 14:49:20 +0530 | [diff] [blame] | 874 | udelay(60); |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 875 | } |
| 876 | |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 877 | spin_unlock_irq(&pprt_lock); |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 878 | } |
| 879 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 880 | static struct charlcd_ops charlcd_serial_ops = { |
| 881 | .write_cmd = lcd_write_cmd_s, |
| 882 | .write_data = lcd_write_data_s, |
| 883 | .clear_fast = lcd_clear_fast_s, |
| 884 | .backlight = lcd_backlight, |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 885 | }; |
| 886 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 887 | static struct charlcd_ops charlcd_parallel_ops = { |
| 888 | .write_cmd = lcd_write_cmd_p8, |
| 889 | .write_data = lcd_write_data_p8, |
| 890 | .clear_fast = lcd_clear_fast_p8, |
| 891 | .backlight = lcd_backlight, |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 892 | }; |
| 893 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 894 | static struct charlcd_ops charlcd_tilcd_ops = { |
| 895 | .write_cmd = lcd_write_cmd_tilcd, |
| 896 | .write_data = lcd_write_data_tilcd, |
| 897 | .clear_fast = lcd_clear_fast_tilcd, |
| 898 | .backlight = lcd_backlight, |
| 899 | }; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 900 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 901 | /* initialize the LCD driver */ |
Peter Huewe | 36d2041 | 2013-02-15 13:47:05 +0100 | [diff] [blame] | 902 | static void lcd_init(void) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 903 | { |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 904 | struct charlcd *charlcd; |
| 905 | |
| 906 | charlcd = charlcd_alloc(0); |
| 907 | if (!charlcd) |
| 908 | return; |
| 909 | |
| 910 | /* |
| 911 | * Init lcd struct with load-time values to preserve exact |
| 912 | * current functionality (at least for now). |
| 913 | */ |
| 914 | charlcd->height = lcd_height; |
| 915 | charlcd->width = lcd_width; |
| 916 | charlcd->bwidth = lcd_bwidth; |
| 917 | charlcd->hwidth = lcd_hwidth; |
| 918 | |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 919 | switch (selected_lcd_type) { |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 920 | case LCD_TYPE_OLD: |
| 921 | /* parallel mode, 8 bits */ |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 922 | lcd.proto = LCD_PROTO_PARALLEL; |
| 923 | lcd.charset = LCD_CHARSET_NORMAL; |
| 924 | lcd.pins.e = PIN_STROBE; |
| 925 | lcd.pins.rs = PIN_AUTOLF; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 926 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 927 | charlcd->width = 40; |
| 928 | charlcd->bwidth = 40; |
| 929 | charlcd->hwidth = 64; |
| 930 | charlcd->height = 2; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 931 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 932 | case LCD_TYPE_KS0074: |
| 933 | /* serial mode, ks0074 */ |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 934 | lcd.proto = LCD_PROTO_SERIAL; |
| 935 | lcd.charset = LCD_CHARSET_KS0074; |
| 936 | lcd.pins.bl = PIN_AUTOLF; |
| 937 | lcd.pins.cl = PIN_STROBE; |
| 938 | lcd.pins.da = PIN_D0; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 939 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 940 | charlcd->width = 16; |
| 941 | charlcd->bwidth = 40; |
| 942 | charlcd->hwidth = 16; |
| 943 | charlcd->height = 2; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 944 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 945 | case LCD_TYPE_NEXCOM: |
| 946 | /* parallel mode, 8 bits, generic */ |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 947 | lcd.proto = LCD_PROTO_PARALLEL; |
| 948 | lcd.charset = LCD_CHARSET_NORMAL; |
| 949 | lcd.pins.e = PIN_AUTOLF; |
| 950 | lcd.pins.rs = PIN_SELECP; |
| 951 | lcd.pins.rw = PIN_INITP; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 952 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 953 | charlcd->width = 16; |
| 954 | charlcd->bwidth = 40; |
| 955 | charlcd->hwidth = 64; |
| 956 | charlcd->height = 2; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 957 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 958 | case LCD_TYPE_CUSTOM: |
| 959 | /* customer-defined */ |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 960 | lcd.proto = DEFAULT_LCD_PROTO; |
| 961 | lcd.charset = DEFAULT_LCD_CHARSET; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 962 | /* default geometry will be set later */ |
| 963 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 964 | case LCD_TYPE_HANTRONIX: |
| 965 | /* parallel mode, 8 bits, hantronix-like */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 966 | default: |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 967 | lcd.proto = LCD_PROTO_PARALLEL; |
| 968 | lcd.charset = LCD_CHARSET_NORMAL; |
| 969 | lcd.pins.e = PIN_STROBE; |
| 970 | lcd.pins.rs = PIN_SELECP; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 971 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 972 | charlcd->width = 16; |
| 973 | charlcd->bwidth = 40; |
| 974 | charlcd->hwidth = 64; |
| 975 | charlcd->height = 2; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 976 | break; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 977 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 978 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 979 | /* Overwrite with module params set on loading */ |
Mariusz Gorski | 1a4b2e3 | 2014-11-27 22:36:52 +0100 | [diff] [blame] | 980 | if (lcd_height != NOT_SET) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 981 | charlcd->height = lcd_height; |
Mariusz Gorski | 1a4b2e3 | 2014-11-27 22:36:52 +0100 | [diff] [blame] | 982 | if (lcd_width != NOT_SET) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 983 | charlcd->width = lcd_width; |
Mariusz Gorski | 1a4b2e3 | 2014-11-27 22:36:52 +0100 | [diff] [blame] | 984 | if (lcd_bwidth != NOT_SET) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 985 | charlcd->bwidth = lcd_bwidth; |
Mariusz Gorski | 1a4b2e3 | 2014-11-27 22:36:52 +0100 | [diff] [blame] | 986 | if (lcd_hwidth != NOT_SET) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 987 | charlcd->hwidth = lcd_hwidth; |
Mariusz Gorski | 1a4b2e3 | 2014-11-27 22:36:52 +0100 | [diff] [blame] | 988 | if (lcd_charset != NOT_SET) |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 989 | lcd.charset = lcd_charset; |
Mariusz Gorski | 1a4b2e3 | 2014-11-27 22:36:52 +0100 | [diff] [blame] | 990 | if (lcd_proto != NOT_SET) |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 991 | lcd.proto = lcd_proto; |
| 992 | if (lcd_e_pin != PIN_NOT_SET) |
| 993 | lcd.pins.e = lcd_e_pin; |
| 994 | if (lcd_rs_pin != PIN_NOT_SET) |
| 995 | lcd.pins.rs = lcd_rs_pin; |
| 996 | if (lcd_rw_pin != PIN_NOT_SET) |
| 997 | lcd.pins.rw = lcd_rw_pin; |
| 998 | if (lcd_cl_pin != PIN_NOT_SET) |
| 999 | lcd.pins.cl = lcd_cl_pin; |
| 1000 | if (lcd_da_pin != PIN_NOT_SET) |
| 1001 | lcd.pins.da = lcd_da_pin; |
| 1002 | if (lcd_bl_pin != PIN_NOT_SET) |
| 1003 | lcd.pins.bl = lcd_bl_pin; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1004 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1005 | /* this is used to catch wrong and default values */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1006 | if (charlcd->width <= 0) |
| 1007 | charlcd->width = DEFAULT_LCD_WIDTH; |
| 1008 | if (charlcd->bwidth <= 0) |
| 1009 | charlcd->bwidth = DEFAULT_LCD_BWIDTH; |
| 1010 | if (charlcd->hwidth <= 0) |
| 1011 | charlcd->hwidth = DEFAULT_LCD_HWIDTH; |
| 1012 | if (charlcd->height <= 0) |
| 1013 | charlcd->height = DEFAULT_LCD_HEIGHT; |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1014 | |
| 1015 | if (lcd.proto == LCD_PROTO_SERIAL) { /* SERIAL */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1016 | charlcd->ops = &charlcd_serial_ops; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1017 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1018 | if (lcd.pins.cl == PIN_NOT_SET) |
| 1019 | lcd.pins.cl = DEFAULT_LCD_PIN_SCL; |
| 1020 | if (lcd.pins.da == PIN_NOT_SET) |
| 1021 | lcd.pins.da = DEFAULT_LCD_PIN_SDA; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1022 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1023 | } else if (lcd.proto == LCD_PROTO_PARALLEL) { /* PARALLEL */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1024 | charlcd->ops = &charlcd_parallel_ops; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1025 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1026 | if (lcd.pins.e == PIN_NOT_SET) |
| 1027 | lcd.pins.e = DEFAULT_LCD_PIN_E; |
| 1028 | if (lcd.pins.rs == PIN_NOT_SET) |
| 1029 | lcd.pins.rs = DEFAULT_LCD_PIN_RS; |
| 1030 | if (lcd.pins.rw == PIN_NOT_SET) |
| 1031 | lcd.pins.rw = DEFAULT_LCD_PIN_RW; |
Sudhakar Rajashekhara | 77943d3 | 2009-08-20 18:13:18 -0400 | [diff] [blame] | 1032 | } else { |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1033 | charlcd->ops = &charlcd_tilcd_ops; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1034 | } |
| 1035 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1036 | if (lcd.pins.bl == PIN_NOT_SET) |
| 1037 | lcd.pins.bl = DEFAULT_LCD_PIN_BL; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1038 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1039 | if (lcd.pins.e == PIN_NOT_SET) |
| 1040 | lcd.pins.e = PIN_NONE; |
| 1041 | if (lcd.pins.rs == PIN_NOT_SET) |
| 1042 | lcd.pins.rs = PIN_NONE; |
| 1043 | if (lcd.pins.rw == PIN_NOT_SET) |
| 1044 | lcd.pins.rw = PIN_NONE; |
| 1045 | if (lcd.pins.bl == PIN_NOT_SET) |
| 1046 | lcd.pins.bl = PIN_NONE; |
| 1047 | if (lcd.pins.cl == PIN_NOT_SET) |
| 1048 | lcd.pins.cl = PIN_NONE; |
| 1049 | if (lcd.pins.da == PIN_NOT_SET) |
| 1050 | lcd.pins.da = PIN_NONE; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1051 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1052 | if (lcd.charset == NOT_SET) |
| 1053 | lcd.charset = DEFAULT_LCD_CHARSET; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1054 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1055 | if (lcd.charset == LCD_CHARSET_KS0074) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1056 | charlcd->char_conv = lcd_char_conv_ks0074; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1057 | else |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1058 | charlcd->char_conv = NULL; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1059 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1060 | pin_to_bits(lcd.pins.e, lcd_bits[LCD_PORT_D][LCD_BIT_E], |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1061 | lcd_bits[LCD_PORT_C][LCD_BIT_E]); |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1062 | pin_to_bits(lcd.pins.rs, lcd_bits[LCD_PORT_D][LCD_BIT_RS], |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1063 | lcd_bits[LCD_PORT_C][LCD_BIT_RS]); |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1064 | pin_to_bits(lcd.pins.rw, lcd_bits[LCD_PORT_D][LCD_BIT_RW], |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1065 | lcd_bits[LCD_PORT_C][LCD_BIT_RW]); |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1066 | pin_to_bits(lcd.pins.bl, lcd_bits[LCD_PORT_D][LCD_BIT_BL], |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1067 | lcd_bits[LCD_PORT_C][LCD_BIT_BL]); |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1068 | pin_to_bits(lcd.pins.cl, lcd_bits[LCD_PORT_D][LCD_BIT_CL], |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1069 | lcd_bits[LCD_PORT_C][LCD_BIT_CL]); |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1070 | pin_to_bits(lcd.pins.da, lcd_bits[LCD_PORT_D][LCD_BIT_DA], |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1071 | lcd_bits[LCD_PORT_C][LCD_BIT_DA]); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1072 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1073 | lcd.charlcd = charlcd; |
Mariusz Gorski | 6d8b588 | 2014-11-27 22:36:53 +0100 | [diff] [blame] | 1074 | lcd.initialized = true; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1075 | } |
| 1076 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1077 | /* |
| 1078 | * These are the file operation function for user access to /dev/keypad |
| 1079 | */ |
| 1080 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1081 | static ssize_t keypad_read(struct file *file, |
Bastien Armand | cce75f4 | 2014-04-18 18:10:08 +0200 | [diff] [blame] | 1082 | char __user *buf, size_t count, loff_t *ppos) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1083 | { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1084 | unsigned i = *ppos; |
Bastien Armand | cce75f4 | 2014-04-18 18:10:08 +0200 | [diff] [blame] | 1085 | char __user *tmp = buf; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1086 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1087 | if (keypad_buflen == 0) { |
| 1088 | if (file->f_flags & O_NONBLOCK) |
| 1089 | return -EAGAIN; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1090 | |
Arnd Bergmann | 310df69 | 2014-01-02 13:07:35 +0100 | [diff] [blame] | 1091 | if (wait_event_interruptible(keypad_read_wait, |
| 1092 | keypad_buflen != 0)) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1093 | return -EINTR; |
| 1094 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1095 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1096 | for (; count-- > 0 && (keypad_buflen > 0); |
| 1097 | ++i, ++tmp, --keypad_buflen) { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1098 | put_user(keypad_buffer[keypad_start], tmp); |
| 1099 | keypad_start = (keypad_start + 1) % KEYPAD_BUFFER; |
| 1100 | } |
| 1101 | *ppos = i; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1102 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1103 | return tmp - buf; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1104 | } |
| 1105 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1106 | static int keypad_open(struct inode *inode, struct file *file) |
| 1107 | { |
Mariusz Gorski | f4757af | 2014-11-04 22:47:19 +0100 | [diff] [blame] | 1108 | if (!atomic_dec_and_test(&keypad_available)) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1109 | return -EBUSY; /* open only once at a time */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1110 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1111 | if (file->f_mode & FMODE_WRITE) /* device is read-only */ |
| 1112 | return -EPERM; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1113 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1114 | keypad_buflen = 0; /* flush the buffer on opening */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1115 | return 0; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1116 | } |
| 1117 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1118 | static int keypad_release(struct inode *inode, struct file *file) |
| 1119 | { |
Mariusz Gorski | f4757af | 2014-11-04 22:47:19 +0100 | [diff] [blame] | 1120 | atomic_inc(&keypad_available); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1121 | return 0; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1122 | } |
| 1123 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1124 | static const struct file_operations keypad_fops = { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1125 | .read = keypad_read, /* read */ |
| 1126 | .open = keypad_open, /* open */ |
| 1127 | .release = keypad_release, /* close */ |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1128 | .llseek = default_llseek, |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1129 | }; |
| 1130 | |
| 1131 | static struct miscdevice keypad_dev = { |
Mariusz Gorski | 6c3773de | 2014-10-29 23:32:30 +0100 | [diff] [blame] | 1132 | .minor = KEYPAD_MINOR, |
| 1133 | .name = "keypad", |
| 1134 | .fops = &keypad_fops, |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1135 | }; |
| 1136 | |
Peter Huewe | 36d2041 | 2013-02-15 13:47:05 +0100 | [diff] [blame] | 1137 | static void keypad_send_key(const char *string, int max_len) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1138 | { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1139 | /* send the key to the device only if a process is attached to it. */ |
Mariusz Gorski | f4757af | 2014-11-04 22:47:19 +0100 | [diff] [blame] | 1140 | if (!atomic_read(&keypad_available)) { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1141 | while (max_len-- && keypad_buflen < KEYPAD_BUFFER && *string) { |
| 1142 | keypad_buffer[(keypad_start + keypad_buflen++) % |
| 1143 | KEYPAD_BUFFER] = *string++; |
| 1144 | } |
| 1145 | wake_up_interruptible(&keypad_read_wait); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1146 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1147 | } |
| 1148 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1149 | /* this function scans all the bits involving at least one logical signal, |
| 1150 | * and puts the results in the bitfield "phys_read" (one bit per established |
| 1151 | * contact), and sets "phys_read_prev" to "phys_read". |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1152 | * |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1153 | * Note: to debounce input signals, we will only consider as switched a signal |
| 1154 | * which is stable across 2 measures. Signals which are different between two |
| 1155 | * reads will be kept as they previously were in their logical form (phys_prev). |
| 1156 | * A signal which has just switched will have a 1 in |
| 1157 | * (phys_read ^ phys_read_prev). |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1158 | */ |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1159 | static void phys_scan_contacts(void) |
| 1160 | { |
| 1161 | int bit, bitval; |
| 1162 | char oldval; |
| 1163 | char bitmask; |
| 1164 | char gndmask; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1165 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1166 | phys_prev = phys_curr; |
| 1167 | phys_read_prev = phys_read; |
| 1168 | phys_read = 0; /* flush all signals */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1169 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1170 | /* keep track of old value, with all outputs disabled */ |
| 1171 | oldval = r_dtr(pprt) | scan_mask_o; |
| 1172 | /* activate all keyboard outputs (active low) */ |
| 1173 | w_dtr(pprt, oldval & ~scan_mask_o); |
| 1174 | |
| 1175 | /* will have a 1 for each bit set to gnd */ |
| 1176 | bitmask = PNL_PINPUT(r_str(pprt)) & scan_mask_i; |
| 1177 | /* disable all matrix signals */ |
| 1178 | w_dtr(pprt, oldval); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1179 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1180 | /* now that all outputs are cleared, the only active input bits are |
| 1181 | * directly connected to the ground |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1182 | */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1183 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1184 | /* 1 for each grounded input */ |
| 1185 | gndmask = PNL_PINPUT(r_str(pprt)) & scan_mask_i; |
| 1186 | |
| 1187 | /* grounded inputs are signals 40-44 */ |
Ksenija Stanojevic | 35fe087 | 2016-01-03 20:40:58 +0100 | [diff] [blame] | 1188 | phys_read |= (__u64)gndmask << 40; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1189 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1190 | if (bitmask != gndmask) { |
Nayeemahmed Badebade | 8c17893 | 2015-08-27 21:02:46 +0530 | [diff] [blame] | 1191 | /* |
| 1192 | * since clearing the outputs changed some inputs, we know |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1193 | * that some input signals are currently tied to some outputs. |
| 1194 | * So we'll scan them. |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1195 | */ |
| 1196 | for (bit = 0; bit < 8; bit++) { |
Amitoj Kaur Chawla | 79f2af6 | 2015-10-16 22:11:36 +0530 | [diff] [blame] | 1197 | bitval = BIT(bit); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1198 | |
| 1199 | if (!(scan_mask_o & bitval)) /* skip unused bits */ |
| 1200 | continue; |
| 1201 | |
| 1202 | w_dtr(pprt, oldval & ~bitval); /* enable this output */ |
| 1203 | bitmask = PNL_PINPUT(r_str(pprt)) & ~gndmask; |
Ksenija Stanojevic | 35fe087 | 2016-01-03 20:40:58 +0100 | [diff] [blame] | 1204 | phys_read |= (__u64)bitmask << (5 * bit); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1205 | } |
| 1206 | w_dtr(pprt, oldval); /* disable all outputs */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1207 | } |
Nayeemahmed Badebade | 8c17893 | 2015-08-27 21:02:46 +0530 | [diff] [blame] | 1208 | /* |
| 1209 | * this is easy: use old bits when they are flapping, |
| 1210 | * use new ones when stable |
| 1211 | */ |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1212 | phys_curr = (phys_prev & (phys_read ^ phys_read_prev)) | |
| 1213 | (phys_read & ~(phys_read ^ phys_read_prev)); |
| 1214 | } |
| 1215 | |
| 1216 | static inline int input_state_high(struct logical_input *input) |
| 1217 | { |
| 1218 | #if 0 |
| 1219 | /* FIXME: |
| 1220 | * this is an invalid test. It tries to catch |
| 1221 | * transitions from single-key to multiple-key, but |
| 1222 | * doesn't take into account the contacts polarity. |
| 1223 | * The only solution to the problem is to parse keys |
| 1224 | * from the most complex to the simplest combinations, |
| 1225 | * and mark them as 'caught' once a combination |
| 1226 | * matches, then unmatch it for all other ones. |
| 1227 | */ |
| 1228 | |
| 1229 | /* try to catch dangerous transitions cases : |
| 1230 | * someone adds a bit, so this signal was a false |
| 1231 | * positive resulting from a transition. We should |
| 1232 | * invalidate the signal immediately and not call the |
| 1233 | * release function. |
| 1234 | * eg: 0 -(press A)-> A -(press B)-> AB : don't match A's release. |
| 1235 | */ |
Dominique van den Broeck | fdf4a494 | 2014-05-21 14:10:00 +0200 | [diff] [blame] | 1236 | if (((phys_prev & input->mask) == input->value) && |
| 1237 | ((phys_curr & input->mask) > input->value)) { |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1238 | input->state = INPUT_ST_LOW; /* invalidate */ |
| 1239 | return 1; |
| 1240 | } |
| 1241 | #endif |
| 1242 | |
| 1243 | if ((phys_curr & input->mask) == input->value) { |
| 1244 | if ((input->type == INPUT_TYPE_STD) && |
| 1245 | (input->high_timer == 0)) { |
| 1246 | input->high_timer++; |
Aybuke Ozdemir | b565b3f | 2015-10-03 14:52:09 +0300 | [diff] [blame] | 1247 | if (input->u.std.press_fct) |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1248 | input->u.std.press_fct(input->u.std.press_data); |
| 1249 | } else if (input->type == INPUT_TYPE_KBD) { |
| 1250 | /* will turn on the light */ |
| 1251 | keypressed = 1; |
| 1252 | |
| 1253 | if (input->high_timer == 0) { |
| 1254 | char *press_str = input->u.kbd.press_str; |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1255 | |
Jake Champlin | e6626de | 2013-05-04 11:21:17 -0400 | [diff] [blame] | 1256 | if (press_str[0]) { |
| 1257 | int s = sizeof(input->u.kbd.press_str); |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1258 | |
Jake Champlin | e6626de | 2013-05-04 11:21:17 -0400 | [diff] [blame] | 1259 | keypad_send_key(press_str, s); |
| 1260 | } |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1261 | } |
| 1262 | |
| 1263 | if (input->u.kbd.repeat_str[0]) { |
| 1264 | char *repeat_str = input->u.kbd.repeat_str; |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1265 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1266 | if (input->high_timer >= KEYPAD_REP_START) { |
Jake Champlin | e6626de | 2013-05-04 11:21:17 -0400 | [diff] [blame] | 1267 | int s = sizeof(input->u.kbd.repeat_str); |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1268 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1269 | input->high_timer -= KEYPAD_REP_DELAY; |
Jake Champlin | e6626de | 2013-05-04 11:21:17 -0400 | [diff] [blame] | 1270 | keypad_send_key(repeat_str, s); |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1271 | } |
| 1272 | /* we will need to come back here soon */ |
| 1273 | inputs_stable = 0; |
| 1274 | } |
| 1275 | |
| 1276 | if (input->high_timer < 255) |
| 1277 | input->high_timer++; |
| 1278 | } |
| 1279 | return 1; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1280 | } |
Vincent Heuken | 083b363 | 2014-07-10 03:34:28 -0700 | [diff] [blame] | 1281 | |
| 1282 | /* else signal falling down. Let's fall through. */ |
| 1283 | input->state = INPUT_ST_FALLING; |
| 1284 | input->fall_timer = 0; |
| 1285 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1286 | return 0; |
| 1287 | } |
| 1288 | |
| 1289 | static inline void input_state_falling(struct logical_input *input) |
| 1290 | { |
| 1291 | #if 0 |
| 1292 | /* FIXME !!! same comment as in input_state_high */ |
Dominique van den Broeck | fdf4a494 | 2014-05-21 14:10:00 +0200 | [diff] [blame] | 1293 | if (((phys_prev & input->mask) == input->value) && |
| 1294 | ((phys_curr & input->mask) > input->value)) { |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1295 | input->state = INPUT_ST_LOW; /* invalidate */ |
| 1296 | return; |
| 1297 | } |
| 1298 | #endif |
| 1299 | |
| 1300 | if ((phys_curr & input->mask) == input->value) { |
| 1301 | if (input->type == INPUT_TYPE_KBD) { |
| 1302 | /* will turn on the light */ |
| 1303 | keypressed = 1; |
| 1304 | |
| 1305 | if (input->u.kbd.repeat_str[0]) { |
| 1306 | char *repeat_str = input->u.kbd.repeat_str; |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1307 | |
Jake Champlin | e6626de | 2013-05-04 11:21:17 -0400 | [diff] [blame] | 1308 | if (input->high_timer >= KEYPAD_REP_START) { |
| 1309 | int s = sizeof(input->u.kbd.repeat_str); |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1310 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1311 | input->high_timer -= KEYPAD_REP_DELAY; |
Jake Champlin | e6626de | 2013-05-04 11:21:17 -0400 | [diff] [blame] | 1312 | keypad_send_key(repeat_str, s); |
| 1313 | } |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1314 | /* we will need to come back here soon */ |
| 1315 | inputs_stable = 0; |
| 1316 | } |
| 1317 | |
| 1318 | if (input->high_timer < 255) |
| 1319 | input->high_timer++; |
| 1320 | } |
| 1321 | input->state = INPUT_ST_HIGH; |
| 1322 | } else if (input->fall_timer >= input->fall_time) { |
| 1323 | /* call release event */ |
| 1324 | if (input->type == INPUT_TYPE_STD) { |
| 1325 | void (*release_fct)(int) = input->u.std.release_fct; |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1326 | |
Aybuke Ozdemir | b565b3f | 2015-10-03 14:52:09 +0300 | [diff] [blame] | 1327 | if (release_fct) |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1328 | release_fct(input->u.std.release_data); |
| 1329 | } else if (input->type == INPUT_TYPE_KBD) { |
| 1330 | char *release_str = input->u.kbd.release_str; |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1331 | |
Jake Champlin | e6626de | 2013-05-04 11:21:17 -0400 | [diff] [blame] | 1332 | if (release_str[0]) { |
| 1333 | int s = sizeof(input->u.kbd.release_str); |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1334 | |
Jake Champlin | e6626de | 2013-05-04 11:21:17 -0400 | [diff] [blame] | 1335 | keypad_send_key(release_str, s); |
| 1336 | } |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1337 | } |
| 1338 | |
| 1339 | input->state = INPUT_ST_LOW; |
| 1340 | } else { |
| 1341 | input->fall_timer++; |
| 1342 | inputs_stable = 0; |
| 1343 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1344 | } |
| 1345 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1346 | static void panel_process_inputs(void) |
| 1347 | { |
| 1348 | struct list_head *item; |
| 1349 | struct logical_input *input; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1350 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1351 | keypressed = 0; |
| 1352 | inputs_stable = 1; |
| 1353 | list_for_each(item, &logical_inputs) { |
| 1354 | input = list_entry(item, struct logical_input, list); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1355 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1356 | switch (input->state) { |
| 1357 | case INPUT_ST_LOW: |
| 1358 | if ((phys_curr & input->mask) != input->value) |
| 1359 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1360 | /* if all needed ones were already set previously, |
| 1361 | * this means that this logical signal has been |
| 1362 | * activated by the releasing of another combined |
| 1363 | * signal, so we don't want to match. |
| 1364 | * eg: AB -(release B)-> A -(release A)-> 0 : |
| 1365 | * don't match A. |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1366 | */ |
| 1367 | if ((phys_prev & input->mask) == input->value) |
| 1368 | break; |
| 1369 | input->rise_timer = 0; |
| 1370 | input->state = INPUT_ST_RISING; |
| 1371 | /* no break here, fall through */ |
| 1372 | case INPUT_ST_RISING: |
| 1373 | if ((phys_curr & input->mask) != input->value) { |
| 1374 | input->state = INPUT_ST_LOW; |
| 1375 | break; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1376 | } |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1377 | if (input->rise_timer < input->rise_time) { |
| 1378 | inputs_stable = 0; |
| 1379 | input->rise_timer++; |
| 1380 | break; |
| 1381 | } |
| 1382 | input->high_timer = 0; |
| 1383 | input->state = INPUT_ST_HIGH; |
| 1384 | /* no break here, fall through */ |
| 1385 | case INPUT_ST_HIGH: |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1386 | if (input_state_high(input)) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1387 | break; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1388 | /* no break here, fall through */ |
| 1389 | case INPUT_ST_FALLING: |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1390 | input_state_falling(input); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1391 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1392 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1393 | } |
| 1394 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1395 | static void panel_scan_timer(void) |
| 1396 | { |
Mariusz Gorski | a8b2580 | 2014-11-27 22:36:49 +0100 | [diff] [blame] | 1397 | if (keypad.enabled && keypad_initialized) { |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 1398 | if (spin_trylock_irq(&pprt_lock)) { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1399 | phys_scan_contacts(); |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1400 | |
| 1401 | /* no need for the parport anymore */ |
Fengguang Wu | d4d2dbc | 2012-09-09 16:23:46 +0800 | [diff] [blame] | 1402 | spin_unlock_irq(&pprt_lock); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1403 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1404 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1405 | if (!inputs_stable || phys_curr != phys_prev) |
| 1406 | panel_process_inputs(); |
| 1407 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1408 | |
Geert Uytterhoeven | fda4ae1 | 2017-02-06 15:38:10 +0100 | [diff] [blame] | 1409 | if (keypressed && lcd.enabled && lcd.initialized) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1410 | charlcd_poke(lcd.charlcd); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1411 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1412 | mod_timer(&scan_timer, jiffies + INPUT_POLL_TIME); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1413 | } |
| 1414 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1415 | static void init_scan_timer(void) |
| 1416 | { |
Aybuke Ozdemir | b565b3f | 2015-10-03 14:52:09 +0300 | [diff] [blame] | 1417 | if (scan_timer.function) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1418 | return; /* already started */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1419 | |
Aya Mahfouz | 8f6e36c | 2015-02-19 07:58:29 +0200 | [diff] [blame] | 1420 | setup_timer(&scan_timer, (void *)&panel_scan_timer, 0); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1421 | scan_timer.expires = jiffies + INPUT_POLL_TIME; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1422 | add_timer(&scan_timer); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1423 | } |
| 1424 | |
| 1425 | /* converts a name of the form "({BbAaPpSsEe}{01234567-})*" to a series of bits. |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1426 | * if <omask> or <imask> are non-null, they will be or'ed with the bits |
| 1427 | * corresponding to out and in bits respectively. |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1428 | * returns 1 if ok, 0 if error (in which case, nothing is written). |
| 1429 | */ |
Ksenija Stanojevic | 35fe087 | 2016-01-03 20:40:58 +0100 | [diff] [blame] | 1430 | static u8 input_name2mask(const char *name, __u64 *mask, __u64 *value, |
Ksenija Stanojevic | d938e1e | 2016-01-03 20:39:49 +0100 | [diff] [blame] | 1431 | u8 *imask, u8 *omask) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1432 | { |
Ksenija Stanojevic | 8aa7307 | 2016-01-03 20:44:44 +0100 | [diff] [blame] | 1433 | const char sigtab[] = "EeSsPpAaBb"; |
Ksenija Stanojevic | d938e1e | 2016-01-03 20:39:49 +0100 | [diff] [blame] | 1434 | u8 im, om; |
Ksenija Stanojevic | 35fe087 | 2016-01-03 20:40:58 +0100 | [diff] [blame] | 1435 | __u64 m, v; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1436 | |
Ksenija Stanojevic | d12f27e | 2016-01-03 20:42:26 +0100 | [diff] [blame] | 1437 | om = 0; |
| 1438 | im = 0; |
Dominique van den Broeck | 2d53426 | 2014-05-24 01:35:24 +0200 | [diff] [blame] | 1439 | m = 0ULL; |
| 1440 | v = 0ULL; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1441 | while (*name) { |
| 1442 | int in, out, bit, neg; |
Ksenija Stanojevic | 8aa7307 | 2016-01-03 20:44:44 +0100 | [diff] [blame] | 1443 | const char *idx; |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1444 | |
Ksenija Stanojevic | 8aa7307 | 2016-01-03 20:44:44 +0100 | [diff] [blame] | 1445 | idx = strchr(sigtab, *name); |
| 1446 | if (!idx) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1447 | return 0; /* input name not found */ |
Ksenija Stanojevic | 8aa7307 | 2016-01-03 20:44:44 +0100 | [diff] [blame] | 1448 | |
| 1449 | in = idx - sigtab; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1450 | neg = (in & 1); /* odd (lower) names are negated */ |
| 1451 | in >>= 1; |
Amitoj Kaur Chawla | 79f2af6 | 2015-10-16 22:11:36 +0530 | [diff] [blame] | 1452 | im |= BIT(in); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1453 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1454 | name++; |
Ksenija Stanojevic | 52ebf93 | 2016-01-03 20:43:27 +0100 | [diff] [blame] | 1455 | if (*name >= '0' && *name <= '7') { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1456 | out = *name - '0'; |
Amitoj Kaur Chawla | 79f2af6 | 2015-10-16 22:11:36 +0530 | [diff] [blame] | 1457 | om |= BIT(out); |
Dominique van den Broeck | 3ac7690 | 2014-05-21 14:09:59 +0200 | [diff] [blame] | 1458 | } else if (*name == '-') { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1459 | out = 8; |
Dominique van den Broeck | 3ac7690 | 2014-05-21 14:09:59 +0200 | [diff] [blame] | 1460 | } else { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1461 | return 0; /* unknown bit name */ |
Dominique van den Broeck | 3ac7690 | 2014-05-21 14:09:59 +0200 | [diff] [blame] | 1462 | } |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1463 | |
| 1464 | bit = (out * 5) + in; |
| 1465 | |
| 1466 | m |= 1ULL << bit; |
| 1467 | if (!neg) |
| 1468 | v |= 1ULL << bit; |
| 1469 | name++; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1470 | } |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1471 | *mask = m; |
| 1472 | *value = v; |
| 1473 | if (imask) |
| 1474 | *imask |= im; |
| 1475 | if (omask) |
| 1476 | *omask |= om; |
| 1477 | return 1; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1478 | } |
| 1479 | |
| 1480 | /* tries to bind a key to the signal name <name>. The key will send the |
| 1481 | * strings <press>, <repeat>, <release> for these respective events. |
| 1482 | * Returns the pointer to the new key if ok, NULL if the key could not be bound. |
| 1483 | */ |
Peter Huewe | 36d2041 | 2013-02-15 13:47:05 +0100 | [diff] [blame] | 1484 | static struct logical_input *panel_bind_key(const char *name, const char *press, |
| 1485 | const char *repeat, |
| 1486 | const char *release) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1487 | { |
| 1488 | struct logical_input *key; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1489 | |
Dominique van den Broeck | fdf4a494 | 2014-05-21 14:10:00 +0200 | [diff] [blame] | 1490 | key = kzalloc(sizeof(*key), GFP_KERNEL); |
Toshiaki Yamane | eb073a9 | 2012-07-12 22:01:17 +0900 | [diff] [blame] | 1491 | if (!key) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1492 | return NULL; |
Toshiaki Yamane | eb073a9 | 2012-07-12 22:01:17 +0900 | [diff] [blame] | 1493 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1494 | if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i, |
Kulikov Vasiliy | cb46f47 | 2010-07-12 18:48:24 +0400 | [diff] [blame] | 1495 | &scan_mask_o)) { |
| 1496 | kfree(key); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1497 | return NULL; |
Kulikov Vasiliy | cb46f47 | 2010-07-12 18:48:24 +0400 | [diff] [blame] | 1498 | } |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1499 | |
| 1500 | key->type = INPUT_TYPE_KBD; |
| 1501 | key->state = INPUT_ST_LOW; |
| 1502 | key->rise_time = 1; |
| 1503 | key->fall_time = 1; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1504 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1505 | strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str)); |
| 1506 | strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str)); |
| 1507 | strncpy(key->u.kbd.release_str, release, |
| 1508 | sizeof(key->u.kbd.release_str)); |
| 1509 | list_add(&key->list, &logical_inputs); |
| 1510 | return key; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1511 | } |
| 1512 | |
Willy Tarreau | 63023177 | 2008-11-22 12:52:18 +0100 | [diff] [blame] | 1513 | #if 0 |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1514 | /* tries to bind a callback function to the signal name <name>. The function |
| 1515 | * <press_fct> will be called with the <press_data> arg when the signal is |
| 1516 | * activated, and so on for <release_fct>/<release_data> |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1517 | * Returns the pointer to the new signal if ok, NULL if the signal could not |
| 1518 | * be bound. |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1519 | */ |
| 1520 | static struct logical_input *panel_bind_callback(char *name, |
Monam Agarwal | 68d386b | 2014-02-25 19:40:49 +0530 | [diff] [blame] | 1521 | void (*press_fct)(int), |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1522 | int press_data, |
Monam Agarwal | 68d386b | 2014-02-25 19:40:49 +0530 | [diff] [blame] | 1523 | void (*release_fct)(int), |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1524 | int release_data) |
| 1525 | { |
| 1526 | struct logical_input *callback; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1527 | |
Dominique van den Broeck | fdf4a494 | 2014-05-21 14:10:00 +0200 | [diff] [blame] | 1528 | callback = kmalloc(sizeof(*callback), GFP_KERNEL); |
Toshiaki Yamane | eb073a9 | 2012-07-12 22:01:17 +0900 | [diff] [blame] | 1529 | if (!callback) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1530 | return NULL; |
Toshiaki Yamane | eb073a9 | 2012-07-12 22:01:17 +0900 | [diff] [blame] | 1531 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1532 | memset(callback, 0, sizeof(struct logical_input)); |
| 1533 | if (!input_name2mask(name, &callback->mask, &callback->value, |
| 1534 | &scan_mask_i, &scan_mask_o)) |
| 1535 | return NULL; |
| 1536 | |
| 1537 | callback->type = INPUT_TYPE_STD; |
| 1538 | callback->state = INPUT_ST_LOW; |
| 1539 | callback->rise_time = 1; |
| 1540 | callback->fall_time = 1; |
| 1541 | callback->u.std.press_fct = press_fct; |
| 1542 | callback->u.std.press_data = press_data; |
| 1543 | callback->u.std.release_fct = release_fct; |
| 1544 | callback->u.std.release_data = release_data; |
| 1545 | list_add(&callback->list, &logical_inputs); |
| 1546 | return callback; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1547 | } |
Willy Tarreau | 63023177 | 2008-11-22 12:52:18 +0100 | [diff] [blame] | 1548 | #endif |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1549 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1550 | static void keypad_init(void) |
| 1551 | { |
| 1552 | int keynum; |
Bastien Armand | c3ed0af | 2014-04-04 21:45:07 +0200 | [diff] [blame] | 1553 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1554 | init_waitqueue_head(&keypad_read_wait); |
| 1555 | keypad_buflen = 0; /* flushes any eventual noisy keystroke */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1556 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1557 | /* Let's create all known keys */ |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1558 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1559 | for (keynum = 0; keypad_profile[keynum][0][0]; keynum++) { |
| 1560 | panel_bind_key(keypad_profile[keynum][0], |
| 1561 | keypad_profile[keynum][1], |
| 1562 | keypad_profile[keynum][2], |
| 1563 | keypad_profile[keynum][3]); |
| 1564 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1565 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1566 | init_scan_timer(); |
| 1567 | keypad_initialized = 1; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1568 | } |
| 1569 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1570 | /**************************************************/ |
| 1571 | /* device initialization */ |
| 1572 | /**************************************************/ |
| 1573 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1574 | static void panel_attach(struct parport *port) |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1575 | { |
Sudip Mukherjee | 9be83c0 | 2015-05-20 20:56:58 +0530 | [diff] [blame] | 1576 | struct pardev_cb panel_cb; |
| 1577 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1578 | if (port->number != parport) |
| 1579 | return; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1580 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1581 | if (pprt) { |
Toshiaki Yamane | eb073a9 | 2012-07-12 22:01:17 +0900 | [diff] [blame] | 1582 | pr_err("%s: port->number=%d parport=%d, already registered!\n", |
| 1583 | __func__, port->number, parport); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1584 | return; |
| 1585 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1586 | |
Sudip Mukherjee | 9be83c0 | 2015-05-20 20:56:58 +0530 | [diff] [blame] | 1587 | memset(&panel_cb, 0, sizeof(panel_cb)); |
| 1588 | panel_cb.private = &pprt; |
| 1589 | /* panel_cb.flags = 0 should be PARPORT_DEV_EXCL? */ |
| 1590 | |
| 1591 | pprt = parport_register_dev_model(port, "panel", &panel_cb, 0); |
Aybuke Ozdemir | b565b3f | 2015-10-03 14:52:09 +0300 | [diff] [blame] | 1592 | if (!pprt) { |
Toshiaki Yamane | eb073a9 | 2012-07-12 22:01:17 +0900 | [diff] [blame] | 1593 | pr_err("%s: port->number=%d parport=%d, parport_register_device() failed\n", |
| 1594 | __func__, port->number, parport); |
Kulikov Vasiliy | 10f3f5b | 2010-07-30 15:08:20 +0400 | [diff] [blame] | 1595 | return; |
| 1596 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1597 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1598 | if (parport_claim(pprt)) { |
Toshiaki Yamane | eb073a9 | 2012-07-12 22:01:17 +0900 | [diff] [blame] | 1599 | pr_err("could not claim access to parport%d. Aborting.\n", |
| 1600 | parport); |
Kulikov Vasiliy | 10f3f5b | 2010-07-30 15:08:20 +0400 | [diff] [blame] | 1601 | goto err_unreg_device; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1602 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1603 | |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1604 | /* must init LCD first, just in case an IRQ from the keypad is |
| 1605 | * generated at keypad init |
| 1606 | */ |
Mariusz Gorski | a8b2580 | 2014-11-27 22:36:49 +0100 | [diff] [blame] | 1607 | if (lcd.enabled) { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1608 | lcd_init(); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1609 | if (!lcd.charlcd || charlcd_register(lcd.charlcd)) |
Kulikov Vasiliy | 10f3f5b | 2010-07-30 15:08:20 +0400 | [diff] [blame] | 1610 | goto err_unreg_device; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1611 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1612 | |
Mariusz Gorski | a8b2580 | 2014-11-27 22:36:49 +0100 | [diff] [blame] | 1613 | if (keypad.enabled) { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1614 | keypad_init(); |
Kulikov Vasiliy | 10f3f5b | 2010-07-30 15:08:20 +0400 | [diff] [blame] | 1615 | if (misc_register(&keypad_dev)) |
| 1616 | goto err_lcd_unreg; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1617 | } |
Kulikov Vasiliy | 10f3f5b | 2010-07-30 15:08:20 +0400 | [diff] [blame] | 1618 | return; |
| 1619 | |
| 1620 | err_lcd_unreg: |
Mariusz Gorski | a8b2580 | 2014-11-27 22:36:49 +0100 | [diff] [blame] | 1621 | if (lcd.enabled) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1622 | charlcd_unregister(lcd.charlcd); |
Kulikov Vasiliy | 10f3f5b | 2010-07-30 15:08:20 +0400 | [diff] [blame] | 1623 | err_unreg_device: |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1624 | kfree(lcd.charlcd); |
| 1625 | lcd.charlcd = NULL; |
Kulikov Vasiliy | 10f3f5b | 2010-07-30 15:08:20 +0400 | [diff] [blame] | 1626 | parport_unregister_device(pprt); |
| 1627 | pprt = NULL; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1628 | } |
| 1629 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1630 | static void panel_detach(struct parport *port) |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1631 | { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1632 | if (port->number != parport) |
| 1633 | return; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1634 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1635 | if (!pprt) { |
Toshiaki Yamane | eb073a9 | 2012-07-12 22:01:17 +0900 | [diff] [blame] | 1636 | pr_err("%s: port->number=%d parport=%d, nothing to unregister.\n", |
| 1637 | __func__, port->number, parport); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1638 | return; |
| 1639 | } |
Aybuke Ozdemir | b565b3f | 2015-10-03 14:52:09 +0300 | [diff] [blame] | 1640 | if (scan_timer.function) |
Sudip Mukherjee | 7d98c63 | 2015-05-12 17:36:08 +0530 | [diff] [blame] | 1641 | del_timer_sync(&scan_timer); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1642 | |
Geert Uytterhoeven | 3f77b43 | 2017-02-06 15:38:08 +0100 | [diff] [blame] | 1643 | if (keypad.enabled) { |
| 1644 | misc_deregister(&keypad_dev); |
| 1645 | keypad_initialized = 0; |
Peter Huewe | 0b0595b | 2009-09-29 01:22:40 +0200 | [diff] [blame] | 1646 | } |
Geert Uytterhoeven | 3f77b43 | 2017-02-06 15:38:08 +0100 | [diff] [blame] | 1647 | |
| 1648 | if (lcd.enabled) { |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1649 | charlcd_unregister(lcd.charlcd); |
Geert Uytterhoeven | 3f77b43 | 2017-02-06 15:38:08 +0100 | [diff] [blame] | 1650 | lcd.initialized = false; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 1651 | kfree(lcd.charlcd); |
| 1652 | lcd.charlcd = NULL; |
Geert Uytterhoeven | 3f77b43 | 2017-02-06 15:38:08 +0100 | [diff] [blame] | 1653 | } |
| 1654 | |
| 1655 | /* TODO: free all input signals */ |
| 1656 | parport_release(pprt); |
| 1657 | parport_unregister_device(pprt); |
| 1658 | pprt = NULL; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1659 | } |
| 1660 | |
| 1661 | static struct parport_driver panel_driver = { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1662 | .name = "panel", |
Sudip Mukherjee | 9be83c0 | 2015-05-20 20:56:58 +0530 | [diff] [blame] | 1663 | .match_port = panel_attach, |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1664 | .detach = panel_detach, |
Sudip Mukherjee | 9be83c0 | 2015-05-20 20:56:58 +0530 | [diff] [blame] | 1665 | .devmodel = true, |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1666 | }; |
| 1667 | |
| 1668 | /* init function */ |
Mariusz Gorski | d911476 | 2014-11-27 22:36:46 +0100 | [diff] [blame] | 1669 | static int __init panel_init_module(void) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1670 | { |
Sudip Mukherjee | e134201 | 2015-03-09 20:08:24 +0530 | [diff] [blame] | 1671 | int selected_keypad_type = NOT_SET, err; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1672 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1673 | /* take care of an eventual profile */ |
| 1674 | switch (profile) { |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1675 | case PANEL_PROFILE_CUSTOM: |
| 1676 | /* custom profile */ |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1677 | selected_keypad_type = DEFAULT_KEYPAD_TYPE; |
| 1678 | selected_lcd_type = DEFAULT_LCD_TYPE; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1679 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1680 | case PANEL_PROFILE_OLD: |
| 1681 | /* 8 bits, 2*16, old keypad */ |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1682 | selected_keypad_type = KEYPAD_TYPE_OLD; |
| 1683 | selected_lcd_type = LCD_TYPE_OLD; |
| 1684 | |
| 1685 | /* TODO: This two are a little hacky, sort it out later */ |
Mariusz Gorski | 2d35bcf | 2014-11-27 22:36:48 +0100 | [diff] [blame] | 1686 | if (lcd_width == NOT_SET) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1687 | lcd_width = 16; |
Mariusz Gorski | 2d35bcf | 2014-11-27 22:36:48 +0100 | [diff] [blame] | 1688 | if (lcd_hwidth == NOT_SET) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1689 | lcd_hwidth = 16; |
| 1690 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1691 | case PANEL_PROFILE_NEW: |
| 1692 | /* serial, 2*16, new keypad */ |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1693 | selected_keypad_type = KEYPAD_TYPE_NEW; |
| 1694 | selected_lcd_type = LCD_TYPE_KS0074; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1695 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1696 | case PANEL_PROFILE_HANTRONIX: |
| 1697 | /* 8 bits, 2*16 hantronix-like, no keypad */ |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1698 | selected_keypad_type = KEYPAD_TYPE_NONE; |
| 1699 | selected_lcd_type = LCD_TYPE_HANTRONIX; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1700 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1701 | case PANEL_PROFILE_NEXCOM: |
| 1702 | /* generic 8 bits, 2*16, nexcom keypad, eg. Nexcom. */ |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1703 | selected_keypad_type = KEYPAD_TYPE_NEXCOM; |
| 1704 | selected_lcd_type = LCD_TYPE_NEXCOM; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1705 | break; |
Henri Häkkinen | 429ccf0 | 2010-06-12 00:27:36 +0300 | [diff] [blame] | 1706 | case PANEL_PROFILE_LARGE: |
| 1707 | /* 8 bits, 2*40, old keypad */ |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1708 | selected_keypad_type = KEYPAD_TYPE_OLD; |
| 1709 | selected_lcd_type = LCD_TYPE_OLD; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1710 | break; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1711 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1712 | |
Mariusz Gorski | 8037e2a | 2014-11-27 22:36:51 +0100 | [diff] [blame] | 1713 | /* |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1714 | * Overwrite selection with module param values (both keypad and lcd), |
| 1715 | * where the deprecated params have lower prio. |
| 1716 | */ |
Mariusz Gorski | 1a4b2e3 | 2014-11-27 22:36:52 +0100 | [diff] [blame] | 1717 | if (keypad_enabled != NOT_SET) |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1718 | selected_keypad_type = keypad_enabled; |
Mariusz Gorski | 1a4b2e3 | 2014-11-27 22:36:52 +0100 | [diff] [blame] | 1719 | if (keypad_type != NOT_SET) |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1720 | selected_keypad_type = keypad_type; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1721 | |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1722 | keypad.enabled = (selected_keypad_type > 0); |
| 1723 | |
Mariusz Gorski | 1a4b2e3 | 2014-11-27 22:36:52 +0100 | [diff] [blame] | 1724 | if (lcd_enabled != NOT_SET) |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1725 | selected_lcd_type = lcd_enabled; |
Mariusz Gorski | 1a4b2e3 | 2014-11-27 22:36:52 +0100 | [diff] [blame] | 1726 | if (lcd_type != NOT_SET) |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1727 | selected_lcd_type = lcd_type; |
| 1728 | |
| 1729 | lcd.enabled = (selected_lcd_type > 0); |
| 1730 | |
Sudip Mukherjee | 733345e | 2015-02-11 16:57:08 +0530 | [diff] [blame] | 1731 | if (lcd.enabled) { |
| 1732 | /* |
| 1733 | * Init lcd struct with load-time values to preserve exact |
| 1734 | * current functionality (at least for now). |
| 1735 | */ |
Sudip Mukherjee | 733345e | 2015-02-11 16:57:08 +0530 | [diff] [blame] | 1736 | lcd.charset = lcd_charset; |
| 1737 | lcd.proto = lcd_proto; |
| 1738 | lcd.pins.e = lcd_e_pin; |
| 1739 | lcd.pins.rs = lcd_rs_pin; |
| 1740 | lcd.pins.rw = lcd_rw_pin; |
| 1741 | lcd.pins.cl = lcd_cl_pin; |
| 1742 | lcd.pins.da = lcd_da_pin; |
| 1743 | lcd.pins.bl = lcd_bl_pin; |
Sudip Mukherjee | 733345e | 2015-02-11 16:57:08 +0530 | [diff] [blame] | 1744 | } |
| 1745 | |
Mariusz Gorski | 87b8e0c | 2014-11-27 22:36:50 +0100 | [diff] [blame] | 1746 | switch (selected_keypad_type) { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1747 | case KEYPAD_TYPE_OLD: |
| 1748 | keypad_profile = old_keypad_profile; |
| 1749 | break; |
| 1750 | case KEYPAD_TYPE_NEW: |
| 1751 | keypad_profile = new_keypad_profile; |
| 1752 | break; |
| 1753 | case KEYPAD_TYPE_NEXCOM: |
| 1754 | keypad_profile = nexcom_keypad_profile; |
| 1755 | break; |
| 1756 | default: |
| 1757 | keypad_profile = NULL; |
| 1758 | break; |
| 1759 | } |
| 1760 | |
Sudip Mukherjee | f43de77 | 2015-02-10 17:26:02 +0530 | [diff] [blame] | 1761 | if (!lcd.enabled && !keypad.enabled) { |
| 1762 | /* no device enabled, let's exit */ |
Geert Uytterhoeven | 30f468b | 2017-02-06 15:38:04 +0100 | [diff] [blame] | 1763 | pr_err("panel driver disabled.\n"); |
Sudip Mukherjee | f43de77 | 2015-02-10 17:26:02 +0530 | [diff] [blame] | 1764 | return -ENODEV; |
| 1765 | } |
| 1766 | |
Sudip Mukherjee | e134201 | 2015-03-09 20:08:24 +0530 | [diff] [blame] | 1767 | err = parport_register_driver(&panel_driver); |
| 1768 | if (err) { |
Toshiaki Yamane | eb073a9 | 2012-07-12 22:01:17 +0900 | [diff] [blame] | 1769 | pr_err("could not register with parport. Aborting.\n"); |
Sudip Mukherjee | e134201 | 2015-03-09 20:08:24 +0530 | [diff] [blame] | 1770 | return err; |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1771 | } |
| 1772 | |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1773 | if (pprt) |
Geert Uytterhoeven | 30f468b | 2017-02-06 15:38:04 +0100 | [diff] [blame] | 1774 | pr_info("panel driver registered on parport%d (io=0x%lx).\n", |
| 1775 | parport, pprt->port->base); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1776 | else |
Geert Uytterhoeven | 30f468b | 2017-02-06 15:38:04 +0100 | [diff] [blame] | 1777 | pr_info("panel driver not yet registered\n"); |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1778 | return 0; |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1779 | } |
| 1780 | |
Willy Tarreau | f6d1fcf | 2008-11-22 12:04:19 +0100 | [diff] [blame] | 1781 | static void __exit panel_cleanup_module(void) |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1782 | { |
Willy Tarreau | 698b151 | 2008-11-22 11:29:33 +0100 | [diff] [blame] | 1783 | parport_unregister_driver(&panel_driver); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1784 | } |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1785 | |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1786 | module_init(panel_init_module); |
| 1787 | module_exit(panel_cleanup_module); |
| 1788 | MODULE_AUTHOR("Willy Tarreau"); |
| 1789 | MODULE_LICENSE("GPL"); |
Willy Tarreau | 7005b58 | 2008-11-13 17:18:59 -0800 | [diff] [blame] | 1790 | |
| 1791 | /* |
| 1792 | * Local variables: |
| 1793 | * c-indent-level: 4 |
| 1794 | * tab-width: 8 |
| 1795 | * End: |
| 1796 | */ |