summaryrefslogtreecommitdiff
path: root/include/lan951x-led-ctl.h
diff options
context:
space:
mode:
authorDominic Radermacher <dominic.radermacher@gmail.com>2017-04-30 15:24:49 +0200
committerDominic Radermacher <dominic.radermacher@gmail.com>2017-04-30 15:24:49 +0200
commit33fb66987a6b2a904ee70fafd0a4ef44d0665573 (patch)
treee6c0b3bb72bb23a6d56dc59b79e5388c445f2ebf /include/lan951x-led-ctl.h
initial commitv1.0
Diffstat (limited to 'include/lan951x-led-ctl.h')
-rw-r--r--include/lan951x-led-ctl.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/include/lan951x-led-ctl.h b/include/lan951x-led-ctl.h
new file mode 100644
index 0000000..5b46aa2
--- /dev/null
+++ b/include/lan951x-led-ctl.h
@@ -0,0 +1,64 @@
+/*
+ lan951x-led-ctl - control LEDs of LAN951X ethernet/usb controllers
+
+ Copyright (C) 2015 Dominic Radermacher <dominic.radermacher@gmail.com>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 3 as
+ published by the Free Software Foundation
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#define VERSION "1.0"
+
+#define USB_CTRL_TIMEOUT (5000)
+#define LAN951X_VENDOR_ID (0x0424)
+#define LAN951X_PRODUCT_ID (0xec00)
+
+/* values taken from kernel driver smsc95xx.h */
+#define USB_VENDOR_REQUEST_WR_REG (0xa0)
+#define USB_VENDOR_REQUEST_RD_REG (0xa1)
+#define LED_GPIO_CFG (0x24)
+/* meaning of the bits in the LED_GPIO_CFG register */
+#define GPDAT0 (1<<0)
+#define GPDAT1 (1<<1)
+#define GPDAT2 (1<<2)
+#define GPDIR0 (1<<4)
+#define GPDIR1 (1<<5)
+#define GPDIR2 (1<<6)
+#define GPCTL0 (1<<16)
+#define GPCTL1 (1<<20)
+#define GPCTL2 (1<<24)
+
+#define GP_ALLDIR (GPDIR0 | GPDIR1 | GPDIR2)
+#define GP_ALLDAT (GPDAT0 | GPDAT1 | GPDAT2)
+#define GP_ALLCTL (GPCTL0 | GPCTL1 | GPCTL2)
+
+#define DUP_MASK (GPCTL0 | GPDIR0 | GPDAT0)
+#define LNK_MASK (GPCTL1 | GPDIR1 | GPDAT1)
+#define SPD_MASK (GPCTL2 | GPDIR2 | GPDAT2)
+
+#define DUPIDX (0)
+#define LNKIDX (1)
+#define SPDIDX (2)
+
+#define MODE_OFF 0
+#define MODE_ON 1
+#define MODE_STATUS 2
+#define MODE_KEEP 4
+#define MODE_ERR -1
+
+void usage(void);
+int ledmode(const char* str);
+int parse_args(int argc, char **argv);
+libusb_device_handle *lan951x_open(int vid, int pid);
+int lan951x_rd_reg(libusb_device_handle *h, uint16_t reg, uint32_t *val);
+int lan951x_wr_reg(libusb_device_handle *h, uint16_t reg, uint32_t val);