summaryrefslogtreecommitdiff
path: root/board/BuR
diff options
context:
space:
mode:
authorHannes Schmelzer <hannes.schmelzer@br-automation.com>2019-04-10 14:13:16 +0200
committerTom Rini <trini@konsulko.com>2019-04-26 17:51:51 -0400
commit1d260739bdb7ef0e8fc58654e52ecea69eaaf672 (patch)
tree6d22fbb2b935c4721009bedfb6a00ce20ad794c8 /board/BuR
parent2b1e242423cc9097b48ffb5454aad370055e7e93 (diff)
downloadu-boot-1d260739bdb7ef0e8fc58654e52ecea69eaaf672.tar.gz
u-boot-1d260739bdb7ef0e8fc58654e52ecea69eaaf672.tar.bz2
u-boot-1d260739bdb7ef0e8fc58654e52ecea69eaaf672.zip
board/BuR/brxre1: use common resetcontroller implementation
The handling of regarding bootmode and early setup has been moved to central location 'common/br_resetc.c', so use this on brxre1 board. Signed-off-by: Hannes Schmelzer <hannes.schmelzer@br-automation.com>
Diffstat (limited to 'board/BuR')
-rw-r--r--board/BuR/brxre1/Makefile1
-rw-r--r--board/BuR/brxre1/board.c159
2 files changed, 18 insertions, 142 deletions
diff --git a/board/BuR/brxre1/Makefile b/board/BuR/brxre1/Makefile
index 1cf7124dbd..1d224e9e71 100644
--- a/board/BuR/brxre1/Makefile
+++ b/board/BuR/brxre1/Makefile
@@ -6,5 +6,6 @@
# Bernecker & Rainer Industrielektronik GmbH - http://www.br-automation.com/
obj-$(CONFIG_SPL_BUILD) += mux.o
+obj-y += ../common/br_resetc.o
obj-y += ../common/common.o
obj-y += board.o
diff --git a/board/BuR/brxre1/board.c b/board/BuR/brxre1/board.c
index 6639f22784..0d1c6c4720 100644
--- a/board/BuR/brxre1/board.c
+++ b/board/BuR/brxre1/board.c
@@ -23,49 +23,20 @@
#include <asm/emif.h>
#include <asm/gpio.h>
#include <dm.h>
-#include <i2c.h>
#include <power/tps65217.h>
#include "../common/bur_common.h"
-#include <lcd.h>
+#include "../common/br_resetc.h"
/* -------------------------------------------------------------------------*/
/* -- defines for used GPIO Hardware -- */
-/* -- PSOC Resetcontroller Register defines -- */
#define ESC_KEY (0 + 19)
#define LCD_PWR (0 + 5)
-/* I2C Address of controller */
-#define RSTCTRL_ADDR 0x75
-/* Register for CTRL-word */
-#define RSTCTRL_CTRLREG 0x01
-/* Register for giving some information to VxWorks OS */
-#define RSTCTRL_SCRATCHREG 0x04
-
-/* -- defines for RSTCTRL_CTRLREG -- */
-#define RSTCTRL_FORCE_PWR_NEN 0x0404
-#define RSTCTRL_CAN_STB 0x4040
+#define RSTCTRL_FORCE_PWR_NEN 0x04
+#define RSTCTRL_CAN_STB 0x40
DECLARE_GLOBAL_DATA_PTR;
-static int rstctrl_rw(u8 reg, unsigned char rnw, void *pdat, int size)
-{
- struct udevice *i2cdev;
- int rc;
-
- rc = i2c_get_chip_for_busnum(0, RSTCTRL_ADDR, 1, &i2cdev);
- if (rc >= 0) {
- if (rnw)
- rc = dm_i2c_read(i2cdev, reg, pdat, size);
- else
- rc = dm_i2c_write(i2cdev, reg, pdat, size);
- } else {
- printf("%s: cannot get udevice for chip 0x%02x!\n",
- __func__, RSTCTRL_ADDR);
- }
-
- return rc;
-}
-
#if defined(CONFIG_SPL_BUILD)
static const struct ddr_data ddr3_data = {
.datardsratio0 = MT41K256M16HA125E_RD_DQS,
@@ -108,7 +79,6 @@ const struct dpll_params dpll_ddr3 = { 400, OSC - 1, 1, -1, -1, -1, -1};
void am33xx_spl_board_init(void)
{
- unsigned short buf;
int rc;
struct cm_perpll *const cmper = (struct cm_perpll *)CM_PER;
@@ -142,10 +112,10 @@ void am33xx_spl_board_init(void)
enable_i2c_pin_mux();
/* power-ON 3V3 via Resetcontroller */
- buf = RSTCTRL_FORCE_PWR_NEN | RSTCTRL_CAN_STB;
- rc = rstctrl_rw(RSTCTRL_CTRLREG, 0, (uint8_t *)&buf, sizeof(buf));
+ rc = br_resetc_regset(RSTCTRL_CTRLREG,
+ RSTCTRL_FORCE_PWR_NEN | RSTCTRL_CAN_STB);
if (rc != 0)
- printf("ERROR: cannot write to resetc (turn on PWR_nEN)\n");
+ printf("ERROR: cannot write to resetc (turn on PWR_nEN)!\n");
pmicsetup(0, 0);
}
@@ -168,6 +138,9 @@ void sdram_init(void)
*/
int board_init(void)
{
+ /* request common used gpios */
+ gpio_request(ESC_KEY, "boot-key");
+
if (power_tps65217_init(0))
printf("WARN: cannot setup PMIC 0x24 @ bus #0, not found!.\n");
@@ -175,117 +148,19 @@ int board_init(void)
}
#ifdef CONFIG_BOARD_LATE_INIT
-int board_late_init(void)
-{
- const unsigned int toff = 1000;
- unsigned int cnt = 3;
- unsigned short buf = 0xAAAA;
- unsigned char scratchreg = 0;
- int rc;
- /* try to read out some boot-instruction from resetcontroller */
- rc = rstctrl_rw(RSTCTRL_SCRATCHREG, 1, &scratchreg, sizeof(scratchreg));
- if (rc != 0)
- printf("ERROR: read scratchregister (resetc) failed!\n");
+int board_boot_key(void)
+{
+ return gpio_get_value(ESC_KEY);
+}
- if (gpio_request(ESC_KEY, "boot-key") != 0) {
- printf("cannot request boot-key!\n");
- } else if (gpio_get_value(ESC_KEY)) {
- do {
- lcd_position_cursor(1, 8);
- switch (cnt) {
- case 3:
- lcd_puts(
- "release ESC-KEY to enter SERVICE-mode.");
- break;
- case 2:
- lcd_puts(
- "release ESC-KEY to enter DIAGNOSE-mode.");
- break;
- case 1:
- lcd_puts(
- "release ESC-KEY to enter BOOT-mode. ");
- break;
- }
- mdelay(toff);
- cnt--;
- if (!gpio_get_value(ESC_KEY) &&
- gpio_get_value(PUSH_KEY) && 2 == cnt) {
- lcd_position_cursor(1, 8);
- lcd_puts(
- "switching to network-console ... ");
- env_set("bootcmd", "run netconsole");
- cnt = 4;
- break;
- } else if (!gpio_get_value(ESC_KEY) &&
- gpio_get_value(PUSH_KEY) && 1 == cnt) {
- lcd_position_cursor(1, 8);
- lcd_puts(
- "starting u-boot script from USB ... ");
- env_set("bootcmd", "run usbscript");
- cnt = 4;
- break;
- } else if ((!gpio_get_value(ESC_KEY) &&
- gpio_get_value(PUSH_KEY) && cnt == 0) ||
- (gpio_get_value(ESC_KEY) &&
- gpio_get_value(PUSH_KEY) && cnt == 0)) {
- lcd_position_cursor(1, 8);
- lcd_puts(
- "starting script from network ... ");
- env_set("bootcmd", "run netscript");
- cnt = 4;
- break;
- } else if (!gpio_get_value(ESC_KEY)) {
- break;
- }
- } while (cnt);
- } else if (scratchreg == 0xCC) {
- lcd_position_cursor(1, 8);
- lcd_puts(
- "starting vxworks from network ... ");
- env_set("bootcmd", "run netboot");
- cnt = 4;
- } else if (scratchreg == 0xCD) {
- lcd_position_cursor(1, 8);
- lcd_puts(
- "starting script from network ... ");
- env_set("bootcmd", "run netscript");
- cnt = 4;
- } else if (scratchreg == 0xCE) {
- lcd_position_cursor(1, 8);
- lcd_puts(
- "starting AR from eMMC ... ");
- env_set("bootcmd", "run mmcboot");
- cnt = 4;
- }
+int board_late_init(void)
+{
+ char othbootargs[128];
- lcd_position_cursor(1, 8);
- switch (cnt) {
- case 0:
- lcd_puts("entering BOOT-mode. ");
- env_set("bootcmd", "run defaultAR");
- buf = 0x0000;
- break;
- case 1:
- lcd_puts("entering DIAGNOSE-mode. ");
- buf = 0x0F0F;
- break;
- case 2:
- lcd_puts("entering SERVICE mode. ");
- buf = 0xB4B4;
- break;
- case 3:
- lcd_puts("loading OS... ");
- buf = 0x0404;
- break;
- }
- /* write bootinfo into scratchregister of resetcontroller */
- rc = rstctrl_rw(RSTCTRL_SCRATCHREG, 0, (uint8_t *)&buf, sizeof(buf));
- if (rc != 0)
- printf("ERROR: write scratchregister (resetc) failed!\n");
+ br_resetc_bmode();
/* setup othbootargs for bootvx-command (vxWorks bootline) */
- char othbootargs[128];
snprintf(othbootargs, sizeof(othbootargs),
"u=vxWorksFTP pw=vxWorks o=0x%08x;0x%08x;0x%08x;0x%08x",
(u32)gd->fb_base - 0x20,