From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Sanket Goswami <Sanket.Goswami@amd.com>
Cc: gregkh@linuxfoundation.org, ajayg@nvidia.com, linux-usb@vger.kernel.org
Subject: Re: [PATCH 2/2] ucsi_ccg: Do not hardcode interrupt polarity and type
Date: Wed, 11 May 2022 10:59:39 +0300 [thread overview]
Message-ID: <Ynts6+QeiWT7tL3I@kuha.fi.intel.com> (raw)
In-Reply-To: <20220510052437.3212186-3-Sanket.Goswami@amd.com>
On Tue, May 10, 2022 at 10:54:37AM +0530, Sanket Goswami wrote:
> The current implementation supports only Level trigger with ACTIVE HIGH.
> Some of the AMD platforms have different PD firmware implementation which
> needs different polarity. This patch checks the polarity and type based
> on the device properties set and registers the interrupt handler
> accordingly.
>
> Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
> ---
> drivers/usb/typec/ucsi/ucsi_ccg.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
> index 7585599bacfd..0db935bd8473 100644
> --- a/drivers/usb/typec/ucsi/ucsi_ccg.c
> +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
> @@ -20,6 +20,7 @@
>
> #include <asm/unaligned.h>
> #include "ucsi.h"
> +#define INTR_POL_TYPE BIT(0)
>
> enum enum_fw_mode {
> BOOT, /* bootloader */
> @@ -1324,6 +1325,8 @@ static int ucsi_ccg_probe(struct i2c_client *client,
> struct device *dev = &client->dev;
> struct ucsi_ccg *uc;
> int status;
> + /* Keep the IRQ type and polarity default as Level trigger Active High */
> + int irqtype = IRQF_TRIGGER_HIGH;
>
> uc = devm_kzalloc(dev, sizeof(*uc), GFP_KERNEL);
> if (!uc)
> @@ -1366,8 +1369,12 @@ static int ucsi_ccg_probe(struct i2c_client *client,
>
> ucsi_set_drvdata(uc->ucsi, uc);
>
> + status = (uintptr_t)device_get_match_data(dev);
> + if (status & INTR_POL_TYPE)
> + irqtype = IRQF_TRIGGER_FALLING;
> +
> status = request_threaded_irq(client->irq, NULL, ccg_irq_handler,
> - IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
> + IRQF_ONESHOT | irqtype,
> dev_name(dev), uc);
Please note that you would need to update ccg_restart() as well, but
there is something else wrong here...
> if (status < 0) {
> dev_err(uc->dev, "request_threaded_irq failed - %d\n", status);
> @@ -1419,7 +1426,7 @@ static const struct i2c_device_id ucsi_ccg_device_id[] = {
> MODULE_DEVICE_TABLE(i2c, ucsi_ccg_device_id);
>
> static const struct acpi_device_id amd_i2c_ucsi_match[] = {
> - {"AMDI0042"},
> + {"AMDI0042", INTR_POL_TYPE},
> {}
> };
This should not be necessary. That information comes from the ACPI
tables.
I don't think that you need to set the polarity/level flags at all in
case of ACPI. I'll double check that, but if that is the case, then you
need to make the case where the device is not ACPI enumerated the
special case instead.
thanks,
--
heikki
next prev parent reply other threads:[~2022-05-11 7:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 5:24 [PATCH 0/2] Updates to ucsi_ccg driver Sanket Goswami
2022-05-10 5:24 ` [PATCH 1/2] ucsi_ccg: ACPI based I2c client enumeration for AMD ASICs Sanket Goswami
2022-05-10 5:24 ` [PATCH 2/2] ucsi_ccg: Do not hardcode interrupt polarity and type Sanket Goswami
2022-05-11 7:59 ` Heikki Krogerus [this message]
2022-05-11 8:06 ` Heikki Krogerus
2022-05-12 17:23 ` Goswami, Sanket
2022-05-13 10:00 ` Heikki Krogerus
2022-05-20 11:25 ` Goswami, Sanket
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=Ynts6+QeiWT7tL3I@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=Sanket.Goswami@amd.com \
--cc=ajayg@nvidia.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.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.