diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2019-04-16 11:42:57 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2019-04-16 11:42:57 +0000 |
commit | 011fb0f5bba71e94df5053498b5264706a0355c9 (patch) | |
tree | d7a29400e0db261ca7c60a78859b07a3280819a1 /sys/dev | |
parent | 5287e30c9f39319fb08ad825d95aeb83c81cba34 (diff) |
i2c reads are more reliable a byte at a time.
reading all 256 at a time was a nice idea, but meant page 0xa2 wasnt
appearing like it should. this follows what freebsd does more
closely too.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/if_myx.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/sys/dev/pci/if_myx.c b/sys/dev/pci/if_myx.c index 78588e79125..f13cf938a28 100644 --- a/sys/dev/pci/if_myx.c +++ b/sys/dev/pci/if_myx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_myx.c,v 1.106 2019/04/16 09:40:21 dlg Exp $ */ +/* $OpenBSD: if_myx.c,v 1.107 2019/04/16 11:42:56 dlg Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@openbsd.org> @@ -947,14 +947,21 @@ myx_rxrinfo(struct myx_softc *sc, struct if_rxrinfo *ifri) } static int -myx_i2c_byte(struct myx_softc *sc, uint8_t off, uint8_t *byte) +myx_i2c_byte(struct myx_softc *sc, uint8_t addr, uint8_t off, uint8_t *byte) { struct myx_cmd mc; int result; uint32_t r; unsigned int ms; - for (ms = 0; ms < 600; ms++) { + memset(&mc, 0, sizeof(mc)); + mc.mc_data0 = htobe32(0); /* get 1 byte */ + mc.mc_data1 = htobe32((addr << 8) | off); + result = myx_cmd(sc, MYXCMD_I2C_READ, &mc, NULL); + if (result != 0) + return (EIO); + + for (ms = 0; ms < 50; ms++) { memset(&mc, 0, sizeof(mc)); mc.mc_data0 = htobe32(off); result = myx_cmd(sc, MYXCMD_I2C_BYTE, &mc, &r); @@ -977,21 +984,13 @@ myx_i2c_byte(struct myx_softc *sc, uint8_t off, uint8_t *byte) int myx_get_sffpage(struct myx_softc *sc, struct if_sffpage *sff) { - struct myx_cmd mc; unsigned int i; int result; - memset(&mc, 0, sizeof(mc)); - mc.mc_data0 = htobe32(1); /* get all 256 bytes */ - mc.mc_data1 = htobe32(sff->sff_addr << 8); - result = myx_cmd(sc, MYXCMD_I2C_READ, &mc, NULL); - if (result != 0) - return (EIO); - if (sff->sff_addr == IFSFF_ADDR_EEPROM) { uint8_t page; - result = myx_i2c_byte(sc, 127, &page); + result = myx_i2c_byte(sc, IFSFF_ADDR_EEPROM, 127, &page); if (result != 0) return (result); @@ -1000,7 +999,8 @@ myx_get_sffpage(struct myx_softc *sc, struct if_sffpage *sff) } for (i = 0; i < sizeof(sff->sff_data); i++) { - result = myx_i2c_byte(sc, i, &sff->sff_data[i]); + result = myx_i2c_byte(sc, sff->sff_addr, + i, &sff->sff_data[i]); if (result != 0) return (result); } |