From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH v2 6/7] spi: implement rescan
Date: Thu, 9 Mar 2023 14:03:55 +0100 [thread overview]
Message-ID: <e7cc2c3b-20ac-1f73-7893-d0e9fb7a8cff@pengutronix.de> (raw)
In-Reply-To: <20230309115208.973893-7-s.hauer@pengutronix.de>
On 09.03.23 12:52, Sascha Hauer wrote:
> Implement rescan to register and probe newly added devices via device
> tree overlays.
>
> While this is easy to do at SPI core level this is not the whole truth.
> Many SPI controllers do not use their native chipselects for the SPI
> devices, but GPIOs instead. These currently won't be rescanned when new
> devices are added, so the chipselects for the new devices must be be
> present in the base device tree already. You have been warned.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/spi/spi.c | 23 +++++++++++++++++++++--
> 1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 3684647f6e..ee467d055b 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -29,6 +29,7 @@ struct boardinfo {
> };
>
> static LIST_HEAD(board_list);
> +static LIST_HEAD(spi_controller_list);
>
> /**
> * spi_new_device - instantiate one new SPI device
> @@ -120,6 +121,12 @@ static void spi_of_register_slaves(struct spi_controller *ctrl)
> for_each_available_child_of_node(node, n) {
> struct spi_board_info chip = {};
>
> + if (n->dev) {
> + dev_dbg(ctrl->dev, "of_i2c: skipping already registered %s\n",
> + dev_name(n->dev));
s/of_i2c/of_spi/
> + continue;
> + }
> +
> chip.name = xstrdup(n->name);
> chip.bus_num = ctrl->bus_num;
> /* Mode (clock phase/polarity/etc.) */
> @@ -142,6 +149,17 @@ static void spi_of_register_slaves(struct spi_controller *ctrl)
> }
> }
>
> +static void spi_controller_rescan(struct device *dev)
> +{
> + struct spi_controller *ctrl;
> +
> + list_for_each_entry(ctrl, &spi_controller_list, list) {
> + if (ctrl->dev != dev)
> + continue;
> + spi_of_register_slaves(ctrl);
> + }
> +}
> +
> /**
> * spi_register_board_info - register SPI devices for a given board
> * @info: array of chip descriptors
> @@ -196,8 +214,6 @@ static void scan_boardinfo(struct spi_controller *ctrl)
> }
> }
>
> -static LIST_HEAD(spi_controller_list);
> -
> static int spi_controller_check_ops(struct spi_controller *ctlr)
> {
> /*
> @@ -274,6 +290,9 @@ int spi_register_controller(struct spi_controller *ctrl)
> scan_boardinfo(ctrl);
> status = 0;
>
> + if (!ctrl->dev->rescan)
> + ctrl->dev->rescan = spi_controller_rescan;
> +
> return status;
> }
> EXPORT_SYMBOL(spi_register_controller);
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2023-03-09 13:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 11:52 [PATCH v2 0/7] support overlays to the barebox live tree Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 1/7] kbuild: Add target to build dtb overlay files Sascha Hauer
2023-03-09 13:24 ` Ahmad Fatoum
2023-03-09 15:28 ` Sascha Hauer
2023-03-09 15:33 ` Ahmad Fatoum
2023-03-09 15:35 ` Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 2/7] driver: Add rescan hook to struct device Sascha Hauer
2023-03-09 12:54 ` Ahmad Fatoum
2023-03-09 13:39 ` Ahmad Fatoum
2023-03-09 13:08 ` Ahmad Fatoum
2023-03-09 15:41 ` Sascha Hauer
2023-03-10 8:37 ` Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 3/7] i2c: implement rescan Sascha Hauer
2023-03-09 13:02 ` Ahmad Fatoum
2023-03-09 15:54 ` Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 4/7] spi: Directly register SPI device Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 5/7] spi: reduce scope of 'chip' Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 6/7] spi: implement rescan Sascha Hauer
2023-03-09 13:03 ` Ahmad Fatoum [this message]
2023-03-09 11:52 ` [PATCH v2 7/7] of_overlay: Add option to apply overlay to live tree Sascha Hauer
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=e7cc2c3b-20ac-1f73-7893-d0e9fb7a8cff@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.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