18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * This file is part of wl12xx
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2008 Nokia Corporation
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#ifndef __WL1251_IO_H__
88c2ecf20Sopenharmony_ci#define __WL1251_IO_H__
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include "wl1251.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define HW_ACCESS_MEMORY_MAX_RANGE		0x1FFC0
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define HW_ACCESS_PART0_SIZE_ADDR           0x1FFC0
158c2ecf20Sopenharmony_ci#define HW_ACCESS_PART0_START_ADDR          0x1FFC4
168c2ecf20Sopenharmony_ci#define HW_ACCESS_PART1_SIZE_ADDR           0x1FFC8
178c2ecf20Sopenharmony_ci#define HW_ACCESS_PART1_START_ADDR          0x1FFCC
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define HW_ACCESS_REGISTER_SIZE             4
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define HW_ACCESS_PRAM_MAX_RANGE		0x3c000
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_cistatic inline u32 wl1251_read32(struct wl1251 *wl, int addr)
248c2ecf20Sopenharmony_ci{
258c2ecf20Sopenharmony_ci	wl->if_ops->read(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32));
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci	return le32_to_cpu(wl->buffer_32);
288c2ecf20Sopenharmony_ci}
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistatic inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val)
318c2ecf20Sopenharmony_ci{
328c2ecf20Sopenharmony_ci	wl->buffer_32 = cpu_to_le32(val);
338c2ecf20Sopenharmony_ci	wl->if_ops->write(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32));
348c2ecf20Sopenharmony_ci}
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistatic inline u32 wl1251_read_elp(struct wl1251 *wl, int addr)
378c2ecf20Sopenharmony_ci{
388c2ecf20Sopenharmony_ci	u32 response;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci	if (wl->if_ops->read_elp)
418c2ecf20Sopenharmony_ci		wl->if_ops->read_elp(wl, addr, &response);
428c2ecf20Sopenharmony_ci	else
438c2ecf20Sopenharmony_ci		wl->if_ops->read(wl, addr, &response, sizeof(u32));
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	return response;
468c2ecf20Sopenharmony_ci}
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cistatic inline void wl1251_write_elp(struct wl1251 *wl, int addr, u32 val)
498c2ecf20Sopenharmony_ci{
508c2ecf20Sopenharmony_ci	if (wl->if_ops->write_elp)
518c2ecf20Sopenharmony_ci		wl->if_ops->write_elp(wl, addr, val);
528c2ecf20Sopenharmony_ci	else
538c2ecf20Sopenharmony_ci		wl->if_ops->write(wl, addr, &val, sizeof(u32));
548c2ecf20Sopenharmony_ci}
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* Memory target IO, address is translated to partition 0 */
578c2ecf20Sopenharmony_civoid wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len);
588c2ecf20Sopenharmony_civoid wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len);
598c2ecf20Sopenharmony_ciu32 wl1251_mem_read32(struct wl1251 *wl, int addr);
608c2ecf20Sopenharmony_civoid wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val);
618c2ecf20Sopenharmony_ci/* Registers IO */
628c2ecf20Sopenharmony_ciu32 wl1251_reg_read32(struct wl1251 *wl, int addr);
638c2ecf20Sopenharmony_civoid wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val);
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_civoid wl1251_set_partition(struct wl1251 *wl,
668c2ecf20Sopenharmony_ci			  u32 part_start, u32 part_size,
678c2ecf20Sopenharmony_ci			  u32 reg_start,  u32 reg_size);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#endif
70