powerpc: eSPI and eSPI controller support
PATCH v3 1/2 powerpc: eSPI and eSPI controller support
From: Mingkai Hu <[email protected]>
---
changes for v2:
remove #ifdef wrapper and refactor spi_xfer by use SPI_XFER(BEGIN | END). remove 'volatile' use I/O accessors instead.
changes for v3:
move powerpc specific code to asm/config.h
use spi_claim_bus() to setup hardware rather than spi_setup_slave(). use slave data rather than global.
drop useless return.
arch/powerpc/include/asm/config.h | 7 + drivers/spi/Makefile | 1 + drivers/spi/fsl_espi.c | 305 +++++++++++++++++++++++++++++++++++++ include/spi.h | 29 +++- 4 files changed, 335 insertions(+), 7 deletions(-) create mode 100644 drivers/spi/fsl_espi.c
arch/powerpc/include/asm/config.h +7 -0
@@ -29,6 +29,13 @@#include <asm/config_mpc86xx.h> #endif +/* CONFIG_HARD_SPI triggers SPI bus initialization in PowerPC */ +#if defined(CONFIG_MPC8XXX_SPI ) || defined(CONFIG_FSL_ESPI ) +# ifndef CONFIG_HARD_SPI +# define CONFIG_HARD_SPI +# endif +#endif +#define CONFIG_LMB #define CONFIG_SYS_BOOT_RAMDISK_HIGH #define CONFIG_SYS_BOOT_GET_CMDLINE
drivers/spi/Makefile +1 -0
@@ -38,6 +38,7 @@ COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o COBJS-$(CONFIG_OMAP3_SPI) += omap3_spi.o COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o COBJS-$(CONFIG_SH_SPI) += sh_spi.o +COBJS-$(CONFIG_FSL_ESPI) += fsl_espi.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/spi/fsl_espi.c new file +305 -0
305 lines not on this page · raw message
include/spi.h +22 -7
@@ -2,6 +2,8 @@* (C) Copyright 2001 * Gerald Van Baren, Custom IDEAS, vanbaren at cideas.com. * +* Copyright 2010-2011 Freescale Semiconductor, Inc +* * See file CREDITS for list of people who contributed to this * project. *
@@ -26,13 +28,6 @@/* Controller-specific definitions: */ -/* CONFIG_HARD_SPI triggers SPI bus initialization in PowerPC */ -#ifdef CONFIG_MPC8XXX_SPI -# ifndef CONFIG_HARD_SPI -# define CONFIG_HARD_SPI -# endif -#endif -/* SPI mode flags */ #define SPI_CPHA 0x01/* clock phase */ #define SPI_CPOL 0x02/* clock polarity */
@@ -50,16 +45,36 @@#define SPI_XFER_END 0x02/* Deassert CS after transfer */ /*----------------------------------------------------------------------- +* Representation of a SPI slave data. +* div16: whether System clock/16 is the input to the eSPI BRG. +* pm: Prescale modulus select. +* mode: Clock polarity, clock phase and other parameters. +* cmd_len: CMD length stored at BEGIN phase. +* cmd_buf: CMD stored at BEGIN phase. +* data_len: data length used to activate CS length. +*/ +struct spi_slave_data { +unsigned int div16; +unsigned int pm; +unsigned int mode; +size_t cmd_len; +u8 cmd_buf[16 ]; +size_t data_len; +}; + +/*----------------------------------------------------------------------- * Representation of a SPI slave, i.e. what we're communicating with. * * Drivers are expected to extend this with controller-specific data. * * bus: ID of the bus that the slave is attached to. * cs: ID of the chip select connected to the slave. +* slave_data: slave data for hardware and transfer. */ struct spi_slave {unsigned int bus;unsigned int cs; +struct spi_slave_data slave_data; };/*-----------------------------------------------------------------------
Signature · 1 line
1.6.4
PATCH v3 1/2 powerpc: eSPI and eSPI controller support
Quoted 11 lines · Shaohui Xie
include/spi.h +0
-0?/*-----------------------------------------------------------------------
+ * Representation of a SPI slave data.
+ * ? div16: ? ?whether System clock/16 is the input to the eSPI BRG.
+ * ? pm: ? ? ? Prescale modulus select.
+ * ? mode: ? ? Clock polarity, clock phase and other parameters.
+ * ?cmd_len: ?CMD length stored at BEGIN phase.
+ * ?cmd_buf: ?CMD stored at BEGIN phase.
+ * ?data_len: data length used to activate CS length.
+ */
include/spi.h
Quoted 8 lines
include/spi.h +8
-0+struct spi_slave_data { + ? ? ? unsigned int ? ?div16; + ? ? ? unsigned int ? ?pm; + ? ? ? unsigned int ? ?mode; + ? ? ? size_t ? ? ? ? ?cmd_len; + ? ? ? u8 ? ? ? ? ? ? ?cmd_buf[16]; + ? ? ? size_t ? ? ? ? ?data_len; +};
err, this belongs in your spi controller code, not the common spi header. look at like the bfin_spi driver to see how to do it. -mike
PATCH v3 1/2 powerpc: eSPI and eSPI controller support
Quoted 6 lines
-----Original Message-----
From: [email protected] [mailto:vapierfilter at gmail.com] On Behalf Of
Quoted 24 lines
Mike Frysinger
Sent: Saturday, April 23, 2011 4:54 AM
To: Xie Shaohui-B21989
Cc: u-boot at lists.denx.de; Gala Kumar-B11780; Zang Roy-R61911; Hu Mingkai- B21284
Subject: Re: [PATCH 1/2][v3] powerpc: eSPI and eSPI controller supportQuoted 16 lines · Shaohui Xie
include/spi.h +0
-0/*--------------------------------------------------------------------
---
+ * Representation of a SPI slave data.
+ * ? div16: ? ?whether System clock/16 is the input to the eSPI BRG.
+ * ? pm: ? ? ? Prescale modulus select.
+ * ? mode: ? ? Clock polarity, clock phase and other parameters.
+ * ?cmd_len: ?CMD length stored at BEGIN phase.
+ * ?cmd_buf: ?CMD stored at BEGIN phase.
+ * ?data_len: data length used to activate CS length.
+ */
+structspi_slave_data{
+ ? ? ? unsigned int ? ?div16;
+ ? ? ? unsigned int ? ?pm;
Quoted 8 lines
Quoted 5 lines
+ ? ? ? unsigned int ? ?mode;
+ ? ? ?size_t? ? ? ? ?cmd_len;
+ ? ? ? u8 ? ? ? ? ? ? ?cmd_buf[16];
+ ? ? ?size_t? ? ? ? ?data_len;
+};err, this belongs in your spi controller code, not the common spi header. look at like the
bfin_spidriver to see how to do it.
[Xie Shaohui] OK, Thanks, I see the bfin_spi driver; I'll take it as an example.
Best Regards,
Shaohui Xie