source: mainline/uspace/srv/hid/input/port/pl050.c@ 1402402

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 1402402 was a996ae31, checked in by Jakub Jermar <jakub@…>, 14 years ago

Userspace IRQ pseudocode is expected to use physical addresses from now.
The kernel creates kernel mappings for those and adjusts the pseudocode
accordingly.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2009 Vineeth Pillai
3 * Copyright (c) 2011 Jiri Svoboda
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup kbd_port
31 * @ingroup kbd
32 * @{
33 */
34/** @file
35 * @brief pl050 port driver.
36 */
37
38#include <ddi.h>
39#include <libarch/ddi.h>
40#include <async.h>
41#include <unistd.h>
42#include <sysinfo.h>
43#include <kbd_port.h>
44#include <kbd.h>
45#include <ddi.h>
46#include <stdio.h>
47#include <errno.h>
48
49static int pl050_port_init(kbd_dev_t *);
50static void pl050_port_yield(void);
51static void pl050_port_reclaim(void);
52static void pl050_port_write(uint8_t data);
53
54kbd_port_ops_t pl050_port = {
55 .init = pl050_port_init,
56 .yield = pl050_port_yield,
57 .reclaim = pl050_port_reclaim,
58 .write = pl050_port_write
59};
60
61static kbd_dev_t *kbd_dev;
62
63#define PL050_STAT_RXFULL (1 << 4)
64
65static irq_cmd_t pl050_cmds[] = {
66 {
67 .cmd = CMD_PIO_READ_8,
68 .addr = NULL,
69 .dstarg = 1
70 },
71 {
72 .cmd = CMD_BTEST,
73 .value = PL050_STAT_RXFULL,
74 .srcarg = 1,
75 .dstarg = 3
76 },
77 {
78 .cmd = CMD_PREDICATE,
79 .value = 2,
80 .srcarg = 3
81 },
82 {
83 .cmd = CMD_PIO_READ_8,
84 .addr = NULL, /* Will be patched in run-time */
85 .dstarg = 2
86 },
87 {
88 .cmd = CMD_ACCEPT
89 }
90};
91
92static irq_code_t pl050_kbd = {
93 0, // FIXME
94 NULL, // FIXME
95 sizeof(pl050_cmds) / sizeof(irq_cmd_t),
96 pl050_cmds
97};
98
99static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call);
100
101static int pl050_port_init(kbd_dev_t *kdev)
102{
103 kbd_dev = kdev;
104
105 sysarg_t addr;
106 if (sysinfo_get_value("kbd.address.status", &addr) != EOK)
107 return -1;
108
109 pl050_kbd.cmds[0].addr = (void *) addr;
110
111 if (sysinfo_get_value("kbd.address.data", &addr) != EOK)
112 return -1;
113
114 pl050_kbd.cmds[3].addr = (void *) addr;
115
116 sysarg_t inr;
117 if (sysinfo_get_value("kbd.inr", &inr) != EOK)
118 return -1;
119
120 async_set_interrupt_received(pl050_irq_handler);
121 irq_register(inr, device_assign_devno(), 0, &pl050_kbd);
122
123 return 0;
124}
125
126static void pl050_port_yield(void)
127{
128}
129
130static void pl050_port_reclaim(void)
131{
132}
133
134static void pl050_port_write(uint8_t data)
135{
136 (void) data;
137}
138
139static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call)
140{
141 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
142}
143
144/**
145 * @}
146 */
Note: See TracBrowser for help on using the repository browser.