From owner-freebsd-hackers Thu Nov 12 14:42:31 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id OAA03481 for freebsd-hackers-outgoing; Thu, 12 Nov 1998 14:42:31 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from reliam.teaser.fr (reliam.teaser.fr [194.51.80.12]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id OAA03471 for ; Thu, 12 Nov 1998 14:42:27 -0800 (PST) (envelope-from son@teaser.fr) Received: from teaser.fr (ppp1087-ft.teaser.fr [194.206.156.40]) by reliam.teaser.fr (8.9.1a/8.9.1a) with ESMTP id XAA21750; Thu, 12 Nov 1998 23:41:53 +0100 (MET) Received: (from son@localhost) by teaser.fr (8.9.1/8.8.5) id AAA01122; Fri, 13 Nov 1998 00:17:48 GMT Message-ID: <19981113001748.14820@breizh.prism.uvsq.fr> Date: Fri, 13 Nov 1998 00:17:48 +0000 From: Nicolas Souchu To: Ron Klinkien Cc: freebsd-hackers@FreeBSD.ORG, Marc Bouget Subject: Re: i2c projects References: <19981109211837.A4702@zappa.demon.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81e In-Reply-To: <19981109211837.A4702@zappa.demon.nl>; from Ron Klinkien on Mon, Nov 09, 1998 at 09:18:37PM +0100 X-Operating-System: FreeBSD breizh 3.0-CURRENT FreeBSD 3.0-CURRENT Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, Nov 09, 1998 at 09:18:37PM +0100, Ron Klinkien wrote: > > > >Does anyone have any pointers/src code on how to use >the i2c drivers with FreeBSD? > >I want to build a weather station / home automation project using a FreeBSD running pc, >and the i2c bus on my video capture card. Cool. FreeBSD is the good choice. > >The i2c driver src and man pages don't give me enough info.. > >Furthermore I have compiled a kernel with i2c support >but there are no ii* devices in /dev, and not in MAKEDEV too. Yes, this is lacking. Waiting for a MAKEDEV update, try: mknod iic0 c 105 0 mknod smb0 c 106 0 and so on, replacing 0 by 1,2... > >Which major/minor numbers to use etc...? You would have found them in the related drivers: /sys/dev/iicbus/iic.c /sys/dev/smbus/smb.c > >Regards, >Ron. > iicbus is a powerfull framework that should bring you all what you need with only few indications about how to use it. First of all, which video card do you have? A bt848 based card? Perfect, the drivers are ready to work. As described in the bktr man page, you'll need in addition to 'device bktr0' in your /sys/i386/conf/MACHINE file: controller iicbus0 controller iicbb0 device iic0 at iicbus? controller smbus0 device smb0 at smbus? -- Now, you want to write user/kernel code? If you need kernel code which is uncertain, /sys/dev/iicbus/iic.c will be a good start. Read, copy and modify it as needed. For userland code, you'll have to add your devices in /sys/dev/iicbus/iic.c: { "iic", IICBUS_DEVICE_CLASS, "MY DEVICE IDENTIFIER", MY_DEVICE_ADDRESS}, like this (for each device on you I2C bus): /* * list of known devices */ struct iicbus_device iicbus_children[] = { { "iicsmb", IICBUS_DRIVER_CLASS, "I2C to SMB bridge" }, { "iic", IICBUS_DEVICE_CLASS, "MY DEVICE IDENTIFIER", MY_DEVICE_ADDRESS}, { "iic", IICBUS_DEVICE_CLASS, "PCF8574 I2C to 8 bits parallel i/o", 64}, { "iic", IICBUS_DEVICE_CLASS, "PCF8584 as slave", PCF_MASTER_ADDRESS }, { "ic", IICBUS_DEVICE_CLASS, "network interface", PCF_MASTER_ADDRESS }, #if 0 { "iic", IICBUS_DRIVER_CLASS, "General Call", I2C_GENERAL_CALL }, #endif { NULL, 0 } }; -- Then see /usr/include/machine/iic.h to have the ioctls on /dev/iic? They are implemented by /sys/dev/iicbus/iic.c Nicolas. -- nsouch@teaser.fr / nsouch@freebsd.org FreeBSD - Turning PCs into workstations - http://www.FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message