vpd.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * (C) Copyright 2001
  3. * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef _VPD_H_
  24. #define _VPD_H_
  25. /*
  26. * Main Flash Configuration.
  27. */
  28. typedef struct flashCfg_s {
  29. unsigned short mfg; /* Manufacture ID */
  30. unsigned short dev; /* Device ID */
  31. unsigned char devWidth; /* Device Width */
  32. unsigned char numDevs; /* Number of devices */
  33. unsigned char numCols; /* Number of columns */
  34. unsigned char colWidth; /* Width of a column */
  35. unsigned char weDataWidth; /* Write/Erase Data Width */
  36. } flashCfg_t;
  37. /*
  38. * Vital Product Data - VPD
  39. */
  40. #define MAX_PROD_ID 15
  41. #define MAX_ETH_ADDRS 10
  42. typedef unsigned char EthAddr[6];
  43. typedef struct vpd {
  44. unsigned char _devAddr; /* Device address during read */
  45. char productId[MAX_PROD_ID]; /* Product ID */
  46. char revisionId; /* Revision ID as a char */
  47. unsigned long serialNum; /* Serial number */
  48. unsigned char manuID; /* Manufact ID - byte int */
  49. unsigned long configOpt; /* Config Option - bit field */
  50. unsigned long sysClk; /* System clock in Hertz */
  51. unsigned long serClk; /* Ext. clock in Hertz */
  52. flashCfg_t flashCfg; /* Flash configuration */
  53. unsigned long numPOTS; /* Number of POTS lines */
  54. unsigned long numDS1; /* Number of DS1 circuits */
  55. EthAddr ethAddrs[MAX_ETH_ADDRS]; /* Ethernet MAC, 1st = craft */
  56. } VPD;
  57. #define VPD_MAX_EEPROM_SIZE 512 /* Max size VPD EEPROM */
  58. #define SDRAM_SPD_DATA_SIZE 128 /* Size SPD in VPD EEPROM */
  59. /*
  60. * PIDs - Packet Identifiers
  61. */
  62. #define VPD_PID_GI 0x0 /* Guaranted Illegal */
  63. #define VPD_PID_PID 0x1 /* Product Identifier */
  64. #define VPD_PID_REV 0x2 /* Product Revision */
  65. #define VPD_PID_SN 0x3 /* Serial Number */
  66. #define VPD_PID_MANID 0x4 /* Manufacture ID */
  67. #define VPD_PID_PCO 0x5 /* Product configuration */
  68. #define VPD_PID_SYSCLK 0x6 /* System Clock */
  69. #define VPD_PID_SERCLK 0x7 /* Ser. Clk. Speed in Hertz */
  70. #define VPD_PID_CRC 0x8 /* VPD CRC */
  71. #define VPD_PID_FLASH 0x9 /* Flash Configuration */
  72. #define VPD_PID_ETHADDR 0xA /* Ethernet Address(es) */
  73. #define VPD_PID_GAL 0xB /* Galileo Switch Config */
  74. #define VPD_PID_POTS 0xC /* Number of POTS Lines */
  75. #define VPD_PID_DS1 0xD /* Number of DS1s */
  76. #define VPD_PID_TERM 0xFF /* Termination packet */
  77. /*
  78. * VPD - Eyecatcher/Magic
  79. */
  80. #define VPD_EYECATCHER "W7O"
  81. #define VPD_EYE_SIZE 3
  82. typedef struct vpd_header {
  83. unsigned char eyecatcher[VPD_EYE_SIZE]; /* eyecatcher - "W7O" */
  84. unsigned short size __attribute__((packed)); /* size of EEPROM */
  85. } vpd_header_t;
  86. #define VPD_DATA_SIZE (VPD_MAX_EEPROM_SIZE - SDRAM_SPD_DATA_SIZE - \
  87. sizeof(vpd_header_t))
  88. typedef struct vpd_s {
  89. vpd_header_t header;
  90. unsigned char packets[VPD_DATA_SIZE];
  91. } vpd_t;
  92. typedef struct vpd_packet {
  93. unsigned char identifier;
  94. unsigned char size;
  95. unsigned char data[1];
  96. } vpd_packet_t;
  97. /*
  98. * VPD configOpt bit mask
  99. */
  100. #define VPD_HAS_BBRAM 0x1 /* Battery backed SRAM */
  101. #define VPD_HAS_RTC 0x2 /* Battery backed RTC */
  102. #define VPD_HAS_EXT_SER_CLK 0x4 /* External serial clock */
  103. #define VPD_HAS_SER_TRANS_1 0x8 /* COM1 transceiver */
  104. #define VPD_HAS_SER_TRANS_2 0x10 /* COM2 transceiver */
  105. #define VPD_HAS_CRAFT_PHY 0x20 /* CRAFT Ethernet */
  106. #define VPD_HAS_DTT_1 0x40 /* I2C Digital therm. #1 */
  107. #define VPD_HAS_DTT_2 0x80 /* I2C Digital therm. #2 */
  108. #define VPD_HAS_1000_UP_LASER 0x100 /* GMM - 1000Mbit Uplink */
  109. #define VPD_HAS_70KM_UP_LASER 0x200 /* CMM - 70KM Uplink laser */
  110. #define VPD_HAS_2_UPLINKS 0x400 /* CMM - 2 uplink lasers */
  111. #define VPD_HAS_FPGA 0x800 /* Has 1 or more FPGAs */
  112. #define VPD_HAS_DFA 0x1000 /* CLM - Has 2 Fiber Inter. */
  113. #define VPD_HAS_GAL_SWITCH 0x2000 /* GMM - Has a Gal switch */
  114. #define VPD_HAS_POTS_LINES 0x4000 /* GMM - Has POTS lines */
  115. #define VPD_HAS_DS1_CHANNELS 0x8000 /* GMM - Has DS1 channels */
  116. #define VPD_HAS_CABLE_RETURN 0x10000 /* GBM/GBR - Cable ret. path */
  117. #define VPD_EEPROM_SIZE (256 - SDRAM_SPD_DATA_SIZE) /* Size EEPROM */
  118. extern int vpd_get_data(unsigned char dev_addr, VPD *vpd);
  119. extern void vpd_print(VPD *vpdInfo);
  120. #endif /* _VPD_H_ */