1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-14 09:16:39 +03:00

asus-z00t: Configure green LED to turn on by default

This is done at the device tree / kernel level.
This commit is contained in:
Samuel Dionne-Riel 2020-04-10 15:54:58 -04:00
parent fc07219c7d
commit 640f2d4c79
3 changed files with 301 additions and 0 deletions

View File

@ -0,0 +1,266 @@
From 229a044117402e0c9cf3137d2e24da44d76f114a Mon Sep 17 00:00:00 2001
From: Samuel Dionne-Riel <samuel@dionne-riel.com>
Date: Fri, 10 Apr 2020 15:48:46 -0400
Subject: [PATCH 1/2] leds-qpnp: Cleanup and shut up
Cleanup includes:
* Getting rid of useless globals
* Getting rid of a useless exported symbol
* Removing the hardcoded shutdown of leds
With this, the defaults as described in the device tree file will work
as expected.
---
drivers/leds/leds-qpnp.c | 101 ++++++++++++++-------------------------
1 file changed, 35 insertions(+), 66 deletions(-)
diff --git a/drivers/leds/leds-qpnp.c b/drivers/leds/leds-qpnp.c
index 06755f879ac95..093c637dead8f 100644
--- a/drivers/leds/leds-qpnp.c
+++ b/drivers/leds/leds-qpnp.c
@@ -564,22 +564,6 @@ static DEFINE_MUTEX(flash_lock);
static DEFINE_MUTEX(mutex_pwm);
static DEFINE_MUTEX(mutex_led);
-//ASUS_BSP Austin_T : add LED globe variable +++
-static struct qpnp_led_data *red_led;
-static struct qpnp_led_data *green_led;
-//ASUS_BSP Austin_T : add LED globe variable ---
-
-extern int asus_PRJ_ID;
-void led_clean(void)
-{
- printk("[LED] led_clean\n");
- red_led->cdev.brightness = 0;
- schedule_work(&red_led->work);
- green_led->cdev.brightness = 0;
- schedule_work(&green_led->work);
-}
-EXPORT_SYMBOL(led_clean);
-
static struct pwm_device *kpdbl_master;
static u32 kpdbl_master_period_us;
DECLARE_BITMAP(kpdbl_leds_in_use, NUM_KPDBL_LEDS);
@@ -620,8 +604,6 @@ static void qpnp_dump_regs(struct qpnp_led_data *led, u8 regs[], u8 array_size)
led->spmi_dev->sid,
led->base + regs[i],
&val, sizeof(val));
- //printk("%s: 0x%x = 0x%x\n", led->cdev.name,
- // led->base + regs[i], val);
}
pr_debug("===== %s LED register dump end =====\n", led->cdev.name);
}
@@ -640,8 +622,6 @@ static void qpnp_dump_regs1(struct qpnp_led_data *led, u8 regs[], u8 array_size)
&val, sizeof(val));
pr_debug("%s: 0x%x = 0x%x\n", led->cdev.name,
led->base1 + regs[i], val);
- //printk("%s: 0x%x = 0x%x\n", led->cdev.name,
- // led->base1 + regs[i], val);
}
pr_debug("===== %s LED register dump end =====\n", led->cdev.name);
}
@@ -910,7 +890,7 @@ static int qpnp_mpp_set(struct qpnp_led_data *led)
u8 val;
int duty_us, duty_ns, period_us;
- printk("[LED] qpnp_mpp_set +++ %s\n", led->cdev.name);
+ pr_debug("[LED] qpnp_mpp_set +++ %s\n", led->cdev.name);
if (led->cdev.brightness) {
if (led->mpp_cfg->mpp_reg && !led->mpp_cfg->enable) {
@@ -922,9 +902,9 @@ static int qpnp_mpp_set(struct qpnp_led_data *led)
"Regulator voltage set failed rc=%d\n",
rc);
mutex_unlock(&mutex_pwm);
- printk("[LED] mutexpwm_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexpwm_unlock %s\n", led->cdev.name);
mutex_unlock(&mutex_led);
- printk("[LED] mutexled_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexled_unlock %s\n", led->cdev.name);
return rc;
}
@@ -1061,9 +1041,9 @@ static int qpnp_mpp_set(struct qpnp_led_data *led)
"MPP regulator disable failed(%d)\n",
rc);
mutex_unlock(&mutex_pwm);
- printk("[LED] mutexpwm_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexpwm_unlock %s\n", led->cdev.name);
mutex_unlock(&mutex_led);
- printk("[LED] mutexled_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexled_unlock %s\n", led->cdev.name);
return rc;
}
@@ -1074,9 +1054,9 @@ static int qpnp_mpp_set(struct qpnp_led_data *led)
"MPP regulator voltage set failed(%d)\n",
rc);
mutex_unlock(&mutex_pwm);
- printk("[LED] mutexpwm_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexpwm_unlock %s\n", led->cdev.name);
mutex_unlock(&mutex_led);
- printk("[LED] mutexled_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexled_unlock %s\n", led->cdev.name);
return rc;
}
}
@@ -1090,9 +1070,9 @@ static int qpnp_mpp_set(struct qpnp_led_data *led)
qpnp_dump_regs1(led, mpp_debug_regs1, ARRAY_SIZE(mpp_debug_regs1));
mutex_unlock(&mutex_pwm);
- printk("[LED] mutexpwm_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexpwm_unlock %s\n", led->cdev.name);
mutex_unlock(&mutex_led);
- printk("[LED] mutexled_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexled_unlock %s\n", led->cdev.name);
return 0;
err_mpp_reg_write:
@@ -1105,9 +1085,9 @@ err_reg_enable:
led->mpp_cfg->enable = false;
mutex_unlock(&mutex_pwm);
- printk("[LED] mutexpwm_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexpwm_unlock %s\n", led->cdev.name);
mutex_unlock(&mutex_led);
- printk("[LED] mutexled_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexled_unlock %s\n", led->cdev.name);
return rc;
}
@@ -1869,17 +1849,17 @@ static void qpnp_led_set(struct led_classdev *led_cdev,
struct qpnp_led_data *led;
mutex_lock(&mutex_led);
- printk("[LED] mutexled_lock %s\n", led_cdev->name);
- printk("[LED] qpnp_led_set %d +++ %s\n", value, led_cdev->name); //aa
+ pr_debug("[LED] mutexled_lock %s\n", led_cdev->name);
+ pr_debug("[LED] qpnp_led_set %d +++ %s\n", value, led_cdev->name); //aa
led = container_of(led_cdev, struct qpnp_led_data, cdev);
if (value < LED_OFF) {
dev_err(&led->spmi_dev->dev, "Invalid brightness value\n");
mutex_unlock(&mutex_pwm);
- printk("[LED] mutexpwm_unlock %s\n", led_cdev->name);
+ pr_debug("[LED] mutexpwm_unlock %s\n", led_cdev->name);
mutex_unlock(&mutex_led);
- printk("[LED] mutexled_unlock %s\n", led_cdev->name);
+ pr_debug("[LED] mutexled_unlock %s\n", led_cdev->name);
return;
}
@@ -2297,7 +2277,7 @@ static ssize_t pwm_us_store(struct device *dev,
return ret;
mutex_lock(&mutex_pwm);
- printk("[LED] mutexpwm_lock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexpwm_lock %s\n", led->cdev.name);
switch (led->id) {
case QPNP_ID_LED_MPP:
@@ -2333,7 +2313,7 @@ static ssize_t pwm_us_store(struct device *dev,
dev_err(&led->spmi_dev->dev,
"Failed to initialize pwm with new pwm_us value\n");
mutex_unlock(&mutex_pwm);
- printk("[LED] mutexpwm_unlock %s\n", led->cdev.name);
+ pr_debug("[LED] mutexpwm_unlock %s\n", led->cdev.name);
return ret;
}
qpnp_led_set(&led->cdev, led->cdev.brightness);
@@ -3657,17 +3637,21 @@ bad_lpg_params:
static int qpnp_led_get_mode(const char *mode)
{
- if (strncmp(mode, "manual", strlen(mode)) == 0)
- {printk("[LED] qpnp_led_get_mode_manual\n");
- return MANUAL_MODE;}
- else if (strncmp(mode, "pwm", strlen(mode)) == 0)
- {printk("[LED] qpnp_led_get_mode_pwm\n");
- return PWM_MODE;}
- else if (strncmp(mode, "lpg", strlen(mode)) == 0)
- {printk("[LED] qpnp_led_get_mode_lpg\n");
- return LPG_MODE;}
- else
+ if (strncmp(mode, "manual", strlen(mode)) == 0) {
+ pr_debug("[LED] qpnp_led_get_mode_manual\n");
+ return MANUAL_MODE;
+ }
+ else if (strncmp(mode, "pwm", strlen(mode)) == 0) {
+ pr_debug("[LED] qpnp_led_get_mode_pwm\n");
+ return PWM_MODE;
+ }
+ else if (strncmp(mode, "lpg", strlen(mode)) == 0) {
+ pr_debug("[LED] qpnp_led_get_mode_lpg\n");
+ return LPG_MODE;
+ }
+ else {
return -EINVAL;
+ }
};
static int qpnp_get_config_kpdbl(struct qpnp_led_data *led,
@@ -3787,7 +3771,7 @@ static int qpnp_get_config_mpp(struct qpnp_led_data *led,
u8 led_mode;
const char *mode;
- printk("[LED] qpnp_get_config_mpp\n");
+ pr_debug("[LED] qpnp_get_config_mpp\n");
led->mpp_cfg = devm_kzalloc(&led->spmi_dev->dev,
sizeof(struct mpp_config_data), GFP_KERNEL);
if (!led->mpp_cfg) {
@@ -3963,7 +3947,7 @@ static int qpnp_leds_probe(struct spmi_device *spmi)
const char *led_label;
bool regulator_probe = false;
- printk("[LED] qpnp_leds_probe\n");
+ pr_debug("[LED] qpnp_leds_probe\n");
node = spmi->dev.of_node;
if (node == NULL)
@@ -4002,7 +3986,7 @@ static int qpnp_leds_probe(struct spmi_device *spmi)
"Failure reading label, rc = %d\n", rc);
goto fail_id_check;
}
- printk("[LED] led_label : %s\n", led_label);
+ pr_debug("[LED] led_label : %s\n", led_label);
rc = of_property_read_string(temp, "linux,name",
&led->cdev.name);
@@ -4011,14 +3995,8 @@ static int qpnp_leds_probe(struct spmi_device *spmi)
"Failure reading led name, rc = %d\n", rc);
goto fail_id_check;
}
- printk("[LED] linux,name : %s\n", led->cdev.name);
+ pr_debug("[LED] linux,name : %s\n", led->cdev.name);
- if (!strcmp(led->cdev.name, "red")) {
- red_led = led;
- }
- else if (!strcmp(led->cdev.name, "green")) {
- green_led = led;
- }
rc = of_property_read_u32(temp, "qcom,max-current",
&led->max_current);
if (rc < 0) {
@@ -4232,16 +4210,7 @@ static int qpnp_leds_probe(struct spmi_device *spmi)
parsed_leds++;
}
dev_set_drvdata(&spmi->dev, led_array);
-
- rc = qpnp_led_masked_write(led,
- LED_MPP_EN_CTRL(led->base), LED_MPP_EN_MASK,
- LED_MPP_EN_DISABLE);
- if (rc)
- dev_err(&led->spmi_dev->dev,
- "Failed to write led enable " \
- "reg\n");
-
return 0;
fail_id_check:
--
2.23.1

View File

@ -0,0 +1,33 @@
From 74e0c9bad60d4d616d1949daf140c75eebdb6483 Mon Sep 17 00:00:00 2001
From: Samuel Dionne-Riel <samuel@dionne-riel.com>
Date: Fri, 10 Apr 2020 15:49:50 -0400
Subject: [PATCH 2/2] ze550kl: Green LED now defaults to on
This helps the user approximately know the moment the kernel is in
control of the hardware, compared to the bootloader.
Practically speaking, this is a sane default for Mobile NixOS and
non-android linux distros, as it shows the device is still on, as long
as there is no userspace LED management software changing the state.
---
arch/arm/boot/dts/qcom/msm8939-cdp-ze550kl.dtsi | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/qcom/msm8939-cdp-ze550kl.dtsi b/arch/arm/boot/dts/qcom/msm8939-cdp-ze550kl.dtsi
index 35e50b131dc12..c63b181d6daae 100644
--- a/arch/arm/boot/dts/qcom/msm8939-cdp-ze550kl.dtsi
+++ b/arch/arm/boot/dts/qcom/msm8939-cdp-ze550kl.dtsi
@@ -372,8 +372,8 @@
qcom,led_mpp_4 {
label = "mpp";
linux,name = "green";
- linux,default-trigger = "none";
- qcom,default-state = "off";
+ linux,default-trigger = "default-on";
+ qcom,default-state = "on";
qcom,max-current = <40>;
qcom,current-setting = <5>;
qcom,id = <6>;
--
2.23.1

View File

@ -31,6 +31,8 @@
./0001-gpio_keys-shut-up.patch
./0002-asus_battery-shut-up.patch
./0003-qpnp-bms-shut-up.patch
./0001-leds-qpnp-Cleanup-and-shut-up.patch
./0002-ze550kl-Green-LED-now-defaults-to-on.patch
./01_more_precise_arch.patch
./01_fix_gcc6_errors.patch
./02_mdss_fb_refresh_rate.patch