diff --git a/firmware/ec/Makefile b/firmware/ec/Makefile index 6eb67a43fd..c69836af70 100644 --- a/firmware/ec/Makefile +++ b/firmware/ec/Makefile @@ -94,7 +94,10 @@ get_cfg: hash: cd ../utilities/checksums; ./hashes.sh $(shell pwd)/$(OUT) -ec -oc_connect1: $(OUT)/OpenCellular.bin +gen_schema: + cd ../utilities/schema; ./mk_schema.sh + +oc_connect1: gen_schema $(OUT)/OpenCellular.bin $(OUT)/%/compiler.opt $(OUT)/%/linker.cmd : %.cfg $(CONFIGURO) -c $(TOOLCHAIN) -t $(TARGET) -p $(PLATFORM) -r release $< diff --git a/firmware/ec/platform/oc-sdr/schema/auto_schema.c b/firmware/ec/platform/oc-sdr/schema/auto_schema.c new file mode 100644 index 0000000000..ad752bdc2e --- /dev/null +++ b/firmware/ec/platform/oc-sdr/schema/auto_schema.c @@ -0,0 +1,1105 @@ +/** +* Copyright (c) 2018-present, Facebook, Inc. +* All rights reserved. +* +* This source code is licensed under the BSD-style license +* found in the LICENSE file in the root directory of this +* source tree. An additional grant of patent rights can be +* found in the PATENTS file in the same directory. +* +* WARNING: Do not modify this file by hand. It is auto +* generated from the json schema definition. +* Refer to sdtester.py +*/ + +#include "auto_schema.h" + +SCHEMA_IMPORT DriverStruct debug_I2C0; +SCHEMA_IMPORT DriverStruct debug_I2C1; +SCHEMA_IMPORT DriverStruct debug_I2C2; +SCHEMA_IMPORT DriverStruct debug_I2C3; +SCHEMA_IMPORT DriverStruct debug_I2C4; +SCHEMA_IMPORT DriverStruct debug_I2C6; +SCHEMA_IMPORT DriverStruct debug_I2C7; +SCHEMA_IMPORT DriverStruct debug_I2C8; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pa; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pb; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pc; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pd; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pe; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pf; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pg; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_ph; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pj; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pk; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pl; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pm; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pn; +SCHEMA_IMPORT DriverStruct debug_ec_gpio_pq; +SCHEMA_IMPORT DriverStruct debug_fe_ioexpanderx1A; +SCHEMA_IMPORT DriverStruct debug_fe_ioexpanderx1B; +SCHEMA_IMPORT DriverStruct debug_fe_ioexpanderx1C; +SCHEMA_IMPORT DriverStruct debug_fe_ioexpanderx1D; +SCHEMA_IMPORT DriverStruct debug_gbc_ioexpanderx70; +SCHEMA_IMPORT DriverStruct debug_gbc_ioexpanderx71; +SCHEMA_IMPORT DriverStruct debug_mdio_global1; +SCHEMA_IMPORT DriverStruct debug_mdio_global2; +SCHEMA_IMPORT DriverStruct debug_mdio_phyport0; +SCHEMA_IMPORT DriverStruct debug_mdio_phyport1; +SCHEMA_IMPORT DriverStruct debug_mdio_phyport2; +SCHEMA_IMPORT DriverStruct debug_mdio_phyport3; +SCHEMA_IMPORT DriverStruct debug_mdio_phyport4; +SCHEMA_IMPORT DriverStruct debug_mdio_swport0; +SCHEMA_IMPORT DriverStruct debug_mdio_swport1; +SCHEMA_IMPORT DriverStruct debug_mdio_swport2; +SCHEMA_IMPORT DriverStruct debug_mdio_swport3; +SCHEMA_IMPORT DriverStruct debug_mdio_swport4; +SCHEMA_IMPORT DriverStruct debug_mdio_swport5; +SCHEMA_IMPORT DriverStruct debug_mdio_swport6; +SCHEMA_IMPORT DriverStruct debug_sdr_ioexpanderx1E; +SCHEMA_IMPORT DriverStruct debug_sync_ioexpanderx71; +SCHEMA_IMPORT DriverStruct eeprom_fe_inv; +SCHEMA_IMPORT DriverStruct eeprom_gbc_inv; +SCHEMA_IMPORT DriverStruct eeprom_gbc_sid; +SCHEMA_IMPORT DriverStruct eeprom_sdr_inv; +SCHEMA_IMPORT DriverStruct fe_ch1_ads7830; +SCHEMA_IMPORT DriverStruct fe_ch1_bandcfg; +SCHEMA_IMPORT DriverStruct fe_ch1_gain; +SCHEMA_IMPORT DriverStruct fe_ch1_lna; +SCHEMA_IMPORT DriverStruct fe_ch1_ps_5_7v; +SCHEMA_IMPORT DriverStruct fe_ch1_pwrcfg; +SCHEMA_IMPORT DriverStruct fe_ch1_ts; +SCHEMA_IMPORT DriverStruct fe_ch1_watchdog; +SCHEMA_IMPORT DriverStruct fe_ch2_ads7830; +SCHEMA_IMPORT DriverStruct fe_ch2_bandcfg; +SCHEMA_IMPORT DriverStruct fe_ch2_gain; +SCHEMA_IMPORT DriverStruct fe_ch2_lna; +SCHEMA_IMPORT DriverStruct fe_ch2_ps_5_7v; +SCHEMA_IMPORT DriverStruct fe_ch2_pwrcfg; +SCHEMA_IMPORT DriverStruct fe_ch2_ts; +SCHEMA_IMPORT DriverStruct fe_ch2_watchdog; +SCHEMA_IMPORT DriverStruct fe_rffecfg; +SCHEMA_IMPORT DriverStruct gbc_bms_ec_ps_12v; +SCHEMA_IMPORT DriverStruct gbc_bms_ec_ps_3p3v; +SCHEMA_IMPORT DriverStruct gbc_bms_ec_ts; +SCHEMA_IMPORT DriverStruct gbc_eth_port0; +SCHEMA_IMPORT DriverStruct gbc_eth_port1; +SCHEMA_IMPORT DriverStruct gbc_eth_port2; +SCHEMA_IMPORT DriverStruct gbc_eth_port3; +SCHEMA_IMPORT DriverStruct gbc_eth_port4; +SCHEMA_IMPORT DriverStruct gbc_gpp_ap_ps; +SCHEMA_IMPORT DriverStruct gbc_gpp_ap_ts1; +SCHEMA_IMPORT DriverStruct gbc_gpp_ap_ts2; +SCHEMA_IMPORT DriverStruct gbc_gpp_ap_ts3; +SCHEMA_IMPORT DriverStruct gbc_gpp_gpioCfg; +SCHEMA_IMPORT DriverStruct gbc_gpp_msata_ps; +SCHEMA_IMPORT DriverStruct gbc_hci_buzzer; +SCHEMA_IMPORT DriverStruct gbc_pwr_ext_bat_charger; +SCHEMA_IMPORT DriverStruct gbc_pwr_int_bat_charger; +SCHEMA_IMPORT DriverStruct gbc_pwr_lead_acid_ts; +SCHEMA_IMPORT DriverStruct gbc_pwr_pd; +SCHEMA_IMPORT DriverStruct gbc_pwr_powerSource; +SCHEMA_IMPORT DriverStruct gbc_pwr_pse; +SCHEMA_IMPORT DriverStruct gbc_spi_flash_memory; +SCHEMA_IMPORT DriverStruct led_hci_ioexp; +SCHEMA_IMPORT DriverStruct led_hci_ts; +SCHEMA_IMPORT DriverStruct obc_irridium; +SCHEMA_IMPORT DriverStruct sdr_fpga_ps; +SCHEMA_IMPORT DriverStruct sdr_fpga_ts; +SCHEMA_IMPORT DriverStruct sdr_gpioCfg; +SCHEMA_IMPORT DriverStruct sdr_ps; +SCHEMA_IMPORT DriverStruct sync_gpiocfg; +SCHEMA_IMPORT DriverStruct sync_gps_ts; +SCHEMA_IMPORT DriverStruct sync_obc_gpiocfg; +SCHEMA_IMPORT DriverStruct testModuleCfg; + +SCHEMA_IMPORT const DriverStruct fact_ap_3v_ps_cfg; +SCHEMA_IMPORT const DriverStruct fact_ap_se98a_ts1_cfg; +SCHEMA_IMPORT const DriverStruct fact_ap_se98a_ts2_cfg; +SCHEMA_IMPORT const DriverStruct fact_ap_se98a_ts3_cfg; +SCHEMA_IMPORT const DriverStruct fact_bc_se98a; +SCHEMA_IMPORT const DriverStruct fact_ch1_band_cfg; +SCHEMA_IMPORT const DriverStruct fact_ch1_rx_gain_cfg; +SCHEMA_IMPORT const DriverStruct fact_ch1_tx_gain_cfg; +SCHEMA_IMPORT const DriverStruct fact_ch2_band_cfg; +SCHEMA_IMPORT const DriverStruct fact_ch2_rx_gain_cfg; +SCHEMA_IMPORT const DriverStruct fact_ch2_tx_gain_cfg; +SCHEMA_IMPORT const DriverStruct fact_ec_12v_ps_cfg; +SCHEMA_IMPORT const DriverStruct fact_ec_3v_ps_cfg; +SCHEMA_IMPORT const DriverStruct fact_ec_se98a_cfg; +SCHEMA_IMPORT const DriverStruct fact_fe_ch1_adt7481_cfg; +SCHEMA_IMPORT const DriverStruct fact_fe_ch1_ps_cfg; +SCHEMA_IMPORT const DriverStruct fact_fe_ch2_adt7481_cfg; +SCHEMA_IMPORT const DriverStruct fact_fe_ch2_ps_cfg; +SCHEMA_IMPORT const DriverStruct fact_leadAcid_cfg; +SCHEMA_IMPORT const DriverStruct fact_led_se98a_cfg; +SCHEMA_IMPORT const DriverStruct fact_lithiumIon_cfg; +SCHEMA_IMPORT const DriverStruct fact_ltc4274_cfg; +SCHEMA_IMPORT const DriverStruct fact_msata_3v_ps_cfg; +SCHEMA_IMPORT const DriverStruct fact_sdr_3v_ps_cfg; +SCHEMA_IMPORT const DriverStruct fact_sdr_fpga_adt7481_cfg; +SCHEMA_IMPORT const DriverStruct fact_sdr_fpga_ps_cfg; +SCHEMA_IMPORT const DriverStruct fact_sync_ts_cfg; + +SCHEMA_IMPORT bool GPP_ap_Reset(void *, void *); +SCHEMA_IMPORT bool gpp_post_init(void *, void *); +SCHEMA_IMPORT bool gpp_pre_init(void *, void *); +SCHEMA_IMPORT bool HCI_Init(void *, void *); +SCHEMA_IMPORT bool obc_pre_init(void *, void *); +SCHEMA_IMPORT bool RFFE_disablePA(void *, void *); +SCHEMA_IMPORT bool RFFE_enablePA(void *, void *); +SCHEMA_IMPORT bool rffe_post_init(void *, void *); +SCHEMA_IMPORT bool rffe_pre_init(void *, void *); +SCHEMA_IMPORT bool RFFE_reset(void *, void *); +SCHEMA_IMPORT bool SDR_fx3Reset(void *, void *); +SCHEMA_IMPORT bool SDR_Init(void *, void *); +SCHEMA_IMPORT bool SDR_reset(void *, void *); +SCHEMA_IMPORT bool SYNC_Init(void *, void *); +SCHEMA_IMPORT bool SYNC_reset(void *, void *); +SCHEMA_IMPORT bool SYS_cmdEcho(void *, void *); +SCHEMA_IMPORT bool SYS_cmdReset(void *, void *); +SCHEMA_IMPORT bool sys_post_init(void *, void *); +SCHEMA_IMPORT bool TestMod_cmdReset(void *, void *); + + +const Component sys_schema[] = { + { + .name = "system", + .driver_cfg = &gbc_spi_flash_memory, + .ssHookSet = &(SSHookSet) { + .preInitFxn = NULL, + .postInitFxn = (ssHook_Cb)sys_post_init, + }, + .components = (Component[]) { + { + .name = "comp_all", + .driver = &SYSTEMDRV, + .driver_cfg = &gbc_gpp_gpioCfg, + .components = (Component[]) { + { + .name = "eeprom_sid", + .driver = &CAT24C04_gbc_sid, + .driver_cfg = &eeprom_gbc_sid, + }, + { + .name = "eeprom_inv", + .driver = &CAT24C04_gbc_inv, + .driver_cfg = &eeprom_gbc_inv, + }, + { + .name = "eeprom_mac", + .driver = &Driver_MAC, + }, + { + .name = "SPI_flash", + .driver = &FLASHDRV, + .driver_cfg = &gbc_spi_flash_memory, + }, + {} + }, + .commands = (Command[]) { + { + .name = "reset", + .cb_cmd = SYS_cmdReset, + }, + { + .name = "echo", + .cb_cmd = SYS_cmdEcho, + }, + {} + }, + }, + {} + }, + }, + { + .name = "power", + .components = (Component[]) { + { + .name = "comp_all", + .components = (Component[]) { + { + .name = "powerSource", + .driver = &PWRSRC, + .driver_cfg = &gbc_pwr_powerSource, + .postDisabled = POST_DISABLED, + }, + {} + }, + }, + { + .name = "leadacid_sensor", + .components = (Component[]) { + { + .name = "temp_sensor1", + .driver = &SE98A, + .driver_cfg = &gbc_pwr_lead_acid_ts, + .factory_config = &fact_bc_se98a, + }, + {} + }, + }, + { + .name = "leadacid", + .components = (Component[]) { + { + .name = "battery", + .driver = <C4015, + .driver_cfg = &gbc_pwr_ext_bat_charger, + .factory_config = &fact_leadAcid_cfg, + }, + {} + }, + }, + { + .name = "lion", + .components = (Component[]) { + { + .name = "battery", + .driver = <C4015, + .driver_cfg = &gbc_pwr_int_bat_charger, + .factory_config = &fact_lithiumIon_cfg, + }, + {} + }, + }, + { + .name = "pse", + .driver = <C4274, + .driver_cfg = &gbc_pwr_pse, + .factory_config = &fact_ltc4274_cfg, + }, + { + .name = "pd", + .driver = <C4275, + .driver_cfg = &gbc_pwr_pd, + }, + {} + }, + }, + { + .name = "bms", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "ec", + .components = (Component[]) { + { + .name = "temp_sensor1", + .driver = &SE98A, + .driver_cfg = &gbc_bms_ec_ts, + .factory_config = &fact_ec_se98a_cfg, + }, + { + .name = "current_sensor1", + .driver = &INA226, + .driver_cfg = &gbc_bms_ec_ps_12v, + .factory_config = &fact_ec_12v_ps_cfg, + }, + { + .name = "current_sensor2", + .driver = &INA226, + .driver_cfg = &gbc_bms_ec_ps_3p3v, + .factory_config = &fact_ec_3v_ps_cfg, + }, + {} + }, + }, + {} + }, + }, + { + .name = "hci", + .ssHookSet = &(SSHookSet) { + .preInitFxn = (ssHook_Cb)HCI_Init, + .postInitFxn = NULL, + }, + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "led", + .components = (Component[]) { + { + .name = "temp_sensor1", + .driver = &SE98A, + .driver_cfg = &led_hci_ts, + .factory_config = &fact_led_se98a_cfg, + .postDisabled = POST_DISABLED, + }, + { + .name = "fw", + .driver = &HCI_LED, + .driver_cfg = &led_hci_ioexp, + }, + {} + }, + }, + { + .name = "buzzer", + .driver_cfg = &gbc_hci_buzzer, + .postDisabled = POST_DISABLED, + }, + {} + }, + }, + { + .name = "ethernet", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "port0", + .driver = Ð_SW, + .driver_cfg = &gbc_eth_port0, + }, + { + .name = "port1", + .driver = Ð_SW, + .driver_cfg = &gbc_eth_port1, + }, + { + .name = "port2", + .driver = Ð_SW, + .driver_cfg = &gbc_eth_port2, + }, + { + .name = "port3", + .driver = Ð_SW, + .driver_cfg = &gbc_eth_port3, + }, + { + .name = "port4", + .driver = Ð_SW, + .driver_cfg = &gbc_eth_port4, + }, + {} + }, + }, + { + .name = "obc", + .ssHookSet = &(SSHookSet) { + .preInitFxn = (ssHook_Cb)obc_pre_init, + .postInitFxn = NULL, + }, + .driver_cfg = &sync_obc_gpiocfg, + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "iridium", + .driver = &OBC_Iridium, + .driver_cfg = &obc_irridium, + }, + {} + }, + }, + { + .name = "gpp", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "ap", + .components = (Component[]) { + { + .name = "temp_sensor1", + .driver = &SE98A, + .driver_cfg = &gbc_gpp_ap_ts1, + .factory_config = &fact_ap_se98a_ts1_cfg, + }, + { + .name = "temp_sensor2", + .driver = &SE98A, + .driver_cfg = &gbc_gpp_ap_ts2, + .factory_config = &fact_ap_se98a_ts2_cfg, + }, + { + .name = "temp_sensor3", + .driver = &SE98A, + .driver_cfg = &gbc_gpp_ap_ts3, + .factory_config = &fact_ap_se98a_ts3_cfg, + }, + { + .name = "current_sensor1", + .driver = &INA226, + .driver_cfg = &gbc_gpp_ap_ps, + .factory_config = &fact_ap_3v_ps_cfg, + }, + {} + }, + .driver_cfg = &gbc_gpp_gpioCfg, + .commands = (Command[]) { + { + .name = "reset", + .cb_cmd = GPP_ap_Reset, + }, + {} + }, + }, + { + .name = "msata", + .components = (Component[]) { + { + .name = "current_sensor1", + .driver = &INA226, + .driver_cfg = &gbc_gpp_msata_ps, + .factory_config = &fact_msata_3v_ps_cfg, + }, + {} + }, + }, + {} + }, + .driver_cfg = &gbc_gpp_gpioCfg, + .ssHookSet = &(SSHookSet) { + .preInitFxn = (ssHook_Cb)gpp_pre_init, + .postInitFxn = (ssHook_Cb)gpp_post_init, + }, + }, + { + .name = "sdr", + .components = (Component[]) { + { + .name = "comp_all", + .components = (Component[]) { + { + .name = "current_sensor1", + .driver = &INA226, + .driver_cfg = &sdr_ps, + .factory_config = &fact_sdr_3v_ps_cfg, + }, + { + .name = "eeprom", + .driver_cfg = &eeprom_sdr_inv, + .driver = &CAT24C04_sdr_inv, + }, + {} + }, + .driver_cfg = &sdr_gpioCfg, + .commands = (Command[]) { + { + .name = "reset", + .cb_cmd = SDR_reset, + }, + {} + }, + }, + { + .name = "fpga", + .components = (Component[]) { + { + .name = "temp_sensor1", + .driver = &ADT7481, + .driver_cfg = &sdr_fpga_ts, + .factory_config = &fact_sdr_fpga_adt7481_cfg, + }, + { + .name = "current_sensor1", + .driver = &INA226, + .driver_cfg = &sdr_fpga_ps, + .factory_config = &fact_sdr_fpga_ps_cfg, + }, + {} + }, + }, + { + .name = "fx3", + .driver_cfg = &sdr_gpioCfg, + .commands = (Command[]) { + { + .name = "reset", + .cb_cmd = SDR_fx3Reset, + }, + {} + }, + .postDisabled = POST_DISABLED, + }, + {} + }, + .driver_cfg = &sdr_gpioCfg, + .ssHookSet = &(SSHookSet) { + .preInitFxn = (ssHook_Cb)SDR_Init, + .postInitFxn = NULL, + }, + }, + { + .name = "rffe", + .driver_cfg = &fe_rffecfg, + .components = (Component[]) { + { + .name = "comp_all", + .components = (Component[]) { + { + .name = "eeprom", + .driver = &CAT24C04_fe_inv, + .driver_cfg = &eeprom_fe_inv, + }, + {} + }, + .driver_cfg = &sdr_gpioCfg, + .commands = (Command[]) { + { + .name = "reset", + .cb_cmd = RFFE_reset, + }, + {} + }, + }, + { + .name = "ch1_sensor", + .components = (Component[]) { + { + .name = "temp_sensor1", + .driver = &ADT7481, + .driver_cfg = &fe_ch1_ts, + .factory_config = &fact_fe_ch1_adt7481_cfg, + }, + { + .name = "current_sensor1", + .driver = &INA226, + .driver_cfg = &fe_ch1_ps_5_7v, + .factory_config = &fact_fe_ch1_ps_cfg, + }, + {} + }, + }, + { + .name = "ch2_sensor", + .components = (Component[]) { + { + .name = "temp_sensor1", + .driver = &ADT7481, + .driver_cfg = &fe_ch2_ts, + .factory_config = &fact_fe_ch2_adt7481_cfg, + }, + { + .name = "current_sensor1", + .driver = &INA226, + .driver_cfg = &fe_ch2_ps_5_7v, + .factory_config = &fact_fe_ch2_ps_cfg, + }, + {} + }, + }, + { + .name = "ch1_fe", + .driver_cfg = &fe_ch1_pwrcfg, + .components = (Component[]) { + { + .name = "ch1_band", + .driver = &FE_Param, + .driver_cfg = &fe_ch1_bandcfg, + .factory_config = &fact_ch1_band_cfg, + }, + { + .name = "watchdog", + .driver = &RFFEWatchdog, + .driver_cfg = &fe_ch1_watchdog, + }, + { + .name = "power", + .driver = &RFPowerMonitor, + .driver_cfg = &fe_ch1_ads7830, + }, + { + .name = "tx", + .driver = &DATXXR5APP, + .driver_cfg = &fe_ch1_gain, + .factory_config = &fact_ch1_tx_gain_cfg, + }, + { + .name = "rx", + .driver = &DATXXR5APP, + .driver_cfg = &fe_ch1_lna, + .factory_config = &fact_ch1_rx_gain_cfg, + }, + {} + }, + .commands = (Command[]) { + { + .name = "enable", + .cb_cmd = RFFE_enablePA, + }, + { + .name = "disable", + .cb_cmd = RFFE_disablePA, + }, + {} + }, + }, + { + .name = "ch2_fe", + .driver_cfg = &fe_ch2_pwrcfg, + .components = (Component[]) { + { + .name = "ch2_band", + .driver = &FE_Param, + .driver_cfg = &fe_ch2_bandcfg, + .factory_config = &fact_ch2_band_cfg, + }, + { + .name = "watchdog", + .driver = &RFFEWatchdog, + .driver_cfg = &fe_ch2_watchdog, + }, + { + .name = "power", + .driver = &RFPowerMonitor, + .driver_cfg = &fe_ch2_ads7830, + }, + { + .name = "tx", + .driver = &DATXXR5APP, + .driver_cfg = &fe_ch2_gain, + .factory_config = &fact_ch2_tx_gain_cfg, + }, + { + .name = "rx", + .driver = &DATXXR5APP, + .driver_cfg = &fe_ch2_lna, + .factory_config = &fact_ch2_rx_gain_cfg, + }, + {} + }, + .commands = (Command[]) { + { + .name = "enable", + .cb_cmd = RFFE_enablePA, + }, + { + .name = "disable", + .cb_cmd = RFFE_disablePA, + }, + {} + }, + }, + {} + }, + .ssHookSet = &(SSHookSet) { + .preInitFxn = (ssHook_Cb)rffe_pre_init, + .postInitFxn = (ssHook_Cb)rffe_post_init, + }, + }, + { + .name = "sync", + .driver_cfg = &sync_gpiocfg, + .ssHookSet = &(SSHookSet) { + .preInitFxn = (ssHook_Cb)SYNC_Init, + .postInitFxn = NULL, + }, + .components = (Component[]) { + { + .name = "comp_all", + .driver_cfg = &sync_gpiocfg, + .commands = (Command[]) { + { + .name = "reset", + .cb_cmd = SYNC_reset, + }, + {} + }, + .postDisabled = POST_DISABLED, + }, + { + .name = "gps", + .driver_cfg = &sync_gpiocfg, + .driver = &Sync_IO, + }, + { + .name = "sensor", + .components = (Component[]) { + { + .name = "temp_sensor1", + .driver = &ADT7481, + .driver_cfg = &sync_gps_ts, + .factory_config = &fact_sync_ts_cfg, + }, + {} + }, + }, + {} + }, + }, + { + .name = "testmodule", + .components = (Component[]) { + { + .name = "comp_all", + .commands = (Command[]) { + { + .name = "reset", + .cb_cmd = TestMod_cmdReset, + }, + {} + }, + .postDisabled = POST_DISABLED, + }, + { + .name = "2gsim", + .driver = &Testmod_G510, + .driver_cfg = &testModuleCfg, + }, + {} + }, + }, + { + .name = "debug", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "I2C", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "bus0", + .driver = &OC_I2C, + .driver_cfg = &debug_I2C0, + .postDisabled = POST_DISABLED, + }, + { + .name = "bus1", + .driver = &OC_I2C, + .driver_cfg = &debug_I2C1, + .postDisabled = POST_DISABLED, + }, + { + .name = "bus2", + .driver = &OC_I2C, + .driver_cfg = &debug_I2C2, + .postDisabled = POST_DISABLED, + }, + { + .name = "bus3", + .driver = &OC_I2C, + .driver_cfg = &debug_I2C3, + .postDisabled = POST_DISABLED, + }, + { + .name = "bus4", + .driver = &OC_I2C, + .driver_cfg = &debug_I2C4, + .postDisabled = POST_DISABLED, + }, + { + .name = "bus6", + .driver = &OC_I2C, + .driver_cfg = &debug_I2C6, + .postDisabled = POST_DISABLED, + }, + { + .name = "bus7", + .driver = &OC_I2C, + .driver_cfg = &debug_I2C7, + .postDisabled = POST_DISABLED, + }, + { + .name = "bus8", + .driver = &OC_I2C, + .driver_cfg = &debug_I2C8, + .postDisabled = POST_DISABLED, + }, + {} + }, + }, + { + .name = "ec", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "PA", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pa, + .postDisabled = POST_DISABLED, + }, + { + .name = "PB", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pb, + .postDisabled = POST_DISABLED, + }, + { + .name = "PC", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pc, + .postDisabled = POST_DISABLED, + }, + { + .name = "PD", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pd, + .postDisabled = POST_DISABLED, + }, + { + .name = "PE", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pe, + .postDisabled = POST_DISABLED, + }, + { + .name = "PF", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pf, + .postDisabled = POST_DISABLED, + }, + { + .name = "PG", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pg, + .postDisabled = POST_DISABLED, + }, + { + .name = "PH", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_ph, + .postDisabled = POST_DISABLED, + }, + { + .name = "PJ", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pj, + .postDisabled = POST_DISABLED, + }, + { + .name = "PK", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pk, + .postDisabled = POST_DISABLED, + }, + { + .name = "PL", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pl, + .postDisabled = POST_DISABLED, + }, + { + .name = "PM", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pm, + .postDisabled = POST_DISABLED, + }, + { + .name = "PN", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pn, + .postDisabled = POST_DISABLED, + }, + { + .name = "PP", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pn, + .postDisabled = POST_DISABLED, + }, + { + .name = "PQ", + .driver = &OC_GPIO, + .driver_cfg = &debug_ec_gpio_pq, + .postDisabled = POST_DISABLED, + }, + {} + }, + }, + { + .name = "gbc", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "ioexpanderx70", + .driver = &OC_GPIO, + .driver_cfg = &debug_gbc_ioexpanderx70, + }, + { + .name = "ioexpanderx71", + .driver = &OC_GPIO, + .driver_cfg = &debug_gbc_ioexpanderx71, + }, + {} + }, + }, + { + .name = "sdr", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "ioexpanderx1E", + .driver = &OC_GPIO, + .driver_cfg = &debug_sdr_ioexpanderx1E, + }, + {} + }, + }, + { + .name = "fe", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "ioexpanderx18", + .driver = &OC_GPIO, + .driver_cfg = &debug_sdr_ioexpanderx1E, + }, + { + .name = "ioexpanderx1C", + .driver = &OC_GPIO, + .driver_cfg = &debug_fe_ioexpanderx1C, + }, + { + .name = "ioexpanderx1B", + .driver = &OC_GPIO, + .driver_cfg = &debug_fe_ioexpanderx1B, + }, + { + .name = "ioexpanderx1A", + .driver = &OC_GPIO, + .driver_cfg = &debug_fe_ioexpanderx1A, + }, + { + .name = "ioexpanderx1D", + .driver = &OC_GPIO, + .driver_cfg = &debug_fe_ioexpanderx1D, + }, + {} + }, + }, + { + .name = "sync", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "ioexpanderx71", + .driver = &OC_GPIO, + .driver_cfg = &debug_sync_ioexpanderx71, + }, + {} + }, + }, + { + .name = "ethernet", + .components = (Component[]) { + { + .name = "comp_all", + .postDisabled = POST_DISABLED, + }, + { + .name = "port0", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_phyport0, + .postDisabled = POST_DISABLED, + }, + { + .name = "port1", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_phyport1, + .postDisabled = POST_DISABLED, + }, + { + .name = "port2", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_phyport2, + .postDisabled = POST_DISABLED, + }, + { + .name = "port3", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_phyport3, + .postDisabled = POST_DISABLED, + }, + { + .name = "port4", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_phyport4, + .postDisabled = POST_DISABLED, + }, + { + .name = "global1", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_global1, + .postDisabled = POST_DISABLED, + }, + { + .name = "global2", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_global2, + .postDisabled = POST_DISABLED, + }, + { + .name = "swport0", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_swport0, + .postDisabled = POST_DISABLED, + }, + { + .name = "swport1", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_swport1, + .postDisabled = POST_DISABLED, + }, + { + .name = "swport2", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_swport2, + .postDisabled = POST_DISABLED, + }, + { + .name = "swport3", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_swport3, + .postDisabled = POST_DISABLED, + }, + { + .name = "swport4", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_swport4, + .postDisabled = POST_DISABLED, + }, + { + .name = "swport5", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_swport5, + .postDisabled = POST_DISABLED, + }, + { + .name = "swport6", + .driver = &OC_MDIO, + .driver_cfg = &debug_mdio_swport6, + .postDisabled = POST_DISABLED, + }, + {} + }, + }, + {} + }, + }, + {} +}; diff --git a/firmware/ec/platform/oc-sdr/schema/auto_schema.h b/firmware/ec/platform/oc-sdr/schema/auto_schema.h new file mode 100644 index 0000000000..46d9982aab --- /dev/null +++ b/firmware/ec/platform/oc-sdr/schema/auto_schema.h @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2018-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +#ifndef _AUTO_SCHEMA_H +#define _AUTO_SCHEMA_H + +#include "common/inc/global/Framework.h" +#include "common/inc/global/OC_CONNECT1.h" +#include "common/inc/ocmp_wrappers/ocmp_adt7481.h" +#include "common/inc/ocmp_wrappers/ocmp_dat-xxr5a-pp.h" +#include "common/inc/ocmp_wrappers/ocmp_debugi2c.h" +#include "common/inc/ocmp_wrappers/ocmp_debugmdio.h" +#include "common/inc/ocmp_wrappers/ocmp_debugmdio.h" +#include "common/inc/ocmp_wrappers/ocmp_debugocgpio.h" +#include "common/inc/ocmp_wrappers/ocmp_eeprom_cat24c04.h" +#include "common/inc/ocmp_wrappers/ocmp_eth_sw.h" +#include "common/inc/ocmp_wrappers/ocmp_fe-param.h" +#include "common/inc/ocmp_wrappers/ocmp_ina226.h" +#include "common/inc/ocmp_wrappers/ocmp_iridium.h" +#include "common/inc/ocmp_wrappers/ocmp_led.h" +#include "common/inc/ocmp_wrappers/ocmp_ltc4015.h" +#include "common/inc/ocmp_wrappers/ocmp_ltc4274.h" +#include "common/inc/ocmp_wrappers/ocmp_ltc4275.h" +#include "common/inc/ocmp_wrappers/ocmp_mac.h" +#include "common/inc/ocmp_wrappers/ocmp_powersource.h" +#include "common/inc/ocmp_wrappers/ocmp_rfpowermonitor.h" +#include "common/inc/ocmp_wrappers/ocmp_rfwatchdog.h" +#include "common/inc/ocmp_wrappers/ocmp_se98a.h" +#include "common/inc/ocmp_wrappers/ocmp_syncio.h" +#include "common/inc/ocmp_wrappers/ocmp_testmodule.h" +#include "schema.h" + +#endif /* _AUTO_SCHEMA_H */ diff --git a/firmware/ec/platform/oc-sdr/schema/schema.c b/firmware/ec/platform/oc-sdr/schema/schema.c deleted file mode 100644 index 568e8eb6c6..0000000000 --- a/firmware/ec/platform/oc-sdr/schema/schema.c +++ /dev/null @@ -1,1131 +0,0 @@ -/** - * Copyright (c) 2017-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#include "common/inc/global/Framework.h" -#include "common/inc/ocmp_wrappers/ocmp_adt7481.h" -#include "common/inc/ocmp_wrappers/ocmp_dat-xxr5a-pp.h" -#include "common/inc/ocmp_wrappers/ocmp_debugi2c.h" -#include "common/inc/ocmp_wrappers/ocmp_debugmdio.h" -#include "common/inc/ocmp_wrappers/ocmp_debugocgpio.h" -#include "common/inc/ocmp_wrappers/ocmp_debugmdio.h" -#include "common/inc/ocmp_wrappers/ocmp_eeprom_cat24c04.h" -#include "common/inc/ocmp_wrappers/ocmp_eth_sw.h" -#include "common/inc/ocmp_wrappers/ocmp_fe-param.h" -#include "common/inc/ocmp_wrappers/ocmp_ina226.h" -#include "common/inc/ocmp_wrappers/ocmp_iridium.h" -#include "common/inc/ocmp_wrappers/ocmp_led.h" -#include "common/inc/ocmp_wrappers/ocmp_ltc4015.h" -#include "common/inc/ocmp_wrappers/ocmp_ltc4274.h" -#include "common/inc/ocmp_wrappers/ocmp_ltc4275.h" -#include "common/inc/ocmp_wrappers/ocmp_mac.h" -#include "common/inc/ocmp_wrappers/ocmp_powersource.h" -#include "common/inc/ocmp_wrappers/ocmp_rfpowermonitor.h" -#include "common/inc/ocmp_wrappers/ocmp_rfwatchdog.h" -#include "common/inc/ocmp_wrappers/ocmp_se98a.h" -#include "common/inc/ocmp_wrappers/ocmp_syncio.h" -#include "common/inc/ocmp_wrappers/ocmp_testmodule.h" -#include "common/inc/global/OC_CONNECT1.h" -#include "schema.h" - -/* SYS Configs*/ -SCHEMA_IMPORT DriverStruct eeprom_gbc_sid; -SCHEMA_IMPORT DriverStruct eeprom_gbc_inv; -SCHEMA_IMPORT DriverStruct eeprom_sdr_inv; -SCHEMA_IMPORT DriverStruct eeprom_fe_inv; -SCHEMA_IMPORT DriverStruct gbc_spi_flash_memory; -/* Power SubSystem Configs */ -SCHEMA_IMPORT DriverStruct gbc_pwr_lead_acid_ts; -SCHEMA_IMPORT DriverStruct gbc_pwr_ext_bat_charger; -SCHEMA_IMPORT DriverStruct gbc_pwr_int_bat_charger; -SCHEMA_IMPORT DriverStruct gbc_pwr_pse; -SCHEMA_IMPORT DriverStruct gbc_pwr_pd; -SCHEMA_IMPORT DriverStruct gbc_pwr_powerSource; - -/* BMS SubSystem Configs */ -SCHEMA_IMPORT DriverStruct gbc_bms_ec_ps_12v; -SCHEMA_IMPORT DriverStruct gbc_bms_ec_ps_3p3v; -SCHEMA_IMPORT DriverStruct gbc_bms_ec_ts; - -/*HCI SubSystem Configs*/ -SCHEMA_IMPORT DriverStruct gbc_hci_buzzer; -SCHEMA_IMPORT DriverStruct led_hci_ts; -SCHEMA_IMPORT DriverStruct led_hci_ioexp; - -/*Ethernet SubSystem Configs*/ -SCHEMA_IMPORT DriverStruct gbc_eth_port0; -SCHEMA_IMPORT DriverStruct gbc_eth_port1; -SCHEMA_IMPORT DriverStruct gbc_eth_port2; -SCHEMA_IMPORT DriverStruct gbc_eth_port3; -SCHEMA_IMPORT DriverStruct gbc_eth_port4; - -/*OBC SubSystem Configs*/ -SCHEMA_IMPORT DriverStruct obc_irridium; -SCHEMA_IMPORT DriverStruct sync_obc_gpiocfg; - -/*GPP SubSystem Configs*/ -SCHEMA_IMPORT DriverStruct gbc_gpp_ap_ps; -SCHEMA_IMPORT DriverStruct gbc_gpp_ap_ts1; -SCHEMA_IMPORT DriverStruct gbc_gpp_ap_ts2; -SCHEMA_IMPORT DriverStruct gbc_gpp_ap_ts3; -SCHEMA_IMPORT DriverStruct gbc_gpp_msata_ps; -SCHEMA_IMPORT DriverStruct gbc_gpp_gpioCfg; - -/*SDR SubSystem Configs*/ -SCHEMA_IMPORT DriverStruct sdr_fpga_ps; -SCHEMA_IMPORT DriverStruct sdr_fpga_ts; -SCHEMA_IMPORT DriverStruct sdr_eeprom_inventory; -SCHEMA_IMPORT DriverStruct sdr_ps; -SCHEMA_IMPORT DriverStruct sdr_gpioCfg; -SCHEMA_IMPORT DriverStruct sdr_fx3_gpiocfg; - -/*FE SubSystem Configs*/ -SCHEMA_IMPORT DriverStruct fe_rffecfg; -SCHEMA_IMPORT DriverStruct fe_ch1_ps_5_7v; -SCHEMA_IMPORT DriverStruct fe_ch2_ps_5_7v; -SCHEMA_IMPORT DriverStruct fe_ch1_ts; -SCHEMA_IMPORT DriverStruct fe_ch2_ts; -SCHEMA_IMPORT DriverStruct fe_eeprom_inventory; -SCHEMA_IMPORT DriverStruct fe_ch1_ads7830; -SCHEMA_IMPORT DriverStruct fe_ch2_ads7830; -SCHEMA_IMPORT DriverStruct fe_ch1_gain; -SCHEMA_IMPORT DriverStruct fe_ch2_gain; -SCHEMA_IMPORT DriverStruct fe_ch1_lna; -SCHEMA_IMPORT DriverStruct fe_ch2_lna; -SCHEMA_IMPORT DriverStruct fe_ch1_watchdog; -SCHEMA_IMPORT DriverStruct fe_ch2_watchdog; -SCHEMA_IMPORT DriverStruct fe_ch1_tx_gain_cfg; -SCHEMA_IMPORT DriverStruct fe_ch2_tx_gain_cfg; -SCHEMA_IMPORT DriverStruct fe_ch1_rx_gain_cfg; -SCHEMA_IMPORT DriverStruct fe_ch2_rx_gain_cfg; -SCHEMA_IMPORT DriverStruct fe_ch1_bandcfg; -SCHEMA_IMPORT DriverStruct fe_ch2_bandcfg; -SCHEMA_IMPORT DriverStruct fe_ch1_pwrcfg; -SCHEMA_IMPORT DriverStruct fe_ch2_pwrcfg; - -/*Sync SubSystem Configs*/ -SCHEMA_IMPORT DriverStruct sync_gps_ts; -SCHEMA_IMPORT DriverStruct sync_gps_io; -SCHEMA_IMPORT DriverStruct sync_gpiocfg; - -/*TestModule Subsystem Configd*/ -SCHEMA_IMPORT DriverStruct testModuleCfg; - -/*Debug SubSystem Configs*/ -SCHEMA_IMPORT DriverStruct debug_I2C0; -SCHEMA_IMPORT DriverStruct debug_I2C1; -SCHEMA_IMPORT DriverStruct debug_I2C2; -SCHEMA_IMPORT DriverStruct debug_I2C3; -SCHEMA_IMPORT DriverStruct debug_I2C4; -SCHEMA_IMPORT DriverStruct debug_I2C6; -SCHEMA_IMPORT DriverStruct debug_I2C7; -SCHEMA_IMPORT DriverStruct debug_I2C8; - -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pa; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pb; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pc; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pd; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pe; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pf; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pg; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_ph; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pj; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pk; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pl; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pm; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pn; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pp; -SCHEMA_IMPORT DriverStruct debug_ec_gpio_pq; - -SCHEMA_IMPORT DriverStruct debug_gbc_ioexpanderx70; -SCHEMA_IMPORT DriverStruct debug_gbc_ioexpanderx71; - -SCHEMA_IMPORT DriverStruct debug_sdr_ioexpanderx1E; - -SCHEMA_IMPORT DriverStruct debug_fe_ioexpanderx18; -SCHEMA_IMPORT DriverStruct debug_fe_ioexpanderx1C; -SCHEMA_IMPORT DriverStruct debug_fe_ioexpanderx1B; -SCHEMA_IMPORT DriverStruct debug_fe_ioexpanderx1A; -SCHEMA_IMPORT DriverStruct debug_fe_ioexpanderx1D; - -SCHEMA_IMPORT DriverStruct debug_sync_ioexpanderx71; - -SCHEMA_IMPORT DriverStruct debug_mdio_phyport0; -SCHEMA_IMPORT DriverStruct debug_mdio_phyport1; -SCHEMA_IMPORT DriverStruct debug_mdio_phyport2; -SCHEMA_IMPORT DriverStruct debug_mdio_phyport3; -SCHEMA_IMPORT DriverStruct debug_mdio_phyport4; -SCHEMA_IMPORT DriverStruct debug_mdio_global1; -SCHEMA_IMPORT DriverStruct debug_mdio_global2; -SCHEMA_IMPORT DriverStruct debug_mdio_swport0; -SCHEMA_IMPORT DriverStruct debug_mdio_swport1; -SCHEMA_IMPORT DriverStruct debug_mdio_swport2; -SCHEMA_IMPORT DriverStruct debug_mdio_swport3; -SCHEMA_IMPORT DriverStruct debug_mdio_swport4; -SCHEMA_IMPORT DriverStruct debug_mdio_swport5; -SCHEMA_IMPORT DriverStruct debug_mdio_swport6; - -SCHEMA_IMPORT const DriverStruct fact_bc_se98a; -SCHEMA_IMPORT const DriverStruct fact_leadAcid_cfg; -SCHEMA_IMPORT const DriverStruct fact_lithiumIon_cfg; -SCHEMA_IMPORT const DriverStruct fact_ltc4274_cfg; -SCHEMA_IMPORT const DriverStruct fact_ec_se98a_cfg; -SCHEMA_IMPORT const DriverStruct fact_ec_12v_ps_cfg; -SCHEMA_IMPORT const DriverStruct fact_ec_3v_ps_cfg; -SCHEMA_IMPORT const DriverStruct fact_led_se98a_cfg; -SCHEMA_IMPORT const DriverStruct fact_ap_se98a_ts1_cfg; -SCHEMA_IMPORT const DriverStruct fact_ap_se98a_ts2_cfg; -SCHEMA_IMPORT const DriverStruct fact_ap_se98a_ts3_cfg; -SCHEMA_IMPORT const DriverStruct fact_ap_3v_ps_cfg; -SCHEMA_IMPORT const DriverStruct fact_msata_3v_ps_cfg; -SCHEMA_IMPORT const DriverStruct fact_sdr_3v_ps_cfg; -SCHEMA_IMPORT const DriverStruct fact_sdr_fpga_adt7481_cfg; -SCHEMA_IMPORT const DriverStruct fact_sdr_fpga_ps_cfg; -SCHEMA_IMPORT const DriverStruct fact_fe_ch1_adt7481_cfg; -SCHEMA_IMPORT const DriverStruct fact_fe_ch1_ps_cfg; -SCHEMA_IMPORT const DriverStruct fact_fe_ch2_adt7481_cfg; -SCHEMA_IMPORT const DriverStruct fact_fe_ch2_ps_cfg; -SCHEMA_IMPORT const DriverStruct fact_ch1_tx_gain_cfg; -SCHEMA_IMPORT const DriverStruct fact_ch1_rx_gain_cfg; -SCHEMA_IMPORT const DriverStruct fact_ch2_tx_gain_cfg; -SCHEMA_IMPORT const DriverStruct fact_ch2_rx_gain_cfg; -SCHEMA_IMPORT const DriverStruct fact_ch1_band_cfg; -SCHEMA_IMPORT const DriverStruct fact_ch2_band_cfg; -SCHEMA_IMPORT const DriverStruct fact_sync_ts_cfg; - -// Function Type -SCHEMA_IMPORT bool gpp_pre_init(void *driver, void *returnValue); -SCHEMA_IMPORT bool gpp_post_init(void *driver, void *returnValue); -SCHEMA_IMPORT bool GPP_ap_Reset(void *driver, void *params); -SCHEMA_IMPORT bool HCI_Init(void *driver, void *returnValue); -SCHEMA_IMPORT bool RFFE_enablePA(void *driver, void *params); -SCHEMA_IMPORT bool RFFE_disablePA(void *driver, void *params); -SCHEMA_IMPORT bool rffe_pre_init(void *driver, void *returnValue); -SCHEMA_IMPORT bool rffe_post_init(void *driver, void *returnValue); -SCHEMA_IMPORT bool RFFE_reset(void *driver, void *params); -SCHEMA_IMPORT bool SDR_Init(void *driver, void *returnValue); -SCHEMA_IMPORT bool SDR_fx3Reset(void *driver, void *params); -SCHEMA_IMPORT bool SDR_reset(void *driver, void *returnValue); -SCHEMA_IMPORT bool SYNC_Init(void *driver, void *returnValue); -SCHEMA_IMPORT bool SYNC_reset(void *driver, void *params); -SCHEMA_IMPORT bool SYS_cmdReset(void *driver, void *params); -SCHEMA_IMPORT bool SYS_cmdEcho(void *driver, void *params); -SCHEMA_IMPORT bool sys_post_init(void *driver, void *returnValue); -SCHEMA_IMPORT bool TestMod_cmdEnable(void *driver, void *params); -SCHEMA_IMPORT bool TestMod_cmdDisable(void *driver, void *params); -SCHEMA_IMPORT bool TestMod_cmdDisconnect(void *driver, void *params); -SCHEMA_IMPORT bool TestMod_cmdConnect(void *driver, void *params); -SCHEMA_IMPORT bool TestMod_cmdSendSms(void *driver, void *params); -SCHEMA_IMPORT bool TestMod_cmdDial(void *driver, void *params); -SCHEMA_IMPORT bool TestMod_cmdAnswer(void *driver, void *params); -SCHEMA_IMPORT bool TestMod_cmdHangup(void *driver, void *params); -SCHEMA_IMPORT bool TestMod_cmdReset(void *driver, void *params); -SCHEMA_IMPORT bool obc_pre_init(void *driver, void *returnValue); -SCHEMA_IMPORT bool SYS_post_get_results(void **getpostResult); -SCHEMA_IMPORT bool SYS_post_enable(void **postActivate); - -const Component sys_schema[] = { - { - .name = "system", - .components = - (Component[]){ - { - .name = "comp_all", - .driver = &SYSTEMDRV, - .driver_cfg = - &gbc_gpp_gpioCfg, /* For reset pin, will revise */ - .components = - (Component[]){ { - .name = "eeprom_sid", - .driver = &CAT24C04_gbc_sid, - .driver_cfg = &eeprom_gbc_sid, - }, - { - .name = "eeprom_inv", - .driver = &CAT24C04_gbc_inv, - .driver_cfg = &eeprom_gbc_inv, - }, - { - .name = "eeprom_mac", - .driver = &Driver_MAC, - }, - { - .name = "SPI_flash", - .driver = &FLASHDRV, - .driver_cfg = &gbc_spi_flash_memory, - }, - {} }, - .commands = (Command[]){ { - .name = "reset", - .cb_cmd = SYS_cmdReset, - }, - { - .name = "echo", - .cb_cmd = SYS_cmdEcho, - }, - {} }, - }, - {} }, - .driver_cfg = &gbc_spi_flash_memory, - .ssHookSet = - &(SSHookSet){ - .postInitFxn = (ssHook_Cb)sys_post_init, - }, - }, - { - .name = "power", - .components = - (Component[]){ - { - .name = "comp_all", - .components = - (Component[]){ - { - .name = "powerSource", - .driver = &PWRSRC, - .driver_cfg = &gbc_pwr_powerSource, - .postDisabled = POST_DISABLED, - }, - {} }, - }, - { .name = "leadacid_sensor", - .components = - (Component[]){ { - .name = "temp_sensor1", - .driver = &SE98A, - .driver_cfg = &gbc_pwr_lead_acid_ts, - .factory_config = &fact_bc_se98a, - }, - {} } }, - { .name = "leadacid", - .components = - (Component[]){ { - .name = "battery", - .driver = <C4015, - .driver_cfg = &gbc_pwr_ext_bat_charger, - .factory_config = &fact_leadAcid_cfg, - }, - {} } }, - { .name = "lion", - .components = - (Component[]){ { - .name = "battery", - .driver = <C4015, - .driver_cfg = &gbc_pwr_int_bat_charger, - .factory_config = &fact_lithiumIon_cfg, - }, - {} } }, - { - .name = "pse", - .driver = <C4274, - .driver_cfg = &gbc_pwr_pse, - .factory_config = &fact_ltc4274_cfg, - }, - { - .name = "pd", - .driver = <C4275, - .driver_cfg = &gbc_pwr_pd, - }, - {} }, - }, - { - .name = "bms", - .components = - (Component[]){ - { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - { .name = "ec", - .components = - (Component[]){ - { - .name = "temp_sensor1", - .driver = &SE98A, - .driver_cfg = &gbc_bms_ec_ts, - .factory_config = &fact_ec_se98a_cfg, - }, - { - .name = "current_sensor1", - .driver = &INA226, - .driver_cfg = &gbc_bms_ec_ps_12v, - .factory_config = &fact_ec_12v_ps_cfg, - }, - { - .name = "current_sensor2", - .driver = &INA226, - .driver_cfg = &gbc_bms_ec_ps_3p3v, - .factory_config = &fact_ec_3v_ps_cfg, - }, - {} } }, - {} }, - }, - { - .name = "hci", - .ssHookSet = - &(SSHookSet){ - .preInitFxn = (ssHook_Cb)HCI_Init, - .postInitFxn = NULL, - }, - .components = - (Component[]){ - { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - { - .name = "led", - .components = - (Component[]){ - { - .name = "temp_sensor1", - .driver = &SE98A, - .driver_cfg = &led_hci_ts, - .factory_config = &fact_led_se98a_cfg, - .postDisabled = POST_DISABLED, - }, - { - .name = "fw", - .driver = &HCI_LED, - .driver_cfg = &led_hci_ioexp, - }, - {} }, - }, - { - /* TODO: Remove buzzer component if there is no OCMP message - * required */ - .name = "buzzer", - .driver_cfg = &gbc_hci_buzzer, - .postDisabled = POST_DISABLED, - }, - {} }, - }, - { - .name = "ethernet", - .components = (Component[]){ { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - { - .name = "port0", - .driver = Ð_SW, - .driver_cfg = &gbc_eth_port0, - }, - { - .name = "port1", - .driver = Ð_SW, - .driver_cfg = &gbc_eth_port1, - }, - { - .name = "port2", - .driver = Ð_SW, - .driver_cfg = &gbc_eth_port2, - }, - { - .name = "port3", - .driver = Ð_SW, - .driver_cfg = &gbc_eth_port3, - }, - { - .name = "port4", - .driver = Ð_SW, - .driver_cfg = &gbc_eth_port4, - }, - {} }, - }, - { - .name = "obc", - .ssHookSet = - &(SSHookSet){ - .preInitFxn = (ssHook_Cb)obc_pre_init, - .postInitFxn = NULL, - }, - .driver_cfg = &sync_obc_gpiocfg, - .components = (Component[]){ { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - { - .name = "iridium", - .driver = &OBC_Iridium, - .driver_cfg = &obc_irridium, - }, - {} }, - }, - { - .name = "gpp", - .components = - (Component[]){ - { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - - { - .name = "ap", - .components = - (Component[]){ - { - .name = "temp_sensor1", - .driver = &SE98A, - .driver_cfg = &gbc_gpp_ap_ts1, - .factory_config = &fact_ap_se98a_ts1_cfg, - }, - { - .name = "temp_sensor2", - .driver = &SE98A, - .driver_cfg = &gbc_gpp_ap_ts2, - .factory_config = &fact_ap_se98a_ts2_cfg, - }, - { - .name = "temp_sensor3", - .driver = &SE98A, - .driver_cfg = &gbc_gpp_ap_ts3, - .factory_config = &fact_ap_se98a_ts3_cfg, - }, - { - .name = "current_sensor1", - .driver = &INA226, - .driver_cfg = &gbc_gpp_ap_ps, - .factory_config = &fact_ap_3v_ps_cfg, - }, - {} }, - .driver_cfg = &gbc_gpp_gpioCfg, - .commands = (Command[]){ { - .name = "reset", - .cb_cmd = GPP_ap_Reset, - }, - {} }, - }, - { .name = "msata", - .components = - (Component[]){ - { - .name = "current_sensor1", - .driver = &INA226, - .driver_cfg = &gbc_gpp_msata_ps, - .factory_config = &fact_msata_3v_ps_cfg, - }, - {} } }, - {} }, - .driver_cfg = &gbc_gpp_gpioCfg, - .ssHookSet = - &(SSHookSet){ - .preInitFxn = (ssHook_Cb)gpp_pre_init, - .postInitFxn = (ssHook_Cb)gpp_post_init, - }, - }, - { - .name = "sdr", - .components = - (Component[]){ - { - .name = "comp_all", - .components = - (Component[]){ - { - .name = "current_sensor1", - .driver = &INA226, - .driver_cfg = &sdr_ps, - .factory_config = &fact_sdr_3v_ps_cfg, - }, - { - /* TODO: this is pretty hw-specific, I think we - * can dedupe for the other boards, but I don't - * think a framework level driver is appropriate - * (although, a proper OC-DB driver might have - * us revisit this) */ - /* TODO: "eeprom" makes the CLI command pretty - * verbose, maybe see about a way of making this - * better: - * sdr.comp_all.eeprom.dev_id is kind of long */ - .name = "eeprom", - .driver_cfg = &eeprom_sdr_inv, - .driver = &CAT24C04_sdr_inv, - }, - {} }, - .driver_cfg = &sdr_gpioCfg, - .commands = (Command[]){ { - .name = "reset", - .cb_cmd = SDR_reset, - }, - {} }, - }, - { .name = "fpga", - .components = - (Component[]){ - { - .name = "temp_sensor1", - .driver = &ADT7481, - .driver_cfg = &sdr_fpga_ts, - .factory_config = &fact_sdr_fpga_adt7481_cfg, - }, - { - .name = "current_sensor1", - .driver = &INA226, - .driver_cfg = &sdr_fpga_ps, - .factory_config = &fact_sdr_fpga_ps_cfg, - }, - {} } }, - { - .name = "fx3", - .driver_cfg = &sdr_gpioCfg, - .commands = (Command[]){ { - .name = "reset", - .cb_cmd = SDR_fx3Reset, - }, - {} }, - .postDisabled = POST_DISABLED, - }, - {} }, - .driver_cfg = &sdr_gpioCfg, - .ssHookSet = - &(SSHookSet){ - .preInitFxn = (ssHook_Cb)SDR_Init, - .postInitFxn = NULL, - }, - }, - { - .name = "rffe", - .driver_cfg = &fe_rffecfg, - .components = - (Component[]){ - { - .name = "comp_all", - .components = (Component[]){ { - .name = "eeprom", - .driver = &CAT24C04_fe_inv, - .driver_cfg = - &eeprom_fe_inv, - }, - {} }, - .driver_cfg = &sdr_gpioCfg, - .commands = (Command[]){ { - .name = "reset", - .cb_cmd = RFFE_reset, - }, - {} }, - }, - { .name = "ch1_sensor", - .components = - (Component[]){ - { - .name = "temp_sensor1", - .driver = &ADT7481, - .driver_cfg = &fe_ch1_ts, - .factory_config = &fact_fe_ch1_adt7481_cfg, - }, - { - .name = "current_sensor1", - .driver = &INA226, - .driver_cfg = &fe_ch1_ps_5_7v, - .factory_config = &fact_fe_ch1_ps_cfg, - }, - {} } }, - { .name = "ch2_sensor", - .components = - (Component[]){ - { - .name = "temp_sensor1", - .driver = &ADT7481, - .driver_cfg = &fe_ch2_ts, - .factory_config = &fact_fe_ch2_adt7481_cfg, - }, - { - .name = "current_sensor1", - .driver = &INA226, - .driver_cfg = &fe_ch2_ps_5_7v, - .factory_config = &fact_fe_ch2_ps_cfg, - }, - {} } }, - { - .name = "ch1_fe", - .driver_cfg = &fe_ch1_pwrcfg, /* For en/dis context */ - .components = - (Component[]){ - { - .name = "ch1_band", - /* Placeholder driver to let us test the DAT - driver */ - .driver = &FE_Param, - .driver_cfg = &fe_ch1_bandcfg, - .factory_config = &fact_ch1_band_cfg, - }, - { - .name = "watchdog", - .driver = &RFFEWatchdog, - .driver_cfg = &fe_ch1_watchdog, - }, - { - .name = "power", - .driver = &RFPowerMonitor, - .driver_cfg = &fe_ch1_ads7830, - }, - { - .name = "tx", - .driver = &DATXXR5APP, - /* this struct should be compatible with the DAT - cfg struct */ - .driver_cfg = &fe_ch1_gain, - .factory_config = &fact_ch1_tx_gain_cfg, - }, - { - .name = "rx", - .driver = &DATXXR5APP, - /* this struct should be compatible with the DAT - cfg struct */ - .driver_cfg = &fe_ch1_lna, - .factory_config = &fact_ch1_rx_gain_cfg, - }, - {} }, - .commands = (Command[]){ { - .name = "enable", - .cb_cmd = RFFE_enablePA, - }, - { - .name = "disable", - .cb_cmd = RFFE_disablePA, - }, - {} }, - }, - { - .name = "ch2_fe", - .driver_cfg = &fe_ch2_pwrcfg, /* For en/dis context */ - .components = - (Component[]){ - { - .name = "ch2_band", - /* Placeholder driver to let us test the DAT - driver */ - .driver = &FE_Param, - .driver_cfg = &fe_ch2_bandcfg, - .factory_config = &fact_ch2_band_cfg, - }, - { - .name = "watchdog", - .driver = &RFFEWatchdog, - .driver_cfg = &fe_ch2_watchdog, - }, - { - .name = "power", - .driver = &RFPowerMonitor, - .driver_cfg = &fe_ch2_ads7830, - }, - { - .name = "tx", - .driver = &DATXXR5APP, - /* this struct should be compatible with the DAT - cfg struct */ - .driver_cfg = &fe_ch2_gain, - .factory_config = &fact_ch2_tx_gain_cfg, - }, - { - .name = "rx", - .driver = &DATXXR5APP, - /* this struct should be compatible with the DAT - cfg struct */ - .driver_cfg = &fe_ch2_lna, - .factory_config = &fact_ch2_rx_gain_cfg, - }, - {} }, - .commands = (Command[]){ { - .name = "enable", - .cb_cmd = RFFE_enablePA, - }, - { - .name = "disable", - .cb_cmd = RFFE_disablePA, - }, - {} }, - }, - {} }, - .driver_cfg = &fe_rffecfg, - .ssHookSet = - &(SSHookSet){ - .preInitFxn = (ssHook_Cb)rffe_pre_init, - .postInitFxn = (ssHook_Cb)rffe_post_init, - }, - }, - { .name = "sync", - .driver_cfg = &sync_gpiocfg, - .ssHookSet = - &(SSHookSet){ - .preInitFxn = (ssHook_Cb)SYNC_Init, - .postInitFxn = NULL, - }, - .components = - (Component[]){ { - .name = "comp_all", - .driver_cfg = &sync_gpiocfg, - .commands = (Command[]){ { - .name = "reset", - .cb_cmd = SYNC_reset, - }, - {} }, - .postDisabled = POST_DISABLED, - }, - { - .name = "gps", - .driver_cfg = &sync_gpiocfg, - .driver = &Sync_IO, - }, - { .name = "sensor", - .components = - (Component[]){ { - .name = "temp_sensor1", - .driver = &ADT7481, - .driver_cfg = &sync_gps_ts, - .factory_config = - &fact_sync_ts_cfg, - }, - {} } }, - {} } }, - { .name = "testmodule", - .components = - (Component[]){ { - .name = "comp_all", - .commands = - (Command[]){ { - .name = "reset", - .cb_cmd = TestMod_cmdReset, - }, - {} }, - .postDisabled = POST_DISABLED, - }, - { - .name = "2gsim", - .driver = &Testmod_G510, - .driver_cfg = &testModuleCfg, - }, - {} } }, - { - .name = "debug", - .components = - (Component[]){ - { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - { - .name = "I2C", - .components = - (Component[]){ - { .name = "comp_all", - .postDisabled = POST_DISABLED }, - { .name = "bus0", - .driver = &OC_I2C, - .driver_cfg = &debug_I2C0, - .postDisabled = POST_DISABLED }, - { .name = "bus1", - .driver = &OC_I2C, - .driver_cfg = &debug_I2C1, - .postDisabled = POST_DISABLED }, - { .name = "bus2", - .driver = &OC_I2C, - .driver_cfg = &debug_I2C2, - .postDisabled = POST_DISABLED }, - { .name = "bus3", - .driver = &OC_I2C, - .driver_cfg = &debug_I2C3, - .postDisabled = POST_DISABLED }, - { .name = "bus4", - .driver = &OC_I2C, - .driver_cfg = &debug_I2C4, - .postDisabled = POST_DISABLED }, - { .name = "bus6", - .driver = &OC_I2C, - .driver_cfg = &debug_I2C6, - .postDisabled = POST_DISABLED }, - { .name = "bus7", - .driver = &OC_I2C, - .driver_cfg = &debug_I2C7, - .postDisabled = POST_DISABLED }, - { .name = "bus8", - .driver = &OC_I2C, - .driver_cfg = &debug_I2C8, - .postDisabled = POST_DISABLED }, - {} }, - }, - { - .name = "ec", - .components = - (Component[]){ - { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - { - .name = "PA", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pa, - .postDisabled = POST_DISABLED, - }, - { - .name = "PB", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pb, - .postDisabled = POST_DISABLED, - }, - { - .name = "PC", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pc, - .postDisabled = POST_DISABLED, - }, - { - .name = "PD", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pd, - .postDisabled = POST_DISABLED, - }, - { - .name = "PE", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pe, - .postDisabled = POST_DISABLED, - }, - { - .name = "PF", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pf, - .postDisabled = POST_DISABLED, - }, - { - .name = "PG", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pg, - .postDisabled = POST_DISABLED, - }, - { - .name = "PH", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_ph, - .postDisabled = POST_DISABLED, - }, - { - .name = "PJ", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pj, - .postDisabled = POST_DISABLED, - }, - { - .name = "PK", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pk, - .postDisabled = POST_DISABLED, - }, - { - .name = "PL", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pl, - .postDisabled = POST_DISABLED, - }, - { - .name = "PM", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pm, - .postDisabled = POST_DISABLED, - }, - { - .name = "PN", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pn, - .postDisabled = POST_DISABLED, - }, - { - .name = "PP", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pn, - .postDisabled = POST_DISABLED, - }, - { - .name = "PQ", - .driver = &OC_GPIO, - .driver_cfg = &debug_ec_gpio_pq, - .postDisabled = POST_DISABLED, - }, - {} }, - }, - { - .name = "gbc", - .components = - (Component[]){ - { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - { - .name = "ioexpanderx70", - .driver = &OC_GPIO, - .driver_cfg = &debug_gbc_ioexpanderx70, - }, - { - .name = "ioexpanderx71", - .driver = &OC_GPIO, - .driver_cfg = &debug_gbc_ioexpanderx71, - }, - {} }, - }, - { .name = "sdr", - .components = - (Component[]){ { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - { - .name = "ioexpanderx1E", - .driver = - &OC_GPIO, - .driver_cfg = &debug_sdr_ioexpanderx1E, - }, - {} } }, - { .name = "fe", - .components = - (Component[]){ { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - { - .name = "ioexpanderx18", - .driver = - &OC_GPIO, - .driver_cfg = &debug_sdr_ioexpanderx1E, - }, - { - .name = "ioexpanderx1C", - .driver = &OC_GPIO, - .driver_cfg = &debug_fe_ioexpanderx1C, - }, - { - .name = "ioexpanderx1B", - .driver = &OC_GPIO, - .driver_cfg = &debug_fe_ioexpanderx1B, - }, - { - .name = "ioexpanderx1A", - .driver = &OC_GPIO, - .driver_cfg = &debug_fe_ioexpanderx1A, - }, - { - .name = "ioexpanderx1D", - .driver = &OC_GPIO, - .driver_cfg = &debug_fe_ioexpanderx1D, - }, - {} - - } }, - { .name = "sync", - .components = - (Component[]){ - { - .name = "comp_all", - .postDisabled = - POST_DISABLED, - }, - { - .name = "ioexpanderx71", - .driver = &OC_GPIO, - .driver_cfg = &debug_sync_ioexpanderx71, - }, - {} } }, - { .name = "ethernet", - .components = - (Component[]){ { - .name = "comp_all", - .postDisabled = POST_DISABLED, - }, - { - .name = "port0", - .driver = - &OC_MDIO, - .driver_cfg = &debug_mdio_phyport0, - .postDisabled = POST_DISABLED, - }, - { - .name = "port1", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_phyport1, - .postDisabled = POST_DISABLED, - }, - { - .name = "port2", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_phyport2, - .postDisabled = POST_DISABLED, - }, - { - .name = "port3", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_phyport3, - .postDisabled = POST_DISABLED, - }, - { - .name = "port4", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_phyport4, - .postDisabled = POST_DISABLED, - }, - { - .name = "global1", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_global1, - .postDisabled = POST_DISABLED, - }, - { - .name = "global2", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_global2, - .postDisabled = POST_DISABLED, - }, - { - .name = "swport0", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_swport0, - .postDisabled = POST_DISABLED, - }, - { - .name = "swport1", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_swport1, - .postDisabled = POST_DISABLED, - }, - { - .name = "swport2", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_swport2, - .postDisabled = POST_DISABLED, - }, - { - .name = "swport3", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_swport3, - .postDisabled = POST_DISABLED, - }, - { - .name = "swport4", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_swport4, - .postDisabled = POST_DISABLED, - }, - { - .name = "swport5", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_swport5, - .postDisabled = POST_DISABLED, - }, - { - .name = "swport6", - .driver = &OC_MDIO, - .driver_cfg = &debug_mdio_swport6, - .postDisabled = POST_DISABLED, - }, - {} } }, - {} }, - }, - {} -}; diff --git a/firmware/ec/platform/oc-sdr/schema/sys_schema.json b/firmware/ec/platform/oc-sdr/schema/sys_schema.json new file mode 100644 index 0000000000..53f1fe114d --- /dev/null +++ b/firmware/ec/platform/oc-sdr/schema/sys_schema.json @@ -0,0 +1,895 @@ +[ + { + "name": "system", + "driver_cfg": "gbc_spi_flash_memory", + "ssHookSet": { + "preInitFxn": "NULL", + "postInitFxn": "sys_post_init" + }, + "components": [ + { + "name": "comp_all", + "driver": "SYSTEMDRV", + "driver_cfg": "gbc_gpp_gpioCfg", + "components": [ + { + "name": "eeprom_sid", + "driver": "CAT24C04_gbc_sid", + "driver_cfg": "eeprom_gbc_sid" + }, + { + "name": "eeprom_inv", + "driver": "CAT24C04_gbc_inv", + "driver_cfg": "eeprom_gbc_inv" + }, + { + "name": "eeprom_mac", + "driver": "Driver_MAC" + }, + { + "name": "SPI_flash", + "driver": "FLASHDRV", + "driver_cfg": "gbc_spi_flash_memory" + } + ], + "commands": [ + { + "name": "reset", + "cb_cmd": "SYS_cmdReset" + }, + { + "name": "echo", + "cb_cmd": "SYS_cmdEcho" + } + ] + } + ] + }, + { + "name": "power", + "components": [ + { + "name": "comp_all", + "components": [ + { + "name": "powerSource", + "driver": "PWRSRC", + "driver_cfg": "gbc_pwr_powerSource", + "postDisabled": "POST_DISABLED" + } + ] + }, + { + "name": "leadacid_sensor", + "components": [ + { + "name": "temp_sensor1", + "driver": "SE98A", + "driver_cfg": "gbc_pwr_lead_acid_ts", + "factory_config": "fact_bc_se98a" + } + ] + }, + { + "name": "leadacid", + "components": [ + { + "name": "battery", + "driver": "LTC4015", + "driver_cfg": "gbc_pwr_ext_bat_charger", + "factory_config": "fact_leadAcid_cfg" + } + ] + }, + { + "name": "lion", + "components": [ + { + "name": "battery", + "driver": "LTC4015", + "driver_cfg": "gbc_pwr_int_bat_charger", + "factory_config": "fact_lithiumIon_cfg" + } + ] + }, + { + "name": "pse", + "driver": "LTC4274", + "driver_cfg": "gbc_pwr_pse", + "factory_config": "fact_ltc4274_cfg" + }, + { + "name": "pd", + "driver": "LTC4275", + "driver_cfg": "gbc_pwr_pd" + } + ] + }, + { + "name": "bms", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "ec", + "components": [ + { + "name": "temp_sensor1", + "driver": "SE98A", + "driver_cfg": "gbc_bms_ec_ts", + "factory_config": "fact_ec_se98a_cfg" + }, + { + "name": "current_sensor1", + "driver": "INA226", + "driver_cfg": "gbc_bms_ec_ps_12v", + "factory_config": "fact_ec_12v_ps_cfg" + }, + { + "name": "current_sensor2", + "driver": "INA226", + "driver_cfg": "gbc_bms_ec_ps_3p3v", + "factory_config": "fact_ec_3v_ps_cfg" + } + ] + } + ] + }, + { + "name": "hci", + "ssHookSet": { + "preInitFxn": "HCI_Init", + "postInitFxn": "NULL" + }, + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "led", + "components": [ + { + "name": "temp_sensor1", + "driver": "SE98A", + "driver_cfg": "led_hci_ts", + "factory_config": "fact_led_se98a_cfg", + "postDisabled": "POST_DISABLED" + }, + { + "name": "fw", + "driver": "HCI_LED", + "driver_cfg": "led_hci_ioexp" + } + ] + }, + { + "name": "buzzer", + "driver_cfg": "gbc_hci_buzzer", + "postDisabled": "POST_DISABLED" + } + ] + }, + { + "name": "ethernet", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "port0", + "driver": "ETH_SW", + "driver_cfg": "gbc_eth_port0" + }, + { + "name": "port1", + "driver": "ETH_SW", + "driver_cfg": "gbc_eth_port1" + }, + { + "name": "port2", + "driver": "ETH_SW", + "driver_cfg": "gbc_eth_port2" + }, + { + "name": "port3", + "driver": "ETH_SW", + "driver_cfg": "gbc_eth_port3" + }, + { + "name": "port4", + "driver": "ETH_SW", + "driver_cfg": "gbc_eth_port4" + } + ] + }, + { + "name": "obc", + "ssHookSet": { + "preInitFxn": "obc_pre_init", + "postInitFxn": "NULL" + }, + "driver_cfg": "sync_obc_gpiocfg", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "iridium", + "driver": "OBC_Iridium", + "driver_cfg": "obc_irridium" + } + ] + }, + { + "name": "gpp", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "ap", + "components": [ + { + "name": "temp_sensor1", + "driver": "SE98A", + "driver_cfg": "gbc_gpp_ap_ts1", + "factory_config": "fact_ap_se98a_ts1_cfg" + }, + { + "name": "temp_sensor2", + "driver": "SE98A", + "driver_cfg": "gbc_gpp_ap_ts2", + "factory_config": "fact_ap_se98a_ts2_cfg" + }, + { + "name": "temp_sensor3", + "driver": "SE98A", + "driver_cfg": "gbc_gpp_ap_ts3", + "factory_config": "fact_ap_se98a_ts3_cfg" + }, + { + "name": "current_sensor1", + "driver": "INA226", + "driver_cfg": "gbc_gpp_ap_ps", + "factory_config": "fact_ap_3v_ps_cfg" + } + ], + "driver_cfg": "gbc_gpp_gpioCfg", + "commands": [ + { + "name": "reset", + "cb_cmd": "GPP_ap_Reset" + } + ] + }, + { + "name": "msata", + "components": [ + { + "name": "current_sensor1", + "driver": "INA226", + "driver_cfg": "gbc_gpp_msata_ps", + "factory_config": "fact_msata_3v_ps_cfg" + } + ] + } + ], + "driver_cfg": "gbc_gpp_gpioCfg", + "ssHookSet": { + "preInitFxn": "gpp_pre_init", + "postInitFxn": "gpp_post_init" + } + }, + { + "name": "sdr", + "components": [ + { + "name": "comp_all", + "components": [ + { + "name": "current_sensor1", + "driver": "INA226", + "driver_cfg": "sdr_ps", + "factory_config": "fact_sdr_3v_ps_cfg" + }, + { + "name": "eeprom", + "driver_cfg": "eeprom_sdr_inv", + "driver": "CAT24C04_sdr_inv" + } + ], + "driver_cfg": "sdr_gpioCfg", + "commands": [ + { + "name": "reset", + "cb_cmd": "SDR_reset" + } + ] + }, + { + "name": "fpga", + "components": [ + { + "name": "temp_sensor1", + "driver": "ADT7481", + "driver_cfg": "sdr_fpga_ts", + "factory_config": "fact_sdr_fpga_adt7481_cfg" + }, + { + "name": "current_sensor1", + "driver": "INA226", + "driver_cfg": "sdr_fpga_ps", + "factory_config": "fact_sdr_fpga_ps_cfg" + } + ] + }, + { + "name": "fx3", + "driver_cfg": "sdr_gpioCfg", + "commands": [ + { + "name": "reset", + "cb_cmd": "SDR_fx3Reset" + } + ], + "postDisabled": "POST_DISABLED" + } + ], + "driver_cfg": "sdr_gpioCfg", + "ssHookSet": { + "preInitFxn": "SDR_Init", + "postInitFxn": "NULL" + } + }, + { + "name": "rffe", + "driver_cfg": "fe_rffecfg", + "components": [ + { + "name": "comp_all", + "components": [ + { + "name": "eeprom", + "driver": "CAT24C04_fe_inv", + "driver_cfg": "eeprom_fe_inv" + } + ], + "driver_cfg": "sdr_gpioCfg", + "commands": [ + { + "name": "reset", + "cb_cmd": "RFFE_reset" + } + ] + }, + { + "name": "ch1_sensor", + "components": [ + { + "name": "temp_sensor1", + "driver": "ADT7481", + "driver_cfg": "fe_ch1_ts", + "factory_config": "fact_fe_ch1_adt7481_cfg" + }, + { + "name": "current_sensor1", + "driver": "INA226", + "driver_cfg": "fe_ch1_ps_5_7v", + "factory_config": "fact_fe_ch1_ps_cfg" + } + ] + }, + { + "name": "ch2_sensor", + "components": [ + { + "name": "temp_sensor1", + "driver": "ADT7481", + "driver_cfg": "fe_ch2_ts", + "factory_config": "fact_fe_ch2_adt7481_cfg" + }, + { + "name": "current_sensor1", + "driver": "INA226", + "driver_cfg": "fe_ch2_ps_5_7v", + "factory_config": "fact_fe_ch2_ps_cfg" + } + ] + }, + { + "name": "ch1_fe", + "driver_cfg": "fe_ch1_pwrcfg", + "components": [ + { + "name": "ch1_band", + "driver": "FE_Param", + "driver_cfg": "fe_ch1_bandcfg", + "factory_config": "fact_ch1_band_cfg" + }, + { + "name": "watchdog", + "driver": "RFFEWatchdog", + "driver_cfg": "fe_ch1_watchdog" + }, + { + "name": "power", + "driver": "RFPowerMonitor", + "driver_cfg": "fe_ch1_ads7830" + }, + { + "name": "tx", + "driver": "DATXXR5APP", + "driver_cfg": "fe_ch1_gain", + "factory_config": "fact_ch1_tx_gain_cfg" + }, + { + "name": "rx", + "driver": "DATXXR5APP", + "driver_cfg": "fe_ch1_lna", + "factory_config": "fact_ch1_rx_gain_cfg" + } + ], + "commands": [ + { + "name": "enable", + "cb_cmd": "RFFE_enablePA" + }, + { + "name": "disable", + "cb_cmd": "RFFE_disablePA" + } + ] + }, + { + "name": "ch2_fe", + "driver_cfg": "fe_ch2_pwrcfg", + "components": [ + { + "name": "ch2_band", + "driver": "FE_Param", + "driver_cfg": "fe_ch2_bandcfg", + "factory_config": "fact_ch2_band_cfg" + }, + { + "name": "watchdog", + "driver": "RFFEWatchdog", + "driver_cfg": "fe_ch2_watchdog" + }, + { + "name": "power", + "driver": "RFPowerMonitor", + "driver_cfg": "fe_ch2_ads7830" + }, + { + "name": "tx", + "driver": "DATXXR5APP", + "driver_cfg": "fe_ch2_gain", + "factory_config": "fact_ch2_tx_gain_cfg" + }, + { + "name": "rx", + "driver": "DATXXR5APP", + "driver_cfg": "fe_ch2_lna", + "factory_config": "fact_ch2_rx_gain_cfg" + } + ], + "commands": [ + { + "name": "enable", + "cb_cmd": "RFFE_enablePA" + }, + { + "name": "disable", + "cb_cmd": "RFFE_disablePA" + } + ] + } + ], + "ssHookSet": { + "preInitFxn": "rffe_pre_init", + "postInitFxn": "rffe_post_init" + } + }, + { + "name": "sync", + "driver_cfg": "sync_gpiocfg", + "ssHookSet": { + "preInitFxn": "SYNC_Init", + "postInitFxn": "NULL" + }, + "components": [ + { + "name": "comp_all", + "driver_cfg": "sync_gpiocfg", + "commands": [ + { + "name": "reset", + "cb_cmd": "SYNC_reset" + } + ], + "postDisabled": "POST_DISABLED" + }, + { + "name": "gps", + "driver_cfg": "sync_gpiocfg", + "driver": "Sync_IO" + }, + { + "name": "sensor", + "components": [ + { + "name": "temp_sensor1", + "driver": "ADT7481", + "driver_cfg": "sync_gps_ts", + "factory_config": "fact_sync_ts_cfg" + } + ] + } + ] + }, + { + "name": "testmodule", + "components": [ + { + "name": "comp_all", + "commands": [ + { + "name": "reset", + "cb_cmd": "TestMod_cmdReset" + } + ], + "postDisabled": "POST_DISABLED" + }, + { + "name": "2gsim", + "driver": "Testmod_G510", + "driver_cfg": "testModuleCfg" + } + ] + }, + { + "name": "debug", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "I2C", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "bus0", + "driver": "OC_I2C", + "driver_cfg": "debug_I2C0", + "postDisabled": "POST_DISABLED" + }, + { + "name": "bus1", + "driver": "OC_I2C", + "driver_cfg": "debug_I2C1", + "postDisabled": "POST_DISABLED" + }, + { + "name": "bus2", + "driver": "OC_I2C", + "driver_cfg": "debug_I2C2", + "postDisabled": "POST_DISABLED" + }, + { + "name": "bus3", + "driver": "OC_I2C", + "driver_cfg": "debug_I2C3", + "postDisabled": "POST_DISABLED" + }, + { + "name": "bus4", + "driver": "OC_I2C", + "driver_cfg": "debug_I2C4", + "postDisabled": "POST_DISABLED" + }, + { + "name": "bus6", + "driver": "OC_I2C", + "driver_cfg": "debug_I2C6", + "postDisabled": "POST_DISABLED" + }, + { + "name": "bus7", + "driver": "OC_I2C", + "driver_cfg": "debug_I2C7", + "postDisabled": "POST_DISABLED" + }, + { + "name": "bus8", + "driver": "OC_I2C", + "driver_cfg": "debug_I2C8", + "postDisabled": "POST_DISABLED" + } + ] + }, + { + "name": "ec", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PA", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pa", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PB", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pb", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PC", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pc", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PD", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pd", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PE", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pe", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PF", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pf", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PG", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pg", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PH", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_ph", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PJ", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pj", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PK", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pk", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PL", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pl", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PM", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pm", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PN", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pn", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PP", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pn", + "postDisabled": "POST_DISABLED" + }, + { + "name": "PQ", + "driver": "OC_GPIO", + "driver_cfg": "debug_ec_gpio_pq", + "postDisabled": "POST_DISABLED" + } + ] + }, + { + "name": "gbc", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "ioexpanderx70", + "driver": "OC_GPIO", + "driver_cfg": "debug_gbc_ioexpanderx70" + }, + { + "name": "ioexpanderx71", + "driver": "OC_GPIO", + "driver_cfg": "debug_gbc_ioexpanderx71" + } + ] + }, + { + "name": "sdr", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "ioexpanderx1E", + "driver": "OC_GPIO", + "driver_cfg": "debug_sdr_ioexpanderx1E" + } + ] + }, + { + "name": "fe", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "ioexpanderx18", + "driver": "OC_GPIO", + "driver_cfg": "debug_sdr_ioexpanderx1E" + }, + { + "name": "ioexpanderx1C", + "driver": "OC_GPIO", + "driver_cfg": "debug_fe_ioexpanderx1C" + }, + { + "name": "ioexpanderx1B", + "driver": "OC_GPIO", + "driver_cfg": "debug_fe_ioexpanderx1B" + }, + { + "name": "ioexpanderx1A", + "driver": "OC_GPIO", + "driver_cfg": "debug_fe_ioexpanderx1A" + }, + { + "name": "ioexpanderx1D", + "driver": "OC_GPIO", + "driver_cfg": "debug_fe_ioexpanderx1D" + } + ] + }, + { + "name": "sync", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "ioexpanderx71", + "driver": "OC_GPIO", + "driver_cfg": "debug_sync_ioexpanderx71" + } + ] + }, + { + "name": "ethernet", + "components": [ + { + "name": "comp_all", + "postDisabled": "POST_DISABLED" + }, + { + "name": "port0", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_phyport0", + "postDisabled": "POST_DISABLED" + }, + { + "name": "port1", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_phyport1", + "postDisabled": "POST_DISABLED" + }, + { + "name": "port2", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_phyport2", + "postDisabled": "POST_DISABLED" + }, + { + "name": "port3", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_phyport3", + "postDisabled": "POST_DISABLED" + }, + { + "name": "port4", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_phyport4", + "postDisabled": "POST_DISABLED" + }, + { + "name": "global1", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_global1", + "postDisabled": "POST_DISABLED" + }, + { + "name": "global2", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_global2", + "postDisabled": "POST_DISABLED" + }, + { + "name": "swport0", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_swport0", + "postDisabled": "POST_DISABLED" + }, + { + "name": "swport1", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_swport1", + "postDisabled": "POST_DISABLED" + }, + { + "name": "swport2", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_swport2", + "postDisabled": "POST_DISABLED" + }, + { + "name": "swport3", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_swport3", + "postDisabled": "POST_DISABLED" + }, + { + "name": "swport4", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_swport4", + "postDisabled": "POST_DISABLED" + }, + { + "name": "swport5", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_swport5", + "postDisabled": "POST_DISABLED" + }, + { + "name": "swport6", + "driver": "OC_MDIO", + "driver_cfg": "debug_mdio_swport6", + "postDisabled": "POST_DISABLED" + } + ] + } + ] + } +] \ No newline at end of file diff --git a/firmware/host/Makefile b/firmware/host/Makefile index ef8970334a..ae77177328 100644 --- a/firmware/host/Makefile +++ b/firmware/host/Makefile @@ -15,11 +15,14 @@ default: @mkdir -p $(output_dir) make all -all: get_cfg ocmw_uart ocmw_usb ocmw_eth occli ocmw_eth_stub ocware_stub hash +all: get_cfg gen_schema ocmw_uart ocmw_usb ocmw_eth occli ocmw_eth_stub ocware_stub hash get_cfg: cd ../utilities/build; ./envDetect.sh +gen_schema: + cd ../utilities/schema; ./mk_schema.sh + hash: cd ../utilities/checksums; ./hashes.sh $(shell pwd)/$(output_dir) -host diff --git a/firmware/utilities/schema/meta_sys_schema_d0.json b/firmware/utilities/schema/meta_sys_schema_d0.json new file mode 100644 index 0000000000..9ced323de1 --- /dev/null +++ b/firmware/utilities/schema/meta_sys_schema_d0.json @@ -0,0 +1,4 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description" : "General purpose JSON validator" +} diff --git a/firmware/utilities/schema/meta_sys_schema_d4.json b/firmware/utilities/schema/meta_sys_schema_d4.json new file mode 100644 index 0000000000..e44319aba4 --- /dev/null +++ b/firmware/utilities/schema/meta_sys_schema_d4.json @@ -0,0 +1,99 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title" : "OC-SDR schema", + "description" : "OC-SDR system specification", + "type": "array", + "items": { + "$ref": "#/definitions/Subsystem" + }, + "definitions": { + "Subsystem": { + "title": "Subsystem", + "type": "object", + "properties": { + "name": {"type": "string"}, + "components": { + "type": "array", + "items": { + "$ref": "#/definitions/Component" + } + }, + "driver_cfg": {"type": "string"}, + "ssHookSet" : { + "type" : "object", + "items" : { + "$ref": "#/definitions/SsHookSet" + } + } + }, + "required": ["name", "components"], + "additionalProperties" : false + }, + "Component": { + "title" : "Component", + "type": "object", + "properties": { + "name": {"type": "string"}, + "components": { + "type": "array", + "items": { + "$ref": "#/definitions/Subcomponent" + } + }, + "driver": {"type": "string"}, + "driver_cfg": {"type": "string"}, + "factory_config": {"type": "string"}, + "commands": { + "type": "array", + "items": { + "$ref": "#/definitions/Command" + } + }, + "ssHookSet" : { + "type" : "object", + "items" : { + "$ref": "#/definitions/SsHookSet" + } + }, + "postDisabled": {"type" : "string"}, + "ss" : {"type" : "string"} + }, + "required": ["name"], + "additionalProperties" : false + }, + "Subcomponent" : { + "title" : "Subcomponent", + "type" : "object", + "properties": { + "name" : {"type" : "string"}, + "driver" : {"type" : "string"}, + "driver_cfg" : {"type" : "string"}, + "postDisabled" : {"type" : "string"}, + "factory_config" : {"type" : "string"} + }, + "required" : ["name"], + "additionalProperties" : false + }, + "Command" : { + "title" : "Command", + "type" : "object", + "properties" : { + "name": {"type" : "string"}, + "parameters" : {"type" : "string"}, + "cb_cmd" : {"type" : "string"} + }, + "required" : ["name"], + "additionalProperties" : false + }, + "SsHookSet" : { + "title" : "SSHookSet", + "type" : "object", + "properties" : { + "preInitFxn": {"type" : "string"}, + "postInitFxn" : {"type" : "string"} + }, + "required" : ["preInitFxn", "postInitFxn"], + "additionalProperties" : false + } + } +} \ No newline at end of file diff --git a/firmware/utilities/schema/meta_sys_schema_d6.json b/firmware/utilities/schema/meta_sys_schema_d6.json new file mode 100644 index 0000000000..d9e4fae58b --- /dev/null +++ b/firmware/utilities/schema/meta_sys_schema_d6.json @@ -0,0 +1,94 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "title" : "OC-SDR schema", + "description" : "OC-SDR system specification", + "type": "array", + "items": { + "$ref": "#/definitions/Subsystem" + }, + "definitions": { + "Subsystem": { + "title": "Subsystem", + "type": "object", + "properties": { + "name": {"type": "string"}, + "components": { + "type": "array", + "items": { + "$ref": "#/definitions/Component" + } + }, + "driver_cfg": {"type": "string"}, + "ssHookSet" : { + "type" : "object", + "items" : { + "$ref": "#/definitions/SsHookSet" + } + } + }, + "required": ["name", "components"] + }, + "Component": { + "title" : "Component", + "type": "object", + "properties": { + "name": {"type": "string"}, + "components": { + "type": "array", + "items": { + "$ref": "#/definitions/Subcomponent" + } + }, + "driver": {"type": "string"}, + "driver_cfg": {"type": "string"}, + "factory_config": {"type": "string"}, + "commands": { + "type": "array", + "items": { + "$ref": "#/definitions/Command" + } + }, + "ssHookSet" : { + "type" : "object", + "items" : { + "$ref": "#/definitions/SsHookSet" + } + }, + "postDisabled": {"type" : "string"}, + "ss" : {"type" : "string"} + }, + "required": ["name"] + }, + "Subcomponent" : { + "title" : "Subcomponent", + "type" : "object", + "properties": { + "name" : {"type" : "string"}, + "driver" : {"type" : "string"}, + "driver_cfg" : {"type" : "string"}, + "postDisabled" : {"type" : "string"}, + "factory_config" : {"type" : "string"} + }, + "required" : ["name"] + }, + "Command" : { + "title" : "Command", + "type" : "object", + "properties" : { + "name": {"type" : "string"}, + "parameters" : {"type" : "string"}, + "cb_cmd" : {"type" : "string"} + }, + "required" : ["name"] + }, + "SsHookSet" : { + "title" : "SSHookSet", + "type" : "object", + "properties" : { + "preInitFxn": {"type" : "string"}, + "postInitFxn" : {"type" : "string"} + }, + "required" : ["preInitFxn", "postInitFxn"] + } + } +} diff --git a/firmware/utilities/schema/mk_schema.sh b/firmware/utilities/schema/mk_schema.sh new file mode 100755 index 0000000000..0497fcc33e --- /dev/null +++ b/firmware/utilities/schema/mk_schema.sh @@ -0,0 +1,48 @@ +#!/bin/sh -e +# +# Description +# The purpose of this script is to automatically generate +# the schema C-file when it is deemed necessary. +# +# Notes +# 1. To force an update, touch sys_schema.json +# 2. See usage notes in sdtester.py +# +# Usage +# Error check +# Exit if JSON schema source file does not exist +# Run sdtester.py when (in order of precedence): +# 1. Auto schema C-file does not exist +# 2. JSON validation schema file does not exist +# 3. JSON schema source file has been updated +# Else do nothing +# +VAL_FNAME=valid_schema.json +SCHEMAPATH=../../ec/platform/oc-sdr/schema +JSON_FNAME=sys_schema.json +C_FNAME=auto_schema.c +INPUT_FNAME=$SCHEMAPATH/$JSON_FNAME +OUTPUT_FNAME=$SCHEMAPATH/$C_FNAME + +gen_schema() +{ + python3 sdtester.py -j $INPUT_FNAME -c $OUTPUT_FNAME +} + +if [ ! -e $INPUT_FNAME ]; then + echo "ERROR: $JSON_FNAME does not exist" 1>&2 + exit 1 +fi + +if [ ! -e $OUTPUT_FNAME ]; then + echo "Generating $C_FNAME because it does not exist" + gen_schema +elif [ ! -e $VAL_FNAME ]; then + echo "Generating $C_FNAME because validation file does not exist" + gen_schema +elif [ $INPUT_FNAME -nt $VAL_FNAME ] || [ $INPUT_FNAME -nt $OUTPUT_FNAME ]; then + echo "Generating $C_FNAME because $JSON_FNAME has been updated" + gen_schema +else + echo "$C_FNAME does not need an update" +fi diff --git a/firmware/utilities/schema/schemautils.py b/firmware/utilities/schema/schemautils.py new file mode 100644 index 0000000000..558471d4db --- /dev/null +++ b/firmware/utilities/schema/schemautils.py @@ -0,0 +1,428 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2018-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. +# + +import re +import json +import jsonschema as js + + +class SchemaUtils: + draftFiles = {'d0' : 'meta_sys_schema_d0.json', + 'd4' : 'meta_sys_schema_d4.json', + 'd6' : 'meta_sys_schema_d6.json'} + + def __init__(self, md, json_fname, c_fname, draft): + """ + Load meta schema and configuration schema + """ + self.draft = draft + self.valid = False + self.json_fname = json_fname + self.c_fname = c_fname + self.sys_schema = '' + self.md = md + # Meta schema: this shouldn't change except when either a new JSON + # draft requires it, or when the hardware is redesigned + self.metaschema = json.load(open(SchemaUtils.draftFiles[draft], 'r')) + + if md != 'g': + # JSON definition file exists and we want to produce the + # corresponding C-file + + # Configuration schema: this can change any time device + # configuration changes + self.cfgschema = json.load(open(self.json_fname, 'r')) + else: + # Want to create JSON definition file from a C-file + # containing a schema declared as a structure + self.cfgschema = [] + + def generate(self): + new_schema = [] + with open(self.c_fname, 'r') as f: + in_schema = False + # Find start of schema declaration and extract + for line in f: + # find start of schema declaration + if (not in_schema) and ('sys_schema' in line): + in_schema = True + # Skip first line + new_schema.append('[\n') + continue + if in_schema: + new_schema.append(line) + schema = ''.join(str(line) for line in new_schema) + + # Remove all C language features + schema = SchemaUtils.stripC(schema) + # Find terminations to array declarations + schema = SchemaUtils.fixarray(schema) + # JSON line formatting + schema = SchemaUtils.parse(schema, 4) + # JSON punctuation + self.sys_schema = SchemaUtils.punct(schema) + + def auto_file(self): + """ + Write C-file from validated schema + """ + # Remove all JSON format features + schema, decls = SchemaUtils.strip(self.sys_schema) + # Format values as required for each data type + schema = SchemaUtils.typeformat(schema) + # Write C-file + SchemaUtils.writeSchema(decls, schema, self.c_fname) + + def dump(self): + """ + Save the validated schema + """ + if self.md != 'g': + # convert the data dictionary to a string + if self.valid: + self.sys_schema = json.dumps(self.cfgschema, indent=4) + # + v_fname = 'valid_schema.json' + msg = 'Saved validated schema to ' + v_fname + else: + v_fname = self.json_fname + msg = 'Saved auto generated schema to ' + v_fname + + with open(v_fname, 'w') as f: + f.write(self.sys_schema) + f.close() + print(msg) + + def validate(self): + """ + Check for errors in either instance or schema + """ + # Sample errors: + # self.metaschema['definitions']['Subcomponent']['required'] = [] + # self.cfgschema[0]['name'] = [] + try: + try: + if (self.draft == 'd4') or (self.draft == 'd0'): + js.Draft4Validator.check_schema(self.metaschema) + else: + # not supported until jsonschema 3.0 + js.Draft6Validator.check_schema(self.metaschema) + print('Meta-schema OK') + except js.SchemaError as e: + print('Error in meta-schema:' + str(e)) + except Exception(): + raise + + try: + js.validate(self.cfgschema, self.metaschema) + print('Configuration schema validated') + except js.ValidationError as e: + print('Error in schema configuration:' + str(e)) + except Exception(): + raise + except Exception() as e: + print(e) + self.valid = False + else: + self.valid = True + return self.valid + + @staticmethod + def declares(text): + """ + Select fields for which either a declaration or a prototype is necessary + """ + setA = set() + setC = set() + setP = set() + for line in text.split('\n'): + words = line.split() + if 'driver_cfg' in line: + setA.add(words[-1]) + if 'factory_config' in line: + setC.add(words[-1]) + if 'null' not in line.lower(): + if 'preInitFxn' in line: + setP.add(words[-1]) + if 'postInitFxn' in line: + setP.add(words[-1]) + if 'cb_cmd' in line: + setP.add(words[-1]) + + qual1 = 'SCHEMA_IMPORT DriverStruct ' + lines1 = [qual1 + value + ';' for value in iter(setA)] + lines1.sort() + str1 = '\n'.join(str(line) for line in lines1) + + qual2 = 'SCHEMA_IMPORT const DriverStruct ' + lines2 = [qual2 + value + ';' for value in iter(setC)] + lines2.sort() + str2 = '\n'.join(str(line) for line in lines2) + + qual3 = 'SCHEMA_IMPORT bool ' + qual4 = '(void *, void *)' + lines3 = [qual3 + value + qual4 + ';' for value in iter(setP)] + lines3.sort(key=str.lower) + str3 = '\n'.join(str(line) for line in lines3) + + decls = str1 + '\n\n' + str2 + '\n\n' + str3 + '\n\n' + return decls + + @staticmethod + def strip(text): + """ + Remove JSON format features + """ + # Find and remove all double quotes + p = re.compile(r'\"') + result = p.sub('', text) + + # Find and replace all colons + result = re.sub(r':', ' =', result) + + # Find and replace all commas + result = re.sub(r',', '', result) + + # Find values for which a declaration is required + decls = SchemaUtils.declares(result) + + # Format structure elements + result = re.sub(r'name', '.name', result) + result = re.sub(r'components', '.components', result) + result = re.sub(r'\bdriver\b', '.driver', result) + result = re.sub(r'\bdriver_cfg\b', '.driver_cfg', result) + result = re.sub(r'factory_config', '.factory_config', result) + result = re.sub(r'commands', '.commands', result) + result = re.sub(r'ssHookSet', '.ssHookSet', result) + result = re.sub(r'postDisabled', '.postDisabled', result) + result = re.sub(r'cb_cmd', '.cb_cmd', result) + result = re.sub(r'preInitFxn', '.preInitFxn', result) + result = re.sub(r'postInitFxn', '.postInitFxn', result) + return result, decls + + @staticmethod + def typeformat(text): + """ + Format each element type as required + """ + newschema = [] + for line in text.split('\n'): + words = line.split() + if '.name' in line: + newline = line.replace(words[-1], '"' + words[-1] + '"') + elif '.driver' in line: + newline = line.replace(words[-1], '&' + words[-1]) + elif '.factory_config' in line: + newline = line.replace(words[-1], '&' + words[-1]) + elif '.components' in line: + newline = line.replace('[', '(Component[]) {') + elif '.commands' in line: + newline = line.replace('[', '(Command[]) {') + elif '.ssHookSet' in line: + newline = line.replace('{', '&(SSHookSet) {') + elif '.preInitFxn' in line and 'NULL' not in line: + newline = line.replace(words[-1], '(ssHook_Cb)' + words[-1]) + elif '.postInitFxn' in line and 'NULL' not in line: + newline = line.replace(words[-1], '(ssHook_Cb)' + words[-1]) + elif ']' in line: + n = line.find(']') + 4 + newschema.append(' ' * n + '{}') + newline = line.replace(']', '}') + else: + newline = line + + if '{' in newline: + newschema.append(newline) + else: + newschema.append(newline + ',') + + # Set first line correctly + newschema[0] = 'const Component sys_schema[] = {' + # Set last line correctly + newschema[-1] = '};' + + return '\n'.join(str(line) for line in newschema) + + @staticmethod + def writeSchema(decls, schema, c_fname): + """ + Save schema to .c file + """ + f = open(c_fname, 'w') + cpw = [] + cpw.append('/**') + cpw.append('* Copyright (c) 2018-present, Facebook, Inc.') + cpw.append('* All rights reserved.') + cpw.append('*') + cpw.append('* This source code is licensed under the BSD-style license') + cpw.append('* found in the LICENSE file in the root directory of this') + cpw.append('* source tree. An additional grant of patent rights can be') + cpw.append('* found in the PATENTS file in the same directory.') + cpw.append('*') + cpw.append('* WARNING: Do not modify this file by hand. It is auto') + cpw.append('* generated from the json schema definition.') + cpw.append('* Refer to sdtester.py') + cpw.append('*/\n') + cpw.append('#include "auto_schema.h"\n\n') + f.write('\n'.join(line for line in cpw)) + f.write(decls) + f.write('\n') + f.write(schema) + f.write('\n') + f.close() + print('Saved schema to ' + c_fname) + + @staticmethod + def stripC(text): + """ + Using regular expressions, strip schema struct from + C-languange features + """ + # Find and remove C-style comments, single line and multiline + p = re.compile(r'/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/') + result = p.sub('', text) + # Find and remove all dots + result = re.sub(r'\.', '', result) + # Find and remove all double quotes + result = re.sub(r'\"', '', result) + # Find and remove all commas + result = re.sub(r',', '', result) + # Find and replace all = + result = re.sub(r'=', ' : ', result) + # Find and remove all ampersands + result = re.sub(r'&', '', result) + # Find and remove all {} + result = re.sub(r'{}', '', result) + # Find and remove all semicolons + result = re.sub(r';', '', result) + # Find and remove all empty lines + result = re.sub(r'\n\s*\n', '\n', result) + # Find and remove all array declarations + p = re.compile(r'\(\w*\[\]\)\s?\{') + result = p.sub('[', result) + # Find and remove all type casts + p = re.compile(r'\(\w*\)') + result = p.sub('', result) + # + return result + + @staticmethod + def fixarray(text): + """ + Use a stack to find where array declarations should end + """ + opers = [] + schema = [] + for line in text.split('\n'): + modline = line + if '{' in line: + opers.append('{') + if '[' in line: + opers.append('[') + if '}' in line: + if opers.pop() == '[': + modline = line.replace('}', ']') + schema.append(modline) + + return '\n'.join(str(line) for line in schema) + + @staticmethod + def parse(text, ident): + """ + Apply indentation levels by parsing through schema + """ + tab = ident * ' ' + depth = 0 + schema = [] + for line in text.split('\n'): + indent, depth = SchemaUtils.stack(line, depth) + modline = SchemaUtils.fields(line) + newline = indent * tab + modline + schema.append(newline) + + return '\n'.join(str(line) for line in schema) + + @staticmethod + def punct(text): + """ + JSON punctuation + """ + schema = [] + lines = text.split('\n') + n = len(lines) - 1 + for i in range(n): + # No comma in starting bracket or brace + if ('{' in lines[i]) or ('[' in lines[i]): + modline = lines[i] + # Comma in objects, except last in a group + elif (':' in lines[i]) and ('}' not in lines[i + 1]): + modline = lines[i] + ',' + # No comma in a last array member + elif ('}' in lines[i]) and \ + (('}' in lines[i + 1]) or (']' in lines[i + 1])): + modline = lines[i] + # Comma after object member of an array + # Comma after array member of an object + elif (('}' in lines[i]) or (']' in lines[i])) and \ + (('{' in lines[i + 1]) or ('[' in lines[i + 1]) or + (':' in lines[i + 1])): + modline = lines[i] + ',' + else: + modline = lines[i] + schema.append(modline) + schema.append(lines[-1]) + return '\n'.join(str(line) for line in schema) + + @staticmethod + def stack(line, depth): + """ + Compute indentation level + """ + if ('{' in line) or ('[' in line): + indent = depth + depth += 1 + elif ('}' in line) or (']' in line): + depth -= 1 + indent = depth + else: + depth = depth + indent = depth + return indent, depth + + @staticmethod + def fields(line): + """ + Apply JSON formatting to the keys and values + """ + modline = '' + for word in line.split(): + modline = modline + SchemaUtils.compose(word) + return modline + + @staticmethod + def compose(word): + """ + Correct use of quotes and spaces + """ + if SchemaUtils.wordOK(word): + newword = '"' + word + '"' + elif word == ':': + newword = ' : ' + else: + newword = word + return newword + + @staticmethod + def wordOK(word): + """ + Check for non-words + """ + return word != '{' and word != '}' and \ + word != '[' and word != ']' and word != ':' diff --git a/firmware/utilities/schema/sdtester.py b/firmware/utilities/schema/sdtester.py new file mode 100644 index 0000000000..f6460bfab5 --- /dev/null +++ b/firmware/utilities/schema/sdtester.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2018-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +""" + + Structured Data Tester + + This module runs the schema utilities. Two use cases are supported: + 1. Given a JSON schema declaration, validate and generate the C-files + 2. Given a C-file with a schema declaration, generate the JSON schema + + Example 1: + Check the JSON schema declaration and generate the C-file + required by the firmware and middleware + $ python3 sdtester.py -j ../../ec/platform/oc-sdr/schema/sys_schema.json -c ../../ec/platform/oc-sdr/schema/auto_schema.c -d d4 + + Example 2: + Same as previous example but with all defaults + $ python3 sdtester.py + + Example 3: + Generate the JSON schema from a given C-file + $ python3 sdtester.py -g -c ../../ec/platform/oc-sdr/schema/schema.c -j ../../ec/platform/oc-sdr/schema/sys_schema.json + + Example 4: + Same as previous example but with all defaults + $ python3 sdtester.py -g + + Example 5: + Check that any arbitrary JSON schema declaration generates a C-file. + Use d0 validation for development purposes + $ python3 sdtester.py -j test_schema.json -c test_schema.c -d d0 + +""" + +import sys +import os +import schemautils as sc +import argparse + + +def useCases(md, json_fname, c_fname, draft): + # Error check + if not os.path.isfile(json_fname) and md != 'g': + print('Missing source JSON file\n') + sys.exit() + elif not os.path.isfile(c_fname) and md == 'g': + print('Missing source C-file\n') + sys.exit() + + if md != 'g': + schema = sc.SchemaUtils('', json_fname, c_fname, draft) + # Validate schema + if not schema.validate(): + sys.exit() + # Write the valid schema to disk + schema.dump() + # Generate auto_schema.c + schema.auto_file() + else: + schema = sc.SchemaUtils('g', json_fname, c_fname, draft) + schema.generate() + schema.dump() + + +def main(args): + if args.generate: + useCases('g', args.json_fname, args.c_fname, args.draft) + else: + useCases('', args.json_fname, args.c_fname, args.draft) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + # JSON Source file + parser.add_argument( + '-j', + dest='json_fname', + action='store', + default='../../ec/platform/oc-sdr/schema/sys_schema.json', + type=str, + help='JSON file where configuration schema is declared', + ) + # C-file name + parser.add_argument( + '-c', + dest='c_fname', + action='store', + default='../../ec/platform/oc-sdr/schema/auto_schema.c', + type=str, + help='Name of C-file to be read from or written to', + ) + # Draft version + parser.add_argument( + '-d', + dest='draft', + action='store', + default='d4', + type=str, + help='JSON draft version, e.g. \'d4\' or \'d6\' for build; \'d0\' for general purpose', + ) + # Schema source C-file to convert into JSON schema + parser.add_argument( + '-g', + dest='generate', + action='store_true', + help='If specified, generates JSON schema from C-file', + ) + + main(parser.parse_args())