OpenBSD Journal
Home : : Add Story : : Archives : : About : : Create Account : : Login :
Developer blog: cnst@: wbng(4) and how it was written
Contributed by dwc on Mon Oct 29 08:00:00 2007 (GMT)
from the I-too-see-more dept.

Constantine A. Murenin (cnst@) writes:

Two weeks ago I wrote a new sensor driver, wbng(4). Below is some history on how it was written…

The story started several months ago, when I was having a chat with some Winbond engineers requesting the datasheet to support the W83627DHG chip on my ASUS barebone. The Winbond guys asked me which chips we currently support, and after I've provided them with our extensive list, they've suggested that a new chip called W83793G was released recently, targeted primarily for servers and workstations, and we might want to support it, too. I've put that into my todo list, and after looking at the register set in the datasheet, decided that a new driver had to be written, because the lm-compatibility registers together with the divisor bits “scattered all over the place” are finally all gone (and thank god for that — the new design is just so much cleaner).

As the Winbond W83793G Hardware Monitor chip itself only provides the iic(4), not isa(4), interface, the next step was to look at our dmesglog archive, where users send in their dmesgs. By default in -current since about 3.9, and in releases since 4.1, our i2c_scan.c component automatically outputs the register dump of unsupported i2c devices right into the dmesg. This dump can then be used by developers to identify which I2C chips are present in the machine in question, and to write a probe signature and driver code after confirming details with the datasheets etc.

Grepping through dmesgs in our dmesglog, I've identified that several of our users were in fact having this chip already. So the next step was writing a probe signature and a driver. Having some free time and wanting to write a driver from scratch, I've decided to recreate some of the kernel interfaces in the userland, so that I could use the actual register dump to test the driver without having any hardware.

So that's how the driver was written and tested. A userland programme was used to parse the iic dump and emulate the iic_exec(9) interface, and to call the wbng_ca.ca_attach() function. This resulted in the driver being entirely functional at the time it was committed into OpenBSD, even though it was not tested on real hardware before it was committed. After committing it, I've asked one of our misc@ subscribers, Jon Steel, who previously tried adding a “quick-and-dirty” support for some monitoring capabilities of this chip to the lm(4) driver, to test the new wbng(4) driver, and there it was. :)

As a conclusion, I'd like to thank all of those users that regularly send in their dmesg's to our archive. Without them, this and many other drivers would not have been possible. If you, the reader, haven't sent in your dmesg yet, please do try to find a minute to do so — it'll be worth your while in the long run!


<< OpenBSD on OSDN conference in Ukraine | Reply | Flattened | Expanded | Jun-ichiro “itojun” Itoh Hagino >>

Threshold: Help

Related Links
more by dwc

  Re: Developer blog: cnst@: wbng(4) and how it was written (mod 5/49)
by Anonymous Coward ( on Mon Oct 29 20:10:52 2007 (GMT)
  Cool, I never knew about that dmesglog archive and if it can help out in any way, it's no trouble for me to email it.

I'll send one once 4.2 is out and installed on this ASUS system, along with 4.2 from my WRAP box too (if it's worth it?).
  [ Show thread ] [ Reply to this comment ] [ Mod Up ] [ Mod Down ]

  Re: Developer blog: cnst@: wbng(4) and how it was written (mod 2/46)
by vext01 ( on Tue Oct 30 13:48:38 2007 (GMT)
  Great, this has encouraged me to send the dmesg's of my machines to dmesg@.
  [ Show thread ] [ Reply to this comment ] [ Mod Up ] [ Mod Down ]

  Re: Developer blog: cnst@: wbng(4) and how it was written (mod 7/49)
by Anonymous Coward ( on Tue Oct 30 17:02:43 2007 (GMT)
  will send my dmesg also for an NVIDIA nForce 570 SLI MCP, amd64 x2 with 4G ddr2, and HDA audio
  [ Show thread ] [ Reply to this comment ] [ Mod Up ] [ Mod Down ]

[ Home | Add Story | Archives | Polls | About ]

Copyright © 2004-2008 Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to April 2nd 2004 as well as images and HTML templates were copied from the fabulous original with Jose's and Jim's kind permission. Some icons from used with permission from Kathleen. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. Search engine is ht://Dig. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]