ARM: mm: Recreate kernel mappings in early_paging_init()
[linux/fpc-iii.git] / drivers / net / wireless / ti / wl18xx / io.c
blobf0abf3ef2c95c22c53a988f4ab38d84cd58800e8
1 /*
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
18 * 02110-1301 USA
22 #include "../wlcore/wlcore.h"
23 #include "../wlcore/io.h"
25 #include "io.h"
27 int wl18xx_top_reg_write(struct wl1271 *wl, int addr, u16 val)
29 u32 tmp;
30 int ret;
32 if (WARN_ON(addr % 2))
33 return -EINVAL;
35 if ((addr % 4) == 0) {
36 ret = wlcore_read32(wl, addr, &tmp);
37 if (ret < 0)
38 goto out;
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;
47 tmp = (tmp & 0xffff) | (val << 16);
48 ret = wlcore_write32(wl, addr - 2, tmp);
51 out:
52 return ret;
55 int wl18xx_top_reg_read(struct wl1271 *wl, int addr, u16 *out)
57 u32 val = 0;
58 int ret;
60 if (WARN_ON(addr % 2))
61 return -EINVAL;
63 if ((addr % 4) == 0) {
64 /* address is 4-bytes aligned */
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;
74 return ret;