From patchwork Thu Mar 21 15:40:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angus Ainslie X-Patchwork-Id: 10863867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F1E91708 for ; Thu, 21 Mar 2019 15:41:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 637EA2A26A for ; Thu, 21 Mar 2019 15:41:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57B022A285; Thu, 21 Mar 2019 15:41:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4D9D2A282 for ; Thu, 21 Mar 2019 15:41:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728429AbfCUPlC (ORCPT ); Thu, 21 Mar 2019 11:41:02 -0400 Received: from node.akkea.ca ([192.155.83.177]:39186 "EHLO node.akkea.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726787AbfCUPlC (ORCPT ); Thu, 21 Mar 2019 11:41:02 -0400 Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id 51AA84E2051; Thu, 21 Mar 2019 15:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1553182861; bh=bPDUZ8GMtcCtdtEBE3Hh0GPN7PC9bETs8gr9/++eQAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Fp6pwiPSWbtsOiOw5MtHSjhRVrUmZG9+7WAPfHSC/nwR3g3tYjtCUApjpYgjEC83f l8or63dRVelUU12OgDz9x9ROPJ4vxvqDCeFWS9nTC58p3gXkgwzY2/7jqIv/zcPWRg cKedagUkYzl38P+i/LKm+uvpiXYaBR8KdEg4r4x4= X-Virus-Scanned: Debian amavisd-new at mail.akkea.ca Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WdTDGA1HT8tK; Thu, 21 Mar 2019 15:41:00 +0000 (UTC) Received: from midas.localdomain (S0106788a2041785e.gv.shawcable.net [70.66.86.75]) by node.akkea.ca (Postfix) with ESMTPSA id DDFBB4E204D; Thu, 21 Mar 2019 15:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1553182860; bh=bPDUZ8GMtcCtdtEBE3Hh0GPN7PC9bETs8gr9/++eQAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=soCUeVA/KwCIuWIrwxgM+cUvXrHGnra49F06Nm0O/ARiQ+kS8lffdDteUiyDLVhYy WbOeM4I1H2tRPr0q5tdi2tVwDjm+0vV4cPRGn99oo0uOYn+f9fuO3y8qs1OFulU1hu qVkndgaRV3/E53QBJ2RrjOXA9soG3hzJw7IG4u98= From: "Angus Ainslie (Purism)" To: jic23@kernel.org Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , Mark Rutland , "Angus Ainslie (Purism)" , Tomas Novotny , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/5] iio: light: vcnl4000 use word writes instead of byte writes Date: Thu, 21 Mar 2019 08:40:43 -0700 Message-Id: <20190321154047.23236-2-angus@akkea.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190321154047.23236-1-angus@akkea.ca> References: <20190321154047.23236-1-angus@akkea.ca> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The VCNL4200 datasheet says that word read and writes should be used to access the registers. Signed-off-by: Angus Ainslie (Purism) Tested-by: Tomas Novotny --- drivers/iio/light/vcnl4000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 04fd0d4b6f19..5e0a8eb83ebc 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -140,10 +140,10 @@ static int vcnl4200_init(struct vcnl4000_data *data) data->rev = (ret >> 8) & 0xf; /* Set defaults and enable both channels */ - ret = i2c_smbus_write_byte_data(data->client, VCNL4200_AL_CONF, 0x00); + ret = i2c_smbus_write_word_data(data->client, VCNL4200_AL_CONF, 0); if (ret < 0) return ret; - ret = i2c_smbus_write_byte_data(data->client, VCNL4200_PS_CONF1, 0x00); + ret = i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1, 0); if (ret < 0) return ret; From patchwork Thu Mar 21 15:40:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angus Ainslie X-Patchwork-Id: 10863869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABC4A922 for ; Thu, 21 Mar 2019 15:41:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 923882A270 for ; Thu, 21 Mar 2019 15:41:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90A362A274; Thu, 21 Mar 2019 15:41:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 475EC2A27B for ; Thu, 21 Mar 2019 15:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728549AbfCUPlZ (ORCPT ); Thu, 21 Mar 2019 11:41:25 -0400 Received: from node.akkea.ca ([192.155.83.177]:39204 "EHLO node.akkea.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727823AbfCUPlC (ORCPT ); Thu, 21 Mar 2019 11:41:02 -0400 Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id A25834E2056; Thu, 21 Mar 2019 15:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1553182861; bh=6k9qZsSXgZqdyav5V2ldzC4b11XN7BN7b7f+Hch7bug=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RDPwZD5RYko5JNd4BS0cjjRaDH/asrehHYNSenxizq86vAV6uPgDi/n9V5+/aiJnF OeV2m2s6pLJ1xv2mcWT9kdBQqmxaGsCKtKxCKs8s6q/yj/bA8iWuWJRQcQenZn/VVZ xGrA2cJfRYOY6g+94qKkuuXCADU6end/rT/HS02Y= X-Virus-Scanned: Debian amavisd-new at mail.akkea.ca Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lU3FEZbRkp9F; Thu, 21 Mar 2019 15:41:01 +0000 (UTC) Received: from midas.localdomain (S0106788a2041785e.gv.shawcable.net [70.66.86.75]) by node.akkea.ca (Postfix) with ESMTPSA id 9B58D4E204B; Thu, 21 Mar 2019 15:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1553182861; bh=6k9qZsSXgZqdyav5V2ldzC4b11XN7BN7b7f+Hch7bug=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RDPwZD5RYko5JNd4BS0cjjRaDH/asrehHYNSenxizq86vAV6uPgDi/n9V5+/aiJnF OeV2m2s6pLJ1xv2mcWT9kdBQqmxaGsCKtKxCKs8s6q/yj/bA8iWuWJRQcQenZn/VVZ xGrA2cJfRYOY6g+94qKkuuXCADU6end/rT/HS02Y= From: "Angus Ainslie (Purism)" To: jic23@kernel.org Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , Mark Rutland , "Angus Ainslie (Purism)" , Tomas Novotny , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/5] iio: light: vcnl4000 add devicetree hooks Date: Thu, 21 Mar 2019 08:40:44 -0700 Message-Id: <20190321154047.23236-3-angus@akkea.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190321154047.23236-1-angus@akkea.ca> References: <20190321154047.23236-1-angus@akkea.ca> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add an of_match table for devicetree probing. Signed-off-by: Angus Ainslie (Purism) --- drivers/iio/light/vcnl4000.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 5e0a8eb83ebc..308cb2d2b641 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -363,9 +363,31 @@ static int vcnl4000_probe(struct i2c_client *client, return devm_iio_device_register(&client->dev, indio_dev); } +static const struct of_device_id vcnl_4000_of_match[] = { + { + .compatible = "vishay,vcnl4000", + .data = "VCNL4000", + }, + { + .compatible = "vishay,vcnl4010", + .data = "VCNL4010", + }, + { + .compatible = "vishay,vcnl4010", + .data = "VCNL4020", + }, + { + .compatible = "vishay,vcnl4200", + .data = "VCNL4200", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, vcnl4000_of_match); + static struct i2c_driver vcnl4000_driver = { .driver = { .name = VCNL4000_DRV_NAME, + .of_match_table = of_match_ptr(vcnl_4000_of_match), }, .probe = vcnl4000_probe, .id_table = vcnl4000_id, From patchwork Thu Mar 21 15:40:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angus Ainslie X-Patchwork-Id: 10863865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2EF441708 for ; Thu, 21 Mar 2019 15:41:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14DED2A275 for ; Thu, 21 Mar 2019 15:41:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07E152A274; Thu, 21 Mar 2019 15:41:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A93622A26A for ; Thu, 21 Mar 2019 15:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728529AbfCUPlS (ORCPT ); Thu, 21 Mar 2019 11:41:18 -0400 Received: from node.akkea.ca ([192.155.83.177]:39228 "EHLO node.akkea.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728420AbfCUPlE (ORCPT ); Thu, 21 Mar 2019 11:41:04 -0400 Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id 66EC34E205C; Thu, 21 Mar 2019 15:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1553182862; bh=4TFo43pNxPR5bE8qq1l7k0ic0qIUblTF7AASecUk58s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SLdQZ3mHo4S8hRTJBvVh/QZEHHiZa3O0FX2aKsI11eki2yvVzY7Y1BnbNca9+VNBN HliwiZcRLHlQLxlqpYFln9NmZ9PkHZX+AciXQRo97giJ2xvyIO19EOhcd54UK2aeV9 Or9srP7OXbI644PdLj+3aRBgpK8vivjiYJmo69EE= X-Virus-Scanned: Debian amavisd-new at mail.akkea.ca Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6ZZIeaEe2qqK; Thu, 21 Mar 2019 15:41:02 +0000 (UTC) Received: from midas.localdomain (S0106788a2041785e.gv.shawcable.net [70.66.86.75]) by node.akkea.ca (Postfix) with ESMTPSA id 67E5D4E204D; Thu, 21 Mar 2019 15:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1553182862; bh=4TFo43pNxPR5bE8qq1l7k0ic0qIUblTF7AASecUk58s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SLdQZ3mHo4S8hRTJBvVh/QZEHHiZa3O0FX2aKsI11eki2yvVzY7Y1BnbNca9+VNBN HliwiZcRLHlQLxlqpYFln9NmZ9PkHZX+AciXQRo97giJ2xvyIO19EOhcd54UK2aeV9 Or9srP7OXbI644PdLj+3aRBgpK8vivjiYJmo69EE= From: "Angus Ainslie (Purism)" To: jic23@kernel.org Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , Mark Rutland , "Angus Ainslie (Purism)" , Tomas Novotny , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/5] dt-bindings: iio: light: add vcnl4000 devicetree bindings Date: Thu, 21 Mar 2019 08:40:45 -0700 Message-Id: <20190321154047.23236-4-angus@akkea.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190321154047.23236-1-angus@akkea.ca> References: <20190321154047.23236-1-angus@akkea.ca> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Document the vishay VCNL4000 devicetree bindings. Signed-off-by: Angus Ainslie (Purism) Reviewed-by: Rob Herring --- .../bindings/iio/light/vcnl4000.txt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/vcnl4000.txt diff --git a/Documentation/devicetree/bindings/iio/light/vcnl4000.txt b/Documentation/devicetree/bindings/iio/light/vcnl4000.txt new file mode 100644 index 000000000000..4a9d558a412a --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/vcnl4000.txt @@ -0,0 +1,22 @@ +VISHAY VCNL4000 - Ambient Light and proximity sensor + +This driver supports the VCNL4000/10/20 and VCNL4200 chips + +Required properties: + + -compatible: must be one of : + vishay,vcnl4000 + vishay,vcnl4010 + vishay,vcnl4020 + vishay,vcnl4200 + + -reg: I2C address of the sensor, should be one from below based on the model: + 0x13 + 0x51 + +Example: + +light-sensor@51 { + compatible = "vishay,vcnl4200"; + reg = <0x51>; +}; From patchwork Thu Mar 21 15:40:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angus Ainslie X-Patchwork-Id: 10863863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95A6E922 for ; Thu, 21 Mar 2019 15:41:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A94F2A272 for ; Thu, 21 Mar 2019 15:41:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E8952A27A; Thu, 21 Mar 2019 15:41:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC3ED2A272 for ; Thu, 21 Mar 2019 15:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728505AbfCUPlM (ORCPT ); Thu, 21 Mar 2019 11:41:12 -0400 Received: from node.akkea.ca ([192.155.83.177]:39240 "EHLO node.akkea.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728445AbfCUPlF (ORCPT ); Thu, 21 Mar 2019 11:41:05 -0400 Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id 804D44E2058; Thu, 21 Mar 2019 15:41:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1553182863; bh=z7f5C+Lh3SIwgVFYuQXcV9EVlIdfDeDPGaYtfMsKfGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VkwRUMvdOHcZQ0OwYObDxpb9UA5/GQbCZttl8lwrAVCnUN5Akm3uKU+bJprYnd2bA vTAlwmUiyznPk6A0uoT9NMY0ehvKteL86KPBECAeNhYLPrkFzVTo6JJNpN20WO9Bs+ vE12ZyGDV0Ty9lI83/lNC+9Wsek151/SU1nRgpHM= X-Virus-Scanned: Debian amavisd-new at mail.akkea.ca Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1_38LrbnoBH3; Thu, 21 Mar 2019 15:41:03 +0000 (UTC) Received: from midas.localdomain (S0106788a2041785e.gv.shawcable.net [70.66.86.75]) by node.akkea.ca (Postfix) with ESMTPSA id 3916B4E2050; Thu, 21 Mar 2019 15:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1553182863; bh=z7f5C+Lh3SIwgVFYuQXcV9EVlIdfDeDPGaYtfMsKfGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VkwRUMvdOHcZQ0OwYObDxpb9UA5/GQbCZttl8lwrAVCnUN5Akm3uKU+bJprYnd2bA vTAlwmUiyznPk6A0uoT9NMY0ehvKteL86KPBECAeNhYLPrkFzVTo6JJNpN20WO9Bs+ vE12ZyGDV0Ty9lI83/lNC+9Wsek151/SU1nRgpHM= From: "Angus Ainslie (Purism)" To: jic23@kernel.org Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , Mark Rutland , "Angus Ainslie (Purism)" , Tomas Novotny , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/5] iio: light: vcnl4000 add support for the VCNL4040 proximity and light sensor Date: Thu, 21 Mar 2019 08:40:46 -0700 Message-Id: <20190321154047.23236-5-angus@akkea.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190321154047.23236-1-angus@akkea.ca> References: <20190321154047.23236-1-angus@akkea.ca> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The VCNL4040 is almost identical to the VCNL4200 as far as register layout goes but just need to check a different ID register location. Signed-off-by: Angus Ainslie (Purism) --- drivers/iio/light/vcnl4000.c | 51 ++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 308cb2d2b641..12c52f2b853a 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -1,8 +1,9 @@ /* - * vcnl4000.c - Support for Vishay VCNL4000/4010/4020/4200 combined ambient + * vcnl4000.c - Support for Vishay VCNL4000/4010/4020/4040/4200 combined ambient * light and proximity sensor * * Copyright 2012 Peter Meerwald + * Copyright 2019 Pursim SPC * * This file is subject to the terms and conditions of version 2 of * the GNU General Public License. See the file COPYING in the main @@ -10,13 +11,14 @@ * * IIO driver for: * VCNL4000/10/20 (7-bit I2C slave address 0x13) + * VCNL4040 (7-bit I2C slave address 0x60) * VCNL4200 (7-bit I2C slave address 0x51) * * TODO: * allow to adjust IR current * proximity threshold and event handling * periodic ALS/proximity measurement (VCNL4010/20) - * interrupts (VCNL4010/20, VCNL4200) + * interrupts (VCNL4010/20/40, VCNL4200) */ #include @@ -30,6 +32,7 @@ #define VCNL4000_DRV_NAME "vcnl4000" #define VCNL4000_PROD_ID 0x01 #define VCNL4010_PROD_ID 0x02 /* for VCNL4020, VCNL4010 */ +#define VCNL4040_PROD_ID 0x86 #define VCNL4200_PROD_ID 0x58 #define VCNL4000_COMMAND 0x80 /* Command register */ @@ -49,6 +52,8 @@ #define VCNL4200_AL_DATA 0x09 /* Ambient light data */ #define VCNL4200_DEV_ID 0x0e /* Device ID, slave address and version */ +#define VCNL4040_DEV_ID 0x0c /* Device ID and version */ + /* Bit masks for COMMAND register */ #define VCNL4000_AL_RDY BIT(6) /* ALS data ready? */ #define VCNL4000_PS_RDY BIT(5) /* proximity data ready? */ @@ -58,6 +63,7 @@ enum vcnl4000_device_ids { VCNL4000, VCNL4010, + VCNL4040, VCNL4200, }; @@ -90,6 +96,7 @@ static const struct i2c_device_id vcnl4000_id[] = { { "vcnl4000", VCNL4000 }, { "vcnl4010", VCNL4010 }, { "vcnl4020", VCNL4010 }, + { "vcnl4040", VCNL4040 }, { "vcnl4200", VCNL4200 }, { } }; @@ -128,14 +135,26 @@ static int vcnl4000_init(struct vcnl4000_data *data) static int vcnl4200_init(struct vcnl4000_data *data) { - int ret; + int ret, id; ret = i2c_smbus_read_word_data(data->client, VCNL4200_DEV_ID); if (ret < 0) return ret; - if ((ret & 0xff) != VCNL4200_PROD_ID) - return -ENODEV; + id = ret & 0xff; + + if (id != VCNL4200_PROD_ID) { + ret = i2c_smbus_read_word_data(data->client, VCNL4040_DEV_ID); + if (ret < 0) + return ret; + + id = ret & 0xff; + + if (id != VCNL4040_PROD_ID) + return -ENODEV; + } + + dev_dbg(&data->client->dev, "device id 0x%x", id); data->rev = (ret >> 8) & 0xf; @@ -150,9 +169,19 @@ static int vcnl4200_init(struct vcnl4000_data *data) data->al_scale = 24000; data->vcnl4200_al.reg = VCNL4200_AL_DATA; data->vcnl4200_ps.reg = VCNL4200_PS_DATA; - /* Integration time is 50ms, but the experiments show 54ms in total. */ - data->vcnl4200_al.sampling_rate = ktime_set(0, 54000 * 1000); - data->vcnl4200_ps.sampling_rate = ktime_set(0, 4200 * 1000); + switch (id) { + case VCNL4200_PROD_ID: + /* Integration time is 50ms, but the experiments */ + /* show 54ms in total. */ + data->vcnl4200_al.sampling_rate = ktime_set(0, 54000 * 1000); + data->vcnl4200_ps.sampling_rate = ktime_set(0, 4200 * 1000); + break; + case VCNL4040_PROD_ID: + /* Integration time is 80ms, add 10ms. */ + data->vcnl4200_al.sampling_rate = ktime_set(0, 100000 * 1000); + data->vcnl4200_ps.sampling_rate = ktime_set(0, 100000 * 1000); + break; + } data->vcnl4200_al.last_measurement = ktime_set(0, 0); data->vcnl4200_ps.last_measurement = ktime_set(0, 0); mutex_init(&data->vcnl4200_al.lock); @@ -271,6 +300,12 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { .measure_light = vcnl4000_measure_light, .measure_proximity = vcnl4000_measure_proximity, }, + [VCNL4040] = { + .prod = "VCNL4040", + .init = vcnl4200_init, + .measure_light = vcnl4200_measure_light, + .measure_proximity = vcnl4200_measure_proximity, + }, [VCNL4200] = { .prod = "VCNL4200", .init = vcnl4200_init, From patchwork Thu Mar 21 15:40:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angus Ainslie X-Patchwork-Id: 10863861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D81F5922 for ; Thu, 21 Mar 2019 15:41:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD0FB2A273 for ; Thu, 21 Mar 2019 15:41:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0F152A26D; Thu, 21 Mar 2019 15:41:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15EE82A273 for ; Thu, 21 Mar 2019 15:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728478AbfCUPlF (ORCPT ); Thu, 21 Mar 2019 11:41:05 -0400 Received: from node.akkea.ca ([192.155.83.177]:39268 "EHLO node.akkea.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728451AbfCUPlF (ORCPT ); Thu, 21 Mar 2019 11:41:05 -0400 Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id ECDDE4E2050; Thu, 21 Mar 2019 15:41:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1553182863; bh=YtdSndT+Zi4H2ytZ+tYpf/nUtlDxjWqNqGUqu3RpO8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i8iOeqvxT1culvpsNKvETdttqGXoisT5aTDefG1JHYb61mNw3tARgm5RHvsunHVm+ VezKG0tpm0TqZ5aSl4s+Mh2PoCfD++4eegilOlxL/cfaZC9HQeF6SfjrzID8a+OZHR 9mDy6n/tNftctHUUbhmmPq1SvLT19a3ShTlogB04= X-Virus-Scanned: Debian amavisd-new at mail.akkea.ca Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6JwGBtvwvxIF; Thu, 21 Mar 2019 15:41:03 +0000 (UTC) Received: from midas.localdomain (S0106788a2041785e.gv.shawcable.net [70.66.86.75]) by node.akkea.ca (Postfix) with ESMTPSA id 242804E204B; Thu, 21 Mar 2019 15:41:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1553182863; bh=YtdSndT+Zi4H2ytZ+tYpf/nUtlDxjWqNqGUqu3RpO8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i8iOeqvxT1culvpsNKvETdttqGXoisT5aTDefG1JHYb61mNw3tARgm5RHvsunHVm+ VezKG0tpm0TqZ5aSl4s+Mh2PoCfD++4eegilOlxL/cfaZC9HQeF6SfjrzID8a+OZHR 9mDy6n/tNftctHUUbhmmPq1SvLT19a3ShTlogB04= From: "Angus Ainslie (Purism)" To: jic23@kernel.org Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , Mark Rutland , "Angus Ainslie (Purism)" , Tomas Novotny , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 5/5] dt-bindings: iio: light: add vcnl4040 devicetree bindings Date: Thu, 21 Mar 2019 08:40:47 -0700 Message-Id: <20190321154047.23236-6-angus@akkea.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190321154047.23236-1-angus@akkea.ca> References: <20190321154047.23236-1-angus@akkea.ca> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Document the vishay VCNL4040 devicetree bindings. Signed-off-by: Angus Ainslie (Purism) Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/iio/light/vcnl4000.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/light/vcnl4000.txt b/Documentation/devicetree/bindings/iio/light/vcnl4000.txt index 4a9d558a412a..955af4555c90 100644 --- a/Documentation/devicetree/bindings/iio/light/vcnl4000.txt +++ b/Documentation/devicetree/bindings/iio/light/vcnl4000.txt @@ -1,6 +1,6 @@ VISHAY VCNL4000 - Ambient Light and proximity sensor -This driver supports the VCNL4000/10/20 and VCNL4200 chips +This driver supports the VCNL4000/10/20/40 and VCNL4200 chips Required properties: @@ -8,11 +8,13 @@ Required properties: vishay,vcnl4000 vishay,vcnl4010 vishay,vcnl4020 + vishay,vcnl4040 vishay,vcnl4200 -reg: I2C address of the sensor, should be one from below based on the model: 0x13 0x51 + 0x60 Example: