Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
5718ea32
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
5718ea32
编写于
8月 20, 2015
作者:
B
Ben Skeggs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
drm/nouveau/therm: switch to device pri macros
Signed-off-by:
N
Ben Skeggs
<
bskeggs@redhat.com
>
上级
bef002e8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
110 addition
and
82 deletion
+110
-82
drivers/gpu/drm/nouveau/nvkm/subdev/therm/g84.c
drivers/gpu/drm/nouveau/nvkm/subdev/therm/g84.c
+26
-18
drivers/gpu/drm/nouveau/nvkm/subdev/therm/gf110.c
drivers/gpu/drm/nouveau/nvkm/subdev/therm/gf110.c
+24
-18
drivers/gpu/drm/nouveau/nvkm/subdev/therm/gm107.c
drivers/gpu/drm/nouveau/nvkm/subdev/therm/gm107.c
+7
-5
drivers/gpu/drm/nouveau/nvkm/subdev/therm/gt215.c
drivers/gpu/drm/nouveau/nvkm/subdev/therm/gt215.c
+9
-7
drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c
drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c
+25
-19
drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv50.c
drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv50.c
+19
-15
未找到文件。
drivers/gpu/drm/nouveau/nvkm/subdev/therm/g84.c
浏览文件 @
5718ea32
...
...
@@ -29,10 +29,11 @@
int
g84_temp_get
(
struct
nvkm_therm
*
therm
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
struct
nvkm_fuse
*
fuse
=
nvkm_fuse
(
therm
);
if
(
nv_ro32
(
fuse
,
0x1a8
)
==
1
)
return
nv
_rd32
(
therm
,
0x20400
);
return
nv
km_rd32
(
device
,
0x20400
);
else
return
-
ENODEV
;
}
...
...
@@ -40,12 +41,13 @@ g84_temp_get(struct nvkm_therm *therm)
void
g84_sensor_setup
(
struct
nvkm_therm
*
therm
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
struct
nvkm_fuse
*
fuse
=
nvkm_fuse
(
therm
);
/* enable temperature reading for cards with insane defaults */
if
(
nv_ro32
(
fuse
,
0x1a8
)
==
1
)
{
nv
_mask
(
therm
,
0x20008
,
0x80008000
,
0x80000000
);
nv
_mask
(
therm
,
0x2000c
,
0x80000003
,
0x00000000
);
nv
km_mask
(
device
,
0x20008
,
0x80008000
,
0x80000000
);
nv
km_mask
(
device
,
0x2000c
,
0x80000003
,
0x00000000
);
mdelay
(
20
);
/* wait for the temperature to stabilize */
}
}
...
...
@@ -54,26 +56,27 @@ static void
g84_therm_program_alarms
(
struct
nvkm_therm
*
obj
)
{
struct
nvkm_therm_priv
*
therm
=
container_of
(
obj
,
typeof
(
*
therm
),
base
);
struct
nvkm_device
*
device
=
therm
->
base
.
subdev
.
device
;
struct
nvbios_therm_sensor
*
sensor
=
&
therm
->
bios_sensor
;
unsigned
long
flags
;
spin_lock_irqsave
(
&
therm
->
sensor
.
alarm_program_lock
,
flags
);
/* enable RISING and FALLING IRQs for shutdown, THRS 0, 1, 2 and 4 */
nv
_wr32
(
therm
,
0x20000
,
0x000003ff
);
nv
km_wr32
(
device
,
0x20000
,
0x000003ff
);
/* shutdown: The computer should be shutdown when reached */
nv
_wr32
(
therm
,
0x20484
,
sensor
->
thrs_shutdown
.
hysteresis
);
nv
_wr32
(
therm
,
0x20480
,
sensor
->
thrs_shutdown
.
temp
);
nv
km_wr32
(
device
,
0x20484
,
sensor
->
thrs_shutdown
.
hysteresis
);
nv
km_wr32
(
device
,
0x20480
,
sensor
->
thrs_shutdown
.
temp
);
/* THRS_1 : fan boost*/
nv
_wr32
(
therm
,
0x204c4
,
sensor
->
thrs_fan_boost
.
temp
);
nv
km_wr32
(
device
,
0x204c4
,
sensor
->
thrs_fan_boost
.
temp
);
/* THRS_2 : critical */
nv
_wr32
(
therm
,
0x204c0
,
sensor
->
thrs_critical
.
temp
);
nv
km_wr32
(
device
,
0x204c0
,
sensor
->
thrs_critical
.
temp
);
/* THRS_4 : down clock */
nv
_wr32
(
therm
,
0x20414
,
sensor
->
thrs_down_clock
.
temp
);
nv
km_wr32
(
device
,
0x20414
,
sensor
->
thrs_down_clock
.
temp
);
spin_unlock_irqrestore
(
&
therm
->
sensor
.
alarm_program_lock
,
flags
);
nv_debug
(
therm
,
...
...
@@ -93,19 +96,20 @@ g84_therm_threshold_hyst_emulation(struct nvkm_therm *therm,
const
struct
nvbios_therm_threshold
*
thrs
,
enum
nvkm_therm_thrs
thrs_name
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
enum
nvkm_therm_thrs_direction
direction
;
enum
nvkm_therm_thrs_state
prev_state
,
new_state
;
int
temp
,
cur
;
prev_state
=
nvkm_therm_sensor_get_threshold_state
(
therm
,
thrs_name
);
temp
=
nv
_rd32
(
therm
,
thrs_reg
);
temp
=
nv
km_rd32
(
device
,
thrs_reg
);
/* program the next threshold */
if
(
temp
==
thrs
->
temp
)
{
nv
_wr32
(
therm
,
thrs_reg
,
thrs
->
temp
-
thrs
->
hysteresis
);
nv
km_wr32
(
device
,
thrs_reg
,
thrs
->
temp
-
thrs
->
hysteresis
);
new_state
=
NVKM_THERM_THRS_HIGHER
;
}
else
{
nv
_wr32
(
therm
,
thrs_reg
,
thrs
->
temp
);
nv
km_wr32
(
device
,
thrs_reg
,
thrs
->
temp
);
new_state
=
NVKM_THERM_THRS_LOWER
;
}
...
...
@@ -134,13 +138,14 @@ static void
g84_therm_intr
(
struct
nvkm_subdev
*
subdev
)
{
struct
nvkm_therm_priv
*
therm
=
(
void
*
)
subdev
;
struct
nvkm_device
*
device
=
therm
->
base
.
subdev
.
device
;
struct
nvbios_therm_sensor
*
sensor
=
&
therm
->
bios_sensor
;
unsigned
long
flags
;
uint32_t
intr
;
spin_lock_irqsave
(
&
therm
->
sensor
.
alarm_program_lock
,
flags
);
intr
=
nv
_rd32
(
therm
,
0x20100
)
&
0x3ff
;
intr
=
nv
km_rd32
(
device
,
0x20100
)
&
0x3ff
;
/* THRS_4: downclock */
if
(
intr
&
0x002
)
{
...
...
@@ -178,8 +183,8 @@ g84_therm_intr(struct nvkm_subdev *subdev)
nv_error
(
therm
,
"unhandled intr 0x%08x
\n
"
,
intr
);
/* ACK everything */
nv
_wr32
(
therm
,
0x20100
,
0xffffffff
);
nv
_wr32
(
therm
,
0x1100
,
0x10000
);
/* PBUS */
nv
km_wr32
(
device
,
0x20100
,
0xffffffff
);
nv
km_wr32
(
device
,
0x1100
,
0x10000
);
/* PBUS */
spin_unlock_irqrestore
(
&
therm
->
sensor
.
alarm_program_lock
,
flags
);
}
...
...
@@ -239,12 +244,15 @@ g84_therm_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
int
g84_therm_fini
(
struct
nvkm_object
*
object
,
bool
suspend
)
{
struct
nvkm_therm
*
therm
=
(
void
*
)
object
;
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
/* Disable PTherm IRQs */
nv
_wr32
(
object
,
0x20000
,
0x00000000
);
nv
km_wr32
(
device
,
0x20000
,
0x00000000
);
/* ACK all PTherm IRQs */
nv
_wr32
(
object
,
0x20100
,
0xffffffff
);
nv
_wr32
(
object
,
0x1100
,
0x10000
);
/* PBUS */
nv
km_wr32
(
device
,
0x20100
,
0xffffffff
);
nv
km_wr32
(
device
,
0x1100
,
0x10000
);
/* PBUS */
return
_nvkm_therm_fini
(
object
,
suspend
);
}
...
...
drivers/gpu/drm/nouveau/nvkm/subdev/therm/gf110.c
浏览文件 @
5718ea32
...
...
@@ -26,7 +26,8 @@
static
int
pwm_info
(
struct
nvkm_therm
*
therm
,
int
line
)
{
u32
gpio
=
nv_rd32
(
therm
,
0x00d610
+
(
line
*
0x04
));
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
u32
gpio
=
nvkm_rd32
(
device
,
0x00d610
+
(
line
*
0x04
));
switch
(
gpio
&
0x000000c0
)
{
case
0x00000000
:
/* normal mode, possibly pwm forced off by us */
...
...
@@ -50,12 +51,13 @@ pwm_info(struct nvkm_therm *therm, int line)
static
int
gf110_fan_pwm_ctrl
(
struct
nvkm_therm
*
therm
,
int
line
,
bool
enable
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
u32
data
=
enable
?
0x00000040
:
0x00000000
;
int
indx
=
pwm_info
(
therm
,
line
);
if
(
indx
<
0
)
return
indx
;
else
if
(
indx
<
2
)
nv
_mask
(
therm
,
0x00d610
+
(
line
*
0x04
),
0x000000c0
,
data
);
nv
km_mask
(
device
,
0x00d610
+
(
line
*
0x04
),
0x000000c0
,
data
);
/* nothing to do for indx == 2, it seems hardwired to PTHERM */
return
0
;
}
...
...
@@ -63,18 +65,19 @@ gf110_fan_pwm_ctrl(struct nvkm_therm *therm, int line, bool enable)
static
int
gf110_fan_pwm_get
(
struct
nvkm_therm
*
therm
,
int
line
,
u32
*
divs
,
u32
*
duty
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
int
indx
=
pwm_info
(
therm
,
line
);
if
(
indx
<
0
)
return
indx
;
else
if
(
indx
<
2
)
{
if
(
nv
_rd32
(
therm
,
0x00d610
+
(
line
*
0x04
))
&
0x00000040
)
{
*
divs
=
nv
_rd32
(
therm
,
0x00e114
+
(
indx
*
8
));
*
duty
=
nv
_rd32
(
therm
,
0x00e118
+
(
indx
*
8
));
if
(
nv
km_rd32
(
device
,
0x00d610
+
(
line
*
0x04
))
&
0x00000040
)
{
*
divs
=
nv
km_rd32
(
device
,
0x00e114
+
(
indx
*
8
));
*
duty
=
nv
km_rd32
(
device
,
0x00e118
+
(
indx
*
8
));
return
0
;
}
}
else
if
(
indx
==
2
)
{
*
divs
=
nv
_rd32
(
therm
,
0x0200d8
)
&
0x1fff
;
*
duty
=
nv
_rd32
(
therm
,
0x0200dc
)
&
0x1fff
;
*
divs
=
nv
km_rd32
(
device
,
0x0200d8
)
&
0x1fff
;
*
duty
=
nv
km_rd32
(
device
,
0x0200dc
)
&
0x1fff
;
return
0
;
}
...
...
@@ -84,15 +87,16 @@ gf110_fan_pwm_get(struct nvkm_therm *therm, int line, u32 *divs, u32 *duty)
static
int
gf110_fan_pwm_set
(
struct
nvkm_therm
*
therm
,
int
line
,
u32
divs
,
u32
duty
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
int
indx
=
pwm_info
(
therm
,
line
);
if
(
indx
<
0
)
return
indx
;
else
if
(
indx
<
2
)
{
nv
_wr32
(
therm
,
0x00e114
+
(
indx
*
8
),
divs
);
nv
_wr32
(
therm
,
0x00e118
+
(
indx
*
8
),
duty
|
0x80000000
);
nv
km_wr32
(
device
,
0x00e114
+
(
indx
*
8
),
divs
);
nv
km_wr32
(
device
,
0x00e118
+
(
indx
*
8
),
duty
|
0x80000000
);
}
else
if
(
indx
==
2
)
{
nv
_mask
(
therm
,
0x0200d8
,
0x1fff
,
divs
);
/* keep the high bits */
nv
_wr32
(
therm
,
0x0200dc
,
duty
|
0x40000000
);
nv
km_mask
(
device
,
0x0200d8
,
0x1fff
,
divs
);
/* keep the high bits */
nv
km_wr32
(
device
,
0x0200dc
,
duty
|
0x40000000
);
}
return
0
;
}
...
...
@@ -100,19 +104,21 @@ gf110_fan_pwm_set(struct nvkm_therm *therm, int line, u32 divs, u32 duty)
static
int
gf110_fan_pwm_clock
(
struct
nvkm_therm
*
therm
,
int
line
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
int
indx
=
pwm_info
(
therm
,
line
);
if
(
indx
<
0
)
return
0
;
else
if
(
indx
<
2
)
return
(
nv_device
(
therm
)
->
crystal
*
1000
)
/
20
;
return
(
device
->
crystal
*
1000
)
/
20
;
else
return
nv_device
(
therm
)
->
crystal
*
1000
/
10
;
return
device
->
crystal
*
1000
/
10
;
}
int
gf110_therm_init
(
struct
nvkm_object
*
object
)
{
struct
nvkm_therm_priv
*
therm
=
(
void
*
)
object
;
struct
nvkm_device
*
device
=
therm
->
base
.
subdev
.
device
;
int
ret
;
ret
=
nvkm_therm_init
(
&
therm
->
base
);
...
...
@@ -120,13 +126,13 @@ gf110_therm_init(struct nvkm_object *object)
return
ret
;
/* enable fan tach, count revolutions per-second */
nv
_mask
(
therm
,
0x00e720
,
0x00000003
,
0x00000002
);
nv
km_mask
(
device
,
0x00e720
,
0x00000003
,
0x00000002
);
if
(
therm
->
fan
->
tach
.
func
!=
DCB_GPIO_UNUSED
)
{
nv
_mask
(
therm
,
0x00d79c
,
0x000000ff
,
therm
->
fan
->
tach
.
line
);
nv
_wr32
(
therm
,
0x00e724
,
nv_device
(
therm
)
->
crystal
*
1000
);
nv
_mask
(
therm
,
0x00e720
,
0x00000001
,
0x00000001
);
nv
km_mask
(
device
,
0x00d79c
,
0x000000ff
,
therm
->
fan
->
tach
.
line
);
nv
km_wr32
(
device
,
0x00e724
,
nv_device
(
therm
)
->
crystal
*
1000
);
nv
km_mask
(
device
,
0x00e720
,
0x00000001
,
0x00000001
);
}
nv
_mask
(
therm
,
0x00e720
,
0x00000002
,
0x00000000
);
nv
km_mask
(
device
,
0x00e720
,
0x00000002
,
0x00000000
);
return
0
;
}
...
...
drivers/gpu/drm/nouveau/nvkm/subdev/therm/gm107.c
浏览文件 @
5718ea32
...
...
@@ -33,23 +33,25 @@ gm107_fan_pwm_ctrl(struct nvkm_therm *therm, int line, bool enable)
static
int
gm107_fan_pwm_get
(
struct
nvkm_therm
*
therm
,
int
line
,
u32
*
divs
,
u32
*
duty
)
{
*
divs
=
nv_rd32
(
therm
,
0x10eb20
)
&
0x1fff
;
*
duty
=
nv_rd32
(
therm
,
0x10eb24
)
&
0x1fff
;
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
*
divs
=
nvkm_rd32
(
device
,
0x10eb20
)
&
0x1fff
;
*
duty
=
nvkm_rd32
(
device
,
0x10eb24
)
&
0x1fff
;
return
0
;
}
static
int
gm107_fan_pwm_set
(
struct
nvkm_therm
*
therm
,
int
line
,
u32
divs
,
u32
duty
)
{
nv_mask
(
therm
,
0x10eb10
,
0x1fff
,
divs
);
/* keep the high bits */
nv_wr32
(
therm
,
0x10eb14
,
duty
|
0x80000000
);
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
nvkm_mask
(
device
,
0x10eb10
,
0x1fff
,
divs
);
/* keep the high bits */
nvkm_wr32
(
device
,
0x10eb14
,
duty
|
0x80000000
);
return
0
;
}
static
int
gm107_fan_pwm_clock
(
struct
nvkm_therm
*
therm
,
int
line
)
{
return
nv_device
(
therm
)
->
crystal
*
1000
;
return
therm
->
subdev
.
device
->
crystal
*
1000
;
}
static
int
...
...
drivers/gpu/drm/nouveau/nvkm/subdev/therm/gt215.c
浏览文件 @
5718ea32
...
...
@@ -28,8 +28,9 @@
int
gt215_therm_fan_sense
(
struct
nvkm_therm
*
therm
)
{
u32
tach
=
nv_rd32
(
therm
,
0x00e728
)
&
0x0000ffff
;
u32
ctrl
=
nv_rd32
(
therm
,
0x00e720
);
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
u32
tach
=
nvkm_rd32
(
device
,
0x00e728
)
&
0x0000ffff
;
u32
ctrl
=
nvkm_rd32
(
device
,
0x00e720
);
if
(
ctrl
&
0x00000001
)
return
tach
*
60
/
2
;
return
-
ENODEV
;
...
...
@@ -39,6 +40,7 @@ static int
gt215_therm_init
(
struct
nvkm_object
*
object
)
{
struct
nvkm_therm_priv
*
therm
=
(
void
*
)
object
;
struct
nvkm_device
*
device
=
therm
->
base
.
subdev
.
device
;
struct
dcb_gpio_func
*
tach
=
&
therm
->
fan
->
tach
;
int
ret
;
...
...
@@ -49,13 +51,13 @@ gt215_therm_init(struct nvkm_object *object)
g84_sensor_setup
(
&
therm
->
base
);
/* enable fan tach, count revolutions per-second */
nv
_mask
(
therm
,
0x00e720
,
0x00000003
,
0x00000002
);
nv
km_mask
(
device
,
0x00e720
,
0x00000003
,
0x00000002
);
if
(
tach
->
func
!=
DCB_GPIO_UNUSED
)
{
nv
_wr32
(
therm
,
0x00e724
,
nv_device
(
therm
)
->
crystal
*
1000
);
nv
_mask
(
therm
,
0x00e720
,
0x001f0000
,
tach
->
line
<<
16
);
nv
_mask
(
therm
,
0x00e720
,
0x00000001
,
0x00000001
);
nv
km_wr32
(
device
,
0x00e724
,
nv_device
(
therm
)
->
crystal
*
1000
);
nv
km_mask
(
device
,
0x00e720
,
0x001f0000
,
tach
->
line
<<
16
);
nv
km_mask
(
device
,
0x00e720
,
0x00000001
,
0x00000001
);
}
nv
_mask
(
therm
,
0x00e720
,
0x00000002
,
0x00000000
);
nv
km_mask
(
device
,
0x00e720
,
0x00000002
,
0x00000000
);
return
0
;
}
...
...
drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c
浏览文件 @
5718ea32
...
...
@@ -55,18 +55,19 @@ nv40_sensor_style(struct nvkm_therm *therm)
static
int
nv40_sensor_setup
(
struct
nvkm_therm
*
therm
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
enum
nv40_sensor_style
style
=
nv40_sensor_style
(
therm
);
/* enable ADC readout and disable the ALARM threshold */
if
(
style
==
NEW_STYLE
)
{
nv
_mask
(
therm
,
0x15b8
,
0x80000000
,
0
);
nv
_wr32
(
therm
,
0x15b0
,
0x80003fff
);
nv
km_mask
(
device
,
0x15b8
,
0x80000000
,
0
);
nv
km_wr32
(
device
,
0x15b0
,
0x80003fff
);
mdelay
(
20
);
/* wait for the temperature to stabilize */
return
nv
_rd32
(
therm
,
0x15b4
)
&
0x3fff
;
return
nv
km_rd32
(
device
,
0x15b4
)
&
0x3fff
;
}
else
if
(
style
==
OLD_STYLE
)
{
nv
_wr32
(
therm
,
0x15b0
,
0xff
);
nv
km_wr32
(
device
,
0x15b0
,
0xff
);
mdelay
(
20
);
/* wait for the temperature to stabilize */
return
nv
_rd32
(
therm
,
0x15b4
)
&
0xff
;
return
nv
km_rd32
(
device
,
0x15b4
)
&
0xff
;
}
else
return
-
ENODEV
;
}
...
...
@@ -75,16 +76,17 @@ static int
nv40_temp_get
(
struct
nvkm_therm
*
obj
)
{
struct
nvkm_therm_priv
*
therm
=
container_of
(
obj
,
typeof
(
*
therm
),
base
);
struct
nvkm_device
*
device
=
therm
->
base
.
subdev
.
device
;
struct
nvbios_therm_sensor
*
sensor
=
&
therm
->
bios_sensor
;
enum
nv40_sensor_style
style
=
nv40_sensor_style
(
&
therm
->
base
);
int
core_temp
;
if
(
style
==
NEW_STYLE
)
{
nv
_wr32
(
therm
,
0x15b0
,
0x80003fff
);
core_temp
=
nv
_rd32
(
therm
,
0x15b4
)
&
0x3fff
;
nv
km_wr32
(
device
,
0x15b0
,
0x80003fff
);
core_temp
=
nv
km_rd32
(
device
,
0x15b4
)
&
0x3fff
;
}
else
if
(
style
==
OLD_STYLE
)
{
nv
_wr32
(
therm
,
0x15b0
,
0xff
);
core_temp
=
nv
_rd32
(
therm
,
0x15b4
)
&
0xff
;
nv
km_wr32
(
device
,
0x15b0
,
0xff
);
core_temp
=
nv
km_rd32
(
device
,
0x15b4
)
&
0xff
;
}
else
return
-
ENODEV
;
...
...
@@ -107,9 +109,10 @@ nv40_temp_get(struct nvkm_therm *obj)
static
int
nv40_fan_pwm_ctrl
(
struct
nvkm_therm
*
therm
,
int
line
,
bool
enable
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
u32
mask
=
enable
?
0x80000000
:
0x0000000
;
if
(
line
==
2
)
nv
_mask
(
therm
,
0x0010f0
,
0x80000000
,
mask
);
else
if
(
line
==
9
)
nv
_mask
(
therm
,
0x0015f4
,
0x80000000
,
mask
);
if
(
line
==
2
)
nv
km_mask
(
device
,
0x0010f0
,
0x80000000
,
mask
);
else
if
(
line
==
9
)
nv
km_mask
(
device
,
0x0015f4
,
0x80000000
,
mask
);
else
{
nv_error
(
therm
,
"unknown pwm ctrl for gpio %d
\n
"
,
line
);
return
-
ENODEV
;
...
...
@@ -120,8 +123,9 @@ nv40_fan_pwm_ctrl(struct nvkm_therm *therm, int line, bool enable)
static
int
nv40_fan_pwm_get
(
struct
nvkm_therm
*
therm
,
int
line
,
u32
*
divs
,
u32
*
duty
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
if
(
line
==
2
)
{
u32
reg
=
nv
_rd32
(
therm
,
0x0010f0
);
u32
reg
=
nv
km_rd32
(
device
,
0x0010f0
);
if
(
reg
&
0x80000000
)
{
*
duty
=
(
reg
&
0x7fff0000
)
>>
16
;
*
divs
=
(
reg
&
0x00007fff
);
...
...
@@ -129,9 +133,9 @@ nv40_fan_pwm_get(struct nvkm_therm *therm, int line, u32 *divs, u32 *duty)
}
}
else
if
(
line
==
9
)
{
u32
reg
=
nv
_rd32
(
therm
,
0x0015f4
);
u32
reg
=
nv
km_rd32
(
device
,
0x0015f4
);
if
(
reg
&
0x80000000
)
{
*
divs
=
nv
_rd32
(
therm
,
0x0015f8
);
*
divs
=
nv
km_rd32
(
device
,
0x0015f8
);
*
duty
=
(
reg
&
0x7fffffff
);
return
0
;
}
...
...
@@ -146,12 +150,13 @@ nv40_fan_pwm_get(struct nvkm_therm *therm, int line, u32 *divs, u32 *duty)
static
int
nv40_fan_pwm_set
(
struct
nvkm_therm
*
therm
,
int
line
,
u32
divs
,
u32
duty
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
if
(
line
==
2
)
{
nv
_mask
(
therm
,
0x0010f0
,
0x7fff7fff
,
(
duty
<<
16
)
|
divs
);
nv
km_mask
(
device
,
0x0010f0
,
0x7fff7fff
,
(
duty
<<
16
)
|
divs
);
}
else
if
(
line
==
9
)
{
nv
_wr32
(
therm
,
0x0015f8
,
divs
);
nv
_mask
(
therm
,
0x0015f4
,
0x7fffffff
,
duty
);
nv
km_wr32
(
device
,
0x0015f8
,
divs
);
nv
km_mask
(
device
,
0x0015f4
,
0x7fffffff
,
duty
);
}
else
{
nv_error
(
therm
,
"unknown pwm ctrl for gpio %d
\n
"
,
line
);
return
-
ENODEV
;
...
...
@@ -164,12 +169,13 @@ void
nv40_therm_intr
(
struct
nvkm_subdev
*
subdev
)
{
struct
nvkm_therm
*
therm
=
nvkm_therm
(
subdev
);
uint32_t
stat
=
nv_rd32
(
therm
,
0x1100
);
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
uint32_t
stat
=
nvkm_rd32
(
device
,
0x1100
);
/* traitement */
/* ack all IRQs */
nv
_wr32
(
therm
,
0x1100
,
0x70000
);
nv
km_wr32
(
device
,
0x1100
,
0x70000
);
nv_error
(
therm
,
"THERM received an IRQ: stat = %x
\n
"
,
stat
);
}
...
...
drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv50.c
浏览文件 @
5718ea32
...
...
@@ -52,23 +52,25 @@ pwm_info(struct nvkm_therm *therm, int *line, int *ctrl, int *indx)
int
nv50_fan_pwm_ctrl
(
struct
nvkm_therm
*
therm
,
int
line
,
bool
enable
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
u32
data
=
enable
?
0x00000001
:
0x00000000
;
int
ctrl
,
id
,
ret
=
pwm_info
(
therm
,
&
line
,
&
ctrl
,
&
id
);
if
(
ret
==
0
)
nv
_mask
(
therm
,
ctrl
,
0x00010001
<<
line
,
data
<<
line
);
nv
km_mask
(
device
,
ctrl
,
0x00010001
<<
line
,
data
<<
line
);
return
ret
;
}
int
nv50_fan_pwm_get
(
struct
nvkm_therm
*
therm
,
int
line
,
u32
*
divs
,
u32
*
duty
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
int
ctrl
,
id
,
ret
=
pwm_info
(
therm
,
&
line
,
&
ctrl
,
&
id
);
if
(
ret
)
return
ret
;
if
(
nv
_rd32
(
therm
,
ctrl
)
&
(
1
<<
line
))
{
*
divs
=
nv
_rd32
(
therm
,
0x00e114
+
(
id
*
8
));
*
duty
=
nv
_rd32
(
therm
,
0x00e118
+
(
id
*
8
));
if
(
nv
km_rd32
(
device
,
ctrl
)
&
(
1
<<
line
))
{
*
divs
=
nv
km_rd32
(
device
,
0x00e114
+
(
id
*
8
));
*
duty
=
nv
km_rd32
(
device
,
0x00e118
+
(
id
*
8
));
return
0
;
}
...
...
@@ -78,36 +80,36 @@ nv50_fan_pwm_get(struct nvkm_therm *therm, int line, u32 *divs, u32 *duty)
int
nv50_fan_pwm_set
(
struct
nvkm_therm
*
therm
,
int
line
,
u32
divs
,
u32
duty
)
{
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
int
ctrl
,
id
,
ret
=
pwm_info
(
therm
,
&
line
,
&
ctrl
,
&
id
);
if
(
ret
)
return
ret
;
nv
_wr32
(
therm
,
0x00e114
+
(
id
*
8
),
divs
);
nv
_wr32
(
therm
,
0x00e118
+
(
id
*
8
),
duty
|
0x80000000
);
nv
km_wr32
(
device
,
0x00e114
+
(
id
*
8
),
divs
);
nv
km_wr32
(
device
,
0x00e118
+
(
id
*
8
),
duty
|
0x80000000
);
return
0
;
}
int
nv50_fan_pwm_clock
(
struct
nvkm_therm
*
therm
,
int
line
)
{
int
chipset
=
nv_device
(
therm
)
->
chipset
;
int
crystal
=
nv_device
(
therm
)
->
crystal
;
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
int
pwm_clock
;
/* determine the PWM source clock */
if
(
chipset
>
0x50
&&
chipset
<
0x94
)
{
u8
pwm_div
=
nv
_rd32
(
therm
,
0x410c
);
if
(
nv
_rd32
(
therm
,
0xc040
)
&
0x800000
)
{
if
(
device
->
chipset
>
0x50
&&
device
->
chipset
<
0x94
)
{
u8
pwm_div
=
nv
km_rd32
(
device
,
0x410c
);
if
(
nv
km_rd32
(
device
,
0xc040
)
&
0x800000
)
{
/* Use the HOST clock (100 MHz)
* Where does this constant(2.4) comes from? */
pwm_clock
=
(
100000000
>>
pwm_div
)
*
10
/
24
;
}
else
{
/* Where does this constant(20) comes from? */
pwm_clock
=
(
crystal
*
1000
)
>>
pwm_div
;
pwm_clock
=
(
device
->
crystal
*
1000
)
>>
pwm_div
;
pwm_clock
/=
20
;
}
}
else
{
pwm_clock
=
(
crystal
*
1000
)
/
20
;
pwm_clock
=
(
device
->
crystal
*
1000
)
/
20
;
}
return
pwm_clock
;
...
...
@@ -116,7 +118,8 @@ nv50_fan_pwm_clock(struct nvkm_therm *therm, int line)
static
void
nv50_sensor_setup
(
struct
nvkm_therm
*
therm
)
{
nv_mask
(
therm
,
0x20010
,
0x40000000
,
0x0
);
struct
nvkm_device
*
device
=
therm
->
subdev
.
device
;
nvkm_mask
(
device
,
0x20010
,
0x40000000
,
0x0
);
mdelay
(
20
);
/* wait for the temperature to stabilize */
}
...
...
@@ -124,10 +127,11 @@ static int
nv50_temp_get
(
struct
nvkm_therm
*
obj
)
{
struct
nvkm_therm_priv
*
therm
=
container_of
(
obj
,
typeof
(
*
therm
),
base
);
struct
nvkm_device
*
device
=
therm
->
base
.
subdev
.
device
;
struct
nvbios_therm_sensor
*
sensor
=
&
therm
->
bios_sensor
;
int
core_temp
;
core_temp
=
nv
_rd32
(
therm
,
0x20014
)
&
0x3fff
;
core_temp
=
nv
km_rd32
(
device
,
0x20014
)
&
0x3fff
;
/* if the slope or the offset is unset, do no use the sensor */
if
(
!
sensor
->
slope_div
||
!
sensor
->
slope_mult
||
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录