Exemplo n.º 1
0
int __init brcm_wifi_init_gpio(struct device_node *np)
{
	if (np) {
		int wl_reg_on;
		wl_reg_on = of_get_named_gpio(np, "wl_reg_on", 0);
		if (wl_reg_on >= 0) {
			gpio_wl_reg_on = wl_reg_on;
			BCM_DBG("%s: wl_reg_on GPIO %d\n", __func__, wl_reg_on);
		}
	}

	if (gpio_request(gpio_wl_reg_on, "WL_REG_ON"))
		pr_err("%s: Faiiled to request gpio %d for WL_REG_ON\n",
			__func__, gpio_wl_reg_on);
	else
		pr_err("%s: gpio_request WL_REG_ON done\n", __func__);

	if (gpio_direction_output(gpio_wl_reg_on, 1))
		pr_err("%s: WL_REG_ON failed to pull up\n", __func__);
	else
		BCM_DBG("%s: WL_REG_ON is pulled up\n", __func__);

	if (gpio_get_value(gpio_wl_reg_on))
		BCM_DBG("%s: Initial WL_REG_ON: [%d]\n",
			__func__, gpio_get_value(gpio_wl_reg_on));

	return 0;
}
Exemplo n.º 2
0
static int __init dhd_mac_addr_setup(char *str)
{
	char macstr[IFHWADDRLEN*3];
	char *macptr = macstr;
	char *token;
	int i = 0;

	if (!str)
		return 0;
	BCM_DBG("wlan MAC = %s\n", str);
	if (strlen(str) >= sizeof(macstr))
		return 0;
	strlcpy(macstr, str, sizeof(macstr));

	while (((token = strsep(&macptr, ":")) != NULL) && (i < IFHWADDRLEN)) {
		unsigned long val;
		int res;

		res = kstrtoul(token, 0x10, &val);
		if (res < 0)
			break;
		brcm_mac_addr[i++] = (u8)val;
	}

	if (i < IFHWADDRLEN && strlen(macstr)==IFHWADDRLEN*2) {
		/* try again with wrong format (sans colons) */
		u64 mac;
		if (kstrtoull(macstr, 0x10, &mac) < 0)
			return 0;
		for (i=0; i<IFHWADDRLEN; i++)
			brcm_mac_addr[IFHWADDRLEN-1-i] = (u8)((0xFF)&(mac>>(i*8)));
	}
Exemplo n.º 3
0
int dhd_wifi_init_gpio(void)
{
	int wl_reg_on,wl_host_wake;
	char *wlan_node = "android,bcmdhd_wlan";
	struct device_node *np;

	np = of_find_compatible_node(NULL, NULL, wlan_node);
	if (!np) {
		WARN(1, "failed to get device node of BRCM WLAN\n");
		return -ENODEV;
	}

	/* get wlan_reg_on */
	wl_reg_on = of_get_named_gpio(np, "wl_reg_on", 0);
	if (wl_reg_on >= 0) {
		gpio_wl_reg_on = wl_reg_on;
		BCM_DBG("%s: gpio_wl_reg_on:%d.\n", __FUNCTION__, gpio_wl_reg_on);
	}

	/* get host_wake irq */
	wl_host_wake = of_get_named_gpio(np, "wl_host_wake", 0);
	if (wl_host_wake >= 0) {
		BCM_DBG("%s: wl_host_wake:%d.\n", __FUNCTION__, wl_host_wake);
		brcm_wake_irq = gpio_to_irq(wl_host_wake);
	}

	if (gpio_request(gpio_wl_reg_on, "WL_REG_ON"))
		pr_err("%s: Faiiled to request gpio %d for WL_REG_ON\n",
			__func__, gpio_wl_reg_on);
	else
		pr_err("%s: gpio_request WL_REG_ON done\n", __func__);

	if (gpio_direction_output(gpio_wl_reg_on, 1))
		pr_err("%s: WL_REG_ON failed to pull up\n", __func__);
	else
		BCM_DBG("%s: WL_REG_ON is pulled up\n", __func__);

	if (gpio_get_value(gpio_wl_reg_on))
		BCM_DBG("%s: Initial WL_REG_ON: [%d]\n",
			__func__, gpio_get_value(gpio_wl_reg_on));

	return 0;
}
Exemplo n.º 4
0
int brcm_wlan_power(int on)
{
	BCM_DBG("------------------------------------------------");
	BCM_DBG("------------------------------------------------\n");
	pr_info("%s Enter: power %s\n", __func__, on ? "on" : "off");

	if (on) {
		if (gpio_direction_output(gpio_wl_reg_on, 1)) {
			pr_err("%s: WL_REG_ON didn't output high\n", __func__);
			return -EIO;
		}
		if (!gpio_get_value(gpio_wl_reg_on))
			pr_err("[%s] gpio didn't set high.\n", __func__);
	} else {
		if (gpio_direction_output(gpio_wl_reg_on, 0)) {
			pr_err("%s: WL_REG_ON didn't output low\n", __func__);
			return -EIO;
		}
	}
	return 0;
}