Loading drivers/gpu/drm/nouveau/Makefile +2 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,8 @@ nouveau-y += core/subdev/mxm/mxms.o nouveau-y += core/subdev/mxm/nv50.o nouveau-y += core/subdev/therm/base.o nouveau-y += core/subdev/therm/fan.o nouveau-y += core/subdev/therm/fannil.o nouveau-y += core/subdev/therm/fanpwm.o nouveau-y += core/subdev/therm/ic.o nouveau-y += core/subdev/therm/temp.o nouveau-y += core/subdev/therm/nv40.o Loading drivers/gpu/drm/nouveau/core/include/subdev/therm.h +14 −8 Original line number Diff line number Diff line Loading @@ -28,6 +28,11 @@ enum nouveau_therm_attr_type { struct nouveau_therm { struct nouveau_subdev base; int (*pwm_ctrl)(struct nouveau_therm *, int line, bool); int (*pwm_get)(struct nouveau_therm *, int line, u32 *, u32 *); int (*pwm_set)(struct nouveau_therm *, int line, u32, u32); int (*pwm_clock)(struct nouveau_therm *); int (*fan_get)(struct nouveau_therm *); int (*fan_set)(struct nouveau_therm *, int); int (*fan_sense)(struct nouveau_therm *); Loading @@ -47,8 +52,10 @@ nouveau_therm(void *obj) #define nouveau_therm_create(p,e,o,d) \ nouveau_therm_create_((p), (e), (o), sizeof(**d), (void **)d) #define nouveau_therm_destroy(p) \ nouveau_subdev_destroy(&(p)->base) #define nouveau_therm_destroy(p) ({ \ struct nouveau_therm *therm = (p); \ _nouveau_therm_dtor(nv_object(therm)); \ }) #define nouveau_therm_init(p) ({ \ struct nouveau_therm *therm = (p); \ _nouveau_therm_init(nv_object(therm)); \ Loading @@ -60,8 +67,7 @@ nouveau_therm(void *obj) int nouveau_therm_create_(struct nouveau_object *, struct nouveau_object *, struct nouveau_oclass *, int, void **); #define _nouveau_therm_dtor _nouveau_subdev_dtor void _nouveau_therm_dtor(struct nouveau_object *); int _nouveau_therm_init(struct nouveau_object *); int _nouveau_therm_fini(struct nouveau_object *, bool); Loading drivers/gpu/drm/nouveau/core/subdev/therm/base.c +29 −16 Original line number Diff line number Diff line Loading @@ -37,11 +37,11 @@ nouveau_therm_attr_get(struct nouveau_therm *therm, switch (type) { case NOUVEAU_THERM_ATTR_FAN_MIN_DUTY: return priv->bios_fan.min_duty; return priv->fan->bios.min_duty; case NOUVEAU_THERM_ATTR_FAN_MAX_DUTY: return priv->bios_fan.max_duty; return priv->fan->bios.max_duty; case NOUVEAU_THERM_ATTR_FAN_MODE: return priv->fan.mode; return priv->fan->mode; case NOUVEAU_THERM_ATTR_THRS_FAN_BOOST: return priv->bios_sensor.thrs_fan_boost.temp; case NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST: Loading Loading @@ -73,16 +73,16 @@ nouveau_therm_attr_set(struct nouveau_therm *therm, case NOUVEAU_THERM_ATTR_FAN_MIN_DUTY: if (value < 0) value = 0; if (value > priv->bios_fan.max_duty) value = priv->bios_fan.max_duty; priv->bios_fan.min_duty = value; if (value > priv->fan->bios.max_duty) value = priv->fan->bios.max_duty; priv->fan->bios.min_duty = value; return 0; case NOUVEAU_THERM_ATTR_FAN_MAX_DUTY: if (value < 0) value = 0; if (value < priv->bios_fan.min_duty) value = priv->bios_fan.min_duty; priv->bios_fan.max_duty = value; if (value < priv->fan->bios.min_duty) value = priv->fan->bios.min_duty; priv->fan->bios.max_duty = value; return 0; case NOUVEAU_THERM_ATTR_FAN_MODE: return nouveau_therm_fan_set_mode(therm, value); Loading Loading @@ -126,8 +126,8 @@ _nouveau_therm_init(struct nouveau_object *object) if (ret) return ret; if (priv->fan.percent >= 0) therm->fan_set(therm, priv->fan.percent); if (priv->fan->percent >= 0) therm->fan_set(therm, priv->fan->percent); return 0; } Loading @@ -138,7 +138,7 @@ _nouveau_therm_fini(struct nouveau_object *object, bool suspend) struct nouveau_therm *therm = (void *)object; struct nouveau_therm_priv *priv = (void *)therm; priv->fan.percent = therm->fan_get(therm); priv->fan->percent = therm->fan_get(therm); return nouveau_subdev_fini(&therm->base, suspend); } Loading @@ -158,10 +158,6 @@ nouveau_therm_create_(struct nouveau_object *parent, if (ret) return ret; nouveau_therm_ic_ctor(&priv->base); nouveau_therm_sensor_ctor(&priv->base); nouveau_therm_fan_ctor(&priv->base); priv->base.fan_get = nouveau_therm_fan_user_get; priv->base.fan_set = nouveau_therm_fan_user_set; priv->base.fan_sense = nouveau_therm_fan_sense; Loading @@ -169,3 +165,20 @@ nouveau_therm_create_(struct nouveau_object *parent, priv->base.attr_set = nouveau_therm_attr_set; return 0; } int nouveau_therm_preinit(struct nouveau_therm *therm) { nouveau_therm_ic_ctor(therm); nouveau_therm_sensor_ctor(therm); nouveau_therm_fan_ctor(therm); return 0; } void _nouveau_therm_dtor(struct nouveau_object *object) { struct nouveau_therm_priv *priv = (void *)object; kfree(priv->fan); nouveau_subdev_destroy(&priv->base.base); } drivers/gpu/drm/nouveau/core/subdev/therm/fan.c +41 −77 Original line number Diff line number Diff line Loading @@ -35,73 +35,23 @@ int nouveau_therm_fan_get(struct nouveau_therm *therm) { struct nouveau_therm_priv *priv = (void *)therm; struct nouveau_gpio *gpio = nouveau_gpio(therm); struct dcb_gpio_func func; int card_type = nv_device(therm)->card_type; u32 divs, duty; int ret; if (!priv->fan.pwm_get) return -ENODEV; ret = gpio->find(gpio, 0, DCB_GPIO_PWM_FAN, 0xff, &func); if (ret == 0) { ret = priv->fan.pwm_get(therm, func.line, &divs, &duty); if (ret == 0 && divs) { divs = max(divs, duty); if (card_type <= NV_40 || (func.log[0] & 1)) duty = divs - duty; return (duty * 100) / divs; } return gpio->get(gpio, 0, func.func, func.line) * 100; } return -ENODEV; return priv->fan->get(therm); } int nouveau_therm_fan_set(struct nouveau_therm *therm, int percent) { struct nouveau_therm_priv *priv = (void *)therm; struct nouveau_gpio *gpio = nouveau_gpio(therm); struct dcb_gpio_func func; int card_type = nv_device(therm)->card_type; u32 divs, duty; int ret; if (priv->fan.mode == FAN_CONTROL_NONE) return -EINVAL; if (!priv->fan.pwm_set) return -ENODEV; if (percent < priv->bios_fan.min_duty) percent = priv->bios_fan.min_duty; if (percent > priv->bios_fan.max_duty) percent = priv->bios_fan.max_duty; ret = gpio->find(gpio, 0, DCB_GPIO_PWM_FAN, 0xff, &func); if (ret == 0) { divs = priv->bios_perf_fan.pwm_divisor; if (priv->bios_fan.pwm_freq) { divs = 1; if (priv->fan.pwm_clock) divs = priv->fan.pwm_clock(therm); divs /= priv->bios_fan.pwm_freq; } duty = ((divs * percent) + 99) / 100; if (card_type <= NV_40 || (func.log[0] & 1)) duty = divs - duty; if (percent < priv->fan->bios.min_duty) percent = priv->fan->bios.min_duty; if (percent > priv->fan->bios.max_duty) percent = priv->fan->bios.max_duty; ret = priv->fan.pwm_set(therm, func.line, divs, duty); if (ret == 0) ret = priv->fan.pwm_ctrl(therm, func.line, true); return ret; } if (priv->fan->mode == FAN_CONTROL_NONE) return -EINVAL; return -ENODEV; return priv->fan->set(therm, percent); } int Loading @@ -113,7 +63,7 @@ nouveau_therm_fan_sense(struct nouveau_therm *therm) u32 cycles, cur, prev; u64 start, end, tach; if (priv->fan.tach.func == DCB_GPIO_UNUSED) if (priv->fan->tach.func == DCB_GPIO_UNUSED) return -ENODEV; /* Time a complete rotation and extrapolate to RPM: Loading @@ -121,12 +71,12 @@ nouveau_therm_fan_sense(struct nouveau_therm *therm) * We get 4 changes (0 -> 1 -> 0 -> 1) per complete rotation. */ start = ptimer->read(ptimer); prev = gpio->get(gpio, 0, priv->fan.tach.func, priv->fan.tach.line); prev = gpio->get(gpio, 0, priv->fan->tach.func, priv->fan->tach.line); cycles = 0; do { usleep_range(500, 1000); /* supports 0 < rpm < 7500 */ cur = gpio->get(gpio, 0, priv->fan.tach.func, priv->fan.tach.line); cur = gpio->get(gpio, 0, priv->fan->tach.func, priv->fan->tach.line); if (prev != cur) { if (!start) start = ptimer->read(ptimer); Loading @@ -150,7 +100,7 @@ nouveau_therm_fan_set_mode(struct nouveau_therm *therm, { struct nouveau_therm_priv *priv = (void *)therm; if (priv->fan.mode == mode) if (priv->fan->mode == mode) return 0; if (mode < FAN_CONTROL_NONE || mode >= FAN_CONTROL_NR) Loading @@ -168,7 +118,7 @@ nouveau_therm_fan_set_mode(struct nouveau_therm *therm, break; } priv->fan.mode = mode; priv->fan->mode = mode; return 0; } Loading @@ -183,7 +133,7 @@ nouveau_therm_fan_user_set(struct nouveau_therm *therm, int percent) { struct nouveau_therm_priv *priv = (void *)therm; if (priv->fan.mode != FAN_CONTROL_MANUAL) if (priv->fan->mode != FAN_CONTROL_MANUAL) return -EINVAL; return nouveau_therm_fan_set(therm, percent); Loading @@ -194,9 +144,9 @@ nouveau_therm_fan_set_defaults(struct nouveau_therm *therm) { struct nouveau_therm_priv *priv = (void *)therm; priv->bios_fan.pwm_freq = 0; priv->bios_fan.min_duty = 0; priv->bios_fan.max_duty = 100; priv->fan->bios.pwm_freq = 0; priv->fan->bios.min_duty = 0; priv->fan->bios.max_duty = 100; } Loading @@ -205,13 +155,13 @@ nouveau_therm_fan_safety_checks(struct nouveau_therm *therm) { struct nouveau_therm_priv *priv = (void *)therm; if (priv->bios_fan.min_duty > 100) priv->bios_fan.min_duty = 100; if (priv->bios_fan.max_duty > 100) priv->bios_fan.max_duty = 100; if (priv->fan->bios.min_duty > 100) priv->fan->bios.min_duty = 100; if (priv->fan->bios.max_duty > 100) priv->fan->bios.max_duty = 100; if (priv->bios_fan.min_duty > priv->bios_fan.max_duty) priv->bios_fan.min_duty = priv->bios_fan.max_duty; if (priv->fan->bios.min_duty > priv->fan->bios.max_duty) priv->fan->bios.min_duty = priv->fan->bios.max_duty; } int nouveau_fan_pwm_clock_dummy(struct nouveau_therm *therm) Loading @@ -225,15 +175,29 @@ nouveau_therm_fan_ctor(struct nouveau_therm *therm) struct nouveau_therm_priv *priv = (void *)therm; struct nouveau_gpio *gpio = nouveau_gpio(therm); struct nouveau_bios *bios = nouveau_bios(therm); struct dcb_gpio_func func; int ret; ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &priv->fan.tach); /* attempt to locate a drivable fan, and determine control method */ ret = gpio->find(gpio, 0, DCB_GPIO_PWM_FAN, 0xff, &func); if (ret == 0) ret = nouveau_fanpwm_create(therm, &func); if (ret) ret = nouveau_fannil_create(therm); if (ret) return ret; nv_info(therm, "FAN control: %s\n", priv->fan->type); /* attempt to detect a tachometer connection */ ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &priv->fan->tach); if (ret) priv->fan.tach.func = DCB_GPIO_UNUSED; priv->fan->tach.func = DCB_GPIO_UNUSED; /* other random init... */ nouveau_therm_fan_set_defaults(therm); nvbios_perf_fan_parse(bios, &priv->bios_perf_fan); if (nvbios_therm_fan_parse(bios, &priv->bios_fan)) nvbios_perf_fan_parse(bios, &priv->fan->perf); if (nvbios_therm_fan_parse(bios, &priv->fan->bios)) nv_error(therm, "parsing the thermal table failed\n"); nouveau_therm_fan_safety_checks(therm); Loading drivers/gpu/drm/nouveau/core/subdev/therm/fannil.c 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright 2012 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: Ben Skeggs */ #include "priv.h" static int nouveau_fannil_get(struct nouveau_therm *therm) { return -ENODEV; } int nouveau_fannil_set(struct nouveau_therm *therm, int percent) { return -ENODEV; } int nouveau_fannil_create(struct nouveau_therm *therm) { struct nouveau_therm_priv *tpriv = (void *)therm; struct nouveau_fan *priv; priv = kzalloc(sizeof(*priv), GFP_KERNEL); tpriv->fan = priv; if (!priv) return -ENOMEM; priv->type = "none / external"; priv->get = nouveau_fannil_get; priv->set = nouveau_fannil_set; return 0; } Loading
drivers/gpu/drm/nouveau/Makefile +2 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,8 @@ nouveau-y += core/subdev/mxm/mxms.o nouveau-y += core/subdev/mxm/nv50.o nouveau-y += core/subdev/therm/base.o nouveau-y += core/subdev/therm/fan.o nouveau-y += core/subdev/therm/fannil.o nouveau-y += core/subdev/therm/fanpwm.o nouveau-y += core/subdev/therm/ic.o nouveau-y += core/subdev/therm/temp.o nouveau-y += core/subdev/therm/nv40.o Loading
drivers/gpu/drm/nouveau/core/include/subdev/therm.h +14 −8 Original line number Diff line number Diff line Loading @@ -28,6 +28,11 @@ enum nouveau_therm_attr_type { struct nouveau_therm { struct nouveau_subdev base; int (*pwm_ctrl)(struct nouveau_therm *, int line, bool); int (*pwm_get)(struct nouveau_therm *, int line, u32 *, u32 *); int (*pwm_set)(struct nouveau_therm *, int line, u32, u32); int (*pwm_clock)(struct nouveau_therm *); int (*fan_get)(struct nouveau_therm *); int (*fan_set)(struct nouveau_therm *, int); int (*fan_sense)(struct nouveau_therm *); Loading @@ -47,8 +52,10 @@ nouveau_therm(void *obj) #define nouveau_therm_create(p,e,o,d) \ nouveau_therm_create_((p), (e), (o), sizeof(**d), (void **)d) #define nouveau_therm_destroy(p) \ nouveau_subdev_destroy(&(p)->base) #define nouveau_therm_destroy(p) ({ \ struct nouveau_therm *therm = (p); \ _nouveau_therm_dtor(nv_object(therm)); \ }) #define nouveau_therm_init(p) ({ \ struct nouveau_therm *therm = (p); \ _nouveau_therm_init(nv_object(therm)); \ Loading @@ -60,8 +67,7 @@ nouveau_therm(void *obj) int nouveau_therm_create_(struct nouveau_object *, struct nouveau_object *, struct nouveau_oclass *, int, void **); #define _nouveau_therm_dtor _nouveau_subdev_dtor void _nouveau_therm_dtor(struct nouveau_object *); int _nouveau_therm_init(struct nouveau_object *); int _nouveau_therm_fini(struct nouveau_object *, bool); Loading
drivers/gpu/drm/nouveau/core/subdev/therm/base.c +29 −16 Original line number Diff line number Diff line Loading @@ -37,11 +37,11 @@ nouveau_therm_attr_get(struct nouveau_therm *therm, switch (type) { case NOUVEAU_THERM_ATTR_FAN_MIN_DUTY: return priv->bios_fan.min_duty; return priv->fan->bios.min_duty; case NOUVEAU_THERM_ATTR_FAN_MAX_DUTY: return priv->bios_fan.max_duty; return priv->fan->bios.max_duty; case NOUVEAU_THERM_ATTR_FAN_MODE: return priv->fan.mode; return priv->fan->mode; case NOUVEAU_THERM_ATTR_THRS_FAN_BOOST: return priv->bios_sensor.thrs_fan_boost.temp; case NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST: Loading Loading @@ -73,16 +73,16 @@ nouveau_therm_attr_set(struct nouveau_therm *therm, case NOUVEAU_THERM_ATTR_FAN_MIN_DUTY: if (value < 0) value = 0; if (value > priv->bios_fan.max_duty) value = priv->bios_fan.max_duty; priv->bios_fan.min_duty = value; if (value > priv->fan->bios.max_duty) value = priv->fan->bios.max_duty; priv->fan->bios.min_duty = value; return 0; case NOUVEAU_THERM_ATTR_FAN_MAX_DUTY: if (value < 0) value = 0; if (value < priv->bios_fan.min_duty) value = priv->bios_fan.min_duty; priv->bios_fan.max_duty = value; if (value < priv->fan->bios.min_duty) value = priv->fan->bios.min_duty; priv->fan->bios.max_duty = value; return 0; case NOUVEAU_THERM_ATTR_FAN_MODE: return nouveau_therm_fan_set_mode(therm, value); Loading Loading @@ -126,8 +126,8 @@ _nouveau_therm_init(struct nouveau_object *object) if (ret) return ret; if (priv->fan.percent >= 0) therm->fan_set(therm, priv->fan.percent); if (priv->fan->percent >= 0) therm->fan_set(therm, priv->fan->percent); return 0; } Loading @@ -138,7 +138,7 @@ _nouveau_therm_fini(struct nouveau_object *object, bool suspend) struct nouveau_therm *therm = (void *)object; struct nouveau_therm_priv *priv = (void *)therm; priv->fan.percent = therm->fan_get(therm); priv->fan->percent = therm->fan_get(therm); return nouveau_subdev_fini(&therm->base, suspend); } Loading @@ -158,10 +158,6 @@ nouveau_therm_create_(struct nouveau_object *parent, if (ret) return ret; nouveau_therm_ic_ctor(&priv->base); nouveau_therm_sensor_ctor(&priv->base); nouveau_therm_fan_ctor(&priv->base); priv->base.fan_get = nouveau_therm_fan_user_get; priv->base.fan_set = nouveau_therm_fan_user_set; priv->base.fan_sense = nouveau_therm_fan_sense; Loading @@ -169,3 +165,20 @@ nouveau_therm_create_(struct nouveau_object *parent, priv->base.attr_set = nouveau_therm_attr_set; return 0; } int nouveau_therm_preinit(struct nouveau_therm *therm) { nouveau_therm_ic_ctor(therm); nouveau_therm_sensor_ctor(therm); nouveau_therm_fan_ctor(therm); return 0; } void _nouveau_therm_dtor(struct nouveau_object *object) { struct nouveau_therm_priv *priv = (void *)object; kfree(priv->fan); nouveau_subdev_destroy(&priv->base.base); }
drivers/gpu/drm/nouveau/core/subdev/therm/fan.c +41 −77 Original line number Diff line number Diff line Loading @@ -35,73 +35,23 @@ int nouveau_therm_fan_get(struct nouveau_therm *therm) { struct nouveau_therm_priv *priv = (void *)therm; struct nouveau_gpio *gpio = nouveau_gpio(therm); struct dcb_gpio_func func; int card_type = nv_device(therm)->card_type; u32 divs, duty; int ret; if (!priv->fan.pwm_get) return -ENODEV; ret = gpio->find(gpio, 0, DCB_GPIO_PWM_FAN, 0xff, &func); if (ret == 0) { ret = priv->fan.pwm_get(therm, func.line, &divs, &duty); if (ret == 0 && divs) { divs = max(divs, duty); if (card_type <= NV_40 || (func.log[0] & 1)) duty = divs - duty; return (duty * 100) / divs; } return gpio->get(gpio, 0, func.func, func.line) * 100; } return -ENODEV; return priv->fan->get(therm); } int nouveau_therm_fan_set(struct nouveau_therm *therm, int percent) { struct nouveau_therm_priv *priv = (void *)therm; struct nouveau_gpio *gpio = nouveau_gpio(therm); struct dcb_gpio_func func; int card_type = nv_device(therm)->card_type; u32 divs, duty; int ret; if (priv->fan.mode == FAN_CONTROL_NONE) return -EINVAL; if (!priv->fan.pwm_set) return -ENODEV; if (percent < priv->bios_fan.min_duty) percent = priv->bios_fan.min_duty; if (percent > priv->bios_fan.max_duty) percent = priv->bios_fan.max_duty; ret = gpio->find(gpio, 0, DCB_GPIO_PWM_FAN, 0xff, &func); if (ret == 0) { divs = priv->bios_perf_fan.pwm_divisor; if (priv->bios_fan.pwm_freq) { divs = 1; if (priv->fan.pwm_clock) divs = priv->fan.pwm_clock(therm); divs /= priv->bios_fan.pwm_freq; } duty = ((divs * percent) + 99) / 100; if (card_type <= NV_40 || (func.log[0] & 1)) duty = divs - duty; if (percent < priv->fan->bios.min_duty) percent = priv->fan->bios.min_duty; if (percent > priv->fan->bios.max_duty) percent = priv->fan->bios.max_duty; ret = priv->fan.pwm_set(therm, func.line, divs, duty); if (ret == 0) ret = priv->fan.pwm_ctrl(therm, func.line, true); return ret; } if (priv->fan->mode == FAN_CONTROL_NONE) return -EINVAL; return -ENODEV; return priv->fan->set(therm, percent); } int Loading @@ -113,7 +63,7 @@ nouveau_therm_fan_sense(struct nouveau_therm *therm) u32 cycles, cur, prev; u64 start, end, tach; if (priv->fan.tach.func == DCB_GPIO_UNUSED) if (priv->fan->tach.func == DCB_GPIO_UNUSED) return -ENODEV; /* Time a complete rotation and extrapolate to RPM: Loading @@ -121,12 +71,12 @@ nouveau_therm_fan_sense(struct nouveau_therm *therm) * We get 4 changes (0 -> 1 -> 0 -> 1) per complete rotation. */ start = ptimer->read(ptimer); prev = gpio->get(gpio, 0, priv->fan.tach.func, priv->fan.tach.line); prev = gpio->get(gpio, 0, priv->fan->tach.func, priv->fan->tach.line); cycles = 0; do { usleep_range(500, 1000); /* supports 0 < rpm < 7500 */ cur = gpio->get(gpio, 0, priv->fan.tach.func, priv->fan.tach.line); cur = gpio->get(gpio, 0, priv->fan->tach.func, priv->fan->tach.line); if (prev != cur) { if (!start) start = ptimer->read(ptimer); Loading @@ -150,7 +100,7 @@ nouveau_therm_fan_set_mode(struct nouveau_therm *therm, { struct nouveau_therm_priv *priv = (void *)therm; if (priv->fan.mode == mode) if (priv->fan->mode == mode) return 0; if (mode < FAN_CONTROL_NONE || mode >= FAN_CONTROL_NR) Loading @@ -168,7 +118,7 @@ nouveau_therm_fan_set_mode(struct nouveau_therm *therm, break; } priv->fan.mode = mode; priv->fan->mode = mode; return 0; } Loading @@ -183,7 +133,7 @@ nouveau_therm_fan_user_set(struct nouveau_therm *therm, int percent) { struct nouveau_therm_priv *priv = (void *)therm; if (priv->fan.mode != FAN_CONTROL_MANUAL) if (priv->fan->mode != FAN_CONTROL_MANUAL) return -EINVAL; return nouveau_therm_fan_set(therm, percent); Loading @@ -194,9 +144,9 @@ nouveau_therm_fan_set_defaults(struct nouveau_therm *therm) { struct nouveau_therm_priv *priv = (void *)therm; priv->bios_fan.pwm_freq = 0; priv->bios_fan.min_duty = 0; priv->bios_fan.max_duty = 100; priv->fan->bios.pwm_freq = 0; priv->fan->bios.min_duty = 0; priv->fan->bios.max_duty = 100; } Loading @@ -205,13 +155,13 @@ nouveau_therm_fan_safety_checks(struct nouveau_therm *therm) { struct nouveau_therm_priv *priv = (void *)therm; if (priv->bios_fan.min_duty > 100) priv->bios_fan.min_duty = 100; if (priv->bios_fan.max_duty > 100) priv->bios_fan.max_duty = 100; if (priv->fan->bios.min_duty > 100) priv->fan->bios.min_duty = 100; if (priv->fan->bios.max_duty > 100) priv->fan->bios.max_duty = 100; if (priv->bios_fan.min_duty > priv->bios_fan.max_duty) priv->bios_fan.min_duty = priv->bios_fan.max_duty; if (priv->fan->bios.min_duty > priv->fan->bios.max_duty) priv->fan->bios.min_duty = priv->fan->bios.max_duty; } int nouveau_fan_pwm_clock_dummy(struct nouveau_therm *therm) Loading @@ -225,15 +175,29 @@ nouveau_therm_fan_ctor(struct nouveau_therm *therm) struct nouveau_therm_priv *priv = (void *)therm; struct nouveau_gpio *gpio = nouveau_gpio(therm); struct nouveau_bios *bios = nouveau_bios(therm); struct dcb_gpio_func func; int ret; ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &priv->fan.tach); /* attempt to locate a drivable fan, and determine control method */ ret = gpio->find(gpio, 0, DCB_GPIO_PWM_FAN, 0xff, &func); if (ret == 0) ret = nouveau_fanpwm_create(therm, &func); if (ret) ret = nouveau_fannil_create(therm); if (ret) return ret; nv_info(therm, "FAN control: %s\n", priv->fan->type); /* attempt to detect a tachometer connection */ ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &priv->fan->tach); if (ret) priv->fan.tach.func = DCB_GPIO_UNUSED; priv->fan->tach.func = DCB_GPIO_UNUSED; /* other random init... */ nouveau_therm_fan_set_defaults(therm); nvbios_perf_fan_parse(bios, &priv->bios_perf_fan); if (nvbios_therm_fan_parse(bios, &priv->bios_fan)) nvbios_perf_fan_parse(bios, &priv->fan->perf); if (nvbios_therm_fan_parse(bios, &priv->fan->bios)) nv_error(therm, "parsing the thermal table failed\n"); nouveau_therm_fan_safety_checks(therm); Loading
drivers/gpu/drm/nouveau/core/subdev/therm/fannil.c 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright 2012 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: Ben Skeggs */ #include "priv.h" static int nouveau_fannil_get(struct nouveau_therm *therm) { return -ENODEV; } int nouveau_fannil_set(struct nouveau_therm *therm, int percent) { return -ENODEV; } int nouveau_fannil_create(struct nouveau_therm *therm) { struct nouveau_therm_priv *tpriv = (void *)therm; struct nouveau_fan *priv; priv = kzalloc(sizeof(*priv), GFP_KERNEL); tpriv->fan = priv; if (!priv) return -ENOMEM; priv->type = "none / external"; priv->get = nouveau_fannil_get; priv->set = nouveau_fannil_set; return 0; }