Add support for a Freescale non-CPM SPI controller
PATCH 1/2 Add support for a Freescale non-CPM SPI controller
This patch adds support for the SPI controller found on Freescale PowerPC processors such as the MCP834x family. Additionally, a new config option, CONFIG_HARD_SPI, is added for general purpose SPI controller use.
--- Makefile | 2 + README | 8 +++ drivers/spi/Makefile | 46 ++++++++++++++ drivers/spi/fsl_spi.c | 140 ++++++++++++++++++++++++++++++++++++++++++ include/asm-ppc/immap_83xx.h | 14 ++++- lib_ppc/board.c | 16 +++++ 6 files changed, 225 insertions(+), 1 deletions(-) create mode 100644 drivers/spi/Makefile create mode 100644 drivers/spi/fsl_spi.c
Makefile +2 -0
@@ -230,6 +230,7 @@ LIBS += drivers/net/libnet.a LIBS += drivers/net/sk98lin/libsk98lin.a LIBS += drivers/pci/libpci.a LIBS += drivers/pcmcia/libpcmcia.a +LIBS += drivers/spi/libspi.a ifeq ($(CPU),mpc83xx) LIBS += drivers/qe/qe.a endif
@@ -378,6 +379,7 @@ TAG_SUBDIRS += drivers/pcmcia TAG_SUBDIRS += drivers/qe TAG_SUBDIRS += drivers/rtc TAG_SUBDIRS += drivers/serial +TAG_SUBDIRS += drivers/spi TAG_SUBDIRS += drivers/usb TAG_SUBDIRS += drivers/video
README +8 -0
@@ -1377,6 +1377,14 @@ The following options need to be configured: SPI configuration items (port pins to use, etc). For an example, see include/configs/sacsng.h. + CONFIG_HARD_SPI + + Enables a hardware SPI driver for general-purpose reads + and writes. As with CONFIG_SOFT_SPI, the board configuration + must define a list of chip-select function pointers. + Currently supported on MPC834x only. For an example, + see include/configs/mpc8349emds.h. + - FPGA Support: CONFIG_FPGA Enables FPGA subsystem.
drivers/spi/Makefile new file +46 -0
46 lines not on this page · raw message
drivers/spi/fsl_spi.c new file +140 -0
140 lines not on this page · raw message
include/asm-ppc/immap_83xx.h +13 -1
@@ -397,6 +397,18 @@ typedef struct spi83xx {u8 res1[0xFD8 ]; } spi83xx_t; +typedef struct spi834x +{ +u8 res0[0x20 ];/* 0x0-0x01f reserved */ +u32 mode;/* mode register */ +u32 event;/* event register */ +u32 mask;/* mask register */ +u32 com;/* command register */ +u32 tx;/* transmit register */ +u32 rx;/* receive register */ +u8 res1[0xC8 ];/* fill up to 0x100 */ + }spi834x_t ; +/* * DMA/Messaging Unit */
@@ -627,7 +639,7 @@ typedef struct immap {u8 res3[0x900 ];lbus83xx_t lbus;/* Local Bus Controller Registers */ u8 res4[0x1000 ]; -spi83xx_t spi;/* Serial Peripheral Interface */ +spi834x_t spi;/* Serial Peripheral Interface */ dma83xx_t dma;/* DMA */ pciconf83xx_t pci_conf[2 ];/* PCI Software Configuration Registers */ ios83xx_t ios;/* Sequencer */
lib_ppc/board.c +16 -0
@@ -87,6 +87,9 @@ void doc_init (void); defined(CONFIG_SOFT_I2C)#include <i2c.h> #endif +#if defined(CONFIG_HARD_SPI ) +#include <spi.h> +#endif #if defined(CONFIG_CMD_NAND )void nand_init (void );#endif
@@ -247,6 +250,16 @@ static int init_func_i2c (void) }#endif +#if defined(CONFIG_HARD_SPI ) +static int init_func_spi (void ) +{ +puts ("SPI: " ); +spi_init (); +puts ("ready\n" ); +return (0 ); +} +#endif +/***********************************************************************/ #if defined(CONFIG_WATCHDOG )
@@ -329,6 +342,9 @@ init_fnc_t *init_sequence[] = {#if defined(CONFIG_HARD_I2C ) || defined(CONFIG_SOFT_I2C ) init_func_i2c,#endif +#if defined(CONFIG_HARD_SPI ) + init_func_spi, +#endif #if defined(CONFIG_DTT )/* Digital Thermometers and Thermostats */ dtt_init,#endif
Signature · 1 line
1.5.2.5
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
Quoted 5 lines · Ben Warren
This patch adds support for the SPI controller found on Freescale PowerPC
processors such as the MCP834x family. Additionally, a new config option,CONFIG_HARD_SPI, is added for general purpose SPI controller use.
Ben, Could you make the SPI drivers more generic/reuseable? IIRC, the 85xx part has the same SPI controller.
[snip]
drivers/spi/fsl_spi.c line 26
Quoted 3 lines
drivers/spi/fsl_spi.c new file +3
-0+#include <common.h> +#include <spi.h> +#include <asm/immap_83xx.h>
Could you use the fsl_spi.h head? not 83xx..
[snip]
Quoted 10 lines
include/asm- renamed from include/asm-ppc/immap_83xx.h +0
-0
ppc/immap_83xx.h
index 34ea295..07ff400 100644include/asm-ppc/immap_83xx.h +1
-0@@ -397,6 +397,18 @@ typedef struct spi83xx {u8 res1[0xFD8 ]; } spi83xx_t; +typedef struct spi834x
include/asm-ppc/immap_83xx.h typedef struct spi83xx { · line 410
Quoted 10 lines
include/asm-ppc/immap_83xx.h +10
-0+{ +u8 res0[0x20 ];/* 0x0-0x01f reserved */ +u32 mode;/* mode register */ +u32 event;/* event register */ +u32 mask;/* mask register */ +u32 com;/* command register */ +u32 tx;/* transmit register */ +u32 rx;/* receive register */ +u8 res1[0xC8 ];/* fill up to 0x100 */ + } spi834x_t;
please put this into fsl_spi.h to reuse for different 8xxx family.
Thanks,
Dave
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
Quoted 9 lines · Dave Liu
Quoted 6 lines · Ben Warren
This patch adds support for the SPI controller found on Freescale PowerPC
processors such as the MCP834x family. Additionally, a new config option,CONFIG_HARD_SPI, is added for general purpose SPI controller use.
Quoted 4 lines
Ben, Could you make the SPI drivers more generic/reuseable? IIRC, the 85xx part has the same SPI controller.
Sure. I don't have nearly the insight into the various Freescale products that you and your colleagues do.
Quoted 10 lines
[snip]
drivers/spi/fsl_spi.c line 26
Quoted 4 lines
drivers/spi/fsl_spi.c new file +3
-0+#include <common.h> +#include <spi.h> +#include <asm/immap_83xx.h> Could you use the
fsl_spi.hhead? not 83xx..
If the memory map is reused identically, then yes.
Quoted 12 lines
[snip]
Quoted 9 lines
include/asm- renamed from include/asm-ppc/immap_83xx.h +0
-0
ppc/immap_83xx.h
index 34ea295..07ff400 100644include/asm-ppc/immap_83xx.h +0
-0@@ -397,6 +397,18 @@ typedef struct spi83xx {u8 res1[0xFD8 ]; } spi83xx_t;
Quoted 15 lines
include/asm-ppc/immap_83xx.h typedef struct spi83xx {
Quoted 12 lines
include/asm-ppc/immap_83xx.h +11
-0+typedef struct spi834x +{ +u8 res0[0x20 ];/* 0x0-0x01f reserved */ +u32 mode;/* mode register */ +u32 event;/* event register */ +u32 mask;/* mask register */ +u32 com;/* command register */ +u32 tx;/* transmit register */ +u32 rx;/* receive register */ +u8 res1[0xC8 ];/* fill up to 0x100 */ + }spi834x_t ;please put this into
fsl_spi.hto reuse for different 8xxx family.
Can you confirm that the registers in 85xx are the same? If so, I'll move this.
Quoted 5 lines
Thanks,
Dave
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
include/asm-ppc/immap_83xx.h +6
-0+typedef struct spi834x +{ + u8 res0[0x20]; /* 0x0-0x01f reserved */ + u32 mode; /* mode register */ + u32 event; /* event register */ + u32 mask; /* mask register */Quoted 9 lines
include/asm-ppc/immap_83xx.h typedef struct spi83xx { · line 410
Quoted 6 lines
include/asm-ppc/immap_83xx.h +5
-0+u32 com;/* command register */ +u32 tx;/* transmit register */ +u32 rx;/* receive register */ +u8 res1[0xC8 ];/* fill up to 0x100 */ + } spi834x_t;please put this into
fsl_spi.hto reuse for different 8xxx family.
Quoted 2 lines
Can you confirm that the registers in 85xx are the same? If so, I'll move this.
Ben, at lease the 8610 has the same SPI as 834x.
The 8360 and 8568 with CPU mode have likely SPI as 834x.
Dave
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
Quoted 16 lines · Liu Dave
Quoted 16 lines
Quoted 16 lines
include/asm-ppc/immap_83xx.h typedef struct spi83xx { · line 410
Quoted 13 lines
include/asm-ppc/immap_83xx.h +11
-0+typedef struct spi834x +{ +u8 res0[0x20 ];/* 0x0-0x01f reserved */ +u32 mode;/* mode register */ +u32 event;/* event register */ +u32 mask;/* mask register */ +u32 com;/* command register */ +u32 tx;/* transmit register */ +u32 rx;/* receive register */ +u8 res1[0xC8 ];/* fill up to 0x100 */ + }spi834x_t ;please put this into
fsl_spi.hto reuse for different 8xxx family.
Quoted 8 lines
Quoted 3 lines
Can you confirm that the registers in 85xx are the same? If so, I'll move this.
Ben, at lease the 8610 has the same SPI as 834x.
The 8360 and 8568 with CPU mode have likely SPI as 834x.
I just looked up the RM for 8360, and for some reason its register offsets are a *bit* different than the 8349. I'll move this struct to fsl_spi.h, but we'll have to do some #ifdef magic to work with multiple processors, I guess.
regards,
Ben
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
In reply to Liu DaveQuoted 20 lines · Liu Dave
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
include/asm-ppc/immap_83xx.h +6
-0+typedef struct spi834x +{ + u8 res0[0x20]; /* 0x0-0x01f reserved */ + u32 mode; /* mode register */ + u32 event; /* event register */ + u32 mask; /* mask register */Quoted 10 lines
include/asm-ppc/immap_83xx.h typedef struct spi83xx { · line 410
Quoted 7 lines
include/asm-ppc/immap_83xx.h +5
-0+u32 com;/* command register */ +u32 tx;/* transmit register */ +u32 rx;/* receive register */ +u8 res1[0xC8 ];/* fill up to 0x100 */ + } spi834x_t;please put this into
fsl_spi.hto reuse for different 8xxx family.Quoted 3 lines
Can you confirm that the registers in 85xx are the same? If so, I'll move this.
Quoted 7 lines
Ben, at lease the 8610 has the same SPI as 834x.
The 8360 and 8568 with CPU mode have likely SPI as 834x.
Dave
I don't have access to 8313 or 8610 reference manuals. Can you please verify the memory map of these two for me. I've verified that 8315 is identical.
regards,
Ben
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
Quoted 3 lines
I don't have access to 8313 or 8610 reference manuals. Can you please verify the memory map of these two for me. I've verified that 8315 is identical.
8313/8315/834x/8610 have same SPI.
Dave
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
Quoted 10 lines · Liu Dave
Quoted 4 lines
I don't have access to 8313 or 8610 reference manuals. Can you please verify the memory map of these two for me. I've verified that 8315 is identical.
8313/8315/834x/8610 have same SPI.
Dave
Cool. Thanks.
Ben
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
In reply to Liu DaveQuoted 10 lines · Liu Dave
Quoted 4 lines
I don't have access to 8313 or 8610 reference manuals. Can you please verify the memory map of these two for me. I've verified that 8315 is identical.
8313/8315/834x/8610 have same SPI.
Dave
asm/immap_86xx.h doesn't have SPI registers listed in the memory map, so support for 8610 will have to wait.
I've incorporated your change requests and will see if there's any more feedback on Monday before reposting the patches.
regards,
Ben
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
Quoted 2 lines
Quoted 2 lines
8313/8315/834x/8610 have same SPI.
and 837x
Quoted 7 lines
asm/immap_86xx.hdoesn't have SPI registers listed in the memory map, so
support for 8610 will have to wait.I've incorporated your change requests and will see if there's any more
feedback on Monday before reposting the patches.
Ok, also, I want to heard some feedback from other people.
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
In reply to Dave LiuQuoted 2 lines · In message <[email protected]> you wrote:
please put this into
fsl_spi.hto reuse for different 8xxx family.
fsl_spi.h might be a bit too general? How about non-8xxx Freescale processors?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Status quo. Latin for "the mess we're in."
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
Quoted 9 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:
please put this into
fsl_spi.hto reuse for different 8xxx family.
fsl_spi.hmight be a bit too general? How about non-8xxx Freescale processors?
f
The naming convention was modeled after 'fsl_i2c', which surely isn't universal to all Freescale I2C controllers either. In Linux, this driver is called 'mpc83xx', which we've learned here is a bit too specialized. I'll happily change the name, but don't know what that should be.
regards,
Ben
PATCH 1/2 Add support for a Freescale non-CPM SPIcontroller
Quoted 9 lines
Quoted 4 lines
fsl_spi.hmight be a bit too general? How about non-8xxx Freescale processors?
fThe naming convention was modeled after '
fsl_i2c', which surely isn't universal to all Freescale I2C controllers either. In Linux, this driver is called 'mpc83xx', which we've learned here is a bit too specialized. I'll happily change the name, but don't know what that should be.
also, I have no idea for this name, how about the mpc8xxx_spi.c[h]?
Best Regards,
Dave