From b469d20bf4d26ccae514567eb8db4dafff1c0740 Mon Sep 17 00:00:00 2001 From: Philip Edelbrock Date: Fri, 18 Dec 1998 03:15:07 +0000 Subject: [PATCH] (Phil) Added access to 'beep' buzzer control registers via 'beep' file. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@87 7894878c-1315-0410-8ee3-d5d059ff63e0 --- kernel/chips/w83781d.c | 35 ++++++++++++++++++++++++++++++++++- kernel/include/sensors.h | 1 + src/sensors.h | 1 + src/w83781d.c | 35 ++++++++++++++++++++++++++++++++++- 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/kernel/chips/w83781d.c b/kernel/chips/w83781d.c index 12708c2c..4b42c965 100644 --- a/kernel/chips/w83781d.c +++ b/kernel/chips/w83781d.c @@ -65,6 +65,10 @@ #define W83781D_REG_ALARM1 0x41 #define W83781D_REG_ALARM2 0x42 +#define W83781D_REG_BEEP_CONFIG 0x4D +#define W83781D_REG_BEEP_INTS1 0x56 +#define W83781D_REG_BEEP_INTS2 0x57 + #define W83781D_REG_VID_FANDIV 0x47 #define W83781D_REG_CHIPID 0x58 @@ -181,6 +185,7 @@ struct w83781d_data { u8 fan_div[2]; /* Register encoding, shifted right */ u8 vid; /* Register encoding, combined */ u16 alarms; /* Register encoding, combined */ + u8 beep[3]; /* Register value of config and interrupt masks */ }; @@ -223,6 +228,8 @@ static void w83781d_vid(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); static void w83781d_alarms(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); +static void w83781d_beep(struct i2c_client *client, int operation, int ctl_name, + int *nrels_mag, long *results); static void w83781d_fan_div(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); @@ -287,6 +294,8 @@ static ctl_table w83781d_dir_table_template[] = { &sensors_sysctl_real, NULL, &w83781d_fan_div }, { W83781D_SYSCTL_ALARMS, "alarms", NULL, 0, 0644, NULL, &sensors_proc_real, &sensors_sysctl_real, NULL, &w83781d_alarms }, + { W83781D_SYSCTL_BEEP, "beep", NULL, 0, 0644, NULL, &sensors_proc_real, + &sensors_sysctl_real, NULL, &w83781d_beep }, { 0 } }; @@ -724,6 +733,9 @@ void w83781d_update_client(struct i2c_client *client) data->fan_div[1] = i >> 6; data->alarms = w83781d_read_value(client,W83781D_REG_ALARM1) + (w83781d_read_value(client,W83781D_REG_ALARM2) >> 8); + data->beep[0] = w83781d_read_value(client,W83781D_REG_BEEP_CONFIG); + data->beep[1] = w83781d_read_value(client,W83781D_REG_BEEP_INTS1); + data->beep[2] = w83781d_read_value(client,W83781D_REG_BEEP_INTS2); data->last_updated = jiffies; data->valid = 1; } @@ -845,7 +857,6 @@ void w83781d_temp(struct i2c_client *client, int operation, int ctl_name, } } -/* Change back! */ void w83781d_temp1(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { @@ -894,6 +905,28 @@ void w83781d_alarms(struct i2c_client *client, int operation, int ctl_name, } } +void w83781d_beep(struct i2c_client *client, int operation, int ctl_name, + int *nrels_mag, long *results) +{ + struct w83781d_data *data = client->data; + if (operation == SENSORS_PROC_REAL_INFO) + *nrels_mag = 0; + else if (operation == SENSORS_PROC_REAL_READ) { + w83781d_update_client(client); + results[0] = data->beep[0]; + results[1] = data->beep[1]; + results[2] = data->beep[2]; + *nrels_mag = 3; + } else if (operation == SENSORS_PROC_REAL_WRITE) { + data->beep[0] = results[0]; + w83781d_write_value(client,W83781D_REG_BEEP_CONFIG,data->beep[0]); + data->beep[1] = results[1]; + w83781d_write_value(client,W83781D_REG_BEEP_INTS1,data->beep[1]); + data->beep[2] = results[2]; + w83781d_write_value(client,W83781D_REG_BEEP_INTS2,data->beep[2]); + } +} + void w83781d_fan_div(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { diff --git a/kernel/include/sensors.h b/kernel/include/sensors.h index c7df6933..6ef8468c 100644 --- a/kernel/include/sensors.h +++ b/kernel/include/sensors.h @@ -148,6 +148,7 @@ struct sensors_chips_data { #define W83781D_SYSCTL_VID 1300 /* Volts * 100 */ #define W83781D_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ #define W83781D_SYSCTL_ALARMS 2001 /* bitvector */ +#define W83781D_SYSCTL_BEEP 2002 /* bitvector */ #define W83781D_ALARM_IN0 0x0001 #define W83781D_ALARM_IN1 0x0002 diff --git a/src/sensors.h b/src/sensors.h index c7df6933..6ef8468c 100644 --- a/src/sensors.h +++ b/src/sensors.h @@ -148,6 +148,7 @@ struct sensors_chips_data { #define W83781D_SYSCTL_VID 1300 /* Volts * 100 */ #define W83781D_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ #define W83781D_SYSCTL_ALARMS 2001 /* bitvector */ +#define W83781D_SYSCTL_BEEP 2002 /* bitvector */ #define W83781D_ALARM_IN0 0x0001 #define W83781D_ALARM_IN1 0x0002 diff --git a/src/w83781d.c b/src/w83781d.c index 12708c2c..4b42c965 100644 --- a/src/w83781d.c +++ b/src/w83781d.c @@ -65,6 +65,10 @@ #define W83781D_REG_ALARM1 0x41 #define W83781D_REG_ALARM2 0x42 +#define W83781D_REG_BEEP_CONFIG 0x4D +#define W83781D_REG_BEEP_INTS1 0x56 +#define W83781D_REG_BEEP_INTS2 0x57 + #define W83781D_REG_VID_FANDIV 0x47 #define W83781D_REG_CHIPID 0x58 @@ -181,6 +185,7 @@ struct w83781d_data { u8 fan_div[2]; /* Register encoding, shifted right */ u8 vid; /* Register encoding, combined */ u16 alarms; /* Register encoding, combined */ + u8 beep[3]; /* Register value of config and interrupt masks */ }; @@ -223,6 +228,8 @@ static void w83781d_vid(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); static void w83781d_alarms(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); +static void w83781d_beep(struct i2c_client *client, int operation, int ctl_name, + int *nrels_mag, long *results); static void w83781d_fan_div(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); @@ -287,6 +294,8 @@ static ctl_table w83781d_dir_table_template[] = { &sensors_sysctl_real, NULL, &w83781d_fan_div }, { W83781D_SYSCTL_ALARMS, "alarms", NULL, 0, 0644, NULL, &sensors_proc_real, &sensors_sysctl_real, NULL, &w83781d_alarms }, + { W83781D_SYSCTL_BEEP, "beep", NULL, 0, 0644, NULL, &sensors_proc_real, + &sensors_sysctl_real, NULL, &w83781d_beep }, { 0 } }; @@ -724,6 +733,9 @@ void w83781d_update_client(struct i2c_client *client) data->fan_div[1] = i >> 6; data->alarms = w83781d_read_value(client,W83781D_REG_ALARM1) + (w83781d_read_value(client,W83781D_REG_ALARM2) >> 8); + data->beep[0] = w83781d_read_value(client,W83781D_REG_BEEP_CONFIG); + data->beep[1] = w83781d_read_value(client,W83781D_REG_BEEP_INTS1); + data->beep[2] = w83781d_read_value(client,W83781D_REG_BEEP_INTS2); data->last_updated = jiffies; data->valid = 1; } @@ -845,7 +857,6 @@ void w83781d_temp(struct i2c_client *client, int operation, int ctl_name, } } -/* Change back! */ void w83781d_temp1(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { @@ -894,6 +905,28 @@ void w83781d_alarms(struct i2c_client *client, int operation, int ctl_name, } } +void w83781d_beep(struct i2c_client *client, int operation, int ctl_name, + int *nrels_mag, long *results) +{ + struct w83781d_data *data = client->data; + if (operation == SENSORS_PROC_REAL_INFO) + *nrels_mag = 0; + else if (operation == SENSORS_PROC_REAL_READ) { + w83781d_update_client(client); + results[0] = data->beep[0]; + results[1] = data->beep[1]; + results[2] = data->beep[2]; + *nrels_mag = 3; + } else if (operation == SENSORS_PROC_REAL_WRITE) { + data->beep[0] = results[0]; + w83781d_write_value(client,W83781D_REG_BEEP_CONFIG,data->beep[0]); + data->beep[1] = results[1]; + w83781d_write_value(client,W83781D_REG_BEEP_INTS1,data->beep[1]); + data->beep[2] = results[2]; + w83781d_write_value(client,W83781D_REG_BEEP_INTS2,data->beep[2]); + } +} + void w83781d_fan_div(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) {