From patchwork Tue Sep 18 07:12:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Mundt X-Patchwork-Id: 1471021 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 924A6400EC for ; Tue, 18 Sep 2012 07:12:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757192Ab2IRHMO (ORCPT ); Tue, 18 Sep 2012 03:12:14 -0400 Received: from linux-sh.org ([111.68.239.195]:48967 "EHLO linux-sh.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757029Ab2IRHMN (ORCPT ); Tue, 18 Sep 2012 03:12:13 -0400 Received: from linux-sh.org (localhost.localdomain [127.0.0.1]) by linux-sh.org (8.14.5/8.14.4) with ESMTP id q8I7C8FC028543; Tue, 18 Sep 2012 16:12:08 +0900 Received: (from pmundt@localhost) by linux-sh.org (8.14.5/8.14.4/Submit) id q8I7C8a2028542; Tue, 18 Sep 2012 16:12:08 +0900 X-Authentication-Warning: linux-sh.org: pmundt set sender to lethal@linux-sh.org using -f Date: Tue, 18 Sep 2012 16:12:08 +0900 From: Paul Mundt To: Laurent Pinchart Cc: linux-sh@vger.kernel.org Subject: Re: GPIO request failure with PCF pinmux Message-ID: <20120918071208.GL13568@linux-sh.org> References: <6045802.ynsOILKLIK@avalon> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6045802.ynsOILKLIK@avalon> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org On Fri, Sep 14, 2012 at 10:11:00PM +0200, Laurent Pinchart wrote: > Hi Paul, > > I ran into an issue with GPIO and pinmuxing in the TPU PWM driver. > > The driver needs to switch the PWM pin between GPIO and function at runtime. > To do so, I use the PWM pin GPIO (GPIO_PORT202) and the associated function > GPIO (GPIO_FN_TPU0TO2_PORT202). > > The driver configures the pin as a GPIO output when loaded with > > gpio_request_one(GPIO_PORT202, GPIOF_INIT_LOW); > > This results in a call to sh_pfc_gpio_request_enable() followed by a call to > sh_pfc_reconfig_pin() for GPIO 202. The later changes the pinmux type from > PINMUX_TYPE_GPIO (2) to PINMUX_TYPE_OUTPUT (3). > > I then call gpio_free(GPIO_PORT202) and gpio_request(GPIO_FN_TPU0TO2_PORT202) > to switch from GPIO to function. The former calls sh_pfc_gpio_disable_free:() > on GPIO 202. > > When I later call gpio_free(GPIO_FN_TPU0TO2_PORT202) and > gpio_request_one(GPIO_PORT202, GPIOF_INIT_LOW), the call to > sh_pfc_gpio_request_enable() fails with > > pinctrl-sh_pfc pinctrl: Unsupported mux type (3), bailing... > pinctrl-sh_pfc pinctrl-sh_pfc: request() failed for pin 202 > pinctrl-sh_pfc pinctrl-sh_pfc: pin-202 (pinctrl-sh_pfc) status -524 > > You're more familiar with pinmux than I am. Am I doing something wrong, or is > there a bug in the PFC pinmux implementation ? > That's a bug, the pin has been reconfigured to a different mux type which we should handle. At first glance, simply handling the input/output types ought to work ok, but we may need more work than that. How does it go with this? --- -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c index 2804eaa..c0857d5 100644 --- a/drivers/sh/pfc/pinctrl.c +++ b/drivers/sh/pfc/pinctrl.c @@ -208,6 +208,8 @@ static int sh_pfc_gpio_request_enable(struct pinctrl_dev *pctldev, break; case PINMUX_TYPE_GPIO: + case PINMUX_TYPE_INPUT: + case PINMUX_TYPE_OUTPUT: break; default: pr_err("Unsupported mux type (%d), bailing...\n", pinmux_type);