spi: npcm-pspi: improve preformance modify reset and fix issue
Subsystems (3)
Tomer Maimon
maintainercover spi: npcm-pspi: improve preformance modify reset and fix issue
This patch set modify Perphiral SPI NPCM driver as follow:
- Improve transfer performance.
- Fix 16 bit send and receive support.
- Modify dt-binding documentation to support reset controller driver.
- Modify reset support to use reset controller driver NPCM reset driver: https://lkml.org/lkml/2019/11/7/429.
Tomer Maimon (4):
spi: npcm-pspi: fix 16 bit send and receive support
spi: npcm-pspi: improve spi transfer performance
dt-binding: spi: add NPCM PSPI reset binding
spi: npcm-pspi: modify reset support
.../bindings/spi/nuvoton,npcm-pspi.txt | 12 +--- drivers/spi/spi-npcm-pspi.c | 57 +++++++++---------- 2 files changed, 29 insertions(+), 40 deletions(-)
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH 1/4 spi: npcm-pspi: fix 16 bit send and receive support
Fixing NPCM BMC Peripheral SPI controller 16 bit
send and receive support by writing and reading
the SPI data in the right order.
--- drivers/spi/spi-npcm-pspi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/spi/spi-npcm-pspi.c +9 -8
@@ -195,6 +195,7 @@ static void npcm_pspi_setup_transfer(struct spi_device *spi,static void npcm_pspi_send (struct npcm_pspi *priv) {int wsize; +u16 val; wsize =min (bytes_per_word (priv->bits_per_word), priv->tx_bytes); priv->tx_bytes -= wsize;
@@ -204,17 +205,18 @@ static void npcm_pspi_send(struct npcm_pspi *priv)switch (wsize) {case 1 : -iowrite8 (*priv->tx_buf,NPCM_PSPI_DATA + priv->base); + val = *priv->tx_buf++; +iowrite8 (val,NPCM_PSPI_DATA + priv->base);break ;case 2 : -iowrite16 (*priv->tx_buf,NPCM_PSPI_DATA + priv->base); + val = *priv->tx_buf++; + val = *priv->tx_buf++ | (val <<8 ); +iowrite16 (val,NPCM_PSPI_DATA + priv->base);break ;default :WARN_ON_ONCE (1 );return ; } - - priv->tx_buf += wsize; }static void npcm_pspi_recv (struct npcm_pspi *priv)
@@ -230,18 +232,17 @@ static void npcm_pspi_recv(struct npcm_pspi *priv)switch (rsize) {case 1 : - val =ioread8 (priv->base +NPCM_PSPI_DATA ); + *priv->rx_buf++ =ioread8 (priv->base +NPCM_PSPI_DATA );break ;case 2 : val =ioread16 (priv->base +NPCM_PSPI_DATA ); + *priv->rx_buf++ = (val >>8 ); + *priv->rx_buf++ = val &0xff ;break ;default :WARN_ON_ONCE (1 );return ; } - - *priv->rx_buf = val; - priv->rx_buf += rsize; } static int npcm_pspi_transfer_one(struct spi_master *master,
Signature · 1 line
2.22.0
Mark Brown
maintainerApplied "spi: npcm-pspi: fix 16 bit send and receive support" to the spi tree
The patch
spi: npcm-pspi: fix 16 bit send and receive support
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.5
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
47416a5f27be0a0e815ef5f9f2f06618ae5e0470Mon Sep 17 00:00:00 2001
From: Tomer Maimon <[email protected]>
Date: Wed, 15 Jan 2020 18:22:58 +0200
Subject: [PATCH] spi: npcm-pspi: fix 16 bit send and receive support
Fixing NPCM BMC Peripheral SPI controller 16 bit
send and receive support by writing and reading
the SPI data in the right order.
--- drivers/spi/spi-npcm-pspi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/spi/spi-npcm-pspi.c +9 -8
@@ -195,6 +195,7 @@ static void npcm_pspi_setup_transfer(struct spi_device *spi,static void npcm_pspi_send (struct npcm_pspi *priv) {int wsize; +u16 val; wsize =min (bytes_per_word (priv->bits_per_word), priv->tx_bytes); priv->tx_bytes -= wsize;
@@ -204,17 +205,18 @@ static void npcm_pspi_send(struct npcm_pspi *priv)switch (wsize) {case 1 : -iowrite8 (*priv->tx_buf,NPCM_PSPI_DATA + priv->base); + val = *priv->tx_buf++; +iowrite8 (val,NPCM_PSPI_DATA + priv->base);break ;case 2 : -iowrite16 (*priv->tx_buf,NPCM_PSPI_DATA + priv->base); + val = *priv->tx_buf++; + val = *priv->tx_buf++ | (val <<8 ); +iowrite16 (val,NPCM_PSPI_DATA + priv->base);break ;default :WARN_ON_ONCE (1 );return ; } - - priv->tx_buf += wsize; }static void npcm_pspi_recv (struct npcm_pspi *priv)
@@ -230,18 +232,17 @@ static void npcm_pspi_recv(struct npcm_pspi *priv)switch (rsize) {case 1 : - val =ioread8 (priv->base +NPCM_PSPI_DATA ); + *priv->rx_buf++ =ioread8 (priv->base +NPCM_PSPI_DATA );break ;case 2 : val =ioread16 (priv->base +NPCM_PSPI_DATA ); + *priv->rx_buf++ = (val >>8 ); + *priv->rx_buf++ = val &0xff ;break ;default :WARN_ON_ONCE (1 );return ; } - - *priv->rx_buf = val; - priv->rx_buf += rsize; } static int npcm_pspi_transfer_one(struct spi_master *master,
Signature · 1 line
2.20.1
Tomer Maimon
maintainerPATCH 2/4 spi: npcm-pspi: improve spi transfer performance
In reply to Tomer MaimonImproving spi 8 bit per word mode transfer performance by using 16 bit per word transfer and receive when the data length is even and larger than one.
--- drivers/spi/spi-npcm-pspi.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/spi/spi-npcm-pspi.c +7 -0
@@ -178,6 +178,13 @@ static void npcm_pspi_setup_transfer(struct spi_device *spi, priv->mode = spi->mode; } +/* +* If transfer is even length, and 8 bits per word transfer, +* then implement 16 bits-per-word transfer. +*/ +if (priv->bits_per_word ==8 && !(t->len &0x1 )) + t->bits_per_word =16 ; +if (!priv->is_save_param || priv->bits_per_word != t->bits_per_word) {npcm_pspi_set_transfer_size (priv, t->bits_per_word); priv->bits_per_word = t->bits_per_word;
Signature · 1 line
2.22.0
Mark Brown
maintainerApplied "spi: npcm-pspi: improve spi transfer performance" to the spi tree
The patch
spi: npcm-pspi: improve spi transfer performance
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.6
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
b4adf5b27d59cdefff1e6fcba99151edea65a9f7Mon Sep 17 00:00:00 2001
From: Tomer Maimon <[email protected]>
Date: Wed, 15 Jan 2020 18:22:59 +0200
Subject: [PATCH] spi: npcm-pspi: improve spi transfer performance
Improving spi 8 bit per word mode transfer performance by using 16 bit per word transfer and receive when the data length is even and larger than one.
--- drivers/spi/spi-npcm-pspi.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/spi/spi-npcm-pspi.c +7 -0
@@ -178,6 +178,13 @@ static void npcm_pspi_setup_transfer(struct spi_device *spi, priv->mode = spi->mode; } +/* +* If transfer is even length, and 8 bits per word transfer, +* then implement 16 bits-per-word transfer. +*/ +if (priv->bits_per_word ==8 && !(t->len &0x1 )) + t->bits_per_word =16 ; +if (!priv->is_save_param || priv->bits_per_word != t->bits_per_word) {npcm_pspi_set_transfer_size (priv, t->bits_per_word); priv->bits_per_word = t->bits_per_word;
Signature · 1 line
2.20.1
Tomer Maimon
maintainerPATCH 3/4 dt-binding: spi: add NPCM PSPI reset binding
In reply to Tomer MaimonAdd NPCM Peripheral SPI reset binding documentation, Removing unnecessary aliases use.
--- .../devicetree/bindings/spi/nuvoton,npcm-pspi.txt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/spi/nuvoton,npcm-pspi.txt +2 -10
@@ -12,6 +12,7 @@ Required properties: - clock-names: Should be "clk_apb5". - pinctrl-names : a pinctrl state named "default" must be defined. - pinctrl-0 : phandle referencing pin configuration of the device. + - resets : phandle to the reset control for this device. - cs-gpios: Specifies the gpio pins to be used for chipselects. See: Documentation/devicetree/bindings/spi/spi-bus.txt
@@ -19,16 +20,6 @@ Optional properties: - clock-frequency : Input clock frequency to the PSPI block in Hz. Default is 25000000 Hz. -Aliases: -- All the SPI controller nodes should be represented in the aliases node using - the following format 'spi{n}' withe the correct numbered in "aliases" node. - -Example: - -aliases { - spi0 = &spi0; -}; - spi0: spi@f0200000 { compatible = "nuvoton,npcm750-pspi"; reg = <0xf0200000 0x1000>;
@@ -39,5 +30,6 @@ spi0: spi@f0200000 { interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clk NPCM7XX_CLK_APB5>; clock-names = "clk_apb5"; + resets = <&rstc NPCM7XX_RESET_IPSRST2 NPCM7XX_RESET_PSPI1> cs-gpios = <&gpio6 11 GPIO_ACTIVE_LOW>; };
Signature · 1 line
2.22.0
Re: [PATCH v1 3/4] dt-binding: spi: add NPCM PSPI reset binding
Quoted 8 lines · Tomer Maimon
Add NPCM Peripheral SPI reset binding documentation, Removing unnecessary aliases use.
Signed-off-by Tomer Maimon <[email protected]>--- .../devicetree/bindings/spi/nuvoton,npcm-pspi.txt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
Mark Brown
maintainerApplied "dt-binding: spi: add NPCM PSPI reset binding" to the spi tree
In reply to Tomer MaimonThe patch
dt-binding: spi: add NPCM PSPI reset binding
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.6
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
a5362b84bdff1def10c136e36ef2126f7f545b2cMon Sep 17 00:00:00 2001
From: Tomer Maimon <[email protected]>
Date: Wed, 15 Jan 2020 18:23:00 +0200
Subject: [PATCH] dt-binding: spi: add NPCM PSPI reset binding
Add NPCM Peripheral SPI reset binding documentation, Removing unnecessary aliases use.
--- .../devicetree/bindings/spi/nuvoton,npcm-pspi.txt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/spi/nuvoton,npcm-pspi.txt +2 -10
@@ -12,6 +12,7 @@ Required properties: - clock-names: Should be "clk_apb5". - pinctrl-names : a pinctrl state named "default" must be defined. - pinctrl-0 : phandle referencing pin configuration of the device. + - resets : phandle to the reset control for this device. - cs-gpios: Specifies the gpio pins to be used for chipselects. See: Documentation/devicetree/bindings/spi/spi-bus.txt
@@ -19,16 +20,6 @@ Optional properties: - clock-frequency : Input clock frequency to the PSPI block in Hz. Default is 25000000 Hz. -Aliases: -- All the SPI controller nodes should be represented in the aliases node using - the following format 'spi{n}' withe the correct numbered in "aliases" node. - -Example: - -aliases { - spi0 = &spi0; -}; - spi0: spi@f0200000 { compatible = "nuvoton,npcm750-pspi"; reg = <0xf0200000 0x1000>;
@@ -39,5 +30,6 @@ spi0: spi@f0200000 { interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clk NPCM7XX_CLK_APB5>; clock-names = "clk_apb5"; + resets = <&rstc NPCM7XX_RESET_IPSRST2 NPCM7XX_RESET_PSPI1> cs-gpios = <&gpio6 11 GPIO_ACTIVE_LOW>; };
Signature · 1 line
2.20.1
Tomer Maimon
maintainerPATCH 4/4 spi: npcm-pspi: modify reset support
In reply to Tomer MaimonModify NPCM perphiral SPI reset support from direct register access to reset controller support.
--- drivers/spi/spi-npcm-pspi.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-)
drivers/spi/spi-npcm-pspi.c +11 -22
@@ -12,6 +12,7 @@#include <linux/spi/spi.h> #include <linux/gpio.h> #include <linux/of_gpio.h> +#include <linux/reset.h> #include <asm/unaligned.h>
@@ -20,7 +21,7 @@struct npcm_pspi {struct completion xfer_done; -struct regmap *rst_regmap; +struct reset_control *reset;struct spi_master *master;unsigned int tx_bytes;unsigned int rx_bytes;
@@ -59,12 +60,6 @@ struct npcm_pspi {#define NPCM_PSPI_MIN_CLK_DIVIDER 4#define NPCM_PSPI_DEFAULT_CLK 25000000 -/* reset register */ -#define NPCM7XX_IPSRST2_OFFSET 0x24 - -#define NPCM7XX_PSPI1_RESET BIT(22) -#define NPCM7XX_PSPI2_RESET BIT(23) -static inline unsigned int bytes_per_word (unsigned int bits) {return bits <=8 ?1 :2 ;
@@ -293,9 +288,9 @@ static int npcm_pspi_unprepare_transfer_hardware(struct spi_master *master)static void npcm_pspi_reset_hw (struct npcm_pspi *priv) { -regmap_write (priv->rst_regmap,NPCM7XX_IPSRST2_OFFSET , -NPCM7XX_PSPI1_RESET << priv->id); -regmap_write (priv->rst_regmap,NPCM7XX_IPSRST2_OFFSET ,0x0 ); +reset_control_assert (priv->reset); +udelay (5 ); +reset_control_deassert (priv->reset); }static irqreturn_t npcm_pspi_handler (int irq,void *dev_id)
@@ -359,10 +354,6 @@ static int npcm_pspi_probe(struct platform_device *pdev)if (num_cs <0 )return num_cs; - pdev->id =of_alias_get_id (np,"spi" ); -if (pdev->id <0 ) - pdev->id =0 ; - master =spi_alloc_master (&pdev->dev,sizeof (*priv));if (!master)return -ENOMEM ;
@@ -372,7 +363,6 @@ static int npcm_pspi_probe(struct platform_device *pdev) priv =spi_master_get_devdata (master); priv->master = master; priv->is_save_param = false; - priv->id = pdev->id; priv->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (priv->base)) {
@@ -397,11 +387,10 @@ static int npcm_pspi_probe(struct platform_device *pdev) goto out_disable_clk; } - priv->rst_regmap = -syscon_regmap_lookup_by_compatible ("nuvoton,npcm750-rst" ); -if (IS_ERR (priv->rst_regmap)) { -dev_err (&pdev->dev,"failed to find nuvoton,npcm750-rst\n" ); -return PTR_ERR (priv->rst_regmap); + priv->reset =devm_reset_control_get (&pdev->dev,NULL ); +if (IS_ERR (priv->reset)) { + ret =PTR_ERR (priv->reset); + goto out_disable_clk; }/* reset SPI-HW block */
@@ -422,7 +411,7 @@ static int npcm_pspi_probe(struct platform_device *pdev) master->min_speed_hz =DIV_ROUND_UP (clk_hz,NPCM_PSPI_MAX_CLK_DIVIDER ); master->mode_bits =SPI_CPHA |SPI_CPOL ; master->dev.of_node = pdev->dev.of_node; - master->bus_num = pdev->id; + master->bus_num =-1 ; master->bits_per_word_mask =SPI_BPW_MASK (8 ) |SPI_BPW_MASK (16 ); master->transfer_one = npcm_pspi_transfer_one; master->prepare_transfer_hardware =
@@ -455,7 +444,7 @@ static int npcm_pspi_probe(struct platform_device *pdev)if (ret) goto out_disable_clk; -pr_info ("NPCM Peripheral SPI %d probed\n" , pdev->id); +pr_info ("NPCM Peripheral SPI %d probed\n" , master->bus_num);return 0 ;
Signature · 1 line
2.22.0
Mark Brown
maintainerApplied "spi: npcm-pspi: modify reset support" to the spi tree
The patch
spi: npcm-pspi: modify reset support
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.6
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
b5df0b2ee2ee6b5bdeb55d76c17f695a1aa5388fMon Sep 17 00:00:00 2001
From: Tomer Maimon <[email protected]>
Date: Wed, 15 Jan 2020 18:23:01 +0200
Subject: [PATCH] spi: npcm-pspi: modify reset support
Modify NPCM perphiral SPI reset support from direct register access to reset controller support.
--- drivers/spi/spi-npcm-pspi.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-)
drivers/spi/spi-npcm-pspi.c +11 -22
@@ -12,6 +12,7 @@#include <linux/spi/spi.h> #include <linux/gpio.h> #include <linux/of_gpio.h> +#include <linux/reset.h> #include <asm/unaligned.h>
@@ -20,7 +21,7 @@struct npcm_pspi {struct completion xfer_done; -struct regmap *rst_regmap; +struct reset_control *reset;struct spi_master *master;unsigned int tx_bytes;unsigned int rx_bytes;
@@ -59,12 +60,6 @@ struct npcm_pspi {#define NPCM_PSPI_MIN_CLK_DIVIDER 4#define NPCM_PSPI_DEFAULT_CLK 25000000 -/* reset register */ -#define NPCM7XX_IPSRST2_OFFSET 0x24 - -#define NPCM7XX_PSPI1_RESET BIT(22) -#define NPCM7XX_PSPI2_RESET BIT(23) -static inline unsigned int bytes_per_word (unsigned int bits) {return bits <=8 ?1 :2 ;
@@ -292,9 +287,9 @@ static int npcm_pspi_unprepare_transfer_hardware(struct spi_master *master)static void npcm_pspi_reset_hw (struct npcm_pspi *priv) { -regmap_write (priv->rst_regmap,NPCM7XX_IPSRST2_OFFSET , -NPCM7XX_PSPI1_RESET << priv->id); -regmap_write (priv->rst_regmap,NPCM7XX_IPSRST2_OFFSET ,0x0 ); +reset_control_assert (priv->reset); +udelay (5 ); +reset_control_deassert (priv->reset); }static irqreturn_t npcm_pspi_handler (int irq,void *dev_id)
@@ -358,10 +353,6 @@ static int npcm_pspi_probe(struct platform_device *pdev)if (num_cs <0 )return num_cs; - pdev->id =of_alias_get_id (np,"spi" ); -if (pdev->id <0 ) - pdev->id =0 ; - master =spi_alloc_master (&pdev->dev,sizeof (*priv));if (!master)return -ENOMEM ;
@@ -371,7 +362,6 @@ static int npcm_pspi_probe(struct platform_device *pdev) priv =spi_master_get_devdata (master); priv->master = master; priv->is_save_param = false; - priv->id = pdev->id; priv->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (priv->base)) {
@@ -396,11 +386,10 @@ static int npcm_pspi_probe(struct platform_device *pdev) goto out_disable_clk; } - priv->rst_regmap = -syscon_regmap_lookup_by_compatible ("nuvoton,npcm750-rst" ); -if (IS_ERR (priv->rst_regmap)) { -dev_err (&pdev->dev,"failed to find nuvoton,npcm750-rst\n" ); -return PTR_ERR (priv->rst_regmap); + priv->reset =devm_reset_control_get (&pdev->dev,NULL ); +if (IS_ERR (priv->reset)) { + ret =PTR_ERR (priv->reset); + goto out_disable_clk; }/* reset SPI-HW block */
@@ -421,7 +410,7 @@ static int npcm_pspi_probe(struct platform_device *pdev) master->min_speed_hz =DIV_ROUND_UP (clk_hz,NPCM_PSPI_MAX_CLK_DIVIDER ); master->mode_bits =SPI_CPHA |SPI_CPOL ; master->dev.of_node = pdev->dev.of_node; - master->bus_num = pdev->id; + master->bus_num =-1 ; master->bits_per_word_mask =SPI_BPW_MASK (8 ) |SPI_BPW_MASK (16 ); master->transfer_one = npcm_pspi_transfer_one; master->prepare_transfer_hardware =
@@ -454,7 +443,7 @@ static int npcm_pspi_probe(struct platform_device *pdev)if (ret) goto out_disable_clk; -pr_info ("NPCM Peripheral SPI %d probed\n" , pdev->id); +pr_info ("NPCM Peripheral SPI %d probed\n" , master->bus_num);return 0 ;
Signature · 1 line
2.20.1