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>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.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>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Bjorn Helgaas" <bhelgaas@google.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@sntech.de>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"Chris Morgan" <macromorgan@hotmail.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Hyeonggon Yoo" <42.hyeyoo@gmail.com>,
"David Rientjes" <rientjes@google.com>,
"Vlastimil Babka" <vbabka@suse.cz>, "Baoquan He" <bhe@redhat.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Guenter Roeck" <linux@roeck-us.net>,
"Stephen Rothwell" <sfr@canb.auug.org.au>,
"Guo Ren" <guoren@kernel.org>,
"Javier Martinez Canillas" <javierm@redhat.com>,
"Azeem Shaikh" <azeemshaikh38@gmail.com>,
"Palmer Dabbelt" <palmer@rivosinc.com>,
"Bin Meng" <bmeng@tinylab.org>,
"Max Filippov" <jcmvbkbc@gmail.com>, "Tom Rix" <trix@redhat.com>,
"Herve Codina" <herve.codina@bootlin.com>,
"Jacky Huang" <ychuang3@nuvoton.com>,
"Lukas Bulwahn" <lukas.bulwahn@gmail.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Biju Das" <biju.das.jz@bp.renesas.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Sam Ravnborg" <sam@ravnborg.org>,
"Michael Karcher" <kernel@mkarcher.dialup.fu-berlin.de>,
"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 v5 23/37] mfd: sm501: Convert platform_data to OF property
Date: Thu, 7 Dec 2023 16:36:44 +0000 [thread overview]
Message-ID: <20231207163644.GB111411@google.com> (raw)
In-Reply-To: <68532082074b0c8fe9945b481678aab77520f517.1701768028.git.ysato@users.sourceforge.jp>
On Tue, 05 Dec 2023, 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 | 99 +++++++++++++++++++++++++++++++++++
> drivers/video/fbdev/sm501fb.c | 82 +++++++++++++++++++++++++++++
> 2 files changed, 181 insertions(+)
>
> diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
> index 28027982cf69..f0104fdf0f34 100644
> --- a/drivers/mfd/sm501.c
> +++ b/drivers/mfd/sm501.c
> @@ -1370,6 +1370,99 @@ static int sm501_init_dev(struct sm501_devdata *sm)
> return 0;
> }
>
> +static void sm501_of_read_reg_init(struct device_node *np,
> + const char *propname, struct sm501_reg_init *val)
> +{
> + u32 u32_val[2];
Encoding the size of the variable in the variable name is odd.
> +
> + if (!of_property_read_u32_array(np, propname, u32_val, sizeof(u32_val))) {
> + val->set = u32_val[0];
> + val->mask = u32_val[1];
Masks and register values stored as DT properties? This is generally
not permitted. Please seek counsel from the DT maintainers.
> + }
> +}
> +
> +/* Read GPIO I2C configuration */
> +static int sm501_parse_dt_gpio_i2c(struct device *dev, struct sm501_platdata *plat,
> + struct device_node *np)
> +{
> + struct sm501_platdata_gpio_i2c *gpio_i2c_p;
> + struct property *prop;
> + u32 gpio_i2c[5];
Why 5? Please define all magic numbers.
> + const __be32 *p;
> + unsigned int i;
> + u32 i2c_nr;
> +
> + prop = of_find_property(np, "smi,gpio-i2c", NULL);
> + if (!prop)
> + return 0;
> +
> + i2c_nr = of_property_count_u32_elems(np, "smi,gpio-i2c");
Why do you need both of these probing functions? What does
of_property_count_u32_elems() return if smi,gpio-i2c doesn't exist?
> + /* GPIO I2C define 5 words per channel. */
> + if (i2c_nr % 5)
> + return -EINVAL;
> + i2c_nr /= 5;
'\n'
> + plat->gpio_i2c = devm_kzalloc(dev, sizeof(*plat->gpio_i2c) * i2c_nr,
> + GFP_KERNEL);
> + if (!plat->gpio_i2c)
> + return -ENOMEM;
> +
> + plat->gpio_i2c_nr = i2c_nr;
> + gpio_i2c_p = plat->gpio_i2c;
What's the purpose of this intermediary variable?
> +
> + for (; i2c_nr > 0; i2c_nr--) {
You can define 'p' in here, right?
> + for (i = 0; i < ARRAY_SIZE(gpio_i2c); i++) {
> + p = of_prop_next_u32(prop, p, &gpio_i2c[i]);
> + if (!p)
> + return -EINVAL;
> + }
> + gpio_i2c_p->bus_num = gpio_i2c[0];
> + gpio_i2c_p->pin_sda = gpio_i2c[1];
> + gpio_i2c_p->pin_scl = gpio_i2c[2];
> + gpio_i2c_p->udelay = gpio_i2c[3];
> + gpio_i2c_p->timeout = gpio_i2c[4];
I'm not even going to ask. I'll leave this to the DT maintainers.
> + gpio_i2c_p++;
> + }
> + return 0;
> +}
> +
> +/* Build platform_data from OF property */
> +static int sm501_parse_dt(struct sm501_devdata *sm, struct device_node *np)
> +{
> + struct sm501_platdata *plat;
> + u32 u32_val;
> + int ret;
> +
> + plat = devm_kzalloc(sm->dev, sizeof(*plat), GFP_KERNEL);
> + if (!plat)
> + return -ENOMEM;
> +
> + plat->init = devm_kzalloc(sm->dev, sizeof(*plat->init), GFP_KERNEL);
Why not grab all of the memory at once?
Maybe make this 'init' thing a non-pointer.
> + if (!plat->init)
> + return -ENOMEM;
> +
> + if (!of_property_read_u32(np, "smi,devices", &u32_val))
> + plat->init->devices = u32_val;
What happens if you do:
of_property_read_u32(np, "smi,devices", &plat->init->devices);
> + if (!of_property_read_u32(np, "smi,mclk", &u32_val))
> + plat->init->mclk = u32_val;
> + if (!of_property_read_u32(np, "smi,m1xclk", &u32_val))
> + plat->init->m1xclk = u32_val;
> +
> + sm501_of_read_reg_init(np, "smi,misc-timing", &plat->init->misc_timing);
> + sm501_of_read_reg_init(np, "smi,misc-control", &plat->init->misc_control);
> + sm501_of_read_reg_init(np, "smi,gpio-low", &plat->init->gpio_low);
> + sm501_of_read_reg_init(np, "smi,gpio-high", &plat->init->gpio_high);
> +
> + if (IS_ENABLED(CONFIG_MFD_SM501_GPIO) &&
> + (plat->init->devices & SM501_USE_GPIO)) {
That's over-bracketed, right?
plat->init->devices is a bit mask of enable devices stored in DT?
Okay, I think this is going to need a lot of work on the DT side.
Leaving the review here for now.
> + ret = sm501_parse_dt_gpio_i2c(sm->dev, plat, np);
> + if (ret)
> + return ret;
> + }
> + sm->platdata = plat;
> + return 0;
> +}
> +
> static int sm501_plat_probe(struct platform_device *dev)
> {
> struct sm501_devdata *sm;
> @@ -1406,6 +1499,12 @@ static int sm501_plat_probe(struct platform_device *dev)
> goto err_res;
> }
>
> + if (IS_ENABLED(CONFIG_OF) && dev->dev.of_node) {
> + ret = sm501_parse_dt(sm, dev->dev.of_node);
> + if (ret)
> + goto err_res;
> + }
> +
> platform_set_drvdata(dev, sm);
>
> sm->regs = ioremap(sm->io_res->start, resource_size(sm->io_res));
> diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c
> index d6fdc1737cd2..d35285819d28 100644
> --- a/drivers/video/fbdev/sm501fb.c
> +++ b/drivers/video/fbdev/sm501fb.c
> @@ -1932,6 +1932,82 @@ static int sm501fb_start_one(struct sm501fb_info *info,
> return 0;
> }
>
> +#if defined(CONFIG_OF)
> +/* parse CRT / panel configuration */
> +static struct sm501_platdata_fbsub *dt_fbsub(struct device *dev,
> + struct device_node *np,
> + const char *name)
> +{
> + struct sm501_platdata_fbsub *fbsub = NULL;
> + struct fb_videomode *def_mode = NULL;
> + struct device_node *child;
> + const void *p_edid;
> + u32 flags = 0;
> + u32 bpp = 0;
> + int len;
> +
> + child = of_get_child_by_name(np, name);
> + if (child == NULL)
> + return NULL;
> +
> + p_edid = of_get_property(child, "edid", &len);
> + if (p_edid && len == EDID_LENGTH) {
> + struct fb_monspecs *specs;
> + u8 *edid;
> +
> + edid = kmemdup(p_edid, EDID_LENGTH, GFP_KERNEL);
> + if (edid) {
> + specs = kzalloc(sizeof(*specs), GFP_KERNEL);
> + if (specs) {
> + fb_edid_to_monspecs(edid, specs);
> + def_mode = specs->modedb;
> + }
> + }
> + kfree(edid);
> + }
> +
> + of_property_read_u32(child, "bpp", &bpp);
> +
> + /* If flags property is obtained, fbsub is returned. */
> + if (!of_property_read_u32(child, "smi,flags", &flags)) {
> + fbsub = devm_kzalloc(dev, sizeof(*fbsub), GFP_KERNEL);
> + if (fbsub) {
> + fbsub->def_mode = def_mode;
> + fbsub->def_bpp = bpp;
> + fbsub->flags = flags;
> + }
> + }
> + return fbsub;
> +}
> +
> +/* Build platform_data from OF property */
> +static struct sm501_platdata_fb *pdata_from_dt(struct device *dev, struct device_node *np)
> +{
> + enum sm501_fb_routing fb_route = SM501_FB_OWN;
> + struct sm501_platdata_fb *pdata = NULL;
> + struct sm501_platdata_fbsub *fb_crt;
> + struct sm501_platdata_fbsub *fb_pnl;
> + unsigned int flags = 0;
> +
> + if (of_property_read_bool(np, "route-crt-panel"))
> + fb_route = SM501_FB_CRT_PANEL;
> + if (of_property_read_bool(np, "swap-fb-endian"))
> + flags = SM501_FBPD_SWAP_FB_ENDIAN;
> + fb_crt = dt_fbsub(dev, np, "crt");
> + fb_pnl = dt_fbsub(dev, np, "panel");
> + if (fb_crt || fb_pnl) {
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> + if (pdata) {
> + pdata->fb_route = fb_route;
> + pdata->flags = flags;
> + pdata->fb_crt = fb_crt;
> + pdata->fb_pnl = fb_pnl;
> + }
> + }
> + return pdata;
> +}
> +#endif
> +
> static int sm501fb_probe(struct platform_device *pdev)
> {
> struct sm501fb_info *info;
> @@ -1974,6 +2050,12 @@ static int sm501fb_probe(struct platform_device *pdev)
> if (info->edid_data)
> found = 1;
> }
> + /* Get platform data compatible configuration */
> + if (!found) {
> + info->pdata = pdata_from_dt(dev, np);
> + if (info->pdata)
> + found = 1;
> + }
> }
> #endif
> if (!found) {
> --
> 2.39.2
>
--
Lee Jones [李琼斯]
WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee@kernel.org>
To: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: "Krzysztof Wilczyński" <kw@linux.com>,
linux-fbdev@vger.kernel.org, "Rich Felker" <dalias@libc.org>,
"Herve Codina" <herve.codina@bootlin.com>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
linux-sh@vger.kernel.org, "Bin Meng" <bmeng@tinylab.org>,
"Michael Turquette" <mturquette@baylibre.com>,
linux-pci@vger.kernel.org, "Jacky Huang" <ychuang3@nuvoton.com>,
"Palmer Dabbelt" <palmer@rivosinc.com>,
"Max Filippov" <jcmvbkbc@gmail.com>,
"Guo Ren" <guoren@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Hyeonggon Yoo" <42.hyeyoo@gmail.com>,
"Jiri Slaby" <jirislaby@kernel.org>,
linux-clk@vger.kernel.org,
"Stephen Rothwell" <sfr@canb.auug.org.au>,
"Laurent Pinchart" <laurent.pinchart+renesas@ideasonboard.com>,
"Baoquan He" <bhe@redhat.com>, "Jonathan Corbet" <corbet@lwn.net>,
"Helge Deller" <deller@gmx.de>,
"Daniel Lezcano" <daniel.lezcano@linaro.org>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Javier Martinez Canillas" <javierm@redhat.com>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
linux-serial@vger.kernel.org,
"David Rientjes" <rientjes@google.com>,
"Lukas Bulwahn" <lukas.bulwahn@gmail.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Guenter Roeck" <linux@roeck-us.net>,
devicetree@vger.kernel.org, "Conor Dooley" <conor+dt@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Arnd Bergmann" <arnd@arndb.de>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Maxime Ripard" <mripard@kernel.org>,
"Sam Ravnborg" <sam@ravnborg.org>,
"Rob Herring" <robh+dt@kernel.org>,
dri-devel@lists.freedesktop.org,
"Chris Morgan" <macromorgan@hotmail.com>,
"John Paul Adrian Glaubitz" <glaubitz@physik.fu-berlin.de>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Vlastimil Babka" <vbabka@suse.cz>,
"Sergey Shtylyov" <s.shtylyov@omp.ru>,
linux-ide@vger.kernel.org, "Stephen Boyd" <sboyd@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Biju Das" <biju.das.jz@bp.renesas.com>,
linux-kernel@vger.kernel.org,
"Azeem Shaikh" <azeemshaikh38@gmail.com>,
linux-renesas-soc@vger.kernel.org, "Tom Rix" <trix@redhat.com>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Michael Karcher" <kernel@mkarcher.dialup.fu-berlin.de>,
"Andrew Morton" <akpm@linux-foundation.org>
Subject: Re: [DO NOT MERGE v5 23/37] mfd: sm501: Convert platform_data to OF property
Date: Thu, 7 Dec 2023 16:36:44 +0000 [thread overview]
Message-ID: <20231207163644.GB111411@google.com> (raw)
In-Reply-To: <68532082074b0c8fe9945b481678aab77520f517.1701768028.git.ysato@users.sourceforge.jp>
On Tue, 05 Dec 2023, 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 | 99 +++++++++++++++++++++++++++++++++++
> drivers/video/fbdev/sm501fb.c | 82 +++++++++++++++++++++++++++++
> 2 files changed, 181 insertions(+)
>
> diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
> index 28027982cf69..f0104fdf0f34 100644
> --- a/drivers/mfd/sm501.c
> +++ b/drivers/mfd/sm501.c
> @@ -1370,6 +1370,99 @@ static int sm501_init_dev(struct sm501_devdata *sm)
> return 0;
> }
>
> +static void sm501_of_read_reg_init(struct device_node *np,
> + const char *propname, struct sm501_reg_init *val)
> +{
> + u32 u32_val[2];
Encoding the size of the variable in the variable name is odd.
> +
> + if (!of_property_read_u32_array(np, propname, u32_val, sizeof(u32_val))) {
> + val->set = u32_val[0];
> + val->mask = u32_val[1];
Masks and register values stored as DT properties? This is generally
not permitted. Please seek counsel from the DT maintainers.
> + }
> +}
> +
> +/* Read GPIO I2C configuration */
> +static int sm501_parse_dt_gpio_i2c(struct device *dev, struct sm501_platdata *plat,
> + struct device_node *np)
> +{
> + struct sm501_platdata_gpio_i2c *gpio_i2c_p;
> + struct property *prop;
> + u32 gpio_i2c[5];
Why 5? Please define all magic numbers.
> + const __be32 *p;
> + unsigned int i;
> + u32 i2c_nr;
> +
> + prop = of_find_property(np, "smi,gpio-i2c", NULL);
> + if (!prop)
> + return 0;
> +
> + i2c_nr = of_property_count_u32_elems(np, "smi,gpio-i2c");
Why do you need both of these probing functions? What does
of_property_count_u32_elems() return if smi,gpio-i2c doesn't exist?
> + /* GPIO I2C define 5 words per channel. */
> + if (i2c_nr % 5)
> + return -EINVAL;
> + i2c_nr /= 5;
'\n'
> + plat->gpio_i2c = devm_kzalloc(dev, sizeof(*plat->gpio_i2c) * i2c_nr,
> + GFP_KERNEL);
> + if (!plat->gpio_i2c)
> + return -ENOMEM;
> +
> + plat->gpio_i2c_nr = i2c_nr;
> + gpio_i2c_p = plat->gpio_i2c;
What's the purpose of this intermediary variable?
> +
> + for (; i2c_nr > 0; i2c_nr--) {
You can define 'p' in here, right?
> + for (i = 0; i < ARRAY_SIZE(gpio_i2c); i++) {
> + p = of_prop_next_u32(prop, p, &gpio_i2c[i]);
> + if (!p)
> + return -EINVAL;
> + }
> + gpio_i2c_p->bus_num = gpio_i2c[0];
> + gpio_i2c_p->pin_sda = gpio_i2c[1];
> + gpio_i2c_p->pin_scl = gpio_i2c[2];
> + gpio_i2c_p->udelay = gpio_i2c[3];
> + gpio_i2c_p->timeout = gpio_i2c[4];
I'm not even going to ask. I'll leave this to the DT maintainers.
> + gpio_i2c_p++;
> + }
> + return 0;
> +}
> +
> +/* Build platform_data from OF property */
> +static int sm501_parse_dt(struct sm501_devdata *sm, struct device_node *np)
> +{
> + struct sm501_platdata *plat;
> + u32 u32_val;
> + int ret;
> +
> + plat = devm_kzalloc(sm->dev, sizeof(*plat), GFP_KERNEL);
> + if (!plat)
> + return -ENOMEM;
> +
> + plat->init = devm_kzalloc(sm->dev, sizeof(*plat->init), GFP_KERNEL);
Why not grab all of the memory at once?
Maybe make this 'init' thing a non-pointer.
> + if (!plat->init)
> + return -ENOMEM;
> +
> + if (!of_property_read_u32(np, "smi,devices", &u32_val))
> + plat->init->devices = u32_val;
What happens if you do:
of_property_read_u32(np, "smi,devices", &plat->init->devices);
> + if (!of_property_read_u32(np, "smi,mclk", &u32_val))
> + plat->init->mclk = u32_val;
> + if (!of_property_read_u32(np, "smi,m1xclk", &u32_val))
> + plat->init->m1xclk = u32_val;
> +
> + sm501_of_read_reg_init(np, "smi,misc-timing", &plat->init->misc_timing);
> + sm501_of_read_reg_init(np, "smi,misc-control", &plat->init->misc_control);
> + sm501_of_read_reg_init(np, "smi,gpio-low", &plat->init->gpio_low);
> + sm501_of_read_reg_init(np, "smi,gpio-high", &plat->init->gpio_high);
> +
> + if (IS_ENABLED(CONFIG_MFD_SM501_GPIO) &&
> + (plat->init->devices & SM501_USE_GPIO)) {
That's over-bracketed, right?
plat->init->devices is a bit mask of enable devices stored in DT?
Okay, I think this is going to need a lot of work on the DT side.
Leaving the review here for now.
> + ret = sm501_parse_dt_gpio_i2c(sm->dev, plat, np);
> + if (ret)
> + return ret;
> + }
> + sm->platdata = plat;
> + return 0;
> +}
> +
> static int sm501_plat_probe(struct platform_device *dev)
> {
> struct sm501_devdata *sm;
> @@ -1406,6 +1499,12 @@ static int sm501_plat_probe(struct platform_device *dev)
> goto err_res;
> }
>
> + if (IS_ENABLED(CONFIG_OF) && dev->dev.of_node) {
> + ret = sm501_parse_dt(sm, dev->dev.of_node);
> + if (ret)
> + goto err_res;
> + }
> +
> platform_set_drvdata(dev, sm);
>
> sm->regs = ioremap(sm->io_res->start, resource_size(sm->io_res));
> diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c
> index d6fdc1737cd2..d35285819d28 100644
> --- a/drivers/video/fbdev/sm501fb.c
> +++ b/drivers/video/fbdev/sm501fb.c
> @@ -1932,6 +1932,82 @@ static int sm501fb_start_one(struct sm501fb_info *info,
> return 0;
> }
>
> +#if defined(CONFIG_OF)
> +/* parse CRT / panel configuration */
> +static struct sm501_platdata_fbsub *dt_fbsub(struct device *dev,
> + struct device_node *np,
> + const char *name)
> +{
> + struct sm501_platdata_fbsub *fbsub = NULL;
> + struct fb_videomode *def_mode = NULL;
> + struct device_node *child;
> + const void *p_edid;
> + u32 flags = 0;
> + u32 bpp = 0;
> + int len;
> +
> + child = of_get_child_by_name(np, name);
> + if (child == NULL)
> + return NULL;
> +
> + p_edid = of_get_property(child, "edid", &len);
> + if (p_edid && len == EDID_LENGTH) {
> + struct fb_monspecs *specs;
> + u8 *edid;
> +
> + edid = kmemdup(p_edid, EDID_LENGTH, GFP_KERNEL);
> + if (edid) {
> + specs = kzalloc(sizeof(*specs), GFP_KERNEL);
> + if (specs) {
> + fb_edid_to_monspecs(edid, specs);
> + def_mode = specs->modedb;
> + }
> + }
> + kfree(edid);
> + }
> +
> + of_property_read_u32(child, "bpp", &bpp);
> +
> + /* If flags property is obtained, fbsub is returned. */
> + if (!of_property_read_u32(child, "smi,flags", &flags)) {
> + fbsub = devm_kzalloc(dev, sizeof(*fbsub), GFP_KERNEL);
> + if (fbsub) {
> + fbsub->def_mode = def_mode;
> + fbsub->def_bpp = bpp;
> + fbsub->flags = flags;
> + }
> + }
> + return fbsub;
> +}
> +
> +/* Build platform_data from OF property */
> +static struct sm501_platdata_fb *pdata_from_dt(struct device *dev, struct device_node *np)
> +{
> + enum sm501_fb_routing fb_route = SM501_FB_OWN;
> + struct sm501_platdata_fb *pdata = NULL;
> + struct sm501_platdata_fbsub *fb_crt;
> + struct sm501_platdata_fbsub *fb_pnl;
> + unsigned int flags = 0;
> +
> + if (of_property_read_bool(np, "route-crt-panel"))
> + fb_route = SM501_FB_CRT_PANEL;
> + if (of_property_read_bool(np, "swap-fb-endian"))
> + flags = SM501_FBPD_SWAP_FB_ENDIAN;
> + fb_crt = dt_fbsub(dev, np, "crt");
> + fb_pnl = dt_fbsub(dev, np, "panel");
> + if (fb_crt || fb_pnl) {
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> + if (pdata) {
> + pdata->fb_route = fb_route;
> + pdata->flags = flags;
> + pdata->fb_crt = fb_crt;
> + pdata->fb_pnl = fb_pnl;
> + }
> + }
> + return pdata;
> +}
> +#endif
> +
> static int sm501fb_probe(struct platform_device *pdev)
> {
> struct sm501fb_info *info;
> @@ -1974,6 +2050,12 @@ static int sm501fb_probe(struct platform_device *pdev)
> if (info->edid_data)
> found = 1;
> }
> + /* Get platform data compatible configuration */
> + if (!found) {
> + info->pdata = pdata_from_dt(dev, np);
> + if (info->pdata)
> + found = 1;
> + }
> }
> #endif
> if (!found) {
> --
> 2.39.2
>
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2023-12-07 16:37 UTC|newest]
Thread overview: 122+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-05 9:45 [DO NOT MERGE v5 00/37] Device Tree support for SH7751 based board Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 01/37] sh: passing FDT address to kernel startup Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 02/37] sh: Kconfig unified OF supported targets Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 03/37] sh: Enable OF support for build and configuration Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 04/37] dt-bindings: interrupt-controller: Add header for Renesas SH3/4 INTC Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 16:01 ` Krzysztof Kozlowski
2023-12-05 16:01 ` Krzysztof Kozlowski
2023-12-05 9:45 ` [DO NOT MERGE v5 05/37] sh: GENERIC_IRQ_CHIP support for CONFIG_OF=y Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 06/37] sh: kernel/setup Update DT support Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 13:14 ` Arnd Bergmann
2023-12-05 13:14 ` Arnd Bergmann
2023-12-05 9:45 ` [DO NOT MERGE v5 07/37] sh: Fix COMMON_CLK support in CONFIG_OF=y Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 08/37] clocksource: sh_tmu: CLOCKSOURCE support Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 09/37] dt-bindings: timer: renesas,tmu: add renesas,tmu-sh7750 Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 09/37] dt-bindings: timer: renesas, tmu: add renesas, tmu-sh7750 Yoshinori Sato
2023-12-05 15:29 ` [DO NOT MERGE v5 09/37] dt-bindings: timer: renesas,tmu: add renesas,tmu-sh7750 Geert Uytterhoeven
2023-12-05 15:29 ` [DO NOT MERGE v5 09/37] dt-bindings: timer: renesas, tmu: add renesas, tmu-sh7750 Geert Uytterhoeven
2023-12-05 16:07 ` [DO NOT MERGE v5 09/37] dt-bindings: timer: renesas,tmu: add renesas,tmu-sh7750 Krzysztof Kozlowski
2023-12-05 16:07 ` Krzysztof Kozlowski
2023-12-05 9:45 ` [DO NOT MERGE v5 10/37] sh: Common PCI Framework driver support Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 13:05 ` Arnd Bergmann
2023-12-05 13:05 ` Arnd Bergmann
2023-12-05 9:45 ` [DO NOT MERGE v5 11/37] pci: pci-sh7751: Add SH7751 PCI driver Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 13:26 ` Arnd Bergmann
2023-12-05 13:26 ` Arnd Bergmann
2023-12-05 13:34 ` Geert Uytterhoeven
2023-12-05 13:34 ` Geert Uytterhoeven
2023-12-05 21:48 ` Linus Walleij
2023-12-05 21:48 ` Linus Walleij
2023-12-05 9:45 ` [DO NOT MERGE v5 12/37] dt-bindings: pci: pci-sh7751: Add SH7751 PCI Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 14:14 ` Geert Uytterhoeven
2023-12-05 14:14 ` Geert Uytterhoeven
2023-12-05 9:45 ` [DO NOT MERGE v5 13/37] dt-bindings: clock: sh7750-cpg: Add renesas,sh7750-cpg header Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 13/37] dt-bindings: clock: sh7750-cpg: Add renesas, sh7750-cpg header Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 14/37] clk: Compatible with narrow registers Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 10:10 ` Uwe Kleine-König
2023-12-05 10:10 ` Uwe Kleine-König
2023-12-05 9:45 ` [DO NOT MERGE v5 15/37] clk: renesas: Add SH7750/7751 CPG Driver Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 16/37] irqchip: Add SH7751 INTC driver Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-08 15:49 ` Thomas Gleixner
2023-12-08 15:49 ` Thomas Gleixner
2023-12-05 9:45 ` [DO NOT MERGE v5 17/37] dt-bindings: interrupt-controller: renesas,sh7751-intc: Add json-schema Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 17/37] dt-bindings: interrupt-controller: renesas, sh7751-intc: " Yoshinori Sato
2023-12-05 9:59 ` [DO NOT MERGE v5 17/37] dt-bindings: interrupt-controller: renesas,sh7751-intc: " Linus Walleij
2023-12-05 9:59 ` Linus Walleij
2023-12-05 15:01 ` Geert Uytterhoeven
2023-12-05 15:01 ` Geert Uytterhoeven
2023-12-05 16:04 ` Krzysztof Kozlowski
2023-12-05 16:04 ` Krzysztof Kozlowski
2023-12-05 9:45 ` [DO NOT MERGE v5 18/37] irqchip: SH7751 IRL external encoder with enable gate Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 19/37] dt-bindings: interrupt-controller: renesas,sh7751-irl-ext: Add json-schema Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 19/37] dt-bindings: interrupt-controller: renesas, sh7751-irl-ext: " Yoshinori Sato
2023-12-05 21:01 ` [DO NOT MERGE v5 19/37] dt-bindings: interrupt-controller: renesas,sh7751-irl-ext: " Rob Herring
2023-12-05 21:01 ` Rob Herring
2023-12-05 9:45 ` [DO NOT MERGE v5 20/37] serial: sh-sci: fix SH4 OF support Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 15:27 ` Geert Uytterhoeven
2023-12-05 15:27 ` Geert Uytterhoeven
2023-12-05 9:45 ` [DO NOT MERGE v5 21/37] dt-bindings: serial: renesas,scif: Add scif-sh7751 Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 21/37] dt-bindings: serial: renesas, scif: " Yoshinori Sato
2023-12-05 14:57 ` [DO NOT MERGE v5 21/37] dt-bindings: serial: renesas,scif: " Geert Uytterhoeven
2023-12-05 14:57 ` [DO NOT MERGE v5 21/37] dt-bindings: serial: renesas, scif: " Geert Uytterhoeven
2023-12-05 9:45 ` [DO NOT MERGE v5 22/37] dt-bindings: display: smi,sm501: SMI SM501 binding json-schema Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 22/37] dt-bindings: display: smi, sm501: " Yoshinori Sato
2023-12-05 13:36 ` [DO NOT MERGE v5 22/37] dt-bindings: display: smi,sm501: " Rob Herring
2023-12-05 13:36 ` Rob Herring
2023-12-05 13:36 ` Arnd Bergmann
2023-12-05 13:36 ` [DO NOT MERGE v5 22/37] dt-bindings: display: smi, sm501: " Arnd Bergmann
2023-12-05 15:56 ` [DO NOT MERGE v5 22/37] dt-bindings: display: smi,sm501: " Krzysztof Kozlowski
2023-12-05 15:56 ` Krzysztof Kozlowski
2023-12-05 9:45 ` [DO NOT MERGE v5 23/37] mfd: sm501: Convert platform_data to OF property Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-07 16:36 ` Lee Jones [this message]
2023-12-07 16:36 ` Lee Jones
2023-12-05 9:45 ` [DO NOT MERGE v5 24/37] dt-binding: sh: cpus: Add SH CPUs json-schema Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 15:07 ` Geert Uytterhoeven
2023-12-05 15:07 ` Geert Uytterhoeven
2023-12-05 9:45 ` [DO NOT MERGE v5 25/37] dt-bindings: vendor-prefixes: Add iodata Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 26/37] dt-bindings: vendor-prefixes: Add smi Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 27/37] dt-bindings: ata: ata-generic: Add new targets Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 28/37] dt-bindings: soc: renesas: sh: Add SH7751 based target Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 29/37] sh: SH7751R SoC Internal peripheral definition dtsi Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 30/37] sh: add RTS7751R2D Plus DTS Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 31/37] sh: Add IO DATA LANDISK dts Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 32/37] sh: Add IO DATA USL-5P dts Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 33/37] sh: j2_mimas_v2.dts update Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 34/37] sh: Add dtbs target support Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 35/37] sh: RTS7751R2D Plus OF defconfig Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 13:01 ` Arnd Bergmann
2023-12-05 13:01 ` Arnd Bergmann
2023-12-05 9:45 ` [DO NOT MERGE v5 36/37] sh: LANDISK " Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
2023-12-05 9:45 ` [DO NOT MERGE v5 37/37] sh: j2_defconfig: update Yoshinori Sato
2023-12-05 9:45 ` Yoshinori Sato
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=20231207163644.GB111411@google.com \
--to=lee@kernel.org \
--cc=42.hyeyoo@gmail.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=azeemshaikh38@gmail.com \
--cc=bhe@redhat.com \
--cc=bhelgaas@google.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=bmeng@tinylab.org \
--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@sntech.de \
--cc=herve.codina@bootlin.com \
--cc=javierm@redhat.com \
--cc=jcmvbkbc@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=jirislaby@kernel.org \
--cc=kernel@mkarcher.dialup.fu-berlin.de \
--cc=krzysztof.kozlowski+dt@linaro.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=lukas.bulwahn@gmail.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=macromorgan@hotmail.com \
--cc=magnus.damm@gmail.com \
--cc=mripard@kernel.org \
--cc=mturquette@baylibre.com \
--cc=palmer@rivosinc.com \
--cc=rdunlap@infradead.org \
--cc=rientjes@google.com \
--cc=robh+dt@kernel.org \
--cc=s.shtylyov@omp.ru \
--cc=sam@ravnborg.org \
--cc=sboyd@kernel.org \
--cc=sfr@canb.auug.org.au \
--cc=tglx@linutronix.de \
--cc=trix@redhat.com \
--cc=tzimmermann@suse.de \
--cc=u.kleine-koenig@pengutronix.de \
--cc=vbabka@suse.cz \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.