Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

smc37c669.c

Go to the documentation of this file.
00001 /*
00002  * SMC 37C669 initialization code
00003  */
00004 #include <linux/kernel.h>
00005 
00006 #include <linux/malloc.h>
00007 #include <linux/mm.h>
00008 #include <linux/init.h>
00009 #include <linux/delay.h>
00010 
00011 #include <asm/hwrpb.h>
00012 #include <asm/io.h>
00013 #include <asm/segment.h>
00014 
00015 #if 0
00016 # define DBG_DEVS(args)         printk args
00017 #else
00018 # define DBG_DEVS(args)
00019 #endif
00020 
00021 #define KB              1024
00022 #define MB              (1024*KB)
00023 #define GB              (1024*MB)
00024 
00025 #define SMC_DEBUG   0
00026 
00027 /* File:        smcc669_def.h
00028  *
00029  * Copyright (C) 1997 by
00030  * Digital Equipment Corporation, Maynard, Massachusetts.
00031  * All rights reserved.
00032  *
00033  * This software is furnished under a license and may be used and copied
00034  * only  in  accordance  of  the  terms  of  such  license  and with the
00035  * inclusion of the above copyright notice. This software or  any  other
00036  * copies thereof may not be provided or otherwise made available to any
00037  * other person.  No title to and  ownership of the  software is  hereby
00038  * transferred.
00039  *
00040  * The information in this software is  subject to change without notice
00041  * and  should  not  be  construed  as a commitment by Digital Equipment
00042  * Corporation.
00043  *
00044  * Digital assumes no responsibility for the use  or  reliability of its
00045  * software on equipment which is not supplied by Digital.
00046  *
00047  *
00048  * Abstract:    
00049  *
00050  *      This file contains header definitions for the SMC37c669 
00051  *      Super I/O controller. 
00052  *
00053  * Author:      
00054  *
00055  *      Eric Rasmussen
00056  *
00057  * Modification History:
00058  *
00059  *      er      28-Jan-1997     Initial Entry
00060  */
00061 
00062 #ifndef __SMC37c669_H
00063 #define __SMC37c669_H
00064 
00065 /*
00066 ** Macros for handling device IRQs
00067 **
00068 ** The mask acts as a flag used in mapping actual ISA IRQs (0 - 15) 
00069 ** to device IRQs (A - H).
00070 */
00071 #define SMC37c669_DEVICE_IRQ_MASK       0x80000000
00072 #define SMC37c669_DEVICE_IRQ( __i )     \
00073         ((SMC37c669_DEVICE_IRQ_MASK) | (__i))
00074 #define SMC37c669_IS_DEVICE_IRQ(__i)    \
00075         (((__i) & (SMC37c669_DEVICE_IRQ_MASK)) == (SMC37c669_DEVICE_IRQ_MASK))
00076 #define SMC37c669_RAW_DEVICE_IRQ(__i)   \
00077         ((__i) & ~(SMC37c669_DEVICE_IRQ_MASK))
00078 
00079 /*
00080 ** Macros for handling device DRQs
00081 **
00082 ** The mask acts as a flag used in mapping actual ISA DMA
00083 ** channels to device DMA channels (A - C).
00084 */
00085 #define SMC37c669_DEVICE_DRQ_MASK       0x80000000
00086 #define SMC37c669_DEVICE_DRQ(__d)       \
00087         ((SMC37c669_DEVICE_DRQ_MASK) | (__d))
00088 #define SMC37c669_IS_DEVICE_DRQ(__d)    \
00089         (((__d) & (SMC37c669_DEVICE_DRQ_MASK)) == (SMC37c669_DEVICE_DRQ_MASK))
00090 #define SMC37c669_RAW_DEVICE_DRQ(__d)   \
00091         ((__d) & ~(SMC37c669_DEVICE_DRQ_MASK))
00092 
00093 #define SMC37c669_DEVICE_ID     0x3
00094 
00095 /*
00096 ** SMC37c669 Device Function Definitions
00097 */
00098 #define SERIAL_0        0
00099 #define SERIAL_1        1
00100 #define PARALLEL_0      2
00101 #define FLOPPY_0        3
00102 #define IDE_0           4
00103 #define NUM_FUNCS       5
00104 
00105 /*
00106 ** Default Device Function Mappings
00107 */
00108 #define COM1_BASE       0x3F8
00109 #define COM1_IRQ        4
00110 #define COM2_BASE       0x2F8
00111 #define COM2_IRQ        3
00112 #define PARP_BASE       0x3BC
00113 #define PARP_IRQ        7
00114 #define PARP_DRQ        3
00115 #define FDC_BASE        0x3F0
00116 #define FDC_IRQ         6
00117 #define FDC_DRQ         2
00118 
00119 /*
00120 ** Configuration On/Off Key Definitions
00121 */
00122 #define SMC37c669_CONFIG_ON_KEY         0x55
00123 #define SMC37c669_CONFIG_OFF_KEY        0xAA
00124 
00125 /*
00126 ** SMC 37c669 Device IRQs
00127 */
00128 #define SMC37c669_DEVICE_IRQ_A      ( SMC37c669_DEVICE_IRQ( 0x01 ) )
00129 #define SMC37c669_DEVICE_IRQ_B      ( SMC37c669_DEVICE_IRQ( 0x02 ) )
00130 #define SMC37c669_DEVICE_IRQ_C      ( SMC37c669_DEVICE_IRQ( 0x03 ) )
00131 #define SMC37c669_DEVICE_IRQ_D      ( SMC37c669_DEVICE_IRQ( 0x04 ) )
00132 #define SMC37c669_DEVICE_IRQ_E      ( SMC37c669_DEVICE_IRQ( 0x05 ) )
00133 #define SMC37c669_DEVICE_IRQ_F      ( SMC37c669_DEVICE_IRQ( 0x06 ) )
00134 /*      SMC37c669_DEVICE_IRQ_G      *** RESERVED ***/
00135 #define SMC37c669_DEVICE_IRQ_H      ( SMC37c669_DEVICE_IRQ( 0x08 ) )
00136 
00137 /*
00138 ** SMC 37c669 Device DMA Channel Definitions
00139 */
00140 #define SMC37c669_DEVICE_DRQ_A              ( SMC37c669_DEVICE_DRQ( 0x01 ) )
00141 #define SMC37c669_DEVICE_DRQ_B              ( SMC37c669_DEVICE_DRQ( 0x02 ) )
00142 #define SMC37c669_DEVICE_DRQ_C              ( SMC37c669_DEVICE_DRQ( 0x03 ) )
00143 
00144 /*
00145 ** Configuration Register Index Definitions
00146 */
00147 #define SMC37c669_CR00_INDEX        0x00
00148 #define SMC37c669_CR01_INDEX        0x01
00149 #define SMC37c669_CR02_INDEX        0x02
00150 #define SMC37c669_CR03_INDEX        0x03
00151 #define SMC37c669_CR04_INDEX        0x04
00152 #define SMC37c669_CR05_INDEX        0x05
00153 #define SMC37c669_CR06_INDEX        0x06
00154 #define SMC37c669_CR07_INDEX        0x07
00155 #define SMC37c669_CR08_INDEX        0x08
00156 #define SMC37c669_CR09_INDEX        0x09
00157 #define SMC37c669_CR0A_INDEX        0x0A
00158 #define SMC37c669_CR0B_INDEX        0x0B
00159 #define SMC37c669_CR0C_INDEX        0x0C
00160 #define SMC37c669_CR0D_INDEX        0x0D
00161 #define SMC37c669_CR0E_INDEX        0x0E
00162 #define SMC37c669_CR0F_INDEX        0x0F
00163 #define SMC37c669_CR10_INDEX        0x10
00164 #define SMC37c669_CR11_INDEX        0x11
00165 #define SMC37c669_CR12_INDEX        0x12
00166 #define SMC37c669_CR13_INDEX        0x13
00167 #define SMC37c669_CR14_INDEX        0x14
00168 #define SMC37c669_CR15_INDEX        0x15
00169 #define SMC37c669_CR16_INDEX        0x16
00170 #define SMC37c669_CR17_INDEX        0x17
00171 #define SMC37c669_CR18_INDEX        0x18
00172 #define SMC37c669_CR19_INDEX        0x19
00173 #define SMC37c669_CR1A_INDEX        0x1A
00174 #define SMC37c669_CR1B_INDEX        0x1B
00175 #define SMC37c669_CR1C_INDEX        0x1C
00176 #define SMC37c669_CR1D_INDEX        0x1D
00177 #define SMC37c669_CR1E_INDEX        0x1E
00178 #define SMC37c669_CR1F_INDEX        0x1F
00179 #define SMC37c669_CR20_INDEX        0x20
00180 #define SMC37c669_CR21_INDEX        0x21
00181 #define SMC37c669_CR22_INDEX        0x22
00182 #define SMC37c669_CR23_INDEX        0x23
00183 #define SMC37c669_CR24_INDEX        0x24
00184 #define SMC37c669_CR25_INDEX        0x25
00185 #define SMC37c669_CR26_INDEX        0x26
00186 #define SMC37c669_CR27_INDEX        0x27
00187 #define SMC37c669_CR28_INDEX        0x28
00188 #define SMC37c669_CR29_INDEX        0x29
00189 
00190 /*
00191 ** Configuration Register Alias Definitions
00192 */
00193 #define SMC37c669_DEVICE_ID_INDEX                   SMC37c669_CR0D_INDEX
00194 #define SMC37c669_DEVICE_REVISION_INDEX             SMC37c669_CR0E_INDEX
00195 #define SMC37c669_FDC_BASE_ADDRESS_INDEX            SMC37c669_CR20_INDEX
00196 #define SMC37c669_IDE_BASE_ADDRESS_INDEX            SMC37c669_CR21_INDEX
00197 #define SMC37c669_IDE_ALTERNATE_ADDRESS_INDEX       SMC37c669_CR22_INDEX
00198 #define SMC37c669_PARALLEL0_BASE_ADDRESS_INDEX      SMC37c669_CR23_INDEX
00199 #define SMC37c669_SERIAL0_BASE_ADDRESS_INDEX        SMC37c669_CR24_INDEX
00200 #define SMC37c669_SERIAL1_BASE_ADDRESS_INDEX        SMC37c669_CR25_INDEX
00201 #define SMC37c669_PARALLEL_FDC_DRQ_INDEX            SMC37c669_CR26_INDEX
00202 #define SMC37c669_PARALLEL_FDC_IRQ_INDEX            SMC37c669_CR27_INDEX
00203 #define SMC37c669_SERIAL_IRQ_INDEX                  SMC37c669_CR28_INDEX
00204 
00205 /*
00206 ** Configuration Register Definitions
00207 **
00208 ** The INDEX (write only) and DATA (read/write) ports are effective 
00209 ** only when the chip is in the Configuration State.
00210 */
00211 typedef struct _SMC37c669_CONFIG_REGS {
00212     unsigned char index_port;
00213     unsigned char data_port;
00214 } SMC37c669_CONFIG_REGS;
00215 
00216 /*
00217 ** CR00 - default value 0x28
00218 **
00219 **  IDE_EN (CR00<1:0>):
00220 **      0x - 30ua pull-ups on nIDEEN, nHDCS0, NHDCS1
00221 **      11 - IRQ_H available as IRQ output,
00222 **           IRRX2, IRTX2 available as alternate IR pins
00223 **      10 - nIDEEN, nHDCS0, nHDCS1 used to control IDE
00224 **
00225 **  VALID (CR00<7>):
00226 **      A high level on this software controlled bit can
00227 **      be used to indicate that a valid configuration
00228 **      cycle has occurred.  The control software must
00229 **      take care to set this bit at the appropriate times.
00230 **      Set to zero after power up.  This bit has no
00231 **      effect on any other hardware in the chip.
00232 **
00233 */
00234 typedef union _SMC37c669_CR00 {
00235     unsigned char as_uchar;
00236     struct {
00237         unsigned ide_en : 2;        /* See note above           */
00238         unsigned reserved1 : 1;     /* RAZ                      */
00239         unsigned fdc_pwr : 1;       /* 1 = supply power to FDC  */
00240         unsigned reserved2 : 3;     /* Read as 010b             */
00241         unsigned valid : 1;         /* See note above           */
00242     }   by_field;
00243 } SMC37c669_CR00;
00244 
00245 /*
00246 ** CR01 - default value 0x9C
00247 */
00248 typedef union _SMC37c669_CR01 {
00249     unsigned char as_uchar;
00250     struct {
00251         unsigned reserved1 : 2;     /* RAZ                          */
00252         unsigned ppt_pwr : 1;       /* 1 = supply power to PPT      */
00253         unsigned ppt_mode : 1;      /* 1 = Printer mode, 0 = EPP    */
00254         unsigned reserved2 : 1;     /* Read as 1                    */
00255         unsigned reserved3 : 2;     /* RAZ                          */
00256         unsigned lock_crx: 1;       /* Lock CR00 - CR18             */
00257     }   by_field;
00258 } SMC37c669_CR01;
00259 
00260 /*
00261 ** CR02 - default value 0x88
00262 */
00263 typedef union _SMC37c669_CR02 {
00264     unsigned char as_uchar;
00265     struct {
00266         unsigned reserved1 : 3;     /* RAZ                          */
00267         unsigned uart1_pwr : 1;     /* 1 = supply power to UART1    */
00268         unsigned reserved2 : 3;     /* RAZ                          */
00269         unsigned uart2_pwr : 1;     /* 1 = supply power to UART2    */
00270     }   by_field;
00271 } SMC37c669_CR02;
00272 
00273 /*
00274 ** CR03 - default value 0x78
00275 **
00276 **  CR03<7>     CR03<2>     Pin 94
00277 **  -------     -------     ------
00278 **     0           X        DRV2 (input)
00279 **     1           0        ADRX
00280 **     1           1        IRQ_B
00281 **
00282 **  CR03<6>     CR03<5>     Op Mode
00283 **  -------     -------     -------
00284 **     0           0        Model 30
00285 **     0           1        PS/2
00286 **     1           0        Reserved
00287 **     1           1        AT Mode
00288 */
00289 typedef union _SMC37c669_CR03 {
00290     unsigned char as_uchar;
00291     struct {
00292         unsigned pwrgd_gamecs : 1;  /* 1 = PWRGD, 0 = GAMECS        */
00293         unsigned fdc_mode2 : 1;     /* 1 = Enhanced Mode 2          */
00294         unsigned pin94_0 : 1;       /* See note above               */
00295         unsigned reserved1 : 1;     /* RAZ                          */
00296         unsigned drvden : 1;        /* 1 = high, 0 - output         */
00297         unsigned op_mode : 2;       /* See note above               */
00298         unsigned pin94_1 : 1;       /* See note above               */
00299     }   by_field;
00300 } SMC37c669_CR03;
00301 
00302 /*
00303 ** CR04 - default value 0x00
00304 **
00305 **  PP_EXT_MODE:
00306 **      If CR01<PP_MODE> = 0 and PP_EXT_MODE =
00307 **          00 - Standard and Bidirectional
00308 **          01 - EPP mode and SPP
00309 **          10 - ECP mode
00310 **               In this mode, 2 drives can be supported
00311 **               directly, 3 or 4 drives must use external
00312 **               4 drive support.  SPP can be selected
00313 **               through the ECR register of ECP as mode 000.
00314 **          11 - ECP mode and EPP mode
00315 **               In this mode, 2 drives can be supported
00316 **               directly, 3 or 4 drives must use external
00317 **               4 drive support.  SPP can be selected
00318 **               through the ECR register of ECP as mode 000.
00319 **               In this mode, EPP can be selected through
00320 **               the ECR register of ECP as mode 100.
00321 **
00322 **  PP_FDC:
00323 **      00 - Normal
00324 **      01 - PPFD1
00325 **      10 - PPFD2
00326 **      11 - Reserved
00327 **
00328 **  MIDI1:
00329 **      Serial Clock Select: 
00330 **          A low level on this bit disables MIDI support,
00331 **          clock = divide by 13.  A high level on this 
00332 **          bit enables MIDI support, clock = divide by 12.
00333 **
00334 **      MIDI operates at 31.25 Kbps which can be derived 
00335 **      from 125 KHz (24 MHz / 12 = 2 MHz, 2 MHz / 16 = 125 KHz)
00336 **
00337 **  ALT_IO:
00338 **      0 - Use pins IRRX, IRTX
00339 **      1 - Use pins IRRX2, IRTX2
00340 **
00341 **      If this bit is set, the IR receive and transmit
00342 **      functions will not be available on pins 25 and 26
00343 **      unless CR00<IDE_EN> = 11.
00344 */
00345 typedef union _SMC37c669_CR04 {
00346     unsigned char as_uchar;
00347     struct {
00348         unsigned ppt_ext_mode : 2;  /* See note above               */
00349         unsigned ppt_fdc : 2;       /* See note above               */
00350         unsigned midi1 : 1;         /* See note above               */
00351         unsigned midi2 : 1;         /* See note above               */
00352         unsigned epp_type : 1;      /* 0 = EPP 1.9, 1 = EPP 1.7     */
00353         unsigned alt_io : 1;        /* See note above               */
00354     }   by_field;
00355 } SMC37c669_CR04;
00356 
00357 /*
00358 ** CR05 - default value 0x00
00359 **
00360 **  DEN_SEL:
00361 **      00 - Densel output normal
00362 **      01 - Reserved
00363 **      10 - Densel output 1
00364 **      11 - Densel output 0
00365 **
00366 */
00367 typedef union _SMC37c669_CR05 {
00368     unsigned char as_uchar;
00369     struct {
00370         unsigned reserved1 : 2;     /* RAZ                                      */
00371         unsigned fdc_dma_mode : 1;  /* 0 = burst, 1 = non-burst                 */
00372         unsigned den_sel : 2;       /* See note above                           */
00373         unsigned swap_drv : 1;      /* Swap the FDC motor selects               */
00374         unsigned extx4 : 1;         /* 0 = 2 drive, 1 = external 4 drive decode */
00375         unsigned reserved2 : 1;     /* RAZ                                      */
00376     }   by_field;
00377 } SMC37c669_CR05;
00378 
00379 /*
00380 ** CR06 - default value 0xFF
00381 */
00382 typedef union _SMC37c669_CR06 {
00383     unsigned char as_uchar;
00384     struct {
00385         unsigned floppy_a : 2;      /* Type of floppy drive A       */
00386         unsigned floppy_b : 2;      /* Type of floppy drive B       */
00387         unsigned floppy_c : 2;      /* Type of floppy drive C       */
00388         unsigned floppy_d : 2;      /* Type of floppy drive D       */
00389     }   by_field;
00390 } SMC37c669_CR06;
00391 
00392 /*
00393 ** CR07 - default value 0x00
00394 **
00395 **  Auto Power Management CR07<7:4>:
00396 **      0 - Auto Powerdown disabled (default)
00397 **      1 - Auto Powerdown enabled
00398 **
00399 **      This bit is reset to the default state by POR or
00400 **      a hardware reset.
00401 **
00402 */
00403 typedef union _SMC37c669_CR07 {
00404     unsigned char as_uchar;
00405     struct {
00406         unsigned floppy_boot : 2;   /* 0 = A:, 1 = B:               */
00407         unsigned reserved1 : 2;     /* RAZ                          */
00408         unsigned ppt_en : 1;        /* See note above               */
00409         unsigned uart1_en : 1;      /* See note above               */
00410         unsigned uart2_en : 1;      /* See note above               */
00411         unsigned fdc_en : 1;        /* See note above               */
00412     }   by_field;
00413 } SMC37c669_CR07;
00414 
00415 /*
00416 ** CR08 - default value 0x00
00417 */
00418 typedef union _SMC37c669_CR08 {
00419     unsigned char as_uchar;
00420     struct {
00421         unsigned zero : 4;          /* 0                            */
00422         unsigned addrx7_4 : 4;      /* ADR<7:3> for ADRx decode     */
00423     }   by_field;
00424 } SMC37c669_CR08;
00425 
00426 /*
00427 ** CR09 - default value 0x00
00428 **
00429 **  ADRx_CONFIG:
00430 **      00 - ADRx disabled
00431 **      01 - 1 byte decode A<3:0> = 0000b
00432 **      10 - 8 byte block decode A<3:0> = 0XXXb
00433 **      11 - 16 byte block decode A<3:0> = XXXXb
00434 **
00435 */
00436 typedef union _SMC37c669_CR09 {
00437     unsigned char as_uchar;
00438     struct {
00439         unsigned adra8 : 3;         /* ADR<10:8> for ADRx decode    */
00440         unsigned reserved1 : 3;
00441         unsigned adrx_config : 2;   /* See note above               */
00442     }   by_field;
00443 } SMC37c669_CR09;
00444 
00445 /*
00446 ** CR0A - default value 0x00
00447 */
00448 typedef union _SMC37c669_CR0A {
00449     unsigned char as_uchar;
00450     struct {
00451         unsigned ecp_fifo_threshold : 4;
00452         unsigned reserved1 : 4;
00453     }   by_field;
00454 } SMC37c669_CR0A;
00455 
00456 /*
00457 ** CR0B - default value 0x00
00458 */
00459 typedef union _SMC37c669_CR0B {
00460     unsigned char as_uchar;
00461     struct {
00462         unsigned fdd0_drtx : 2;     /* FDD0 Data Rate Table         */
00463         unsigned fdd1_drtx : 2;     /* FDD1 Data Rate Table         */
00464         unsigned fdd2_drtx : 2;     /* FDD2 Data Rate Table         */
00465         unsigned fdd3_drtx : 2;     /* FDD3 Data Rate Table         */
00466     }   by_field;
00467 } SMC37c669_CR0B;
00468 
00469 /*
00470 ** CR0C - default value 0x00
00471 **
00472 **  UART2_MODE:
00473 **      000 - Standard (default)
00474 **      001 - IrDA (HPSIR)
00475 **      010 - Amplitude Shift Keyed IR @500 KHz
00476 **      011 - Reserved
00477 **      1xx - Reserved
00478 **
00479 */
00480 typedef union _SMC37c669_CR0C {
00481     unsigned char as_uchar;
00482     struct {
00483         unsigned uart2_rcv_polarity : 1;    /* 1 = invert RX            */
00484         unsigned uart2_xmit_polarity : 1;   /* 1 = invert TX            */
00485         unsigned uart2_duplex : 1;          /* 1 = full, 0 = half       */
00486         unsigned uart2_mode : 3;            /* See note above           */
00487         unsigned uart1_speed : 1;           /* 1 = high speed enabled   */
00488         unsigned uart2_speed : 1;           /* 1 = high speed enabled   */
00489     }   by_field;
00490 } SMC37c669_CR0C;
00491 
00492 /*
00493 ** CR0D - default value 0x03
00494 **
00495 **  Device ID Register - read only
00496 */
00497 typedef union _SMC37c669_CR0D {
00498     unsigned char as_uchar;
00499     struct {
00500         unsigned device_id : 8;     /* Returns 0x3 in this field    */
00501     }   by_field;
00502 } SMC37c669_CR0D;
00503 
00504 /*
00505 ** CR0E - default value 0x02
00506 **
00507 **  Device Revision Register - read only
00508 */
00509 typedef union _SMC37c669_CR0E {
00510     unsigned char as_uchar;
00511     struct {
00512         unsigned device_rev : 8;    /* Returns 0x2 in this field    */
00513     }   by_field;
00514 } SMC37c669_CR0E;
00515 
00516 /*
00517 ** CR0F - default value 0x00
00518 */
00519 typedef union _SMC37c669_CR0F {
00520     unsigned char as_uchar;
00521     struct {
00522         unsigned test0 : 1;         /* Reserved - set to 0          */
00523         unsigned test1 : 1;         /* Reserved - set to 0          */
00524         unsigned test2 : 1;         /* Reserved - set to 0          */
00525         unsigned test3 : 1;         /* Reserved - set t0 0          */
00526         unsigned test4 : 1;         /* Reserved - set to 0          */
00527         unsigned test5 : 1;         /* Reserved - set t0 0          */
00528         unsigned test6 : 1;         /* Reserved - set t0 0          */
00529         unsigned test7 : 1;         /* Reserved - set to 0          */
00530     }   by_field;
00531 } SMC37c669_CR0F;
00532 
00533 /*
00534 ** CR10 - default value 0x00
00535 */
00536 typedef union _SMC37c669_CR10 {
00537     unsigned char as_uchar;
00538     struct {
00539         unsigned reserved1 : 3;      /* RAZ                         */
00540         unsigned pll_gain : 1;       /* 1 = 3V, 2 = 5V operation    */
00541         unsigned pll_stop : 1;       /* 1 = stop PLLs               */
00542         unsigned ace_stop : 1;       /* 1 = stop UART clocks        */
00543         unsigned pll_clock_ctrl : 1; /* 0 = 14.318 MHz, 1 = 24 MHz  */
00544         unsigned ir_test : 1;        /* Enable IR test mode         */
00545     }   by_field;
00546 } SMC37c669_CR10;
00547 
00548 /*
00549 ** CR11 - default value 0x00
00550 */
00551 typedef union _SMC37c669_CR11 {
00552     unsigned char as_uchar;
00553     struct {
00554         unsigned ir_loopback : 1;   /* Internal IR loop back                */
00555         unsigned test_10ms : 1;     /* Test 10ms autopowerdown FDC timeout  */
00556         unsigned reserved1 : 6;     /* RAZ                                  */
00557     }   by_field;
00558 } SMC37c669_CR11;
00559 
00560 /*
00561 ** CR12 - CR1D are reserved registers
00562 */
00563 
00564 /*
00565 ** CR1E - default value 0x80
00566 **
00567 **  GAMECS:
00568 **      00 - GAMECS disabled
00569 **      01 - 1 byte decode ADR<3:0> = 0001b
00570 **      10 - 8 byte block decode ADR<3:0> = 0XXXb
00571 **      11 - 16 byte block decode ADR<3:0> = XXXXb
00572 **
00573 */
00574 typedef union _SMC37c66_CR1E {
00575     unsigned char as_uchar;
00576     struct {
00577         unsigned gamecs_config: 2;   /* See note above              */
00578         unsigned gamecs_addr9_4 : 6; /* GAMECS Addr<9:4>            */
00579     }   by_field;
00580 } SMC37c669_CR1E;
00581 
00582 /*
00583 ** CR1F - default value 0x00
00584 **
00585 **  DT0 DT1 DRVDEN0 DRVDEN1 Drive Type
00586 **  --- --- ------- ------- ----------
00587 **   0   0  DENSEL  DRATE0  4/2/1 MB 3.5"
00588 **                          2/1 MB 5.25"
00589 **                          2/1.6/1 MB 3.5" (3-mode)
00590 **   0   1  DRATE1  DRATE0
00591 **   1   0  nDENSEL DRATE0  PS/2
00592 **   1   1  DRATE0  DRATE1
00593 **
00594 **  Note: DENSEL, DRATE1, and DRATE0 map onto two output
00595 **        pins - DRVDEN0 and DRVDEN1.
00596 **
00597 */
00598 typedef union _SMC37c669_CR1F {
00599     unsigned char as_uchar;
00600     struct {
00601         unsigned fdd0_drive_type : 2;   /* FDD0 drive type          */
00602         unsigned fdd1_drive_type : 2;   /* FDD1 drive type          */
00603         unsigned fdd2_drive_type : 2;   /* FDD2 drive type          */
00604         unsigned fdd3_drive_type : 2;   /* FDD3 drive type          */
00605     }   by_field;
00606 } SMC37c669_CR1F;
00607 
00608 /*
00609 ** CR20 - default value 0x3C
00610 **
00611 **  FDC Base Address Register
00612 **      - To disable this decode set Addr<9:8> = 0
00613 **      - A<10> = 0, A<3:0> = 0XXXb to access.
00614 **
00615 */
00616 typedef union _SMC37c669_CR20 {
00617     unsigned char as_uchar;
00618     struct {
00619         unsigned zero : 2;          /* 0                            */
00620         unsigned addr9_4 : 6;       /* FDC Addr<9:4>                */
00621     }   by_field;
00622 } SMC37c669_CR20;
00623 
00624 /*
00625 ** CR21 - default value 0x3C
00626 **
00627 **  IDE Base Address Register
00628 **      - To disable this decode set Addr<9:8> = 0
00629 **      - A<10> = 0, A<3:0> = 0XXXb to access.
00630 **
00631 */
00632 typedef union _SMC37c669_CR21 {
00633     unsigned char as_uchar;
00634     struct {
00635         unsigned zero : 2;          /* 0                            */
00636         unsigned addr9_4 : 6;       /* IDE Addr<9:4>                */
00637     }   by_field;
00638 } SMC37c669_CR21;
00639 
00640 /*
00641 ** CR22 - default value 0x3D
00642 **
00643 **  IDE Alternate Status Base Address Register
00644 **      - To disable this decode set Addr<9:8> = 0
00645 **      - A<10> = 0, A<3:0> = 0110b to access.
00646 **
00647 */
00648 typedef union _SMC37c669_CR22 {
00649     unsigned char as_uchar;
00650     struct {
00651         unsigned zero : 2;          /* 0                            */
00652         unsigned addr9_4 : 6;       /* IDE Alt Status Addr<9:4>     */
00653     }   by_field;
00654 } SMC37c669_CR22;
00655 
00656 /*
00657 ** CR23 - default value 0x00
00658 **
00659 **  Parallel Port Base Address Register
00660 **      - To disable this decode set Addr<9:8> = 0
00661 **      - A<10> = 0 to access.
00662 **      - If EPP is enabled, A<2:0> = XXXb to access.
00663 **        If EPP is NOT enabled, A<1:0> = XXb to access
00664 **
00665 */
00666 typedef union _SMC37c669_CR23 {
00667     unsigned char as_uchar;
00668     struct {
00669         unsigned addr9_2 : 8;       /* Parallel Port Addr<9:2>      */
00670     }   by_field;
00671 } SMC37c669_CR23;
00672 
00673 /*
00674 ** CR24 - default value 0x00
00675 **
00676 **  UART1 Base Address Register
00677 **      - To disable this decode set Addr<9:8> = 0
00678 **      - A<10> = 0, A<2:0> = XXXb to access.
00679 **
00680 */
00681 typedef union _SMC37c669_CR24 {
00682     unsigned char as_uchar;
00683     struct {
00684         unsigned zero : 1;          /* 0                            */
00685         unsigned addr9_3 : 7;       /* UART1 Addr<9:3>              */
00686     }   by_field;
00687 } SMC37c669_CR24;
00688 
00689 /*
00690 ** CR25 - default value 0x00
00691 **
00692 **  UART2 Base Address Register
00693 **      - To disable this decode set Addr<9:8> = 0
00694 **      - A<10> = 0, A<2:0> = XXXb to access.
00695 **
00696 */
00697 typedef union _SMC37c669_CR25 {
00698     unsigned char as_uchar;
00699     struct {
00700         unsigned zero : 1;          /* 0                            */
00701         unsigned addr9_3 : 7;       /* UART2 Addr<9:3>              */
00702     }   by_field;
00703 } SMC37c669_CR25;
00704 
00705 /*
00706 ** CR26 - default value 0x00
00707 **
00708 **  Parallel Port / FDC DMA Select Register
00709 **
00710 **  D3 - D0       DMA
00711 **  D7 - D4     Selected
00712 **  -------     --------
00713 **   0000        None
00714 **   0001        DMA_A
00715 **   0010        DMA_B
00716 **   0011        DMA_C
00717 **
00718 */
00719 typedef union _SMC37c669_CR26 {
00720     unsigned char as_uchar;
00721     struct {
00722         unsigned ppt_drq : 4;       /* See note above               */
00723         unsigned fdc_drq : 4;       /* See note above               */
00724     }   by_field;
00725 } SMC37c669_CR26;
00726 
00727 /*
00728 ** CR27 - default value 0x00
00729 **
00730 **  Parallel Port / FDC IRQ Select Register
00731 **
00732 **  D3 - D0       IRQ
00733 **  D7 - D4     Selected
00734 **  -------     --------
00735 **   0000        None
00736 **   0001        IRQ_A
00737 **   0010        IRQ_B
00738 **   0011        IRQ_C
00739 **   0100        IRQ_D
00740 **   0101        IRQ_E
00741 **   0110        IRQ_F
00742 **   0111        Reserved
00743 **   1000        IRQ_H
00744 **
00745 **  Any unselected IRQ REQ is in tristate
00746 **
00747 */
00748 typedef union _SMC37c669_CR27 {
00749     unsigned char as_uchar;
00750     struct {
00751         unsigned ppt_irq : 4;       /* See note above               */
00752         unsigned fdc_irq : 4;       /* See note above               */
00753     }   by_field;
00754 } SMC37c669_CR27;
00755 
00756 /*
00757 ** CR28 - default value 0x00
00758 **
00759 **  UART IRQ Select Register
00760 **
00761 **  D3 - D0       IRQ
00762 **  D7 - D4     Selected
00763 **  -------     --------
00764 **   0000        None
00765 **   0001        IRQ_A
00766 **   0010        IRQ_B
00767 **   0011        IRQ_C
00768 **   0100        IRQ_D
00769 **   0101        IRQ_E
00770 **   0110        IRQ_F
00771 **   0111        Reserved
00772 **   1000        IRQ_H
00773 **   1111        share with UART1 (only for UART2)
00774 **
00775 **  Any unselected IRQ REQ is in tristate
00776 **
00777 **  To share an IRQ between UART1 and UART2, set
00778 **  UART1 to use the desired IRQ and set UART2 to
00779 **  0xF to enable sharing mechanism.
00780 **
00781 */
00782 typedef union _SMC37c669_CR28 {
00783     unsigned char as_uchar;
00784     struct {
00785         unsigned uart2_irq : 4;     /* See note above               */
00786         unsigned uart1_irq : 4;     /* See note above               */
00787     }   by_field;
00788 } SMC37c669_CR28;
00789 
00790 /*
00791 ** CR29 - default value 0x00
00792 **
00793 **  IRQIN IRQ Select Register
00794 **
00795 **  D3 - D0       IRQ
00796 **  D7 - D4     Selected
00797 **  -------     --------
00798 **   0000        None
00799 **   0001        IRQ_A
00800 **   0010        IRQ_B
00801 **   0011        IRQ_C
00802 **   0100        IRQ_D
00803 **   0101        IRQ_E
00804 **   0110        IRQ_F
00805 **   0111        Reserved
00806 **   1000        IRQ_H
00807 **
00808 **  Any unselected IRQ REQ is in tristate
00809 **
00810 */
00811 typedef union _SMC37c669_CR29 {
00812     unsigned char as_uchar;
00813     struct {
00814         unsigned irqin_irq : 4;     /* See note above               */
00815         unsigned reserved1 : 4;     /* RAZ                          */
00816     }   by_field;
00817 } SMC37c669_CR29;
00818 
00819 /*
00820 ** Aliases of Configuration Register formats (should match
00821 ** the set of index aliases).
00822 **
00823 ** Note that CR24 and CR25 have the same format and are the
00824 ** base address registers for UART1 and UART2.  Because of
00825 ** this we only define 1 alias here - for CR24 - as the serial
00826 ** base address register.
00827 **
00828 ** Note that CR21 and CR22 have the same format and are the
00829 ** base address and alternate status address registers for
00830 ** the IDE controller.  Because of this we only define 1 alias
00831 ** here - for CR21 - as the IDE address register.
00832 **
00833 */
00834 typedef SMC37c669_CR0D SMC37c669_DEVICE_ID_REGISTER;
00835 typedef SMC37c669_CR0E SMC37c669_DEVICE_REVISION_REGISTER;
00836 typedef SMC37c669_CR20 SMC37c669_FDC_BASE_ADDRESS_REGISTER;
00837 typedef SMC37c669_CR21 SMC37c669_IDE_ADDRESS_REGISTER;
00838 typedef SMC37c669_CR23 SMC37c669_PARALLEL_BASE_ADDRESS_REGISTER;
00839 typedef SMC37c669_CR24 SMC37c669_SERIAL_BASE_ADDRESS_REGISTER;
00840 typedef SMC37c669_CR26 SMC37c669_PARALLEL_FDC_DRQ_REGISTER;
00841 typedef SMC37c669_CR27 SMC37c669_PARALLEL_FDC_IRQ_REGISTER;
00842 typedef SMC37c669_CR28 SMC37c669_SERIAL_IRQ_REGISTER;
00843 
00844 /*
00845 ** ISA/Device IRQ Translation Table Entry Definition
00846 */
00847 typedef struct _SMC37c669_IRQ_TRANSLATION_ENTRY {
00848     int device_irq;
00849     int isa_irq;
00850 } SMC37c669_IRQ_TRANSLATION_ENTRY;
00851 
00852 /*
00853 ** ISA/Device DMA Translation Table Entry Definition
00854 */
00855 typedef struct _SMC37c669_DRQ_TRANSLATION_ENTRY {
00856     int device_drq;
00857     int isa_drq;
00858 } SMC37c669_DRQ_TRANSLATION_ENTRY;
00859 
00860 /*
00861 ** External Interface Function Prototype Declarations
00862 */
00863 
00864 SMC37c669_CONFIG_REGS *SMC37c669_detect( 
00865     int
00866 );
00867 
00868 unsigned int SMC37c669_enable_device( 
00869     unsigned int func 
00870 );
00871 
00872 unsigned int SMC37c669_disable_device( 
00873     unsigned int func 
00874 );
00875 
00876 unsigned int SMC37c669_configure_device( 
00877     unsigned int func, 
00878     int port, 
00879     int irq, 
00880     int drq 
00881 );
00882 
00883 void SMC37c669_display_device_info( 
00884     void 
00885 );
00886 
00887 #endif  /* __SMC37c669_H */
00888 
00889 /* file:        smcc669.c
00890  *
00891  * Copyright (C) 1997 by
00892  * Digital Equipment Corporation, Maynard, Massachusetts.
00893  * All rights reserved.
00894  *
00895  * This software is furnished under a license and may be used and copied
00896  * only  in  accordance  of  the  terms  of  such  license  and with the
00897  * inclusion of the above copyright notice. This software or  any  other
00898  * copies thereof may not be provided or otherwise made available to any
00899  * other person.  No title to and  ownership of the  software is  hereby
00900  * transferred.
00901  *
00902  * The information in this software is  subject to change without notice
00903  * and  should  not  be  construed  as a commitment by digital equipment
00904  * corporation.
00905  *
00906  * Digital assumes no responsibility for the use  or  reliability of its
00907  * software on equipment which is not supplied by digital.
00908  */
00909 
00910 /*
00911  *++
00912  *  FACILITY:
00913  *
00914  *      Alpha SRM Console Firmware
00915  *
00916  *  MODULE DESCRIPTION:
00917  *
00918  *      SMC37c669 Super I/O controller configuration routines.
00919  *
00920  *  AUTHORS:
00921  *
00922  *      Eric Rasmussen
00923  *
00924  *  CREATION DATE:
00925  *  
00926  *      28-Jan-1997
00927  *
00928  *  MODIFICATION HISTORY:
00929  *      
00930  *      er      01-May-1997     Fixed pointer conversion errors in 
00931  *                              SMC37c669_get_device_config().
00932  *      er      28-Jan-1997     Initial version.
00933  *
00934  *--
00935  */
00936 #if 0
00937 /* $INCLUDE_OPTIONS$ */
00938 #include    "cp$inc:platform_io.h"
00939 /* $INCLUDE_OPTIONS_END$ */
00940 #include    "cp$src:common.h"
00941 #include    "cp$inc:prototypes.h"
00942 #include    "cp$src:kernel_def.h"
00943 #include    "cp$src:msg_def.h"
00944 #include    "cp$src:smcc669_def.h"
00945 /* Platform-specific includes */
00946 #include    "cp$src:platform.h"
00947 #endif
00948 
00949 #ifndef TRUE
00950 #define TRUE 1
00951 #endif
00952 #ifndef FALSE
00953 #define FALSE 0
00954 #endif
00955 
00956 #define wb( _x_, _y_ )  outb( _y_, (unsigned int)((unsigned long)_x_) )
00957 #define rb( _x_ )       inb( (unsigned int)((unsigned long)_x_) )
00958 
00959 /*
00960 ** Local storage for device configuration information.
00961 **
00962 ** Since the SMC37c669 does not provide an explicit
00963 ** mechanism for enabling/disabling individual device 
00964 ** functions, other than unmapping the device, local 
00965 ** storage for device configuration information is 
00966 ** allocated here for use in implementing our own 
00967 ** function enable/disable scheme.
00968 */
00969 static struct DEVICE_CONFIG {
00970     unsigned int port1;
00971     unsigned int port2;
00972     unsigned int irq;
00973     unsigned int drq;
00974 } local_config [NUM_FUNCS];
00975 
00976 /*
00977 ** List of all possible addresses for the Super I/O chip
00978 */
00979 static unsigned long SMC37c669_Addresses[] __initdata =
00980     {
00981         0x3F0UL,            /* Primary address      */
00982         0x370UL,            /* Secondary address    */
00983         0UL                 /* End of list          */
00984     };
00985 
00986 /*
00987 ** Global Pointer to the Super I/O device
00988 */
00989 static SMC37c669_CONFIG_REGS *SMC37c669 __initdata = NULL;
00990 
00991 /*
00992 ** IRQ Translation Table
00993 **
00994 ** The IRQ translation table is a list of SMC37c669 device 
00995 ** and standard ISA IRQs.
00996 **
00997 */
00998 static SMC37c669_IRQ_TRANSLATION_ENTRY *SMC37c669_irq_table __initdata = 0; 
00999 
01000 /*
01001 ** The following definition is for the default IRQ 
01002 ** translation table.
01003 */
01004 static SMC37c669_IRQ_TRANSLATION_ENTRY SMC37c669_default_irq_table[]
01005 __initdata = 
01006     { 
01007         { SMC37c669_DEVICE_IRQ_A, -1 }, 
01008         { SMC37c669_DEVICE_IRQ_B, -1 }, 
01009         { SMC37c669_DEVICE_IRQ_C, 7 }, 
01010         { SMC37c669_DEVICE_IRQ_D, 6 }, 
01011         { SMC37c669_DEVICE_IRQ_E, 4 }, 
01012         { SMC37c669_DEVICE_IRQ_F, 3 }, 
01013         { SMC37c669_DEVICE_IRQ_H, -1 }, 
01014         { -1, -1 } /* End of table */
01015     };
01016 
01017 /*
01018 ** The following definition is for the MONET (XP1000) IRQ 
01019 ** translation table.
01020 */
01021 static SMC37c669_IRQ_TRANSLATION_ENTRY SMC37c669_monet_irq_table[]
01022 __initdata = 
01023     { 
01024         { SMC37c669_DEVICE_IRQ_A, -1 }, 
01025         { SMC37c669_DEVICE_IRQ_B, -1 }, 
01026         { SMC37c669_DEVICE_IRQ_C, 6 }, 
01027         { SMC37c669_DEVICE_IRQ_D, 7 }, 
01028         { SMC37c669_DEVICE_IRQ_E, 4 }, 
01029         { SMC37c669_DEVICE_IRQ_F, 3 }, 
01030         { SMC37c669_DEVICE_IRQ_H, -1 }, 
01031         { -1, -1 } /* End of table */
01032     };
01033 
01034 static SMC37c669_IRQ_TRANSLATION_ENTRY *SMC37c669_irq_tables[] __initdata =
01035     {
01036         SMC37c669_default_irq_table,
01037         SMC37c669_monet_irq_table
01038     }; 
01039 
01040 /*
01041 ** DRQ Translation Table
01042 **
01043 ** The DRQ translation table is a list of SMC37c669 device and
01044 ** ISA DMA channels.
01045 **
01046 */
01047 static SMC37c669_DRQ_TRANSLATION_ENTRY *SMC37c669_drq_table __initdata = 0;
01048 
01049 /*
01050 ** The following definition is the default DRQ
01051 ** translation table.
01052 */
01053 static SMC37c669_DRQ_TRANSLATION_ENTRY SMC37c669_default_drq_table[]
01054 __initdata = 
01055     { 
01056         { SMC37c669_DEVICE_DRQ_A, 2 }, 
01057         { SMC37c669_DEVICE_DRQ_B, 3 }, 
01058         { SMC37c669_DEVICE_DRQ_C, -1 }, 
01059         { -1, -1 } /* End of table */
01060     };
01061 
01062 /*
01063 ** Local Function Prototype Declarations
01064 */
01065 
01066 static unsigned int SMC37c669_is_device_enabled( 
01067     unsigned int func 
01068 );
01069 
01070 #if 0
01071 static unsigned int SMC37c669_get_device_config( 
01072     unsigned int func, 
01073     int *port, 
01074     int *irq, 
01075     int *drq 
01076 );
01077 #endif
01078 
01079 static void SMC37c669_config_mode( 
01080     unsigned int enable 
01081 );
01082 
01083 static unsigned char SMC37c669_read_config( 
01084     unsigned char index 
01085 );
01086 
01087 static void SMC37c669_write_config( 
01088     unsigned char index, 
01089     unsigned char data 
01090 );
01091 
01092 static void SMC37c669_init_local_config( void );
01093 
01094 static struct DEVICE_CONFIG *SMC37c669_get_config(
01095     unsigned int func
01096 );
01097 
01098 static int SMC37c669_xlate_irq(
01099     unsigned int irq 
01100 );
01101 
01102 static int SMC37c669_xlate_drq(
01103     unsigned int drq 
01104 );
01105 
01106 #if 0
01107 /*
01108 ** External Data Declarations
01109 */
01110 
01111 extern struct LOCK spl_atomic;
01112 
01113 /*
01114 ** External Function Prototype Declarations
01115 */
01116 
01117 /* From kernel_alpha.mar */
01118 extern spinlock( 
01119     struct LOCK *spl 
01120 );
01121 
01122 extern spinunlock( 
01123     struct LOCK *spl 
01124 );
01125 
01126 /* From filesys.c */
01127 int allocinode(
01128     char *name, 
01129     int can_create, 
01130     struct INODE **ipp
01131 );
01132 
01133 extern int null_procedure( void );
01134 
01135 int smcc669_init( void );
01136 int smcc669_open( struct FILE *fp, char *info, char *next, char *mode );
01137 int smcc669_read( struct FILE *fp, int size, int number, unsigned char *buf );
01138 int smcc669_write( struct FILE *fp, int size, int number, unsigned char *buf );
01139 int smcc669_close( struct FILE *fp );
01140 
01141 struct DDB smc_ddb = {
01142         "smc",                  /* how this routine wants to be called  */
01143         smcc669_read,           /* read routine                         */
01144         smcc669_write,          /* write routine                        */
01145         smcc669_open,           /* open routine                         */
01146         smcc669_close,          /* close routine                        */
01147         null_procedure,         /* name expansion routine               */
01148         null_procedure,         /* delete routine                       */
01149         null_procedure,         /* create routine                       */
01150         null_procedure,         /* setmode                              */
01151         null_procedure,         /* validation routine                   */
01152         0,                      /* class specific use                   */
01153         1,                      /* allows information                   */
01154         0,                      /* must be stacked                      */
01155         0,                      /* is a flash update driver             */
01156         0,                      /* is a block device                    */
01157         0,                      /* not seekable                         */
01158         0,                      /* is an Ethernet device                */
01159         0,                      /* is a filesystem driver               */
01160 };
01161 #endif
01162 
01163 #define spinlock(x)
01164 #define spinunlock(x)
01165 
01166 
01167