mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-01 10:22:48 +02:00
Implement GPIO changing with SPL commands.
This commit is contained in:
parent
4f6670e5af
commit
8c36acee57
@ -38,6 +38,10 @@ int ingenic_loadstage(void *hndl, int id, const char *filename);
|
||||
#define INGENIC_STAGE1 1
|
||||
#define INGENIC_STAGE2 2
|
||||
|
||||
#define SPL_DEBUG_MEMTEST "1"
|
||||
#define SPL_DEBUG_GPIO_SET "2"
|
||||
#define SPL_DEBUG_GPIO_CLEAR "3"
|
||||
|
||||
#define STAGE1_BASE 0x2000
|
||||
#define STAGE2_CODESIZE 0x400000
|
||||
#define SDRAM_BASE 0x80000000
|
||||
|
37
spl_cmdset.c
37
spl_cmdset.c
@ -19,16 +19,19 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "shell.h"
|
||||
#include "config.h"
|
||||
#include "ingenic.h"
|
||||
|
||||
static int spl_memtest(int argc, char *argv[]);
|
||||
static int spl_gpio(int argc, char *argv[]);
|
||||
static int spl_boot(int argc, char *argv[]);
|
||||
|
||||
const shell_command_t spl_cmdset[] = {
|
||||
{ "memtest", "[BASE <SIZE>] - SDRAM test", spl_memtest },
|
||||
{ "gpio", "<PIN> <STATE> - Set GPIO #PIN to STATE 0 or 1", spl_gpio },
|
||||
{ "boot", " - Load stage2 USB bootloader", spl_boot },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
@ -51,6 +54,40 @@ static int spl_memtest(int argc, char *argv[]) {
|
||||
return spl_load_stage1(); // TODO
|
||||
}
|
||||
|
||||
static int spl_gpio(int argc, char *argv[]) {
|
||||
if(argc != 3 || (strcmp(argv[2], "0") && strcmp(argv[2], "1"))) {
|
||||
printf("Usage: %s <PIN> <STATE>\n", argv[0]);
|
||||
printf(" STATE := 0 | 1\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *old_debugops = strdup(cfg_getenv("DEBUGOPS")),
|
||||
*old_pinnum = strdup(cfg_getenv("PINNUM"));
|
||||
|
||||
cfg_setenv("DEBUGOPS", (!strcmp(argv[2], "1")) ?
|
||||
SPL_DEBUG_GPIO_SET : SPL_DEBUG_GPIO_CLEAR);
|
||||
cfg_setenv("PINNUM", argv[1]);
|
||||
|
||||
int ret = 0;
|
||||
|
||||
ret = shell_execute("rebuildcfg");
|
||||
|
||||
if(ret == -1)
|
||||
goto finally;
|
||||
|
||||
ret = spl_load_stage1();
|
||||
|
||||
finally:
|
||||
cfg_setenv("DEBUGOPS", old_debugops);
|
||||
cfg_setenv("PINNUM", old_pinnum);
|
||||
|
||||
free(old_debugops);
|
||||
free(old_pinnum);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int spl_boot(int argc, char *argv[]) {
|
||||
if(argc != 1) {
|
||||
printf("Usage: %s\n", argv[0]);
|
||||
|
Loading…
Reference in New Issue
Block a user