intel_opregion.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright 2010 Intel Corporation
  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 (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. *
  23. * FIXME: resolve with the i915 version
  24. */
  25. #include "psb_drv.h"
  26. struct opregion_header {
  27. u8 signature[16];
  28. u32 size;
  29. u32 opregion_ver;
  30. u8 bios_ver[32];
  31. u8 vbios_ver[16];
  32. u8 driver_ver[16];
  33. u32 mboxes;
  34. u8 reserved[164];
  35. } __packed;
  36. struct opregion_apci {
  37. /*FIXME: add it later*/
  38. } __packed;
  39. struct opregion_swsci {
  40. /*FIXME: add it later*/
  41. } __packed;
  42. struct opregion_acpi {
  43. /*FIXME: add it later*/
  44. } __packed;
  45. int gma_intel_opregion_init(struct drm_device *dev)
  46. {
  47. struct drm_psb_private *dev_priv = dev->dev_private;
  48. u32 opregion_phy;
  49. void *base;
  50. u32 *lid_state;
  51. dev_priv->lid_state = NULL;
  52. pci_read_config_dword(dev->pdev, 0xfc, &opregion_phy);
  53. if (opregion_phy == 0)
  54. return -ENOTSUPP;
  55. base = ioremap(opregion_phy, 8*1024);
  56. if (!base)
  57. return -ENOMEM;
  58. lid_state = base + 0x01ac;
  59. dev_priv->lid_state = lid_state;
  60. dev_priv->lid_last_state = readl(lid_state);
  61. return 0;
  62. }
  63. int gma_intel_opregion_exit(struct drm_device *dev)
  64. {
  65. struct drm_psb_private *dev_priv = dev->dev_private;
  66. if (dev_priv->lid_state)
  67. iounmap(dev_priv->lid_state);
  68. return 0;
  69. }