Re: [OpenWrt-Devel] First boot provisioning

2016-01-26 Thread David Lang

catching up on old e-mail

On Wed, 9 Dec 2015, Lukáš Macura wrote:


Hello,

I would want to start some discussion about first boot provisioning and 
theoretical inclusion of some script into default images.

Today, if somebody want some automatic way to autoconfigure OpenWrt boxes, he 
has to create its own image. But if there is some possibility directly in 
OpenWrt, how to do some well-documented procedure during first boot, first boot 
auto configuration could be offloaded from image. I know there are some 
security issues. But I think that such procedure could be very tiny and 
efficient.

For example, it is very easy to write handler for reset button 
/etc/rc.button/reset :

if [ "$SEEN" -lt 1 ]
then
   echo "REBOOT" > /dev/console
   sync
   reboot
elif [ "$SEEN" -gt 10 ]
then
   ( echo "PROVISIONING"
 wget -q -O- http://openwrt-prov/opkg.repo >/etc/opkg/provisioned.conf
 packages=$(wget -q -O- http://openwrt-prov/default/opkg.install)
 [ -n "$packages" ] && opkg update && opkg install $packages
   ) 2>&1 | logger

elif [ "$SEEN" -gt 5 ]
then
   echo "FACTORY RESET" > /dev/console
   jffs2reset -y && reboot &
fi

so if you press reset button for more than 10 seconds, box will download two 
files from some server. One which can add some local repositories and second to 
get package names to install. Next to this, it will do opkg update and install.
There are more ways how to trigger first boot procedure. This is only proof of 
concept.
Another way is to include this procedure in uci-defaults and run each time when 
device is in factory defaults mode.

Some questions:
- - How to form url? Which url?
- - Is it secure to download some external content by default? No, but this 
will hapen only during first boot.
- - Should this procedure be manual? eg. it needs to press button or 
automaticaly?


It all depends on the environment. For he Scale conference last week, I had 120 
APs out and they got configured by a combination of the base image (populating 
/files) and DHCP parameters. That wouldn't work in home systems where the AP is 
the DHCP.


Automating configuation and updates from your own system is a great thing to do. 
Doing so from someone else's system on the Internet is something else. And 
taking on the responsibility for holding such configs (and the potential 
liability if the configs get tampered with and access is granted to lots of 
peoples systmes) is something else again. It's not something Openwrt is going to 
want to get involved with.



The bigger issue is that the reason why most openwrt devices get updated by 
flashing a complete image is the shortage of storage on them. By using a 
pre-compressed, read-only filesystem, the compression ratio is much higher, but 
it means that anything that gets installed on the device after that point has 
two versions taking up space, the original, highly compressed version, and a 
later, less compressed version. You very quickly run out of space updating 
individual packages and overriding basic configs.


But I do like the idea of holding the reset button down to pull from a local 
system. I'll use that trick in the future :-)


David Lang___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v3] base-files: For sysfixtime use hwclock if RTC available

2016-01-26 Thread John Crispin


On 26/01/2016 21:35, Petr Štetiar wrote:
> Bastian Bittorf  [2016-01-21 12:53:48]:
> 
>> * Petr Štetiar  [21.01.2016 12:22]:
>>>  boot() {
>>> +   [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV && 
>>> exit 0
>>
>> thank you! can you please do in this line a:
>> && return
> 
> Like following?
> 
>   deps_ok && $HWCLOCK -s -f $RTC_DEV && exit 0 && return 
> 
> Is it really needed? I've always thought, that exit will terminate the script
> so the return wouldn't be called anyway.
> 
>> and introduce a helper (maybe overengineered 8-)
> 
> Kind of, was thinking about it also so I'll change it, thanks.
> 
>> deps_ok() {
>>  [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ]
>> }
> 
> -- ynezz

please don't add a helper. instead just call start from boot, honour its
return code and then decide if you want to run the exising code.

John

> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> 
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Question about custom script at init on Trunk.-

2016-01-26 Thread Eric Schultz
Guillermo,

It's always best to use a custom package if you can. Modifying upstream
leads to problems like this.

I don't think you'd need those changes in uci-defaults.sh. Instead, I think
you should put your changes in your own uci-default, like 02_network, but
your own. Use a number after 02, like 03_custom and put it in
/etc/uci-defaults. It should run on first boot. As long as this uci-default
script completes successfully, I think the change should occur and the
script itself should be deleted so it doesn't run again.

Eric


On Tue, Jan 26, 2016 at 6:19 PM, Guillermo Javier Nardoni <
guille...@geryon.com.ar> wrote:

> Hello everyone,
>
> At first, I should say that I've been away a long time from openwrt-devel
> mailing list.
>
> I was using Barrier Braker 14.07 to build our custom firmware, usually for
> TP-Link WR740/741 v3/v4, but recently we have received TP-Link WR740 v5
> (a.k.a. 741 v5) so I figured out that Barrier Braker don't have support for
> it, at least not native one.
> Googling I found a solution which I've flashed it first with a stripped
> custom firmware found on Internet and then, via console, do a beautifull
> reflash with WR741 v4 firmware (build by us) and everything Works perfect!.
>
> Since I'm not the one who flashes the devices I did a new git from trunk
> versión of OpenWrt (CHAOS CALMER (15.05)) because it has native support for
> TP-Link TL-WR740N versión 5 but when I looked into the code I've figured
> out, again, that the code changed a lot since the BB 14.07 and I don't know
> how to adapt the custom configurations.
>
> The reason I changed those 2 files it is because of the users sometimes (i
> mean always) press the reset button and it won't allow us to remotely
> recofigure the device and to use one port of the switch to bridge it with
> the WAN port to use them just because we have ATAs devices that don't
> support NAT etc etc.
> When a user presses the reset button, it resets the device and configure it
> with a standard configuration which let the user to have Telephone (VoIP),
> Internet, Wifi and we can Access remotely to reconfigure it as I said
> before.
>
> On BB 14.07 I've just modified 2 files:
> ./package/base-files/files/lib/functions/uci-defaults.sh
> ...
>
> ucidef_add_switch() {
> local name=$1
> local reset=$2
> local enable=$3
> uci batch < add network switch
> set network.@switch[-1].name='$name'
> set network.@switch[-1].reset='$reset'
> set network.@switch[-1].enable_vlan='$enable'
> EOF
> }
>
> ucidef_add_switch_vlan() {
> local device=$1
> local vlan=$2
> local ports=$3
> local device_name=$4
> uci batch < set network.$4=switch_vlan
> set network.$4.device='$device'
> set network.$4.vlan='$vlan'
> set network.$4.ports='$ports'
>
> EOF
> #add network switch_vlan
> #set network.$device_name.device='$device'
> #set network.$device_name.vlan='$vlan'
> #set network.$device_name.ports='$ports'
> }
>
> ucidef_add_switch_port() {
> local device=$1
> local port=$2
> uci batch < add network switch_port
> set network.@switch_port[-1].device='$device'
> set network.@switch_port[-1].port='$port'
> EOF
> }
>
> And file:
> ./target/linux/ar71xx/base-files/etc/uci-defaults/02_network
>
> ap121 |\
> ap121-mini |\
> ap96 |\
> airrouter |\
> dir-600-a1 |\
> dir-615-c1 |\
> dir-615-e1 |\
> dir-615-e4 |\
> hiwifi-hc6361 |\
> ja76pf |\
> mynet-n600 |\
> oolite |\
> rb-750 |\
> rb-751 |\
> tew-632brp |\
> tew-712br |\
> tl-mr3220 |\
> tl-mr3220-v2 |\
> tl-mr3420 |\
> tl-wdr3500 |\
> tl-wr741nd |\
> tl-wr741nd-v4 |\
> tl-wr841n-v7 |\
> tl-wr841n-v9 |\
> whr-g301n |\
> whr-hp-g300n |\
> whr-hp-gn |\
> wzr-hp-ag300h)
> ucidef_set_interfaces_lan_wan "eth0.1" "eth1 eth0.2"
> ucidef_add_switch "switch0" "1" "1"
> ucidef_add_switch_vlan "switch0" "1" "1 3 4 0t" "eth0_1"
> ucidef_add_switch_vlan "switch0" "2" "2 0t" "eth0_2"
> ;;
>
> But in new trunk version I found those files but uci-defaults.sh uses json.
> Could you please lend me a hand?.
>
> Would it be a great idea to build a custom package insted of modify the
> "upstream" code?
>
> Thanks in advance.
>
> Best Regards,
> Guillermo Nardoni.
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>



-- 
Eric Schultz, Community Manager, prpl Foundation
http://www.prplfoundation.org
eschu...@prplfoundation.org
cell: 920-539-0404
skype: ericschultzwi
@EricPrpl
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 8/8] ath79: all LEDs and buttons for Netgear WNR2000v3

2016-01-26 Thread Michal
From: Michal Cieslakiewicz 

This patch provides full GPIO support for WNR2000v3 (LEDs and buttons).
It exposes all LEDs to operating system, including Ethernet ones.

Signed-off-by: Michal Cieslakiewicz 
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |  14 +++
 target/linux/ar71xx/base-files/etc/diag.sh |   1 +
 .../ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c | 137 +++--
 3 files changed, 142 insertions(+), 10 deletions(-)

diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds 
b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index 151eac2..7374422 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -676,6 +676,20 @@ wlae-ag300n)
ucidef_set_led_netdev "wireless" "WIRELESS" "buffalo:green:wireless" 
"wlan0"
;;
 
+wnr2000-v3)
+   ucidef_set_led_netdev "wan-amber" "WAN (amber)" "netgear:amber:wan" 
"eth0"
+   ucidef_set_led_default "wan-green" "WAN (green)" "netgear:green:wan" "0"
+   ucidef_set_led_netdev "wlan" "WLAN" "netgear:blue:wlan" "wlan0"
+   ucidef_set_led_switch "lan1green" "LAN1 (green)" "netgear:green:lan1" 
"switch0" "0x02"
+   ucidef_set_led_switch "lan2green" "LAN2 (green)" "netgear:green:lan2" 
"switch0" "0x04"
+   ucidef_set_led_switch "lan3green" "LAN3 (green)" "netgear:green:lan3" 
"switch0" "0x08"
+   ucidef_set_led_switch "lan4green" "LAN4 (green)" "netgear:green:lan4" 
"switch0" "0x10"
+   ucidef_set_led_default "lan1amber" "LAN1 (amber)" "netgear:amber:lan1" 
"0"
+   ucidef_set_led_default "lan2amber" "LAN2 (amber)" "netgear:amber:lan2" 
"0"
+   ucidef_set_led_default "lan3amber" "LAN3 (amber)" "netgear:amber:lan3" 
"0"
+   ucidef_set_led_default "lan4amber" "LAN4 (amber)" "netgear:amber:lan4" 
"0"
+   ;;
+
 wnr2000-v4)
ucidef_set_led_netdev "wan" "WAN" "netgear:green:wan" "eth0"
ucidef_set_led_netdev "wlan" "WLAN" "netgear:blue:wlan" "wlan0"
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh 
b/target/linux/ar71xx/base-files/etc/diag.sh
index c0e73ad..4ee40f7 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -368,6 +368,7 @@ get_status_led() {
wndr3700v4 | \
wndr4300 | \
wnr2000 | \
+   wnr2000-v3 |\
wnr2200 |\
wnr612-v2 |\
wnr1000-v2 |\
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c 
b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c
index ee6b449..b4ca9b1 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c
@@ -14,6 +14,7 @@
 
 #include 
 #include 
+#include  /* PLATFORM_DEVID_AUTO is defined here */
 
 #include 
 #include  /* needed to disable switch LEDs */
@@ -26,11 +27,25 @@
 #include "dev-m25p80.h"
 #include "machtypes.h"
 
+/* ar7241 GPIOs */
 #define WNR2000V3_GPIO_LED_WAN_GREEN   0
 #define WNR2000V3_GPIO_LED_LAN1_AMBER  1
-#define WNR2000V3_GPIO_LED_LAN4_AMBER  12
-#define WNR2000V3_GPIO_LED_PWR_GREEN   14
+#define WNR2000V3_GPIO_LED_LAN2_AMBER  6
+#define WNR2000V3_GPIO_LED_WPS_GREEN   7
+#define WNR2000V3_GPIO_LED_LAN3_AMBER  8
 #define WNR2000V3_GPIO_BTN_WPS 11
+#define WNR2000V3_GPIO_LED_LAN4_AMBER  12
+#define WNR2000V3_GPIO_LED_LAN1_GREEN  13
+#define WNR2000V3_GPIO_LED_LAN2_GREEN  14
+#define WNR2000V3_GPIO_LED_LAN3_GREEN  15
+#define WNR2000V3_GPIO_LED_LAN4_GREEN  16
+#define WNR2000V3_GPIO_LED_WAN_AMBER   17
+/* ar9287 GPIOs */
+#define WNR2000V3_GPIO_WMAC_LED_WLAN_BLUE  1
+#define WNR2000V3_GPIO_WMAC_LED_TEST_AMBER 2
+#define WNR2000V3_GPIO_WMAC_LED_POWER_GREEN3
+#define WNR2000V3_GPIO_WMAC_BTN_RESET  8
+#define WNR2000V3_GPIO_WMAC_BTN_RFKILL 9
 
 #define WNR612V2_GPIO_LED_PWR_GREEN11
 
@@ -69,16 +84,67 @@
 
 static struct gpio_led wnr2000v3_leds_gpio[] __initdata = {
{
-   .name   = "wnr2000v3:green:power",
-   .gpio   = WNR2000V3_GPIO_LED_PWR_GREEN,
+   .name   = "netgear:green:wan",
+   .gpio   = WNR2000V3_GPIO_LED_WAN_GREEN,
.active_low = 1,
}, {
-   .name   = "wnr2000v3:green:wan",
-   .gpio   = WNR2000V3_GPIO_LED_WAN_GREEN,
+   .name   = "netgear:amber:lan1",
+   .gpio   = WNR2000V3_GPIO_LED_LAN1_AMBER,
+   .active_low = 1,
+   }, {
+   .name   = "netgear:amber:lan2",
+   .gpio   = WNR2000V3_GPIO_LED_LAN2_AMBER,
+   .active_low = 1,
+   }, {
+   .name   = "netgear:amber:lan3",
+   .gpio   = WNR2000V3_GPIO_LED_LAN3_AMBER,
+   .active_low = 1,
+   }, {
+   .name   = "netgear:amber:lan4",
+   .gpio   = WNR2000V3_GPIO_LED

[OpenWrt-Devel] [PATCH 7/8] ath79: fix for random WLAN MAC for WNR2000v3

2016-01-26 Thread Michal
From: Michal Cieslakiewicz 

Fix for invalid/random WLAN MAC address in WNR2000v3. Permanent platform MAC
is calculated and assigned during system startup. WLAN MAC follows wired
Ethernet interface addresses.

Signed-off-by: Michal Cieslakiewicz 
---
 .../ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c | 30 +-
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c 
b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c
index 205c2e7..ee6b449 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c
@@ -181,7 +181,7 @@ static struct gpio_keys_button wnr2000v3_gpio_keys[] 
__initdata = {
}
 };
 
-static void __init wnr_common_setup(void)
+static void __init wnr_common_setup(u8 *wmac_addr)
 {
u8 *art = (u8 *) KSEG1ADDR(0x1fff);
 
@@ -200,12 +200,30 @@ static void __init wnr_common_setup(void)
ath79_register_eth(1);
 
ath79_register_m25p80(NULL);
-   ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, NULL);
+   ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, wmac_addr);
 }
 
 static void __init wnr2000v3_setup(void)
 {
-   wnr_common_setup();
+   u8 *art = (u8 *) KSEG1ADDR(0x1fff);
+   u8 wlan_mac_addr[6];
+   u8 *eth0_mac_addr = (u8 *) (art + WNR2000V3_MAC0_OFFSET);
+   u8 *eth1_mac_addr = (u8 *) (art + WNR2000V3_MAC1_OFFSET);
+
+   /*
+* For WNR2000v3 ART flash area used for wlan MAC is usually empty 
(0xff)
+* so ath9k driver uses random MAC instead each time module is loaded.
+* To fix that, assign permanent wlan MAC equal to ethN's MAC plus 1,
+* so network interfaces get sequential addresses.
+*/
+   memcpy(wlan_mac_addr, eth0_mac_addr, sizeof(wlan_mac_addr));
+   wlan_mac_addr[5] = (eth0_mac_addr[5] > eth1_mac_addr[5] ?
+  eth0_mac_addr[5] : eth1_mac_addr[5]) + 1;
+
+   /* Avoid potential conflict in case: max(0xff,0x00)+1==0x00 */
+   if (!wlan_mac_addr[5]) wlan_mac_addr[5] = 1;
+
+   wnr_common_setup(wlan_mac_addr);
 
ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v3_leds_gpio),
 wnr2000v3_leds_gpio);
@@ -219,7 +237,7 @@ MIPS_MACHINE(ATH79_MACH_WNR2000_V3, "WNR2000V3", "NETGEAR 
WNR2000 V3", wnr2000v3
 
 static void __init wnr612v2_setup(void)
 {
-   wnr_common_setup();
+   wnr_common_setup(NULL);
 
ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio),
 wnr612v2_leds_gpio);
@@ -229,7 +247,7 @@ MIPS_MACHINE(ATH79_MACH_WNR612_V2, "WNR612V2", "NETGEAR 
WNR612 V2", wnr612v2_set
 
 static void __init wnr1000v2_setup(void)
 {
-   wnr_common_setup();
+   wnr_common_setup(NULL);
 
ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr1000v2_leds_gpio),
 wnr1000v2_leds_gpio);
@@ -247,7 +265,7 @@ static void __init wpn824n_setup(void)
  AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN |
  AR724X_GPIO_FUNC_CLK_OBS3_EN);
 
-   wnr_common_setup();
+   wnr_common_setup(NULL);
 
ath79_register_leds_gpio(-1, ARRAY_SIZE(wpn824n_leds_gpio),
 wpn824n_leds_gpio);
-- 
2.6.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 6/8] package: exclude USB modules from WNR2000v3 image

2016-01-26 Thread Michal
From: Michal Cieslakiewicz 

Netgear WNR2000v3 has no USB port yet default system image
includes USB kernel modules. This patch fixes that.

Signed-off-by: Michal Cieslakiewicz 
---
 target/linux/ar71xx/generic/profiles/netgear.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/linux/ar71xx/generic/profiles/netgear.mk 
b/target/linux/ar71xx/generic/profiles/netgear.mk
index ca22a18..0b05adf 100644
--- a/target/linux/ar71xx/generic/profiles/netgear.mk
+++ b/target/linux/ar71xx/generic/profiles/netgear.mk
@@ -30,6 +30,7 @@ $(eval $(call Profile,WNDR3700))
 
 define Profile/WNR2000V3
NAME:=NETGEAR WNR2000V3
+   PACKAGES:=
 endef
 
 define Profile/WNR2000V3/Description
-- 
2.6.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 5/8] ath9k: enable GPIO buttons

2016-01-26 Thread Michal
From: Michal Cieslakiewicz 

Enable platform-defined GPIO button support for ath9k device. Key poller
is activated for attached platform buttons. Requires ath9k GPIO chip access.

Signed-off-by: Michal Cieslakiewicz 
---
 .../patches/550-ath9k_enable_gpio_buttons.patch| 164 +
 .../ar71xx/files/arch/mips/ath79/dev-ap9x-pci.c|  18 +++
 .../ar71xx/files/arch/mips/ath79/dev-ap9x-pci.h|   7 +
 .../generic/files/include/linux/ath9k_platform.h   |   4 +
 4 files changed, 193 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/550-ath9k_enable_gpio_buttons.patch

diff --git 
a/package/kernel/mac80211/patches/550-ath9k_enable_gpio_buttons.patch 
b/package/kernel/mac80211/patches/550-ath9k_enable_gpio_buttons.patch
new file mode 100644
index 000..0c8af26
--- /dev/null
+++ b/package/kernel/mac80211/patches/550-ath9k_enable_gpio_buttons.patch
@@ -0,0 +1,164 @@
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
 b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -825,6 +825,13 @@ int ath_create_gpio_led(struct ath_softc
+ void ath9k_register_gpio_chip(struct ath_softc *sc);
+ void ath9k_unregister_gpio_chip(struct ath_softc *sc);
+ 
++/**/
++/*  GPIO Buttons  */
++/**/
++
++void ath9k_init_buttons(struct ath_softc *sc);
++void ath9k_deinit_buttons(struct ath_softc *sc);
++
+ #else
+ static inline void ath_init_leds(struct ath_softc *sc)
+ {
+@@ -843,6 +850,13 @@ static inline void ath9k_register_gpio_c
+ static inline void ath9k_unregister_gpio_chip(struct ath_softc *sc)
+ {
+ }
++
++void ath9k_init_buttons(struct ath_softc *sc)
++{
++}
++void ath9k_deinit_buttons(struct ath_softc *sc)
++{
++}
+ #endif
+ 
+ //
+@@ -1039,6 +1053,7 @@ struct ath_softc {
+   const char *led_default_trigger;
+   struct list_head leds;
+   struct ath9k_gpio_chip *gpiochip;
++  struct platform_device *btnpdev;/* gpio-keys-polled */
+ #endif
+ 
+ #ifdef CPTCFG_ATH9K_DEBUGFS
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
 b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -24,6 +24,8 @@
+ #ifdef CPTCFG_MAC80211_LEDS
+ 
+ #include 
++#include 
++#include 
+ 
+ static void ath_led_brightness(struct led_classdev *led_cdev,
+  enum led_brightness brightness)
+@@ -312,6 +314,83 @@ void ath9k_unregister_gpio_chip(struct a
+   sc->gpiochip = NULL;
+ }
+ 
++/**/
++/*  GPIO Buttons  */
++/**/
++
++/* add GPIO buttons */
++void ath9k_init_buttons(struct ath_softc *sc)
++{
++  struct ath9k_platform_data *pdata = sc->dev->platform_data;
++  struct platform_device *pdev;
++  struct gpio_keys_platform_data gkpdata;
++  struct gpio_keys_button *bt;
++  int i;
++
++  if (!sc->gpiochip)
++  return;
++
++  bt = kmemdup(pdata->btns,
++   pdata->num_btns * sizeof(struct gpio_keys_button),
++   GFP_KERNEL);
++
++  if (!bt)
++  return;
++
++  pdev = platform_device_alloc("gpio-keys-polled", PLATFORM_DEVID_AUTO);
++
++  if (!pdev)
++  goto err_bt_free;
++
++  for (i = 0; i < pdata->num_btns; i++) {
++  ath9k_hw_cfg_gpio_input(sc->sc_ah, pdata->btns[i].gpio);
++  bt[i].gpio = sc->gpiochip->gchip.base + pdata->btns[i].gpio;
++  }
++
++  memset(&gkpdata, 0, sizeof(struct gpio_keys_platform_data));
++  gkpdata.buttons = bt;
++  gkpdata.nbuttons = pdata->num_btns;
++  gkpdata.poll_interval = pdata->btn_poll_interval;
++
++  if (platform_device_add_data(pdev, &gkpdata, sizeof(gkpdata)))
++  goto err_pdev_put;
++
++  if (platform_device_add(pdev))
++  goto err_pdev_put;
++
++  sc->btnpdev = pdev;
++
++  return;
++
++err_pdev_put:
++  platform_device_put(pdev);
++
++err_bt_free:
++  kfree(bt);
++}
++
++/* remove GPIO buttons */
++void ath9k_deinit_buttons(struct ath_softc *sc)
++{
++  struct gpio_keys_platform_data *gkpdata;
++  struct gpio_keys_button *bt = NULL;
++
++  if (!sc->gpiochip || !sc->btnpdev)
++  return;
++
++  gkpdata = sc->btnpdev->dev.platform_data;
++  if (gkpdata)
++  bt = gkpdata->buttons;
++
++  platform_device_del(sc->btnpdev);
++  platform_device_put(sc->btnpdev);
++
++  sc->btnpdev = NULL;
++
++  if (bt)
++  kfree(bt);
++}
++
+ #endif
+ 
+ /***/
+--- a/drivers/net/wireless/ath/ath9k/init.c
 b/drivers/net/wireless/ath/ath9k/init.c
+@@ -981,6 +981,7 @@ int ath9k_init_device(u16 devid, struct
+ 
+   ath9k_register_gpio_chip(sc);
+   ath_init_leds(sc);
++  ath9k_init_buttons(sc);
+   ath_start_rfkill_poll(sc);
+ 
+   return 0;
+@@ -1026,6 +1027,7 @@ void ath9k_deinit_device(struct ath_soft
+   ath9k_ps_wakeup(sc);
+ 
+   wiphy_rfkill_stop_polling(sc->hw->wiphy);
++  ath9k_deinit_buttons(sc);
+   ath_deinit_leds(sc);
+   ath9k_unregister_gpio_chip

[OpenWrt-Devel] [PATCH 4/8] ath9k: enable access to GPIO

2016-01-26 Thread Michal
From: Michal Cieslakiewicz 

Enable access to GPIO chip and its pins for Atheros AR92xx
wireless devices. For now AR9285 and AR9287 are supported.

Signed-off-by: Michal Cieslakiewicz 
---
 .../patches/549-ath9k_enable_gpio_chip.patch   | 233 +
 1 file changed, 233 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/549-ath9k_enable_gpio_chip.patch

diff --git a/package/kernel/mac80211/patches/549-ath9k_enable_gpio_chip.patch 
b/package/kernel/mac80211/patches/549-ath9k_enable_gpio_chip.patch
new file mode 100644
index 000..df38009
--- /dev/null
+++ b/package/kernel/mac80211/patches/549-ath9k_enable_gpio_chip.patch
@@ -0,0 +1,233 @@
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
 b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -24,6 +24,7 @@
+ #include 
+ #include 
+ #include 
++#include 
+ 
+ #include "common.h"
+ #include "debug.h"
+@@ -817,6 +818,13 @@ void ath_fill_led_pin(struct ath_softc *
+ int ath_create_gpio_led(struct ath_softc *sc, int gpio, const char *name,
+ const char *trigger, bool active_low);
+ 
++/***/
++/*  GPIO Chip  */
++/***/
++
++void ath9k_register_gpio_chip(struct ath_softc *sc);
++void ath9k_unregister_gpio_chip(struct ath_softc *sc);
++
+ #else
+ static inline void ath_init_leds(struct ath_softc *sc)
+ {
+@@ -828,6 +836,13 @@ static inline void ath_deinit_leds(struc
+ static inline void ath_fill_led_pin(struct ath_softc *sc)
+ {
+ }
++
++static inline void ath9k_register_gpio_chip(struct ath_softc *sc)
++{
++}
++static inline void ath9k_unregister_gpio_chip(struct ath_softc *sc)
++{
++}
+ #endif
+ 
+ //
+@@ -963,6 +978,12 @@ struct ath_led {
+   struct led_classdev cdev;
+ };
+ 
++struct ath9k_gpio_chip {
++  struct ath_softc *sc;
++  char label[32];
++  struct gpio_chip gchip;
++};
++
+ struct ath_softc {
+   struct ieee80211_hw *hw;
+   struct device *dev;
+@@ -1017,6 +1038,7 @@ struct ath_softc {
+ #ifdef CPTCFG_MAC80211_LEDS
+   const char *led_default_trigger;
+   struct list_head leds;
++  struct ath9k_gpio_chip *gpiochip;
+ #endif
+ 
+ #ifdef CPTCFG_ATH9K_DEBUGFS
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
 b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -22,6 +22,9 @@
+ //
+ 
+ #ifdef CPTCFG_MAC80211_LEDS
++
++#include 
++
+ static void ath_led_brightness(struct led_classdev *led_cdev,
+  enum led_brightness brightness)
+ {
+@@ -60,6 +63,10 @@ static int ath_add_led(struct ath_softc
+   else
+   ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low);
+ 
++  /* If there is GPIO chip configured, reserve LED pin */
++  if (sc->gpiochip)
++  gpio_request(sc->gpiochip->gchip.base + gpio->gpio, gpio->name);
++
+   return 0;
+ }
+ 
+@@ -116,6 +123,9 @@ void ath_deinit_leds(struct ath_softc *s
+ 
+   while (!list_empty(&sc->leds)) {
+   led = list_first_entry(&sc->leds, struct ath_led, list);
++  /* If there is GPIO chip configured, free LED pin */
++  if (sc->gpiochip)
++  gpio_free(sc->gpiochip->gchip.base + led->gpio->gpio);
+   list_del(&led->list);
+   ath_led_brightness(&led->cdev, LED_OFF);
+   led_classdev_unregister(&led->cdev);
+@@ -186,6 +196,122 @@ void ath_fill_led_pin(struct ath_softc *
+   /* LED off, active low */
+   ath9k_hw_set_gpio(ah, ah->led_pin, (ah->config.led_active_high) ? 0 : 
1);
+ }
++
++/***/
++/*  GPIO Chip  */
++/***/
++
++/* gpio_chip handler : set GPIO to input */
++static int ath9k_gpio_pin_cfg_input(struct gpio_chip *chip, unsigned offset)
++{
++  struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip,
++gchip);
++
++  ath9k_hw_cfg_gpio_input(gc->sc->sc_ah, offset);
++
++  return 0;
++}
++
++/* gpio_chip handler : set GPIO to output */
++static int ath9k_gpio_pin_cfg_output(struct gpio_chip *chip, unsigned offset,
++   int value)
++{
++  struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip,
++gchip);
++
++  ath9k_hw_cfg_output(gc->sc->sc_ah, offset,
++  AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
++  ath9k_hw_set_gpio(gc->sc->sc_ah, offset, value);
++
++  return 0;
++}
++
++/* gpio_chip handler : query GPIO direction (0=out, 1=in) */
++static int ath9k_gpio_pin_get_dir(struct gpio_chip *chip, unsigned offset)
++{
++  struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip,
++gchip);
++  struct ath_hw *ah = gc->sc->sc_ah;
++
++  return !((REG_READ(ah, AR_GPIO_OE_OUT) >> (offset * 2)) & 3);
++}
++
++/* gpio_chip handler : get GPIO pin value */
++static int ath9k_gpio_pin_get(struct gpio_chip *chip,

[OpenWrt-Devel] [PATCH 3/8] ath9k: show platform MAC address in kernel log if set

2016-01-26 Thread Michal
From: Michal Cieslakiewicz 

Add information in kernel log during module startup if MAC address
of WLAN device is overridden by platform-supplied one.

Signed-off-by: Michal Cieslakiewicz 
---
 .../mac80211/patches/548-ath9k_platform_mac_info.patch   | 16 
 1 file changed, 16 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/548-ath9k_platform_mac_info.patch

diff --git a/package/kernel/mac80211/patches/548-ath9k_platform_mac_info.patch 
b/package/kernel/mac80211/patches/548-ath9k_platform_mac_info.patch
new file mode 100644
index 000..76115e1
--- /dev/null
+++ b/package/kernel/mac80211/patches/548-ath9k_platform_mac_info.patch
@@ -0,0 +1,16 @@
+--- a/drivers/net/wireless/ath/ath9k/init.c
 b/drivers/net/wireless/ath/ath9k/init.c
+@@ -640,8 +640,12 @@ static int ath9k_init_softc(u16 devid, s
+   if (ret)
+   goto err_hw;
+ 
+-  if (pdata && pdata->macaddr)
++  if (pdata && pdata->macaddr) {
+   memcpy(common->macaddr, pdata->macaddr, ETH_ALEN);
++  ath_info(common,
++   "platform MAC address will be used: %pM\n",
++   common->macaddr);
++  }
+ 
+   ret = ath9k_init_queues(sc);
+   if (ret)
-- 
2.6.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/8] ath9k: set default state for platform LEDs

2016-01-26 Thread Michal
From: Michal Cieslakiewicz 

Support default state for platform LEDs connected to ath9k device.
Now LEDs are correctly set on or off at ath9k module initialization.

Signed-off-by: Michal Cieslakiewicz 
---
 .../mac80211/patches/547-ath9k_led_defstate_fix.patch| 16 
 1 file changed, 16 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/547-ath9k_led_defstate_fix.patch

diff --git a/package/kernel/mac80211/patches/547-ath9k_led_defstate_fix.patch 
b/package/kernel/mac80211/patches/547-ath9k_led_defstate_fix.patch
new file mode 100644
index 000..3ecffb8
--- /dev/null
+++ b/package/kernel/mac80211/patches/547-ath9k_led_defstate_fix.patch
@@ -0,0 +1,16 @@
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
 b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -54,8 +54,11 @@ static int ath_add_led(struct ath_softc
+   ath9k_hw_cfg_output(sc->sc_ah, gpio->gpio,
+   AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
+ 
+-  /* LED off */
+-  ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low);
++  /* Set default LED state */
++  if (gpio->default_state == LEDS_GPIO_DEFSTATE_ON)
++  ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, !gpio->active_low);
++  else
++  ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low);
+ 
+   return 0;
+ }
-- 
2.6.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/8] ath9k: enable platform WLAN LED name

2016-01-26 Thread Michal
From: Michal Cieslakiewicz 

Enable platform-supplied WLAN LED name for ath9k device.

Signed-off-by: Michal Cieslakiewicz 
---
 .../patches/546-ath9k_platform_led_name.patch  | 35 ++
 .../ar71xx/files/arch/mips/ath79/dev-ap9x-pci.c| 12 
 .../ar71xx/files/arch/mips/ath79/dev-ap9x-pci.h|  3 ++
 .../generic/files/include/linux/ath9k_platform.h   |  1 +
 4 files changed, 51 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/546-ath9k_platform_led_name.patch

diff --git a/package/kernel/mac80211/patches/546-ath9k_platform_led_name.patch 
b/package/kernel/mac80211/patches/546-ath9k_platform_led_name.patch
new file mode 100644
index 000..04e312d
--- /dev/null
+++ b/package/kernel/mac80211/patches/546-ath9k_platform_led_name.patch
@@ -0,0 +1,35 @@
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
 b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -132,15 +132,19 @@ void ath_init_leds(struct ath_softc *sc)
+   if (AR_SREV_9100(sc->sc_ah))
+   return;
+ 
+-  snprintf(led_name, sizeof(led_name), "ath9k-%s",
+-   wiphy_name(sc->hw->wiphy));
++  if (pdata && pdata->led_name)
++  strncpy(led_name, pdata->led_name, sizeof(led_name));
++  else
++  snprintf(led_name, sizeof(led_name), "ath9k-%s",
++   wiphy_name(sc->hw->wiphy));
+ 
+   if (ath9k_led_blink)
+   trigger = sc->led_default_trigger;
+   else
+   trigger = ieee80211_get_radio_led_name(sc->hw);
+ 
+-  ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, 
!sc->sc_ah->config.led_active_high);
++  ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger,
++  !sc->sc_ah->config.led_active_high);
+ 
+   if (!pdata)
+   return;
+--- a/include/linux/ath9k_platform.h
 b/include/linux/ath9k_platform.h
+@@ -45,6 +45,7 @@ struct ath9k_platform_data {
+ 
+   int num_leds;
+   const struct gpio_led *leds;
++  const char *led_name;
+ };
+ 
+ #endif /* _LINUX_ATH9K_PLATFORM_H */
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-ap9x-pci.c 
b/target/linux/ar71xx/files/arch/mips/ath79/dev-ap9x-pci.c
index d382453..bf80d4d 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/dev-ap9x-pci.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-ap9x-pci.c
@@ -39,6 +39,18 @@ __init void ap9x_pci_setup_wmac_led_pin(unsigned wmac, int 
pin)
}
 }
 
+__init void ap9x_pci_setup_wmac_led_name(unsigned wmac, const char *led_name)
+{
+   switch (wmac) {
+   case 0:
+   ap9x_wmac0_data.led_name = led_name;
+   break;
+   case 1:
+   ap9x_wmac1_data.led_name = led_name;
+   break;
+   }
+}
+
 __init struct ath9k_platform_data *ap9x_pci_get_wmac_data(unsigned wmac)
 {
switch (wmac) {
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-ap9x-pci.h 
b/target/linux/ar71xx/files/arch/mips/ath79/dev-ap9x-pci.h
index ad288cb..dcfe541 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/dev-ap9x-pci.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-ap9x-pci.h
@@ -19,6 +19,7 @@ void ap9x_pci_setup_wmac_led_pin(unsigned wmac, int pin);
 void ap9x_pci_setup_wmac_gpio(unsigned wmac, u32 mask, u32 val);
 void ap9x_pci_setup_wmac_leds(unsigned wmac, struct gpio_led *leds,
  int num_leds);
+void ap9x_pci_setup_wmac_led_name(unsigned wmac, const char *led_name);
 struct ath9k_platform_data *ap9x_pci_get_wmac_data(unsigned wmac);
 
 void ap91_pci_init(u8 *cal_data, u8 *mac_addr);
@@ -33,6 +34,8 @@ static inline void ap9x_pci_setup_wmac_gpio(unsigned wmac,
 static inline void ap9x_pci_setup_wmac_leds(unsigned wmac,
struct gpio_led *leds,
int num_leds) {}
+static inline void ap9x_pci_setup_wmac_led_name(unsigned wmac,
+   const char *led_name) {}
 static inline struct ath9k_platform_data *ap9x_pci_get_wmac_data(unsigned wmac)
 {
return NULL;
diff --git a/target/linux/generic/files/include/linux/ath9k_platform.h 
b/target/linux/generic/files/include/linux/ath9k_platform.h
index 30ce216..823e5ac 100644
--- a/target/linux/generic/files/include/linux/ath9k_platform.h
+++ b/target/linux/generic/files/include/linux/ath9k_platform.h
@@ -45,6 +45,7 @@ struct ath9k_platform_data {
 
int num_leds;
const struct gpio_led *leds;
+   const char *led_name;
 };
 
 #endif /* _LINUX_ATH9K_PLATFORM_H */
-- 
2.6.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Question about custom script at init on Trunk.-

2016-01-26 Thread Guillermo Javier Nardoni
Hello everyone, 

At first, I should say that I’ve been away a long time from openwrt-devel
mailing list. 

I was using Barrier Braker 14.07 to build our custom firmware, usually for
TP-Link WR740/741 v3/v4, but recently we have received TP-Link WR740 v5
(a.k.a. 741 v5) so I figured out that Barrier Braker don’t have support for
it, at least not native one.
Googling I found a solution which I’ve flashed it first with a stripped
custom firmware found on Internet and then, via console, do a beautifull
reflash with WR741 v4 firmware (build by us) and everything Works perfect!.

Since I’m not the one who flashes the devices I did a new git from trunk
versión of OpenWrt (CHAOS CALMER (15.05)) because it has native support for
TP-Link TL-WR740N versión 5 but when I looked into the code I’ve figured
out, again, that the code changed a lot since the BB 14.07 and I don’t know
how to adapt the custom configurations.

The reason I changed those 2 files it is because of the users sometimes (i
mean always) press the reset button and it won’t allow us to remotely
recofigure the device and to use one port of the switch to bridge it with
the WAN port to use them just because we have ATAs devices that don’t
support NAT etc etc.
When a user presses the reset button, it resets the device and configure it
with a standard configuration which let the user to have Telephone (VoIP),
Internet, Wifi and we can Access remotely to reconfigure it as I said
before.

On BB 14.07 I’ve just modified 2 files:
./package/base-files/files/lib/functions/uci-defaults.sh
…….

ucidef_add_switch() {
    local name=$1
    local reset=$2
    local enable=$3
    uci batch 

Re: [OpenWrt-Devel] [PATCH 1/6] [kernel] ath9k: enable GPIO access for ar9287 and ar9285

2016-01-26 Thread Michal

Hello,

Hartmut, thanks for your input and help, it is always welcome.

> 
> [...] Why not create the gpio_chip just
> based on the fact, if a supported AR928x device is present or not?
> The support code will be there, already. So, the additional footprint
> of the gpio_chip is pretty small.
> 

I agree that ath9k GPIO chip should be visible regardless of
LED and/or button presence, I wanted to implement this later,
but it seems quite stable now so here it is - changed as requested.

I spent some time reorganizing patches to form more logical
entities - at least IMHO each of them is now providing complete
functionality, enhancement or fix. Due to changed structure, I
decided to attach all new patches to this thread, not to old ones.

I have also adjusted text formatting. Everything fits 80 cols.

Applied to r48508, compiled, it works. The only thing that has changed
from last trunk build is minor issue - it appears that empty PACKAGES
line in netgear.mk is not working anymore. USB modules sneaked
somehow into build image for my WNR2000v3 so for now there is only 108K
left in /overlay.

Best regards
Michal
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/2] kernel: other: add PWM controller support

2016-01-26 Thread Pushpal Sidhu
This adds basic PWM controller support and support for i.MX

Signed-off-by: Tim Harvey 
Signed-off-by: Pushpal Sidhu 
---
 package/kernel/linux/modules/other.mk | 36 +++
 1 file changed, 36 insertions(+)

diff --git a/package/kernel/linux/modules/other.mk 
b/package/kernel/linux/modules/other.mk
index 3039180..8edf8a6 100644
--- a/package/kernel/linux/modules/other.mk
+++ b/package/kernel/linux/modules/other.mk
@@ -371,6 +371,42 @@ endef
 $(eval $(call KernelPackage,mmc))
 
 
+define KernelPackage/pwm
+  SUBMENU:=$(OTHER_MENU)
+  TITLE:=Pulse-Width Modulation support
+  KCONFIG:= \
+   CONFIG_PWM=y \
+   CONFIG_REGULATOR_PWM=n \
+   CONFIG_PWM_FSL_FTM=n
+endef
+
+define KernelPackage/pwm/description
+ Pulse Width Modulation subsystem.
+endef
+
+$(eval $(call KernelPackage,pwm))
+
+define AddDepends/pwm
+  SUBMENU:=$(OTHER_MENU)
+  DEPENDS+=kmod-pwm $(1)
+endef
+
+define KernelPackage/pwm-imx
+  SUBMENU:=$(OTHER_MENU)
+  TITLE:=IMX Pulse-Width Modulation support
+  KCONFIG:=CONFIG_PWM_IMX
+  FILES:= $(LINUX_DIR)/drivers/pwm/pwm-imx.ko
+  DEPENDS:=@TARGET_imx6
+  AUTOLOAD:=$(call AutoProbe,pwm-imx)
+  $(call AddDepends/pwm)
+endef
+
+define KernelPackage/pwm-imx/description
+ Freescale IMX Pulse Width Modulation support.
+endef
+
+$(eval $(call KernelPackage,pwm-imx))
+
 define KernelPackage/sdhci
   SUBMENU:=$(OTHER_MENU)
   TITLE:=Secure Digital Host Controller Interface support
-- 
2.7.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/2] kernel: add mma8451 module

2016-01-26 Thread Pushpal Sidhu
Signed-off-by: Pushpal Sidhu 
---
 package/kernel/linux/modules/input.mk | 17 +
 1 file changed, 17 insertions(+)

diff --git a/package/kernel/linux/modules/input.mk 
b/package/kernel/linux/modules/input.mk
index 3f50a9f..b50106b 100644
--- a/package/kernel/linux/modules/input.mk
+++ b/package/kernel/linux/modules/input.mk
@@ -224,3 +224,20 @@ define KernelPackage/input-uinput/description
 endef
 
 $(eval $(call KernelPackage,input-uinput))
+
+
+define KernelPackage/input-mma8451
+  SUBMENU:=$(INPUT_MODULES_MENU)
+  TITLE:=MMA8451 input device driver
+  DEPENDS:=+kmod-i2c-core +kmod-input-polldev
+  KCONFIG:=CONFIG_INPUT_MMA8451
+  FILES:=$(LINUX_DIR)/drivers/input/misc/mma8451.ko
+  AUTOLOAD:=$(call AutoProbe,mma8451)
+  $(call AddDepends/input)
+endef
+
+define KernelPackage/input-mma8451/description
+ MMA8451 device driver
+endef
+
+$(eval $(call KernelPackage,input-mma8451))
-- 
2.7.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Add several kernel modules

2016-01-26 Thread Pushpal Sidhu
adds kernel modules for:
 * input-mma8451
 * pwm
 * pwm-imx

Pushpal Sidhu (2):
  kernel: add mma8451 module
  kernel: other: add PWM controller support

 package/kernel/linux/modules/input.mk | 17 +
 package/kernel/linux/modules/other.mk | 36 
 2 files changed, 53 insertions(+)

- Pushpal
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] kernel: gpio-button-hotplug: update to use threaded irq's

2016-01-26 Thread Pushpal Sidhu
Many gpio controllers 'cansleep' due to the fact that they are behind busses
e.g. i2c etc.

Using threaded irq's allows for 'sleep-able' gpio's to be used.

Signed-off-by: Pushpal Sidhu 
Signed-off-by: Tim Harvey 
---
 .../kernel/gpio-button-hotplug/src/gpio-button-hotplug.c| 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c 
b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
index 029a388..6d1a197 100644
--- a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
+++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
@@ -555,20 +555,17 @@ static int gpio_keys_probe(struct platform_device *pdev)
struct gpio_keys_button *button = &pdata->buttons[i];
struct gpio_keys_button_data *bdata = &bdev->data[i];
 
-   if (bdata->can_sleep) {
-   dev_err(&pdev->dev, "skipping gpio:%d, it can sleep\n", 
button->gpio);
-   continue;
-   }
if (!button->irq)
button->irq = gpio_to_irq(button->gpio);
if (button->irq < 0) {
dev_err(&pdev->dev, "failed to get irq for gpio:%d\n", 
button->gpio);
continue;
}
-   ret = devm_request_irq(&pdev->dev, button->irq, 
button_handle_irq,
-   IRQF_TRIGGER_RISING | 
IRQF_TRIGGER_FALLING,
-   dev_name(&pdev->dev), bdata);
-   if (ret)
+
+   ret = devm_request_threaded_irq(&pdev->dev, button->irq, NULL, 
button_handle_irq,
+   IRQF_TRIGGER_RISING | 
IRQF_TRIGGER_FALLING,
+   dev_name(&pdev->dev), bdata);
+   if (ret < 0)
dev_err(&pdev->dev, "failed to request irq:%d for 
gpio:%d\n", button->irq, button->gpio);
else
dev_dbg(&pdev->dev, "gpio:%d has irq:%d\n", 
button->gpio, button->irq);
-- 
2.7.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] kernel: add dsa driver support

2016-01-26 Thread Pushpal Sidhu
From: Tim Harvey 

The Linux Distributed Switch Architecture drivers provide richer support than
the swconfig driver API in that each switch port gets its own interface which
allows protocols such as STP, LLDP, 802.1x etc.

Signed-off-by: Tim Harvey 
Signed-off-by: Pushpal Sidhu 
---
 package/kernel/linux/modules/dsa.mk | 136 
 1 file changed, 136 insertions(+)
 create mode 100644 package/kernel/linux/modules/dsa.mk

diff --git a/package/kernel/linux/modules/dsa.mk 
b/package/kernel/linux/modules/dsa.mk
new file mode 100644
index 000..0696d75
--- /dev/null
+++ b/package/kernel/linux/modules/dsa.mk
@@ -0,0 +1,136 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+#
+# DSA core
+#
+
+DSA_MENU:=DSA Support
+
+define KernelPackage/dsa
+  SUBMENU:=$(DSA_MENU)
+  TITLE:=DSA support
+  KCONFIG:=\
+   CONFIG_NET_DSA \
+   CONFIG_NET_SWITCHDEV=y \
+   CONFIG_NET_DSA_HWMON=n
+  FILES:=$(LINUX_DIR)/net/dsa/dsa_core.ko
+  AUTOLOAD:=$(call AutoLoad,34,dsa_core)
+endef
+
+define KernelPackage/dsa/description
+ Kernel module for DSA support.
+endef
+
+$(eval $(call KernelPackage,dsa))
+
+
+define AddDepends/dsa
+  SUBMENU:=$(DSA_MENU)
+  DEPENDS+=kmod-dsa $(1)
+endef
+
+
+#
+# Switch drivers
+#
+
+define KernelPackage/dsa-mv88e6060
+  TITLE:=Marvell 88E6060 ethernet switch chip support
+  KCONFIG:=\
+   CONFIG_NET_DSA_MV88E6060 \
+   CONFIG_NET_DSA_TAG_TRAILER=y
+  FILES:=$(LINUX_DIR)/drivers/net/dsa/mv88e6060.ko
+  AUTOLOAD:=$(call AutoLoad,34,mv88e6060)
+  $(call AddDepends/dsa)
+endef
+
+define KernelPackage/dsa-mv88e6060/description
+  This enables support for the Marvell 88E6060 ethernet switch chips.
+endef
+
+$(eval $(call KernelPackage,dsa-mv88e6060))
+
+
+define KernelPackage/dsa-mv88e6xxx
+  TITLE:=Marvell 88E6XXX switch support
+  KCONFIG:=CONFIG_NET_DSA_MV88E6XXX
+  FILES:=$(LINUX_DIR)/drivers/net/dsa/mv88e6xxx_drv.ko
+  AUTOLOAD:=$(call AutoLoad,34,mv88e6xxx_drv)
+  $(call AddDepends/dsa)
+endef
+
+define KernelPackage/dsa-mv88e6xxx/description
+  This enables support for the Marvell 88E6XXX ethernet switch chips.
+endef
+
+$(eval $(call KernelPackage,dsa-mv88e6xxx))
+
+define AddDepends/dsa-mv88e6xxx
+  SUBMENU:=$(DSA_MENU)
+  DEPENDS+=kmod-dsa kmod-dsa-mv88e6xxx $(1)
+endef
+
+
+define KernelPackage/dsa-mv88e6131
+  TITLE:=Marvell 88E6085/6095/6095F/6131 switch support
+  KCONFIG:=\
+   CONFIG_NET_DSA_MV88E6131 \
+   CONFIG_NET_DSA_TAG_DSA=y
+  $(call AddDepends/dsa-mv88e6xxx)
+endef
+
+define KernelPackage/dsa-mv88e6131/description
+  This enables support for the Marvell 88E6085/6095/6095F/6131 ethernet switch 
chips.
+endef
+
+$(eval $(call KernelPackage,dsa-mv88e6131))
+
+
+define KernelPackage/dsa-mv88e6123
+  TITLE:=Marvell 88E6123/6161/6165 switch support
+  KCONFIG:=\
+   CONFIG_NET_DSA_MV88E6123_61_65 \
+   CONFIG_NET_DSA_TAG_EDSA=y
+  $(call AddDepends/dsa-mv88e6xxx)
+endef
+
+define KernelPackage/dsa-mv88e6123/description
+  This enables support for the Marvell 88E6123/6161/6165 ethernet switch chips.
+endef
+
+$(eval $(call KernelPackage,dsa-mv88e6123))
+
+
+define KernelPackage/dsa-mv88e6171
+  TITLE:=Marvell 88E6171/6172 switch support
+  KCONFIG:=\
+   CONFIG_NET_DSA_MV88E6131 \
+   CONFIG_NET_DSA_TAG_DSA=y
+  $(call AddDepends/dsa-mv88e6xxx)
+endef
+
+define KernelPackage/dsa-mv88e6171/description
+  This enables support for the Marvell 88E6171/6172 ethernet switch chips.
+endef
+
+$(eval $(call KernelPackage,dsa-mv88e6171))
+
+
+define KernelPackage/dsa-mv88e6352
+  TITLE:=Marvell 88E6176/88E6352 switch support
+  KCONFIG:=\
+   CONFIG_NET_DSA_MV88E6352 \
+   CONFIG_NET_DSA_TAG_DSA=y
+  $(call AddDepends/dsa-mv88e6xxx)
+endef
+
+define KernelPackage/dsa-mv88e6352/description
+  This enables support for the Marvell 88E6176/88E6352 ethernet switch chips.
+endef
+
+$(eval $(call KernelPackage,dsa-mv88e6352))
-- 
2.7.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] iproute2: ip_tiny.patch: Don't filter CAN support

2016-01-26 Thread Pushpal Sidhu
Adds < 4k to ipk.

Signed-off-by: Tim Harvey 
Signed-off-by: Pushpal Sidhu 
---
 package/network/utils/iproute2/patches/300-ip_tiny.patch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/network/utils/iproute2/patches/300-ip_tiny.patch 
b/package/network/utils/iproute2/patches/300-ip_tiny.patch
index c0ebfd3..4b2f5da 100644
--- a/package/network/utils/iproute2/patches/300-ip_tiny.patch
+++ b/package/network/utils/iproute2/patches/300-ip_tiny.patch
@@ -6,7 +6,7 @@
  
 +STATIC_SYM_FILTER:=
 +ifeq ($(IP_CONFIG_TINY),y)
-+  STATIC_SYM_FILTER:=iplink_can.c iplink_ipoib.c iplink_vxlan.c
++  STATIC_SYM_FILTER:=iplink_ipoib.c iplink_vxlan.c
 +  CFLAGS += -DIPROUTE2_TINY
 +endif
 +STATIC_SYM_SOURCES:=$(filter-out $(STATIC_SYM_FILTER),$(wildcard *.c))
-- 
2.7.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v3] base-files: For sysfixtime use hwclock if RTC available

2016-01-26 Thread Petr Štetiar
Bastian Bittorf  [2016-01-21 12:53:48]:

> * Petr Štetiar  [21.01.2016 12:22]:
> >  boot() {
> > +   [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV && 
> > exit 0
> 
> thank you! can you please do in this line a:
> && return

Like following?

deps_ok && $HWCLOCK -s -f $RTC_DEV && exit 0 && return 

Is it really needed? I've always thought, that exit will terminate the script
so the return wouldn't be called anyway.

> and introduce a helper (maybe overengineered 8-)

Kind of, was thinking about it also so I'll change it, thanks.

> deps_ok() {
>   [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ]
> }

-- ynezz
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/3] b53: support setting port link

2016-01-26 Thread Rafał Miłecki
When dealing with Broadcom hardware we can simply use swconfig's generic
helper, we just need to do some validation of requested state.

Signed-off-by: Rafał Miłecki 
---
 .../generic/files/drivers/net/phy/b53/b53_common.c | 31 ++
 1 file changed, 31 insertions(+)

diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c 
b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
index 41b5ae9..676e301 100644
--- a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
+++ b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
@@ -794,6 +794,34 @@ static int b53_port_get_link(struct switch_dev *dev, int 
port,
 
 }
 
+static int b53_port_set_link(struct switch_dev *sw_dev, int port,
+struct switch_port_link *link)
+{
+   struct b53_device *dev = sw_to_b53(sw_dev);
+
+   /*
+* TODO: BCM63XX requires special handling as it can have external phys
+* and ports might be GE or only FE
+*/
+   if (is63xx(dev))
+   return -ENOTSUPP;
+
+   if (port == sw_dev->cpu_port)
+   return -EINVAL;
+
+   if (!(BIT(port) & dev->enabled_ports))
+   return -EINVAL;
+
+   if (link->speed == SWITCH_PORT_SPEED_1000 &&
+   (is5325(dev) || is5365(dev)))
+   return -EINVAL;
+
+   if (link->speed == SWITCH_PORT_SPEED_1000 && !link->duplex)
+   return -EINVAL;
+
+   return switch_generic_set_link(sw_dev, port, link);
+}
+
 static int b53_phy_read16(struct switch_dev *dev, int addr, u8 reg, u16 *value)
 {
struct b53_device *priv = sw_to_b53(dev);
@@ -1022,6 +1050,7 @@ static const struct switch_dev_ops b53_switch_ops_25 = {
.apply_config = b53_global_apply_config,
.reset_switch = b53_global_reset_switch,
.get_port_link = b53_port_get_link,
+   .set_port_link = b53_port_set_link,
.phy_read16 = b53_phy_read16,
.phy_write16 = b53_phy_write16,
 };
@@ -1047,6 +1076,7 @@ static const struct switch_dev_ops b53_switch_ops_65 = {
.apply_config = b53_global_apply_config,
.reset_switch = b53_global_reset_switch,
.get_port_link = b53_port_get_link,
+   .set_port_link = b53_port_set_link,
.phy_read16 = b53_phy_read16,
.phy_write16 = b53_phy_write16,
 };
@@ -1072,6 +1102,7 @@ static const struct switch_dev_ops b53_switch_ops = {
.apply_config = b53_global_apply_config,
.reset_switch = b53_global_reset_switch,
.get_port_link = b53_port_get_link,
+   .set_port_link = b53_port_set_link,
.phy_read16 = b53_phy_read16,
.phy_write16 = b53_phy_write16,
 };
-- 
1.8.4.5
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/3] b53: provide PHY access to swconfig

2016-01-26 Thread Rafał Miłecki
Thanks to this swconfig can access port PHYs e.g. when setting port link
state with a generic helper.

Signed-off-by: Rafał Miłecki 
---
 .../generic/files/drivers/net/phy/b53/b53_common.c | 26 ++
 .../generic/files/drivers/net/phy/b53/b53_mdio.c   | 20 +
 .../generic/files/drivers/net/phy/b53/b53_priv.h   |  2 ++
 3 files changed, 48 insertions(+)

diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c 
b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
index 859d8d1..41b5ae9 100644
--- a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
+++ b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
@@ -794,6 +794,26 @@ static int b53_port_get_link(struct switch_dev *dev, int 
port,
 
 }
 
+static int b53_phy_read16(struct switch_dev *dev, int addr, u8 reg, u16 *value)
+{
+   struct b53_device *priv = sw_to_b53(dev);
+
+   if (priv->ops->phy_read16)
+   return priv->ops->phy_read16(priv, addr, reg, value);
+
+   return b53_read16(priv, B53_PORT_MII_PAGE(addr), reg, value);
+}
+
+static int b53_phy_write16(struct switch_dev *dev, int addr, u8 reg, u16 value)
+{
+   struct b53_device *priv = sw_to_b53(dev);
+
+   if (priv->ops->phy_write16)
+   return priv->ops->phy_write16(priv, addr, reg, value);
+
+   return b53_write16(priv, B53_PORT_MII_PAGE(addr), reg, value);
+}
+
 static int b53_global_reset_switch(struct switch_dev *dev)
 {
struct b53_device *priv = sw_to_b53(dev);
@@ -1002,6 +1022,8 @@ static const struct switch_dev_ops b53_switch_ops_25 = {
.apply_config = b53_global_apply_config,
.reset_switch = b53_global_reset_switch,
.get_port_link = b53_port_get_link,
+   .phy_read16 = b53_phy_read16,
+   .phy_write16 = b53_phy_write16,
 };
 
 static const struct switch_dev_ops b53_switch_ops_65 = {
@@ -1025,6 +1047,8 @@ static const struct switch_dev_ops b53_switch_ops_65 = {
.apply_config = b53_global_apply_config,
.reset_switch = b53_global_reset_switch,
.get_port_link = b53_port_get_link,
+   .phy_read16 = b53_phy_read16,
+   .phy_write16 = b53_phy_write16,
 };
 
 static const struct switch_dev_ops b53_switch_ops = {
@@ -1048,6 +1072,8 @@ static const struct switch_dev_ops b53_switch_ops = {
.apply_config = b53_global_apply_config,
.reset_switch = b53_global_reset_switch,
.get_port_link = b53_port_get_link,
+   .phy_read16 = b53_phy_read16,
+   .phy_write16 = b53_phy_write16,
 };
 
 struct b53_chip_data {
diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c 
b/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c
index 3c25f0e..185c95f 100644
--- a/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c
+++ b/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c
@@ -238,6 +238,24 @@ static int b53_mdio_write64(struct b53_device *dev, u8 
page, u8 reg,
return b53_mdio_op(dev, page, reg, REG_MII_ADDR_WRITE);
 }
 
+static int b53_mdio_phy_read16(struct b53_device *dev, int addr, u8 reg,
+  u16 *value)
+{
+   struct mii_bus *bus = dev->priv;
+
+   *value = mdiobus_read(bus, addr, reg);
+
+   return 0;
+}
+
+static int b53_mdio_phy_write16(struct b53_device *dev, int addr, u8 reg,
+   u16 value)
+{
+   struct mii_bus *bus = dev->priv;
+
+   return mdiobus_write(bus, addr, reg, value);
+}
+
 static struct b53_io_ops b53_mdio_ops = {
.read8 = b53_mdio_read8,
.read16 = b53_mdio_read16,
@@ -249,6 +267,8 @@ static struct b53_io_ops b53_mdio_ops = {
.write32 = b53_mdio_write32,
.write48 = b53_mdio_write48,
.write64 = b53_mdio_write64,
+   .phy_read16 = b53_mdio_phy_read16,
+   .phy_write16 = b53_mdio_phy_write16,
 };
 
 static int b53_phy_probe(struct phy_device *phydev)
diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_priv.h 
b/target/linux/generic/files/drivers/net/phy/b53/b53_priv.h
index 0c4c394..53da97e 100644
--- a/target/linux/generic/files/drivers/net/phy/b53/b53_priv.h
+++ b/target/linux/generic/files/drivers/net/phy/b53/b53_priv.h
@@ -36,6 +36,8 @@ struct b53_io_ops {
int (*write32)(struct b53_device *dev, u8 page, u8 reg, u32 value);
int (*write48)(struct b53_device *dev, u8 page, u8 reg, u64 value);
int (*write64)(struct b53_device *dev, u8 page, u8 reg, u64 value);
+   int (*phy_read16)(struct b53_device *dev, int addr, u8 reg, u16 *value);
+   int (*phy_write16)(struct b53_device *dev, int addr, u8 reg, u16 value);
 };
 
 enum {
-- 
1.8.4.5
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/3] swconfig: add (PHY) generic helper setting port link

2016-01-26 Thread Rafał Miłecki
It's quite common for switches to have PHY per port so adding a generic
helper setting link state will help many drivers. It just neede an API
to access PHYs which this patch also adds.

Signed-off-by: Rafał Miłecki 
---
 .../linux/generic/files/drivers/net/phy/swconfig.c | 36 ++
 target/linux/generic/files/include/linux/switch.h  |  6 
 2 files changed, 42 insertions(+)

diff --git a/target/linux/generic/files/drivers/net/phy/swconfig.c 
b/target/linux/generic/files/drivers/net/phy/swconfig.c
index 4bfe64f..68ddd24 100644
--- a/target/linux/generic/files/drivers/net/phy/swconfig.c
+++ b/target/linux/generic/files/drivers/net/phy/swconfig.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define SWCONFIG_DEVNAME   "switch%d"
 
@@ -1168,6 +1169,41 @@ unregister_switch(struct switch_dev *dev)
 }
 EXPORT_SYMBOL_GPL(unregister_switch);
 
+int
+switch_generic_set_link(struct switch_dev *dev, int port,
+   struct switch_port_link *link)
+{
+   if (WARN_ON(!dev->ops->phy_write16))
+   return -ENOTSUPP;
+
+   /* Generic implementation */
+   if (link->aneg) {
+   dev->ops->phy_write16(dev, port, MII_BMCR, 0x);
+   dev->ops->phy_write16(dev, port, MII_BMCR, BMCR_ANENABLE | 
BMCR_ANRESTART);
+   } else {
+   u16 bmcr = 0;
+
+   if (link->duplex)
+   bmcr |= BMCR_FULLDPLX;
+
+   switch (link->speed) {
+   case SWITCH_PORT_SPEED_10:
+   break;
+   case SWITCH_PORT_SPEED_100:
+   bmcr |= BMCR_SPEED100;
+   break;
+   case SWITCH_PORT_SPEED_1000:
+   bmcr |= BMCR_SPEED1000;
+   break;
+   default:
+   return -ENOTSUPP;
+   }
+
+   dev->ops->phy_write16(dev, port, MII_BMCR, bmcr);
+   }
+
+   return 0;
+}
 
 static int __init
 swconfig_init(void)
diff --git a/target/linux/generic/files/include/linux/switch.h 
b/target/linux/generic/files/include/linux/switch.h
index 4ada0e5..0c4cce7 100644
--- a/target/linux/generic/files/include/linux/switch.h
+++ b/target/linux/generic/files/include/linux/switch.h
@@ -99,6 +99,9 @@ struct switch_dev_ops {
 struct switch_port_link *link);
int (*get_port_stats)(struct switch_dev *dev, int port,
  struct switch_port_stats *stats);
+
+   int (*phy_read16)(struct switch_dev *dev, int addr, u8 reg, u16 *value);
+   int (*phy_write16)(struct switch_dev *dev, int addr, u8 reg, u16 value);
 };
 
 struct switch_dev {
@@ -170,4 +173,7 @@ struct switch_attr {
int max;
 };
 
+int switch_generic_set_link(struct switch_dev *dev, int port,
+   struct switch_port_link *link);
+
 #endif /* _LINUX_SWITCH_H */
-- 
1.8.4.5
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] ramips: Error in mt7620_gsw_probe/mt7621_gsw_probe?

2016-01-26 Thread Cezary Jackiewicz
Hello,

+static int mt7620_gsw_probe(struct platform_device *pdev)
+{
+   struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   const char *port4 = NULL;
+   struct mt7620_gsw *gsw;
+   struct device_node *np;
+
+   gsw = devm_kzalloc(&pdev->dev, sizeof(struct mt7620_gsw), GFP_KERNEL);
+   if (!gsw)
+   return -ENOMEM;
+
+   gsw->base = devm_ioremap_resource(&pdev->dev, res);
+   if (!gsw->base)
+   return -EADDRNOTAVAIL;
+
+   gsw->dev = &pdev->dev;
+
+   of_property_read_string(np, "mediatek,port4", &port4);
+   if (port4 && !strcmp(port4, "ephy"))
+   gsw->port4 = PORT4_EPHY;
+   else if (port4 && !strcmp(port4, "gmac"))
+   gsw->port4 = PORT4_EXT;
+   else
+   gsw->port4 = PORT4_EPHY;
+

Where device_node structure is populated? CC uses of_find_matching_node, 
but in DD/trunk this structure is null, and I cannot set "mediatek,port4" 
property to gmac.


-- 
Pozdrawiam,
 Cezary Jackiewicz
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] busybox: sysntpd - use NTP servers received via DHCP

2016-01-26 Thread Amine Aouled Hamed
Anyone tried both triggers at the same time and checked if it works
correctly?

On Mon, Jan 25, 2016 at 5:05 PM, Amine Aouled Hamed 
wrote:

> this is the patch:
> ---
>  package/utils/busybox/files/sysntpd | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/package/utils/busybox/files/sysntpd
> b/package/utils/busybox/files/sysntpd
> index f73bb83..2e7a47d 100755
> --- a/package/utils/busybox/files/sysntpd
> +++ b/package/utils/busybox/files/sysntpd
> @@ -15,6 +15,7 @@ validate_ntp_section() {
>  start_service() {
> local server enabled enable_server peer
>
> +   logger -t sysntpd "starting ntpds"
> validate_ntp_section ntp || {
> echo "validation failed"
> return 1
> @@ -37,6 +38,13 @@ start_service() {
>
>  service_triggers()
>  {
> +   local script=$(readlink "$initscript")
> +   local name=$(basename ${script:-$initscript})
> +
> +   procd_open_trigger
> +   procd_add_raw_trigger "interface.*" 2000 /etc/init.d/$name reload
> +   procd_close_trigger
> +
> procd_add_reload_trigger "system"
> procd_add_validation validate_ntp_section
>  }
>
> What I found is that commenting out the system reload trigger will make
> the interface trigger work. Maybe a bug when adding multiple triggers?
>
> On Mon, Jan 25, 2016 at 3:14 PM, Bastian Bittorf 
> wrote:
>
>> * Amine Aouled Hamed  [25.01.2016 14:53]:
>> > So using the latest procd version,
>> > I added a simple logger message on top start_service() in sysntpd and
>> added
>> > the triggers in service_triggers and to test I just unplugged and
>> > re-plugget my network cable and checked logread.
>> > Nothing shows up.
>>
>> not every switchport is aware of un- or replug.
>> better wait for DHCP-lease timeout to check if it triggers.
>> (or do 'ifup lan')
>>
>> bye, bastian
>>
>
>
>
> --
>
> Amine Hamed | Software Engineer
>
>
>
> Ocedo GmbH | Hirschstrasse 7 | 76133 Karlsruhe | Germany
>
> Email aha...@ocedo.com
>
>
> 
>
> REGISTERED OFFICE: KARLSRUHE | DISTRICT COURT: MANNHEIM | REGISTER NUMBER:
> HRB 717873
> MANAGING DIRECTOR: MARKUS HENNIG|JAN HICHERT
>



-- 

Amine Hamed | Software Engineer



Ocedo GmbH | Hirschstrasse 7 | 76133 Karlsruhe | Germany

Email aha...@ocedo.com




REGISTERED OFFICE: KARLSRUHE | DISTRICT COURT: MANNHEIM | REGISTER NUMBER:
HRB 717873
MANAGING DIRECTOR: MARKUS HENNIG|JAN HICHERT
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] brcm63xx: fix HG556a C button

2016-01-26 Thread dani
One button of the HG556a-C has the wrong GPIO pin defined in the dts file,
fix it

Probably as it happened with leds previously, the buttons were copied from
the A, B versions of this router, but nobody checked it. The "help" button 
has the GPIO pin 36 not the pin 8.

Signed-off-by: Daniel Gonzalez 
diff --git a/target/linux/brcm63xx/dts/hg556a-c.dts 
b/target/linux/brcm63xx/dts/hg556a-c.dts
index 9798091..5a1856d 100644
--- a/target/linux/brcm63xx/dts/hg556a-c.dts
+++ b/target/linux/brcm63xx/dts/hg556a-c.dts
@@ -17,7 +17,7 @@
 
help {
label = "help";
-   gpios = <&gpio0 8 1>;
+   gpios = <&gpio1 4 1>;
linux,code = ;
};
wlan {
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] malta: move to 4.4 kernel

2016-01-26 Thread Yousong Zhou
Linux now has device tree support for malta.  The patch for correcting
/proc/iomem content is not needed now.  Previously it was

root@(none):/# cat /proc/iomem
-0fff : reserved
1000-000e : System RAM
000f-000f : reserved
0010-0fffefff : System RAM
  0010-003f2b6b : Kernel code
  003f2b6c-00485937 : Kernel data
...

Now it's

root@OpenWrt:/# cat /proc/iomem
-0fffefff : System RAM
  0010-004a3297 : Kernel code
  004a3298-0057cfff : Kernel data
...

The kernel config was prepared as follows

 1. cp target/linux/malta/config-{3.18,4.4}
 2. make kernel_menuconfig CONFIG_TARGET=subtarget_platform

Signed-off-by: Yousong Zhou 
---
The patch was run-tested with QEMU 2.5.0.

 target/linux/malta/Makefile|   2 +-
 target/linux/malta/config-3.18 | 256 -
 target/linux/malta/config-4.4  | 313 +
 ...Mark-kernel-code-and-kernel-data-segments.patch |  34 ---
 4 files changed, 314 insertions(+), 291 deletions(-)
 delete mode 100644 target/linux/malta/config-3.18
 create mode 100644 target/linux/malta/config-4.4
 delete mode 100644 
target/linux/malta/patches/330-MIPS-Malta-Mark-kernel-code-and-kernel-data-segments.patch

diff --git a/target/linux/malta/Makefile b/target/linux/malta/Makefile
index 8392738..a8663d8 100644
--- a/target/linux/malta/Makefile
+++ b/target/linux/malta/Makefile
@@ -13,7 +13,7 @@ SUBTARGETS:=le be #le64 be64
 INITRAMFS_EXTRA_FILES:=
 MAINTAINER:=Florian Fainelli 
 
-KERNEL_PATCHVER:=3.18
+KERNEL_PATCHVER:=4.4
 
 include $(INCLUDE_DIR)/target.mk
 
diff --git a/target/linux/malta/config-3.18 b/target/linux/malta/config-3.18
deleted file mode 100644
index 09d3ab3..000
--- a/target/linux/malta/config-3.18
+++ /dev/null
@@ -1,256 +0,0 @@
-CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE=y
-CONFIG_ARCH_DISCARD_MEMBLOCK=y
-CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
-CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
-CONFIG_ARCH_MAY_HAVE_PC_FDC=y
-CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
-CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y
-CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
-# CONFIG_AX88796_93CX6 is not set
-CONFIG_ATA=y
-CONFIG_ATA_PIIX=y
-CONFIG_BLK_DEV_BSG=y
-CONFIG_BLK_DEV_BSGLIB=y
-# CONFIG_BLK_DEV_DM is not set
-# CONFIG_BLK_DEV_INITRD is not set
-# CONFIG_BLK_DEV_MD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_COUNT=16
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_SD=y
-CONFIG_BOARD_SCACHE=y
-CONFIG_BOOT_ELF32=y
-CONFIG_BOUNCE=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-# CONFIG_CEVT_GIC is not set
-CONFIG_CEVT_R4K=y
-CONFIG_CLKBLD_I8253=y
-CONFIG_CLKEVT_I8253=y
-CONFIG_CLKSRC_I8253=y
-CONFIG_CLONE_BACKWARDS=y
-CONFIG_CONSOLE_TRANSLATIONS=y
-CONFIG_CPU_GENERIC_DUMP_TLB=y
-CONFIG_CPU_HAS_PREFETCH=y
-# CONFIG_CPU_HAS_SMARTMIPS is not set
-CONFIG_CPU_HAS_SYNC=y
-# CONFIG_CPU_MIPS32_3_5_FEATURES is not set
-CONFIG_CPU_MIPSR2=y
-CONFIG_CPU_MIPSR2_IRQ_EI=y
-CONFIG_CPU_MIPSR2_IRQ_VI=y
-# CONFIG_CPU_NEEDS_NO_SMARTMIPS_OR_MICROMIPS is not set
-# CONFIG_CPU_NEVADA is not set
-CONFIG_CPU_R4K_CACHE_TLB=y
-CONFIG_CPU_R4K_FPU=y
-# CONFIG_CPU_RM7000 is not set
-CONFIG_CPU_RMAP=y
-CONFIG_CPU_SUPPORTS_HIGHMEM=y
-CONFIG_CRYPTO_MANAGER2=y
-CONFIG_CSRC_GIC=y
-CONFIG_CSRC_R4K=y
-# CONFIG_DEBUG_FS is not set
-CONFIG_DEVKMEM=y
-CONFIG_DMA_MAYBE_COHERENT=y
-CONFIG_DMA_NONCOHERENT=y
-CONFIG_DNOTIFY=y
-CONFIG_DUMMY_CONSOLE=y
-CONFIG_EARLY_PRINTK=y
-CONFIG_ENABLE_MUST_CHECK=y
-CONFIG_EXT4_FS=y
-CONFIG_FIRMWARE_IN_KERNEL=y
-CONFIG_FS_POSIX_ACL=y
-CONFIG_GENERIC_ATOMIC64=y
-CONFIG_GENERIC_CLOCKEVENTS=y
-CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
-CONFIG_GENERIC_CMOS_UPDATE=y
-CONFIG_GENERIC_IO=y
-CONFIG_GENERIC_IRQ_SHOW=y
-CONFIG_GENERIC_ISA_DMA=y
-CONFIG_GENERIC_PCI_IOMAP=y
-CONFIG_GENERIC_SMP_IDLE_THREAD=y
-CONFIG_GPIO_DEVRES=y
-CONFIG_HARDWARE_WATCHPOINTS=y
-CONFIG_HAS_DMA=y
-CONFIG_HAS_IOMEM=y
-CONFIG_HAS_IOPORT=y
-CONFIG_HAVE_ARCH_JUMP_LABEL=y
-CONFIG_HAVE_ARCH_KGDB=y
-CONFIG_HAVE_ARCH_TRACEHOOK=y
-# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
-CONFIG_HAVE_CC_STACKPROTECTOR=y
-CONFIG_HAVE_CONTEXT_TRACKING=y
-CONFIG_HAVE_C_RECORDMCOUNT=y
-CONFIG_HAVE_DEBUG_KMEMLEAK=y
-CONFIG_HAVE_DEBUG_STACKOVERFLOW=y
-CONFIG_HAVE_DMA_API_DEBUG=y
-CONFIG_HAVE_DMA_ATTRS=y
-CONFIG_HAVE_DYNAMIC_FTRACE=y
-CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
-CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
-CONFIG_HAVE_FUNCTION_TRACER=y
-CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
-CONFIG_HAVE_GENERIC_DMA_COHERENT=y
-CONFIG_HAVE_GENERIC_HARDIRQS=y
-CONFIG_HAVE_IDE=y
-CONFIG_HAVE_KERNEL_BZIP2=y
-CONFIG_HAVE_KERNEL_GZIP=y
-CONFIG_HAVE_KERNEL_LZ4=y
-CONFIG_HAVE_KERNEL_LZMA=y
-CONFIG_HAVE_KERNEL_LZO=y
-CONFIG_HAVE_KERNEL_XZ=y
-CONFIG_HAVE_KVM=y
-CONFIG_HAVE_MEMBLOCK=y
-CONFIG_HAVE_MEMBLOCK_NODE_MAP=y
-CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
-CONFIG_HAVE_NET_DSA=y
-CONFIG_HAVE_OPROFILE=y
-CONFIG_HAVE_PCSPKR_PLATFORM=y
-CONFIG_HAVE_PERF_EVENTS=y
-CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
-CONFIG_HOSTAP_FIRMWARE=y
-CONFIG_HOSTAP_FIRMWARE_NVRAM=y
-CONFIG_HW_CON