Subversion Repositories shark

Rev

Rev 494 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1063 tullio 1
 
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 *
17
 */
18
 
494 giacomo 19
#ifndef _I8042_SPARCIO_H
20
#define _I8042_SPARCIO_H
21
 
22
#include <linux/config.h>
23
#include <asm/io.h>
24
 
25
#ifdef CONFIG_PCI
26
#include <asm/oplib.h>
27
#include <asm/ebus.h>
28
#endif
29
 
30
static int i8042_kbd_irq = -1;
31
static int i8042_aux_irq = -1;
32
#define I8042_KBD_IRQ i8042_kbd_irq
33
#define I8042_AUX_IRQ i8042_aux_irq
34
 
35
#define I8042_KBD_PHYS_DESC "sparcps2/serio0"
36
#define I8042_AUX_PHYS_DESC "sparcps2/serio1"
37
#define I8042_MUX_PHYS_DESC "sparcps2/serio%d"
38
 
39
static unsigned long kbd_iobase;
40
 
41
#define I8042_COMMAND_REG       (kbd_iobase + 0x64UL)
42
#define I8042_DATA_REG          (kbd_iobase + 0x60UL)
43
 
44
static inline int i8042_read_data(void)
45
{
46
        return readb(kbd_iobase + 0x60UL);
47
}
48
 
49
static inline int i8042_read_status(void)
50
{
51
        return readb(kbd_iobase + 0x64UL);
52
}
53
 
54
static inline void i8042_write_data(int val)
55
{
56
        writeb(val, kbd_iobase + 0x60UL);
57
}
58
 
59
static inline void i8042_write_command(int val)
60
{
61
        writeb(val, kbd_iobase + 0x64UL);
62
}
63
 
64
#define OBP_PS2KBD_NAME1        "kb_ps2"
65
#define OBP_PS2KBD_NAME2        "keyboard"
66
#define OBP_PS2MS_NAME1         "kdmouse"
67
#define OBP_PS2MS_NAME2         "mouse"
68
 
69
static int i8042_platform_init(void)
70
{
71
#ifndef CONFIG_PCI
72
        return -1;
73
#else
74
        char prop[128];
75
        int len;
76
 
77
        len = prom_getproperty(prom_root_node, "name", prop, sizeof(prop));
78
        if (len < 0) {
79
                printk("i8042: Cannot get name property of root OBP node.\n");
80
                return -1;
81
        }
82
        if (strncmp(prop, "SUNW,JavaStation-1", len) == 0) {
83
                /* Hardcoded values for MrCoffee.  */
84
                i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
85
                kbd_iobase = (unsigned long) ioremap(0x71300060, 8);
86
                if (!kbd_iobase)
87
                        return -1;
88
        } else {
89
                struct linux_ebus *ebus;
90
                struct linux_ebus_device *edev;
91
                struct linux_ebus_child *child;
92
 
93
                for_each_ebus(ebus) {
94
                        for_each_ebusdev(edev, ebus) {
95
                                if (!strcmp(edev->prom_name, "8042"))
96
                                        goto edev_found;
97
                        }
98
                }
99
                return -1;
100
 
101
        edev_found:
102
                for_each_edevchild(edev, child) {
103
                        if (!strcmp(child->prom_name, OBP_PS2KBD_NAME1) ||
104
                            !strcmp(child->prom_name, OBP_PS2KBD_NAME2)) {
105
                                i8042_kbd_irq = child->irqs[0];
106
                                kbd_iobase = (unsigned long)
107
                                        ioremap(child->resource[0].start, 8);
108
                        }
109
                        if (!strcmp(child->prom_name, OBP_PS2MS_NAME1) ||
110
                            !strcmp(child->prom_name, OBP_PS2MS_NAME2))
111
                                i8042_aux_irq = child->irqs[0];
112
                }
113
                if (i8042_kbd_irq == -1 ||
114
                    i8042_aux_irq == -1) {
115
                        printk("i8042: Error, 8042 device lacks both kbd and "
116
                               "mouse nodes.\n");
117
                        return -1;
118
                }
119
        }
120
 
121
        i8042_reset = 1;
122
 
123
        return 0;
124
#endif /* CONFIG_PCI */
125
}
126
 
127
static inline void i8042_platform_exit(void)
128
{
129
#ifdef CONFIG_PCI
130
        iounmap((void *)kbd_iobase);
131
#endif
132
}
133
 
134
#endif /* _I8042_SPARCIO_H */