From patchwork Mon Nov 26 00:16:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 1799831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 43203DF264 for ; Mon, 26 Nov 2012 00:20:31 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TcmOL-0006Zu-Q1; Mon, 26 Nov 2012 00:17:42 +0000 Received: from kirsty.vergenet.net ([202.4.237.240]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TcmNm-0006Tp-1c for linux-arm-kernel@lists.infradead.org; Mon, 26 Nov 2012 00:17:07 +0000 Received: from ayumi.akashicho.tokyo.vergenet.net (p4024-ipbfp1903kobeminato.hyogo.ocn.ne.jp [114.172.131.24]) by kirsty.vergenet.net (Postfix) with ESMTP id E168F266CED; Mon, 26 Nov 2012 11:17:00 +1100 (EST) Received: by ayumi.akashicho.tokyo.vergenet.net (Postfix, from userid 7100) id 7CDDFEDE0B6; Mon, 26 Nov 2012 09:16:59 +0900 (JST) From: Simon Horman To: linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/7] sh: pfc: Allow device tree registration Date: Mon, 26 Nov 2012 09:16:50 +0900 Message-Id: <1353889014-17142-4-git-send-email-horms@verge.net.au> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1353889014-17142-1-git-send-email-horms@verge.net.au> References: <1353889014-17142-1-git-send-email-horms@verge.net.au> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121125_191706_722534_65D26A97 X-CRM114-Status: GOOD ( 13.29 ) X-Spam-Score: -3.3 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [202.4.237.240 listed in list.dnswl.org] -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Paul Mundt , Magnus Damm , Laurent Pinchart , Simon Horman X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This is a crude mechanism to allow the pfc driver to be registered through device tree. The mofication of this is to provide a way for pfc gpios to be looked up by device tree for devices which use pfc gpios. More specifically, the motivation is to allow the registration of the card-detect gpio for the Micro-SD SDHI slot of the KZM9G board. Cc: Paul Mundt Cc: Laurent Pinchart Signed-off-by: Simon Horman --- drivers/sh/pfc/gpio.c | 15 +++++++++++++++ include/linux/sh_pfc.h | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c index 038fa07..322b927 100644 --- a/drivers/sh/pfc/gpio.c +++ b/drivers/sh/pfc/gpio.c @@ -136,6 +136,19 @@ static void sh_pfc_gpio_setup(struct sh_pfc_chip *chip) gc->ngpio = (pfc->last_gpio - pfc->first_gpio) + 1; } +#ifdef CONFIG_OF_GPIO +static void +sh_pfc_register_gpiochip_dt(struct sh_pfc *pfc, struct gpio_chip *chip) +{ + chip->of_node = pfc->of_node; + chip->of_gpio_n_cells = pfc->of_gpio_n_cells; + chip->of_xlate = pfc->of_xlate; +} +#else +static void sh_pfc_register_gpiochip_dt(struct sh_pfc *pfc, + struct gpio_chip *chip) {} +#endif + int sh_pfc_register_gpiochip(struct sh_pfc *pfc) { struct sh_pfc_chip *chip; @@ -153,6 +166,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc) if (unlikely(ret < 0)) kfree(chip); + sh_pfc_register_gpiochip_dt(pfc, &chip->gpio_chip); + pr_info("%s handling gpio %d -> %d\n", pfc->name, pfc->first_gpio, pfc->last_gpio); diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h index c19a092..9963370 100644 --- a/include/linux/sh_pfc.h +++ b/include/linux/sh_pfc.h @@ -124,6 +124,13 @@ struct sh_pfc { struct pfc_window *window; unsigned long unlock_reg; + +#ifdef CONFIG_OF_GPIO + struct device_node *of_node; + int of_gpio_n_cells; + int (*of_xlate)(struct gpio_chip *gc, + const struct of_phandle_args *gpiospec, u32 *flags); +#endif }; /* XXX compat for now */