[platform]: Support for platforms based on Barefoot Networks' device (#1478)
This commit is contained in:
parent
ff6066db5e
commit
2d24c9ee2a
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -74,3 +74,6 @@
|
||||
[submodule "platform/centec/sonic-platform-modules-e582"]
|
||||
path = platform/centec/sonic-platform-modules-e582
|
||||
url = https://github.com/CentecNetworks/sonic-platform-modules-e582
|
||||
[submodule "platform/barefoot/sonic-platform-modules-ingrasys"]
|
||||
path = platform/barefoot/sonic-platform-modules-ingrasys
|
||||
url = https://github.com/Ingrasys-sonic/sonic-platform-modules-ingrasys-barefoot.git
|
||||
|
@ -0,0 +1 @@
|
||||
CONSOLE_SPEED=57600
|
1079
device/barefoot/x86_64-accton_wedge100bf_32x-r0/minigraph.xml
Normal file
1079
device/barefoot/x86_64-accton_wedge100bf_32x-r0/minigraph.xml
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,33 @@
|
||||
# name lanes
|
||||
Ethernet0 0,1,2,3
|
||||
Ethernet4 4,5,6,7
|
||||
Ethernet8 8,9,10,11
|
||||
Ethernet12 12,13,14,15
|
||||
Ethernet16 16,17,18,19
|
||||
Ethernet20 20,21,22,23
|
||||
Ethernet24 24,25,26,27
|
||||
Ethernet28 28,29,30,31
|
||||
Ethernet32 32,33,34,35
|
||||
Ethernet36 36,37,38,39
|
||||
Ethernet40 40,41,42,43
|
||||
Ethernet44 44,45,46,47
|
||||
Ethernet48 48,49,50,51
|
||||
Ethernet52 52,53,54,55
|
||||
Ethernet56 56,57,58,59
|
||||
Ethernet60 60,61,62,63
|
||||
Ethernet64 64,65,66,67
|
||||
Ethernet68 68,69,70,71
|
||||
Ethernet72 72,73,74,75
|
||||
Ethernet76 76,77,78,79
|
||||
Ethernet80 80,81,82,83
|
||||
Ethernet84 84,85,86,87
|
||||
Ethernet88 88,89,90,91
|
||||
Ethernet92 92,93,94,95
|
||||
Ethernet96 96,97,98,99
|
||||
Ethernet100 100,101,102,103
|
||||
Ethernet104 104,105,106,107
|
||||
Ethernet108 108,109,110,111
|
||||
Ethernet112 112,113,114,115
|
||||
Ethernet116 116,117,118,119
|
||||
Ethernet120 120,121,122,123
|
||||
Ethernet124 124,125,126,127
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
"chip_list": [
|
||||
{
|
||||
"id": "asic-0",
|
||||
"chip_family": "Tofino",
|
||||
"instance": 0,
|
||||
"pcie_sysfs_prefix": "/sys/devices/pci0000:00/0000:00:03.0/0000:05:00.0",
|
||||
"pcie_domain": 0,
|
||||
"pcie_bus": 5,
|
||||
"pcie_fn": 0,
|
||||
"pcie_dev": 0,
|
||||
"pcie_int_mode": 1,
|
||||
"sds_fw_path": "share/tofino_sds_fw/avago/firmware"
|
||||
}
|
||||
],
|
||||
"instance": 0,
|
||||
"p4_program_list": [
|
||||
{
|
||||
"id": "pgm-0",
|
||||
"instance": 0,
|
||||
"path": "switch",
|
||||
"program-name": "switch",
|
||||
"pd": "lib/tofinopd/switch/libpd.so",
|
||||
"pd-thrift": "lib/tofinopd/switch/libpdthrift.so",
|
||||
"table-config": "share/tofinopd/switch/context.json",
|
||||
"tofino-bin": "share/tofinopd/switch/tofino.bin",
|
||||
"switchapi": "lib/libswitchapi.so",
|
||||
"switchsai": "lib/libswitchsai.so",
|
||||
"agent0": "lib/platform/x86_64-accton_wedge100bf_32x-r0/libpltfm_mgr.so",
|
||||
"switchapi_port_add": false
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1 @@
|
||||
CONSOLE_SPEED=57600
|
@ -0,0 +1,66 @@
|
||||
# name lanes
|
||||
Ethernet0 0,1,2,3
|
||||
Ethernet4 4,5,6,7
|
||||
Ethernet8 8,9,10,11
|
||||
Ethernet12 12,13,14,15
|
||||
Ethernet16 16,17,18,19
|
||||
Ethernet20 20,21,22,23
|
||||
Ethernet24 24,25,26,27
|
||||
Ethernet28 28,29,30,31
|
||||
Ethernet32 32,33,34,35
|
||||
Ethernet36 36,37,38,39
|
||||
Ethernet40 40,41,42,43
|
||||
Ethernet44 44,45,46,47
|
||||
Ethernet48 48,49,50,51
|
||||
Ethernet52 52,53,54,55
|
||||
Ethernet56 56,57,58,59
|
||||
Ethernet60 60,61,62,63
|
||||
Ethernet64 64,65,66,67
|
||||
Ethernet68 68,69,70,71
|
||||
Ethernet72 72,73,74,75
|
||||
Ethernet76 76,77,78,79
|
||||
Ethernet80 80,81,82,83
|
||||
Ethernet84 84,85,86,87
|
||||
Ethernet88 88,89,90,91
|
||||
Ethernet92 92,93,94,95
|
||||
Ethernet96 96,97,98,99
|
||||
Ethernet100 100,101,102,103
|
||||
Ethernet104 104,105,106,107
|
||||
Ethernet108 108,109,110,111
|
||||
Ethernet112 112,113,114,115
|
||||
Ethernet116 116,117,118,119
|
||||
Ethernet120 120,121,122,123
|
||||
Ethernet124 124,125,126,127
|
||||
Ethernet128 128,129,130,131
|
||||
Ethernet132 132,133,134,135
|
||||
Ethernet136 136,137,138,139
|
||||
Ethernet140 140,141,142,143
|
||||
Ethernet144 144,145,146,147
|
||||
Ethernet148 148,149,150,151
|
||||
Ethernet152 152,153,154,155
|
||||
Ethernet156 156,157,158,159
|
||||
Ethernet160 160,161,162,163
|
||||
Ethernet164 164,165,166,167
|
||||
Ethernet168 168,169,170,171
|
||||
Ethernet172 172,173,174,175
|
||||
Ethernet176 176,177,178,179
|
||||
Ethernet180 180,181,182,183
|
||||
Ethernet184 184,185,186,187
|
||||
Ethernet188 188,189,190,191
|
||||
Ethernet192 192,193,194,195
|
||||
Ethernet196 196,197,198,199
|
||||
Ethernet200 200,201,202,203
|
||||
Ethernet204 204,205,206,207
|
||||
Ethernet208 208,209,210,211
|
||||
Ethernet212 212,213,214,215
|
||||
Ethernet216 216,217,218,219
|
||||
Ethernet220 220,221,222,223
|
||||
Ethernet224 224,225,226,227
|
||||
Ethernet228 228,229,230,231
|
||||
Ethernet232 232,233,234,235
|
||||
Ethernet236 236,237,238,239
|
||||
Ethernet240 240,241,242,243
|
||||
Ethernet244 244,245,246,247
|
||||
Ethernet248 248,249,250,251
|
||||
Ethernet252 252,253,254,255
|
||||
Ethernet256 256,257,258,259
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
"chip_list": [
|
||||
{
|
||||
"id": "asic-0",
|
||||
"chip_family": "Tofino",
|
||||
"instance": 0,
|
||||
"pcie_sysfs_prefix": "/sys/devices/pci0000:00/0000:00:03.0/0000:05:00.0",
|
||||
"pcie_domain": 0,
|
||||
"pcie_bus": 5,
|
||||
"pcie_fn": 0,
|
||||
"pcie_dev": 0,
|
||||
"pcie_int_mode": 1,
|
||||
"sds_fw_path": "share/tofino_sds_fw/avago/firmware"
|
||||
}
|
||||
],
|
||||
"instance": 0,
|
||||
"p4_program_list": [
|
||||
{
|
||||
"id": "pgm-0",
|
||||
"instance": 0,
|
||||
"path": "switch",
|
||||
"program-name": "switch",
|
||||
"pd": "lib/tofinopd/switch/libpd.so",
|
||||
"pd-thrift": "lib/tofinopd/switch/libpdthrift.so",
|
||||
"table-config": "share/tofinopd/switch/context.json",
|
||||
"tofino-bin": "share/tofinopd/switch/tofino.bin",
|
||||
"switchapi": "lib/libswitchapi.so",
|
||||
"switchsai": "lib/libswitchsai.so",
|
||||
"agent0": "lib/platform/x86_64-accton_wedge100bf_65x-r0/libpltfm_mgr.so",
|
||||
"switchapi_port_add": false
|
||||
}
|
||||
]
|
||||
}
|
1079
device/barefoot/x86_64-accton_wedge100bf_65x-r0/minigraph.xml
Normal file
1079
device/barefoot/x86_64-accton_wedge100bf_65x-r0/minigraph.xml
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,33 @@
|
||||
# name lanes alias speed autoneg fec index
|
||||
Ethernet0 0,1,2,3 Ethernet0 100000 0 none 0
|
||||
Ethernet4 4,5,6,7 Ethernet4 100000 0 none 1
|
||||
Ethernet8 8,9,10,11 Ethernet8 100000 0 none 2
|
||||
Ethernet12 12,13,14,15 Ethernet12 100000 0 none 3
|
||||
Ethernet16 16,17,18,19 Ethernet16 100000 0 none 4
|
||||
Ethernet20 20,21,22,23 Ethernet20 100000 0 none 5
|
||||
Ethernet24 24,25,26,27 Ethernet24 100000 0 none 6
|
||||
Ethernet28 28,29,30,31 Ethernet28 100000 0 none 7
|
||||
Ethernet32 32,33,34,35 Ethernet32 100000 0 none 8
|
||||
Ethernet36 36,37,38,39 Ethernet36 100000 0 none 9
|
||||
Ethernet40 40,41,42,43 Ethernet40 100000 0 none 10
|
||||
Ethernet44 44,45,46,47 Ethernet44 100000 0 none 11
|
||||
Ethernet48 48,49,50,51 Ethernet48 100000 0 none 12
|
||||
Ethernet52 52,53,54,55 Ethernet52 100000 0 none 13
|
||||
Ethernet56 56,57,58,59 Ethernet56 100000 0 none 14
|
||||
Ethernet60 60,61,62,63 Ethernet60 100000 0 none 15
|
||||
Ethernet64 64,65,66,67 Ethernet64 100000 0 none 16
|
||||
Ethernet68 68,69,70,71 Ethernet68 100000 0 none 17
|
||||
Ethernet72 72,73,74,75 Ethernet72 100000 0 none 18
|
||||
Ethernet76 76,77,78,79 Ethernet76 100000 0 none 19
|
||||
Ethernet80 80,81,82,83 Ethernet80 100000 0 none 20
|
||||
Ethernet84 84,85,86,87 Ethernet84 100000 0 none 21
|
||||
Ethernet88 88,89,90,91 Ethernet88 100000 0 none 22
|
||||
Ethernet92 92,93,94,95 Ethernet92 100000 0 none 23
|
||||
Ethernet96 96,97,98,99 Ethernet96 100000 0 none 24
|
||||
Ethernet100 100,101,102,103 Ethernet100 100000 0 none 25
|
||||
Ethernet104 104,105,106,107 Ethernet104 100000 0 none 26
|
||||
Ethernet108 108,109,110,111 Ethernet108 100000 0 none 27
|
||||
Ethernet112 112,113,114,115 Ethernet112 100000 0 none 28
|
||||
Ethernet116 116,117,118,119 Ethernet116 100000 0 none 29
|
||||
Ethernet120 120,121,122,123 Ethernet120 100000 0 none 30
|
||||
Ethernet124 124,125,126,127 Ethernet124 100000 0 none 31
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
"chip_list": [
|
||||
{
|
||||
"id": "asic-0",
|
||||
"chip_family": "Tofino",
|
||||
"instance": 0,
|
||||
"pcie_sysfs_prefix": "/sys/devices/pci0000:00/0000:00:03.0/0000:05:00.0",
|
||||
"pcie_domain": 0,
|
||||
"pcie_bus": 5,
|
||||
"pcie_fn": 0,
|
||||
"pcie_dev": 0,
|
||||
"pcie_int_mode": 1,
|
||||
"sds_fw_path": "share/tofino_sds_fw/avago/firmware"
|
||||
}
|
||||
],
|
||||
"instance": 0,
|
||||
"p4_program_list": [
|
||||
{
|
||||
"id": "pgm-0",
|
||||
"instance": 0,
|
||||
"path": "switch",
|
||||
"program-name": "switch",
|
||||
"pd": "lib/tofinopd/switch/libpd.so",
|
||||
"pd-thrift": "lib/tofinopd/switch/libpdthrift.so",
|
||||
"table-config": "share/tofinopd/switch/context.json",
|
||||
"tofino-bin": "share/tofinopd/switch/tofino.bin",
|
||||
"switchapi": "lib/libswitchapi.so",
|
||||
"switchsai": "lib/libswitchsai.so",
|
||||
"agent0": "lib/platform/x86_64-ingrasys_s9180_32x-r0/libpltfm_mgr.so",
|
||||
"switchapi_port_add": false
|
||||
}
|
||||
]
|
||||
}
|
12
device/ingrasys/x86_64-ingrasys_s9180_32x-r0/fancontrol
Normal file
12
device/ingrasys/x86_64-ingrasys_s9180_32x-r0/fancontrol
Normal file
@ -0,0 +1,12 @@
|
||||
# Configuration file generated by pwmconfig, changes will be lost
|
||||
INTERVAL=10
|
||||
DEVPATH=hwmon1=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-56/56-002f
|
||||
DEVNAME=hwmon1=w83795adg
|
||||
FCTEMPS=hwmon1/device/pwm2=hwmon2/temp2_input hwmon1/device/pwm1=hwmon2/temp2_input
|
||||
FCFANS=hwmon1/device/pwm2=hwmon1/device/fan8_input hwmon1/device/pwm2=hwmon1/device/fan7_input hwmon1/device/pwm2=hwmon1/device/fan6_input hwmon1/device/pwm2=hwmon1/device/fan5_input hwmon1/device/pwm1=hwmon1/device/fan4_input hwmon1/device/pwm1=hwmon1/device/fan3_input hwmon1/device/pwm1=hwmon1/device/fan2_input hwmon1/device/pwm1=hwmon1/device/fan1_input
|
||||
# TODO: check the temp value with HW after board ready
|
||||
MINTEMP=hwmon1/device/pwm2=20 hwmon1/device/pwm1=20
|
||||
MAXTEMP=hwmon1/device/pwm2=60 hwmon1/device/pwm1=60
|
||||
MINSTART=hwmon1/device/pwm2=75 hwmon1/device/pwm1=75
|
||||
MINSTOP=hwmon1/device/pwm2=22 hwmon1/device/pwm1=22
|
||||
|
@ -0,0 +1,3 @@
|
||||
CONSOLE_PORT=0x3f8
|
||||
CONSOLE_DEV=0
|
||||
CONSOLE_SPEED=115200
|
151
device/ingrasys/x86_64-ingrasys_s9180_32x-r0/minigraph.xml
Normal file
151
device/ingrasys/x86_64-ingrasys_s9180_32x-r0/minigraph.xml
Normal file
@ -0,0 +1,151 @@
|
||||
<DeviceMiniGraph xmlns="Microsoft.Search.Autopilot.Evolution" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<CpgDec>
|
||||
<IsisRouters xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
<PeeringSessions>
|
||||
<BGPSession>
|
||||
<StartRouter>OCPSCH0104001MS</StartRouter>
|
||||
<StartPeer>10.10.1.26</StartPeer>
|
||||
<EndRouter>OCPSCH01040GGLF</EndRouter>
|
||||
<EndPeer>10.10.1.25</EndPeer>
|
||||
<Multihop>1</Multihop>
|
||||
<HoldTime>10</HoldTime>
|
||||
<KeepAliveTime>3</KeepAliveTime>
|
||||
</BGPSession>
|
||||
<BGPSession>
|
||||
<StartRouter>OCPSCH0104002MS</StartRouter>
|
||||
<StartPeer>10.10.2.26</StartPeer>
|
||||
<EndRouter>OCPSCH01040GGLF</EndRouter>
|
||||
<EndPeer>10.10.2.25</EndPeer>
|
||||
<Multihop>1</Multihop>
|
||||
<HoldTime>10</HoldTime>
|
||||
<KeepAliveTime>3</KeepAliveTime>
|
||||
</BGPSession>
|
||||
</PeeringSessions>
|
||||
<Routers xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:BGPRouterDeclaration>
|
||||
<a:ASN>64536</a:ASN>
|
||||
<a:Hostname>OCPSCH01040GGLF</a:Hostname>
|
||||
<a:Peers>
|
||||
<BGPPeer>
|
||||
<Address>10.10.1.26</Address>
|
||||
<RouteMapIn i:nil="true"/>
|
||||
<RouteMapOut i:nil="true"/>
|
||||
</BGPPeer>
|
||||
<BGPPeer>
|
||||
<Address>10.10.2.26</Address>
|
||||
<RouteMapIn i:nil="true"/>
|
||||
<RouteMapOut i:nil="true"/>
|
||||
</BGPPeer>
|
||||
</a:Peers>
|
||||
<a:RouteMaps/>
|
||||
</a:BGPRouterDeclaration>
|
||||
<a:BGPRouterDeclaration>
|
||||
<a:ASN>64542</a:ASN>
|
||||
<a:Hostname>OCPSCH0104001MS</a:Hostname>
|
||||
<a:RouteMaps/>
|
||||
</a:BGPRouterDeclaration>
|
||||
<a:BGPRouterDeclaration>
|
||||
<a:ASN>64543</a:ASN>
|
||||
<a:Hostname>OCPSCH0104002MS</a:Hostname>
|
||||
<a:RouteMaps/>
|
||||
</a:BGPRouterDeclaration>
|
||||
</Routers>
|
||||
</CpgDec>
|
||||
<DpgDec>
|
||||
<DeviceDataPlaneInfo>
|
||||
<IPSecTunnels/>
|
||||
<LoopbackIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:LoopbackIPInterface>
|
||||
<Name>HostIP</Name>
|
||||
<AttachTo>Loopback0</AttachTo>
|
||||
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux">
|
||||
<b:IPPrefix>100.0.0.9/32</b:IPPrefix>
|
||||
</a:Prefix>
|
||||
<a:PrefixStr>100.0.0.9/32</a:PrefixStr>
|
||||
</a:LoopbackIPInterface>
|
||||
</LoopbackIPInterfaces>
|
||||
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
</ManagementIPInterfaces>
|
||||
<MplsInterfaces/>
|
||||
<MplsTeInterfaces/>
|
||||
<RsvpInterfaces/>
|
||||
<Hostname>OCPSCH01040GGLF</Hostname>
|
||||
<PortChannelInterfaces/>
|
||||
<VlanInterfaces/>
|
||||
<IPInterfaces>
|
||||
<IPInterface>
|
||||
<Name i:nil="true"/>
|
||||
<AttachTo>Ethernet0</AttachTo>
|
||||
<Prefix>10.10.1.25/30</Prefix>
|
||||
</IPInterface>
|
||||
<IPInterface>
|
||||
<Name i:nil="true"/>
|
||||
<AttachTo>Ethernet4</AttachTo>
|
||||
<Prefix>10.10.2.25/30</Prefix>
|
||||
</IPInterface>
|
||||
</IPInterfaces>
|
||||
<DataAcls/>
|
||||
<AclInterfaces/>
|
||||
<DownstreamSummaries/>
|
||||
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
</DeviceDataPlaneInfo>
|
||||
</DpgDec>
|
||||
<PngDec>
|
||||
<DeviceInterfaceLinks>
|
||||
<DeviceLinkBase i:type="DeviceInterfaceLink">
|
||||
<Bandwidth>40000</Bandwidth>
|
||||
<ElementType>DeviceInterfaceLink</ElementType>
|
||||
<EndDevice>OCPSCH0104001MS</EndDevice>
|
||||
<EndPort>Ethernet24</EndPort>
|
||||
<StartDevice>OCPSCH01040GGLF</StartDevice>
|
||||
<StartPort>Ethernet0</StartPort>
|
||||
</DeviceLinkBase>
|
||||
<DeviceLinkBase i:type="DeviceInterfaceLink">
|
||||
<Bandwidth>40000</Bandwidth>
|
||||
<ElementType>DeviceInterfaceLink</ElementType>
|
||||
<EndDevice>OCPSCH0104002MS</EndDevice>
|
||||
<EndPort>Ethernet24</EndPort>
|
||||
<StartDevice>OCPSCH01040GGLF</StartDevice>
|
||||
<StartPort>Ethernet4</StartPort>
|
||||
</DeviceLinkBase>
|
||||
</DeviceInterfaceLinks>
|
||||
<Devices>
|
||||
<Device i:type="LeafRouter">
|
||||
<Hostname>OCPSCH01040GGLF</Hostname>
|
||||
<HwSku>INGRASYS-S9180-32X</HwSku>
|
||||
</Device>
|
||||
</Devices>
|
||||
</PngDec>
|
||||
<MetadataDeclaration>
|
||||
<Devices xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:DeviceMetadata>
|
||||
<a:Name>OCPSCH01040GGLF</a:Name>
|
||||
<a:Properties>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>DhcpResources</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value></a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>NtpResources</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value>0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org</a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>SyslogResources</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value></a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value>2.2.2.2</a:Value>
|
||||
</a:DeviceProperty>
|
||||
</a:Properties>
|
||||
</a:DeviceMetadata>
|
||||
</Devices>
|
||||
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
</MetadataDeclaration>
|
||||
<Hostname>OCPSCH01040GGLF</Hostname>
|
||||
<HwSku>INGRASYS-S9180-32X</HwSku>
|
||||
</DeviceMiniGraph>
|
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Ingrasys S9180-32X
|
||||
#
|
||||
# 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:
|
||||
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-0055/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
@ -0,0 +1,90 @@
|
||||
#
|
||||
# psuutil.py
|
||||
# Platform-specific PSU status interface for SONiC
|
||||
#
|
||||
|
||||
|
||||
import os.path
|
||||
|
||||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
||||
SYS_GPIO_DIR = "/sys/class/gpio/"
|
||||
|
||||
def __init__(self):
|
||||
PsuBase.__init__(self)
|
||||
|
||||
|
||||
# Get sysfs attribute
|
||||
def get_attr_value(self, attr_path):
|
||||
|
||||
retval = 'ERR'
|
||||
if (not os.path.isfile(attr_path)):
|
||||
return retval
|
||||
|
||||
try:
|
||||
with open(attr_path, 'r') as fd:
|
||||
retval = fd.read()
|
||||
except Exception as error:
|
||||
logging.error("Unable to open ", attr_path, " file !")
|
||||
|
||||
retval = retval.rstrip('\r\n')
|
||||
return retval
|
||||
|
||||
def get_num_psus(self):
|
||||
"""
|
||||
Retrieves the number of PSUs available on the device
|
||||
:return: An integer, the number of PSUs available on the device
|
||||
"""
|
||||
MAX_PSUS = 2
|
||||
return MAX_PSUS
|
||||
|
||||
def get_psu_status(self, index):
|
||||
"""
|
||||
Retrieves the oprational status of power supply unit (PSU) defined
|
||||
by index <index>
|
||||
:param index: An integer, index of the PSU of which to query status
|
||||
:return: Boolean, True if PSU is operating properly, False if PSU is\
|
||||
faulty
|
||||
"""
|
||||
status = 0
|
||||
gpio_path = [ 'gpio99/value', 'gpio96/value' ]
|
||||
attr_path = self.SYS_GPIO_DIR + gpio_path[index-1]
|
||||
|
||||
attr_value = self.get_attr_value(attr_path)
|
||||
|
||||
if (attr_value != 'ERR'):
|
||||
attr_value = int(attr_value, 10)
|
||||
# Check for PSU status
|
||||
if (attr_value == 1):
|
||||
status = 1
|
||||
|
||||
return status
|
||||
|
||||
def get_psu_presence(self, index):
|
||||
"""
|
||||
Retrieves the presence status of power supply unit (PSU) defined
|
||||
by index <index>
|
||||
:param index: An integer, index of the PSU of which to query status
|
||||
:return: Boolean, True if PSU is plugged, False if not
|
||||
"""
|
||||
status = 0
|
||||
gpio_path = [ 'gpio100/value', 'gpio97/value' ]
|
||||
attr_path = self.SYS_GPIO_DIR + gpio_path[index-1]
|
||||
|
||||
attr_value = self.get_attr_value(attr_path)
|
||||
|
||||
if (attr_value != 'ERR'):
|
||||
attr_value = int(attr_value, 10)
|
||||
# Check for PSU status
|
||||
if (attr_value == 1):
|
||||
status = 1
|
||||
|
||||
return status
|
||||
|
290
device/ingrasys/x86_64-ingrasys_s9180_32x-r0/plugins/sfputil.py
Normal file
290
device/ingrasys/x86_64-ingrasys_s9180_32x-r0/plugins/sfputil.py
Normal file
@ -0,0 +1,290 @@
|
||||
# sfputil.py
|
||||
#
|
||||
# Platform-specific SFP transceiver interface for SONiC
|
||||
#
|
||||
|
||||
try:
|
||||
import time
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
PORT_START = 0
|
||||
PORT_END = 33
|
||||
SFP_PORT_START = 32
|
||||
PORTS_IN_BLOCK = 34
|
||||
|
||||
BASE_DIR_PATH = "/sys/class/gpio/gpio{0}/direction"
|
||||
BASE_VAL_PATH = "/sys/class/gpio/gpio{0}/value"
|
||||
|
||||
_port_to_eeprom_mapping = {}
|
||||
port_to_i2c_mapping = {
|
||||
0: 10,
|
||||
1: 9,
|
||||
2: 12,
|
||||
3: 11,
|
||||
4: 14,
|
||||
5: 13,
|
||||
6: 16,
|
||||
7: 15,
|
||||
8: 18,
|
||||
9: 17,
|
||||
10: 20,
|
||||
11: 19,
|
||||
12: 22,
|
||||
13: 21,
|
||||
14: 24,
|
||||
15: 23,
|
||||
16: 26,
|
||||
17: 25,
|
||||
18: 28,
|
||||
19: 27,
|
||||
20: 30,
|
||||
21: 29,
|
||||
22: 32,
|
||||
23: 31,
|
||||
24: 34,
|
||||
25: 33,
|
||||
26: 36,
|
||||
27: 35,
|
||||
28: 38,
|
||||
29: 37,
|
||||
30: 40,
|
||||
31: 39,
|
||||
32: 45,
|
||||
33: 46
|
||||
}
|
||||
|
||||
abs_to_gpio_mapping = {
|
||||
0: 241,
|
||||
1: 240,
|
||||
2: 243,
|
||||
3: 242,
|
||||
4: 245,
|
||||
5: 244,
|
||||
6: 247,
|
||||
7: 246,
|
||||
8: 249,
|
||||
9: 248,
|
||||
10: 251,
|
||||
11: 250,
|
||||
12: 253,
|
||||
13: 252,
|
||||
14: 255,
|
||||
15: 254,
|
||||
16: 225,
|
||||
17: 224,
|
||||
18: 227,
|
||||
19: 226,
|
||||
20: 229,
|
||||
21: 228,
|
||||
22: 231,
|
||||
23: 230,
|
||||
24: 233,
|
||||
25: 232,
|
||||
26: 235,
|
||||
27: 234,
|
||||
28: 237,
|
||||
29: 236,
|
||||
30: 239,
|
||||
31: 238,
|
||||
32: 177,
|
||||
33: 176
|
||||
}
|
||||
|
||||
lpmode_to_gpio_mapping = {
|
||||
0: 161,
|
||||
1: 160,
|
||||
2: 163,
|
||||
3: 162,
|
||||
4: 165,
|
||||
5: 164,
|
||||
6: 167,
|
||||
7: 166,
|
||||
8: 169,
|
||||
9: 168,
|
||||
10: 171,
|
||||
11: 170,
|
||||
12: 173,
|
||||
13: 172,
|
||||
14: 175,
|
||||
15: 174,
|
||||
16: 145,
|
||||
17: 144,
|
||||
18: 147,
|
||||
19: 146,
|
||||
20: 149,
|
||||
21: 148,
|
||||
22: 151,
|
||||
23: 150,
|
||||
24: 153,
|
||||
25: 152,
|
||||
26: 155,
|
||||
27: 154,
|
||||
28: 157,
|
||||
29: 156,
|
||||
30: 159,
|
||||
31: 158
|
||||
}
|
||||
|
||||
reset_to_gpio_mapping = {
|
||||
0: 129,
|
||||
1: 128,
|
||||
2: 131,
|
||||
3: 130,
|
||||
4: 133,
|
||||
5: 132,
|
||||
6: 135,
|
||||
7: 134,
|
||||
8: 137,
|
||||
9: 136,
|
||||
10: 139,
|
||||
11: 138,
|
||||
12: 141,
|
||||
13: 140,
|
||||
14: 143,
|
||||
15: 142,
|
||||
16: 113,
|
||||
17: 112,
|
||||
18: 115,
|
||||
19: 114,
|
||||
20: 117,
|
||||
21: 116,
|
||||
22: 119,
|
||||
23: 118,
|
||||
24: 121,
|
||||
25: 120,
|
||||
26: 123,
|
||||
27: 122,
|
||||
28: 125,
|
||||
29: 124,
|
||||
30: 127,
|
||||
31: 126
|
||||
}
|
||||
|
||||
@property
|
||||
def port_start(self):
|
||||
return self.PORT_START
|
||||
|
||||
@property
|
||||
def port_end(self):
|
||||
return self.PORT_END
|
||||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(0, self.PORTS_IN_BLOCK + 1)
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
return self._port_to_eeprom_mapping
|
||||
@property
|
||||
def sfp_port_start(self):
|
||||
return self.SFP_PORT_START
|
||||
|
||||
def __init__(self):
|
||||
# Override port_to_eeprom_mapping for class initialization
|
||||
eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
|
||||
|
||||
for x in range(self.port_start, self.port_end + 1):
|
||||
port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x])
|
||||
self.port_to_eeprom_mapping[x] = port_eeprom_path
|
||||
|
||||
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:
|
||||
abs_device_file = self.BASE_VAL_PATH.format(
|
||||
self.abs_to_gpio_mapping[port_num])
|
||||
val_file = open(abs_device_file)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
|
||||
# content is a string, either "0" or "1"
|
||||
if content == "1":
|
||||
return True
|
||||
|
||||
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.sfp_port_start: # TBD
|
||||
return False
|
||||
|
||||
try:
|
||||
lpmode_val_device_file = self.BASE_VAL_PATH.format(
|
||||
self.lpmode_to_gpio_mapping[port_num])
|
||||
val_file = open(lpmode_val_device_file)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
|
||||
# content is a string, either "0" or "1"
|
||||
if content == "1":
|
||||
return True
|
||||
|
||||
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.sfp_port_start: # TBD
|
||||
return False
|
||||
|
||||
try:
|
||||
lpmode_val_device_file = self.BASE_VAL_PATH.format(
|
||||
self.lpmode_to_gpio_mapping[port_num])
|
||||
val_file = open(lpmode_val_device_file, "w")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
val_file.write("1" if lpmode is True else "0")
|
||||
val_file.close()
|
||||
|
||||
return True
|
||||
|
||||
def reset(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.sfp_port_start: # TBD
|
||||
return False
|
||||
|
||||
try:
|
||||
reset_val_device_file = self.BASE_VAL_PATH.format(
|
||||
self.reset_to_gpio_mapping[port_num])
|
||||
val_file = open(reset_val_device_file, "w")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
val_file.write("1")
|
||||
val_file.close()
|
||||
|
||||
# Sleep 1 second to allow it to settle
|
||||
time.sleep(1)
|
||||
|
||||
try:
|
||||
reset_val_device_file = self.BASE_VAL_PATH.format(
|
||||
self.reset_to_gpio_mapping[port_num])
|
||||
val_file = open(reset_val_device_file, "w")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
val_file.write("0")
|
||||
val_file.close()
|
||||
|
||||
return True
|
76
device/ingrasys/x86_64-ingrasys_s9180_32x-r0/sensors.conf
Normal file
76
device/ingrasys/x86_64-ingrasys_s9180_32x-r0/sensors.conf
Normal file
@ -0,0 +1,76 @@
|
||||
# libsensors configuration file
|
||||
chip "i350bb-*"
|
||||
ignore loc1
|
||||
|
||||
chip "jc42-*"
|
||||
label temp1 "DIMM Temp"
|
||||
set temp1_max 50
|
||||
set temp1_crit 85
|
||||
|
||||
bus "i2c-0" "I2C I801"
|
||||
chip "tmp75-i2c-*-4f"
|
||||
label temp1 "CPU Board Temp"
|
||||
set temp1_max 50
|
||||
|
||||
bus "i2c-41" "i2c-7-switch (chan_id 0)"
|
||||
chip "tmp75-i2c-*-48"
|
||||
label temp1 "Near PSU1"
|
||||
set temp1_max 50
|
||||
chip "tmp75-i2c-*-4a"
|
||||
label temp1 "Rear MAC"
|
||||
set temp1_max 50
|
||||
chip "tmp75-i2c-*-4b"
|
||||
label temp1 "Near Port 32"
|
||||
set temp1_max 50
|
||||
chip "tmp75-i2c-*-4d"
|
||||
label temp1 "Near PSU2"
|
||||
set temp1_max 50
|
||||
chip "lm86-i2c-*-4c"
|
||||
label temp1 "Front MAC"
|
||||
label temp2 "ASIC Core Temp"
|
||||
set temp1_min 20
|
||||
set temp1_max 65
|
||||
set temp1_crit 70
|
||||
set temp2_min 20
|
||||
set temp2_max 70
|
||||
set temp2_crit 80
|
||||
|
||||
bus "i2c-56" "i2c-0-mux (chan_id 7)"
|
||||
chip "w83795adg-*"
|
||||
label in0 "0.9V"
|
||||
set in0_max 0.927
|
||||
set in0_min 0.873
|
||||
label in1 "0.86V"
|
||||
set in1_max 0.877
|
||||
set in1_min 0.843
|
||||
ignore in2
|
||||
ignore in3
|
||||
ignore in4
|
||||
ignore in5
|
||||
ignore in6
|
||||
ignore in7
|
||||
label in12 "2.5V"
|
||||
#compute in12 (2*4*@)/10, @-(2*4*@/10)
|
||||
compute in12 @/(1+(3/10)), @*(1+(3/10))
|
||||
set in12_max 2.625
|
||||
set in12_min 2.375
|
||||
# in12 and in13 are the same source
|
||||
ignore in13
|
||||
ignore in14
|
||||
ignore in15
|
||||
ignore in16
|
||||
label fan1 "FANTRAY 1-A"
|
||||
label fan2 "FANTRAY 1-B"
|
||||
label fan3 "FANTRAY 2-A"
|
||||
label fan4 "FANTRAY 2-B"
|
||||
label fan5 "FANTRAY 3-A"
|
||||
label fan6 "FANTRAY 3-B"
|
||||
label fan7 "FANTRAY 4-A"
|
||||
label fan8 "FANTRAY 4-B"
|
||||
ignore temp1
|
||||
ignore temp2
|
||||
ignore temp3
|
||||
ignore temp4
|
||||
ignore temp5
|
||||
ignore temp6
|
||||
ignore intrusion0
|
@ -0,0 +1,55 @@
|
||||
# name lanes alias speed autoneg fec
|
||||
Ethernet0 0 Ethernet0 25000 1 rs
|
||||
Ethernet4 1 Ethernet4 25000 1 rs
|
||||
Ethernet8 2 Ethernet8 25000 1 rs
|
||||
Ethernet12 3 Ethernet12 25000 1 rs
|
||||
Ethernet16 4 Ethernet16 25000 1 rs
|
||||
Ethernet20 5 Ethernet20 25000 1 rs
|
||||
Ethernet24 6 Ethernet24 25000 1 rs
|
||||
Ethernet28 7 Ethernet28 25000 1 rs
|
||||
Ethernet32 8 Ethernet32 25000 1 rs
|
||||
Ethernet36 9 Ethernet36 25000 1 rs
|
||||
Ethernet40 10 Ethernet40 25000 1 rs
|
||||
Ethernet44 11 Ethernet44 25000 1 rs
|
||||
Ethernet48 12 Ethernet48 25000 1 rs
|
||||
Ethernet52 13 Ethernet52 25000 1 rs
|
||||
Ethernet56 14 Ethernet56 25000 1 rs
|
||||
Ethernet60 15 Ethernet60 25000 1 rs
|
||||
Ethernet64 16 Ethernet64 25000 1 rs
|
||||
Ethernet68 17 Ethernet68 25000 1 rs
|
||||
Ethernet72 18 Ethernet72 25000 1 rs
|
||||
Ethernet76 19 Ethernet76 25000 1 rs
|
||||
Ethernet80 20 Ethernet80 25000 1 rs
|
||||
Ethernet84 21 Ethernet84 25000 1 rs
|
||||
Ethernet88 22 Ethernet88 25000 1 rs
|
||||
Ethernet92 23 Ethernet92 25000 1 rs
|
||||
Ethernet96 24 Ethernet96 25000 1 rs
|
||||
Ethernet100 25 Ethernet100 25000 1 rs
|
||||
Ethernet104 26 Ethernet104 25000 1 rs
|
||||
Ethernet108 27 Ethernet108 25000 1 rs
|
||||
Ethernet112 28 Ethernet112 25000 1 rs
|
||||
Ethernet116 29 Ethernet116 25000 1 rs
|
||||
Ethernet120 30 Ethernet120 25000 1 rs
|
||||
Ethernet124 31 Ethernet124 25000 1 rs
|
||||
Ethernet128 32 Ethernet128 25000 1 rs
|
||||
Ethernet132 33 Ethernet132 25000 1 rs
|
||||
Ethernet136 34 Ethernet136 25000 1 rs
|
||||
Ethernet140 35 Ethernet140 25000 1 rs
|
||||
Ethernet144 36 Ethernet144 25000 1 rs
|
||||
Ethernet148 37 Ethernet148 25000 1 rs
|
||||
Ethernet152 38 Ethernet152 25000 1 rs
|
||||
Ethernet156 39 Ethernet156 25000 1 rs
|
||||
Ethernet160 40 Ethernet160 25000 1 rs
|
||||
Ethernet164 41 Ethernet164 25000 1 rs
|
||||
Ethernet168 42 Ethernet168 25000 1 rs
|
||||
Ethernet172 43 Ethernet172 25000 1 rs
|
||||
Ethernet176 44 Ethernet176 25000 1 rs
|
||||
Ethernet180 45 Ethernet180 25000 1 rs
|
||||
Ethernet184 46 Ethernet184 25000 1 rs
|
||||
Ethernet188 47 Ethernet188 25000 1 rs
|
||||
Ethernet192 48,49,50,51 Ethernet192 100000 1 rs
|
||||
Ethernet196 52,53,54,55 Ethernet196 100000 1 rs
|
||||
Ethernet200 56,57,58,59 Ethernet200 100000 1 rs
|
||||
Ethernet204 60,61,62,63 Ethernet204 100000 1 rs
|
||||
Ethernet208 64,65,66,67 Ethernet208 100000 1 rs
|
||||
Ethernet212 68,69,70,71 Ethernet212 100000 1 rs
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
"chip_list": [
|
||||
{
|
||||
"id": "asic-0",
|
||||
"chip_family": "Tofino",
|
||||
"instance": 0,
|
||||
"pcie_sysfs_prefix": "/sys/devices/pci0000:00/0000:00:03.0/0000:05:00.0",
|
||||
"pcie_domain": 0,
|
||||
"pcie_bus": 5,
|
||||
"pcie_fn": 0,
|
||||
"pcie_dev": 0,
|
||||
"pcie_int_mode": 1,
|
||||
"sds_fw_path": "share/tofino_sds_fw/avago/firmware"
|
||||
}
|
||||
],
|
||||
"instance": 0,
|
||||
"p4_program_list": [
|
||||
{
|
||||
"id": "pgm-0",
|
||||
"instance": 0,
|
||||
"path": "switch",
|
||||
"program-name": "switch",
|
||||
"pd": "lib/tofinopd/switch/libpd.so",
|
||||
"pd-thrift": "lib/tofinopd/switch/libpdthrift.so",
|
||||
"table-config": "share/tofinopd/switch/context.json",
|
||||
"tofino-bin": "share/tofinopd/switch/tofino.bin",
|
||||
"switchapi": "lib/libswitchapi.so",
|
||||
"switchsai": "lib/libswitchsai.so",
|
||||
"agent0": "lib/platform/x86_64-wnc_osw1800-r0/libpltfm_mgr.so",
|
||||
"switchapi_port_add": false
|
||||
}
|
||||
]
|
||||
}
|
11
device/wnc/x86_64-wnc_osw1800-r0/fancontrol
Normal file
11
device/wnc/x86_64-wnc_osw1800-r0/fancontrol
Normal file
@ -0,0 +1,11 @@
|
||||
INTERVAL=10
|
||||
DEVPATH=hwmon1=devices/pci0000:00/0000:00:16.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3:1.2/i2c-2/i2c-5/5-0033 hwmon2=devices/pci0000:00/0000:00:16.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3:1.2/i2c-2/i2c-7/7-001e hwmon3=devices/pci0000:00/0000:00:16.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3:1.2/i2c-2/i2c-7/7-004e hwmon4=devices/pci0000:00/0000:00:16.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3:1.2/i2c-2/i2c-7/7-004f
|
||||
DEVNAME=hwmon1=wnc_cpld3 hwmon2=tmp421 hwmon3=tmp75 hwmon4=tmp421
|
||||
FCTEMPS=hwmon1/pwm1=hwmon2/temp1_input hwmon1/pwm2=hwmon2/temp2_input hwmon1/pwm3=hwmon3/temp1_input hwmon1/pwm4=hwmon4/temp1_input hwmon1/pwm5=hwmon4/temp2_input
|
||||
FCFANS=hwmon1/pwm1=hwmon1/fan1_input hwmon1/pwm2=hwmon1/fan2_input hwmon1/pwm3=hwmon1/fan3_input hwmon1/pwm4=hwmon1/fan4_input hwmon1/pwm5=hwmon1/fan5_input
|
||||
MINTEMP=hwmon1/pwm1=20 hwmon1/pwm2=20 hwmon1/pwm3=20 hwmon1/pwm4=20 hwmon1/pwm5=20
|
||||
MAXTEMP=hwmon1/pwm1=50 hwmon1/pwm2=50 hwmon1/pwm3=50 hwmon1/pwm4=50 hwmon1/pwm5=50
|
||||
MINSTART=hwmon1/pwm1=32 hwmon1/pwm2=32 hwmon1/pwm3=32 hwmon1/pwm4=32 hwmon1/pwm5=32
|
||||
MINSTOP=hwmon1/pwm1=22 hwmon1/pwm2=22 hwmon1/pwm3=22 hwmon1/pwm4=22 hwmon1/pwm5=22
|
||||
MINPWM=hwmon1/pwm1=10 hwmon1/pwm2=10 hwmon1/pwm3=10 hwmon1/pwm4=10 hwmon1/pwm5=10
|
||||
MAXPWM=hwmon1/pwm1=100 hwmon1/pwm2=100 hwmon1/pwm3=100 hwmon1/pwm4=100 hwmon1/pwm5=100
|
3
device/wnc/x86_64-wnc_osw1800-r0/installer.conf
Normal file
3
device/wnc/x86_64-wnc_osw1800-r0/installer.conf
Normal file
@ -0,0 +1,3 @@
|
||||
CONSOLE_PORT=0x2f8
|
||||
CONSOLE_DEV=1
|
||||
CONSOLE_SPEED=57600
|
1761
device/wnc/x86_64-wnc_osw1800-r0/minigraph.xml
Normal file
1761
device/wnc/x86_64-wnc_osw1800-r0/minigraph.xml
Normal file
File diff suppressed because it is too large
Load Diff
22
device/wnc/x86_64-wnc_osw1800-r0/plugins/eeprom.py
Normal file
22
device/wnc/x86_64-wnc_osw1800-r0/plugins/eeprom.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
import warnings
|
||||
import os
|
||||
import sys
|
||||
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-8/8-0052/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
64
device/wnc/x86_64-wnc_osw1800-r0/plugins/psuutil.py
Normal file
64
device/wnc/x86_64-wnc_osw1800-r0/plugins/psuutil.py
Normal file
@ -0,0 +1,64 @@
|
||||
#
|
||||
# psuutil.py
|
||||
# Platform-specific PSU status interface for SONiC
|
||||
#
|
||||
|
||||
|
||||
import os.path
|
||||
|
||||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
||||
def __init__(self):
|
||||
PsuBase.__init__(self)
|
||||
|
||||
def get_num_psus(self):
|
||||
return 2
|
||||
|
||||
def get_psu_status(self, index):
|
||||
if index == 1:
|
||||
psu_path = "/sys/bus/i2c/devices/6-0050/eeprom"
|
||||
elif index == 2:
|
||||
psu_path = "/sys/bus/i2c/devices/6-0051/eeprom"
|
||||
else:
|
||||
return False
|
||||
|
||||
try:
|
||||
data = open(psu_path, "rb")
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
result = int(data.read(1).encode("hex"), 16)
|
||||
data.close()
|
||||
|
||||
if result != 255 and result != 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_psu_presence(self, index):
|
||||
if index == 1:
|
||||
psu_path = "/sys/bus/i2c/devices/6-0050/eeprom"
|
||||
elif index == 2:
|
||||
psu_path = "/sys/bus/i2c/devices/6-0051/eeprom"
|
||||
else:
|
||||
return False
|
||||
|
||||
try:
|
||||
data = open(psu_path, "rb")
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
result = int(data.read(1).encode("hex"), 16)
|
||||
data.close()
|
||||
|
||||
if result != 255 and result != 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
205
device/wnc/x86_64-wnc_osw1800-r0/plugins/sfputil.py
Normal file
205
device/wnc/x86_64-wnc_osw1800-r0/plugins/sfputil.py
Normal file
@ -0,0 +1,205 @@
|
||||
#! /usr/bin/python
|
||||
#
|
||||
# Platform-specific SFP transceiver interface for SONiC
|
||||
#
|
||||
|
||||
try:
|
||||
import time
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
import sys
|
||||
sys.path.append('/usr/lib/python2.7/dist-packages/sonic_sfp/')
|
||||
from sff8472 import sff8472InterfaceId
|
||||
from sff8472 import sff8472Dom
|
||||
from sff8436 import sff8436InterfaceId
|
||||
from sff8436 import sff8436Dom
|
||||
except ImportError, e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
PORT_START = 0
|
||||
PORT_END = 53
|
||||
PORTS_IN_BLOCK = 54
|
||||
|
||||
EEPROM_OFFSET = 11
|
||||
|
||||
_port_to_eeprom_mapping = {}
|
||||
|
||||
@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(self.PORT_START + 48, self.PORTS_IN_BLOCK)
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
return self._port_to_eeprom_mapping
|
||||
|
||||
def __init__(self):
|
||||
eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
|
||||
|
||||
for x in range(0, self.port_end + 1):
|
||||
self._port_to_eeprom_mapping[x] = eeprom_path.format(x + self.EEPROM_OFFSET)
|
||||
|
||||
SfpUtilBase.__init__(self)
|
||||
|
||||
def get_presence(self, port_num):
|
||||
bit_mask = port_num % 8
|
||||
|
||||
if port_num <= 7:
|
||||
presence_path = "/sys/bus/i2c/devices/3-0031/sfp_mod_abs1"
|
||||
elif 8 <= port_num and port_num <= 15:
|
||||
presence_path = "/sys/bus/i2c/devices/3-0031/sfp_mod_abs2"
|
||||
elif 16 <= port_num and port_num <= 23:
|
||||
presence_path = "/sys/bus/i2c/devices/3-0031/sfp_mod_abs3"
|
||||
elif 24 <= port_num and port_num <= 27:
|
||||
presence_path = "/sys/bus/i2c/devices/3-0031/sfp_mod_abs4"
|
||||
elif 28 <= port_num and port_num <= 31:
|
||||
presence_path = "/sys/bus/i2c/devices/4-0032/sfp_mod_abs1"
|
||||
bit_mask = bit_mask - 4
|
||||
elif 32 <= port_num and port_num <= 39:
|
||||
presence_path = "/sys/bus/i2c/devices/4-0032/sfp_mod_abs2"
|
||||
elif 40 <= port_num and port_num <= 47:
|
||||
presence_path = "/sys/bus/i2c/devices/4-0032/sfp_mod_abs3"
|
||||
elif 48 <= port_num and port_num <= 71:
|
||||
presence_path = "/sys/bus/i2c/devices/4-0032/qsfp_modprs"
|
||||
else:
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open(presence_path, "rb")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
content = reg_file.readline().rstrip()
|
||||
reg_value = int(content, 16)
|
||||
reg_file.close()
|
||||
|
||||
if reg_value & (1 << bit_mask) == 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_low_power_mode(self, port_num):
|
||||
if port_num in self.qsfp_ports:
|
||||
bit_mask = port_num % 8
|
||||
else:
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/bus/i2c/devices/4-0032/qsfp_lpmode")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
|
||||
content = reg_file.readline().rstrip()
|
||||
reg_value = int(content, 16)
|
||||
reg_file.close()
|
||||
|
||||
if reg_value & (1 << bit_mask) == 0:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def set_low_power_mode(self, port_num, lpmode):
|
||||
if port_num in self.qsfp_ports:
|
||||
bit_mask = port_num % 8
|
||||
else:
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/bus/i2c/devices/4-0032/qsfp_lpmode", "r+")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
content = reg_file.readline().rstrip()
|
||||
reg_value = int(content, 16)
|
||||
|
||||
if lpmode is True:
|
||||
reg_value = reg_value | (1 << bit_mask)
|
||||
else:
|
||||
reg_value = reg_value & ~(1 << bit_mask)
|
||||
|
||||
reg_file.seek(0)
|
||||
reg_file.write(str(reg_value))
|
||||
reg_file.close()
|
||||
|
||||
return True
|
||||
|
||||
def reset(self, port_num):
|
||||
if port_num in self.qsfp_ports:
|
||||
bit_mask = (port_num % 8) + 2
|
||||
else:
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/bus/i2c/devices/4-0032/reset_control", "r+")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
content = reg_file.readline().rstrip()
|
||||
reg_value = int(content, 16)
|
||||
reg_value = reg_value & ~(1 << bit_mask)
|
||||
|
||||
reg_file.seek(0)
|
||||
reg_file.write(str(reg_value))
|
||||
reg_file.close()
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/bus/i2c/devices/4-0032/reset_control", "w")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
reg_value = reg_value | (1 << bit_mask)
|
||||
reg_file.seek(0)
|
||||
reg_file.write(str(reg_value))
|
||||
reg_file.close()
|
||||
|
||||
return True
|
||||
|
||||
def get_eeprom_dict(self, port_num):
|
||||
if not self.get_presence(port_num):
|
||||
return None
|
||||
|
||||
sfp_data = {}
|
||||
|
||||
eeprom_ifraw = self.get_eeprom_raw(port_num)
|
||||
eeprom_domraw = self.get_eeprom_dom_raw(port_num)
|
||||
|
||||
if eeprom_ifraw is None:
|
||||
return None
|
||||
|
||||
if port_num in self.qsfp_ports:
|
||||
sfpi_obj = sff8436InterfaceId(eeprom_ifraw)
|
||||
if sfpi_obj is not None:
|
||||
sfp_data['interface'] = sfpi_obj.get_data_pretty()
|
||||
|
||||
sfpd_obj = sff8436Dom(eeprom_ifraw)
|
||||
if sfpd_obj is not None:
|
||||
sfp_data['dom'] = sfpd_obj.get_data_pretty()
|
||||
return sfp_data
|
||||
|
||||
sfpi_obj = sff8472InterfaceId(eeprom_ifraw)
|
||||
if sfpi_obj is not None:
|
||||
sfp_data['interface'] = sfpi_obj.get_data_pretty()
|
||||
cal_type = sfpi_obj.get_calibration_type()
|
||||
|
||||
if eeprom_domraw is not None:
|
||||
sfpd_obj = sff8472Dom(eeprom_domraw, cal_type)
|
||||
if sfpd_obj is not None:
|
||||
sfp_data['dom'] = sfpd_obj.get_data_pretty()
|
||||
|
||||
return sfp_data
|
33
device/wnc/x86_64-wnc_osw1800-r0/sensors.conf
Normal file
33
device/wnc/x86_64-wnc_osw1800-r0/sensors.conf
Normal file
@ -0,0 +1,33 @@
|
||||
# libsensors configuration filei
|
||||
# --------------------------------------------------
|
||||
#
|
||||
|
||||
bus "i2c-7" "i2c-2-mux"
|
||||
chip "tmp421-i2c-7-1E"
|
||||
label temp1 "ts1"
|
||||
set temp1_max 50
|
||||
set temp1_max_hyst 25
|
||||
label temp2 "ts4"
|
||||
set temp2_max 50
|
||||
set temp2_max_hyst 25
|
||||
|
||||
chip "tmp75-i2c-7-4E"
|
||||
label temp1 "ts3"
|
||||
set temp1_max 50
|
||||
set temp1_max_hyst 25
|
||||
|
||||
chip "tmp421-i2c-7-4F"
|
||||
label temp1 "ts2"
|
||||
set temp1_max 50
|
||||
set temp1_max_hyst 25
|
||||
label temp2 "ts5"
|
||||
set temp2_max 50
|
||||
set temp2_max_hyst 25
|
||||
|
||||
bus "i2c-5" "i2c-2-mux"
|
||||
chip "wnc_cpld3-i2c-5-33"
|
||||
label fan1 "fan1"
|
||||
label fan2 "fan2"
|
||||
label fan3 "fan3"
|
||||
label fan4 "fan4"
|
||||
label fan5 "fan5"
|
1
dockers/docker-orchagent-bfn
Symbolic link
1
dockers/docker-orchagent-bfn
Symbolic link
@ -0,0 +1 @@
|
||||
docker-orchagent
|
@ -20,6 +20,8 @@ elif [ "$platform" == "cavium" ]; then
|
||||
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
||||
elif [ "$platform" == "nephos" ]; then
|
||||
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
||||
elif [ "$platform" == "barefoot" ]; then
|
||||
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
||||
fi
|
||||
|
||||
exec /usr/bin/orchagent ${ORCHAGENT_ARGS}
|
||||
|
@ -27,7 +27,13 @@ fast_reboot
|
||||
|
||||
HWSKU=`sonic-cfggen -d -v "DEVICE_METADATA['localhost']['hwsku']"`
|
||||
|
||||
SWSSCONFIG_ARGS="00-copp.config.json ipinip.json ports.json switch.json "
|
||||
SWSSCONFIG_ARGS="00-copp.config.json "
|
||||
|
||||
if [ "$HWSKU" != "montara" ] && [ "$HWSKU" != "mavericks" ] && [ "$HWSKU" != "OSW1800-48x6q" ] && [ "$HWSKU" != "INGRASYS-S9180-32X"]; then
|
||||
SWSSCONFIG_ARGS+="ipinip.json "
|
||||
fi
|
||||
|
||||
SWSSCONFIG_ARGS+="ports.json switch.json "
|
||||
|
||||
if [ "$HWSKU" == "Force10-S6000" ]; then
|
||||
SWSSCONFIG_ARGS+="td2.32ports.buffers.json td2.32ports.qos.json "
|
||||
|
38
dockers/docker-saiserver-bfn/Dockerfile
Executable file
38
dockers/docker-saiserver-bfn/Dockerfile
Executable file
@ -0,0 +1,38 @@
|
||||
FROM docker-base
|
||||
|
||||
## Make apt-get non-interactive
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
COPY ["deps/applibs_*.deb", "/deps/applibs-dev_*.deb", "/deps/sx-complib_*.deb", "/deps/sxd-libs_*.deb", "/deps/sx-scew_*.deb", "/deps/sx-examples_*.deb", "/deps/sx-gen-utils_*.deb", "/deps/python-sdk-api_*.deb", "/deps/iproute2_*.deb", "/deps/mlnx-sai_*.deb", "/deps/libthrift-0.9.3_*.deb", "/deps/libnl-3-200_*.deb", "/deps/libnl-genl-3-200_*.deb", "/deps/libnl-route-3-200_*.deb", "/deps/"]
|
||||
|
||||
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; \
|
||||
dpkg_apt /deps/applibs_*.deb \
|
||||
&& dpkg_apt /deps/applibs-dev_*.deb \
|
||||
&& dpkg_apt /deps/sx-complib_*.deb \
|
||||
&& dpkg_apt /deps/sxd-libs_*.deb \
|
||||
&& dpkg_apt /deps/sx-scew_*.deb \
|
||||
&& dpkg_apt /deps/sx-examples_*.deb \
|
||||
&& dpkg_apt /deps/sx-gen-utils_*.deb \
|
||||
&& dpkg_apt /deps/python-sdk-api_*.deb \
|
||||
&& dpkg_apt /deps/iproute2_*.deb \
|
||||
&& dpkg_apt /deps/mlnx-sai_*.deb \
|
||||
&& dpkg_apt /deps/libthrift-0.9.3_*.deb \
|
||||
&& dpkg_apt /deps/libnl-3-200_*.deb \
|
||||
&& dpkg_apt /deps/libnl-genl-3-200_*.deb \
|
||||
&& dpkg_apt /deps/libnl-route-3-200_*.deb
|
||||
|
||||
COPY ["deps/saiserver", "start.sh", "/usr/bin/"]
|
||||
|
||||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
||||
|
||||
COPY ["profile.ini", "portmap.ini", "/etc/sai/"]
|
||||
|
||||
|
||||
## Clean up
|
||||
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
|
||||
RUN rm -rf /deps
|
||||
|
||||
ENTRYPOINT ["/usr/bin/supervisord"]
|
||||
|
33
dockers/docker-saiserver-bfn/portmap.ini
Normal file
33
dockers/docker-saiserver-bfn/portmap.ini
Normal file
@ -0,0 +1,33 @@
|
||||
# alias lanes
|
||||
Ethernet1 0,1,2,3
|
||||
Ethernet2 4,5,6,7
|
||||
Ethernet3 8,9,10,11
|
||||
Ethernet4 12,13,14,15
|
||||
Ethernet5 16,17,18,19
|
||||
Ethernet6 20,21,22,23
|
||||
Ethernet7 24,25,26,27
|
||||
Ethernet8 28,29,30,31
|
||||
Ethernet9 32,33,34,35
|
||||
Ethernet10 36,37,38,39
|
||||
Ethernet11 40,41,42,43
|
||||
Ethernet12 44,45,46,47
|
||||
Ethernet13 48,49,50,51
|
||||
Ethernet14 52,53,54,55
|
||||
Ethernet15 56,57,58,59
|
||||
Ethernet16 60,61,62,63
|
||||
Ethernet17 64,65,66,67
|
||||
Ethernet18 68,69,70,71
|
||||
Ethernet19 72,73,74,75
|
||||
Ethernet20 76,77,78,79
|
||||
Ethernet21 80,81,82,83
|
||||
Ethernet22 84,85,86,87
|
||||
Ethernet23 88,89,90,91
|
||||
Ethernet24 92,93,94,95
|
||||
Ethernet25 96,97,98,99
|
||||
Ethernet26 100,101,102,103
|
||||
Ethernet27 104,105,106,107
|
||||
Ethernet28 108,109,110,111
|
||||
Ethernet29 112,113,114,115
|
||||
Ethernet30 116,117,118,119
|
||||
Ethernet31 120,121,122,123
|
||||
Ethernet32 124,125,126,127
|
1
dockers/docker-saiserver-bfn/profile.ini
Normal file
1
dockers/docker-saiserver-bfn/profile.ini
Normal file
@ -0,0 +1 @@
|
||||
SAI_INIT_CONFIG_FILE=/usr/share/sai_tofino.xml
|
2
dockers/docker-saiserver-bfn/sai_tofino.xml
Normal file
2
dockers/docker-saiserver-bfn/sai_tofino.xml
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
|
8
dockers/docker-saiserver-bfn/start.sh
Executable file
8
dockers/docker-saiserver-bfn/start.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
rm -f /var/run/rsyslogd.pid
|
||||
|
||||
supervisorctl start rsyslogd
|
||||
|
||||
supervisorctl start saiserver
|
||||
|
29
dockers/docker-saiserver-bfn/supervisord.conf
Normal file
29
dockers/docker-saiserver-bfn/supervisord.conf
Normal file
@ -0,0 +1,29 @@
|
||||
[supervisord]
|
||||
logfile_maxbytes=1MB
|
||||
logfile_backups=2
|
||||
nodaemon=true
|
||||
|
||||
[program:start.sh]
|
||||
command=/usr/bin/start.sh
|
||||
priority=1
|
||||
autostart=true
|
||||
autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
|
||||
[program:rsyslogd]
|
||||
command=/usr/sbin/rsyslogd -n
|
||||
priority=2
|
||||
autostart=false
|
||||
autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
|
||||
[program:saiserver]
|
||||
command=/usr/bin/saiserver -p /etc/sai/profile.ini -f /etc/sai/portmap.ini
|
||||
priority=3
|
||||
autostart=false
|
||||
autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
|
@ -18,6 +18,10 @@ iface lo {{ 'inet' if prefix | ipv4 else 'inet6' }} static
|
||||
{% endfor %}
|
||||
{% endblock loopback %}
|
||||
{% block mgmt_interface %}
|
||||
# BMC interface
|
||||
auto usb0
|
||||
iface usb0 inet6 auto
|
||||
|
||||
# The management network interface
|
||||
auto eth0
|
||||
{% if MGMT_INTERFACE %}
|
||||
|
5
platform/barefoot/bfn-platform-ingrasys.mk
Normal file
5
platform/barefoot/bfn-platform-ingrasys.mk
Normal file
@ -0,0 +1,5 @@
|
||||
BFN_INGRASYS_PLATFORM = bfnplatform-ingrasys_1.0.0_amd64.deb
|
||||
$(BFN_INGRASYS_PLATFORM)_URL = "https://github.com/Ingrasys-sonic/packages/raw/master/lib/bfnplatform-ingrasys_1.0.0_amd64.deb"
|
||||
|
||||
SONIC_ONLINE_DEBS += $(BFN_INGRASYS_PLATFORM) # $(BFN_SAI_DEV)
|
||||
$(BFN_SAI_DEV)_DEPENDS += $(BFN_INGRASYS_PLATFORM)
|
5
platform/barefoot/bfn-platform-wnc.mk
Normal file
5
platform/barefoot/bfn-platform-wnc.mk
Normal file
@ -0,0 +1,5 @@
|
||||
WNC_OSW1800_PLATFORM = bfnplatformwnc_1.0.0_amd64.deb
|
||||
$(WNC_OSW1800_PLATFORM)_URL = "https://github.com/YaoTien/download/raw/master/sonic/sde/7_0_0_18/bfnplatformwnc_1.0.0_amd64.deb"
|
||||
|
||||
SONIC_ONLINE_DEBS += $(WNC_OSW1800_PLATFORM) # $(BFN_SAI_DEV)
|
||||
$(BFN_SAI_DEV)_DEPENDS += $(WNC_OSW1800_PLATFORM)
|
5
platform/barefoot/bfn-platform.mk
Normal file
5
platform/barefoot/bfn-platform.mk
Normal file
@ -0,0 +1,5 @@
|
||||
BFN_PLATFORM = bfnplatform_1.0.0_amd64.deb
|
||||
$(BFN_PLATFORM)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/rel_7_0/bfnplatform_1.0.0_amd64.deb"
|
||||
|
||||
SONIC_ONLINE_DEBS += $(BFN_PLATFORM) # $(BFN_SAI_DEV)
|
||||
$(BFN_SAI_DEV)_DEPENDS += $(BFN_PLATFORM)
|
6
platform/barefoot/bfn-sai.mk
Normal file
6
platform/barefoot/bfn-sai.mk
Normal file
@ -0,0 +1,6 @@
|
||||
BFN_SAI = bfnsdk_1.0.0_amd64.deb
|
||||
$(BFN_SAI)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/rel_7_0_1/bfnsdk_1.0.0_amd64.deb"
|
||||
|
||||
|
||||
SONIC_ONLINE_DEBS += $(BFN_SAI) # $(BFN_SAI_DEV)
|
||||
$(BFN_SAI_DEV)_DEPENDS += $(BFN_SAI)
|
19
platform/barefoot/docker-orchagent-bfn.mk
Normal file
19
platform/barefoot/docker-orchagent-bfn.mk
Normal file
@ -0,0 +1,19 @@
|
||||
# docker image for orchagent
|
||||
|
||||
DOCKER_ORCHAGENT_BFN = docker-orchagent-bfn.gz
|
||||
$(DOCKER_ORCHAGENT_BFN)_PATH = $(DOCKERS_PATH)/docker-orchagent
|
||||
$(DOCKER_ORCHAGENT_BFN)_DEPENDS += $(SWSS) $(REDIS_TOOLS)
|
||||
$(DOCKER_ORCHAGENT_BFN)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE)
|
||||
SONIC_DOCKER_IMAGES += $(DOCKER_ORCHAGENT_BFN)
|
||||
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ORCHAGENT_BFN)
|
||||
|
||||
$(DOCKER_ORCHAGENT_BFN)_CONTAINER_NAME = swss
|
||||
$(DOCKER_ORCHAGENT_BFN)_RUN_OPT += --net=host --privileged -t
|
||||
$(DOCKER_ORCHAGENT_BFN)_RUN_OPT += -v /etc/network/interfaces:/etc/network/interfaces:ro
|
||||
$(DOCKER_ORCHAGENT_BFN)_RUN_OPT += -v /etc/network/interfaces.d/:/etc/network/interfaces.d/:ro
|
||||
$(DOCKER_ORCHAGENT_BFN)_RUN_OPT += -v /host/machine.conf:/host/machine.conf:ro
|
||||
$(DOCKER_ORCHAGENT_BFN)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
|
||||
$(DOCKER_ORCHAGENT_BFN)_RUN_OPT += -v /var/log/swss:/var/log/swss:rw
|
||||
|
||||
$(DOCKER_ORCHAGENT_BFN)_BASE_IMAGE_FILES += swssloglevel:/usr/bin/swssloglevel
|
||||
$(DOCKER_ORCHAGENT_BFN)_FILES += $(ARP_UPDATE_SCRIPT)
|
5
platform/barefoot/docker-ptf-bfn.mk
Normal file
5
platform/barefoot/docker-ptf-bfn.mk
Normal file
@ -0,0 +1,5 @@
|
||||
# docker image for docker-ptf
|
||||
|
||||
DOCKER_PTF_BFN = docker-ptf-bfn.gz
|
||||
$(DOCKER_PTF_BFN)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift
|
||||
$(DOCKER_PTF_BFN)_LOAD_DOCKERS += $(DOCKER_PTF)
|
15
platform/barefoot/docker-syncd-bfn-rpc.mk
Normal file
15
platform/barefoot/docker-syncd-bfn-rpc.mk
Normal file
@ -0,0 +1,15 @@
|
||||
# docker image for syncd with rpc
|
||||
|
||||
DOCKER_SYNCD_BFN_RPC = docker-syncd-bfn-rpc.gz
|
||||
$(DOCKER_SYNCD_BFN_RPC)_PATH = $(PLATFORM_PATH)/docker-syncd-bfn-rpc
|
||||
$(DOCKER_SYNCD_BFN_RPC)_DEPENDS += $(SYNCD_RPC) $(LIBTHRIFT)
|
||||
$(DOCKER_SYNCD_BFN_RPC)_LOAD_DOCKERS += $(DOCKER_SYNCD_BFN)
|
||||
SONIC_DOCKER_IMAGES += $(DOCKER_SYNCD_BFN_RPC)
|
||||
ifeq ($(ENABLE_SYNCD_RPC),y)
|
||||
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_SYNCD_BFN_RPC)
|
||||
endif
|
||||
|
||||
$(DOCKER_SYNCD_BFN_RPC)_CONTAINER_NAME = syncd
|
||||
$(DOCKER_SYNCD_BFN_RPC)_RUN_OPT += --net=host --privileged -t
|
||||
$(DOCKER_SYNCD_BFN_RPC)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf
|
||||
$(DOCKER_SYNCD_BFN_RPC)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
|
52
platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2
Normal file
52
platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2
Normal file
@ -0,0 +1,52 @@
|
||||
FROM docker-syncd-bfn
|
||||
|
||||
## Make apt-get non-interactive
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
COPY \
|
||||
{% for deb in docker_syncd_bfn_rpc_debs.split(' ') -%}
|
||||
debs/{{ deb }}{{' '}}
|
||||
{%- endfor -%}
|
||||
debs/
|
||||
|
||||
RUN dpkg -P syncd
|
||||
|
||||
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \
|
||||
{% for deb in docker_syncd_bfn_rpc_debs.split(' ') -%}
|
||||
dpkg_apt debs/{{ deb }}{{'; '}}
|
||||
{%- endfor %}
|
||||
|
||||
## Pre-install the fundamental packages
|
||||
RUN apt-get update \
|
||||
&& apt-get -y install \
|
||||
net-tools \
|
||||
python-pip \
|
||||
build-essential \
|
||||
libssl-dev \
|
||||
libffi-dev \
|
||||
python-dev \
|
||||
wget \
|
||||
cmake \
|
||||
&& wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \
|
||||
&& tar xvfz 1.0.0.tar.gz \
|
||||
&& cd nanomsg-1.0.0 \
|
||||
&& mkdir -p build \
|
||||
&& cmake . \
|
||||
&& make install \
|
||||
&& ldconfig \
|
||||
&& cd .. \
|
||||
&& rm -fr nanomsg-1.0.0 \
|
||||
&& rm -f 1.0.0.tar.gz \
|
||||
&& pip install cffi==1.7.0 \
|
||||
&& pip install --upgrade cffi==1.7.0 \
|
||||
&& pip install nnpy \
|
||||
&& mkdir -p /opt \
|
||||
&& cd /opt \
|
||||
&& wget https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py \
|
||||
&& apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y \
|
||||
&& rm -rf /root/deps
|
||||
|
||||
COPY ["ptf_nn_agent.conf", "/etc/supervisor/conf.d/"]
|
||||
|
||||
ENTRYPOINT ["/usr/bin/supervisord"]
|
||||
|
10
platform/barefoot/docker-syncd-bfn-rpc/ptf_nn_agent.conf
Normal file
10
platform/barefoot/docker-syncd-bfn-rpc/ptf_nn_agent.conf
Normal file
@ -0,0 +1,10 @@
|
||||
[program:ptf_nn_agent]
|
||||
command=/usr/bin/python /opt/ptf_nn_agent.py --device-socket 1@tcp://0.0.0.0:10900 -i 1-3@Ethernet12 --set-iface-rcv-buffer=109430400
|
||||
process_name=ptf_nn_agent
|
||||
stdout_logfile=/tmp/ptf_nn_agent.out.log
|
||||
stderr_logfile=/tmp/ptf_nn_agent.err.log
|
||||
redirect_stderr=false
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=1
|
||||
numprocs=1
|
15
platform/barefoot/docker-syncd-bfn.mk
Normal file
15
platform/barefoot/docker-syncd-bfn.mk
Normal file
@ -0,0 +1,15 @@
|
||||
# docker image for syncd
|
||||
|
||||
DOCKER_SYNCD_BFN = docker-syncd-bfn.gz
|
||||
$(DOCKER_SYNCD_BFN)_PATH = $(PLATFORM_PATH)/docker-syncd-bfn
|
||||
$(DOCKER_SYNCD_BFN)_DEPENDS += $(SYNCD)
|
||||
$(DOCKER_SYNCD_BFN)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE)
|
||||
SONIC_DOCKER_IMAGES += $(DOCKER_SYNCD_BFN)
|
||||
ifneq ($(ENABLE_SYNCD_RPC),y)
|
||||
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_SYNCD_BFN)
|
||||
endif
|
||||
|
||||
$(DOCKER_SYNCD_BFN)_CONTAINER_NAME = syncd
|
||||
$(DOCKER_SYNCD_BFN)_RUN_OPT += --net=host --privileged -t
|
||||
$(DOCKER_SYNCD_BFN)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf
|
||||
$(DOCKER_SYNCD_BFN)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
|
29
platform/barefoot/docker-syncd-bfn/Dockerfile.j2
Executable file
29
platform/barefoot/docker-syncd-bfn/Dockerfile.j2
Executable file
@ -0,0 +1,29 @@
|
||||
FROM docker-config-engine
|
||||
|
||||
## Make apt-get non-interactive
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
COPY \
|
||||
{% for deb in docker_syncd_bfn_debs.split(' ') -%}
|
||||
debs/{{ deb }}{{' '}}
|
||||
{%- endfor -%}
|
||||
debs/
|
||||
|
||||
RUN apt-get install -y libxml2 libpcap-dev libusb-1.0-0-dev libcurl3 libcurl4-gnutls-dev libunwind8-dev
|
||||
|
||||
RUN dpkg -i \
|
||||
{% for deb in docker_syncd_bfn_debs.split(' ') -%}
|
||||
debs/{{ deb }}{{' '}}
|
||||
{%- endfor %}
|
||||
|
||||
COPY ["start.sh", "/usr/bin/"]
|
||||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
||||
|
||||
## Clean up
|
||||
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
|
||||
RUN rm -rf /debs
|
||||
|
||||
ENTRYPOINT ["/usr/bin/supervisord"]
|
||||
|
9
platform/barefoot/docker-syncd-bfn/start.sh
Executable file
9
platform/barefoot/docker-syncd-bfn/start.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
rm -f /var/run/rsyslogd.pid
|
||||
|
||||
supervisorctl start rsyslogd
|
||||
|
||||
. /opt/bfn/install/bin/dma_setup.sh
|
||||
# . /opt/bfn/install/bin/bf_kdrv_mod_load /opt/bfn/install
|
||||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/bfn/install/lib supervisorctl start syncd
|
29
platform/barefoot/docker-syncd-bfn/supervisord.conf
Normal file
29
platform/barefoot/docker-syncd-bfn/supervisord.conf
Normal file
@ -0,0 +1,29 @@
|
||||
[supervisord]
|
||||
logfile_maxbytes=1MB
|
||||
logfile_backups=2
|
||||
nodaemon=true
|
||||
|
||||
[program:start.sh]
|
||||
command=/usr/bin/start.sh
|
||||
priority=1
|
||||
autostart=true
|
||||
autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
|
||||
[program:rsyslogd]
|
||||
command=/usr/sbin/rsyslogd -n
|
||||
priority=2
|
||||
autostart=false
|
||||
autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
|
||||
[program:syncd]
|
||||
command=/usr/bin/syncd_start.sh
|
||||
priority=3
|
||||
autostart=false
|
||||
autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
|
7
platform/barefoot/libsaithrift-dev.mk
Normal file
7
platform/barefoot/libsaithrift-dev.mk
Normal file
@ -0,0 +1,7 @@
|
||||
# libsaithrift-dev package
|
||||
|
||||
LIBSAITHRIFT_DEV_BFN = libsaithrift-dev_0.9.4_amd64.deb
|
||||
$(LIBSAITHRIFT_DEV_BFN)_SRC_PATH = $(SRC_PATH)/SAI
|
||||
$(LIBSAITHRIFT_DEV_BFN)_DEPENDS += $(LIBTHRIFT) $(LIBTHRIFT_DEV) $(THRIFT_COMPILER) $(BFN_SAI) $(BFN_SAI_DEV)
|
||||
$(LIBSAITHRIFT_DEV_BFN)_RDEPENDS += $(LIBTHRIFT) $(BFN_SAI)
|
||||
#SONIC_DPKG_DEBS += $(LIBSAITHRIFT_DEV_BFN)
|
11
platform/barefoot/one-image.mk
Normal file
11
platform/barefoot/one-image.mk
Normal file
@ -0,0 +1,11 @@
|
||||
# sonic one image installer
|
||||
|
||||
SONIC_ONE_IMAGE = sonic-barefoot.bin
|
||||
$(SONIC_ONE_IMAGE)_MACHINE = barefoot
|
||||
$(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie
|
||||
$(SONIC_ONE_IMAGE)_INSTALLS += $(BFN_PLATFORM_MODULE)
|
||||
$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(BFN_MONTARA_PLATFORM_MODULE)
|
||||
$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(WNC_OSW1800_PLATFORM_MODULE)
|
||||
$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(INGRASYS_S9180_32X_PLATFORM_MODULE)
|
||||
$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES)
|
||||
SONIC_INSTALLERS += $(SONIC_ONE_IMAGE)
|
11
platform/barefoot/platform-modules-bfn-montara.mk
Normal file
11
platform/barefoot/platform-modules-bfn-montara.mk
Normal file
@ -0,0 +1,11 @@
|
||||
# BFN Platform modules
|
||||
|
||||
BFN_MONTARA_PLATFORM_MODULE_VERSION = 1.0
|
||||
|
||||
export BFN_MONTARA_PLATFORM_MODULE_VERSION
|
||||
|
||||
BFN_MONTARA_PLATFORM_MODULE = platform-modules-bfn-montara_$(BFN_MONTARA_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
$(BFN_MONTARA_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-bfn-montara
|
||||
$(BFN_MONTARA_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
|
||||
$(BFN_MONTARA_PLATFORM_MODULE)_PLATFORM = x86_64-accton_wedge100bf_32x-r0
|
||||
SONIC_DPKG_DEBS += $(BFN_MONTARA_PLATFORM_MODULE)
|
11
platform/barefoot/platform-modules-bfn.mk
Normal file
11
platform/barefoot/platform-modules-bfn.mk
Normal file
@ -0,0 +1,11 @@
|
||||
# BFN Platform modules
|
||||
|
||||
BFN_PLATFORM_MODULE_VERSION = 1.0
|
||||
|
||||
export BFN_PLATFORM_MODULE_VERSION
|
||||
|
||||
BFN_PLATFORM_MODULE = platform-modules-bfn_$(BFN_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
$(BFN_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-bfn
|
||||
$(BFN_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
|
||||
$(BFN_PLATFORM_MODULE)_PLATFORM = x86_64-accton_wedge100bf_65x-r0
|
||||
SONIC_DPKG_DEBS += $(BFN_PLATFORM_MODULE)
|
11
platform/barefoot/platform-modules-ingrasys.mk
Normal file
11
platform/barefoot/platform-modules-ingrasys.mk
Normal file
@ -0,0 +1,11 @@
|
||||
# Ingrasys S9180-32X Platform modules
|
||||
|
||||
INGRASYS_S9180_32X_PLATFORM_MODULE_VERSION = 1.1.0
|
||||
|
||||
export INGRASYS_S9180_32X_PLATFORM_MODULE_VERSION
|
||||
|
||||
INGRASYS_S9180_32X_PLATFORM_MODULE = sonic-platform-ingrasys-s9180-32x_$(INGRASYS_S9180_32X_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
$(INGRASYS_S9180_32X_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-ingrasys
|
||||
$(INGRASYS_S9180_32X_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
|
||||
$(INGRASYS_S9180_32X_PLATFORM_MODULE)_PLATFORM = x86_64-ingrasys_s9180_32x-r0
|
||||
SONIC_DPKG_DEBS += $(INGRASYS_S9180_32X_PLATFORM_MODULE)
|
11
platform/barefoot/platform-modules-wnc-osw1800.mk
Normal file
11
platform/barefoot/platform-modules-wnc-osw1800.mk
Normal file
@ -0,0 +1,11 @@
|
||||
# BFN Platform modules
|
||||
|
||||
WNC_OSW1800_PLATFORM_MODULE_VERSION = 1.0
|
||||
|
||||
export WNC_OSW1800_PLATFORM_MODULE_VERSION
|
||||
|
||||
WNC_OSW1800_PLATFORM_MODULE = platform-modules-wnc-osw1800_$(WNC_OSW1800_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
$(WNC_OSW1800_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-wnc-osw1800
|
||||
$(WNC_OSW1800_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
|
||||
$(WNC_OSW1800_PLATFORM_MODULE)_PLATFORM = x86_64-wnc_osw1800-r0
|
||||
SONIC_DPKG_DEBS += $(WNC_OSW1800_PLATFORM_MODULE)
|
0
platform/barefoot/platform.conf
Normal file
0
platform/barefoot/platform.conf
Normal file
6
platform/barefoot/python-saithrift.mk
Normal file
6
platform/barefoot/python-saithrift.mk
Normal file
@ -0,0 +1,6 @@
|
||||
# python-saithrift package
|
||||
|
||||
PYTHON_SAITHRIFT_BFN = python-saithrift_0.9.4_amd64.deb
|
||||
$(PYTHON_SAITHRIFT_BFN)_SRC_PATH = $(SRC_PATH)/SAI
|
||||
$(PYTHON_SAITHRIFT_BFN)_DEPENDS += $(BFN_SAI_DEV) $(BFN_SAI) $(THRIFT_COMPILER) $(PYTHON_THRIFT) $(LIBTHRIFT_DEV)
|
||||
#SONIC_DPKG_DEBS += $(PYTHON_SAITHRIFT_BFN)
|
23
platform/barefoot/rules.mk
Normal file
23
platform/barefoot/rules.mk
Normal file
@ -0,0 +1,23 @@
|
||||
include $(PLATFORM_PATH)/platform-modules-bfn.mk
|
||||
include $(PLATFORM_PATH)/platform-modules-bfn-montara.mk
|
||||
include $(PLATFORM_PATH)/platform-modules-wnc-osw1800.mk
|
||||
include $(PLATFORM_PATH)/platform-modules-ingrasys.mk
|
||||
include $(PLATFORM_PATH)/bfn-sai.mk
|
||||
include $(PLATFORM_PATH)/docker-syncd-bfn.mk
|
||||
include $(PLATFORM_PATH)/docker-syncd-bfn-rpc.mk
|
||||
include $(PLATFORM_PATH)/docker-orchagent-bfn.mk
|
||||
include $(PLATFORM_PATH)/one-image.mk
|
||||
include $(PLATFORM_PATH)/libsaithrift-dev.mk
|
||||
include $(PLATFORM_PATH)/python-saithrift.mk
|
||||
include $(PLATFORM_PATH)/docker-ptf-bfn.mk
|
||||
include $(PLATFORM_PATH)/bfn-platform.mk
|
||||
include $(PLATFORM_PATH)/bfn-platform-wnc.mk
|
||||
include $(PLATFORM_PATH)/bfn-platform-ingrasys.mk
|
||||
SONIC_ALL += $(SONIC_ONE_IMAGE) \
|
||||
$(DOCKER_FPM)
|
||||
|
||||
# Inject sai into sairedis
|
||||
$(LIBSAIREDIS)_DEPENDS += $(BFN_SAI) $(WNC_OSW1800_PLATFORM) $(BFN_INGRASYS_PLATFORM) $(BFN_PLATFORM) #$(LIBSAITHRIFT_DEV_BFN)
|
||||
|
||||
# Runtime dependency on sai is set only for syncd
|
||||
$(SYNCD)_RDEPENDS += $(BFN_SAI) $(WNC_OSW1800_PLATFORM) $(BFN_INGRASYS_PLATFORM) $(BFN_PLATFORM)
|
15
platform/barefoot/sonic-platform-modules-bfn-montara/LICENSE
Normal file
15
platform/barefoot/sonic-platform-modules-bfn-montara/LICENSE
Normal file
@ -0,0 +1,15 @@
|
||||
Copyright (C) 2016 Microsoft, 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.
|
@ -0,0 +1,3 @@
|
||||
# This file describes the maintainers for sonic-platform-modules-bfn
|
||||
# See the SONiC project governance document for more information
|
||||
Mailinglist = sonicproject@googlegroups.com
|
@ -0,0 +1,2 @@
|
||||
# sonic-platform-modules-bfn
|
||||
Device drivers for support of BFN platform for the SONiC project
|
@ -0,0 +1,5 @@
|
||||
platform-modules-bfn-montara (1.0) unstable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
||||
-- Support <support@edge-core.com> Mon, 11 Nov 2015 11:11:11 -0800
|
@ -0,0 +1 @@
|
||||
8
|
@ -0,0 +1,12 @@
|
||||
Source: platform-modules-bfn-montara
|
||||
Section: main
|
||||
Priority: extra
|
||||
Maintainer: Support <support@edge-core.com>
|
||||
Build-Depends: debhelper (>= 8.0.0), bzip2
|
||||
Standards-Version: 3.9.3
|
||||
|
||||
Package: platform-modules-bfn-montara
|
||||
Architecture: amd64
|
||||
Depends: linux-image-3.16.0-4-amd64
|
||||
Description: kernel modules for platform devices such as fan, led, sfp
|
||||
|
@ -0,0 +1,15 @@
|
||||
Provides linux kernel driver for BF PCIe devices
|
||||
|
||||
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.
|
32
platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules
Executable file
32
platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
export INSTALL_MOD_DIR:=extra
|
||||
|
||||
PACKAGE_NAME := platform-modules-bfn-montara
|
||||
KVERSION ?= $(shell uname -r)
|
||||
KERNEL_SRC := /lib/modules/$(KVERSION)
|
||||
MODULE_SRC := $(shell pwd)/modules
|
||||
SCRIPT_SRC := $(shell pwd)/scripts
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_auto_build:
|
||||
make -C $(KERNEL_SRC)/build M=$(MODULE_SRC)
|
||||
|
||||
override_dh_auto_install:
|
||||
dh_installdirs -p$(PACKAGE_NAME) $(KERNEL_SRC)/$(INSTALL_MOD_DIR)
|
||||
cp $(MODULE_SRC)/*.ko debian/$(PACKAGE_NAME)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR)
|
||||
dh_installdirs -p$(PACKAGE_NAME) usr/local/bin
|
||||
cp -r $(SCRIPT_SRC)/* debian/$(PACKAGE_NAME)/usr/local/bin
|
||||
|
||||
override_dh_usrlocal:
|
||||
|
||||
override_dh_pysupport:
|
||||
|
||||
override_dh_clean:
|
||||
dh_clean
|
||||
rm -f $(MODULE_SRC)/*.o $(MODULE_SRC)/*.ko $(MODULE_SRC)/*.mod.c $(MODULE_SRC)/.*.cmd
|
||||
rm -f $(MODULE_SRC)/Module.markers $(MODULE_SRC)/Module.symvers $(MODULE_SRC)/modules.order
|
||||
rm -rf $(MODULE_SRC)/.tmp_versions
|
||||
|
@ -0,0 +1 @@
|
||||
../../sonic-platform-modules-bfn/modules/Makefile
|
@ -0,0 +1 @@
|
||||
../../sonic-platform-modules-bfn/modules/bf_kdrv.c
|
@ -0,0 +1 @@
|
||||
../../sonic-platform-modules-bfn/modules/bf_tun.c
|
1
platform/barefoot/sonic-platform-modules-bfn-montara/scripts/test
Executable file
1
platform/barefoot/sonic-platform-modules-bfn-montara/scripts/test
Executable file
@ -0,0 +1 @@
|
||||
echo "test"
|
15
platform/barefoot/sonic-platform-modules-bfn/LICENSE
Normal file
15
platform/barefoot/sonic-platform-modules-bfn/LICENSE
Normal file
@ -0,0 +1,15 @@
|
||||
Copyright (C) 2016 Microsoft, 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.
|
4
platform/barefoot/sonic-platform-modules-bfn/MAINTAINERS
Normal file
4
platform/barefoot/sonic-platform-modules-bfn/MAINTAINERS
Normal file
@ -0,0 +1,4 @@
|
||||
# This file describes the maintainers for sonic-platform-modules-bfn
|
||||
# See the SONiC project governance document for more information
|
||||
|
||||
Mailinglist = sonicproject@googlegroups.com
|
2
platform/barefoot/sonic-platform-modules-bfn/README.md
Normal file
2
platform/barefoot/sonic-platform-modules-bfn/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# sonic-platform-modules-bfn
|
||||
Device drivers for support of BFN platform for the SONiC project
|
@ -0,0 +1,5 @@
|
||||
platform-modules-bfn (1.0) unstable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
||||
-- Support <support@edge-core.com> Mon, 11 Nov 2015 11:11:11 -0800
|
@ -0,0 +1 @@
|
||||
8
|
12
platform/barefoot/sonic-platform-modules-bfn/debian/control
Normal file
12
platform/barefoot/sonic-platform-modules-bfn/debian/control
Normal file
@ -0,0 +1,12 @@
|
||||
Source: platform-modules-bfn
|
||||
Section: main
|
||||
Priority: extra
|
||||
Maintainer: support <support@edge-core.com>
|
||||
Build-Depends: debhelper (>= 8.0.0), bzip2
|
||||
Standards-Version: 3.9.3
|
||||
|
||||
Package: platform-modules-bfn
|
||||
Architecture: amd64
|
||||
Depends: linux-image-3.16.0-4-amd64
|
||||
Description: kernel modules for platform devices such as fan, led, sfp
|
||||
|
@ -0,0 +1,15 @@
|
||||
Provides linux kernel driver for BF PCIe devices
|
||||
|
||||
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.
|
@ -0,0 +1 @@
|
||||
platform-modules-bfn_1.0_amd64.deb main extra
|
32
platform/barefoot/sonic-platform-modules-bfn/debian/rules
Executable file
32
platform/barefoot/sonic-platform-modules-bfn/debian/rules
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
export INSTALL_MOD_DIR:=extra
|
||||
|
||||
PACKAGE_NAME := platform-modules-bfn
|
||||
KVERSION ?= $(shell uname -r)
|
||||
KERNEL_SRC := /lib/modules/$(KVERSION)
|
||||
MODULE_SRC := $(shell pwd)/modules
|
||||
SCRIPT_SRC := $(shell pwd)/scripts
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_auto_build:
|
||||
make -C $(KERNEL_SRC)/build M=$(MODULE_SRC)
|
||||
|
||||
override_dh_auto_install:
|
||||
dh_installdirs -p$(PACKAGE_NAME) $(KERNEL_SRC)/$(INSTALL_MOD_DIR)
|
||||
cp $(MODULE_SRC)/*.ko debian/$(PACKAGE_NAME)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR)
|
||||
dh_installdirs -p$(PACKAGE_NAME) usr/local/bin
|
||||
cp -r $(SCRIPT_SRC)/* debian/$(PACKAGE_NAME)/usr/local/bin
|
||||
|
||||
override_dh_usrlocal:
|
||||
|
||||
override_dh_pysupport:
|
||||
|
||||
override_dh_clean:
|
||||
dh_clean
|
||||
rm -f $(MODULE_SRC)/*.o $(MODULE_SRC)/*.ko $(MODULE_SRC)/*.mod.c $(MODULE_SRC)/.*.cmd
|
||||
rm -f $(MODULE_SRC)/Module.markers $(MODULE_SRC)/Module.symvers $(MODULE_SRC)/modules.order
|
||||
rm -rf $(MODULE_SRC)/.tmp_versions
|
||||
|
@ -0,0 +1,2 @@
|
||||
obj-m := bf_kdrv.o
|
||||
obj-m += bf_tun.o
|
1254
platform/barefoot/sonic-platform-modules-bfn/modules/bf_kdrv.c
Normal file
1254
platform/barefoot/sonic-platform-modules-bfn/modules/bf_kdrv.c
Normal file
File diff suppressed because it is too large
Load Diff
2396
platform/barefoot/sonic-platform-modules-bfn/modules/bf_tun.c
Normal file
2396
platform/barefoot/sonic-platform-modules-bfn/modules/bf_tun.c
Normal file
File diff suppressed because it is too large
Load Diff
1
platform/barefoot/sonic-platform-modules-bfn/scripts/test
Executable file
1
platform/barefoot/sonic-platform-modules-bfn/scripts/test
Executable file
@ -0,0 +1 @@
|
||||
echo "test"
|
@ -0,0 +1 @@
|
||||
Subproject commit c165fddbb8da8bb11efc3c6952cb98949f2cdc87
|
15
platform/barefoot/sonic-platform-modules-wnc-osw1800/LICENSE
Normal file
15
platform/barefoot/sonic-platform-modules-wnc-osw1800/LICENSE
Normal file
@ -0,0 +1,15 @@
|
||||
Copyright (C) 2016 Microsoft, 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.
|
@ -0,0 +1,7 @@
|
||||
# This file describes the maintainers for sonic-platform-modules-wnc-osw1800
|
||||
# See the SONiC project governance document for more information
|
||||
|
||||
Name = "WNC"
|
||||
Email = "wnc@wnc.com.tw"
|
||||
Github = barefootnetworks
|
||||
Mailinglist = wnc@wnc.com.tw
|
@ -0,0 +1,2 @@
|
||||
# sonic-platform-modules-wnc-osw1800
|
||||
Device drivers for support of BFN platform for the SONiC project
|
@ -0,0 +1,5 @@
|
||||
platform-modules-wnc-osw1800 (1.0) unstable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
||||
-- WNC <wnc@wnc.com.tw> Mon, 11 Nov 2015 11:11:11 -0800
|
@ -0,0 +1 @@
|
||||
8
|
@ -0,0 +1,12 @@
|
||||
Source: platform-modules-wnc-osw1800
|
||||
Section: main
|
||||
Priority: extra
|
||||
Maintainer: WNC <wnc@wnc.com.tw>
|
||||
Build-Depends: debhelper (>= 8.0.0), bzip2
|
||||
Standards-Version: 3.9.3
|
||||
|
||||
Package: platform-modules-wnc-osw1800
|
||||
Architecture: amd64
|
||||
Depends: linux-image-3.16.0-4-amd64
|
||||
Description: kernel modules for platform devices such as fan, led, sfp
|
||||
|
@ -0,0 +1,15 @@
|
||||
Provides linux kernel driver for BF PCIe devices
|
||||
|
||||
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.
|
38
platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/rules
Executable file
38
platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/rules
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
export INSTALL_MOD_DIR:=extra
|
||||
|
||||
PACKAGE_NAME := platform-modules-wnc-osw1800
|
||||
KVERSION ?= $(shell uname -r)
|
||||
KERNEL_SRC := /lib/modules/$(KVERSION)
|
||||
MODULE_SRC := $(shell pwd)/modules
|
||||
SCRIPT_SRC := $(shell pwd)/scripts
|
||||
SERVICE_SRC := $(shell pwd)/service
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_auto_build:
|
||||
make -C $(KERNEL_SRC)/build M=$(MODULE_SRC)
|
||||
|
||||
override_dh_auto_install:
|
||||
dh_installdirs -p$(PACKAGE_NAME) $(KERNEL_SRC)/$(INSTALL_MOD_DIR)
|
||||
cp $(MODULE_SRC)/*.ko debian/$(PACKAGE_NAME)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR)
|
||||
dh_installdirs -p$(PACKAGE_NAME) usr/local/bin
|
||||
cp -r $(SCRIPT_SRC)/* debian/$(PACKAGE_NAME)/usr/local/bin
|
||||
dh_installdirs -p$(PACKAGE_NAME) /etc/systemd/system
|
||||
cp -r $(SERVICE_SRC)/* debian/$(PACKAGE_NAME)/etc/systemd/system
|
||||
dh_installdirs -p$(PACKAGE_NAME) /etc/systemd/system/multi-user.target.wants
|
||||
ln -s ../device_node.service debian/$(PACKAGE_NAME)/etc/systemd/system/multi-user.target.wants/device_node.service
|
||||
ln -s ../driver_load.service debian/$(PACKAGE_NAME)/etc/systemd/system/multi-user.target.wants/driver_load.service
|
||||
|
||||
override_dh_usrlocal:
|
||||
|
||||
override_dh_pysupport:
|
||||
|
||||
override_dh_clean:
|
||||
dh_clean
|
||||
rm -f $(MODULE_SRC)/*.o $(MODULE_SRC)/*.ko $(MODULE_SRC)/*.mod.c $(MODULE_SRC)/.*.cmd
|
||||
rm -f $(MODULE_SRC)/Module.markers $(MODULE_SRC)/Module.symvers $(MODULE_SRC)/modules.order
|
||||
rm -rf $(MODULE_SRC)/.tmp_versions
|
||||
|
@ -0,0 +1,6 @@
|
||||
obj-m := bf_kdrv.o
|
||||
obj-m += bf_tun.o
|
||||
obj-m += i2c-mcp2221.o
|
||||
obj-m += wnc_cpld.o
|
||||
obj-m += wnc_cpld3.o
|
||||
obj-m += wnc_eeprom.o
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,611 @@
|
||||
/*
|
||||
* i2c bus driver for MCP2221
|
||||
*
|
||||
* Derived from:
|
||||
* i2c-tiny-usb.c
|
||||
* i2c-diolan-u2c.c
|
||||
* usb-serial.c
|
||||
* onetouch.c
|
||||
* usb-skeleton.c
|
||||
*
|
||||
* Copyright (C) 2014 Microchip Technology Inc.
|
||||
*
|
||||
* Author: Bogdan Bolocan http://www.microchip.com/support
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/usb.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define DRIVER_NAME "i2c-mcp2221"
|
||||
|
||||
#define USB_VENDOR_ID_MCP2221 0x04d8
|
||||
#define USB_DEVICE_ID_MCP2221 0x00dd
|
||||
|
||||
#define MCP2221_OUTBUF_LEN 64 /* USB write packet length */
|
||||
#define MCP2221_INBUF_LEN 64 /* USB read packet length */
|
||||
|
||||
#define MCP2221_MAX_I2C_DATA_LEN 60
|
||||
|
||||
//#define MCP2221_FREQ_STD 100000
|
||||
#define MCP2221_FREQ_STD 400000
|
||||
//#define MCP2221_FREQ_STD 50000
|
||||
#define MCP2221_FREQ_MAX 500000
|
||||
|
||||
#define MCP2221_RETRY_MAX 50
|
||||
#define MCP2221_STD_DELAY_MS 1
|
||||
//#define MCP2221_STD_DELAY_MS 2
|
||||
|
||||
#define RESP_ERR_NOERR 0x00
|
||||
#define RESP_ADDR_NACK 0x25
|
||||
#define RESP_READ_ERR 0x7F
|
||||
#define RESP_READ_COMPL 0x55
|
||||
#define RESP_I2C_IDLE 0x00
|
||||
#define RESP_I2C_START_TOUT 0x12
|
||||
#define RESP_I2C_RSTART_TOUT 0x17
|
||||
#define RESP_I2C_WRADDRL_TOUT 0x23
|
||||
#define RESP_I2C_WRADDRL_WSEND 0x21
|
||||
#define RESP_I2C_WRADDRL_NACK 0x25
|
||||
#define RESP_I2C_WRDATA_TOUT 0x44
|
||||
#define RESP_I2C_RDDATA_TOUT 0x52
|
||||
#define RESP_I2C_STOP_TOUT 0x62
|
||||
|
||||
#define CMD_MCP2221_STATUS 0x10
|
||||
#define SUBCMD_STATUS_CANCEL 0x10
|
||||
#define SUBCMD_STATUS_SPEED 0x20
|
||||
#define MASK_ADDR_NACK 0x40
|
||||
|
||||
#define CMD_MCP2221_RDDATA7 0x91
|
||||
#define CMD_MCP2221_GET_RDDATA 0x40
|
||||
|
||||
#define CMD_MCP2221_WRDATA7 0x90
|
||||
|
||||
/* Structure to hold all of our device specific stuff */
|
||||
struct i2c_mcp2221 {
|
||||
u8 obuffer[MCP2221_OUTBUF_LEN]; /* USB write buffer */
|
||||
u8 ibuffer[MCP2221_INBUF_LEN]; /* USB read buffer */
|
||||
/* I2C/SMBus data buffer */
|
||||
u8 user_data_buffer[MCP2221_MAX_I2C_DATA_LEN];
|
||||
int ep_in, ep_out; /* Endpoints */
|
||||
struct usb_device *usb_dev; /* the usb device for this device */
|
||||
struct usb_interface *interface;/* the interface for this device */
|
||||
struct i2c_adapter adapter; /* i2c related things */
|
||||
uint frequency; /* I2C/SMBus communication frequency */
|
||||
/* Mutex for low-level USB transactions */
|
||||
struct mutex mcp2221_usb_op_lock;
|
||||
/* wq to wait for an ongoing read/write */
|
||||
wait_queue_head_t usb_urb_completion_wait;
|
||||
bool ongoing_usb_ll_op; /* a ll is in progress */
|
||||
|
||||
struct urb *interrupt_in_urb;
|
||||
struct urb *interrupt_out_urb;
|
||||
};
|
||||
|
||||
static uint frequency = MCP2221_FREQ_STD; /* I2C clock frequency in Hz */
|
||||
|
||||
module_param(frequency, uint, S_IRUGO | S_IWUSR);
|
||||
MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
|
||||
|
||||
/* usb layer */
|
||||
|
||||
|
||||
/*
|
||||
* Return list of supported functionality.
|
||||
*/
|
||||
static u32 mcp2221_usb_func(struct i2c_adapter *a)
|
||||
{
|
||||
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
|
||||
I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL;
|
||||
}
|
||||
|
||||
static void mcp2221_usb_cmpl_cbk(struct urb *urb)
|
||||
{
|
||||
struct i2c_mcp2221 *dev = urb->context;
|
||||
int status = urb->status;
|
||||
int retval;
|
||||
|
||||
switch (status) {
|
||||
case 0: /* success */
|
||||
break;
|
||||
case -ECONNRESET: /* unlink */
|
||||
case -ENOENT:
|
||||
case -ESHUTDOWN:
|
||||
return;
|
||||
/* -EPIPE: should clear the halt */
|
||||
default: /* error */
|
||||
goto resubmit;
|
||||
}
|
||||
|
||||
/* wake up the waitting function
|
||||
modify the flag indicating the ll status */
|
||||
dev->ongoing_usb_ll_op = 0;
|
||||
wake_up_interruptible(&dev->usb_urb_completion_wait);
|
||||
return;
|
||||
|
||||
resubmit:
|
||||
retval = usb_submit_urb(urb, GFP_ATOMIC);
|
||||
if (retval) {
|
||||
dev_err(&dev->interface->dev,
|
||||
"mcp2221(irq): can't resubmit intrerrupt urb, retval %d\n",
|
||||
retval);
|
||||
}
|
||||
}
|
||||
|
||||
static int mcp2221_ll_cmd(struct i2c_mcp2221 *dev)
|
||||
{
|
||||
int rv;
|
||||
|
||||
/* tell everybody to leave the URB alone */
|
||||
dev->ongoing_usb_ll_op = 1;
|
||||
|
||||
/* submit the interrupt out ep packet */
|
||||
if (usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL)) {
|
||||
dev_err(&dev->interface->dev,
|
||||
"mcp2221(ll): usb_submit_urb intr out failed\n");
|
||||
dev->ongoing_usb_ll_op = 0;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* wait for its completion */
|
||||
rv = wait_event_interruptible(dev->usb_urb_completion_wait,
|
||||
(!dev->ongoing_usb_ll_op));
|
||||
if (rv < 0) {
|
||||
dev_err(&dev->interface->dev, "mcp2221(ll): wait interrupted\n");
|
||||
goto ll_exit_clear_flag;
|
||||
}
|
||||
|
||||
/* tell everybody to leave the URB alone */
|
||||
dev->ongoing_usb_ll_op = 1;
|
||||
|
||||
/* submit the interrupt in ep packet */
|
||||
if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL)) {
|
||||
dev_err(&dev->interface->dev, "mcp2221(ll): usb_submit_urb intr in failed\n");
|
||||
dev->ongoing_usb_ll_op = 0;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* wait for its completion */
|
||||
rv = wait_event_interruptible(dev->usb_urb_completion_wait,
|
||||
(!dev->ongoing_usb_ll_op));
|
||||
if (rv < 0) {
|
||||
dev_err(&dev->interface->dev, "mcp2221(ll): wait interrupted\n");
|
||||
goto ll_exit_clear_flag;
|
||||
}
|
||||
|
||||
ll_exit_clear_flag:
|
||||
dev->ongoing_usb_ll_op = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int mcp2221_init(struct i2c_mcp2221 *dev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = 0;
|
||||
if (frequency > MCP2221_FREQ_MAX)
|
||||
frequency = MCP2221_FREQ_MAX;
|
||||
|
||||
/* initialize the MCP2221 and bring it to "idle/ready" state */
|
||||
dev_info(&dev->interface->dev,
|
||||
"MCP2221 at USB bus %03d address %03d Freq=%dKhz-- mcp2221_init()\n",
|
||||
dev->usb_dev->bus->busnum, dev->usb_dev->devnum, frequency/1000);
|
||||
|
||||
/* initialize unlocked mutex */
|
||||
mutex_init(&dev->mcp2221_usb_op_lock);
|
||||
|
||||
dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||
if (!dev->interrupt_out_urb)
|
||||
goto init_error;
|
||||
|
||||
usb_fill_int_urb(dev->interrupt_out_urb, dev->usb_dev,
|
||||
usb_sndintpipe(dev->usb_dev,
|
||||
dev->ep_out),
|
||||
(void *)&dev->obuffer, MCP2221_OUTBUF_LEN,
|
||||
mcp2221_usb_cmpl_cbk, dev,
|
||||
1);
|
||||
|
||||
dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||
if (!dev->interrupt_in_urb)
|
||||
goto init_error;
|
||||
|
||||
usb_fill_int_urb(dev->interrupt_in_urb, dev->usb_dev,
|
||||
usb_rcvintpipe(dev->usb_dev,
|
||||
dev->ep_in),
|
||||
(void *)&dev->ibuffer, MCP2221_INBUF_LEN,
|
||||
mcp2221_usb_cmpl_cbk, dev,
|
||||
1);
|
||||
ret = 0;
|
||||
goto init_no_error;
|
||||
|
||||
init_error:
|
||||
dev_err(&dev->interface->dev, "mcp2221_init: Error = %d\n", ret);
|
||||
ret = -ENODEV;
|
||||
|
||||
init_no_error:
|
||||
dev_info(&dev->interface->dev, "mcp2221_init: Success\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mcp2221_i2c_readwrite(struct i2c_mcp2221 *dev,
|
||||
struct i2c_msg *pmsg)
|
||||
{
|
||||
u8 ucI2cDiv, ucCancelXfer, ucXferLen;
|
||||
int rv, retries;
|
||||
unsigned int sleepCmd;
|
||||
u8 *pSrc, *pDst, usbCmdStatus;
|
||||
|
||||
retries = 0;
|
||||
ucCancelXfer = 0;
|
||||
/* clock divider for I2C operations */
|
||||
ucI2cDiv = (u8)((12000000/frequency) - 3);
|
||||
|
||||
/* determine the best delay value here */
|
||||
/* (MCP2221_STD_DELAY_MS * MCP2221_FREQ_MAX)/frequency; */
|
||||
sleepCmd = MCP2221_STD_DELAY_MS;
|
||||
|
||||
if (pmsg->len > MCP2221_MAX_I2C_DATA_LEN)
|
||||
return -EINVAL;
|
||||
|
||||
readwrite_reinit:
|
||||
dev->obuffer[0] = CMD_MCP2221_STATUS; /* code for STATUS cmd */
|
||||
dev->obuffer[1] = 0x00;
|
||||
dev->obuffer[2] = ucCancelXfer; /* cancel subcmd */
|
||||
dev->obuffer[3] = SUBCMD_STATUS_SPEED; /* set the xfer speed */
|
||||
dev->obuffer[4] = ucI2cDiv;
|
||||
dev->obuffer[5] = 0x00;
|
||||
dev->obuffer[6] = 0x00;
|
||||
dev->obuffer[7] = 0x00;
|
||||
|
||||
rv = mcp2221_ll_cmd(dev);
|
||||
if (rv < 0)
|
||||
return -EFAULT;
|
||||
|
||||
if (dev->ibuffer[1] != RESP_ERR_NOERR)
|
||||
return -EFAULT;
|
||||
|
||||
if (dev->ibuffer[3] != SUBCMD_STATUS_SPEED) {
|
||||
/* the speed could not be set - wait a while and retry */
|
||||
if (retries < MCP2221_RETRY_MAX) {
|
||||
/* wait a while and retry the operation */
|
||||
retries++;
|
||||
msleep(MCP2221_STD_DELAY_MS);
|
||||
ucCancelXfer = SUBCMD_STATUS_CANCEL;
|
||||
goto readwrite_reinit;
|
||||
} else {
|
||||
/* max number of retries was reached - return error */
|
||||
dev_err(&dev->interface->dev,
|
||||
"mcp2221 CANCEL ERROR:retries = %d\n", retries);
|
||||
return -EFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
if (pmsg->flags & I2C_M_RD) {
|
||||
/* I2C read */
|
||||
ucXferLen = (u8)pmsg->len;
|
||||
dev->obuffer[0] = CMD_MCP2221_RDDATA7;
|
||||
dev->obuffer[1] = ucXferLen; /* LSB of the xfer length */
|
||||
dev->obuffer[2] = 0; /* no MSB for the xfer length */
|
||||
/* address in 8-bit format */
|
||||
dev->obuffer[3] = (u8)((pmsg->addr) << 1);
|
||||
|
||||
rv = mcp2221_ll_cmd(dev);
|
||||
if (rv < 0)
|
||||
return -EFAULT;
|
||||
|
||||
if (dev->ibuffer[1] != RESP_ERR_NOERR)
|
||||
return -EFAULT;
|
||||
|
||||
retries = 0;
|
||||
dev->obuffer[0] = CMD_MCP2221_GET_RDDATA;
|
||||
dev->obuffer[1] = 0x00;
|
||||
dev->obuffer[2] = 0x00;
|
||||
dev->obuffer[3] = 0x00;
|
||||
|
||||
while (retries < MCP2221_RETRY_MAX) {
|
||||
msleep(sleepCmd);
|
||||
|
||||
rv = mcp2221_ll_cmd(dev);
|
||||
if (rv < 0)
|
||||
return -EFAULT;
|
||||
|
||||
if (dev->ibuffer[1] != RESP_ERR_NOERR)
|
||||
return -EFAULT;
|
||||
|
||||
if (dev->ibuffer[2] == RESP_ADDR_NACK)
|
||||
return -EFAULT;
|
||||
|
||||
/* break the loop - cmd ended ok - used for bus scan */
|
||||
if ((dev->ibuffer[3] == 0x00) &&
|
||||
(dev->ibuffer[2] == 0x00))
|
||||
break;
|
||||
|
||||
if (dev->ibuffer[3] == RESP_READ_ERR) {
|
||||
retries++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((dev->ibuffer[2] == RESP_READ_COMPL) &&
|
||||
(dev->ibuffer[3] == ucXferLen)) {
|
||||
/* we got the data - copy it */
|
||||
pSrc = (u8 *)&dev->ibuffer[4];
|
||||
pDst = (u8 *)&pmsg->buf[0];
|
||||
memcpy(pDst, pSrc, ucXferLen);
|
||||
|
||||
if (pmsg->flags & I2C_M_RECV_LEN)
|
||||
pmsg->len = ucXferLen;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (retries >= MCP2221_RETRY_MAX)
|
||||
return -EFAULT;
|
||||
} else {
|
||||
/* I2C write */
|
||||
ucXferLen = (u8)pmsg->len;
|
||||
dev->obuffer[0] = CMD_MCP2221_WRDATA7;
|
||||
dev->obuffer[1] = ucXferLen; /* LSB of the xfer length */
|
||||
dev->obuffer[2] = 0; /* no MSB for the xfer length */
|
||||
/* address in 8-bit format */
|
||||
dev->obuffer[3] = (u8)((pmsg->addr) << 1);
|
||||
/* copy the data we've read back */
|
||||
pSrc = (u8 *)&pmsg->buf[0];
|
||||
pDst = (u8 *)&dev->obuffer[4];
|
||||
memcpy(pDst, pSrc, ucXferLen);
|
||||
|
||||
retries = 0;
|
||||
|
||||
while (retries < MCP2221_RETRY_MAX) {
|
||||
rv = mcp2221_ll_cmd(dev);
|
||||
if (rv < 0)
|
||||
return -EFAULT;
|
||||
|
||||
if (dev->ibuffer[1] != RESP_ERR_NOERR) {
|
||||
usbCmdStatus = dev->ibuffer[2];
|
||||
if (usbCmdStatus == RESP_I2C_START_TOUT)
|
||||
return -EFAULT;
|
||||
|
||||
if (usbCmdStatus == RESP_I2C_WRADDRL_TOUT)
|
||||
return -EFAULT;
|
||||
|
||||
if (usbCmdStatus == RESP_I2C_WRADDRL_NACK)
|
||||
return -EFAULT;
|
||||
|
||||
if (usbCmdStatus == RESP_I2C_WRDATA_TOUT)
|
||||
return -EFAULT;
|
||||
|
||||
if (usbCmdStatus == RESP_I2C_STOP_TOUT)
|
||||
return -EFAULT;
|
||||
|
||||
msleep(sleepCmd);
|
||||
retries++;
|
||||
continue;
|
||||
} else { /* command completed successfully */
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (retries >= MCP2221_RETRY_MAX)
|
||||
return -EFAULT;
|
||||
|
||||
/* now, prepare for the STATUS stage */
|
||||
retries = 0;
|
||||
dev->obuffer[0] = CMD_MCP2221_STATUS; /* code for STATUS cmd */
|
||||
dev->obuffer[1] = 0x00;
|
||||
dev->obuffer[2] = 0x00;
|
||||
dev->obuffer[3] = 0x00;
|
||||
dev->obuffer[4] = 0x00;
|
||||
dev->obuffer[5] = 0x00;
|
||||
dev->obuffer[6] = 0x00;
|
||||
dev->obuffer[7] = 0x00;
|
||||
|
||||
while (retries < MCP2221_RETRY_MAX) {
|
||||
rv = mcp2221_ll_cmd(dev);
|
||||
if (rv < 0)
|
||||
return -EFAULT;
|
||||
|
||||
if (dev->ibuffer[1] != RESP_ERR_NOERR)
|
||||
return -EFAULT;
|
||||
|
||||
/* i2c slave address was nack-ed */
|
||||
if (dev->ibuffer[20] & MASK_ADDR_NACK)
|
||||
return -EFAULT;
|
||||
|
||||
usbCmdStatus = dev->ibuffer[8];
|
||||
if (usbCmdStatus == RESP_I2C_IDLE)
|
||||
break;
|
||||
|
||||
if (usbCmdStatus == RESP_I2C_START_TOUT)
|
||||
return -EFAULT;
|
||||
|
||||
if (usbCmdStatus == RESP_I2C_WRADDRL_TOUT)
|
||||
return -EFAULT;
|
||||
|
||||
if (usbCmdStatus == RESP_I2C_WRADDRL_WSEND)
|
||||
return -EFAULT;
|
||||
|
||||
if (usbCmdStatus == RESP_I2C_WRADDRL_NACK)
|
||||
return -EFAULT;
|
||||
|
||||
if (usbCmdStatus == RESP_I2C_WRDATA_TOUT)
|
||||
return -EFAULT;
|
||||
|
||||
if (usbCmdStatus == RESP_I2C_STOP_TOUT)
|
||||
return -EFAULT;
|
||||
|
||||
msleep(sleepCmd);
|
||||
retries++;
|
||||
}
|
||||
if (retries >= MCP2221_RETRY_MAX)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* device layer */
|
||||
static int mcp2221_usb_i2c_xfer(struct i2c_adapter *adap,
|
||||
struct i2c_msg *msgs, int num)
|
||||
{
|
||||
struct i2c_mcp2221 *dev = i2c_get_adapdata(adap);
|
||||
struct i2c_msg *pmsg;
|
||||
int ret, count;
|
||||
|
||||
for (count = 0; count < num; count++) {
|
||||
pmsg = &msgs[count];
|
||||
/* no concurrent users of the mcp2221 i2c xfer */
|
||||
ret = mutex_lock_interruptible(&dev->mcp2221_usb_op_lock);
|
||||
if (ret < 0)
|
||||
goto abort;
|
||||
|
||||
ret = mcp2221_i2c_readwrite(dev, pmsg);
|
||||
mutex_unlock(&dev->mcp2221_usb_op_lock);
|
||||
if (ret < 0)
|
||||
goto abort;
|
||||
}
|
||||
|
||||
/* if all the messages were transferred ok, return "num" */
|
||||
ret = num;
|
||||
|
||||
abort:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct i2c_algorithm mcp2221_usb_algorithm = {
|
||||
.master_xfer = mcp2221_usb_i2c_xfer,
|
||||
.functionality = mcp2221_usb_func,
|
||||
};
|
||||
|
||||
static const struct usb_device_id mcp2221_table[] = {
|
||||
{ USB_DEVICE(USB_VENDOR_ID_MCP2221, USB_DEVICE_ID_MCP2221) },
|
||||
{ }
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(usb, mcp2221_table);
|
||||
|
||||
static void mcp2221_free(struct i2c_mcp2221 *dev)
|
||||
{
|
||||
usb_put_dev(dev->usb_dev);
|
||||
kfree(dev);
|
||||
}
|
||||
|
||||
static int mcp2221_probe(struct usb_interface *interface,
|
||||
const struct usb_device_id *id)
|
||||
{
|
||||
struct usb_host_interface *hostif = interface->cur_altsetting;
|
||||
struct i2c_mcp2221 *dev;
|
||||
int ret;
|
||||
|
||||
if ((hostif->desc.bInterfaceNumber != 2)
|
||||
|| (hostif->desc.bInterfaceClass != 3)) {
|
||||
pr_info("i2c-mcp2221(probe): Interface doesn't match the MCP2221 HID\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* allocate memory for our device state and initialize it */
|
||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
||||
if (dev == NULL) {
|
||||
pr_info("i2c-mcp2221(probe): no memory for device state\n");
|
||||
ret = -ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
|
||||
dev->ep_in = hostif->endpoint[0].desc.bEndpointAddress;
|
||||
dev->ep_out = hostif->endpoint[1].desc.bEndpointAddress;
|
||||
|
||||
dev->usb_dev = usb_get_dev(interface_to_usbdev(interface));
|
||||
dev->interface = interface;
|
||||
|
||||
init_waitqueue_head(&dev->usb_urb_completion_wait);
|
||||
|
||||
/* save our data pointer in this interface device */
|
||||
usb_set_intfdata(interface, dev);
|
||||
|
||||
/* setup i2c adapter description */
|
||||
dev->adapter.owner = THIS_MODULE;
|
||||
dev->adapter.class = I2C_CLASS_HWMON;
|
||||
dev->adapter.algo = &mcp2221_usb_algorithm;
|
||||
i2c_set_adapdata(&dev->adapter, dev);
|
||||
|
||||
snprintf(dev->adapter.name, sizeof(dev->adapter.name),
|
||||
DRIVER_NAME " at bus %03d device %03d",
|
||||
dev->usb_dev->bus->busnum, dev->usb_dev->devnum);
|
||||
|
||||
dev->adapter.dev.parent = &dev->interface->dev;
|
||||
|
||||
/* initialize mcp2221 i2c interface */
|
||||
ret = mcp2221_init(dev);
|
||||
if (ret < 0) {
|
||||
dev_err(&interface->dev, "failed to initialize adapter\n");
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
/* and finally attach to i2c layer */
|
||||
ret = i2c_add_adapter(&dev->adapter);
|
||||
if (ret < 0) {
|
||||
dev_err(&interface->dev, "failed to add I2C adapter\n");
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
dev_info(&dev->interface->dev,
|
||||
"mcp2221_probe() -> chip connected -> Success\n");
|
||||
return 0;
|
||||
|
||||
error_free:
|
||||
usb_set_intfdata(interface, NULL);
|
||||
mcp2221_free(dev);
|
||||
error:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void mcp2221_disconnect(struct usb_interface *interface)
|
||||
{
|
||||
struct i2c_mcp2221 *dev = usb_get_intfdata(interface);
|
||||
|
||||
i2c_del_adapter(&dev->adapter);
|
||||
|
||||
usb_kill_urb(dev->interrupt_in_urb);
|
||||
usb_kill_urb(dev->interrupt_out_urb);
|
||||
usb_free_urb(dev->interrupt_in_urb);
|
||||
usb_free_urb(dev->interrupt_out_urb);
|
||||
|
||||
usb_set_intfdata(interface, NULL);
|
||||
mcp2221_free(dev);
|
||||
|
||||
pr_info("i2c-mcp2221(disconnect) -> chip disconnected");
|
||||
}
|
||||
|
||||
static struct usb_driver mcp2221_driver = {
|
||||
.name = DRIVER_NAME,
|
||||
.probe = mcp2221_probe,
|
||||
.disconnect = mcp2221_disconnect,
|
||||
.id_table = mcp2221_table,
|
||||
};
|
||||
|
||||
module_usb_driver(mcp2221_driver);
|
||||
|
||||
MODULE_AUTHOR("Bogdan Bolocan");
|
||||
MODULE_DESCRIPTION(DRIVER_NAME "I2C MCP2221");
|
||||
MODULE_LICENSE("GPL v2");
|
@ -0,0 +1,198 @@
|
||||
/*
|
||||
* wnc_cpld.c - A driver for control wnc_cpld base on lm75.c
|
||||
*
|
||||
* Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
|
||||
* Copyright (c) 2017 WNC <wnc@wnc.com.tw>
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
/* Addresses scanned */
|
||||
static const unsigned short normal_i2c[] = { 0x31, 0x32, I2C_CLIENT_END };
|
||||
|
||||
/* Size of EEPROM in bytes */
|
||||
#define CPLD_SIZE 3
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct cpld_data {
|
||||
struct mutex update_lock;
|
||||
char valid; /* !=0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 data[CPLD_SIZE]; /* Register value */
|
||||
};
|
||||
|
||||
static ssize_t show_value(struct device *dev, struct device_attribute *da, char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
data->data[0] = i2c_smbus_read_byte_data(client, attr->index);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return sprintf(buf, "%02x\n", data->data[0]);
|
||||
}
|
||||
|
||||
static ssize_t set_value(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 temp;
|
||||
int error;
|
||||
|
||||
error = kstrtou8(buf, 10, &temp);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
i2c_smbus_write_byte_data(client, attr->index, temp);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static SENSOR_DEVICE_ATTR(reset_control, S_IWUSR | S_IRUGO, show_value, set_value, 2);
|
||||
static SENSOR_DEVICE_ATTR(sfp_mod_abs1, S_IRUGO, show_value, NULL, 3);
|
||||
static SENSOR_DEVICE_ATTR(sfp_mod_abs2, S_IRUGO, show_value, NULL, 4);
|
||||
static SENSOR_DEVICE_ATTR(sfp_mod_abs3, S_IRUGO, show_value, NULL, 5);
|
||||
static SENSOR_DEVICE_ATTR(sfp_mod_abs4, S_IRUGO, show_value, NULL, 6);
|
||||
static SENSOR_DEVICE_ATTR(qsfp_modprs, S_IRUGO, show_value, NULL, 22);
|
||||
static SENSOR_DEVICE_ATTR(qsfp_lpmode, S_IWUSR | S_IRUGO, show_value, set_value, 24);
|
||||
|
||||
static struct attribute *cpld2_attributes[] = {
|
||||
&sensor_dev_attr_reset_control.dev_attr.attr,
|
||||
&sensor_dev_attr_sfp_mod_abs1.dev_attr.attr,
|
||||
&sensor_dev_attr_sfp_mod_abs2.dev_attr.attr,
|
||||
&sensor_dev_attr_sfp_mod_abs3.dev_attr.attr,
|
||||
&sensor_dev_attr_qsfp_modprs.dev_attr.attr,
|
||||
&sensor_dev_attr_qsfp_lpmode.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct attribute *cpld1_attributes[] = {
|
||||
&sensor_dev_attr_sfp_mod_abs1.dev_attr.attr,
|
||||
&sensor_dev_attr_sfp_mod_abs2.dev_attr.attr,
|
||||
&sensor_dev_attr_sfp_mod_abs3.dev_attr.attr,
|
||||
&sensor_dev_attr_sfp_mod_abs4.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct attribute_group cpld2_group = {
|
||||
.attrs = cpld2_attributes,
|
||||
};
|
||||
|
||||
static const struct attribute_group cpld1_group = {
|
||||
.attrs = cpld1_attributes,
|
||||
};
|
||||
|
||||
/* Return 0 if detection is successful, -ENODEV otherwise */
|
||||
static int cpld_detect(struct i2c_client *new_client, struct i2c_board_info *info)
|
||||
{
|
||||
struct i2c_adapter *adapter = new_client->adapter;
|
||||
int conf;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
|
||||
I2C_FUNC_SMBUS_WORD_DATA))
|
||||
return -ENODEV;
|
||||
|
||||
/* Unused bits */
|
||||
conf = i2c_smbus_read_byte_data(new_client, 0);
|
||||
if (!conf)
|
||||
return -ENODEV;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int cpld_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct cpld_data *data;
|
||||
int status;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
return -EIO;
|
||||
#if 1
|
||||
data = devm_kzalloc(&client->dev, sizeof(struct cpld_data), GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->update_lock);
|
||||
#endif
|
||||
|
||||
if (client->addr == 49) /* 0x31 */
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &cpld1_group);
|
||||
else if (client->addr == 50) /* 0x32 */
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &cpld2_group);
|
||||
else
|
||||
status = 1;
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
dev_info(&client->dev, "cpld 0x%x found\n", client->addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpld_remove(struct i2c_client *client)
|
||||
{
|
||||
if (client->addr == 49) /* 0x31 */
|
||||
sysfs_remove_group(&client->dev.kobj, &cpld1_group);
|
||||
else if (client->addr == 50) /* 0x32 */
|
||||
sysfs_remove_group(&client->dev.kobj, &cpld2_group);
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id cpld_id[] = {
|
||||
{ "wnc_cpld", 0 },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, cpld_id);
|
||||
|
||||
static struct i2c_driver cpld_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "wnc_cpld",
|
||||
},
|
||||
.probe = cpld_probe,
|
||||
.remove = cpld_remove,
|
||||
.id_table = cpld_id,
|
||||
.detect = cpld_detect,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
module_i2c_driver(cpld_driver);
|
||||
|
||||
MODULE_AUTHOR("WNC <wnc@wnc.com.tw>");
|
||||
MODULE_DESCRIPTION("WNC CPLD driver");
|
||||
MODULE_LICENSE("GPL");
|
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* wnc_cpld.c - A driver for control wnc_cpld3 base on lm75.c
|
||||
*
|
||||
* Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
|
||||
* Copyright (c) 2017 WNC <wnc@wnc.com.tw>
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
/* Addresses scanned */
|
||||
static const unsigned short normal_i2c[] = { 0x33, I2C_CLIENT_END };
|
||||
|
||||
/* Size of EEPROM in bytes */
|
||||
#define CPLD_SIZE 3
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct cpld_data {
|
||||
struct i2c_client *client;
|
||||
struct mutex update_lock;
|
||||
char valid; /* !=0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 data[CPLD_SIZE]; /* Register value */
|
||||
};
|
||||
|
||||
static ssize_t show_hwmon_value(struct device *dev, struct device_attribute *da, char *buf)
|
||||
{
|
||||
struct cpld_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->client;
|
||||
int index = to_sensor_dev_attr_2(da)->index;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
data->data[0] = i2c_smbus_read_byte_data(client, index);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return sprintf(buf, "%d\n", data->data[0]);
|
||||
}
|
||||
|
||||
static ssize_t show_sysfs_value(struct device *dev, struct device_attribute *da, char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
data->data[0] = i2c_smbus_read_byte_data(client, attr->index);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return sprintf(buf, "%02x\n", data->data[0]);
|
||||
}
|
||||
|
||||
static ssize_t set_hwmon_value(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
|
||||
{
|
||||
struct cpld_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->client;
|
||||
int index = to_sensor_dev_attr_2(da)->index;
|
||||
u8 temp;
|
||||
int error;
|
||||
|
||||
error = kstrtou8(buf, 10, &temp);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
i2c_smbus_write_byte_data(client, index, temp);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_hwmon_value, NULL, 6);
|
||||
static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_hwmon_value, NULL, 7);
|
||||
static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_hwmon_value, NULL, 8);
|
||||
static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_hwmon_value, NULL, 9);
|
||||
static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_hwmon_value, NULL, 10);
|
||||
static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_hwmon_value, set_hwmon_value, 6);
|
||||
static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_hwmon_value, set_hwmon_value, 7);
|
||||
static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_hwmon_value, set_hwmon_value, 8);
|
||||
static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR | S_IRUGO, show_hwmon_value, set_hwmon_value, 9);
|
||||
static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR | S_IRUGO, show_hwmon_value, set_hwmon_value, 10);
|
||||
|
||||
static struct attribute *cpld3_hwmon_attrs[] = {
|
||||
&sensor_dev_attr_fan1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan3_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan4_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan5_input.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm1.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm2.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm3.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm4.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm5.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
ATTRIBUTE_GROUPS(cpld3_hwmon);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(cpld_version, S_IRUGO, show_sysfs_value, NULL, 1);
|
||||
static SENSOR_DEVICE_ATTR(power_good, S_IRUGO, show_sysfs_value, NULL, 4);
|
||||
|
||||
static struct attribute *cpld3_sysfs_attrs[] = {
|
||||
&sensor_dev_attr_cpld_version.dev_attr.attr,
|
||||
&sensor_dev_attr_power_good.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct attribute_group cpld3_sysfs_group = {
|
||||
.attrs = cpld3_sysfs_attrs,
|
||||
};
|
||||
|
||||
/* Return 0 if detection is successful, -ENODEV otherwise */
|
||||
static int cpld_detect(struct i2c_client *new_client, struct i2c_board_info *info)
|
||||
{
|
||||
struct i2c_adapter *adapter = new_client->adapter;
|
||||
int conf;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
|
||||
I2C_FUNC_SMBUS_WORD_DATA))
|
||||
return -ENODEV;
|
||||
|
||||
/* Unused bits */
|
||||
conf = i2c_smbus_read_byte_data(new_client, 0);
|
||||
if (!conf)
|
||||
return -ENODEV;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int cpld_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct device *hwmon_dev;
|
||||
struct cpld_data *data;
|
||||
int status;
|
||||
|
||||
data = devm_kzalloc(&client->dev, sizeof(struct cpld_data), GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
data->client = client;
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
status = sysfs_create_group(&client->dev.kobj, &cpld3_sysfs_group);
|
||||
hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev, client->name, data, cpld3_hwmon_groups);
|
||||
|
||||
return PTR_ERR_OR_ZERO(hwmon_dev);
|
||||
}
|
||||
|
||||
static int cpld_remove(struct i2c_client *client)
|
||||
{
|
||||
devm_hwmon_device_unregister(&client->dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &cpld3_sysfs_group);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id cpld_id[] = {
|
||||
{ "wnc_cpld3", 0 },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, cpld_id);
|
||||
|
||||
static struct i2c_driver cpld_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "wnc_cpld3",
|
||||
},
|
||||
.probe = cpld_probe,
|
||||
.remove = cpld_remove,
|
||||
.id_table = cpld_id,
|
||||
.detect = cpld_detect,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
module_i2c_driver(cpld_driver);
|
||||
|
||||
MODULE_AUTHOR("WNC <wnc@wnc.com.tw>");
|
||||
MODULE_DESCRIPTION("WNC CPLD3 driver");
|
||||
MODULE_LICENSE("GPL");
|
@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Copyright (C) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and
|
||||
* Philip Edelbrock <phil@netroedge.com>
|
||||
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
|
||||
* Copyright (C) 2003 IBM Corp.
|
||||
* Copyright (C) 2004 Jean Delvare <jdelvare@suse.de>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
/* Addresses to scan */
|
||||
static const unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||
0x55, 0x56, 0x57, I2C_CLIENT_END };
|
||||
|
||||
|
||||
/* Size of EEPROM in bytes */
|
||||
#define EEPROM_SIZE 256
|
||||
|
||||
/* possible types of eeprom devices */
|
||||
enum eeprom_nature {
|
||||
UNKNOWN,
|
||||
VAIO,
|
||||
};
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct eeprom_data {
|
||||
struct mutex update_lock;
|
||||
u8 valid; /* bitfield, bit!=0 if slice is valid */
|
||||
unsigned long last_updated[8]; /* In jiffies, 8 slices */
|
||||
u8 data[EEPROM_SIZE]; /* Register values */
|
||||
enum eeprom_nature nature;
|
||||
};
|
||||
|
||||
|
||||
static void eeprom_update_client(struct i2c_client *client, u8 slice)
|
||||
{
|
||||
struct eeprom_data *data = i2c_get_clientdata(client);
|
||||
int i;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (!(data->valid & (1 << slice)) ||
|
||||
time_after(jiffies, data->last_updated[slice] + 300 * HZ)) {
|
||||
dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice);
|
||||
|
||||
if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
|
||||
//for (i = slice << 5; i < (slice + 1) << 5; i += 32)
|
||||
for (i = slice << 5; i < (slice + 1) << 5; i += 24)
|
||||
if (i2c_smbus_read_i2c_block_data(client, i,
|
||||
24, data->data + i)
|
||||
!= 24)
|
||||
goto exit;
|
||||
} else {
|
||||
for (i = slice << 5; i < (slice + 1) << 5; i += 2) {
|
||||
int word = i2c_smbus_read_word_data(client, i);
|
||||
if (word < 0)
|
||||
goto exit;
|
||||
data->data[i] = word & 0xff;
|
||||
data->data[i + 1] = word >> 8;
|
||||
}
|
||||
}
|
||||
data->last_updated[slice] = jiffies;
|
||||
data->valid |= (1 << slice);
|
||||
}
|
||||
exit:
|
||||
mutex_unlock(&data->update_lock);
|
||||
}
|
||||
|
||||
static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *bin_attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
|
||||
struct eeprom_data *data = i2c_get_clientdata(client);
|
||||
u8 slice;
|
||||
|
||||
data->valid = 0;
|
||||
|
||||
if (off > EEPROM_SIZE)
|
||||
return 0;
|
||||
if (off + count > EEPROM_SIZE)
|
||||
count = EEPROM_SIZE - off;
|
||||
|
||||
/* Only refresh slices which contain requested bytes */
|
||||
for (slice = off >> 5; slice <= (off + count - 1) >> 5; slice++)
|
||||
eeprom_update_client(client, slice);
|
||||
|
||||
/* Hide Vaio private settings to regular users:
|
||||
- BIOS passwords: bytes 0x00 to 0x0f
|
||||
- UUID: bytes 0x10 to 0x1f
|
||||
- Serial number: 0xc0 to 0xdf */
|
||||
if (data->nature == VAIO && !capable(CAP_SYS_ADMIN)) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if ((off + i <= 0x1f) ||
|
||||
(off + i >= 0xc0 && off + i <= 0xdf))
|
||||
buf[i] = 0;
|
||||
else
|
||||
buf[i] = data->data[off + i];
|
||||
}
|
||||
} else {
|
||||
memcpy(buf, &data->data[off], count);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *bin_attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
|
||||
struct eeprom_data *data = i2c_get_clientdata(client);
|
||||
u8 temp;
|
||||
int error, reg;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
error = kstrtou8(buf, 10, &temp);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (client->addr == 0x51) { /* SFP AOC cable, page selection byte is 126 */
|
||||
reg = 126;
|
||||
}
|
||||
else if (client->addr == 0x50) { /* QSFP, page selection byte is 127 */
|
||||
data->data[0] = i2c_smbus_read_byte_data(client, 0);
|
||||
|
||||
/* Base on SFF-8024, determine this module is SFP or QSFP by byte 0 (Identifier) */
|
||||
switch (data->data[0]){
|
||||
case 12:
|
||||
case 13:
|
||||
case 17:
|
||||
case 24:
|
||||
reg = 127;
|
||||
break;
|
||||
|
||||
default:
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
goto exit;
|
||||
|
||||
i2c_smbus_write_byte_data(client, reg, temp);
|
||||
|
||||
exit:
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static struct bin_attribute eeprom_attr = {
|
||||
.attr = {
|
||||
.name = "eeprom",
|
||||
.mode = S_IWUSR | S_IRUGO | S_IWGRP | S_IWOTH,
|
||||
},
|
||||
.size = EEPROM_SIZE,
|
||||
.read = eeprom_read,
|
||||
.write = eeprom_write,
|
||||
};
|
||||
|
||||
/* Return 0 if detection is successful, -ENODEV otherwise */
|
||||
static int eeprom_detect(struct i2c_client *client, struct i2c_board_info *info)
|
||||
{
|
||||
struct i2c_adapter *adapter = client->adapter;
|
||||
|
||||
/* EDID EEPROMs are often 24C00 EEPROMs, which answer to all
|
||||
addresses 0x50-0x57, but we only care about 0x50. So decline
|
||||
attaching to addresses >= 0x51 on DDC buses */
|
||||
if (!(adapter->class & I2C_CLASS_SPD) && client->addr >= 0x51)
|
||||
return -ENODEV;
|
||||
|
||||
/* There are four ways we can read the EEPROM data:
|
||||
(1) I2C block reads (faster, but unsupported by most adapters)
|
||||
(2) Word reads (128% overhead)
|
||||
(3) Consecutive byte reads (88% overhead, unsafe)
|
||||
(4) Regular byte data reads (265% overhead)
|
||||
The third and fourth methods are not implemented by this driver
|
||||
because all known adapters support one of the first two. */
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_WORD_DATA)
|
||||
&& !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK))
|
||||
return -ENODEV;
|
||||
|
||||
strlcpy(info->type, "wnc_eeprom", I2C_NAME_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct i2c_adapter *adapter = client->adapter;
|
||||
struct eeprom_data *data;
|
||||
int err;
|
||||
|
||||
if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
memset(data->data, 0xff, EEPROM_SIZE);
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->update_lock);
|
||||
data->nature = UNKNOWN;
|
||||
|
||||
/* Detect the Vaio nature of EEPROMs.
|
||||
We use the "PCG-" or "VGN-" prefix as the signature. */
|
||||
if (client->addr == 0x57
|
||||
&& i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
|
||||
char name[4];
|
||||
|
||||
name[0] = i2c_smbus_read_byte_data(client, 0x80);
|
||||
name[1] = i2c_smbus_read_byte_data(client, 0x81);
|
||||
name[2] = i2c_smbus_read_byte_data(client, 0x82);
|
||||
name[3] = i2c_smbus_read_byte_data(client, 0x83);
|
||||
|
||||
if (!memcmp(name, "PCG-", 4) || !memcmp(name, "VGN-", 4)) {
|
||||
dev_info(&client->dev, "Vaio EEPROM detected, "
|
||||
"enabling privacy protection\n");
|
||||
data->nature = VAIO;
|
||||
}
|
||||
}
|
||||
|
||||
/* create the sysfs eeprom file */
|
||||
err = sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr);
|
||||
if (err)
|
||||
goto exit_kfree;
|
||||
|
||||
return 0;
|
||||
|
||||
exit_kfree:
|
||||
kfree(data);
|
||||
exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int eeprom_remove(struct i2c_client *client)
|
||||
{
|
||||
sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr);
|
||||
kfree(i2c_get_clientdata(client));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id eeprom_id[] = {
|
||||
{ "wnc_eeprom", 0 },
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct i2c_driver eeprom_driver = {
|
||||
.driver = {
|
||||
.name = "wnc_eeprom",
|
||||
},
|
||||
.probe = eeprom_probe,
|
||||
.remove = eeprom_remove,
|
||||
.id_table = eeprom_id,
|
||||
|
||||
.class = I2C_CLASS_DDC | I2C_CLASS_SPD,
|
||||
.detect = eeprom_detect,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
module_i2c_driver(eeprom_driver);
|
||||
|
||||
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and "
|
||||
"Philip Edelbrock <phil@netroedge.com> and "
|
||||
"Greg Kroah-Hartman <greg@kroah.com>");
|
||||
MODULE_DESCRIPTION("I2C EEPROM driver");
|
||||
MODULE_LICENSE("GPL");
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user