[OpenWrt-Devel] [RFC] ar71xx: add TP-Link TL-WR810N support
John Crispin
john at phrozen.org
Mon May 2 15:12:34 EDT 2016
On 02/05/2016 20:50, Jens Steinhauser wrote:
> On 05/02/2016 10:55 AM, John Crispin wrote:
>> On 02/05/2016 00:05, Jens Steinhauser wrote:
>>> On 04/25/2016 10:02 PM, John Crispin wrote:
>>>> Hi
>>>>
>>>> On 10/04/2016 14:00, Jens Steinhauser wrote:
>>>>> This patch adds support for the TP-Link TL-WR810N.
>>>>> https://wiki.openwrt.org/toh/tp-link/tl-wr810n
>>>>>
>>>>> The device has a slide switch to select its mode of operation when using
>>>>> the stock firmware. After looking at how it's implemented for similar
>>>>> devices, I also used 'struct gpio_keys_button { .type = EV_SW, .code = BTN_... }'
>>>>> to support the switch, but both 'switch_b0' and 'switch_b1' are missing
>>>>> when using 'evtest' and 'thd', only the 'reset' button shows up in the
>>>>> output of the programs.
>>>>>
>>>>> Changing '.code' to some SW_ value, for example SW_LID and SW_TABLET_MODE,
>>>>> makes them usable with both 'evtest' and 'thd'. Am I missing something,
>>>>> or is EV_SW + BTN_... an invalid combination?
>>>>
>>>> i use EV_SW and KEY_RFKILL on various boards and it works well. look at
>>>> package/base-files/files/etc/rc.button/rfkill to see how to handle the
>>>> events in userland
>>>>
>>>> John
>>>
>>> Thanks for the hint, indeed the switches can be used like ordinary buttons with procd. What's missing is a way to get the initial switch state after start-up, but that seems to be a limitation of the gpio-button-hotplug driver and procd, not an error in the initialization code.
>>>
>>
>> when using EV_SW it should send one initial event with the starting
>> state. i am sure i added that at some point. i've just put a task onto
>> my todo list. i'll have a look at it the next days.
>
> I used the following script to react on switch changes:
>
> root at OpenWrt:/# cat /etc/hotplug.d/button/btn
> #!/bin/sh
> logger "$0 $BUTTON $ACTION"
> echo "$0 $BUTTON $ACTION" >>/tmp/btn
>
> Directly after start-up the file /tmp/btn is empty and no messages got logged. Enabling the debug messages of the driver shows that it generates some events after it is loaded:
>
> [ 4.263157] gpio-keys: event type=5, code=256, value=0
> [ 4.263179] gpio-keys: create event, name=BTN_0, seen=42949377, pressed=0
> [ 4.263192] gpio-keys: event type=5, code=257, value=1
> [ 4.263203] gpio-keys: create event, name=BTN_1, seen=42949377, pressed=1
> [ 4.263231] gpio-keys: added variable 'released@'
> [ 4.263241] gpio-keys: added variable 'HOME=/'
> [ 4.263252] gpio-keys: added variable 'PATH=/sbin:/bin:/usr/sbin:/usr/bin'
> [ 4.263263] gpio-keys: added variable 'SUBSYSTEM=button'
> [ 4.263273] gpio-keys: added variable 'ACTION=released'
> [ 4.263283] gpio-keys: added variable 'BUTTON=BTN_0'
> [ 4.263293] gpio-keys: added variable 'TYPE=switch'
> [ 4.263303] gpio-keys: added variable 'SEEN=42949377'
> [ 4.263314] gpio-keys: added variable 'SEQNUM=258'
> [ 4.263340] gpio-keys: added variable 'pressed@'
> [ 4.263349] gpio-keys: added variable 'HOME=/'
> [ 4.263360] gpio-keys: added variable 'PATH=/sbin:/bin:/usr/sbin:/usr/bin'
> [ 4.263371] gpio-keys: added variable 'SUBSYSTEM=button'
> [ 4.263381] gpio-keys: added variable 'ACTION=pressed'
> [ 4.263390] gpio-keys: added variable 'BUTTON=BTN_1'
> [ 4.263400] gpio-keys: added variable 'TYPE=switch'
> [ 4.263410] gpio-keys: added variable 'SEEN=42949377'
> [ 4.263420] gpio-keys: added variable 'SEQNUM=259'
> [ 4.263455] ehci-platform ehci-platform: USB 2.0 started, EHCI 1.00
> [ 4.270905] hub 1-0:1.0: USB hub found
> [ 4.275308] hub 1-0:1.0: 1 port detected
> [ 4.282975] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
> [ 4.291082] ohci-platform: OHCI generic platform driver
> [ 4.299513] uhci_hcd: USB Universal Host Controller Interface driver
> [ 4.316930] init: - preinit -
> [ 5.025936] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
> [ 5.054558] random: procd urandom read with 8 bits of entropy available
> [ 8.292207] jffs2: notice: (359) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
> [ 8.310100] mount_root: switching to jffs2 overlay
> [ 8.358949] procd: - early -
> [ 8.362073] procd: - watchdog -
> [ 9.052180] procd: - ubus -
> [ 9.172024] procd: - init -
>
> The procd messages come a few seconds after the messages from the driver, so maybe it's just to early for userspace to react?
>
> When I reload the driver, the events are processed by procd/the button handling script:
>
> root at OpenWrt:/# cat /tmp/btn
> cat: can't open '/tmp/btn': No such file or directory
> root at OpenWrt:/# rmmod gpio_button_hotplug
> root at OpenWrt:/# modprobe gpio_button_hotplug
> root at OpenWrt:/# cat /tmp/btn
> /etc/rc.button/BTN_0 BTN_0 released
> /sbin/hotplug-call BTN_0 released
> /etc/rc.button/BTN_1 BTN_1 pressed
> /sbin/hotplug-call BTN_1 pressed
>
> Jens
>
thanks for debugging, looks like a regression, this used to work for
sure. i'll have a look at it.
John
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list