2 * This file is part of wl1271
4 * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
5 * Copyright (C) 2008-2010 Nokia Corporation
7 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 #ifndef __WL1271_IO_H__
26 #define __WL1271_IO_H__
30 void wl1271_disable_interrupts(struct wl1271 *wl);
31 void wl1271_enable_interrupts(struct wl1271 *wl);
33 void wl1271_io_reset(struct wl1271 *wl);
34 void wl1271_io_init(struct wl1271 *wl);
36 static inline struct device *wl1271_wl_to_dev(struct wl1271 *wl)
38 return wl->if_ops->dev(wl);
42 /* Raw target IO, address is not translated */
43 static inline void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf,
44 size_t len, bool fixed)
46 wl->if_ops->write(wl, addr, buf, len, fixed);
49 static inline void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf,
50 size_t len, bool fixed)
52 wl->if_ops->read(wl, addr, buf, len, fixed);
55 static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr)
57 wl1271_raw_read(wl, addr, &wl->buffer_32,
58 sizeof(wl->buffer_32), false);
63 static inline void wl1271_raw_write32(struct wl1271 *wl, int addr, u32 val)
66 wl1271_raw_write(wl, addr, &wl->buffer_32,
67 sizeof(wl->buffer_32), false);
70 /* Translated target IO */
71 static inline int wl1271_translate_addr(struct wl1271 *wl, int addr)
74 * To translate, first check to which window of addresses the
75 * particular address belongs. Then subtract the starting address
76 * of that window from the address. Then, add offset of the
79 * The translated regions occur next to each other in physical device
80 * memory, so just add the sizes of the preceeding address regions to
81 * get the offset to the new region.
83 * Currently, only the two first regions are addressed, and the
84 * assumption is that all addresses will fall into either of those
87 if ((addr >= wl->part.reg.start) &&
88 (addr < wl->part.reg.start + wl->part.reg.size))
89 return addr - wl->part.reg.start + wl->part.mem.size;
91 return addr - wl->part.mem.start;
94 static inline void wl1271_read(struct wl1271 *wl, int addr, void *buf,
95 size_t len, bool fixed)
99 physical = wl1271_translate_addr(wl, addr);
101 wl1271_raw_read(wl, physical, buf, len, fixed);
104 static inline void wl1271_write(struct wl1271 *wl, int addr, void *buf,
105 size_t len, bool fixed)
109 physical = wl1271_translate_addr(wl, addr);
111 wl1271_raw_write(wl, physical, buf, len, fixed);
114 static inline u32 wl1271_read32(struct wl1271 *wl, int addr)
116 return wl1271_raw_read32(wl, wl1271_translate_addr(wl, addr));
119 static inline void wl1271_write32(struct wl1271 *wl, int addr, u32 val)
121 wl1271_raw_write32(wl, wl1271_translate_addr(wl, addr), val);
125 /* Top Register IO */
126 void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val);
127 u16 wl1271_top_reg_read(struct wl1271 *wl, int addr);
129 int wl1271_set_partition(struct wl1271 *wl,
130 struct wl1271_partition_set *p);
132 /* Functions from wl1271_main.c */
134 int wl1271_register_hw(struct wl1271 *wl);
135 int wl1271_init_ieee80211(struct wl1271 *wl);
136 struct ieee80211_hw *wl1271_alloc_hw(void);
137 int wl1271_free_hw(struct wl1271 *wl);