cdv_device.c 17 KB

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