regulator
[TOC] regulator-uclass.c类信息12345678UCLASS_DRIVER(regulator) = { .id = UCLASS_REGULATOR, .name = "regulator", .post_bind = regulator_post_bind, .pre_probe = regulator_pre_probe, .post_probe = regulator_post_probe, .per_device_plat_auto = sizeof(struct dm_regulator_uclass_plat),}; regulator_post_bind 读取设备属性用于设置设备属性,并检查设备是否是DM设备中唯一的12345678910111213141516171819202122232425262728293031323334static int regulator_post_bind(struct udevice *dev){ struct dm_regulator_uclass...
reset
[TOC] reset-uclass.creset_get_by_index123456789101112int reset_get_by_index(struct udevice *dev, int index, struct reset_ctl *reset_ctl){ struct ofnode_phandle_args args; int ret; //寻找当前节点的`resets`的phandle索引,内容为`#reset-cells`的设备节点 ret = dev_read_phandle_with_args(dev, "resets", "#reset-cells", 0, index, &args); return reset_get_by_index_tail(ret, dev_ofnode(dev), &args, "resets", index > 0, reset_ctl);} reset_get_by...
serial
[TOC] serial-uclass.cserial_init 初始化串口 注意DM已初始化完成 serial_init 在relocation前调用 serial_initialize 在relocation后调用 1234567891011121314/* Called after relocation */int serial_initialize(void){ /* Scanning uclass to probe devices */ if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL)) { int ret; //探测所有的串口设备 ret = uclass_probe_all(UCLASS_SERIAL); if (ret) return ret; } return serial_init();} 123456789101112131415161718192021222324252627282930/* Called prior to relocation */i...
simple-bus
[TOC] simple-bus驱动信息 在重定向之前调用123456789101112131415161718192021UCLASS_DRIVER(simple_bus) = { .id = UCLASS_SIMPLE_BUS, .name = "simple_bus", .post_bind = simple_bus_post_bind, .per_device_plat_auto = sizeof(struct simple_bus_plat),};#if CONFIG_IS_ENABLED(OF_REAL)static const struct udevice_id generic_simple_bus_ids[] = { { .compatible = "simple-bus" }, { .compatible = "simple-mfd" }, { }};#endifU_BOOT_DRIVER(simpl...
spi
[TOC] spi-uclass.c.post_bind dm_scan_fdt_devspi_child_post_bind 子节点绑定到总线123456789static int spi_child_post_bind(struct udevice *dev){ struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); if (!dev_has_ofnode(dev)) return 0; return spi_slave_of_to_plat(dev, plat);} spi_slave_of_to_plat 获取spi设备的属性1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374int spi_slave_of_to_plat(struct udevice *dev,...
syscon
[TOC] syscon - System Controller 系统控制器 Kconfig 1234567891011121314 config REGMAPbool "Support register maps"depends on DM/*help 硬件外设往往有一组或多组 registers可以访问它来控制硬件。A 寄存器映射使用简单的读/写接口对此进行建模。 原则上可以支持任何总线类型(I2C、SPI)、但到目前为止这仅支持直接内存访问。 */ config SYSCONbool "Support system controllers"depends on REGMAP/*help 许多 SoC 有许多系统控制器需要处理.作为一个组。提供了一些常见的功能. 通过这个 uclass,包括通过 regmap 和 每个 Cookie 分配一个唯一的编号。 */ DTS1234567891011121314soc { #address-cells = <0x01>; ...
timer
[TOC] timer-uclass.cdm_timer_init 注意到这个函数在多个地方都可以被调; DM扫描识别之后 get_tick和get_tbclk时没有gd->timer的时候 但是只有在gd->timer为空的时候才会执行 12345678910111213141516171819202122232425262728293031323334353637383940int dm_timer_init(void){ struct udevice *dev = NULL; __maybe_unused ofnode node; int ret; if (gd->timer) return 0; if (gd->dm_root == NULL) return -EAGAIN; if (CONFIG_IS_ENABLED(OF_REAL)) { node = ofnode_get_chosen_node("tick-timer"); //优先使用tick-timer节点 if (ofnode_va...
env
envU_BOOT_ENV_LOCATION 通过该宏定义环境变量的位置 1234567891011121314151617181920/* * Define a callback that can be associated with variables. * when associated through the ".callbacks" environment variable, the callback * will be executed any time the variable is inserted, overwritten, or deleted. * * For SPL these are silently dropped to reduce code size, since environment * callbacks are not supported with SPL. */#ifdef CONFIG_XPL_BUILD#define U_BOOT_ENV_CALLBACK(name, callback) \ static ...
fdt
fdtdec 扁平设备树解析 devicetree devicetree-specification devicetree-specification.pdf 设备树BLLOB结构 123456789101112131415161718struct fdt_header { fdt32_t magic; /* magic word FDT_MAGIC */ fdt32_t totalsize; /* total size of DT block */ fdt32_t off_dt_struct; /* offset to structure */ fdt32_t off_dt_strings; /* offset to strings */ fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ fdt32_t version; /* format version */ fdt32_t last_comp_version; /* last compatible version *...
kconfig
linux/kconfig.h__count_args 计算可变参数宏的参数数123456/* * 计算可变参数宏的参数数。目前只需要 * 它用于 1、2 或 3 个参数。 */#define __arg6(a1, a2, a3, a4, a5, a6, ...) a6#define __count_args(...) __arg6(dummy, ##__VA_ARGS__, 4, 3, 2, 1, 0) 传递一个虚拟参数 dummy和参数传入,并返回第6个参数; 例如传入 __count_args(a, b, c),则展开为 __arg6(dummy, a, b, c, 4, 3, 2, 1, 0),则返回3 dummy 是一个虚拟参数,用于确保宏展开时参数列表的长度一致。在 __count_args 宏中,dummy 被用作第一个参数,以确保即使没有传递任何参数,参数列表的长度也至少为 1。 ##__VA_ARGS__ 是一个预处理器技巧,用于处理可变参数宏。VA_ARGS 是一个特殊的宏参数,表示传递给宏的所有可变参数。## 是预处理器的连接运算符,用于将两个...







