串口相关的 UCLASS DRIVER DEVICE
UCLASS
./drivers/serial/serial-uclass.c L504
504 UCLASS_DRIVER(serial) = {
505 .id = UCLASS_SERIAL,
506 .name = "serial",
507 .flags = DM_UC_FLAG_SEQ_ALIAS,
508 .post_probe = serial_post_probe,
509 .pre_remove = serial_pre_remove,
510 .per_device_auto_alloc_size = sizeof(struct serial_dev_priv),
511 };
DRIVER
./drivers/serial/s3c64xx_serial.c L218
static const struct udevice_id s3c64xx_serial_ids[] = {
{ .compatible = "samsung,ok6410-uart" },
{ }
};
U_BOOT_DRIVER(serial_s3c64xx) = {
.name = "serial_s3c64xx",
.id = UCLASS_SERIAL,
.of_match = s3c64xx_serial_ids,
.ofdata_to_platdata = s3c64xx_serial_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct s3c64xx_serial_platdata),
.probe = s3c64xx_serial_probe,
.ops = &s3c64xx_serial_ops,
.flags = DM_FLAG_PRE_RELOC,
};
DEVICE
arch/arm/dts/s3c64xx-ok6410a.dts L54
serial0@7F005000 {
compatible = "samsung,ok6410-uart";
reg = <0x7F005000 0x400>;
interrupt-parent = <&gic>;
interrupts = <0 37 0>;
id = <0>;
};
初始化过程中的绑定
initf_dm 中串口 UCLASS DRIVER DEVICE 的 绑定
initf_dm
dm_init_and_scan
dm_extended_scan_fdt
dm_scan_fdt
dm_scan_fdt_node
for_each_node // node serial0@7F005000
lists_bind_fdt
driver_check_compatible
strcmp(of_match->compatible, compat)
device_bind_with_driver_data
device_bind_common
dev = calloc(1, sizeof(struct udevice));
dev->driver = drv;
dev->uclass = uc;
uclass_bind_device(dev);
if (drv->bind) drv->bind(dev);
init_baud_rate
serial_init
serial_find_console_or_panic
serial_check_stdout
fdtdec_get_chosen_prop
uclass_get_device_by_of_offset
uclass_get_device_tail
device_probe
device_ofdata_to_platdata
if (drv->ofdata_to_platdata && (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_of_node(dev)))
drv->ofdata_to_platdata(dev);
if (drv->probe) drv->probe(dev);/即s3c64xx_serial_probe
s3c64xx_serial_init
uart->UFCON = 0;
serial_setbrg
initr_dm 中串口 UCLASS DRIVER DEVICE 的 绑定
initr_dm
serial_initialize
serial_init
极度类似 initf_dm
消费者
UCLASS 提供的 API
消费者调用的 是 UCLASS(./drivers/serial/serial-uclass.c) 中提供的 api
为下面 的函数
serial_init(void)
serial_initialize(void)
serial_putc(char ch)
serial_puts(const char *str)
serial_getc(void)
serial_tstc(void)
serial_setbrg(void)
serial_getconfig(struct udevice *dev, uint *config)
serial_setconfig(struct udevice *dev, uint config)
serial_getinfo(struct udevice *dev, struct serial_device_info *info)
serial_stdio_init(void)
初始化阶段的消费者
board_init_f
serial_init
serial_setbrg
display_options
printf
puts
serial_puts
board_init_r
serial_initialize
serial_init
serial_setbrg
stdio_add_devices
serial_stdio_init
console_init_r
print_pre_console_buffer(flushpoint);
puts
console_puts
stdio_devices[file]->puts(stdio_devices[file], s);/ 即 stdio_serial_puts
serial_puts
run_main_loop
main_loop
cli_loop
...
getcmd_getch
serial_getc
printf // lib/vsprintf.c
puts // common/console.c
fputs // common/console.c
console_puts // common/console.c
stdio_devices[file]->puts(stdio_devices[file], s);/ 即 stdio_serial_puts
serial_puts(s);
DRIVER
driver的实现
static const struct udevice_id s3c64xx_serial_ids[] = {
{ .compatible = "samsung,ok6410-uart" },
{ }
};
s3c64xx_serial_probe
s3c64xx_serial_init
static const struct dm_serial_ops s3c64xx_serial_ops = {
.putc = s3c64xx_serial_putc,
.pending = s3c64xx_serial_pending,
.getc = s3c64xx_serial_getc,
上一篇:OK6410A 开发板 (三) 24 u-boot-2021.01 boot 解析 U-boot 镜像运行部分 fs-fat
下一篇:OK6410A 开发板 (三) 22 u-boot-2021.01 boot 解析 U-boot 镜像运行部分 malloc
推荐阅读最新更新时间:2024-10-12 16:52
设计资源 培训 开发板 精华推荐
- 使用 ROHM Semiconductor 的 BM2P012 的参考设计
- LT3990EDD 1.8V 降压转换器的典型应用
- EVAL-AD7767EDZ,用于数据采集系统的 AD7767、24 位、128KSPS、1CH ADC 的评估板
- 使用 ROHM Semiconductor 的 BD80GA5WEFJ 的参考设计
- 1.8V RS-232 收发器
- 使用 Microchip Technology 的 MIC2779H-1YM5 的参考设计
- LT1171IT、2.5A 外部限流器的典型应用
- 具有 1V 开/关控制的 MC33762 双路超低噪声低压降稳压器的典型应用
- BUCK开关电源
- 【训练营_进阶班】基于阿里云智能的插座