io.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * This file is part of wl18xx
  3. *
  4. * Copyright (C) 2011 Texas Instruments
  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. #include "../wlcore/wlcore.h"
  22. #include "../wlcore/io.h"
  23. #include "io.h"
  24. void wl18xx_top_reg_write(struct wl1271 *wl, int addr, u16 val)
  25. {
  26. u32 tmp;
  27. if (WARN_ON(addr % 2))
  28. return;
  29. if ((addr % 4) == 0) {
  30. tmp = wl1271_read32(wl, addr);
  31. tmp = (tmp & 0xffff0000) | val;
  32. wl1271_write32(wl, addr, tmp);
  33. } else {
  34. tmp = wl1271_read32(wl, addr - 2);
  35. tmp = (tmp & 0xffff) | (val << 16);
  36. wl1271_write32(wl, addr - 2, tmp);
  37. }
  38. }
  39. u16 wl18xx_top_reg_read(struct wl1271 *wl, int addr)
  40. {
  41. u32 val;
  42. if (WARN_ON(addr % 2))
  43. return 0;
  44. if ((addr % 4) == 0) {
  45. /* address is 4-bytes aligned */
  46. val = wl1271_read32(wl, addr);
  47. return val & 0xffff;
  48. } else {
  49. val = wl1271_read32(wl, addr - 2);
  50. return (val & 0xffff0000) >> 16;
  51. }
  52. }