Lines Matching refs:wdev
20 static int wfx_read32(struct wfx_dev *wdev, int reg, u32 *val)
28 ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, reg, tmp, sizeof(u32));
33 dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret);
37 static int wfx_write32(struct wfx_dev *wdev, int reg, u32 val)
45 ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, reg, tmp, sizeof(u32));
48 dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret);
52 static int wfx_read32_locked(struct wfx_dev *wdev, int reg, u32 *val)
56 wdev->hwbus_ops->lock(wdev->hwbus_priv);
57 ret = wfx_read32(wdev, reg, val);
59 wdev->hwbus_ops->unlock(wdev->hwbus_priv);
63 static int wfx_write32_locked(struct wfx_dev *wdev, int reg, u32 val)
67 wdev->hwbus_ops->lock(wdev->hwbus_priv);
68 ret = wfx_write32(wdev, reg, val);
70 wdev->hwbus_ops->unlock(wdev->hwbus_priv);
74 static int wfx_write32_bits_locked(struct wfx_dev *wdev, int reg, u32 mask, u32 val)
81 wdev->hwbus_ops->lock(wdev->hwbus_priv);
82 ret = wfx_read32(wdev, reg, &val_r);
88 ret = wfx_write32(wdev, reg, val_w);
92 wdev->hwbus_ops->unlock(wdev->hwbus_priv);
96 static int wfx_indirect_read(struct wfx_dev *wdev, int reg, u32 addr, void *buf, size_t len)
113 ret = wfx_write32(wdev, WFX_REG_BASE_ADDR, addr);
117 ret = wfx_read32(wdev, WFX_REG_CONFIG, &cfg);
121 ret = wfx_write32(wdev, WFX_REG_CONFIG, cfg | prefetch);
126 ret = wfx_read32(wdev, WFX_REG_CONFIG, &cfg);
138 ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, reg, buf, len);
146 static int wfx_indirect_write(struct wfx_dev *wdev, int reg, u32 addr,
153 ret = wfx_write32(wdev, WFX_REG_BASE_ADDR, addr);
157 return wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, reg, buf, len);
160 static int wfx_indirect_read_locked(struct wfx_dev *wdev, int reg, u32 addr,
165 wdev->hwbus_ops->lock(wdev->hwbus_priv);
166 ret = wfx_indirect_read(wdev, reg, addr, buf, len);
168 wdev->hwbus_ops->unlock(wdev->hwbus_priv);
172 static int wfx_indirect_write_locked(struct wfx_dev *wdev, int reg, u32 addr,
177 wdev->hwbus_ops->lock(wdev->hwbus_priv);
178 ret = wfx_indirect_write(wdev, reg, addr, buf, len);
180 wdev->hwbus_ops->unlock(wdev->hwbus_priv);
184 static int wfx_indirect_read32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 *val)
191 wdev->hwbus_ops->lock(wdev->hwbus_priv);
192 ret = wfx_indirect_read(wdev, reg, addr, tmp, sizeof(u32));
195 wdev->hwbus_ops->unlock(wdev->hwbus_priv);
200 static int wfx_indirect_write32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 val)
208 wdev->hwbus_ops->lock(wdev->hwbus_priv);
209 ret = wfx_indirect_write(wdev, reg, addr, tmp, sizeof(u32));
211 wdev->hwbus_ops->unlock(wdev->hwbus_priv);
216 int wfx_data_read(struct wfx_dev *wdev, void *buf, size_t len)
221 wdev->hwbus_ops->lock(wdev->hwbus_priv);
222 ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, WFX_REG_IN_OUT_QUEUE, buf, len);
224 wdev->hwbus_ops->unlock(wdev->hwbus_priv);
226 dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret);
230 int wfx_data_write(struct wfx_dev *wdev, const void *buf, size_t len)
235 wdev->hwbus_ops->lock(wdev->hwbus_priv);
236 ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, WFX_REG_IN_OUT_QUEUE, buf, len);
238 wdev->hwbus_ops->unlock(wdev->hwbus_priv);
240 dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret);
244 int wfx_sram_buf_read(struct wfx_dev *wdev, u32 addr, void *buf, size_t len)
246 return wfx_indirect_read_locked(wdev, WFX_REG_SRAM_DPORT, addr, buf, len);
249 int wfx_ahb_buf_read(struct wfx_dev *wdev, u32 addr, void *buf, size_t len)
251 return wfx_indirect_read_locked(wdev, WFX_REG_AHB_DPORT, addr, buf, len);
254 int wfx_sram_buf_write(struct wfx_dev *wdev, u32 addr, const void *buf, size_t len)
256 return wfx_indirect_write_locked(wdev, WFX_REG_SRAM_DPORT, addr, buf, len);
259 int wfx_ahb_buf_write(struct wfx_dev *wdev, u32 addr, const void *buf, size_t len)
261 return wfx_indirect_write_locked(wdev, WFX_REG_AHB_DPORT, addr, buf, len);
264 int wfx_sram_reg_read(struct wfx_dev *wdev, u32 addr, u32 *val)
266 return wfx_indirect_read32_locked(wdev, WFX_REG_SRAM_DPORT, addr, val);
269 int wfx_ahb_reg_read(struct wfx_dev *wdev, u32 addr, u32 *val)
271 return wfx_indirect_read32_locked(wdev, WFX_REG_AHB_DPORT, addr, val);
274 int wfx_sram_reg_write(struct wfx_dev *wdev, u32 addr, u32 val)
276 return wfx_indirect_write32_locked(wdev, WFX_REG_SRAM_DPORT, addr, val);
279 int wfx_ahb_reg_write(struct wfx_dev *wdev, u32 addr, u32 val)
281 return wfx_indirect_write32_locked(wdev, WFX_REG_AHB_DPORT, addr, val);
284 int wfx_config_reg_read(struct wfx_dev *wdev, u32 *val)
286 return wfx_read32_locked(wdev, WFX_REG_CONFIG, val);
289 int wfx_config_reg_write(struct wfx_dev *wdev, u32 val)
291 return wfx_write32_locked(wdev, WFX_REG_CONFIG, val);
294 int wfx_config_reg_write_bits(struct wfx_dev *wdev, u32 mask, u32 val)
296 return wfx_write32_bits_locked(wdev, WFX_REG_CONFIG, mask, val);
299 int wfx_control_reg_read(struct wfx_dev *wdev, u32 *val)
301 return wfx_read32_locked(wdev, WFX_REG_CONTROL, val);
304 int wfx_control_reg_write(struct wfx_dev *wdev, u32 val)
306 return wfx_write32_locked(wdev, WFX_REG_CONTROL, val);
309 int wfx_control_reg_write_bits(struct wfx_dev *wdev, u32 mask, u32 val)
311 return wfx_write32_bits_locked(wdev, WFX_REG_CONTROL, mask, val);
314 int wfx_igpr_reg_read(struct wfx_dev *wdev, int index, u32 *val)
319 ret = wfx_write32_locked(wdev, WFX_REG_SET_GEN_R_W, IGPR_RW | index << 24);
322 ret = wfx_read32_locked(wdev, WFX_REG_SET_GEN_R_W, val);
329 int wfx_igpr_reg_write(struct wfx_dev *wdev, int index, u32 val)
331 return wfx_write32_locked(wdev, WFX_REG_SET_GEN_R_W, index << 24 | val);