linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Sergey.Semin@baikalelectronics.ru
Cc: Serge Semin <fancer.lancer@gmail.com>,
	Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Paul Burton <paulburton@kernel.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mfd: Add Baikal-T1 Boot Controller driver
Date: Wed, 25 Mar 2020 10:09:40 +0000	[thread overview]
Message-ID: <20200325100940.GI442973@dell> (raw)
In-Reply-To: <20200306130614.696EF8030704@mail.baikalelectronics.ru>

On Fri, 06 Mar 2020, Sergey.Semin@baikalelectronics.ru wrote:

> From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> 
> Baikal-T1 Boot Controller is an IP block embedded into the SoC and
> responsible for the chip proper pre-initialization and further
> booting up from some memory device. From the Linux kernel point of view
> it's just a multi-functional device, which exports three physically mapped
> ROMs and a single SPI controller.
> 
> Primarily the ROMs are intended to be used for transparent access of
> the memory devices with system bootup code. First ROM device is an
> embedded into the SoC firmware, which is supposed to be used just for
> the chip debug and tests. Second ROM device provides a MMIO-based
> access to an external SPI flash. Third ROM mirrors either the Internal
> or SPI ROM region, depending on the state of the external BOOTCFG_{0,1}
> chip pins selecting the system boot device.
> 
> External SPI flash can be also accessed by the DW APB SSI SPI controller
> embedded into the Baikal-T1 Boot Controller. In this case the memory mapped
> SPI flash region shouldn't be accessed.
> 
> Taking into account all the peculiarities described above, we created
> an MFD-based driver for the Baikal-T1 controller. Aside from ordinary
> OF-based sub-device registration it also provides a simple API to
> serialize an access to the external SPI flash from either the MMIO-based
> SPI interface or embedded SPI controller.

Not sure why this is being classified as an MFD.

This is clearly 'just' a memory device.

> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> ---
>  drivers/mfd/Kconfig              |  13 ++
>  drivers/mfd/Makefile             |   1 +
>  drivers/mfd/bt1-boot-ctl.c       | 345 +++++++++++++++++++++++++++++++
>  include/linux/mfd/bt1-boot-ctl.h |  46 +++++
>  4 files changed, 405 insertions(+)
>  create mode 100644 drivers/mfd/bt1-boot-ctl.c
>  create mode 100644 include/linux/mfd/bt1-boot-ctl.h

[...]

> diff --git a/drivers/mfd/bt1-boot-ctl.c b/drivers/mfd/bt1-boot-ctl.c
> new file mode 100644
> index 000000000000..9e3cd47a2e7a
> --- /dev/null
> +++ b/drivers/mfd/bt1-boot-ctl.c
> @@ -0,0 +1,345 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2020 BAIKAL ELECTRONICS, JSC
> + *
> + * Authors:
> + *   Serge Semin <Sergey.Semin@baikalelectronics.ru>
> + *
> + * Baikal-T1 Boot Controller driver.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/types.h>
> +#include <linux/device.h>
> +#include <linux/platform_device.h>
> +#include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/of_platform.h>
> +#include <linux/clk.h>
> +#include <linux/mutex.h>
> +#include <linux/mfd/core.h>

Despite including the MFD API, I don't see it being used at all.

> +#include <linux/mfd/bt1-boot-ctl.h>

[...]

> +static inline u32 bc_read(void __iomem *reg)
> +{
> +	return readl(reg);
> +}
> +
> +static inline void bc_write(void __iomem *reg, u32 data)
> +{
> +	writel(data, reg);
> +}

Abstraction for the sake of abstraction is generally discouraged.

[...]

> +static int bc_register_devices(struct bt1_bc *bc)
> +{
> +	int ret;
> +
> +	ret = devm_of_platform_populate(bc->dev);
> +	if (ret)
> +		dev_err(bc->dev, "Failed to add sub-devices\n");
> +
> +	return ret;
> +}

You can call devm_of_platform_populate() from anywhere.

Doesn't have to be an MFD.

[...]

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2020-03-25 10:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200306130528.9973-1-Sergey.Semin@baikalelectronics.ru>
2020-03-06 13:05 ` [PATCH 1/2] dt-bindings: mfd: Add Baikal-T1 Boot Controller bindings Sergey.Semin
2020-03-09 18:07   ` Rob Herring
     [not found]   ` <20200309180734.A303C80307C7@mail.baikalelectronics.ru>
2020-03-13 15:09     ` Sergey Semin
2020-03-06 13:05 ` [PATCH 2/2] mfd: Add Baikal-T1 Boot Controller driver Sergey.Semin
2020-03-25 10:09   ` Lee Jones [this message]
2020-03-25 16:55     ` Sergey Semin
2020-03-26  9:13       ` Lee Jones
2020-03-26 11:32         ` Sergey Semin
2020-03-27  9:01           ` Lee Jones
2020-03-27 10:25             ` Miquel Raynal
2020-03-27 16:36               ` Sergey Semin
2020-03-27 10:45             ` Sergey Semin
2020-03-10  1:11 ` [PATCH 0/2] mfd: Add Baikal-T1 SoC " Sergey Semin

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=20200325100940.GI442973@dell \
    --to=lee.jones@linaro.org \
    --cc=Alexey.Malahov@baikalelectronics.ru \
    --cc=Sergey.Semin@baikalelectronics.ru \
    --cc=fancer.lancer@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulburton@kernel.org \
    --cc=ralf@linux-mips.org \
    --cc=tsbogend@alpha.franken.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).