linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: William Breathitt Gray <william.gray@linaro.org>
To: andy.shevchenko@gmail.com
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-gpio@vger.kernel.org
Subject: Re: [PATCH 0/3] Add Intel 8254 Counter support
Date: Mon, 22 May 2023 12:20:12 -0400	[thread overview]
Message-ID: <ZGuWPLISTk7ALOe/@fedora> (raw)
In-Reply-To: <ZGiYr6XLguZ8R3_8@surfacebook>

[-- Attachment #1: Type: text/plain, Size: 3364 bytes --]

On Sat, May 20, 2023 at 12:53:51PM +0300, andy.shevchenko@gmail.com wrote:
> Sun, Apr 16, 2023 at 01:36:52PM -0400, William Breathitt Gray kirjoitti:
> > The Intel 8254 PIT first appeared in the early 1980s and was used
> > initially in IBM PC compatibles. The popularity of the original Intel
> > 825x family of chips led to many subsequent variants and clones of the
> > interface in various chips and integrated circuits. Although still
> > popular, interfaces compatible with the Intel 8254 PIT are nowdays
> > typically found embedded in larger VLSI processing chips and FPGA
> > components rather than as discrete ICs.
> > 
> > This patch series introduces a library to provide support for interfaces
> > compatible with the venerable Intel 8254 Programmable Interval Timer
> > (PIT). Modules wanting access to the i8254 library should select the
> > newly introduced CONFIG_I8254 Kconfig option, and import the I8254
> > symbol namespace.
> > 
> > Support for the i8254 is added in respective follow-up patches for the
> > 104-dio-48e driver and stx104 driver whose devices feature i8254
> > compatible interfaces. Several additional dependencies are necessary for
> > the 104-dio-48e [0][1][2] and stx104 [3][4].
> > 
> > Due to the dependency requirements, I can take the i8254 introduction
> > patch through the Counter tree and provide an immutable branch that can
> > be merged to the GPIO and IIO trees; the 104-dio-48e patch and stx104
> > patch could then be picked up separately by the respective subsystem
> > maintainers.
> 
> Good job!
> 
> What I'm wondering is that. Can x86 core and others which are using that chip
> utilize (some of) the functions from the library?

Essentially we just need a regmap to register the device to the system
via devm_i8254_regmap_register(), so theoretically it would be possible
to load this driver for the integrated 8254 interface used by x86 core.
The big caveat however is that the Counter subsystem currently lacks an
in-kernel API, so registering that device would just expose the
userspace Counter sysfs and chrdev interfaces.

I suppose the interest is whether we could use the configuration
functionality of the Counter subsystem to abstract some of the hardcoded
routines and magic numbers in places like drivers/clocksource/i8253.c
and similar. Right now we wouldn't be able to do so, but perhaps in the
future if an in-kernel API is developed for the Counter subsystem then
it would be possible.

An interesting side-note about compatibility: the Intel 8253 counting
behavior differs subtly from the Intel 8254 in certain situations. For
example, suppose odd counts in Mode 3: the Intel 8253 will load the
initial count directly [0] whereas the Intel 8254 loads the initial
count minus one (an even number) [1]. This results in different maximums
and minimums: for example if the initial count is 5, the Intel 8253 will
report a maximum count of 5 and a minimum count of 2 (counting 5->4->2),
whereas the Intel 8254 will report a maximum count of 4 and a minimum
count of 0 (counting 4->2->0); same square wave is produced, but
different count values are reported.

William Breathitt Gray

[0] https://www.alldatasheet.com/datasheet-pdf/pdf/66098/INTEL/8253.html
[1] https://www.alldatasheet.com/datasheet-pdf/pdf/66099/INTEL/8254.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2023-05-22 16:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-16 17:36 [PATCH 0/3] Add Intel 8254 Counter support William Breathitt Gray
2023-04-16 17:36 ` [PATCH 1/3] counter: i8254: Introduce the Intel 8254 interface library module William Breathitt Gray
2023-06-08 14:43   ` William Breathitt Gray
2023-06-20 14:03     ` Jarkko Nikula
2023-06-12  5:14       ` William Breathitt Gray
2023-04-16 17:36 ` [PATCH 2/3] gpio: 104-dio-48e: Add Counter/Timer support William Breathitt Gray
2023-05-17 14:35   ` Bartosz Golaszewski
2023-05-20 19:28   ` Linus Walleij
2023-05-22 16:44     ` William Breathitt Gray
2023-04-16 17:36 ` [PATCH 3/3] iio: addac: stx104: Add 8254 " William Breathitt Gray
2023-05-20  9:53 ` [PATCH 0/3] Add Intel 8254 Counter support andy.shevchenko
2023-05-22 16:20   ` William Breathitt Gray [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZGuWPLISTk7ALOe/@fedora \
    --to=william.gray@linaro.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).