From: "Marek Behún" <kabel@kernel.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: "Gregory CLEMENT" <gregory.clement@bootlin.com>,
"Arnd Bergmann" <arnd@arndb.de>,
soc@kernel.org, arm@kernel.org,
"Andy Shevchenko" <andy@kernel.org>,
"Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH v12 3/8] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs
Date: Mon, 1 Jul 2024 13:35:04 +0200 [thread overview]
Message-ID: <20240701133429.1f2650e1@dellmb> (raw)
In-Reply-To: <CAMRc=MdpJUaJ3B64TTdt8B=PeJwR+BjiCx1SJj+SJGOT=LtT9A@mail.gmail.com>
On Mon, 1 Jul 2024 11:37:44 +0200
Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> On Mon, Jun 17, 2024 at 5:26 PM Marek Behún <kabel@kernel.org> wrote:
> >
> > Add support for GPIOs connected to the MCU on the Turris Omnia board.
> >
> > This includes:
> > - front button pin
> > - enable pins for USB regulators
> > - MiniPCIe / mSATA card presence pins in MiniPCIe port 0
> > - LED output pins from WAN ethernet PHY, LAN switch and MiniPCIe ports
> > - on board revisions 32+ also various peripheral resets and another
> > voltage regulator enable pin
> >
> > Signed-off-by: Marek Behún <kabel@kernel.org>
>
> This is one heck of a complex GPIO driver!
The complexity comes from how the MCU command API was engineered and
then when I took over the MCU firmware, I had to extend the command in
a way that would ensure backwards compatibility.
> > +
> > +#define _DEF_GPIO(_cmd, _ctl_cmd, _bit, _ctl_bit, _int_bit, _feat, _feat_mask) \
> > + { \
> > + .cmd = _cmd, \
> > + .ctl_cmd = _ctl_cmd, \
> > + .bit = _bit, \
> > + .ctl_bit = _ctl_bit, \
> > + .int_bit = (_int_bit) < 0 ? OMNIA_GPIO_INVALID_INT_BIT \
> > + : (_int_bit), \
> > + .feat = _feat, \
> > + .feat_mask = _feat_mask, \
> > + }
> > +#define _DEF_GPIO_STS(_name) \
> > + _DEF_GPIO(OMNIA_CMD_GET_STATUS_WORD, 0, __bf_shf(OMNIA_STS_ ## _name), \
> > + 0, __bf_shf(OMNIA_INT_ ## _name), 0, 0)
> > +#define _DEF_GPIO_CTL(_name) \
> > + _DEF_GPIO(OMNIA_CMD_GET_STATUS_WORD, OMNIA_CMD_GENERAL_CONTROL, \
> > + __bf_shf(OMNIA_STS_ ## _name), __bf_shf(OMNIA_CTL_ ## _name), \
> > + -1, 0, 0)
> > +#define _DEF_GPIO_EXT_STS(_name, _feat) \
> > + _DEF_GPIO(OMNIA_CMD_GET_EXT_STATUS_DWORD, 0, \
> > + __bf_shf(OMNIA_EXT_STS_ ## _name), 0, \
> > + __bf_shf(OMNIA_INT_ ## _name), \
> > + OMNIA_FEAT_ ## _feat | OMNIA_FEAT_EXT_CMDS, \
> > + OMNIA_FEAT_ ## _feat | OMNIA_FEAT_EXT_CMDS)
> > +#define _DEF_GPIO_EXT_STS_LED(_name, _ledext) \
> > + _DEF_GPIO(OMNIA_CMD_GET_EXT_STATUS_DWORD, 0, \
> > + __bf_shf(OMNIA_EXT_STS_ ## _name), 0, \
> > + __bf_shf(OMNIA_INT_ ## _name), \
> > + OMNIA_FEAT_LED_STATE_ ## _ledext, \
> > + OMNIA_FEAT_LED_STATE_EXT_MASK)
> > +#define _DEF_GPIO_EXT_STS_LEDALL(_name) \
> > + _DEF_GPIO(OMNIA_CMD_GET_EXT_STATUS_DWORD, 0, \
> > + __bf_shf(OMNIA_EXT_STS_ ## _name), 0, \
> > + __bf_shf(OMNIA_INT_ ## _name), \
> > + OMNIA_FEAT_LED_STATE_EXT_MASK, 0)
> > +#define _DEF_GPIO_EXT_CTL(_name, _feat) \
> > + _DEF_GPIO(OMNIA_CMD_GET_EXT_CONTROL_STATUS, OMNIA_CMD_EXT_CONTROL, \
> > + __bf_shf(OMNIA_EXT_CTL_ ## _name), \
> > + __bf_shf(OMNIA_EXT_CTL_ ## _name), -1, \
> > + OMNIA_FEAT_ ## _feat | OMNIA_FEAT_EXT_CMDS, \
> > + OMNIA_FEAT_ ## _feat | OMNIA_FEAT_EXT_CMDS)
> > +#define _DEF_INT(_name) \
> > + _DEF_GPIO(0, 0, 0, 0, __bf_shf(OMNIA_INT_ ## _name), 0, 0)
> > +
>
> One coding-style nit: can you add newlines between these macros?
Sent v13 with this change.
> I'm having a hard-time understanding the entire architecture of this
> MCU but the code overall looks good to me so I trust you know what
> you're doing.
>
> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Thanks.
Marek
next prev parent reply other threads:[~2024-07-01 11:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 15:25 [PATCH v12 0/8] Turris Omnia MCU driver Marek Behún
2024-06-17 15:26 ` [PATCH v12 2/8] platform: cznic: Add preliminary support for Turris Omnia MCU Marek Behún
2024-06-17 15:26 ` [PATCH v12 3/8] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs Marek Behún
2024-07-01 9:37 ` Bartosz Golaszewski
2024-07-01 11:35 ` Marek Behún [this message]
2024-07-01 8:41 ` [PATCH v12 0/8] Turris Omnia MCU driver Marek Behún
2024-07-01 11:38 ` Marek Behún
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=20240701133429.1f2650e1@dellmb \
--to=kabel@kernel.org \
--cc=andy@kernel.org \
--cc=arm@kernel.org \
--cc=arnd@arndb.de \
--cc=brgl@bgdev.pl \
--cc=gregory.clement@bootlin.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=soc@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).