blob: 34842aa4705891928df2f1346f22803f80116caa [file] [log] [blame]
Simon Glass6a84aaf2015-06-23 15:38:43 -06001/*
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
11/**
12 * struct syscon_uc_info - Information stored by the syscon UCLASS_UCLASS
13 *
14 * @regmap: Register map for this controller
15 */
16struct syscon_uc_info {
17 struct regmap *regmap;
18};
19
20/* So far there are no ops so this is a placeholder */
21struct syscon_ops {
22};
23
24#define syscon_get_ops(dev) ((struct syscon_ops *)(dev)->driver->ops)
25
Simon Glass73dd0692016-07-04 11:58:00 -060026#if CONFIG_IS_ENABLED(OF_PLATDATA)
27/*
28 * We don't support 64-bit machines. If they are so resource-contrained that
29 * they need to use OF_PLATDATA, something is horribly wrong with the
30 * education of our hardware engineers.
31 */
32struct syscon_base_platdata {
33 u32 reg[2];
34};
35#endif
36
Simon Glass6a84aaf2015-06-23 15:38:43 -060037/**
38 * syscon_get_regmap() - Get access to a register map
39 *
40 * @dev: Device to check (UCLASS_SCON)
41 * @info: Returns regmap for the device
42 * @return 0 if OK, -ve on error
43 */
44struct regmap *syscon_get_regmap(struct udevice *dev);
45
46/**
47 * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
48 *
49 * Each system controller can be accessed by its driver data, which is
50 * assumed to be unique through the scope of all system controllers that
Simon Glass6d5579c2016-01-17 16:11:08 -070051 * are in use. This function looks up the controller given this driver data.
52 *
53 * @driver_data: Driver data value to look up
54 * @devp: Returns the controller correponding to @driver_data
55 * @return 0 on success, -ENODEV if the ID was not found, or other -ve error
56 * code
57 */
58int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp);
59
60/**
61 * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
62 *
63 * Each system controller can be accessed by its driver data, which is
64 * assumed to be unique through the scope of all system controllers that
Simon Glass6a84aaf2015-06-23 15:38:43 -060065 * are in use. This function looks up the regmap given this driver data.
66 *
67 * @driver_data: Driver data value to look up
68 * @return register map correponding to @driver_data, or -ve error code
69 */
70struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data);
71
72/**
73 * syscon_get_first_range() - get the first memory range from a syscon regmap
74 *
75 * @driver_data: Driver data value to look up
76 * @return first region of register map correponding to @driver_data, or
77 * -ve error code
78 */
79void *syscon_get_first_range(ulong driver_data);
80
81#endif