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#ifndef __IO_H__
26#define __IO_H__
27
28#include <linux/irqreturn.h>
29#include "reg.h"
30
31#define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0
32
33#define HW_PARTITION_REGISTERS_ADDR 0x1FFC0
34#define HW_PART0_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR)
35#define HW_PART0_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 4)
36#define HW_PART1_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR + 8)
37#define HW_PART1_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 12)
38#define HW_PART2_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR + 16)
39#define HW_PART2_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 20)
40#define HW_PART3_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 24)
41
42#define HW_ACCESS_REGISTER_SIZE 4
43
44#define HW_ACCESS_PRAM_MAX_RANGE 0x3c000
45
46struct wl1271;
47
48void wl1271_disable_interrupts(struct wl1271 *wl);
49void wl1271_enable_interrupts(struct wl1271 *wl);
50
51void wl1271_io_reset(struct wl1271 *wl);
52void wl1271_io_init(struct wl1271 *wl);
53
54static inline struct device *wl1271_wl_to_dev(struct wl1271 *wl)
55{
56 return wl->if_ops->dev(wl);
57}
58
59
60
61static inline void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf,
62 size_t len, bool fixed)
63{
64 wl->if_ops->write(wl, addr, buf, len, fixed);
65}
66
67static inline void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf,
68 size_t len, bool fixed)
69{
70 wl->if_ops->read(wl, addr, buf, len, fixed);
71}
72
73static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr)
74{
75 wl1271_raw_read(wl, addr, &wl->buffer_32,
76 sizeof(wl->buffer_32), false);
77
78 return le32_to_cpu(wl->buffer_32);
79}
80
81static inline void wl1271_raw_write32(struct wl1271 *wl, int addr, u32 val)
82{
83 wl->buffer_32 = cpu_to_le32(val);
84 wl1271_raw_write(wl, addr, &wl->buffer_32,
85 sizeof(wl->buffer_32), false);
86}
87
88
89static inline int wl1271_translate_addr(struct wl1271 *wl, int addr)
90{
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 if ((addr >= wl->part.reg.start) &&
106 (addr < wl->part.reg.start + wl->part.reg.size))
107 return addr - wl->part.reg.start + wl->part.mem.size;
108 else
109 return addr - wl->part.mem.start;
110}
111
112static inline void wl1271_read(struct wl1271 *wl, int addr, void *buf,
113 size_t len, bool fixed)
114{
115 int physical;
116
117 physical = wl1271_translate_addr(wl, addr);
118
119 wl1271_raw_read(wl, physical, buf, len, fixed);
120}
121
122static inline void wl1271_write(struct wl1271 *wl, int addr, void *buf,
123 size_t len, bool fixed)
124{
125 int physical;
126
127 physical = wl1271_translate_addr(wl, addr);
128
129 wl1271_raw_write(wl, physical, buf, len, fixed);
130}
131
132static inline void wl1271_read_hwaddr(struct wl1271 *wl, int hwaddr,
133 void *buf, size_t len, bool fixed)
134{
135 int physical;
136 int addr;
137
138
139 addr = hwaddr << 5;
140
141 physical = wl1271_translate_addr(wl, addr);
142
143 wl1271_raw_read(wl, physical, buf, len, fixed);
144}
145
146static inline u32 wl1271_read32(struct wl1271 *wl, int addr)
147{
148 return wl1271_raw_read32(wl, wl1271_translate_addr(wl, addr));
149}
150
151static inline void wl1271_write32(struct wl1271 *wl, int addr, u32 val)
152{
153 wl1271_raw_write32(wl, wl1271_translate_addr(wl, addr), val);
154}
155
156static inline void wl1271_power_off(struct wl1271 *wl)
157{
158 wl->if_ops->power(wl, false);
159 clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
160}
161
162static inline int wl1271_power_on(struct wl1271 *wl)
163{
164 int ret = wl->if_ops->power(wl, true);
165 if (ret == 0)
166 set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
167
168 return ret;
169}
170
171
172
173void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val);
174u16 wl1271_top_reg_read(struct wl1271 *wl, int addr);
175
176int wl1271_set_partition(struct wl1271 *wl,
177 struct wl1271_partition_set *p);
178
179
180
181int wl1271_register_hw(struct wl1271 *wl);
182void wl1271_unregister_hw(struct wl1271 *wl);
183int wl1271_init_ieee80211(struct wl1271 *wl);
184struct ieee80211_hw *wl1271_alloc_hw(void);
185int wl1271_free_hw(struct wl1271 *wl);
186irqreturn_t wl1271_irq(int irq, void *data);
187bool wl1271_set_block_size(struct wl1271 *wl);
188int wl1271_tx_dummy_packet(struct wl1271 *wl);
189void wl1271_configure_filters(struct wl1271 *wl, unsigned int filters);
190
191#endif
192