Added Netberg Aurora 715 support (#8604)

* [202012][platform/barefoot] (#8543)

Why I did it
Pcied running by python 2.

How I did it
dropped python2 support and add python3 support for pcied in file docker-pmon.supervisord.conf.j2

How to verify it
docker exec pmon supervisorctl status

* [Netberg][nba715] Initial support for Netberg Aurora 715 switch

Signed-off-by: Andrew Sapronov <andrew.sapronov@gmail.com>

Co-authored-by: Kostiantyn Yarovyi <kostiantynx.yarovyi@intel.com>
This commit is contained in:
Andrew Sapronov 2021-10-26 23:04:27 +03:00 committed by GitHub
parent 32ad7444f9
commit 8eab0e02df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 9995 additions and 0 deletions

View File

@ -0,0 +1,137 @@
{# Default values which will be used if no actual configura available #}
{% set default_cable = '40m' %}
{# Port configuration to cable length look-up table #}
{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #}
{# Roles described in the minigraph #}
{% set ports2cable = {
'torrouter_server' : '5m',
'leafrouter_torrouter' : '40m',
'spinerouter_leafrouter' : '300m'
}
%}
{%- macro cable_length(port_name) %}
{%- set cable_len = [] %}
{%- for local_port in DEVICE_NEIGHBOR %}
{%- if local_port == port_name %}
{%- if DEVICE_NEIGHBOR_METADATA is defined and DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] %}
{%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] %}
{%- set neighbor_role = neighbor.type %}
{%- set roles1 = switch_role + '_' + neighbor_role %}
{%- set roles2 = neighbor_role + '_' + switch_role %}
{%- set roles1 = roles1 | lower %}
{%- set roles2 = roles2 | lower %}
{%- if roles1 in ports2cable %}
{%- if cable_len.append(ports2cable[roles1]) %}{% endif %}
{%- elif roles2 in ports2cable %}
{%- if cable_len.append(ports2cable[roles2]) %}{% endif %}
{%- endif %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if cable_len -%}
{{ cable_len.0 }}
{%- else %}
{%- if switch_role.lower() == 'torrouter' %}
{%- for local_port in VLAN_MEMBER %}
{%- if local_port[1] == port_name %}
{%- set roles3 = switch_role + '_' + 'server' %}
{%- set roles3 = roles3 | lower %}
{%- if roles3 in ports2cable %}
{%- if cable_len.append(ports2cable[roles3]) %}{% endif %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if cable_len -%}
{{ cable_len.0 }}
{%- else -%}
{{ default_cable }}
{%- endif %}
{%- else -%}
{{ default_cable }}
{%- endif %}
{%- endif %}
{%- endmacro %}
{%- if DEVICE_METADATA is defined %}
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
{%- endif -%}
{% set port_names_list = [] %}
{% for port in PORT %}
{%- if port_names_list.append(port) %}{% endif %}
{% endfor %}
{% set port_names = port_names_list | join(',') -%}
{
"CABLE_LENGTH": {
"AZURE": {
{% for port in PORT %}
{% set cable = cable_length(port) -%}
"{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %}
{% endfor %}
}
},
"BUFFER_POOL": {
"ingress_lossless_pool": {
"size": "34056960",
"type": "ingress",
"mode": "dynamic",
"xoff": "4185600"
},
"lossy_pool": {
"size": "14595840",
"type": "egress",
"mode": "dynamic",
"xoff": "0"
}
},
"BUFFER_PROFILE": {
"ingress_lossless_profile": {
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
"xoff":"38816",
"size":"1518",
"dynamic_th":"1",
"xon_offset":"13440"
},
"egress_lossless_profile": {
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
"size":"0",
"static_th":"23001600"
},
"ingress_lossy_profile": {
"pool":"[BUFFER_POOL|lossy_pool]",
"size":"0",
"static_th":"23001600"
},
"egress_lossy_profile": {
"pool":"[BUFFER_POOL|lossy_pool]",
"size":"1518",
"dynamic_th":"2"
}
},
"BUFFER_PG": {
"{{ port_names }}|0-2": {
"profile" : "[BUFFER_PROFILE|ingress_lossy_profile]"
},
"{{ port_names }}|3-4": {
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile]"
},
"{{ port_names }}|5-7": {
"profile" : "[BUFFER_PROFILE|ingress_lossy_profile]"
}
},
"BUFFER_QUEUE": {
"{{ port_names }}|3-4": {
"profile" : "[BUFFER_PROFILE|egress_lossless_profile]"
},
"{{ port_names }}|0-2": {
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
},
"{{ port_names }}|5-7": {
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
}
}
}

View File

@ -0,0 +1,38 @@
{% set port_names_list = [] %}
{% for port in PORT %}
{%- if port_names_list.append(port) %}{% endif %}
{% endfor %}
{% set port_names = port_names_list | join(',') -%}
{
"BUFFER_POOL": {
"lossy_pool": {
"size": "46003200",
"type": "egress",
"mode": "dynamic",
"xoff": "0"
}
},
"BUFFER_PROFILE": {
"ingress_lossy_profile": {
"pool":"[BUFFER_POOL|lossy_pool]",
"size":"0",
"static_th":"23001600"
},
"egress_lossy_profile": {
"pool":"[BUFFER_POOL|lossy_pool]",
"size":"1518",
"dynamic_th":"2"
}
},
"BUFFER_PG": {
"{{ port_names }}|0-7": {
"profile" : "[BUFFER_PROFILE|ingress_lossy_profile]"
}
},
"BUFFER_QUEUE": {
"{{ port_names }}|0-7": {
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
}
}
}

View File

@ -0,0 +1,137 @@
{# Default values which will be used if no actual configura available #}
{% set default_cable = '40m' %}
{# Port configuration to cable length look-up table #}
{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #}
{# Roles described in the minigraph #}
{% set ports2cable = {
'torrouter_server' : '5m',
'leafrouter_torrouter' : '40m',
'spinerouter_leafrouter' : '300m'
}
%}
{%- macro cable_length(port_name) %}
{%- set cable_len = [] %}
{%- for local_port in DEVICE_NEIGHBOR %}
{%- if local_port == port_name %}
{%- if DEVICE_NEIGHBOR_METADATA is defined and DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] %}
{%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] %}
{%- set neighbor_role = neighbor.type %}
{%- set roles1 = switch_role + '_' + neighbor_role %}
{%- set roles2 = neighbor_role + '_' + switch_role %}
{%- set roles1 = roles1 | lower %}
{%- set roles2 = roles2 | lower %}
{%- if roles1 in ports2cable %}
{%- if cable_len.append(ports2cable[roles1]) %}{% endif %}
{%- elif roles2 in ports2cable %}
{%- if cable_len.append(ports2cable[roles2]) %}{% endif %}
{%- endif %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if cable_len -%}
{{ cable_len.0 }}
{%- else %}
{%- if switch_role.lower() == 'torrouter' %}
{%- for local_port in VLAN_MEMBER %}
{%- if local_port[1] == port_name %}
{%- set roles3 = switch_role + '_' + 'server' %}
{%- set roles3 = roles3 | lower %}
{%- if roles3 in ports2cable %}
{%- if cable_len.append(ports2cable[roles3]) %}{% endif %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if cable_len -%}
{{ cable_len.0 }}
{%- else -%}
{{ default_cable }}
{%- endif %}
{%- else -%}
{{ default_cable }}
{%- endif %}
{%- endif %}
{%- endmacro %}
{%- if DEVICE_METADATA is defined %}
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
{%- endif -%}
{% set port_names_list = [] %}
{% for port in PORT %}
{%- if port_names_list.append(port) %}{% endif %}
{% endfor %}
{% set port_names = port_names_list | join(',') -%}
{
"CABLE_LENGTH": {
"AZURE": {
{% for port in PORT %}
{% set cable = cable_length(port) -%}
"{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %}
{% endfor %}
}
},
"BUFFER_POOL": {
"ingress_lossless_pool": {
"size": "34056960",
"type": "ingress",
"mode": "dynamic",
"xoff": "4185600"
},
"lossy_pool": {
"size": "14595840",
"type": "egress",
"mode": "dynamic",
"xoff": "0"
}
},
"BUFFER_PROFILE": {
"ingress_lossless_profile": {
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
"xoff":"38816",
"size":"1518",
"dynamic_th":"1",
"xon_offset":"13440"
},
"egress_lossless_profile": {
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
"size":"0",
"static_th":"23001600"
},
"ingress_lossy_profile": {
"pool":"[BUFFER_POOL|lossy_pool]",
"size":"0",
"static_th":"23001600"
},
"egress_lossy_profile": {
"pool":"[BUFFER_POOL|lossy_pool]",
"size":"1518",
"dynamic_th":"2"
}
},
"BUFFER_PG": {
"{{ port_names }}|0-2": {
"profile" : "[BUFFER_PROFILE|ingress_lossy_profile]"
},
"{{ port_names }}|3-4": {
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile]"
},
"{{ port_names }}|5-7": {
"profile" : "[BUFFER_PROFILE|ingress_lossy_profile]"
}
},
"BUFFER_QUEUE": {
"{{ port_names }}|3-4": {
"profile" : "[BUFFER_PROFILE|egress_lossless_profile]"
},
"{{ port_names }}|0-2": {
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
},
"{{ port_names }}|5-7": {
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
}
}
}

View File

@ -0,0 +1,397 @@
ifcs:
options:
log_level: "info"
nodes:
- node_id: "0"
options:
sku: "configs/sku/innovium.55300"
netdev:
- auto_create: "no"
multi_interface: "yes"
buffer_management_mode: "api_driven"
max_lossless_tc: "2"
skip_pll_check: "false"
ilpm_enable: "1"
forward_profile: "IFCS_FORWARD_PROFILE_ID_PROFILE_E"
mac_clk: "750"
sys_clk: "1300"
ifc_clk: "675"
txring:
- txring_id: "0"
desc_count: "1024"
prio: "1"
netdev: "true"
- txring_id: "1"
desc_count: "1024"
prio: "1"
netdev: "true"
- txring_id: "2"
desc_count: "1024"
prio: "1"
netdev: "true"
- txring_id: "3"
desc_count: "1024"
prio: "1"
netdev: "true"
rxring:
- rxring_id: "0"
desc_count: "1024"
prio: "1"
netdev: "true"
queues: "0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39"
- rxring_id: "1"
desc_count: "1024"
prio: "1"
netdev: "true"
queues: "1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40"
- rxring_id: "2"
desc_count: "1024"
prio: "1"
netdev: "true"
queues: "2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 47"
- rxring_id: "3"
desc_count: "1024"
prio: "1"
queues: "42, 43, 44, 45, 46"
devports:
- id: "0"
sysport: "129"
type: "cpu"
- fec: "KRFEC"
id: "121"
lanes: "0:4"
serdes_group: "15"
speed: "100G"
sysport: "121"
type: "eth"
- fec: "KRFEC"
id: "125"
lanes: "4:4"
serdes_group: "15"
speed: "100G"
sysport: "125"
type: "eth"
- fec: "KRFEC"
id: "113"
lanes: "0:4"
serdes_group: "14"
speed: "100G"
sysport: "113"
type: "eth"
- fec: "KRFEC"
id: "117"
lanes: "4:4"
serdes_group: "14"
speed: "100G"
sysport: "117"
type: "eth"
- fec: "KRFEC"
id: "105"
lanes: "0:4"
serdes_group: "13"
speed: "100G"
sysport: "105"
type: "eth"
- fec: "KRFEC"
id: "109"
lanes: "4:4"
serdes_group: "13"
speed: "100G"
sysport: "109"
type: "eth"
- fec: "KRFEC"
id: "97"
lanes: "0:4"
serdes_group: "12"
speed: "100G"
sysport: "97"
type: "eth"
- fec: "KRFEC"
id: "101"
lanes: "4:4"
serdes_group: "12"
speed: "100G"
sysport: "101"
type: "eth"
- fec: "KRFEC"
id: "89"
lanes: "0:4"
serdes_group: "11"
speed: "100G"
sysport: "89"
type: "eth"
- fec: "KRFEC"
id: "93"
lanes: "4:4"
serdes_group: "11"
speed: "100G"
sysport: "93"
type: "eth"
- fec: "KRFEC"
id: "81"
lanes: "0:4"
serdes_group: "10"
speed: "100G"
sysport: "81"
type: "eth"
- fec: "KRFEC"
id: "85"
lanes: "4:4"
serdes_group: "10"
speed: "100G"
sysport: "85"
type: "eth"
- fec: "KRFEC"
id: "73"
lanes: "0:4"
serdes_group: "9"
speed: "100G"
sysport: "73"
type: "eth"
- fec: "KRFEC"
id: "77"
lanes: "4:4"
serdes_group: "9"
speed: "100G"
sysport: "77"
type: "eth"
- fec: "KRFEC"
id: "65"
lanes: "0:4"
serdes_group: "8"
speed: "100G"
sysport: "65"
type: "eth"
- fec: "KRFEC"
id: "69"
lanes: "4:4"
serdes_group: "8"
speed: "100G"
sysport: "69"
type: "eth"
- fec: "KRFEC"
id: "57"
lanes: "0:4"
serdes_group: "7"
speed: "100G"
sysport: "57"
type: "eth"
- fec: "KRFEC"
id: "61"
lanes: "4:4"
serdes_group: "7"
speed: "100G"
sysport: "61"
type: "eth"
- fec: "KRFEC"
id: "49"
lanes: "0:4"
serdes_group: "6"
speed: "100G"
sysport: "49"
type: "eth"
- fec: "KRFEC"
id: "53"
lanes: "4:4"
serdes_group: "6"
speed: "100G"
sysport: "53"
type: "eth"
- fec: "KRFEC"
id: "41"
lanes: "0:4"
serdes_group: "5"
speed: "100G"
sysport: "41"
type: "eth"
- fec: "KRFEC"
id: "45"
lanes: "4:4"
serdes_group: "5"
speed: "100G"
sysport: "45"
type: "eth"
- fec: "KRFEC"
id: "33"
lanes: "0:4"
serdes_group: "4"
speed: "100G"
sysport: "33"
type: "eth"
- fec: "KRFEC"
id: "37"
lanes: "4:4"
serdes_group: "4"
speed: "100G"
sysport: "37"
type: "eth"
- fec: "KRFEC"
id: "25"
lanes: "0:4"
serdes_group: "3"
speed: "100G"
sysport: "25"
type: "eth"
- fec: "KRFEC"
id: "29"
lanes: "4:4"
serdes_group: "3"
speed: "100G"
sysport: "29"
type: "eth"
- fec: "KRFEC"
id: "17"
lanes: "0:4"
serdes_group: "2"
speed: "100G"
sysport: "17"
type: "eth"
- fec: "KRFEC"
id: "21"
lanes: "4:4"
serdes_group: "2"
speed: "100G"
sysport: "21"
type: "eth"
- fec: "KRFEC"
id: "9"
lanes: "0:4"
serdes_group: "1"
speed: "100G"
sysport: "9"
type: "eth"
- fec: "KRFEC"
id: "13"
lanes: "4:4"
serdes_group: "1"
speed: "100G"
sysport: "13"
type: "eth"
- fec: "KRFEC"
id: "1"
lanes: "0:4"
serdes_group: "0"
speed: "100G"
sysport: "1"
type: "eth"
- fec: "KRFEC"
id: "5"
lanes: "4:4"
serdes_group: "0"
speed: "100G"
sysport: "5"
type: "eth"
# Aux ports to be enabled later
# - id: "33"
# fec: "NONE"
# lanes: "0:1"
# serdes_group: "16"
# speed: "10G"
# sysport: "33"
# type: "mgmt 0"
# - id: "34"
# fec: "NONE"
# lanes: "1:1"
# serdes_group: "16"
# speed: "10G"
# sysport: "34"
# type: "mgmt 1"
isg:
- id: "0"
tx_polarity: "00001010"
rx_polarity: "01001001"
lane_swap: "46750132"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "1"
tx_polarity: "00011111"
rx_polarity: "01101001"
lane_swap: "46752130"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "2"
tx_polarity: "00101000"
rx_polarity: "11110111"
lane_swap: "57462301"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "3"
tx_polarity: "00111101"
rx_polarity: "00101101"
lane_swap: "67542301"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "4"
tx_polarity: "01110110"
rx_polarity: "01111101"
lane_swap: "76543021"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "5"
tx_polarity: "00100100"
rx_polarity: "01101010"
lane_swap: "76542103"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "6"
tx_polarity: "11000011"
rx_polarity: "11110101"
lane_swap: "45672013"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "7"
tx_polarity: "10011101"
rx_polarity: "11111010"
lane_swap: "74562103"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "8"
tx_polarity: "01001000"
rx_polarity: "00100011"
lane_swap: "54672301"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "9"
tx_polarity: "11111111"
rx_polarity: "01110111"
lane_swap: "46750321"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "10"
tx_polarity: "10011110"
rx_polarity: "10110000"
lane_swap: "67542310"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "11"
tx_polarity: "01010010"
rx_polarity: "10101011"
lane_swap: "65741302"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "12"
tx_polarity: "11010110"
rx_polarity: "01101001"
lane_swap: "45760321"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "13"
tx_polarity: "01110111"
rx_polarity: "00101000"
lane_swap: "45670123"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "14"
tx_polarity: "11110110"
rx_polarity: "10111100"
lane_swap: "67542013"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"
- id: "15"
tx_polarity: "01011011"
rx_polarity: "01101000"
lane_swap: "64572103"
pre1: "-3, -3, -3, -3, -3, -3, -3, -3"
main: "20, 20, 20, 20, 20, 20, 20, 20"

View File

@ -0,0 +1,62 @@
sku: innovium.55300
device_id: 0x1b59
# Hardware constraint information
hardware:
num_ibs: 2
ib_active: 0, 1
ports_per_ib: 64, 64
recirc_port_num: 64, 64
cpu_port_num: 65
cpu_port_ib: 0
mgmt_port_num: 65, 66
mgmt_port_ibs: 1, 1
pics_per_ib: 9, 9
pic_ports_per_pic: 8
max_serdes_speed: 25
num_shared_pics: 0
isg [0-7]:
ib: 0
pic_id: [0-7]
isg 8:
ib: 1
pic_id: 7
isg 9:
ib: 1
pic_id: 6
isg 10:
ib: 1
pic_id: 5
isg 11:
ib: 1
pic_id: 4
isg 12:
ib: 1
pic_id: 3
isg 13:
ib: 1
pic_id: 2
isg 14:
ib: 1
pic_id: 1
isg 15:
ib: 1
pic_id: 0
isg 16:
mode: 0:2
ib: 1
pic_id: 8

View File

@ -0,0 +1,8 @@
IFCS_INIT_FILE : "/usr/share/sonic/hwsku/config_32x100G_netberg-aurora-715.yaml"
IFCS_SKU_FILE : "/usr/share/sonic/hwsku/innovium.55300"
IFCS_INNO_CLI_PORT : "9999"
IFCS_TARGET : "device"
INNOVIUM_DIR : "/innovium"
PYTHONPATH : "$INNOVIUM_DIR:$INNOVIUM_DIR/cmds:$INNOVIUM_DIR/scripts:$INNOVIUM_DIR/test/:$INNOVIUM_DIR/test/utils:$INNOVIUM_DIR/utils:$INNOVIUM_DIR/pyctypes"
IVM_SAI_DATAPATH_CONFIG_FILE: "/usr/share/sonic/hwsku/ivm.sai.datapath.config.yaml"
IVM_SAI_PARAM_A0008: "64"

View File

@ -0,0 +1,9 @@
ISAI_PARAM_P0_0_LS : "9216 9216"
ISAI_PARAM_P0_1_LS : "2850 2650"
ISAI_PARAM_P0_1_ALS : "290 90"
ISAI_PARAM_P1_0_LS : "3072 3072"
ISAI_PARAM_P1_0_LL : "6144 6144"
ISAI_PARAM_P1_1_LS : "2210 2010"
ISAI_PARAM_P1_1_LL : "1330 1330"
ISAI_PARAM_P1_1_ALS : "290 90"
ISAI_PARAM_P1_1_ALL : "50 50"

View File

@ -0,0 +1,18 @@
# PG lossless profiles.
# speed cable size xon xoff threshold xon_offset
25000 5m 1518 0 15680 1 13440
50000 5m 1518 0 21248 1 13440
100000 5m 1518 0 34624 1 13440
400000 5m 1518 0 117536 1 13440
25000 40m 1518 0 16928 1 13440
50000 40m 1518 0 23392 1 13440
100000 40m 1518 0 38816 1 13440
400000 40m 1518 0 135520 1 13440
25000 100m 1518 0 18848 1 13440
50000 100m 1518 0 27264 1 13440
100000 100m 1518 0 46496 1 13440
400000 100m 1518 0 166688 1 13440
25000 300m 1518 0 25184 1 13440
50000 300m 1518 0 40128 1 13440
100000 300m 1518 0 72384 1 13440
400000 300m 1518 0 268640 1 13440

View File

@ -0,0 +1,33 @@
# name lanes speed index mtu fec
Ethernet0 121,122,123,124 100000 0 9126 rs
Ethernet4 125,126,127,128 100000 1 9126 rs
Ethernet8 113,114,115,116 100000 2 9126 rs
Ethernet12 117,118,119,120 100000 3 9126 rs
Ethernet16 105,106,107,108 100000 4 9126 rs
Ethernet20 109,110,111,112 100000 5 9126 rs
Ethernet24 97,98,99,100 100000 6 9126 rs
Ethernet28 101,102,103,104 100000 7 9126 rs
Ethernet32 89,90,91,92 100000 8 9126 rs
Ethernet36 93,94,95,96 100000 9 9126 rs
Ethernet40 81,82,83,84 100000 10 9126 rs
Ethernet44 85,86,87,88 100000 11 9126 rs
Ethernet48 73,74,75,76 100000 12 9126 rs
Ethernet52 77,78,79,80 100000 13 9126 rs
Ethernet56 65,66,67,68 100000 14 9126 rs
Ethernet60 69,70,71,72 100000 15 9126 rs
Ethernet64 57,58,59,60 100000 16 9126 rs
Ethernet68 61,62,63,64 100000 17 9126 rs
Ethernet72 49,50,51,52 100000 18 9126 rs
Ethernet76 53,54,55,56 100000 19 9126 rs
Ethernet80 41,42,43,44 100000 20 9126 rs
Ethernet84 45,46,47,48 100000 21 9126 rs
Ethernet88 33,34,35,36 100000 22 9126 rs
Ethernet92 37,38,39,40 100000 23 9126 rs
Ethernet96 25,26,27,28 100000 24 9126 rs
Ethernet100 29,30,31,32 100000 25 9126 rs
Ethernet104 17,18,19,20 100000 26 9126 rs
Ethernet108 21,22,23,24 100000 27 9126 rs
Ethernet112 9,10,11,12 100000 28 9126 rs
Ethernet116 13,14,15,16 100000 29 9126 rs
Ethernet120 1,2,3,4 100000 30 9126 rs
Ethernet124 5,6,7,8 100000 31 9126 rs

View File

@ -0,0 +1,114 @@
{% set port_names_list = [] %}
{% for port in PORT %}
{%- if port_names_list.append(port) %}{% endif %}
{% endfor %}
{% set port_names = port_names_list | join(',') -%}
{
"TC_TO_QUEUE_MAP":{
"AZURE":{
"0":"0",
"1":"1",
"2":"2",
"3":"3",
"4":"4",
"5":"5",
"6":"6",
"7":"7"
}
},
"TC_TO_PRIORITY_GROUP_MAP": {
"AZURE": {
"0": "0",
"1": "0",
"2": "0",
"3": "3",
"4": "4",
"5": "0",
"6": "0",
"7": "0"
}
},
"DSCP_TO_TC_MAP": {
"AZURE": {
"0":"0",
"1":"0",
"2":"0",
"3":"3",
"4":"4",
"5":"0",
"6":"0",
"7":"0",
"8":"1",
"9":"0",
"10":"0",
"11":"0",
"12":"0",
"13":"0",
"14":"0",
"15":"0",
"16":"0",
"17":"0",
"18":"0",
"19":"0",
"20":"0",
"21":"0",
"22":"0",
"23":"0",
"24":"0",
"25":"0",
"26":"0",
"27":"0",
"28":"0",
"29":"0",
"30":"0",
"31":"0",
"32":"0",
"33":"0",
"34":"0",
"35":"0",
"36":"0",
"37":"0",
"38":"0",
"39":"0",
"40":"0",
"41":"0",
"42":"0",
"43":"0",
"44":"0",
"45":"0",
"46":"0",
"47":"0",
"48":"0",
"49":"0",
"50":"0",
"51":"0",
"52":"0",
"53":"0",
"54":"0",
"55":"0",
"56":"0",
"57":"0",
"58":"0",
"59":"0",
"60":"0",
"61":"0",
"62":"0",
"63":"0"
}
},
"PORT_QOS_MAP": {
"{{ port_names }}": {
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]",
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"pfc_enable": "3,4"
}
},
"WRED_PROFILE": {
"AZURE_LOSSLESS" : {
"red_min_threshold":"50000"
}
}
}

View File

@ -0,0 +1,118 @@
{% set port_names_list = [] %}
{% for port in PORT %}
{%- if port_names_list.append(port) %}{% endif %}
{% endfor %}
{% set port_names = port_names_list | join(',') -%}
{
"TC_TO_QUEUE_MAP":{
"AZURE":{
"0":"0",
"1":"1",
"2":"2",
"3":"3",
"4":"4",
"5":"5",
"6":"6",
"7":"7"
}
},
"TC_TO_PRIORITY_GROUP_MAP": {
"AZURE": {
"0": "0",
"1": "0",
"2": "0",
"3": "3",
"4": "4",
"5": "0",
"6": "0",
"7": "0"
}
},
"DSCP_TO_TC_MAP": {
"AZURE": {
"0":"0",
"1":"0",
"2":"0",
"3":"0",
"4":"0",
"5":"0",
"6":"0",
"7":"0",
"8":"0",
"9":"0",
"10":"0",
"11":"0",
"12":"0",
"13":"0",
"14":"0",
"15":"0",
"16":"0",
"17":"0",
"18":"0",
"19":"0",
"20":"0",
"21":"0",
"22":"0",
"23":"0",
"24":"0",
"25":"0",
"26":"0",
"27":"0",
"28":"0",
"29":"0",
"30":"0",
"31":"0",
"32":"0",
"33":"0",
"34":"0",
"35":"0",
"36":"0",
"37":"0",
"38":"0",
"39":"0",
"40":"0",
"41":"0",
"42":"0",
"43":"0",
"44":"0",
"45":"0",
"46":"0",
"47":"0",
"48":"0",
"49":"0",
"50":"0",
"51":"0",
"52":"0",
"53":"0",
"54":"0",
"55":"0",
"56":"0",
"57":"0",
"58":"0",
"59":"0",
"60":"0",
"61":"0",
"62":"0",
"63":"0"
}
},
"PORT_QOS_MAP": {
"{{ port_names }}": {
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]",
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]"
}
},
"SCHEDULER": {
"scheduler.7": {
"type": "STRICT"
}
},
"QUEUE": {
"{{ port_names }}|7": {
"scheduler": "[SCHEDULER|scheduler.7]"
}
}
}

View File

@ -0,0 +1,114 @@
{% set port_names_list = [] %}
{% for port in PORT %}
{%- if port_names_list.append(port) %}{% endif %}
{% endfor %}
{% set port_names = port_names_list | join(',') -%}
{
"TC_TO_QUEUE_MAP":{
"AZURE":{
"0":"0",
"1":"1",
"2":"2",
"3":"3",
"4":"4",
"5":"5",
"6":"6",
"7":"7"
}
},
"TC_TO_PRIORITY_GROUP_MAP": {
"AZURE": {
"0": "0",
"1": "0",
"2": "0",
"3": "3",
"4": "4",
"5": "0",
"6": "0",
"7": "0"
}
},
"DSCP_TO_TC_MAP": {
"AZURE": {
"0":"0",
"1":"0",
"2":"0",
"3":"3",
"4":"4",
"5":"0",
"6":"0",
"7":"0",
"8":"1",
"9":"0",
"10":"0",
"11":"0",
"12":"0",
"13":"0",
"14":"0",
"15":"0",
"16":"0",
"17":"0",
"18":"0",
"19":"0",
"20":"0",
"21":"0",
"22":"0",
"23":"0",
"24":"0",
"25":"0",
"26":"0",
"27":"0",
"28":"0",
"29":"0",
"30":"0",
"31":"0",
"32":"0",
"33":"0",
"34":"0",
"35":"0",
"36":"0",
"37":"0",
"38":"0",
"39":"0",
"40":"0",
"41":"0",
"42":"0",
"43":"0",
"44":"0",
"45":"0",
"46":"0",
"47":"0",
"48":"0",
"49":"0",
"50":"0",
"51":"0",
"52":"0",
"53":"0",
"54":"0",
"55":"0",
"56":"0",
"57":"0",
"58":"0",
"59":"0",
"60":"0",
"61":"0",
"62":"0",
"63":"0"
}
},
"PORT_QOS_MAP": {
"{{ port_names }}": {
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]",
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"pfc_enable": "3,4"
}
},
"WRED_PROFILE": {
"AZURE_LOSSLESS" : {
"red_min_threshold":"50000"
}
}
}

View File

@ -0,0 +1 @@
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/ivm.sai.config.yaml

View File

@ -0,0 +1 @@
aurora-715 t1

View File

@ -0,0 +1,3 @@
CONSOLE_PORT=0x3f8
CONSOLE_DEV=0
CONSOLE_SPEED=115200

View File

@ -0,0 +1,16 @@
#!/bin/sh
mr_reboot() {
sudo rmmod x86-64-netberg-aurora-715
sudo i2cset -y 0 0x30 0xa1 0
}
if [ $# -eq 0 ] || [ $@ = "-f" ] || [ $@ = "--force" ] || [ $@ = "reboot" ]; then
mr_reboot
elif [ $@ = "-p" ] ; then
sudo halt
else
echo "unsupported option"
fi

View File

@ -0,0 +1,14 @@
#!/usr/bin/env python
try:
from sonic_eeprom import eeprom_tlvinfo
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class board(eeprom_tlvinfo.TlvInfoDecoder):
_TLV_INFO_MAX_LEN = 256
def __init__(self, name, path, cpld_root, ro):
self.eeprom_path = "/sys/bus/i2c/devices/0-0030/eeprom"
super(board, self).__init__(self.eeprom_path, 0, '', True)

View File

@ -0,0 +1,95 @@
#
# psuutil.py
# Platform-specific PSU status interface for SONiC
#
import os.path
try:
from sonic_psu.psu_base import PsuBase
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
ATTR_PATH = '/sys/class/hwmon/hwmon2/device/NBA715_POWER/'
MAX_PSUS = 2
class PsuUtil(PsuBase):
"""Platform-specific PSUutil class"""
def __init__(self):
PsuBase.__init__(self)
# Get sysfs attribute
def get_attr_value(self, path):
retval = 'ERR'
if not os.path.isfile(path):
return retval
try:
with open(path, 'r') as file_d:
retval = file_d.read()
except IOError as error:
print("Unable to open ", path, " file !", str(error))
retval = retval.rstrip('\r\n')
return retval
def get_num_psus(self):
"""
Retrieves the number of PSUs available on the device
:return: An integer, the number of PSUs available on the device
"""
return MAX_PSUS
def get_psu_status(self, index):
"""
Retrieves the oprational status of power supply unit (PSU) defined
by index <index>
:param index: An integer, index of the PSU of which to query status
:return: Boolean, True if PSU is operating properly, False if PSU is\
faulty
"""
status = 0
attr_file = 'psu{}_good'.format(index)
status_path = ATTR_PATH + attr_file
try:
reg_file = open(status_path, 'r')
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False
text = reg_file.read()
if int(text) == 1:
status = 1
reg_file.close()
return status
def get_psu_presence(self, index):
"""
Retrieves the presence status of power supply unit (PSU) defined
by index <index>
:param index: An integer, index of the PSU of which to query status
:return: Boolean, True if PSU is plugged, False if not
"""
status = 0
attr_file = 'psu{}_prnt'.format(index)
presence_path = ATTR_PATH + attr_file
try:
reg_file = open(presence_path, 'r')
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False
text = reg_file.read()
if int(text) == 1:
status = 1
reg_file.close()
return status

View File

@ -0,0 +1,213 @@
#!/usr/bin/env python
import time
try:
from sonic_sfp.sfputilbase import SfpUtilBase
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
ATTR_PATH = '/sys/class/hwmon/hwmon2/device/'
SFP_GROUPS = {
'SFP-G01': {
"type": "QSFP28",
'number': 8,
'parent': 'PCA9548_0x71_1',
'channels': [0, 1, 2, 3, 4, 5, 6, 7],
'driver': 'optoe1',
'i2caddr': '0x50',
'paths': ["/sys/bus/i2c/devices/9-0050", "/sys/bus/i2c/devices/10-0050",
"/sys/bus/i2c/devices/11-0050", "/sys/bus/i2c/devices/12-0050",
"/sys/bus/i2c/devices/13-0050", "/sys/bus/i2c/devices/14-0050",
"/sys/bus/i2c/devices/15-0050", "/sys/bus/i2c/devices/16-0050"],
'status': 'NOTINST'
},
'SFP-G02': {
"type": "QSFP28",
'number': 8,
'parent': 'PCA9548_0x71_2',
'channels': [0, 1, 2, 3, 4, 5, 6, 7],
'driver': 'optoe1',
'i2caddr': '0x50',
'paths': ["/sys/bus/i2c/devices/17-0050", "/sys/bus/i2c/devices/18-0050",
"/sys/bus/i2c/devices/19-0050", "/sys/bus/i2c/devices/20-0050",
"/sys/bus/i2c/devices/21-0050", "/sys/bus/i2c/devices/22-0050",
"/sys/bus/i2c/devices/23-0050", "/sys/bus/i2c/devices/24-0050"],
'status': 'NOTINST'
},
'SFP-G03': {
"type": "QSFP28",
'number': 8,
'parent': 'PCA9548_0x71_3',
'channels': [0, 1, 2, 3, 4, 5, 6, 7],
'driver': 'optoe1',
'i2caddr': '0x50',
'paths': ["/sys/bus/i2c/devices/25-0050", "/sys/bus/i2c/devices/26-0050",
"/sys/bus/i2c/devices/27-0050", "/sys/bus/i2c/devices/28-0050",
"/sys/bus/i2c/devices/29-0050", "/sys/bus/i2c/devices/30-0050",
"/sys/bus/i2c/devices/31-0050", "/sys/bus/i2c/devices/32-0050"],
'status': 'NOTINST'
},
'SFP-G04': {
"type": "QSFP28",
'number': 8,
'parent': 'PCA9548_0x71_4',
'channels': [0, 1, 2, 3, 4, 5, 6, 7],
'driver': 'optoe1',
'i2caddr': '0x50',
'paths': ["/sys/bus/i2c/devices/33-0050", "/sys/bus/i2c/devices/34-0050",
"/sys/bus/i2c/devices/35-0050", "/sys/bus/i2c/devices/36-0050",
"/sys/bus/i2c/devices/37-0050", "/sys/bus/i2c/devices/38-0050",
"/sys/bus/i2c/devices/39-0050", "/sys/bus/i2c/devices/40-0050"],
'status': 'NOTINST'
}
}
QSFP_RESET_FILE = 'NBA715_QSFP/qsfp{}_reset'
QSFP_LOWPOWER_FILE = 'NBA715_QSFP/qsfp{}_low_power'
QSFP_PRESENT_FILE = 'NBA715_QSFP/qsfp{}_present'
class SfpUtil(SfpUtilBase):
"""Platform specific SfpUtill class"""
_port_start = 0
_port_end = 31
_port_in_block = 32
_port_to_eeprom_mapping = {}
_global_port_pres_dict = {}
def __init__(self):
eeprom_path = "{}/eeprom"
path_list = self.get_sfp_path()
for port_n in range(self._port_start, self._port_end + 1):
port_eeprom_path = eeprom_path.format(path_list[port_n])
self._port_to_eeprom_mapping[port_n] = port_eeprom_path
self.init_global_port_presence()
SfpUtilBase.__init__(self)
def get_sfp_path(self):
paths = []
for sfp_group in SFP_GROUPS:
paths += SFP_GROUPS[sfp_group]['paths']
return paths
def reset(self, port_num):
# Check for invalid port_num
if port_num < self._port_start or port_num > self._port_end:
return False
path = ATTR_PATH+QSFP_RESET_FILE.format(port_num+1)
try:
reg_file = open(path, 'w')
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False
reg_file.seek(0)
reg_file.write('1')
reg_file.close()
return True
def set_low_power_mode(self, port_num, lpmode):
# Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end:
return False
path = ATTR_PATH+QSFP_LOWPOWER_FILE.format(port_num+1)
try:
reg_file = open(path, 'w')
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False
# the gpio pin is ACTIVE_HIGH
if lpmode is True:
val = "1"
else:
val = "0"
# write value to gpio
reg_file.seek(0)
reg_file.write(val)
reg_file.close()
return True
def get_low_power_mode(self, port_num):
# Check for invalid port_num
if port_num < self._port_start or port_num > self._port_end:
return False
path = ATTR_PATH+QSFP_LOWPOWER_FILE.format(port_num+1)
try:
reg_file = open(path, 'r')
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False
text = reg_file.read()
reg_file.close()
return int(text) == 1
def get_presence(self, port_num):
# Check for invalid port_num
if port_num < self._port_start or port_num > self._port_end:
return False
path = ATTR_PATH+QSFP_PRESENT_FILE.format(port_num+1)
try:
reg_file = open(path, 'r')
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False
text = reg_file.read()
reg_file.close()
return int(text) == 1
def init_global_port_presence(self):
for port_num in range(self.port_start, (self.port_end + 1)):
presence = self.get_presence(port_num)
if presence:
self._global_port_pres_dict[port_num] = '1'
else:
self._global_port_pres_dict[port_num] = '0'
def get_transceiver_change_event(self, timeout=0):
port_dict = {}
while True:
for port_num in range(self.port_start, (self.port_end + 1)):
presence = self.get_presence(port_num)
if(presence and self._global_port_pres_dict[port_num] == '0'):
self._global_port_pres_dict[port_num] = '1'
port_dict[port_num] = '1'
elif(not presence and
self._global_port_pres_dict[port_num] == '1'):
self._global_port_pres_dict[port_num] = '0'
port_dict[port_num] = '0'
if len(port_dict) > 0:
return True, port_dict
time.sleep(1)
@property
def port_start(self):
return self._port_start
@property
def port_end(self):
return self._port_end
@property
def qsfp_ports(self):
return range(0, self._port_in_block + 1)
@property
def port_to_eeprom_mapping(self):
return self._port_to_eeprom_mapping

View File

@ -0,0 +1,4 @@
{
"skip_ledd": true,
"skip_thermalctld": true
}

View File

@ -0,0 +1,3 @@

View File

@ -0,0 +1 @@
t1

View File

@ -6,6 +6,7 @@ $(SONIC_ONE_IMAGE)_INSTALLS += $(SYSTEMD_SONIC_GENERATOR)
$(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie
$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CEL_MIDSTONE_200I_PLATFORM_MODULE)
$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELTA_PLATFORM_MODULE)
$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(NETBERG_AURORA_715_PLATFORM_MODULE)
$(SONIC_ONE_IMAGE)_INSTALLS += $(INVM_DRV)
$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES)
SONIC_INSTALLERS += $(SONIC_ONE_IMAGE)

View File

@ -0,0 +1,13 @@
# Netberg Platform modules
NETBERG_AURORA_715_PLATFORM_MODULE_VERSION = 1.0.0
export NETBERG_AURORA_715_PLATFORM_MODULE_VERSION
NETBERG_AURORA_715_PLATFORM_MODULE = sonic-platform-netberg-aurora-715_$(NETBERG_AURORA_715_PLATFORM_MODULE_VERSION)_amd64.deb
$(NETBERG_AURORA_715_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-netberg
$(NETBERG_AURORA_715_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
$(NETBERG_AURORA_715_PLATFORM_MODULE)_PLATFORM = x86_64-netberg_aurora_715-r0
SONIC_DPKG_DEBS += $(NETBERG_AURORA_715_PLATFORM_MODULE)
SONIC_STRETCH_DEBS +=$(NETBERG_AURORA_715_PLATFORM_MODULE)

View File

@ -1,6 +1,7 @@
include $(PLATFORM_PATH)/invm-sai.mk
include $(PLATFORM_PATH)/platform-modules-cel.mk
include $(PLATFORM_PATH)/platform-modules-delta.mk
include $(PLATFORM_PATH)/platform-modules-netberg.mk
include $(PLATFORM_PATH)/docker-syncd-invm.mk
include $(PLATFORM_PATH)/docker-syncd-invm-rpc.mk
include $(PLATFORM_PATH)/one-image.mk

View File

@ -0,0 +1,4 @@
obj-m := x86-64-netberg-aurora-715.o
x86-64-netberg-aurora-715-objs := x86-64-netberg-aurora-715-common.o x86-64-netberg-aurora-715-sys.o \
x86-64-netberg-aurora-715-led.o x86-64-netberg-aurora-715-fan.o x86-64-netberg-aurora-715-power.o \
x86-64-netberg-aurora-715-thermal.o x86-64-netberg-aurora-715-qsfp.o

View File

@ -0,0 +1,399 @@
/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#include "x86-64-netberg-aurora-715.h"
#include "x86-64-netberg-aurora-715-common.h"
/* Addresses scanned */
static const unsigned short normal_i2c[] = { 0x30, 0x31, 0x32, I2C_CLIENT_END };
static int debug = 0;
/* i2c_client Declaration */
struct i2c_client *Netberg_CPLD_30_client; //0x30 for SYS CPLD
struct i2c_client *Netberg_CPLD_31_client; //0x31 for Port 01-16
struct i2c_client *Netberg_CPLD_32_client; //0x32 for Port 17-32
struct i2c_client *Netberg_CPLD_23_client; //0x23 for Fan CPLD
struct i2c_client *Netberg_CPLD_35_client; //0x35 for Power CPLD
struct i2c_client *Netberg_BMC_14_client; //0x14 for BMC slave
struct i2c_client *Netberg_EEPROM_56_client; //0x56 for EEPROM
/* end of i2c_client Declaration */
/* register offset define */
#define BMC_EN_REG 0xA4
/* end of register offset define */
/* common function */
int bmc_enable(void)
{
if ((i2c_smbus_read_byte_data(Netberg_CPLD_30_client, BMC_EN_REG) & BIT_0_MASK) == 0x01)
{
return ENABLE;
}
else
{
return DISABLE;
}
}
int read_8bit_temp(u8 sign,u8 value)
{
int result = 0;
if(sign)
{
//printf("read_8bit_temp UP %d\n", value & 0x80);
value = ~(value)+1;
result = value;
return result;
}
else
{
//printf("read_8bit_temp DOWN %d\n", value & 0x80);
result = value;
return result;
}
}
/* end of common function*/
static int Netberg_i2c_probe(struct i2c_client *client, const struct i2c_device_id *dev_id)
{
struct Netberg_i2c_data *Netberg_CPLD_30_data;
struct Netberg_i2c_data *Netberg_CPLD_31_data;
struct Netberg_i2c_data *Netberg_CPLD_32_data;
struct Netberg_i2c_data *Netberg_CPLD_23_data;
struct Netberg_i2c_data *Netberg_CPLD_35_data;
struct Netberg_i2c_data *Netberg_BMC_14_data;
struct eeprom_data *Netberg_EEPROM_56_data;
int status;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
{
status = -EIO;
goto exit;
}
if (!(Netberg_CPLD_30_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL)))
{
printk(KERN_ALERT "kzalloc fail\n");
status = -ENOMEM;
goto exit;
}
if (!(Netberg_CPLD_31_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL)))
{
printk(KERN_ALERT "kzalloc fail\n");
status = -ENOMEM;
goto exit;
}
if (!(Netberg_CPLD_32_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL)))
{
printk(KERN_ALERT "kzalloc fail\n");
status = -ENOMEM;
goto exit;
}
if (!(Netberg_CPLD_23_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL)))
{
printk(KERN_ALERT "kzalloc fail\n");
status = -ENOMEM;
goto exit;
}
if (!(Netberg_CPLD_35_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL)))
{
printk(KERN_ALERT "kzalloc fail\n");
status = -ENOMEM;
goto exit;
}
if (!(Netberg_BMC_14_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL)))
{
printk(KERN_ALERT "kzalloc fail\n");
status = -ENOMEM;
goto exit;
}
if (!(Netberg_EEPROM_56_data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL)))
{
status = -ENOMEM;
goto exit;
}
memset(Netberg_EEPROM_56_data->data, 0xff, EEPROM_SIZE);
i2c_set_clientdata(Netberg_CPLD_30_client, Netberg_CPLD_30_data);
i2c_set_clientdata(Netberg_CPLD_31_client, Netberg_CPLD_31_data);
i2c_set_clientdata(Netberg_CPLD_32_client, Netberg_CPLD_32_data);
i2c_set_clientdata(Netberg_CPLD_23_client, Netberg_CPLD_23_data);
i2c_set_clientdata(Netberg_CPLD_35_client, Netberg_CPLD_35_data);
i2c_set_clientdata(Netberg_BMC_14_client , Netberg_BMC_14_data);
i2c_set_clientdata(Netberg_EEPROM_56_client, Netberg_EEPROM_56_data);
mutex_init(&Netberg_CPLD_30_data->update_lock);
mutex_init(&Netberg_CPLD_31_data->update_lock);
mutex_init(&Netberg_CPLD_32_data->update_lock);
mutex_init(&Netberg_CPLD_23_data->update_lock);
mutex_init(&Netberg_CPLD_35_data->update_lock);
mutex_init(&Netberg_BMC_14_data->update_lock);
mutex_init(&Netberg_EEPROM_56_data->update_lock);
Netberg_CPLD_30_data->valid = 0;
mutex_init(&Netberg_CPLD_30_data->update_lock);
dev_info(&client->dev, "chip found\n");
/* Register sysfs hooks */
status = sysfs_create_group(&client->dev.kobj, &NBA715_SYS_group);
if (status)
{
goto exit_free;
}
status = sysfs_create_group(&client->dev.kobj, &NBA715_LED_group);
if (status)
{
goto exit_free;
}
status = sysfs_create_group(&client->dev.kobj, &NBA715_FAN_group);
if (status)
{
goto exit_free;
}
status = sysfs_create_group(&client->dev.kobj, &NBA715_THERMAL_group);
if (status)
{
goto exit_free;
}
status = sysfs_create_group(&client->dev.kobj, &NBA715_POWER_group);
if (status)
{
goto exit_free;
}
status = sysfs_create_group(&client->dev.kobj, &NBA715_QSFP_group);
if (status)
{
goto exit_free;
}
/* create the sysfs eeprom file */
status = sysfs_create_bin_file(&client->dev.kobj, &net_eeprom_attr);
if (status) {
goto exit_free;
}
Netberg_CPLD_30_data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(Netberg_CPLD_30_data->hwmon_dev))
{
status = PTR_ERR(Netberg_CPLD_30_data->hwmon_dev);
goto exit_remove;
}
dev_info(&client->dev, "%s: '%s'\n", dev_name(Netberg_CPLD_30_data->hwmon_dev), client->name);
return 0;
exit_remove:
sysfs_remove_group(&client->dev.kobj, &NBA715_SYS_group);
sysfs_remove_group(&client->dev.kobj, &NBA715_LED_group);
sysfs_remove_group(&client->dev.kobj, &NBA715_FAN_group);
sysfs_remove_group(&client->dev.kobj, &NBA715_THERMAL_group);
sysfs_remove_group(&client->dev.kobj, &NBA715_POWER_group);
sysfs_remove_group(&client->dev.kobj, &NBA715_QSFP_group);
exit_free:
kfree(Netberg_CPLD_30_data);
kfree(Netberg_EEPROM_56_data);
exit:
return status;
}
static int Netberg_i2c_remove(struct i2c_client *client)
{
struct Netberg_i2c_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &NBA715_SYS_group);
sysfs_remove_group(&client->dev.kobj, &NBA715_LED_group);
sysfs_remove_group(&client->dev.kobj, &NBA715_FAN_group);
sysfs_remove_group(&client->dev.kobj, &NBA715_THERMAL_group);
sysfs_remove_group(&client->dev.kobj, &NBA715_POWER_group);
sysfs_remove_group(&client->dev.kobj, &NBA715_QSFP_group);
sysfs_remove_bin_file(&client->dev.kobj, &net_eeprom_attr);
kfree(data);
return 0;
}
static const struct i2c_device_id Netberg_i2c_id[] =
{
{ "Netberg_CPLD_30", 0 },
{},
};
MODULE_DEVICE_TABLE(i2c, Netberg_i2c_id);
static struct i2c_driver Netberg_i2c_driver =
{
.class = I2C_CLASS_HWMON,
.driver =
{
.name = "NBA_715_i2c",
},
.probe = Netberg_i2c_probe,
.remove = Netberg_i2c_remove,
.id_table = Netberg_i2c_id,
.address_list = normal_i2c,
};
/*For main Switch board*/
static struct i2c_board_info Netberg_CPLD_30_info[] __initdata =
{
{
I2C_BOARD_INFO("Netberg_CPLD_30", 0x30),
.platform_data = NULL,
},
};
/*For QSFP Port 01 - 16*/
static struct i2c_board_info Netberg_CPLD_31_info[] __initdata =
{
{
I2C_BOARD_INFO("Netberg_CPLD_31", 0x31),
.platform_data = NULL,
},
};
/*For QSFP Port 17 - 32*/
static struct i2c_board_info Netberg_CPLD_32_info[] __initdata =
{
{
I2C_BOARD_INFO("Netberg_CPLD_32", 0x32),
.platform_data = NULL,
},
};
/*For Fan status*/
static struct i2c_board_info Netberg_CPLD_23_info[] __initdata =
{
{
I2C_BOARD_INFO("Netberg_CPLD_23", 0x23),
.platform_data = NULL,
},
};
/*For Power status*/
static struct i2c_board_info Netberg_CPLD_35_info[] __initdata =
{
{
I2C_BOARD_INFO("Netberg_CPLD_35", 0x35),
.platform_data = NULL,
},
};
/*For BMC Slave*/
static struct i2c_board_info Netberg_BMC_14_info[] __initdata =
{
{
I2C_BOARD_INFO("Netberg_BMC_14", 0x14),
.platform_data = NULL,
},
};
static struct i2c_board_info Netberg_EEPROM_56_info[] __initdata =
{
{
I2C_BOARD_INFO("Netberg_EEPROM_56", 0x56),
.platform_data = NULL,
},
};
static int __init Netberg_i2c_init(void)
{
int ret;
int cmp;
char keyword[] = "SMBus I801";
char buf1[128];
struct i2c_adapter *i2c_adap;
struct file *fp;
mm_segment_t fs;
loff_t pos;
printk("Open file...\n");
fp = filp_open("/sys/class/i2c-dev/i2c-0/name", O_RDONLY , 0644);
if (IS_ERR(fp)) {
printk("Open file FAILED\n");
return -1;
}
fs = get_fs();
set_fs(KERNEL_DS);
pos = 0;
vfs_read(fp, buf1, sizeof(buf1), &pos);
printk("Detect %s\n", buf1);
cmp = strncmp(keyword, buf1, sizeof(keyword)-1);
set_fs(fs);
filp_close(fp, NULL);
if(cmp == 0)
{
i2c_adap = i2c_get_adapter(0);
printk("SMBus I801 is at bus 0\n");
}
else
{
i2c_adap = i2c_get_adapter(1);
printk("SMBus I801 is at bus 1\n");
}
if (i2c_adap == NULL)
{
printk("ERROR: i2c_get_adapter FAILED!\n");
return -1;
}
Netberg_CPLD_30_client = i2c_new_device(i2c_adap, &Netberg_CPLD_30_info[0]);
Netberg_CPLD_31_client = i2c_new_device(i2c_adap, &Netberg_CPLD_31_info[0]);
Netberg_CPLD_32_client = i2c_new_device(i2c_adap, &Netberg_CPLD_32_info[0]);
Netberg_CPLD_23_client = i2c_new_device(i2c_adap, &Netberg_CPLD_23_info[0]);
Netberg_CPLD_35_client = i2c_new_device(i2c_adap, &Netberg_CPLD_35_info[0]);
Netberg_BMC_14_client = i2c_new_device(i2c_adap, &Netberg_BMC_14_info[0]);
Netberg_EEPROM_56_client = i2c_new_device(i2c_adap, &Netberg_EEPROM_56_info[0]);
if (Netberg_CPLD_30_info == NULL || Netberg_CPLD_31_info == NULL || Netberg_CPLD_32_info == NULL
|| Netberg_CPLD_23_info == NULL || Netberg_CPLD_35_info == NULL || Netberg_BMC_14_info == NULL
|| Netberg_EEPROM_56_info == NULL)
{
printk("ERROR: i2c_new_device FAILED!\n");
return -1;
}
i2c_put_adapter(i2c_adap);
ret = i2c_add_driver(&Netberg_i2c_driver);
printk(KERN_ALERT "NBA715 i2c Driver Version: %s\n", DRIVER_VERSION);
printk(KERN_ALERT "NBA715 i2c Driver INSTALL SUCCESS\n");
return ret;
}
static void __exit Netberg_i2c_exit(void)
{
i2c_unregister_device(Netberg_CPLD_30_client);
i2c_unregister_device(Netberg_CPLD_31_client);
i2c_unregister_device(Netberg_CPLD_32_client);
i2c_unregister_device(Netberg_CPLD_23_client);
i2c_unregister_device(Netberg_CPLD_35_client);
i2c_unregister_device(Netberg_BMC_14_client);
i2c_unregister_device(Netberg_EEPROM_56_client);
i2c_del_driver(&Netberg_i2c_driver);
printk(KERN_ALERT "NBA715 i2c Driver UNINSTALL SUCCESS\n");
}
MODULE_AUTHOR("Netberg Inc.");
MODULE_DESCRIPTION("Netberg Aurora 715 i2c Driver");
MODULE_LICENSE("GPL");
module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "Enable debugging (0-1)");
module_init(Netberg_i2c_init);
module_exit(Netberg_i2c_exit);

View File

@ -0,0 +1,25 @@
/* register offset define */
#define ENABLE 1
#define DISABLE 0
#define PASSED 1
#define FAILED 0
#define TRUE 1
#define FALSE 0
#define ABNORMAL 1
#define NORMAL 0
#define BIT_0_MASK 0x01
#define BIT_1_MASK 0x02
#define BIT_2_MASK 0x04
#define BIT_3_MASK 0x08
#define BIT_4_MASK 0x10
#define BIT_5_MASK 0x20
#define BIT_6_MASK 0x40
#define BIT_7_MASK 0x80
/* end of register offset define */
int bmc_enable(void);
int read_8bit_temp(u8 sign,u8 value);

View File

@ -0,0 +1,365 @@
/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#include "x86-64-netberg-aurora-715.h"
#include "x86-64-netberg-aurora-715-common.h"
#include "x86-64-netberg-aurora-715-fan.h"
/* extern i2c_client */
extern struct i2c_client *Netberg_CPLD_23_client; //0x23 for Fan CPLD
extern struct i2c_client *Netberg_BMC_14_client; //0x14 for BMC slave
/* end of extern i2c_client */
/* implement i2c_function */
ssize_t fan_ctrl_mode_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_BMC_14_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
if (attr->index == FANCTRL_MODE)
{
if( bmc_enable() == ENABLE)
{
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, FANCTRL_MODE_REG);
if(status == 0xff || status < 0)
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
else
{
sprintf(buf, "%s0x%x\n", buf, status);
}
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
}
mutex_unlock(&data->update_lock);
return sprintf(buf, "%s\n", buf);
}
ssize_t fan_ctrl_rpm_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_BMC_14_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
if (attr->index == FANCTRL_RPM)
{
if( bmc_enable() == ENABLE)
{
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, FANCTRL_RPM_REG);
if(status == 0xff || status < 0)
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
else
{
sprintf(buf, "%s0x%x\n", buf, status);
}
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
}
mutex_unlock(&data->update_lock);
return sprintf(buf, "%s\n", buf);
}
ssize_t fan_status_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int result = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_23_data = i2c_get_clientdata(Netberg_CPLD_23_client);
struct Netberg_i2c_data *Netberg_BMC_14_data = i2c_get_clientdata(Netberg_BMC_14_client);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
mutex_lock(&Netberg_BMC_14_data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, BMC_FAN_STAT_REG);
mutex_unlock(&Netberg_BMC_14_data->update_lock);
}
else
{
mutex_lock(&Netberg_CPLD_23_data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_23_client, FAN_STAT_REG);
mutex_unlock(&Netberg_CPLD_23_data->update_lock);
}
result = FAILED;
switch (attr->index)
{
case 1:
if(status & BIT_0_MASK)
{
result = PASSED;
}
break;
case 2:
if(status & BIT_1_MASK)
{
result = PASSED;
}
break;
case 3:
if(status & BIT_2_MASK)
{
result = PASSED;
}
break;
case 4:
if(status & BIT_3_MASK)
{
result = PASSED;
}
break;
case 5:
if(status & BIT_4_MASK)
{
result = PASSED;
}
break;
}
if(result != PASSED)
{
return sprintf(buf, "%s%d\n", buf, FAILED);
}
return sprintf(buf, "%s%d\n", buf, PASSED);
}
ssize_t fan_present_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int result = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_23_data = i2c_get_clientdata(Netberg_CPLD_23_client);
struct Netberg_i2c_data *Netberg_BMC_14_data = i2c_get_clientdata(Netberg_BMC_14_client);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
mutex_lock(&Netberg_BMC_14_data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, BMC_FAN_PRESENT_REG);
mutex_unlock(&Netberg_BMC_14_data->update_lock);
}
else
{
mutex_lock(&Netberg_CPLD_23_data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_23_client, FAN_PRESENT_REG);
mutex_unlock(&Netberg_CPLD_23_data->update_lock);
}
result = FAILED;
switch (attr->index)
{
case 1:
if(status & BIT_0_MASK)
{
result = PASSED;
}
break;
case 2:
if(status & BIT_1_MASK)
{
result = PASSED;
}
break;
case 3:
if(status & BIT_2_MASK)
{
result = PASSED;
}
break;
case 4:
if(status & BIT_3_MASK)
{
result = PASSED;
}
break;
case 5:
if(status & BIT_4_MASK)
{
result = PASSED;
}
break;
}
if(result != PASSED)
{
return sprintf(buf, "%s%d\n", buf, FAILED);
}
return sprintf(buf, "%s%d\n", buf, PASSED);
}
ssize_t fan_power_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int result = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_23_data = i2c_get_clientdata(Netberg_CPLD_23_client);
struct Netberg_i2c_data *Netberg_BMC_14_data = i2c_get_clientdata(Netberg_BMC_14_client);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
mutex_lock(&Netberg_BMC_14_data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, BMC_FAN_POWER_REG);
mutex_unlock(&Netberg_BMC_14_data->update_lock);
}
else
{
mutex_lock(&Netberg_CPLD_23_data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_23_client, FAN_POWER_REG);
mutex_unlock(&Netberg_CPLD_23_data->update_lock);
}
result = FAILED;
switch (attr->index)
{
case 1:
if(status & BIT_0_MASK)
{
result = PASSED;
}
break;
case 2:
if(status & BIT_1_MASK)
{
result = PASSED;
}
break;
case 3:
if(status & BIT_2_MASK)
{
result = PASSED;
}
break;
case 4:
if(status & BIT_3_MASK)
{
result = PASSED;
}
break;
case 5:
if(status & BIT_4_MASK)
{
result = PASSED;
}
break;
}
if(result != PASSED)
{
return sprintf(buf, "%s%d\n", buf, FAILED);
}
return sprintf(buf, "%s%d\n", buf, PASSED);
}
ssize_t fan_rpm_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int fan_location = 0;
int fan_offset = 0;
u16 fan_speed = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct i2c_client *target_client = NULL;
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
target_client = Netberg_BMC_14_client;
}
else
{
target_client = Netberg_CPLD_23_client;
}
switch (attr->index)
{
case FAN1_FRONT_RPM:
fan_location = 0;
fan_offset = 0;
break;
case FAN2_FRONT_RPM:
fan_location = 0;
fan_offset = 1;
break;
case FAN3_FRONT_RPM:
fan_location = 0;
fan_offset = 2;
break;
case FAN4_FRONT_RPM:
fan_location = 0;
fan_offset = 3;
break;
case FAN5_FRONT_RPM:
fan_location = 0;
fan_offset = 4;
break;
case FAN1_REAR_RPM:
fan_location = 1;
fan_offset = 0;
break;
case FAN2_REAR_RPM:
fan_location = 1;
fan_offset = 1;
break;
case FAN3_REAR_RPM:
fan_location = 1;
fan_offset = 2;
break;
case FAN4_REAR_RPM:
fan_location = 1;
fan_offset = 3;
break;
case FAN5_REAR_RPM:
fan_location = 1;
fan_offset = 4;
break;
}
if(fan_location == 0)
{
// front fan of couple
// read high byte
status = i2c_smbus_read_byte_data(target_client, FAN_F_RPM_REG+(fan_offset*2)+1);
fan_speed = status;
if(status < 0 || status == 0xff)
{
fan_speed = 0;
}
// read low byte
status = i2c_smbus_read_byte_data(target_client, FAN_F_RPM_REG+(fan_offset*2));
fan_speed = ((fan_speed<<8) + status)*30;
if(status < 0 || status == 0xff)
{
fan_speed = 0;
}
}
else
{
// rear fan of couple
// read high byte
status = i2c_smbus_read_byte_data(target_client, FAN_R_RPM_REG+(fan_offset*2)+1);
fan_speed = status;
if(status < 0 || status == 0xff)
{
fan_speed = 0;
}
// read low byte
status = i2c_smbus_read_byte_data(target_client, FAN_R_RPM_REG+(fan_offset*2));
fan_speed = ((fan_speed<<8) + status)*30;
if(status < 0 || status == 0xff)
{
fan_speed = 0;
}
}
sprintf(buf, "%s%d\n", buf, fan_speed);
return sprintf(buf, "%s\n",buf);
}
/* end of implement i2c_function */

View File

@ -0,0 +1,12 @@
/* register offset define */
#define FANCTRL_RPM_REG 0x1a
#define FANCTRL_MODE_REG 0x1b
#define FAN_STAT_REG 0x00
#define FAN_POWER_REG 0x01
#define FAN_PRESENT_REG 0x02
#define BMC_FAN_STAT_REG 0x80
#define BMC_FAN_POWER_REG 0x81
#define BMC_FAN_PRESENT_REG 0x82
#define FAN_F_RPM_REG 0xa0
#define FAN_R_RPM_REG 0xb0
/* end of register offset define */

View File

@ -0,0 +1,220 @@
/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#include "x86-64-netberg-aurora-715.h"
#include "x86-64-netberg-aurora-715-common.h"
#include "x86-64-netberg-aurora-715-led.h"
/* i2c_client Declaration */
extern struct i2c_client *Netberg_CPLD_30_client; //0x30 for SYS CPLD
/* end of i2c_client Declaration */
/* implement i2c_function */
ssize_t led_ctrl_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int res = 0x1;
int i;
int led_a_status = 0;
int led_g_status = 0;
int led_b_status = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_CTRL_REG);
sprintf(buf, "");
for (i = 1; i <= 4; i++)
{
if ( i == attr->index)
{
if (status & res)
{
led_a_status = ENABLE;
}
else
{
led_a_status = DISABLE;
}
}
res = res << 1;
if( i == (attr->index + 1) )
{
if (status & res)
{
led_g_status = ENABLE;
}
else
{
led_g_status = DISABLE;
}
}
res = res << 1;
}
res = 0x1;
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_BLINK_REG);
for (i = 1; i <= 4; i++)
{
if ( i == attr->index)
{
if (status & res)
{
led_b_status = ENABLE;
}
else
{
led_b_status = DISABLE;
}
}
res = res << 1;
}
if(led_a_status == ENABLE && led_b_status == ENABLE)
{
sprintf(buf, "%s2\n", buf);
}
else if(led_a_status == ENABLE && led_b_status == DISABLE)
{
sprintf(buf, "%s1\n", buf);
}
else if(led_g_status == ENABLE && led_b_status == ENABLE)
{
sprintf(buf, "%s4\n", buf);
}
else if(led_g_status == ENABLE && led_b_status == DISABLE)
{
sprintf(buf, "%s3\n", buf);
}
else
{
sprintf(buf, "%s0\n", buf);
}
return sprintf(buf, "%s", buf);
}
ssize_t led_ctrl_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int led_value = -EPERM;
int blk_value = -EPERM;
int result = -EPERM;
int offset = 0;
u16 i;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
led_value = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_CTRL_REG);
blk_value = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_BLINK_REG);
if (attr->index != 0)
{
i = simple_strtol(buf, NULL, 10);
if(attr->index == 1)
{
offset = 0;
}
else
{
offset = 2*((attr->index)-1);
}
switch(i)
{
case SWITCH_LED_OFF: //i=0
led_value &= ~(0x03 << offset);
blk_value &= ~(1 << ((attr->index)-1));
break;
case SWITCH_LED_A_N: //i=1
led_value &= ~(0x03 << offset);
led_value |= (0x01 << offset);
blk_value &= ~(1 << ((attr->index)-1));
break;
case SWITCH_LED_A_B: //i=2
led_value &= ~(0x03 << offset);
led_value |= (0x01 << offset);
blk_value |= (1 << ((attr->index)-1));
break;
case SWITCH_LED_G_N: //i=3
led_value &= ~(0x03 << offset);
led_value |= (0x02 << offset);
blk_value &= ~(1 << ((attr->index)-1));
break;
case SWITCH_LED_G_B: //i=4
led_value &= ~(0x03 << offset);
led_value |= (0x02 << offset);
blk_value |= (1 << ((attr->index)-1));
break;
default:
printk(KERN_ALERT "led_ctrl_set wrong Value\n");
return count;
}
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, LED_CTRL_REG, led_value);
result |= i2c_smbus_write_byte_data(Netberg_CPLD_30_client, LED_BLINK_REG, blk_value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: led_ctrl_set FAILED!\n");
}
}
mutex_unlock(&data->update_lock);
return count;
}
ssize_t led_fiber_get(struct device *dev, struct device_attribute *da, char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
if (attr->index == LED_FIBER)
{
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_FIBER_REG) & BIT_0_MASK)
{
sprintf(buf, "%s%d\n", buf, ENABLE);
}
else
{
sprintf(buf, "%s%d\n", buf, DISABLE);
}
}
mutex_unlock(&data->update_lock);
return sprintf(buf, "%s\n", buf);
}
ssize_t led_fiber_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int value = -EPERM;
int result = -EPERM;
int input;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_CTRL_REG);
if (attr->index == LED_FIBER)
{
input = simple_strtol(buf, NULL, 10);
if (input == ENABLE)
{
value = status | LED_FIBER_ENABLE;
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, LED_FIBER_REG, value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: led_ctrl_set FAILED!\n");
}
}
else if (input == DISABLE)
{
value = status & LED_FIBER_DISABLE;
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, LED_FIBER_REG, value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: led_ctrl_set FAILED!\n");
}
}
else
{
printk(KERN_ALERT "led_ctrl_set wrong Value\n");
}
}
mutex_unlock(&data->update_lock);
return count;
}
/* end of implement i2c_function */

View File

@ -0,0 +1,12 @@
/* register offset define */
#define LED_CTRL_REG 0xa2
#define LED_BLINK_REG 0xa3
#define LED_FIBER_REG 0xa0
#define LED_FIBER_ENABLE 0x01
#define LED_FIBER_DISABLE 0xfe
#define SWITCH_LED_OFF 0
#define SWITCH_LED_A_N 1
#define SWITCH_LED_A_B 2
#define SWITCH_LED_G_N 3
#define SWITCH_LED_G_B 4
/* end of register offset define */

View File

@ -0,0 +1,650 @@
/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#include "x86-64-netberg-aurora-715.h"
#include "x86-64-netberg-aurora-715-common.h"
#include "x86-64-netberg-aurora-715-power.h"
/* extern i2c_client */
extern struct i2c_client *Netberg_CPLD_35_client; //0x35 for Power CPLD
extern struct i2c_client *Netberg_BMC_14_client; //0x14 for BMC slave
/* end of extern i2c_client */
/* convert function */
static int two_complement_to_int(u16 data, u8 valid_bit, int mask)
{
u16 valid_data = data & mask;
bool is_negative = valid_data >> (valid_bit - 1);
return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data;
}
/* end of convert function */
/* implement i2c_function */
ssize_t psu_status_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
u32 result = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_35_data = i2c_get_clientdata(Netberg_CPLD_35_client);
struct Netberg_i2c_data *Netberg_BMC_14_data = i2c_get_clientdata(Netberg_BMC_14_client);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
mutex_lock(&Netberg_BMC_14_data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, BMC_PSU_STAT_REG);
mutex_unlock(&Netberg_BMC_14_data->update_lock);
}
else
{
mutex_lock(&Netberg_CPLD_35_data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_35_client, PSU_STAT_REG);
mutex_unlock(&Netberg_CPLD_35_data->update_lock);
}
result = TRUE;
switch (attr->index)
{
case 1:
if(status & BIT_2_MASK)
{
result = FALSE;
}
break;
case 2:
if(status & BIT_3_MASK)
{
result = FALSE;
}
break;
}
if(result != TRUE)
{
return sprintf(buf, "%s%d\n", buf, FALSE);
}
return sprintf(buf, "%s%d\n", buf, TRUE);
}
ssize_t psu_present_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
u32 result = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_35_data = i2c_get_clientdata(Netberg_CPLD_35_client);
struct Netberg_i2c_data *Netberg_BMC_14_data = i2c_get_clientdata(Netberg_BMC_14_client);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
mutex_lock(&Netberg_BMC_14_data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, BMC_PSU_STAT_REG);
mutex_unlock(&Netberg_BMC_14_data->update_lock);
}
else
{
mutex_lock(&Netberg_CPLD_35_data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_35_client, PSU_STAT_REG);
mutex_unlock(&Netberg_CPLD_35_data->update_lock);
}
result = FALSE;
switch (attr->index)
{
case 1:
if(status & BIT_0_MASK)
{
result = TRUE;
}
break;
case 2:
if(status & BIT_1_MASK)
{
result = TRUE;
}
break;
}
if(result != TRUE)
{
return sprintf(buf, "%s%d\n", buf, FALSE);
}
return sprintf(buf, "%s%d\n", buf, TRUE);
}
ssize_t psu_vin_get(struct device *dev, struct device_attribute *da, char *buf)
{
u32 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_VIN:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_VIN_REG);
break;
case PSU2_VIN:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_VIN_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1000;
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t psu_iin_get(struct device *dev, struct device_attribute *da, char *buf)
{
u32 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_IIN:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_IIN_REG);
break;
case PSU2_IIN:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_IIN_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1000;
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t psu_vout_get(struct device *dev, struct device_attribute *da, char *buf)
{
u32 result = -EPERM;
int exponent = 0;
int multiplier = 1000;
u16 u16_vmode = 0;
u16 u16_vout = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_VOUT:
u16_vmode = i2c_smbus_read_byte_data(Netberg_BMC_14_client, PSU_1_VOMDE_REG);
u16_vout = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_VOUT_REG);
break;
case PSU2_VOUT:
u16_vmode = i2c_smbus_read_byte_data(Netberg_BMC_14_client, PSU_2_VOMDE_REG);
u16_vout = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_VOUT_REG);
break;
}
if(u16_vout == 0xffff || u16_vout == -1)
{
return sprintf(buf, "%s0\n", buf);
}
/* vout mode */
multiplier = 1000;
exponent = two_complement_to_int(u16_vmode & 0x1f, 5, 0x1f);
/* vout */
result = (exponent >= 0) ? ((u16_vout << exponent)*multiplier) : \
(u16_vout*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t psu_iout_get(struct device *dev, struct device_attribute *da, char *buf)
{
u32 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_IOUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_IOUT_REG);
break;
case PSU2_IOUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_IOUT_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1000;
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t psu_temp_get(struct device *dev, struct device_attribute *da, char *buf)
{
u16 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_TEMP:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_TEMP_1_REG);
break;
case PSU2_TEMP:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_TEMP_1_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1000;
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t psu_fan_get(struct device *dev, struct device_attribute *da, char *buf)
{
u16 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_FAN_SPEED:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_FAN_SPEED_REG);
break;
case PSU2_FAN_SPEED:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_FAN_SPEED_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1;
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t psu_pout_get(struct device *dev, struct device_attribute *da, char *buf)
{
u32 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_POUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_POUT_REG);
break;
case PSU2_POUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_POUT_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1000000; // lm-sensor unit: uW
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t psu_pin_get(struct device *dev, struct device_attribute *da, char *buf)
{
u32 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_PIN:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_PIN_REG);
break;
case PSU2_PIN:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_PIN_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1000000; // lm-sensor unit: uW
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t psu_mfr_model_get(struct device *dev, struct device_attribute *da, char *buf)
{
u16 u16_val = 0;
char model[2];
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_MFR_MODEL:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_MFR_MODEL_REG);
break;
case PSU2_MFR_MODEL:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_MFR_MODEL_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
model[0] = u16_val >> 8;
model[1] = u16_val;
sprintf(buf, "%s%c%c\n", buf, model[0], model[1]);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t psu_iout_max_get(struct device *dev, struct device_attribute *da, char *buf)
{
u32 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_MFR_IOUT_MAX:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_MFR_IOUT_MAX_REG);
break;
case PSU2_MFR_IOUT_MAX:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_MFR_IOUT_MAX_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1000; // lm-sensor unit: uW
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t psu_vmode_get(struct device *dev, struct device_attribute *da, char *buf)
{
u16 u16_vmode = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case PSU1_VOMDE:
u16_vmode = i2c_smbus_read_byte_data(Netberg_BMC_14_client, PSU_1_VOMDE_REG);
break;
case PSU2_VOMDE:
u16_vmode = i2c_smbus_read_byte_data(Netberg_BMC_14_client, PSU_2_VOMDE_REG);
break;
}
if(u16_vmode == 0xffff || u16_vmode == -1)
{
return sprintf(buf, "%s0\n", buf);
}
/* vout mode */
sprintf(buf, "%s%d\n", buf, u16_vmode);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t dc_vout_get(struct device *dev, struct device_attribute *da, char *buf)
{
u16 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case DC6E_P0_VOUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P0_VOUT_REG);
break;
case DC6E_P1_VOUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P1_VOUT_REG);
break;
case DC70_P0_VOUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P0_VOUT_REG);
break;
case DC70_P1_VOUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P1_VOUT_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1000;
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t dc_iout_get(struct device *dev, struct device_attribute *da, char *buf)
{
u16 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case DC6E_P0_IOUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P0_IOUT_REG);
break;
case DC6E_P1_IOUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P1_IOUT_REG);
break;
case DC70_P0_IOUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P0_IOUT_REG);
break;
case DC70_P1_IOUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P1_IOUT_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1000;
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t dc_pout_get(struct device *dev, struct device_attribute *da, char *buf)
{
u16 result = -EPERM;
int exponent = 0, mantissa = 0;
int multiplier = 1000;
u16 u16_val = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch(attr->index)
{
case DC6E_P0_POUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P0_POUT_REG);
break;
case DC6E_P1_POUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P1_POUT_REG);
break;
case DC70_P0_POUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P0_POUT_REG);
break;
case DC70_P1_POUT:
u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P1_POUT_REG);
break;
}
if(u16_val == 0xffff || u16_val == -1)
{
return sprintf(buf, "%s0\n", buf);
}
exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f);
mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff);
multiplier = 1000000;
result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \
(mantissa*multiplier / (1 << -exponent));
sprintf(buf, "%s%d\n", buf, result);
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
/* end of implement i2c_function */

View File

@ -0,0 +1,38 @@
/* register offset define */
#define PSU_STAT_REG 0xa0
#define BMC_PSU_STAT_REG 0xc0
#define PSU_1_VIN_REG 0x50
#define PSU_1_IIN_REG 0x51
#define PSU_1_VOUT_REG 0x52
#define PSU_1_IOUT_REG 0x53
#define PSU_1_TEMP_1_REG 0x54
#define PSU_1_FAN_SPEED_REG 0x55
#define PSU_1_POUT_REG 0x56
#define PSU_1_PIN_REG 0x57
#define PSU_1_MFR_MODEL_REG 0x58
#define PSU_1_MFR_IOUT_MAX_REG 0x59
#define PSU_1_VOMDE_REG 0x5a
#define PSU_2_VIN_REG 0x60
#define PSU_2_IIN_REG 0x61
#define PSU_2_VOUT_REG 0x62
#define PSU_2_IOUT_REG 0x63
#define PSU_2_TEMP_1_REG 0x64
#define PSU_2_FAN_SPEED_REG 0x65
#define PSU_2_POUT_REG 0x66
#define PSU_2_PIN_REG 0x67
#define PSU_2_MFR_MODEL_REG 0x68
#define PSU_2_MFR_IOUT_MAX_REG 0x69
#define PSU_2_VOMDE_REG 0x6a
#define DC_CHIP_6E_P0_VOUT_REG 0x90
#define DC_CHIP_6E_P0_IOUT_REG 0x91
#define DC_CHIP_6E_P0_POUT_REG 0x92
#define DC_CHIP_6E_P1_VOUT_REG 0x94
#define DC_CHIP_6E_P1_IOUT_REG 0x95
#define DC_CHIP_6E_P1_POUT_REG 0x96
#define DC_CHIP_70_P0_VOUT_REG 0x98
#define DC_CHIP_70_P0_IOUT_REG 0x99
#define DC_CHIP_70_P0_POUT_REG 0x9a
#define DC_CHIP_70_P1_VOUT_REG 0x9c
#define DC_CHIP_70_P1_IOUT_REG 0x9d
#define DC_CHIP_70_P1_POUT_REG 0x9e
/* end of register offset define */

View File

@ -0,0 +1,584 @@
/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#include "x86-64-netberg-aurora-715.h"
#include "x86-64-netberg-aurora-715-common.h"
#include "x86-64-netberg-aurora-715-qsfp.h"
/* i2c_client Declaration */
extern struct i2c_client *Netberg_CPLD_31_client; //0x31 for Port 01-16
extern struct i2c_client *Netberg_CPLD_32_client; //0x32 for Port 17-32
/* end of i2c_client Declaration */
/* extern i2c_function */
/* end of extern i2c_function */
/* implement i2c_function */
ssize_t qsfp_low_power_all_get(struct device *dev, struct device_attribute *da, char *buf)
{
u8 status = -EPERM;
u32 result = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
if (attr->index == QSFP_LOW_POWER_ALL)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_REAR_LOW_POWER_REG); //25-32
result = status;
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_FRONT_LOW_POWER_REG); //17-24
result = (result << 8) | status;
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_REAR_LOW_POWER_REG); //9-16
result = (result << 8) | status;
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_FRONT_LOW_POWER_REG); //1-8
result = (result << 8) | status;
sprintf(buf, "%s0x%x\n", buf, result);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t qsfp_low_power_all_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int value = 0x0;
int result = 0;
int input = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client);
struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client);
mutex_lock(&Netberg_CPLD_31_data->update_lock);
mutex_lock(&Netberg_CPLD_32_data->update_lock);
if (attr->index == QSFP_LOW_POWER_ALL)
{
input = simple_strtol(buf, NULL, 10);
if (input == ENABLE)
{
value = 0xff;
}
else if(input == DISABLE)
{
value = 0x00;
}
else
{
printk(KERN_ALERT "qsfp_low_power_all_set wrong value\n");
return count;
}
result += i2c_smbus_write_byte_data(Netberg_CPLD_31_client, QSFP_FRONT_LOW_POWER_REG, value);
result += i2c_smbus_write_byte_data(Netberg_CPLD_31_client, QSFP_REAR_LOW_POWER_REG, value);
result += i2c_smbus_write_byte_data(Netberg_CPLD_32_client, QSFP_FRONT_LOW_POWER_REG, value);
result += i2c_smbus_write_byte_data(Netberg_CPLD_32_client, QSFP_REAR_LOW_POWER_REG, value);
if(result != 0)
{
printk(KERN_ALERT "qsfp_low_power_all_set FAILED\n");
return count;
}
}
mutex_unlock(&Netberg_CPLD_31_data->update_lock);
mutex_unlock(&Netberg_CPLD_32_data->update_lock);
return count;
}
ssize_t qsfp_low_power_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int port_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
port_index = attr->index;
sprintf(buf, "");
if (port_index >= 1 && port_index <= 16)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_low_power_regs[port_index][0]);
}
else if (port_index >= 17 && port_index <= 32)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_low_power_regs[port_index][0]);
}
if (status & qsfp_low_power_regs[port_index][1])
{
sprintf(buf, "%s%d\n", buf, ENABLE);
}
else
{
sprintf(buf, "%s%d\n", buf, DISABLE);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t qsfp_low_power_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int result = 0;
int input = 0;
int port_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client);
struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client);
struct i2c_client *target_client = NULL;
port_index = attr->index;
input = simple_strtol(buf, NULL, 10);
mutex_lock(&Netberg_CPLD_31_data->update_lock);
mutex_lock(&Netberg_CPLD_32_data->update_lock);
if (port_index >= 1 && port_index <= 16)
{
target_client = Netberg_CPLD_31_client;
}
else if (port_index >= 17 && port_index <= 32)
{
target_client = Netberg_CPLD_32_client;
}
status = i2c_smbus_read_byte_data(target_client, qsfp_low_power_regs[port_index][0]);
if( input == ENABLE)
{
status |= qsfp_low_power_regs[port_index][1];
result = i2c_smbus_write_byte_data(target_client, qsfp_low_power_regs[port_index][0], status);
if (result < 0)
{
printk(KERN_ALERT "ERROR: qsfp_low_power_set ON FAILED!\n");
}
}
else if( input == DISABLE)
{
status &= ~(qsfp_low_power_regs[port_index][1]);
result = i2c_smbus_write_byte_data(target_client, qsfp_low_power_regs[port_index][0], status);
if (result < 0)
{
printk(KERN_ALERT "ERROR: qsfp_low_power_set OFF FAILED!\n");
}
}
else
{
printk(KERN_ALERT "ERROR: qsfp_low_power_set WRONG VALUE\n");
}
mutex_unlock(&Netberg_CPLD_31_data->update_lock);
mutex_unlock(&Netberg_CPLD_32_data->update_lock);
return count;
}
ssize_t qsfp_reset_all_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int value = 0x0;
int result = 0;
int input = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client);
struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client);
mutex_lock(&Netberg_CPLD_31_data->update_lock);
mutex_lock(&Netberg_CPLD_32_data->update_lock);
if (attr->index == QSFP_RESET_ALL)
{
input = simple_strtol(buf, NULL, 10);
if (input == QSFP_RESET)
{
value = 0x00;
}
else
{
printk(KERN_ALERT "qsfp_reset_all_set wrong value\n");
return count;
}
result += i2c_smbus_write_byte_data(Netberg_CPLD_31_client, QSFP_FRONT_RESET_REG, value);
result += i2c_smbus_write_byte_data(Netberg_CPLD_31_client, QSFP_REAR_RESET_REG, value);
result += i2c_smbus_write_byte_data(Netberg_CPLD_32_client, QSFP_FRONT_RESET_REG, value);
result += i2c_smbus_write_byte_data(Netberg_CPLD_32_client, QSFP_REAR_RESET_REG, value);
if(result != 0)
{
printk(KERN_ALERT "qsfp_reset_all_set FAILED\n");
return count;
}
}
mutex_unlock(&Netberg_CPLD_31_data->update_lock);
mutex_unlock(&Netberg_CPLD_32_data->update_lock);
return count;
}
ssize_t qsfp_reset_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int result = 0;
int input = 0;
int port_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client);
struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client);
struct i2c_client *target_client = NULL;
port_index = attr->index;
input = simple_strtol(buf, NULL, 10);
mutex_lock(&Netberg_CPLD_31_data->update_lock);
mutex_lock(&Netberg_CPLD_32_data->update_lock);
if (port_index >= 1 && port_index <= 16)
{
target_client = Netberg_CPLD_31_client;
}
else if (port_index >= 17 && port_index <= 32)
{
target_client = Netberg_CPLD_32_client;
}
status = i2c_smbus_read_byte_data(target_client, qsfp_reset_regs[port_index][0]);
if( input == QSFP_RESET)
{
status |= qsfp_reset_regs[port_index][1];
result = i2c_smbus_write_byte_data(target_client, qsfp_reset_regs[port_index][0], status);
if (result < 0)
{
printk(KERN_ALERT "ERROR: qsfp_reset_set FAILED!\n");
}
}
else
{
printk(KERN_ALERT "ERROR: qsfp_reset_set WRONG VALUE\n");
}
mutex_unlock(&Netberg_CPLD_31_data->update_lock);
mutex_unlock(&Netberg_CPLD_32_data->update_lock);
return count;
}
ssize_t qsfp_present_all_get(struct device *dev, struct device_attribute *da, char *buf)
{
u8 status = -EPERM;
u32 result = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
if (attr->index == QSFP_PRESENT_ALL)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_REAR_PRESENT_REG); //25-32
result = status;
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_FRONT_PRESENT_REG); //17-24
result = (result << 8) | status;
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_REAR_PRESENT_REG); //9-16
result = (result << 8) | status;
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_FRONT_PRESENT_REG); //1-8
result = (result << 8) | status;
result = ~(result);
sprintf(buf, "%s0x%x\n", buf, result);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t qsfp_present_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int port_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
port_index = attr->index;
sprintf(buf, "");
if (port_index >= 1 && port_index <= 16)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_present_regs[port_index][0]);
}
else if (port_index >= 17 && port_index <= 32)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_present_regs[port_index][0]);
}
if (status & qsfp_present_regs[port_index][1])
{
sprintf(buf, "%s%d\n", buf, DISABLE);
}
else
{
sprintf(buf, "%s%d\n", buf, ENABLE);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t qsfp_int_all_get(struct device *dev, struct device_attribute *da, char *buf)
{
u8 status = -EPERM;
u32 result = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
if (attr->index == QSFP_INT_ALL)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_REAR_INT_REG); //25-32
result = status;
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_FRONT_INT_REG); //17-24
result = (result << 8) | status;
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_REAR_INT_REG); //9-16
result = (result << 8) | status;
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_FRONT_INT_REG); //1-8
result = (result << 8) | status;
sprintf(buf, "%s0x%x\n", buf, result);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t qsfp_int_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int port_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
port_index = attr->index;
sprintf(buf, "");
if (port_index >= 1 && port_index <= 16)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_int_regs[port_index][0]);
}
else if (port_index >= 17 && port_index <= 32)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_int_regs[port_index][0]);
}
if (status & qsfp_int_regs[port_index][1])
{
sprintf(buf, "%s%d\n", buf, ENABLE);
}
else
{
sprintf(buf, "%s%d\n", buf, DISABLE);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t qsfp_quter_int_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int quter_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
quter_index = attr->index;
sprintf(buf, "");
if (quter_index >= 1 && quter_index <= 2)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_quter_int_regs[quter_index][0]);
}
else if (quter_index >= 3 && quter_index <= 4)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_quter_int_regs[quter_index][0]);
}
if (status & qsfp_quter_int_regs[quter_index][1])
{
sprintf(buf, "%s%d\n", buf, NORMAL);
}
else
{
sprintf(buf, "%s%d\n", buf, ABNORMAL);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t qsfp_quter_int_mask_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int quter_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
quter_index = attr->index;
sprintf(buf, "");
if (quter_index >= 1 && quter_index <= 2)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_quter_int_mask_regs[quter_index][0]);
}
else if (quter_index >= 3 && quter_index <= 4)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_quter_int_mask_regs[quter_index][0]);
}
if (status & qsfp_quter_int_mask_regs[quter_index][1])
{
sprintf(buf, "%s%d\n", buf, DISABLE);
}
else
{
sprintf(buf, "%s%d\n", buf, ENABLE);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t qsfp_quter_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int result = 0;
int input = 0;
int quter_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client);
struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client);
struct i2c_client *target_client = NULL;
quter_index = attr->index;
input = simple_strtol(buf, NULL, 10);
mutex_lock(&Netberg_CPLD_31_data->update_lock);
mutex_lock(&Netberg_CPLD_32_data->update_lock);
if (quter_index >= 1 && quter_index <= 2)
{
target_client = Netberg_CPLD_31_client;
}
else if (quter_index >= 3 && quter_index <= 4)
{
target_client = Netberg_CPLD_32_client;
}
status = i2c_smbus_read_byte_data(target_client, qsfp_quter_int_mask_regs[quter_index][0]);
if( input == DISABLE)
{
status |= qsfp_quter_int_mask_regs[quter_index][1];
result = i2c_smbus_write_byte_data(target_client, qsfp_quter_int_mask_regs[quter_index][0], status);
if (result < 0)
{
printk(KERN_ALERT "ERROR: qsfp_quter_int_mask_set ON FAILED!\n");
}
}
else if( input == ENABLE)
{
status &= ~(qsfp_quter_int_mask_regs[quter_index][1]);
result = i2c_smbus_write_byte_data(target_client, qsfp_quter_int_mask_regs[quter_index][0], status);
if (result < 0)
{
printk(KERN_ALERT "ERROR: qsfp_quter_int_mask_set OFF FAILED!\n");
}
}
else
{
printk(KERN_ALERT "ERROR: qsfp_quter_int_mask_set WRONG VALUE\n");
}
mutex_unlock(&Netberg_CPLD_31_data->update_lock);
mutex_unlock(&Netberg_CPLD_32_data->update_lock);
return count;
}
ssize_t qsfp_modprs_int_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int quter_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
quter_index = attr->index;
sprintf(buf, "");
if (quter_index >= 1 && quter_index <= 2)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_modprs_int_regs[quter_index][0]);
}
else if (quter_index >= 3 && quter_index <= 4)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_modprs_int_regs[quter_index][0]);
}
if (status & qsfp_modprs_int_regs[quter_index][1])
{
sprintf(buf, "%s%d\n", buf, NORMAL);
}
else
{
sprintf(buf, "%s%d\n", buf, ABNORMAL);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t qsfp_modprs_int_mask_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
int quter_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
quter_index = attr->index;
sprintf(buf, "");
if (quter_index >= 1 && quter_index <= 2)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_modprs_int_mask_regs[quter_index][0]);
}
else if (quter_index >= 3 && quter_index <= 4)
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_modprs_int_mask_regs[quter_index][0]);
}
if (status & qsfp_modprs_int_mask_regs[quter_index][1])
{
sprintf(buf, "%s%d\n", buf, DISABLE);
}
else
{
sprintf(buf, "%s%d\n", buf, ENABLE);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t qsfp_modprs_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int result = 0;
int input = 0;
int quter_index = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client);
struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client);
struct i2c_client *target_client = NULL;
quter_index = attr->index;
input = simple_strtol(buf, NULL, 10);
mutex_lock(&Netberg_CPLD_31_data->update_lock);
mutex_lock(&Netberg_CPLD_32_data->update_lock);
if (quter_index >= 1 && quter_index <= 2)
{
target_client = Netberg_CPLD_31_client;
}
else if (quter_index >= 3 && quter_index <= 4)
{
target_client = Netberg_CPLD_32_client;
}
status = i2c_smbus_read_byte_data(target_client, qsfp_modprs_int_mask_regs[quter_index][0]);
if( input == DISABLE)
{
status |= qsfp_modprs_int_mask_regs[quter_index][1];
result = i2c_smbus_write_byte_data(target_client, qsfp_modprs_int_mask_regs[quter_index][0], status);
if (result < 0)
{
printk(KERN_ALERT "ERROR: qsfp_modprs_int_mask_set ON FAILED!\n");
}
}
else if( input == ENABLE)
{
status &= ~(qsfp_modprs_int_mask_regs[quter_index][1]);
result = i2c_smbus_write_byte_data(target_client, qsfp_modprs_int_mask_regs[quter_index][0], status);
if (result < 0)
{
printk(KERN_ALERT "ERROR: qsfp_modprs_int_mask_set OFF FAILED!\n");
}
}
else
{
printk(KERN_ALERT "ERROR: qsfp_modprs_int_mask_set WRONG VALUE\n");
}
mutex_unlock(&Netberg_CPLD_31_data->update_lock);
mutex_unlock(&Netberg_CPLD_32_data->update_lock);
return count;
}
/* end of implement i2c_function */

View File

@ -0,0 +1,187 @@
/* register offset define */
#define QSFP_FRONT_LOW_POWER_REG 0x60
#define QSFP_REAR_LOW_POWER_REG 0x61
#define QSFP_FRONT_RESET_REG 0x70
#define QSFP_REAR_RESET_REG 0x71
#define QSFP_FRONT_PRESENT_REG 0x80
#define QSFP_REAR_PRESENT_REG 0x81
#define QSFP_FRONT_INT_REG 0x90
#define QSFP_REAR_INT_REG 0x91
#define QSFP_RESET 1
unsigned char qsfp_low_power_regs[33][2] = {
{0x00, 0x00}, //cpld offset, bit mask
{0x60, 0x01},
{0x60, 0x02},
{0x60, 0x04},
{0x60, 0x08},
{0x60, 0x10},
{0x60, 0x20},
{0x60, 0x40},
{0x60, 0x80},
{0x61, 0x01},
{0x61, 0x02},
{0x61, 0x04},
{0x61, 0x08},
{0x61, 0x10},
{0x61, 0x20},
{0x61, 0x40},
{0x61, 0x80},
{0x60, 0x01},
{0x60, 0x02},
{0x60, 0x04},
{0x60, 0x08},
{0x60, 0x10},
{0x60, 0x20},
{0x60, 0x40},
{0x60, 0x80},
{0x61, 0x01},
{0x61, 0x02},
{0x61, 0x04},
{0x61, 0x08},
{0x61, 0x10},
{0x61, 0x20},
{0x61, 0x40},
{0x61, 0x80}
};
unsigned char qsfp_reset_regs[33][2] = {
{0x00, 0x00}, //cpld offset, bit mask
{0x70, 0x01},
{0x70, 0x02},
{0x70, 0x04},
{0x70, 0x08},
{0x70, 0x10},
{0x70, 0x20},
{0x70, 0x40},
{0x70, 0x80},
{0x71, 0x01},
{0x71, 0x02},
{0x71, 0x04},
{0x71, 0x08},
{0x71, 0x10},
{0x71, 0x20},
{0x71, 0x40},
{0x71, 0x80},
{0x70, 0x01},
{0x70, 0x02},
{0x70, 0x04},
{0x70, 0x08},
{0x70, 0x10},
{0x70, 0x20},
{0x70, 0x40},
{0x70, 0x80},
{0x71, 0x01},
{0x71, 0x02},
{0x71, 0x04},
{0x71, 0x08},
{0x71, 0x10},
{0x71, 0x20},
{0x71, 0x40},
{0x71, 0x80}
};
unsigned char qsfp_present_regs[33][2] = {
{0x00, 0x00}, //cpld offset, bit mask
{0x80, 0x01},
{0x80, 0x02},
{0x80, 0x04},
{0x80, 0x08},
{0x80, 0x10},
{0x80, 0x20},
{0x80, 0x40},
{0x80, 0x80},
{0x81, 0x01},
{0x81, 0x02},
{0x81, 0x04},
{0x81, 0x08},
{0x81, 0x10},
{0x81, 0x20},
{0x81, 0x40},
{0x81, 0x80},
{0x80, 0x01},
{0x80, 0x02},
{0x80, 0x04},
{0x80, 0x08},
{0x80, 0x10},
{0x80, 0x20},
{0x80, 0x40},
{0x80, 0x80},
{0x81, 0x01},
{0x81, 0x02},
{0x81, 0x04},
{0x81, 0x08},
{0x81, 0x10},
{0x81, 0x20},
{0x81, 0x40},
{0x81, 0x80}
};
unsigned char qsfp_int_regs[33][2] = {
{0x00, 0x00}, //cpld offset, bit mask
{0x90, 0x01},
{0x90, 0x02},
{0x90, 0x04},
{0x90, 0x08},
{0x90, 0x10},
{0x90, 0x20},
{0x90, 0x40},
{0x90, 0x80},
{0x91, 0x01},
{0x91, 0x02},
{0x91, 0x04},
{0x91, 0x08},
{0x91, 0x10},
{0x91, 0x20},
{0x91, 0x40},
{0x91, 0x80},
{0x90, 0x01},
{0x90, 0x02},
{0x90, 0x04},
{0x90, 0x08},
{0x90, 0x10},
{0x90, 0x20},
{0x90, 0x40},
{0x90, 0x80},
{0x91, 0x01},
{0x91, 0x02},
{0x91, 0x04},
{0x91, 0x08},
{0x91, 0x10},
{0x91, 0x20},
{0x91, 0x40},
{0x91, 0x80}
};
unsigned char qsfp_quter_int_regs[5][2] = {
{0x00, 0x00}, //cpld offset, bit mask
{0xd0, 0x04},
{0xd0, 0x08},
{0xd0, 0x04},
{0xd0, 0x08}
};
unsigned char qsfp_quter_int_mask_regs[5][2] = {
{0x00, 0x00}, //cpld offset, bit mask
{0xd1, 0x04},
{0xd1, 0x08},
{0xd1, 0x04},
{0xd1, 0x08}
};
unsigned char qsfp_modprs_int_regs[5][2] = {
{0x00, 0x00}, //cpld offset, bit mask
{0xd0, 0x01},
{0xd0, 0x02},
{0xd0, 0x01},
{0xd0, 0x02}
};
unsigned char qsfp_modprs_int_mask_regs[5][2] = {
{0x00, 0x00}, //cpld offset, bit mask
{0xd1, 0x01},
{0xd1, 0x02},
{0xd1, 0x01},
{0xd1, 0x02}
};
/* end of register offset define */

View File

@ -0,0 +1,864 @@
/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#include "x86-64-netberg-aurora-715.h"
#include "x86-64-netberg-aurora-715-common.h"
#include "x86-64-netberg-aurora-715-sys.h"
/* extern i2c_client */
extern struct i2c_client *Netberg_CPLD_30_client; //0x30 for SYS CPLD
extern struct i2c_client *Netberg_CPLD_31_client; //0x31 for Port 01-16
extern struct i2c_client *Netberg_CPLD_32_client; //0x32 for Port 17-32
extern struct i2c_client *Netberg_CPLD_23_client; //0x23 for Fan CPLD
extern struct i2c_client *Netberg_BMC_14_client; //0x14 for BMC slave
extern struct i2c_client *Netberg_EEPROM_56_client; //0x56 for EEPROM slave
/* end of extern i2c_client */
/* implement i2c_function */
ssize_t cpld_hw_ver_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
switch (attr->index)
{
case 23:
if( bmc_enable() == ENABLE)
{
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, 0xff);
}
else
{
status = i2c_smbus_read_byte_data(Netberg_CPLD_23_client, CPLD_VER_REG);
}
case 30:
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, CPLD_VER_REG);
case 31:
status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, CPLD_VER_REG);
case 32:
status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, CPLD_VER_REG);
}
if(status < 0)
{
mutex_unlock(&data->update_lock);
return status;
}
else
{
mutex_unlock(&data->update_lock);
sprintf(buf, "%s0x%x\n", buf, status);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t wdt_enable_get(struct device *dev, struct device_attribute *da, char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
if (attr->index == WDT_EN)
{
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, WDT_EN_REG) & BIT_4_MASK)
{
sprintf(buf, "%s%d\n", buf, ENABLE);
}
else
{
sprintf(buf, "%s%d\n", buf, DISABLE);
}
}
mutex_unlock(&data->update_lock);
return sprintf(buf, "%s\n", buf);
}
ssize_t wdt_enable_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int value = -EPERM;
int result = -EPERM;
int input;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, WDT_EN_REG);
if (attr->index == WDT_EN)
{
input = simple_strtol(buf, NULL, 10);
if (input == ENABLE)
{
value = status | WDT_EN_ENABLE;
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, WDT_EN_REG, value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: wdt_enable_set FAILED!\n");
}
}
else if (input == DISABLE)
{
value = status & WDT_EN_DISABLE;
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, WDT_EN_REG, value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: wdt_enable_set FAILED!\n");
}
}
else
{
printk(KERN_ALERT "wdt_enable_set wrong Value\n");
}
}
mutex_unlock(&data->update_lock);
return count;
}
ssize_t eeprom_wp_get(struct device *dev, struct device_attribute *da, char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
if (attr->index == EEPROM_WP)
{
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, EEPROM_WP_REG) & BIT_2_MASK)
{
sprintf(buf, "%s%d\n", buf, ENABLE);
}
else
{
sprintf(buf, "%s%d\n", buf, DISABLE);
}
}
mutex_unlock(&data->update_lock);
return sprintf(buf, "%s\n", buf);
}
ssize_t eeprom_wp_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int value = -EPERM;
int result = -EPERM;
int input;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, EEPROM_WP_REG);
if (attr->index == EEPROM_WP)
{
input = simple_strtol(buf, NULL, 10);
if (input == ENABLE)
{
value = status | EEPROM_WP_ENABLE;
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, EEPROM_WP_REG, value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: eeprom_wp_set FAILED!\n");
}
}
else if (input == DISABLE)
{
value = status & EEPROM_WP_DISABLE;
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, EEPROM_WP_REG, value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: eeprom_wp_set FAILED!\n");
}
}
else
{
printk(KERN_ALERT "eeprom_wp_set wrong Value\n");
}
}
mutex_unlock(&data->update_lock);
return count;
}
static void net_eeprom_update_client(struct i2c_client *client, u8 slice)
{
struct eeprom_data *data = i2c_get_clientdata(client);
int i, j;
int ret;
int addr;
mutex_lock(&data->update_lock);
if (!(data->valid & (1 << slice)) ||
time_after(jiffies, data->last_updated[slice] + 300 * HZ)) {
dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice);
addr = slice << SLICE_BITS;
ret = i2c_smbus_write_byte_data(client, ((u8)addr >> 8) & 0xFF, (u8)addr & 0xFF);
/* select the eeprom address */
if (ret < 0) {
dev_err(&client->dev, "address set failed\n");
goto exit;
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) {
goto exit;
}
for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) {
for (j = i; j < (i+SLICE_SIZE); j++) {
int res;
res = i2c_smbus_read_byte(client);
if (res < 0) {
goto exit;
}
data->data[j] = res & 0xFF;
}
}
data->last_updated[slice] = jiffies;
data->valid |= (1 << slice);
}
exit:
mutex_unlock(&data->update_lock);
}
ssize_t net_eeprom_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
/* struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); */
struct eeprom_data *data = i2c_get_clientdata(Netberg_EEPROM_56_client);
u8 slice;
if (off > EEPROM_SIZE) {
return 0;
}
if (off + count > EEPROM_SIZE) {
count = EEPROM_SIZE - off;
}
if (count == 0) {
return 0;
}
/* Only refresh slices which contain requested bytes */
for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) {
net_eeprom_update_client(Netberg_EEPROM_56_client, slice);
}
memcpy(buf, &data->data[off], count);
return count;
}
ssize_t usb_enable_get(struct device *dev, struct device_attribute *da, char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
if (attr->index == USB_EN)
{
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, USB_EN_REG) & BIT_2_MASK)
{
sprintf(buf, "%s%d\n", buf, ENABLE);
}
else
{
sprintf(buf, "%s%d\n", buf, DISABLE);
}
}
mutex_unlock(&data->update_lock);
return sprintf(buf, "%s\n", buf);
}
ssize_t usb_enable_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int value = -EPERM;
int result = -EPERM;
int input;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, USB_EN_REG);
if (attr->index == USB_EN)
{
input = simple_strtol(buf, NULL, 10);
if (input == ENABLE)
{
value = status | USB_EN_ENABLE;
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, USB_EN_REG, value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: usb_enable_set FAILED!\n");
}
}
else if (input == DISABLE)
{
value = status & USB_EN_DISABLE;
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, USB_EN_REG, value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: usb_enable_set FAILED!\n");
}
}
else
{
printk(KERN_ALERT "usb_enable_set wrong Value\n");
}
}
mutex_unlock(&data->update_lock);
return count;
}
ssize_t reset_mac_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int value = -EPERM;
int result = -EPERM;
int input;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, MAC_RESET_REG);
if (attr->index == RESET)
{
input = simple_strtol(buf, NULL, 10);
if (input == MAC_RESET)
{
value = MAC_RESET;
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, MAC_RESET_REG, value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: reset_mac_set FAILED!\n");
}
}
else
{
printk(KERN_ALERT "reset_mac_set wrong Value\n");
}
}
mutex_unlock(&data->update_lock);
return count;
}
ssize_t shutdown_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int value = -EPERM;
int result = -EPERM;
int input;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SHUTDOWN_REG);
if (attr->index == SHUTDOWN_SET)
{
input = simple_strtol(buf, NULL, 10);
if (input == SHUTDOWN)
{
value = status | SHUTDOWN;
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, SHUTDOWN_REG, value);
if (result < 0)
{
printk(KERN_ALERT "ERROR: shutdown_set FAILED!\n");
}
}
else
{
printk(KERN_ALERT "shutdown_set wrong Value\n");
}
}
mutex_unlock(&data->update_lock);
return count;
}
ssize_t bmc_enable_get(struct device *dev, struct device_attribute *da, char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
if (attr->index == BMC_PRESENT)
{
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, BMC_EN_REG) & BIT_0_MASK)
{
sprintf(buf, "%s%d\n", buf, ENABLE);
}
else
{
sprintf(buf, "%s%d\n", buf, DISABLE);
}
}
mutex_unlock(&data->update_lock);
return sprintf(buf, "%s\n", buf);
}
ssize_t themal_int_get(struct device *dev, struct device_attribute *da, char *buf)
{
int result = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
switch (attr->index)
{
case TEMP_R_B_INT:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_REG) & BIT_0_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case TEMP_L_B_INT:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_REG) & BIT_1_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case TEMP_L_T_INT:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_REG) & BIT_2_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case TEMP_R_T_INT:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_REG) & BIT_3_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
}
mutex_unlock(&data->update_lock);
sprintf(buf, "%s%d\n", buf, result);
return sprintf(buf, "%s\n", buf);
}
ssize_t themal_int_mask_get(struct device *dev, struct device_attribute *da, char *buf)
{
int result = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
switch (attr->index)
{
case TEMP_R_B_INT_MASK:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG) & BIT_0_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case TEMP_L_B_INT_MASK:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG) & BIT_1_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case TEMP_L_T_INT_MASK:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG) & BIT_2_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case TEMP_R_T_INT_MASK:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG) & BIT_3_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
}
mutex_unlock(&data->update_lock);
sprintf(buf, "%s%d\n", buf, result);
return sprintf(buf, "%s\n", buf);
}
ssize_t themal_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int value = -EPERM;
int result = -EPERM;
int input;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG);
input = simple_strtol(buf, NULL, 10);
switch (attr->index)
{
case TEMP_R_B_INT_MASK:
if (input == ENABLE)
{
value = status | 0x01;
}
else if (input == DISABLE)
{
value = status & 0xfe;
}
else
{
printk(KERN_ALERT "themal_int_mask_set wrong Value\n");
return count;
}
break;
case TEMP_L_B_INT_MASK:
if (input == ENABLE)
{
value = status | 0x02;
}
else if (input == DISABLE)
{
value = status & 0xfd;
}
else
{
printk(KERN_ALERT "themal_int_mask_set wrong Value\n");
return count;
}
break;
case TEMP_L_T_INT_MASK:
if (input == ENABLE)
{
value = status | 0x04;
}
else if (input == DISABLE)
{
value = status & 0xfb;
}
else
{
printk(KERN_ALERT "themal_int_mask_set wrong Value\n");
return count;
}
break;
case TEMP_R_T_INT_MASK:
if (input == ENABLE)
{
value = status | 0x08;
}
else if (input == DISABLE)
{
value = status & 0xf7;
}
else
{
printk(KERN_ALERT "themal_int_mask_set wrong Value\n");
return count;
}
break;
}
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG, value);
mutex_unlock(&data->update_lock);
return count;
}
ssize_t sys_int_get(struct device *dev, struct device_attribute *da, char *buf)
{
int result = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
switch (attr->index)
{
case CPLD_FP_INT:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_2_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case CPLD_RP_INT:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_3_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case CPLD_FAN_INT:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_4_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case CPLD_PSU_INT:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_5_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case THERMAL_INT:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_6_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case USB_INT:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_7_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
}
mutex_unlock(&data->update_lock);
sprintf(buf, "%s%d\n", buf, result);
return sprintf(buf, "%s\n", buf);
}
ssize_t sys_int_mask_get(struct device *dev, struct device_attribute *da, char *buf)
{
int result = 0;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
sprintf(buf, "");
switch (attr->index)
{
case CPLD_FP_INT_MASK:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_2_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case CPLD_RP_INT_MASK:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_3_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case CPLD_FAN_INT_MASK:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_4_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case CPLD_PSU_INT_MASK:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_5_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case THERMAL_INT_MASK:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_6_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
case USB_INT_MASK:
if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_7_MASK)
{
result = ENABLE;
}
else
{
result = DISABLE;
}
break;
}
mutex_unlock(&data->update_lock);
sprintf(buf, "%s%d\n", buf, result);
return sprintf(buf, "%s\n", buf);
}
ssize_t sys_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
int status = -EPERM;
int value = -EPERM;
int result = -EPERM;
int input;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client);
mutex_lock(&data->update_lock);
status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG);
input = simple_strtol(buf, NULL, 10);
switch (attr->index)
{
case CPLD_FP_INT_MASK:
if (input == ENABLE)
{
value = status | 0x02;
}
else if (input == DISABLE)
{
value = status & 0xfd;
}
else
{
printk(KERN_ALERT "sys_int_mask_set wrong Value\n");
return count;
}
break;
case CPLD_RP_INT_MASK:
if (input == ENABLE)
{
value = status | 0x04;
}
else if (input == DISABLE)
{
value = status & 0xfb;
}
else
{
printk(KERN_ALERT "sys_int_mask_set wrong Value\n");
return count;
}
break;
case CPLD_FAN_INT_MASK:
if (input == ENABLE)
{
value = status | 0x08;
}
else if (input == DISABLE)
{
value = status & 0xf7;
}
else
{
printk(KERN_ALERT "sys_int_mask_set wrong Value\n");
return count;
}
break;
case CPLD_PSU_INT_MASK:
if (input == ENABLE)
{
value = status | 0x10;
}
else if (input == DISABLE)
{
value = status & 0xef;
}
else
{
printk(KERN_ALERT "sys_int_mask_set wrong Value\n");
return count;
}
break;
case THERMAL_INT_MASK:
if (input == ENABLE)
{
value = status | 0x20;
}
else if (input == DISABLE)
{
value = status & 0xdf;
}
else
{
printk(KERN_ALERT "sys_int_mask_set wrong Value\n");
return count;
}
break;
case USB_INT_MASK:
if (input == ENABLE)
{
value = status | 0x40;
}
else if (input == DISABLE)
{
value = status & 0xbf;
}
else
{
printk(KERN_ALERT "sys_int_mask_set wrong Value\n");
return count;
}
break;
}
result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG, value);
mutex_unlock(&data->update_lock);
return count;
}
/* end of implement i2c_function */

View File

@ -0,0 +1,23 @@
/* register offset define */
#define CPLD_VER_REG 0x20
#define WDT_EN_REG 0xa0
#define WDT_EN_ENABLE 0x10
#define WDT_EN_DISABLE 0xef
#define EEPROM_WP_REG 0xa0
#define EEPROM_WP_ENABLE 0x04
#define EEPROM_WP_DISABLE 0xfB
#define USB_EN_REG 0xa0
#define USB_EN_ENABLE 0x02
#define USB_EN_DISABLE 0xfD
#define MAC_RESET_REG 0xa1
#define MAC_RESET 0x00
#define SHUTDOWN_REG 0xa1
#define SHUTDOWN 0x10
#define BMC_EN_REG 0xa4
#define BMC_EN_ENABLE 0x01
#define BMC_EN_DISABLE 0x00
#define THERMAL_INT_REG 0xc0
#define THERMAL_INT_MASK_REG 0xc1
#define SYS_INT_REG 0xd0
#define SYS_INT_MASK_REG 0xd1
/* end of register offset define */

View File

@ -0,0 +1,271 @@
/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#include "x86-64-netberg-aurora-715.h"
#include "x86-64-netberg-aurora-715-common.h"
#include "x86-64-netberg-aurora-715-thermal.h"
/* extern i2c_client */
extern struct i2c_client *Netberg_BMC_14_client; //0x14 for BMC slave
/* end of extern i2c_client */
/* implement i2c_function */
ssize_t themal_temp_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch (attr->index)
{
case TEMP_R_B_F:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_F_REG);
break;
case TEMP_R_B_B:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_B_REG);
break;
case TEMP_L_B_F:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_F_REG);
break;
case TEMP_L_B_B:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_B_REG);
break;
case TEMP_R_T_F:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_F_REG);
break;
case TEMP_R_T_B:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_B_REG);
break;
case TEMP_L_T_F:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_F_REG);
break;
case TEMP_L_T_B:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_B_REG);
break;
}
if(status == 0xff || status < 0)
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
else
{
sprintf(buf, "%s%d\n", buf, (read_8bit_temp((status & 0x80), status))*1000);
}
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t themal_temp_max_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch (attr->index)
{
case TEMP_R_B_F_MAX:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_F_MAX_REG);
break;
case TEMP_L_B_F_MAX:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_F_MAX_REG);
break;
case TEMP_R_T_F_MAX:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_F_MAX_REG);
break;
case TEMP_L_T_F_MAX:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_F_MAX_REG);
break;
case TEMP_R_B_B_MAX:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_B_MAX_REG);
break;
case TEMP_L_B_B_MAX:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_B_MAX_REG);
break;
case TEMP_R_T_B_MAX:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_B_MAX_REG);
break;
case TEMP_L_T_B_MAX:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_B_MAX_REG);
break;
}
if(status == 0xff || status < 0)
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
else
{
sprintf(buf, "%s%d\n", buf, (read_8bit_temp((status & 0x80), status))*1000);
}
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t themal_temp_min_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch (attr->index)
{
case TEMP_R_B_F_MIN:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_F_MIN_REG);
break;
case TEMP_L_B_F_MIN:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_F_MIN_REG);
break;
case TEMP_R_T_F_MIN:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_F_MIN_REG);
break;
case TEMP_L_T_F_MIN:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_F_MIN_REG);
break;
case TEMP_R_B_B_MIN:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_B_MIN_REG);
break;
case TEMP_L_B_B_MIN:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_B_MIN_REG);
break;
case TEMP_R_T_B_MIN:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_B_MIN_REG);
break;
case TEMP_L_T_B_MIN:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_B_MIN_REG);
break;
}
if(status == 0xff || status < 0)
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
else
{
sprintf(buf, "%s%d\n", buf, (read_8bit_temp((status & 0x80), status))*1000);
}
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t themal_temp_crit_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch (attr->index)
{
case TEMP_R_B_F_CRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_F_CRIT_REG);
break;
case TEMP_L_B_F_CRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_F_CRIT_REG);
break;
case TEMP_R_T_F_CRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_F_CRIT_REG);
break;
case TEMP_L_T_F_CRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_F_CRIT_REG);
break;
case TEMP_R_B_B_CRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_B_CRIT_REG);
break;
case TEMP_L_B_B_CRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_B_CRIT_REG);
break;
case TEMP_R_T_B_CRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_B_CRIT_REG);
break;
case TEMP_L_T_B_CRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_B_CRIT_REG);
break;
}
if(status == 0xff || status < 0)
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
else
{
sprintf(buf, "%s%d\n", buf, (read_8bit_temp((status & 0x80), status))*1000);
}
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
ssize_t themal_temp_lcrit_get(struct device *dev, struct device_attribute *da, char *buf)
{
int status = -EPERM;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
sprintf(buf, "");
if( bmc_enable() == ENABLE)
{
switch (attr->index)
{
case TEMP_R_B_F_LCRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_F_LCRIT_REG);
break;
case TEMP_L_B_F_LCRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_F_LCRIT_REG);
break;
case TEMP_R_T_F_LCRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_F_LCRIT_REG);
break;
case TEMP_L_T_F_LCRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_F_LCRIT_REG);
break;
case TEMP_R_B_B_LCRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_B_LCRIT_REG);
break;
case TEMP_L_B_B_LCRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_B_LCRIT_REG);
break;
case TEMP_R_T_B_LCRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_B_LCRIT_REG);
break;
case TEMP_L_T_B_LCRIT:
status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_B_LCRIT_REG);
break;
}
if(status == 0xff || status < 0)
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
else
{
sprintf(buf, "%s%d\n", buf, (read_8bit_temp((status & 0x80), status))*1000);
}
}
else
{
sprintf(buf, "%sAccess BMC module FAILED\n", buf);
}
return sprintf(buf, "%s\n", buf);
}
/* end of implement i2c_function */

View File

@ -0,0 +1,45 @@
/* register offset define */
#define TEMP_R_B_F_REG 0x10
#define TEMP_R_B_B_REG 0x11
#define TEMP_R_B_F_MAX_REG 0x12
#define TEMP_R_B_F_MIN_REG 0x13
#define TEMP_R_B_F_CRIT_REG 0x14
#define TEMP_R_B_F_LCRIT_REG 0x15
#define TEMP_R_B_B_MAX_REG 0x16
#define TEMP_R_B_B_MIN_REG 0x17
#define TEMP_R_B_B_CRIT_REG 0x18
#define TEMP_R_B_B_LCRIT_REG 0x19
#define TEMP_L_B_F_REG 0x20
#define TEMP_L_B_B_REG 0x21
#define TEMP_L_B_F_MAX_REG 0x22
#define TEMP_L_B_F_MIN_REG 0x23
#define TEMP_L_B_F_CRIT_REG 0x24
#define TEMP_L_B_F_LCRIT_REG 0x25
#define TEMP_L_B_B_MAX_REG 0x26
#define TEMP_L_B_B_MIN_REG 0x27
#define TEMP_L_B_B_CRIT_REG 0x28
#define TEMP_L_B_B_LCRIT_REG 0x29
#define TEMP_R_T_F_REG 0x30
#define TEMP_R_T_B_REG 0x31
#define TEMP_R_T_F_MAX_REG 0x32
#define TEMP_R_T_F_MIN_REG 0x33
#define TEMP_R_T_F_CRIT_REG 0x34
#define TEMP_R_T_F_LCRIT_REG 0x35
#define TEMP_R_T_B_MAX_REG 0x36
#define TEMP_R_T_B_MIN_REG 0x37
#define TEMP_R_T_B_CRIT_REG 0x38
#define TEMP_R_T_B_LCRIT_REG 0x39
#define TEMP_L_T_F_REG 0x40
#define TEMP_L_T_B_REG 0x41
#define TEMP_L_T_F_MAX_REG 0x42
#define TEMP_L_T_F_MIN_REG 0x43
#define TEMP_L_T_F_CRIT_REG 0x44
#define TEMP_L_T_F_LCRIT_REG 0x45
#define TEMP_L_T_B_MAX_REG 0x46
#define TEMP_L_T_B_MIN_REG 0x47
#define TEMP_L_T_B_CRIT_REG 0x48
#define TEMP_L_T_B_LCRIT_REG 0x49
/* end of register offset define */

View File

@ -0,0 +1,8 @@
#!/bin/bash
docker exec -i pmon sensors "$@"
#To probe sensors not part of lm-sensors
if [ -r /usr/local/bin/netberg_nba715_sensors.py ]; then
python /usr/local/bin/netberg_nba715_sensors.py fan_status
python /usr/local/bin/netberg_nba715_sensors.py sensor_status
fi

View File

@ -0,0 +1,14 @@
[Unit]
Description=Netberg Aurora 715 Platform initialization service
After=local-fs.target innovium_platform_driver.service
Before=pmon.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/netberg_nba715_startup start
ExecStop=/usr/local/bin/netberg_nba715_startup stop
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,30 @@
#!/usr/bin/env python
import os
# import sys
from setuptools import setup
os.listdir
setup(
name='sonic_platform',
version='1.0',
description='Netberg Aurora 715 sonic platform API',
packages=['sonic_platform'],
package_dir={'sonic_platform': 'aurora-715/sonic_platform'},
classifiers=[
'Development Status :: 3 - Beta',
'Environment :: Plugins',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.7',
'Topic :: Utilities',
],
)

View File

@ -0,0 +1,335 @@
#############################################################################
# Module contains an implementation of SONiC Platform Base API and
# provides the platform information
#
#############################################################################
try:
import os
import time
import subprocess
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.platDev import PlatDev
from sonic_platform.fan import Fan
from sonic_platform.psu import Psu
from sonic_platform.sfp import Sfp
from sonic_platform.thermal import Thermal
from sonic_platform.eeprom import Eeprom
from sonic_platform.component import Component
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
GET_HWSKU_CMD = "sonic-cfggen -d -v DEVICE_METADATA.localhost.hwsku"
GET_PLATFORM_CMD = "sonic-cfggen -d -v DEVICE_METADATA.localhost.platform"
# XCVR type definition
SFP_TYPE = 0
QSFP_TYPE = 1
class Chassis(ChassisBase):
"""Platform-specific Chassis class"""
_global_port_pres_dict = {}
def __init__(self):
super(Chassis, self).__init__()
# Initialize SKU name and Platform name
self.sku_name = self._get_sku_name()
self.platform_name = self._get_platform_name()
self.name = self.sku_name
# get the device infomation of platform
self.platdev = PlatDev()
#self._component_list = []
#self._module_list = []
#self._fan_drawer_list = []
self._eeprom = Eeprom()
# init component
for i in range(self.platdev.get_component_count()):
component = Component(i, self.platdev.get_component_name(
i), self.platdev.get_component_descript(i))
self._component_list.append(component)
# init fan list
if self.platdev.get_fan_support():
fanlist = self.platdev.get_fan_list()
for index in range(0, len(fanlist)):
fan_name = fanlist[index]
for pos in range(0, self.platdev.get_fan_num_by_name(fan_name)):
fan = Fan(
index, pos, [self.platdev.get_fan_sysfile_path_by_name(fan_name), ''])
self._fan_list.append(fan)
# init psu list
psulist = self.platdev.get_psu_list()
for index in range(0, len(psulist)):
psu_name = psulist[index]
psu = Psu(index, [self.platdev.get_psu_attr_path_by_name(psu_name),
self.platdev.get_psu_status_path_by_name(psu_name)],
self.platdev.bmc_is_exist())
self._psu_list.append(psu)
# init thermal list
thermal_info_list = self.platdev.get_thermal_dev_info_all()
for index in range(0, len(thermal_info_list)):
if len(self.platdev.get_thermal_dev_tempidx_by_idx(index)) > 1:
for idx in self.platdev.get_thermal_dev_tempidx_by_idx(index):
thermal = Thermal(idx, self.platdev.get_thermal_dev_name_by_idx(index)+"-{}".format(idx),
self.platdev.get_thermal_dev_sysfile_path_by_idx(
index),
self.platdev.bmc_is_exist(),
self.platdev.get_thermal_dev_support_mask_by_idx(
index),
self.platdev.get_thermal_dev_ext_sysfile_list_by_idx(index))
self._thermal_list.append(thermal)
else:
thermal = Thermal(1, self.platdev.get_thermal_dev_name_by_idx(index),
self.platdev.get_thermal_dev_sysfile_path_by_idx(
index),
self.platdev.bmc_is_exist(),
self.platdev.get_thermal_dev_support_mask_by_idx(
index),
self.platdev.get_thermal_dev_ext_sysfile_list_by_idx(index))
self._thermal_list.append(thermal)
# init sfp list
port_num = 1
for sfpg_name in self.platdev.get_sfp_group_list():
if self.platdev.get_sfp_group_type_by_name(sfpg_name) == 'QSFP28':
sfp_type = QSFP_TYPE
else:
sfp_type = SFP_TYPE
for x in range(0, self.platdev.get_sfp_group_number_by_name(sfpg_name)):
eeprom_path_list = ['n/a', 'n/a']
if self.platdev.get_sfp_group_path_by_name(sfpg_name)[x] != 'n/a':
eeprom_path_list[0] = self.platdev.get_sfp_group_path_by_name(sfpg_name)[
x] + '/eeprom'
if os.path.exists(eeprom_path_list[0].replace("0050", "0051")):
eeprom_path_list[1] = eeprom_path_list[0].replace(
"0050", "0051")
# index: port index, start from 0
# eeprom_path_list : a list of path to eeprom sysfile
# [0]: for 0x50
# [1]: for 0x51
# ext_sysfile_list: used to get other function of sfp
# [0]: present
# [1]: reset
# [2]: get lowpower mode
# [3]: set lowpower mode
sfp = Sfp(port_num, eeprom_path_list, sfp_type,
self.platdev.get_sfp_ext_sysfile_list())
port_num += 1
self._sfp_list.append(sfp)
self.init_global_port_presence()
def _get_sku_name(self):
pipe = subprocess.Popen(
GET_HWSKU_CMD, shell=True, stdout=subprocess.PIPE)
out, err = pipe.communicate()
return out.decode().rstrip('\n')
def _get_platform_name(self):
pipe = subprocess.Popen(
GET_PLATFORM_CMD, shell=True, stdout=subprocess.PIPE)
out, err = pipe.communicate()
return out.decode().rstrip('\n')
def get_name(self):
"""
Retrieves the name of the device
Returns:
string: The name of the device
"""
return self.name
def get_base_mac(self):
"""
Retrieves the base MAC address for the chassis
Returns:
A string containing the MAC address in the format
'XX:XX:XX:XX:XX:XX'
"""
return self._eeprom.base_mac_addr('')
def get_model(self):
"""
Retrieves the model number (or part number) of the chassis
Returns:
string: Model/part number of chassis
"""
return self._eeprom.part_number_str()
def get_serial_number(self):
"""
Retrieves the hardware serial number for the chassis
Returns:
A string containing the hardware serial number for this chassis.
"""
return self._eeprom.serial_number_str()
def get_system_eeprom_info(self):
"""
Retrieves the full content of system EEPROM information for the chassis
Returns:
A dictionary where keys are the type code defined in
OCP ONIE TlvInfo EEPROM format and values are their corresponding
values.
"""
return self._eeprom.system_eeprom_info()
def get_reboot_cause(self):
"""
Retrieves the cause of the previous reboot
Returns:
A tuple (string, string) where the first element is a string
containing the cause of the previous reboot. This string must be
one of the predefined strings in this class. If the first string
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
to pass a description of the reboot cause.
"""
# not support any hardware reboot, just return REBOOT_CAUSE_NON_HARDWARE
# to keep reboot cause as software reboot
return (self.REBOOT_CAUSE_NON_HARDWARE, None)
##############################################
# System LED methods
##############################################
def set_status_led(self, color):
"""
Sets the state of the system LED
Args:
color: A string representing the color with which to set the
system LED
Returns:
bool: True if system LED state is set successfully, False if not
"""
return False
def get_status_led(self):
"""
Gets the state of the system LED
Returns:
A string, one of the valid LED color strings which could be vendor
specified.
"""
raise NotImplementedError
##############################################
# Other methods
##############################################
def init_global_port_presence(self):
for port_num in range(0, self.platdev.get_sfp_num()):
presence = self._sfp_list[port_num].get_presence()
self._global_port_pres_dict[port_num] = '1' if presence else '0'
def get_change_event(self, timeout=0):
"""
Returns a nested dictionary containing all devices which have
experienced a change at chassis level
Args:
timeout: Timeout in milliseconds (optional). If timeout == 0,
this method will block until a change is detected.
Returns:
(bool, dict):
- True if call successful, False if not;
- A nested dictionary where key is a device type,
value is a dictionary with key:value pairs in the format of
{'device_id':'device_event'},
where device_id is the device ID for this device and
device_event,
status='1' represents device inserted,
status='0' represents device removed.
Ex. {'fan':{'0':'0', '2':'1'}, 'sfp':{'11':'0'}}
indicates that fan 0 has been removed, fan 2
has been inserted and sfp 11 has been removed.
Specifically for SFP event, besides SFP plug in and plug out,
there are some other error event could be raised from SFP, when
these error happened, SFP eeprom will not be avalaible, XCVRD shall
stop to read eeprom before SFP recovered from error status.
status='2' I2C bus stuck,
status='3' Bad eeprom,
status='4' Unsupported cable,
status='5' High Temperature,
status='6' Bad cable.
"""
port_dict = {}
while True:
for port_num in range(0, self.platdev.get_sfp_num()):
presence = self._sfp_list[port_num].get_presence()
if(presence and self._global_port_pres_dict[port_num] == '0'):
self._global_port_pres_dict[port_num] = '1'
port_dict[port_num] = '1'
elif(not presence and
self._global_port_pres_dict[port_num] == '1'):
self._global_port_pres_dict[port_num] = '0'
port_dict[port_num] = '0'
if len(port_dict) > 0:
return True, {'sfp': port_dict}
time.sleep(1)
def sfp_debugger(self):
"""
Try to show all parameters read from eeprom with sfp methods
"""
print("SFP EEPROM data:")
for sfp_n in range(0, len(self._sfp_list)):
print("======SFP{}==TYPE {}====".format(
sfp_n, self._sfp_list[sfp_n].sfp_type))
print("get_transceiver_info:")
print(self._sfp_list[sfp_n].get_transceiver_info())
print(" ")
print("get_transceiver_threshold_info:")
print(self._sfp_list[sfp_n].get_transceiver_threshold_info())
print(" ")
print("get_transceiver_bulk_status:")
print(self._sfp_list[sfp_n].get_transceiver_bulk_status())
print(" ")
print("get_lpmode:")
for sfp_n in range(0, len(self._sfp_list)):
print("\tsfp{}: {}".format(
sfp_n, self._sfp_list[sfp_n].get_lpmode()))
# set_lpmode
print("get_power_override:")
for sfp_n in range(0, len(self._sfp_list)):
print("\tsfp{}: {}".format(
sfp_n, self._sfp_list[sfp_n].get_power_override()))
print("get_temperature:")
for sfp_n in range(0, len(self._sfp_list)):
print("\tsfp{}: {}".format(
sfp_n, self._sfp_list[sfp_n].get_temperature()))
print("get_voltage")
for sfp_n in range(0, len(self._sfp_list)):
print("\tsfp{}: {}".format(
sfp_n, self._sfp_list[sfp_n].get_voltage()))
print("get_tx_bias")
for sfp_n in range(0, len(self._sfp_list)):
print("\tsfp{}: {}".format(
sfp_n, self._sfp_list[sfp_n].get_tx_bias()))
print("get_rx_power")
for sfp_n in range(0, len(self._sfp_list)):
print("\tsfp{}: {}".format(
sfp_n, self._sfp_list[sfp_n].get_rx_power()))
print("get_tx_power")
for sfp_n in range(0, len(self._sfp_list)):
print("\tsfp{}: {}".format(
sfp_n, self._sfp_list[sfp_n].get_tx_power()))

View File

@ -0,0 +1,100 @@
########################################################################
# Module contains an implementation of SONiC Platform Base API and
# provides the Components' (e.g., BIOS, CPLD, FPGA, etc.) available in
# the platform
#
########################################################################
try:
import os
from sonic_platform_base.component_base import ComponentBase
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version"
class Component(ComponentBase):
def __init__(self, idx, name, descript):
self.index = idx
self.name = name
self.description = descript
def _get_cpld_register(self, syspath):
rv = 'ERR'
if (not os.path.isfile(syspath)):
return rv
# noinspection PyBroadException
try:
with open(syspath, 'r') as fd:
rv = fd.read()
except Exception as error:
rv = 'ERR'
rv = rv.rstrip('\r\n')
rv = rv.lstrip(" ")
return rv
def _get_bios_version(self):
# Retrieves the BIOS firmware version
try:
with open(BIOS_VERSION_PATH, 'r') as fd:
bios_version = fd.read()
return bios_version.strip()
except Exception as e:
return None
def _get_cpld_version(self, cpld_number):
cpld_version_reg = {
1: "/sys/class/hwmon/hwmon2/device/NBA715_SYS/cpld_30_ver",
2: "master_cpld_ver",
3: "slave_cpld_ver"
}
cpld_version = self._get_cpld_register(cpld_version_reg[cpld_number])
if cpld_version != 'ERR':
return cpld_version[-4:]
return 'NA'
def get_name(self):
"""
Retrieves the name of the component
Returns:
A string containing the name of the component
"""
return self.name
def get_description(self):
"""
Retrieves the description of the component
Returns:
A string containing the description of the component
"""
return self.description
def get_firmware_version(self):
"""
Retrieves the firmware version of the component
Returns:
A string containing the firmware version of the component
"""
if self.index == 0:
bios_ver = self._get_bios_version()
if not bios_ver:
return 'NA'
return bios_ver
elif self.index <= 3:
return self._get_cpld_version(self.index)
def install_firmware(self, image_path):
"""
Installs firmware to the component
Args:
image_path: A string, path to firmware image
Returns:
A boolean, True if install was successful, False if not
"""
return False

View File

@ -0,0 +1,108 @@
try:
import sys
import re
if sys.version_info.major == 3:
from io import StringIO
else:
from cStringIO import StringIO
from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
EEPROM_DECODE_HEADLINES = 6
def __init__(self):
self._eeprom_path = "/sys/bus/i2c/drivers/NBA_715_i2c/0-0030/eeprom"
super(Eeprom, self).__init__(self._eeprom_path, 0, '', True)
self._eeprom = self._load_eeprom()
def __parse_output(self, decode_output):
decode_output.replace('\0', '')
lines = decode_output.split('\n')
lines = lines[self.EEPROM_DECODE_HEADLINES:]
_eeprom_info_dict = dict()
for line in lines:
match = re.search(
'(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', line)
if match is not None:
idx = match.group(1)
value = match.group(3).rstrip('\0')
_eeprom_info_dict[idx] = value
return _eeprom_info_dict
def _load_eeprom(self):
original_stdout = sys.stdout
sys.stdout = StringIO()
err = self.read_eeprom_db()
if err:
pass
else:
decode_output = sys.stdout.getvalue()
sys.stdout = original_stdout
return self.__parse_output(decode_output)
status = self.check_status()
if status < 'ok':
return {}
data = self.read_eeprom()
if data is None:
return 0
self.decode_eeprom(data)
decode_output = sys.stdout.getvalue()
sys.stdout = original_stdout
(is_valid, valid_crc) = self.is_checksum_valid(data)
if not is_valid:
return {}
return self.__parse_output(decode_output)
def get_eeprom(self):
return self._eeprom
def serial_number_str(self):
"""
Returns the serial number
"""
return self._eeprom.get('0x23', "Undefined.")
def base_mac_addr(self, e):
"""
Returns the base mac address found in the system EEPROM
"""
return self._eeprom.get('0x24', "Undefined.")
def modelstr(self):
"""
Returns the Model name
"""
return self._eeprom.get('0x28', "Undefined.")
def part_number_str(self):
"""
Returns the part number
"""
return self._eeprom.get('0x22', "Undefined.")
def revision_str(self):
"""
Returns the device revision
"""
return self._eeprom.get('0x26', "Undefined.")
def serial_str(self):
return self._eeprom.get('0x2F', "Undefined.")
def system_eeprom_info(self):
"""
Returns a dictionary, where keys are the type code defined in
ONIE EEPROM format and values are their corresponding values
found in the system EEPROM.
"""
return self._eeprom

View File

@ -0,0 +1,152 @@
try:
from sonic_py_common.logger import Logger
from sonic_platform_base.fan_base import FanBase
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
SYSLOG_IDENTIFIER = 'thermalctld'
logger = Logger(SYSLOG_IDENTIFIER)
FAN_POSITION_NAME = ["Front", "Rear"]
class Fan(FanBase):
"""Platform-specific Fan class"""
def __init__(self, fan_index, position_index, attr_path, psu_fan=False):
# fan_index: the index of a fan module belongs to
# position_index : position of the fan in a fan module, 0 -> front, 1 -> rear,
# position_index : index of PSU belongs to if psu_fan is True, start from 0
super(Fan, self).__init__()
self.index = fan_index + 1
self.position = position_index
self.is_psu_fan = psu_fan
self.attr_path = attr_path[0]
if psu_fan is True:
self.fan_name = "PSU{}_FAN{}".format(self.index, self.position+1)
self.speed_file = attr_path[1]
else:
self.fan_name = "FAN{}-{}".format(self.index,
FAN_POSITION_NAME[self.position])
def __read_attr_file(self, filepath, line=0xFF):
try:
with open(filepath, 'r') as fd:
if line == 0xFF:
data = fd.read()
return data.rstrip('\r\n')
else:
data = fd.readlines()
return data[line].rstrip('\r\n')
except FileNotFoundError:
logger.log_error(f"File {filepath} not found. Aborting")
except OSError as ex:
logger.log_error("Cannot open - {}: {}".format(filepath, repr(ex)))
return None
def get_presence(self):
if self.is_psu_fan is True:
data = self.__read_attr_file(
self.attr_path + 'psu{}_prnt'.format(self.index))
return data == '1'
ret = self.__read_attr_file(
self.attr_path + 'fan{}_present'.format(self.index))
return ret == '1'
def get_name(self):
"""
Retrieves the name of the device
Returns:
string: The name of the device
"""
return self.fan_name
def get_direction(self):
"""
Retrieves the direction of fan
Returns:
A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST
depending on fan direction
"""
return self.FAN_DIRECTION_NOT_APPLICABLE
def get_status(self):
if self.is_psu_fan is True:
data = self.__read_attr_file(
self.attr_path + 'psu{}_good'.format(self.index))
return data == '1'
data = self.__read_attr_file(
self.attr_path + 'fan{}_stat'.format(self.index))
return data == '1'
def get_speed(self):
"""
Retrieves the speed of fan as a percentage of full speed
Returns:
An integer, the percentage of full fan speed, in the range 0 (off)
to 100 (full speed)
"""
if self.is_psu_fan is True and self.get_presence():
speed = self.__read_attr_file(self.speed_file, 0)
if speed is not None:
return (int(speed)*100)//16000
return 0
if self.get_presence():
if self.position == 0:
speed_file = self.attr_path + \
'fan{}_front_rpm'.format(self.index)
else:
speed_file = self.attr_path + \
'fan{}_rear_rpm'.format(self.index)
data = self.__read_attr_file(speed_file)
if data is not None:
for sdata in data.split(' '):
if sdata.isdigit():
return (int(sdata)*100)//18000
return 0
def get_target_speed(self):
"""
Retrieves the target (expected) speed of the fan
Returns:
An integer, the percentage of full fan speed, in the range 0 (off)
to 100 (full speed)
"""
return self.get_speed()
def get_speed_tolerance(self):
"""
Retrieves the speed tolerance of the fan
Returns:
An integer, the percentage of variance from target speed which is
considered tolerable
"""
return 10
def set_speed(self, speed):
"""
Sets the fan speed
Args:
speed: An integer, the percentage of full fan speed to set fan to,
in the range 0 (off) to 100 (full speed)
Returns:
A boolean, True if speed is set successfully, False if not
"""
return False
def set_status_led(self, color):
"""
Sets the state of the fan module status LED
Args:
color: A string representing the color with which to set the
fan module status LED
Returns:
bool: True if status LED state is set successfully, False if not
"""
return False

View File

@ -0,0 +1,408 @@
#!/usr/bin/env python
try:
import os
import copy
from sonic_py_common.logger import Logger
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
logger = Logger("platDev")
PLATFORM_NAME = "aurora-715"
MAX_FAN_MODULE = 5
MAX_FAN = 2
THERMAL_SENSOR_LIST = [
{
'name': "pch_haswell",
'temp_index': [1],
'sysfile_path': "/sys/class/hwmon/hwmon0/",
'support_mask': 0x81,
'ext_sysfile_list': None
},
{
'name': "CPU core temp",
'temp_index': [1, 2],
'sysfile_path': "/sys/class/hwmon/hwmon1/",
'support_mask': 0x8B,
'ext_sysfile_list': None
},
{
'name': "NCT7511Y(U73)",
'temp_index': [1, 2],
'sysfile_path': "/sys/class/hwmon/hwmon2/device/NBA715_THERMAL/",
'support_mask': 0x0F,
'ext_sysfile_list': {1: ['temp_r_b_f', 'temp_r_b_f_max', 'temp_r_b_f_min', 'temp_r_b_f_crit', 'temp_r_b_f_lcrit'],
2:['temp_r_b_b', 'temp_r_b_b_max', 'temp_r_b_b_min', 'temp_r_b_b_crit', 'temp_r_b_b_lcrit']}
},
{
'name': "G781(U94)",
'temp_index': [1, 2],
'sysfile_path': "/sys/class/hwmon/hwmon2/device/NBA715_THERMAL/",
'support_mask': 0x0F,
'ext_sysfile_list': {1: ['temp_l_b_f', 'temp_l_b_f_max', 'temp_l_b_f_min', 'temp_l_b_f_crit', 'temp_l_b_f_lcrit'],
2:['temp_l_b_b', 'temp_l_b_b_max', 'temp_l_b_b_min', 'temp_l_b_b_crit', 'temp_l_b_b_lcrit']}
},
{
'name': "G781(U34)",
'temp_index': [1, 2],
'sysfile_path': "/sys/class/hwmon/hwmon2/device/NBA715_THERMAL/",
'support_mask': 0x0F,
'ext_sysfile_list': {1: ['temp_r_t_f', 'temp_r_t_f_max', 'temp_r_t_f_min', 'temp_r_t_f_crit', 'temp_r_t_f_lcrit'],
2:['temp_r_t_b', 'temp_r_t_b_max', 'temp_r_t_b_min', 'temp_r_t_b_crit', 'temp_r_t_b_lcrit']}
},
{
'name': "G781(U4)",
'temp_index': [1, 2],
'sysfile_path': "/sys/class/hwmon/hwmon2/device/NBA715_THERMAL/",
'support_mask': 0x0F,
'ext_sysfile_list': {1: ['temp_l_t_f', 'temp_l_t_f_max', 'temp_l_t_f_min', 'temp_l_t_f_crit', 'temp_l_t_f_lcrit'],
2:['temp_l_t_b', 'temp_l_t_b_max', 'temp_l_t_b_min', 'temp_l_t_b_crit', 'temp_l_t_b_lcrit']}
}
]
# PSU LIST
# ext_sysfile_list
# [0] : sysfile path for present
# [1] : sysfile path for status
#
PSU_LIST = ['PSU1', 'PSU2']
PSU_INFO = {
'PSU1': {
'attr_path': "/sys/class/hwmon/hwmon2/device/NBA715_POWER/",
'status_path': "/sys/class/hwmon/hwmon2/device/NBA715_POWER/"
},
'PSU2': {
'attr_path': "/sys/class/hwmon/hwmon2/device/NBA715_POWER/",
'status_path': "/sys/class/hwmon/hwmon2/device/NBA715_POWER/"
}
}
FAN_LIST = ['FAN1', 'FAN2', 'FAN3', 'FAN4', 'FAN5']
FAN_INFO = {
'FAN1': {
'isdraw': True,
'fan_num': 2,
'attr_path': '/sys/class/hwmon/hwmon2/device/NBA715_FAN/'
},
'FAN2': {
'isdraw': True,
'fan_num': 2,
'attr_path': '/sys/class/hwmon/hwmon2/device/NBA715_FAN/'
},
'FAN3': {
'isdraw': True,
'fan_num': 2,
'attr_path': '/sys/class/hwmon/hwmon2/device/NBA715_FAN/'
},
'FAN4': {
'isdraw': True,
'fan_num': 2,
'attr_path': '/sys/class/hwmon/hwmon2/device/NBA715_FAN/'
},
'FAN5': {
'isdraw': True,
'fan_num': 2,
'attr_path': '/sys/class/hwmon/hwmon2/device/NBA715_FAN/'
}
}
# SFP LIST
#
#
# 0: QSFP
# 1: SFP
# sfp not port on 715 platform
SFP_EXT_SYSFILE_LIST = ["/sys/class/hwmon/hwmon2/device/NBA715_QSFP/", ""]
SFP_GROUP_LIST = ['SFP-G01', 'SFP-G02', 'SFP-G03', 'SFP-G04']
PORT_NUM = 32
# SFP-eeprom paths /sys/bus/i2c/devices/XX-0050
I2C_DEVICES = {
# NCT7511Y sensor & fan control
'NCT7511Y(U73)': {
'parent': 'viaBMC',
'parent_ch': 0,
'driver': 'nct7511',
'i2caddr': '0x2e',
'path': ' ',
'status': 'NOTINST'
},
# G781 sensors
'G781(U94)': {
'parent': 'viaBMC',
'parent_ch': 1,
'driver': 'g781',
'i2caddr': '0x4c',
'path': ' ',
'status': 'NOTINST'
},
'G781(U4)': {
'parent': 'viaBMC',
'parent_ch': 2,
'driver': 'g781',
'i2caddr': '0x4c',
'path': ' ',
'status': 'NOTINST'
},
'G781(U34)': {
'parent': 'viaBMC',
'parent_ch': 3,
'driver': 'g781',
'i2caddr': '0x4c',
'path': ' ',
'status': 'NOTINST'
},
# PSU
'PSU1': {
'parent': 'viaBMC',
'parent_ch': 4,
'driver': 'zrh2800k2',
'i2caddr': '0x58',
'path': ' ',
'status': 'NOTINST'
},
'PSU2': {
'parent': 'viaBMC',
'parent_ch': 4,
'driver': 'zrh2800k2',
'i2caddr': '0x59',
'path': ' ',
'status': 'NOTINST'
},
'TPS53681(0x6C)': {
'parent': 'viaBMC',
'parent_ch': 5,
'driver': 'tps53679',
'i2caddr': '0x6c',
'path': ' ',
'status': 'NOTINST'
},
'TPS53681(0x6E)': {
'parent': 'viaBMC',
'parent_ch': 5,
'driver': 'tps53679',
'i2caddr': '0x6e',
'path': ' ',
'status': 'NOTINST'
},
'TPS53681(0x70)': {
'parent': 'viaBMC',
'parent_ch': 5,
'driver': 'tps53679',
'i2caddr': '0x70',
'path': ' ',
'status': 'NOTINST'
}
}
SFP_GROUPS = {
'SFP-G01': {
"type": "QSFP28",
'number': 8,
'parent': 'PCA9548_0x71_1',
'channels': [0, 1, 2, 3, 4, 5, 6, 7],
'driver': 'optoe1',
'i2caddr': '0x50',
'paths': ["/sys/bus/i2c/devices/9-0050", "/sys/bus/i2c/devices/10-0050",
"/sys/bus/i2c/devices/11-0050", "/sys/bus/i2c/devices/12-0050",
"/sys/bus/i2c/devices/13-0050", "/sys/bus/i2c/devices/14-0050",
"/sys/bus/i2c/devices/15-0050", "/sys/bus/i2c/devices/16-0050"],
'status': 'NOTINST'
},
'SFP-G02': {
"type": "QSFP28",
'number': 8,
'parent': 'PCA9548_0x71_2',
'channels': [0, 1, 2, 3, 4, 5, 6, 7],
'driver': 'optoe1',
'i2caddr': '0x50',
'paths': ["/sys/bus/i2c/devices/17-0050", "/sys/bus/i2c/devices/18-0050",
"/sys/bus/i2c/devices/19-0050", "/sys/bus/i2c/devices/20-0050",
"/sys/bus/i2c/devices/21-0050", "/sys/bus/i2c/devices/22-0050",
"/sys/bus/i2c/devices/23-0050", "/sys/bus/i2c/devices/24-0050"],
'status': 'NOTINST'
},
'SFP-G03': {
"type": "QSFP28",
'number': 8,
'parent': 'PCA9548_0x71_3',
'channels': [0, 1, 2, 3, 4, 5, 6, 7],
'driver': 'optoe1',
'i2caddr': '0x50',
'paths': ["/sys/bus/i2c/devices/25-0050", "/sys/bus/i2c/devices/26-0050",
"/sys/bus/i2c/devices/27-0050", "/sys/bus/i2c/devices/28-0050",
"/sys/bus/i2c/devices/29-0050", "/sys/bus/i2c/devices/30-0050",
"/sys/bus/i2c/devices/31-0050", "/sys/bus/i2c/devices/32-0050"],
'status': 'NOTINST'
},
'SFP-G04': {
"type": "QSFP28",
'number': 8,
'parent': 'PCA9548_0x71_4',
'channels': [0, 1, 2, 3, 4, 5, 6, 7],
'driver': 'optoe1',
'i2caddr': '0x50',
'paths': ["/sys/bus/i2c/devices/33-0050", "/sys/bus/i2c/devices/34-0050",
"/sys/bus/i2c/devices/35-0050", "/sys/bus/i2c/devices/36-0050",
"/sys/bus/i2c/devices/37-0050", "/sys/bus/i2c/devices/38-0050",
"/sys/bus/i2c/devices/39-0050", "/sys/bus/i2c/devices/40-0050"],
'status': 'NOTINST'
}
}
# Component
# ["Master-CPLD", ("Used for managing Fan, PSU, system LEDs, QSFP "
# "modules (1-16)")],
# ["Slave-CPLD", "Used for managing QSFP modules (17-32)"]
CHASSIS_COMPONENTS = [
["BIOS", ("Performs initialization of hardware components during "
"booting")],
["System-CPLD", "Used for managing CPU board devices and power"]
]
class PlatDev():
def __init__(self):
self.plat_name = PLATFORM_NAME
self.psu_info = copy.deepcopy(PSU_INFO)
self.thermal_info = []
self.fan_info = copy.deepcopy(FAN_INFO)
self.sfp_info = copy.deepcopy(SFP_GROUPS)
# get install info
# self.sfp_install_info = SFP_GROUPS
self.device_install_info = I2C_DEVICES
# update path info with install info
# Item 1/2 not changed, append directly
self.thermal_info.append(THERMAL_SENSOR_LIST[0])
self.thermal_info.append(THERMAL_SENSOR_LIST[1])
def __read_attr_file(self, filepath, line=0xFF):
try:
with open(filepath, 'r') as fd:
if line == 0xFF:
data = fd.read()
return data.rstrip('\r\n')
else:
data = fd.readlines()
return data[line].rstrip('\r\n')
except FileNotFoundError:
logger.log_error(f"File {filepath} not found. Aborting")
except OSError as ex:
logger.log_error("Cannot open - {}: {}".format(filepath, repr(ex)))
return None
def bmc_is_exist(self):
bmc_filePath = '/sys/class/hwmon/hwmon2/device/NBA715_SYS/bmc_present'
if os.path.exists(bmc_filePath):
value = self.__read_attr_file(bmc_filePath)
if int(value) == 1:
return True
else:
return False
else:
return False
######Componet method #####
def get_component_count(self):
return len(CHASSIS_COMPONENTS)
def get_component_name(self, idx):
return CHASSIS_COMPONENTS[idx][0]
def get_component_descript(self, idx):
return CHASSIS_COMPONENTS[idx][1]
###### PSU method ######
def get_psu_list(self):
return PSU_LIST
def get_psu_info_all(self):
return self.psu_info
def get_psu_info_by_name(self, name):
return self.psu_info.get(name)
def get_psu_attr_path_by_name(self, name):
return self.psu_info[name].get('attr_path')
def get_psu_status_path_by_name(self, name):
return self.psu_info[name].get('status_path')
###### Thermal method ######
def get_thermal_dev_info_all(self):
return self.thermal_info
def get_thermal_dev_name_by_idx(self, index):
return self.thermal_info[index].get('name')
def get_thermal_dev_tempidx_by_idx(self, index):
return self.thermal_info[index].get('temp_index')
def get_thermal_dev_sysfile_path_by_idx(self, index):
return self.thermal_info[index].get('sysfile_path')
def get_thermal_dev_support_mask_by_idx(self, index):
return self.thermal_info[index].get('support_mask')
def get_thermal_dev_ext_sysfile_list_by_idx(self, index):
return self.thermal_info[index].get('ext_sysfile_list')
###### Fan method ######
def get_fan_support(self):
return True
def get_fan_list(self):
return FAN_LIST
def get_fan_info_all(self):
return self.fan_info
def get_fan_info_by_name(self, name):
return self.fan_info.get(name)
def get_fan_sysfile_path_by_name(self, name):
return self.fan_info[name].get('attr_path')
def get_fan_is_draw_by_name(self, name):
return self.fan_info[name].get('isdraw')
def get_fan_num_by_name(self, name):
return self.fan_info[name].get('fan_num')
###### SFP method ######
def get_sfp_num(self):
return PORT_NUM
def get_sfp_group_list(self):
return SFP_GROUP_LIST
def get_sfp_group_info(self):
return self.sfp_info
def get_sfp_group_info_by_name(self, name):
return self.sfp_info.get(name)
def get_sfp_group_type_by_name(self, name):
return self.sfp_info[name].get('type')
def get_sfp_group_path_by_name(self, name):
return self.sfp_info[name].get('paths')
def get_sfp_group_number_by_name(self, name):
return self.sfp_info[name].get('number')
def get_sfp_ext_sysfile_list(self):
return SFP_EXT_SYSFILE_LIST

View File

@ -0,0 +1,19 @@
#############################################################################
# Module contains an implementation of SONiC Platform Base API and
# provides the platform information
#
#############################################################################
try:
from sonic_platform_base.platform_base import PlatformBase
from sonic_platform.chassis import Chassis
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class Platform(PlatformBase):
"""Platform-specific Platform class"""
def __init__(self):
PlatformBase.__init__(self)
self._chassis = Chassis()

View File

@ -0,0 +1,196 @@
#############################################################################
#
# Module contains an implementation of SONiC Platform Base API and
# provides the PSUs status which are available in the platform
#
#############################################################################
try:
from sonic_platform_base.psu_base import PsuBase
from sonic_py_common.logger import Logger
from sonic_platform.fan import Fan
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
SYSLOG_IDENTIFIER = 'thermalctld'
logger = Logger(SYSLOG_IDENTIFIER)
# To do: should be defined in platDev
PSU_MAX_VOUT = 12.0 # voltage
PSU_MIN_VOUT = 3.3 # voltage
PSU_MAX_TEMP = 50.0 # C
class Psu(PsuBase):
"""Platform-specific Psu class"""
def __init__(self, index, info_list, is_bmc):
PsuBase.__init__(self)
self.index = index
self.is_bmc = is_bmc
self.attr_path = info_list[0]
self.status_path = info_list[1]
if is_bmc:
speed_file = self.attr_path + 'psu{}_fan_speed'.format(index+1)
else:
speed_file = self.attr_path + 'psu_fan_speed_1'
fan = Fan(index, 0, [self.status_path, speed_file], True)
self._fan_list.append(fan)
self.psu_name = "PSU{}".format(self.index+1)
def __read_attr_file(self, filepath, line=0xFF):
try:
with open(filepath, 'r') as fd:
if line == 0xFF:
data = fd.read()
return data.rstrip('\r\n')
else:
data = fd.readlines()
return data[line].rstrip('\r\n')
except FileNotFoundError:
logger.log_error(f"File {filepath} not found. Aborting")
except OSError as ex:
logger.log_error("Cannot open - {}: {}".format(filepath, repr(ex)))
return None
def get_name(self):
return self.psu_name
def get_presence(self):
"""
Retrieves the presence status of power supply unit (PSU) defined
Returns:
bool: True if PSU is present, False if not
"""
data = self.__read_attr_file(
self.status_path + 'psu{}_prnt'.format(self.index+1))
if data == '1':
return True
else:
return False
def get_powergood_status(self):
"""
Retrieves the powergood status of PSU
Returns:
A boolean, True if PSU has stablized its output voltages and passed all
its internal self-tests, False if not.
"""
data = self.__read_attr_file(
self.status_path + 'psu{}_good'.format(self.index+1))
if data == '1':
return True
else:
return False
def get_voltage(self):
"""
Retrieves current PSU voltage output
Returns:
A float number, the output voltage in volts,
e.g. 12.1
"""
if self.is_bmc:
path = self.attr_path + 'psu{}_vout'.format(self.index+1)
else:
path = self.attr_path + "/psu_vout"
vout = self.__read_attr_file(path, 0)
if vout is not None:
return float(vout) / 1000
return False
def get_current(self):
"""
Retrieves present electric current supplied by PSU
Returns:
A float number, the electric current in amperes, e.g 15.4
"""
if self.is_bmc:
path = self.attr_path + 'psu{}_iout'.format(self.index+1)
else:
path = self.attr_path + "/psu_iout"
iout = self.__read_attr_file(path, 0)
if iout is not None:
return float(iout) / 1000
return False
def get_power(self):
"""
Retrieves current energy supplied by PSU
Returns:
A float number, the power in watts, e.g. 302.6
"""
if self.is_bmc:
path = self.attr_path + 'psu{}_pout'.format(self.index+1)
else:
path = self.attr_path + "/psu_pout"
pout = self.__read_attr_file(path, 0)
if pout is not None:
return float(pout) / 1000000
return False
def set_status_led(self, color):
"""
Sets the state of the PSU status LED
Args:
color: A string representing the color with which to set the
PSU status LED
Returns:
bool: True if status LED state is set successfully, False if not
"""
raise NotImplementedError
def get_status_led(self):
"""
Gets the state of the PSU status LED
Returns:
A string, one of the predefined STATUS_LED_COLOR_* strings above
"""
raise NotImplementedError
def get_temperature(self):
"""
Retrieves current temperature reading from PSU
Returns:
A float number of current temperature in Celsius up to nearest thousandth
of one degree Celsius, e.g. 30.125
"""
if self.is_bmc:
path = self.attr_path+'psu{}_temp'.format(self.index+1)
else:
path = self.attr_path + "/psu_temp_1"
temperature = self.__read_attr_file(path, 0)
if temperature is not None:
return float(temperature) / 1000
return False
def get_temperature_high_threshold(self):
"""
Retrieves the high threshold temperature of PSU
Returns:
A float number, the high threshold temperature of PSU in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
return PSU_MAX_TEMP
def get_voltage_high_threshold(self):
"""
Retrieves the high threshold PSU voltage output
Returns:
A float number, the high threshold output voltage in volts,
e.g. 12.1
"""
return PSU_MAX_VOUT
def get_voltage_low_threshold(self):
"""
Retrieves the low threshold PSU voltage output
Returns:
A float number, the low threshold output voltage in volts,
e.g. 12.1
"""
return PSU_MIN_VOUT

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,201 @@
#############################################################################
#
# Module contains an implementation of SONiC Platform Base API and
# provides the PSUs status which are available in the platform
#
#############################################################################
try:
from sonic_py_common.logger import Logger
from sonic_platform_base.thermal_base import ThermalBase
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
logger = Logger("thermal")
class Thermal(ThermalBase):
"""Platform-specific Thermal class"""
def __init__(self, index, name, sysfile_path, is_bmc, support_mask=0x1, ext_sysfile_list=None):
# index is used to indicate the temp{} under sffile_path
# support_mask: 1:support 0:not support
# bit 0 : temperature (always 1)
# bit 1 : high threshold
# bit 2 : low threshold
# bit 3 : high critical threshold
# bit 4 : low critical threshold
# bit 7 : cpu internal sensor
# ext_sysfile_list: each specified path of each supported function,
# which not follows the general naming rule
self.index = index
self.name = name
self.filepath = sysfile_path
self.support_mask = support_mask
self.is_bmc = is_bmc
self.temperature_file = None
self.high_thershold_file = None
self.low_threshold_file = None
self.high_critical_file = None
self.low_critical_file = None
if sysfile_path is None:
return
if self.is_bmc == False or support_mask & 0x80 == 0x80:
if support_mask & 0x1:
self.temperature_file = \
sysfile_path + "/temp{}_input".format(self.index)
if support_mask & 0x2:
self.high_thershold_file = \
sysfile_path + "/temp{}_max".format(self.index)
if support_mask & 0x4:
self.low_threshold_file = \
sysfile_path + "/temp{}_min".format(self.index)
if support_mask & 0x8:
self.high_critical_file = \
sysfile_path + "/temp{}_crit".format(self.index)
if support_mask & 0x10:
self.low_critical_file = \
sysfile_path + "/temp{}_lcrit".format(self.index)
elif self.is_bmc and ext_sysfile_list is not None:
if support_mask & 0x1:
self.temperature_file = \
sysfile_path + ext_sysfile_list[self.index][0]
if support_mask & 0x2:
self.high_thershold_file = \
sysfile_path + ext_sysfile_list[self.index][1]
if support_mask & 0x4:
self.low_threshold_file = \
sysfile_path + ext_sysfile_list[self.index][2]
if support_mask & 0x8:
self.high_critical_file = \
sysfile_path + ext_sysfile_list[self.index][3]
if support_mask & 0x10:
self.low_critical_file = \
sysfile_path + ext_sysfile_list[self.index][4]
def __read_attr_file(self, filepath, line=0xFF):
try:
with open(filepath, 'r') as fd:
if line == 0xFF:
data = fd.read()
return data.rstrip('\r\n')
else:
data = fd.readlines()
return data[line].rstrip('\r\n')
except Exception as ex:
logger.log_error(
"Unable to open {} due to {}".format(filepath, repr(ex)))
return None
def get_name(self):
return self.name
def get_presence(self):
return True
def get_temperature(self):
"""
Retrieves current temperature reading from thermal
Returns:
A float number of current temperature in Celsius up to nearest thousandth
of one degree Celsius, e.g. 30.125
"""
if self.temperature_file is not None:
temp = self.__read_attr_file(self.temperature_file)
if temp is not None:
return float(temp) / 1000
return None
def get_high_threshold(self):
"""
Retrieves the high threshold temperature of thermal
Returns:
A float number, the high threshold temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
if self.high_thershold_file is not None:
temp = self.__read_attr_file(self.high_thershold_file)
if temp is not None:
return float(temp) / 1000
return None
def get_low_threshold(self):
"""
Retrieves the low threshold temperature of thermal
Returns:
A float number, the low threshold temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
if self.low_threshold_file is not None:
temp = self.__read_attr_file(self.low_threshold_file)
if temp is not None:
return float(temp) / 1000
return None
def set_high_threshold(self, temperature):
"""
Sets the high threshold temperature of thermal
Args :
temperature: A float number up to nearest thousandth of one degree Celsius,
e.g. 30.125
Returns:
A boolean, True if threshold is set successfully, False if not
"""
return False
def set_low_threshold(self, temperature):
"""
Sets the low threshold temperature of thermal
Args :
temperature: A float number up to nearest thousandth of one degree Celsius,
e.g. 30.125
Returns:
A boolean, True if threshold is set successfully, False if not
"""
return False
def get_high_critical_threshold(self):
"""
Retrieves the high critical threshold temperature of thermal
Returns:
A float number, the high critical threshold temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
if self.high_critical_file is not None:
temp = self.__read_attr_file(self.high_critical_file)
if temp is not None:
return float(temp) / 1000
return None
def get_low_critical_threshold(self):
"""
Retrieves the low critical threshold temperature of thermal
Returns:
A float number, the low critical threshold temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
if self.low_critical_file is not None:
temp = self.__read_attr_file(self.low_critical_file)
if temp is not None:
return float(temp) / 1000
return None

View File

@ -0,0 +1,408 @@
#!/usr/bin/env python
"""
Usage: %(scriptName)s [options] command object
options:
-h | --help : this help message
-d | --debug : run with debug mode
-f | --force : ignore error during installation or clean
command:
install : install drivers and generate related sysfs nodes
clean : uninstall drivers and remove related sysfs nodes
show : show all systen status
sff : dump SFP eeprom
set : change board setting with fan|led|sfp
"""
import os
import commands
import sys, getopt
import logging
import re
import time
import json
PROJECT_NAME = 'aurora_715'
verbose = False
DEBUG = False
FORCE = 0
# default is 'i2c-0', we will choose the correct one from 'i2c-0' and 'i2c-1'.
#DEFAULT_BASE_BUS = 'i2c-0'
I2C_PREFIX = '/sys/bus/i2c/devices/'
BASE_BUS = 'i2c-0'
BASE_BUS_PATH = I2C_PREFIX + BASE_BUS
#I2C_BASE_BUS = {
# 'i2c-0':{
# 'path':'/sys/bus/i2c/devices/i2c-0',
# 'status':'INSTALLED'
# }
#}
switch_install_order = [
# 'PCA9548_0x73',
'PCA9548_0x71_1',
'PCA9548_0x71_2',
'PCA9548_0x71_3',
'PCA9548_0x71_4'
# 'PCA9548_0x75'
]
I2C_SWITCH_LIST = {
# i2c switches
'PCA9548_0x73': {
'parent':BASE_BUS,
'driver':'pca9548',
'i2caddr': '0x73',
'path': '/sys/bus/i2c/devices/0-0073',
'bus_map': [1,2,3,4,5,6,7,8],
'status':'NOTINST'
},
#'PCA9548_0x75': {
# 'parent':BASE_BUS,
# 'driver':'pca9548',
# 'i2caddr': '0x75',
# 'path': ' ',
# 'bus_map': [0,0,0,0,0,0,0,0],
# 'status':'NOTINST'
#},
'PCA9548_0x71_1': {
'parent':'PCA9548_0x73',
'parent_ch': 4,
'driver':'pca9548',
'i2caddr': '0x71',
'path': '/sys/bus/i2c/devices/5-0071',
'bus_map': [9,10,11,12,13,14,15,16],
'status':'NOTINST'
},
'PCA9548_0x71_2': {
'parent':'PCA9548_0x73',
'parent_ch': 5,
'driver':'pca9548',
'i2caddr': '0x71',
'path': '/sys/bus/i2c/devices/6-0071',
'bus_map': [17,18,19,20,21,22,23,24],
'status':'NOTINST'
},
'PCA9548_0x71_3': {
'parent':'PCA9548_0x73',
'parent_ch': 6,
'driver':'pca9548',
'i2caddr': '0x71',
'path': '/sys/bus/i2c/devices/7-0071',
'bus_map': [25,26,27,28,29,30,31,32],
'status':'NOTINST'
},
'PCA9548_0x71_4': {
'parent':'PCA9548_0x73',
'parent_ch': 7,
'driver':'pca9548',
'i2caddr': '0x71',
'path': '/sys/bus/i2c/devices/8-0071',
'bus_map': [33,34,35,36,37,38,39,40],
'status':'NOTINST'
}
}
I2C_DEVICES = {
# NCT7511Y sensor & fan control
'NCT7511Y(U73)': {
'parent':'PCA9548_0x75',
'parent_ch': 0,
'driver':'nct7511',
'i2caddr': '0x2e',
'path': ' ',
'status':'NOTINST'
},
# G781 sensors
'G781(U94)': {
'parent':'PCA9548_0x75',
'parent_ch': 1,
'driver':'g781',
'i2caddr': '0x4c',
'path': ' ',
'status':'NOTINST'
},
'G781(U4)': {
'parent':'PCA9548_0x75',
'parent_ch': 2,
'driver':'g781',
'i2caddr': '0x4c',
'path': ' ',
'status':'NOTINST'
},
'G781(U34)': {
'parent':'PCA9548_0x75',
'parent_ch': 3,
'driver':'g781',
'i2caddr': '0x4c',
'path': ' ',
'status':'NOTINST'
},
# PSU
'PSU1': {
'parent':'PCA9548_0x75',
'parent_ch': 4,
'driver':'zrh2800k2',
'i2caddr': '0x58',
'path': ' ',
'status':'NOTINST'
},
'PSU2': {
'parent':'PCA9548_0x75',
'parent_ch': 4,
'driver':'zrh2800k2',
'i2caddr': '0x59',
'path': ' ',
'status':'NOTINST'
},
'TPS53681(0x6C)': {
'parent':'PCA9548_0x75',
'parent_ch': 5,
'driver':'tps53679',
'i2caddr': '0x6c',
'path': ' ',
'status':'NOTINST'
},
'TPS53681(0x6E)': {
'parent':'PCA9548_0x75',
'parent_ch': 5,
'driver':'tps53679',
'i2caddr': '0x6e',
'path': ' ',
'status':'NOTINST'
},
'TPS53681(0x70)': {
'parent':'PCA9548_0x75',
'parent_ch': 5,
'driver':'tps53679',
'i2caddr': '0x70',
'path': ' ',
'status':'NOTINST'
}
}
SFP_GROUPS = {
'SFP-G01' :{
'number': 8,
'parent':'PCA9548_0x71_1',
'channels':[0,1,2,3,4,5,6,7],
'driver':'optoe1',
'i2caddr': '0x50',
'paths': [],
'status':'NOTINST'
},
'SFP-G02' :{
'number': 8,
'parent':'PCA9548_0x71_2',
'channels':[0,1,2,3,4,5,6,7],
'driver':'optoe1',
'i2caddr': '0x50',
'paths': [],
'status':'NOTINST'
},
'SFP-G03' :{
'number': 8,
'parent':'PCA9548_0x71_3',
'channels':[0,1,2,3,4,5,6,7],
'driver':'optoe1',
'i2caddr': '0x50',
'paths': [],
'status':'NOTINST'
},
'SFP-G04' :{
'number': 8,
'parent':'PCA9548_0x71_4',
'channels':[0,1,2,3,4,5,6,7],
'driver':'optoe1',
'i2caddr': '0x50',
'paths': [],
'status':'NOTINST'
}
}
def main():
global DEBUG
global args
global FORCE
options, args = getopt.getopt(sys.argv[1:], 'hdf', ['help',
'debug',
'force',
])
for opt, arg in options:
if opt in ('-d', '--debug'):
DEBUG = True
logging.basicConfig(level=logging.INFO)
elif opt in ('-f', '--force'):
FORCE = 1
else:
logging.info('no option')
for arg in args:
if arg == 'install':
do_install()
elif arg == 'clean':
do_uninstall()
elif arg == 'version':
show_version()
return 0
def show_version():
print("platform driver version: {}\n".format(PLATFORM_DRIVER_VER))
def driver_check():
with open('/proc/modules') as modules:
return 'x86_64_netberg_aurora' in modules.read()
def driver_install():
print("Probbing modules...")
os.system('modprobe i2c_dev')
os.system('modprobe x86-64-netberg-aurora-715')
os.system('modprobe i2c_mux_pca954x force_deselect_on_exit=1')
return 0
def driver_uninstall():
os.system('rmmod i2c_mux_pca954x')
os.system('rmmod x86-64-netberg-aurora-715')
os.system('rmmod i2c_dev')
return 0
def install_i2c_switch():
print("Init root I2C switch...")
root_sw = I2C_SWITCH_LIST['PCA9548_0x73']
os.system("echo {} {} > {}/new_device".format(root_sw['driver'], root_sw['i2caddr'], BASE_BUS_PATH))
# make sure the root switch for sfp is installed
time.sleep(2)
for switch_name in switch_install_order:
switch = I2C_SWITCH_LIST[switch_name]
install_path = I2C_SWITCH_LIST[switch['parent']]['path']
install_path = install_path+"/channel-{}".format(switch['parent_ch'])
cmd = "echo {} {} > {}/new_device".format(switch['driver'], switch['i2caddr'], install_path)
print(cmd)
os.system(cmd)
def install_sfp():
for sfp_group_name in SFP_GROUPS.keys():
sfp_group = SFP_GROUPS[sfp_group_name]
install_path = I2C_SWITCH_LIST[sfp_group['parent']]['path']
for n in range(0,sfp_group['number']):
sfp_install_path = install_path+"/channel-{}".format(sfp_group['channels'][n])
cmd = "echo {} {} > {}/new_device".format(sfp_group['driver'], sfp_group['i2caddr'], sfp_install_path)
print(cmd)
os.system(cmd)
# sfp_group['paths'].append("/sys/bus/i2c/devices/{}-00{}".format(I2C_SWITCH_LIST[sfp_group['parent']]['bus_map'][sfp_group['channels'][n]],sfp_group['i2caddr'][-2:]))
print("/sys/bus/i2c/devices/{}-00{}".format(I2C_SWITCH_LIST[sfp_group['parent']]['bus_map'][sfp_group['channels'][n]],sfp_group['i2caddr'][-2:]))
def uninstall_sfp():
for sfp_group_name in SFP_GROUPS.keys():
sfp_group = SFP_GROUPS[sfp_group_name]
uninst_path = I2C_SWITCH_LIST[sfp_group['parent']]['path']
for n in range(0,sfp_group['number']):
sfp_uninst_path = uninst_path+"/channel-{}".format(sfp_group['channels'][n])
cmd = "echo {} > {}/delete_device".format(sfp_group['i2caddr'], sfp_uninst_path)
print(cmd)
os.system(cmd)
def uninstall_i2c_switch():
for switch_name in reversed(switch_install_order):
switch = I2C_SWITCH_LIST[switch_name]
uninst_path = I2C_SWITCH_LIST[switch['parent']]['path'] + "/channel-{}".format(switch['parent_ch'])
cmd = "echo {} > {}/delete_device".format(switch['i2caddr'], uninst_path)
print(cmd)
os.system(cmd)
print("Uninstall root switch...")
root_sw = I2C_SWITCH_LIST['PCA9548_0x73']
cmd = "echo {} > {}/delete_device".format(root_sw['i2caddr'], BASE_BUS_PATH)
print(cmd)
os.system(cmd)
def set_led_control():
cmd = "echo 1 > /sys/class/hwmon/hwmon2/device/NBA715_LED/led_fiber"
print(cmd)
os.system(cmd)
def device_install():
print('Base bus is {}'.format(BASE_BUS))
set_led_control()
install_i2c_switch()
# delay to make sure all switches are installed completely,
time.sleep(1)
# install_i2c_device()
install_sfp()
return 0
def device_uninstall():
global SFP_GROUPS
# global I2C_DEVICES
global I2C_SWITCH_LIST
uninstall_sfp()
# uninstall_i2c_device()
uninstall_i2c_switch()
return 0
def do_install():
print("Drivers installing....")
status = driver_install()
print("Devices installing....")
status = device_install()
return
def do_uninstall():
print "Checking system...."
if not device_exist():
print PROJECT_NAME.upper() + " has no device installed...."
else:
print "Removing device...."
status = device_uninstall()
if status:
if FORCE == 0:
return status
if driver_check() == False:
print PROJECT_NAME.upper() + " has no driver installed...."
else:
print "Removing installed driver...."
status = driver_uninstall()
if status:
if FORCE == 0:
return status
return
def device_exist():
print("Checking devices... ")
return os.path.isdir("/sys/bus/i2c/devices/0-0056/")
if __name__ == "__main__":
main()

View File

@ -0,0 +1,18 @@
#!/bin/sh
mr_reboot() {
sudo rmmod x86-64-netberg-aurora-715
sudo i2cset -y 0 0x30 0xa1 0
}
if [ $# -eq 0 ] || [ $@ = "--halt" ] || [ $@ = "-f" ] || [ $@ = "--force" ]; then
sudo /sbin/halt
elif [ $@ = "-p" ] || [ $@ = "--reboot" ] || [ $@ = "--poweroff" ]; then
sync;sync
mr_reboot
else
echo "unsupported option"
fi

View File

@ -0,0 +1,10 @@
#!/bin/bash
# Install aurora-715 python package
DEVICE="/usr/share/sonic/device"
PLATFORM=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
if [ -e $DEVICE/$PLATFORM/sonic_platform-1.0-py3-none-any.whl ]; then
pip install $DEVICE/$PLATFORM/sonic_platform-1.0-py3-none-any.whl
fi

View File

@ -0,0 +1,281 @@
#!/usr/bin/python
from __future__ import print_function
import os
import sys
import logging
MAX_FAN_NUM = 5
MAX_PSU_NUM = 2
PSU_LIST = ['PSU1', 'PSU2'] # 0x58, 0x59
THERMAL_SENSOR_LIST = ['NCT7511Y(U73)', 'G781(U94)', 'G781(U34)', 'G781(U4)']
BMC_SYSFILE_PATH = '/sys/class/hwmon/hwmon2/device/NBA715_SYS/'
FAN_SYSFILE_PATH = '/sys/class/hwmon/hwmon2/device/NBA715_FAN/'
POWER_SYSFILE_PATH = '/sys/class/hwmon/hwmon2/device/NBA715_POWER/'
THERMAL_SYSFILE_PATH = '/sys/class/hwmon/hwmon2/device/NBA715_THERMAL/'
def get_thermal_sensor_path():
sensor_path = []
try:
with open(PLATFORM_INSTALL_INFO_FILE) as fd:
install_info = json.load(fd)
for sensor_name in THERMAL_SENSOR_LIST:
sensor = install_info[1][sensor_name]
sensor_path.append(sensor['hwmon_path']+'/')
return sensor_path
except Exception:
print("Fail to get sensor sysfsfile path")
return sensor_path
# Get sysfs attribute
def get_attr_value(attr_path):
retval = 'ERR'
if not os.path.isfile(attr_path):
return retval
try:
with open(attr_path, 'r') as fd:
retval = fd.read()
except Exception as error:
logging.error("Unable to open ", attr_path, " file !")
retval = retval.rstrip('\r\n')
fd.close()
return retval
def print_attr_value_lines(sys_path):
retval = 'ERR'
if not os.path.isfile(sys_path):
return retval
try:
fo = open(sys_path, "r")
except Exception as error:
logging.error("Unable to open ", sys_path, " file !")
for line in fo.readlines():
line = line.strip()
print(" %s" % line)
fo.close()
return retval
def show_sensor_table():
headers = ['Sensor', 'Temperature', 'High',
'Low', 'Critical High', 'Critical Low']
table = list()
temp = list()
sensor_table = [
['Right Bottom Front', 'temp_r_b_f', 'temp_r_b_f_max',
'temp_r_b_f_min', 'temp_r_b_f_crit', 'temp_r_b_f_lcrit'],
['Right Bottom Back', 'temp_r_b_b', 'temp_r_b_b_max',
'temp_r_b_b_min', 'temp_r_b_b_crit', 'temp_r_b_b_lcrit'],
['Left Bottom Front', 'temp_l_b_f', 'temp_l_b_f_max',
'temp_l_b_f_min', 'temp_l_b_f_crit', 'temp_l_b_f_lcrit'],
['Left Bottom Back', 'temp_l_b_b', 'temp_l_b_b_max',
'temp_l_b_b_min', 'temp_l_b_b_crit', 'temp_l_b_b_lcrit'],
['Right Top Front', 'temp_r_t_f', 'temp_r_t_f_max',
'temp_r_t_f_min', 'temp_r_t_f_crit', 'temp_r_t_f_lcrit'],
['Right Top Back Sensor', 'temp_r_t_b', 'temp_r_t_b_max',
'temp_r_t_b_min', 'temp_r_t_b_crit', 'temp_r_t_b_lcrit'],
['Left Top Front Sensor', 'temp_l_t_f', 'temp_l_t_f_max',
'temp_l_t_f_min', 'temp_l_t_f_crit', 'temp_l_t_f_lcrit'],
['Left Top Back Sensor', 'temp_l_t_b', 'temp_l_t_b_max',
'temp_l_t_b_min', 'temp_l_t_b_crit', 'temp_l_t_b_lcrit'],
]
for index in range(len(sensor_table)):
name = sensor_table[index][0]
for x in range(0, 5):
sys_path = THERMAL_SYSFILE_PATH + sensor_table[index][x+1]
t = get_attr_value(sys_path)
if t == 'ERR':
temp.append('N/A')
else:
if t.isdigit():
t = int(t)/1000.0
temp.append('{} C'.format(t))
table.append([name, temp[0], temp[1], temp[2], temp[3], temp[4]])
del temp[:]
print(headers)
print(table)
print('')
def show_fan_table():
print(*['Fan', 'Speed', 'Presence', 'Status', 'Power'], sep='\t')
for index in range(1, MAX_FAN_NUM+1):
name_front = "FAN{}-Front".format(index)
name_rear = "FAN{}-Rear".format(index)
speed_front, speed_rear = fan_speed_dual(index)
present = fan_present(index)
status = fan_status(index)
power = fan_power(index)
print(*[name_front, speed_front, present, status, power], sep='\t')
print(*[name_rear, speed_front, present, status, power], sep='\t')
print('')
def fan_status(index):
sys_path = FAN_SYSFILE_PATH + 'fan{}_stat'.format(index)
ret = get_attr_value(sys_path)
if ret == '1':
return 'OK'
elif ret == '0':
return 'NG'
else:
return 'N/A'
def fan_present(index):
sys_path = FAN_SYSFILE_PATH + 'fan{}_present'.format(index)
ret = get_attr_value(sys_path)
if ret == '1':
return 'Present'
elif ret == '0':
return 'Not Present'
else:
return 'N/A'
def fan_power(index):
sys_path = FAN_SYSFILE_PATH + 'fan{}_power'.format(index)
ret = get_attr_value(sys_path)
if ret == '1':
return 'On'
elif ret == '0':
return 'Off'
else:
return 'N/A'
def fan_speed_dual(index):
sys_path = FAN_SYSFILE_PATH + 'fan{}_front_rpm'.format(index)
front_ret = get_attr_value(sys_path)
if front_ret == 'ERR':
front_ret = 'N/A'
else:
front_ret = front_ret+'RPM'
sys_path = FAN_SYSFILE_PATH + 'fan{}_rear_rpm'.format(index)
rear_ret = get_attr_value(sys_path)
if rear_ret == 'ERR':
rear_ret = 'N/A'
else:
rear_ret = rear_ret+'RPM'
return (front_ret, rear_ret)
def is_psu_present(psu_number):
sys_path = POWER_SYSFILE_PATH + 'psu{}_prnt'.format(psu_number)
if os.path.exists(sys_path):
value = get_attr_value(sys_path)
if value == '1':
return True
else:
return False
return False
def is_psu_power_up(psu_number):
sys_path = POWER_SYSFILE_PATH + 'psu{}_good'.format(psu_number)
if os.path.exists(sys_path):
value = get_attr_value(sys_path)
if value == '1':
return True
else:
return False
return False
def show_psu_table():
headers = ['PSU', 'Presence', 'Power', 'Fan Speed(RPM)', 'Temperature(C)',
'Vin(V)', 'Vout(V)', 'Pin(W)', 'Pout(W)', 'Iin(A)', 'Iout(A)', 'Max Iout(A)']
table = []
psu_sysfiles_list = []
for index in range(0, MAX_PSU_NUM):
psu_sysfiles_list = [
POWER_SYSFILE_PATH+'psu{}_fan_speed'.format(index+1),
POWER_SYSFILE_PATH+'psu{}_temp'.format(index+1),
POWER_SYSFILE_PATH+'psu{}_vin'.format(index+1),
POWER_SYSFILE_PATH+'psu{}_vout'.format(index+1),
POWER_SYSFILE_PATH+'psu{}_pin'.format(index+1),
POWER_SYSFILE_PATH+'psu{}_pout'.format(index+1),
POWER_SYSFILE_PATH+'psu{}_iin'.format(index+1),
POWER_SYSFILE_PATH+'psu{}_iout'.format(index+1),
POWER_SYSFILE_PATH+'psu{}_mfr_iout_max'.format(index+1)
]
status_list = get_psu_status(index+1, psu_sysfiles_list)
table.append(status_list)
print(headers)
print(table)
print('')
def get_psu_status(index, sysfile_list):
# result_list: [name, presence, power, fanSpeed(RPM), temperature(C), vin(V), vout(V), pin(W), pout(W), iin(A), iout(A), maxIout(A)]
name = 'PSU{}'.format(index)
result_list = [name, 'Not Present', 'N/A', 'N/A', 'N/A',
'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A']
result_mutipler = [None, None, None, None, 1000.0, 1000.0,
1000.0, 1000000.0, 1000000.0, 1000.0, 1000.0, 1000.0]
if is_psu_present(index):
result_list[1] = 'Present'
else:
return result_list
if is_psu_power_up(index):
result_list[2] = 'up'
else:
result_list[2] = 'down'
for x in range(0, 9):
result_list[x+3] = get_attr_value(sysfile_list[x])
for x in range(0, 12):
if result_mutipler[x] != None and result_list[x] != 'ERR':
result_list[x] = int(result_list[x]) / result_mutipler[x]
return result_list
def main():
"""
Usage: %(scriptName)s command object
command:
fan_status : display fans status(present/power good)
"""
if len(sys.argv) < 2:
print (main.__doc__)
for arg in sys.argv[1:]:
if arg == 'fan_status':
show_fan_table()
elif arg == 'sensor_status':
show_sensor_table()
show_psu_table()
else:
print (main.__doc__)
if __name__ == "__main__":
main()

View File

@ -0,0 +1,17 @@
#!/bin/bash
start() {
# load platform driver, native drivers
/usr/local/bin/netberg_aurora-715_util.py install
}
stop() {
/usr/local/bin/netberg_aurora-715_util.py clean
}
case $1 in
start|stop) "$1" ;;
esac

View File

@ -0,0 +1,18 @@
#!/bin/sh
mr_reboot() {
sudo rmmod x86-64-netberg-aurora-715
sudo i2cset -y 0 0x30 0xa1 0
}
if [ $# -eq 0 ] || [ $@ = "-p" ] || [ $@ = "--reboot" ] || [ $@ = "--poweroff" ] || [ $@ = "-f" ] || [ $@ = "--force" ]; then
sync;sync
mr_reboot
elif [ $@ = "--halt" ]; then
sudo halt
else
echo "unsupported option"
fi

View File

@ -0,0 +1,18 @@
#!/bin/sh
mr_reboot() {
sudo rmmod x86-64-netberg-aurora-715
sudo i2cset -y 0 0x31 0xa1 0
}
if [ $# -eq 0 ] || [ $@ = "-r" ] || [ $@ = "--reboot" ] || [ $@ = "-h" ] || [ $@ = "-P" ] || [ $@ = "--poweroff" ]; then
sync;sync
mr_reboot
elif [ $@ = "-H" ] || [ $@ = "--halt" ]; then
sudo halt
else
echo "unsupported option"
fi

View File

@ -0,0 +1,6 @@
sonic-netberg-platform-modules (1.0.0) unstable; urgency=low
* Add support for Netberg Aurora 715
-- developer <support@netbergtw.com> Mon, 29 Jul 2019 11:00:00 +0800

View File

@ -0,0 +1 @@
9

View File

@ -0,0 +1,10 @@
Source: sonic-netberg-platform-modules
Section: main
Priority: extra
Maintainer: support@netbergtw.com
Build-Depends: debhelper (>= 8.0.0), bzip2
Standards-Version: 3.9.3
Package: sonic-platform-netberg-aurora-715
Architecture: amd64
Description: kernel modules for platform devices such as fan, led, sfp

View File

@ -0,0 +1,14 @@
#! /bin/sh
# driver version
PLATFROM=$1
PLATFROM_PATH=$2
export PLATFORM_DRIVER_VER='"0.3.16"'
echo "PLATFORM_DRIVER_VER = $PLATFORM_DRIVER_VER"
util_name=$(echo $PLATFROM)
j2 $PLATFROM_PATH/templates/netberg_${util_name}_util.py.j2 -o $PLATFROM_PATH/utils/netberg_${util_name}_util.py
chmod 775 $PLATFROM_PATH/utils/netberg_${util_name}_util.py

View File

@ -0,0 +1,41 @@
#!/usr/bin/make -f
export INSTALL_MOD_DIR:=extra
PYTHON3 ?= python3
PACKAGE_PRE_NAME := sonic-platform-netberg
KVERSION ?= $(shell uname -r)
KERNEL_SRC := /lib/modules/$(KVERSION)
MOD_SRC_DIR:= $(shell pwd)
MODULE_DIRS:= aurora-715
MODULE_DIR := modules
%:
dh $@
override_dh_auto_build:
(for mod in $(MODULE_DIRS); do \
make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
if [ -f "$${mod}/setup.py" ]; then \
rm -rdf build; \
$(PYTHON3) $${mod}/setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
fi;\
debian/netberg_platform_version.sh $${mod} $(MOD_SRC_DIR)/$${mod}; \
done)
override_dh_auto_install:
(for mod in $(MODULE_DIRS); do \
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} /$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko \
debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
done)
override_dh_usrlocal:
override_dh_clean:
dh_clean
(for mod in $(MODULE_DIRS); do \
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \
done)

View File

@ -0,0 +1,4 @@
aurora-715/scripts/* usr/bin
aurora-715/utils/* usr/local/bin
aurora-715/service/*.service lib/systemd/system
aurora-715/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-netberg_aurora_715-r0

View File

@ -0,0 +1,8 @@
#!/bin/sh
depmod -a
systemctl enable nba715-platform-init.service
systemctl start nba715-platform-init.service
/usr/local/bin/netberg_nba715_platform.sh