Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 6a84aaf | 2015-06-23 15:38:43 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
Simon Glass | 6a84aaf | 2015-06-23 15:38:43 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __SYSCON_H |
| 8 | #define __SYSCON_H |
| 9 | |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 10 | #include <fdtdec.h> |
| 11 | |
Simon Glass | 6a84aaf | 2015-06-23 15:38:43 -0600 | [diff] [blame] | 12 | /** |
| 13 | * struct syscon_uc_info - Information stored by the syscon UCLASS_UCLASS |
| 14 | * |
| 15 | * @regmap: Register map for this controller |
| 16 | */ |
| 17 | struct syscon_uc_info { |
| 18 | struct regmap *regmap; |
| 19 | }; |
| 20 | |
| 21 | /* So far there are no ops so this is a placeholder */ |
| 22 | struct syscon_ops { |
| 23 | }; |
| 24 | |
| 25 | #define syscon_get_ops(dev) ((struct syscon_ops *)(dev)->driver->ops) |
| 26 | |
Simon Glass | 73dd069 | 2016-07-04 11:58:00 -0600 | [diff] [blame] | 27 | #if CONFIG_IS_ENABLED(OF_PLATDATA) |
| 28 | /* |
| 29 | * We don't support 64-bit machines. If they are so resource-contrained that |
| 30 | * they need to use OF_PLATDATA, something is horribly wrong with the |
| 31 | * education of our hardware engineers. |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 32 | * |
| 33 | * Update: 64-bit is now supported and we have an education crisis. |
Simon Glass | 73dd069 | 2016-07-04 11:58:00 -0600 | [diff] [blame] | 34 | */ |
| 35 | struct syscon_base_platdata { |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 36 | fdt_val_t reg[2]; |
Simon Glass | 73dd069 | 2016-07-04 11:58:00 -0600 | [diff] [blame] | 37 | }; |
| 38 | #endif |
| 39 | |
Simon Glass | 6a84aaf | 2015-06-23 15:38:43 -0600 | [diff] [blame] | 40 | /** |
| 41 | * syscon_get_regmap() - Get access to a register map |
| 42 | * |
| 43 | * @dev: Device to check (UCLASS_SCON) |
| 44 | * @info: Returns regmap for the device |
| 45 | * @return 0 if OK, -ve on error |
| 46 | */ |
| 47 | struct regmap *syscon_get_regmap(struct udevice *dev); |
| 48 | |
| 49 | /** |
| 50 | * syscon_get_regmap_by_driver_data() - Look up a controller by its ID |
| 51 | * |
| 52 | * Each system controller can be accessed by its driver data, which is |
| 53 | * assumed to be unique through the scope of all system controllers that |
Simon Glass | 6d5579c | 2016-01-17 16:11:08 -0700 | [diff] [blame] | 54 | * are in use. This function looks up the controller given this driver data. |
| 55 | * |
| 56 | * @driver_data: Driver data value to look up |
| 57 | * @devp: Returns the controller correponding to @driver_data |
| 58 | * @return 0 on success, -ENODEV if the ID was not found, or other -ve error |
| 59 | * code |
| 60 | */ |
| 61 | int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp); |
| 62 | |
| 63 | /** |
| 64 | * syscon_get_regmap_by_driver_data() - Look up a controller by its ID |
| 65 | * |
| 66 | * Each system controller can be accessed by its driver data, which is |
| 67 | * assumed to be unique through the scope of all system controllers that |
Simon Glass | 6a84aaf | 2015-06-23 15:38:43 -0600 | [diff] [blame] | 68 | * are in use. This function looks up the regmap given this driver data. |
| 69 | * |
| 70 | * @driver_data: Driver data value to look up |
| 71 | * @return register map correponding to @driver_data, or -ve error code |
| 72 | */ |
| 73 | struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data); |
| 74 | |
| 75 | /** |
| 76 | * syscon_get_first_range() - get the first memory range from a syscon regmap |
| 77 | * |
| 78 | * @driver_data: Driver data value to look up |
| 79 | * @return first region of register map correponding to @driver_data, or |
| 80 | * -ve error code |
| 81 | */ |
| 82 | void *syscon_get_first_range(ulong driver_data); |
| 83 | |
| 84 | #endif |