aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1271_spi.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_spi.h')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_spi.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_spi.h b/drivers/net/wireless/wl12xx/wl1271_spi.h
new file mode 100644
index 000000000000..2c9968458646
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/wl1271_spi.h
@@ -0,0 +1,113 @@
1/*
2 * This file is part of wl1271
3 *
4 * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
5 * Copyright (C) 2008-2009 Nokia Corporation
6 *
7 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
8 *
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.
12 *
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.
17 *
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
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef __WL1271_SPI_H__
26#define __WL1271_SPI_H__
27
28#include "wl1271_reg.h"
29
30#define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0
31
32#define HW_ACCESS_PART0_SIZE_ADDR 0x1FFC0
33#define HW_ACCESS_PART0_START_ADDR 0x1FFC4
34#define HW_ACCESS_PART1_SIZE_ADDR 0x1FFC8
35#define HW_ACCESS_PART1_START_ADDR 0x1FFCC
36
37#define HW_ACCESS_REGISTER_SIZE 4
38
39#define HW_ACCESS_PRAM_MAX_RANGE 0x3c000
40
41#define WSPI_CMD_READ 0x40000000
42#define WSPI_CMD_WRITE 0x00000000
43#define WSPI_CMD_FIXED 0x20000000
44#define WSPI_CMD_BYTE_LENGTH 0x1FFE0000
45#define WSPI_CMD_BYTE_LENGTH_OFFSET 17
46#define WSPI_CMD_BYTE_ADDR 0x0001FFFF
47
48#define WSPI_INIT_CMD_CRC_LEN 5
49
50#define WSPI_INIT_CMD_START 0x00
51#define WSPI_INIT_CMD_TX 0x40
52/* the extra bypass bit is sampled by the TNET as '1' */
53#define WSPI_INIT_CMD_BYPASS_BIT 0x80
54#define WSPI_INIT_CMD_FIXEDBUSY_LEN 0x07
55#define WSPI_INIT_CMD_EN_FIXEDBUSY 0x80
56#define WSPI_INIT_CMD_DIS_FIXEDBUSY 0x00
57#define WSPI_INIT_CMD_IOD 0x40
58#define WSPI_INIT_CMD_IP 0x20
59#define WSPI_INIT_CMD_CS 0x10
60#define WSPI_INIT_CMD_WS 0x08
61#define WSPI_INIT_CMD_WSPI 0x01
62#define WSPI_INIT_CMD_END 0x01
63
64#define WSPI_INIT_CMD_LEN 8
65
66#define HW_ACCESS_WSPI_FIXED_BUSY_LEN \
67 ((WL1271_BUSY_WORD_LEN - 4) / sizeof(u32))
68#define HW_ACCESS_WSPI_INIT_CMD_MASK 0
69
70
71/* Raw target IO, address is not translated */
72void wl1271_spi_write(struct wl1271 *wl, int addr, void *buf,
73 size_t len, bool fixed);
74void wl1271_spi_read(struct wl1271 *wl, int addr, void *buf,
75 size_t len, bool fixed);
76
77/* Memory target IO, address is tranlated to partition 0 */
78void wl1271_spi_mem_read(struct wl1271 *wl, int addr, void *buf, size_t len);
79void wl1271_spi_mem_write(struct wl1271 *wl, int addr, void *buf, size_t len);
80u32 wl1271_mem_read32(struct wl1271 *wl, int addr);
81void wl1271_mem_write32(struct wl1271 *wl, int addr, u32 val);
82
83/* Registers IO */
84void wl1271_spi_reg_read(struct wl1271 *wl, int addr, void *buf, size_t len,
85 bool fixed);
86void wl1271_spi_reg_write(struct wl1271 *wl, int addr, void *buf, size_t len,
87 bool fixed);
88u32 wl1271_reg_read32(struct wl1271 *wl, int addr);
89void wl1271_reg_write32(struct wl1271 *wl, int addr, u32 val);
90
91/* INIT and RESET words */
92void wl1271_spi_reset(struct wl1271 *wl);
93void wl1271_spi_init(struct wl1271 *wl);
94int wl1271_set_partition(struct wl1271 *wl,
95 u32 part_start, u32 part_size,
96 u32 reg_start, u32 reg_size);
97
98static inline u32 wl1271_read32(struct wl1271 *wl, int addr)
99{
100 wl1271_spi_read(wl, addr, &wl->buffer_32,
101 sizeof(wl->buffer_32), false);
102
103 return wl->buffer_32;
104}
105
106static inline void wl1271_write32(struct wl1271 *wl, int addr, u32 val)
107{
108 wl->buffer_32 = val;
109 wl1271_spi_write(wl, addr, &wl->buffer_32,
110 sizeof(wl->buffer_32), false);
111}
112
113#endif /* __WL1271_SPI_H__ */