All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/1] Add MAX14526 MUIC driver
@ 2023-04-19 18:52 Svyatoslav Ryhel
  2023-04-19 18:52 ` [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support Svyatoslav Ryhel
  0 siblings, 1 reply; 9+ messages in thread
From: Svyatoslav Ryhel @ 2023-04-19 18:52 UTC (permalink / raw)
  To: Marek Vasut, Stefan Roese, Simon Glass, Svyatoslav Ryhel; +Cc: u-boot

MAX14526 MUIC is used by LG P880/P895 which are currently
in the process of merging.

Unfortunately U-Boot has no extcon driver model so I used
a MISC model for now.

MAX14526 is a powerful extcon device which has the ability to
accurately determine plugged devices. In this implementation
muic can be configured to represent 3 modes: CP-USB/UART and
AP-USB. Unfortunately AP-UART was disabled on P880/P895.
Additionally the driver configures some stuff required by
the charger.

Svyatoslav Ryhel (1):
  misc: extcon: add MAX14526 MUIC support

 drivers/misc/Kconfig                  |   2 +
 drivers/misc/Makefile                 |   1 +
 drivers/misc/extcon/Kconfig           |   8 ++
 drivers/misc/extcon/Makefile          |   2 +
 drivers/misc/extcon/extcon-max14526.c | 153 ++++++++++++++++++++++++++
 5 files changed, 166 insertions(+)
 create mode 100644 drivers/misc/extcon/Kconfig
 create mode 100644 drivers/misc/extcon/Makefile
 create mode 100644 drivers/misc/extcon/extcon-max14526.c

-- 
2.37.2


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

* [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support
  2023-04-19 18:52 [PATCH v1 0/1] Add MAX14526 MUIC driver Svyatoslav Ryhel
@ 2023-04-19 18:52 ` Svyatoslav Ryhel
  2023-04-19 22:40   ` Simon Glass
  0 siblings, 1 reply; 9+ messages in thread
From: Svyatoslav Ryhel @ 2023-04-19 18:52 UTC (permalink / raw)
  To: Marek Vasut, Stefan Roese, Simon Glass, Svyatoslav Ryhel; +Cc: u-boot

MAX14526 is a powerful extcon chip which allows detection of various
plugs like usb, mhl, uart, headset etc. This version of driver
implements support of AP-usb and CP-usb/uart paths.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # LG P880 T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/misc/Kconfig                  |   2 +
 drivers/misc/Makefile                 |   1 +
 drivers/misc/extcon/Kconfig           |   8 ++
 drivers/misc/extcon/Makefile          |   2 +
 drivers/misc/extcon/extcon-max14526.c | 153 ++++++++++++++++++++++++++
 5 files changed, 166 insertions(+)
 create mode 100644 drivers/misc/extcon/Kconfig
 create mode 100644 drivers/misc/extcon/Makefile
 create mode 100644 drivers/misc/extcon/extcon-max14526.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 4e1ae03e9f..1b49f3cf72 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -659,4 +659,6 @@ config SL28CPLD
 	  the base driver which provides common access methods for the
 	  sub-drivers.
 
+source "drivers/misc/extcon/Kconfig"
+
 endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 3b792f2a14..6d4fc8ddf9 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -87,3 +87,4 @@ obj-$(CONFIG_K3_AVS0) += k3_avs.o
 obj-$(CONFIG_ESM_K3) += k3_esm.o
 obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
 obj-$(CONFIG_SL28CPLD) += sl28cpld.o
+obj-y += extcon/
diff --git a/drivers/misc/extcon/Kconfig b/drivers/misc/extcon/Kconfig
new file mode 100644
index 0000000000..99c38224f3
--- /dev/null
+++ b/drivers/misc/extcon/Kconfig
@@ -0,0 +1,8 @@
+config EXTCON_MAX14526
+	bool "Maxim MAX14526 EXTCON Support"
+	select DM_I2C
+	select DM_MISC
+	help
+	  If you say yes here you get support for the MUIC device of
+	  Maxim MAX14526. The MAX14526 MUIC is a USB port accessory
+	  detector and switch.
diff --git a/drivers/misc/extcon/Makefile b/drivers/misc/extcon/Makefile
new file mode 100644
index 0000000000..f012b688ce
--- /dev/null
+++ b/drivers/misc/extcon/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0+
+obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o
diff --git a/drivers/misc/extcon/extcon-max14526.c b/drivers/misc/extcon/extcon-max14526.c
new file mode 100644
index 0000000000..c8505dae49
--- /dev/null
+++ b/drivers/misc/extcon/extcon-max14526.c
@@ -0,0 +1,153 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Svyatoslav Ryhel <clamor95@gmail.com>
+ *
+ * U-boot lacks extcon DM.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <i2c.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <log.h>
+#include <misc.h>
+#include <asm/gpio.h>
+
+#define CONTROL_1	0x01
+#define SW_CONTROL	0x03
+
+#define ID_200		0x10
+#define ADC_EN		0x02
+#define CP_EN		0x01
+
+#define DP_USB		0x00
+#define DP_UART		0x08
+#define DP_AUDIO	0x10
+#define DP_OPEN		0x38
+
+#define DM_USB		0x00
+#define DM_UART		0x01
+#define DM_AUDIO	0x02
+#define DM_OPEN		0x07
+
+#define AP_USB		BIT(0)
+#define CP_USB		BIT(1)
+#define CP_UART		BIT(2)
+
+struct max14526_priv {
+	struct gpio_desc usif_gpio;
+	struct gpio_desc dp2t_gpio;
+	struct gpio_desc ifx_usb_vbus_gpio;
+};
+
+static void max14526_set_mode(struct udevice *dev, int mode)
+{
+	struct max14526_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	if ((mode & AP_USB) || (mode & CP_USB)) {
+		/* Connect CP UART signals to AP */
+		ret = dm_gpio_set_value(&priv->usif_gpio, 0);
+		if (ret)
+			printf("%s: error changing usif-gpio (%d)\n", __func__, ret);
+	}
+
+	if (mode & CP_UART) {
+		/* Connect CP UART signals to DP2T */
+		ret = dm_gpio_set_value(&priv->usif_gpio, 1);
+		if (ret)
+			printf("%s: error changing usif-gpio (%d)\n", __func__, ret);
+	}
+
+	if (mode & CP_USB) {
+		/* Connect CP USB to MUIC UART */
+		ret = dm_gpio_set_value(&priv->ifx_usb_vbus_gpio, 1);
+		if (ret)
+			printf("%s: error changing usb-vbus-gpio (%d)\n", __func__, ret);
+
+		ret = dm_gpio_set_value(&priv->dp2t_gpio, 1);
+		if (ret)
+			printf("%s: error changing dp2t-gpio (%d)\n", __func__, ret);
+	}
+
+	if ((mode & AP_USB) || (mode & CP_UART)) {
+		/* Connect CP UART to MUIC UART */
+		ret = dm_gpio_set_value(&priv->dp2t_gpio, 0);
+		if (ret)
+			printf("%s: error changing dp2t-gpio (%d)\n", __func__, ret);
+	}
+
+	if (mode & AP_USB) {
+		/* Enables USB Path */
+		ret = dm_i2c_reg_write(dev, SW_CONTROL, DP_USB | DM_USB);
+		if (ret)
+			printf("USB Path set failed: %d\n", ret);
+	}
+
+	if ((mode & CP_USB) || (mode & CP_UART)) {
+		/* Enables UART Path */
+		ret = dm_i2c_reg_write(dev, SW_CONTROL, DP_UART | DM_UART);
+		if (ret)
+			printf("USB Path set failed: %d\n", ret);
+	}
+
+	/* Enables 200K, Charger Pump, and ADC */
+	ret = dm_i2c_reg_write(dev, CONTROL_1, ID_200 | ADC_EN | CP_EN);
+	if (ret)
+		printf("200K, Charger Pump, and ADC set failed: %d\n", ret);
+}
+
+static int max14526_probe(struct udevice *dev)
+{
+	struct max14526_priv *priv = dev_get_priv(dev);
+	int ret, mode = 0;
+
+	ret = gpio_request_by_name(dev, "usif-gpios", 0,
+				   &priv->usif_gpio, GPIOD_IS_OUT);
+	if (ret) {
+		printf("%s: Could not decode usif-gpios (%d)\n", __func__, ret);
+		return ret;
+	}
+
+	ret = gpio_request_by_name(dev, "dp2t-gpios", 0,
+				   &priv->dp2t_gpio, GPIOD_IS_OUT);
+	if (ret) {
+		printf("%s: Could not decode dp2t-gpios (%d)\n", __func__, ret);
+		return ret;
+	}
+
+	if (dev_read_bool(dev, "maxim,ap-usb"))
+		mode |= AP_USB;
+
+	if (dev_read_bool(dev, "maxim,cp-usb")) {
+		mode |= CP_USB;
+
+		ret = gpio_request_by_name(dev, "usb-vbus-gpios", 0,
+					   &priv->ifx_usb_vbus_gpio, GPIOD_IS_OUT);
+		if (ret) {
+			printf("%s: Could not decode usb-vbus-gpios (%d)\n", __func__, ret);
+			return ret;
+		}
+	}
+
+	if (dev_read_bool(dev, "maxim,cp-uart"))
+		mode |= CP_UART;
+
+	max14526_set_mode(dev, mode);
+
+	return 0;
+}
+
+static const struct udevice_id max14526_ids[] = {
+	{ .compatible = "maxim,max14526-muic" },
+	{ }
+};
+
+U_BOOT_DRIVER(extcon_max14526) = {
+	.name		= "extcon_max14526",
+	.id		= UCLASS_MISC,
+	.of_match	= max14526_ids,
+	.probe		= max14526_probe,
+	.priv_auto	= sizeof(struct max14526_priv),
+};
-- 
2.37.2


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

* Re: [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support
  2023-04-19 18:52 ` [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support Svyatoslav Ryhel
@ 2023-04-19 22:40   ` Simon Glass
  2023-04-20  6:00     ` Svyatoslav Ryhel
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Glass @ 2023-04-19 22:40 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: Marek Vasut, Stefan Roese, u-boot

Hi Svyatoslav,

On Wed, 19 Apr 2023 at 12:53, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
>
> MAX14526 is a powerful extcon chip which allows detection of various
> plugs like usb, mhl, uart, headset etc. This version of driver
> implements support of AP-usb and CP-usb/uart paths.
>
> Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # LG P880 T30
> Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
>  drivers/misc/Kconfig                  |   2 +
>  drivers/misc/Makefile                 |   1 +
>  drivers/misc/extcon/Kconfig           |   8 ++
>  drivers/misc/extcon/Makefile          |   2 +
>  drivers/misc/extcon/extcon-max14526.c | 153 ++++++++++++++++++++++++++
>  5 files changed, 166 insertions(+)
>  create mode 100644 drivers/misc/extcon/Kconfig
>  create mode 100644 drivers/misc/extcon/Makefile
>  create mode 100644 drivers/misc/extcon/extcon-max14526.c
>
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 4e1ae03e9f..1b49f3cf72 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -659,4 +659,6 @@ config SL28CPLD
>           the base driver which provides common access methods for the
>           sub-drivers.
>
> +source "drivers/misc/extcon/Kconfig"
> +
>  endmenu
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index 3b792f2a14..6d4fc8ddf9 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -87,3 +87,4 @@ obj-$(CONFIG_K3_AVS0) += k3_avs.o
>  obj-$(CONFIG_ESM_K3) += k3_esm.o
>  obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
>  obj-$(CONFIG_SL28CPLD) += sl28cpld.o
> +obj-y += extcon/
> diff --git a/drivers/misc/extcon/Kconfig b/drivers/misc/extcon/Kconfig
> new file mode 100644
> index 0000000000..99c38224f3
> --- /dev/null
> +++ b/drivers/misc/extcon/Kconfig
> @@ -0,0 +1,8 @@
> +config EXTCON_MAX14526
> +       bool "Maxim MAX14526 EXTCON Support"
> +       select DM_I2C
> +       select DM_MISC
> +       help
> +         If you say yes here you get support for the MUIC device of
> +         Maxim MAX14526. The MAX14526 MUIC is a USB port accessory
> +         detector and switch.
> diff --git a/drivers/misc/extcon/Makefile b/drivers/misc/extcon/Makefile
> new file mode 100644
> index 0000000000..f012b688ce
> --- /dev/null
> +++ b/drivers/misc/extcon/Makefile
> @@ -0,0 +1,2 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o
> diff --git a/drivers/misc/extcon/extcon-max14526.c b/drivers/misc/extcon/extcon-max14526.c
> new file mode 100644
> index 0000000000..c8505dae49
> --- /dev/null
> +++ b/drivers/misc/extcon/extcon-max14526.c
> @@ -0,0 +1,153 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2022 Svyatoslav Ryhel <clamor95@gmail.com>
> + *
> + * U-boot lacks extcon DM.

In that case I think it is best to add a new uclass for it.

Regards,
Simon

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

* Re: [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support
  2023-04-19 22:40   ` Simon Glass
@ 2023-04-20  6:00     ` Svyatoslav Ryhel
  2023-04-20 16:30       ` Simon Glass
  0 siblings, 1 reply; 9+ messages in thread
From: Svyatoslav Ryhel @ 2023-04-20  6:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Marek Vasut, Stefan Roese, u-boot

чт, 20 квіт. 2023 р. о 01:41 Simon Glass <sjg@chromium.org> пише:
>
> Hi Svyatoslav,
>
> On Wed, 19 Apr 2023 at 12:53, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> >
> > MAX14526 is a powerful extcon chip which allows detection of various
> > plugs like usb, mhl, uart, headset etc. This version of driver
> > implements support of AP-usb and CP-usb/uart paths.
> >
> > Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # LG P880 T30
> > Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > ---
> >  drivers/misc/Kconfig                  |   2 +
> >  drivers/misc/Makefile                 |   1 +
> >  drivers/misc/extcon/Kconfig           |   8 ++
> >  drivers/misc/extcon/Makefile          |   2 +
> >  drivers/misc/extcon/extcon-max14526.c | 153 ++++++++++++++++++++++++++
> >  5 files changed, 166 insertions(+)
> >  create mode 100644 drivers/misc/extcon/Kconfig
> >  create mode 100644 drivers/misc/extcon/Makefile
> >  create mode 100644 drivers/misc/extcon/extcon-max14526.c
> >
> > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> > index 4e1ae03e9f..1b49f3cf72 100644
> > --- a/drivers/misc/Kconfig
> > +++ b/drivers/misc/Kconfig
> > @@ -659,4 +659,6 @@ config SL28CPLD
> >           the base driver which provides common access methods for the
> >           sub-drivers.
> >
> > +source "drivers/misc/extcon/Kconfig"
> > +
> >  endmenu
> > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> > index 3b792f2a14..6d4fc8ddf9 100644
> > --- a/drivers/misc/Makefile
> > +++ b/drivers/misc/Makefile
> > @@ -87,3 +87,4 @@ obj-$(CONFIG_K3_AVS0) += k3_avs.o
> >  obj-$(CONFIG_ESM_K3) += k3_esm.o
> >  obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
> >  obj-$(CONFIG_SL28CPLD) += sl28cpld.o
> > +obj-y += extcon/
> > diff --git a/drivers/misc/extcon/Kconfig b/drivers/misc/extcon/Kconfig
> > new file mode 100644
> > index 0000000000..99c38224f3
> > --- /dev/null
> > +++ b/drivers/misc/extcon/Kconfig
> > @@ -0,0 +1,8 @@
> > +config EXTCON_MAX14526
> > +       bool "Maxim MAX14526 EXTCON Support"
> > +       select DM_I2C
> > +       select DM_MISC
> > +       help
> > +         If you say yes here you get support for the MUIC device of
> > +         Maxim MAX14526. The MAX14526 MUIC is a USB port accessory
> > +         detector and switch.
> > diff --git a/drivers/misc/extcon/Makefile b/drivers/misc/extcon/Makefile
> > new file mode 100644
> > index 0000000000..f012b688ce
> > --- /dev/null
> > +++ b/drivers/misc/extcon/Makefile
> > @@ -0,0 +1,2 @@
> > +# SPDX-License-Identifier: GPL-2.0+
> > +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o
> > diff --git a/drivers/misc/extcon/extcon-max14526.c b/drivers/misc/extcon/extcon-max14526.c
> > new file mode 100644
> > index 0000000000..c8505dae49
> > --- /dev/null
> > +++ b/drivers/misc/extcon/extcon-max14526.c
> > @@ -0,0 +1,153 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Copyright (c) 2022 Svyatoslav Ryhel <clamor95@gmail.com>
> > + *
> > + * U-boot lacks extcon DM.
>
> In that case I think it is best to add a new uclass for it.
>
> Regards,
> Simon

Thank you, Simon!

First of all, thanks for your reviews, all of them apart from those I have
responded to are fairly reasonable and will be implemented.

About extcon uclass. My vision is to leave this driver as is in misc for
some time and check if there will be any other extcon devices added.
In case these devices become at least sometimes used on supported
devices there will be good reasons to create a new uclass. As for now,
it is a bit pointless to waste time for a new uclass and new framework for
only one device used by one board.

Best regards,
Svyatoslav R.

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

* Re: [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support
  2023-04-20  6:00     ` Svyatoslav Ryhel
@ 2023-04-20 16:30       ` Simon Glass
  2023-04-20 16:53         ` Svyatoslav Ryhel
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Glass @ 2023-04-20 16:30 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: Marek Vasut, Stefan Roese, u-boot

Hi Svyatoslav,

On Thu, 20 Apr 2023 at 18:01, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
>
> чт, 20 квіт. 2023 р. о 01:41 Simon Glass <sjg@chromium.org> пише:
> >
> > Hi Svyatoslav,
> >
> > On Wed, 19 Apr 2023 at 12:53, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> > >
> > > MAX14526 is a powerful extcon chip which allows detection of various
> > > plugs like usb, mhl, uart, headset etc. This version of driver
> > > implements support of AP-usb and CP-usb/uart paths.
> > >
> > > Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # LG P880 T30
> > > Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
> > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > ---
> > >  drivers/misc/Kconfig                  |   2 +
> > >  drivers/misc/Makefile                 |   1 +
> > >  drivers/misc/extcon/Kconfig           |   8 ++
> > >  drivers/misc/extcon/Makefile          |   2 +
> > >  drivers/misc/extcon/extcon-max14526.c | 153 ++++++++++++++++++++++++++
> > >  5 files changed, 166 insertions(+)
> > >  create mode 100644 drivers/misc/extcon/Kconfig
> > >  create mode 100644 drivers/misc/extcon/Makefile
> > >  create mode 100644 drivers/misc/extcon/extcon-max14526.c
> > >
> > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> > > index 4e1ae03e9f..1b49f3cf72 100644
> > > --- a/drivers/misc/Kconfig
> > > +++ b/drivers/misc/Kconfig
> > > @@ -659,4 +659,6 @@ config SL28CPLD
> > >           the base driver which provides common access methods for the
> > >           sub-drivers.
> > >
> > > +source "drivers/misc/extcon/Kconfig"
> > > +
> > >  endmenu
> > > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> > > index 3b792f2a14..6d4fc8ddf9 100644
> > > --- a/drivers/misc/Makefile
> > > +++ b/drivers/misc/Makefile
> > > @@ -87,3 +87,4 @@ obj-$(CONFIG_K3_AVS0) += k3_avs.o
> > >  obj-$(CONFIG_ESM_K3) += k3_esm.o
> > >  obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
> > >  obj-$(CONFIG_SL28CPLD) += sl28cpld.o
> > > +obj-y += extcon/
> > > diff --git a/drivers/misc/extcon/Kconfig b/drivers/misc/extcon/Kconfig
> > > new file mode 100644
> > > index 0000000000..99c38224f3
> > > --- /dev/null
> > > +++ b/drivers/misc/extcon/Kconfig
> > > @@ -0,0 +1,8 @@
> > > +config EXTCON_MAX14526
> > > +       bool "Maxim MAX14526 EXTCON Support"
> > > +       select DM_I2C
> > > +       select DM_MISC
> > > +       help
> > > +         If you say yes here you get support for the MUIC device of
> > > +         Maxim MAX14526. The MAX14526 MUIC is a USB port accessory
> > > +         detector and switch.
> > > diff --git a/drivers/misc/extcon/Makefile b/drivers/misc/extcon/Makefile
> > > new file mode 100644
> > > index 0000000000..f012b688ce
> > > --- /dev/null
> > > +++ b/drivers/misc/extcon/Makefile
> > > @@ -0,0 +1,2 @@
> > > +# SPDX-License-Identifier: GPL-2.0+
> > > +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o
> > > diff --git a/drivers/misc/extcon/extcon-max14526.c b/drivers/misc/extcon/extcon-max14526.c
> > > new file mode 100644
> > > index 0000000000..c8505dae49
> > > --- /dev/null
> > > +++ b/drivers/misc/extcon/extcon-max14526.c
> > > @@ -0,0 +1,153 @@
> > > +// SPDX-License-Identifier: GPL-2.0+
> > > +/*
> > > + * Copyright (c) 2022 Svyatoslav Ryhel <clamor95@gmail.com>
> > > + *
> > > + * U-boot lacks extcon DM.
> >
> > In that case I think it is best to add a new uclass for it.
> >
> > Regards,
> > Simon
>
> Thank you, Simon!
>
> First of all, thanks for your reviews, all of them apart from those I have
> responded to are fairly reasonable and will be implemented.
>
> About extcon uclass. My vision is to leave this driver as is in misc for
> some time and check if there will be any other extcon devices added.
> In case these devices become at least sometimes used on supported
> devices there will be good reasons to create a new uclass. As for now,
> it is a bit pointless to waste time for a new uclass and new framework for
> only one device used by one board.

I am sure there will be more.

The problem with accepting this patch as is, is that the burden of
creating the uclass (which is actually not that large at all) falls on
the second driver submitter, as well as the burden of converting your
driver. In practice what happens is that no one can be bothered.

See UCLASS_PCH for a simple uclass. You just need to define the API
(which may just be empty), any uclass-private struct then add
something to test.dst and a simple test to test/dm/extcon.c

Regards

Simon

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

* Re: [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support
  2023-04-20 16:30       ` Simon Glass
@ 2023-04-20 16:53         ` Svyatoslav Ryhel
  2023-04-21 16:30           ` Tim Harvey
  0 siblings, 1 reply; 9+ messages in thread
From: Svyatoslav Ryhel @ 2023-04-20 16:53 UTC (permalink / raw)
  To: Simon Glass; +Cc: Marek Vasut, Stefan Roese, u-boot

чт, 20 квіт. 2023 р. о 19:30 Simon Glass <sjg@chromium.org> пише:
>
> Hi Svyatoslav,
>
> On Thu, 20 Apr 2023 at 18:01, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> >
> > чт, 20 квіт. 2023 р. о 01:41 Simon Glass <sjg@chromium.org> пише:
> > >
> > > Hi Svyatoslav,
> > >
> > > On Wed, 19 Apr 2023 at 12:53, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> > > >
> > > > MAX14526 is a powerful extcon chip which allows detection of various
> > > > plugs like usb, mhl, uart, headset etc. This version of driver
> > > > implements support of AP-usb and CP-usb/uart paths.
> > > >
> > > > Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # LG P880 T30
> > > > Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
> > > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > ---
> > > >  drivers/misc/Kconfig                  |   2 +
> > > >  drivers/misc/Makefile                 |   1 +
> > > >  drivers/misc/extcon/Kconfig           |   8 ++
> > > >  drivers/misc/extcon/Makefile          |   2 +
> > > >  drivers/misc/extcon/extcon-max14526.c | 153 ++++++++++++++++++++++++++
> > > >  5 files changed, 166 insertions(+)
> > > >  create mode 100644 drivers/misc/extcon/Kconfig
> > > >  create mode 100644 drivers/misc/extcon/Makefile
> > > >  create mode 100644 drivers/misc/extcon/extcon-max14526.c
> > > >
> > > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> > > > index 4e1ae03e9f..1b49f3cf72 100644
> > > > --- a/drivers/misc/Kconfig
> > > > +++ b/drivers/misc/Kconfig
> > > > @@ -659,4 +659,6 @@ config SL28CPLD
> > > >           the base driver which provides common access methods for the
> > > >           sub-drivers.
> > > >
> > > > +source "drivers/misc/extcon/Kconfig"
> > > > +
> > > >  endmenu
> > > > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> > > > index 3b792f2a14..6d4fc8ddf9 100644
> > > > --- a/drivers/misc/Makefile
> > > > +++ b/drivers/misc/Makefile
> > > > @@ -87,3 +87,4 @@ obj-$(CONFIG_K3_AVS0) += k3_avs.o
> > > >  obj-$(CONFIG_ESM_K3) += k3_esm.o
> > > >  obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
> > > >  obj-$(CONFIG_SL28CPLD) += sl28cpld.o
> > > > +obj-y += extcon/
> > > > diff --git a/drivers/misc/extcon/Kconfig b/drivers/misc/extcon/Kconfig
> > > > new file mode 100644
> > > > index 0000000000..99c38224f3
> > > > --- /dev/null
> > > > +++ b/drivers/misc/extcon/Kconfig
> > > > @@ -0,0 +1,8 @@
> > > > +config EXTCON_MAX14526
> > > > +       bool "Maxim MAX14526 EXTCON Support"
> > > > +       select DM_I2C
> > > > +       select DM_MISC
> > > > +       help
> > > > +         If you say yes here you get support for the MUIC device of
> > > > +         Maxim MAX14526. The MAX14526 MUIC is a USB port accessory
> > > > +         detector and switch.
> > > > diff --git a/drivers/misc/extcon/Makefile b/drivers/misc/extcon/Makefile
> > > > new file mode 100644
> > > > index 0000000000..f012b688ce
> > > > --- /dev/null
> > > > +++ b/drivers/misc/extcon/Makefile
> > > > @@ -0,0 +1,2 @@
> > > > +# SPDX-License-Identifier: GPL-2.0+
> > > > +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o
> > > > diff --git a/drivers/misc/extcon/extcon-max14526.c b/drivers/misc/extcon/extcon-max14526.c
> > > > new file mode 100644
> > > > index 0000000000..c8505dae49
> > > > --- /dev/null
> > > > +++ b/drivers/misc/extcon/extcon-max14526.c
> > > > @@ -0,0 +1,153 @@
> > > > +// SPDX-License-Identifier: GPL-2.0+
> > > > +/*
> > > > + * Copyright (c) 2022 Svyatoslav Ryhel <clamor95@gmail.com>
> > > > + *
> > > > + * U-boot lacks extcon DM.
> > >
> > > In that case I think it is best to add a new uclass for it.
> > >
> > > Regards,
> > > Simon
> >
> > Thank you, Simon!
> >
> > First of all, thanks for your reviews, all of them apart from those I have
> > responded to are fairly reasonable and will be implemented.
> >
> > About extcon uclass. My vision is to leave this driver as is in misc for
> > some time and check if there will be any other extcon devices added.
> > In case these devices become at least sometimes used on supported
> > devices there will be good reasons to create a new uclass. As for now,
> > it is a bit pointless to waste time for a new uclass and new framework for
> > only one device used by one board.
>
> I am sure there will be more.
>
> The problem with accepting this patch as is, is that the burden of
> creating the uclass (which is actually not that large at all) falls on
> the second driver submitter, as well as the burden of converting your
> driver. In practice what happens is that no one can be bothered.
>
> See UCLASS_PCH for a simple uclass. You just need to define the API
> (which may just be empty), any uclass-private struct then add
> something to test.dst and a simple test to test/dm/extcon.c
>
> Regards
>
> Simon

Ok, I will look into this a bit deeper

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

* Re: [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support
  2023-04-20 16:53         ` Svyatoslav Ryhel
@ 2023-04-21 16:30           ` Tim Harvey
  2023-04-21 16:36             ` Svyatoslav Ryhel
  0 siblings, 1 reply; 9+ messages in thread
From: Tim Harvey @ 2023-04-21 16:30 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: Simon Glass, Marek Vasut, Stefan Roese, u-boot

On Thu, Apr 20, 2023 at 9:54 AM Svyatoslav Ryhel <clamor95@gmail.com> wrote:
>
> чт, 20 квіт. 2023 р. о 19:30 Simon Glass <sjg@chromium.org> пише:
> >
> > Hi Svyatoslav,
> >
> > On Thu, 20 Apr 2023 at 18:01, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> > >
> > > чт, 20 квіт. 2023 р. о 01:41 Simon Glass <sjg@chromium.org> пише:
> > > >
> > > > Hi Svyatoslav,
> > > >
> > > > On Wed, 19 Apr 2023 at 12:53, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> > > > >
> > > > > MAX14526 is a powerful extcon chip which allows detection of various
> > > > > plugs like usb, mhl, uart, headset etc. This version of driver
> > > > > implements support of AP-usb and CP-usb/uart paths.
> > > > >
> > > > > Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # LG P880 T30
> > > > > Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
> > > > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > > ---
> > > > >  drivers/misc/Kconfig                  |   2 +
> > > > >  drivers/misc/Makefile                 |   1 +
> > > > >  drivers/misc/extcon/Kconfig           |   8 ++
> > > > >  drivers/misc/extcon/Makefile          |   2 +
> > > > >  drivers/misc/extcon/extcon-max14526.c | 153 ++++++++++++++++++++++++++
> > > > >  5 files changed, 166 insertions(+)
> > > > >  create mode 100644 drivers/misc/extcon/Kconfig
> > > > >  create mode 100644 drivers/misc/extcon/Makefile
> > > > >  create mode 100644 drivers/misc/extcon/extcon-max14526.c
> > > > >
> > > > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> > > > > index 4e1ae03e9f..1b49f3cf72 100644
> > > > > --- a/drivers/misc/Kconfig
> > > > > +++ b/drivers/misc/Kconfig
> > > > > @@ -659,4 +659,6 @@ config SL28CPLD
> > > > >           the base driver which provides common access methods for the
> > > > >           sub-drivers.
> > > > >
> > > > > +source "drivers/misc/extcon/Kconfig"
> > > > > +
> > > > >  endmenu
> > > > > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> > > > > index 3b792f2a14..6d4fc8ddf9 100644
> > > > > --- a/drivers/misc/Makefile
> > > > > +++ b/drivers/misc/Makefile
> > > > > @@ -87,3 +87,4 @@ obj-$(CONFIG_K3_AVS0) += k3_avs.o
> > > > >  obj-$(CONFIG_ESM_K3) += k3_esm.o
> > > > >  obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
> > > > >  obj-$(CONFIG_SL28CPLD) += sl28cpld.o
> > > > > +obj-y += extcon/
> > > > > diff --git a/drivers/misc/extcon/Kconfig b/drivers/misc/extcon/Kconfig
> > > > > new file mode 100644
> > > > > index 0000000000..99c38224f3
> > > > > --- /dev/null
> > > > > +++ b/drivers/misc/extcon/Kconfig
> > > > > @@ -0,0 +1,8 @@
> > > > > +config EXTCON_MAX14526
> > > > > +       bool "Maxim MAX14526 EXTCON Support"
> > > > > +       select DM_I2C
> > > > > +       select DM_MISC
> > > > > +       help
> > > > > +         If you say yes here you get support for the MUIC device of
> > > > > +         Maxim MAX14526. The MAX14526 MUIC is a USB port accessory
> > > > > +         detector and switch.
> > > > > diff --git a/drivers/misc/extcon/Makefile b/drivers/misc/extcon/Makefile
> > > > > new file mode 100644
> > > > > index 0000000000..f012b688ce
> > > > > --- /dev/null
> > > > > +++ b/drivers/misc/extcon/Makefile
> > > > > @@ -0,0 +1,2 @@
> > > > > +# SPDX-License-Identifier: GPL-2.0+
> > > > > +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o
> > > > > diff --git a/drivers/misc/extcon/extcon-max14526.c b/drivers/misc/extcon/extcon-max14526.c
> > > > > new file mode 100644
> > > > > index 0000000000..c8505dae49
> > > > > --- /dev/null
> > > > > +++ b/drivers/misc/extcon/extcon-max14526.c
> > > > > @@ -0,0 +1,153 @@
> > > > > +// SPDX-License-Identifier: GPL-2.0+
> > > > > +/*
> > > > > + * Copyright (c) 2022 Svyatoslav Ryhel <clamor95@gmail.com>
> > > > > + *
> > > > > + * U-boot lacks extcon DM.
> > > >
> > > > In that case I think it is best to add a new uclass for it.
> > > >
> > > > Regards,
> > > > Simon
> > >
> > > Thank you, Simon!
> > >
> > > First of all, thanks for your reviews, all of them apart from those I have
> > > responded to are fairly reasonable and will be implemented.
> > >
> > > About extcon uclass. My vision is to leave this driver as is in misc for
> > > some time and check if there will be any other extcon devices added.
> > > In case these devices become at least sometimes used on supported
> > > devices there will be good reasons to create a new uclass. As for now,
> > > it is a bit pointless to waste time for a new uclass and new framework for
> > > only one device used by one board.
> >
> > I am sure there will be more.
> >
> > The problem with accepting this patch as is, is that the burden of
> > creating the uclass (which is actually not that large at all) falls on
> > the second driver submitter, as well as the burden of converting your
> > driver. In practice what happens is that no one can be bothered.
> >
> > See UCLASS_PCH for a simple uclass. You just need to define the API
> > (which may just be empty), any uclass-private struct then add
> > something to test.dst and a simple test to test/dm/extcon.c
> >
> > Regards
> >
> > Simon
>
> Ok, I will look into this a bit deeper

Svyatoslav,

I agree with Simon and would like to see a uclass. We do have the need
for a U-Boot driver that supports gpio based USB ID such as Linux
drivers/usb/common/usb-conn-gpio.c (compatible "gpio-usb-b-connector")
and drivers/extcon/extcon-usb-gpio.c (compatible
"linux,extcon-usb-gpio") (which I believe is deprecated) as there are
many usb controllers that use this that appear unsupported for
role-switch in U-Boot today.

Best Regards,

Tim

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

* Re: [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support
  2023-04-21 16:30           ` Tim Harvey
@ 2023-04-21 16:36             ` Svyatoslav Ryhel
  2023-04-21 20:13               ` Tim Harvey
  0 siblings, 1 reply; 9+ messages in thread
From: Svyatoslav Ryhel @ 2023-04-21 16:36 UTC (permalink / raw)
  To: Tim Harvey; +Cc: Simon Glass, Marek Vasut, Stefan Roese, u-boot

пт, 21 квіт. 2023 р. о 19:30 Tim Harvey <tharvey@gateworks.com> пише:
>
> On Thu, Apr 20, 2023 at 9:54 AM Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> >
> > чт, 20 квіт. 2023 р. о 19:30 Simon Glass <sjg@chromium.org> пише:
> > >
> > > Hi Svyatoslav,
> > >
> > > On Thu, 20 Apr 2023 at 18:01, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> > > >
> > > > чт, 20 квіт. 2023 р. о 01:41 Simon Glass <sjg@chromium.org> пише:
> > > > >
> > > > > Hi Svyatoslav,
> > > > >
> > > > > On Wed, 19 Apr 2023 at 12:53, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> > > > > >
> > > > > > MAX14526 is a powerful extcon chip which allows detection of various
> > > > > > plugs like usb, mhl, uart, headset etc. This version of driver
> > > > > > implements support of AP-usb and CP-usb/uart paths.
> > > > > >
> > > > > > Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # LG P880 T30
> > > > > > Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
> > > > > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > > > ---
> > > > > >  drivers/misc/Kconfig                  |   2 +
> > > > > >  drivers/misc/Makefile                 |   1 +
> > > > > >  drivers/misc/extcon/Kconfig           |   8 ++
> > > > > >  drivers/misc/extcon/Makefile          |   2 +
> > > > > >  drivers/misc/extcon/extcon-max14526.c | 153 ++++++++++++++++++++++++++
> > > > > >  5 files changed, 166 insertions(+)
> > > > > >  create mode 100644 drivers/misc/extcon/Kconfig
> > > > > >  create mode 100644 drivers/misc/extcon/Makefile
> > > > > >  create mode 100644 drivers/misc/extcon/extcon-max14526.c
> > > > > >
> > > > > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> > > > > > index 4e1ae03e9f..1b49f3cf72 100644
> > > > > > --- a/drivers/misc/Kconfig
> > > > > > +++ b/drivers/misc/Kconfig
> > > > > > @@ -659,4 +659,6 @@ config SL28CPLD
> > > > > >           the base driver which provides common access methods for the
> > > > > >           sub-drivers.
> > > > > >
> > > > > > +source "drivers/misc/extcon/Kconfig"
> > > > > > +
> > > > > >  endmenu
> > > > > > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> > > > > > index 3b792f2a14..6d4fc8ddf9 100644
> > > > > > --- a/drivers/misc/Makefile
> > > > > > +++ b/drivers/misc/Makefile
> > > > > > @@ -87,3 +87,4 @@ obj-$(CONFIG_K3_AVS0) += k3_avs.o
> > > > > >  obj-$(CONFIG_ESM_K3) += k3_esm.o
> > > > > >  obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
> > > > > >  obj-$(CONFIG_SL28CPLD) += sl28cpld.o
> > > > > > +obj-y += extcon/
> > > > > > diff --git a/drivers/misc/extcon/Kconfig b/drivers/misc/extcon/Kconfig
> > > > > > new file mode 100644
> > > > > > index 0000000000..99c38224f3
> > > > > > --- /dev/null
> > > > > > +++ b/drivers/misc/extcon/Kconfig
> > > > > > @@ -0,0 +1,8 @@
> > > > > > +config EXTCON_MAX14526
> > > > > > +       bool "Maxim MAX14526 EXTCON Support"
> > > > > > +       select DM_I2C
> > > > > > +       select DM_MISC
> > > > > > +       help
> > > > > > +         If you say yes here you get support for the MUIC device of
> > > > > > +         Maxim MAX14526. The MAX14526 MUIC is a USB port accessory
> > > > > > +         detector and switch.
> > > > > > diff --git a/drivers/misc/extcon/Makefile b/drivers/misc/extcon/Makefile
> > > > > > new file mode 100644
> > > > > > index 0000000000..f012b688ce
> > > > > > --- /dev/null
> > > > > > +++ b/drivers/misc/extcon/Makefile
> > > > > > @@ -0,0 +1,2 @@
> > > > > > +# SPDX-License-Identifier: GPL-2.0+
> > > > > > +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o
> > > > > > diff --git a/drivers/misc/extcon/extcon-max14526.c b/drivers/misc/extcon/extcon-max14526.c
> > > > > > new file mode 100644
> > > > > > index 0000000000..c8505dae49
> > > > > > --- /dev/null
> > > > > > +++ b/drivers/misc/extcon/extcon-max14526.c
> > > > > > @@ -0,0 +1,153 @@
> > > > > > +// SPDX-License-Identifier: GPL-2.0+
> > > > > > +/*
> > > > > > + * Copyright (c) 2022 Svyatoslav Ryhel <clamor95@gmail.com>
> > > > > > + *
> > > > > > + * U-boot lacks extcon DM.
> > > > >
> > > > > In that case I think it is best to add a new uclass for it.
> > > > >
> > > > > Regards,
> > > > > Simon
> > > >
> > > > Thank you, Simon!
> > > >
> > > > First of all, thanks for your reviews, all of them apart from those I have
> > > > responded to are fairly reasonable and will be implemented.
> > > >
> > > > About extcon uclass. My vision is to leave this driver as is in misc for
> > > > some time and check if there will be any other extcon devices added.
> > > > In case these devices become at least sometimes used on supported
> > > > devices there will be good reasons to create a new uclass. As for now,
> > > > it is a bit pointless to waste time for a new uclass and new framework for
> > > > only one device used by one board.
> > >
> > > I am sure there will be more.
> > >
> > > The problem with accepting this patch as is, is that the burden of
> > > creating the uclass (which is actually not that large at all) falls on
> > > the second driver submitter, as well as the burden of converting your
> > > driver. In practice what happens is that no one can be bothered.
> > >
> > > See UCLASS_PCH for a simple uclass. You just need to define the API
> > > (which may just be empty), any uclass-private struct then add
> > > something to test.dst and a simple test to test/dm/extcon.c
> > >
> > > Regards
> > >
> > > Simon
> >
> > Ok, I will look into this a bit deeper
>
> Svyatoslav,
>
> I agree with Simon and would like to see a uclass. We do have the need
> for a U-Boot driver that supports gpio based USB ID such as Linux
> drivers/usb/common/usb-conn-gpio.c (compatible "gpio-usb-b-connector")
> and drivers/extcon/extcon-usb-gpio.c (compatible
> "linux,extcon-usb-gpio") (which I believe is deprecated) as there are
> many usb controllers that use this that appear unsupported for
> role-switch in U-Boot today.
>
> Best Regards,
>
> Tim

Tim,

I have implemented simple extcon uclass in v3 iteration. As for now it has
empty platform struct and no ops but those will be added once required.

Best regards,
Svyatoslav R.

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

* Re: [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support
  2023-04-21 16:36             ` Svyatoslav Ryhel
@ 2023-04-21 20:13               ` Tim Harvey
  0 siblings, 0 replies; 9+ messages in thread
From: Tim Harvey @ 2023-04-21 20:13 UTC (permalink / raw)
  To: Svyatoslav Ryhel, Marek Vasut; +Cc: Simon Glass, Stefan Roese, u-boot

On Fri, Apr 21, 2023 at 9:36 AM Svyatoslav Ryhel <clamor95@gmail.com> wrote:
>
> пт, 21 квіт. 2023 р. о 19:30 Tim Harvey <tharvey@gateworks.com> пише:
> >
> > On Thu, Apr 20, 2023 at 9:54 AM Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> > >
> > > чт, 20 квіт. 2023 р. о 19:30 Simon Glass <sjg@chromium.org> пише:
> > > >
> > > > Hi Svyatoslav,
> > > >
> > > > On Thu, 20 Apr 2023 at 18:01, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> > > > >
> > > > > чт, 20 квіт. 2023 р. о 01:41 Simon Glass <sjg@chromium.org> пише:
> > > > > >
> > > > > > Hi Svyatoslav,
> > > > > >
> > > > > > On Wed, 19 Apr 2023 at 12:53, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> > > > > > >
> > > > > > > MAX14526 is a powerful extcon chip which allows detection of various
> > > > > > > plugs like usb, mhl, uart, headset etc. This version of driver
> > > > > > > implements support of AP-usb and CP-usb/uart paths.
> > > > > > >
> > > > > > > Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # LG P880 T30
> > > > > > > Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
> > > > > > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > > > > ---
> > > > > > >  drivers/misc/Kconfig                  |   2 +
> > > > > > >  drivers/misc/Makefile                 |   1 +
> > > > > > >  drivers/misc/extcon/Kconfig           |   8 ++
> > > > > > >  drivers/misc/extcon/Makefile          |   2 +
> > > > > > >  drivers/misc/extcon/extcon-max14526.c | 153 ++++++++++++++++++++++++++
> > > > > > >  5 files changed, 166 insertions(+)
> > > > > > >  create mode 100644 drivers/misc/extcon/Kconfig
> > > > > > >  create mode 100644 drivers/misc/extcon/Makefile
> > > > > > >  create mode 100644 drivers/misc/extcon/extcon-max14526.c
> > > > > > >
> > > > > > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> > > > > > > index 4e1ae03e9f..1b49f3cf72 100644
> > > > > > > --- a/drivers/misc/Kconfig
> > > > > > > +++ b/drivers/misc/Kconfig
> > > > > > > @@ -659,4 +659,6 @@ config SL28CPLD
> > > > > > >           the base driver which provides common access methods for the
> > > > > > >           sub-drivers.
> > > > > > >
> > > > > > > +source "drivers/misc/extcon/Kconfig"
> > > > > > > +
> > > > > > >  endmenu
> > > > > > > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> > > > > > > index 3b792f2a14..6d4fc8ddf9 100644
> > > > > > > --- a/drivers/misc/Makefile
> > > > > > > +++ b/drivers/misc/Makefile
> > > > > > > @@ -87,3 +87,4 @@ obj-$(CONFIG_K3_AVS0) += k3_avs.o
> > > > > > >  obj-$(CONFIG_ESM_K3) += k3_esm.o
> > > > > > >  obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
> > > > > > >  obj-$(CONFIG_SL28CPLD) += sl28cpld.o
> > > > > > > +obj-y += extcon/
> > > > > > > diff --git a/drivers/misc/extcon/Kconfig b/drivers/misc/extcon/Kconfig
> > > > > > > new file mode 100644
> > > > > > > index 0000000000..99c38224f3
> > > > > > > --- /dev/null
> > > > > > > +++ b/drivers/misc/extcon/Kconfig
> > > > > > > @@ -0,0 +1,8 @@
> > > > > > > +config EXTCON_MAX14526
> > > > > > > +       bool "Maxim MAX14526 EXTCON Support"
> > > > > > > +       select DM_I2C
> > > > > > > +       select DM_MISC
> > > > > > > +       help
> > > > > > > +         If you say yes here you get support for the MUIC device of
> > > > > > > +         Maxim MAX14526. The MAX14526 MUIC is a USB port accessory
> > > > > > > +         detector and switch.
> > > > > > > diff --git a/drivers/misc/extcon/Makefile b/drivers/misc/extcon/Makefile
> > > > > > > new file mode 100644
> > > > > > > index 0000000000..f012b688ce
> > > > > > > --- /dev/null
> > > > > > > +++ b/drivers/misc/extcon/Makefile
> > > > > > > @@ -0,0 +1,2 @@
> > > > > > > +# SPDX-License-Identifier: GPL-2.0+
> > > > > > > +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o
> > > > > > > diff --git a/drivers/misc/extcon/extcon-max14526.c b/drivers/misc/extcon/extcon-max14526.c
> > > > > > > new file mode 100644
> > > > > > > index 0000000000..c8505dae49
> > > > > > > --- /dev/null
> > > > > > > +++ b/drivers/misc/extcon/extcon-max14526.c
> > > > > > > @@ -0,0 +1,153 @@
> > > > > > > +// SPDX-License-Identifier: GPL-2.0+
> > > > > > > +/*
> > > > > > > + * Copyright (c) 2022 Svyatoslav Ryhel <clamor95@gmail.com>
> > > > > > > + *
> > > > > > > + * U-boot lacks extcon DM.
> > > > > >
> > > > > > In that case I think it is best to add a new uclass for it.
> > > > > >
> > > > > > Regards,
> > > > > > Simon
> > > > >
> > > > > Thank you, Simon!
> > > > >
> > > > > First of all, thanks for your reviews, all of them apart from those I have
> > > > > responded to are fairly reasonable and will be implemented.
> > > > >
> > > > > About extcon uclass. My vision is to leave this driver as is in misc for
> > > > > some time and check if there will be any other extcon devices added.
> > > > > In case these devices become at least sometimes used on supported
> > > > > devices there will be good reasons to create a new uclass. As for now,
> > > > > it is a bit pointless to waste time for a new uclass and new framework for
> > > > > only one device used by one board.
> > > >
> > > > I am sure there will be more.
> > > >
> > > > The problem with accepting this patch as is, is that the burden of
> > > > creating the uclass (which is actually not that large at all) falls on
> > > > the second driver submitter, as well as the burden of converting your
> > > > driver. In practice what happens is that no one can be bothered.
> > > >
> > > > See UCLASS_PCH for a simple uclass. You just need to define the API
> > > > (which may just be empty), any uclass-private struct then add
> > > > something to test.dst and a simple test to test/dm/extcon.c
> > > >
> > > > Regards
> > > >
> > > > Simon
> > >
> > > Ok, I will look into this a bit deeper
> >
> > Svyatoslav,
> >
> > I agree with Simon and would like to see a uclass. We do have the need
> > for a U-Boot driver that supports gpio based USB ID such as Linux
> > drivers/usb/common/usb-conn-gpio.c (compatible "gpio-usb-b-connector")
> > and drivers/extcon/extcon-usb-gpio.c (compatible
> > "linux,extcon-usb-gpio") (which I believe is deprecated) as there are
> > many usb controllers that use this that appear unsupported for
> > role-switch in U-Boot today.
> >
> > Best Regards,
> >
> > Tim
>
> Tim,
>
> I have implemented simple extcon uclass in v3 iteration. As for now it has
> empty platform struct and no ops but those will be added once required.
>
> Best regards,
> Svyatoslav R.

Marek,

Is there any common API in U-Boot USB controller drivers for role
selection that would lend itself to an extcon uclass driver? I'm only
familiar with ehci-mx6 which has an internal register mapped to a
dedicated ID pin and not clear what the other dual-role USB host
controllers use for role determination.

Best Regards,

Tim

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

end of thread, other threads:[~2023-04-21 20:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-19 18:52 [PATCH v1 0/1] Add MAX14526 MUIC driver Svyatoslav Ryhel
2023-04-19 18:52 ` [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support Svyatoslav Ryhel
2023-04-19 22:40   ` Simon Glass
2023-04-20  6:00     ` Svyatoslav Ryhel
2023-04-20 16:30       ` Simon Glass
2023-04-20 16:53         ` Svyatoslav Ryhel
2023-04-21 16:30           ` Tim Harvey
2023-04-21 16:36             ` Svyatoslav Ryhel
2023-04-21 20:13               ` Tim Harvey

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.