summaryrefslogtreecommitdiff
path: root/target/linux/brcm63xx/patches-3.18/377-MIPS-BCM63XX-register-lookup-for-ephy-reset-gpio.patch
blob: 30f6ba50983eb264aca52c1f03659a10884b349b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
From d13bdf92ec885105cf107183f8464c40e5f3b93b Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jogo@openwrt.org>
Date: Sat, 21 Feb 2015 17:21:59 +0100
Subject: [PATCH 4/6] MIPS: BCM63XX: register lookup for ephy-reset gpio


Signed-off-by: Jonas Gorski <jogo@openwrt.org>
---
 arch/mips/bcm63xx/boards/board_bcm963xx.c          |    2 +-
 arch/mips/bcm63xx/boards/board_common.c            |    7 +++--
 arch/mips/bcm63xx/gpio.c                           |   32 ++++++++++++++++++++
 arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h  |    2 ++
 .../mips/include/asm/mach-bcm63xx/board_bcm963xx.h |    5 +--
 5 files changed, 42 insertions(+), 6 deletions(-)

--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -59,7 +59,7 @@ static struct board_info __initdata boar
 	},
 
 	.ephy_reset_gpio		= 36,
-	.ephy_reset_gpio_flags		= GPIOF_INIT_HIGH,
+	.ephy_reset_gpio_flags		= GPIO_ACTIVE_LOW,
 };
 #endif
 
--- a/arch/mips/bcm63xx/boards/board_common.c
+++ b/arch/mips/bcm63xx/boards/board_common.c
@@ -278,9 +278,10 @@ int __init board_register_devices(void)
 		platform_device_register(&bcm63xx_gpio_leds);
 	}
 
-	if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
-		gpio_request_one(board.ephy_reset_gpio,
-				board.ephy_reset_gpio_flags, "ephy-reset");
+	if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags) {
+		bcm63xx_gpio_ephy_reset(board.ephy_reset_gpio,
+					board.ephy_reset_gpio_flags);
+	}
 
 	/* count number of BUTTONs defined by this device */
 	while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
--- a/arch/mips/bcm63xx/gpio.c
+++ b/arch/mips/bcm63xx/gpio.c
@@ -8,15 +8,24 @@
  * Copyright (C) Jonas Gorski <jogo@openwrt.org>
  */
 
+#include <asm/addrspace.h>
+
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/basic_mmio_gpio.h>
 #include <linux/gpio.h>
+#include <linux/gpio/machine.h>
 
 #include <bcm63xx_cpu.h>
 #include <bcm63xx_gpio.h>
 #include <bcm63xx_regs.h>
 
+/* for registering lookups; make them large enough to hold OF names */
+static char *gpio_chip_labels[] = {
+	"xxxxxxxx.gpio-controller",
+	"xxxxxxxx.gpio-controller",
+};
+
 static void __init bcm63xx_gpio_init_one(int id, int dir, int data, int ngpio)
 {
 	struct resource res[2];
@@ -40,6 +49,7 @@ static void __init bcm63xx_gpio_init_one
 	pdata.base = id * 32;
 	pdata.ngpio = ngpio;
 
+	sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
 	platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res, 2,
 					  &pdata, sizeof(pdata));
 }
@@ -64,3 +74,25 @@ int __init bcm63xx_gpio_init(void)
 	return 0;
 
 }
+
+static struct gpiod_lookup_table ephy_reset = {
+	.dev_id = "bcm63xx_enet_shared.0",
+	.table = {
+		{ /* filled at runtime */ },
+		{ },
+	},
+};
+
+
+void bcm63xx_gpio_ephy_reset(int hw_gpio, enum gpio_lookup_flags flags)
+{
+	if (ephy_reset.table[0].chip_label)
+		return;
+
+	ephy_reset.table[0].chip_label = gpio_chip_labels[hw_gpio / 32];
+	ephy_reset.table[0].chip_hwnum = hw_gpio % 32;
+	ephy_reset.table[0].con_id = "ephy-reset";
+	ephy_reset.table[0].flags = flags;
+
+	gpiod_add_lookup_table(&ephy_reset);
+}
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
@@ -2,9 +2,11 @@
 #define BCM63XX_GPIO_H
 
 #include <linux/init.h>
+#include <linux/gpio/machine.h>
 #include <bcm63xx_cpu.h>
 
 int __init bcm63xx_gpio_init(void);
+void bcm63xx_gpio_ephy_reset(int hw_gpio, enum gpio_lookup_flags flags);
 
 static inline unsigned long bcm63xx_gpio_count(void)
 {
--- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
+++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
@@ -4,6 +4,7 @@
 #include <linux/types.h>
 #include <linux/gpio.h>
 #include <linux/gpio_keys.h>
+#include <linux/gpio/machine.h>
 #include <linux/leds.h>
 #include <bcm63xx_dev_enet.h>
 #include <bcm63xx_dev_usb_usbd.h>
@@ -58,8 +59,8 @@ struct board_info {
 	/* External PHY reset GPIO */
 	unsigned int ephy_reset_gpio;
 
-	/* External PHY reset GPIO flags from gpio.h */
-	unsigned long ephy_reset_gpio_flags;
+	/* External PHY reset GPIO flags from gpio/machine.h */
+	enum gpio_lookup_flags ephy_reset_gpio_flags;
 
 	/* fallback sprom config */
 	struct fallback_sprom_data fallback_sprom;