am33xx: Rework pinmux functions

- Move definition of the EEPROM contents to <asm/arch/sys_proto.h>
  - Make some defines a little less generic now.
- Pinmux must be done by done by SPL now.
- Create 3 pinmux functions, uart0, i2c0 and board.
- Add pinmux specific to Starter Kit EVM for MMC now.

Signed-off-by: Tom Rini <trini@ti.com>
This commit is contained in:
Tom Rini 2012-07-31 10:50:01 -07:00 committed by Albert ARIBAUD
parent 726c05d2cf
commit db7dd8109c
5 changed files with 68 additions and 78 deletions

View File

@ -25,7 +25,7 @@
#include <asm/arch/clock.h> #include <asm/arch/clock.h>
#include <asm/arch/gpio.h> #include <asm/arch/gpio.h>
#include <asm/arch/mmc_host_def.h> #include <asm/arch/mmc_host_def.h>
#include <asm/arch/common_def.h> #include <asm/arch/sys_proto.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/omap_common.h> #include <asm/omap_common.h>
#include <asm/emif.h> #include <asm/emif.h>
@ -58,29 +58,16 @@ const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;
static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
#define NO_OF_MAC_ADDR 3
#define ETH_ALEN 6
#define NAME_LEN 8
struct am335x_baseboard_id {
unsigned int magic;
char name[NAME_LEN];
char version[4];
char serial[12];
char config[32];
char mac_addr[NO_OF_MAC_ADDR][ETH_ALEN];
};
static struct am335x_baseboard_id __attribute__((section (".data"))) header; static struct am335x_baseboard_id __attribute__((section (".data"))) header;
static inline int board_is_bone(void) static inline int board_is_bone(void)
{ {
return !strncmp(header.name, "A335BONE", NAME_LEN); return !strncmp(header.name, "A335BONE", HDR_NAME_LEN);
} }
static inline int board_is_evm_sk(void) static inline int board_is_evm_sk(void)
{ {
return !strncmp("A335X_SK", header.name, NAME_LEN); return !strncmp("A335X_SK", header.name, HDR_NAME_LEN);
} }
/* /*
@ -207,21 +194,18 @@ void s_init(void)
if (read_eeprom() < 0) if (read_eeprom() < 0)
puts("Could not get board ID.\n"); puts("Could not get board ID.\n");
enable_board_pin_mux(&header);
if (board_is_evm_sk()) { if (board_is_evm_sk()) {
/* /*
* EVM SK 1.2A and later use gpio0_7 to enable DDR3. * EVM SK 1.2A and later use gpio0_7 to enable DDR3.
* This is safe enough to do on older revs. * This is safe enough to do on older revs.
*/ */
enable_gpio0_7_pin_mux();
gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en"); gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
gpio_direction_output(GPIO_DDR_VTT_EN, 1); gpio_direction_output(GPIO_DDR_VTT_EN, 1);
} }
config_ddr(board_memory_type()); config_ddr(board_memory_type());
#endif #endif
/* Enable MMC0 */
enable_mmc0_pin_mux();
} }
#if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD) #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
@ -238,14 +222,10 @@ void setup_clocks_for_console(void)
} }
/* /*
* Basic board specific setup * Basic board specific setup. Pinmux has been handled already.
*/ */
int board_init(void) int board_init(void)
{ {
enable_uart0_pin_mux();
enable_i2c0_pin_mux();
enable_i2c1_pin_mux();
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
if (read_eeprom() < 0) if (read_eeprom() < 0)
puts("Could not get board ID.\n"); puts("Could not get board ID.\n");
@ -318,12 +298,10 @@ int board_eth_init(bd_t *bis)
} }
if (board_is_bone()) { if (board_is_bone()) {
enable_mii1_pin_mux();
writel(MII_MODE_ENABLE, &cdev->miisel); writel(MII_MODE_ENABLE, &cdev->miisel);
cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
PHY_INTERFACE_MODE_MII; PHY_INTERFACE_MODE_MII;
} else { } else {
enable_rgmii1_pin_mux();
writel(RGMII_MODE_ENABLE, &cdev->miisel); writel(RGMII_MODE_ENABLE, &cdev->miisel);
cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
PHY_INTERFACE_MODE_RGMII; PHY_INTERFACE_MODE_RGMII;

View File

@ -1,26 +0,0 @@
/*
* common_def.h
*
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation version 2.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
* kind, whether express or implied; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __COMMON_DEF_H__
#define __COMMON_DEF_H__
extern void enable_uart0_pin_mux(void);
extern void enable_mmc0_pin_mux(void);
extern void enable_gpio0_7_pin_mux(void);
extern void enable_i2c0_pin_mux(void);
extern void enable_mii1_pin_mux(void);
extern void enable_rgmii1_pin_mux(void);
#endif/*__COMMON_DEF_H__ */

View File

@ -19,6 +19,24 @@
#ifndef _SYS_PROTO_H_ #ifndef _SYS_PROTO_H_
#define _SYS_PROTO_H_ #define _SYS_PROTO_H_
/*
* AM335x parts define a system EEPROM that defines certain sub-fields.
* We use these fields to in turn see what board we are on, and what
* that might require us to set or not set.
*/
#define HDR_NO_OF_MAC_ADDR 3
#define HDR_ETH_ALEN 6
#define HDR_NAME_LEN 8
struct am335x_baseboard_id {
unsigned int magic;
char name[HDR_NAME_LEN];
char version[4];
char serial[12];
char config[32];
char mac_addr[HDR_NO_OF_MAC_ADDR][HDR_ETH_ALEN];
};
#define BOARD_REV_ID 0x0 #define BOARD_REV_ID 0x0
u32 get_cpu_rev(void); u32 get_cpu_rev(void);
@ -31,4 +49,14 @@ int print_cpuinfo(void);
u32 get_device_type(void); u32 get_device_type(void);
void setup_clocks_for_console(void); void setup_clocks_for_console(void);
void ddr_pll_config(unsigned int ddrpll_M); void ddr_pll_config(unsigned int ddrpll_M);
/*
* We have three pin mux functions that must exist. We must be able to enable
* uart0, for initial output and i2c0 to read the main EEPROM. We then have a
* main pinmux function that can be overridden to enable all other pinmux that
* is required on the board.
*/
void enable_uart0_pin_mux(void);
void enable_i2c0_pin_mux(void);
void enable_board_pin_mux(struct am335x_baseboard_id *header);
#endif #endif

View File

@ -18,7 +18,9 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(BOARD).o LIB = $(obj)lib$(BOARD).o
ifdef CONFIG_SPL_BUILD
COBJS := mux.o COBJS := mux.o
endif
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS)) OBJS := $(addprefix $(obj),$(COBJS))

View File

@ -13,8 +13,8 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <config.h> #include <common.h>
#include <asm/arch/common_def.h> #include <asm/arch/sys_proto.h>
#include <asm/arch/hardware.h> #include <asm/arch/hardware.h>
#include <asm/io.h> #include <asm/io.h>
@ -258,7 +258,6 @@ static struct module_pin_mux uart0_pin_mux[] = {
{-1}, {-1},
}; };
#ifdef CONFIG_MMC
static struct module_pin_mux mmc0_pin_mux[] = { static struct module_pin_mux mmc0_pin_mux[] = {
{OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */ {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */
{OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */ {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */
@ -270,7 +269,17 @@ static struct module_pin_mux mmc0_pin_mux[] = {
{OFFSET(spi0_cs1), (MODE(5) | RXACTIVE | PULLUP_EN)}, /* MMC0_CD */ {OFFSET(spi0_cs1), (MODE(5) | RXACTIVE | PULLUP_EN)}, /* MMC0_CD */
{-1}, {-1},
}; };
#endif
static struct module_pin_mux mmc0_pin_mux_sk_evm[] = {
{OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */
{OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */
{OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */
{OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */
{OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */
{OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */
{OFFSET(spi0_cs1), (MODE(5) | RXACTIVE | PULLUP_EN)}, /* MMC0_CD */
{-1},
};
static struct module_pin_mux i2c0_pin_mux[] = { static struct module_pin_mux i2c0_pin_mux[] = {
{OFFSET(i2c0_sda), (MODE(0) | RXACTIVE | {OFFSET(i2c0_sda), (MODE(0) | RXACTIVE |
@ -349,34 +358,33 @@ void enable_uart0_pin_mux(void)
configure_module_pin_mux(uart0_pin_mux); configure_module_pin_mux(uart0_pin_mux);
} }
#ifdef CONFIG_MMC
void enable_mmc0_pin_mux(void)
{
configure_module_pin_mux(mmc0_pin_mux);
}
#endif
void enable_i2c0_pin_mux(void) void enable_i2c0_pin_mux(void)
{ {
configure_module_pin_mux(i2c0_pin_mux); configure_module_pin_mux(i2c0_pin_mux);
} }
void enable_i2c1_pin_mux(void) void enable_board_pin_mux(struct am335x_baseboard_id *header)
{ {
/* Enable pinmux that is common to all TI boards. */
configure_module_pin_mux(i2c1_pin_mux); configure_module_pin_mux(i2c1_pin_mux);
}
void enable_rgmii1_pin_mux(void) /* Now do board-specific muxes. */
{ if (!strncmp(header->name, "A335BONE", HDR_NAME_LEN)) {
configure_module_pin_mux(rgmii1_pin_mux); /* Beaglebone pinmux */
}
void enable_mii1_pin_mux(void)
{
configure_module_pin_mux(mii1_pin_mux); configure_module_pin_mux(mii1_pin_mux);
} configure_module_pin_mux(mmc0_pin_mux);
} else if (!strncmp(header->config, "SKU#01", 6)) {
void enable_gpio0_7_pin_mux(void) /* General Purpose EVM */
{ configure_module_pin_mux(rgmii1_pin_mux);
configure_module_pin_mux(mmc0_pin_mux);
} else if (!strncmp(header->name, "A335X_SK", HDR_NAME_LEN)) {
/* Starter Kit EVM */
configure_module_pin_mux(gpio0_7_pin_mux); configure_module_pin_mux(gpio0_7_pin_mux);
configure_module_pin_mux(rgmii1_pin_mux);
configure_module_pin_mux(mmc0_pin_mux_sk_evm);
} else {
puts("Unknown board, cannot configure pinmux.");
hang();
}
} }