rv770.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright 2008 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Jerome Glisse.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Dave Airlie
  25. * Alex Deucher
  26. * Jerome Glisse
  27. */
  28. #include "drmP.h"
  29. #include "radeon_reg.h"
  30. #include "radeon.h"
  31. /* rv770,rv730,rv710 depends on : */
  32. void rs600_mc_disable_clients(struct radeon_device *rdev);
  33. /* This files gather functions specifics to:
  34. * rv770,rv730,rv710
  35. *
  36. * Some of these functions might be used by newer ASICs.
  37. */
  38. int rv770_mc_wait_for_idle(struct radeon_device *rdev);
  39. void rv770_gpu_init(struct radeon_device *rdev);
  40. /*
  41. * MC
  42. */
  43. int rv770_mc_init(struct radeon_device *rdev)
  44. {
  45. uint32_t tmp;
  46. rv770_gpu_init(rdev);
  47. /* setup the gart before changing location so we can ask to
  48. * discard unmapped mc request
  49. */
  50. /* FIXME: disable out of gart access */
  51. tmp = rdev->mc.gtt_location / 4096;
  52. tmp = REG_SET(R700_LOGICAL_PAGE_NUMBER, tmp);
  53. WREG32(R700_MC_VM_SYSTEM_APERTURE_LOW_ADDR, tmp);
  54. tmp = (rdev->mc.gtt_location + rdev->mc.gtt_size) / 4096;
  55. tmp = REG_SET(R700_LOGICAL_PAGE_NUMBER, tmp);
  56. WREG32(R700_MC_VM_SYSTEM_APERTURE_HIGH_ADDR, tmp);
  57. rs600_mc_disable_clients(rdev);
  58. if (rv770_mc_wait_for_idle(rdev)) {
  59. printk(KERN_WARNING "Failed to wait MC idle while "
  60. "programming pipes. Bad things might happen.\n");
  61. }
  62. tmp = rdev->mc.vram_location + rdev->mc.vram_size - 1;
  63. tmp = REG_SET(R700_MC_FB_TOP, tmp >> 24);
  64. tmp |= REG_SET(R700_MC_FB_BASE, rdev->mc.vram_location >> 24);
  65. WREG32(R700_MC_VM_FB_LOCATION, tmp);
  66. tmp = rdev->mc.gtt_location + rdev->mc.gtt_size - 1;
  67. tmp = REG_SET(R700_MC_AGP_TOP, tmp >> 22);
  68. WREG32(R700_MC_VM_AGP_TOP, tmp);
  69. tmp = REG_SET(R700_MC_AGP_BOT, rdev->mc.gtt_location >> 22);
  70. WREG32(R700_MC_VM_AGP_BOT, tmp);
  71. return 0;
  72. }
  73. void rv770_mc_fini(struct radeon_device *rdev)
  74. {
  75. /* FIXME: implement */
  76. }
  77. /*
  78. * Global GPU functions
  79. */
  80. void rv770_errata(struct radeon_device *rdev)
  81. {
  82. rdev->pll_errata = 0;
  83. }
  84. int rv770_mc_wait_for_idle(struct radeon_device *rdev)
  85. {
  86. /* FIXME: implement */
  87. return 0;
  88. }
  89. void rv770_gpu_init(struct radeon_device *rdev)
  90. {
  91. /* FIXME: implement */
  92. }
  93. /*
  94. * VRAM info
  95. */
  96. void rv770_vram_get_type(struct radeon_device *rdev)
  97. {
  98. /* FIXME: implement */
  99. }
  100. void rv770_vram_info(struct radeon_device *rdev)
  101. {
  102. rv770_vram_get_type(rdev);
  103. /* FIXME: implement */
  104. /* Could aper size report 0 ? */
  105. rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
  106. rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
  107. }