From 0a4b4cf5efa760c878b31422389443c5955b8751 Mon Sep 17 00:00:00 2001 From: Achala Ram Date: Thu, 21 Dec 2023 14:52:38 +0530 Subject: [PATCH 1/2] am64x/am243x: SDFM: add syscfg module Fixes: PINDSW-7102 Signed-off-by: Achala Ram --- source/.meta/current_sense/sdfm.syscfg.js | 132 +++++++++++++ source/.meta/current_sense/sdfm_pins.js | 175 ++++++++++++++++++ .../templates/sdfm_template.h.xdt | 41 ++++ .../.meta/soc/motor_control_am243x.syscfg.js | 1 + 4 files changed, 349 insertions(+) create mode 100644 source/.meta/current_sense/sdfm.syscfg.js create mode 100644 source/.meta/current_sense/sdfm_pins.js create mode 100644 source/.meta/current_sense/templates/sdfm_template.h.xdt diff --git a/source/.meta/current_sense/sdfm.syscfg.js b/source/.meta/current_sense/sdfm.syscfg.js new file mode 100644 index 0000000..81eece1 --- /dev/null +++ b/source/.meta/current_sense/sdfm.syscfg.js @@ -0,0 +1,132 @@ +let common = system.getScript("/common"); +let sdfm_pins = system.getScript("/current_sense/sdfm_pins.js"); +let device = common.getDeviceName(); +let is_am243x_lp_device = (device === "am243x-lp") ? true : false; + +let sdfm_module_name = "/current_sense/sdfm"; + +/*function onValidate(inst, validation) { + for (let instance_index in inst.$module.$instances) + { + let instance = inst.$module.$instances[instance_index]; + //if ((!instance.channel_0)&&(!instance.channel_1)&&(!instance.channel_2)&&(!instance.channel_3)&&(!instance.channel_4)&&(!instance.channel_5)&&(!instance.channel_6)&&(!instance.channel_7)&&(!instance.channel_8)) + // validation.logError("Select atleast one channel",inst,"channel_0" + //) + } +}*/ + +let sdfm_module = { + displayName: "SDFM", + templates: { + "/drivers/system/system_config.h.xdt": { + driver_config:"/.meta/current_sense/templates/sdfm_template.h.xdt", + moduleName: sdfm_module_name, + }, + "/drivers/pinmux/pinmux_config.c.xdt": { + moduleName: sdfm_module_name, + }, + }, + defaultInstanceName: "CONFIG_SDFM", + config: [ + { + name: "instance", + displayName: "Instance", + default: "ICSSG0", + options: [ + { + name: "ICSSG0", + }, + { + name: "ICSSG1", + } + ], + }, + { + name: "Channel_0", + displayName: "Enable Channel 0", + description: "Channel 0 Selection", + default: true, + }, + { + name: "Channel_1", + displayName: "Enable Channel 1", + description: "Channel 1 Selection ", + default: true, + }, + { + name: "Channel_2", + displayName: "Enable Channel 2", + description: "Channel 2 Selection ", + default: true, + }, + + { + name: "Channel_3", + displayName: "Enable Channel 3", + description: "Channel 3 Selection", + default: false, + }, + { + name: "Channel_4", + displayName: "Enable Channel 4", + description: "Channel 4 Selection ", + default: false, + }, + { + name: "Channel_5", + displayName: "Enable Channel 5", + description: "Channel 5 Selection ", + default: false, + }, + { + name: "Channel_6", + displayName: "Enable Channel 6", + description: "Channel 6 Selection", + default: false, + }, + { + name: "Channel_7", + displayName: "Enable Channel 7", + description: "Channel 7 Selection ", + default: false, + }, + { + name: "Channel_8", + displayName: "Enable Channel 8", + description: "Channel 8 Selection ", + default: false, + }, + + ], + moduleStatic: { + modules: function(inst) { + return [{ + name: "system_common", + moduleName: "/system_common", + }] + }, + }, + pinmuxRequirements: sdfm_pins.pinmuxRequirements, + getInterfaceName: sdfm_pins.getInterfaceName, + getPeripheralPinNames: sdfm_pins.getPeripheralPinNames, + sharedModuleInstances: sharedModuleInstances, + /*validate: onValidate,*/ + +}; + +function sharedModuleInstances(instance) { + let modInstances = new Array(); + + modInstances.push({ + name: "pru", + displayName: "PRU ICSS Configuration", + moduleName: '/drivers/pruicss/pruicss', + requiredArgs: { + instance: instance.instance, + + }, + }); + return (modInstances); +} + +exports = sdfm_module; \ No newline at end of file diff --git a/source/.meta/current_sense/sdfm_pins.js b/source/.meta/current_sense/sdfm_pins.js new file mode 100644 index 0000000..395a88d --- /dev/null +++ b/source/.meta/current_sense/sdfm_pins.js @@ -0,0 +1,175 @@ +let common = system.getScript("/common"); +let pinmux = system.getScript("/drivers/pinmux/pinmux"); + + +function getInterfaceName(inst) +{ + return `PRU_${inst.instance}_PRU`; +} + +function getInterfacePinList(inst) +{ + let pinList = []; + + /*SDFM SD8_CLK clock*/ + pinList.push({ pinName: "GPI16", displayName: "SD_CLK8", rx: true}); + + /*SD0_D*/ + pinList.push({ pinName: "GPI1", displayName: "SD_CHANNEL0_DATA", rx: true}); + + /*SD1_D*/ + pinList.push({ pinName: "GPI3", displayName: "SD_CHANNEL1_DATA", rx: true}); + + /*SD2_D*/ + pinList.push({ pinName: "GPI5", displayName: "SD_CHANNEL2_DATA", rx: true}); + + /*SD3_D*/ + pinList.push({ pinName: "GPI7", displayName: "SD_CHANNEL3_DATA", rx: true}); + + /*SD4_D*/ + pinList.push({ pinName: "GPI18", displayName: "SD_CHANNEL4_DATA", rx: true}); + + /*SD5_D*/ + pinList.push({ pinName: "GPI11", displayName: "SD_CHANNEL5_DATA", rx: true}); + + /*SD6_D*/ + pinList.push({ pinName: "GPI13", displayName: "SD_CHANNEL6_DATA", rx: true}); + + /*SD7_D*/ + pinList.push({ pinName: "GPI15", displayName: "SD_CHANNEL7_DATA", rx: true}); + + /*SD8_D*/ + pinList.push({ pinName: "GPI17", displayName: "SD_CHANNEL8_DATA", rx: true}); + + return pinList; +} + +function pinmuxRequirements(inst) { + + let interfaceName = getInterfaceName(inst); + let pinList = getInterfacePinList(inst); + let resources = []; + + for(let pin of pinList) + { + let pinResource = pinmux.getPinRequirements(interfaceName, pin.pinName, pin.displayName); + + pinmux.setConfigurableDefault( pinResource, "rx", pin.rx ); + + if(inst["Channel_0"] == true){ + if((pin.pinName == "GPI1")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI1")){ + pinResource.used = false; + } + } + if(inst["Channel_1"] == true){ + if((pin.pinName == "GPI3")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI3")){ + pinResource.used = false; + } + } + if(inst["Channel_2"]==true){ + if((pin.pinName == "GPI5")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI5")){ + pinResource.used = false; + } + } + if(inst["Channel_3"]==true){ + if((pin.pinName == "GPI7")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI7")){ + pinResource.used = false; + } + } + if(inst["Channel_4"]==true){ + if((pin.pinName == "GPI18")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI18")){ + pinResource.used = false; + } + } + if(inst["Channel_5"]==true){ + if((pin.pinName == "GPI11")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI11")){ + pinResource.used = false; + } + } + if(inst["Channel_6"]==true){ + if((pin.pinName == "GPI13")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI13")){ + pinResource.used = false; + } + } + if(inst["Channel_7"]==true){ + if((pin.pinName == "GPI15")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI15")){ + pinResource.used = false; + } + } + if(inst["Channel_8"]==true){ + if((pin.pinName == "GPI17")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI17")){ + pinResource.used = false; + } + } + + resources.push( pinResource ); + } + + let peripheralRequirements = { + name: interfaceName, + displayName: interfaceName, + interfaceName: interfaceName, + resources: resources, + }; + + return [peripheralRequirements]; +} + +function getPeripheralPinNames(inst) +{ + let pinList = []; + let pinNameList = []; + + pinList = getInterfacePinList(inst); + + for(let pin of pinList) + { + pinNameList.push( pin.pinName ); + } + + return pinNameList; +} + + +exports = { + + pinmuxRequirements, + getInterfaceName, + getPeripheralPinNames, +}; diff --git a/source/.meta/current_sense/templates/sdfm_template.h.xdt b/source/.meta/current_sense/templates/sdfm_template.h.xdt new file mode 100644 index 0000000..17ef358 --- /dev/null +++ b/source/.meta/current_sense/templates/sdfm_template.h.xdt @@ -0,0 +1,41 @@ +%%{ + let module = system.modules[args[0]]; +%%} +/* + * SDFM + */ + +/* SDFM Instance Macros */ +#define CONFIG_SDFM_NUM_INSTANCES `module.$instances.length` +%for(let i = 0; i < module.$instances.length; i++) { + % let instance = module.$instances[i]; + % let Slice = 0 ; + %if(instance.instance === "ICSSG1") + %{ + % if(instance.PRU_ICSSG1_PRU.$assign === "PRU_ICSSG1_PRU1") + %{ + % Slice = 1; + %} + + %} + %else + %{ + %if(instance.PRU_ICSSG0_PRU.$assign === "PRU_ICSSG0_PRU1") + %{ + % Slice = 1; + %} + + %} + +#define `instance.$name` `i` +#define `instance.$name`_CHANNEL0 `instance.Channel_0 & 1` +#define `instance.$name`_CHANNEL1 `instance.Channel_1 & 1` +#define `instance.$name`_CHANNEL2 `instance.Channel_2 & 1` +#define `instance.$name`_CHANNEL3 `instance.Channel_3 & 1` +#define `instance.$name`_CHANNEL4 `instance.Channel_4 & 1` +#define `instance.$name`_CHANNEL5 `instance.Channel_5 & 1` +#define `instance.$name`_CHANNEL6 `instance.Channel_6 & 1` +#define `instance.$name`_CHANNEL7 `instance.Channel_7 & 1` +#define `instance.$name`_CHANNEL8 `instance.Channel_8 & 1` +#define PRU_ICSSGx_PRU_SLICE `Slice` +% } diff --git a/source/.meta/soc/motor_control_am243x.syscfg.js b/source/.meta/soc/motor_control_am243x.syscfg.js index 77e8ab4..5fc93e0 100644 --- a/source/.meta/soc/motor_control_am243x.syscfg.js +++ b/source/.meta/soc/motor_control_am243x.syscfg.js @@ -6,6 +6,7 @@ const topModules_main = [ "/position_sense/hdsl", "/position_sense/tamagawa", "/position_sense/bissc", + "/current_sense/sdfm", ]; From c4246dd4b937c1a3e454e3e0a9c36f17ba0153e6 Mon Sep 17 00:00:00 2001 From: Achala Ram Date: Thu, 21 Dec 2023 16:13:33 +0530 Subject: [PATCH 2/2] am243x/am64x: PWM: Add syscfg module - Add PWM syscfg module in motor control section Fixes: PINDSW-7102 Signed-off-by: Achala Ram --- source/.meta/current_sense/sdfm.syscfg.js | 11 -- .../templates/sdfm_template.h.xdt | 2 +- source/.meta/pru_icssg/pwm.syscfg.js | 105 ++++++++++++++++++ .../.meta/soc/motor_control_am243x.syscfg.js | 1 + 4 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 source/.meta/pru_icssg/pwm.syscfg.js diff --git a/source/.meta/current_sense/sdfm.syscfg.js b/source/.meta/current_sense/sdfm.syscfg.js index 81eece1..1692931 100644 --- a/source/.meta/current_sense/sdfm.syscfg.js +++ b/source/.meta/current_sense/sdfm.syscfg.js @@ -1,19 +1,9 @@ let common = system.getScript("/common"); let sdfm_pins = system.getScript("/current_sense/sdfm_pins.js"); let device = common.getDeviceName(); -let is_am243x_lp_device = (device === "am243x-lp") ? true : false; let sdfm_module_name = "/current_sense/sdfm"; -/*function onValidate(inst, validation) { - for (let instance_index in inst.$module.$instances) - { - let instance = inst.$module.$instances[instance_index]; - //if ((!instance.channel_0)&&(!instance.channel_1)&&(!instance.channel_2)&&(!instance.channel_3)&&(!instance.channel_4)&&(!instance.channel_5)&&(!instance.channel_6)&&(!instance.channel_7)&&(!instance.channel_8)) - // validation.logError("Select atleast one channel",inst,"channel_0" - //) - } -}*/ let sdfm_module = { displayName: "SDFM", @@ -110,7 +100,6 @@ let sdfm_module = { getInterfaceName: sdfm_pins.getInterfaceName, getPeripheralPinNames: sdfm_pins.getPeripheralPinNames, sharedModuleInstances: sharedModuleInstances, - /*validate: onValidate,*/ }; diff --git a/source/.meta/current_sense/templates/sdfm_template.h.xdt b/source/.meta/current_sense/templates/sdfm_template.h.xdt index 17ef358..b63eeb6 100644 --- a/source/.meta/current_sense/templates/sdfm_template.h.xdt +++ b/source/.meta/current_sense/templates/sdfm_template.h.xdt @@ -37,5 +37,5 @@ #define `instance.$name`_CHANNEL6 `instance.Channel_6 & 1` #define `instance.$name`_CHANNEL7 `instance.Channel_7 & 1` #define `instance.$name`_CHANNEL8 `instance.Channel_8 & 1` -#define PRU_ICSSGx_PRU_SLICE `Slice` +#define `instance.$name`_SLICE `Slice` % } diff --git a/source/.meta/pru_icssg/pwm.syscfg.js b/source/.meta/pru_icssg/pwm.syscfg.js new file mode 100644 index 0000000..970a0ad --- /dev/null +++ b/source/.meta/pru_icssg/pwm.syscfg.js @@ -0,0 +1,105 @@ +let common = system.getScript("/common"); +let pinmux = system.getScript("/drivers/pinmux/pinmux"); + +function getInterfaceName(inst, peripheralName) +{ + return `PRU_${inst.instance}_${peripheralName}`; +} + +function getInterfacePinList(inst, peripheralName) +{ + let interfaceName = getInterfaceName(inst, peripheralName); + let pinList = []; + + pinList = pinmux.getInterfacePinList(interfaceName); + + return pinList; +} + +function getPeripheralRequirements(inst, peripheralName) +{ + let interfaceName = getInterfaceName(inst, peripheralName); + let pinList = getInterfacePinList(inst, peripheralName); + let resources = []; + + for(let pin of pinList) + { + let pinResource = pinmux.getPinRequirements(interfaceName, pin); + + /* make all pins as "rx" and then override to make "rx" as false as needed */ + pinmux.setConfigurableDefault( pinResource, "rx", false ); + + /* Disable all the pins. */ + pinResource.used=false; + + resources.push( pinResource ); + } + + let peripheralRequirements = { + name: interfaceName, + displayName: interfaceName, + interfaceName: interfaceName, + resources: resources, + }; + + return peripheralRequirements; +} + +function pinmuxRequirements(inst) { + + let pwm = getPeripheralRequirements(inst, "PWM"); + return [pwm]; +} + +function getInterfaceNameList(inst) { + + return [ + getInterfaceName(inst, "PWM"), + ]; +} + +function getPeripheralPinNames(inst) +{ + let pinList = []; + + pinList = pinList.concat(getInterfacePinList(inst, "PWM")); + return pinList; +} + +let pruicss_top_module_name = "/pru_icssg/pwm"; + +let pruicss_top_module = { + displayName: "PRU (ICSS) PWM", + + templates: { + "/drivers/pinmux/pinmux_config.c.xdt": { + moduleName: pruicss_top_module_name, + }, + }, + + defaultInstanceName: "CONFIG_PRU_ICSS_PWM", + config: [ + { + name: "instance", + displayName: "Instance", + default: "ICSSG0", + options: [ + { + name: "ICSSG0", + }, + { + name: "ICSSG1", + } + ], + }, + ], + pinmuxRequirements, + getInterfaceNameList, + getPeripheralPinNames, +}; + +function validate(inst, report) { + common.validate.checkSameInstanceName(inst, report); +} + +exports = pruicss_top_module; \ No newline at end of file diff --git a/source/.meta/soc/motor_control_am243x.syscfg.js b/source/.meta/soc/motor_control_am243x.syscfg.js index 5fc93e0..1288d1f 100644 --- a/source/.meta/soc/motor_control_am243x.syscfg.js +++ b/source/.meta/soc/motor_control_am243x.syscfg.js @@ -7,6 +7,7 @@ const topModules_main = [ "/position_sense/tamagawa", "/position_sense/bissc", "/current_sense/sdfm", + "/pru_icssg/pwm", ];