spi:rewrite the Freescale DSPI driver.
Subsystems (4)
PATCH v4 1/3 spi:rewrite the Freescale DSPI driver.
From: Chao Fu <[email protected]>
Freescale DSPI module is used on both the ColdFire platform and the ARM platform. The original DSPI driver is written for ColdFire platform only, this patch rewrite the driver to make it be used across the platforms. Some files, functions, variables and macros were changed accordingly for some ColdFire boards and Arm boards.
The rewrite including the following changes:
Rename the file name :
cf_spi.c -> fsl_dspi.c
Move the file:
arch/m68k/include/asm/coldfire/dspi.h -> include/fsl_dspi.h
Rename the functions and variables:
cfxxx -> dspixxx
Renamed macros:
CONFIG_CF_DSPI -> CONFIG_FSL_DSPIKeep the following functions for ColdFire:
cfspi_port_conf()
cfspi_claim_bus()
cfspi_release_bus()
Add function for ColdFire:
get_dspi_clk()
Add endian convert for different platform.
dspi_write32() dspi_read32()
Tested on board M54455EVB, ls1021a-qds and VF610-twr.
---
Change in v2:
Merge m68k update and driver update into the patch.
Change in v3:
Remove some unstandard coding style.
Change in v4:
Add two-endian support, and ls1021a support.
arch/m68k/cpu/mcf5227x/cpu_init.c | 3 +- arch/m68k/cpu/mcf5227x/speed.c | 7 + arch/m68k/cpu/mcf52x2/speed.c | 7 + arch/m68k/cpu/mcf5445x/cpu_init.c | 3 +- arch/m68k/cpu/mcf5445x/speed.c | 7 + arch/m68k/include/asm/coldfire/dspi.h | 142 ------------- arch/m68k/include/asm/immap_5227x.h | 1 - arch/m68k/include/asm/immap_5301x.h | 1 - arch/m68k/include/asm/immap_5441x.h | 1 - arch/m68k/include/asm/immap_5445x.h | 1 - arch/m68k/include/asm/immap_547x_8x.h | 1 - drivers/spi/Makefile | 2 +- drivers/spi/cf_spi.c | 347 ------------------------------- drivers/spi/fsl_dspi.c | 373 ++++++++++++++++++++++++++++++++++ include/configs/M52277EVB.h | 3 +- include/configs/M54418TWR.h | 3 +- include/configs/M54451EVB.h | 3 +- include/configs/M54455EVB.h | 3 +- include/fsl_dspi.h | 142 +++++++++++++ 19 files changed, 545 insertions(+), 505 deletions(-) delete mode 100644 arch/m68k/include/asm/coldfire/dspi.h delete mode 100644 drivers/spi/cf_spi.c create mode 100644 drivers/spi/fsl_dspi.c create mode 100644 include/fsl_dspi.h
arch/m68k/cpu/mcf5227x/cpu_init.c +2 -1
@@ -16,6 +16,7 @@#include <asm/io.h> #include <asm/rtc.h> #include <linux/compiler.h> +#include <fsl_dspi.h> /* * Breath some life into the CPU...
@@ -139,7 +140,7 @@ void uart_port_conf(int port) } } -#ifdef CONFIG_CF_DSPI +#ifdef CONFIG_FSL_DSPI void cfspi_port_conf (void ) {gpio_t *gpio = (gpio_t *)MMAP_GPIO ;
arch/m68k/cpu/mcf5227x/speed.c +7 -0
@@ -124,3 +124,10 @@ int get_clocks(void)return (0 ); } + +#ifdef CONFIG_FSL_DSPI +int get_dspi_clk (void ) +{ +return gd->bus_clk; +} +#endif
arch/m68k/cpu/mcf52x2/speed.c +7 -0
@@ -83,3 +83,10 @@ int get_clocks (void)return (0 ); } + +#ifdef CONFIG_FSL_DSPI +int get_dspi_clk (void ) +{ +return gd->bus_clk; +} +#endif
arch/m68k/cpu/mcf5445x/cpu_init.c +2 -1
@@ -16,6 +16,7 @@#include <asm/rtc.h> #include <asm/io.h> #include <linux/compiler.h> +#include <fsl_dspi.h> #if defined(CONFIG_CMD_NET )#include <config.h>
@@ -423,7 +424,7 @@ int fecpin_setclear(struct eth_device *dev, int setclear) }#endif -#ifdef CONFIG_CF_DSPI +#ifdef CONFIG_FSL_DSPI void cfspi_port_conf (void ) {gpio_t *gpio = (gpio_t *)MMAP_GPIO ;
arch/m68k/cpu/mcf5445x/speed.c +7 -0
@@ -279,3 +279,10 @@ int get_clocks(void)return (0 ); } + +#ifdef CONFIG_FSL_DSPI +int get_dspi_clk (void ) +{ +return gd->bus_clk; +} +#endif
arch/m68k/include/asm/coldfire/dspi.h deleted +0 -142
142 lines not on this page · raw message
arch/m68k/include/asm/immap_5227x.h +0 -1
@@ -51,7 +51,6 @@#define MMAP_PLL (CONFIG_SYS_MBAR + 0x000C0000)#include <asm/coldfire/crossbar.h> -#include <asm/coldfire/dspi.h> #include <asm/coldfire/edma.h> #include <asm/coldfire/eport.h> #include <asm/coldfire/flexbus.h>
arch/m68k/include/asm/immap_5301x.h +0 -1
@@ -52,7 +52,6 @@#define MMAP_ESDHC (CONFIG_SYS_MBAR + 0x000CC000)#include <asm/coldfire/crossbar.h> -#include <asm/coldfire/dspi.h> #include <asm/coldfire/edma.h> #include <asm/coldfire/eport.h> #include <asm/coldfire/flexbus.h>
arch/m68k/include/asm/immap_5441x.h +0 -1
@@ -78,7 +78,6 @@#define MMAP_GPIO 0xEC094000#include <asm/coldfire/crossbar.h> -#include <asm/coldfire/dspi.h> #include <asm/coldfire/edma.h> #include <asm/coldfire/eport.h> #include <asm/coldfire/flexbus.h>
arch/m68k/include/asm/immap_5445x.h +0 -1
@@ -55,7 +55,6 @@#include <asm/coldfire/ata.h> #include <asm/coldfire/crossbar.h> -#include <asm/coldfire/dspi.h> #include <asm/coldfire/edma.h> #include <asm/coldfire/eport.h> #include <asm/coldfire/flexbus.h>
arch/m68k/include/asm/immap_547x_8x.h +0 -1
@@ -41,7 +41,6 @@#define MMAP_SRAMCFG (CONFIG_SYS_MBAR + 0x0001FF00)#define MMAP_SEC (CONFIG_SYS_MBAR + 0x00020000) -#include <asm/coldfire/dspi.h> #include <asm/coldfire/eport.h> #include <asm/coldfire/flexbus.h> #include <asm/coldfire/flexcan.h>
drivers/spi/Makefile +1 -1
@@ -15,7 +15,7 @@ obj-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o obj-$(CONFIG_ATMEL_SPI) += atmel_spi.o obj-$(CONFIG_BFIN_SPI) += bfin_spi.o obj-$(CONFIG_BFIN_SPI6XX) += bfin_spi6xx.o -obj-$(CONFIG_CF_SPI) += cf_spi.o +obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o obj-$(CONFIG_CF_QSPI) += cf_qspi.o obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o obj-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
drivers/spi/cf_spi.c deleted +0 -347
347 lines not on this page · raw message
drivers/spi/fsl_dspi.c new file +373 -0
373 lines not on this page · raw message
include/configs/M52277EVB.h +1 -2
@@ -137,8 +137,7 @@#define CONFIG_SYS_IMMR CONFIG_SYS_MBAR/* DSPI and Serial Flash */ -#define CONFIG_CF_SPI -#define CONFIG_CF_DSPI +#define CONFIG_FSL_DSPI #define CONFIG_HARD_SPI #define CONFIG_SYS_SBFHDR_SIZE 0x7#ifdef CONFIG_CMD_SPI
include/configs/M54418TWR.h +1 -2
@@ -206,8 +206,7 @@#define CONFIG_SYS_IMMR CONFIG_SYS_MBAR/* DSPI and Serial Flash */ -#define CONFIG_CF_SPI -#define CONFIG_CF_DSPI +#define CONFIG_FSL_DSPI #define CONFIG_SERIAL_FLASH #define CONFIG_HARD_SPI #define CONFIG_SYS_SBFHDR_SIZE 0x7
include/configs/M54451EVB.h +1 -2
@@ -148,8 +148,7 @@#define CONFIG_SYS_IMMR CONFIG_SYS_MBAR/* DSPI and Serial Flash */ -#define CONFIG_CF_SPI -#define CONFIG_CF_DSPI +#define CONFIG_FSL_DSPI #define CONFIG_SERIAL_FLASH #define CONFIG_HARD_SPI #define CONFIG_SYS_SBFHDR_SIZE 0x7
include/configs/M54455EVB.h +1 -2
@@ -181,8 +181,7 @@#define CONFIG_SYS_IMMR CONFIG_SYS_MBAR/* DSPI and Serial Flash */ -#define CONFIG_CF_SPI -#define CONFIG_CF_DSPI +#define CONFIG_FSL_DSPI #define CONFIG_HARD_SPI #define CONFIG_SYS_SBFHDR_SIZE 0x13#ifdef CONFIG_CMD_SPI
include/fsl_dspi.h new file +142 -0
142 lines not on this page · raw message
Signature · 1 line
1.8.4
PATCH 2/3 arm:vf610:Enable the DSPI for Freescale vf610 platform
From: Chao Fu <[email protected]>
This patch enable the DSPI moudle on VF610 platform with following udpate:
Add get_dspi_clk() function and enable DPSI clock gate.
Add DSPI iomux definition and set the iomux for DSPI.
---
Change in v2:
Separated vf610-twr update into patch 3/4.
Change in v3:
None.
Change in v4:
None.
arch/arm/cpu/armv7/vf610/generic.c | 7 +++++++ arch/arm/include/asm/arch-vf610/clock.h | 1 + arch/arm/include/asm/arch-vf610/crm_regs.h | 1 + arch/arm/include/asm/arch-vf610/iomux-vf610.h | 8 ++++++++ arch/arm/include/asm/imx-common/iomux-v3.h | 2 ++ 5 files changed, 19 insertions(+)
arch/arm/cpu/armv7/vf610/generic.c +7 -0
@@ -196,6 +196,11 @@ static u32 get_i2c_clk(void)return get_ipg_clk (); } +static u32 get_dspi_clk (void ) +{ +return get_ipg_clk (); +} +unsigned int mxc_get_clock (enum mxc_clock clk) {switch (clk) {
@@ -213,6 +218,8 @@ unsigned int mxc_get_clock(enum mxc_clock clk)return get_fec_clk ();case MXC_I2C_CLK :return get_i2c_clk (); +case MXC_DSPI_CLK : +return get_dspi_clk ();default :break ; }
arch/arm/include/asm/arch-vf610/clock.h +1 -0
@@ -17,6 +17,7 @@ enum mxc_clock {MXC_ESDHC_CLK ,MXC_FEC_CLK ,MXC_I2C_CLK , + MXC_DSPI_CLK, };void enable_ocotp_clk (unsigned char enable);
arch/arm/include/asm/arch-vf610/crm_regs.h +1 -0
@@ -176,6 +176,7 @@ struct anadig_reg {#define CCM_REG_CTRL_MASK 0xffffffff#define CCM_CCGR0_UART0_CTRL_MASK (0x3 << 14)#define CCM_CCGR0_UART1_CTRL_MASK (0x3 << 16) +#define CCM_CCGR0_DSPI0_CTRL_MASK (0x3 << 24)#define CCM_CCGR1_PIT_CTRL_MASK (0x3 << 14)#define CCM_CCGR1_WDOGA5_CTRL_MASK (0x3 << 28)#define CCM_CCGR2_QSPI0_CTRL_MASK (0x3 << 8)
arch/arm/include/asm/arch-vf610/iomux-vf610.h +8 -0
@@ -22,6 +22,10 @@#define VF610_QSPI_PAD_CTRL (PAD_CTL_SPEED_HIGH | PAD_CTL_DSE_150ohm | \ PAD_CTL_PUS_22K_UP | PAD_CTL_OBE_IBE_ENABLE) +#define VF610_DSPI_PAD_CTRL (PAD_CTL_OBE | PAD_CTL_DSE_25ohm | \ + PAD_CTL_SPEED_MED) +#define VF610_DSPI_SIN_PAD_CTRL (PAD_CTL_IBE | PAD_CTL_DSE_25ohm | \ + PAD_CTL_SPEED_MED)enum {VF610_PAD_PTA6__RMII0_CLKIN =IOMUX_PAD (0x0000 ,0x0000 ,2 , __NA_,0 ,VF610_ENET_PAD_CTRL ),
@@ -56,6 +60,10 @@ enum {VF610_PAD_PTA29__ESDHC1_DAT3 =IOMUX_PAD (0x004c ,0x004c ,5 , __NA_,0 ,VF610_SDHC_PAD_CTRL ),VF610_PAD_PTB14__I2C0_SCL =IOMUX_PAD (0x0090 ,0x0090 ,2 ,0x033c ,1 ,VF610_I2C_PAD_CTRL ),VF610_PAD_PTB15__I2C0_SDA =IOMUX_PAD (0x0094 ,0x0094 ,2 ,0x0340 ,1 ,VF610_I2C_PAD_CTRL ), +VF610_PAD_PTB19__DSPI0_CS0 =IOMUX_PAD (0x00a4 ,0x00a4 ,1 , __NA_,0 ,VF610_DSPI_PAD_CTRL ), +VF610_PAD_PTB20__DSPI0_SIN =IOMUX_PAD (0x00a8 ,0x00a8 ,1 , __NA_,0 ,VF610_DSPI_SIN_PAD_CTRL ), +VF610_PAD_PTB21__DSPI0_SOUT =IOMUX_PAD (0x00ac ,0x00ac ,1 , __NA_,0 ,VF610_DSPI_PAD_CTRL ), +VF610_PAD_PTB22__DSPI0_SCK =IOMUX_PAD (0x00b0 ,0x00b0 ,1 , __NA_,0 ,VF610_DSPI_PAD_CTRL ),VF610_PAD_PTD0__QSPI0_A_QSCK =IOMUX_PAD (0x013c ,0x013c ,1 , __NA_,0 ,VF610_QSPI_PAD_CTRL ),VF610_PAD_PTD1__QSPI0_A_CS0 =IOMUX_PAD (0x0140 ,0x0140 ,1 , __NA_,0 ,VF610_QSPI_PAD_CTRL ), VF610_PAD_PTD2__QSPI0_A_DATA3 = IOMUX_PAD(0x0144, 0x0144, 1, __NA_, 0, VF610_QSPI_PAD_CTRL),
arch/arm/include/asm/imx-common/iomux-v3.h +2 -0
@@ -133,6 +133,8 @@ typedef u64 iomux_v3_cfg_t;#define PAD_CTL_PUS_22K_UP (3 << 4 | PAD_CTL_PUE)#define PAD_CTL_PKE (1 << 3)#define PAD_CTL_PUE (1 << 2 | PAD_CTL_PKE) +#define PAD_CTL_OBE (1 << 1) +#define PAD_CTL_IBE (1 << 0)#define PAD_CTL_OBE_IBE_ENABLE (3 << 0)
Signature · 1 line
1.8.4
PATCH 3/3 arm:vf610:vf610-twr:Enable the DSPI for Freesacale vf610-twr board
In reply to Chao FuFrom: Chao Fu <[email protected]>
Enable DSPI iomux for vf610twr board.
Add the SPI configuration for vf610twr board.
---
Change in v2 :
New.
Change in v3 :
None.
Change in v4 :
None.
board/freescale/vf610twr/vf610twr.c | 15 ++++++++++++++- include/configs/vf610twr.h | 13 +++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-)
board/freescale/vf610twr/vf610twr.c +14 -1
@@ -298,6 +298,18 @@ static void setup_iomux_qspi(void)imx_iomux_v3_setup_multiple_pads (qspi0_pads,ARRAY_SIZE (qspi0_pads)); } +static void setup_iomux_dspi (void ) +{ +static const iomux_v3_cfg_t dspi0_pads[] = { +VF610_PAD_PTB19__DSPI0_CS0 , +VF610_PAD_PTB20__DSPI0_SIN , +VF610_PAD_PTB21__DSPI0_SOUT , +VF610_PAD_PTB22__DSPI0_SCK , + }; + +imx_iomux_v3_setup_multiple_pads (dspi0_pads,ARRAY_SIZE (dspi0_pads)); +} +#ifdef CONFIG_FSL_ESDHC struct fsl_esdhc_cfg esdhc_cfg[1 ] = { {ESDHC1_BASE_ADDR},
@@ -335,7 +347,7 @@ static void clock_init(void)struct anadig_reg *anadig = (struct anadig_reg *)ANADIG_BASE_ADDR ;clrsetbits_le32 (&ccm->ccgr0,CCM_REG_CTRL_MASK , -CCM_CCGR0_UART1_CTRL_MASK ); +CCM_CCGR0_UART1_CTRL_MASK |CCM_CCGR0_DSPI0_CTRL_MASK );clrsetbits_le32 (&ccm->ccgr1,CCM_REG_CTRL_MASK ,CCM_CCGR1_PIT_CTRL_MASK |CCM_CCGR1_WDOGA5_CTRL_MASK ); clrsetbits_le32(&ccm->ccgr2, CCM_REG_CTRL_MASK,
@@ -411,6 +423,7 @@ int board_early_init_f(void)setup_iomux_enet ();setup_iomux_i2c ();setup_iomux_qspi (); +setup_iomux_dspi ();return 0 ; }
include/configs/vf610twr.h +13 -0
@@ -80,6 +80,19 @@#define CONFIG_SYS_FSL_QSPI_LE #endif +/* DSPI Configs */ +#ifdef CONFIG_FSL_DSPI +#define MMAP_DSPI SPI0_BASE_ADDR +#define CONFIG_SYS_FSL_DSPI_LE +#define CONFIG_SYS_DSPI_CTAR0 (DSPI_CTAR_TRSZ(7) | \ + DSPI_CTAR_PCSSCK_1CLK | \ + DSPI_CTAR_PASC(0) | \ + DSPI_CTAR_PDT(0) | \ + DSPI_CTAR_CSSCK(0) | \ + DSPI_CTAR_ASC(0) | \ + DSPI_CTAR_DT(0)) +#endif +/* I2C Configs */ #define CONFIG_CMD_I2C #define CONFIG_SYS_I2C
Signature · 1 line
1.8.4