1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2015 Google, Inc
10 #include <dm/ofnode.h>
14 * struct syscon_uc_info - Information stored by the syscon UCLASS_UCLASS
16 * @regmap: Register map for this controller
18 struct syscon_uc_info {
19 struct regmap *regmap;
22 /* So far there are no ops so this is a placeholder */
26 #define syscon_get_ops(dev) ((struct syscon_ops *)(dev)->driver->ops)
29 * syscon_get_regmap() - Get access to a register map
31 * @dev: Device to check (UCLASS_SCON)
32 * @info: Returns regmap for the device
33 * Return: 0 if OK, -ve on error
35 struct regmap *syscon_get_regmap(struct udevice *dev);
38 * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
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.
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
49 int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp);
52 * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
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.
58 * @driver_data: Driver data value to look up
59 * Return: register map correponding to @driver_data, or -ve error code
61 struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data);
64 * syscon_regmap_lookup_by_phandle() - Look up a controller by a phandle
66 * This operates by looking up the given name in the device (device
67 * tree property) of the device using the system controller.
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
73 struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev,
77 * syscon_get_first_range() - get the first memory range from a syscon regmap
79 * @driver_data: Driver data value to look up
80 * Return: first region of register map correponding to @driver_data, or
83 void *syscon_get_first_range(ulong driver_data);
86 * syscon_node_to_regmap - get regmap from syscon
88 * @node: Device node of syscon
90 struct regmap *syscon_node_to_regmap(ofnode node);