UCLASS DRIVER DEVICE related to serial port
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>;
};
Binding during initialization
Binding of UCLASS DRIVER DEVICE in initf_dm
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
Binding of UCLASS DRIVER DEVICE in initr_dm
initr_dm
serial_initialize
serial_init
Very similar to initf_dm
consumer
API provided by UCLASS
The consumer calls the API provided by UCLASS (./drivers/serial/serial-uclass.c)
For the following function
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)
Consumers in the initialization phase
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 Implementation
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,
.setbrg = s3c64xx_serial_setbrg,
};
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,
};
Relationship with uclass
serial_getc // API provided by UCLASS
_serial_getc(gd->cur_serial_dev);
__serial_getc(dev);
struct dm_serial_ops *ops = serial_get_ops(dev);
ops->getc(dev); / 即 s3c64xx_serial_getc
struct s3c64xx_serial_platdata *plat = dev->platdata;
struct s3c64xx_uart *const uart = plat->reg;
while (!(uart->UTRSTAT & 0x1));
return uart->URXH & 0xff;
other
Successful matching during initf_dm
- found match at 's3c64xx_gpio': 'samsung,s3c6410-pinctrl' matches 'samsung,s3c6410-pinctrl'
- found match at 's3c6410_clock': 'samsung,s3c6410-clk' matches 'samsung,s3c6410-clk'
- found match at 'serial_s3c64xx': 'samsung,ok6410-uart' matches 'samsung,ok6410-uart'
Successful matching during initr_dm
- found match at 's3c64xx_gpio': 'samsung,s3c6410-pinctrl' matches 'samsung,s3c6410-pinctrl'
- found match at 's3c6410_clock': 'samsung,s3c6410-clk' matches 'samsung,s3c6410-clk'
- found match at 'serial_s3c64xx': 'samsung,ok6410-uart' matches 'samsung,ok6410-uart'
Previous article:OK6410A development board (three) 24 u-boot-2021.01 boot analysis U-boot image running part fs-fat
Next article:OK6410A development board (three) 22 u-boot-2021.01 boot analysis U-boot image running part malloc
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- DSP C6000 assembly, handling of data byte non-alignment issues
- 【BearPi-HM Micro】VII: Trial Summary
- TPS61040 boost abnormality problem
- [National Technology N32G457 Review] III. ADC and Serial Port Function Test
- Open-source language Toit claims to be 30 times faster than MicroPython on ESP32
- 【GD32L233C-START Review】4. Signal
- I would like to ask you how to choose an optocoupler
- TI 74HC4052 4-channel analog switch (voltage support 2~6V), 1 of the 8 chips is not working properly, is there a solution?
- FPGA Tutorial from National Taiwan University.rar
- The waveform of the PSIM simulation circuit is inconsistent with the data