From: Romain Perier <romain.perier@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>,
Lee Jones <lee.jones@linaro.org>, Daniel Palmer <daniel@0x0f.com>,
Rob Herring <robh+dt@kernel.org>,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] pwm: Add support for the MSTAR MSC313 PWM
Date: Fri, 19 Aug 2022 15:12:56 +0200 [thread overview]
Message-ID: <CABgxDo+_uZyO2vV4QxmVLTo2ohpAxzC89jcGJ3oksT6XxEBCmA@mail.gmail.com> (raw)
In-Reply-To: <20220619213520.qonqdv4e7zkvpeo7@pengutronix.de>
Hi,
Le dim. 19 juin 2022 à 23:35, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> a écrit :
> > diff --git a/drivers/pwm/pwm-msc313e.c b/drivers/pwm/pwm-msc313e.c
> > new file mode 100644
> > index 000000000000..f20419c6b9be
> > --- /dev/null
> > +++ b/drivers/pwm/pwm-msc313e.c
> > @@ -0,0 +1,242 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (C) 2021 Daniel Palmer <daniel@thingy.jp>
> > + * Copyright (C) 2022 Romain Perier <romain.perier@gmail.com>
> > + */
> > +
> > +#include <linux/clk.h>
> > +#include <linux/of_device.h>
> > +#include <linux/pwm.h>
> > +#include <linux/regmap.h>
> > +
> > +#define DRIVER_NAME "msc313e-pwm"
> > +
> > +#define CHANNEL_OFFSET 0x80
> > +#define REG_DUTY 0x8
> > +#define REG_PERIOD 0x10
> > +#define REG_DIV 0x18
> > +#define REG_CTRL 0x1c
> > +#define REG_SWRST 0x1fc
> > +
> > +struct msc313e_pwm_channel {
> > + struct regmap_field *clkdiv;
> > + struct regmap_field *polarity;
> > + struct regmap_field *dutyl;
> > + struct regmap_field *dutyh;
> > + struct regmap_field *periodl;
> > + struct regmap_field *periodh;
> > + struct regmap_field *swrst;
> > +};
> > +
> > +struct msc313e_pwm {
> > + struct regmap *regmap;
> > + struct pwm_chip pwmchip;
> > + struct clk *clk;
> > + struct msc313e_pwm_channel channels[];
> > +};
> > +
> > +struct msc313e_pwm_info {
> > + unsigned int channels;
> > +};
> > +
> > +#define to_msc313e_pwm(ptr) container_of(ptr, struct msc313e_pwm, pwmchip)
> > +
> > +static const struct regmap_config msc313e_pwm_regmap_config = {
> > + .reg_bits = 16,
> > + .val_bits = 16,
> > + .reg_stride = 4,
> > +};
> > +
> > +static const struct msc313e_pwm_info msc313e_data = {
> > + .channels = 8,
> > +};
> > +
> > +static const struct msc313e_pwm_info ssd20xd_data = {
> > + .channels = 4,
> > +};
> > +
> > +static void msc313e_pwm_writecounter(struct regmap_field *low, struct regmap_field *high, u32 value)
> > +{
> > + regmap_field_write(low, value);
> > + regmap_field_write(high, value >> 16);
>
> Is this racy? E.g. if the hw is running and the low register overflows
> before the high register is updated?
>
Ack, I am re-working most of the stuff you noticed. The problem with
this IP blocks (and others...) is we have close registers
but we only need to write or read 16 bits in each of these (it is
mainly reverse engineered from vendor source or runtime most of the
time) . You cannot really do a single read (except by doing an obscur
thing via readq ? ...)
. We had exactly the same issue with the rtc driver see [1]
1. https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/rtc/rtc-msc313.c#n50
.
Regards,
Romain
next prev parent reply other threads:[~2022-08-19 13:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 7:08 [PATCH 0/5] Add PWM for MStar SoCs Romain Perier
2022-06-15 7:08 ` [PATCH 1/5] dt-bindings: pwm: Add Mstar MSC313e PWM devicetree bindings documentation Romain Perier
2022-06-15 7:23 ` Conor Dooley
2022-06-16 14:06 ` Romain Perier
2022-06-15 13:16 ` Rob Herring
2022-06-16 14:08 ` Romain Perier
2022-06-16 15:25 ` Rob Herring
2022-06-15 7:08 ` [PATCH 2/5] pwm: Add support for the MSTAR MSC313 PWM Romain Perier
2022-06-19 21:35 ` Uwe Kleine-König
2022-08-19 13:12 ` Romain Perier [this message]
2022-08-19 14:44 ` Uwe Kleine-König
2022-06-15 7:08 ` [PATCH 3/5] ARM: dts: mstar: Add pwm device node to infinity Romain Perier
2022-06-15 7:08 ` [PATCH 4/5] ARM: dts: mstar: Add pwm device node to infinity3 Romain Perier
2022-06-15 7:08 ` [PATCH 5/5] ARM: dts: mstar: Add pwm device node to infinity2m Romain Perier
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=CABgxDo+_uZyO2vV4QxmVLTo2ohpAxzC89jcGJ3oksT6XxEBCmA@mail.gmail.com \
--to=romain.perier@gmail.com \
--cc=daniel@0x0f.com \
--cc=devicetree@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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).