psb_drv.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /**************************************************************************
  3. * Copyright (c) 2007-2011, Intel Corporation.
  4. * All Rights Reserved.
  5. *
  6. **************************************************************************/
  7. #ifndef _PSB_DRV_H_
  8. #define _PSB_DRV_H_
  9. #include <linux/kref.h>
  10. #include <linux/mm_types.h>
  11. #include <drm/drm_device.h>
  12. #include "gtt.h"
  13. #include "intel_bios.h"
  14. #include "mmu.h"
  15. #include "oaktrail.h"
  16. #include "opregion.h"
  17. #include "power.h"
  18. #include "psb_intel_drv.h"
  19. #include "psb_reg.h"
  20. #define DRIVER_AUTHOR "Alan Cox <alan@linux.intel.com> and others"
  21. #define DRIVER_NAME "gma500"
  22. #define DRIVER_DESC "DRM driver for the Intel GMA500, GMA600, GMA3600, GMA3650"
  23. #define DRIVER_DATE "20140314"
  24. #define DRIVER_MAJOR 1
  25. #define DRIVER_MINOR 0
  26. #define DRIVER_PATCHLEVEL 0
  27. /* Append new drm mode definition here, align with libdrm definition */
  28. #define DRM_MODE_SCALE_NO_SCALE 2
  29. #define IS_PSB(drm) ((to_pci_dev((drm)->dev)->device & 0xfffe) == 0x8108)
  30. #define IS_MRST(drm) ((to_pci_dev((drm)->dev)->device & 0xfff0) == 0x4100)
  31. #define IS_CDV(drm) ((to_pci_dev((drm)->dev)->device & 0xfff0) == 0x0be0)
  32. /* Hardware offsets */
  33. #define PSB_VDC_OFFSET 0x00000000
  34. #define PSB_VDC_SIZE 0x000080000
  35. #define MRST_MMIO_SIZE 0x0000C0000
  36. #define PSB_SGX_SIZE 0x8000
  37. #define PSB_SGX_OFFSET 0x00040000
  38. #define MRST_SGX_OFFSET 0x00080000
  39. /* PCI resource identifiers */
  40. #define PSB_MMIO_RESOURCE 0
  41. #define PSB_AUX_RESOURCE 0
  42. #define PSB_GATT_RESOURCE 2
  43. #define PSB_GTT_RESOURCE 3
  44. /* PCI configuration */
  45. #define PSB_GMCH_CTRL 0x52
  46. #define PSB_BSM 0x5C
  47. #define _PSB_GMCH_ENABLED 0x4
  48. #define PSB_PGETBL_CTL 0x2020
  49. #define _PSB_PGETBL_ENABLED 0x00000001
  50. #define PSB_SGX_2D_SLAVE_PORT 0x4000
  51. #define PSB_LPC_GBA 0x44
  52. /* TODO: To get rid of */
  53. #define PSB_TT_PRIV0_LIMIT (256*1024*1024)
  54. #define PSB_TT_PRIV0_PLIMIT (PSB_TT_PRIV0_LIMIT >> PAGE_SHIFT)
  55. /* SGX side MMU definitions (these can probably go) */
  56. /* Flags for external memory type field */
  57. #define PSB_MMU_CACHED_MEMORY 0x0001 /* Bind to MMU only */
  58. #define PSB_MMU_RO_MEMORY 0x0002 /* MMU RO memory */
  59. #define PSB_MMU_WO_MEMORY 0x0004 /* MMU WO memory */
  60. /* PTE's and PDE's */
  61. #define PSB_PDE_MASK 0x003FFFFF
  62. #define PSB_PDE_SHIFT 22
  63. #define PSB_PTE_SHIFT 12
  64. /* Cache control */
  65. #define PSB_PTE_VALID 0x0001 /* PTE / PDE valid */
  66. #define PSB_PTE_WO 0x0002 /* Write only */
  67. #define PSB_PTE_RO 0x0004 /* Read only */
  68. #define PSB_PTE_CACHED 0x0008 /* CPU cache coherent */
  69. /* VDC registers and bits */
  70. #define PSB_MSVDX_CLOCKGATING 0x2064
  71. #define PSB_TOPAZ_CLOCKGATING 0x2068
  72. #define PSB_HWSTAM 0x2098
  73. #define PSB_INSTPM 0x20C0
  74. #define PSB_INT_IDENTITY_R 0x20A4
  75. #define _PSB_IRQ_ASLE (1<<0)
  76. #define _MDFLD_PIPEC_EVENT_FLAG (1<<2)
  77. #define _MDFLD_PIPEC_VBLANK_FLAG (1<<3)
  78. #define _PSB_DPST_PIPEB_FLAG (1<<4)
  79. #define _MDFLD_PIPEB_EVENT_FLAG (1<<4)
  80. #define _PSB_VSYNC_PIPEB_FLAG (1<<5)
  81. #define _PSB_DPST_PIPEA_FLAG (1<<6)
  82. #define _PSB_PIPEA_EVENT_FLAG (1<<6)
  83. #define _PSB_VSYNC_PIPEA_FLAG (1<<7)
  84. #define _PSB_IRQ_DISP_HOTSYNC (1<<17)
  85. #define _PSB_IRQ_SGX_FLAG (1<<18)
  86. #define _PSB_IRQ_MSVDX_FLAG (1<<19)
  87. #define _LNC_IRQ_TOPAZ_FLAG (1<<20)
  88. #define _PSB_PIPE_EVENT_FLAG (_PSB_VSYNC_PIPEA_FLAG | \
  89. _PSB_VSYNC_PIPEB_FLAG)
  90. #define PSB_INT_IDENTITY_R 0x20A4
  91. #define PSB_INT_MASK_R 0x20A8
  92. #define PSB_INT_ENABLE_R 0x20A0
  93. #define _PSB_MMU_ER_MASK 0x0001FF00
  94. #define _PSB_MMU_ER_HOST (1 << 16)
  95. #define GPIOA 0x5010
  96. #define GPIOB 0x5014
  97. #define GPIOC 0x5018
  98. #define GPIOD 0x501c
  99. #define GPIOE 0x5020
  100. #define GPIOF 0x5024
  101. #define GPIOG 0x5028
  102. #define GPIOH 0x502c
  103. #define GPIO_CLOCK_DIR_MASK (1 << 0)
  104. #define GPIO_CLOCK_DIR_IN (0 << 1)
  105. #define GPIO_CLOCK_DIR_OUT (1 << 1)
  106. #define GPIO_CLOCK_VAL_MASK (1 << 2)
  107. #define GPIO_CLOCK_VAL_OUT (1 << 3)
  108. #define GPIO_CLOCK_VAL_IN (1 << 4)
  109. #define GPIO_CLOCK_PULLUP_DISABLE (1 << 5)
  110. #define GPIO_DATA_DIR_MASK (1 << 8)
  111. #define GPIO_DATA_DIR_IN (0 << 9)
  112. #define GPIO_DATA_DIR_OUT (1 << 9)
  113. #define GPIO_DATA_VAL_MASK (1 << 10)
  114. #define GPIO_DATA_VAL_OUT (1 << 11)
  115. #define GPIO_DATA_VAL_IN (1 << 12)
  116. #define GPIO_DATA_PULLUP_DISABLE (1 << 13)
  117. #define VCLK_DIVISOR_VGA0 0x6000
  118. #define VCLK_DIVISOR_VGA1 0x6004
  119. #define VCLK_POST_DIV 0x6010
  120. #define PSB_COMM_2D (PSB_ENGINE_2D << 4)
  121. #define PSB_COMM_3D (PSB_ENGINE_3D << 4)
  122. #define PSB_COMM_TA (PSB_ENGINE_TA << 4)
  123. #define PSB_COMM_HP (PSB_ENGINE_HP << 4)
  124. #define PSB_COMM_USER_IRQ (1024 >> 2)
  125. #define PSB_COMM_USER_IRQ_LOST (PSB_COMM_USER_IRQ + 1)
  126. #define PSB_COMM_FW (2048 >> 2)
  127. #define PSB_UIRQ_VISTEST 1
  128. #define PSB_UIRQ_OOM_REPLY 2
  129. #define PSB_UIRQ_FIRE_TA_REPLY 3
  130. #define PSB_UIRQ_FIRE_RASTER_REPLY 4
  131. #define PSB_2D_SIZE (256*1024*1024)
  132. #define PSB_MAX_RELOC_PAGES 1024
  133. #define PSB_LOW_REG_OFFS 0x0204
  134. #define PSB_HIGH_REG_OFFS 0x0600
  135. #define PSB_NUM_VBLANKS 2
  136. #define PSB_WATCHDOG_DELAY (HZ * 2)
  137. #define PSB_MAX_BRIGHTNESS 100
  138. #define PSB_PWR_STATE_ON 1
  139. #define PSB_PWR_STATE_OFF 2
  140. #define PSB_PMPOLICY_NOPM 0
  141. #define PSB_PMPOLICY_CLOCKGATING 1
  142. #define PSB_PMPOLICY_POWERDOWN 2
  143. #define PSB_PMSTATE_POWERUP 0
  144. #define PSB_PMSTATE_CLOCKGATED 1
  145. #define PSB_PMSTATE_POWERDOWN 2
  146. #define PSB_PCIx_MSI_ADDR_LOC 0x94
  147. #define PSB_PCIx_MSI_DATA_LOC 0x98
  148. /* Medfield crystal settings */
  149. #define KSEL_CRYSTAL_19 1
  150. #define KSEL_BYPASS_19 5
  151. #define KSEL_BYPASS_25 6
  152. #define KSEL_BYPASS_83_100 7
  153. struct opregion_header;
  154. struct opregion_acpi;
  155. struct opregion_swsci;
  156. struct opregion_asle;
  157. struct psb_intel_opregion {
  158. struct opregion_header *header;
  159. struct opregion_acpi *acpi;
  160. struct opregion_swsci *swsci;
  161. struct opregion_asle *asle;
  162. void *vbt;
  163. u32 __iomem *lid_state;
  164. struct work_struct asle_work;
  165. };
  166. struct sdvo_device_mapping {
  167. u8 initialized;
  168. u8 dvo_port;
  169. u8 target_addr;
  170. u8 dvo_wiring;
  171. u8 i2c_pin;
  172. u8 i2c_speed;
  173. u8 ddc_pin;
  174. };
  175. struct intel_gmbus {
  176. struct i2c_adapter adapter;
  177. struct i2c_adapter *force_bit;
  178. u32 reg0;
  179. };
  180. /* Register offset maps */
  181. struct psb_offset {
  182. u32 fp0;
  183. u32 fp1;
  184. u32 cntr;
  185. u32 conf;
  186. u32 src;
  187. u32 dpll;
  188. u32 dpll_md;
  189. u32 htotal;
  190. u32 hblank;
  191. u32 hsync;
  192. u32 vtotal;
  193. u32 vblank;
  194. u32 vsync;
  195. u32 stride;
  196. u32 size;
  197. u32 pos;
  198. u32 surf;
  199. u32 addr;
  200. u32 base;
  201. u32 status;
  202. u32 linoff;
  203. u32 tileoff;
  204. u32 palette;
  205. };
  206. /*
  207. * Register save state. This is used to hold the context when the
  208. * device is powered off. In the case of Oaktrail this can (but does not
  209. * yet) include screen blank. Operations occuring during the save
  210. * update the register cache instead.
  211. */
  212. /* Common status for pipes */
  213. struct psb_pipe {
  214. u32 fp0;
  215. u32 fp1;
  216. u32 cntr;
  217. u32 conf;
  218. u32 src;
  219. u32 dpll;
  220. u32 dpll_md;
  221. u32 htotal;
  222. u32 hblank;
  223. u32 hsync;
  224. u32 vtotal;
  225. u32 vblank;
  226. u32 vsync;
  227. u32 stride;
  228. u32 size;
  229. u32 pos;
  230. u32 base;
  231. u32 surf;
  232. u32 addr;
  233. u32 status;
  234. u32 linoff;
  235. u32 tileoff;
  236. u32 palette[256];
  237. };
  238. struct psb_state {
  239. uint32_t saveVCLK_DIVISOR_VGA0;
  240. uint32_t saveVCLK_DIVISOR_VGA1;
  241. uint32_t saveVCLK_POST_DIV;
  242. uint32_t saveVGACNTRL;
  243. uint32_t saveADPA;
  244. uint32_t saveLVDS;
  245. uint32_t saveDVOA;
  246. uint32_t saveDVOB;
  247. uint32_t saveDVOC;
  248. uint32_t savePP_ON;
  249. uint32_t savePP_OFF;
  250. uint32_t savePP_CONTROL;
  251. uint32_t savePP_CYCLE;
  252. uint32_t savePFIT_CONTROL;
  253. uint32_t saveCLOCKGATING;
  254. uint32_t saveDSPARB;
  255. uint32_t savePFIT_AUTO_RATIOS;
  256. uint32_t savePFIT_PGM_RATIOS;
  257. uint32_t savePP_ON_DELAYS;
  258. uint32_t savePP_OFF_DELAYS;
  259. uint32_t savePP_DIVISOR;
  260. uint32_t saveBCLRPAT_A;
  261. uint32_t saveBCLRPAT_B;
  262. uint32_t savePERF_MODE;
  263. uint32_t saveDSPFW1;
  264. uint32_t saveDSPFW2;
  265. uint32_t saveDSPFW3;
  266. uint32_t saveDSPFW4;
  267. uint32_t saveDSPFW5;
  268. uint32_t saveDSPFW6;
  269. uint32_t saveCHICKENBIT;
  270. uint32_t saveDSPACURSOR_CTRL;
  271. uint32_t saveDSPBCURSOR_CTRL;
  272. uint32_t saveDSPACURSOR_BASE;
  273. uint32_t saveDSPBCURSOR_BASE;
  274. uint32_t saveDSPACURSOR_POS;
  275. uint32_t saveDSPBCURSOR_POS;
  276. uint32_t saveOV_OVADD;
  277. uint32_t saveOV_OGAMC0;
  278. uint32_t saveOV_OGAMC1;
  279. uint32_t saveOV_OGAMC2;
  280. uint32_t saveOV_OGAMC3;
  281. uint32_t saveOV_OGAMC4;
  282. uint32_t saveOV_OGAMC5;
  283. uint32_t saveOVC_OVADD;
  284. uint32_t saveOVC_OGAMC0;
  285. uint32_t saveOVC_OGAMC1;
  286. uint32_t saveOVC_OGAMC2;
  287. uint32_t saveOVC_OGAMC3;
  288. uint32_t saveOVC_OGAMC4;
  289. uint32_t saveOVC_OGAMC5;
  290. /* DPST register save */
  291. uint32_t saveHISTOGRAM_INT_CONTROL_REG;
  292. uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG;
  293. uint32_t savePWM_CONTROL_LOGIC;
  294. };
  295. struct cdv_state {
  296. uint32_t saveDSPCLK_GATE_D;
  297. uint32_t saveRAMCLK_GATE_D;
  298. uint32_t saveDSPARB;
  299. uint32_t saveDSPFW[6];
  300. uint32_t saveADPA;
  301. uint32_t savePP_CONTROL;
  302. uint32_t savePFIT_PGM_RATIOS;
  303. uint32_t saveLVDS;
  304. uint32_t savePFIT_CONTROL;
  305. uint32_t savePP_ON_DELAYS;
  306. uint32_t savePP_OFF_DELAYS;
  307. uint32_t savePP_CYCLE;
  308. uint32_t saveVGACNTRL;
  309. uint32_t saveIER;
  310. uint32_t saveIMR;
  311. u8 saveLBB;
  312. };
  313. struct psb_save_area {
  314. struct psb_pipe pipe[3];
  315. uint32_t saveBSM;
  316. uint32_t saveVBT;
  317. union {
  318. struct psb_state psb;
  319. struct cdv_state cdv;
  320. };
  321. uint32_t saveBLC_PWM_CTL2;
  322. uint32_t saveBLC_PWM_CTL;
  323. };
  324. struct psb_ops;
  325. #define PSB_NUM_PIPE 3
  326. struct intel_scu_ipc_dev;
  327. struct drm_psb_private {
  328. struct drm_device dev;
  329. struct pci_dev *aux_pdev; /* Currently only used by mrst */
  330. struct pci_dev *lpc_pdev; /* Currently only used by mrst */
  331. const struct psb_ops *ops;
  332. const struct psb_offset *regmap;
  333. struct child_device_config *child_dev;
  334. int child_dev_num;
  335. struct psb_gtt gtt;
  336. /* GTT Memory manager */
  337. struct psb_gtt_mm *gtt_mm;
  338. struct page *scratch_page;
  339. u32 __iomem *gtt_map;
  340. uint32_t stolen_base;
  341. u8 __iomem *vram_addr;
  342. unsigned long vram_stolen_size;
  343. u16 gmch_ctrl; /* Saved GTT setup */
  344. u32 pge_ctl;
  345. struct mutex gtt_mutex;
  346. struct resource *gtt_mem; /* Our PCI resource */
  347. struct mutex mmap_mutex;
  348. struct psb_mmu_driver *mmu;
  349. struct psb_mmu_pd *pf_pd;
  350. /* Register base */
  351. uint8_t __iomem *sgx_reg;
  352. uint8_t __iomem *vdc_reg;
  353. uint8_t __iomem *aux_reg; /* Auxillary vdc pipe regs */
  354. uint16_t lpc_gpio_base;
  355. uint32_t gatt_free_offset;
  356. /* Fencing / irq */
  357. uint32_t vdc_irq_mask;
  358. uint32_t pipestat[PSB_NUM_PIPE];
  359. spinlock_t irqmask_lock;
  360. bool irq_enabled;
  361. /* Power */
  362. bool pm_initialized;
  363. /* Modesetting */
  364. struct psb_intel_mode_device mode_dev;
  365. bool modeset; /* true if we have done the mode_device setup */
  366. struct drm_crtc *plane_to_crtc_mapping[PSB_NUM_PIPE];
  367. struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE];
  368. uint32_t num_pipe;
  369. /* OSPM info (Power management base) (TODO: can go ?) */
  370. uint32_t ospm_base;
  371. /* Sizes info */
  372. u32 fuse_reg_value;
  373. u32 video_device_fuse;
  374. /* PCI revision ID for B0:D2:F0 */
  375. uint8_t platform_rev_id;
  376. /* gmbus */
  377. struct intel_gmbus *gmbus;
  378. uint8_t __iomem *gmbus_reg;
  379. /* Used by SDVO */
  380. int crt_ddc_pin;
  381. /* FIXME: The mappings should be parsed from bios but for now we can
  382. pretend there are no mappings available */
  383. struct sdvo_device_mapping sdvo_mappings[2];
  384. u32 hotplug_supported_mask;
  385. struct drm_property *broadcast_rgb_property;
  386. struct drm_property *force_audio_property;
  387. /* LVDS info */
  388. int backlight_duty_cycle; /* restore backlight to this value */
  389. bool panel_wants_dither;
  390. struct drm_display_mode *panel_fixed_mode;
  391. struct drm_display_mode *lfp_lvds_vbt_mode;
  392. struct drm_display_mode *sdvo_lvds_vbt_mode;
  393. struct bdb_lvds_backlight *lvds_bl; /* LVDS backlight info from VBT */
  394. struct gma_i2c_chan *lvds_i2c_bus; /* FIXME: Remove this? */
  395. /* Feature bits from the VBIOS */
  396. unsigned int int_tv_support:1;
  397. unsigned int lvds_dither:1;
  398. unsigned int lvds_vbt:1;
  399. unsigned int int_crt_support:1;
  400. unsigned int lvds_use_ssc:1;
  401. int lvds_ssc_freq;
  402. bool is_lvds_on;
  403. bool is_mipi_on;
  404. bool lvds_enabled_in_vbt;
  405. u32 mipi_ctrl_display;
  406. unsigned int core_freq;
  407. uint32_t iLVDS_enable;
  408. /* MID specific */
  409. bool use_msi;
  410. bool has_gct;
  411. struct oaktrail_gct_data gct_data;
  412. /* Oaktrail HDMI state */
  413. struct oaktrail_hdmi_dev *hdmi_priv;
  414. /* Register state */
  415. struct psb_save_area regs;
  416. /* Hotplug handling */
  417. struct work_struct hotplug_work;
  418. struct psb_intel_opregion opregion;
  419. /* Watchdog */
  420. uint32_t apm_reg;
  421. uint16_t apm_base;
  422. /*
  423. * Used for modifying backlight from
  424. * xrandr -- consider removing and using HAL instead
  425. */
  426. struct intel_scu_ipc_dev *scu;
  427. struct backlight_device *backlight_device;
  428. struct drm_property *backlight_property;
  429. bool backlight_enabled;
  430. int backlight_level;
  431. uint32_t blc_adj1;
  432. uint32_t blc_adj2;
  433. bool dsr_enable;
  434. u32 dsr_fb_update;
  435. bool dpi_panel_on[3];
  436. void *dsi_configs[2];
  437. u32 bpp;
  438. u32 bpp2;
  439. u32 pipeconf[3];
  440. u32 dspcntr[3];
  441. bool dplla_96mhz; /* DPLL data from the VBT */
  442. struct {
  443. int rate;
  444. int lanes;
  445. int preemphasis;
  446. int vswing;
  447. bool initialized;
  448. bool support;
  449. int bpp;
  450. struct edp_power_seq pps;
  451. } edp;
  452. uint8_t panel_type;
  453. };
  454. static inline struct drm_psb_private *to_drm_psb_private(struct drm_device *dev)
  455. {
  456. return container_of(dev, struct drm_psb_private, dev);
  457. }
  458. /* Operations for each board type */
  459. struct psb_ops {
  460. const char *name;
  461. int pipes; /* Number of output pipes */
  462. int crtcs; /* Number of CRTCs */
  463. int sgx_offset; /* Base offset of SGX device */
  464. int hdmi_mask; /* Mask of HDMI CRTCs */
  465. int lvds_mask; /* Mask of LVDS CRTCs */
  466. int sdvo_mask; /* Mask of SDVO CRTCs */
  467. int cursor_needs_phys; /* If cursor base reg need physical address */
  468. /* Sub functions */
  469. struct drm_crtc_helper_funcs const *crtc_helper;
  470. const struct gma_clock_funcs *clock_funcs;
  471. /* Setup hooks */
  472. int (*chip_setup)(struct drm_device *dev);
  473. void (*chip_teardown)(struct drm_device *dev);
  474. /* Optional helper caller after modeset */
  475. void (*errata)(struct drm_device *dev);
  476. /* Display management hooks */
  477. int (*output_init)(struct drm_device *dev);
  478. int (*hotplug)(struct drm_device *dev);
  479. void (*hotplug_enable)(struct drm_device *dev, bool on);
  480. /* Power management hooks */
  481. void (*init_pm)(struct drm_device *dev);
  482. int (*save_regs)(struct drm_device *dev);
  483. int (*restore_regs)(struct drm_device *dev);
  484. void (*save_crtc)(struct drm_crtc *crtc);
  485. void (*restore_crtc)(struct drm_crtc *crtc);
  486. int (*power_up)(struct drm_device *dev);
  487. int (*power_down)(struct drm_device *dev);
  488. void (*update_wm)(struct drm_device *dev, struct drm_crtc *crtc);
  489. void (*disable_sr)(struct drm_device *dev);
  490. void (*lvds_bl_power)(struct drm_device *dev, bool on);
  491. /* Backlight */
  492. int (*backlight_init)(struct drm_device *dev);
  493. void (*backlight_set)(struct drm_device *dev, int level);
  494. int (*backlight_get)(struct drm_device *dev);
  495. const char *backlight_name;
  496. int i2c_bus; /* I2C bus identifier for Moorestown */
  497. };
  498. /* modesetting */
  499. extern void psb_modeset_init(struct drm_device *dev);
  500. extern void psb_modeset_cleanup(struct drm_device *dev);
  501. /* framebuffer */
  502. struct drm_framebuffer *psb_framebuffer_create(struct drm_device *dev,
  503. const struct drm_mode_fb_cmd2 *mode_cmd,
  504. struct drm_gem_object *obj);
  505. /* fbdev */
  506. #if defined(CONFIG_DRM_FBDEV_EMULATION)
  507. void psb_fbdev_setup(struct drm_psb_private *dev_priv);
  508. #else
  509. static inline void psb_fbdev_setup(struct drm_psb_private *dev_priv)
  510. { }
  511. #endif
  512. /* backlight.c */
  513. int gma_backlight_init(struct drm_device *dev);
  514. void gma_backlight_exit(struct drm_device *dev);
  515. void gma_backlight_disable(struct drm_device *dev);
  516. void gma_backlight_enable(struct drm_device *dev);
  517. void gma_backlight_set(struct drm_device *dev, int v);
  518. /* oaktrail_crtc.c */
  519. extern const struct drm_crtc_helper_funcs oaktrail_helper_funcs;
  520. /* oaktrail_lvds.c */
  521. extern void oaktrail_lvds_init(struct drm_device *dev,
  522. struct psb_intel_mode_device *mode_dev);
  523. /* psb_intel_display.c */
  524. extern const struct drm_crtc_helper_funcs psb_intel_helper_funcs;
  525. /* psb_intel_lvds.c */
  526. extern const struct drm_connector_helper_funcs
  527. psb_intel_lvds_connector_helper_funcs;
  528. extern const struct drm_connector_funcs psb_intel_lvds_connector_funcs;
  529. /* gem.c */
  530. extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
  531. struct drm_mode_create_dumb *args);
  532. /* psb_device.c */
  533. extern const struct psb_ops psb_chip_ops;
  534. /* oaktrail_device.c */
  535. extern const struct psb_ops oaktrail_chip_ops;
  536. /* cdv_device.c */
  537. extern const struct psb_ops cdv_chip_ops;
  538. /* Utilities */
  539. static inline uint32_t REGISTER_READ(struct drm_device *dev, uint32_t reg)
  540. {
  541. struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
  542. return ioread32(dev_priv->vdc_reg + reg);
  543. }
  544. static inline uint32_t REGISTER_READ_AUX(struct drm_device *dev, uint32_t reg)
  545. {
  546. struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
  547. return ioread32(dev_priv->aux_reg + reg);
  548. }
  549. #define REG_READ(reg) REGISTER_READ(dev, (reg))
  550. #define REG_READ_AUX(reg) REGISTER_READ_AUX(dev, (reg))
  551. /* Useful for post reads */
  552. static inline uint32_t REGISTER_READ_WITH_AUX(struct drm_device *dev,
  553. uint32_t reg, int aux)
  554. {
  555. uint32_t val;
  556. if (aux)
  557. val = REG_READ_AUX(reg);
  558. else
  559. val = REG_READ(reg);
  560. return val;
  561. }
  562. #define REG_READ_WITH_AUX(reg, aux) REGISTER_READ_WITH_AUX(dev, (reg), (aux))
  563. static inline void REGISTER_WRITE(struct drm_device *dev, uint32_t reg,
  564. uint32_t val)
  565. {
  566. struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
  567. iowrite32((val), dev_priv->vdc_reg + (reg));
  568. }
  569. static inline void REGISTER_WRITE_AUX(struct drm_device *dev, uint32_t reg,
  570. uint32_t val)
  571. {
  572. struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
  573. iowrite32((val), dev_priv->aux_reg + (reg));
  574. }
  575. #define REG_WRITE(reg, val) REGISTER_WRITE(dev, (reg), (val))
  576. #define REG_WRITE_AUX(reg, val) REGISTER_WRITE_AUX(dev, (reg), (val))
  577. static inline void REGISTER_WRITE_WITH_AUX(struct drm_device *dev, uint32_t reg,
  578. uint32_t val, int aux)
  579. {
  580. if (aux)
  581. REG_WRITE_AUX(reg, val);
  582. else
  583. REG_WRITE(reg, val);
  584. }
  585. #define REG_WRITE_WITH_AUX(reg, val, aux) REGISTER_WRITE_WITH_AUX(dev, (reg), (val), (aux))
  586. static inline void REGISTER_WRITE16(struct drm_device *dev,
  587. uint32_t reg, uint32_t val)
  588. {
  589. struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
  590. iowrite16((val), dev_priv->vdc_reg + (reg));
  591. }
  592. #define REG_WRITE16(reg, val) REGISTER_WRITE16(dev, (reg), (val))
  593. static inline void REGISTER_WRITE8(struct drm_device *dev,
  594. uint32_t reg, uint32_t val)
  595. {
  596. struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
  597. iowrite8((val), dev_priv->vdc_reg + (reg));
  598. }
  599. #define REG_WRITE8(reg, val) REGISTER_WRITE8(dev, (reg), (val))
  600. #define PSB_WVDC32(_val, _offs) iowrite32(_val, dev_priv->vdc_reg + (_offs))
  601. #define PSB_RVDC32(_offs) ioread32(dev_priv->vdc_reg + (_offs))
  602. #define PSB_RSGX32(_offs) ioread32(dev_priv->sgx_reg + (_offs))
  603. #define PSB_WSGX32(_val, _offs) iowrite32(_val, dev_priv->sgx_reg + (_offs))
  604. #define PSB_WMSVDX32(_val, _offs) iowrite32(_val, dev_priv->msvdx_reg + (_offs))
  605. #define PSB_RMSVDX32(_offs) ioread32(dev_priv->msvdx_reg + (_offs))
  606. #endif