devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/3] iio: light: stk3310: stk3013 support
@ 2024-07-26 18:53 Kaustabh Chakraborty
  2024-07-26 18:53 ` [PATCH v4 1/3] iio: light: stk3310: relax chipid check warning Kaustabh Chakraborty
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Kaustabh Chakraborty @ 2024-07-26 18:53 UTC (permalink / raw)
  To: Jonathan Cameron, Conor Dooley
  Cc: linux-iio, devicetree, Kaustabh Chakraborty

STK3013 is a part manufactured by Sensortek which is marketed as a [1]
"Proximity Sensor". This part is available in several consumer mobile
devices, including, but not limited to, Samsung Galaxy J7 Prime and
Samsung Galaxy A2 Core.

The existing ambient light sensor seemed suitable for this chip, and on
enabling the driver, it was discovered that these "Proximity Sensors" had
ambient light sensing capabilities as well.

The downstream kernel driver shipped with this phone by Samsung [2] exposes
a sysfs interface for proximity sensing, but leaves out the light sensing
features, hence there's no such functionality in userspace.

The following patch series aims to add support for STK3013 as an
ambient light/proximity sensor.

[1] https://www.sensortek.com.tw/index.php/en/products/optical-sensor/
[2] https://github.com/samsungexynos7870/android_kernel_samsung_exynos7870/blob/master/drivers/sensors/stk3013.c

Changes in v4:
- fixed incorrect indentation in doc
- Link to v3: https://lore.kernel.org/r/20240721-stk3310-v3-0-98fcb6f551a1@disroot.org

Changes in v3:
- added a cover letter to the patch series
- added stk3310 as a fallback compatible
- Link to v2: https://lore.kernel.org/r/20240712152417.97726-1-kauschluss@disroot.org

Changes in v2:
- added a commit to relax unknown chipid warning
- missed "v2" in patches
- Link to v1: https://lore.kernel.org/r/20240625165122.231182-1-kauschluss@disroot.org

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
---
Kaustabh Chakraborty (3):
      iio: light: stk3310: relax chipid check warning
      iio: light: stk3310: add support for stk3013
      dt-bindings: iio: light: stk33xx: add compatible for stk3013

 Documentation/devicetree/bindings/iio/light/stk33xx.yaml | 13 +++++++++----
 drivers/iio/light/stk3310.c                              |  7 ++++++-
 2 files changed, 15 insertions(+), 5 deletions(-)
---
base-commit: 62c97045b8f720c2eac807a5f38e26c9ed512371
change-id: 20240714-stk3310-658f6f34a798

Best regards,
-- 
Kaustabh Chakraborty <kauschluss@disroot.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v4 1/3] iio: light: stk3310: relax chipid check warning
  2024-07-26 18:53 [PATCH v4 0/3] iio: light: stk3310: stk3013 support Kaustabh Chakraborty
@ 2024-07-26 18:53 ` Kaustabh Chakraborty
  2024-07-26 18:53 ` [PATCH v4 2/3] iio: light: stk3310: add support for stk3013 Kaustabh Chakraborty
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Kaustabh Chakraborty @ 2024-07-26 18:53 UTC (permalink / raw)
  To: Jonathan Cameron, Conor Dooley
  Cc: linux-iio, devicetree, Kaustabh Chakraborty

In order to allow newer devices which are compatible with existing
sensors, issuing a warning for an unknown chipid indicates that
something has gone wrong with the init process, which isn't ideal.
Swap it with a friendlier info message to get things right.

Suggested-by: Conor Dooley <conor@kernel.org>
Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
---
 drivers/iio/light/stk3310.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index e3470d6743ef..48a971de6a04 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -496,7 +496,7 @@ static int stk3310_init(struct iio_dev *indio_dev)
 
 	ret = stk3310_check_chip_id(chipid);
 	if (ret < 0)
-		dev_warn(&client->dev, "unknown chip id: 0x%x\n", chipid);
+		dev_info(&client->dev, "new unknown chip id: 0x%x\n", chipid);
 
 	state = STK3310_STATE_EN_ALS | STK3310_STATE_EN_PS;
 	ret = stk3310_set_state(data, state);

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 2/3] iio: light: stk3310: add support for stk3013
  2024-07-26 18:53 [PATCH v4 0/3] iio: light: stk3310: stk3013 support Kaustabh Chakraborty
  2024-07-26 18:53 ` [PATCH v4 1/3] iio: light: stk3310: relax chipid check warning Kaustabh Chakraborty
@ 2024-07-26 18:53 ` Kaustabh Chakraborty
  2024-07-26 18:53 ` [PATCH v4 3/3] dt-bindings: iio: light: stk33xx: add compatible " Kaustabh Chakraborty
  2024-07-28 17:05 ` [PATCH v4 0/3] iio: light: stk3310: stk3013 support Jonathan Cameron
  3 siblings, 0 replies; 7+ messages in thread
From: Kaustabh Chakraborty @ 2024-07-26 18:53 UTC (permalink / raw)
  To: Jonathan Cameron, Conor Dooley
  Cc: linux-iio, devicetree, Kaustabh Chakraborty

Add support for Sensortek's STK3013 in the driver. The part bears the
product ID 0x31.

As seen in [1], Sensortek lists STK3013 as a proximity sensor. But it
has been experimentally observed that they do have ambient light sensing
capabilities. Furthermore, [2] implements a proximity and ambient light
sensor driver for STK3x1x devices, which is also indicative of the fact
that these parts are also ambient light sensors.

[1] https://www.sensortek.com.tw/index.php/en/products/optical-sensor/
[2] https://android.googlesource.com/kernel/msm.git/+/e6dfa4641d88201e8019be19ff557e5d2cf4572f

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
---
 drivers/iio/light/stk3310.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index 48a971de6a04..ed20b6714546 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -35,6 +35,7 @@
 #define STK3310_STATE_EN_ALS			BIT(1)
 #define STK3310_STATE_STANDBY			0x00
 
+#define STK3013_CHIP_ID_VAL			0x31
 #define STK3310_CHIP_ID_VAL			0x13
 #define STK3311_CHIP_ID_VAL			0x1D
 #define STK3311A_CHIP_ID_VAL			0x15
@@ -84,6 +85,7 @@ static const struct reg_field stk3310_reg_field_flag_nf =
 				REG_FIELD(STK3310_REG_FLAG, 0, 0);
 
 static const u8 stk3310_chip_ids[] = {
+	STK3013_CHIP_ID_VAL,
 	STK3310_CHIP_ID_VAL,
 	STK3311A_CHIP_ID_VAL,
 	STK3311S34_CHIP_ID_VAL,
@@ -700,6 +702,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk3310_suspend,
 				stk3310_resume);
 
 static const struct i2c_device_id stk3310_i2c_id[] = {
+	{ "STK3013" },
 	{ "STK3310" },
 	{ "STK3311" },
 	{ "STK3335" },
@@ -708,6 +711,7 @@ static const struct i2c_device_id stk3310_i2c_id[] = {
 MODULE_DEVICE_TABLE(i2c, stk3310_i2c_id);
 
 static const struct acpi_device_id stk3310_acpi_id[] = {
+	{"STK3013", 0},
 	{"STK3310", 0},
 	{"STK3311", 0},
 	{}
@@ -716,6 +720,7 @@ static const struct acpi_device_id stk3310_acpi_id[] = {
 MODULE_DEVICE_TABLE(acpi, stk3310_acpi_id);
 
 static const struct of_device_id stk3310_of_match[] = {
+	{ .compatible = "sensortek,stk3013", },
 	{ .compatible = "sensortek,stk3310", },
 	{ .compatible = "sensortek,stk3311", },
 	{ .compatible = "sensortek,stk3335", },

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 3/3] dt-bindings: iio: light: stk33xx: add compatible for stk3013
  2024-07-26 18:53 [PATCH v4 0/3] iio: light: stk3310: stk3013 support Kaustabh Chakraborty
  2024-07-26 18:53 ` [PATCH v4 1/3] iio: light: stk3310: relax chipid check warning Kaustabh Chakraborty
  2024-07-26 18:53 ` [PATCH v4 2/3] iio: light: stk3310: add support for stk3013 Kaustabh Chakraborty
@ 2024-07-26 18:53 ` Kaustabh Chakraborty
  2024-07-30 16:25   ` Rob Herring (Arm)
  2024-07-28 17:05 ` [PATCH v4 0/3] iio: light: stk3310: stk3013 support Jonathan Cameron
  3 siblings, 1 reply; 7+ messages in thread
From: Kaustabh Chakraborty @ 2024-07-26 18:53 UTC (permalink / raw)
  To: Jonathan Cameron, Conor Dooley
  Cc: linux-iio, devicetree, Kaustabh Chakraborty

STK3013 is a proximity sensor by Sensortek, bearing chipid of 0x31. Despite
being marketed as a proximity sensor, it also appears to have ambient
light sensing capabilities.

The part is fully compatible with the existing implementation of the
device driver. Add the compatible string of stk3013 to the existing
list, with a fallback of stk3310.

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
---
 Documentation/devicetree/bindings/iio/light/stk33xx.yaml | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
index f6e22dc9814a..e4341fdced98 100644
--- a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
+++ b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
@@ -18,10 +18,15 @@ allOf:
 
 properties:
   compatible:
-    enum:
-      - sensortek,stk3310
-      - sensortek,stk3311
-      - sensortek,stk3335
+    oneOf:
+      - enum:
+          - sensortek,stk3310
+          - sensortek,stk3311
+          - sensortek,stk3335
+      - items:
+          - enum:
+              - sensortek,stk3013
+          - const: sensortek,stk3310
 
   reg:
     maxItems: 1

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 0/3] iio: light: stk3310: stk3013 support
  2024-07-26 18:53 [PATCH v4 0/3] iio: light: stk3310: stk3013 support Kaustabh Chakraborty
                   ` (2 preceding siblings ...)
  2024-07-26 18:53 ` [PATCH v4 3/3] dt-bindings: iio: light: stk33xx: add compatible " Kaustabh Chakraborty
@ 2024-07-28 17:05 ` Jonathan Cameron
  2024-07-30 18:17   ` Jonathan Cameron
  3 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2024-07-28 17:05 UTC (permalink / raw)
  To: Kaustabh Chakraborty; +Cc: Conor Dooley, linux-iio, devicetree

On Sat, 27 Jul 2024 00:23:30 +0530
Kaustabh Chakraborty <kauschluss@disroot.org> wrote:

> STK3013 is a part manufactured by Sensortek which is marketed as a [1]
> "Proximity Sensor". This part is available in several consumer mobile
> devices, including, but not limited to, Samsung Galaxy J7 Prime and
> Samsung Galaxy A2 Core.
> 
> The existing ambient light sensor seemed suitable for this chip, and on
> enabling the driver, it was discovered that these "Proximity Sensors" had
> ambient light sensing capabilities as well.
> 
> The downstream kernel driver shipped with this phone by Samsung [2] exposes
> a sysfs interface for proximity sensing, but leaves out the light sensing
> features, hence there's no such functionality in userspace.
> 
> The following patch series aims to add support for STK3013 as an
> ambient light/proximity sensor.
> 
> [1] https://www.sensortek.com.tw/index.php/en/products/optical-sensor/
> [2] https://github.com/samsungexynos7870/android_kernel_samsung_exynos7870/blob/master/drivers/sensors/stk3013.c
Series LGTM. I'll leave it on list for a few more days though for other
review to come in.

Thanks,

Jonathan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 3/3] dt-bindings: iio: light: stk33xx: add compatible for stk3013
  2024-07-26 18:53 ` [PATCH v4 3/3] dt-bindings: iio: light: stk33xx: add compatible " Kaustabh Chakraborty
@ 2024-07-30 16:25   ` Rob Herring (Arm)
  0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring (Arm) @ 2024-07-30 16:25 UTC (permalink / raw)
  To: Kaustabh Chakraborty
  Cc: Jonathan Cameron, Conor Dooley, linux-iio, devicetree


On Sat, 27 Jul 2024 00:23:33 +0530, Kaustabh Chakraborty wrote:
> STK3013 is a proximity sensor by Sensortek, bearing chipid of 0x31. Despite
> being marketed as a proximity sensor, it also appears to have ambient
> light sensing capabilities.
> 
> The part is fully compatible with the existing implementation of the
> device driver. Add the compatible string of stk3013 to the existing
> list, with a fallback of stk3310.
> 
> Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
> ---
>  Documentation/devicetree/bindings/iio/light/stk33xx.yaml | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 

Acked-by: Rob Herring (Arm) <robh@kernel.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 0/3] iio: light: stk3310: stk3013 support
  2024-07-28 17:05 ` [PATCH v4 0/3] iio: light: stk3310: stk3013 support Jonathan Cameron
@ 2024-07-30 18:17   ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2024-07-30 18:17 UTC (permalink / raw)
  To: Kaustabh Chakraborty; +Cc: Conor Dooley, linux-iio, devicetree

On Sun, 28 Jul 2024 18:05:41 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Sat, 27 Jul 2024 00:23:30 +0530
> Kaustabh Chakraborty <kauschluss@disroot.org> wrote:
> 
> > STK3013 is a part manufactured by Sensortek which is marketed as a [1]
> > "Proximity Sensor". This part is available in several consumer mobile
> > devices, including, but not limited to, Samsung Galaxy J7 Prime and
> > Samsung Galaxy A2 Core.
> > 
> > The existing ambient light sensor seemed suitable for this chip, and on
> > enabling the driver, it was discovered that these "Proximity Sensors" had
> > ambient light sensing capabilities as well.
> > 
> > The downstream kernel driver shipped with this phone by Samsung [2] exposes
> > a sysfs interface for proximity sensing, but leaves out the light sensing
> > features, hence there's no such functionality in userspace.
> > 
> > The following patch series aims to add support for STK3013 as an
> > ambient light/proximity sensor.
> > 
> > [1] https://www.sensortek.com.tw/index.php/en/products/optical-sensor/
> > [2] https://github.com/samsungexynos7870/android_kernel_samsung_exynos7870/blob/master/drivers/sensors/stk3013.c  
> Series LGTM. I'll leave it on list for a few more days though for other
> review to come in.
> 
> Thanks,
> 
> Jonathan
> 
Applied and initially pushed out as testing for 0-day to take a first look at
this.

Thanks,

Jonathan



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-07-30 18:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-26 18:53 [PATCH v4 0/3] iio: light: stk3310: stk3013 support Kaustabh Chakraborty
2024-07-26 18:53 ` [PATCH v4 1/3] iio: light: stk3310: relax chipid check warning Kaustabh Chakraborty
2024-07-26 18:53 ` [PATCH v4 2/3] iio: light: stk3310: add support for stk3013 Kaustabh Chakraborty
2024-07-26 18:53 ` [PATCH v4 3/3] dt-bindings: iio: light: stk33xx: add compatible " Kaustabh Chakraborty
2024-07-30 16:25   ` Rob Herring (Arm)
2024-07-28 17:05 ` [PATCH v4 0/3] iio: light: stk3310: stk3013 support Jonathan Cameron
2024-07-30 18:17   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).