Skip to content

Commit bbf17e8

Browse files
committed
Merge branch 'at91-5.4-trunk/wilc' into linux-5.4-at91
2 parents fe15300 + e94f7a1 commit bbf17e8

9 files changed

Lines changed: 219 additions & 208 deletions

File tree

drivers/staging/wilc1000/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ccflags-y += -I$(src)/ -DWILC_ASIC_A0 -DWILC_DEBUGFS
33

44
wilc-objs := cfg80211.o netdev.o mon.o \
55
hif.o wlan_cfg.o debugfs.o \
6-
wlan.o sysfs.o bt.o
6+
wlan.o sysfs.o bt.o power.o
77

88
obj-$(CONFIG_WILC_SDIO) += wilc-sdio.o
99
wilc-sdio-objs += $(wilc-objs)

drivers/staging/wilc1000/bt.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -309,26 +309,28 @@ int wilc_bt_power_down(struct wilc *wilc, int source)
309309

310310
pr_info("source: %s, current bus status Wifi: %d, BT: %d\n",
311311
(source == DEV_WIFI ? "Wifi" : "BT"),
312-
wilc->power_status[DEV_WIFI],
313-
wilc->power_status[DEV_BT]);
312+
wilc->power.status[DEV_WIFI],
313+
wilc->power.status[DEV_BT]);
314314

315-
if (wilc->power_status[source] == false) {
315+
if (wilc->power.status[source] == false) {
316316
pr_err("power down request for already powered down source %s\n",
317317
(source == DEV_WIFI ? "Wifi" : "BT"));
318318
} else if (((source == DEV_WIFI) &&
319-
(wilc->power_status[DEV_BT] == true)) ||
319+
(wilc->power.status[DEV_BT] == true)) ||
320320
((source == DEV_BT) &&
321-
(wilc->power_status[DEV_WIFI] == true))) {
321+
(wilc->power.status[DEV_WIFI] == true))) {
322322
pr_warn("Another device is preventing power down. request source is %s\n",
323323
(source == DEV_WIFI ? "Wifi" : "BT"));
324324
} else {
325-
ret = wilc_wlan_power_off_sequence(wilc);
325+
acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY, source);
326+
ret = wilc->hif_func->hif_deinit(wilc);
327+
release_bus(wilc, WILC_BUS_RELEASE_ONLY, source);
326328
if (ret) {
327329
mutex_unlock(&wilc->cs);
328330
return ret;
329331
}
330332
}
331-
wilc->power_status[source] = false;
333+
wilc->power.status[source] = false;
332334

333335
mutex_unlock(&wilc->cs);
334336

@@ -346,24 +348,24 @@ int wilc_bt_power_up(struct wilc *wilc, int source)
346348

347349
pr_debug("source: %s, current bus status Wifi: %d, BT: %d\n",
348350
(source == DEV_WIFI ? "Wifi" : "BT"),
349-
wilc->power_status[DEV_WIFI],
350-
wilc->power_status[DEV_BT]);
351+
wilc->power.status[DEV_WIFI],
352+
wilc->power.status[DEV_BT]);
351353

352-
if (wilc->power_status[source] == true) {
354+
if (wilc->power.status[source] == true) {
353355
pr_err("power up request for already powered up source %s\n",
354356
(source == DEV_WIFI ? "Wifi" : "BT"));
355357
} else {
356358
/*Bug 215*/
357359
/*Avoid overlapping between BT and Wifi intialization*/
358-
if (wilc->power_status[DEV_WIFI] == true) {
360+
if (wilc->power.status[DEV_WIFI] == true) {
359361
while (!wilc->initialized) {
360362
msleep(100);
361363
if (++count > 20) {
362364
pr_warn("Wifi initialize timeout\n");
363365
break;
364366
}
365367
}
366-
} else if (wilc->power_status[DEV_BT] == true) {
368+
} else if (wilc->power.status[DEV_BT] == true) {
367369
while (!bt_init_done) {
368370
msleep(200);
369371
if (++count > 30) {
@@ -380,20 +382,20 @@ int wilc_bt_power_up(struct wilc *wilc, int source)
380382
}
381383
}
382384

383-
if ((wilc->power_status[DEV_WIFI] == true) ||
384-
(wilc->power_status[DEV_BT] == true)) {
385+
if ((wilc->power.status[DEV_WIFI] == true) ||
386+
(wilc->power.status[DEV_BT] == true)) {
385387
pr_info("Device already up. request source is %s\n",
386388
(source == DEV_WIFI ? "Wifi" : "BT"));
387389
} else {
388390
pr_info("WILC POWER UP\n");
389391
}
390-
wilc->power_status[source] = true;
392+
wilc->power.status[source] = true;
391393
mutex_unlock(&wilc->cs);
392394

393395
if (source == DEV_BT) {
394396
/*TicketId1092*/
395397
/*If WiFi is off, force BT*/
396-
if (wilc->power_status[DEV_WIFI] == false) {
398+
if (wilc->power.status[DEV_WIFI] == false) {
397399
acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP, DEV_BT);
398400

399401
/*TicketId1115*/

drivers/staging/wilc1000/hif.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,6 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
236236
void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
237237
struct cfg80211_crypto_settings *crypto);
238238
void handle_connect_cancel(struct wilc_vif *vif);
239+
int wilc_of_parse_power_pins(struct wilc *wilc);
240+
void wilc_wlan_power(struct wilc *wilc, bool on);
239241
#endif

drivers/staging/wilc1000/netdev.c

Lines changed: 4 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ static int init_irq(struct net_device *dev)
170170
struct wilc_vif *vif = netdev_priv(dev);
171171
struct wilc *wl = vif->wilc;
172172

173+
if (wl->dev_irq_num <= 0)
174+
return 0;
175+
173176
if (wl->io_type == WILC_HIF_SPI ||
174177
wl->io_type == WILC_HIF_SDIO_GPIO_IRQ) {
175178
if (request_threaded_irq(wl->dev_irq_num, isr_uh_routine,
@@ -182,8 +185,7 @@ static int init_irq(struct net_device *dev)
182185
return -EINVAL;
183186
}
184187
} else {
185-
if (wl->dev_irq_num &&
186-
request_irq(wl->dev_irq_num, host_wakeup_isr,
188+
if (request_irq(wl->dev_irq_num, host_wakeup_isr,
187189
IRQF_TRIGGER_FALLING |
188190
IRQF_NO_SUSPEND,
189191
"WILC_IRQ", wl) < 0) {
@@ -1345,152 +1347,4 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
13451347
return vif;
13461348
}
13471349

1348-
#if KERNEL_VERSION(3, 13, 0) < LINUX_VERSION_CODE
1349-
static int wilc_wlan_power(struct wilc *wilc, int power)
1350-
{
1351-
struct gpio_desc *gpio_reset;
1352-
struct gpio_desc *gpio_chip_en;
1353-
int ret = 0;
1354-
1355-
pr_info("wifi_pm : %d\n", power);
1356-
1357-
gpio_reset = gpiod_get(wilc->dt_dev, "reset", GPIOD_ASIS);
1358-
if (IS_ERR(gpio_reset)) {
1359-
dev_warn(wilc->dev, "failed to get Reset GPIO, try default\r\n");
1360-
gpio_reset = gpio_to_desc(GPIO_NUM_RESET);
1361-
if (!gpio_reset) {
1362-
dev_warn(wilc->dev,
1363-
"failed to get default Reset GPIO\r\n");
1364-
return -EIO;
1365-
}
1366-
} else {
1367-
dev_info(wilc->dev, "succesfully got gpio_reset\r\n");
1368-
}
1369-
1370-
gpio_chip_en = gpiod_get(wilc->dt_dev, "chip_en", GPIOD_ASIS);
1371-
if (IS_ERR(gpio_chip_en)) {
1372-
gpio_chip_en = gpio_to_desc(GPIO_NUM_CHIP_EN);
1373-
if (!gpio_chip_en) {
1374-
dev_warn(wilc->dev,
1375-
"failed to get default chip_en GPIO\r\n");
1376-
gpiod_put(gpio_reset);
1377-
return -EIO;
1378-
}
1379-
} else {
1380-
dev_info(wilc->dev, "succesfully got gpio_chip_en\r\n");
1381-
}
1382-
1383-
if (power) {
1384-
ret = gpiod_direction_output(gpio_chip_en, 1);
1385-
if (ret < 0) {
1386-
dev_warn(wilc->dev,
1387-
"failed to set chip_en GPIO direction\r\n");
1388-
goto out;
1389-
ret = -EIO;
1390-
}
1391-
mdelay(5);
1392-
ret = gpiod_direction_output(gpio_reset, 1);
1393-
if (ret) {
1394-
dev_warn(wilc->dev,
1395-
"failed to set reset GPIO direction\r\n");
1396-
goto out;
1397-
ret = -EIO;
1398-
}
1399-
} else {
1400-
ret = gpiod_direction_output(gpio_reset, 0);
1401-
if (ret) {
1402-
dev_warn(wilc->dev,
1403-
"failed to set chip_en GPIO direction\r\n");
1404-
goto out;
1405-
ret = -EIO;
1406-
}
1407-
ret = gpiod_direction_output(gpio_chip_en, 0);
1408-
if (ret) {
1409-
dev_warn(wilc->dev,
1410-
"failed to set reset GPIO direction\r\n");
1411-
goto out;
1412-
ret = -EIO;
1413-
}
1414-
}
1415-
1416-
out:
1417-
gpiod_put(gpio_chip_en);
1418-
gpiod_put(gpio_reset);
1419-
1420-
return ret;
1421-
}
1422-
#else
1423-
static int wilc_wlan_power(struct wilc *wilc, int power)
1424-
{
1425-
int gpio_reset;
1426-
int gpio_chip_en;
1427-
struct device_node *of_node = wilc->dt_dev->of_node;
1428-
1429-
pr_info("wifi_pm : %d\n", power);
1430-
1431-
gpio_reset = of_get_named_gpio_flags(of_node, "reset-gpios", 0, NULL);
1432-
1433-
if (gpio_reset < 0) {
1434-
gpio_reset = GPIO_NUM_RESET;
1435-
pr_info("wifi_pm : load default reset GPIO %d\n", gpio_reset);
1436-
}
1437-
1438-
gpio_chip_en = of_get_named_gpio_flags(of_node, "chip_en-gpios", 0,
1439-
NULL);
1440-
1441-
if (gpio_chip_en < 0) {
1442-
gpio_chip_en = GPIO_NUM_CHIP_EN;
1443-
pr_info("wifi_pm : load default chip_en GPIO %d\n",
1444-
gpio_chip_en);
1445-
}
1446-
1447-
if (gpio_request(gpio_chip_en, "CHIP_EN") == 0 &&
1448-
gpio_request(gpio_reset, "RESET") == 0) {
1449-
gpio_direction_output(gpio_chip_en, 0);
1450-
gpio_direction_output(gpio_reset, 0);
1451-
if (power) {
1452-
gpio_set_value(gpio_chip_en, 1);
1453-
mdelay(5);
1454-
gpio_set_value(gpio_reset, 1);
1455-
} else {
1456-
gpio_set_value(gpio_reset, 0);
1457-
gpio_set_value(gpio_chip_en, 0);
1458-
}
1459-
gpio_free(gpio_chip_en);
1460-
gpio_free(gpio_reset);
1461-
} else {
1462-
dev_err(wilc->dev,
1463-
"Error requesting GPIOs for CHIP_EN and RESET");
1464-
return -EIO;
1465-
}
1466-
1467-
return 0;
1468-
}
1469-
#endif
1470-
1471-
int wilc_wlan_power_on_sequence(struct wilc *wilc)
1472-
{
1473-
int ret;
1474-
1475-
ret = wilc_wlan_power(wilc, 0);
1476-
if (ret)
1477-
return ret;
1478-
ret = wilc_wlan_power(wilc, 1);
1479-
if (ret)
1480-
return ret;
1481-
1482-
return 0;
1483-
}
1484-
1485-
int wilc_wlan_power_off_sequence(struct wilc *wilc)
1486-
{
1487-
int ret;
1488-
1489-
ret = wilc_wlan_power(wilc, 0);
1490-
if (ret)
1491-
return ret;
1492-
1493-
return 0;
1494-
}
1495-
14961350
MODULE_LICENSE("GPL");

drivers/staging/wilc1000/netdev.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
#include <net/ieee80211_radiotap.h>
1414
#include <linux/if_arp.h>
1515
#include <linux/version.h>
16-
#if KERNEL_VERSION(3, 13, 0) < LINUX_VERSION_CODE
17-
#include <linux/gpio/consumer.h>
18-
#else
19-
#include <linux/of_gpio.h>
20-
#include <linux/gpio.h>
21-
#endif
2216

2317
#include "hif.h"
2418
#include "wlan.h"
@@ -372,6 +366,16 @@ struct wilc_vif {
372366
struct cfg80211_bss *bss;
373367
};
374368

369+
struct wilc_power_gpios {
370+
int reset;
371+
int chip_en;
372+
};
373+
374+
struct wilc_power {
375+
struct wilc_power_gpios gpios;
376+
u8 status[DEV_MAX];
377+
};
378+
375379
struct wilc {
376380
struct wiphy *wiphy;
377381
const struct wilc_hif_func *hif_func;
@@ -433,7 +437,7 @@ struct wilc {
433437

434438
enum wilc_chip_type chip;
435439

436-
uint8_t power_status[DEV_MAX];
440+
struct wilc_power power;
437441
uint8_t keep_awake[DEV_MAX];
438442
struct mutex cs;
439443
struct workqueue_struct *hif_workqueue;

0 commit comments

Comments
 (0)