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
84d19d92
Commit
84d19d92
authored
Dec 04, 2012
by
Guenter Roeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hwmon: (nct6775) Add power management support
Signed-off-by:
Guenter Roeck
<
linux@roeck-us.net
>
parent
47ece964
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
drivers/hwmon/nct6775.c
drivers/hwmon/nct6775.c
+86
-0
No files found.
drivers/hwmon/nct6775.c
View file @
84d19d92
...
...
@@ -511,6 +511,12 @@ struct nct6775_data {
u16
have_temp
;
u16
have_temp_fixed
;
u16
have_in
;
#ifdef CONFIG_PM
/* Remember extra register values over suspend/resume */
u8
vbat
;
u8
fandiv1
;
u8
fandiv2
;
#endif
};
struct
nct6775_sio_data
{
...
...
@@ -2270,10 +2276,90 @@ static int nct6775_remove(struct platform_device *pdev)
return
0
;
}
#ifdef CONFIG_PM
static
int
nct6775_suspend
(
struct
device
*
dev
)
{
struct
nct6775_data
*
data
=
nct6775_update_device
(
dev
);
struct
nct6775_sio_data
*
sio_data
=
dev
->
platform_data
;
mutex_lock
(
&
data
->
update_lock
);
data
->
vbat
=
nct6775_read_value
(
data
,
data
->
REG_VBAT
);
if
(
sio_data
->
kind
==
nct6775
)
{
data
->
fandiv1
=
nct6775_read_value
(
data
,
NCT6775_REG_FANDIV1
);
data
->
fandiv2
=
nct6775_read_value
(
data
,
NCT6775_REG_FANDIV2
);
}
mutex_unlock
(
&
data
->
update_lock
);
return
0
;
}
static
int
nct6775_resume
(
struct
device
*
dev
)
{
struct
nct6775_data
*
data
=
dev_get_drvdata
(
dev
);
struct
nct6775_sio_data
*
sio_data
=
dev
->
platform_data
;
int
i
,
j
;
mutex_lock
(
&
data
->
update_lock
);
data
->
bank
=
0xff
;
/* Force initial bank selection */
/* Restore limits */
for
(
i
=
0
;
i
<
data
->
in_num
;
i
++
)
{
if
(
!
(
data
->
have_in
&
(
1
<<
i
)))
continue
;
nct6775_write_value
(
data
,
data
->
REG_IN_MINMAX
[
0
][
i
],
data
->
in
[
i
][
1
]);
nct6775_write_value
(
data
,
data
->
REG_IN_MINMAX
[
1
][
i
],
data
->
in
[
i
][
2
]);
}
for
(
i
=
0
;
i
<
5
;
i
++
)
{
if
(
!
(
data
->
has_fan_min
&
(
1
<<
i
)))
continue
;
nct6775_write_value
(
data
,
data
->
REG_FAN_MIN
[
i
],
data
->
fan_min
[
i
]);
}
for
(
i
=
0
;
i
<
NUM_TEMP
;
i
++
)
{
if
(
!
(
data
->
have_temp
&
(
1
<<
i
)))
continue
;
for
(
j
=
1
;
j
<
4
;
j
++
)
if
(
data
->
reg_temp
[
j
][
i
])
nct6775_write_temp
(
data
,
data
->
reg_temp
[
j
][
i
],
data
->
temp
[
j
][
i
]);
}
/* Restore other settings */
nct6775_write_value
(
data
,
data
->
REG_VBAT
,
data
->
vbat
);
if
(
sio_data
->
kind
==
nct6775
)
{
nct6775_write_value
(
data
,
NCT6775_REG_FANDIV1
,
data
->
fandiv1
);
nct6775_write_value
(
data
,
NCT6775_REG_FANDIV2
,
data
->
fandiv2
);
}
/* Force re-reading all values */
data
->
valid
=
false
;
mutex_unlock
(
&
data
->
update_lock
);
return
0
;
}
static
const
struct
dev_pm_ops
nct6775_dev_pm_ops
=
{
.
suspend
=
nct6775_suspend
,
.
resume
=
nct6775_resume
,
};
#define NCT6775_DEV_PM_OPS (&nct6775_dev_pm_ops)
#else
#define NCT6775_DEV_PM_OPS NULL
#endif
/* CONFIG_PM */
static
struct
platform_driver
nct6775_driver
=
{
.
driver
=
{
.
owner
=
THIS_MODULE
,
.
name
=
DRVNAME
,
.
pm
=
NCT6775_DEV_PM_OPS
,
},
.
probe
=
nct6775_probe
,
.
remove
=
nct6775_remove
,
...
...
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