diff mbox series

[v1,01/11] i2c: Introduce common module to instantiate CCGx UCSI

Message ID 20211207192159.41383-1-andriy.shevchenko@linux.intel.com
State Superseded
Headers show
Series [v1,01/11] i2c: Introduce common module to instantiate CCGx UCSI | expand

Commit Message

Andy Shevchenko Dec. 7, 2021, 7:21 p.m. UTC
Introduce a common module to provide an API to instantiate UCSI device
for Cypress CCGx Type-C controller. Individual bus drivers need to select
this one on demand.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/Kconfig         |  7 +++++++
 drivers/i2c/busses/Makefile        |  3 +++
 drivers/i2c/busses/i2c-ccgx-ucsi.c | 27 +++++++++++++++++++++++++++
 drivers/i2c/busses/i2c-ccgx-ucsi.h | 11 +++++++++++
 4 files changed, 48 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ccgx-ucsi.c
 create mode 100644 drivers/i2c/busses/i2c-ccgx-ucsi.h

Comments

Andy Shevchenko Dec. 13, 2021, 6 p.m. UTC | #1
On Wed, Dec 08, 2021 at 02:29:04PM +0200, Jarkko Nikula wrote:
> On 12/7/21 21:21, Andy Shevchenko wrote:
> > Introduce a common module to provide an API to instantiate UCSI device
> > for Cypress CCGx Type-C controller. Individual bus drivers need to select
> > this one on demand.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >   drivers/i2c/busses/Kconfig         |  7 +++++++
> >   drivers/i2c/busses/Makefile        |  3 +++
> >   drivers/i2c/busses/i2c-ccgx-ucsi.c | 27 +++++++++++++++++++++++++++
> >   drivers/i2c/busses/i2c-ccgx-ucsi.h | 11 +++++++++++
> >   4 files changed, 48 insertions(+)
> >   create mode 100644 drivers/i2c/busses/i2c-ccgx-ucsi.c
> >   create mode 100644 drivers/i2c/busses/i2c-ccgx-ucsi.h
> > 
> I've mixed feelings about this set. I'd either put patches 3-8 first since
> e.g. 6/11 and 8/11 are fixing existing issues or even better to split CCGx
> UCSI stuff into another set.

I have sent v2 with DesignWare patches only and no conversion part included.
Nehal-bakulchandra Shah Dec. 15, 2021, 1:50 p.m. UTC | #2
Hi Andy,

On 12/13/2021 11:30 PM, Andy Shevchenko wrote:
> On Wed, Dec 08, 2021 at 02:29:04PM +0200, Jarkko Nikula wrote:
>> On 12/7/21 21:21, Andy Shevchenko wrote:
>>> Introduce a common module to provide an API to instantiate UCSI device
>>> for Cypress CCGx Type-C controller. Individual bus drivers need to select
>>> this one on demand.
>>>
>>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>>> ---
>>>    drivers/i2c/busses/Kconfig         |  7 +++++++
>>>    drivers/i2c/busses/Makefile        |  3 +++
>>>    drivers/i2c/busses/i2c-ccgx-ucsi.c | 27 +++++++++++++++++++++++++++
>>>    drivers/i2c/busses/i2c-ccgx-ucsi.h | 11 +++++++++++
>>>    4 files changed, 48 insertions(+)
>>>    create mode 100644 drivers/i2c/busses/i2c-ccgx-ucsi.c
>>>    create mode 100644 drivers/i2c/busses/i2c-ccgx-ucsi.h
>>>
>> I've mixed feelings about this set. I'd either put patches 3-8 first since
>> e.g. 6/11 and 8/11 are fixing existing issues or even better to split CCGx
>> UCSI stuff into another set.
> 
> I have sent v2 with DesignWare patches only and no conversion part included.
> 

It will be good we can take this patch also in this series. This is more 
nicer and cleaner solution. That said, we are working futuristic 
platform where CCGX is connected over system  i2c of our platform i.e 
AMDI0010 so in this case from designware platform i2c driver we will 
have to probe the CCGX driver.

Regards
Nehal
diff mbox series

Patch

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index df89cb809330..0fb2caf7498c 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -9,6 +9,13 @@  menu "I2C Hardware Bus support"
 comment "PC SMBus host controller drivers"
 	depends on PCI
 
+config I2C_CCGX_UCSI
+	tristate
+	help
+	  A common module to provide an API to instantiate UCSI device
+	  for Cypress CCGx Type-C controller. Individual bus drivers
+	  need to select this one on demand.
+
 config I2C_ALI1535
 	tristate "ALI 1535"
 	depends on PCI
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 1d00dce77098..79405cb5d600 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -6,6 +6,9 @@ 
 # ACPI drivers
 obj-$(CONFIG_I2C_SCMI)		+= i2c-scmi.o
 
+# Auxiliary I2C/SMBus modules
+obj-$(CONFIG_I2C_CCGX_UCSI)	+= i2c-ccgx-ucsi.o
+
 # PC SMBus host controller drivers
 obj-$(CONFIG_I2C_ALI1535)	+= i2c-ali1535.o
 obj-$(CONFIG_I2C_ALI1563)	+= i2c-ali1563.o
diff --git a/drivers/i2c/busses/i2c-ccgx-ucsi.c b/drivers/i2c/busses/i2c-ccgx-ucsi.c
new file mode 100644
index 000000000000..141c3d1ef752
--- /dev/null
+++ b/drivers/i2c/busses/i2c-ccgx-ucsi.c
@@ -0,0 +1,27 @@ 
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Instantiate UCSI device for Cypress CCGx Type-C controller.
+ * Derived from i2c-designware-pcidrv.c and i2c-nvidia-gpu.c.
+ */
+
+#include <linux/i2c.h>
+#include <linux/export.h>
+#include <linux/string.h>
+
+#include "i2c-ccgx-ucsi.h"
+
+struct software_node;
+
+struct i2c_client *i2c_new_ccgx_ucsi(struct i2c_adapter *adapter, int irq,
+				     const struct software_node *swnode)
+{
+	struct i2c_board_info info = {};
+
+	strscpy(info.type, "ccgx-ucsi", sizeof(info.type));
+	info.addr = 0x08;
+	info.irq = irq;
+	info.swnode = swnode;
+
+	return i2c_new_client_device(adapter, &info);
+}
+EXPORT_SYMBOL_GPL(i2c_new_ccgx_ucsi);
diff --git a/drivers/i2c/busses/i2c-ccgx-ucsi.h b/drivers/i2c/busses/i2c-ccgx-ucsi.h
new file mode 100644
index 000000000000..739ac7a4b117
--- /dev/null
+++ b/drivers/i2c/busses/i2c-ccgx-ucsi.h
@@ -0,0 +1,11 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef __I2C_CCGX_UCSI_H_
+#define __I2C_CCGX_UCSI_H_
+
+struct i2c_adapter;
+struct i2c_client;
+struct software_node;
+
+struct i2c_client *i2c_new_ccgx_ucsi(struct i2c_adapter *adapter, int irq,
+				     const struct software_node *swnode);
+#endif /* __I2C_CCGX_UCSI_H_ */