|
发表于 2019-6-19 15:19:24
只看该作者
9#
1.i2c-hid.c
我是参考新版的驱动改的,
+#ifdef CONFIG_OF
+static int i2c_hid_of_probe(struct i2c_client *client,
+ struct i2c_hid_platform_data *pdata)
+{
+ struct device *dev = &client->dev;
+ u32 val;
+ int ret;
+
+ ret = of_property_read_u32(dev->of_node, "hid-descr-addr", &val);
+ if (ret) {
+ dev_err(&client->dev, "HID register address not provided\n");
+ return -ENODEV;
+ }
+ if (val >> 16) {
+ dev_err(&client->dev, "Bad HID register address: 0x%08x\n",
+ val);
+ return -EINVAL;
+ }
+ pdata->hid_descriptor_address = val;
+ return 0;
+}
+static const struct of_device_id i2c_hid_of_match[] = {
+ { .compatible = "hid-over-i2c" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, i2c_hid_of_match);
+#else
+static inline int i2c_hid_of_probe(struct i2c_client *client,
+ struct i2c_hid_platform_data *pdata)
+{
+ return -ENODEV;
+}
+#endif
static int i2c_hid_probe(struct i2c_client *client,
const struct i2c_device_id *dev_id)
{
int ret;
struct i2c_hid *ihid;
struct hid_device *hid;
__u16 hidRegister;
struct i2c_hid_platform_data *platform_data = client->dev.platform_data;
dbg_hid("HID probe called for i2c 0x%02x\n", client->addr);
if (!client->irq) {
dev_err(&client->dev,
"HID over i2c has not been provided an Int IRQ\n");
return -EINVAL;
}
ihid = kzalloc(sizeof(struct i2c_hid), GFP_KERNEL);
+ if (!ihid)
+ return -ENOMEM;
+
+ if (client->dev.of_node) {
+ ret = i2c_hid_of_probe(client, &ihid->pdata);
+ if (ret)
+ goto err;
+ } else if (!platform_data) {
+ ret = i2c_hid_acpi_pdata(client, &ihid->pdata);
+ if (ret) {
+ dev_err(&client->dev,
+ "HID register address not provided\n");
+ goto err;
+ }
} else {
ihid->pdata = *platform_data;
}
i2c_set_clientdata(client, ihid);
....................
...................
static struct i2c_driver i2c_hid_driver = {
.driver = {
.name = "i2c_hid",
.owner = THIS_MODULE,
.pm = &i2c_hid_pm,
.acpi_match_table = ACPI_PTR(i2c_hid_acpi_match),
+ .of_match_table = of_match_ptr(i2c_hid_of_match),
},
2.i2c address你必须看你的触摸屏的配置
如果是goodix 有0xBA/oxBB 地址使用0x5d, 0x28/0x29 地址使用0x14
3. firefly-rk3288_defconfig
增加 CONFIG_I2C_HID=y
4. firefly-rk3288.dts
&pinctrl 增加
gpio8_gpio {
gpio8_a7: gpio8-a7 {
rockchip,pins = <GPIO8_A7>;
rockchip,pull = <VALUE_PULL_UP>;
};
};
&i2c1 增加
i2c_hid@5d {
status = "okay";
compatible = "hid-over-i2c";
reg = <0x5d>;
hid-descr-addr = <0x0001>;
interrupt-parent = <&gpio8>;
interrupts = <GPIO_A7 IRQ_TYPE_EDGE_RISING>;
pinctrl-names = "default";
pinctrl-0 = <&gpio8_a7>;
};
应该就这些
|
|