1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-17 13:10:29 +03:00

Merge pull request #292 from samueldr-wip/device/asus-dumo/usb-gadget

asus-dumo: Go go usb gadget mode
This commit is contained in:
Samuel Dionne-Riel 2021-01-30 23:18:39 -05:00 committed by GitHub
commit 8d76ca2ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 368 additions and 651 deletions

View File

@ -37,50 +37,29 @@
config.mobile.device.firmware
];
# The controller is hidden from the OS unless started using the "android"
# launch option in the weird UEFI GUI chooser.
mobile.usb.mode = "gadgetfs";
# Commonly re-used values, Nexus 4 (debug)
# (These identifiers have well-known default udev rules.)
mobile.usb.idVendor = "18d1";
mobile.usb.idProduct = "d002";
# Mainline gadgetfs functions
mobile.usb.gadgetfs.functions = {
rndis = "rndis.usb0";
mass_storage = "mass_storage.0";
adb = "ffs.adb";
};
mobile.boot.stage-1.bootConfig = {
# Used by target-disk-mode to share the internal drive
storage.internal = "/dev/disk/by-path/platform-fe330000.sdhci";
};
mobile.boot.stage-1.tasks = [
# This hack unbinds and rebinds the currently problematic storage driver.
# TODO: move into a generic "gru family" thing.
(pkgs.writeText "fixup-sdhci-arasan.rb" ''
class Tasks::FixupSDHCIArasan < SingletonTask
MAX = 60;
NAME = "fe330000.sdhci"
DRIVER = "/sys/bus/platform/drivers/sdhci-arasan"
GLOB = "#{DRIVER}/#{NAME}/mmc_host/mmc*/mmc*/block"
def initialize()
add_dependency(:Mount, "/sys")
add_dependency(:Files, DRIVER)
#add_dependency(:Target, :Environment)
end
def run()
tries = 0
$stdout.print " -> Waiting for #{NAME}"
$stdout.flush
until Dir.glob(GLOB).length > 0 do
$stdout.print "."
$stdout.flush
tries += 1
begin
System.write(File.join(DRIVER, "unbind"), NAME)
rescue => e
$logger.fatal(e.inspect)
end
begin
System.write(File.join(DRIVER, "bind"), NAME)
rescue => e
$logger.fatal(e.inspect)
end
sleep(1)
raise "Couldn't get #{NAME} up in #{tries} tries." if tries > MAX
end
$stdout.puts "!\n"
log("Took #{tries} tries for #{NAME} to appear...")
end
end
'')
./fixup_sdhci_arasan_task.rb
./usb_role_switch_task.rb
];
}

View File

@ -0,0 +1,41 @@
# This hack unbinds and rebinds the currently problematic storage driver.
class Tasks::FixupSDHCIArasan < SingletonTask
MAX = 60;
NAME = "fe330000.sdhci"
DRIVER = "/sys/bus/platform/drivers/sdhci-arasan"
GLOB = "#{DRIVER}/#{NAME}/mmc_host/mmc*/mmc*/block"
def initialize()
add_dependency(:Mount, "/sys")
add_dependency(:Files, DRIVER)
#add_dependency(:Target, :Environment)
end
def run()
tries = 0
$stdout.print " -> Waiting for #{NAME}"
$stdout.flush
until Dir.glob(GLOB).length > 0 do
$stdout.print "."
$stdout.flush
tries += 1
begin
System.write(File.join(DRIVER, "unbind"), NAME)
rescue => e
$logger.fatal(e.inspect)
end
begin
System.write(File.join(DRIVER, "bind"), NAME)
rescue => e
$logger.fatal(e.inspect)
end
sleep(1)
raise "Couldn't get #{NAME} up in #{tries} tries." if tries > MAX
end
$stdout.puts "!\n"
log("Took #{tries} tries for #{NAME} to appear...")
end
end

View File

@ -1,512 +0,0 @@
From 6f83e6c55989efae059e264f5a6f6a075b88b7a7 Mon Sep 17 00:00:00 2001
From: Samuel Dionne-Riel <samuel@dionne-riel.com>
Date: Tue, 11 Aug 2020 22:47:08 -0400
Subject: [PATCH] [HACK] haphazard revert of sbs-battery improvements
Reverts part of the following:
- https://lore.kernel.org/patchwork/cover/1241662/
---
drivers/power/supply/sbs-battery.c | 232 ++++-------------------------
1 file changed, 29 insertions(+), 203 deletions(-)
diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 83b9924033bd..6acd242eed48 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -14,7 +14,7 @@
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/property.h>
+#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/power/sbs-battery.h>
#include <linux/power_supply.h>
@@ -23,12 +23,9 @@
enum {
REG_MANUFACTURER_DATA,
- REG_BATTERY_MODE,
REG_TEMPERATURE,
REG_VOLTAGE,
- REG_CURRENT_NOW,
- REG_CURRENT_AVG,
- REG_MAX_ERR,
+ REG_CURRENT,
REG_CAPACITY,
REG_TIME_TO_EMPTY,
REG_TIME_TO_FULL,
@@ -44,15 +41,10 @@ enum {
REG_DESIGN_CAPACITY_CHARGE,
REG_DESIGN_VOLTAGE_MIN,
REG_DESIGN_VOLTAGE_MAX,
- REG_CHEMISTRY,
REG_MANUFACTURER,
REG_MODEL_NAME,
- REG_CHARGE_CURRENT,
- REG_CHARGE_VOLTAGE,
};
-#define REG_ADDR_MANUFACTURE_DATE 0x1B
-
/* Battery Mode defines */
#define BATTERY_MODE_OFFSET 0x03
#define BATTERY_MODE_CAPACITY_MASK BIT(15)
@@ -60,7 +52,6 @@ enum sbs_capacity_mode {
CAPACITY_MODE_AMPS = 0,
CAPACITY_MODE_WATTS = BATTERY_MODE_CAPACITY_MASK
};
-#define BATTERY_MODE_CHARGER_MASK (1<<14)
/* manufacturer access defines */
#define MANUFACTURER_ACCESS_STATUS 0x0006
@@ -88,18 +79,12 @@ static const struct chip_data {
} sbs_data[] = {
[REG_MANUFACTURER_DATA] =
SBS_DATA(POWER_SUPPLY_PROP_PRESENT, 0x00, 0, 65535),
- [REG_BATTERY_MODE] =
- SBS_DATA(-1, 0x03, 0, 65535),
[REG_TEMPERATURE] =
SBS_DATA(POWER_SUPPLY_PROP_TEMP, 0x08, 0, 65535),
[REG_VOLTAGE] =
SBS_DATA(POWER_SUPPLY_PROP_VOLTAGE_NOW, 0x09, 0, 20000),
- [REG_CURRENT_NOW] =
+ [REG_CURRENT] =
SBS_DATA(POWER_SUPPLY_PROP_CURRENT_NOW, 0x0A, -32768, 32767),
- [REG_CURRENT_AVG] =
- SBS_DATA(POWER_SUPPLY_PROP_CURRENT_AVG, 0x0B, -32768, 32767),
- [REG_MAX_ERR] =
- SBS_DATA(POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN, 0x0c, 0, 100),
[REG_CAPACITY] =
SBS_DATA(POWER_SUPPLY_PROP_CAPACITY, 0x0D, 0, 100),
[REG_REMAINING_CAPACITY] =
@@ -114,10 +99,6 @@ static const struct chip_data {
SBS_DATA(POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG, 0x12, 0, 65535),
[REG_TIME_TO_FULL] =
SBS_DATA(POWER_SUPPLY_PROP_TIME_TO_FULL_AVG, 0x13, 0, 65535),
- [REG_CHARGE_CURRENT] =
- SBS_DATA(POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, 0x14, 0, 65535),
- [REG_CHARGE_VOLTAGE] =
- SBS_DATA(POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, 0x15, 0, 65535),
[REG_STATUS] =
SBS_DATA(POWER_SUPPLY_PROP_STATUS, 0x16, 0, 65535),
[REG_CAPACITY_LEVEL] =
@@ -138,12 +119,10 @@ static const struct chip_data {
[REG_MANUFACTURER] =
SBS_DATA(POWER_SUPPLY_PROP_MANUFACTURER, 0x20, 0, 65535),
[REG_MODEL_NAME] =
- SBS_DATA(POWER_SUPPLY_PROP_MODEL_NAME, 0x21, 0, 65535),
- [REG_CHEMISTRY] =
- SBS_DATA(POWER_SUPPLY_PROP_TECHNOLOGY, 0x22, 0, 65535)
+ SBS_DATA(POWER_SUPPLY_PROP_MODEL_NAME, 0x21, 0, 65535)
};
-static const enum power_supply_property sbs_properties[] = {
+static enum power_supply_property sbs_properties[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
POWER_SUPPLY_PROP_HEALTH,
@@ -152,9 +131,7 @@ static const enum power_supply_property sbs_properties[] = {
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_CURRENT_NOW,
- POWER_SUPPLY_PROP_CURRENT_AVG,
POWER_SUPPLY_PROP_CAPACITY,
- POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN,
POWER_SUPPLY_PROP_TEMP,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
@@ -167,18 +144,13 @@ static const enum power_supply_property sbs_properties[] = {
POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_CHARGE_FULL,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
- POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
- POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
- POWER_SUPPLY_PROP_MANUFACTURE_YEAR,
- POWER_SUPPLY_PROP_MANUFACTURE_MONTH,
- POWER_SUPPLY_PROP_MANUFACTURE_DAY,
/* Properties of type `const char *' */
POWER_SUPPLY_PROP_MANUFACTURER,
POWER_SUPPLY_PROP_MODEL_NAME
};
-/* Supports special manufacturer commands from TI BQ20Z65 and BQ20Z75 IC. */
-#define SBS_FLAGS_TI_BQ20ZX5 BIT(0)
+/* Supports special manufacturer commands from TI BQ20Z75 IC. */
+#define SBS_FLAGS_TI_BQ20Z75 BIT(0)
struct sbs_info {
struct i2c_client *client;
@@ -186,7 +158,6 @@ struct sbs_info {
bool is_present;
struct gpio_desc *gpio_detect;
bool enable_detection;
- bool charger_broadcasts;
int last_state;
int poll_time;
u32 i2c_retry_count;
@@ -198,48 +169,8 @@ struct sbs_info {
static char model_name[I2C_SMBUS_BLOCK_MAX + 1];
static char manufacturer[I2C_SMBUS_BLOCK_MAX + 1];
-static char chemistry[I2C_SMBUS_BLOCK_MAX + 1];
static bool force_load;
-static int sbs_read_word_data(struct i2c_client *client, u8 address);
-static int sbs_write_word_data(struct i2c_client *client, u8 address, u16 value);
-
-static void sbs_disable_charger_broadcasts(struct sbs_info *chip)
-{
- int val = sbs_read_word_data(chip->client, BATTERY_MODE_OFFSET);
- if (val < 0)
- goto exit;
-
- val |= BATTERY_MODE_CHARGER_MASK;
-
- val = sbs_write_word_data(chip->client, BATTERY_MODE_OFFSET, val);
-
-exit:
- if (val < 0)
- dev_err(&chip->client->dev,
- "Failed to disable charger broadcasting: %d\n", val);
- else
- dev_dbg(&chip->client->dev, "%s\n", __func__);
-}
-
-static int sbs_update_presence(struct sbs_info *chip, bool is_present)
-{
- if (chip->is_present == is_present)
- return 0;
-
- if (!is_present) {
- chip->is_present = false;
- return 0;
- }
-
- if (!chip->is_present && is_present && !chip->charger_broadcasts)
- sbs_disable_charger_broadcasts(chip);
-
- chip->is_present = true;
-
- return 0;
-}
-
static int sbs_read_word_data(struct i2c_client *client, u8 address)
{
struct sbs_info *chip = i2c_get_clientdata(client);
@@ -357,15 +288,15 @@ static int sbs_status_correct(struct i2c_client *client, int *intval)
{
int ret;
- ret = sbs_read_word_data(client, sbs_data[REG_CURRENT_NOW].addr);
+ ret = sbs_read_word_data(client, sbs_data[REG_CURRENT].addr);
if (ret < 0)
return ret;
ret = (s16)ret;
- /* Not drawing current -> not charging (i.e. idle) */
- if (*intval != POWER_SUPPLY_STATUS_FULL && ret == 0)
- *intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
+ /* Not drawing current means full (cannot be not charging) */
+ if (ret == 0)
+ *intval = POWER_SUPPLY_STATUS_FULL;
if (*intval == POWER_SUPPLY_STATUS_FULL) {
/* Drawing or providing current when full */
@@ -378,17 +309,6 @@ static int sbs_status_correct(struct i2c_client *client, int *intval)
return 0;
}
-static bool sbs_bat_needs_calibration(struct i2c_client *client)
-{
- int ret;
-
- ret = sbs_read_word_data(client, sbs_data[REG_BATTERY_MODE].addr);
- if (ret < 0)
- return false;
-
- return !!(ret & BIT(7));
-}
-
static int sbs_get_battery_presence_and_health(
struct i2c_client *client, enum power_supply_property psp,
union power_supply_propval *val)
@@ -408,14 +328,9 @@ static int sbs_get_battery_presence_and_health(
if (psp == POWER_SUPPLY_PROP_PRESENT)
val->intval = 1; /* battery present */
- else { /* POWER_SUPPLY_PROP_HEALTH */
- if (sbs_bat_needs_calibration(client)) {
- val->intval = POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED;
- } else {
- /* SBS spec doesn't have a general health command. */
- val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
- }
- }
+ else /* POWER_SUPPLY_PROP_HEALTH */
+ /* SBS spec doesn't have a general health command. */
+ val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
return 0;
}
@@ -469,8 +384,6 @@ static int sbs_get_ti_battery_presence_and_health(
val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
else if (ret == 0x0C)
val->intval = POWER_SUPPLY_HEALTH_DEAD;
- else if (sbs_bat_needs_calibration(client))
- val->intval = POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED;
else
val->intval = POWER_SUPPLY_HEALTH_GOOD;
}
@@ -579,10 +492,7 @@ static void sbs_unit_adjustment(struct i2c_client *client,
case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
case POWER_SUPPLY_PROP_CURRENT_NOW:
- case POWER_SUPPLY_PROP_CURRENT_AVG:
case POWER_SUPPLY_PROP_CHARGE_NOW:
- case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
- case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
case POWER_SUPPLY_PROP_CHARGE_FULL:
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
val->intval *= BASE_UNIT_CONVERSION;
@@ -692,70 +602,6 @@ static int sbs_get_property_index(struct i2c_client *client,
return -EINVAL;
}
-static int sbs_get_chemistry(struct i2c_client *client,
- union power_supply_propval *val)
-{
- enum power_supply_property psp = POWER_SUPPLY_PROP_TECHNOLOGY;
- int ret;
-
- ret = sbs_get_property_index(client, psp);
- if (ret < 0)
- return ret;
-
- ret = sbs_get_battery_string_property(client, ret, psp,
- chemistry);
- if (ret < 0)
- return ret;
-
- if (!strncasecmp(chemistry, "LION", 4))
- val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
- else if (!strncasecmp(chemistry, "LiP", 3))
- val->intval = POWER_SUPPLY_TECHNOLOGY_LIPO;
- else if (!strncasecmp(chemistry, "NiCd", 4))
- val->intval = POWER_SUPPLY_TECHNOLOGY_NiCd;
- else if (!strncasecmp(chemistry, "NiMH", 4))
- val->intval = POWER_SUPPLY_TECHNOLOGY_NiMH;
- else
- val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
-
- if (val->intval == POWER_SUPPLY_TECHNOLOGY_UNKNOWN)
- dev_warn(&client->dev, "Unknown chemistry: %s\n", chemistry);
-
- return 0;
-}
-
-static int sbs_get_battery_manufacture_date(struct i2c_client *client,
- enum power_supply_property psp,
- union power_supply_propval *val)
-{
- int ret;
- u16 day, month, year;
-
- ret = sbs_read_word_data(client, REG_ADDR_MANUFACTURE_DATE);
- if (ret < 0)
- return ret;
-
- day = ret & GENMASK(4, 0);
- month = (ret & GENMASK(8, 5)) >> 5;
- year = ((ret & GENMASK(15, 9)) >> 9) + 1980;
-
- switch (psp) {
- case POWER_SUPPLY_PROP_MANUFACTURE_YEAR:
- val->intval = year;
- break;
- case POWER_SUPPLY_PROP_MANUFACTURE_MONTH:
- val->intval = month;
- break;
- case POWER_SUPPLY_PROP_MANUFACTURE_DAY:
- val->intval = day;
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
static int sbs_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
@@ -770,7 +616,7 @@ static int sbs_get_property(struct power_supply *psy,
return ret;
if (psp == POWER_SUPPLY_PROP_PRESENT) {
val->intval = ret;
- sbs_update_presence(chip, ret);
+ chip->is_present = val->intval;
return 0;
}
if (ret == 0)
@@ -780,7 +626,7 @@ static int sbs_get_property(struct power_supply *psy,
switch (psp) {
case POWER_SUPPLY_PROP_PRESENT:
case POWER_SUPPLY_PROP_HEALTH:
- if (chip->flags & SBS_FLAGS_TI_BQ20ZX5)
+ if (chip->flags & SBS_FLAGS_TI_BQ20Z75)
ret = sbs_get_ti_battery_presence_and_health(client,
psp, val);
else
@@ -793,10 +639,7 @@ static int sbs_get_property(struct power_supply *psy,
break;
case POWER_SUPPLY_PROP_TECHNOLOGY:
- ret = sbs_get_chemistry(client, val);
- if (ret < 0)
- break;
-
+ val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
goto done; /* don't trigger power_supply_changed()! */
case POWER_SUPPLY_PROP_ENERGY_NOW:
@@ -827,16 +670,12 @@ static int sbs_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_CYCLE_COUNT:
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
case POWER_SUPPLY_PROP_CURRENT_NOW:
- case POWER_SUPPLY_PROP_CURRENT_AVG:
case POWER_SUPPLY_PROP_TEMP:
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
- case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
- case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
case POWER_SUPPLY_PROP_CAPACITY:
- case POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN:
ret = sbs_get_property_index(client, psp);
if (ret < 0)
break;
@@ -864,12 +703,6 @@ static int sbs_get_property(struct power_supply *psy,
val->strval = manufacturer;
break;
- case POWER_SUPPLY_PROP_MANUFACTURE_YEAR:
- case POWER_SUPPLY_PROP_MANUFACTURE_MONTH:
- case POWER_SUPPLY_PROP_MANUFACTURE_DAY:
- ret = sbs_get_battery_manufacture_date(client, psp, val);
- break;
-
default:
dev_err(&client->dev,
"%s: INVALID property\n", __func__);
@@ -881,7 +714,7 @@ static int sbs_get_property(struct power_supply *psy,
if (!chip->gpio_detect &&
chip->is_present != (ret >= 0)) {
- sbs_update_presence(chip, (ret >= 0));
+ chip->is_present = (ret >= 0);
power_supply_changed(chip->power_supply);
}
@@ -912,7 +745,7 @@ static void sbs_supply_changed(struct sbs_info *chip)
ret = gpiod_get_value_cansleep(chip->gpio_detect);
if (ret < 0)
return;
- sbs_update_presence(chip, ret);
+ chip->is_present = ret;
power_supply_changed(battery);
}
@@ -982,7 +815,8 @@ static const struct power_supply_desc sbs_default_desc = {
.external_power_changed = sbs_external_power_changed,
};
-static int sbs_probe(struct i2c_client *client)
+static int sbs_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
{
struct sbs_info *chip;
struct power_supply_desc *sbs_desc;
@@ -1005,7 +839,7 @@ static int sbs_probe(struct i2c_client *client)
if (!chip)
return -ENOMEM;
- chip->flags = (u32)(uintptr_t)device_get_match_data(&client->dev);
+ chip->flags = (u32)(uintptr_t)of_device_get_match_data(&client->dev);
chip->client = client;
chip->enable_detection = false;
psy_cfg.of_node = client->dev.of_node;
@@ -1016,13 +850,13 @@ static int sbs_probe(struct i2c_client *client)
/* use pdata if available, fall back to DT properties,
* or hardcoded defaults if not
*/
- rc = device_property_read_u32(&client->dev, "sbs,i2c-retry-count",
- &chip->i2c_retry_count);
+ rc = of_property_read_u32(client->dev.of_node, "sbs,i2c-retry-count",
+ &chip->i2c_retry_count);
if (rc)
chip->i2c_retry_count = 0;
- rc = device_property_read_u32(&client->dev, "sbs,poll-retry-count",
- &chip->poll_retry_count);
+ rc = of_property_read_u32(client->dev.of_node, "sbs,poll-retry-count",
+ &chip->poll_retry_count);
if (rc)
chip->poll_retry_count = 0;
@@ -1032,9 +866,6 @@ static int sbs_probe(struct i2c_client *client)
}
chip->i2c_retry_count = chip->i2c_retry_count + 1;
- chip->charger_broadcasts = !device_property_read_bool(&client->dev,
- "sbs,disable-charger-broadcasts");
-
chip->gpio_detect = devm_gpiod_get_optional(&client->dev,
"sbs,battery-detect", GPIOD_IN);
if (IS_ERR(chip->gpio_detect)) {
@@ -1119,7 +950,7 @@ static int sbs_suspend(struct device *dev)
if (chip->poll_time > 0)
cancel_delayed_work_sync(&chip->work);
- if (chip->flags & SBS_FLAGS_TI_BQ20ZX5) {
+ if (chip->flags & SBS_FLAGS_TI_BQ20Z75) {
/* Write to manufacturer access with sleep command. */
ret = sbs_write_word_data(client,
sbs_data[REG_MANUFACTURER_DATA].addr,
@@ -1139,7 +970,6 @@ static SIMPLE_DEV_PM_OPS(sbs_pm_ops, sbs_suspend, NULL);
#endif
static const struct i2c_device_id sbs_id[] = {
- { "bq20z65", 0 },
{ "bq20z75", 0 },
{ "sbs-battery", 1 },
{}
@@ -1148,20 +978,16 @@ MODULE_DEVICE_TABLE(i2c, sbs_id);
static const struct of_device_id sbs_dt_ids[] = {
{ .compatible = "sbs,sbs-battery" },
- {
- .compatible = "ti,bq20z65",
- .data = (void *)SBS_FLAGS_TI_BQ20ZX5,
- },
{
.compatible = "ti,bq20z75",
- .data = (void *)SBS_FLAGS_TI_BQ20ZX5,
+ .data = (void *)SBS_FLAGS_TI_BQ20Z75,
},
{ }
};
MODULE_DEVICE_TABLE(of, sbs_dt_ids);
static struct i2c_driver sbs_battery_driver = {
- .probe_new = sbs_probe,
+ .probe = sbs_probe,
.remove = sbs_remove,
.alert = sbs_alert,
.id_table = sbs_id,
--
2.25.4

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,41 @@
{
mobile-nixos
, fetchFromGitHub
, fetchgit
, fetchpatch
}:
let
sdrPatch = rev: sha256: fetchpatch {
url = "https://github.com/samueldr/linux/commit/${rev}.patch";
inherit sha256;
};
in
mobile-nixos.kernel-builder {
version = "5.8.0";
version = "5.10.0";
configfile = ./config.aarch64;
src = fetchFromGitHub {
owner = "torvalds";
repo = "linux";
rev = "v5.8";
sha256 = "1jffq83jzcvkvpf6afhwkaj0zlb293vlndp1r66xzx41mbnnra0x";
rev = "v5.10";
sha256 = "1znxp4v7ykfz4fghzjzhd5mj9pj5qpk88n7k7nbkr5x2n0xqfj6k";
};
patches = [
./0001-gru-Force-hs200-for-eMMC.patch
# Work around Regression from https://lore.kernel.org/patchwork/project/lkml/list/?series=443749
./0001-HACK-haphazard-revert-of-sbs-battery-improvements.patch
# usb: dwc3: Enable userspace role switch control
(sdrPatch "03aedba687e2aacb258aa0f92876c48f5bde30e7" "09701lbb06daix9cs22yf0nm8wvb7cmybh19s2lbr0b5fn9s73fh")
# phy: rockchip-inno-usb2: rockchip: Update phy_sus
(sdrPatch "31585eed614a526324dec66f690fad3fc52dd419" "0hxmrf9y2rrv9nisy2f5cgikkz6fsi1m42fwl36g22x8z393gyjb")
# WIP: usb: dwc3: Force output B_sessionvalid asserted
# (While WIP, it is because it is extremely gru-centric...)
(sdrPatch "9dc445c2e4370be3eb19ee49fd0f4319d91e8631" "1fc7dr5fybnxpfnmdil91d891qvqycpad6anrix7cbzjvflifas6")
# arm64: dts: rockchip: Set type-c port to OTG and enable role switch for gru-scarlet
(sdrPatch "cbe4e04bf85d8d37058f89853a8ac0ad518a3e42" "139a9pkaya41nkar3mbcvfvg3xnxr3cr9ja9b320r2cn4qnrbjjc")
];
isModular = false;

View File

@ -0,0 +1,10 @@
class Tasks::UsbRoleSwitchTask < SingletonTask
def initialize()
Tasks::SetupGadgetMode.instance.add_dependency(:Task, self)
add_dependency(:Mount, "/sys")
end
def run()
System.write("/sys/class/usb_role/fe800000.usb-role-switch/role", "device")
end
end

View File

@ -24,6 +24,9 @@ class Tasks::RunGui < SingletonTask
end
def run()
# Free up the framebuffer / DRM context
Progress.kill()
System.run(LOADER, "/applets/tdm-gui.mrb")
# This `raise` shouldn't really happen as `System#run` will raise