spi: omap3: Move headers code inside the driver
PATCH v6 1/3 spi: omap3: Move headers code inside the driver
Header file have macro's and register definition and some unneeded function proto types which becomes tunned further in future patches and entire driver code resides in one file for more readability.
---
Changes for v6:
- Add spaces for to_omap3_spi definition.
drivers/spi/omap3_spi.c | 88 +++++++++++++++++++++++++++++++++++++- drivers/spi/omap3_spi.h | 109 ------------------------------------------------ 2 files changed, 86 insertions(+), 111 deletions(-) delete mode 100644 drivers/spi/omap3_spi.h
drivers/spi/omap3_spi.c +86 -2
@@ -18,9 +18,93 @@#include <spi.h> #include <malloc.h> #include <asm/io.h> -#include "omap3_spi.h" -#define SPI_WAIT_TIMEOUT 10 +#if defined(CONFIG_AM33XX ) || defined(CONFIG_AM43XX ) +#define OMAP3_MCSPI1_BASE 0x48030100 +#define OMAP3_MCSPI2_BASE 0x481A0100 +#else +#define OMAP3_MCSPI1_BASE 0x48098000 +#define OMAP3_MCSPI2_BASE 0x4809A000 +#define OMAP3_MCSPI3_BASE 0x480B8000 +#define OMAP3_MCSPI4_BASE 0x480BA000 +#endif + +/* per-register bitmasks */ +#define OMAP3_MCSPI_SYSCONFIG_SMARTIDLE (2 << 3) +#define OMAP3_MCSPI_SYSCONFIG_ENAWAKEUP BIT(2) +#define OMAP3_MCSPI_SYSCONFIG_AUTOIDLE BIT(0) +#define OMAP3_MCSPI_SYSCONFIG_SOFTRESET BIT(1) + +#define OMAP3_MCSPI_SYSSTATUS_RESETDONE BIT(0) + +#define OMAP3_MCSPI_MODULCTRL_SINGLE BIT(0) +#define OMAP3_MCSPI_MODULCTRL_MS BIT(2) +#define OMAP3_MCSPI_MODULCTRL_STEST BIT(3) + +#define OMAP3_MCSPI_CHCONF_PHA BIT(0) +#define OMAP3_MCSPI_CHCONF_POL BIT(1) +#define OMAP3_MCSPI_CHCONF_CLKD_MASK GENMASK(5, 2) +#define OMAP3_MCSPI_CHCONF_EPOL BIT(6) +#define OMAP3_MCSPI_CHCONF_WL_MASK GENMASK(11, 7) +#define OMAP3_MCSPI_CHCONF_TRM_RX_ONLY BIT(12) +#define OMAP3_MCSPI_CHCONF_TRM_TX_ONLY BIT(13) +#define OMAP3_MCSPI_CHCONF_TRM_MASK GENMASK(13, 12) +#define OMAP3_MCSPI_CHCONF_DMAW BIT(14) +#define OMAP3_MCSPI_CHCONF_DMAR BIT(15) +#define OMAP3_MCSPI_CHCONF_DPE0 BIT(16) +#define OMAP3_MCSPI_CHCONF_DPE1 BIT(17) +#define OMAP3_MCSPI_CHCONF_IS BIT(18) +#define OMAP3_MCSPI_CHCONF_TURBO BIT(19) +#define OMAP3_MCSPI_CHCONF_FORCE BIT(20) + +#define OMAP3_MCSPI_CHSTAT_RXS BIT(0) +#define OMAP3_MCSPI_CHSTAT_TXS BIT(1) +#define OMAP3_MCSPI_CHSTAT_EOT BIT(2) + +#define OMAP3_MCSPI_CHCTRL_EN BIT(0) +#define OMAP3_MCSPI_CHCTRL_DIS (0 << 0) + +#define OMAP3_MCSPI_WAKEUPENABLE_WKEN BIT(0) + +#define OMAP3_MCSPI_MAX_FREQ 48000000 +#define SPI_WAIT_TIMEOUT 10 + +/* OMAP3 McSPI registers */ +struct mcspi_channel { +unsigned int chconf;/* 0x2C, 0x40, 0x54, 0x68 */ +unsigned int chstat;/* 0x30, 0x44, 0x58, 0x6C */ +unsigned int chctrl;/* 0x34, 0x48, 0x5C, 0x70 */ +unsigned int tx;/* 0x38, 0x4C, 0x60, 0x74 */ +unsigned int rx;/* 0x3C, 0x50, 0x64, 0x78 */ +}; + +struct mcspi { +unsigned char res1[0x10 ]; +unsigned int sysconfig;/* 0x10 */ +unsigned int sysstatus;/* 0x14 */ +unsigned int irqstatus;/* 0x18 */ +unsigned int irqenable;/* 0x1C */ +unsigned int wakeupenable;/* 0x20 */ +unsigned int syst;/* 0x24 */ +unsigned int modulctrl;/* 0x28 */ +struct mcspi_channel channel[4 ]; +/* channel0: 0x2C - 0x3C, bus 0 & 1 & 2 & 3 */ +/* channel1: 0x40 - 0x50, bus 0 & 1 */ +/* channel2: 0x54 - 0x64, bus 0 & 1 */ +/* channel3: 0x68 - 0x78, bus 0 */ +}; + +struct omap3_spi_slave { +struct spi_slave slave; +struct mcspi *regs; +unsigned int freq; +unsigned int mode; +}; + +static inline struct omap3_spi_slave *to_omap3_spi (struct spi_slave *slave) +{ + return container_of(slave, struct omap3_spi_slave, slave); +}static void spi_reset (struct omap3_spi_slave *ds) {
drivers/spi/omap3_spi.h deleted +0 -109
109 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v6 2/3 spi: omap3: Make local functions as static
Attach static on local defined functions.
---
Changes for v6:
- None.
drivers/spi/omap3_spi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/spi/omap3_spi.c +6 -6
@@ -306,8 +306,8 @@ void spi_release_bus(struct spi_slave *slave)spi_reset (ds); } -int omap3_spi_write (struct spi_slave *slave,unsigned int len,const void *txp, -unsigned long flags) +static int omap3_spi_write (struct spi_slave *slave,unsigned int len, +const void *txp,unsigned long flags) {struct omap3_spi_slave *ds =to_omap3_spi (slave);int i;
@@ -360,8 +360,8 @@ int omap3_spi_write(struct spi_slave *slave, unsigned int len, const void *txp,return 0 ; } -int omap3_spi_read (struct spi_slave *slave,unsigned int len,void *rxp, -unsigned long flags) +static int omap3_spi_read (struct spi_slave *slave,unsigned int len, +void *rxp,unsigned long flags) {struct omap3_spi_slave *ds =to_omap3_spi (slave);int i;
@@ -414,8 +414,8 @@ int omap3_spi_read(struct spi_slave *slave, unsigned int len, void *rxp, }/*McSPI Transmit Receive Mode*/ -int omap3_spi_txrx (struct spi_slave *slave,unsigned int len, -const void *txp,void *rxp,unsigned long flags) +static int omap3_spi_txrx (struct spi_slave *slave,unsigned int len, +const void *txp,void *rxp,unsigned long flags) {struct omap3_spi_slave *ds =to_omap3_spi (slave);ulong start;
Signature · 1 line
1.9.1
PATCH v6 2/3 spi: omap3: Make local functions as static
Quoted 9 lines · Jagan Teki
Attach static on local defined functions.
Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Jagan Teki <[email protected]>Signed-off-by Christophe Ricard <[email protected]>---
Changes for v6:
- None.
Applied to u-boot-spi/master
Signature · 1 line
Jagan.
PATCH v6 2/3 spi: omap3: Make local functions as static
In reply to Jagan TekiQuoted 6 lines · Jagan Teki
Attach static on local defined functions.
Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Jagan Teki <[email protected]>Signed-off-by Christophe Ricard <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160315/7e6b640b/attachment.sig>
PATCH v6 3/3 spi: omap3: Convert to driver model
In reply to Jagan TekiAfter this conversion the driver will able to support both dm and non-dm and code is more extensible like we can remove the non-dm part simply without touching anycode if all the boards which are using this driver become dm driven.
---
Changes for v6:
- Add spaces for to_omap3_spi definition.
drivers/spi/Kconfig | 7 + drivers/spi/omap3_spi.c | 679 +++++++++++++++++++++++++++++------------------- 2 files changed, 416 insertions(+), 270 deletions(-)
drivers/spi/Kconfig +7 -0
@@ -155,6 +155,13 @@ config ZYNQ_QSPI Zynq QSPI IP core. This IP is used to connect the flash in 4-bit qspi, 8-bit dual stacked and shared 4-bit dual parallel. +config OMAP3_SPI + bool "McSPI driver for OMAP" + help + SPI master controller for OMAP24XX and later Multichannel SPI + (McSPI). This driver be used to access SPI chips on platforms + embedding this OMAP3 McSPI IP core. + endif # if DM_SPI config FSL_ESPI
drivers/spi/omap3_spi.c +409 -270
874 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v6 3/3 spi: omap3: Convert to driver model
Quoted 12 lines · Jagan Teki
After this conversion the driver will able to support both dm and non-dm and code is more extensible like we can remove the non-dm part simply without touching anycode if all the boards which are using this driver become dm driven.
Cc Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>Tested-by Christophe Ricard <[email protected]>Signed-off-by Jagan Teki <[email protected]>[Set priv->wordlen, Add Kconfig entry and file credit for dm conversion]Signed-off-by Christophe Ricard <[email protected]>
Quoted 3 lines
---
Changes for v6:
- Add spaces forto_omap3_spidefinition.
Applied to u-boot-spi/master
Signature · 1 line
Jagan.
PATCH v6 3/3 spi: omap3: Convert to driver model
In reply to Jagan TekiQuoted 5 lines · Jagan Teki
After this conversion the driver will able to support both dm and non-dm and code is more extensible like we can remove the non-dm part simply without touching anycode if all the boards which are using this driver become dm driven.
Quoted 7 lines
Cc Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>Tested-by Christophe Ricard <[email protected]>Signed-off-by Jagan Teki <[email protected]>[Set priv->wordlen, Add Kconfig entry and file credit for dm conversion]Signed-off-by Christophe Ricard <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160315/85a31010/attachment.sig>
PATCH v6 1/3 spi: omap3: Move headers code inside the driver
In reply to Jagan TekiQuoted 4 lines · Jagan Teki
Header file have macro's and register definition and some unneeded function proto types which becomes tunned further in future patches and entire driver code resides in one file for more readability.
Quoted 8 lines
Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Jagan Teki <[email protected]>[Fixes on code styles, Remove omap3_spi_txrx|write|read in header]Signed-off-by Christophe Ricard <[email protected]>---
Changes for v6:
- Add spaces forto_omap3_spidefinition.
Applied to u-boot-spi/master
Signature · 1 line
Jagan.
PATCH v6 1/3 spi: omap3: Move headers code inside the driver
In reply to Jagan TekiQuoted 9 lines · Jagan Teki
Header file have macro's and register definition and some unneeded function proto types which becomes tunned further in future patches and entire driver code resides in one file for more readability.
Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Jagan Teki <[email protected]>[Fixes on code styles, Remove omap3_spi_txrx|write|read in header]Signed-off-by Christophe Ricard <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160315/2236c15f/attachment.sig>