From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Pengyu Luo <mitltlatltl@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH v3 4/6] usb: typec: ucsi: add Huawei Matebook E Go ucsi driver
Date: Thu, 16 Jan 2025 13:55:27 +0200 [thread overview]
Message-ID: <Z4jzr1PUPhwpQLTY@kuha.fi.intel.com> (raw)
In-Reply-To: <20250113175131.590683-2-mitltlatltl@gmail.com>
Hi,
On Tue, Jan 14, 2025 at 01:51:26AM +0800, Pengyu Luo wrote:
> The Huawei Matebook E Go tablet implements the UCSI interface in the
> onboard EC. Add the glue driver to interface with the platform's UCSI
> implementation.
>
> Signed-off-by: Pengyu Luo <mitltlatltl@gmail.com>
> ---
> drivers/usb/typec/ucsi/Kconfig | 11 +
> drivers/usb/typec/ucsi/Makefile | 1 +
> drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c | 526 ++++++++++++++++++++
> 3 files changed, 538 insertions(+)
> create mode 100644 drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c
>
> diff --git a/drivers/usb/typec/ucsi/Kconfig b/drivers/usb/typec/ucsi/Kconfig
> index 75559601f..e94956d27 100644
> --- a/drivers/usb/typec/ucsi/Kconfig
> +++ b/drivers/usb/typec/ucsi/Kconfig
> @@ -91,4 +91,15 @@ config UCSI_LENOVO_YOGA_C630
> To compile the driver as a module, choose M here: the module will be
> called ucsi_yoga_c630.
>
> +config UCSI_HUAWEI_GAOKUN
> + tristate "UCSI Interface Driver for Huawei Matebook E Go"
> + depends on EC_HUAWEI_GAOKUN
> + select DRM_AUX_HPD_BRIDGE
> + help
> + This driver enables UCSI support on the Huawei Matebook E Go tablet,
> + which is a sc8280xp-based 2-in-1 tablet.
> +
> + To compile the driver as a module, choose M here: the module will be
> + called ucsi_huawei_gaokun.
> +
> endif
> diff --git a/drivers/usb/typec/ucsi/Makefile b/drivers/usb/typec/ucsi/Makefile
> index be98a8791..dbc571763 100644
> --- a/drivers/usb/typec/ucsi/Makefile
> +++ b/drivers/usb/typec/ucsi/Makefile
> @@ -23,3 +23,4 @@ obj-$(CONFIG_UCSI_STM32G0) += ucsi_stm32g0.o
> obj-$(CONFIG_UCSI_PMIC_GLINK) += ucsi_glink.o
> obj-$(CONFIG_CROS_EC_UCSI) += cros_ec_ucsi.o
> obj-$(CONFIG_UCSI_LENOVO_YOGA_C630) += ucsi_yoga_c630.o
> +obj-$(CONFIG_UCSI_HUAWEI_GAOKUN) += ucsi_huawei_gaokun.o
> diff --git a/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c b/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c
> new file mode 100644
> index 000000000..da1993805
> --- /dev/null
> +++ b/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c
> @@ -0,0 +1,527 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * ucsi-huawei-gaokun - A UCSI driver for HUAWEI Matebook E Go
> + *
> + * reference: drivers/usb/typec/ucsi/ucsi_yoga_c630.c
> + * drivers/usb/typec/ucsi/ucsi_glink.c
> + * drivers/soc/qcom/pmic_glink_altmode.c
> + *
> + * Copyright (C) 2024 Pengyu Luo <mitltlatltl@gmail.com>
> + */
> +
> +#include <drm/bridge/aux-bridge.h>
> +#include <linux/auxiliary_bus.h>
> +#include <linux/bitops.h>
> +#include <linux/completion.h>
> +#include <linux/container_of.h>
> +#include <linux/module.h>
> +#include <linux/notifier.h>
> +#include <linux/of.h>
> +#include <linux/platform_data/huawei-gaokun-ec.h>
> +#include <linux/string.h>
> +#include <linux/usb/pd_vdo.h>
> +#include <linux/usb/typec_altmode.h>
> +#include <linux/usb/typec_dp.h>
> +#include <linux/workqueue_types.h>
> +
> +#include "ucsi.h"
> +
> +#define EC_EVENT_UCSI 0x21
> +#define EC_EVENT_USB 0x22
> +
> +#define GAOKUN_CCX_MASK GENMASK(1, 0)
> +#define GAOKUN_MUX_MASK GENMASK(3, 2)
> +
> +#define GAOKUN_DPAM_MASK GENMASK(3, 0)
> +#define GAOKUN_HPD_STATE_MASK BIT(4)
> +#define GAOKUN_HPD_IRQ_MASK BIT(5)
> +
> +#define GET_IDX(updt) (ffs(updt) - 1)
> +
> +#define CCX_TO_ORI(ccx) (++ccx % 3) /* convert ccx to enum typec_orientation */
> +
> +/* Configuration Channel Extension */
> +enum gaokun_ucsi_ccx {
> + USBC_CCX_NORMAL,
> + USBC_CCX_REVERSE,
> + USBC_CCX_NONE,
> +};
> +
> +enum gaokun_ucsi_mux {
> + USBC_MUX_NONE,
> + USBC_MUX_USB_2L,
> + USBC_MUX_DP_4L,
> + USBC_MUX_USB_DP,
> +};
Missing newline.
> +/* based on pmic_glink_altmode_pin_assignment */
> +enum gaokun_ucsi_dpam_pan { /* DP Alt Mode Pin Assignments */
> + USBC_DPAM_PAN_NONE,
> + USBC_DPAM_PAN_A, /* Not supported after USB Type-C Standard v1.0b */
> + USBC_DPAM_PAN_B, /* Not supported after USB Type-C Standard v1.0b */
> + USBC_DPAM_PAN_C, /* USBC_DPAM_PAN_C_REVERSE - 6 */
> + USBC_DPAM_PAN_D,
> + USBC_DPAM_PAN_E,
> + USBC_DPAM_PAN_F, /* Not supported after USB Type-C Standard v1.0b */
> + USBC_DPAM_PAN_A_REVERSE,/* Not supported after USB Type-C Standard v1.0b */
> + USBC_DPAM_PAN_B_REVERSE,/* Not supported after USB Type-C Standard v1.0b */
> + USBC_DPAM_PAN_C_REVERSE,
> + USBC_DPAM_PAN_D_REVERSE,
> + USBC_DPAM_PAN_E_REVERSE,
> + USBC_DPAM_PAN_F_REVERSE,/* Not supported after USB Type-C Standard v1.0b */
> +};
> +
> +struct gaokun_ucsi_reg {
> + u8 num_ports;
> + u8 port_updt;
> + u8 port_data[4];
> + u8 checksum;
> + u8 reserved;
> +} __packed;
> +
> +struct gaokun_ucsi_port {
> + struct completion usb_ack;
> + spinlock_t lock;
Locks need to be commented. Did you run checkpatch.pl on this?
> + struct gaokun_ucsi *ucsi;
> + struct auxiliary_device *bridge;
> +
> + int idx;
> + enum gaokun_ucsi_ccx ccx;
> + enum gaokun_ucsi_mux mux;
> + u8 mode;
> + u16 svid;
> + u8 hpd_state;
> + u8 hpd_irq;
> +};
> +
> +struct gaokun_ucsi {
> + struct gaokun_ec *ec;
> + struct ucsi *ucsi;
> + struct gaokun_ucsi_port *ports;
> + struct device *dev;
> + struct delayed_work work;
> + struct notifier_block nb;
> + u16 version;
> + u8 num_ports;
> +};
thanks,
--
heikki
next prev parent reply other threads:[~2025-01-16 11:55 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
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 [this message]
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=Z4jzr1PUPhwpQLTY@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mitltlatltl@gmail.com \
/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.