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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 25eec4ef was 1ae74c6, checked in by Jan Vesely <jano.vesely@…>, 13 years ago

Fix ddi.h header includes.

  • Property mode set to 100644
File size: 3.5 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 <async.h>
40#include <unistd.h>
41#include <sysinfo.h>
42#include <stdio.h>
43#include <errno.h>
44#include "../kbd_port.h"
45#include "../kbd.h"
46
47static int pl050_port_init(kbd_dev_t *);
48static void pl050_port_yield(void);
49static void pl050_port_reclaim(void);
50static void pl050_port_write(uint8_t data);
51
52kbd_port_ops_t pl050_port = {
53 .init = pl050_port_init,
54 .yield = pl050_port_yield,
55 .reclaim = pl050_port_reclaim,
56 .write = pl050_port_write
57};
58
59static kbd_dev_t *kbd_dev;
60
61#define PL050_STAT 4
62#define PL050_DATA 8
63
64#define PL050_STAT_RXFULL (1 << 4)
65
66static irq_pio_range_t pl050_ranges[] = {
67 {
68 .base = 0,
69 .size = 9,
70 }
71};
72
73static irq_cmd_t pl050_cmds[] = {
74 {
75 .cmd = CMD_PIO_READ_8,
76 .addr = NULL,
77 .dstarg = 1
78 },
79 {
80 .cmd = CMD_AND,
81 .value = PL050_STAT_RXFULL,
82 .srcarg = 1,
83 .dstarg = 3
84 },
85 {
86 .cmd = CMD_PREDICATE,
87 .value = 2,
88 .srcarg = 3
89 },
90 {
91 .cmd = CMD_PIO_READ_8,
92 .addr = NULL, /* Will be patched in run-time */
93 .dstarg = 2
94 },
95 {
96 .cmd = CMD_ACCEPT
97 }
98};
99
100static irq_code_t pl050_kbd = {
101 sizeof(pl050_ranges) / sizeof(irq_pio_range_t),
102 pl050_ranges,
103 sizeof(pl050_cmds) / sizeof(irq_cmd_t),
104 pl050_cmds
105};
106
107static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call);
108
109static int pl050_port_init(kbd_dev_t *kdev)
110{
111 kbd_dev = kdev;
112
113 sysarg_t addr;
114 if (sysinfo_get_value("kbd.address.physical", &addr) != EOK)
115 return -1;
116
117 pl050_kbd.ranges[0].base = addr;
118 pl050_kbd.cmds[0].addr = (void *) addr + PL050_STAT;
119 pl050_kbd.cmds[3].addr = (void *) addr + PL050_DATA;
120
121 sysarg_t inr;
122 if (sysinfo_get_value("kbd.inr", &inr) != EOK)
123 return -1;
124
125 async_set_interrupt_received(pl050_irq_handler);
126 irq_register(inr, device_assign_devno(), 0, &pl050_kbd);
127
128 return 0;
129}
130
131static void pl050_port_yield(void)
132{
133}
134
135static void pl050_port_reclaim(void)
136{
137}
138
139static void pl050_port_write(uint8_t data)
140{
141 (void) data;
142}
143
144static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call)
145{
146 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
147}
148
149/**
150 * @}
151 */
Note: See TracBrowser for help on using the repository browser.