mdp_hw40.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2010 Google, Inc.
  3. * Author: Dima Zavin <dima@android.com>
  4. *
  5. * Based on code from Code Aurora Forum.
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #include <linux/clk.h>
  18. #include <linux/io.h>
  19. #include "mdp_hw.h"
  20. static void mdp_dma_to_mddi(void *priv, uint32_t addr, uint32_t stride,
  21. uint32_t width, uint32_t height, uint32_t x,
  22. uint32_t y)
  23. {
  24. struct mdp_info *mdp = priv;
  25. uint32_t dma2_cfg;
  26. uint16_t ld_param = 0; /* 0=PRIM, 1=SECD, 2=EXT */
  27. dma2_cfg = DMA_PACK_TIGHT |
  28. DMA_PACK_ALIGN_LSB;
  29. dma2_cfg |= mdp->dma_format;
  30. dma2_cfg |= mdp->dma_pack_pattern;
  31. dma2_cfg |= DMA_DITHER_EN;
  32. /* 666 18BPP */
  33. dma2_cfg |= DMA_DSTC0G_6BITS | DMA_DSTC1B_6BITS | DMA_DSTC2R_6BITS;
  34. /* setup size, address, and stride */
  35. mdp_writel(mdp, (height << 16) | (width), MDP_DMA_P_SIZE);
  36. mdp_writel(mdp, addr, MDP_DMA_P_IBUF_ADDR);
  37. mdp_writel(mdp, stride, MDP_DMA_P_IBUF_Y_STRIDE);
  38. /* set y & x offset and MDDI transaction parameters */
  39. mdp_writel(mdp, (y << 16) | (x), MDP_DMA_P_OUT_XY);
  40. mdp_writel(mdp, ld_param, MDP_MDDI_PARAM_WR_SEL);
  41. mdp_writel(mdp, (MDDI_VDO_PACKET_DESC << 16) | MDDI_VDO_PACKET_PRIM,
  42. MDP_MDDI_PARAM);
  43. mdp_writel(mdp, 0x1, MDP_MDDI_DATA_XFR);
  44. mdp_writel(mdp, dma2_cfg, MDP_DMA_P_CONFIG);
  45. mdp_writel(mdp, 0, MDP_DMA_P_START);
  46. }
  47. int mdp_hw_init(struct mdp_info *mdp)
  48. {
  49. int ret;
  50. ret = mdp_out_if_register(&mdp->mdp_dev, MSM_MDDI_PMDH_INTERFACE, mdp,
  51. MDP_DMA_P_DONE, mdp_dma_to_mddi);
  52. if (ret)
  53. return ret;
  54. mdp_writel(mdp, 0, MDP_INTR_ENABLE);
  55. mdp_writel(mdp, 0, MDP_DMA_P_HIST_INTR_ENABLE);
  56. /* XXX: why set this? QCT says it should be > mdp_pclk,
  57. * but they never set the clkrate of pclk */
  58. clk_set_rate(mdp->clk, 122880000); /* 122.88 Mhz */
  59. pr_info("%s: mdp_clk=%lu\n", __func__, clk_get_rate(mdp->clk));
  60. /* TODO: Configure the VG/RGB pipes fetch data */
  61. /* this should work for any mdp_clk freq.
  62. * TODO: use different value for mdp_clk freqs >= 90Mhz */
  63. mdp_writel(mdp, 0x27, MDP_DMA_P_FETCH_CFG); /* 8 bytes-burst x 8 req */
  64. mdp_writel(mdp, 0x3, MDP_EBI2_PORTMAP_MODE);
  65. /* 3 pending requests */
  66. mdp_writel(mdp, 0x02222, MDP_MAX_RD_PENDING_CMD_CONFIG);
  67. /* no overlay processing, sw controls everything */
  68. mdp_writel(mdp, 0, MDP_LAYERMIXER_IN_CFG);
  69. mdp_writel(mdp, 1 << 3, MDP_OVERLAYPROC0_CFG);
  70. mdp_writel(mdp, 1 << 3, MDP_OVERLAYPROC1_CFG);
  71. /* XXX: HACK! hardcode to do mddi on primary */
  72. mdp_writel(mdp, 0x2, MDP_DISP_INTF_SEL);
  73. return 0;
  74. }