2 * This file is part of wl12xx
4 * Copyright (C) 2008 Nokia Corporation
6 * Contact: Kalle Valo <kalle.valo@nokia.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 #include "wl1251_io.h"
28 static int wl1251_translate_reg_addr(struct wl1251 *wl, int addr)
30 /* If the address is lower than REGISTERS_BASE, it means that this is
31 * a chip-specific register address, so look it up in the registers
33 if (addr < REGISTERS_BASE) {
34 /* Make sure we don't go over the table */
35 if (addr >= ACX_REG_TABLE_LEN) {
36 wl1251_error("address out of range (%d)", addr);
39 addr = wl->chip.acx_reg_table[addr];
42 return addr - wl->physical_reg_addr + wl->virtual_reg_addr;
45 static int wl1251_translate_mem_addr(struct wl1251 *wl, int addr)
47 return addr - wl->physical_mem_addr + wl->virtual_mem_addr;
50 void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len)
54 physical = wl1251_translate_mem_addr(wl, addr);
56 wl->if_ops->read(wl, physical, buf, len);
59 void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len)
63 physical = wl1251_translate_mem_addr(wl, addr);
65 wl->if_ops->write(wl, physical, buf, len);
68 u32 wl1251_mem_read32(struct wl1251 *wl, int addr)
70 return wl1251_read32(wl, wl1251_translate_mem_addr(wl, addr));
73 void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val)
75 wl1251_write32(wl, wl1251_translate_mem_addr(wl, addr), val);
78 u32 wl1251_reg_read32(struct wl1251 *wl, int addr)
80 return wl1251_read32(wl, wl1251_translate_reg_addr(wl, addr));
83 void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val)
85 wl1251_write32(wl, wl1251_translate_reg_addr(wl, addr), val);