g2d-hw.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Samsung S5P G2D - 2D Graphics Accelerator Driver
  3. *
  4. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  5. * Kamil Debski, <k.debski@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the
  10. * License, or (at your option) any later version
  11. */
  12. #include <linux/io.h>
  13. #include "g2d.h"
  14. #include "g2d-regs.h"
  15. #define w(x, a) writel((x), d->regs + (a))
  16. #define r(a) readl(d->regs + (a))
  17. /* g2d_reset clears all g2d registers */
  18. void g2d_reset(struct g2d_dev *d)
  19. {
  20. w(1, SOFT_RESET_REG);
  21. }
  22. void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame *f)
  23. {
  24. u32 n;
  25. w(f->stride & 0xFFFF, SRC_STRIDE_REG);
  26. n = f->o_height & 0xFFF;
  27. n <<= 16;
  28. n |= f->o_width & 0xFFF;
  29. w(n, SRC_LEFT_TOP_REG);
  30. n = f->bottom & 0xFFF;
  31. n <<= 16;
  32. n |= f->right & 0xFFF;
  33. w(n, SRC_RIGHT_BOTTOM_REG);
  34. w(f->fmt->hw, SRC_COLOR_MODE_REG);
  35. }
  36. void g2d_set_src_addr(struct g2d_dev *d, dma_addr_t a)
  37. {
  38. w(a, SRC_BASE_ADDR_REG);
  39. }
  40. void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame *f)
  41. {
  42. u32 n;
  43. w(f->stride & 0xFFFF, DST_STRIDE_REG);
  44. n = f->o_height & 0xFFF;
  45. n <<= 16;
  46. n |= f->o_width & 0xFFF;
  47. w(n, DST_LEFT_TOP_REG);
  48. n = f->bottom & 0xFFF;
  49. n <<= 16;
  50. n |= f->right & 0xFFF;
  51. w(n, DST_RIGHT_BOTTOM_REG);
  52. w(f->fmt->hw, DST_COLOR_MODE_REG);
  53. }
  54. void g2d_set_dst_addr(struct g2d_dev *d, dma_addr_t a)
  55. {
  56. w(a, DST_BASE_ADDR_REG);
  57. }
  58. void g2d_set_rop4(struct g2d_dev *d, u32 r)
  59. {
  60. w(r, ROP4_REG);
  61. }
  62. void g2d_set_flip(struct g2d_dev *d, u32 r)
  63. {
  64. w(r, SRC_MSK_DIRECT_REG);
  65. }
  66. u32 g2d_cmd_stretch(u32 e)
  67. {
  68. e &= 1;
  69. return e << 4;
  70. }
  71. void g2d_set_cmd(struct g2d_dev *d, u32 c)
  72. {
  73. w(c, BITBLT_COMMAND_REG);
  74. }
  75. void g2d_start(struct g2d_dev *d)
  76. {
  77. /* Clear cache */
  78. w(0x7, CACHECTL_REG);
  79. /* Enable interrupt */
  80. w(1, INTEN_REG);
  81. /* Start G2D engine */
  82. w(1, BITBLT_START_REG);
  83. }
  84. void g2d_clear_int(struct g2d_dev *d)
  85. {
  86. w(1, INTC_PEND_REG);
  87. }