i2c driver newbie question

Artem Kim artem_kim at inbox.ru
Tue Feb 5 16:16:33 UTC 2008

Can anybody help my to write i2c drivers for saa7146 ?

I do not good understand how to connect this device to existing  iicbus 

I do:

static device_method_t saa7146_i2c_methods[] = {
	/* device interface */
	DEVMETHOD(device_probe,		saa7146_i2c_probe),
	DEVMETHOD(device_attach,	saa7146_i2c_attach),
	DEVMETHOD(device_detach,	saa7146_i2c_detach),
	/* iicbus interface */
	DEVMETHOD(iicbus_callback,	iicbus_null_callback),
	DEVMETHOD(iicbus_repeated_start, saa7146_i2c_repeated_start),
	DEVMETHOD(iicbus_start,         saa7146_i2c_start),
	DEVMETHOD(iicbus_stop,		saa7146_i2c_stop),
	DEVMETHOD(iicbus_write,		saa7146_i2c_write),
	DEVMETHOD(iicbus_read,		saa7146_i2c_read),
	DEVMETHOD(iicbus_reset,		saa7146_i2c_rst_card),
	{ 0, 0 }

static int
saa7146_i2c_probe(device_t dev)

static int
saa7146_i2c_attach(device_t dev)
	//... Allocation of some resources

	//add child

	if ((sc->i2c_dev = device_add_child(dev, "iicbus", -1)) == NULL)
                device_printf(dev, "could not allocate iicbus instance\n");


	device_printf(dev, "%s complite\n", __FUNCTION__);

	return (0);

static int
saa7146_i2c_start (device_t dev, u_char slave, int timeout)


DRIVER_MODULE  (saa7146_i2c, pci, saa7146_i2c_driver, saa7146_i2c_devclass, 0, 
MODULE_DEPEND  (saa7146_i2c, iicbus, SAA7146_I2C_MINVER, SAA7146_I2C_PREFVER, 
MODULE_VERSION (saa7146_i2c, SAA7146_I2C_MODVER);

But this now work. Сhild-device do not use any resource and is no active, and 
calling any method of this device lead to panic.

What do I do wrong?


More information about the freebsd-questions mailing list