]> git.ipfire.org Git - thirdparty/u-boot.git/blame - include/syscon.h
Merge tag 'doc-2024-10-rc6' of https://source.denx.de/u-boot/custodians/u-boot-efi
[thirdparty/u-boot.git] / include / syscon.h
CommitLineData
83d290c5 1/* SPDX-License-Identifier: GPL-2.0+ */
57251285
SG
2/*
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
57251285
SG
5 */
6
7#ifndef __SYSCON_H
8#define __SYSCON_H
9
e151a1c2 10#include <dm/ofnode.h>
c20ee0ed
SG
11#include <fdtdec.h>
12
57251285
SG
13/**
14 * struct syscon_uc_info - Information stored by the syscon UCLASS_UCLASS
15 *
16 * @regmap: Register map for this controller
17 */
18struct syscon_uc_info {
19 struct regmap *regmap;
20};
21
22/* So far there are no ops so this is a placeholder */
23struct 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
185f812c 33 * Return: 0 if OK, -ve on error
57251285
SG
34 */
35struct regmap *syscon_get_regmap(struct udevice *dev);
36
ac94b7bc
SG
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
185f812c 46 * Return: 0 on success, -ENODEV if the ID was not found, or other -ve error
ac94b7bc
SG
47 * code
48 */
49int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp);
50
57251285
SG
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
185f812c 59 * Return: register map correponding to @driver_data, or -ve error code
57251285
SG
60 */
61struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data);
62
6c3af1f2
JJH
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
185f812c 71 * Return: A pointer to the regmap if found, ERR_PTR(-ve) on error
6c3af1f2
JJH
72 */
73struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev,
74 const char *name);
75
57251285
SG
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
185f812c 80 * Return: first region of register map correponding to @driver_data, or
57251285
SG
81 * -ve error code
82 */
83void *syscon_get_first_range(ulong driver_data);
84
e151a1c2
MY
85/**
86 * syscon_node_to_regmap - get regmap from syscon
87 *
88 * @node: Device node of syscon
89 */
90struct regmap *syscon_node_to_regmap(ofnode node);
91
57251285 92#endif