hc
2024-03-26 e0728245c89800c2038c23308f2d88969d5b41c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef __KEYBOARD_H
#define __KEYBOARD_H
 
#ifdef CONFIG_DM_KEYBOARD
#include <input.h>
#include <stdio_dev.h>
 
/**
 * struct keyboard_priv - information about a keyboard, for the uclass
 *
 * @sdev:    stdio device
 * @input:    input configuration (the driver may use this if desired)
 */
struct keyboard_priv {
   struct stdio_dev sdev;
 
   /*
    * This is set up by the uclass but will only be used if the driver
    * sets input.dev to its device pointer (it is initially NULL).
    */
   struct input_config input;
};
 
/**
 * struct keyboard_ops - keyboard device operations
 */
struct keyboard_ops {
   /**
    * start() - enable the keyboard ready for use
    *
    * @dev:    Device to enable
    * @return 0 if OK, -ve on error
    */
   int (*start)(struct udevice *dev);
 
   /**
    * stop() - disable the keyboard when no-longer needed
    *
    * @dev:    Device to disable
    * @return 0 if OK, -ve on error
    */
   int (*stop)(struct udevice *dev);
 
   /**
    * tstc() - check if a key is available
    *
    * @dev:    Device to check
    * @return 0 if no key is available, 1 if a key is available, -ve on
    *       error
    */
   int (*tstc)(struct udevice *dev);
 
   /**
    * getc() - get a key
    *
    * TODO(sjg@chromium.org): At present this method may wait if it calls
    * input_getc().
    *
    * @dev:    Device to read from
    * @return -EAGAIN if no key is available, otherwise key value read
    *       (as ASCII).
    */
   int (*getc)(struct udevice *dev);
 
   /**
    * update_leds() - update keyboard LEDs
    *
    * This is called when the LEDs have changed and need to be updated.
    * For example, if 'caps lock' is pressed then this method will be
    * called with the new LED value.
    *
    * @dev:    Device to update
    * @leds:    New LED mask (see INPUT_LED_... in input.h)
    */
   int (*update_leds)(struct udevice *dev, int leds);
};
 
#define keyboard_get_ops(dev)    ((struct keyboard_ops *)(dev)->driver->ops)
 
#else
 
#ifdef CONFIG_PS2MULT
#include <ps2mult.h>
#endif
 
#if !defined(kbd_request_region) || \
    !defined(kbd_request_irq) || \
    !defined(kbd_read_input) || \
    !defined(kbd_read_status) || \
    !defined(kbd_write_output) || \
    !defined(kbd_write_command)
#error PS/2 low level routines not defined
#endif
 
extern int kbd_init (void);
extern void handle_scancode(unsigned char scancode);
extern int kbd_init_hw(void);
extern void pckbd_leds(unsigned char leds);
#endif /* !CONFIG_DM_KEYBOARD */
 
#if defined(CONFIG_ARCH_MPC8540) || \
       defined(CONFIG_ARCH_MPC8541) || defined(CONFIG_ARCH_MPC8555)
int ps2ser_check(void);
#endif
 
#ifdef CONFIG_USB_KEYBOARD
/**
 * Check if usb keyboard receive F1~F12.
 *
 * @key_fn: KEY_F1, KEY_F2, KEY_F3, .... KEY_F12. (defined in input.h)
 *
 * return 1 if received, otherwise 0.
 */
extern int usb_kbd_recv_fn(int key_fn);
#endif
 
#endif /* __KEYBOARD_H */