Toybrick EN

中文 / EN
Toybrick EN Wiki TB-RK3399ProD How to attach a I2C device to the TB-RK3399ProD
How to attach a I2C device to the TB-RK3399ProD

There are two I2C busses for user, they are I2C6 and I2C7.

1.png

How to add a device to the device tree(gsl3673 here)

  1. &i2c6 {
        status = "okay";
        gsl3673: gsl3673@40 {
                    compatible = "GSL,GSL3673";
                    reg = <0x40>;
                    screen_max_x = <1536>;
                    screen_max_y = <2048>;
                    irq_gpio_number = <&gpio4 RK_PC5 IRQ_TYPE_LEVEL_LOW>;
                    rst_gpio_number = <&gpio4 RK_PC6 GPIO_ACTIVE_HIGH>;
                    };
        };

gsl3673: gsl3673@40: The i2c address of this gsl3673 sensor is 0x40, you should use the same value here

compatible: It should match the value at the driver file

reg: The i2c address of this gsl3673 sensor

gpio: Addition GPIO pin for gsl3673

Driver

You can found the driver file at "drivers/input/touchscreen/gsl3673.c"

The of_device define the compatible value for device tree

  1. static const struct of_device_id gsl_ts_ids[] = {
                       {.compatible = "GSL,GSL3673"},
                       { }
                                };

  1. static const struct i2c_device_id gsl_ts_id[] = {
                       {GSL3673_I2C_NAME, 0},
                       {}
                                };

The entry point of a i2c slave device:

  1. static struct i2c_driver gsl_ts_driver = {
                    .driver = {
                    .name = GSL3673_I2C_NAME,
                    .owner = THIS_MODULE,
                    .of_match_table = of_match_ptr(gsl_ts_ids),
                          },
                    .probe = gsl_ts_probe,
                    .remove = gsl_ts_remove,
                    .id_table = gsl_ts_id,
                         };


Kernel would parse its device tree at booting time, when a I2C device is enabled at the device with its match device, kernel would call the .probe() method of the above struct.




Products Store Community Wiki Download About TB


To Top