Commit d8f266a3 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/bios: switch to device pri macros

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 9155c162
...@@ -180,27 +180,30 @@ init_nvreg(struct nvbios_init *init, u32 reg) ...@@ -180,27 +180,30 @@ init_nvreg(struct nvbios_init *init, u32 reg)
static u32 static u32
init_rd32(struct nvbios_init *init, u32 reg) init_rd32(struct nvbios_init *init, u32 reg)
{ {
struct nvkm_device *device = init->bios->subdev.device;
reg = init_nvreg(init, reg); reg = init_nvreg(init, reg);
if (reg != ~0 && init_exec(init)) if (reg != ~0 && init_exec(init))
return nv_rd32(init->subdev, reg); return nvkm_rd32(device, reg);
return 0x00000000; return 0x00000000;
} }
static void static void
init_wr32(struct nvbios_init *init, u32 reg, u32 val) init_wr32(struct nvbios_init *init, u32 reg, u32 val)
{ {
struct nvkm_device *device = init->bios->subdev.device;
reg = init_nvreg(init, reg); reg = init_nvreg(init, reg);
if (reg != ~0 && init_exec(init)) if (reg != ~0 && init_exec(init))
nv_wr32(init->subdev, reg, val); nvkm_wr32(device, reg, val);
} }
static u32 static u32
init_mask(struct nvbios_init *init, u32 reg, u32 mask, u32 val) init_mask(struct nvbios_init *init, u32 reg, u32 mask, u32 val)
{ {
struct nvkm_device *device = init->bios->subdev.device;
reg = init_nvreg(init, reg); reg = init_nvreg(init, reg);
if (reg != ~0 && init_exec(init)) { if (reg != ~0 && init_exec(init)) {
u32 tmp = nv_rd32(init->subdev, reg); u32 tmp = nvkm_rd32(device, reg);
nv_wr32(init->subdev, reg, (tmp & ~mask) | val); nvkm_wr32(device, reg, (tmp & ~mask) | val);
return tmp; return tmp;
} }
return 0x00000000; return 0x00000000;
......
...@@ -221,6 +221,7 @@ pll_map_type(struct nvkm_bios *bios, u8 type, u32 *reg, u8 *ver, u8 *len) ...@@ -221,6 +221,7 @@ pll_map_type(struct nvkm_bios *bios, u8 type, u32 *reg, u8 *ver, u8 *len)
int int
nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info) nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info)
{ {
struct nvkm_device *device = bios->subdev.device;
u8 ver, len; u8 ver, len;
u32 reg = type; u32 reg = type;
u16 data; u16 data;
...@@ -360,9 +361,9 @@ nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info) ...@@ -360,9 +361,9 @@ nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info)
} }
if (!info->refclk) { if (!info->refclk) {
info->refclk = nv_device(bios)->crystal; info->refclk = device->crystal;
if (bios->version.chip == 0x51) { if (bios->version.chip == 0x51) {
u32 sel_clk = nv_rd32(bios, 0x680524); u32 sel_clk = nvkm_rd32(device, 0x680524);
if ((info->reg == 0x680508 && sel_clk & 0x20) || if ((info->reg == 0x680508 && sel_clk & 0x20) ||
(info->reg == 0x680520 && sel_clk & 0x80)) { (info->reg == 0x680520 && sel_clk & 0x80)) {
if (nv_rdvgac(bios, 0, 0x27) < 0xa3) if (nv_rdvgac(bios, 0, 0x27) < 0xa3)
...@@ -392,7 +393,7 @@ nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info) ...@@ -392,7 +393,7 @@ nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info)
info->vco1.max_n = 0xff; info->vco1.max_n = 0xff;
info->vco1.min_m = 0x1; info->vco1.min_m = 0x1;
if (nv_device(bios)->crystal == 13500) { if (device->crystal == 13500) {
/* nv05 does this, nv11 doesn't, nv10 unknown */ /* nv05 does this, nv11 doesn't, nv10 unknown */
if (bios->version.chip < 0x11) if (bios->version.chip < 0x11)
info->vco1.min_m = 0x7; info->vco1.min_m = 0x7;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
static u8 static u8
nvbios_ramcfg_strap(struct nvkm_subdev *subdev) nvbios_ramcfg_strap(struct nvkm_subdev *subdev)
{ {
return (nv_rd32(subdev, 0x101000) & 0x0000003c) >> 2; return (nvkm_rd32(subdev->device, 0x101000) & 0x0000003c) >> 2;
} }
u8 u8
......
...@@ -30,10 +30,11 @@ struct priv { ...@@ -30,10 +30,11 @@ struct priv {
static u32 static u32
pramin_read(void *data, u32 offset, u32 length, struct nvkm_bios *bios) pramin_read(void *data, u32 offset, u32 length, struct nvkm_bios *bios)
{ {
struct nvkm_device *device = bios->subdev.device;
u32 i; u32 i;
if (offset + length <= 0x00100000) { if (offset + length <= 0x00100000) {
for (i = offset; i < offset + length; i += 4) for (i = offset; i < offset + length; i += 4)
*(u32 *)&bios->data[i] = nv_rd32(bios, 0x700000 + i); *(u32 *)&bios->data[i] = nvkm_rd32(device, 0x700000 + i);
return length; return length;
} }
return 0; return 0;
...@@ -44,7 +45,8 @@ pramin_fini(void *data) ...@@ -44,7 +45,8 @@ pramin_fini(void *data)
{ {
struct priv *priv = data; struct priv *priv = data;
if (priv) { if (priv) {
nv_wr32(priv->bios, 0x001700, priv->bar0); struct nvkm_device *device = priv->bios->subdev.device;
nvkm_wr32(device, 0x001700, priv->bar0);
kfree(priv); kfree(priv);
} }
} }
...@@ -52,19 +54,20 @@ pramin_fini(void *data) ...@@ -52,19 +54,20 @@ pramin_fini(void *data)
static void * static void *
pramin_init(struct nvkm_bios *bios, const char *name) pramin_init(struct nvkm_bios *bios, const char *name)
{ {
struct nvkm_device *device = bios->subdev.device;
struct priv *priv = NULL; struct priv *priv = NULL;
u64 addr = 0; u64 addr = 0;
/* PRAMIN always potentially available prior to nv50 */ /* PRAMIN always potentially available prior to nv50 */
if (nv_device(bios)->card_type < NV_50) if (device->card_type < NV_50)
return NULL; return NULL;
/* we can't get the bios image pointer without PDISP */ /* we can't get the bios image pointer without PDISP */
if (nv_device(bios)->card_type >= GM100) if (device->card_type >= GM100)
addr = nv_rd32(bios, 0x021c04); addr = nvkm_rd32(device, 0x021c04);
else else
if (nv_device(bios)->card_type >= NV_C0) if (device->card_type >= NV_C0)
addr = nv_rd32(bios, 0x022500); addr = nvkm_rd32(device, 0x022500);
if (addr & 0x00000001) { if (addr & 0x00000001) {
nv_debug(bios, "... display disabled\n"); nv_debug(bios, "... display disabled\n");
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
...@@ -74,7 +77,7 @@ pramin_init(struct nvkm_bios *bios, const char *name) ...@@ -74,7 +77,7 @@ pramin_init(struct nvkm_bios *bios, const char *name)
* important as we don't want to be touching vram on an * important as we don't want to be touching vram on an
* uninitialised board * uninitialised board
*/ */
addr = nv_rd32(bios, 0x619f04); addr = nvkm_rd32(device, 0x619f04);
if (!(addr & 0x00000008)) { if (!(addr & 0x00000008)) {
nv_debug(bios, "... not enabled\n"); nv_debug(bios, "... not enabled\n");
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
...@@ -87,7 +90,7 @@ pramin_init(struct nvkm_bios *bios, const char *name) ...@@ -87,7 +90,7 @@ pramin_init(struct nvkm_bios *bios, const char *name)
/* some alternate method inherited from xf86-video-nv... */ /* some alternate method inherited from xf86-video-nv... */
addr = (addr & 0xffffff00) << 8; addr = (addr & 0xffffff00) << 8;
if (!addr) { if (!addr) {
addr = (u64)nv_rd32(bios, 0x001700) << 16; addr = (u64)nvkm_rd32(device, 0x001700) << 16;
addr += 0xf0000; addr += 0xf0000;
} }
...@@ -98,8 +101,8 @@ pramin_init(struct nvkm_bios *bios, const char *name) ...@@ -98,8 +101,8 @@ pramin_init(struct nvkm_bios *bios, const char *name)
} }
priv->bios = bios; priv->bios = bios;
priv->bar0 = nv_rd32(bios, 0x001700); priv->bar0 = nvkm_rd32(device, 0x001700);
nv_wr32(bios, 0x001700, addr >> 16); nvkm_wr32(device, 0x001700, addr >> 16);
return priv; return priv;
} }
......
...@@ -25,10 +25,11 @@ ...@@ -25,10 +25,11 @@
static u32 static u32
prom_read(void *data, u32 offset, u32 length, struct nvkm_bios *bios) prom_read(void *data, u32 offset, u32 length, struct nvkm_bios *bios)
{ {
struct nvkm_device *device = data;
u32 i; u32 i;
if (offset + length <= 0x00100000) { if (offset + length <= 0x00100000) {
for (i = offset; i < offset + length; i += 4) for (i = offset; i < offset + length; i += 4)
*(u32 *)&bios->data[i] = nv_rd32(bios, 0x300000 + i); *(u32 *)&bios->data[i] = nvkm_rd32(device, 0x300000 + i);
return length; return length;
} }
return 0; return 0;
...@@ -37,25 +38,25 @@ prom_read(void *data, u32 offset, u32 length, struct nvkm_bios *bios) ...@@ -37,25 +38,25 @@ prom_read(void *data, u32 offset, u32 length, struct nvkm_bios *bios)
static void static void
prom_fini(void *data) prom_fini(void *data)
{ {
struct nvkm_bios *bios = data; struct nvkm_device *device = data;
if (nv_device(bios)->card_type < NV_50) if (device->card_type < NV_50)
nv_mask(bios, 0x001850, 0x00000001, 0x00000001); nvkm_mask(device, 0x001850, 0x00000001, 0x00000001);
else else
nv_mask(bios, 0x088050, 0x00000001, 0x00000001); nvkm_mask(device, 0x088050, 0x00000001, 0x00000001);
} }
static void * static void *
prom_init(struct nvkm_bios *bios, const char *name) prom_init(struct nvkm_bios *bios, const char *name)
{ {
if (nv_device(bios)->card_type < NV_50) { struct nvkm_device *device = bios->subdev.device;
if (nv_device(bios)->card_type == NV_40 && if (device->card_type < NV_50) {
nv_device(bios)->chipset >= 0x4c) if (device->card_type == NV_40 && device->chipset >= 0x4c)
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
nv_mask(bios, 0x001850, 0x00000001, 0x00000000); nvkm_mask(device, 0x001850, 0x00000001, 0x00000000);
} else { } else {
nv_mask(bios, 0x088050, 0x00000001, 0x00000000); nvkm_mask(device, 0x088050, 0x00000001, 0x00000000);
} }
return bios; return device;
} }
const struct nvbios_source const struct nvbios_source
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment