]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/syscon.h
dfu: Fix up the Kconfig mess
[people/ms/u-boot.git] / include / syscon.h
CommitLineData
57251285
SG
1/*
2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#ifndef __SYSCON_H
9#define __SYSCON_H
10
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
04ecf36b
SG
28#if CONFIG_IS_ENABLED(OF_PLATDATA)
29/*
30 * We don't support 64-bit machines. If they are so resource-contrained that
31 * they need to use OF_PLATDATA, something is horribly wrong with the
32 * education of our hardware engineers.
c20ee0ed
SG
33 *
34 * Update: 64-bit is now supported and we have an education crisis.
04ecf36b
SG
35 */
36struct syscon_base_platdata {
c20ee0ed 37 fdt_val_t reg[2];
04ecf36b
SG
38};
39#endif
40
57251285
SG
41/**
42 * syscon_get_regmap() - Get access to a register map
43 *
44 * @dev: Device to check (UCLASS_SCON)
45 * @info: Returns regmap for the device
46 * @return 0 if OK, -ve on error
47 */
48struct regmap *syscon_get_regmap(struct udevice *dev);
49
ac94b7bc
SG
50/**
51 * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
52 *
53 * Each system controller can be accessed by its driver data, which is
54 * assumed to be unique through the scope of all system controllers that
55 * are in use. This function looks up the controller given this driver data.
56 *
57 * @driver_data: Driver data value to look up
58 * @devp: Returns the controller correponding to @driver_data
59 * @return 0 on success, -ENODEV if the ID was not found, or other -ve error
60 * code
61 */
62int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp);
63
57251285
SG
64/**
65 * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
66 *
67 * Each system controller can be accessed by its driver data, which is
68 * assumed to be unique through the scope of all system controllers that
69 * are in use. This function looks up the regmap given this driver data.
70 *
71 * @driver_data: Driver data value to look up
72 * @return register map correponding to @driver_data, or -ve error code
73 */
74struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data);
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 */
83void *syscon_get_first_range(ulong driver_data);
84
85#endif