spi: pxa2xx: Remove unused define
Subsystems (3)
PATCH 1/5 spi: pxa2xx: Remove unused define
--- drivers/spi/spi-pxa2xx.c | 2 -- 1 file changed, 2 deletions(-)
drivers/spi/spi-pxa2xx.c +0 -2
@@ -45,8 +45,6 @@ MODULE_DESCRIPTION("PXA2xx SSP SPI Controller");MODULE_LICENSE ("GPL" );MODULE_ALIAS ("platform:pxa2xx-spi" ); -#define MAX_BUSES 3 -#define TIMOUT_DFLT 1000/*
Signature · 6 lines
2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1418907863-11116-1-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/[email protected]
PATCH 2/5 spi: pxa2xx: Move is_lpss_ssp() tests to caller
Move is_lpss_ssp() tests from functions to caller. Although this aims to improve readability it also saves a few code bytes on x86.
--- drivers/spi/spi-pxa2xx.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/spi/spi-pxa2xx.c +6 -9
@@ -251,9 +251,6 @@ static void lpss_ssp_setup(struct driver_data *drv_data)unsigned offset =0x400 ;u32 value, orig; -if (!is_lpss_ssp (drv_data)) -return ; -/* * Perform auto-detection of the LPSS SSP private registers. They * can be either at 1k or 2k offset from the base address.
@@ -302,9 +299,6 @@ static void lpss_ssp_cs_control(struct driver_data *drv_data, bool enable) {u32 value; -if (!is_lpss_ssp (drv_data)) -return ; - value =__lpss_ssp_read_priv (drv_data,SPI_CS_CONTROL );if (enable) value &= ~SPI_CS_CONTROL_CS_HIGH ;
@@ -332,7 +326,8 @@ static void cs_assert(struct driver_data *drv_data)return ; } -lpss_ssp_cs_control (drv_data, true); +if (is_lpss_ssp (drv_data)) +lpss_ssp_cs_control (drv_data, true); }static void cs_deassert (struct driver_data *drv_data)
@@ -352,7 +347,8 @@ static void cs_deassert(struct driver_data *drv_data)return ; } -lpss_ssp_cs_control (drv_data, false); +if (is_lpss_ssp (drv_data)) +lpss_ssp_cs_control (drv_data, false); }int pxa2xx_spi_flush (struct driver_data *drv_data)
@@ -1415,7 +1411,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)if (!is_quark_x1000_ssp (drv_data))write_SSPSP (0 , drv_data->ioaddr); -lpss_ssp_setup (drv_data); +if (is_lpss_ssp (drv_data)) +lpss_ssp_setup (drv_data);tasklet_init (&drv_data->pump_transfers, pump_transfers, (unsigned long )drv_data);
Signature · 6 lines
2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/5 spi: pxa2xx: Add definition for Intel Quark DDS_RATE register
In reply to a message not in the archiveIntel Quark DDS_RATE register is defined only in register access macro. Add a definition for it to common SSP register definitions for preparing to cleanup those macros.
--- include/linux/pxa2xx_ssp.h | 1 + 1 file changed, 1 insertion(+)
include/linux/pxa2xx_ssp.h +1 -0
@@ -37,6 +37,7 @@#define SSDR (0x10)/* SSP Data Write/Data Read Register */ #define SSTO (0x28)/* SSP Time Out Register */ +#define DDS_RATE (0x28)/* SSP DDS Clock Rate Register (Intel Quark) */ #define SSPSP (0x2C)/* SSP Programmable Serial Protocol */ #define SSTSA (0x30)/* SSP Tx Timeslot Active */ #define SSRSA (0x34)/* SSP Rx Timeslot Active */
Signature · 6 lines
2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/5 spi: pxa2xx: Pass driver data instead of ioaddr to wait_ssp_rx_stall()
In reply to a message not in the archivePass pointer to struct driver_data instead of ioaddr to wait_ssp_rx_stall() for preparing to register access macro cleanup.
--- drivers/spi/spi-pxa2xx-pxadma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-pxa2xx-pxadma.c +3 -3
@@ -118,11 +118,11 @@ static void pxa2xx_spi_unmap_dma_buffers(struct driver_data *drv_data) drv_data->dma_mapped =0 ; } -static int wait_ssp_rx_stall (void const __iomem *ioaddr) +static int wait_ssp_rx_stall (struct driver_data *drv_data) {unsigned long limit = loops_per_jiffy <<1 ; -while ((read_SSSR (ioaddr) &SSSR_BSY ) && --limit) +while ((read_SSSR (drv_data->ioaddr) &SSSR_BSY ) && --limit)cpu_relax ();return limit;
@@ -228,7 +228,7 @@ void pxa2xx_spi_dma_handler(int channel, void *data) && (drv_data->ssp_type == PXA25x_SSP)) {/* Wait for rx to stall */ -if (wait_ssp_rx_stall (drv_data->ioaddr) ==0 ) +if (wait_ssp_rx_stall (drv_data) ==0 )dev_err (&drv_data->pdev->dev,"dma_handler: ssp rx stall failed\n" );
Signature · 6 lines
2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/5 spi: pxa2xx: Cleanup register access macros
In reply to a message not in the archiveCurrently SSP registers are accessed by having an own read and write macros for each register. For instance read_SSSR(iobase) and write_SSSR(iobase).
In my opinion this hurts readability and requires new macros to be defined for each new added register. Let's define and use instead common pxa2xx_spi_read() and pxa2xx_spi_write() accessors.
--- drivers/spi/spi-pxa2xx-dma.c | 17 ++-- drivers/spi/spi-pxa2xx-pxadma.c | 25 +++--- drivers/spi/spi-pxa2xx.c | 183 ++++++++++++++++++---------------------- drivers/spi/spi-pxa2xx.h | 34 +++----- 4 files changed, 117 insertions(+), 142 deletions(-)
drivers/spi/spi-pxa2xx-dma.c +10 -7
@@ -111,23 +111,24 @@ static void pxa2xx_spi_dma_transfer_complete(struct driver_data *drv_data,* by using ->dma_running. */ if (atomic_dec_and_test (&drv_data->dma_running)) { -void __iomem *reg = drv_data->ioaddr; -/* * If the other CPU is still handling the ROR interrupt we * might not know about the error yet. So we re-check the * ROR bit here before we clear the status register. */ if (!error) { -u32 status =read_SSSR (reg) & drv_data->mask_sr; +u32 status =pxa2xx_spi_read (drv_data,SSSR ) + & drv_data->mask_sr; error = status &SSSR_ROR ; }/* Clear status & disable interrupts */ -write_SSCR1 (read_SSCR1 (reg) & ~drv_data->dma_cr1, reg); +pxa2xx_spi_write (drv_data,SSCR1 , +pxa2xx_spi_read (drv_data,SSCR1 ) + & ~drv_data->dma_cr1);write_SSSR_CS (drv_data, drv_data->clear_sr);if (!pxa25x_ssp_comp (drv_data)) -write_SSTO (0 , reg); +pxa2xx_spi_write (drv_data,SSTO ,0 );if (!error) {pxa2xx_spi_unmap_dma_buffers (drv_data);
@@ -139,7 +140,9 @@ static void pxa2xx_spi_dma_transfer_complete(struct driver_data *drv_data, msg->state =pxa2xx_spi_next_transfer (drv_data); }else {/* In case we got an error we disable the SSP now */ -write_SSCR0 (read_SSCR0 (reg) & ~SSCR0_SSE , reg); +pxa2xx_spi_write (drv_data,SSCR0 , +pxa2xx_spi_read (drv_data,SSCR0 ) + & ~SSCR0_SSE ); msg->state =ERROR_STATE ; }
@@ -247,7 +250,7 @@ irqreturn_t pxa2xx_spi_dma_transfer(struct driver_data *drv_data) {u32 status; - status =read_SSSR (drv_data->ioaddr) & drv_data->mask_sr; + status =pxa2xx_spi_read (drv_data,SSSR ) & drv_data->mask_sr;if (status &SSSR_ROR ) {dev_err (&drv_data->pdev->dev,"FIFO overrun\n" );
drivers/spi/spi-pxa2xx-pxadma.c +13 -12
@@ -122,7 +122,7 @@ static int wait_ssp_rx_stall(struct driver_data *drv_data) {unsigned long limit = loops_per_jiffy <<1 ; -while ((read_SSSR (drv_data->ioaddr) &SSSR_BSY ) && --limit) +while ((pxa2xx_spi_read (drv_data,SSSR ) &SSSR_BSY ) && --limit)cpu_relax ();return limit;
@@ -141,17 +141,18 @@ static int wait_dma_channel_stop(int channel)static void pxa2xx_spi_dma_error_stop (struct driver_data *drv_data,const char *msg) { -void __iomem *reg = drv_data->ioaddr; -/* Stop and reset */ DCSR (drv_data->rx_channel) =RESET_DMA_CHANNEL ;DCSR (drv_data->tx_channel) =RESET_DMA_CHANNEL ;write_SSSR_CS (drv_data, drv_data->clear_sr); -write_SSCR1 (read_SSCR1 (reg) & ~drv_data->dma_cr1, reg); +pxa2xx_spi_write (drv_data,SSCR1 , +pxa2xx_spi_read (drv_data,SSCR1 ) + & ~drv_data->dma_cr1);if (!pxa25x_ssp_comp (drv_data)) -write_SSTO (0 , reg); +pxa2xx_spi_write (drv_data,SSTO ,0 );pxa2xx_spi_flush (drv_data); -write_SSCR0 (read_SSCR0 (reg) & ~SSCR0_SSE , reg); +pxa2xx_spi_write (drv_data,SSCR0 , +pxa2xx_spi_read (drv_data,SSCR0 ) & ~SSCR0_SSE );pxa2xx_spi_unmap_dma_buffers (drv_data);
@@ -163,11 +164,12 @@ static void pxa2xx_spi_dma_error_stop(struct driver_data *drv_data,static void pxa2xx_spi_dma_transfer_complete (struct driver_data *drv_data) { -void __iomem *reg = drv_data->ioaddr;struct spi_message *msg = drv_data->cur_msg;/* Clear and disable interrupts on SSP and DMA channels*/ -write_SSCR1 (read_SSCR1 (reg) & ~drv_data->dma_cr1, reg); +pxa2xx_spi_write (drv_data,SSCR1 , +pxa2xx_spi_read (drv_data,SSCR1 ) + & ~drv_data->dma_cr1);write_SSSR_CS (drv_data, drv_data->clear_sr);DCSR (drv_data->tx_channel) =RESET_DMA_CHANNEL ;DCSR (drv_data->rx_channel) =RESET_DMA_CHANNEL ;
@@ -240,9 +242,8 @@ void pxa2xx_spi_dma_handler(int channel, void *data)irqreturn_t pxa2xx_spi_dma_transfer (struct driver_data *drv_data) {u32 irq_status; -void __iomem *reg = drv_data->ioaddr; - irq_status =read_SSSR (reg) & drv_data->mask_sr; + irq_status =pxa2xx_spi_read (drv_data,SSSR ) & drv_data->mask_sr;if (irq_status &SSSR_ROR ) {pxa2xx_spi_dma_error_stop (drv_data,"dma_transfer: fifo overrun" );
@@ -252,7 +253,7 @@ irqreturn_t pxa2xx_spi_dma_transfer(struct driver_data *drv_data)/* Check for false positive timeout */ if ((irq_status &SSSR_TINT ) && (DCSR (drv_data->tx_channel) &DCSR_RUN )) { -write_SSSR (SSSR_TINT , reg); +pxa2xx_spi_write (drv_data,SSSR ,SSSR_TINT );return IRQ_HANDLED ; }
@@ -261,7 +262,7 @@ irqreturn_t pxa2xx_spi_dma_transfer(struct driver_data *drv_data)/* Clear and disable timeout interrupt, do the rest in * dma_transfer_complete */ if (!pxa25x_ssp_comp (drv_data)) -write_SSTO (0 , reg); +pxa2xx_spi_write (drv_data,SSTO ,0 );/* finish this transfer, start the next */ pxa2xx_spi_dma_transfer_complete (drv_data);
drivers/spi/spi-pxa2xx.c +81 -102
431 lines not on this page · raw message
drivers/spi/spi-pxa2xx.h +13 -21
@@ -115,23 +115,17 @@ struct chip_data {void (*cs_control)(u32 command); }; -#define DEFINE_SSP_REG (reg, off) \ -static inline u32 read_##reg(void const __iomem *p) \ -{ return __raw_readl(p + (off)); } \ -\ -static inline void write_##reg(u32 v, void __iomem *p) \ -{ __raw_writel(v, p + (off)); } - -DEFINE_SSP_REG(SSCR0, 0x00) -DEFINE_SSP_REG(SSCR1, 0x04) -DEFINE_SSP_REG(SSSR, 0x08) -DEFINE_SSP_REG(SSITR, 0x0c) -DEFINE_SSP_REG(SSDR, 0x10) -DEFINE_SSP_REG(DDS_RATE, 0x28) /* DDS Clock Rate */ -DEFINE_SSP_REG(SSTO, 0x28) -DEFINE_SSP_REG(SSPSP, 0x2c) -DEFINE_SSP_REG(SSITF, SSITF) -DEFINE_SSP_REG(SSIRF, SSIRF) +static inline u32 pxa2xx_spi_read (const struct driver_data *drv_data, +unsigned reg) +{ +return __raw_readl (drv_data->ioaddr + reg); +} + +static inline void pxa2xx_spi_write (const struct driver_data *drv_data, +unsigned reg,u32 val) +{ +__raw_writel (val, drv_data->ioaddr + reg); +}#define START_STATE ((void *)0)#define RUNNING_STATE ((void *)1)
@@ -155,13 +149,11 @@ static inline int pxa25x_ssp_comp(struct driver_data *drv_data)static inline void write_SSSR_CS (struct driver_data *drv_data,u32 val) { -void __iomem *reg = drv_data->ioaddr; -if (drv_data->ssp_type ==CE4100_SSP || drv_data->ssp_type ==QUARK_X1000_SSP ) - val |=read_SSSR (reg) &SSSR_ALT_FRM_MASK ; + val |=pxa2xx_spi_read (drv_data,SSSR ) &SSSR_ALT_FRM_MASK ; -write_SSSR (val, reg); +pxa2xx_spi_write (drv_data,SSSR , val); }extern int pxa2xx_spi_flush (struct driver_data *drv_data);
Signature · 6 lines
2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Brown
AppliedQuoted 1 line · Jarkko Nikula
Applied all, thanks.