From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFkN4-0003Lz-U2 for qemu-devel@nongnu.org; Tue, 18 Feb 2014 08:06:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFkMy-0004Dv-Pg for qemu-devel@nongnu.org; Tue, 18 Feb 2014 08:05:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2875) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFkMy-0004Dp-Hz for qemu-devel@nongnu.org; Tue, 18 Feb 2014 08:05:52 -0500 Message-ID: <53035AAC.4030708@redhat.com> Date: Tue, 18 Feb 2014 14:05:48 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <52FE3D0E.8070904@redhat.com> <52FE44DB.8030408@suse.de> <52FE4820.8050009@redhat.com> <5301D40F.2010506@redhat.com> <5301DC83.6030307@redhat.com> <5301E6AA.7000809@redhat.com> <53020C67.5040603@redhat.com> <53021CF6.5010808@redhat.com> <530234B6.1020307@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Fwd: Trying to write a new device / virtio-i2c ? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex David Cc: qemu-devel Il 18/02/2014 13:48, Alex David ha scritto: > > 2014-02-17 17:11 GMT+01:00 Paolo Bonzini >: > > Il 17/02/2014 16:33, Alex David ha scritto: > > If you need more than one bus, you need a new device > exposing the > I2C bus, besides the new sensor devices. USB-I2C could be > one such > device. > > So let me see if I understood well. USB-I2C (host QEMU device) > seems a > good idea, I could normally do : qemu-system-i386 -device > usb-I2c,chardev=foo -device usb-i2c,chardev=bar -chardev > socket,path=/tmp/test0,server,__nowait,id=foo -chardev > socket,path=/tmp/test1,server,__nowait,id=bar. > > > Almost. For QOM: > > -device usb-i2c,id=usb-i2c-0 > -device i2c-my-sensor,address=0x48,__bus=usb-i2c-0.0 > > For chardev: > > -device usb-i2c,id=usb-i2c-0 > -chardev socket,path=/tmp/test0,server,__nowait,id=chr-foo-0 > -device > i2c-my-sensor,address=0x48,__bus=usb-i2c-0.0,chardev=chr-__foo-0 > > Repeat for the other buses, replacing -0 with -1 and -2. > > > I need a "USB-I2C guest kernel driver" that would register a bus > (i2c-1 > for chardev foo, i2c-2 for chardev bar etc...), I guess ? > > > It exists already, drivers/i2c/busses/i2c-tiny-usb.c. > > > I'm now trying to write this new USB-I2C device, I look through some of > the code (dev-serial, dev-...), I used dev-serial code and removed the > code that wanted to declare a chardev (I don't need one to create my > bus, right ?). > > Now I'm wondering, how will be i2c-tiny-usb launched and declare a new > /dev/i2c-N, with my device. I found : > > static struct usb_device_id i2c_tiny_usb_table [] = { > { USB_DEVICE(0x0403, 0xc631) }, /* FTDI */ > { USB_DEVICE(0x1c40, 0x0534) }, /* EZPrototypes */ > { } /* Terminating entry */ > }; > > So I figured my USB-I2C should register using these numbers ? > > static const USBDesc desc_i2c = { > .id = { > .idVendor = 0x0403, > .idProduct = 0xc631, > .bcdDevice = 0x0400, > .iManufacturer = STR_MANUFACTURER, > .iProduct = STR_PRODUCT_I2C, > .iSerialNumber = STR_SERIALNUMBER, > }, > .full = &desc_device, > .str = desc_strings, > }; > > However, this doesn't work, after a $ qemu-system-i386 > debian_wheezy_i386_standard.qcow2 -usb -device USB-I2C,id=usb-i2c-0, the > driver doesn't seem to be used (/sys/class/i2c-dev/i2c-0/name isn't for > it...), even if I modprobe i2c-tiny-usb... > The dmesg shows it doesn't go into the "probe" function. > > What did I miss ? I honestly don't know, you'll have to debug it. Paolo