# # Copyright 2017 Ettus Research (National Instruments) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # """ N310 implementation module """ from __future__ import print_function import os from six import iteritems from builtins import object from .base import PeriphManagerBase from ..net import get_iface_addrs from ..net import byte_to_mac from ..net import get_mac_addr from ..mpmtypes import SID from usrp_mpm.uio import UIO from ..sysfs_gpio import SysFSGPIO from ..ethtable import EthDispatcherTable from .. import libpyusrp_periphs as lib N3XX_DEFAULT_EXT_CLOCK_FREQ = 10e6 N3XX_DEFAULT_CLOCK_SOURCE = 'external' N3XX_DEFAULT_TIME_SOURCE = 'internal' N3XX_DEFAULT_ENABLE_GPS = True N3XX_DEFAULT_ENABLE_FPGPIO = True class TCA6424(object): """ Abstraction layer for the port/gpio expander """ pins = ( 'PWREN-CLK-MGT156MHz', 'PWREN-CLK-WB-CDCM', 'WB-CDCM-RESETn', 'WB-CDCM-PR0', 'WB-CDCM-PR1', 'WB-CDCM-OD0', 'WB-CDCM-OD1', 'WB-CDCM-OD2', 'PWREN-CLK-MAINREF', 'CLK-MAINREF-SEL1', 'CLK-MAINREF-SEL0', '12', '13', 'FPGA-GPIO-EN', 'PWREN-CLK-WB-20MHz', 'PWREN-CLK-WB-25MHz', 'GPS-PHASELOCK', 'GPS-nINITSURV', 'GPS-nRESET', 'GPS-WARMUP', 'GPS-SURVEY', 'GPS-LOCKOK', 'GPS-ALARM', 'PWREN-GPS', ) def __init__(self): # Default state: Turn on GPS power, take GPS out of reset or # init-survey, turn on 156.25 MHz clock self._gpios = SysFSGPIO('tca6424', 0xFFE7FF, 0x86E7FF, 0x860001) def set(self, name, value=None): """ Assert a pin by name """ assert name in self.pins self._gpios.set(self.pins.index(name), value=value) def reset(self, name): """ Deassert a pin by name """ self.set(name, value=0) def get(self, name): """ Read back a pin by name """ assert name in self.pins return self._gpios.get(self.pins.index(name)) class FP_GPIO(object): """ Abstraction layer for the front panel GPIO """ EMIO_BASE = 54 FP_GPIO_OFFSET = 32 # Bit offset within the ps_gpio_* pins def __init__(self, ddr): self._gpiosize = 12 self._offset = self.FP_GPIO_OFFSET + self.EMIO_BASE self.usemask = 0xFFF self.ddr = ddr self._gpios = SysFSGPIO( 'zynq_gpio', self.usemask<