Skip to content

Commit

Permalink
Merge pull request #217 from CaryChen-Deltaww/tn48m2-dent3
Browse files Browse the repository at this point in the history
[tn48m] Add new platform TN48M2-SWDEV
  • Loading branch information
taraschornyiplv authored Jul 27, 2023
2 parents 2857787 + c962cfd commit 407966a
Show file tree
Hide file tree
Showing 23 changed files with 168 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ K_PATCH_SERIES=series.arm64

include ../../kconfig.mk
K_CONFIG := arm64-all.config
K_BUILD_TARGET := Image Image.gz freescale/fsl-ls1043a-rdb.dtb freescale/fsl-ls1046a-rdb-sdk.dtb freescale/fsl-ls2080a-rdb.dtb freescale/fsl-ls2088a-rdb.dtb freescale/fsl-ls1088a-rdb.dtb marvell/accton-as4224.dtb marvell/accton-as5114.dtb marvell/accton-as4564-26p.dtb marvell/delta-tn48m.dtb marvell/delta-tn4810m.dtb marvell/delta-tn48m-dn.dtb marvell/delta-tn4810m-dn.dtb
K_BUILD_TARGET := Image Image.gz freescale/fsl-ls1043a-rdb.dtb freescale/fsl-ls1046a-rdb-sdk.dtb freescale/fsl-ls2080a-rdb.dtb freescale/fsl-ls2088a-rdb.dtb freescale/fsl-ls1088a-rdb.dtb marvell/accton-as4224.dtb marvell/accton-as5114.dtb marvell/accton-as4564-26p.dtb marvell/delta-tn48m.dtb marvell/delta-tn4810m.dtb marvell/delta-tn48m-dn.dtb marvell/delta-tn4810m-dn.dtb marvell/delta-tn48m2-swdev.dtb
K_COPY_SRC := arch/arm64/boot/Image
K_COPY_GZIP := 1
ifndef K_COPY_DST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <onlplib/file.h>
#include <onlplib/onie.h>
#include "platform_lib.h"

plat_id_t gPlat_id = PID_UNKNOWN;
Expand Down Expand Up @@ -108,7 +109,23 @@ plat_info_t gPlat_info[] = {

.thermal_count = 11,
.fan_count = 3,
.psu_count = 2,
.psu_count = 3,
.led_count = 3,

.sfp_start_idx = 49,
.sfp_end_idx = 52,
},
[PID_TN48M2_SWDEV] = {
.name = "arm64-delta-tn48m2-swdev",

.onie_eeprom_path = "/sys/bus/i2c/devices/1-0056/eeprom",

.cpld_bus = 0,
.cpld_path = "/sys/bus/i2c/devices/0-0041",

.thermal_count = 11,
.fan_count = 3,
.psu_count = 3,
.led_count = 3,

.sfp_start_idx = 49,
Expand All @@ -119,12 +136,14 @@ plat_info_t gPlat_info[] = {
plat_id_t get_platform_id(void)
{
int len;
int rc;
int pid = PID_UNKNOWN;
int cpld_bus = 0;
char buf[4] = {0};
char pid_fullpath[PATH_MAX] = {0};
plat_info_t *tn48m_info = &gPlat_info[PID_TN48M];
plat_info_t *tn4810m_pvt_info = &gPlat_info[PID_TN4810M_PVT];
onlp_onie_info_t onie_syseeprom;

if (plat_os_file_is_existed(tn48m_info->cpld_path)) {
sprintf(pid_fullpath, "%s/platform_id", tn48m_info->cpld_path);
Expand All @@ -148,6 +167,13 @@ plat_id_t get_platform_id(void)
if (pid == PID_TN4810M_PVT && cpld_bus == 0)
pid = PID_TN4810M_NONPVT;

/* Special case to check TN48M2-SWDEV platform */
if (pid == PID_TN48M2) {
rc = onlp_onie_decode_file(&onie_syseeprom, tn48m_info->onie_eeprom_path);
if (rc >= 0 && onie_syseeprom.device_version >= 4)
pid = PID_TN48M2_SWDEV;
}

return pid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typedef enum plat_id {
PID_TN4810M_PVT,
PID_TN48M2,
PID_TN4810M_NONPVT,
PID_TN48M2_SWDEV,
PID_UNKNOWN,
} plat_id_t;

Expand Down Expand Up @@ -156,6 +157,7 @@ typedef enum plat_psu_id {
PLAT_PSU_ID_INVALID = 0,
PLAT_PSU_ID_1,
PLAT_PSU_ID_2,
PLAT_PSU_ID_3,
PLAT_PSU_ID_MAX
} plat_psu_id_t;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ static plat_psu_t plat_tn48m2_psus[] = {
.power_status_path = "/sys/bus/i2c/devices/0-0041/psu2_powergood",
.state = PLAT_PSU_STATE_PRESENT,
},
[PLAT_PSU_ID_3] = {
.name = "DCIN",
.type = PLAT_PSU_TYPE_DC12,
.power_status_path = "/sys/bus/i2c/devices/0-0041/dcin_powergood",
.state = PLAT_PSU_STATE_PRESENT,
},
};

static plat_psu_t* get_plat_psu()
Expand All @@ -186,6 +192,7 @@ static plat_psu_t* get_plat_psu()
else if (gPlat_id == PID_TN4810M_NONPVT)
return plat_tn4810m_nonpvt_psus;
else
/* tn48m2 and tn48m2-swdev shares the same psu configuration */
return plat_tn48m2_psus;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ onlp_sysi_platform_get(void)
return "arm64-delta-tn48m-poe";
else if (gPlat_id == PID_TN48M2)
return "arm64-delta-tn48m2";
else if (gPlat_id == PID_TN48M2_SWDEV)
return "arm64-delta-tn48m2-swdev";
else if (gPlat_id == PID_TN4810M_PVT || gPlat_id == PID_TN4810M_NONPVT)
return "arm64-delta-tn4810m";
else
Expand All @@ -73,6 +75,9 @@ onlp_sysi_platform_set(const char* platform)
if (strstr(platform, "arm64-delta-tn48m-poe-r0")) {
return ONLP_STATUS_OK;
}
if (strstr(platform, "arm64-delta-tn48m2-swdev-r0")) {
return ONLP_STATUS_OK;
}
if (strstr(platform, "arm64-delta-tn4810m-r0")) {
return ONLP_STATUS_OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#define TN48M_CPLD_BIT_PSU2_PRESENT 1
#define TN48M_CPLD_BIT_PSU1_PG 2
#define TN48M_CPLD_BIT_PSU2_PG 3
#define TN48M_CPLD_BIT_DCIN_PG 6

#define I2C_RW_RETRY_COUNT 10
#define I2C_RW_RETRY_INTERVAL 60 /* ms */
Expand Down Expand Up @@ -124,6 +125,7 @@ enum tn48m_cpld_sysfs_attributes {
PSU2_PRESENT,
PSU1_PG,
PSU2_PG,
DCIN_PG,
MODULE_PRESENT_ALL,
MODULE_RX_LOS_ALL,
MODULE_TX_DIS_ALL,
Expand Down Expand Up @@ -410,6 +412,9 @@ static ssize_t show_psu_status_bit(struct device *dev,
case PSU2_PG:
bit = !!(data->psu_status & BIT(TN48M_CPLD_BIT_PSU2_PG));
break;
case DCIN_PG:
bit = !!(data->psu_status & BIT(TN48M_CPLD_BIT_DCIN_PG));
break;
default:
bit = 0;
dev_err(dev, "Unknown case %d in show_psu_status_bit.\n", attr->index);
Expand All @@ -423,6 +428,7 @@ static SENSOR_DEVICE_ATTR(psu1_present, S_IRUGO, show_psu_status_bit, NULL, PSU1
static SENSOR_DEVICE_ATTR(psu2_present, S_IRUGO, show_psu_status_bit, NULL, PSU2_PRESENT);
static SENSOR_DEVICE_ATTR(psu1_powergood, S_IRUGO, show_psu_status_bit, NULL, PSU1_PG);
static SENSOR_DEVICE_ATTR(psu2_powergood, S_IRUGO, show_psu_status_bit, NULL, PSU2_PG);
static SENSOR_DEVICE_ATTR(dcin_powergood, S_IRUGO, show_psu_status_bit, NULL, DCIN_PG);

static ssize_t show_module_status_all(struct device *dev,
struct device_attribute *devattr,
Expand Down Expand Up @@ -646,6 +652,7 @@ static struct attribute *tn48m_cpld_attributes[] = {
&sensor_dev_attr_psu2_present.dev_attr.attr,
&sensor_dev_attr_psu1_powergood.dev_attr.attr,
&sensor_dev_attr_psu2_powergood.dev_attr.attr,
&sensor_dev_attr_dcin_powergood.dev_attr.attr,
/* tn48m transceiver attributes */
&sensor_dev_attr_module_tx_dis_all.dev_attr.attr,
&sensor_dev_attr_module_present_all.dev_attr.attr,
Expand Down
2 changes: 2 additions & 0 deletions packages/platforms/delta/arm64/tn48m/tn48m2-swdev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*arm64*delta*tn48m2*swdev*.mk
onlpdump.mk
1 change: 1 addition & 0 deletions packages/platforms/delta/arm64/tn48m/tn48m2-swdev/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(ONL)/make/pkg.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(ONL)/make/pkg.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!include $ONL_TEMPLATES/platform-modules.yml ARCH=arm64 VENDOR=delta BASENAME=arm64-delta-tn48m2-swdev KERNELS="onl-kernel-5.15-lts-arm64-all:arm64"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
KERNELS := onl-kernel-5.15-lts-arm64-all:arm64
KMODULES := $(ONL)/packages/platforms/delta/arm64/tn48m/src/modules/
VENDOR := delta
BASENAME := arm64-delta-tn48m2-swdev
ARCH := arm64
include $(ONL)/make/kmodule.mk
export CROSS_COMPILE=aarch64-linux-gnu-
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(ONL)/make/pkg.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=arm64-delta-tn48m2-swdev ARCH=arm64 TOOLCHAIN=aarch64-linux-gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FILTER=src
include $(ONL)/make/subdirs.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PLATFORM := arm64-delta-tn48m2-swdev
PLATFORM_MODULE := arm64_delta_tn48m
include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PLATFORM := arm64-delta-tn48m2-swdev
PLATFORM_MODULE := arm64_delta_tn48m
include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(ONL)/make/pkg.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(ONL)/make/pkg.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=arm64 VENDOR=delta BASENAME=arm64-delta-tn48m2-swdev REVISION=r0
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---

######################################################################
#
# platform-config for TN48M2-SWDEV
#
######################################################################

arm64-delta-tn48m2-swdev-r0:
flat_image_tree:
kernel:
<<: *arm64-kernel-5-15
dtb:
=: delta-tn48m2-swdev.dtb
<<: *arm64-kernel-5-15-package
itb:
<<: *arm64-itb

loader:
device: /dev/sda
##partition: /dev/sda1
loadaddr: 0x10000000
nos_bootcmds: *ssd_bootcmds

setenv:
- bootargs: >-
$console
onl_platform=$onl_platform
environment:
- device: /dev/mtd1
env_offset: 0x00000000
env_size: 0x00010000
sector_size: 0x00010000

installer:
- ONL-BOOT:
=: 128MiB
format: ext2
##format: raw
- ONL-CONFIG:
=: 128MiB
format: ext4
- ONL-IMAGES:
=: 1GiB
format: ext4
- ONL-DATA:
=: 100%
format: ext4

network:
interfaces:
ma1:
name: eth0
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/python

from onl.platform.base import *
from onl.platform.delta import *

class OnlPlatform_arm64_delta_tn48m2_swdev_r0(OnlPlatformDelta,
OnlPlatformPortConfig_48x1_4x10):
PLATFORM='arm64-delta-tn48m2-swdev-r0'
MODEL="TN48M2-SWDEV"
SYS_OBJECT_ID=".48.14"

def baseconfig(self):
# Insert platform drivers
self.insmod("arm64-delta-tn48m-cpld.ko")
self.insmod("arm64-delta-tn48m-led.ko")

########### initialize I2C bus 1 ###########
self.new_i2c_devices (
[
# FAN Controller
('adt7473', 0x2e, 1),

# Temperature devices
('tmp1075', 0x4a, 1),
('tmp1075', 0x4b, 1),
]
)

# Insert Marvell prestera modules by only probing prestera_pci module
# Suggested by Taras Chornyi
self.modprobe('prestera_pci')

# set up systemctl rules
for swp in range(1, 53):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True
1 change: 1 addition & 0 deletions setup.env
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ arm64-nxp-ls1046ardb-r0
arm64-delta-tx4810-r0
arm64-delta-tn4810m-r0
arm64-delta-tn48m2-r0
arm64-delta-tn48m2-swdev-r0
arm64-delta-tn48m-r0
arm64-delta-tn48m-poe-r0
arm64-delta-tn48m-dn-r0
Expand Down

0 comments on commit 407966a

Please sign in to comment.