GPIO refactored (#495)

* **Refactor**
  * GPIO subsystem moved to a descriptor-based model for per-pin ownership and runtime pin management; many platform drivers now acquire/release descriptors.
  * Device trees and drivers now use GPIO phandle-style pin specifications across all boards and all drivers.

* **Behavior**
  * Device list now encodes per-device status (ok/disabled); boot will skip disabled devices accordingly.

* **Deprecation**
  * Legacy GPIO HAL marked deprecated and replaced with descriptor-based interfaces.

* **Chores**
  * Bindings and platform configs updated to the new GPIO pin-spec format.
This commit is contained in:
Ken Van Hoeylandt
2026-02-11 20:34:54 +01:00
committed by GitHub
parent dff93cb655
commit 26c17986c6
80 changed files with 1129 additions and 665 deletions
+5 -11
View File
@@ -7,22 +7,16 @@
extern "C" {
#endif
/** Logical GPIO pin identifier used by the HAL. Typically maps to the SoC GPIO number. */
/** @deprecated NON-FUNCTIONAL - WILL BE REMOVED SOON */
typedef unsigned int GpioPin;
/** Value indicating that no GPIO pin is used/applicable. */
/** @deprecated NON-FUNCTIONAL - WILL BE REMOVED SOON */
#define GPIO_NO_PIN -1
/** Read the current logic level of a pin.
* The pin should be configured for input or input/output.
* @param[in] pin The pin to read.
* @return true if the level is high, false if low. If the pin is invalid, the
* behavior is implementation-defined and may return false.
*/
/** @deprecated NON-FUNCTIONAL - WILL BE REMOVED SOON */
bool tt_hal_gpio_get_level(GpioPin pin);
/** Get the number of GPIO pins available on this platform.
* @return The count of valid GPIO pins.
*/
/** @deprecated NON-FUNCTIONAL - WILL BE REMOVED SOON */
int tt_hal_gpio_get_pin_count();
#ifdef __cplusplus
+2 -23
View File
@@ -7,33 +7,12 @@ extern "C" {
using namespace tt::hal;
static Device* find_first_gpio_controller() {
Device* device_result = nullptr;
device_for_each_of_type(&GPIO_CONTROLLER_TYPE, &device_result, [](Device* device, void* context) {
if (device_is_ready(device)) {
auto** device_result_ptr = static_cast<Device**>(context);
*device_result_ptr = device;
return false;
}
return true;
});
return device_result;
}
bool tt_hal_gpio_get_level(GpioPin pin) {
Device* device_result = find_first_gpio_controller();
if (device_result == nullptr) return false;
bool pin_state = false;
if (gpio_controller_get_level(device_result, pin, &pin_state) != ERROR_NONE) return false;
return pin_state;
return false;
}
int tt_hal_gpio_get_pin_count() {
Device* device_result = find_first_gpio_controller();
if (device_result == nullptr) return 0;
uint32_t pin_count = 0;
if (gpio_controller_get_pin_count(device_result, &pin_count) != ERROR_NONE) return 0;
return (int)pin_count;
return 0;
}
}
+7 -2
View File
@@ -53,6 +53,7 @@
#include <driver/i2s_common.h>
#include <driver/i2s_std.h>
#include <driver/gpio.h>
extern "C" {
@@ -374,7 +375,11 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(esp_netif_get_handle_from_ifkey),
// Locale
ESP_ELFSYM_EXPORT(localeconv),
//i2s_common.h
// driver/gpio.h
ESP_ELFSYM_EXPORT(gpio_config),
ESP_ELFSYM_EXPORT(gpio_get_level),
ESP_ELFSYM_EXPORT(gpio_set_level),
// driver/i2s_common.h
ESP_ELFSYM_EXPORT(i2s_new_channel),
ESP_ELFSYM_EXPORT(i2s_del_channel),
ESP_ELFSYM_EXPORT(i2s_channel_enable),
@@ -385,7 +390,7 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(i2s_channel_register_event_callback),
ESP_ELFSYM_EXPORT(i2s_channel_preload_data),
ESP_ELFSYM_EXPORT(i2s_channel_tune_rate),
//i2s_std.h
// driver/i2s_std.h
ESP_ELFSYM_EXPORT(i2s_channel_init_std_mode),
ESP_ELFSYM_EXPORT(i2s_channel_reconfig_std_clock),
ESP_ELFSYM_EXPORT(i2s_channel_reconfig_std_slot),