From mboxrd@z Thu Jan 1 00:00:00 1970 From: Afzal Mohammed Subject: [PATCH v5 06/14] ARM: OMAP2+: gpmc: CS configuration helper Date: Mon, 11 Jun 2012 19:56:55 +0530 Message-ID: <9dd458171d6a68ea4f97a4ba19dbacc0d6b5ba35.1339419492.git.afzal@ti.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from arroyo.ext.ti.com ([192.94.94.40]:50093 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753967Ab2FKOmf (ORCPT ); Mon, 11 Jun 2012 10:42:35 -0400 In-Reply-To: Sender: linux-omap-owner@vger.kernel.org List-Id: linux-omap@vger.kernel.org To: tony@atomide.com, paul@pwsan.com, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Afzal Mohammed Helper for configuring given CS based on flags. Signed-off-by: Afzal Mohammed --- arch/arm/mach-omap2/gpmc.c | 33 ++++++++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/gpmc.h | 5 +++++ 2 files changed, 38 insertions(+) diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 652b245..4e19010 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -927,6 +927,39 @@ static __devinit int gpmc_setup_cs_mem(struct gpmc_cs_data *cs, return 1; } +static void gpmc_setup_cs_config(unsigned cs, unsigned conf) +{ + u32 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); + + l &= ~(GPMC_CONFIG1_MUXADDDATA | + GPMC_CONFIG1_WRITETYPE_SYNC | + GPMC_CONFIG1_WRITEMULTIPLE_SUPP | + GPMC_CONFIG1_READTYPE_SYNC | + GPMC_CONFIG1_READMULTIPLE_SUPP | + GPMC_CONFIG1_WRAPBURST_SUPP | + GPMC_CONFIG1_DEVICETYPE(~0) | + GPMC_CONFIG1_DEVICESIZE(~0) | + GPMC_CONFIG1_PAGE_LEN(~0)); + + l |= conf & GPMC_CONFIG1_DEVICETYPE_NAND; + l |= conf & GPMC_CONFIG1_DEVICESIZE_16; + + if (conf & GPMC_CONFIG1_PAGE_LEN_8) + l |= GPMC_CONFIG1_PAGE_LEN_8; + else if (conf & GPMC_CONFIG1_PAGE_LEN_16) + l |= GPMC_CONFIG1_PAGE_LEN_16; + + conf &= (GPMC_CONFIG1_MUXADDDATA | + GPMC_CONFIG1_WRITETYPE_SYNC | + GPMC_CONFIG1_WRITEMULTIPLE_SUPP | + GPMC_CONFIG1_READTYPE_SYNC | + GPMC_CONFIG1_READMULTIPLE_SUPP | + GPMC_CONFIG1_WRAPBURST_SUPP); + l |= conf; + + gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, l); +} + static inline unsigned gpmc_bit_to_irq(unsigned bitmask) { return bitmask; diff --git a/arch/arm/plat-omap/include/plat/gpmc.h b/arch/arm/plat-omap/include/plat/gpmc.h index 698fa33..ff3f32c 100644 --- a/arch/arm/plat-omap/include/plat/gpmc.h +++ b/arch/arm/plat-omap/include/plat/gpmc.h @@ -57,14 +57,19 @@ #define GPMC_CONFIG1_WRITETYPE_SYNC (1 << 27) #define GPMC_CONFIG1_CLKACTIVATIONTIME(val) ((val & 3) << 25) #define GPMC_CONFIG1_PAGE_LEN(val) ((val & 3) << 23) +#define GPMC_CONFIG1_PAGE_LEN_4 GPMC_CONFIG1_PAGE_LEN(0) +#define GPMC_CONFIG1_PAGE_LEN_8 GPMC_CONFIG1_PAGE_LEN(1) +#define GPMC_CONFIG1_PAGE_LEN_16 GPMC_CONFIG1_PAGE_LEN(2) #define GPMC_CONFIG1_WAIT_READ_MON (1 << 22) #define GPMC_CONFIG1_WAIT_WRITE_MON (1 << 21) #define GPMC_CONFIG1_WAIT_MON_IIME(val) ((val & 3) << 18) #define GPMC_CONFIG1_WAIT_PIN_SEL(val) ((val & 3) << 16) #define GPMC_CONFIG1_DEVICESIZE(val) ((val & 3) << 12) +#define GPMC_CONFIG1_DEVICESIZE_8 GPMC_CONFIG1_DEVICESIZE(0) #define GPMC_CONFIG1_DEVICESIZE_16 GPMC_CONFIG1_DEVICESIZE(1) #define GPMC_CONFIG1_DEVICETYPE(val) ((val & 3) << 10) #define GPMC_CONFIG1_DEVICETYPE_NOR GPMC_CONFIG1_DEVICETYPE(0) +#define GPMC_CONFIG1_DEVICETYPE_NAND GPMC_CONFIG1_DEVICETYPE(2) #define GPMC_CONFIG1_MUXADDDATA (1 << 9) #define GPMC_CONFIG1_TIME_PARA_GRAN (1 << 4) #define GPMC_CONFIG1_FCLK_DIV(val) (val & 3) -- 1.7.10.2 From mboxrd@z Thu Jan 1 00:00:00 1970 From: afzal@ti.com (Afzal Mohammed) Date: Mon, 11 Jun 2012 19:56:55 +0530 Subject: [PATCH v5 06/14] ARM: OMAP2+: gpmc: CS configuration helper In-Reply-To: References: Message-ID: <9dd458171d6a68ea4f97a4ba19dbacc0d6b5ba35.1339419492.git.afzal@ti.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Helper for configuring given CS based on flags. Signed-off-by: Afzal Mohammed --- arch/arm/mach-omap2/gpmc.c | 33 ++++++++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/gpmc.h | 5 +++++ 2 files changed, 38 insertions(+) diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 652b245..4e19010 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -927,6 +927,39 @@ static __devinit int gpmc_setup_cs_mem(struct gpmc_cs_data *cs, return 1; } +static void gpmc_setup_cs_config(unsigned cs, unsigned conf) +{ + u32 l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); + + l &= ~(GPMC_CONFIG1_MUXADDDATA | + GPMC_CONFIG1_WRITETYPE_SYNC | + GPMC_CONFIG1_WRITEMULTIPLE_SUPP | + GPMC_CONFIG1_READTYPE_SYNC | + GPMC_CONFIG1_READMULTIPLE_SUPP | + GPMC_CONFIG1_WRAPBURST_SUPP | + GPMC_CONFIG1_DEVICETYPE(~0) | + GPMC_CONFIG1_DEVICESIZE(~0) | + GPMC_CONFIG1_PAGE_LEN(~0)); + + l |= conf & GPMC_CONFIG1_DEVICETYPE_NAND; + l |= conf & GPMC_CONFIG1_DEVICESIZE_16; + + if (conf & GPMC_CONFIG1_PAGE_LEN_8) + l |= GPMC_CONFIG1_PAGE_LEN_8; + else if (conf & GPMC_CONFIG1_PAGE_LEN_16) + l |= GPMC_CONFIG1_PAGE_LEN_16; + + conf &= (GPMC_CONFIG1_MUXADDDATA | + GPMC_CONFIG1_WRITETYPE_SYNC | + GPMC_CONFIG1_WRITEMULTIPLE_SUPP | + GPMC_CONFIG1_READTYPE_SYNC | + GPMC_CONFIG1_READMULTIPLE_SUPP | + GPMC_CONFIG1_WRAPBURST_SUPP); + l |= conf; + + gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, l); +} + static inline unsigned gpmc_bit_to_irq(unsigned bitmask) { return bitmask; diff --git a/arch/arm/plat-omap/include/plat/gpmc.h b/arch/arm/plat-omap/include/plat/gpmc.h index 698fa33..ff3f32c 100644 --- a/arch/arm/plat-omap/include/plat/gpmc.h +++ b/arch/arm/plat-omap/include/plat/gpmc.h @@ -57,14 +57,19 @@ #define GPMC_CONFIG1_WRITETYPE_SYNC (1 << 27) #define GPMC_CONFIG1_CLKACTIVATIONTIME(val) ((val & 3) << 25) #define GPMC_CONFIG1_PAGE_LEN(val) ((val & 3) << 23) +#define GPMC_CONFIG1_PAGE_LEN_4 GPMC_CONFIG1_PAGE_LEN(0) +#define GPMC_CONFIG1_PAGE_LEN_8 GPMC_CONFIG1_PAGE_LEN(1) +#define GPMC_CONFIG1_PAGE_LEN_16 GPMC_CONFIG1_PAGE_LEN(2) #define GPMC_CONFIG1_WAIT_READ_MON (1 << 22) #define GPMC_CONFIG1_WAIT_WRITE_MON (1 << 21) #define GPMC_CONFIG1_WAIT_MON_IIME(val) ((val & 3) << 18) #define GPMC_CONFIG1_WAIT_PIN_SEL(val) ((val & 3) << 16) #define GPMC_CONFIG1_DEVICESIZE(val) ((val & 3) << 12) +#define GPMC_CONFIG1_DEVICESIZE_8 GPMC_CONFIG1_DEVICESIZE(0) #define GPMC_CONFIG1_DEVICESIZE_16 GPMC_CONFIG1_DEVICESIZE(1) #define GPMC_CONFIG1_DEVICETYPE(val) ((val & 3) << 10) #define GPMC_CONFIG1_DEVICETYPE_NOR GPMC_CONFIG1_DEVICETYPE(0) +#define GPMC_CONFIG1_DEVICETYPE_NAND GPMC_CONFIG1_DEVICETYPE(2) #define GPMC_CONFIG1_MUXADDDATA (1 << 9) #define GPMC_CONFIG1_TIME_PARA_GRAN (1 << 4) #define GPMC_CONFIG1_FCLK_DIV(val) (val & 3) -- 1.7.10.2