[OpenWrt-Devel] [PATCH] new package wattsup

2011-03-07 Thread Roberto Riggio

This patch adds a command line utility to interface with the WattsUp
power meters (https://www.wattsupmeters.com/)

Signed-off-by: Roberto Riggioroberto.rig...@create-net.org

--
Index: utils/wattsup/src/wattsup.c
===
--- utils/wattsup/src/wattsup.c (revision 0)
+++ utils/wattsup/src/wattsup.c (revision 0)
@@ -0,0 +1,1877 @@
+/*
+ * wattsup - Program for controlling the Watts Up? Pro Device
+ *
+ *
+ * Copyright (c) 2005 Patrick Mochel
+ *
+ * This program is released under the GPLv2
+ *
+ *
+ * Compiled with:
+ *
+ * gcc -O2 -Wall -o wattsup wattsup.c
+ *
+ */
+
+#define _GNU_SOURCE
+#includestdio.h
+#includestdlib.h
+#includestdarg.h
+#includestring.h
+#includeerrno.h
+#includeunistd.h
+#includefcntl.h
+#includetermios.h
+#includectype.h
+#includegetopt.h
+#includesignal.h
+#includetime.h
+
+#includesys/stat.h
+
+static const char * wu_version = 0.02;
+
+
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
+
+static const char * prog_name = wattsup;
+
+static const char * sysfs_path_start = /sys/class/tty;
+
+static char * wu_device = ttyUSB0;
+static int wu_fd = 0;
+static int wu_count = 0;
+static int wu_debug = 0;
+static char *wu_delim = , ;
+static int wu_final = 0;
+static int wu_interval = 1;
+static int wu_label = 0;
+static int wu_newline = 0;
+static int wu_suppress = 0;
+
+static int wu_localtime = 0;
+static int wu_gmtime = 0;
+
+static int wu_info_all = 0;
+static int wu_no_data = 0;
+static int wu_set_only = 0;
+
+#define wu_strlen  256
+#define wu_num_fields  18
+#define wu_param_len   16
+
+struct wu_packet {
+   unsigned intcmd;
+   unsigned intsub_cmd;
+   unsigned intcount;
+   charbuf[wu_strlen];
+   int len;
+   char* field[wu_num_fields];
+   char* label[wu_num_fields];
+};
+
+
+struct wu_data {
+   unsigned intwatts;
+   unsigned intvolts;
+   unsigned intamps;
+   unsigned intwatt_hours;
+
+   unsigned intcost;
+   unsigned intmo_kWh;
+   unsigned intmo_cost;
+   unsigned intmax_watts;
+
+   unsigned intmax_volts;
+   unsigned intmax_amps;
+   unsigned intmin_watts;
+   unsigned intmin_volts;
+
+   unsigned intmin_amps;
+   unsigned intpower_factor;
+   unsigned intduty_cycle;
+   unsigned intpower_cycle;
+};
+
+struct wu_options {
+   char* longopt;
+   int shortopt;
+   int param;
+   int flag;
+   char* value;
+
+   char* descr;
+   char* option;
+   char* format;
+
+   int (*show)(int dev_fd);
+   int (*store)(int dev_fd);
+};
+
+enum {
+   wu_option_help = 0,
+   wu_option_version,
+
+   wu_option_debug,
+
+   wu_option_count,
+   wu_option_final,
+
+   wu_option_delim,
+   wu_option_newline,
+   wu_option_localtime,
+   wu_option_gmtime,
+   wu_option_label,
+
+   wu_option_suppress,
+
+   wu_option_cal,
+   wu_option_header,
+
+   wu_option_interval,
+   wu_option_mode,
+   wu_option_user,
+
+   wu_option_info_all,
+   wu_option_no_data,
+   wu_option_set_only,
+};
+
+
+static char * wu_option_value(unsigned int index);
+
+
+enum {
+   wu_field_watts  = 0,
+   wu_field_volts,
+   wu_field_amps,
+
+   wu_field_watt_hours,
+   wu_field_cost,
+   wu_field_mo_kwh,
+   wu_field_mo_cost,
+
+   wu_field_max_watts,
+   wu_field_max_volts,
+   wu_field_max_amps,
+
+   wu_field_min_watts,
+   wu_field_min_volts,
+   wu_field_min_amps,
+
+   wu_field_power_factor,
+   wu_field_duty_cycle,
+   wu_field_power_cycle,
+};
+
+struct wu_field {
+   unsigned intenable;
+   char* name;
+   char* descr;
+};
+
+static struct wu_field wu_fields[wu_num_fields] = {
+   [wu_field_watts]= {
+   .name   = watts,
+   .descr  = Watt Consumption,
+   },
+
+   [wu_field_min_watts]= {
+   .name   = min-watts,
+   .descr  = Minimum Watts Consumed,
+   },
+
+   [wu_field_max_watts]= {
+   .name   = max-watts,
+   .descr  = Maxium Watts Consumed,
+   },
+
+   [wu_field_volts]= {
+   .name   = volts,
+   .descr  = Volts Consumption,
+   },
+
+   [wu_field_min_volts]= {
+   .name   = max-volts,
+   .descr  = Minimum Volts Consumed,
+   },
+
+   [wu_field_max_volts]= {
+   .name   = min-volts,
+   .descr  = Maximum Volts Consumed,
+   },
+
+   [wu_field_amps] = {
+   .name   = amps,
+   .descr  = Amp Consumption,
+   },
+
+   [wu_field_min_amps] = {
+   .name   = min-amps,
+   

Re: [OpenWrt-Devel] [PATCH] Initial Board Support for Aztech HW550-3G (Ralink rt3052, ramips)

2011-03-07 Thread Sławomir Cygan
2011/3/7 ZioPRoTo (Saverio Proto) ziopr...@gmail.com:
 This patch adds initial support for the Aztech HW550-3G (Ralink RT3052f SoC,
 8MB flash, 32MB dram).  Ethernet is not working yet.  Wireless appears to
 work fine.  USB does not work yet (as with other Ralink boards).

 At Ninux we found this stuff:
 https://github.com/ago/openwrt

 USB patches for OpenWRT support to ralink, worthed to take a look ?

 Saverio


I do not understand: we found this stuff:
https://github.com/ago/openwrt;, support to ralink, worthed to take a
look ?.

I have not tested theese patches. I have enabled my working copy of
openwrt to support USB on ramips targets using DWC_OTG driver 2.72a
24-JUN-2008 avaliable in some vendor gpl sources.

My patch from http://pastebin.com/hJ7XEJXX adds two files under
target/linux/ramips/patches-2.6.36/ , these patches contain full
dwc_otg driver set to HOST mode. ALso driver selection is enabled in
kernel_menuconfig

-- 
Pozdrawiam,
Sławomir Cygan
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] Initial Board Support for Aztech HW550-3G (Ralink rt3052, ramips)

2011-03-07 Thread Layne M. Edwards
On Sun, 06 Mar 2011 19:14:19 -0500, Layne M. Edwards 
ledwa...@astrumtech.net wrote:

This patch adds initial support for the Aztech HW550-3G (Ralink
RT3052f SoC, 8MB flash, 32MB dram).  Ethernet is not working yet.
Wireless appears to work fine.  USB does not work yet (as with other
Ralink boards).

Signed-off-by: Layne Edwards ledward...@gmail.com



The following patch has updated (corrected) GPIOs for the Aztech 
HW550-3G.  Please use this patch instead of the original.  Still 
troubleshooting why the ethernet isn't working.  Thanks.


Signed-off-by: Layne Edwards ledward...@gmail.com

---

Index: target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig
===
--- target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig	(revision 
25902)
+++ target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig	(working 
copy)

@@ -44,6 +44,12 @@
select RALINK_DEV_GPIO_BUTTONS
select RALINK_DEV_GPIO_LEDS

+config RT305X_MACH_HW550_3G
+   bool Aztech HW550-3G support
+   default y
+   select RALINK_DEV_GPIO_BUTTONS
+   select RALINK_DEV_GPIO_LEDS
+
 endmenu

 endif
Index: 
target/linux/ramips/files/arch/mips/ralink/rt305x/mach-hw550-3g.c

===
--- 
target/linux/ramips/files/arch/mips/ralink/rt305x/mach-hw550-3g.c	(revision 
0)
+++ 
target/linux/ramips/files/arch/mips/ralink/rt305x/mach-hw550-3g.c	(revision 
0)

@@ -0,0 +1,141 @@
+/*
+ *  Aztech HW550-3G board support
+ *
+ *  Copyright (C) 2011 Layne Edwards ledward...@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 2 as 
published

+ *  by the Free Software Foundation.
+ */
+
+#include linux/init.h
+#include linux/platform_device.h
+#include linux/mtd/mtd.h
+#include linux/mtd/partitions.h
+#include linux/mtd/physmap.h
+
+#include asm/mach-ralink/machine.h
+#include asm/mach-ralink/dev-gpio-buttons.h
+#include asm/mach-ralink/dev-gpio-leds.h
+#include asm/mach-ralink/rt305x.h
+#include asm/mach-ralink/rt305x_regs.h
+
+#include devices.h
+
+#define HW550_3G_GPIO_LED_USB  8
+#define HW550_3G_GPIO_LED_3G_STAT  11
+#define HW550_3G_GPIO_LED_3G_TOGGLE12
+#define HW550_3G_GPIO_LED_WPS  14
+
+#define HW550_3G_GPIO_BUTTON_RESET 10
+#define HW550_3G_GPIO_BUTTON_3G7
+#define HW550_3G_GPIO_BUTTON_WPS   0
+
+#define HW550_3G_BUTTONS_POLL_INTERVAL 20
+
+#ifdef CONFIG_MTD_PARTITIONS
+static struct mtd_partition hw550_3g_partitions[] = {
+   {
+   .name   = u-boot,
+   .offset = 0,
+   .size   = 0x03,
+   .mask_flags = MTD_WRITEABLE,
+   }, {
+   .name   = config,
+   .offset = 0x03,
+   .size   = 0x01,
+   .mask_flags = MTD_WRITEABLE,
+   }, {
+   .name   = factory,
+   .offset = 0x04,
+   .size   = 0x01,
+   .mask_flags = MTD_WRITEABLE,
+   }, {
+   .name   = kernel,
+   .offset = 0x05,
+   .size   = 0x18,
+   }, {
+   .name   = rootfs,
+   .offset = 0x1d,
+   .size   = 0x58,
+   }, {
+   .name   = user,
+   .offset = 0x75,
+   .size   = 0x0b,
+   }, {
+   .name   = firmware,
+   .offset = 0x05,
+   .size   = 0x70,
+   }
+};
+#endif /* CONFIG_MTD_PARTITIONS */
+
+static struct physmap_flash_data hw550_3g_flash_data = {
+#ifdef CONFIG_MTD_PARTITIONS
+   .nr_parts   = ARRAY_SIZE(hw550_3g_partitions),
+   .parts  = hw550_3g_partitions,
+#endif
+};
+
+static struct gpio_led hw550_3g_leds_gpio[] __initdata = {
+   {
+   .name   = hw550-3g:green:usb,
+   .gpio   = HW550_3G_GPIO_LED_USB,
+   .active_low = 1,
+   }, {
+   .name   = hw550-3g:green:3g-stat,
+   .gpio   = HW550_3G_GPIO_LED_3G_STAT,
+   .active_low = 1,
+   }, {
+   .name   = hw550-3g:green:3g-toggle,
+   .gpio   = HW550_3G_GPIO_LED_3G_TOGGLE,
+   .active_low = 1,
+   }, {
+   .name   = hw550-3g:green:wps,
+   .gpio   = HW550_3G_GPIO_LED_WPS,
+   .active_low = 1,
+   }
+};
+
+static struct gpio_button hw550_3g_gpio_buttons[] __initdata = {
+   {
+   .desc   = reset,
+   .type   = EV_KEY,
+   .code   = KEY_RESTART,
+   .threshold  = 3,
+   .gpio   = HW550_3G_GPIO_BUTTON_RESET,
+   .active_low = 1,
+   }, {
+   .desc   = 3g,
+   .type   

Re: [OpenWrt-Devel] [PATCH] Initial Board Support for Aztech HW550-3G (Ralink rt3052, ramips)

2011-03-07 Thread John Crispin
On 08/03/11 08:13, Layne M. Edwards wrote:
 On Sun, 06 Mar 2011 19:14:19 -0500, Layne M. Edwards
 ledwa...@astrumtech.net wrote:
 This patch adds initial support for the Aztech HW550-3G (Ralink
 RT3052f SoC, 8MB flash, 32MB dram).  Ethernet is not working yet.
 Wireless appears to work fine.  USB does not work yet (as with other
 Ralink boards).

 Signed-off-by: Layne Edwards ledward...@gmail.com

 
 The following patch has updated (corrected) GPIOs for the Aztech
 HW550-3G.  Please use this patch instead of the original.  Still
 troubleshooting why the ethernet isn't working.  Thanks.
 

the rt305X have a embedded switch. does your board use it or does it
connect a phy to the gbit port ? looking at the driver currently only
esw seems supported

https://dev.openwrt.org/browser/trunk/target/linux/ramips/files/drivers/net/ramips_esw.c
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel