extcon: add basic Maxim MAX14526 MUIC support
Subsystems (2)
v2 cover extcon: add basic Maxim MAX14526 MUIC support
The MAX14526 is a simple multiplexer of common inputs on a single mini/micro USB for portable devices.
---
Changes on switching from v1 to v2:
- added port and connector to schema
- removed -muic suffix
- removed unneded comment header
- removed unneded gpios in private data
- improved code formatting
---
Svyatoslav Ryhel (2):
dt-bindings: extcon: Document Maxim MAX14526 MUIC
extcon: Add basic support for Maxim MAX14526 MUIC
.../bindings/extcon/maxim,max14526.yaml | 80 +++++ drivers/extcon/Kconfig | 12 + drivers/extcon/Makefile | 1 + drivers/extcon/extcon-max14526.c | 301 ++++++++++++++++++ 4 files changed, 394 insertions(+) create mode 100644 Documentation/devicetree/bindings/extcon/maxim,max14526.yaml create mode 100644 drivers/extcon/extcon-max14526.c
Signature · 1 line
2.43.0
PATCH v2 1/2 dt-bindings: extcon: Document Maxim MAX14526 MUIC
Add bindings for Maxim MAX14526 MicroUSB Integrated Circuit.
--- .../bindings/extcon/maxim,max14526.yaml | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/extcon/maxim,max14526.yaml
Documentation/devicetree/bindings/extcon/maxim,max14526.yaml new file +80 -0
@@ -0,0 +1,80 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/extcon/maxim,max14526.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX14526 MicroUSB Integrated Circuit (MUIC) + +maintainers: + - Svyatoslav Ryhel <[email protected]> + +properties: + compatible: + const: maxim,max14526 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + connector: + $ref: /schemas/connector/usb-connector.yaml# + + port: + $ref: /schemas/graph.yaml#/properties/port + +required: + - compatible + - reg + - interrupts + - connector + - port + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + muic@44 { + compatible = "maxim,max14526"; + reg = <0x44>; + + interrupt-parent = <&gpio>; + interrupts = <72 IRQ_TYPE_EDGE_FALLING>; + + connector { + compatible = "usb-b-connector"; + label = "micro-USB"; + type = "micro"; + }; + + port { + #address-cells = <1>; + #size-cells = <0>; + + muic_to_charger: endpoint@0 { + reg = <0>; + remote-endpoint = <&charger_input>; + }; + + muic_to_usb: endpoint@1 { + reg = <1>; + remote-endpoint = <&usb_input>; + }; + + muic_to_mhl: endpoint@2 { + reg = <2>; + remote-endpoint = <&mhl_input>; + }; + }; + }; + }; +...
Signature · 1 line
2.43.0
Re: [PATCH v2 1/2] dt-bindings: extcon: Document Maxim MAX14526 MUIC
Quoted 7 lines · Svyatoslav Ryhel
Add bindings for Maxim MAX14526 MicroUSB Integrated Circuit.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- .../bindings/extcon/maxim,max14526.yaml | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/extcon/maxim,max14526.yaml
Best regards,
Krzysztof
PATCH v2 2/2 extcon: Add basic support for Maxim MAX14526 MUIC
In reply to Svyatoslav RyhelThe MAX14526 is designed to simplify interface requirements on portable devices by multiplexing common inputs (USB, UART, Microphone, Stereo Audio and Composite Video) on a single micro/mini USB connector. The USB input supports Hi-Speed USB and the audio/video inputs feature negative rail signal operation allowing simple DC coupled accessories. These device allow a single micro/mini USB port to support all the common interfaces on Cellular phones and portable media players over the same external lines.
--- drivers/extcon/Kconfig | 12 ++ drivers/extcon/Makefile | 1 + drivers/extcon/extcon-max14526.c | 301 +++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 drivers/extcon/extcon-max14526.c
drivers/extcon/Kconfig +12 -0
@@ -134,6 +134,18 @@ config EXTCON_MAX8997 Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory detector and switch. +config EXTCON_MAX14526 + tristate "Maxim MAX14526 EXTCON Support" + select IRQ_DOMAIN + select REGMAP_I2C + help + If you say yes here you get support for the Maxim MAX14526 + MUIC device. The MAX14526 MUIC is a USB port accessory + detector and switch. The MAX14526 is designed to simplify + interface requirements on portable devices by multiplexing + common inputs (USB, UART, Microphone, Stereo Audio and + Composite Video) on a single micro/mini USB connector. + config EXTCON_PALMAS tristate "Palmas USB EXTCON support" depends on MFD_PALMAS
drivers/extcon/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_EXTCON_MAX3355) += extcon-max3355.o obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.o obj-$(CONFIG_EXTCON_PTN5150) += extcon-ptn5150.o obj-$(CONFIG_EXTCON_QCOM_SPMI_MISC) += extcon-qcom-spmi-misc.o
drivers/extcon/extcon-max14526.c new file +301 -0
301 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v2 2/2] extcon: Add basic support for Maxim MAX14526 MUIC
вт, 25 лют. 2025 р. о 11:00 Svyatoslav Ryhel <[email protected]> пише:
Quoted 11 lines
The MAX14526 is designed to simplify interface requirements on portable devices by multiplexing common inputs (USB, UART, Microphone, Stereo Audio and Composite Video) on a single micro/mini USB connector. The USB input supports Hi-Speed USB and the audio/video inputs feature negative rail signal operation allowing simple DC coupled accessories. These device allow a single micro/mini USB port to support all the common interfaces on Cellular phones and portable media players over the same external lines.
Quoted 8 lines
Signed-off-by Svyatoslav Ryhel <[email protected]>--- drivers/extcon/Kconfig | 12 ++ drivers/extcon/Makefile | 1 + drivers/extcon/extcon-max14526.c | 301 +++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 drivers/extcon/extcon-max14526.c
These patches had no activity/feedback from maintainers for a while, so, in case they got lost in the depths of email box, this is a friendly reminder that they are still relevant and I would like them to move on.
Best regards,
Svyatoslav R.
Re: [PATCH v2 2/2] extcon: Add basic support for Maxim MAX14526 MUIC
In reply to Svyatoslav RyhelHi,
Quoted 95 lines · Svyatoslav Ryhel
The MAX14526 is designed to simplify interface requirements on portable devices by multiplexing common inputs (USB, UART, Microphone, Stereo Audio and Composite Video) on a single micro/mini USB connector. The USB input supports Hi-Speed USB and the audio/video inputs feature negative rail signal operation allowing simple DC coupled accessories. These device allow a single micro/mini USB port to support all the common interfaces on Cellular phones and portable media players over the same external lines.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- drivers/extcon/Kconfig | 12 ++ drivers/extcon/Makefile | 1 + drivers/extcon/extcon-max14526.c | 301 +++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 drivers/extcon/extcon-max14526.cdrivers/extcon/Kconfig +12
-0@@ -134,6 +134,18 @@ config EXTCON_MAX8997 Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory detector and switch. +config EXTCON_MAX14526 + tristate "Maxim MAX14526 EXTCON Support" + select IRQ_DOMAIN + select REGMAP_I2C + help + If you say yes here you get support for the Maxim MAX14526 + MUIC device. The MAX14526 MUIC is a USB port accessory + detector and switch. The MAX14526 is designed to simplify + interface requirements on portable devices by multiplexing + common inputs (USB, UART, Microphone, Stereo Audio and + Composite Video) on a single micro/mini USB connector. + config EXTCON_PALMAS tristate "Palmas USB EXTCON support" depends on MFD_PALMASdrivers/extcon/Makefile +1
-0@@ -18,6 +18,7 @@ obj-$(CONFIG_EXTCON_MAX3355) += extcon-max3355.o obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.o obj-$(CONFIG_EXTCON_PTN5150) += extcon-ptn5150.o obj-$(CONFIG_EXTCON_QCOM_SPMI_MISC) += extcon-qcom-spmi-misc.odrivers/extcon/extcon-max14526.c new file +35
-0@@ -0,0 +1,301 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include <linux/device.h> +#include <linux/devm-helpers.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/extcon-provider.h> +#include <linux/i2c.h> +#include <linux/mod_devicetable.h> +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/pm.h> +#include <linux/regmap.h> + +/* I2C addresses of MUIC internal registers */ +#define MAX14526_DEVICE_ID 0x00 +#define MAX14526_ID 0x02 + +/* CONTROL_1 register masks */ +#define MAX14526_CONTROL_1 0x01 +#define ID_2P2 BIT(6) +#define ID_620 BIT(5) +#define ID_200 BIT(4) +#define VLDO BIT(3) +#define SEMREN BIT(2) +#define ADC_EN BIT(1) +#define CP_EN BIT(0) + +/* CONTROL_2 register masks */ +#define MAX14526_CONTROL_2 0x02 +#define INTPOL BIT(7) +#define INT_EN BIT(6) +#define MIC_LP BIT(5) +#define CP_AUD BIT(4) +#define CHG_TYPE BIT(1) +#define USB_DET_DIS BIT(0)
(snip)
Quoted 42 lines
drivers/extcon/extcon-max14526.c new file +42
-0+static int max14526_probe (struct i2c_client *client) +{ +struct device *dev = &client->dev; +struct max14526_data *priv; +int ret, dev_id, rev, i; + + priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + + priv->client = client; +i2c_set_clientdata (client, priv); + + priv->regmap =devm_regmap_init_i2c (client, &max14526_regmap_config); +if (IS_ERR (priv->regmap)) +return dev_err_probe (dev,PTR_ERR (priv->regmap),"cannot allocate regmap\n" ); + +for (i =0 ; i <MAX14526_N_REGMAP_FIELDS ; i++) { + priv->rfield[i] =devm_regmap_field_alloc (dev, priv->regmap, + max14526_reg_field[i]); +if (IS_ERR (priv->rfield[i])) +return dev_err_probe (dev,PTR_ERR (priv->rfield[i]), +"cannot allocate regmap field\n" ); + } + +/* Detect if MUIC version is supported */ + ret =regmap_field_read (priv->rfield[VENDOR_ID ], &dev_id); +if (ret) +return dev_err_probe (dev, ret,"failed to read MUIC ID\n" ); + +regmap_field_read (priv->rfield[CHIP_REV ], &rev); + +if (dev_id ==MAX14526_ID ) +dev_info (dev,"detected MAX14526 MUIC with id 0x%x, rev 0x%x\n" , dev_id, rev); +else +dev_err_probe (dev, -EINVAL ,"MUIC vendor id 0x%X is not recognized\n" , dev_id); + + priv->edev =devm_extcon_dev_allocate (dev, max14526_extcon_cable); +if (IS_ERR (priv->edev)) +return dev_err_probe (dev, (IS_ERR (priv->edev)), +"failed to allocate extcon device\n" ); +
drivers/extcon/extcon-max14526.c line 252
Quoted 10 lines
drivers/extcon/extcon-max14526.c new file +10
-0+ ret =devm_extcon_dev_register (dev, priv->edev); +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to register extcon device\n" ); + + ret =max14526_ap_usb_mode (priv); +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to set AP USB mode\n" ); + +regmap_write_bits (priv->regmap,MAX14526_CONTROL_2 ,INT_EN ,INT_EN ); +regmap_write_bits (priv->regmap,MAX14526_CONTROL_2 ,USB_DET_DIS , ~USB_DET_DIS );
When using ~USB_DET_DIS, there is overflow issue like you are received mail from linux-next.
I'd like you to fix this issue.
I'm sorry for late reply.
(snip)
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Re: [PATCH v2 2/2] extcon: Add basic support for Maxim MAX14526 MUIC
вт, 6 трав. 2025 р. о 09:57 Chanwoo Choi <[email protected]> пише:
Quoted 159 lines
Hi,
Quoted 95 lines · Svyatoslav Ryhel
The MAX14526 is designed to simplify interface requirements on portable devices by multiplexing common inputs (USB, UART, Microphone, Stereo Audio and Composite Video) on a single micro/mini USB connector. The USB input supports Hi-Speed USB and the audio/video inputs feature negative rail signal operation allowing simple DC coupled accessories. These device allow a single micro/mini USB port to support all the common interfaces on Cellular phones and portable media players over the same external lines.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- drivers/extcon/Kconfig | 12 ++ drivers/extcon/Makefile | 1 + drivers/extcon/extcon-max14526.c | 301 +++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 drivers/extcon/extcon-max14526.cdrivers/extcon/Kconfig +12
-0@@ -134,6 +134,18 @@ config EXTCON_MAX8997 Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory detector and switch. +config EXTCON_MAX14526 + tristate "Maxim MAX14526 EXTCON Support" + select IRQ_DOMAIN + select REGMAP_I2C + help + If you say yes here you get support for the Maxim MAX14526 + MUIC device. The MAX14526 MUIC is a USB port accessory + detector and switch. The MAX14526 is designed to simplify + interface requirements on portable devices by multiplexing + common inputs (USB, UART, Microphone, Stereo Audio and + Composite Video) on a single micro/mini USB connector. + config EXTCON_PALMAS tristate "Palmas USB EXTCON support" depends on MFD_PALMASdrivers/extcon/Makefile +1
-0@@ -18,6 +18,7 @@ obj-$(CONFIG_EXTCON_MAX3355) += extcon-max3355.o obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.o obj-$(CONFIG_EXTCON_PTN5150) += extcon-ptn5150.o obj-$(CONFIG_EXTCON_QCOM_SPMI_MISC) += extcon-qcom-spmi-misc.odrivers/extcon/extcon-max14526.c new file +35
-0@@ -0,0 +1,301 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include <linux/device.h> +#include <linux/devm-helpers.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/extcon-provider.h> +#include <linux/i2c.h> +#include <linux/mod_devicetable.h> +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/pm.h> +#include <linux/regmap.h> + +/* I2C addresses of MUIC internal registers */ +#define MAX14526_DEVICE_ID 0x00 +#define MAX14526_ID 0x02 + +/* CONTROL_1 register masks */ +#define MAX14526_CONTROL_1 0x01 +#define ID_2P2 BIT(6) +#define ID_620 BIT(5) +#define ID_200 BIT(4) +#define VLDO BIT(3) +#define SEMREN BIT(2) +#define ADC_EN BIT(1) +#define CP_EN BIT(0) + +/* CONTROL_2 register masks */ +#define MAX14526_CONTROL_2 0x02 +#define INTPOL BIT(7) +#define INT_EN BIT(6) +#define MIC_LP BIT(5) +#define CP_AUD BIT(4) +#define CHG_TYPE BIT(1) +#define USB_DET_DIS BIT(0)(snip)
Quoted 42 lines
drivers/extcon/extcon-max14526.c new file +42
-0+static int max14526_probe (struct i2c_client *client) +{ +struct device *dev = &client->dev; +struct max14526_data *priv; +int ret, dev_id, rev, i; + + priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + + priv->client = client; +i2c_set_clientdata (client, priv); + + priv->regmap =devm_regmap_init_i2c (client, &max14526_regmap_config); +if (IS_ERR (priv->regmap)) +return dev_err_probe (dev,PTR_ERR (priv->regmap),"cannot allocate regmap\n" ); + +for (i =0 ; i <MAX14526_N_REGMAP_FIELDS ; i++) { + priv->rfield[i] =devm_regmap_field_alloc (dev, priv->regmap, + max14526_reg_field[i]); +if (IS_ERR (priv->rfield[i])) +return dev_err_probe (dev,PTR_ERR (priv->rfield[i]), +"cannot allocate regmap field\n" ); + } + +/* Detect if MUIC version is supported */ + ret =regmap_field_read (priv->rfield[VENDOR_ID ], &dev_id); +if (ret) +return dev_err_probe (dev, ret,"failed to read MUIC ID\n" ); + +regmap_field_read (priv->rfield[CHIP_REV ], &rev); + +if (dev_id ==MAX14526_ID ) +dev_info (dev,"detected MAX14526 MUIC with id 0x%x, rev 0x%x\n" , dev_id, rev); +else +dev_err_probe (dev, -EINVAL ,"MUIC vendor id 0x%X is not recognized\n" , dev_id); + + priv->edev =devm_extcon_dev_allocate (dev, max14526_extcon_cable); +if (IS_ERR (priv->edev)) +return dev_err_probe (dev, (IS_ERR (priv->edev)), +"failed to allocate extcon device\n" ); +drivers/extcon/extcon-max14526.c line 252
Quoted 10 lines
drivers/extcon/extcon-max14526.c new file +10
-0+ ret =devm_extcon_dev_register (dev, priv->edev); +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to register extcon device\n" ); + + ret =max14526_ap_usb_mode (priv); +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to set AP USB mode\n" ); + +regmap_write_bits (priv->regmap,MAX14526_CONTROL_2 ,INT_EN ,INT_EN ); +regmap_write_bits (priv->regmap,MAX14526_CONTROL_2 ,USB_DET_DIS , ~USB_DET_DIS );When using ~USB_DET_DIS, there is overflow issue like you are received mail from linux-next.
I'd like you to fix this issue.
Quoted 2 lines
I'm sorry for late reply.
It should not matter because register bit size is 8 bit anyway.
Quoted 6 lines
(snip)
--
Best Regards,
Chanwoo Choi
Samsung Electronics
Re: [PATCH v2 2/2] extcon: Add basic support for Maxim MAX14526 MUIC
Quoted 161 lines · Svyatoslav Ryhel
вт, 6 трав. 2025 р. о 09:57 Chanwoo Choi <[email protected]> пише:
Quoted 159 lines
Hi,
Quoted 95 lines · Svyatoslav Ryhel
The MAX14526 is designed to simplify interface requirements on portable devices by multiplexing common inputs (USB, UART, Microphone, Stereo Audio and Composite Video) on a single micro/mini USB connector. The USB input supports Hi-Speed USB and the audio/video inputs feature negative rail signal operation allowing simple DC coupled accessories. These device allow a single micro/mini USB port to support all the common interfaces on Cellular phones and portable media players over the same external lines.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- drivers/extcon/Kconfig | 12 ++ drivers/extcon/Makefile | 1 + drivers/extcon/extcon-max14526.c | 301 +++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 drivers/extcon/extcon-max14526.cdrivers/extcon/Kconfig +12
-0@@ -134,6 +134,18 @@ config EXTCON_MAX8997 Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory detector and switch. +config EXTCON_MAX14526 + tristate "Maxim MAX14526 EXTCON Support" + select IRQ_DOMAIN + select REGMAP_I2C + help + If you say yes here you get support for the Maxim MAX14526 + MUIC device. The MAX14526 MUIC is a USB port accessory + detector and switch. The MAX14526 is designed to simplify + interface requirements on portable devices by multiplexing + common inputs (USB, UART, Microphone, Stereo Audio and + Composite Video) on a single micro/mini USB connector. + config EXTCON_PALMAS tristate "Palmas USB EXTCON support" depends on MFD_PALMASdrivers/extcon/Makefile +1
-0@@ -18,6 +18,7 @@ obj-$(CONFIG_EXTCON_MAX3355) += extcon-max3355.o obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.o obj-$(CONFIG_EXTCON_PTN5150) += extcon-ptn5150.o obj-$(CONFIG_EXTCON_QCOM_SPMI_MISC) += extcon-qcom-spmi-misc.odrivers/extcon/extcon-max14526.c new file +35
-0@@ -0,0 +1,301 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include <linux/device.h> +#include <linux/devm-helpers.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/extcon-provider.h> +#include <linux/i2c.h> +#include <linux/mod_devicetable.h> +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/pm.h> +#include <linux/regmap.h> + +/* I2C addresses of MUIC internal registers */ +#define MAX14526_DEVICE_ID 0x00 +#define MAX14526_ID 0x02 + +/* CONTROL_1 register masks */ +#define MAX14526_CONTROL_1 0x01 +#define ID_2P2 BIT(6) +#define ID_620 BIT(5) +#define ID_200 BIT(4) +#define VLDO BIT(3) +#define SEMREN BIT(2) +#define ADC_EN BIT(1) +#define CP_EN BIT(0) + +/* CONTROL_2 register masks */ +#define MAX14526_CONTROL_2 0x02 +#define INTPOL BIT(7) +#define INT_EN BIT(6) +#define MIC_LP BIT(5) +#define CP_AUD BIT(4) +#define CHG_TYPE BIT(1) +#define USB_DET_DIS BIT(0)(snip)
Quoted 42 lines
drivers/extcon/extcon-max14526.c new file +42
-0+static int max14526_probe (struct i2c_client *client) +{ +struct device *dev = &client->dev; +struct max14526_data *priv; +int ret, dev_id, rev, i; + + priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + + priv->client = client; +i2c_set_clientdata (client, priv); + + priv->regmap =devm_regmap_init_i2c (client, &max14526_regmap_config); +if (IS_ERR (priv->regmap)) +return dev_err_probe (dev,PTR_ERR (priv->regmap),"cannot allocate regmap\n" ); + +for (i =0 ; i <MAX14526_N_REGMAP_FIELDS ; i++) { + priv->rfield[i] =devm_regmap_field_alloc (dev, priv->regmap, + max14526_reg_field[i]); +if (IS_ERR (priv->rfield[i])) +return dev_err_probe (dev,PTR_ERR (priv->rfield[i]), +"cannot allocate regmap field\n" ); + } + +/* Detect if MUIC version is supported */ + ret =regmap_field_read (priv->rfield[VENDOR_ID ], &dev_id); +if (ret) +return dev_err_probe (dev, ret,"failed to read MUIC ID\n" ); + +regmap_field_read (priv->rfield[CHIP_REV ], &rev); + +if (dev_id ==MAX14526_ID ) +dev_info (dev,"detected MAX14526 MUIC with id 0x%x, rev 0x%x\n" , dev_id, rev); +else +dev_err_probe (dev, -EINVAL ,"MUIC vendor id 0x%X is not recognized\n" , dev_id); + + priv->edev =devm_extcon_dev_allocate (dev, max14526_extcon_cable); +if (IS_ERR (priv->edev)) +return dev_err_probe (dev, (IS_ERR (priv->edev)), +"failed to allocate extcon device\n" ); +drivers/extcon/extcon-max14526.c line 252
Quoted 10 lines
drivers/extcon/extcon-max14526.c new file +10
-0+ ret =devm_extcon_dev_register (dev, priv->edev); +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to register extcon device\n" ); + + ret =max14526_ap_usb_mode (priv); +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to set AP USB mode\n" ); + +regmap_write_bits (priv->regmap,MAX14526_CONTROL_2 ,INT_EN ,INT_EN ); +regmap_write_bits (priv->regmap,MAX14526_CONTROL_2 ,USB_DET_DIS , ~USB_DET_DIS );When using ~USB_DET_DIS, there is overflow issue like you are received mail from linux-next.
I'd like you to fix this issue.
Quoted 4 lines
Quoted 2 lines
I'm sorry for late reply.
It should not matter because register bit size is 8 bit anyway.
There is issue on linux-next build (x86_64, allmodconfig). You can check the failure details on 'linux-next: build failure after merge of the extcon tree' mail title.
If there is build issue when merging it into linux-next.git, it will happen on linux.git mainline git.
It should support all arch build.
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Re: [PATCH v2 2/2] extcon: Add basic support for Maxim MAX14526 MUIC
вт, 6 трав. 2025 р. о 10:06 Chanwoo Choi <[email protected]> пише:
Quoted 168 lines · Svyatoslav Ryhel
Quoted 161 lines
вт, 6 трав. 2025 р. о 09:57 Chanwoo Choi <[email protected]> пише:
Quoted 159 lines
Hi,
Quoted 95 lines · Svyatoslav Ryhel
The MAX14526 is designed to simplify interface requirements on portable devices by multiplexing common inputs (USB, UART, Microphone, Stereo Audio and Composite Video) on a single micro/mini USB connector. The USB input supports Hi-Speed USB and the audio/video inputs feature negative rail signal operation allowing simple DC coupled accessories. These device allow a single micro/mini USB port to support all the common interfaces on Cellular phones and portable media players over the same external lines.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- drivers/extcon/Kconfig | 12 ++ drivers/extcon/Makefile | 1 + drivers/extcon/extcon-max14526.c | 301 +++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 drivers/extcon/extcon-max14526.cdrivers/extcon/Kconfig +12
-0@@ -134,6 +134,18 @@ config EXTCON_MAX8997 Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory detector and switch. +config EXTCON_MAX14526 + tristate "Maxim MAX14526 EXTCON Support" + select IRQ_DOMAIN + select REGMAP_I2C + help + If you say yes here you get support for the Maxim MAX14526 + MUIC device. The MAX14526 MUIC is a USB port accessory + detector and switch. The MAX14526 is designed to simplify + interface requirements on portable devices by multiplexing + common inputs (USB, UART, Microphone, Stereo Audio and + Composite Video) on a single micro/mini USB connector. + config EXTCON_PALMAS tristate "Palmas USB EXTCON support" depends on MFD_PALMASdrivers/extcon/Makefile +1
-0@@ -18,6 +18,7 @@ obj-$(CONFIG_EXTCON_MAX3355) += extcon-max3355.o obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.o obj-$(CONFIG_EXTCON_PTN5150) += extcon-ptn5150.o obj-$(CONFIG_EXTCON_QCOM_SPMI_MISC) += extcon-qcom-spmi-misc.odrivers/extcon/extcon-max14526.c new file +35
-0@@ -0,0 +1,301 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include <linux/device.h> +#include <linux/devm-helpers.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/extcon-provider.h> +#include <linux/i2c.h> +#include <linux/mod_devicetable.h> +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/pm.h> +#include <linux/regmap.h> + +/* I2C addresses of MUIC internal registers */ +#define MAX14526_DEVICE_ID 0x00 +#define MAX14526_ID 0x02 + +/* CONTROL_1 register masks */ +#define MAX14526_CONTROL_1 0x01 +#define ID_2P2 BIT(6) +#define ID_620 BIT(5) +#define ID_200 BIT(4) +#define VLDO BIT(3) +#define SEMREN BIT(2) +#define ADC_EN BIT(1) +#define CP_EN BIT(0) + +/* CONTROL_2 register masks */ +#define MAX14526_CONTROL_2 0x02 +#define INTPOL BIT(7) +#define INT_EN BIT(6) +#define MIC_LP BIT(5) +#define CP_AUD BIT(4) +#define CHG_TYPE BIT(1) +#define USB_DET_DIS BIT(0)(snip)
Quoted 42 lines
drivers/extcon/extcon-max14526.c new file +42
-0+static int max14526_probe (struct i2c_client *client) +{ +struct device *dev = &client->dev; +struct max14526_data *priv; +int ret, dev_id, rev, i; + + priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + + priv->client = client; +i2c_set_clientdata (client, priv); + + priv->regmap =devm_regmap_init_i2c (client, &max14526_regmap_config); +if (IS_ERR (priv->regmap)) +return dev_err_probe (dev,PTR_ERR (priv->regmap),"cannot allocate regmap\n" ); + +for (i =0 ; i <MAX14526_N_REGMAP_FIELDS ; i++) { + priv->rfield[i] =devm_regmap_field_alloc (dev, priv->regmap, + max14526_reg_field[i]); +if (IS_ERR (priv->rfield[i])) +return dev_err_probe (dev,PTR_ERR (priv->rfield[i]), +"cannot allocate regmap field\n" ); + } + +/* Detect if MUIC version is supported */ + ret =regmap_field_read (priv->rfield[VENDOR_ID ], &dev_id); +if (ret) +return dev_err_probe (dev, ret,"failed to read MUIC ID\n" ); + +regmap_field_read (priv->rfield[CHIP_REV ], &rev); + +if (dev_id ==MAX14526_ID ) +dev_info (dev,"detected MAX14526 MUIC with id 0x%x, rev 0x%x\n" , dev_id, rev); +else +dev_err_probe (dev, -EINVAL ,"MUIC vendor id 0x%X is not recognized\n" , dev_id); + + priv->edev =devm_extcon_dev_allocate (dev, max14526_extcon_cable); +if (IS_ERR (priv->edev)) +return dev_err_probe (dev, (IS_ERR (priv->edev)), +"failed to allocate extcon device\n" ); +drivers/extcon/extcon-max14526.c line 252
Quoted 10 lines
drivers/extcon/extcon-max14526.c new file +10
-0+ ret =devm_extcon_dev_register (dev, priv->edev); +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to register extcon device\n" ); + + ret =max14526_ap_usb_mode (priv); +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to set AP USB mode\n" ); + +regmap_write_bits (priv->regmap,MAX14526_CONTROL_2 ,INT_EN ,INT_EN ); +regmap_write_bits (priv->regmap,MAX14526_CONTROL_2 ,USB_DET_DIS , ~USB_DET_DIS );When using ~USB_DET_DIS, there is overflow issue like you are received mail from linux-next.
I'd like you to fix this issue.Quoted 4 lines
Quoted 2 lines
I'm sorry for late reply.
It should not matter because register bit size is 8 bit anyway.
Quoted 8 lines
There is issue on linux-next build (
x86_64, allmodconfig). You can check the failure details on 'linux-next: build failure after merge of the extcon tree' mail title.
If there is build issue when merging it into linux-next.git, it will happen on linux.git mainline git.It should support all arch build.
ok, fine, I will send v3 within a few hours.
Quoted 4 lines
--
Best Regards,
Chanwoo Choi
Samsung Electronics