From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Pengyu Luo <mitltlatltl@gmail.com>
Cc: andersson@kernel.org, bryan.odonoghue@linaro.org,
conor+dt@kernel.org, devicetree@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Hans de Goede <hdegoede@redhat.com>,
heikki.krogerus@linux.intel.com, jdelvare@suse.com,
konradybcio@kernel.org, krzk+dt@kernel.org,
linux-arm-msm@vger.kernel.org, linux-hwmon@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
linux-pm@vger.kernel.org, linux-usb@vger.kernel.org,
linux@roeck-us.net, platform-driver-x86@vger.kernel.org,
robh@kernel.org, sre@kernel.org
Subject: Re: [PATCH v3 2/6] platform: arm64: add Huawei Matebook E Go EC driver
Date: Tue, 14 Jan 2025 17:40:51 +0200 (EET) [thread overview]
Message-ID: <d2a42fc7-37a9-3fcc-4c35-e542ddb112e8@linux.intel.com> (raw)
In-Reply-To: <20250114083133.607318-1-mitltlatltl@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5290 bytes --]
On Tue, 14 Jan 2025, Pengyu Luo wrote:
> On Tue, Jan 14, 2025 at 2:56 AM Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote:
> > On Tue, 14 Jan 2025, Pengyu Luo wrote:
> >
> > > There are three variants of which Huawei released the first two
> > > simultaneously.
> > >
> > > Huawei Matebook E Go LTE(sc8180x), codename seems to be gaokun2.
> > > Huawei Matebook E Go(sc8280xp@3.0GHz), codename must be gaokun3. (see [1])
> > > Huawei Matebook E Go 2023(sc8280xp@2.69GHz), codename should be also gaokun3.
> > >
> > > Adding support for the latter two variants for now, this driver should
> > > also work for the sc8180x variant according to acpi table files, but I
> > > don't have the device to test yet.
> > >
> > > Different from other Qualcomm Snapdragon sc8280xp based machines, the
> > > Huawei Matebook E Go uses an embedded controller while others use
> > > a system called PMIC GLink. This embedded controller can be used to
> > > perform a set of various functions, including, but not limited to:
> > >
> > > - Battery and charger monitoring;
> > > - Charge control and smart charge;
> > > - Fn_lock settings;
> > > - Tablet lid status;
> > > - Temperature sensors;
> > > - USB Type-C notifications (ports orientation, DP alt mode HPD);
> > > - USB Type-C PD (according to observation, up to 48w).
> > >
> > > Add a driver for the EC which creates devices for UCSI and power supply
> > > devices.
> > >
> > > [1] https://bugzilla.kernel.org/show_bug.cgi?id=219645
> > >
> > > Signed-off-by: Pengyu Luo <mitltlatltl@gmail.com>
> > > +/**
> > > + * gaokun_ec_psy_get_smart_charge_enable - check if smart charge is enabled
> > > + * @ec: The gaokun_ec
> > > + * @on: The state
> > > + *
> > > + * Return: 0 on success or negative error code.
> > > + */
> > > +int gaokun_ec_psy_get_smart_charge_enable(struct gaokun_ec *ec, bool *on)
> > > +{
> > > + /* GBAC */
> > > + *on = 0; /* clear other 3 Bytes */
> >
> > = false (as it's bool)
> >
> > What that comment means??? The type is bool so what "3 Bytes" ???
> >
>
> We will write to the lowest Byte, the higher 3 Bytes are dirty, so clear it.
Are you saying you assume bool is 4 bytes long? I'd be cautious on making
assumptions on sizeof(bool).
> We can also implememnt it like this
>
> int ret;
> u8 resp;
>
> ret = gaokun_ec_read_byte(.., &resp);
> if (ret)
> return ret;
>
> *on = !!resp;
Yes, I prefer explicit u8 -> bool conversion like this.
> > > +/* Fn lock */
> > > +static int gaokun_ec_get_fn_lock(struct gaokun_ec *ec, bool *on)
> > > +{
> > > + /* GFRS */
> > > + u8 req[] = MKREQ(0x02, 0x6B, 0);
> >
> > Does that random acronym map to one of the literal? In which case a define
> > would be more useful than a comment. (You seem to have a few similar
> > comments preceeding the req definitions)
> >
>
> They are ACPI method names/identifiers, it will be useful if someone want
> to locate ACPI's implementations.
Okay, I guess it's fine as is then.
> > > +static int gaokun_ec_get_temp(struct gaokun_ec *ec, u8 idx, int *temp)
> > > +{
> > > + /* GTMP */
> > > + u8 req[] = MKREQ(0x02, 0x61, 1, temp_reg[idx]);
> > > + u8 resp[] = MKRESP(sizeof(__le16));
> > > + __le16 tmp;
> > > + int ret;
> > > +
> > > + ret = gaokun_ec_read(ec, req, sizeof(resp), resp);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + extr_resp((u8 *)&tmp, resp, sizeof(tmp));
> > > + *temp = le16_to_cpu(tmp) * 100; /* convert to HwMon's unit */
> >
> > extr_resp() does memcpy() but there should be no need to copy anything
> > here. You just want to have __le16 pointer of the response data data.
> >
>
> I think this would break abstraction, recently, these data are accessed by
> extr_resp() and refill_req() only.
If you want to keep doing it like that, not a big deal for me.
There are different ways to do the abstraction though, and not all require
memcpy() when changing a layer (e.g., a pointer advancing to the other
layer).
> > > +/* -------------------------------------------------------------------------- */
> > > +/* EC */
> > > +
> > > +static irqreturn_t gaokun_ec_irq_handler(int irq, void *data)
> > > +{
> > > + struct gaokun_ec *ec = data;
> > > + u8 req[] = MKREQ(EC_EVENT, EC_QUERY, 0);
> >
> > Great, here you have named them. Could you name all of the other literals
> > too, please.
>
> I mentioned this in previous version. Most of them are magic, it is hard to
> generalize them. We could name partial scmd according to specific functions
> (sysfs functions), their function names have implied registers' meaning, and
> these registers would be never reused in other functions.
Fair (I didn't read every comment made to the previous version).
> > > +/* -------------------------------------------------------------------------- */
> > > +/* API For UCSI */
> >
> > for
> >
>
> Agree
For me, you don't need to reply "Agree", "Ack" or something along those
lines if you're going to act on the feedback. Just make sure you don't
forget them :-). It'll save us both some time when we focus on points that
need further discussion.
--
i.
next prev parent reply other threads:[~2025-01-14 15:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 17:49 [PATCH v3 0/6] platform: arm64: Huawei Matebook E Go embedded controller Pengyu Luo
2025-01-13 17:50 ` [PATCH v3 2/6] platform: arm64: add Huawei Matebook E Go EC driver Pengyu Luo
2025-01-13 18:34 ` Guenter Roeck
2025-01-13 18:56 ` Ilpo Järvinen
2025-01-14 8:31 ` Pengyu Luo
2025-01-14 15:40 ` Ilpo Järvinen [this message]
2025-01-16 12:02 ` Heikki Krogerus
2025-01-13 17:51 ` [PATCH v3 3/6] usb: typec: ucsi: Add a macro definition for UCSI v1.0 Pengyu Luo
2025-01-13 17:51 ` [PATCH v3 4/6] usb: typec: ucsi: add Huawei Matebook E Go ucsi driver Pengyu Luo
2025-01-16 11:55 ` Heikki Krogerus
2025-01-16 18:26 ` Pengyu Luo
2025-01-13 17:51 ` [PATCH v3 5/6] power: supply: add Huawei Matebook E Go psy driver Pengyu Luo
2025-02-20 0:24 ` Sebastian Reichel
2025-02-20 6:43 ` Pengyu Luo
2025-02-21 1:33 ` Sebastian Reichel
2025-02-21 6:01 ` Pengyu Luo
2025-02-21 22:22 ` Sebastian Reichel
2025-02-22 11:27 ` Pengyu Luo
2025-01-13 17:51 ` [PATCH v3 6/6] arm64: dts: qcom: gaokun3: Add Embedded Controller node Pengyu Luo
2025-01-16 11:26 ` [PATCH v3 3/6] usb: typec: ucsi: Add a macro definition for UCSI v1.0 Heikki Krogerus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d2a42fc7-37a9-3fcc-4c35-e542ddb112e8@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=andersson@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=jdelvare@suse.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mitltlatltl@gmail.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.