psb_drv.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. /**************************************************************************
  2. * Copyright (c) 2007-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. #ifndef _PSB_DRV_H_
  20. #define _PSB_DRV_H_
  21. #include <linux/kref.h>
  22. #include <drm/drmP.h>
  23. #include <drm/drm_global.h>
  24. #include <drm/gma_drm.h>
  25. #include "psb_reg.h"
  26. #include "psb_intel_drv.h"
  27. #include "gma_display.h"
  28. #include "intel_bios.h"
  29. #include "gtt.h"
  30. #include "power.h"
  31. #include "opregion.h"
  32. #include "oaktrail.h"
  33. #include "mmu.h"
  34. #define DRIVER_AUTHOR "Alan Cox <alan@linux.intel.com> and others"
  35. #define DRIVER_LICENSE "GPL"
  36. #define DRIVER_NAME "gma500"
  37. #define DRIVER_DESC "DRM driver for the Intel GMA500, GMA600, GMA3600, GMA3650"
  38. #define DRIVER_DATE "20140314"
  39. #define DRIVER_MAJOR 1
  40. #define DRIVER_MINOR 0
  41. #define DRIVER_PATCHLEVEL 0
  42. /* Append new drm mode definition here, align with libdrm definition */
  43. #define DRM_MODE_SCALE_NO_SCALE 2
  44. enum {
  45. CHIP_PSB_8108 = 0, /* Poulsbo */
  46. CHIP_PSB_8109 = 1, /* Poulsbo */
  47. CHIP_MRST_4100 = 2, /* Moorestown/Oaktrail */
  48. CHIP_MFLD_0130 = 3, /* Medfield */
  49. };
  50. #define IS_PSB(dev) (((dev)->pdev->device & 0xfffe) == 0x8108)
  51. #define IS_MRST(dev) (((dev)->pdev->device & 0xfff0) == 0x4100)
  52. #define IS_MFLD(dev) (((dev)->pdev->device & 0xfff8) == 0x0130)
  53. #define IS_CDV(dev) (((dev)->pdev->device & 0xfff0) == 0x0be0)
  54. /* Hardware offsets */
  55. #define PSB_VDC_OFFSET 0x00000000
  56. #define PSB_VDC_SIZE 0x000080000
  57. #define MRST_MMIO_SIZE 0x0000C0000
  58. #define MDFLD_MMIO_SIZE 0x000100000
  59. #define PSB_SGX_SIZE 0x8000
  60. #define PSB_SGX_OFFSET 0x00040000
  61. #define MRST_SGX_OFFSET 0x00080000
  62. /* PCI resource identifiers */
  63. #define PSB_MMIO_RESOURCE 0
  64. #define PSB_AUX_RESOURCE 0
  65. #define PSB_GATT_RESOURCE 2
  66. #define PSB_GTT_RESOURCE 3
  67. /* PCI configuration */
  68. #define PSB_GMCH_CTRL 0x52
  69. #define PSB_BSM 0x5C
  70. #define _PSB_GMCH_ENABLED 0x4
  71. #define PSB_PGETBL_CTL 0x2020
  72. #define _PSB_PGETBL_ENABLED 0x00000001
  73. #define PSB_SGX_2D_SLAVE_PORT 0x4000
  74. #define PSB_LPC_GBA 0x44
  75. /* TODO: To get rid of */
  76. #define PSB_TT_PRIV0_LIMIT (256*1024*1024)
  77. #define PSB_TT_PRIV0_PLIMIT (PSB_TT_PRIV0_LIMIT >> PAGE_SHIFT)
  78. /* SGX side MMU definitions (these can probably go) */
  79. /* Flags for external memory type field */
  80. #define PSB_MMU_CACHED_MEMORY 0x0001 /* Bind to MMU only */
  81. #define PSB_MMU_RO_MEMORY 0x0002 /* MMU RO memory */
  82. #define PSB_MMU_WO_MEMORY 0x0004 /* MMU WO memory */
  83. /* PTE's and PDE's */
  84. #define PSB_PDE_MASK 0x003FFFFF
  85. #define PSB_PDE_SHIFT 22
  86. #define PSB_PTE_SHIFT 12
  87. /* Cache control */
  88. #define PSB_PTE_VALID 0x0001 /* PTE / PDE valid */
  89. #define PSB_PTE_WO 0x0002 /* Write only */
  90. #define PSB_PTE_RO 0x0004 /* Read only */
  91. #define PSB_PTE_CACHED 0x0008 /* CPU cache coherent */
  92. /* VDC registers and bits */
  93. #define PSB_MSVDX_CLOCKGATING 0x2064
  94. #define PSB_TOPAZ_CLOCKGATING 0x2068
  95. #define PSB_HWSTAM 0x2098
  96. #define PSB_INSTPM 0x20C0
  97. #define PSB_INT_IDENTITY_R 0x20A4
  98. #define _PSB_IRQ_ASLE (1<<0)
  99. #define _MDFLD_PIPEC_EVENT_FLAG (1<<2)
  100. #define _MDFLD_PIPEC_VBLANK_FLAG (1<<3)
  101. #define _PSB_DPST_PIPEB_FLAG (1<<4)
  102. #define _MDFLD_PIPEB_EVENT_FLAG (1<<4)
  103. #define _PSB_VSYNC_PIPEB_FLAG (1<<5)
  104. #define _PSB_DPST_PIPEA_FLAG (1<<6)
  105. #define _PSB_PIPEA_EVENT_FLAG (1<<6)
  106. #define _PSB_VSYNC_PIPEA_FLAG (1<<7)
  107. #define _MDFLD_MIPIA_FLAG (1<<16)
  108. #define _MDFLD_MIPIC_FLAG (1<<17)
  109. #define _PSB_IRQ_DISP_HOTSYNC (1<<17)
  110. #define _PSB_IRQ_SGX_FLAG (1<<18)
  111. #define _PSB_IRQ_MSVDX_FLAG (1<<19)
  112. #define _LNC_IRQ_TOPAZ_FLAG (1<<20)
  113. #define _PSB_PIPE_EVENT_FLAG (_PSB_VSYNC_PIPEA_FLAG | \
  114. _PSB_VSYNC_PIPEB_FLAG)
  115. /* This flag includes all the display IRQ bits excepts the vblank irqs. */
  116. #define _MDFLD_DISP_ALL_IRQ_FLAG (_MDFLD_PIPEC_EVENT_FLAG | \
  117. _MDFLD_PIPEB_EVENT_FLAG | \
  118. _PSB_PIPEA_EVENT_FLAG | \
  119. _PSB_VSYNC_PIPEA_FLAG | \
  120. _MDFLD_MIPIA_FLAG | \
  121. _MDFLD_MIPIC_FLAG)
  122. #define PSB_INT_IDENTITY_R 0x20A4
  123. #define PSB_INT_MASK_R 0x20A8
  124. #define PSB_INT_ENABLE_R 0x20A0
  125. #define _PSB_MMU_ER_MASK 0x0001FF00
  126. #define _PSB_MMU_ER_HOST (1 << 16)
  127. #define GPIOA 0x5010
  128. #define GPIOB 0x5014
  129. #define GPIOC 0x5018
  130. #define GPIOD 0x501c
  131. #define GPIOE 0x5020
  132. #define GPIOF 0x5024
  133. #define GPIOG 0x5028
  134. #define GPIOH 0x502c
  135. #define GPIO_CLOCK_DIR_MASK (1 << 0)
  136. #define GPIO_CLOCK_DIR_IN (0 << 1)
  137. #define GPIO_CLOCK_DIR_OUT (1 << 1)
  138. #define GPIO_CLOCK_VAL_MASK (1 << 2)
  139. #define GPIO_CLOCK_VAL_OUT (1 << 3)
  140. #define GPIO_CLOCK_VAL_IN (1 << 4)
  141. #define GPIO_CLOCK_PULLUP_DISABLE (1 << 5)
  142. #define GPIO_DATA_DIR_MASK (1 << 8)
  143. #define GPIO_DATA_DIR_IN (0 << 9)
  144. #define GPIO_DATA_DIR_OUT (1 << 9)
  145. #define GPIO_DATA_VAL_MASK (1 << 10)
  146. #define GPIO_DATA_VAL_OUT (1 << 11)
  147. #define GPIO_DATA_VAL_IN (1 << 12)
  148. #define GPIO_DATA_PULLUP_DISABLE (1 << 13)
  149. #define VCLK_DIVISOR_VGA0 0x6000
  150. #define VCLK_DIVISOR_VGA1 0x6004
  151. #define VCLK_POST_DIV 0x6010
  152. #define PSB_COMM_2D (PSB_ENGINE_2D << 4)
  153. #define PSB_COMM_3D (PSB_ENGINE_3D << 4)
  154. #define PSB_COMM_TA (PSB_ENGINE_TA << 4)
  155. #define PSB_COMM_HP (PSB_ENGINE_HP << 4)
  156. #define PSB_COMM_USER_IRQ (1024 >> 2)
  157. #define PSB_COMM_USER_IRQ_LOST (PSB_COMM_USER_IRQ + 1)
  158. #define PSB_COMM_FW (2048 >> 2)
  159. #define PSB_UIRQ_VISTEST 1
  160. #define PSB_UIRQ_OOM_REPLY 2
  161. #define PSB_UIRQ_FIRE_TA_REPLY 3
  162. #define PSB_UIRQ_FIRE_RASTER_REPLY 4
  163. #define PSB_2D_SIZE (256*1024*1024)
  164. #define PSB_MAX_RELOC_PAGES 1024
  165. #define PSB_LOW_REG_OFFS 0x0204
  166. #define PSB_HIGH_REG_OFFS 0x0600
  167. #define PSB_NUM_VBLANKS 2
  168. #define PSB_2D_SIZE (256*1024*1024)
  169. #define PSB_MAX_RELOC_PAGES 1024
  170. #define PSB_LOW_REG_OFFS 0x0204
  171. #define PSB_HIGH_REG_OFFS 0x0600
  172. #define PSB_NUM_VBLANKS 2
  173. #define PSB_WATCHDOG_DELAY (HZ * 2)
  174. #define PSB_LID_DELAY (HZ / 10)
  175. #define MDFLD_PNW_B0 0x04
  176. #define MDFLD_PNW_C0 0x08
  177. #define MDFLD_DSR_2D_3D_0 (1 << 0)
  178. #define MDFLD_DSR_2D_3D_2 (1 << 1)
  179. #define MDFLD_DSR_CURSOR_0 (1 << 2)
  180. #define MDFLD_DSR_CURSOR_2 (1 << 3)
  181. #define MDFLD_DSR_OVERLAY_0 (1 << 4)
  182. #define MDFLD_DSR_OVERLAY_2 (1 << 5)
  183. #define MDFLD_DSR_MIPI_CONTROL (1 << 6)
  184. #define MDFLD_DSR_DAMAGE_MASK_0 ((1 << 0) | (1 << 2) | (1 << 4))
  185. #define MDFLD_DSR_DAMAGE_MASK_2 ((1 << 1) | (1 << 3) | (1 << 5))
  186. #define MDFLD_DSR_2D_3D (MDFLD_DSR_2D_3D_0 | MDFLD_DSR_2D_3D_2)
  187. #define MDFLD_DSR_RR 45
  188. #define MDFLD_DPU_ENABLE (1 << 31)
  189. #define MDFLD_DSR_FULLSCREEN (1 << 30)
  190. #define MDFLD_DSR_DELAY (HZ / MDFLD_DSR_RR)
  191. #define PSB_PWR_STATE_ON 1
  192. #define PSB_PWR_STATE_OFF 2
  193. #define PSB_PMPOLICY_NOPM 0
  194. #define PSB_PMPOLICY_CLOCKGATING 1
  195. #define PSB_PMPOLICY_POWERDOWN 2
  196. #define PSB_PMSTATE_POWERUP 0
  197. #define PSB_PMSTATE_CLOCKGATED 1
  198. #define PSB_PMSTATE_POWERDOWN 2
  199. #define PSB_PCIx_MSI_ADDR_LOC 0x94
  200. #define PSB_PCIx_MSI_DATA_LOC 0x98
  201. /* Medfield crystal settings */
  202. #define KSEL_CRYSTAL_19 1
  203. #define KSEL_BYPASS_19 5
  204. #define KSEL_BYPASS_25 6
  205. #define KSEL_BYPASS_83_100 7
  206. struct opregion_header;
  207. struct opregion_acpi;
  208. struct opregion_swsci;
  209. struct opregion_asle;
  210. struct psb_intel_opregion {
  211. struct opregion_header *header;
  212. struct opregion_acpi *acpi;
  213. struct opregion_swsci *swsci;
  214. struct opregion_asle *asle;
  215. void *vbt;
  216. u32 __iomem *lid_state;
  217. struct work_struct asle_work;
  218. };
  219. struct sdvo_device_mapping {
  220. u8 initialized;
  221. u8 dvo_port;
  222. u8 slave_addr;
  223. u8 dvo_wiring;
  224. u8 i2c_pin;
  225. u8 i2c_speed;
  226. u8 ddc_pin;
  227. };
  228. struct intel_gmbus {
  229. struct i2c_adapter adapter;
  230. struct i2c_adapter *force_bit;
  231. u32 reg0;
  232. };
  233. /* Register offset maps */
  234. struct psb_offset {
  235. u32 fp0;
  236. u32 fp1;
  237. u32 cntr;
  238. u32 conf;
  239. u32 src;
  240. u32 dpll;
  241. u32 dpll_md;
  242. u32 htotal;
  243. u32 hblank;
  244. u32 hsync;
  245. u32 vtotal;
  246. u32 vblank;
  247. u32 vsync;
  248. u32 stride;
  249. u32 size;
  250. u32 pos;
  251. u32 surf;
  252. u32 addr;
  253. u32 base;
  254. u32 status;
  255. u32 linoff;
  256. u32 tileoff;
  257. u32 palette;
  258. };
  259. /*
  260. * Register save state. This is used to hold the context when the
  261. * device is powered off. In the case of Oaktrail this can (but does not
  262. * yet) include screen blank. Operations occuring during the save
  263. * update the register cache instead.
  264. */
  265. /* Common status for pipes */
  266. struct psb_pipe {
  267. u32 fp0;
  268. u32 fp1;
  269. u32 cntr;
  270. u32 conf;
  271. u32 src;
  272. u32 dpll;
  273. u32 dpll_md;
  274. u32 htotal;
  275. u32 hblank;
  276. u32 hsync;
  277. u32 vtotal;
  278. u32 vblank;
  279. u32 vsync;
  280. u32 stride;
  281. u32 size;
  282. u32 pos;
  283. u32 base;
  284. u32 surf;
  285. u32 addr;
  286. u32 status;
  287. u32 linoff;
  288. u32 tileoff;
  289. u32 palette[256];
  290. };
  291. struct psb_state {
  292. uint32_t saveVCLK_DIVISOR_VGA0;
  293. uint32_t saveVCLK_DIVISOR_VGA1;
  294. uint32_t saveVCLK_POST_DIV;
  295. uint32_t saveVGACNTRL;
  296. uint32_t saveADPA;
  297. uint32_t saveLVDS;
  298. uint32_t saveDVOA;
  299. uint32_t saveDVOB;
  300. uint32_t saveDVOC;
  301. uint32_t savePP_ON;
  302. uint32_t savePP_OFF;
  303. uint32_t savePP_CONTROL;
  304. uint32_t savePP_CYCLE;
  305. uint32_t savePFIT_CONTROL;
  306. uint32_t saveCLOCKGATING;
  307. uint32_t saveDSPARB;
  308. uint32_t savePFIT_AUTO_RATIOS;
  309. uint32_t savePFIT_PGM_RATIOS;
  310. uint32_t savePP_ON_DELAYS;
  311. uint32_t savePP_OFF_DELAYS;
  312. uint32_t savePP_DIVISOR;
  313. uint32_t saveBCLRPAT_A;
  314. uint32_t saveBCLRPAT_B;
  315. uint32_t savePERF_MODE;
  316. uint32_t saveDSPFW1;
  317. uint32_t saveDSPFW2;
  318. uint32_t saveDSPFW3;
  319. uint32_t saveDSPFW4;
  320. uint32_t saveDSPFW5;
  321. uint32_t saveDSPFW6;
  322. uint32_t saveCHICKENBIT;
  323. uint32_t saveDSPACURSOR_CTRL;
  324. uint32_t saveDSPBCURSOR_CTRL;
  325. uint32_t saveDSPACURSOR_BASE;
  326. uint32_t saveDSPBCURSOR_BASE;
  327. uint32_t saveDSPACURSOR_POS;
  328. uint32_t saveDSPBCURSOR_POS;
  329. uint32_t saveOV_OVADD;
  330. uint32_t saveOV_OGAMC0;
  331. uint32_t saveOV_OGAMC1;
  332. uint32_t saveOV_OGAMC2;
  333. uint32_t saveOV_OGAMC3;
  334. uint32_t saveOV_OGAMC4;
  335. uint32_t saveOV_OGAMC5;
  336. uint32_t saveOVC_OVADD;
  337. uint32_t saveOVC_OGAMC0;
  338. uint32_t saveOVC_OGAMC1;
  339. uint32_t saveOVC_OGAMC2;
  340. uint32_t saveOVC_OGAMC3;
  341. uint32_t saveOVC_OGAMC4;
  342. uint32_t saveOVC_OGAMC5;
  343. /* DPST register save */
  344. uint32_t saveHISTOGRAM_INT_CONTROL_REG;
  345. uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG;
  346. uint32_t savePWM_CONTROL_LOGIC;
  347. };
  348. struct medfield_state {
  349. uint32_t saveMIPI;
  350. uint32_t saveMIPI_C;
  351. uint32_t savePFIT_CONTROL;
  352. uint32_t savePFIT_PGM_RATIOS;
  353. uint32_t saveHDMIPHYMISCCTL;
  354. uint32_t saveHDMIB_CONTROL;
  355. };
  356. struct cdv_state {
  357. uint32_t saveDSPCLK_GATE_D;
  358. uint32_t saveRAMCLK_GATE_D;
  359. uint32_t saveDSPARB;
  360. uint32_t saveDSPFW[6];
  361. uint32_t saveADPA;
  362. uint32_t savePP_CONTROL;
  363. uint32_t savePFIT_PGM_RATIOS;
  364. uint32_t saveLVDS;
  365. uint32_t savePFIT_CONTROL;
  366. uint32_t savePP_ON_DELAYS;
  367. uint32_t savePP_OFF_DELAYS;
  368. uint32_t savePP_CYCLE;
  369. uint32_t saveVGACNTRL;
  370. uint32_t saveIER;
  371. uint32_t saveIMR;
  372. u8 saveLBB;
  373. };
  374. struct psb_save_area {
  375. struct psb_pipe pipe[3];
  376. uint32_t saveBSM;
  377. uint32_t saveVBT;
  378. union {
  379. struct psb_state psb;
  380. struct medfield_state mdfld;
  381. struct cdv_state cdv;
  382. };
  383. uint32_t saveBLC_PWM_CTL2;
  384. uint32_t saveBLC_PWM_CTL;
  385. };
  386. struct psb_ops;
  387. #define PSB_NUM_PIPE 3
  388. struct drm_psb_private {
  389. struct drm_device *dev;
  390. struct pci_dev *aux_pdev; /* Currently only used by mrst */
  391. struct pci_dev *lpc_pdev; /* Currently only used by mrst */
  392. const struct psb_ops *ops;
  393. const struct psb_offset *regmap;
  394. struct child_device_config *child_dev;
  395. int child_dev_num;
  396. struct psb_gtt gtt;
  397. /* GTT Memory manager */
  398. struct psb_gtt_mm *gtt_mm;
  399. struct page *scratch_page;
  400. u32 __iomem *gtt_map;
  401. uint32_t stolen_base;
  402. u8 __iomem *vram_addr;
  403. unsigned long vram_stolen_size;
  404. int gtt_initialized;
  405. u16 gmch_ctrl; /* Saved GTT setup */
  406. u32 pge_ctl;
  407. struct mutex gtt_mutex;
  408. struct resource *gtt_mem; /* Our PCI resource */
  409. struct psb_mmu_driver *mmu;
  410. struct psb_mmu_pd *pf_pd;
  411. /* Register base */
  412. uint8_t __iomem *sgx_reg;
  413. uint8_t __iomem *vdc_reg;
  414. uint8_t __iomem *aux_reg; /* Auxillary vdc pipe regs */
  415. uint16_t lpc_gpio_base;
  416. uint32_t gatt_free_offset;
  417. /* Fencing / irq */
  418. uint32_t vdc_irq_mask;
  419. uint32_t pipestat[PSB_NUM_PIPE];
  420. spinlock_t irqmask_lock;
  421. /* Power */
  422. bool suspended;
  423. bool display_power;
  424. int display_count;
  425. /* Modesetting */
  426. struct psb_intel_mode_device mode_dev;
  427. bool modeset; /* true if we have done the mode_device setup */
  428. struct drm_crtc *plane_to_crtc_mapping[PSB_NUM_PIPE];
  429. struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE];
  430. uint32_t num_pipe;
  431. /* OSPM info (Power management base) (TODO: can go ?) */
  432. uint32_t ospm_base;
  433. /* Sizes info */
  434. u32 fuse_reg_value;
  435. u32 video_device_fuse;
  436. /* PCI revision ID for B0:D2:F0 */
  437. uint8_t platform_rev_id;
  438. /* gmbus */
  439. struct intel_gmbus *gmbus;
  440. uint8_t __iomem *gmbus_reg;
  441. /* Used by SDVO */
  442. int crt_ddc_pin;
  443. /* FIXME: The mappings should be parsed from bios but for now we can
  444. pretend there are no mappings available */
  445. struct sdvo_device_mapping sdvo_mappings[2];
  446. u32 hotplug_supported_mask;
  447. struct drm_property *broadcast_rgb_property;
  448. struct drm_property *force_audio_property;
  449. /* LVDS info */
  450. int backlight_duty_cycle; /* restore backlight to this value */
  451. bool panel_wants_dither;
  452. struct drm_display_mode *panel_fixed_mode;
  453. struct drm_display_mode *lfp_lvds_vbt_mode;
  454. struct drm_display_mode *sdvo_lvds_vbt_mode;
  455. struct bdb_lvds_backlight *lvds_bl; /* LVDS backlight info from VBT */
  456. struct psb_intel_i2c_chan *lvds_i2c_bus; /* FIXME: Remove this? */
  457. /* Feature bits from the VBIOS */
  458. unsigned int int_tv_support:1;
  459. unsigned int lvds_dither:1;
  460. unsigned int lvds_vbt:1;
  461. unsigned int int_crt_support:1;
  462. unsigned int lvds_use_ssc:1;
  463. int lvds_ssc_freq;
  464. bool is_lvds_on;
  465. bool is_mipi_on;
  466. u32 mipi_ctrl_display;
  467. unsigned int core_freq;
  468. uint32_t iLVDS_enable;
  469. /* Runtime PM state */
  470. int rpm_enabled;
  471. /* MID specific */
  472. bool has_gct;
  473. struct oaktrail_gct_data gct_data;
  474. /* Oaktrail HDMI state */
  475. struct oaktrail_hdmi_dev *hdmi_priv;
  476. /* Register state */
  477. struct psb_save_area regs;
  478. /* MSI reg save */
  479. uint32_t msi_addr;
  480. uint32_t msi_data;
  481. /* Hotplug handling */
  482. struct work_struct hotplug_work;
  483. /* LID-Switch */
  484. spinlock_t lid_lock;
  485. struct timer_list lid_timer;
  486. struct psb_intel_opregion opregion;
  487. u32 lid_last_state;
  488. /* Watchdog */
  489. uint32_t apm_reg;
  490. uint16_t apm_base;
  491. /*
  492. * Used for modifying backlight from
  493. * xrandr -- consider removing and using HAL instead
  494. */
  495. struct backlight_device *backlight_device;
  496. struct drm_property *backlight_property;
  497. bool backlight_enabled;
  498. int backlight_level;
  499. uint32_t blc_adj1;
  500. uint32_t blc_adj2;
  501. void *fbdev;
  502. /* 2D acceleration */
  503. spinlock_t lock_2d;
  504. /* Panel brightness */
  505. int brightness;
  506. int brightness_adjusted;
  507. bool dsr_enable;
  508. u32 dsr_fb_update;
  509. bool dpi_panel_on[3];
  510. void *dsi_configs[2];
  511. u32 bpp;
  512. u32 bpp2;
  513. u32 pipeconf[3];
  514. u32 dspcntr[3];
  515. int mdfld_panel_id;
  516. bool dplla_96mhz; /* DPLL data from the VBT */
  517. struct {
  518. int rate;
  519. int lanes;
  520. int preemphasis;
  521. int vswing;
  522. bool initialized;
  523. bool support;
  524. int bpp;
  525. struct edp_power_seq pps;
  526. } edp;
  527. uint8_t panel_type;
  528. };
  529. /* Operations for each board type */
  530. struct psb_ops {
  531. const char *name;
  532. unsigned int accel_2d:1;
  533. int pipes; /* Number of output pipes */
  534. int crtcs; /* Number of CRTCs */
  535. int sgx_offset; /* Base offset of SGX device */
  536. int hdmi_mask; /* Mask of HDMI CRTCs */
  537. int lvds_mask; /* Mask of LVDS CRTCs */
  538. int sdvo_mask; /* Mask of SDVO CRTCs */
  539. int cursor_needs_phys; /* If cursor base reg need physical address */
  540. /* Sub functions */
  541. struct drm_crtc_helper_funcs const *crtc_helper;
  542. struct drm_crtc_funcs const *crtc_funcs;
  543. const struct gma_clock_funcs *clock_funcs;
  544. /* Setup hooks */
  545. int (*chip_setup)(struct drm_device *dev);
  546. void (*chip_teardown)(struct drm_device *dev);
  547. /* Optional helper caller after modeset */
  548. void (*errata)(struct drm_device *dev);
  549. /* Display management hooks */
  550. int (*output_init)(struct drm_device *dev);
  551. int (*hotplug)(struct drm_device *dev);
  552. void (*hotplug_enable)(struct drm_device *dev, bool on);
  553. /* Power management hooks */
  554. void (*init_pm)(struct drm_device *dev);
  555. int (*save_regs)(struct drm_device *dev);
  556. int (*restore_regs)(struct drm_device *dev);
  557. int (*power_up)(struct drm_device *dev);
  558. int (*power_down)(struct drm_device *dev);
  559. void (*update_wm)(struct drm_device *dev, struct drm_crtc *crtc);
  560. void (*disable_sr)(struct drm_device *dev);
  561. void (*lvds_bl_power)(struct drm_device *dev, bool on);
  562. #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
  563. /* Backlight */
  564. int (*backlight_init)(struct drm_device *dev);
  565. #endif
  566. int i2c_bus; /* I2C bus identifier for Moorestown */
  567. };
  568. extern int drm_crtc_probe_output_modes(struct drm_device *dev, int, int);
  569. extern int drm_pick_crtcs(struct drm_device *dev);
  570. static inline struct drm_psb_private *psb_priv(struct drm_device *dev)
  571. {
  572. return (struct drm_psb_private *) dev->dev_private;
  573. }
  574. /* psb_irq.c */
  575. extern irqreturn_t psb_irq_handler(int irq, void *arg);
  576. extern int psb_irq_enable_dpst(struct drm_device *dev);
  577. extern int psb_irq_disable_dpst(struct drm_device *dev);
  578. extern void psb_irq_preinstall(struct drm_device *dev);
  579. extern int psb_irq_postinstall(struct drm_device *dev);
  580. extern void psb_irq_uninstall(struct drm_device *dev);
  581. extern void psb_irq_turn_on_dpst(struct drm_device *dev);
  582. extern void psb_irq_turn_off_dpst(struct drm_device *dev);
  583. extern void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands);
  584. extern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
  585. extern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence);
  586. extern int psb_enable_vblank(struct drm_device *dev, unsigned int pipe);
  587. extern void psb_disable_vblank(struct drm_device *dev, unsigned int pipe);
  588. void
  589. psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
  590. void
  591. psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
  592. extern u32 psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
  593. /* framebuffer.c */
  594. extern int psbfb_probed(struct drm_device *dev);
  595. extern int psbfb_remove(struct drm_device *dev,
  596. struct drm_framebuffer *fb);
  597. /* accel_2d.c */
  598. extern void psbfb_copyarea(struct fb_info *info,
  599. const struct fb_copyarea *region);
  600. extern int psbfb_sync(struct fb_info *info);
  601. extern void psb_spank(struct drm_psb_private *dev_priv);
  602. /* psb_reset.c */
  603. extern void psb_lid_timer_init(struct drm_psb_private *dev_priv);
  604. extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv);
  605. extern void psb_print_pagefault(struct drm_psb_private *dev_priv);
  606. /* modesetting */
  607. extern void psb_modeset_init(struct drm_device *dev);
  608. extern void psb_modeset_cleanup(struct drm_device *dev);
  609. extern int psb_fbdev_init(struct drm_device *dev);
  610. /* backlight.c */
  611. int gma_backlight_init(struct drm_device *dev);
  612. void gma_backlight_exit(struct drm_device *dev);
  613. void gma_backlight_disable(struct drm_device *dev);
  614. void gma_backlight_enable(struct drm_device *dev);
  615. void gma_backlight_set(struct drm_device *dev, int v);
  616. /* oaktrail_crtc.c */
  617. extern const struct drm_crtc_helper_funcs oaktrail_helper_funcs;
  618. /* oaktrail_lvds.c */
  619. extern void oaktrail_lvds_init(struct drm_device *dev,
  620. struct psb_intel_mode_device *mode_dev);
  621. /* psb_intel_display.c */
  622. extern const struct drm_crtc_helper_funcs psb_intel_helper_funcs;
  623. extern const struct drm_crtc_funcs psb_intel_crtc_funcs;
  624. /* psb_intel_lvds.c */
  625. extern const struct drm_connector_helper_funcs
  626. psb_intel_lvds_connector_helper_funcs;
  627. extern const struct drm_connector_funcs psb_intel_lvds_connector_funcs;
  628. /* gem.c */
  629. extern void psb_gem_free_object(struct drm_gem_object *obj);
  630. extern int psb_gem_get_aperture(struct drm_device *dev, void *data,
  631. struct drm_file *file);
  632. extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
  633. struct drm_mode_create_dumb *args);
  634. extern int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
  635. uint32_t handle, uint64_t *offset);
  636. extern int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
  637. extern int psb_gem_create_ioctl(struct drm_device *dev, void *data,
  638. struct drm_file *file);
  639. extern int psb_gem_mmap_ioctl(struct drm_device *dev, void *data,
  640. struct drm_file *file);
  641. /* psb_device.c */
  642. extern const struct psb_ops psb_chip_ops;
  643. /* oaktrail_device.c */
  644. extern const struct psb_ops oaktrail_chip_ops;
  645. /* mdlfd_device.c */
  646. extern const struct psb_ops mdfld_chip_ops;
  647. /* cdv_device.c */
  648. extern const struct psb_ops cdv_chip_ops;
  649. /* Debug print bits setting */
  650. #define PSB_D_GENERAL (1 << 0)
  651. #define PSB_D_INIT (1 << 1)
  652. #define PSB_D_IRQ (1 << 2)
  653. #define PSB_D_ENTRY (1 << 3)
  654. /* debug the get H/V BP/FP count */
  655. #define PSB_D_HV (1 << 4)
  656. #define PSB_D_DBI_BF (1 << 5)
  657. #define PSB_D_PM (1 << 6)
  658. #define PSB_D_RENDER (1 << 7)
  659. #define PSB_D_REG (1 << 8)
  660. #define PSB_D_MSVDX (1 << 9)
  661. #define PSB_D_TOPAZ (1 << 10)
  662. extern int drm_idle_check_interval;
  663. /* Utilities */
  664. static inline u32 MRST_MSG_READ32(uint port, uint offset)
  665. {
  666. int mcr = (0xD0<<24) | (port << 16) | (offset << 8);
  667. uint32_t ret_val = 0;
  668. struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
  669. pci_write_config_dword(pci_root, 0xD0, mcr);
  670. pci_read_config_dword(pci_root, 0xD4, &ret_val);
  671. pci_dev_put(pci_root);
  672. return ret_val;
  673. }
  674. static inline void MRST_MSG_WRITE32(uint port, uint offset, u32 value)
  675. {
  676. int mcr = (0xE0<<24) | (port << 16) | (offset << 8) | 0xF0;
  677. struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
  678. pci_write_config_dword(pci_root, 0xD4, value);
  679. pci_write_config_dword(pci_root, 0xD0, mcr);
  680. pci_dev_put(pci_root);
  681. }
  682. static inline u32 MDFLD_MSG_READ32(uint port, uint offset)
  683. {
  684. int mcr = (0x10<<24) | (port << 16) | (offset << 8);
  685. uint32_t ret_val = 0;
  686. struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
  687. pci_write_config_dword(pci_root, 0xD0, mcr);
  688. pci_read_config_dword(pci_root, 0xD4, &ret_val);
  689. pci_dev_put(pci_root);
  690. return ret_val;
  691. }
  692. static inline void MDFLD_MSG_WRITE32(uint port, uint offset, u32 value)
  693. {
  694. int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
  695. struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
  696. pci_write_config_dword(pci_root, 0xD4, value);
  697. pci_write_config_dword(pci_root, 0xD0, mcr);
  698. pci_dev_put(pci_root);
  699. }
  700. static inline uint32_t REGISTER_READ(struct drm_device *dev, uint32_t reg)
  701. {
  702. struct drm_psb_private *dev_priv = dev->dev_private;
  703. return ioread32(dev_priv->vdc_reg + reg);
  704. }
  705. static inline uint32_t REGISTER_READ_AUX(struct drm_device *dev, uint32_t reg)
  706. {
  707. struct drm_psb_private *dev_priv = dev->dev_private;
  708. return ioread32(dev_priv->aux_reg + reg);
  709. }
  710. #define REG_READ(reg) REGISTER_READ(dev, (reg))
  711. #define REG_READ_AUX(reg) REGISTER_READ_AUX(dev, (reg))
  712. /* Useful for post reads */
  713. static inline uint32_t REGISTER_READ_WITH_AUX(struct drm_device *dev,
  714. uint32_t reg, int aux)
  715. {
  716. uint32_t val;
  717. if (aux)
  718. val = REG_READ_AUX(reg);
  719. else
  720. val = REG_READ(reg);
  721. return val;
  722. }
  723. #define REG_READ_WITH_AUX(reg, aux) REGISTER_READ_WITH_AUX(dev, (reg), (aux))
  724. static inline void REGISTER_WRITE(struct drm_device *dev, uint32_t reg,
  725. uint32_t val)
  726. {
  727. struct drm_psb_private *dev_priv = dev->dev_private;
  728. iowrite32((val), dev_priv->vdc_reg + (reg));
  729. }
  730. static inline void REGISTER_WRITE_AUX(struct drm_device *dev, uint32_t reg,
  731. uint32_t val)
  732. {
  733. struct drm_psb_private *dev_priv = dev->dev_private;
  734. iowrite32((val), dev_priv->aux_reg + (reg));
  735. }
  736. #define REG_WRITE(reg, val) REGISTER_WRITE(dev, (reg), (val))
  737. #define REG_WRITE_AUX(reg, val) REGISTER_WRITE_AUX(dev, (reg), (val))
  738. static inline void REGISTER_WRITE_WITH_AUX(struct drm_device *dev, uint32_t reg,
  739. uint32_t val, int aux)
  740. {
  741. if (aux)
  742. REG_WRITE_AUX(reg, val);
  743. else
  744. REG_WRITE(reg, val);
  745. }
  746. #define REG_WRITE_WITH_AUX(reg, val, aux) REGISTER_WRITE_WITH_AUX(dev, (reg), (val), (aux))
  747. static inline void REGISTER_WRITE16(struct drm_device *dev,
  748. uint32_t reg, uint32_t val)
  749. {
  750. struct drm_psb_private *dev_priv = dev->dev_private;
  751. iowrite16((val), dev_priv->vdc_reg + (reg));
  752. }
  753. #define REG_WRITE16(reg, val) REGISTER_WRITE16(dev, (reg), (val))
  754. static inline void REGISTER_WRITE8(struct drm_device *dev,
  755. uint32_t reg, uint32_t val)
  756. {
  757. struct drm_psb_private *dev_priv = dev->dev_private;
  758. iowrite8((val), dev_priv->vdc_reg + (reg));
  759. }
  760. #define REG_WRITE8(reg, val) REGISTER_WRITE8(dev, (reg), (val))
  761. #define PSB_WVDC32(_val, _offs) iowrite32(_val, dev_priv->vdc_reg + (_offs))
  762. #define PSB_RVDC32(_offs) ioread32(dev_priv->vdc_reg + (_offs))
  763. /* #define TRAP_SGX_PM_FAULT 1 */
  764. #ifdef TRAP_SGX_PM_FAULT
  765. #define PSB_RSGX32(_offs) \
  766. ({ \
  767. if (inl(dev_priv->apm_base + PSB_APM_STS) & 0x3) { \
  768. printk(KERN_ERR \
  769. "access sgx when it's off!! (READ) %s, %d\n", \
  770. __FILE__, __LINE__); \
  771. melay(1000); \
  772. } \
  773. ioread32(dev_priv->sgx_reg + (_offs)); \
  774. })
  775. #else
  776. #define PSB_RSGX32(_offs) ioread32(dev_priv->sgx_reg + (_offs))
  777. #endif
  778. #define PSB_WSGX32(_val, _offs) iowrite32(_val, dev_priv->sgx_reg + (_offs))
  779. #define MSVDX_REG_DUMP 0
  780. #define PSB_WMSVDX32(_val, _offs) iowrite32(_val, dev_priv->msvdx_reg + (_offs))
  781. #define PSB_RMSVDX32(_offs) ioread32(dev_priv->msvdx_reg + (_offs))
  782. #endif