2 * Copyright (c) 2007-2013 QLogic Corporation. All rights reserved.
4 * Eric Davis <edavis@broadcom.com>
5 * David Christensen <davidch@broadcom.com>
6 * Gary Zambrano <zambrano@broadcom.com>
8 * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
9 * Copyright (c) 2015 QLogic Corporation.
10 * All rights reserved.
13 * See LICENSE.bnx2x_pmd for copyright and licensing details.
20 * Debug versions of the 8/16/32 bit OS register read/write functions to
21 * capture/display values read/written from/to the controller.
24 bnx2x_reg_write8(struct bnx2x_softc *sc, size_t offset, uint8_t val)
26 PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%02x", (unsigned long)offset, val);
27 *((volatile uint8_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val;
31 bnx2x_reg_write16(struct bnx2x_softc *sc, size_t offset, uint16_t val)
33 if ((offset % 2) != 0) {
34 PMD_DRV_LOG(NOTICE, "Unaligned 16-bit write to 0x%08lx",
35 (unsigned long)offset);
38 PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%04x", (unsigned long)offset, val);
39 *((volatile uint16_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val;
43 bnx2x_reg_write32(struct bnx2x_softc *sc, size_t offset, uint32_t val)
45 if ((offset % 4) != 0) {
46 PMD_DRV_LOG(NOTICE, "Unaligned 32-bit write to 0x%08lx",
47 (unsigned long)offset);
50 PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%08x", (unsigned long)offset, val);
51 *((volatile uint32_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val;
55 bnx2x_reg_read8(struct bnx2x_softc *sc, size_t offset)
59 val = (uint8_t)(*((volatile uint8_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)));
60 PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%02x", (unsigned long)offset, val);
66 bnx2x_reg_read16(struct bnx2x_softc *sc, size_t offset)
70 if ((offset % 2) != 0) {
71 PMD_DRV_LOG(NOTICE, "Unaligned 16-bit read from 0x%08lx",
72 (unsigned long)offset);
75 val = (uint16_t)(*((volatile uint16_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)));
76 PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%08x", (unsigned long)offset, val);
82 bnx2x_reg_read32(struct bnx2x_softc *sc, size_t offset)
86 if ((offset % 4) != 0) {
87 PMD_DRV_LOG(NOTICE, "Unaligned 32-bit read from 0x%08lx",
88 (unsigned long)offset);
92 val = (uint32_t)(*((volatile uint32_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)));
93 PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%08x", (unsigned long)offset, val);