Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Nov 1998 00:17:48 +0000
From:      Nicolas Souchu <nsouch@teaser.fr>
To:        Ron Klinkien <root@zappa.demon.nl>
Cc:        freebsd-hackers@FreeBSD.ORG, Marc Bouget <mbouget@club-internet.fr>
Subject:   Re: i2c projects
Message-ID:  <19981113001748.14820@breizh.prism.uvsq.fr>
In-Reply-To: <19981109211837.A4702@zappa.demon.nl>; from Ron Klinkien on Mon, Nov 09, 1998 at 09:18:37PM %2B0100
References:  <19981109211837.A4702@zappa.demon.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981113001748.14820>