Commit c15c7481 authored by Adam Wujek's avatar Adam Wujek

sw/petalinux/diot-util: Add support of hard reset of fantray

Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parent b9ee9bd8
Pipeline #3879 passed with stage
in 41 minutes and 22 seconds
......@@ -24,12 +24,14 @@
#include "diot_util_i2c.h"
#include "diot_util_error.h"
#include "diot_util_fantray.h"
#include "diot_util_gpio.h"
#include "util.h"
#define FANTRAY_FW_MAX_SIZE 0x3E000
static int cmd_fantray_status(char *params);
static int cmd_fantray_reset(char *params);
static int cmd_fantray_reset_hard(char *params);
static int cmd_fantray_set_fan(char *params);
static int cmd_fantray_load_fw(char *params);
......@@ -37,6 +39,7 @@ static int cmd_fantray_load_fw(char *params);
struct command_entry commands_list_fantray[] = {
{ .cmd_name = "status", .cmd_func = cmd_fantray_status, .cmd_help_string = "Get the status of the Fantray module\n", .cmd_params = NULL},
{ .cmd_name = "reset", .cmd_func = cmd_fantray_reset, .cmd_help_string = "Reset Fantray module\n", .cmd_params = NULL},
{ .cmd_name = "reset_hard", .cmd_func = cmd_fantray_reset_hard, .cmd_help_string = "Hard Reset Fantray module (using GPIO)\n", .cmd_params = NULL},
{ .cmd_name = "fan", .cmd_func = cmd_fantray_set_fan, .cmd_help_string = "Set fan(s) speed for Fantray module\n", .cmd_params = "<1|2|3|all>"},
{ .cmd_name = "load_fw", .cmd_func = cmd_fantray_load_fw, .cmd_help_string = "Update Fantray's firmware\n", .cmd_params = "<filename>"},
{ .cmd_name = NULL }
......@@ -155,6 +158,42 @@ static int cmd_fantray_reset(char *params)
return rc;
}
static int cmd_fantray_reset_hard(char *params)
{
int rc;
int ret;
diot_error_clear();
/* Unbind the Fantray from the monimod driver */
/* Ignore errors of unbind */
fantray_bind_driver(FANTRAY_DRIVER_PATH "/unbind");
/* Reset Fantray */
ret = gpio_fantray_reset(0);
if (ret < 0)
printf("Unable to reset Fantray (ret = %d)\n", ret);
sleep(1);
ret = gpio_fantray_reset(1);
if (ret < 0)
printf("Unable to reset Fantray (ret = %d)\n", ret);
/* Give the Fantray some time to start */
sleep(2);
/* Bind the Fantray to the monimod driver */
rc = fantray_bind_driver(FANTRAY_DRIVER_PATH "/bind");
diot_error_print();
if (ret) {
return -1;
}
return rc;
}
static int fantray_status(void)
{
char buff_hwmon[20];
......
......@@ -86,6 +86,7 @@ enum diot_gpio{
#endif
RST_N,
PSU_ALERT,
F_RST,
MAX_GPIO,
};
......@@ -132,6 +133,7 @@ struct gpio_entry gpio_entries[MAX_GPIO] = {
#endif
DECLARE_GPIO_OUT(RST_N, 1),
DECLARE_GPIO_IN(PSU_ALERT),
DECLARE_GPIO_OUT(F_RST, 1),
};
/* commands */
......@@ -646,3 +648,8 @@ int restore_i2c(void)
return 1;
}
int gpio_fantray_reset(int val)
{
return gpiod_line_set_value(gpio_entries[F_RST].gpio_line, val);
}
......@@ -27,6 +27,7 @@ int read_pb_eeprom(uint8_t *eeprom_buff, size_t eeprom_size, int slot);
int read_fmc_eeprom(uint8_t *eeprom_buff, size_t eeprom_size);
int psu_added_or_removed(int psu);
int restore_i2c(void);
int gpio_fantray_reset(int val);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment