From 0a2c09a658e745849e05896482a25754542cf779 Mon Sep 17 00:00:00 2001 From: vaishnav98 Date: Tue, 18 Aug 2020 17:28:28 +0530 Subject: [PATCH] update manifesto for modified descriptors This commit updates the mikrobus descriptor and the device descriptor as per the changes in the v2 patch for mikrobus driver. --- .../IID1-simple-mikrobus-addon-module.mnfs | 35 ++-- manifesto | 195 +++++++++--------- 2 files changed, 119 insertions(+), 111 deletions(-) diff --git a/examples/IID1-simple-mikrobus-addon-module.mnfs b/examples/IID1-simple-mikrobus-addon-module.mnfs index d89f303..bb15f95 100644 --- a/examples/IID1-simple-mikrobus-addon-module.mnfs +++ b/examples/IID1-simple-mikrobus-addon-module.mnfs @@ -22,19 +22,21 @@ string = MikroElektronika string = ENC28J60 Ethernet Controller ; mikrobus-descriptor describes the setup of -; mikroBUS GPIOs and the number of devices -; present in the add-on board. The GPIO positions -; are relative to the mikrobus and the following -; values can be used to refer to different GPIOs -; on the mikrobus port. -; MIKROBUS_GPIO_INT = 0x01 -; MIKROBUS_GPIO_RST = 0x02 -; MIKROBUS_GPIO_PWM = 0x03 +; mikroBUS Pins and the GPIO states required for +; the add-on board. [mikrobus-descriptor] -num-devices = 1 -int-gpio = 1 -rst-gpio = 2 -pwm-gpio = 0 +pwm-state = 4 +int-state = 1 +rx-state = 7 +tx-state = 7 +scl-state = 6 +sda-state = 6 +mosi-state = 5 +miso-state = 5 +sck-state = 5 +cs-state = 5 +rst-state = 2 +an-state = 1 ; gbphy protocol Bundle 0 [bundle-descriptor 1] @@ -56,19 +58,18 @@ protocol = 0xb ; has the following fields, ; driver-string-id : device driver string id ; protocol : type of bus the device uses , can be -; one of the following: -; MIKROBUS_PROTOCOL_SPI = 0x01 -; MIKROBUS_PROTOCOL_I2C = 0x02 -; MIKROBUS_PROTOCOL_UART = 0x03 +; one of the Greybus CPORT Protocols ; mode : SPI Device Mode +; reg : CS relative to mikrobus port(0-CS,1- GPIO CS on RST) ; irq : IRQ GPIO used by the device ; irq_type : Type of IRQ used by the ; device, same values as described ; in linux/irq.h [device-descriptor 1] driver-string-id = 3 -protocol = 0x1 +protocol = 0xb mode = 0x0 +reg = 0 max-speed-hz = 16000000 irq = 1 irq-type = 0x2 diff --git a/manifesto b/manifesto index 4b7d513..cf0097c 100755 --- a/manifesto +++ b/manifesto @@ -232,19 +232,35 @@ class InterfaceDescriptor(Descriptor): return r class MikrobusDescriptor(Descriptor): - def __init__(self, num_devices, rst_gpio, pwm_gpio, int_gpio, section): + def __init__(self, pwm, _int, rx, tx, scl, sda, mosi, miso, sck, cs, rst, an, section): super(MikrobusDescriptor, self).__init__(section, True) - self.num_devices = num_devices - self.rst_gpio = rst_gpio - self.pwm_gpio = pwm_gpio - self.int_gpio = int_gpio + self.pwm = pwm + self.int = _int + self.rx = rx + self.tx = tx + self.scl = scl + self.sda = sda + self.mosi = mosi + self.miso = miso + self.sck = sck + self.cs = cs + self.rst = rst + self.an = an def __str__(self): r = "[{}]\n".format(MnfsParser.MIKROBUS_DESC) - r += "num-devices = {:#x}\n".format(self.num_devices) - r += "rst-gpio = {:#x}\n".format(self.rst_gpio) - r += "pwm-gpio = {:#x}\n".format(self.pwm_gpio) - r += "int-gpio = {:#x}\n".format(self.int_gpio) + r += "pwm-state = {:#x}\n".format(self.pwm) + r += "int-state = {:#x}\n".format(self.int) + r += "rx-state = {:#x}\n".format(self.rx) + r += "tx-state = {:#x}\n".format(self.tx) + r += "scl-state = {:#x}\n".format(self.scl) + r += "sda-state = {:#x}\n".format(self.sda) + r += "mosi-state = {:#x}\n".format(self.mosi) + r += "miso-state = {:#x}\n".format(self.miso) + r += "sck-state = {:#x}\n".format(self.sck) + r += "cs-state = {:#x}\n".format(self.cs) + r += "rst-state = {:#x}\n".format(self.rst) + r += "an-state = {:#x}\n".format(self.an) return r class StringDescriptor(Descriptor): @@ -430,36 +446,20 @@ class PropertyDescriptor(Descriptor): return r class DeviceDescriptor(Descriptor): - device_protocol = { - 0x01: 'SPI', - 0x02: 'I2C', - 0x03: 'UART', - 0x04: 'SPI_GPIO_CS', - 0x05: 'I2C_MUX' - } + def __init__(self, id_, props, section): super(DeviceDescriptor, self).__init__(section) self.id_ = id_ self.driver_string_id = props[0] - self.num_properties = props[1] - self.protocol = props[2] - self.reg = props[3] - self.cs_gpio = props[4] - self.irq = props[5] - self.irq_type = props[6] - self.max_speed_hz = props[7] - self.mode = props[8] - self.num_gpio_res = props[9] - self.prop_link = props[10] - self.gpio_link = props[11] - - @property - def protocol_name(self): - try: - return self.device_protocol[self.protocol] - except KeyError: - return "Reserved" + self.protocol = props[1] + self.reg = props[2] + self.irq = props[3] + self.irq_type = props[4] + self.max_speed_hz = props[5] + self.mode = props[6] + self.prop_link = props[7] + self.gpio_link = props[8] def __str__(self): r = "; '{}' Protocol on Device {}\n".format(self.protocol_name, self.id_) @@ -486,10 +486,18 @@ class MnfsParser(object): MNFS_HEADER_VMAJ = 'version-major' MNFS_HEADER_VMIN = 'version-minor' MIKROBUS_DESC = 'mikrobus-descriptor' - MNFS_MIKROBUS_NUM_DEVICES = 'num-devices' - MNFS_MIKROBUS_RST_GPIO_STATE = 'rst-gpio' - MNFS_MIKROBUS_PWM_GPIO_STATE = 'pwm-gpio' - MNFS_MIKROBUS_INT_GPIO_STATE = 'int-gpio' + MNFS_MIKROBUS_PWM_STATE = 'pwm-state' + MNFS_MIKROBUS_INT_STATE = 'int-state' + MNFS_MIKROBUS_RX_STATE = 'rx-state' + MNFS_MIKROBUS_TX_STATE = 'tx-state' + MNFS_MIKROBUS_SCL_STATE = 'scl-state' + MNFS_MIKROBUS_SDA_STATE = 'sda-state' + MNFS_MIKROBUS_MOSI_STATE = 'mosi-state' + MNFS_MIKROBUS_MISO_STATE = 'miso-state' + MNFS_MIKROBUS_SCK_STATE = 'sck-state' + MNFS_MIKROBUS_CS_STATE = 'cs-state' + MNFS_MIKROBUS_RST_STATE = 'rst-state' + MNFS_MIKROBUS_AN_STATE = 'an-state' INTERFACE_DESC = 'interface-descriptor' INTERFACE_DESC_VSID = 'vendor-string-id' INTERFACE_DESC_PSID = 'product-string-id' @@ -502,13 +510,10 @@ class MnfsParser(object): CPORT_DESC_PROTOCOL = 'protocol' DEVICE_DESC = 'device-descriptor' DEVICE_DESC_DRIVER_STRING_ID = 'driver-string-id' - DEVICE_DESC_NUM_PROPERTIES = 'num-properties' DEVICE_DESC_MAX_SPEED_HZ = 'max-speed-hz' DEVICE_DESC_MODE = 'mode' - DEVICE_DESC_NUM_GPIO_RESOURCES = 'num-gpio-resources' DEVICE_DESC_PROTOCOL = 'protocol' DEVICE_DESC_REG = 'reg' - DEVICE_DESC_CS_GPIO = 'cs-gpio' DEVICE_DESC_IRQ = 'irq' DEVICE_DESC_IRQ_TYPE = 'irq-type' DEVICE_DESC_PROP_LINK = 'prop-link' @@ -630,19 +635,44 @@ class MnfsParser(object): interface = InterfaceDescriptor(vsid, psid, section) manifest.add_interface_desc(interface) elif section == MnfsParser.MIKROBUS_DESC: - numdevices = self.__get_int_option(cfg_parser, section, - MnfsParser.MNFS_MIKROBUS_NUM_DEVICES, + pwm = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_PWM_STATE, + MnfsParser.ID_DESC_SIZE) + _int = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_INT_STATE, + MnfsParser.ID_DESC_SIZE) + rx = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_RX_STATE, + MnfsParser.ID_DESC_SIZE) + tx = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_TX_STATE, + MnfsParser.ID_DESC_SIZE) + scl = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_SCL_STATE, MnfsParser.ID_DESC_SIZE) - rstgpio = self.__get_int_option(cfg_parser, section, - MnfsParser.MNFS_MIKROBUS_RST_GPIO_STATE, + sda = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_SDA_STATE, MnfsParser.ID_DESC_SIZE) - pwmgpio = self.__get_int_option(cfg_parser, section, - MnfsParser.MNFS_MIKROBUS_PWM_GPIO_STATE, + mosi = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_MOSI_STATE, MnfsParser.ID_DESC_SIZE) - intgpio = self.__get_int_option(cfg_parser, section, - MnfsParser.MNFS_MIKROBUS_INT_GPIO_STATE, + miso = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_MISO_STATE, MnfsParser.ID_DESC_SIZE) - mikrobus = MikrobusDescriptor(numdevices, rstgpio, pwmgpio, intgpio, section) + sck = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_SCK_STATE, + MnfsParser.ID_DESC_SIZE) + cs = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_CS_STATE, + MnfsParser.ID_DESC_SIZE) + rst = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_RST_STATE, + MnfsParser.ID_DESC_SIZE) + an = self.__get_int_option(cfg_parser, section, + MnfsParser.MNFS_MIKROBUS_AN_STATE, + MnfsParser.ID_DESC_SIZE) + mikrobus = MikrobusDescriptor(pwm, _int, rx, tx, scl, \ + sda, mosi, miso, sck, cs, rst, an, section) manifest.add_mikrobus_desc(mikrobus) elif section.split()[0] == MnfsParser.STRING_DESC: @@ -693,13 +723,6 @@ class MnfsParser(object): driverstr = self.__get_int_option(cfg_parser, section, MnfsParser.DEVICE_DESC_DRIVER_STRING_ID, MnfsParser.ID_DESC_SIZE) - if (self.__check_option(cfg_parser, section, - MnfsParser.DEVICE_DESC_NUM_PROPERTIES)): - numprop = self.__get_int_option(cfg_parser, section, - MnfsParser.DEVICE_DESC_NUM_PROPERTIES, - MnfsParser.ID_DESC_SIZE) - else: - numprop = 0 protocol = self.__get_int_option(cfg_parser, section, MnfsParser.DEVICE_DESC_PROTOCOL, MnfsParser.ID_DESC_SIZE) @@ -710,30 +733,12 @@ class MnfsParser(object): mode = self.__get_int_option(cfg_parser, section, MnfsParser.DEVICE_DESC_MODE, MnfsParser.ID_DESC_SIZE) - if (self.__check_option(cfg_parser, section, - MnfsParser.DEVICE_DESC_CS_GPIO)): - csgpio = self.__get_int_option(cfg_parser, section, - MnfsParser.DEVICE_DESC_CS_GPIO, - MnfsParser.ID_DESC_SIZE) - else: - csgpio = 0 else: maxspeedhz=0 - csgpio=0 mode=0 - if (self.__check_option(cfg_parser, section, - MnfsParser.DEVICE_DESC_NUM_GPIO_RESOURCES)): - numgpio = self.__get_int_option(cfg_parser, section, - MnfsParser.DEVICE_DESC_NUM_GPIO_RESOURCES, - MnfsParser.ID_DESC_SIZE) - else: - numgpio = 0 - if(protocol == 2 or protocol == 5): - reg = self.__get_int_option(cfg_parser, section, - MnfsParser.DEVICE_DESC_REG, - MnfsParser.ID_DESC_SIZE) - else: - reg = 0 + reg = self.__get_int_option(cfg_parser, section, + MnfsParser.DEVICE_DESC_REG, + MnfsParser.ID_DESC_SIZE) if (self.__check_option(cfg_parser, section, MnfsParser.DEVICE_DESC_IRQ)): irq = self.__get_int_option(cfg_parser, section, @@ -753,14 +758,14 @@ class MnfsParser(object): else: prop_link = 0 if (self.__check_option(cfg_parser, section, - MnfsParser.DEVICE_DESC_PROP_LINK)): + MnfsParser.DEVICE_DESC_GPIO_LINK)): gpio_link = self.__get_int_option(cfg_parser, section, MnfsParser.DEVICE_DESC_GPIO_LINK, MnfsParser.ID_DESC_SIZE) else: gpio_link = 0 - props = [driverstr, numprop, protocol, reg, csgpio, irq, irq_type, \ - maxspeedhz, mode, numgpio, prop_link, gpio_link] + props = [driverstr, protocol, reg, irq, irq_type, \ + maxspeedhz, mode, prop_link, gpio_link] device = DeviceDescriptor(id_, props, section) manifest.add_device_desc(device) else: @@ -791,7 +796,7 @@ class MnfbGenerator(object): DEVICE_DESC_SIZE = BASE_DESC_SIZE + 0x10 PROP_DESC_BASE_SIZE = BASE_DESC_SIZE + 0x4 INTERFACE_DESC_SIZE = BASE_DESC_SIZE + 0x4 - MIKROBUS_DESC_SIZE = BASE_DESC_SIZE + 0x4 + MIKROBUS_DESC_SIZE = BASE_DESC_SIZE + 0xC STRING_DESC_BASE_SIZE = BASE_DESC_SIZE + 0x2 BUNDLE_DESC_SIZE = BASE_DESC_SIZE + 0x4 CPORT_DESC_SIZE = BASE_DESC_SIZE + 0x4 @@ -803,18 +808,19 @@ class MnfbGenerator(object): 0x00: 1, 0x01: 1, 0x02: 1, - 0x03: 2, - 0x04: 4, - 0x05: 8 + 0x03: 1, + 0x04: 2, + 0x05: 4, + 0x06: 8 } # formatting MNFS_HEADER_FMT = '