From nobody Wed Nov 27 21:29:24 2024 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CEE31DE897; Mon, 7 Oct 2024 20:36:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728333419; cv=none; b=oXeTNw8eWL/MViSRqVYW9ayp0XAnAQsQyNewNbw5SEAZAhUxx3c/TWVrI9CVZzT6sMUAmsaFXJs5/e6U/G1DS67VNYpHURhb2s4gkkyVzKWJxqkGihvJLRxVYdBbeeYZufOWcljHszJQjof6w+gqDZTeRafeLdENn5gs+jztNEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728333419; c=relaxed/simple; bh=y4vqS5nfCnERP4qzOWuVu6eCZ3By6WEqi9MYZeckG9U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cNq30lcVApFmOfJtW9dc7SSLSYnk3CdJjA6lCmp9TN/zu4Ilau4/JHDm0PyIpljeo8Pmg73uTyZ8uCki4DMLvrAD14UZvjtUela7JpeUdx/d129DiUy7FBema/hDGOODVrxeESsr4PYI7IFl3JBi2Qdev1uOCYhR5sNcrz/VdwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=K2Jy12nJ; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K2Jy12nJ" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-539908f238fso5462446e87.2; Mon, 07 Oct 2024 13:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728333416; x=1728938216; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=k2maYBiM5LIOhyk/i3lQ3qKHgbPUsqZuC6OiA0rm4sE=; b=K2Jy12nJVlB2kzqdq1xCikiXRJwqUl2KHKjEzvKHQFBY7ce13AFzSKrAOR39Z8y6KK ZvrbSb6o8u2ij4twwYAatTfkGgdYY25B7oY8A/KNxe9QB5CxYnsipu4aLqPxRMCfznS3 hpZ5VZBTOUXufQBuuI1hctdhe0Gzu05xoD8KoefH4tTwInJfSuIj2bogNoMwOfR8DCEv tJRTqRbbJCdSE63bm7o0yPHKiTYyJmyyAJTbPgbjsv9SmGw0WoWvRRZKArMVLLGibMWe IrpndrD38jwaS412mTW1VDmdg4/xwDcSE+5SScsEPEkyro0tiAljJaRtuXvFzmIGJu9o Dluw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728333416; x=1728938216; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k2maYBiM5LIOhyk/i3lQ3qKHgbPUsqZuC6OiA0rm4sE=; b=uAJy4xGWHrh2MWaAcU5VyqT6Q/rhn/laWzX3reuSElZKQKAT/G7iGPpoJyrV90KCII vFi6De9aUi5Th/VUgnDkeF4NmVXCVi6EIdCfab3MjZoj/EOPXtMkzdMkhKTBJPgm5vWR y6P72rVoQfksfbsbUbgy6ZPJ610aps1/asWNNdm08UreZKncagRI6QoNLFtyUP4XY7K5 oT5Lk+aCRlcnbqa5vcl1Sgs7FfBxTCXPpoXrsLx0ipkDiASskhZmwumEmihiENFIFotq CeVfHqRfZX2C+rS6sqwxDcHP9cqPJTftPqSYlI5NyfPS2/WySS9DpxVHan863JMX1J4O uYDQ== X-Forwarded-Encrypted: i=1; AJvYcCW2N4yDAGTplbbWT+spKiBkbjQ0FbAyFl2AQRub5LIgLmAXCN17qsoEzRm/Uz+i8qks78qpcVrwj1Yi@vger.kernel.org, AJvYcCWLO0eh/ZPNXTACuc5nO6H9f3u0jIDqp67/6opZHBUdoNzcnL1X+j44tXNF0t/bDEnUD2sACodyXV4EAjV+@vger.kernel.org, AJvYcCXckXoCPFWZXIlZudTt5G9LfcUMBcyEXBXw5fZrxveRHtvA3ynQCQr9GKpVaPlAb7H+ao2tsGYVm76W@vger.kernel.org X-Gm-Message-State: AOJu0YxlcazbQ6R6Vvvz2L2nLpmUlyhoFtHPnPnO8xNb75CInkZ1U9iE namZe3JRrrUSeLtEX11ZUNeAYoZ89i693Ez8if2B29W8bi6uOtp8D8wNgA== X-Google-Smtp-Source: AGHT+IH6cLAUJNTcmZyhSx914kndG2XyPmg8cfvfVi+R9NAIzUtsooMjqhFu8imn1PFV7qc1Q2YxJw== X-Received: by 2002:a05:6512:3d93:b0:533:d3e:16fe with SMTP id 2adb3069b0e04-539ab9eae13mr6638267e87.38.1728333415276; Mon, 07 Oct 2024 13:36:55 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-26cc-001d-7ed0-e346.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:26cc:1d:7ed0:e346]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1690f75bsm6464315f8f.23.2024.10.07.13.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 13:36:53 -0700 (PDT) From: Javier Carrasco Date: Mon, 07 Oct 2024 22:36:36 +0200 Subject: [PATCH 1/3] iio: light: veml6035: fix read_avail in no_irq case for veml6035 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241007-veml7700-v1-1-fb85dd839d63@gmail.com> References: <20241007-veml7700-v1-0-fb85dd839d63@gmail.com> In-Reply-To: <20241007-veml7700-v1-0-fb85dd839d63@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1728333411; l=3278; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=y4vqS5nfCnERP4qzOWuVu6eCZ3By6WEqi9MYZeckG9U=; b=d8Fnn37QwWjf77/oAvh13BikQMOj9HD96wgh4hFpEuy1zxc7fbsQwtR8yUxdIWgxGl9NA4fL1 CRCPgjrxNtgBtuytsvT+N+nfc0CcjkIHOpt4IFdLEuyay3PjVU5N+UZ X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The iio_info is identical for veml6030 and veml6035. Moreover, veml6035_info_no_irq is missing the initialization of the read_avail member, which is actually a bug if no irq is provided. Instead of adding the missing initialization, remove the device-specific iio_info and use the existing one for the veml6030. Fixes: ccc26bd7d7d7 ("iio: light: veml6030: add support for veml6035") Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index a5deae333554..ca0379945b1c 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -56,8 +56,6 @@ struct veml603x_chip { const char *name; const int(*scale_vals)[][2]; const int num_scale_vals; - const struct iio_info *info; - const struct iio_info *info_no_irq; int (*hw_init)(struct iio_dev *indio_dev, struct device *dev); int (*set_als_gain)(struct iio_dev *indio_dev, int val, int val2); int (*get_als_gain)(struct iio_dev *indio_dev, int *val, int *val2); @@ -829,28 +827,12 @@ static const struct iio_info veml6030_info =3D { .event_attrs =3D &veml6030_event_attr_group, }; =20 -static const struct iio_info veml6035_info =3D { - .read_raw =3D veml6030_read_raw, - .read_avail =3D veml6030_read_avail, - .write_raw =3D veml6030_write_raw, - .read_event_value =3D veml6030_read_event_val, - .write_event_value =3D veml6030_write_event_val, - .read_event_config =3D veml6030_read_interrupt_config, - .write_event_config =3D veml6030_write_interrupt_config, - .event_attrs =3D &veml6030_event_attr_group, -}; - static const struct iio_info veml6030_info_no_irq =3D { .read_raw =3D veml6030_read_raw, .read_avail =3D veml6030_read_avail, .write_raw =3D veml6030_write_raw, }; =20 -static const struct iio_info veml6035_info_no_irq =3D { - .read_raw =3D veml6030_read_raw, - .write_raw =3D veml6030_write_raw, -}; - static irqreturn_t veml6030_event_handler(int irq, void *private) { int ret, reg, evtdir; @@ -1039,9 +1021,9 @@ static int veml6030_probe(struct i2c_client *client) "irq %d request failed\n", client->irq); =20 - indio_dev->info =3D data->chip->info; + indio_dev->info =3D &veml6030_info; } else { - indio_dev->info =3D data->chip->info_no_irq; + indio_dev->info =3D &veml6030_info_no_irq; } =20 ret =3D data->chip->hw_init(indio_dev, &client->dev); @@ -1084,8 +1066,6 @@ static const struct veml603x_chip veml6030_chip =3D { .name =3D "veml6030", .scale_vals =3D &veml6030_scale_vals, .num_scale_vals =3D ARRAY_SIZE(veml6030_scale_vals), - .info =3D &veml6030_info, - .info_no_irq =3D &veml6030_info_no_irq, .hw_init =3D veml6030_hw_init, .set_als_gain =3D veml6030_set_als_gain, .get_als_gain =3D veml6030_get_als_gain, @@ -1095,8 +1075,6 @@ static const struct veml603x_chip veml6035_chip =3D { .name =3D "veml6035", .scale_vals =3D &veml6035_scale_vals, .num_scale_vals =3D ARRAY_SIZE(veml6035_scale_vals), - .info =3D &veml6035_info, - .info_no_irq =3D &veml6035_info_no_irq, .hw_init =3D veml6035_hw_init, .set_als_gain =3D veml6035_set_als_gain, .get_als_gain =3D veml6035_get_als_gain, --=20 2.43.0 From nobody Wed Nov 27 21:29:24 2024 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85A331DE8B1; Mon, 7 Oct 2024 20:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728333421; cv=none; b=nL8uyBa9iZo5967J8Y7o7Z5X121v9L+u4NxpHzyVoY50Y95N8+lJCR0AW9kRxDAB67KfprHD2ZzZkQ5hwgheDGv7kkDslWjYlPD0so2H1SYhwcjXoJL8DoZYuwX1dyAM8B38X3krgQo+adK8pXUPHHZq14RZ/0BBNoBmUcSbWTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728333421; c=relaxed/simple; bh=0g8TwFDtanIN2XC2B0GQ8d8dwsTdPMy2x28iNYCMoGM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pmMyw40QAFX2Nnk0zG0abDYv2nQE31lcCFug53ywxH3dq8YsLh6ql+erlu/Ex6tTC247UR4koDlgfGO/zZ2vH8BpwVHjB+K8eoMsHJaowlIReWa/yY+wgS5jkCWiPTzCqpPgkk5gJJVkkcT5qfcOIMlKxHfEz63TxjkKE6MN940= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iMtDiSX1; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iMtDiSX1" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-37cdb42b29dso3083029f8f.0; Mon, 07 Oct 2024 13:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728333418; x=1728938218; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fsEp6JbURkIC0sqAA8ljjlQfh1UMQrk51Wr0yDIIrao=; b=iMtDiSX1z7vAJE4divroQ/a1poKgakdE+9nlH4uHK4aq4CuYImlGl5ggI/UgcA9MTT x5NpLRJDB67cy6PgDaXgYC9ZpzjV8NHnU5c+rseSFvX6+nC8DyIk6dwdn7gwVVrpl0SU ur0yocQ+pYOM/v6JaeVQ8TtCojPIz06HVfAAsen9zunVLgIcImGe67oTPOeW/W4wW1c4 7q055ByGRvjXqSCflXKOA1I+WzHY1qpZ9dBCq78kTxMsgqTxWnvGD9YWHNu8P5B0HruH RX1qF6s0y8/G+TToB+LAJafFkA2KMU/aPzW+m3VWj65jN9v7X2rX1r+QXL05qjD4WVwk jCiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728333418; x=1728938218; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fsEp6JbURkIC0sqAA8ljjlQfh1UMQrk51Wr0yDIIrao=; b=tbk9HnXh2gQfyDrIdGS+Q8gWqtEEueHBzc4P+9FuMg8ZxXD/oyY5qXYCkbuW0r6WE6 wAuLcbspqQ2jrB3m4uxoTgKW6owrCXjr9MAhkomIzyimH55+IfeAO1bOhw6TH53nbWsc yImATc2U+UgfmjwtiKCVUeB6AxH9QL0K7dHk6uwBcVJnLX7seaF4paGm46RCKsCWAZxH UunCMjowCoilS3NAJGfDpxZWm2J351mF8G2mb5dPMhy2Fy9ZZv55aCdul8Rb2DDwhtNa ZH2JP/9mejWctpPpggCdtFs3393r62TP6HVn1BbI+PvZkPBfPw8ovdRU6+SHozctoFvb siVg== X-Forwarded-Encrypted: i=1; AJvYcCUBS343G2Hv6blvtURnH4npTiXbU6CGmPOm12uoD4O3g2JQJV58rQ9OwfLXH7jd58GY/p4Aza4yUh/C@vger.kernel.org, AJvYcCX2H+Hf9Dq2oLHxUd8EhxTMGxnHz4mDE4aasKY8mX7MNl5nEnyiE/9Kv50ddHdpFpLRFF0e29S5RKhtt1G8@vger.kernel.org, AJvYcCXNeHvaSDWM1F10dc7WBMrPZKySfZWWBbVL7q6VKxJEARuJK1UwNPOpViMRDyXE1Eg/eo/p0D9jSNZR@vger.kernel.org X-Gm-Message-State: AOJu0Yz8WvWAW7NSO3VCqaT5+VoGEOJhx+Y6oS+YIvjEz/nopabniEo0 m3RLbopFIFmHubdRI81ThpRNcUORiErfpd1Vs9k014hoHU4XvsJTI3SPGQ== X-Google-Smtp-Source: AGHT+IHQYP2GNN7cRMNPaTK2X44OXEPNbrJxNlU3BEddKMEMAo1GvAUaeusXAgrzbXv7UqsCeYv1DA== X-Received: by 2002:adf:ed8d:0:b0:37c:ddab:a626 with SMTP id ffacd0b85a97d-37d0e6d3172mr8116742f8f.7.1728333417527; Mon, 07 Oct 2024 13:36:57 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-26cc-001d-7ed0-e346.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:26cc:1d:7ed0:e346]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1690f75bsm6464315f8f.23.2024.10.07.13.36.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 13:36:57 -0700 (PDT) From: Javier Carrasco Date: Mon, 07 Oct 2024 22:36:37 +0200 Subject: [PATCH 2/3] dt-bindings: iio: light: veml6030: add veml7700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241007-veml7700-v1-2-fb85dd839d63@gmail.com> References: <20241007-veml7700-v1-0-fb85dd839d63@gmail.com> In-Reply-To: <20241007-veml7700-v1-0-fb85dd839d63@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1728333411; l=1816; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=0g8TwFDtanIN2XC2B0GQ8d8dwsTdPMy2x28iNYCMoGM=; b=hvBUoo/QBGU1eDWfcCAiTRIbollF4Fw/SA+Ay0kup3a+pcPr63u0dZVWLt54DSxn2s47tmBs4 X0oLKuJjtH4Dcdnw0HDQxV3j+yA3Zwo1ImvumTBjQ2QMJib/gRb3GNL X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The veml7700 contains the same chip as the veml6030 in a different package with no interrupt line and no pin to select the I2C address, which makes it suitable to be supported by the same bindings. Signed-off-by: Javier Carrasco Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/iio/light/vishay,veml6030.yaml | 16 ++++++++++++= +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6030.ya= ml b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml index 6218273b0e86..53b55575efd3 100644 --- a/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml +++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml @@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/iio/light/vishay,veml6030.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: VEML6030 and VEML6035 Ambient Light Sensors (ALS) +title: VEML6030, VEML6035 and VEML7700 Ambient Light Sensors (ALS) =20 maintainers: - Rishi Gupta @@ -22,12 +22,14 @@ description: | Specifications about the sensors can be found at: https://www.vishay.com/docs/84366/veml6030.pdf https://www.vishay.com/docs/84889/veml6035.pdf + https://www.vishay.com/docs/84286/veml7700.pdf =20 properties: compatible: enum: - vishay,veml6030 - vishay,veml6035 + - vishay,veml7700 =20 reg: maxItems: 1 @@ -70,6 +72,18 @@ allOf: enum: - 0x29 =20 + - if: + properties: + compatible: + enum: + - vishay,veml7700 + then: + properties: + reg: + enum: + - 0x10 + interrupts: false + additionalProperties: false =20 examples: --=20 2.43.0 From nobody Wed Nov 27 21:29:24 2024 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63C0E1DE4F6; Mon, 7 Oct 2024 20:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728333427; cv=none; b=OUckjvTtpDlT9ER0hIy6xZCV4WodBleLNgsntbuSCpNIOso6ojQWBa7wJiVTl6zM4RgdPLyIlGxuQZJn0WonHUUQuHh4SHouhdR/vet16fbFCDGRk33svwFsxzEXULKR9IG2XfRdx+5m7ZDVrVqUfHHqIx4JpyQGWsrbqcibHX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728333427; c=relaxed/simple; bh=ffBqKTIzKKORtDAQTnF0ixHeiBBU1WJxjkoh95cX3hQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SxPMXYP+UTIecb+0S5VdWzYtnCP+JNzk21OLDMLWc2cqvqx4CTk1uaG80a4C8qjscFs8X2wy8GljKAsHw07dRnPgD8Z20B3LlKWUAYQc1sEQ8HksKAGtbnaKymttGIOHJ78quL5rR2746Jcb1V9M+KFEwOUa/fMhi1EgYq6+xgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gV/yCC2M; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gV/yCC2M" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-37cd8a5aac9so2619369f8f.2; Mon, 07 Oct 2024 13:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728333424; x=1728938224; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=R0B/ACvOpGHW6u8EpRZ7oeA/qI9QuVr63Qwli6fHJpg=; b=gV/yCC2MdfGYzqT2FnYyouQJlzI+VmF1ZaPqG5AmiQLqZyUXgt9cBcpGv4lO4dh3yw 546VUDdhLs7UsBNEfxioQioiHjydhF91rmjJBRiH8NWxm5ZaG7uDLzEuh2BCgoBzNpBn iHh0NS2dcUFgvA7CpwOAnEy9dcRFX96HDgzxcDSyL7xUWPpV/MtAdhEI2hsif03pMMug 3eQywi5C0BBla8GvPO5lykiosVVn/0XJPgivi2NmzoHpZVbW2gw7oQ6LwCJFNTbOiJmY dk/RKpvNhYdeil18hB36jbTzLV5ggQFbiewFrdWacFORe3muAbo7sO6gWelSvnlUf0NC PIbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728333424; x=1728938224; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R0B/ACvOpGHW6u8EpRZ7oeA/qI9QuVr63Qwli6fHJpg=; b=wW4wijwwiCSJ58W7fndxPJ2+EtIHWt5e7Rk3RWG8+VPZN058FOAmCy1qNU3UKNoy+Z N5U39vxTph+V3ges99F2CNIS3B8t534/N/7bOG2Cdmgc1JylK53hxIP86dbZRRKXulYn 5A/APCCIetR7uffG76s4VOmQ+fYXqrKGyZwmCP+q81YnHM7t5ughIwU5W5OjL8L/R9mr wh1Sgbyvy8m4cMI/U1vdgcdEMFZnBm9kngGc0oy4soXswXwLp95pAkzB2O5KTIuXO1H5 UlraDCBUcowvCPLYZIx/UbC2dK9pRqgosdqspb1GVpNUh0QUPa5uI4oV/xdErEClg0g0 +ItQ== X-Forwarded-Encrypted: i=1; AJvYcCWN8Rd9LSxzcec3a90Xp27FXq4wdVNfhh0lTiE/19IU4H72M0wpt8lPblae/qMEkOJjw7yvO5uGiUyx@vger.kernel.org, AJvYcCWfnw4Rp9OmLx0mc2hoERqCL5IHgKO5Zqk95EBLCkBhXDRAGJF16c//wO1UGigHUPHhhya6ScedxX/o@vger.kernel.org, AJvYcCWsQhICjFUlaxqAp4GaPpMeIdSQRBmFE1J5WnVZTxUtmivM42u0ICohCMRUhpYzJJ9n+my8RqjCZmjicabn@vger.kernel.org X-Gm-Message-State: AOJu0YycOwV8WWTbg5vqyutxiN5nN8TbdMQY+c07ye+WEc8qERwSuihc GgE6/1UrqBJfpceLn6G5PC6gO5vV82UTPlqwHDokWCXj9Wu+F/C5 X-Google-Smtp-Source: AGHT+IElWGF/J3lYVMjLRCX4hUFrco/Kpvzbw/A8jguDUfW3hbZhHKJxw50QPrU3kkSMpcxaaADIdw== X-Received: by 2002:adf:e502:0:b0:37c:d2d2:7f67 with SMTP id ffacd0b85a97d-37d0e74b62cmr6056692f8f.30.1728333418972; Mon, 07 Oct 2024 13:36:58 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-26cc-001d-7ed0-e346.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:26cc:1d:7ed0:e346]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1690f75bsm6464315f8f.23.2024.10.07.13.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 13:36:58 -0700 (PDT) From: Javier Carrasco Date: Mon, 07 Oct 2024 22:36:38 +0200 Subject: [PATCH 3/3] iio: light: veml6030: add support for veml7700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241007-veml7700-v1-3-fb85dd839d63@gmail.com> References: <20241007-veml7700-v1-0-fb85dd839d63@gmail.com> In-Reply-To: <20241007-veml7700-v1-0-fb85dd839d63@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1728333411; l=6748; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=ffBqKTIzKKORtDAQTnF0ixHeiBBU1WJxjkoh95cX3hQ=; b=Ichfa+n/zTkvi8u7AEtV619VW+zwZUglXdVjgVqUfx5q0Uyv8ESG4JbNPlSN+AW+ibjzpWokV 6COuh21LbkRDjH80iDjXhNx4NsBeedR1hVBKoGpWTBdGpxN+viyZJlH X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The veml7700 contains the same sensor as the veml6030 in a different package with no interrupt line and no pin to select the I2C address. To handle the lack of the interrupt line and profit from the existing support for the veml6030, add a specific iio_chan_spec with no (num_)event_spec(s), and register the device's info from the veml6030_info_no_irq struct. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 108 ++++++++++++++++++++++++++++++++++++---= ---- 1 file changed, 91 insertions(+), 17 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index ca0379945b1c..173c85a05a8d 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * VEML6030 and VMEL6035 Ambient Light Sensors + * VEML6030, VMEL6035 and VEML7700 Ambient Light Sensors * * Copyright (c) 2019, Rishi Gupta * @@ -11,6 +11,10 @@ * VEML6035: * Datasheet: https://www.vishay.com/docs/84889/veml6035.pdf * Appnote-84944: https://www.vishay.com/docs/84944/designingveml6035.pdf + * + * VEML7700: + * Datasheet: https://www.vishay.com/docs/84286/veml7700.pdf + * Appnote-84323: https://www.vishay.com/docs/84323/designingveml7700.pdf */ =20 #include @@ -56,7 +60,10 @@ struct veml603x_chip { const char *name; const int(*scale_vals)[][2]; const int num_scale_vals; + const struct iio_chan_spec *channels; + const int num_channels; int (*hw_init)(struct iio_dev *indio_dev, struct device *dev); + int (*set_info)(struct iio_dev *indio_dev); int (*set_als_gain)(struct iio_dev *indio_dev, int val, int val2); int (*get_als_gain)(struct iio_dev *indio_dev, int *val, int *val2); }; @@ -250,6 +257,30 @@ static const struct iio_chan_spec veml6030_channels[] = =3D { }, }; =20 +static const struct iio_chan_spec veml7700_channels[] =3D { + { + .type =3D IIO_LIGHT, + .channel =3D CH_ALS, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all_available =3D BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), + }, + { + .type =3D IIO_INTENSITY, + .channel =3D CH_WHITE, + .modified =3D 1, + .channel2 =3D IIO_MOD_LIGHT_BOTH, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all_available =3D BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), + }, +}; + static const struct regmap_config veml6030_regmap_config =3D { .name =3D "veml6030_regmap", .reg_bits =3D 8, @@ -862,6 +893,37 @@ static irqreturn_t veml6030_event_handler(int irq, voi= d *private) return IRQ_HANDLED; } =20 +static int veml6030_set_info(struct iio_dev *indio_dev) +{ + struct veml6030_data *data =3D iio_priv(indio_dev); + struct i2c_client *client =3D data->client; + int ret; + + if (client->irq) { + ret =3D devm_request_threaded_irq(&client->dev, client->irq, + NULL, veml6030_event_handler, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + indio_dev->name, indio_dev); + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "irq %d request failed\n", + client->irq); + + indio_dev->info =3D &veml6030_info; + } else { + indio_dev->info =3D &veml6030_info_no_irq; + } + + return 0; +} + +static int veml7700_set_info(struct iio_dev *indio_dev) +{ + indio_dev->info =3D &veml6030_info_no_irq; + + return 0; +} + /* * Set ALS gain to 1/8, integration time to 100 ms, PSM to mode 2, * persistence to 1 x integration time and the threshold @@ -1007,24 +1069,13 @@ static int veml6030_probe(struct i2c_client *client) return -EINVAL; =20 indio_dev->name =3D data->chip->name; - indio_dev->channels =3D veml6030_channels; - indio_dev->num_channels =3D ARRAY_SIZE(veml6030_channels); + indio_dev->channels =3D data->chip->channels; + indio_dev->num_channels =3D data->chip->num_channels; indio_dev->modes =3D INDIO_DIRECT_MODE; =20 - if (client->irq) { - ret =3D devm_request_threaded_irq(&client->dev, client->irq, - NULL, veml6030_event_handler, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, - indio_dev->name, indio_dev); - if (ret < 0) - return dev_err_probe(&client->dev, ret, - "irq %d request failed\n", - client->irq); - - indio_dev->info =3D &veml6030_info; - } else { - indio_dev->info =3D &veml6030_info_no_irq; - } + ret =3D data->chip->set_info(indio_dev); + if (ret < 0) + return ret; =20 ret =3D data->chip->hw_init(indio_dev, &client->dev); if (ret < 0) @@ -1066,7 +1117,10 @@ static const struct veml603x_chip veml6030_chip =3D { .name =3D "veml6030", .scale_vals =3D &veml6030_scale_vals, .num_scale_vals =3D ARRAY_SIZE(veml6030_scale_vals), + .channels =3D veml6030_channels, + .num_channels =3D ARRAY_SIZE(veml6030_channels), .hw_init =3D veml6030_hw_init, + .set_info =3D veml6030_set_info, .set_als_gain =3D veml6030_set_als_gain, .get_als_gain =3D veml6030_get_als_gain, }; @@ -1075,11 +1129,26 @@ static const struct veml603x_chip veml6035_chip =3D= { .name =3D "veml6035", .scale_vals =3D &veml6035_scale_vals, .num_scale_vals =3D ARRAY_SIZE(veml6035_scale_vals), + .channels =3D veml6030_channels, + .num_channels =3D ARRAY_SIZE(veml6030_channels), .hw_init =3D veml6035_hw_init, + .set_info =3D veml6030_set_info, .set_als_gain =3D veml6035_set_als_gain, .get_als_gain =3D veml6035_get_als_gain, }; =20 +static const struct veml603x_chip veml7700_chip =3D { + .name =3D "veml7700", + .scale_vals =3D &veml6030_scale_vals, + .num_scale_vals =3D ARRAY_SIZE(veml6030_scale_vals), + .channels =3D veml7700_channels, + .num_channels =3D ARRAY_SIZE(veml7700_channels), + .hw_init =3D veml6030_hw_init, + .set_info =3D veml7700_set_info, + .set_als_gain =3D veml6030_set_als_gain, + .get_als_gain =3D veml6030_get_als_gain, +}; + static const struct of_device_id veml6030_of_match[] =3D { { .compatible =3D "vishay,veml6030", @@ -1089,6 +1158,10 @@ static const struct of_device_id veml6030_of_match[]= =3D { .compatible =3D "vishay,veml6035", .data =3D &veml6035_chip, }, + { + .compatible =3D "vishay,veml7700", + .data =3D &veml7700_chip, + }, { } }; MODULE_DEVICE_TABLE(of, veml6030_of_match); @@ -1096,6 +1169,7 @@ MODULE_DEVICE_TABLE(of, veml6030_of_match); static const struct i2c_device_id veml6030_id[] =3D { { "veml6030", (kernel_ulong_t)&veml6030_chip}, { "veml6035", (kernel_ulong_t)&veml6035_chip}, + { "veml7700", (kernel_ulong_t)&veml7700_chip}, { } }; MODULE_DEVICE_TABLE(i2c, veml6030_id); --=20 2.43.0