summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@ti.com>2013-03-12 14:29:26 -0400
committerTom Rini <trini@ti.com>2013-03-12 14:29:26 -0400
commitce839172bc9db69e6f245f49b8754f1500306bd5 (patch)
tree77282c7a32f8073166a28a11bc548c9a39002116
parentd309a1003804716309f9e74e19959ab3fbdac453 (diff)
parent05d212c0e101e6654bf8127275bac03fc0a7a382 (diff)
Merge branch 'am335x-power-2013.01.01' into ti-u-boot-2013.01.01
Conflicts: arch/arm/cpu/armv7/omap-common/boot-common.c board/ti/am335x/board.c Signed-off-by: Tom Rini <trini@ti.com>
-rw-r--r--arch/arm/cpu/armv7/am33xx/clock.c7
-rw-r--r--arch/arm/cpu/armv7/omap-common/boot-common.c3
-rw-r--r--arch/arm/include/asm/arch-am33xx/clocks_am33xx.h6
-rw-r--r--arch/arm/include/asm/arch-am33xx/ddr_defs.h2
-rw-r--r--arch/arm/include/asm/arch-am33xx/sys_proto.h3
-rw-r--r--board/ti/am335x/board.c202
-rw-r--r--board/ti/am335x/pmic.h76
-rw-r--r--board/ti/am335x/tps65217.h90
8 files changed, 382 insertions, 7 deletions
diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c
index d7d98d1111..74f98d7403 100644
--- a/arch/arm/cpu/armv7/am33xx/clock.c
+++ b/arch/arm/cpu/armv7/am33xx/clock.c
@@ -212,7 +212,7 @@ static void enable_per_clocks(void)
;
}
-static void mpu_pll_config(void)
+void mpu_pll_config(int mpupll_M)
{
u32 clkmode, clksel, div_m2;
@@ -226,7 +226,7 @@ static void mpu_pll_config(void)
;
clksel = clksel & (~CLK_SEL_MASK);
- clksel = clksel | ((MPUPLL_M << CLK_SEL_SHIFT) | MPUPLL_N);
+ clksel = clksel | ((mpupll_M << CLK_SEL_SHIFT) | MPUPLL_N);
writel(clksel, &cmwkup->clkseldpllmpu);
div_m2 = div_m2 & ~CLK_DIV_MASK;
@@ -359,7 +359,8 @@ void enable_emif_clocks(void)
*/
void pll_init()
{
- mpu_pll_config();
+ /* Start at 550MHz, will be tweaked up if possible. */
+ mpu_pll_config(MPUPLL_M_550);
core_pll_config();
per_pll_config();
diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c
index 1c8b6177dd..4f63ba3b57 100644
--- a/arch/arm/cpu/armv7/omap-common/boot-common.c
+++ b/arch/arm/cpu/armv7/omap-common/boot-common.c
@@ -55,6 +55,9 @@ void spl_board_init(void)
#ifdef CONFIG_SPL_NAND_SUPPORT
gpmc_init();
#endif
+#ifdef CONFIG_AM33XX
+ am33xx_spl_board_init();
+#endif
#if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT)
arch_misc_init();
#endif
diff --git a/arch/arm/include/asm/arch-am33xx/clocks_am33xx.h b/arch/arm/include/asm/arch-am33xx/clocks_am33xx.h
index d748dd2787..eff04cd7e8 100644
--- a/arch/arm/include/asm/arch-am33xx/clocks_am33xx.h
+++ b/arch/arm/include/asm/arch-am33xx/clocks_am33xx.h
@@ -21,8 +21,10 @@
#define OSC (V_OSCK/1000000)
-/* MAIN PLL Fdll = 550 MHZ, */
-#define MPUPLL_M 550
+/* MAIN PLL Fdll = 550MHz, 720MHz or 800MHz */
+#define MPUPLL_M_800 800
+#define MPUPLL_M_720 720
+#define MPUPLL_M_550 550
#define MPUPLL_N (OSC-1)
#define MPUPLL_M2 1
diff --git a/arch/arm/include/asm/arch-am33xx/ddr_defs.h b/arch/arm/include/asm/arch-am33xx/ddr_defs.h
index 7b46dbdc9d..1ac4c0df89 100644
--- a/arch/arm/include/asm/arch-am33xx/ddr_defs.h
+++ b/arch/arm/include/asm/arch-am33xx/ddr_defs.h
@@ -49,7 +49,7 @@
#define MT47H128M16RT25E_IOCTRL_VALUE 0x18B
/* Micron MT41J128M16JT-125 */
-#define MT41J128MJT125_EMIF_READ_LATENCY 0x06
+#define MT41J128MJT125_EMIF_READ_LATENCY 0x100006
#define MT41J128MJT125_EMIF_TIM1 0x0888A39B
#define MT41J128MJT125_EMIF_TIM2 0x26337FDA
#define MT41J128MJT125_EMIF_TIM3 0x501F830F
diff --git a/arch/arm/include/asm/arch-am33xx/sys_proto.h b/arch/arm/include/asm/arch-am33xx/sys_proto.h
index 588d8de82f..b60cd4bdd6 100644
--- a/arch/arm/include/asm/arch-am33xx/sys_proto.h
+++ b/arch/arm/include/asm/arch-am33xx/sys_proto.h
@@ -32,8 +32,9 @@ extern struct ctrl_stat *cstat;
u32 get_device_type(void);
void setup_clocks_for_console(void);
void ddr_pll_config(unsigned int ddrpll_M);
-
+void mpu_pll_config(int mpupll_M);
void sdelay(unsigned long);
void gpmc_init(void);
void omap_nand_switch_ecc(int);
+void am33xx_spl_board_init(void);
#endif
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index f4b972b3e9..515e14d826 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -34,6 +34,8 @@
#include <miiphy.h>
#include <cpsw.h>
#include "board.h"
+#include "pmic.h"
+#include "tps65217.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -128,6 +130,132 @@ static int read_eeprom(void)
/* UART Defines */
#ifdef CONFIG_SPL_BUILD
+/**
+ * tps65217_reg_read() - Generic function that can read a TPS65217 register
+ * @src_reg: Source register address
+ * @src_val: Address of destination variable
+ */
+
+unsigned char tps65217_reg_read(uchar src_reg, uchar *src_val)
+{
+ if (i2c_read(TPS65217_CHIP_PM, src_reg, 1, src_val, 1))
+ return 1;
+ return 0;
+}
+
+/**
+ * tps65217_reg_write() - Generic function that can write a TPS65217 PMIC
+ * register or bit field regardless of protection
+ * level.
+ *
+ * @prot_level: Register password protection.
+ * use PROT_LEVEL_NONE, PROT_LEVEL_1, or PROT_LEVEL_2
+ * @dest_reg: Register address to write.
+ * @dest_val: Value to write.
+ * @mask: Bit mask (8 bits) to be applied. Function will only
+ * change bits that are set in the bit mask.
+ *
+ * @return: 0 for success, 1 for failure.
+ */
+int tps65217_reg_write(uchar prot_level, uchar dest_reg,
+ uchar dest_val, uchar mask)
+{
+ uchar read_val;
+ uchar xor_reg;
+
+ /* if we are affecting only a bit field, read dest_reg and apply the mask */
+ if (mask != MASK_ALL_BITS) {
+ if (i2c_read(TPS65217_CHIP_PM, dest_reg, 1, &read_val, 1))
+ return 1;
+ read_val &= (~mask);
+ read_val |= (dest_val & mask);
+ dest_val = read_val;
+ }
+
+ if (prot_level > 0) {
+ xor_reg = dest_reg ^ PASSWORD_UNLOCK;
+ if (i2c_write(TPS65217_CHIP_PM, PASSWORD, 1, &xor_reg, 1))
+ return 1;
+ }
+
+ if (i2c_write(TPS65217_CHIP_PM, dest_reg, 1, &dest_val, 1))
+ return 1;
+
+ if (prot_level == PROT_LEVEL_2) {
+ if (i2c_write(TPS65217_CHIP_PM, PASSWORD, 1, &xor_reg, 1))
+ return 1;
+
+ if (i2c_write(TPS65217_CHIP_PM, dest_reg, 1, &dest_val, 1))
+ return 1;
+ }
+
+ return 0;
+}
+
+int tps65217_voltage_update(unsigned char dc_cntrl_reg, unsigned char volt_sel)
+{
+ if ((dc_cntrl_reg != DEFDCDC1) && (dc_cntrl_reg != DEFDCDC2)
+ && (dc_cntrl_reg != DEFDCDC3))
+ return 1;
+
+ /* set voltage level */
+ if (tps65217_reg_write(PROT_LEVEL_2, dc_cntrl_reg, volt_sel, MASK_ALL_BITS))
+ return 1;
+
+ /* set GO bit to initiate voltage transition */
+ if (tps65217_reg_write(PROT_LEVEL_2, DEFSLEW, DCDC_GO, DCDC_GO))
+ return 1;
+
+ return 0;
+}
+
+/*
+ * voltage switching for MPU frequency switching.
+ * @module = mpu - 0, core - 1
+ * @vddx_op_vol_sel = vdd voltage to set
+ */
+
+#define MPU 0
+#define CORE 1
+
+int voltage_update(unsigned int module, unsigned char vddx_op_vol_sel)
+{
+ uchar buf[4];
+ unsigned int reg_offset;
+
+ if(module == MPU)
+ reg_offset = PMIC_VDD1_OP_REG;
+ else
+ reg_offset = PMIC_VDD2_OP_REG;
+
+ /* Select VDDx OP */
+ if (i2c_read(PMIC_CTRL_I2C_ADDR, reg_offset, 1, buf, 1))
+ return 1;
+
+ buf[0] &= ~PMIC_OP_REG_CMD_MASK;
+
+ if (i2c_write(PMIC_CTRL_I2C_ADDR, reg_offset, 1, buf, 1))
+ return 1;
+
+ /* Configure VDDx OP Voltage */
+ if (i2c_read(PMIC_CTRL_I2C_ADDR, reg_offset, 1, buf, 1))
+ return 1;
+
+ buf[0] &= ~PMIC_OP_REG_SEL_MASK;
+ buf[0] |= vddx_op_vol_sel;
+
+ if (i2c_write(PMIC_CTRL_I2C_ADDR, reg_offset, 1, buf, 1))
+ return 1;
+
+ if (i2c_read(PMIC_CTRL_I2C_ADDR, reg_offset, 1, buf, 1))
+ return 1;
+
+ if ((buf[0] & PMIC_OP_REG_SEL_MASK ) != vddx_op_vol_sel)
+ return 1;
+
+ return 0;
+}
+
#define UART_RESET (0x1 << 1)
#define UART_CLK_RUNNING_MASK 0x1
#define UART_SMART_IDLE_EN (0x1 << 0x3)
@@ -263,6 +391,80 @@ static struct emif_regs ddr3_evm_emif_reg_data = {
.zq_config = MT41J512M8RH125_ZQ_CFG,
.emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY,
};
+
+void am33xx_spl_board_init(void)
+{
+ if (!strncmp("A335BONE", header.name, 8)) {
+ /* BeagleBone PMIC Code */
+ uchar pmic_status_reg;
+
+ if (i2c_probe(TPS65217_CHIP_PM))
+ return;
+
+ if (tps65217_reg_read(STATUS, &pmic_status_reg))
+ return;
+
+ /* Increase USB current limit to 1300mA */
+ if (tps65217_reg_write(PROT_LEVEL_NONE, POWER_PATH,
+ USB_INPUT_CUR_LIMIT_1300MA,
+ USB_INPUT_CUR_LIMIT_MASK))
+ printf("tps65217_reg_write failure\n");
+
+ /* Only perform PMIC configurations if board rev > A1 */
+ if (!strncmp(header.version, "00A1", 4))
+ return;
+
+ /* Set DCDC2 (MPU) voltage to 1.275V */
+ if (tps65217_voltage_update(DEFDCDC2,
+ DCDC_VOLT_SEL_1275MV)) {
+ printf("tps65217_voltage_update failure\n");
+ return;
+ }
+
+ /* Set LDO3, LDO4 output voltage to 3.3V */
+ if (tps65217_reg_write(PROT_LEVEL_2, DEFLS1,
+ LDO_VOLTAGE_OUT_3_3, LDO_MASK))
+ printf("tps65217_reg_write failure\n");
+
+ if (tps65217_reg_write(PROT_LEVEL_2, DEFLS2,
+ LDO_VOLTAGE_OUT_3_3, LDO_MASK))
+ printf("tps65217_reg_write failure\n");
+
+ if (!(pmic_status_reg & PWR_SRC_AC_BITMASK)) {
+ printf("No AC power, disabling frequency switch\n");
+ return;
+ }
+
+ /* Set MPU Frequency to 720MHz */
+ mpu_pll_config(MPUPLL_M_720);
+ } else {
+ uchar buf[4];
+ /*
+ * EVM PMIC code. All boards currently want an MPU voltage
+ * of 1.2625V and CORE voltage of 1.1375V to operate at
+ * 720MHz.
+ */
+ if (i2c_probe(PMIC_CTRL_I2C_ADDR))
+ return;
+
+ /* VDD1/2 voltage selection register access by control i/f */
+ if (i2c_read(PMIC_CTRL_I2C_ADDR, PMIC_DEVCTRL_REG, 1, buf, 1))
+ return;
+
+ buf[0] |= PMIC_DEVCTRL_REG_SR_CTL_I2C_SEL_CTL_I2C;
+
+ if (i2c_write(PMIC_CTRL_I2C_ADDR, PMIC_DEVCTRL_REG, 1, buf, 1))
+ return;
+
+ if (!voltage_update(MPU, PMIC_OP_REG_SEL_1_2_6) &&
+ !voltage_update(CORE, PMIC_OP_REG_SEL_1_1_3)) {
+ if (board_is_evm_15_or_later())
+ mpu_pll_config(MPUPLL_M_800);
+ else
+ mpu_pll_config(MPUPLL_M_720);
+ }
+ }
+}
#endif
/*
diff --git a/board/ti/am335x/pmic.h b/board/ti/am335x/pmic.h
new file mode 100644
index 0000000000..e258c445cc
--- /dev/null
+++ b/board/ti/am335x/pmic.h
@@ -0,0 +1,76 @@
+/*
+ * pmic.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 PMIC_h
+#define PMIC_H
+
+/*
+ * The PMIC on this board is a TPS65910.
+ */
+
+#define PMIC_SR_I2C_ADDR 0x12
+#define PMIC_CTRL_I2C_ADDR 0x2D
+/* PMIC Register offsets */
+#define PMIC_VDD1_REG 0x21
+#define PMIC_VDD1_OP_REG 0x22
+#define PMIC_VDD2_REG 0x24
+#define PMIC_VDD2_OP_REG 0x25
+#define PMIC_DEVCTRL_REG 0x3f
+
+/* VDD2 & VDD1 control register (VDD2_REG & VDD1_REG) */
+#define PMIC_VGAIN_SEL_MASK (0x3 << 6)
+#define PMIC_ILMAX_MASK (0x1 << 5)
+#define PMIC_TSTEP_MASK (0x7 << 2)
+#define PMIC_ST_MASK (0x3)
+
+#define PMIC_REG_VGAIN_SEL_X1 (0x0 << 6)
+#define PMIC_REG_VGAIN_SEL_X1_0 (0x1 << 6)
+#define PMIC_REG_VGAIN_SEL_X3 (0x2 << 6)
+#define PMIC_REG_VGAIN_SEL_X4 (0x3 << 6)
+
+#define PMIC_REG_ILMAX_1_0_A (0x0 << 5)
+#define PMIC_REG_ILMAX_1_5_A (0x1 << 5)
+
+#define PMIC_REG_TSTEP_ (0x0 << 2)
+#define PMIC_REG_TSTEP_12_5 (0x1 << 2)
+#define PMIC_REG_TSTEP_9_4 (0x2 << 2)
+#define PMIC_REG_TSTEP_7_5 (0x3 << 2)
+#define PMIC_REG_TSTEP_6_25 (0x4 << 2)
+#define PMIC_REG_TSTEP_4_7 (0x5 << 2)
+#define PMIC_REG_TSTEP_3_12 (0x6 << 2)
+#define PMIC_REG_TSTEP_2_5 (0x7 << 2)
+
+#define PMIC_REG_ST_OFF (0x0)
+#define PMIC_REG_ST_ON_HI_POW (0x1)
+#define PMIC_REG_ST_OFF_1 (0x2)
+#define PMIC_REG_ST_ON_LOW_POW (0x3)
+
+
+/* VDD2 & VDD1 voltage selection register. (VDD2_OP_REG & VDD1_OP_REG) */
+#define PMIC_OP_REG_SEL (0x7F)
+
+#define PMIC_OP_REG_CMD_MASK (0x1 << 7)
+#define PMIC_OP_REG_CMD_OP (0x0 << 7)
+#define PMIC_OP_REG_CMD_SR (0x1 << 7)
+
+#define PMIC_OP_REG_SEL_MASK (0x7F)
+#define PMIC_OP_REG_SEL_1_1_3 (0x2E) /* 1.1375 V */
+#define PMIC_OP_REG_SEL_1_2_6 (0x38) /* 1.2625 V */
+
+/* Device control register . (DEVCTRL_REG) */
+#define PMIC_DEVCTRL_REG_SR_CTL_I2C_MASK (0x1 << 4)
+#define PMIC_DEVCTRL_REG_SR_CTL_I2C_SEL_SR_I2C (0x0 << 4)
+#define PMIC_DEVCTRL_REG_SR_CTL_I2C_SEL_CTL_I2C (0x1 << 4)
+
+#endif
diff --git a/board/ti/am335x/tps65217.h b/board/ti/am335x/tps65217.h
new file mode 100644
index 0000000000..3197209a98
--- /dev/null
+++ b/board/ti/am335x/tps65217.h
@@ -0,0 +1,90 @@
+/*
+ * (C) Copyright 2011
+ * Texas Instruments, <www.ti.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __TPS65217_H__
+#define __TPS65217_H__
+
+#include <common.h>
+#include <i2c.h>
+
+/* I2C chip address */
+#define TPS65217_CHIP_PM 0x24
+
+/* Registers */
+#define CHIPID 0x00
+#define POWER_PATH 0x01
+#define INTERRUPT 0x02
+#define CHGCONFIG0 0x03
+#define CHGCONFIG1 0x04
+#define CHGCONFIG2 0x05
+#define CHGCONFIG3 0x06
+#define WLEDCTRL1 0x07
+#define WLEDCTRL2 0x08
+#define MUXCTRL 0x09
+#define STATUS 0x0A
+#define PASSWORD 0x0B
+#define PGOOD 0x0C
+#define DEFPG 0x0D
+#define DEFDCDC1 0x0E
+#define DEFDCDC2 0x0F
+#define DEFDCDC3 0x10
+#define DEFSLEW 0x11
+#define DEFLDO1 0x12
+#define DEFLDO2 0x13
+#define DEFLS1 0x14
+#define DEFLS2 0x15
+#define ENABLE 0x16
+#define DEFUVLO 0x18
+#define SEQ1 0x19
+#define SEQ2 0x1A
+#define SEQ3 0x1B
+#define SEQ4 0x1C
+#define SEQ5 0x1D
+#define SEQ6 0x1E
+
+#define PROT_LEVEL_NONE 0x00
+#define PROT_LEVEL_1 0x01
+#define PROT_LEVEL_2 0x02
+
+#define PASSWORD_LOCK_FOR_WRITE 0x00
+#define PASSWORD_UNLOCK 0x7D
+
+#define DCDC_GO 0x80
+
+#define MASK_ALL_BITS 0xFF
+
+#define USB_INPUT_CUR_LIMIT_MASK 0x03
+#define USB_INPUT_CUR_LIMIT_100MA 0x00
+#define USB_INPUT_CUR_LIMIT_500MA 0x01
+#define USB_INPUT_CUR_LIMIT_1300MA 0x02
+#define USB_INPUT_CUR_LIMIT_1800MA 0x03
+
+#define DCDC_VOLT_SEL_1275MV 0x0F
+#define DCDC_VOLT_SEL_135MV 0x12
+
+#define LDO_MASK 0x1F
+#define LDO_VOLTAGE_OUT_3_3 0x1F
+
+#define PWR_SRC_USB_BITMASK 0x4
+#define PWR_SRC_AC_BITMASK 0x8
+#endif