18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci#include "bcm47xx_private.h"
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#include <linux/gpio.h>
58c2ecf20Sopenharmony_ci#include <bcm47xx_board.h>
68c2ecf20Sopenharmony_ci#include <bcm47xx.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_cistatic void __init bcm47xx_workarounds_enable_usb_power(int usb_power)
98c2ecf20Sopenharmony_ci{
108c2ecf20Sopenharmony_ci	int err;
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci	err = gpio_request_one(usb_power, GPIOF_OUT_INIT_HIGH, "usb_power");
138c2ecf20Sopenharmony_ci	if (err)
148c2ecf20Sopenharmony_ci		pr_err("Failed to request USB power gpio: %d\n", err);
158c2ecf20Sopenharmony_ci	else
168c2ecf20Sopenharmony_ci		gpio_free(usb_power);
178c2ecf20Sopenharmony_ci}
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_civoid __init bcm47xx_workarounds(void)
208c2ecf20Sopenharmony_ci{
218c2ecf20Sopenharmony_ci	enum bcm47xx_board board = bcm47xx_board_get();
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci	switch (board) {
248c2ecf20Sopenharmony_ci	case BCM47XX_BOARD_NETGEAR_WNR3500L:
258c2ecf20Sopenharmony_ci		bcm47xx_workarounds_enable_usb_power(12);
268c2ecf20Sopenharmony_ci		break;
278c2ecf20Sopenharmony_ci	case BCM47XX_BOARD_NETGEAR_WNDR3400V2:
288c2ecf20Sopenharmony_ci	case BCM47XX_BOARD_NETGEAR_WNDR3400_V3:
298c2ecf20Sopenharmony_ci		bcm47xx_workarounds_enable_usb_power(21);
308c2ecf20Sopenharmony_ci		break;
318c2ecf20Sopenharmony_ci	default:
328c2ecf20Sopenharmony_ci		/* No workaround(s) needed */
338c2ecf20Sopenharmony_ci		break;
348c2ecf20Sopenharmony_ci	}
358c2ecf20Sopenharmony_ci}
36