From: Miquel Raynal <miquel.raynal@bootlin.com>
To: zhengxunli <zhengxunli@mxic.com.tw>
Cc: juliensu@mxic.com.tw, ycllin@mxic.com.tw, linux-mtd@lists.infradead.org
Subject: Re: [PATCH 3/3] spi: mxic: add maximum speed of spi host
Date: Mon, 1 Feb 2021 16:02:47 +0100 [thread overview]
Message-ID: <20210201160247.1c83719c@xps13> (raw)
In-Reply-To: <1611908018-29937-4-git-send-email-zhengxunli@mxic.com.tw>
Hi,
zhengxunli <zhengxunli@mxic.com.tw> wrote on Fri, 29 Jan 2021 16:13:38
+0800:
> Add the maximum speed of the host to avoid over-speed
> operation of the device.
>
> Signed-off-by: zhengxunli <zhengxunli@mxic.com.tw>
> ---
> Documentation/devicetree/bindings/spi/spi-mxic.txt | 4 ++++
> drivers/spi/spi-mxic.c | 7 +++++++
> 2 files changed, 11 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/spi/spi-mxic.txt b/Documentation/devicetree/bindings/spi/spi-mxic.txt
> index 529f2da..ff6937c 100644
> --- a/Documentation/devicetree/bindings/spi/spi-mxic.txt
> +++ b/Documentation/devicetree/bindings/spi/spi-mxic.txt
Binding and driver changes should be in two separate commits.
> @@ -13,6 +13,9 @@ Required properties:
> - clocks: should contain 3 entries for the "ps_clk", "send_clk" and
> "send_dly_clk" clocks
>
> +Recommended properties:
> +- spi-max-frequency: Maximum SPI clocking speed of the device in Hz.
I don't think this property should be part of the controller binding.
It is a per device property and is already parsed by the core (see
of_spi_parse_dt() in spi.c).
> +
> Example:
>
> spi@43c30000 {
> @@ -21,6 +24,7 @@ Example:
> reg-names = "regs", "dirmap";
> clocks = <&clkwizard 0>, <&clkwizard 1>, <&clkc 18>;
> clock-names = "send_clk", "send_dly_clk", "ps_clk";
> + spi-max-frequency = <200000000>;
> #address-cells = <1>;
> #size-cells = <0>;
>
> diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c
> index 821328a..7786d33 100644
> --- a/drivers/spi/spi-mxic.c
> +++ b/drivers/spi/spi-mxic.c
> @@ -12,6 +12,7 @@
> #include <linux/io.h>
> #include <linux/iopoll.h>
> #include <linux/module.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/pm_runtime.h>
> #include <linux/spi/spi.h>
> @@ -536,7 +537,9 @@ static int mxic_spi_probe(struct platform_device *pdev)
> {
> struct spi_master *master;
> struct resource *res;
> + struct device_node *np = pdev->dev.of_node;
> struct mxic_spi *mxic;
> + u32 max_freq;
> int ret;
>
> master = devm_spi_alloc_master(&pdev->dev, sizeof(struct mxic_spi));
> @@ -580,6 +583,10 @@ static int mxic_spi_probe(struct platform_device *pdev)
> SPI_RX_QUAD | SPI_TX_QUAD |
> SPI_RX_OCTAL | SPI_TX_OCTAL;
>
> + if (of_property_read_u32(np, "spi-max-frequency",
> + &master->max_speed_hz))
> + master->max_speed_hz = 25000000; /* 25MHz */
As said before, there are two limitations to take into account:
1- your controller maximum speed
2- your flash maximum speed
(1) I don't think this needs to be exported through the DT, the driver
knows his own limitations and enforces them.
(2) Should be either advertised by the DT through the spi-max-frequency
property or advertised somehow by the vendor driver (macronix.c).
> +
> mxic_spi_hw_init(mxic);
>
> ret = spi_register_master(master);
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2021-02-01 15:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 8:13 [PATCH 0/3] Add octal DTR support for Macronix flash zhengxunli
2021-01-29 8:13 ` [PATCH 1/3] mtd: spi-nor: macronix: add support for Macronix octaflash zhengxunli
2021-02-01 14:44 ` Miquel Raynal
2021-02-01 15:06 ` Miquel Raynal
2021-02-01 19:55 ` Pratyush Yadav
2021-01-29 8:13 ` [PATCH 2/3] spi: mxic: patch for octal DTR mode support zhengxunli
2021-02-01 14:49 ` Miquel Raynal
2021-02-01 20:10 ` Pratyush Yadav
2021-02-01 21:20 ` Miquel Raynal
[not found] ` <OF6211E4EF.55839180-ON48258670.0011946B-48258670.001EE31F@mxic.com.tw>
2021-02-02 8:06 ` Miquel Raynal
2021-01-29 8:13 ` [PATCH 3/3] spi: mxic: add maximum speed of spi host zhengxunli
2021-02-01 15:02 ` Miquel Raynal [this message]
[not found] ` <OFCBF59ED0.4C198CA3-ON48258670.00236718-48258670.0026E452@mxic.com.tw>
2021-02-02 8:04 ` Miquel Raynal
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=20210201160247.1c83719c@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=juliensu@mxic.com.tw \
--cc=linux-mtd@lists.infradead.org \
--cc=ycllin@mxic.com.tw \
--cc=zhengxunli@mxic.com.tw \
/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.