[platform]: update centec platform drivers and sai (#1702)
This commit is contained in:
parent
58db7f17a7
commit
eefd3f4ddb
@ -0,0 +1,70 @@
|
|||||||
|
{# Default values which will be used if no actual configura available #}
|
||||||
|
{% set default_cable = '40m' %}
|
||||||
|
{% set default_ports_num = 54 -%}
|
||||||
|
|
||||||
|
{# 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[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 -%}
|
||||||
|
{{ default_cable }}
|
||||||
|
{%- endif -%}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{%- if DEVICE_METADATA is defined %}
|
||||||
|
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
|
{# Generate list of ports if not defined #}
|
||||||
|
{% if PORT is not defined %}
|
||||||
|
{% set PORT = [] %}
|
||||||
|
{% for port_idx in range(1,default_ports_num+1) %}
|
||||||
|
{% if PORT.append("Ethernet%d" % (port_idx)) %}{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% 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 %}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
|||||||
|
# PG lossless profiles.
|
||||||
|
# speed cable size xon xoff threshold
|
||||||
|
1000 5m 34816 18432 16384 0
|
||||||
|
10000 5m 34816 18432 16384 0
|
||||||
|
25000 5m 34816 18432 16384 0
|
||||||
|
40000 5m 34816 18432 16384 0
|
||||||
|
50000 5m 34816 18432 16384 0
|
||||||
|
100000 5m 36864 18432 18432 0
|
||||||
|
1000 40m 36864 18432 18432 0
|
||||||
|
10000 40m 36864 18432 18432 0
|
||||||
|
25000 40m 39936 18432 21504 0
|
||||||
|
40000 40m 41984 18432 23552 0
|
||||||
|
50000 40m 41984 18432 23552 0
|
||||||
|
100000 40m 54272 18432 35840 0
|
||||||
|
1000 300m 49152 18432 30720 0
|
||||||
|
10000 300m 49152 18432 30720 0
|
||||||
|
25000 300m 71680 18432 53248 0
|
||||||
|
40000 300m 94208 18432 75776 0
|
||||||
|
50000 300m 94208 18432 75776 0
|
||||||
|
100000 300m 184320 18432 165888 0
|
||||||
|
|
@ -1,33 +1,55 @@
|
|||||||
# name lanes
|
# name lanes
|
||||||
Ethernet0 1
|
Ethernet1 4
|
||||||
Ethernet4 2
|
Ethernet2 5
|
||||||
Ethernet8 3
|
Ethernet3 6
|
||||||
Ethernet12 4
|
Ethernet4 8
|
||||||
Ethernet16 5
|
Ethernet5 9
|
||||||
Ethernet20 6
|
Ethernet6 10
|
||||||
Ethernet24 7
|
Ethernet7 12
|
||||||
Ethernet28 8
|
Ethernet8 13
|
||||||
Ethernet32 9
|
Ethernet9 14
|
||||||
Ethernet36 10
|
Ethernet10 16
|
||||||
Ethernet40 11
|
Ethernet11 17
|
||||||
Ethernet44 12
|
Ethernet12 18
|
||||||
Ethernet48 13
|
Ethernet13 20
|
||||||
Ethernet52 14
|
Ethernet14 21
|
||||||
Ethernet56 15
|
Ethernet15 22
|
||||||
Ethernet60 16
|
Ethernet16 24
|
||||||
Ethernet64 17
|
Ethernet17 25
|
||||||
Ethernet68 18
|
Ethernet18 26
|
||||||
Ethernet72 19
|
Ethernet19 28
|
||||||
Ethernet76 20
|
Ethernet20 30
|
||||||
Ethernet80 21
|
Ethernet21 31
|
||||||
Ethernet84 22
|
Ethernet22 32
|
||||||
Ethernet88 23
|
Ethernet23 34
|
||||||
Ethernet92 24
|
Ethernet24 35
|
||||||
Ethernet96 25
|
Ethernet25 40
|
||||||
Ethernet100 26
|
Ethernet26 41
|
||||||
Ethernet104 27
|
Ethernet27 43
|
||||||
Ethernet108 28
|
Ethernet28 36
|
||||||
Ethernet112 29
|
Ethernet29 37
|
||||||
Ethernet116 30
|
Ethernet30 39
|
||||||
Ethernet120 31
|
Ethernet31 44
|
||||||
Ethernet124 32
|
Ethernet32 45
|
||||||
|
Ethernet33 46
|
||||||
|
Ethernet34 47
|
||||||
|
Ethernet35 80
|
||||||
|
Ethernet36 81
|
||||||
|
Ethernet37 82
|
||||||
|
Ethernet38 88
|
||||||
|
Ethernet39 89
|
||||||
|
Ethernet40 90
|
||||||
|
Ethernet41 84
|
||||||
|
Ethernet42 85
|
||||||
|
Ethernet43 86
|
||||||
|
Ethernet44 87
|
||||||
|
Ethernet45 92
|
||||||
|
Ethernet46 93
|
||||||
|
Ethernet47 94
|
||||||
|
Ethernet48 95
|
||||||
|
Ethernet49 52,53,54,55
|
||||||
|
Ethernet50 56,57,58,59
|
||||||
|
Ethernet51 60,61,62,63
|
||||||
|
Ethernet52 68,69,70,71
|
||||||
|
Ethernet53 72,73,74,75
|
||||||
|
Ethernet54 76,77,78,79
|
||||||
|
133
device/centec/x86_64-centec_e582_48x6q-r0/E582-48x6q/qos.json
Normal file
133
device/centec/x86_64-centec_e582_48x6q-r0/E582-48x6q/qos.json
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
{
|
||||||
|
"DSCP_TO_TC_MAP": {
|
||||||
|
"AZURE": {
|
||||||
|
"0":"0",
|
||||||
|
"1":"0",
|
||||||
|
"2":"0",
|
||||||
|
"3":"0",
|
||||||
|
"4":"0",
|
||||||
|
"5":"0",
|
||||||
|
"6":"0",
|
||||||
|
"7":"0",
|
||||||
|
"8":"1",
|
||||||
|
"9":"1",
|
||||||
|
"10":"1",
|
||||||
|
"11":"1",
|
||||||
|
"12":"1",
|
||||||
|
"13":"1",
|
||||||
|
"14":"1",
|
||||||
|
"15":"1",
|
||||||
|
"16":"2",
|
||||||
|
"17":"2",
|
||||||
|
"18":"2",
|
||||||
|
"19":"2",
|
||||||
|
"20":"2",
|
||||||
|
"21":"2",
|
||||||
|
"22":"2",
|
||||||
|
"23":"2",
|
||||||
|
"24":"3",
|
||||||
|
"25":"3",
|
||||||
|
"26":"3",
|
||||||
|
"27":"3",
|
||||||
|
"28":"3",
|
||||||
|
"29":"3",
|
||||||
|
"30":"3",
|
||||||
|
"31":"3",
|
||||||
|
"32":"4",
|
||||||
|
"33":"4",
|
||||||
|
"34":"4",
|
||||||
|
"35":"4",
|
||||||
|
"36":"4",
|
||||||
|
"37":"4",
|
||||||
|
"38":"4",
|
||||||
|
"39":"4",
|
||||||
|
"40":"5",
|
||||||
|
"41":"5",
|
||||||
|
"42":"5",
|
||||||
|
"43":"5",
|
||||||
|
"44":"5",
|
||||||
|
"45":"5",
|
||||||
|
"46":"5",
|
||||||
|
"47":"5",
|
||||||
|
"48":"6",
|
||||||
|
"49":"6",
|
||||||
|
"50":"6",
|
||||||
|
"51":"6",
|
||||||
|
"52":"6",
|
||||||
|
"53":"6",
|
||||||
|
"54":"6",
|
||||||
|
"55":"6",
|
||||||
|
"56":"7",
|
||||||
|
"57":"7",
|
||||||
|
"58":"7",
|
||||||
|
"59":"7",
|
||||||
|
"60":"7",
|
||||||
|
"61":"7",
|
||||||
|
"62":"7",
|
||||||
|
"63":"7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SCHEDULER": {
|
||||||
|
"scheduler.0": {
|
||||||
|
"type":"DWRR",
|
||||||
|
"weight": "25"
|
||||||
|
},
|
||||||
|
"scheduler.1": {
|
||||||
|
"type":"DWRR",
|
||||||
|
"weight": "30"
|
||||||
|
},
|
||||||
|
"scheduler.2": {
|
||||||
|
"type":"DWRR",
|
||||||
|
"weight": "20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"PORT_QOS_MAP": {
|
||||||
|
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54": {
|
||||||
|
"dscp_to_tc_map" : "[DSCP_TO_TC_MAP|AZURE]",
|
||||||
|
"pfc_enable": "3,4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"WRED_PROFILE": {
|
||||||
|
"AZURE_LOSSY": {
|
||||||
|
"wred_green_enable":"true",
|
||||||
|
"wred_yellow_enable":"true",
|
||||||
|
"red_max_threshold":"32760",
|
||||||
|
"red_min_threshold":"4095",
|
||||||
|
"yellow_max_threshold":"32760",
|
||||||
|
"yellow_min_threshold":"4095",
|
||||||
|
"green_max_threshold": "32760",
|
||||||
|
"green_min_threshold": "4095"
|
||||||
|
},
|
||||||
|
"AZURE_LOSSLESS": {
|
||||||
|
"wred_green_enable":"true",
|
||||||
|
"wred_yellow_enable":"true",
|
||||||
|
"red_max_threshold":"32760",
|
||||||
|
"red_min_threshold":"4095",
|
||||||
|
"yellow_max_threshold":"32760",
|
||||||
|
"yellow_min_threshold":"4095",
|
||||||
|
"green_max_threshold": "32760",
|
||||||
|
"green_min_threshold": "4095"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"QUEUE": {
|
||||||
|
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|0-2": {
|
||||||
|
"scheduler" : "[SCHEDULER|scheduler.1]"
|
||||||
|
},
|
||||||
|
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|5-7": {
|
||||||
|
"scheduler" : "[SCHEDULER|scheduler.2]"
|
||||||
|
},
|
||||||
|
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|0-2": {
|
||||||
|
"wred_profile" : "[WRED_PROFILE|AZURE_LOSSY]"
|
||||||
|
},
|
||||||
|
|
||||||
|
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|5-7": {
|
||||||
|
"wred_profile" : "[WRED_PROFILE|AZURE_LOSSY]"
|
||||||
|
},
|
||||||
|
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|3-4": {
|
||||||
|
"scheduler" : "[SCHEDULER|scheduler.0]",
|
||||||
|
"wred_profile" : "[WRED_PROFILE|AZURE_LOSSLESS]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1 +1,3 @@
|
|||||||
BOARD_CONFIG_FILE_PATH=/etc/centec/E582-48x6q.json
|
BOARD_CONFIG_FILE_PATH=/etc/centec/E582-48x6q.json
|
||||||
|
SAI_INIT_CONFIG_FILE=/etc/centec/E582-48x6q-chip-profile.txt
|
||||||
|
SAI_HW_PORT_PROFILE_ID_CONFIG_FILE=/etc/centec/E582-48x6q-datapath-cfg.txt
|
||||||
|
11
device/centec/x86_64-centec_e582_48x6q-r0/fancontrol
Normal file
11
device/centec/x86_64-centec_e582_48x6q-r0/fancontrol
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Configuration file generated by pwmconfig, changes will be lost
|
||||||
|
INTERVAL=10
|
||||||
|
DEVPATH=hwmon0= hwmon5=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-15/15-002f
|
||||||
|
DEVNAME=hwmon0=acpitz hwmon5=adt7470
|
||||||
|
FCTEMPS=hwmon5/device/pwm4=hwmon0/temp1_input hwmon5/device/pwm3=hwmon0/temp1_input hwmon5/device/pwm2=hwmon0/temp1_input hwmon5/device/pwm1=hwmon0/temp1_input
|
||||||
|
FCFANS=hwmon5/device/pwm4=hwmon5/device/fan4_input hwmon5/device/pwm3=hwmon5/device/fan3_input hwmon5/device/pwm2=hwmon5/device/fan2_input hwmon5/device/pwm1=hwmon5/device/fan1_input
|
||||||
|
MINTEMP=hwmon5/device/pwm4=20 hwmon5/device/pwm3=20 hwmon5/device/pwm2=20 hwmon5/device/pwm1=20
|
||||||
|
MAXTEMP=hwmon5/device/pwm4=60 hwmon5/device/pwm3=60 hwmon5/device/pwm2=60 hwmon5/device/pwm1=60
|
||||||
|
MINSTART=hwmon5/device/pwm4=150 hwmon5/device/pwm3=12 hwmon5/device/pwm2=12 hwmon5/device/pwm1=150
|
||||||
|
MINSTOP=hwmon5/device/pwm4=0 hwmon5/device/pwm3=12 hwmon5/device/pwm2=12 hwmon5/device/pwm1=0
|
||||||
|
MAXPWM= hwmon5/device/pwm4=150
|
@ -1 +1,2 @@
|
|||||||
CONSOLE_SPEED=115200
|
CONSOLE_SPEED=115200
|
||||||
|
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="acpi_enforce_resources=no"
|
||||||
|
File diff suppressed because it is too large
Load Diff
31
device/centec/x86_64-centec_e582_48x6q-r0/plugins/eeprom.py
Normal file
31
device/centec/x86_64-centec_e582_48x6q-r0/plugins/eeprom.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# Centec E582-48X6Q
|
||||||
|
#
|
||||||
|
# Platform and model specific eeprom subclass, inherits from the base class,
|
||||||
|
# and provides the followings:
|
||||||
|
# - the eeprom format definition
|
||||||
|
# - specific encoder/decoder if there is special need
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
try:
|
||||||
|
import exceptions
|
||||||
|
import binascii
|
||||||
|
import time
|
||||||
|
import optparse
|
||||||
|
import warnings
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
from sonic_eeprom import eeprom_base
|
||||||
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
|
except ImportError, e:
|
||||||
|
raise ImportError (str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||||
|
|
||||||
|
def __init__(self, name, path, cpld_root, ro):
|
||||||
|
self.eeprom_path = "/sys/class/i2c-adapter/i2c-0/0-0057/eeprom"
|
||||||
|
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
153
device/centec/x86_64-centec_e582_48x6q-r0/plugins/led_control.py
Normal file
153
device/centec/x86_64-centec_e582_48x6q-r0/plugins/led_control.py
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# led_control.py
|
||||||
|
#
|
||||||
|
# Platform-specific LED control functionality for SONiC
|
||||||
|
#
|
||||||
|
|
||||||
|
try:
|
||||||
|
from sonic_led.led_control_base import LedControlBase
|
||||||
|
import swsssdk
|
||||||
|
import threading
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
import struct
|
||||||
|
import time
|
||||||
|
import syslog
|
||||||
|
from socket import *
|
||||||
|
from select import *
|
||||||
|
except ImportError, e:
|
||||||
|
raise ImportError(str(e) + " - required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
def DBG_PRINT(str):
|
||||||
|
syslog.openlog("centec-led")
|
||||||
|
syslog.syslog(syslog.LOG_INFO, str)
|
||||||
|
syslog.closelog()
|
||||||
|
|
||||||
|
class LedControl(LedControlBase):
|
||||||
|
"""Platform specific LED control class"""
|
||||||
|
SONIC_PORT_NAME_PREFIX = "Ethernet"
|
||||||
|
LED_MODE_UP = [11, 1]
|
||||||
|
LED_MODE_DOWN = [7, 2]
|
||||||
|
|
||||||
|
def _initSystemLed(self):
|
||||||
|
try:
|
||||||
|
with open(self.f_led.format("system"), 'w') as led_file:
|
||||||
|
led_file.write("5")
|
||||||
|
DBG_PRINT("init system led to normal")
|
||||||
|
with open(self.f_led.format("idn"), 'w') as led_file:
|
||||||
|
led_file.write("1")
|
||||||
|
DBG_PRINT("init idn led to off")
|
||||||
|
except IOError as e:
|
||||||
|
DBG_PRINT(str(e))
|
||||||
|
|
||||||
|
def _initPanelLed(self):
|
||||||
|
with open(self.f_led.format("port1"), 'r') as led_file:
|
||||||
|
shouldInit = (int(led_file.read()) == 0)
|
||||||
|
|
||||||
|
if shouldInit == True:
|
||||||
|
for (port, ctlid, defmode) in self.led_mapping[1:59]:
|
||||||
|
data = struct.pack('=HHHBBH', 0, 7, 4, ctlid, defmode, port)
|
||||||
|
self.udpClient.sendto(data, ('localhost', 8101))
|
||||||
|
|
||||||
|
data = struct.pack('=HHHBB34B', 0, 3, 36, 34, 0, *[x[0] for x in self.led_mapping[1:35]])
|
||||||
|
self.udpClient.sendto(data, ('localhost', 8101))
|
||||||
|
data = struct.pack('=HHHBB24B', 0, 3, 26, 24, 1, *[x[0] for x in self.led_mapping[35:59]])
|
||||||
|
self.udpClient.sendto(data, ('localhost', 8101))
|
||||||
|
|
||||||
|
data = struct.pack('=HHHB', 0, 5, 1, 1)
|
||||||
|
self.udpClient.sendto(data, ('localhost', 8101))
|
||||||
|
|
||||||
|
for idx in range(1, 55):
|
||||||
|
(port, ctlid, defmode) = self.led_mapping[idx]
|
||||||
|
with open(self.f_led.format("port{}".format(idx)), 'w') as led_file:
|
||||||
|
led_file.write(str(defmode))
|
||||||
|
DBG_PRINT("init port{} led to mode={}".format(idx, defmode))
|
||||||
|
|
||||||
|
for idx in range(1, 55):
|
||||||
|
(port, ctlid, defmode) = self.led_mapping[idx]
|
||||||
|
with open(self.f_led.format("port{}".format(idx)), 'r') as led_file:
|
||||||
|
defmode = int(led_file.read())
|
||||||
|
data = struct.pack('=HHHBBH', 0, 7, 4, ctlid, defmode, port)
|
||||||
|
self.udpClient.sendto(data, ('localhost', 8101))
|
||||||
|
DBG_PRINT("init port{} led to mode={}".format(idx, defmode))
|
||||||
|
|
||||||
|
def _initDefaultConfig(self):
|
||||||
|
DBG_PRINT("start init led")
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
r_sel = [self.udpClient]
|
||||||
|
echo_req = struct.pack('=HHH', 0, 1, 0)
|
||||||
|
self.udpClient.sendto(echo_req, ('localhost', 8101))
|
||||||
|
result = select(r_sel, [], [], 1)
|
||||||
|
if self.udpClient in result[0]:
|
||||||
|
echo_rsp, srv_addr = self.udpClient.recvfrom(1024)
|
||||||
|
if echo_rsp:
|
||||||
|
break
|
||||||
|
DBG_PRINT("connect to sdk rpc server timeout, try again.")
|
||||||
|
except IOError as e:
|
||||||
|
DBG_PRINT(str(e))
|
||||||
|
|
||||||
|
DBG_PRINT("connect to sdk rpc server success.")
|
||||||
|
|
||||||
|
self._initSystemLed()
|
||||||
|
self._initPanelLed()
|
||||||
|
|
||||||
|
DBG_PRINT("init led done")
|
||||||
|
|
||||||
|
|
||||||
|
# Helper method to map SONiC port name to index
|
||||||
|
def _port_name_to_index(self, port_name):
|
||||||
|
# Strip "Ethernet" off port name
|
||||||
|
if not port_name.startswith(self.SONIC_PORT_NAME_PREFIX):
|
||||||
|
return -1
|
||||||
|
|
||||||
|
port_idx = int(port_name[len(self.SONIC_PORT_NAME_PREFIX):])
|
||||||
|
return port_idx
|
||||||
|
|
||||||
|
def _port_state_to_mode(self, port_idx, state):
|
||||||
|
if state == "up":
|
||||||
|
return self.LED_MODE_UP[0] if (port_idx < 49) else self.LED_MODE_UP[1]
|
||||||
|
else:
|
||||||
|
return self.LED_MODE_DOWN[0] if (port_idx < 49) else self.LED_MODE_DOWN[1]
|
||||||
|
|
||||||
|
def _port_led_mode_update(self, port_idx, ledMode):
|
||||||
|
with open(self.f_led.format("port{}".format(port_idx)), 'w') as led_file:
|
||||||
|
led_file.write(str(ledMode))
|
||||||
|
(port, ctlid) = (self.led_mapping[port_idx][0], self.led_mapping[port_idx][1])
|
||||||
|
data = struct.pack('=HHHBBH', 0, 7, 4, ctlid, ledMode, port)
|
||||||
|
self.udpClient.sendto(data, ('localhost', 8101))
|
||||||
|
|
||||||
|
# Concrete implementation of port_link_state_change() method
|
||||||
|
def port_link_state_change(self, portname, state):
|
||||||
|
port_idx = self._port_name_to_index(portname)
|
||||||
|
ledMode = self._port_state_to_mode(port_idx, state)
|
||||||
|
with open(self.f_led.format("port{}".format(port_idx)), 'r') as led_file:
|
||||||
|
saveMode = int(led_file.read())
|
||||||
|
|
||||||
|
if ledMode == saveMode:
|
||||||
|
return
|
||||||
|
|
||||||
|
self._port_led_mode_update(port_idx, ledMode)
|
||||||
|
DBG_PRINT("update {} led mode from {} to {}".format(portname, saveMode, ledMode))
|
||||||
|
|
||||||
|
# Constructor
|
||||||
|
def __init__(self):
|
||||||
|
# [macid, ctlid, defaultmode]
|
||||||
|
self.led_mapping = [(0, 0, 0)] # resv
|
||||||
|
self.led_mapping.extend([(4, 0, 7), (5, 0, 7), (6, 0, 7), (8, 0, 7), (9, 0, 7), (10, 0, 7), (12, 0, 7), (13, 0, 7)]) # panel port 1~8
|
||||||
|
self.led_mapping.extend([(14, 0, 7), (16, 0, 7), (17, 0, 7), (18, 0, 7), (20, 0, 7), (21, 0, 7), (22, 0, 7), (24, 0, 7)]) # panel port 9~16
|
||||||
|
self.led_mapping.extend([(25, 0, 7), (26, 0, 7), (28, 0, 7), (30, 0, 7), (31, 0, 7), (32, 0, 7), (34, 0, 7), (35, 0, 7)]) # panel port 17~24
|
||||||
|
self.led_mapping.extend([(48, 0, 7), (49, 0, 7), (51, 0, 7), (36, 0, 7), (37, 0, 7), (39, 0, 7), (55, 0, 7), (54, 0, 7)]) # panel port 25~32
|
||||||
|
self.led_mapping.extend([(53, 0, 7), (52, 0, 7), (52, 1, 7), (53, 1, 7), (54, 1, 7), (55, 1, 7), (38, 1, 7), (37, 1, 7)]) # panel port 33~40
|
||||||
|
self.led_mapping.extend([(36, 1, 7), (51, 1, 7), (50, 1, 7), (49, 1, 7), (48, 1, 7), (34, 1, 7), (33, 1, 7), (32, 1, 7)]) # panel port 41~48
|
||||||
|
self.led_mapping.extend([(28, 1, 2), (24, 1, 2), (20, 1, 2), (12, 1, 2), (8, 1, 2), (4, 1, 2)]) # panel port 49~54
|
||||||
|
self.led_mapping.extend([(0, 1, 2), (0, 1, 2), (0, 1, 2), (0, 1, 2), (0, 1, 2), (0, 1, 2)])
|
||||||
|
|
||||||
|
self.f_led = "/sys/class/leds/{}/brightness"
|
||||||
|
|
||||||
|
self.udpClient = socket(AF_INET, SOCK_DGRAM)
|
||||||
|
|
||||||
|
self._initDefaultConfig()
|
||||||
|
|
74
device/centec/x86_64-centec_e582_48x6q-r0/plugins/psuutil.py
Normal file
74
device/centec/x86_64-centec_e582_48x6q-r0/plugins/psuutil.py
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# Mellanox
|
||||||
|
#
|
||||||
|
# Module contains an implementation of SONiC PSU Base API and
|
||||||
|
# provides the PSUs status which are available in the platform
|
||||||
|
#
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
try:
|
||||||
|
from sonic_psu.psu_base import PsuBase
|
||||||
|
except ImportError as e:
|
||||||
|
raise ImportError (str(e) + "- required module not found")
|
||||||
|
|
||||||
|
class PsuUtil(PsuBase):
|
||||||
|
"""Platform-specific PSUutil class"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
PsuBase.__init__(self)
|
||||||
|
|
||||||
|
self.psu_path = "/sys/class/psu/psu{}/"
|
||||||
|
self.psu_presence = "psu_presence"
|
||||||
|
self.psu_oper_status = "psu_status"
|
||||||
|
|
||||||
|
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 2
|
||||||
|
|
||||||
|
def get_psu_status(self, index):
|
||||||
|
"""
|
||||||
|
Retrieves the oprational status of power supply unit (PSU) defined
|
||||||
|
by 1-based index <index>
|
||||||
|
|
||||||
|
:param index: An integer, 1-based index of the PSU of which to query status
|
||||||
|
:return: Boolean, True if PSU is operating properly, False if PSU is faulty
|
||||||
|
"""
|
||||||
|
if index is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
status = 0
|
||||||
|
try:
|
||||||
|
with open(self.psu_path.format(index) + self.psu_oper_status, 'r') as power_status:
|
||||||
|
status = int(power_status.read())
|
||||||
|
except IOError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return status == 0
|
||||||
|
|
||||||
|
def get_psu_presence(self, index):
|
||||||
|
"""
|
||||||
|
Retrieves the presence status of power supply unit (PSU) defined
|
||||||
|
by 1-based index <index>
|
||||||
|
|
||||||
|
:param index: An integer, 1-based index of the PSU of which to query status
|
||||||
|
:return: Boolean, True if PSU is plugged, False if not
|
||||||
|
"""
|
||||||
|
if index is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
status = 0
|
||||||
|
try:
|
||||||
|
with open(self.psu_path.format(index) + self.psu_presence, 'r') as presence_status:
|
||||||
|
status = int(presence_status.read())
|
||||||
|
except IOError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return status == 0
|
160
device/centec/x86_64-centec_e582_48x6q-r0/plugins/sfputil.py
Normal file
160
device/centec/x86_64-centec_e582_48x6q-r0/plugins/sfputil.py
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# sfputil.py
|
||||||
|
#
|
||||||
|
# Platform-specific SFP transceiver interface for SONiC
|
||||||
|
#
|
||||||
|
|
||||||
|
try:
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
import struct
|
||||||
|
import syslog
|
||||||
|
from socket import *
|
||||||
|
from select import *
|
||||||
|
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||||
|
except ImportError as e:
|
||||||
|
raise ImportError("%s - required module not found" % str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def DBG_PRINT(str):
|
||||||
|
print str + "\n"
|
||||||
|
|
||||||
|
|
||||||
|
class SfpUtil(SfpUtilBase):
|
||||||
|
"""Platform-specific SfpUtil class"""
|
||||||
|
SONIC_PORT_NAME_PREFIX = "Ethernet"
|
||||||
|
PORT_START = 1
|
||||||
|
PORT_END = 54
|
||||||
|
PORTS_IN_BLOCK = 54
|
||||||
|
|
||||||
|
@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(49, self.PORTS_IN_BLOCK + 1)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def port_to_eeprom_mapping(self):
|
||||||
|
return self.eeprom_mapping
|
||||||
|
|
||||||
|
def is_logical_port(self, port_name):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def get_logical_to_physical(self, port_name):
|
||||||
|
if not port_name.startswith(self.SONIC_PORT_NAME_PREFIX):
|
||||||
|
return None
|
||||||
|
|
||||||
|
port_idx = int(port_name[len(self.SONIC_PORT_NAME_PREFIX):])
|
||||||
|
|
||||||
|
return [port_idx]
|
||||||
|
|
||||||
|
def get_eeprom_data(self, port):
|
||||||
|
(ctlid, devid) = self.fiber_mapping[port]
|
||||||
|
offset = (128 if port in self.qsfp_ports else 0)
|
||||||
|
r_sel = [self.udpClient]
|
||||||
|
req = struct.pack('=HHHBBHIBBBBI',
|
||||||
|
0, 9, 16, # lchip/msgtype/msglen
|
||||||
|
ctlid, # uint8 ctl_id
|
||||||
|
devid, # uint8 slave_dev_id
|
||||||
|
0x50, # uint16 dev_addr
|
||||||
|
(1<<devid), # uint32 slave_bitmap
|
||||||
|
offset, # uint8 offset
|
||||||
|
95, # uint8 length
|
||||||
|
0xf, # uint8 i2c_switch_id
|
||||||
|
0, # uint8 access_switch
|
||||||
|
95 # uint32 buf_length
|
||||||
|
)
|
||||||
|
self.udpClient.sendto(req, ('localhost', 8101))
|
||||||
|
result = select(r_sel, [], [], 1)
|
||||||
|
if self.udpClient in result[0]:
|
||||||
|
rsp, addr = self.udpClient.recvfrom(1024)
|
||||||
|
if rsp:
|
||||||
|
rsp_data = struct.unpack('=HHHBBHIBBBBIi512B', rsp)
|
||||||
|
if rsp_data[12] != 0:
|
||||||
|
return None
|
||||||
|
if port in self.qsfp_ports:
|
||||||
|
return buffer(bytearray([0]*128), 0, 128) + buffer(rsp, 26, 512)
|
||||||
|
return buffer(rsp, 26, 512)
|
||||||
|
return None
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
"""[ctlid, slavedevid]"""
|
||||||
|
self.fiber_mapping = [(0, 0)] # res
|
||||||
|
self.fiber_mapping.extend([(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7)]) # panel port 1~8
|
||||||
|
self.fiber_mapping.extend([(0, 14), (0, 13), (0, 15), (0, 12), (0, 8), (0, 11), (0, 9), (0, 10)]) # panel port 9~16
|
||||||
|
self.fiber_mapping.extend([(0, 22), (0, 21), (0, 23), (0, 20), (0, 16), (0, 19), (0, 17), (0, 18)]) # panel port 17~24
|
||||||
|
self.fiber_mapping.extend([(1, 4), (1, 3), (1, 5), (1, 2), (1, 6), (1, 1), (1, 7), (1, 0)]) # panel port 25~32
|
||||||
|
self.fiber_mapping.extend([(1, 8), (1, 15), (1, 9), (1, 14), (1, 10), (1, 13), (1, 11), (1, 12)]) # panel port 33~40
|
||||||
|
self.fiber_mapping.extend([(1, 22), (1, 21), (1, 23), (1, 20), (1, 16), (1, 19), (1, 17), (1, 18)]) # panel port 41~48
|
||||||
|
self.fiber_mapping.extend([(1, 28), (1, 29), (1, 26), (1, 27), (1, 24), (1, 25)]) # panel port 49~54
|
||||||
|
|
||||||
|
self.udpClient = socket(AF_INET, SOCK_DGRAM)
|
||||||
|
self.eeprom_mapping = {}
|
||||||
|
self.f_sfp_present = "/sys/class/sfp/sfp{}/sfp_presence"
|
||||||
|
self.f_sfp_enable = "/sys/class/sfp/sfp{}/sfp_enable"
|
||||||
|
|
||||||
|
for x in range(1, self.port_end + 1):
|
||||||
|
self.eeprom_mapping[x] = "/var/cache/sonic/sfp/sfp{}_eeprom".format(x)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not os.path.exists("/var/cache/sonic/sfp"):
|
||||||
|
os.makedirs("/var/cache/sonic/sfp", 0777)
|
||||||
|
for x in range(1, self.port_end + 1):
|
||||||
|
if not self.get_presence(x):
|
||||||
|
if os.path.exists(self.eeprom_mapping[x]):
|
||||||
|
os.remove(self.eeprom_mapping[x])
|
||||||
|
continue
|
||||||
|
data = self.get_eeprom_data(x)
|
||||||
|
if data:
|
||||||
|
with open(self.eeprom_mapping[x], 'w') as sfp_eeprom:
|
||||||
|
sfp_eeprom.write(data)
|
||||||
|
else:
|
||||||
|
DBG_PRINT("get sfp{} eeprom data failed.".format(x))
|
||||||
|
break
|
||||||
|
except IOError as e:
|
||||||
|
DBG_PRINT(str(e))
|
||||||
|
|
||||||
|
SfpUtilBase.__init__(self)
|
||||||
|
|
||||||
|
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
|
||||||
|
try:
|
||||||
|
with open(self.f_sfp_present.format(port_num), 'r') as sfp_file:
|
||||||
|
return 1 == int(sfp_file.read())
|
||||||
|
except IOError as e:
|
||||||
|
DBG_PRINT(str(e))
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
def reset(self, port_num):
|
||||||
|
# Check for invalid port_num
|
||||||
|
if port_num < self.port_start or port_num > self.port_end:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
@ -20,6 +20,11 @@ elif [ "$platform" == "cavium" ]; then
|
|||||||
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
||||||
elif [ "$platform" == "nephos" ]; then
|
elif [ "$platform" == "nephos" ]; then
|
||||||
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
||||||
|
elif [ "$platform" == "centec" ]; then
|
||||||
|
last_byte=$(python -c "print '$MAC_ADDRESS'[-2:]")
|
||||||
|
aligned_last_byte=$(python -c "print format(int(int('$last_byte', 16) + 1), '02x')") # put mask and take away the 0x prefix
|
||||||
|
ALIGNED_MAC_ADDRESS=$(python -c "print '$MAC_ADDRESS'[:-2] + '$aligned_last_byte'") # put aligned byte into the end of MAC
|
||||||
|
ORCHAGENT_ARGS+="-m $ALIGNED_MAC_ADDRESS"
|
||||||
elif [ "$platform" == "barefoot" ]; then
|
elif [ "$platform" == "barefoot" ]; then
|
||||||
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
||||||
fi
|
fi
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
SONIC_ONE_IMAGE = sonic-centec.bin
|
SONIC_ONE_IMAGE = sonic-centec.bin
|
||||||
$(SONIC_ONE_IMAGE)_MACHINE = centec
|
$(SONIC_ONE_IMAGE)_MACHINE = centec
|
||||||
$(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie
|
$(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie
|
||||||
$(SONIC_ONE_IMAGE)_INSTALLS += $(CENTEC_SDK_KERNEL)
|
$(SONIC_ONE_IMAGE)_INSTALLS += $(CENTEC_E582_48X6Q_PLATFORM_MODULE)
|
||||||
$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES)
|
$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES)
|
||||||
SONIC_INSTALLERS += $(SONIC_ONE_IMAGE)
|
SONIC_INSTALLERS += $(SONIC_ONE_IMAGE)
|
||||||
|
19
platform/centec/platform-modules-centec-e582.mk
Normal file
19
platform/centec/platform-modules-centec-e582.mk
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Centec E582-48X6Q Platform modules
|
||||||
|
|
||||||
|
|
||||||
|
CENTEC_E582_48X6Q_PLATFORM_MODULE_VERSION =1.1
|
||||||
|
CENTEC_E582_48X2Q4Z_PLATFORM_MODULE_VERSION =1.1
|
||||||
|
|
||||||
|
export CENTEC_E582_48X6Q_PLATFORM_MODULE_VERSION
|
||||||
|
export CENTEC_E582_48X2Q4Z_PLATFORM_MODULE_VERSION
|
||||||
|
|
||||||
|
CENTEC_E582_48X6Q_PLATFORM_MODULE = platform-modules-e582-48x6q_$(CENTEC_E582_48X6Q_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||||
|
|
||||||
|
$(CENTEC_E582_48X6Q_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-e582
|
||||||
|
$(CENTEC_E582_48X6Q_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
|
||||||
|
$(CENTEC_E582_48X6Q_PLATFORM_MODULE)_PLATFORM = x86_64-centec_e582_48x6q-r0
|
||||||
|
SONIC_DPKG_DEBS += $(CENTEC_E582_48X6Q_PLATFORM_MODULE)
|
||||||
|
|
||||||
|
CENTEC_E582_48X2Q4Z_PLATFORM_MODULE = platform-modules-e582-48x2q4z_$(CENTEC_E582_48X2Q4Z_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||||
|
$(CENTEC_E582_48X2Q4Z_PLATFORM_MODULE)_PLATFORM = x86_64-centec_e582_48x2q4z-r0
|
||||||
|
$(eval $(call add_extra_package,$(CENTEC_E582_48X6Q_PLATFORM_MODULE),$(CENTEC_E582_48X2Q4Z_PLATFORM_MODULE)))
|
@ -1,5 +1,5 @@
|
|||||||
|
include $(PLATFORM_PATH)/platform-modules-centec-e582.mk
|
||||||
include $(PLATFORM_PATH)/sdk.mk
|
include $(PLATFORM_PATH)/sdk.mk
|
||||||
include $(PLATFORM_PATH)/sai.mk
|
|
||||||
include $(PLATFORM_PATH)/docker-orchagent-centec.mk
|
include $(PLATFORM_PATH)/docker-orchagent-centec.mk
|
||||||
include $(PLATFORM_PATH)/docker-syncd-centec.mk
|
include $(PLATFORM_PATH)/docker-syncd-centec.mk
|
||||||
include $(PLATFORM_PATH)/docker-syncd-centec-rpc.mk
|
include $(PLATFORM_PATH)/docker-syncd-centec-rpc.mk
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
# Centec SAI
|
|
||||||
CENTEC_SAI = libsai_1.0.0_amd64.deb
|
|
||||||
$(CENTEC_SAI)_URL = https://github.com/CentecNetworks/goldengate-sai/raw/master/lib/SONiC_1.0/libsai_1.0.0_amd64.deb
|
|
||||||
|
|
||||||
SONIC_ONLINE_DEBS += $(CENTEC_SAI)
|
|
@ -1,4 +1,5 @@
|
|||||||
CENTEC_SDK_KERNEL = centec-gg-sdk3.5-modules-3.16.0-4-amd64.deb
|
# Centec SAI
|
||||||
$(CENTEC_SDK_KERNEL)_URL = "https://github.com/CentecNetworks/goldengate-sai/raw/master/lib/SONiC_1.0/centec-gg-sdk3.5-modules-3.16.0-4-amd64.deb"
|
CENTEC_SAI = libsai_1.2.4_amd64.deb
|
||||||
|
$(CENTEC_SAI)_URL = https://github.com/CentecNetworks/goldengate-sai/raw/master/lib/SONiC_1.2.4/libsai_1.2.4-1.0_amd64.deb
|
||||||
|
|
||||||
SONIC_ONLINE_DEBS += $(CENTEC_SDK_KERNEL)
|
SONIC_ONLINE_DEBS += $(CENTEC_SAI)
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
# /etc/modules: kernel modules to load at boot time.
|
||||||
|
#
|
||||||
|
# This file contains the names of kernel modules that should be loaded
|
||||||
|
# at boot time, one per line. Lines beginning with "#" are ignored.
|
||||||
|
|
||||||
|
i2c-i801
|
||||||
|
i2c-dev
|
||||||
|
i2c-mux
|
||||||
|
i2c-smbus
|
||||||
|
|
||||||
|
i2c-mux-pca954x
|
||||||
|
lm77
|
||||||
|
adt7470
|
||||||
|
tun
|
||||||
|
centec_e582_48x6q_platform
|
||||||
|
dal
|
||||||
|
centec_at24c64
|
@ -0,0 +1,2 @@
|
|||||||
|
obj-m := centec_e582_48x2q4z_platform.o dal.o centec_at24c64.o
|
||||||
|
dal-y := dal_kernel.o dal_mpool.o
|
@ -0,0 +1,657 @@
|
|||||||
|
/*
|
||||||
|
* at24.c - handle most I2C EEPROMs
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005-2007 David Brownell
|
||||||
|
* Copyright (C) 2008 Wolfram Sang, Pengutronix
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/init.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/sysfs.h>
|
||||||
|
#include <linux/mod_devicetable.h>
|
||||||
|
#include <linux/log2.h>
|
||||||
|
#include <linux/bitops.h>
|
||||||
|
#include <linux/jiffies.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/i2c.h>
|
||||||
|
#include <linux/platform_data/at24.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.
|
||||||
|
* Differences between different vendor product lines (like Atmel AT24C or
|
||||||
|
* MicroChip 24LC, etc) won't much matter for typical read/write access.
|
||||||
|
* There are also I2C RAM chips, likewise interchangeable. One example
|
||||||
|
* would be the PCF8570, which acts like a 24c02 EEPROM (256 bytes).
|
||||||
|
*
|
||||||
|
* However, misconfiguration can lose data. "Set 16-bit memory address"
|
||||||
|
* to a part with 8-bit addressing will overwrite data. Writing with too
|
||||||
|
* big a page size also loses data. And it's not safe to assume that the
|
||||||
|
* conventional addresses 0x50..0x57 only hold eeproms; a PCF8563 RTC
|
||||||
|
* uses 0x51, for just one example.
|
||||||
|
*
|
||||||
|
* Accordingly, explicit board-specific configuration data should be used
|
||||||
|
* in almost all cases. (One partial exception is an SMBus used to access
|
||||||
|
* "SPD" data for DRAM sticks. Those only use 24c02 EEPROMs.)
|
||||||
|
*
|
||||||
|
* So this driver uses "new style" I2C driver binding, expecting to be
|
||||||
|
* told what devices exist. That may be in arch/X/mach-Y/board-Z.c or
|
||||||
|
* similar kernel-resident tables; or, configuration data coming from
|
||||||
|
* a bootloader.
|
||||||
|
*
|
||||||
|
* Other than binding model, current differences from "eeprom" driver are
|
||||||
|
* that this one handles write access and isn't restricted to 24c02 devices.
|
||||||
|
* It also handles larger devices (32 kbit and up) with two-byte addresses,
|
||||||
|
* which won't work on pure SMBus systems.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct at24_data {
|
||||||
|
struct at24_platform_data chip;
|
||||||
|
struct memory_accessor macc;
|
||||||
|
int use_smbus;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lock protects against activities from other Linux tasks,
|
||||||
|
* but not from changes by other I2C masters.
|
||||||
|
*/
|
||||||
|
struct mutex lock;
|
||||||
|
struct bin_attribute bin;
|
||||||
|
|
||||||
|
u8 *writebuf;
|
||||||
|
unsigned write_max;
|
||||||
|
unsigned num_addresses;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some chips tie up multiple I2C addresses; dummy devices reserve
|
||||||
|
* them for us, and we'll use them with SMBus calls.
|
||||||
|
*/
|
||||||
|
struct i2c_client *client[];
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This parameter is to help this driver avoid blocking other drivers out
|
||||||
|
* of I2C for potentially troublesome amounts of time. With a 100 kHz I2C
|
||||||
|
* clock, one 256 byte read takes about 1/43 second which is excessive;
|
||||||
|
* but the 1/170 second it takes at 400 kHz may be quite reasonable; and
|
||||||
|
* at 1 MHz (Fm+) a 1/430 second delay could easily be invisible.
|
||||||
|
*
|
||||||
|
* This value is forced to be a power of two so that writes align on pages.
|
||||||
|
*/
|
||||||
|
static unsigned io_limit = 128;
|
||||||
|
module_param(io_limit, uint, 0);
|
||||||
|
MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specs often allow 5 msec for a page write, sometimes 20 msec;
|
||||||
|
* it's important to recover from write timeouts.
|
||||||
|
*/
|
||||||
|
static unsigned write_timeout = 25;
|
||||||
|
module_param(write_timeout, uint, 0);
|
||||||
|
MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)");
|
||||||
|
|
||||||
|
#define AT24_SIZE_BYTELEN 5
|
||||||
|
#define AT24_SIZE_FLAGS 8
|
||||||
|
|
||||||
|
#define AT24_BITMASK(x) (BIT(x) - 1)
|
||||||
|
|
||||||
|
/* create non-zero magic value for given eeprom parameters */
|
||||||
|
#define AT24_DEVICE_MAGIC(_len, _flags) \
|
||||||
|
((1 << AT24_SIZE_FLAGS | (_flags)) \
|
||||||
|
<< AT24_SIZE_BYTELEN | ilog2(_len))
|
||||||
|
|
||||||
|
static const struct i2c_device_id at24_ctc_ids[] = {
|
||||||
|
{ "24c64-ctc", AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16 | AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
|
||||||
|
{ /* END OF LIST */ }
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(i2c, at24_ctc_ids);
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This routine supports chips which consume multiple I2C addresses. It
|
||||||
|
* computes the addressing information to be used for a given r/w request.
|
||||||
|
* Assumes that sanity checks for offset happened at sysfs-layer.
|
||||||
|
*/
|
||||||
|
static struct i2c_client *at24_translate_offset(struct at24_data *at24,
|
||||||
|
unsigned *offset)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
if (at24->chip.flags & AT24_FLAG_ADDR16) {
|
||||||
|
i = *offset >> 16;
|
||||||
|
*offset &= 0xffff;
|
||||||
|
} else {
|
||||||
|
i = *offset >> 8;
|
||||||
|
*offset &= 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
return at24->client[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
|
||||||
|
unsigned offset, size_t count)
|
||||||
|
{
|
||||||
|
struct i2c_msg msg[2];
|
||||||
|
struct i2c_client *client;
|
||||||
|
unsigned long timeout, read_time;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
memset(msg, 0, sizeof(msg));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* REVISIT some multi-address chips don't rollover page reads to
|
||||||
|
* the next slave address, so we may need to truncate the count.
|
||||||
|
* Those chips might need another quirk flag.
|
||||||
|
*
|
||||||
|
* If the real hardware used four adjacent 24c02 chips and that
|
||||||
|
* were misconfigured as one 24c08, that would be a similar effect:
|
||||||
|
* one "eeprom" file not four, but larger reads would fail when
|
||||||
|
* they crossed certain pages.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Slave address and byte offset derive from the offset. Always
|
||||||
|
* set the byte address; on a multi-master board, another master
|
||||||
|
* may have changed the chip's "current" address pointer.
|
||||||
|
*/
|
||||||
|
client = at24_translate_offset(at24, &offset);
|
||||||
|
|
||||||
|
if (count > io_limit)
|
||||||
|
count = io_limit;
|
||||||
|
|
||||||
|
count = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reads fail if the previous write didn't complete yet. We may
|
||||||
|
* loop a few times until this one succeeds, waiting at least
|
||||||
|
* long enough for one entire page write to work.
|
||||||
|
*/
|
||||||
|
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||||
|
do {
|
||||||
|
read_time = jiffies;
|
||||||
|
|
||||||
|
status = i2c_smbus_write_byte_data(client, (offset >> 8) & 0x0ff, offset & 0x0ff );
|
||||||
|
status = i2c_smbus_read_byte(client);
|
||||||
|
if (status >= 0) {
|
||||||
|
buf[0] = status;
|
||||||
|
status = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n",
|
||||||
|
count, offset, status, jiffies);
|
||||||
|
|
||||||
|
if (status == count)
|
||||||
|
return count;
|
||||||
|
|
||||||
|
/* REVISIT: at HZ=100, this is sloooow */
|
||||||
|
msleep(1);
|
||||||
|
} while (time_before(read_time, timeout));
|
||||||
|
|
||||||
|
return -ETIMEDOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_read(struct at24_data *at24,
|
||||||
|
char *buf, loff_t off, size_t count)
|
||||||
|
{
|
||||||
|
ssize_t retval = 0;
|
||||||
|
|
||||||
|
if (unlikely(!count))
|
||||||
|
return count;
|
||||||
|
|
||||||
|
memset(buf, 0, count);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read data from chip, protecting against concurrent updates
|
||||||
|
* from this host, but not from other I2C masters.
|
||||||
|
*/
|
||||||
|
mutex_lock(&at24->lock);
|
||||||
|
|
||||||
|
while (count) {
|
||||||
|
ssize_t status;
|
||||||
|
|
||||||
|
status = at24_eeprom_read(at24, buf, off, count);
|
||||||
|
if (status <= 0) {
|
||||||
|
if (retval == 0)
|
||||||
|
retval = status;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buf += status;
|
||||||
|
off += status;
|
||||||
|
count -= status;
|
||||||
|
retval += status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//printk(KERN_ALERT "at24_read buf = %s, retval = %zu\n", buf, retval);
|
||||||
|
|
||||||
|
mutex_unlock(&at24->lock);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_bin_read(struct file *filp, struct kobject *kobj,
|
||||||
|
struct bin_attribute *attr,
|
||||||
|
char *buf, loff_t off, size_t count)
|
||||||
|
{
|
||||||
|
struct at24_data *at24;
|
||||||
|
|
||||||
|
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||||
|
return at24_read(at24, buf, off, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note that if the hardware write-protect pin is pulled high, the whole
|
||||||
|
* chip is normally write protected. But there are plenty of product
|
||||||
|
* variants here, including OTP fuses and partial chip protect.
|
||||||
|
*
|
||||||
|
* We only use page mode writes; the alternative is sloooow. This routine
|
||||||
|
* writes at most one page.
|
||||||
|
*/
|
||||||
|
static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
|
||||||
|
unsigned offset, size_t count)
|
||||||
|
{
|
||||||
|
struct i2c_client *client;
|
||||||
|
ssize_t status;
|
||||||
|
unsigned long timeout, write_time;
|
||||||
|
unsigned next_page;
|
||||||
|
|
||||||
|
/* Get corresponding I2C address and adjust offset */
|
||||||
|
client = at24_translate_offset(at24, &offset);
|
||||||
|
|
||||||
|
/* write_max is at most a page */
|
||||||
|
if (count > at24->write_max)
|
||||||
|
count = at24->write_max;
|
||||||
|
|
||||||
|
/* Never roll over backwards, to the start of this page */
|
||||||
|
next_page = roundup(offset + 1, at24->chip.page_size);
|
||||||
|
if (offset + count > next_page)
|
||||||
|
count = next_page - offset;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Writes fail if the previous one didn't complete yet. We may
|
||||||
|
* loop a few times until this one succeeds, waiting at least
|
||||||
|
* long enough for one entire page write to work.
|
||||||
|
*/
|
||||||
|
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||||
|
do {
|
||||||
|
write_time = jiffies;
|
||||||
|
|
||||||
|
status = i2c_smbus_write_word_data(client,
|
||||||
|
(offset >> 8) & 0x0ff, (offset & 0xFF) | buf[0]);
|
||||||
|
if (status == 0)
|
||||||
|
status = count;
|
||||||
|
|
||||||
|
dev_dbg(&client->dev, "write %zu@%d --> %zd (%ld)\n",
|
||||||
|
count, offset, status, jiffies);
|
||||||
|
|
||||||
|
if (status == count)
|
||||||
|
return count;
|
||||||
|
|
||||||
|
/* REVISIT: at HZ=100, this is sloooow */
|
||||||
|
msleep(1);
|
||||||
|
} while (time_before(write_time, timeout));
|
||||||
|
|
||||||
|
return -ETIMEDOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off,
|
||||||
|
size_t count)
|
||||||
|
{
|
||||||
|
ssize_t retval = 0;
|
||||||
|
|
||||||
|
if (unlikely(!count))
|
||||||
|
return count;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Write data to chip, protecting against concurrent updates
|
||||||
|
* from this host, but not from other I2C masters.
|
||||||
|
*/
|
||||||
|
mutex_lock(&at24->lock);
|
||||||
|
|
||||||
|
while (count) {
|
||||||
|
ssize_t status;
|
||||||
|
|
||||||
|
status = at24_eeprom_write(at24, buf, off, 1); /* only one-byte to write; TODO page wirte */
|
||||||
|
if (status <= 0) {
|
||||||
|
if (retval == 0)
|
||||||
|
retval = status;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buf += status;
|
||||||
|
off += status;
|
||||||
|
count -= status;
|
||||||
|
retval += status;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutex_unlock(&at24->lock);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_bin_write(struct file *filp, struct kobject *kobj,
|
||||||
|
struct bin_attribute *attr,
|
||||||
|
char *buf, loff_t off, size_t count)
|
||||||
|
{
|
||||||
|
struct at24_data *at24;
|
||||||
|
|
||||||
|
if (unlikely(off >= attr->size))
|
||||||
|
return -EFBIG;
|
||||||
|
|
||||||
|
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||||
|
return at24_write(at24, buf, off, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This lets other kernel code access the eeprom data. For example, it
|
||||||
|
* might hold a board's Ethernet address, or board-specific calibration
|
||||||
|
* data generated on the manufacturing floor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static ssize_t at24_macc_read(struct memory_accessor *macc, char *buf,
|
||||||
|
off_t offset, size_t count)
|
||||||
|
{
|
||||||
|
struct at24_data *at24 = container_of(macc, struct at24_data, macc);
|
||||||
|
|
||||||
|
return at24_read(at24, buf, offset, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf,
|
||||||
|
off_t offset, size_t count)
|
||||||
|
{
|
||||||
|
struct at24_data *at24 = container_of(macc, struct at24_data, macc);
|
||||||
|
|
||||||
|
return at24_write(at24, buf, offset, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_OF
|
||||||
|
static void at24_get_ofdata(struct i2c_client *client,
|
||||||
|
struct at24_platform_data *chip)
|
||||||
|
{
|
||||||
|
const __be32 *val;
|
||||||
|
struct device_node *node = client->dev.of_node;
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
if (of_get_property(node, "read-only", NULL))
|
||||||
|
chip->flags |= AT24_FLAG_READONLY;
|
||||||
|
val = of_get_property(node, "pagesize", NULL);
|
||||||
|
if (val)
|
||||||
|
chip->page_size = be32_to_cpup(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void at24_get_ofdata(struct i2c_client *client,
|
||||||
|
struct at24_platform_data *chip)
|
||||||
|
{ }
|
||||||
|
#endif /* CONFIG_OF */
|
||||||
|
|
||||||
|
static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||||
|
{
|
||||||
|
struct at24_platform_data chip;
|
||||||
|
bool writable;
|
||||||
|
int use_smbus = 0;
|
||||||
|
struct at24_data *at24;
|
||||||
|
int err;
|
||||||
|
unsigned i, num_addresses;
|
||||||
|
kernel_ulong_t magic;
|
||||||
|
|
||||||
|
if (client->dev.platform_data) {
|
||||||
|
chip = *(struct at24_platform_data *)client->dev.platform_data;
|
||||||
|
} else {
|
||||||
|
if (!id->driver_data)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
magic = id->driver_data;
|
||||||
|
chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
|
||||||
|
magic >>= AT24_SIZE_BYTELEN;
|
||||||
|
chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is slow, but we can't know all eeproms, so we better
|
||||||
|
* play safe. Specifying custom eeprom-types via platform_data
|
||||||
|
* is recommended anyhow.
|
||||||
|
*/
|
||||||
|
chip.page_size = 1;
|
||||||
|
|
||||||
|
/* update chipdata if OF is present */
|
||||||
|
at24_get_ofdata(client, &chip);
|
||||||
|
|
||||||
|
printk(KERN_ALERT "at24_probe chip.byte_len = 0x%x\n", chip.byte_len);
|
||||||
|
printk(KERN_ALERT "at24_probe chip.flags = 0x%x\n", chip.flags);
|
||||||
|
printk(KERN_ALERT "at24_probe chip.magic = 0x%lx\n", id->driver_data);
|
||||||
|
|
||||||
|
chip.setup = NULL;
|
||||||
|
chip.context = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_power_of_2(chip.byte_len))
|
||||||
|
dev_warn(&client->dev,
|
||||||
|
"byte_len looks suspicious (no power of 2)!\n");
|
||||||
|
if (!chip.page_size) {
|
||||||
|
dev_err(&client->dev, "page_size must not be 0!\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
if (!is_power_of_2(chip.page_size))
|
||||||
|
dev_warn(&client->dev,
|
||||||
|
"page_size looks suspicious (no power of 2)!\n");
|
||||||
|
|
||||||
|
/* Use I2C operations unless we're stuck with SMBus extensions. */
|
||||||
|
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
|
||||||
|
if (i2c_check_functionality(client->adapter,
|
||||||
|
I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
|
||||||
|
use_smbus = I2C_SMBUS_I2C_BLOCK_DATA;
|
||||||
|
} else if (i2c_check_functionality(client->adapter,
|
||||||
|
I2C_FUNC_SMBUS_READ_WORD_DATA)) {
|
||||||
|
use_smbus = I2C_SMBUS_WORD_DATA;
|
||||||
|
} else if (i2c_check_functionality(client->adapter,
|
||||||
|
I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
|
||||||
|
use_smbus = I2C_SMBUS_BYTE_DATA;
|
||||||
|
} else {
|
||||||
|
return -EPFNOSUPPORT;
|
||||||
|
}
|
||||||
|
use_smbus = I2C_SMBUS_BYTE_DATA;
|
||||||
|
printk(KERN_ALERT "at24_probe use_smbus --> %d\n",
|
||||||
|
use_smbus);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chip.flags & AT24_FLAG_TAKE8ADDR)
|
||||||
|
num_addresses = 8;
|
||||||
|
else
|
||||||
|
num_addresses = DIV_ROUND_UP(chip.byte_len,
|
||||||
|
(chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
|
||||||
|
|
||||||
|
at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
|
||||||
|
num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
|
||||||
|
if (!at24)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
mutex_init(&at24->lock);
|
||||||
|
at24->use_smbus = use_smbus;
|
||||||
|
at24->chip = chip;
|
||||||
|
at24->num_addresses = num_addresses;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Export the EEPROM bytes through sysfs, since that's convenient.
|
||||||
|
* By default, only root should see the data (maybe passwords etc)
|
||||||
|
*/
|
||||||
|
sysfs_bin_attr_init(&at24->bin);
|
||||||
|
at24->bin.attr.name = "eeprom";
|
||||||
|
at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
|
||||||
|
at24->bin.read = at24_bin_read;
|
||||||
|
at24->bin.size = chip.byte_len;
|
||||||
|
|
||||||
|
at24->macc.read = at24_macc_read;
|
||||||
|
|
||||||
|
writable = !(chip.flags & AT24_FLAG_READONLY);
|
||||||
|
if (writable) {
|
||||||
|
if (!use_smbus || i2c_check_functionality(client->adapter,
|
||||||
|
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
|
||||||
|
|
||||||
|
unsigned write_max = chip.page_size;
|
||||||
|
|
||||||
|
at24->macc.write = at24_macc_write;
|
||||||
|
|
||||||
|
at24->bin.write = at24_bin_write;
|
||||||
|
at24->bin.attr.mode |= S_IWUSR;
|
||||||
|
|
||||||
|
if (write_max > io_limit)
|
||||||
|
write_max = io_limit;
|
||||||
|
if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX)
|
||||||
|
write_max = I2C_SMBUS_BLOCK_MAX;
|
||||||
|
at24->write_max = write_max;
|
||||||
|
|
||||||
|
/* buffer (data + address at the beginning) */
|
||||||
|
at24->writebuf = devm_kzalloc(&client->dev,
|
||||||
|
write_max + 2, GFP_KERNEL);
|
||||||
|
if (!at24->writebuf)
|
||||||
|
return -ENOMEM;
|
||||||
|
} else {
|
||||||
|
dev_warn(&client->dev,
|
||||||
|
"cannot write due to controller restrictions.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
at24->client[0] = client;
|
||||||
|
|
||||||
|
/* use dummy devices for multiple-address chips */
|
||||||
|
for (i = 1; i < num_addresses; i++) {
|
||||||
|
at24->client[i] = i2c_new_dummy(client->adapter,
|
||||||
|
client->addr + i);
|
||||||
|
if (!at24->client[i]) {
|
||||||
|
dev_err(&client->dev, "address 0x%02x unavailable\n",
|
||||||
|
client->addr + i);
|
||||||
|
err = -EADDRINUSE;
|
||||||
|
goto err_clients;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = sysfs_create_bin_file(&client->dev.kobj, &at24->bin);
|
||||||
|
if (err)
|
||||||
|
goto err_clients;
|
||||||
|
|
||||||
|
i2c_set_clientdata(client, at24);
|
||||||
|
|
||||||
|
dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n",
|
||||||
|
at24->bin.size, client->name,
|
||||||
|
writable ? "writable" : "read-only", at24->write_max);
|
||||||
|
if (use_smbus == I2C_SMBUS_WORD_DATA ||
|
||||||
|
use_smbus == I2C_SMBUS_BYTE_DATA) {
|
||||||
|
dev_notice(&client->dev, "Falling back to %s reads, "
|
||||||
|
"performance will suffer\n", use_smbus ==
|
||||||
|
I2C_SMBUS_WORD_DATA ? "word" : "byte");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* export data to kernel code */
|
||||||
|
if (chip.setup)
|
||||||
|
chip.setup(&at24->macc, chip.context);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_clients:
|
||||||
|
for (i = 1; i < num_addresses; i++)
|
||||||
|
if (at24->client[i])
|
||||||
|
i2c_unregister_device(at24->client[i]);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int at24_remove(struct i2c_client *client)
|
||||||
|
{
|
||||||
|
struct at24_data *at24;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
at24 = i2c_get_clientdata(client);
|
||||||
|
sysfs_remove_bin_file(&client->dev.kobj, &at24->bin);
|
||||||
|
|
||||||
|
for (i = 1; i < at24->num_addresses; i++)
|
||||||
|
i2c_unregister_device(at24->client[i]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static struct i2c_board_info i2c_devs = {
|
||||||
|
I2C_BOARD_INFO("24c64-ctc", 0x57),
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct i2c_adapter *adapter = NULL;
|
||||||
|
static struct i2c_client *client = NULL;
|
||||||
|
|
||||||
|
static int ctc_at24c64_init(void)
|
||||||
|
{
|
||||||
|
printk(KERN_ALERT "ctc_at24c64_init\n");
|
||||||
|
|
||||||
|
adapter = i2c_get_adapter(0);
|
||||||
|
if(adapter == NULL){
|
||||||
|
printk(KERN_ALERT "i2c_get_adapter == NULL\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
client = i2c_new_device(adapter, &i2c_devs);
|
||||||
|
if(client == NULL){
|
||||||
|
printk(KERN_ALERT "i2c_new_device == NULL\n");
|
||||||
|
i2c_put_adapter(adapter);
|
||||||
|
adapter = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ctc_at24c64_exit(void)
|
||||||
|
{
|
||||||
|
printk(KERN_ALERT "ctc_at24c64_exit\n");
|
||||||
|
if(client){
|
||||||
|
i2c_unregister_device(client);
|
||||||
|
}
|
||||||
|
if(adapter){
|
||||||
|
i2c_put_adapter(adapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct i2c_driver at24_ctc_driver = {
|
||||||
|
.driver = {
|
||||||
|
.name = "at24-ctc",
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
},
|
||||||
|
.probe = at24_probe,
|
||||||
|
.remove = at24_remove,
|
||||||
|
.id_table = at24_ctc_ids,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int __init at24_ctc_init(void)
|
||||||
|
{
|
||||||
|
if (!io_limit) {
|
||||||
|
pr_err("at24_ctc: io_limit must not be 0!\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
io_limit = rounddown_pow_of_two(io_limit);
|
||||||
|
|
||||||
|
ctc_at24c64_init();
|
||||||
|
|
||||||
|
return i2c_add_driver(&at24_ctc_driver);
|
||||||
|
}
|
||||||
|
module_init(at24_ctc_init);
|
||||||
|
|
||||||
|
static void __exit at24_ctc_exit(void)
|
||||||
|
{
|
||||||
|
ctc_at24c64_exit();
|
||||||
|
i2c_del_driver(&at24_ctc_driver);
|
||||||
|
}
|
||||||
|
module_exit(at24_ctc_exit);
|
||||||
|
|
||||||
|
MODULE_DESCRIPTION("Driver for most I2C EEPROMs");
|
||||||
|
MODULE_AUTHOR("David Brownell and Wolfram Sang");
|
||||||
|
MODULE_LICENSE("GPL");
|
@ -0,0 +1,142 @@
|
|||||||
|
#include <linux/init.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/i2c.h>
|
||||||
|
#include <linux/i2c/pca954x.h>
|
||||||
|
|
||||||
|
#define PCA9548_CHANNEL_NUM 8
|
||||||
|
#define PCA9548_ADAPT_ID_START 10
|
||||||
|
|
||||||
|
static struct pca954x_platform_mode i2c_dev_pca9548_platform_mode[PCA9548_CHANNEL_NUM] = {
|
||||||
|
[0] = {
|
||||||
|
.adap_id = PCA9548_ADAPT_ID_START,
|
||||||
|
.deselect_on_exit = 1,
|
||||||
|
.class = 0,
|
||||||
|
},
|
||||||
|
[1] = {
|
||||||
|
.adap_id = PCA9548_ADAPT_ID_START + 1,
|
||||||
|
.deselect_on_exit = 1,
|
||||||
|
.class = 0,
|
||||||
|
},
|
||||||
|
[2] = {
|
||||||
|
.adap_id = PCA9548_ADAPT_ID_START + 2,
|
||||||
|
.deselect_on_exit = 1,
|
||||||
|
.class = 0,
|
||||||
|
},
|
||||||
|
[3] = {
|
||||||
|
.adap_id = PCA9548_ADAPT_ID_START + 3,
|
||||||
|
.deselect_on_exit = 1,
|
||||||
|
.class = 0,
|
||||||
|
},
|
||||||
|
[4] = {
|
||||||
|
.adap_id = PCA9548_ADAPT_ID_START + 4,
|
||||||
|
.deselect_on_exit = 1,
|
||||||
|
.class = 0,
|
||||||
|
},
|
||||||
|
[5] = {
|
||||||
|
.adap_id = PCA9548_ADAPT_ID_START + 5,
|
||||||
|
.deselect_on_exit = 1,
|
||||||
|
.class = 0,
|
||||||
|
},
|
||||||
|
[6] = {
|
||||||
|
.adap_id = PCA9548_ADAPT_ID_START + 6,
|
||||||
|
.deselect_on_exit = 1,
|
||||||
|
.class = 0,
|
||||||
|
},
|
||||||
|
[7] = {
|
||||||
|
.adap_id = PCA9548_ADAPT_ID_START + 7,
|
||||||
|
.deselect_on_exit = 1,
|
||||||
|
.class = 0,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct pca954x_platform_data i2c_dev_pca9548_platform_data = {
|
||||||
|
.modes = i2c_dev_pca9548_platform_mode,
|
||||||
|
.num_modes = PCA9548_CHANNEL_NUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct i2c_board_info i2c_dev_pca9548 = {
|
||||||
|
I2C_BOARD_INFO("pca9548", 0x70),
|
||||||
|
.platform_data = &i2c_dev_pca9548_platform_data,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct i2c_board_info i2c_dev_adt7475 = {
|
||||||
|
I2C_BOARD_INFO("adt7470", 0x2F),
|
||||||
|
};
|
||||||
|
|
||||||
|
struct i2c_adapter *i2c_core_master = NULL; /* i2c-0-cpu */
|
||||||
|
struct i2c_adapter *i2c_mux_channel_4 = NULL; /* pca9548x-channel 5 */
|
||||||
|
struct i2c_client *i2c_client_pca9548x = NULL;
|
||||||
|
struct i2c_client *i2c_client_adt7475 = NULL;
|
||||||
|
|
||||||
|
static int e582_48x6q_init(void)
|
||||||
|
{
|
||||||
|
printk(KERN_INFO "install e582_48x6q board dirver...\n");
|
||||||
|
|
||||||
|
/* find i2c-core master */
|
||||||
|
i2c_core_master = i2c_get_adapter(0);
|
||||||
|
if(i2c_core_master == NULL)
|
||||||
|
{
|
||||||
|
printk(KERN_CRIT "can't find i2c-core bus\n");
|
||||||
|
goto err_i2c_core_master;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* install i2c-mux */
|
||||||
|
i2c_client_pca9548x = i2c_new_device(i2c_core_master, &i2c_dev_pca9548);
|
||||||
|
if(i2c_client_pca9548x == NULL)
|
||||||
|
{
|
||||||
|
printk(KERN_INFO "install e582_48x6q board pca9548 failed\n");
|
||||||
|
goto install_at24c64;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* install adt7475 */
|
||||||
|
/* find i2c-mux-channel 15 */
|
||||||
|
i2c_mux_channel_4 = i2c_get_adapter(PCA9548_ADAPT_ID_START + 4);
|
||||||
|
if(i2c_mux_channel_4 == NULL)
|
||||||
|
{
|
||||||
|
printk(KERN_INFO "install e582_48x6q board adt7470 failed\n");
|
||||||
|
goto install_at24c64;
|
||||||
|
}
|
||||||
|
|
||||||
|
i2c_client_adt7475 = i2c_new_device(i2c_mux_channel_4, &i2c_dev_adt7475);
|
||||||
|
if(i2c_client_adt7475 == NULL){
|
||||||
|
printk(KERN_INFO "install e582_48x6q board adt7470 failed\n");
|
||||||
|
goto install_at24c64;
|
||||||
|
}
|
||||||
|
|
||||||
|
install_at24c64:
|
||||||
|
|
||||||
|
printk(KERN_INFO "install e582_48x6q board dirver...ok\n");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_i2c_core_master:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void e582_48x6q_exit(void)
|
||||||
|
{
|
||||||
|
printk(KERN_INFO "uninstall e582_48x6q board dirver...\n");
|
||||||
|
|
||||||
|
/* uninstall adt7475 master */
|
||||||
|
if(i2c_client_adt7475) {
|
||||||
|
i2c_unregister_device(i2c_client_adt7475);
|
||||||
|
}
|
||||||
|
if(i2c_mux_channel_4) {
|
||||||
|
i2c_put_adapter(i2c_mux_channel_4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* uninstall i2c-core master */
|
||||||
|
if(i2c_client_pca9548x) {
|
||||||
|
i2c_unregister_device(i2c_client_pca9548x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* uninstall i2c-core master */
|
||||||
|
if(i2c_core_master) {
|
||||||
|
i2c_put_adapter(i2c_core_master);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MODULE_LICENSE("Dual BSD/GPL");
|
||||||
|
MODULE_AUTHOR("xuwj centecNetworks, Inc");
|
||||||
|
MODULE_DESCRIPTION("e582-48x6q board driver");
|
||||||
|
module_init(e582_48x6q_init);
|
||||||
|
module_exit(e582_48x6q_exit);
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,170 @@
|
|||||||
|
/**
|
||||||
|
@file dal_kernel_io.h
|
||||||
|
|
||||||
|
@author Copyright (C) 2012 Centec Networks Inc. All rights reserved.
|
||||||
|
|
||||||
|
@date 2012-4-9
|
||||||
|
|
||||||
|
@version v2.0
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifndef _DAL_KERNEL_H_
|
||||||
|
#define _DAL_KERNEL_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RESOURCES_64BIT) || defined(CONFIG_PHYS_ADDR_T_64BIT)
|
||||||
|
#define PHYS_ADDR_IS_64BIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SDK_IN_USERMODE
|
||||||
|
#ifdef PHYS_ADDR_IS_64BIT
|
||||||
|
typedef long long intptr;
|
||||||
|
typedef unsigned long long uintptr;
|
||||||
|
#else
|
||||||
|
typedef int intptr;
|
||||||
|
typedef unsigned int uintptr;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DAL_PCI_READ_ADDR 0x0
|
||||||
|
#define DAL_PCI_READ_DATA 0xc
|
||||||
|
#define DAL_PCI_WRITE_ADDR 0x8
|
||||||
|
#define DAL_PCI_WRITE_DATA 0x4
|
||||||
|
#define DAL_PCI_STATUS 0x10
|
||||||
|
|
||||||
|
#define DAL_PCI_STATUS_IN_PROCESS 31
|
||||||
|
#define DAL_PCI_STATUS_BAD_PARITY 5
|
||||||
|
#define DAL_PCI_STATUS_CPU_ACCESS_ERR 4
|
||||||
|
#define DAL_PCI_STATUS_READ_CMD 3
|
||||||
|
#define DAL_PCI_STATUS_REGISTER_ERR 1
|
||||||
|
#define DAL_PCI_STATUS_REGISTER_ACK 0
|
||||||
|
|
||||||
|
#define DAL_PCI_ACCESS_TIMEOUT 0x64
|
||||||
|
|
||||||
|
#define DAL_NAME "linux_dal" /* "linux_dal" */
|
||||||
|
|
||||||
|
#define DAL_DEV_MAJOR 198
|
||||||
|
|
||||||
|
#define DAL_DEV_INTR_MAJOR_BASE 200
|
||||||
|
|
||||||
|
#define DAL_DEV_NAME "/dev/" DAL_NAME
|
||||||
|
#define DAL_ONE_KB 1024
|
||||||
|
#define DAL_ONE_MB (1024*1024)
|
||||||
|
struct dal_chip_parm_s
|
||||||
|
{
|
||||||
|
unsigned int chip_id; /*tmp should be uint8*/
|
||||||
|
unsigned int fpga_id; /*tmp add*/
|
||||||
|
unsigned int reg_addr;
|
||||||
|
unsigned int value;
|
||||||
|
};
|
||||||
|
typedef struct dal_chip_parm_s dal_chip_parm_t;
|
||||||
|
|
||||||
|
struct dal_intr_parm_s
|
||||||
|
{
|
||||||
|
unsigned int irq;
|
||||||
|
unsigned int enable;
|
||||||
|
};
|
||||||
|
typedef struct dal_intr_parm_s dal_intr_parm_t;
|
||||||
|
|
||||||
|
struct dal_irq_mapping_s
|
||||||
|
{
|
||||||
|
unsigned int hw_irq;
|
||||||
|
unsigned int sw_irq;
|
||||||
|
};
|
||||||
|
typedef struct dal_irq_mapping_s dal_irq_mapping_t;
|
||||||
|
|
||||||
|
struct dal_user_dev_s
|
||||||
|
{
|
||||||
|
unsigned int chip_num; /*output: local chip number*/
|
||||||
|
unsigned int chip_id; /*input: local chip id*/
|
||||||
|
unsigned int phy_base0; /* low 32bits physical base address */
|
||||||
|
unsigned int phy_base1; /* high 32bits physical base address */
|
||||||
|
unsigned int bus_no;
|
||||||
|
unsigned int dev_no;
|
||||||
|
unsigned int fun_no;
|
||||||
|
void* virt_base[2]; /* Virtual base address; this must be last member */
|
||||||
|
};
|
||||||
|
typedef struct dal_user_dev_s dal_user_dev_t;
|
||||||
|
|
||||||
|
struct dma_info_s
|
||||||
|
{
|
||||||
|
unsigned int lchip;
|
||||||
|
unsigned int phy_base;
|
||||||
|
unsigned int phy_base_hi;
|
||||||
|
unsigned int size;
|
||||||
|
unsigned int* virt_base;
|
||||||
|
};
|
||||||
|
typedef struct dma_info_s dma_info_t;
|
||||||
|
|
||||||
|
struct dal_pci_cfg_ioctl_s
|
||||||
|
{
|
||||||
|
unsigned int chip_id; /* Device ID */
|
||||||
|
unsigned int offset;
|
||||||
|
unsigned int value;
|
||||||
|
};
|
||||||
|
typedef struct dal_pci_cfg_ioctl_s dal_pci_cfg_ioctl_t;
|
||||||
|
|
||||||
|
struct dal_msi_info_s
|
||||||
|
{
|
||||||
|
unsigned int lchip;
|
||||||
|
unsigned int irq_base;
|
||||||
|
unsigned int irq_num;
|
||||||
|
};
|
||||||
|
typedef struct dal_msi_info_s dal_msi_info_t;
|
||||||
|
|
||||||
|
struct dal_intr_info_s
|
||||||
|
{
|
||||||
|
unsigned int irq;
|
||||||
|
unsigned int irq_idx;
|
||||||
|
};
|
||||||
|
typedef struct dal_intr_info_s dal_intr_info_t;
|
||||||
|
|
||||||
|
struct dal_dma_cache_info_s
|
||||||
|
{
|
||||||
|
unsigned long ptr;
|
||||||
|
unsigned int length;
|
||||||
|
};
|
||||||
|
typedef struct dal_dma_cache_info_s dal_dma_cache_info_t;
|
||||||
|
|
||||||
|
#define CMD_MAGIC 'C'
|
||||||
|
#define CMD_WRITE_CHIP _IO(CMD_MAGIC, 0) /* for humber ioctrol*/
|
||||||
|
#define CMD_READ_CHIP _IO(CMD_MAGIC, 1) /* for humber ioctrol*/
|
||||||
|
#define CMD_GET_DEVICES _IO(CMD_MAGIC, 2)
|
||||||
|
#define CMD_GET_DAL_VERSION _IO(CMD_MAGIC, 3)
|
||||||
|
#define CMD_PCI_CONFIG_WRITE _IO(CMD_MAGIC, 4)
|
||||||
|
#define CMD_PCI_CONFIG_READ _IO(CMD_MAGIC, 5)
|
||||||
|
#define CMD_GET_DMA_INFO _IO(CMD_MAGIC, 6)
|
||||||
|
#define CMD_REG_INTERRUPTS _IO(CMD_MAGIC, 7)
|
||||||
|
#define CMD_UNREG_INTERRUPTS _IO(CMD_MAGIC, 8)
|
||||||
|
#define CMD_EN_INTERRUPTS _IO(CMD_MAGIC, 9)
|
||||||
|
#define CMD_I2C_READ _IO(CMD_MAGIC, 10)
|
||||||
|
#define CMD_I2C_WRITE _IO(CMD_MAGIC, 11)
|
||||||
|
#define CMD_GET_MSI_INFO _IO(CMD_MAGIC, 12)
|
||||||
|
#define CMD_SET_MSI_CAP _IO(CMD_MAGIC, 13)
|
||||||
|
#define CMD_IRQ_MAPPING _IO(CMD_MAGIC, 14)
|
||||||
|
#define CMD_GET_INTR_INFO _IO(CMD_MAGIC, 15)
|
||||||
|
#define CMD_CACHE_INVAL _IO(CMD_MAGIC, 16)
|
||||||
|
#define CMD_CACHE_FLUSH _IO(CMD_MAGIC, 17)
|
||||||
|
|
||||||
|
enum dal_version_e
|
||||||
|
{
|
||||||
|
VERSION_MIN,
|
||||||
|
VERSION_1DOT0,
|
||||||
|
VERSION_1DOT1,
|
||||||
|
VERSION_1DOT2,
|
||||||
|
|
||||||
|
VERSION_MAX
|
||||||
|
};
|
||||||
|
typedef enum dal_version_e dal_version_t;
|
||||||
|
|
||||||
|
/* We try to assemble a contiguous segment from chunks of this size */
|
||||||
|
#define DMA_BLOCK_SIZE (512 * DAL_ONE_KB)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,343 @@
|
|||||||
|
|
||||||
|
#include "dal_mpool.h"
|
||||||
|
|
||||||
|
#ifdef __KERNEL__
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
|
||||||
|
#define DAL_MALLOC(x) kmalloc(x, GFP_ATOMIC)
|
||||||
|
#define DAL_FREE(x) kfree(x)
|
||||||
|
|
||||||
|
static spinlock_t dal_mpool_lock;
|
||||||
|
#define MPOOL_LOCK_INIT() spin_lock_init(&dal_mpool_lock)
|
||||||
|
#define MPOOL_LOCK() unsigned long flags; spin_lock_irqsave(&dal_mpool_lock, flags)
|
||||||
|
#define MPOOL_UNLOCK() spin_unlock_irqrestore(&dal_mpool_lock, flags)
|
||||||
|
#define DAL_PRINT(fmt,arg...) printk(fmt,##arg)
|
||||||
|
#else /* !__KERNEL__*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "sal.h"
|
||||||
|
#define DAL_MALLOC(x) malloc(x)
|
||||||
|
#define DAL_FREE(x) free(x)
|
||||||
|
static sal_mutex_t* dal_mpool_lock;
|
||||||
|
#define MPOOL_LOCK_INIT() sal_mutex_create(&dal_mpool_lock)
|
||||||
|
#define MPOOL_LOCK() sal_mutex_lock(dal_mpool_lock)
|
||||||
|
#define MPOOL_UNLOCK() sal_mutex_unlock(dal_mpool_lock)
|
||||||
|
#define DAL_PRINT(fmt,arg...) sal_printf(fmt,##arg)
|
||||||
|
|
||||||
|
#endif /* __KERNEL__ */
|
||||||
|
|
||||||
|
dal_mpool_mem_t* g_free_block_ptr = NULL;
|
||||||
|
|
||||||
|
/* System cache line size */
|
||||||
|
#ifndef DAL_CACHE_LINE_BYTES
|
||||||
|
#define DAL_CACHE_LINE_BYTES 256
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static dal_mpool_mem_t* p_desc_pool = NULL;
|
||||||
|
static dal_mpool_mem_t* p_data_pool = NULL;
|
||||||
|
|
||||||
|
int
|
||||||
|
dal_mpool_init(void)
|
||||||
|
{
|
||||||
|
MPOOL_LOCK_INIT();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dal_mpool_mem_t*
|
||||||
|
_dal_mpool_create(void* base, int size, int type)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* head = NULL;
|
||||||
|
dal_mpool_mem_t* tail = NULL;
|
||||||
|
|
||||||
|
head = (dal_mpool_mem_t*)DAL_MALLOC(sizeof(dal_mpool_mem_t));
|
||||||
|
if (head == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tail = (dal_mpool_mem_t*)DAL_MALLOC(sizeof(dal_mpool_mem_t));
|
||||||
|
if (tail == NULL)
|
||||||
|
{
|
||||||
|
DAL_FREE(head);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
head->size = tail->size = 0;
|
||||||
|
head->type = type;
|
||||||
|
head->address = base;
|
||||||
|
tail->address = head->address + size;
|
||||||
|
head->next = tail;
|
||||||
|
tail->next = NULL;
|
||||||
|
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
|
dal_mpool_mem_t*
|
||||||
|
dal_mpool_create(void* base, int size)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* head = NULL;
|
||||||
|
int mod = (int)(((unsigned long)base) & (DAL_CACHE_LINE_BYTES - 1));
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
if (mod)
|
||||||
|
{
|
||||||
|
base = (char*)base + (DAL_CACHE_LINE_BYTES - mod);
|
||||||
|
size -= (DAL_CACHE_LINE_BYTES - mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
size &= ~(DAL_CACHE_LINE_BYTES - 1);
|
||||||
|
|
||||||
|
/* init for common linkptr, only used for GB */
|
||||||
|
head = _dal_mpool_create(base, size, DAL_MPOOL_TYPE_USELESS);
|
||||||
|
if (NULL == head)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* init for desc linkptr */
|
||||||
|
p_desc_pool = _dal_mpool_create(base, DAL_MPOOL_MAX_DESX_SIZE, DAL_MPOOL_TYPE_DESC);
|
||||||
|
if (NULL == p_desc_pool)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
DAL_FREE(head->next);
|
||||||
|
DAL_FREE(head);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* init for data linkptr */
|
||||||
|
p_data_pool = _dal_mpool_create(((char*)base+DAL_MPOOL_MAX_DESX_SIZE), (size - DAL_MPOOL_MAX_DESX_SIZE), DAL_MPOOL_TYPE_DATA);
|
||||||
|
if (NULL == p_data_pool)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
DAL_FREE(head->next);
|
||||||
|
DAL_FREE(head);
|
||||||
|
DAL_FREE(p_desc_pool->next);
|
||||||
|
DAL_FREE(p_desc_pool);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
|
dal_mpool_mem_t*
|
||||||
|
_dal_mpool_alloc_comon(dal_mpool_mem_t* ptr, int size, int type)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* new_ptr = NULL;
|
||||||
|
|
||||||
|
while (ptr && ptr->next)
|
||||||
|
{
|
||||||
|
if (ptr->next->address - (ptr->address + ptr->size) >= size)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(ptr && ptr->next))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_ptr = DAL_MALLOC(sizeof(dal_mpool_mem_t));
|
||||||
|
if (!new_ptr)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_ptr->type = type;
|
||||||
|
new_ptr->address = ptr->address + ptr->size;
|
||||||
|
new_ptr->size = size;
|
||||||
|
new_ptr->next = ptr->next;
|
||||||
|
ptr->next = new_ptr;
|
||||||
|
|
||||||
|
return new_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void*
|
||||||
|
dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* ptr = NULL;
|
||||||
|
dal_mpool_mem_t* new_ptr = NULL;
|
||||||
|
int mod;
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
mod = size & (DAL_CACHE_LINE_BYTES - 1);
|
||||||
|
if (mod != 0)
|
||||||
|
{
|
||||||
|
size += (DAL_CACHE_LINE_BYTES - mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case DAL_MPOOL_TYPE_USELESS:
|
||||||
|
ptr = pool;
|
||||||
|
new_ptr = _dal_mpool_alloc_comon(ptr, size, type);
|
||||||
|
if (NULL == new_ptr)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DAL_MPOOL_TYPE_DESC:
|
||||||
|
ptr = p_desc_pool;
|
||||||
|
new_ptr = _dal_mpool_alloc_comon(ptr, size, type);
|
||||||
|
if (NULL == new_ptr)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DAL_MPOOL_TYPE_DATA:
|
||||||
|
ptr = p_data_pool;
|
||||||
|
new_ptr = _dal_mpool_alloc_comon(ptr, size, type);
|
||||||
|
if (NULL == new_ptr)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
|
||||||
|
return new_ptr->address;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_dal_mpool_free(dal_mpool_mem_t* ptr, void* addr, int type)
|
||||||
|
{
|
||||||
|
unsigned char* address = (unsigned char*)addr;
|
||||||
|
dal_mpool_mem_t* prev = NULL;
|
||||||
|
|
||||||
|
while (ptr && ptr->next)
|
||||||
|
{
|
||||||
|
if (ptr->next->address == address)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ptr && ptr->next)
|
||||||
|
{
|
||||||
|
prev = ptr;
|
||||||
|
ptr = ptr->next;
|
||||||
|
prev->next = ptr->next;
|
||||||
|
DAL_FREE(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dal_mpool_free(dal_mpool_mem_t* pool, void* addr)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* ptr = pool;
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
switch(pool->type)
|
||||||
|
{
|
||||||
|
case DAL_MPOOL_TYPE_USELESS:
|
||||||
|
ptr = pool;
|
||||||
|
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_USELESS);
|
||||||
|
break;
|
||||||
|
case DAL_MPOOL_TYPE_DESC:
|
||||||
|
ptr = p_desc_pool;
|
||||||
|
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_DESC);
|
||||||
|
break;
|
||||||
|
case DAL_MPOOL_TYPE_DATA:
|
||||||
|
ptr = p_data_pool;
|
||||||
|
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_DATA);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
dal_mpool_destroy(dal_mpool_mem_t* pool)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* ptr, * next;
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
for (ptr = pool; ptr; ptr = next)
|
||||||
|
{
|
||||||
|
next = ptr->next;
|
||||||
|
DAL_FREE(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ptr = p_desc_pool; ptr; ptr = next)
|
||||||
|
{
|
||||||
|
next = ptr->next;
|
||||||
|
DAL_FREE(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ptr = p_data_pool; ptr; ptr = next)
|
||||||
|
{
|
||||||
|
next = ptr->next;
|
||||||
|
DAL_FREE(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
dal_mpool_usage(dal_mpool_mem_t* pool, int type)
|
||||||
|
{
|
||||||
|
int usage = 0;
|
||||||
|
dal_mpool_mem_t* ptr;
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
for (ptr = pool; ptr; ptr = ptr->next)
|
||||||
|
{
|
||||||
|
if (ptr->type == type || ptr->type == -1)
|
||||||
|
{
|
||||||
|
usage += ptr->size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
|
||||||
|
return usage;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
dal_mpool_debug(dal_mpool_mem_t* pool)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* ptr;
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
for (ptr = pool; ptr; ptr = ptr->next)
|
||||||
|
{
|
||||||
|
// DAL_PRINT("%2dst mpool block: address=0x%8x, size=0x%x \n", index, (unsigned int)ptr->address, ptr->size);
|
||||||
|
DAL_PRINT("%2dst mpool block: address=%p, size=0x%x \n", index, ptr->address, ptr->size); // note
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
@file dal_mpool.h
|
||||||
|
|
||||||
|
@author Copyright (C) 2011 Centec Networks Inc. All rights reserved.
|
||||||
|
|
||||||
|
@date 2012-5-10
|
||||||
|
|
||||||
|
@version v2.0
|
||||||
|
|
||||||
|
This file contains the dma memory init, allocation and free APIs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _DMA_MPOOL_H
|
||||||
|
#define _DMA_MPOOL_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DAL_MPOOL_MAX_DESX_SIZE (1024*1024)
|
||||||
|
|
||||||
|
enum dal_mpool_type_e
|
||||||
|
{
|
||||||
|
DAL_MPOOL_TYPE_USELESS, /* just compatible with GB */
|
||||||
|
DAL_MPOOL_TYPE_DESC, /* dma mpool op for desc */
|
||||||
|
DAL_MPOOL_TYPE_DATA /* dma mpool op for data */
|
||||||
|
};
|
||||||
|
typedef enum dal_mpool_type_e dal_mpool_type_t;
|
||||||
|
|
||||||
|
struct dal_mpool_mem_s
|
||||||
|
{
|
||||||
|
unsigned char* address;
|
||||||
|
int size;
|
||||||
|
int type;
|
||||||
|
struct dal_mpool_mem_s* next;
|
||||||
|
};
|
||||||
|
typedef struct dal_mpool_mem_s dal_mpool_mem_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief This function is to alloc dma memory
|
||||||
|
|
||||||
|
@param[in] size size of memory
|
||||||
|
|
||||||
|
@return NULL
|
||||||
|
|
||||||
|
*/
|
||||||
|
extern int
|
||||||
|
dal_mpool_init(void);
|
||||||
|
|
||||||
|
extern dal_mpool_mem_t*
|
||||||
|
dal_mpool_create(void* base_ptr, int size);
|
||||||
|
|
||||||
|
extern void*
|
||||||
|
dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type);
|
||||||
|
|
||||||
|
extern void
|
||||||
|
dal_mpool_free(dal_mpool_mem_t* pool, void* addr);
|
||||||
|
|
||||||
|
extern int
|
||||||
|
dal_mpool_destroy(dal_mpool_mem_t* pool);
|
||||||
|
|
||||||
|
extern int
|
||||||
|
dal_mpool_usage(dal_mpool_mem_t* pool, int type);
|
||||||
|
|
||||||
|
extern int
|
||||||
|
dal_mpool_debug(dal_mpool_mem_t* pool);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !_DMA_MPOOL_H */
|
||||||
|
|
@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#platform init script for centec e582-48x2q4z
|
||||||
|
|
||||||
|
init_devnum() {
|
||||||
|
found=0
|
||||||
|
for devnum in 0 1; do
|
||||||
|
devname=`cat /sys/bus/i2c/devices/i2c-${devnum}/name`
|
||||||
|
# I801 adapter can be at either dffd0000 or dfff0000
|
||||||
|
if [[ $devname == 'SMBus I801 adapter at '* ]]; then
|
||||||
|
found=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
[ $found -eq 0 ] && echo "cannot find I801" && exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
init_devnum
|
||||||
|
|
||||||
|
if [ "$1" == "init" ]; then
|
||||||
|
depmod -a
|
||||||
|
modprobe i2c-dev
|
||||||
|
modprobe i2c-mux-pca954x force_deselect_on_exit=1
|
||||||
|
modprobe centec_e582_48x2q4z_platform
|
||||||
|
modprobe dal
|
||||||
|
modprobe centec_at24c64
|
||||||
|
elif [ "$1" == "deinit" ]; then
|
||||||
|
modprobe -r centec_at24c64
|
||||||
|
modprobe -r dal
|
||||||
|
modprobe -r centec_e582_48x2q4z_platform
|
||||||
|
modprobe -r i2c-mux-pca954x
|
||||||
|
modprobe -r i2c-dev
|
||||||
|
else
|
||||||
|
echo "e582-48x2q4z_platform : Invalid option !"
|
||||||
|
fi
|
@ -0,0 +1,14 @@
|
|||||||
|
# /etc/modules: kernel modules to load at boot time.
|
||||||
|
#
|
||||||
|
# This file contains the names of kernel modules that should be loaded
|
||||||
|
# at boot time, one per line. Lines beginning with "#" are ignored.
|
||||||
|
|
||||||
|
i2c-i801
|
||||||
|
i2c-dev
|
||||||
|
i2c-mux
|
||||||
|
i2c-smbus
|
||||||
|
|
||||||
|
i2c-mux-pca954x
|
||||||
|
lm77
|
||||||
|
adt7470
|
||||||
|
tun
|
@ -0,0 +1,303 @@
|
|||||||
|
{
|
||||||
|
"DEVICE_METADATA": {
|
||||||
|
"localhost": {
|
||||||
|
"bgp_asn": 65100,
|
||||||
|
"deployment_id": null,
|
||||||
|
"hostname": "switch1",
|
||||||
|
"type": "LeafRouter",
|
||||||
|
"hwsku": "E582-48x6q"
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"BGP_PEER_RANGE": {},
|
||||||
|
"VLAN": {},
|
||||||
|
"PORT": {
|
||||||
|
"Ethernet1": {
|
||||||
|
"alias": "Ethernet1",
|
||||||
|
"lanes": "4",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet2": {
|
||||||
|
"alias": "Ethernet2",
|
||||||
|
"lanes": "5",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet3": {
|
||||||
|
"alias": "Ethernet3",
|
||||||
|
"lanes": "6",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet4": {
|
||||||
|
"alias": "Ethernet4",
|
||||||
|
"lanes": "8",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet5": {
|
||||||
|
"alias": "Ethernet5",
|
||||||
|
"lanes": "9",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet6": {
|
||||||
|
"alias": "Ethernet6",
|
||||||
|
"lanes": "10",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet7": {
|
||||||
|
"alias": "Ethernet7",
|
||||||
|
"lanes": "12",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet8": {
|
||||||
|
"alias": "Ethernet8",
|
||||||
|
"lanes": "13",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet9": {
|
||||||
|
"alias": "Ethernet9",
|
||||||
|
"lanes": "14",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet10": {
|
||||||
|
"alias": "Ethernet10",
|
||||||
|
"lanes": "16",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet11": {
|
||||||
|
"alias": "Ethernet11",
|
||||||
|
"lanes": "17",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet12": {
|
||||||
|
"alias": "Ethernet12",
|
||||||
|
"lanes": "18",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet13": {
|
||||||
|
"alias": "Ethernet13",
|
||||||
|
"lanes": "20",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet14": {
|
||||||
|
"alias": "Ethernet14",
|
||||||
|
"lanes": "21",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet15": {
|
||||||
|
"alias": "Ethernet15",
|
||||||
|
"lanes": "22",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet16": {
|
||||||
|
"alias": "Ethernet16",
|
||||||
|
"lanes": "24",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet17": {
|
||||||
|
"alias": "Ethernet17",
|
||||||
|
"lanes": "25",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet18": {
|
||||||
|
"alias": "Ethernet18",
|
||||||
|
"lanes": "26",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet19": {
|
||||||
|
"alias": "Ethernet19",
|
||||||
|
"lanes": "28",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet20": {
|
||||||
|
"alias": "Ethernet20",
|
||||||
|
"lanes": "30",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet21": {
|
||||||
|
"alias": "Ethernet21",
|
||||||
|
"lanes": "31",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet22": {
|
||||||
|
"alias": "Ethernet22",
|
||||||
|
"lanes": "32",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet23": {
|
||||||
|
"alias": "Ethernet23",
|
||||||
|
"lanes": "34",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet24": {
|
||||||
|
"alias": "Ethernet24",
|
||||||
|
"lanes": "35",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet25": {
|
||||||
|
"alias": "Ethernet25",
|
||||||
|
"lanes": "40",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet26": {
|
||||||
|
"alias": "Ethernet26",
|
||||||
|
"lanes": "41",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet27": {
|
||||||
|
"alias": "Ethernet27",
|
||||||
|
"lanes": "43",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet28": {
|
||||||
|
"alias": "Ethernet28",
|
||||||
|
"lanes": "36",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet29": {
|
||||||
|
"alias": "Ethernet29",
|
||||||
|
"lanes": "37",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet30": {
|
||||||
|
"alias": "Ethernet30",
|
||||||
|
"lanes": "39",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet31": {
|
||||||
|
"alias": "Ethernet31",
|
||||||
|
"lanes": "44",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet32": {
|
||||||
|
"alias": "Ethernet32",
|
||||||
|
"lanes": "45",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet33": {
|
||||||
|
"alias": "Ethernet33",
|
||||||
|
"lanes": "46",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet34": {
|
||||||
|
"alias": "Ethernet34",
|
||||||
|
"lanes": "47",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet35": {
|
||||||
|
"alias": "Ethernet35",
|
||||||
|
"lanes": "80",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet36": {
|
||||||
|
"alias": "Ethernet36",
|
||||||
|
"lanes": "81",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet37": {
|
||||||
|
"alias": "Ethernet37",
|
||||||
|
"lanes": "82",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet38": {
|
||||||
|
"alias": "Ethernet38",
|
||||||
|
"lanes": "88",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet39": {
|
||||||
|
"alias": "Ethernet39",
|
||||||
|
"lanes": "89",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet40": {
|
||||||
|
"alias": "Ethernet40",
|
||||||
|
"lanes": "90",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet41": {
|
||||||
|
"alias": "Ethernet41",
|
||||||
|
"lanes": "84",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet42": {
|
||||||
|
"alias": "Ethernet42",
|
||||||
|
"lanes": "85",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet43": {
|
||||||
|
"alias": "Ethernet43",
|
||||||
|
"lanes": "86",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet44": {
|
||||||
|
"alias": "Ethernet44",
|
||||||
|
"lanes": "87",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet45": {
|
||||||
|
"alias": "Ethernet45",
|
||||||
|
"lanes": "92",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet46": {
|
||||||
|
"alias": "Ethernet46",
|
||||||
|
"lanes": "93",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet47": {
|
||||||
|
"alias": "Ethernet47",
|
||||||
|
"lanes": "94",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet48": {
|
||||||
|
"alias": "Ethernet48",
|
||||||
|
"lanes": "95",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet49": {
|
||||||
|
"alias": "Ethernet49",
|
||||||
|
"lanes": "52,53,54,55",
|
||||||
|
"speed": "40000"
|
||||||
|
},
|
||||||
|
"Ethernet50": {
|
||||||
|
"alias": "Ethernet50",
|
||||||
|
"lanes": "56,57,58,59",
|
||||||
|
"speed": "40000"
|
||||||
|
},
|
||||||
|
"Ethernet51": {
|
||||||
|
"alias": "Ethernet51",
|
||||||
|
"lanes": "60,61,62,63",
|
||||||
|
"speed": "40000"
|
||||||
|
},
|
||||||
|
"Ethernet52": {
|
||||||
|
"alias": "Ethernet52",
|
||||||
|
"lanes": "68,69,70,71",
|
||||||
|
"speed": "40000"
|
||||||
|
},
|
||||||
|
"Ethernet53": {
|
||||||
|
"alias": "Ethernet53",
|
||||||
|
"lanes": "72,73,74,75",
|
||||||
|
"speed": "40000"
|
||||||
|
},
|
||||||
|
"Ethernet54": {
|
||||||
|
"alias": "Ethernet54",
|
||||||
|
"lanes": "76,77,78,79",
|
||||||
|
"speed": "40000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER": {},
|
||||||
|
"VLAN_INTERFACE": {},
|
||||||
|
"PORTCHANNEL_INTERFACE": {},
|
||||||
|
"PORTCHANNEL": {},
|
||||||
|
"MGMT_INTERFACE": {},
|
||||||
|
"DHCP_SERVER": {},
|
||||||
|
"LOOPBACK_INTERFACE": {
|
||||||
|
"Loopback0|127.0.0.1/8": {}
|
||||||
|
},
|
||||||
|
"ACL_TABLE": {},
|
||||||
|
"INTERFACE": {
|
||||||
|
"Ethernet1|192.168.1.1/24": {},
|
||||||
|
"Ethernet2|192.168.2.1/24": {},
|
||||||
|
"Ethernet3|192.168.3.1/24": {},
|
||||||
|
"Ethernet4|192.168.4.1/24": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,610 @@
|
|||||||
|
{
|
||||||
|
"QUEUE": {
|
||||||
|
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|0-2": {
|
||||||
|
"wred_profile": "[WRED_PROFILE|AZURE_LOSSY]"
|
||||||
|
},
|
||||||
|
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|3-4": {
|
||||||
|
"wred_profile": "[WRED_PROFILE|AZURE_LOSSLESS]",
|
||||||
|
"scheduler": "[SCHEDULER|scheduler.0]"
|
||||||
|
},
|
||||||
|
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|5-7": {
|
||||||
|
"wred_profile": "[WRED_PROFILE|AZURE_LOSSY]"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"WRED_PROFILE": {
|
||||||
|
"AZURE_LOSSLESS": {
|
||||||
|
"red_max_threshold": "32760",
|
||||||
|
"yellow_max_threshold": "32760",
|
||||||
|
"green_min_threshold": "4095",
|
||||||
|
"red_min_threshold": "4095",
|
||||||
|
"yellow_min_threshold": "4095",
|
||||||
|
"green_max_threshold": "32760",
|
||||||
|
"wred_yellow_enable": "true",
|
||||||
|
"wred_green_enable": "true"
|
||||||
|
},
|
||||||
|
"AZURE_LOSSY": {
|
||||||
|
"red_max_threshold": "32760",
|
||||||
|
"yellow_max_threshold": "32760",
|
||||||
|
"green_min_threshold": "4095",
|
||||||
|
"red_min_threshold": "4095",
|
||||||
|
"yellow_min_threshold": "4095",
|
||||||
|
"green_max_threshold": "32760",
|
||||||
|
"wred_yellow_enable": "true",
|
||||||
|
"wred_green_enable": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"DSCP_TO_TC_MAP": {
|
||||||
|
"AZURE": {
|
||||||
|
"56": "7",
|
||||||
|
"54": "6",
|
||||||
|
"28": "3",
|
||||||
|
"48": "6",
|
||||||
|
"29": "3",
|
||||||
|
"60": "7",
|
||||||
|
"61": "7",
|
||||||
|
"62": "7",
|
||||||
|
"63": "7",
|
||||||
|
"49": "6",
|
||||||
|
"34": "4",
|
||||||
|
"24": "3",
|
||||||
|
"25": "3",
|
||||||
|
"26": "3",
|
||||||
|
"27": "3",
|
||||||
|
"20": "2",
|
||||||
|
"21": "2",
|
||||||
|
"22": "2",
|
||||||
|
"23": "2",
|
||||||
|
"46": "5",
|
||||||
|
"47": "5",
|
||||||
|
"44": "5",
|
||||||
|
"45": "5",
|
||||||
|
"42": "5",
|
||||||
|
"43": "5",
|
||||||
|
"40": "5",
|
||||||
|
"41": "5",
|
||||||
|
"1": "0",
|
||||||
|
"0": "0",
|
||||||
|
"3": "0",
|
||||||
|
"2": "0",
|
||||||
|
"5": "0",
|
||||||
|
"4": "0",
|
||||||
|
"7": "0",
|
||||||
|
"6": "0",
|
||||||
|
"9": "1",
|
||||||
|
"8": "1",
|
||||||
|
"35": "4",
|
||||||
|
"13": "1",
|
||||||
|
"12": "1",
|
||||||
|
"15": "1",
|
||||||
|
"58": "7",
|
||||||
|
"11": "1",
|
||||||
|
"10": "1",
|
||||||
|
"39": "4",
|
||||||
|
"38": "4",
|
||||||
|
"59": "7",
|
||||||
|
"14": "1",
|
||||||
|
"17": "2",
|
||||||
|
"16": "2",
|
||||||
|
"19": "2",
|
||||||
|
"18": "2",
|
||||||
|
"31": "3",
|
||||||
|
"30": "3",
|
||||||
|
"51": "6",
|
||||||
|
"36": "4",
|
||||||
|
"53": "6",
|
||||||
|
"52": "6",
|
||||||
|
"33": "4",
|
||||||
|
"55": "6",
|
||||||
|
"37": "4",
|
||||||
|
"32": "4",
|
||||||
|
"57": "7",
|
||||||
|
"50": "6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"DEVICE_METADATA": {
|
||||||
|
"localhost": {
|
||||||
|
"hwsku": "E582-48x6q",
|
||||||
|
"hostname": "switch1",
|
||||||
|
"bgp_asn": "None",
|
||||||
|
"deployment_id": "None",
|
||||||
|
"type": "LeafRouter"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"PORT": {
|
||||||
|
"Ethernet1": {
|
||||||
|
"alias": "Ethernet1",
|
||||||
|
"lanes": "4",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet2": {
|
||||||
|
"alias": "Ethernet2",
|
||||||
|
"lanes": "5",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet3": {
|
||||||
|
"alias": "Ethernet3",
|
||||||
|
"lanes": "6",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet4": {
|
||||||
|
"alias": "Ethernet4",
|
||||||
|
"lanes": "8",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet5": {
|
||||||
|
"alias": "Ethernet5",
|
||||||
|
"lanes": "9",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet6": {
|
||||||
|
"alias": "Ethernet6",
|
||||||
|
"lanes": "10",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet7": {
|
||||||
|
"alias": "Ethernet7",
|
||||||
|
"lanes": "12",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet8": {
|
||||||
|
"alias": "Ethernet8",
|
||||||
|
"lanes": "13",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet9": {
|
||||||
|
"alias": "Ethernet9",
|
||||||
|
"lanes": "14",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet10": {
|
||||||
|
"alias": "Ethernet10",
|
||||||
|
"lanes": "16",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet11": {
|
||||||
|
"alias": "Ethernet11",
|
||||||
|
"lanes": "17",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet12": {
|
||||||
|
"alias": "Ethernet12",
|
||||||
|
"lanes": "18",
|
||||||
|
"speed": "1000"
|
||||||
|
},
|
||||||
|
"Ethernet13": {
|
||||||
|
"alias": "Ethernet13",
|
||||||
|
"lanes": "20",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet14": {
|
||||||
|
"alias": "Ethernet14",
|
||||||
|
"lanes": "21",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet15": {
|
||||||
|
"alias": "Ethernet15",
|
||||||
|
"lanes": "22",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet16": {
|
||||||
|
"alias": "Ethernet16",
|
||||||
|
"lanes": "24",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet17": {
|
||||||
|
"alias": "Ethernet17",
|
||||||
|
"lanes": "25",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet18": {
|
||||||
|
"alias": "Ethernet18",
|
||||||
|
"lanes": "26",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet19": {
|
||||||
|
"alias": "Ethernet19",
|
||||||
|
"lanes": "28",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet20": {
|
||||||
|
"alias": "Ethernet20",
|
||||||
|
"lanes": "30",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet21": {
|
||||||
|
"alias": "Ethernet21",
|
||||||
|
"lanes": "31",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet22": {
|
||||||
|
"alias": "Ethernet22",
|
||||||
|
"lanes": "32",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet23": {
|
||||||
|
"alias": "Ethernet23",
|
||||||
|
"lanes": "34",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet24": {
|
||||||
|
"alias": "Ethernet24",
|
||||||
|
"lanes": "35",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet25": {
|
||||||
|
"alias": "Ethernet25",
|
||||||
|
"lanes": "40",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet26": {
|
||||||
|
"alias": "Ethernet26",
|
||||||
|
"lanes": "41",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet27": {
|
||||||
|
"alias": "Ethernet27",
|
||||||
|
"lanes": "43",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet28": {
|
||||||
|
"alias": "Ethernet28",
|
||||||
|
"lanes": "36",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet29": {
|
||||||
|
"alias": "Ethernet29",
|
||||||
|
"lanes": "37",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet30": {
|
||||||
|
"alias": "Ethernet30",
|
||||||
|
"lanes": "39",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet31": {
|
||||||
|
"alias": "Ethernet31",
|
||||||
|
"lanes": "44",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet32": {
|
||||||
|
"alias": "Ethernet32",
|
||||||
|
"lanes": "45",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet33": {
|
||||||
|
"alias": "Ethernet33",
|
||||||
|
"lanes": "46",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet34": {
|
||||||
|
"alias": "Ethernet34",
|
||||||
|
"lanes": "47",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet35": {
|
||||||
|
"alias": "Ethernet35",
|
||||||
|
"lanes": "80",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet36": {
|
||||||
|
"alias": "Ethernet36",
|
||||||
|
"lanes": "81",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet37": {
|
||||||
|
"alias": "Ethernet37",
|
||||||
|
"lanes": "82",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet38": {
|
||||||
|
"alias": "Ethernet38",
|
||||||
|
"lanes": "88",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet39": {
|
||||||
|
"alias": "Ethernet39",
|
||||||
|
"lanes": "89",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet40": {
|
||||||
|
"alias": "Ethernet40",
|
||||||
|
"lanes": "90",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet41": {
|
||||||
|
"alias": "Ethernet41",
|
||||||
|
"lanes": "84",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet42": {
|
||||||
|
"alias": "Ethernet42",
|
||||||
|
"lanes": "85",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet43": {
|
||||||
|
"alias": "Ethernet43",
|
||||||
|
"lanes": "86",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet44": {
|
||||||
|
"alias": "Ethernet44",
|
||||||
|
"lanes": "87",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet45": {
|
||||||
|
"alias": "Ethernet45",
|
||||||
|
"lanes": "92",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet46": {
|
||||||
|
"alias": "Ethernet46",
|
||||||
|
"lanes": "93",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet47": {
|
||||||
|
"alias": "Ethernet47",
|
||||||
|
"lanes": "94",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet48": {
|
||||||
|
"alias": "Ethernet48",
|
||||||
|
"lanes": "95",
|
||||||
|
"speed": "10000"
|
||||||
|
},
|
||||||
|
"Ethernet49": {
|
||||||
|
"alias": "Ethernet49",
|
||||||
|
"lanes": "52,53,54,55",
|
||||||
|
"speed": "40000"
|
||||||
|
},
|
||||||
|
"Ethernet50": {
|
||||||
|
"alias": "Ethernet50",
|
||||||
|
"lanes": "56,57,58,59",
|
||||||
|
"speed": "40000"
|
||||||
|
},
|
||||||
|
"Ethernet51": {
|
||||||
|
"alias": "Ethernet51",
|
||||||
|
"lanes": "60,61,62,63",
|
||||||
|
"speed": "40000"
|
||||||
|
},
|
||||||
|
"Ethernet52": {
|
||||||
|
"alias": "Ethernet52",
|
||||||
|
"lanes": "68,69,70,71",
|
||||||
|
"speed": "40000"
|
||||||
|
},
|
||||||
|
"Ethernet53": {
|
||||||
|
"alias": "Ethernet53",
|
||||||
|
"lanes": "72,73,74,75",
|
||||||
|
"speed": "40000"
|
||||||
|
},
|
||||||
|
"Ethernet54": {
|
||||||
|
"alias": "Ethernet54",
|
||||||
|
"lanes": "76,77,78,79",
|
||||||
|
"speed": "40000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"PORT_QOS_MAP": {
|
||||||
|
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54": {
|
||||||
|
"pfc_enable": "3,4",
|
||||||
|
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SCHEDULER": {
|
||||||
|
"scheduler.0": {
|
||||||
|
"type": "DWRR",
|
||||||
|
"weight": "25"
|
||||||
|
},
|
||||||
|
"scheduler.1": {
|
||||||
|
"type": "DWRR",
|
||||||
|
"weight": "30"
|
||||||
|
},
|
||||||
|
"scheduler.2": {
|
||||||
|
"type": "DWRR",
|
||||||
|
"weight": "20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"VLAN": {
|
||||||
|
"Vlan500": {
|
||||||
|
"dhcp_servers": [
|
||||||
|
"192.168.5.1",
|
||||||
|
"192.168.5.2",
|
||||||
|
"192.168.5.3",
|
||||||
|
"192.168.5.4"
|
||||||
|
],
|
||||||
|
"members": [
|
||||||
|
"Ethernet5",
|
||||||
|
"Ethernet6",
|
||||||
|
"Ethernet7",
|
||||||
|
"Ethernet8"
|
||||||
|
],
|
||||||
|
"vlanid": "500"
|
||||||
|
},
|
||||||
|
"Vlan600": {
|
||||||
|
"dhcp_servers": [
|
||||||
|
"192.168.6.1",
|
||||||
|
"192.168.6.2",
|
||||||
|
"192.168.6.3",
|
||||||
|
"192.168.6.4"
|
||||||
|
],
|
||||||
|
"members": [
|
||||||
|
"Ethernet5",
|
||||||
|
"Ethernet6"
|
||||||
|
],
|
||||||
|
"vlanid": "600"
|
||||||
|
},
|
||||||
|
"Vlan700": {
|
||||||
|
"dhcp_servers": [
|
||||||
|
"192.168.7.1",
|
||||||
|
"192.168.7.2",
|
||||||
|
"192.168.7.3",
|
||||||
|
"192.168.7.4"
|
||||||
|
],
|
||||||
|
"members": [
|
||||||
|
"Ethernet5",
|
||||||
|
"Ethernet7"
|
||||||
|
],
|
||||||
|
"vlanid": "700"
|
||||||
|
},
|
||||||
|
"Vlan800": {
|
||||||
|
"dhcp_servers": [
|
||||||
|
"192.168.8.1",
|
||||||
|
"192.168.8.2",
|
||||||
|
"192.168.8.3",
|
||||||
|
"192.168.8.4"
|
||||||
|
],
|
||||||
|
"members": [
|
||||||
|
"Ethernet5",
|
||||||
|
"Ethernet8"
|
||||||
|
],
|
||||||
|
"vlanid": "800"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"VLAN_MEMBER": {
|
||||||
|
"Vlan500|Ethernet5": {
|
||||||
|
"tagging_mode": "tagged"
|
||||||
|
},
|
||||||
|
"Vlan500|Ethernet6": {
|
||||||
|
"tagging_mode": "untagged"
|
||||||
|
},
|
||||||
|
"Vlan500|Ethernet7": {
|
||||||
|
"tagging_mode": "untagged"
|
||||||
|
},
|
||||||
|
"Vlan500|Ethernet8": {
|
||||||
|
"tagging_mode": "untagged"
|
||||||
|
},
|
||||||
|
"Vlan600|Ethernet5": {
|
||||||
|
"tagging_mode": "tagged"
|
||||||
|
},
|
||||||
|
"Vlan600|Ethernet6": {
|
||||||
|
"tagging_mode": "tagged"
|
||||||
|
},
|
||||||
|
"Vlan700|Ethernet5": {
|
||||||
|
"tagging_mode": "tagged"
|
||||||
|
},
|
||||||
|
"Vlan700|Ethernet7": {
|
||||||
|
"tagging_mode": "tagged"
|
||||||
|
},
|
||||||
|
"Vlan800|Ethernet5": {
|
||||||
|
"tagging_mode": "tagged"
|
||||||
|
},
|
||||||
|
"Vlan800|Ethernet8": {
|
||||||
|
"tagging_mode": "tagged"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"INTERFACE": {
|
||||||
|
"Ethernet1|192.168.1.1/24": {},
|
||||||
|
"Ethernet2|192.168.2.1/24": {},
|
||||||
|
"Ethernet3|192.168.3.1/24": {},
|
||||||
|
"Ethernet4|192.168.4.1/24": {}
|
||||||
|
},
|
||||||
|
"VLAN_INTERFACE": {
|
||||||
|
"Vlan500|192.168.5.1/24": {},
|
||||||
|
"Vlan600|192.168.6.1/24": {},
|
||||||
|
"Vlan700|192.168.7.1/24": {},
|
||||||
|
"Vlan800|192.168.8.1/24": {}
|
||||||
|
},
|
||||||
|
"LOOPBACK_INTERFACE": {
|
||||||
|
"Loopback0|127.0.0.1/8": {}
|
||||||
|
},
|
||||||
|
"CABLE_LENGTH": {
|
||||||
|
"AZURE": {
|
||||||
|
"Ethernet8": "40m",
|
||||||
|
"Ethernet9": "40m",
|
||||||
|
"Ethernet2": "40m",
|
||||||
|
"Ethernet3": "40m",
|
||||||
|
"Ethernet1": "40m",
|
||||||
|
"Ethernet6": "40m",
|
||||||
|
"Ethernet7": "40m",
|
||||||
|
"Ethernet4": "40m",
|
||||||
|
"Ethernet5": "40m",
|
||||||
|
"Ethernet22": "40m",
|
||||||
|
"Ethernet50": "40m",
|
||||||
|
"Ethernet51": "40m",
|
||||||
|
"Ethernet52": "40m",
|
||||||
|
"Ethernet53": "40m",
|
||||||
|
"Ethernet54": "40m",
|
||||||
|
"Ethernet38": "40m",
|
||||||
|
"Ethernet39": "40m",
|
||||||
|
"Ethernet18": "40m",
|
||||||
|
"Ethernet19": "40m",
|
||||||
|
"Ethernet14": "40m",
|
||||||
|
"Ethernet15": "40m",
|
||||||
|
"Ethernet16": "40m",
|
||||||
|
"Ethernet17": "40m",
|
||||||
|
"Ethernet10": "40m",
|
||||||
|
"Ethernet11": "40m",
|
||||||
|
"Ethernet12": "40m",
|
||||||
|
"Ethernet35": "40m",
|
||||||
|
"Ethernet37": "40m",
|
||||||
|
"Ethernet32": "40m",
|
||||||
|
"Ethernet33": "40m",
|
||||||
|
"Ethernet30": "40m",
|
||||||
|
"Ethernet31": "40m",
|
||||||
|
"Ethernet49": "40m",
|
||||||
|
"Ethernet48": "40m",
|
||||||
|
"Ethernet47": "40m",
|
||||||
|
"Ethernet36": "40m",
|
||||||
|
"Ethernet45": "40m",
|
||||||
|
"Ethernet44": "40m",
|
||||||
|
"Ethernet43": "40m",
|
||||||
|
"Ethernet42": "40m",
|
||||||
|
"Ethernet41": "40m",
|
||||||
|
"Ethernet40": "40m",
|
||||||
|
"Ethernet29": "40m",
|
||||||
|
"Ethernet28": "40m",
|
||||||
|
"Ethernet34": "40m",
|
||||||
|
"Ethernet46": "40m",
|
||||||
|
"Ethernet21": "40m",
|
||||||
|
"Ethernet20": "40m",
|
||||||
|
"Ethernet23": "40m",
|
||||||
|
"Ethernet13": "40m",
|
||||||
|
"Ethernet25": "40m",
|
||||||
|
"Ethernet24": "40m",
|
||||||
|
"Ethernet27": "40m",
|
||||||
|
"Ethernet26": "40m"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"CRM": {
|
||||||
|
"Config": {
|
||||||
|
"acl_table_threshold_type": "percentage",
|
||||||
|
"nexthop_group_threshold_type": "percentage",
|
||||||
|
"fdb_entry_high_threshold": "85",
|
||||||
|
"acl_entry_threshold_type": "percentage",
|
||||||
|
"ipv6_neighbor_low_threshold": "70",
|
||||||
|
"nexthop_group_member_low_threshold": "70",
|
||||||
|
"acl_group_high_threshold": "85",
|
||||||
|
"ipv4_route_high_threshold": "85",
|
||||||
|
"acl_counter_high_threshold": "85",
|
||||||
|
"ipv4_route_low_threshold": "70",
|
||||||
|
"ipv4_route_threshold_type": "percentage",
|
||||||
|
"ipv4_neighbor_low_threshold": "70",
|
||||||
|
"acl_group_threshold_type": "percentage",
|
||||||
|
"ipv4_nexthop_high_threshold": "85",
|
||||||
|
"ipv6_route_threshold_type": "percentage",
|
||||||
|
"nexthop_group_low_threshold": "70",
|
||||||
|
"ipv4_neighbor_high_threshold": "85",
|
||||||
|
"ipv6_route_high_threshold": "85",
|
||||||
|
"ipv6_nexthop_threshold_type": "percentage",
|
||||||
|
"polling_interval": "300",
|
||||||
|
"ipv4_nexthop_threshold_type": "percentage",
|
||||||
|
"acl_group_low_threshold": "70",
|
||||||
|
"acl_entry_low_threshold": "70",
|
||||||
|
"nexthop_group_member_threshold_type": "percentage",
|
||||||
|
"ipv4_nexthop_low_threshold": "70",
|
||||||
|
"acl_counter_threshold_type": "percentage",
|
||||||
|
"ipv6_neighbor_high_threshold": "85",
|
||||||
|
"nexthop_group_member_high_threshold": "85",
|
||||||
|
"acl_table_low_threshold": "70",
|
||||||
|
"fdb_entry_threshold_type": "percentage",
|
||||||
|
"ipv6_neighbor_threshold_type": "percentage",
|
||||||
|
"acl_table_high_threshold": "85",
|
||||||
|
"ipv6_nexthop_low_threshold": "70",
|
||||||
|
"acl_counter_low_threshold": "70",
|
||||||
|
"ipv4_neighbor_threshold_type": "percentage",
|
||||||
|
"nexthop_group_high_threshold": "85",
|
||||||
|
"ipv6_route_low_threshold": "70",
|
||||||
|
"acl_entry_high_threshold": "85",
|
||||||
|
"fdb_entry_low_threshold": "70",
|
||||||
|
"ipv6_nexthop_high_threshold": "85"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
<DeviceMiniGraph xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="Microsoft.Search.Autopilot.Evolution">
|
||||||
|
<CpgDec>
|
||||||
|
<IsisRouters xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||||
|
<PeeringSessions/>
|
||||||
|
<Routers xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||||
|
</CpgDec>
|
||||||
|
<DpgDec>
|
||||||
|
<DeviceDataPlaneInfo>
|
||||||
|
<IPSecTunnels/>
|
||||||
|
<LoopbackIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||||
|
</LoopbackIPInterfaces>
|
||||||
|
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||||
|
</ManagementIPInterfaces>
|
||||||
|
<MplsInterfaces/>
|
||||||
|
<MplsTeInterfaces/>
|
||||||
|
<RsvpInterfaces/>
|
||||||
|
<Hostname>switch1</Hostname>
|
||||||
|
<PortChannelInterfaces/>
|
||||||
|
<VlanInterfaces/>
|
||||||
|
<IPInterfaces/>
|
||||||
|
<DataAcls/>
|
||||||
|
<AclInterfaces/>
|
||||||
|
<DownstreamSummaries/>
|
||||||
|
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||||
|
</DeviceDataPlaneInfo>
|
||||||
|
</DpgDec>
|
||||||
|
<PngDec>
|
||||||
|
<Devices>
|
||||||
|
<Device i:type="LeafRouter">
|
||||||
|
<Hostname>switch1</Hostname>
|
||||||
|
<HwSku>E582-48x6q</HwSku>
|
||||||
|
</Device>
|
||||||
|
</Devices>
|
||||||
|
</PngDec>
|
||||||
|
<Hostname>switch1</Hostname>
|
||||||
|
<HwSku>E582-48x6q</HwSku>
|
||||||
|
</DeviceMiniGraph>
|
||||||
|
|
@ -0,0 +1,2 @@
|
|||||||
|
obj-m := centec_e582_48x6q_platform.o dal.o centec_at24c64.o
|
||||||
|
dal-y := dal_kernel.o dal_mpool.o
|
@ -0,0 +1,658 @@
|
|||||||
|
/*
|
||||||
|
* at24.c - handle most I2C EEPROMs
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005-2007 David Brownell
|
||||||
|
* Copyright (C) 2008 Wolfram Sang, Pengutronix
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/init.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/sysfs.h>
|
||||||
|
#include <linux/mod_devicetable.h>
|
||||||
|
#include <linux/log2.h>
|
||||||
|
#include <linux/bitops.h>
|
||||||
|
#include <linux/jiffies.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/i2c.h>
|
||||||
|
#include <linux/platform_data/at24.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.
|
||||||
|
* Differences between different vendor product lines (like Atmel AT24C or
|
||||||
|
* MicroChip 24LC, etc) won't much matter for typical read/write access.
|
||||||
|
* There are also I2C RAM chips, likewise interchangeable. One example
|
||||||
|
* would be the PCF8570, which acts like a 24c02 EEPROM (256 bytes).
|
||||||
|
*
|
||||||
|
* However, misconfiguration can lose data. "Set 16-bit memory address"
|
||||||
|
* to a part with 8-bit addressing will overwrite data. Writing with too
|
||||||
|
* big a page size also loses data. And it's not safe to assume that the
|
||||||
|
* conventional addresses 0x50..0x57 only hold eeproms; a PCF8563 RTC
|
||||||
|
* uses 0x51, for just one example.
|
||||||
|
*
|
||||||
|
* Accordingly, explicit board-specific configuration data should be used
|
||||||
|
* in almost all cases. (One partial exception is an SMBus used to access
|
||||||
|
* "SPD" data for DRAM sticks. Those only use 24c02 EEPROMs.)
|
||||||
|
*
|
||||||
|
* So this driver uses "new style" I2C driver binding, expecting to be
|
||||||
|
* told what devices exist. That may be in arch/X/mach-Y/board-Z.c or
|
||||||
|
* similar kernel-resident tables; or, configuration data coming from
|
||||||
|
* a bootloader.
|
||||||
|
*
|
||||||
|
* Other than binding model, current differences from "eeprom" driver are
|
||||||
|
* that this one handles write access and isn't restricted to 24c02 devices.
|
||||||
|
* It also handles larger devices (32 kbit and up) with two-byte addresses,
|
||||||
|
* which won't work on pure SMBus systems.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct at24_data {
|
||||||
|
struct at24_platform_data chip;
|
||||||
|
struct memory_accessor macc;
|
||||||
|
int use_smbus;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lock protects against activities from other Linux tasks,
|
||||||
|
* but not from changes by other I2C masters.
|
||||||
|
*/
|
||||||
|
struct mutex lock;
|
||||||
|
struct bin_attribute bin;
|
||||||
|
|
||||||
|
u8 *writebuf;
|
||||||
|
unsigned write_max;
|
||||||
|
unsigned num_addresses;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some chips tie up multiple I2C addresses; dummy devices reserve
|
||||||
|
* them for us, and we'll use them with SMBus calls.
|
||||||
|
*/
|
||||||
|
struct i2c_client *client[];
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This parameter is to help this driver avoid blocking other drivers out
|
||||||
|
* of I2C for potentially troublesome amounts of time. With a 100 kHz I2C
|
||||||
|
* clock, one 256 byte read takes about 1/43 second which is excessive;
|
||||||
|
* but the 1/170 second it takes at 400 kHz may be quite reasonable; and
|
||||||
|
* at 1 MHz (Fm+) a 1/430 second delay could easily be invisible.
|
||||||
|
*
|
||||||
|
* This value is forced to be a power of two so that writes align on pages.
|
||||||
|
*/
|
||||||
|
static unsigned io_limit = 128;
|
||||||
|
module_param(io_limit, uint, 0);
|
||||||
|
MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specs often allow 5 msec for a page write, sometimes 20 msec;
|
||||||
|
* it's important to recover from write timeouts.
|
||||||
|
*/
|
||||||
|
static unsigned write_timeout = 25;
|
||||||
|
module_param(write_timeout, uint, 0);
|
||||||
|
MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)");
|
||||||
|
|
||||||
|
#define AT24_SIZE_BYTELEN 5
|
||||||
|
#define AT24_SIZE_FLAGS 8
|
||||||
|
|
||||||
|
#define AT24_BITMASK(x) (BIT(x) - 1)
|
||||||
|
|
||||||
|
/* create non-zero magic value for given eeprom parameters */
|
||||||
|
#define AT24_DEVICE_MAGIC(_len, _flags) \
|
||||||
|
((1 << AT24_SIZE_FLAGS | (_flags)) \
|
||||||
|
<< AT24_SIZE_BYTELEN | ilog2(_len))
|
||||||
|
|
||||||
|
static const struct i2c_device_id at24_ctc_ids[] = {
|
||||||
|
{ "24c64-ctc", AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16 | AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
|
||||||
|
{ /* END OF LIST */ }
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(i2c, at24_ctc_ids);
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This routine supports chips which consume multiple I2C addresses. It
|
||||||
|
* computes the addressing information to be used for a given r/w request.
|
||||||
|
* Assumes that sanity checks for offset happened at sysfs-layer.
|
||||||
|
*/
|
||||||
|
static struct i2c_client *at24_translate_offset(struct at24_data *at24,
|
||||||
|
unsigned *offset)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
if (at24->chip.flags & AT24_FLAG_ADDR16) {
|
||||||
|
i = *offset >> 16;
|
||||||
|
*offset &= 0xffff;
|
||||||
|
} else {
|
||||||
|
i = *offset >> 8;
|
||||||
|
*offset &= 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
return at24->client[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
|
||||||
|
unsigned offset, size_t count)
|
||||||
|
{
|
||||||
|
struct i2c_msg msg[2];
|
||||||
|
struct i2c_client *client;
|
||||||
|
unsigned long timeout, read_time;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
memset(msg, 0, sizeof(msg));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* REVISIT some multi-address chips don't rollover page reads to
|
||||||
|
* the next slave address, so we may need to truncate the count.
|
||||||
|
* Those chips might need another quirk flag.
|
||||||
|
*
|
||||||
|
* If the real hardware used four adjacent 24c02 chips and that
|
||||||
|
* were misconfigured as one 24c08, that would be a similar effect:
|
||||||
|
* one "eeprom" file not four, but larger reads would fail when
|
||||||
|
* they crossed certain pages.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Slave address and byte offset derive from the offset. Always
|
||||||
|
* set the byte address; on a multi-master board, another master
|
||||||
|
* may have changed the chip's "current" address pointer.
|
||||||
|
*/
|
||||||
|
client = at24_translate_offset(at24, &offset);
|
||||||
|
|
||||||
|
if (count > io_limit)
|
||||||
|
count = io_limit;
|
||||||
|
|
||||||
|
count = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reads fail if the previous write didn't complete yet. We may
|
||||||
|
* loop a few times until this one succeeds, waiting at least
|
||||||
|
* long enough for one entire page write to work.
|
||||||
|
*/
|
||||||
|
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||||
|
do {
|
||||||
|
read_time = jiffies;
|
||||||
|
|
||||||
|
status = i2c_smbus_write_byte_data(client, (offset >> 8) & 0x0ff, offset & 0x0ff );
|
||||||
|
status = i2c_smbus_read_byte(client);
|
||||||
|
if (status >= 0) {
|
||||||
|
buf[0] = status;
|
||||||
|
status = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n",
|
||||||
|
count, offset, status, jiffies);
|
||||||
|
|
||||||
|
if (status == count)
|
||||||
|
return count;
|
||||||
|
|
||||||
|
/* REVISIT: at HZ=100, this is sloooow */
|
||||||
|
msleep(1);
|
||||||
|
} while (time_before(read_time, timeout));
|
||||||
|
|
||||||
|
return -ETIMEDOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_read(struct at24_data *at24,
|
||||||
|
char *buf, loff_t off, size_t count)
|
||||||
|
{
|
||||||
|
ssize_t retval = 0;
|
||||||
|
|
||||||
|
if (unlikely(!count))
|
||||||
|
return count;
|
||||||
|
|
||||||
|
memset(buf, 0, count);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read data from chip, protecting against concurrent updates
|
||||||
|
* from this host, but not from other I2C masters.
|
||||||
|
*/
|
||||||
|
mutex_lock(&at24->lock);
|
||||||
|
|
||||||
|
while (count) {
|
||||||
|
ssize_t status;
|
||||||
|
|
||||||
|
status = at24_eeprom_read(at24, buf, off, count);
|
||||||
|
if (status <= 0) {
|
||||||
|
if (retval == 0)
|
||||||
|
retval = status;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buf += status;
|
||||||
|
off += status;
|
||||||
|
count -= status;
|
||||||
|
retval += status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//printk(KERN_ALERT "at24_read buf = %s, retval = %zu\n", buf, retval);
|
||||||
|
|
||||||
|
mutex_unlock(&at24->lock);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_bin_read(struct file *filp, struct kobject *kobj,
|
||||||
|
struct bin_attribute *attr,
|
||||||
|
char *buf, loff_t off, size_t count)
|
||||||
|
{
|
||||||
|
struct at24_data *at24;
|
||||||
|
|
||||||
|
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||||
|
return at24_read(at24, buf, off, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note that if the hardware write-protect pin is pulled high, the whole
|
||||||
|
* chip is normally write protected. But there are plenty of product
|
||||||
|
* variants here, including OTP fuses and partial chip protect.
|
||||||
|
*
|
||||||
|
* We only use page mode writes; the alternative is sloooow. This routine
|
||||||
|
* writes at most one page.
|
||||||
|
*/
|
||||||
|
static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
|
||||||
|
unsigned offset, size_t count)
|
||||||
|
{
|
||||||
|
struct i2c_client *client;
|
||||||
|
ssize_t status;
|
||||||
|
unsigned long timeout, write_time;
|
||||||
|
unsigned next_page;
|
||||||
|
|
||||||
|
/* Get corresponding I2C address and adjust offset */
|
||||||
|
client = at24_translate_offset(at24, &offset);
|
||||||
|
|
||||||
|
/* write_max is at most a page */
|
||||||
|
if (count > at24->write_max)
|
||||||
|
count = at24->write_max;
|
||||||
|
|
||||||
|
/* Never roll over backwards, to the start of this page */
|
||||||
|
next_page = roundup(offset + 1, at24->chip.page_size);
|
||||||
|
if (offset + count > next_page)
|
||||||
|
count = next_page - offset;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Writes fail if the previous one didn't complete yet. We may
|
||||||
|
* loop a few times until this one succeeds, waiting at least
|
||||||
|
* long enough for one entire page write to work.
|
||||||
|
*/
|
||||||
|
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||||
|
do {
|
||||||
|
write_time = jiffies;
|
||||||
|
|
||||||
|
status = i2c_smbus_write_word_data(client,
|
||||||
|
(offset >> 8) & 0x0ff, (offset & 0xFF) | buf[0]);
|
||||||
|
if (status == 0)
|
||||||
|
status = count;
|
||||||
|
|
||||||
|
dev_dbg(&client->dev, "write %zu@%d --> %zd (%ld)\n",
|
||||||
|
count, offset, status, jiffies);
|
||||||
|
|
||||||
|
if (status == count)
|
||||||
|
return count;
|
||||||
|
|
||||||
|
/* REVISIT: at HZ=100, this is sloooow */
|
||||||
|
msleep(1);
|
||||||
|
} while (time_before(write_time, timeout));
|
||||||
|
|
||||||
|
return -ETIMEDOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off,
|
||||||
|
size_t count)
|
||||||
|
{
|
||||||
|
ssize_t retval = 0;
|
||||||
|
|
||||||
|
if (unlikely(!count))
|
||||||
|
return count;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Write data to chip, protecting against concurrent updates
|
||||||
|
* from this host, but not from other I2C masters.
|
||||||
|
*/
|
||||||
|
mutex_lock(&at24->lock);
|
||||||
|
|
||||||
|
while (count) {
|
||||||
|
ssize_t status;
|
||||||
|
|
||||||
|
status = at24_eeprom_write(at24, buf, off, 1); /* only one-byte to write; TODO page wirte */
|
||||||
|
if (status <= 0) {
|
||||||
|
if (retval == 0)
|
||||||
|
retval = status;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buf += status;
|
||||||
|
off += status;
|
||||||
|
count -= status;
|
||||||
|
retval += status;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutex_unlock(&at24->lock);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_bin_write(struct file *filp, struct kobject *kobj,
|
||||||
|
struct bin_attribute *attr,
|
||||||
|
char *buf, loff_t off, size_t count)
|
||||||
|
{
|
||||||
|
struct at24_data *at24;
|
||||||
|
|
||||||
|
if (unlikely(off >= attr->size))
|
||||||
|
return -EFBIG;
|
||||||
|
|
||||||
|
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||||
|
return at24_write(at24, buf, off, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This lets other kernel code access the eeprom data. For example, it
|
||||||
|
* might hold a board's Ethernet address, or board-specific calibration
|
||||||
|
* data generated on the manufacturing floor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static ssize_t at24_macc_read(struct memory_accessor *macc, char *buf,
|
||||||
|
off_t offset, size_t count)
|
||||||
|
{
|
||||||
|
struct at24_data *at24 = container_of(macc, struct at24_data, macc);
|
||||||
|
|
||||||
|
return at24_read(at24, buf, offset, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf,
|
||||||
|
off_t offset, size_t count)
|
||||||
|
{
|
||||||
|
struct at24_data *at24 = container_of(macc, struct at24_data, macc);
|
||||||
|
|
||||||
|
return at24_write(at24, buf, offset, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_OF
|
||||||
|
static void at24_get_ofdata(struct i2c_client *client,
|
||||||
|
struct at24_platform_data *chip)
|
||||||
|
{
|
||||||
|
const __be32 *val;
|
||||||
|
struct device_node *node = client->dev.of_node;
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
if (of_get_property(node, "read-only", NULL))
|
||||||
|
chip->flags |= AT24_FLAG_READONLY;
|
||||||
|
val = of_get_property(node, "pagesize", NULL);
|
||||||
|
if (val)
|
||||||
|
chip->page_size = be32_to_cpup(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void at24_get_ofdata(struct i2c_client *client,
|
||||||
|
struct at24_platform_data *chip)
|
||||||
|
{ }
|
||||||
|
#endif /* CONFIG_OF */
|
||||||
|
|
||||||
|
static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||||
|
{
|
||||||
|
struct at24_platform_data chip;
|
||||||
|
bool writable;
|
||||||
|
int use_smbus = 0;
|
||||||
|
struct at24_data *at24;
|
||||||
|
int err;
|
||||||
|
unsigned i, num_addresses;
|
||||||
|
kernel_ulong_t magic;
|
||||||
|
|
||||||
|
if (client->dev.platform_data) {
|
||||||
|
chip = *(struct at24_platform_data *)client->dev.platform_data;
|
||||||
|
} else {
|
||||||
|
if (!id->driver_data)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
magic = id->driver_data;
|
||||||
|
chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
|
||||||
|
magic >>= AT24_SIZE_BYTELEN;
|
||||||
|
chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is slow, but we can't know all eeproms, so we better
|
||||||
|
* play safe. Specifying custom eeprom-types via platform_data
|
||||||
|
* is recommended anyhow.
|
||||||
|
*/
|
||||||
|
chip.page_size = 1;
|
||||||
|
|
||||||
|
/* update chipdata if OF is present */
|
||||||
|
at24_get_ofdata(client, &chip);
|
||||||
|
|
||||||
|
printk(KERN_ALERT "at24_probe chip.byte_len = 0x%x\n", chip.byte_len);
|
||||||
|
printk(KERN_ALERT "at24_probe chip.flags = 0x%x\n", chip.flags);
|
||||||
|
printk(KERN_ALERT "at24_probe chip.magic = 0x%lx\n", id->driver_data);
|
||||||
|
|
||||||
|
chip.setup = NULL;
|
||||||
|
chip.context = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_power_of_2(chip.byte_len))
|
||||||
|
dev_warn(&client->dev,
|
||||||
|
"byte_len looks suspicious (no power of 2)!\n");
|
||||||
|
if (!chip.page_size) {
|
||||||
|
dev_err(&client->dev, "page_size must not be 0!\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
if (!is_power_of_2(chip.page_size))
|
||||||
|
dev_warn(&client->dev,
|
||||||
|
"page_size looks suspicious (no power of 2)!\n");
|
||||||
|
|
||||||
|
/* Use I2C operations unless we're stuck with SMBus extensions. */
|
||||||
|
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
|
||||||
|
if (i2c_check_functionality(client->adapter,
|
||||||
|
I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
|
||||||
|
use_smbus = I2C_SMBUS_I2C_BLOCK_DATA;
|
||||||
|
} else if (i2c_check_functionality(client->adapter,
|
||||||
|
I2C_FUNC_SMBUS_READ_WORD_DATA)) {
|
||||||
|
use_smbus = I2C_SMBUS_WORD_DATA;
|
||||||
|
} else if (i2c_check_functionality(client->adapter,
|
||||||
|
I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
|
||||||
|
use_smbus = I2C_SMBUS_BYTE_DATA;
|
||||||
|
} else {
|
||||||
|
return -EPFNOSUPPORT;
|
||||||
|
}
|
||||||
|
use_smbus = I2C_SMBUS_BYTE_DATA;
|
||||||
|
printk(KERN_ALERT "at24_probe use_smbus --> %d\n",
|
||||||
|
use_smbus);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chip.flags & AT24_FLAG_TAKE8ADDR)
|
||||||
|
num_addresses = 8;
|
||||||
|
else
|
||||||
|
num_addresses = DIV_ROUND_UP(chip.byte_len,
|
||||||
|
(chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
|
||||||
|
|
||||||
|
at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
|
||||||
|
num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
|
||||||
|
if (!at24)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
mutex_init(&at24->lock);
|
||||||
|
at24->use_smbus = use_smbus;
|
||||||
|
at24->chip = chip;
|
||||||
|
at24->num_addresses = num_addresses;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Export the EEPROM bytes through sysfs, since that's convenient.
|
||||||
|
* By default, only root should see the data (maybe passwords etc)
|
||||||
|
*/
|
||||||
|
sysfs_bin_attr_init(&at24->bin);
|
||||||
|
at24->bin.attr.name = "eeprom";
|
||||||
|
at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
|
||||||
|
at24->bin.read = at24_bin_read;
|
||||||
|
at24->bin.size = chip.byte_len;
|
||||||
|
|
||||||
|
at24->macc.read = at24_macc_read;
|
||||||
|
|
||||||
|
writable = !(chip.flags & AT24_FLAG_READONLY);
|
||||||
|
if (writable) {
|
||||||
|
if (!use_smbus || i2c_check_functionality(client->adapter,
|
||||||
|
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
|
||||||
|
|
||||||
|
unsigned write_max = chip.page_size;
|
||||||
|
|
||||||
|
at24->macc.write = at24_macc_write;
|
||||||
|
|
||||||
|
at24->bin.write = at24_bin_write;
|
||||||
|
at24->bin.attr.mode |= S_IWUSR;
|
||||||
|
|
||||||
|
if (write_max > io_limit)
|
||||||
|
write_max = io_limit;
|
||||||
|
if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX)
|
||||||
|
write_max = I2C_SMBUS_BLOCK_MAX;
|
||||||
|
at24->write_max = write_max;
|
||||||
|
|
||||||
|
/* buffer (data + address at the beginning) */
|
||||||
|
at24->writebuf = devm_kzalloc(&client->dev,
|
||||||
|
write_max + 2, GFP_KERNEL);
|
||||||
|
if (!at24->writebuf)
|
||||||
|
return -ENOMEM;
|
||||||
|
} else {
|
||||||
|
dev_warn(&client->dev,
|
||||||
|
"cannot write due to controller restrictions.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
at24->client[0] = client;
|
||||||
|
|
||||||
|
/* use dummy devices for multiple-address chips */
|
||||||
|
for (i = 1; i < num_addresses; i++) {
|
||||||
|
at24->client[i] = i2c_new_dummy(client->adapter,
|
||||||
|
client->addr + i);
|
||||||
|
if (!at24->client[i]) {
|
||||||
|
dev_err(&client->dev, "address 0x%02x unavailable\n",
|
||||||
|
client->addr + i);
|
||||||
|
err = -EADDRINUSE;
|
||||||
|
goto err_clients;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = sysfs_create_bin_file(&client->dev.kobj, &at24->bin);
|
||||||
|
if (err)
|
||||||
|
goto err_clients;
|
||||||
|
|
||||||
|
i2c_set_clientdata(client, at24);
|
||||||
|
|
||||||
|
dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n",
|
||||||
|
at24->bin.size, client->name,
|
||||||
|
writable ? "writable" : "read-only", at24->write_max);
|
||||||
|
if (use_smbus == I2C_SMBUS_WORD_DATA ||
|
||||||
|
use_smbus == I2C_SMBUS_BYTE_DATA) {
|
||||||
|
dev_notice(&client->dev, "Falling back to %s reads, "
|
||||||
|
"performance will suffer\n", use_smbus ==
|
||||||
|
I2C_SMBUS_WORD_DATA ? "word" : "byte");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* export data to kernel code */
|
||||||
|
if (chip.setup)
|
||||||
|
chip.setup(&at24->macc, chip.context);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_clients:
|
||||||
|
for (i = 1; i < num_addresses; i++)
|
||||||
|
if (at24->client[i])
|
||||||
|
i2c_unregister_device(at24->client[i]);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int at24_remove(struct i2c_client *client)
|
||||||
|
{
|
||||||
|
struct at24_data *at24;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
at24 = i2c_get_clientdata(client);
|
||||||
|
sysfs_remove_bin_file(&client->dev.kobj, &at24->bin);
|
||||||
|
|
||||||
|
for (i = 1; i < at24->num_addresses; i++)
|
||||||
|
i2c_unregister_device(at24->client[i]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static struct i2c_board_info i2c_devs = {
|
||||||
|
I2C_BOARD_INFO("24c64-ctc", 0x57),
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct i2c_adapter *adapter = NULL;
|
||||||
|
static struct i2c_client *client = NULL;
|
||||||
|
|
||||||
|
static int ctc_at24c64_init(void)
|
||||||
|
{
|
||||||
|
printk(KERN_ALERT "ctc_at24c64_init\n");
|
||||||
|
|
||||||
|
adapter = i2c_get_adapter(0);
|
||||||
|
if(adapter == NULL){
|
||||||
|
printk(KERN_ALERT "i2c_get_adapter == NULL\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
client = i2c_new_device(adapter, &i2c_devs);
|
||||||
|
if(client == NULL){
|
||||||
|
printk(KERN_ALERT "i2c_new_device == NULL\n");
|
||||||
|
i2c_put_adapter(adapter);
|
||||||
|
adapter = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ctc_at24c64_exit(void)
|
||||||
|
{
|
||||||
|
printk(KERN_ALERT "ctc_at24c64_exit\n");
|
||||||
|
if(client){
|
||||||
|
i2c_unregister_device(client);
|
||||||
|
}
|
||||||
|
if(adapter){
|
||||||
|
i2c_put_adapter(adapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct i2c_driver at24_ctc_driver = {
|
||||||
|
.driver = {
|
||||||
|
.name = "at24-ctc",
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
},
|
||||||
|
.probe = at24_probe,
|
||||||
|
.remove = at24_remove,
|
||||||
|
.id_table = at24_ctc_ids,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int __init at24_ctc_init(void)
|
||||||
|
{
|
||||||
|
if (!io_limit) {
|
||||||
|
pr_err("at24_ctc: io_limit must not be 0!\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
io_limit = rounddown_pow_of_two(io_limit);
|
||||||
|
|
||||||
|
ctc_at24c64_init();
|
||||||
|
|
||||||
|
return i2c_add_driver(&at24_ctc_driver);
|
||||||
|
}
|
||||||
|
module_init(at24_ctc_init);
|
||||||
|
|
||||||
|
static void __exit at24_ctc_exit(void)
|
||||||
|
{
|
||||||
|
ctc_at24c64_exit();
|
||||||
|
i2c_del_driver(&at24_ctc_driver);
|
||||||
|
}
|
||||||
|
module_exit(at24_ctc_exit);
|
||||||
|
|
||||||
|
MODULE_DESCRIPTION("Driver for most I2C EEPROMs");
|
||||||
|
MODULE_AUTHOR("David Brownell and Wolfram Sang");
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
/* XXX */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,170 @@
|
|||||||
|
/**
|
||||||
|
@file dal_kernel_io.h
|
||||||
|
|
||||||
|
@author Copyright (C) 2012 Centec Networks Inc. All rights reserved.
|
||||||
|
|
||||||
|
@date 2012-4-9
|
||||||
|
|
||||||
|
@version v2.0
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifndef _DAL_KERNEL_H_
|
||||||
|
#define _DAL_KERNEL_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RESOURCES_64BIT) || defined(CONFIG_PHYS_ADDR_T_64BIT)
|
||||||
|
#define PHYS_ADDR_IS_64BIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SDK_IN_USERMODE
|
||||||
|
#ifdef PHYS_ADDR_IS_64BIT
|
||||||
|
typedef long long intptr;
|
||||||
|
typedef unsigned long long uintptr;
|
||||||
|
#else
|
||||||
|
typedef int intptr;
|
||||||
|
typedef unsigned int uintptr;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DAL_PCI_READ_ADDR 0x0
|
||||||
|
#define DAL_PCI_READ_DATA 0xc
|
||||||
|
#define DAL_PCI_WRITE_ADDR 0x8
|
||||||
|
#define DAL_PCI_WRITE_DATA 0x4
|
||||||
|
#define DAL_PCI_STATUS 0x10
|
||||||
|
|
||||||
|
#define DAL_PCI_STATUS_IN_PROCESS 31
|
||||||
|
#define DAL_PCI_STATUS_BAD_PARITY 5
|
||||||
|
#define DAL_PCI_STATUS_CPU_ACCESS_ERR 4
|
||||||
|
#define DAL_PCI_STATUS_READ_CMD 3
|
||||||
|
#define DAL_PCI_STATUS_REGISTER_ERR 1
|
||||||
|
#define DAL_PCI_STATUS_REGISTER_ACK 0
|
||||||
|
|
||||||
|
#define DAL_PCI_ACCESS_TIMEOUT 0x64
|
||||||
|
|
||||||
|
#define DAL_NAME "linux_dal" /* "linux_dal" */
|
||||||
|
|
||||||
|
#define DAL_DEV_MAJOR 198
|
||||||
|
|
||||||
|
#define DAL_DEV_INTR_MAJOR_BASE 200
|
||||||
|
|
||||||
|
#define DAL_DEV_NAME "/dev/" DAL_NAME
|
||||||
|
#define DAL_ONE_KB 1024
|
||||||
|
#define DAL_ONE_MB (1024*1024)
|
||||||
|
struct dal_chip_parm_s
|
||||||
|
{
|
||||||
|
unsigned int chip_id; /*tmp should be uint8*/
|
||||||
|
unsigned int fpga_id; /*tmp add*/
|
||||||
|
unsigned int reg_addr;
|
||||||
|
unsigned int value;
|
||||||
|
};
|
||||||
|
typedef struct dal_chip_parm_s dal_chip_parm_t;
|
||||||
|
|
||||||
|
struct dal_intr_parm_s
|
||||||
|
{
|
||||||
|
unsigned int irq;
|
||||||
|
unsigned int enable;
|
||||||
|
};
|
||||||
|
typedef struct dal_intr_parm_s dal_intr_parm_t;
|
||||||
|
|
||||||
|
struct dal_irq_mapping_s
|
||||||
|
{
|
||||||
|
unsigned int hw_irq;
|
||||||
|
unsigned int sw_irq;
|
||||||
|
};
|
||||||
|
typedef struct dal_irq_mapping_s dal_irq_mapping_t;
|
||||||
|
|
||||||
|
struct dal_user_dev_s
|
||||||
|
{
|
||||||
|
unsigned int chip_num; /*output: local chip number*/
|
||||||
|
unsigned int chip_id; /*input: local chip id*/
|
||||||
|
unsigned int phy_base0; /* low 32bits physical base address */
|
||||||
|
unsigned int phy_base1; /* high 32bits physical base address */
|
||||||
|
unsigned int bus_no;
|
||||||
|
unsigned int dev_no;
|
||||||
|
unsigned int fun_no;
|
||||||
|
void* virt_base[2]; /* Virtual base address; this must be last member */
|
||||||
|
};
|
||||||
|
typedef struct dal_user_dev_s dal_user_dev_t;
|
||||||
|
|
||||||
|
struct dma_info_s
|
||||||
|
{
|
||||||
|
unsigned int lchip;
|
||||||
|
unsigned int phy_base;
|
||||||
|
unsigned int phy_base_hi;
|
||||||
|
unsigned int size;
|
||||||
|
unsigned int* virt_base;
|
||||||
|
};
|
||||||
|
typedef struct dma_info_s dma_info_t;
|
||||||
|
|
||||||
|
struct dal_pci_cfg_ioctl_s
|
||||||
|
{
|
||||||
|
unsigned int chip_id; /* Device ID */
|
||||||
|
unsigned int offset;
|
||||||
|
unsigned int value;
|
||||||
|
};
|
||||||
|
typedef struct dal_pci_cfg_ioctl_s dal_pci_cfg_ioctl_t;
|
||||||
|
|
||||||
|
struct dal_msi_info_s
|
||||||
|
{
|
||||||
|
unsigned int lchip;
|
||||||
|
unsigned int irq_base;
|
||||||
|
unsigned int irq_num;
|
||||||
|
};
|
||||||
|
typedef struct dal_msi_info_s dal_msi_info_t;
|
||||||
|
|
||||||
|
struct dal_intr_info_s
|
||||||
|
{
|
||||||
|
unsigned int irq;
|
||||||
|
unsigned int irq_idx;
|
||||||
|
};
|
||||||
|
typedef struct dal_intr_info_s dal_intr_info_t;
|
||||||
|
|
||||||
|
struct dal_dma_cache_info_s
|
||||||
|
{
|
||||||
|
unsigned long ptr;
|
||||||
|
unsigned int length;
|
||||||
|
};
|
||||||
|
typedef struct dal_dma_cache_info_s dal_dma_cache_info_t;
|
||||||
|
|
||||||
|
#define CMD_MAGIC 'C'
|
||||||
|
#define CMD_WRITE_CHIP _IO(CMD_MAGIC, 0) /* for humber ioctrol*/
|
||||||
|
#define CMD_READ_CHIP _IO(CMD_MAGIC, 1) /* for humber ioctrol*/
|
||||||
|
#define CMD_GET_DEVICES _IO(CMD_MAGIC, 2)
|
||||||
|
#define CMD_GET_DAL_VERSION _IO(CMD_MAGIC, 3)
|
||||||
|
#define CMD_PCI_CONFIG_WRITE _IO(CMD_MAGIC, 4)
|
||||||
|
#define CMD_PCI_CONFIG_READ _IO(CMD_MAGIC, 5)
|
||||||
|
#define CMD_GET_DMA_INFO _IO(CMD_MAGIC, 6)
|
||||||
|
#define CMD_REG_INTERRUPTS _IO(CMD_MAGIC, 7)
|
||||||
|
#define CMD_UNREG_INTERRUPTS _IO(CMD_MAGIC, 8)
|
||||||
|
#define CMD_EN_INTERRUPTS _IO(CMD_MAGIC, 9)
|
||||||
|
#define CMD_I2C_READ _IO(CMD_MAGIC, 10)
|
||||||
|
#define CMD_I2C_WRITE _IO(CMD_MAGIC, 11)
|
||||||
|
#define CMD_GET_MSI_INFO _IO(CMD_MAGIC, 12)
|
||||||
|
#define CMD_SET_MSI_CAP _IO(CMD_MAGIC, 13)
|
||||||
|
#define CMD_IRQ_MAPPING _IO(CMD_MAGIC, 14)
|
||||||
|
#define CMD_GET_INTR_INFO _IO(CMD_MAGIC, 15)
|
||||||
|
#define CMD_CACHE_INVAL _IO(CMD_MAGIC, 16)
|
||||||
|
#define CMD_CACHE_FLUSH _IO(CMD_MAGIC, 17)
|
||||||
|
|
||||||
|
enum dal_version_e
|
||||||
|
{
|
||||||
|
VERSION_MIN,
|
||||||
|
VERSION_1DOT0,
|
||||||
|
VERSION_1DOT1,
|
||||||
|
VERSION_1DOT2,
|
||||||
|
|
||||||
|
VERSION_MAX
|
||||||
|
};
|
||||||
|
typedef enum dal_version_e dal_version_t;
|
||||||
|
|
||||||
|
/* We try to assemble a contiguous segment from chunks of this size */
|
||||||
|
#define DMA_BLOCK_SIZE (512 * DAL_ONE_KB)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,343 @@
|
|||||||
|
|
||||||
|
#include "dal_mpool.h"
|
||||||
|
|
||||||
|
#ifdef __KERNEL__
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
|
||||||
|
#define DAL_MALLOC(x) kmalloc(x, GFP_ATOMIC)
|
||||||
|
#define DAL_FREE(x) kfree(x)
|
||||||
|
|
||||||
|
static spinlock_t dal_mpool_lock;
|
||||||
|
#define MPOOL_LOCK_INIT() spin_lock_init(&dal_mpool_lock)
|
||||||
|
#define MPOOL_LOCK() unsigned long flags; spin_lock_irqsave(&dal_mpool_lock, flags)
|
||||||
|
#define MPOOL_UNLOCK() spin_unlock_irqrestore(&dal_mpool_lock, flags)
|
||||||
|
#define DAL_PRINT(fmt,arg...) printk(fmt,##arg)
|
||||||
|
#else /* !__KERNEL__*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "sal.h"
|
||||||
|
#define DAL_MALLOC(x) malloc(x)
|
||||||
|
#define DAL_FREE(x) free(x)
|
||||||
|
static sal_mutex_t* dal_mpool_lock;
|
||||||
|
#define MPOOL_LOCK_INIT() sal_mutex_create(&dal_mpool_lock)
|
||||||
|
#define MPOOL_LOCK() sal_mutex_lock(dal_mpool_lock)
|
||||||
|
#define MPOOL_UNLOCK() sal_mutex_unlock(dal_mpool_lock)
|
||||||
|
#define DAL_PRINT(fmt,arg...) sal_printf(fmt,##arg)
|
||||||
|
|
||||||
|
#endif /* __KERNEL__ */
|
||||||
|
|
||||||
|
dal_mpool_mem_t* g_free_block_ptr = NULL;
|
||||||
|
|
||||||
|
/* System cache line size */
|
||||||
|
#ifndef DAL_CACHE_LINE_BYTES
|
||||||
|
#define DAL_CACHE_LINE_BYTES 256
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static dal_mpool_mem_t* p_desc_pool = NULL;
|
||||||
|
static dal_mpool_mem_t* p_data_pool = NULL;
|
||||||
|
|
||||||
|
int
|
||||||
|
dal_mpool_init(void)
|
||||||
|
{
|
||||||
|
MPOOL_LOCK_INIT();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dal_mpool_mem_t*
|
||||||
|
_dal_mpool_create(void* base, int size, int type)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* head = NULL;
|
||||||
|
dal_mpool_mem_t* tail = NULL;
|
||||||
|
|
||||||
|
head = (dal_mpool_mem_t*)DAL_MALLOC(sizeof(dal_mpool_mem_t));
|
||||||
|
if (head == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tail = (dal_mpool_mem_t*)DAL_MALLOC(sizeof(dal_mpool_mem_t));
|
||||||
|
if (tail == NULL)
|
||||||
|
{
|
||||||
|
DAL_FREE(head);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
head->size = tail->size = 0;
|
||||||
|
head->type = type;
|
||||||
|
head->address = base;
|
||||||
|
tail->address = head->address + size;
|
||||||
|
head->next = tail;
|
||||||
|
tail->next = NULL;
|
||||||
|
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
|
dal_mpool_mem_t*
|
||||||
|
dal_mpool_create(void* base, int size)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* head = NULL;
|
||||||
|
int mod = (int)(((unsigned long)base) & (DAL_CACHE_LINE_BYTES - 1));
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
if (mod)
|
||||||
|
{
|
||||||
|
base = (char*)base + (DAL_CACHE_LINE_BYTES - mod);
|
||||||
|
size -= (DAL_CACHE_LINE_BYTES - mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
size &= ~(DAL_CACHE_LINE_BYTES - 1);
|
||||||
|
|
||||||
|
/* init for common linkptr, only used for GB */
|
||||||
|
head = _dal_mpool_create(base, size, DAL_MPOOL_TYPE_USELESS);
|
||||||
|
if (NULL == head)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* init for desc linkptr */
|
||||||
|
p_desc_pool = _dal_mpool_create(base, DAL_MPOOL_MAX_DESX_SIZE, DAL_MPOOL_TYPE_DESC);
|
||||||
|
if (NULL == p_desc_pool)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
DAL_FREE(head->next);
|
||||||
|
DAL_FREE(head);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* init for data linkptr */
|
||||||
|
p_data_pool = _dal_mpool_create(((char*)base+DAL_MPOOL_MAX_DESX_SIZE), (size - DAL_MPOOL_MAX_DESX_SIZE), DAL_MPOOL_TYPE_DATA);
|
||||||
|
if (NULL == p_data_pool)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
DAL_FREE(head->next);
|
||||||
|
DAL_FREE(head);
|
||||||
|
DAL_FREE(p_desc_pool->next);
|
||||||
|
DAL_FREE(p_desc_pool);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
|
dal_mpool_mem_t*
|
||||||
|
_dal_mpool_alloc_comon(dal_mpool_mem_t* ptr, int size, int type)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* new_ptr = NULL;
|
||||||
|
|
||||||
|
while (ptr && ptr->next)
|
||||||
|
{
|
||||||
|
if (ptr->next->address - (ptr->address + ptr->size) >= size)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(ptr && ptr->next))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_ptr = DAL_MALLOC(sizeof(dal_mpool_mem_t));
|
||||||
|
if (!new_ptr)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_ptr->type = type;
|
||||||
|
new_ptr->address = ptr->address + ptr->size;
|
||||||
|
new_ptr->size = size;
|
||||||
|
new_ptr->next = ptr->next;
|
||||||
|
ptr->next = new_ptr;
|
||||||
|
|
||||||
|
return new_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void*
|
||||||
|
dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* ptr = NULL;
|
||||||
|
dal_mpool_mem_t* new_ptr = NULL;
|
||||||
|
int mod;
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
mod = size & (DAL_CACHE_LINE_BYTES - 1);
|
||||||
|
if (mod != 0)
|
||||||
|
{
|
||||||
|
size += (DAL_CACHE_LINE_BYTES - mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case DAL_MPOOL_TYPE_USELESS:
|
||||||
|
ptr = pool;
|
||||||
|
new_ptr = _dal_mpool_alloc_comon(ptr, size, type);
|
||||||
|
if (NULL == new_ptr)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DAL_MPOOL_TYPE_DESC:
|
||||||
|
ptr = p_desc_pool;
|
||||||
|
new_ptr = _dal_mpool_alloc_comon(ptr, size, type);
|
||||||
|
if (NULL == new_ptr)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DAL_MPOOL_TYPE_DATA:
|
||||||
|
ptr = p_data_pool;
|
||||||
|
new_ptr = _dal_mpool_alloc_comon(ptr, size, type);
|
||||||
|
if (NULL == new_ptr)
|
||||||
|
{
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
|
||||||
|
return new_ptr->address;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_dal_mpool_free(dal_mpool_mem_t* ptr, void* addr, int type)
|
||||||
|
{
|
||||||
|
unsigned char* address = (unsigned char*)addr;
|
||||||
|
dal_mpool_mem_t* prev = NULL;
|
||||||
|
|
||||||
|
while (ptr && ptr->next)
|
||||||
|
{
|
||||||
|
if (ptr->next->address == address)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ptr && ptr->next)
|
||||||
|
{
|
||||||
|
prev = ptr;
|
||||||
|
ptr = ptr->next;
|
||||||
|
prev->next = ptr->next;
|
||||||
|
DAL_FREE(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dal_mpool_free(dal_mpool_mem_t* pool, void* addr)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* ptr = pool;
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
switch(pool->type)
|
||||||
|
{
|
||||||
|
case DAL_MPOOL_TYPE_USELESS:
|
||||||
|
ptr = pool;
|
||||||
|
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_USELESS);
|
||||||
|
break;
|
||||||
|
case DAL_MPOOL_TYPE_DESC:
|
||||||
|
ptr = p_desc_pool;
|
||||||
|
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_DESC);
|
||||||
|
break;
|
||||||
|
case DAL_MPOOL_TYPE_DATA:
|
||||||
|
ptr = p_data_pool;
|
||||||
|
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_DATA);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
dal_mpool_destroy(dal_mpool_mem_t* pool)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* ptr, * next;
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
for (ptr = pool; ptr; ptr = next)
|
||||||
|
{
|
||||||
|
next = ptr->next;
|
||||||
|
DAL_FREE(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ptr = p_desc_pool; ptr; ptr = next)
|
||||||
|
{
|
||||||
|
next = ptr->next;
|
||||||
|
DAL_FREE(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ptr = p_data_pool; ptr; ptr = next)
|
||||||
|
{
|
||||||
|
next = ptr->next;
|
||||||
|
DAL_FREE(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
dal_mpool_usage(dal_mpool_mem_t* pool, int type)
|
||||||
|
{
|
||||||
|
int usage = 0;
|
||||||
|
dal_mpool_mem_t* ptr;
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
for (ptr = pool; ptr; ptr = ptr->next)
|
||||||
|
{
|
||||||
|
if (ptr->type == type || ptr->type == -1)
|
||||||
|
{
|
||||||
|
usage += ptr->size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
|
||||||
|
return usage;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
dal_mpool_debug(dal_mpool_mem_t* pool)
|
||||||
|
{
|
||||||
|
dal_mpool_mem_t* ptr;
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
MPOOL_LOCK();
|
||||||
|
|
||||||
|
for (ptr = pool; ptr; ptr = ptr->next)
|
||||||
|
{
|
||||||
|
// DAL_PRINT("%2dst mpool block: address=0x%8x, size=0x%x \n", index, (unsigned int)ptr->address, ptr->size);
|
||||||
|
DAL_PRINT("%2dst mpool block: address=%p, size=0x%x \n", index, ptr->address, ptr->size); // note
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPOOL_UNLOCK();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
@file dal_mpool.h
|
||||||
|
|
||||||
|
@author Copyright (C) 2011 Centec Networks Inc. All rights reserved.
|
||||||
|
|
||||||
|
@date 2012-5-10
|
||||||
|
|
||||||
|
@version v2.0
|
||||||
|
|
||||||
|
This file contains the dma memory init, allocation and free APIs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _DMA_MPOOL_H
|
||||||
|
#define _DMA_MPOOL_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DAL_MPOOL_MAX_DESX_SIZE (1024*1024)
|
||||||
|
|
||||||
|
enum dal_mpool_type_e
|
||||||
|
{
|
||||||
|
DAL_MPOOL_TYPE_USELESS, /* just compatible with GB */
|
||||||
|
DAL_MPOOL_TYPE_DESC, /* dma mpool op for desc */
|
||||||
|
DAL_MPOOL_TYPE_DATA /* dma mpool op for data */
|
||||||
|
};
|
||||||
|
typedef enum dal_mpool_type_e dal_mpool_type_t;
|
||||||
|
|
||||||
|
struct dal_mpool_mem_s
|
||||||
|
{
|
||||||
|
unsigned char* address;
|
||||||
|
int size;
|
||||||
|
int type;
|
||||||
|
struct dal_mpool_mem_s* next;
|
||||||
|
};
|
||||||
|
typedef struct dal_mpool_mem_s dal_mpool_mem_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief This function is to alloc dma memory
|
||||||
|
|
||||||
|
@param[in] size size of memory
|
||||||
|
|
||||||
|
@return NULL
|
||||||
|
|
||||||
|
*/
|
||||||
|
extern int
|
||||||
|
dal_mpool_init(void);
|
||||||
|
|
||||||
|
extern dal_mpool_mem_t*
|
||||||
|
dal_mpool_create(void* base_ptr, int size);
|
||||||
|
|
||||||
|
extern void*
|
||||||
|
dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type);
|
||||||
|
|
||||||
|
extern void
|
||||||
|
dal_mpool_free(dal_mpool_mem_t* pool, void* addr);
|
||||||
|
|
||||||
|
extern int
|
||||||
|
dal_mpool_destroy(dal_mpool_mem_t* pool);
|
||||||
|
|
||||||
|
extern int
|
||||||
|
dal_mpool_usage(dal_mpool_mem_t* pool, int type);
|
||||||
|
|
||||||
|
extern int
|
||||||
|
dal_mpool_debug(dal_mpool_mem_t* pool);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !_DMA_MPOOL_H */
|
||||||
|
|
62
platform/centec/sonic-platform-modules-e582/48x6q/scripts/48x6q_platform.sh
Executable file
62
platform/centec/sonic-platform-modules-e582/48x6q/scripts/48x6q_platform.sh
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#platform init script for centec e582-48x6q
|
||||||
|
|
||||||
|
init_devnum() {
|
||||||
|
found=0
|
||||||
|
for devnum in 0 1; do
|
||||||
|
devname=`cat /sys/bus/i2c/devices/i2c-${devnum}/name`
|
||||||
|
# I801 adapter can be at either dffd0000 or dfff0000
|
||||||
|
if [[ $devname == 'SMBus I801 adapter at '* ]]; then
|
||||||
|
found=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
[ $found -eq 0 ] && echo "cannot find I801" && exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
init_devnum
|
||||||
|
|
||||||
|
if [ "$1" == "init" ]; then
|
||||||
|
#install drivers and dependencies
|
||||||
|
depmod -a
|
||||||
|
modprobe i2c-i801
|
||||||
|
modprobe i2c-dev
|
||||||
|
modprobe i2c-mux
|
||||||
|
modprobe i2c-smbus
|
||||||
|
modprobe i2c-mux-pca954x force_deselect_on_exit=1
|
||||||
|
i2cset -y 0 0x58 0x8 0x3f
|
||||||
|
i2cset -y 0 0x20 0x1b 0x0
|
||||||
|
i2cset -y 0 0x20 0xb 0x0
|
||||||
|
i2cset -y 0 0x21 0x19 0x0
|
||||||
|
i2cset -y 0 0x21 0x9 0x0
|
||||||
|
i2cset -y 0 0x21 0x1c 0x0
|
||||||
|
i2cset -y 0 0x21 0xc 0x0
|
||||||
|
i2cset -y 0 0x22 0x1a 0x0
|
||||||
|
i2cset -y 0 0x22 0xa 0x0
|
||||||
|
i2cset -y 0 0x23 0x18 0x0
|
||||||
|
i2cset -y 0 0x23 0x8 0x0
|
||||||
|
i2cset -y 0 0x23 0x1b 0x0
|
||||||
|
i2cset -y 0 0x23 0xb 0x0
|
||||||
|
modprobe lm77
|
||||||
|
modprobe tun
|
||||||
|
modprobe dal
|
||||||
|
modprobe centec_at24c64
|
||||||
|
modprobe centec_e582_48x6q_platform
|
||||||
|
|
||||||
|
#start platform monitor
|
||||||
|
rm -rf /usr/bin/platform_monitor
|
||||||
|
ln -s /usr/bin/48x6q_platform_monitor.py /usr/bin/platform_monitor
|
||||||
|
python /usr/bin/platform_monitor &
|
||||||
|
elif [ "$1" == "deinit" ]; then
|
||||||
|
kill -9 $(pidof platform_monitor) > /dev/null 2>&1
|
||||||
|
rm -rf /usr/bin/platform_monitor
|
||||||
|
modprobe -r centec_e582_48x6q_platform
|
||||||
|
modprobe -r centec_at24c64
|
||||||
|
modprobe -r dal
|
||||||
|
modprobe -r i2c-mux-pca954x
|
||||||
|
modprobe -r i2c-dev
|
||||||
|
else
|
||||||
|
echo "e582-48x6q_platform : Invalid option !"
|
||||||
|
fi
|
@ -0,0 +1,217 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# Centec
|
||||||
|
#
|
||||||
|
# Module contains an implementation of sfp presence scan logic
|
||||||
|
#
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
try:
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
import struct
|
||||||
|
import syslog
|
||||||
|
import swsssdk
|
||||||
|
from socket import *
|
||||||
|
from select import *
|
||||||
|
except ImportError, e:
|
||||||
|
raise ImportError(str(e) + " - required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
def DBG_PRINT(str):
|
||||||
|
syslog.openlog("centec-pmon")
|
||||||
|
syslog.syslog(syslog.LOG_INFO, str)
|
||||||
|
syslog.closelog()
|
||||||
|
|
||||||
|
PORT_NUMBER = (48+6)
|
||||||
|
|
||||||
|
class PlatformMonitor:
|
||||||
|
|
||||||
|
"""init board platform default config"""
|
||||||
|
def __init__(self):
|
||||||
|
"""[ctlid, slavedevid]"""
|
||||||
|
self.fiber_mapping = [(0, 0)] # res
|
||||||
|
self.fiber_mapping.extend([(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7)]) # panel port 1~8
|
||||||
|
self.fiber_mapping.extend([(0, 14), (0, 13), (0, 15), (0, 12), (0, 8), (0, 11), (0, 9), (0, 10)]) # panel port 9~16
|
||||||
|
self.fiber_mapping.extend([(0, 22), (0, 21), (0, 23), (0, 20), (0, 16), (0, 19), (0, 17), (0, 18)]) # panel port 17~24
|
||||||
|
self.fiber_mapping.extend([(1, 4), (1, 3), (1, 5), (1, 2), (1, 6), (1, 1), (1, 7), (1, 0)]) # panel port 25~32
|
||||||
|
self.fiber_mapping.extend([(1, 8), (1, 15), (1, 9), (1, 14), (1, 10), (1, 13), (1, 11), (1, 12)]) # panel port 33~40
|
||||||
|
self.fiber_mapping.extend([(1, 22), (1, 21), (1, 23), (1, 20), (1, 16), (1, 19), (1, 17), (1, 18)]) # panel port 41~48
|
||||||
|
self.fiber_mapping.extend([(1, 28), (1, 29), (1, 26), (1, 27), (1, 24), (1, 25)]) # panel port 49~54
|
||||||
|
|
||||||
|
self.udpClient = socket(AF_INET, SOCK_DGRAM)
|
||||||
|
self.sfp_present = [0]*(PORT_NUMBER+1)
|
||||||
|
self.sfp_enable = [0]*(PORT_NUMBER+1)
|
||||||
|
self.f_sfp_present = "/sys/class/sfp/sfp{}/sfp_presence"
|
||||||
|
self.f_sfp_enable = "/sys/class/sfp/sfp{}/sfp_enable"
|
||||||
|
self.sfp_scan_timer = 0
|
||||||
|
|
||||||
|
def is_qsfp(self, port):
|
||||||
|
if port <= 48:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def get_sfp_present(self, port):
|
||||||
|
with open(self.f_sfp_present.format(port), 'r') as sfp_file:
|
||||||
|
return int(sfp_file.read())
|
||||||
|
|
||||||
|
def set_sfp_present(self, port, present):
|
||||||
|
self.sfp_present[port] = present
|
||||||
|
|
||||||
|
def set_sfp_enable(self, port, enable):
|
||||||
|
if self.is_qsfp(port):
|
||||||
|
if enable:
|
||||||
|
with open(self.f_sfp_enable.format(port), 'w') as sfp_file:
|
||||||
|
sfp_file.write("1")
|
||||||
|
self.sfp_enable[port] = 1
|
||||||
|
else:
|
||||||
|
with open(self.f_sfp_enable.format(port), 'w') as sfp_file:
|
||||||
|
sfp_file.write("0")
|
||||||
|
self.sfp_enable[port] = 0
|
||||||
|
else:
|
||||||
|
(ctlid, devid) = self.fiber_mapping[port]
|
||||||
|
req = struct.pack('=HHHBBHIBBBBI', 0, 9, 16, ctlid, devid, 0x50, 0, 0x56, 1, 0xf, 0, 1)
|
||||||
|
self.udpClient.sendto(req, ('localhost', 8101))
|
||||||
|
rsp, addr = self.udpClient.recvfrom(1024)
|
||||||
|
rsp_data = struct.unpack('=HHHBBHIBBBBIi512B', rsp)
|
||||||
|
enable_v = rsp_data[13]
|
||||||
|
if enable:
|
||||||
|
enable_v &= 0xf0
|
||||||
|
else:
|
||||||
|
enable_v |= 0x0f
|
||||||
|
data = struct.pack('=HHHBBHBBBB', 0, 11, 8, ctlid, 0x56, 0x50, devid, enable_v, 0xf, 0)
|
||||||
|
self.udpClient.sendto(data, ('localhost', 8101))
|
||||||
|
DBG_PRINT("set sfp{} to {}".format(port, ("enable" if enable else "disable")))
|
||||||
|
|
||||||
|
def initialize_configdb(self):
|
||||||
|
try:
|
||||||
|
f_mac = os.popen('ip link show eth0 | grep ether | awk \'{print $2}\'')
|
||||||
|
mac_addr = f_mac.read(17)
|
||||||
|
last_byte = mac_addr[-2:]
|
||||||
|
aligned_last_byte = format(int(int(str(last_byte), 16) + 1), '02x')
|
||||||
|
mac_addr = mac_addr[:-2] + aligned_last_byte
|
||||||
|
DBG_PRINT("start connect swss config-db to set device mac-address")
|
||||||
|
swss = swsssdk.SonicV2Connector()
|
||||||
|
swss.connect(swss.CONFIG_DB)
|
||||||
|
swss.set(swss.CONFIG_DB, "DEVICE_METADATA|localhost", 'mac', mac_addr)
|
||||||
|
mac_addr = swss.get(swss.CONFIG_DB, "DEVICE_METADATA|localhost", 'mac')
|
||||||
|
DBG_PRINT("set device mac-address: %s" % mac_addr)
|
||||||
|
except IOError as e:
|
||||||
|
DBG_PRINT(str(e))
|
||||||
|
|
||||||
|
def initialize_rpc(self):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
r_sel = [self.udpClient]
|
||||||
|
echo_req = struct.pack('=HHH', 0, 1, 0)
|
||||||
|
self.udpClient.sendto(echo_req, ('localhost', 8101))
|
||||||
|
result = select(r_sel, [], [], 1)
|
||||||
|
if self.udpClient in result[0]:
|
||||||
|
echo_rsp, srv_addr = self.udpClient.recvfrom(1024)
|
||||||
|
if echo_rsp:
|
||||||
|
break
|
||||||
|
DBG_PRINT("connect to sdk rpc server timeout, try again.")
|
||||||
|
except IOError as e:
|
||||||
|
DBG_PRINT(str(e))
|
||||||
|
|
||||||
|
DBG_PRINT("connect to sdk rpc server success.")
|
||||||
|
|
||||||
|
def initialize_gpio(self):
|
||||||
|
# set gpio 1,2,3,4,5,6,7,8 output mode
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 1, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 2, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 3, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 4, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 5, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 6, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 7, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 8, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
# set gpio 1,2,3,4,5,6,7,8 output 0 to reset i2c bridge
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 1, 0)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 2, 0)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 3, 0)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 4, 0)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 5, 0)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 6, 0)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 7, 0)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 8, 0)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
# set gpio 1,2,3,4,5,6,7,8 output 1 to release i2c bridge
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 1, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 2, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 3, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 4, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 5, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 6, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 7, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 8, 1)
|
||||||
|
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||||
|
DBG_PRINT("config ctc chip gpio done.")
|
||||||
|
|
||||||
|
def initialize_sfp(self):
|
||||||
|
try:
|
||||||
|
for port in range(1, PORT_NUMBER+1):
|
||||||
|
if self.get_sfp_present(port):
|
||||||
|
self.set_sfp_present(port, 1)
|
||||||
|
self.set_sfp_enable(port, 1)
|
||||||
|
else:
|
||||||
|
self.set_sfp_present(port, 0)
|
||||||
|
self.set_sfp_enable(port, 0)
|
||||||
|
except IOError as e:
|
||||||
|
DBG_PRINT(str(e))
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
DBG_PRINT("start connect to sdk rpc server.")
|
||||||
|
|
||||||
|
self.initialize_configdb()
|
||||||
|
self.initialize_rpc()
|
||||||
|
self.initialize_gpio()
|
||||||
|
self.initialize_sfp()
|
||||||
|
|
||||||
|
def sfp_scan(self):
|
||||||
|
try:
|
||||||
|
for port in range(1, PORT_NUMBER+1):
|
||||||
|
cur_present = self.get_sfp_present(port)
|
||||||
|
if self.sfp_present[port] != cur_present:
|
||||||
|
self.set_sfp_present(port, cur_present)
|
||||||
|
self.set_sfp_enable(port, cur_present)
|
||||||
|
except IOError as e:
|
||||||
|
DBG_PRINT(str(e))
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
while True:
|
||||||
|
self.sfp_scan()
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
monitor = PlatformMonitor()
|
||||||
|
monitor.initialize()
|
||||||
|
monitor.start()
|
||||||
|
|
15
platform/centec/sonic-platform-modules-e582/LICENSE
Normal file
15
platform/centec/sonic-platform-modules-e582/LICENSE
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
Copyright (C) 2017 Centec, Inc
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1
platform/centec/sonic-platform-modules-e582/README.md
Normal file
1
platform/centec/sonic-platform-modules-e582/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
platform drivers for Centec E582 for the SONiC project
|
11
platform/centec/sonic-platform-modules-e582/debian/changelog
Normal file
11
platform/centec/sonic-platform-modules-e582/debian/changelog
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
sonic-centec-platform-modules (1.1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Add support for centec e582-48x2q4z
|
||||||
|
|
||||||
|
-- xuwj <xuwj@centecnetworks.com> Thus, 25 Jan 2018 13:43:40 +0800
|
||||||
|
|
||||||
|
sonic-centec-platform-modules (1.0) unstable; urgency=low
|
||||||
|
|
||||||
|
* Initial release
|
||||||
|
|
||||||
|
-- xuwj <xuwj@centecnetworks.com> Mon, 22 Jan 2018 13:43:40 +0800
|
@ -0,0 +1 @@
|
|||||||
|
9
|
17
platform/centec/sonic-platform-modules-e582/debian/control
Normal file
17
platform/centec/sonic-platform-modules-e582/debian/control
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Source: sonic-centec-platform-modules
|
||||||
|
Section: main
|
||||||
|
Priority: extra
|
||||||
|
Maintainer: yangbs <yangbs@centecnetworks.com>
|
||||||
|
Build-Depends: debhelper (>= 8.0.0), bzip2
|
||||||
|
Standards-Version: 3.9.3
|
||||||
|
|
||||||
|
Package: platform-modules-e582-48x2q4z
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: linux-image-3.16.0-5-amd64
|
||||||
|
Description: kernel modules for platform devices such as fan, led, sfp
|
||||||
|
|
||||||
|
Package: platform-modules-e582-48x6q
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: linux-image-3.16.0-5-amd64
|
||||||
|
Description: kernel modules for platform devices such as fan, led, sfp
|
||||||
|
|
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: setup-board
|
||||||
|
# Required-Start:
|
||||||
|
# Required-Stop:
|
||||||
|
# Should-Start:
|
||||||
|
# Should-Stop:
|
||||||
|
# Default-Start: S
|
||||||
|
# Default-Stop: 0 6
|
||||||
|
# Short-Description: Setup e582-48x2q4z board.
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo -n "Setting up board... "
|
||||||
|
/usr/bin/48x2q4z_platform.sh init
|
||||||
|
|
||||||
|
echo "done."
|
||||||
|
;;
|
||||||
|
|
||||||
|
stop)
|
||||||
|
/usr/bin/48x2q4z_platform.sh deinit
|
||||||
|
echo "done."
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
force-reload|restart)
|
||||||
|
echo "Not supported"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Usage: service platform-modules-e582-48x2q4z {start|stop}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
@ -0,0 +1,2 @@
|
|||||||
|
48x2q4z/cfg/48x2q4z-modules.conf etc/modules-load.d
|
||||||
|
48x2q4z/scripts/48x2q4z_platform.sh usr/bin
|
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: setup-board
|
||||||
|
# Required-Start:
|
||||||
|
# Required-Stop:
|
||||||
|
# Should-Start:
|
||||||
|
# Should-Stop:
|
||||||
|
# Default-Start: S
|
||||||
|
# Default-Stop: 0 6
|
||||||
|
# Short-Description: Setup e582-48x6q board.
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo -n "Setting up board... "
|
||||||
|
/usr/bin/48x6q_platform.sh init
|
||||||
|
|
||||||
|
echo "done."
|
||||||
|
;;
|
||||||
|
|
||||||
|
stop)
|
||||||
|
/usr/bin/48x6q_platform.sh deinit
|
||||||
|
echo "done."
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
force-reload|restart)
|
||||||
|
echo "Not supported"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Usage: service platform-modules-e582-48x6q {start|stop}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
@ -0,0 +1,6 @@
|
|||||||
|
48x6q/cfg/48x6q-modules.conf etc/modules-load.d
|
||||||
|
48x6q/cfg/minigraph.xml etc/sonic
|
||||||
|
48x6q/cfg/config_db.json etc/sonic
|
||||||
|
48x6q/cfg/config_db_l2l3.json etc/sonic
|
||||||
|
48x6q/scripts/48x6q_platform.sh usr/bin
|
||||||
|
48x6q/scripts/48x6q_platform_monitor.py usr/bin
|
35
platform/centec/sonic-platform-modules-e582/debian/rules
Executable file
35
platform/centec/sonic-platform-modules-e582/debian/rules
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
export INSTALL_MOD_DIR:=extra
|
||||||
|
|
||||||
|
KVERSION ?= $(shell uname -r)
|
||||||
|
KERNEL_SRC := /lib/modules/$(KVERSION)
|
||||||
|
MOD_SRC_DIR:= $(shell pwd)
|
||||||
|
MODULE_DIRS:= 48x6q 48x2q4z
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
|
|
||||||
|
override_dh_auto_build:
|
||||||
|
(for mod in $(MODULE_DIRS); do \
|
||||||
|
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
|
||||||
|
done)
|
||||||
|
|
||||||
|
override_dh_auto_install:
|
||||||
|
(for mod in $(MODULE_DIRS); do \
|
||||||
|
dh_installdirs -pplatform-modules-e582-$${mod} \
|
||||||
|
$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
|
||||||
|
cp -f $(MOD_SRC_DIR)/$${mod}/modules/*.ko \
|
||||||
|
debian/platform-modules-e582-$${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; \
|
||||||
|
rm -rf $(MOD_SRC_DIR)/$${mod}/modules/*.ko; \
|
||||||
|
rm -rf debian/platform-modules-e582-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR)/*.ko; \
|
||||||
|
done)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user