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
RevLine 
[6b781c0]1/*
[6ac14a70]2 * Copyright (c) 2009 Vineeth Pillai
[9be360ee]3 * Copyright (c) 2011 Jiri Svoboda
[6b781c0]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
[6ac14a70]30/** @addtogroup kbd_port
31 * @ingroup kbd
[6b781c0]32 * @{
33 */
[6ac14a70]34/** @file
35 * @brief pl050 port driver.
36 */
[6b781c0]37
[6ac14a70]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>
[3bdf3d3]47#include <errno.h>
48
[9be360ee]49static int pl050_port_init(kbd_dev_t *);
[b1bdc7a4]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
[9be360ee]61static kbd_dev_t *kbd_dev;
62
[3bdf3d3]63#define PL050_STAT_RXFULL (1 << 4)
[6b781c0]64
[6ac14a70]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,
[3bdf3d3]84 .addr = NULL, /* Will be patched in run-time */
[6ac14a70]85 .dstarg = 2
86 },
87 {
88 .cmd = CMD_ACCEPT
89 }
90};
[6b781c0]91
[6ac14a70]92static irq_code_t pl050_kbd = {
[a996ae31]93 0, // FIXME
94 NULL, // FIXME
[6ac14a70]95 sizeof(pl050_cmds) / sizeof(irq_cmd_t),
96 pl050_cmds
97};
[6b781c0]98
[6ac14a70]99static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call);
[6b781c0]100
[9be360ee]101static int pl050_port_init(kbd_dev_t *kdev)
[6b781c0]102{
[9be360ee]103 kbd_dev = kdev;
104
[3bdf3d3]105 sysarg_t addr;
106 if (sysinfo_get_value("kbd.address.status", &addr) != EOK)
[d9fae235]107 return -1;
108
[3bdf3d3]109 pl050_kbd.cmds[0].addr = (void *) addr;
110
111 if (sysinfo_get_value("kbd.address.data", &addr) != EOK)
[d9fae235]112 return -1;
113
[3bdf3d3]114 pl050_kbd.cmds[3].addr = (void *) addr;
115
[d9fae235]116 sysarg_t inr;
117 if (sysinfo_get_value("kbd.inr", &inr) != EOK)
118 return -1;
119
[6ac14a70]120 async_set_interrupt_received(pl050_irq_handler);
[f044e96]121 irq_register(inr, device_assign_devno(), 0, &pl050_kbd);
[d9fae235]122
[6ac14a70]123 return 0;
[6b781c0]124}
125
[b1bdc7a4]126static void pl050_port_yield(void)
[6ac14a70]127{
128}
[6b781c0]129
[b1bdc7a4]130static void pl050_port_reclaim(void)
[6b781c0]131{
132}
133
[b1bdc7a4]134static void pl050_port_write(uint8_t data)
[c145bc2]135{
136 (void) data;
137}
138
[6ac14a70]139static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call)
140{
[1875a0c]141 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
[6ac14a70]142}
143
144/**
145 * @}
[1875a0c]146 */
Note: See TracBrowser for help on using the repository browser.