mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-31 18:35:42 +01:00 
			
		
		
		
	fdt: Add function to get a config string from device tree
Add a function to look up a configuration string such as board name and returns its value. We look in the "/config" node for this. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		
				
					committed by
					
						 Gerald Van Baren
						Gerald Van Baren
					
				
			
			
				
	
			
			
			
						parent
						
							09258f1e8b
						
					
				
				
					commit
					332ab0d54a
				
			| @@ -367,6 +367,16 @@ int fdtdec_setup_gpio(struct fdt_gpio_state *gpio); | |||||||
| int fdtdec_get_config_int(const void *blob, const char *prop_name, | int fdtdec_get_config_int(const void *blob, const char *prop_name, | ||||||
| 		int default_val); | 		int default_val); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Look in the FDT for a config item with the given name and return its value | ||||||
|  |  * as a string. | ||||||
|  |  * | ||||||
|  |  * @param blob          FDT blob | ||||||
|  |  * @param prop_name     property name to look up | ||||||
|  |  * @returns property string, NULL on error. | ||||||
|  |  */ | ||||||
|  | char *fdtdec_get_config_string(const void *blob, const char *prop_name); | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Look up a property in a node and return its contents in a byte |  * Look up a property in a node and return its contents in a byte | ||||||
|  * array of given length. The property must have at least enough data for |  * array of given length. The property must have at least enough data for | ||||||
|   | |||||||
							
								
								
									
										28
									
								
								lib/fdtdec.c
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								lib/fdtdec.c
									
									
									
									
									
								
							| @@ -513,16 +513,6 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node, | |||||||
| 	return cell; | 	return cell; | ||||||
| } | } | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Look in the FDT for a config item with the given name and return its value |  | ||||||
|  * as a 32-bit integer. The property must have at least 4 bytes of data. The |  | ||||||
|  * value of the first cell is returned. |  | ||||||
|  * |  | ||||||
|  * @param blob		FDT blob to use |  | ||||||
|  * @param prop_name	Node property name |  | ||||||
|  * @param default_val	default value to return if the property is not found |  | ||||||
|  * @return integer value, if found, or default_val if not |  | ||||||
|  */ |  | ||||||
| int fdtdec_get_config_int(const void *blob, const char *prop_name, | int fdtdec_get_config_int(const void *blob, const char *prop_name, | ||||||
| 		int default_val) | 		int default_val) | ||||||
| { | { | ||||||
| @@ -534,3 +524,21 @@ int fdtdec_get_config_int(const void *blob, const char *prop_name, | |||||||
| 		return default_val; | 		return default_val; | ||||||
| 	return fdtdec_get_int(blob, config_node, prop_name, default_val); | 	return fdtdec_get_int(blob, config_node, prop_name, default_val); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | char *fdtdec_get_config_string(const void *blob, const char *prop_name) | ||||||
|  | { | ||||||
|  | 	const char *nodep; | ||||||
|  | 	int nodeoffset; | ||||||
|  | 	int len; | ||||||
|  |  | ||||||
|  | 	debug("%s: %s\n", __func__, prop_name); | ||||||
|  | 	nodeoffset = fdt_path_offset(blob, "/config"); | ||||||
|  | 	if (nodeoffset < 0) | ||||||
|  | 		return NULL; | ||||||
|  |  | ||||||
|  | 	nodep = fdt_getprop(blob, nodeoffset, prop_name, &len); | ||||||
|  | 	if (!nodep) | ||||||
|  | 		return NULL; | ||||||
|  |  | ||||||
|  | 	return (char *)nodep; | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user