cdv_device.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /**************************************************************************
  2. * Copyright (c) 2011, Intel Corporation.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  17. *
  18. **************************************************************************/
  19. #include <linux/backlight.h>
  20. #include <drm/drmP.h>
  21. #include <drm/drm.h>
  22. #include <drm/gma_drm.h>
  23. #include "psb_drv.h"
  24. #include "psb_reg.h"
  25. #include "psb_intel_reg.h"
  26. #include "intel_bios.h"
  27. #include "cdv_device.h"
  28. #include "gma_device.h"
  29. #define VGA_SR_INDEX 0x3c4
  30. #define VGA_SR_DATA 0x3c5
  31. static void cdv_disable_vga(struct drm_device *dev)
  32. {
  33. u8 sr1;
  34. u32 vga_reg;
  35. vga_reg = VGACNTRL;
  36. outb(1, VGA_SR_INDEX);
  37. sr1 = inb(VGA_SR_DATA);
  38. outb(sr1 | 1<<5, VGA_SR_DATA);
  39. udelay(300);
  40. REG_WRITE(vga_reg, VGA_DISP_DISABLE);
  41. REG_READ(vga_reg);
  42. }
  43. static int cdv_output_init(struct drm_device *dev)
  44. {
  45. struct drm_psb_private *dev_priv = dev->dev_private;
  46. drm_mode_create_scaling_mode_property(dev);
  47. cdv_disable_vga(dev);
  48. cdv_intel_crt_init(dev, &dev_priv->mode_dev);
  49. cdv_intel_lvds_init(dev, &dev_priv->mode_dev);
  50. /* These bits indicate HDMI not SDVO on CDV */
  51. if (REG_READ(SDVOB) & SDVO_DETECTED) {
  52. cdv_hdmi_init(dev, &dev_priv->mode_dev, SDVOB);
  53. if (REG_READ(DP_B) & DP_DETECTED)
  54. cdv_intel_dp_init(dev, &dev_priv->mode_dev, DP_B);
  55. }
  56. if (REG_READ(SDVOC) & SDVO_DETECTED) {
  57. cdv_hdmi_init(dev, &dev_priv->mode_dev, SDVOC);
  58. if (REG_READ(DP_C) & DP_DETECTED)
  59. cdv_intel_dp_init(dev, &dev_priv->mode_dev, DP_C);
  60. }
  61. return 0;
  62. }
  63. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  64. /*
  65. * Cedartrail Backlght Interfaces
  66. */
  67. static struct backlight_device *cdv_backlight_device;
  68. static int cdv_backlight_combination_mode(struct drm_device *dev)
  69. {
  70. return REG_READ(BLC_PWM_CTL2) & PWM_LEGACY_MODE;
  71. }
  72. static u32 cdv_get_max_backlight(struct drm_device *dev)
  73. {
  74. u32 max = REG_READ(BLC_PWM_CTL);
  75. if (max == 0) {
  76. DRM_DEBUG_KMS("LVDS Panel PWM value is 0!\n");
  77. /* i915 does this, I believe which means that we should not
  78. * smash PWM control as firmware will take control of it. */
  79. return 1;
  80. }
  81. max >>= 16;
  82. if (cdv_backlight_combination_mode(dev))
  83. max *= 0xff;
  84. return max;
  85. }
  86. static int cdv_get_brightness(struct backlight_device *bd)
  87. {
  88. struct drm_device *dev = bl_get_data(bd);
  89. u32 val = REG_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
  90. if (cdv_backlight_combination_mode(dev)) {
  91. u8 lbpc;
  92. val &= ~1;
  93. pci_read_config_byte(dev->pdev, 0xF4, &lbpc);
  94. val *= lbpc;
  95. }
  96. return (val * 100)/cdv_get_max_backlight(dev);
  97. }
  98. static int cdv_set_brightness(struct backlight_device *bd)
  99. {
  100. struct drm_device *dev = bl_get_data(bd);
  101. int level = bd->props.brightness;
  102. u32 blc_pwm_ctl;
  103. /* Percentage 1-100% being valid */
  104. if (level < 1)
  105. level = 1;
  106. level *= cdv_get_max_backlight(dev);
  107. level /= 100;
  108. if (cdv_backlight_combination_mode(dev)) {
  109. u32 max = cdv_get_max_backlight(dev);
  110. u8 lbpc;
  111. lbpc = level * 0xfe / max + 1;
  112. level /= lbpc;
  113. pci_write_config_byte(dev->pdev, 0xF4, lbpc);
  114. }
  115. blc_pwm_ctl = REG_READ(BLC_PWM_CTL) & ~BACKLIGHT_DUTY_CYCLE_MASK;
  116. REG_WRITE(BLC_PWM_CTL, (blc_pwm_ctl |
  117. (level << BACKLIGHT_DUTY_CYCLE_SHIFT)));
  118. return 0;
  119. }
  120. static const struct backlight_ops cdv_ops = {
  121. .get_brightness = cdv_get_brightness,
  122. .update_status = cdv_set_brightness,
  123. };
  124. static int cdv_backlight_init(struct drm_device *dev)
  125. {
  126. struct drm_psb_private *dev_priv = dev->dev_private;
  127. struct backlight_properties props;
  128. memset(&props, 0, sizeof(struct backlight_properties));
  129. props.max_brightness = 100;
  130. props.type = BACKLIGHT_PLATFORM;
  131. cdv_backlight_device = backlight_device_register("psb-bl",
  132. NULL, (void *)dev, &cdv_ops, &props);
  133. if (IS_ERR(cdv_backlight_device))
  134. return PTR_ERR(cdv_backlight_device);
  135. cdv_backlight_device->props.brightness =
  136. cdv_get_brightness(cdv_backlight_device);
  137. backlight_update_status(cdv_backlight_device);
  138. dev_priv->backlight_device = cdv_backlight_device;
  139. dev_priv->backlight_enabled = true;
  140. return 0;
  141. }
  142. #endif
  143. /*
  144. * Provide the Cedarview specific chip logic and low level methods
  145. * for power management
  146. *
  147. * FIXME: we need to implement the apm/ospm base management bits
  148. * for this and the MID devices.
  149. */
  150. static inline u32 CDV_MSG_READ32(uint port, uint offset)
  151. {
  152. int mcr = (0x10<<24) | (port << 16) | (offset << 8);
  153. uint32_t ret_val = 0;
  154. struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
  155. pci_write_config_dword(pci_root, 0xD0, mcr);
  156. pci_read_config_dword(pci_root, 0xD4, &ret_val);
  157. pci_dev_put(pci_root);
  158. return ret_val;
  159. }
  160. static inline void CDV_MSG_WRITE32(uint port, uint offset, u32 value)
  161. {
  162. int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
  163. struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
  164. pci_write_config_dword(pci_root, 0xD4, value);
  165. pci_write_config_dword(pci_root, 0xD0, mcr);
  166. pci_dev_put(pci_root);
  167. }
  168. #define PSB_PM_SSC 0x20
  169. #define PSB_PM_SSS 0x30
  170. #define PSB_PWRGT_GFX_ON 0x02
  171. #define PSB_PWRGT_GFX_OFF 0x01
  172. #define PSB_PWRGT_GFX_D0 0x00
  173. #define PSB_PWRGT_GFX_D3 0x03
  174. static void cdv_init_pm(struct drm_device *dev)
  175. {
  176. struct drm_psb_private *dev_priv = dev->dev_private;
  177. u32 pwr_cnt;
  178. int i;
  179. dev_priv->apm_base = CDV_MSG_READ32(PSB_PUNIT_PORT,
  180. PSB_APMBA) & 0xFFFF;
  181. dev_priv->ospm_base = CDV_MSG_READ32(PSB_PUNIT_PORT,
  182. PSB_OSPMBA) & 0xFFFF;
  183. /* Power status */
  184. pwr_cnt = inl(dev_priv->apm_base + PSB_APM_CMD);
  185. /* Enable the GPU */
  186. pwr_cnt &= ~PSB_PWRGT_GFX_MASK;
  187. pwr_cnt |= PSB_PWRGT_GFX_ON;
  188. outl(pwr_cnt, dev_priv->apm_base + PSB_APM_CMD);
  189. /* Wait for the GPU power */
  190. for (i = 0; i < 5; i++) {
  191. u32 pwr_sts = inl(dev_priv->apm_base + PSB_APM_STS);
  192. if ((pwr_sts & PSB_PWRGT_GFX_MASK) == 0)
  193. return;
  194. udelay(10);
  195. }
  196. dev_err(dev->dev, "GPU: power management timed out.\n");
  197. }
  198. static void cdv_errata(struct drm_device *dev)
  199. {
  200. /* Disable bonus launch.
  201. * CPU and GPU competes for memory and display misses updates and
  202. * flickers. Worst with dual core, dual displays.
  203. *
  204. * Fixes were done to Win 7 gfx driver to disable a feature called
  205. * Bonus Launch to work around the issue, by degrading
  206. * performance.
  207. */
  208. CDV_MSG_WRITE32(3, 0x30, 0x08027108);
  209. }
  210. /**
  211. * cdv_save_display_registers - save registers lost on suspend
  212. * @dev: our DRM device
  213. *
  214. * Save the state we need in order to be able to restore the interface
  215. * upon resume from suspend
  216. */
  217. static int cdv_save_display_registers(struct drm_device *dev)
  218. {
  219. struct drm_psb_private *dev_priv = dev->dev_private;
  220. struct psb_save_area *regs = &dev_priv->regs;
  221. struct drm_connector *connector;
  222. dev_dbg(dev->dev, "Saving GPU registers.\n");
  223. pci_read_config_byte(dev->pdev, 0xF4, &regs->cdv.saveLBB);
  224. regs->cdv.saveDSPCLK_GATE_D = REG_READ(DSPCLK_GATE_D);
  225. regs->cdv.saveRAMCLK_GATE_D = REG_READ(RAMCLK_GATE_D);
  226. regs->cdv.saveDSPARB = REG_READ(DSPARB);
  227. regs->cdv.saveDSPFW[0] = REG_READ(DSPFW1);
  228. regs->cdv.saveDSPFW[1] = REG_READ(DSPFW2);
  229. regs->cdv.saveDSPFW[2] = REG_READ(DSPFW3);
  230. regs->cdv.saveDSPFW[3] = REG_READ(DSPFW4);
  231. regs->cdv.saveDSPFW[4] = REG_READ(DSPFW5);
  232. regs->cdv.saveDSPFW[5] = REG_READ(DSPFW6);
  233. regs->cdv.saveADPA = REG_READ(ADPA);
  234. regs->cdv.savePP_CONTROL = REG_READ(PP_CONTROL);
  235. regs->cdv.savePFIT_PGM_RATIOS = REG_READ(PFIT_PGM_RATIOS);
  236. regs->saveBLC_PWM_CTL = REG_READ(BLC_PWM_CTL);
  237. regs->saveBLC_PWM_CTL2 = REG_READ(BLC_PWM_CTL2);
  238. regs->cdv.saveLVDS = REG_READ(LVDS);
  239. regs->cdv.savePFIT_CONTROL = REG_READ(PFIT_CONTROL);
  240. regs->cdv.savePP_ON_DELAYS = REG_READ(PP_ON_DELAYS);
  241. regs->cdv.savePP_OFF_DELAYS = REG_READ(PP_OFF_DELAYS);
  242. regs->cdv.savePP_CYCLE = REG_READ(PP_CYCLE);
  243. regs->cdv.saveVGACNTRL = REG_READ(VGACNTRL);
  244. regs->cdv.saveIER = REG_READ(PSB_INT_ENABLE_R);
  245. regs->cdv.saveIMR = REG_READ(PSB_INT_MASK_R);
  246. list_for_each_entry(connector, &dev->mode_config.connector_list, head)
  247. connector->funcs->dpms(connector, DRM_MODE_DPMS_OFF);
  248. return 0;
  249. }
  250. /**
  251. * cdv_restore_display_registers - restore lost register state
  252. * @dev: our DRM device
  253. *
  254. * Restore register state that was lost during suspend and resume.
  255. *
  256. * FIXME: review
  257. */
  258. static int cdv_restore_display_registers(struct drm_device *dev)
  259. {
  260. struct drm_psb_private *dev_priv = dev->dev_private;
  261. struct psb_save_area *regs = &dev_priv->regs;
  262. struct drm_connector *connector;
  263. u32 temp;
  264. pci_write_config_byte(dev->pdev, 0xF4, regs->cdv.saveLBB);
  265. REG_WRITE(DSPCLK_GATE_D, regs->cdv.saveDSPCLK_GATE_D);
  266. REG_WRITE(RAMCLK_GATE_D, regs->cdv.saveRAMCLK_GATE_D);
  267. /* BIOS does below anyway */
  268. REG_WRITE(DPIO_CFG, 0);
  269. REG_WRITE(DPIO_CFG, DPIO_MODE_SELECT_0 | DPIO_CMN_RESET_N);
  270. temp = REG_READ(DPLL_A);
  271. if ((temp & DPLL_SYNCLOCK_ENABLE) == 0) {
  272. REG_WRITE(DPLL_A, temp | DPLL_SYNCLOCK_ENABLE);
  273. REG_READ(DPLL_A);
  274. }
  275. temp = REG_READ(DPLL_B);
  276. if ((temp & DPLL_SYNCLOCK_ENABLE) == 0) {
  277. REG_WRITE(DPLL_B, temp | DPLL_SYNCLOCK_ENABLE);
  278. REG_READ(DPLL_B);
  279. }
  280. udelay(500);
  281. REG_WRITE(DSPFW1, regs->cdv.saveDSPFW[0]);
  282. REG_WRITE(DSPFW2, regs->cdv.saveDSPFW[1]);
  283. REG_WRITE(DSPFW3, regs->cdv.saveDSPFW[2]);
  284. REG_WRITE(DSPFW4, regs->cdv.saveDSPFW[3]);
  285. REG_WRITE(DSPFW5, regs->cdv.saveDSPFW[4]);
  286. REG_WRITE(DSPFW6, regs->cdv.saveDSPFW[5]);
  287. REG_WRITE(DSPARB, regs->cdv.saveDSPARB);
  288. REG_WRITE(ADPA, regs->cdv.saveADPA);
  289. REG_WRITE(BLC_PWM_CTL2, regs->saveBLC_PWM_CTL2);
  290. REG_WRITE(LVDS, regs->cdv.saveLVDS);
  291. REG_WRITE(PFIT_CONTROL, regs->cdv.savePFIT_CONTROL);
  292. REG_WRITE(PFIT_PGM_RATIOS, regs->cdv.savePFIT_PGM_RATIOS);
  293. REG_WRITE(BLC_PWM_CTL, regs->saveBLC_PWM_CTL);
  294. REG_WRITE(PP_ON_DELAYS, regs->cdv.savePP_ON_DELAYS);
  295. REG_WRITE(PP_OFF_DELAYS, regs->cdv.savePP_OFF_DELAYS);
  296. REG_WRITE(PP_CYCLE, regs->cdv.savePP_CYCLE);
  297. REG_WRITE(PP_CONTROL, regs->cdv.savePP_CONTROL);
  298. REG_WRITE(VGACNTRL, regs->cdv.saveVGACNTRL);
  299. REG_WRITE(PSB_INT_ENABLE_R, regs->cdv.saveIER);
  300. REG_WRITE(PSB_INT_MASK_R, regs->cdv.saveIMR);
  301. /* Fix arbitration bug */
  302. cdv_errata(dev);
  303. drm_mode_config_reset(dev);
  304. list_for_each_entry(connector, &dev->mode_config.connector_list, head)
  305. connector->funcs->dpms(connector, DRM_MODE_DPMS_ON);
  306. /* Resume the modeset for every activated CRTC */
  307. drm_helper_resume_force_mode(dev);
  308. return 0;
  309. }
  310. static int cdv_power_down(struct drm_device *dev)
  311. {
  312. struct drm_psb_private *dev_priv = dev->dev_private;
  313. u32 pwr_cnt, pwr_mask, pwr_sts;
  314. int tries = 5;
  315. pwr_cnt = inl(dev_priv->apm_base + PSB_APM_CMD);
  316. pwr_cnt &= ~PSB_PWRGT_GFX_MASK;
  317. pwr_cnt |= PSB_PWRGT_GFX_OFF;
  318. pwr_mask = PSB_PWRGT_GFX_MASK;
  319. outl(pwr_cnt, dev_priv->apm_base + PSB_APM_CMD);
  320. while (tries--) {
  321. pwr_sts = inl(dev_priv->apm_base + PSB_APM_STS);
  322. if ((pwr_sts & pwr_mask) == PSB_PWRGT_GFX_D3)
  323. return 0;
  324. udelay(10);
  325. }
  326. return 0;
  327. }
  328. static int cdv_power_up(struct drm_device *dev)
  329. {
  330. struct drm_psb_private *dev_priv = dev->dev_private;
  331. u32 pwr_cnt, pwr_mask, pwr_sts;
  332. int tries = 5;
  333. pwr_cnt = inl(dev_priv->apm_base + PSB_APM_CMD);
  334. pwr_cnt &= ~PSB_PWRGT_GFX_MASK;
  335. pwr_cnt |= PSB_PWRGT_GFX_ON;
  336. pwr_mask = PSB_PWRGT_GFX_MASK;
  337. outl(pwr_cnt, dev_priv->apm_base + PSB_APM_CMD);
  338. while (tries--) {
  339. pwr_sts = inl(dev_priv->apm_base + PSB_APM_STS);
  340. if ((pwr_sts & pwr_mask) == PSB_PWRGT_GFX_D0)
  341. return 0;
  342. udelay(10);
  343. }
  344. return 0;
  345. }
  346. static void cdv_hotplug_work_func(struct work_struct *work)
  347. {
  348. struct drm_psb_private *dev_priv = container_of(work, struct drm_psb_private,
  349. hotplug_work);
  350. struct drm_device *dev = dev_priv->dev;
  351. /* Just fire off a uevent and let userspace tell us what to do */
  352. drm_helper_hpd_irq_event(dev);
  353. }
  354. /* The core driver has received a hotplug IRQ. We are in IRQ context
  355. so extract the needed information and kick off queued processing */
  356. static int cdv_hotplug_event(struct drm_device *dev)
  357. {
  358. struct drm_psb_private *dev_priv = dev->dev_private;
  359. schedule_work(&dev_priv->hotplug_work);
  360. REG_WRITE(PORT_HOTPLUG_STAT, REG_READ(PORT_HOTPLUG_STAT));
  361. return 1;
  362. }
  363. static void cdv_hotplug_enable(struct drm_device *dev, bool on)
  364. {
  365. if (on) {
  366. u32 hotplug = REG_READ(PORT_HOTPLUG_EN);
  367. hotplug |= HDMIB_HOTPLUG_INT_EN | HDMIC_HOTPLUG_INT_EN |
  368. HDMID_HOTPLUG_INT_EN | CRT_HOTPLUG_INT_EN;
  369. REG_WRITE(PORT_HOTPLUG_EN, hotplug);
  370. } else {
  371. REG_WRITE(PORT_HOTPLUG_EN, 0);
  372. REG_WRITE(PORT_HOTPLUG_STAT, REG_READ(PORT_HOTPLUG_STAT));
  373. }
  374. }
  375. static const char *force_audio_names[] = {
  376. "off",
  377. "auto",
  378. "on",
  379. };
  380. void cdv_intel_attach_force_audio_property(struct drm_connector *connector)
  381. {
  382. struct drm_device *dev = connector->dev;
  383. struct drm_psb_private *dev_priv = dev->dev_private;
  384. struct drm_property *prop;
  385. int i;
  386. prop = dev_priv->force_audio_property;
  387. if (prop == NULL) {
  388. prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
  389. "audio",
  390. ARRAY_SIZE(force_audio_names));
  391. if (prop == NULL)
  392. return;
  393. for (i = 0; i < ARRAY_SIZE(force_audio_names); i++)
  394. drm_property_add_enum(prop, i, i-1, force_audio_names[i]);
  395. dev_priv->force_audio_property = prop;
  396. }
  397. drm_object_attach_property(&connector->base, prop, 0);
  398. }
  399. static const char *broadcast_rgb_names[] = {
  400. "Full",
  401. "Limited 16:235",
  402. };
  403. void cdv_intel_attach_broadcast_rgb_property(struct drm_connector *connector)
  404. {
  405. struct drm_device *dev = connector->dev;
  406. struct drm_psb_private *dev_priv = dev->dev_private;
  407. struct drm_property *prop;
  408. int i;
  409. prop = dev_priv->broadcast_rgb_property;
  410. if (prop == NULL) {
  411. prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
  412. "Broadcast RGB",
  413. ARRAY_SIZE(broadcast_rgb_names));
  414. if (prop == NULL)
  415. return;
  416. for (i = 0; i < ARRAY_SIZE(broadcast_rgb_names); i++)
  417. drm_property_add_enum(prop, i, i, broadcast_rgb_names[i]);
  418. dev_priv->broadcast_rgb_property = prop;
  419. }
  420. drm_object_attach_property(&connector->base, prop, 0);
  421. }
  422. /* Cedarview */
  423. static const struct psb_offset cdv_regmap[2] = {
  424. {
  425. .fp0 = FPA0,
  426. .fp1 = FPA1,
  427. .cntr = DSPACNTR,
  428. .conf = PIPEACONF,
  429. .src = PIPEASRC,
  430. .dpll = DPLL_A,
  431. .dpll_md = DPLL_A_MD,
  432. .htotal = HTOTAL_A,
  433. .hblank = HBLANK_A,
  434. .hsync = HSYNC_A,
  435. .vtotal = VTOTAL_A,
  436. .vblank = VBLANK_A,
  437. .vsync = VSYNC_A,
  438. .stride = DSPASTRIDE,
  439. .size = DSPASIZE,
  440. .pos = DSPAPOS,
  441. .base = DSPABASE,
  442. .surf = DSPASURF,
  443. .addr = DSPABASE,
  444. .status = PIPEASTAT,
  445. .linoff = DSPALINOFF,
  446. .tileoff = DSPATILEOFF,
  447. .palette = PALETTE_A,
  448. },
  449. {
  450. .fp0 = FPB0,
  451. .fp1 = FPB1,
  452. .cntr = DSPBCNTR,
  453. .conf = PIPEBCONF,
  454. .src = PIPEBSRC,
  455. .dpll = DPLL_B,
  456. .dpll_md = DPLL_B_MD,
  457. .htotal = HTOTAL_B,
  458. .hblank = HBLANK_B,
  459. .hsync = HSYNC_B,
  460. .vtotal = VTOTAL_B,
  461. .vblank = VBLANK_B,
  462. .vsync = VSYNC_B,
  463. .stride = DSPBSTRIDE,
  464. .size = DSPBSIZE,
  465. .pos = DSPBPOS,
  466. .base = DSPBBASE,
  467. .surf = DSPBSURF,
  468. .addr = DSPBBASE,
  469. .status = PIPEBSTAT,
  470. .linoff = DSPBLINOFF,
  471. .tileoff = DSPBTILEOFF,
  472. .palette = PALETTE_B,
  473. }
  474. };
  475. static int cdv_chip_setup(struct drm_device *dev)
  476. {
  477. struct drm_psb_private *dev_priv = dev->dev_private;
  478. INIT_WORK(&dev_priv->hotplug_work, cdv_hotplug_work_func);
  479. if (pci_enable_msi(dev->pdev))
  480. dev_warn(dev->dev, "Enabling MSI failed!\n");
  481. dev_priv->regmap = cdv_regmap;
  482. gma_get_core_freq(dev);
  483. psb_intel_opregion_init(dev);
  484. psb_intel_init_bios(dev);
  485. cdv_hotplug_enable(dev, false);
  486. return 0;
  487. }
  488. /* CDV is much like Poulsbo but has MID like SGX offsets and PM */
  489. const struct psb_ops cdv_chip_ops = {
  490. .name = "GMA3600/3650",
  491. .accel_2d = 0,
  492. .pipes = 2,
  493. .crtcs = 2,
  494. .hdmi_mask = (1 << 0) | (1 << 1),
  495. .lvds_mask = (1 << 1),
  496. .sdvo_mask = (1 << 0),
  497. .cursor_needs_phys = 0,
  498. .sgx_offset = MRST_SGX_OFFSET,
  499. .chip_setup = cdv_chip_setup,
  500. .errata = cdv_errata,
  501. .crtc_helper = &cdv_intel_helper_funcs,
  502. .crtc_funcs = &cdv_intel_crtc_funcs,
  503. .clock_funcs = &cdv_clock_funcs,
  504. .output_init = cdv_output_init,
  505. .hotplug = cdv_hotplug_event,
  506. .hotplug_enable = cdv_hotplug_enable,
  507. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  508. .backlight_init = cdv_backlight_init,
  509. #endif
  510. .init_pm = cdv_init_pm,
  511. .save_regs = cdv_save_display_registers,
  512. .restore_regs = cdv_restore_display_registers,
  513. .power_down = cdv_power_down,
  514. .power_up = cdv_power_up,
  515. .update_wm = cdv_update_wm,
  516. .disable_sr = cdv_disable_sr,
  517. };