spi:rewrite the Freescale DSPI driver.
Subsystems (5)
PATCH v3 1/4 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()
Tested on board M54455EVB and VF610-twr.
---
Change in v2:
Merge m68k update and driver update into the patch.
Change in v3:
Remove some unstandard coding style.
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/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 => fsl_dspi.c} | 240 +++++++++++----------
include/configs/M52277EVB.h | 3 +-
include/configs/M54418TWR.h | 3 +-
include/configs/M54451EVB.h | 3 +-
include/configs/M54455EVB.h | 3 +-
.../asm/coldfire/dspi.h => include/fsl_dspi.h | 8 +-
17 files changed, 156 insertions(+), 138 deletions(-)
rename drivers/spi/{cf_spi.c => fsl_dspi.c} (56%)
rename arch/m68k/include/asm/coldfire/dspi.h => include/fsl_dspi.h (96%)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/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/fsl_dspi.c renamed from drivers/spi/cf_spi.c +122 -118
402 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
@@ -207,8 +207,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 renamed from arch/m68k/include/asm/coldfire/dspi.h +4 -4
@@ -1,8 +1,9 @@/* -* MCF5227x Internal Memory Map +* Freescale DSPI Module Defines * -* Copyright (C) 2004-2007 Freescale Semiconductor, Inc. +* Copyright (C) 2004-2007, 2013 Freescale Semiconductor, Inc. * TsiChung Liew (Tsi-Chung.Liew at freescale.com) +* Chao Fu (B44548 at freesacle.com) * * SPDX-License-Identifier: GPL-2.0+ */
@@ -19,8 +20,7 @@ typedef struct dspi {u32 sr;/* 0x2C */ u32 irsr;/* 0x30 */ u32 tfr;/* 0x34 - PUSHR */ -u16 resv1;/* 0x38 */ -u16 rfr;/* 0x3A - POPR */ +u32 rfr;/* 0x38 - POPR */ #ifdef CONFIG_MCF547x_8xu32 tfdr[4 ];/* 0x3C */ u8 resv2[0x30 ];/* 0x40 */
Signature · 1 line
1.8.4
PATCH v3 2/4 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.
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
@@ -165,6 +165,7 @@ struct anadig_reg {#define CCM_REG_CTRL_MASK 0xffffffff#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_IOMUXC_CTRL_MASK (0x3 << 16)
arch/arm/include/asm/arch-vf610/iomux-vf610.h +8 -0
@@ -19,6 +19,10 @@#define VF610_DDR_PAD_CTRL PAD_CTL_DSE_25ohm#define VF610_I2C_PAD_CTRL (PAD_CTL_PUS_47K_UP | PAD_CTL_DSE_50ohm | \ PAD_CTL_SPEED_HIGH | 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 ),
@@ -41,6 +45,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_DDR_A15__DDR_A_15 =IOMUX_PAD (0x0220 ,0x0220 ,0 , __NA_,0 ,VF610_DDR_PAD_CTRL ),VF610_PAD_DDR_A14__DDR_A_14 =IOMUX_PAD (0x0224 ,0x0224 ,0 , __NA_,0 ,VF610_DDR_PAD_CTRL ), VF610_PAD_DDR_A13__DDR_A_13 = IOMUX_PAD(0x0228, 0x0228, 0, __NA_, 0, VF610_DDR_PAD_CTRL),
arch/arm/include/asm/imx-common/iomux-v3.h +2 -0
@@ -124,6 +124,8 @@ typedef u64 iomux_v3_cfg_t;#define PAD_CTL_PUS_100K_UP (2 << 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 v3 3/4 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.
board/freescale/vf610twr/vf610twr.c | 15 ++++++++++++++- include/configs/vf610twr.h | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
board/freescale/vf610twr/vf610twr.c +14 -1
@@ -278,6 +278,18 @@ static void setup_iomux_i2c(void)imx_iomux_v3_setup_multiple_pads (i2c0_pads,ARRAY_SIZE (i2c0_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},
@@ -315,7 +327,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,
@@ -386,6 +398,7 @@ int board_early_init_f(void)setup_iomux_uart ();setup_iomux_enet ();setup_iomux_i2c (); +setup_iomux_dspi ();return 0 ; }
include/configs/vf610twr.h +15 -0
@@ -74,6 +74,21 @@#define CONFIG_SYS_I2C_MXC #define CONFIG_SYS_SPD_BUS_NUM 0 +/* DSPI Configs */ +#define CONFIG_CMD_SPI +#define CONFIG_CMD_SF +#define CONFIG_FSL_DSPI +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_ATMEL +#define MMAP_DSPI SPI0_BASE_ADDR +#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)) +#define CONFIG_BOOTDELAY 3#define CONFIG_LOADADDR 0x82000000
Signature · 1 line
1.8.4
PATCH v3 4/4 mtd:vf610twr:add flash at26df081a for vf610twr platform
In reply to Chao FuFrom: Chao Fu <[email protected]>
AT26DF081 is used on vf610twr board through the DSPI bus, this patch add AT26DF081 into the spi flash params table.
---
Change in v2: None
Change in v3: None
drivers/mtd/spi/sf_probe.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/spi/sf_probe.c +1 -0
@@ -47,6 +47,7 @@ static const struct spi_flash_params spi_flash_params_table[] = { {"AT45DB321D", 0x1f2700, 0x0, 64 * 1024, 64, SECT_4K}, {"AT45DB641D", 0x1f2800, 0x0, 64 * 1024, 128, SECT_4K}, {"AT25DF321", 0x1f4701, 0x0, 64 * 1024, 64, SECT_4K}, + {"AT26DF081", 0x1f4501, 0x0, 64 * 1024, 64, SECT_4K}, #endif #ifdef CONFIG_SPI_FLASH_EON /* EON */ {"EN25Q32B", 0x1c3016, 0x0, 64 * 1024, 64, 0},
Signature · 1 line
1.8.4