mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Mason Yang <masonccyang@mxic.com.tw>,
	broonie@kernel.org, marek.vasut@gmail.com,
	linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org,
	bbrezillon@kernel.org, linux-renesas-soc@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com,
	devicetree@vger.kernel.org
Cc: juliensu@mxic.com.tw, Simon Horman <horms@verge.net.au>
Subject: Re: [PATCH v10 1/3] mfd: Add Renesas R-Car Gen3 RPC-IF MFD controller driver
Date: Mon, 15 Apr 2019 22:57:45 +0300	[thread overview]
Message-ID: <935046cc-e2e5-b9b8-0c94-1be5ae604276@cogentembedded.com> (raw)
In-Reply-To: <1555313834-15107-2-git-send-email-masonccyang@mxic.com.tw>

The patch name is somewhat misleading -- there's no "MFD controller".

On 04/15/2019 10:37 AM, Mason Yang wrote:

> Add a driver for Renesas R-Car Gen3 RPC-IF MFD controller.
> 
> Signed-off-by: Mason Yang <masonccyang@mxic.com.tw>
[...]
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 26ad646..7914349 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -978,6 +978,15 @@ config MFD_RDC321X
>  	  southbridge which provides access to GPIOs and Watchdog using the
>  	  southbridge PCI device configuration space.
>  
> +config MFD_RENESAS_RPC
> +	tristate "Renesas R-Car Gen3 RPC-IF MFD driver"
> +	select MFD_CORE
> +	depends on ARCH_RENESAS
> +	help
> +	  This supports for Renesas R-Car Gen3 RPC-IF multifunction device

   "For" node needed here.

> +	  controller which provides either SPI host controller or HyperFlash.
> +	  You have to select individual components under the corresponding menu.
> +
>  config MFD_RT5033
>  	tristate "Richtek RT5033 Power Management IC"
>  	depends on I2C
[...]
> diff --git a/drivers/mfd/renesas-rpc.c b/drivers/mfd/renesas-rpc.c
> new file mode 100644
> index 0000000..a565f31
> --- /dev/null
> +++ b/drivers/mfd/renesas-rpc.c
> @@ -0,0 +1,128 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// Copyright (C) 2018 ~ 2019 Renesas Solutions Corp.
> +// Copyright (C) 2019 Macronix International Co., Ltd.
> +//
> +// R-Car Gen3 RPC-IF MFD driver
> +//
> +// Author:
> +//	Mason Yang <masonccyang@mxic.com.tw>
> +//
> +
> +#include <linux/mfd/renesas-rpc.h>
> +#include <linux/mfd/core.h>
> +
> +static const struct mfd_cell rpc_hf_ctlr = {
> +	.name = "rpc-hf",
> +	.of_compatible = "renesas,rcar-rpc-hf",

   Don't need this line any more...

> +};
> +
> +static const struct mfd_cell rpc_spi_ctlr = {
> +	.name = "rpc-spi",
> +	.of_compatible = "renesas,rcar-rpc-spi",

   ... and this too.

[...]
> +static int rpc_mfd_probe(struct platform_device *pdev)
> +{
> +	struct device_node *flash;
> +	const struct mfd_cell *cell;
> +	struct resource *res;
> +	struct rpc_mfd *rpc;
> +	void __iomem *base;
> +	int ret;
> +
> +	flash = of_get_next_child(pdev->dev.of_node, NULL);
> +	if (!flash) {
> +		dev_warn(&pdev->dev, "no flash node found\n");
> +		return -ENODEV;
> +	}
> +
> +	ret = of_device_is_compatible(flash, "jedec,spi-nor");
> +	if (ret) {
> +		cell = &rpc_spi_ctlr;
> +	} else {
> +		ret = of_device_is_compatible(flash, "cfi-flash");
> +		if (ret) {
> +			cell = &rpc_hf_ctlr;
> +		} else {
> +			dev_warn(&pdev->dev, "no jedec spi/cfi device found\n");
> +			return -ENODEV;
> +		}
> +	}


   This definitely should look simpler, like below:

	if (of_device_is_compatible(flash, "jedec,spi-nor")) {
 		cell = &rpc_spi_ctlr;
	} else if (of_device_is_compatible(flash, "cfi-flash")) {
		cell = &rpc_hf_ctlr;
 	} else {
		dev_warn(&pdev->dev, "unknown flash type\n");
		return -ENODEV;
	}

[...]

> +	ret = devm_mfd_add_devices(&pdev->dev, -1, cell, 1, NULL, 0, NULL);
> +
> +	return ret;

	return devm_mfd_add_devices(&pdev->dev, -1, cell, 1, NULL, 0, NULL);

[...]
> diff --git a/include/linux/mfd/renesas-rpc.h b/include/linux/mfd/renesas-rpc.h
> new file mode 100644
> index 0000000..61ada14
> --- /dev/null
> +++ b/include/linux/mfd/renesas-rpc.h
> @@ -0,0 +1,153 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// Copyright (C) 2018 ~ 2019 Renesas Solutions Corp.
> +// Copyright (C) 2019 Macronix International Co., Ltd.
> +//
> +// R-Car Gen3 RPC-IF MFD driver
> +//
> +// Author:
> +//	Mason Yang <masonccyang@mxic.com.tw>
> +//
> +
> +#ifndef __MFD_RENESAS_RPC_H
> +#define __MFD_RENESAS_RPC_H
> +
> +#include <linux/clk.h>
> +#include <linux/io.h>
> +#include <linux/log2.h>
> +#include <linux/iopoll.h>
> +#include <linux/module.h>
> +#include <linux/mtd/mtd.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/of.h>
> +#include <linux/regmap.h>
> +#include <linux/reset.h>

   NAK. I have already told you that these #include's are only needed in the
drivers, not in this header.

   My idea is to contain all hardware manipulation in the MFD driver,
with SPI/HF drivers calling that code via a set of APIs declared in this header.
The registers (declared below) would end up only needed by that common MFD driver...

[...]

MBR, Sergei

  reply	other threads:[~2019-04-15 19:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-15  7:37 [PATCH v10 0/3] mfd: Add Renesas R-Car Gen3 RPC-IF MFD & SPI driver Mason Yang
2019-04-15  7:37 ` [PATCH v10 1/3] mfd: Add Renesas R-Car Gen3 RPC-IF MFD controller driver Mason Yang
2019-04-15 19:57   ` Sergei Shtylyov [this message]
     [not found]     ` <OF8A9D093C.B3035121-ON482583DE.00065F23-482583DE.00074AC0@mxic.com.tw>
2019-04-16 18:57       ` Sergei Shtylyov
     [not found]         ` <OF2BD84B79.FBC5E822-ON482583DF.0020009F-482583DF.0022E315@mxic.com.tw>
2019-04-17 20:26           ` Sergei Shtylyov
2019-04-15  7:37 ` [PATCH v10 2/3] spi: Add Renesas R-Car Gen3 RPC-IF SPI " Mason Yang
2019-04-16 18:37   ` Sergei Shtylyov
2019-04-15  7:37 ` [PATCH v10 3/3] dt-bindings: mfd: Document Renesas R-Car Gen3 RPC-IF controller bindings Mason Yang
2019-04-15 16:49   ` Sergei Shtylyov
     [not found]     ` <OF2F61A6E6.AA7717A3-ON482583DE.0005C1EE-482583DE.00061474@mxic.com.tw>
2019-04-16  8:02       ` Sergei Shtylyov
     [not found]         ` <OFCBCE0527.706EB4F2-ON482583E0.00200707-482583E0.00208EAD@mxic.com.tw>
2019-04-18 16:55           ` Sergei Shtylyov
2019-04-19 15:44             ` Sergei Shtylyov

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=935046cc-e2e5-b9b8-0c94-1be5ae604276@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=bbrezillon@kernel.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=horms@verge.net.au \
    --cc=juliensu@mxic.com.tw \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=marek.vasut@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=masonccyang@mxic.com.tw \
    --cc=robh+dt@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

all inboxes | Powered by JetHome®