From 0cf54ce07335f60642a14df7e6107422a5aeb9a0 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 14 Nov 2019 13:12:20 -0800 Subject: mpm/mpmd: Expose APIs to drive GPIO sources The N310 has a feature that allows the front panel GPIOs to be driven by various sources: The PS, or any of the radio channels. The MPM-based APIs did not expose any way to change that. Changes: - Add MPM APIs to PeripheralManagerBase and n3xx classes - Improve comments and explanations - Add host-side hooks into these new APIs in mpmd_mb_controller - Implement these APIs for N3xx The N3xx devices will have the option to set the GPIO source to "PS", or to one of "RF0", "RF1", "RF2", "RF3" (if there are four channels; the N300 and N320 can only go up to RF1). Note: The N310 radio does not have separate FP-GPIO banks for channels 0 and 1, which needs to be fixed in a separate commit. --- mpm/python/usrp_mpm/periph_manager/base.py | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'mpm/python/usrp_mpm/periph_manager/base.py') diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index 6d363fd89..8f75a97c6 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -925,3 +925,41 @@ class PeriphManagerBase(object): Gets the RFNoC-related clocks present in the FPGA design """ raise NotImplementedError("get_clocks() not implemented.") + + ####################################################################### + # GPIO API + ####################################################################### + def get_gpio_banks(self): + """ + Returns a list of GPIO banks over which MPM has any control + """ + self.log.debug("get_gpio_banks(): No banks defined on this device.") + return [] + + def get_gpio_srcs(self, bank): + """ + Return a list of valid GPIO sources for a given bank + """ + assert bank in self.get_gpio_banks(), \ + "Invalid GPIO bank: {}".format(bank) + return [] + + def get_gpio_src(self, bank): + """ + Return the currently selected GPIO source for a given bank. The return + value is a list of strings. The length of the vector is identical to + the number of controllable GPIO pins on this bank. + """ + assert bank in self.get_gpio_banks(), \ + "Invalid GPIO bank: {}".format(bank) + raise NotImplementedError("get_gpio_src() not available on this device!") + + def set_gpio_src(self, bank, src): + """ + Set the GPIO source for a given bank. + """ + assert bank in self.get_gpio_banks(), \ + "Invalid GPIO bank: {}".format(bank) + assert src in self.get_gpio_srcs(bank), \ + "Invalid GPIO source: {}".format(src) + raise NotImplementedError("set_gpio_src() not available on this device!") -- cgit v1.2.3