1/*
2 *  linux/include/asm-ppc/keyboard.h
3 *
4 *  Created 3 Nov 1996 by Geert Uytterhoeven
5 *  Modified for Power Macintosh by Paul Mackerras
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13/*
14 * This file contains the ppc architecture specific keyboard definitions -
15 * like the intel pc for prep systems, different for power macs.
16 */
17
18#ifndef __ASMPPC64_KEYBOARD_H
19#define __ASMPPC64_KEYBOARD_H
20
21#ifdef __KERNEL__
22
23#include <linux/adb.h>
24#include <asm/machdep.h>
25
26#include <linux/kernel.h>
27#include <linux/ioport.h>
28#include <linux/kd.h>
29#include <asm/io.h>
30
31#define KEYBOARD_IRQ			1
32#define DISABLE_KBD_DURING_INTERRUPTS	0
33#define INIT_KBD
34
35static inline int kbd_setkeycode(unsigned int scancode, unsigned int keycode)
36{
37	if ( ppc_md.kbd_setkeycode )
38		return ppc_md.kbd_setkeycode(scancode, keycode);
39	else
40		return 0;
41}
42
43static inline int kbd_getkeycode(unsigned int scancode)
44{
45	if ( ppc_md.kbd_getkeycode )
46		return ppc_md.kbd_getkeycode(scancode);
47	else
48		return 0;
49}
50
51static inline int kbd_translate(unsigned char keycode, unsigned char *keycodep,
52				char raw_mode)
53{
54	if ( ppc_md.kbd_translate )
55		return ppc_md.kbd_translate(keycode, keycodep, raw_mode);
56	else
57		return 0;
58}
59
60static inline int kbd_unexpected_up(unsigned char keycode)
61{
62	if ( ppc_md.kbd_unexpected_up )
63		return ppc_md.kbd_unexpected_up(keycode);
64	else
65		return 0;
66}
67
68static inline void kbd_leds(unsigned char leds)
69{
70	if ( ppc_md.kbd_leds )
71		ppc_md.kbd_leds(leds);
72}
73
74static inline void kbd_init_hw(void)
75{
76	if ( ppc_md.kbd_init_hw )
77		ppc_md.kbd_init_hw();
78}
79
80#define kbd_sysrq_xlate	(ppc_md.ppc_kbd_sysrq_xlate)
81
82extern unsigned long SYSRQ_KEY;
83#define E1_PAUSE	119		/* PAUSE key */
84
85/* resource allocation */
86#define kbd_request_region()
87#define kbd_request_irq(handler) request_irq(KEYBOARD_IRQ, handler, 0, \
88                                             "keyboard", NULL)
89
90/* How to access the keyboard macros on this platform.  */
91#define kbd_read_input() inb(KBD_DATA_REG)
92static inline int kbd_read_status(void) {
93	int ret = inb(0x64);
94	return (ret == 0xff) ? 0 : ret;	/* translate float to bad status. */
95}
96#define kbd_write_output(val) outb(val, KBD_DATA_REG)
97#define kbd_write_command(val) outb(val, KBD_CNTL_REG)
98
99/* Some stoneage hardware needs delays after some operations.  */
100#define kbd_pause() do { } while(0)
101
102/*
103 * Machine specific bits for the PS/2 driver
104 */
105
106#define AUX_IRQ 12
107
108#define aux_request_irq(hand, dev_id)					\
109	request_irq(AUX_IRQ, hand, SA_SHIRQ, "PS/2 Mouse", dev_id)
110
111#define aux_free_irq(dev_id) free_irq(AUX_IRQ, dev_id)
112
113#endif /* __KERNEL__ */
114
115#endif /* __ASMPPC64_KEYBOARD_H */
116