From patchwork Mon Sep 26 12:26:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Vogt X-Patchwork-Id: 675155 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3sjPPG0yHpz9ryZ for ; Mon, 26 Sep 2016 23:06:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 467AAA768F; Mon, 26 Sep 2016 15:05:37 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09g1iz-VGP-L; Mon, 26 Sep 2016 15:05:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 379BFA76F8; Mon, 26 Sep 2016 15:05:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CFC14A75BC for ; Mon, 26 Sep 2016 14:47:50 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pF5KHpCntUeT for ; Mon, 26 Sep 2016 14:47:50 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) by theia.denx.de (Postfix) with ESMTPS id 26D5BA758E for ; Mon, 26 Sep 2016 14:47:45 +0200 (CEST) Received: from nwb-ext-pat.microfocus.com ([10.120.13.103]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Mon, 26 Sep 2016 14:27:40 +0200 Received: from linux-lm3i.site (nwb-a10-snat.microfocus.com [10.120.13.201]) by nwb-ext-pat.microfocus.com with ESMTP (TLS encrypted); Mon, 26 Sep 2016 13:27:18 +0100 From: Fabian Vogt To: u-boot@lists.denx.de Date: Mon, 26 Sep 2016 14:26:43 +0200 Message-Id: <20160926122651.22132-2-fvogt@suse.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160926122651.22132-1-fvogt@suse.com> References: <20160926122651.22132-1-fvogt@suse.com> X-Mailman-Approved-At: Mon, 26 Sep 2016 15:04:20 +0200 Subject: [U-Boot] [PATCH 1/9] gpio: bcm2835: add device tree support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch adds device tree support for the bcm2835 GPIO driver. Signed-off-by: Fabian Vogt Reviewed-by: Simon Glass --- doc/device-tree-bindings/gpio/bcm2835-gpio.txt | 5 +++++ drivers/gpio/bcm2835_gpio.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 doc/device-tree-bindings/gpio/bcm2835-gpio.txt diff --git a/doc/device-tree-bindings/gpio/bcm2835-gpio.txt b/doc/device-tree-bindings/gpio/bcm2835-gpio.txt new file mode 100644 index 0000000..21e0610 --- /dev/null +++ b/doc/device-tree-bindings/gpio/bcm2835-gpio.txt @@ -0,0 +1,5 @@ +* Broadcom BCM283x GPIO controller + +Required properties: +- compatible: must be "brcm,bcm2835-gpio" +- reg: exactly one register range with length 0xb4 diff --git a/drivers/gpio/bcm2835_gpio.c b/drivers/gpio/bcm2835_gpio.c index 8dd7a28..cd5480e 100644 --- a/drivers/gpio/bcm2835_gpio.c +++ b/drivers/gpio/bcm2835_gpio.c @@ -10,6 +10,7 @@ #include #include #include +#include struct bcm2835_gpios { struct bcm2835_gpio_regs *reg; @@ -118,9 +119,32 @@ static int bcm2835_gpio_probe(struct udevice *dev) return 0; } +#if CONFIG_IS_ENABLED(OF_CONTROL) +static const struct udevice_id bcm2835_gpio_id[] = { + {.compatible = "brcm,bcm2835-gpio"}, + {} +}; + +static int bcm2835_gpio_ofdata_to_platdata(struct udevice *dev) +{ + struct bcm2835_gpio_platdata *plat = dev_get_platdata(dev); + fdt_addr_t addr; + + addr = dev_get_addr(dev); + if (addr == FDT_ADDR_T_NONE) + return -EINVAL; + + plat->base = addr; + return 0; +} +#endif + U_BOOT_DRIVER(gpio_bcm2835) = { .name = "gpio_bcm2835", .id = UCLASS_GPIO, + .of_match = of_match_ptr(bcm2835_gpio_id), + .ofdata_to_platdata = of_match_ptr(bcm2835_gpio_ofdata_to_platdata), + .platdata_auto_alloc_size = sizeof(struct bcm2835_gpio_platdata), .ops = &gpio_bcm2835_ops, .probe = bcm2835_gpio_probe, .flags = DM_FLAG_PRE_RELOC,