Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2014 Martin Peres
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: Martin Peres
0023  */
0024 #include "priv.h"
0025 
0026 static int
0027 gm107_fan_pwm_ctrl(struct nvkm_therm *therm, int line, bool enable)
0028 {
0029     /* nothing to do, it seems hardwired */
0030     return 0;
0031 }
0032 
0033 static int
0034 gm107_fan_pwm_get(struct nvkm_therm *therm, int line, u32 *divs, u32 *duty)
0035 {
0036     struct nvkm_device *device = therm->subdev.device;
0037     *divs = nvkm_rd32(device, 0x10eb20) & 0x1fff;
0038     *duty = nvkm_rd32(device, 0x10eb24) & 0x1fff;
0039     return 0;
0040 }
0041 
0042 static int
0043 gm107_fan_pwm_set(struct nvkm_therm *therm, int line, u32 divs, u32 duty)
0044 {
0045     struct nvkm_device *device = therm->subdev.device;
0046     nvkm_mask(device, 0x10eb10, 0x1fff, divs); /* keep the high bits */
0047     nvkm_wr32(device, 0x10eb14, duty | 0x80000000);
0048     return 0;
0049 }
0050 
0051 static int
0052 gm107_fan_pwm_clock(struct nvkm_therm *therm, int line)
0053 {
0054     return therm->subdev.device->crystal * 1000;
0055 }
0056 
0057 static const struct nvkm_therm_func
0058 gm107_therm = {
0059     .init = gf119_therm_init,
0060     .fini = g84_therm_fini,
0061     .pwm_ctrl = gm107_fan_pwm_ctrl,
0062     .pwm_get = gm107_fan_pwm_get,
0063     .pwm_set = gm107_fan_pwm_set,
0064     .pwm_clock = gm107_fan_pwm_clock,
0065     .temp_get = g84_temp_get,
0066     .fan_sense = gt215_therm_fan_sense,
0067     .program_alarms = nvkm_therm_program_alarms_polling,
0068 };
0069 
0070 int
0071 gm107_therm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0072         struct nvkm_therm **ptherm)
0073 {
0074     return nvkm_therm_new_(&gm107_therm, device, type, inst, ptherm);
0075 }