diff options
-rw-r--r-- | configs/Barreleye.py | 36 | ||||
-rw-r--r-- | configs/Firestone.py | 46 | ||||
-rw-r--r-- | configs/Garrison.py | 46 | ||||
-rw-r--r-- | configs/Palmetto.py | 36 | ||||
-rw-r--r-- | configs/Romulus.py | 30 | ||||
-rw-r--r-- | configs/Witherspoon.py | 38 | ||||
-rw-r--r-- | configs/Zaius.py | 28 | ||||
-rw-r--r-- | libopenbmc_intf/power_gpio.c | 143 | ||||
-rw-r--r-- | libopenbmc_intf/power_gpio.h | 25 | ||||
-rw-r--r-- | op-hostctl/control_host_obj.c | 129 | ||||
-rw-r--r-- | op-pwrctl/power_control_obj.c | 64 | ||||
-rw-r--r-- | pysystemmgr/system_manager.py | 24 |
12 files changed, 407 insertions, 238 deletions
diff --git a/configs/Barreleye.py b/configs/Barreleye.py index e8e8d57..ac1902f 100644 --- a/configs/Barreleye.py +++ b/configs/Barreleye.py @@ -557,18 +557,30 @@ HWMON_CONFIG = { }, } -POWER_CONFIG = { - 'power_good_in': 'PGOOD', - 'power_up_outs': [ - ('POWER_PIN', False), - ], - 'reset_outs': [ - ('USB_RESET', False), - ], - 'pci_reset_outs': [ - # net name, polarity, reset hold - ('PCIE_RESET', False, False), - ], +GPIO_CONFIGS = { + 'power_config' : { + 'power_good_in' : 'PGOOD', + 'power_up_outs' : [ + ('POWER_PIN', False), + ], + 'reset_outs' : [ + ('USB_RESET', False), + ], + 'pci_reset_outs': [ + # net name, polarity, reset hold + ('PCIE_RESET', False, False), + ], + }, + 'hostctl_config' : { + 'fsi_data' : 'FSI_DATA', + 'fsi_clk' : 'FSI_CLK', + 'fsi_enable' : 'FSI_ENABLE', + 'cronus_sel' : 'CRONUS_SEL', + 'optionals' : [ + ('BMC_THROTTLE', True), + ('IDBTN', False), + ], + }, } # Miscellaneous non-poll sensor with system specific properties. diff --git a/configs/Firestone.py b/configs/Firestone.py index 285c397..6c7c908 100644 --- a/configs/Firestone.py +++ b/configs/Firestone.py @@ -451,23 +451,35 @@ HWMON_CONFIG = { } -POWER_CONFIG = { - 'power_good_in' : 'SYS_PWROK_BUFF', - 'power_up_outs' : [ - ('BMC_POWER_UP', True), - ], - 'reset_outs' : [ - ('CM1_OE_R_N', True), - ('BMC_CP0_RESET_N', False), - ('BMC_CFAM_RESET_N_R', False), - ], - 'pci_reset_outs' : [ - # net name, polarity, reset hold - # if 'reset hold' set to 'True', BMC will hold pci reset until host CPU ready to drive PCI - ('PEX8718_DEVICES_RESET_N', False, True), - ('CP0_DEVICES_RESET_N', False, True), - ('CP1_DEVICES_RESET_N', False, True), - ], +GPIO_CONFIGS = { + 'power_config' : { + 'power_good_in' : 'SYS_PWROK_BUFF', + 'power_up_outs' : [ + ('BMC_POWER_UP', True), + ], + 'reset_outs' : [ + ('CM1_OE_R_N', True), + ('BMC_CP0_RESET_N', False), + ('BMC_CFAM_RESET_N_R', False), + ], + 'pci_reset_outs': [ + # net name, polarity, reset hold + # if 'reset hold' set to 'True', BMC will hold pci reset until host CPU ready to drive PCI + ('PEX8718_DEVICES_RESET_N', False, True), + ('CP0_DEVICES_RESET_N', False, True), + ('CP1_DEVICES_RESET_N', False, True), + ], + }, + 'hostctl_config' : { + 'fsi_data' : 'FSI_DATA', + 'fsi_clk' : 'FSI_CLK', + 'fsi_enable' : 'FSI_ENABLE', + 'cronus_sel' : 'CRONUS_SEL', + 'optionals' : [ + ('BMC_THROTTLE', True), + ('IDBTN', False), + ], + }, } diff --git a/configs/Garrison.py b/configs/Garrison.py index aef0720..d108fc0 100644 --- a/configs/Garrison.py +++ b/configs/Garrison.py @@ -452,23 +452,35 @@ HWMON_CONFIG = { } -POWER_CONFIG = { - 'power_good_in' : 'SYS_PWROK_BUFF', - 'power_up_outs' : [ - ('BMC_POWER_UP', True), - ], - 'reset_outs' : [ - ('CM1_OE_R_N', True), - ('BMC_CP0_RESET_N', False), - ('BMC_CFAM_RESET_N_R', False), - ], - 'pci_reset_outs' : [ - # net name, polarity, reset hold - # if 'reset hold' set to 'True', BMC will hold pci reset until host CPU ready to drive PCI - ('PEX8718_DEVICES_RESET_N', False, True), - ('CP0_DEVICES_RESET_N', False, True), - ('CP1_DEVICES_RESET_N', False, True), - ], +GPIO_CONFIGS = { + 'power_config' : { + 'power_good_in' : 'SYS_PWROK_BUFF', + 'power_up_outs' : [ + ('BMC_POWER_UP', True), + ], + 'reset_outs' : [ + ('CM1_OE_R_N', True), + ('BMC_CP0_RESET_N', False), + ('BMC_CFAM_RESET_N_R', False), + ], + 'pci_reset_outs': [ + # net name, polarity, reset hold + # if 'reset hold' set to 'True', BMC will hold pci reset until host CPU ready to drive PCI + ('PEX8718_DEVICES_RESET_N', False, True), + ('CP0_DEVICES_RESET_N', False, True), + ('CP1_DEVICES_RESET_N', False, True), + ], + }, + 'hostctl_config' : { + 'fsi_data' : 'FSI_DATA', + 'fsi_clk' : 'FSI_CLK', + 'fsi_enable' : 'FSI_ENABLE', + 'cronus_sel' : 'CRONUS_SEL', + 'optionals' : [ + ('BMC_THROTTLE', True), + ('IDBTN', False), + ], + }, } diff --git a/configs/Palmetto.py b/configs/Palmetto.py index 7ed578c..5ce94ae 100644 --- a/configs/Palmetto.py +++ b/configs/Palmetto.py @@ -130,18 +130,30 @@ HWMON_CONFIG = { } } -POWER_CONFIG = { - 'power_good_in': 'PGOOD', - 'power_up_outs': [ - ('POWER_PIN', False), - ], - 'reset_outs': [ - ('USB_RESET', False), - ], - 'pci_reset_outs': [ - # net name, polarity, reset hold - ('PCIE_RESET', False, False), - ], +GPIO_CONFIGS = { + 'power_config' : { + 'power_good_in' : 'PGOOD', + 'power_up_outs' : [ + ('POWER_PIN', False), + ], + 'reset_outs' : [ + ('USB_RESET', False), + ], + 'pci_reset_outs': [ + # net name, polarity, reset hold + ('PCIE_RESET', False, False), + ], + }, + 'hostctl_config' : { + 'fsi_data' : 'FSI_DATA', + 'fsi_clk' : 'FSI_CLK', + 'fsi_enable' : 'FSI_ENABLE', + 'cronus_sel' : 'CRONUS_SEL', + 'optionals' : [ + ('BMC_THROTTLE', True), + ('IDBTN', False), + ], + }, } # Miscellaneous non-poll sensor with system specific properties. diff --git a/configs/Romulus.py b/configs/Romulus.py index c474647..178fb8e 100644 --- a/configs/Romulus.py +++ b/configs/Romulus.py @@ -321,16 +321,26 @@ HWMON_CONFIG = { }, } -POWER_CONFIG = { - 'power_good_in' : 'SYS_PWROK_BUFF', - 'power_up_outs' : [ - ('SOFTWARE_PGOOD', True), - ('BMC_POWER_UP', True), - ], - 'reset_outs' : [ - ('BMC_CP0_RESET_N', False), - ('BMC_CP0_PERST_ENABLE_R', False), - ], +GPIO_CONFIGS = { + 'power_config' : { + 'power_good_in' : 'SYS_PWROK_BUFF', + 'power_up_outs' : [ + ('SOFTWARE_PGOOD', True), + ('BMC_POWER_UP', True), + ], + 'reset_outs' : [ + ('BMC_CP0_RESET_N', False), + ('BMC_CP0_PERST_ENABLE_R', False), + ], + }, + 'hostctl_config' : { + 'fsi_data' : 'FSI_DATA', + 'fsi_clk' : 'FSI_CLK', + 'fsi_enable' : 'FSI_ENABLE', + 'cronus_sel' : 'CRONUS_SEL', + 'optionals' : [ + ], + }, } # Miscellaneous non-poll sensor with system specific properties. diff --git a/configs/Witherspoon.py b/configs/Witherspoon.py index 1fe77d0..1c12b2a 100644 --- a/configs/Witherspoon.py +++ b/configs/Witherspoon.py @@ -451,20 +451,30 @@ HWMON_CONFIG = { } -POWER_CONFIG = { - 'power_good_in': 'SYS_PWROK_BUFF', - 'power_up_outs': [ - ('SOFTWARE_PGOOD', True), - ('BMC_POWER_UP', True), - ], - 'reset_outs': [ - ('BMC_CP0_RESET_N', False), - ], - 'pci_reset_outs': [ - # net name, polarity, reset hold - ('BMC_VS1_PERST_N', False, False), - ('BMC_CP0_PERST_ENABLE_R', False, False), - ], +GPIO_CONFIGS = { + 'power_config' : { + 'power_good_in' : 'SYS_PWROK_BUFF', + 'power_up_outs' : [ + ('SOFTWARE_PGOOD', True), + ('BMC_POWER_UP', True), + ], + 'reset_outs' : [ + ('BMC_CP0_RESET_N', False), + ], + 'pci_reset_outs': [ + # net name, polarity, reset hold + ('BMC_VS1_PERST_N', False, False), + ('BMC_CP0_PERST_ENABLE_R', False, False), + ], + }, + 'hostctl_config' : { + 'fsi_data' : 'FSI_DATA', + 'fsi_clk' : 'FSI_CLK', + 'fsi_enable' : 'FSI_ENABLE', + 'cronus_sel' : 'CRONUS_SEL', + 'optionals' : [ + ], + }, } diff --git a/configs/Zaius.py b/configs/Zaius.py index 6b46f63..2ce380d 100644 --- a/configs/Zaius.py +++ b/configs/Zaius.py @@ -307,15 +307,25 @@ HWMON_CONFIG = { }, } -POWER_CONFIG = { - 'latch_out': 'BMC_UCD_LATCH_LE', - 'power_good_in': 'SYS_PWROK_BUFF', - 'power_up_outs': [ - ('SOFTWARE_PGOOD', True), - ('BMC_POWER_UP', True), - ], - 'reset_outs': [ - ], +GPIO_CONFIGS = { + 'power_config' : { + 'latch_out': 'BMC_UCD_LATCH_LE', + 'power_good_in' : 'SYS_PWROK_BUFF', + 'power_up_outs' : [ + ('SOFTWARE_PGOOD', True), + ('BMC_POWER_UP', True), + ], + 'reset_outs' : [ + ], + }, + 'hostctl_config' : { + 'fsi_data' : 'FSI_DATA', + 'fsi_clk' : 'FSI_CLK', + 'fsi_enable' : 'FSI_ENABLE', + 'cronus_sel' : 'CRONUS_SEL', + 'optionals' : [ + ], + }, } # Miscellaneous non-poll sensor with system specific properties. diff --git a/libopenbmc_intf/power_gpio.c b/libopenbmc_intf/power_gpio.c index 1e7d9cd..a3fcc36 100644 --- a/libopenbmc_intf/power_gpio.c +++ b/libopenbmc_intf/power_gpio.c @@ -22,13 +22,12 @@ #include <string.h> #include <glib.h> -gboolean read_power_gpio(GDBusConnection *connection, PowerGpio *power_gpio) +gboolean read_gpios(GDBusConnection *connection, GpioConfigs *gpios) { GDBusProxy *proxy; GError *error = NULL; GVariant *value; - gchar *power_good_in_name; - gchar *latch_out_name; + GVariantIter *power_up_outs_iter; GVariantIter *reset_outs_iter; GVariantIter *pci_reset_outs_iter; @@ -39,6 +38,10 @@ gboolean read_power_gpio(GDBusConnection *connection, PowerGpio *power_gpio) gboolean reset_out_polarity; gboolean pci_reset_out_polarity; gboolean pci_reset_out_hold; + + GVariantIter *optionals_iter; + gchar *optional_name; + gboolean optional_polarity; int i; proxy = g_dbus_proxy_new_sync(connection, @@ -56,66 +59,74 @@ gboolean read_power_gpio(GDBusConnection *connection, PowerGpio *power_gpio) } value = g_dbus_proxy_call_sync(proxy, - "getPowerConfiguration", + "getGpioConfiguration", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if(error != NULL) { - fprintf(stderr, "Power GPIO: call to getPowerConfiguration failed: %s\n", + fprintf(stderr, "Power GPIO: call to getGpioConfiguration failed: %s\n", error->message); g_error_free(error); return FALSE; } g_assert(value != NULL); - memset(power_gpio, 0, sizeof(*power_gpio)); - g_variant_get(value, "(&s&sa(sb)a(sb)a(sbb))", &power_good_in_name, &latch_out_name, - &power_up_outs_iter, &reset_outs_iter, &pci_reset_outs_iter); + memset(gpios, 0, sizeof(*gpios)); + g_variant_get( + value, "(&s&sa(sb)a(sb)a(sbb)&s&s&s&sa(sb))", + &gpios->power_gpio.power_good_in.name, &gpios->power_gpio.latch_out.name, + &power_up_outs_iter, &reset_outs_iter, &pci_reset_outs_iter, + &gpios->hostctl_gpio.fsi_data.name, &gpios->hostctl_gpio.fsi_clk.name, + &gpios->hostctl_gpio.fsi_enable.name, &gpios->hostctl_gpio.cronus_sel.name, + &optionals_iter); - g_print("Power GPIO latch output %s\n", latch_out_name); - if(*latch_out_name != '\0') { /* latch is optional */ - power_gpio->latch_out.name = strdup(latch_out_name); + g_print("Power GPIO latch output: %s\n", gpios->power_gpio.latch_out.name); + if(*gpios->power_gpio.latch_out.name != '\0') { /* latch is optional */ + gpios->power_gpio.latch_out.name = strdup(gpios->power_gpio.latch_out.name); + } + else { + gpios->power_gpio.latch_out.name = NULL; } - g_print("Power GPIO power good input %s\n", power_good_in_name); - power_gpio->power_good_in.name = g_strdup(power_good_in_name); - power_gpio->num_power_up_outs = g_variant_iter_n_children( + g_print("Power GPIO power good input: %s\n", gpios->power_gpio.power_good_in.name); + gpios->power_gpio.power_good_in.name = g_strdup(gpios->power_gpio.power_good_in.name); + gpios->power_gpio.num_power_up_outs = g_variant_iter_n_children( power_up_outs_iter); - g_print("Power GPIO %d power_up outputs\n", - power_gpio->num_power_up_outs); - power_gpio->power_up_outs = g_malloc0_n(power_gpio->num_power_up_outs, + g_print("Power GPIO %zu power_up outputs\n", + gpios->power_gpio.num_power_up_outs); + gpios->power_gpio.power_up_outs = g_malloc0_n(gpios->power_gpio.num_power_up_outs, sizeof(GPIO)); - power_gpio->power_up_pols = g_malloc0_n(power_gpio->num_power_up_outs, + gpios->power_gpio.power_up_pols = g_malloc0_n(gpios->power_gpio.num_power_up_outs, sizeof(gboolean)); for(i = 0; g_variant_iter_next(power_up_outs_iter, "(&sb)", &power_up_out_name, &power_up_polarity); i++) { g_print("Power GPIO power_up[%d] = %s active %s\n", i, power_up_out_name, power_up_polarity ? "HIGH" : "LOW"); - power_gpio->power_up_outs[i].name = g_strdup(power_up_out_name); - power_gpio->power_up_pols[i] = power_up_polarity; + gpios->power_gpio.power_up_outs[i].name = g_strdup(power_up_out_name); + gpios->power_gpio.power_up_pols[i] = power_up_polarity; } - power_gpio->num_reset_outs = g_variant_iter_n_children(reset_outs_iter); - g_print("Power GPIO %d reset outputs\n", power_gpio->num_reset_outs); - power_gpio->reset_outs = g_malloc0_n(power_gpio->num_reset_outs, sizeof(GPIO)); - power_gpio->reset_pols = g_malloc0_n(power_gpio->num_reset_outs, + gpios->power_gpio.num_reset_outs = g_variant_iter_n_children(reset_outs_iter); + g_print("Power GPIO %zu reset outputs\n", gpios->power_gpio.num_reset_outs); + gpios->power_gpio.reset_outs = g_malloc0_n(gpios->power_gpio.num_reset_outs, sizeof(GPIO)); + gpios->power_gpio.reset_pols = g_malloc0_n(gpios->power_gpio.num_reset_outs, sizeof(gboolean)); for(i = 0; g_variant_iter_next(reset_outs_iter, "(&sb)", &reset_out_name, &reset_out_polarity); i++) { g_print("Power GPIO reset[%d] = %s active %s\n", i, reset_out_name, reset_out_polarity ? "HIGH" : "LOW"); - power_gpio->reset_outs[i].name = g_strdup(reset_out_name); - power_gpio->reset_pols[i] = reset_out_polarity; + gpios->power_gpio.reset_outs[i].name = g_strdup(reset_out_name); + gpios->power_gpio.reset_pols[i] = reset_out_polarity; } - power_gpio->num_pci_reset_outs = g_variant_iter_n_children(pci_reset_outs_iter); - g_print("Power GPIO %d pci reset outputs\n", power_gpio->num_pci_reset_outs); - power_gpio->pci_reset_outs = g_malloc0_n(power_gpio->num_pci_reset_outs, + gpios->power_gpio.num_pci_reset_outs = g_variant_iter_n_children(pci_reset_outs_iter); + g_print("Power GPIO %d pci reset outputs\n", gpios->power_gpio.num_pci_reset_outs); + gpios->power_gpio.pci_reset_outs = g_malloc0_n(gpios->power_gpio.num_pci_reset_outs, sizeof(GPIO)); - power_gpio->pci_reset_pols = g_malloc0_n(power_gpio->num_pci_reset_outs, + gpios->power_gpio.pci_reset_pols = g_malloc0_n(gpios->power_gpio.num_pci_reset_outs, sizeof(gboolean)); - power_gpio->pci_reset_holds = g_malloc0_n(power_gpio->num_pci_reset_outs, + gpios->power_gpio.pci_reset_holds = g_malloc0_n(gpios->power_gpio.num_pci_reset_outs, sizeof(gboolean)); for(i = 0; g_variant_iter_next(pci_reset_outs_iter, "(&sbb)", &pci_reset_out_name, &pci_reset_out_polarity, &pci_reset_out_hold); i++) { @@ -123,37 +134,69 @@ gboolean read_power_gpio(GDBusConnection *connection, PowerGpio *power_gpio) pci_reset_out_name, pci_reset_out_polarity ? "HIGH" : "LOW", pci_reset_out_hold ? "Yes" : "No"); - power_gpio->pci_reset_outs[i].name = g_strdup(pci_reset_out_name); - power_gpio->pci_reset_pols[i] = pci_reset_out_polarity; - power_gpio->pci_reset_holds[i] = pci_reset_out_hold; + gpios->power_gpio.pci_reset_outs[i].name = g_strdup(pci_reset_out_name); + gpios->power_gpio.pci_reset_pols[i] = pci_reset_out_polarity; + gpios->power_gpio.pci_reset_holds[i] = pci_reset_out_hold; + } + + + g_print("FSI DATA GPIO: %s\n", gpios->hostctl_gpio.fsi_data.name); + gpios->hostctl_gpio.fsi_data.name = strdup(gpios->hostctl_gpio.fsi_data.name); + + g_print("FSI CLK GPIO: %s\n", gpios->hostctl_gpio.fsi_clk.name); + gpios->hostctl_gpio.fsi_clk.name = strdup(gpios->hostctl_gpio.fsi_clk.name); + + g_print("FSI ENABLE GPIO: %s\n", gpios->hostctl_gpio.fsi_enable.name); + gpios->hostctl_gpio.fsi_enable.name = strdup(gpios->hostctl_gpio.fsi_enable.name); + + g_print("CRONUS SEL GPIO: %s\n", gpios->hostctl_gpio.cronus_sel.name); + gpios->hostctl_gpio.cronus_sel.name = strdup(gpios->hostctl_gpio.cronus_sel.name); + + gpios->hostctl_gpio.num_optionals = g_variant_iter_n_children(optionals_iter); + g_print("Hostctl GPIO optionals: %zu\n", gpios->hostctl_gpio.num_optionals); + gpios->hostctl_gpio.optionals = g_malloc0_n(gpios->hostctl_gpio.num_optionals, sizeof(GPIO)); + gpios->hostctl_gpio.optional_pols = g_malloc0_n(gpios->hostctl_gpio.num_optionals, sizeof(gboolean)); + for (i = 0; g_variant_iter_next(optionals_iter, "(&sb)", &optional_name, &optional_polarity); ++i) { + g_print("Hostctl optional GPIO[%d] = %s active %s\n", i, optional_name, optional_polarity ? "HIGH" : "LOW"); + gpios->hostctl_gpio.optionals[i].name = g_strdup(optional_name); + gpios->hostctl_gpio.optional_pols[i] = optional_polarity; } g_variant_iter_free(power_up_outs_iter); g_variant_iter_free(reset_outs_iter); g_variant_iter_free(pci_reset_outs_iter); + g_variant_iter_free(optionals_iter); g_variant_unref(value); return TRUE; } -void free_power_gpio(PowerGpio *power_gpio) { +void free_gpios(GpioConfigs *gpios) { int i; - g_free(power_gpio->latch_out.name); - g_free(power_gpio->power_good_in.name); - for(i = 0; i < power_gpio->num_power_up_outs; i++) { - g_free(power_gpio->power_up_outs[i].name); + g_free(gpios->power_gpio.latch_out.name); + g_free(gpios->power_gpio.power_good_in.name); + for(i = 0; i < gpios->power_gpio.num_power_up_outs; i++) { + g_free(gpios->power_gpio.power_up_outs[i].name); + } + g_free(gpios->power_gpio.power_up_outs); + g_free(gpios->power_gpio.power_up_pols); + for(i = 0; i < gpios->power_gpio.num_reset_outs; i++) { + g_free(gpios->power_gpio.reset_outs[i].name); } - g_free(power_gpio->power_up_outs); - g_free(power_gpio->power_up_pols); - for(i = 0; i < power_gpio->num_reset_outs; i++) { - g_free(power_gpio->reset_outs[i].name); + g_free(gpios->power_gpio.reset_outs); + g_free(gpios->power_gpio.reset_pols); + for(i = 0; i < gpios->power_gpio.num_pci_reset_outs; i++) { + g_free(gpios->power_gpio.pci_reset_outs[i].name); } - g_free(power_gpio->reset_outs); - g_free(power_gpio->reset_pols); - for(i = 0; i < power_gpio->num_pci_reset_outs; i++) { - g_free(power_gpio->pci_reset_outs[i].name); + g_free(gpios->power_gpio.pci_reset_outs); + g_free(gpios->power_gpio.pci_reset_pols); + g_free(gpios->power_gpio.pci_reset_holds); + + g_free(gpios->hostctl_gpio.fsi_data.name); + g_free(gpios->hostctl_gpio.fsi_clk.name); + g_free(gpios->hostctl_gpio.fsi_enable.name); + g_free(gpios->hostctl_gpio.cronus_sel.name); + for (i = 0; i < gpios->hostctl_gpio.num_optionals; ++i) { + g_free(gpios->hostctl_gpio.optionals[i].name); } - g_free(power_gpio->pci_reset_outs); - g_free(power_gpio->pci_reset_pols); - g_free(power_gpio->pci_reset_holds); } diff --git a/libopenbmc_intf/power_gpio.h b/libopenbmc_intf/power_gpio.h index e3714d0..ab01fe5 100644 --- a/libopenbmc_intf/power_gpio.h +++ b/libopenbmc_intf/power_gpio.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef __POWER_GPIO_H__ -#define __POWER_GPIO_H__ +#ifndef __GPIO_CONFIGS_H__ +#define __GPIO_CONFIGS_H__ #include <stddef.h> #include <glib.h> @@ -44,9 +44,24 @@ typedef struct PowerGpio { gboolean *pci_reset_holds; } PowerGpio; -/* Read system configuration for power GPIOs. */ -gboolean read_power_gpio(GDBusConnection *connection, PowerGpio *power_gpio); +typedef struct HostctlGpio { + GPIO fsi_data; + GPIO fsi_clk; + GPIO fsi_enable; + GPIO cronus_sel; + size_t num_optionals; + GPIO* optionals; + gboolean* optional_pols; +} HostctlGpio; + +typedef struct GpioConfigs { + PowerGpio power_gpio; + HostctlGpio hostctl_gpio; +} GpioConfigs; + +/* Read system configuration for GPIOs. */ +gboolean read_gpios(GDBusConnection *connection, GpioConfigs *gpios); /* Frees internal buffers. Does not free parameter. Does not close GPIOs. */ -void free_power_gpio(PowerGpio *power_gpio); +void free_gpios(GpioConfigs *gpios); #endif diff --git a/op-hostctl/control_host_obj.c b/op-hostctl/control_host_obj.c index 6202044..c0b4e12 100644 --- a/op-hostctl/control_host_obj.c +++ b/op-hostctl/control_host_obj.c @@ -8,20 +8,24 @@ #include <openbmc_intf.h> #include <openbmc.h> #include <gpio.h> +#include <power_gpio.h> /* ------------------------------------------------------------------------- */ static const gchar* dbus_object_path = "/org/openbmc/control"; static const gchar* instance_name = "host0"; static const gchar* dbus_name = "org.openbmc.control.Host"; +static GpioConfigs g_gpio_configs; + static GDBusObjectManagerServer *manager = NULL; -GPIO fsi_data = (GPIO){ "FSI_DATA" }; -GPIO fsi_clk = (GPIO){ "FSI_CLK" }; -GPIO fsi_enable = (GPIO){ "FSI_ENABLE" }; -GPIO cronus_sel = (GPIO){ "CRONUS_SEL" }; -GPIO Throttle = (GPIO){ "BMC_THROTTLE" }; -GPIO idbtn = (GPIO){ "IDBTN" }; +static GPIO* fsi_data; +static GPIO* fsi_clk; +static GPIO* fsi_enable; +static GPIO* cronus_sel; +static size_t num_optionals; +static GPIO* optionals; +static gboolean* optional_pols; /* Bit bang patterns */ @@ -37,7 +41,7 @@ static const char* golden = "000011111111110101111000111001100111101101111111111 static const char* attnA = "000011111111111101111110001001101111111111111111111111111111110001111111"; //putcfam pu 0x100D 40000000 static const char* attnB = "000011111111111011111100101001011111111111111111111111111111110001111111"; -//putcfam pu 0x100B FFFFFFFF +//putcfam pu 0x100B FFFFFFFF static const char* attnC = "000011111111111011111101001000000000000000000000000000000000001011111111"; @@ -57,9 +61,9 @@ fsi_bitbang(const char* pattern) int rc=GPIO_OK; int i; for(i=0;i<strlen(pattern);i++) { - rc = gpio_writec(&fsi_data,pattern[i]); + rc = gpio_writec(fsi_data,pattern[i]); if(rc!=GPIO_OK) { break; } - rc = gpio_clock_cycle(&fsi_clk,1); + rc = gpio_clock_cycle(fsi_clk,1); if(rc!=GPIO_OK) { break; } } return rc; @@ -69,9 +73,9 @@ int fsi_standby() { int rc=GPIO_OK; - rc = gpio_write(&fsi_data,1); + rc = gpio_write(fsi_data,1); if(rc!=GPIO_OK) { return rc; } - rc = gpio_clock_cycle(&fsi_clk,5000); + rc = gpio_clock_cycle(fsi_clk,5000); if(rc!=GPIO_OK) { return rc; } return rc; } @@ -89,13 +93,16 @@ on_boot(ControlHost *host, GDBusConnection *connection = g_dbus_object_manager_server_get_connection(manager); - if(control_host_get_debug_mode(host)==1) - { + if (!(fsi_data && fsi_clk && fsi_enable && cronus_sel)) { + g_print("ERROR invalid GPIO configuration, will not boot\n"); + return FALSE; + } + if(control_host_get_debug_mode(host)==1) { g_print("Enabling debug mode; not booting host\n"); - rc |= gpio_open(&fsi_enable); - rc |= gpio_open(&cronus_sel); - rc |= gpio_write(&fsi_enable,1); - rc |= gpio_write(&cronus_sel,0); + rc |= gpio_open(fsi_enable); + rc |= gpio_open(cronus_sel); + rc |= gpio_write(fsi_enable,1); + rc |= gpio_write(cronus_sel,0); if(rc!=GPIO_OK) { g_print("ERROR enabling debug mode: %d\n",rc); } @@ -105,30 +112,32 @@ on_boot(ControlHost *host, Control* control = object_get_control((Object*)user_data); control_host_complete_boot(host,invocation); do { - rc = gpio_open(&fsi_clk); - rc |= gpio_open(&fsi_data); - rc |= gpio_open(&fsi_enable); - rc |= gpio_open(&cronus_sel); - rc |= gpio_open(&Throttle); - rc |= gpio_open(&idbtn); + rc = gpio_open(fsi_clk); + rc |= gpio_open(fsi_data); + rc |= gpio_open(fsi_enable); + rc |= gpio_open(cronus_sel); + for (size_t i = 0; i < num_optionals; ++i) { + rc |= gpio_open(&optionals[i]); + } if(rc!=GPIO_OK) { break; } //setup dc pins - rc = gpio_write(&cronus_sel,1); - rc |= gpio_write(&fsi_enable,1); - rc |= gpio_write(&fsi_clk,1); - rc |= gpio_write(&Throttle,1); - rc |= gpio_write(&idbtn,0); + rc = gpio_write(cronus_sel,1); + rc |= gpio_write(fsi_enable,1); + rc |= gpio_write(fsi_clk,1); + for (size_t i = 0; i < num_optionals; ++i) { + rc |= gpio_write(&optionals[i], optional_pols[i]); + } if(rc!=GPIO_OK) { break; } //data standy state rc = fsi_standby(); //clear out pipes - rc |= gpio_write(&fsi_data,0); - rc |= gpio_clock_cycle(&fsi_clk,256); - rc |= gpio_write(&fsi_data,1); - rc |= gpio_clock_cycle(&fsi_clk,50); + rc |= gpio_write(fsi_data,0); + rc |= gpio_clock_cycle(fsi_clk,256); + rc |= gpio_write(fsi_data,1); + rc |= gpio_clock_cycle(fsi_clk,50); if(rc!=GPIO_OK) { break; } rc = fsi_bitbang(attnA); @@ -157,13 +166,13 @@ on_boot(ControlHost *host, rc = fsi_bitbang(go); - rc |= gpio_write(&fsi_data,1); /* Data standby state */ - rc |= gpio_clock_cycle(&fsi_clk,2); + rc |= gpio_write(fsi_data,1); /* Data standby state */ + rc |= gpio_clock_cycle(fsi_clk,2); - rc |= gpio_write(&fsi_clk,0); /* hold clk low for clock mux */ - rc |= gpio_write(&fsi_enable,0); - rc |= gpio_clock_cycle(&fsi_clk,16); - rc |= gpio_write(&fsi_clk,0); /* Data standby state */ + rc |= gpio_write(fsi_clk,0); /* hold clk low for clock mux */ + rc |= gpio_write(fsi_enable,0); + rc |= gpio_clock_cycle(fsi_clk,16); + rc |= gpio_write(fsi_clk,0); /* Data standby state */ } while(0); if(rc != GPIO_OK) @@ -172,12 +181,13 @@ on_boot(ControlHost *host, } else { control_emit_goto_system_state(control,"HOST_BOOTING"); } - gpio_close(&fsi_clk); - gpio_close(&fsi_data); - gpio_close(&fsi_enable); - gpio_close(&cronus_sel); - gpio_close(&Throttle); - gpio_close(&idbtn); + gpio_close(fsi_clk); + gpio_close(fsi_data); + gpio_close(fsi_enable); + gpio_close(cronus_sel); + for (size_t i = 0; i < num_optionals; ++i) { + gpio_close(&optionals[i]); + } // Start watchdog with 30s timeout per the OpenPower Host IPMI Spec. // Once the host starts booting, it'll reset and refresh the timer. @@ -273,12 +283,26 @@ on_bus_acquired(GDBusConnection *connection, g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object)); g_object_unref(object); - gpio_init(connection,&fsi_data); - gpio_init(connection,&fsi_clk); - gpio_init(connection,&fsi_enable); - gpio_init(connection,&cronus_sel); - gpio_init(connection,&Throttle); - gpio_init(connection,&idbtn); + if(read_gpios(connection, &g_gpio_configs) != TRUE) { + g_print("ERROR Hostctl: could not read GPIO configuration\n"); + return; + } + + fsi_data = &g_gpio_configs.hostctl_gpio.fsi_data; + fsi_clk = &g_gpio_configs.hostctl_gpio.fsi_clk; + fsi_enable = &g_gpio_configs.hostctl_gpio.fsi_enable; + cronus_sel = &g_gpio_configs.hostctl_gpio.cronus_sel; + num_optionals = g_gpio_configs.hostctl_gpio.num_optionals; + optionals = g_gpio_configs.hostctl_gpio.optionals; + optional_pols = g_gpio_configs.hostctl_gpio.optional_pols; + + gpio_init(connection, fsi_data); + gpio_init(connection, fsi_clk); + gpio_init(connection, fsi_enable); + gpio_init(connection, cronus_sel); + for (int i = 0; i < num_optionals; ++i) { + gpio_init(connection, &optionals[i]); + } } static void @@ -286,7 +310,7 @@ on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { - // g_print ("Acquired the name %s\n", name); + // g_print ("Acquired the name %s\n", name); } static void @@ -294,7 +318,8 @@ on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) { - // g_print ("Lost the name %s\n", name); + // g_print ("Lost the name %s\n", name); + free_gpios(&g_gpio_configs); } gint diff --git a/op-pwrctl/power_control_obj.c b/op-pwrctl/power_control_obj.c index 9cf8ce4..493b588 100644 --- a/op-pwrctl/power_control_obj.c +++ b/op-pwrctl/power_control_obj.c @@ -19,7 +19,7 @@ static const gchar* dbus_name = "org.openbmc.control.Power"; static int g_pci_reset_held = 1; -static PowerGpio g_power_gpio; +static GpioConfigs g_gpio_configs; static GDBusObjectManagerServer *manager = NULL; @@ -52,14 +52,14 @@ poll_pgood(gpointer user_data) } uint8_t pgood_state; - int rc = gpio_open(&g_power_gpio.power_good_in); + int rc = gpio_open(&g_gpio_configs.power_gpio.power_good_in); if(rc != GPIO_OK) { g_print("ERROR PowerControl: GPIO open error (gpio=%s,rc=%d)\n", - g_power_gpio.power_good_in.name, rc); + g_gpio_configs.power_gpio.power_good_in.name, rc); return FALSE; } - rc = gpio_read(&g_power_gpio.power_good_in, &pgood_state); - gpio_close(&g_power_gpio.power_good_in); + rc = gpio_read(&g_gpio_configs.power_gpio.power_good_in, &pgood_state); + gpio_close(&g_gpio_configs.power_gpio.power_good_in); if(rc == GPIO_OK) { //if changed, set property and emit signal @@ -80,9 +80,9 @@ poll_pgood(gpointer user_data) control_emit_goto_system_state(control,"HOST_POWERED_ON"); } - for(i = 0; i < g_power_gpio.num_reset_outs; i++) + for(i = 0; i < g_gpio_configs.power_gpio.num_reset_outs; i++) { - GPIO *reset_out = &g_power_gpio.reset_outs[i]; + GPIO *reset_out = &g_gpio_configs.power_gpio.reset_outs[i]; rc = gpio_open(reset_out); if(rc != GPIO_OK) { @@ -91,23 +91,23 @@ poll_pgood(gpointer user_data) continue; } - reset_state = pgood_state ^ g_power_gpio.reset_pols[i]; + reset_state = pgood_state ^ g_gpio_configs.power_gpio.reset_pols[i]; g_print("PowerControl: pgood: %d, setting reset %s to %d\n", - (int)pgood_state, reset_out->name, (int)reset_state); + (int)pgood_state, reset_out->name, (int)reset_state); gpio_write(reset_out, reset_state); gpio_close(reset_out); } - for(i = 0; i < g_power_gpio.num_pci_reset_outs; i++) + for(i = 0; i < g_gpio_configs.power_gpio.num_pci_reset_outs; i++) { - GPIO *pci_reset_out = &g_power_gpio.pci_reset_outs[i]; + GPIO *pci_reset_out = &g_gpio_configs.power_gpio.pci_reset_outs[i]; if(pgood_state == 1) { /* * When powering on, hold PCI reset until * the processor can forward clocks and control reset. */ - if(g_power_gpio.pci_reset_holds[i]) + if(g_gpio_configs.power_gpio.pci_reset_holds[i]) { g_print("Holding pci reset: %s\n", pci_reset_out->name); continue; @@ -121,16 +121,16 @@ poll_pgood(gpointer user_data) continue; } - reset_state = pgood_state ^ g_power_gpio.pci_reset_pols[i]; + reset_state = pgood_state ^ g_gpio_configs.power_gpio.pci_reset_pols[i]; g_print("PowerControl: pgood: %d, setting pci reset %s to %d\n", - (int)pgood_state, pci_reset_out->name, (int)reset_state); + (int)pgood_state, pci_reset_out->name, (int)reset_state); gpio_write(pci_reset_out, reset_state); gpio_close(pci_reset_out); } } } else { g_print("ERROR PowerControl: GPIO read error (gpio=%s,rc=%d)\n", - g_power_gpio.power_good_in.name, rc); + g_gpio_configs.power_gpio.power_good_in.name, rc); //return false so poll won't get called anymore return FALSE; } @@ -177,23 +177,23 @@ on_boot_progress(GDBusConnection *connection, if(strcmp(boot_progress, "FW Progress, Baseboard Init") == 0) return; - rc = gpio_open(&g_power_gpio.power_good_in); + rc = gpio_open(&g_gpio_configs.power_gpio.power_good_in); if(rc != GPIO_OK) { g_print("ERROR PowerControl: on_boot_progress(): GPIO open error (gpio=%s,rc=%d)\n", - g_power_gpio.power_good_in.name, rc); + g_gpio_configs.power_gpio.power_good_in.name, rc); return; } - rc = gpio_read(&g_power_gpio.power_good_in, &pgood_state); - gpio_close(&g_power_gpio.power_good_in); + rc = gpio_read(&g_gpio_configs.power_gpio.power_good_in, &pgood_state); + gpio_close(&g_gpio_configs.power_gpio.power_good_in); if(rc != GPIO_OK || pgood_state != 1) return; - for(i = 0; i < g_power_gpio.num_pci_reset_outs; i++) + for(i = 0; i < g_gpio_configs.power_gpio.num_pci_reset_outs; i++) { - GPIO *pci_reset_out = &g_power_gpio.pci_reset_outs[i]; + GPIO *pci_reset_out = &g_gpio_configs.power_gpio.pci_reset_outs[i]; - if(!g_power_gpio.pci_reset_holds[i]) + if(!g_gpio_configs.power_gpio.pci_reset_holds[i]) continue; rc = gpio_open(pci_reset_out); if(rc != GPIO_OK) @@ -203,9 +203,9 @@ on_boot_progress(GDBusConnection *connection, continue; } - reset_state = pgood_state ^ g_power_gpio.pci_reset_pols[i]; + reset_state = pgood_state ^ g_gpio_configs.power_gpio.pci_reset_pols[i]; g_print("PowerControl: pgood: %d, setting pci reset %s to %d\n", - (int)pgood_state, pci_reset_out->name, (int)reset_state); + (int)pgood_state, pci_reset_out->name, (int)reset_state); gpio_write(pci_reset_out, reset_state); gpio_close(pci_reset_out); g_print("Released pci reset: %s - %s\n", pci_reset_out->name, boot_progress); @@ -244,17 +244,17 @@ on_set_power_state(ControlPower *pwr, } else { control_emit_goto_system_state(control,"HOST_POWERING_OFF"); } - for (i = 0; i < g_power_gpio.num_power_up_outs; i++) { - GPIO *power_pin = &g_power_gpio.power_up_outs[i]; + for (i = 0; i < g_gpio_configs.power_gpio.num_power_up_outs; i++) { + GPIO *power_pin = &g_gpio_configs.power_gpio.power_up_outs[i]; error = gpio_open(power_pin); if(error != GPIO_OK) { g_print("ERROR PowerControl: GPIO open error (gpio=%s,rc=%d)\n", - g_power_gpio.power_up_outs[i].name, error); + g_gpio_configs.power_gpio.power_up_outs[i].name, error); continue; } - power_up_out = state ^ !g_power_gpio.power_up_pols[i]; + power_up_out = state ^ !g_gpio_configs.power_gpio.power_up_pols[i]; g_print("PowerControl: setting power up %s to %d\n", - g_power_gpio.power_up_outs[i].name, (int)power_up_out); + g_gpio_configs.power_gpio.power_up_outs[i].name, (int)power_up_out); error = gpio_write(power_pin, power_up_out); if(error != GPIO_OK) { continue; @@ -429,11 +429,11 @@ on_bus_acquired(GDBusConnection *connection, g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object)); g_object_unref(object); - if(read_power_gpio(connection, &g_power_gpio) != TRUE) { + if(read_gpios(connection, &g_gpio_configs) != TRUE) { g_print("ERROR PowerControl: could not read power GPIO configuration\n"); } - int rc = set_up_gpio(connection, &g_power_gpio, control_power); + int rc = set_up_gpio(connection, &g_gpio_configs.power_gpio, control_power); if(rc != GPIO_OK) { g_print("ERROR PowerControl: GPIO setup (rc=%d)\n",rc); } @@ -462,7 +462,7 @@ on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) { - free_power_gpio(&g_power_gpio); + free_gpios(&g_gpio_configs); } /*----------------------------------------------------------------*/ diff --git a/pysystemmgr/system_manager.py b/pysystemmgr/system_manager.py index 5152ff2..d145e74 100644 --- a/pysystemmgr/system_manager.py +++ b/pysystemmgr/system_manager.py @@ -184,14 +184,22 @@ class SystemManager(DbusProperties, DbusObjectManager): return r @dbus.service.method(DBUS_NAME, in_signature='', - out_signature='ssa(sb)a(sb)a(sbb)') - def getPowerConfiguration(self): - power_good_in = System.POWER_CONFIG.get('power_good_in', '') - latch_out = System.POWER_CONFIG.get('latch_out', '') - power_up_outs = System.POWER_CONFIG.get('power_up_outs', []) - reset_outs = System.POWER_CONFIG.get('reset_outs', []) - pci_reset_outs = System.POWER_CONFIG.get('pci_reset_outs', []) - r = [power_good_in, latch_out, power_up_outs, reset_outs, pci_reset_outs] + out_signature='ssa(sb)a(sb)a(sbb)ssssa(sb)') + def getGpioConfiguration(self): + power_config = System.GPIO_CONFIGS.get('power_config', {}) + power_good_in = power_config.get('power_good_in', '') + latch_out = power_config.get('latch_out', '') + power_up_outs = power_config.get('power_up_outs', []) + reset_outs = power_config.get('reset_outs', []) + pci_reset_outs = System.GPIO_CONFIGS.get('pci_reset_outs', []) + hostctl_config = System.GPIO_CONFIGS.get('hostctl_config', {}) + fsi_data = hostctl_config.get('fsi_data', '') + fsi_clk = hostctl_config.get('fsi_clk', '') + fsi_enable = hostctl_config.get('fsi_enable', '') + cronus_sel = hostctl_config.get('cronus_sel', '') + optionals = hostctl_config.get('optionals', []) + r = [power_good_in, latch_out, power_up_outs, reset_outs, pci_reset_outs,\ + fsi_data, fsi_clk, fsi_enable, cronus_sel, optionals] print "Power GPIO config: " + str(r) return r |