summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ti/wl18xx/io.c
blob: 598c057e722b0db4eb177128ea4736e96699317e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * This file is part of wl18xx
 *
 * Copyright (C) 2011 Texas Instruments
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#include "../wlcore/wlcore.h"
#include "../wlcore/io.h"

#include "io.h"

void wl18xx_top_reg_write(struct wl1271 *wl, int addr, u16 val)
{
	u32 tmp;

	if (WARN_ON(addr % 2))
		return;

	if ((addr % 4) == 0) {
		tmp = wl1271_read32(wl, addr);
		tmp = (tmp & 0xffff0000) | val;
		wl1271_write32(wl, addr, tmp);
	} else {
		tmp = wl1271_read32(wl, addr - 2);
		tmp = (tmp & 0xffff) | (val << 16);
		wl1271_write32(wl, addr - 2, tmp);
	}
}

u16 wl18xx_top_reg_read(struct wl1271 *wl, int addr)
{
	u32 val;

	if (WARN_ON(addr % 2))
		return 0;

	if ((addr % 4) == 0) {
		/* address is 4-bytes aligned */
		val = wl1271_read32(wl, addr);
		return val & 0xffff;
	} else {
		val = wl1271_read32(wl, addr - 2);
		return (val & 0xffff0000) >> 16;
	}
}
OpenPOWER on IntegriCloud