Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
cb9fa626
Commit
cb9fa626
authored
Aug 14, 2011
by
Ben Skeggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drm/nv50/pm: add support for pwm fan control
Signed-off-by:
Ben Skeggs
<
bskeggs@redhat.com
>
parent
8f27c543
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
2 deletions
+85
-2
drivers/gpu/drm/nouveau/nouveau_pm.c
drivers/gpu/drm/nouveau/nouveau_pm.c
+5
-2
drivers/gpu/drm/nouveau/nouveau_pm.h
drivers/gpu/drm/nouveau/nouveau_pm.h
+2
-0
drivers/gpu/drm/nouveau/nouveau_state.c
drivers/gpu/drm/nouveau/nouveau_state.c
+4
-0
drivers/gpu/drm/nouveau/nv50_pm.c
drivers/gpu/drm/nouveau/nv50_pm.c
+74
-0
No files found.
drivers/gpu/drm/nouveau/nouveau_pm.c
View file @
cb9fa626
...
@@ -167,8 +167,11 @@ nouveau_pm_perflvl_get(struct drm_device *dev, struct nouveau_pm_level *perflvl)
...
@@ -167,8 +167,11 @@ nouveau_pm_perflvl_get(struct drm_device *dev, struct nouveau_pm_level *perflvl)
}
}
}
}
if
(
pm
->
fanspeed_get
)
if
(
pm
->
fanspeed_get
)
{
perflvl
->
fanspeed
=
pm
->
fanspeed_get
(
dev
);
ret
=
pm
->
fanspeed_get
(
dev
);
if
(
ret
>
0
)
perflvl
->
fanspeed
=
ret
;
}
return
0
;
return
0
;
}
}
...
...
drivers/gpu/drm/nouveau/nouveau_pm.h
View file @
cb9fa626
...
@@ -66,6 +66,8 @@ int nv50_pm_clock_get(struct drm_device *, u32 id);
...
@@ -66,6 +66,8 @@ int nv50_pm_clock_get(struct drm_device *, u32 id);
void
*
nv50_pm_clock_pre
(
struct
drm_device
*
,
struct
nouveau_pm_level
*
,
void
*
nv50_pm_clock_pre
(
struct
drm_device
*
,
struct
nouveau_pm_level
*
,
u32
id
,
int
khz
);
u32
id
,
int
khz
);
void
nv50_pm_clock_set
(
struct
drm_device
*
,
void
*
);
void
nv50_pm_clock_set
(
struct
drm_device
*
,
void
*
);
int
nv50_pm_fanspeed_get
(
struct
drm_device
*
);
int
nv50_pm_fanspeed_set
(
struct
drm_device
*
,
int
percent
);
/* nva3_pm.c */
/* nva3_pm.c */
int
nva3_pm_clocks_get
(
struct
drm_device
*
,
struct
nouveau_pm_level
*
);
int
nva3_pm_clocks_get
(
struct
drm_device
*
,
struct
nouveau_pm_level
*
);
...
...
drivers/gpu/drm/nouveau/nouveau_state.c
View file @
cb9fa626
...
@@ -386,6 +386,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
...
@@ -386,6 +386,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
engine
->
pm
.
temp_get
=
nv84_temp_get
;
engine
->
pm
.
temp_get
=
nv84_temp_get
;
else
else
engine
->
pm
.
temp_get
=
nv40_temp_get
;
engine
->
pm
.
temp_get
=
nv40_temp_get
;
engine
->
pm
.
fanspeed_get
=
nv50_pm_fanspeed_get
;
engine
->
pm
.
fanspeed_set
=
nv50_pm_fanspeed_set
;
engine
->
vram
.
init
=
nv50_vram_init
;
engine
->
vram
.
init
=
nv50_vram_init
;
engine
->
vram
.
takedown
=
nv50_vram_fini
;
engine
->
vram
.
takedown
=
nv50_vram_fini
;
engine
->
vram
.
get
=
nv50_vram_new
;
engine
->
vram
.
get
=
nv50_vram_new
;
...
@@ -441,6 +443,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
...
@@ -441,6 +443,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
engine
->
pm
.
clocks_get
=
nvc0_pm_clocks_get
;
engine
->
pm
.
clocks_get
=
nvc0_pm_clocks_get
;
engine
->
pm
.
voltage_get
=
nouveau_voltage_gpio_get
;
engine
->
pm
.
voltage_get
=
nouveau_voltage_gpio_get
;
engine
->
pm
.
voltage_set
=
nouveau_voltage_gpio_set
;
engine
->
pm
.
voltage_set
=
nouveau_voltage_gpio_set
;
engine
->
pm
.
fanspeed_get
=
nv50_pm_fanspeed_get
;
engine
->
pm
.
fanspeed_set
=
nv50_pm_fanspeed_set
;
break
;
break
;
case
0xd0
:
case
0xd0
:
engine
->
instmem
.
init
=
nvc0_instmem_init
;
engine
->
instmem
.
init
=
nvc0_instmem_init
;
...
...
drivers/gpu/drm/nouveau/nv50_pm.c
View file @
cb9fa626
...
@@ -144,3 +144,77 @@ nv50_pm_clock_set(struct drm_device *dev, void *pre_state)
...
@@ -144,3 +144,77 @@ nv50_pm_clock_set(struct drm_device *dev, void *pre_state)
kfree
(
state
);
kfree
(
state
);
}
}
struct
pwm_info
{
int
id
;
int
invert
;
u8
tag
;
u32
ctrl
;
int
line
;
};
static
int
nv50_pm_fanspeed_pwm
(
struct
drm_device
*
dev
,
struct
pwm_info
*
pwm
)
{
struct
dcb_gpio_entry
*
gpio
;
gpio
=
nouveau_bios_gpio_entry
(
dev
,
0x09
);
if
(
gpio
)
{
pwm
->
tag
=
gpio
->
tag
;
pwm
->
id
=
(
gpio
->
line
==
9
)
?
1
:
0
;
pwm
->
invert
=
gpio
->
state
[
0
]
&
1
;
pwm
->
ctrl
=
(
gpio
->
line
<
16
)
?
0xe100
:
0xe28c
;
pwm
->
line
=
(
gpio
->
line
&
0xf
);
return
0
;
}
return
-
ENOENT
;
}
int
nv50_pm_fanspeed_get
(
struct
drm_device
*
dev
)
{
struct
drm_nouveau_private
*
dev_priv
=
dev
->
dev_private
;
struct
nouveau_gpio_engine
*
pgpio
=
&
dev_priv
->
engine
.
gpio
;
struct
pwm_info
pwm
;
int
ret
;
ret
=
nv50_pm_fanspeed_pwm
(
dev
,
&
pwm
);
if
(
ret
)
return
ret
;
if
(
nv_rd32
(
dev
,
pwm
.
ctrl
)
&
(
0x00000001
<<
pwm
.
line
))
{
u32
divs
=
nv_rd32
(
dev
,
0x00e114
+
(
pwm
.
id
*
8
));
u32
duty
=
nv_rd32
(
dev
,
0x00e118
+
(
pwm
.
id
*
8
));
if
(
divs
)
{
divs
=
max
(
divs
,
duty
);
if
(
pwm
.
invert
)
duty
=
divs
-
duty
;
return
(
duty
*
100
)
/
divs
;
}
return
0
;
}
return
pgpio
->
get
(
dev
,
pwm
.
tag
)
*
100
;
}
int
nv50_pm_fanspeed_set
(
struct
drm_device
*
dev
,
int
percent
)
{
struct
pwm_info
pwm
;
u32
divs
,
duty
;
int
ret
;
ret
=
nv50_pm_fanspeed_pwm
(
dev
,
&
pwm
);
if
(
ret
)
return
ret
;
divs
=
nv_rd32
(
dev
,
0x00e114
+
(
pwm
.
id
*
8
));
duty
=
((
divs
*
percent
)
+
99
)
/
100
;
if
(
pwm
.
invert
)
duty
=
divs
-
duty
;
nv_mask
(
dev
,
pwm
.
ctrl
,
0x00010001
<<
pwm
.
line
,
0x00000001
<<
pwm
.
line
);
nv_wr32
(
dev
,
0x00e118
+
(
pwm
.
id
*
8
),
0x80000000
|
duty
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment