From patchwork Fri Feb 1 21:57:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 10793775 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 7301513BF for ; Fri, 1 Feb 2019 21:58:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D55529C91 for ; Fri, 1 Feb 2019 21:58:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FB1629B93; Fri, 1 Feb 2019 21:58:51 +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,FREEMAIL_FROM,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 5C1EB28563 for ; Fri, 1 Feb 2019 21:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbfBAV6j (ORCPT ); Fri, 1 Feb 2019 16:58:39 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:33710 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbfBAV6h (ORCPT ); Fri, 1 Feb 2019 16:58:37 -0500 Received: by mail-lj1-f193.google.com with SMTP id v1-v6so7118468ljd.0; Fri, 01 Feb 2019 13:58:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VnI54u+EhdK/GX5e9WgXGHoIutOBqDm3JI68hHuak5s=; b=NTCv4wUVNZq+DQU4yvpLIzXIceHJd+DlCkwz/gsiVkKJfNZjBhjoOgs2hPpqqRrAap WvjFWgenK7bwOJUO3G/DgueP6ZGz+Duy8389dAojExtDlKM3qoS3bms+HSGZqsjkBJqt FBO0PJNg/55C2fUEPuIwdwUyVPX08QBIEh9aTlMESQh0onRoH/F6F38hYcrHBzBSmfKk ZwAtpjlDKvrsxKeg4Pq8bmLw3fM7bNdk7tGSueb2OvYYU0dhgME+VyJqWDJNWxyFjbh7 AOhJ3uH/+laTaUgXgicWarhDiGwqZkYOQvN438BJhe6p+yH7powIO9SZRlPbdvr0SnHb busg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VnI54u+EhdK/GX5e9WgXGHoIutOBqDm3JI68hHuak5s=; b=rcVnBEeK9mjDYTxuBsNhaxHXYar+25VnRtkTe4xKXsoVvEYQQTKzK0hjT2fe1DNPy9 Ag0mgB8ms2G1OVObGEP4jvPRuY99SHkMCXQP0D3szs4cUObhpjb4n0KHb+6akqDocykH dgZ2XM/h0Yy9CDiWpmvN90rzw6NAW8CdUwe2xYf1rojLRd6Lsj6EYn9bgn1Ikakj5SsQ X7Wd0rMNYjt2F7pIvH9jE4cfGqDUzg3LgPEd8nugxrKJP39Aw+1BZKriLwLKST/Yp27h dsjlI1UCDcm2OgAjJ2PDnczabOAPu5vqq4/pOdMyZahOeJyfbwGRX7e6HRWF0Ef7aeoG ONpg== X-Gm-Message-State: AJcUukeh+vijE867cqzOSZVyjbpbjRCFO9nynhjp97SlIaOlW1BjiYH6 uugWX4VTjl7+RZ9gz4lD0oS8rCclvYQ= X-Google-Smtp-Source: ALg8bN7Tk19pTWrUNkCJelT1yM7ljwpiXxMUScXqoxRRxAbEKj/YWw3GcC5bvQ3GtrwDeiGdoWlZ4Q== X-Received: by 2002:a2e:9b15:: with SMTP id u21-v6mr29618784lji.29.1549058313889; Fri, 01 Feb 2019 13:58:33 -0800 (PST) Received: from arch.domain.name (89-70-37-207.dynamic.chello.pl. [89.70.37.207]) by smtp.gmail.com with ESMTPSA id s20sm1567630lfb.51.2019.02.01.13.58.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 13:58:33 -0800 (PST) From: Tomasz Duszynski To: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org, jic23@jic23.retrosnub.co.uk, pmeerw@pmeerw.net, johan@kernel.org, Tomasz Duszynski Subject: [PATCH v3 1/3] iio: chemical: add support for Plantower PMS7003 sensor Date: Fri, 1 Feb 2019 22:57:57 +0100 Message-Id: <20190201215759.14569-2-tduszyns@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201215759.14569-1-tduszyns@gmail.com> References: <20190201215759.14569-1-tduszyns@gmail.com> MIME-Version: 1.0 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 support for Plantower PMS7003 particulate matter sensor. Signed-off-by: Tomasz Duszynski --- drivers/iio/chemical/Kconfig | 10 + drivers/iio/chemical/Makefile | 1 + drivers/iio/chemical/pms7003.c | 340 +++++++++++++++++++++++++++++++++ 3 files changed, 351 insertions(+) create mode 100644 drivers/iio/chemical/pms7003.c diff --git a/drivers/iio/chemical/Kconfig b/drivers/iio/chemical/Kconfig index 57832b4360e9..d5d146e9e372 100644 --- a/drivers/iio/chemical/Kconfig +++ b/drivers/iio/chemical/Kconfig @@ -61,6 +61,16 @@ config IAQCORE iAQ-Core Continuous/Pulsed VOC (Volatile Organic Compounds) sensors +config PMS7003 + tristate "Plantower PMS7003 particulate matter sensor" + depends on SERIAL_DEV_BUS + help + Say Y here to build support for the Plantower PMS7003 particulate + matter sensor. + + To compile this driver as a module, choose M here: the module will + be called pms7003. + config SPS30 tristate "SPS30 particulate matter sensor" depends on I2C diff --git a/drivers/iio/chemical/Makefile b/drivers/iio/chemical/Makefile index 65bf0f89c0e4..f5d1365acb49 100644 --- a/drivers/iio/chemical/Makefile +++ b/drivers/iio/chemical/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_BME680_I2C) += bme680_i2c.o obj-$(CONFIG_BME680_SPI) += bme680_spi.o obj-$(CONFIG_CCS811) += ccs811.o obj-$(CONFIG_IAQCORE) += ams-iaq-core.o +obj-$(CONFIG_PMS7003) += pms7003.o obj-$(CONFIG_SENSIRION_SGP30) += sgp30.o obj-$(CONFIG_SPS30) += sps30.o obj-$(CONFIG_VZ89X) += vz89x.o diff --git a/drivers/iio/chemical/pms7003.c b/drivers/iio/chemical/pms7003.c new file mode 100644 index 000000000000..0c913c60adde --- /dev/null +++ b/drivers/iio/chemical/pms7003.c @@ -0,0 +1,340 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Plantower PMS7003 particulate matter sensor driver + * + * Copyright (c) Tomasz Duszynski + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PMS7003_DRIVER_NAME "pms7003" + +#define PMS7003_MAGIC 0x424d +/* last 2 data bytes hold frame checksum */ +#define PMS7003_MAX_DATA_LENGTH 28 +#define PMS7003_CHECKSUM_LENGTH 2 +#define PMS7003_PM10_OFFSET 10 +#define PMS7003_PM2P5_OFFSET 8 +#define PMS7003_PM1_OFFSET 6 + +#define PMS7003_TIMEOUT msecs_to_jiffies(6000) +#define PMS7003_CMD_LENGTH 7 +#define PMS7003_PM_MAX 1000 +#define PMS7003_PM_MIN 0 + +enum { + PM1, + PM2P5, + PM10, +}; + +enum pms7003_cmd { + CMD_WAKEUP, + CMD_ENTER_PASSIVE_MODE, + CMD_READ_PASSIVE, + CMD_SLEEP, +}; + +/* + * commands have following format: + * + * +------+------+-----+------+-----+-----------+-----------+ + * | 0x42 | 0x4d | cmd | 0x00 | arg | cksum msb | cksum lsb | + * +------+------+-----+------+-----+-----------+-----------+ + */ +static const u8 pms7003_cmd_tbl[][PMS7003_CMD_LENGTH] = { + [CMD_WAKEUP] = { 0x42, 0x4d, 0xe4, 0x00, 0x01, 0x01, 0x74 }, + [CMD_ENTER_PASSIVE_MODE] = { 0x42, 0x4d, 0xe1, 0x00, 0x00, 0x01, 0x70 }, + [CMD_READ_PASSIVE] = { 0x42, 0x4d, 0xe2, 0x00, 0x00, 0x01, 0x71 }, + [CMD_SLEEP] = { 0x42, 0x4d, 0xe4, 0x00, 0x00, 0x01, 0x73 }, +}; + +struct pms7003_frame { + u8 data[PMS7003_MAX_DATA_LENGTH]; + u16 expected_length; + u16 length; +}; + +struct pms7003_state { + struct serdev_device *serdev; + struct pms7003_frame frame; + struct completion frame_ready; + struct mutex lock; /* must be held whenever state gets touched */ +}; + +static int pms7003_do_cmd(struct pms7003_state *state, enum pms7003_cmd cmd) +{ + int ret; + + ret = serdev_device_write(state->serdev, pms7003_cmd_tbl[cmd], + PMS7003_CMD_LENGTH, PMS7003_TIMEOUT); + if (ret < PMS7003_CMD_LENGTH) + return ret < 0 ? ret : -EIO; + + ret = wait_for_completion_interruptible_timeout(&state->frame_ready, + PMS7003_TIMEOUT); + if (!ret) + ret = -ETIMEDOUT; + + return ret < 0 ? ret : 0; +} + +static u16 pms7003_get_pm(const u8 *data) +{ + return clamp_val(get_unaligned_be16(data), + PMS7003_PM_MIN, PMS7003_PM_MAX); +} + +static irqreturn_t pms7003_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct pms7003_state *state = iio_priv(indio_dev); + struct pms7003_frame *frame = &state->frame; + u16 data[3 + 1 + 4]; /* PM1, PM2P5, PM10, padding, timestamp */ + int ret; + + mutex_lock(&state->lock); + ret = pms7003_do_cmd(state, CMD_READ_PASSIVE); + if (ret) { + mutex_unlock(&state->lock); + goto err; + } + + data[PM1] = pms7003_get_pm(frame->data + PMS7003_PM1_OFFSET); + data[PM2P5] = pms7003_get_pm(frame->data + PMS7003_PM2P5_OFFSET); + data[PM10] = pms7003_get_pm(frame->data + PMS7003_PM10_OFFSET); + mutex_unlock(&state->lock); + + iio_push_to_buffers_with_timestamp(indio_dev, data, + iio_get_time_ns(indio_dev)); +err: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +static int pms7003_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct pms7003_state *state = iio_priv(indio_dev); + struct pms7003_frame *frame = &state->frame; + int ret; + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + switch (chan->type) { + case IIO_MASSCONCENTRATION: + mutex_lock(&state->lock); + ret = pms7003_do_cmd(state, CMD_READ_PASSIVE); + if (ret) { + mutex_unlock(&state->lock); + return ret; + } + + *val = pms7003_get_pm(frame->data + chan->address); + mutex_unlock(&state->lock); + + return IIO_VAL_INT; + default: + return -EINVAL; + } + } + + return -EINVAL; +} + +static const struct iio_info pms7003_info = { + .read_raw = pms7003_read_raw, +}; + +#define PMS7003_CHAN(_index, _mod, _addr) { \ + .type = IIO_MASSCONCENTRATION, \ + .modified = 1, \ + .channel2 = IIO_MOD_ ## _mod, \ + .address = _addr, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \ + .scan_index = _index, \ + .scan_type = { \ + .sign = 'u', \ + .realbits = 10, \ + .storagebits = 16, \ + .endianness = IIO_CPU, \ + }, \ +} + +static const struct iio_chan_spec pms7003_channels[] = { + PMS7003_CHAN(0, PM1, PMS7003_PM1_OFFSET), + PMS7003_CHAN(1, PM2P5, PMS7003_PM2P5_OFFSET), + PMS7003_CHAN(2, PM10, PMS7003_PM10_OFFSET), + IIO_CHAN_SOFT_TIMESTAMP(3), +}; + +static u16 pms7003_calc_checksum(struct pms7003_frame *frame) +{ + u16 checksum = (PMS7003_MAGIC >> 8) + (u8)PMS7003_MAGIC + + (frame->length >> 8) + (u8)frame->length; + int i; + + for (i = 0; i < frame->length - PMS7003_CHECKSUM_LENGTH; i++) + checksum += frame->data[i]; + + return checksum; +} + +static bool pms7003_frame_is_okay(struct pms7003_frame *frame) +{ + int offset = frame->length - PMS7003_CHECKSUM_LENGTH; + u16 checksum = get_unaligned_be16(frame->data + offset); + + return checksum == pms7003_calc_checksum(frame); +} + +static int pms7003_receive_buf(struct serdev_device *serdev, + const unsigned char *buf, size_t size) +{ + struct iio_dev *indio_dev = serdev_device_get_drvdata(serdev); + struct pms7003_state *state = iio_priv(indio_dev); + struct pms7003_frame *frame = &state->frame; + int num; + + if (!frame->expected_length) { + u16 magic; + + /* wait for SOF and data length */ + if (size < 4) + return 0; + + magic = get_unaligned_be16(buf); + if (magic != PMS7003_MAGIC) + return 2; + + num = get_unaligned_be16(buf + 2); + if (num <= PMS7003_MAX_DATA_LENGTH) { + frame->expected_length = num; + frame->length = 0; + } + + return 4; + } + + num = min(size, (size_t)(frame->expected_length - frame->length)); + memcpy(frame->data + frame->length, buf, num); + frame->length += num; + + if (frame->length == frame->expected_length) { + if (pms7003_frame_is_okay(frame)) + complete(&state->frame_ready); + + frame->expected_length = 0; + } + + return num; +} + +static const struct serdev_device_ops pms7003_serdev_ops = { + .receive_buf = pms7003_receive_buf, + .write_wakeup = serdev_device_write_wakeup, +}; + +static void pms7003_stop(void *data) +{ + struct pms7003_state *state = data; + + pms7003_do_cmd(state, CMD_SLEEP); +} + +static const unsigned long pms7003_scan_masks[] = { 0x07, 0x00 }; + +static int pms7003_probe(struct serdev_device *serdev) +{ + struct pms7003_state *state; + struct iio_dev *indio_dev; + int ret; + + indio_dev = devm_iio_device_alloc(&serdev->dev, sizeof(*state)); + if (!indio_dev) + return -ENOMEM; + + state = iio_priv(indio_dev); + serdev_device_set_drvdata(serdev, indio_dev); + state->serdev = serdev; + indio_dev->dev.parent = &serdev->dev; + indio_dev->info = &pms7003_info; + indio_dev->name = PMS7003_DRIVER_NAME; + indio_dev->channels = pms7003_channels, + indio_dev->num_channels = ARRAY_SIZE(pms7003_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->available_scan_masks = pms7003_scan_masks; + + mutex_init(&state->lock); + init_completion(&state->frame_ready); + + serdev_device_set_client_ops(serdev, &pms7003_serdev_ops); + ret = devm_serdev_device_open(&serdev->dev, serdev); + if (ret) + return ret; + + serdev_device_set_baudrate(serdev, 9600); + serdev_device_set_flow_control(serdev, false); + + ret = serdev_device_set_parity(serdev, SERDEV_PARITY_NONE); + if (ret) + return ret; + + ret = pms7003_do_cmd(state, CMD_WAKEUP); + if (ret) { + dev_err(&serdev->dev, "failed to wakeup sensor\n"); + return ret; + } + + ret = pms7003_do_cmd(state, CMD_ENTER_PASSIVE_MODE); + if (ret) { + dev_err(&serdev->dev, "failed to enter passive mode\n"); + return ret; + } + + ret = devm_add_action_or_reset(&serdev->dev, pms7003_stop, state); + if (ret) + return ret; + + ret = devm_iio_triggered_buffer_setup(&serdev->dev, indio_dev, NULL, + pms7003_trigger_handler, NULL); + if (ret) + return ret; + + return devm_iio_device_register(&serdev->dev, indio_dev); +} + +static const struct of_device_id pms7003_of_match[] = { + { .compatible = "plantower,pms7003" }, + { } +}; +MODULE_DEVICE_TABLE(of, pms7003_of_match); + +static struct serdev_device_driver pms7003_driver = { + .driver = { + .name = PMS7003_DRIVER_NAME, + .of_match_table = pms7003_of_match, + }, + .probe = pms7003_probe, +}; +module_serdev_device_driver(pms7003_driver); + +MODULE_AUTHOR("Tomasz Duszynski "); +MODULE_DESCRIPTION("Plantower PMS7003 particulate matter sensor driver"); +MODULE_LICENSE("GPL v2"); From patchwork Fri Feb 1 21:57:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 10793777 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 D297B922 for ; Fri, 1 Feb 2019 21:59:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE408324B8 for ; Fri, 1 Feb 2019 21:59:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA8F6324BA; Fri, 1 Feb 2019 21:59:01 +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,FREEMAIL_FROM,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 E0F16324B8 for ; Fri, 1 Feb 2019 21:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726698AbfBAV6j (ORCPT ); Fri, 1 Feb 2019 16:58:39 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44643 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726067AbfBAV6i (ORCPT ); Fri, 1 Feb 2019 16:58:38 -0500 Received: by mail-lf1-f65.google.com with SMTP id z13so6158350lfe.11; Fri, 01 Feb 2019 13:58:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k4K07+PMA9omMHyycWXsghoi13jqHOsNkg22kq8mIMI=; b=i+tRs3nRuY/ZGSjgH98LxtrzwFu9e4OyRul5zXQYR3eDWX7KyaqIW00StJ9lXFMq3E 0EO6X/9T7aWP5Z2T/1QAS3g06PfBSfLYaDURqmu3qhv7tsoM1QhGOq7r3+l5n1bT8M9s vx/dktgr+Jw3iW1o/BOl+IMLLFCf71ydDN0kEXQNTBUMr5GQxZPftoSwEhr6d+/KQbmO RSFvw7dL6VbwnqFLeKcid2QZywagE2lsW0GUTzwOPSzeLVmkMH+/sGMcFWLsNAEz+uCT binYMJinUS/9KsS8b4RJojClaDZYS19YVyWiG/4lBuJtKaenlxLAP3QoR7SR6u2+7AvF eyOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k4K07+PMA9omMHyycWXsghoi13jqHOsNkg22kq8mIMI=; b=P0Bd7rW4LkURl44f0KmXQD4r9uQO4QvBibH873LOoeppcv2nW3ona5INorVwF79MHF Sc0y31iEQyj5aOtFUgiVynl+C8AgOuDWS/rGCqF2VwrjqdQtIK/a6ncqVDA8a9oVyPiN NQXAJNYVNtOYfqHkT9h45vbR+Yc1edE4GRDTBI8MGMzy95LkxuHfAfCf8NNHHiCG6YGi TUIIQTyvdJbkejZ8k7odkff90tNMH6ZAxpzA4te1zW8yr9sGkzhclbeLdrT39LPu2+CF XeSIVsQ4rtyWLJ3LMbocJnMy/m4E8oxlETQBbeP2HLtK43YGfXRhfWTEaGlwH2oNrb0x fw4w== X-Gm-Message-State: AJcUukfytGkdyT3h/vuJ5Wyj84X4rjBPZLeQ44IAFlvgUbptFd0tx1bB WjZL5nCzl3OSTc45vhNYjDniJKU9MQc= X-Google-Smtp-Source: ALg8bN6Y7YWDooKbPztllH89n7v5JIpX+Omd/U5lN1rpSlMg8Mx3kaQ4Mchor/suYZS1R6wj3Kc3xw== X-Received: by 2002:a19:db54:: with SMTP id s81mr33689510lfg.102.1549058315379; Fri, 01 Feb 2019 13:58:35 -0800 (PST) Received: from arch.domain.name (89-70-37-207.dynamic.chello.pl. [89.70.37.207]) by smtp.gmail.com with ESMTPSA id s20sm1567630lfb.51.2019.02.01.13.58.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 13:58:34 -0800 (PST) From: Tomasz Duszynski To: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org, jic23@jic23.retrosnub.co.uk, pmeerw@pmeerw.net, johan@kernel.org, Tomasz Duszynski , Rob Herring Subject: [PATCH v3 2/3] dt-bindings: add Plantower to the vendor prefixes Date: Fri, 1 Feb 2019 22:57:58 +0100 Message-Id: <20190201215759.14569-3-tduszyns@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201215759.14569-1-tduszyns@gmail.com> References: <20190201215759.14569-1-tduszyns@gmail.com> MIME-Version: 1.0 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 Plantower to the vendor prefixes. Signed-off-by: Tomasz Duszynski Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 3cfe0c8b8250..fa391a650f3a 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -300,6 +300,7 @@ phytec PHYTEC Messtechnik GmbH picochip Picochip Ltd pine64 Pine64 pixcir PIXCIR MICROELECTRONICS Co., Ltd +plantower Plantower Co., Ltd plathome Plat'Home Co., Ltd. plda PLDA plx Broadcom Corporation (formerly PLX Technology) From patchwork Fri Feb 1 21:57:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 10793773 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 4072D922 for ; Fri, 1 Feb 2019 21:58:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E0502999F for ; Fri, 1 Feb 2019 21:58:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EBD629844; Fri, 1 Feb 2019 21:58:51 +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,FREEMAIL_FROM,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 AB04C28DC9 for ; Fri, 1 Feb 2019 21:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbfBAV6t (ORCPT ); Fri, 1 Feb 2019 16:58:49 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33715 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbfBAV6j (ORCPT ); Fri, 1 Feb 2019 16:58:39 -0500 Received: by mail-lj1-f195.google.com with SMTP id v1-v6so7118541ljd.0; Fri, 01 Feb 2019 13:58:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n3lyGEA96Cx0tDawBx8Bnt96fulhEcOs/o2QgNWNbzI=; b=KxNPcOXZ/geYhy05PBFlx5ddK9Sah3VjUtVdYlIfpF1fiVWfY3SEMYavtpTW1yh3Hp LbW6Ek0lFpeycqB1N8Ms57Z5ypGiVUYzI/Oo6KDENOYGu0OjKuj9NnjaLOgv1nb0WR+o 1dbY98Por36hCUBM3xtA4phXbOBszsteo6dOjRmU2+tWD3Vr1mnazOMd2CpRgVp1s6Yl tC6Mo09jJOU+761shwDINHBJmHxbS0viOsQJOQL8CqKdlxtQbqUp4pssfUrK72n2r7Xk PYgG4Q9JZKmxzeyBHXaNJAJrxolHiVQmOt4Kjsi8zyIctA65Xob/ws87Qb8mPrqcO814 5ylw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n3lyGEA96Cx0tDawBx8Bnt96fulhEcOs/o2QgNWNbzI=; b=SSj6GjSmN/XkZhNPL1K0AZ/DvvIDtRjrFvOBPe2YxfK5S9Z6RNDjH7R6qQ5dtyGJ35 VYfBacohoMHo9imZcueGTkeYKtwqtRIqY2ms1xQoTIuhbMKgLdSA/NtFNkfPXRTN2e87 ZrDS1dD3KdorEry9n6qmctV+gh3ADcaZ17Gc1gJP2Z9+8qA/cvFQ5btCpbNd0VH/loDg 5yABoJSRuY25bJMd5EzGSQ2mem6A70aQ2qgKqGFWslwVQ168GLt9cSCyMdAqMkYK6zw7 b8pM8BedLiPxfkvDJl6AoOFTFaSagp8xRDxX9/5Nvd2TSku3/V/8+L7ImfzxsKD3cLkN /izg== X-Gm-Message-State: AJcUuke2OxoslBHvLp0eCNCiOC/jCOKu7Vp8JVVabb7xIMF9bNITQGut 2Nsx/wNNvoAtP5GzWM7i0jYjouPTDpU= X-Google-Smtp-Source: ALg8bN4cJjJ1hR2xaO6FAJ3RG6ySgxGqP34rYVEXlAchKBnERLMXINlvlWQO6InRjutxDbzbbayWsQ== X-Received: by 2002:a2e:4601:: with SMTP id t1-v6mr33006103lja.111.1549058316717; Fri, 01 Feb 2019 13:58:36 -0800 (PST) Received: from arch.domain.name (89-70-37-207.dynamic.chello.pl. [89.70.37.207]) by smtp.gmail.com with ESMTPSA id s20sm1567630lfb.51.2019.02.01.13.58.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 13:58:36 -0800 (PST) From: Tomasz Duszynski To: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org, jic23@jic23.retrosnub.co.uk, pmeerw@pmeerw.net, johan@kernel.org, Tomasz Duszynski Subject: [PATCH v3 3/3] dt-bindings: iio: chemical: pms7003: add device tree support Date: Fri, 1 Feb 2019 22:57:59 +0100 Message-Id: <20190201215759.14569-4-tduszyns@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201215759.14569-1-tduszyns@gmail.com> References: <20190201215759.14569-1-tduszyns@gmail.com> MIME-Version: 1.0 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 device tree support for Plantower PMS7003 particulate matter sensor. Signed-off-by: Tomasz Duszynski --- .../iio/chemical/plantower,pms7003.txt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt diff --git a/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt new file mode 100644 index 000000000000..cbad95480e04 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt @@ -0,0 +1,20 @@ +* Plantower PMS7003 particulate matter sensor + +Required properties: +- compatible: must be "plantower,pms7003" +- vcc-supply: phandle to the regulator that provides power to the sensor + +Optional properties: +- set-gpios: phandle to the GPIO connected to the SET line +- reset-gpios: phandle to the GPIO connected to the RESET line + +Refer to serial/slave-device.txt for generic serial attached device bindings. + +Example: + +&uart0 { + air-pollution-sensor { + vcc-supply = <®_vcc5v0>; + compatible = "plantower,pms7003"; + }; +};