OK6410A development board (three) 23 u-boot-2021.01 boot analysis U-boot image running part of the DM an example analysis - serial port

Publisher:HarmoniousDreamLatest update time:2022-09-21 Source: csdnKeywords:OK6410A Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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'

Keywords:OK6410A Reference address:OK6410A development board (three) 23 u-boot-2021.01 boot analysis U-boot image running part of the DM an example analysis - serial port

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

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号