mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-19 19:40:49 +00:00
`indent -kr -i8' on all kernel sources
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@707 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
83d5845df5
commit
6a2c82b491
29 files changed
+10217
-9155
No files matched your search
+322
-292
@@ -38,14 +38,15 @@
|
||||
#endif
|
||||
|
||||
/* Addresses to scan */
|
||||
static unsigned short normal_i2c[] = {SENSORS_I2C_END};
|
||||
static unsigned short normal_i2c_range[] = {0x18,0x1a,0x29,0x2b,
|
||||
0x4c,0x4e,SENSORS_I2C_END};
|
||||
static unsigned int normal_isa[] = {SENSORS_ISA_END};
|
||||
static unsigned int normal_isa_range[] = {SENSORS_ISA_END};
|
||||
static unsigned short normal_i2c[] = { SENSORS_I2C_END };
|
||||
static unsigned short normal_i2c_range[] = { 0x18, 0x1a, 0x29, 0x2b,
|
||||
0x4c, 0x4e, SENSORS_I2C_END
|
||||
};
|
||||
static unsigned int normal_isa[] = { SENSORS_ISA_END };
|
||||
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
|
||||
|
||||
/* Insmod parameters */
|
||||
SENSORS_INSMOD_6(adm1021,max1617,max1617a,thmc10,lm84,gl523sm);
|
||||
SENSORS_INSMOD_6(adm1021, max1617, max1617a, thmc10, lm84, gl523sm);
|
||||
|
||||
/* adm1021 constants specified below */
|
||||
|
||||
@@ -54,9 +55,9 @@ SENSORS_INSMOD_6(adm1021,max1617,max1617a,thmc10,lm84,gl523sm);
|
||||
#define ADM1021_REG_TEMP 0x00
|
||||
#define ADM1021_REG_REMOTE_TEMP 0x01
|
||||
#define ADM1021_REG_STATUS 0x02
|
||||
#define ADM1021_REG_MAN_ID 0x0FE /* 0x41 = AMD, 0x49 = TI, 0x4D = Maxim, 0x23 = Genesys */
|
||||
#define ADM1021_REG_DEV_ID 0x0FF /* ADM1021 */
|
||||
#define ADM1021_REG_DIE_CODE 0x0FF /* MAX1617A */
|
||||
#define ADM1021_REG_MAN_ID 0x0FE /* 0x41 = AMD, 0x49 = TI, 0x4D = Maxim, 0x23 = Genesys */
|
||||
#define ADM1021_REG_DEV_ID 0x0FF /* ADM1021 */
|
||||
#define ADM1021_REG_DIE_CODE 0x0FF /* MAX1617A */
|
||||
/* These use different addresses for reading/writing */
|
||||
#define ADM1021_REG_CONFIG_R 0x03
|
||||
#define ADM1021_REG_CONFIG_W 0x09
|
||||
@@ -95,61 +96,63 @@ clearing it. Weird, ey? --Phil */
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct adm1021_data {
|
||||
int sysctl_id;
|
||||
enum chips type;
|
||||
int sysctl_id;
|
||||
enum chips type;
|
||||
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
|
||||
u8 temp,temp_os,temp_hyst; /* Register values */
|
||||
u8 remote_temp,remote_temp_os,remote_temp_hyst,alarms,die_code;
|
||||
u8 temp, temp_os, temp_hyst; /* Register values */
|
||||
u8 remote_temp, remote_temp_os, remote_temp_hyst, alarms, die_code;
|
||||
};
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init sensors_adm1021_init(void);
|
||||
int __init sensors_adm1021_init(void);
|
||||
static int __init adm1021_cleanup(void);
|
||||
static int adm1021_attach_adapter(struct i2c_adapter *adapter);
|
||||
static int adm1021_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static int adm1021_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static void adm1021_init_client(struct i2c_client *client);
|
||||
static int adm1021_detach_client(struct i2c_client *client);
|
||||
static int adm1021_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
static void adm1021_inc_use (struct i2c_client *client);
|
||||
static void adm1021_dec_use (struct i2c_client *client);
|
||||
void *arg);
|
||||
static void adm1021_inc_use(struct i2c_client *client);
|
||||
static void adm1021_dec_use(struct i2c_client *client);
|
||||
static int adm1021_read_value(struct i2c_client *client, u8 reg);
|
||||
static int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value);
|
||||
static void adm1021_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void adm1021_remote_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void adm1021_alarms(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void adm1021_die_code(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static int adm1021_write_value(struct i2c_client *client, u8 reg,
|
||||
u16 value);
|
||||
static void adm1021_temp(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void adm1021_remote_temp(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag,
|
||||
long *results);
|
||||
static void adm1021_alarms(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void adm1021_die_code(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void adm1021_update_client(struct i2c_client *client);
|
||||
|
||||
|
||||
/* This is the driver that will be inserted */
|
||||
static struct i2c_driver adm1021_driver = {
|
||||
/* name */ "ADM1021, MAX1617 sensor driver",
|
||||
/* id */ I2C_DRIVERID_ADM1021,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &adm1021_attach_adapter,
|
||||
/* detach_client */ &adm1021_detach_client,
|
||||
/* command */ &adm1021_command,
|
||||
/* inc_use */ &adm1021_inc_use,
|
||||
/* dec_use */ &adm1021_dec_use
|
||||
/* name */ "ADM1021, MAX1617 sensor driver",
|
||||
/* id */ I2C_DRIVERID_ADM1021,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &adm1021_attach_adapter,
|
||||
/* detach_client */ &adm1021_detach_client,
|
||||
/* command */ &adm1021_command,
|
||||
/* inc_use */ &adm1021_inc_use,
|
||||
/* dec_use */ &adm1021_dec_use
|
||||
};
|
||||
|
||||
/* These files are created for each detected adm1021. This is just a template;
|
||||
@@ -158,25 +161,25 @@ static struct i2c_driver adm1021_driver = {
|
||||
is done through one of the 'extra' fields which are initialized
|
||||
when a new copy is allocated. */
|
||||
static ctl_table adm1021_dir_table_template[] = {
|
||||
{ ADM1021_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_temp },
|
||||
{ADM1021_SYSCTL_REMOTE_TEMP, "remote_temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_remote_temp },
|
||||
{ADM1021_SYSCTL_DIE_CODE, "die_code", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_die_code },
|
||||
{ADM1021_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_alarms },
|
||||
{ 0 }
|
||||
{ADM1021_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_temp},
|
||||
{ADM1021_SYSCTL_REMOTE_TEMP, "remote_temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_remote_temp},
|
||||
{ADM1021_SYSCTL_DIE_CODE, "die_code", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_die_code},
|
||||
{ADM1021_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_alarms},
|
||||
{0}
|
||||
};
|
||||
|
||||
static ctl_table adm1021_max_dir_table_template[] = {
|
||||
{ ADM1021_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_temp },
|
||||
{ADM1021_SYSCTL_REMOTE_TEMP, "remote_temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_remote_temp },
|
||||
{ADM1021_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_alarms },
|
||||
{ 0 }
|
||||
{ADM1021_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_temp},
|
||||
{ADM1021_SYSCTL_REMOTE_TEMP, "remote_temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_remote_temp},
|
||||
{ADM1021_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &adm1021_alarms},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
@@ -190,166 +193,177 @@ static int adm1021_id = 0;
|
||||
|
||||
int adm1021_attach_adapter(struct i2c_adapter *adapter)
|
||||
{
|
||||
return sensors_detect(adapter,&addr_data,adm1021_detect);
|
||||
return sensors_detect(adapter, &addr_data, adm1021_detect);
|
||||
}
|
||||
|
||||
static int adm1021_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
{
|
||||
int i;
|
||||
struct i2c_client *new_client;
|
||||
struct adm1021_data *data;
|
||||
int err=0;
|
||||
const char *type_name = "";
|
||||
const char *client_name = "";
|
||||
static int adm1021_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
{
|
||||
int i;
|
||||
struct i2c_client *new_client;
|
||||
struct adm1021_data *data;
|
||||
int err = 0;
|
||||
const char *type_name = "";
|
||||
const char *client_name = "";
|
||||
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
#ifdef DEBUG
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk("adm1021.o: adm1021_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk
|
||||
("adm1021.o: adm1021_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
goto ERROR0;
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
goto ERROR0;
|
||||
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access adm1021_{read,write}_value. */
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access adm1021_{read,write}_value. */
|
||||
|
||||
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct adm1021_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct adm1021_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
data = (struct adm1021_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &adm1021_driver;
|
||||
new_client->flags = 0;
|
||||
data = (struct adm1021_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &adm1021_driver;
|
||||
new_client->flags = 0;
|
||||
|
||||
/* Now, we do the remaining detection. */
|
||||
/* Now, we do the remaining detection. */
|
||||
|
||||
if (kind < 0) {
|
||||
if ((adm1021_read_value(new_client,ADM1021_REG_STATUS) & 0x03) != 0x00)
|
||||
goto ERROR1;
|
||||
}
|
||||
if (kind < 0) {
|
||||
if (
|
||||
(adm1021_read_value(new_client, ADM1021_REG_STATUS) &
|
||||
0x03) != 0x00)
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
/* Determine the chip type. */
|
||||
|
||||
if (kind <= 0) {
|
||||
i = adm1021_read_value(new_client,ADM1021_REG_MAN_ID);
|
||||
if (i == 0x41)
|
||||
kind = adm1021;
|
||||
else if (i == 0x49)
|
||||
kind = thmc10;
|
||||
else if (i == 0x23)
|
||||
kind = gl523sm;
|
||||
else if ((i== 0x4d) &&
|
||||
(adm1021_read_value(new_client,ADM1021_REG_DEV_ID) == 0x01))
|
||||
kind = max1617a;
|
||||
/* LM84 Mfr ID in a different place */
|
||||
else if (adm1021_read_value(new_client,ADM1021_REG_CONV_RATE_R) == 0x00)
|
||||
kind = lm84;
|
||||
else
|
||||
kind = max1617;
|
||||
}
|
||||
/* Determine the chip type. */
|
||||
|
||||
if (kind == max1617) {
|
||||
type_name = "max1617";
|
||||
client_name = "MAX1617 chip";
|
||||
} else if (kind == max1617a) {
|
||||
type_name = "max1617a";
|
||||
client_name = "MAX1617A chip";
|
||||
} else if (kind == adm1021) {
|
||||
type_name = "adm1021";
|
||||
client_name = "ADM1021 chip";
|
||||
} else if (kind == thmc10) {
|
||||
type_name = "thmc10";
|
||||
client_name = "THMC10 chip";
|
||||
} else {
|
||||
if (kind <= 0) {
|
||||
i = adm1021_read_value(new_client, ADM1021_REG_MAN_ID);
|
||||
if (i == 0x41)
|
||||
kind = adm1021;
|
||||
else if (i == 0x49)
|
||||
kind = thmc10;
|
||||
else if (i == 0x23)
|
||||
kind = gl523sm;
|
||||
else if ((i == 0x4d) &&
|
||||
(adm1021_read_value
|
||||
(new_client, ADM1021_REG_DEV_ID) == 0x01))
|
||||
kind = max1617a;
|
||||
/* LM84 Mfr ID in a different place */
|
||||
else
|
||||
if (adm1021_read_value
|
||||
(new_client, ADM1021_REG_CONV_RATE_R) == 0x00)
|
||||
kind = lm84;
|
||||
else
|
||||
kind = max1617;
|
||||
}
|
||||
|
||||
if (kind == max1617) {
|
||||
type_name = "max1617";
|
||||
client_name = "MAX1617 chip";
|
||||
} else if (kind == max1617a) {
|
||||
type_name = "max1617a";
|
||||
client_name = "MAX1617A chip";
|
||||
} else if (kind == adm1021) {
|
||||
type_name = "adm1021";
|
||||
client_name = "ADM1021 chip";
|
||||
} else if (kind == thmc10) {
|
||||
type_name = "thmc10";
|
||||
client_name = "THMC10 chip";
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
printk("adm1021.o: Internal error: unknown kind (%d)?!?",kind);
|
||||
printk("adm1021.o: Internal error: unknown kind (%d)?!?",
|
||||
kind);
|
||||
#endif
|
||||
goto ERROR1;
|
||||
}
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name,client_name);
|
||||
data->type = kind;
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name, client_name);
|
||||
data->type = kind;
|
||||
|
||||
new_client->id = adm1021_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
new_client->id = adm1021_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client,
|
||||
type_name,
|
||||
data->type==adm1021?adm1021_dir_table_template:
|
||||
adm1021_max_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client,
|
||||
type_name,
|
||||
data->type ==
|
||||
adm1021 ?
|
||||
adm1021_dir_table_template :
|
||||
adm1021_max_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
|
||||
/* Initialize the ADM1021 chip */
|
||||
adm1021_init_client(new_client);
|
||||
return 0;
|
||||
/* Initialize the ADM1021 chip */
|
||||
adm1021_init_client(new_client);
|
||||
return 0;
|
||||
|
||||
/* OK, this is not exactly good programming practice, usually. But it is
|
||||
very code-efficient in this case. */
|
||||
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
}
|
||||
|
||||
void adm1021_init_client(struct i2c_client *client)
|
||||
{
|
||||
/* Initialize the adm1021 chip */
|
||||
adm1021_write_value(client,ADM1021_REG_TOS_W,
|
||||
TEMP_TO_REG(adm1021_INIT_TOS));
|
||||
adm1021_write_value(client,ADM1021_REG_THYST_W,
|
||||
TEMP_TO_REG(adm1021_INIT_THYST));
|
||||
adm1021_write_value(client,ADM1021_REG_REMOTE_TOS_W,
|
||||
TEMP_TO_REG(adm1021_INIT_REMOTE_TOS));
|
||||
adm1021_write_value(client,ADM1021_REG_REMOTE_THYST_W,
|
||||
TEMP_TO_REG(adm1021_INIT_REMOTE_THYST));
|
||||
/* Enable ADC and disable suspend mode */
|
||||
adm1021_write_value(client,ADM1021_REG_CONFIG_W,0);
|
||||
/* Set Conversion rate to 1/sec (this can be tinkered with) */
|
||||
adm1021_write_value(client,ADM1021_REG_CONV_RATE_W,0x04);
|
||||
/* Initialize the adm1021 chip */
|
||||
adm1021_write_value(client, ADM1021_REG_TOS_W,
|
||||
TEMP_TO_REG(adm1021_INIT_TOS));
|
||||
adm1021_write_value(client, ADM1021_REG_THYST_W,
|
||||
TEMP_TO_REG(adm1021_INIT_THYST));
|
||||
adm1021_write_value(client, ADM1021_REG_REMOTE_TOS_W,
|
||||
TEMP_TO_REG(adm1021_INIT_REMOTE_TOS));
|
||||
adm1021_write_value(client, ADM1021_REG_REMOTE_THYST_W,
|
||||
TEMP_TO_REG(adm1021_INIT_REMOTE_THYST));
|
||||
/* Enable ADC and disable suspend mode */
|
||||
adm1021_write_value(client, ADM1021_REG_CONFIG_W, 0);
|
||||
/* Set Conversion rate to 1/sec (this can be tinkered with) */
|
||||
adm1021_write_value(client, ADM1021_REG_CONV_RATE_W, 0x04);
|
||||
}
|
||||
|
||||
int adm1021_detach_client(struct i2c_client *client)
|
||||
{
|
||||
|
||||
int err;
|
||||
int err;
|
||||
|
||||
sensors_deregister_entry(((struct adm1021_data *)(client->data))->sysctl_id);
|
||||
sensors_deregister_entry(((struct adm1021_data *) (client->data))->
|
||||
sysctl_id);
|
||||
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk("adm1021.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk
|
||||
("adm1021.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
kfree(client);
|
||||
kfree(client);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -357,188 +371,204 @@ int adm1021_detach_client(struct i2c_client *client)
|
||||
/* No commands defined yet */
|
||||
int adm1021_command(struct i2c_client *client, unsigned int cmd, void *arg)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void adm1021_inc_use (struct i2c_client *client)
|
||||
void adm1021_inc_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
void adm1021_dec_use (struct i2c_client *client)
|
||||
void adm1021_dec_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* All registers are byte-sized */
|
||||
int adm1021_read_value(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
return i2c_smbus_read_byte_data(client,reg);
|
||||
return i2c_smbus_read_byte_data(client, reg);
|
||||
}
|
||||
|
||||
int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value)
|
||||
{
|
||||
return i2c_smbus_write_byte_data(client,reg,value);
|
||||
return i2c_smbus_write_byte_data(client, reg, value);
|
||||
}
|
||||
|
||||
void adm1021_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct adm1021_data *data = client->data;
|
||||
struct adm1021_data *data = client->data;
|
||||
|
||||
down(&data->update_lock);
|
||||
down(&data->update_lock);
|
||||
|
||||
if ((jiffies - data->last_updated > HZ+HZ/2 ) ||
|
||||
(jiffies < data->last_updated) || ! data->valid) {
|
||||
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
|
||||
(jiffies < data->last_updated) || !data->valid) {
|
||||
|
||||
#ifdef DEBUG
|
||||
printk("Starting adm1021 update\n");
|
||||
printk("Starting adm1021 update\n");
|
||||
#endif
|
||||
|
||||
data->temp = adm1021_read_value(client,ADM1021_REG_TEMP);
|
||||
data->temp_os = adm1021_read_value(client,ADM1021_REG_TOS_R);
|
||||
data->temp_hyst = adm1021_read_value(client,ADM1021_REG_THYST_R);
|
||||
data->remote_temp = adm1021_read_value(client,ADM1021_REG_REMOTE_TEMP);
|
||||
data->remote_temp_os = adm1021_read_value(client,ADM1021_REG_REMOTE_TOS_R);
|
||||
data->remote_temp_hyst = adm1021_read_value(client,ADM1021_REG_REMOTE_THYST_R);
|
||||
data->alarms = adm1021_read_value(client,ADM1021_REG_STATUS) & 0xec;
|
||||
if (data->type == adm1021)
|
||||
data->die_code = adm1021_read_value(client,ADM1021_REG_DIE_CODE);
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
data->temp = adm1021_read_value(client, ADM1021_REG_TEMP);
|
||||
data->temp_os =
|
||||
adm1021_read_value(client, ADM1021_REG_TOS_R);
|
||||
data->temp_hyst =
|
||||
adm1021_read_value(client, ADM1021_REG_THYST_R);
|
||||
data->remote_temp =
|
||||
adm1021_read_value(client, ADM1021_REG_REMOTE_TEMP);
|
||||
data->remote_temp_os =
|
||||
adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R);
|
||||
data->remote_temp_hyst =
|
||||
adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R);
|
||||
data->alarms =
|
||||
adm1021_read_value(client, ADM1021_REG_STATUS) & 0xec;
|
||||
if (data->type == adm1021)
|
||||
data->die_code =
|
||||
adm1021_read_value(client,
|
||||
ADM1021_REG_DIE_CODE);
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
up(&data->update_lock);
|
||||
up(&data->update_lock);
|
||||
}
|
||||
|
||||
|
||||
void adm1021_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
struct adm1021_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
adm1021_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->temp_os);
|
||||
results[1] = TEMP_FROM_REG(data->temp_hyst);
|
||||
results[2] = TEMP_FROM_REG(data->temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->temp_os = TEMP_TO_REG(results[0]);
|
||||
adm1021_write_value(client,ADM1021_REG_TOS_W,data->temp_os);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->temp_hyst = TEMP_TO_REG(results[1]);
|
||||
adm1021_write_value(client,ADM1021_REG_THYST_W,data->temp_hyst);
|
||||
}
|
||||
}
|
||||
struct adm1021_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
adm1021_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->temp_os);
|
||||
results[1] = TEMP_FROM_REG(data->temp_hyst);
|
||||
results[2] = TEMP_FROM_REG(data->temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->temp_os = TEMP_TO_REG(results[0]);
|
||||
adm1021_write_value(client, ADM1021_REG_TOS_W,
|
||||
data->temp_os);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->temp_hyst = TEMP_TO_REG(results[1]);
|
||||
adm1021_write_value(client, ADM1021_REG_THYST_W,
|
||||
data->temp_hyst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void adm1021_remote_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void adm1021_remote_temp(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
struct adm1021_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
adm1021_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->remote_temp_os);
|
||||
results[1] = TEMP_FROM_REG(data->remote_temp_hyst);
|
||||
results[2] = TEMP_FROM_REG(data->remote_temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->remote_temp_os = TEMP_TO_REG(results[0]);
|
||||
adm1021_write_value(client,ADM1021_REG_REMOTE_TOS_W,data->remote_temp_os);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->remote_temp_hyst = TEMP_TO_REG(results[1]);
|
||||
adm1021_write_value(client,ADM1021_REG_REMOTE_THYST_W,data->remote_temp_hyst);
|
||||
}
|
||||
}
|
||||
struct adm1021_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
adm1021_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->remote_temp_os);
|
||||
results[1] = TEMP_FROM_REG(data->remote_temp_hyst);
|
||||
results[2] = TEMP_FROM_REG(data->remote_temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->remote_temp_os = TEMP_TO_REG(results[0]);
|
||||
adm1021_write_value(client,
|
||||
ADM1021_REG_REMOTE_TOS_W,
|
||||
data->remote_temp_os);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->remote_temp_hyst = TEMP_TO_REG(results[1]);
|
||||
adm1021_write_value(client,
|
||||
ADM1021_REG_REMOTE_THYST_W,
|
||||
data->remote_temp_hyst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void adm1021_die_code(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void adm1021_die_code(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
struct adm1021_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
adm1021_update_client(client);
|
||||
results[0] = data->die_code;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
/* Can't write to it */
|
||||
}
|
||||
struct adm1021_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
adm1021_update_client(client);
|
||||
results[0] = data->die_code;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
/* Can't write to it */
|
||||
}
|
||||
}
|
||||
|
||||
void adm1021_alarms(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
struct adm1021_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
adm1021_update_client(client);
|
||||
results[0] = data->alarms;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
/* Can't write to it */
|
||||
}
|
||||
struct adm1021_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
adm1021_update_client(client);
|
||||
results[0] = data->alarms;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
/* Can't write to it */
|
||||
}
|
||||
}
|
||||
|
||||
int __init sensors_adm1021_init(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
printk("adm1021.o version %s (%s)\n",LM_VERSION,LM_DATE);
|
||||
adm1021_initialized = 0;
|
||||
if ((res = i2c_add_driver(&adm1021_driver))) {
|
||||
printk("adm1021.o: Driver registration failed, module not inserted.\n");
|
||||
adm1021_cleanup();
|
||||
return res;
|
||||
}
|
||||
adm1021_initialized ++;
|
||||
return 0;
|
||||
printk("adm1021.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
adm1021_initialized = 0;
|
||||
if ((res = i2c_add_driver(&adm1021_driver))) {
|
||||
printk
|
||||
("adm1021.o: Driver registration failed, module not inserted.\n");
|
||||
adm1021_cleanup();
|
||||
return res;
|
||||
}
|
||||
adm1021_initialized++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init adm1021_cleanup(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
if (adm1021_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&adm1021_driver))) {
|
||||
printk("adm1021.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
adm1021_initialized --;
|
||||
}
|
||||
if (adm1021_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&adm1021_driver))) {
|
||||
printk
|
||||
("adm1021.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
adm1021_initialized--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_DESCRIPTION("adm1021 driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return sensors_adm1021_init();
|
||||
return sensors_adm1021_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return adm1021_cleanup();
|
||||
return adm1021_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
|
||||
#endif /* MODULE */
|
||||
+484
-415
File diff suppressed because it is too large.
Load diff
+341
-325
@@ -40,12 +40,12 @@
|
||||
|
||||
|
||||
/* Addresses to scan */
|
||||
static unsigned short normal_i2c[] = {SENSORS_I2C_END};
|
||||
static unsigned short normal_i2c[] = { SENSORS_I2C_END };
|
||||
|
||||
/* found only at 0x44 or 0x45 */
|
||||
static unsigned short normal_i2c_range[] = {0x44,0x45,SENSORS_I2C_END};
|
||||
static unsigned int normal_isa[] = {SENSORS_ISA_END};
|
||||
static unsigned int normal_isa_range[] = {SENSORS_ISA_END};
|
||||
static unsigned short normal_i2c_range[] = { 0x44, 0x45, SENSORS_I2C_END };
|
||||
static unsigned int normal_isa[] = { SENSORS_ISA_END };
|
||||
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
|
||||
|
||||
/* Insmod parameters */
|
||||
SENSORS_INSMOD_1(bt869);
|
||||
@@ -59,76 +59,76 @@ SENSORS_INSMOD_1(bt869);
|
||||
variants. Note that you should be a bit careful with which arguments
|
||||
these macros are called: arguments may be evaluated more than once.
|
||||
Fixing this is just not worth it. */
|
||||
|
||||
/*none*/
|
||||
|
||||
/*none */
|
||||
|
||||
/* Initial values */
|
||||
/*none*/
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct bt869_data {
|
||||
int sysctl_id;
|
||||
int sysctl_id;
|
||||
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
|
||||
u8 status[3]; /* Register values */
|
||||
u16 res[2]; /* Resolution XxY */
|
||||
u8 ntsc; /* 1=NTSC, 0=PAL */
|
||||
u8 half; /* go half res */
|
||||
u8 depth; /* screen depth */
|
||||
u8 colorbars; /* turn on/off colorbar calibration screen */
|
||||
u8 status[3]; /* Register values */
|
||||
u16 res[2]; /* Resolution XxY */
|
||||
u8 ntsc; /* 1=NTSC, 0=PAL */
|
||||
u8 half; /* go half res */
|
||||
u8 depth; /* screen depth */
|
||||
u8 colorbars; /* turn on/off colorbar calibration screen */
|
||||
};
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init sensors_bt869_init(void);
|
||||
int __init sensors_bt869_init(void);
|
||||
static int __init bt869_cleanup(void);
|
||||
static int bt869_attach_adapter(struct i2c_adapter *adapter);
|
||||
static int bt869_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static int bt869_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static void bt869_init_client(struct i2c_client *client);
|
||||
static int bt869_detach_client(struct i2c_client *client);
|
||||
static int bt869_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
static void bt869_inc_use (struct i2c_client *client);
|
||||
static void bt869_dec_use (struct i2c_client *client);
|
||||
void *arg);
|
||||
static void bt869_inc_use(struct i2c_client *client);
|
||||
static void bt869_dec_use(struct i2c_client *client);
|
||||
static int bt869_read_value(struct i2c_client *client, u8 reg);
|
||||
static int bt869_write_value(struct i2c_client *client, u8 reg, u16 value);
|
||||
static void bt869_status(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void bt869_ntsc(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void bt869_res(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void bt869_half(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void bt869_colorbars(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void bt869_depth(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void bt869_status(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void bt869_ntsc(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void bt869_res(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void bt869_half(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void bt869_colorbars(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void bt869_depth(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void bt869_update_client(struct i2c_client *client);
|
||||
|
||||
|
||||
/* This is the driver that will be inserted */
|
||||
static struct i2c_driver bt869_driver = {
|
||||
/* name */ "BT869 video-output chip driver",
|
||||
/* id */ I2C_DRIVERID_BT869,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &bt869_attach_adapter,
|
||||
/* detach_client */ &bt869_detach_client,
|
||||
/* command */ &bt869_command,
|
||||
/* inc_use */ &bt869_inc_use,
|
||||
/* dec_use */ &bt869_dec_use
|
||||
/* name */ "BT869 video-output chip driver",
|
||||
/* id */ I2C_DRIVERID_BT869,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &bt869_attach_adapter,
|
||||
/* detach_client */ &bt869_detach_client,
|
||||
/* command */ &bt869_command,
|
||||
/* inc_use */ &bt869_inc_use,
|
||||
/* dec_use */ &bt869_dec_use
|
||||
};
|
||||
|
||||
/* These files are created for each detected bt869. This is just a template;
|
||||
@@ -137,19 +137,19 @@ static struct i2c_driver bt869_driver = {
|
||||
is done through one of the 'extra' fields which are initialized
|
||||
when a new copy is allocated. */
|
||||
static ctl_table bt869_dir_table_template[] = {
|
||||
{ BT869_SYSCTL_STATUS, "status", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_status },
|
||||
{ BT869_SYSCTL_NTSC, "ntsc", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_ntsc },
|
||||
{ BT869_SYSCTL_RES, "res", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_res },
|
||||
{ BT869_SYSCTL_HALF, "half", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_half },
|
||||
{ BT869_SYSCTL_COLORBARS, "colorbars", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_colorbars },
|
||||
{ BT869_SYSCTL_DEPTH, "depth", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_depth },
|
||||
{ 0 }
|
||||
{BT869_SYSCTL_STATUS, "status", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_status},
|
||||
{BT869_SYSCTL_NTSC, "ntsc", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_ntsc},
|
||||
{BT869_SYSCTL_RES, "res", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_res},
|
||||
{BT869_SYSCTL_HALF, "half", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_half},
|
||||
{BT869_SYSCTL_COLORBARS, "colorbars", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_colorbars},
|
||||
{BT869_SYSCTL_DEPTH, "depth", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &bt869_depth},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* Used by init/cleanup */
|
||||
@@ -159,142 +159,146 @@ int bt869_id = 0;
|
||||
|
||||
int bt869_attach_adapter(struct i2c_adapter *adapter)
|
||||
{
|
||||
return sensors_detect(adapter,&addr_data,bt869_detect);
|
||||
return sensors_detect(adapter, &addr_data, bt869_detect);
|
||||
}
|
||||
|
||||
/* This function is called by sensors_detect */
|
||||
int bt869_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
int bt869_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
{
|
||||
int i,cur;
|
||||
struct i2c_client *new_client;
|
||||
struct bt869_data *data;
|
||||
int err=0;
|
||||
const char *type_name,*client_name;
|
||||
int i, cur;
|
||||
struct i2c_client *new_client;
|
||||
struct bt869_data *data;
|
||||
int err = 0;
|
||||
const char *type_name, *client_name;
|
||||
|
||||
|
||||
printk("bt869.o: probing address %d .\n",address);
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
printk("bt869.o: probing address %d .\n", address);
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
#ifdef DEBUG
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk("bt869.o: bt869_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk
|
||||
("bt869.o: bt869_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_READ_BYTE|
|
||||
I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
|
||||
goto ERROR0;
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE |
|
||||
I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
|
||||
goto ERROR0;
|
||||
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access bt869_{read,write}_value. */
|
||||
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct bt869_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access bt869_{read,write}_value. */
|
||||
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct bt869_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
data = (struct bt869_data *) (((struct i2c_client *) new_client) + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &bt869_driver;
|
||||
new_client->flags = 0;
|
||||
data =
|
||||
(struct bt869_data *) (((struct i2c_client *) new_client) + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &bt869_driver;
|
||||
new_client->flags = 0;
|
||||
|
||||
/* Now, we do the remaining detection. It is lousy. */
|
||||
i2c_smbus_write_byte_data(new_client,0xC4,0); /* set status bank 0 */
|
||||
cur = i2c_smbus_read_byte(new_client);
|
||||
printk("bt869.o: address 0x%X testing-->0x%X\n",address,cur);
|
||||
if ((cur & 0xE0) != 0x20)
|
||||
goto ERROR1;
|
||||
|
||||
/* Determine the chip type */
|
||||
kind = ((cur & 0x20)>>5);
|
||||
/* Now, we do the remaining detection. It is lousy. */
|
||||
i2c_smbus_write_byte_data(new_client, 0xC4, 0); /* set status bank 0 */
|
||||
cur = i2c_smbus_read_byte(new_client);
|
||||
printk("bt869.o: address 0x%X testing-->0x%X\n", address, cur);
|
||||
if ((cur & 0xE0) != 0x20)
|
||||
goto ERROR1;
|
||||
|
||||
if (kind) {
|
||||
type_name = "bt869";
|
||||
client_name = "bt869 chip";
|
||||
printk("bt869.o: BT869 detected\n");
|
||||
} else {
|
||||
type_name = "bt868";
|
||||
client_name = "bt868 chip";
|
||||
printk("bt869.o: BT868 detected\n");
|
||||
}
|
||||
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name,client_name);
|
||||
/* Determine the chip type */
|
||||
kind = ((cur & 0x20) >> 5);
|
||||
|
||||
new_client->id = bt869_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
if (kind) {
|
||||
type_name = "bt869";
|
||||
client_name = "bt869 chip";
|
||||
printk("bt869.o: BT869 detected\n");
|
||||
} else {
|
||||
type_name = "bt868";
|
||||
client_name = "bt868 chip";
|
||||
printk("bt869.o: BT868 detected\n");
|
||||
}
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client,type_name,
|
||||
bt869_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name, client_name);
|
||||
|
||||
bt869_init_client((struct i2c_client *) new_client);
|
||||
return 0;
|
||||
new_client->id = bt869_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client, type_name,
|
||||
bt869_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
|
||||
bt869_init_client((struct i2c_client *) new_client);
|
||||
return 0;
|
||||
|
||||
/* OK, this is not exactly good programming practice, usually. But it is
|
||||
very code-efficient in this case. */
|
||||
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt869_detach_client(struct i2c_client *client)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
sensors_deregister_entry(((struct bt869_data *)(client->data))->sysctl_id);
|
||||
sensors_deregister_entry(((struct bt869_data *) (client->data))->
|
||||
sysctl_id);
|
||||
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk("bt869.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk
|
||||
("bt869.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
kfree(client);
|
||||
kfree(client);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* No commands defined yet */
|
||||
int bt869_command(struct i2c_client *client, unsigned int cmd, void *arg)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Nothing here yet */
|
||||
void bt869_inc_use (struct i2c_client *client)
|
||||
void bt869_inc_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Nothing here yet */
|
||||
void bt869_dec_use (struct i2c_client *client)
|
||||
void bt869_dec_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -303,7 +307,7 @@ void bt869_dec_use (struct i2c_client *client)
|
||||
the usual practice. */
|
||||
int bt869_read_value(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
return i2c_smbus_read_byte(client);
|
||||
return i2c_smbus_read_byte(client);
|
||||
}
|
||||
|
||||
/* All registers are byte-sized.
|
||||
@@ -311,249 +315,261 @@ int bt869_read_value(struct i2c_client *client, u8 reg)
|
||||
the usual practice. */
|
||||
int bt869_write_value(struct i2c_client *client, u8 reg, u16 value)
|
||||
{
|
||||
return i2c_smbus_write_byte_data(client,reg,value);
|
||||
return i2c_smbus_write_byte_data(client, reg, value);
|
||||
}
|
||||
|
||||
void bt869_init_client(struct i2c_client *client)
|
||||
{
|
||||
struct bt869_data *data = client->data;
|
||||
|
||||
/* Initialize the bt869 chip */
|
||||
bt869_write_value(client,0x0ba,0x80);
|
||||
// bt869_write_value(client,0x0D6, 0x00);
|
||||
/* Be a slave to the clock on the Voodoo3 */
|
||||
bt869_write_value(client,0xa0,0x80);
|
||||
bt869_write_value(client,0xba,0x20);
|
||||
/* depth =16bpp */
|
||||
bt869_write_value(client,0x0C6, 0x001);
|
||||
bt869_write_value(client,0xC4,1);
|
||||
/* Flicker free enable and config */
|
||||
bt869_write_value(client,0xC8,0);
|
||||
data->res[0]=640;
|
||||
data->res[1]=480;
|
||||
data->ntsc=1;
|
||||
data->half=0;
|
||||
data->colorbars=0;
|
||||
data->depth=16;
|
||||
|
||||
struct bt869_data *data = client->data;
|
||||
|
||||
/* Initialize the bt869 chip */
|
||||
bt869_write_value(client, 0x0ba, 0x80);
|
||||
// bt869_write_value(client,0x0D6, 0x00);
|
||||
/* Be a slave to the clock on the Voodoo3 */
|
||||
bt869_write_value(client, 0xa0, 0x80);
|
||||
bt869_write_value(client, 0xba, 0x20);
|
||||
/* depth =16bpp */
|
||||
bt869_write_value(client, 0x0C6, 0x001);
|
||||
bt869_write_value(client, 0xC4, 1);
|
||||
/* Flicker free enable and config */
|
||||
bt869_write_value(client, 0xC8, 0);
|
||||
data->res[0] = 640;
|
||||
data->res[1] = 480;
|
||||
data->ntsc = 1;
|
||||
data->half = 0;
|
||||
data->colorbars = 0;
|
||||
data->depth = 16;
|
||||
|
||||
}
|
||||
|
||||
void bt869_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct bt869_data *data = client->data;
|
||||
struct bt869_data *data = client->data;
|
||||
|
||||
down(&data->update_lock);
|
||||
down(&data->update_lock);
|
||||
|
||||
if ((jiffies - data->last_updated > HZ+HZ/2 ) ||
|
||||
(jiffies < data->last_updated) || ! data->valid) {
|
||||
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
|
||||
(jiffies < data->last_updated) || !data->valid) {
|
||||
#ifdef DEBUG
|
||||
printk("Starting bt869 update\n");
|
||||
printk("Starting bt869 update\n");
|
||||
#endif
|
||||
/* Set values of device */
|
||||
if ((data->res[0] == 640) && (data->res[1] == 480)) {
|
||||
bt869_write_value(client,0xB8,(! data->ntsc));
|
||||
bt869_write_value(client,0xa0,0x80 + 0x0C);
|
||||
printk("bt869.o: writing into config -->0x%X\n",(0 + (! data->ntsc)));
|
||||
} else if ((data->res[0] == 800) && (data->res[1] == 600)) {
|
||||
bt869_write_value(client,0xB8,(2 + (! data->ntsc)));
|
||||
bt869_write_value(client,0xa0,0x80 + 0x11);
|
||||
printk("bt869.o: writing into config -->0x%X\n",(2 + (! data->ntsc)));
|
||||
} else {
|
||||
bt869_write_value(client,0xB8,(! data->ntsc));
|
||||
bt869_write_value(client,0xa0,0x80 + 0x0C);
|
||||
printk("bt869.o: writing into config -->0x%X\n",(0 + (! data->ntsc)));
|
||||
printk("bt869.o: Warning: arbitrary resolutions not supported yet. Using 640x480.\n");
|
||||
data->res[0] = 640;
|
||||
data->res[1] = 480;
|
||||
}
|
||||
if ((data->depth!=24) && (data->depth!=16))
|
||||
data->depth=16;
|
||||
if (data->depth==16)
|
||||
bt869_write_value(client,0x0C6, 0x001);
|
||||
if (data->depth==24)
|
||||
bt869_write_value(client,0x0C6, 0x000);
|
||||
bt869_write_value(client,0xD4,data->half<<6);
|
||||
/* Be a slave to the clock on the Voodoo3 */
|
||||
bt869_write_value(client,0xba,0x20);
|
||||
/* depth =16bpp */
|
||||
bt869_write_value(client,0x0C6, 0x001);
|
||||
bt869_write_value(client,0xC4,1);
|
||||
if ((data->res[0] == 640) && (data->res[1] == 480)) {
|
||||
bt869_write_value(client, 0xB8, (!data->ntsc));
|
||||
bt869_write_value(client, 0xa0, 0x80 + 0x0C);
|
||||
printk("bt869.o: writing into config -->0x%X\n",
|
||||
(0 + (!data->ntsc)));
|
||||
} else if ((data->res[0] == 800) && (data->res[1] == 600)) {
|
||||
bt869_write_value(client, 0xB8,
|
||||
(2 + (!data->ntsc)));
|
||||
bt869_write_value(client, 0xa0, 0x80 + 0x11);
|
||||
printk("bt869.o: writing into config -->0x%X\n",
|
||||
(2 + (!data->ntsc)));
|
||||
} else {
|
||||
bt869_write_value(client, 0xB8, (!data->ntsc));
|
||||
bt869_write_value(client, 0xa0, 0x80 + 0x0C);
|
||||
printk("bt869.o: writing into config -->0x%X\n",
|
||||
(0 + (!data->ntsc)));
|
||||
printk
|
||||
("bt869.o: Warning: arbitrary resolutions not supported yet. Using 640x480.\n");
|
||||
data->res[0] = 640;
|
||||
data->res[1] = 480;
|
||||
}
|
||||
if ((data->depth != 24) && (data->depth != 16))
|
||||
data->depth = 16;
|
||||
if (data->depth == 16)
|
||||
bt869_write_value(client, 0x0C6, 0x001);
|
||||
if (data->depth == 24)
|
||||
bt869_write_value(client, 0x0C6, 0x000);
|
||||
bt869_write_value(client, 0xD4, data->half << 6);
|
||||
/* Be a slave to the clock on the Voodoo3 */
|
||||
bt869_write_value(client, 0xba, 0x20);
|
||||
/* depth =16bpp */
|
||||
bt869_write_value(client, 0x0C6, 0x001);
|
||||
bt869_write_value(client, 0xC4, 1);
|
||||
|
||||
/* Get status */
|
||||
bt869_write_value(client,0xC4,1 | (data->colorbars << 2));
|
||||
data->status[0] = bt869_read_value(client,1);
|
||||
bt869_write_value(client,0xC4,0x41 | (data->colorbars << 2));
|
||||
data->status[1] = bt869_read_value(client,1);
|
||||
bt869_write_value(client,0xC4,0x81 | (data->colorbars << 2));
|
||||
data->status[2] = bt869_read_value(client,1);
|
||||
bt869_write_value(client,0xC4,0x0C1 | (data->colorbars << 2));
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
up(&data->update_lock);
|
||||
bt869_write_value(client, 0xC4,
|
||||
1 | (data->colorbars << 2));
|
||||
data->status[0] = bt869_read_value(client, 1);
|
||||
bt869_write_value(client, 0xC4,
|
||||
0x41 | (data->colorbars << 2));
|
||||
data->status[1] = bt869_read_value(client, 1);
|
||||
bt869_write_value(client, 0xC4,
|
||||
0x81 | (data->colorbars << 2));
|
||||
data->status[2] = bt869_read_value(client, 1);
|
||||
bt869_write_value(client, 0xC4,
|
||||
0x0C1 | (data->colorbars << 2));
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
up(&data->update_lock);
|
||||
}
|
||||
|
||||
|
||||
void bt869_status(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->status[0];
|
||||
results[1] = data->status[1];
|
||||
results[2] = data->status[2];
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
printk("bt869.o: Warning: write was requested on read-only proc file: status\n");
|
||||
}
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->status[0];
|
||||
results[1] = data->status[1];
|
||||
results[2] = data->status[2];
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
printk
|
||||
("bt869.o: Warning: write was requested on read-only proc file: status\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bt869_ntsc(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->ntsc;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->ntsc = (results[0] > 0);
|
||||
}
|
||||
bt869_update_client(client);
|
||||
}
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->ntsc;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->ntsc = (results[0] > 0);
|
||||
}
|
||||
bt869_update_client(client);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bt869_res(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->res[0];
|
||||
results[1] = data->res[1];
|
||||
*nrels_mag = 2;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->res[0] = results[0];
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->res[1] = results[1];
|
||||
}
|
||||
bt869_update_client(client);
|
||||
}
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->res[0];
|
||||
results[1] = data->res[1];
|
||||
*nrels_mag = 2;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->res[0] = results[0];
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->res[1] = results[1];
|
||||
}
|
||||
bt869_update_client(client);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bt869_half(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->half;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->half = (results[0] > 0);
|
||||
bt869_update_client(client);
|
||||
}
|
||||
}
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->half;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->half = (results[0] > 0);
|
||||
bt869_update_client(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bt869_colorbars(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void bt869_colorbars(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->colorbars;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->colorbars = (results[0] > 0);
|
||||
bt869_update_client(client);
|
||||
}
|
||||
}
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->colorbars;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->colorbars = (results[0] > 0);
|
||||
bt869_update_client(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bt869_depth(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->depth;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->depth = results[0];
|
||||
bt869_update_client(client);
|
||||
}
|
||||
}
|
||||
struct bt869_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
bt869_update_client(client);
|
||||
results[0] = data->depth;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->depth = results[0];
|
||||
bt869_update_client(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int __init sensors_bt869_init(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
printk("bt869.o version %s (%s)\n",LM_VERSION,LM_DATE);
|
||||
bt869_initialized = 0;
|
||||
if ((res = i2c_add_driver(&bt869_driver))) {
|
||||
printk("bt869.o: Driver registration failed, module not inserted.\n");
|
||||
bt869_cleanup();
|
||||
return res;
|
||||
}
|
||||
bt869_initialized ++;
|
||||
return 0;
|
||||
printk("bt869.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
bt869_initialized = 0;
|
||||
if ((res = i2c_add_driver(&bt869_driver))) {
|
||||
printk
|
||||
("bt869.o: Driver registration failed, module not inserted.\n");
|
||||
bt869_cleanup();
|
||||
return res;
|
||||
}
|
||||
bt869_initialized++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init bt869_cleanup(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
if (bt869_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&bt869_driver))) {
|
||||
printk("bt869.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
bt869_initialized --;
|
||||
}
|
||||
if (bt869_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&bt869_driver))) {
|
||||
printk
|
||||
("bt869.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
bt869_initialized--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_DESCRIPTION("bt869 driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return sensors_bt869_init();
|
||||
return sensors_bt869_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return bt869_cleanup();
|
||||
return bt869_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
|
||||
#endif /* MODULE */
|
||||
+239
-216
@@ -38,17 +38,18 @@
|
||||
#endif
|
||||
|
||||
/* Addresses to scan */
|
||||
static unsigned short normal_i2c[] = {SENSORS_I2C_END};
|
||||
static unsigned short normal_i2c_range[] = {0x50,0x57,SENSORS_I2C_END};
|
||||
static unsigned int normal_isa[] = {SENSORS_ISA_END};
|
||||
static unsigned int normal_isa_range[] = {SENSORS_ISA_END};
|
||||
static unsigned short normal_i2c[] = { SENSORS_I2C_END };
|
||||
static unsigned short normal_i2c_range[] = { 0x50, 0x57, SENSORS_I2C_END };
|
||||
static unsigned int normal_isa[] = { SENSORS_ISA_END };
|
||||
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
|
||||
|
||||
/* Insmod parameters */
|
||||
SENSORS_INSMOD_1(eeprom);
|
||||
|
||||
static int checksum = 0;
|
||||
MODULE_PARM(checksum,"i");
|
||||
MODULE_PARM_DESC(checksum,"Only accept eeproms whose checksum is correct");
|
||||
MODULE_PARM(checksum, "i");
|
||||
MODULE_PARM_DESC(checksum,
|
||||
"Only accept eeproms whose checksum is correct");
|
||||
|
||||
|
||||
/* Many constants specified below */
|
||||
@@ -69,58 +70,59 @@ MODULE_PARM_DESC(checksum,"Only accept eeproms whose checksum is correct");
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct eeprom_data {
|
||||
int sysctl_id;
|
||||
int sysctl_id;
|
||||
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
|
||||
u8 data[EEPROM_SIZE]; /* Register values */
|
||||
int memtype;
|
||||
u8 data[EEPROM_SIZE]; /* Register values */
|
||||
int memtype;
|
||||
};
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init sensors_eeprom_init(void);
|
||||
int __init sensors_eeprom_init(void);
|
||||
static int __init eeprom_cleanup(void);
|
||||
|
||||
static int eeprom_attach_adapter(struct i2c_adapter *adapter);
|
||||
static int eeprom_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static int eeprom_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static int eeprom_detach_client(struct i2c_client *client);
|
||||
static int eeprom_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
|
||||
static void eeprom_inc_use (struct i2c_client *client);
|
||||
static void eeprom_dec_use (struct i2c_client *client);
|
||||
void *arg);
|
||||
|
||||
static void eeprom_inc_use(struct i2c_client *client);
|
||||
static void eeprom_dec_use(struct i2c_client *client);
|
||||
|
||||
#if 0
|
||||
static int eeprom_write_value(struct i2c_client *client, u8 reg, u16 value);
|
||||
static int eeprom_write_value(struct i2c_client *client, u8 reg,
|
||||
u16 value);
|
||||
#endif
|
||||
|
||||
static void eeprom_contents(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void eeprom_contents(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void eeprom_update_client(struct i2c_client *client);
|
||||
|
||||
|
||||
/* This is the driver that will be inserted */
|
||||
static struct i2c_driver eeprom_driver = {
|
||||
/* name */ "EEPROM READER",
|
||||
/* id */ I2C_DRIVERID_EEPROM,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &eeprom_attach_adapter,
|
||||
/* detach_client */ &eeprom_detach_client,
|
||||
/* command */ &eeprom_command,
|
||||
/* inc_use */ &eeprom_inc_use,
|
||||
/* dec_use */ &eeprom_dec_use
|
||||
/* name */ "EEPROM READER",
|
||||
/* id */ I2C_DRIVERID_EEPROM,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &eeprom_attach_adapter,
|
||||
/* detach_client */ &eeprom_detach_client,
|
||||
/* command */ &eeprom_command,
|
||||
/* inc_use */ &eeprom_inc_use,
|
||||
/* dec_use */ &eeprom_dec_use
|
||||
};
|
||||
|
||||
/* These files are created for each detected EEPROM. This is just a template;
|
||||
@@ -129,23 +131,23 @@ static struct i2c_driver eeprom_driver = {
|
||||
is done through one of the 'extra' fields which are initialized
|
||||
when a new copy is allocated. */
|
||||
static ctl_table eeprom_dir_table_template[] = {
|
||||
{ EEPROM_SYSCTL1, "data0-15", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents },
|
||||
{ EEPROM_SYSCTL2, "data16-31", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents },
|
||||
{ EEPROM_SYSCTL3, "data32-47", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents },
|
||||
{ EEPROM_SYSCTL4, "data48-63", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents },
|
||||
{ EEPROM_SYSCTL5, "data64-79", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents },
|
||||
{ EEPROM_SYSCTL6, "data80-95", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents },
|
||||
{ EEPROM_SYSCTL7, "data96-111", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents },
|
||||
{ EEPROM_SYSCTL8, "data112-127", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents },
|
||||
{ 0 }
|
||||
{EEPROM_SYSCTL1, "data0-15", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents},
|
||||
{EEPROM_SYSCTL2, "data16-31", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents},
|
||||
{EEPROM_SYSCTL3, "data32-47", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents},
|
||||
{EEPROM_SYSCTL4, "data48-63", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents},
|
||||
{EEPROM_SYSCTL5, "data64-79", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents},
|
||||
{EEPROM_SYSCTL6, "data80-95", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents},
|
||||
{EEPROM_SYSCTL7, "data96-111", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents},
|
||||
{EEPROM_SYSCTL8, "data112-127", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &eeprom_contents},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* Used by init/cleanup */
|
||||
@@ -155,142 +157,147 @@ static int eeprom_id = 0;
|
||||
|
||||
int eeprom_attach_adapter(struct i2c_adapter *adapter)
|
||||
{
|
||||
return sensors_detect(adapter,&addr_data,eeprom_detect);
|
||||
return sensors_detect(adapter, &addr_data, eeprom_detect);
|
||||
}
|
||||
|
||||
/* This function is called by sensors_detect */
|
||||
int eeprom_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
int eeprom_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
{
|
||||
int i,cs;
|
||||
struct i2c_client *new_client;
|
||||
struct eeprom_data *data;
|
||||
int err=0;
|
||||
const char *type_name,*client_name;
|
||||
int i, cs;
|
||||
struct i2c_client *new_client;
|
||||
struct eeprom_data *data;
|
||||
int err = 0;
|
||||
const char *type_name, *client_name;
|
||||
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
#ifdef DEBUG
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk("eeprom.o: eeprom_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk
|
||||
("eeprom.o: eeprom_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA |
|
||||
I2C_FUNC_SMBUS_WRITE_WORD_DATA))
|
||||
goto ERROR0;
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
|
||||
I2C_FUNC_SMBUS_WRITE_WORD_DATA))
|
||||
goto ERROR0;
|
||||
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access eeprom_{read,write}_value. */
|
||||
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct eeprom_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access eeprom_{read,write}_value. */
|
||||
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct eeprom_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
data = (struct eeprom_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &eeprom_driver;
|
||||
new_client->flags = 0;
|
||||
data = (struct eeprom_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &eeprom_driver;
|
||||
new_client->flags = 0;
|
||||
|
||||
/* Now, we do the remaining detection. It is not there, unless you force
|
||||
the checksum to work out. */
|
||||
if (checksum) {
|
||||
cs = 0;
|
||||
for (i = 0; i <= 0x3e; i++)
|
||||
cs += i2c_smbus_read_byte_data(new_client,i);
|
||||
cs &= 0xff;
|
||||
if (i2c_smbus_read_byte_data(new_client,EEPROM_REG_CHECKSUM) != cs)
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
/* Determine the chip type - only one kind supported! */
|
||||
if (kind <= 0)
|
||||
kind = eeprom;
|
||||
/* Now, we do the remaining detection. It is not there, unless you force
|
||||
the checksum to work out. */
|
||||
if (checksum) {
|
||||
cs = 0;
|
||||
for (i = 0; i <= 0x3e; i++)
|
||||
cs += i2c_smbus_read_byte_data(new_client, i);
|
||||
cs &= 0xff;
|
||||
if (i2c_smbus_read_byte_data
|
||||
(new_client, EEPROM_REG_CHECKSUM) != cs)
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
if (kind == eeprom) {
|
||||
type_name = "eeprom";
|
||||
client_name = "EEPROM chip";
|
||||
} else {
|
||||
/* Determine the chip type - only one kind supported! */
|
||||
if (kind <= 0)
|
||||
kind = eeprom;
|
||||
|
||||
if (kind == eeprom) {
|
||||
type_name = "eeprom";
|
||||
client_name = "EEPROM chip";
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
printk("eeprom.o: Internal error: unknown kind (%d)?!?",kind);
|
||||
printk("eeprom.o: Internal error: unknown kind (%d)?!?",
|
||||
kind);
|
||||
#endif
|
||||
goto ERROR1;
|
||||
}
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name,client_name);
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name, client_name);
|
||||
|
||||
new_client->id = eeprom_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
new_client->id = eeprom_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client,type_name,
|
||||
eeprom_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client, type_name,
|
||||
eeprom_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
/* OK, this is not exactly good programming practice, usually. But it is
|
||||
very code-efficient in this case. */
|
||||
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
}
|
||||
|
||||
int eeprom_detach_client(struct i2c_client *client)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
sensors_deregister_entry(((struct eeprom_data *)(client->data))->sysctl_id);
|
||||
sensors_deregister_entry(((struct eeprom_data *) (client->data))->
|
||||
sysctl_id);
|
||||
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk("eeprom.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk
|
||||
("eeprom.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
kfree(client);
|
||||
kfree(client);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* No commands defined yet */
|
||||
int eeprom_command(struct i2c_client *client, unsigned int cmd, void *arg)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void eeprom_inc_use (struct i2c_client *client)
|
||||
void eeprom_inc_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
void eeprom_dec_use (struct i2c_client *client)
|
||||
void eeprom_dec_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -298,129 +305,145 @@ void eeprom_dec_use (struct i2c_client *client)
|
||||
/* No writes yet (PAE) */
|
||||
int eeprom_write_value(struct i2c_client *client, u8 reg, u16 value)
|
||||
{
|
||||
if (reg == EEPROM_REG_CONF)
|
||||
return i2c_smbus_write_byte_data(client,reg,value);
|
||||
else
|
||||
return i2c_smbus_write_word_data(client,reg,value); */
|
||||
|
||||
return 0;
|
||||
if (reg == EEPROM_REG_CONF)
|
||||
return i2c_smbus_write_byte_data(client, reg, value);
|
||||
else
|
||||
return i2c_smbus_write_word_data(client, reg, value);
|
||||
*/return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void eeprom_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct eeprom_data *data = client->data;
|
||||
int i;
|
||||
struct eeprom_data *data = client->data;
|
||||
int i;
|
||||
|
||||
down(&data->update_lock);
|
||||
down(&data->update_lock);
|
||||
|
||||
if ((jiffies - data->last_updated > HZ+HZ/2 ) ||
|
||||
(jiffies < data->last_updated) || ! data->valid) {
|
||||
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
|
||||
(jiffies < data->last_updated) || !data->valid) {
|
||||
|
||||
#ifdef DEBUG
|
||||
printk("Starting eeprom update\n");
|
||||
printk("Starting eeprom update\n");
|
||||
#endif
|
||||
|
||||
if (i2c_smbus_write_byte(client,0)) {
|
||||
if (i2c_smbus_write_byte(client, 0)) {
|
||||
#ifdef DEBUG
|
||||
printk("eeprom read start has failed!\n");
|
||||
#endif
|
||||
}
|
||||
for (i=0;i<EEPROM_SIZE;i++) {
|
||||
data->data[i] = (u8)i2c_smbus_read_byte(client);
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
printk("eeprom read start has failed!\n");
|
||||
#endif
|
||||
}
|
||||
for (i = 0; i < EEPROM_SIZE; i++) {
|
||||
data->data[i] = (u8) i2c_smbus_read_byte(client);
|
||||
}
|
||||
|
||||
up(&data->update_lock);
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
up(&data->update_lock);
|
||||
}
|
||||
|
||||
|
||||
void eeprom_contents(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void eeprom_contents(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
int i;
|
||||
int base=0;
|
||||
struct eeprom_data *data = client->data;
|
||||
|
||||
if (ctl_name == EEPROM_SYSCTL2){ base=16; }
|
||||
if (ctl_name == EEPROM_SYSCTL3){ base=32; }
|
||||
if (ctl_name == EEPROM_SYSCTL4){ base=48; }
|
||||
if (ctl_name == EEPROM_SYSCTL5){ base=64; }
|
||||
if (ctl_name == EEPROM_SYSCTL6){ base=80; }
|
||||
if (ctl_name == EEPROM_SYSCTL7){ base=96; }
|
||||
if (ctl_name == EEPROM_SYSCTL8){ base=112; }
|
||||
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
eeprom_update_client(client);
|
||||
for (i=0; i<16; i++) {
|
||||
results[i]=data->data[i + base];
|
||||
}
|
||||
int i;
|
||||
int base = 0;
|
||||
struct eeprom_data *data = client->data;
|
||||
|
||||
if (ctl_name == EEPROM_SYSCTL2) {
|
||||
base = 16;
|
||||
}
|
||||
if (ctl_name == EEPROM_SYSCTL3) {
|
||||
base = 32;
|
||||
}
|
||||
if (ctl_name == EEPROM_SYSCTL4) {
|
||||
base = 48;
|
||||
}
|
||||
if (ctl_name == EEPROM_SYSCTL5) {
|
||||
base = 64;
|
||||
}
|
||||
if (ctl_name == EEPROM_SYSCTL6) {
|
||||
base = 80;
|
||||
}
|
||||
if (ctl_name == EEPROM_SYSCTL7) {
|
||||
base = 96;
|
||||
}
|
||||
if (ctl_name == EEPROM_SYSCTL8) {
|
||||
base = 112;
|
||||
}
|
||||
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
eeprom_update_client(client);
|
||||
for (i = 0; i < 16; i++) {
|
||||
results[i] = data->data[i + base];
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printk("eeprom.o: 0x%X EEPROM Contents (base %d): ",client->addr,base);
|
||||
for (i=0; i<16; i++) {
|
||||
printk(" 0x%X",data->data[i + base]);
|
||||
}
|
||||
printk(" .\n");
|
||||
printk("eeprom.o: 0x%X EEPROM Contents (base %d): ",
|
||||
client->addr, base);
|
||||
for (i = 0; i < 16; i++) {
|
||||
printk(" 0x%X", data->data[i + base]);
|
||||
}
|
||||
printk(" .\n");
|
||||
#endif
|
||||
*nrels_mag = 16;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
*nrels_mag = 16;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
|
||||
/* No writes to the EEPROM (yet, anyway) (PAE) */
|
||||
printk("eeprom.o: No writes to EEPROMs supported!\n");
|
||||
}
|
||||
printk("eeprom.o: No writes to EEPROMs supported!\n");
|
||||
}
|
||||
}
|
||||
|
||||
int __init sensors_eeprom_init(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
printk("eeprom.o version %s (%s)\n",LM_VERSION,LM_DATE);
|
||||
eeprom_initialized = 0;
|
||||
if ((res = i2c_add_driver(&eeprom_driver))) {
|
||||
printk("eeprom.o: Driver registration failed, module not inserted.\n");
|
||||
eeprom_cleanup();
|
||||
return res;
|
||||
}
|
||||
eeprom_initialized ++;
|
||||
return 0;
|
||||
printk("eeprom.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
eeprom_initialized = 0;
|
||||
if ((res = i2c_add_driver(&eeprom_driver))) {
|
||||
printk
|
||||
("eeprom.o: Driver registration failed, module not inserted.\n");
|
||||
eeprom_cleanup();
|
||||
return res;
|
||||
}
|
||||
eeprom_initialized++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init eeprom_cleanup(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
if (eeprom_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&eeprom_driver))) {
|
||||
printk("eeprom.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
} else
|
||||
eeprom_initialized --;
|
||||
if (eeprom_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&eeprom_driver))) {
|
||||
printk
|
||||
("eeprom.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
} else
|
||||
eeprom_initialized--;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_DESCRIPTION("EEPROM driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return sensors_eeprom_init();
|
||||
return sensors_eeprom_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return eeprom_cleanup();
|
||||
return eeprom_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
|
||||
#endif /* MODULE */
|
||||
+710
-654
File diff suppressed because it is too large.
Load diff
+579
-522
File diff suppressed because it is too large.
Load diff
+177
-165
@@ -53,56 +53,57 @@
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct icspll_data {
|
||||
int sysctl_id;
|
||||
int sysctl_id;
|
||||
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
|
||||
u8 data[ICSPLL_SIZE]; /* Register values */
|
||||
int memtype;
|
||||
u8 data[ICSPLL_SIZE]; /* Register values */
|
||||
int memtype;
|
||||
};
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init sensors_icspll_init(void);
|
||||
int __init sensors_icspll_init(void);
|
||||
static int __init icspll_cleanup(void);
|
||||
|
||||
static int icspll_attach_adapter(struct i2c_adapter *adapter);
|
||||
static int icspll_detach_client(struct i2c_client *client);
|
||||
static int icspll_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
|
||||
static void icspll_inc_use (struct i2c_client *client);
|
||||
static void icspll_dec_use (struct i2c_client *client);
|
||||
void *arg);
|
||||
|
||||
static void icspll_inc_use(struct i2c_client *client);
|
||||
static void icspll_dec_use(struct i2c_client *client);
|
||||
|
||||
#if 0
|
||||
static int icspll_write_value(struct i2c_client *client, u8 reg, u16 value);
|
||||
static int icspll_write_value(struct i2c_client *client, u8 reg,
|
||||
u16 value);
|
||||
#endif
|
||||
|
||||
static void icspll_contents(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void icspll_contents(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void icspll_update_client(struct i2c_client *client);
|
||||
|
||||
|
||||
/* This is the driver that will be inserted */
|
||||
static struct i2c_driver icspll_driver = {
|
||||
/* name */ "ICS/PLL clock reader",
|
||||
/* id */ I2C_DRIVERID_ICSPLL,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &icspll_attach_adapter,
|
||||
/* detach_client */ &icspll_detach_client,
|
||||
/* command */ &icspll_command,
|
||||
/* inc_use */ &icspll_inc_use,
|
||||
/* dec_use */ &icspll_dec_use
|
||||
/* name */ "ICS/PLL clock reader",
|
||||
/* id */ I2C_DRIVERID_ICSPLL,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &icspll_attach_adapter,
|
||||
/* detach_client */ &icspll_detach_client,
|
||||
/* command */ &icspll_command,
|
||||
/* inc_use */ &icspll_inc_use,
|
||||
/* dec_use */ &icspll_dec_use
|
||||
};
|
||||
|
||||
/* These files are created for each detected ICSPLL. This is just a template;
|
||||
@@ -111,9 +112,9 @@ static struct i2c_driver icspll_driver = {
|
||||
is done through one of the 'extra' fields which are initialized
|
||||
when a new copy is allocated. */
|
||||
static ctl_table icspll_dir_table_template[] = {
|
||||
{ ICSPLL_SYSCTL1, "reg0-6", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &icspll_contents },
|
||||
{ 0 }
|
||||
{ICSPLL_SYSCTL1, "reg0-6", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &icspll_contents},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* holding place for data - block read could be as much as 32 */
|
||||
@@ -125,119 +126,124 @@ static int __initdata icspll_initialized = 0;
|
||||
static int icspll_id = 0;
|
||||
int icspll_attach_adapter(struct i2c_adapter *adapter)
|
||||
{
|
||||
int address,err,i;
|
||||
struct i2c_client *new_client;
|
||||
struct icspll_data *data;
|
||||
int address, err, i;
|
||||
struct i2c_client *new_client;
|
||||
struct icspll_data *data;
|
||||
|
||||
err = 0;
|
||||
/* Make sure we aren't probing the ISA bus!! */
|
||||
if (i2c_is_isa_adapter(adapter)) return 0;
|
||||
|
||||
/* OK, this is no detection. I know. It will do for now, though. */
|
||||
err = 0;
|
||||
/* Make sure we aren't probing the ISA bus!! */
|
||||
if (i2c_is_isa_adapter(adapter))
|
||||
return 0;
|
||||
|
||||
/* Set err only if a global error would make registering other clients
|
||||
impossible too (like out-of-memory). */
|
||||
|
||||
/* ICS and PLL clock chips seem to all be at 0x69.
|
||||
Don't know what is out there at 0x6A, don't scan that yet. */
|
||||
/* OK, this is no detection. I know. It will do for now, though. */
|
||||
|
||||
for (address = 0x69; (! err) && (address <= 0x69); address ++) {
|
||||
/* Set err only if a global error would make registering other clients
|
||||
impossible too (like out-of-memory). */
|
||||
|
||||
/* Later on, we will keep a list of registered addresses for each
|
||||
adapter, and check whether they are used here */
|
||||
|
||||
/* these chips only support block transfers so use that for detection */
|
||||
if(i2c_smbus_read_block_data(adapter, address, 0x00, tempdata) < 0) {
|
||||
/* ICS and PLL clock chips seem to all be at 0x69.
|
||||
Don't know what is out there at 0x6A, don't scan that yet. */
|
||||
|
||||
for (address = 0x69; (!err) && (address <= 0x69); address++) {
|
||||
|
||||
/* Later on, we will keep a list of registered addresses for each
|
||||
adapter, and check whether they are used here */
|
||||
|
||||
/* these chips only support block transfers so use that for detection */
|
||||
if (i2c_smbus_read_block_data
|
||||
(adapter, address, 0x00, tempdata) < 0) {
|
||||
#ifdef DEBUG
|
||||
printk("icspll.o: No icspll found at: 0x%X\n",address);
|
||||
printk("icspll.o: No icspll found at: 0x%X\n",
|
||||
address);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Real detection code goes here */
|
||||
/* Real detection code goes here */
|
||||
|
||||
/* Allocate space for a new client structure */
|
||||
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct icspll_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
continue;
|
||||
}
|
||||
/* Allocate space for a new client structure */
|
||||
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct icspll_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Fill the new client structure with data */
|
||||
data = (struct icspll_data *) (new_client + 1);
|
||||
new_client->data = data;
|
||||
new_client->id = icspll_id++;
|
||||
new_client->addr = address;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &icspll_driver;
|
||||
new_client->flags = 0;
|
||||
strcpy(new_client->name,"ICSPLL chip");
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
/* Fill the new client structure with data */
|
||||
data = (struct icspll_data *) (new_client + 1);
|
||||
new_client->data = data;
|
||||
new_client->id = icspll_id++;
|
||||
new_client->addr = address;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &icspll_driver;
|
||||
new_client->flags = 0;
|
||||
strcpy(new_client->name, "ICSPLL chip");
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
/* fill data structure so unknown registers are 0xFF */
|
||||
data->data[0] = ICSPLL_SIZE;
|
||||
for(i = 1; i <= ICSPLL_SIZE; i++)
|
||||
data->data[i] = 0xFF;
|
||||
|
||||
/* Tell i2c-core a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR2;
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((err = sensors_register_entry(new_client,"icspll",
|
||||
icspll_dir_table_template
|
||||
THIS_MODULE)) < 0)
|
||||
goto ERROR3;
|
||||
data->sysctl_id = err;
|
||||
err = 0;
|
||||
data->data[0] = ICSPLL_SIZE;
|
||||
for (i = 1; i <= ICSPLL_SIZE; i++)
|
||||
data->data[i] = 0xFF;
|
||||
|
||||
continue;
|
||||
/* Tell i2c-core a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR2;
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((err = sensors_register_entry(new_client, "icspll",
|
||||
icspll_dir_table_template
|
||||
THIS_MODULE)) < 0)
|
||||
goto ERROR3;
|
||||
data->sysctl_id = err;
|
||||
err = 0;
|
||||
|
||||
continue;
|
||||
/* OK, this is not exactly good programming practice, usually. But it is
|
||||
very code-efficient in this case. */
|
||||
|
||||
ERROR3:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR2:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
}
|
||||
return err;
|
||||
ERROR3:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR2:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int icspll_detach_client(struct i2c_client *client)
|
||||
{
|
||||
int err,i;
|
||||
int err, i;
|
||||
|
||||
sensors_deregister_entry(((struct icspll_data *)(client->data))->sysctl_id);
|
||||
sensors_deregister_entry(((struct icspll_data *) (client->data))->
|
||||
sysctl_id);
|
||||
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk("icspll.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk
|
||||
("icspll.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
kfree(client);
|
||||
return 0;
|
||||
kfree(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* No commands defined yet */
|
||||
int icspll_command(struct i2c_client *client, unsigned int cmd, void *arg)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void icspll_inc_use (struct i2c_client *client)
|
||||
void icspll_inc_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
void icspll_dec_use (struct i2c_client *client)
|
||||
void icspll_dec_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -245,111 +251,117 @@ void icspll_dec_use (struct i2c_client *client)
|
||||
/* No writes yet (PAE) */
|
||||
int icspll_write_value(struct i2c_client *client, u8 reg, u16 value)
|
||||
{
|
||||
return i2c_smbus_write_block_data(client->adapter,client->addr,reg,value);
|
||||
return i2c_smbus_write_block_data(client->adapter, client->addr,
|
||||
reg, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
void icspll_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct icspll_data *data = client->data;
|
||||
int i, len;
|
||||
struct icspll_data *data = client->data;
|
||||
int i, len;
|
||||
|
||||
down(&data->update_lock);
|
||||
down(&data->update_lock);
|
||||
|
||||
if ((jiffies - data->last_updated > HZ+HZ/2 ) ||
|
||||
(jiffies < data->last_updated) || ! data->valid) {
|
||||
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
|
||||
(jiffies < data->last_updated) || !data->valid) {
|
||||
|
||||
len = i2c_smbus_read_block_data(client->adapter, client->addr, 0x00, tempdata);
|
||||
len =
|
||||
i2c_smbus_read_block_data(client->adapter,
|
||||
client->addr, 0x00,
|
||||
tempdata);
|
||||
#ifdef DEBUG
|
||||
printk("icspll.o: read returned %d values\n", len);
|
||||
printk("icspll.o: read returned %d values\n", len);
|
||||
#endif
|
||||
if(len > ICSPLL_SIZE)
|
||||
len = ICSPLL_SIZE;
|
||||
for(i = 0; i < len; i++)
|
||||
data->data[i] = tempdata[i];
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
if (len > ICSPLL_SIZE)
|
||||
len = ICSPLL_SIZE;
|
||||
for (i = 0; i < len; i++)
|
||||
data->data[i] = tempdata[i];
|
||||
|
||||
up(&data->update_lock);
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
up(&data->update_lock);
|
||||
}
|
||||
|
||||
|
||||
void icspll_contents(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void icspll_contents(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
int i;
|
||||
struct icspll_data *data = client->data;
|
||||
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
icspll_update_client(client);
|
||||
for (i=0; i< ICSPLL_SIZE; i++) {
|
||||
results[i]=data->data[i];
|
||||
}
|
||||
int i;
|
||||
struct icspll_data *data = client->data;
|
||||
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
icspll_update_client(client);
|
||||
for (i = 0; i < ICSPLL_SIZE; i++) {
|
||||
results[i] = data->data[i];
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printk("icspll.o: 0x%X ICSPLL Contents: ",client->addr);
|
||||
for (i=0; i< ICSPLL_SIZE; i++) {
|
||||
printk(" 0x%X",data->data[i]);
|
||||
}
|
||||
printk(" .\n");
|
||||
printk("icspll.o: 0x%X ICSPLL Contents: ", client->addr);
|
||||
for (i = 0; i < ICSPLL_SIZE; i++) {
|
||||
printk(" 0x%X", data->data[i]);
|
||||
}
|
||||
printk(" .\n");
|
||||
#endif
|
||||
*nrels_mag = ICSPLL_SIZE;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
*nrels_mag = ICSPLL_SIZE;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
|
||||
/* No writes to the ICSPLL (yet, anyway) (PAE) */
|
||||
printk("icspll.o: No writes to ICSPLLs supported!\n");
|
||||
}
|
||||
printk("icspll.o: No writes to ICSPLLs supported!\n");
|
||||
}
|
||||
}
|
||||
|
||||
int __init sensors_icspll_init(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
printk("icspll.o version %s (%s)\n",LM_VERSION,LM_DATE);
|
||||
icspll_initialized = 0;
|
||||
if ((res = i2c_add_driver(&icspll_driver))) {
|
||||
printk("icspll.o: Driver registration failed, module not inserted.\n");
|
||||
icspll_cleanup();
|
||||
return res;
|
||||
}
|
||||
icspll_initialized ++;
|
||||
return 0;
|
||||
printk("icspll.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
icspll_initialized = 0;
|
||||
if ((res = i2c_add_driver(&icspll_driver))) {
|
||||
printk
|
||||
("icspll.o: Driver registration failed, module not inserted.\n");
|
||||
icspll_cleanup();
|
||||
return res;
|
||||
}
|
||||
icspll_initialized++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init icspll_cleanup(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
if (icspll_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&icspll_driver))) {
|
||||
printk("icspll.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
} else
|
||||
icspll_initialized --;
|
||||
if (icspll_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&icspll_driver))) {
|
||||
printk
|
||||
("icspll.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
} else
|
||||
icspll_initialized--;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, and Mark Studebaker <mdsxyz123@yahoo.com>");
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, and Mark Studebaker <mdsxyz123@yahoo.com>");
|
||||
MODULE_DESCRIPTION("ICSPLL driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return sensors_icspll_init();
|
||||
return sensors_icspll_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return icspll_cleanup();
|
||||
return icspll_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
|
||||
#endif /* MODULE */
|
||||
+209
-195
@@ -37,10 +37,10 @@
|
||||
#endif
|
||||
|
||||
/* Addresses to scan */
|
||||
static unsigned short normal_i2c[] = {SENSORS_I2C_END};
|
||||
static unsigned short normal_i2c_range[] = {0x48,0x4f,SENSORS_I2C_END};
|
||||
static unsigned int normal_isa[] = {SENSORS_ISA_END};
|
||||
static unsigned int normal_isa_range[] = {SENSORS_ISA_END};
|
||||
static unsigned short normal_i2c[] = { SENSORS_I2C_END };
|
||||
static unsigned short normal_i2c_range[] = { 0x48, 0x4f, SENSORS_I2C_END };
|
||||
static unsigned int normal_isa[] = { SENSORS_ISA_END };
|
||||
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
|
||||
|
||||
/* Insmod parameters */
|
||||
SENSORS_INSMOD_1(lm75);
|
||||
@@ -66,54 +66,54 @@ SENSORS_INSMOD_1(lm75);
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct lm75_data {
|
||||
int sysctl_id;
|
||||
int sysctl_id;
|
||||
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
|
||||
u16 temp,temp_os,temp_hyst; /* Register values */
|
||||
u16 temp, temp_os, temp_hyst; /* Register values */
|
||||
};
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init sensors_lm75_init(void);
|
||||
int __init sensors_lm75_init(void);
|
||||
static int __init lm75_cleanup(void);
|
||||
static int lm75_attach_adapter(struct i2c_adapter *adapter);
|
||||
static int lm75_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static int lm75_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static void lm75_init_client(struct i2c_client *client);
|
||||
static int lm75_detach_client(struct i2c_client *client);
|
||||
static int lm75_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
static void lm75_inc_use (struct i2c_client *client);
|
||||
static void lm75_dec_use (struct i2c_client *client);
|
||||
void *arg);
|
||||
static void lm75_inc_use(struct i2c_client *client);
|
||||
static void lm75_dec_use(struct i2c_client *client);
|
||||
static u16 swap_bytes(u16 val);
|
||||
static int lm75_read_value(struct i2c_client *client, u8 reg);
|
||||
static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value);
|
||||
static void lm75_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void lm75_temp(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void lm75_update_client(struct i2c_client *client);
|
||||
|
||||
|
||||
/* This is the driver that will be inserted */
|
||||
static struct i2c_driver lm75_driver = {
|
||||
/* name */ "LM75 sensor chip driver",
|
||||
/* id */ I2C_DRIVERID_LM75,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &lm75_attach_adapter,
|
||||
/* detach_client */ &lm75_detach_client,
|
||||
/* command */ &lm75_command,
|
||||
/* inc_use */ &lm75_inc_use,
|
||||
/* dec_use */ &lm75_dec_use
|
||||
/* name */ "LM75 sensor chip driver",
|
||||
/* id */ I2C_DRIVERID_LM75,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &lm75_attach_adapter,
|
||||
/* detach_client */ &lm75_detach_client,
|
||||
/* command */ &lm75_command,
|
||||
/* inc_use */ &lm75_inc_use,
|
||||
/* dec_use */ &lm75_dec_use
|
||||
};
|
||||
|
||||
/* These files are created for each detected LM75. This is just a template;
|
||||
@@ -122,9 +122,9 @@ static struct i2c_driver lm75_driver = {
|
||||
is done through one of the 'extra' fields which are initialized
|
||||
when a new copy is allocated. */
|
||||
static ctl_table lm75_dir_table_template[] = {
|
||||
{ LM75_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &lm75_temp },
|
||||
{ 0 }
|
||||
{LM75_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &lm75_temp},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* Used by init/cleanup */
|
||||
@@ -134,153 +134,163 @@ static int lm75_id = 0;
|
||||
|
||||
int lm75_attach_adapter(struct i2c_adapter *adapter)
|
||||
{
|
||||
return sensors_detect(adapter,&addr_data,lm75_detect);
|
||||
return sensors_detect(adapter, &addr_data, lm75_detect);
|
||||
}
|
||||
|
||||
/* This function is called by sensors_detect */
|
||||
int lm75_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
int lm75_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
{
|
||||
int i,cur,conf,hyst,os;
|
||||
struct i2c_client *new_client;
|
||||
struct lm75_data *data;
|
||||
int err=0;
|
||||
const char *type_name,*client_name;
|
||||
int i, cur, conf, hyst, os;
|
||||
struct i2c_client *new_client;
|
||||
struct lm75_data *data;
|
||||
int err = 0;
|
||||
const char *type_name, *client_name;
|
||||
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
#ifdef DEBUG
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk("lm75.o: lm75_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk
|
||||
("lm75.o: lm75_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA |
|
||||
I2C_FUNC_SMBUS_WORD_DATA))
|
||||
goto ERROR0;
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
|
||||
I2C_FUNC_SMBUS_WORD_DATA))
|
||||
goto ERROR0;
|
||||
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access lm75_{read,write}_value. */
|
||||
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct lm75_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access lm75_{read,write}_value. */
|
||||
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct lm75_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
data = (struct lm75_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &lm75_driver;
|
||||
new_client->flags = 0;
|
||||
data = (struct lm75_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &lm75_driver;
|
||||
new_client->flags = 0;
|
||||
|
||||
/* Now, we do the remaining detection. It is lousy. */
|
||||
if (kind < 0) {
|
||||
cur = i2c_smbus_read_word_data(new_client,0);
|
||||
conf = i2c_smbus_read_byte_data(new_client,1);
|
||||
hyst = i2c_smbus_read_word_data(new_client,2);
|
||||
os = i2c_smbus_read_word_data(new_client,3);
|
||||
for (i = 0; i <= 0x1f; i++)
|
||||
if ((i2c_smbus_read_byte_data(new_client,i*8+1) != conf) ||
|
||||
(i2c_smbus_read_word_data(new_client,i*8+2) != hyst) ||
|
||||
(i2c_smbus_read_word_data(new_client,i*8+3) != os))
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
/* Determine the chip type - only one kind supported! */
|
||||
if (kind <= 0)
|
||||
kind = lm75;
|
||||
/* Now, we do the remaining detection. It is lousy. */
|
||||
if (kind < 0) {
|
||||
cur = i2c_smbus_read_word_data(new_client, 0);
|
||||
conf = i2c_smbus_read_byte_data(new_client, 1);
|
||||
hyst = i2c_smbus_read_word_data(new_client, 2);
|
||||
os = i2c_smbus_read_word_data(new_client, 3);
|
||||
for (i = 0; i <= 0x1f; i++)
|
||||
if (
|
||||
(i2c_smbus_read_byte_data
|
||||
(new_client, i * 8 + 1) != conf)
|
||||
||
|
||||
(i2c_smbus_read_word_data
|
||||
(new_client, i * 8 + 2) != hyst)
|
||||
||
|
||||
(i2c_smbus_read_word_data
|
||||
(new_client, i * 8 + 3) != os))
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
if (kind == lm75) {
|
||||
type_name = "lm75";
|
||||
client_name = "LM75 chip";
|
||||
} else {
|
||||
/* Determine the chip type - only one kind supported! */
|
||||
if (kind <= 0)
|
||||
kind = lm75;
|
||||
|
||||
if (kind == lm75) {
|
||||
type_name = "lm75";
|
||||
client_name = "LM75 chip";
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
printk("lm75.o: Internal error: unknown kind (%d)?!?",kind);
|
||||
printk("lm75.o: Internal error: unknown kind (%d)?!?",
|
||||
kind);
|
||||
#endif
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name,client_name);
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
new_client->id = lm75_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name, client_name);
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client,type_name,
|
||||
lm75_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
new_client->id = lm75_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
lm75_init_client(new_client);
|
||||
return 0;
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client, type_name,
|
||||
lm75_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
|
||||
lm75_init_client(new_client);
|
||||
return 0;
|
||||
|
||||
/* OK, this is not exactly good programming practice, usually. But it is
|
||||
very code-efficient in this case. */
|
||||
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
}
|
||||
|
||||
int lm75_detach_client(struct i2c_client *client)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
sensors_deregister_entry(((struct lm75_data *)(client->data))->sysctl_id);
|
||||
sensors_deregister_entry(((struct lm75_data *) (client->data))->
|
||||
sysctl_id);
|
||||
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk("lm75.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk
|
||||
("lm75.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
kfree(client);
|
||||
kfree(client);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* No commands defined yet */
|
||||
int lm75_command(struct i2c_client *client, unsigned int cmd, void *arg)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Nothing here yet */
|
||||
void lm75_inc_use (struct i2c_client *client)
|
||||
void lm75_inc_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Nothing here yet */
|
||||
void lm75_dec_use (struct i2c_client *client)
|
||||
void lm75_dec_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
u16 swap_bytes(u16 val)
|
||||
{
|
||||
return (val >> 8) | (val << 8);
|
||||
return (val >> 8) | (val << 8);
|
||||
}
|
||||
|
||||
/* All registers are word-sized, except for the configuration register.
|
||||
@@ -288,10 +298,10 @@ u16 swap_bytes(u16 val)
|
||||
the usual practice. */
|
||||
int lm75_read_value(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
if (reg == LM75_REG_CONF)
|
||||
return i2c_smbus_read_byte_data(client,reg);
|
||||
else
|
||||
return swap_bytes(i2c_smbus_read_word_data(client,reg));
|
||||
if (reg == LM75_REG_CONF)
|
||||
return i2c_smbus_read_byte_data(client, reg);
|
||||
else
|
||||
return swap_bytes(i2c_smbus_read_word_data(client, reg));
|
||||
}
|
||||
|
||||
/* All registers are word-sized, except for the configuration register.
|
||||
@@ -299,99 +309,104 @@ int lm75_read_value(struct i2c_client *client, u8 reg)
|
||||
the usual practice. */
|
||||
int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
|
||||
{
|
||||
if (reg == LM75_REG_CONF)
|
||||
return i2c_smbus_write_byte_data(client,reg,value);
|
||||
else
|
||||
return i2c_smbus_write_word_data(client,reg,
|
||||
swap_bytes(value));
|
||||
if (reg == LM75_REG_CONF)
|
||||
return i2c_smbus_write_byte_data(client, reg, value);
|
||||
else
|
||||
return i2c_smbus_write_word_data(client, reg,
|
||||
swap_bytes(value));
|
||||
}
|
||||
|
||||
void lm75_init_client(struct i2c_client *client)
|
||||
{
|
||||
/* Initialize the LM75 chip */
|
||||
lm75_write_value(client,LM75_REG_TEMP_OS,
|
||||
TEMP_TO_REG(LM75_INIT_TEMP_OS));
|
||||
lm75_write_value(client,LM75_REG_TEMP_HYST,
|
||||
TEMP_TO_REG(LM75_INIT_TEMP_HYST));
|
||||
lm75_write_value(client,LM75_REG_CONF,0);
|
||||
/* Initialize the LM75 chip */
|
||||
lm75_write_value(client, LM75_REG_TEMP_OS,
|
||||
TEMP_TO_REG(LM75_INIT_TEMP_OS));
|
||||
lm75_write_value(client, LM75_REG_TEMP_HYST,
|
||||
TEMP_TO_REG(LM75_INIT_TEMP_HYST));
|
||||
lm75_write_value(client, LM75_REG_CONF, 0);
|
||||
}
|
||||
|
||||
void lm75_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct lm75_data *data = client->data;
|
||||
struct lm75_data *data = client->data;
|
||||
|
||||
down(&data->update_lock);
|
||||
down(&data->update_lock);
|
||||
|
||||
if ((jiffies - data->last_updated > HZ+HZ/2 ) ||
|
||||
(jiffies < data->last_updated) || ! data->valid) {
|
||||
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
|
||||
(jiffies < data->last_updated) || !data->valid) {
|
||||
|
||||
#ifdef DEBUG
|
||||
printk("Starting lm75 update\n");
|
||||
printk("Starting lm75 update\n");
|
||||
#endif
|
||||
|
||||
data->temp = lm75_read_value(client,LM75_REG_TEMP);
|
||||
data->temp_os = lm75_read_value(client,LM75_REG_TEMP_OS);
|
||||
data->temp_hyst = lm75_read_value(client,LM75_REG_TEMP_HYST);
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
data->temp = lm75_read_value(client, LM75_REG_TEMP);
|
||||
data->temp_os = lm75_read_value(client, LM75_REG_TEMP_OS);
|
||||
data->temp_hyst =
|
||||
lm75_read_value(client, LM75_REG_TEMP_HYST);
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
up(&data->update_lock);
|
||||
up(&data->update_lock);
|
||||
}
|
||||
|
||||
|
||||
void lm75_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
struct lm75_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 1;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
lm75_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->temp_os);
|
||||
results[1] = TEMP_FROM_REG(data->temp_hyst);
|
||||
results[2] = TEMP_FROM_REG(data->temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->temp_os = TEMP_TO_REG(results[0]);
|
||||
lm75_write_value(client,LM75_REG_TEMP_OS,data->temp_os);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->temp_hyst = TEMP_TO_REG(results[1]);
|
||||
lm75_write_value(client,LM75_REG_TEMP_HYST,data->temp_hyst);
|
||||
}
|
||||
}
|
||||
struct lm75_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 1;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
lm75_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->temp_os);
|
||||
results[1] = TEMP_FROM_REG(data->temp_hyst);
|
||||
results[2] = TEMP_FROM_REG(data->temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->temp_os = TEMP_TO_REG(results[0]);
|
||||
lm75_write_value(client, LM75_REG_TEMP_OS,
|
||||
data->temp_os);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->temp_hyst = TEMP_TO_REG(results[1]);
|
||||
lm75_write_value(client, LM75_REG_TEMP_HYST,
|
||||
data->temp_hyst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int __init sensors_lm75_init(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
printk("lm75.o version %s (%s)\n",LM_VERSION,LM_DATE);
|
||||
lm75_initialized = 0;
|
||||
if ((res = i2c_add_driver(&lm75_driver))) {
|
||||
printk("lm75.o: Driver registration failed, module not inserted.\n");
|
||||
lm75_cleanup();
|
||||
return res;
|
||||
}
|
||||
lm75_initialized ++;
|
||||
return 0;
|
||||
printk("lm75.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
lm75_initialized = 0;
|
||||
if ((res = i2c_add_driver(&lm75_driver))) {
|
||||
printk
|
||||
("lm75.o: Driver registration failed, module not inserted.\n");
|
||||
lm75_cleanup();
|
||||
return res;
|
||||
}
|
||||
lm75_initialized++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init lm75_cleanup(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
if (lm75_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&lm75_driver))) {
|
||||
printk("lm75.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
lm75_initialized --;
|
||||
}
|
||||
if (lm75_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&lm75_driver))) {
|
||||
printk
|
||||
("lm75.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
lm75_initialized--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
@@ -403,13 +418,12 @@ MODULE_DESCRIPTION("LM75 driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return sensors_lm75_init();
|
||||
return sensors_lm75_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return lm75_cleanup();
|
||||
return lm75_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
|
||||
#endif /* MODULE */
|
||||
+500
-453
File diff suppressed because it is too large.
Load diff
+433
-383
File diff suppressed because it is too large.
Load diff
+186
-179
@@ -60,10 +60,10 @@
|
||||
#endif
|
||||
|
||||
/* Addresses to scan */
|
||||
static unsigned short normal_i2c[] = {SENSORS_I2C_END};
|
||||
static unsigned short normal_i2c_range[] = {0x58,0x5a,SENSORS_I2C_END};
|
||||
static unsigned int normal_isa[] = {SENSORS_ISA_END};
|
||||
static unsigned int normal_isa_range[] = {SENSORS_ISA_END};
|
||||
static unsigned short normal_i2c[] = { SENSORS_I2C_END };
|
||||
static unsigned short normal_i2c_range[] = { 0x58, 0x5a, SENSORS_I2C_END };
|
||||
static unsigned int normal_isa[] = { SENSORS_ISA_END };
|
||||
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
|
||||
|
||||
/* Insmod parameters */
|
||||
SENSORS_INSMOD_1(ltc1710);
|
||||
@@ -73,56 +73,56 @@ SENSORS_INSMOD_1(ltc1710);
|
||||
/* (No registers. [Wow! This thing is SIMPLE!] ) */
|
||||
|
||||
/* Initial values */
|
||||
#define LTC1710_INIT 0 /* Both off */
|
||||
#define LTC1710_INIT 0 /* Both off */
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct ltc1710_data {
|
||||
int sysctl_id;
|
||||
int sysctl_id;
|
||||
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
|
||||
u8 status; /* Register values */
|
||||
u8 status; /* Register values */
|
||||
};
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init sensors_ltc1710_init(void);
|
||||
int __init sensors_ltc1710_init(void);
|
||||
static int __init ltc1710_cleanup(void);
|
||||
static int ltc1710_attach_adapter(struct i2c_adapter *adapter);
|
||||
static int ltc1710_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static int ltc1710_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static int ltc1710_detach_client(struct i2c_client *client);
|
||||
static int ltc1710_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
static void ltc1710_inc_use (struct i2c_client *client);
|
||||
static void ltc1710_dec_use (struct i2c_client *client);
|
||||
static void ltc1710_switch1(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void ltc1710_switch2(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
void *arg);
|
||||
static void ltc1710_inc_use(struct i2c_client *client);
|
||||
static void ltc1710_dec_use(struct i2c_client *client);
|
||||
static void ltc1710_switch1(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void ltc1710_switch2(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void ltc1710_update_client(struct i2c_client *client);
|
||||
|
||||
|
||||
/* This is the driver that will be inserted */
|
||||
static struct i2c_driver ltc1710_driver = {
|
||||
/* name */ "LTC1710 sensor chip driver",
|
||||
/* id */ I2C_DRIVERID_LTC1710,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ <c1710_attach_adapter,
|
||||
/* detach_client */ <c1710_detach_client,
|
||||
/* command */ <c1710_command,
|
||||
/* inc_use */ <c1710_inc_use,
|
||||
/* dec_use */ <c1710_dec_use
|
||||
/* name */ "LTC1710 sensor chip driver",
|
||||
/* id */ I2C_DRIVERID_LTC1710,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ <c1710_attach_adapter,
|
||||
/* detach_client */ <c1710_detach_client,
|
||||
/* command */ <c1710_command,
|
||||
/* inc_use */ <c1710_inc_use,
|
||||
/* dec_use */ <c1710_dec_use
|
||||
};
|
||||
|
||||
/* These files are created for each detected LTC1710. This is just a template;
|
||||
@@ -131,11 +131,11 @@ static struct i2c_driver ltc1710_driver = {
|
||||
is done through one of the 'extra' fields which are initialized
|
||||
when a new copy is allocated. */
|
||||
static ctl_table ltc1710_dir_table_template[] = {
|
||||
{ LTC1710_SYSCTL_SWITCH_1, "switch1", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, <c1710_switch1 },
|
||||
{ LTC1710_SYSCTL_SWITCH_2, "switch2", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, <c1710_switch2 },
|
||||
{ 0 }
|
||||
{LTC1710_SYSCTL_SWITCH_1, "switch1", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, <c1710_switch1},
|
||||
{LTC1710_SYSCTL_SWITCH_2, "switch2", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, <c1710_switch2},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* Used by init/cleanup */
|
||||
@@ -148,245 +148,252 @@ static int ltc1710_id = 0;
|
||||
|
||||
int ltc1710_attach_adapter(struct i2c_adapter *adapter)
|
||||
{
|
||||
return sensors_detect(adapter,&addr_data,ltc1710_detect);
|
||||
return sensors_detect(adapter, &addr_data, ltc1710_detect);
|
||||
}
|
||||
|
||||
/* This function is called by sensors_detect */
|
||||
int ltc1710_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
int ltc1710_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
{
|
||||
int i;
|
||||
struct i2c_client *new_client;
|
||||
struct ltc1710_data *data;
|
||||
int err=0;
|
||||
const char *type_name,*client_name;
|
||||
int i;
|
||||
struct i2c_client *new_client;
|
||||
struct ltc1710_data *data;
|
||||
int err = 0;
|
||||
const char *type_name, *client_name;
|
||||
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
#ifdef DEBUG
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk("ltc1710.o: ltc1710_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk
|
||||
("ltc1710.o: ltc1710_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE))
|
||||
goto ERROR0;
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
|
||||
goto ERROR0;
|
||||
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access ltc1710_{read,write}_value. */
|
||||
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct ltc1710_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access ltc1710_{read,write}_value. */
|
||||
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct ltc1710_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
data = (struct ltc1710_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = <c1710_driver;
|
||||
new_client->flags = 0;
|
||||
data = (struct ltc1710_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = <c1710_driver;
|
||||
new_client->flags = 0;
|
||||
|
||||
/* Now, we would do the remaining detection. But the LTC1710 is plainly
|
||||
impossible to detect! Stupid chip. */
|
||||
/* Now, we would do the remaining detection. But the LTC1710 is plainly
|
||||
impossible to detect! Stupid chip. */
|
||||
|
||||
/* Determine the chip type - only one kind supported! */
|
||||
if (kind <= 0)
|
||||
kind = ltc1710;
|
||||
/* Determine the chip type - only one kind supported! */
|
||||
if (kind <= 0)
|
||||
kind = ltc1710;
|
||||
|
||||
if (kind == ltc1710) {
|
||||
type_name = "ltc1710";
|
||||
client_name = "LTC1710 chip";
|
||||
} else {
|
||||
if (kind == ltc1710) {
|
||||
type_name = "ltc1710";
|
||||
client_name = "LTC1710 chip";
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
printk("ltc1710.o: Internal error: unknown kind (%d)?!?",kind);
|
||||
printk("ltc1710.o: Internal error: unknown kind (%d)?!?",
|
||||
kind);
|
||||
#endif
|
||||
goto ERROR1;
|
||||
}
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name,client_name);
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name, client_name);
|
||||
|
||||
new_client->id = ltc1710_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
new_client->id = ltc1710_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client,type_name,
|
||||
ltc1710_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client, type_name,
|
||||
ltc1710_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
/* OK, this is not exactly good programming practice, usually. But it is
|
||||
very code-efficient in this case. */
|
||||
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int ltc1710_detach_client(struct i2c_client *client)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
sensors_deregister_entry(((struct ltc1710_data *)(client->data))->sysctl_id);
|
||||
sensors_deregister_entry(((struct ltc1710_data *) (client->data))->
|
||||
sysctl_id);
|
||||
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk("ltc1710.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk
|
||||
("ltc1710.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
kfree(client);
|
||||
kfree(client);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* No commands defined yet */
|
||||
int ltc1710_command(struct i2c_client *client, unsigned int cmd, void *arg)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Nothing here yet */
|
||||
void ltc1710_inc_use (struct i2c_client *client)
|
||||
void ltc1710_inc_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Nothing here yet */
|
||||
void ltc1710_dec_use (struct i2c_client *client)
|
||||
void ltc1710_dec_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ltc1710_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct ltc1710_data *data = client->data;
|
||||
struct ltc1710_data *data = client->data;
|
||||
|
||||
down(&data->update_lock);
|
||||
down(&data->update_lock);
|
||||
|
||||
if ((jiffies - data->last_updated > HZ+HZ/2 ) ||
|
||||
(jiffies < data->last_updated) || ! data->valid) {
|
||||
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
|
||||
(jiffies < data->last_updated) || !data->valid) {
|
||||
|
||||
#ifdef DEBUG
|
||||
printk("Starting ltc1710 update\n");
|
||||
printk("Starting ltc1710 update\n");
|
||||
#endif
|
||||
|
||||
/* data->status = i2c_smbus_read_byte(client);
|
||||
Unfortunately, reads always fail! */
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
/* data->status = i2c_smbus_read_byte(client);
|
||||
Unfortunately, reads always fail! */
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
up(&data->update_lock);
|
||||
up(&data->update_lock);
|
||||
}
|
||||
|
||||
|
||||
void ltc1710_switch1(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void ltc1710_switch1(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
struct ltc1710_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
ltc1710_update_client(client);
|
||||
results[0] = data->status & 1;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->status = (data->status & 2) | results[0];
|
||||
i2c_smbus_write_byte(client,data->status);
|
||||
}
|
||||
}
|
||||
struct ltc1710_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
ltc1710_update_client(client);
|
||||
results[0] = data->status & 1;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->status = (data->status & 2) | results[0];
|
||||
i2c_smbus_write_byte(client, data->status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ltc1710_switch2(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void ltc1710_switch2(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
struct ltc1710_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
ltc1710_update_client(client);
|
||||
results[0] = (data->status & 2) >> 1;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->status = (data->status & 1) | (results[0] << 1);
|
||||
i2c_smbus_write_byte(client,data->status);
|
||||
}
|
||||
}
|
||||
struct ltc1710_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
ltc1710_update_client(client);
|
||||
results[0] = (data->status & 2) >> 1;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->status =
|
||||
(data->status & 1) | (results[0] << 1);
|
||||
i2c_smbus_write_byte(client, data->status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int __init sensors_ltc1710_init(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
printk("ltc1710.o version %s (%s)\n",LM_VERSION,LM_DATE);
|
||||
ltc1710_initialized = 0;
|
||||
if ((res = i2c_add_driver(<c1710_driver))) {
|
||||
printk("ltc1710.o: Driver registration failed, module not inserted.\n");
|
||||
ltc1710_cleanup();
|
||||
return res;
|
||||
}
|
||||
ltc1710_initialized ++;
|
||||
return 0;
|
||||
printk("ltc1710.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
ltc1710_initialized = 0;
|
||||
if ((res = i2c_add_driver(<c1710_driver))) {
|
||||
printk
|
||||
("ltc1710.o: Driver registration failed, module not inserted.\n");
|
||||
ltc1710_cleanup();
|
||||
return res;
|
||||
}
|
||||
ltc1710_initialized++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init ltc1710_cleanup(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
if (ltc1710_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(<c1710_driver))) {
|
||||
printk("ltc1710.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
ltc1710_initialized --;
|
||||
}
|
||||
if (ltc1710_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(<c1710_driver))) {
|
||||
printk
|
||||
("ltc1710.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
ltc1710_initialized--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_DESCRIPTION("LTC1710 driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return sensors_ltc1710_init();
|
||||
return sensors_ltc1710_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return ltc1710_cleanup();
|
||||
return ltc1710_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
|
||||
#endif /* MODULE */
|
||||
+164
-158
@@ -41,10 +41,10 @@
|
||||
#endif
|
||||
|
||||
/* Addresses to scan */
|
||||
static unsigned short normal_i2c[] = {0x2E,SENSORS_I2C_END};
|
||||
static unsigned short normal_i2c_range[] = {SENSORS_I2C_END};
|
||||
static unsigned int normal_isa[] = {SENSORS_ISA_END};
|
||||
static unsigned int normal_isa_range[] = {SENSORS_ISA_END};
|
||||
static unsigned short normal_i2c[] = { 0x2E, SENSORS_I2C_END };
|
||||
static unsigned short normal_i2c_range[] = { SENSORS_I2C_END };
|
||||
static unsigned int normal_isa[] = { SENSORS_ISA_END };
|
||||
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
|
||||
|
||||
/* Insmod parameters */
|
||||
SENSORS_INSMOD_1(matorb);
|
||||
@@ -54,51 +54,52 @@ SENSORS_INSMOD_1(matorb);
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct matorb_data {
|
||||
int sysctl_id;
|
||||
int sysctl_id;
|
||||
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
|
||||
};
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init sensors_matorb_init(void);
|
||||
int __init sensors_matorb_init(void);
|
||||
static int __init matorb_cleanup(void);
|
||||
static int matorb_attach_adapter(struct i2c_adapter *adapter);
|
||||
static int matorb_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static int matorb_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static void matorb_init_client(struct i2c_client *client);
|
||||
static int matorb_detach_client(struct i2c_client *client);
|
||||
static int matorb_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
static void matorb_inc_use (struct i2c_client *client);
|
||||
static void matorb_dec_use (struct i2c_client *client);
|
||||
static int matorb_write_value(struct i2c_client *client, u8 reg, u16 value);
|
||||
static void matorb_disp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
void *arg);
|
||||
static void matorb_inc_use(struct i2c_client *client);
|
||||
static void matorb_dec_use(struct i2c_client *client);
|
||||
static int matorb_write_value(struct i2c_client *client, u8 reg,
|
||||
u16 value);
|
||||
static void matorb_disp(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void matorb_update_client(struct i2c_client *client);
|
||||
|
||||
|
||||
/* This is the driver that will be inserted */
|
||||
static struct i2c_driver matorb_driver = {
|
||||
/* name */ "Matrix Orbital LCD driver",
|
||||
/* id */ I2C_DRIVERID_MATORB,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &matorb_attach_adapter,
|
||||
/* detach_client */ &matorb_detach_client,
|
||||
/* command */ &matorb_command,
|
||||
/* inc_use */ &matorb_inc_use,
|
||||
/* dec_use */ &matorb_dec_use
|
||||
/* name */ "Matrix Orbital LCD driver",
|
||||
/* id */ I2C_DRIVERID_MATORB,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &matorb_attach_adapter,
|
||||
/* detach_client */ &matorb_detach_client,
|
||||
/* command */ &matorb_command,
|
||||
/* inc_use */ &matorb_inc_use,
|
||||
/* dec_use */ &matorb_dec_use
|
||||
};
|
||||
|
||||
/* These files are created for each detected MATORB. This is just a template;
|
||||
@@ -107,9 +108,9 @@ static struct i2c_driver matorb_driver = {
|
||||
is done through one of the 'extra' fields which are initialized
|
||||
when a new copy is allocated. */
|
||||
static ctl_table matorb_dir_table_template[] = {
|
||||
{ MATORB_SYSCTL_DISP, "disp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &matorb_disp },
|
||||
{ 0 }
|
||||
{MATORB_SYSCTL_DISP, "disp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &matorb_disp},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* Used by init/cleanup */
|
||||
@@ -119,126 +120,129 @@ static int matorb_id = 0;
|
||||
|
||||
int matorb_attach_adapter(struct i2c_adapter *adapter)
|
||||
{
|
||||
return sensors_detect(adapter,&addr_data,matorb_detect);
|
||||
return sensors_detect(adapter, &addr_data, matorb_detect);
|
||||
}
|
||||
|
||||
/* This function is called by sensors_detect */
|
||||
int matorb_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
int matorb_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
{
|
||||
int i,cur;
|
||||
struct i2c_client *new_client;
|
||||
struct matorb_data *data;
|
||||
int err=0;
|
||||
const char *type_name="matorb";
|
||||
const char *client_name="matorb";
|
||||
int i, cur;
|
||||
struct i2c_client *new_client;
|
||||
struct matorb_data *data;
|
||||
int err = 0;
|
||||
const char *type_name = "matorb";
|
||||
const char *client_name = "matorb";
|
||||
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
#ifdef DEBUG
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk("matorb.o: matorb_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk
|
||||
("matorb.o: matorb_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_WRITE_BYTE |
|
||||
I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
|
||||
goto ERROR0;
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE |
|
||||
I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
|
||||
goto ERROR0;
|
||||
|
||||
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access matorb_{read,write}_value. */
|
||||
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct matorb_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access matorb_{read,write}_value. */
|
||||
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct matorb_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
data = (struct matorb_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &matorb_driver;
|
||||
new_client->flags = 0;
|
||||
data = (struct matorb_data *) (new_client + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &matorb_driver;
|
||||
new_client->flags = 0;
|
||||
|
||||
/* Now, we do the remaining detection. It is lousy. */
|
||||
cur = i2c_smbus_write_byte_data(new_client,0x0FE, 0x58); /* clear screen */
|
||||
|
||||
printk("matorb.o: debug detect 0x%X\n",cur);
|
||||
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name,client_name);
|
||||
/* Now, we do the remaining detection. It is lousy. */
|
||||
cur = i2c_smbus_write_byte_data(new_client, 0x0FE, 0x58); /* clear screen */
|
||||
|
||||
new_client->id = matorb_id ++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
printk("matorb.o: debug detect 0x%X\n", cur);
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client,type_name,
|
||||
matorb_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name, client_name);
|
||||
|
||||
matorb_init_client(new_client);
|
||||
return 0;
|
||||
new_client->id = matorb_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client, type_name,
|
||||
matorb_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
|
||||
matorb_init_client(new_client);
|
||||
return 0;
|
||||
|
||||
/* OK, this is not exactly good programming practice, usually. But it is
|
||||
very code-efficient in this case. */
|
||||
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
}
|
||||
|
||||
int matorb_detach_client(struct i2c_client *client)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
sensors_deregister_entry(((struct matorb_data *)(client->data))->sysctl_id);
|
||||
sensors_deregister_entry(((struct matorb_data *) (client->data))->
|
||||
sysctl_id);
|
||||
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk("matorb.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk
|
||||
("matorb.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
kfree(client);
|
||||
kfree(client);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* No commands defined yet */
|
||||
int matorb_command(struct i2c_client *client, unsigned int cmd, void *arg)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Nothing here yet */
|
||||
void matorb_inc_use (struct i2c_client *client)
|
||||
void matorb_inc_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Nothing here yet */
|
||||
void matorb_dec_use (struct i2c_client *client)
|
||||
void matorb_dec_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -248,7 +252,7 @@ void matorb_dec_use (struct i2c_client *client)
|
||||
the usual practice. */
|
||||
int matorb_read_value(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
return -1; /* Doesn't support reads */
|
||||
return -1; /* Doesn't support reads */
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -257,104 +261,106 @@ int matorb_read_value(struct i2c_client *client, u8 reg)
|
||||
the usual practice. */
|
||||
int matorb_write_value(struct i2c_client *client, u8 reg, u16 value)
|
||||
{
|
||||
if (reg==0) {
|
||||
return i2c_smbus_write_byte(client,value);
|
||||
} else {
|
||||
return i2c_smbus_write_byte_data(client,reg,value);
|
||||
}
|
||||
if (reg == 0) {
|
||||
return i2c_smbus_write_byte(client, value);
|
||||
} else {
|
||||
return i2c_smbus_write_byte_data(client, reg, value);
|
||||
}
|
||||
}
|
||||
|
||||
void matorb_init_client(struct i2c_client *client)
|
||||
{
|
||||
/* Initialize the MATORB chip */
|
||||
/* Initialize the MATORB chip */
|
||||
}
|
||||
|
||||
void matorb_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct matorb_data *data = client->data;
|
||||
struct matorb_data *data = client->data;
|
||||
|
||||
down(&data->update_lock);
|
||||
down(&data->update_lock);
|
||||
|
||||
if ((jiffies - data->last_updated > HZ+HZ/2 ) ||
|
||||
(jiffies < data->last_updated) || ! data->valid) {
|
||||
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
|
||||
(jiffies < data->last_updated) || !data->valid) {
|
||||
|
||||
#ifdef DEBUG
|
||||
printk("Starting matorb update\n");
|
||||
printk("Starting matorb update\n");
|
||||
#endif
|
||||
|
||||
/* nothing yet */
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
up(&data->update_lock);
|
||||
up(&data->update_lock);
|
||||
}
|
||||
|
||||
|
||||
void matorb_disp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
matorb_update_client(client);
|
||||
results[0] = 0;
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
for (i=1; i<=*nrels_mag;i++) {
|
||||
matorb_write_value(client,0,results[i-1]);
|
||||
}
|
||||
}
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
matorb_update_client(client);
|
||||
results[0] = 0;
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
for (i = 1; i <= *nrels_mag; i++) {
|
||||
matorb_write_value(client, 0, results[i - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int __init sensors_matorb_init(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
printk("matorb.o version %s (%s)\n",LM_VERSION,LM_DATE);
|
||||
matorb_initialized = 0;
|
||||
if ((res = i2c_add_driver(&matorb_driver))) {
|
||||
printk("matorb.o: Driver registration failed, module not inserted.\n");
|
||||
matorb_cleanup();
|
||||
return res;
|
||||
}
|
||||
matorb_initialized ++;
|
||||
return 0;
|
||||
printk("matorb.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
matorb_initialized = 0;
|
||||
if ((res = i2c_add_driver(&matorb_driver))) {
|
||||
printk
|
||||
("matorb.o: Driver registration failed, module not inserted.\n");
|
||||
matorb_cleanup();
|
||||
return res;
|
||||
}
|
||||
matorb_initialized++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init matorb_cleanup(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
if (matorb_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&matorb_driver))) {
|
||||
printk("matorb.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
matorb_initialized --;
|
||||
}
|
||||
if (matorb_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&matorb_driver))) {
|
||||
printk
|
||||
("matorb.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
matorb_initialized--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_DESCRIPTION("MATORB driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return sensors_matorb_init();
|
||||
return sensors_matorb_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return matorb_cleanup();
|
||||
return matorb_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
|
||||
#endif /* MODULE */
|
||||
+441
-412
File diff suppressed because it is too large.
Load diff
+430
-386
File diff suppressed because it is too large.
Load diff
+315
-285
@@ -39,10 +39,10 @@
|
||||
#endif
|
||||
|
||||
/* Addresses to scan */
|
||||
static unsigned short normal_i2c[] = {SENSORS_I2C_END};
|
||||
static unsigned short normal_i2c_range[] = {0x2D,0x2F,SENSORS_I2C_END};
|
||||
static unsigned int normal_isa[] = {SENSORS_ISA_END};
|
||||
static unsigned int normal_isa_range[] = {SENSORS_ISA_END};
|
||||
static unsigned short normal_i2c[] = { SENSORS_I2C_END };
|
||||
static unsigned short normal_i2c_range[] = { 0x2D, 0x2F, SENSORS_I2C_END };
|
||||
static unsigned int normal_isa[] = { SENSORS_ISA_END };
|
||||
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
|
||||
|
||||
/* Insmod parameters */
|
||||
SENSORS_INSMOD_1(thmc50);
|
||||
@@ -85,66 +85,68 @@ SENSORS_INSMOD_1(thmc50);
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct thmc50_data {
|
||||
int sysctl_id;
|
||||
int sysctl_id;
|
||||
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
struct semaphore update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
|
||||
u16 temp,temp_os,temp_hyst,
|
||||
remote_temp,remote_temp_os,remote_temp_hyst,
|
||||
inter, inter_mask, die_code, analog_out; /* Register values */
|
||||
u16 temp, temp_os, temp_hyst,
|
||||
remote_temp, remote_temp_os, remote_temp_hyst,
|
||||
inter, inter_mask, die_code, analog_out; /* Register values */
|
||||
};
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init sensors_thmc50_init(void);
|
||||
int __init sensors_thmc50_init(void);
|
||||
static int __init thmc50_cleanup(void);
|
||||
static int thmc50_attach_adapter(struct i2c_adapter *adapter);
|
||||
static int thmc50_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static int thmc50_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind);
|
||||
static void thmc50_init_client(struct i2c_client *client);
|
||||
static int thmc50_detach_client(struct i2c_client *client);
|
||||
static int thmc50_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
static void thmc50_inc_use (struct i2c_client *client);
|
||||
static void thmc50_dec_use (struct i2c_client *client);
|
||||
void *arg);
|
||||
static void thmc50_inc_use(struct i2c_client *client);
|
||||
static void thmc50_dec_use(struct i2c_client *client);
|
||||
static u16 swap_bytes(u16 val);
|
||||
static int thmc50_read_value(struct i2c_client *client, u8 reg);
|
||||
static int thmc50_write_value(struct i2c_client *client, u8 reg, u16 value);
|
||||
static void thmc50_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void thmc50_remote_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void thmc50_inter(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void thmc50_inter_mask(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void thmc50_die_code(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static void thmc50_analog_out(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results);
|
||||
static int thmc50_write_value(struct i2c_client *client, u8 reg,
|
||||
u16 value);
|
||||
static void thmc50_temp(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void thmc50_remote_temp(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag,
|
||||
long *results);
|
||||
static void thmc50_inter(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void thmc50_inter_mask(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void thmc50_die_code(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void thmc50_analog_out(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results);
|
||||
static void thmc50_update_client(struct i2c_client *client);
|
||||
|
||||
|
||||
/* This is the driver that will be inserted */
|
||||
static struct i2c_driver thmc50_driver = {
|
||||
/* name */ "THMC50 sensor chip driver",
|
||||
/* id */ I2C_DRIVERID_THMC50,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &thmc50_attach_adapter,
|
||||
/* detach_client */ &thmc50_detach_client,
|
||||
/* command */ &thmc50_command,
|
||||
/* inc_use */ &thmc50_inc_use,
|
||||
/* dec_use */ &thmc50_dec_use
|
||||
/* name */ "THMC50 sensor chip driver",
|
||||
/* id */ I2C_DRIVERID_THMC50,
|
||||
/* flags */ I2C_DF_NOTIFY,
|
||||
/* attach_adapter */ &thmc50_attach_adapter,
|
||||
/* detach_client */ &thmc50_detach_client,
|
||||
/* command */ &thmc50_command,
|
||||
/* inc_use */ &thmc50_inc_use,
|
||||
/* dec_use */ &thmc50_dec_use
|
||||
};
|
||||
|
||||
/* These files are created for each detected THMC50. This is just a template;
|
||||
@@ -153,19 +155,19 @@ static struct i2c_driver thmc50_driver = {
|
||||
is done through one of the 'extra' fields which are initialized
|
||||
when a new copy is allocated. */
|
||||
static ctl_table thmc50_dir_table_template[] = {
|
||||
{ THMC50_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_temp },
|
||||
{ THMC50_SYSCTL_REMOTE_TEMP, "remote_temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_remote_temp },
|
||||
{ THMC50_SYSCTL_INTER, "inter", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_inter },
|
||||
{ THMC50_SYSCTL_INTER_MASK, "inter_mask", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_inter_mask },
|
||||
{ THMC50_SYSCTL_DIE_CODE, "die_code", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_die_code },
|
||||
{ THMC50_SYSCTL_ANALOG_OUT, "analog_out", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_analog_out },
|
||||
{ 0 }
|
||||
{THMC50_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_temp},
|
||||
{THMC50_SYSCTL_REMOTE_TEMP, "remote_temp", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_remote_temp},
|
||||
{THMC50_SYSCTL_INTER, "inter", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_inter},
|
||||
{THMC50_SYSCTL_INTER_MASK, "inter_mask", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_inter_mask},
|
||||
{THMC50_SYSCTL_DIE_CODE, "die_code", NULL, 0, 0444, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_die_code},
|
||||
{THMC50_SYSCTL_ANALOG_OUT, "analog_out", NULL, 0, 0644, NULL, &sensors_proc_real,
|
||||
&sensors_sysctl_real, NULL, &thmc50_analog_out},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* Used by init/cleanup */
|
||||
@@ -175,150 +177,160 @@ static int thmc50_id = 0;
|
||||
|
||||
int thmc50_attach_adapter(struct i2c_adapter *adapter)
|
||||
{
|
||||
return sensors_detect(adapter,&addr_data,thmc50_detect);
|
||||
return sensors_detect(adapter, &addr_data, thmc50_detect);
|
||||
}
|
||||
|
||||
/* This function is called by sensors_detect */
|
||||
int thmc50_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
int thmc50_detect(struct i2c_adapter *adapter, int address,
|
||||
unsigned short flags, int kind)
|
||||
{
|
||||
int company,i;
|
||||
struct i2c_client *new_client;
|
||||
struct thmc50_data *data;
|
||||
int err=0;
|
||||
const char *type_name,*client_name;
|
||||
int company, i;
|
||||
struct i2c_client *new_client;
|
||||
struct thmc50_data *data;
|
||||
int err = 0;
|
||||
const char *type_name, *client_name;
|
||||
|
||||
#ifdef DEBUG
|
||||
printk("thmc50.o: Probing for THMC50 at 0x%2X on bus %d\n",address,adapter->id);
|
||||
printk("thmc50.o: Probing for THMC50 at 0x%2X on bus %d\n",
|
||||
address, adapter->id);
|
||||
#endif
|
||||
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
/* Make sure we aren't probing the ISA bus!! This is just a safety check
|
||||
at this moment; sensors_detect really won't call us. */
|
||||
#ifdef DEBUG
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk("thmc50.o: thmc50_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
if (i2c_is_isa_adapter(adapter)) {
|
||||
printk
|
||||
("thmc50.o: thmc50_detect called for an ISA bus adapter?!?\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
goto ERROR0;
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
goto ERROR0;
|
||||
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access thmc50_{read,write}_value. */
|
||||
if (! (new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct thmc50_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
/* OK. For now, we presume we have a valid client. We now create the
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access thmc50_{read,write}_value. */
|
||||
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct thmc50_data),
|
||||
GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
data = (struct thmc50_data *) (((struct i2c_client *) new_client) + 1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &thmc50_driver;
|
||||
new_client->flags = 0;
|
||||
data =
|
||||
(struct thmc50_data *) (((struct i2c_client *) new_client) +
|
||||
1);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
new_client->driver = &thmc50_driver;
|
||||
new_client->flags = 0;
|
||||
|
||||
/* Now, we do the remaining detection. */
|
||||
company = i2c_smbus_read_byte_data(new_client,THMC50_REG_COMPANY_ID);
|
||||
/* Now, we do the remaining detection. */
|
||||
company =
|
||||
i2c_smbus_read_byte_data(new_client, THMC50_REG_COMPANY_ID);
|
||||
|
||||
if (company != 0x49) {
|
||||
if (company != 0x49) {
|
||||
#ifdef DEBUG
|
||||
printk("thmc50.o: Detect of THMC50 failed (reg 3E: 0x%X)\n",company);
|
||||
printk
|
||||
("thmc50.o: Detect of THMC50 failed (reg 3E: 0x%X)\n",
|
||||
company);
|
||||
#endif
|
||||
goto ERROR1;
|
||||
}
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
/* Determine the chip type - only one kind supported! */
|
||||
kind = thmc50;
|
||||
/* Determine the chip type - only one kind supported! */
|
||||
kind = thmc50;
|
||||
|
||||
if (kind == thmc50) {
|
||||
type_name = "thmc50";
|
||||
client_name = "THMC50 chip";
|
||||
} else {
|
||||
if (kind == thmc50) {
|
||||
type_name = "thmc50";
|
||||
client_name = "THMC50 chip";
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
printk("thmc50.o: Internal error: unknown kind (%d)?!?",kind);
|
||||
printk("thmc50.o: Internal error: unknown kind (%d)?!?",
|
||||
kind);
|
||||
#endif
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name,client_name);
|
||||
goto ERROR1;
|
||||
}
|
||||
|
||||
new_client->id = thmc50_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
/* Fill in the remaining client fields and put it into the global list */
|
||||
strcpy(new_client->name, client_name);
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client,type_name,
|
||||
thmc50_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
new_client->id = thmc50_id++;
|
||||
data->valid = 0;
|
||||
init_MUTEX(&data->update_lock);
|
||||
|
||||
thmc50_init_client(new_client);
|
||||
return 0;
|
||||
/* Tell the I2C layer a new client has arrived */
|
||||
if ((err = i2c_attach_client(new_client)))
|
||||
goto ERROR3;
|
||||
|
||||
/* Register a new directory entry with module sensors */
|
||||
if ((i = sensors_register_entry(new_client, type_name,
|
||||
thmc50_dir_table_template,
|
||||
THIS_MODULE)) < 0) {
|
||||
err = i;
|
||||
goto ERROR4;
|
||||
}
|
||||
data->sysctl_id = i;
|
||||
|
||||
thmc50_init_client(new_client);
|
||||
return 0;
|
||||
|
||||
/* OK, this is not exactly good programming practice, usually. But it is
|
||||
very code-efficient in this case. */
|
||||
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
ERROR4:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR3:
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
ERROR0:
|
||||
return err;
|
||||
}
|
||||
|
||||
int thmc50_detach_client(struct i2c_client *client)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
sensors_deregister_entry(((struct thmc50_data *)(client->data))->sysctl_id);
|
||||
sensors_deregister_entry(((struct thmc50_data *) (client->data))->
|
||||
sysctl_id);
|
||||
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk("thmc50.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
if ((err = i2c_detach_client(client))) {
|
||||
printk
|
||||
("thmc50.o: Client deregistration failed, client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
kfree(client);
|
||||
kfree(client);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* No commands defined yet */
|
||||
int thmc50_command(struct i2c_client *client, unsigned int cmd, void *arg)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void thmc50_inc_use (struct i2c_client *client)
|
||||
void thmc50_inc_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
void thmc50_dec_use (struct i2c_client *client)
|
||||
void thmc50_dec_use(struct i2c_client *client)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
u16 swap_bytes(u16 val)
|
||||
{
|
||||
return (val >> 8) | (val << 8);
|
||||
return (val >> 8) | (val << 8);
|
||||
}
|
||||
|
||||
/* All registers are word-sized, except for the configuration register.
|
||||
@@ -326,7 +338,7 @@ u16 swap_bytes(u16 val)
|
||||
the usual practice. */
|
||||
int thmc50_read_value(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
return i2c_smbus_read_byte_data(client,reg);
|
||||
return i2c_smbus_read_byte_data(client, reg);
|
||||
}
|
||||
|
||||
/* All registers are word-sized, except for the configuration register.
|
||||
@@ -334,167 +346,183 @@ int thmc50_read_value(struct i2c_client *client, u8 reg)
|
||||
the usual practice. */
|
||||
int thmc50_write_value(struct i2c_client *client, u8 reg, u16 value)
|
||||
{
|
||||
return i2c_smbus_write_byte_data(client,reg,value);
|
||||
return i2c_smbus_write_byte_data(client, reg, value);
|
||||
}
|
||||
|
||||
void thmc50_init_client(struct i2c_client *client)
|
||||
{
|
||||
/* Initialize the THMC50 chip */
|
||||
thmc50_write_value(client,THMC50_REG_TEMP_OS,
|
||||
TEMP_TO_REG(THMC50_INIT_TEMP_OS));
|
||||
thmc50_write_value(client,THMC50_REG_TEMP_HYST,
|
||||
TEMP_TO_REG(THMC50_INIT_TEMP_HYST));
|
||||
thmc50_write_value(client,THMC50_REG_CONF,1);
|
||||
/* Initialize the THMC50 chip */
|
||||
thmc50_write_value(client, THMC50_REG_TEMP_OS,
|
||||
TEMP_TO_REG(THMC50_INIT_TEMP_OS));
|
||||
thmc50_write_value(client, THMC50_REG_TEMP_HYST,
|
||||
TEMP_TO_REG(THMC50_INIT_TEMP_HYST));
|
||||
thmc50_write_value(client, THMC50_REG_CONF, 1);
|
||||
}
|
||||
|
||||
void thmc50_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct thmc50_data *data = client->data;
|
||||
struct thmc50_data *data = client->data;
|
||||
|
||||
down(&data->update_lock);
|
||||
down(&data->update_lock);
|
||||
|
||||
if ((jiffies - data->last_updated > HZ+HZ/2 ) ||
|
||||
(jiffies < data->last_updated) || ! data->valid) {
|
||||
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
|
||||
(jiffies < data->last_updated) || !data->valid) {
|
||||
|
||||
#ifdef DEBUG
|
||||
printk("Starting thmc50 update\n");
|
||||
printk("Starting thmc50 update\n");
|
||||
#endif
|
||||
|
||||
data->temp = thmc50_read_value(client,THMC50_REG_TEMP);
|
||||
data->temp_os = thmc50_read_value(client,THMC50_REG_TEMP_OS);
|
||||
data->temp_hyst = thmc50_read_value(client,THMC50_REG_TEMP_HYST);
|
||||
data->remote_temp = thmc50_read_value(client,THMC50_REG_REMOTE_TEMP);
|
||||
data->remote_temp_os = thmc50_read_value(client,THMC50_REG_REMOTE_TEMP_OS);
|
||||
data->remote_temp_hyst = thmc50_read_value(client,THMC50_REG_REMOTE_TEMP_HYST);
|
||||
data->inter = thmc50_read_value(client,THMC50_REG_INTER);
|
||||
data->inter_mask = thmc50_read_value(client,THMC50_REG_INTER_MASK);
|
||||
data->die_code = thmc50_read_value(client,THMC50_REG_DIE_CODE);
|
||||
data->analog_out = thmc50_read_value(client,THMC50_REG_ANALOG_OUT);
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
data->temp = thmc50_read_value(client, THMC50_REG_TEMP);
|
||||
data->temp_os =
|
||||
thmc50_read_value(client, THMC50_REG_TEMP_OS);
|
||||
data->temp_hyst =
|
||||
thmc50_read_value(client, THMC50_REG_TEMP_HYST);
|
||||
data->remote_temp =
|
||||
thmc50_read_value(client, THMC50_REG_REMOTE_TEMP);
|
||||
data->remote_temp_os =
|
||||
thmc50_read_value(client, THMC50_REG_REMOTE_TEMP_OS);
|
||||
data->remote_temp_hyst =
|
||||
thmc50_read_value(client, THMC50_REG_REMOTE_TEMP_HYST);
|
||||
data->inter = thmc50_read_value(client, THMC50_REG_INTER);
|
||||
data->inter_mask =
|
||||
thmc50_read_value(client, THMC50_REG_INTER_MASK);
|
||||
data->die_code =
|
||||
thmc50_read_value(client, THMC50_REG_DIE_CODE);
|
||||
data->analog_out =
|
||||
thmc50_read_value(client, THMC50_REG_ANALOG_OUT);
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
up(&data->update_lock);
|
||||
up(&data->update_lock);
|
||||
}
|
||||
|
||||
|
||||
void thmc50_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->temp_os);
|
||||
results[1] = TEMP_FROM_REG(data->temp_hyst);
|
||||
results[2] = TEMP_FROM_REG(data->temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->temp_os = TEMP_TO_REG(results[0]);
|
||||
thmc50_write_value(client,THMC50_REG_TEMP_OS,data->temp_os);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->temp_hyst = TEMP_TO_REG(results[1]);
|
||||
thmc50_write_value(client,THMC50_REG_TEMP_HYST,data->temp_hyst);
|
||||
}
|
||||
}
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->temp_os);
|
||||
results[1] = TEMP_FROM_REG(data->temp_hyst);
|
||||
results[2] = TEMP_FROM_REG(data->temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->temp_os = TEMP_TO_REG(results[0]);
|
||||
thmc50_write_value(client, THMC50_REG_TEMP_OS,
|
||||
data->temp_os);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->temp_hyst = TEMP_TO_REG(results[1]);
|
||||
thmc50_write_value(client, THMC50_REG_TEMP_HYST,
|
||||
data->temp_hyst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void thmc50_remote_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void thmc50_remote_temp(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->remote_temp_os);
|
||||
results[1] = TEMP_FROM_REG(data->remote_temp_hyst);
|
||||
results[2] = TEMP_FROM_REG(data->remote_temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->remote_temp_os = TEMP_TO_REG(results[0]);
|
||||
thmc50_write_value(client,THMC50_REG_REMOTE_TEMP_OS,data->remote_temp_os);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->remote_temp_hyst = TEMP_TO_REG(results[1]);
|
||||
thmc50_write_value(client,THMC50_REG_REMOTE_TEMP_HYST,data->remote_temp_hyst);
|
||||
}
|
||||
}
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->remote_temp_os);
|
||||
results[1] = TEMP_FROM_REG(data->remote_temp_hyst);
|
||||
results[2] = TEMP_FROM_REG(data->remote_temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->remote_temp_os = TEMP_TO_REG(results[0]);
|
||||
thmc50_write_value(client,
|
||||
THMC50_REG_REMOTE_TEMP_OS,
|
||||
data->remote_temp_os);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->remote_temp_hyst = TEMP_TO_REG(results[1]);
|
||||
thmc50_write_value(client,
|
||||
THMC50_REG_REMOTE_TEMP_HYST,
|
||||
data->remote_temp_hyst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void thmc50_inter(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
int *nrels_mag, long *results)
|
||||
{
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = data->inter;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
printk("thmc50.o: No writes to Interrupt register!\n");
|
||||
}
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = data->inter;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
printk("thmc50.o: No writes to Interrupt register!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void thmc50_inter_mask(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void thmc50_inter_mask(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = data->inter_mask;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->inter_mask = results[0];
|
||||
thmc50_write_value(client,THMC50_REG_INTER_MASK,data->inter_mask);
|
||||
}
|
||||
}
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = data->inter_mask;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->inter_mask = results[0];
|
||||
thmc50_write_value(client, THMC50_REG_INTER_MASK,
|
||||
data->inter_mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void thmc50_die_code(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void thmc50_die_code(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = data->die_code;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
printk("thmc50.o: No writes to Die-Code register!\n");
|
||||
}
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = data->die_code;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
printk("thmc50.o: No writes to Die-Code register!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void thmc50_analog_out(struct i2c_client *client, int operation, int ctl_name,
|
||||
int *nrels_mag, long *results)
|
||||
void thmc50_analog_out(struct i2c_client *client, int operation,
|
||||
int ctl_name, int *nrels_mag, long *results)
|
||||
{
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = data->analog_out;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->analog_out = results[0];
|
||||
thmc50_write_value(client,THMC50_REG_ANALOG_OUT,data->analog_out);
|
||||
}
|
||||
}
|
||||
struct thmc50_data *data = client->data;
|
||||
if (operation == SENSORS_PROC_REAL_INFO)
|
||||
*nrels_mag = 0;
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
thmc50_update_client(client);
|
||||
results[0] = data->analog_out;
|
||||
*nrels_mag = 1;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->analog_out = results[0];
|
||||
thmc50_write_value(client, THMC50_REG_ANALOG_OUT,
|
||||
data->analog_out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -502,50 +530,52 @@ void thmc50_analog_out(struct i2c_client *client, int operation, int ctl_name,
|
||||
|
||||
int __init sensors_thmc50_init(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
printk("thmc50.o version %s (%s)\n",LM_VERSION,LM_DATE);
|
||||
thmc50_initialized = 0;
|
||||
if ((res = i2c_add_driver(&thmc50_driver))) {
|
||||
printk("thmc50.o: Driver registration failed, module not inserted.\n");
|
||||
thmc50_cleanup();
|
||||
return res;
|
||||
}
|
||||
thmc50_initialized ++;
|
||||
return 0;
|
||||
printk("thmc50.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
thmc50_initialized = 0;
|
||||
if ((res = i2c_add_driver(&thmc50_driver))) {
|
||||
printk
|
||||
("thmc50.o: Driver registration failed, module not inserted.\n");
|
||||
thmc50_cleanup();
|
||||
return res;
|
||||
}
|
||||
thmc50_initialized++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init thmc50_cleanup(void)
|
||||
{
|
||||
int res;
|
||||
int res;
|
||||
|
||||
if (thmc50_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&thmc50_driver))) {
|
||||
printk("thmc50.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
thmc50_initialized --;
|
||||
}
|
||||
if (thmc50_initialized >= 1) {
|
||||
if ((res = i2c_del_driver(&thmc50_driver))) {
|
||||
printk
|
||||
("thmc50.o: Driver deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
}
|
||||
thmc50_initialized--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_DESCRIPTION("THMC50 driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return sensors_thmc50_init();
|
||||
return sensors_thmc50_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return thmc50_cleanup();
|
||||
return thmc50_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
|
||||
#endif /* MODULE */
|
||||
+1314
-1123
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user