0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _SPARC_NS87303_H
0009 #define _SPARC_NS87303_H 1
0010
0011
0012
0013
0014 #define FER 0x00
0015 #define FAR 0x01
0016 #define PTR 0x02
0017 #define FCR 0x03
0018 #define PCR 0x04
0019 #define KRR 0x05
0020 #define PMC 0x06
0021 #define TUP 0x07
0022 #define SID 0x08
0023 #define ASC 0x09
0024 #define CS0CF0 0x0a
0025 #define CS0CF1 0x0b
0026 #define CS1CF0 0x0c
0027 #define CS1CF1 0x0d
0028
0029
0030 #define FER_EDM 0x10
0031
0032
0033 #define FAR_LPT_MASK 0x03
0034 #define FAR_LPTB 0x00
0035 #define FAR_LPTA 0x01
0036 #define FAR_LPTC 0x02
0037
0038
0039 #define PTR_LPTB_IRQ7 0x08
0040 #define PTR_LEVEL_IRQ 0x80
0041 #define PTR_LPT_REG_DIR 0x80
0042
0043
0044
0045 #define FCR_LDE 0x10
0046 #define FCR_ZWS_ENA 0x20
0047
0048
0049 #define PCR_EPP_ENABLE 0x01
0050 #define PCR_EPP_IEEE 0x02
0051 #define PCR_ECP_ENABLE 0x04
0052 #define PCR_ECP_CLK_ENA 0x08
0053 #define PCR_IRQ_POLAR 0x20
0054
0055 #define PCR_IRQ_ODRAIN 0x40
0056
0057
0058 #define TUP_EPP_TIMO 0x02
0059
0060
0061 #define ASC_LPT_IRQ7 0x01
0062 #define ASC_DRV2_SEL 0x02
0063
0064 #define FER_RESERVED 0x00
0065 #define FAR_RESERVED 0x00
0066 #define PTR_RESERVED 0x73
0067 #define FCR_RESERVED 0xc4
0068 #define PCR_RESERVED 0x10
0069 #define KRR_RESERVED 0x00
0070 #define PMC_RESERVED 0x98
0071 #define TUP_RESERVED 0xfb
0072 #define SIP_RESERVED 0x00
0073 #define ASC_RESERVED 0x18
0074 #define CS0CF0_RESERVED 0x00
0075 #define CS0CF1_RESERVED 0x08
0076 #define CS1CF0_RESERVED 0x00
0077 #define CS1CF1_RESERVED 0x08
0078
0079 #ifdef __KERNEL__
0080
0081 #include <linux/spinlock.h>
0082
0083 #include <asm/io.h>
0084
0085 extern spinlock_t ns87303_lock;
0086
0087 static inline int ns87303_modify(unsigned long port, unsigned int index,
0088 unsigned char clr, unsigned char set)
0089 {
0090 static unsigned char reserved[] = {
0091 FER_RESERVED, FAR_RESERVED, PTR_RESERVED, FCR_RESERVED,
0092 PCR_RESERVED, KRR_RESERVED, PMC_RESERVED, TUP_RESERVED,
0093 SIP_RESERVED, ASC_RESERVED, CS0CF0_RESERVED, CS0CF1_RESERVED,
0094 CS1CF0_RESERVED, CS1CF1_RESERVED
0095 };
0096 unsigned long flags;
0097 unsigned char value;
0098
0099 if (index > 0x0d)
0100 return -EINVAL;
0101
0102 spin_lock_irqsave(&ns87303_lock, flags);
0103
0104 outb(index, port);
0105 value = inb(port + 1);
0106 value &= ~(reserved[index] | clr);
0107 value |= set;
0108 outb(value, port + 1);
0109 outb(value, port + 1);
0110
0111 spin_unlock_irqrestore(&ns87303_lock, flags);
0112
0113 return 0;
0114 }
0115
0116 #endif
0117
0118 #endif