* [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 11:10 ` [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add " sashiko-bot
0 siblings, 2 replies; 4+ 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] 4+ 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 11:15 ` sashiko-bot
2026-12-04 11:10 ` [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add " sashiko-bot
1 sibling, 1 reply; 4+ 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] 4+ 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 11:10 ` sashiko-bot
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-12-04 11:10 UTC (permalink / raw)
To: Jakkapong Saksrisuwan; +Cc: devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dt-bindings: iio: adc: commit message misdescribes MCP3302/3304
input type
--
commit ca568d66a54cdd7d36d534abf25b168c72c2e3a8
Author: Jakkapong Saksrisuwan <me@jakkapong.dev>
dt-bindings: iio: adc: microchip,mcp3201: add MCP3302 and MCP3304
This commit adds the microchip,mcp3302 and microchip,mcp3304 compatible
strings to the microchip,mcp3201 ADC binding.
> 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.
[Severity: Low]
Should the commit message describe the MCP3302 and MCP3304 as
full-differential (and single-ended) rather than pseudo-differential ADCs?
Per the cited datasheet (DS21697F), the MCP3302 and MCP3304 have
full-differential inputs where IN+ - IN- spans -Vref to +Vref for the
13-bit signed output, whereas pseudo-differential applies to the 12-bit
unsigned MCP3204 and MCP3208.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204110214.40106-1-me@jakkapong.dev?part=1
^ permalink raw reply [flat|nested] 4+ 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 11:15 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-12-04 11:15 UTC (permalink / raw)
To: Jakkapong Saksrisuwan; +Cc: devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] iio: adc: mcp320x: Commit message mischaracterizes MCP3302/04
inputs
--
commit c3f3e8270719c63e13a60d55f723f36a385f372f
Author: Jakkapong Saksrisuwan <me@jakkapong.dev>
iio: adc: mcp320x: Add support for MCP3302 and MCP3304
This commit adds support for the MCP3302 and MCP3304 ADCs to the mcp320x
driver.
> The MCP3302 and MCP3304 are 13-bit output ADCs with pseudo-differential
> inputs.
[Severity: Low]
Should this describe the MCP3302 and MCP3304 as full differential (or
differential and single-ended) rather than pseudo-differential?
Unlike the unsigned MCP3204 and MCP3208, the MCP3302 and MCP3304 support
full differential inputs measuring negative voltages down to -Vref, which
is why the driver decodes a signed 13-bit result with sign_extend32().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204110214.40106-1-me@jakkapong.dev?part=2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-04 11:15 UTC | newest]
Thread overview: 4+ 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 11:15 ` sashiko-bot
2026-12-04 11:10 ` [PATCH 1/2] dt-bindings: iio: adc: microchip,mcp3201: add " sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox