2 * SMC 37C93X initialization code
5 #include <linux/config.h>
6 #include <linux/kernel.h>
8 #include <linux/slab.h>
10 #include <linux/init.h>
11 #include <linux/delay.h>
13 #include <asm/hwrpb.h>
15 #include <asm/segment.h>
20 # define DBG_DEVS(args) printk args
22 # define DBG_DEVS(args)
29 /* device "activate" register contents */
33 /* configuration on/off keys */
34 #define CONFIG_ON_KEY 0x55
35 #define CONFIG_OFF_KEY 0xaa
37 /* configuration space device definitions */
48 /* Chip register offsets from base */
49 #define CONFIG_CONTROL 0x02
50 #define INDEX_ADDRESS 0x03
51 #define LOGICAL_DEVICE_NUMBER 0x07
52 #define DEVICE_ID 0x20
53 #define DEVICE_REV 0x21
54 #define POWER_CONTROL 0x22
55 #define POWER_MGMT 0x23
61 #define INTERRUPT_SEL 0x70
62 #define INTERRUPT_SEL_2 0x72 /* KYBD/MOUS only */
63 #define DMA_CHANNEL_SEL 0x74 /* FDC/PARP only */
65 #define FDD_MODE_REGISTER 0x90
66 #define FDD_OPTION_REGISTER 0x91
68 /* values that we read back that are expected ... */
69 #define VALID_DEVICE_ID 2
71 /* default device addresses */
72 #define KYBD_INTERRUPT 1
73 #define MOUS_INTERRUPT 12
74 #define COM2_BASE 0x2f8
75 #define COM2_INTERRUPT 3
76 #define COM1_BASE 0x3f8
77 #define COM1_INTERRUPT 4
78 #define PARP_BASE 0x3bc
79 #define PARP_INTERRUPT 7
81 static unsigned long __init
SMCConfigState(unsigned long baseAddr
)
86 unsigned long configPort
;
87 unsigned long indexPort
;
88 unsigned long dataPort
;
92 configPort
= indexPort
= baseAddr
;
93 dataPort
= configPort
+ 1;
97 for (i
= 0; i
< NUM_RETRIES
; i
++)
99 outb(CONFIG_ON_KEY
, configPort
);
100 outb(CONFIG_ON_KEY
, configPort
);
101 outb(DEVICE_ID
, indexPort
);
102 devId
= inb(dataPort
);
103 if (devId
== VALID_DEVICE_ID
) {
104 outb(DEVICE_REV
, indexPort
);
105 devRev
= inb(dataPort
);
111 return (i
!= NUM_RETRIES
) ? baseAddr
: 0L;
114 static void __init
SMCRunState(unsigned long baseAddr
)
116 outb(CONFIG_OFF_KEY
, baseAddr
);
119 static unsigned long __init
SMCDetectUltraIO(void)
121 unsigned long baseAddr
;
124 if ( ( baseAddr
= SMCConfigState( baseAddr
) ) == 0x3F0 ) {
128 if ( ( baseAddr
= SMCConfigState( baseAddr
) ) == 0x370 ) {
131 return( ( unsigned long )0 );
134 static void __init
SMCEnableDevice(unsigned long baseAddr
,
135 unsigned long device
,
136 unsigned long portaddr
,
137 unsigned long interrupt
)
139 unsigned long indexPort
;
140 unsigned long dataPort
;
142 indexPort
= baseAddr
;
143 dataPort
= baseAddr
+ 1;
145 outb(LOGICAL_DEVICE_NUMBER
, indexPort
);
146 outb(device
, dataPort
);
148 outb(ADDR_LO
, indexPort
);
149 outb(( portaddr
& 0xFF ), dataPort
);
151 outb(ADDR_HI
, indexPort
);
152 outb((portaddr
>> 8) & 0xFF, dataPort
);
154 outb(INTERRUPT_SEL
, indexPort
);
155 outb(interrupt
, dataPort
);
157 outb(ACTIVATE
, indexPort
);
158 outb(DEVICE_ON
, dataPort
);
161 static void __init
SMCEnableKYBD(unsigned long baseAddr
)
163 unsigned long indexPort
;
164 unsigned long dataPort
;
166 indexPort
= baseAddr
;
167 dataPort
= baseAddr
+ 1;
169 outb(LOGICAL_DEVICE_NUMBER
, indexPort
);
170 outb(KYBD
, dataPort
);
172 outb(INTERRUPT_SEL
, indexPort
); /* Primary interrupt select */
173 outb(KYBD_INTERRUPT
, dataPort
);
175 outb(INTERRUPT_SEL_2
, indexPort
); /* Secondary interrupt select */
176 outb(MOUS_INTERRUPT
, dataPort
);
178 outb(ACTIVATE
, indexPort
);
179 outb(DEVICE_ON
, dataPort
);
182 static void __init
SMCEnableFDC(unsigned long baseAddr
)
184 unsigned long indexPort
;
185 unsigned long dataPort
;
187 unsigned char oldValue
;
189 indexPort
= baseAddr
;
190 dataPort
= baseAddr
+ 1;
192 outb(LOGICAL_DEVICE_NUMBER
, indexPort
);
195 outb(FDD_MODE_REGISTER
, indexPort
);
196 oldValue
= inb(dataPort
);
198 oldValue
|= 0x0E; /* Enable burst mode */
199 outb(oldValue
, dataPort
);
201 outb(INTERRUPT_SEL
, indexPort
); /* Primary interrupt select */
202 outb(0x06, dataPort
);
204 outb(DMA_CHANNEL_SEL
, indexPort
); /* DMA channel select */
205 outb(0x02, dataPort
);
207 outb(ACTIVATE
, indexPort
);
208 outb(DEVICE_ON
, dataPort
);
212 static void __init
SMCReportDeviceStatus(unsigned long baseAddr
)
214 unsigned long indexPort
;
215 unsigned long dataPort
;
216 unsigned char currentControl
;
218 indexPort
= baseAddr
;
219 dataPort
= baseAddr
+ 1;
221 outb(POWER_CONTROL
, indexPort
);
222 currentControl
= inb(dataPort
);
224 printk(currentControl
& (1 << FDC
)
225 ? "\t+FDC Enabled\n" : "\t-FDC Disabled\n");
226 printk(currentControl
& (1 << IDE1
)
227 ? "\t+IDE1 Enabled\n" : "\t-IDE1 Disabled\n");
228 printk(currentControl
& (1 << IDE2
)
229 ? "\t+IDE2 Enabled\n" : "\t-IDE2 Disabled\n");
230 printk(currentControl
& (1 << PARP
)
231 ? "\t+PARP Enabled\n" : "\t-PARP Disabled\n");
232 printk(currentControl
& (1 << SER1
)
233 ? "\t+SER1 Enabled\n" : "\t-SER1 Disabled\n");
234 printk(currentControl
& (1 << SER2
)
235 ? "\t+SER2 Enabled\n" : "\t-SER2 Disabled\n");
241 int __init
SMC93x_Init(void)
243 unsigned long SMCUltraBase
;
246 local_irq_save(flags
);
247 if ((SMCUltraBase
= SMCDetectUltraIO()) != 0UL) {
249 SMCReportDeviceStatus(SMCUltraBase
);
251 SMCEnableDevice(SMCUltraBase
, SER1
, COM1_BASE
, COM1_INTERRUPT
);
252 DBG_DEVS(("SMC FDC37C93X: SER1 done\n"));
253 SMCEnableDevice(SMCUltraBase
, SER2
, COM2_BASE
, COM2_INTERRUPT
);
254 DBG_DEVS(("SMC FDC37C93X: SER2 done\n"));
255 SMCEnableDevice(SMCUltraBase
, PARP
, PARP_BASE
, PARP_INTERRUPT
);
256 DBG_DEVS(("SMC FDC37C93X: PARP done\n"));
257 /* On PC164, IDE on the SMC is not enabled;
258 CMD646 (PCI) on MB */
259 SMCEnableKYBD(SMCUltraBase
);
260 DBG_DEVS(("SMC FDC37C93X: KYB done\n"));
261 SMCEnableFDC(SMCUltraBase
);
262 DBG_DEVS(("SMC FDC37C93X: FDC done\n"));
264 SMCReportDeviceStatus(SMCUltraBase
);
266 SMCRunState(SMCUltraBase
);
267 local_irq_restore(flags
);
268 printk("SMC FDC37C93X Ultra I/O Controller found @ 0x%lx\n",
273 local_irq_restore(flags
);
274 DBG_DEVS(("No SMC FDC37C93X Ultra I/O Controller found\n"));