Changeset 24840


Ignore:
Timestamp:
2010-12-28T01:24:50+01:00 (7 years ago)
Author:
florian
Message:

[brcm63xx] spi driver: remove bcm_rset usage

Since bcm636x platform embeds two spi master device,
the attached patch removes static bcm_rset usage, replaced by
"bs->regs" field for all I/O operation.

Signed-off-by: Miguel Gaio <miguel.gaio@…>

File:
1 edited

Legend:

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

    r24304 r24840  
    319319--- /dev/null 
    320320+++ b/drivers/spi/bcm63xx_spi.c 
    321 @@ -0,0 +1,479 @@ 
     321@@ -0,0 +1,501 @@ 
    322322+/* 
    323323+ * Broadcom BCM63xx SPI controller support 
     
    358358+struct bcm63xx_spi { 
    359359+       spinlock_t              lock; 
    360 +       int                     stopping; 
     360+       int                     stopping; 
    361361+        struct completion      done; 
    362362+ 
    363 +        void __iomem           *regs; 
    364 +        int                    irq; 
     363+       void __iomem            *regs; 
     364+       int                     irq; 
    365365+ 
    366366+       /* Platform data */ 
     
    376376+       struct platform_device  *pdev; 
    377377+}; 
     378+ 
     379+static inline u8 bcm_spi_readb(struct bcm63xx_hsspi *bs, 
     380+                               unsigned int offset) 
     381+{ 
     382+        return bcm_readw(bs->regs + bcm63xx_spireg(offset)); 
     383+} 
     384+ 
     385+static inline u16 bcm_spi_readw(struct bcm63xx_hsspi *bs, 
     386+                               unsigned int offset) 
     387+{ 
     388+        return bcm_readw(bs->regs + bcm63xx_spireg(offset)); 
     389+} 
     390+ 
     391+static inline void bcm_spi_writeb(struct bcm63xx_hsspi *bs, 
     392+                                 u8 value, unsigned int offset) 
     393+{ 
     394+        bcm_writeb(value, bs->regs + bcm63xx_spireg(offset)); 
     395+} 
     396+ 
     397+static inline void bcm_spi_writew(struct bcm63xx_hsspi *bs, 
     398+                                 u16 value, unsigned int offset) 
     399+{ 
     400+        bcm_writew(value, bs->regs + bcm63xx_spireg(offset)); 
     401+} 
    378402+ 
    379403+static int bcm63xx_spi_setup_transfer(struct spi_device *spi, 
     
    429453+       } 
    430454+ 
    431 +       bcm_spi_writeb(clk_cfg, SPI_CLK_CFG); 
     455+       bcm_spi_writeb(bs, clk_cfg, SPI_CLK_CFG); 
    432456+       dev_dbg(&spi->dev, "Setting clock register to %d (hz %d, cmd %02x)\n", 
    433457+               div, hz, clk_cfg); 
     
    442466+{ 
    443467+       struct bcm63xx_spi *bs; 
    444 +       int retval; 
     468+       int ret; 
    445469+ 
    446470+       bs = spi_master_get_devdata(spi->master); 
     
    458482+       } 
    459483+ 
    460 +       retval = bcm63xx_spi_setup_transfer(spi, NULL); 
    461 +       if (retval < 0) { 
     484+       ret = bcm63xx_spi_setup_transfer(spi, NULL); 
     485+       if (ret < 0) { 
    462486+               dev_err(&spi->dev, "setup: unsupported mode bits %x\n", 
    463487+                       spi->mode & ~MODEBITS); 
    464 +               return retval; 
     488+               return ret; 
    465489+       } 
    466490+ 
     
    474498+static void bcm63xx_spi_fill_tx_fifo(struct bcm63xx_spi *bs) 
    475499+{ 
    476 +        u8 tail; 
     500+       u8 tail; 
    477501+ 
    478502+        /* Fill the Tx FIFO with as many bytes as possible */ 
    479 +       tail = bcm_spi_readb(SPI_MSG_TAIL); 
    480 + 
    481 +        while ((tail < bs->fifo_size) && (bs->remaining_bytes > 0)) { 
    482 +                if (bs->tx_ptr) 
    483 +                        bcm_spi_writeb(*bs->tx_ptr++, SPI_MSG_DATA); 
     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); 
    484508+               else 
    485 +                       bcm_spi_writeb(0, SPI_MSG_DATA); 
    486 + 
    487 +                bs->remaining_bytes--; 
    488 +               tail = bcm_spi_readb(SPI_MSG_TAIL); 
    489 +        } 
     509+                       bcm_spi_writeb(bs, 0, SPI_MSG_DATA); 
     510+ 
     511+               bs->remaining_bytes--; 
     512+               tail = bcm_spi_readb(bs, SPI_MSG_TAIL); 
     513+       } 
    490514+} 
    491515+ 
     
    511535+       /* Enable the command done interrupt which 
    512536+        * we use to determine completion of a command */ 
    513 +       bcm_spi_writeb(SPI_INTR_CMD_DONE, SPI_INT_MASK); 
     537+       bcm_spi_writeb(bs, SPI_INTR_CMD_DONE, SPI_INT_MASK); 
    514538+ 
    515539+       /* Fill in the Message control register */ 
     
    523547+               msg_ctl |= (SPI_HD_W << SPI_MSG_TYPE_SHIFT); 
    524548+ 
    525 +       bcm_spi_writew(msg_ctl, SPI_MSG_CTL); 
     549+       bcm_spi_writew(bs, msg_ctl, SPI_MSG_CTL); 
    526550+ 
    527551+       /* Issue the transfer */ 
    528552+       cmd = SPI_CMD_START_IMMEDIATE; 
    529553+       cmd |= (0 << SPI_CMD_PREPEND_BYTE_CNT_SHIFT); 
    530 +       bcm_spi_writew(cmd, SPI_CMD); 
     554+       bcm_spi_writew(bs, cmd, SPI_CMD); 
    531555+       wait_for_completion(&bs->done); 
    532556+ 
    533557+       /* Disable the CMD_DONE interrupt */ 
    534 +       bcm_spi_writeb(0, SPI_INT_MASK); 
     558+       bcm_spi_writeb(bs, 0, SPI_INT_MASK); 
    535559+ 
    536560+       return t->len - bs->remaining_bytes; 
    537561+} 
    538562+ 
    539 +static int bcm63xx_transfer(struct spi_device *spi, struct spi_message *msg) 
     563+static int bcm63xx_transfer(struct spi_device *spi, struct spi_message *m) 
    540564+{ 
    541565+       struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master); 
    542 +       struct spi_transfer *xfer; 
     566+       struct spi_transfer *t; 
    543567+       int ret = 0; 
    544568+ 
    545 +       if (unlikely(list_empty(&msg->transfers))) 
     569+       if (unlikely(list_empty(&m->transfers))) 
    546570+               return -EINVAL; 
    547571+ 
     
    549573+               return -ESHUTDOWN; 
    550574+ 
    551 +       list_for_each_entry(xfer, &msg->transfers, transfer_list) { 
    552 +               ret += bcm63xx_txrx_bufs(spi, xfer); 
    553 +       } 
    554 + 
    555 +       msg->complete(msg->context); 
     575+       list_for_each_entry(t, &m->transfers, transfer_list) { 
     576+               ret += bcm63xx_txrx_bufs(spi, t); 
     577+       } 
     578+ 
     579+       m->complete(m->context); 
    556580+ 
    557581+       return ret; 
     
    569593+ 
    570594+       /* Read interupts and clear them immediately */ 
    571 +       intr = bcm_spi_readb(SPI_INT_STATUS); 
    572 +       bcm_spi_writeb(SPI_INTR_CLEAR_ALL, SPI_INT_STATUS); 
    573 +       bcm_spi_writeb(0, SPI_INT_MASK); 
     595+       intr = bcm_spi_readb(bs, SPI_INT_STATUS); 
     596+       bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS); 
     597+       bcm_spi_writeb(bs, 0, SPI_INT_MASK); 
    574598+ 
    575599+       /* A tansfer completed */ 
     
    577601+               u8 rx_tail; 
    578602+ 
    579 +               rx_tail = bcm_spi_readb(SPI_RX_TAIL); 
     603+               rx_tail = bcm_spi_readb(bs, SPI_RX_TAIL); 
    580604+ 
    581605+               /* Read out all the data */ 
     
    585609+ 
    586610+                       for(i = 0; i < rx_tail; i++) { 
    587 +                               data = bcm_spi_readb(SPI_RX_DATA); 
     611+                               data = bcm_spi_readb(bs, SPI_RX_DATA); 
    588612+                               if (bs->rx_ptr) 
    589613+                                       *bs->rx_ptr++ = data; 
     
    596620+ 
    597621+                       /* Start the transfer */ 
    598 +                       bcm_spi_writew(SPI_HD_W << SPI_MSG_TYPE_SHIFT, 
     622+                       bcm_spi_writew(bs, SPI_HD_W << SPI_MSG_TYPE_SHIFT, 
    599623+                                      SPI_MSG_CTL); 
    600 +                       cmd = bcm_spi_readw(SPI_CMD); 
     624+                       cmd = bcm_spi_readw(bs, SPI_CMD); 
    601625+                       cmd |= SPI_CMD_START_IMMEDIATE; 
    602626+                       cmd |= (0 << SPI_CMD_PREPEND_BYTE_CNT_SHIFT); 
    603 +                       bcm_spi_writeb(SPI_INTR_CMD_DONE, SPI_INT_MASK); 
    604 +                       bcm_spi_writew(cmd, SPI_CMD); 
     627+                       bcm_spi_writeb(bs, SPI_INTR_CMD_DONE, SPI_INT_MASK); 
     628+                       bcm_spi_writew(bs, cmd, SPI_CMD); 
    605629+               } else { 
    606630+                       complete(&bs->done); 
     
    637661+       } 
    638662+ 
    639 +       clk = clk_get(&pdev->dev, "spi"); 
     663+       clk = clk_get(dev, "spi"); 
    640664+       if (IS_ERR(clk)) { 
    641665+               dev_err(dev, "no clock for device\n"); 
     
    644668+       } 
    645669+ 
    646 +       master = spi_alloc_master(&pdev->dev, sizeof(struct bcm63xx_spi)); 
     670+       master = spi_alloc_master(dev, sizeof(*bs)); 
    647671+       if (!master) { 
    648672+               dev_err(dev, "out of memory\n"); 
     
    655679+ 
    656680+       platform_set_drvdata(pdev, master); 
    657 +        bs->pdev = pdev; 
    658 + 
    659 +       if (!request_mem_region(r->start, 
    660 +                       r->end - r->start, PFX)) { 
     681+       bs->pdev = pdev; 
     682+ 
     683+       if (!request_mem_region(r->start, r->end - r->start, PFX)) { 
    661684+               dev_err(dev, "iomem request failed\n"); 
    662685+               ret = -ENXIO; 
     
    664687+       } 
    665688+ 
    666 +        bs->regs = ioremap_nocache(r->start, r->end - r->start); 
     689+       bs->regs = ioremap_nocache(r->start, r->end - r->start); 
    667690+       if (!bs->regs) { 
    668691+               dev_err(dev, "unable to ioremap regs\n"); 
     
    674697+       bs->fifo_size = pdata->fifo_size; 
    675698+ 
    676 +       ret = request_irq(irq, bcm63xx_spi_interrupt, 0, 
    677 +                         pdev->name, master); 
     699+       ret = request_irq(irq, bcm63xx_spi_interrupt, 0, pdev->name, master); 
    678700+       if (ret) { 
    679701+               dev_err(dev, "unable to request irq\n"); 
     
    691713+       /* Initialize hardware */ 
    692714+       clk_enable(bs->clk); 
    693 +       bcm_spi_writeb(SPI_INTR_CLEAR_ALL, SPI_INT_STATUS); 
     715+       bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS); 
    694716+ 
    695717+       /* register and we are done */ 
     
    703725+                r->start, irq, bs->fifo_size, DRV_VER); 
    704726+ 
    705 +       return ret; 
     727+       return 0; 
    706728+ 
    707729+out_reset_hw: 
     
    720742+static int __exit bcm63xx_spi_remove(struct platform_device *pdev) 
    721743+{ 
    722 +       struct spi_master  *master = platform_get_drvdata(pdev); 
    723 +       struct bcm63xx_spi *bs = spi_master_get_devdata(master); 
    724 +       struct resource    *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 
     744+       struct spi_master       *master = platform_get_drvdata(pdev); 
     745+       struct bcm63xx_spi      *bs = spi_master_get_devdata(master); 
     746+       struct resource         *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 
    725747+ 
    726748+       /* reset spi block */ 
    727 +       bcm_spi_writeb(0, SPI_INT_MASK); 
     749+       bcm_spi_writeb(bs, 0, SPI_INT_MASK); 
    728750+       spin_lock(&bs->lock); 
    729751+       bs->stopping = 1; 
     
    826848--- /dev/null 
    827849+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h 
    828 @@ -0,0 +1,136 @@ 
     850@@ -0,0 +1,126 @@ 
    829851+#ifndef BCM63XX_DEV_SPI_H 
    830852+#define BCM63XX_DEV_SPI_H 
     
    952974+} 
    953975+ 
    954 +/* 
    955 + * helpers for the SPI register sets 
    956 + */ 
    957 +#define bcm_spi_readb(o)    bcm_rset_readb(RSET_SPI, bcm63xx_spireg(o)) 
    958 +#define bcm_spi_readw(o)    bcm_rset_readw(RSET_SPI, bcm63xx_spireg(o)) 
    959 +#define bcm_spi_readl(o)    bcm_rset_readl(RSET_SPI, bcm63xx_spireg(o)) 
    960 +#define bcm_spi_writeb(v,o) bcm_rset_writeb(RSET_SPI, (v), bcm63xx_spireg(o)) 
    961 +#define bcm_spi_writew(v,o) bcm_rset_writew(RSET_SPI, (v), bcm63xx_spireg(o)) 
    962 +#define bcm_spi_writel(v,o) bcm_rset_writel(RSET_SPI, (v), bcm63xx_spireg(o)) 
    963 + 
    964976+#endif /* BCM63XX_DEV_SPI_H */ 
    965977--- a/arch/mips/bcm63xx/Makefile 
Note: See TracChangeset for help on using the changeset viewer.