* [U-Boot] [PATCH] spi: kirkwood_spi: implement mvebu_spi_set_mode()
@ 2016-10-14 3:19 Chris Packham
2016-10-18 5:29 ` Stefan Roese
2016-10-26 7:15 ` Jagan Teki
0 siblings, 2 replies; 8+ messages in thread
From: Chris Packham @ 2016-10-14 3:19 UTC (permalink / raw)
To: u-boot
Set the appropriate bits in the interface config register based
on the SPI_ mode flags.
Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
arch/arm/include/asm/arch-mvebu/spi.h | 4 ++++
drivers/spi/kirkwood_spi.c | 13 +++++++++++++
2 files changed, 17 insertions(+)
diff --git a/arch/arm/include/asm/arch-mvebu/spi.h b/arch/arm/include/asm/arch-mvebu/spi.h
index 78869a253d1f..3545aed17347 100644
--- a/arch/arm/include/asm/arch-mvebu/spi.h
+++ b/arch/arm/include/asm/arch-mvebu/spi.h
@@ -52,6 +52,10 @@ struct kwspi_registers {
#define KWSPI_ADRLEN_3BYTE (2 << 8)
#define KWSPI_ADRLEN_4BYTE (3 << 8)
#define KWSPI_ADRLEN_MASK (3 << 8)
+#define KWSPI_CPOL (1 << 11)
+#define KWSPI_CPHA (1 << 12)
+#define KWSPI_TXLSBF (1 << 13)
+#define KWSPI_RXLSBF (1 << 14)
#define KWSPI_IRQUNMASK 1 /* unmask SPI interrupt */
#define KWSPI_IRQMASK 0 /* mask SPI interrupt */
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 6851ba942f51..69a0be9ea5b2 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -271,6 +271,19 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
{
+ struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+ struct kwspi_registers *reg = plat->spireg;
+ u32 data = readl(®->cfg);
+
+ if (mode & SPI_CPHA)
+ data |= KWSPI_CPHA;
+ if (mode & SPI_CPOL)
+ data |= KWSPI_CPOL;
+ if (mode & SPI_LSB_FIRST)
+ data |= (KWSPI_RXLSBF | KWSPI_TXLSBF);
+
+ writel(data, ®->cfg);
+
return 0;
}
--
2.10.0.479.g7c56b16
^ permalink raw reply related [flat|nested] 8+ messages in thread* [U-Boot] [PATCH] spi: kirkwood_spi: implement mvebu_spi_set_mode()
2016-10-14 3:19 [U-Boot] [PATCH] spi: kirkwood_spi: implement mvebu_spi_set_mode() Chris Packham
@ 2016-10-18 5:29 ` Stefan Roese
2016-10-26 7:15 ` Jagan Teki
1 sibling, 0 replies; 8+ messages in thread
From: Stefan Roese @ 2016-10-18 5:29 UTC (permalink / raw)
To: u-boot
On 14.10.2016 05:19, Chris Packham wrote:
> Set the appropriate bits in the interface config register based
> on the SPI_ mode flags.
>
> Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Thanks,
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] spi: kirkwood_spi: implement mvebu_spi_set_mode()
2016-10-14 3:19 [U-Boot] [PATCH] spi: kirkwood_spi: implement mvebu_spi_set_mode() Chris Packham
2016-10-18 5:29 ` Stefan Roese
@ 2016-10-26 7:15 ` Jagan Teki
2016-10-27 8:16 ` [U-Boot] [PATCH v2] " Chris Packham
1 sibling, 1 reply; 8+ messages in thread
From: Jagan Teki @ 2016-10-26 7:15 UTC (permalink / raw)
To: u-boot
On Fri, Oct 14, 2016 at 8:49 AM, Chris Packham <judge.packham@gmail.com> wrote:
> Set the appropriate bits in the interface config register based
> on the SPI_ mode flags.
>
> Signed-off-by: Chris Packham <judge.packham@gmail.com>
> ---
>
> arch/arm/include/asm/arch-mvebu/spi.h | 4 ++++
> drivers/spi/kirkwood_spi.c | 13 +++++++++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/arch/arm/include/asm/arch-mvebu/spi.h b/arch/arm/include/asm/arch-mvebu/spi.h
> index 78869a253d1f..3545aed17347 100644
> --- a/arch/arm/include/asm/arch-mvebu/spi.h
> +++ b/arch/arm/include/asm/arch-mvebu/spi.h
> @@ -52,6 +52,10 @@ struct kwspi_registers {
> #define KWSPI_ADRLEN_3BYTE (2 << 8)
> #define KWSPI_ADRLEN_4BYTE (3 << 8)
> #define KWSPI_ADRLEN_MASK (3 << 8)
> +#define KWSPI_CPOL (1 << 11)
> +#define KWSPI_CPHA (1 << 12)
> +#define KWSPI_TXLSBF (1 << 13)
> +#define KWSPI_RXLSBF (1 << 14)
>
> #define KWSPI_IRQUNMASK 1 /* unmask SPI interrupt */
> #define KWSPI_IRQMASK 0 /* mask SPI interrupt */
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index 6851ba942f51..69a0be9ea5b2 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -271,6 +271,19 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
>
> static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
> {
> + struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
> + struct kwspi_registers *reg = plat->spireg;
> + u32 data = readl(®->cfg);
Better to clear the bits(mask) on data before updating,
thanks!
--
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
^ permalink raw reply [flat|nested] 8+ messages in thread* [U-Boot] [PATCH v2] spi: kirkwood_spi: implement mvebu_spi_set_mode()
2016-10-26 7:15 ` Jagan Teki
@ 2016-10-27 8:16 ` Chris Packham
2016-10-27 9:41 ` Jagan Teki
0 siblings, 1 reply; 8+ messages in thread
From: Chris Packham @ 2016-10-27 8:16 UTC (permalink / raw)
To: u-boot
Set the appropriate bits in the interface config register based
on the SPI_ mode flags.
Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
Changes in v2:
- Clear bits before updating
arch/arm/include/asm/arch-mvebu/spi.h | 4 ++++
drivers/spi/kirkwood_spi.c | 15 +++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/arch/arm/include/asm/arch-mvebu/spi.h b/arch/arm/include/asm/arch-mvebu/spi.h
index 78869a253d1f..3545aed17347 100644
--- a/arch/arm/include/asm/arch-mvebu/spi.h
+++ b/arch/arm/include/asm/arch-mvebu/spi.h
@@ -52,6 +52,10 @@ struct kwspi_registers {
#define KWSPI_ADRLEN_3BYTE (2 << 8)
#define KWSPI_ADRLEN_4BYTE (3 << 8)
#define KWSPI_ADRLEN_MASK (3 << 8)
+#define KWSPI_CPOL (1 << 11)
+#define KWSPI_CPHA (1 << 12)
+#define KWSPI_TXLSBF (1 << 13)
+#define KWSPI_RXLSBF (1 << 14)
#define KWSPI_IRQUNMASK 1 /* unmask SPI interrupt */
#define KWSPI_IRQMASK 0 /* mask SPI interrupt */
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 6851ba942f51..791f3e8099c8 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -271,6 +271,21 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
{
+ struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+ struct kwspi_registers *reg = plat->spireg;
+ u32 data = readl(®->cfg);
+
+ data &= ~(KWSPI_CPHA | KWSPI_CPOL | KWSPI_RXLSBF | KWSPI_TXLSBF);
+
+ if (mode & SPI_CPHA)
+ data |= KWSPI_CPHA;
+ if (mode & SPI_CPOL)
+ data |= KWSPI_CPOL;
+ if (mode & SPI_LSB_FIRST)
+ data |= (KWSPI_RXLSBF | KWSPI_TXLSBF);
+
+ writel(data, ®->cfg);
+
return 0;
}
--
2.10.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [U-Boot] [PATCH v2] spi: kirkwood_spi: implement mvebu_spi_set_mode()
2016-10-27 8:16 ` [U-Boot] [PATCH v2] " Chris Packham
@ 2016-10-27 9:41 ` Jagan Teki
2016-10-27 9:49 ` Chris Packham
0 siblings, 1 reply; 8+ messages in thread
From: Jagan Teki @ 2016-10-27 9:41 UTC (permalink / raw)
To: u-boot
On Thu, Oct 27, 2016 at 1:46 PM, Chris Packham <judge.packham@gmail.com> wrote:
> Set the appropriate bits in the interface config register based
> on the SPI_ mode flags.
>
> Signed-off-by: Chris Packham <judge.packham@gmail.com>
Missed updating Stefan Reviewed-by tag? please check for next time.
> ---
>
> Changes in v2:
> - Clear bits before updating
Applied, thanks!
--
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH v2] spi: kirkwood_spi: implement mvebu_spi_set_mode()
2016-10-27 9:41 ` Jagan Teki
@ 2016-10-27 9:49 ` Chris Packham
2016-10-27 9:51 ` Stefan Roese
0 siblings, 1 reply; 8+ messages in thread
From: Chris Packham @ 2016-10-27 9:49 UTC (permalink / raw)
To: u-boot
On 27/10/2016 10:41 PM, "Jagan Teki" <jagan@openedev.com> wrote:
>
> On Thu, Oct 27, 2016 at 1:46 PM, Chris Packham <judge.packham@gmail.com>
wrote:
> > Set the appropriate bits in the interface config register based
> > on the SPI_ mode flags.
> >
> > Signed-off-by: Chris Packham <judge.packham@gmail.com>
>
> Missed updating Stefan Reviewed-by tag? please check for next time.
That was semi-intentional. I thought v2 was different enough that I didn't
want to assume Stefan's review would carry through.
>
> > ---
> >
> > Changes in v2:
> > - Clear bits before updating
>
> Applied, thanks!
>
> --
> Jagan Teki
> Free Software Engineer | www.openedev.com
> U-Boot, Linux | Upstream Maintainer
> Hyderabad, India.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH v2] spi: kirkwood_spi: implement mvebu_spi_set_mode()
2016-10-27 9:49 ` Chris Packham
@ 2016-10-27 9:51 ` Stefan Roese
2016-10-27 10:09 ` Jagan Teki
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Roese @ 2016-10-27 9:51 UTC (permalink / raw)
To: u-boot
On 27.10.2016 11:49, Chris Packham wrote:
> On 27/10/2016 10:41 PM, "Jagan Teki" <jagan@openedev.com
> <mailto:jagan@openedev.com>> wrote:
>>
>> On Thu, Oct 27, 2016 at 1:46 PM, Chris Packham
> <judge.packham at gmail.com <mailto:judge.packham@gmail.com>> wrote:
>> > Set the appropriate bits in the interface config register based
>> > on the SPI_ mode flags.
>> >
>> > Signed-off-by: Chris Packham <judge.packham@gmail.com
> <mailto:judge.packham@gmail.com>>
>>
>> Missed updating Stefan Reviewed-by tag? please check for next time.
>
> That was semi-intentional. I thought v2 was different enough that I
> didn't want to assume Stefan's review would carry through.
Fair enough. I've overlooked the clearing of the bits spotted by
Jagan. Please add my Reviewed-by now as well.
Thanks,
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH v2] spi: kirkwood_spi: implement mvebu_spi_set_mode()
2016-10-27 9:51 ` Stefan Roese
@ 2016-10-27 10:09 ` Jagan Teki
0 siblings, 0 replies; 8+ messages in thread
From: Jagan Teki @ 2016-10-27 10:09 UTC (permalink / raw)
To: u-boot
On Thu, Oct 27, 2016 at 3:21 PM, Stefan Roese <sr@denx.de> wrote:
> On 27.10.2016 11:49, Chris Packham wrote:
>>
>> On 27/10/2016 10:41 PM, "Jagan Teki" <jagan@openedev.com
>> <mailto:jagan@openedev.com>> wrote:
>>>
>>>
>>> On Thu, Oct 27, 2016 at 1:46 PM, Chris Packham
>>
>> <judge.packham at gmail.com <mailto:judge.packham@gmail.com>> wrote:
>>>
>>> > Set the appropriate bits in the interface config register based
>>> > on the SPI_ mode flags.
>>> >
>>> > Signed-off-by: Chris Packham <judge.packham@gmail.com
>>
>> <mailto:judge.packham@gmail.com>>
>>>
>>>
>>> Missed updating Stefan Reviewed-by tag? please check for next time.
>>
>>
>> That was semi-intentional. I thought v2 was different enough that I
>> didn't want to assume Stefan's review would carry through.
>
>
> Fair enough. I've overlooked the clearing of the bits spotted by
> Jagan. Please add my Reviewed-by now as well.
Yeah, added and applied!
--
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-10-27 10:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-14 3:19 [U-Boot] [PATCH] spi: kirkwood_spi: implement mvebu_spi_set_mode() Chris Packham
2016-10-18 5:29 ` Stefan Roese
2016-10-26 7:15 ` Jagan Teki
2016-10-27 8:16 ` [U-Boot] [PATCH v2] " Chris Packham
2016-10-27 9:41 ` Jagan Teki
2016-10-27 9:49 ` Chris Packham
2016-10-27 9:51 ` Stefan Roese
2016-10-27 10:09 ` Jagan Teki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox