Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-06 Thread Peter Crosthwaite
On Thu, Apr 5, 2012 at 5:18 PM, Peter Maydell wrote: > > I'm not sure what you intend the tristate masks to be used for? > If the sending device puts the line into high-impedance presumably > the receiving device is just going to read something random which > it's supposed to ignore, so the sender

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-05 Thread Peter Maydell
On 5 April 2012 01:32, Peter Crosthwaite wrote: > 3: add support for flagging sdi/sdo bits as tristated: > > --- a/hw/ssi.h > +++ b/hw/ssi.h > @@ -28,7 +28,11 @@ typedef struct SSISlaveClass { >     DeviceClass parent_class; > >     int (*init)(SSISlave *dev); > -    uint32_t (*transfer)(SSISlave

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-04 Thread Peter Crosthwaite
>> >> It may be a case though that ssi is a superclass of spi - all SPI >> devices are SSI devices but not all SSI devices are SPI? To that end >> can we make SPI a child object of SSI with the desired extra behaviors >> mentioned in this thread? This kind of stuff is the whole reason for >> QOM. >

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-04 Thread Paul Brook
> Hi Paul, > > Regarding using ssi, theres a few things that come to mind: > > Theres no sense of it being a multi-slave bus, its just a point to > point link. SPI devices universally have the notion of the CS pin that > tristates the device of the bus. Masters connect to a number of slaves > and

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-03 Thread Peter Crosthwaite
Hi Paul, Regarding using ssi, theres a few things that come to mind: Theres no sense of it being a multi-slave bus, its just a point to point link. SPI devices universally have the notion of the CS pin that tristates the device of the bus. Masters connect to a number of slaves and one-hot-decode

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-03 Thread Paul Brook
> 2012/4/3 Paul Brook : > >> > I'm no SPI expert, but a bit of googling suggests that it's > >> > a synchronous duplex bus, so you always send a byte of data > >> > to the slave and get one back in return (even if for some slaves > >> > it might be random garbage). > > > > Waitaminute. So this is

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-03 Thread Peter Maydell
2012/4/3 Paul Brook : >> > I'm no SPI expert, but a bit of googling suggests that it's >> > a synchronous duplex bus, so you always send a byte of data >> > to the slave and get one back in return (even if for some slaves >> > it might be random garbage). > > Waitaminute. So this is just basic sync

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-03 Thread Paul Brook
> > I'm no SPI expert, but a bit of googling suggests that it's > > a synchronous duplex bus, so you always send a byte of data > > to the slave and get one back in return (even if for some slaves > > it might be random garbage). Waitaminute. So this is just basic synchronous serial? We already h

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-02 Thread Peter Crosthwaite
Hi Peter, So ive looked into this further, and I think I better see the confusion between us. My api attempt is attempting to abstract away the clock wheras the txrx approach is true'er to the physical interface. This sense of one-sided communication that im trying to model is comming from the fac

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-02 Thread Andreas Färber
Am 03.04.2012 01:57, schrieb Peter Crosthwaite: > On Tue, Apr 3, 2012 at 3:39 AM, Peter Maydell > wrote: >> On 30 March 2012 07:37, Peter A. G. Crosthwaite >> wrote: >>> +typedef struct spi_bus { >>> +BusState qbus; >>> +SPISlave **slaves; >>> +uint8_t num_slaves; >>> +uint8_t cu

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-02 Thread Peter Crosthwaite
On Tue, Apr 3, 2012 at 3:39 AM, Peter Maydell wrote: > On 30 March 2012 07:37, Peter A. G. Crosthwaite > wrote: >> defined spi bus and spi slave QOM interfaces. Inspired by and loosley based >> on > > "Define"; "loosely". > ack >> existing I2C framework. >> >> Signed-off-by: Peter A. G. Crosth

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-02 Thread Peter Crosthwaite
>> + >> +/* create a new spi bus */ >> +spi_bus *spi_init_bus(DeviceState *parent, int num_slaves, const char >> *name); >> +int spi_attach_slave(spi_bus *bus, SPISlave *s, int cs); >> + >> +/* change the chip select. Return 1 on failure. */ >> +int spi_set_cs(spi_bus *bus, int cs); >> +int spi_ge

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-04-02 Thread Peter Maydell
On 30 March 2012 07:37, Peter A. G. Crosthwaite wrote: > defined spi bus and spi slave QOM interfaces. Inspired by and loosley based on "Define"; "loosely". > existing I2C framework. > > Signed-off-by: Peter A. G. Crosthwaite > --- >  Makefile.target |    1 + >  hw/spi.c        |  175 > ++

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-03-30 Thread Peter Crosthwaite
Hi Peter, One major flaw in that interface (which is similar to another that we originally used) is it doesnt have an API for wiggling the CS lines. Some spi devices (e.g. the m25p80 in this series) have side effects from cs strobing whether or not a txrx occurs during cs assertion, which is not p

Re: [Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-03-30 Thread Peter Maydell
On 30 March 2012 07:37, Peter A. G. Crosthwaite wrote: > defined spi bus and spi slave QOM interfaces. Inspired by and loosley based on > existing I2C framework. There's also SPI support in qemu-linaro thanks to the folks at Nokia: http://git.linaro.org/gitweb?p=qemu/qemu-linaro.git;a=blob;f=hw/s

[Qemu-devel] [RFC PATCH v1 1/4] SPI: initial support

2012-03-30 Thread Peter A. G. Crosthwaite
defined spi bus and spi slave QOM interfaces. Inspired by and loosley based on existing I2C framework. Signed-off-by: Peter A. G. Crosthwaite --- Makefile.target |1 + hw/spi.c| 175 +++ hw/spi.h| 86 +