1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#include "../wlcore/wlcore.h"
23#include "../wlcore/io.h"
24
25#include "io.h"
26
27int wl18xx_top_reg_write(struct wl1271 *wl, int addr, u16 val)
28{
29 u32 tmp;
30 int ret;
31
32 if (WARN_ON(addr % 2))
33 return -EINVAL;
34
35 if ((addr % 4) == 0) {
36 ret = wlcore_read32(wl, addr, &tmp);
37 if (ret < 0)
38 goto out;
39
40 tmp = (tmp & 0xffff0000) | val;
41 ret = wlcore_write32(wl, addr, tmp);
42 } else {
43 ret = wlcore_read32(wl, addr - 2, &tmp);
44 if (ret < 0)
45 goto out;
46
47 tmp = (tmp & 0xffff) | (val << 16);
48 ret = wlcore_write32(wl, addr - 2, tmp);
49 }
50
51out:
52 return ret;
53}
54
55int wl18xx_top_reg_read(struct wl1271 *wl, int addr, u16 *out)
56{
57 u32 val = 0;
58 int ret;
59
60 if (WARN_ON(addr % 2))
61 return -EINVAL;
62
63 if ((addr % 4) == 0) {
64
65 ret = wlcore_read32(wl, addr, &val);
66 if (ret >= 0 && out)
67 *out = val & 0xffff;
68 } else {
69 ret = wlcore_read32(wl, addr - 2, &val);
70 if (ret >= 0 && out)
71 *out = (val & 0xffff0000) >> 16;
72 }
73
74 return ret;
75}
76