1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2016 Broadcom
6 #ifndef __SPI_BCM_QSPI_H__
7 #define __SPI_BCM_QSPI_H__
9 #include <linux/types.h>
12 /* BSPI interrupt masks */
13 #define INTR_BSPI_LR_OVERREAD_MASK BIT(4)
14 #define INTR_BSPI_LR_SESSION_DONE_MASK BIT(3)
15 #define INTR_BSPI_LR_IMPATIENT_MASK BIT(2)
16 #define INTR_BSPI_LR_SESSION_ABORTED_MASK BIT(1)
17 #define INTR_BSPI_LR_FULLNESS_REACHED_MASK BIT(0)
19 #define BSPI_LR_INTERRUPTS_DATA \
20 (INTR_BSPI_LR_SESSION_DONE_MASK | \
21 INTR_BSPI_LR_FULLNESS_REACHED_MASK)
23 #define BSPI_LR_INTERRUPTS_ERROR \
24 (INTR_BSPI_LR_OVERREAD_MASK | \
25 INTR_BSPI_LR_IMPATIENT_MASK | \
26 INTR_BSPI_LR_SESSION_ABORTED_MASK)
28 #define BSPI_LR_INTERRUPTS_ALL \
29 (BSPI_LR_INTERRUPTS_ERROR | \
30 BSPI_LR_INTERRUPTS_DATA)
32 /* MSPI Interrupt masks */
33 #define INTR_MSPI_HALTED_MASK BIT(6)
34 #define INTR_MSPI_DONE_MASK BIT(5)
36 #define MSPI_INTERRUPTS_ALL \
37 (INTR_MSPI_DONE_MASK | \
38 INTR_MSPI_HALTED_MASK)
40 #define QSPI_INTERRUPTS_ALL \
41 (MSPI_INTERRUPTS_ALL | \
42 BSPI_LR_INTERRUPTS_ALL)
44 struct platform_device;
54 struct bcm_qspi_soc_intc {
55 void (*bcm_qspi_int_ack)(struct bcm_qspi_soc_intc *soc_intc, int type);
56 void (*bcm_qspi_int_set)(struct bcm_qspi_soc_intc *soc_intc, int type,
58 u32 (*bcm_qspi_get_int_status)(struct bcm_qspi_soc_intc *soc_intc);
61 /* Read controller register*/
62 static inline u32 bcm_qspi_readl(bool be, void __iomem *addr)
65 return ioread32be(addr);
67 return readl_relaxed(addr);
70 /* Write controller register*/
71 static inline void bcm_qspi_writel(bool be,
72 unsigned int data, void __iomem *addr)
75 iowrite32be(data, addr);
77 writel_relaxed(data, addr);
80 static inline u32 get_qspi_mask(int type)
84 return INTR_MSPI_DONE_MASK;
86 return BSPI_LR_INTERRUPTS_ALL;
88 return QSPI_INTERRUPTS_ALL;
90 return BSPI_LR_INTERRUPTS_ERROR;
96 /* The common driver functions to be called by the SoC platform driver */
97 int bcm_qspi_probe(struct platform_device *pdev,
98 struct bcm_qspi_soc_intc *soc_intc);
99 int bcm_qspi_remove(struct platform_device *pdev);
101 /* pm_ops used by the SoC platform driver called on PM suspend/resume */
102 extern const struct dev_pm_ops bcm_qspi_pm_ops;
104 #endif /* __SPI_BCM_QSPI_H__ */