16ab0f5cdSMatthew Wilcox /* 26ab0f5cdSMatthew Wilcox * HP i8042 System Device Controller -- header 36ab0f5cdSMatthew Wilcox * 46ab0f5cdSMatthew Wilcox * Copyright (c) 2001 Brian S. Julin 56ab0f5cdSMatthew Wilcox * All rights reserved. 66ab0f5cdSMatthew Wilcox * 76ab0f5cdSMatthew Wilcox * Redistribution and use in source and binary forms, with or without 86ab0f5cdSMatthew Wilcox * modification, are permitted provided that the following conditions 96ab0f5cdSMatthew Wilcox * are met: 106ab0f5cdSMatthew Wilcox * 1. Redistributions of source code must retain the above copyright 116ab0f5cdSMatthew Wilcox * notice, this list of conditions, and the following disclaimer, 126ab0f5cdSMatthew Wilcox * without modification. 136ab0f5cdSMatthew Wilcox * 2. The name of the author may not be used to endorse or promote products 146ab0f5cdSMatthew Wilcox * derived from this software without specific prior written permission. 156ab0f5cdSMatthew Wilcox * 166ab0f5cdSMatthew Wilcox * Alternatively, this software may be distributed under the terms of the 176ab0f5cdSMatthew Wilcox * GNU General Public License ("GPL"). 186ab0f5cdSMatthew Wilcox * 196ab0f5cdSMatthew Wilcox * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 206ab0f5cdSMatthew Wilcox * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 216ab0f5cdSMatthew Wilcox * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 226ab0f5cdSMatthew Wilcox * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 236ab0f5cdSMatthew Wilcox * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 246ab0f5cdSMatthew Wilcox * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 256ab0f5cdSMatthew Wilcox * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 266ab0f5cdSMatthew Wilcox * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 276ab0f5cdSMatthew Wilcox * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 286ab0f5cdSMatthew Wilcox * 296ab0f5cdSMatthew Wilcox * References: 306ab0f5cdSMatthew Wilcox * 316ab0f5cdSMatthew Wilcox * HP-HIL Technical Reference Manual. Hewlett Packard Product No. 45918A 326ab0f5cdSMatthew Wilcox * 336ab0f5cdSMatthew Wilcox * System Device Controller Microprocessor Firmware Theory of Operation 346ab0f5cdSMatthew Wilcox * for Part Number 1820-4784 Revision B. Dwg No. A-1820-4784-2 356ab0f5cdSMatthew Wilcox * 366ab0f5cdSMatthew Wilcox */ 376ab0f5cdSMatthew Wilcox 386ab0f5cdSMatthew Wilcox #ifndef _LINUX_HP_SDC_H 396ab0f5cdSMatthew Wilcox #define _LINUX_HP_SDC_H 406ab0f5cdSMatthew Wilcox 416ab0f5cdSMatthew Wilcox #include <linux/interrupt.h> 426ab0f5cdSMatthew Wilcox #include <linux/types.h> 436ab0f5cdSMatthew Wilcox #include <linux/time.h> 446ab0f5cdSMatthew Wilcox #include <linux/timer.h> 456ab0f5cdSMatthew Wilcox #if defined(__hppa__) 466ab0f5cdSMatthew Wilcox #include <asm/hardware.h> 476ab0f5cdSMatthew Wilcox #endif 486ab0f5cdSMatthew Wilcox 496ab0f5cdSMatthew Wilcox 506ab0f5cdSMatthew Wilcox /* No 4X status reads take longer than this (in usec). 516ab0f5cdSMatthew Wilcox */ 526ab0f5cdSMatthew Wilcox #define HP_SDC_MAX_REG_DELAY 20000 536ab0f5cdSMatthew Wilcox 546ab0f5cdSMatthew Wilcox typedef void (hp_sdc_irqhook) (int irq, void *dev_id, 556ab0f5cdSMatthew Wilcox uint8_t status, uint8_t data); 566ab0f5cdSMatthew Wilcox 576ab0f5cdSMatthew Wilcox int hp_sdc_request_timer_irq(hp_sdc_irqhook *callback); 586ab0f5cdSMatthew Wilcox int hp_sdc_request_hil_irq(hp_sdc_irqhook *callback); 596ab0f5cdSMatthew Wilcox int hp_sdc_request_cooked_irq(hp_sdc_irqhook *callback); 606ab0f5cdSMatthew Wilcox int hp_sdc_release_timer_irq(hp_sdc_irqhook *callback); 616ab0f5cdSMatthew Wilcox int hp_sdc_release_hil_irq(hp_sdc_irqhook *callback); 626ab0f5cdSMatthew Wilcox int hp_sdc_release_cooked_irq(hp_sdc_irqhook *callback); 636ab0f5cdSMatthew Wilcox 646ab0f5cdSMatthew Wilcox typedef struct { 656ab0f5cdSMatthew Wilcox int actidx; /* Start of act. Acts are atomic WRT I/O to SDC */ 666ab0f5cdSMatthew Wilcox int idx; /* Index within the act */ 676ab0f5cdSMatthew Wilcox int endidx; /* transaction is over and done if idx == endidx */ 686ab0f5cdSMatthew Wilcox uint8_t *seq; /* commands/data for the transaction */ 696ab0f5cdSMatthew Wilcox union { 706ab0f5cdSMatthew Wilcox hp_sdc_irqhook *irqhook; /* Callback, isr or tasklet context */ 716ab0f5cdSMatthew Wilcox struct semaphore *semaphore; /* Semaphore to sleep on. */ 726ab0f5cdSMatthew Wilcox } act; 736ab0f5cdSMatthew Wilcox } hp_sdc_transaction; 749575499dSHelge Deller int __hp_sdc_enqueue_transaction(hp_sdc_transaction *this); 756ab0f5cdSMatthew Wilcox int hp_sdc_enqueue_transaction(hp_sdc_transaction *this); 766ab0f5cdSMatthew Wilcox int hp_sdc_dequeue_transaction(hp_sdc_transaction *this); 776ab0f5cdSMatthew Wilcox 786ab0f5cdSMatthew Wilcox /* The HP_SDC_ACT* values are peculiar to this driver. 796ab0f5cdSMatthew Wilcox * Nuance: never HP_SDC_ACT_DATAIN | HP_SDC_ACT_DEALLOC, use another 806ab0f5cdSMatthew Wilcox * act to perform the dealloc. 816ab0f5cdSMatthew Wilcox */ 826ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_PRECMD 0x01 /* Send a command first */ 836ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_DATAREG 0x02 /* Set data registers */ 846ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_DATAOUT 0x04 /* Send data bytes */ 856ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_POSTCMD 0x08 /* Send command after */ 866ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_DATAIN 0x10 /* Collect data after */ 876ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_DURING 0x1f 886ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_SEMAPHORE 0x20 /* Raise semaphore after */ 896ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_CALLBACK 0x40 /* Pass data to IRQ handler */ 906ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_DEALLOC 0x80 /* Destroy transaction after */ 916ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_AFTER 0xe0 926ab0f5cdSMatthew Wilcox #define HP_SDC_ACT_DEAD 0x60 /* Act timed out. */ 936ab0f5cdSMatthew Wilcox 946ab0f5cdSMatthew Wilcox /* Rest of the flags are straightforward representation of the SDC interface */ 956ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_IBF 0x02 /* Input buffer full */ 966ab0f5cdSMatthew Wilcox 976ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_IRQMASK 0xf0 /* Bits containing "level 1" irq */ 986ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_PERIODIC 0x10 /* Periodic 10ms timer */ 996ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_USERTIMER 0x20 /* "Special purpose" timer */ 1006ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_TIMER 0x30 /* Both PERIODIC and USERTIMER */ 1016ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_REG 0x40 /* Data from an i8042 register */ 1026ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_HILCMD 0x50 /* Command from HIL MLC */ 1036ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_HILDATA 0x60 /* Data from HIL MLC */ 10425985edcSLucas De Marchi #define HP_SDC_STATUS_PUP 0x70 /* Successful power-up self test */ 1056ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_KCOOKED 0x80 /* Key from cooked kbd */ 1066ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_KRPG 0xc0 /* Key from Repeat Gen */ 1076ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_KMOD_SUP 0x10 /* Shift key is up */ 1086ab0f5cdSMatthew Wilcox #define HP_SDC_STATUS_KMOD_CUP 0x20 /* Control key is up */ 1096ab0f5cdSMatthew Wilcox 1106ab0f5cdSMatthew Wilcox #define HP_SDC_NMISTATUS_FHS 0x40 /* NMI is a fast handshake irq */ 1116ab0f5cdSMatthew Wilcox 1126ab0f5cdSMatthew Wilcox /* Internal i8042 registers (there are more, but they are not too useful). */ 1136ab0f5cdSMatthew Wilcox 1146ab0f5cdSMatthew Wilcox #define HP_SDC_USE 0x02 /* Resource usage (including OB bit) */ 1156ab0f5cdSMatthew Wilcox #define HP_SDC_IM 0x04 /* Interrupt mask */ 1166ab0f5cdSMatthew Wilcox #define HP_SDC_CFG 0x11 /* Configuration register */ 1176ab0f5cdSMatthew Wilcox #define HP_SDC_KBLANGUAGE 0x12 /* Keyboard language */ 1186ab0f5cdSMatthew Wilcox 1196ab0f5cdSMatthew Wilcox #define HP_SDC_D0 0x70 /* General purpose data buffer 0 */ 1206ab0f5cdSMatthew Wilcox #define HP_SDC_D1 0x71 /* General purpose data buffer 1 */ 1216ab0f5cdSMatthew Wilcox #define HP_SDC_D2 0x72 /* General purpose data buffer 2 */ 1226ab0f5cdSMatthew Wilcox #define HP_SDC_D3 0x73 /* General purpose data buffer 3 */ 1236ab0f5cdSMatthew Wilcox #define HP_SDC_VT1 0x74 /* Timer for voice 1 */ 1246ab0f5cdSMatthew Wilcox #define HP_SDC_VT2 0x75 /* Timer for voice 2 */ 1256ab0f5cdSMatthew Wilcox #define HP_SDC_VT3 0x76 /* Timer for voice 3 */ 1266ab0f5cdSMatthew Wilcox #define HP_SDC_VT4 0x77 /* Timer for voice 4 */ 1276ab0f5cdSMatthew Wilcox #define HP_SDC_KBN 0x78 /* Which HIL devs are Nimitz */ 1286ab0f5cdSMatthew Wilcox #define HP_SDC_KBC 0x79 /* Which HIL devs are cooked kbds */ 1296ab0f5cdSMatthew Wilcox #define HP_SDC_LPS 0x7a /* i8042's view of HIL status */ 1306ab0f5cdSMatthew Wilcox #define HP_SDC_LPC 0x7b /* i8042's view of HIL "control" */ 1316ab0f5cdSMatthew Wilcox #define HP_SDC_RSV 0x7c /* Reserved "for testing" */ 1326ab0f5cdSMatthew Wilcox #define HP_SDC_LPR 0x7d /* i8042 count of HIL reconfigs */ 1336ab0f5cdSMatthew Wilcox #define HP_SDC_XTD 0x7e /* "Extended Configuration" register */ 1346ab0f5cdSMatthew Wilcox #define HP_SDC_STR 0x7f /* i8042 self-test result */ 1356ab0f5cdSMatthew Wilcox 1366ab0f5cdSMatthew Wilcox /* Bitfields for above registers */ 1376ab0f5cdSMatthew Wilcox #define HP_SDC_USE_LOOP 0x04 /* Command is currently on the loop. */ 1386ab0f5cdSMatthew Wilcox 1396ab0f5cdSMatthew Wilcox #define HP_SDC_IM_MASK 0x1f /* these bits not part of cmd/status */ 1406ab0f5cdSMatthew Wilcox #define HP_SDC_IM_FH 0x10 /* Mask the fast handshake irq */ 1416ab0f5cdSMatthew Wilcox #define HP_SDC_IM_PT 0x08 /* Mask the periodic timer irq */ 1426ab0f5cdSMatthew Wilcox #define HP_SDC_IM_TIMERS 0x04 /* Mask the MT/DT/CT irq */ 1436ab0f5cdSMatthew Wilcox #define HP_SDC_IM_RESET 0x02 /* Mask the reset key irq */ 1446ab0f5cdSMatthew Wilcox #define HP_SDC_IM_HIL 0x01 /* Mask the HIL MLC irq */ 1456ab0f5cdSMatthew Wilcox 1466ab0f5cdSMatthew Wilcox #define HP_SDC_CFG_ROLLOVER 0x08 /* WTF is "N-key rollover"? */ 1476ab0f5cdSMatthew Wilcox #define HP_SDC_CFG_KBD 0x10 /* There is a keyboard */ 1486ab0f5cdSMatthew Wilcox #define HP_SDC_CFG_NEW 0x20 /* Supports/uses HIL MLC */ 1496ab0f5cdSMatthew Wilcox #define HP_SDC_CFG_KBD_OLD 0x03 /* keyboard code for non-HIL */ 1506ab0f5cdSMatthew Wilcox #define HP_SDC_CFG_KBD_NEW 0x07 /* keyboard code from HIL autoconfig */ 1516ab0f5cdSMatthew Wilcox #define HP_SDC_CFG_REV 0x40 /* Code revision bit */ 1526ab0f5cdSMatthew Wilcox #define HP_SDC_CFG_IDPROM 0x80 /* IDPROM present in kbd (not HIL) */ 1536ab0f5cdSMatthew Wilcox 1546ab0f5cdSMatthew Wilcox #define HP_SDC_LPS_NDEV 0x07 /* # devices autoconfigured on HIL */ 1556ab0f5cdSMatthew Wilcox #define HP_SDC_LPS_ACSUCC 0x08 /* loop autoconfigured successfully */ 1566ab0f5cdSMatthew Wilcox #define HP_SDC_LPS_ACFAIL 0x80 /* last loop autoconfigure failed */ 1576ab0f5cdSMatthew Wilcox 1586ab0f5cdSMatthew Wilcox #define HP_SDC_LPC_APE_IPF 0x01 /* HIL MLC APE/IPF (autopoll) set */ 1596ab0f5cdSMatthew Wilcox #define HP_SDC_LPC_ARCONERR 0x02 /* i8042 autoreconfigs loop on err */ 1606ab0f5cdSMatthew Wilcox #define HP_SDC_LPC_ARCQUIET 0x03 /* i8042 doesn't report autoreconfigs*/ 1616ab0f5cdSMatthew Wilcox #define HP_SDC_LPC_COOK 0x10 /* i8042 cooks devices in _KBN */ 1626ab0f5cdSMatthew Wilcox #define HP_SDC_LPC_RC 0x80 /* causes autoreconfig */ 1636ab0f5cdSMatthew Wilcox 1646ab0f5cdSMatthew Wilcox #define HP_SDC_XTD_REV 0x07 /* contains revision code */ 1656ab0f5cdSMatthew Wilcox #define HP_SDC_XTD_REV_STRINGS(val, str) \ 1666ab0f5cdSMatthew Wilcox switch (val) { \ 1676ab0f5cdSMatthew Wilcox case 0x1: str = "1820-3712"; break; \ 1686ab0f5cdSMatthew Wilcox case 0x2: str = "1820-4379"; break; \ 1696ab0f5cdSMatthew Wilcox case 0x3: str = "1820-4784"; break; \ 1706ab0f5cdSMatthew Wilcox default: str = "unknown"; \ 1716ab0f5cdSMatthew Wilcox }; 1726ab0f5cdSMatthew Wilcox #define HP_SDC_XTD_BEEPER 0x08 /* TI SN76494 beeper available */ 1736ab0f5cdSMatthew Wilcox #define HP_SDC_XTD_BBRTC 0x20 /* OKI MSM-58321 BBRTC present */ 1746ab0f5cdSMatthew Wilcox 1756ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_LOAD_RT 0x31 /* Load real time (from 8042) */ 1766ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_LOAD_FHS 0x36 /* Load the fast handshake timer */ 1776ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_LOAD_MT 0x38 /* Load the match timer */ 1786ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_LOAD_DT 0x3B /* Load the delay timer */ 1796ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_LOAD_CT 0x3E /* Load the cycle timer */ 1806ab0f5cdSMatthew Wilcox 1816ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_IM 0x40 /* 010xxxxx == set irq mask */ 1826ab0f5cdSMatthew Wilcox 183*4b9d1bc7SJiangshan Yi /* The documents provided do not explicitly state that all registers between 1846ab0f5cdSMatthew Wilcox * 0x01 and 0x1f inclusive can be read by sending their register index as a 1856ab0f5cdSMatthew Wilcox * command, but this is implied and appears to be the case. 1866ab0f5cdSMatthew Wilcox */ 1876ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_RAM 0x00 /* Load from i8042 RAM (autoinc) */ 1886ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_USE 0x02 /* Undocumented! Load from usage reg */ 1896ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_IM 0x04 /* Load current interrupt mask */ 1906ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_KCC 0x11 /* Load primary kbd config code */ 1916ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_KLC 0x12 /* Load primary kbd language code */ 1926ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_T1 0x13 /* Load timer output buffer byte 1 */ 1936ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_T2 0x14 /* Load timer output buffer byte 1 */ 1946ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_T3 0x15 /* Load timer output buffer byte 1 */ 1956ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_T4 0x16 /* Load timer output buffer byte 1 */ 1966ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_T5 0x17 /* Load timer output buffer byte 1 */ 1976ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_D0 0xf0 /* Load from i8042 RAM location 0x70 */ 1986ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_D1 0xf1 /* Load from i8042 RAM location 0x71 */ 1996ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_D2 0xf2 /* Load from i8042 RAM location 0x72 */ 2006ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_D3 0xf3 /* Load from i8042 RAM location 0x73 */ 2016ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_VT1 0xf4 /* Load from i8042 RAM location 0x74 */ 2026ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_VT2 0xf5 /* Load from i8042 RAM location 0x75 */ 2036ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_VT3 0xf6 /* Load from i8042 RAM location 0x76 */ 2046ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_VT4 0xf7 /* Load from i8042 RAM location 0x77 */ 2056ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_KBN 0xf8 /* Load from i8042 RAM location 0x78 */ 2066ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_KBC 0xf9 /* Load from i8042 RAM location 0x79 */ 2076ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_LPS 0xfa /* Load from i8042 RAM location 0x7a */ 2086ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_LPC 0xfb /* Load from i8042 RAM location 0x7b */ 2096ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_RSV 0xfc /* Load from i8042 RAM location 0x7c */ 2106ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_LPR 0xfd /* Load from i8042 RAM location 0x7d */ 2116ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_XTD 0xfe /* Load from i8042 RAM location 0x7e */ 2126ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_READ_STR 0xff /* Load from i8042 RAM location 0x7f */ 2136ab0f5cdSMatthew Wilcox 2146ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_ARD 0xA0 /* Set emulated autorepeat delay */ 2156ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_ARR 0xA2 /* Set emulated autorepeat rate */ 2166ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_BELL 0xA3 /* Set voice 3 params for "beep" cmd */ 2176ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_RPGR 0xA6 /* Set "RPG" irq rate (doesn't work) */ 2186ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_RTMS 0xAD /* Set the RTC time (milliseconds) */ 2196ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_RTD 0xAF /* Set the RTC time (days) */ 2206ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_FHS 0xB2 /* Set fast handshake timer */ 2216ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_MT 0xB4 /* Set match timer */ 2226ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_DT 0xB7 /* Set delay timer */ 2236ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_CT 0xBA /* Set cycle timer */ 2246ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_RAMP 0xC1 /* Reset READ_RAM autoinc counter */ 2256ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_D0 0xe0 /* Load to i8042 RAM location 0x70 */ 2266ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_D1 0xe1 /* Load to i8042 RAM location 0x71 */ 2276ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_D2 0xe2 /* Load to i8042 RAM location 0x72 */ 2286ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_D3 0xe3 /* Load to i8042 RAM location 0x73 */ 2296ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_VT1 0xe4 /* Load to i8042 RAM location 0x74 */ 2306ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_VT2 0xe5 /* Load to i8042 RAM location 0x75 */ 2316ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_VT3 0xe6 /* Load to i8042 RAM location 0x76 */ 2326ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_VT4 0xe7 /* Load to i8042 RAM location 0x77 */ 2336ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_KBN 0xe8 /* Load to i8042 RAM location 0x78 */ 2346ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_KBC 0xe9 /* Load to i8042 RAM location 0x79 */ 2356ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_LPS 0xea /* Load to i8042 RAM location 0x7a */ 2366ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_LPC 0xeb /* Load to i8042 RAM location 0x7b */ 2376ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_RSV 0xec /* Load to i8042 RAM location 0x7c */ 2386ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_LPR 0xed /* Load to i8042 RAM location 0x7d */ 2396ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_XTD 0xee /* Load to i8042 RAM location 0x7e */ 2406ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_SET_STR 0xef /* Load to i8042 RAM location 0x7f */ 2416ab0f5cdSMatthew Wilcox 2426ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_DO_RTCW 0xc2 /* i8042 RAM 0x70 --> RTC */ 2436ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_DO_RTCR 0xc3 /* RTC[0x70 0:3] --> irq/status/data */ 2446ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_DO_BEEP 0xc4 /* i8042 RAM 0x70-74 --> beeper,VT3 */ 2456ab0f5cdSMatthew Wilcox #define HP_SDC_CMD_DO_HIL 0xc5 /* i8042 RAM 0x70-73 --> 2466ab0f5cdSMatthew Wilcox HIL MLC R0,R1 i8042 HIL watchdog */ 2476ab0f5cdSMatthew Wilcox 2486ab0f5cdSMatthew Wilcox /* Values used to (de)mangle input/output to/from the HIL MLC */ 2496ab0f5cdSMatthew Wilcox #define HP_SDC_DATA 0x40 /* Data from an 8042 register */ 2506ab0f5cdSMatthew Wilcox #define HP_SDC_HIL_CMD 0x50 /* Data from HIL MLC R1/8042 */ 2516ab0f5cdSMatthew Wilcox #define HP_SDC_HIL_R1MASK 0x0f /* Contents of HIL MLC R1 0:3 */ 2526ab0f5cdSMatthew Wilcox #define HP_SDC_HIL_AUTO 0x10 /* Set if POL results from i8042 */ 2536ab0f5cdSMatthew Wilcox #define HP_SDC_HIL_ISERR 0x80 /* Has meaning as in next 4 values */ 2546ab0f5cdSMatthew Wilcox #define HP_SDC_HIL_RC_DONE 0x80 /* i8042 auto-configured loop */ 2556ab0f5cdSMatthew Wilcox #define HP_SDC_HIL_ERR 0x81 /* HIL MLC R2 had a bit set */ 2566ab0f5cdSMatthew Wilcox #define HP_SDC_HIL_TO 0x82 /* i8042 HIL watchdog expired */ 2576ab0f5cdSMatthew Wilcox #define HP_SDC_HIL_RC 0x84 /* i8042 is auto-configuring loop */ 2586ab0f5cdSMatthew Wilcox #define HP_SDC_HIL_DAT 0x60 /* Data from HIL MLC R0 */ 2596ab0f5cdSMatthew Wilcox 2606ab0f5cdSMatthew Wilcox 2616ab0f5cdSMatthew Wilcox typedef struct { 2626ab0f5cdSMatthew Wilcox rwlock_t ibf_lock; 2636ab0f5cdSMatthew Wilcox rwlock_t lock; /* user/tasklet lock */ 2646ab0f5cdSMatthew Wilcox rwlock_t rtq_lock; /* isr/tasklet lock */ 2656ab0f5cdSMatthew Wilcox rwlock_t hook_lock; /* isr/user lock for handler add/del */ 2666ab0f5cdSMatthew Wilcox 2676ab0f5cdSMatthew Wilcox unsigned int irq, nmi; /* Our IRQ lines */ 2686ab0f5cdSMatthew Wilcox unsigned long base_io, status_io, data_io; /* Our IO ports */ 2696ab0f5cdSMatthew Wilcox 2706ab0f5cdSMatthew Wilcox uint8_t im; /* Interrupt mask */ 2716ab0f5cdSMatthew Wilcox int set_im; /* Interrupt mask needs to be set. */ 2726ab0f5cdSMatthew Wilcox 2736ab0f5cdSMatthew Wilcox int ibf; /* Last known status of IBF flag */ 2746ab0f5cdSMatthew Wilcox uint8_t wi; /* current i8042 write index */ 2756ab0f5cdSMatthew Wilcox uint8_t r7[4]; /* current i8042[0x70 - 0x74] values */ 2766ab0f5cdSMatthew Wilcox uint8_t r11, r7e; /* Values from version/revision regs */ 2776ab0f5cdSMatthew Wilcox 2786ab0f5cdSMatthew Wilcox hp_sdc_irqhook *timer, *reg, *hil, *pup, *cooked; 2796ab0f5cdSMatthew Wilcox 2806ab0f5cdSMatthew Wilcox #define HP_SDC_QUEUE_LEN 16 2816ab0f5cdSMatthew Wilcox hp_sdc_transaction *tq[HP_SDC_QUEUE_LEN]; /* All pending read/writes */ 2826ab0f5cdSMatthew Wilcox 2836ab0f5cdSMatthew Wilcox int rcurr, rqty; /* Current read transact in process */ 284d09ac610SArnd Bergmann ktime_t rtime; /* Time when current read started */ 2856ab0f5cdSMatthew Wilcox int wcurr; /* Current write transact in process */ 2866ab0f5cdSMatthew Wilcox 2876ab0f5cdSMatthew Wilcox int dev_err; /* carries status from registration */ 2886ab0f5cdSMatthew Wilcox #if defined(__hppa__) 2896ab0f5cdSMatthew Wilcox struct parisc_device *dev; 2906ab0f5cdSMatthew Wilcox #elif defined(__mc68000__) 2916ab0f5cdSMatthew Wilcox void *dev; 2926ab0f5cdSMatthew Wilcox #else 2936ab0f5cdSMatthew Wilcox #error No support for device registration on this arch yet. 2946ab0f5cdSMatthew Wilcox #endif 2956ab0f5cdSMatthew Wilcox 2966ab0f5cdSMatthew Wilcox struct timer_list kicker; /* Keeps below task alive */ 2976ab0f5cdSMatthew Wilcox struct tasklet_struct task; 2986ab0f5cdSMatthew Wilcox 2996ab0f5cdSMatthew Wilcox } hp_i8042_sdc; 3006ab0f5cdSMatthew Wilcox 3016ab0f5cdSMatthew Wilcox #endif /* _LINUX_HP_SDC_H */ 302