Code Monkey home page Code Monkey logo

mtpoe_ctrl's Introduction

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->mtik_poe

In /etc/config/network the mtik_poe section should be present:
config mtik_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>;
	};
};

mtpoe_ctrl's People

Contributors

adron-s avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.