Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
spi-imx.c File Reference
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/spi/spi.h>
#include <linux/spi/spi_bitbang.h>
#include <linux/types.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_data/spi-imx.h>

Go to the source code of this file.

Data Structures

struct  spi_imx_config
 
struct  spi_imx_devtype_data
 
struct  spi_imx_data
 

Macros

#define DRIVER_NAME   "spi_imx"
 
#define MXC_CSPIRXDATA   0x00
 
#define MXC_CSPITXDATA   0x04
 
#define MXC_CSPICTRL   0x08
 
#define MXC_CSPIINT   0x0c
 
#define MXC_RESET   0x1c
 
#define MXC_INT_RR   (1 << 0) /* Receive data ready interrupt */
 
#define MXC_INT_TE   (1 << 1) /* Transmit FIFO empty interrupt */
 
#define MXC_SPI_BUF_RX(type)
 
#define MXC_SPI_BUF_TX(type)
 
#define MX51_ECSPI_CTRL   0x08
 
#define MX51_ECSPI_CTRL_ENABLE   (1 << 0)
 
#define MX51_ECSPI_CTRL_XCH   (1 << 2)
 
#define MX51_ECSPI_CTRL_MODE_MASK   (0xf << 4)
 
#define MX51_ECSPI_CTRL_POSTDIV_OFFSET   8
 
#define MX51_ECSPI_CTRL_PREDIV_OFFSET   12
 
#define MX51_ECSPI_CTRL_CS(cs)   ((cs) << 18)
 
#define MX51_ECSPI_CTRL_BL_OFFSET   20
 
#define MX51_ECSPI_CONFIG   0x0c
 
#define MX51_ECSPI_CONFIG_SCLKPHA(cs)   (1 << ((cs) + 0))
 
#define MX51_ECSPI_CONFIG_SCLKPOL(cs)   (1 << ((cs) + 4))
 
#define MX51_ECSPI_CONFIG_SBBCTRL(cs)   (1 << ((cs) + 8))
 
#define MX51_ECSPI_CONFIG_SSBPOL(cs)   (1 << ((cs) + 12))
 
#define MX51_ECSPI_CONFIG_SCLKCTL(cs)   (1 << ((cs) + 20))
 
#define MX51_ECSPI_INT   0x10
 
#define MX51_ECSPI_INT_TEEN   (1 << 0)
 
#define MX51_ECSPI_INT_RREN   (1 << 3)
 
#define MX51_ECSPI_STAT   0x18
 
#define MX51_ECSPI_STAT_RR   (1 << 3)
 
#define MX31_INTREG_TEEN   (1 << 0)
 
#define MX31_INTREG_RREN   (1 << 3)
 
#define MX31_CSPICTRL_ENABLE   (1 << 0)
 
#define MX31_CSPICTRL_MASTER   (1 << 1)
 
#define MX31_CSPICTRL_XCH   (1 << 2)
 
#define MX31_CSPICTRL_POL   (1 << 4)
 
#define MX31_CSPICTRL_PHA   (1 << 5)
 
#define MX31_CSPICTRL_SSCTL   (1 << 6)
 
#define MX31_CSPICTRL_SSPOL   (1 << 7)
 
#define MX31_CSPICTRL_BC_SHIFT   8
 
#define MX35_CSPICTRL_BL_SHIFT   20
 
#define MX31_CSPICTRL_CS_SHIFT   24
 
#define MX35_CSPICTRL_CS_SHIFT   12
 
#define MX31_CSPICTRL_DR_SHIFT   16
 
#define MX31_CSPISTATUS   0x14
 
#define MX31_STATUS_RR   (1 << 3)
 
#define MX21_INTREG_RR   (1 << 4)
 
#define MX21_INTREG_TEEN   (1 << 9)
 
#define MX21_INTREG_RREN   (1 << 13)
 
#define MX21_CSPICTRL_POL   (1 << 5)
 
#define MX21_CSPICTRL_PHA   (1 << 6)
 
#define MX21_CSPICTRL_SSPOL   (1 << 8)
 
#define MX21_CSPICTRL_XCH   (1 << 9)
 
#define MX21_CSPICTRL_ENABLE   (1 << 10)
 
#define MX21_CSPICTRL_MASTER   (1 << 11)
 
#define MX21_CSPICTRL_DR_SHIFT   14
 
#define MX21_CSPICTRL_CS_SHIFT   19
 
#define MX1_INTREG_RR   (1 << 3)
 
#define MX1_INTREG_TEEN   (1 << 8)
 
#define MX1_INTREG_RREN   (1 << 11)
 
#define MX1_CSPICTRL_POL   (1 << 4)
 
#define MX1_CSPICTRL_PHA   (1 << 5)
 
#define MX1_CSPICTRL_XCH   (1 << 8)
 
#define MX1_CSPICTRL_ENABLE   (1 << 9)
 
#define MX1_CSPICTRL_MASTER   (1 << 10)
 
#define MX1_CSPICTRL_DR_SHIFT   13
 

Enumerations

enum  spi_imx_devtype {
  IMX1_CSPI, IMX21_CSPI, IMX27_CSPI, IMX31_CSPI,
  IMX35_CSPI, IMX51_ECSPI
}
 

Functions

 module_platform_driver (spi_imx_driver)
 
 MODULE_DESCRIPTION ("SPI Master Controller driver")
 
 MODULE_AUTHOR ("Sascha Hauer, Pengutronix")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define DRIVER_NAME   "spi_imx"

Definition at line 44 of file spi-imx.c.

#define MX1_CSPICTRL_DR_SHIFT   13

Definition at line 482 of file spi-imx.c.

#define MX1_CSPICTRL_ENABLE   (1 << 9)

Definition at line 480 of file spi-imx.c.

#define MX1_CSPICTRL_MASTER   (1 << 10)

Definition at line 481 of file spi-imx.c.

#define MX1_CSPICTRL_PHA   (1 << 5)

Definition at line 478 of file spi-imx.c.

#define MX1_CSPICTRL_POL   (1 << 4)

Definition at line 477 of file spi-imx.c.

#define MX1_CSPICTRL_XCH   (1 << 8)

Definition at line 479 of file spi-imx.c.

#define MX1_INTREG_RR   (1 << 3)

Definition at line 473 of file spi-imx.c.

#define MX1_INTREG_RREN   (1 << 11)

Definition at line 475 of file spi-imx.c.

#define MX1_INTREG_TEEN   (1 << 8)

Definition at line 474 of file spi-imx.c.

#define MX21_CSPICTRL_CS_SHIFT   19

Definition at line 415 of file spi-imx.c.

#define MX21_CSPICTRL_DR_SHIFT   14

Definition at line 414 of file spi-imx.c.

#define MX21_CSPICTRL_ENABLE   (1 << 10)

Definition at line 412 of file spi-imx.c.

#define MX21_CSPICTRL_MASTER   (1 << 11)

Definition at line 413 of file spi-imx.c.

#define MX21_CSPICTRL_PHA   (1 << 6)

Definition at line 409 of file spi-imx.c.

#define MX21_CSPICTRL_POL   (1 << 5)

Definition at line 408 of file spi-imx.c.

#define MX21_CSPICTRL_SSPOL   (1 << 8)

Definition at line 410 of file spi-imx.c.

#define MX21_CSPICTRL_XCH   (1 << 9)

Definition at line 411 of file spi-imx.c.

#define MX21_INTREG_RR   (1 << 4)

Definition at line 404 of file spi-imx.c.

#define MX21_INTREG_RREN   (1 << 13)

Definition at line 406 of file spi-imx.c.

#define MX21_INTREG_TEEN   (1 << 9)

Definition at line 405 of file spi-imx.c.

#define MX31_CSPICTRL_BC_SHIFT   8

Definition at line 326 of file spi-imx.c.

#define MX31_CSPICTRL_CS_SHIFT   24

Definition at line 328 of file spi-imx.c.

#define MX31_CSPICTRL_DR_SHIFT   16

Definition at line 330 of file spi-imx.c.

#define MX31_CSPICTRL_ENABLE   (1 << 0)

Definition at line 319 of file spi-imx.c.

#define MX31_CSPICTRL_MASTER   (1 << 1)

Definition at line 320 of file spi-imx.c.

#define MX31_CSPICTRL_PHA   (1 << 5)

Definition at line 323 of file spi-imx.c.

#define MX31_CSPICTRL_POL   (1 << 4)

Definition at line 322 of file spi-imx.c.

#define MX31_CSPICTRL_SSCTL   (1 << 6)

Definition at line 324 of file spi-imx.c.

#define MX31_CSPICTRL_SSPOL   (1 << 7)

Definition at line 325 of file spi-imx.c.

#define MX31_CSPICTRL_XCH   (1 << 2)

Definition at line 321 of file spi-imx.c.

#define MX31_CSPISTATUS   0x14

Definition at line 332 of file spi-imx.c.

#define MX31_INTREG_RREN   (1 << 3)

Definition at line 317 of file spi-imx.c.

#define MX31_INTREG_TEEN   (1 << 0)

Definition at line 316 of file spi-imx.c.

#define MX31_STATUS_RR   (1 << 3)

Definition at line 333 of file spi-imx.c.

#define MX35_CSPICTRL_BL_SHIFT   20

Definition at line 327 of file spi-imx.c.

#define MX35_CSPICTRL_CS_SHIFT   12

Definition at line 329 of file spi-imx.c.

#define MX51_ECSPI_CONFIG   0x0c

Definition at line 195 of file spi-imx.c.

#define MX51_ECSPI_CONFIG_SBBCTRL (   cs)    (1 << ((cs) + 8))

Definition at line 198 of file spi-imx.c.

#define MX51_ECSPI_CONFIG_SCLKCTL (   cs)    (1 << ((cs) + 20))

Definition at line 200 of file spi-imx.c.

#define MX51_ECSPI_CONFIG_SCLKPHA (   cs)    (1 << ((cs) + 0))

Definition at line 196 of file spi-imx.c.

#define MX51_ECSPI_CONFIG_SCLKPOL (   cs)    (1 << ((cs) + 4))

Definition at line 197 of file spi-imx.c.

#define MX51_ECSPI_CONFIG_SSBPOL (   cs)    (1 << ((cs) + 12))

Definition at line 199 of file spi-imx.c.

#define MX51_ECSPI_CTRL   0x08

Definition at line 186 of file spi-imx.c.

#define MX51_ECSPI_CTRL_BL_OFFSET   20

Definition at line 193 of file spi-imx.c.

#define MX51_ECSPI_CTRL_CS (   cs)    ((cs) << 18)

Definition at line 192 of file spi-imx.c.

#define MX51_ECSPI_CTRL_ENABLE   (1 << 0)

Definition at line 187 of file spi-imx.c.

#define MX51_ECSPI_CTRL_MODE_MASK   (0xf << 4)

Definition at line 189 of file spi-imx.c.

#define MX51_ECSPI_CTRL_POSTDIV_OFFSET   8

Definition at line 190 of file spi-imx.c.

#define MX51_ECSPI_CTRL_PREDIV_OFFSET   12

Definition at line 191 of file spi-imx.c.

#define MX51_ECSPI_CTRL_XCH   (1 << 2)

Definition at line 188 of file spi-imx.c.

#define MX51_ECSPI_INT   0x10

Definition at line 202 of file spi-imx.c.

#define MX51_ECSPI_INT_RREN   (1 << 3)

Definition at line 204 of file spi-imx.c.

#define MX51_ECSPI_INT_TEEN   (1 << 0)

Definition at line 203 of file spi-imx.c.

#define MX51_ECSPI_STAT   0x18

Definition at line 206 of file spi-imx.c.

#define MX51_ECSPI_STAT_RR   (1 << 3)

Definition at line 207 of file spi-imx.c.

#define MXC_CSPICTRL   0x08

Definition at line 48 of file spi-imx.c.

#define MXC_CSPIINT   0x0c

Definition at line 49 of file spi-imx.c.

#define MXC_CSPIRXDATA   0x00

Definition at line 46 of file spi-imx.c.

#define MXC_CSPITXDATA   0x04

Definition at line 47 of file spi-imx.c.

#define MXC_INT_RR   (1 << 0) /* Receive data ready interrupt */

Definition at line 53 of file spi-imx.c.

#define MXC_INT_TE   (1 << 1) /* Transmit FIFO empty interrupt */

Definition at line 54 of file spi-imx.c.

#define MXC_RESET   0x1c

Definition at line 50 of file spi-imx.c.

#define MXC_SPI_BUF_RX (   type)
Value:
static void spi_imx_buf_rx_##type(struct spi_imx_data *spi_imx) \
{ \
unsigned int val = readl(spi_imx->base + MXC_CSPIRXDATA); \
if (spi_imx->rx_buf) { \
*(type *)spi_imx->rx_buf = val; \
spi_imx->rx_buf += sizeof(type); \
} \
}

Definition at line 119 of file spi-imx.c.

#define MXC_SPI_BUF_TX (   type)
Value:
static void spi_imx_buf_tx_##type(struct spi_imx_data *spi_imx) \
{ \
type val = 0; \
if (spi_imx->tx_buf) { \
val = *(type *)spi_imx->tx_buf; \
spi_imx->tx_buf += sizeof(type); \
} \
\
spi_imx->count -= sizeof(type); \
writel(val, spi_imx->base + MXC_CSPITXDATA); \
}

Definition at line 130 of file spi-imx.c.

Enumeration Type Documentation

Enumerator:
IMX1_CSPI 
IMX21_CSPI 
IMX27_CSPI 
IMX31_CSPI 
IMX35_CSPI 
IMX51_ECSPI 

Definition at line 63 of file spi-imx.c.

Function Documentation

MODULE_AUTHOR ( "Sascha  Hauer,
Pengutronix"   
)
MODULE_DESCRIPTION ( "SPI Master Controller driver )
MODULE_LICENSE ( "GPL"  )
module_platform_driver ( spi_imx_driver  )