]> git.ipfire.org Git - thirdparty/u-boot.git/blob - include/syscon.h
configs: at91: sama7g54_curiosity: Add initial default configs
[thirdparty/u-boot.git] / include / syscon.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
5 */
6
7 #ifndef __SYSCON_H
8 #define __SYSCON_H
9
10 #include <dm/ofnode.h>
11 #include <fdtdec.h>
12
13 /**
14 * struct syscon_uc_info - Information stored by the syscon UCLASS_UCLASS
15 *
16 * @regmap: Register map for this controller
17 */
18 struct syscon_uc_info {
19 struct regmap *regmap;
20 };
21
22 /* So far there are no ops so this is a placeholder */
23 struct syscon_ops {
24 };
25
26 #define syscon_get_ops(dev) ((struct syscon_ops *)(dev)->driver->ops)
27
28 /**
29 * syscon_get_regmap() - Get access to a register map
30 *
31 * @dev: Device to check (UCLASS_SCON)
32 * @info: Returns regmap for the device
33 * Return: 0 if OK, -ve on error
34 */
35 struct regmap *syscon_get_regmap(struct udevice *dev);
36
37 /**
38 * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
39 *
40 * Each system controller can be accessed by its driver data, which is
41 * assumed to be unique through the scope of all system controllers that
42 * are in use. This function looks up the controller given this driver data.
43 *
44 * @driver_data: Driver data value to look up
45 * @devp: Returns the controller correponding to @driver_data
46 * Return: 0 on success, -ENODEV if the ID was not found, or other -ve error
47 * code
48 */
49 int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp);
50
51 /**
52 * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
53 *
54 * Each system controller can be accessed by its driver data, which is
55 * assumed to be unique through the scope of all system controllers that
56 * are in use. This function looks up the regmap given this driver data.
57 *
58 * @driver_data: Driver data value to look up
59 * Return: register map correponding to @driver_data, or -ve error code
60 */
61 struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data);
62
63 /**
64 * syscon_regmap_lookup_by_phandle() - Look up a controller by a phandle
65 *
66 * This operates by looking up the given name in the device (device
67 * tree property) of the device using the system controller.
68 *
69 * @dev: Device using the system controller
70 * @name: Name of property referring to the system controller
71 * Return: A pointer to the regmap if found, ERR_PTR(-ve) on error
72 */
73 struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev,
74 const char *name);
75
76 /**
77 * syscon_get_first_range() - get the first memory range from a syscon regmap
78 *
79 * @driver_data: Driver data value to look up
80 * Return: first region of register map correponding to @driver_data, or
81 * -ve error code
82 */
83 void *syscon_get_first_range(ulong driver_data);
84
85 /**
86 * syscon_node_to_regmap - get regmap from syscon
87 *
88 * @node: Device node of syscon
89 */
90 struct regmap *syscon_node_to_regmap(ofnode node);
91
92 #endif