Skip to contentSkip to conversation

Need help: Watchdog-driver over smbus (i2c)

DISCUSSION Sven Anders 2 participants 4 messages Nov 30, 2009 – Dec 3, 2009 3 messages not in the archive I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

Hello!

I'm trying to code a watchdog driver for the Winbond w83793g chip. I already coded a watchdog for another Winbond chip before, but for this I need to access it over the system managment bus (or more specific the i2c, client address 2E).

I already coded the detection and initialization routines, but now I need some help, because I do not know how to use the i2c framework together with the watchdog framework.
All other drivers I found are using the sysfs framework. This functions use the to_i2c_client() function to get a pointer to the i2c client.

I tried to store the i2c client pointer to a global variable, to use it later in the watchdog functions.
But when I try to use the "i2c_smbus_read_byte_data()" or "i2c_smbus_write_byte_data()" functions, I will get a kernel OOPS (without any hw-sensors driver loaded!).

What is the best method to get the watchdog framework (i.e. the open, close, write, read and ioctl functions) to work with the i2c framework?

Moreover the w83793g hardware sensors driver may already accessing the same chip. What is the normal way to deal with this?

Regards
Sven Anders

Signature · 9 lines
 Sven Anders <[email protected]>                 () Ascii Ribbon Campaign
                                                 /\ Support plain text e-mail
 ANDURAS service solutions AG
 Innstrasse 71 - 94036 Passau - Germany
 Web: www.anduras.de - Tel: +49 (0)851-4 90 50-0 - Fax: +49 (0)851-4 90 50-55

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
  - Benjamin Franklin

begin:vcard
fn:Sven Anders
n:Anders;Sven
org:ANDURAS AG;Research and Development adr;quoted-printable:;;Innstra=C3=9Fe 71;Passau;Bavaria;94036;Germany email;internet:[email protected] title:Dipl. Inf.
tel;work:++49 (0)851 / 490 50 -0
tel;fax:++49 (0)851 / 590 50 - 55
x-mozilla-html:FALSE
url:http://www.anduras.de
version:2.1
end:vcard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hallo Sven,

Quoted 14 lines · Sven Anders

I'm trying to code a watchdog driver for the Winbond w83793g chip. I already coded a watchdog for another Winbond chip before, but for this I need to access it over the system managment bus (or more specific the i2c, client address 2E).

I already coded the detection and initialization routines, but now I need some help, because I do not know how to use the i2c framework together with the watchdog framework.
All other drivers I found are using the sysfs framework. This functions use the to_i2c_client() function to get a pointer to the i2c client.

I tried to store the i2c client pointer to a global variable, to use it later in the watchdog functions.

Quoted 6 lines

But when I try to use the "i2c_smbus_read_byte_data()" or "i2c_smbus_write_byte_data()" functions, I will get a kernel OOPS (without any hw-sensors driver loaded!).

What is the best method to get the watchdog framework (i.e. the open, close, write, read and ioctl functions) to work with the i2c framework?

The fact that the device is accessed over I2C/SMBus doesn't change anything to the watchdog interface. It is only an implementation detail for the way the data registers are accessed.

Quoted 2 lines

Moreover the w83793g hardware sensors driver may already accessing the same chip. What is the normal way to deal with this?

Do not write a separate driver for the watchdog functionality. Instead, add the functionality to the existing hwmon/w83793.c driver. Otherwise both features will be mutually exclusive.

An example of how this can be done is in hwmon/fschmd.c [1] if you want to take a look. This is an I2C/SMBus device driver as well, so your code should be very similar in the end.

[1] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=drivers/hwmon/fschmd.c

Hope this helps,

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 11 lines · Jean Delvare

Hallo Sven,

Quoted 2 lines · Sven Anders

Moreover the w83793g hardware sensors driver may already accessing the same chip. What is the normal way to deal with this?

Do not write a separate driver for the watchdog functionality. Instead, add the functionality to the existing hwmon/w83793.c driver. Otherwise both features will be mutually exclusive.

Quoted 7 lines

An example of how this can be done is in hwmon/fschmd.c [1] if you want to take a look. This is an I2C/SMBus device driver as well, so your code should be very similar in the end.

[1] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=drivers/hwmon/fschmd.c

Hope this helps,

Yes, thanks! This was the hint I needed.
Now I finished the watchdog driver and it's working!

Regards
Sven Anders

Signature · 9 lines
 Sven Anders <[email protected]>                 () Ascii Ribbon Campaign
                                                 /\ Support plain text e-mail
 ANDURAS service solutions AG
 Innstrasse 71 - 94036 Passau - Germany
 Web: www.anduras.de - Tel: +49 (0)851-4 90 50-0 - Fax: +49 (0)851-4 90 50-55

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
  - Benjamin Franklin

begin:vcard
fn:Sven Anders
n:Anders;Sven
org:ANDURAS AG;Research and Development adr;quoted-printable:;;Innstra=C3=9Fe 71;Passau;Bavaria;94036;Germany email;internet:[email protected] title:Dipl. Inf.
tel;work:++49 (0)851 / 490 50 -0
tel;fax:++49 (0)851 / 590 50 - 55
x-mozilla-html:FALSE
url:http://www.anduras.de
version:2.1
end:vcard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 16 lines · Sven Anders
Quoted 15 lines · Jean Delvare

Hallo Sven,

Quoted 2 lines · Sven Anders

Moreover the w83793g hardware sensors driver may already accessing the same chip. What is the normal way to deal with this?

Do not write a separate driver for the watchdog functionality. Instead, add the functionality to the existing hwmon/w83793.c driver. Otherwise both features will be mutually exclusive.

An example of how this can be done is in hwmon/fschmd.c [1] if you want to take a look. This is an I2C/SMBus device driver as well, so your code should be very similar in the end.

Quoted 6 lines
Quoted 3 lines

[1] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=drivers/hwmon/fschmd.c

Hope this helps,

Yes, thanks! This was the hint I needed.
Now I finished the watchdog driver and it's working!

Cool. When it's ready, please send it over to the lm-sensors list so that it gets merged.

Signature · 1 line
Jean Delvare