io.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * This file is part of wl12xx
  3. *
  4. * Copyright (C) 2008 Nokia Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  18. * 02110-1301 USA
  19. *
  20. */
  21. #ifndef __WL1251_IO_H__
  22. #define __WL1251_IO_H__
  23. #include "wl1251.h"
  24. #define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0
  25. #define HW_ACCESS_PART0_SIZE_ADDR 0x1FFC0
  26. #define HW_ACCESS_PART0_START_ADDR 0x1FFC4
  27. #define HW_ACCESS_PART1_SIZE_ADDR 0x1FFC8
  28. #define HW_ACCESS_PART1_START_ADDR 0x1FFCC
  29. #define HW_ACCESS_REGISTER_SIZE 4
  30. #define HW_ACCESS_PRAM_MAX_RANGE 0x3c000
  31. static inline u32 wl1251_read32(struct wl1251 *wl, int addr)
  32. {
  33. wl->if_ops->read(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32));
  34. return le32_to_cpu(wl->buffer_32);
  35. }
  36. static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val)
  37. {
  38. wl->buffer_32 = cpu_to_le32(val);
  39. wl->if_ops->write(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32));
  40. }
  41. static inline u32 wl1251_read_elp(struct wl1251 *wl, int addr)
  42. {
  43. u32 response;
  44. if (wl->if_ops->read_elp)
  45. wl->if_ops->read_elp(wl, addr, &response);
  46. else
  47. wl->if_ops->read(wl, addr, &response, sizeof(u32));
  48. return response;
  49. }
  50. static inline void wl1251_write_elp(struct wl1251 *wl, int addr, u32 val)
  51. {
  52. if (wl->if_ops->write_elp)
  53. wl->if_ops->write_elp(wl, addr, val);
  54. else
  55. wl->if_ops->write(wl, addr, &val, sizeof(u32));
  56. }
  57. /* Memory target IO, address is translated to partition 0 */
  58. void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len);
  59. void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len);
  60. u32 wl1251_mem_read32(struct wl1251 *wl, int addr);
  61. void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val);
  62. /* Registers IO */
  63. u32 wl1251_reg_read32(struct wl1251 *wl, int addr);
  64. 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);
  68. #endif