I apologize in advance for my bad English.

Problem Description Control USB Power on the device TL-MR3420v2.
Exactly found that the Power switch USB port controlled by GPIO4, but
the ability to control this GPIO4 (in output mode) - does not allow.
Are known patches that manage GPIO4 in Input mode, so it can somehow
enable USB-Power switch.
My doubts about that I wrote in https://dev.openwrt.org/ticket/13201#comment:18

In the original firmware source code found that USB-port powered GPIO4
in Output mode (USB_POWER_ON =  "1").

> static int usb_power_write (struct file *file, const char *buf,
>                                         unsigned long count, void *data)
> {
>     u_int32_t val = 0;
>
>       if (sscanf(buf, "%d", &val) != 1)
>         return -EINVAL;
>
>       if ((val < 0) || (val > 1))
>               return -EINVAL;
>
>       printk("%s %d: write gpio:value = %d\r\n",__FUNCTION__,__LINE__,val);
>       
>       if (USB_POWER_ON == val)
>       {
>               ath_gpio_out_val(USB_POWER_SW_GPIO, USB_POWER_ON);
>       }
>       else
>       {
>               ath_gpio_out_val(USB_POWER_SW_GPIO, USB_POWER_OFF);
>       }
>       
>       return count;
> }
ap123_gpl/ap123/linux/kernels/mips-linux-2.6.31/arch/mips/atheros/gpio.c

However, the actual change with this configuration OpenWRT - there is
no positive result and GPIO4 not controlled.
Also known that with this configuration OpenWRT  does not work
USB-LED. In the original firmware source code revealed that it is
controlled by a negative value of "0" = enabled.

> /* USB LED, default is GPIO11 */
> #define AP_USB_LED_GPIO     CONFIG_GPIO_USB_LED_BIT
> /* USB LED's value when off */
> #define USB_LED_OFF         (!CONFIG_GPIO_USB_LED_ON)
> /* USB LED's value when on, default is 0 */
> #define USB_LED_ON          CONFIG_GPIO_USB_LED_ON
ap123_gpl/ap123/linux/kernels/mips-linux-2.6.31/arch/mips/atheros/gpio.c

But in this configuration OpenWRT USB-LED default active_low = "1"

I have some thoughts on that.
In the GPL-source code for the AP123 platform I do not find the
initial configuration of GPIO at uboot level. Most likely this is
because it was moved to the level of firmware (compared with other
platforms TP-Link). At least this applies to GPIO4 - where exactly in
the source "gpio.c" disable AR934X_GPIO_FUNC_CLK_OBS4_EN (BIT (6)).

>       /* config gpio15, 14, 11, 4, 16, 17 as normal gpio function */
>       /* gpio4 */
>       ath_reg_rmw_clear(ATH_GPIO_FUNCTIONS, 1<<6);
>       ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION1, 0xff);
>       /* gpio11 */
>       ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION2, 0xff<<24);
>       /* gpio14 */
>       ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION3, 0xff<<16);
>       /* gpio15 */
>       ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION3, 0xff<<24);
>       /* gpio16 */
>       ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<0);
>       /* gpio17 */
>       ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<8);
ap123_gpl/ap123/linux/kernels/mips-linux-2.6.31/arch/mips/atheros/gpio.c

I ask to speak up about my comments.
GPL source code can be downloaded at link:
http://www.tp-link.com/en/support/gpl/?categoryid=547
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to