X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=qemu%2Froms%2Fu-boot%2Fboard%2Feltec%2Felppc%2Feepro100_srom.c;fp=qemu%2Froms%2Fu-boot%2Fboard%2Feltec%2Felppc%2Feepro100_srom.c;h=05ba9c4472d271bc6aac186c6fb6081bcfae5a7d;hb=e44e3482bdb4d0ebde2d8b41830ac2cdb07948fb;hp=0000000000000000000000000000000000000000;hpb=9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00;p=kvmfornfv.git diff --git a/qemu/roms/u-boot/board/eltec/elppc/eepro100_srom.c b/qemu/roms/u-boot/board/eltec/elppc/eepro100_srom.c new file mode 100644 index 000000000..05ba9c447 --- /dev/null +++ b/qemu/roms/u-boot/board/eltec/elppc/eepro100_srom.c @@ -0,0 +1,98 @@ +/* + * (C) Copyright 2002 ELTEC Elektronik AG + * Frank Gottschling + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +/* + * Local network srom writing for first time run + */ + +/* includes */ +#include +#include +#include +#include "srom.h" + +extern int eepro100_write_eeprom (struct eth_device *dev, + int location, int addr_len, + unsigned short data); + +/*----------------------------------------------------------------------------*/ + +unsigned short eepro100_srom_checksum (unsigned short *sromdata) +{ + unsigned short sum = 0; + unsigned int i; + + for (i = 0; i < (EE_SIZE - 1); i++) { + sum += sromdata[i]; + } + return (EE_CHECKSUM - sum); +} + +/*----------------------------------------------------------------------------*/ + +int eepro100_srom_store (unsigned short *source) +{ + int count; + struct eth_device onboard_dev; + + /* get onboard network iobase */ + pci_read_config_dword (PCI_BDF (0, 0x10, 0), PCI_BASE_ADDRESS_0, + (unsigned int *) &onboard_dev.iobase); + onboard_dev.iobase &= ~0xf; + + source[63] = eepro100_srom_checksum (source); + + for (count = 0; count < EE_SIZE; count++) { + if (eepro100_write_eeprom ((struct eth_device *) &onboard_dev, + count, EE_ADDR_BITS, + SROM_SHORT (source)) == -1) { + return -1; + } + source++; + } + return 0; +} + +/*----------------------------------------------------------------------------*/ + +#ifdef EEPRO100_SROM_CHECK + +extern int read_eeprom (struct eth_device *dev, int location, int addr_len); + +void eepro100_srom_load (unsigned short *destination) +{ + int count; + struct eth_device onboard_dev; + +#ifdef DEBUG + int lr = 0; + + printf ("eepro100_srom_download:\n"); +#endif + + /* get onboard network iobase */ + pci_read_config_dword (PCI_BDF (0, 0x10, 0), PCI_BASE_ADDRESS_0, + &onboard_dev.iobase); + onboard_dev.iobase &= ~0xf; + + memset (destination, 0x65, 128); + + for (count = 0; count < 0x40; count++) { + *destination++ = read_eeprom ((struct eth_device *) &onboard_dev, + count, EE_ADDR_BITS); +#ifdef DEBUG + printf ("%04x ", *(destination - 1)); + if (lr++ == 7) { + printf ("\n"); + lr = 0; + } +#endif + } +} +#endif /* EEPRO100_SROM_CHECK */ + +/*----------------------------------------------------------------------------*/