2017-03-28 01:03:52 +00:00
|
|
|
#
|
|
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
import pyudev
|
2017-04-11 22:56:25 +00:00
|
|
|
import os
|
2017-04-20 01:45:29 +00:00
|
|
|
from ..mpmlog import get_logger
|
2017-03-28 01:03:52 +00:00
|
|
|
|
2017-05-10 19:07:14 +00:00
|
|
|
def get_eeprom_paths(address):
|
2017-03-28 01:03:52 +00:00
|
|
|
"""
|
2017-05-10 19:07:14 +00:00
|
|
|
Return EEPROM device paths for a given I2C address
|
2017-03-28 01:03:52 +00:00
|
|
|
"""
|
|
|
|
|
context = pyudev.Context()
|
|
|
|
|
parent = pyudev.Device.from_name(context, "platform", address)
|
2017-04-11 22:56:25 +00:00
|
|
|
paths = [device.device_node if device.device_node is not None else device.sys_path
|
2017-03-28 01:03:52 +00:00
|
|
|
for device in context.list_devices(parent=parent, subsystem="nvmem")]
|
2017-05-10 19:07:14 +00:00
|
|
|
return [os.path.join(x.encode('ascii'), 'nvmem') for x in paths]
|
2017-03-28 01:03:52 +00:00
|
|
|
|
|
|
|
|
def get_spidev_nodes(spi_master):
|
|
|
|
|
"""
|
|
|
|
|
Return found spidev device paths for a given SPI master
|
|
|
|
|
"""
|
|
|
|
|
context = pyudev.Context()
|
|
|
|
|
parent = pyudev.Device.from_name(context, "platform", spi_master)
|
2017-04-27 00:25:23 +00:00
|
|
|
paths = [device.device_node.encode('ascii')
|
2017-03-28 01:03:52 +00:00
|
|
|
for device in context.list_devices(parent=parent, subsystem="spidev")]
|
|
|
|
|
return paths
|
2017-04-11 22:56:25 +00:00
|
|
|
|