Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1561485ybf; Sun, 1 Mar 2020 12:18:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyiP7yD6Qgg1M6T3F6iUVDPnqTM0AdweP5Nni8NWO+bF7uJHpQuGgv0QpSEKIe347cDP5Df X-Received: by 2002:a9d:20c1:: with SMTP id x59mr11267646ota.286.1583093903666; Sun, 01 Mar 2020 12:18:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583093903; cv=none; d=google.com; s=arc-20160816; b=xlCgZZIk28bzB0WUcc0PFpFqQJZ7qefWe5nvbI4sbdsdPAbohooHoIwXOTba/Rhznd 12N+swx4gBaUtxzCToABBzi1m1HcwlhWQmPXQ/AOb3ZqoGCrm33APPNFKQh/8aFsZZMl +XdIgy0gDVVNgGGHMLZ/q4LbhyWRsHCHYEYlFaL1KPUSlggwTSCyhrZ1hi+lTrs9DO5g JxoVknOUbSb2cVw+2bm1j2YIIrJHJg/3I5P8lukN8DAt46Wf5maVhsGoBGp/qTZn1WeC w+DxBP8wYy1tkVazZ18igkgZH0IB1bwka0us4rWsbjcUusArLiVUC/KEXJslMSf8xSa6 xvrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=BqeDwDgmDScKv2Itn9RPdkTYkj4mUqy1qn53xm40E8Y=; b=XDRt/1KajY+fyusZSfssX5YqjAWr3aMwa76HZJZjaI/165qT5Bmt6jh1+cCeqYCZss CdIfatGihTKYErjtz6cHZWR3XQn6ZQB/1c+lq2GyMijUiydyIt+yWX5Cdk/b6w/n9sEC W+c+LFdvssQg6tSyh/7xMJ1+x8Qmt/igQhp3CJya1aQ5b39qqqmoRH/mruWyU3uopcGm I0MypZ9WGKjeVFWLB+V00ijex6W45y9hME2FExFwWmZZ9mMgAHu1OiDA8UWmVueOoTfa Y8UtYk/vZ7mNKBvevUtSBMxKjv6R+skzoOQyxW1pYiuWHFYd3aRBNMkuceCfvtwy4jXw IuJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Y5k/FuSN"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q195si5284835oic.83.2020.03.01.12.18.10; Sun, 01 Mar 2020 12:18:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Y5k/FuSN"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726490AbgCAUSB (ORCPT + 99 others); Sun, 1 Mar 2020 15:18:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:38028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbgCAUSB (ORCPT ); Sun, 1 Mar 2020 15:18:01 -0500 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A436246BF; Sun, 1 Mar 2020 20:17:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583093880; bh=v8CQ/Vk08LpPLK20LK0xMU0V8MT8aNDZSukNATFwahU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Y5k/FuSN/Qqlh0hjHkCDS9G9eSk8RYH1CwXShlGbG5yfALvuqToeJHLHCiFblB4+G 0to24IEan09DFuN3JwXS0p+ep6C/yJ7ReGRO1GcLY3h8N9yYOfTfCOghObIwUGXWEH vS4ZWFEyQU96EBmE9pA+5S9ZySgO96EdxIWCKUi4= Date: Sun, 1 Mar 2020 20:17:52 +0000 From: Jonathan Cameron To: William Breathitt Gray Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] counter: 104-quad-8: Support Filter Clock Prescaler Message-ID: <20200301201752.35014f30@archlinux> In-Reply-To: <20200222164958.105288-1-vilhelm.gray@gmail.com> References: <20200222164958.105288-1-vilhelm.gray@gmail.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 22 Feb 2020 11:49:58 -0500 William Breathitt Gray wrote: > The ACCES 104-QUAD-8 series does active filtering on the quadrature > input signals via the PC/104 bus clock (OSC 14.318 MHz). This patch > exposes the filter clock prescaler available on each channel. > > Signed-off-by: William Breathitt Gray Looks good to me. Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to poke at it. thanks, Jonathan > --- > .../ABI/testing/sysfs-bus-counter-104-quad-8 | 7 +++ > drivers/counter/104-quad-8.c | 61 ++++++++++++++++++- > 2 files changed, 65 insertions(+), 3 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 b/Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 > index 46b1f33b2fce..3c905d3cf5d7 100644 > --- a/Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 > +++ b/Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 > @@ -1,3 +1,10 @@ > +What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler > +KernelVersion: 5.7 > +Contact: linux-iio@vger.kernel.org > +Description: > + Filter clock factor for input Signal Y. This prescaler value > + affects the inputs of both quadrature pair signals. > + > What: /sys/bus/counter/devices/counterX/signalY/index_polarity > KernelVersion: 5.2 > Contact: linux-iio@vger.kernel.org > diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c > index 17e67a84777d..0cfc813ee2cb 100644 > --- a/drivers/counter/104-quad-8.c > +++ b/drivers/counter/104-quad-8.c > @@ -43,6 +43,7 @@ MODULE_PARM_DESC(base, "ACCES 104-QUAD-8 base addresses"); > */ > struct quad8_iio { > struct counter_device counter; > + unsigned int fck_prescaler[QUAD8_NUM_COUNTERS]; > unsigned int preset[QUAD8_NUM_COUNTERS]; > unsigned int count_mode[QUAD8_NUM_COUNTERS]; > unsigned int quadrature_mode[QUAD8_NUM_COUNTERS]; > @@ -84,6 +85,8 @@ struct quad8_iio { > #define QUAD8_RLD_PRESET_CNTR 0x08 > /* Transfer Counter to Output Latch */ > #define QUAD8_RLD_CNTR_OUT 0x10 > +/* Transfer Preset Register LSB to FCK Prescaler */ > +#define QUAD8_RLD_PRESET_PSC 0x18 > #define QUAD8_CHAN_OP_ENABLE_COUNTERS 0x00 > #define QUAD8_CHAN_OP_RESET_COUNTERS 0x01 > #define QUAD8_CMR_QUADRATURE_X1 0x08 > @@ -1140,6 +1143,50 @@ static ssize_t quad8_count_preset_enable_write(struct counter_device *counter, > return len; > } > > +static ssize_t quad8_signal_fck_prescaler_read(struct counter_device *counter, > + struct counter_signal *signal, void *private, char *buf) > +{ > + const struct quad8_iio *const priv = counter->priv; > + const size_t channel_id = signal->id / 2; > + > + return sprintf(buf, "%u\n", priv->fck_prescaler[channel_id]); > +} > + > +static ssize_t quad8_signal_fck_prescaler_write(struct counter_device *counter, > + struct counter_signal *signal, void *private, const char *buf, > + size_t len) > +{ > + struct quad8_iio *const priv = counter->priv; > + const size_t channel_id = signal->id / 2; > + const int base_offset = priv->base + 2 * channel_id; > + u8 prescaler; > + int ret; > + > + ret = kstrtou8(buf, 0, &prescaler); > + if (ret) > + return ret; > + > + priv->fck_prescaler[channel_id] = prescaler; > + > + /* Reset Byte Pointer */ > + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); > + > + /* Set filter clock factor */ > + outb(prescaler, base_offset); > + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, > + base_offset + 1); > + > + return len; > +} > + > +static const struct counter_signal_ext quad8_signal_ext[] = { > + { > + .name = "filter_clock_prescaler", > + .read = quad8_signal_fck_prescaler_read, > + .write = quad8_signal_fck_prescaler_write > + } > +}; > + > static const struct counter_signal_ext quad8_index_ext[] = { > COUNTER_SIGNAL_ENUM("index_polarity", &quad8_index_pol_enum), > COUNTER_SIGNAL_ENUM_AVAILABLE("index_polarity", &quad8_index_pol_enum), > @@ -1147,9 +1194,11 @@ static const struct counter_signal_ext quad8_index_ext[] = { > COUNTER_SIGNAL_ENUM_AVAILABLE("synchronous_mode", &quad8_syn_mode_enum) > }; > > -#define QUAD8_QUAD_SIGNAL(_id, _name) { \ > - .id = (_id), \ > - .name = (_name) \ > +#define QUAD8_QUAD_SIGNAL(_id, _name) { \ > + .id = (_id), \ > + .name = (_name), \ > + .ext = quad8_signal_ext, \ > + .num_ext = ARRAY_SIZE(quad8_signal_ext) \ > } > > #define QUAD8_INDEX_SIGNAL(_id, _name) { \ > @@ -1314,6 +1363,12 @@ static int quad8_probe(struct device *dev, unsigned int id) > base_offset = base[id] + 2 * i; > /* Reset Byte Pointer */ > outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); > + /* Reset filter clock factor */ > + outb(0, base_offset); > + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, > + base_offset + 1); > + /* Reset Byte Pointer */ > + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); > /* Reset Preset Register */ > for (j = 0; j < 3; j++) > outb(0x00, base_offset);