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