mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-31 14:25:39 +00:00
Many PWM fixes:
Fix enable; implement disable; preserve clock select bit; /proc value now 0-255; use correct bits in register git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2536 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -117,8 +117,9 @@ static inline u8 MIN_TO_REG(long rpm, int div)
|
|||||||
983040/(((val)-preload)*(div)))
|
983040/(((val)-preload)*(div)))
|
||||||
#define DIV_FROM_REG(val) (1 << (val))
|
#define DIV_FROM_REG(val) (1 << (val))
|
||||||
#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)
|
#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)
|
||||||
#define PWM_FROM_REG(val) ((((val) & 0x7f) * 1005) / 640)
|
/* reg is 6 middle bits; /proc is 8 bits */
|
||||||
#define PWM_TO_REG(val) SENSORS_LIMIT((((val) * 645) / 1000), 0, 63)
|
#define PWM_FROM_REG(val) (((val) << 1) & 0xfc)
|
||||||
|
#define PWM_TO_REG(val) (((SENSORS_LIMIT((val), 0, 255)) >> 1) & 0x7e)
|
||||||
|
|
||||||
struct smsc47m1_data {
|
struct smsc47m1_data {
|
||||||
struct i2c_client client;
|
struct i2c_client client;
|
||||||
@@ -458,22 +459,27 @@ void smsc47m1_pwm(struct i2c_client *client, int operation, int ctl_name,
|
|||||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||||
smsc47m1_update_client(client);
|
smsc47m1_update_client(client);
|
||||||
results[0] = PWM_FROM_REG(data->pwm[nr - 1]);
|
results[0] = PWM_FROM_REG(data->pwm[nr - 1]);
|
||||||
results[1] = data->pwm[nr - 1] >> 7;
|
results[1] = data->pwm[nr - 1] & 0x01;
|
||||||
*nrels_mag = 2;
|
*nrels_mag = 2;
|
||||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||||
if (*nrels_mag >= 1) {
|
if (*nrels_mag >= 1) {
|
||||||
data->pwm[nr - 1] &= 0x80;
|
data->pwm[nr - 1] &= 0x81;
|
||||||
data->pwm[nr - 1] |= PWM_TO_REG(results[0]);
|
data->pwm[nr - 1] |= PWM_TO_REG(results[0]);
|
||||||
if (*nrels_mag >= 2) {
|
if (*nrels_mag >= 2) {
|
||||||
if(results[1] && (!(data->pwm[nr-1] & 0x80))) {
|
if(results[1] && (!(data->pwm[nr-1] & 0x01))) {
|
||||||
/* output PWM */
|
/* enable PWM */
|
||||||
|
/* hope BIOS did it already
|
||||||
smsc47m1_write_value(client,
|
smsc47m1_write_value(client,
|
||||||
SMSC47M1_REG_PPIN(nr), 0x04);
|
SMSC47M1_REG_PPIN(nr), 0x04);
|
||||||
data->pwm[nr - 1] |= 0x80;
|
*/
|
||||||
|
data->pwm[nr - 1] |= 0x01;
|
||||||
|
} else if((!results[1]) && (data->pwm[nr-1] & 0x01)) {
|
||||||
|
/* disable PWM */
|
||||||
|
data->pwm[nr - 1] &= 0xfe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr),
|
smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr),
|
||||||
data->pwm[nr - 1]);
|
data->pwm[nr - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user