2 * This file is part of wl18xx
4 * Copyright (C) 2011 Texas Instruments
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 #include "../wlcore/wlcore.h"
23 #include "../wlcore/io.h"
27 int wl18xx_top_reg_write(struct wl1271
*wl
, int addr
, u16 val
)
32 if (WARN_ON(addr
% 2))
35 if ((addr
% 4) == 0) {
36 ret
= wlcore_read32(wl
, addr
, &tmp
);
40 tmp
= (tmp
& 0xffff0000) | val
;
41 ret
= wlcore_write32(wl
, addr
, tmp
);
43 ret
= wlcore_read32(wl
, addr
- 2, &tmp
);
47 tmp
= (tmp
& 0xffff) | (val
<< 16);
48 ret
= wlcore_write32(wl
, addr
- 2, tmp
);
55 int wl18xx_top_reg_read(struct wl1271
*wl
, int addr
, u16
*out
)
60 if (WARN_ON(addr
% 2))
63 if ((addr
% 4) == 0) {
64 /* address is 4-bytes aligned */
65 ret
= wlcore_read32(wl
, addr
, &val
);
69 ret
= wlcore_read32(wl
, addr
- 2, &val
);
71 *out
= (val
& 0xffff0000) >> 16;