Hi guys, I am trying to load TI bq2429x drivers into my yocto image. I face errors when at the do_compile stage. At first glance it looks to be a c program cross compilation error. I think the issue is due to not being able to link with the header files. The error I see on my screen. ERROR: bq2429x-charger-0.1-r0 do_compile: oe_runmake failed ERROR: bq2429x-charger-0.1-r0 do_compile: Execution of '/home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/temp/run.do_compile.322928' failed with exit code 1 ERROR: Logfile of failure stored in: /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/temp/log.do_compile.322928 Log data follows: | DEBUG: Executing shell function do_compile | NOTE: make -j 4 KERNEL_SRC=/home/mohan/amlogic/build/tmp/work-shared/mesons4-lib32-ap222/kernel-source KERNEL_PATH=/home/mohan/amlogic/build/tmp/work-shared/mesons4-lib32-ap222/kernel-source KERNEL_VERSION=5.4.180-amlogic CC=aarch64-poky-linux-gcc -fuse-ld=bfd -fdebug-prefix-map=/home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0=/usr/src/debug/bq2429x-charger/0.1-r0
-fdebug-prefix-map=/home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/recipe-sysroot= -fdebug-prefix-map=/home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/recipe-sysroot-native= -fdebug-prefix-map=/home/mohan/amlogic/build/tmp/work-shared/mesons4-lib32-ap222/kernel-source=/usr/src/kernel LD=aarch64-poky-linux-ld.bfd AR=aarch64-poky-linux-ar O=/home/mohan/amlogic/build/tmp/work-shared/mesons4-lib32-ap222/kernel-build-artifacts KBUILD_EXTRA_SYMBOLS= | make -C /home/mohan/amlogic/build/tmp/work-shared/mesons4-lib32-ap222/kernel-source M=/home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0 | make[1]: Entering directory '/home/mohan/amlogic/aml-comp/kernel/aml-5.4' | make[2]: Entering directory '/home/mohan/amlogic/build/tmp/work-shared/mesons4-lib32-ap222/kernel-build-artifacts' | AR /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/built-in.a | CC [M] /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.o | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:37: error: "BQ2429X_OTG_ENABLE" redefined [-Werror] | 37 | #define BQ2429X_OTG_ENABLE 0x00 | | | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:36: note: this is the location of the previous definition | 36 | #define BQ2429X_OTG_ENABLE 0x01 | | | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c: In function 'bq2429x_disable_otg': | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:317:14: error: 'BQ2429X_OTG_DISABLE' undeclared (first use in this function); did you mean 'BQ2429X_WD_DISABLE'? | 317 | u8 val = BQ2429X_OTG_DISABLE << BQ2429x_OTG_SHIFT; | | ^~~~~~~~~~~~~~~~~~~ | | BQ2429X_WD_DISABLE | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:317:14: note: each undeclared identifier is reported only once for each function it appears in | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:317:37: error: 'BQ2429x_OTG_SHIFT' undeclared (first use in this function); did you mean 'BQ2429X_OTG_SHIFT'? | 317 | u8 val = BQ2429X_OTG_DISABLE << BQ2429x_OTG_SHIFT; | | ^~~~~~~~~~~~~~~~~ | | BQ2429X_OTG_SHIFT | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c: At top level: | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:323:63: error: function declaration isn't a prototype [-Werror=strict-prototypes] | 323 | static int bq2429x_set_chargecurrent(struct bq2429x *bq, enum bq2429x_charge_current current) | | ^~~~~~~~~~~~~~~~~~~~~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c: In function 'bq2429x_set_chargevoltage': | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:349:6: error: unused variable 'ret' [-Werror=unused-variable] | 349 | int ret; | | ^~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c: In function 'bq2429x_set_input_volt_limit': | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:373:6: error: unused variable 'ret' [-Werror=unused-variable] | 373 | int ret; | | ^~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c: At top level: | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:393:69: error: function declaration isn't a prototype [-Werror=strict-prototypes] | 393 | static int bq2429x_set_input_current_limit(struct bq2429x *bq, enum bq2429x_input_current_limit current) | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c: In function 'bq2429x_set_input_current_limit': | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:397:6: error: unused variable 'ret' [-Werror=unused-variable] | 397 | int ret; | | ^~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c: In function 'bq2429x_psy_register': | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:478:9: error: 'struct power_supply' has no member named 'name' | 478 | bq->usb.name = "bq2429x-usb"; | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:479:9: error: 'struct power_supply' has no member named 'type' | 479 | bq->usb.type = POWER_SUPPLY_TYPE_USB; | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:480:9: error: 'struct power_supply' has no member named 'properties' | 480 | bq->usb.properties = bq2429x_charger_props; | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:481:9: error: 'struct power_supply' has no member named 'num_properties' | 481 | bq->usb.num_properties = ARRAY_SIZE(bq2429x_charger_props); | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:482:9: error: 'struct power_supply' has no member named 'get_property' | 482 | bq->usb.get_property = bq2429x_usb_get_property; | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:483:9: error: 'struct power_supply' has no member named 'external_power_changed' | 483 | bq->usb.external_power_changed = NULL; | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:485:39: error: passing argument 2 of 'power_supply_register' from incompatible pointer type [-Werror=incompatible-pointer-types] | 485 | ret = power_supply_register(bq->dev, &bq->usb); | | ^~~~~~~~ | | | | | struct power_supply * | In file included from /home/mohan/amlogic/aml-comp/kernel/aml-5.4/include/linux/i2c/bq2429x.h:20, | from /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:17: | /home/mohan/amlogic/aml-comp/kernel/aml-5.4/include/linux/power_supply.h:451:1: note: expected 'const struct power_supply_desc *' but argument is of type 'struct power_supply *' | 451 | power_supply_register(struct device *parent, | | ^~~~~~~~~~~~~~~~~~~~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:485:8: error: too few arguments to function 'power_supply_register' | 485 | ret = power_supply_register(bq->dev, &bq->usb); | | ^~~~~~~~~~~~~~~~~~~~~ | In file included from /home/mohan/amlogic/aml-comp/kernel/aml-5.4/include/linux/i2c/bq2429x.h:20, | from /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:17: | /home/mohan/amlogic/aml-comp/kernel/aml-5.4/include/linux/power_supply.h:451:1: note: declared here | 451 | power_supply_register(struct device *parent, | | ^~~~~~~~~~~~~~~~~~~~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:491:10: error: 'struct power_supply' has no member named 'name' | 491 | bq->wall.name = "bq2429x-wall"; | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:492:10: error: 'struct power_supply' has no member named 'type' | 492 | bq->wall.type = POWER_SUPPLY_TYPE_MAINS; | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:493:10: error: 'struct power_supply' has no member named 'properties' | 493 | bq->wall.properties = bq2429x_charger_props; | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:494:10: error: 'struct power_supply' has no member named 'num_properties' | 494 | bq->wall.num_properties = ARRAY_SIZE(bq2429x_charger_props); | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:495:10: error: 'struct power_supply' has no member named 'get_property' | 495 | bq->wall.get_property = bq2429x_wall_get_property; | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:496:10: error: 'struct power_supply' has no member named 'external_power_changed' | 496 | bq->wall.external_power_changed = NULL; | | ^ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:498:39: error: passing argument 2 of 'power_supply_register' from incompatible pointer type [-Werror=incompatible-pointer-types] | 498 | ret = power_supply_register(bq->dev, &bq->wall); | | ^~~~~~~~~ | | | | | struct power_supply * | In file included from /home/mohan/amlogic/aml-comp/kernel/aml-5.4/include/linux/i2c/bq2429x.h:20, | from /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:17: | /home/mohan/amlogic/aml-comp/kernel/aml-5.4/include/linux/power_supply.h:451:1: note: expected 'const struct power_supply_desc *' but argument is of type 'struct power_supply *' | 451 | power_supply_register(struct device *parent, | | ^~~~~~~~~~~~~~~~~~~~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:498:8: error: too few arguments to function 'power_supply_register' | 498 | ret = power_supply_register(bq->dev, &bq->wall); | | ^~~~~~~~~~~~~~~~~~~~~ | In file included from /home/mohan/amlogic/aml-comp/kernel/aml-5.4/include/linux/i2c/bq2429x.h:20, | from /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:17: | /home/mohan/amlogic/aml-comp/kernel/aml-5.4/include/linux/power_supply.h:451:1: note: declared here | 451 | power_supply_register(struct device *parent, | | ^~~~~~~~~~~~~~~~~~~~~ | At top level: | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:393:12: error: 'bq2429x_set_input_current_limit' defined but not used [-Werror=unused-function] | 393 | static int bq2429x_set_input_current_limit(struct bq2429x *bq, enum bq2429x_input_current_limit current) | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:369:12: error: 'bq2429x_set_input_volt_limit' defined but not used [-Werror=unused-function] | 369 | static int bq2429x_set_input_volt_limit(struct bq2429x *bq, enum bq2429x_input_voltage_limit volt) | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:345:12: error: 'bq2429x_set_chargevoltage' defined but not used [-Werror=unused-function] | 345 | static int bq2429x_set_chargevoltage(struct bq2429x *bq, enum bq2429x_charge_voltage_limit volt) | | ^~~~~~~~~~~~~~~~~~~~~~~~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:323:12: error: 'bq2429x_set_chargecurrent' defined but not used [-Werror=unused-function] | 323 | static int bq2429x_set_chargecurrent(struct bq2429x *bq, enum bq2429x_charge_current current) | | ^~~~~~~~~~~~~~~~~~~~~~~~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:315:12: error: 'bq2429x_disable_otg' defined but not used [-Werror=unused-function] | 315 | static int bq2429x_disable_otg(struct bq2429x *bq) | | ^~~~~~~~~~~~~~~~~~~ | /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.c:306:12: error: 'bq2429x_enable_otg' defined but not used [-Werror=unused-function] | 306 | static int bq2429x_enable_otg(struct bq2429x *bq) | | ^~~~~~~~~~~~~~~~~~ | cc1: all warnings being treated as errors | make[3]: *** [/home/mohan/amlogic/aml-comp/kernel/aml-5.4/scripts/Makefile.build:284: /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/bq2429x_charger.o] Error 1 | ERROR: oe_runmake failed | make[2]: *** [/home/mohan/amlogic/aml-comp/kernel/aml-5.4/Makefile:1857: /home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0] Error 2 | make[2]: Leaving directory '/home/mohan/amlogic/build/tmp/work-shared/mesons4-lib32-ap222/kernel-build-artifacts' | make[1]: *** [Makefile:179: sub-make] Error 2 | make[1]: Leaving directory '/home/mohan/amlogic/aml-comp/kernel/aml-5.4' | make: *** [Makefile:7: all] Error 2 | WARNING: exit code 1 from a shell command. | ERROR: Execution of '/home/mohan/amlogic/build/tmp/work/mesons4_lib32_ap222-poky-linux/bq2429x-charger/0.1-r0/temp/run.do_compile.322928' failed with exit code 1 ERROR: Task (/home/mohan/amlogic/meta-meson/recipes-kernel/bq2429x_charger/bq2429x-charger_0.1.bb:do_compile) failed with exit code '1' I have attached the drivers files I got from the vendor and also the log.do_compile file. Thanks Hassan
bq2429x-charger_0.1.bb
Description: Binary data
/* * BQ2429x battery charging driver * * Copyright (C) 2013 Texas Instruments * * This package is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include <linux/gpio.h> #include <linux/i2c.h> #include <linux/i2c/bq2429x.h> //#include "bq2429x.h" #include <linux/init.h> #include <linux/interrupt.h> #include <linux/module.h> #include <linux/power_supply.h> #include <linux/slab.h> /* Register 00h */ #define BQ2429X_INPUT_SRC_CTRL 0x00 #define BQ2429X_VINDPM_MASK 0x78 #define BQ2429X_VINDPM_SHIFT 3 #define BQ2429X_IINLIM_MASK 0x07 #define BQ2429X_IINLIM_SHIFT 0 /* Register 01h */ #define BQ2429X_CONFIG 0x01 #define BQ2429X_OTG_MASK 0x20 #define BQ2429X_OTG_SHIFT 5 #define BQ2429X_OTG_ENABLE 0x01 #define BQ2429X_OTG_ENABLE 0x00 /* Register 02h */ #define BQ2429X_ICHG_CTRL 0x02 #define BQ2429X_ICHG_MASK 0xFC #define BQ2429X_ICHG_SHIFT 2 /* Register 04h */ #define BQ2429X_VREG_CTRL 0x04 #define BQ2429X_VREG_MASK 0xFC #define BQ2429X_VREG_SHIFT 2 /* Register 05h */ #define BQ2429X_WD_CTRL 0x05 #define BQ2429X_WD_MASK 0x30 #define BQ2429X_WD_SHIFT 4 #define BQ2429X_WD_DISABLE 0x00 /* Register 08h */ #define BQ2429X_STATUS 0x08 #define BQ2429X_VBUS_STATUS_MASK 0xC0 #define BQ2429X_VBUS_STATUS_SHIFT 6 #define BQ2429X_CHG_STAT_MASK 0x30 #define BQ2429X_CHG_STAT_SHIFT 4 #define BQ2429X_NOT_CHARGING 0 #define BQ2429X_FAST_CHARGING 2 /* Register 09h */ #define BQ2429X_FAULT 0x09 /* Charging parameters */ #define BQ2429X_DEFAULT_USB_VLIM BQ2429X_VLIM_4360mV #define BQ2429X_DEFAULT_USB_ILIM BQ2429X_ILIM_500mA #define BQ2429X_DEFAULT_USB_ICHG BQ2429X_ICHG_512mA #define BQ2429X_DEFAULT_USB_VREG BQ2429X_VREG_4352mV #define BQ2429X_DEFAULT_TA_VLIM BQ2429X_VLIM_4360mV #define BQ2429X_DEFAULT_TA_ILIM BQ2429X_ILIM_3000mA #define BQ2429X_DEFAULT_TA_ICHG BQ2429X_ICHG_3008mA #define BQ2429X_DEFAULT_TA_VREG BQ2429X_VREG_4352mV enum bq2429x_vbus_type { BQ2429X_VBUS_NONE, BQ2429X_VBUS_USB_CHARGER, BQ2429X_VBUS_TA_CHARGER, BQ2429X_VBUS_OTG, }; struct bq2429x { struct device *dev; struct i2c_client *client; int irq; struct work_struct irq_work; struct power_supply usb; struct power_supply wall; /* Charging parameters */ struct bq2429x_charge_param usb_param; struct bq2429x_charge_param ta_param; }; static int bq2429x_disable_watchdog_timer(struct bq2429x *bq); static int bq2429x_read_byte(struct bq2429x *bq, u8 *data, u8 reg) { int ret; ret = i2c_smbus_read_byte_data(bq->client, reg); if (ret < 0) { dev_err(bq->dev, "failed to read 0x%.2x\n", reg); return ret; } *data = (u8)ret; return 0; } static int bq2429x_write_byte(struct bq2429x *bq, u8 reg, u8 data) { return i2c_smbus_write_byte_data(bq->client, reg, data); } static int bq2429x_update_bits(struct bq2429x *bq, u8 reg, u8 mask, u8 data) { int ret; u8 tmp; ret = bq2429x_read_byte(bq, &tmp, reg); if (ret) return ret; tmp &= ~mask; tmp |= data & mask; return bq2429x_write_byte(bq, reg, tmp); } static enum power_supply_property bq2429x_charger_props[] = { POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_CHARGE_TYPE, }; static enum bq2429x_vbus_type bq2429x_get_vbus_type(struct bq2429x *bq) { u8 val = 0; bq2429x_read_byte(bq, &val, BQ2429X_STATUS); val &= BQ2429X_VBUS_STATUS_MASK; val >>= BQ2429X_VBUS_STATUS_SHIFT; return val; } static int bq2429x_charge_status(struct bq2429x *bq) { u8 val = 0; bq2429x_read_byte(bq, &val, BQ2429X_STATUS); val &= BQ2429X_CHG_STAT_MASK; val >>= BQ2429X_CHG_STAT_SHIFT; switch (val) { case BQ2429X_FAST_CHARGING: return POWER_SUPPLY_CHARGE_TYPE_FAST; case BQ2429X_NOT_CHARGING: return POWER_SUPPLY_CHARGE_TYPE_NONE; default: return POWER_SUPPLY_CHARGE_TYPE_UNKNOWN; } } static int bq2429x_usb_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { struct bq2429x *bq = container_of(psy, struct bq2429x, usb); switch (psp) { case POWER_SUPPLY_PROP_ONLINE: if (bq2429x_get_vbus_type(bq) == BQ2429X_VBUS_USB_CHARGER) val->intval = 1; else val->intval = 0; break; case POWER_SUPPLY_PROP_CHARGE_TYPE: val->intval = bq2429x_charge_status(bq); break; default: return -EINVAL; } return 0; } static int bq2429x_wall_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { struct bq2429x *bq = container_of(psy, struct bq2429x, wall); switch (psp) { case POWER_SUPPLY_PROP_ONLINE: if (bq2429x_get_vbus_type(bq) == BQ2429X_VBUS_TA_CHARGER) val->intval = 1; else val->intval = 0; break; case POWER_SUPPLY_PROP_CHARGE_TYPE: val->intval = bq2429x_charge_status(bq); break; default: return -EINVAL; } return 0; } static int bq2429x_update_charge_params(struct bq2429x *bq) { enum bq2429x_vbus_type type = bq2429x_get_vbus_type(bq); int ret; u8 vlim; u8 ilim; u8 ichg; u8 vreg; switch (type) { case BQ2429X_VBUS_USB_CHARGER: vlim = bq->usb_param.vlim; ilim = bq->usb_param.ilim; ichg = bq->usb_param.ichg; vreg = bq->usb_param.vreg; break; case BQ2429X_VBUS_TA_CHARGER: vlim = bq->ta_param.vlim; ilim = bq->ta_param.ilim; ichg = bq->ta_param.ichg; vreg = bq->ta_param.vreg; break; default: return -EINVAL; } ret = bq2429x_update_bits(bq, BQ2429X_INPUT_SRC_CTRL, BQ2429X_VINDPM_MASK, vlim << BQ2429X_VINDPM_SHIFT); if (ret) return ret; ret = bq2429x_update_bits(bq, BQ2429X_INPUT_SRC_CTRL, BQ2429X_IINLIM_MASK, ilim << BQ2429X_IINLIM_SHIFT); if (ret) return ret; ret = bq2429x_update_bits(bq, BQ2429X_ICHG_CTRL, BQ2429X_ICHG_MASK, ichg << BQ2429X_ICHG_SHIFT); if (ret) return ret; return bq2429x_update_bits(bq, BQ2429X_VREG_CTRL, BQ2429X_VREG_MASK, vreg << BQ2429X_VREG_SHIFT); } static void bq2429x_irq_workfunc(struct work_struct *work) { struct bq2429x *bq = container_of(work, struct bq2429x, irq_work); u8 status; u8 fault; int ret; /* Disable the watchdog timer forcedly */ bq2429x_disable_watchdog_timer(bq); /* Read STATUS and FAULT registers */ ret = bq2429x_read_byte(bq, &status, BQ2429X_STATUS); if (ret) { dev_err(bq->dev, "i2c failure:%d\n", ret); return; } ret = bq2429x_read_byte(bq, &fault, BQ2429X_FAULT); if (ret) { dev_err(bq->dev, "i2c failure: %d\n", ret); return; } dev_info(bq->dev, "IRQ status=0x%.2x, fault=0x%.2x\n", status, fault); /* Set charging parameters: VINDPM, IINLIM and ICHG */ bq2429x_update_charge_params(bq); } static irqreturn_t bq2429x_interrupt(int irq, void *data) { struct bq2429x *bq = data; schedule_work(&bq->irq_work); return IRQ_HANDLED; } static int bq2429x_disable_watchdog_timer(struct bq2429x *bq) { u8 val = BQ2429X_WD_DISABLE << BQ2429X_WD_SHIFT; return bq2429x_update_bits(bq, BQ2429X_WD_CTRL, BQ2429X_WD_MASK, val); } static int bq2429x_enable_otg(struct bq2429x *bq) { u8 val = BQ2429X_OTG_ENABLE << BQ2429X_OTG_SHIFT; return bq2429x_update_bits(bq, BQ2429X_CONFIG, BQ2429X_OTG_MASK, val); } static int bq2429x_disable_otg(struct bq2429x *bq) { u8 val = BQ2429X_OTG_DISABLE << BQ2429x_OTG_SHIFT; return bq2429x_update_bits(bq, BQ2429X_CONFIG, BQ2429X_OTG_MASK, val); } static int bq2429x_set_chargecurrent(struct bq2429x *bq, enum bq2429x_charge_current current) { enum bq2429x_vbus_type type = bq2429x_get_vbus_type(bq); u8 ichg; switch (type) { case BQ2429X_VBUS_USB_CHARGER: ichg = bq->usb_param.ichg = current; break; case BQ2429X_VBUS_TA_CHARGER: ichg = bq->ta_param.ichg = current; break; default: return -EINVAL; } return bq2429x_update_bits(bq, BQ2429X_ICHG_CTRL, BQ2429X_ICHG_MASK, ichg << BQ2429X_ICHG_SHIFT); } static int bq2429x_set_chargevoltage(struct bq2429x *bq, enum bq2429x_charge_voltage_limit volt) { enum bq2429x_vbus_type type = bq2429x_get_vbus_type(bq); int ret; u8 vreg; switch (type) { case BQ2429X_VBUS_USB_CHARGER: vreg = bq->usb_param.vreg = volt; break; case BQ2429X_VBUS_TA_CHARGER: vreg = bq->ta_param.vreg = volt; break; default: return -EINVAL; } return bq2429x_update_bits(bq, BQ2429X_VREG_CTRL, BQ2429X_VREG_MASK, vreg << BQ2429X_VREG_SHIFT); } static int bq2429x_set_input_volt_limit(struct bq2429x *bq, enum bq2429x_input_voltage_limit volt) { enum bq2429x_vbus_type type = bq2429x_get_vbus_type(bq); int ret; u8 vlim; switch (type) { case BQ2429X_VBUS_USB_CHARGER: vlim = bq->usb_param.vlim = volt; break; case BQ2429X_VBUS_TA_CHARGER: vlim = bq->ta_param.vlim = volt; break; default: return -EINVAL; } return bq2429x_update_bits(bq, BQ2429X_INPUT_SRC_CTRL, BQ2429X_VINDPM_MASK, vlim << BQ2429X_VINDPM_SHIFT); } static int bq2429x_set_input_current_limit(struct bq2429x *bq, enum bq2429x_input_current_limit current) { enum bq2429x_vbus_type type = bq2429x_get_vbus_type(bq); int ret; u8 ilim; switch (type) { case BQ2429X_VBUS_USB_CHARGER: ilim = bq->usb_param.ilim = current; break; case BQ2429X_VBUS_TA_CHARGER: ilim = bq->ta_param.ilim = current; break; default: return -EINVAL; } return bq2429x_update_bits(bq, BQ2429X_INPUT_SRC_CTRL, BQ2429X_IINLIM_MASK, ilim << BQ2429X_IINLIM_SHIFT); } static int bq2429x_init_charge_params(struct bq2429x *bq, struct bq2429x_platform_data *pdata) { /* * Update charging parameters: * if the platform data is not configured, use the default value * if the platform data has specific values, use them */ bq->usb_param.vlim = BQ2429X_DEFAULT_USB_VLIM; bq->usb_param.ilim = BQ2429X_DEFAULT_USB_ILIM; bq->usb_param.ichg = BQ2429X_DEFAULT_USB_ICHG; bq->usb_param.vreg = BQ2429X_DEFAULT_USB_VREG; bq->ta_param.vlim = BQ2429X_DEFAULT_TA_VLIM; bq->ta_param.ilim = BQ2429X_DEFAULT_TA_ILIM; bq->ta_param.ichg = BQ2429X_DEFAULT_TA_ICHG; bq->ta_param.vreg = BQ2429X_DEFAULT_TA_VREG; if (!pdata) return 0; if (pdata->usb_param) { bq->usb_param.vlim = pdata->usb_param->vlim; bq->usb_param.ilim = pdata->usb_param->ilim; bq->usb_param.ichg = pdata->usb_param->ichg; bq->usb_param.vreg = pdata->usb_param->vreg; } if (pdata->ta_param) { bq->ta_param.vlim = pdata->ta_param->vlim; bq->ta_param.ilim = pdata->ta_param->ilim; bq->ta_param.ichg = pdata->ta_param->ichg; bq->ta_param.vreg = pdata->ta_param->vreg; } return 0; } static int bq2429x_init_device(struct bq2429x *bq, struct bq2429x_platform_data *pdata) { int ret; /* * Put here for initialization process */ ret = bq2429x_disable_watchdog_timer(bq); if (ret) return ret; return bq2429x_init_charge_params(bq, pdata); } static int bq2429x_psy_register(struct bq2429x *bq) { int ret; bq->usb.name = "bq2429x-usb"; bq->usb.type = POWER_SUPPLY_TYPE_USB; bq->usb.properties = bq2429x_charger_props; bq->usb.num_properties = ARRAY_SIZE(bq2429x_charger_props); bq->usb.get_property = bq2429x_usb_get_property; bq->usb.external_power_changed = NULL; ret = power_supply_register(bq->dev, &bq->usb); if (ret) { dev_err(bq->dev, "failed to register usb: %d\n", ret); return ret; } bq->wall.name = "bq2429x-wall"; bq->wall.type = POWER_SUPPLY_TYPE_MAINS; bq->wall.properties = bq2429x_charger_props; bq->wall.num_properties = ARRAY_SIZE(bq2429x_charger_props); bq->wall.get_property = bq2429x_wall_get_property; bq->wall.external_power_changed = NULL; ret = power_supply_register(bq->dev, &bq->wall); if (ret) { dev_err(bq->dev, "failed to register wall: %d\n", ret); goto err_psy_wall; } return 0; err_psy_wall: power_supply_unregister(&bq->usb); return ret; } static void bq2429x_psy_unregister(struct bq2429x *bq) { power_supply_unregister(&bq->wall); power_supply_unregister(&bq->usb); } static ssize_t bq2429x_show_registers(struct device *dev, struct device_attribute *attr, char *buf) { struct bq2429x *bq = dev_get_drvdata(dev); u8 addr; u8 val; for (addr = 0x0; addr <= 0x0A; addr++) { bq2429x_read_byte(bq, &val, addr); dev_info(bq->dev, "[0x%.2x] = 0x%.2x\n", addr, val); } return 0; } static DEVICE_ATTR(registers, S_IRUGO, bq2429x_show_registers, NULL); static struct attribute *bq2429x_attributes[] = { &dev_attr_registers.attr, NULL, }; static const struct attribute_group bq2429x_attr_group = { .attrs = bq2429x_attributes, }; static int bq2429x_charger_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct bq2429x *bq; struct bq2429x_platform_data *pdata = client->dev.platform_data; int ret; bq = kzalloc(sizeof(struct bq2429x), GFP_KERNEL); if (!bq) return -ENOMEM; bq->dev = &client->dev; bq->client = client; bq->irq = client->irq; i2c_set_clientdata(client, bq); ret = bq2429x_init_device(bq, pdata); if (ret) { dev_err(bq->dev, "device init failure: %d\n", ret); goto err_dev; } INIT_WORK(&bq->irq_work, bq2429x_irq_workfunc); ret = bq2429x_psy_register(bq); if (ret) goto err_dev; ret = sysfs_create_group(&bq->dev->kobj, &bq2429x_attr_group); if (ret) { dev_err(bq->dev, "failed to register sysfs. err: %d\n", ret); goto err_dev; } ret = request_irq(bq->irq, bq2429x_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "bq2429x_irq", bq); if (ret) { dev_err(bq->dev, "Request IRQ%d err: %d\n", bq->irq, ret); goto err_irq; } return 0; err_irq: bq2429x_psy_unregister(bq); cancel_work_sync(&bq->irq_work); err_dev: kfree(bq); return ret; } static int bq2429x_charger_remove(struct i2c_client *client) { struct bq2429x *bq = i2c_get_clientdata(client); free_irq(bq->irq, bq); sysfs_remove_group(&bq->dev->kobj, &bq2429x_attr_group); bq2429x_psy_unregister(bq); cancel_work_sync(&bq->irq_work); kfree(bq); return 0; } static const struct i2c_device_id bq2429x_id[] = { { "bq24296", 0 }, {}, }; MODULE_DEVICE_TABLE(i2c, bq2429x_id); static struct i2c_driver bq2429x_charger = { .probe = bq2429x_charger_probe, .remove = bq2429x_charger_remove, .id_table = bq2429x_id, .driver = { .name = "bq2429x", }, }; module_i2c_driver(bq2429x_charger); MODULE_DESCRIPTION("TI BQ2419x Charger Driver"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Texas Instruments");
Makefile
Description: Binary data
/* * Copyright (C) 2013 Texas Instruments * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _LINUX_BQ2429X_I2C_H #define _LINUX_BQ2429X_I2C_H #include <linux/power_supply.h> enum bq2429x_input_voltage_limit { BQ2429X_VLIM_3880mV, BQ2429X_VLIM_3960mV, BQ2429X_VLIM_4040mV, BQ2429X_VLIM_4120mV, BQ2429X_VLIM_4200mV, BQ2429X_VLIM_4280mV, BQ2429X_VLIM_4360mV, BQ2429X_VLIM_4440mV, BQ2429X_VLIM_4520mV, BQ2429X_VLIM_4600mV, BQ2429X_VLIM_4680mV, BQ2429X_VLIM_4760mV, BQ2429X_VLIM_4840mV, BQ2429X_VLIM_4920mV, BQ2429X_VLIM_5000mV, BQ2429X_VLIM_5080mV, }; enum bq2429x_input_current_limit { BQ2429X_ILIM_100mA, BQ2429X_ILIM_150mA, BQ2429X_ILIM_500mA, BQ2429X_ILIM_900mA, BQ2429X_ILIM_1000mA, BQ2429X_ILIM_1500mA, BQ2429X_ILIM_2000mA, BQ2429X_ILIM_3000mA, }; enum bq2429x_charge_current { BQ2429X_ICHG_512mA, BQ2429X_ICHG_1024mA = 8, BQ2429X_ICHG_2048mA = 24, BQ2429X_ICHG_3008mA = 39, // BQ2429X_ICHG_4032mA = 55, // BQ2429X_ICHG_4544mA = 63, }; enum bq2429x_charge_voltage_limit { BQ2429X_VREG_3504mV, BQ2429X_VREG_3600mV = 6, BQ2429X_VREG_3808mV = 19, BQ2429X_VREG_3904mV = 25, BQ2429X_VREG_4000mV = 31, BQ2429X_VREG_4112mV = 38, BQ2429X_VREG_4208mV = 44, BQ2429X_VREG_4304mV = 50, BQ2429X_VREG_4352mV = 53, BQ2429X_VREG_4400mV = 56, BQ2429X_VREG_MAX = BQ2429X_VREG_4400mV, }; struct bq2429x_charge_param { enum bq2429x_input_voltage_limit vlim; enum bq2429x_input_current_limit ilim; enum bq2429x_charge_current ichg; enum bq2429x_charge_voltage_limit vreg; }; struct bq2429x_platform_data { const struct bq2429x_charge_param *usb_param; const struct bq2429x_charge_param *ta_param; }; #endif /* _LINUX_BQ2429X_I2C_H */
log.do_compile.322928
Description: Binary data
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#60356): https://lists.yoctoproject.org/g/yocto/message/60356 Mute This Topic: https://lists.yoctoproject.org/mt/99640197/21656 Group Owner: yocto+ow...@lists.yoctoproject.org Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-