162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * This file is part of wl12xx 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2008 Nokia Corporation 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci#ifndef __WL1251_IO_H__ 862306a36Sopenharmony_ci#define __WL1251_IO_H__ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include "wl1251.h" 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#define HW_ACCESS_PART0_SIZE_ADDR 0x1FFC0 1562306a36Sopenharmony_ci#define HW_ACCESS_PART0_START_ADDR 0x1FFC4 1662306a36Sopenharmony_ci#define HW_ACCESS_PART1_SIZE_ADDR 0x1FFC8 1762306a36Sopenharmony_ci#define HW_ACCESS_PART1_START_ADDR 0x1FFCC 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define HW_ACCESS_REGISTER_SIZE 4 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#define HW_ACCESS_PRAM_MAX_RANGE 0x3c000 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_cistatic inline u32 wl1251_read32(struct wl1251 *wl, int addr) 2462306a36Sopenharmony_ci{ 2562306a36Sopenharmony_ci wl->if_ops->read(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32)); 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci return le32_to_cpu(wl->buffer_32); 2862306a36Sopenharmony_ci} 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_cistatic inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val) 3162306a36Sopenharmony_ci{ 3262306a36Sopenharmony_ci wl->buffer_32 = cpu_to_le32(val); 3362306a36Sopenharmony_ci wl->if_ops->write(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32)); 3462306a36Sopenharmony_ci} 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_cistatic inline u32 wl1251_read_elp(struct wl1251 *wl, int addr) 3762306a36Sopenharmony_ci{ 3862306a36Sopenharmony_ci u32 response; 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci if (wl->if_ops->read_elp) 4162306a36Sopenharmony_ci wl->if_ops->read_elp(wl, addr, &response); 4262306a36Sopenharmony_ci else 4362306a36Sopenharmony_ci wl->if_ops->read(wl, addr, &response, sizeof(u32)); 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci return response; 4662306a36Sopenharmony_ci} 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_cistatic inline void wl1251_write_elp(struct wl1251 *wl, int addr, u32 val) 4962306a36Sopenharmony_ci{ 5062306a36Sopenharmony_ci if (wl->if_ops->write_elp) 5162306a36Sopenharmony_ci wl->if_ops->write_elp(wl, addr, val); 5262306a36Sopenharmony_ci else 5362306a36Sopenharmony_ci wl->if_ops->write(wl, addr, &val, sizeof(u32)); 5462306a36Sopenharmony_ci} 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci/* Memory target IO, address is translated to partition 0 */ 5762306a36Sopenharmony_civoid wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len); 5862306a36Sopenharmony_civoid wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len); 5962306a36Sopenharmony_ciu32 wl1251_mem_read32(struct wl1251 *wl, int addr); 6062306a36Sopenharmony_civoid wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val); 6162306a36Sopenharmony_ci/* Registers IO */ 6262306a36Sopenharmony_ciu32 wl1251_reg_read32(struct wl1251 *wl, int addr); 6362306a36Sopenharmony_civoid wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val); 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_civoid wl1251_set_partition(struct wl1251 *wl, 6662306a36Sopenharmony_ci u32 part_start, u32 part_size, 6762306a36Sopenharmony_ci u32 reg_start, u32 reg_size); 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#endif 70