1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * This file is part of wl12xx
5 * Copyright (C) 2008 Nokia Corporation
7 #ifndef __WL1251_IO_H__
8 #define __WL1251_IO_H__
12 #define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0
14 #define HW_ACCESS_PART0_SIZE_ADDR 0x1FFC0
15 #define HW_ACCESS_PART0_START_ADDR 0x1FFC4
16 #define HW_ACCESS_PART1_SIZE_ADDR 0x1FFC8
17 #define HW_ACCESS_PART1_START_ADDR 0x1FFCC
19 #define HW_ACCESS_REGISTER_SIZE 4
21 #define HW_ACCESS_PRAM_MAX_RANGE 0x3c000
23 static inline u32
wl1251_read32(struct wl1251
*wl
, int addr
)
25 wl
->if_ops
->read(wl
, addr
, &wl
->buffer_32
, sizeof(wl
->buffer_32
));
27 return le32_to_cpu(wl
->buffer_32
);
30 static inline void wl1251_write32(struct wl1251
*wl
, int addr
, u32 val
)
32 wl
->buffer_32
= cpu_to_le32(val
);
33 wl
->if_ops
->write(wl
, addr
, &wl
->buffer_32
, sizeof(wl
->buffer_32
));
36 static inline u32
wl1251_read_elp(struct wl1251
*wl
, int addr
)
40 if (wl
->if_ops
->read_elp
)
41 wl
->if_ops
->read_elp(wl
, addr
, &response
);
43 wl
->if_ops
->read(wl
, addr
, &response
, sizeof(u32
));
48 static inline void wl1251_write_elp(struct wl1251
*wl
, int addr
, u32 val
)
50 if (wl
->if_ops
->write_elp
)
51 wl
->if_ops
->write_elp(wl
, addr
, val
);
53 wl
->if_ops
->write(wl
, addr
, &val
, sizeof(u32
));
56 /* Memory target IO, address is translated to partition 0 */
57 void wl1251_mem_read(struct wl1251
*wl
, int addr
, void *buf
, size_t len
);
58 void wl1251_mem_write(struct wl1251
*wl
, int addr
, void *buf
, size_t len
);
59 u32
wl1251_mem_read32(struct wl1251
*wl
, int addr
);
60 void wl1251_mem_write32(struct wl1251
*wl
, int addr
, u32 val
);
62 u32
wl1251_reg_read32(struct wl1251
*wl
, int addr
);
63 void wl1251_reg_write32(struct wl1251
*wl
, int addr
, u32 val
);
65 void wl1251_set_partition(struct wl1251
*wl
,
66 u32 part_start
, u32 part_size
,
67 u32 reg_start
, u32 reg_size
);