Lines Matching +full:reg +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Low-level I/O functions.
5 * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
6 * Copyright (c) 2010, ST-Ericsson
20 static int wfx_read32(struct wfx_dev *wdev, int reg, u32 *val) in wfx_read32() argument
27 return -ENOMEM; in wfx_read32()
28 ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, reg, tmp, sizeof(u32)); in wfx_read32()
33 dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); in wfx_read32()
37 static int wfx_write32(struct wfx_dev *wdev, int reg, u32 val) in wfx_write32() argument
43 return -ENOMEM; in wfx_write32()
45 ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, reg, tmp, sizeof(u32)); in wfx_write32()
48 dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); in wfx_write32()
52 static int wfx_read32_locked(struct wfx_dev *wdev, int reg, u32 *val) in wfx_read32_locked() argument
56 wdev->hwbus_ops->lock(wdev->hwbus_priv); in wfx_read32_locked()
57 ret = wfx_read32(wdev, reg, val); in wfx_read32_locked()
58 _trace_io_read32(reg, *val); in wfx_read32_locked()
59 wdev->hwbus_ops->unlock(wdev->hwbus_priv); in wfx_read32_locked()
63 static int wfx_write32_locked(struct wfx_dev *wdev, int reg, u32 val) in wfx_write32_locked() argument
67 wdev->hwbus_ops->lock(wdev->hwbus_priv); in wfx_write32_locked()
68 ret = wfx_write32(wdev, reg, val); in wfx_write32_locked()
69 _trace_io_write32(reg, val); in wfx_write32_locked()
70 wdev->hwbus_ops->unlock(wdev->hwbus_priv); in wfx_write32_locked()
74 static int wfx_write32_bits_locked(struct wfx_dev *wdev, int reg, u32 mask, u32 val) in wfx_write32_bits_locked() argument
81 wdev->hwbus_ops->lock(wdev->hwbus_priv); in wfx_write32_bits_locked()
82 ret = wfx_read32(wdev, reg, &val_r); in wfx_write32_bits_locked()
83 _trace_io_read32(reg, val_r); in wfx_write32_bits_locked()
88 ret = wfx_write32(wdev, reg, val_w); in wfx_write32_bits_locked()
89 _trace_io_write32(reg, val_w); in wfx_write32_bits_locked()
92 wdev->hwbus_ops->unlock(wdev->hwbus_priv); in wfx_write32_bits_locked()
96 static int wfx_indirect_read(struct wfx_dev *wdev, int reg, u32 addr, void *buf, size_t len) in wfx_indirect_read() argument
104 WARN_ON(reg != WFX_REG_AHB_DPORT && reg != WFX_REG_SRAM_DPORT); in wfx_indirect_read()
106 if (reg == WFX_REG_AHB_DPORT) in wfx_indirect_read()
108 else if (reg == WFX_REG_SRAM_DPORT) in wfx_indirect_read()
111 return -ENODEV; in wfx_indirect_read()
113 ret = wfx_write32(wdev, WFX_REG_BASE_ADDR, addr); in wfx_indirect_read()
134 ret = -ETIMEDOUT; in wfx_indirect_read()
138 ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, reg, buf, len); in wfx_indirect_read()
146 static int wfx_indirect_write(struct wfx_dev *wdev, int reg, u32 addr, in wfx_indirect_write() argument
152 WARN_ON(reg != WFX_REG_AHB_DPORT && reg != WFX_REG_SRAM_DPORT); in wfx_indirect_write()
153 ret = wfx_write32(wdev, WFX_REG_BASE_ADDR, addr); in wfx_indirect_write()
157 return wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, reg, buf, len); in wfx_indirect_write()
160 static int wfx_indirect_read_locked(struct wfx_dev *wdev, int reg, u32 addr, in wfx_indirect_read_locked() argument
165 wdev->hwbus_ops->lock(wdev->hwbus_priv); in wfx_indirect_read_locked()
166 ret = wfx_indirect_read(wdev, reg, addr, buf, len); in wfx_indirect_read_locked()
167 _trace_io_ind_read(reg, addr, buf, len); in wfx_indirect_read_locked()
168 wdev->hwbus_ops->unlock(wdev->hwbus_priv); in wfx_indirect_read_locked()
172 static int wfx_indirect_write_locked(struct wfx_dev *wdev, int reg, u32 addr, in wfx_indirect_write_locked() argument
177 wdev->hwbus_ops->lock(wdev->hwbus_priv); in wfx_indirect_write_locked()
178 ret = wfx_indirect_write(wdev, reg, addr, buf, len); in wfx_indirect_write_locked()
179 _trace_io_ind_write(reg, addr, buf, len); in wfx_indirect_write_locked()
180 wdev->hwbus_ops->unlock(wdev->hwbus_priv); in wfx_indirect_write_locked()
184 static int wfx_indirect_read32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 *val) in wfx_indirect_read32_locked() argument
190 return -ENOMEM; in wfx_indirect_read32_locked()
191 wdev->hwbus_ops->lock(wdev->hwbus_priv); in wfx_indirect_read32_locked()
192 ret = wfx_indirect_read(wdev, reg, addr, tmp, sizeof(u32)); in wfx_indirect_read32_locked()
194 _trace_io_ind_read32(reg, addr, *val); in wfx_indirect_read32_locked()
195 wdev->hwbus_ops->unlock(wdev->hwbus_priv); in wfx_indirect_read32_locked()
200 static int wfx_indirect_write32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 val) in wfx_indirect_write32_locked() argument
206 return -ENOMEM; in wfx_indirect_write32_locked()
208 wdev->hwbus_ops->lock(wdev->hwbus_priv); in wfx_indirect_write32_locked()
209 ret = wfx_indirect_write(wdev, reg, addr, tmp, sizeof(u32)); in wfx_indirect_write32_locked()
210 _trace_io_ind_write32(reg, addr, val); in wfx_indirect_write32_locked()
211 wdev->hwbus_ops->unlock(wdev->hwbus_priv); in wfx_indirect_write32_locked()
221 wdev->hwbus_ops->lock(wdev->hwbus_priv); in wfx_data_read()
222 ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, WFX_REG_IN_OUT_QUEUE, buf, len); in wfx_data_read()
224 wdev->hwbus_ops->unlock(wdev->hwbus_priv); in wfx_data_read()
226 dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); in wfx_data_read()
235 wdev->hwbus_ops->lock(wdev->hwbus_priv); in wfx_data_write()
236 ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, WFX_REG_IN_OUT_QUEUE, buf, len); in wfx_data_write()
238 wdev->hwbus_ops->unlock(wdev->hwbus_priv); in wfx_data_write()
240 dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); in wfx_data_write()
244 int wfx_sram_buf_read(struct wfx_dev *wdev, u32 addr, void *buf, size_t len) in wfx_sram_buf_read() argument
246 return wfx_indirect_read_locked(wdev, WFX_REG_SRAM_DPORT, addr, buf, len); in wfx_sram_buf_read()
249 int wfx_ahb_buf_read(struct wfx_dev *wdev, u32 addr, void *buf, size_t len) in wfx_ahb_buf_read() argument
251 return wfx_indirect_read_locked(wdev, WFX_REG_AHB_DPORT, addr, buf, len); in wfx_ahb_buf_read()
254 int wfx_sram_buf_write(struct wfx_dev *wdev, u32 addr, const void *buf, size_t len) in wfx_sram_buf_write() argument
256 return wfx_indirect_write_locked(wdev, WFX_REG_SRAM_DPORT, addr, buf, len); in wfx_sram_buf_write()
259 int wfx_ahb_buf_write(struct wfx_dev *wdev, u32 addr, const void *buf, size_t len) in wfx_ahb_buf_write() argument
261 return wfx_indirect_write_locked(wdev, WFX_REG_AHB_DPORT, addr, buf, len); in wfx_ahb_buf_write()
264 int wfx_sram_reg_read(struct wfx_dev *wdev, u32 addr, u32 *val) in wfx_sram_reg_read() argument
266 return wfx_indirect_read32_locked(wdev, WFX_REG_SRAM_DPORT, addr, val); in wfx_sram_reg_read()
269 int wfx_ahb_reg_read(struct wfx_dev *wdev, u32 addr, u32 *val) in wfx_ahb_reg_read() argument
271 return wfx_indirect_read32_locked(wdev, WFX_REG_AHB_DPORT, addr, val); in wfx_ahb_reg_read()
274 int wfx_sram_reg_write(struct wfx_dev *wdev, u32 addr, u32 val) in wfx_sram_reg_write() argument
276 return wfx_indirect_write32_locked(wdev, WFX_REG_SRAM_DPORT, addr, val); in wfx_sram_reg_write()
279 int wfx_ahb_reg_write(struct wfx_dev *wdev, u32 addr, u32 val) in wfx_ahb_reg_write() argument
281 return wfx_indirect_write32_locked(wdev, WFX_REG_AHB_DPORT, addr, val); in wfx_ahb_reg_write()