Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2244179rdb; Fri, 8 Dec 2023 02:32:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXRPwMtZmwF6ZGpUuuUWctF12bF/dpYhend+YyeFxfatyjHfb8uLXCD9/DRvvHYwGhB89p X-Received: by 2002:a17:902:7c0d:b0:1d0:a35b:8cf0 with SMTP id x13-20020a1709027c0d00b001d0a35b8cf0mr3022815pll.132.1702031578245; Fri, 08 Dec 2023 02:32:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702031578; cv=none; d=google.com; s=arc-20160816; b=AMUyA4MFfFhspPVdDwg15W/8860UkTm5AMGjPyl6E7PxgSXqlroP5ICOyjo5Vjyj81 XvJlwtbF8QQ3Vv0k5qKrCkjHXGBAmH66N/flt3shKyCjebxg++U6fqBd/lgDzJw8ogKr qN9gx+DbisTFvZdI+IeiudNuNFJf0Fa8OStXQSbFnNZHCTJk7cZaXnrciBLgoHZcDwbO lkN2AcYF+YKKlcuFSytkQ7/acr6dnFAN6LuG0ylW1lS0C7kq8V5j50Ed/hsYKqNTcP+e 1qPW8sqKGNFAH8XHOaZPvzM9rk12OB+8M4G8wlggWmY47SRFVkNjKfdWDsVxlYDAd0TW p4gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:references :in-reply-to:subject:cc:to:from:date:mime-version:dkim-signature; bh=Y9w4Ouk1WhwgFjveXSyfvsVGBEIrLwrLDZ9cjpyU2Ww=; fh=w4ytFHC9hopmTi9LMYz9cXktoIdGOeo+G1GZj3Y5Wsk=; b=i8KiMsCK4hBGWgi/f8rcbbIqRyTxzXn0PePTuSp6XJ/0GBtD5HtQUaFbA8nYe3H1Uj m2qoqmqoi5ztntxMFYw2jD8h+ZDQ/mzui6jys77VKc8VDMgoJBs2aM4S8wHWM9YPJnBb DPNaWn5tlyl245s8UV8gGjNkEcIY2RXkWL+Lvsq2ThKqKq/49PN9FT4nlphRuD0feC4b 6XDo8ZsPQaCUM20vTcm0TiXP9PaM8EB3c7/nFlPCsYlWUzArvSZzXB1apjY+ZMQDgY7c 59Fn3pj7xiUrNpS/IcBpN4B1Pr6LDhWUX4mDHrjgc3TUzC8o9rsck8RU1RjW8aU25g+3 TDsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@trvn.ru header.s=mail header.b=RajIO39J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=trvn.ru Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l12-20020a170903244c00b001cf68d9d2b4si1380267pls.554.2023.12.08.02.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 02:32:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@trvn.ru header.s=mail header.b=RajIO39J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=trvn.ru Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CA10580966D4; Fri, 8 Dec 2023 02:32:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573747AbjLHKcU (ORCPT + 99 others); Fri, 8 Dec 2023 05:32:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235941AbjLHKbz (ORCPT ); Fri, 8 Dec 2023 05:31:55 -0500 Received: from box.trvn.ru (box.trvn.ru [194.87.146.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DE331BD8; Fri, 8 Dec 2023 02:31:32 -0800 (PST) Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id 68CCB40553; Fri, 8 Dec 2023 15:31:28 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1702031488; bh=4y6IzqXuYCaOZRj832BYim9z7oqNFMfqjRtC49eFuJM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RajIO39JCopnXz/UHAH8GGunqq6K8NXh+7Gh0Dt2D6EgmpAC+4kKE5u/kc+Y9iixy 3T5ijAlEqz4za3cgDx7IBwfTV5qtghTKX4ohClLUiDAb1v7P+yXl5B7Q7p626uIS5x dyqDln9a+E4mUV/2S3ydRIS9OvlPoqbd1kRnGhyT0BO0XFhytw48ew8PqkMA4I1rqY uekI9IP8XCIvPcQE/Eb8ve0s0NvR8o37C0Ne9Gp/QyecP/QFiXC6ZBtTDuq4+idi1k AHqTv+rh4NLCJVZ3GV74fac680lt9V3tSWBVACxKWf/RFNU4rHbYeye+O1e1v+c7YF nUjuTgBa2Zo9Q== MIME-Version: 1.0 Date: Fri, 08 Dec 2023 15:31:27 +0500 From: Nikita Travkin To: Konrad Dybcio Cc: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , cros-qcom-dts-watchers@chromium.org, Andy Gross , Bjorn Andersson , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 2/3] power: supply: Add Acer Aspire 1 embedded controller driver In-Reply-To: <71459bab-05b9-41f6-bb32-2b744736487d@linaro.org> References: <20231207-aspire1-ec-v1-0-ba9e1c227007@trvn.ru> <20231207-aspire1-ec-v1-2-ba9e1c227007@trvn.ru> <71459bab-05b9-41f6-bb32-2b744736487d@linaro.org> Message-ID: <8fe5cb8cecf92d98f2768b811deb3ea0@trvn.ru> X-Sender: nikita@trvn.ru Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 08 Dec 2023 02:32:54 -0800 (PST) Konrad Dybcio писал(а) 08.12.2023 00:24: > On 12/7/23 12:20, Nikita Travkin wrote: >> Acer Aspire 1 is a Snapdragon 7c based laptop. It uses an embedded >> controller to control the charging and battery management, as well as to >> perform a set of misc functions. >> >> Unfortunately, while all this functionality is implemented in ACPI, it's >> currently not possible to use ACPI to boot Linux on such Qualcomm >> devices. To allow Linux to still support the features provided by EC, >> this driver reimplments the relevant ACPI parts. This allows us to boot >> the laptop with Device Tree and retain all the features. >> >> Signed-off-by: Nikita Travkin >> --- > [...] > >> + case POWER_SUPPLY_PROP_CAPACITY: >> + val->intval = le16_to_cpu(ddat.capacity_now) * 100 >> + / le16_to_cpu(sdat.capacity_full); > It may be just my OCD and im not the maintainer here, but I'd do > /= here Hm you're right, this did look a bit ugly to me when I split the line (it was 101/100), Will probably use /= to make it nicer in v2. > > [...] > >> + case POWER_SUPPLY_PROP_MODEL_NAME: >> + if (sdat.model_id - 1 < ARRAY_SIZE(aspire_ec_psy_battery_model)) >> + val->strval = aspire_ec_psy_battery_model[sdat.model_id - 1]; >> + else >> + val->strval = "Unknown"; > Would it make sense to print the model_id that's absent from the LUT > here and similarly below? > The original ACPI code returns "Unknown" like this when the value is not in the table. I suppose I could warn here but not sure how useful it would be... And since this is a rather "hot" path, would need to warn only once, so extra complexity for a very unlikely situation IMO. >> + break; >> + >> + case POWER_SUPPLY_PROP_MANUFACTURER: >> + if (sdat.vendor_id - 3 < ARRAY_SIZE(aspire_ec_psy_battery_vendor)) >> + val->strval = aspire_ec_psy_battery_vendor[sdat.vendor_id - 3]; >> + else >> + val->strval = "Unknown"; >> + break; >> + >> + default: >> + return -EINVAL; >> + } > Another ocd trip, i'd add a newline before return > Yeah I agree here, missed this. Will add in v2. >> + return 0; >> +} > [...] > >> + /* >> + * The original ACPI firmware actually has a small sleep in the handler. >> + * >> + * It seems like in most cases it's not needed but when the device >> + * just exits suspend, our i2c driver has a brief time where data >> + * transfer is not possible yet. So this delay allows us to suppress >> + * quite a bunch of spurious error messages in dmesg. Thus it's kept. > Ouch.. do you think i2c-geni needs fixing on this part? Not sure, it seems like when we exit suspend, this handler gets triggered before geni (or it's dependencies?) is considered "awake" (my guess is when the clocks are still off): [ 119.246867] PM: suspend entry (s2idle) (...) [ 119.438052] printk: Suspending console(s) (use no_console_suspend to debug) [ 119.942498] geni_i2c 888000.i2c: error turning SE resources:-13 [ 119.942550] aspire-ec 2-0076: Failed to read event id: -EACCES (...) [ 119.942657] geni_i2c 888000.i2c: error turning SE resources:-13 [ 119.942666] aspire-ec 2-0076: Failed to read event id: -EACCES (...) [ 120.881452] PM: suspend exit FWIW it doesn't seem to be a big problem since this is a level interrupt, so it will be retried until the event can be cleared, but since ACPI also has the sleep, I'm happy to inherit in and suppress a couple of red lines :) > > [...] > >> + switch (id) { >> + case 0x0: /* No event */ >> + break; > Is this a NOP/watchdog sort of thing? > This is a NOP, yes. I think I was hitting spurious interrupts once or twice so I suppressed this. > [...] > >> + >> +static struct i2c_driver aspire_ec_driver = { >> + .driver = { >> + .name = "aspire-ec", >> + .of_match_table = aspire_ec_of_match, >> + .pm = pm_sleep_ptr(&aspire_ec_pm_ops), >> + }, >> + .probe = aspire_ec_probe, >> + .id_table = aspire_ec_id, > Since it's tristate, I'd expect an entry for .remove_new here > All the resources I allocate are devm_ so I believe I shouldn't need to clean anything up on remove... Thanks for the review! Nikita > Konrad