Merge branch 'master' of https://github.com/gl-inet/mt798x
This commit is contained in:
@@ -21,6 +21,10 @@
|
||||
config {
|
||||
bootcmd = "mtkboardboot";
|
||||
|
||||
blink_led = "blue:run";
|
||||
system_led = "white:system";
|
||||
gpio_power_clr = <12>;
|
||||
|
||||
environment {
|
||||
lu = "mtkupgrade fip uboot-gl-mt2500.bin";
|
||||
lf = "mtkupgrade fw openwrt-gl-mt2500.bin";
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
config {
|
||||
bootcmd = "mtkboardboot";
|
||||
|
||||
blink_led = "blue:run";
|
||||
system_led = "white:system";
|
||||
gpio_power_clr = <12>;
|
||||
|
||||
environment {
|
||||
lu = "mtkupgrade fip uboot-gl-mt3000.bin";
|
||||
lf = "mtkupgrade fw openwrt-gl-mt3000.bin";
|
||||
|
||||
@@ -3,13 +3,47 @@
|
||||
#include <button.h>
|
||||
#include <linux/delay.h>
|
||||
#include <poller.h>
|
||||
#include <dm/ofnode.h>
|
||||
|
||||
static struct poller_async led_p;
|
||||
|
||||
void led_control(const char *cmd, const char *name, const char *arg)
|
||||
{
|
||||
const char *led = ofnode_conf_read_str(name);
|
||||
char buf[128];
|
||||
|
||||
if (!led)
|
||||
return;
|
||||
|
||||
sprintf(buf, "%s %s %s", cmd, led, arg);
|
||||
|
||||
run_command(buf, 0);
|
||||
}
|
||||
|
||||
static void gpio_power_clr(void)
|
||||
{
|
||||
ofnode node = ofnode_path("/config");
|
||||
char cmd[128];
|
||||
const u32 *val;
|
||||
int size, i;
|
||||
|
||||
if (!ofnode_valid(node))
|
||||
return;
|
||||
|
||||
val = ofnode_read_prop(node, "gpio_power_clr", &size);
|
||||
if (!val)
|
||||
return;
|
||||
|
||||
for (i = 0; i < size / 4; i++) {
|
||||
sprintf(cmd, "gpio clear %u", fdt32_to_cpu(val[i]));
|
||||
run_command(cmd, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void led_action_post(void *arg)
|
||||
{
|
||||
run_command("ledblink blue:run 0", 0);
|
||||
run_command("led blue:run on", 0);
|
||||
led_control("ledblink", "blink_led", "0");
|
||||
led_control("led", "blink_led", "on");
|
||||
}
|
||||
|
||||
static int do_glbtn(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||
@@ -19,8 +53,10 @@ static int do_glbtn(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[
|
||||
struct udevice *dev;
|
||||
ulong ts;
|
||||
|
||||
run_command("ledblink blue:run 250", 0);
|
||||
//run_command("gpio clear 12", 0);
|
||||
led_control("ledblink", "blink_led", "250");
|
||||
|
||||
gpio_power_clr();
|
||||
|
||||
ret = button_get_by_label(button_label, &dev);
|
||||
if (ret) {
|
||||
printf("Button '%s' not found (err=%d)\n", button_label, ret);
|
||||
@@ -33,7 +69,7 @@ static int do_glbtn(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[
|
||||
return CMD_RET_SUCCESS;
|
||||
}
|
||||
|
||||
run_command("ledblink blue:run 500", 0);
|
||||
led_control("ledblink", "blink_led", "500");
|
||||
|
||||
printf("RESET button is pressed for: %2d second(s)", counter++);
|
||||
|
||||
@@ -50,13 +86,13 @@ static int do_glbtn(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[
|
||||
|
||||
printf("\n");
|
||||
|
||||
run_command("ledblink blue:run 0", 0);
|
||||
led_control("ledblink", "blink_led", "0");
|
||||
|
||||
if (counter == 6) {
|
||||
run_command("led white:system on", 0);
|
||||
led_control("led", "system_led", "on");
|
||||
run_command("httpd", 0);
|
||||
} else {
|
||||
run_command("led blue:run on", 0);
|
||||
led_control("ledblink", "blink_led", "0");
|
||||
}
|
||||
|
||||
return CMD_RET_SUCCESS;
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "fs.h"
|
||||
|
||||
void led_control(const char *cmd, const char *name, const char *arg);
|
||||
|
||||
enum {
|
||||
FW_TYPE_GPT,
|
||||
FW_TYPE_BL2,
|
||||
@@ -70,7 +72,7 @@ static int write_firmware_failsafe(size_t data_addr, uint32_t data_size)
|
||||
{
|
||||
int r;
|
||||
|
||||
run_command("ledblink blue:run 100", 0);
|
||||
led_control("ledblink", "blink_led", "100");
|
||||
|
||||
switch (fw_type) {
|
||||
#ifdef CONFIG_MT7981_BOOTMENU_EMMC
|
||||
@@ -94,7 +96,7 @@ static int write_firmware_failsafe(size_t data_addr, uint32_t data_size)
|
||||
break;
|
||||
}
|
||||
|
||||
run_command("ledblink blue:run 0", 0);
|
||||
led_control("ledblink", "blink_led", "0");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -293,8 +295,8 @@ static void result_handler(enum httpd_uri_handler_status status,
|
||||
/* invalidate upload identifier */
|
||||
upload_data_id = rand();
|
||||
|
||||
run_command("led blue:run on", 0);
|
||||
run_command("led white:system off", 0);
|
||||
led_control("led", "blink_led", "on");
|
||||
led_control("led", "system_led", "off");
|
||||
|
||||
if (!st->ret)
|
||||
response->data = "success";
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <net/httpd.h>
|
||||
#include <command.h>
|
||||
|
||||
void led_control(const char *cmd, const char *name, const char *arg);
|
||||
|
||||
struct httpd_instance {
|
||||
struct list_head node;
|
||||
|
||||
@@ -641,7 +643,7 @@ static int httpd_handle_request(struct httpd_instance *inst,
|
||||
free(boundary);
|
||||
}
|
||||
|
||||
run_command("ledblink blue:run 0", 0);
|
||||
led_control("ledblink", "blink_led", "0");
|
||||
|
||||
/* call uri handler */
|
||||
assert((size_t) req->urih->cb > CONFIG_SYS_SDRAM_BASE);
|
||||
@@ -684,7 +686,7 @@ static void httpd_rx(struct httpd_instance *inst, struct tcb_cb_data *cbd)
|
||||
u8 sip[4];
|
||||
|
||||
if (pdata->status == HTTPD_S_NEW) {
|
||||
run_command("ledblink blue:run 100", 0);
|
||||
led_control("ledblink", "blink_led", "100");
|
||||
|
||||
memcpy(sip, &cbd->sip, 4);
|
||||
debug("New connection from %d.%d.%d.%d:%d\n",
|
||||
|
||||
Reference in New Issue
Block a user