srom.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * (C) Copyright 2002 ELTEC Elektronik AG
  3. * Frank Gottschling <fgottschling@eltec.de>
  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. /* common srom defs */
  24. #define FIRST_DEVICE 0x00
  25. #define SECOND_DEVICE 0x04
  26. #define FIRST_BLOCK 0x00
  27. #define SECOND_BLOCK 0x02
  28. #define BLOCK_SIZE 0x100
  29. #define ERROR (-1)
  30. #define CLK2P0TO1_1MB_PB_0P5DH 0x79000100
  31. #define CLK2P5TO1_1MB_PB_0P5DH 0x7B000100
  32. #define CPU_TYPE_740 0x08
  33. #define CPU_TYPE_750 0x08
  34. #define CPU_TYPE ((get_pvr()>>16)&0xffff)
  35. #define ABS(x) ((x<0)?-x:x)
  36. #define SROM_SHORT(pX) (*(u8 *)(pX) | *((u8 *)(pX)+1) << 8)
  37. /* bab7xx ELTEC srom */
  38. #define I2C_BUS_DAT (CFG_ISA_IO + 0x220)
  39. #define I2C_BUS_DIR (CFG_ISA_IO + 0x221)
  40. /* srom at mpc107 */
  41. #define MPC107_I2CADDR (mpc107_eumb_addr + 0x3000) /* address */
  42. #define MPC107_I2CFDR (mpc107_eumb_addr + 0x3004) /* freq divider */
  43. #define MPC107_I2CCR (mpc107_eumb_addr + 0x3008) /* control */
  44. #define MPC107_I2CSR (mpc107_eumb_addr + 0x300c) /* status */
  45. #define MPC107_I2CDR (mpc107_eumb_addr + 0x3010) /* data */
  46. #define MPC107_I2C_TIMEOUT 10000000
  47. /* i82559 */
  48. #define EE_ADDR_BITS 6
  49. #define EE_SIZE 0x40 /* 0x40 words */
  50. #define EE_CHECKSUM 0xBABA
  51. /* dc21143 */
  52. #define DEC_SROM_SIZE 128
  53. /*
  54. * structure of revision srom
  55. */
  56. typedef struct {
  57. char magic[8]; /* 000 - Magic number */
  58. char revrev[2]; /* 008 - Revision of structure */
  59. unsigned short size; /* 00A - Size of CRC area */
  60. unsigned long crc; /* 00C - CRC */
  61. char board[16]; /* 010 - Board Revision information */
  62. char option[4][16]; /* 020 - Option Revision information */
  63. char serial[8]; /* 060 - Board serial number */
  64. char etheraddr[6]; /* 068 - Ethernet node addresse */
  65. char reserved[2]; /* 06E - Reserved */
  66. char revision[7][2]; /* 070 - Revision codes */
  67. char category[2]; /* 07E - Category codes */
  68. char text[64]; /* 080 - Text field */
  69. char res[64]; /* 0C0 - Reserved */
  70. } revinfo;
  71. unsigned long el_srom_checksum (unsigned char *ptr, unsigned long size);
  72. int el_srom_load (unsigned char addr, unsigned char *buf, int cnt,
  73. unsigned char device, unsigned char block);
  74. int el_srom_store (unsigned char addr, unsigned char *buf, int cnt,
  75. unsigned char device, unsigned char block);
  76. int mpc107_i2c_init (unsigned long eumb_addr, unsigned long divider);
  77. int mpc107_i2c_read_byte (unsigned char device, unsigned char block, unsigned char offset);
  78. int mpc107_i2c_write_byte (unsigned char device, unsigned char block,
  79. unsigned char offset, unsigned char val);
  80. int mpc107_srom_load (unsigned char addr, unsigned char *pBuf, int cnt,
  81. unsigned char device, unsigned char block);
  82. int mpc107_srom_store (unsigned char addr, unsigned char *pBuf, int cnt,
  83. unsigned char device, unsigned char block);
  84. int dc_srom_load (unsigned short *dest);
  85. int dc_srom_store (unsigned short *src);
  86. unsigned short eepro100_srom_checksum (unsigned short *sromdata);
  87. void eepro100_srom_load (unsigned short *destination);
  88. int eepro100_srom_store (unsigned short *source);