Skip to content

Commit

Permalink
Adding pmon2.0 support for amd platform
Browse files Browse the repository at this point in the history
  • Loading branch information
lkunjumon committed May 31, 2021
1 parent 2a8b61a commit d762069
Show file tree
Hide file tree
Showing 40 changed files with 5,027 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ def _get_transceiver_status(self):
offset = int(profile[port_index].split(",")[1])
bin_offset = 1<<offset
device_reg = int(profile[port_index].split(",")[0],16)
self.i2c_set(device_reg, 0, bin_offset)
path = "/sys/bus/i2c/devices/0-0050/eeprom"
try:
reg_file = open(path, 'rb')
reg_file.seek(1)
reg_file.read(2)
sfp_status=( x | (1<<index-self.SFP_PORT_START)) + sfp_status
except IOError as e:
sfp_status=( x & ~(1<<index-self.SFP_PORT_START)) + sfp_status
self.i2c_set(device_reg, 0, bin_offset)
path = "/sys/bus/i2c/devices/0-0050/eeprom"
try:
reg_file = open(path, 'rb')
reg_file.seek(1)
reg_file.read(2)
sfp_status=( x | (1<<index-self.SFP_PORT_START)) + sfp_status
except IOError as e:
sfp_status=( x & ~(1<<index-self.SFP_PORT_START)) + sfp_status

sfp_status = ~sfp_status
return sfp_status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,15 @@ def _get_transceiver_status(self):
offset = int(profile[port_index].split(",")[1])
bin_offset = 1<<offset
device_reg = int(profile[port_index].split(",")[0],16)
self.i2c_set(device_reg, 0, bin_offset)
path = "/sys/bus/i2c/devices/0-0050/eeprom"
try:
reg_file = open(path, 'rb')
reg_file.seek(1)
reg_file.read(2)
sfp_status=( x | (1<<index-self.SFP_PORT_START)) + sfp_status
except IOError as e:
sfp_status=( x & ~(1<<index-self.SFP_PORT_START)) + sfp_status
self.i2c_set(device_reg, 0, bin_offset)
path = "/sys/bus/i2c/devices/0-0050/eeprom"
try:
reg_file = open(path, 'rb')
reg_file.seek(1)
reg_file.read(2)
sfp_status=( x | (1<<index-self.SFP_PORT_START)) + sfp_status
except IOError as e:
sfp_status=( x & ~(1<<index-self.SFP_PORT_START)) + sfp_status

sfp_status = ~sfp_status
return sfp_status
Expand Down
3 changes: 3 additions & 0 deletions platform/marvell/one-image.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ SONIC_ONE_IMAGE = sonic-marvell.bin
$(SONIC_ONE_IMAGE)_MACHINE = marvell
$(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie
$(SONIC_ONE_IMAGE)_INSTALLS += $(SYSTEMD_SONIC_GENERATOR)
$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(FALCON_DB98CX8540_16CD_PLATFORM)
$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(FALCON_DB98CX8580_32CD_PLATFORM)

ifeq ($(INSTALL_DEBUG_TOOLS),y)
$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_DBG_IMAGES)
$(SONIC_ONE_IMAGE)_DOCKERS += $(filter-out $(patsubst %-$(DBG_IMAGE_MARK).gz,%.gz, $(SONIC_INSTALL_DOCKER_DBG_IMAGES)), $(SONIC_INSTALL_DOCKER_IMAGES))
Expand Down
12 changes: 12 additions & 0 deletions platform/marvell/platform-db98cx8540-16cd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# FALCON Platform

FALCON_VERSION = 1.0
export FALCON_VERSION

FALCON_DB98CX8540_16CD_PLATFORM = sonic-platform-db98cx8540-16cd-db98cx8540_$(FALCON_VERSION)_$(CONFIGURED_ARCH).deb
$(FALCON_DB98CX8540_16CD_PLATFORM)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-db98cx8540-16cd
$(FALCON_DB98CX8540_16CD_PLATFORM)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
$(FALCON_DB98CX8540_16CD_PLATFORM)_PLATFORM = x86_64-marvell_db98cx8540_16cd-r0

SONIC_DPKG_DEBS += $(FALCON_DB98CX8540_16CD_PLATFORM)

12 changes: 12 additions & 0 deletions platform/marvell/platform-db98cx8580-32cd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# FALCON Platform

FALCON_VERSION = 1.0
export FALCON_VERSION

FALCON_DB98CX8580_32CD_PLATFORM = sonic-platform-db98cx8580-32cd-db98cx8580_$(FALCON_VERSION)_$(CONFIGURED_ARCH).deb
$(FALCON_DB98CX8580_32CD_PLATFORM)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-db98cx8580-32cd
$(FALCON_DB98CX8580_32CD_PLATFORM)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
$(FALCON_DB98CX8580_32CD_PLATFORM)_PLATFORM = x86_64-marvell_db98cx8580_32cd-r0

SONIC_DPKG_DEBS += $(FALCON_DB98CX8580_32CD_PLATFORM)

2 changes: 2 additions & 0 deletions platform/marvell/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include $(PLATFORM_PATH)/docker-syncd-mrvl.mk
include $(PLATFORM_PATH)/docker-syncd-mrvl-rpc.mk
include $(PLATFORM_PATH)/libsaithrift-dev.mk
include $(PLATFORM_PATH)/one-image.mk
include $(PLATFORM_PATH)/platform-db98cx8540-16cd.mk
include $(PLATFORM_PATH)/platform-db98cx8580-32cd.mk

SONIC_ALL += $(SONIC_ONE_IMAGE) \
$(DOCKER_FPM) \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Platform init script for db98cx8540-16cd

# Load required kernel-mode drivers
load_kernel_drivers() {
# Remove modules loaded during Linux init
# FIX-ME: This will be removed in the future when Linux init no longer loads these
rmmod i2c_mux_gpio
rmmod i2c_dev
rmmod i2c_mv64xxx

# Carefully control the load order here to ensure consistent i2c bus numbering
modprobe i2c_mv64xxx
modprobe i2c_dev
modprobe i2c_mux_gpio
modprobe eeprom
}

# - Main entry

# Install kernel drivers required for i2c bus access
load_kernel_drivers

# LOGIC to enumerate SFP eeprom devices - send 0x50 to kernel i2c driver - initialize devices
# the mux may be enumerated at number 4 or 5 so we check for the mux and skip if needed
# Get list of the mux channels
ismux_bus=$(i2cdetect -l|grep mux|cut -f1)
# Enumerate the SFP eeprom device on each mux channel
for mux in ${ismux_bus}
do
echo optoe2 0x50 > /sys/class/i2c-adapter/${mux}/new_device
done

exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Platform db98cx8540-16cd Service
Before=pmon.service
After=sysinit.target
DefaultDependencies=no

[Service]
ExecStart=/usr/local/bin/db98cx8540-16cd-init.sh
KillSignal=SIGKILL
SuccessExitStatus=SIGKILL
#StandardOutput=tty

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python

import os
from setuptools import setup
os.listdir

setup(
name='sonic_platform',
version='1.0',
description='Module to initialize platforms',

packages=['sonic_platform'],
package_dir={'sonic_platform': 'db98cx8540/sonic_platform'},
)

Empty file.
Loading

0 comments on commit d762069

Please sign in to comment.