* [U-Boot-Users] [PATCH v2 2/2] Implement hard SPI driver on MPC8349EMDS
@ 2008-01-17 3:37 Ben Warren
2008-01-17 18:44 ` Kim Phillips
0 siblings, 1 reply; 5+ messages in thread
From: Ben Warren @ 2008-01-17 3:37 UTC (permalink / raw)
To: u-boot
This patch implements the fsl_spi driver on the MPC8349EMDS evaluation board.
This board has an ST M25P40 4Mbit EEPROM on its SPI bus
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
---
board/freescale/mpc8349emds/mpc8349emds.c | 29 +++++++++++++++++++++++++++++
include/configs/MPC8349EMDS.h | 10 ++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/board/freescale/mpc8349emds/mpc8349emds.c b/board/freescale/mpc8349emds/mpc8349emds.c
index 3d72eb7..3fb2a45 100644
--- a/board/freescale/mpc8349emds/mpc8349emds.c
+++ b/board/freescale/mpc8349emds/mpc8349emds.c
@@ -27,6 +27,7 @@
#include <mpc83xx.h>
#include <asm/mpc8349_pci.h>
#include <i2c.h>
+#include <spi.h>
#include <spd.h>
#include <miiphy.h>
#if defined(CONFIG_SPD_EEPROM)
@@ -251,6 +252,34 @@ void sdram_init(void)
}
#endif
+/*
+ * The following are used to control the SPI chip selects for the SPI command.
+ */
+#ifdef CONFIG_HARD_SPI
+
+#define SPI_CS_MASK 0x80000000
+
+void spi_eeprom_chipsel(int cs)
+{
+ volatile gpio83xx_t *iopd = &((immap_t *)CFG_IMMR)->gpio[0];
+
+ if(cs)
+ iopd->dat &= ~SPI_CS_MASK;
+ else
+ iopd->dat |= SPI_CS_MASK;
+}
+
+/*
+ * The SPI command uses this table of functions for controlling the SPI
+ * chip selects.
+ */
+spi_chipsel_type spi_chipsel[] = {
+ spi_eeprom_chipsel,
+};
+int spi_chipsel_cnt = sizeof(spi_chipsel) / sizeof(spi_chipsel[0]);
+
+#endif /* CONFIG_HARD_SPI */
+
#if defined(CONFIG_OF_BOARD_SETUP)
void ft_board_setup(void *blob, bd_t *bd)
{
diff --git a/include/configs/MPC8349EMDS.h b/include/configs/MPC8349EMDS.h
index 437a9a5..584c59d 100644
--- a/include/configs/MPC8349EMDS.h
+++ b/include/configs/MPC8349EMDS.h
@@ -355,6 +355,16 @@
#define CFG_I2C_OFFSET 0x3000
#define CFG_I2C2_OFFSET 0x3100
+/* SPI */
+#define CONFIG_HARD_SPI /* SPI with hardware support*/
+#undef CONFIG_SOFT_SPI /* SPI bit-banged */
+#define CONFIG_FSL_SPI
+
+/* GPIOs. Used as SPI chip selects */
+#define CFG_GPIO1_PRELIM
+#define CFG_GPIO1_DIR 0xC0000000 /* SPI CS on 0, LED on 1 */
+#define CFG_GPIO1_DAT 0xC0000000 /* Both are active LOW */
+
/* TSEC */
#define CFG_TSEC1_OFFSET 0x24000
#define CFG_TSEC1 (CFG_IMMR+CFG_TSEC1_OFFSET)
--
1.5.2.5
^ permalink raw reply related [flat|nested] 5+ messages in thread* [U-Boot-Users] [PATCH v2 2/2] Implement hard SPI driver on MPC8349EMDS
2008-01-17 3:37 [U-Boot-Users] [PATCH v2 2/2] Implement hard SPI driver on MPC8349EMDS Ben Warren
@ 2008-01-17 18:44 ` Kim Phillips
2008-01-17 19:06 ` Ben Warren
0 siblings, 1 reply; 5+ messages in thread
From: Kim Phillips @ 2008-01-17 18:44 UTC (permalink / raw)
To: u-boot
On Wed, 16 Jan 2008 22:37:42 -0500
Ben Warren <biggerbadderben@gmail.com> wrote:
> +void spi_eeprom_chipsel(int cs)
> +{
> + volatile gpio83xx_t *iopd = &((immap_t *)CFG_IMMR)->gpio[0];
> +
> + if(cs)
s/if(/if (/
unless no-one else has any objections, this should probably go in
before the window closes.
Kim
^ permalink raw reply [flat|nested] 5+ messages in thread* [U-Boot-Users] [PATCH v2 2/2] Implement hard SPI driver on MPC8349EMDS
2008-01-17 18:44 ` Kim Phillips
@ 2008-01-17 19:06 ` Ben Warren
2008-01-17 19:28 ` Kim Phillips
0 siblings, 1 reply; 5+ messages in thread
From: Ben Warren @ 2008-01-17 19:06 UTC (permalink / raw)
To: u-boot
Kim Phillips wrote:
> On Wed, 16 Jan 2008 22:37:42 -0500
> Ben Warren <biggerbadderben@gmail.com> wrote:
>
>
>> +void spi_eeprom_chipsel(int cs)
>> +{
>> + volatile gpio83xx_t *iopd = &((immap_t *)CFG_IMMR)->gpio[0];
>> +
>> + if(cs)
>>
>
> s/if(/if (/
>
> unless no-one else has any objections, this should probably go in
> before the window closes.
>
> Kim
>
>
I was just about to respond to your other message to ask if you'd have
time to fit it in. Do you want me to resend patches or can you apply
yourself (since you already have the handy diff). Either way's fine by me.
regards,
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread* [U-Boot-Users] [PATCH v2 2/2] Implement hard SPI driver on MPC8349EMDS
2008-01-17 19:06 ` Ben Warren
@ 2008-01-17 19:28 ` Kim Phillips
2008-01-17 19:35 ` Ben Warren
0 siblings, 1 reply; 5+ messages in thread
From: Kim Phillips @ 2008-01-17 19:28 UTC (permalink / raw)
To: u-boot
On Thu, 17 Jan 2008 14:06:57 -0500
Ben Warren <biggerbadderben@gmail.com> wrote:
> I was just about to respond to your other message to ask if you'd have
> time to fit it in. Do you want me to resend patches or can you apply
> yourself (since you already have the handy diff). Either way's fine by me.
I'm on it.
Kim
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot-Users] [PATCH v2 2/2] Implement hard SPI driver on MPC8349EMDS
2008-01-17 19:28 ` Kim Phillips
@ 2008-01-17 19:35 ` Ben Warren
0 siblings, 0 replies; 5+ messages in thread
From: Ben Warren @ 2008-01-17 19:35 UTC (permalink / raw)
To: u-boot
Kim Phillips wrote:
> On Thu, 17 Jan 2008 14:06:57 -0500
> Ben Warren <biggerbadderben@gmail.com> wrote:
>
>
>> I was just about to respond to your other message to ask if you'd have
>> time to fit it in. Do you want me to resend patches or can you apply
>> yourself (since you already have the handy diff). Either way's fine by me.
>>
>
> I'm on it.
>
> Kim
>
>
Thanks dude.
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-01-17 19:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-17 3:37 [U-Boot-Users] [PATCH v2 2/2] Implement hard SPI driver on MPC8349EMDS Ben Warren
2008-01-17 18:44 ` Kim Phillips
2008-01-17 19:06 ` Ben Warren
2008-01-17 19:28 ` Kim Phillips
2008-01-17 19:35 ` Ben Warren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox