mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 09:32:34 +00:00
Merge branch 'main' into staging-WIFI-14723-Add-Support-for-EMPLUS-WAP581
This commit is contained in:
2
.github/workflows/build-dev.yml
vendored
2
.github/workflows/build-dev.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target: [ 'cig_wf189h', 'cig_wf189w', 'cig_wf672', 'cig_wf186h', 'cig_wf186w', 'cig_wf188n', 'cig_wf189', 'cig_wf196', 'cig_wf196', 'cybertan_eww631-a1', 'cybertan_eww631-b1', 'sonicfi_rap630w-312g', 'sonicfi_rap63xc-211g', 'sonicfi_rap630c-311g', 'sonicfi_rap630w-311g', 'sonicfi_rap630w-211g', 'sonicfi_rap650c', 'sonicfi_rap7110c-341x', 'sonicfi_rap750e-h', 'sonicfi_rap750e-s', 'sonicfi_rap750w-311a', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_eap104', 'edgecore_eap105', 'edgecore_eap111', 'edgecore_eap112', 'edgecore_oap101', 'edgecore_oap101-6e', 'edgecore_oap101e', 'edgecore_oap101e-6e', 'edgecore_oap103', 'hfcl_ion4xe', 'hfcl_ion4xi', 'hfcl_ion4x', 'hfcl_ion4x_2', 'hfcl_ion4x_3', 'hfcl_ion4xi_w', 'hfcl_ion4x_w', 'indio_um-305ax', 'senao_iap4300m', 'senao_iap2300m', 'senao_jeap6500', 'udaya_a6-id2', 'udaya_a6-od2', 'yuncore_ax820', 'yuncore_ax840', 'yuncore_fap640', 'yuncore_fap650', 'yuncore_fap655', 'emplus_wap588m', 'emplus_wap581', 'zyxel_nwa130be', 'sercomm_ap72tip-v4' ]
|
||||
target: [ 'cig_wf189h', 'cig_wf189w', 'cig_wf660a', 'cig_wf672', 'cig_wf186h', 'cig_wf186w', 'cig_wf188n', 'cig_wf189', 'cig_wf196', 'cig_wf196', 'cybertan_eww631-a1', 'cybertan_eww631-b1', 'sonicfi_rap630w-312g', 'sonicfi_rap63xc-211g', 'sonicfi_rap630c-311g', 'sonicfi_rap630w-311g', 'sonicfi_rap630w-211g', 'sonicfi_rap650c', 'sonicfi_rap7110c-341x', 'sonicfi_rap750e-h', 'sonicfi_rap750e-s', 'sonicfi_rap750w-311a', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_eap104', 'edgecore_eap105', 'edgecore_eap111', 'edgecore_eap112', 'edgecore_oap101', 'edgecore_oap101-6e', 'edgecore_oap101e', 'edgecore_oap101e-6e', 'edgecore_oap103', 'hfcl_ion4xe', 'hfcl_ion4xi', 'hfcl_ion4x', 'hfcl_ion4x_2', 'hfcl_ion4x_3', 'hfcl_ion4xi_w', 'hfcl_ion4x_w', 'indio_um-305ax', 'senao_iap4300m', 'senao_iap2300m', 'senao_jeap6500', 'udaya_a6-id2', 'udaya_a6-od2', 'yuncore_ax820', 'yuncore_ax840', 'yuncore_fap640', 'yuncore_fap650', 'yuncore_fap655', 'emplus_wap588m', 'emplus_wap581', 'zyxel_nwa130be', 'sercomm_ap72tip-v4' ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ function netifd_reload() {
|
||||
|
||||
push(ssid.interfaces, iface.ifname);
|
||||
ssid.bands[band] = iface.ifname;
|
||||
ssid.mpsk = config.multi_psk;
|
||||
ssid.mpsk = ssid?.mpsk ? true : config.multi_psk;
|
||||
for (let sta in iface.stations) {
|
||||
let stacfg = sta.config;
|
||||
|
||||
@@ -308,18 +308,18 @@ function sta_auth_cache(ifname, addr, idx, phrase) {
|
||||
function auth_cb(msg) {
|
||||
let data = msg.data;
|
||||
|
||||
if (!is_ssid_mpsk(data.iface))
|
||||
return;
|
||||
|
||||
printf(`Event ${msg.type}: ${msg.data}\n`);
|
||||
switch (msg.type) {
|
||||
case 'sta_auth':
|
||||
if (!is_ssid_mpsk(data.iface))
|
||||
return;
|
||||
|
||||
return {
|
||||
psk: sta_auth_psk(data.iface, data.sta),
|
||||
force_psk: true,
|
||||
};
|
||||
case 'sta_connected':
|
||||
if (data.psk_idx == null)
|
||||
if (data.psk_idx == null || !is_ssid_mpsk(data.iface))
|
||||
return;
|
||||
return sta_auth_cache(data.iface, data.sta, data.psk_idx, data.psk);
|
||||
case 'reload':
|
||||
|
||||
@@ -832,6 +832,13 @@ morse_hostapd_add_bss(){
|
||||
morse_override_hostapd_set_bss_options hostapd_cfg "$_phy" "$vif" || return 1
|
||||
json_get_vars wds wds_bridge sae_pwe dtim_period max_listen_int start_disabled
|
||||
|
||||
local network_config network_values
|
||||
json_get_values network_values network
|
||||
network_config=$(echo "$network_values" | cut -d' ' -f1)
|
||||
|
||||
if [ "$wds" -gt 0 ] && [ -z "$wds_bridge" ]; then
|
||||
wds_bridge="${network_config%%[0-9]*}"
|
||||
fi
|
||||
|
||||
raw_block=
|
||||
json_for_each_item morse_hostapd_add_raw raws
|
||||
|
||||
25
feeds/qca-wifi-7/cig-platform-pkg/cig-poe-judgment/Makefile
Normal file
25
feeds/qca-wifi-7/cig-platform-pkg/cig-poe-judgment/Makefile
Normal file
@@ -0,0 +1,25 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=cig-poe-judgment
|
||||
PKG_RELEASE:=1
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/cig-poe-judgment
|
||||
SUBMENU:=Other modules
|
||||
TITLE:=CIG POE judgment
|
||||
FILES:=$(PKG_BUILD_DIR)/cig_poe_judgment.ko
|
||||
AUTOLOAD:=$(call AutoLoad,99,cig_poe_judgment)
|
||||
endef
|
||||
|
||||
define KernelPackage/cig-poe-judgment/description
|
||||
Find POE type
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(KERNEL_MAKE) M="$(PKG_BUILD_DIR)" modules
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,cig-poe-judgment))
|
||||
@@ -0,0 +1 @@
|
||||
obj-m += cig_poe_judgment.o
|
||||
@@ -0,0 +1,252 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/irqreturn.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
#define GPIO_MAX 8
|
||||
#define INT_MODE_MASK 0xf0
|
||||
#define DETECT_MODE1 0x3
|
||||
#define DETECT_MODE2 0x4
|
||||
|
||||
enum POE_TYPE {
|
||||
POE_TYPE_AT = 1,
|
||||
POE_TYPE_AF,
|
||||
POE_TYPE_BT,
|
||||
POE_TYPE_DC,
|
||||
POE_TYPE_MAX
|
||||
};
|
||||
|
||||
struct poe_irq_data
|
||||
{
|
||||
struct device *dev;
|
||||
int irq;
|
||||
struct tasklet_struct tasklet;
|
||||
int poe_type;
|
||||
};
|
||||
|
||||
static void *poe_gpio_base;
|
||||
static void *pse_gpio_base;
|
||||
struct poe_irq_data *data = NULL;
|
||||
u32 mode;
|
||||
|
||||
static const struct of_device_id my_of_ids[] = {
|
||||
{.compatible = "poe-judge"},
|
||||
{},
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of,my_of_ids);
|
||||
|
||||
static int poe_info_proc_show(struct seq_file *m, void *v)
|
||||
{
|
||||
const char *type_str = "invalid";
|
||||
|
||||
switch (data->poe_type) {
|
||||
case POE_TYPE_AT:
|
||||
type_str = "AT";
|
||||
break;
|
||||
case POE_TYPE_AF:
|
||||
type_str = "AF";
|
||||
break;
|
||||
case POE_TYPE_BT:
|
||||
type_str = "BT";
|
||||
break;
|
||||
case POE_TYPE_DC:
|
||||
type_str = "DC";
|
||||
break;
|
||||
}
|
||||
|
||||
seq_printf(m, "%s\n", type_str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void poe_tasklet_func(unsigned long data)
|
||||
{
|
||||
struct poe_irq_data *irq_data = (struct poe_irq_data *)data;
|
||||
|
||||
writel(0x3, pse_gpio_base+4);
|
||||
irq_data->poe_type = POE_TYPE_BT;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static irqreturn_t gpio_key1_irq_handler(int irq, void *dev_id)
|
||||
{
|
||||
struct poe_irq_data *data = (struct poe_irq_data *)dev_id;
|
||||
|
||||
disable_irq_nosync(data->irq);
|
||||
tasklet_schedule(&data->tasklet);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static int poe_info_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, poe_info_proc_show, NULL);
|
||||
}
|
||||
|
||||
static const struct proc_ops poe_info_proc_fops = {
|
||||
.proc_open = poe_info_proc_open,
|
||||
.proc_read = seq_read,
|
||||
.proc_lseek = seq_lseek,
|
||||
.proc_release = single_release,
|
||||
};
|
||||
|
||||
static int gpio_key_probe(struct platform_device *dev)
|
||||
{
|
||||
int ret = 0;
|
||||
int irq = (-1);
|
||||
int val = 0;
|
||||
int gpio_id = 0;
|
||||
int gpio[GPIO_MAX] = {0}, gpio_val[GPIO_MAX] = {0};
|
||||
int num;
|
||||
char name[16];
|
||||
struct device_node *np = dev->dev.of_node;
|
||||
|
||||
if (of_property_read_u32(np, "detect-mode", &mode)) {
|
||||
pr_err("Failed to read detect mode\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
data = devm_kzalloc(&dev->dev, sizeof(struct poe_irq_data), GFP_KERNEL);
|
||||
if (!data)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (mode & INT_MODE_MASK) {
|
||||
poe_gpio_base = ioremap(0x1017004, 8);
|
||||
pse_gpio_base = ioremap(0x1026000, 8);
|
||||
|
||||
writel(0x2c1, pse_gpio_base);
|
||||
writel(0x0, pse_gpio_base+4);
|
||||
|
||||
|
||||
data->dev = &dev->dev;
|
||||
dev_set_drvdata(&dev->dev, data);
|
||||
|
||||
gpio_id = of_get_named_gpio(dev->dev.of_node, "detect_gpio", 0);
|
||||
if (gpio_id < 0)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tasklet_init(&data->tasklet, poe_tasklet_func, (unsigned long)data);
|
||||
|
||||
ret = devm_gpio_request_one(&dev->dev, gpio_id, GPIOF_IN, "poe_judge");
|
||||
if(ret)
|
||||
{
|
||||
pr_err("GPIO23 request failed, ret:%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
val = readl(poe_gpio_base);
|
||||
if(val == 1)
|
||||
{
|
||||
pr_info("poe type is af or bt,close pse first\n");
|
||||
data->poe_type = POE_TYPE_AF;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->poe_type = POE_TYPE_AT;
|
||||
}
|
||||
|
||||
irq = gpio_to_irq(gpio_id);
|
||||
data->irq = irq;
|
||||
|
||||
ret = devm_request_any_context_irq(&dev->dev, data->irq,
|
||||
gpio_key1_irq_handler,
|
||||
IRQF_TRIGGER_FALLING,
|
||||
"poe_judge", data);
|
||||
if (ret)
|
||||
{
|
||||
pr_err("Request irq fail %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
if (mode == DETECT_MODE1 || mode == DETECT_MODE2) {
|
||||
num = 3;
|
||||
} else {
|
||||
pr_err("Wrong poe detect mode\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
sprintf(name, "detect-gpio%d", i+1);
|
||||
gpio[i] = of_get_named_gpio(np, name, 0);
|
||||
ret = gpio_request(gpio[i], name);
|
||||
if (ret) {
|
||||
pr_err("Can not request gpio %d\n", i+1);
|
||||
return ret;
|
||||
}
|
||||
gpio_direction_input(gpio[i]);
|
||||
gpio_val[i] = gpio_get_value_cansleep(gpio[i]);
|
||||
}
|
||||
|
||||
if (mode == DETECT_MODE1){
|
||||
if (gpio_val[0] > 0) {
|
||||
data->poe_type = POE_TYPE_DC;
|
||||
} else if (gpio_val[1] > 0){
|
||||
if (gpio_val[2] == 0) {
|
||||
data->poe_type = POE_TYPE_AT;
|
||||
} else {
|
||||
data->poe_type = POE_TYPE_AF;
|
||||
}
|
||||
}
|
||||
}else if (mode == DETECT_MODE2){
|
||||
switch (gpio_val[0] | (gpio_val[1] << 1) | (gpio_val[2] << 2)) {
|
||||
case 3:
|
||||
data->poe_type = POE_TYPE_AT;
|
||||
break;
|
||||
case 4:
|
||||
data->poe_type = POE_TYPE_BT;
|
||||
break;
|
||||
case 7:
|
||||
data->poe_type = POE_TYPE_AF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!proc_create("poe_info", 0444, NULL, &poe_info_proc_fops)) {
|
||||
pr_err("Failed to create proc entry for poe_info\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gpio_key_remove(struct platform_device *dev)
|
||||
{
|
||||
remove_proc_entry("poe_info", NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver poe_judge_driver =
|
||||
{
|
||||
.driver = {
|
||||
.name = "poe_judge",
|
||||
.of_match_table = my_of_ids,
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = gpio_key_probe,
|
||||
.remove = gpio_key_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(poe_judge_driver);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("Poe type judgment driver");
|
||||
MODULE_AUTHOR("huangyunxiang<huangyunxiang@cigtech.com>");
|
||||
@@ -777,11 +777,16 @@ hostapd_set_bss_options() {
|
||||
set_default sae_require_mfp 1
|
||||
[ "$ppsk" -eq 0 ] && set_default sae_pwe 2
|
||||
;;
|
||||
psk-sae|psk2-radius|eap-eap2)
|
||||
psk-sae|eap-eap2)
|
||||
set_default ieee80211w 1
|
||||
set_default sae_require_mfp 1
|
||||
[ "$ppsk" -eq 0 ] && set_default sae_pwe 2
|
||||
;;
|
||||
psk2-radius)
|
||||
set_default ieee80211w 1
|
||||
set_default sae_require_mfp 0
|
||||
[ "$ppsk" -eq 0 ] && set_default sae_pwe 4
|
||||
;;
|
||||
esac
|
||||
[ -n "$sae_require_mfp" ] && append bss_conf "sae_require_mfp=$sae_require_mfp" "$N"
|
||||
[ -n "$sae_pwe" ] && append bss_conf "sae_pwe=$sae_pwe" "$N"
|
||||
|
||||
@@ -144,7 +144,7 @@ function netifd_reload() {
|
||||
|
||||
push(ssid.interfaces, iface.ifname);
|
||||
ssid.bands[band] = iface.ifname;
|
||||
ssid.mpsk = config.multi_psk;
|
||||
ssid.mpsk = ssid?.mpsk ? true : config.multi_psk;
|
||||
for (let sta in iface.stations) {
|
||||
let stacfg = sta.config;
|
||||
|
||||
@@ -308,18 +308,18 @@ function sta_auth_cache(ifname, addr, idx, phrase) {
|
||||
function auth_cb(msg) {
|
||||
let data = msg.data;
|
||||
|
||||
if (!is_ssid_mpsk(data.iface))
|
||||
return;
|
||||
|
||||
printf(`Event ${msg.type}: ${msg.data}\n`);
|
||||
switch (msg.type) {
|
||||
case 'sta_auth':
|
||||
if (!is_ssid_mpsk(data.iface))
|
||||
return;
|
||||
|
||||
return {
|
||||
psk: sta_auth_psk(data.iface, data.sta),
|
||||
force_psk: true,
|
||||
};
|
||||
case 'sta_connected':
|
||||
if (data.psk_idx == null)
|
||||
if (data.psk_idx == null || !is_ssid_mpsk(data.iface))
|
||||
return;
|
||||
return sta_auth_cache(data.iface, data.sta, data.psk_idx, data.psk);
|
||||
case 'reload':
|
||||
|
||||
@@ -236,6 +236,15 @@
|
||||
};
|
||||
};
|
||||
|
||||
poe {
|
||||
compatible = "poe-judge";
|
||||
detect-mode = <0x3>;
|
||||
detect-gpio1 = <&tlmm 25 GPIO_ACTIVE_HIGH>;
|
||||
detect-gpio2 = <&tlmm 43 GPIO_ACTIVE_HIGH>;
|
||||
detect-gpio3 = <&tlmm 29 GPIO_ACTIVE_HIGH>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
wsi: wsi {
|
||||
id = <0>;
|
||||
num_chip = <2>;
|
||||
|
||||
@@ -298,6 +298,13 @@
|
||||
};
|
||||
};
|
||||
|
||||
poe {
|
||||
compatible = "poe-judge";
|
||||
detect-mode = <0x11>;
|
||||
detect_gpio = <&tlmm 0x17 0>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
ess-instance {
|
||||
num_devices = <0x2>;
|
||||
|
||||
|
||||
@@ -298,6 +298,13 @@
|
||||
};
|
||||
};
|
||||
|
||||
poe {
|
||||
compatible = "poe-judge";
|
||||
detect-mode = <0x11>;
|
||||
detect_gpio = <&tlmm 0x17 0>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
ess-instance {
|
||||
num_devices = <0x2>;
|
||||
|
||||
|
||||
@@ -234,6 +234,15 @@
|
||||
};
|
||||
};
|
||||
|
||||
poe {
|
||||
compatible = "poe-judge";
|
||||
detect-mode = <0x4>;
|
||||
detect-gpio1 = <&extgpio 0 0>;
|
||||
detect-gpio2 = <&extgpio 1 0>;
|
||||
detect-gpio3 = <&extgpio 2 0>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
wsi: wsi {
|
||||
id = <0>;
|
||||
num_chip = <2>;
|
||||
@@ -538,7 +547,6 @@
|
||||
pinctrl-0 = <&pwm_pins>;
|
||||
pinctrl-names = "default";
|
||||
dft-pwm-status = <0>, <0>, <1>, <0>;
|
||||
poe_type_pin = <&extgpio 0 0 &extgpio 1 0 &extgpio 2 0>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
|
||||
42
feeds/ucentral/poe/Makefile
Normal file
42
feeds/ucentral/poe/Makefile
Normal file
@@ -0,0 +1,42 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=poe
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
ifeq ($(CONFIG_TARGET_ipq50xx_generic_DEVICE_sonicfi_rap630w_311g),y)
|
||||
TARGET_CFLAGS += -DPLATFORM_EWW631_B1=1
|
||||
endif
|
||||
|
||||
define Package/poe
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Turn on/off PoE ports with TSP23861 chipset
|
||||
DEPENDS:= +libubox +libubus +libuci +libi2c
|
||||
endef
|
||||
|
||||
define Package/poe/description
|
||||
Turn on/off PoE ports
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
|
||||
define Package/poe/install
|
||||
$(INSTALL_DIR) $(1)
|
||||
$(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/poe.init $(1)/etc/init.d/poe
|
||||
$(INSTALL_BIN) ./files/poe.config $(1)/etc/config/poe
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tps23861-poe-ctrl $(1)/usr/bin
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,poe))
|
||||
0
feeds/ucentral/poe/files/poe.config
Normal file
0
feeds/ucentral/poe/files/poe.config
Normal file
33
feeds/ucentral/poe/files/poe.init
Normal file
33
feeds/ucentral/poe/files/poe.init
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=10
|
||||
|
||||
tps23861_poe_ctrl () {
|
||||
local section="$1"
|
||||
local num mode
|
||||
config_get num "$section" port_num
|
||||
config_get mode "$section" admin_mode
|
||||
|
||||
if [ "$mode" == "1" ]; then
|
||||
output=$(tps23861-poe-ctrl -p "${num}" -P on)
|
||||
echo "<6>${output}" > "/dev/kmsg"
|
||||
else
|
||||
output=$(tps23861-poe-ctrl -p "${num}" -P off)
|
||||
echo "<6>${output}" > "/dev/kmsg"
|
||||
fi
|
||||
}
|
||||
|
||||
start(){
|
||||
. /lib/functions.sh
|
||||
|
||||
board=$(board_name)
|
||||
case $board in
|
||||
sonicfi,rap630w-311g|\
|
||||
cybertan,eww631-b1)
|
||||
config_load poe
|
||||
config_foreach tps23861_poe_ctrl port
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
26
feeds/ucentral/poe/src/Makefile
Normal file
26
feeds/ucentral/poe/src/Makefile
Normal file
@@ -0,0 +1,26 @@
|
||||
CFLAGS += -Wall -g
|
||||
|
||||
INCLUDES =
|
||||
|
||||
LDFLAGS = -lubus -lubox -li2c
|
||||
|
||||
LIBS =
|
||||
|
||||
SRCS = tps23861-poe-ctrl.c \
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
MAIN = tps23861-poe-ctrl
|
||||
|
||||
|
||||
all: $(MAIN)
|
||||
|
||||
$(MAIN): $(OBJS)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
clean:
|
||||
$(RM) *.o *~ $(MAIN) $(TEST)
|
||||
|
||||
215
feeds/ucentral/poe/src/tps23861-poe-ctrl.c
Normal file
215
feeds/ucentral/poe/src/tps23861-poe-ctrl.c
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* User-space daemon formonitoring and managing PoE ports with
|
||||
* TI TPS23861 chips. based on the Linux Kernel TPS23861
|
||||
* HWMON driver.
|
||||
*/
|
||||
|
||||
#include <stdio.h> /* Standard input/output definitions */
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h> /* uapi/linux/i2c-dev.h */
|
||||
|
||||
#include <libubox/ulog.h>
|
||||
|
||||
#define TPS23861_I2C_ADDR 0x20
|
||||
#define DETECT_CLASS_RESTART 0x18
|
||||
#define POWER_ENABLE 0x19
|
||||
#define POWER_ON_SHIFT 0
|
||||
#define POWER_OFF_SHIFT 4
|
||||
|
||||
typedef unsigned char u8;
|
||||
|
||||
#if defined(PLATFORM_EWW631_B1)
|
||||
#define TPS23861_NUM_PORTS 1
|
||||
#endif
|
||||
|
||||
#define CONVERT_PORT_NUM(x) (1 << ((u8)x-1))
|
||||
|
||||
unsigned int PORT_POWER_STATUS[TPS23861_NUM_PORTS];
|
||||
|
||||
int i2c_handler = -1;
|
||||
#define ULOG_DBG(fmt, ...) ulog(LOG_DEBUG, fmt, ## __VA_ARGS__)
|
||||
|
||||
int open_device(void)
|
||||
{
|
||||
int fd, fset;
|
||||
|
||||
fd = open("/dev/i2c-0", O_RDWR);
|
||||
fset = fcntl(fd, F_SETFL, 0);
|
||||
if (fset < 0)
|
||||
printf("fcntl failed!\n");
|
||||
|
||||
//if (isatty(STDIN_FILENO) == 0)
|
||||
// printf("standard input is not a terminal device\n");
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int access_salve(int fd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if((ret = ioctl(fd, I2C_SLAVE, TPS23861_I2C_ADDR)) < 0)
|
||||
{
|
||||
printf("%s: Failed to access slave bus[%s]\n",__func__, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
// Write to an I2C slave device's register:
|
||||
int i2c_write(u8 slave_addr, u8 reg, u8 data)
|
||||
{
|
||||
u8 outbuf[2];
|
||||
|
||||
struct i2c_msg msgs[1];
|
||||
struct i2c_rdwr_ioctl_data msgset[1];
|
||||
|
||||
outbuf[0] = reg;
|
||||
outbuf[1] = data;
|
||||
|
||||
msgs[0].addr = slave_addr;
|
||||
msgs[0].flags = 0;
|
||||
msgs[0].len = 2;
|
||||
msgs[0].buf = outbuf;
|
||||
|
||||
msgset[0].msgs = msgs;
|
||||
msgset[0].nmsgs = 1;
|
||||
|
||||
if (ioctl(i2c_handler, I2C_RDWR, &msgset) < 0) {
|
||||
perror("ioctl(I2C_RDWR) in i2c_write");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void poe_set_PowerOnOff(u8 port, u8 on_off) {
|
||||
u8 value;
|
||||
u8 portBit;
|
||||
portBit = CONVERT_PORT_NUM(port+1);
|
||||
|
||||
if(on_off == 0) {
|
||||
value = (portBit << POWER_OFF_SHIFT);
|
||||
PORT_POWER_STATUS[port] = 0;
|
||||
} else {
|
||||
value = (portBit << POWER_ON_SHIFT);
|
||||
PORT_POWER_STATUS[port] = 1;
|
||||
}
|
||||
|
||||
ULOG_DBG("set Port%d Power Status [%d] portBit 0x[%x] value 0x[%x]\n", port+1, PORT_POWER_STATUS[port], portBit, value);
|
||||
|
||||
if(i2c_write(TPS23861_I2C_ADDR, POWER_ENABLE, value) < 0)
|
||||
{
|
||||
ULOG_ERR("Set port%d power on-off error (0x19)\n", port);
|
||||
}
|
||||
}
|
||||
|
||||
void RestartPortDetectClass(u8 port)
|
||||
{
|
||||
u8 value;
|
||||
|
||||
value = (1 << port) | (1 << (port + 4));
|
||||
ULOG_DBG("RestartPortDetectClass value 0x%x\n", value);
|
||||
if(i2c_write(TPS23861_I2C_ADDR, DETECT_CLASS_RESTART, value) < 0) {
|
||||
ULOG_ERR("Set port%d detection and class on error\n",port);
|
||||
}
|
||||
}
|
||||
|
||||
int usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s -p <1-3> -P <on|off> [options]\n"
|
||||
"Required options:\n"
|
||||
" -p <1-3>: Select port number (Only port 1 is supported)\n"
|
||||
" -P <on|off>: Set PSE function state <on|off>\n"
|
||||
"Optional options:\n"
|
||||
" -d Enable debug mode\n"
|
||||
"\n", progname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int setPSE(int port ,char *optarg)
|
||||
{
|
||||
int ret = 0;
|
||||
i2c_handler = open_device();
|
||||
if (i2c_handler < 0) {
|
||||
ULOG_ERR("open i2c-0 device error!\n");
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
ret = access_salve(i2c_handler);
|
||||
if (ret < 0)
|
||||
{
|
||||
ULOG_ERR("The i2c-0 access error\n");
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if(!strncmp("on", optarg, 2)) {
|
||||
printf("Enable port%d PSE function\n", port);
|
||||
RestartPortDetectClass(port-1);
|
||||
}
|
||||
else if (!strncmp("off", optarg, 3)) {
|
||||
printf("Disable port%d PSE function\n", port);
|
||||
poe_set_PowerOnOff(port-1, 0);
|
||||
}
|
||||
else {
|
||||
ULOG_ERR("[Set] Do not accept this optarg!!!\n");
|
||||
ret = 1;
|
||||
}
|
||||
EXIT:
|
||||
close(i2c_handler);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ch, ret = 0, port = 0;
|
||||
char *PSE = NULL;
|
||||
if (argc == 1) {
|
||||
return usage(argv[0]);
|
||||
}
|
||||
|
||||
|
||||
ulog_open(ULOG_STDIO | ULOG_SYSLOG, LOG_DAEMON, "tps23861");
|
||||
ulog_threshold(LOG_INFO);
|
||||
|
||||
while ((ch = getopt(argc, argv, "dp:P:")) != -1) {
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
printf("tps23861-i2c-control ulog_threshold set to debug level\n");
|
||||
ulog_threshold(LOG_DEBUG);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
port = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
PSE = optarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = usage(argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (port < 1 || port > 3) {
|
||||
ret = usage(argv[0]);
|
||||
}
|
||||
else {
|
||||
if (PSE) {
|
||||
setPSE(port, PSE);
|
||||
}
|
||||
else {
|
||||
ret = usage(argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
@@ -4,10 +4,10 @@ PKG_NAME:=ucentral-client
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL=https://github.com/Telecominfraproject/wlan-ucentral-client.git
|
||||
PKG_MIRROR_HASH:=20d0573e5460ae9780307ab9d54234bb75d3b98fb36806f896819918087b14df
|
||||
PKG_MIRROR_HASH:=7dfeaedf141a6377de2dc6bcd646b1640201f204db42af52777d018700bc991c
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2024-10-20
|
||||
PKG_SOURCE_VERSION:=8c45f965c30d1cf11e3a5a625a5e2baf3178697f
|
||||
PKG_SOURCE_DATE:=2025-06-27
|
||||
PKG_SOURCE_VERSION:=08a842d9921196821a19d52b9061db6c428aab3f
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
|
||||
|
||||
14
feeds/ucentral/ucentral-client/files/etc/init.d/cpm
Executable file
14
feeds/ucentral/ucentral-client/files/etc/init.d/cpm
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=90
|
||||
STOP=01
|
||||
|
||||
boot() {
|
||||
mkdir -p /tmp/cpm/ || { logger -t init "Failed to create /tmp/cpm"; exit 1; }
|
||||
opkg list-installed > /tmp/packages.state || { logger -t init "Failed to list packages"; exit 1; }
|
||||
if [ -x /usr/share/ucentral/package_list.uc ]; then
|
||||
/usr/share/ucentral/package_list.uc || { logger -t init "Failed to execute package_list.uc"; exit 1; }
|
||||
else
|
||||
logger -t init "package_list.uc not found or not executable"
|
||||
fi
|
||||
}
|
||||
@@ -4,10 +4,10 @@ PKG_NAME:=ucentral-schema
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL=https://github.com/Telecominfraproject/wlan-ucentral-schema.git
|
||||
PKG_MIRROR_HASH:=c641622188b9b378550c21b1dcfa105b08a60e534d7d77ae63001d38a3e95cd8
|
||||
PKG_MIRROR_HASH:=aac8731d564f4ccd85a366417b9a02c1d3de9b6533d1474b58768249c50707f1
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2025-01-27
|
||||
PKG_SOURCE_VERSION:=ac3a1c7c25339de11e005dd4d1d4007a0c00c4b6
|
||||
PKG_SOURCE_DATE:=2025-06-27
|
||||
PKG_SOURCE_VERSION:=125a148764c9ef7a02086b6fadccd7b96bfdf591
|
||||
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
board=$(board_name)
|
||||
case $board in
|
||||
sonicfi,rap630w-311g|\
|
||||
cybertan,eww631-b1)
|
||||
for num in $(seq 1 3)
|
||||
do
|
||||
uci add poe port
|
||||
uci set poe.@port[-1]='port'
|
||||
eval uci set poe.@port[-1].port_num='${num}'
|
||||
uci set poe.@port[-1].admin_mode='1'
|
||||
done
|
||||
uci commit
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
@@ -13,3 +13,4 @@ packages:
|
||||
- ipq53xx
|
||||
- ftm
|
||||
- qca-ssdk-shell
|
||||
- kmod-cig-poe-judgment
|
||||
|
||||
@@ -12,3 +12,4 @@ include:
|
||||
packages:
|
||||
- ipq53xx
|
||||
- qca-ssdk-shell
|
||||
- kmod-cig-poe-judgment
|
||||
|
||||
@@ -12,3 +12,4 @@ include:
|
||||
packages:
|
||||
- ipq53xx
|
||||
- qca-ssdk-shell
|
||||
- kmod-cig-poe-judgment
|
||||
|
||||
@@ -21,3 +21,4 @@ packages:
|
||||
- kmod-gpio-pca953x
|
||||
- kmod-hwmon-tmp103
|
||||
- kmod-iio-ilps22qs
|
||||
- kmod-cig-poe-judgment
|
||||
|
||||
@@ -10,5 +10,6 @@ feeds:
|
||||
packages:
|
||||
- ipq50xx
|
||||
- cooling
|
||||
- poe
|
||||
include:
|
||||
- ucentral-ap
|
||||
|
||||
Reference in New Issue
Block a user