bdk: bm92t: do not parse non fixed pdos
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* USB-PD driver for Nintendo Switch's TI BM92T36
|
* USB-PD driver for Nintendo Switch's TI BM92T36
|
||||||
*
|
*
|
||||||
* Copyright (c) 2020-2025 CTCaer
|
* Copyright (c) 2020-2026 CTCaer
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
@@ -58,6 +58,11 @@
|
|||||||
#define MAX_ROHM 0x4B5
|
#define MAX_ROHM 0x4B5
|
||||||
#define DEV_BM92T 0x3B0
|
#define DEV_BM92T 0x3B0
|
||||||
|
|
||||||
|
#define PDO_TYPE_FIXED 0
|
||||||
|
#define PDO_TYPE_BATT 1
|
||||||
|
#define PDO_TYPE_VAR 2
|
||||||
|
#define PDO_TYPE_APDO 3
|
||||||
|
|
||||||
typedef struct _pd_object_t {
|
typedef struct _pd_object_t {
|
||||||
unsigned int amp:10;
|
unsigned int amp:10;
|
||||||
unsigned int volt:10;
|
unsigned int volt:10;
|
||||||
@@ -90,7 +95,7 @@ int bm92t36_get_version(u32 *value)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bm92t36_get_sink_info(bool *inserted, usb_pd_objects_t *usb_pd)
|
void bm92t36_get_source_info(bool *inserted, usb_pd_objects_t *usb_pd)
|
||||||
{
|
{
|
||||||
u8 buf[32];
|
u8 buf[32];
|
||||||
pd_object_t pdos[7];
|
pd_object_t pdos[7];
|
||||||
@@ -112,11 +117,18 @@ void bm92t36_get_sink_info(bool *inserted, usb_pd_objects_t *usb_pd)
|
|||||||
if (usb_pd->pdo_no > 7)
|
if (usb_pd->pdo_no > 7)
|
||||||
usb_pd->pdo_no = 7;
|
usb_pd->pdo_no = 7;
|
||||||
|
|
||||||
|
u32 idx = 0;
|
||||||
for (u32 i = 0; i < usb_pd->pdo_no; i++)
|
for (u32 i = 0; i < usb_pd->pdo_no; i++)
|
||||||
{
|
{
|
||||||
usb_pd->pdos[i].amperage = pdos[i].amp * 10;
|
// Parse fixed type pdos only.
|
||||||
usb_pd->pdos[i].voltage = (pdos[i].volt * 50) / 1000;
|
if (pdos[i].type != PDO_TYPE_FIXED)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
usb_pd->pdos[idx].amperage = pdos[i].amp * 10;
|
||||||
|
usb_pd->pdos[idx].voltage = (pdos[i].volt * 50) / 1000;
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
|
usb_pd->pdo_no = idx;
|
||||||
|
|
||||||
_bm92t36_read_reg(buf, 5, CURRENT_PDO_REG);
|
_bm92t36_read_reg(buf, 5, CURRENT_PDO_REG);
|
||||||
memcpy(pdos, &buf[1], 4);
|
memcpy(pdos, &buf[1], 4);
|
||||||
|
|||||||
@@ -37,6 +37,6 @@ typedef struct _usb_pd_objects_t
|
|||||||
} usb_pd_objects_t;
|
} usb_pd_objects_t;
|
||||||
|
|
||||||
int bm92t36_get_version(u32 *value);
|
int bm92t36_get_version(u32 *value);
|
||||||
void bm92t36_get_sink_info(bool *inserted, usb_pd_objects_t *usb_pd);
|
void bm92t36_get_source_info(bool *inserted, usb_pd_objects_t *usb_pd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user