power.c (ffb1e76f4f32d2b8ea4189df0484980370476395) | power.c (f71635e893c3832790484f2e22b8d5825cc6ce1c) |
---|---|
1/************************************************************************** 2 * Copyright (c) 2009-2011, Intel Corporation. 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, --- 33 unchanged lines hidden (view full) --- 42/** 43 * gma_power_init - initialise power manager 44 * @dev: our device 45 * 46 * Set up for power management tracking of our hardware. 47 */ 48void gma_power_init(struct drm_device *dev) 49{ | 1/************************************************************************** 2 * Copyright (c) 2009-2011, Intel Corporation. 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, --- 33 unchanged lines hidden (view full) --- 42/** 43 * gma_power_init - initialise power manager 44 * @dev: our device 45 * 46 * Set up for power management tracking of our hardware. 47 */ 48void gma_power_init(struct drm_device *dev) 49{ |
50 struct drm_psb_private *dev_priv = dev->dev_private; | 50 struct drm_psb_private *dev_priv = to_drm_psb_private(dev); |
51 52 /* FIXME: Move APM/OSPM base into relevant device code */ 53 dev_priv->apm_base = dev_priv->apm_reg & 0xffff; 54 dev_priv->ospm_base &= 0xffff; 55 56 dev_priv->display_power = true; /* We start active */ 57 dev_priv->display_count = 0; /* Currently no users */ 58 dev_priv->suspended = false; /* And not suspended */ --- 18 unchanged lines hidden (view full) --- 77/** 78 * gma_suspend_display - suspend the display logic 79 * @dev: our DRM device 80 * 81 * Suspend the display logic of the graphics interface 82 */ 83static void gma_suspend_display(struct drm_device *dev) 84{ | 51 52 /* FIXME: Move APM/OSPM base into relevant device code */ 53 dev_priv->apm_base = dev_priv->apm_reg & 0xffff; 54 dev_priv->ospm_base &= 0xffff; 55 56 dev_priv->display_power = true; /* We start active */ 57 dev_priv->display_count = 0; /* Currently no users */ 58 dev_priv->suspended = false; /* And not suspended */ --- 18 unchanged lines hidden (view full) --- 77/** 78 * gma_suspend_display - suspend the display logic 79 * @dev: our DRM device 80 * 81 * Suspend the display logic of the graphics interface 82 */ 83static void gma_suspend_display(struct drm_device *dev) 84{ |
85 struct drm_psb_private *dev_priv = dev->dev_private; | 85 struct drm_psb_private *dev_priv = to_drm_psb_private(dev); |
86 87 if (dev_priv->suspended) 88 return; 89 dev_priv->ops->save_regs(dev); 90 dev_priv->ops->power_down(dev); 91 dev_priv->display_power = false; 92} 93 94/** 95 * gma_resume_display - resume display side logic 96 * @pdev: PCI device 97 * 98 * Resume the display hardware restoring state and enabling 99 * as necessary. 100 */ 101static void gma_resume_display(struct pci_dev *pdev) 102{ 103 struct drm_device *dev = pci_get_drvdata(pdev); | 86 87 if (dev_priv->suspended) 88 return; 89 dev_priv->ops->save_regs(dev); 90 dev_priv->ops->power_down(dev); 91 dev_priv->display_power = false; 92} 93 94/** 95 * gma_resume_display - resume display side logic 96 * @pdev: PCI device 97 * 98 * Resume the display hardware restoring state and enabling 99 * as necessary. 100 */ 101static void gma_resume_display(struct pci_dev *pdev) 102{ 103 struct drm_device *dev = pci_get_drvdata(pdev); |
104 struct drm_psb_private *dev_priv = dev->dev_private; | 104 struct drm_psb_private *dev_priv = to_drm_psb_private(dev); |
105 106 /* turn on the display power island */ 107 dev_priv->ops->power_up(dev); 108 dev_priv->suspended = false; 109 dev_priv->display_power = true; 110 111 PSB_WVDC32(dev_priv->pge_ctl | _PSB_PGETBL_ENABLED, PSB_PGETBL_CTL); 112 pci_write_config_word(pdev, PSB_GMCH_CTRL, --- 7 unchanged lines hidden (view full) --- 120 * gma_suspend_pci - suspend PCI side 121 * @pdev: PCI device 122 * 123 * Perform the suspend processing on our PCI device state 124 */ 125static void gma_suspend_pci(struct pci_dev *pdev) 126{ 127 struct drm_device *dev = pci_get_drvdata(pdev); | 105 106 /* turn on the display power island */ 107 dev_priv->ops->power_up(dev); 108 dev_priv->suspended = false; 109 dev_priv->display_power = true; 110 111 PSB_WVDC32(dev_priv->pge_ctl | _PSB_PGETBL_ENABLED, PSB_PGETBL_CTL); 112 pci_write_config_word(pdev, PSB_GMCH_CTRL, --- 7 unchanged lines hidden (view full) --- 120 * gma_suspend_pci - suspend PCI side 121 * @pdev: PCI device 122 * 123 * Perform the suspend processing on our PCI device state 124 */ 125static void gma_suspend_pci(struct pci_dev *pdev) 126{ 127 struct drm_device *dev = pci_get_drvdata(pdev); |
128 struct drm_psb_private *dev_priv = dev->dev_private; | 128 struct drm_psb_private *dev_priv = to_drm_psb_private(dev); |
129 int bsm, vbt; 130 131 if (dev_priv->suspended) 132 return; 133 134 pci_save_state(pdev); 135 pci_read_config_dword(pdev, 0x5C, &bsm); 136 dev_priv->regs.saveBSM = bsm; --- 13 unchanged lines hidden (view full) --- 150 * @pdev: our PCI device 151 * 152 * Perform the resume processing on our PCI device state - rewrite 153 * register state and re-enable the PCI device 154 */ 155static bool gma_resume_pci(struct pci_dev *pdev) 156{ 157 struct drm_device *dev = pci_get_drvdata(pdev); | 129 int bsm, vbt; 130 131 if (dev_priv->suspended) 132 return; 133 134 pci_save_state(pdev); 135 pci_read_config_dword(pdev, 0x5C, &bsm); 136 dev_priv->regs.saveBSM = bsm; --- 13 unchanged lines hidden (view full) --- 150 * @pdev: our PCI device 151 * 152 * Perform the resume processing on our PCI device state - rewrite 153 * register state and re-enable the PCI device 154 */ 155static bool gma_resume_pci(struct pci_dev *pdev) 156{ 157 struct drm_device *dev = pci_get_drvdata(pdev); |
158 struct drm_psb_private *dev_priv = dev->dev_private; | 158 struct drm_psb_private *dev_priv = to_drm_psb_private(dev); |
159 int ret; 160 161 if (!dev_priv->suspended) 162 return true; 163 164 pci_set_power_state(pdev, PCI_D0); 165 pci_restore_state(pdev); 166 pci_write_config_dword(pdev, 0x5c, dev_priv->regs.saveBSM); --- 17 unchanged lines hidden (view full) --- 184 * Called back by the PCI layer during a suspend of the system. We 185 * perform the necessary shut down steps and save enough state that 186 * we can undo this when resume is called. 187 */ 188int gma_power_suspend(struct device *_dev) 189{ 190 struct pci_dev *pdev = to_pci_dev(_dev); 191 struct drm_device *dev = pci_get_drvdata(pdev); | 159 int ret; 160 161 if (!dev_priv->suspended) 162 return true; 163 164 pci_set_power_state(pdev, PCI_D0); 165 pci_restore_state(pdev); 166 pci_write_config_dword(pdev, 0x5c, dev_priv->regs.saveBSM); --- 17 unchanged lines hidden (view full) --- 184 * Called back by the PCI layer during a suspend of the system. We 185 * perform the necessary shut down steps and save enough state that 186 * we can undo this when resume is called. 187 */ 188int gma_power_suspend(struct device *_dev) 189{ 190 struct pci_dev *pdev = to_pci_dev(_dev); 191 struct drm_device *dev = pci_get_drvdata(pdev); |
192 struct drm_psb_private *dev_priv = dev->dev_private; | 192 struct drm_psb_private *dev_priv = to_drm_psb_private(dev); |
193 194 mutex_lock(&power_mutex); 195 if (!dev_priv->suspended) { 196 if (dev_priv->display_count) { 197 mutex_unlock(&power_mutex); 198 dev_err(dev->dev, "GPU hardware busy, cannot suspend\n"); 199 return -EBUSY; 200 } --- 28 unchanged lines hidden (view full) --- 229/** 230 * gma_power_is_on - returne true if power is on 231 * @dev: our DRM device 232 * 233 * Returns true if the display island power is on at this moment 234 */ 235bool gma_power_is_on(struct drm_device *dev) 236{ | 193 194 mutex_lock(&power_mutex); 195 if (!dev_priv->suspended) { 196 if (dev_priv->display_count) { 197 mutex_unlock(&power_mutex); 198 dev_err(dev->dev, "GPU hardware busy, cannot suspend\n"); 199 return -EBUSY; 200 } --- 28 unchanged lines hidden (view full) --- 229/** 230 * gma_power_is_on - returne true if power is on 231 * @dev: our DRM device 232 * 233 * Returns true if the display island power is on at this moment 234 */ 235bool gma_power_is_on(struct drm_device *dev) 236{ |
237 struct drm_psb_private *dev_priv = dev->dev_private; | 237 struct drm_psb_private *dev_priv = to_drm_psb_private(dev); |
238 return dev_priv->display_power; 239} 240 241/** 242 * gma_power_begin - begin requiring power 243 * @dev: our DRM device 244 * @force_on: true to force power on 245 * 246 * Begin an action that requires the display power island is enabled. 247 * We refcount the islands. 248 */ 249bool gma_power_begin(struct drm_device *dev, bool force_on) 250{ | 238 return dev_priv->display_power; 239} 240 241/** 242 * gma_power_begin - begin requiring power 243 * @dev: our DRM device 244 * @force_on: true to force power on 245 * 246 * Begin an action that requires the display power island is enabled. 247 * We refcount the islands. 248 */ 249bool gma_power_begin(struct drm_device *dev, bool force_on) 250{ |
251 struct drm_psb_private *dev_priv = dev->dev_private; | 251 struct drm_psb_private *dev_priv = to_drm_psb_private(dev); |
252 struct pci_dev *pdev = to_pci_dev(dev->dev); 253 int ret; 254 unsigned long flags; 255 256 spin_lock_irqsave(&power_ctrl_lock, flags); 257 /* Power already on ? */ 258 if (dev_priv->display_power) { 259 dev_priv->display_count++; --- 23 unchanged lines hidden (view full) --- 283 * gma_power_end - end use of power 284 * @dev: Our DRM device 285 * 286 * Indicate that one of our gma_power_begin() requested periods when 287 * the diplay island power is needed has completed. 288 */ 289void gma_power_end(struct drm_device *dev) 290{ | 252 struct pci_dev *pdev = to_pci_dev(dev->dev); 253 int ret; 254 unsigned long flags; 255 256 spin_lock_irqsave(&power_ctrl_lock, flags); 257 /* Power already on ? */ 258 if (dev_priv->display_power) { 259 dev_priv->display_count++; --- 23 unchanged lines hidden (view full) --- 283 * gma_power_end - end use of power 284 * @dev: Our DRM device 285 * 286 * Indicate that one of our gma_power_begin() requested periods when 287 * the diplay island power is needed has completed. 288 */ 289void gma_power_end(struct drm_device *dev) 290{ |
291 struct drm_psb_private *dev_priv = dev->dev_private; | 291 struct drm_psb_private *dev_priv = to_drm_psb_private(dev); |
292 unsigned long flags; 293 spin_lock_irqsave(&power_ctrl_lock, flags); 294 dev_priv->display_count--; 295 WARN_ON(dev_priv->display_count < 0); 296 spin_unlock_irqrestore(&power_ctrl_lock, flags); 297 pm_runtime_put(dev->dev); 298} 299 --- 5 unchanged lines hidden (view full) --- 305int psb_runtime_resume(struct device *dev) 306{ 307 return gma_power_resume(dev); 308} 309 310int psb_runtime_idle(struct device *dev) 311{ 312 struct drm_device *drmdev = pci_get_drvdata(to_pci_dev(dev)); | 292 unsigned long flags; 293 spin_lock_irqsave(&power_ctrl_lock, flags); 294 dev_priv->display_count--; 295 WARN_ON(dev_priv->display_count < 0); 296 spin_unlock_irqrestore(&power_ctrl_lock, flags); 297 pm_runtime_put(dev->dev); 298} 299 --- 5 unchanged lines hidden (view full) --- 305int psb_runtime_resume(struct device *dev) 306{ 307 return gma_power_resume(dev); 308} 309 310int psb_runtime_idle(struct device *dev) 311{ 312 struct drm_device *drmdev = pci_get_drvdata(to_pci_dev(dev)); |
313 struct drm_psb_private *dev_priv = drmdev->dev_private; | 313 struct drm_psb_private *dev_priv = to_drm_psb_private(drmdev); |
314 if (dev_priv->display_count) 315 return 0; 316 else 317 return 1; 318} 319 320int gma_power_thaw(struct device *_dev) 321{ --- 12 unchanged lines hidden --- | 314 if (dev_priv->display_count) 315 return 0; 316 else 317 return 1; 318} 319 320int gma_power_thaw(struct device *_dev) 321{ --- 12 unchanged lines hidden --- |