Kamal Dasu | fa236a7 | 2016-08-24 18:04:23 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Broadcom |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License, version 2, as |
| 6 | * published by the Free Software Foundation (the "GPL"). |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * General Public License version 2 (GPLv2) for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * version 2 (GPLv2) along with this source code. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __SPI_BCM_QSPI_H__ |
| 18 | #define __SPI_BCM_QSPI_H__ |
| 19 | |
| 20 | #include <linux/types.h> |
| 21 | #include <linux/io.h> |
| 22 | |
Kamal Dasu | 4e3b2d2 | 2016-08-24 18:04:25 -0400 | [diff] [blame^] | 23 | /* BSPI interrupt masks */ |
| 24 | #define INTR_BSPI_LR_OVERREAD_MASK BIT(4) |
| 25 | #define INTR_BSPI_LR_SESSION_DONE_MASK BIT(3) |
| 26 | #define INTR_BSPI_LR_IMPATIENT_MASK BIT(2) |
| 27 | #define INTR_BSPI_LR_SESSION_ABORTED_MASK BIT(1) |
| 28 | #define INTR_BSPI_LR_FULLNESS_REACHED_MASK BIT(0) |
| 29 | |
| 30 | #define BSPI_LR_INTERRUPTS_DATA \ |
| 31 | (INTR_BSPI_LR_SESSION_DONE_MASK | \ |
| 32 | INTR_BSPI_LR_FULLNESS_REACHED_MASK) |
| 33 | |
| 34 | #define BSPI_LR_INTERRUPTS_ERROR \ |
| 35 | (INTR_BSPI_LR_OVERREAD_MASK | \ |
| 36 | INTR_BSPI_LR_IMPATIENT_MASK | \ |
| 37 | INTR_BSPI_LR_SESSION_ABORTED_MASK) |
| 38 | |
| 39 | #define BSPI_LR_INTERRUPTS_ALL \ |
| 40 | (BSPI_LR_INTERRUPTS_ERROR | \ |
| 41 | BSPI_LR_INTERRUPTS_DATA) |
| 42 | |
Kamal Dasu | fa236a7 | 2016-08-24 18:04:23 -0400 | [diff] [blame] | 43 | /* MSPI Interrupt masks */ |
| 44 | #define INTR_MSPI_HALTED_MASK BIT(6) |
| 45 | #define INTR_MSPI_DONE_MASK BIT(5) |
| 46 | |
| 47 | #define MSPI_INTERRUPTS_ALL \ |
| 48 | (INTR_MSPI_DONE_MASK | \ |
| 49 | INTR_MSPI_HALTED_MASK) |
| 50 | |
| 51 | struct platform_device; |
| 52 | struct dev_pm_ops; |
| 53 | |
| 54 | struct bcm_qspi_soc_intc; |
| 55 | |
| 56 | /* Read controller register*/ |
| 57 | static inline u32 bcm_qspi_readl(bool be, void __iomem *addr) |
| 58 | { |
| 59 | if (be) |
| 60 | return ioread32be(addr); |
| 61 | else |
| 62 | return readl_relaxed(addr); |
| 63 | } |
| 64 | |
| 65 | /* Write controller register*/ |
| 66 | static inline void bcm_qspi_writel(bool be, |
| 67 | unsigned int data, void __iomem *addr) |
| 68 | { |
| 69 | if (be) |
| 70 | iowrite32be(data, addr); |
| 71 | else |
| 72 | writel_relaxed(data, addr); |
| 73 | } |
| 74 | |
| 75 | /* The common driver functions to be called by the SoC platform driver */ |
| 76 | int bcm_qspi_probe(struct platform_device *pdev, |
| 77 | struct bcm_qspi_soc_intc *soc_intc); |
| 78 | int bcm_qspi_remove(struct platform_device *pdev); |
| 79 | |
| 80 | /* pm_ops used by the SoC platform driver called on PM suspend/resume */ |
| 81 | extern const struct dev_pm_ops bcm_qspi_pm_ops; |
| 82 | |
| 83 | #endif /* __SPI_BCM_QSPI_H__ */ |