vchristo
Posts: 7
Joined: Wed Aug 28, 2013 12:23 am

Hacking spi_bcm2708

Sun Oct 06, 2013 3:25 am

Hi friends,
Anyone know any place where, I can find the flowchart or the manual of the spi_bcm2708, I'm a beginner about linux module, but I'm interested to make some changes in it, but I don't know the exact place on the code I will made the changes, I just needed to put the driver to read several times the mcp3008, at now, the spi_2708 just write 3 bytes to mcp3008, and read 3, my intention are to put the driver to read several times (size of rx buffer) the adc chip, store it on my rx_buff, and return. I had tried apply the changes in bcm2708_rd_fifo(), no results, and in "bcm2708_spi_interrupt()", and it results "bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated".
I don't know if I need to make some changes in another places of the code,
please if someone have some knowhow about internal functionality of this drive please help me.
below is some changes I did.
tks..

Code: Select all

static irqreturn_t bcm2708_spi_interrupt(int irq, void *dev_id)
{
	struct spi_master *master = dev_id;
	struct bcm2708_spi *bs = spi_master_get_devdata(master);
	u32 cs;
	u16 x;

	spin_lock(&bs->lock);

	cs = bcm2708_rd(bs, SPI_CS);

	if (cs & SPI_CS_DONE) {
		if (bs->len) { /* first interrupt in a transfer */
			/* fill the TX fifo with up to 16 bytes */
			bcm2708_wr_fifo(bs, 16);
		} else if(LEN) { /* transfer incomplete LEN is sizeof rx_buf*/
				/* disable interrupts and cs and enable again  */
			cs &= ~(SPI_CS_INTR | SPI_CS_INTD);
			bcm2708_wr(bs, SPI_CS, cs);  /* I think this put cs LOW  ??? */
			while (cs & SPI_CS_RXD) {
				bcm2708_rd_fifo(bs, 1);
				cs = bcm2708_rd(bs, SPI_CS);
			}
			bs->len=3;
			LEN -=3;  
			printk(" Valor de LEN: %d\n",LEN);
			for(x=0;x<100;x++); /*to do call a function wait_for_new_sample()  */
			*bs->rx_buf +=3;
			cs &= ~(SPI_CS_INTR | SPI_CS_INTD); /* I think this put now the cs HIGH ?? */
			bcm2708_wr(bs, SPI_CS, cs);
	
			bcm2708_wr_fifo(bs, 16);
			}
			else {
				/* transfer complete */
				/* disable interrupts */
				cs &= ~(SPI_CS_INTR | SPI_CS_INTD);
				bcm2708_wr(bs, SPI_CS, cs);

				/* drain RX FIFO */
			while (cs & SPI_CS_RXD) {
				bcm2708_rd_fifo(bs, 1);
				cs = bcm2708_rd(bs, SPI_CS);
			}
			

			/* wake up our bh */
			complete(&bs->done);
		}
	} else if (cs & SPI_CS_RXR) {
		/* read 12 bytes of data */
		bcm2708_rd_fifo(bs, 12);

		/* write up to 12 bytes */
		bcm2708_wr_fifo(bs, 12);
	}

	spin_unlock(&bs->lock);

	return IRQ_HANDLED;
}
I have a new idea, if I find the correct place, i can create a new tread using all old arguments, previously passed to driver but changing only the rx_buff pointer *rx_buff +=3.
Any help ? please.

Return to “C/C++”