diff options
| -rw-r--r-- | drivers/spi/spi-imx.c | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index f3edb5652fc6..0fbd378bd1db 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c | |||
| @@ -171,30 +171,30 @@ static unsigned int spi_imx_clkdiv_2(unsigned int fin, | |||
| 171 | return 7; | 171 | return 7; |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | #define SPI_IMX2_3_CTRL 0x08 | 174 | #define MX51_ECSPI_CTRL 0x08 |
| 175 | #define SPI_IMX2_3_CTRL_ENABLE (1 << 0) | 175 | #define MX51_ECSPI_CTRL_ENABLE (1 << 0) |
| 176 | #define SPI_IMX2_3_CTRL_XCH (1 << 2) | 176 | #define MX51_ECSPI_CTRL_XCH (1 << 2) |
| 177 | #define SPI_IMX2_3_CTRL_MODE_MASK (0xf << 4) | 177 | #define MX51_ECSPI_CTRL_MODE_MASK (0xf << 4) |
| 178 | #define SPI_IMX2_3_CTRL_POSTDIV_OFFSET 8 | 178 | #define MX51_ECSPI_CTRL_POSTDIV_OFFSET 8 |
| 179 | #define SPI_IMX2_3_CTRL_PREDIV_OFFSET 12 | 179 | #define MX51_ECSPI_CTRL_PREDIV_OFFSET 12 |
| 180 | #define SPI_IMX2_3_CTRL_CS(cs) ((cs) << 18) | 180 | #define MX51_ECSPI_CTRL_CS(cs) ((cs) << 18) |
| 181 | #define SPI_IMX2_3_CTRL_BL_OFFSET 20 | 181 | #define MX51_ECSPI_CTRL_BL_OFFSET 20 |
| 182 | 182 | ||
| 183 | #define SPI_IMX2_3_CONFIG 0x0c | 183 | #define MX51_ECSPI_CONFIG 0x0c |
| 184 | #define SPI_IMX2_3_CONFIG_SCLKPHA(cs) (1 << ((cs) + 0)) | 184 | #define MX51_ECSPI_CONFIG_SCLKPHA(cs) (1 << ((cs) + 0)) |
| 185 | #define SPI_IMX2_3_CONFIG_SCLKPOL(cs) (1 << ((cs) + 4)) | 185 | #define MX51_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs) + 4)) |
| 186 | #define SPI_IMX2_3_CONFIG_SBBCTRL(cs) (1 << ((cs) + 8)) | 186 | #define MX51_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs) + 8)) |
| 187 | #define SPI_IMX2_3_CONFIG_SSBPOL(cs) (1 << ((cs) + 12)) | 187 | #define MX51_ECSPI_CONFIG_SSBPOL(cs) (1 << ((cs) + 12)) |
| 188 | 188 | ||
| 189 | #define SPI_IMX2_3_INT 0x10 | 189 | #define MX51_ECSPI_INT 0x10 |
| 190 | #define SPI_IMX2_3_INT_TEEN (1 << 0) | 190 | #define MX51_ECSPI_INT_TEEN (1 << 0) |
| 191 | #define SPI_IMX2_3_INT_RREN (1 << 3) | 191 | #define MX51_ECSPI_INT_RREN (1 << 3) |
| 192 | 192 | ||
| 193 | #define SPI_IMX2_3_STAT 0x18 | 193 | #define MX51_ECSPI_STAT 0x18 |
| 194 | #define SPI_IMX2_3_STAT_RR (1 << 3) | 194 | #define MX51_ECSPI_STAT_RR (1 << 3) |
| 195 | 195 | ||
| 196 | /* MX51 eCSPI */ | 196 | /* MX51 eCSPI */ |
| 197 | static unsigned int spi_imx2_3_clkdiv(unsigned int fin, unsigned int fspi) | 197 | static unsigned int mx51_ecspi_clkdiv(unsigned int fin, unsigned int fspi) |
| 198 | { | 198 | { |
| 199 | /* | 199 | /* |
| 200 | * there are two 4-bit dividers, the pre-divider divides by | 200 | * there are two 4-bit dividers, the pre-divider divides by |
| @@ -222,36 +222,36 @@ static unsigned int spi_imx2_3_clkdiv(unsigned int fin, unsigned int fspi) | |||
| 222 | 222 | ||
| 223 | pr_debug("%s: fin: %u, fspi: %u, post: %u, pre: %u\n", | 223 | pr_debug("%s: fin: %u, fspi: %u, post: %u, pre: %u\n", |
| 224 | __func__, fin, fspi, post, pre); | 224 | __func__, fin, fspi, post, pre); |
| 225 | return (pre << SPI_IMX2_3_CTRL_PREDIV_OFFSET) | | 225 | return (pre << MX51_ECSPI_CTRL_PREDIV_OFFSET) | |
| 226 | (post << SPI_IMX2_3_CTRL_POSTDIV_OFFSET); | 226 | (post << MX51_ECSPI_CTRL_POSTDIV_OFFSET); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | static void __maybe_unused spi_imx2_3_intctrl(struct spi_imx_data *spi_imx, int enable) | 229 | static void __maybe_unused mx51_ecspi_intctrl(struct spi_imx_data *spi_imx, int enable) |
| 230 | { | 230 | { |
| 231 | unsigned val = 0; | 231 | unsigned val = 0; |
| 232 | 232 | ||
| 233 | if (enable & MXC_INT_TE) | 233 | if (enable & MXC_INT_TE) |
| 234 | val |= SPI_IMX2_3_INT_TEEN; | 234 | val |= MX51_ECSPI_INT_TEEN; |
| 235 | 235 | ||
| 236 | if (enable & MXC_INT_RR) | 236 | if (enable & MXC_INT_RR) |
| 237 | val |= SPI_IMX2_3_INT_RREN; | 237 | val |= MX51_ECSPI_INT_RREN; |
| 238 | 238 | ||
| 239 | writel(val, spi_imx->base + SPI_IMX2_3_INT); | 239 | writel(val, spi_imx->base + MX51_ECSPI_INT); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | static void __maybe_unused spi_imx2_3_trigger(struct spi_imx_data *spi_imx) | 242 | static void __maybe_unused mx51_ecspi_trigger(struct spi_imx_data *spi_imx) |
| 243 | { | 243 | { |
| 244 | u32 reg; | 244 | u32 reg; |
| 245 | 245 | ||
| 246 | reg = readl(spi_imx->base + SPI_IMX2_3_CTRL); | 246 | reg = readl(spi_imx->base + MX51_ECSPI_CTRL); |
| 247 | reg |= SPI_IMX2_3_CTRL_XCH; | 247 | reg |= MX51_ECSPI_CTRL_XCH; |
| 248 | writel(reg, spi_imx->base + SPI_IMX2_3_CTRL); | 248 | writel(reg, spi_imx->base + MX51_ECSPI_CTRL); |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | static int __maybe_unused spi_imx2_3_config(struct spi_imx_data *spi_imx, | 251 | static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, |
| 252 | struct spi_imx_config *config) | 252 | struct spi_imx_config *config) |
| 253 | { | 253 | { |
| 254 | u32 ctrl = SPI_IMX2_3_CTRL_ENABLE, cfg = 0; | 254 | u32 ctrl = MX51_ECSPI_CTRL_ENABLE, cfg = 0; |
| 255 | 255 | ||
| 256 | /* | 256 | /* |
| 257 | * The hardware seems to have a race condition when changing modes. The | 257 | * The hardware seems to have a race condition when changing modes. The |
| @@ -260,42 +260,42 @@ static int __maybe_unused spi_imx2_3_config(struct spi_imx_data *spi_imx, | |||
| 260 | * the same time. | 260 | * the same time. |
| 261 | * So set master mode for all channels as we do not support slave mode. | 261 | * So set master mode for all channels as we do not support slave mode. |
| 262 | */ | 262 | */ |
| 263 | ctrl |= SPI_IMX2_3_CTRL_MODE_MASK; | 263 | ctrl |= MX51_ECSPI_CTRL_MODE_MASK; |
| 264 | 264 | ||
| 265 | /* set clock speed */ | 265 | /* set clock speed */ |
| 266 | ctrl |= spi_imx2_3_clkdiv(spi_imx->spi_clk, config->speed_hz); | 266 | ctrl |= mx51_ecspi_clkdiv(spi_imx->spi_clk, config->speed_hz); |
| 267 | 267 | ||
| 268 | /* set chip select to use */ | 268 | /* set chip select to use */ |
| 269 | ctrl |= SPI_IMX2_3_CTRL_CS(config->cs); | 269 | ctrl |= MX51_ECSPI_CTRL_CS(config->cs); |
| 270 | 270 | ||
| 271 | ctrl |= (config->bpw - 1) << SPI_IMX2_3_CTRL_BL_OFFSET; | 271 | ctrl |= (config->bpw - 1) << MX51_ECSPI_CTRL_BL_OFFSET; |
| 272 | 272 | ||
| 273 | cfg |= SPI_IMX2_3_CONFIG_SBBCTRL(config->cs); | 273 | cfg |= MX51_ECSPI_CONFIG_SBBCTRL(config->cs); |
| 274 | 274 | ||
| 275 | if (config->mode & SPI_CPHA) | 275 | if (config->mode & SPI_CPHA) |
| 276 | cfg |= SPI_IMX2_3_CONFIG_SCLKPHA(config->cs); | 276 | cfg |= MX51_ECSPI_CONFIG_SCLKPHA(config->cs); |
| 277 | 277 | ||
| 278 | if (config->mode & SPI_CPOL) | 278 | if (config->mode & SPI_CPOL) |
| 279 | cfg |= SPI_IMX2_3_CONFIG_SCLKPOL(config->cs); | 279 | cfg |= MX51_ECSPI_CONFIG_SCLKPOL(config->cs); |
| 280 | 280 | ||
| 281 | if (config->mode & SPI_CS_HIGH) | 281 | if (config->mode & SPI_CS_HIGH) |
| 282 | cfg |= SPI_IMX2_3_CONFIG_SSBPOL(config->cs); | 282 | cfg |= MX51_ECSPI_CONFIG_SSBPOL(config->cs); |
| 283 | 283 | ||
| 284 | writel(ctrl, spi_imx->base + SPI_IMX2_3_CTRL); | 284 | writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); |
| 285 | writel(cfg, spi_imx->base + SPI_IMX2_3_CONFIG); | 285 | writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG); |
| 286 | 286 | ||
| 287 | return 0; | 287 | return 0; |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | static int __maybe_unused spi_imx2_3_rx_available(struct spi_imx_data *spi_imx) | 290 | static int __maybe_unused mx51_ecspi_rx_available(struct spi_imx_data *spi_imx) |
| 291 | { | 291 | { |
| 292 | return readl(spi_imx->base + SPI_IMX2_3_STAT) & SPI_IMX2_3_STAT_RR; | 292 | return readl(spi_imx->base + MX51_ECSPI_STAT) & MX51_ECSPI_STAT_RR; |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | static void __maybe_unused spi_imx2_3_reset(struct spi_imx_data *spi_imx) | 295 | static void __maybe_unused mx51_ecspi_reset(struct spi_imx_data *spi_imx) |
| 296 | { | 296 | { |
| 297 | /* drain receive buffer */ | 297 | /* drain receive buffer */ |
| 298 | while (spi_imx2_3_rx_available(spi_imx)) | 298 | while (mx51_ecspi_rx_available(spi_imx)) |
| 299 | readl(spi_imx->base + MXC_CSPIRXDATA); | 299 | readl(spi_imx->base + MXC_CSPIRXDATA); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| @@ -582,11 +582,11 @@ static struct spi_imx_devtype_data spi_imx_devtype_data[] = { | |||
| 582 | #endif | 582 | #endif |
| 583 | #ifdef CONFIG_SPI_IMX_VER_2_3 | 583 | #ifdef CONFIG_SPI_IMX_VER_2_3 |
| 584 | [SPI_IMX_VER_2_3] = { | 584 | [SPI_IMX_VER_2_3] = { |
| 585 | .intctrl = spi_imx2_3_intctrl, | 585 | .intctrl = mx51_ecspi_intctrl, |
| 586 | .config = spi_imx2_3_config, | 586 | .config = mx51_ecspi_config, |
| 587 | .trigger = spi_imx2_3_trigger, | 587 | .trigger = mx51_ecspi_trigger, |
| 588 | .rx_available = spi_imx2_3_rx_available, | 588 | .rx_available = mx51_ecspi_rx_available, |
| 589 | .reset = spi_imx2_3_reset, | 589 | .reset = mx51_ecspi_reset, |
| 590 | .fifosize = 64, | 590 | .fifosize = 64, |
| 591 | }, | 591 | }, |
| 592 | #endif | 592 | #endif |
