summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-03-07 14:23:37 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-07 14:23:37 +0100
commit8f397a4b163f6ee149837f0ab0dfd4081a720010 (patch)
treedd8f34d7eb3dace62842e575b7b3a306f9b204b8 /drivers
parentce9cbae133c84c147bc6823f07c0b55bf4012837 (diff)
parent9fd32f5a4e8d25fb8985fec86bc03f3743820f0e (diff)
downloadbarebox-8f397a4b163f6ee149837f0ab0dfd4081a720010.tar.gz
Merge branch 'for-next/rpi'
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/Kconfig4
-rw-r--r--drivers/gpio/Makefile1
-rw-r--r--drivers/mci/mci-bcm2835.c5
-rw-r--r--drivers/pinctrl/Kconfig10
-rw-r--r--drivers/pinctrl/Makefile1
-rw-r--r--drivers/pinctrl/pinctrl-bcm2835.c (renamed from drivers/gpio/gpio-bcm2835.c)52
-rw-r--r--drivers/watchdog/bcm2835_wdt.c5
7 files changed, 71 insertions, 7 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index ed93e86..c535904 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -21,10 +21,6 @@ config GPIO_74164
shift registers. This driver can be used to provide access
to more gpio outputs.
-config GPIO_BCM283X
- bool "GPIO support for BCM283X"
- depends on ARCH_BCM283X
-
config GPIO_CLPS711X
bool "GPIO support for CLPS711X"
depends on ARCH_CLPS711X
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index f5ed876..52280f0 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -2,7 +2,6 @@ obj-$(CONFIG_GPIOLIB) += gpiolib.o
obj-$(CONFIG_GPIO_74164) += gpio-74164.o
obj-$(CONFIG_MACH_MIPS_ATH79) += gpio-ath79.o
-obj-$(CONFIG_GPIO_BCM283X) += gpio-bcm2835.o
obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o
obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o
obj-$(CONFIG_GPIO_DIGIC) += gpio-digic.o
diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
index 9438e66..2ed1251 100644
--- a/drivers/mci/mci-bcm2835.c
+++ b/drivers/mci/mci-bcm2835.c
@@ -506,6 +506,9 @@ static int bcm2835_mci_probe(struct device_d *hw_dev)
host->mci.hw_dev = hw_dev;
host->hw_dev = hw_dev;
host->max_clock = clk_get_rate(clk);
+
+ mci_of_parse(&host->mci);
+
iores = dev_request_mem_resource(hw_dev, 0);
if (IS_ERR(iores)) {
dev_err(host->hw_dev, "Failed request mem region, aborting...\n");
@@ -561,4 +564,4 @@ static int bcm2835_mci_add(void)
{
return platform_driver_register(&bcm2835_mci_driver);
}
-coredevice_initcall(bcm2835_mci_add);
+device_initcall(bcm2835_mci_add);
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 12fff4f..45c3b35 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -1,3 +1,5 @@
+menu "Pin controllers"
+
config PINCTRL
bool "Pin controller core support"
default y if OFDEVICE
@@ -15,6 +17,12 @@ config PINCTRL_AT91
help
The pinmux controller found on AT91 SoCs.
+config PINCTRL_BCM283X
+ bool "GPIO and pinmux support for BCM283X"
+ depends on ARCH_BCM283X
+ help
+ The pinmux controller on BCM2835
+
config PINCTRL_IMX_IOMUX_V1
bool
help
@@ -83,3 +91,5 @@ config PINCTRL_VF610
help
Pinmux controller found on Vybrid VF610 family of SoCs
endif
+
+endmenu
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index 9450dbb..35b2d47 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -1,5 +1,6 @@
obj-$(CONFIG_PINCTRL) += pinctrl.o
obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o
+obj-$(CONFIG_PINCTRL_BCM283X) += pinctrl-bcm2835.o
obj-$(CONFIG_PINCTRL_IMX_IOMUX_V1) += imx-iomux-v1.o
obj-$(CONFIG_PINCTRL_IMX_IOMUX_V2) += imx-iomux-v2.o
obj-$(CONFIG_PINCTRL_IMX_IOMUX_V3) += imx-iomux-v3.o
diff --git a/drivers/gpio/gpio-bcm2835.c b/drivers/pinctrl/pinctrl-bcm2835.c
index 1802ab7..5fd5740 100644
--- a/drivers/gpio/gpio-bcm2835.c
+++ b/drivers/pinctrl/pinctrl-bcm2835.c
@@ -1,7 +1,9 @@
/*
* Author: Carlo Caione <carlo@carlocaione.org>
*
- * Based on linux/arch/arm/mach-bcm2708/bcm2708_gpio.c
+ * GPIO code based on linux/arch/arm/mach-bcm2708/bcm2708_gpio.c
+ *
+ * pinctrl part added by Tomaz Solc <tomaz.solc@tablix.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -21,6 +23,7 @@
#include <io.h>
#include <gpio.h>
#include <init.h>
+#include <pinctrl.h>
#define GPIOFSEL(x) (0x00+(x)*4)
#define GPIOSET(x) (0x1c+(x)*4)
@@ -46,6 +49,7 @@ enum {
struct bcm2835_gpio_chip {
void __iomem *base;
struct gpio_chip chip;
+ struct pinctrl_device pctl;
};
static int bcm2835_set_function(struct gpio_chip *chip, unsigned gpio, int function)
@@ -110,6 +114,39 @@ static struct gpio_ops bcm2835_gpio_ops = {
.set = bcm2835_gpio_set_value,
};
+static int bcm2835_pinctrl_set_state(struct pinctrl_device *pdev, struct device_node *np)
+{
+ const __be32 *list;
+ u32 function;
+ int i, size;
+
+ list = of_get_property(np, "brcm,pins", &size);
+ if (!list) {
+ return -EINVAL;
+ }
+
+ size /= sizeof(*list);
+
+ if (of_property_read_u32(np, "brcm,function", &function)) {
+ return -EINVAL;
+ }
+
+ for (i = 0; i < size; i++) {
+ int pin = be32_to_cpu(list[i]);
+ struct bcm2835_gpio_chip *bcmgpio = container_of(pdev, struct bcm2835_gpio_chip, pctl);
+
+ dev_dbg(pdev->dev, "set_state pin %d to function %d\n", pin, function);
+
+ bcm2835_set_function(&bcmgpio->chip, pin, function);
+ }
+
+ return 0;
+}
+
+static struct pinctrl_ops bcm2835_pinctrl_ops = {
+ .set_state = bcm2835_pinctrl_set_state,
+};
+
static int bcm2835_gpio_probe(struct device_d *dev)
{
struct resource *iores;
@@ -125,14 +162,27 @@ static int bcm2835_gpio_probe(struct device_d *dev)
bcmgpio->chip.base = 0;
bcmgpio->chip.ngpio = 54;
bcmgpio->chip.dev = dev;
+ bcmgpio->pctl.ops = &bcm2835_pinctrl_ops;
+ bcmgpio->pctl.dev = dev;
ret = gpiochip_add(&bcmgpio->chip);
if (ret) {
dev_err(dev, "couldn't add gpiochip, ret = %d\n", ret);
goto err;
}
+
dev_info(dev, "probed gpiochip%d with base %d\n", dev->id, bcmgpio->chip.base);
+ if (IS_ENABLED(CONFIG_PINCTRL)) {
+ ret = pinctrl_register(&bcmgpio->pctl);
+ if (ret) {
+ dev_err(dev, "couldn't add pinctrl, ret = %d\n", ret);
+ // don't free bcmgpio, since it's already used by gpiochip.
+ } else {
+ dev_dbg(dev, "bcm283x pinctrl registered\n");
+ }
+ }
+
return 0;
err:
diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c
index d0c51ed..781626f 100644
--- a/drivers/watchdog/bcm2835_wdt.c
+++ b/drivers/watchdog/bcm2835_wdt.c
@@ -45,6 +45,10 @@
#define SECS_TO_WDOG_TICKS(x) ((x) << 16)
+/* Largest value where SECS_TO_WDOG_TICKS doesn't overflow 20 bits
+ * (PM_WDOG_TIME_SET) */
+#define WDOG_SECS_MAX 15
+
struct bcm2835_wd {
struct watchdog wd;
void __iomem *base;
@@ -101,6 +105,7 @@ static int bcm2835_wd_probe(struct device_d *dev)
}
priv->base = IOMEM(iores->start);
priv->wd.set_timeout = bcm2835_wd_set_timeout;
+ priv->wd.timeout_max = WDOG_SECS_MAX;
priv->wd.hwdev = dev;
priv->dev = dev;