avionic design with actual uboot and tooling

submodule of avionic design uboot bootloader and with included tools to
get you started , read readme.md and readme-tk1-loader.md
This commit is contained in:
2026-03-03 21:46:32 +02:00
parent fe3ba02c96
commit 68d74d3181
11967 changed files with 2221897 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
menu "LED Support"
config LED
bool "Enable LED support"
depends on DM
help
Many boards have LEDs which can be used to signal status or alerts.
U-Boot provides a uclass API to implement this feature. LED drivers
can provide access to board-specific LEDs. Use of the device tree
for configuration is encouraged.
config SPL_LED
bool "Enable LED support in SPL"
depends on SPL && SPL_DM
help
The LED subsystem adds a small amount of overhead to the image.
If this is acceptable and you have a need to use LEDs in SPL,
enable this option. You will need to enable device tree in SPL
for this to work.
config LED_GPIO
bool "LED support for GPIO-connected LEDs"
depends on LED && DM_GPIO
help
Enable support for LEDs which are connected to GPIO lines. These
GPIOs may be on the SoC or some other device which provides GPIOs.
The GPIO driver must used driver model. LEDs are configured using
the device tree.
config SPL_LED_GPIO
bool "LED support for GPIO-connected LEDs in SPL"
depends on SPL_LED && DM_GPIO
help
This option is an SPL-variant of the LED_GPIO option.
See the help of LED_GPIO for details.
endmenu

View File

@@ -0,0 +1,9 @@
#
# Copyright (c) 2015 Google, Inc
# Written by Simon Glass <sjg@chromium.org>
#
# SPDX-License-Identifier: GPL-2.0+
#
obj-y += led-uclass.o
obj-$(CONFIG_$(SPL_)LED_GPIO) += led_gpio.o

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2015 Google, Inc
* Written by Simon Glass <sjg@chromium.org>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <dm.h>
#include <errno.h>
#include <led.h>
#include <dm/root.h>
#include <dm/uclass-internal.h>
int led_get_by_label(const char *label, struct udevice **devp)
{
struct udevice *dev;
struct uclass *uc;
int ret;
ret = uclass_get(UCLASS_LED, &uc);
if (ret)
return ret;
uclass_foreach_dev(dev, uc) {
struct led_uclass_plat *uc_plat = dev_get_uclass_platdata(dev);
/* Ignore the top-level LED node */
if (uc_plat->label && !strcmp(label, uc_plat->label))
return uclass_get_device_tail(dev, 0, devp);
}
return -ENODEV;
}
int led_set_on(struct udevice *dev, int on)
{
struct led_ops *ops = led_get_ops(dev);
if (!ops->set_on)
return -ENOSYS;
return ops->set_on(dev, on);
}
UCLASS_DRIVER(led) = {
.id = UCLASS_LED,
.name = "led",
.per_device_platdata_auto_alloc_size = sizeof(struct led_uclass_plat),
};

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 2015 Google, Inc
* Written by Simon Glass <sjg@chromium.org>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <dm.h>
#include <errno.h>
#include <led.h>
#include <asm/gpio.h>
#include <dm/lists.h>
DECLARE_GLOBAL_DATA_PTR;
struct led_gpio_priv {
struct gpio_desc gpio;
};
static int gpio_led_set_on(struct udevice *dev, int on)
{
struct led_gpio_priv *priv = dev_get_priv(dev);
if (!dm_gpio_is_valid(&priv->gpio))
return -EREMOTEIO;
return dm_gpio_set_value(&priv->gpio, on);
}
static int led_gpio_probe(struct udevice *dev)
{
struct led_uclass_plat *uc_plat = dev_get_uclass_platdata(dev);
struct led_gpio_priv *priv = dev_get_priv(dev);
/* Ignore the top-level LED node */
if (!uc_plat->label)
return 0;
return gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
}
static int led_gpio_remove(struct udevice *dev)
{
/*
* The GPIO driver may have already been removed. We will need to
* address this more generally.
*/
#ifndef CONFIG_SANDBOX
struct led_gpio_priv *priv = dev_get_priv(dev);
if (dm_gpio_is_valid(&priv->gpio))
dm_gpio_free(dev, &priv->gpio);
#endif
return 0;
}
static int led_gpio_bind(struct udevice *parent)
{
const void *blob = gd->fdt_blob;
struct udevice *dev;
int node;
int ret;
for (node = fdt_first_subnode(blob, parent->of_offset);
node > 0;
node = fdt_next_subnode(blob, node)) {
struct led_uclass_plat *uc_plat;
const char *label;
label = fdt_getprop(blob, node, "label", NULL);
if (!label) {
debug("%s: node %s has no label\n", __func__,
fdt_get_name(blob, node, NULL));
return -EINVAL;
}
ret = device_bind_driver_to_node(parent, "gpio_led",
fdt_get_name(blob, node, NULL),
node, &dev);
if (ret)
return ret;
uc_plat = dev_get_uclass_platdata(dev);
uc_plat->label = label;
}
return 0;
}
static const struct led_ops gpio_led_ops = {
.set_on = gpio_led_set_on,
};
static const struct udevice_id led_gpio_ids[] = {
{ .compatible = "gpio-leds" },
{ }
};
U_BOOT_DRIVER(led_gpio) = {
.name = "gpio_led",
.id = UCLASS_LED,
.of_match = led_gpio_ids,
.ops = &gpio_led_ops,
.priv_auto_alloc_size = sizeof(struct led_gpio_priv),
.bind = led_gpio_bind,
.probe = led_gpio_probe,
.remove = led_gpio_remove,
};