FIX: [uboot] change findings from rs regarding shield

SVN commit 24938@trunk
This commit is contained in:
Stefan Eichenberger 2017-09-04 15:17:51 +00:00 committed by Moritz Rosenthal
parent 1e663e39f5
commit f702243ee9
6 changed files with 117 additions and 106 deletions

View File

@ -42,6 +42,7 @@
DECLARE_GLOBAL_DATA_PTR;
/* GPIO that controls power to DDR on EVM-SK */
#define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
#define GPIO_DDR_VTT_EN GPIO_TO_PIN(0, 7)
#define ICE_GPIO_DDR_VTT_EN GPIO_TO_PIN(0, 18)
#define GPIO_PR1_MII_CTRL GPIO_TO_PIN(3, 4)

View File

@ -525,6 +525,7 @@ static void set_fdtshieldcmd(const char *fdt_cmd)
struct shield_command {
int shield_id;
const char *name;
const char *default_shieldcmd;
const char *fdtshieldcmd;
};
@ -535,12 +536,14 @@ struct shield_command {
static struct shield_command known_shield_commands[] = {
{
SHIELD_COM_IO,
"comio",
"shield comio mode rs232",
"fdt get value serial0 /aliases serial0;" \
"fdt set $serial0 status okay"
},
{
SHIELD_DUALCAN,
"dualcan",
"shield dualcan termination off off",
"fdt get value can0 /aliases d_can0;" \
"fdt get value can1 /aliases d_can1;" \
@ -572,7 +575,7 @@ static void shield_config(void)
int shield_id = bd_get_shield(0);
if (shield_id < 0) {
printf("No shield found in bd\n");
debug("No shield found in bd\n");
return;
}
@ -582,16 +585,20 @@ static void shield_config(void)
return;
}
printf("Shield found: %s\n", cmd->name);
shieldcmd = cmd->default_shieldcmd;
/* If a shield configuration set by linux take it without bd check, we asume that Linux knows
* what to do. */
len = read_file("/root/boot/shieldcmd", shieldcmd_linux, MAX_SHIELD_CMD_LEN);
if (len > 0) {
puts("Shield command found in file, using it\n");
debug("Shield command found in file, using it\n");
shieldcmd = shieldcmd_linux;
}
printf("Shield command: %s\n", shieldcmd);
setenv("shieldcmd", shieldcmd);
set_fdtshieldcmd(cmd->fdtshieldcmd);

View File

@ -1,4 +1,4 @@
#define DEBUG
#undef DEBUG
#include <common.h>
#include <asm/gpio.h>
@ -57,7 +57,6 @@ int shield_set_mode(const char* shield_type, int argc, char * const argv[])
static int do_shieldmode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
if (argc < 3) {
puts("Invalid command (see help)\n");
return -1;
}

View File

@ -1,4 +1,4 @@
#define DEBUG
#undef DEBUG
#include <common.h>
#include <asm/gpio.h>
@ -37,7 +37,7 @@ static int request_gpios(void)
{
int ret;
debug("Shiled configure gpios\n");
debug("Shield configure gpios\n");
ret = shield_gpio_request_as_input(NETBIRD_GPIO_RST_SHIELD_N, "shield-rst");
if ((ret < 0))
return -1;
@ -60,7 +60,7 @@ static int configure_shieldmode(int mode)
int ret;
if (mode < 0 || mode > 3) {
printf("Invalid shield mode %d\n", mode);
debug("Invalid shield mode %d\n", mode);
return -1;
}
@ -144,8 +144,8 @@ static int get_termination(const char* termination)
return 0;
}
printf ("Invalid termination mode %s (falling back to off)", termination);
return 0;
debug ("Invalid termination mode %s (falling back to off)", termination);
return -1;
}
static int get_mode_from_args(char * const argv[], int argc)
@ -157,12 +157,15 @@ static int get_mode_from_args(char * const argv[], int argc)
assert(argc == (CAN_PORTS + 1));
if (strcmp ("termination", argv[0])) {
puts("The only option for dualcan is terminations\n");
debug("The only option for dualcan is terminations\n");
return -1;
}
for (i = 0; i < CAN_PORTS; i ++) {
terminations[i] = get_termination(argv[i + 1]);
if (terminations[i] < 0) {
return -1;
}
}
/* Termination is inverse */
@ -172,12 +175,11 @@ static int get_mode_from_args(char * const argv[], int argc)
static int set_shieldmode(char * const argv[], int argc)
{
if (argc != 3) {
puts("Too few arguments for dualcan\n");
debug("Too few arguments for dualcan\n");
return -1;
}
configure_shieldmode(get_mode_from_args(argv, argc));
return 0;
return configure_shieldmode(get_mode_from_args(argv, argc));
}
struct shield_t can_shield = {

View File

@ -1,4 +1,4 @@
/* #define DEBUG */
#undef DEBUG
#include <common.h>
#include <asm/gpio.h>
@ -58,7 +58,7 @@ static int configure_shieldmode(int mode)
int ret;
if (mode < 0 || mode > 3) {
printf("Invalid shield mode %d\n", mode);
debug ("Invalid shield mode %d\n", mode);
return -1;
}
@ -138,7 +138,6 @@ static int configure_shieldmode(int mode)
}
return 0;
}
static int get_rs232(const char *mode)
@ -160,8 +159,8 @@ static int get_termination(const char* termination)
return 0;
}
printf ("Invalid termination mode %s (falling back to off)", termination);
return 0;
debug ("Invalid termination mode %s (falling back to off)", termination);
return -1;
}
static int get_mode_from_args(char * const argv[], int argc)
@ -172,7 +171,7 @@ static int get_mode_from_args(char * const argv[], int argc)
assert(argc >= 2);
if (strcmp ("mode", argv[0])) {
puts("Invalid arguments (see help)\n");
debug("Invalid arguments (see help)\n");
return -1;
}
@ -180,10 +179,14 @@ static int get_mode_from_args(char * const argv[], int argc)
if (argc > 2) {
if (rs232 || strcmp("termination", argv[2])) {
puts("Invalid arguments, do not configure termination\n");
debug("Invalid arguments, do not configure termination\n");
return -1;
}
else {
termination = get_termination(argv[3]);
if (termination < 0) {
return -1;
}
}
}
@ -194,13 +197,12 @@ static int get_mode_from_args(char * const argv[], int argc)
int set_shieldmode(char * const argv[], int argc)
{
if (argc < 2) {
puts("Too few arguments for comio\n");
debug("Too few arguments for comio\n");
return -1;
}
configure_shieldmode(get_mode_from_args(argv, argc));
return 0;
/* -1 will make configure_shieldmode to faile and is okay therefore */
return configure_shieldmode(get_mode_from_args(argv, argc));
}
struct shield_t comio_shield = {