blob: 3d66230c61b6b58d60a65b8fb48746e37c2a9480 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Robert Reifc9f5b7e2009-06-04 02:00:02 -07002#ifndef _OF_DEVICE_COMMON_H
3#define _OF_DEVICE_COMMON_H
4
5static 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
13void of_bus_default_count_cells(struct device_node *dev, int *addrc,
14 int *sizec);
15int of_out_of_range(const u32 *addr, const u32 *base,
16 const u32 *size, int na, int ns);
17int of_bus_default_map(u32 *addr, const u32 *range, int na, int ns, int pna);
18unsigned long of_bus_default_get_flags(const u32 *addr, unsigned long flags);
19
20int of_bus_sbus_match(struct device_node *np);
21void 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
26struct 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 */