aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm63xx/patches-4.9/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch
diff options
context:
space:
mode:
authorJonas Gorski <jonas.gorski@gmail.com>2018-01-13 13:18:10 +0100
committerJonas Gorski <jonas.gorski@gmail.com>2018-02-11 23:15:05 +0100
commitb0c5e8b9274188bf3bb238e013e324542ee747c4 (patch)
tree4cd32d3be6ef96eaa069d2e6cd52b625da07def1 /target/linux/brcm63xx/patches-4.9/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch
parenta27d59bb427466311fe7e69da3f0f53be18237aa (diff)
downloadupstream-b0c5e8b9274188bf3bb238e013e324542ee747c4.tar.gz
upstream-b0c5e8b9274188bf3bb238e013e324542ee747c4.tar.bz2
upstream-b0c5e8b9274188bf3bb238e013e324542ee747c4.zip
brcm63xx: add kernel 4.9 support
Add support for kernel 4.9 based on the more upstream comformant partition defintions. Increases compressed kernel size by ~95k compared to 4.4. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Diffstat (limited to 'target/linux/brcm63xx/patches-4.9/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch')
-rw-r--r--target/linux/brcm63xx/patches-4.9/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch178
1 files changed, 178 insertions, 0 deletions
diff --git a/target/linux/brcm63xx/patches-4.9/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch b/target/linux/brcm63xx/patches-4.9/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch
new file mode 100644
index 0000000000..2eaf0b6b5d
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.9/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch
@@ -0,0 +1,178 @@
+From dbe94a8daaa63ef81b7414f2a17bca8e36dd6daa Mon Sep 17 00:00:00 2001
+From: Jonas Gorski <jogo@openwrt.org>
+Date: Fri, 20 Feb 2015 19:55:32 +0100
+Subject: [PATCH 1/6] gpio: add a simple GPIO driver for bcm63xx
+
+
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ drivers/gpio/Kconfig | 8 +++
+ drivers/gpio/Makefile | 1 +
+ drivers/gpio/gpio-bcm63xx.c | 135 +++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 131 insertions(+)
+ create mode 100644 drivers/gpio/gpio-bcm63xx.c
+
+--- a/drivers/gpio/Kconfig
++++ b/drivers/gpio/Kconfig
+@@ -134,6 +134,13 @@ config GPIO_BCM_KONA
+ help
+ Turn on GPIO support for Broadcom "Kona" chips.
+
++config GPIO_BCM63XX
++ bool "Broadcom BCM63XX GPIO"
++ depends on MIPS || COMPILE_TEST
++ select GPIO_GENERIC
++ help
++ Turn on GPIO support for Broadcom BCM63XX xDSL chips.
++
+ config GPIO_BRCMSTB
+ tristate "BRCMSTB GPIO support"
+ default y if (ARCH_BRCMSTB || BMIPS_GENERIC)
+--- a/drivers/gpio/Makefile
++++ b/drivers/gpio/Makefile
+@@ -31,6 +31,7 @@ obj-$(CONFIG_GPIO_ATH79) += gpio-ath79.o
+ obj-$(CONFIG_GPIO_ASPEED) += gpio-aspeed.o
+ obj-$(CONFIG_GPIO_AXP209) += gpio-axp209.o
+ obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o
++obj-$(CONFIG_GPIO_BCM63XX) += gpio-bcm63xx.o
+ obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o
+ obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o
+ obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o
+--- /dev/null
++++ b/drivers/gpio/gpio-bcm63xx.c
+@@ -0,0 +1,135 @@
++/*
++ * Driver for BCM63XX memory-mapped GPIO controllers, based on
++ * Generic driver for memory-mapped GPIO controllers.
++ *
++ * Copyright 2008 MontaVista Software, Inc.
++ * Copyright 2008,2010 Anton Vorontsov <cbouatmailru@gmail.com>
++ * Copyright 2015 Jonas Gorski <jogo@openwrt.org>
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License as published by the
++ * Free Software Foundation; either version 2 of the License, or (at your
++ * option) any later version.
++ */
++
++#include <linux/init.h>
++#include <linux/err.h>
++#include <linux/bug.h>
++#include <linux/kernel.h>
++#include <linux/module.h>
++#include <linux/spinlock.h>
++#include <linux/compiler.h>
++#include <linux/types.h>
++#include <linux/errno.h>
++#include <linux/log2.h>
++#include <linux/ioport.h>
++#include <linux/io.h>
++#include <linux/gpio.h>
++#include <linux/gpio/driver.h>
++#include <linux/slab.h>
++#include <linux/platform_device.h>
++#include <linux/mod_devicetable.h>
++#include <linux/of.h>
++#include <linux/of_irq.h>
++#include <linux/of_gpio.h>
++
++static int bcm63xx_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
++{
++ char irq_name[7]; /* "gpioXX" */
++
++ sprintf(irq_name, "gpio%d", gpio);
++ return of_irq_get_byname(chip->of_node, irq_name);
++}
++
++static int bcm63xx_gpio_probe(struct platform_device *pdev)
++{
++ struct device *dev = &pdev->dev;
++ struct resource *dat_r, *dirout_r;
++ void __iomem *dat;
++ void __iomem *dirout;
++ unsigned long sz;
++ int err;
++ struct gpio_chip *gc;
++ struct bgpio_pdata *pdata = dev_get_platdata(dev);
++
++ dirout_r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
++ dat_r = platform_get_resource(pdev, IORESOURCE_MEM, 1);
++ if (!dat_r || !dirout_r)
++ return -EINVAL;
++
++ if (resource_size(dat_r) != resource_size(dirout_r))
++ return -EINVAL;
++
++ sz = resource_size(dat_r);
++
++ dat = devm_ioremap_resource(dev, dat_r);
++ if (IS_ERR(dat))
++ return PTR_ERR(dat);
++
++ dirout = devm_ioremap_resource(dev, dirout_r);
++ if (IS_ERR(dirout))
++ return PTR_ERR(dirout);
++
++ gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
++ if (!gc)
++ return -ENOMEM;
++
++ err = bgpio_init(gc, dev, sz, dat, NULL, NULL, dirout, NULL,
++ BGPIOF_BIG_ENDIAN_BYTE_ORDER);
++ if (err)
++ return err;
++
++ platform_set_drvdata(pdev, gc);
++
++ if (dev->of_node) {
++ int id = of_alias_get_id(dev->of_node, "gpio");
++ u32 ngpios;
++
++ if (id >= 0)
++ gc->label = devm_kasprintf(dev, GFP_KERNEL,
++ "bcm63xx-gpio.%d", id);
++
++ if (!of_property_read_u32(dev->of_node, "ngpios", &ngpios))
++ gc->ngpio = ngpios;
++
++ if (of_get_property(dev->of_node, "interrupt-names", NULL))
++ gc->to_irq = bcm63xx_gpio_to_irq;
++
++ } else if (pdata) {
++ gc->base = pdata->base;
++ if (pdata->ngpio > 0)
++ gc->ngpio = pdata->ngpio;
++ }
++
++ return gpiochip_add(gc);
++}
++
++static int bcm63xx_gpio_remove(struct platform_device *pdev)
++{
++ struct gpio_chip *gc = platform_get_drvdata(pdev);
++
++ gpiochip_remove(gc);
++ return 0;
++}
++
++#ifdef CONFIG_OF
++static struct of_device_id bcm63xx_gpio_of_match[] = {
++ { .compatible = "brcm,bcm6345-gpio" },
++ { },
++};
++#endif
++
++static struct platform_driver bcm63xx_gpio_driver = {
++ .probe = bcm63xx_gpio_probe,
++ .remove = bcm63xx_gpio_remove,
++ .driver = {
++ .name = "bcm63xx-gpio",
++ .of_match_table = of_match_ptr(bcm63xx_gpio_of_match),
++ },
++};
++
++module_platform_driver(bcm63xx_gpio_driver);
++
++MODULE_DESCRIPTION("Driver for BCM63XX memory-mapped GPIO controllers");
++MODULE_AUTHOR("Jonas Gorski <jogo@openwrt.org>");
++MODULE_LICENSE("GPL");