From patchwork Sun Mar 4 12:36:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreeya Patel X-Patchwork-Id: 10257639 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1ABB3602BD for ; Sun, 4 Mar 2018 12:36:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A89B28755 for ; Sun, 4 Mar 2018 12:36:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3192287E5; Sun, 4 Mar 2018 12:36:30 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 540DD28755 for ; Sun, 4 Mar 2018 12:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752607AbeCDMg3 (ORCPT ); Sun, 4 Mar 2018 07:36:29 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:33468 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752570AbeCDMg1 (ORCPT ); Sun, 4 Mar 2018 07:36:27 -0500 Received: by mail-pl0-f66.google.com with SMTP id c11-v6so8192710plo.0; Sun, 04 Mar 2018 04:36:27 -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; bh=LIoKGn+QzA+jklhp37lmEfGCuDjVSmppEqHWiBT4HY0=; b=aJMj7/l7I/+G4BpbCs/IwAbX64MksuFOZ7dlwsRE4FmID5XAM4GBlH2YYSjLkJmCUY Fw60F/vPofQ8KZH+JNEBtUIUwjmFYw4wbHLYZPRN9a6ecR1ZNcLVYXdqphQ4h0WbUxdS VYf3KR05jL8JeUb8C4maTWu1ZLhFK5/c0Tz6IGtSfF/qN/bj8XJLv4TtVHUuLDaZmX6D mr2S7UBs9kCSwysLB3Uc2QwG5h6MS7Ex3Pqt4JvxllUsla04qlj32O/ODxUGmgG0h3Gf QiTNZiBL7WaaOSQkkFRJeKfnooxGq3ZLIJvNmBWwYl5P/zkdJSvFB59U04sz2zT25LhI ZFBw== 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; bh=LIoKGn+QzA+jklhp37lmEfGCuDjVSmppEqHWiBT4HY0=; b=HlxW9qGralXyWG5snVwPKZvmEvzbf6dWA4Kux0o1FBlImsGsd2J/Xu0sXap7PWIK4x ZRa32NeKC6HG2WhEQO/FNQrjtGXxxdL54Z0PCQ+m4GLNjwQOQ0icHxCHQG1dW/r3kmay XDipj3sLN9TdCv396EM+KJ1KGFl8P3JfG49szsMGSRxs6PcTRJJ5um28KzLvXMJrdTvd DdBVgADRwcbgS+cVNcN9djWizHwYZpFITgk7KlvGX3dNcoeoSt5PDQrsi5qzobt6Mg2V etdNUkpSzFxfDlBp/qJbVCZaxXYD5YptS9FIqase5ykJthG0lTO7xb9TuAeBDXYB1GeG IAlw== X-Gm-Message-State: APf1xPCFK/+esRTjt0zyzGOS1rN9PONw5doGDjwKDZU2cbIpwv6nlLH6 spK5FG/AEZzCb4G0JWiSp6E= X-Google-Smtp-Source: AG47ELvS0HnFL3xmnDbacJUJ7pJVFEaEVUa8bLq3OZ7x8V/F11lCQRV1e4VeKiMabl8rDWydcr3t3A== X-Received: by 2002:a17:902:69cf:: with SMTP id m15-v6mr10358922pln.104.1520166987179; Sun, 04 Mar 2018 04:36:27 -0800 (PST) Received: from shreeya-VirtualBox ([103.212.140.139]) by smtp.gmail.com with ESMTPSA id h67sm25846679pfk.184.2018.03.04.04.36.26 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Mar 2018 04:36:26 -0800 (PST) From: Shreeya Patel To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, daniel.baluta@gmail.com Cc: Shreeya Patel Subject: [PATCH v3 1/4] Staging: iio: adis16209: Remove and add some comments and group the definitions Date: Sun, 4 Mar 2018 18:06:22 +0530 Message-Id: <982742b1bb71d4d97c2f5edc6f95b85129d8667b.1520164945.git.shreeya.patel23498@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: 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 Remove some unnecessay comments and group the control register and register field macros together. Some of the register names does not make it's puporse very clear and hence, add some comments for more information. Also there are certain unit based comments which are not providing sufficient information, so expand those comments. Signed-off-by: Shreeya Patel --- Changes in v3 -This patch is the combination of two patches from the previous series. Also add some more comments. drivers/staging/iio/accel/adis16209.c | 132 ++++++++++------------------------ 1 file changed, 39 insertions(+), 93 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index 151120f..d8aef9c 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -21,135 +21,70 @@ #include #define ADIS16209_STARTUP_DELAY_MS 220 - -/* Flash memory write count */ #define ADIS16209_FLASH_CNT_REG 0x00 -/* Output, power supply */ +/* Data Output Register Definitions */ #define ADIS16209_SUPPLY_OUT_REG 0x02 - -/* Output, x-axis accelerometer */ #define ADIS16209_XACCL_OUT_REG 0x04 - -/* Output, y-axis accelerometer */ #define ADIS16209_YACCL_OUT_REG 0x06 - /* Output, auxiliary ADC input */ #define ADIS16209_AUX_ADC_REG 0x08 - /* Output, temperature */ #define ADIS16209_TEMP_OUT_REG 0x0A - -/* Output, x-axis inclination */ +/* Output, +/- 90 degrees X-axis inclination */ #define ADIS16209_XINCL_OUT_REG 0x0C - -/* Output, y-axis inclination */ #define ADIS16209_YINCL_OUT_REG 0x0E - /* Output, +/-180 vertical rotational position */ #define ADIS16209_ROT_OUT_REG 0x10 -/* Calibration, x-axis acceleration offset null */ +/* + * Calibration Register Definitions. + * Acceleration, inclination or rotation offset null. + */ #define ADIS16209_XACCL_NULL_REG 0x12 - -/* Calibration, y-axis acceleration offset null */ #define ADIS16209_YACCL_NULL_REG 0x14 - -/* Calibration, x-axis inclination offset null */ #define ADIS16209_XINCL_NULL_REG 0x16 - -/* Calibration, y-axis inclination offset null */ #define ADIS16209_YINCL_NULL_REG 0x18 - -/* Calibration, vertical rotation offset null */ #define ADIS16209_ROT_NULL_REG 0x1A -/* Alarm 1 amplitude threshold */ +/* Alarm Register Definitions */ #define ADIS16209_ALM_MAG1_REG 0x20 - -/* Alarm 2 amplitude threshold */ #define ADIS16209_ALM_MAG2_REG 0x22 - -/* Alarm 1, sample period */ #define ADIS16209_ALM_SMPL1_REG 0x24 - -/* Alarm 2, sample period */ #define ADIS16209_ALM_SMPL2_REG 0x26 - -/* Alarm control */ #define ADIS16209_ALM_CTRL_REG 0x28 -/* Auxiliary DAC data */ #define ADIS16209_AUX_DAC_REG 0x30 - -/* General-purpose digital input/output control */ #define ADIS16209_GPIO_CTRL_REG 0x32 - -/* Miscellaneous control */ -#define ADIS16209_MSC_CTRL_REG 0x34 - -/* Internal sample period (rate) control */ #define ADIS16209_SMPL_PRD_REG 0x36 - -/* Operation, filter configuration */ #define ADIS16209_AVG_CNT_REG 0x38 - -/* Operation, sleep mode control */ #define ADIS16209_SLP_CNT_REG 0x3A -/* Diagnostics, system status register */ -#define ADIS16209_DIAG_STAT_REG 0x3C - -/* Operation, system command register */ -#define ADIS16209_GLOB_CMD_REG 0x3E - -/* MSC_CTRL */ - -/* Self-test at power-on: 1 = disabled, 0 = enabled */ -#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) - -/* Self-test enable */ -#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) - -/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2) - +#define ADIS16209_MSC_CTRL_REG 0x34 +#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) +#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2) /* Data-ready polarity: 1 = active high, 0 = active low */ -#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) -/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ -#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) - -/* DIAG_STAT */ - -/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16209_DIAG_STAT_ALARM2 BIT(9) - -/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16209_DIAG_STAT_ALARM1 BIT(8) - -/* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */ +#define ADIS16209_DIAG_STAT_REG 0x3C +#define ADIS16209_DIAG_STAT_ALARM2 BIT(9) +#define ADIS16209_DIAG_STAT_ALARM1 BIT(8) #define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 - -/* SPI communications failure */ #define ADIS16209_DIAG_STAT_SPI_FAIL_BIT 3 - -/* Flash update failure */ #define ADIS16209_DIAG_STAT_FLASH_UPT_BIT 2 - /* Power supply above 3.625 V */ #define ADIS16209_DIAG_STAT_POWER_HIGH_BIT 1 - /* Power supply below 3.15 V */ #define ADIS16209_DIAG_STAT_POWER_LOW_BIT 0 -/* GLOB_CMD */ - -#define ADIS16209_GLOB_CMD_SW_RESET BIT(7) -#define ADIS16209_GLOB_CMD_CLEAR_STAT BIT(4) -#define ADIS16209_GLOB_CMD_FACTORY_CAL BIT(1) +#define ADIS16209_GLOB_CMD_REG 0x3E +#define ADIS16209_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16209_GLOB_CMD_CLEAR_STAT BIT(4) +#define ADIS16209_GLOB_CMD_FACTORY_CAL BIT(1) -#define ADIS16209_ERROR_ACTIVE BIT(14) +#define ADIS16209_ERROR_ACTIVE BIT(14) enum adis16209_scan { ADIS16209_SCAN_SUPPLY, @@ -226,24 +161,38 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, *val2 = 610500; /* 0.6105 mV */ return IIO_VAL_INT_PLUS_MICRO; case IIO_TEMP: - *val = -470; /* -0.47 C */ + *val = -470; *val2 = 0; return IIO_VAL_INT_PLUS_MICRO; case IIO_ACCEL: + /* + * IIO base unit for sensitivity of accelerometer + * is milli g. + * 1 LSB represents 0.244 mg. + */ *val = 0; - *val2 = IIO_G_TO_M_S_2(244140); /* 0.244140 mg */ + *val2 = IIO_G_TO_M_S_2(244140); return IIO_VAL_INT_PLUS_NANO; case IIO_INCLI: case IIO_ROT: + /* + * IIO base units for rotation are degrees. + * 1 LSB represents 0.025 milli degrees. + */ *val = 0; - *val2 = 25000; /* 0.025 degree */ + *val2 = 25000; return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; } break; case IIO_CHAN_INFO_OFFSET: - *val = 25000 / -470 - 0x4FE; /* 25 C = 0x4FE */ + /* + * The raw ADC value is 0x4FE when the temperature + * is 45 degrees and the scale factor per milli + * degree celcius is -470. + */ + *val = 25000 / -470 - 0x4FE; return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBBIAS: switch (chan->type) { @@ -320,12 +269,10 @@ static int adis16209_probe(struct spi_device *spi) struct adis *st; struct iio_dev *indio_dev; - /* setup the industrialio driver allocated elements */ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); - /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); indio_dev->name = spi->dev.driver->name; @@ -342,7 +289,6 @@ static int adis16209_probe(struct spi_device *spi) if (ret) return ret; - /* Get the device into a sane initial state */ ret = adis_initial_startup(st); if (ret) goto error_cleanup_buffer_trigger;