From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796214199; b=dzz5YY0GKu7UDGHMgwB0iO9Df14InRDje5ZDm54LEugY0C1wQ8t60xEbONdlL4GBARVC 4NqA2xtBXI5InpC9YFRWCQVFHCHhzRSdf/n+kRfvRNUMxQvodi4f5GXN7txZCTG7PBX9J 8a0srMilTyttmB90fLvkt6DL9FcifTlPDnz4uWP05DmDrWKmbWcSOmtCqhpD3dEQCFia+ Z3ynQkJRwmGcwFdRh1b/e415vzkcczBrXQW+x7IC7XicfKwTaWYO0q813g4CTqr1G/HIJ MlFL9Mm9JvpoODg3dUAR3QBNkmYF3qnaFZX3EIozZqGNk0PqNEToXmP3TMTIOYgMY6Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796214199; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition; bh=uX9WNjYLpTIgw5w/syyFnZrff7JRIx1muJf0sZtoenY=; b=cD4+3WY4db6Ifk8kW/S236IHPjAFmRpYZjN5BI5Zaan/mjHhwvK2Mr1OwoVyBBN9fiph /YQhsPitFJKtfh9dliLgmTiVXijRF3nT26Rzh2hoVMqVLfiFMZZO+I2fyxVimi/Ykh5jq 08evuoc1eGR+CHP2Jz1RH0YoXeZOF+I30/L/EKawn6In76JMGN6MFUPc9hcc5vtQ3c+CI V3fWqzCx5q1xwRx+dQW7nnwVVUMG2Gq3A52GVgErNXPEeb52MOJNAKUpQEds30NkCwlka kLbtv33hVHIie4HqXAB2O5eKnQZca1y0ZKt2EHYn2f5WhOi5GQ87sTd37ENDzK5MQnA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=qIXgW9aU; arc=none smtp.remote-ip=91.218.175.199 Received: from mta0.migadu.com (out-199.mta0.migadu.com [91.218.175.199]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C0A4606A31A for ; Wed, 2 Dec 2026 12:23:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2C0A4606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=qIXgW9aU X-Envelope-To: linux-iio@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=QZhOa9vZ1NuTXdy+FDn4p5/oFObkitExjVFO1yRLun0=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796214196; v=1; x=1796818996; b=qIXgW9aUg/OZJPLyqobTa5+pNaDRNJMv0iosbw9jv099Ei6ZMI5yPQbI0roAgy0ax3zo/Bub DWRTG59Fq1IczuLukriHNxmgB3+b10WPE9oQXpVWyyjUUlwdVckVcNkup5zEcToaq1VIacw5EdH e2iAE72mO5Jg8WcJNM2lM1kE= X-Envelope-To: linux-iio@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 2ef2b86f5786bcc0; Wed, 02 Dec 2026 12:23:16 +0000 X-Mizu-Trace-ID: 2ef2b86f5786bcc0 X-Migadu-Flow: FLOW_OUT Date: Wed, 2 Dec 2026 12:23:09 +0000 From: Akhilesh Patil To: jic23@kernel.org, andy@kernel.org, krzk+dt@kernel.org, robh@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com, conor+dt@kernel.org, joshua.crofts1@gmail.com, maxwell@maxwelld.cc, u.kleine-koenig@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, akhileshpatilvnit@gmail.com, akhilesh@ee.iitb.ac.in Subject: [PATCH v2 0/2] iio: chemical: Add driver and bindings for acd10 Message-ID: X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This patch series adds support for Aosong ASAIR acd10 CO2 (Carbon dioxide) sensor driver in IIO subsystem. Patch 1: Adds bindings for this hardware Patch 2: Adds driver code for acd10 under drivers/iio/chemical Why new driver under iio/chemical ? I have checked existing chemical drivers from iio/chemical. Many of the drivers are for other vendors and are I2C based with different register layout. They do not match with serial interface of acd10 co2 sensor. ags02ma is the same vendor, but it is an I2C based with a different protocol. There are few drivers with serial interface - scd30, pms7003, sps30, and mhz19b. however their framing, command positions, padding, checksum calculation, supported commands, reply etc, all differ from acd10. Given the above differences from existing drivers, it is my judgement to add a new driver for it. Quick overview of acd10: - This is CO2 sensor based on NDIR technology. - Can measure CO2 concentration up to 5000ppm - Supports serial interface over UART with 1200 baud rate. Datasheet: https://www.es.co.th/Schemetic/PDF/ACD10.PDF Protocol: acd10 defines 4 types of UART frames - read co2, get software version, get instrument number and set single point calibration. Frame format: fixed header, length of data, command code, Actual data, checksum. Response from the sensor follows same format. Total length of each tx and rx frame for 4 commands is fixed and defined in the datasheet. Driver uses this information to write and read from sensor for each command over serdev interface. Testing: Driver is tested on Texas Instruments am62x sk board with sensor connected on UART5 on 40pin IO expander. Additional 3.3 to 5v bidirectional logic translator is used to interface with 3.3v IOs of am62x. Values are read using iio sysfs interface. Also I have blown into the sensor to observe sensor output increase due to CO2 in my exhale. Waveforms for read co2, get sw rev and get ins num commands are validated on logic analyzer. Slight deviation from datasheet: For command get software version, datasheet mentions frame length of 16 bytes including D11 reserved, however it is observed that sensor sends 15 bytes with length field 0xb (11 bytes of data), but actual data is 10 bytes. Hence, this is handled in the driver. Scope of this series: Driver supports reading co2, getting sw version and instrument number(serialnumber). As sensor serial protocol is fairly simple, I have intentionally kept receiver implementation simple. Single point calibration and preheat implementation is left for future contributions and are maked as TODO items in the driver file. Changes in v2: - Fixed possibility of buffer overflow in acd10_receive_buf() by doing bound checks. - Added regulator support in driver. - Added missing MODULE_DEVICE_TABLE() for loadable kernel modules. - Dropped device.h from include files. - Initialized all enum acd10_cmds members explicitly. - Used __must_hold markings for acd10_serdev_transfer() mutex usage. - Protected functions acd10_get_sw_rev() and acd10_get_instrument_num() with mutex lock. - Defined and used ACD10_FRAME_START_IDX and ACD10_FRAME_FIXED_CODE_IDX wherever applicable. - Removed obvious comments from acd10_serdev_transfer(). - Used dev_dbg() instead of dev_info() wherever applicable to avoid more bloated kernel logs. - Mapped instrument number to standard IIO ABI serialnumber and added sysfs attribute code to export it. - Used guard() instead of scoped_guard() inside acd10_read_raw() - Arranged _probe function's local variables as per reverse xmas tree convention. - Used sizeof(*drv_state) instead of sizeof(struct acd10_state) inside _probe function. - Used dev_err_probe() to handle err during probe wherever applicable. - Clean up of devm_iio_device_register() call from _probe function. - Added section "Why new driver" in cover letter of the patch series. - Link to v1: https://lore.kernel.org/linux-iio/cover.1795326744.git.akhilesh.patil@linux.dev/ Akhilesh Patil (2): dt-bindings: iio: chemical: Add aosong acd10 iio: chemical: acd10: Add driver for ACD10 CO2 sensor .../bindings/iio/chemical/aosong,acd10.yaml | 34 ++ MAINTAINERS | 7 + drivers/iio/chemical/Kconfig | 10 + drivers/iio/chemical/Makefile | 3 + drivers/iio/chemical/acd10.c | 389 ++++++++++++++++++ 5 files changed, 443 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/chemical/aosong,acd10.yaml create mode 100644 drivers/iio/chemical/acd10.c -- 2.47.3