io: light: tcs3472: Add TMD3782 proximity support#445
Open
playday3008 wants to merge 8 commits intomsm8916-mainline:msm8916/6.12.1from
Open
io: light: tcs3472: Add TMD3782 proximity support#445playday3008 wants to merge 8 commits intomsm8916-mainline:msm8916/6.12.1from
playday3008 wants to merge 8 commits intomsm8916-mainline:msm8916/6.12.1from
Conversation
Note that a5-zt no longer exists in newer branches and it's now a5ltezt. |
added 8 commits
April 29, 2026 16:25
Add devicetree binding for the AMS/TAOS TCS3472 RGBC color light sensor and TMD3782 RGBC + proximity sensor. The TCS3472 has no existing binding despite having a mainline driver since 2013. The TMD3782 is a superset of TCS3472 adding an integrated proximity detector with IR LED. Additional properties for proximity configuration (pulse count, LED current, LED supply) are optional and only relevant for TMD3782.
Add of_device_id table for devicetree-based probing of TCS3472 and TMD3782 sensors. Add optional vdd/vddio regulator support with 2.4ms power-on settling delay. Update tcs3472_powerdown() to write 0x00 for full chip power-down instead of only clearing AEN+PON. This is a behavior change: the old code preserved AIEN, the new code clears everything. This is safe because resume now performs a full register restore. Update resume to rewrite all configuration registers (ATIME, WTIME, thresholds, PERS, CONFIG, CONTROL, ENABLE) and clear stale interrupt flags. This hardens against potential register state loss during PON=0. Remove hardcoded IRQF_TRIGGER_FALLING from request_threaded_irq to let the devicetree specify the interrupt trigger type.
Add tcs3472_chip_info struct to hold per-variant channel arrays, channel counts, and feature flags. This prepares for adding TMD3782 proximity support without scattering variant checks throughout the driver. No functional change — only TCS3472 is populated. The TMD3782 entry will be added when proximity support lands.
Add proximity register definitions for the TMD3782 (PILT, PIHT, PPULSE, PDATA, PIEN, PEN, WEN, PINT, PVALID) and interrupt clear commands. Detect TMD3782 chip IDs (0x60 for TMD37821, 0x69 for TMD37823) in probe. Initialize the CONTROL register with the mandatory bit 5 and LED drive current from the led-max-microamp DT property. Configure proximity pulse count from DT (default 8) and set PPERS to 3 to match downstream behavior. Fix the PERS register write to merge both APERS and PPERS nibbles, preventing the existing bug where writing APERS clobbers PPERS. Extend resume to restore proximity thresholds, pulse count, and clear stale interrupt flags from both ALS and proximity.
Add proximity channel (IIO_PROXIMITY, scan_index 4) to TMD3782 channel array. The proximity data register at 0x1C fits the existing trigger handler's CDATA+2*i arithmetic naturally: 0xB4+8 = 0xBC. Add proximity threshold events (rising/falling/enable) with a separate event spec — no IIO_EV_INFO_PERIOD since PPERS uses a linear count, not the non-linear APERS mapping. PPERS is fixed at 3 (not configurable by userspace in v1). Extend event value read/write for proximity thresholds (PILT/PIHT). Extend write_event_config to manage PEN+WEN+PIEN for proximity events, with proper coordination against buffer enable state. Guard against enabling interrupts when no IRQ is configured. Extend interrupt handler to check both AINT and PINT in STATUS and clear only the interrupts actually observed, preventing a race where a new interrupt between STATUS read and clear would be silently lost.
Extend tcs3472_req_data() to accept a status mask parameter for polling AVALID, PVALID, or both. For direct-mode proximity reads (in_proximity_raw), temporarily enable PEN+WEN when no events or buffer are active. Uses a re-check-under-lock pattern on teardown to avoid clobbering concurrent event enables. Add buffer preenable/postdisable callbacks that manage PEN+WEN when the proximity channel (scan_index 4) is in the active scan mask. This prevents the trigger handler from hanging on PVALID when PEN is off. Coordinates with event enable state so neither path clobbers the other.
Add TMD3782 RGBC + proximity sensor on blsp_i2c2 at address 0x39. Uses GPIO113 as level-triggered interrupt input and GPIO8 as VDD enable for the sensor (modeled as a fixed regulator). The sensor shares the I2C bus with the existing BMC150 accelerometer and magnetometer. VDD (GPIO8) and VDDIO (pm8916_l5) need explicit control. The a5-zt variant inherits this node via its include of a5u-eur.dts.
Add TMD3782 RGBC + proximity sensor on the bit-banged i2c-sensor bus at address 0x39. Uses GPIO113 as level-triggered interrupt input. Unlike the A5 which uses a GPIO-controlled fixed regulator for sensor VDD, the A7 powers the sensor directly from pm8916_l17.
803ff70 to
8798788
Compare
Author
Well, I was working against same kernel version that was in pmOS edge for Galaxy A5, couldn't get latest kernel from source running, so, was writing patches against same version that was on device. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add TMD3782 RGBC + proximity sensor support to the tcs3472 driver and enable it on Samsung Galaxy A5/A7 device trees.
Driver changes (patches 1-6):
Device tree changes (patches 7-8):
Based on msm8916/6.12.1 from msm8916-mainline/linux.