fix(drivers/marvell/comphy): change reg_set() / reg_set16() to update semantics

Currently reg_set() and reg_set16() are implemented via
mmio_clrsetbits_32(), meaning that first bits from mask are cleared,
then data bits are set.

But these function are used everywhere according to update semantics,
where only those bits that are in mask are allowed to be changed.

Example from phy-comphy-cp110.c
  mask = HPIPE_RST_CLK_CTRL_PIPE_RST_MASK;
  data = 0x1 << HPIPE_RST_CLK_CTRL_PIPE_RST_OFFSET;
  /* Set PHY datapath width mode for V0 */
  mask |= HPIPE_RST_CLK_CTRL_FIXED_PCLK_MASK;
  data |= 0x0 << HPIPE_RST_CLK_CTRL_FIXED_PCLK_OFFSET;
  /* Set Data bus width USB mode for V0 */
  mask |= HPIPE_RST_CLK_CTRL_PIPE_WIDTH_MASK;
  data |= 0x0 << HPIPE_RST_CLK_CTRL_PIPE_WIDTH_OFFSET;
  /* Set CORE_CLK output frequency for 250Mhz */
  mask |= HPIPE_RST_CLK_CTRL_CORE_FREQ_SEL_MASK;
  data |= 0x0 << HPIPE_RST_CLK_CTRL_CORE_FREQ_SEL_OFFSET;
  reg_set(hpipe_addr + HPIPE_RST_CLK_CTRL_REG, data, mask);

Change the implementation to update semantics by anding data with mask.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Change-Id: Ic72a8f64916274e08baef0b3f4c44a4fa07c1a6c
This commit is contained in:
Marek Behún 2021-12-01 18:11:44 +01:00
parent 4d01bfe665
commit 95c26d6489
1 changed files with 3 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Marvell International Ltd.
* Copyright (C) 2018-2021 Marvell International Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
* https://spdx.org/licenses
@ -147,7 +147,7 @@ static inline void reg_set(uintptr_t addr, uint32_t data, uint32_t mask)
debug("<atf>: WR to addr = 0x%lx, data = 0x%x (mask = 0x%x) - ",
addr, data, mask);
debug("old value = 0x%x ==> ", mmio_read_32(addr));
mmio_clrsetbits_32(addr, mask, data);
mmio_clrsetbits_32(addr, mask, data & mask);
debug("new val 0x%x\n", mmio_read_32(addr));
}
@ -159,7 +159,7 @@ static inline void __unused reg_set16(uintptr_t addr, uint16_t data,
debug("<atf>: WR to addr = 0x%lx, data = 0x%x (mask = 0x%x) - ",
addr, data, mask);
debug("old value = 0x%x ==> ", mmio_read_16(addr));
mmio_clrsetbits_16(addr, mask, data);
mmio_clrsetbits_16(addr, mask, data & mask);
debug("new val 0x%x\n", mmio_read_16(addr));
}