Linux kernel i²c underlying code tracking

Source: Internet
Author: User

Actually, it's about the last platform bus.

In the Arch/arm/mach-mx6/board-mx6q_sabresd.c file

1 Static void__init Mx6_sabresd_board_init (void)                                 2 {                                                                               3 ..... 4strcpy (mxc_i2c0_board_info[0].type,"wm8962"); 5mxc_i2c0_board_info[0].platform_data = &Wm8962_config_data; 6                                                                                 7IMX6Q_ADD_IMX_I2C (0, &mx6q_sabresd_i2c_data); 8IMX6Q_ADD_IMX_I2C (1, &mx6q_sabresd_i2c_data); 9IMX6Q_ADD_IMX_I2C (2, &mx6q_sabresd_i2c_data); Ten .....  One}

3 I²c buses are added here

Look at the prototype of Mx6q_sabresd_i2c_data.

1 Static struct imxi2c_platform_data mx6q_sabresd_i2c_data = {                    2     //. Bitrate = 100000,                                                        3     400000,                                                          4 };                                                                              

Set the I²C bit rate

Into the inside of the code:

1 #define imx6q_add_imx_i2c (ID, pdata)    \                                       2     imx_add_imx_i2c (&imx6q_imx_i2c_data[ ID], pdata)                             

Inside is a macro definition, obviously, this may be another person writing code, there is a structure

1 extern Const struct

 1  struct   Imx_imx_i2c_data { 2  int   ID;  3   Resour                                                     ce_size_t iobase;                                                      4   resource_size_t Iosize;  5   RESOURC                                                        e_size_t IRQ;                                                                               6 }; 

Re-enter IMX_ADD_IMX_I2C ();

1 structPlatform_device *__init IMX_ADD_IMX_I2C (2         Const structImx_imx_i2c_data *data,3         Const structImxi2c_platform_data *pdata)4 {                                                                               5     structResource res[] = {                                                   6         {                                                                       7. Start = data->Iobase,8. end = Data->iobase + Data->iosize-1,                             9. Flags =Ioresource_mem,Ten         }, {                                                                     One. Start = data->IRQ, A. end = Data->IRQ, -. Flags =Ioresource_irq, -         },                                                                       the     };  -                                                                                  -     returnImx_add_platform_device ("IMX-I2C", data->ID, - Res, array_size (res), +pdatasizeof(*pdata));  -}

Linux kernel i²c underlying code tracking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.