forked from prudy/mtpoe_ctrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
82 lines (74 loc) · 2.96 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Program for manage the Mikrotiks PoE V2 based on a microcontroller ATtiny 461a
Licence is GNU GPL V3
Examples of using:
mtpoe_ctrl -dumpvars #shows the values of parameter variables
mtpoe_ctrl #shows full information about PoE controller state/work
mtpoe_ctrl --action=get_fw_ver #shows firmware version of the Attiny PoE microcontroller
mtpoe_ctrl --action=get_voltage #shows the input voltage
mtpoe_ctrl --action=get_temperature #shows the temperature
mtpoe_ctrl --action=get_poe #shows the status of PoE for the ports. 0->ether2, 1..2, 3->ether5
mtpoe_ctrl --action=set_poe --port=0 --val=1 #force-on PoE for port ether2
mtpoe_ctrl --action=set_poe --port=1 --val=2 #auto-on PoE for port ether3
mtpoe_ctrl --action=set_poe --port=2 --val=1 #force-on PoE for port ether4
mtpoe_ctrl --action=set_poe --port=3 --val=0 #turn off PoE for port ether5
mtpoe_ctrl --action=load_poe_from_uci #load PoE port settings from uci->network->poe
In /etc/config/network the poe section should be present:
config poe
option port0 '1'
option port1 '0'
option port2 '1'
option port3 '0'
Control is performed by sending commands via SPI bus. The mediator between userspace
and kernel is spidev driver and as a consequence in mach-rb-*.c init file of the platform it is
necessary to write about the following:
/* RB 750-r2(HB) with POE v2 */
#define RB750R2_ATTINY_CS 12
#define RB750R2_ATTINY_RESET 14
static int rb750r2spi_cs_gpios[3] = {
-ENOENT, /* NOR flash. CS is automatically controlled by the spi controller itself. */
RB750R2SSR_CS, /* 74x164 gpio extender */
RB750R2_ATTINY_CS, /* ATtiny PoE v2 */
};
static struct ath79_spi_platform_data rb750r2spi_data __initdata = {
.bus_num = 0,
.num_chipselect = 3, /* We have three CS */
.cs_gpios = rb750r2spi_cs_gpios, /* which CS */
};
static struct spi_board_info rb750r2spi_info[] = {
...
.max_speed_hz = 10000000,
.modalias = "74x164",
.platform_data = &rb750r2ssr_data,
}, {
.bus_num = 0,
.chip_select = 2,
.max_speed_hz = 2000000,
.modalias = "spidev",
}
}
static void __init rb750r2_setup(void)
{
...
ath79_register_spi(&rb750r2spi_data, rb750r2spi_info, ARRAY_SIZE(rb750r2spi_info));
...
}
or if you use DTS:
&spi {
spidev@2 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "linux,spidev";
reg = <2>;
spi-max-frequency = <2200000>;
};
};
RB500UPr+S+IN:
The board name expected is "mikrotik,rb5009upr".
It is expected the appropriate spi device is defined in DT and the PoE is enabled. This is already ensured with
patches for this board (also refer to https://forum.openwrt.org/t/mikrotik-rb750-r2-series-poe/7032/68).
The get_poe command does not return the ports configuration (0x45), only the status.
Build:
1. Copy openwrt/package/utils/mtpoe_ctrl into <openwrt build tree>/package/utils/
2. In <openwrt build tree> run 'make menuconfig' and select this new package to build
3a. Type 'make' to rebuild the openwrt OR
3b. Type 'make package/utils/mtpoe_ctrl/{clean,compile}' to build this package only