oaktrail_device.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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 <linux/module.h>
  21. #include <linux/dmi.h>
  22. #include <drm/drmP.h>
  23. #include <drm/drm.h>
  24. #include <drm/gma_drm.h>
  25. #include "psb_drv.h"
  26. #include "psb_reg.h"
  27. #include "psb_intel_reg.h"
  28. #include <asm/intel-mid.h>
  29. #include <asm/intel_scu_ipc.h>
  30. #include "mid_bios.h"
  31. #include "intel_bios.h"
  32. static int oaktrail_output_init(struct drm_device *dev)
  33. {
  34. struct drm_psb_private *dev_priv = dev->dev_private;
  35. if (dev_priv->iLVDS_enable)
  36. oaktrail_lvds_init(dev, &dev_priv->mode_dev);
  37. else
  38. dev_err(dev->dev, "DSI is not supported\n");
  39. if (dev_priv->hdmi_priv)
  40. oaktrail_hdmi_init(dev, &dev_priv->mode_dev);
  41. psb_intel_sdvo_init(dev, SDVOB);
  42. return 0;
  43. }
  44. /*
  45. * Provide the low level interfaces for the Moorestown backlight
  46. */
  47. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  48. #define MRST_BLC_MAX_PWM_REG_FREQ 0xFFFF
  49. #define BLC_PWM_PRECISION_FACTOR 100 /* 10000000 */
  50. #define BLC_PWM_FREQ_CALC_CONSTANT 32
  51. #define MHz 1000000
  52. #define BLC_ADJUSTMENT_MAX 100
  53. static struct backlight_device *oaktrail_backlight_device;
  54. static int oaktrail_brightness;
  55. static int oaktrail_set_brightness(struct backlight_device *bd)
  56. {
  57. struct drm_device *dev = bl_get_data(oaktrail_backlight_device);
  58. struct drm_psb_private *dev_priv = dev->dev_private;
  59. int level = bd->props.brightness;
  60. u32 blc_pwm_ctl;
  61. u32 max_pwm_blc;
  62. /* Percentage 1-100% being valid */
  63. if (level < 1)
  64. level = 1;
  65. if (gma_power_begin(dev, 0)) {
  66. /* Calculate and set the brightness value */
  67. max_pwm_blc = REG_READ(BLC_PWM_CTL) >> 16;
  68. blc_pwm_ctl = level * max_pwm_blc / 100;
  69. /* Adjust the backlight level with the percent in
  70. * dev_priv->blc_adj1;
  71. */
  72. blc_pwm_ctl = blc_pwm_ctl * dev_priv->blc_adj1;
  73. blc_pwm_ctl = blc_pwm_ctl / 100;
  74. /* Adjust the backlight level with the percent in
  75. * dev_priv->blc_adj2;
  76. */
  77. blc_pwm_ctl = blc_pwm_ctl * dev_priv->blc_adj2;
  78. blc_pwm_ctl = blc_pwm_ctl / 100;
  79. /* force PWM bit on */
  80. REG_WRITE(BLC_PWM_CTL2, (0x80000000 | REG_READ(BLC_PWM_CTL2)));
  81. REG_WRITE(BLC_PWM_CTL, (max_pwm_blc << 16) | blc_pwm_ctl);
  82. gma_power_end(dev);
  83. }
  84. oaktrail_brightness = level;
  85. return 0;
  86. }
  87. static int oaktrail_get_brightness(struct backlight_device *bd)
  88. {
  89. /* return locally cached var instead of HW read (due to DPST etc.) */
  90. /* FIXME: ideally return actual value in case firmware fiddled with
  91. it */
  92. return oaktrail_brightness;
  93. }
  94. static int device_backlight_init(struct drm_device *dev)
  95. {
  96. struct drm_psb_private *dev_priv = dev->dev_private;
  97. unsigned long core_clock;
  98. u16 bl_max_freq;
  99. uint32_t value;
  100. uint32_t blc_pwm_precision_factor;
  101. dev_priv->blc_adj1 = BLC_ADJUSTMENT_MAX;
  102. dev_priv->blc_adj2 = BLC_ADJUSTMENT_MAX;
  103. bl_max_freq = 256;
  104. /* this needs to be set elsewhere */
  105. blc_pwm_precision_factor = BLC_PWM_PRECISION_FACTOR;
  106. core_clock = dev_priv->core_freq;
  107. value = (core_clock * MHz) / BLC_PWM_FREQ_CALC_CONSTANT;
  108. value *= blc_pwm_precision_factor;
  109. value /= bl_max_freq;
  110. value /= blc_pwm_precision_factor;
  111. if (value > (unsigned long long)MRST_BLC_MAX_PWM_REG_FREQ)
  112. return -ERANGE;
  113. if (gma_power_begin(dev, false)) {
  114. REG_WRITE(BLC_PWM_CTL2, (0x80000000 | REG_READ(BLC_PWM_CTL2)));
  115. REG_WRITE(BLC_PWM_CTL, value | (value << 16));
  116. gma_power_end(dev);
  117. }
  118. return 0;
  119. }
  120. static const struct backlight_ops oaktrail_ops = {
  121. .get_brightness = oaktrail_get_brightness,
  122. .update_status = oaktrail_set_brightness,
  123. };
  124. static int oaktrail_backlight_init(struct drm_device *dev)
  125. {
  126. struct drm_psb_private *dev_priv = dev->dev_private;
  127. int ret;
  128. struct backlight_properties props;
  129. memset(&props, 0, sizeof(struct backlight_properties));
  130. props.max_brightness = 100;
  131. props.type = BACKLIGHT_PLATFORM;
  132. oaktrail_backlight_device = backlight_device_register("oaktrail-bl",
  133. NULL, (void *)dev, &oaktrail_ops, &props);
  134. if (IS_ERR(oaktrail_backlight_device))
  135. return PTR_ERR(oaktrail_backlight_device);
  136. ret = device_backlight_init(dev);
  137. if (ret < 0) {
  138. backlight_device_unregister(oaktrail_backlight_device);
  139. return ret;
  140. }
  141. oaktrail_backlight_device->props.brightness = 100;
  142. oaktrail_backlight_device->props.max_brightness = 100;
  143. backlight_update_status(oaktrail_backlight_device);
  144. dev_priv->backlight_device = oaktrail_backlight_device;
  145. return 0;
  146. }
  147. #endif
  148. /*
  149. * Provide the Moorestown specific chip logic and low level methods
  150. * for power management
  151. */
  152. /**
  153. * oaktrail_save_display_registers - save registers lost on suspend
  154. * @dev: our DRM device
  155. *
  156. * Save the state we need in order to be able to restore the interface
  157. * upon resume from suspend
  158. */
  159. static int oaktrail_save_display_registers(struct drm_device *dev)
  160. {
  161. struct drm_psb_private *dev_priv = dev->dev_private;
  162. struct psb_save_area *regs = &dev_priv->regs;
  163. struct psb_pipe *p = &regs->pipe[0];
  164. int i;
  165. u32 pp_stat;
  166. /* Display arbitration control + watermarks */
  167. regs->psb.saveDSPARB = PSB_RVDC32(DSPARB);
  168. regs->psb.saveDSPFW1 = PSB_RVDC32(DSPFW1);
  169. regs->psb.saveDSPFW2 = PSB_RVDC32(DSPFW2);
  170. regs->psb.saveDSPFW3 = PSB_RVDC32(DSPFW3);
  171. regs->psb.saveDSPFW4 = PSB_RVDC32(DSPFW4);
  172. regs->psb.saveDSPFW5 = PSB_RVDC32(DSPFW5);
  173. regs->psb.saveDSPFW6 = PSB_RVDC32(DSPFW6);
  174. regs->psb.saveCHICKENBIT = PSB_RVDC32(DSPCHICKENBIT);
  175. /* Pipe & plane A info */
  176. p->conf = PSB_RVDC32(PIPEACONF);
  177. p->src = PSB_RVDC32(PIPEASRC);
  178. p->fp0 = PSB_RVDC32(MRST_FPA0);
  179. p->fp1 = PSB_RVDC32(MRST_FPA1);
  180. p->dpll = PSB_RVDC32(MRST_DPLL_A);
  181. p->htotal = PSB_RVDC32(HTOTAL_A);
  182. p->hblank = PSB_RVDC32(HBLANK_A);
  183. p->hsync = PSB_RVDC32(HSYNC_A);
  184. p->vtotal = PSB_RVDC32(VTOTAL_A);
  185. p->vblank = PSB_RVDC32(VBLANK_A);
  186. p->vsync = PSB_RVDC32(VSYNC_A);
  187. regs->psb.saveBCLRPAT_A = PSB_RVDC32(BCLRPAT_A);
  188. p->cntr = PSB_RVDC32(DSPACNTR);
  189. p->stride = PSB_RVDC32(DSPASTRIDE);
  190. p->addr = PSB_RVDC32(DSPABASE);
  191. p->surf = PSB_RVDC32(DSPASURF);
  192. p->linoff = PSB_RVDC32(DSPALINOFF);
  193. p->tileoff = PSB_RVDC32(DSPATILEOFF);
  194. /* Save cursor regs */
  195. regs->psb.saveDSPACURSOR_CTRL = PSB_RVDC32(CURACNTR);
  196. regs->psb.saveDSPACURSOR_BASE = PSB_RVDC32(CURABASE);
  197. regs->psb.saveDSPACURSOR_POS = PSB_RVDC32(CURAPOS);
  198. /* Save palette (gamma) */
  199. for (i = 0; i < 256; i++)
  200. p->palette[i] = PSB_RVDC32(PALETTE_A + (i << 2));
  201. if (dev_priv->hdmi_priv)
  202. oaktrail_hdmi_save(dev);
  203. /* Save performance state */
  204. regs->psb.savePERF_MODE = PSB_RVDC32(MRST_PERF_MODE);
  205. /* LVDS state */
  206. regs->psb.savePP_CONTROL = PSB_RVDC32(PP_CONTROL);
  207. regs->psb.savePFIT_PGM_RATIOS = PSB_RVDC32(PFIT_PGM_RATIOS);
  208. regs->psb.savePFIT_AUTO_RATIOS = PSB_RVDC32(PFIT_AUTO_RATIOS);
  209. regs->saveBLC_PWM_CTL = PSB_RVDC32(BLC_PWM_CTL);
  210. regs->saveBLC_PWM_CTL2 = PSB_RVDC32(BLC_PWM_CTL2);
  211. regs->psb.saveLVDS = PSB_RVDC32(LVDS);
  212. regs->psb.savePFIT_CONTROL = PSB_RVDC32(PFIT_CONTROL);
  213. regs->psb.savePP_ON_DELAYS = PSB_RVDC32(LVDSPP_ON);
  214. regs->psb.savePP_OFF_DELAYS = PSB_RVDC32(LVDSPP_OFF);
  215. regs->psb.savePP_DIVISOR = PSB_RVDC32(PP_CYCLE);
  216. /* HW overlay */
  217. regs->psb.saveOV_OVADD = PSB_RVDC32(OV_OVADD);
  218. regs->psb.saveOV_OGAMC0 = PSB_RVDC32(OV_OGAMC0);
  219. regs->psb.saveOV_OGAMC1 = PSB_RVDC32(OV_OGAMC1);
  220. regs->psb.saveOV_OGAMC2 = PSB_RVDC32(OV_OGAMC2);
  221. regs->psb.saveOV_OGAMC3 = PSB_RVDC32(OV_OGAMC3);
  222. regs->psb.saveOV_OGAMC4 = PSB_RVDC32(OV_OGAMC4);
  223. regs->psb.saveOV_OGAMC5 = PSB_RVDC32(OV_OGAMC5);
  224. /* DPST registers */
  225. regs->psb.saveHISTOGRAM_INT_CONTROL_REG =
  226. PSB_RVDC32(HISTOGRAM_INT_CONTROL);
  227. regs->psb.saveHISTOGRAM_LOGIC_CONTROL_REG =
  228. PSB_RVDC32(HISTOGRAM_LOGIC_CONTROL);
  229. regs->psb.savePWM_CONTROL_LOGIC = PSB_RVDC32(PWM_CONTROL_LOGIC);
  230. if (dev_priv->iLVDS_enable) {
  231. /* Shut down the panel */
  232. PSB_WVDC32(0, PP_CONTROL);
  233. do {
  234. pp_stat = PSB_RVDC32(PP_STATUS);
  235. } while (pp_stat & 0x80000000);
  236. /* Turn off the plane */
  237. PSB_WVDC32(0x58000000, DSPACNTR);
  238. /* Trigger the plane disable */
  239. PSB_WVDC32(0, DSPASURF);
  240. /* Wait ~4 ticks */
  241. msleep(4);
  242. /* Turn off pipe */
  243. PSB_WVDC32(0x0, PIPEACONF);
  244. /* Wait ~8 ticks */
  245. msleep(8);
  246. /* Turn off PLLs */
  247. PSB_WVDC32(0, MRST_DPLL_A);
  248. }
  249. return 0;
  250. }
  251. /**
  252. * oaktrail_restore_display_registers - restore lost register state
  253. * @dev: our DRM device
  254. *
  255. * Restore register state that was lost during suspend and resume.
  256. */
  257. static int oaktrail_restore_display_registers(struct drm_device *dev)
  258. {
  259. struct drm_psb_private *dev_priv = dev->dev_private;
  260. struct psb_save_area *regs = &dev_priv->regs;
  261. struct psb_pipe *p = &regs->pipe[0];
  262. u32 pp_stat;
  263. int i;
  264. /* Display arbitration + watermarks */
  265. PSB_WVDC32(regs->psb.saveDSPARB, DSPARB);
  266. PSB_WVDC32(regs->psb.saveDSPFW1, DSPFW1);
  267. PSB_WVDC32(regs->psb.saveDSPFW2, DSPFW2);
  268. PSB_WVDC32(regs->psb.saveDSPFW3, DSPFW3);
  269. PSB_WVDC32(regs->psb.saveDSPFW4, DSPFW4);
  270. PSB_WVDC32(regs->psb.saveDSPFW5, DSPFW5);
  271. PSB_WVDC32(regs->psb.saveDSPFW6, DSPFW6);
  272. PSB_WVDC32(regs->psb.saveCHICKENBIT, DSPCHICKENBIT);
  273. /* Make sure VGA plane is off. it initializes to on after reset!*/
  274. PSB_WVDC32(0x80000000, VGACNTRL);
  275. /* set the plls */
  276. PSB_WVDC32(p->fp0, MRST_FPA0);
  277. PSB_WVDC32(p->fp1, MRST_FPA1);
  278. /* Actually enable it */
  279. PSB_WVDC32(p->dpll, MRST_DPLL_A);
  280. DRM_UDELAY(150);
  281. /* Restore mode */
  282. PSB_WVDC32(p->htotal, HTOTAL_A);
  283. PSB_WVDC32(p->hblank, HBLANK_A);
  284. PSB_WVDC32(p->hsync, HSYNC_A);
  285. PSB_WVDC32(p->vtotal, VTOTAL_A);
  286. PSB_WVDC32(p->vblank, VBLANK_A);
  287. PSB_WVDC32(p->vsync, VSYNC_A);
  288. PSB_WVDC32(p->src, PIPEASRC);
  289. PSB_WVDC32(regs->psb.saveBCLRPAT_A, BCLRPAT_A);
  290. /* Restore performance mode*/
  291. PSB_WVDC32(regs->psb.savePERF_MODE, MRST_PERF_MODE);
  292. /* Enable the pipe*/
  293. if (dev_priv->iLVDS_enable)
  294. PSB_WVDC32(p->conf, PIPEACONF);
  295. /* Set up the plane*/
  296. PSB_WVDC32(p->linoff, DSPALINOFF);
  297. PSB_WVDC32(p->stride, DSPASTRIDE);
  298. PSB_WVDC32(p->tileoff, DSPATILEOFF);
  299. /* Enable the plane */
  300. PSB_WVDC32(p->cntr, DSPACNTR);
  301. PSB_WVDC32(p->surf, DSPASURF);
  302. /* Enable Cursor A */
  303. PSB_WVDC32(regs->psb.saveDSPACURSOR_CTRL, CURACNTR);
  304. PSB_WVDC32(regs->psb.saveDSPACURSOR_POS, CURAPOS);
  305. PSB_WVDC32(regs->psb.saveDSPACURSOR_BASE, CURABASE);
  306. /* Restore palette (gamma) */
  307. for (i = 0; i < 256; i++)
  308. PSB_WVDC32(p->palette[i], PALETTE_A + (i << 2));
  309. if (dev_priv->hdmi_priv)
  310. oaktrail_hdmi_restore(dev);
  311. if (dev_priv->iLVDS_enable) {
  312. PSB_WVDC32(regs->saveBLC_PWM_CTL2, BLC_PWM_CTL2);
  313. PSB_WVDC32(regs->psb.saveLVDS, LVDS); /*port 61180h*/
  314. PSB_WVDC32(regs->psb.savePFIT_CONTROL, PFIT_CONTROL);
  315. PSB_WVDC32(regs->psb.savePFIT_PGM_RATIOS, PFIT_PGM_RATIOS);
  316. PSB_WVDC32(regs->psb.savePFIT_AUTO_RATIOS, PFIT_AUTO_RATIOS);
  317. PSB_WVDC32(regs->saveBLC_PWM_CTL, BLC_PWM_CTL);
  318. PSB_WVDC32(regs->psb.savePP_ON_DELAYS, LVDSPP_ON);
  319. PSB_WVDC32(regs->psb.savePP_OFF_DELAYS, LVDSPP_OFF);
  320. PSB_WVDC32(regs->psb.savePP_DIVISOR, PP_CYCLE);
  321. PSB_WVDC32(regs->psb.savePP_CONTROL, PP_CONTROL);
  322. }
  323. /* Wait for cycle delay */
  324. do {
  325. pp_stat = PSB_RVDC32(PP_STATUS);
  326. } while (pp_stat & 0x08000000);
  327. /* Wait for panel power up */
  328. do {
  329. pp_stat = PSB_RVDC32(PP_STATUS);
  330. } while (pp_stat & 0x10000000);
  331. /* Restore HW overlay */
  332. PSB_WVDC32(regs->psb.saveOV_OVADD, OV_OVADD);
  333. PSB_WVDC32(regs->psb.saveOV_OGAMC0, OV_OGAMC0);
  334. PSB_WVDC32(regs->psb.saveOV_OGAMC1, OV_OGAMC1);
  335. PSB_WVDC32(regs->psb.saveOV_OGAMC2, OV_OGAMC2);
  336. PSB_WVDC32(regs->psb.saveOV_OGAMC3, OV_OGAMC3);
  337. PSB_WVDC32(regs->psb.saveOV_OGAMC4, OV_OGAMC4);
  338. PSB_WVDC32(regs->psb.saveOV_OGAMC5, OV_OGAMC5);
  339. /* DPST registers */
  340. PSB_WVDC32(regs->psb.saveHISTOGRAM_INT_CONTROL_REG,
  341. HISTOGRAM_INT_CONTROL);
  342. PSB_WVDC32(regs->psb.saveHISTOGRAM_LOGIC_CONTROL_REG,
  343. HISTOGRAM_LOGIC_CONTROL);
  344. PSB_WVDC32(regs->psb.savePWM_CONTROL_LOGIC, PWM_CONTROL_LOGIC);
  345. return 0;
  346. }
  347. /**
  348. * oaktrail_power_down - power down the display island
  349. * @dev: our DRM device
  350. *
  351. * Power down the display interface of our device
  352. */
  353. static int oaktrail_power_down(struct drm_device *dev)
  354. {
  355. struct drm_psb_private *dev_priv = dev->dev_private;
  356. u32 pwr_mask ;
  357. u32 pwr_sts;
  358. pwr_mask = PSB_PWRGT_DISPLAY_MASK;
  359. outl(pwr_mask, dev_priv->ospm_base + PSB_PM_SSC);
  360. while (true) {
  361. pwr_sts = inl(dev_priv->ospm_base + PSB_PM_SSS);
  362. if ((pwr_sts & pwr_mask) == pwr_mask)
  363. break;
  364. else
  365. udelay(10);
  366. }
  367. return 0;
  368. }
  369. /*
  370. * oaktrail_power_up
  371. *
  372. * Restore power to the specified island(s) (powergating)
  373. */
  374. static int oaktrail_power_up(struct drm_device *dev)
  375. {
  376. struct drm_psb_private *dev_priv = dev->dev_private;
  377. u32 pwr_mask = PSB_PWRGT_DISPLAY_MASK;
  378. u32 pwr_sts, pwr_cnt;
  379. pwr_cnt = inl(dev_priv->ospm_base + PSB_PM_SSC);
  380. pwr_cnt &= ~pwr_mask;
  381. outl(pwr_cnt, (dev_priv->ospm_base + PSB_PM_SSC));
  382. while (true) {
  383. pwr_sts = inl(dev_priv->ospm_base + PSB_PM_SSS);
  384. if ((pwr_sts & pwr_mask) == 0)
  385. break;
  386. else
  387. udelay(10);
  388. }
  389. return 0;
  390. }
  391. /* Oaktrail */
  392. static const struct psb_offset oaktrail_regmap[2] = {
  393. {
  394. .fp0 = MRST_FPA0,
  395. .fp1 = MRST_FPA1,
  396. .cntr = DSPACNTR,
  397. .conf = PIPEACONF,
  398. .src = PIPEASRC,
  399. .dpll = MRST_DPLL_A,
  400. .htotal = HTOTAL_A,
  401. .hblank = HBLANK_A,
  402. .hsync = HSYNC_A,
  403. .vtotal = VTOTAL_A,
  404. .vblank = VBLANK_A,
  405. .vsync = VSYNC_A,
  406. .stride = DSPASTRIDE,
  407. .size = DSPASIZE,
  408. .pos = DSPAPOS,
  409. .surf = DSPASURF,
  410. .addr = MRST_DSPABASE,
  411. .base = MRST_DSPABASE,
  412. .status = PIPEASTAT,
  413. .linoff = DSPALINOFF,
  414. .tileoff = DSPATILEOFF,
  415. .palette = PALETTE_A,
  416. },
  417. {
  418. .fp0 = FPB0,
  419. .fp1 = FPB1,
  420. .cntr = DSPBCNTR,
  421. .conf = PIPEBCONF,
  422. .src = PIPEBSRC,
  423. .dpll = DPLL_B,
  424. .htotal = HTOTAL_B,
  425. .hblank = HBLANK_B,
  426. .hsync = HSYNC_B,
  427. .vtotal = VTOTAL_B,
  428. .vblank = VBLANK_B,
  429. .vsync = VSYNC_B,
  430. .stride = DSPBSTRIDE,
  431. .size = DSPBSIZE,
  432. .pos = DSPBPOS,
  433. .surf = DSPBSURF,
  434. .addr = DSPBBASE,
  435. .base = DSPBBASE,
  436. .status = PIPEBSTAT,
  437. .linoff = DSPBLINOFF,
  438. .tileoff = DSPBTILEOFF,
  439. .palette = PALETTE_B,
  440. },
  441. };
  442. static int oaktrail_chip_setup(struct drm_device *dev)
  443. {
  444. struct drm_psb_private *dev_priv = dev->dev_private;
  445. int ret;
  446. if (pci_enable_msi(dev->pdev))
  447. dev_warn(dev->dev, "Enabling MSI failed!\n");
  448. dev_priv->regmap = oaktrail_regmap;
  449. ret = mid_chip_setup(dev);
  450. if (ret < 0)
  451. return ret;
  452. if (!dev_priv->has_gct) {
  453. /* Now pull the BIOS data */
  454. psb_intel_opregion_init(dev);
  455. psb_intel_init_bios(dev);
  456. }
  457. gma_intel_setup_gmbus(dev);
  458. oaktrail_hdmi_setup(dev);
  459. return 0;
  460. }
  461. static void oaktrail_teardown(struct drm_device *dev)
  462. {
  463. struct drm_psb_private *dev_priv = dev->dev_private;
  464. gma_intel_teardown_gmbus(dev);
  465. oaktrail_hdmi_teardown(dev);
  466. if (!dev_priv->has_gct)
  467. psb_intel_destroy_bios(dev);
  468. }
  469. const struct psb_ops oaktrail_chip_ops = {
  470. .name = "Oaktrail",
  471. .accel_2d = 1,
  472. .pipes = 2,
  473. .crtcs = 2,
  474. .hdmi_mask = (1 << 1),
  475. .lvds_mask = (1 << 0),
  476. .sdvo_mask = (1 << 1),
  477. .cursor_needs_phys = 0,
  478. .sgx_offset = MRST_SGX_OFFSET,
  479. .chip_setup = oaktrail_chip_setup,
  480. .chip_teardown = oaktrail_teardown,
  481. .crtc_helper = &oaktrail_helper_funcs,
  482. .crtc_funcs = &psb_intel_crtc_funcs,
  483. .output_init = oaktrail_output_init,
  484. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  485. .backlight_init = oaktrail_backlight_init,
  486. #endif
  487. .save_regs = oaktrail_save_display_registers,
  488. .restore_regs = oaktrail_restore_display_registers,
  489. .power_down = oaktrail_power_down,
  490. .power_up = oaktrail_power_up,
  491. .i2c_bus = 1,
  492. };