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
7 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
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(-)
16 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
17 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
18 @@ -59,7 +59,7 @@ static struct board_info __initdata boar
21 .ephy_reset_gpio = 36,
22 - .ephy_reset_gpio_flags = GPIOF_INIT_HIGH,
23 + .ephy_reset_gpio_flags = GPIO_ACTIVE_LOW,
27 --- a/arch/mips/bcm63xx/boards/board_common.c
28 +++ b/arch/mips/bcm63xx/boards/board_common.c
29 @@ -278,9 +278,10 @@ int __init board_register_devices(void)
30 platform_device_register(&bcm63xx_gpio_leds);
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);
41 /* count number of BUTTONs defined by this device */
42 while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
43 --- a/arch/mips/bcm63xx/gpio.c
44 +++ b/arch/mips/bcm63xx/gpio.c
46 * Copyright (C) Jonas Gorski <jogo@openwrt.org>
49 +#include <asm/addrspace.h>
51 #include <linux/kernel.h>
52 #include <linux/platform_device.h>
53 #include <linux/basic_mmio_gpio.h>
54 #include <linux/gpio.h>
55 +#include <linux/gpio/driver.h>
57 #include <bcm63xx_cpu.h>
58 #include <bcm63xx_gpio.h>
59 #include <bcm63xx_regs.h>
61 +/* for registering lookups; make them large enough to hold OF names */
62 +static char *gpio_chip_labels[] = {
63 + "xxxxxxxx.gpio-controller",
64 + "xxxxxxxx.gpio-controller",
67 static void __init bcm63xx_gpio_init_one(int id, int dir, int data, int ngpio)
69 struct resource res[2];
70 @@ -40,6 +49,7 @@ static void __init bcm63xx_gpio_init_one
74 + sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
75 platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res, 2,
76 &pdata, sizeof(pdata));
78 @@ -64,3 +74,25 @@ int __init bcm63xx_gpio_init(void)
83 +static struct gpiod_lookup_table ephy_reset = {
84 + .dev_id = "bcm63xx_enet_shared.0",
86 + { /* filled at runtime */ },
92 +void bcm63xx_gpio_ephy_reset(int hw_gpio, enum gpio_lookup_flags flags)
94 + if (ephy_reset.table[0].chip_label)
97 + ephy_reset.table[0].chip_label = gpio_chip_labels[hw_gpio / 32];
98 + ephy_reset.table[0].chip_hwnum = hw_gpio % 32;
99 + ephy_reset.table[0].con_id = "ephy-reset";
100 + ephy_reset.table[0].flags = flags;
102 + gpiod_add_lookup_table(&ephy_reset);
104 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
105 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
107 #define BCM63XX_GPIO_H
109 #include <linux/init.h>
110 +#include <linux/gpio/driver.h>
111 #include <bcm63xx_cpu.h>
113 int __init bcm63xx_gpio_init(void);
114 +void bcm63xx_gpio_ephy_reset(int hw_gpio, enum gpio_lookup_flags flags);
116 static inline unsigned long bcm63xx_gpio_count(void)
118 --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
119 +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
121 #include <linux/types.h>
122 #include <linux/gpio.h>
123 #include <linux/gpio_keys.h>
124 +#include <linux/gpio/driver.h>
125 #include <linux/leds.h>
126 #include <bcm63xx_dev_enet.h>
127 #include <bcm63xx_dev_usb_usbd.h>
128 @@ -58,8 +59,8 @@ struct board_info {
129 /* External PHY reset GPIO */
130 unsigned int ephy_reset_gpio;
132 - /* External PHY reset GPIO flags from gpio.h */
133 - unsigned long ephy_reset_gpio_flags;
134 + /* External PHY reset GPIO flags from gpio/machine.h */
135 + enum gpio_lookup_flags ephy_reset_gpio_flags;
137 /* fallback sprom config */
138 struct fallback_sprom_data fallback_sprom;