0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "nv50.h"
0025
0026 #include <subdev/bios.h>
0027 #include <subdev/bios/init.h>
0028 #include <subdev/bios/pll.h>
0029 #include <subdev/clk/pll.h>
0030
0031 int
0032 gf100_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
0033 {
0034 struct nvkm_subdev *subdev = &init->subdev;
0035 struct nvkm_device *device = subdev->device;
0036 struct nvbios_pll info;
0037 int N, fN, M, P;
0038 int ret;
0039
0040 ret = nvbios_pll_parse(device->bios, type, &info);
0041 if (ret)
0042 return ret;
0043
0044 ret = gt215_pll_calc(subdev, &info, freq, &N, &fN, &M, &P);
0045 if (ret < 0)
0046 return ret;
0047
0048 switch (info.type) {
0049 case PLL_VPLL0:
0050 case PLL_VPLL1:
0051 case PLL_VPLL2:
0052 case PLL_VPLL3:
0053 nvkm_mask(device, info.reg + 0x0c, 0x00000000, 0x00000100);
0054 nvkm_wr32(device, info.reg + 0x04, (P << 16) | (N << 8) | M);
0055 nvkm_wr32(device, info.reg + 0x10, fN << 16);
0056 break;
0057 default:
0058 nvkm_warn(subdev, "%08x/%dKhz unimplemented\n", type, freq);
0059 ret = -EINVAL;
0060 break;
0061 }
0062
0063 return ret;
0064 }
0065
0066 static u64
0067 gf100_devinit_disable(struct nvkm_devinit *init)
0068 {
0069 struct nvkm_device *device = init->subdev.device;
0070 u32 r022500 = nvkm_rd32(device, 0x022500);
0071
0072 if (r022500 & 0x00000001)
0073 nvkm_subdev_disable(device, NVKM_ENGINE_DISP, 0);
0074
0075 if (r022500 & 0x00000002) {
0076 nvkm_subdev_disable(device, NVKM_ENGINE_MSPDEC, 0);
0077 nvkm_subdev_disable(device, NVKM_ENGINE_MSPPP, 0);
0078 }
0079
0080 if (r022500 & 0x00000004)
0081 nvkm_subdev_disable(device, NVKM_ENGINE_MSVLD, 0);
0082 if (r022500 & 0x00000008)
0083 nvkm_subdev_disable(device, NVKM_ENGINE_MSENC, 0);
0084 if (r022500 & 0x00000100)
0085 nvkm_subdev_disable(device, NVKM_ENGINE_CE, 0);
0086 if (r022500 & 0x00000200)
0087 nvkm_subdev_disable(device, NVKM_ENGINE_CE, 1);
0088
0089 return 0ULL;
0090 }
0091
0092 void
0093 gf100_devinit_preinit(struct nvkm_devinit *base)
0094 {
0095 struct nv50_devinit *init = nv50_devinit(base);
0096 struct nvkm_subdev *subdev = &init->base.subdev;
0097 struct nvkm_device *device = subdev->device;
0098
0099
0100
0101
0102
0103 base->post = ((nvkm_rd32(device, 0x2240c) & BIT(1)) == 0);
0104 }
0105
0106 static const struct nvkm_devinit_func
0107 gf100_devinit = {
0108 .preinit = gf100_devinit_preinit,
0109 .init = nv50_devinit_init,
0110 .post = nv04_devinit_post,
0111 .pll_set = gf100_devinit_pll_set,
0112 .disable = gf100_devinit_disable,
0113 };
0114
0115 int
0116 gf100_devinit_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0117 struct nvkm_devinit **pinit)
0118 {
0119 return nv50_devinit_new_(&gf100_devinit, device, type, inst, pinit);
0120 }