Skip to content

Commit

Permalink
[AS7315-27XB] Fix build error and incorrect I2C bus number (#9712)
Browse files Browse the repository at this point in the history
* Add intel_iommu=off to installer.conf

* This solve flooding DMAR err msg: "handling fault status reg 2"

Signed-off-by: Sean Wu <sean_wu@edge-core.com>

* remove customized at24 driver

* Use kernel 5.10.46 upstream at24 driver directly. The ADDR16 issue on
old driver has gone.

Signed-off-by: Sean Wu <sean_wu@edge-core.com>

* pin I2C-0/I2C-1 bus order

* otherwise, sometimes I2C-0/I2C-1 will be assigned to the undesired one.

Signed-off-by: Sean Wu <sean_wu@edge-core.com>

* fix i2c bus num for fan driver

Signed-off-by: Sean Wu <sean_wu@edge-core.com>

* backward compatible with R0A/R0B HW

Signed-off-by: Sean Wu <sean_wu@edge-core.com>
  • Loading branch information
seanwu-ec authored Jan 16, 2022
1 parent 1b657be commit a2d1798
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 704 deletions.
2 changes: 1 addition & 1 deletion device/accton/x86_64-accton_as7315_27xb-r0/installer.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CONSOLE_SPEED=115200
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="tg3.short_preamble=1 tg3.bcm5718s_reset=1"
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="tg3.short_preamble=1 tg3.bcm5718s_reset=1 intel_iommu=off modprobe.blacklist=i2c-ismt,i2c_ismt,i2c-i801,i2c_i801"
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import time
import logging
from collections import namedtuple
import subprocess
except ImportError as e:
raise ImportError('%s - required module not found' % str(e))

Expand All @@ -44,8 +45,11 @@ class FanUtil(object):
#FAN_NODE_DUTY_IDX_OF_MAP = 4
#FANR_NODE_FAULT_IDX_OF_MAP = 5

BASE_VAL_PATH = '/sys/bus/i2c/devices/50-0066/{0}'
FAN_DUTY_PATH = '/sys/bus/i2c/devices/50-0066/fan{0}_pwm'
I2CADDR_CANDIDATES = ((9, 66), # for R0C HW and later
(50, 66)) # for R0A, R0B HW
PATH_PREFIX = '/sys/bus/i2c/devices/{}-00{}/'
BASE_VAL_PATH = '{0}'
FAN_DUTY_PATH = 'fan{0}_pwm'

#logfile = ''
#loglevel = self.logger.INFO
Expand All @@ -59,6 +63,21 @@ class FanUtil(object):
node_postfix = ["fault", "direction"]
def _get_fan_to_device_node(self, fan_num, node_num):
return "fan{0}_{1}".format(fan_num, self.node_postfix[node_num-1])

def _get_fan_i2c_bus_addr(self):
cmd_template = 'i2cget -f -y {} 0x{} 0'
for bus_no, dev_addr in self.I2CADDR_CANDIDATES:
cmd = cmd_template.format(bus_no, dev_addr)
if subprocess.getstatusoutput(cmd)[0] == 0:
return bus_no, dev_addr
raise IOError('Unable to reach fan CPLD via I2C')

def _init_fnode_basepath(self):
'''format BASE_VAL_PATH and FAN_DUTY_PATH '''
bus, addr = self._get_fan_i2c_bus_addr()
self.PATH_PREFIX = self.PATH_PREFIX.format(bus, addr)
self.BASE_VAL_PATH = self.PATH_PREFIX + self.BASE_VAL_PATH
self.FAN_DUTY_PATH = self.PATH_PREFIX + self.FAN_DUTY_PATH

def _get_fan_node_val(self, fan_num, node_num):
if fan_num < self.FAN_NUM_1_IDX or fan_num > self.FAN_TOTAL_NUM:
Expand All @@ -84,7 +103,7 @@ def _get_fan_node_val(self, fan_num, node_num):
return None

try:
val_file.close()
val_file.close()
except:
self.logger.debug('GET. unable to close file. device_path:%s', device_path)
return None
Expand Down Expand Up @@ -115,7 +134,7 @@ def _set_fan_node_val(self, fan_num, node_num, val):
val_file.write(content)

try:
val_file.close()
val_file.close()
except:
self.logger.debug('GET. unable to close file. device_path:%s', device_path)
return None
Expand All @@ -128,6 +147,7 @@ def __init__(self, log_level=logging.DEBUG):
ch.setLevel(log_level)
self.logger.addHandler(ch)

self._init_fnode_basepath()
fan_path = self.BASE_VAL_PATH
for fan_num in range(self.FAN_NUM_1_IDX, self.FAN_TOTAL_NUM+1):
for node_num in range(1, self.FAN_NODE_NUM+1):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
obj-m:= accton_as7315_27xb_fan.o x86-64-accton-as7315-27xb-cpld.o x86-64-accton-as7315-27xb-psu.o \
at24_as7315_27xb.o x86-64-accton-as7315-27xb-led.o ym2651y.o
x86-64-accton-as7315-27xb-led.o ym2651y.o
Loading

0 comments on commit a2d1798

Please sign in to comment.