Changeset 24849


Ignore:
Timestamp:
2010-12-29T17:19:59+01:00 (5 years ago)
Author:
florian
Message:

[brcm63xx] multiple SPI driver fixes

  • fix platform device registration
  • fix chipselect, command register defines, add missing clock
  • make slave select proper
  • fix multibytes transferts

Signed-off-by: Tanguy Bouzéloc <tanguy.bouzeloc@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/brcm63xx/patches-2.6.35/240-spi.patch

    r24840 r24849  
    319319--- /dev/null 
    320320+++ b/drivers/spi/bcm63xx_spi.c 
    321 @@ -0,0 +1,501 @@ 
     321@@ -0,0 +1,494 @@ 
    322322+/* 
    323323+ * Broadcom BCM63xx SPI controller support 
     
    371371+       const unsigned char     *tx_ptr; 
    372372+       unsigned char           *rx_ptr; 
     373+ 
     374+       /* data iomem */ 
     375+       u8 __iomem              *tx_io; 
     376+       const u8 __iomem        *rx_io; 
     377+ 
    373378+       int                     remaining_bytes; 
    374379+ 
     
    377382+}; 
    378383+ 
    379 +static inline u8 bcm_spi_readb(struct bcm63xx_hsspi *bs, 
     384+static inline u8 bcm_spi_readb(struct bcm63xx_spi *bs, 
    380385+                               unsigned int offset) 
    381386+{ 
    382 +        return bcm_readw(bs->regs + bcm63xx_spireg(offset)); 
    383 +} 
    384 + 
    385 +static inline u16 bcm_spi_readw(struct bcm63xx_hsspi *bs, 
     387+       return bcm_readw(bs->regs + bcm63xx_spireg(offset)); 
     388+} 
     389+ 
     390+static inline u16 bcm_spi_readw(struct bcm63xx_spi *bs, 
    386391+                               unsigned int offset) 
    387392+{ 
    388 +        return bcm_readw(bs->regs + bcm63xx_spireg(offset)); 
    389 +} 
    390 + 
    391 +static inline void bcm_spi_writeb(struct bcm63xx_hsspi *bs, 
     393+       return bcm_readw(bs->regs + bcm63xx_spireg(offset)); 
     394+} 
     395+ 
     396+static inline void bcm_spi_writeb(struct bcm63xx_spi *bs, 
    392397+                                 u8 value, unsigned int offset) 
    393398+{ 
    394 +        bcm_writeb(value, bs->regs + bcm63xx_spireg(offset)); 
    395 +} 
    396 + 
    397 +static inline void bcm_spi_writew(struct bcm63xx_hsspi *bs, 
     399+       bcm_writeb(value, bs->regs + bcm63xx_spireg(offset)); 
     400+} 
     401+ 
     402+static inline void bcm_spi_writew(struct bcm63xx_spi *bs, 
    398403+                                 u16 value, unsigned int offset) 
    399404+{ 
    400 +        bcm_writew(value, bs->regs + bcm63xx_spireg(offset)); 
     405+       bcm_writew(value, bs->regs + bcm63xx_spireg(offset)); 
    401406+} 
    402407+ 
    403408+static int bcm63xx_spi_setup_transfer(struct spi_device *spi, 
    404 +                                       struct spi_transfer *t) 
     409+                                     struct spi_transfer *t) 
    405410+{ 
    406411+       u8 bits_per_word; 
     
    443448+               clk_cfg = SPI_CLK_1_563MHZ; 
    444449+               break; 
    445 +       case 128: 
     450+       case 64: 
    446451+               clk_cfg = SPI_CLK_0_781MHZ; 
    447452+               break; 
    448 +       case 64: 
     453+       case 128: 
    449454+       default: 
    450455+               /* Set to slowest mode for compatibility */ 
    451 +               clk_cfg = SPI_CLK_0_781MHZ; 
     456+               clk_cfg = SPI_CLK_0_391MHZ; 
    452457+               break; 
    453458+       } 
     
    498503+static void bcm63xx_spi_fill_tx_fifo(struct bcm63xx_spi *bs) 
    499504+{ 
    500 +       u8 tail; 
     505+       u8 size; 
    501506+ 
    502507+        /* Fill the Tx FIFO with as many bytes as possible */ 
    503 +       tail = bcm_spi_readb(bs, SPI_MSG_TAIL); 
    504 + 
    505 +       while ((tail < bs->fifo_size) && (bs->remaining_bytes > 0)) { 
    506 +               if (bs->tx_ptr) 
    507 +                       bcm_spi_writeb(bs, *bs->tx_ptr++, SPI_MSG_DATA); 
    508 +               else 
    509 +                       bcm_spi_writeb(bs, 0, SPI_MSG_DATA); 
    510 + 
    511 +               bs->remaining_bytes--; 
    512 +               tail = bcm_spi_readb(bs, SPI_MSG_TAIL); 
    513 +       } 
     508+       size = bs->remaining_bytes < bs->fifo_size ? bs->remaining_bytes : 
     509+               bs->fifo_size; 
     510+       memcpy_toio(bs->tx_io, bs->tx_ptr, size); 
     511+       bs->remaining_bytes -= size; 
    514512+} 
    515513+ 
     
    552550+       cmd = SPI_CMD_START_IMMEDIATE; 
    553551+       cmd |= (0 << SPI_CMD_PREPEND_BYTE_CNT_SHIFT); 
     552+       cmd |= (spi->chip_select << SPI_CMD_DEVICE_ID_SHIFT); 
    554553+       bcm_spi_writew(bs, cmd, SPI_CMD); 
    555554+       wait_for_completion(&bs->done); 
     
    604603+ 
    605604+               /* Read out all the data */ 
    606 +               if (rx_tail) { 
    607 +                       u8 data; 
    608 +                       u8 i = 0; 
    609 + 
    610 +                       for(i = 0; i < rx_tail; i++) { 
    611 +                               data = bcm_spi_readb(bs, SPI_RX_DATA); 
    612 +                               if (bs->rx_ptr) 
    613 +                                       *bs->rx_ptr++ = data; 
    614 +                       } 
    615 +               } 
     605+               if (rx_tail) 
     606+                       memcpy_fromio(bs->rx_ptr, bs->rx_io, rx_tail); 
    616607+ 
    617608+               /* See if there is more data to send */ 
     
    709700+       bs->speed_hz = pdata->speed_hz; 
    710701+       bs->stopping = 0; 
     702+       bs->tx_io = (u8*)(bs->regs + bcm63xx_spireg(SPI_MSG_DATA)); 
     703+       bs->rx_io = (const u8*)(bs->regs + bcm63xx_spireg(SPI_RX_DATA)); 
    711704+       spin_lock_init(&bs->lock); 
    712705+ 
     
    797790+       }, 
    798791+       .probe          = bcm63xx_spi_probe, 
    799 +       .remove         = bcm63xx_spi_remove, 
     792+       .remove         = __exit_p(bcm63xx_spi_remove), 
    800793+       .suspend        = bcm63xx_spi_suspend, 
    801794+       .resume         = bcm63xx_spi_resume, 
Note: See TracChangeset for help on using the changeset viewer.