summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib-of.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio/gpiolib-of.c')
-rw-r--r--drivers/gpio/gpiolib-of.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 9c9b965d7d6d..f974075ff00e 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -165,6 +165,12 @@ static void of_gpio_flags_quirks(struct device_node *np,
165 } 165 }
166 } 166 }
167 } 167 }
168
169 /* Legacy handling of stmmac's active-low PHY reset line */
170 if (IS_ENABLED(CONFIG_STMMAC_ETH) &&
171 !strcmp(propname, "snps,reset-gpio") &&
172 of_property_read_bool(np, "snps,reset-active-low"))
173 *flags |= OF_GPIO_ACTIVE_LOW;
168} 174}
169 175
170/** 176/**
@@ -262,6 +268,37 @@ static struct gpio_desc *of_find_spi_gpio(struct device *dev, const char *con_id
262} 268}
263 269
264/* 270/*
271 * The old Freescale bindings use simply "gpios" as name for the chip select
272 * lines rather than "cs-gpios" like all other SPI hardware. Account for this
273 * with a special quirk.
274 */
275static struct gpio_desc *of_find_spi_cs_gpio(struct device *dev,
276 const char *con_id,
277 unsigned int idx,
278 unsigned long *flags)
279{
280 struct device_node *np = dev->of_node;
281
282 if (!IS_ENABLED(CONFIG_SPI_MASTER))
283 return ERR_PTR(-ENOENT);
284
285 /* Allow this specifically for Freescale devices */
286 if (!of_device_is_compatible(np, "fsl,spi") &&
287 !of_device_is_compatible(np, "aeroflexgaisler,spictrl"))
288 return ERR_PTR(-ENOENT);
289 /* Allow only if asking for "cs-gpios" */
290 if (!con_id || strcmp(con_id, "cs"))
291 return ERR_PTR(-ENOENT);
292
293 /*
294 * While all other SPI controllers use "cs-gpios" the Freescale
295 * uses just "gpios" so translate to that when "cs-gpios" is
296 * requested.
297 */
298 return of_find_gpio(dev, NULL, idx, flags);
299}
300
301/*
265 * Some regulator bindings happened before we managed to establish that GPIO 302 * Some regulator bindings happened before we managed to establish that GPIO
266 * properties should be named "foo-gpios" so we have this special kludge for 303 * properties should be named "foo-gpios" so we have this special kludge for
267 * them. 304 * them.
@@ -332,6 +369,12 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
332 /* Special handling for SPI GPIOs if used */ 369 /* Special handling for SPI GPIOs if used */
333 if (IS_ERR(desc)) 370 if (IS_ERR(desc))
334 desc = of_find_spi_gpio(dev, con_id, &of_flags); 371 desc = of_find_spi_gpio(dev, con_id, &of_flags);
372 if (IS_ERR(desc)) {
373 /* This quirk looks up flags and all */
374 desc = of_find_spi_cs_gpio(dev, con_id, idx, flags);
375 if (!IS_ERR(desc))
376 return desc;
377 }
335 378
336 /* Special handling for regulator GPIOs if used */ 379 /* Special handling for regulator GPIOs if used */
337 if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) 380 if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER)