PageRenderTime 83ms CodeModel.GetById 40ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/alpha/kernel/smc37c669.c

https://github.com/mturquette/linux
C | 2049 lines | 948 code | 138 blank | 963 comment | 42 complexity | efc241c144facc6e43d318f65f976577 MD5 | raw file
  1. /*
  2. * SMC 37C669 initialization code
  3. */
  4. #include <linux/kernel.h>
  5. #include <linux/mm.h>
  6. #include <linux/init.h>
  7. #include <linux/delay.h>
  8. #include <linux/spinlock.h>
  9. #include <asm/hwrpb.h>
  10. #include <asm/io.h>
  11. #include <asm/segment.h>
  12. #if 0
  13. # define DBG_DEVS(args) printk args
  14. #else
  15. # define DBG_DEVS(args)
  16. #endif
  17. #define KB 1024
  18. #define MB (1024*KB)
  19. #define GB (1024*MB)
  20. #define SMC_DEBUG 0
  21. /* File: smcc669_def.h
  22. *
  23. * Copyright (C) 1997 by
  24. * Digital Equipment Corporation, Maynard, Massachusetts.
  25. * All rights reserved.
  26. *
  27. * This software is furnished under a license and may be used and copied
  28. * only in accordance of the terms of such license and with the
  29. * inclusion of the above copyright notice. This software or any other
  30. * copies thereof may not be provided or otherwise made available to any
  31. * other person. No title to and ownership of the software is hereby
  32. * transferred.
  33. *
  34. * The information in this software is subject to change without notice
  35. * and should not be construed as a commitment by Digital Equipment
  36. * Corporation.
  37. *
  38. * Digital assumes no responsibility for the use or reliability of its
  39. * software on equipment which is not supplied by Digital.
  40. *
  41. *
  42. * Abstract:
  43. *
  44. * This file contains header definitions for the SMC37c669
  45. * Super I/O controller.
  46. *
  47. * Author:
  48. *
  49. * Eric Rasmussen
  50. *
  51. * Modification History:
  52. *
  53. * er 28-Jan-1997 Initial Entry
  54. */
  55. #ifndef __SMC37c669_H
  56. #define __SMC37c669_H
  57. /*
  58. ** Macros for handling device IRQs
  59. **
  60. ** The mask acts as a flag used in mapping actual ISA IRQs (0 - 15)
  61. ** to device IRQs (A - H).
  62. */
  63. #define SMC37c669_DEVICE_IRQ_MASK 0x80000000
  64. #define SMC37c669_DEVICE_IRQ( __i ) \
  65. ((SMC37c669_DEVICE_IRQ_MASK) | (__i))
  66. #define SMC37c669_IS_DEVICE_IRQ(__i) \
  67. (((__i) & (SMC37c669_DEVICE_IRQ_MASK)) == (SMC37c669_DEVICE_IRQ_MASK))
  68. #define SMC37c669_RAW_DEVICE_IRQ(__i) \
  69. ((__i) & ~(SMC37c669_DEVICE_IRQ_MASK))
  70. /*
  71. ** Macros for handling device DRQs
  72. **
  73. ** The mask acts as a flag used in mapping actual ISA DMA
  74. ** channels to device DMA channels (A - C).
  75. */
  76. #define SMC37c669_DEVICE_DRQ_MASK 0x80000000
  77. #define SMC37c669_DEVICE_DRQ(__d) \
  78. ((SMC37c669_DEVICE_DRQ_MASK) | (__d))
  79. #define SMC37c669_IS_DEVICE_DRQ(__d) \
  80. (((__d) & (SMC37c669_DEVICE_DRQ_MASK)) == (SMC37c669_DEVICE_DRQ_MASK))
  81. #define SMC37c669_RAW_DEVICE_DRQ(__d) \
  82. ((__d) & ~(SMC37c669_DEVICE_DRQ_MASK))
  83. #define SMC37c669_DEVICE_ID 0x3
  84. /*
  85. ** SMC37c669 Device Function Definitions
  86. */
  87. #define SERIAL_0 0
  88. #define SERIAL_1 1
  89. #define PARALLEL_0 2
  90. #define FLOPPY_0 3
  91. #define IDE_0 4
  92. #define NUM_FUNCS 5
  93. /*
  94. ** Default Device Function Mappings
  95. */
  96. #define COM1_BASE 0x3F8
  97. #define COM1_IRQ 4
  98. #define COM2_BASE 0x2F8
  99. #define COM2_IRQ 3
  100. #define PARP_BASE 0x3BC
  101. #define PARP_IRQ 7
  102. #define PARP_DRQ 3
  103. #define FDC_BASE 0x3F0
  104. #define FDC_IRQ 6
  105. #define FDC_DRQ 2
  106. /*
  107. ** Configuration On/Off Key Definitions
  108. */
  109. #define SMC37c669_CONFIG_ON_KEY 0x55
  110. #define SMC37c669_CONFIG_OFF_KEY 0xAA
  111. /*
  112. ** SMC 37c669 Device IRQs
  113. */
  114. #define SMC37c669_DEVICE_IRQ_A ( SMC37c669_DEVICE_IRQ( 0x01 ) )
  115. #define SMC37c669_DEVICE_IRQ_B ( SMC37c669_DEVICE_IRQ( 0x02 ) )
  116. #define SMC37c669_DEVICE_IRQ_C ( SMC37c669_DEVICE_IRQ( 0x03 ) )
  117. #define SMC37c669_DEVICE_IRQ_D ( SMC37c669_DEVICE_IRQ( 0x04 ) )
  118. #define SMC37c669_DEVICE_IRQ_E ( SMC37c669_DEVICE_IRQ( 0x05 ) )
  119. #define SMC37c669_DEVICE_IRQ_F ( SMC37c669_DEVICE_IRQ( 0x06 ) )
  120. /* SMC37c669_DEVICE_IRQ_G *** RESERVED ***/
  121. #define SMC37c669_DEVICE_IRQ_H ( SMC37c669_DEVICE_IRQ( 0x08 ) )
  122. /*
  123. ** SMC 37c669 Device DMA Channel Definitions
  124. */
  125. #define SMC37c669_DEVICE_DRQ_A ( SMC37c669_DEVICE_DRQ( 0x01 ) )
  126. #define SMC37c669_DEVICE_DRQ_B ( SMC37c669_DEVICE_DRQ( 0x02 ) )
  127. #define SMC37c669_DEVICE_DRQ_C ( SMC37c669_DEVICE_DRQ( 0x03 ) )
  128. /*
  129. ** Configuration Register Index Definitions
  130. */
  131. #define SMC37c669_CR00_INDEX 0x00
  132. #define SMC37c669_CR01_INDEX 0x01
  133. #define SMC37c669_CR02_INDEX 0x02
  134. #define SMC37c669_CR03_INDEX 0x03
  135. #define SMC37c669_CR04_INDEX 0x04
  136. #define SMC37c669_CR05_INDEX 0x05
  137. #define SMC37c669_CR06_INDEX 0x06
  138. #define SMC37c669_CR07_INDEX 0x07
  139. #define SMC37c669_CR08_INDEX 0x08
  140. #define SMC37c669_CR09_INDEX 0x09
  141. #define SMC37c669_CR0A_INDEX 0x0A
  142. #define SMC37c669_CR0B_INDEX 0x0B
  143. #define SMC37c669_CR0C_INDEX 0x0C
  144. #define SMC37c669_CR0D_INDEX 0x0D
  145. #define SMC37c669_CR0E_INDEX 0x0E
  146. #define SMC37c669_CR0F_INDEX 0x0F
  147. #define SMC37c669_CR10_INDEX 0x10
  148. #define SMC37c669_CR11_INDEX 0x11
  149. #define SMC37c669_CR12_INDEX 0x12
  150. #define SMC37c669_CR13_INDEX 0x13
  151. #define SMC37c669_CR14_INDEX 0x14
  152. #define SMC37c669_CR15_INDEX 0x15
  153. #define SMC37c669_CR16_INDEX 0x16
  154. #define SMC37c669_CR17_INDEX 0x17
  155. #define SMC37c669_CR18_INDEX 0x18
  156. #define SMC37c669_CR19_INDEX 0x19
  157. #define SMC37c669_CR1A_INDEX 0x1A
  158. #define SMC37c669_CR1B_INDEX 0x1B
  159. #define SMC37c669_CR1C_INDEX 0x1C
  160. #define SMC37c669_CR1D_INDEX 0x1D
  161. #define SMC37c669_CR1E_INDEX 0x1E
  162. #define SMC37c669_CR1F_INDEX 0x1F
  163. #define SMC37c669_CR20_INDEX 0x20
  164. #define SMC37c669_CR21_INDEX 0x21
  165. #define SMC37c669_CR22_INDEX 0x22
  166. #define SMC37c669_CR23_INDEX 0x23
  167. #define SMC37c669_CR24_INDEX 0x24
  168. #define SMC37c669_CR25_INDEX 0x25
  169. #define SMC37c669_CR26_INDEX 0x26
  170. #define SMC37c669_CR27_INDEX 0x27
  171. #define SMC37c669_CR28_INDEX 0x28
  172. #define SMC37c669_CR29_INDEX 0x29
  173. /*
  174. ** Configuration Register Alias Definitions
  175. */
  176. #define SMC37c669_DEVICE_ID_INDEX SMC37c669_CR0D_INDEX
  177. #define SMC37c669_DEVICE_REVISION_INDEX SMC37c669_CR0E_INDEX
  178. #define SMC37c669_FDC_BASE_ADDRESS_INDEX SMC37c669_CR20_INDEX
  179. #define SMC37c669_IDE_BASE_ADDRESS_INDEX SMC37c669_CR21_INDEX
  180. #define SMC37c669_IDE_ALTERNATE_ADDRESS_INDEX SMC37c669_CR22_INDEX
  181. #define SMC37c669_PARALLEL0_BASE_ADDRESS_INDEX SMC37c669_CR23_INDEX
  182. #define SMC37c669_SERIAL0_BASE_ADDRESS_INDEX SMC37c669_CR24_INDEX
  183. #define SMC37c669_SERIAL1_BASE_ADDRESS_INDEX SMC37c669_CR25_INDEX
  184. #define SMC37c669_PARALLEL_FDC_DRQ_INDEX SMC37c669_CR26_INDEX
  185. #define SMC37c669_PARALLEL_FDC_IRQ_INDEX SMC37c669_CR27_INDEX
  186. #define SMC37c669_SERIAL_IRQ_INDEX SMC37c669_CR28_INDEX
  187. /*
  188. ** Configuration Register Definitions
  189. **
  190. ** The INDEX (write only) and DATA (read/write) ports are effective
  191. ** only when the chip is in the Configuration State.
  192. */
  193. typedef struct _SMC37c669_CONFIG_REGS {
  194. unsigned char index_port;
  195. unsigned char data_port;
  196. } SMC37c669_CONFIG_REGS;
  197. /*
  198. ** CR00 - default value 0x28
  199. **
  200. ** IDE_EN (CR00<1:0>):
  201. ** 0x - 30ua pull-ups on nIDEEN, nHDCS0, NHDCS1
  202. ** 11 - IRQ_H available as IRQ output,
  203. ** IRRX2, IRTX2 available as alternate IR pins
  204. ** 10 - nIDEEN, nHDCS0, nHDCS1 used to control IDE
  205. **
  206. ** VALID (CR00<7>):
  207. ** A high level on this software controlled bit can
  208. ** be used to indicate that a valid configuration
  209. ** cycle has occurred. The control software must
  210. ** take care to set this bit at the appropriate times.
  211. ** Set to zero after power up. This bit has no
  212. ** effect on any other hardware in the chip.
  213. **
  214. */
  215. typedef union _SMC37c669_CR00 {
  216. unsigned char as_uchar;
  217. struct {
  218. unsigned ide_en : 2; /* See note above */
  219. unsigned reserved1 : 1; /* RAZ */
  220. unsigned fdc_pwr : 1; /* 1 = supply power to FDC */
  221. unsigned reserved2 : 3; /* Read as 010b */
  222. unsigned valid : 1; /* See note above */
  223. } by_field;
  224. } SMC37c669_CR00;
  225. /*
  226. ** CR01 - default value 0x9C
  227. */
  228. typedef union _SMC37c669_CR01 {
  229. unsigned char as_uchar;
  230. struct {
  231. unsigned reserved1 : 2; /* RAZ */
  232. unsigned ppt_pwr : 1; /* 1 = supply power to PPT */
  233. unsigned ppt_mode : 1; /* 1 = Printer mode, 0 = EPP */
  234. unsigned reserved2 : 1; /* Read as 1 */
  235. unsigned reserved3 : 2; /* RAZ */
  236. unsigned lock_crx: 1; /* Lock CR00 - CR18 */
  237. } by_field;
  238. } SMC37c669_CR01;
  239. /*
  240. ** CR02 - default value 0x88
  241. */
  242. typedef union _SMC37c669_CR02 {
  243. unsigned char as_uchar;
  244. struct {
  245. unsigned reserved1 : 3; /* RAZ */
  246. unsigned uart1_pwr : 1; /* 1 = supply power to UART1 */
  247. unsigned reserved2 : 3; /* RAZ */
  248. unsigned uart2_pwr : 1; /* 1 = supply power to UART2 */
  249. } by_field;
  250. } SMC37c669_CR02;
  251. /*
  252. ** CR03 - default value 0x78
  253. **
  254. ** CR03<7> CR03<2> Pin 94
  255. ** ------- ------- ------
  256. ** 0 X DRV2 (input)
  257. ** 1 0 ADRX
  258. ** 1 1 IRQ_B
  259. **
  260. ** CR03<6> CR03<5> Op Mode
  261. ** ------- ------- -------
  262. ** 0 0 Model 30
  263. ** 0 1 PS/2
  264. ** 1 0 Reserved
  265. ** 1 1 AT Mode
  266. */
  267. typedef union _SMC37c669_CR03 {
  268. unsigned char as_uchar;
  269. struct {
  270. unsigned pwrgd_gamecs : 1; /* 1 = PWRGD, 0 = GAMECS */
  271. unsigned fdc_mode2 : 1; /* 1 = Enhanced Mode 2 */
  272. unsigned pin94_0 : 1; /* See note above */
  273. unsigned reserved1 : 1; /* RAZ */
  274. unsigned drvden : 1; /* 1 = high, 0 - output */
  275. unsigned op_mode : 2; /* See note above */
  276. unsigned pin94_1 : 1; /* See note above */
  277. } by_field;
  278. } SMC37c669_CR03;
  279. /*
  280. ** CR04 - default value 0x00
  281. **
  282. ** PP_EXT_MODE:
  283. ** If CR01<PP_MODE> = 0 and PP_EXT_MODE =
  284. ** 00 - Standard and Bidirectional
  285. ** 01 - EPP mode and SPP
  286. ** 10 - ECP mode
  287. ** In this mode, 2 drives can be supported
  288. ** directly, 3 or 4 drives must use external
  289. ** 4 drive support. SPP can be selected
  290. ** through the ECR register of ECP as mode 000.
  291. ** 11 - ECP mode and EPP mode
  292. ** In this mode, 2 drives can be supported
  293. ** directly, 3 or 4 drives must use external
  294. ** 4 drive support. SPP can be selected
  295. ** through the ECR register of ECP as mode 000.
  296. ** In this mode, EPP can be selected through
  297. ** the ECR register of ECP as mode 100.
  298. **
  299. ** PP_FDC:
  300. ** 00 - Normal
  301. ** 01 - PPFD1
  302. ** 10 - PPFD2
  303. ** 11 - Reserved
  304. **
  305. ** MIDI1:
  306. ** Serial Clock Select:
  307. ** A low level on this bit disables MIDI support,
  308. ** clock = divide by 13. A high level on this
  309. ** bit enables MIDI support, clock = divide by 12.
  310. **
  311. ** MIDI operates at 31.25 Kbps which can be derived
  312. ** from 125 KHz (24 MHz / 12 = 2 MHz, 2 MHz / 16 = 125 KHz)
  313. **
  314. ** ALT_IO:
  315. ** 0 - Use pins IRRX, IRTX
  316. ** 1 - Use pins IRRX2, IRTX2
  317. **
  318. ** If this bit is set, the IR receive and transmit
  319. ** functions will not be available on pins 25 and 26
  320. ** unless CR00<IDE_EN> = 11.
  321. */
  322. typedef union _SMC37c669_CR04 {
  323. unsigned char as_uchar;
  324. struct {
  325. unsigned ppt_ext_mode : 2; /* See note above */
  326. unsigned ppt_fdc : 2; /* See note above */
  327. unsigned midi1 : 1; /* See note above */
  328. unsigned midi2 : 1; /* See note above */
  329. unsigned epp_type : 1; /* 0 = EPP 1.9, 1 = EPP 1.7 */
  330. unsigned alt_io : 1; /* See note above */
  331. } by_field;
  332. } SMC37c669_CR04;
  333. /*
  334. ** CR05 - default value 0x00
  335. **
  336. ** DEN_SEL:
  337. ** 00 - Densel output normal
  338. ** 01 - Reserved
  339. ** 10 - Densel output 1
  340. ** 11 - Densel output 0
  341. **
  342. */
  343. typedef union _SMC37c669_CR05 {
  344. unsigned char as_uchar;
  345. struct {
  346. unsigned reserved1 : 2; /* RAZ */
  347. unsigned fdc_dma_mode : 1; /* 0 = burst, 1 = non-burst */
  348. unsigned den_sel : 2; /* See note above */
  349. unsigned swap_drv : 1; /* Swap the FDC motor selects */
  350. unsigned extx4 : 1; /* 0 = 2 drive, 1 = external 4 drive decode */
  351. unsigned reserved2 : 1; /* RAZ */
  352. } by_field;
  353. } SMC37c669_CR05;
  354. /*
  355. ** CR06 - default value 0xFF
  356. */
  357. typedef union _SMC37c669_CR06 {
  358. unsigned char as_uchar;
  359. struct {
  360. unsigned floppy_a : 2; /* Type of floppy drive A */
  361. unsigned floppy_b : 2; /* Type of floppy drive B */
  362. unsigned floppy_c : 2; /* Type of floppy drive C */
  363. unsigned floppy_d : 2; /* Type of floppy drive D */
  364. } by_field;
  365. } SMC37c669_CR06;
  366. /*
  367. ** CR07 - default value 0x00
  368. **
  369. ** Auto Power Management CR07<7:4>:
  370. ** 0 - Auto Powerdown disabled (default)
  371. ** 1 - Auto Powerdown enabled
  372. **
  373. ** This bit is reset to the default state by POR or
  374. ** a hardware reset.
  375. **
  376. */
  377. typedef union _SMC37c669_CR07 {
  378. unsigned char as_uchar;
  379. struct {
  380. unsigned floppy_boot : 2; /* 0 = A:, 1 = B: */
  381. unsigned reserved1 : 2; /* RAZ */
  382. unsigned ppt_en : 1; /* See note above */
  383. unsigned uart1_en : 1; /* See note above */
  384. unsigned uart2_en : 1; /* See note above */
  385. unsigned fdc_en : 1; /* See note above */
  386. } by_field;
  387. } SMC37c669_CR07;
  388. /*
  389. ** CR08 - default value 0x00
  390. */
  391. typedef union _SMC37c669_CR08 {
  392. unsigned char as_uchar;
  393. struct {
  394. unsigned zero : 4; /* 0 */
  395. unsigned addrx7_4 : 4; /* ADR<7:3> for ADRx decode */
  396. } by_field;
  397. } SMC37c669_CR08;
  398. /*
  399. ** CR09 - default value 0x00
  400. **
  401. ** ADRx_CONFIG:
  402. ** 00 - ADRx disabled
  403. ** 01 - 1 byte decode A<3:0> = 0000b
  404. ** 10 - 8 byte block decode A<3:0> = 0XXXb
  405. ** 11 - 16 byte block decode A<3:0> = XXXXb
  406. **
  407. */
  408. typedef union _SMC37c669_CR09 {
  409. unsigned char as_uchar;
  410. struct {
  411. unsigned adra8 : 3; /* ADR<10:8> for ADRx decode */
  412. unsigned reserved1 : 3;
  413. unsigned adrx_config : 2; /* See note above */
  414. } by_field;
  415. } SMC37c669_CR09;
  416. /*
  417. ** CR0A - default value 0x00
  418. */
  419. typedef union _SMC37c669_CR0A {
  420. unsigned char as_uchar;
  421. struct {
  422. unsigned ecp_fifo_threshold : 4;
  423. unsigned reserved1 : 4;
  424. } by_field;
  425. } SMC37c669_CR0A;
  426. /*
  427. ** CR0B - default value 0x00
  428. */
  429. typedef union _SMC37c669_CR0B {
  430. unsigned char as_uchar;
  431. struct {
  432. unsigned fdd0_drtx : 2; /* FDD0 Data Rate Table */
  433. unsigned fdd1_drtx : 2; /* FDD1 Data Rate Table */
  434. unsigned fdd2_drtx : 2; /* FDD2 Data Rate Table */
  435. unsigned fdd3_drtx : 2; /* FDD3 Data Rate Table */
  436. } by_field;
  437. } SMC37c669_CR0B;
  438. /*
  439. ** CR0C - default value 0x00
  440. **
  441. ** UART2_MODE:
  442. ** 000 - Standard (default)
  443. ** 001 - IrDA (HPSIR)
  444. ** 010 - Amplitude Shift Keyed IR @500 KHz
  445. ** 011 - Reserved
  446. ** 1xx - Reserved
  447. **
  448. */
  449. typedef union _SMC37c669_CR0C {
  450. unsigned char as_uchar;
  451. struct {
  452. unsigned uart2_rcv_polarity : 1; /* 1 = invert RX */
  453. unsigned uart2_xmit_polarity : 1; /* 1 = invert TX */
  454. unsigned uart2_duplex : 1; /* 1 = full, 0 = half */
  455. unsigned uart2_mode : 3; /* See note above */
  456. unsigned uart1_speed : 1; /* 1 = high speed enabled */
  457. unsigned uart2_speed : 1; /* 1 = high speed enabled */
  458. } by_field;
  459. } SMC37c669_CR0C;
  460. /*
  461. ** CR0D - default value 0x03
  462. **
  463. ** Device ID Register - read only
  464. */
  465. typedef union _SMC37c669_CR0D {
  466. unsigned char as_uchar;
  467. struct {
  468. unsigned device_id : 8; /* Returns 0x3 in this field */
  469. } by_field;
  470. } SMC37c669_CR0D;
  471. /*
  472. ** CR0E - default value 0x02
  473. **
  474. ** Device Revision Register - read only
  475. */
  476. typedef union _SMC37c669_CR0E {
  477. unsigned char as_uchar;
  478. struct {
  479. unsigned device_rev : 8; /* Returns 0x2 in this field */
  480. } by_field;
  481. } SMC37c669_CR0E;
  482. /*
  483. ** CR0F - default value 0x00
  484. */
  485. typedef union _SMC37c669_CR0F {
  486. unsigned char as_uchar;
  487. struct {
  488. unsigned test0 : 1; /* Reserved - set to 0 */
  489. unsigned test1 : 1; /* Reserved - set to 0 */
  490. unsigned test2 : 1; /* Reserved - set to 0 */
  491. unsigned test3 : 1; /* Reserved - set t0 0 */
  492. unsigned test4 : 1; /* Reserved - set to 0 */
  493. unsigned test5 : 1; /* Reserved - set t0 0 */
  494. unsigned test6 : 1; /* Reserved - set t0 0 */
  495. unsigned test7 : 1; /* Reserved - set to 0 */
  496. } by_field;
  497. } SMC37c669_CR0F;
  498. /*
  499. ** CR10 - default value 0x00
  500. */
  501. typedef union _SMC37c669_CR10 {
  502. unsigned char as_uchar;
  503. struct {
  504. unsigned reserved1 : 3; /* RAZ */
  505. unsigned pll_gain : 1; /* 1 = 3V, 2 = 5V operation */
  506. unsigned pll_stop : 1; /* 1 = stop PLLs */
  507. unsigned ace_stop : 1; /* 1 = stop UART clocks */
  508. unsigned pll_clock_ctrl : 1; /* 0 = 14.318 MHz, 1 = 24 MHz */
  509. unsigned ir_test : 1; /* Enable IR test mode */
  510. } by_field;
  511. } SMC37c669_CR10;
  512. /*
  513. ** CR11 - default value 0x00
  514. */
  515. typedef union _SMC37c669_CR11 {
  516. unsigned char as_uchar;
  517. struct {
  518. unsigned ir_loopback : 1; /* Internal IR loop back */
  519. unsigned test_10ms : 1; /* Test 10ms autopowerdown FDC timeout */
  520. unsigned reserved1 : 6; /* RAZ */
  521. } by_field;
  522. } SMC37c669_CR11;
  523. /*
  524. ** CR12 - CR1D are reserved registers
  525. */
  526. /*
  527. ** CR1E - default value 0x80
  528. **
  529. ** GAMECS:
  530. ** 00 - GAMECS disabled
  531. ** 01 - 1 byte decode ADR<3:0> = 0001b
  532. ** 10 - 8 byte block decode ADR<3:0> = 0XXXb
  533. ** 11 - 16 byte block decode ADR<3:0> = XXXXb
  534. **
  535. */
  536. typedef union _SMC37c66_CR1E {
  537. unsigned char as_uchar;
  538. struct {
  539. unsigned gamecs_config: 2; /* See note above */
  540. unsigned gamecs_addr9_4 : 6; /* GAMECS Addr<9:4> */
  541. } by_field;
  542. } SMC37c669_CR1E;
  543. /*
  544. ** CR1F - default value 0x00
  545. **
  546. ** DT0 DT1 DRVDEN0 DRVDEN1 Drive Type
  547. ** --- --- ------- ------- ----------
  548. ** 0 0 DENSEL DRATE0 4/2/1 MB 3.5"
  549. ** 2/1 MB 5.25"
  550. ** 2/1.6/1 MB 3.5" (3-mode)
  551. ** 0 1 DRATE1 DRATE0
  552. ** 1 0 nDENSEL DRATE0 PS/2
  553. ** 1 1 DRATE0 DRATE1
  554. **
  555. ** Note: DENSEL, DRATE1, and DRATE0 map onto two output
  556. ** pins - DRVDEN0 and DRVDEN1.
  557. **
  558. */
  559. typedef union _SMC37c669_CR1F {
  560. unsigned char as_uchar;
  561. struct {
  562. unsigned fdd0_drive_type : 2; /* FDD0 drive type */
  563. unsigned fdd1_drive_type : 2; /* FDD1 drive type */
  564. unsigned fdd2_drive_type : 2; /* FDD2 drive type */
  565. unsigned fdd3_drive_type : 2; /* FDD3 drive type */
  566. } by_field;
  567. } SMC37c669_CR1F;
  568. /*
  569. ** CR20 - default value 0x3C
  570. **
  571. ** FDC Base Address Register
  572. ** - To disable this decode set Addr<9:8> = 0
  573. ** - A<10> = 0, A<3:0> = 0XXXb to access.
  574. **
  575. */
  576. typedef union _SMC37c669_CR20 {
  577. unsigned char as_uchar;
  578. struct {
  579. unsigned zero : 2; /* 0 */
  580. unsigned addr9_4 : 6; /* FDC Addr<9:4> */
  581. } by_field;
  582. } SMC37c669_CR20;
  583. /*
  584. ** CR21 - default value 0x3C
  585. **
  586. ** IDE Base Address Register
  587. ** - To disable this decode set Addr<9:8> = 0
  588. ** - A<10> = 0, A<3:0> = 0XXXb to access.
  589. **
  590. */
  591. typedef union _SMC37c669_CR21 {
  592. unsigned char as_uchar;
  593. struct {
  594. unsigned zero : 2; /* 0 */
  595. unsigned addr9_4 : 6; /* IDE Addr<9:4> */
  596. } by_field;
  597. } SMC37c669_CR21;
  598. /*
  599. ** CR22 - default value 0x3D
  600. **
  601. ** IDE Alternate Status Base Address Register
  602. ** - To disable this decode set Addr<9:8> = 0
  603. ** - A<10> = 0, A<3:0> = 0110b to access.
  604. **
  605. */
  606. typedef union _SMC37c669_CR22 {
  607. unsigned char as_uchar;
  608. struct {
  609. unsigned zero : 2; /* 0 */
  610. unsigned addr9_4 : 6; /* IDE Alt Status Addr<9:4> */
  611. } by_field;
  612. } SMC37c669_CR22;
  613. /*
  614. ** CR23 - default value 0x00
  615. **
  616. ** Parallel Port Base Address Register
  617. ** - To disable this decode set Addr<9:8> = 0
  618. ** - A<10> = 0 to access.
  619. ** - If EPP is enabled, A<2:0> = XXXb to access.
  620. ** If EPP is NOT enabled, A<1:0> = XXb to access
  621. **
  622. */
  623. typedef union _SMC37c669_CR23 {
  624. unsigned char as_uchar;
  625. struct {
  626. unsigned addr9_2 : 8; /* Parallel Port Addr<9:2> */
  627. } by_field;
  628. } SMC37c669_CR23;
  629. /*
  630. ** CR24 - default value 0x00
  631. **
  632. ** UART1 Base Address Register
  633. ** - To disable this decode set Addr<9:8> = 0
  634. ** - A<10> = 0, A<2:0> = XXXb to access.
  635. **
  636. */
  637. typedef union _SMC37c669_CR24 {
  638. unsigned char as_uchar;
  639. struct {
  640. unsigned zero : 1; /* 0 */
  641. unsigned addr9_3 : 7; /* UART1 Addr<9:3> */
  642. } by_field;
  643. } SMC37c669_CR24;
  644. /*
  645. ** CR25 - default value 0x00
  646. **
  647. ** UART2 Base Address Register
  648. ** - To disable this decode set Addr<9:8> = 0
  649. ** - A<10> = 0, A<2:0> = XXXb to access.
  650. **
  651. */
  652. typedef union _SMC37c669_CR25 {
  653. unsigned char as_uchar;
  654. struct {
  655. unsigned zero : 1; /* 0 */
  656. unsigned addr9_3 : 7; /* UART2 Addr<9:3> */
  657. } by_field;
  658. } SMC37c669_CR25;
  659. /*
  660. ** CR26 - default value 0x00
  661. **
  662. ** Parallel Port / FDC DMA Select Register
  663. **
  664. ** D3 - D0 DMA
  665. ** D7 - D4 Selected
  666. ** ------- --------
  667. ** 0000 None
  668. ** 0001 DMA_A
  669. ** 0010 DMA_B
  670. ** 0011 DMA_C
  671. **
  672. */
  673. typedef union _SMC37c669_CR26 {
  674. unsigned char as_uchar;
  675. struct {
  676. unsigned ppt_drq : 4; /* See note above */
  677. unsigned fdc_drq : 4; /* See note above */
  678. } by_field;
  679. } SMC37c669_CR26;
  680. /*
  681. ** CR27 - default value 0x00
  682. **
  683. ** Parallel Port / FDC IRQ Select Register
  684. **
  685. ** D3 - D0 IRQ
  686. ** D7 - D4 Selected
  687. ** ------- --------
  688. ** 0000 None
  689. ** 0001 IRQ_A
  690. ** 0010 IRQ_B
  691. ** 0011 IRQ_C
  692. ** 0100 IRQ_D
  693. ** 0101 IRQ_E
  694. ** 0110 IRQ_F
  695. ** 0111 Reserved
  696. ** 1000 IRQ_H
  697. **
  698. ** Any unselected IRQ REQ is in tristate
  699. **
  700. */
  701. typedef union _SMC37c669_CR27 {
  702. unsigned char as_uchar;
  703. struct {
  704. unsigned ppt_irq : 4; /* See note above */
  705. unsigned fdc_irq : 4; /* See note above */
  706. } by_field;
  707. } SMC37c669_CR27;
  708. /*
  709. ** CR28 - default value 0x00
  710. **
  711. ** UART IRQ Select Register
  712. **
  713. ** D3 - D0 IRQ
  714. ** D7 - D4 Selected
  715. ** ------- --------
  716. ** 0000 None
  717. ** 0001 IRQ_A
  718. ** 0010 IRQ_B
  719. ** 0011 IRQ_C
  720. ** 0100 IRQ_D
  721. ** 0101 IRQ_E
  722. ** 0110 IRQ_F
  723. ** 0111 Reserved
  724. ** 1000 IRQ_H
  725. ** 1111 share with UART1 (only for UART2)
  726. **
  727. ** Any unselected IRQ REQ is in tristate
  728. **
  729. ** To share an IRQ between UART1 and UART2, set
  730. ** UART1 to use the desired IRQ and set UART2 to
  731. ** 0xF to enable sharing mechanism.
  732. **
  733. */
  734. typedef union _SMC37c669_CR28 {
  735. unsigned char as_uchar;
  736. struct {
  737. unsigned uart2_irq : 4; /* See note above */
  738. unsigned uart1_irq : 4; /* See note above */
  739. } by_field;
  740. } SMC37c669_CR28;
  741. /*
  742. ** CR29 - default value 0x00
  743. **
  744. ** IRQIN IRQ Select Register
  745. **
  746. ** D3 - D0 IRQ
  747. ** D7 - D4 Selected
  748. ** ------- --------
  749. ** 0000 None
  750. ** 0001 IRQ_A
  751. ** 0010 IRQ_B
  752. ** 0011 IRQ_C
  753. ** 0100 IRQ_D
  754. ** 0101 IRQ_E
  755. ** 0110 IRQ_F
  756. ** 0111 Reserved
  757. ** 1000 IRQ_H
  758. **
  759. ** Any unselected IRQ REQ is in tristate
  760. **
  761. */
  762. typedef union _SMC37c669_CR29 {
  763. unsigned char as_uchar;
  764. struct {
  765. unsigned irqin_irq : 4; /* See note above */
  766. unsigned reserved1 : 4; /* RAZ */
  767. } by_field;
  768. } SMC37c669_CR29;
  769. /*
  770. ** Aliases of Configuration Register formats (should match
  771. ** the set of index aliases).
  772. **
  773. ** Note that CR24 and CR25 have the same format and are the
  774. ** base address registers for UART1 and UART2. Because of
  775. ** this we only define 1 alias here - for CR24 - as the serial
  776. ** base address register.
  777. **
  778. ** Note that CR21 and CR22 have the same format and are the
  779. ** base address and alternate status address registers for
  780. ** the IDE controller. Because of this we only define 1 alias
  781. ** here - for CR21 - as the IDE address register.
  782. **
  783. */
  784. typedef SMC37c669_CR0D SMC37c669_DEVICE_ID_REGISTER;
  785. typedef SMC37c669_CR0E SMC37c669_DEVICE_REVISION_REGISTER;
  786. typedef SMC37c669_CR20 SMC37c669_FDC_BASE_ADDRESS_REGISTER;
  787. typedef SMC37c669_CR21 SMC37c669_IDE_ADDRESS_REGISTER;
  788. typedef SMC37c669_CR23 SMC37c669_PARALLEL_BASE_ADDRESS_REGISTER;
  789. typedef SMC37c669_CR24 SMC37c669_SERIAL_BASE_ADDRESS_REGISTER;
  790. typedef SMC37c669_CR26 SMC37c669_PARALLEL_FDC_DRQ_REGISTER;
  791. typedef SMC37c669_CR27 SMC37c669_PARALLEL_FDC_IRQ_REGISTER;
  792. typedef SMC37c669_CR28 SMC37c669_SERIAL_IRQ_REGISTER;
  793. /*
  794. ** ISA/Device IRQ Translation Table Entry Definition
  795. */
  796. typedef struct _SMC37c669_IRQ_TRANSLATION_ENTRY {
  797. int device_irq;
  798. int isa_irq;
  799. } SMC37c669_IRQ_TRANSLATION_ENTRY;
  800. /*
  801. ** ISA/Device DMA Translation Table Entry Definition
  802. */
  803. typedef struct _SMC37c669_DRQ_TRANSLATION_ENTRY {
  804. int device_drq;
  805. int isa_drq;
  806. } SMC37c669_DRQ_TRANSLATION_ENTRY;
  807. /*
  808. ** External Interface Function Prototype Declarations
  809. */
  810. SMC37c669_CONFIG_REGS *SMC37c669_detect(
  811. int
  812. );
  813. unsigned int SMC37c669_enable_device(
  814. unsigned int func
  815. );
  816. unsigned int SMC37c669_disable_device(
  817. unsigned int func
  818. );
  819. unsigned int SMC37c669_configure_device(
  820. unsigned int func,
  821. int port,
  822. int irq,
  823. int drq
  824. );
  825. void SMC37c669_display_device_info(
  826. void
  827. );
  828. #endif /* __SMC37c669_H */
  829. /* file: smcc669.c
  830. *
  831. * Copyright (C) 1997 by
  832. * Digital Equipment Corporation, Maynard, Massachusetts.
  833. * All rights reserved.
  834. *
  835. * This software is furnished under a license and may be used and copied
  836. * only in accordance of the terms of such license and with the
  837. * inclusion of the above copyright notice. This software or any other
  838. * copies thereof may not be provided or otherwise made available to any
  839. * other person. No title to and ownership of the software is hereby
  840. * transferred.
  841. *
  842. * The information in this software is subject to change without notice
  843. * and should not be construed as a commitment by digital equipment
  844. * corporation.
  845. *
  846. * Digital assumes no responsibility for the use or reliability of its
  847. * software on equipment which is not supplied by digital.
  848. */
  849. /*
  850. *++
  851. * FACILITY:
  852. *
  853. * Alpha SRM Console Firmware
  854. *
  855. * MODULE DESCRIPTION:
  856. *
  857. * SMC37c669 Super I/O controller configuration routines.
  858. *
  859. * AUTHORS:
  860. *
  861. * Eric Rasmussen
  862. *
  863. * CREATION DATE:
  864. *
  865. * 28-Jan-1997
  866. *
  867. * MODIFICATION HISTORY:
  868. *
  869. * er 01-May-1997 Fixed pointer conversion errors in
  870. * SMC37c669_get_device_config().
  871. * er 28-Jan-1997 Initial version.
  872. *
  873. *--
  874. */
  875. #ifndef TRUE
  876. #define TRUE 1
  877. #endif
  878. #ifndef FALSE
  879. #define FALSE 0
  880. #endif
  881. #define wb( _x_, _y_ ) outb( _y_, (unsigned int)((unsigned long)_x_) )
  882. #define rb( _x_ ) inb( (unsigned int)((unsigned long)_x_) )
  883. /*
  884. ** Local storage for device configuration information.
  885. **
  886. ** Since the SMC37c669 does not provide an explicit
  887. ** mechanism for enabling/disabling individual device
  888. ** functions, other than unmapping the device, local
  889. ** storage for device configuration information is
  890. ** allocated here for use in implementing our own
  891. ** function enable/disable scheme.
  892. */
  893. static struct DEVICE_CONFIG {
  894. unsigned int port1;
  895. unsigned int port2;
  896. int irq;
  897. int drq;
  898. } local_config [NUM_FUNCS];
  899. /*
  900. ** List of all possible addresses for the Super I/O chip
  901. */
  902. static unsigned long SMC37c669_Addresses[] __initdata =
  903. {
  904. 0x3F0UL, /* Primary address */
  905. 0x370UL, /* Secondary address */
  906. 0UL /* End of list */
  907. };
  908. /*
  909. ** Global Pointer to the Super I/O device
  910. */
  911. static SMC37c669_CONFIG_REGS *SMC37c669 __initdata = NULL;
  912. /*
  913. ** IRQ Translation Table
  914. **
  915. ** The IRQ translation table is a list of SMC37c669 device
  916. ** and standard ISA IRQs.
  917. **
  918. */
  919. static SMC37c669_IRQ_TRANSLATION_ENTRY *SMC37c669_irq_table __initdata;
  920. /*
  921. ** The following definition is for the default IRQ
  922. ** translation table.
  923. */
  924. static SMC37c669_IRQ_TRANSLATION_ENTRY SMC37c669_default_irq_table[]
  925. __initdata =
  926. {
  927. { SMC37c669_DEVICE_IRQ_A, -1 },
  928. { SMC37c669_DEVICE_IRQ_B, -1 },
  929. { SMC37c669_DEVICE_IRQ_C, 7 },
  930. { SMC37c669_DEVICE_IRQ_D, 6 },
  931. { SMC37c669_DEVICE_IRQ_E, 4 },
  932. { SMC37c669_DEVICE_IRQ_F, 3 },
  933. { SMC37c669_DEVICE_IRQ_H, -1 },
  934. { -1, -1 } /* End of table */
  935. };
  936. /*
  937. ** The following definition is for the MONET (XP1000) IRQ
  938. ** translation table.
  939. */
  940. static SMC37c669_IRQ_TRANSLATION_ENTRY SMC37c669_monet_irq_table[]
  941. __initdata =
  942. {
  943. { SMC37c669_DEVICE_IRQ_A, -1 },
  944. { SMC37c669_DEVICE_IRQ_B, -1 },
  945. { SMC37c669_DEVICE_IRQ_C, 6 },
  946. { SMC37c669_DEVICE_IRQ_D, 7 },
  947. { SMC37c669_DEVICE_IRQ_E, 4 },
  948. { SMC37c669_DEVICE_IRQ_F, 3 },
  949. { SMC37c669_DEVICE_IRQ_H, -1 },
  950. { -1, -1 } /* End of table */
  951. };
  952. static SMC37c669_IRQ_TRANSLATION_ENTRY *SMC37c669_irq_tables[] __initdata =
  953. {
  954. SMC37c669_default_irq_table,
  955. SMC37c669_monet_irq_table
  956. };
  957. /*
  958. ** DRQ Translation Table
  959. **
  960. ** The DRQ translation table is a list of SMC37c669 device and
  961. ** ISA DMA channels.
  962. **
  963. */
  964. static SMC37c669_DRQ_TRANSLATION_ENTRY *SMC37c669_drq_table __initdata;
  965. /*
  966. ** The following definition is the default DRQ
  967. ** translation table.
  968. */
  969. static SMC37c669_DRQ_TRANSLATION_ENTRY SMC37c669_default_drq_table[]
  970. __initdata =
  971. {
  972. { SMC37c669_DEVICE_DRQ_A, 2 },
  973. { SMC37c669_DEVICE_DRQ_B, 3 },
  974. { SMC37c669_DEVICE_DRQ_C, -1 },
  975. { -1, -1 } /* End of table */
  976. };
  977. /*
  978. ** Local Function Prototype Declarations
  979. */
  980. static unsigned int SMC37c669_is_device_enabled(
  981. unsigned int func
  982. );
  983. #if 0
  984. static unsigned int SMC37c669_get_device_config(
  985. unsigned int func,
  986. int *port,
  987. int *irq,
  988. int *drq
  989. );
  990. #endif
  991. static void SMC37c669_config_mode(
  992. unsigned int enable
  993. );
  994. static unsigned char SMC37c669_read_config(
  995. unsigned char index
  996. );
  997. static void SMC37c669_write_config(
  998. unsigned char index,
  999. unsigned char data
  1000. );
  1001. static void SMC37c669_init_local_config( void );
  1002. static struct DEVICE_CONFIG *SMC37c669_get_config(
  1003. unsigned int func
  1004. );
  1005. static int SMC37c669_xlate_irq(
  1006. int irq
  1007. );
  1008. static int SMC37c669_xlate_drq(
  1009. int drq
  1010. );
  1011. static __cacheline_aligned DEFINE_SPINLOCK(smc_lock);
  1012. /*
  1013. **++
  1014. ** FUNCTIONAL DESCRIPTION:
  1015. **
  1016. ** This function detects the presence of an SMC37c669 Super I/O
  1017. ** controller.
  1018. **
  1019. ** FORMAL PARAMETERS:
  1020. **
  1021. ** None
  1022. **
  1023. ** RETURN VALUE:
  1024. **
  1025. ** Returns a pointer to the device if found, otherwise,
  1026. ** the NULL pointer is returned.
  1027. **
  1028. ** SIDE EFFECTS:
  1029. **
  1030. ** None
  1031. **
  1032. **--
  1033. */
  1034. SMC37c669_CONFIG_REGS * __init SMC37c669_detect( int index )
  1035. {
  1036. int i;
  1037. SMC37c669_DEVICE_ID_REGISTER id;
  1038. for ( i = 0; SMC37c669_Addresses[i] != 0; i++ ) {
  1039. /*
  1040. ** Initialize the device pointer even though we don't yet know if
  1041. ** the controller is at this address. The support functions access
  1042. ** the controller through this device pointer so we need to set it
  1043. ** even when we are looking ...
  1044. */
  1045. SMC37c669 = ( SMC37c669_CONFIG_REGS * )SMC37c669_Addresses[i];
  1046. /*
  1047. ** Enter configuration mode
  1048. */
  1049. SMC37c669_config_mode( TRUE );
  1050. /*
  1051. ** Read the device id
  1052. */
  1053. id.as_uchar = SMC37c669_read_config( SMC37c669_DEVICE_ID_INDEX );
  1054. /*
  1055. ** Exit configuration mode
  1056. */
  1057. SMC37c669_config_mode( FALSE );
  1058. /*
  1059. ** Does the device id match? If so, assume we have found an
  1060. ** SMC37c669 controller at this address.
  1061. */
  1062. if ( id.by_field.device_id == SMC37c669_DEVICE_ID ) {
  1063. /*
  1064. ** Initialize the IRQ and DRQ translation tables.
  1065. */
  1066. SMC37c669_irq_table = SMC37c669_irq_tables[ index ];
  1067. SMC37c669_drq_table = SMC37c669_default_drq_table;
  1068. /*
  1069. ** erfix
  1070. **
  1071. ** If the platform can't use the IRQ and DRQ defaults set up in this
  1072. ** file, it should call a platform-specific external routine at this
  1073. ** point to reset the IRQ and DRQ translation table pointers to point
  1074. ** at the appropriate tables for the platform. If the defaults are
  1075. ** acceptable, then the external routine should do nothing.
  1076. */
  1077. /*
  1078. ** Put the chip back into configuration mode
  1079. */
  1080. SMC37c669_config_mode( TRUE );
  1081. /*
  1082. ** Initialize local storage for configuration information
  1083. */
  1084. SMC37c669_init_local_config( );
  1085. /*
  1086. ** Exit configuration mode
  1087. */
  1088. SMC37c669_config_mode( FALSE );
  1089. /*
  1090. ** SMC37c669 controller found, break out of search loop
  1091. */
  1092. break;
  1093. }
  1094. else {
  1095. /*
  1096. ** Otherwise, we did not find an SMC37c669 controller at this
  1097. ** address so set the device pointer to NULL.
  1098. */
  1099. SMC37c669 = NULL;
  1100. }
  1101. }
  1102. return SMC37c669;
  1103. }
  1104. /*
  1105. **++
  1106. ** FUNCTIONAL DESCRIPTION:
  1107. **
  1108. ** This function enables an SMC37c669 device function.
  1109. **
  1110. ** FORMAL PARAMETERS:
  1111. **
  1112. ** func:
  1113. ** Which device function to enable
  1114. **
  1115. ** RETURN VALUE:
  1116. **
  1117. ** Returns TRUE is the device function was enabled, otherwise, FALSE
  1118. **
  1119. ** SIDE EFFECTS:
  1120. **
  1121. ** {@description or none@}
  1122. **
  1123. ** DESIGN:
  1124. **
  1125. ** Enabling a device function in the SMC37c669 controller involves
  1126. ** setting all of its mappings (port, irq, drq ...). A local
  1127. ** "shadow" copy of the device configuration is kept so we can
  1128. ** just set each mapping to what the local copy says.
  1129. **
  1130. ** This function ALWAYS updates the local shadow configuration of
  1131. ** the device function being enabled, even if the device is always
  1132. ** enabled. To avoid replication of code, functions such as
  1133. ** configure_device set up the local copy and then call this
  1134. ** function to the update the real device.
  1135. **
  1136. **--
  1137. */
  1138. unsigned int __init SMC37c669_enable_device ( unsigned int func )
  1139. {
  1140. unsigned int ret_val = FALSE;
  1141. /*
  1142. ** Put the device into configuration mode
  1143. */
  1144. SMC37c669_config_mode( TRUE );
  1145. switch ( func ) {
  1146. case SERIAL_0:
  1147. {
  1148. SMC37c669_SERIAL_BASE_ADDRESS_REGISTER base_addr;
  1149. SMC37c669_SERIAL_IRQ_REGISTER irq;
  1150. /*
  1151. ** Enable the serial 1 IRQ mapping
  1152. */
  1153. irq.as_uchar =
  1154. SMC37c669_read_config( SMC37c669_SERIAL_IRQ_INDEX );
  1155. irq.by_field.uart1_irq =
  1156. SMC37c669_RAW_DEVICE_IRQ(
  1157. SMC37c669_xlate_irq( local_config[ func ].irq )
  1158. );
  1159. SMC37c669_write_config( SMC37c669_SERIAL_IRQ_INDEX, irq.as_uchar );
  1160. /*
  1161. ** Enable the serial 1 port base address mapping
  1162. */
  1163. base_addr.as_uchar = 0;
  1164. base_addr.by_field.addr9_3 = local_config[ func ].port1 >> 3;
  1165. SMC37c669_write_config(
  1166. SMC37c669_SERIAL0_BASE_ADDRESS_INDEX,
  1167. base_addr.as_uchar
  1168. );
  1169. ret_val = TRUE;
  1170. break;
  1171. }
  1172. case SERIAL_1:
  1173. {
  1174. SMC37c669_SERIAL_BASE_ADDRESS_REGISTER base_addr;
  1175. SMC37c669_SERIAL_IRQ_REGISTER irq;
  1176. /*
  1177. ** Enable the serial 2 IRQ mapping
  1178. */
  1179. irq.as_uchar =
  1180. SMC37c669_read_config( SMC37c669_SERIAL_IRQ_INDEX );
  1181. irq.by_field.uart2_irq =
  1182. SMC37c669_RAW_DEVICE_IRQ(
  1183. SMC37c669_xlate_irq( local_config[ func ].irq )
  1184. );
  1185. SMC37c669_write_config( SMC37c669_SERIAL_IRQ_INDEX, irq.as_uchar );
  1186. /*
  1187. ** Enable the serial 2 port base address mapping
  1188. */
  1189. base_addr.as_uchar = 0;
  1190. base_addr.by_field.addr9_3 = local_config[ func ].port1 >> 3;
  1191. SMC37c669_write_config(
  1192. SMC37c669_SERIAL1_BASE_ADDRESS_INDEX,
  1193. base_addr.as_uchar
  1194. );
  1195. ret_val = TRUE;
  1196. break;
  1197. }
  1198. case PARALLEL_0:
  1199. {
  1200. SMC37c669_PARALLEL_BASE_ADDRESS_REGISTER base_addr;
  1201. SMC37c669_PARALLEL_FDC_IRQ_REGISTER irq;
  1202. SMC37c669_PARALLEL_FDC_DRQ_REGISTER drq;
  1203. /*
  1204. ** Enable the parallel port DMA channel mapping
  1205. */
  1206. drq.as_uchar =
  1207. SMC37c669_read_config( SMC37c669_PARALLEL_FDC_DRQ_INDEX );
  1208. drq.by_field.ppt_drq =
  1209. SMC37c669_RAW_DEVICE_DRQ(
  1210. SMC37c669_xlate_drq( local_config[ func ].drq )
  1211. );
  1212. SMC37c669_write_config(
  1213. SMC37c669_PARALLEL_FDC_DRQ_INDEX,
  1214. drq.as_uchar
  1215. );
  1216. /*
  1217. ** Enable the parallel port IRQ mapping
  1218. */
  1219. irq.as_uchar =
  1220. SMC37c669_read_config( SMC37c669_PARALLEL_FDC_IRQ_INDEX );
  1221. irq.by_field.ppt_irq =
  1222. SMC37c669_RAW_DEVICE_IRQ(
  1223. SMC37c669_xlate_irq( local_config[ func ].irq )
  1224. );
  1225. SMC37c669_write_config(
  1226. SMC37c669_PARALLEL_FDC_IRQ_INDEX,
  1227. irq.as_uchar
  1228. );
  1229. /*
  1230. ** Enable the parallel port base address mapping
  1231. */
  1232. base_addr.as_uchar = 0;
  1233. base_addr.by_field.addr9_2 = local_config[ func ].port1 >> 2;
  1234. SMC37c669_write_config(
  1235. SMC37c669_PARALLEL0_BASE_ADDRESS_INDEX,
  1236. base_addr.as_uchar
  1237. );
  1238. ret_val = TRUE;
  1239. break;
  1240. }
  1241. case FLOPPY_0:
  1242. {
  1243. SMC37c669_FDC_BASE_ADDRESS_REGISTER base_addr;
  1244. SMC37c669_PARALLEL_FDC_IRQ_REGISTER irq;
  1245. SMC37c669_PARALLEL_FDC_DRQ_REGISTER drq;
  1246. /*
  1247. ** Enable the floppy controller DMA channel mapping
  1248. */
  1249. drq.as_uchar =
  1250. SMC37c669_read_config( SMC37c669_PARALLEL_FDC_DRQ_INDEX );
  1251. drq.by_field.fdc_drq =
  1252. SMC37c669_RAW_DEVICE_DRQ(
  1253. SMC37c669_xlate_drq( local_config[ func ].drq )
  1254. );
  1255. SMC37c669_write_config(
  1256. SMC37c669_PARALLEL_FDC_DRQ_INDEX,
  1257. drq.as_uchar
  1258. );
  1259. /*
  1260. ** Enable the floppy controller IRQ mapping
  1261. */
  1262. irq.as_uchar =
  1263. SMC37c669_read_config( SMC37c669_PARALLEL_FDC_IRQ_INDEX );
  1264. irq.by_field.fdc_irq =
  1265. SMC37c669_RAW_DEVICE_IRQ(
  1266. SMC37c669_xlate_irq( local_config[ func ].irq )
  1267. );
  1268. SMC37c669_write_config(
  1269. SMC37c669_PARALLEL_FDC_IRQ_INDEX,
  1270. irq.as_uchar
  1271. );
  1272. /*
  1273. ** Enable the floppy controller base address mapping
  1274. */
  1275. base_addr.as_uchar = 0;
  1276. base_addr.by_field.addr9_4 = local_config[ func ].port1 >> 4;
  1277. SMC37c669_write_config(
  1278. SMC37c669_FDC_BASE_ADDRESS_INDEX,
  1279. base_addr.as_uchar
  1280. );
  1281. ret_val = TRUE;
  1282. break;
  1283. }
  1284. case IDE_0:
  1285. {
  1286. SMC37c669_IDE_ADDRESS_REGISTER ide_addr;
  1287. /*
  1288. ** Enable the IDE alternate status base address mapping
  1289. */
  1290. ide_addr.as_uchar = 0;
  1291. ide_addr.by_field.addr9_4 = local_config[ func ].port2 >> 4;
  1292. SMC37c669_write_config(
  1293. SMC37c669_IDE_ALTERNATE_ADDRESS_INDEX,
  1294. ide_addr.as_uchar
  1295. );
  1296. /*
  1297. ** Enable the IDE controller base address mapping
  1298. */
  1299. ide_addr.as_uchar = 0;
  1300. ide_addr.by_field.addr9_4 = local_config[ func ].port1 >> 4;
  1301. SMC37c669_write_config(
  1302. SMC37c669_IDE_BASE_ADDRESS_INDEX,
  1303. ide_addr.as_uchar
  1304. );
  1305. ret_val = TRUE;
  1306. break;
  1307. }
  1308. }
  1309. /*
  1310. ** Exit configuration mode and return
  1311. */
  1312. SMC37c669_config_mode( FALSE );
  1313. return ret_val;
  1314. }
  1315. /*
  1316. **++
  1317. ** FUNCTIONAL DESCRIPTION:
  1318. **
  1319. ** This function disables a device function within the
  1320. ** SMC37c669 Super I/O controller.
  1321. **
  1322. ** FORMAL PARAMETERS:
  1323. **
  1324. ** func:
  1325. ** Which function to disable
  1326. **
  1327. ** RETURN VALUE:
  1328. **
  1329. ** Return TRUE if the device function was disabled, otherwise, FALSE
  1330. **
  1331. ** SIDE EFFECTS:
  1332. **
  1333. ** {@description or none@}
  1334. **
  1335. ** DESIGN:
  1336. **
  1337. ** Disabling a function in the SMC37c669 device involves
  1338. ** disabling all the function's mappings (port, irq, drq ...).
  1339. ** A shadow copy of the device configuration is maintained
  1340. ** in local storage so we won't worry aboving saving the
  1341. ** current configuration information.
  1342. **
  1343. **--
  1344. */
  1345. unsigned int __init SMC37c669_disable_device ( unsigned int func )
  1346. {
  1347. unsigned int ret_val = FALSE;
  1348. /*
  1349. ** Put the device into configuration mode
  1350. */
  1351. SMC37c669_config_mode( TRUE );
  1352. switch ( func ) {
  1353. case SERIAL_0:
  1354. {
  1355. SMC37c669_SERIAL_BASE_ADDRESS_REGISTER base_addr;
  1356. SMC37c669_SERIAL_IRQ_REGISTER irq;
  1357. /*
  1358. ** Disable the serial 1 IRQ mapping
  1359. */
  1360. irq.as_uchar =
  1361. SMC37c669_read_config( SMC37c669_SERIAL_IRQ_INDEX );
  1362. irq.by_field.uart1_irq = 0;
  1363. SMC37c669_write_config( SMC37c669_SERIAL_IRQ_INDEX, irq.as_uchar );
  1364. /*
  1365. ** Disable the serial 1 port base address mapping
  1366. */
  1367. base_addr.as_uchar = 0;
  1368. SMC37c669_write_config(
  1369. SMC37c669_SERIAL0_BASE_ADDRESS_INDEX,
  1370. base_addr.as_uchar
  1371. );
  1372. ret_val = TRUE;
  1373. break;
  1374. }
  1375. case SERIAL_1:
  1376. {
  1377. SMC37c669_SERIAL_BASE_ADDRESS_REGISTER base_addr;
  1378. SMC37c669_SERIAL_IRQ_REGISTER irq;
  1379. /*
  1380. ** Disable the serial 2 IRQ mapping
  1381. */
  1382. irq.as_uchar =
  1383. SMC37c669_read_config( SMC37c669_SERIAL_IRQ_INDEX );
  1384. irq.by_field.uart2_irq = 0;
  1385. SMC37c669_write_config( SMC37c669_SERIAL_IRQ_INDEX, irq.as_uchar );
  1386. /*
  1387. ** Disable the serial 2 port base address mapping
  1388. */
  1389. base_addr.as_uchar = 0;
  1390. SMC37c669_write_config(
  1391. SMC37c669_SERIAL1_BASE_ADDRESS_INDEX,
  1392. base_addr.as_uchar
  1393. );
  1394. ret_val = TRUE;
  1395. break;
  1396. }
  1397. case PARALLEL_0:
  1398. {
  1399. SMC37c669_PARALLEL_BASE_ADDRESS_REGISTER base_addr;
  1400. SMC37c669_PARALLEL_FDC_IRQ_REGISTER irq;
  1401. SMC37c669_PARALLEL_FDC_DRQ_REGISTER drq;
  1402. /*
  1403. ** Disable the parallel port DMA channel mapping
  1404. */
  1405. drq.as_uchar =
  1406. SMC37c669_read_config( SMC37c669_PARALLEL_FDC_DRQ_INDEX );
  1407. drq.by_field.ppt_drq = 0;
  1408. SMC37c669_write_config(
  1409. SMC37c669_PARALLEL_FDC_DRQ_INDEX,
  1410. drq.as_uchar
  1411. );
  1412. /*
  1413. ** Disable the parallel port IRQ mapping
  1414. */
  1415. irq.as_uchar =
  1416. SMC37c669_read_config( SMC37c669_PARALLEL_FDC_IRQ_INDEX );
  1417. irq.by_field.ppt_irq = 0;
  1418. SMC37c669_write_config(
  1419. SMC37c669_PARALLEL_FDC_IRQ_INDEX,
  1420. irq.as_uchar
  1421. );
  1422. /*
  1423. ** Disable the parallel port base address mapping
  1424. */
  1425. base_addr.as_uchar = 0;
  1426. SMC37c669_write_config(
  1427. SMC37c669_PARALLEL0_BASE_ADDRESS_INDEX,
  1428. base_addr.as_uchar
  1429. );
  1430. ret_val = TRUE;
  1431. break;
  1432. }
  1433. case FLOPPY_0:
  1434. {
  1435. SMC37c669_FDC_BASE_ADDRESS_REGISTER base_addr;
  1436. SMC37c669_PARALLEL_FDC_IRQ_REGISTER irq;
  1437. SMC37c669_PARALLEL_FDC_DRQ_REGISTER drq;
  1438. /*
  1439. ** Disable the floppy controller DMA channel mapping
  1440. */
  1441. drq.as_uchar =
  1442. SMC37c669_read_config( SMC37c669_PARALLEL_FDC_DRQ_INDEX );
  1443. drq.by_field.fdc_drq = 0;
  1444. SMC37c669_write_config(
  1445. SMC37c669_PARALLEL_FDC_DRQ_INDEX,
  1446. drq.as_uchar
  1447. );
  1448. /*
  1449. ** Disable the floppy controller IRQ mapping
  1450. */
  1451. irq.as_uchar =
  1452. SMC37c669_read_config( SMC37c669_PARALLEL_FDC_IRQ_INDEX );
  1453. irq.by_field.fdc_irq = 0;
  1454. SMC37c669_write_config(
  1455. SMC37c669_PARALLEL_FDC_IRQ_INDEX,
  1456. irq.as_uchar
  1457. );
  1458. /*
  1459. ** Disable the floppy controller base address mapping
  1460. */
  1461. base_addr.as_uchar = 0;
  1462. SMC37c669_write_config(
  1463. SMC37c669_FDC_BASE_ADDRESS_INDEX,
  1464. base_addr.as_uchar
  1465. );
  1466. ret_val = TRUE;
  1467. break;
  1468. }
  1469. case IDE_0:
  1470. {
  1471. SMC37c669_IDE_ADDRESS_REGISTER ide_addr;
  1472. /*
  1473. ** Disable the IDE alternate status base address mapping
  1474. */
  1475. ide_addr.as_uchar = 0;
  1476. SMC37c669_write_config(
  1477. SMC37c669_IDE_ALTERNATE_ADDRESS_INDEX,
  1478. ide_addr.as_uchar
  1479. );
  1480. /*
  1481. ** Disable the IDE controller base address mapping
  1482. */
  1483. ide_addr.as_uchar = 0;
  1484. SMC37c669_write_config(
  1485. SMC37c669_IDE_BASE_ADDRESS_INDEX,
  1486. ide_addr.as_uchar
  1487. );
  1488. ret_val = TRUE;
  1489. break;
  1490. }
  1491. }
  1492. /*
  1493. ** Exit configuration mode and return
  1494. */
  1495. SMC37c669_config_mode( FALSE );
  1496. return ret_val;
  1497. }
  1498. /*
  1499. **++
  1500. ** FUNCTIONAL DESCRIPTION:
  1501. **
  1502. ** This function configures a device function within the
  1503. ** SMC37c669 Super I/O controller.
  1504. **
  1505. ** FORMAL PARAMETERS:
  1506. **
  1507. ** func:
  1508. ** Which device function
  1509. **
  1510. ** port:
  1511. ** I/O port for the function to use
  1512. **
  1513. ** irq:
  1514. ** IRQ for the device function to use
  1515. **
  1516. ** drq:
  1517. ** DMA channel for the device function to use
  1518. **
  1519. ** RETURN VALUE:
  1520. **
  1521. ** Returns TRUE if the device function was configured,
  1522. ** otherwise, FALSE.
  1523. **
  1524. ** SIDE EFFECTS:
  1525. **
  1526. ** {@description or none@}
  1527. **
  1528. ** DESIGN:
  1529. **
  1530. ** If this function returns TRUE, the local shadow copy of
  1531. ** the configuration is also updated. If the device function
  1532. ** is currently disabled, only the local shadow copy is
  1533. ** updated and the actual device function will be updated
  1534. ** if/when it is enabled.
  1535. **
  1536. **--
  1537. */
  1538. unsigned int __init SMC37c669_configure_device (
  1539. unsigned int func,
  1540. int port,
  1541. int irq,
  1542. int drq )
  1543. {
  1544. struct DEVICE_CONFIG *cp;
  1545. /*
  1546. ** Check for a valid configuration
  1547. */
  1548. if ( ( cp = SMC37c669_get_config ( func ) ) != NULL ) {
  1549. /*
  1550. ** Configuration is valid, update the local shadow copy
  1551. */
  1552. if ( ( drq & ~0xFF ) == 0 ) {
  1553. cp->drq = drq;
  1554. }
  1555. if ( ( irq & ~0xFF ) == 0 ) {
  1556. cp->irq = irq;
  1557. }
  1558. if ( ( port & ~0xFFFF ) == 0 ) {
  1559. cp->port1 = port;
  1560. }
  1561. /*
  1562. ** If the device function is enabled, update the actual
  1563. ** device configuration.
  1564. */
  1565. if ( SMC37c669_is_device_enabled( func ) ) {
  1566. SMC37c669_enable_device( func );
  1567. }
  1568. return TRUE;
  1569. }
  1570. return FALSE;
  1571. }
  1572. /*
  1573. **++
  1574. ** FUNCTIONAL DESCRIPTION:
  1575. **
  1576. ** This function determines whether a device function
  1577. ** within the SMC37c669 controller is enabled.
  1578. **
  1579. ** FORMAL PARAMETERS:
  1580. **
  1581. ** func:
  1582. ** Which device function
  1583. **
  1584. ** RETURN VALUE:
  1585. **
  1586. ** Returns TRUE if the device function is enabled, otherwise, FALSE
  1587. **
  1588. ** SIDE EFFECTS:
  1589. **
  1590. ** {@description or none@}
  1591. **
  1592. ** DESIGN:
  1593. **
  1594. ** To check whether a device is enabled we will only look at
  1595. ** the port base address mapping. According to the SMC37c669
  1596. ** specification, all of the port base address mappings are
  1597. ** disabled if the addr<9:8> (bits <7:6> of the register) are
  1598. ** zero.
  1599. **
  1600. **--
  1601. */
  1602. static unsigned int __init SMC37c669_is_device_enabled ( unsigned int func )
  1603. {
  1604. unsigned char base_addr = 0;
  1605. unsigned int dev_ok = FALSE;
  1606. unsigned int ret_val = FALSE;
  1607. /*
  1608. ** Enter configuration mode
  1609. */
  1610. SMC37c669_config_mode( TRUE );
  1611. switch ( func ) {
  1612. case SERIAL_0:
  1613. base_addr =
  1614. SMC37c669_read_config( SMC37c669_SERIAL0_BASE_ADDRESS_INDEX );
  1615. dev_ok = TRUE;
  1616. break;
  1617. case SERIAL_1:
  1618. base_addr =
  1619. SMC37c669_read_config( SMC37c669_SERIAL1_BASE_ADDRESS_INDEX );
  1620. dev_ok = TRUE;
  1621. break;
  1622. case PARALLEL_0:
  1623. base_addr =
  1624. SMC37c669_read_config( SMC37c669_PARALLEL0_BASE_ADDRESS_INDEX );
  1625. dev_ok = TRUE;
  1626. break;
  1627. case FLOPPY_0:
  1628. base_addr =
  1629. SMC37c669_read_config( SMC37c669_FDC_BASE_ADDRESS_INDEX );
  1630. dev_ok = TRUE;
  1631. break;
  1632. case IDE_0:
  1633. base_addr =
  1634. SMC37c669_read_config( SMC37c669_IDE_BASE_ADDRESS_INDEX );
  1635. dev_ok = TRUE;
  1636. break;
  1637. }
  1638. /*
  1639. ** If we have a valid device, check base_addr<7:6> to see if the
  1640. ** device is enabled (mapped).
  1641. */
  1642. if ( ( dev_ok ) && ( ( base_addr & 0xC0 ) != 0 ) ) {
  1643. /*
  1644. ** The mapping is not disabled, so assume that the function is
  1645. ** enabled.
  1646. */
  1647. ret_val = TRUE;
  1648. }
  1649. /*
  1650. ** Exit configuration mode
  1651. */
  1652. SMC37c669_config_mode( FALSE );
  1653. return ret_val;
  1654. }
  1655. #if 0
  1656. /*
  1657. **++
  1658. ** FUNCTIONAL DESCRIPTION:
  1659. **
  1660. ** This function retrieves the configuration information of a
  1661. ** device function within the SMC37c699 Super I/O controller.
  1662. **
  1663. ** FORMAL PARAMETERS:
  1664. **
  1665. ** func:
  1666. ** Which device function
  1667. **
  1668. ** port:
  1669. ** I/O port returned
  1670. **
  1671. ** irq:
  1672. ** IRQ returned
  1673. **
  1674. ** drq:
  1675. ** DMA channel returned
  1676. **
  1677. ** RETURN VALUE:
  1678. **
  1679. ** Returns TRUE if the device configuration was successfully
  1680. ** retrieved, otherwise, FALSE.
  1681. **
  1682. ** SIDE EFFECTS:
  1683. **
  1684. ** The data pointed to by the port, irq, and drq parameters
  1685. ** my be modified even if the configuration is not successfully
  1686. ** retrieved.
  1687. **
  1688. ** DESIGN:
  1689. **
  1690. ** The device configuration is fetched from the local shadow
  1691. ** copy. Any unused parameters will be set to -1. Any
  1692. ** parameter which is not desired can specify the NULL
  1693. ** pointer.
  1694. **
  1695. **--
  1696. */
  1697. static unsigned int __init SMC37c669_get_device_config (
  1698. unsigned int func,
  1699. int *port,
  1700. int *irq,
  1701. int *drq )
  1702. {
  1703. struct DEVICE_CONFIG *cp;
  1704. unsigned int ret_val = FALSE;
  1705. /*
  1706. ** Check for a valid device configuration
  1707. */
  1708. if ( ( cp = SMC37c669_get_config( func ) ) != NULL ) {
  1709. if ( drq != NULL ) {
  1710. *drq = cp->drq;
  1711. ret_val = TRUE;
  1712. }
  1713. if ( irq != NULL ) {
  1714. *irq = cp->irq;
  1715. ret_val = TRUE;
  1716. }
  1717. if ( port != NULL ) {
  1718. *port = cp->port1;
  1719. ret_val = TRUE;
  1720. }
  1721. }
  1722. return ret_val;
  1723. }
  1724. #endif
  1725. /*
  1726. **++
  1727. ** FUNCTIONAL DESCRIPTION:
  1728. **
  1729. ** This function displays the current state of the SMC37c699
  1730. ** Super I/O controller's device functions.
  1731. **
  1732. ** FORMAL PARAMETERS:
  1733. **
  1734. ** None
  1735. **
  1736. ** RETURN VALUE:
  1737. **
  1738. ** None
  1739. **
  1740. ** SIDE EFFECTS:
  1741. **
  1742. ** None
  1743. **
  1744. **--
  1745. */
  1746. void __init SMC37c669_display_device_info ( void )
  1747. {
  1748. if ( SMC37c669_is_device_enabled( SERIAL_0 ) ) {
  1749. printk( " Serial 0: Enabled [ Port 0x%x, IRQ %d ]\n",
  1750. local_config[ SERIAL_0 ].port1,
  1751. local_config[ SERIAL_0 ].irq
  1752. );
  1753. }
  1754. else {
  1755. printk( " Serial 0: Disabled\n" );
  1756. }
  1757. if ( SMC37c669_is_device_enabled( SERIAL_1 ) ) {
  1758. printk( " Serial 1: Enabled [ Port 0x%x, IRQ %d ]\n",
  1759. local_config[ SERIAL_1 ].port1,
  1760. local_config[ SERIAL_1 ].irq
  1761. );
  1762. }
  1763. else {
  1764. printk( " Serial 1: Disabled\n" );
  1765. }
  1766. if ( SMC37c669_is_device_enabled( PARALLEL_0 ) ) {
  1767. printk( " Parallel: Enabled [ Port 0x%x, IRQ %d/%d ]\n",
  1768. local_config[ PARALLEL_0 ].port1,
  1769. local_config[ PARALLEL_0 ].irq,
  1770. local_config[ PARALLEL_0 ].drq
  1771. );
  1772. }
  1773. else {
  1774. printk( " Parallel: Disabled\n" );
  1775. }
  1776. if ( SMC37c669_is_device_enabled( FLOPPY_0 ) ) {
  1777. printk( " Floppy Ctrl: Enabled [ Port 0x%x, IRQ %d/%d ]\n",
  1778. local_config[ FLOPPY_0 ].port1,
  1779. local_config[ FLOPPY_0 ].irq,
  1780. local_config[ FLOPPY_0 ].drq
  1781. );
  1782. }
  1783. else {
  1784. printk( " Floppy Ctrl: Disabled\n" );
  1785. }
  1786. if ( SMC37c669_is_device_enabled( IDE_0 ) ) {
  1787. printk( " IDE 0: Enabled [ Port 0x%x, IRQ %d ]\n",
  1788. local_config[ IDE_0 ].port1,
  1789. local_config[ IDE_0 ].irq
  1790. );
  1791. }
  1792. else {
  1793. printk( " IDE 0: Disabled\n" );
  1794. }
  1795. }
  1796. /*
  1797. **++
  1798. ** FUNCTIONAL DESCRIPTION:
  1799. **
  1800. ** This function puts the SMC37c669 Super I/O controller into,
  1801. ** and takes it out of, configuration mode.
  1802. **
  1803. ** FORMAL PARAMETERS:
  1804. **
  1805. ** enable:
  1806. ** TRUE to enter configuration mode, FALSE to exit.
  1807. **
  1808. ** RETURN VALUE:
  1809. **
  1810. ** None
  1811. **
  1812. ** SIDE EFFECTS:
  1813. **
  1814. ** The SMC37c669 controller may be left in configuration mode.
  1815. **
  1816. **--
  1817. */
  1818. static void __init SMC37c669_config_mode(
  1819. unsigned int enable )
  1820. {
  1821. if ( enable ) {
  1822. /*
  1823. ** To enter configuration mode, two writes in succession to the index
  1824. ** port are required. If a write to another address or port occurs
  1825. ** between these two writes, the chip does not enter configuration
  1826. ** mode. Therefore, a spinlock is placed around the two writes to
  1827. ** guarantee that they complete uninterrupted.
  1828. */
  1829. spin_lock(&smc_lock);
  1830. wb( &SMC37c669->index_port, SMC37c669_CONFIG_ON_KEY );
  1831. wb( &SMC37c669->index_port, SMC37c669_CONFIG_ON_KEY );
  1832. spin_unlock(&smc_lock);
  1833. }
  1834. else {
  1835. wb( &SMC37c669->index_port, SMC37c669_CONFIG_OFF_KEY );
  1836. }
  1837. }
  1838. /*
  1839. **++
  1840. ** FUNCTIONAL DESCRIPTION:
  1841. **
  1842. ** This function reads an SMC37c669 Super I/O controller
  1843. ** configuration register. This function assumes that the
  1844. ** device is already in configuration mode.
  1845. **
  1846. ** FORMAL PARAMETERS:
  1847. **
  1848. ** index:
  1849. ** Index value of configuration register to read
  1850. **
  1851. ** RETURN VALUE:
  1852. **
  1853. ** Data read from configuration register
  1854. **
  1855. ** SIDE EFFECTS:
  1856. **
  1857. ** None
  1858. **
  1859. **--
  1860. */
  1861. static unsigned char __init SMC37c669_read_config(
  1862. unsigned char index )
  1863. {
  1864. unsigned char data;
  1865. wb( &SMC37c669->index_port, index );
  1866. data = rb( &SMC37c669->data_port );
  1867. return data;
  1868. }
  1869. /*
  1870. **++
  1871. ** FUNCTIONAL DESCRIPTION:
  1872. **
  1873. ** This function writes an SMC37c669 Super I/O controller
  1874. ** configuration register. This function assumes that the
  1875. ** device is already in configuration mode.
  1876. **
  1877. ** FORMAL PARAMETERS:
  1878. **
  1879. ** index:
  1880. ** Index of configuration register to write
  1881. **
  1882. ** data:
  1883. ** Data to be written
  1884. **
  1885. ** RETURN VALUE:
  1886. **
  1887. ** None
  1888. **
  1889. ** SIDE EFFECTS:
  1890. **
  1891. ** None
  1892. **
  1893. **--
  1894. */
  1895. static void __init SMC37c669_write_config(
  1896. unsigned char index,
  1897. unsigned char data )
  1898. {
  1899. wb( &SMC37c669->index_port, index );
  1900. wb( &SMC37c669->data_port, data );
  1901. }