Changeset 9b7a1da in rtems
- Timestamp:
- 05/18/23 18:47:30 (7 months ago)
- Branches:
- master
- Children:
- bcef89f2
- Parents:
- 59f9ed2
- git-author:
- Alex White <alex.white@…> (05/18/23 18:47:30)
- git-committer:
- Joel Sherrill <joel@…> (05/19/23 17:32:18)
- Location:
- bsps/microblaze/microblaze_fpga
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
bsps/microblaze/microblaze_fpga/gpio/microblaze-gpio.c
r59f9ed2 r9b7a1da 37 37 38 38 #include <bsp/fatal.h> 39 #include <bsp/fdt.h> 39 40 #include <bsp/microblaze-gpio.h> 41 42 #include <libfdt.h> 40 43 41 44 #ifdef __cplusplus 42 45 extern "C" { 43 46 #endif /* __cplusplus */ 47 48 #ifdef BSP_MICROBLAZE_FPGA_USE_FDT 49 rtems_status_code microblaze_gpio_init_context_from_fdt( 50 Microblaze_GPIO_context *context, 51 int index 52 ) 53 { 54 if ( context == NULL ) { 55 return RTEMS_INVALID_ADDRESS; 56 } 57 58 const char* compatible = "xlnx,xps-gpio-1.00.a"; 59 const void *fdt = bsp_fdt_get(); 60 int node = fdt_node_offset_by_compatible( fdt, -1, compatible ); 61 if ( node < 0 ) { 62 return RTEMS_INVALID_NUMBER; 63 } 64 65 /* Get the desired GPIO node if index is greater than zero. */ 66 for(int i = 0; i < index; i++) { 67 node = fdt_node_offset_by_compatible( fdt, node, compatible ); 68 if ( node < 0 ) { 69 return RTEMS_INVALID_NUMBER; 70 } 71 } 72 73 const uint32_t *prop; 74 prop = fdt_getprop( fdt, node, "reg", NULL ); 75 if ( prop != NULL ) { 76 context->regs = (Microblaze_GPIO_registers *) fdt32_to_cpu( prop[0] ); 77 } else { 78 return RTEMS_INVALID_NUMBER; 79 } 80 81 prop = fdt_getprop( fdt, node, "xlnx,is-dual", NULL ); 82 if ( prop != NULL ) { 83 context->is_dual = fdt32_to_cpu( prop[0] ) != 0 ? true : false; 84 } else { 85 return RTEMS_INVALID_NUMBER; 86 } 87 88 prop = fdt_getprop( fdt, node, "xlnx,interrupt-present", NULL ); 89 if ( prop != NULL ) { 90 context->has_interrupts = fdt32_to_cpu( prop[0] ) != 0 ? true : false; 91 } else { 92 return RTEMS_INVALID_NUMBER; 93 } 94 95 if ( context->has_interrupts ) { 96 prop = fdt_getprop( fdt, node, "interrupts", NULL ); 97 if ( prop != NULL ) { 98 context->irq = fdt32_to_cpu( prop[0] ); 99 } else { 100 return RTEMS_INVALID_NUMBER; 101 } 102 } 103 104 return RTEMS_SUCCESSFUL; 105 } 106 #endif /* BSP_MICROBLAZE_FPGA_USE_FDT */ 44 107 45 108 void microblaze_gpio_set_data_direction( -
bsps/microblaze/microblaze_fpga/include/bsp/microblaze-gpio.h
r59f9ed2 r9b7a1da 130 130 } Microblaze_GPIO_context; 131 131 132 #ifdef BSP_MICROBLAZE_FPGA_USE_FDT 133 /** 134 * @brief Initialize GPIO context from FDT. 135 * 136 * @param[in] context the GPIO context to initialize 137 * @param[in] index the zero-based GPIO index in the FDT 138 * 139 * @retval RTEMS_SUCCESSFUL on success 140 * @retval RTEMS_INVALID_NUMBER if the index is invalid or the node is missing a 141 * required property 142 * @retval RTEMS_INVALID_ADDRESS if the context is NULL 143 */ 144 rtems_status_code microblaze_gpio_init_context_from_fdt( 145 Microblaze_GPIO_context *context, 146 int index 147 ); 148 #endif /* BSP_MICROBLAZE_FPGA_USE_FDT */ 149 132 150 /** 133 151 * @brief Set pin configuration for the specified GPIO channel.
Note: See TracChangeset
for help on using the changeset viewer.