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
28 #include <linux/irqreturn.h>
30 #define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0
32 #define HW_PARTITION_REGISTERS_ADDR 0x1FFC0
33 #define HW_PART0_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR)
34 #define HW_PART0_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 4)
35 #define HW_PART1_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR + 8)
36 #define HW_PART1_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 12)
37 #define HW_PART2_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR + 16)
38 #define HW_PART2_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 20)
39 #define HW_PART3_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 24)
41 #define HW_ACCESS_REGISTER_SIZE 4
43 #define HW_ACCESS_PRAM_MAX_RANGE 0x3c000
47 void wlcore_disable_interrupts(struct wl1271 *wl);
48 void wlcore_enable_interrupts(struct wl1271 *wl);
50 void wl1271_io_reset(struct wl1271 *wl);
51 void wl1271_io_init(struct wl1271 *wl);
52 int wlcore_translate_addr(struct wl1271 *wl, int addr);
54 /* Raw target IO, address is not translated */
55 static inline void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf,
56 size_t len, bool fixed)
58 wl->if_ops->write(wl->dev, addr, buf, len, fixed);
61 static inline void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf,
62 size_t len, bool fixed)
64 wl->if_ops->read(wl->dev, addr, buf, len, fixed);
67 static inline void wlcore_raw_read_data(struct wl1271 *wl, int reg, void *buf,
68 size_t len, bool fixed)
70 wl1271_raw_read(wl, wl->rtable[reg], buf, len, fixed);
73 static inline void wlcore_raw_write_data(struct wl1271 *wl, int reg, void *buf,
74 size_t len, bool fixed)
76 wl1271_raw_write(wl, wl->rtable[reg], buf, len, fixed);
79 static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr)
81 wl1271_raw_read(wl, addr, &wl->buffer_32,
82 sizeof(wl->buffer_32), false);
84 return le32_to_cpu(wl->buffer_32);
87 static inline void wl1271_raw_write32(struct wl1271 *wl, int addr, u32 val)
89 wl->buffer_32 = cpu_to_le32(val);
90 wl1271_raw_write(wl, addr, &wl->buffer_32,
91 sizeof(wl->buffer_32), false);
94 static inline void wl1271_read(struct wl1271 *wl, int addr, void *buf,
95 size_t len, bool fixed)
99 physical = wlcore_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 = wlcore_translate_addr(wl, addr);
111 wl1271_raw_write(wl, physical, buf, len, fixed);
114 static inline void wlcore_write_data(struct wl1271 *wl, int reg, void *buf,
115 size_t len, bool fixed)
117 wl1271_write(wl, wl->rtable[reg], buf, len, fixed);
120 static inline void wlcore_read_data(struct wl1271 *wl, int reg, void *buf,
121 size_t len, bool fixed)
123 wl1271_read(wl, wl->rtable[reg], buf, len, fixed);
126 static inline void wl1271_read_hwaddr(struct wl1271 *wl, int hwaddr,
127 void *buf, size_t len, bool fixed)
132 /* Addresses are stored internally as addresses to 32 bytes blocks */
135 physical = wlcore_translate_addr(wl, addr);
137 wl1271_raw_read(wl, physical, buf, len, fixed);
140 static inline u32 wl1271_read32(struct wl1271 *wl, int addr)
142 return wl1271_raw_read32(wl, wlcore_translate_addr(wl, addr));
145 static inline void wl1271_write32(struct wl1271 *wl, int addr, u32 val)
147 wl1271_raw_write32(wl, wlcore_translate_addr(wl, addr), val);
150 static inline u32 wlcore_read_reg(struct wl1271 *wl, int reg)
152 return wl1271_raw_read32(wl,
153 wlcore_translate_addr(wl, wl->rtable[reg]));
156 static inline void wlcore_write_reg(struct wl1271 *wl, int reg, u32 val)
158 wl1271_raw_write32(wl, wlcore_translate_addr(wl, wl->rtable[reg]), val);
161 static inline void wl1271_power_off(struct wl1271 *wl)
163 wl->if_ops->power(wl->dev, false);
164 clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
167 static inline int wl1271_power_on(struct wl1271 *wl)
169 int ret = wl->if_ops->power(wl->dev, true);
171 set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
176 void wlcore_set_partition(struct wl1271 *wl,
177 const struct wlcore_partition_set *p);
179 bool wl1271_set_block_size(struct wl1271 *wl);
181 /* Functions from wl1271_main.c */
183 int wl1271_tx_dummy_packet(struct wl1271 *wl);
185 void wlcore_select_partition(struct wl1271 *wl, u8 part);