From patchwork Sun May 17 00:28:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 6422211 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C597EC0432 for ; Sun, 17 May 2015 00:28:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EBF4F20222 for ; Sun, 17 May 2015 00:28:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F4125200C6 for ; Sun, 17 May 2015 00:28:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751395AbbEQA2t (ORCPT ); Sat, 16 May 2015 20:28:49 -0400 Received: from ducie-dc1.codethink.co.uk ([185.25.241.215]:47205 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751293AbbEQA2t (ORCPT ); Sat, 16 May 2015 20:28:49 -0400 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id 8D275461612; Sun, 17 May 2015 01:28:47 +0100 (BST) X-Virus-Scanned: Debian amavisd-new at ducie-dc1.codethink.co.uk Received: from ducie-dc1.codethink.co.uk ([127.0.0.1]) by localhost (ducie-dc1.codethink.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 074xUbzafi7q; Sun, 17 May 2015 01:28:44 +0100 (BST) Received: from [192.168.25.61] (unknown [192.168.25.61]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPSA id 63003460BCA; Sun, 17 May 2015 01:28:44 +0100 (BST) Message-ID: <1431822523.4222.169.camel@xylophone.i.decadent.org.uk> Subject: [PATCH 2/6] pinctrl: sh-pfc: Add set_mux operation to struct sh_pfc_function From: Ben Hutchings To: Ian Molton , linux-mmc@vger.kernel.org Cc: linux-sh@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@lists.codethink.co.uk, Sergei Shtylyov , Simon Horman Date: Sun, 17 May 2015 01:28:43 +0100 In-Reply-To: <1431822459.4222.166.camel@xylophone.i.decadent.org.uk> References: <1431822459.4222.166.camel@xylophone.i.decadent.org.uk> Organization: Codethink Ltd. X-Mailer: Evolution 3.4.4-3 Mime-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some cases a change of function requires changes in more than just the GPSR/IPSR registers. In particular, changing the SDHI between 3.3V and 1.8V signalling also requires modifying IOCTRL6. Add this optional operation so that such special cases can be handled in each SoC's code. Signed-off-by: Ben Hutchings --- drivers/pinctrl/sh-pfc/pinctrl.c | 4 ++++ drivers/pinctrl/sh-pfc/sh_pfc.h | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c index 072e7c62cab7..068b1cdeddde 100644 --- a/drivers/pinctrl/sh-pfc/pinctrl.c +++ b/drivers/pinctrl/sh-pfc/pinctrl.c @@ -317,6 +317,7 @@ static int sh_pfc_func_set_mux(struct pinctrl_dev *pctldev, unsigned selector, { struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); struct sh_pfc *pfc = pmx->pfc; + const struct sh_pfc_function *func = &pfc->info->functions[selector]; const struct sh_pfc_pin_group *grp = &pfc->info->groups[group]; unsigned long flags; unsigned int i; @@ -340,6 +341,9 @@ static int sh_pfc_func_set_mux(struct pinctrl_dev *pctldev, unsigned selector, break; } + if (func->set_mux) + func->set_mux(pfc, func, grp); + done: spin_unlock_irqrestore(&pfc->lock, flags); return ret; diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h index c7508d5f6886..0ce4f5c7add8 100644 --- a/drivers/pinctrl/sh-pfc/sh_pfc.h +++ b/drivers/pinctrl/sh-pfc/sh_pfc.h @@ -28,6 +28,8 @@ enum { #define SH_PFC_PIN_CFG_PULL_DOWN (1 << 3) #define SH_PFC_PIN_CFG_NO_GPIO (1 << 31) +struct sh_pfc; + struct sh_pfc_pin { u16 pin; u16 enum_id; @@ -50,17 +52,23 @@ struct sh_pfc_pin_group { unsigned int nr_pins; }; -#define SH_PFC_FUNCTION(n) \ +#define SH_PFC_FUNCTION_SPECIAL(n, set_mux_fn) \ { \ .name = #n, \ .groups = n##_groups, \ .nr_groups = ARRAY_SIZE(n##_groups), \ + .set_mux = (set_mux_fn), \ } +#define SH_PFC_FUNCTION(n) SH_PFC_FUNCTION_SPECIAL(n, NULL) + struct sh_pfc_function { const char *name; const char * const *groups; unsigned int nr_groups; + void (*set_mux)(struct sh_pfc *pfc, + const struct sh_pfc_function *func, + const struct sh_pfc_pin_group *grp); }; struct pinmux_func {