oaktrail_device.c 15 KB

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