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: 1799731 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 3A529DFF71 for ; Mon, 26 Nov 2012 00:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753829Ab2KZARF (ORCPT ); Sun, 25 Nov 2012 19:17:05 -0500 Received: from kirsty.vergenet.net ([202.4.237.240]:59469 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753796Ab2KZARD (ORCPT ); Sun, 25 Nov 2012 19:17:03 -0500 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 Cc: Magnus Damm , Paul Mundt , Simon Horman , Laurent Pinchart 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> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.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 */