1 // SPDX-License-Identifier: GPL-2.0-only
3 * This file is part of wl18xx
5 * Copyright (C) 2011 Texas Instruments
8 #include "../wlcore/wlcore.h"
9 #include "../wlcore/io.h"
13 int wl18xx_top_reg_write(struct wl1271 *wl, int addr, u16 val)
18 if (WARN_ON(addr % 2))
21 if ((addr % 4) == 0) {
22 ret = wlcore_read32(wl, addr, &tmp);
26 tmp = (tmp & 0xffff0000) | val;
27 ret = wlcore_write32(wl, addr, tmp);
29 ret = wlcore_read32(wl, addr - 2, &tmp);
33 tmp = (tmp & 0xffff) | (val << 16);
34 ret = wlcore_write32(wl, addr - 2, tmp);
41 int wl18xx_top_reg_read(struct wl1271 *wl, int addr, u16 *out)
46 if (WARN_ON(addr % 2))
49 if ((addr % 4) == 0) {
50 /* address is 4-bytes aligned */
51 ret = wlcore_read32(wl, addr, &val);
55 ret = wlcore_read32(wl, addr - 2, &val);
57 *out = (val & 0xffff0000) >> 16;