control.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * OMAP2/3 System Control Module register access
  3. *
  4. * Copyright (C) 2007 Texas Instruments, Inc.
  5. * Copyright (C) 2007 Nokia Corporation
  6. *
  7. * Written by Paul Walmsley
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #undef DEBUG
  14. #include <linux/kernel.h>
  15. #include <asm/io.h>
  16. #include <asm/arch/control.h>
  17. static u32 omap2_ctrl_base;
  18. #define OMAP_CTRL_REGADDR(reg) (void __iomem *)IO_ADDRESS(omap2_ctrl_base \
  19. + (reg))
  20. void omap_ctrl_base_set(u32 base)
  21. {
  22. omap2_ctrl_base = base;
  23. }
  24. u32 omap_ctrl_base_get(void)
  25. {
  26. return omap2_ctrl_base;
  27. }
  28. u8 omap_ctrl_readb(u16 offset)
  29. {
  30. return __raw_readb(OMAP_CTRL_REGADDR(offset));
  31. }
  32. u16 omap_ctrl_readw(u16 offset)
  33. {
  34. return __raw_readw(OMAP_CTRL_REGADDR(offset));
  35. }
  36. u32 omap_ctrl_readl(u16 offset)
  37. {
  38. return __raw_readl(OMAP_CTRL_REGADDR(offset));
  39. }
  40. void omap_ctrl_writeb(u8 val, u16 offset)
  41. {
  42. pr_debug("omap_ctrl_writeb: writing 0x%0x to 0x%0x\n", val,
  43. (u32)OMAP_CTRL_REGADDR(offset));
  44. __raw_writeb(val, OMAP_CTRL_REGADDR(offset));
  45. }
  46. void omap_ctrl_writew(u16 val, u16 offset)
  47. {
  48. pr_debug("omap_ctrl_writew: writing 0x%0x to 0x%0x\n", val,
  49. (u32)OMAP_CTRL_REGADDR(offset));
  50. __raw_writew(val, OMAP_CTRL_REGADDR(offset));
  51. }
  52. void omap_ctrl_writel(u32 val, u16 offset)
  53. {
  54. pr_debug("omap_ctrl_writel: writing 0x%0x to 0x%0x\n", val,
  55. (u32)OMAP_CTRL_REGADDR(offset));
  56. __raw_writel(val, OMAP_CTRL_REGADDR(offset));
  57. }