aboutsummaryrefslogtreecommitdiff
path: root/src/parisc/lasips2.c
blob: 119c21468ea9775a015097b5896baadcad844ab4 (plain)
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
/* LASI PS2 keyboard support code
 *
 * Copyright (C) 2019 Sven Schnelle <svens@stackframe.org>
 *
 * This file may be distributed under the terms of the GNU LGPLv2 license.
 */

#include "bregs.h"
#include "autoconf.h"
#include "types.h"
#include "output.h"
#include "hw/ps2port.h"
#include "util.h"
#include "string.h"
#include "lasips2.h"

int lasips2_kbd_in(char *c, int max)
{
    struct bregs regs;
    volatile int count = 0;

    while((readl(LASIPS2_KBD_STATUS) & LASIPS2_KBD_STATUS_RBNE)) {
        process_key(readb(LASIPS2_KBD_DATA));
    }

    while(count < max) {
        memset(&regs, 0, sizeof(regs));
        regs.ah = 0x10;
        handle_16(&regs);
        if (!regs.ah)
            break;
        *c++ = regs.ah;
        count++;
    }
    return count;
}


int ps2_kbd_command(int command, u8 *param)
{
    return 0;
}

int lasips2_command(u16 cmd)
{
    while(readl(LASIPS2_KBD_STATUS) & LASIPS2_KBD_STATUS_TBNE)
        udelay(10);
    writeb(LASIPS2_KBD_DATA, cmd & 0xff);

    while(!(readl(LASIPS2_KBD_STATUS) & LASIPS2_KBD_STATUS_RBNE))
        udelay(10);
    return readb(LASIPS2_KBD_DATA);
}

void ps2port_setup(void)
{
    writeb(LASIPS2_KBD_RESET, 0);
    udelay(1000);
    writeb(LASIPS2_KBD_CONTROL, LASIPS2_KBD_CONTROL_EN);
    lasips2_command(ATKBD_CMD_RESET_BAT);
    lasips2_command(ATKBD_CMD_RESET_DIS);
    lasips2_command(ATKBD_CMD_SSCANSET);
    lasips2_command(0x01);
    lasips2_command(ATKBD_CMD_ENABLE);
    kbd_init();
}