blob: 3a1d60471361ed52f29e929eb1b2455200022de9 [file] [log] [blame]
Philippe Reynes5aa6cfb2019-03-15 15:14:36 +01001/* SPDX-License-Identifier: GPL-2.0+ */
2
3#ifndef __BRCMNAND_H__
4#define __BRCMNAND_H__
5
6#include <linux/types.h>
7#include <linux/io.h>
8
9struct brcmnand_soc {
10 bool (*ctlrdy_ack)(struct brcmnand_soc *soc);
11 void (*ctlrdy_set_enabled)(struct brcmnand_soc *soc, bool en);
12 void (*prepare_data_bus)(struct brcmnand_soc *soc, bool prepare,
13 bool is_param);
Linus Walleijd2ad1572024-09-16 11:58:47 +020014 void (*read_data_bus)(struct brcmnand_soc *soc, void __iomem *flash_cache,
15 u32 *buffer, int fc_words);
Philippe Reynes5aa6cfb2019-03-15 15:14:36 +010016 void *ctrl;
17};
18
19static inline void brcmnand_soc_data_bus_prepare(struct brcmnand_soc *soc,
20 bool is_param)
21{
22 if (soc && soc->prepare_data_bus)
23 soc->prepare_data_bus(soc, true, is_param);
24}
25
26static inline void brcmnand_soc_data_bus_unprepare(struct brcmnand_soc *soc,
27 bool is_param)
28{
29 if (soc && soc->prepare_data_bus)
30 soc->prepare_data_bus(soc, false, is_param);
31}
32
33static inline u32 brcmnand_readl(void __iomem *addr)
34{
35 /*
36 * MIPS endianness is configured by boot strap, which also reverses all
37 * bus endianness (i.e., big-endian CPU + big endian bus ==> native
38 * endian I/O).
39 *
40 * Other architectures (e.g., ARM) either do not support big endian, or
41 * else leave I/O in little endian mode.
42 */
43 if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_SYS_BIG_ENDIAN))
44 return __raw_readl(addr);
45 else
46 return readl_relaxed(addr);
47}
48
49static inline void brcmnand_writel(u32 val, void __iomem *addr)
50{
51 /* See brcmnand_readl() comments */
52 if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_SYS_BIG_ENDIAN))
53 __raw_writel(val, addr);
54 else
55 writel_relaxed(val, addr);
56}
57
58int brcmnand_probe(struct udevice *dev, struct brcmnand_soc *soc);
59int brcmnand_remove(struct udevice *dev);
60
61#ifndef __UBOOT__
62extern const struct dev_pm_ops brcmnand_pm_ops;
63#endif /* __UBOOT__ */
64
65#endif /* __BRCMNAND_H__ */