* [PATCH 2/3] spi: mvebu: make sure the value calculated for PSCL is also used
2016-12-08 9:05 [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider Uwe Kleine-König
@ 2016-12-08 9:05 ` Uwe Kleine-König
2016-12-08 9:05 ` [PATCH 3/3] spi: mvebu: various non-critical improvements to armada_370_xp_spi_set_baudrate Uwe Kleine-König
2016-12-12 5:15 ` [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider Sascha Hauer
2 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2016-12-08 9:05 UTC (permalink / raw)
To: barebox
The function used a separate variable to hold the value calculated and
only used it for range checking but then didn't use it.
This fixes calculation for slow baud rate that require a divider > 15.
Additionally fix the rounding.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/spi/mvebu_spi.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/mvebu_spi.c b/drivers/spi/mvebu_spi.c
index d61a545f02d8..319d213872e0 100644
--- a/drivers/spi/mvebu_spi.c
+++ b/drivers/spi/mvebu_spi.c
@@ -135,22 +135,22 @@ static int mvebu_spi_set_baudrate(struct mvebu_spi *p, u32 speed)
#if defined(CONFIG_ARCH_ARMADA_370) || defined(CONFIG_ARCH_ARMADA_XP)
static int armada_370_xp_spi_set_baudrate(struct mvebu_spi *p, u32 speed)
{
- u32 pscl, pdiv, rate, val;
+ u32 pscl, pdiv, val;
/* prescaler values: 1,2,3,...,15 */
pscl = DIV_ROUND_UP(clk_get_rate(p->clk), speed);
/* additional prescaler divider: 1, 2, 4, 8, 16, 32, 64, 128 */
- pdiv = 0; rate = pscl;
- while (rate > 15 && pdiv <= 7) {
- rate /= 2;
+ pdiv = 0;
+ while (pscl > 15 && pdiv <= 7) {
+ pscl = DIV_ROUND_UP(pscl, 2);
pdiv++;
}
dev_dbg(p->master.dev, "%s: clk = %lu, speed = %u, pscl = %d, pdiv = %d\n",
__func__, clk_get_rate(p->clk), speed, pscl, pdiv);
- if (rate > 15 || pdiv > 7)
+ if (pscl > 15 || pdiv > 7)
return -EINVAL;
val = readl(p->base + SPI_IF_CONFIG) & ~(IF_CLK_PRESCALE_MASK);
--
2.10.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] spi: mvebu: various non-critical improvements to armada_370_xp_spi_set_baudrate
2016-12-08 9:05 [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider Uwe Kleine-König
2016-12-08 9:05 ` [PATCH 2/3] spi: mvebu: make sure the value calculated for PSCL is also used Uwe Kleine-König
@ 2016-12-08 9:05 ` Uwe Kleine-König
2016-12-12 5:15 ` [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider Sascha Hauer
2 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2016-12-08 9:05 UTC (permalink / raw)
To: barebox
- Initialize pdiv in declaration
- fix format specifiers
- simplify range check, pdiv can never be > 7
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/spi/mvebu_spi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/mvebu_spi.c b/drivers/spi/mvebu_spi.c
index 319d213872e0..58ac6057afe3 100644
--- a/drivers/spi/mvebu_spi.c
+++ b/drivers/spi/mvebu_spi.c
@@ -135,22 +135,21 @@ static int mvebu_spi_set_baudrate(struct mvebu_spi *p, u32 speed)
#if defined(CONFIG_ARCH_ARMADA_370) || defined(CONFIG_ARCH_ARMADA_XP)
static int armada_370_xp_spi_set_baudrate(struct mvebu_spi *p, u32 speed)
{
- u32 pscl, pdiv, val;
+ u32 pscl, pdiv = 0, val;
/* prescaler values: 1,2,3,...,15 */
pscl = DIV_ROUND_UP(clk_get_rate(p->clk), speed);
/* additional prescaler divider: 1, 2, 4, 8, 16, 32, 64, 128 */
- pdiv = 0;
while (pscl > 15 && pdiv <= 7) {
pscl = DIV_ROUND_UP(pscl, 2);
pdiv++;
}
- dev_dbg(p->master.dev, "%s: clk = %lu, speed = %u, pscl = %d, pdiv = %d\n",
+ dev_dbg(p->master.dev, "%s: clk = %lu, speed = %u, pscl = %u, pdiv = %u\n",
__func__, clk_get_rate(p->clk), speed, pscl, pdiv);
- if (pscl > 15 || pdiv > 7)
+ if (pscl > 15)
return -EINVAL;
val = readl(p->base + SPI_IF_CONFIG) & ~(IF_CLK_PRESCALE_MASK);
--
2.10.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider
2016-12-08 9:05 [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider Uwe Kleine-König
2016-12-08 9:05 ` [PATCH 2/3] spi: mvebu: make sure the value calculated for PSCL is also used Uwe Kleine-König
2016-12-08 9:05 ` [PATCH 3/3] spi: mvebu: various non-critical improvements to armada_370_xp_spi_set_baudrate Uwe Kleine-König
@ 2016-12-12 5:15 ` Sascha Hauer
2017-01-11 16:33 ` Uwe Kleine-König
2 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2016-12-12 5:15 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: barebox
On Thu, Dec 08, 2016 at 10:05:42AM +0100, Uwe Kleine-König wrote:
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/spi/mvebu_spi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/drivers/spi/mvebu_spi.c b/drivers/spi/mvebu_spi.c
> index 887a6a72134c..d61a545f02d8 100644
> --- a/drivers/spi/mvebu_spi.c
> +++ b/drivers/spi/mvebu_spi.c
> @@ -50,8 +50,8 @@
> #define IF_TRANSFER_2BYTE BIT(5)
> #define IF_CLK_PRESCALE_POW2 BIT(4)
> #define IF_CLK_PRESCALE(x) ((x) & 0x0f)
> -#define IF_CLK_PRE_PRESCALE(x) (((((x) & 0xc) << 1) | ((x) & 0x1)) << 4)
> -#define IF_CLK_PRESCALE_MASK (IF_CLK_PRESCALE(7) | IF_CLK_PRE_PRESCALE(7))
> +#define IF_CLK_PRE_PRESCALE(x) (((((x) & 0x6) << 6) | ((x) & 0x1)) << 4)
> +#define IF_CLK_PRESCALE_MASK (IF_CLK_PRESCALE(0xf) | IF_CLK_PRE_PRESCALE(7))
> #define SPI_DATA_OUT 0x08
> #define SPI_DATA_IN 0x0c
> #define SPI_INT_CAUSE 0x10
> --
> 2.10.2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider
2016-12-12 5:15 ` [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider Sascha Hauer
@ 2017-01-11 16:33 ` Uwe Kleine-König
2017-01-12 6:44 ` Sascha Hauer
0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2017-01-11 16:33 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On Mon, Dec 12, 2016 at 06:15:14AM +0100, Sascha Hauer wrote:
> On Thu, Dec 08, 2016 at 10:05:42AM +0100, Uwe Kleine-König wrote:
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> > drivers/spi/mvebu_spi.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Applied, thanks
I cannot find this patch neither in the barebox repo's next branch nor
in its master branch.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider
2017-01-11 16:33 ` Uwe Kleine-König
@ 2017-01-12 6:44 ` Sascha Hauer
0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2017-01-12 6:44 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: barebox
On Wed, Jan 11, 2017 at 05:33:31PM +0100, Uwe Kleine-König wrote:
> On Mon, Dec 12, 2016 at 06:15:14AM +0100, Sascha Hauer wrote:
> > On Thu, Dec 08, 2016 at 10:05:42AM +0100, Uwe Kleine-König wrote:
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > ---
> > > drivers/spi/mvebu_spi.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > Applied, thanks
>
> I cannot find this patch neither in the barebox repo's next branch nor
> in its master branch.
Look again ;)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread