2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2013-08-19 14:39:01 +00:00
|
|
|
/*
|
|
|
|
* Board functions for TI AM335X based pxm2 board
|
|
|
|
* (C) Copyright 2013 Siemens Schweiz AG
|
|
|
|
* (C) Heiko Schocher, DENX Software Engineering, hs@denx.de.
|
|
|
|
*
|
|
|
|
* Based on:
|
|
|
|
* u-boot:/board/ti/am335x/board.c
|
|
|
|
*
|
|
|
|
* Board functions for TI AM335X based boards
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-08-01 15:46:51 +00:00
|
|
|
#include <env.h>
|
2013-08-19 14:39:01 +00:00
|
|
|
#include <errno.h>
|
2019-11-14 19:57:46 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <malloc.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <net.h>
|
2013-08-19 14:39:01 +00:00
|
|
|
#include <spl.h>
|
|
|
|
#include <asm/arch/cpu.h>
|
|
|
|
#include <asm/arch/hardware.h>
|
|
|
|
#include <asm/arch/omap.h>
|
|
|
|
#include <asm/arch/ddr_defs.h>
|
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/gpio.h>
|
|
|
|
#include <asm/arch/mmc_host_def.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/emif.h>
|
|
|
|
#include <asm/gpio.h>
|
|
|
|
#include <i2c.h>
|
|
|
|
#include <miiphy.h>
|
|
|
|
#include <cpsw.h>
|
|
|
|
#include <watchdog.h>
|
|
|
|
#include "board.h"
|
|
|
|
#include "../common/factoryset.h"
|
|
|
|
#include "pmic.h"
|
|
|
|
#include <nand.h>
|
|
|
|
#include <bmp_layout.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_SPL_BUILD
|
|
|
|
static void board_init_ddr(void)
|
|
|
|
{
|
|
|
|
struct emif_regs pxm2_ddr3_emif_reg_data = {
|
|
|
|
.sdram_config = 0x41805332,
|
|
|
|
.sdram_tim1 = 0x666b3c9,
|
|
|
|
.sdram_tim2 = 0x243631ca,
|
|
|
|
.sdram_tim3 = 0x33f,
|
|
|
|
.emif_ddr_phy_ctlr_1 = 0x100005,
|
|
|
|
.zq_config = 0,
|
|
|
|
.ref_ctrl = 0x81a,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ddr_data pxm2_ddr3_data = {
|
|
|
|
.datardsratio0 = 0x81204812,
|
|
|
|
.datawdsratio0 = 0,
|
|
|
|
.datafwsratio0 = 0x8020080,
|
|
|
|
.datawrsratio0 = 0x4010040,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cmd_control pxm2_ddr3_cmd_ctrl_data = {
|
|
|
|
.cmd0csratio = 0x80,
|
|
|
|
.cmd0iclkout = 0,
|
|
|
|
.cmd1csratio = 0x80,
|
|
|
|
.cmd1iclkout = 0,
|
|
|
|
.cmd2csratio = 0x80,
|
|
|
|
.cmd2iclkout = 0,
|
|
|
|
};
|
|
|
|
|
2013-12-10 09:32:21 +00:00
|
|
|
const struct ctrl_ioregs ioregs = {
|
2014-04-24 15:57:52 +00:00
|
|
|
.cm0ioctl = DDR_IOCTRL_VAL,
|
|
|
|
.cm1ioctl = DDR_IOCTRL_VAL,
|
|
|
|
.cm2ioctl = DDR_IOCTRL_VAL,
|
|
|
|
.dt0ioctl = DDR_IOCTRL_VAL,
|
|
|
|
.dt1ioctl = DDR_IOCTRL_VAL,
|
2013-12-10 09:32:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config_ddr(DDR_PLL_FREQ, &ioregs, &pxm2_ddr3_data,
|
2013-08-19 14:39:01 +00:00
|
|
|
&pxm2_ddr3_cmd_ctrl_data, &pxm2_ddr3_emif_reg_data, 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 OSC (V_OSCK/1000000)
|
|
|
|
|
|
|
|
const struct dpll_params dpll_mpu_pxm2 = {
|
|
|
|
720, OSC-1, 1, -1, -1, -1, -1};
|
|
|
|
|
|
|
|
void spl_siemens_board_init(void)
|
|
|
|
{
|
|
|
|
uchar buf[4];
|
|
|
|
/*
|
|
|
|
* pxm2 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;
|
|
|
|
|
|
|
|
/* Frequency switching for OPP 120 */
|
|
|
|
if (voltage_update(MPU, PMIC_OP_REG_SEL_1_2_6) ||
|
|
|
|
voltage_update(CORE, PMIC_OP_REG_SEL_1_1_3)) {
|
|
|
|
printf("voltage update failed\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* if def CONFIG_SPL_BUILD */
|
|
|
|
|
|
|
|
int read_eeprom(void)
|
|
|
|
{
|
|
|
|
/* nothing ToDo here for this board */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
|
2021-07-11 03:14:26 +00:00
|
|
|
(defined(CONFIG_SPL_ETH) && defined(CONFIG_SPL_BUILD))
|
2013-08-19 14:39:01 +00:00
|
|
|
static void cpsw_control(int enabled)
|
|
|
|
{
|
|
|
|
/* VTP can be added here */
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct cpsw_slave_data cpsw_slaves[] = {
|
|
|
|
{
|
|
|
|
.slave_reg_ofs = 0x208,
|
|
|
|
.sliver_reg_ofs = 0xd80,
|
2014-02-18 12:31:52 +00:00
|
|
|
.phy_addr = 0,
|
2013-08-19 14:39:01 +00:00
|
|
|
.phy_if = PHY_INTERFACE_MODE_RMII,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.slave_reg_ofs = 0x308,
|
|
|
|
.sliver_reg_ofs = 0xdc0,
|
2014-02-18 12:31:52 +00:00
|
|
|
.phy_addr = 1,
|
2013-08-19 14:39:01 +00:00
|
|
|
.phy_if = PHY_INTERFACE_MODE_RMII,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct cpsw_platform_data cpsw_data = {
|
|
|
|
.mdio_base = CPSW_MDIO_BASE,
|
|
|
|
.cpsw_base = CPSW_BASE,
|
|
|
|
.mdio_div = 0xff,
|
|
|
|
.channels = 4,
|
|
|
|
.cpdma_reg_ofs = 0x800,
|
|
|
|
.slaves = 1,
|
|
|
|
.slave_data = cpsw_slaves,
|
|
|
|
.ale_reg_ofs = 0xd00,
|
|
|
|
.ale_entries = 1024,
|
|
|
|
.host_port_reg_ofs = 0x108,
|
|
|
|
.hw_stats_reg_ofs = 0x900,
|
|
|
|
.bd_ram_ofs = 0x2000,
|
|
|
|
.mac_control = (1 << 5),
|
|
|
|
.control = cpsw_control,
|
|
|
|
.host_port_num = 0,
|
|
|
|
.version = CPSW_CTRL_VERSION_2,
|
|
|
|
};
|
|
|
|
#endif /* #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) */
|
|
|
|
|
|
|
|
#if defined(CONFIG_DRIVER_TI_CPSW) || \
|
2015-08-04 15:04:06 +00:00
|
|
|
(defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET))
|
2020-06-26 06:13:33 +00:00
|
|
|
int board_eth_init(struct bd_info *bis)
|
2013-08-19 14:39:01 +00:00
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
#if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
|
2021-07-11 03:14:26 +00:00
|
|
|
(defined(CONFIG_SPL_ETH) && defined(CONFIG_SPL_BUILD))
|
2013-08-19 14:39:01 +00:00
|
|
|
struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
|
|
|
|
#ifdef CONFIG_FACTORYSET
|
|
|
|
int rv;
|
2015-04-08 06:41:04 +00:00
|
|
|
if (!is_valid_ethaddr(factory_dat.mac))
|
2013-08-19 14:39:01 +00:00
|
|
|
printf("Error: no valid mac address\n");
|
|
|
|
else
|
2017-08-03 18:22:11 +00:00
|
|
|
eth_env_set_enetaddr("ethaddr", factory_dat.mac);
|
2013-08-19 14:39:01 +00:00
|
|
|
#endif /* #ifdef CONFIG_FACTORYSET */
|
|
|
|
|
|
|
|
/* Set rgmii mode and enable rmii clock to be sourced from chip */
|
2014-11-05 09:23:21 +00:00
|
|
|
writel(RGMII_MODE_ENABLE | RGMII_INT_DELAY, &cdev->miisel);
|
2013-08-19 14:39:01 +00:00
|
|
|
|
|
|
|
rv = cpsw_register(&cpsw_data);
|
|
|
|
if (rv < 0)
|
|
|
|
printf("Error %d registering CPSW switch\n", rv);
|
|
|
|
else
|
|
|
|
n += rv;
|
|
|
|
#endif
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
#endif /* #if defined(CONFIG_DRIVER_TI_CPSW) */
|
|
|
|
|
2014-11-18 10:51:06 +00:00
|
|
|
#ifdef CONFIG_BOARD_LATE_INIT
|
|
|
|
int board_late_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
omap_nand_switch_ecc(1, 8);
|
|
|
|
|
|
|
|
#ifdef CONFIG_FACTORYSET
|
|
|
|
if (factory_dat.asn[0] != 0) {
|
|
|
|
char tmp[2 * MAX_STRING_LENGTH + 2];
|
|
|
|
|
|
|
|
if (strncmp((const char *)factory_dat.asn, "PXM50", 5) == 0)
|
|
|
|
factory_dat.pxm50 = 1;
|
|
|
|
else
|
|
|
|
factory_dat.pxm50 = 0;
|
|
|
|
sprintf(tmp, "%s_%s", factory_dat.asn,
|
|
|
|
factory_dat.comp_version);
|
2017-08-03 18:22:09 +00:00
|
|
|
ret = env_set("boardid", tmp);
|
2014-11-18 10:51:06 +00:00
|
|
|
if (ret)
|
|
|
|
printf("error setting board id\n");
|
|
|
|
} else {
|
|
|
|
factory_dat.pxm50 = 1;
|
2017-08-03 18:22:09 +00:00
|
|
|
ret = env_set("boardid", "PXM50_1.0");
|
2014-11-18 10:51:06 +00:00
|
|
|
if (ret)
|
|
|
|
printf("error setting board id\n");
|
|
|
|
}
|
|
|
|
debug("PXM50: %d\n", factory_dat.pxm50);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-08-19 14:39:01 +00:00
|
|
|
#include "../common/board.c"
|