nv84_bsp.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright 2011 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Ben Skeggs
  23. */
  24. #include "drmP.h"
  25. #include "nouveau_drv.h"
  26. #include "nouveau_util.h"
  27. #include "nouveau_vm.h"
  28. #include "nouveau_ramht.h"
  29. /*XXX: This stub is currently used on NV98+ also, as soon as this becomes
  30. * more than just an enable/disable stub this needs to be split out to
  31. * nv98_bsp.c...
  32. */
  33. struct nv84_bsp_engine {
  34. struct nouveau_exec_engine base;
  35. };
  36. static int
  37. nv84_bsp_fini(struct drm_device *dev, int engine, bool suspend)
  38. {
  39. if (!(nv_rd32(dev, 0x000200) & 0x00008000))
  40. return 0;
  41. nv_mask(dev, 0x000200, 0x00008000, 0x00000000);
  42. return 0;
  43. }
  44. static int
  45. nv84_bsp_init(struct drm_device *dev, int engine)
  46. {
  47. nv_mask(dev, 0x000200, 0x00008000, 0x00000000);
  48. nv_mask(dev, 0x000200, 0x00008000, 0x00008000);
  49. return 0;
  50. }
  51. static void
  52. nv84_bsp_destroy(struct drm_device *dev, int engine)
  53. {
  54. struct nv84_bsp_engine *pbsp = nv_engine(dev, engine);
  55. NVOBJ_ENGINE_DEL(dev, BSP);
  56. kfree(pbsp);
  57. }
  58. int
  59. nv84_bsp_create(struct drm_device *dev)
  60. {
  61. struct nv84_bsp_engine *pbsp;
  62. pbsp = kzalloc(sizeof(*pbsp), GFP_KERNEL);
  63. if (!pbsp)
  64. return -ENOMEM;
  65. pbsp->base.destroy = nv84_bsp_destroy;
  66. pbsp->base.init = nv84_bsp_init;
  67. pbsp->base.fini = nv84_bsp_fini;
  68. NVOBJ_ENGINE_ADD(dev, BSP, &pbsp->base);
  69. return 0;
  70. }