All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Updates to ucsi_ccg driver
@ 2022-05-26  6:33 Sanket Goswami
  2022-05-26  6:33 ` [PATCH v3 1/2] ucsi_ccg: Do not hardcode interrupt polarity and type Sanket Goswami
  2022-05-26  6:33 ` [PATCH v3 2/2] ucsi_ccg: ACPI based I2c client enumeration for AMD ASICs Sanket Goswami
  0 siblings, 2 replies; 3+ messages in thread
From: Sanket Goswami @ 2022-05-26  6:33 UTC (permalink / raw)
  To: heikki.krogerus, gregkh, ajayg, linux-usb; +Cc: Sanket Goswami

This patch series includes:
- Add interrupt type and polarity check for some AMD ASICs
- Add ACPI ID to enumerate ucsi_ccg client

Sanket Goswami (2):
  ucsi_ccg: Do not hardcode interrupt polarity and type
  ucsi_ccg: ACPI based I2c client enumeration for AMD ASICs

 drivers/usb/typec/ucsi/ucsi_ccg.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v3 1/2] ucsi_ccg: Do not hardcode interrupt polarity and type
  2022-05-26  6:33 [PATCH v3 0/2] Updates to ucsi_ccg driver Sanket Goswami
@ 2022-05-26  6:33 ` Sanket Goswami
  2022-05-26  6:33 ` [PATCH v3 2/2] ucsi_ccg: ACPI based I2c client enumeration for AMD ASICs Sanket Goswami
  1 sibling, 0 replies; 3+ messages in thread
From: Sanket Goswami @ 2022-05-26  6:33 UTC (permalink / raw)
  To: heikki.krogerus, gregkh, ajayg, linux-usb; +Cc: Sanket Goswami

The current implementation supports only Level trigger with ACTIVE HIGH,
which is overriding level and polarity set by the ACPI table, hence
implement the common utility function to manage irq requests.

Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
---
Changes in v3:
- Implemented the new routine ccg_request_irq to handle irq requests
  including ACPI based device check.

Changes in v2:
- Implemented the new routine ccg_request_irq to handle irq requests. 

 drivers/usb/typec/ucsi/ucsi_ccg.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
index 6db7c8ddd51c..0707a7156299 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -627,6 +627,16 @@ static irqreturn_t ccg_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+static int ccg_request_irq(struct ucsi_ccg *uc)
+{
+	unsigned long flags = IRQF_ONESHOT;
+
+	if (!has_acpi_companion(uc->dev))
+		flags |= IRQF_TRIGGER_HIGH;
+
+	return request_threaded_irq(uc->irq, NULL, ccg_irq_handler, flags, dev_name(uc->dev), uc);
+}
+
 static void ccg_pm_workaround_work(struct work_struct *pm_work)
 {
 	ccg_irq_handler(0, container_of(pm_work, struct ucsi_ccg, pm_work));
@@ -1250,9 +1260,7 @@ static int ccg_restart(struct ucsi_ccg *uc)
 		return status;
 	}
 
-	status = request_threaded_irq(uc->irq, NULL, ccg_irq_handler,
-				      IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
-				      dev_name(dev), uc);
+	status = ccg_request_irq(uc);
 	if (status < 0) {
 		dev_err(dev, "request_threaded_irq failed - %d\n", status);
 		return status;
@@ -1331,6 +1339,7 @@ static int ucsi_ccg_probe(struct i2c_client *client,
 
 	uc->dev = dev;
 	uc->client = client;
+	uc->irq = client->irq;
 	mutex_init(&uc->lock);
 	init_completion(&uc->complete);
 	INIT_WORK(&uc->work, ccg_update_firmware);
@@ -1366,16 +1375,12 @@ static int ucsi_ccg_probe(struct i2c_client *client,
 
 	ucsi_set_drvdata(uc->ucsi, uc);
 
-	status = request_threaded_irq(client->irq, NULL, ccg_irq_handler,
-				      IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
-				      dev_name(dev), uc);
+	status = ccg_request_irq(uc);
 	if (status < 0) {
 		dev_err(uc->dev, "request_threaded_irq failed - %d\n", status);
 		goto out_ucsi_destroy;
 	}
 
-	uc->irq = client->irq;
-
 	status = ucsi_register(uc->ucsi);
 	if (status)
 		goto out_free_irq;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v3 2/2] ucsi_ccg: ACPI based I2c client enumeration for AMD ASICs
  2022-05-26  6:33 [PATCH v3 0/2] Updates to ucsi_ccg driver Sanket Goswami
  2022-05-26  6:33 ` [PATCH v3 1/2] ucsi_ccg: Do not hardcode interrupt polarity and type Sanket Goswami
@ 2022-05-26  6:33 ` Sanket Goswami
  1 sibling, 0 replies; 3+ messages in thread
From: Sanket Goswami @ 2022-05-26  6:33 UTC (permalink / raw)
  To: heikki.krogerus, gregkh, ajayg, linux-usb; +Cc: Sanket Goswami

Some of the AMD platforms have Cypress CCGX PD controller connected
to system I2C i.e designware I2C controller. Added support to enumerate
the CCGX client by adding ACPI ID to the firmware.

Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
---
Changes in v3:
- Swap the patch 1 and 2 to achieve required functionality.

Changes in v2:
- No change.

 drivers/usb/typec/ucsi/ucsi_ccg.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
index 0707a7156299..5c0bf48be766 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -1423,6 +1423,12 @@ 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"},
+	{}
+};
+MODULE_DEVICE_TABLE(acpi, amd_i2c_ucsi_match);
+
 static int ucsi_ccg_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -1464,6 +1470,7 @@ static struct i2c_driver ucsi_ccg_driver = {
 		.name = "ucsi_ccg",
 		.pm = &ucsi_ccg_pm,
 		.dev_groups = ucsi_ccg_groups,
+		.acpi_match_table = amd_i2c_ucsi_match,
 	},
 	.probe = ucsi_ccg_probe,
 	.remove = ucsi_ccg_remove,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-26  6:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26  6:33 [PATCH v3 0/2] Updates to ucsi_ccg driver Sanket Goswami
2022-05-26  6:33 ` [PATCH v3 1/2] ucsi_ccg: Do not hardcode interrupt polarity and type Sanket Goswami
2022-05-26  6:33 ` [PATCH v3 2/2] ucsi_ccg: ACPI based I2c client enumeration for AMD ASICs Sanket Goswami

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.