当前位置:网站首页>[semidrive source code analysis] [x9 chip startup process] 26 - LK of R5 safetyos_ INIT_ LEVEL_ Target phase code flow analysis (TP drvier, audio server initialization)

[semidrive source code analysis] [x9 chip startup process] 26 - LK of R5 safetyos_ INIT_ LEVEL_ Target phase code flow analysis (TP drvier, audio server initialization)

2022-06-12 13:44:00 CielleeX


Ben SemiDrive Source code analysis And Yocto Source code analysis The series is summarized below :

  1. 【SemiDrive Source code analysis 】【Yocto Source code analysis 】01 - yocto/base Directory source code analysis ( Compilation environment initialization process )
  2. 【SemiDrive Source code analysis 】【Yocto Source code analysis 】02 - yocto/meta-openembedded Directory source code analysis
  3. 【SemiDrive Source code analysis 】【Yocto Source code analysis 】03 - yocto/meta-semidrive Contents and Yocto Kernel Compile process analysis ( On )
  4. 【SemiDrive Source code analysis 】【Yocto Source code analysis 】04 - yocto/meta-semidrive Contents and Yocto Kernel Compile process analysis ( Next )
  5. 【SemiDrive Source code analysis 】【Yocto Source code analysis 】05 - Look for it Yocto Kernel All during compilation Task Where is the source code defined ?
  6. 【SemiDrive Source code analysis 】【Yocto Source code analysis 】06 - Kernel Compile generated Image.bin、Image_nobt.dtb、modules.tgz How are these three files generated ?
  7. 【SemiDrive Source code analysis 】【Yocto Source code analysis 】07 - core-image-base-x9h_ref_serdes.rootfs.ext4 How the file system is generated
  8. 【SemiDrive Source code analysis 】【X9 Chip startup process 】08 - X9 platform lk Directory source code analysis And catalogue
  9. 【SemiDrive Source code analysis 】【X9 Chip startup process 】09 - X9 Platform system startup process analysis
  10. 【SemiDrive Source code analysis 】【X9 Chip startup process 】10 - BareMetal_Suite Catalog R5 DIL.bin Bootstrap source code analysis
  11. 【SemiDrive Source code analysis 】【X9 Chip startup process 】11 - freertos_safetyos Catalog Cortex-R5 DIL2.bin Bootstrap source code analysis
  12. 【SemiDrive Source code analysis 】【X9 Chip startup process 】12 - freertos_safetyos Catalog Cortex-R5 DIL2.bin And sdm_display_init Display initialization source code analysis
  13. 【SemiDrive Source code analysis 】【X9 Chip driver debugging 】13 - GPIO Configuration method
  14. 【SemiDrive Source code analysis 】【X9 Chip startup process 】14 - freertos_safetyos Catalog Cortex-R5 SafetyOS/RTOS Workflow analysis
  15. 【SemiDrive Source code analysis 】【X9 Chip startup process 】15 - freertos_safetyos Catalog R5 SafetyOS And tcpip_init() Code flow analysis
  16. 【SemiDrive Source code analysis 】【X9 Audio Audio module analysis 】16 - Audio module block diagram and hardware schematic diagram analysis
  17. 【SemiDrive Source code analysis 】【X9 Chip startup process 】17 - R5 SafetyOS And LK_INIT_LEVEL_PLATFORM Stage code flow analysis ( On )dcf_init Inter core communication initialization
  18. 【SemiDrive Source code analysis 】【X9 Chip startup process 】18 - R5 SafetyOS And LK_INIT_LEVEL_PLATFORM Phase code flow ( Next ) start-up QNX、Android
  19. 【SemiDrive Source code analysis 】【X9 Chip startup process 】19 - MailBox Introduction to inter core communication mechanism ( Theory Chapter )
  20. 【SemiDrive Source code analysis 】【X9 Chip startup process 】20 - MailBox Introduction to inter core communication mechanism ( Code analysis ) And MailBox for RTOS piece
  21. 【SemiDrive Source code analysis 】【X9 Chip startup process 】21 - MailBox Introduction to inter core communication mechanism ( Code analysis ) And Mailbox for Linux piece
  22. 【SemiDrive Source code analysis 】【X9 Chip startup process 】22 - MailBox Introduction to inter core communication mechanism ( Code analysis ) And RPMSG-VIRTIO Kernel piece
  23. 【SemiDrive Source code analysis 】【X9 Chip startup process 】23 - MailBox Introduction to inter core communication mechanism ( Code analysis ) And RPMSG-IPCC Kernel piece
  24. 【SemiDrive Source code analysis 】【X9 Chip startup process 】24 - MailBox Inter core communication mechanism related register introduction
  25. 【SemiDrive Source code analysis 】【X9 Chip startup process 】25 - MailBox Introduction to inter core communication mechanism ( Code analysis ) And RPMSG-IPCC RTOS & QNX piece
  26. 【SemiDrive Source code analysis 】【X9 Chip startup process 】26 - R5 SafetyOS And LK_INIT_LEVEL_TARGET Stage code flow analysis (TP Drvier、Audio Server initialization )
  27. 《【SemiDrive Source code analysis 】【X9 Chip startup process 】27 - R5 SafetyOS And .apps Application startup code flow analysis 》
  28. 《【SemiDrive Source code analysis 】【X9 Chip startup process 】28 - Android Preloader Start process analysis 》
  29. 《【SemiDrive Source code analysis 】【X9 Chip startup process 】29 - MailBox Introduction to inter core communication mechanism ( Code analysis ) And Property piece 》
  30. 《【SemiDrive Source code analysis 】【X9 Chip startup process 】30 - MailBox Introduction to inter core communication mechanism ( Code analysis ) And RPCall piece 》
  31. 《【SemiDrive Source code analysis 】【X9 Chip startup process 】31 - MailBox Introduction to inter core communication mechanism ( Code analysis ) And Notify piece 》
  32. 《【SemiDrive Source code analysis 】【X9 Chip startup process 】32 - MailBox Introduction to inter core communication mechanism ( Code analysis ) And Socket piece 》
  33. 《【SemiDrive Source code analysis 】【X9 Chip startup process 】33 - MailBox Introduction to inter core communication mechanism ( Code analysis ) And /dev/vircan piece 》


Some time ago , We are analyzing MailBox, Although not all of them have been analyzed , but MailBox I have almost understood the principle of ,

As the project is about to start , Considering the time is no longer supported to continue the detailed analysis MailBox 了 , So start with this article , Continue the analysis of the regression initialization process , Finish the startup process as soon as possible , as for MailBox Let's see later .

in front 《【SemiDrive Source code analysis 】【X9 Chip startup process 】14 - freertos_safetyos Catalog Cortex-R5 SafetyOS/RTOS Workflow analysis 》 in ,

We analyzed ,R5 SafetyOS And LK_INIT_LEVEL_TARGET The stage mainly runs the following functions :
register_touch_driver_entry(),
hal_vpu_create_mutex(),
cospi_early_init(),
hal_crypto_init(),
(lk_init_hook)res_fs_init(),
(lk_init_hook)audio_server_init()


One 、register_touch_driver_entry() register TP drive

It can be seen that , The touch drive is driven by register_touch_driver() To detect initialization TP Of ,

Registration time , First call get_touch_device(&tsc, &tsc_num); obtain TP Relevant configuration information is saved in tsc[i] in ,
Then call the driver switch probe function , The ginseng tsc[i] Configuration parameters

# buildsystem\rtos\lk_boot\framework\service\input\include\touch_driver.h
#define register_touch_driver(drv) \ static void register_touch_driver_entry(uint level) \ {
       \ __register_touch_driver(&drv); \ } \ LK_INIT_HOOK(touch_driver##drv, register_touch_driver_entry, LK_INIT_LEVEL_TARGET)

# buildsystem\rtos\lk_boot\framework\service\input\touch_driver.c
void __register_touch_driver(struct touch_driver *driver)
{
    
    struct ts_board_config *tsc = NULL;
    int tsc_num = 0;
    get_touch_device(&tsc, &tsc_num);

    for (int i = 0; i < tsc_num; i++) {
    
        if (tsc[i].enable && driver->probe && !strcmp(tsc[i].device_name, driver->driver_name))
            driver->probe(&tsc[i]);
    }
}

1.1 TP Configuration parameters ts_board_config

The following is X9HP default TP Configuration parameters , The following is used LVDS3 and LVDS4 Two interfaces

# buildsystem\rtos\lk_boot\target\reference_x9\safety\touch_device.c
static struct ts_board_config tsc[] = {
    
    {
    
        /*---LVDS4---*/
        TS_ENABLE, "goodix", RES_I2C_I2C15, 0x5d,
        TS_SUPPORT_CTRLPANEL_MAIN, CONTROLPANEL,
        {
    1920, 720, 10, 0, 0, 0},
        {
    false, 12, 0x75, TCA9539_P07},
        {
    true, TI_SERDES, TI947_SINGLE, TI948, 0x1a, 0x2c, 3, 2},
        {
    0}, //reset-pin:0 not used yet
        {
    
            PortConf_PIN_I2S_MC_SD7, //irq-pin:131
            {
    0, 0}
        }
    },
    {
    
        /*---LVDS3---*/
        TS_DISABLE, "goodix", RES_I2C_I2C14, 0x5d,
        TS_SUPPORT_CTRLPANEL_AUX1, ENTERTAINMENT,
        {
    1920, 720, 10, 0, 0, 0},
        {
    false, 12, 0x75, TCA9539_P06},
        {
    false, TI_SERDES, TI947_SINGLE, TI948, 0x0, 0x0, 0, 0},
        {
    0}, //reset-pin:0 not used yet
        {
    
            PortConf_PIN_I2S_MC_SD6, //irq-pin:130
            {
    0, 0}
        }
    },
};

 Its structure is defined as follows :
# buildsystem\rtos\lk_boot\framework\service\input\include\touch_device.h
struct ts_board_config {
    
    bool enable;
    const char *device_name;
    u32 res_id;
    u16 i2c_addr;
    u16 ts_domain_support;
    enum DISPLAY_SCREEN screen_id;
    struct ts_coord_config coord_config;
    struct port_expand_config port_config;
    struct ts_serdes_config serdes_config;
    struct ts_pin_config reset_pin;
    struct ts_pin_config irq_pin;
};

TP Using serial 、 The chip for unthreading is TI947_SINGLETI948

# buildsystem\rtos\lk_boot\framework\service\input\include\touch_device.h
enum ts_serdes_type {
    
    TI_SERDES,
    TS_SERDES_MAX,
};
enum ts_ser_type {
    
    TI941_SINGLE,
    TI941_SECOND,
    TI941_DUAL,
    TI947_SINGLE,
    TI947_SECOND,
    TI947_DUAL,
    TS_SER_MAX,
};
enum ts_des_type {
    
    TI948,
    TS_DES_MAX
};

1.2 TP Configuration parameters

We use goodix.c For example , have a look TP What was done during initialization :

# buildsystem\rtos\lk_boot\exdev\touch\src\goodix.c
static struct touch_driver goodix_driver = {
    
    "goodix",
    goodix_probe_device,
};
register_touch_driver(goodix_driver);

We enter goodix_probe_device() function , Start probe initialization :

  1. Apply and initialize goodix Structure , analysis dev_irq_pin_num Respectively 130 and 131
  2. obtain I2C Handle instance, Save in goodix->i2c_handle in
  3. analysis Serial 、 Deserialization conf Parameters , Configure the serial deserialization link : Check serdes Whether the link is connected 、 Can make TI947_SINGLE chip 、 Write register 0x17 by 0x9e( start-up i2c pass
  4. Check serdes Whether the link is connected , adopt I2C Direct reading 0x6 register , In which the corresponding des Address
  5. Reset device , Read the version number .
# buildsystem\rtos\lk_boot\exdev\touch\src\goodix.c
static int goodix_probe_device(const struct ts_board_config *conf)
{
    
    struct goodix_ts_data *goodix = NULL;
    // 1.  Apply and initialize  goodix  Structure , analysis dev_irq_pin_num Respectively 130 and 131
    goodix = malloc(sizeof(struct goodix_ts_data));
    memset(goodix, 0, sizeof(struct goodix_ts_data));
    goodix->conf = conf;									// reference_x9\safety\touch_device.c
    goodix->instance = goodix->conf->ts_domain_support;		// 0x5d
    goodix->dev_irq = goodix->conf->irq_pin.pin_num;		// PortConf_PIN_I2S_MC_SD7:131, PortConf_PIN_I2S_MC_SD6:130
	
	// 2.  obtain RES_I2C_I2C15 and RES_I2C_I2C14  Of I2C Handle instance,  Save in goodix->i2c_handle in 
    hal_i2c_creat_handle(&goodix->i2c_handle, goodix->conf->res_id);	// RES_I2C_I2C15、RES_I2C_I2C14
    =====>  instance = hal_i2c_get_instance(i2c_res_glb_idx);
	
	// 3.  analysis   Serial 、 Deserialization  conf Parameters , Configure the serial deserialization link :  Check  serdes  Whether the link is connected 、 Can make TI947_SINGLE  chip 、 Write register  0x17 by 0x9e( start-up i2c pass)
    if (goodix->conf->serdes_config.enable) {
    
        if (goodix->conf->serdes_config.serdes_type == TI_SERDES) {
    
            enum ts_ser_type ser_type = goodix->conf->serdes_config.ser_type;	// TI947_SINGLE
            enum ts_des_type des_type = goodix->conf->serdes_config.des_type;	// TI948
            u16 ser_addr = goodix->conf->serdes_config.ser_addr;				// 0x1a
            u16 des_addr = goodix->conf->serdes_config.des_addr;				// 0x2c
			// 4.  Check  serdes  Whether the link is connected , adopt  I2C  Direct reading  0x6  register , In which the corresponding des  Address .
            ret = ti_serdes_link_check(goodix->i2c_handle, ser_addr, ser_type, des_addr, des_type);
			// 5.  Can make TI947_SINGLE  chip , Write register 0x1e=0x01
            ret = ti_ser_enable_port(goodix->i2c_handle, ser_addr, ser_type);
			// 6.  Write register  0x17 by 0x9e:  start-up i2c pas
            ret = ti_ser_enable_i2c_passthrough(goodix->i2c_handle, ser_addr, ser_type);
        }
    }
	// 7.  Reset device , Read the version number .
    do {
    
        goodix_reset_device(goodix);
        if (!goodix_read_version(goodix))
            break;
    } while (++count < 3);


    ret = goodix_firmware_upgrade(goodix);

    ret = goodix_config_device(goodix);

    goodix->safe_ts_dev = safe_ts_alloc_device();


    goodix->safe_ts_dev->instance = goodix->conf->ts_domain_support;
    goodix->safe_ts_dev->screen_id = goodix->conf->screen_id;
    goodix->safe_ts_dev->vinfo.id = goodix->id;
    goodix->safe_ts_dev->vinfo.version = goodix->version;
    goodix->safe_ts_dev->vinfo.vendor = goodix->vendor;
    goodix->safe_ts_dev->vinfo.name = goodix->conf->device_name;
    goodix->safe_ts_dev->vinfo.ser_addr = goodix->conf->serdes_config.ser_addr;
    goodix->safe_ts_dev->vinfo.des_addr = goodix->conf->serdes_config.des_addr;
    goodix->safe_ts_dev->vinfo.ts_addr = goodix->conf->i2c_addr;
    goodix->safe_ts_dev->cinfo.max_touch_num = goodix->conf->coord_config.max_touch_num;
    goodix->safe_ts_dev->cinfo.swapped_x_y = goodix->conf->coord_config.swapped_x_y;
    goodix->safe_ts_dev->cinfo.inverted_x = goodix->conf->coord_config.inverted_x;
    goodix->safe_ts_dev->cinfo.inverted_y = goodix->conf->coord_config.inverted_y;
    goodix->safe_ts_dev->set_inited = goodix_set_inited;
    goodix->safe_ts_dev->vendor_priv = goodix;

    ret = safe_ts_register_device(goodix->safe_ts_dev);
    if (ret) {
    
        safe_ts_delete_device(goodix->safe_ts_dev);
        dprintf(CRITICAL, "%s: safe_ts_register_device fail, instance=%#x\n",
                __func__, goodix->instance);
        goto err;
    }

    dprintf(ALWAYS, "%s, instance=%#x, done ok\n", __func__, goodix->instance);
    return 0;

err1:
    hal_i2c_release_handle(goodix->i2c_handle);
err:
    free(goodix);
    return -1;
}

Two 、hal_vpu_create_mutex()


3、 ... and 、cospi_early_init()


Four 、hal_crypto_init()


5、 ... and 、(lk_init_hook)res_fs_init()


6、 ... and 、(lk_init_hook)audio_server_init()

原网站

版权声明
本文为[CielleeX]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206121335505919.html