157251285SSimon Glass /* 257251285SSimon Glass * Copyright (c) 2015 Google, Inc 357251285SSimon Glass * Written by Simon Glass <sjg@chromium.org> 457251285SSimon Glass * 557251285SSimon Glass * SPDX-License-Identifier: GPL-2.0+ 657251285SSimon Glass */ 757251285SSimon Glass 857251285SSimon Glass #ifndef __SYSCON_H 957251285SSimon Glass #define __SYSCON_H 1057251285SSimon Glass 1157251285SSimon Glass /** 1257251285SSimon Glass * struct syscon_uc_info - Information stored by the syscon UCLASS_UCLASS 1357251285SSimon Glass * 1457251285SSimon Glass * @regmap: Register map for this controller 1557251285SSimon Glass */ 1657251285SSimon Glass struct syscon_uc_info { 1757251285SSimon Glass struct regmap *regmap; 1857251285SSimon Glass }; 1957251285SSimon Glass 2057251285SSimon Glass /* So far there are no ops so this is a placeholder */ 2157251285SSimon Glass struct syscon_ops { 2257251285SSimon Glass }; 2357251285SSimon Glass 2457251285SSimon Glass #define syscon_get_ops(dev) ((struct syscon_ops *)(dev)->driver->ops) 2557251285SSimon Glass 2657251285SSimon Glass /** 2757251285SSimon Glass * syscon_get_regmap() - Get access to a register map 2857251285SSimon Glass * 2957251285SSimon Glass * @dev: Device to check (UCLASS_SCON) 3057251285SSimon Glass * @info: Returns regmap for the device 3157251285SSimon Glass * @return 0 if OK, -ve on error 3257251285SSimon Glass */ 3357251285SSimon Glass struct regmap *syscon_get_regmap(struct udevice *dev); 3457251285SSimon Glass 3557251285SSimon Glass /** 3657251285SSimon Glass * syscon_get_regmap_by_driver_data() - Look up a controller by its ID 3757251285SSimon Glass * 3857251285SSimon Glass * Each system controller can be accessed by its driver data, which is 3957251285SSimon Glass * assumed to be unique through the scope of all system controllers that 40*ac94b7bcSSimon Glass * are in use. This function looks up the controller given this driver data. 41*ac94b7bcSSimon Glass * 42*ac94b7bcSSimon Glass * @driver_data: Driver data value to look up 43*ac94b7bcSSimon Glass * @devp: Returns the controller correponding to @driver_data 44*ac94b7bcSSimon Glass * @return 0 on success, -ENODEV if the ID was not found, or other -ve error 45*ac94b7bcSSimon Glass * code 46*ac94b7bcSSimon Glass */ 47*ac94b7bcSSimon Glass int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp); 48*ac94b7bcSSimon Glass 49*ac94b7bcSSimon Glass /** 50*ac94b7bcSSimon Glass * syscon_get_regmap_by_driver_data() - Look up a controller by its ID 51*ac94b7bcSSimon Glass * 52*ac94b7bcSSimon Glass * Each system controller can be accessed by its driver data, which is 53*ac94b7bcSSimon Glass * assumed to be unique through the scope of all system controllers that 5457251285SSimon Glass * are in use. This function looks up the regmap given this driver data. 5557251285SSimon Glass * 5657251285SSimon Glass * @driver_data: Driver data value to look up 5757251285SSimon Glass * @return register map correponding to @driver_data, or -ve error code 5857251285SSimon Glass */ 5957251285SSimon Glass struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data); 6057251285SSimon Glass 6157251285SSimon Glass /** 6257251285SSimon Glass * syscon_get_first_range() - get the first memory range from a syscon regmap 6357251285SSimon Glass * 6457251285SSimon Glass * @driver_data: Driver data value to look up 6557251285SSimon Glass * @return first region of register map correponding to @driver_data, or 6657251285SSimon Glass * -ve error code 6757251285SSimon Glass */ 6857251285SSimon Glass void *syscon_get_first_range(ulong driver_data); 6957251285SSimon Glass 7057251285SSimon Glass #endif 71