nv20.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2010 Francisco Jerez.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial
  15. * portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  21. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. */
  26. #include "nv04.h"
  27. #include "fbmem.h"
  28. #include <subdev/bios.h>
  29. #include <subdev/bios/init.h>
  30. static void
  31. nv20_devinit_meminit(struct nvkm_devinit *init)
  32. {
  33. struct nvkm_subdev *subdev = &init->subdev;
  34. struct nvkm_device *device = subdev->device;
  35. uint32_t mask = (device->chipset >= 0x25 ? 0x300 : 0x900);
  36. uint32_t amount, off;
  37. struct io_mapping *fb;
  38. /* Map the framebuffer aperture */
  39. fb = fbmem_init(device);
  40. if (!fb) {
  41. nvkm_error(subdev, "failed to map fb\n");
  42. return;
  43. }
  44. nvkm_wr32(device, NV10_PFB_REFCTRL, NV10_PFB_REFCTRL_VALID_1);
  45. /* Allow full addressing */
  46. nvkm_mask(device, NV04_PFB_CFG0, 0, mask);
  47. amount = nvkm_rd32(device, 0x10020c);
  48. for (off = amount; off > 0x2000000; off -= 0x2000000)
  49. fbmem_poke(fb, off - 4, off);
  50. amount = nvkm_rd32(device, 0x10020c);
  51. if (amount != fbmem_peek(fb, amount - 4))
  52. /* IC missing - disable the upper half memory space. */
  53. nvkm_mask(device, NV04_PFB_CFG0, mask, 0);
  54. fbmem_fini(fb);
  55. }
  56. static const struct nvkm_devinit_func
  57. nv20_devinit = {
  58. .dtor = nv04_devinit_dtor,
  59. .preinit = nv04_devinit_preinit,
  60. .post = nv04_devinit_post,
  61. .meminit = nv20_devinit_meminit,
  62. .pll_set = nv04_devinit_pll_set,
  63. };
  64. int
  65. nv20_devinit_new(struct nvkm_device *device, int index,
  66. struct nvkm_devinit **pinit)
  67. {
  68. return nv04_devinit_new_(&nv20_devinit, device, index, pinit);
  69. }