brcm63xx: remove broken DSP platform device code
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-4.14 / 377-MIPS-BCM63XX-register-lookup-for-ephy-reset-gpio.patch
1 From d13bdf92ec885105cf107183f8464c40e5f3b93b Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Sat, 21 Feb 2015 17:21:59 +0100
4 Subject: [PATCH 4/6] MIPS: BCM63XX: register lookup for ephy-reset gpio
5
6
7 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
8 ---
9 arch/mips/bcm63xx/boards/board_bcm963xx.c | 2 +-
10 arch/mips/bcm63xx/boards/board_common.c | 7 +++--
11 arch/mips/bcm63xx/gpio.c | 32 ++++++++++++++++++++
12 arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h | 2 ++
13 .../mips/include/asm/mach-bcm63xx/board_bcm963xx.h | 5 +--
14 5 files changed, 42 insertions(+), 6 deletions(-)
15
16 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
17 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
18 @@ -55,7 +55,7 @@ static struct board_info __initdata boar
19 },
20
21 .ephy_reset_gpio = 36,
22 - .ephy_reset_gpio_flags = GPIOF_INIT_HIGH,
23 + .ephy_reset_gpio_flags = GPIO_ACTIVE_LOW,
24 };
25 #endif
26
27 --- a/arch/mips/bcm63xx/boards/board_common.c
28 +++ b/arch/mips/bcm63xx/boards/board_common.c
29 @@ -247,9 +247,10 @@ int __init board_register_devices(void)
30
31 platform_device_register(&bcm63xx_gpio_leds);
32
33 - if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
34 - gpio_request_one(board.ephy_reset_gpio,
35 - board.ephy_reset_gpio_flags, "ephy-reset");
36 + if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags) {
37 + bcm63xx_gpio_ephy_reset(board.ephy_reset_gpio,
38 + board.ephy_reset_gpio_flags);
39 + }
40
41 return 0;
42 }
43 --- a/arch/mips/bcm63xx/gpio.c
44 +++ b/arch/mips/bcm63xx/gpio.c
45 @@ -8,15 +8,23 @@
46 * Copyright (C) Jonas Gorski <jogo@openwrt.org>
47 */
48
49 +#include <asm/addrspace.h>
50 +
51 #include <linux/kernel.h>
52 #include <linux/init.h>
53 #include <linux/platform_device.h>
54 #include <linux/gpio/driver.h>
55 +#include <linux/gpio/machine.h>
56
57 #include <bcm63xx_cpu.h>
58 #include <bcm63xx_gpio.h>
59 #include <bcm63xx_regs.h>
60
61 +static const char * const gpio_chip_labels[] = {
62 + "bcm63xx-gpio.0",
63 + "bcm63xx-gpio.1",
64 +};
65 +
66 static void __init bcm63xx_gpio_init_one(int id, int dir, int data, int ngpio)
67 {
68 struct resource res[2];
69 @@ -64,3 +72,25 @@ int __init bcm63xx_gpio_init(void)
70 return 0;
71
72 }
73 +
74 +static struct gpiod_lookup_table ephy_reset = {
75 + .dev_id = "bcm63xx_enet-0",
76 + .table = {
77 + { /* filled at runtime */ },
78 + { },
79 + },
80 +};
81 +
82 +
83 +void bcm63xx_gpio_ephy_reset(int hw_gpio, enum gpio_lookup_flags flags)
84 +{
85 + if (ephy_reset.table[0].chip_label)
86 + return;
87 +
88 + ephy_reset.table[0].chip_label = gpio_chip_labels[hw_gpio / 32];
89 + ephy_reset.table[0].chip_hwnum = hw_gpio % 32;
90 + ephy_reset.table[0].con_id = "reset";
91 + ephy_reset.table[0].flags = flags;
92 +
93 + gpiod_add_lookup_table(&ephy_reset);
94 +}
95 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
96 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
97 @@ -3,9 +3,11 @@
98 #define BCM63XX_GPIO_H
99
100 #include <linux/init.h>
101 +#include <linux/gpio/machine.h>
102 #include <bcm63xx_cpu.h>
103
104 int __init bcm63xx_gpio_init(void);
105 +void bcm63xx_gpio_ephy_reset(int hw_gpio, enum gpio_lookup_flags flags);
106
107 static inline unsigned long bcm63xx_gpio_count(void)
108 {
109 --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
110 +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
111 @@ -4,6 +4,7 @@
112
113 #include <linux/types.h>
114 #include <linux/gpio.h>
115 +#include <linux/gpio/machine.h>
116 #include <linux/leds.h>
117 #include <bcm63xx_dev_enet.h>
118 #include <bcm63xx_dev_usb_usbd.h>
119 @@ -50,8 +51,8 @@ struct board_info {
120 /* External PHY reset GPIO */
121 unsigned int ephy_reset_gpio;
122
123 - /* External PHY reset GPIO flags from gpio.h */
124 - unsigned long ephy_reset_gpio_flags;
125 + /* External PHY reset GPIO flags from gpio/machine.h */
126 + enum gpio_lookup_flags ephy_reset_gpio_flags;
127
128 /* fallback sprom config */
129 struct fallback_sprom_data fallback_sprom;