usb: add all i2c number

Add all I2c number to change the permission

Bug: 297109635
Test: limit 1.3A work
Change-Id: I5ca8301da72ea848154f5382265ea06fa432fea2
This commit is contained in:
Chien Kun Niu 2023-08-24 15:45:35 +08:00
parent 9313c4edfd
commit 2d27d7b453
4 changed files with 149 additions and 44 deletions

View file

@ -35,10 +35,10 @@ namespace usb {
namespace gadget {
string enabledPath;
constexpr char kHsi2cPath[] = "/sys/devices/platform/10d50000.hsi2c";
constexpr char kI2CPath[] = "/sys/devices/platform/10d50000.hsi2c/i2c-";
constexpr char kAccessoryLimitCurrent[] = "i2c-max77759tcpc/usb_limit_accessory_current";
constexpr char kAccessoryLimitCurrentEnable[] = "i2c-max77759tcpc/usb_limit_accessory_enable";
constexpr char kHsi2cPath[] = "/sys/devices/platform/108d0000.hsi2c";
constexpr char kI2CPath[] = "/sys/devices/platform/108d0000.hsi2c/i2c-";
constexpr char kAccessoryLimitCurrent[] = "-0025/usb_limit_accessory_current";
constexpr char kAccessoryLimitCurrentEnable[] = "-0025/usb_limit_accessory_enable";
UsbGadget::UsbGadget() : mGadgetIrqPath("") {
if (access(OS_DESC_PATH, R_OK) != 0) {
@ -455,8 +455,8 @@ ScopedAStatus UsbGadget::setCurrentUsbFunctions(long functions,
mCurrentUsbFunctionsApplied = false;
getI2cBusHelper(&path);
accessoryCurrentLimitPath = kI2CPath + path + "/" + kAccessoryLimitCurrent;
accessoryCurrentLimitEnablePath = kI2CPath + path + "/" + kAccessoryLimitCurrentEnable;
accessoryCurrentLimitPath = kI2CPath + path + "/" + path + kAccessoryLimitCurrent;
accessoryCurrentLimitEnablePath = kI2CPath + path + "/" + path + kAccessoryLimitCurrentEnable;
// Get the gadget IRQ number before tearDownGadget()
if (mGadgetIrqPath.empty())