tegra: Enhance funcmux to support I2C and MMC
Subsystems (2)
v2 cover tegra: Enhance funcmux to support I2C and MMC
This series expands funcmux_select() to support configs other than 0, and to name each config option.
This permits introduction of I2C and MMC support in the funcmux.
Changes in v2:
- Add enum to select from available funcmux configs
- Remove funcmux_select() option parameter
- Use config enum to select funcmux
- Fix SDMMC4 config 0 to remove unwanted ATB pin group
Simon Glass (7):
tegra: Adjust funcmux config test to permit expansion
tegra: Add enum to select from available funcmux configs
tegra: Add I2C support to funcmux
tegra: Add SDMMC support to funcmux
tegra: Use funcmux for MMC on tamonten
tegra: Use funcmux for MMC on harmony
tegra: Use funcmux for MMC on seaboard
arch/arm/cpu/armv7/tegra2/board.c | 2 +- arch/arm/cpu/armv7/tegra2/funcmux.c | 139 +++++++++++++++++++++++++--- arch/arm/include/asm/arch-tegra2/funcmux.h | 30 ++++++- board/avionic-design/common/tamonten.c | 10 +-- board/nvidia/harmony/harmony.c | 19 +--- board/nvidia/seaboard/seaboard.c | 21 +---- 6 files changed, 166 insertions(+), 55 deletions(-)
Signature · 1 line
1.7.3.1
PATCH v2 1/7 tegra: Adjust funcmux config test to permit expansion
We want to support config options other than zero, so move the test to the end to allow intermediate code to OK such a config.
---
arch/arm/cpu/armv7/tegra2/funcmux.c | 35 +++++++++++++++++---------- arch/arm/include/asm/arch-tegra2/funcmux.h | 3 ++ 2 files changed, 25 insertions(+), 13 deletions(-)
arch/arm/cpu/armv7/tegra2/funcmux.c +22 -13
@@ -26,27 +26,30 @@int funcmux_select (enum periph_id id,int config) { -if (config !=0 ) { -debug ("%s: invalid config %d for periph_id %d" , __func__, - config, id); -return -1 ; - } +int bad_config = config !=0 ; +switch (id) {case PERIPH_ID_UART1 : -pinmux_set_func (PINGRP_IRRX ,PMUX_FUNC_UARTA ); -pinmux_set_func (PINGRP_IRTX ,PMUX_FUNC_UARTA ); -pinmux_tristate_disable (PINGRP_IRRX ); -pinmux_tristate_disable (PINGRP_IRTX ); +if (config ==0 ) { +pinmux_set_func (PINGRP_IRRX ,PMUX_FUNC_UARTA ); +pinmux_set_func (PINGRP_IRTX ,PMUX_FUNC_UARTA ); +pinmux_tristate_disable (PINGRP_IRRX ); +pinmux_tristate_disable (PINGRP_IRTX ); + }break ;case PERIPH_ID_UART2 : -pinmux_set_func (PINGRP_UAD ,PMUX_FUNC_IRDA ); -pinmux_tristate_disable (PINGRP_UAD ); +if (config ==0 ) { +pinmux_set_func (PINGRP_UAD ,PMUX_FUNC_IRDA ); +pinmux_tristate_disable (PINGRP_UAD ); + }break ;case PERIPH_ID_UART4 : -pinmux_set_func (PINGRP_GMC ,PMUX_FUNC_UARTD ); -pinmux_tristate_disable (PINGRP_GMC ); +if (config ==0 ) { +pinmux_set_func (PINGRP_GMC ,PMUX_FUNC_UARTD ); +pinmux_tristate_disable (PINGRP_GMC ); + }break ;default :
@@ -54,5 +57,11 @@ int funcmux_select(enum periph_id id, int config)return -1 ; } +if (bad_config) { +debug ("%s: invalid config %d for periph_id %d" , __func__, + config, id); +return -1 ; + } +return 0 ; }
arch/arm/include/asm/arch-tegra2/funcmux.h +3 -0
@@ -32,6 +32,9 @@* The basic config is 0, and higher numbers indicate different * pinmux settings to bring the peripheral out on other pins, * +* This function also disables tristate for the function's pins, +* so that they operate in normal mode. +* * @param id Peripheral id * @param config Configuration to use (generally 0) * @return 0 if ok, -1 on error (e.g. incorrect id or config)
Signature · 1 line
1.7.3.1
PATCH v2 2/7 tegra: Add enum to select from available funcmux configs
In reply to Simon GlassWe want to give a name to each available funcmux config. For now we just use the pin group names (even through it is verbose) since there seems to be nothing better.
---
Changes in v2:
- Add enum to select from available funcmux configs
arch/arm/cpu/armv7/tegra2/board.c | 2 +- arch/arm/cpu/armv7/tegra2/funcmux.c | 9 +++++---- arch/arm/include/asm/arch-tegra2/funcmux.h | 12 +++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-)
arch/arm/cpu/armv7/tegra2/board.c +1 -1
@@ -120,7 +120,7 @@ static void setup_uarts(int uart_ids)if (uart_ids & (1 << i)) {enum periph_id id = id_for_uart[i]; -funcmux_select (id,0 ); +funcmux_select (id,FUNCMUX_DEFAULT );clock_ll_start_uart (id); } }
arch/arm/cpu/armv7/tegra2/funcmux.c +5 -4
@@ -22,15 +22,16 @@/* Tegra2 high-level function multiplexing */ #include <common.h> #include <asm/arch/clock.h> +#include <asm/arch/funcmux.h> #include <asm/arch/pinmux.h> int funcmux_select (enum periph_id id,int config) { -int bad_config = config !=0 ; +int bad_config = config !=FUNCMUX_DEFAULT ;switch (id) {case PERIPH_ID_UART1 : -if (config ==0 ) { +if (config ==FUNCMUX_UART1_IRRX_IRTX ) {pinmux_set_func (PINGRP_IRRX ,PMUX_FUNC_UARTA );pinmux_set_func (PINGRP_IRTX ,PMUX_FUNC_UARTA );pinmux_tristate_disable (PINGRP_IRRX );
@@ -39,14 +40,14 @@ int funcmux_select(enum periph_id id, int config)break ;case PERIPH_ID_UART2 : -if (config ==0 ) { +if (config ==FUNCMUX_UART2_IRDA ) {pinmux_set_func (PINGRP_UAD ,PMUX_FUNC_IRDA );pinmux_tristate_disable (PINGRP_UAD ); }break ;case PERIPH_ID_UART4 : -if (config ==0 ) { +if (config ==FUNCMUX_UART4_GMC ) {pinmux_set_func (PINGRP_GMC ,PMUX_FUNC_UARTD );pinmux_tristate_disable (PINGRP_GMC ); }
arch/arm/include/asm/arch-tegra2/funcmux.h +11 -1
@@ -24,6 +24,16 @@#ifndef __FUNCMUX_H#define __FUNCMUX_H +/* Configs supported by the func mux */ +enum { +FUNCMUX_DEFAULT =0 ,/* default config */ + +/* UART configs */ +FUNCMUX_UART1_IRRX_IRTX =0 , +FUNCMUX_UART2_IRDA =0 , +FUNCMUX_UART4_GMC =0 , +}; +/** * Select a config for a particular peripheral. *
@@ -36,7 +46,7 @@* so that they operate in normal mode. * * @param id Peripheral id -* @param config Configuration to use (generally 0) +* @param config Configuration to use (FUNCMUX_...), 0 for default * @return 0 if ok, -1 on error (e.g. incorrect id or config) */ int funcmux_select (enum periph_id id,int config);
Signature · 1 line
1.7.3.1
PATCH v2 3/7 tegra: Add I2C support to funcmux
In reply to Simon GlassAdd support to funcmux for selecting I2C functions and programming the pinmux appropriately.
---
Changes in v2:
- Remove funcmux_select() option parameter
- Use config enum to select funcmux
arch/arm/cpu/armv7/tegra2/funcmux.c | 40 ++++++++++++++++++++++++++++ arch/arm/include/asm/arch-tegra2/funcmux.h | 7 +++++ 2 files changed, 47 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/tegra2/funcmux.c +40 -0
@@ -53,6 +53,46 @@ int funcmux_select(enum periph_id id, int config) }break ; +case PERIPH_ID_DVC_I2C : +/* there is only one selection, pinmux_config is ignored */ +if (config ==FUNCMUX_DVC_I2CP ) { +pinmux_set_func (PINGRP_I2CP ,PMUX_FUNC_I2C ); +pinmux_tristate_disable (PINGRP_I2CP ); + } +break ; + +case PERIPH_ID_I2C1 : +/* support pinmux_config of 0 for now, */ +if (config ==FUNCMUX_I2C1_RM ) { +pinmux_set_func (PINGRP_RM ,PMUX_FUNC_I2C ); +pinmux_tristate_disable (PINGRP_RM ); + } +break ; +case PERIPH_ID_I2C2 :/* I2C2 */ +switch (config) { +case FUNCMUX_I2C2_DDC :/* DDC pin group, select I2C2 */ +pinmux_set_func (PINGRP_DDC ,PMUX_FUNC_I2C2 ); +/* PTA to HDMI */ +pinmux_set_func (PINGRP_PTA ,PMUX_FUNC_HDMI ); +pinmux_tristate_disable (PINGRP_DDC ); +break ; +case FUNCMUX_I2C2_PTA :/* PTA pin group, select I2C2 */ +pinmux_set_func (PINGRP_PTA ,PMUX_FUNC_I2C2 ); +/* set DDC_SEL to RSVDx (RSVD2 works for now) */ +pinmux_set_func (PINGRP_DDC ,PMUX_FUNC_RSVD2 ); +pinmux_tristate_disable (PINGRP_PTA ); + bad_config =0 ; +break ; + } +break ; +case PERIPH_ID_I2C3 :/* I2C3 */ +/* support pinmux_config of 0 for now */ +if (config ==FUNCMUX_I2C3_DTF ) { +pinmux_set_func (PINGRP_DTF ,PMUX_FUNC_I2C3 ); +pinmux_tristate_disable (PINGRP_DTF ); + } +break ; +default :debug ("%s: invalid periph_id %d" , __func__, id);return -1 ;
arch/arm/include/asm/arch-tegra2/funcmux.h +7 -0
@@ -32,6 +32,13 @@ enum {FUNCMUX_UART1_IRRX_IRTX =0 ,FUNCMUX_UART2_IRDA =0 ,FUNCMUX_UART4_GMC =0 , + +/* I2C configs */ +FUNCMUX_DVC_I2CP =0 , +FUNCMUX_I2C1_RM =0 , +FUNCMUX_I2C2_DDC =0 , +FUNCMUX_I2C2_PTA , + FUNCMUX_I2C3_DTF = 0, };/**
Signature · 1 line
1.7.3.1
PATCH v2 4/7 tegra: Add SDMMC support to funcmux
In reply to Simon GlassThis adds support for SDMMC ports to the funcmux. Only one option is supported: FUNCMUXO_SDMMC_8BIT which selects an 8-bit wide SDIO interface where available.
---
Changes in v2:
- Fix SDMMC4 config 0 to remove unwanted ATB pin group
- Remove funcmux_select() option parameter
- Use config enum to select funcmux
arch/arm/cpu/armv7/tegra2/funcmux.c | 63 ++++++++++++++++++++++++++++ arch/arm/include/asm/arch-tegra2/funcmux.h | 8 ++++ 2 files changed, 71 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/tegra2/funcmux.c +63 -0
@@ -93,6 +93,69 @@ int funcmux_select(enum periph_id id, int config) }break ; +case PERIPH_ID_SDMMC2 : +if (config ==FUNCMUX_SDMMC2_DTA_DTD_8BIT ) { +pinmux_set_func (PINGRP_DTA ,PMUX_FUNC_SDIO2 ); +pinmux_set_func (PINGRP_DTD ,PMUX_FUNC_SDIO2 ); + +pinmux_tristate_disable (PINGRP_DTA ); +pinmux_tristate_disable (PINGRP_DTD ); + } +break ; + +case PERIPH_ID_SDMMC3 : +switch (config) { +case FUNCMUX_SDMMC3_SDB_SLXA_8BIT : +pinmux_set_func (PINGRP_SLXA ,PMUX_FUNC_SDIO3 ); +pinmux_set_func (PINGRP_SLXC ,PMUX_FUNC_SDIO3 ); +pinmux_set_func (PINGRP_SLXD ,PMUX_FUNC_SDIO3 ); +pinmux_set_func (PINGRP_SLXK ,PMUX_FUNC_SDIO3 ); + +pinmux_tristate_disable (PINGRP_SLXA ); +pinmux_tristate_disable (PINGRP_SLXC ); +pinmux_tristate_disable (PINGRP_SLXD ); +pinmux_tristate_disable (PINGRP_SLXK ); +/* fall through */ + +case FUNCMUX_SDMMC3_SDB_4BIT : +pinmux_set_func (PINGRP_SDB ,PMUX_FUNC_SDIO3 ); +pinmux_set_func (PINGRP_SDC ,PMUX_FUNC_SDIO3 ); +pinmux_set_func (PINGRP_SDD ,PMUX_FUNC_SDIO3 ); + +pinmux_tristate_disable (PINGRP_SDB ); +pinmux_tristate_disable (PINGRP_SDC ); +pinmux_tristate_disable (PINGRP_SDD ); + bad_config =0 ; +break ; + } +break ; + +case PERIPH_ID_SDMMC4 : +switch (config) { +case FUNCMUX_SDMMC4_ATC_ATD_8BIT : +pinmux_set_func (PINGRP_ATC ,PMUX_FUNC_SDIO4 ); +pinmux_set_func (PINGRP_ATD ,PMUX_FUNC_SDIO4 ); + +pinmux_tristate_disable (PINGRP_ATC ); +pinmux_tristate_disable (PINGRP_ATD ); +break ; + +case FUNCMUX_SDMMC4_ATB_GMA_GME_8_BIT : +pinmux_set_func (PINGRP_GME ,PMUX_FUNC_SDIO4 ); +pinmux_tristate_disable (PINGRP_GME ); +/* fall through */ + +case FUNCMUX_SDMMC4_ATB_GMA_4_BIT : +pinmux_set_func (PINGRP_ATB ,PMUX_FUNC_SDIO4 ); +pinmux_set_func (PINGRP_GMA ,PMUX_FUNC_SDIO4 ); + +pinmux_tristate_disable (PINGRP_ATB ); +pinmux_tristate_disable (PINGRP_GMA ); + bad_config =0 ; +break ; + } +break ; +default :debug ("%s: invalid periph_id %d" , __func__, id);return -1 ;
arch/arm/include/asm/arch-tegra2/funcmux.h +8 -0
@@ -39,6 +39,14 @@ enum {FUNCMUX_I2C2_DDC =0 ,FUNCMUX_I2C2_PTA ,FUNCMUX_I2C3_DTF =0 , + +/* SDMMC configs */ +FUNCMUX_SDMMC2_DTA_DTD_8BIT =0 , +FUNCMUX_SDMMC3_SDB_4BIT =0 , +FUNCMUX_SDMMC3_SDB_SLXA_8BIT , +FUNCMUX_SDMMC4_ATC_ATD_8BIT =0 , +FUNCMUX_SDMMC4_ATB_GMA_4_BIT , + FUNCMUX_SDMMC4_ATB_GMA_GME_8_BIT, };/**
Signature · 1 line
1.7.3.1
PATCH v2 5/7 tegra: Use funcmux for MMC on tamonten
In reply to Simon GlassUse the new funcmux_select() feature to set up the MMC pin mux.
---
Changes in v2:
- Remove funcmux_select() option parameter
- Use config enum to select funcmux
board/avionic-design/common/tamonten.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-)
board/avionic-design/common/tamonten.c +2 -8
@@ -32,6 +32,7 @@#include <asm/arch/sys_proto.h> #include <asm/arch/clk_rst.h> #include <asm/arch/clock.h> +#include <asm/arch/funcmux.h> #include <asm/arch/pinmux.h> #include <asm/arch/uart.h> #include <asm/arch/mmc.h>
@@ -63,14 +64,7 @@ int timer_init(void)*/ static void pin_mux_mmc (void ) { -/* SDMMC4: config 3, x8 on 2nd set of pins */ -pinmux_set_func (PINGRP_ATB ,PMUX_FUNC_SDIO4 ); -pinmux_set_func (PINGRP_GMA ,PMUX_FUNC_SDIO4 ); -pinmux_set_func (PINGRP_GME ,PMUX_FUNC_SDIO4 ); - -pinmux_tristate_disable (PINGRP_ATB ); -pinmux_tristate_disable (PINGRP_GMA ); -pinmux_tristate_disable (PINGRP_GME ); +funcmux_select (PERIPH_ID_SDMMC4 ,FUNCMUX_SDMMC4_ATB_GMA_GME_8_BIT ); }#endif
Signature · 1 line
1.7.3.1
PATCH v2 6/7 tegra: Use funcmux for MMC on harmony
In reply to Simon GlassUse the new funcmux_select() feature to set up the MMC pin mux.
---
Changes in v2:
- Remove funcmux_select() option parameter
- Use config enum to select funcmux
board/nvidia/harmony/harmony.c | 19 ++++--------------- 1 files changed, 4 insertions(+), 15 deletions(-)
board/nvidia/harmony/harmony.c +4 -15
@@ -24,6 +24,8 @@#include <common.h> #include <asm/io.h> #include <asm/arch/tegra2.h> +#include <asm/arch/clock.h> +#include <asm/arch/funcmux.h> #include <asm/arch/pinmux.h> #include <asm/arch/mmc.h> #include <asm/gpio.h>
@@ -46,27 +48,14 @@ void gpio_config_uart(void)*/ static void pin_mux_mmc (void ) { -/* SDMMC4: config 3, x8 on 2nd set of pins */ -pinmux_set_func (PINGRP_ATB ,PMUX_FUNC_SDIO4 ); -pinmux_set_func (PINGRP_GMA ,PMUX_FUNC_SDIO4 ); -pinmux_set_func (PINGRP_GME ,PMUX_FUNC_SDIO4 ); - -pinmux_tristate_disable (PINGRP_ATB ); -pinmux_tristate_disable (PINGRP_GMA ); -pinmux_tristate_disable (PINGRP_GME ); +funcmux_select (PERIPH_ID_SDMMC4 ,FUNCMUX_SDMMC4_ATB_GMA_GME_8_BIT ); +funcmux_select (PERIPH_ID_SDMMC2 ,FUNCMUX_SDMMC2_DTA_DTD_8BIT );/* For power GPIO PI6 */ pinmux_tristate_disable (PINGRP_ATA );/* For CD GPIO PH2 */ pinmux_tristate_disable (PINGRP_ATD ); -/* SDMMC2: SDIO2_CLK, SDIO2_CMD, SDIO2_DAT[7:0] */ -pinmux_set_func (PINGRP_DTA ,PMUX_FUNC_SDIO2 ); -pinmux_set_func (PINGRP_DTD ,PMUX_FUNC_SDIO2 ); - -pinmux_tristate_disable (PINGRP_DTA ); -pinmux_tristate_disable (PINGRP_DTD ); -/* For power GPIO PT3 */ pinmux_tristate_disable (PINGRP_DTB );/* For CD GPIO PI5 */
Signature · 1 line
1.7.3.1
PATCH v2 7/7 tegra: Use funcmux for MMC on seaboard
In reply to Simon GlassUse the new funcmux_select() feature to set up the MMC pin mux.
---
Changes in v2:
- Remove funcmux_select() option parameter
- Use config enum to select funcmux
board/nvidia/seaboard/seaboard.c | 21 ++++----------------- 1 files changed, 4 insertions(+), 17 deletions(-)
board/nvidia/seaboard/seaboard.c +4 -17
@@ -24,6 +24,8 @@#include <common.h> #include <asm/io.h> #include <asm/arch/tegra2.h> +#include <asm/arch/clock.h> +#include <asm/arch/funcmux.h> #include <asm/arch/pinmux.h> #include <asm/arch/mmc.h> #include <asm/gpio.h>
@@ -59,23 +61,8 @@ void gpio_config_uart(void)*/ static void pin_mux_mmc (void ) { -/* SDMMC4: config 3, x8 on 2nd set of pins */ -pinmux_set_func (PINGRP_ATB ,PMUX_FUNC_SDIO4 ); -pinmux_set_func (PINGRP_GMA ,PMUX_FUNC_SDIO4 ); -pinmux_set_func (PINGRP_GME ,PMUX_FUNC_SDIO4 ); - -pinmux_tristate_disable (PINGRP_ATB ); -pinmux_tristate_disable (PINGRP_GMA ); -pinmux_tristate_disable (PINGRP_GME ); - -/* SDMMC3: SDIO3_CLK, SDIO3_CMD, SDIO3_DAT[3:0] */ -pinmux_set_func (PINGRP_SDB ,PMUX_FUNC_SDIO3 ); -pinmux_set_func (PINGRP_SDC ,PMUX_FUNC_SDIO3 ); -pinmux_set_func (PINGRP_SDD ,PMUX_FUNC_SDIO3 ); - -pinmux_tristate_disable (PINGRP_SDC ); -pinmux_tristate_disable (PINGRP_SDD ); -pinmux_tristate_disable (PINGRP_SDB ); +funcmux_select (PERIPH_ID_SDMMC4 ,FUNCMUX_SDMMC4_ATB_GMA_GME_8_BIT ); +funcmux_select (PERIPH_ID_SDMMC3 ,FUNCMUX_SDMMC3_SDB_4BIT );/* For power GPIO PI6 */ pinmux_tristate_disable (PINGRP_ATA );
Signature · 1 line
1.7.3.1
v2 cover tegra: Enhance funcmux to support I2C and MMC
In reply to Simon GlassQuoted 4 lines · Simon Glass
This series expands
funcmux_select()to support configs other than 0, and to name each config option.This permits introduction of I2C and MMC support in the funcmux.
The series,
Signature · 1 line
nvpublic