mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-24 16:57:02 +00:00
Merge remote-tracking branch 'remote_onl/master' into onl-anaconda
This commit is contained in:
4
Makefile
4
Makefile
@@ -13,7 +13,7 @@ endif
|
||||
include $(ONL)/make/config.mk
|
||||
|
||||
# All available architectures.
|
||||
ALL_ARCHES := amd64 powerpc armel arm64
|
||||
ALL_ARCHES := amd64 powerpc armel arm64 armhf
|
||||
|
||||
# Build rule for each architecture.
|
||||
define build_arch_template
|
||||
@@ -26,7 +26,7 @@ $(foreach a,$(ALL_ARCHES),$(eval $(call build_arch_template,$(a))))
|
||||
# Available build architectures based on the current suite
|
||||
BUILD_ARCHES_wheezy := amd64 powerpc
|
||||
BUILD_ARCHES_jessie := amd64 powerpc armel
|
||||
BUILD_ARCHES_stretch := arm64 amd64
|
||||
BUILD_ARCHES_stretch := arm64 amd64 armel armhf
|
||||
|
||||
# Build available architectures by default.
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
1
REPO/stretch/packages/binary-armhf/Makefile
Normal file
1
REPO/stretch/packages/binary-armhf/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/repo.mk
|
||||
@@ -11,6 +11,7 @@ include $(ONL)/make/versions/version-onl.mk
|
||||
INSTALLER_NAME=$(FNAME_PRODUCT_VERSION)_ONL-OS_$(FNAME_BUILD_ID)_$(UARCH)_$(BOOTMODE)_INSTALLER
|
||||
|
||||
MKINSTALLER_OPTS = \
|
||||
--onl-version "$(VERSION_STRING)" \
|
||||
--arch $(ARCH) \
|
||||
--boot-config boot-config \
|
||||
--add-dir config \
|
||||
|
||||
@@ -19,6 +19,7 @@ if test "$ARCH" != "$IARCH"; then
|
||||
# identify mappings between kernel arch and debian arch
|
||||
case "$IARCH:$ARCH" in
|
||||
armel:armv7l) ;;
|
||||
armhf:armv7l) ;;
|
||||
arm64:aarch64) ;;
|
||||
powerpc:ppc) ;;
|
||||
*)
|
||||
|
||||
@@ -11,6 +11,7 @@ include $(ONL)/make/versions/version-onl.mk
|
||||
INSTALLER_NAME=$(FNAME_PRODUCT_VERSION)_ONL-OS_$(FNAME_BUILD_ID)_$(UARCH)_$(BOOTMODE)_INSTALLER
|
||||
|
||||
MKINSTALLER_OPTS = \
|
||||
--onl-version "$(VERSION_STRING)" \
|
||||
--arch $(ARCH) \
|
||||
--boot-config boot-config \
|
||||
--add-dir config \
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
- python
|
||||
- apt
|
||||
- apt-utils
|
||||
- debconf
|
||||
- dialog
|
||||
- procps
|
||||
- net-tools
|
||||
- iputils-ping
|
||||
@@ -78,3 +80,4 @@
|
||||
- strace
|
||||
- sysstat
|
||||
- ipmitool
|
||||
- lm-sensors
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
- u-boot-tools
|
||||
- onl-kernel-4.14-lts-armel-iproc-all-modules
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
- python
|
||||
- apt
|
||||
- apt-utils
|
||||
- debconf
|
||||
- dialog
|
||||
- procps
|
||||
- net-tools
|
||||
- iputils-ping
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
- u-boot-tools
|
||||
- onl-kernel-4.14-lts-armel-iproc-all-modules
|
||||
|
||||
2
builds/any/rootfs/stretch/common/armhf-base-packages.yml
Normal file
2
builds/any/rootfs/stretch/common/armhf-base-packages.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
- u-boot-tools
|
||||
- onl-kernel-4.14-lts-armhf-iproc-all-modules
|
||||
9
builds/any/rootfs/stretch/common/armhf-onl-packages.yml
Normal file
9
builds/any/rootfs/stretch/common/armhf-onl-packages.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
############################################################
|
||||
#
|
||||
# These packages are specific to the ONL root filesystem build.
|
||||
#
|
||||
############################################################
|
||||
- onl-loader-fit
|
||||
|
||||
|
||||
|
||||
@@ -46,12 +46,14 @@ Multistrap:
|
||||
source: http://apt.opennetlinux.org/debian
|
||||
suite: unstable
|
||||
omitdebsrc: true
|
||||
arches: amd64, arm64, armel
|
||||
|
||||
ONL-Local:
|
||||
packages: *Packages
|
||||
source: http://${APT_CACHE}apt.opennetlinux.org/debian
|
||||
suite: unstable
|
||||
omitdebsrc: true
|
||||
arches: amd64, arm64, armel
|
||||
|
||||
Local-All:
|
||||
source: ${ONLPM_OPTION_REPO}/${ONL_DEBIAN_SUITE}/packages/binary-all
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
- python
|
||||
- apt
|
||||
- apt-utils
|
||||
- debconf
|
||||
- dialog
|
||||
- procps
|
||||
- net-tools
|
||||
- iputils-ping
|
||||
|
||||
@@ -4,7 +4,9 @@ include $(ONL)/make/config.armel.mk
|
||||
# Default to include all available powerpc platforms.
|
||||
# You override this with you own list or yaml file.
|
||||
#
|
||||
ifndef PLATFORM_LIST
|
||||
export PLATFORM_LIST=$(shell onlpm --list-platforms --arch armel --csv )
|
||||
endif
|
||||
|
||||
RFS_CONFIG := $(ONL)/builds/any/rootfs/$(ONL_DEBIAN_SUITE)/standard/standard.yml
|
||||
RFS_DIR := rootfs-armel.d
|
||||
|
||||
1
builds/armhf/Makefile
Normal file
1
builds/armhf/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/arch-build.mk
|
||||
1
builds/armhf/installer/installed/Makefile
Normal file
1
builds/armhf/installer/installed/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
1
builds/armhf/installer/installed/PKG.yml
Normal file
1
builds/armhf/installer/installed/PKG.yml
Normal file
@@ -0,0 +1 @@
|
||||
!include $ONL/builds/any/installer/APKG.yml ARCH=armhf BOOTMODE=installed
|
||||
1
builds/armhf/installer/installed/builds/.gitignore
vendored
Normal file
1
builds/armhf/installer/installed/builds/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*INSTALLER
|
||||
3
builds/armhf/installer/installed/builds/Makefile
Normal file
3
builds/armhf/installer/installed/builds/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
BOOTMODE=INSTALLED
|
||||
include $(ONL)/make/config.armhf.mk
|
||||
include $(ONL)/builds/any/installer/uboot/builds/Makefile
|
||||
3
builds/armhf/installer/installed/builds/boot-config
Normal file
3
builds/armhf/installer/installed/builds/boot-config
Normal file
@@ -0,0 +1,3 @@
|
||||
NETDEV=ma1
|
||||
BOOTMODE=INSTALLED
|
||||
SWI=images::latest
|
||||
2
builds/armhf/installer/installed/builds/config/README
Normal file
2
builds/armhf/installer/installed/builds/config/README
Normal file
@@ -0,0 +1,2 @@
|
||||
This partition contains system configuration data that is persistant across installations and upgrades of ONL-based systems.
|
||||
|
||||
1
builds/armhf/installer/swi/Makefile
Normal file
1
builds/armhf/installer/swi/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
1
builds/armhf/installer/swi/PKG.yml
Normal file
1
builds/armhf/installer/swi/PKG.yml
Normal file
@@ -0,0 +1 @@
|
||||
!include $ONL/builds/any/installer/APKG.yml ARCH=armhf BOOTMODE=swi
|
||||
1
builds/armhf/installer/swi/builds/.gitignore
vendored
Normal file
1
builds/armhf/installer/swi/builds/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*INSTALLER
|
||||
3
builds/armhf/installer/swi/builds/Makefile
Normal file
3
builds/armhf/installer/swi/builds/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
BOOTMODE=SWI
|
||||
include $(ONL)/make/config.armhf.mk
|
||||
include $(ONL)/builds/any/installer/uboot/builds/Makefile
|
||||
3
builds/armhf/installer/swi/builds/boot-config
Normal file
3
builds/armhf/installer/swi/builds/boot-config
Normal file
@@ -0,0 +1,3 @@
|
||||
NETDEV=ma1
|
||||
BOOTMODE=SWI
|
||||
SWI=images::latest
|
||||
2
builds/armhf/installer/swi/builds/config/README
Normal file
2
builds/armhf/installer/swi/builds/config/README
Normal file
@@ -0,0 +1,2 @@
|
||||
This partition contains system configuration data that is persistant across installations and upgrades of ONL-based systems.
|
||||
|
||||
1
builds/armhf/rootfs/Makefile
Normal file
1
builds/armhf/rootfs/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
1
builds/armhf/rootfs/PKG.yml
Normal file
1
builds/armhf/rootfs/PKG.yml
Normal file
@@ -0,0 +1 @@
|
||||
!include $ONL/builds/any/rootfs/APKG.yml ARCH=armhf
|
||||
2
builds/armhf/rootfs/builds/.gitignore
vendored
Normal file
2
builds/armhf/rootfs/builds/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.d/
|
||||
manifest.json
|
||||
16
builds/armhf/rootfs/builds/Makefile
Normal file
16
builds/armhf/rootfs/builds/Makefile
Normal file
@@ -0,0 +1,16 @@
|
||||
include $(ONL)/make/config.armhf.mk
|
||||
|
||||
#
|
||||
# Default to include all available powerpc platforms.
|
||||
# You override this with you own list or yaml file.
|
||||
#
|
||||
ifndef PLATFORM_LIST
|
||||
export PLATFORM_LIST=$(shell onlpm --list-platforms --arch armhf --csv )
|
||||
endif
|
||||
|
||||
RFS_CONFIG := $(ONL)/builds/any/rootfs/$(ONL_DEBIAN_SUITE)/standard/standard.yml
|
||||
RFS_DIR := rootfs-armhf.d
|
||||
RFS_CPIO := rootfs-armhf.cpio.gz
|
||||
RFS_SQUASH := rootfs-armhf.sqsh
|
||||
|
||||
include $(ONL)/make/rfs.mk
|
||||
1
builds/armhf/swi/Makefile
Normal file
1
builds/armhf/swi/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
1
builds/armhf/swi/PKG.yml
Normal file
1
builds/armhf/swi/PKG.yml
Normal file
@@ -0,0 +1 @@
|
||||
!include $ONL/builds/any/swi/APKG.yml ARCH=armhf
|
||||
1
builds/armhf/swi/builds/.gitignore
vendored
Normal file
1
builds/armhf/swi/builds/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
manifest.json
|
||||
3
builds/armhf/swi/builds/Makefile
Normal file
3
builds/armhf/swi/builds/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
ROOTFS_PACKAGE := onl-rootfs
|
||||
include $(ONL)/make/config.armhf.mk
|
||||
include $(ONL)/make/swi.mk
|
||||
12
docker/images/builder8/1.10/Dockerfile
Normal file
12
docker/images/builder8/1.10/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM opennetworklinux/builder8:1.9
|
||||
MAINTAINER Jeffrey Townsend <jeffrey.townsend@bigswitch.com>
|
||||
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
|
||||
apt-get install linux-perf-4.9 linux-tools-3.16 linux-tools -y
|
||||
|
||||
#
|
||||
# Docker shell and other container tools.
|
||||
#
|
||||
COPY docker_shell /bin/docker_shell
|
||||
COPY container-id /bin/container-id
|
||||
19
docker/images/builder8/1.10/Makefile
Normal file
19
docker/images/builder8/1.10/Makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
VERSION=1.10
|
||||
USER=opennetworklinux
|
||||
REPO=builder8
|
||||
|
||||
TOOLS=../../../tools/docker_shell ../../../tools/container-id
|
||||
|
||||
build: check_version
|
||||
cp $(TOOLS) .
|
||||
docker build -t $(USER)/$(REPO):$(VERSION) .
|
||||
rm -rf $(notdir $(TOOLS))
|
||||
|
||||
#
|
||||
# Todo: Query remote repository to see if the request version already exists to avoid accidental overwrites
|
||||
# when a new image is built but the VERSION variable is not updated.
|
||||
#
|
||||
check_version:
|
||||
|
||||
push:
|
||||
docker push $(USER)/$(REPO):$(VERSION)
|
||||
27
docker/images/builder9/1.3/Dockerfile
Normal file
27
docker/images/builder9/1.3/Dockerfile
Normal file
@@ -0,0 +1,27 @@
|
||||
############################################################
|
||||
#
|
||||
# Add armel and armhf
|
||||
#
|
||||
############################################################
|
||||
FROM opennetworklinux/builder9:1.2
|
||||
MAINTAINER Jeffrey Townsend <jeffrey.townsend@bigswitch.com>
|
||||
|
||||
RUN dpkg --add-architecture armel
|
||||
RUN dpkg --add-architecture armhf
|
||||
|
||||
RUN apt-get update && apt-get upgrade -y
|
||||
|
||||
RUN apt-get install -y \
|
||||
crossbuild-essential-armel \
|
||||
gcc-arm-linux-gnueabi \
|
||||
crossbuild-essential-armhf \
|
||||
gcc-arm-linux-gnueabi
|
||||
|
||||
RUN xapt -a armel libedit-dev ncurses-dev libsensors4-dev libwrap0-dev libssl-dev libsnmp-dev
|
||||
RUN xapt -a armhf libedit-dev ncurses-dev libsensors4-dev libwrap0-dev libssl-dev libsnmp-dev
|
||||
|
||||
#
|
||||
# Docker shell and other container tools.
|
||||
#
|
||||
COPY docker_shell /bin/docker_shell
|
||||
COPY container-id /bin/container-id
|
||||
19
docker/images/builder9/1.3/Makefile
Normal file
19
docker/images/builder9/1.3/Makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
VERSION=1.3
|
||||
USER=opennetworklinux
|
||||
REPO=builder9
|
||||
|
||||
TOOLS=../../../tools/docker_shell ../../../tools/container-id
|
||||
|
||||
build: check_version
|
||||
cp $(TOOLS) .
|
||||
docker build -t $(USER)/$(REPO):$(VERSION) .
|
||||
rm -rf $(notdir $(TOOLS))
|
||||
|
||||
#
|
||||
# Todo: Query remote repository to see if the request version already exists to avoid accidental overwrites
|
||||
# when a new image is built but the VERSION variable is not updated.
|
||||
#
|
||||
check_version:
|
||||
|
||||
push:
|
||||
docker push $(USER)/$(REPO):$(VERSION)
|
||||
@@ -1,6 +1,6 @@
|
||||
common:
|
||||
arch: all
|
||||
version: 1.4.0
|
||||
version: 1.3.10.0
|
||||
copyright: Copyright 2013, 2014, 2015 Big Switch Networks
|
||||
maintainer: support@bigswitch.com
|
||||
support: opennetworklinux@googlegroups.com
|
||||
|
||||
@@ -18,8 +18,8 @@ g_current_uid = os.getuid()
|
||||
g_timestamp = datetime.datetime.now().strftime("%Y-%m-%d.%H%M%S")
|
||||
|
||||
g_builder7_image_name="opennetworklinux/builder7:1.2"
|
||||
g_builder8_image_name="opennetworklinux/builder8:1.9"
|
||||
g_builder9_image_name="opennetworklinux/builder9:1.2"
|
||||
g_builder8_image_name="opennetworklinux/builder8:1.10"
|
||||
g_builder9_image_name="opennetworklinux/builder9:1.3"
|
||||
|
||||
g_default_image_name=g_builder8_image_name
|
||||
g_default_container_name = "%s_%s" % (g_current_user, g_timestamp)
|
||||
|
||||
12
make/config.armhf.mk
Normal file
12
make/config.armhf.mk
Normal file
@@ -0,0 +1,12 @@
|
||||
############################################################
|
||||
#
|
||||
# Open Network Linux
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.mk
|
||||
export TOOLCHAIN := arm-linux-gnueabihf
|
||||
export CROSS_COMPILER := $(TOOLCHAIN)-
|
||||
export ARCH := armhf
|
||||
export UARCH := ARMHF
|
||||
export ARCH_BOOT := uboot
|
||||
export __$(ARCH)__ := 1
|
||||
26
make/dtbs.mk
26
make/dtbs.mk
@@ -13,14 +13,30 @@ ifndef DTB_LIST
|
||||
DTB_LIST := $(patsubst %.dts,%.dtb,$(DTS_LIST))
|
||||
endif
|
||||
|
||||
%.dtb: %.dts
|
||||
$(ONL)/tools/dtc -I dts -O dtb -o $@ $<
|
||||
ifndef DTC
|
||||
ifdef KERNEL
|
||||
DTC := $(shell $(ONLPM) --find-file $(KERNEL) dtc)
|
||||
ifeq ($(DTC),)
|
||||
$(error No device tree compiler.)
|
||||
endif
|
||||
else
|
||||
DTC := $(ONL)/tools/dtc
|
||||
endif
|
||||
endif
|
||||
|
||||
.DEFAULT_GOAL := $(DTB_LIST)
|
||||
%.dtb: %.dts
|
||||
cpp -nostdinc -undef -x assembler-with-cpp $(foreach inc,$(INCLUDES),-I$(inc) ) $< > $(notdir $<).i
|
||||
$(DTC) $(foreach inc,$(INCLUDES),-i$(inc) ) $(DTC_OPTIONS) -I dts -O dtb -o $@ $(notdir $<).i
|
||||
rm $(notdir $<).i
|
||||
|
||||
.DEFAULT_GOAL := dtbs
|
||||
|
||||
dtbs: $(DTB_LIST)
|
||||
echo $(DTB_LIST) $(VPATH)
|
||||
$(MAKE) setup-clean
|
||||
|
||||
$(DTB_LIST): setup
|
||||
|
||||
clean::
|
||||
rm -rf *.dtb
|
||||
|
||||
setup::
|
||||
setup-clean::
|
||||
|
||||
@@ -174,7 +174,7 @@ endif
|
||||
MODSYNCLIST_DEFAULT := .config Module.symvers Makefile include scripts drivers \
|
||||
arch/x86/include arch/x86/Makefile \
|
||||
arch/powerpc/include arch/powerpc/Makefile arch/powerpc/lib arch/powerpc/boot/dts \
|
||||
arch/arm/include arch/arm/Makefile arch/arm/lib arch/arm/boot/dts
|
||||
arch/arm/include arch/arm/Makefile arch/arm/lib arch/arm/boot/dts arch/arm/kernel
|
||||
|
||||
MODSYNCLIST := $(MODSYNCLIST_DEFAULT) $(MODSYNCLIST_EXTRA) $(K_MODSYNCLIST)
|
||||
|
||||
|
||||
@@ -26,4 +26,4 @@ endif
|
||||
|
||||
modules:
|
||||
rm -rf lib
|
||||
ARCH=$(ARCH) $(ONL)/tools/scripts/kmodbuild.sh "$(KERNELS)" "$(KMODULES)" "$(SUBDIR)"
|
||||
ARCH=$(ARCH) $(ONL)/tools/scripts/kmodbuild.sh "$(KERNELS)" "$(KMODULES)" "$(SUBDIR)" "$(KINCLUDES)"
|
||||
|
||||
@@ -14,7 +14,7 @@ include $(ONL)/make/config.mk
|
||||
# directory tree.
|
||||
#
|
||||
ifndef ARCHES
|
||||
ARCHES := amd64 powerpc armel arm64 all
|
||||
ARCHES := amd64 powerpc armel armhf arm64 all
|
||||
endif
|
||||
|
||||
ONLPM_ENVIRONMENT = \
|
||||
|
||||
@@ -44,18 +44,21 @@ if [ "${NETHW}" ]; then
|
||||
ip link set dev ${NETDEV} addr ${NETHW}
|
||||
fi
|
||||
|
||||
# Default DHCP timeout is 10 requests in 10 seconds.
|
||||
NETRETRIES_DEFAULT=10
|
||||
NETRETRIES=${NETRETRIES:-$NETRETRIES_DEFAULT}
|
||||
if [ "$NETRETRIES" = "infinite" ]; then
|
||||
NETRETRIES=
|
||||
elif [ $(echo "$NETRETRIES" | tr -d '[:digit:]') ] || [ "$NETRETRIES" -lt 0 ]; then
|
||||
echo "Warning: the NETRETRIES setting is currently '$NETRETRIES'. This is invalid and the default value of $NETRETRIES_DEFAULT will be used instead."
|
||||
NETRETRIES=$NETRETRIES_DEFAULT
|
||||
fi
|
||||
case "${NETAUTO}" in
|
||||
dhcp|auto)
|
||||
# Default DHCP timeout is 10 requests in 10 seconds.
|
||||
NETRETRIES_DEFAULT=10
|
||||
NETRETRIES=${NETRETRIES:-$NETRETRIES_DEFAULT}
|
||||
if [ "$NETRETRIES" = "infinite" ]; then
|
||||
NETRETRIES=
|
||||
elif [ $(echo "$NETRETRIES" | tr -d '[:digit:]') ] || [ "$NETRETRIES" -lt 0 ]; then
|
||||
echo "Warning: the NETRETRIES setting is currently '$NETRETRIES'."
|
||||
echo "This is invalid and the default value of $NETRETRIES_DEFAULT will be used instead."
|
||||
NETRETRIES=$NETRETRIES_DEFAULT
|
||||
fi
|
||||
|
||||
echo 1 >/proc/sys/net/ipv6/conf/${NETDEV}/autoconf
|
||||
|
||||
if [ -n "${NETRETRIES}" ]; then
|
||||
if ! udhcpc --retries $NETRETRIES --now -i ${NETDEV}; then
|
||||
echo "**********************************************************************"
|
||||
@@ -81,6 +84,9 @@ case "${NETAUTO}" in
|
||||
up)
|
||||
ifconfig "${NETDEV}" up
|
||||
;;
|
||||
none)
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
if [ "${NETIP}" ] && [ "${NETMASK}" ] && [ "${NETIP#*/}" = "${NETIP}" ]; then
|
||||
NETIP=${NETIP}/$(ipcalc -p -s ${NETIP} ${NETMASK} | sed -n 's/PREFIX=//p')
|
||||
@@ -118,6 +124,7 @@ for i in $(seq 30); do
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
wait_link_up()
|
||||
{
|
||||
local intf=$1
|
||||
@@ -144,4 +151,5 @@ wait_link_up()
|
||||
if [ -n "${NETAUTO}" ]; then
|
||||
wait_link_up $NETDEV 100
|
||||
fi
|
||||
return 0
|
||||
|
||||
exit 0
|
||||
|
||||
230
packages/base/all/initrds/loader-initrd-files/src/bin/initrng.py
Normal file
230
packages/base/all/initrds/loader-initrd-files/src/bin/initrng.py
Normal file
@@ -0,0 +1,230 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Distributed under MIT License.
|
||||
See LICENSE file for full license text.
|
||||
"""
|
||||
|
||||
import fcntl
|
||||
import struct
|
||||
import sys
|
||||
import os
|
||||
import hashlib
|
||||
import logging
|
||||
import argparse
|
||||
|
||||
RNDADDENTROPY = 0x40085203 # from linux/random.h
|
||||
|
||||
def sha512sum(digest, fileName, blockSize = 16 * 1024):
|
||||
"""
|
||||
Take SHA512 digest from file given by it's name contents.
|
||||
|
||||
File opened in os.O_NONBLOCK mode to support FIFOs and
|
||||
special files like /dev/kmsg. Read data from files in
|
||||
blockSize (default 16kB) chunks to keep memory usage at
|
||||
minimum when used with large files.
|
||||
|
||||
Return True on success and False otherwise.
|
||||
"""
|
||||
|
||||
def read():
|
||||
try:
|
||||
return fp.read(blockSize)
|
||||
except IOError:
|
||||
return b''
|
||||
#end def
|
||||
|
||||
if digest is None:
|
||||
return False
|
||||
|
||||
try:
|
||||
fp = open(fileName, 'rb')
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
flags = fcntl.fcntl(fp, fcntl.F_GETFL) | os.O_NONBLOCK
|
||||
if fcntl.fcntl(fp, fcntl.F_SETFL, flags):
|
||||
fp.close()
|
||||
return False
|
||||
|
||||
for block in iter(read, b''):
|
||||
digest.update(block)
|
||||
|
||||
fp.close()
|
||||
return True
|
||||
|
||||
def sha512(digest, fileName):
|
||||
"""
|
||||
Computes sha512sum() optionally logging status.
|
||||
|
||||
For internal use only.
|
||||
|
||||
Return 1 on success and 0 on failure.
|
||||
"""
|
||||
|
||||
rc = sha512sum(digest, fileName)
|
||||
logging.debug("SHA512 (%s) = %s", fileName, 'ok' if rc else 'fail')
|
||||
return int(rc)
|
||||
|
||||
def add_entropy(digest, fileName = "/dev/urandom"):
|
||||
"""
|
||||
Adds digest.digest_size * 8 bits of entropy using ioctl(RNDADDENTROPY, ...)
|
||||
to increase entropy count if fileName is a character special file node and
|
||||
CAP_SYS_ADMIN is available (otherwise IOError is raised by fnctl.fnctl()).
|
||||
|
||||
Writes entropy to fileName if IOError exception is raised by fnctl.fnctl()
|
||||
or fileName is a regular file. Update entropy pool without incrementing
|
||||
entropy count if fileName is special character device like "/dev/urandom".
|
||||
"""
|
||||
|
||||
try:
|
||||
fp = open(fileName, 'ab')
|
||||
except IOError as e:
|
||||
return None, str(e)
|
||||
|
||||
size = digest.digest_size
|
||||
digest = digest.digest()
|
||||
|
||||
method = None
|
||||
err = None
|
||||
|
||||
do_ioctl = not os.path.isfile(fileName)
|
||||
|
||||
try:
|
||||
if do_ioctl:
|
||||
# from random(4):
|
||||
#
|
||||
# struct rand_pool_info {
|
||||
# int entropy_count;
|
||||
# int buf_size;
|
||||
# __u32 buf[0];
|
||||
# };
|
||||
#
|
||||
fmt = "ii{:d}s".format(size)
|
||||
rand_pool_info = struct.pack(fmt, size * 8, size, digest)
|
||||
fcntl.ioctl(fp, RNDADDENTROPY, rand_pool_info)
|
||||
else:
|
||||
raise IOError()
|
||||
except IOError:
|
||||
try:
|
||||
fp.write(digest)
|
||||
except IOError as e:
|
||||
err = str(e)
|
||||
else:
|
||||
method = "write"
|
||||
else:
|
||||
method = "ioctl"
|
||||
|
||||
return method, err
|
||||
|
||||
def init():
|
||||
prog_name = os.path.splitext(os.path.basename(__file__))[0]
|
||||
if not prog_name:
|
||||
prog_name = "initrng"
|
||||
|
||||
parser = argparse.ArgumentParser(description = 'Linux RNG early init')
|
||||
|
||||
# loglevel
|
||||
loglevels = {
|
||||
'crit' : 'CRITICAL',
|
||||
'err' : 'ERROR',
|
||||
'warn' : 'WARNING',
|
||||
'info' : 'INFO',
|
||||
'debug': 'DEBUG',
|
||||
}
|
||||
parser.add_argument('-l', '--loglevel', default = 'info',
|
||||
choices = list(loglevels.keys()),
|
||||
help = 'set program loging severity (level)')
|
||||
|
||||
# entropy_files
|
||||
dflt_entropy_files = [
|
||||
"/proc/timer_list",
|
||||
"/proc/buddyinfo",
|
||||
"/proc/interrupts",
|
||||
"/proc/softirqs",
|
||||
]
|
||||
|
||||
sched_debug = "/proc/sched_debug"
|
||||
if os.path.isfile(sched_debug):
|
||||
dflt_entropy_files.append(sched_debug)
|
||||
else:
|
||||
dflt_entropy_files.append("/proc/schedstat")
|
||||
|
||||
parser.add_argument('-e', '--entropy-file', default = [],
|
||||
action = 'append', dest = 'entropy_files', type = str,
|
||||
help = 'files to use as source of entropy ({:s})'.format(', '.join(dflt_entropy_files)))
|
||||
|
||||
# repeat
|
||||
dflt_repeat = 8
|
||||
parser.add_argument('-r', '--repeat', default = dflt_repeat,
|
||||
action = 'store', type = int,
|
||||
help = 'repeat entropy updates # times (default {:d})'.format(dflt_repeat))
|
||||
|
||||
# output
|
||||
dflt_output = "/dev/urandom"
|
||||
parser.add_argument('-o', '--output', default = dflt_output,
|
||||
action = 'store', type = str,
|
||||
help = 'file to output entropy (default "{:s}")'.format(dflt_output))
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(format = "{:s}: %(message)s".format(prog_name),
|
||||
level = getattr(logging, loglevels[args.loglevel]))
|
||||
|
||||
# adjust entropy_files
|
||||
if not args.entropy_files:
|
||||
args.entropy_files = dflt_entropy_files
|
||||
logging.debug("using default list of files as entropy source")
|
||||
|
||||
# adjust repeat
|
||||
repeat = args.repeat
|
||||
|
||||
if repeat <= 0:
|
||||
repeat = 1
|
||||
elif repeat > 65536:
|
||||
repeat = 65536
|
||||
|
||||
if repeat != args.repeat:
|
||||
logging.debug("adjust repeat count from %d to %d", args.repeat, repeat)
|
||||
args.repeat = repeat
|
||||
|
||||
# truncate entropy file
|
||||
output = args.output
|
||||
try:
|
||||
with open(output, 'wb'):
|
||||
pass
|
||||
except IOError:
|
||||
logging.debug("entropy file '%s' isn't writable", output)
|
||||
args = None
|
||||
else:
|
||||
logging.debug("entropy file '%s' is writable", output)
|
||||
|
||||
return args
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = init()
|
||||
|
||||
if args is None:
|
||||
logging.debug("fail to adjust/validate args")
|
||||
sys.exit(1)
|
||||
|
||||
logging.info("Linux Random Number Generator (RNG) early init")
|
||||
|
||||
entropy_files = args.entropy_files
|
||||
repeat = args.repeat
|
||||
|
||||
for x in range(1, repeat + 1):
|
||||
digest_sha512 = hashlib.sha512()
|
||||
|
||||
i = 0
|
||||
for f in entropy_files:
|
||||
i += sha512(digest_sha512, f)
|
||||
if not i:
|
||||
logging.debug("digest error for all entropy files, step %d", x)
|
||||
continue
|
||||
|
||||
method, err = add_entropy(digest_sha512, args.output)
|
||||
if err:
|
||||
logging.debug("error seeding Linux RNG, step %d: %s", x, err)
|
||||
else:
|
||||
logging.debug("seeded Linux RNG, method '%s', step %d", method, x)
|
||||
@@ -138,7 +138,7 @@ case $(uname -m) in
|
||||
ARCH_LIST="x86_64 amd64"
|
||||
;;
|
||||
armv7l)
|
||||
ARCH_LIST="armel"
|
||||
ARCH_LIST="armel armhf"
|
||||
;;
|
||||
aarch64)
|
||||
ARCH_LIST="arm64"
|
||||
|
||||
@@ -47,8 +47,10 @@ case "$(stat -f -c "%T" /tmp)" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# Grab cmdline settings
|
||||
# Initialize RNG early
|
||||
python /bin/initrng.py
|
||||
|
||||
# Grab cmdline settings
|
||||
touch /etc/onl/boot-config
|
||||
tr -s " " "\n" </proc/cmdline |
|
||||
while read -r l; do
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
#!/bin/sh
|
||||
############################################################
|
||||
onlfs mount images --rw
|
||||
(cd /mnt/onl/images && rm -f *.swi && wget $1)
|
||||
onlfs mount images
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import subprocess
|
||||
from onl.util import wget
|
||||
from onl.mounts import OnlMountContextReadWrite
|
||||
|
||||
ap = argparse.ArgumentParser('onlswi')
|
||||
ap.add_argument('url', help="The SWI URL")
|
||||
ap.add_argument('--onl-data', help='Use /mnt/onl/data for temporary storage.', action='store_true')
|
||||
|
||||
ops = ap.parse_args()
|
||||
(ex, filename, directory) = wget(ops.url, extension=".swi", temp_directory='/mnt/onl/data' if ops.onl_data else None)
|
||||
|
||||
if ex:
|
||||
print ex
|
||||
sys.exit(1)
|
||||
|
||||
with OnlMountContextReadWrite('ONL-IMAGES', None):
|
||||
subprocess.check_call("rm -f /mnt/onl/images/*.swi", shell=True)
|
||||
subprocess.check_call("cp %s /mnt/onl/images" % os.path.join(directory, filename), shell=True)
|
||||
|
||||
subprocess.check_call("rm -rf %s" % directory, shell=True)
|
||||
subprocess.check_call("ls -l /mnt/onl/images", shell=True)
|
||||
|
||||
@@ -10,7 +10,7 @@ installer:
|
||||
os_name: Open Network Linux
|
||||
grub:
|
||||
- $PLATFORM.cpio.gz
|
||||
- onl-loader-initrd-$PARCH.cpio.gz
|
||||
- onl-loader-initrd-amd64.cpio.gz
|
||||
|
||||
fit:
|
||||
- $PLATFORM.itb
|
||||
|
||||
@@ -46,12 +46,19 @@ default:
|
||||
=: kernel-3.2-lts-arm-iproc-all.bin.gz
|
||||
<<: *arm-iproc-kernel-package
|
||||
|
||||
arm-iproc-kernel-4-4-package: &arm-iproc-kernel-4-4-package
|
||||
package: onl-kernel-4.4-lts-arm-iproc-all:armel
|
||||
armel-iproc-4-14-kernel-package: &armel-iproc-4-14-kernel-package
|
||||
package: onl-kernel-4.14-lts-armel-iproc-all:armel
|
||||
|
||||
arm-iproc-kernel-4-4: &arm-iproc-kernel-4-4
|
||||
=: kernel-4.4-lts-arm-iproc-all.bin.gz
|
||||
<<: *arm-iproc-kernel-4-4-package
|
||||
armel-iproc-4-14-kernel: &armel-iproc-4-14-kernel
|
||||
=: kernel-4.14-lts-armel-iproc-all.bin.gz
|
||||
<<: *armel-iproc-4-14-kernel-package
|
||||
|
||||
armhf-iproc-4-14-kernel-package: &armhf-iproc-4-14-kernel-package
|
||||
package: onl-kernel-4.14-lts-armhf-iproc-all:armhf
|
||||
|
||||
armhf-iproc-4-14-kernel: &armhf-iproc-4-14-kernel
|
||||
=: kernel-4.14-lts-armhf-iproc-all.bin.gz
|
||||
<<: *armhf-iproc-4-14-kernel-package
|
||||
|
||||
arm64-kernel-package: &arm64-kernel-package
|
||||
package: onl-kernel-4.9-lts-arm64-all:arm64
|
||||
@@ -85,10 +92,14 @@ default:
|
||||
=: onl-loader-fit.itb
|
||||
package: onl-loader-fit:powerpc
|
||||
|
||||
arm-itb: &arm-itb
|
||||
armel-itb: &armel-itb
|
||||
=: onl-loader-fit.itb
|
||||
package: onl-loader-fit:armel
|
||||
|
||||
armhf-itb: &armhf-itb
|
||||
=: onl-loader-fit.itb
|
||||
package: onl-loader-fit:armhf
|
||||
|
||||
arm64-itb: &arm64-itb
|
||||
=: onl-loader-fit.itb
|
||||
package: onl-loader-fit:arm64
|
||||
|
||||
@@ -191,7 +191,7 @@ class OnlBootConfigNet(OnlBootConfig):
|
||||
if not self.is_ip_address(netdns):
|
||||
raise ValueError("NETDNS=%s is not a valid ip-address" % (netdns))
|
||||
|
||||
elif self.keys['NETAUTO'] not in ['dhcp', 'up']:
|
||||
elif self.keys['NETAUTO'] not in ['dhcp', 'up', 'none', '']:
|
||||
raise ValueError("The NETAUTO value '%s' is invalid." % self.keys['NETAUTO'])
|
||||
elif self.keys['NETAUTO'] == 'up' and self.NET_REQUIRED:
|
||||
raise ValueError("NETAUTO is 'up' but non-local networking is required.")
|
||||
|
||||
@@ -242,8 +242,9 @@ class OnieSysinfoApp(SubprocessMixin, object):
|
||||
with InitrdContext(initrd=initrd, log=self.log) as ctx:
|
||||
cmd = ['onie-sysinfo',]
|
||||
cmd.extend(self.args)
|
||||
cmd = 'IFS=;' + " ".join(cmd)
|
||||
cmd = ('chroot', ctx.dir,
|
||||
'/bin/sh', '-c', 'IFS=;' + " ".join(cmd))
|
||||
'/bin/sh', '-c', cmd,)
|
||||
try:
|
||||
self.output = self.check_output(cmd)
|
||||
ret = 0
|
||||
|
||||
@@ -8,11 +8,8 @@ import sys
|
||||
import os
|
||||
import argparse
|
||||
import logging
|
||||
import tempfile
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import yaml
|
||||
from onl.mounts import OnlMountManager, OnlMountContextReadOnly, OnlMountContextReadWrite
|
||||
from onl.sysconfig import sysconfig
|
||||
from onl.util import *
|
||||
@@ -50,39 +47,70 @@ class OnlPki(OnlServiceMixin):
|
||||
self.init_cert(force=force)
|
||||
|
||||
def init_key(self, force=False):
|
||||
with OnlPkiContextReadOnly(self.logger):
|
||||
if not os.path.exists(self.kpath) or force:
|
||||
self.logger.info("Generating private key...")
|
||||
cmd = "openssl genrsa -out %s %s" % (self.kpath, sysconfig.pki.key.len)
|
||||
with OnlPkiContextReadWrite(self.logger):
|
||||
if not os.path.isdir(self.CONFIG_PKI_DIR):
|
||||
os.makedirs(self.CONFIG_PKI_DIR)
|
||||
self._execute(cmd)
|
||||
self.init_cert(force=True)
|
||||
else:
|
||||
self.logger.info("Using existing private key.")
|
||||
need_key = False
|
||||
need_cert = False
|
||||
|
||||
if force:
|
||||
need_key = True
|
||||
else:
|
||||
with OnlPkiContextReadOnly(self.logger):
|
||||
if not os.path.exists(self.kpath):
|
||||
need_key = True
|
||||
|
||||
if need_key:
|
||||
self.logger.info("Generating private key...")
|
||||
cmd = ('openssl', 'genrsa',
|
||||
'-out', self.kpath,
|
||||
str(sysconfig.pki.key.len),)
|
||||
with OnlPkiContextReadWrite(self.logger):
|
||||
if not os.path.isdir(self.CONFIG_PKI_DIR):
|
||||
os.makedirs(self.CONFIG_PKI_DIR)
|
||||
self._execute(cmd, logLevel=logging.INFO)
|
||||
need_cert = True
|
||||
else:
|
||||
self.logger.info("Using existing private key.")
|
||||
|
||||
if need_cert:
|
||||
self.init_cert(force=True)
|
||||
|
||||
def init_cert(self, force=False):
|
||||
with OnlPkiContextReadOnly(self.logger):
|
||||
if not os.path.exists(self.cpath) or force:
|
||||
self.logger.info("Generating self-signed certificate...")
|
||||
csr = tempfile.NamedTemporaryFile(prefix="pki-", suffix=".csr", delete=False)
|
||||
csr.close()
|
||||
fields = [ "%s=%s" % (k, v) for k,v in sysconfig.pki.cert.csr.fields.iteritems() ]
|
||||
subject = "/" + "/".join(fields)
|
||||
self.logger.debug("Subject: '%s'", subject)
|
||||
self.logger.debug("CSR: %s", csr.name)
|
||||
with OnlPkiContextReadWrite(self.logger):
|
||||
if not os.path.isdir(self.CONFIG_PKI_DIR):
|
||||
os.makedirs(self.CONFIG_PKI_DIR)
|
||||
self._execute("""openssl req -new -batch -subj "%s" -key %s -out %s""" % (
|
||||
subject, self.kpath, csr.name))
|
||||
self._execute("""openssl x509 -req -days %s -sha256 -in %s -signkey %s -out %s""" % (
|
||||
sysconfig.pki.cert.csr.cdays,
|
||||
csr.name, self.kpath, self.cpath))
|
||||
os.unlink(csr.name)
|
||||
else:
|
||||
self.logger.info("Using existing certificate.")
|
||||
need_cert = False
|
||||
|
||||
if force:
|
||||
need_cert = True
|
||||
else:
|
||||
with OnlPkiContextReadOnly(self.logger):
|
||||
if not os.path.exists(self.cpath):
|
||||
need_cert = True
|
||||
|
||||
if need_cert:
|
||||
self.logger.info("Generating self-signed certificate...")
|
||||
csr = tempfile.NamedTemporaryFile(prefix="pki-", suffix=".csr", delete=False)
|
||||
csr.close()
|
||||
fields = [ "%s=%s" % (k, v) for k,v in sysconfig.pki.cert.csr.fields.iteritems() ]
|
||||
subject = "/" + "/".join(fields)
|
||||
self.logger.debug("Subject: '%s'", subject)
|
||||
self.logger.debug("CSR: %s", csr.name)
|
||||
with OnlPkiContextReadWrite(self.logger):
|
||||
if not os.path.isdir(self.CONFIG_PKI_DIR):
|
||||
os.makedirs(self.CONFIG_PKI_DIR)
|
||||
self._execute(('openssl', 'req',
|
||||
'-new', '-batch',
|
||||
'-subj', subject,
|
||||
'-key', self.kpath,
|
||||
'-out', csr.name,),
|
||||
logLevel=logging.INFO)
|
||||
self._execute(('openssl', 'x509',
|
||||
'-req',
|
||||
'-days', str(sysconfig.pki.cert.csr.cdays),
|
||||
'-sha256',
|
||||
'-in', csr.name,
|
||||
'-signkey', self.kpath,
|
||||
'-out', self.cpath,),
|
||||
logLevel=logging.INFO)
|
||||
os.unlink(csr.name)
|
||||
else:
|
||||
self.logger.info("Using existing certificate.")
|
||||
|
||||
@staticmethod
|
||||
def main():
|
||||
|
||||
@@ -452,6 +452,7 @@ class OnlPlatformBase(object):
|
||||
s = """Model: %s
|
||||
Manufacturer: %s
|
||||
Ports: %s (%s)
|
||||
Platform Revision: %s
|
||||
System Object Id: %s
|
||||
System Information:
|
||||
%s
|
||||
@@ -461,6 +462,7 @@ System Information:
|
||||
self.MANUFACTURER,
|
||||
self.PORT_COUNT,
|
||||
self.PORT_CONFIG,
|
||||
self.PLATFORM.split('-')[-1],
|
||||
self.sys_object_id(),
|
||||
str(self.onie_info),
|
||||
str(self.platform_info),
|
||||
@@ -504,6 +506,10 @@ class OnlPlatformPortConfig_48x25_8x100(object):
|
||||
PORT_COUNT=56
|
||||
PORT_CONFIG="48x25 + 8x100"
|
||||
|
||||
class OnlPlatformPortConfig_48x25_4x100_2x200(object):
|
||||
PORT_COUNT=54
|
||||
PORT_CONFIG="48x25 + 4x100 + 2x200"
|
||||
|
||||
class OnlPlatformPortConfig_32x40(object):
|
||||
PORT_COUNT=32
|
||||
PORT_CONFIG="32x40"
|
||||
@@ -539,3 +545,11 @@ class OnlPlatformPortConfig_12x10_3x100(object):
|
||||
class OnlPlatformPortConfig_24x10_2x100(object):
|
||||
PORT_COUNT=26
|
||||
PORT_CONFIG="24x10 + 2x100"
|
||||
|
||||
class OnlPlatformPortConfig_20x100(object):
|
||||
PORT_COUNT=20
|
||||
PORT_CONFIG="20x100"
|
||||
|
||||
class OnlPlatformPortConfig_16x10_8x25_2x100(object):
|
||||
PORT_COUNT=26
|
||||
PORT_CONFIG="16x10 + 8x25 + 2x100"
|
||||
|
||||
@@ -33,6 +33,7 @@ def baseconfig():
|
||||
'i386-linux-gnu',
|
||||
'x86_64-linux-gnu',
|
||||
'arm-linux-gnueabi',
|
||||
'arm-linux-gnueabihf',
|
||||
'aarch64-linux-gnu',
|
||||
]
|
||||
|
||||
|
||||
@@ -41,11 +41,7 @@ class OnlSystemConfig(object):
|
||||
self.variables = {}
|
||||
self.variables['PLATFORM'] = platform.platform()
|
||||
self.variables['ARCH'] = pp.machine()
|
||||
self.variables['PARCH'] = dict(ppc='powerpc',
|
||||
x86_64='amd64',
|
||||
armv7l='armel',
|
||||
aarch64='arm64')[pp.machine()]
|
||||
|
||||
self.variables['PARCH'] = onl.util.dpkg_architecture()
|
||||
self.config = {}
|
||||
for dir_ in self.SYSTEM_CONFIG_DIRS:
|
||||
if os.path.isdir(dir_):
|
||||
|
||||
@@ -15,6 +15,7 @@ import string
|
||||
import argparse
|
||||
import yaml
|
||||
from time import sleep
|
||||
import onl.util
|
||||
|
||||
from onl.platform.current import OnlPlatform, OnlPlatformName
|
||||
from onl.mounts import OnlMountManager, OnlMountContextReadOnly, OnlMountContextReadWrite
|
||||
@@ -37,7 +38,7 @@ class BaseUpgrade(object):
|
||||
self.init_argparser()
|
||||
self.load_config()
|
||||
self.arch = pp.machine()
|
||||
self.parch = dict(ppc='powerpc', x86_64='amd64', armv7l='armel', aarch64='arm64')[self.arch]
|
||||
self.parch = onl.util.dpkg_architecture()
|
||||
self.platform = OnlPlatform()
|
||||
self.init()
|
||||
|
||||
|
||||
@@ -1,18 +1,50 @@
|
||||
import subprocess
|
||||
import logging
|
||||
import os
|
||||
|
||||
class OnlServiceMixin(object):
|
||||
def _execute(self, cmd, root=False, ex=True):
|
||||
self.logger.debug("Executing: %s" % cmd)
|
||||
|
||||
def _execute(self, cmd,
|
||||
root=False, ex=True,
|
||||
logLevel=logging.DEBUG):
|
||||
self.logger.log(logLevel, "Executing: %s", cmd)
|
||||
|
||||
if isinstance(cmd, basestring):
|
||||
shell = True
|
||||
else:
|
||||
shell = False
|
||||
|
||||
if root is True and os.getuid() != 0:
|
||||
cmd = "sudo " + cmd
|
||||
if isinstance(cmd, basestring):
|
||||
cmd = "sudo " + cmd
|
||||
else:
|
||||
cmd = ['sudo',] + list(cmd)
|
||||
|
||||
try:
|
||||
subprocess.check_call(cmd, shell=True)
|
||||
except Exception, e:
|
||||
pipe = subprocess.Popen(cmd, shell=shell,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
except OSError as e:
|
||||
if ex:
|
||||
self.logger.error("Command failed: %s" % e)
|
||||
self.logger.error("Command did not start: %s (%s)",
|
||||
str(e), str(e.child_traceback),)
|
||||
raise
|
||||
else:
|
||||
return e.returncode
|
||||
return -1
|
||||
|
||||
out, _ = pipe.communicate()
|
||||
code = pipe.wait()
|
||||
|
||||
lvl = logging.WARN if code else logLevel
|
||||
out = (out or "").rstrip()
|
||||
for line in out.splitlines(False):
|
||||
self.logger.log(lvl, ">>> %s", line)
|
||||
|
||||
if ex and code:
|
||||
self.logger.error("Command failed with code %s", code)
|
||||
raise subprocess.CalledProcessError(code, cmd)
|
||||
|
||||
return code
|
||||
|
||||
def _raise(self, msg, klass):
|
||||
self.logger.critical(msg)
|
||||
@@ -89,3 +121,36 @@ def dmerge(d1, d2):
|
||||
q.append((v1, v2, c3[k],))
|
||||
|
||||
return merged
|
||||
|
||||
|
||||
def wget(url, directory=None, temp_directory=None, extension=None):
|
||||
|
||||
import urllib2
|
||||
import tempfile
|
||||
|
||||
try:
|
||||
response = urllib2.urlopen(url)
|
||||
filename = os.path.basename(urllib2.urlparse.urlparse(response.url).path)
|
||||
except Exception, e:
|
||||
return (e, None, None)
|
||||
|
||||
if extension and not filename.endswith("%s" % extension):
|
||||
return (ValueError("The requested filename does not have the correct extension (%s)" % extension), None, None)
|
||||
|
||||
if directory is None:
|
||||
directory = tempfile.mkdtemp(dir=temp_directory)
|
||||
|
||||
if os.path.exists(os.path.join(directory, filename)):
|
||||
return (ValueError("The requested filename already exists in the target directory."), None, None)
|
||||
|
||||
try:
|
||||
subprocess.check_call("wget -P %s %s" % (directory, url), shell=True)
|
||||
return (None, filename, directory)
|
||||
except subprocess.CalledProcessError, e:
|
||||
return (e, None, None)
|
||||
|
||||
def dpkg_architecture():
|
||||
try:
|
||||
return subprocess.check_output(['/usr/bin/dpkg', '--print-architecture']).strip()
|
||||
except (subprocess.CalledProcessError, OSError):
|
||||
return None
|
||||
|
||||
@@ -4,7 +4,7 @@ endif
|
||||
|
||||
.PHONY: onl-loader-fit.itb onl-loader-fit.its
|
||||
|
||||
onl-loader-fit.itb:
|
||||
onl-loader-fit.itb: its
|
||||
$(ONL)/tools/flat-image-tree.py --initrd onl-loader-initrd:$(ARCH),onl-loader-initrd-$(ARCH).cpio.gz --arch $(ARCH) --add-platform initrd --itb $@
|
||||
$(ONLPM) --copy-file onl-loader-initrd:$(ARCH) manifest.json .
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
Index: linux-3.16.39/drivers/mfd/lpc_ich.c
|
||||
===================================================================
|
||||
--- linux-3.16.39.orig/drivers/mfd/lpc_ich.c
|
||||
+++ linux-3.16.39/drivers/mfd/lpc_ich.c
|
||||
@@ -493,6 +493,7 @@ static struct lpc_ich_info lpc_chipset_i
|
||||
[LPC_LPT] = {
|
||||
.name = "Lynx Point",
|
||||
.iTCO_version = 2,
|
||||
+ .gpio_version = ICH_V5_GPIO,
|
||||
},
|
||||
[LPC_LPT_LP] = {
|
||||
.name = "Lynx Point_LP",
|
||||
@@ -29,3 +29,4 @@ driver-igb-netberg-aurora.patch
|
||||
driver-hid-cp2112-mods.patch
|
||||
gcc-no-pie.patch
|
||||
driver-ixgbe-version-5.2.4.patch
|
||||
drivers-mfd-lpc_ich.patch
|
||||
|
||||
2
packages/base/any/kernels/4.14-lts/configs/armel-iproc-all/.gitignore
vendored
Normal file
2
packages/base/any/kernels/4.14-lts/configs/armel-iproc-all/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
linux-4.14*
|
||||
kernel-4.14*
|
||||
@@ -1,4 +1,4 @@
|
||||
############################################################
|
||||
###########################################################
|
||||
# <bsn.cl fy=2015 v=onl>
|
||||
#
|
||||
# Copyright 2015 Big Switch Networks, Inc.
|
||||
@@ -29,13 +29,14 @@ endif
|
||||
K_PATCH_DIR := $(THIS_DIR)/patches
|
||||
|
||||
include ../../kconfig.mk
|
||||
K_CONFIG := arm-iproc-all.config
|
||||
K_CONFIG := armel-iproc-all.config
|
||||
K_BUILD_TARGET := Image
|
||||
K_COPY_SRC := arch/arm/boot/Image
|
||||
K_COPY_GZIP := 1
|
||||
ifndef K_COPY_DST
|
||||
K_COPY_DST := kernel-4.4-lts-arm-iproc-all.bin.gz
|
||||
K_COPY_DST := kernel-4.14-lts-armel-iproc-all.bin.gz
|
||||
endif
|
||||
|
||||
export ARCH=arm
|
||||
|
||||
include $(ONL)/make/kbuild.mk
|
||||
File diff suppressed because it is too large
Load Diff
2
packages/base/any/kernels/4.14-lts/configs/armhf-iproc-all/.gitignore
vendored
Normal file
2
packages/base/any/kernels/4.14-lts/configs/armhf-iproc-all/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
linux-4.14*
|
||||
kernel-4.14*
|
||||
@@ -0,0 +1,42 @@
|
||||
###########################################################
|
||||
# <bsn.cl fy=2015 v=onl>
|
||||
#
|
||||
# Copyright 2015 Big Switch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
|
||||
THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
include $(ONL)/make/config.mk
|
||||
|
||||
ifndef K_TARGET_DIR
|
||||
K_TARGET_DIR := $(THIS_DIR)
|
||||
endif
|
||||
|
||||
K_PATCH_DIR := $(THIS_DIR)/patches
|
||||
|
||||
include ../../kconfig.mk
|
||||
K_CONFIG := armhf-iproc-all.config
|
||||
K_BUILD_TARGET := Image
|
||||
K_COPY_SRC := arch/arm/boot/Image
|
||||
K_COPY_GZIP := 1
|
||||
ifndef K_COPY_DST
|
||||
K_COPY_DST := kernel-4.14-lts-armhf-iproc-all.bin.gz
|
||||
endif
|
||||
|
||||
export ARCH=arm
|
||||
|
||||
include $(ONL)/make/kbuild.mk
|
||||
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,7 @@ CONFIG_ZONE_DMA32=y
|
||||
CONFIG_AUDIT_ARCH=y
|
||||
CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
|
||||
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
|
||||
CONFIG_HAVE_INTEL_TXT=y
|
||||
CONFIG_X86_64_SMP=y
|
||||
CONFIG_ARCH_SUPPORTS_UPROBES=y
|
||||
CONFIG_FIX_EARLYCON_MEM=y
|
||||
@@ -557,6 +558,7 @@ CONFIG_ARCH_ENABLE_THP_MIGRATION=y
|
||||
CONFIG_PHYS_ADDR_T_64BIT=y
|
||||
CONFIG_BOUNCE=y
|
||||
CONFIG_VIRT_TO_BUS=y
|
||||
CONFIG_MMU_NOTIFIER=y
|
||||
CONFIG_KSM=y
|
||||
CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
|
||||
CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y
|
||||
@@ -1708,10 +1710,10 @@ CONFIG_MD=y
|
||||
CONFIG_BLK_DEV_MD=y
|
||||
# CONFIG_MD_AUTODETECT is not set
|
||||
# CONFIG_MD_LINEAR is not set
|
||||
# CONFIG_MD_RAID0 is not set
|
||||
# CONFIG_MD_RAID1 is not set
|
||||
# CONFIG_MD_RAID10 is not set
|
||||
# CONFIG_MD_RAID456 is not set
|
||||
CONFIG_MD_RAID0=y
|
||||
CONFIG_MD_RAID1=y
|
||||
CONFIG_MD_RAID10=y
|
||||
CONFIG_MD_RAID456=y
|
||||
# CONFIG_MD_MULTIPATH is not set
|
||||
# CONFIG_MD_FAULTY is not set
|
||||
# CONFIG_BCACHE is not set
|
||||
@@ -1719,19 +1721,25 @@ CONFIG_BLK_DEV_DM_BUILTIN=y
|
||||
CONFIG_BLK_DEV_DM=y
|
||||
# CONFIG_DM_MQ_DEFAULT is not set
|
||||
# CONFIG_DM_DEBUG is not set
|
||||
CONFIG_DM_BUFIO=y
|
||||
# CONFIG_DM_DEBUG_BLOCK_MANAGER_LOCKING is not set
|
||||
CONFIG_DM_BIO_PRISON=y
|
||||
CONFIG_DM_PERSISTENT_DATA=y
|
||||
CONFIG_DM_CRYPT=y
|
||||
# CONFIG_DM_SNAPSHOT is not set
|
||||
# CONFIG_DM_THIN_PROVISIONING is not set
|
||||
CONFIG_DM_SNAPSHOT=y
|
||||
CONFIG_DM_THIN_PROVISIONING=y
|
||||
# CONFIG_DM_CACHE is not set
|
||||
# CONFIG_DM_ERA is not set
|
||||
# CONFIG_DM_MIRROR is not set
|
||||
# CONFIG_DM_RAID is not set
|
||||
CONFIG_DM_MIRROR=y
|
||||
# CONFIG_DM_LOG_USERSPACE is not set
|
||||
CONFIG_DM_RAID=y
|
||||
# CONFIG_DM_ZERO is not set
|
||||
# CONFIG_DM_MULTIPATH is not set
|
||||
# CONFIG_DM_DELAY is not set
|
||||
# CONFIG_DM_UEVENT is not set
|
||||
CONFIG_DM_UEVENT=y
|
||||
# CONFIG_DM_FLAKEY is not set
|
||||
# CONFIG_DM_VERITY is not set
|
||||
CONFIG_DM_VERITY=y
|
||||
# CONFIG_DM_VERITY_FEC is not set
|
||||
# CONFIG_DM_SWITCH is not set
|
||||
# CONFIG_DM_LOG_WRITES is not set
|
||||
# CONFIG_DM_INTEGRITY is not set
|
||||
@@ -2270,7 +2278,7 @@ CONFIG_DEVPORT=y
|
||||
# I2C support
|
||||
#
|
||||
CONFIG_I2C=y
|
||||
# CONFIG_ACPI_I2C_OPREGION is not set
|
||||
CONFIG_ACPI_I2C_OPREGION=y
|
||||
CONFIG_I2C_BOARDINFO=y
|
||||
CONFIG_I2C_COMPAT=y
|
||||
CONFIG_I2C_CHARDEV=y
|
||||
@@ -2327,11 +2335,11 @@ CONFIG_I2C_PIIX4=y
|
||||
# CONFIG_I2C_DESIGNWARE_PCI is not set
|
||||
# CONFIG_I2C_EMEV2 is not set
|
||||
# CONFIG_I2C_GPIO is not set
|
||||
# CONFIG_I2C_OCORES is not set
|
||||
CONFIG_I2C_OCORES=y
|
||||
CONFIG_I2C_PCA_PLATFORM=y
|
||||
# CONFIG_I2C_PXA_PCI is not set
|
||||
# CONFIG_I2C_SIMTEC is not set
|
||||
# CONFIG_I2C_XILINX is not set
|
||||
CONFIG_I2C_XILINX=y
|
||||
|
||||
#
|
||||
# External I2C/SMBus adapter drivers
|
||||
@@ -2804,6 +2812,7 @@ CONFIG_MFD_CORE=y
|
||||
CONFIG_LPC_ICH=y
|
||||
CONFIG_LPC_SCH=y
|
||||
# CONFIG_INTEL_SOC_PMIC is not set
|
||||
# CONFIG_INTEL_SOC_PMIC_BXTWC is not set
|
||||
# CONFIG_INTEL_SOC_PMIC_CHTWC is not set
|
||||
CONFIG_MFD_INTEL_LPSS=y
|
||||
CONFIG_MFD_INTEL_LPSS_ACPI=y
|
||||
@@ -3411,15 +3420,16 @@ CONFIG_SYNC_FILE=y
|
||||
# CONFIG_SW_SYNC is not set
|
||||
# CONFIG_AUXDISPLAY is not set
|
||||
CONFIG_UIO=y
|
||||
# CONFIG_UIO_CIF is not set
|
||||
# CONFIG_UIO_PDRV_GENIRQ is not set
|
||||
# CONFIG_UIO_DMEM_GENIRQ is not set
|
||||
CONFIG_UIO_CIF=y
|
||||
CONFIG_UIO_PDRV_GENIRQ=y
|
||||
CONFIG_UIO_DMEM_GENIRQ=y
|
||||
# CONFIG_UIO_AEC is not set
|
||||
# CONFIG_UIO_SERCOS3 is not set
|
||||
# CONFIG_UIO_PCI_GENERIC is not set
|
||||
CONFIG_UIO_PCI_GENERIC=y
|
||||
# CONFIG_UIO_NETX is not set
|
||||
# CONFIG_UIO_PRUSS is not set
|
||||
# CONFIG_UIO_MF624 is not set
|
||||
# CONFIG_VFIO is not set
|
||||
CONFIG_VIRT_DRIVERS=y
|
||||
CONFIG_VIRTIO=y
|
||||
|
||||
@@ -3463,9 +3473,10 @@ CONFIG_X86_PLATFORM_DEVICES=y
|
||||
# CONFIG_INTEL_RST is not set
|
||||
# CONFIG_INTEL_SMARTCONNECT is not set
|
||||
# CONFIG_PVPANIC is not set
|
||||
# CONFIG_INTEL_PMC_IPC is not set
|
||||
CONFIG_INTEL_PMC_IPC=y
|
||||
# CONFIG_SURFACE_PRO3_BUTTON is not set
|
||||
# CONFIG_INTEL_PUNIT_IPC is not set
|
||||
CONFIG_INTEL_PUNIT_IPC=y
|
||||
CONFIG_INTEL_TELEMETRY=y
|
||||
# CONFIG_MLX_PLATFORM is not set
|
||||
# CONFIG_MLX_CPLD_PLATFORM is not set
|
||||
# CONFIG_INTEL_TURBO_MAX_3 is not set
|
||||
@@ -3500,14 +3511,21 @@ CONFIG_CLKBLD_I8253=y
|
||||
CONFIG_MAILBOX=y
|
||||
CONFIG_PCC=y
|
||||
# CONFIG_ALTERA_MBOX is not set
|
||||
CONFIG_IOMMU_API=y
|
||||
CONFIG_IOMMU_SUPPORT=y
|
||||
|
||||
#
|
||||
# Generic IOMMU Pagetable Support
|
||||
#
|
||||
# CONFIG_AMD_IOMMU is not set
|
||||
# CONFIG_INTEL_IOMMU is not set
|
||||
# CONFIG_IRQ_REMAP is not set
|
||||
CONFIG_IOMMU_IOVA=y
|
||||
CONFIG_AMD_IOMMU=y
|
||||
CONFIG_AMD_IOMMU_V2=y
|
||||
CONFIG_DMAR_TABLE=y
|
||||
CONFIG_INTEL_IOMMU=y
|
||||
# CONFIG_INTEL_IOMMU_SVM is not set
|
||||
# CONFIG_INTEL_IOMMU_DEFAULT_ON is not set
|
||||
CONFIG_INTEL_IOMMU_FLOPPY_WA=y
|
||||
CONFIG_IRQ_REMAP=y
|
||||
|
||||
#
|
||||
# Remoteproc drivers
|
||||
@@ -4017,6 +4035,7 @@ CONFIG_PROVIDE_OHCI1394_DMA_INIT=y
|
||||
# CONFIG_INTERVAL_TREE_TEST is not set
|
||||
# CONFIG_PERCPU_TEST is not set
|
||||
# CONFIG_ATOMIC64_SELFTEST is not set
|
||||
# CONFIG_ASYNC_RAID6_TEST is not set
|
||||
# CONFIG_TEST_HEXDUMP is not set
|
||||
# CONFIG_TEST_STRING_HELPERS is not set
|
||||
# CONFIG_TEST_KSTRTOX is not set
|
||||
@@ -4095,6 +4114,7 @@ CONFIG_SECURITY_NETWORK=y
|
||||
CONFIG_PAGE_TABLE_ISOLATION=y
|
||||
# CONFIG_SECURITY_NETWORK_XFRM is not set
|
||||
# CONFIG_SECURITY_PATH is not set
|
||||
# CONFIG_INTEL_TXT is not set
|
||||
CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR=y
|
||||
# CONFIG_HARDENED_USERCOPY is not set
|
||||
# CONFIG_FORTIFY_SOURCE is not set
|
||||
@@ -4112,6 +4132,12 @@ CONFIG_INTEGRITY_AUDIT=y
|
||||
# CONFIG_EVM is not set
|
||||
CONFIG_DEFAULT_SECURITY_DAC=y
|
||||
CONFIG_DEFAULT_SECURITY=""
|
||||
CONFIG_XOR_BLOCKS=y
|
||||
CONFIG_ASYNC_CORE=y
|
||||
CONFIG_ASYNC_MEMCPY=y
|
||||
CONFIG_ASYNC_XOR=y
|
||||
CONFIG_ASYNC_PQ=y
|
||||
CONFIG_ASYNC_RAID6_RECOV=y
|
||||
CONFIG_CRYPTO=y
|
||||
|
||||
#
|
||||
@@ -4301,6 +4327,7 @@ CONFIG_BINARY_PRINTF=y
|
||||
#
|
||||
# Library routines
|
||||
#
|
||||
CONFIG_RAID6_PQ=y
|
||||
CONFIG_BITREVERSE=y
|
||||
# CONFIG_HAVE_ARCH_BITREVERSE is not set
|
||||
CONFIG_RATIONAL=y
|
||||
|
||||
32416
packages/base/any/kernels/4.14-lts/patches/brcm-iproc-4.14.patch
Normal file
32416
packages/base/any/kernels/4.14-lts/patches/brcm-iproc-4.14.patch
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,86 @@
|
||||
diff -urpN a/drivers/i2c/busses/xgs_iproc_smbus.c b/drivers/i2c/busses/xgs_iproc_smbus.c
|
||||
--- a/drivers/i2c/busses/xgs_iproc_smbus.c 2018-12-17 15:00:29.412457650 +0000
|
||||
+++ b/drivers/i2c/busses/xgs_iproc_smbus.c 2018-12-17 15:01:26.255275662 +0000
|
||||
@@ -52,6 +52,8 @@
|
||||
(regval & ~(mask)) | \
|
||||
((fldval) << (startbit))
|
||||
|
||||
+//#define IPROC_SMB_DBG 1
|
||||
+
|
||||
typedef enum iproc_smb_clk_freq {
|
||||
I2C_SPEED_100KHz = 0,
|
||||
I2C_SPEED_400KHz = 1,
|
||||
@@ -178,7 +180,7 @@ static int iproc_smb_set_clk_freq(void _
|
||||
SETREGFLDVAL(regval, val, CCB_SMB_TIMGCFG_MODE400_MASK,
|
||||
CCB_SMB_TIMGCFG_MODE400_SHIFT);
|
||||
writel(regval, base_addr + CCB_SMB_TIMGCFG_REG);
|
||||
-
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -208,9 +210,20 @@ static int iproc_smbus_block_init(struct
|
||||
udelay(100);
|
||||
|
||||
/* Set default clock frequency */
|
||||
- if (of_property_read_u32(dn, "clock-frequency", &i2c_clk_freq))
|
||||
- /*no property available, use default: 100KHz*/
|
||||
- i2c_clk_freq = I2C_SPEED_100KHz;
|
||||
+ if (of_property_read_u32(dn, "clock-frequency", &i2c_clk_freq)) {
|
||||
+ /*no property available, use default: 100KHz*/
|
||||
+ i2c_clk_freq = 100000;
|
||||
+ }
|
||||
+
|
||||
+/* Edgecore patch */
|
||||
+ if (i2c_clk_freq == 400000) {
|
||||
+ dev_info(dev->dev, "bus set to %u Hz\n", i2c_clk_freq);
|
||||
+ i2c_clk_freq = I2C_SPEED_400KHz;
|
||||
+ } else {
|
||||
+ dev_info(dev->dev, "bus set to %u Hz\n", 100000);
|
||||
+ i2c_clk_freq = I2C_SPEED_100KHz;
|
||||
+ }
|
||||
+
|
||||
iproc_smb_set_clk_freq(base_addr, i2c_clk_freq);
|
||||
|
||||
/* Disable intrs */
|
||||
@@ -577,7 +590,9 @@ static int iproc_smb_data_send(struct i2
|
||||
|
||||
if (regval != MSTR_STS_XACT_SUCCESS) {
|
||||
/* We can flush Tx FIFO here */
|
||||
+#ifdef IPROC_SMB_DBG
|
||||
dev_err(dev->dev, "Send: Error in transaction\n");
|
||||
+#endif
|
||||
return -EREMOTEIO;
|
||||
}
|
||||
}
|
||||
@@ -662,7 +677,9 @@ static int iproc_smb_data_recv(struct i2
|
||||
|
||||
if (regval != MSTR_STS_XACT_SUCCESS) {
|
||||
/* We can flush Tx FIFO here */
|
||||
+#ifdef IPROC_SMB_DBG
|
||||
dev_info(dev->dev, "Error in transaction\n");
|
||||
+#endif
|
||||
return -EREMOTEIO;
|
||||
}
|
||||
}
|
||||
@@ -840,8 +857,10 @@ static int iproc_smb_xfer(struct i2c_ada
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
+#ifdef IPROC_SMB_DBG
|
||||
dev_info(dev->dev, "%s error accessing\n",
|
||||
(read_write == I2C_SMBUS_READ) ? "Read" : "Write");
|
||||
+#endif
|
||||
up(&dev->xfer_lock);
|
||||
return -EREMOTEIO;
|
||||
}
|
||||
@@ -856,7 +875,8 @@ static int iproc_smb_xfer(struct i2c_ada
|
||||
}
|
||||
}
|
||||
|
||||
- msleep(1);
|
||||
+ /* Edge-core comments out the sleep to speed up EEPROM dump */
|
||||
+ //msleep(1);
|
||||
up(&dev->xfer_lock);
|
||||
|
||||
return (rc);
|
||||
@@ -0,0 +1,26 @@
|
||||
diff -urpN a/drivers/usb/phy/phy-xgs-iproc.c b/drivers/usb/phy/phy-xgs-iproc.c
|
||||
--- a/drivers/usb/phy/phy-xgs-iproc.c 2018-12-17 14:49:55.121649311 +0000
|
||||
+++ b/drivers/usb/phy/phy-xgs-iproc.c 2018-12-17 14:50:06.529412019 +0000
|
||||
@@ -161,12 +161,22 @@ static int xgs_iproc_usb_phy_mode(struct
|
||||
int usb_mode = IPROC_USB_MODE_HOST;
|
||||
u32 __maybe_unused val;
|
||||
int __maybe_unused gpio_pin, ret;
|
||||
+ const char *phy_mode_str;
|
||||
|
||||
if (!wrap_base)
|
||||
dev_warn(dev, "no wrap base addr");
|
||||
|
||||
if (of_device_is_compatible(dn, "brcm,usb-phy-hx4") ||
|
||||
of_device_is_compatible(dn, "brcm,usb-phy-kt2")) {
|
||||
+
|
||||
+ /* Edge-core patch: use "usb-phy-mode" in dts to decide host/device mode */
|
||||
+ if (!of_property_read_string(dn, "usb-phy-mode", &phy_mode_str)) {
|
||||
+ if (!strcasecmp(phy_mode_str, "host"))
|
||||
+ return IPROC_USB_MODE_HOST;
|
||||
+ if (!strcasecmp(phy_mode_str, "device"))
|
||||
+ return IPROC_USB_MODE_DEVICE;
|
||||
+ }
|
||||
+
|
||||
/* gpio pin 4 to control host/device mode */
|
||||
gpio_pin = of_get_named_gpio(dev->of_node, "usbdev-gpio", 0);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
brcm-iproc-4.14.patch
|
||||
drivers-usb-phy-phy-xgs-iproc-usb-phy-mode.patch
|
||||
drivers-i2c-busses-xgs_iproc_smbus-clk-freq.patch
|
||||
0001-drivers-i2c-muxes-pca954x-deselect-on-exit.patch
|
||||
0002-driver-support-intel-igb-bcm5461S-phy.patch
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
kernel-4.4-brcm-iproc.patch
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Linux/x86_64 4.9.75 Kernel Configuration
|
||||
# Linux/x86 4.9.75 Kernel Configuration
|
||||
#
|
||||
CONFIG_64BIT=y
|
||||
CONFIG_X86_64=y
|
||||
@@ -2273,7 +2273,7 @@ CONFIG_PTP_1588_CLOCK=y
|
||||
CONFIG_GPIOLIB=y
|
||||
CONFIG_GPIO_ACPI=y
|
||||
# CONFIG_DEBUG_GPIO is not set
|
||||
# CONFIG_GPIO_SYSFS is not set
|
||||
CONFIG_GPIO_SYSFS=y
|
||||
|
||||
#
|
||||
# Memory mapped GPIO drivers
|
||||
@@ -2301,7 +2301,7 @@ CONFIG_GPIO_ACPI=y
|
||||
# CONFIG_GPIO_ADP5588 is not set
|
||||
# CONFIG_GPIO_MAX7300 is not set
|
||||
# CONFIG_GPIO_MAX732X is not set
|
||||
# CONFIG_GPIO_PCA953X is not set
|
||||
CONFIG_GPIO_PCA953X=m
|
||||
# CONFIG_GPIO_PCF857X is not set
|
||||
# CONFIG_GPIO_SX150X is not set
|
||||
# CONFIG_GPIO_TPIC2810 is not set
|
||||
@@ -2504,7 +2504,7 @@ CONFIG_SENSORS_UCD9200=y
|
||||
# CONFIG_SENSORS_THMC50 is not set
|
||||
CONFIG_SENSORS_TMP102=y
|
||||
# CONFIG_SENSORS_TMP103 is not set
|
||||
# CONFIG_SENSORS_TMP401 is not set
|
||||
CONFIG_SENSORS_TMP401=m
|
||||
# CONFIG_SENSORS_TMP421 is not set
|
||||
# CONFIG_SENSORS_VIA_CPUTEMP is not set
|
||||
# CONFIG_SENSORS_VIA686A is not set
|
||||
@@ -3880,7 +3880,7 @@ CONFIG_RAS=y
|
||||
#
|
||||
# CONFIG_ANDROID is not set
|
||||
# CONFIG_LIBNVDIMM is not set
|
||||
CONFIG_NVMEM=m
|
||||
CONFIG_NVMEM=y
|
||||
# CONFIG_STM is not set
|
||||
# CONFIG_INTEL_TH is not set
|
||||
|
||||
|
||||
580
packages/base/any/kernels/modules/accton_i2c_psu.c
Executable file
580
packages/base/any/kernels/modules/accton_i2c_psu.c
Executable file
@@ -0,0 +1,580 @@
|
||||
/*
|
||||
* An hwmon driver for the Accton Redundant Power Module
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/module.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>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define DRIVER_DESCRIPTION_NAME "accton i2c psu driver"
|
||||
/* PMBus Protocol. */
|
||||
#define PMBUS_LITERAL_DATA_MULTIPLIER 1000
|
||||
#define PMBUS_REGISTER_VOUT_MODE 0x20
|
||||
#define PMBUS_REGISTER_STATUS_BYTE 0x78
|
||||
#define PMBUS_REGISTER_STATUS_WORD 0x79
|
||||
#define PMBUS_REGISTER_STATUS_FAN 0x81
|
||||
#define PMBUS_REGISTER_READ_VIN 0x88
|
||||
#define PMBUS_REGISTER_READ_IIN 0x89
|
||||
#define PMBUS_REGISTER_READ_VOUT 0x8B
|
||||
#define PMBUS_REGISTER_READ_IOUT 0x8C
|
||||
#define PMBUS_REGISTER_READ_TEMPERATURE_1 0x8D
|
||||
#define PMBUS_REGISTER_READ_TEMPERATURE_2 0x8E
|
||||
#define PMBUS_REGISTER_READ_TEMPERATURE_3 0x8F
|
||||
#define PMBUS_REGISTER_READ_FAN_SPEED_1 0x90
|
||||
#define PMBUS_REGISTER_READ_FAN_SPEED_2 0x91
|
||||
|
||||
#define PMBUS_REGISTER_READ_FAN_CONFIG_1 0x3A
|
||||
#define PMBUS_REGISTER_FAN_COMMAND_1 0x3B
|
||||
|
||||
#define PMBUS_REGISTER_READ_POUT 0x96
|
||||
#define PMBUS_REGISTER_READ_PIN 0x97
|
||||
#define PMBUS_REGISTER_MFR_ID 0x99
|
||||
#define PMBUS_REGISTER_MFR_MODEL 0x9A
|
||||
#define PMBUS_REGISTER_MFR_REVISION 0x9B
|
||||
#define PMBUS_REGISTER_MFR_SERIAL 0x9E
|
||||
|
||||
|
||||
#define MAX_FAN_DUTY_CYCLE 100
|
||||
#define I2C_RW_RETRY_COUNT 10
|
||||
#define I2C_RW_RETRY_INTERVAL 60 /* ms */
|
||||
|
||||
/* Addresses scanned
|
||||
*/
|
||||
static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
|
||||
|
||||
/* Each client has this additional data
|
||||
*/
|
||||
struct accton_i2c_psu_data {
|
||||
struct device *hwmon_dev;
|
||||
struct mutex update_lock;
|
||||
char valid; /* !=0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 vout_mode; /* Register value */
|
||||
u16 v_in; /* Register value */
|
||||
u16 v_out; /* Register value */
|
||||
u16 i_in; /* Register value */
|
||||
u16 i_out; /* Register value */
|
||||
u16 p_in; /* Register value */
|
||||
u16 p_out; /* Register value */
|
||||
u16 temp_input[2]; /* Register value */
|
||||
u8 fan_fault; /* Register value */
|
||||
u16 fan_duty_cycle[2]; /* Register value */
|
||||
u16 fan_speed[2]; /* Register value */
|
||||
u8 pmbus_revision; /* Register value */
|
||||
u8 mfr_id[10]; /* Register value */
|
||||
u8 mfr_model[16]; /* Register value */
|
||||
u8 mfr_revsion[3]; /* Register value */
|
||||
u8 mfr_serial[26]; /* Register value */
|
||||
};
|
||||
|
||||
static ssize_t show_linear(struct device *dev, struct device_attribute *da, char *buf);
|
||||
static ssize_t show_fan_fault(struct device *dev, struct device_attribute *da, char *buf);
|
||||
static ssize_t show_vout(struct device *dev, struct device_attribute *da, char *buf);
|
||||
static ssize_t set_fan_duty_cycle(struct device *dev, struct device_attribute *da, const char *buf, size_t count);
|
||||
static ssize_t show_ascii(struct device *dev, struct device_attribute *da,
|
||||
char *buf);
|
||||
static ssize_t show_byte(struct device *dev, struct device_attribute *da,
|
||||
char *buf);
|
||||
|
||||
static int accton_i2c_psu_write_word(struct i2c_client *client, u8 reg, u16 value);
|
||||
static struct accton_i2c_psu_data *accton_i2c_psu_update_device(struct device *dev);
|
||||
|
||||
enum accton_i2c_psu_sysfs_attributes {
|
||||
PSU_V_IN,
|
||||
PSU_V_OUT,
|
||||
PSU_I_IN,
|
||||
PSU_I_OUT,
|
||||
PSU_P_IN,
|
||||
PSU_P_OUT,
|
||||
PSU_TEMP1_INPUT,
|
||||
PSU_FAN1_FAULT,
|
||||
PSU_FAN1_DUTY_CYCLE,
|
||||
PSU_FAN1_SPEED,
|
||||
PSU_PMBUS_REVISION,
|
||||
PSU_MFR_ID,
|
||||
PSU_MFR_MODEL,
|
||||
PSU_MFR_REVISION,
|
||||
PSU_MFR_SERIAL,
|
||||
};
|
||||
|
||||
/* sysfs attributes for hwmon
|
||||
*/
|
||||
static SENSOR_DEVICE_ATTR(psu_v_in, S_IRUGO, show_linear, NULL, PSU_V_IN);
|
||||
static SENSOR_DEVICE_ATTR(psu_v_out, S_IRUGO, show_vout, NULL, PSU_V_OUT);
|
||||
static SENSOR_DEVICE_ATTR(psu_i_in, S_IRUGO, show_linear, NULL, PSU_I_IN);
|
||||
static SENSOR_DEVICE_ATTR(psu_i_out, S_IRUGO, show_linear, NULL, PSU_I_OUT);
|
||||
static SENSOR_DEVICE_ATTR(psu_p_in, S_IRUGO, show_linear, NULL, PSU_P_IN);
|
||||
static SENSOR_DEVICE_ATTR(psu_p_out, S_IRUGO, show_linear, NULL, PSU_P_OUT);
|
||||
static SENSOR_DEVICE_ATTR(psu_temp1_input, S_IRUGO, show_linear, NULL, PSU_TEMP1_INPUT);
|
||||
static SENSOR_DEVICE_ATTR(psu_fan1_fault, S_IRUGO, show_fan_fault, NULL, PSU_FAN1_FAULT);
|
||||
static SENSOR_DEVICE_ATTR(psu_fan1_duty_cycle_percentage, S_IWUSR | S_IRUGO, show_linear, set_fan_duty_cycle, PSU_FAN1_DUTY_CYCLE);
|
||||
static SENSOR_DEVICE_ATTR(psu_fan1_speed_rpm, S_IRUGO, show_linear, NULL, PSU_FAN1_SPEED);
|
||||
static SENSOR_DEVICE_ATTR(psu_pmbus_revision,S_IRUGO, show_byte, NULL, PSU_PMBUS_REVISION);
|
||||
static SENSOR_DEVICE_ATTR(psu_mfr_id, S_IRUGO, show_ascii, NULL, PSU_MFR_ID);
|
||||
static SENSOR_DEVICE_ATTR(psu_mfr_model, S_IRUGO, show_ascii, NULL, PSU_MFR_MODEL);
|
||||
static SENSOR_DEVICE_ATTR(psu_mfr_revision, S_IRUGO, show_ascii, NULL, PSU_MFR_REVISION);
|
||||
static SENSOR_DEVICE_ATTR(psu_mfr_serial, S_IRUGO, show_ascii, NULL, PSU_MFR_SERIAL);
|
||||
|
||||
static struct attribute *accton_i2c_psu_attributes[] = {
|
||||
&sensor_dev_attr_psu_v_in.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_v_out.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_i_in.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_i_out.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_p_in.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_p_out.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_temp1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_fan1_fault.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_fan1_duty_cycle_percentage.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_fan1_speed_rpm.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_pmbus_revision.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_mfr_id.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_mfr_model.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_mfr_revision.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_mfr_serial.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static int two_complement_to_int(u16 data, u8 valid_bit, int mask)
|
||||
{
|
||||
u16 valid_data = data & mask;
|
||||
bool is_negative = valid_data >> (valid_bit - 1);
|
||||
|
||||
return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data;
|
||||
}
|
||||
|
||||
static ssize_t set_fan_duty_cycle(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 accton_i2c_psu_data *data = i2c_get_clientdata(client);
|
||||
int nr = (attr->index == PSU_FAN1_DUTY_CYCLE) ? 0 : 1;
|
||||
long speed;
|
||||
int error;
|
||||
|
||||
error = kstrtol(buf, 10, &speed);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (speed < 0 || speed > MAX_FAN_DUTY_CYCLE)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
data->fan_duty_cycle[nr] = speed;
|
||||
accton_i2c_psu_write_word(client, PMBUS_REGISTER_FAN_COMMAND_1 + nr, data->fan_duty_cycle[nr]);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_linear(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct accton_i2c_psu_data *data = accton_i2c_psu_update_device(dev);
|
||||
|
||||
u16 value = 0;
|
||||
int exponent, mantissa;
|
||||
int multiplier = 0;
|
||||
|
||||
switch (attr->index) {
|
||||
case PSU_V_IN:
|
||||
value = data->v_in;
|
||||
break;
|
||||
case PSU_I_IN:
|
||||
value = data->i_in;
|
||||
break;
|
||||
case PSU_I_OUT:
|
||||
value = data->i_out;
|
||||
break;
|
||||
case PSU_P_IN:
|
||||
value = data->p_in;
|
||||
break;
|
||||
case PSU_P_OUT:
|
||||
value = data->p_out;
|
||||
break;
|
||||
case PSU_TEMP1_INPUT:
|
||||
value = data->temp_input[0];
|
||||
break;
|
||||
case PSU_FAN1_DUTY_CYCLE:
|
||||
multiplier = 1;
|
||||
value = data->fan_duty_cycle[0];
|
||||
break;
|
||||
case PSU_FAN1_SPEED:
|
||||
multiplier = 1;
|
||||
value = data->fan_speed[0];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
exponent = two_complement_to_int(value >> 11, 5, 0x1f);
|
||||
mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff);
|
||||
|
||||
if(!multiplier)
|
||||
multiplier = PMBUS_LITERAL_DATA_MULTIPLIER;
|
||||
|
||||
|
||||
return (exponent >= 0) ? sprintf(buf, "%d\n", (mantissa << exponent) * multiplier) :
|
||||
sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent));
|
||||
}
|
||||
|
||||
static ssize_t show_fan_fault(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct accton_i2c_psu_data *data = accton_i2c_psu_update_device(dev);
|
||||
|
||||
u8 shift = (attr->index == PSU_FAN1_FAULT) ? 7 : 6;
|
||||
|
||||
return sprintf(buf, "%d\n", data->fan_fault >> shift);
|
||||
}
|
||||
|
||||
static ssize_t show_vout(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct accton_i2c_psu_data *data = accton_i2c_psu_update_device(dev);
|
||||
int exponent, mantissa;
|
||||
|
||||
exponent = two_complement_to_int(data->vout_mode, 5, 0x1f);
|
||||
mantissa = data->v_out;
|
||||
|
||||
return (exponent > 0) ? sprintf(buf, "%d\n", (mantissa << exponent) * PMBUS_LITERAL_DATA_MULTIPLIER) :
|
||||
sprintf(buf, "%d\n", (mantissa * PMBUS_LITERAL_DATA_MULTIPLIER) / (1 << -exponent));
|
||||
}
|
||||
|
||||
static ssize_t show_byte(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct accton_i2c_psu_data *data = accton_i2c_psu_update_device(dev);
|
||||
|
||||
if (!data->valid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (attr->index == PSU_PMBUS_REVISION) ? sprintf(buf, "%d\n", data->pmbus_revision) :
|
||||
sprintf(buf, "0\n");
|
||||
}
|
||||
|
||||
static ssize_t show_ascii(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct accton_i2c_psu_data *data = accton_i2c_psu_update_device(dev);
|
||||
u8 *ptr = NULL;
|
||||
|
||||
if (!data->valid) {
|
||||
return 0;
|
||||
}
|
||||
switch (attr->index) {
|
||||
|
||||
case PSU_MFR_ID:
|
||||
ptr = data->mfr_id;
|
||||
break;
|
||||
case PSU_MFR_MODEL:
|
||||
ptr = data->mfr_model;
|
||||
break;
|
||||
case PSU_MFR_REVISION:
|
||||
ptr = data->mfr_revsion;
|
||||
break;
|
||||
case PSU_MFR_SERIAL:
|
||||
ptr = data->mfr_serial;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sprintf(buf, "%s\n", ptr);
|
||||
}
|
||||
|
||||
|
||||
static const struct attribute_group accton_i2c_psu_group = {
|
||||
.attrs = accton_i2c_psu_attributes,
|
||||
};
|
||||
|
||||
static int accton_i2c_psu_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *dev_id)
|
||||
{
|
||||
struct accton_i2c_psu_data *data;
|
||||
int status;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) {
|
||||
status = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data = kzalloc(sizeof(struct accton_i2c_psu_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
status = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
data->valid = 0;
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
dev_info(&client->dev, "chip found\n");
|
||||
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &accton_i2c_psu_group);
|
||||
if (status) {
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->hwmon_dev = hwmon_device_register(&client->dev);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "%s: psu '%s'\n",
|
||||
dev_name(data->hwmon_dev), client->name);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &accton_i2c_psu_group);
|
||||
exit_free:
|
||||
kfree(data);
|
||||
exit:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int accton_i2c_psu_remove(struct i2c_client *client)
|
||||
{
|
||||
struct accton_i2c_psu_data *data = i2c_get_clientdata(client);
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &accton_i2c_psu_group);
|
||||
kfree(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* Support psu moduel
|
||||
*/
|
||||
static const struct i2c_device_id accton_i2c_psu_id[] = {
|
||||
{ "acbel_fsh082", 0 },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, accton_i2c_psu_id);
|
||||
|
||||
static struct i2c_driver accton_i2c_psu_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "accton_i2c_psu",
|
||||
},
|
||||
.probe = accton_i2c_psu_probe,
|
||||
.remove = accton_i2c_psu_remove,
|
||||
.id_table = accton_i2c_psu_id,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
static int accton_i2c_psu_read_byte(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
return i2c_smbus_read_byte_data(client, reg);
|
||||
}
|
||||
|
||||
static int accton_i2c_psu_read_word(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
return i2c_smbus_read_word_data(client, reg);
|
||||
}
|
||||
|
||||
static int accton_i2c_psu_write_word(struct i2c_client *client, u8 reg, u16 value)
|
||||
{
|
||||
return i2c_smbus_write_word_data(client, reg, value);
|
||||
}
|
||||
|
||||
static int accton_i2c_psu_read_block(struct i2c_client *client, u8 command, u8 *data,
|
||||
int data_len)
|
||||
{
|
||||
int status = 0, retry = I2C_RW_RETRY_COUNT;
|
||||
|
||||
while (retry) {
|
||||
status = i2c_smbus_read_i2c_block_data(client, command, data_len, data);
|
||||
if (unlikely(status < 0)) {
|
||||
msleep(I2C_RW_RETRY_INTERVAL);
|
||||
retry--;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static int accton_i2c_psu_read_block_data(struct i2c_client *client, u8 command, u8 *data, int data_length)
|
||||
{
|
||||
int status = -EIO;
|
||||
int length;
|
||||
u8 buffer[128] = {0}, *ptr = buffer;
|
||||
|
||||
status = accton_i2c_psu_read_byte(client, command);
|
||||
if (status < 0)
|
||||
{
|
||||
dev_dbg(&client->dev, "Unable to get data from offset 0x%02X\r\n", command);
|
||||
status = -EIO;
|
||||
goto EXIT_READ_BLOCK_DATA;
|
||||
}
|
||||
|
||||
status = (status & 0xFF) + 1;
|
||||
if ( status > 128)
|
||||
{
|
||||
dev_dbg(&client->dev, "Unable to get big data from offset 0x%02X\r\n", command);
|
||||
status = -EINVAL;
|
||||
goto EXIT_READ_BLOCK_DATA;
|
||||
}
|
||||
|
||||
length = status;
|
||||
status = accton_i2c_psu_read_block(client, command, buffer, length);
|
||||
if (unlikely(status < 0))
|
||||
goto EXIT_READ_BLOCK_DATA;
|
||||
if (unlikely(status != length)) {
|
||||
status = -EIO;
|
||||
goto EXIT_READ_BLOCK_DATA;
|
||||
}
|
||||
/* The first byte is the count byte of string. */
|
||||
ptr++;
|
||||
status--;
|
||||
|
||||
length=status>(data_length-1)?(data_length-1):status;
|
||||
memcpy(data, ptr, length);
|
||||
data[length-1] = 0;
|
||||
|
||||
EXIT_READ_BLOCK_DATA:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
struct reg_data_byte {
|
||||
u8 reg;
|
||||
u8 *value;
|
||||
};
|
||||
|
||||
struct reg_data_word {
|
||||
u8 reg;
|
||||
u16 *value;
|
||||
};
|
||||
|
||||
static struct accton_i2c_psu_data *accton_i2c_psu_update_device(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct accton_i2c_psu_data *data = i2c_get_clientdata(client);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|
||||
|| !data->valid) {
|
||||
int i, status, length;
|
||||
u8 command, buf;
|
||||
struct reg_data_byte regs_byte[] = { {PMBUS_REGISTER_VOUT_MODE, &data->vout_mode},
|
||||
{PMBUS_REGISTER_STATUS_FAN, &data->fan_fault}};
|
||||
struct reg_data_word regs_word[] = { {PMBUS_REGISTER_READ_VIN, &data->v_in},
|
||||
{PMBUS_REGISTER_READ_VOUT, &data->v_out},
|
||||
{PMBUS_REGISTER_READ_IIN, &data->i_in},
|
||||
{PMBUS_REGISTER_READ_IOUT, &data->i_out},
|
||||
{PMBUS_REGISTER_READ_POUT, &data->p_out},
|
||||
{PMBUS_REGISTER_READ_PIN, &data->p_in},
|
||||
{PMBUS_REGISTER_READ_TEMPERATURE_1, &(data->temp_input[0])},
|
||||
{PMBUS_REGISTER_READ_TEMPERATURE_2, &(data->temp_input[1])},
|
||||
{PMBUS_REGISTER_FAN_COMMAND_1, &(data->fan_duty_cycle[0])},
|
||||
{PMBUS_REGISTER_READ_FAN_SPEED_1, &(data->fan_speed[0])},
|
||||
{PMBUS_REGISTER_READ_FAN_SPEED_2, &(data->fan_speed[1])},
|
||||
};
|
||||
|
||||
dev_dbg(&client->dev, "Starting accton_i2c_psu update\n");
|
||||
|
||||
/* Read byte data */
|
||||
for (i = 0; i < ARRAY_SIZE(regs_byte); i++) {
|
||||
status = accton_i2c_psu_read_byte(client, regs_byte[i].reg);
|
||||
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n",
|
||||
regs_byte[i].reg, status);
|
||||
}
|
||||
else {
|
||||
*(regs_byte[i].value) = status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read word data */
|
||||
for (i = 0; i < ARRAY_SIZE(regs_word); i++) {
|
||||
status = accton_i2c_psu_read_word(client, regs_word[i].reg);
|
||||
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n",
|
||||
regs_word[i].reg, status);
|
||||
}
|
||||
else {
|
||||
*(regs_word[i].value) = status;
|
||||
}
|
||||
|
||||
}
|
||||
/* Read mfr_id */
|
||||
status = accton_i2c_psu_read_block_data(client, PMBUS_REGISTER_MFR_ID, data->mfr_id,
|
||||
ARRAY_SIZE(data->mfr_id));
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n", PMBUS_REGISTER_MFR_ID, status);
|
||||
goto exit;
|
||||
}
|
||||
/* Read mfr_model */
|
||||
status = accton_i2c_psu_read_block_data(client, PMBUS_REGISTER_MFR_MODEL, data->mfr_model,
|
||||
ARRAY_SIZE(data->mfr_model));
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n", PMBUS_REGISTER_MFR_MODEL, status);
|
||||
goto exit;
|
||||
}
|
||||
/* Read mfr_revsion */
|
||||
status = accton_i2c_psu_read_block_data(client, PMBUS_REGISTER_MFR_REVISION, data->mfr_revsion,
|
||||
ARRAY_SIZE(data->mfr_revsion));
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n", PMBUS_REGISTER_MFR_REVISION, status);
|
||||
goto exit;
|
||||
}
|
||||
/* Read mfr_serial */
|
||||
status = accton_i2c_psu_read_block_data(client, PMBUS_REGISTER_MFR_SERIAL, data->mfr_serial,
|
||||
ARRAY_SIZE(data->mfr_serial));
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n", PMBUS_REGISTER_MFR_SERIAL, status);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static int __init accton_i2c_psu_init(void)
|
||||
{
|
||||
return i2c_add_driver(&accton_i2c_psu_driver);
|
||||
}
|
||||
|
||||
static void __exit accton_i2c_psu_exit(void)
|
||||
{
|
||||
i2c_del_driver(&accton_i2c_psu_driver);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Jostar Yang <jostar_yang@accton.com.tw>");
|
||||
MODULE_DESCRIPTION(DRIVER_DESCRIPTION_NAME);
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_init(accton_i2c_psu_init);
|
||||
module_exit(accton_i2c_psu_exit);
|
||||
509
packages/base/any/kernels/modules/dps850.c
Executable file
509
packages/base/any/kernels/modules/dps850.c
Executable file
@@ -0,0 +1,509 @@
|
||||
/*
|
||||
* An hwmon driver for the Delta DPS-850AB-4 Power Module
|
||||
*
|
||||
* Copyright (C) 2017 Accton Technology Corporation.
|
||||
* Brandon Chuang <brandon_chuang@accton.com.tw>
|
||||
*
|
||||
* Based on ad7414.c
|
||||
* Copyright 2006 Stefan Roese <sr at denx.de>, DENX Software Engineering
|
||||
*
|
||||
* 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/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define I2C_RW_RETRY_COUNT 10
|
||||
#define I2C_RW_RETRY_INTERVAL 60 /* ms */
|
||||
|
||||
/* Addresses scanned
|
||||
*/
|
||||
static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
|
||||
|
||||
enum chips {
|
||||
DPS850
|
||||
};
|
||||
|
||||
/* Each client has this additional data
|
||||
*/
|
||||
struct dps850_data {
|
||||
struct device *hwmon_dev;
|
||||
struct mutex update_lock;
|
||||
char valid; /* !=0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 chip; /* chip id */
|
||||
u8 vout_mode; /* Register value */
|
||||
u16 v_in; /* Register value */
|
||||
u16 v_out; /* Register value */
|
||||
u16 i_in; /* Register value */
|
||||
u16 i_out; /* Register value */
|
||||
u16 p_in; /* Register value */
|
||||
u16 p_out; /* Register value */
|
||||
u16 temp_input[3]; /* Register value */
|
||||
u16 fan_speed; /* Register value */
|
||||
u8 mfr_model[16]; /* Register value */
|
||||
u8 mfr_serial[16]; /* Register value */
|
||||
};
|
||||
|
||||
static ssize_t show_linear(struct device *dev, struct device_attribute *da,
|
||||
char *buf);
|
||||
static ssize_t show_vout_by_mode(struct device *dev, struct device_attribute *da,
|
||||
char *buf);
|
||||
static ssize_t show_ascii(struct device *dev, struct device_attribute *da,
|
||||
char *buf);
|
||||
static struct dps850_data *dps850_update_device(struct device *dev);
|
||||
static int dps850_write_word(struct i2c_client *client, u8 reg, u16 value);
|
||||
|
||||
enum dps850_sysfs_attributes {
|
||||
PSU_V_IN,
|
||||
PSU_V_OUT,
|
||||
PSU_I_IN,
|
||||
PSU_I_OUT,
|
||||
PSU_P_IN,
|
||||
PSU_P_OUT,
|
||||
PSU_TEMP1_INPUT,
|
||||
PSU_TEMP2_INPUT,
|
||||
PSU_TEMP3_INPUT,
|
||||
PSU_FAN1_SPEED,
|
||||
PSU_MFR_MODEL,
|
||||
PSU_MFR_SERIAL
|
||||
};
|
||||
|
||||
/* sysfs attributes for hwmon
|
||||
*/
|
||||
static SENSOR_DEVICE_ATTR(psu_v_in, S_IRUGO, show_linear, NULL, PSU_V_IN);
|
||||
static SENSOR_DEVICE_ATTR(psu_v_out,S_IRUGO, show_vout_by_mode,NULL, PSU_V_OUT);
|
||||
static SENSOR_DEVICE_ATTR(psu_i_in, S_IRUGO, show_linear, NULL, PSU_I_IN);
|
||||
static SENSOR_DEVICE_ATTR(psu_i_out,S_IRUGO, show_linear, NULL, PSU_I_OUT);
|
||||
static SENSOR_DEVICE_ATTR(psu_p_in, S_IRUGO, show_linear, NULL, PSU_P_IN);
|
||||
static SENSOR_DEVICE_ATTR(psu_p_out,S_IRUGO, show_linear, NULL, PSU_P_OUT);
|
||||
static SENSOR_DEVICE_ATTR(psu_temp1_input, S_IRUGO, show_linear, NULL, PSU_TEMP1_INPUT);
|
||||
static SENSOR_DEVICE_ATTR(psu_temp2_input, S_IRUGO, show_linear, NULL, PSU_TEMP2_INPUT);
|
||||
static SENSOR_DEVICE_ATTR(psu_temp3_input, S_IRUGO, show_linear, NULL, PSU_TEMP3_INPUT);
|
||||
static SENSOR_DEVICE_ATTR(psu_fan1_speed_rpm, S_IRUGO, show_linear, NULL, PSU_FAN1_SPEED);
|
||||
static SENSOR_DEVICE_ATTR(psu_mfr_model, S_IRUGO, show_ascii, NULL, PSU_MFR_MODEL);
|
||||
static SENSOR_DEVICE_ATTR(psu_mfr_serial, S_IRUGO, show_ascii, NULL, PSU_MFR_SERIAL);
|
||||
|
||||
static struct attribute *dps850_attributes[] = {
|
||||
&sensor_dev_attr_psu_v_out.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_i_out.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_p_out.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_v_in.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_i_in.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_p_in.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_temp1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_temp2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_temp3_input.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_fan1_speed_rpm.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_mfr_model.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_mfr_serial.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static int two_complement_to_int(u16 data, u8 valid_bit, int mask)
|
||||
{
|
||||
u16 valid_data = data & mask;
|
||||
bool is_negative = valid_data >> (valid_bit - 1);
|
||||
|
||||
return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data;
|
||||
}
|
||||
|
||||
static ssize_t show_linear(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct dps850_data *data = dps850_update_device(dev);
|
||||
|
||||
u16 value = 0;
|
||||
int exponent, mantissa;
|
||||
int multiplier = 1000;
|
||||
|
||||
if (!data->valid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (attr->index) {
|
||||
case PSU_V_IN:
|
||||
value = data->v_in;
|
||||
break;
|
||||
case PSU_I_IN:
|
||||
value = data->i_in;
|
||||
break;
|
||||
case PSU_I_OUT:
|
||||
value = data->i_out;
|
||||
break;
|
||||
case PSU_P_IN:
|
||||
value = data->p_in;
|
||||
break;
|
||||
case PSU_P_OUT:
|
||||
value = data->p_out;
|
||||
break;
|
||||
case PSU_TEMP1_INPUT:
|
||||
case PSU_TEMP2_INPUT:
|
||||
case PSU_TEMP3_INPUT:
|
||||
value = data->temp_input[attr->index-PSU_TEMP1_INPUT];
|
||||
break;
|
||||
case PSU_FAN1_SPEED:
|
||||
value = data->fan_speed;
|
||||
multiplier = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
exponent = two_complement_to_int(value >> 11, 5, 0x1f);
|
||||
mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff);
|
||||
|
||||
return (exponent >= 0) ? sprintf(buf, "%d\n", (mantissa << exponent) * multiplier) :
|
||||
sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent));
|
||||
}
|
||||
|
||||
static ssize_t show_ascii(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct dps850_data *data = dps850_update_device(dev);
|
||||
u8 *ptr = NULL;
|
||||
|
||||
if (!data->valid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (attr->index) {
|
||||
case PSU_MFR_MODEL: /* psu_mfr_model */
|
||||
ptr = data->mfr_model + 1; /* The first byte is the length of string. */
|
||||
break;
|
||||
case PSU_MFR_SERIAL: /* psu_mfr_serial */
|
||||
ptr = data->mfr_serial + 1; /* The first byte is the length of string. */
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sprintf(buf, "%s\n", ptr);
|
||||
}
|
||||
|
||||
static ssize_t show_vout_by_mode(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct dps850_data *data = dps850_update_device(dev);
|
||||
int exponent, mantissa;
|
||||
int multiplier = 1000;
|
||||
|
||||
if (!data->valid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
exponent = two_complement_to_int(data->vout_mode, 5, 0x1f);
|
||||
mantissa = data->v_out;
|
||||
|
||||
return (exponent > 0) ? sprintf(buf, "%d\n", (mantissa << exponent) * multiplier) :
|
||||
sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent));
|
||||
}
|
||||
|
||||
static const struct attribute_group dps850_group = {
|
||||
.attrs = dps850_attributes,
|
||||
};
|
||||
|
||||
static int dps850_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *dev_id)
|
||||
{
|
||||
struct dps850_data *data;
|
||||
int status;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_BYTE_DATA |
|
||||
I2C_FUNC_SMBUS_WORD_DATA |
|
||||
I2C_FUNC_SMBUS_I2C_BLOCK)) {
|
||||
status = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data = kzalloc(sizeof(struct dps850_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
status = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->update_lock);
|
||||
data->chip = dev_id->driver_data;
|
||||
dev_info(&client->dev, "chip found\n");
|
||||
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &dps850_group);
|
||||
if (status) {
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->hwmon_dev = hwmon_device_register(&client->dev);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "%s: psu '%s'\n",
|
||||
dev_name(data->hwmon_dev), client->name);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &dps850_group);
|
||||
exit_free:
|
||||
kfree(data);
|
||||
exit:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int dps850_remove(struct i2c_client *client)
|
||||
{
|
||||
struct dps850_data *data = i2c_get_clientdata(client);
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &dps850_group);
|
||||
kfree(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id dps850_id[] = {
|
||||
{ "dps850", DPS850 },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, dps850_id);
|
||||
|
||||
static struct i2c_driver dps850_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "dps850",
|
||||
},
|
||||
.probe = dps850_probe,
|
||||
.remove = dps850_remove,
|
||||
.id_table = dps850_id,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
static int dps850_read_byte(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
int status = 0, retry = I2C_RW_RETRY_COUNT;
|
||||
|
||||
while (retry) {
|
||||
status = i2c_smbus_read_byte_data(client, reg);
|
||||
if (unlikely(status < 0)) {
|
||||
msleep(I2C_RW_RETRY_INTERVAL);
|
||||
retry--;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int dps850_read_word(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
int status = 0, retry = I2C_RW_RETRY_COUNT;
|
||||
|
||||
while (retry) {
|
||||
status = i2c_smbus_read_word_data(client, reg);
|
||||
if (unlikely(status < 0)) {
|
||||
msleep(I2C_RW_RETRY_INTERVAL);
|
||||
retry--;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int dps850_write_word(struct i2c_client *client, u8 reg, u16 value)
|
||||
{
|
||||
int status = 0, retry = I2C_RW_RETRY_COUNT;
|
||||
|
||||
while (retry) {
|
||||
status = i2c_smbus_write_word_data(client, reg, value);
|
||||
if (unlikely(status < 0)) {
|
||||
msleep(I2C_RW_RETRY_INTERVAL);
|
||||
retry--;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int dps850_read_block(struct i2c_client *client, u8 command, u8 *data,
|
||||
int data_len)
|
||||
{
|
||||
int status = 0, retry = I2C_RW_RETRY_COUNT;
|
||||
|
||||
while (retry) {
|
||||
status = i2c_smbus_read_i2c_block_data(client, command, data_len, data);
|
||||
if (unlikely(status < 0)) {
|
||||
msleep(I2C_RW_RETRY_INTERVAL);
|
||||
retry--;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
struct reg_data_byte {
|
||||
u8 reg;
|
||||
u8 *value;
|
||||
};
|
||||
|
||||
struct reg_data_word {
|
||||
u8 reg;
|
||||
u16 *value;
|
||||
};
|
||||
|
||||
static struct dps850_data *dps850_update_device(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct dps850_data *data = i2c_get_clientdata(client);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|
||||
|| !data->valid) {
|
||||
int i, status, length;
|
||||
u8 command, buf;
|
||||
struct reg_data_byte regs_byte[] = { {0x20, &data->vout_mode}};
|
||||
struct reg_data_word regs_word[] = { {0x88, &data->v_in},
|
||||
{0x8b, &data->v_out},
|
||||
{0x89, &data->i_in},
|
||||
{0x8c, &data->i_out},
|
||||
{0x96, &data->p_out},
|
||||
{0x97, &data->p_in},
|
||||
{0x8d, &(data->temp_input[0])},
|
||||
{0x8e, &(data->temp_input[1])},
|
||||
{0x8f, &(data->temp_input[2])},
|
||||
{0x90, &data->fan_speed}};
|
||||
|
||||
dev_dbg(&client->dev, "Starting dps850 update\n");
|
||||
data->valid = 0;
|
||||
|
||||
/* Read byte data */
|
||||
for (i = 0; i < ARRAY_SIZE(regs_byte); i++) {
|
||||
status = dps850_read_byte(client, regs_byte[i].reg);
|
||||
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n",
|
||||
regs_byte[i].reg, status);
|
||||
goto exit;
|
||||
}
|
||||
else {
|
||||
*(regs_byte[i].value) = status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read word data */
|
||||
for (i = 0; i < ARRAY_SIZE(regs_word); i++) {
|
||||
status = dps850_read_word(client, regs_word[i].reg);
|
||||
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n",
|
||||
regs_word[i].reg, status);
|
||||
goto exit;
|
||||
}
|
||||
else {
|
||||
*(regs_word[i].value) = status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read mfr_model */
|
||||
command = 0x9a;
|
||||
length = 1;
|
||||
memset(data->mfr_model, 0, sizeof(data->mfr_model));
|
||||
|
||||
/* Read first byte to determine the length of data */
|
||||
status = dps850_read_block(client, command, &buf, length);
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n", command, status);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
status = dps850_read_block(client, command, data->mfr_model, buf+1);
|
||||
data->mfr_model[buf+1] = '\0';
|
||||
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n", command, status);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
||||
/* Read mfr_serial */
|
||||
command = 0x9e;
|
||||
length = 1;
|
||||
memset(data->mfr_serial, 0, sizeof(data->mfr_serial));
|
||||
|
||||
/* Read first byte to determine the length of data */
|
||||
status = dps850_read_block(client, command, &buf, length);
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n", command, status);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
status = dps850_read_block(client, command, data->mfr_serial, buf+1);
|
||||
data->mfr_serial[buf+1] = '\0';
|
||||
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n", command, status);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static int __init dps850_init(void)
|
||||
{
|
||||
return i2c_add_driver(&dps850_driver);
|
||||
}
|
||||
|
||||
static void __exit dps850_exit(void)
|
||||
{
|
||||
i2c_del_driver(&dps850_driver);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Brandon Chuang <brandon_chuang@accton.com.tw>");
|
||||
MODULE_DESCRIPTION("DELTA DPS-850AB driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_init(dps850_init);
|
||||
module_exit(dps850_exit);
|
||||
|
||||
@@ -660,6 +660,7 @@ static ssize_t optoe_read_write(struct optoe_data *optoe,
|
||||
ssize_t retval;
|
||||
size_t pending_len = 0, chunk_len = 0;
|
||||
loff_t chunk_offset = 0, chunk_start_offset = 0;
|
||||
loff_t chunk_end_offset = 0;
|
||||
|
||||
dev_dbg(&client->dev,
|
||||
"%s: off %lld len:%ld, opcode:%s\n",
|
||||
@@ -699,30 +700,30 @@ static ssize_t optoe_read_write(struct optoe_data *optoe,
|
||||
/*
|
||||
* Compute the offset and number of bytes to be read/write
|
||||
*
|
||||
* 1. start at offset 0 (within the chunk), and read/write
|
||||
* the entire chunk
|
||||
* 2. start at offset 0 (within the chunk) and read/write less
|
||||
* than entire chunk
|
||||
* 3. start at an offset not equal to 0 and read/write the rest
|
||||
* 1. start at an offset not equal to 0 (within the chunk)
|
||||
* and read/write less than the rest of the chunk
|
||||
* 2. start at an offset not equal to 0 and read/write the rest
|
||||
* of the chunk
|
||||
* 4. start at an offset not equal to 0 and read/write less than
|
||||
* (end of chunk - offset)
|
||||
* 3. start at offset 0 (within the chunk) and read/write less
|
||||
* than entire chunk
|
||||
* 4. start at offset 0 (within the chunk), and read/write
|
||||
* the entire chunk
|
||||
*/
|
||||
chunk_start_offset = chunk * OPTOE_PAGE_SIZE;
|
||||
chunk_end_offset = chunk_start_offset + OPTOE_PAGE_SIZE;
|
||||
|
||||
if (chunk_start_offset < off) {
|
||||
chunk_offset = off;
|
||||
if ((off + pending_len) < (chunk_start_offset +
|
||||
OPTOE_PAGE_SIZE))
|
||||
if ((off + pending_len) < chunk_end_offset)
|
||||
chunk_len = pending_len;
|
||||
else
|
||||
chunk_len = OPTOE_PAGE_SIZE - off;
|
||||
chunk_len = chunk_end_offset - off;
|
||||
} else {
|
||||
chunk_offset = chunk_start_offset;
|
||||
if (pending_len > OPTOE_PAGE_SIZE)
|
||||
chunk_len = OPTOE_PAGE_SIZE;
|
||||
else
|
||||
if (pending_len < OPTOE_PAGE_SIZE)
|
||||
chunk_len = pending_len;
|
||||
else
|
||||
chunk_len = OPTOE_PAGE_SIZE;
|
||||
}
|
||||
|
||||
dev_dbg(&client->dev,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -206,7 +206,7 @@ void onlp_api_unlock(void);
|
||||
ONLP_API_T1(_name); \
|
||||
ONLP_LOCKED_API_NAME(_name) (_v1, _v2, _v3); \
|
||||
ONLP_API_UNLOCK(); \
|
||||
ONLP_API_T2_(name); \
|
||||
ONLP_API_T2(name); \
|
||||
}
|
||||
|
||||
#define ONLP_LOCKED_VAPI4(_name, _t1, _v1, _t2, _v2, _t3, _v3, _t4, _v4) \
|
||||
|
||||
@@ -62,12 +62,12 @@ ds_connect__(const char* path)
|
||||
if(connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == 0) {
|
||||
|
||||
/*
|
||||
* Set blocking with a 1 second timeout on all domain socket read/write operations.
|
||||
* Set blocking with a 5 second timeout on all domain socket read/write operations.
|
||||
*/
|
||||
struct timeval tv;
|
||||
|
||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NONBLOCK);
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_sec = 5;
|
||||
tv.tv_usec = 0;
|
||||
setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);
|
||||
return fd;
|
||||
|
||||
@@ -18,6 +18,7 @@ common:
|
||||
maintainer: support@bigswitch.com
|
||||
support: opennetworklinux@googlegroups.com
|
||||
changelog: None
|
||||
dists: $DISTS
|
||||
|
||||
packages:
|
||||
- name: onl-platform-config-$PLATFORM
|
||||
|
||||
@@ -5,6 +5,7 @@ common:
|
||||
copyright: Copyright 2013, 2014, 2015 Big Switch Networks
|
||||
maintainer: support@bigswitch.com
|
||||
support: opennetworklinux@googlegroups.com
|
||||
dists: jessie
|
||||
|
||||
packages:
|
||||
- name: onl-kernel-3.2-lts-arm-iproc-all
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL/packages/base/any/kernels/lts/APKG.yml VERSION=4.14 ARCH=armel CONFIG=armel-iproc-all
|
||||
@@ -0,0 +1,5 @@
|
||||
KERNEL_BUILD_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
KERNEL_ARCH := arm
|
||||
KERNEL_LTS_VERSION := 4.14
|
||||
KERNEL_CONFIG := armel-iproc-all
|
||||
include $(ONL)/packages/base/any/kernels/lts/builds/Makefile
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
common:
|
||||
arch: armel
|
||||
version: 1.0.0
|
||||
copyright: Copyright 2013, 2014, 2015 Big Switch Networks
|
||||
maintainer: support@bigswitch.com
|
||||
support: opennetworklinux@googlegroups.com
|
||||
|
||||
packages:
|
||||
- name: onl-kernel-4.4-lts-arm-iproc-all
|
||||
version: 1.0.0
|
||||
summary: Open Network Linux Kernel 4.4-LTS for ARM Integrated Processor Platforms.
|
||||
|
||||
files:
|
||||
builds/kernel-4.4-lts-arm-iproc-all.bin.gz : $$PKG_INSTALL/
|
||||
builds/linux-4.4.*-mbuild : $$PKG_INSTALL/mbuilds
|
||||
|
||||
changelog: Change changes changes.,
|
||||
@@ -1,21 +0,0 @@
|
||||
# -*- Makefile -*-
|
||||
############################################################
|
||||
# <bsn.cl fy=2013 v=none>
|
||||
#
|
||||
# Copyright 2013, 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
#
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
include $(ONL)/make/config.mk
|
||||
|
||||
#export MODSYNCLIST_EXTRA := arch/arm/plat-iproc/include
|
||||
|
||||
kernel:
|
||||
$(MAKE) -C $(ONL)/packages/base/any/kernels/4.4-lts/configs/arm-iproc-all K_TARGET_DIR=$(THIS_DIR) $(ONL_MAKE_PARALLEL)
|
||||
|
||||
clean:
|
||||
rm -rf kernel-* linux-4.4.*
|
||||
1
packages/base/armhf/Makefile
Normal file
1
packages/base/armhf/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
1
packages/base/armhf/faultd/.gitignore
vendored
Normal file
1
packages/base/armhf/faultd/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
packages/base/armhf/faultd/Makefile
Normal file
1
packages/base/armhf/faultd/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
1
packages/base/armhf/faultd/PKG.yml
Normal file
1
packages/base/armhf/faultd/PKG.yml
Normal file
@@ -0,0 +1 @@
|
||||
!include $ONL/packages/base/any/faultd/APKG.yml ARCH=armhf TOOLCHAIN=arm-linux-gnueabihf
|
||||
2
packages/base/armhf/faultd/builds/.gitignore
vendored
Normal file
2
packages/base/armhf/faultd/builds/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
faultd.mk
|
||||
faultd-module.mk
|
||||
2
packages/base/armhf/faultd/builds/Makefile
Normal file
2
packages/base/armhf/faultd/builds/Makefile
Normal file
@@ -0,0 +1,2 @@
|
||||
include $(ONL)/make/config.armhf.mk
|
||||
include $(ONL)/packages/base/any/faultd/builds/Makefile
|
||||
1
packages/base/armhf/fit/Makefile
Normal file
1
packages/base/armhf/fit/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user