aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/dispnv04
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2014-08-09 14:10:22 -0400
committerBen Skeggs <bskeggs@redhat.com>2014-08-09 15:13:13 -0400
commit967e7bde8739fe3b215f7537e8f1f39c044902af (patch)
tree5d96683b3b139da0b681ae038a8cd5f25ca32ef8 /drivers/gpu/drm/nouveau/dispnv04
parentdb2bec187dd68e79d512112df1f6e7a849e7f0ce (diff)
drm/nouveau: initial pass at moving to struct nvif_device
This is an attempt at isolating some of the changes necessary to port to NVIF in a separate commit. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/dispnv04')
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/arb.c6
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/crtc.c38
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/cursor.c2
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/dac.c14
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/dfp.c12
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/disp.c2
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/disp.h6
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/hw.c76
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/hw.h42
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/overlay.c20
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/tvnv04.c4
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/tvnv17.c22
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/tvnv17.h4
13 files changed, 124 insertions, 124 deletions
diff --git a/drivers/gpu/drm/nouveau/dispnv04/arb.c b/drivers/gpu/drm/nouveau/dispnv04/arb.c
index c64db854cc26..c6361422a0b2 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/arb.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/arb.c
@@ -198,7 +198,7 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
198 int *burst, int *lwm) 198 int *burst, int *lwm)
199{ 199{
200 struct nouveau_drm *drm = nouveau_drm(dev); 200 struct nouveau_drm *drm = nouveau_drm(dev);
201 struct nouveau_object *device = nouveau_drm(dev)->device; 201 struct nvif_device *device = &nouveau_drm(dev)->device;
202 struct nv_fifo_info fifo_data; 202 struct nv_fifo_info fifo_data;
203 struct nv_sim_state sim_data; 203 struct nv_sim_state sim_data;
204 int MClk = nouveau_hw_get_clock(dev, PLL_MEMORY); 204 int MClk = nouveau_hw_get_clock(dev, PLL_MEMORY);
@@ -227,7 +227,7 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
227 sim_data.mem_page_miss = ((cfg1 >> 4) & 0xf) + ((cfg1 >> 31) & 0x1); 227 sim_data.mem_page_miss = ((cfg1 >> 4) & 0xf) + ((cfg1 >> 31) & 0x1);
228 } 228 }
229 229
230 if (nv_device(drm->device)->card_type == NV_04) 230 if (drm->device.info.family == NV_DEVICE_INFO_V0_TNT)
231 nv04_calc_arb(&fifo_data, &sim_data); 231 nv04_calc_arb(&fifo_data, &sim_data);
232 else 232 else
233 nv10_calc_arb(&fifo_data, &sim_data); 233 nv10_calc_arb(&fifo_data, &sim_data);
@@ -254,7 +254,7 @@ nouveau_calc_arb(struct drm_device *dev, int vclk, int bpp, int *burst, int *lwm
254{ 254{
255 struct nouveau_drm *drm = nouveau_drm(dev); 255 struct nouveau_drm *drm = nouveau_drm(dev);
256 256
257 if (nv_device(drm->device)->card_type < NV_20) 257 if (drm->device.info.family < NV_DEVICE_INFO_V0_KELVIN)
258 nv04_update_arb(dev, vclk, bpp, burst, lwm); 258 nv04_update_arb(dev, vclk, bpp, burst, lwm);
259 else if ((dev->pdev->device & 0xfff0) == 0x0240 /*CHIPSET_C51*/ || 259 else if ((dev->pdev->device & 0xfff0) == 0x0240 /*CHIPSET_C51*/ ||
260 (dev->pdev->device & 0xfff0) == 0x03d0 /*CHIPSET_C512*/) { 260 (dev->pdev->device & 0xfff0) == 0x03d0 /*CHIPSET_C512*/) {
diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 8b17d7d49e26..b90aa5c1f90a 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -111,8 +111,8 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod
111{ 111{
112 struct drm_device *dev = crtc->dev; 112 struct drm_device *dev = crtc->dev;
113 struct nouveau_drm *drm = nouveau_drm(dev); 113 struct nouveau_drm *drm = nouveau_drm(dev);
114 struct nouveau_bios *bios = nouveau_bios(drm->device); 114 struct nouveau_bios *bios = nvkm_bios(&drm->device);
115 struct nouveau_clock *clk = nouveau_clock(drm->device); 115 struct nouveau_clock *clk = nvkm_clock(&drm->device);
116 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 116 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
117 struct nv04_mode_state *state = &nv04_display(dev)->mode_reg; 117 struct nv04_mode_state *state = &nv04_display(dev)->mode_reg;
118 struct nv04_crtc_reg *regp = &state->crtc_reg[nv_crtc->index]; 118 struct nv04_crtc_reg *regp = &state->crtc_reg[nv_crtc->index];
@@ -136,7 +136,7 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod
136 * has yet been observed in allowing the use a single stage pll on all 136 * has yet been observed in allowing the use a single stage pll on all
137 * nv43 however. the behaviour of single stage use is untested on nv40 137 * nv43 however. the behaviour of single stage use is untested on nv40
138 */ 138 */
139 if (nv_device(drm->device)->chipset > 0x40 && dot_clock <= (pll_lim.vco1.max_freq / 2)) 139 if (drm->device.info.chipset > 0x40 && dot_clock <= (pll_lim.vco1.max_freq / 2))
140 memset(&pll_lim.vco2, 0, sizeof(pll_lim.vco2)); 140 memset(&pll_lim.vco2, 0, sizeof(pll_lim.vco2));
141 141
142 142
@@ -146,10 +146,10 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod
146 state->pllsel &= PLLSEL_VPLL1_MASK | PLLSEL_VPLL2_MASK | PLLSEL_TV_MASK; 146 state->pllsel &= PLLSEL_VPLL1_MASK | PLLSEL_VPLL2_MASK | PLLSEL_TV_MASK;
147 147
148 /* The blob uses this always, so let's do the same */ 148 /* The blob uses this always, so let's do the same */
149 if (nv_device(drm->device)->card_type == NV_40) 149 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE)
150 state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_USE_VPLL2_TRUE; 150 state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_USE_VPLL2_TRUE;
151 /* again nv40 and some nv43 act more like nv3x as described above */ 151 /* again nv40 and some nv43 act more like nv3x as described above */
152 if (nv_device(drm->device)->chipset < 0x41) 152 if (drm->device.info.chipset < 0x41)
153 state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_MPLL | 153 state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_MPLL |
154 NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_NVPLL; 154 NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_NVPLL;
155 state->pllsel |= nv_crtc->index ? PLLSEL_VPLL2_MASK : PLLSEL_VPLL1_MASK; 155 state->pllsel |= nv_crtc->index ? PLLSEL_VPLL2_MASK : PLLSEL_VPLL1_MASK;
@@ -275,7 +275,7 @@ nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode)
275 horizEnd = horizTotal - 2; 275 horizEnd = horizTotal - 2;
276 horizBlankEnd = horizTotal + 4; 276 horizBlankEnd = horizTotal + 4;
277#if 0 277#if 0
278 if (dev->overlayAdaptor && nv_device(drm->device)->card_type >= NV_10) 278 if (dev->overlayAdaptor && drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
279 /* This reportedly works around some video overlay bandwidth problems */ 279 /* This reportedly works around some video overlay bandwidth problems */
280 horizTotal += 2; 280 horizTotal += 2;
281#endif 281#endif
@@ -509,7 +509,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
509 regp->cursor_cfg = NV_PCRTC_CURSOR_CONFIG_CUR_LINES_64 | 509 regp->cursor_cfg = NV_PCRTC_CURSOR_CONFIG_CUR_LINES_64 |
510 NV_PCRTC_CURSOR_CONFIG_CUR_PIXELS_64 | 510 NV_PCRTC_CURSOR_CONFIG_CUR_PIXELS_64 |
511 NV_PCRTC_CURSOR_CONFIG_ADDRESS_SPACE_PNVM; 511 NV_PCRTC_CURSOR_CONFIG_ADDRESS_SPACE_PNVM;
512 if (nv_device(drm->device)->chipset >= 0x11) 512 if (drm->device.info.chipset >= 0x11)
513 regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_CUR_BPP_32; 513 regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_CUR_BPP_32;
514 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) 514 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
515 regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_DOUBLE_SCAN_ENABLE; 515 regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_DOUBLE_SCAN_ENABLE;
@@ -550,26 +550,26 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
550 * 1 << 30 on 0x60.830), for no apparent reason */ 550 * 1 << 30 on 0x60.830), for no apparent reason */
551 regp->CRTC[NV_CIO_CRE_59] = off_chip_digital; 551 regp->CRTC[NV_CIO_CRE_59] = off_chip_digital;
552 552
553 if (nv_device(drm->device)->card_type >= NV_30) 553 if (drm->device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
554 regp->CRTC[0x9f] = off_chip_digital ? 0x11 : 0x1; 554 regp->CRTC[0x9f] = off_chip_digital ? 0x11 : 0x1;
555 555
556 regp->crtc_830 = mode->crtc_vdisplay - 3; 556 regp->crtc_830 = mode->crtc_vdisplay - 3;
557 regp->crtc_834 = mode->crtc_vdisplay - 1; 557 regp->crtc_834 = mode->crtc_vdisplay - 1;
558 558
559 if (nv_device(drm->device)->card_type == NV_40) 559 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE)
560 /* This is what the blob does */ 560 /* This is what the blob does */
561 regp->crtc_850 = NVReadCRTC(dev, 0, NV_PCRTC_850); 561 regp->crtc_850 = NVReadCRTC(dev, 0, NV_PCRTC_850);
562 562
563 if (nv_device(drm->device)->card_type >= NV_30) 563 if (drm->device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
564 regp->gpio_ext = NVReadCRTC(dev, 0, NV_PCRTC_GPIO_EXT); 564 regp->gpio_ext = NVReadCRTC(dev, 0, NV_PCRTC_GPIO_EXT);
565 565
566 if (nv_device(drm->device)->card_type >= NV_10) 566 if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
567 regp->crtc_cfg = NV10_PCRTC_CONFIG_START_ADDRESS_HSYNC; 567 regp->crtc_cfg = NV10_PCRTC_CONFIG_START_ADDRESS_HSYNC;
568 else 568 else
569 regp->crtc_cfg = NV04_PCRTC_CONFIG_START_ADDRESS_HSYNC; 569 regp->crtc_cfg = NV04_PCRTC_CONFIG_START_ADDRESS_HSYNC;
570 570
571 /* Some misc regs */ 571 /* Some misc regs */
572 if (nv_device(drm->device)->card_type == NV_40) { 572 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) {
573 regp->CRTC[NV_CIO_CRE_85] = 0xFF; 573 regp->CRTC[NV_CIO_CRE_85] = 0xFF;
574 regp->CRTC[NV_CIO_CRE_86] = 0x1; 574 regp->CRTC[NV_CIO_CRE_86] = 0x1;
575 } 575 }
@@ -581,7 +581,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
581 581
582 /* Generic PRAMDAC regs */ 582 /* Generic PRAMDAC regs */
583 583
584 if (nv_device(drm->device)->card_type >= NV_10) 584 if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
585 /* Only bit that bios and blob set. */ 585 /* Only bit that bios and blob set. */
586 regp->nv10_cursync = (1 << 25); 586 regp->nv10_cursync = (1 << 25);
587 587
@@ -590,7 +590,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
590 NV_PRAMDAC_GENERAL_CONTROL_PIXMIX_ON; 590 NV_PRAMDAC_GENERAL_CONTROL_PIXMIX_ON;
591 if (crtc->primary->fb->depth == 16) 591 if (crtc->primary->fb->depth == 16)
592 regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL; 592 regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL;
593 if (nv_device(drm->device)->chipset >= 0x11) 593 if (drm->device.info.chipset >= 0x11)
594 regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_PIPE_LONG; 594 regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_PIPE_LONG;
595 595
596 regp->ramdac_630 = 0; /* turn off green mode (tv test pattern?) */ 596 regp->ramdac_630 = 0; /* turn off green mode (tv test pattern?) */
@@ -653,7 +653,7 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
653 653
654 nv_crtc_mode_set_vga(crtc, adjusted_mode); 654 nv_crtc_mode_set_vga(crtc, adjusted_mode);
655 /* calculated in nv04_dfp_prepare, nv40 needs it written before calculating PLLs */ 655 /* calculated in nv04_dfp_prepare, nv40 needs it written before calculating PLLs */
656 if (nv_device(drm->device)->card_type == NV_40) 656 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE)
657 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, nv04_display(dev)->mode_reg.sel_clk); 657 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, nv04_display(dev)->mode_reg.sel_clk);
658 nv_crtc_mode_set_regs(crtc, adjusted_mode); 658 nv_crtc_mode_set_regs(crtc, adjusted_mode);
659 nv_crtc_calc_state_ext(crtc, mode, adjusted_mode->clock); 659 nv_crtc_calc_state_ext(crtc, mode, adjusted_mode->clock);
@@ -714,7 +714,7 @@ static void nv_crtc_prepare(struct drm_crtc *crtc)
714 714
715 /* Some more preparation. */ 715 /* Some more preparation. */
716 NVWriteCRTC(dev, nv_crtc->index, NV_PCRTC_CONFIG, NV_PCRTC_CONFIG_START_ADDRESS_NON_VGA); 716 NVWriteCRTC(dev, nv_crtc->index, NV_PCRTC_CONFIG, NV_PCRTC_CONFIG_START_ADDRESS_NON_VGA);
717 if (nv_device(drm->device)->card_type == NV_40) { 717 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) {
718 uint32_t reg900 = NVReadRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900); 718 uint32_t reg900 = NVReadRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900);
719 NVWriteRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900, reg900 & ~0x10000); 719 NVWriteRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900, reg900 & ~0x10000);
720 } 720 }
@@ -888,7 +888,7 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
888 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FF_INDEX); 888 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FF_INDEX);
889 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FFLWM__INDEX); 889 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FFLWM__INDEX);
890 890
891 if (nv_device(drm->device)->card_type >= NV_20) { 891 if (drm->device.info.family >= NV_DEVICE_INFO_V0_KELVIN) {
892 regp->CRTC[NV_CIO_CRE_47] = arb_lwm >> 8; 892 regp->CRTC[NV_CIO_CRE_47] = arb_lwm >> 8;
893 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_47); 893 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_47);
894 } 894 }
@@ -969,7 +969,7 @@ static void nv11_cursor_upload(struct drm_device *dev, struct nouveau_bo *src,
969 { 969 {
970 struct nouveau_drm *drm = nouveau_drm(dev); 970 struct nouveau_drm *drm = nouveau_drm(dev);
971 971
972 if (nv_device(drm->device)->chipset == 0x11) { 972 if (drm->device.info.chipset == 0x11) {
973 pixel = ((pixel & 0x000000ff) << 24) | 973 pixel = ((pixel & 0x000000ff) << 24) |
974 ((pixel & 0x0000ff00) << 8) | 974 ((pixel & 0x0000ff00) << 8) |
975 ((pixel & 0x00ff0000) >> 8) | 975 ((pixel & 0x00ff0000) >> 8) |
@@ -1010,7 +1010,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
1010 if (ret) 1010 if (ret)
1011 goto out; 1011 goto out;
1012 1012
1013 if (nv_device(drm->device)->chipset >= 0x11) 1013 if (drm->device.info.chipset >= 0x11)
1014 nv11_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo); 1014 nv11_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo);
1015 else 1015 else
1016 nv04_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo); 1016 nv04_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/cursor.c b/drivers/gpu/drm/nouveau/dispnv04/cursor.c
index a810303169de..4e61173c3353 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/cursor.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/cursor.c
@@ -55,7 +55,7 @@ nv04_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset)
55 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX); 55 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX);
56 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR1_INDEX); 56 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR1_INDEX);
57 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX); 57 crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX);
58 if (nv_device(drm->device)->card_type == NV_40) 58 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE)
59 nv_fix_nv40_hw_cursor(dev, nv_crtc->index); 59 nv_fix_nv40_hw_cursor(dev, nv_crtc->index);
60} 60}
61 61
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dac.c b/drivers/gpu/drm/nouveau/dispnv04/dac.c
index 3fec5e6b66b1..2d8056cde996 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dac.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dac.c
@@ -65,8 +65,8 @@ int nv04_dac_output_offset(struct drm_encoder *encoder)
65 65
66static int sample_load_twice(struct drm_device *dev, bool sense[2]) 66static int sample_load_twice(struct drm_device *dev, bool sense[2])
67{ 67{
68 struct nouveau_object *device = nouveau_drm(dev)->device; 68 struct nvif_device *device = &nouveau_drm(dev)->device;
69 struct nouveau_timer *ptimer = nouveau_timer(device); 69 struct nouveau_timer *ptimer = nvkm_timer(device);
70 int i; 70 int i;
71 71
72 for (i = 0; i < 2; i++) { 72 for (i = 0; i < 2; i++) {
@@ -128,7 +128,7 @@ static enum drm_connector_status nv04_dac_detect(struct drm_encoder *encoder,
128 struct drm_connector *connector) 128 struct drm_connector *connector)
129{ 129{
130 struct drm_device *dev = encoder->dev; 130 struct drm_device *dev = encoder->dev;
131 struct nouveau_object *device = nouveau_drm(dev)->device; 131 struct nvif_device *device = &nouveau_drm(dev)->device;
132 struct nouveau_drm *drm = nouveau_drm(dev); 132 struct nouveau_drm *drm = nouveau_drm(dev);
133 uint8_t saved_seq1, saved_pi, saved_rpc1, saved_cr_mode; 133 uint8_t saved_seq1, saved_pi, saved_rpc1, saved_cr_mode;
134 uint8_t saved_palette0[3], saved_palette_mask; 134 uint8_t saved_palette0[3], saved_palette_mask;
@@ -231,8 +231,8 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
231{ 231{
232 struct drm_device *dev = encoder->dev; 232 struct drm_device *dev = encoder->dev;
233 struct nouveau_drm *drm = nouveau_drm(dev); 233 struct nouveau_drm *drm = nouveau_drm(dev);
234 struct nouveau_object *device = nouveau_drm(dev)->device; 234 struct nvif_device *device = &nouveau_drm(dev)->device;
235 struct nouveau_gpio *gpio = nouveau_gpio(device); 235 struct nouveau_gpio *gpio = nvkm_gpio(device);
236 struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; 236 struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
237 uint32_t sample, testval, regoffset = nv04_dac_output_offset(encoder); 237 uint32_t sample, testval, regoffset = nv04_dac_output_offset(encoder);
238 uint32_t saved_powerctrl_2 = 0, saved_powerctrl_4 = 0, saved_routput, 238 uint32_t saved_powerctrl_2 = 0, saved_powerctrl_4 = 0, saved_routput,
@@ -283,7 +283,7 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
283 /* nv driver and nv31 use 0xfffffeee, nv34 and 6600 use 0xfffffece */ 283 /* nv driver and nv31 use 0xfffffeee, nv34 and 6600 use 0xfffffece */
284 routput = (saved_routput & 0xfffffece) | head << 8; 284 routput = (saved_routput & 0xfffffece) | head << 8;
285 285
286 if (nv_device(drm->device)->card_type >= NV_40) { 286 if (drm->device.info.family >= NV_DEVICE_INFO_V0_CURIE) {
287 if (dcb->type == DCB_OUTPUT_TV) 287 if (dcb->type == DCB_OUTPUT_TV)
288 routput |= 0x1a << 16; 288 routput |= 0x1a << 16;
289 else 289 else
@@ -398,7 +398,7 @@ static void nv04_dac_mode_set(struct drm_encoder *encoder,
398 } 398 }
399 399
400 /* This could use refinement for flatpanels, but it should work this way */ 400 /* This could use refinement for flatpanels, but it should work this way */
401 if (nv_device(drm->device)->chipset < 0x44) 401 if (drm->device.info.chipset < 0x44)
402 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0xf0000000); 402 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0xf0000000);
403 else 403 else
404 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000); 404 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
index a9f510e01c2f..42a5435259f7 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
@@ -281,7 +281,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
281 struct drm_display_mode *adjusted_mode) 281 struct drm_display_mode *adjusted_mode)
282{ 282{
283 struct drm_device *dev = encoder->dev; 283 struct drm_device *dev = encoder->dev;
284 struct nouveau_object *device = nouveau_drm(dev)->device; 284 struct nvif_device *device = &nouveau_drm(dev)->device;
285 struct nouveau_drm *drm = nouveau_drm(dev); 285 struct nouveau_drm *drm = nouveau_drm(dev);
286 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 286 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
287 struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; 287 struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index];
@@ -416,7 +416,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
416 if ((nv_connector->dithering_mode == DITHERING_MODE_ON) || 416 if ((nv_connector->dithering_mode == DITHERING_MODE_ON) ||
417 (nv_connector->dithering_mode == DITHERING_MODE_AUTO && 417 (nv_connector->dithering_mode == DITHERING_MODE_AUTO &&
418 encoder->crtc->primary->fb->depth > connector->display_info.bpc * 3)) { 418 encoder->crtc->primary->fb->depth > connector->display_info.bpc * 3)) {
419 if (nv_device(drm->device)->chipset == 0x11) 419 if (drm->device.info.chipset == 0x11)
420 regp->dither = savep->dither | 0x00010000; 420 regp->dither = savep->dither | 0x00010000;
421 else { 421 else {
422 int i; 422 int i;
@@ -427,7 +427,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
427 } 427 }
428 } 428 }
429 } else { 429 } else {
430 if (nv_device(drm->device)->chipset != 0x11) { 430 if (drm->device.info.chipset != 0x11) {
431 /* reset them */ 431 /* reset them */
432 int i; 432 int i;
433 for (i = 0; i < 3; i++) { 433 for (i = 0; i < 3; i++) {
@@ -463,7 +463,7 @@ static void nv04_dfp_commit(struct drm_encoder *encoder)
463 NVReadRAMDAC(dev, head, NV_PRAMDAC_FP_TG_CONTROL); 463 NVReadRAMDAC(dev, head, NV_PRAMDAC_FP_TG_CONTROL);
464 464
465 /* This could use refinement for flatpanels, but it should work this way */ 465 /* This could use refinement for flatpanels, but it should work this way */
466 if (nv_device(drm->device)->chipset < 0x44) 466 if (drm->device.info.chipset < 0x44)
467 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0xf0000000); 467 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0xf0000000);
468 else 468 else
469 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000); 469 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000);
@@ -485,7 +485,7 @@ static void nv04_dfp_update_backlight(struct drm_encoder *encoder, int mode)
485{ 485{
486#ifdef __powerpc__ 486#ifdef __powerpc__
487 struct drm_device *dev = encoder->dev; 487 struct drm_device *dev = encoder->dev;
488 struct nouveau_object *device = nouveau_drm(dev)->device; 488 struct nvif_device *device = &nouveau_drm(dev)->device;
489 489
490 /* BIOS scripts usually take care of the backlight, thanks 490 /* BIOS scripts usually take care of the backlight, thanks
491 * Apple for your consistency. 491 * Apple for your consistency.
@@ -623,7 +623,7 @@ static void nv04_tmds_slave_init(struct drm_encoder *encoder)
623 struct drm_device *dev = encoder->dev; 623 struct drm_device *dev = encoder->dev;
624 struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; 624 struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
625 struct nouveau_drm *drm = nouveau_drm(dev); 625 struct nouveau_drm *drm = nouveau_drm(dev);
626 struct nouveau_i2c *i2c = nouveau_i2c(drm->device); 626 struct nouveau_i2c *i2c = nvkm_i2c(&drm->device);
627 struct nouveau_i2c_port *port = i2c->find(i2c, 2); 627 struct nouveau_i2c_port *port = i2c->find(i2c, 2);
628 struct nouveau_i2c_board_info info[] = { 628 struct nouveau_i2c_board_info info[] = {
629 { 629 {
diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.c b/drivers/gpu/drm/nouveau/dispnv04/disp.c
index 4342fdaee707..e63f5d694c55 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.c
@@ -58,7 +58,7 @@ int
58nv04_display_create(struct drm_device *dev) 58nv04_display_create(struct drm_device *dev)
59{ 59{
60 struct nouveau_drm *drm = nouveau_drm(dev); 60 struct nouveau_drm *drm = nouveau_drm(dev);
61 struct nouveau_i2c *i2c = nouveau_i2c(drm->device); 61 struct nouveau_i2c *i2c = nvkm_i2c(&drm->device);
62 struct dcb_table *dcb = &drm->vbios.dcb; 62 struct dcb_table *dcb = &drm->vbios.dcb;
63 struct drm_connector *connector, *ct; 63 struct drm_connector *connector, *ct;
64 struct drm_encoder *encoder; 64 struct drm_encoder *encoder;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.h b/drivers/gpu/drm/nouveau/dispnv04/disp.h
index 99408cf03af0..17b899d9aba3 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.h
@@ -131,7 +131,7 @@ nv_two_heads(struct drm_device *dev)
131 struct nouveau_drm *drm = nouveau_drm(dev); 131 struct nouveau_drm *drm = nouveau_drm(dev);
132 const int impl = dev->pdev->device & 0x0ff0; 132 const int impl = dev->pdev->device & 0x0ff0;
133 133
134 if (nv_device(drm->device)->card_type >= NV_10 && impl != 0x0100 && 134 if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS && impl != 0x0100 &&
135 impl != 0x0150 && impl != 0x01a0 && impl != 0x0200) 135 impl != 0x0150 && impl != 0x01a0 && impl != 0x0200)
136 return true; 136 return true;
137 137
@@ -150,7 +150,7 @@ nv_two_reg_pll(struct drm_device *dev)
150 struct nouveau_drm *drm = nouveau_drm(dev); 150 struct nouveau_drm *drm = nouveau_drm(dev);
151 const int impl = dev->pdev->device & 0x0ff0; 151 const int impl = dev->pdev->device & 0x0ff0;
152 152
153 if (impl == 0x0310 || impl == 0x0340 || nv_device(drm->device)->card_type >= NV_40) 153 if (impl == 0x0310 || impl == 0x0340 || drm->device.info.family >= NV_DEVICE_INFO_V0_CURIE)
154 return true; 154 return true;
155 return false; 155 return false;
156} 156}
@@ -172,7 +172,7 @@ nouveau_bios_run_init_table(struct drm_device *dev, u16 table,
172 struct dcb_output *outp, int crtc) 172 struct dcb_output *outp, int crtc)
173{ 173{
174 struct nouveau_drm *drm = nouveau_drm(dev); 174 struct nouveau_drm *drm = nouveau_drm(dev);
175 struct nouveau_bios *bios = nouveau_bios(drm->device); 175 struct nouveau_bios *bios = nvkm_bios(&drm->device);
176 struct nvbios_init init = { 176 struct nvbios_init init = {
177 .subdev = nv_subdev(bios), 177 .subdev = nv_subdev(bios),
178 .bios = bios, 178 .bios = bios,
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.c b/drivers/gpu/drm/nouveau/dispnv04/hw.c
index e09c35a948ca..c12f3a871da1 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.c
@@ -92,7 +92,7 @@ NVSetOwner(struct drm_device *dev, int owner)
92 if (owner == 1) 92 if (owner == 1)
93 owner *= 3; 93 owner *= 3;
94 94
95 if (nv_device(drm->device)->chipset == 0x11) { 95 if (drm->device.info.chipset == 0x11) {
96 /* This might seem stupid, but the blob does it and 96 /* This might seem stupid, but the blob does it and
97 * omitting it often locks the system up. 97 * omitting it often locks the system up.
98 */ 98 */
@@ -103,7 +103,7 @@ NVSetOwner(struct drm_device *dev, int owner)
103 /* CR44 is always changed on CRTC0 */ 103 /* CR44 is always changed on CRTC0 */
104 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_44, owner); 104 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_44, owner);
105 105
106 if (nv_device(drm->device)->chipset == 0x11) { /* set me harder */ 106 if (drm->device.info.chipset == 0x11) { /* set me harder */
107 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_2E, owner); 107 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_2E, owner);
108 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_2E, owner); 108 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_2E, owner);
109 } 109 }
@@ -152,7 +152,7 @@ nouveau_hw_decode_pll(struct drm_device *dev, uint32_t reg1, uint32_t pll1,
152 pllvals->NM1 = pll1 & 0xffff; 152 pllvals->NM1 = pll1 & 0xffff;
153 if (nv_two_reg_pll(dev) && pll2 & NV31_RAMDAC_ENABLE_VCO2) 153 if (nv_two_reg_pll(dev) && pll2 & NV31_RAMDAC_ENABLE_VCO2)
154 pllvals->NM2 = pll2 & 0xffff; 154 pllvals->NM2 = pll2 & 0xffff;
155 else if (nv_device(drm->device)->chipset == 0x30 || nv_device(drm->device)->chipset == 0x35) { 155 else if (drm->device.info.chipset == 0x30 || drm->device.info.chipset == 0x35) {
156 pllvals->M1 &= 0xf; /* only 4 bits */ 156 pllvals->M1 &= 0xf; /* only 4 bits */
157 if (pll1 & NV30_RAMDAC_ENABLE_VCO2) { 157 if (pll1 & NV30_RAMDAC_ENABLE_VCO2) {
158 pllvals->M2 = (pll1 >> 4) & 0x7; 158 pllvals->M2 = (pll1 >> 4) & 0x7;
@@ -168,8 +168,8 @@ nouveau_hw_get_pllvals(struct drm_device *dev, enum nvbios_pll_type plltype,
168 struct nouveau_pll_vals *pllvals) 168 struct nouveau_pll_vals *pllvals)
169{ 169{
170 struct nouveau_drm *drm = nouveau_drm(dev); 170 struct nouveau_drm *drm = nouveau_drm(dev);
171 struct nouveau_object *device = drm->device; 171 struct nvif_device *device = &drm->device;
172 struct nouveau_bios *bios = nouveau_bios(device); 172 struct nouveau_bios *bios = nvkm_bios(device);
173 uint32_t reg1, pll1, pll2 = 0; 173 uint32_t reg1, pll1, pll2 = 0;
174 struct nvbios_pll pll_lim; 174 struct nvbios_pll pll_lim;
175 int ret; 175 int ret;
@@ -187,7 +187,7 @@ nouveau_hw_get_pllvals(struct drm_device *dev, enum nvbios_pll_type plltype,
187 pll2 = nvif_rd32(device, reg2); 187 pll2 = nvif_rd32(device, reg2);
188 } 188 }
189 189
190 if (nv_device(drm->device)->card_type == 0x40 && reg1 >= NV_PRAMDAC_VPLL_COEFF) { 190 if (drm->device.info.family == NV_DEVICE_INFO_V0_CELSIUS && reg1 >= NV_PRAMDAC_VPLL_COEFF) {
191 uint32_t ramdac580 = NVReadRAMDAC(dev, 0, NV_PRAMDAC_580); 191 uint32_t ramdac580 = NVReadRAMDAC(dev, 0, NV_PRAMDAC_580);
192 192
193 /* check whether vpll has been forced into single stage mode */ 193 /* check whether vpll has been forced into single stage mode */
@@ -255,9 +255,9 @@ nouveau_hw_fix_bad_vpll(struct drm_device *dev, int head)
255 */ 255 */
256 256
257 struct nouveau_drm *drm = nouveau_drm(dev); 257 struct nouveau_drm *drm = nouveau_drm(dev);
258 struct nouveau_object *device = drm->device; 258 struct nvif_device *device = &drm->device;
259 struct nouveau_clock *clk = nouveau_clock(device); 259 struct nouveau_clock *clk = nvkm_clock(device);
260 struct nouveau_bios *bios = nouveau_bios(device); 260 struct nouveau_bios *bios = nvkm_bios(device);
261 struct nvbios_pll pll_lim; 261 struct nvbios_pll pll_lim;
262 struct nouveau_pll_vals pv; 262 struct nouveau_pll_vals pv;
263 enum nvbios_pll_type pll = head ? PLL_VPLL1 : PLL_VPLL0; 263 enum nvbios_pll_type pll = head ? PLL_VPLL1 : PLL_VPLL0;
@@ -394,21 +394,21 @@ nv_save_state_ramdac(struct drm_device *dev, int head,
394 struct nv04_crtc_reg *regp = &state->crtc_reg[head]; 394 struct nv04_crtc_reg *regp = &state->crtc_reg[head];
395 int i; 395 int i;
396 396
397 if (nv_device(drm->device)->card_type >= NV_10) 397 if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
398 regp->nv10_cursync = NVReadRAMDAC(dev, head, NV_RAMDAC_NV10_CURSYNC); 398 regp->nv10_cursync = NVReadRAMDAC(dev, head, NV_RAMDAC_NV10_CURSYNC);
399 399
400 nouveau_hw_get_pllvals(dev, head ? PLL_VPLL1 : PLL_VPLL0, &regp->pllvals); 400 nouveau_hw_get_pllvals(dev, head ? PLL_VPLL1 : PLL_VPLL0, &regp->pllvals);
401 state->pllsel = NVReadRAMDAC(dev, 0, NV_PRAMDAC_PLL_COEFF_SELECT); 401 state->pllsel = NVReadRAMDAC(dev, 0, NV_PRAMDAC_PLL_COEFF_SELECT);
402 if (nv_two_heads(dev)) 402 if (nv_two_heads(dev))
403 state->sel_clk = NVReadRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK); 403 state->sel_clk = NVReadRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK);
404 if (nv_device(drm->device)->chipset == 0x11) 404 if (drm->device.info.chipset == 0x11)
405 regp->dither = NVReadRAMDAC(dev, head, NV_RAMDAC_DITHER_NV11); 405 regp->dither = NVReadRAMDAC(dev, head, NV_RAMDAC_DITHER_NV11);
406 406
407 regp->ramdac_gen_ctrl = NVReadRAMDAC(dev, head, NV_PRAMDAC_GENERAL_CONTROL); 407 regp->ramdac_gen_ctrl = NVReadRAMDAC(dev, head, NV_PRAMDAC_GENERAL_CONTROL);
408 408
409 if (nv_gf4_disp_arch(dev)) 409 if (nv_gf4_disp_arch(dev))
410 regp->ramdac_630 = NVReadRAMDAC(dev, head, NV_PRAMDAC_630); 410 regp->ramdac_630 = NVReadRAMDAC(dev, head, NV_PRAMDAC_630);
411 if (nv_device(drm->device)->chipset >= 0x30) 411 if (drm->device.info.chipset >= 0x30)
412 regp->ramdac_634 = NVReadRAMDAC(dev, head, NV_PRAMDAC_634); 412 regp->ramdac_634 = NVReadRAMDAC(dev, head, NV_PRAMDAC_634);
413 413
414 regp->tv_setup = NVReadRAMDAC(dev, head, NV_PRAMDAC_TV_SETUP); 414 regp->tv_setup = NVReadRAMDAC(dev, head, NV_PRAMDAC_TV_SETUP);
@@ -450,7 +450,7 @@ nv_save_state_ramdac(struct drm_device *dev, int head,
450 if (nv_gf4_disp_arch(dev)) 450 if (nv_gf4_disp_arch(dev))
451 regp->ramdac_8c0 = NVReadRAMDAC(dev, head, NV_PRAMDAC_8C0); 451 regp->ramdac_8c0 = NVReadRAMDAC(dev, head, NV_PRAMDAC_8C0);
452 452
453 if (nv_device(drm->device)->card_type == NV_40) { 453 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) {
454 regp->ramdac_a20 = NVReadRAMDAC(dev, head, NV_PRAMDAC_A20); 454 regp->ramdac_a20 = NVReadRAMDAC(dev, head, NV_PRAMDAC_A20);
455 regp->ramdac_a24 = NVReadRAMDAC(dev, head, NV_PRAMDAC_A24); 455 regp->ramdac_a24 = NVReadRAMDAC(dev, head, NV_PRAMDAC_A24);
456 regp->ramdac_a34 = NVReadRAMDAC(dev, head, NV_PRAMDAC_A34); 456 regp->ramdac_a34 = NVReadRAMDAC(dev, head, NV_PRAMDAC_A34);
@@ -466,26 +466,26 @@ nv_load_state_ramdac(struct drm_device *dev, int head,
466 struct nv04_mode_state *state) 466 struct nv04_mode_state *state)
467{ 467{
468 struct nouveau_drm *drm = nouveau_drm(dev); 468 struct nouveau_drm *drm = nouveau_drm(dev);
469 struct nouveau_clock *clk = nouveau_clock(drm->device); 469 struct nouveau_clock *clk = nvkm_clock(&drm->device);
470 struct nv04_crtc_reg *regp = &state->crtc_reg[head]; 470 struct nv04_crtc_reg *regp = &state->crtc_reg[head];
471 uint32_t pllreg = head ? NV_RAMDAC_VPLL2 : NV_PRAMDAC_VPLL_COEFF; 471 uint32_t pllreg = head ? NV_RAMDAC_VPLL2 : NV_PRAMDAC_VPLL_COEFF;
472 int i; 472 int i;
473 473
474 if (nv_device(drm->device)->card_type >= NV_10) 474 if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
475 NVWriteRAMDAC(dev, head, NV_RAMDAC_NV10_CURSYNC, regp->nv10_cursync); 475 NVWriteRAMDAC(dev, head, NV_RAMDAC_NV10_CURSYNC, regp->nv10_cursync);
476 476
477 clk->pll_prog(clk, pllreg, &regp->pllvals); 477 clk->pll_prog(clk, pllreg, &regp->pllvals);
478 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_PLL_COEFF_SELECT, state->pllsel); 478 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_PLL_COEFF_SELECT, state->pllsel);
479 if (nv_two_heads(dev)) 479 if (nv_two_heads(dev))
480 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, state->sel_clk); 480 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, state->sel_clk);
481 if (nv_device(drm->device)->chipset == 0x11) 481 if (drm->device.info.chipset == 0x11)
482 NVWriteRAMDAC(dev, head, NV_RAMDAC_DITHER_NV11, regp->dither); 482 NVWriteRAMDAC(dev, head, NV_RAMDAC_DITHER_NV11, regp->dither);
483 483
484 NVWriteRAMDAC(dev, head, NV_PRAMDAC_GENERAL_CONTROL, regp->ramdac_gen_ctrl); 484 NVWriteRAMDAC(dev, head, NV_PRAMDAC_GENERAL_CONTROL, regp->ramdac_gen_ctrl);
485 485
486 if (nv_gf4_disp_arch(dev)) 486 if (nv_gf4_disp_arch(dev))
487 NVWriteRAMDAC(dev, head, NV_PRAMDAC_630, regp->ramdac_630); 487 NVWriteRAMDAC(dev, head, NV_PRAMDAC_630, regp->ramdac_630);
488 if (nv_device(drm->device)->chipset >= 0x30) 488 if (drm->device.info.chipset >= 0x30)
489 NVWriteRAMDAC(dev, head, NV_PRAMDAC_634, regp->ramdac_634); 489 NVWriteRAMDAC(dev, head, NV_PRAMDAC_634, regp->ramdac_634);
490 490
491 NVWriteRAMDAC(dev, head, NV_PRAMDAC_TV_SETUP, regp->tv_setup); 491 NVWriteRAMDAC(dev, head, NV_PRAMDAC_TV_SETUP, regp->tv_setup);
@@ -522,7 +522,7 @@ nv_load_state_ramdac(struct drm_device *dev, int head,
522 if (nv_gf4_disp_arch(dev)) 522 if (nv_gf4_disp_arch(dev))
523 NVWriteRAMDAC(dev, head, NV_PRAMDAC_8C0, regp->ramdac_8c0); 523 NVWriteRAMDAC(dev, head, NV_PRAMDAC_8C0, regp->ramdac_8c0);
524 524
525 if (nv_device(drm->device)->card_type == NV_40) { 525 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) {
526 NVWriteRAMDAC(dev, head, NV_PRAMDAC_A20, regp->ramdac_a20); 526 NVWriteRAMDAC(dev, head, NV_PRAMDAC_A20, regp->ramdac_a20);
527 NVWriteRAMDAC(dev, head, NV_PRAMDAC_A24, regp->ramdac_a24); 527 NVWriteRAMDAC(dev, head, NV_PRAMDAC_A24, regp->ramdac_a24);
528 NVWriteRAMDAC(dev, head, NV_PRAMDAC_A34, regp->ramdac_a34); 528 NVWriteRAMDAC(dev, head, NV_PRAMDAC_A34, regp->ramdac_a34);
@@ -603,10 +603,10 @@ nv_save_state_ext(struct drm_device *dev, int head,
603 rd_cio_state(dev, head, regp, NV_CIO_CRE_FFLWM__INDEX); 603 rd_cio_state(dev, head, regp, NV_CIO_CRE_FFLWM__INDEX);
604 rd_cio_state(dev, head, regp, NV_CIO_CRE_21); 604 rd_cio_state(dev, head, regp, NV_CIO_CRE_21);
605 605
606 if (nv_device(drm->device)->card_type >= NV_20) 606 if (drm->device.info.family >= NV_DEVICE_INFO_V0_KELVIN)
607 rd_cio_state(dev, head, regp, NV_CIO_CRE_47); 607 rd_cio_state(dev, head, regp, NV_CIO_CRE_47);
608 608
609 if (nv_device(drm->device)->card_type >= NV_30) 609 if (drm->device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
610 rd_cio_state(dev, head, regp, 0x9f); 610 rd_cio_state(dev, head, regp, 0x9f);
611 611
612 rd_cio_state(dev, head, regp, NV_CIO_CRE_49); 612 rd_cio_state(dev, head, regp, NV_CIO_CRE_49);
@@ -615,14 +615,14 @@ nv_save_state_ext(struct drm_device *dev, int head,
615 rd_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX); 615 rd_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX);
616 rd_cio_state(dev, head, regp, NV_CIO_CRE_ILACE__INDEX); 616 rd_cio_state(dev, head, regp, NV_CIO_CRE_ILACE__INDEX);
617 617
618 if (nv_device(drm->device)->card_type >= NV_10) { 618 if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) {
619 regp->crtc_830 = NVReadCRTC(dev, head, NV_PCRTC_830); 619 regp->crtc_830 = NVReadCRTC(dev, head, NV_PCRTC_830);
620 regp->crtc_834 = NVReadCRTC(dev, head, NV_PCRTC_834); 620 regp->crtc_834 = NVReadCRTC(dev, head, NV_PCRTC_834);
621 621
622 if (nv_device(drm->device)->card_type >= NV_30) 622 if (drm->device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
623 regp->gpio_ext = NVReadCRTC(dev, head, NV_PCRTC_GPIO_EXT); 623 regp->gpio_ext = NVReadCRTC(dev, head, NV_PCRTC_GPIO_EXT);
624 624
625 if (nv_device(drm->device)->card_type == NV_40) 625 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE)
626 regp->crtc_850 = NVReadCRTC(dev, head, NV_PCRTC_850); 626 regp->crtc_850 = NVReadCRTC(dev, head, NV_PCRTC_850);
627 627
628 if (nv_two_heads(dev)) 628 if (nv_two_heads(dev))
@@ -634,7 +634,7 @@ nv_save_state_ext(struct drm_device *dev, int head,
634 634
635 rd_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH3__INDEX); 635 rd_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH3__INDEX);
636 rd_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH4__INDEX); 636 rd_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH4__INDEX);
637 if (nv_device(drm->device)->card_type >= NV_10) { 637 if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) {
638 rd_cio_state(dev, head, regp, NV_CIO_CRE_EBR_INDEX); 638 rd_cio_state(dev, head, regp, NV_CIO_CRE_EBR_INDEX);
639 rd_cio_state(dev, head, regp, NV_CIO_CRE_CSB); 639 rd_cio_state(dev, head, regp, NV_CIO_CRE_CSB);
640 rd_cio_state(dev, head, regp, NV_CIO_CRE_4B); 640 rd_cio_state(dev, head, regp, NV_CIO_CRE_4B);
@@ -663,14 +663,14 @@ nv_load_state_ext(struct drm_device *dev, int head,
663 struct nv04_mode_state *state) 663 struct nv04_mode_state *state)
664{ 664{
665 struct nouveau_drm *drm = nouveau_drm(dev); 665 struct nouveau_drm *drm = nouveau_drm(dev);
666 struct nouveau_object *device = drm->device; 666 struct nvif_device *device = &drm->device;
667 struct nouveau_timer *ptimer = nouveau_timer(device); 667 struct nouveau_timer *ptimer = nvkm_timer(device);
668 struct nouveau_fb *pfb = nouveau_fb(device); 668 struct nouveau_fb *pfb = nvkm_fb(device);
669 struct nv04_crtc_reg *regp = &state->crtc_reg[head]; 669 struct nv04_crtc_reg *regp = &state->crtc_reg[head];
670 uint32_t reg900; 670 uint32_t reg900;
671 int i; 671 int i;
672 672
673 if (nv_device(drm->device)->card_type >= NV_10) { 673 if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) {
674 if (nv_two_heads(dev)) 674 if (nv_two_heads(dev))
675 /* setting ENGINE_CTRL (EC) *must* come before 675 /* setting ENGINE_CTRL (EC) *must* come before
676 * CIO_CRE_LCD, as writing CRE_LCD sets bits 16 & 17 in 676 * CIO_CRE_LCD, as writing CRE_LCD sets bits 16 & 17 in
@@ -692,10 +692,10 @@ nv_load_state_ext(struct drm_device *dev, int head,
692 NVWriteCRTC(dev, head, NV_PCRTC_830, regp->crtc_830); 692 NVWriteCRTC(dev, head, NV_PCRTC_830, regp->crtc_830);
693 NVWriteCRTC(dev, head, NV_PCRTC_834, regp->crtc_834); 693 NVWriteCRTC(dev, head, NV_PCRTC_834, regp->crtc_834);
694 694
695 if (nv_device(drm->device)->card_type >= NV_30) 695 if (drm->device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
696 NVWriteCRTC(dev, head, NV_PCRTC_GPIO_EXT, regp->gpio_ext); 696 NVWriteCRTC(dev, head, NV_PCRTC_GPIO_EXT, regp->gpio_ext);
697 697
698 if (nv_device(drm->device)->card_type == NV_40) { 698 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) {
699 NVWriteCRTC(dev, head, NV_PCRTC_850, regp->crtc_850); 699 NVWriteCRTC(dev, head, NV_PCRTC_850, regp->crtc_850);
700 700
701 reg900 = NVReadRAMDAC(dev, head, NV_PRAMDAC_900); 701 reg900 = NVReadRAMDAC(dev, head, NV_PRAMDAC_900);
@@ -718,23 +718,23 @@ nv_load_state_ext(struct drm_device *dev, int head,
718 wr_cio_state(dev, head, regp, NV_CIO_CRE_FF_INDEX); 718 wr_cio_state(dev, head, regp, NV_CIO_CRE_FF_INDEX);
719 wr_cio_state(dev, head, regp, NV_CIO_CRE_FFLWM__INDEX); 719 wr_cio_state(dev, head, regp, NV_CIO_CRE_FFLWM__INDEX);
720 720
721 if (nv_device(drm->device)->card_type >= NV_20) 721 if (drm->device.info.family >= NV_DEVICE_INFO_V0_KELVIN)
722 wr_cio_state(dev, head, regp, NV_CIO_CRE_47); 722 wr_cio_state(dev, head, regp, NV_CIO_CRE_47);
723 723
724 if (nv_device(drm->device)->card_type >= NV_30) 724 if (drm->device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
725 wr_cio_state(dev, head, regp, 0x9f); 725 wr_cio_state(dev, head, regp, 0x9f);
726 726
727 wr_cio_state(dev, head, regp, NV_CIO_CRE_49); 727 wr_cio_state(dev, head, regp, NV_CIO_CRE_49);
728 wr_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX); 728 wr_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX);
729 wr_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR1_INDEX); 729 wr_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR1_INDEX);
730 wr_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX); 730 wr_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX);
731 if (nv_device(drm->device)->card_type == NV_40) 731 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE)
732 nv_fix_nv40_hw_cursor(dev, head); 732 nv_fix_nv40_hw_cursor(dev, head);
733 wr_cio_state(dev, head, regp, NV_CIO_CRE_ILACE__INDEX); 733 wr_cio_state(dev, head, regp, NV_CIO_CRE_ILACE__INDEX);
734 734
735 wr_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH3__INDEX); 735 wr_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH3__INDEX);
736 wr_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH4__INDEX); 736 wr_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH4__INDEX);
737 if (nv_device(drm->device)->card_type >= NV_10) { 737 if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) {
738 wr_cio_state(dev, head, regp, NV_CIO_CRE_EBR_INDEX); 738 wr_cio_state(dev, head, regp, NV_CIO_CRE_EBR_INDEX);
739 wr_cio_state(dev, head, regp, NV_CIO_CRE_CSB); 739 wr_cio_state(dev, head, regp, NV_CIO_CRE_CSB);
740 wr_cio_state(dev, head, regp, NV_CIO_CRE_4B); 740 wr_cio_state(dev, head, regp, NV_CIO_CRE_4B);
@@ -742,7 +742,7 @@ nv_load_state_ext(struct drm_device *dev, int head,
742 } 742 }
743 /* NV11 and NV20 stop at 0x52. */ 743 /* NV11 and NV20 stop at 0x52. */
744 if (nv_gf4_disp_arch(dev)) { 744 if (nv_gf4_disp_arch(dev)) {
745 if (nv_device(drm->device)->card_type < NV_20) { 745 if (drm->device.info.family < NV_DEVICE_INFO_V0_KELVIN) {
746 /* Not waiting for vertical retrace before modifying 746 /* Not waiting for vertical retrace before modifying
747 CRE_53/CRE_54 causes lockups. */ 747 CRE_53/CRE_54 causes lockups. */
748 nouveau_timer_wait_eq(ptimer, 650000000, NV_PRMCIO_INP0__COLOR, 0x8, 0x8); 748 nouveau_timer_wait_eq(ptimer, 650000000, NV_PRMCIO_INP0__COLOR, 0x8, 0x8);
@@ -769,7 +769,7 @@ static void
769nv_save_state_palette(struct drm_device *dev, int head, 769nv_save_state_palette(struct drm_device *dev, int head,
770 struct nv04_mode_state *state) 770 struct nv04_mode_state *state)
771{ 771{
772 struct nouveau_object *device = nouveau_drm(dev)->device; 772 struct nvif_device *device = &nouveau_drm(dev)->device;
773 int head_offset = head * NV_PRMDIO_SIZE, i; 773 int head_offset = head * NV_PRMDIO_SIZE, i;
774 774
775 nvif_wr08(device, NV_PRMDIO_PIXEL_MASK + head_offset, 775 nvif_wr08(device, NV_PRMDIO_PIXEL_MASK + head_offset,
@@ -788,7 +788,7 @@ void
788nouveau_hw_load_state_palette(struct drm_device *dev, int head, 788nouveau_hw_load_state_palette(struct drm_device *dev, int head,
789 struct nv04_mode_state *state) 789 struct nv04_mode_state *state)
790{ 790{
791 struct nouveau_object *device = nouveau_drm(dev)->device; 791 struct nvif_device *device = &nouveau_drm(dev)->device;
792 int head_offset = head * NV_PRMDIO_SIZE, i; 792 int head_offset = head * NV_PRMDIO_SIZE, i;
793 793
794 nvif_wr08(device, NV_PRMDIO_PIXEL_MASK + head_offset, 794 nvif_wr08(device, NV_PRMDIO_PIXEL_MASK + head_offset,
@@ -808,7 +808,7 @@ void nouveau_hw_save_state(struct drm_device *dev, int head,
808{ 808{
809 struct nouveau_drm *drm = nouveau_drm(dev); 809 struct nouveau_drm *drm = nouveau_drm(dev);
810 810
811 if (nv_device(drm->device)->chipset == 0x11) 811 if (drm->device.info.chipset == 0x11)
812 /* NB: no attempt is made to restore the bad pll later on */ 812 /* NB: no attempt is made to restore the bad pll later on */
813 nouveau_hw_fix_bad_vpll(dev, head); 813 nouveau_hw_fix_bad_vpll(dev, head);
814 nv_save_state_ramdac(dev, head, state); 814 nv_save_state_ramdac(dev, head, state);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.h b/drivers/gpu/drm/nouveau/dispnv04/hw.h
index ebaf33dbc1a1..7f53c571f31f 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.h
@@ -60,7 +60,7 @@ extern void nouveau_calc_arb(struct drm_device *, int vclk, int bpp,
60static inline uint32_t NVReadCRTC(struct drm_device *dev, 60static inline uint32_t NVReadCRTC(struct drm_device *dev,
61 int head, uint32_t reg) 61 int head, uint32_t reg)
62{ 62{
63 struct nouveau_object *device = nouveau_drm(dev)->device; 63 struct nvif_device *device = &nouveau_drm(dev)->device;
64 uint32_t val; 64 uint32_t val;
65 if (head) 65 if (head)
66 reg += NV_PCRTC0_SIZE; 66 reg += NV_PCRTC0_SIZE;
@@ -71,7 +71,7 @@ static inline uint32_t NVReadCRTC(struct drm_device *dev,
71static inline void NVWriteCRTC(struct drm_device *dev, 71static inline void NVWriteCRTC(struct drm_device *dev,
72 int head, uint32_t reg, uint32_t val) 72 int head, uint32_t reg, uint32_t val)
73{ 73{
74 struct nouveau_object *device = nouveau_drm(dev)->device; 74 struct nvif_device *device = &nouveau_drm(dev)->device;
75 if (head) 75 if (head)
76 reg += NV_PCRTC0_SIZE; 76 reg += NV_PCRTC0_SIZE;
77 nvif_wr32(device, reg, val); 77 nvif_wr32(device, reg, val);
@@ -80,7 +80,7 @@ static inline void NVWriteCRTC(struct drm_device *dev,
80static inline uint32_t NVReadRAMDAC(struct drm_device *dev, 80static inline uint32_t NVReadRAMDAC(struct drm_device *dev,
81 int head, uint32_t reg) 81 int head, uint32_t reg)
82{ 82{
83 struct nouveau_object *device = nouveau_drm(dev)->device; 83 struct nvif_device *device = &nouveau_drm(dev)->device;
84 uint32_t val; 84 uint32_t val;
85 if (head) 85 if (head)
86 reg += NV_PRAMDAC0_SIZE; 86 reg += NV_PRAMDAC0_SIZE;
@@ -91,7 +91,7 @@ static inline uint32_t NVReadRAMDAC(struct drm_device *dev,
91static inline void NVWriteRAMDAC(struct drm_device *dev, 91static inline void NVWriteRAMDAC(struct drm_device *dev,
92 int head, uint32_t reg, uint32_t val) 92 int head, uint32_t reg, uint32_t val)
93{ 93{
94 struct nouveau_object *device = nouveau_drm(dev)->device; 94 struct nvif_device *device = &nouveau_drm(dev)->device;
95 if (head) 95 if (head)
96 reg += NV_PRAMDAC0_SIZE; 96 reg += NV_PRAMDAC0_SIZE;
97 nvif_wr32(device, reg, val); 97 nvif_wr32(device, reg, val);
@@ -120,7 +120,7 @@ static inline void nv_write_tmds(struct drm_device *dev,
120static inline void NVWriteVgaCrtc(struct drm_device *dev, 120static inline void NVWriteVgaCrtc(struct drm_device *dev,
121 int head, uint8_t index, uint8_t value) 121 int head, uint8_t index, uint8_t value)
122{ 122{
123 struct nouveau_object *device = nouveau_drm(dev)->device; 123 struct nvif_device *device = &nouveau_drm(dev)->device;
124 nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); 124 nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index);
125 nvif_wr08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value); 125 nvif_wr08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value);
126} 126}
@@ -128,7 +128,7 @@ static inline void NVWriteVgaCrtc(struct drm_device *dev,
128static inline uint8_t NVReadVgaCrtc(struct drm_device *dev, 128static inline uint8_t NVReadVgaCrtc(struct drm_device *dev,
129 int head, uint8_t index) 129 int head, uint8_t index)
130{ 130{
131 struct nouveau_object *device = nouveau_drm(dev)->device; 131 struct nvif_device *device = &nouveau_drm(dev)->device;
132 uint8_t val; 132 uint8_t val;
133 nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); 133 nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index);
134 val = nvif_rd08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE); 134 val = nvif_rd08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE);
@@ -165,13 +165,13 @@ static inline uint8_t NVReadVgaCrtc5758(struct drm_device *dev, int head, uint8_
165static inline uint8_t NVReadPRMVIO(struct drm_device *dev, 165static inline uint8_t NVReadPRMVIO(struct drm_device *dev,
166 int head, uint32_t reg) 166 int head, uint32_t reg)
167{ 167{
168 struct nouveau_object *device = nouveau_drm(dev)->device; 168 struct nvif_device *device = &nouveau_drm(dev)->device;
169 struct nouveau_drm *drm = nouveau_drm(dev); 169 struct nouveau_drm *drm = nouveau_drm(dev);
170 uint8_t val; 170 uint8_t val;
171 171
172 /* Only NV4x have two pvio ranges; other twoHeads cards MUST call 172 /* Only NV4x have two pvio ranges; other twoHeads cards MUST call
173 * NVSetOwner for the relevant head to be programmed */ 173 * NVSetOwner for the relevant head to be programmed */
174 if (head && nv_device(drm->device)->card_type == NV_40) 174 if (head && drm->device.info.family == NV_DEVICE_INFO_V0_CURIE)
175 reg += NV_PRMVIO_SIZE; 175 reg += NV_PRMVIO_SIZE;
176 176
177 val = nvif_rd08(device, reg); 177 val = nvif_rd08(device, reg);
@@ -181,12 +181,12 @@ static inline uint8_t NVReadPRMVIO(struct drm_device *dev,
181static inline void NVWritePRMVIO(struct drm_device *dev, 181static inline void NVWritePRMVIO(struct drm_device *dev,
182 int head, uint32_t reg, uint8_t value) 182 int head, uint32_t reg, uint8_t value)
183{ 183{
184 struct nouveau_object *device = nouveau_drm(dev)->device; 184 struct nvif_device *device = &nouveau_drm(dev)->device;
185 struct nouveau_drm *drm = nouveau_drm(dev); 185 struct nouveau_drm *drm = nouveau_drm(dev);
186 186
187 /* Only NV4x have two pvio ranges; other twoHeads cards MUST call 187 /* Only NV4x have two pvio ranges; other twoHeads cards MUST call
188 * NVSetOwner for the relevant head to be programmed */ 188 * NVSetOwner for the relevant head to be programmed */
189 if (head && nv_device(drm->device)->card_type == NV_40) 189 if (head && drm->device.info.family == NV_DEVICE_INFO_V0_CURIE)
190 reg += NV_PRMVIO_SIZE; 190 reg += NV_PRMVIO_SIZE;
191 191
192 nvif_wr08(device, reg, value); 192 nvif_wr08(device, reg, value);
@@ -194,14 +194,14 @@ static inline void NVWritePRMVIO(struct drm_device *dev,
194 194
195static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable) 195static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable)
196{ 196{
197 struct nouveau_object *device = nouveau_drm(dev)->device; 197 struct nvif_device *device = &nouveau_drm(dev)->device;
198 nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); 198 nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
199 nvif_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20); 199 nvif_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20);
200} 200}
201 201
202static inline bool NVGetEnablePalette(struct drm_device *dev, int head) 202static inline bool NVGetEnablePalette(struct drm_device *dev, int head)
203{ 203{
204 struct nouveau_object *device = nouveau_drm(dev)->device; 204 struct nvif_device *device = &nouveau_drm(dev)->device;
205 nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); 205 nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
206 return !(nvif_rd08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20); 206 return !(nvif_rd08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20);
207} 207}
@@ -209,7 +209,7 @@ static inline bool NVGetEnablePalette(struct drm_device *dev, int head)
209static inline void NVWriteVgaAttr(struct drm_device *dev, 209static inline void NVWriteVgaAttr(struct drm_device *dev,
210 int head, uint8_t index, uint8_t value) 210 int head, uint8_t index, uint8_t value)
211{ 211{
212 struct nouveau_object *device = nouveau_drm(dev)->device; 212 struct nvif_device *device = &nouveau_drm(dev)->device;
213 if (NVGetEnablePalette(dev, head)) 213 if (NVGetEnablePalette(dev, head))
214 index &= ~0x20; 214 index &= ~0x20;
215 else 215 else
@@ -223,7 +223,7 @@ static inline void NVWriteVgaAttr(struct drm_device *dev,
223static inline uint8_t NVReadVgaAttr(struct drm_device *dev, 223static inline uint8_t NVReadVgaAttr(struct drm_device *dev,
224 int head, uint8_t index) 224 int head, uint8_t index)
225{ 225{
226 struct nouveau_object *device = nouveau_drm(dev)->device; 226 struct nvif_device *device = &nouveau_drm(dev)->device;
227 uint8_t val; 227 uint8_t val;
228 if (NVGetEnablePalette(dev, head)) 228 if (NVGetEnablePalette(dev, head))
229 index &= ~0x20; 229 index &= ~0x20;
@@ -259,10 +259,10 @@ static inline void NVVgaProtect(struct drm_device *dev, int head, bool protect)
259static inline bool 259static inline bool
260nv_heads_tied(struct drm_device *dev) 260nv_heads_tied(struct drm_device *dev)
261{ 261{
262 struct nouveau_object *device = nouveau_drm(dev)->device; 262 struct nvif_device *device = &nouveau_drm(dev)->device;
263 struct nouveau_drm *drm = nouveau_drm(dev); 263 struct nouveau_drm *drm = nouveau_drm(dev);
264 264
265 if (nv_device(drm->device)->chipset == 0x11) 265 if (drm->device.info.chipset == 0x11)
266 return !!(nvif_rd32(device, NV_PBUS_DEBUG_1) & (1 << 28)); 266 return !!(nvif_rd32(device, NV_PBUS_DEBUG_1) & (1 << 28));
267 267
268 return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4; 268 return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4;
@@ -318,7 +318,7 @@ NVLockVgaCrtcs(struct drm_device *dev, bool lock)
318 NVWriteVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX, 318 NVWriteVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX,
319 lock ? NV_CIO_SR_LOCK_VALUE : NV_CIO_SR_UNLOCK_RW_VALUE); 319 lock ? NV_CIO_SR_LOCK_VALUE : NV_CIO_SR_UNLOCK_RW_VALUE);
320 /* NV11 has independently lockable extended crtcs, except when tied */ 320 /* NV11 has independently lockable extended crtcs, except when tied */
321 if (nv_device(drm->device)->chipset == 0x11 && !nv_heads_tied(dev)) 321 if (drm->device.info.chipset == 0x11 && !nv_heads_tied(dev))
322 NVWriteVgaCrtc(dev, 1, NV_CIO_SR_LOCK_INDEX, 322 NVWriteVgaCrtc(dev, 1, NV_CIO_SR_LOCK_INDEX,
323 lock ? NV_CIO_SR_LOCK_VALUE : 323 lock ? NV_CIO_SR_LOCK_VALUE :
324 NV_CIO_SR_UNLOCK_RW_VALUE); 324 NV_CIO_SR_UNLOCK_RW_VALUE);
@@ -335,7 +335,7 @@ static inline int nv_cursor_width(struct drm_device *dev)
335{ 335{
336 struct nouveau_drm *drm = nouveau_drm(dev); 336 struct nouveau_drm *drm = nouveau_drm(dev);
337 337
338 return nv_device(drm->device)->card_type >= NV_10 ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE; 338 return drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE;
339} 339}
340 340
341static inline void 341static inline void
@@ -357,7 +357,7 @@ nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset)
357 357
358 NVWriteCRTC(dev, head, NV_PCRTC_START, offset); 358 NVWriteCRTC(dev, head, NV_PCRTC_START, offset);
359 359
360 if (nv_device(drm->device)->card_type == NV_04) { 360 if (drm->device.info.family == NV_DEVICE_INFO_V0_TNT) {
361 /* 361 /*
362 * Hilarious, the 24th bit doesn't want to stick to 362 * Hilarious, the 24th bit doesn't want to stick to
363 * PCRTC_START... 363 * PCRTC_START...
@@ -382,7 +382,7 @@ nv_show_cursor(struct drm_device *dev, int head, bool show)
382 *curctl1 &= ~MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE); 382 *curctl1 &= ~MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE);
383 NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HCUR_ADDR1_INDEX, *curctl1); 383 NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HCUR_ADDR1_INDEX, *curctl1);
384 384
385 if (nv_device(drm->device)->card_type == NV_40) 385 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE)
386 nv_fix_nv40_hw_cursor(dev, head); 386 nv_fix_nv40_hw_cursor(dev, head);
387} 387}
388 388
@@ -398,7 +398,7 @@ nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp)
398 bpp = 8; 398 bpp = 8;
399 399
400 /* Alignment requirements taken from the Haiku driver */ 400 /* Alignment requirements taken from the Haiku driver */
401 if (nv_device(drm->device)->card_type == NV_04) 401 if (drm->device.info.family == NV_DEVICE_INFO_V0_TNT)
402 mask = 128 / bpp - 1; 402 mask = 128 / bpp - 1;
403 else 403 else
404 mask = 512 / bpp - 1; 404 mask = 512 / bpp - 1;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
index bae8068b897f..b36afcbbc83f 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
@@ -96,7 +96,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
96 uint32_t src_x, uint32_t src_y, 96 uint32_t src_x, uint32_t src_y,
97 uint32_t src_w, uint32_t src_h) 97 uint32_t src_w, uint32_t src_h)
98{ 98{
99 struct nouveau_object *dev = nouveau_drm(plane->dev)->device; 99 struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
100 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; 100 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
101 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); 101 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
102 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 102 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
@@ -117,7 +117,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
117 if (format > 0xffff) 117 if (format > 0xffff)
118 return -ERANGE; 118 return -ERANGE;
119 119
120 if (nv_device(dev)->chipset >= 0x30) { 120 if (dev->info.chipset >= 0x30) {
121 if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1)) 121 if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1))
122 return -ERANGE; 122 return -ERANGE;
123 } else { 123 } else {
@@ -172,7 +172,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
172static int 172static int
173nv10_disable_plane(struct drm_plane *plane) 173nv10_disable_plane(struct drm_plane *plane)
174{ 174{
175 struct nouveau_object *dev = nouveau_drm(plane->dev)->device; 175 struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
176 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; 176 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
177 177
178 nvif_wr32(dev, NV_PVIDEO_STOP, 1); 178 nvif_wr32(dev, NV_PVIDEO_STOP, 1);
@@ -195,7 +195,7 @@ nv_destroy_plane(struct drm_plane *plane)
195static void 195static void
196nv10_set_params(struct nouveau_plane *plane) 196nv10_set_params(struct nouveau_plane *plane)
197{ 197{
198 struct nouveau_object *dev = nouveau_drm(plane->base.dev)->device; 198 struct nvif_device *dev = &nouveau_drm(plane->base.dev)->device;
199 u32 luma = (plane->brightness - 512) << 16 | plane->contrast; 199 u32 luma = (plane->brightness - 512) << 16 | plane->contrast;
200 u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) | 200 u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) |
201 (cos_mul(plane->hue, plane->saturation) & 0xffff); 201 (cos_mul(plane->hue, plane->saturation) & 0xffff);
@@ -264,7 +264,7 @@ nv10_overlay_init(struct drm_device *device)
264 if (!plane) 264 if (!plane)
265 return; 265 return;
266 266
267 switch (nv_device(drm->device)->chipset) { 267 switch (drm->device.info.chipset) {
268 case 0x10: 268 case 0x10:
269 case 0x11: 269 case 0x11:
270 case 0x15: 270 case 0x15:
@@ -343,7 +343,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
343 uint32_t src_x, uint32_t src_y, 343 uint32_t src_x, uint32_t src_y,
344 uint32_t src_w, uint32_t src_h) 344 uint32_t src_w, uint32_t src_h)
345{ 345{
346 struct nouveau_object *dev = nouveau_drm(plane->dev)->device; 346 struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
347 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; 347 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
348 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); 348 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
349 struct nouveau_bo *cur = nv_plane->cur; 349 struct nouveau_bo *cur = nv_plane->cur;
@@ -422,7 +422,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
422static int 422static int
423nv04_disable_plane(struct drm_plane *plane) 423nv04_disable_plane(struct drm_plane *plane)
424{ 424{
425 struct nouveau_object *dev = nouveau_drm(plane->dev)->device; 425 struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
426 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; 426 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
427 427
428 nvif_mask(dev, NV_PVIDEO_OVERLAY, 1, 0); 428 nvif_mask(dev, NV_PVIDEO_OVERLAY, 1, 0);
@@ -489,9 +489,9 @@ err:
489void 489void
490nouveau_overlay_init(struct drm_device *device) 490nouveau_overlay_init(struct drm_device *device)
491{ 491{
492 struct nouveau_object *dev = nouveau_drm(device)->device; 492 struct nvif_device *dev = &nouveau_drm(device)->device;
493 if (nv_device(dev)->chipset < 0x10) 493 if (dev->info.chipset < 0x10)
494 nv04_overlay_init(device); 494 nv04_overlay_init(device);
495 else if (nv_device(dev)->chipset <= 0x40) 495 else if (dev->info.chipset <= 0x40)
496 nv10_overlay_init(device); 496 nv10_overlay_init(device);
497} 497}
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c
index 8667620b703a..1ed54c9b5a49 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c
@@ -56,7 +56,7 @@ static struct nouveau_i2c_board_info nv04_tv_encoder_info[] = {
56int nv04_tv_identify(struct drm_device *dev, int i2c_index) 56int nv04_tv_identify(struct drm_device *dev, int i2c_index)
57{ 57{
58 struct nouveau_drm *drm = nouveau_drm(dev); 58 struct nouveau_drm *drm = nouveau_drm(dev);
59 struct nouveau_i2c *i2c = nouveau_i2c(drm->device); 59 struct nouveau_i2c *i2c = nvkm_i2c(&drm->device);
60 60
61 return i2c->identify(i2c, i2c_index, "TV encoder", 61 return i2c->identify(i2c, i2c_index, "TV encoder",
62 nv04_tv_encoder_info, NULL, NULL); 62 nv04_tv_encoder_info, NULL, NULL);
@@ -206,7 +206,7 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry)
206 struct drm_encoder *encoder; 206 struct drm_encoder *encoder;
207 struct drm_device *dev = connector->dev; 207 struct drm_device *dev = connector->dev;
208 struct nouveau_drm *drm = nouveau_drm(dev); 208 struct nouveau_drm *drm = nouveau_drm(dev);
209 struct nouveau_i2c *i2c = nouveau_i2c(drm->device); 209 struct nouveau_i2c *i2c = nvkm_i2c(&drm->device);
210 struct nouveau_i2c_port *port = i2c->find(i2c, entry->i2c_index); 210 struct nouveau_i2c_port *port = i2c->find(i2c, entry->i2c_index);
211 int type, ret; 211 int type, ret;
212 212
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
index 195bd8e86c6a..28975b732c6a 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
@@ -51,7 +51,7 @@ static uint32_t nv42_tv_sample_load(struct drm_encoder *encoder)
51{ 51{
52 struct drm_device *dev = encoder->dev; 52 struct drm_device *dev = encoder->dev;
53 struct nouveau_drm *drm = nouveau_drm(dev); 53 struct nouveau_drm *drm = nouveau_drm(dev);
54 struct nouveau_gpio *gpio = nouveau_gpio(drm->device); 54 struct nouveau_gpio *gpio = nvkm_gpio(&drm->device);
55 uint32_t testval, regoffset = nv04_dac_output_offset(encoder); 55 uint32_t testval, regoffset = nv04_dac_output_offset(encoder);
56 uint32_t gpio0, gpio1, fp_htotal, fp_hsync_start, fp_hsync_end, 56 uint32_t gpio0, gpio1, fp_htotal, fp_hsync_start, fp_hsync_end,
57 fp_control, test_ctrl, dacclk, ctv_14, ctv_1c, ctv_6c; 57 fp_control, test_ctrl, dacclk, ctv_14, ctv_1c, ctv_6c;
@@ -135,17 +135,17 @@ static bool
135get_tv_detect_quirks(struct drm_device *dev, uint32_t *pin_mask) 135get_tv_detect_quirks(struct drm_device *dev, uint32_t *pin_mask)
136{ 136{
137 struct nouveau_drm *drm = nouveau_drm(dev); 137 struct nouveau_drm *drm = nouveau_drm(dev);
138 struct nouveau_object *device = drm->device; 138 struct nvif_device *device = &drm->device;
139 139
140 /* Zotac FX5200 */ 140 /* Zotac FX5200 */
141 if (nv_device_match(device, 0x0322, 0x19da, 0x1035) || 141 if (nv_device_match(nvkm_object(device), 0x0322, 0x19da, 0x1035) ||
142 nv_device_match(device, 0x0322, 0x19da, 0x2035)) { 142 nv_device_match(nvkm_object(device), 0x0322, 0x19da, 0x2035)) {
143 *pin_mask = 0xc; 143 *pin_mask = 0xc;
144 return false; 144 return false;
145 } 145 }
146 146
147 /* MSI nForce2 IGP */ 147 /* MSI nForce2 IGP */
148 if (nv_device_match(device, 0x01f0, 0x1462, 0x5710)) { 148 if (nv_device_match(nvkm_object(device), 0x01f0, 0x1462, 0x5710)) {
149 *pin_mask = 0xc; 149 *pin_mask = 0xc;
150 return false; 150 return false;
151 } 151 }
@@ -167,8 +167,8 @@ nv17_tv_detect(struct drm_encoder *encoder, struct drm_connector *connector)
167 return connector_status_disconnected; 167 return connector_status_disconnected;
168 168
169 if (reliable) { 169 if (reliable) {
170 if (nv_device(drm->device)->chipset == 0x42 || 170 if (drm->device.info.chipset == 0x42 ||
171 nv_device(drm->device)->chipset == 0x43) 171 drm->device.info.chipset == 0x43)
172 tv_enc->pin_mask = 172 tv_enc->pin_mask =
173 nv42_tv_sample_load(encoder) >> 28 & 0xe; 173 nv42_tv_sample_load(encoder) >> 28 & 0xe;
174 else 174 else
@@ -375,7 +375,7 @@ static void nv17_tv_dpms(struct drm_encoder *encoder, int mode)
375{ 375{
376 struct drm_device *dev = encoder->dev; 376 struct drm_device *dev = encoder->dev;
377 struct nouveau_drm *drm = nouveau_drm(dev); 377 struct nouveau_drm *drm = nouveau_drm(dev);
378 struct nouveau_gpio *gpio = nouveau_gpio(drm->device); 378 struct nouveau_gpio *gpio = nvkm_gpio(&drm->device);
379 struct nv17_tv_state *regs = &to_tv_enc(encoder)->state; 379 struct nv17_tv_state *regs = &to_tv_enc(encoder)->state;
380 struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder); 380 struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder);
381 381
@@ -448,7 +448,7 @@ static void nv17_tv_prepare(struct drm_encoder *encoder)
448 /* Set the DACCLK register */ 448 /* Set the DACCLK register */
449 dacclk = (NVReadRAMDAC(dev, 0, dacclk_off) & ~0x30) | 0x1; 449 dacclk = (NVReadRAMDAC(dev, 0, dacclk_off) & ~0x30) | 0x1;
450 450
451 if (nv_device(drm->device)->card_type == NV_40) 451 if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE)
452 dacclk |= 0x1a << 16; 452 dacclk |= 0x1a << 16;
453 453
454 if (tv_norm->kind == CTV_ENC_MODE) { 454 if (tv_norm->kind == CTV_ENC_MODE) {
@@ -505,7 +505,7 @@ static void nv17_tv_mode_set(struct drm_encoder *encoder,
505 tv_regs->ptv_614 = 0x13; 505 tv_regs->ptv_614 = 0x13;
506 } 506 }
507 507
508 if (nv_device(drm->device)->card_type >= NV_30) { 508 if (drm->device.info.family >= NV_DEVICE_INFO_V0_RANKINE) {
509 tv_regs->ptv_500 = 0xe8e0; 509 tv_regs->ptv_500 = 0xe8e0;
510 tv_regs->ptv_504 = 0x1710; 510 tv_regs->ptv_504 = 0x1710;
511 tv_regs->ptv_604 = 0x0; 511 tv_regs->ptv_604 = 0x0;
@@ -600,7 +600,7 @@ static void nv17_tv_commit(struct drm_encoder *encoder)
600 nv17_tv_state_load(dev, &to_tv_enc(encoder)->state); 600 nv17_tv_state_load(dev, &to_tv_enc(encoder)->state);
601 601
602 /* This could use refinement for flatpanels, but it should work */ 602 /* This could use refinement for flatpanels, but it should work */
603 if (nv_device(drm->device)->chipset < 0x44) 603 if (drm->device.info.chipset < 0x44)
604 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + 604 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL +
605 nv04_dac_output_offset(encoder), 605 nv04_dac_output_offset(encoder),
606 0xf0000000); 606 0xf0000000);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h
index ce40e398f895..225894cdcac2 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h
@@ -130,13 +130,13 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder);
130static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg, 130static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg,
131 uint32_t val) 131 uint32_t val)
132{ 132{
133 struct nouveau_object *device = nouveau_drm(dev)->device; 133 struct nvif_device *device = &nouveau_drm(dev)->device;
134 nvif_wr32(device, reg, val); 134 nvif_wr32(device, reg, val);
135} 135}
136 136
137static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg) 137static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg)
138{ 138{
139 struct nouveau_object *device = nouveau_drm(dev)->device; 139 struct nvif_device *device = &nouveau_drm(dev)->device;
140 return nvif_rd32(device, reg); 140 return nvif_rd32(device, reg);
141} 141}
142 142