From: Pengyu Luo <mitltlatltl@gmail.com>
To: krzk@kernel.org
Cc: andersson@kernel.org, bryan.odonoghue@linaro.org,
conor+dt@kernel.org, devicetree@vger.kernel.org,
dmitry.baryshkov@linaro.org, gregkh@linuxfoundation.org,
hdegoede@redhat.com, heikki.krogerus@linux.intel.com,
ilpo.jarvinen@linux.intel.com, konradybcio@kernel.org,
krzk+dt@kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
linux-usb@vger.kernel.org, mitltlatltl@gmail.com, nikita@trvn.ru,
platform-driver-x86@vger.kernel.org, robh@kernel.org,
sre@kernel.org
Subject: Re: [PATCH 1/5] dt-bindings: platform: Add Huawei Matebook E Go EC
Date: Sat, 28 Dec 2024 19:34:37 +0800 [thread overview]
Message-ID: <20241228113438.591254-1-mitltlatltl@gmail.com> (raw)
In-Reply-To: <53da6468-501c-4c0f-a73b-4eac99c72b8c@kernel.org>
> On Sat, Dec 28, 2024 at 5:58 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
> On 27/12/2024 18:13, Pengyu Luo wrote:
> > +
> > +#include <linux/platform_data/huawei-gaokun-ec.h>
> > +
> > +#define EC_EVENT 0x06
> > +
> > +/* Also can be found in ACPI specification 12.3 */
> > +#define EC_READ 0x80
> > +#define EC_WRITE 0x81
> > +#define EC_BURST 0x82
> > +#define EC_QUERY 0x84
> > +
> > +
> > +#define EC_EVENT_LID 0x81
> > +
> > +#define EC_LID_STATE 0x80
> > +#define EC_LID_OPEN BIT(1)
> > +
> > +#define UCSI_REG_SIZE 7
> > +
> > +/* for tx, command sequences are arranged as
>
> Use Linux style comments, see coding style.
>
Agree
> > + * {master_cmd, slave_cmd, data_len, data_seq}
> > + */
> > +#define REQ_HDR_SIZE 3
> > +#define INPUT_SIZE_OFFSET 2
> > +#define INPUT_DATA_OFFSET 3
> > +
> > +/* for rx, data sequences are arranged as
> > + * {status, data_len(unreliable), data_seq}
> > + */
> > +#define RESP_HDR_SIZE 2
> > +#define DATA_OFFSET 2
> > +
> > +
> > +struct gaokun_ec {
> > + struct i2c_client *client;
> > + struct mutex lock;
>
> Missing doc. Run Checkpatch --strict, so you will know what is missing here.
>
I see. A comment for mutex lock.
> > + struct blocking_notifier_head notifier_list;
> > + struct input_dev *idev;
> > + bool suspended;
> > +};
> > +
>
>
>
> ...
>
> > +
> > +static DEVICE_ATTR_RO(temperature);
> > +
> > +static struct attribute *gaokun_wmi_features_attrs[] = {
> > + &dev_attr_charge_control_thresholds.attr,
> > + &dev_attr_smart_charge_param.attr,
> > + &dev_attr_smart_charge.attr,
> > + &dev_attr_fn_lock_state.attr,
> > + &dev_attr_temperature.attr,
> > + NULL,
> > +};
>
>
> No, don't expose your own interface. Charging is already exposed by
> power supply framework. Temperature by hwmon sensors. Drop all these and
> never re-implement existing kernel user-space interfaces.
>
I don't quite understand what you mean. You mean I should use hwmon
interface like hwmon_device_register_with_groups to register it, right?
As for battery, get/set_propery allow us to handle charging thresholds
things, but there are smart_charge_param, smart_charge and fn_lock to handle.
>
> > diff --git a/include/linux/platform_data/huawei-gaokun-ec.h b/include/linux/platform_data/huawei-gaokun-ec.h
> > new file mode 100644
> > index 000000000..a649e9ecf
> > --- /dev/null
> > +++ b/include/linux/platform_data/huawei-gaokun-ec.h
> > @@ -0,0 +1,90 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/* Huawei Matebook E Go (sc8280xp) Embedded Controller
> > + *
> > + * Copyright (C) 2024 Pengyu Luo <mitltlatltl@gmail.com>
> > + *
> > + */
> > +
> > +#ifndef __HUAWEI_GAOKUN_EC_H__
> > +#define __HUAWEI_GAOKUN_EC_H__
> > +
> > +#define GAOKUN_UCSI_CCI_SIZE 4
> > +#define GAOKUN_UCSI_DATA_SIZE 16
> > +#define GAOKUN_UCSI_READ_SIZE (GAOKUN_UCSI_CCI_SIZE + GAOKUN_UCSI_DATA_SIZE)
> > +#define GAOKUN_UCSI_WRITE_SIZE 0x18
> > +
> > +#define GAOKUN_TZ_REG_NUM 20
> > +#define GAOKUN_SMART_CHARGE_DATA_SIZE 4 /* mode, delay, start, end */
> > +
> > +/* -------------------------------------------------------------------------- */
> > +
> > +struct gaokun_ec;
> > +struct notifier_block;
>
> Drop, include proper header instead.
>
I agree, I copy 'struct notifier_block;' from
include/linux/platform_data/lenovo-yoga-c630.h
> > +
> > +#define GAOKUN_MOD_NAME "huawei_gaokun_ec"
> > +#define GAOKUN_DEV_PSY "psy"
> > +#define GAOKUN_DEV_WMI "wmi"
> > +#define GAOKUN_DEV_UCSI "ucsi"
> > +
> > +/* -------------------------------------------------------------------------- */
> > +/* Common API */
> > +
> > +int gaokun_ec_register_notify(struct gaokun_ec *ec,
> > + struct notifier_block *nb);
> > +void gaokun_ec_unregister_notify(struct gaokun_ec *ec,
> > + struct notifier_block *nb);
> > +
> > +int gaokun_ec_read(struct gaokun_ec *ec, const u8 *req,
> > + size_t resp_len, u8 *resp);
> > +int gaokun_ec_write(struct gaokun_ec *ec, u8 *req);
> > +int gaokun_ec_read_byte(struct gaokun_ec *ec, u8 *req, u8 *byte);
>
>
> You need kerneldoc, in the C file, for all exported functions.
>
I got it.
>
>
> Best regards,
> Krzysztof
Best Wishes,
Pengyu
next prev parent reply other threads:[~2024-12-28 11:35 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-27 17:13 [PATCH 0/5] platform: arm64: Huawei Matebook E Go embedded controller Pengyu Luo
2024-12-27 17:13 ` [PATCH 1/5] dt-bindings: platform: Add Huawei Matebook E Go EC Pengyu Luo
2024-12-27 18:18 ` Rob Herring (Arm)
2024-12-28 9:54 ` Krzysztof Kozlowski
2024-12-28 10:50 ` Pengyu Luo
2024-12-29 9:50 ` Krzysztof Kozlowski
2024-12-29 10:12 ` Pengyu Luo
2024-12-30 7:28 ` Aiqun(Maria) Yu
2024-12-30 7:35 ` Krzysztof Kozlowski
2024-12-30 9:10 ` Aiqun(Maria) Yu
2024-12-30 8:00 ` Pengyu Luo
2025-01-01 5:57 ` Pengyu Luo
2024-12-27 17:13 ` [PATCH 2/5] platform: arm64: add Huawei Matebook E Go (sc8280xp) EC driver Pengyu Luo
2024-12-27 18:21 ` Maya Matuszczyk
2024-12-28 5:42 ` Pengyu Luo
2024-12-28 9:58 ` Krzysztof Kozlowski
2024-12-28 11:34 ` Pengyu Luo [this message]
2024-12-29 4:08 ` [PATCH 1/5] dt-bindings: platform: Add Huawei Matebook E Go EC Dmitry Baryshkov
2024-12-29 9:04 ` [PATCH 2/5] platform: arm64: add Huawei Matebook E Go (sc8280xp) EC driver Pengyu Luo
2024-12-29 9:44 ` Krzysztof Kozlowski
2024-12-29 9:43 ` [PATCH 1/5] dt-bindings: platform: Add Huawei Matebook E Go EC Krzysztof Kozlowski
2024-12-29 10:28 ` Pengyu Luo
2024-12-29 21:45 ` Krzysztof Kozlowski
2024-12-28 12:33 ` [PATCH 2/5] platform: arm64: add Huawei Matebook E Go (sc8280xp) EC driver Bryan O'Donoghue
2024-12-28 13:51 ` Pengyu Luo
2024-12-29 15:32 ` Ilpo Järvinen
2024-12-29 15:55 ` Pengyu Luo
2024-12-29 14:49 ` Markus Elfring
2024-12-30 9:04 ` Aiqun(Maria) Yu
2024-12-30 10:44 ` Pengyu Luo
2024-12-31 5:00 ` Aiqun(Maria) Yu
2024-12-31 7:44 ` Pengyu Luo
2024-12-31 11:09 ` Bryan O'Donoghue
2025-01-03 5:38 ` Dmitry Baryshkov
2025-01-03 7:19 ` Pengyu Luo
2025-01-01 11:27 ` Pengyu Luo
2024-12-27 17:13 ` [PATCH 3/5] usb: typec: ucsi: add Huawei Matebook E Go (sc8280xp) ucsi driver Pengyu Luo
2024-12-28 13:06 ` Bryan O'Donoghue
2024-12-28 14:38 ` Pengyu Luo
2024-12-29 14:51 ` Bryan O'Donoghue
2024-12-29 16:25 ` Pengyu Luo
2024-12-29 4:40 ` Dmitry Baryshkov
2024-12-29 9:05 ` Pengyu Luo
2025-01-06 3:33 ` Dmitry Baryshkov
2025-01-06 9:20 ` [PATCH 1/5] dt-bindings: platform: Add Huawei Matebook E Go EC Pengyu Luo
2025-01-06 9:22 ` [PATCH 3/5] usb: typec: ucsi: add Huawei Matebook E Go (sc8280xp) ucsi driver Pengyu Luo
2024-12-29 16:15 ` Markus Elfring
2024-12-27 17:13 ` [PATCH 4/5] power: supply: add Huawei Matebook E Go (sc8280xp) psy driver Pengyu Luo
2024-12-27 17:13 ` [PATCH 5/5] arm64: dts: qcom: gaokun3: Add Embedded Controller node Pengyu Luo
2024-12-30 14:53 ` Konrad Dybcio
2024-12-30 16:22 ` Pengyu Luo
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=20241228113438.591254-1-mitltlatltl@gmail.com \
--to=mitltlatltl@gmail.com \
--cc=andersson@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nikita@trvn.ru \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox