|
36 | 36 | #include <linux/platform_device.h>
|
37 | 37 | #include <linux/irq.h>
|
38 | 38 | #include <linux/slab.h>
|
| 39 | +#include <linux/regulator/consumer.h> |
| 40 | +#include <linux/gpio.h> |
| 41 | +#include <linux/of_gpio.h> |
39 | 42 |
|
40 | 43 | #include <asm/delay.h>
|
41 | 44 | #include <asm/irq.h>
|
@@ -1426,11 +1429,48 @@ dm9000_probe(struct platform_device *pdev)
|
1426 | 1429 | struct dm9000_plat_data *pdata = dev_get_platdata(&pdev->dev);
|
1427 | 1430 | struct board_info *db; /* Point a board information structure */
|
1428 | 1431 | struct net_device *ndev;
|
| 1432 | + struct device *dev = &pdev->dev; |
1429 | 1433 | const unsigned char *mac_src;
|
1430 | 1434 | int ret = 0;
|
1431 | 1435 | int iosize;
|
1432 | 1436 | int i;
|
1433 | 1437 | u32 id_val;
|
| 1438 | + int reset_gpios; |
| 1439 | + enum of_gpio_flags flags; |
| 1440 | + struct regulator *power; |
| 1441 | + |
| 1442 | + power = devm_regulator_get(dev, "vcc"); |
| 1443 | + if (IS_ERR(power)) { |
| 1444 | + if (PTR_ERR(power) == -EPROBE_DEFER) |
| 1445 | + return -EPROBE_DEFER; |
| 1446 | + dev_dbg(dev, "no regulator provided\n"); |
| 1447 | + } else { |
| 1448 | + ret = regulator_enable(power); |
| 1449 | + if (ret != 0) { |
| 1450 | + dev_err(dev, |
| 1451 | + "Failed to enable power regulator: %d\n", ret); |
| 1452 | + return ret; |
| 1453 | + } |
| 1454 | + dev_dbg(dev, "regulator enabled\n"); |
| 1455 | + } |
| 1456 | + |
| 1457 | + reset_gpios = of_get_named_gpio_flags(dev->of_node, "reset-gpios", 0, |
| 1458 | + &flags); |
| 1459 | + if (gpio_is_valid(reset_gpios)) { |
| 1460 | + ret = devm_gpio_request_one(dev, reset_gpios, flags, |
| 1461 | + "dm9000_reset"); |
| 1462 | + if (ret) { |
| 1463 | + dev_err(dev, "failed to request reset gpio %d: %d\n", |
| 1464 | + reset_gpios, ret); |
| 1465 | + return -ENODEV; |
| 1466 | + } |
| 1467 | + |
| 1468 | + /* According to manual PWRST# Low Period Min 1ms */ |
| 1469 | + msleep(2); |
| 1470 | + gpio_set_value(reset_gpios, 1); |
| 1471 | + /* Needs 3ms to read eeprom when PWRST is deasserted */ |
| 1472 | + msleep(4); |
| 1473 | + } |
1434 | 1474 |
|
1435 | 1475 | if (!pdata) {
|
1436 | 1476 | pdata = dm9000_parse_dt(&pdev->dev);
|
|
0 commit comments