psb_drv.h 25 KB

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