spi_mpc8xxx: Add support for DMA transfers
cover spi_mpc8xxx: Add support for DMA transfers
Hello Kumar,
There are Acks from Greg KH and David Brownell to pass the whole patchset via PowerPC tree. Can you please apply it?
Thanks,
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
PATCH 1/8 powerpc/cpm: Remove SPI defines and spi structs
When cpm2.h included into spi_mpc8xxx driver, the SPI defines in the header conflict with defines in the driver.
We don't need them in the header file, so remove them. Plus remove "struct spi", we'll use a better version in the driver.
--- arch/powerpc/include/asm/cpm1.h | 45 --------------------------------------- arch/powerpc/include/asm/cpm2.h | 39 --------------------------------- 2 files changed, 0 insertions(+), 84 deletions(-)
arch/powerpc/include/asm/cpm1.h +0 -45
@@ -478,51 +478,6 @@ typedef struct iic {char res2[2 ];/* Reserved */ } iic_t; -/* SPI parameter RAM. -*/ -typedef struct spi { -ushort spi_rbase;/* Rx Buffer descriptor base address */ -ushort spi_tbase;/* Tx Buffer descriptor base address */ -u_char spi_rfcr;/* Rx function code */ -u_char spi_tfcr;/* Tx function code */ -ushort spi_mrblr;/* Max receive buffer length */ -uint spi_rstate;/* Internal */ -uint spi_rdp;/* Internal */ -ushort spi_rbptr;/* Internal */ -ushort spi_rbc;/* Internal */ -uint spi_rxtmp;/* Internal */ -uint spi_tstate;/* Internal */ -uint spi_tdp;/* Internal */ -ushort spi_tbptr;/* Internal */ -ushort spi_tbc;/* Internal */ -uint spi_txtmp;/* Internal */ -uint spi_res; -ushort spi_rpbase;/* Relocation pointer */ -ushort spi_res2; -}spi_t ; - -/* SPI Mode register. -*/ -#define SPMODE_LOOP ((ushort)0x4000)/* Loopback */ -#define SPMODE_CI ((ushort)0x2000)/* Clock Invert */ -#define SPMODE_CP ((ushort)0x1000)/* Clock Phase */ -#define SPMODE_DIV16 ((ushort)0x0800)/* BRG/16 mode */ -#define SPMODE_REV ((ushort)0x0400)/* Reversed Data */ -#define SPMODE_MSTR ((ushort)0x0200)/* SPI Master */ -#define SPMODE_EN ((ushort)0x0100)/* Enable */ -#define SPMODE_LENMSK ((ushort)0x00f0)/* character length */ -#define SPMODE_LEN4 ((ushort)0x0030)/* 4 bits per char */ -#define SPMODE_LEN8 ((ushort)0x0070)/* 8 bits per char */ -#define SPMODE_LEN16 ((ushort)0x00f0)/* 16 bits per char */ -#define SPMODE_PMMSK ((ushort)0x000f)/* prescale modulus */ - -/* SPIE fields */ -#define SPIE_MME 0x20 -#define SPIE_TXE 0x10 -#define SPIE_BSY 0x04 -#define SPIE_TXB 0x02 -#define SPIE_RXB 0x01 -/* * RISC Controller Configuration Register definitons */
arch/powerpc/include/asm/cpm2.h +0 -39
@@ -654,45 +654,6 @@ typedef struct iic {uint iic_txtmp;/* Internal */ } iic_t; -/* SPI parameter RAM. -*/ -typedef struct spi { -ushort spi_rbase;/* Rx Buffer descriptor base address */ -ushort spi_tbase;/* Tx Buffer descriptor base address */ -u_char spi_rfcr;/* Rx function code */ -u_char spi_tfcr;/* Tx function code */ -ushort spi_mrblr;/* Max receive buffer length */ -uint spi_rstate;/* Internal */ -uint spi_rdp;/* Internal */ -ushort spi_rbptr;/* Internal */ -ushort spi_rbc;/* Internal */ -uint spi_rxtmp;/* Internal */ -uint spi_tstate;/* Internal */ -uint spi_tdp;/* Internal */ -ushort spi_tbptr;/* Internal */ -ushort spi_tbc;/* Internal */ -uint spi_txtmp;/* Internal */ -uint spi_res;/* Tx temp. */ -uint spi_res1[4 ];/* SDMA temp. */ -}spi_t ; - -/* SPI Mode register. -*/ -#define SPMODE_LOOP ((ushort)0x4000)/* Loopback */ -#define SPMODE_CI ((ushort)0x2000)/* Clock Invert */ -#define SPMODE_CP ((ushort)0x1000)/* Clock Phase */ -#define SPMODE_DIV16 ((ushort)0x0800)/* BRG/16 mode */ -#define SPMODE_REV ((ushort)0x0400)/* Reversed Data */ -#define SPMODE_MSTR ((ushort)0x0200)/* SPI Master */ -#define SPMODE_EN ((ushort)0x0100)/* Enable */ -#define SPMODE_LENMSK ((ushort)0x00f0)/* character length */ -#define SPMODE_PMMSK ((ushort)0x000f)/* prescale modulus */ - -#define SPMODE_LEN (x) ((((x)-1)&0xF)<<4) -#define SPMODE_PM (x) ((x) &0xF) - -#define SPI_EB ((u_char)0x10)/* big endian byte order */ -/* IDMA parameter RAM */ typedef struct idma {
Signature · 1 line
1.6.3.3
Kumar Gala
AppliedRe: [PATCH 1/8] powerpc/cpm: Remove SPI defines and spi structs
Quoted 6 lines · Anton Vorontsov
When
cpm2.hincluded intospi_mpc8xxxdriver, the SPI defines in the header conflict with defines in the driver.We don't need them in the header file, so remove them. Plus remove "struct spi", we'll use a better version in the driver.
Quoted 7 lines
Signed-off-by Anton Vorontsov <[email protected]>---
arch/powerpc/include/asm/cpm1.h| 45
---------------------------------------arch/powerpc/include/asm/cpm2.h| 39
---------------------------------2 files changed, 0 insertions(+), 84 deletions(-)
applied to next
- k
PATCH 2/8 powerpc/qe&cpm2: Avoid redefinitions in CPM2 and QE headers
In reply to Anton Vorontsovstruct mcc defined in both immap_qe.h and immap_cpm2.h, so they will conflic when included in a single file. The mcc struct is easy to deal with, since it isn't used in any driver (yet), so let's just rename QE version to qe_mcc.
The ucb_ctlr is a bit trickier, since it is used by fsl_qe_udc driver, and the driver supports both CPM and QE UDCs, plus the QE version is used to form a bigger immap struct.
I don't want to touch too much of USB code in this series, so for now let's just copy most generic version into the common cpm.h header, later we'll create cpm_usb.h where we'll place common USB structs that are used by QE/CPM UDC and QE Host drivers (FHCI).
And as for the structs in qe.h and cpm2.h, just prefix them with qe_ and cpm_.
--- arch/powerpc/include/asm/cpm.h | 22 ++++++++++++++++++++++ arch/powerpc/include/asm/immap_cpm2.h | 2 +- arch/powerpc/include/asm/immap_qe.h | 8 ++++---- 3 files changed, 27 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/cpm.h +22 -0
@@ -5,6 +5,28 @@#include <linux/types.h> #include <linux/of.h> +/* +* USB Controller pram common to QE and CPM. +*/ +struct usb_ctlr { +u8 usb_usmod; +u8 usb_usadr; +u8 usb_uscom; +u8 res1[1 ]; +__be16 usb_usep[4 ]; +u8 res2[4 ]; +__be16 usb_usber; +u8 res3[2 ]; +__be16 usb_usbmr; +u8 res4[1 ]; +u8 usb_usbs; +/* Fields down below are QE-only */ +__be16 usb_ussft; +u8 res5[2 ]; +__be16 usb_usfrn; +u8 res6[0x22 ]; +} __attribute__ ((packed)); +/* Opcodes common to CPM1 and CPM2 */ #define CPM_CR_INIT_TRX ((ushort)0x0000)
arch/powerpc/include/asm/immap_cpm2.h +1 -1
@@ -549,7 +549,7 @@ typedef struct comm_proc {/* USB Controller. */ -typedef struct usb_ctlr { +typedef struct cpm_usb_ctlr { u8 usb_usmod; u8 usb_usadr; u8 usb_uscom;
arch/powerpc/include/asm/immap_qe.h +4 -4
@@ -210,7 +210,7 @@ struct sir { } __attribute__ ((packed));/* USB Controller */ -struct usb_ctlr { +struct qe_usb_ctlr {u8 usb_usmod;u8 usb_usadr;u8 usb_uscom;
@@ -229,7 +229,7 @@ struct usb_ctlr { } __attribute__ ((packed));/* MCC */ -struct mcc { +struct qe_mcc {__be32 mcce;/* MCC event register */ __be32 mccm;/* MCC mask register */ __be32 mccf;/* MCC configuration register */
@@ -431,9 +431,9 @@ struct qe_immap {struct qe_mux qmx;/* QE Multiplexer */ struct qe_timers qet;/* QE Timers */ struct spi spi[0x2 ];/* spi */ -struct mcc mcc;/* mcc */ +struct qe_mcc mcc;/* mcc */ struct qe_brg brg;/* brg */ -struct usb_ctlr usb;/* USB */ +struct qe_usb_ctlr usb;/* USB */ struct si1 si1;/* SI */ u8 res11[0x800 ];struct sir sir;/* SI Routing Tables */
Signature · 1 line
1.6.3.3
Kumar Gala
AppliedRe: [PATCH 2/8] powerpc/qe&cpm2: Avoid redefinitions in CPM2 and QE headers
Quoted 17 lines · Anton Vorontsov
struct mcc defined in both
immap_qe.handimmap_cpm2.h, so they will conflic when included in a single file. The mcc struct is easy to deal with, since it isn't used in any driver (yet), so let's just rename QE version toqe_mcc.The
ucb_ctlris a bit trickier, since it is used byfsl_qe_udcdriver, and the driver supports both CPM and QE UDCs, plus the QE version is used to form a bigger immap struct.I don't want to touch too much of USB code in this series, so for now let's just copy most generic version into the common
cpm.hheader, later we'll createcpm_usb.hwhere we'll place common USB structs that are used by QE/CPM UDC and QE Host drivers (FHCI).And as for the structs in
qe.handcpm2.h, just prefix them withqe_andcpm_.
Quoted 6 lines
Signed-off-by Anton Vorontsov <[email protected]>---
arch/powerpc/include/asm/cpm.h | 22 ++++++++++++++++++++++ arch/powerpc/include/asm/immap_cpm2.h | 2 +- arch/powerpc/include/asm/immap_qe.h | 8 ++++---- 3 files changed, 27 insertions(+), 5 deletions(-)
applied to next
- k
PATCH 3/8 powerpc/cpm: Move CPMFCR_* defines into cpm.h
In reply to Anton VorontsovThe bits are generic to CPM devices, so let's move them to the common header file, so drivers won't need to privately reintroduce another bunch of the same bits (as we can't include cpm2.h header together with cpm1.h).
--- arch/powerpc/include/asm/cpm.h | 16 ++++++++++++++++ arch/powerpc/include/asm/cpm2.h | 8 -------- 2 files changed, 16 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/cpm.h +16 -0
@@ -27,6 +27,22 @@ struct usb_ctlr {u8 res6[0x22 ]; } __attribute__ ((packed)); +/* +* Function code bits, usually generic to devices. +*/ +#ifdef CONFIG_CPM1 +#define CPMFCR_GBL ((u_char)0x00)/* Flag doesn't exist in CPM1 */ +#define CPMFCR_TC2 ((u_char)0x00)/* Flag doesn't exist in CPM1 */ +#define CPMFCR_DTB ((u_char)0x00)/* Flag doesn't exist in CPM1 */ +#define CPMFCR_BDB ((u_char)0x00)/* Flag doesn't exist in CPM1 */ +#else +#define CPMFCR_GBL ((u_char)0x20)/* Set memory snooping */ +#define CPMFCR_TC2 ((u_char)0x04)/* Transfer code 2 value */ +#define CPMFCR_DTB ((u_char)0x02)/* Use local bus for data when set */ +#define CPMFCR_BDB ((u_char)0x01)/* Use local bus for BD when set */ +#endif +#define CPMFCR_EB ((u_char)0x10)/* Set big endian byte order */ +/* Opcodes common to CPM1 and CPM2 */ #define CPM_CR_INIT_TRX ((ushort)0x0000)
arch/powerpc/include/asm/cpm2.h +0 -8
@@ -124,14 +124,6 @@ static inline void cpm2_fastbrg(uint brg, uint rate, int div16)__cpm2_setbrg (brg, rate,CPM2_BRG_INT_CLK , div16,CPM_BRG_EXTC_INT ); } -/* Function code bits, usually generic to devices. -*/ -#define CPMFCR_GBL ((u_char)0x20)/* Set memory snooping */ -#define CPMFCR_EB ((u_char)0x10)/* Set big endian byte order */ -#define CPMFCR_TC2 ((u_char)0x04)/* Transfer code 2 value */ -#define CPMFCR_DTB ((u_char)0x02)/* Use local bus for data when set */ -#define CPMFCR_BDB ((u_char)0x01)/* Use local bus for BD when set */ -/* Parameter RAM offsets from the base. */ #define PROFF_SCC1 ((uint)0x8000)
Signature · 9 lines
1.6.3.3 ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference
Kumar Gala
AppliedRe: [PATCH 3/8] powerpc/cpm: Move CPMFCR_* defines into cpm.h
Quoted 10 lines · Anton Vorontsov
The bits are generic to CPM devices, so let's move them to the common header file, so drivers won't need to privately reintroduce another bunch of the same bits (as we can't include
cpm2.hheader together withcpm1.h).Signed-off-by Anton Vorontsov <[email protected]>---
arch/powerpc/include/asm/cpm.h| 16 ++++++++++++++++arch/powerpc/include/asm/cpm2.h| 8 --------2 files changed, 16 insertions(+), 8 deletions(-)
applied to next
- k
PATCH 4/8 powerpc/qe&cpm: Implement static inline stubs for non-QE/CPM builds
In reply to Anton VorontsovThis is needed to avoid ugly #ifdefs in drivers. Also update fsl_qe_udc driver so that now it doesn't define its own versions that cause build breakage when the generic stubs are used.
--- arch/powerpc/include/asm/cpm.h | 44 +++++++++++++++++++++++++++++++++++++++ arch/powerpc/include/asm/qe.h | 11 ++++++++- drivers/usb/gadget/fsl_qe_udc.h | 15 ------------- 3 files changed, 54 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/cpm.h +44 -0
@@ -3,6 +3,7 @@#include <linux/compiler.h> #include <linux/types.h> +#include <linux/errno.h> #include <linux/of.h> /*
@@ -131,13 +132,56 @@ typedef struct cpm_buf_desc {#define BD_I2C_START (0x0400)int cpm_muram_init (void ); + +#if defined(CONFIG_CPM ) || defined(CONFIG_QUICC_ENGINE )unsigned long cpm_muram_alloc (unsigned long size,unsigned long align);int cpm_muram_free (unsigned long offset);unsigned long cpm_muram_alloc_fixed (unsigned long offset,unsigned long size);void __iomem *cpm_muram_addr (unsigned long offset);unsigned long cpm_muram_offset (void __iomem *addr);dma_addr_t cpm_muram_dma (void __iomem *addr); +#else +static inline unsigned long cpm_muram_alloc (unsigned long size, +unsigned long align) +{ +return -ENOSYS ; +} + +static inline int cpm_muram_free (unsigned long offset) +{ +return -ENOSYS ; +} + +static inline unsigned long cpm_muram_alloc_fixed (unsigned long offset, +unsigned long size) +{ +return -ENOSYS ; +} + +static inline void __iomem *cpm_muram_addr (unsigned long offset) +{ +return NULL ; +} + +static inline unsigned long cpm_muram_offset (void __iomem *addr) +{ +return -ENOSYS ; +} + +static inline dma_addr_t cpm_muram_dma (void __iomem *addr) +{ +return 0 ; +} +#endif /* defined(CONFIG_CPM) || defined(CONFIG_QUICC_ENGINE) */ + +#ifdef CONFIG_CPM int cpm_command (u32 command,u8 opcode); +#else +static inline int cpm_command (u32 command,u8 opcode) +{ +return -ENOSYS ; +} +#endif /* CONFIG_CPM */ int cpm2_gpiochip_add32 (struct device_node *np);
arch/powerpc/include/asm/qe.h +10 -1
@@ -145,8 +145,17 @@ static inline void qe_pin_set_gpio(struct qe_pin *qe_pin) {}static inline void qe_pin_set_dedicated (struct qe_pin *pin) {}#endif /* CONFIG_QE_GPIO */ -/* QE internal API */ +#ifdef CONFIG_QUICC_ENGINE int qe_issue_cmd (u32 cmd,u32 device,u8 mcn_protocol,u32 cmd_input); +#else +static inline int qe_issue_cmd (u32 cmd,u32 device,u8 mcn_protocol, +u32 cmd_input) +{ +return -ENOSYS ; +} +#endif /* CONFIG_QUICC_ENGINE */ + +/* QE internal API */ enum qe_clock qe_clock_source (const char *source);unsigned int qe_get_brg_clk (void );int qe_setbrg (enum qe_clock brg,unsigned int rate,unsigned int multiplier);
drivers/usb/gadget/fsl_qe_udc.h +0 -15
@@ -419,19 +419,4 @@ struct qe_udc {#define CPM_USB_RESTART_TX_OPCODE 0x0b#define CPM_USB_EP_SHIFT 5 -#ifndef CONFIG_CPM -inline int cpm_command (u32 command,u8 opcode) -{ -return -EOPNOTSUPP ; -} -#endif - -#ifndef CONFIG_QUICC_ENGINE -inline int qe_issue_cmd (u32 cmd,u32 device,u8 mcn_protocol, -u32 cmd_input) -{ -return -EOPNOTSUPP ; -} -#endif -#endif /* __FSL_QE_UDC_H */
Signature · 9 lines
1.6.3.3 ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference
Kumar Gala
AppliedRe: [PATCH 4/8] powerpc/qe&cpm: Implement static inline stubs for non-QE/CPM builds
Quoted 4 lines · Anton Vorontsov
This is needed to avoid ugly #ifdefs in drivers. Also update
fsl_qe_udcdriver so that now it doesn't define its own versions that cause build breakage when the generic stubs are used.
Quoted 8 lines
Signed-off-by Anton Vorontsov <[email protected]>---
arch/powerpc/include/asm/cpm.h| 44 ++++++++++++++++++++++++++++++
+++++++++arch/powerpc/include/asm/qe.h | 11 ++++++++- drivers/usb/gadget/fsl_qe_udc.h | 15 ------------- 3 files changed, 54 insertions(+), 16 deletions(-)
applied to next
- k
PATCH 5/8 spi_mpc8xxx: Fix uninitialized variable
In reply to Anton VorontsovThis patch fixes the following warning:
CC drivers/spi/spi_mpc8xxx.o
spi_mpc8xxx.c: In function 'of_mpc8xxx_spi_probe':
spi_mpc8xxx.c:681: warning: 'ret' may be used uninitialized in this function
--- drivers/spi/spi_mpc8xxx.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/spi/spi_mpc8xxx.c +1 -0
@@ -709,6 +709,7 @@ static int of_mpc8xxx_spi_get_chipselects(struct device *dev) gpio =of_get_gpio_flags (np, i, &flags);if (!gpio_is_valid (gpio)) {dev_err (dev,"invalid gpio #%d: %d\n" , i, gpio); + ret = gpio; goto err_loop; }
Signature · 9 lines
1.6.3.3 ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference
Kumar Gala
AppliedRe: [PATCH 5/8] spi_mpc8xxx: Fix uninitialized variable
Quoted 7 lines · Anton Vorontsov
This patch fixes the following warning:
CC
drivers/spi/spi_mpc8xxx.o
spi_mpc8xxx.c: In function 'of_mpc8xxx_spi_probe':
spi_mpc8xxx.c:681: warning: 'ret' may be used uninitialized in this
function
Quoted 5 lines
Signed-off-by Anton Vorontsov <[email protected]>Acked-by David Brownell <[email protected]>---
drivers/spi/spi_mpc8xxx.c| 1 +1 files changed, 1 insertions(+), 0 deletions(-)
applied to next
- k
PATCH 6/8 spi_mpc8xxx: Factor out SPI mode change steps into a call
In reply to Anton VorontsovWe'll add more steps soon, so get rid of the duplication.
--- drivers/spi/spi_mpc8xxx.c | 56 +++++++++++++++++++------------------------- 1 files changed, 24 insertions(+), 32 deletions(-)
drivers/spi/spi_mpc8xxx.c +24 -32
@@ -155,6 +155,26 @@ MPC83XX_SPI_TX_BUF(u8)MPC83XX_SPI_TX_BUF (u16)MPC83XX_SPI_TX_BUF (u32) +static void mpc8xxx_spi_change_mode(struct spi_device *spi) +{ +struct mpc8xxx_spi *mspi =spi_master_get_devdata (spi->master); +struct spi_mpc8xxx_cs *cs = spi->controller_state; +__be32 __iomem *mode = &mspi->base->mode; +unsigned long flags; + + if (cs->hw_mode == mpc8xxx_spi_read_reg(mode)) + return; + +/* Turn off IRQs locally to minimize time that SPI is disabled. */ +local_irq_save (flags); + +/* Turn off SPI unit prior changing mode */ + mpc8xxx_spi_write_reg(mode, cs->hw_mode & ~SPMODE_ENABLE); + mpc8xxx_spi_write_reg(mode, cs->hw_mode); + +local_irq_restore (flags); +} + static void mpc8xxx_spi_chipselect(struct spi_device *spi, int value) {struct mpc8xxx_spi *mpc8xxx_spi =spi_master_get_devdata (spi->master);
@@ -168,27 +188,13 @@ static void mpc8xxx_spi_chipselect(struct spi_device *spi, int value) }if (value ==BITBANG_CS_ACTIVE ) { -u32 regval =mpc8xxx_spi_read_reg (&mpc8xxx_spi->base->mode); - mpc8xxx_spi->rx_shift = cs->rx_shift; mpc8xxx_spi->tx_shift = cs->tx_shift; mpc8xxx_spi->get_rx = cs->get_rx; mpc8xxx_spi->get_tx = cs->get_tx; -if (cs->hw_mode != regval) { -unsigned long flags; -__be32 __iomem *mode = &mpc8xxx_spi->base->mode; - - regval = cs->hw_mode; -/* Turn off IRQs locally to minimize time that -* SPI is disabled -*/ -local_irq_save (flags); -/* Turn off SPI unit prior changing mode */ -mpc8xxx_spi_write_reg (mode, regval & ~SPMODE_ENABLE ); -mpc8xxx_spi_write_reg (mode, regval); -local_irq_restore (flags); - } +mpc8xxx_spi_change_mode (spi); +if (pdata->cs_control) pdata->cs_control (spi, pol); }
@@ -198,7 +204,6 @@ staticint mpc8xxx_spi_setup_transfer (struct spi_device *spi,struct spi_transfer *t) {struct mpc8xxx_spi *mpc8xxx_spi; -u32 regval;u8 bits_per_word, pm;u32 hz;struct spi_mpc8xxx_cs *cs = spi->controller_state;
@@ -286,21 +291,8 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) pm--; cs->hw_mode |=SPMODE_PM (pm); - regval =mpc8xxx_spi_read_reg (&mpc8xxx_spi->base->mode); -if (cs->hw_mode != regval) { -unsigned long flags; -__be32 __iomem *mode = &mpc8xxx_spi->base->mode; - - regval = cs->hw_mode; -/* Turn off IRQs locally to minimize time -* that SPI is disabled -*/ -local_irq_save (flags); -/* Turn off SPI unit prior changing mode */ -mpc8xxx_spi_write_reg (mode, regval & ~SPMODE_ENABLE ); -mpc8xxx_spi_write_reg (mode, regval); -local_irq_restore (flags); - } + +mpc8xxx_spi_change_mode (spi);return 0 ; }
Signature · 9 lines
1.6.3.3 ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference
Kumar Gala
AppliedRe: [PATCH 6/8] spi_mpc8xxx: Factor out SPI mode change steps into a call
Quoted 8 lines · Anton Vorontsov
We'll add more steps soon, so get rid of the duplication.
Signed-off-by Anton Vorontsov <[email protected]>Acked-by David Brownell <[email protected]>---
drivers/spi/spi_mpc8xxx.c| 56 ++++++++++++++++++
+-------------------------1 files changed, 24 insertions(+), 32 deletions(-)
applied to next
- k
PATCH 7/8 spi_mpc8xxx: Turn qe_mode into flags
In reply to Anton VorontsovSoon there will be more flags introduced in subsequent patches, so let's turn qe_mode into flags.
Also introduce mpc8xxx_spi_strmode() and print current SPI mode.
--- drivers/spi/spi_mpc8xxx.c | 30 +++++++++++++++++++----------- include/linux/fsl_devices.h | 2 +- 2 files changed, 20 insertions(+), 12 deletions(-)
drivers/spi/spi_mpc8xxx.c +19 -11
@@ -96,7 +96,8 @@ struct mpc8xxx_spi {u32 rx_shift;/* RX data reg shift when in qe mode */ u32 tx_shift;/* TX data reg shift when in qe mode */ -bool qe_mode; +unsigned int flags; +#define SPI_QE_CPU_MODE (1 << 0)/* QE CPU ("PIO") mode */ struct workqueue_struct *workqueue;struct work_struct work;
@@ -235,14 +236,14 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)if (bits_per_word <=8 ) { cs->get_rx = mpc8xxx_spi_rx_buf_u8; cs->get_tx = mpc8xxx_spi_tx_buf_u8; -if (mpc8xxx_spi->qe_mode) { +if (mpc8xxx_spi->flags &SPI_QE_CPU_MODE ) { cs->rx_shift =16 ; cs->tx_shift =24 ; } }else if (bits_per_word <=16 ) { cs->get_rx = mpc8xxx_spi_rx_buf_u16; cs->get_tx = mpc8xxx_spi_tx_buf_u16; -if (mpc8xxx_spi->qe_mode) { +if (mpc8xxx_spi->flags &SPI_QE_CPU_MODE ) { cs->rx_shift =16 ; cs->tx_shift =16 ; }
@@ -252,7 +253,8 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) }else return -EINVAL ; -if (mpc8xxx_spi->qe_mode && spi->mode &SPI_LSB_FIRST ) { +if (mpc8xxx_spi->flags &SPI_QE_CPU_MODE && + spi->mode &SPI_LSB_FIRST ) { cs->tx_shift =0 ;if (bits_per_word <=8 ) cs->rx_shift =8 ;
@@ -518,6 +520,13 @@ static void mpc8xxx_spi_cleanup(struct spi_device *spi)kfree (spi->controller_state); } +static const char *mpc8xxx_spi_strmode (unsigned int flags) +{ +if (flags &SPI_QE_CPU_MODE ) +return "QE CPU" ; +return "CPU" ; +} +static struct spi_master *__devinit mpc8xxx_spi_probe (struct device *dev,struct resource *mem,unsigned int irq) {
@@ -544,14 +553,14 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) master->cleanup = mpc8xxx_spi_cleanup; mpc8xxx_spi =spi_master_get_devdata (master); - mpc8xxx_spi->qe_mode = pdata->qe_mode; mpc8xxx_spi->get_rx = mpc8xxx_spi_rx_buf_u8; mpc8xxx_spi->get_tx = mpc8xxx_spi_tx_buf_u8; + mpc8xxx_spi->flags = pdata->flags; mpc8xxx_spi->spibrg = pdata->sysclk; mpc8xxx_spi->rx_shift =0 ; mpc8xxx_spi->tx_shift =0 ; -if (mpc8xxx_spi->qe_mode) { +if (mpc8xxx_spi->flags &SPI_QE_CPU_MODE ) { mpc8xxx_spi->rx_shift =16 ; mpc8xxx_spi->tx_shift =24 ; }
@@ -584,7 +593,7 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq)/* Enable SPI interface */ regval = pdata->initial_spmode |SPMODE_INIT_VAL |SPMODE_ENABLE ; -if (pdata->qe_mode) +if (mpc8xxx_spi->flags &SPI_QE_CPU_MODE ) regval |=SPMODE_OP ;mpc8xxx_spi_write_reg (&mpc8xxx_spi->base->mode, regval);
@@ -604,9 +613,8 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq)if (ret <0 ) goto unreg_master; -printk (KERN_INFO -"%s: MPC8xxx SPI Controller driver at 0x%p (irq = %d)\n" , -dev_name (dev), mpc8xxx_spi->base, mpc8xxx_spi->irq); +dev_info (dev,"at 0x%p (irq = %d), %s mode\n" , mpc8xxx_spi->base, + mpc8xxx_spi->irq,mpc8xxx_spi_strmode (mpc8xxx_spi->flags));return master;
@@ -797,7 +805,7 @@ static int __devinit of_mpc8xxx_spi_probe(struct of_device *ofdev, prop =of_get_property (np,"mode" ,NULL );if (prop && !strcmp (prop,"cpu-qe" )) - pdata->qe_mode =1 ; + pdata->flags =SPI_QE_CPU_MODE ; ret =of_mpc8xxx_spi_get_chipselects (dev);if (ret)
include/linux/fsl_devices.h +1 -1
@@ -74,7 +74,7 @@ struct spi_device;struct fsl_spi_platform_data {u32 initial_spmode;/* initial SPMODE value */ s16 bus_num; -bool qe_mode; +unsigned int flags;/* board specific information */ u16 max_chipselect;void (*cs_control)(struct spi_device *spi,bool on);
Signature · 9 lines
1.6.3.3 ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference
Kumar Gala
AppliedRe: [PATCH 7/8] spi_mpc8xxx: Turn qe_mode into flags
Quoted 11 lines · Anton Vorontsov
Soon there will be more flags introduced in subsequent patches, so let's turn
qe_modeinto flags.Also introduce
mpc8xxx_spi_strmode()and print current SPI mode.Signed-off-by Anton Vorontsov <[email protected]>Acked-by David Brownell <[email protected]>---
drivers/spi/spi_mpc8xxx.c| 30 +++++++++++++++++++-----------include/linux/fsl_devices.h| 2 +-2 files changed, 20 insertions(+), 12 deletions(-)
applied to next
- k
Re: [PATCH 7/8] spi_mpc8xxx: Turn qe_mode into flags
Quoted 7 lines · Kumar Gala
Quoted 5 lines · Anton Vorontsov
Soon there will be more flags introduced in subsequent patches, so let's turn
qe_modeinto flags.Also introduce
mpc8xxx_spi_strmode()and print current SPI mode.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Anton Vorontsov <[email protected]>Acked-by David Brownell <[email protected]>---
drivers/spi/spi_mpc8xxx.c| 30 +++++++++++++++++++-----------include/linux/fsl_devices.h| 2 +-2 files changed, 20 insertions(+), 12 deletions(-)applied to next
This patch breaks my 6xx config:
/home/benh/linux-powerpc-test/arch/powerpc/platforms/83xx/mpc832x_rdb.c: In function ‘of_fsl_spi_probe’:/home/benh/linux-powerpc-test/arch/powerpc/platforms/83xx/mpc832x_rdb.c:77: error: ‘struct fsl_spi_platform_data’ has no member named ‘qe_
The reason is that the mpc832x_rdb.c code still uses the legacy probing method. The fix is not totally trivial as the new flags are defined inside spi_mpc8xxx.c so either the flags need to be moved to fsl_devices.h or mpc832x_rdb.c needs to be converted to new style stuff.
I'll commit (will be up later today in my next branch) a fix moving the flags over for now so the tree doesn't break building.
If you are going to keep the flags in the .c file you probably also want to remove the platform device definition from fsl_devices.h anyways as there's no point exposing to the world a structure with a "flags" member if the definition of those flags isn't also exposed.
Cheers,
Ben.
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 7/8] spi_mpc8xxx: Turn qe_mode into flags
On Tue, Nov 24, 2009 at 04:03:36PM +1100, Benjamin Herrenschmidt wrote:
[...]
Quoted 8 lines
This patch breaks my 6xx config:
/home/benh/linux-powerpc-test/arch/powerpc/platforms/83xx/mpc832x_rdb.c: In function ‘of_fsl_spi_probe’:/home/benh/linux-powerpc-test/arch/powerpc/platforms/83xx/mpc832x_rdb.c:77: error: ‘struct fsl_spi_platform_data’ has no member named ‘qe_The reason is that the
mpc832x_rdb.ccode still uses the legacy probing method. The fix is not totally trivial as the new flags are defined insidespi_mpc8xxx.c
Thanks for noticing. I indeed forgot about the legacy stuff. :-/
Quoted 4 lines
If you are going to keep the flags in the .c file you probably also want to remove the platform device definition from
fsl_devices.hanyways as there's no point exposing to the world a structure with a "flags" member if the definition of those flags isn't also exposed.
Yep. Though, IIRC Joakim asked to keep the legacy bindings for some time (until we implement SPI chip-select framework?)... so for now we'll have to leave we the exposed flags.
Thanks again,
Signature · 7 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
PATCH 8/8 spi_mpc8xxx: Add support for QE DMA mode and CPM1/CPM2 chips
In reply to Anton VorontsovThis patch adds QE buffer descriptors mode support for the spi_mpc8xxx driver, and as a side effect we now support CPM1 and CPM2 SPI controllers.
That means that today we support almost all MPC SPI controllers:
- MPC834x-style controllers (support PIO mode only);
- CPM1 and CPM2 controllers (support DMA mode only);
- QE SPI controllers in CPU mode (PIO mode with shift quirks);
- QE SPI controllers in buffer descriptors (DMA) mode;
The only controller we don't currently support is a newer eSPI (with a dedicated chip selects and a bit different registers map).
--- drivers/spi/Kconfig | 3 - drivers/spi/spi_mpc8xxx.c | 540 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 500 insertions(+), 43 deletions(-)
drivers/spi/Kconfig +0 -3
@@ -147,9 +147,6 @@ config SPI_MPC8xxx This enables using the Freescale MPC8xxx SPI controllers in master mode. - This driver uses a simple set of shift registers for data (opposed - to the CPM based descriptor model). - config SPI_OMAP_UWIRE tristate "OMAP1 MicroWire" depends on ARCH_OMAP1
drivers/spi/spi_mpc8xxx.c +500 -40
698 lines not on this page · raw message
Signature · 8 lines
1.6.3.3 ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference
Kumar Gala
AppliedRe: [PATCH 8/8] spi_mpc8xxx: Add support for QE DMA mode and CPM1/CPM2 chips
Quoted 14 lines · Anton Vorontsov
This patch adds QE buffer descriptors mode support for the
spi_mpc8xxxdriver, and as a side effect we now support CPM1 and CPM2 SPI controllers.That means that today we support almost all MPC SPI controllers:
- MPC834x-style controllers (support PIO mode only);
- CPM1 and CPM2 controllers (support DMA mode only);
- QE SPI controllers in CPU mode (PIO mode with shift quirks);
- QE SPI controllers in buffer descriptors (DMA) mode;The only controller we don't currently support is a newer eSPI (with a dedicated chip selects and a bit different registers map).
Quoted 7 lines
Signed-off-by Anton Vorontsov <[email protected]>Acked-by David Brownell <[email protected]>---
drivers/spi/Kconfig| 3 -drivers/spi/spi_mpc8xxx.c| 540 ++++++++++++++++++++++++++++++++++++
+++++----2 files changed, 500 insertions(+), 43 deletions(-)
applied to next
- k