| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2006 Ben Dooks |
|---|
| 3 | 4 | * Copyright 2006-2009 Simtec Electronics |
|---|
| 4 | 5 | * Ben Dooks <ben@simtec.co.uk> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/spinlock.h> |
|---|
| .. | .. |
|---|
| 23 | 19 | #include <linux/spi/spi.h> |
|---|
| 24 | 20 | #include <linux/spi/spi_bitbang.h> |
|---|
| 25 | 21 | #include <linux/spi/s3c24xx.h> |
|---|
| 22 | +#include <linux/spi/s3c24xx-fiq.h> |
|---|
| 26 | 23 | #include <linux/module.h> |
|---|
| 27 | | - |
|---|
| 28 | | -#include <plat/regs-spi.h> |
|---|
| 29 | 24 | |
|---|
| 30 | 25 | #include <asm/fiq.h> |
|---|
| 31 | 26 | |
|---|
| 32 | | -#include "spi-s3c24xx-fiq.h" |
|---|
| 27 | +#include "spi-s3c24xx-regs.h" |
|---|
| 33 | 28 | |
|---|
| 34 | 29 | /** |
|---|
| 35 | | - * s3c24xx_spi_devstate - per device data |
|---|
| 30 | + * struct s3c24xx_spi_devstate - per device data |
|---|
| 36 | 31 | * @hz: Last frequency calculated for @sppre field. |
|---|
| 37 | 32 | * @mode: Last mode setting for the @spcon field. |
|---|
| 38 | 33 | * @spcon: Value to write to the SPCON register. |
|---|
| .. | .. |
|---|
| 231 | 226 | struct spi_fiq_code { |
|---|
| 232 | 227 | u32 length; |
|---|
| 233 | 228 | u32 ack_offset; |
|---|
| 234 | | - u8 data[0]; |
|---|
| 229 | + u8 data[]; |
|---|
| 235 | 230 | }; |
|---|
| 236 | | - |
|---|
| 237 | | -extern struct spi_fiq_code s3c24xx_spi_fiq_txrx; |
|---|
| 238 | | -extern struct spi_fiq_code s3c24xx_spi_fiq_tx; |
|---|
| 239 | | -extern struct spi_fiq_code s3c24xx_spi_fiq_rx; |
|---|
| 240 | | - |
|---|
| 241 | | -/** |
|---|
| 242 | | - * ack_bit - turn IRQ into IRQ acknowledgement bit |
|---|
| 243 | | - * @irq: The interrupt number |
|---|
| 244 | | - * |
|---|
| 245 | | - * Returns the bit to write to the interrupt acknowledge register. |
|---|
| 246 | | - */ |
|---|
| 247 | | -static inline u32 ack_bit(unsigned int irq) |
|---|
| 248 | | -{ |
|---|
| 249 | | - return 1 << (irq - IRQ_EINT0); |
|---|
| 250 | | -} |
|---|
| 251 | 231 | |
|---|
| 252 | 232 | /** |
|---|
| 253 | 233 | * s3c24xx_spi_tryfiq - attempt to claim and setup FIQ for transfer |
|---|
| .. | .. |
|---|
| 265 | 245 | struct pt_regs regs; |
|---|
| 266 | 246 | enum spi_fiq_mode mode; |
|---|
| 267 | 247 | struct spi_fiq_code *code; |
|---|
| 248 | + u32 *ack_ptr = NULL; |
|---|
| 268 | 249 | int ret; |
|---|
| 269 | 250 | |
|---|
| 270 | 251 | if (!hw->fiq_claimed) { |
|---|
| .. | .. |
|---|
| 287 | 268 | regs.uregs[fiq_rrx] = (long)hw->rx; |
|---|
| 288 | 269 | regs.uregs[fiq_rtx] = (long)hw->tx + 1; |
|---|
| 289 | 270 | regs.uregs[fiq_rcount] = hw->len - 1; |
|---|
| 290 | | - regs.uregs[fiq_rirq] = (long)S3C24XX_VA_IRQ; |
|---|
| 291 | 271 | |
|---|
| 292 | 272 | set_fiq_regs(®s); |
|---|
| 293 | 273 | |
|---|
| 294 | 274 | if (hw->fiq_mode != mode) { |
|---|
| 295 | | - u32 *ack_ptr; |
|---|
| 296 | | - |
|---|
| 297 | 275 | hw->fiq_mode = mode; |
|---|
| 298 | 276 | |
|---|
| 299 | 277 | switch (mode) { |
|---|
| .. | .. |
|---|
| 313 | 291 | BUG_ON(!code); |
|---|
| 314 | 292 | |
|---|
| 315 | 293 | ack_ptr = (u32 *)&code->data[code->ack_offset]; |
|---|
| 316 | | - *ack_ptr = ack_bit(hw->irq); |
|---|
| 317 | | - |
|---|
| 318 | 294 | set_fiq_handler(&code->data, code->length); |
|---|
| 319 | 295 | } |
|---|
| 320 | 296 | |
|---|
| 321 | | - s3c24xx_set_fiq(hw->irq, true); |
|---|
| 297 | + s3c24xx_set_fiq(hw->irq, ack_ptr, true); |
|---|
| 322 | 298 | |
|---|
| 323 | 299 | hw->fiq_mode = mode; |
|---|
| 324 | 300 | hw->fiq_inuse = 1; |
|---|
| .. | .. |
|---|
| 491 | 467 | struct s3c2410_spi_info *pdata; |
|---|
| 492 | 468 | struct s3c24xx_spi *hw; |
|---|
| 493 | 469 | struct spi_master *master; |
|---|
| 494 | | - struct resource *res; |
|---|
| 495 | 470 | int err = 0; |
|---|
| 496 | 471 | |
|---|
| 497 | 472 | master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi)); |
|---|
| .. | .. |
|---|
| 540 | 515 | dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang); |
|---|
| 541 | 516 | |
|---|
| 542 | 517 | /* find and map our resources */ |
|---|
| 543 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 544 | | - hw->regs = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 518 | + hw->regs = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 545 | 519 | if (IS_ERR(hw->regs)) { |
|---|
| 546 | 520 | err = PTR_ERR(hw->regs); |
|---|
| 547 | 521 | goto err_no_pdata; |
|---|
| .. | .. |
|---|
| 549 | 523 | |
|---|
| 550 | 524 | hw->irq = platform_get_irq(pdev, 0); |
|---|
| 551 | 525 | if (hw->irq < 0) { |
|---|
| 552 | | - dev_err(&pdev->dev, "No IRQ specified\n"); |
|---|
| 553 | 526 | err = -ENOENT; |
|---|
| 554 | 527 | goto err_no_pdata; |
|---|
| 555 | 528 | } |
|---|