From: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
Cc: lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
alexandre.torgue-qxv4g6HH51o@public.gmane.org,
mcoquelin.stm32-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
benjamin.gaignard-qxv4g6HH51o@public.gmane.org,
linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 6/8] iio: trigger: Add STM32 LPTimer trigger driver
Date: Fri, 30 Jun 2017 14:57:13 +0100 [thread overview]
Message-ID: <20170630145713.2e612033@kernel.org> (raw)
In-Reply-To: <a1368383-8e5e-72ab-32f9-efe9715aaccb-qxv4g6HH51o@public.gmane.org>
On Mon, 26 Jun 2017 18:41:36 +0200
Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org> wrote:
> On 06/24/2017 10:13 PM, Jonathan Cameron wrote:
> > On Wed, 21 Jun 2017 16:30:13 +0200
> > Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org> wrote:
> >
> >> Add support for LPTIMx_OUT triggers that can be found on some STM32
> >> devices. These triggers can be used then by ADC or DAC.
> >> Typical usage is to configure LPTimer as PWM output (via pwm-stm32-lp)
> >> and have synchronised analog conversions with these triggers.
> >>
> >> Signed-off-by: Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
> > Given this can't be used as a trigger for other devices (no exposed
> > interrupt?) I'd expect to see a validate_device callback provided for
> > the trigger ops. That would prevent other devices trying to use it.
>
> Hi Jonathan,
>
> This is something I had in mind also earlier. Only thing is...
> Basically, this is limiting: when trigger poll happens on device side
> (e.g. ADC), another device could use same trigger. But I admit this
> looks like corner case.
>
> I'll add it in next version, with additional patch for ADC part to
> validate it's a valid device (No DAC yet).
> I think I'll use INDIO_HARDWARE_TRIGGERED mode:
> - in adc driver: indio_dev->modes |= INDIO_HARDWARE_TRIGGERED;
> - in lptimer: if (indio_dev->modes & INDIO_HARDWARE_TRIGGERED)...
That may not be enough in of itself. Could be other hardware
triggered elements on the platform (quite likely with these
stm parts!)
J
>
> >
> > Otherwise, looks good.
>
> Many thanks for your review.
> Best Regards,
> Fabrice
>
> >
> > Jonathan
> >> ---
> >> Changes in v2:
> >> - s/Low Power/Low-Power
> >> - update few comments
> >> ---
> >> drivers/iio/trigger/Kconfig | 11 +++
> >> drivers/iio/trigger/Makefile | 1 +
> >> drivers/iio/trigger/stm32-lptimer-trigger.c | 110 ++++++++++++++++++++++++++
> >> include/linux/iio/timer/stm32-lptim-trigger.h | 24 ++++++
> >> 4 files changed, 146 insertions(+)
> >> create mode 100644 drivers/iio/trigger/stm32-lptimer-trigger.c
> >> create mode 100644 include/linux/iio/timer/stm32-lptim-trigger.h
> >>
> >> diff --git a/drivers/iio/trigger/Kconfig b/drivers/iio/trigger/Kconfig
> >> index e4d4e63..a633d2c 100644
> >> --- a/drivers/iio/trigger/Kconfig
> >> +++ b/drivers/iio/trigger/Kconfig
> >> @@ -24,6 +24,17 @@ config IIO_INTERRUPT_TRIGGER
> >> To compile this driver as a module, choose M here: the
> >> module will be called iio-trig-interrupt.
> >>
> >> +config IIO_STM32_LPTIMER_TRIGGER
> >> + tristate "STM32 Low-Power Timer Trigger"
> >> + depends on MFD_STM32_LPTIMER || COMPILE_TEST
> >> + help
> >> + Select this option to enable STM32 Low-Power Timer Trigger.
> >> + This can be used as trigger source for STM32 internal ADC
> >> + and/or DAC.
> >> +
> >> + To compile this driver as a module, choose M here: the
> >> + module will be called stm32-lptimer-trigger.
> >> +
> >> config IIO_STM32_TIMER_TRIGGER
> >> tristate "STM32 Timer Trigger"
> >> depends on (ARCH_STM32 && OF && MFD_STM32_TIMERS) || COMPILE_TEST
> >> diff --git a/drivers/iio/trigger/Makefile b/drivers/iio/trigger/Makefile
> >> index 5c4ecd3..0a72a2a 100644
> >> --- a/drivers/iio/trigger/Makefile
> >> +++ b/drivers/iio/trigger/Makefile
> >> @@ -6,6 +6,7 @@
> >>
> >> obj-$(CONFIG_IIO_HRTIMER_TRIGGER) += iio-trig-hrtimer.o
> >> obj-$(CONFIG_IIO_INTERRUPT_TRIGGER) += iio-trig-interrupt.o
> >> +obj-$(CONFIG_IIO_STM32_LPTIMER_TRIGGER) += stm32-lptimer-trigger.o
> >> obj-$(CONFIG_IIO_STM32_TIMER_TRIGGER) += stm32-timer-trigger.o
> >> obj-$(CONFIG_IIO_SYSFS_TRIGGER) += iio-trig-sysfs.o
> >> obj-$(CONFIG_IIO_TIGHTLOOP_TRIGGER) += iio-trig-loop.o
> >> diff --git a/drivers/iio/trigger/stm32-lptimer-trigger.c b/drivers/iio/trigger/stm32-lptimer-trigger.c
> >> new file mode 100644
> >> index 0000000..bcb9aa2
> >> --- /dev/null
> >> +++ b/drivers/iio/trigger/stm32-lptimer-trigger.c
> >> @@ -0,0 +1,110 @@
> >> +/*
> >> + * STM32 Low-Power Timer Trigger driver
> >> + *
> >> + * Copyright (C) STMicroelectronics 2017
> >> + *
> >> + * Author: Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org>.
> >> + *
> >> + * License terms: GNU General Public License (GPL), version 2
> >> + *
> >> + * Inspired by Benjamin Gaignard's stm32-timer-trigger driver
> >> + */
> >> +
> >> +#include <linux/iio/iio.h>
> >> +#include <linux/iio/timer/stm32-lptim-trigger.h>
> >> +#include <linux/iio/trigger.h>
> >> +#include <linux/mfd/stm32-lptimer.h>
> >> +#include <linux/module.h>
> >> +#include <linux/platform_device.h>
> >> +
> >> +/* List Low-Power Timer triggers */
> >> +static const char * const stm32_lptim_triggers[] = {
> >> + LPTIM1_OUT,
> >> + LPTIM2_OUT,
> >> + LPTIM3_OUT,
> >> +};
> >> +
> >> +struct stm32_lptim_trigger {
> >> + struct device *dev;
> >> + const char *trg;
> >> +};
> >> +
> >> +static const struct iio_trigger_ops stm32_lptim_trigger_ops = {
> >> + .owner = THIS_MODULE,
> >> +};
> >> +
> >> +/**
> >> + * is_stm32_lptim_trigger
> >> + * @trig: trigger to be checked
> >> + *
> >> + * return true if the trigger is a valid STM32 IIO Low-Power Timer Trigger
> >> + * either return false
> >> + */
> >> +bool is_stm32_lptim_trigger(struct iio_trigger *trig)
> >> +{
> >> + return (trig->ops == &stm32_lptim_trigger_ops);
> >> +}
> >> +EXPORT_SYMBOL(is_stm32_lptim_trigger);
> >> +
> >> +static int stm32_lptim_setup_trig(struct stm32_lptim_trigger *priv)
> >> +{
> >> + struct iio_trigger *trig;
> >> +
> >> + trig = devm_iio_trigger_alloc(priv->dev, "%s", priv->trg);
> >> + if (!trig)
> >> + return -ENOMEM;
> >> +
> >> + trig->dev.parent = priv->dev->parent;
> >> + trig->ops = &stm32_lptim_trigger_ops;
> >> + iio_trigger_set_drvdata(trig, priv);
> >> +
> >> + return devm_iio_trigger_register(priv->dev, trig);
> >> +}
> >> +
> >> +static int stm32_lptim_trigger_probe(struct platform_device *pdev)
> >> +{
> >> + struct stm32_lptim_trigger *priv;
> >> + u32 index;
> >> + int ret;
> >> +
> >> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> >> + if (!priv)
> >> + return -ENOMEM;
> >> +
> >> + if (of_property_read_u32(pdev->dev.of_node, "reg", &index))
> >> + return -EINVAL;
> >> +
> >> + if (index >= ARRAY_SIZE(stm32_lptim_triggers))
> >> + return -EINVAL;
> >> +
> >> + priv->dev = &pdev->dev;
> >> + priv->trg = stm32_lptim_triggers[index];
> >> +
> >> + ret = stm32_lptim_setup_trig(priv);
> >> + if (ret)
> >> + return ret;
> >> +
> >> + platform_set_drvdata(pdev, priv);
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static const struct of_device_id stm32_lptim_trig_of_match[] = {
> >> + { .compatible = "st,stm32-lptimer-trigger", },
> >> + {},
> >> +};
> >> +MODULE_DEVICE_TABLE(of, stm32_lptim_trig_of_match);
> >> +
> >> +static struct platform_driver stm32_lptim_trigger_driver = {
> >> + .probe = stm32_lptim_trigger_probe,
> >> + .driver = {
> >> + .name = "stm32-lptimer-trigger",
> >> + .of_match_table = stm32_lptim_trig_of_match,
> >> + },
> >> +};
> >> +module_platform_driver(stm32_lptim_trigger_driver);
> >> +
> >> +MODULE_AUTHOR("Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org>");
> >> +MODULE_ALIAS("platform:stm32-lptimer-trigger");
> >> +MODULE_DESCRIPTION("STMicroelectronics STM32 LPTIM trigger driver");
> >> +MODULE_LICENSE("GPL v2");
> >> diff --git a/include/linux/iio/timer/stm32-lptim-trigger.h b/include/linux/iio/timer/stm32-lptim-trigger.h
> >> new file mode 100644
> >> index 0000000..cb795b1
> >> --- /dev/null
> >> +++ b/include/linux/iio/timer/stm32-lptim-trigger.h
> >> @@ -0,0 +1,24 @@
> >> +/*
> >> + * Copyright (C) STMicroelectronics 2017
> >> + *
> >> + * Author: Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
> >> + *
> >> + * License terms: GNU General Public License (GPL), version 2
> >> + */
> >> +
> >> +#ifndef _STM32_LPTIM_TRIGGER_H_
> >> +#define _STM32_LPTIM_TRIGGER_H_
> >> +
> >> +#define LPTIM1_OUT "lptim1_out"
> >> +#define LPTIM2_OUT "lptim2_out"
> >> +#define LPTIM3_OUT "lptim3_out"
> >> +
> >> +#if IS_ENABLED(CONFIG_IIO_STM32_LPTIMER_TRIGGER)
> >> +bool is_stm32_lptim_trigger(struct iio_trigger *trig);
> >> +#else
> >> +static inline bool is_stm32_lptim_trigger(struct iio_trigger *trig)
> >> +{
> >> + return false;
> >> +}
> >> +#endif
> >> +#endif
> >
next prev parent reply other threads:[~2017-06-30 13:57 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-21 14:30 [PATCH v2 0/8] Add STM32 LPTimer: PWM, trigger and counter Fabrice Gasnier
2017-06-21 14:30 ` [PATCH v2 1/8] dt-bindings: mfd: Add STM32 LPTimer binding Fabrice Gasnier
[not found] ` <1498055415-31513-2-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-06-21 20:05 ` Jonathan Cameron
2017-06-22 15:43 ` Lee Jones
2017-06-26 18:07 ` Rob Herring
2017-06-27 8:57 ` Fabrice Gasnier
[not found] ` <a69a61c3-95a8-d0cc-10a6-4a7cf65ff2c5-qxv4g6HH51o@public.gmane.org>
2017-06-28 16:44 ` Rob Herring
2017-06-29 7:17 ` Fabrice Gasnier
2017-06-21 14:30 ` [PATCH v2 2/8] mfd: Add STM32 LPTimer driver Fabrice Gasnier
2017-06-22 15:44 ` Lee Jones
2017-06-21 14:30 ` [PATCH v2 3/8] dt-bindings: pwm: Add STM32 LPTimer PWM binding Fabrice Gasnier
[not found] ` <1498055415-31513-4-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-06-26 18:10 ` Rob Herring
2017-06-21 14:30 ` [PATCH v2 4/8] pwm: Add STM32 LPTimer PWM driver Fabrice Gasnier
2017-07-06 7:43 ` Thierry Reding
2017-07-07 8:10 ` Fabrice Gasnier
[not found] ` <b82d9c76-d8c5-43bf-45cc-b5c26c1c7164-qxv4g6HH51o@public.gmane.org>
2017-07-07 9:23 ` Thierry Reding
[not found] ` <20170707092316.GA15652-m5CkvRiFyV9wFLYp8hBm2A@public.gmane.org>
2017-07-07 10:11 ` Fabrice Gasnier
2017-06-21 14:30 ` [PATCH v2 5/8] dt-bindings: iio: Add STM32 LPTimer trigger binding Fabrice Gasnier
[not found] ` <1498055415-31513-6-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-06-24 20:10 ` Jonathan Cameron
2017-06-26 18:14 ` Rob Herring
2017-06-26 20:38 ` Jonathan Cameron
2017-06-27 9:04 ` Fabrice Gasnier
2017-06-21 14:30 ` [PATCH v2 6/8] iio: trigger: Add STM32 LPTimer trigger driver Fabrice Gasnier
[not found] ` <1498055415-31513-7-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-06-24 20:13 ` Jonathan Cameron
2017-06-26 16:41 ` Fabrice Gasnier
[not found] ` <a1368383-8e5e-72ab-32f9-efe9715aaccb-qxv4g6HH51o@public.gmane.org>
2017-06-30 13:57 ` Jonathan Cameron [this message]
[not found] ` <20170630145713.2e612033-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-06-30 16:26 ` Fabrice Gasnier
[not found] ` <5435defb-f32e-c874-4977-e3eea5574774-qxv4g6HH51o@public.gmane.org>
2017-06-30 18:28 ` Jonathan Cameron
2017-06-21 14:30 ` [PATCH v2 7/8] dt-bindings: iio: Add STM32 LPTimer quadrature encoder and counter Fabrice Gasnier
2017-06-24 20:14 ` Jonathan Cameron
[not found] ` <1498055415-31513-8-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-06-26 18:16 ` Rob Herring
2017-06-21 14:30 ` [PATCH v2 8/8] iio: counter: Add support for STM32 LPTimer Fabrice Gasnier
[not found] ` <1498055415-31513-9-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-06-24 20:35 ` Jonathan Cameron
2017-06-26 20:29 ` William Breathitt Gray
2017-06-27 8:21 ` Benjamin Gaignard
[not found] ` <CA+M3ks73_-TRVRFYrGyWqB24aZCjdXv5ZwmnFQvvbOvKUVn-rw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-30 18:19 ` Jonathan Cameron
2017-06-30 20:36 ` Benjamin Gaignard
[not found] ` <CA+M3ks5PXzUVrnoEEcmRObB-65_Er9CVQcN9c8wJyjgP3=0Oxg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-01 12:25 ` Jonathan Cameron
2017-07-01 13:40 ` William Breathitt Gray
2017-07-01 18:09 ` Jonathan Cameron
[not found] ` <20170701190917.62acff57-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-07-03 1:02 ` William Breathitt Gray
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=20170630145713.2e612033@kernel.org \
--to=jic23-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=alexandre.torgue-qxv4g6HH51o@public.gmane.org \
--cc=benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=benjamin.gaignard-qxv4g6HH51o@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=fabrice.gasnier-qxv4g6HH51o@public.gmane.org \
--cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=mcoquelin.stm32-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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).