Add Broadcom / Netgear changes from RAXE 1.0.0.48
[project/bcm63xx/u-boot.git] / drivers / net / bcmbca / phy / dt_access.h
1 #ifndef __DT_ACCESS_H__
2 #define __DT_ACCESS_H__
3
4 #ifdef __UBOOT__
5 #include <dm/ofnode.h>
6 #include <dm/of_access.h>
7 #include <dm/device.h>
8 #include <dm/read.h>
9 #include <asm-generic/gpio.h>
10 #include <linux/errno.h>
11 typedef ofnode dt_handle_t;
12 typedef struct udevice dt_device_t;
13 typedef struct gpio_desc dt_gpio_desc;
14 #else
15 #include "linux/of.h"
16 #include <linux/gpio/consumer.h>
17 #include <linux/of_platform.h>
18 #include <linux/io.h>
19 #include <linux/module.h>
20 typedef struct device_node * dt_handle_t;
21 typedef struct platform_device dt_device_t;
22 extern struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
23 const char *propname, int index,
24 enum gpiod_flags dflags,
25 const char *label);
26 typedef struct gpio_desc *dt_gpio_desc;
27 #endif
28
29 #ifdef __UBOOT__
30 #define dt_for_each_child_of_node(parent, child) ofnode_for_each_subnode(child, parent)
31 #else
32 #define dt_for_each_child_of_node(parent, child) for_each_child_of_node(parent, child)
33 #endif
34
35 const bool dt_is_available(const dt_handle_t handle);
36 const bool dt_is_valid(const dt_handle_t handle);
37 const dt_handle_t dt_parent(const dt_handle_t handle);
38 const bool dt_is_equal(const dt_handle_t handle1, const dt_handle_t handle2);
39 const dt_handle_t dt_parse_phandle(const dt_handle_t handle, const char *phandle_name, int index);
40 const dt_handle_t dt_find_compatible_node(dt_handle_t handle, const char *compat);
41 const void *dt_get_property(const dt_handle_t handle, const char *propname, int *lenp);
42 const bool dt_property_read_bool(const dt_handle_t handle, const char *propname);
43 const char *dt_property_read_string(const dt_handle_t handle, const char *propname);
44 /* Note that if property is not found, return value will be -1 (0xffffffff) */
45 const uint32_t dt_property_read_u32(const dt_handle_t handle, const char *propname);
46 const uint32_t dt_property_read_u32_default(const dt_handle_t handle, const char *propname, uint32_t defval);
47 const char *dt_get_name(const dt_handle_t handle);
48 int dt_gpio_request_by_name_optional(const dt_handle_t handle, const char *propname, int index, const char *label, dt_gpio_desc *desc);
49 void dt_gpio_set_value(dt_gpio_desc desc, int value);
50 void dt_gpio_set_direction_output(dt_gpio_desc desc, int value);
51 int dt_gpio_exists(dt_gpio_desc desc);
52
53 dt_handle_t dt_dev_get_handle(dt_device_t *pdev);
54 void *dt_dev_read_addr(dt_device_t *pdev, int index);
55 void *dt_dev_remap(dt_device_t *pdev, int index);
56 void *dt_dev_remap_resource(dt_device_t *pdev, int index);
57
58 #endif
59