1
2
3
4
5
6
7#ifndef _SPARC_NS87303_H
8#define _SPARC_NS87303_H 1
9
10
11
12
13#define FER 0x00
14#define FAR 0x01
15#define PTR 0x02
16#define FCR 0x03
17#define PCR 0x04
18#define KRR 0x05
19#define PMC 0x06
20#define TUP 0x07
21#define SID 0x08
22#define ASC 0x09
23#define CS0CF0 0x0a
24#define CS0CF1 0x0b
25#define CS1CF0 0x0c
26#define CS1CF1 0x0d
27
28
29#define FER_EDM 0x10
30
31
32#define FAR_LPT_MASK 0x03
33#define FAR_LPTB 0x00
34#define FAR_LPTA 0x01
35#define FAR_LPTC 0x02
36
37
38#define PTR_LPTB_IRQ7 0x08
39#define PTR_LEVEL_IRQ 0x80
40#define PTR_LPT_REG_DIR 0x80
41
42
43
44#define FCR_LDE 0x10
45#define FCR_ZWS_ENA 0x20
46
47
48#define PCR_EPP_ENABLE 0x01
49#define PCR_EPP_IEEE 0x02
50#define PCR_ECP_ENABLE 0x04
51#define PCR_ECP_CLK_ENA 0x08
52#define PCR_IRQ_POLAR 0x20
53
54#define PCR_IRQ_ODRAIN 0x40
55
56
57#define TUP_EPP_TIMO 0x02
58
59
60#define ASC_LPT_IRQ7 0x01
61#define ASC_DRV2_SEL 0x02
62
63#define FER_RESERVED 0x00
64#define FAR_RESERVED 0x00
65#define PTR_RESERVED 0x73
66#define FCR_RESERVED 0xc4
67#define PCR_RESERVED 0x10
68#define KRR_RESERVED 0x00
69#define PMC_RESERVED 0x98
70#define TUP_RESERVED 0xfb
71#define SIP_RESERVED 0x00
72#define ASC_RESERVED 0x18
73#define CS0CF0_RESERVED 0x00
74#define CS0CF1_RESERVED 0x08
75#define CS1CF0_RESERVED 0x00
76#define CS1CF1_RESERVED 0x08
77
78#ifdef __KERNEL__
79
80#include <linux/spinlock.h>
81
82#include <asm/io.h>
83
84extern spinlock_t ns87303_lock;
85
86static inline int ns87303_modify(unsigned long port, unsigned int index,
87 unsigned char clr, unsigned char set)
88{
89 static unsigned char reserved[] = {
90 FER_RESERVED, FAR_RESERVED, PTR_RESERVED, FCR_RESERVED,
91 PCR_RESERVED, KRR_RESERVED, PMC_RESERVED, TUP_RESERVED,
92 SIP_RESERVED, ASC_RESERVED, CS0CF0_RESERVED, CS0CF1_RESERVED,
93 CS1CF0_RESERVED, CS1CF1_RESERVED
94 };
95 unsigned long flags;
96 unsigned char value;
97
98 if (index > 0x0d)
99 return -EINVAL;
100
101 spin_lock_irqsave(&ns87303_lock, flags);
102
103 outb(index, port);
104 value = inb(port + 1);
105 value &= ~(reserved[index] | clr);
106 value |= set;
107 outb(value, port + 1);
108 outb(value, port + 1);
109
110 spin_unlock_irqrestore(&ns87303_lock, flags);
111
112 return 0;
113}
114
115#endif
116
117#endif
118