io.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * This file is part of wl12xx
  4. *
  5. * Copyright (C) 2008 Nokia Corporation
  6. */
  7. #ifndef __WL1251_IO_H__
  8. #define __WL1251_IO_H__
  9. #include "wl1251.h"
  10. #define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0
  11. #define HW_ACCESS_PART0_SIZE_ADDR 0x1FFC0
  12. #define HW_ACCESS_PART0_START_ADDR 0x1FFC4
  13. #define HW_ACCESS_PART1_SIZE_ADDR 0x1FFC8
  14. #define HW_ACCESS_PART1_START_ADDR 0x1FFCC
  15. #define HW_ACCESS_REGISTER_SIZE 4
  16. #define HW_ACCESS_PRAM_MAX_RANGE 0x3c000
  17. static inline u32 wl1251_read32(struct wl1251 *wl, int addr)
  18. {
  19. wl->if_ops->read(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32));
  20. return le32_to_cpu(wl->buffer_32);
  21. }
  22. static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val)
  23. {
  24. wl->buffer_32 = cpu_to_le32(val);
  25. wl->if_ops->write(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32));
  26. }
  27. static inline u32 wl1251_read_elp(struct wl1251 *wl, int addr)
  28. {
  29. u32 response;
  30. if (wl->if_ops->read_elp)
  31. wl->if_ops->read_elp(wl, addr, &response);
  32. else
  33. wl->if_ops->read(wl, addr, &response, sizeof(u32));
  34. return response;
  35. }
  36. static inline void wl1251_write_elp(struct wl1251 *wl, int addr, u32 val)
  37. {
  38. if (wl->if_ops->write_elp)
  39. wl->if_ops->write_elp(wl, addr, val);
  40. else
  41. wl->if_ops->write(wl, addr, &val, sizeof(u32));
  42. }
  43. /* Memory target IO, address is translated to partition 0 */
  44. void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len);
  45. void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len);
  46. u32 wl1251_mem_read32(struct wl1251 *wl, int addr);
  47. void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val);
  48. /* Registers IO */
  49. u32 wl1251_reg_read32(struct wl1251 *wl, int addr);
  50. void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val);
  51. void wl1251_set_partition(struct wl1251 *wl,
  52. u32 part_start, u32 part_size,
  53. u32 reg_start, u32 reg_size);
  54. #endif