pcicShow.c
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:16k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* pcicShow.c - Intel 82365SL PCMCIA host bus adaptor chip show library */
  2. /* Copyright 1984-1996 Wind River Systems, Inc. */
  3. /* Copyright (c) 1994 David A. Hinds -- All Rights Reserved */
  4. #include "copyright_wrs.h"
  5. /*
  6. modification history
  7. --------------------
  8. 01d,01nov96,hdn  fixed PCIC_PORT().
  9. 01c,28mar96,jdi  doc: cleaned up language and format.
  10. 01b,22feb96,hdn  cleaned up
  11. 01a,15feb95,hdn  written based on David Hinds's version 2.2.3.
  12. */
  13. /*
  14. DESCRIPTION
  15. This is a driver show routine for the Intel 82365 series PCMCIA chip.
  16. pcicShow() is the only global function and is installed in the 
  17. PCMCIA chip table `pcmciaAdapter' in pcmciaShowInit().
  18. */
  19. #include "vxWorks.h"
  20. #include "stdio.h"
  21. #include "dllLib.h"
  22. #include "drv/pcmcia/pcmciaLib.h"
  23. #include "drv/pcmcia/pcic.h"
  24. #include "drv/pcmcia/pd67.h"
  25. /* defines */
  26. #define PCIC_PORT(slot) (pcicBase + (2*((slot) >> 2)))
  27. #define PCIC_REG(slot, reg) ((((slot) & 3) * 0x40) + reg)
  28. /* imports */
  29. IMPORT PCMCIA_CTRL pcmciaCtrl;
  30. IMPORT int pcicBase;
  31. /* globals */
  32. /* locals */
  33. LOCAL BOOL cirrus = FALSE;
  34. /* forward declarations */
  35. LOCAL STATUS pcicProbe (void);
  36. LOCAL void pcicShowStatus (int sock);
  37. LOCAL void pcicShowPower (int sock);
  38. LOCAL void pcicShowIntctl (int sock);
  39. LOCAL void pcicShowCsc (int sock);
  40. LOCAL void pcicShowCscint (int sock);
  41. LOCAL void pcicShowGenctl (int sock);
  42. LOCAL void pcicShowGblctl (int sock);
  43. LOCAL void pcicShowMisc (int sock);
  44. LOCAL void pcicShowTime (char *pName, int value);
  45. LOCAL void pcicShowTiming (int sock, int reg);
  46. LOCAL void pcicShowMemwin (int sock, int win);
  47. LOCAL void pcicShowIowin (int sock, int win);
  48. LOCAL int pcicGet (int sock, int reg);
  49. LOCAL int pcicGet2 (int sock, int reg);
  50. LOCAL void pcicSet (int sock, int reg, char value);
  51. /*******************************************************************************
  52. *
  53. * pcicShow - show all configurations of the PCIC chip
  54. *
  55. * This routine shows all configurations of the PCIC chip.
  56. *
  57. * RETURNS: N/A
  58. */
  59. void pcicShow
  60.     (
  61.     int sock /* socket no. */
  62.     )
  63.     {
  64.     int ix;
  65.     if (pcicProbe () != OK)
  66. return;
  67.     printf("Identification and revision = 0x%2.2xn",
  68.    pcicGet (sock, PCIC_IDENT));
  69.     if (cirrus)
  70. printf("Chip information = 0x%2.2xn", pcicGet (sock, PD67_CHIP_INFO));
  71.     pcicShowStatus (sock);
  72.     pcicShowPower  (sock);
  73.     pcicShowIntctl (sock);
  74.     pcicShowCsc    (sock);
  75.     pcicShowCscint (sock);
  76.  
  77.     if (cirrus)
  78. pcicShowMisc (sock);
  79.     else
  80. {
  81. pcicShowGenctl (sock);
  82. pcicShowGblctl (sock);
  83.         }
  84.     for (ix = 0; ix < PCIC_MEM_WINDOWS; ix++)
  85. pcicShowMemwin (sock, ix);
  86.     for (ix = 0; ix < PCIC_IO_WINDOWS; ix++)
  87. pcicShowIowin (sock, ix);
  88.     if (cirrus)
  89. for (ix = 0; ix < 2; ix++)
  90.     pcicShowTiming (sock, ix);
  91.     printf ("n");
  92.     }
  93. /*******************************************************************************
  94. *
  95. * pcicProbe - Probe the PCIC chip.
  96. *
  97. * This routine probes the PCIC chip.
  98. *
  99. * RETURNS: OK, or ERROR if it could not find the PCIC chip.
  100. */
  101. LOCAL STATUS pcicProbe (void)
  102.     {
  103.     char *name = "i82365sl";
  104.     int id = 0;
  105.     BOOL done = FALSE;
  106.     int sock;
  107.     int value;
  108.     printf ("Intel PCIC probe: ");
  109.     
  110.     for (sock = 0; sock < PCIC_MAX_SOCKS; sock++)
  111. {
  112. value = pcicGet (sock, PCIC_IDENT);
  113. switch (value)
  114.     {
  115.     case 0x82:
  116.     case 0x83:
  117. name = "INTEL 82365SL";
  118. break;
  119.     case 0x84:
  120. name = "VLSI 82C146";
  121. break;
  122.     case 0x88:
  123.     case 0x89:
  124. name = "IBM Clone";
  125. break;
  126.     case 0x8b:
  127. name = "VADEM Clone";
  128. break;
  129.     default:
  130. done = TRUE;
  131.     }
  132. id = value & 7;
  133. if (done)
  134.     break;
  135.         }
  136.     
  137.     if (sock == 0)
  138. {
  139. printf ("not found:  value=0x%x.n", value);
  140. return (ERROR);
  141.         }
  142.     
  143.     /* Check for Cirrus CL-PD67xx chips */
  144.     pcicSet (0, PD67_CHIP_INFO, 0);
  145.     value = pcicGet (0, PD67_CHIP_INFO);
  146.     if ((value & PD67_INFO_CHIP_ID) == PD67_INFO_CHIP_ID)
  147. {
  148. value = pcicGet (0, PD67_CHIP_INFO);
  149. if ((value & PD67_INFO_CHIP_ID) == 0)
  150.     {
  151.     cirrus = TRUE;
  152.     if (value & PD67_INFO_SLOTS)
  153. name = "Cirrus CL-PD672x";
  154.     else
  155. {
  156. name = "Cirrus CL-PD6710";
  157. sock = 1;
  158.         }
  159.     id = 8 - ((value & PD67_INFO_REV) >> 2);
  160.     }
  161.         }
  162.     printf ("%s rev %d found, %d socketsn", name, id, sock);
  163.     return (OK);
  164.     }
  165. /*******************************************************************************
  166. *
  167. * pcicShowStatus - Show status of the PCIC chip.
  168. *
  169. * This routine shows status of the PCIC chip.
  170. *
  171. * RETURNS: N/A
  172. */
  173. LOCAL void pcicShowStatus
  174.     (
  175.     int sock /* socket no. */
  176.     )
  177.     {
  178.     u_char value = pcicGet (sock, PCIC_STATUS);
  179.     printf ("Interface status = 0x%2.2xn", value);
  180.     printf ("  ");
  181.     if (value & PCIC_CS_BVD1)
  182. printf ("[BVD1/STSCHG] ");
  183.     if (value & PCIC_CS_BVD2)
  184. printf ("[BVD2/SPKR] ");
  185.     if (value & PCIC_CS_DETECT)
  186. printf ("[DETECT] ");
  187.     if (value & PCIC_CS_WRPROT)
  188. printf ("[WRPROT] ");
  189.     if (value & PCIC_CS_READY)
  190. printf ("[READY] ");
  191.     if (value & PCIC_CS_POWERON)
  192. printf ("[POWERON] ");
  193.     if (value & PCIC_CS_GPI)
  194. printf ("[GPI] ");
  195.     printf ("n");
  196.     }
  197. /*******************************************************************************
  198. *
  199. * pcicShowPower - Show power configuration of the PCIC chip.
  200. *
  201. * This routine shows power configuration of the PCIC chip.
  202. *
  203. * RETURNS: N/A
  204. */
  205. LOCAL void pcicShowPower
  206.     (
  207.     int sock /* socket no. */
  208.     )
  209.     {
  210.     u_char value = pcicGet(sock, PCIC_POWER);
  211.     printf ("Power control = 0x%2.2xn", value);
  212.     printf ("  ");
  213.     if (value & PCIC_PWR_OUT)
  214. printf ("[OUTPUT] ");
  215.     if (!(value & PCIC_PWR_NORESET))
  216. printf ("[RESETDRV] ");
  217.     if (value & PCIC_PWR_AUTO)
  218. printf ("[AUTO] ");
  219.     switch (value & PCIC_VCC_MASK)
  220. {
  221.         case PCIC_VCC_5V:
  222.     printf ("[Vcc=5v] ");
  223.     break;
  224.         case PCIC_VCC_3V:
  225.     printf ("[Vcc=3v] ");
  226.     break;
  227.         case 0:
  228.     printf ("[Vcc off] ");
  229.     break;
  230.         }
  231.     switch (value & PCIC_VPP_MASK)
  232. {
  233.         case PCIC_VPP_5V:
  234.     printf ("[Vpp=5v] ");
  235.     break;
  236.         case PCIC_VPP_12V:
  237.     printf ("[Vpp=12v] ");
  238.     break;
  239.         case 0:
  240.     printf ("[Vpp off] ");
  241.     break;
  242.         }
  243.     printf ("n");
  244.     }
  245. /*******************************************************************************
  246. *
  247. * pcicShowIntctl - Show interrupt control configuration of the PCIC chip.
  248. *
  249. * This routine shows interrupt control configuration of the PCIC chip.
  250. *
  251. * RETURNS: N/A
  252. */
  253. LOCAL void pcicShowIntctl
  254.     (
  255.     int sock /* socket no. */
  256.     )
  257.     {
  258.     u_char value = pcicGet (sock, PCIC_INTCTL);
  259.     printf ("Interrupt and general control = 0x%2.2xn", value);
  260.     printf ("  ");
  261.     if (value & PCIC_RING_ENA)
  262. printf ("[RING_ENA] ");
  263.     if (!(value & PCIC_PC_RESET))
  264. printf ("[RESET] ");
  265.     if (value & PCIC_PC_IOCARD)
  266. printf ("[IOCARD] ");
  267.     if (value & PCIC_INTR_ENA)
  268. printf ("[INTR_ENA] ");
  269.     printf ("[irq=%d]n", value & PCIC_IRQ_MASK);
  270. }
  271. /*******************************************************************************
  272. *
  273. * pcicShowCsc - Show card status change of the PCIC chip.
  274. *
  275. * This routine shows card status change of the PCIC chip.
  276. *
  277. * RETURNS: N/A
  278. */
  279. LOCAL void pcicShowCsc
  280.     (
  281.     int sock /* socket no. */
  282.     )
  283.     {
  284.     u_char value = pcicGet (sock, PCIC_CSC);
  285.     printf ("Card status change = 0x%2.2xn", value);
  286.     printf ("  ");
  287.     if (value & PCIC_CSC_BVD1)
  288. printf ("[BVD1/STSCHG] ");
  289.     if (value & PCIC_CSC_BVD2)
  290. printf ("[BVD2] ");
  291.     if (value & PCIC_CSC_DETECT)
  292. printf ("[DETECT] ");
  293.     if (value & PCIC_CSC_READY)
  294. printf ("[READY] ");
  295.     if (value & PCIC_CSC_GPI)
  296. printf ("[GPI] ");
  297.     printf ("n");
  298.     }
  299. /*******************************************************************************
  300. *
  301. * pcicShowCscint - Show card status change interrupt configuration.
  302. *
  303. * This routine shows card status change interrupt configuration of 
  304. * the PCIC chip.
  305. *
  306. * RETURNS: N/A
  307. */
  308. LOCAL void pcicShowCscint
  309.     (
  310.     int sock /* socket no. */
  311.     )
  312.     {
  313.     u_char value = pcicGet (sock, PCIC_CSCINT);
  314.     printf ("Card status change interrupt control = 0x%2.2xn", value);
  315.     printf ("  ");
  316.     if (value & PCIC_CSC_BVD1)
  317. printf ("[BVD1/STSCHG] ");
  318.     if (value & PCIC_CSC_BVD2)
  319. printf ("[BVD2] ");
  320.     if (value & PCIC_CSC_DETECT)
  321. printf ("[DETECT] ");
  322.     if (value & PCIC_CSC_READY)
  323. printf ("[READY] ");
  324.     printf ("[irq = %d]n", value >> 4);
  325.     }
  326. /*******************************************************************************
  327. *
  328. * pcicShowGenctl - Show general control of the PCIC chip.
  329. *
  330. * This routine shows general control of the PCIC chip.
  331. *
  332. * RETURNS: N/A
  333. */
  334. LOCAL void pcicShowGenctl
  335.     (
  336.     int sock /* socket no. */
  337.     )
  338.     {
  339.     u_char value = pcicGet (sock, PCIC_GENCTL);
  340.     printf ("Card detect and general control = 0x%2.2xn", value);
  341.     printf ("  ");
  342.     if (value & PCIC_CTL_16DELAY)
  343. printf ("[16DELAY] ");
  344.     if (value & PCIC_CTL_RESET_ENA)
  345. printf ("[RESET] ");
  346.     if (value & PCIC_CTL_GPI_ENA)
  347. printf ("[GPI_ENA] ");
  348.     if (value & PCIC_CTL_GPI_CTL)
  349. printf ("[GPI_CTL] ");
  350.     if (value & PCIC_CTL_RESUME)
  351. printf ("[RESUME] ");
  352.     printf ("n");
  353.     }
  354. /*******************************************************************************
  355. *
  356. * pcicShowGblctl - Show global control of the PCIC chip.
  357. *
  358. * This routine shows global control of the PCIC chip.
  359. *
  360. * RETURNS: N/A
  361. */
  362. LOCAL void pcicShowGblctl
  363.     (
  364.     int sock /* socket no. */
  365.     )
  366.     {
  367.     u_char value = pcicGet (sock, PCIC_GBLCTL);
  368.     printf ("Global control = 0x%2.2xn", value);
  369.     printf ("  ");
  370.     if (value & PCIC_GBL_PWRDOWN)
  371. printf ("[PWRDOWN] ");
  372.     if (value & PCIC_GBL_CSC_LEV)
  373. printf ("[CSC_LEV] ");
  374.     if (value & PCIC_GBL_WRBACK)
  375. printf ("[WRBACK] ");
  376.     if (value & PCIC_GBL_IRQ_0_LEV)
  377. printf ("[IRQ_0_LEV] ");
  378.     if (value & PCIC_GBL_IRQ_1_LEV)
  379. printf ("[IRQ_1_LEV] ");
  380.     printf ("n");
  381.     }
  382. /*******************************************************************************
  383. *
  384. * pcicShowMisc - Show misc control of the PCIC chip.
  385. *
  386. * This routine shows misc control of the PCIC chip.
  387. *
  388. * RETURNS: N/A
  389. */
  390. LOCAL void pcicShowMisc
  391.     (
  392.     int sock /* socket no. */
  393.     )
  394.     {
  395.     u_char value = pcicGet(sock, PD67_MISC_CTL_1);
  396.     printf ("Misc control 1 = 0x%2.2xn", value);
  397.     printf ("  ");
  398.     if (value & PD67_MC1_5V_DET)
  399. printf ("[5V_DET] ");
  400.     if (value & PD67_MC1_VCC_3V)
  401. printf ("[VCC_3V] ");
  402.     if (value & PD67_MC1_PULSE_MGMT)
  403. printf ("[PULSE_MGMT] ");
  404.     if (value & PD67_MC1_PULSE_IRQ)
  405. printf ("[PULSE_IRQ] ");
  406.     if (value & PD67_MC1_SPKR_ENA)
  407. printf ("[SPKR] ");
  408.     if (value & PD67_MC1_INPACK_ENA)
  409. printf ("[INPACK] ");
  410.     printf ("n");
  411.     value = pcicGet(sock, PD67_MISC_CTL_2);
  412.     printf ("Misc control 2 = 0x%2.2xn", value);
  413.     printf ("  ");
  414.     if (value & PD67_MC2_FREQ_BYPASS)
  415. printf ("[FREQ_BYPASS] ");
  416.     if (value & PD67_MC2_DYNAMIC_MODE)
  417. printf ("[DYNAMIC_MODE] ");
  418.     if (value & PD67_MC2_SUSPEND)
  419. printf ("[SUSPEND] ");
  420.     if (value & PD67_MC2_5V_CORE)
  421. printf ("[5V_CORE] ");
  422.     if (value & PD67_MC2_LED_ENA)
  423. printf ("[LED_ENA] ");
  424.     if (value & PD67_MC2_3STATE_BIT7)
  425. printf ("[3STATE_BIT7] ");
  426.     if (value & PD67_MC2_DMA_MODE)
  427. printf ("[DMA_MODE] ");
  428.     if (value & PD67_MC2_IRQ15_RI)
  429. printf ("[IRQ15_RI] ");
  430.     printf ("n");
  431.     }
  432. /*******************************************************************************
  433. *
  434. * pcicShowTime - Show time scale of the PCIC chip.
  435. *
  436. * This routine shows time scale of the PCIC chip.
  437. *
  438. * RETURNS: N/A
  439. */
  440. LOCAL void pcicShowTime
  441.     (
  442.     char *pName, /* name of time scale */
  443.     int  value /* value of a time scale */
  444.     )
  445.     {
  446.     printf ("%s = %d", pName, value & PD67_TIME_MULT);
  447.     switch (value & PD67_TIME_SCALE)
  448. {
  449.         case PD67_TIME_SCALE_16:
  450.     printf ("[*16] ");
  451.     break;
  452.         case PD67_TIME_SCALE_256:
  453.     printf ("[*256] ");
  454.     break;
  455.         case PD67_TIME_SCALE_4096:
  456.     printf ("[*4096] ");
  457.     break;
  458.         }
  459.     }
  460. /*******************************************************************************
  461. *
  462. * pcicShowTiming - Show timing of the PCIC chip.
  463. *
  464. * This routine shows timing of the PCIC chip.
  465. *
  466. * RETURNS: N/A
  467. */
  468. LOCAL void pcicShowTiming
  469.     (
  470.     int sock, /* socket no. */
  471.     int reg /* timing register no. */
  472.     )
  473.     {
  474.     printf ("Timing set %d: ", reg);
  475.     pcicShowTime ("setup", pcicGet (sock, PD67_TIME_SETUP(reg)));
  476.     pcicShowTime (", command", pcicGet (sock, PD67_TIME_CMD(reg)));
  477.     pcicShowTime (", recovery", pcicGet (sock, PD67_TIME_RECOV(reg)));
  478.     printf ("n");
  479.     }
  480. /*******************************************************************************
  481. *
  482. * pcicShowMemwin - Show memory window of the PCIC chip.
  483. *
  484. * This routine shows memory window of the PCIC chip.
  485. *
  486. * RETURNS: N/A
  487. */
  488. LOCAL void pcicShowMemwin
  489.     (
  490.     int sock, /* socket no. */
  491.     int win /* memory window no. */
  492.     )
  493.     {
  494.     u_short start = pcicGet2 (sock, PCIC_MEM(win)+PCIC_W_START);
  495.     u_short stop  = pcicGet2 (sock, PCIC_MEM(win)+PCIC_W_STOP);
  496.     u_short off   = pcicGet2 (sock, PCIC_MEM(win)+PCIC_W_OFF);
  497.     printf ("Memory window %d: ", win);
  498.     if (pcicGet (sock, PCIC_ADDRWIN) & PCIC_ENA_MEM(win))
  499. printf ("[ON] ");
  500.     else
  501. printf ("[OFF] ");
  502.     if (start & PCIC_MEM_16BIT)
  503. printf ("[16BIT] ");
  504.     if (cirrus)
  505. {
  506. if (stop & PCIC_MEM_WS1)
  507.     printf ("[TIME1] ");
  508. else
  509.     printf ("[TIME0] ");
  510.         }
  511.     else
  512. {
  513. if (start & PCIC_MEM_0WS)
  514.     printf ("[0WS] ");
  515. if (stop & PCIC_MEM_WS1)
  516.     printf ("[WS1] ");
  517. if (stop & PCIC_MEM_WS0)
  518.     printf ("[WS0] ");
  519.         }
  520.     if (off & PCIC_MEM_WRPROT)
  521. printf ("[WRPROT] ");
  522.     if (off & PCIC_MEM_REG)
  523. printf ("[REG] ");
  524.     printf ("n  start = 0x%4.4x", start & 0x3fff);
  525.     printf (", stop = 0x%4.4x", stop & 0x3fff);
  526.     printf (", offset = 0x%4.4xn", off & 0x3fff);
  527.     }
  528. /*******************************************************************************
  529. *
  530. * pcicShowIowin - Show IO window of the PCIC chip.
  531. *
  532. * This routine shows IO window of the PCIC chip.
  533. *
  534. * RETURNS: N/A
  535. */
  536. LOCAL void pcicShowIowin
  537.     (
  538.     int sock, /* socket no. */
  539.     int win /* IO window no. */
  540.     )
  541.     {
  542.     u_char  ctl   = pcicGet  (sock, PCIC_IOCTL);
  543.     u_short start = pcicGet2 (sock, PCIC_IO(win)+PCIC_W_START);
  544.     u_short stop  = pcicGet2 (sock, PCIC_IO(win)+PCIC_W_STOP);
  545.     printf ("I/O window %d: ", win);
  546.     if (pcicGet (sock, PCIC_ADDRWIN) & PCIC_ENA_IO(win))
  547. printf ("[ON] ");
  548.     else
  549. printf ("[OFF] ");
  550.     
  551.     if (cirrus)
  552. {
  553. if (ctl & PCIC_IOCTL_WAIT(win))
  554.     printf (" [TIME1]");
  555. else
  556.     printf (" [TIME0]");
  557.         }
  558.     else
  559. {
  560. if (ctl & PCIC_IOCTL_WAIT(win))
  561.     printf ("[WAIT] ");
  562. if (ctl & PCIC_IOCTL_0WS(win))
  563.     printf ("[0WS] ");
  564.         }
  565.     if (ctl & PCIC_IOCTL_CS16(win))
  566. printf ("[CS16] ");
  567.     if (ctl & PCIC_IOCTL_16BIT(win))
  568. printf ("[16BIT] ");
  569.     
  570.     printf ("n  start = 0x%4.4x, stop = 0x%4.4x", start, stop);
  571.     if (cirrus)
  572. {
  573.         u_short off = pcicGet2 (sock, PD67_IO_OFF(win));
  574. printf (", offset = 0x%4.4x", off);
  575.         }
  576.     printf ("n");
  577.     }
  578. /*******************************************************************************
  579. *
  580. * pcicGet - Get a value from the register.
  581. *
  582. * This routine gets a value from the register.
  583. *
  584. * RETURNS: a value of the register.
  585. */
  586. LOCAL int pcicGet
  587.     (
  588.     int sock, /* socket no. */
  589.     int reg /* register no. */
  590.     )
  591.     {
  592.     short port = PCIC_PORT (sock);
  593.     char offset = PCIC_REG (sock, reg);
  594.     sysOutByte (port, offset);
  595.     return (sysInByte (port+1));
  596.     }
  597. /*******************************************************************************
  598. *
  599. * pcicGet2 - Get a value from the consecutive registers.
  600. *
  601. * This routine gets a value from the consecutive registers.
  602. *
  603. * RETURNS: a value of the register.
  604. */
  605. LOCAL int pcicGet2
  606.     (
  607.     int sock, /* socket no. */
  608.     int reg /* register no. */
  609.     )
  610.     {
  611.     short a = pcicGet (sock, reg);
  612.     short b = pcicGet (sock, reg+1);
  613.     return (a + (b<<8));
  614.     }
  615. /*******************************************************************************
  616. *
  617. * pcicSet - Set value into the register.
  618. *
  619. * This routine sets value into the register.
  620. *
  621. * RETURNS: N/A
  622. */
  623. LOCAL void pcicSet
  624.     (
  625.     int  sock, /* socket no. */
  626.     int  reg, /* register no. */
  627.     char value /* value to set */
  628.     )
  629.     {
  630.     short port = PCIC_PORT (sock);
  631.     char offset = PCIC_REG (sock, reg);
  632.     sysOutByte (port, offset);
  633.     sysOutByte (port+1, value);
  634.     }