* [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add MCP3302 and MCP3304
@ 2026-12-04 11:02 Jakkapong Saksrisuwan
2026-12-04 11:02 ` [PATCH 2/2] iio: adc: mcp320x: Add support for " Jakkapong Saksrisuwan
2026-12-04 16:56 ` [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add " Conor Dooley
0 siblings, 2 replies; 7+ messages in thread
From: Jakkapong Saksrisuwan @ 2026-12-04 11:02 UTC (permalink / raw)
To: linux-iio
Cc: jic23, andy, dlechner, nuno.sa, robh, krzk+dt, conor+dt,
devicetree, Jakkapong Saksrisuwan
The MCP3302 and MCP3304 are 13-bit output (12 data bits plus sign)
pseudo-differential ADCs sharing the channel configuration of the
MCP3204 and MCP3208. Add their compatibles to the family binding.
Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/21697F.pdf
Signed-off-by: Jakkapong Saksrisuwan <me@jakkapong.dev>
---
Notes:
The MCP3302 and MCP3304 share the binding file's existing channel
configuration (DS21697F Tables 6-1/6-2), so only the compatible list
changes.
AI assistance: I used an AI assistant (Qwen) to extract text from
the datasheet, cross-check the channel tables against the MCP3204/08
datasheet (DS21298E), and draft this note and the commit message. I
checked the two compatible strings against the datasheet part numbers
and the driver's mcp320x_dt_ids[] table myself.
.../devicetree/bindings/iio/adc/microchip,mcp3201.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml
index 18108f0f3731..7bc53ab0481d 100644
--- a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml
@@ -24,6 +24,8 @@ properties:
- microchip,mcp3204
- microchip,mcp3208
- microchip,mcp3301
+ - microchip,mcp3302
+ - microchip,mcp3304
- microchip,mcp3550-50
- microchip,mcp3550-60
- microchip,mcp3551
base-commit: fba506008a5b548ad2708bc2765a039cb00a47ab
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/2] iio: adc: mcp320x: Add support for MCP3302 and MCP3304 2026-12-04 11:02 [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add MCP3302 and MCP3304 Jakkapong Saksrisuwan @ 2026-12-04 11:02 ` Jakkapong Saksrisuwan 2026-12-04 12:21 ` Andy Shevchenko 2026-12-04 16:56 ` [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add " Conor Dooley 1 sibling, 1 reply; 7+ messages in thread From: Jakkapong Saksrisuwan @ 2026-12-04 11:02 UTC (permalink / raw) To: linux-iio Cc: jic23, andy, dlechner, nuno.sa, robh, krzk+dt, conor+dt, devicetree, Jakkapong Saksrisuwan The MCP3302 and MCP3304 are 13-bit output ADCs with pseudo-differential inputs. They share the command frame and channel layout of the MCP3204 and MCP3208. The sign bit is not counted toward resolution, which is set to 12. Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/21697F.pdf Signed-off-by: Jakkapong Saksrisuwan <me@jakkapong.dev> --- Notes: This is based on the datasheet (DS21697F) and the driver cross-check only. I do not have an MCP3302/04, so it is untested on hardware. AI assistance: I used an AI assistant (Qwen) to help read the datasheet and the driver and to draft this message. I checked the channel tables (DS21697F Tables 6-1/6-2, cross-checked against the MCP3204/08 datasheet DS21298E) and the RX bit math against the timing diagrams (Figures 6-2 and 6-3) myself. Build-tested (W=1, C=1) and checked with checkpatch.pl --strict; not tested on hardware. drivers/iio/adc/Kconfig | 4 ++-- drivers/iio/adc/mcp320x.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 82e2eb652e16..53be5911bf42 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1210,8 +1210,8 @@ config MCP320X help Say yes here to build support for Microchip Technology's MCP3001, MCP3002, MCP3004, MCP3008, MCP3201, MCP3202, MCP3204, - MCP3208, MCP3301, MCP3550, MCP3551 and MCP3553 analog to digital - converters. + MCP3208, MCP3301, MCP3302, MCP3304, MCP3550, MCP3551 and MCP3553 + analog to digital converters. This driver can also be built as a module. If so, the module will be called mcp320x. diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c index 18cb957e7095..fe0c47ba582d 100644 --- a/drivers/iio/adc/mcp320x.c +++ b/drivers/iio/adc/mcp320x.c @@ -20,6 +20,8 @@ * ------------ * 13 bit converter * MCP3301 + * MCP3302 + * MCP3304 * ------------ * 22 bit converter * MCP3550 @@ -34,6 +36,7 @@ * http://ww1.microchip.com/downloads/en/DeviceDoc/21034D.pdf mcp3202 * http://ww1.microchip.com/downloads/en/DeviceDoc/21298c.pdf mcp3204/08 * https://ww1.microchip.com/downloads/en/DeviceDoc/21700E.pdf mcp3301 + * https://ww1.microchip.com/downloads/en/DeviceDoc/21697F.pdf mcp3302/04 * http://ww1.microchip.com/downloads/en/DeviceDoc/21950D.pdf mcp3550/1/3 */ @@ -54,6 +57,8 @@ enum { mcp3204, mcp3208, mcp3301, + mcp3302, + mcp3304, mcp3550_50, mcp3550_60, mcp3551, @@ -105,8 +110,10 @@ static int mcp320x_channel_to_tx_data(int device_index, case mcp3202: return ((start_bit << 4) | (!differential << 3) | (channel << 2)); + case mcp3302: case mcp3004: case mcp3204: + case mcp3304: case mcp3008: case mcp3208: return ((start_bit << 6) | (!differential << 5) | @@ -160,6 +167,15 @@ static int mcp320x_adc_conversion(struct mcp320x *adc, u8 channel, *val = sign_extend32((adc->rx_buf[0] & 0x1f) << 8 | adc->rx_buf[1], 12); return 0; + case mcp3302: + case mcp3304: + /* + * rx_buf[0] reads SB, B11, B10, ... , B5 + * rx_buf[1] reads B4, B3, ... , B0, X, X, X + */ + *val = sign_extend32(adc->rx_buf[0] << 5 | + adc->rx_buf[1] >> 3, 12); + return 0; case mcp3550_50: case mcp3550_60: case mcp3551: @@ -343,6 +359,18 @@ static const struct mcp320x_chip_info mcp320x_chip_infos[] = { .num_channels = ARRAY_SIZE(mcp3201_channels), .resolution = 13 }, + [mcp3302] = { + /* same channel layout as the MCP3204 */ + .channels = mcp3204_channels, + .num_channels = ARRAY_SIZE(mcp3204_channels), + .resolution = 12, + }, + [mcp3304] = { + /* same channel layout as the MCP3208 */ + .channels = mcp3208_channels, + .num_channels = ARRAY_SIZE(mcp3208_channels), + .resolution = 12, + }, [mcp3550_50] = { .channels = mcp3201_channels, .num_channels = ARRAY_SIZE(mcp3201_channels), @@ -467,6 +495,8 @@ static const struct of_device_id mcp320x_dt_ids[] = { { .compatible = "microchip,mcp3204" }, { .compatible = "microchip,mcp3208" }, { .compatible = "microchip,mcp3301" }, + { .compatible = "microchip,mcp3302" }, + { .compatible = "microchip,mcp3304" }, { .compatible = "microchip,mcp3550-50" }, { .compatible = "microchip,mcp3550-60" }, { .compatible = "microchip,mcp3551" }, @@ -485,6 +515,8 @@ static const struct spi_device_id mcp320x_id[] = { { .name = "mcp3204", .driver_data = mcp3204 }, { .name = "mcp3208", .driver_data = mcp3208 }, { .name = "mcp3301", .driver_data = mcp3301 }, + { .name = "mcp3302", .driver_data = mcp3302 }, + { .name = "mcp3304", .driver_data = mcp3304 }, { .name = "mcp3550-50", .driver_data = mcp3550_50 }, { .name = "mcp3550-60", .driver_data = mcp3550_60 }, { .name = "mcp3551", .driver_data = mcp3551 }, -- 2.47.3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] iio: adc: mcp320x: Add support for MCP3302 and MCP3304 2026-12-04 11:02 ` [PATCH 2/2] iio: adc: mcp320x: Add support for " Jakkapong Saksrisuwan @ 2026-12-04 12:21 ` Andy Shevchenko 2026-12-04 13:26 ` Joshua Crofts 2026-12-04 14:56 ` Jakkapong Saksrisuwan 0 siblings, 2 replies; 7+ messages in thread From: Andy Shevchenko @ 2026-12-04 12:21 UTC (permalink / raw) To: Jakkapong Saksrisuwan Cc: linux-iio, jic23, andy, dlechner, nuno.sa, robh, krzk+dt, conor+dt, devicetree On Fri, Dec 04, 2026 at 06:02:14PM +0700, Jakkapong Saksrisuwan wrote: > The MCP3302 and MCP3304 are 13-bit output ADCs with pseudo-differential > inputs. They share the command frame and channel layout of the MCP3204 > and MCP3208. The sign bit is not counted toward resolution, which is > set to 12. Did I miss the cover letter? Always when there are 2+ patches in a series, provide a cover letter. ... > --- a/drivers/iio/adc/Kconfig > +++ b/drivers/iio/adc/Kconfig > @@ -1210,8 +1210,8 @@ config MCP320X > help > Say yes here to build support for Microchip Technology's > MCP3001, MCP3002, MCP3004, MCP3008, MCP3201, MCP3202, MCP3204, > - MCP3208, MCP3301, MCP3550, MCP3551 and MCP3553 analog to digital > - converters. > + MCP3208, MCP3301, MCP3302, MCP3304, MCP3550, MCP3551 and MCP3553 > + analog to digital converters. No. Study the mailing list archive for linux-iio@ to see how we recommend to make this kind of list flexible and scalable. > This driver can also be built as a module. If so, the module will be > called mcp320x. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] iio: adc: mcp320x: Add support for MCP3302 and MCP3304 2026-12-04 12:21 ` Andy Shevchenko @ 2026-12-04 13:26 ` Joshua Crofts 2026-12-04 14:59 ` Andy Shevchenko 2026-12-04 14:56 ` Jakkapong Saksrisuwan 1 sibling, 1 reply; 7+ messages in thread From: Joshua Crofts @ 2026-12-04 13:26 UTC (permalink / raw) To: Andy Shevchenko, Jakkapong Saksrisuwan Cc: linux-iio, jic23, andy, dlechner, nuno.sa, robh, krzk+dt, conor+dt, devicetree On 04-Dec-26 13:21, Andy Shevchenko wrote: > On Fri, Dec 04, 2026 at 06:02:14PM +0700, Jakkapong Saksrisuwan wrote: >> The MCP3302 and MCP3304 are 13-bit output ADCs with pseudo-differential >> inputs. They share the command frame and channel layout of the MCP3204 >> and MCP3208. The sign bit is not counted toward resolution, which is >> set to 12. > > Did I miss the cover letter? > Always when there are 2+ patches in a series, provide a cover letter. Side note, I once suggested this to a person and a certain senior maintainer pushed back, saying I was overcomplicating things :) -- Kind regards, Joshua Crofts ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] iio: adc: mcp320x: Add support for MCP3302 and MCP3304 2026-12-04 13:26 ` Joshua Crofts @ 2026-12-04 14:59 ` Andy Shevchenko 0 siblings, 0 replies; 7+ messages in thread From: Andy Shevchenko @ 2026-12-04 14:59 UTC (permalink / raw) To: Joshua Crofts Cc: Jakkapong Saksrisuwan, linux-iio, jic23, andy, dlechner, nuno.sa, robh, krzk+dt, conor+dt, devicetree On Fri, Dec 04, 2026 at 02:26:32PM +0100, Joshua Crofts wrote: > On 04-Dec-26 13:21, Andy Shevchenko wrote: > > On Fri, Dec 04, 2026 at 06:02:14PM +0700, Jakkapong Saksrisuwan wrote: > >> The MCP3302 and MCP3304 are 13-bit output ADCs with pseudo-differential > >> inputs. They share the command frame and channel layout of the MCP3204 > >> and MCP3208. The sign bit is not counted toward resolution, which is > >> set to 12. > > > > Did I miss the cover letter? > > Always when there are 2+ patches in a series, provide a cover letter. > > Side note, I once suggested this to a person and a certain senior maintainer > pushed back, saying I was overcomplicating things :) He-he. I have a script [1] that creates cover letter by default for 2+ patches. `b4` IIRC also does the same. [1]: https://github.com/andy-shev/home-bin-tools/blob/master/ge2maintainer.sh -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] iio: adc: mcp320x: Add support for MCP3302 and MCP3304 2026-12-04 12:21 ` Andy Shevchenko 2026-12-04 13:26 ` Joshua Crofts @ 2026-12-04 14:56 ` Jakkapong Saksrisuwan 1 sibling, 0 replies; 7+ messages in thread From: Jakkapong Saksrisuwan @ 2026-12-04 14:56 UTC (permalink / raw) To: Andy Shevchenko, Jakkapong Saksrisuwan Cc: linux-iio, jic23, andy, dlechner, nuno.sa, robh, krzk+dt, conor+dt, devicetree On Fri Dec 4, 2026 at 7:21 PM +07, Andy Shevchenko wrote: > Did I miss the cover letter? > Always when there are 2+ patches in a series, provide a cover letter. Adding in V2 >> + MCP3208, MCP3301, MCP3302, MCP3304, MCP3550, MCP3551 and MCP3553 >> + analog to digital converters. > > No. Study the mailing list archive for linux-iio@ to see how we recommend to > make this kind of list flexible and scalable. Will change to one part per line in V2 Best regards, Jakkapong ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add MCP3302 and MCP3304 2026-12-04 11:02 [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add MCP3302 and MCP3304 Jakkapong Saksrisuwan 2026-12-04 11:02 ` [PATCH 2/2] iio: adc: mcp320x: Add support for " Jakkapong Saksrisuwan @ 2026-12-04 16:56 ` Conor Dooley 1 sibling, 0 replies; 7+ messages in thread From: Conor Dooley @ 2026-12-04 16:56 UTC (permalink / raw) To: Jakkapong Saksrisuwan Cc: linux-iio, jic23, andy, dlechner, nuno.sa, robh, krzk+dt, conor+dt, devicetree [-- Attachment #1: Type: text/plain, Size: 1915 bytes --] On Fri, Dec 04, 2026 at 06:02:13PM +0700, Jakkapong Saksrisuwan wrote: > The MCP3302 and MCP3304 are 13-bit output (12 data bits plus sign) > pseudo-differential ADCs sharing the channel configuration of the > MCP3204 and MCP3208. Add their compatibles to the family binding. Please provide an explanation for why fallback compatibles cannot be used. pw-bot: changes-requested Thanks, Conor. > > Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/21697F.pdf > Signed-off-by: Jakkapong Saksrisuwan <me@jakkapong.dev> > --- > > Notes: > The MCP3302 and MCP3304 share the binding file's existing channel > configuration (DS21697F Tables 6-1/6-2), so only the compatible list > changes. > > AI assistance: I used an AI assistant (Qwen) to extract text from > the datasheet, cross-check the channel tables against the MCP3204/08 > datasheet (DS21298E), and draft this note and the commit message. I > checked the two compatible strings against the datasheet part numbers > and the driver's mcp320x_dt_ids[] table myself. > > .../devicetree/bindings/iio/adc/microchip,mcp3201.yaml | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml > index 18108f0f3731..7bc53ab0481d 100644 > --- a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml > +++ b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml > @@ -24,6 +24,8 @@ properties: > - microchip,mcp3204 > - microchip,mcp3208 > - microchip,mcp3301 > + - microchip,mcp3302 > + - microchip,mcp3304 > - microchip,mcp3550-50 > - microchip,mcp3550-60 > - microchip,mcp3551 > > base-commit: fba506008a5b548ad2708bc2765a039cb00a47ab > -- > 2.47.3 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-04 16:56 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-04 11:02 [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add MCP3302 and MCP3304 Jakkapong Saksrisuwan 2026-12-04 11:02 ` [PATCH 2/2] iio: adc: mcp320x: Add support for " Jakkapong Saksrisuwan 2026-12-04 12:21 ` Andy Shevchenko 2026-12-04 13:26 ` Joshua Crofts 2026-12-04 14:59 ` Andy Shevchenko 2026-12-04 14:56 ` Jakkapong Saksrisuwan 2026-12-04 16:56 ` [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add " Conor Dooley
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox