xref: /linux/arch/sparc/kernel/of_device_common.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _OF_DEVICE_COMMON_H
3 #define _OF_DEVICE_COMMON_H
4 
of_read_addr(const u32 * cell,int size)5 static inline u64 of_read_addr(const u32 *cell, int size)
6 {
7 	u64 r = 0;
8 	while (size--)
9 		r = (r << 32) | *(cell++);
10 	return r;
11 }
12 
13 void of_bus_default_count_cells(struct device_node *dev, int *addrc,
14 				int *sizec);
15 int of_out_of_range(const u32 *addr, const u32 *base,
16 		    const u32 *size, int na, int ns);
17 int of_bus_default_map(u32 *addr, const u32 *range, int na, int ns, int pna);
18 unsigned long of_bus_default_get_flags(const u32 *addr, unsigned long flags);
19 
20 int of_bus_sbus_match(struct device_node *np);
21 void of_bus_sbus_count_cells(struct device_node *child, int *addrc, int *sizec);
22 
23 /* Max address size we deal with */
24 #define OF_MAX_ADDR_CELLS	4
25 
26 struct of_bus {
27 	const char	*name;
28 	const char	*addr_prop_name;
29 	int		(*match)(struct device_node *parent);
30 	void		(*count_cells)(struct device_node *child,
31 				       int *addrc, int *sizec);
32 	int		(*map)(u32 *addr, const u32 *range,
33 			       int na, int ns, int pna);
34 	unsigned long	(*get_flags)(const u32 *addr, unsigned long);
35 };
36 
37 #endif /* _OF_DEVICE_COMMON_H */
38