.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright © 2015 Broadcom Corporation |
---|
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. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | 4 | */ |
---|
13 | 5 | |
---|
14 | 6 | #ifndef __BRCMNAND_H__ |
---|
.. | .. |
---|
19 | 11 | |
---|
20 | 12 | struct platform_device; |
---|
21 | 13 | struct dev_pm_ops; |
---|
| 14 | +struct brcmnand_io_ops; |
---|
| 15 | + |
---|
| 16 | +/* Special register offset constant to intercept a non-MMIO access |
---|
| 17 | + * to the flash cache register space. This is intentionally large |
---|
| 18 | + * not to overlap with an existing offset. |
---|
| 19 | + */ |
---|
| 20 | +#define BRCMNAND_NON_MMIO_FC_ADDR 0xffffffff |
---|
22 | 21 | |
---|
23 | 22 | struct brcmnand_soc { |
---|
24 | 23 | bool (*ctlrdy_ack)(struct brcmnand_soc *soc); |
---|
25 | 24 | void (*ctlrdy_set_enabled)(struct brcmnand_soc *soc, bool en); |
---|
26 | 25 | void (*prepare_data_bus)(struct brcmnand_soc *soc, bool prepare, |
---|
27 | 26 | bool is_param); |
---|
| 27 | + const struct brcmnand_io_ops *ops; |
---|
| 28 | +}; |
---|
| 29 | + |
---|
| 30 | +struct brcmnand_io_ops { |
---|
| 31 | + u32 (*read_reg)(struct brcmnand_soc *soc, u32 offset); |
---|
| 32 | + void (*write_reg)(struct brcmnand_soc *soc, u32 val, u32 offset); |
---|
28 | 33 | }; |
---|
29 | 34 | |
---|
30 | 35 | static inline void brcmnand_soc_data_bus_prepare(struct brcmnand_soc *soc, |
---|
.. | .. |
---|
66 | 71 | writel_relaxed(val, addr); |
---|
67 | 72 | } |
---|
68 | 73 | |
---|
| 74 | +static inline bool brcmnand_soc_has_ops(struct brcmnand_soc *soc) |
---|
| 75 | +{ |
---|
| 76 | + return soc && soc->ops && soc->ops->read_reg && soc->ops->write_reg; |
---|
| 77 | +} |
---|
| 78 | + |
---|
| 79 | +static inline u32 brcmnand_soc_read(struct brcmnand_soc *soc, u32 offset) |
---|
| 80 | +{ |
---|
| 81 | + return soc->ops->read_reg(soc, offset); |
---|
| 82 | +} |
---|
| 83 | + |
---|
| 84 | +static inline void brcmnand_soc_write(struct brcmnand_soc *soc, u32 val, |
---|
| 85 | + u32 offset) |
---|
| 86 | +{ |
---|
| 87 | + soc->ops->write_reg(soc, val, offset); |
---|
| 88 | +} |
---|
| 89 | + |
---|
69 | 90 | int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc); |
---|
70 | 91 | int brcmnand_remove(struct platform_device *pdev); |
---|
71 | 92 | |
---|