Subversion Repositories HelenOS

Rev

Rev 2071 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2071 Rev 2089
1
/*
1
/*
2
 * Copyright (c) 2006 Jakub Jermar
2
 * Copyright (c) 2006 Jakub Jermar
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup sparc64
29
/** @addtogroup sparc64
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#ifndef KERN_sparc64_Z8530_H_
35
#ifndef KERN_sparc64_Z8530_H_
36
#define KERN_sparc64_Z8530_H_
36
#define KERN_sparc64_Z8530_H_
37
 
37
 
38
#include <arch/types.h>
38
#include <arch/types.h>
39
#include <typedefs.h>
-
 
40
#include <arch/drivers/kbd.h>
39
#include <arch/drivers/kbd.h>
41
 
40
 
42
#define Z8530_CHAN_A    4
41
#define Z8530_CHAN_A    4
43
#define Z8530_CHAN_B    0
42
#define Z8530_CHAN_B    0
44
 
43
 
45
#define WR0 0
44
#define WR0 0
46
#define WR1 1
45
#define WR1 1
47
#define WR2 2
46
#define WR2 2
48
#define WR3 3
47
#define WR3 3
49
#define WR4 4
48
#define WR4 4
50
#define WR5 5
49
#define WR5 5
51
#define WR6 6
50
#define WR6 6
52
#define WR7 7
51
#define WR7 7
53
#define WR8 8
52
#define WR8 8
54
#define WR9 9
53
#define WR9 9
55
#define WR10    10
54
#define WR10    10
56
#define WR11    11
55
#define WR11    11
57
#define WR12    12
56
#define WR12    12
58
#define WR13    13
57
#define WR13    13
59
#define WR14    14
58
#define WR14    14
60
#define WR15    15
59
#define WR15    15
61
 
60
 
62
#define RR0 0
61
#define RR0 0
63
#define RR1 1
62
#define RR1 1
64
#define RR2 2
63
#define RR2 2
65
#define RR3 3
64
#define RR3 3
66
#define RR8 8
65
#define RR8 8
67
#define RR10    10
66
#define RR10    10
68
#define RR12    12
67
#define RR12    12
69
#define RR13    13
68
#define RR13    13
70
#define RR14    14
69
#define RR14    14
71
#define RR15    15
70
#define RR15    15
72
 
71
 
73
/* Write Register 0 */
72
/* Write Register 0 */
74
#define WR0_TX_IP_RST   (0x5<<3)    /** Reset pending TX interrupt. */
73
#define WR0_TX_IP_RST   (0x5<<3)    /** Reset pending TX interrupt. */
75
#define WR0_ERR_RST (0x6<<3)
74
#define WR0_ERR_RST (0x6<<3)
76
 
75
 
77
/* Write Register 1 */
76
/* Write Register 1 */
78
#define WR1_RID     (0x0<<3)    /** Receive Interrupts Disabled. */
77
#define WR1_RID     (0x0<<3)    /** Receive Interrupts Disabled. */
79
#define WR1_RIFCSC  (0x1<<3)    /** Receive Interrupt on First Character or Special Condition. */
78
#define WR1_RIFCSC  (0x1<<3)    /** Receive Interrupt on First Character or Special Condition. */
80
#define WR1_IARCSC  (0x2<<3)    /** Interrupt on All Receive Characters or Special Conditions. */
79
#define WR1_IARCSC  (0x2<<3)    /** Interrupt on All Receive Characters or Special Conditions. */
81
#define WR1_RISC    (0x3<<3)    /** Receive Interrupt on Special Condition. */
80
#define WR1_RISC    (0x3<<3)    /** Receive Interrupt on Special Condition. */
82
#define WR1_PISC    (0x1<<2)    /** Parity Is Special Condition. */
81
#define WR1_PISC    (0x1<<2)    /** Parity Is Special Condition. */
83
 
82
 
84
/* Write Register 3 */
83
/* Write Register 3 */
85
#define WR3_RX_ENABLE   (0x1<<0)    /** Rx Enable. */
84
#define WR3_RX_ENABLE   (0x1<<0)    /** Rx Enable. */
86
#define WR3_RX8BITSCH   (0x3<<6)    /** 8-bits per character. */
85
#define WR3_RX8BITSCH   (0x3<<6)    /** 8-bits per character. */
87
 
86
 
88
/* Write Register 9 */
87
/* Write Register 9 */
89
#define WR9_MIE     (0x1<<3)    /** Master Interrupt Enable. */
88
#define WR9_MIE     (0x1<<3)    /** Master Interrupt Enable. */
90
 
89
 
91
/* Read Register 0 */
90
/* Read Register 0 */
92
#define RR0_RCA     (0x1<<0)    /** Receive Character Available. */
91
#define RR0_RCA     (0x1<<0)    /** Receive Character Available. */
93
 
92
 
94
/** Structure representing the z8530 device. */
93
/** Structure representing the z8530 device. */
95
typedef struct {
94
typedef struct {
96
    devno_t devno;
95
    devno_t devno;
97
    volatile uint8_t *reg;      /** Memory mapped registers of the z8530. */
96
    volatile uint8_t *reg;      /** Memory mapped registers of the z8530. */
98
} z8530_t;
97
} z8530_t;
99
 
98
 
100
static inline void z8530_write(z8530_t *dev, index_t chan, uint8_t reg, uint8_t val)
99
static inline void z8530_write(z8530_t *dev, index_t chan, uint8_t reg, uint8_t val)
101
{
100
{
102
    /*
101
    /*
103
     * Registers 8-15 will automatically issue the Point High
102
     * Registers 8-15 will automatically issue the Point High
104
     * command as their bit 3 is 1.
103
     * command as their bit 3 is 1.
105
     */
104
     */
106
    dev->reg[WR0+chan] = reg;   /* select register */
105
    dev->reg[WR0+chan] = reg;   /* select register */
107
    dev->reg[WR0+chan] = val;   /* write value */
106
    dev->reg[WR0+chan] = val;   /* write value */
108
}
107
}
109
 
108
 
110
static inline void z8530_write_a(z8530_t *dev, uint8_t reg, uint8_t val)
109
static inline void z8530_write_a(z8530_t *dev, uint8_t reg, uint8_t val)
111
{
110
{
112
    z8530_write(dev, Z8530_CHAN_A, reg, val);
111
    z8530_write(dev, Z8530_CHAN_A, reg, val);
113
}
112
}
114
static inline void z8530_write_b(z8530_t *dev, uint8_t reg, uint8_t val)
113
static inline void z8530_write_b(z8530_t *dev, uint8_t reg, uint8_t val)
115
{
114
{
116
    z8530_write(dev, Z8530_CHAN_B, reg, val);
115
    z8530_write(dev, Z8530_CHAN_B, reg, val);
117
}
116
}
118
 
117
 
119
static inline uint8_t z8530_read(z8530_t *dev, index_t chan, uint8_t reg)
118
static inline uint8_t z8530_read(z8530_t *dev, index_t chan, uint8_t reg)
120
{
119
{
121
    /*
120
    /*
122
     * Registers 8-15 will automatically issue the Point High
121
     * Registers 8-15 will automatically issue the Point High
123
     * command as their bit 3 is 1.
122
     * command as their bit 3 is 1.
124
     */
123
     */
125
    dev->reg[WR0+chan] = reg;   /* select register */
124
    dev->reg[WR0+chan] = reg;   /* select register */
126
    return dev->reg[WR0+chan];
125
    return dev->reg[WR0+chan];
127
}
126
}
128
 
127
 
129
static inline uint8_t z8530_read_a(z8530_t *dev, uint8_t reg)
128
static inline uint8_t z8530_read_a(z8530_t *dev, uint8_t reg)
130
{
129
{
131
    return z8530_read(dev, Z8530_CHAN_A, reg);
130
    return z8530_read(dev, Z8530_CHAN_A, reg);
132
}
131
}
133
static inline uint8_t z8530_read_b(z8530_t *dev, uint8_t reg)
132
static inline uint8_t z8530_read_b(z8530_t *dev, uint8_t reg)
134
{
133
{
135
    return z8530_read(dev, Z8530_CHAN_B, reg);
134
    return z8530_read(dev, Z8530_CHAN_B, reg);
136
}
135
}
137
 
136
 
138
#endif
137
#endif
139
 
138
 
140
/** @}
139
/** @}
141
 */
140
 */
142
 
141