brcm63xx: Add DGND3700 v1 / DGND3800B support
[oweals/openwrt.git] / target / linux / brcm63xx / patches-3.14 / 376-net-bcm63xx_enet-use-named-gpio-for-ephy-reset-gpio.patch
1 From ec905f2ea78ec40602a685ede31c5e4f9893d196 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Sat, 21 Feb 2015 16:35:07 +0100
4 Subject: [PATCH 3/6] net: bcm63xx_enet: use named gpio for ephy reset gpio
5
6 Allow using a named optional gpio for ephy reset gpio registration.
7 ---
8  drivers/net/ethernet/broadcom/bcm63xx_enet.c |    12 ++++++++++++
9  1 file changed, 12 insertions(+)
10
11 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
12 +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
13 @@ -30,6 +30,7 @@
14  #include <linux/dma-mapping.h>
15  #include <linux/platform_device.h>
16  #include <linux/if_vlan.h>
17 +#include <linux/gpio/consumer.h>
18  
19  #include <bcm63xx_dev_enet.h>
20  #include "bcm63xx_enet.h"
21 @@ -2852,10 +2853,18 @@ static int bcm_enet_shared_probe(struct
22  {
23         struct resource *res;
24         void __iomem *p[3];
25 +       struct gpio_desc *ephy_reset;
26         unsigned int i;
27  
28         memset(bcm_enet_shared_base, 0, sizeof(bcm_enet_shared_base));
29  
30 +       ephy_reset = devm_gpiod_get(&pdev->dev, "ephy-reset");
31 +       if (IS_ERR(ephy_reset)) {
32 +               if (PTR_ERR(ephy_reset) != -ENOENT)
33 +                       return PTR_ERR(ephy_reset);
34 +               ephy_reset = NULL;
35 +       }
36 +       
37         for (i = 0; i < 3; i++) {
38                 res = platform_get_resource(pdev, IORESOURCE_MEM, i);
39                 p[i] = devm_ioremap_resource(&pdev->dev, res);
40 @@ -2865,6 +2874,9 @@ static int bcm_enet_shared_probe(struct
41  
42         memcpy(bcm_enet_shared_base, p, sizeof(bcm_enet_shared_base));
43  
44 +       if (ephy_reset)
45 +               gpiod_direction_output(ephy_reset, 0);
46 +
47         return 0;
48  }
49