int _gk20a_volt_ctor(struct nvkm_device *device, int index, const struct cvb_coef *coefs, int nb_coefs, struct gk20a_volt *volt) { struct nvkm_device_tegra *tdev = device->func->tegra(device); int i, uv; nvkm_volt_ctor(&gk20a_volt, device, index, &volt->base); uv = regulator_get_voltage(tdev->vdd); nvkm_debug(&volt->base.subdev, "the default voltage is %duV\n", uv); volt->vdd = tdev->vdd; volt->base.vid_nr = nb_coefs; for (i = 0; i < volt->base.vid_nr; i++) { volt->base.vid[i].vid = i; volt->base.vid[i].uv = gk20a_volt_calc_voltage(&coefs[i], tdev->gpu_speedo); nvkm_debug(&volt->base.subdev, "%2d: vid=%d, uv=%d\n", i, volt->base.vid[i].vid, volt->base.vid[i].uv); } return 0; }
int gk20a_volt_new(struct nvkm_device *device, int index, struct nvkm_volt **pvolt) { struct nvkm_device_tegra *tdev = device->func->tegra(device); struct gk20a_volt *volt; int i, uv; if (!(volt = kzalloc(sizeof(*volt), GFP_KERNEL))) return -ENOMEM; nvkm_volt_ctor(&gk20a_volt, device, index, &volt->base); *pvolt = &volt->base; uv = regulator_get_voltage(tdev->vdd); nvkm_info(&volt->base.subdev, "The default voltage is %duV\n", uv); volt->vdd = tdev->vdd; volt->base.vid_nr = ARRAY_SIZE(gk20a_cvb_coef); nvkm_debug(&volt->base.subdev, "%s - vid_nr = %d\n", __func__, volt->base.vid_nr); for (i = 0; i < volt->base.vid_nr; i++) { volt->base.vid[i].vid = i; volt->base.vid[i].uv = gk20a_volt_calc_voltage(&gk20a_cvb_coef[i], tdev->gpu_speedo); nvkm_debug(&volt->base.subdev, "%2d: vid=%d, uv=%d\n", i, volt->base.vid[i].vid, volt->base.vid[i].uv); } return 0; }
int gk104_volt_new(struct nvkm_device *device, int index, struct nvkm_volt **pvolt) { const struct nvkm_volt_func *volt_func = &gk104_volt_gpio; struct dcb_gpio_func gpio; struct nvbios_volt bios; struct gk104_volt *volt; u8 ver, hdr, cnt, len; const char *mode; if (!nvbios_volt_parse(device->bios, &ver, &hdr, &cnt, &len, &bios)) return 0; if (!nvkm_gpio_find(device->gpio, 0, DCB_GPIO_VID_PWM, 0xff, &gpio) && bios.type == NVBIOS_VOLT_PWM) { volt_func = &gk104_volt_pwm; } if (!(volt = kzalloc(sizeof(*volt), GFP_KERNEL))) return -ENOMEM; nvkm_volt_ctor(volt_func, device, index, &volt->base); *pvolt = &volt->base; volt->bios = bios; /* now that we have a subdev, we can show an error if we found through * the voltage table that we were supposed to use the PWN mode but we * did not find the right GPIO for it. */ if (bios.type == NVBIOS_VOLT_PWM && volt_func != &gk104_volt_pwm) { nvkm_error(&volt->base.subdev, "Type mismatch between the voltage table type and " "the GPIO table. Fallback to GPIO mode.\n"); } if (volt_func == &gk104_volt_gpio) { nvkm_voltgpio_init(&volt->base); mode = "GPIO"; } else mode = "PWM"; nvkm_debug(&volt->base.subdev, "Using %s mode\n", mode); return 0; }