From: Lee Jones <lee@kernel.org>
To: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: linux-sh@vger.kernel.org, "Damien Le Moal" <dlemoal@kernel.org>,
"Niklas Cassel" <cassel@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Michael Turquette" <mturquette@baylibre.com>,
"Stephen Boyd" <sboyd@kernel.org>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Daniel Lezcano" <daniel.lezcano@linaro.org>,
"Rich Felker" <dalias@libc.org>,
"John Paul Adrian Glaubitz" <glaubitz@physik.fu-berlin.de>,
"Helge Deller" <deller@gmx.de>,
"Heiko Stuebner" <heiko.stuebner@cherry.de>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Chris Morgan" <macromorgan@hotmail.com>,
"Sebastian Reichel" <sre@kernel.org>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Baoquan He" <bhe@redhat.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Guenter Roeck" <linux@roeck-us.net>,
"Kefeng Wang" <wangkefeng.wang@huawei.com>,
"Stephen Rothwell" <sfr@canb.auug.org.au>,
"Azeem Shaikh" <azeemshaikh38@gmail.com>,
"Guo Ren" <guoren@kernel.org>,
"Max Filippov" <jcmvbkbc@gmail.com>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"Herve Codina" <herve.codina@bootlin.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Anup Patel" <apatel@ventanamicro.com>,
"Jacky Huang" <ychuang3@nuvoton.com>,
"Hugo Villeneuve" <hvilleneuve@dimonoff.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Christophe JAILLET" <christophe.jaillet@wanadoo.fr>,
"Sam Ravnborg" <sam@ravnborg.org>,
"Javier Martinez Canillas" <javierm@redhat.com>,
"Sergey Shtylyov" <s.shtylyov@omp.ru>,
"Laurent Pinchart" <laurent.pinchart+renesas@ideasonboard.com>,
linux-ide@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-pci@vger.kernel.org, linux-serial@vger.kernel.org,
linux-fbdev@vger.kernel.org
Subject: Re: [DO NOT MERGE v8 23/36] mfd: sm501: Convert platform_data to OF property
Date: Fri, 31 May 2024 10:56:50 +0100 [thread overview]
Message-ID: <20240531095650.GD8682@google.com> (raw)
In-Reply-To: <c139d3a42c61d978296aa2e513de073c643e4fbe.1716965617.git.ysato@users.sourceforge.jp>
On Wed, 29 May 2024, Yoshinori Sato wrote:
> Various parameters of SM501 can be set using platform_data,
> so parameters cannot be passed in the DeviceTree target.
> Expands the parameters set in platform_data so that they can be
> specified using DeviceTree properties.
>
> Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
> ---
> drivers/mfd/sm501.c | 238 ++++++++++++++++++++++++++++++++++
> drivers/video/fbdev/sm501fb.c | 87 +++++++++++++
> 2 files changed, 325 insertions(+)
>
> diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
> index b3592982a83b..d373aded0c3b 100644
> --- a/drivers/mfd/sm501.c
> +++ b/drivers/mfd/sm501.c
> @@ -20,6 +20,7 @@
> #include <linux/gpio/driver.h>
> #include <linux/gpio/machine.h>
> #include <linux/slab.h>
> +#include <linux/clk.h>
>
> #include <linux/sm501.h>
> #include <linux/sm501-regs.h>
> @@ -82,6 +83,16 @@ struct sm501_devdata {
> unsigned int rev;
> };
>
> +struct sm501_config_props_uint {
> + char *name;
> + u32 shift;
> +};
> +
> +struct sm501_config_props_flag {
> + char *clr_name;
> + char *set_name;
> + u32 bit;
> +};
>
> #define MHZ (1000 * 1000)
>
> @@ -1370,6 +1381,227 @@ static int sm501_init_dev(struct sm501_devdata *sm)
> return 0;
> }
>
> +#define FIELD_WIDTH 4
> +struct dt_values {
> + char *name;
> + unsigned int offset;
> + unsigned int width;
> + char *val[(1 << FIELD_WIDTH) + 1];
> +};
> +
> +#define fld(_name, _offset, _width, ...) \
> + { \
> + .name = _name, \
> + .offset = _offset, \
> + .width = _width, \
> + .val = { __VA_ARGS__, NULL}, \
> + }
> +
> +static const struct dt_values misc_timing[] = {
> + fld("ex", 28, 4,
> + "none", "16", "32", "48", "64", "80", "96", "112",
> + "128", "144", "160", "176", "192", "208", "224", "240"),
> + fld("xc", 24, 2, "internal-pll", "hclk", "gpio30"),
> + fld("us", 23, 1, "disable", "enable"),
> + fld("ssm1", 20, 1, "288", "divider"),
> + fld("sm1", 16, 4,
> + "1", "2", "4", "8", "16", "32", "64", "128",
> + "3", "6", "12", "24", "48", "96", "192", "384"),
> + fld("ssm0", 12, 1, "288", "divider"),
> + fld("sm0", 8, 4,
> + "1", "2", "4", "8", "16", "32", "64", "128",
> + "3", "6", "12", "24", "48", "96", "192", "384"),
> + fld("deb", 7, 1, "input-reference", "output"),
> + fld("a", 6, 1, "no-acpi", "acpi"),
> + fld("divider", 4, 2, "336", "288", "240", "192"),
> + fld("u", 3, 1, "normal", "simulation"),
> + fld("delay", 0, 3, "none", "0.5", "1.0", "1.5", "2.0", "2.5"),
> + { .name = NULL },
> +};
> +
> +static const struct dt_values misc_control[] = {
> + fld("pad", 30, 2, "24", "12", "8"),
> + fld("usbclk", 28, 2, "xtal", "96", "48"),
> + fld("ssp", 27, 1, "uart1", "ssp1"),
> + fld("lat", 26, 1, "disable", "enable"),
> + fld("fp", 25, 1, "18", "24"),
> + fld("freq", 24, 1, "24", "12"),
> + fld("refresh", 21, 2, "8", "16", "32", "64"),
> + fld("hold", 18, 3, "fifo-empty", "8", "16", "24", "32"),
> + fld("sh", 17, 1, "active-low", "active-high"),
> + fld("ii", 16, 1, "normal", "inverted"),
> + fld("pll", 15, 1, "disable", "enable"),
> + fld("gap", 13, 2, "0"),
> + fld("dac", 12, 1, "enable", "disable"),
> + fld("mc", 11, 1, "cpu", "8051"),
> + fld("bl", 10, 8, "1"),
> + fld("usb", 9, 1, "master", "slave"),
> + fld("vr", 4, 1, "0x1e00000", "0x3e00000"),
> + { .name = NULL },
> +};
I've been avoiding this set for a while now!
I appreciate the amount of work that you've put into this, but this is a
bit of a disaster. It's a hell of lot of over-complex infrastructure
just to pull out some values from DT.
Forgive me if I have this wrong, but it looks like you're defining
various structs then populating static versions with hard-coded offsets
into DT arrays! Then you have a bunch of hoop-jumpy functions to
firstly parse the offset-structs, then conduct look-ups to pull the
final value which in turn gets shifted into an encoded variable ready
for to write out to the registers. Bonkers.
What does 'timing' even mean in this context? Clocks?
What other devices require this kind of handling? Why is this device so
different from all other supported devices to date? Instead of
attempting to shoehorn this into a 20 year old driver, why not reshape
it to bring it into alignment with how we do things today?
E.g. handle all clocking from the clock driver, all display settings
(including timing?) from the display driver, etc.
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2024-05-31 9:57 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 8:00 [DO NOT MERGE v8 00/36] Device Tree support for SH7751 based board Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 01/36] sh: passing FDT address to kernel startup Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 02/36] sh: Kconfig unified OF supported targets Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 03/36] sh: Enable OF support for build and configuration Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 04/36] dt-bindings: interrupt-controller: Add header for Renesas SH3/4 INTC Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 05/36] sh: GENERIC_IRQ_CHIP support for CONFIG_OF=y Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 06/36] sh: kernel/setup Update DT support Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 07/36] sh: Fix COMMON_CLK support in CONFIG_OF=y Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 08/36] clocksource: sh_tmu: CLOCKSOURCE support Yoshinori Sato
2024-05-29 12:55 ` Andy Shevchenko
2024-05-29 8:00 ` [DO NOT MERGE v8 09/36] dt-binding: Add compatible SH7750 SoC Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 10/36] sh: Common PCI Framework driver support Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 11/36] pci: pci-sh7751: Add SH7751 PCI driver Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 12/36] dt-bindings: pci: pci-sh7751: Add SH7751 PCI Yoshinori Sato
2024-05-29 8:00 ` [DO NOT MERGE v8 13/36] dt-bindings: clock: sh7750-cpg: Add renesas,sh7750-cpg header Yoshinori Sato
2024-05-29 13:06 ` Geert Uytterhoeven
2024-05-29 8:01 ` [DO NOT MERGE v8 14/36] clk: Compatible with narrow registers Yoshinori Sato
2024-05-29 23:15 ` Stephen Boyd
2024-05-29 8:01 ` [DO NOT MERGE v8 15/36] clk: renesas: Add SH7750/7751 CPG Driver Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 16/36] irqchip: Add SH7751 INTC driver Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 17/36] dt-bindings: interrupt-controller: renesas,sh7751-intc: Add json-schema Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 18/36] irqchip: SH7751 external interrupt encoder with enable gate Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 19/36] dt-bindings: interrupt-controller: renesas,sh7751-irl-ext: Add json-schema Yoshinori Sato
2024-06-03 15:54 ` Rob Herring
2024-05-29 8:01 ` [DO NOT MERGE v8 20/36] serial: sh-sci: fix SH4 OF support Yoshinori Sato
2024-07-11 12:57 ` John Paul Adrian Glaubitz
2024-05-29 8:01 ` [DO NOT MERGE v8 21/36] dt-bindings: serial: renesas,scif: Add scif-sh7751 Yoshinori Sato
2024-06-03 15:55 ` Rob Herring (Arm)
2024-05-29 8:01 ` [DO NOT MERGE v8 22/36] dt-bindings: display: smi,sm501: SMI SM501 binding json-schema Yoshinori Sato
2024-05-29 10:44 ` Rob Herring (Arm)
2024-05-29 8:01 ` [DO NOT MERGE v8 23/36] mfd: sm501: Convert platform_data to OF property Yoshinori Sato
2024-05-31 9:56 ` Lee Jones [this message]
2024-05-29 8:01 ` [DO NOT MERGE v8 24/36] dt-binding: sh: cpus: Add SH CPUs json-schema Yoshinori Sato
2024-05-29 10:44 ` Rob Herring (Arm)
2024-05-29 8:01 ` [DO NOT MERGE v8 25/36] dt-bindings: vendor-prefixes: Add iodata Yoshinori Sato
2024-05-29 16:27 ` Conor Dooley
2024-05-29 8:01 ` [DO NOT MERGE v8 26/36] dt-bindings: ata: ata-generic: Add new targets Yoshinori Sato
2024-05-29 16:25 ` Conor Dooley
2024-05-29 8:01 ` [DO NOT MERGE v8 27/36] dt-bindings: soc: renesas: sh: Add SH7751 based target Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 28/36] sh: SH7751R SoC Internal peripheral definition dtsi Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 29/36] sh: add RTS7751R2D Plus DTS Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 30/36] sh: Add IO DATA LANDISK dts Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 31/36] sh: Add IO DATA USL-5P dts Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 32/36] sh: j2_mimas_v2.dts update Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 33/36] sh: Add dtbs target support Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 34/36] sh: RTS7751R2D Plus OF defconfig Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 35/36] sh: LANDISK " Yoshinori Sato
2024-05-29 8:01 ` [DO NOT MERGE v8 36/36] sh: j2_defconfig: update Yoshinori Sato
2024-05-30 17:15 ` [DO NOT MERGE v8 00/36] Device Tree support for SH7751 based board Bjorn Helgaas
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=20240531095650.GD8682@google.com \
--to=lee@kernel.org \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=apatel@ventanamicro.com \
--cc=arnd@arndb.de \
--cc=azeemshaikh38@gmail.com \
--cc=bhe@redhat.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=dalias@libc.org \
--cc=daniel.lezcano@linaro.org \
--cc=daniel@ffwll.ch \
--cc=deller@gmx.de \
--cc=devicetree@vger.kernel.org \
--cc=dlemoal@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert+renesas@glider.be \
--cc=glaubitz@physik.fu-berlin.de \
--cc=gregkh@linuxfoundation.org \
--cc=guoren@kernel.org \
--cc=heiko.stuebner@cherry.de \
--cc=herve.codina@bootlin.com \
--cc=hvilleneuve@dimonoff.com \
--cc=javierm@redhat.com \
--cc=jcmvbkbc@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=jirislaby@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kw@linux.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linus.walleij@linaro.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lpieralisi@kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=macromorgan@hotmail.com \
--cc=magnus.damm@gmail.com \
--cc=masahiroy@kernel.org \
--cc=mripard@kernel.org \
--cc=mturquette@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=robh@kernel.org \
--cc=s.shtylyov@omp.ru \
--cc=sam@ravnborg.org \
--cc=sboyd@kernel.org \
--cc=sfr@canb.auug.org.au \
--cc=sre@kernel.org \
--cc=tglx@linutronix.de \
--cc=tzimmermann@suse.de \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wangkefeng.wang@huawei.com \
--cc=wsa+renesas@sang-engineering.com \
--cc=ychuang3@nuvoton.com \
--cc=ysato@users.sourceforge.jp \
/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).