mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
* **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.
78 lines
2.3 KiB
C++
78 lines
2.3 KiB
C++
#include "tactility/dts.h"
|
|
#include <tactility/kernel_init.h>
|
|
#include <tactility/log.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define TAG "kernel"
|
|
|
|
extern const struct ModuleSymbol KERNEL_SYMBOLS[];
|
|
|
|
static error_t start() {
|
|
extern Driver root_driver;
|
|
if (driver_construct_add(&root_driver) != ERROR_NONE) return ERROR_RESOURCE;
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
static error_t stop() {
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
struct Module root_module = {
|
|
.name = "kernel",
|
|
.start = start,
|
|
.stop = stop,
|
|
.symbols = (const struct ModuleSymbol*)KERNEL_SYMBOLS,
|
|
.internal = nullptr
|
|
};
|
|
|
|
error_t kernel_init(struct Module* platform_module, struct Module* device_module, struct DtsDevice dts_devices[]) {
|
|
LOG_I(TAG, "init");
|
|
|
|
if (module_construct_add_start(&root_module) != ERROR_NONE) {
|
|
LOG_E(TAG, "root module init failed");
|
|
return ERROR_RESOURCE;
|
|
}
|
|
|
|
if (module_construct_add_start(platform_module) != ERROR_NONE) {
|
|
LOG_E(TAG, "platform module init failed");
|
|
return ERROR_RESOURCE;
|
|
}
|
|
|
|
if (device_module != nullptr) {
|
|
if (module_construct_add_start(device_module) != ERROR_NONE) {
|
|
LOG_E(TAG, "device module init failed");
|
|
return ERROR_RESOURCE;
|
|
}
|
|
}
|
|
|
|
if (dts_devices) {
|
|
DtsDevice* dts_device = dts_devices;
|
|
while (dts_device->device != nullptr) {
|
|
if (dts_device->status == DTS_DEVICE_STATUS_OKAY) {
|
|
if (device_construct_add_start(dts_device->device, dts_device->compatible) != ERROR_NONE) {
|
|
LOG_E(TAG, "kernel_init failed to construct+add+start device: %s (%s)", dts_device->device->name, dts_device->compatible);
|
|
return ERROR_RESOURCE;
|
|
}
|
|
} else if (dts_device->status == DTS_DEVICE_STATUS_DISABLED) {
|
|
if (device_construct_add(dts_device->device, dts_device->compatible) != ERROR_NONE) {
|
|
LOG_E(TAG, "kernel_init failed to construct+add device: %s (%s)", dts_device->device->name, dts_device->compatible);
|
|
return ERROR_RESOURCE;
|
|
}
|
|
} else {
|
|
check(false, "DTS status not implemented");
|
|
}
|
|
dts_device++;
|
|
}
|
|
}
|
|
|
|
LOG_I(TAG, "init done");
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|