driver/power: add charge protocol get

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2022-07-21 14:48:29 +00:00 committed by Petro Karashchenko
parent fc35cf4737
commit 4ef7cf068b
3 changed files with 24 additions and 1 deletions

View File

@ -388,6 +388,16 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd,
}
break;
case BATIOC_GET_PROTOCOL:
{
FAR int *ptr = (FAR int *)(uintptr_t)arg;
if (ptr)
{
ret = dev->ops->get_protocol(dev, ptr);
}
}
break;
default:
_err("ERROR: Unrecognized cmd: %d\n", cmd);
ret = -ENOTTY;

View File

@ -125,7 +125,11 @@ struct battery_charger_operations_s
/* Get the actual output voltage for charging */
int (*get_voltage)(struct battery_charger_dev_s *dev, int *value);
int (*get_voltage)(struct battery_charger_dev_s *dev, FAR int *value);
/* Get charge protocol */
int (*get_protocol)(struct battery_charger_dev_s *dev, FAR int *value);
};
/* This structure defines the battery driver state structure */

View File

@ -56,6 +56,7 @@
#define BATIOC_COULOMBS _BATIOC(0x0010)
#define BATIOC_CHIPID _BATIOC(0x0011)
#define BATIOC_GET_VOLTAGE _BATIOC(0x0012)
#define BATIOC_GET_PROTOCOL _BATIOC(0x0013)
/* Special input values for BATIOC_INPUT_CURRENT that may optionally
* be supported by lower-half driver:
@ -110,6 +111,14 @@ enum battery_health_e
BATTERY_HEALTH_DISCONNECTED /* Battery is not connected */
};
/* battery charge protocol type */
enum battery_protocol_e
{
BATTERY_PROTOCOL_QC3P0 = 1 << 0, /* Battery charge protocol of adapter is QC 3.0 */
BATTERY_PROTOCOL_TX_XIAOMI = 1 << 1, /* Battery charge protocol of TX is xiaomi standard */
};
/* Battery operation message */
struct batio_operate_msg_s