From patchwork Mon May 4 08:56:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ludovic.desroches@atmel.com X-Patchwork-Id: 467521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 630B514028F for ; Mon, 4 May 2015 18:56:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752463AbbEDI4i (ORCPT ); Mon, 4 May 2015 04:56:38 -0400 Received: from eusmtp01.atmel.com ([212.144.249.242]:32765 "EHLO eusmtp01.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752380AbbEDI4d (ORCPT ); Mon, 4 May 2015 04:56:33 -0400 Received: from ibiza.corp.atmel.com (10.161.101.13) by eusmtp01.atmel.com (10.161.101.30) with Microsoft SMTP Server id 14.2.347.0; Mon, 4 May 2015 10:56:30 +0200 From: Ludovic Desroches To: , , , CC: , , Ludovic Desroches Subject: [PATCH 1/2] pinctrl: change function behavior for per pin muxing controllers Date: Mon, 4 May 2015 10:56:13 +0200 Message-ID: <1430729776-27797-2-git-send-email-ludovic.desroches@atmel.com> X-Mailer: git-send-email 2.2.0 In-Reply-To: <1430729776-27797-1-git-send-email-ludovic.desroches@atmel.com> References: <1430729776-27797-1-git-send-email-ludovic.desroches@atmel.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org When having a controller which allows per pin muxing, declaring with which groups a function can be used is a useless constraint since groups are something virtual. Signed-off-by: Ludovic Desroches --- drivers/pinctrl/pinmux.c | 58 +++++++++++++++++++++++------------------- include/linux/pinctrl/pinmux.h | 3 +++ 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index b874458..15fe3f7 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -40,7 +40,7 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev) if (!ops || !ops->get_functions_count || !ops->get_function_name || - !ops->get_function_groups || + (!ops->get_function_groups & !ops->mux_per_pin) || !ops->set_mux) { dev_err(pctldev->dev, "pinmux ops lacks necessary functions\n"); return -EINVAL; @@ -338,36 +338,42 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, } setting->data.mux.func = ret; - ret = pmxops->get_function_groups(pctldev, setting->data.mux.func, - &groups, &num_groups); - if (ret < 0) { - dev_err(pctldev->dev, "can't query groups for function %s\n", - map->data.mux.function); - return ret; - } - if (!num_groups) { - dev_err(pctldev->dev, - "function %s can't be selected on any group\n", - map->data.mux.function); - return -EINVAL; - } - if (map->data.mux.group) { - bool found = false; - group = map->data.mux.group; - for (i = 0; i < num_groups; i++) { - if (!strcmp(group, groups[i])) { - found = true; - break; - } + if (!pmxops->mux_per_pin) { + ret = pmxops->get_function_groups(pctldev, + setting->data.mux.func, + &groups, &num_groups); + if (ret < 0) { + dev_err(pctldev->dev, + "can't query groups for function %s\n", + map->data.mux.function); + return ret; } - if (!found) { + if (!num_groups) { dev_err(pctldev->dev, - "invalid group \"%s\" for function \"%s\"\n", - group, map->data.mux.function); + "function %s can't be selected on any group\n", + map->data.mux.function); return -EINVAL; } + if (map->data.mux.group) { + bool found = false; + group = map->data.mux.group; + for (i = 0; i < num_groups; i++) { + if (!strcmp(group, groups[i])) { + found = true; + break; + } + } + if (!found) { + dev_err(pctldev->dev, + "invalid group \"%s\" for function \"%s\"\n", + group, map->data.mux.function); + return -EINVAL; + } + } else { + group = groups[0]; + } } else { - group = groups[0]; + group = map->data.mux.group; } ret = pinctrl_get_group_selector(pctldev, group); diff --git a/include/linux/pinctrl/pinmux.h b/include/linux/pinctrl/pinmux.h index 511bda9..51b84eb 100644 --- a/include/linux/pinctrl/pinmux.h +++ b/include/linux/pinctrl/pinmux.h @@ -23,6 +23,8 @@ struct pinctrl_dev; /** * struct pinmux_ops - pinmux operations, to be implemented by pin controller * drivers that support pinmuxing + * @mux_per_pin: in case of per pin muxing, it removes the need to declare + * with which groups a function can be used. * @request: called by the core to see if a certain pin can be made * available for muxing. This is called by the core to acquire the pins * before selecting any actual mux setting across a function. The driver @@ -58,6 +60,7 @@ struct pinctrl_dev; * to the GPIO controllers that need pin muxing. */ struct pinmux_ops { + bool mux_per_pin; int (*request) (struct pinctrl_dev *pctldev, unsigned offset); int (*free) (struct pinctrl_dev *pctldev, unsigned offset); int (*get_functions_count) (struct pinctrl_dev *pctldev);