ARM: keystone: aemif: move aemif driver to drivers/memory/ti-aemif.c
PATCH 1/1 ARM: keystone: aemif: move aemif driver to drivers/memory/ti-aemif.c
Move AEMIF driver to drivers/memory/ti-aemif.c along with AEMIF definitions collected in drivers/memory/ti-aemif.h
---
Based on [U-boot] [PATCH] mtd: nand: davinci: add header file for driver definitions
arch/arm/cpu/armv7/keystone/Makefile | 1 - arch/arm/include/asm/arch-keystone/aemif.h | 16 --------- arch/arm/include/asm/arch-keystone/hardware-k2hk.h | 7 ---- arch/arm/include/asm/arch-keystone/hardware.h | 30 +++-------------- board/ti/k2hk_evm/board.c | 10 +++--- drivers/Makefile | 1 + drivers/memory/Makefile | 1 + .../keystone/aemif.c => drivers/memory/ti-aemif.c | 37 ++++++++++++-------- drivers/memory/ti-aemif.h | 39 ++++++++++++++++++++++ include/configs/k2hk_evm.h | 4 +++ 10 files changed, 77 insertions(+), 69 deletions(-) delete mode 100644 arch/arm/include/asm/arch-keystone/aemif.h create mode 100644 drivers/memory/Makefile rename arch/arm/cpu/armv7/keystone/aemif.c => drivers/memory/ti-aemif.c (63%) create mode 100644 drivers/memory/ti-aemif.h
arch/arm/cpu/armv7/keystone/Makefile +0 -1
@@ -5,7 +5,6 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += aemif.o obj-y += init.o obj-y += psc.o obj-y += clock.o
arch/arm/include/asm/arch-keystone/aemif.h deleted +0 -16
@@ -1,16 +0,0 @@ -/* -* emif definitions to re-use davinci emif driver on Keystone2 -* -* (C) Copyright 2012-2014 -* Texas Instruments Incorporated, <www.ti.com> -* (C) Copyright 2007 Sergey Kubushyn <[email protected]> -* -* SPDX-License-Identifier: GPL-2.0+ -*/ -#ifndef _AEMIF_H_ -#define _AEMIF_H_ - -#include <asm/arch/hardware.h> - - -#endif
arch/arm/include/asm/arch-keystone/hardware-k2hk.h +0 -7
@@ -9,13 +9,6 @@#ifndef __ASM_ARCH_HARDWARE_K2HK_H#define __ASM_ARCH_HARDWARE_K2HK_H -#define K2HK_ASYNC_EMIF_CNTRL_BASE 0x21000a00 -#define DAVINCI_ASYNC_EMIF_CNTRL_BASE K2HK_ASYNC_EMIF_CNTRL_BASE -#define K2HK_ASYNC_EMIF_DATA_CE0_BASE 0x30000000 -#define K2HK_ASYNC_EMIF_DATA_CE1_BASE 0x34000000 -#define K2HK_ASYNC_EMIF_DATA_CE2_BASE 0x38000000 -#define K2HK_ASYNC_EMIF_DATA_CE3_BASE 0x3c000000 -#define K2HK_PLL_CNTRL_BASE 0x02310000#define CLOCK_BASE K2HK_PLL_CNTRL_BASE#define KS2_RSTCTRL (K2HK_PLL_CNTRL_BASE + 0xe8)
arch/arm/include/asm/arch-keystone/hardware.h +4 -26
@@ -22,32 +22,6 @@typedef volatile unsigned int dv_reg ;typedef volatile unsigned int *dv_reg_p ; -#define ASYNC_EMIF_NUM_CS 4 -#define ASYNC_EMIF_MODE_NOR 0 -#define ASYNC_EMIF_MODE_NAND 1 -#define ASYNC_EMIF_MODE_ONENAND 2 -#define ASYNC_EMIF_PRESERVE -1 - -struct async_emif_config { -unsigned mode; -unsigned select_strobe; -unsigned extend_wait; -unsigned wr_setup; -unsigned wr_strobe; -unsigned wr_hold; -unsigned rd_setup; -unsigned rd_strobe; -unsigned rd_hold; -unsigned turn_around; -enum { -ASYNC_EMIF_8 =0 , -ASYNC_EMIF_16 =1 , -ASYNC_EMIF_32 =2 , - } width; -}; - -void init_async_emif (int num_cs,struct async_emif_config *config); -struct ddr3_phy_config {unsigned int pllcr;unsigned int pgcr1_mask;
@@ -145,6 +119,10 @@ struct ddr3_emif_config {#define KS2_UART0_BASE 0x02530c00#define KS2_UART1_BASE 0x02531000 +/* AEMIF */ +#define KS2_AEMIF_CNTRL_BASE 0x21000a00 +#define DAVINCI_ASYNC_EMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE +#ifdef CONFIG_SOC_K2HK #include <asm/arch/hardware-k2hk.h> #endif
board/ti/k2hk_evm/board.c +5 -5
@@ -16,9 +16,9 @@#include <asm/arch/clock.h> #include <asm/io.h> #include <asm/mach-types.h> -#include <asm/arch/nand_defs.h> #include <asm/arch/emac_defs.h> #include <asm/arch/psc_defs.h> +#include <../drivers/memory/ti-aemif.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -40,9 +40,9 @@ unsigned int external_clk[ext_clk_count] = {what is that */ }; -static struct async_emif_config async_emif_config[ASYNC_EMIF_NUM_CS ] = { +static struct aemif_config aemif_configs[] = { {/* CS0 */ - .mode =ASYNC_EMIF_MODE_NAND , + .mode =AEMIF_MODE_NAND , .wr_setup =0xf , .wr_strobe =0x3f , .wr_hold =7 ,
@@ -50,7 +50,7 @@ static struct async_emif_config async_emif_config[ASYNC_EMIF_NUM_CS] = { .rd_strobe = 0x3f, .rd_hold = 7, .turn_around = 3, - .width = ASYNC_EMIF_8, + .width = AEMIF_WIDTH_8, }, };
@@ -67,7 +67,7 @@ int dram_init(void) gd->ram_size =get_ram_size ((long *)CONFIG_SYS_SDRAM_BASE ,CONFIG_MAX_RAM_BANK_SIZE ); -init_async_emif (ARRAY_SIZE (async_emif_config), async_emif_config); +aemif_init (sizeof (aemif_configs), aemif_configs);return 0 ; }
drivers/Makefile +1 -0
@@ -14,3 +14,4 @@ obj-y += twserial/ obj-y += video/ obj-y += watchdog/ obj-$(CONFIG_QE) += qe/ +obj-y += memory/
drivers/memory/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_TI_AEMIF) += ti-aemif.o
drivers/memory/ti-aemif.c renamed from arch/arm/cpu/armv7/keystone/aemif.c +23 -14
@@ -8,9 +8,13 @@*/ #include <common.h> -#include <asm/io.h> -#include <asm/arch/clock.h> -#include <../drivers/mtd/nand/davinci_nand.h> +#include "ti-aemif.h" + +#define AEMIF_WAITCYCLE_CONFIG (CONFIG_AEMIF_CNTRL_BASE + 0x4) +#define AEMIF_NAND_CONTROL (CONFIG_AEMIF_CNTRL_BASE + 0x60) +#define AEMIF_ONENAND_CONTROL (CONFIG_AEMIF_CNTRL_BASE + 0x5c) +#define AEMIF_CONFIG (cs) (CONFIG_AEMIF_CNTRL_BASE + 0x10 \ + + (cs * 4))#define AEMIF_CFG_SELECT_STROBE (v) ((v) ? 1 << 31 : 0)#define AEMIF_CFG_EXTEND_WAIT (v) ((v) ? 1 << 30 : 0)
@@ -31,22 +35,22 @@ } \ }while (0 ) -void configure_async_emif(int cs, struct async_emif_config *cfg) +static void aemif_configure(int cs, struct aemif_config *cfg) {unsigned long tmp; -if (cfg->mode ==ASYNC_EMIF_MODE_NAND ) { - tmp =__raw_readl (&davinci_emif_regs->nandfcr); +if (cfg->mode ==AEMIF_MODE_NAND ) { + tmp =__raw_readl (AEMIF_NAND_CONTROL ); tmp |= (1 << cs); -__raw_writel (tmp, &davinci_emif_regs->nandfcr); +__raw_writel (tmp,AEMIF_NAND_CONTROL ); - }else if (cfg->mode ==ASYNC_EMIF_MODE_ONENAND ) { - tmp =__raw_readl (&davinci_emif_regs->one_nand_cr); + }else if (cfg->mode ==AEMIF_MODE_ONENAND ) { + tmp =__raw_readl (AEMIF_ONENAND_CONTROL ); tmp |= (1 << cs); -__raw_writel (tmp, &davinci_emif_regs->one_nand_cr); +__raw_writel (tmp,AEMIF_ONENAND_CONTROL ); } - tmp =__raw_readl (&davinci_emif_regs->abncr[cs]); + tmp =__raw_readl (AEMIF_CONFIG (cs));set_config_field (tmp,SELECT_STROBE , cfg->select_strobe);set_config_field (tmp,EXTEND_WAIT , cfg->extend_wait);
@@ -59,13 +63,18 @@ void configure_async_emif(int cs, struct async_emif_config *cfg)set_config_field (tmp,TURN_AROUND , cfg->turn_around);set_config_field (tmp,WIDTH , cfg->width); -__raw_writel (tmp, &davinci_emif_regs->abncr[cs]); +__raw_writel (tmp,AEMIF_CONFIG (cs)); } -void init_async_emif (int num_cs,struct async_emif_config *config) +void aemif_init (int num_cs,struct aemif_config *config) {int cs; +if (num_cs >AEMIF_NUM_CS ) { + num_cs =AEMIF_NUM_CS ; +printf ("AEMIF: csnum has to be <= 5" ); + } +for (cs =0 ; cs < num_cs; cs++) -configure_async_emif (cs, config + cs); +aemif_configure (cs, config + cs); }
drivers/memory/ti-aemif.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* AEMIF definitions +* +* (C) Copyright 2012-2014 +* Texas Instruments Incorporated, <www.ti.com> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _AEMIF_H_ +#define _AEMIF_H_ + +#define AEMIF_NUM_CS 4 +#define AEMIF_MODE_NOR 0 +#define AEMIF_MODE_NAND 1 +#define AEMIF_MODE_ONENAND 2 +#define AEMIF_PRESERVE -1 + +struct aemif_config { +unsigned mode; +unsigned select_strobe; +unsigned extend_wait; +unsigned wr_setup; +unsigned wr_strobe; +unsigned wr_hold; +unsigned rd_setup; +unsigned rd_strobe; +unsigned rd_hold; +unsigned turn_around; +enum { +AEMIF_WIDTH_8 =0 , +AEMIF_WIDTH_16 =1 , +AEMIF_WIDTH_32 =2 , + } width; +}; + +void aemif_init (int num_cs,struct aemif_config *config); + +#endif
include/configs/k2hk_evm.h +4 -0
@@ -129,6 +129,10 @@#define CONFIG_SYS_SGMII_LINERATE_MHZ 1250#define CONFIG_SYS_SGMII_RATESCALE 2 +/* AEMIF */ +#define CONFIG_TI_AEMIF +#define CONFIG_AEMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE +/* NAND Configuration */ #define CONFIG_NAND_DAVINCI #define CONFIG_CMD_NAND_ECCLAYOUT
Signature · 1 line
1.8.3.2
PATCH 1/1 ARM: keystone: aemif: move aemif driver to drivers/memory/ti-aemif.c
Quoted 313 lines · Ivan Khoronzhuk
Move AEMIF driver to
drivers/memory/ti-aemif.calong with AEMIF definitions collected indrivers/memory/ti-aemif.hAcked-by Vitaly Andrianov <[email protected]>Signed-off-by Ivan Khoronzhuk <[email protected]>---
Based on [U-boot] [PATCH] mtd: nand: davinci: add header file for driver definitions
arch/arm/cpu/armv7/keystone/Makefile | 1 - arch/arm/include/asm/arch-keystone/aemif.h | 16 --------- arch/arm/include/asm/arch-keystone/hardware-k2hk.h | 7 ---- arch/arm/include/asm/arch-keystone/hardware.h | 30 +++-------------- board/ti/k2hk_evm/board.c | 10 +++--- drivers/Makefile | 1 + drivers/memory/Makefile | 1 + .../keystone/aemif.c => drivers/memory/ti-aemif.c | 37 ++++++++++++-------- drivers/memory/ti-aemif.h | 39 ++++++++++++++++++++++ include/configs/k2hk_evm.h | 4 +++ 10 files changed, 77 insertions(+), 69 deletions(-)delete mode 100644
arch/arm/include/asm/arch-keystone/aemif.hcreate mode 100644drivers/memory/Makefile
renamearch/arm/cpu/armv7/keystone/aemif.c=>drivers/memory/ti-aemif.c(63%) create mode 100644drivers/memory/ti-aemif.harch/arm/cpu/armv7/keystone/Makefile +0
-1@@ -5,7 +5,6 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += aemif.o obj-y += init.o obj-y += psc.o obj-y += clock.oarch/arm/include/asm/arch-keystone/aemif.h deleted +0
-16@@ -1,16 +0,0 @@ -/* -* emif definitions to re-use davinci emif driver on Keystone2 -* -* (C) Copyright 2012-2014 -* Texas Instruments Incorporated, <www.ti.com> -* (C) Copyright 2007 Sergey Kubushyn <[email protected]> -* -* SPDX-License-Identifier: GPL-2.0+ -*/ -#ifndef _AEMIF_H_ -#define _AEMIF_H_ - -#include <asm/arch/hardware.h> - - -#endif arch/arm/include/asm/arch-keystone/hardware-k2hk.h +0
-7@@ -9,13 +9,6 @@#ifndef __ASM_ARCH_HARDWARE_K2HK_H#define __ASM_ARCH_HARDWARE_K2HK_H -#define K2HK_ASYNC_EMIF_CNTRL_BASE 0x21000a00 -#define DAVINCI_ASYNC_EMIF_CNTRL_BASE K2HK_ASYNC_EMIF_CNTRL_BASE -#define K2HK_ASYNC_EMIF_DATA_CE0_BASE 0x30000000 -#define K2HK_ASYNC_EMIF_DATA_CE1_BASE 0x34000000 -#define K2HK_ASYNC_EMIF_DATA_CE2_BASE 0x38000000 -#define K2HK_ASYNC_EMIF_DATA_CE3_BASE 0x3c000000 -#define K2HK_PLL_CNTRL_BASE 0x02310000#define CLOCK_BASE K2HK_PLL_CNTRL_BASE#define KS2_RSTCTRL (K2HK_PLL_CNTRL_BASE + 0xe8)arch/arm/include/asm/arch-keystone/hardware.h +4
-26@@ -22,32 +22,6 @@typedef volatile unsigned int dv_reg ;typedef volatile unsigned int *dv_reg_p ; -#define ASYNC_EMIF_NUM_CS 4 -#define ASYNC_EMIF_MODE_NOR 0 -#define ASYNC_EMIF_MODE_NAND 1 -#define ASYNC_EMIF_MODE_ONENAND 2 -#define ASYNC_EMIF_PRESERVE -1 - -struct async_emif_config { -unsigned mode; -unsigned select_strobe; -unsigned extend_wait; -unsigned wr_setup; -unsigned wr_strobe; -unsigned wr_hold; -unsigned rd_setup; -unsigned rd_strobe; -unsigned rd_hold; -unsigned turn_around; -enum { -ASYNC_EMIF_8 =0 , -ASYNC_EMIF_16 =1 , -ASYNC_EMIF_32 =2 , - } width; -}; - -void init_async_emif (int num_cs,struct async_emif_config *config); -struct ddr3_phy_config {unsigned int pllcr;unsigned int pgcr1_mask;@@ -145,6 +119,10 @@ struct ddr3_emif_config {#define KS2_UART0_BASE 0x02530c00#define KS2_UART1_BASE 0x02531000 +/* AEMIF */ +#define KS2_AEMIF_CNTRL_BASE 0x21000a00 +#define DAVINCI_ASYNC_EMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE +#ifdef CONFIG_SOC_K2HK #include <asm/arch/hardware-k2hk.h> #endif board/ti/k2hk_evm/board.c +5
-5@@ -16,9 +16,9 @@#include <asm/arch/clock.h> #include <asm/io.h> #include <asm/mach-types.h> -#include <asm/arch/nand_defs.h> #include <asm/arch/emac_defs.h> #include <asm/arch/psc_defs.h> +#include <../drivers/memory/ti-aemif.h> DECLARE_GLOBAL_DATA_PTR ;@@ -40,9 +40,9 @@ unsigned int external_clk[ext_clk_count] = {what is that */ }; -static struct async_emif_config async_emif_config[ASYNC_EMIF_NUM_CS ] = { +static struct aemif_config aemif_configs[] = { {/* CS0 */ - .mode =ASYNC_EMIF_MODE_NAND , + .mode =AEMIF_MODE_NAND , .wr_setup =0xf , .wr_strobe =0x3f , .wr_hold =7 ,@@ -50,7 +50,7 @@ static struct async_emif_config async_emif_config[ASYNC_EMIF_NUM_CS] = { .rd_strobe = 0x3f, .rd_hold = 7, .turn_around = 3, - .width = ASYNC_EMIF_8, + .width = AEMIF_WIDTH_8, }, };@@ -67,7 +67,7 @@ int dram_init(void) gd->ram_size =get_ram_size ((long *)CONFIG_SYS_SDRAM_BASE ,CONFIG_MAX_RAM_BANK_SIZE ); -init_async_emif (ARRAY_SIZE (async_emif_config), async_emif_config); +aemif_init (sizeof (aemif_configs), aemif_configs);return 0 ; }drivers/Makefile +1
-0@@ -14,3 +14,4 @@ obj-y += twserial/ obj-y += video/ obj-y += watchdog/ obj-$(CONFIG_QE) += qe/ +obj-y += memory/drivers/memory/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_TI_AEMIF) += ti-aemif.odrivers/memory/ti-aemif.c renamed from arch/arm/cpu/armv7/keystone/aemif.c +23
-14@@ -8,9 +8,13 @@*/ #include <common.h> -#include <asm/io.h> -#include <asm/arch/clock.h> -#include <../drivers/mtd/nand/davinci_nand.h> +#include "ti-aemif.h" + +#define AEMIF_WAITCYCLE_CONFIG (CONFIG_AEMIF_CNTRL_BASE + 0x4) +#define AEMIF_NAND_CONTROL (CONFIG_AEMIF_CNTRL_BASE + 0x60) +#define AEMIF_ONENAND_CONTROL (CONFIG_AEMIF_CNTRL_BASE + 0x5c) +#define AEMIF_CONFIG (cs) (CONFIG_AEMIF_CNTRL_BASE + 0x10 \ + + (cs * 4))#define AEMIF_CFG_SELECT_STROBE (v) ((v) ? 1 << 31 : 0)#define AEMIF_CFG_EXTEND_WAIT (v) ((v) ? 1 << 30 : 0)@@ -31,22 +35,22 @@ } \ }while (0 ) -void configure_async_emif(int cs, struct async_emif_config *cfg) +static void aemif_configure(int cs, struct aemif_config *cfg) {unsigned long tmp; -if (cfg->mode ==ASYNC_EMIF_MODE_NAND ) { - tmp =__raw_readl (&davinci_emif_regs->nandfcr); +if (cfg->mode ==AEMIF_MODE_NAND ) { + tmp =__raw_readl (AEMIF_NAND_CONTROL ); tmp |= (1 << cs); -__raw_writel (tmp, &davinci_emif_regs->nandfcr); +__raw_writel (tmp,AEMIF_NAND_CONTROL ); - }else if (cfg->mode ==ASYNC_EMIF_MODE_ONENAND ) { - tmp =__raw_readl (&davinci_emif_regs->one_nand_cr); + }else if (cfg->mode ==AEMIF_MODE_ONENAND ) { + tmp =__raw_readl (AEMIF_ONENAND_CONTROL ); tmp |= (1 << cs); -__raw_writel (tmp, &davinci_emif_regs->one_nand_cr); +__raw_writel (tmp,AEMIF_ONENAND_CONTROL ); } - tmp =__raw_readl (&davinci_emif_regs->abncr[cs]); + tmp =__raw_readl (AEMIF_CONFIG (cs));set_config_field (tmp,SELECT_STROBE , cfg->select_strobe);set_config_field (tmp,EXTEND_WAIT , cfg->extend_wait);@@ -59,13 +63,18 @@ void configure_async_emif(int cs, struct async_emif_config *cfg)set_config_field (tmp,TURN_AROUND , cfg->turn_around);set_config_field (tmp,WIDTH , cfg->width); -__raw_writel (tmp, &davinci_emif_regs->abncr[cs]); +__raw_writel (tmp,AEMIF_CONFIG (cs)); } -void init_async_emif (int num_cs,struct async_emif_config *config) +void aemif_init (int num_cs,struct aemif_config *config) {int cs; +if (num_cs >AEMIF_NUM_CS ) { + num_cs =AEMIF_NUM_CS ; +printf ("AEMIF: csnum has to be <= 5" ); + } +for (cs =0 ; cs < num_cs; cs++) -configure_async_emif (cs, config + cs); +aemif_configure (cs, config + cs); }drivers/memory/ti-aemif.h new file +39
-0@@ -0,0 +1,39 @@ +/* +* AEMIF definitions +* +* (C) Copyright 2012-2014 +* Texas Instruments Incorporated, <www.ti.com> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _AEMIF_H_ +#define _AEMIF_H_ + +#define AEMIF_NUM_CS 4 +#define AEMIF_MODE_NOR 0 +#define AEMIF_MODE_NAND 1 +#define AEMIF_MODE_ONENAND 2 +#define AEMIF_PRESERVE -1 + +struct aemif_config { +unsigned mode; +unsigned select_strobe; +unsigned extend_wait; +unsigned wr_setup; +unsigned wr_strobe; +unsigned wr_hold; +unsigned rd_setup; +unsigned rd_strobe; +unsigned rd_hold; +unsigned turn_around; +enum { +AEMIF_WIDTH_8 =0 , +AEMIF_WIDTH_16 =1 , +AEMIF_WIDTH_32 =2 , + } width; +}; + +void aemif_init (int num_cs,struct aemif_config *config); + +#endif include/configs/k2hk_evm.h +0
-0
include/configs/k2hk_evm.h line 138
Quoted 10 lines
include/configs/k2hk_evm.h +4
-0@@ -129,6 +129,10 @@#define CONFIG_SYS_SGMII_LINERATE_MHZ 1250#define CONFIG_SYS_SGMII_RATESCALE 2 +/* AEMIF */ +#define CONFIG_TI_AEMIF +#define CONFIG_AEMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE +/* NAND Configuration */ #define CONFIG_NAND_DAVINCI #define CONFIG_CMD_NAND_ECCLAYOUT
I think this looks good. Moving driver to memory makes it similar to kernel. Make sure the header
files are arranged in a similar fashion. I got confused with the first patch.
Murali
PATCH 1/1 ARM: keystone: aemif: move aemif driver to drivers/memory/ti-aemif.c
Quoted 321 lines · Murali Karicheri
Quoted 306 lines · Ivan Khoronzhuk
Move AEMIF driver to
drivers/memory/ti-aemif.calong with AEMIF definitions collected indrivers/memory/ti-aemif.hAcked-by Vitaly Andrianov <[email protected]>Signed-off-by Ivan Khoronzhuk <[email protected]>---
Based on [U-boot] [PATCH] mtd: nand: davinci: add header file for driver definitions
arch/arm/cpu/armv7/keystone/Makefile | 1 - arch/arm/include/asm/arch-keystone/aemif.h | 16 --------- arch/arm/include/asm/arch-keystone/hardware-k2hk.h | 7 ---- arch/arm/include/asm/arch-keystone/hardware.h | 30 +++-------------- board/ti/k2hk_evm/board.c | 10 +++--- drivers/Makefile | 1 + drivers/memory/Makefile | 1 + .../keystone/aemif.c => drivers/memory/ti-aemif.c | 37 ++++++++++++-------- drivers/memory/ti-aemif.h | 39 ++++++++++++++++++++++ include/configs/k2hk_evm.h | 4 +++ 10 files changed, 77 insertions(+), 69 deletions(-)delete mode 100644
arch/arm/include/asm/arch-keystone/aemif.hcreate mode 100644drivers/memory/Makefile
renamearch/arm/cpu/armv7/keystone/aemif.c=>drivers/memory/ti-aemif.c(63%)
create mode 100644drivers/memory/ti-aemif.harch/arm/cpu/armv7/keystone/Makefile +0
-0@@ -5,7 +5,6 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += aemif.o obj-y += init.o obj-y += psc.o obj-y += clock.oarch/arm/include/asm/arch-keystone/aemif.h deleted +0
-16@@ -1,16 +0,0 @@ -/* -* emif definitions to re-use davinci emif driver on Keystone2 -* -* (C) Copyright 2012-2014 -* Texas Instruments Incorporated, <www.ti.com> -* (C) Copyright 2007 Sergey Kubushyn <[email protected]> -* -* SPDX-License-Identifier: GPL-2.0+ -*/ -#ifndef _AEMIF_H_ -#define _AEMIF_H_ - -#include <asm/arch/hardware.h> - - -#endif arch/arm/include/asm/arch-keystone/hardware-k2hk.h +0
-6@@ -9,13 +9,6 @@#ifndef __ASM_ARCH_HARDWARE_K2HK_H#define __ASM_ARCH_HARDWARE_K2HK_H -#define K2HK_ASYNC_EMIF_CNTRL_BASE 0x21000a00 -#define DAVINCI_ASYNC_EMIF_CNTRL_BASE K2HK_ASYNC_EMIF_CNTRL_BASE -#define K2HK_ASYNC_EMIF_DATA_CE0_BASE 0x30000000 -#define K2HK_ASYNC_EMIF_DATA_CE1_BASE 0x34000000 -#define K2HK_ASYNC_EMIF_DATA_CE2_BASE 0x38000000 -#define K2HK_ASYNC_EMIF_DATA_CE3_BASE 0x3c000000 -#define K2HK_PLL_CNTRL_BASE 0x02310000#define CLOCK_BASE K2HK_PLL_CNTRL_BASE#define KS2_RSTCTRL (K2HK_PLL_CNTRL_BASE + 0xe8)arch/arm/include/asm/arch-keystone/hardware.h +3
-25@@ -22,32 +22,6 @@typedef volatile unsigned int dv_reg ;typedef volatile unsigned int *dv_reg_p ; -#define ASYNC_EMIF_NUM_CS 4 -#define ASYNC_EMIF_MODE_NOR 0 -#define ASYNC_EMIF_MODE_NAND 1 -#define ASYNC_EMIF_MODE_ONENAND 2 -#define ASYNC_EMIF_PRESERVE -1 - -struct async_emif_config { -unsigned mode; -unsigned select_strobe; -unsigned extend_wait; -unsigned wr_setup; -unsigned wr_strobe; -unsigned wr_hold; -unsigned rd_setup; -unsigned rd_strobe; -unsigned rd_hold; -unsigned turn_around; -enum { -ASYNC_EMIF_8 =0 , -ASYNC_EMIF_16 =1 , -ASYNC_EMIF_32 =2 , - } width; -}; - -void init_async_emif (int num_cs,struct async_emif_config *config); -struct ddr3_phy_config {unsigned int pllcr;unsigned int pgcr1_mask;@@ -145,6 +119,10 @@ struct ddr3_emif_config {#define KS2_UART0_BASE 0x02530c00#define KS2_UART1_BASE 0x02531000 +/* AEMIF */ +#define KS2_AEMIF_CNTRL_BASE 0x21000a00 +#define DAVINCI_ASYNC_EMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE +#ifdef CONFIG_SOC_K2HK #include <asm/arch/hardware-k2hk.h> #endif board/ti/k2hk_evm/board.c +1
-1@@ -16,9 +16,9 @@#include <asm/arch/clock.h> #include <asm/io.h> #include <asm/mach-types.h> -#include <asm/arch/nand_defs.h> #include <asm/arch/emac_defs.h> #include <asm/arch/psc_defs.h> +#include <../drivers/memory/ti-aemif.h> DECLARE_GLOBAL_DATA_PTR; @@ -40,9 +40,9 @@ unsigned int external_clk[ext_clk_count] = { what is that */ };
-static structasync_emif_config
async_emif_config[ASYNC_EMIF_NUM_CS] = {board/ti/k2hk_evm/board.c +4
-3+static struct aemif_config aemif_configs[] = { {/* CS0 */ - .mode = ASYNC_EMIF_MODE_NAND, + .mode =AEMIF_MODE_NAND , .wr_setup =0xf , .wr_strobe =0x3f , .wr_hold =7 ,@@ -50,7 +50,7 @@ static struct async_emif_config async_emif_config[ASYNC_EMIF_NUM_CS] = { .rd_strobe = 0x3f, .rd_hold = 7, .turn_around = 3, - .width = ASYNC_EMIF_8, + .width = AEMIF_WIDTH_8, }, };@@ -67,7 +67,7 @@ int dram_init(void) gd->ram_size =get_ram_size ((long *)CONFIG_SYS_SDRAM_BASE ,CONFIG_MAX_RAM_BANK_SIZE ); -init_async_emif (ARRAY_SIZE (async_emif_config), async_emif_config); +aemif_init (sizeof (aemif_configs), aemif_configs);return 0 ; } diff --git a/drivers/Makefile b/drivers/Makefileindex 5d03f37..b23076f 100644
drivers/Makefile +1
-0@@ -14,3 +14,4 @@ obj-y += twserial/ obj-y += video/ obj-y += watchdog/ obj-$(CONFIG_QE) += qe/ +obj-y += memory/drivers/memory/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_TI_AEMIF) += ti-aemif.odrivers/memory/ti-aemif.c renamed from arch/arm/cpu/armv7/keystone/aemif.c +22
-8@@ -8,9 +8,13 @@*/ #include <common.h> -#include <asm/io.h> -#include <asm/arch/clock.h> -#include <../drivers/mtd/nand/davinci_nand.h> +#include "ti-aemif.h" + +#define AEMIF_WAITCYCLE_CONFIG (CONFIG_AEMIF_CNTRL_BASE + 0x4) +#define AEMIF_NAND_CONTROL (CONFIG_AEMIF_CNTRL_BASE + 0x60) +#define AEMIF_ONENAND_CONTROL (CONFIG_AEMIF_CNTRL_BASE + 0x5c) +#define AEMIF_CONFIG (cs) (CONFIG_AEMIF_CNTRL_BASE + 0x10 \ + + (cs * 4))#define AEMIF_CFG_SELECT_STROBE (v) ((v) ? 1 << 31 : 0)#define AEMIF_CFG_EXTEND_WAIT (v) ((v) ? 1 << 30 : 0)@@ -31,22 +35,22 @@ } \ }while (0 ) -void configure_async_emif(int cs, struct async_emif_config *cfg) +static void aemif_configure (int cs,struct aemif_config *cfg) {unsigned long tmp; - if (cfg->mode == ASYNC_EMIF_MODE_NAND) { - tmp =__raw_readl (&davinci_emif_regs->nandfcr); +if (cfg->mode ==AEMIF_MODE_NAND ) { + tmp =__raw_readl (AEMIF_NAND_CONTROL ); tmp |= (1 << cs); -__raw_writel (tmp, &davinci_emif_regs->nandfcr); +__raw_writel (tmp,AEMIF_NAND_CONTROL ); - } else if (cfg->mode == ASYNC_EMIF_MODE_ONENAND) { - tmp =__raw_readl (&davinci_emif_regs->one_nand_cr); + }else if (cfg->mode ==AEMIF_MODE_ONENAND ) { + tmp =__raw_readl (AEMIF_ONENAND_CONTROL ); tmp |= (1 << cs); -__raw_writel (tmp, &davinci_emif_regs->one_nand_cr); +__raw_writel (tmp,AEMIF_ONENAND_CONTROL ); } - tmp =__raw_readl (&davinci_emif_regs->abncr[cs]); + tmp =__raw_readl (AEMIF_CONFIG (cs));set_config_field (tmp,SELECT_STROBE , cfg->select_strobe);set_config_field (tmp,EXTEND_WAIT , cfg->extend_wait);@@ -59,13 +63,18 @@ void configure_async_emif(int cs, struct async_emif_config *cfg) set_config_field(tmp, TURN_AROUND, cfg->turn_around);set_config_field (tmp,WIDTH , cfg->width); -__raw_writel (tmp, &davinci_emif_regs->abncr[cs]); +__raw_writel (tmp,AEMIF_CONFIG (cs)); } -void init_async_emif(int num_cs, struct async_emif_config *config) +void aemif_init (int num_cs,struct aemif_config *config) {int cs; + if (num_cs > AEMIF_NUM_CS) { + num_cs =AEMIF_NUM_CS ; +printf ("AEMIF: csnum has to be <= 5" ); + } +for (cs =0 ; cs < num_cs; cs++) -configure_async_emif (cs, config + cs); +aemif_configure (cs, config + cs); }drivers/memory/ti-aemif.h new file +39
-0@@ -0,0 +1,39 @@ +/* +* AEMIF definitions +* +* (C) Copyright 2012-2014 +* Texas Instruments Incorporated, <www.ti.com> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _AEMIF_H_ +#define _AEMIF_H_ + +#define AEMIF_NUM_CS 4 +#define AEMIF_MODE_NOR 0 +#define AEMIF_MODE_NAND 1 +#define AEMIF_MODE_ONENAND 2 +#define AEMIF_PRESERVE -1 + +struct aemif_config { +unsigned mode; +unsigned select_strobe; +unsigned extend_wait; +unsigned wr_setup; +unsigned wr_strobe; +unsigned wr_hold; +unsigned rd_setup; +unsigned rd_strobe; +unsigned rd_hold; +unsigned turn_around; +enum { +AEMIF_WIDTH_8 =0 , +AEMIF_WIDTH_16 =1 , +AEMIF_WIDTH_32 =2 , + } width; +}; + +void aemif_init (int num_cs,struct aemif_config *config); + +#endif include/configs/k2hk_evm.h +0
-0include/configs/k2hk_evm.h line 137
Quoted 9 lines
include/configs/k2hk_evm.h +3
-0@@ -129,6 +129,10 @@#define CONFIG_SYS_SGMII_LINERATE_MHZ 1250#define CONFIG_SYS_SGMII_RATESCALE 2 +/* AEMIF */ +#define CONFIG_TI_AEMIF +#define CONFIG_AEMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE +/* NAND Configuration */ #define CONFIG_NAND_DAVINCI #define CONFIG_CMD_NAND_ECCLAYOUT I think this looks good. Moving driver to memory makes it similar to kernel. Make sure the header
files are arranged in a similar fashion. I got confused with the first patch.
Quoted 1 line
Murali
Seems there is no place for driver headers like in linux. Here is include/linux, but I think it's for code ported from linux. I saw headers along with sources hence I decided that's better place for now.
Signature · 2 lines
Regards, Ivan Khoronzhuk
PATCH 1/1 ARM: keystone: aemif: move aemif driver to drivers/memory/ti-aemif.c
In reply to Murali KaricheriQuoted 321 lines · Murali Karicheri
Quoted 306 lines · Ivan Khoronzhuk
Move AEMIF driver to
drivers/memory/ti-aemif.calong with AEMIF definitions collected indrivers/memory/ti-aemif.hAcked-by Vitaly Andrianov <[email protected]>Signed-off-by Ivan Khoronzhuk <[email protected]>---
Based on [U-boot] [PATCH] mtd: nand: davinci: add header file for driver definitions
arch/arm/cpu/armv7/keystone/Makefile | 1 - arch/arm/include/asm/arch-keystone/aemif.h | 16 --------- arch/arm/include/asm/arch-keystone/hardware-k2hk.h | 7 ---- arch/arm/include/asm/arch-keystone/hardware.h | 30 +++-------------- board/ti/k2hk_evm/board.c | 10 +++--- drivers/Makefile | 1 + drivers/memory/Makefile | 1 + .../keystone/aemif.c => drivers/memory/ti-aemif.c | 37 ++++++++++++-------- drivers/memory/ti-aemif.h | 39 ++++++++++++++++++++++ include/configs/k2hk_evm.h | 4 +++ 10 files changed, 77 insertions(+), 69 deletions(-)delete mode 100644
arch/arm/include/asm/arch-keystone/aemif.hcreate mode 100644drivers/memory/Makefile
renamearch/arm/cpu/armv7/keystone/aemif.c=>drivers/memory/ti-aemif.c(63%)
create mode 100644drivers/memory/ti-aemif.harch/arm/cpu/armv7/keystone/Makefile +0
-0@@ -5,7 +5,6 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += aemif.o obj-y += init.o obj-y += psc.o obj-y += clock.oarch/arm/include/asm/arch-keystone/aemif.h deleted +0
-16@@ -1,16 +0,0 @@ -/* -* emif definitions to re-use davinci emif driver on Keystone2 -* -* (C) Copyright 2012-2014 -* Texas Instruments Incorporated, <www.ti.com> -* (C) Copyright 2007 Sergey Kubushyn <[email protected]> -* -* SPDX-License-Identifier: GPL-2.0+ -*/ -#ifndef _AEMIF_H_ -#define _AEMIF_H_ - -#include <asm/arch/hardware.h> - - -#endif arch/arm/include/asm/arch-keystone/hardware-k2hk.h +0
-6@@ -9,13 +9,6 @@#ifndef __ASM_ARCH_HARDWARE_K2HK_H#define __ASM_ARCH_HARDWARE_K2HK_H -#define K2HK_ASYNC_EMIF_CNTRL_BASE 0x21000a00 -#define DAVINCI_ASYNC_EMIF_CNTRL_BASE K2HK_ASYNC_EMIF_CNTRL_BASE -#define K2HK_ASYNC_EMIF_DATA_CE0_BASE 0x30000000 -#define K2HK_ASYNC_EMIF_DATA_CE1_BASE 0x34000000 -#define K2HK_ASYNC_EMIF_DATA_CE2_BASE 0x38000000 -#define K2HK_ASYNC_EMIF_DATA_CE3_BASE 0x3c000000 -#define K2HK_PLL_CNTRL_BASE 0x02310000#define CLOCK_BASE K2HK_PLL_CNTRL_BASE#define KS2_RSTCTRL (K2HK_PLL_CNTRL_BASE + 0xe8)arch/arm/include/asm/arch-keystone/hardware.h +3
-25@@ -22,32 +22,6 @@typedef volatile unsigned int dv_reg ;typedef volatile unsigned int *dv_reg_p ; -#define ASYNC_EMIF_NUM_CS 4 -#define ASYNC_EMIF_MODE_NOR 0 -#define ASYNC_EMIF_MODE_NAND 1 -#define ASYNC_EMIF_MODE_ONENAND 2 -#define ASYNC_EMIF_PRESERVE -1 - -struct async_emif_config { -unsigned mode; -unsigned select_strobe; -unsigned extend_wait; -unsigned wr_setup; -unsigned wr_strobe; -unsigned wr_hold; -unsigned rd_setup; -unsigned rd_strobe; -unsigned rd_hold; -unsigned turn_around; -enum { -ASYNC_EMIF_8 =0 , -ASYNC_EMIF_16 =1 , -ASYNC_EMIF_32 =2 , - } width; -}; - -void init_async_emif (int num_cs,struct async_emif_config *config); -struct ddr3_phy_config {unsigned int pllcr;unsigned int pgcr1_mask;@@ -145,6 +119,10 @@ struct ddr3_emif_config {#define KS2_UART0_BASE 0x02530c00#define KS2_UART1_BASE 0x02531000 +/* AEMIF */ +#define KS2_AEMIF_CNTRL_BASE 0x21000a00 +#define DAVINCI_ASYNC_EMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE +#ifdef CONFIG_SOC_K2HK #include <asm/arch/hardware-k2hk.h> #endif board/ti/k2hk_evm/board.c +1
-1@@ -16,9 +16,9 @@#include <asm/arch/clock.h> #include <asm/io.h> #include <asm/mach-types.h> -#include <asm/arch/nand_defs.h> #include <asm/arch/emac_defs.h> #include <asm/arch/psc_defs.h> +#include <../drivers/memory/ti-aemif.h> DECLARE_GLOBAL_DATA_PTR; @@ -40,9 +40,9 @@ unsigned int external_clk[ext_clk_count] = { what is that */ };
-static structasync_emif_config
async_emif_config[ASYNC_EMIF_NUM_CS] = {board/ti/k2hk_evm/board.c +4
-3+static struct aemif_config aemif_configs[] = { {/* CS0 */ - .mode = ASYNC_EMIF_MODE_NAND, + .mode =AEMIF_MODE_NAND , .wr_setup =0xf , .wr_strobe =0x3f , .wr_hold =7 ,@@ -50,7 +50,7 @@ static struct async_emif_config async_emif_config[ASYNC_EMIF_NUM_CS] = { .rd_strobe = 0x3f, .rd_hold = 7, .turn_around = 3, - .width = ASYNC_EMIF_8, + .width = AEMIF_WIDTH_8, }, };@@ -67,7 +67,7 @@ int dram_init(void) gd->ram_size =get_ram_size ((long *)CONFIG_SYS_SDRAM_BASE ,CONFIG_MAX_RAM_BANK_SIZE ); -init_async_emif (ARRAY_SIZE (async_emif_config), async_emif_config); +aemif_init (sizeof (aemif_configs), aemif_configs);return 0 ; } diff --git a/drivers/Makefile b/drivers/Makefileindex 5d03f37..b23076f 100644
drivers/Makefile +1
-0@@ -14,3 +14,4 @@ obj-y += twserial/ obj-y += video/ obj-y += watchdog/ obj-$(CONFIG_QE) += qe/ +obj-y += memory/drivers/memory/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_TI_AEMIF) += ti-aemif.odrivers/memory/ti-aemif.c renamed from arch/arm/cpu/armv7/keystone/aemif.c +22
-8@@ -8,9 +8,13 @@*/ #include <common.h> -#include <asm/io.h> -#include <asm/arch/clock.h> -#include <../drivers/mtd/nand/davinci_nand.h> +#include "ti-aemif.h" + +#define AEMIF_WAITCYCLE_CONFIG (CONFIG_AEMIF_CNTRL_BASE + 0x4) +#define AEMIF_NAND_CONTROL (CONFIG_AEMIF_CNTRL_BASE + 0x60) +#define AEMIF_ONENAND_CONTROL (CONFIG_AEMIF_CNTRL_BASE + 0x5c) +#define AEMIF_CONFIG (cs) (CONFIG_AEMIF_CNTRL_BASE + 0x10 \ + + (cs * 4))#define AEMIF_CFG_SELECT_STROBE (v) ((v) ? 1 << 31 : 0)#define AEMIF_CFG_EXTEND_WAIT (v) ((v) ? 1 << 30 : 0)@@ -31,22 +35,22 @@ } \ }while (0 ) -void configure_async_emif(int cs, struct async_emif_config *cfg) +static void aemif_configure (int cs,struct aemif_config *cfg) {unsigned long tmp; - if (cfg->mode == ASYNC_EMIF_MODE_NAND) { - tmp =__raw_readl (&davinci_emif_regs->nandfcr); +if (cfg->mode ==AEMIF_MODE_NAND ) { + tmp =__raw_readl (AEMIF_NAND_CONTROL ); tmp |= (1 << cs); -__raw_writel (tmp, &davinci_emif_regs->nandfcr); +__raw_writel (tmp,AEMIF_NAND_CONTROL ); - } else if (cfg->mode == ASYNC_EMIF_MODE_ONENAND) { - tmp =__raw_readl (&davinci_emif_regs->one_nand_cr); + }else if (cfg->mode ==AEMIF_MODE_ONENAND ) { + tmp =__raw_readl (AEMIF_ONENAND_CONTROL ); tmp |= (1 << cs); -__raw_writel (tmp, &davinci_emif_regs->one_nand_cr); +__raw_writel (tmp,AEMIF_ONENAND_CONTROL ); } - tmp =__raw_readl (&davinci_emif_regs->abncr[cs]); + tmp =__raw_readl (AEMIF_CONFIG (cs));set_config_field (tmp,SELECT_STROBE , cfg->select_strobe);set_config_field (tmp,EXTEND_WAIT , cfg->extend_wait);@@ -59,13 +63,18 @@ void configure_async_emif(int cs, struct async_emif_config *cfg) set_config_field(tmp, TURN_AROUND, cfg->turn_around);set_config_field (tmp,WIDTH , cfg->width); -__raw_writel (tmp, &davinci_emif_regs->abncr[cs]); +__raw_writel (tmp,AEMIF_CONFIG (cs)); } -void init_async_emif(int num_cs, struct async_emif_config *config) +void aemif_init (int num_cs,struct aemif_config *config) {int cs; + if (num_cs > AEMIF_NUM_CS) { + num_cs =AEMIF_NUM_CS ; +printf ("AEMIF: csnum has to be <= 5" ); + } +for (cs =0 ; cs < num_cs; cs++) -configure_async_emif (cs, config + cs); +aemif_configure (cs, config + cs); }drivers/memory/ti-aemif.h new file +39
-0@@ -0,0 +1,39 @@ +/* +* AEMIF definitions +* +* (C) Copyright 2012-2014 +* Texas Instruments Incorporated, <www.ti.com> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _AEMIF_H_ +#define _AEMIF_H_ + +#define AEMIF_NUM_CS 4 +#define AEMIF_MODE_NOR 0 +#define AEMIF_MODE_NAND 1 +#define AEMIF_MODE_ONENAND 2 +#define AEMIF_PRESERVE -1 + +struct aemif_config { +unsigned mode; +unsigned select_strobe; +unsigned extend_wait; +unsigned wr_setup; +unsigned wr_strobe; +unsigned wr_hold; +unsigned rd_setup; +unsigned rd_strobe; +unsigned rd_hold; +unsigned turn_around; +enum { +AEMIF_WIDTH_8 =0 , +AEMIF_WIDTH_16 =1 , +AEMIF_WIDTH_32 =2 , + } width; +}; + +void aemif_init (int num_cs,struct aemif_config *config); + +#endif include/configs/k2hk_evm.h +0
-0include/configs/k2hk_evm.h line 137
Quoted 9 lines
include/configs/k2hk_evm.h +3
-0@@ -129,6 +129,10 @@#define CONFIG_SYS_SGMII_LINERATE_MHZ 1250#define CONFIG_SYS_SGMII_RATESCALE 2 +/* AEMIF */ +#define CONFIG_TI_AEMIF +#define CONFIG_AEMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE +/* NAND Configuration */ #define CONFIG_NAND_DAVINCI #define CONFIG_CMD_NAND_ECCLAYOUT I think this looks good. Moving driver to memory makes it similar to kernel. Make sure the header
files are arranged in a similar fashion. I got confused with the first patch.
Quoted 1 line
Murali
Murali,
I've sent v2 patches, could you please look at them:
[U-boot] [Patch v2] mtd: nand: davinci: add header file for driver definitions
[U-boot] [Patch v2] ARM: keystone: aemif: move aemif driver to drivers/memory/ti-aemif.c
Signature · 2 lines
Regards, Ivan Khoronzhuk