Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3151416imm; Sun, 29 Jul 2018 11:28:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfItuNktDg12Ejk0AHVi/sGTFtcD9QI8hPU4ynUtNdNYBqmaQgnzaPvqHA09OzZW8jqjMQZ X-Received: by 2002:a63:5c7:: with SMTP id 190-v6mr13274396pgf.385.1532888892748; Sun, 29 Jul 2018 11:28:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532888892; cv=none; d=google.com; s=arc-20160816; b=mnZR9iXP56uoPuGeKONc7WPLNvTkomwNbnfMlOyAHgi22XOjxjQ0badI3Hr20ZmVnY O34GJ8IwOVEZHHsIf3E2tx8WVFLJijX2ma7xnhFJWR3/W1cZePZAuduvQEqKHLXKTFcl 7z6UR8TMLfOKvumONh9Rvg+9DnbCK31zWop9vhR/3L47oONW7VZvYURuqDsEyp1Pl6pM ZTZGq1td1WTfaWAuDfhiNv2fkfu6CVUtl02+DeTytkf/EQJl5G2UBpJqt3fZLQuDzxyL l0kAF8O7uFrA7liHCmN/UavX+0zu2tGYYcQjsMeST7VpBXrXt2ZRpr6Sf5MjjoNRhERB Yd3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=vgRocl3UYCG8ifLkM3KBUizc2bW7OelkJnbxNkdPElU=; b=UTbMDR7KlPk3l1/aF6r4omE7a+zAkOIT/sMNuVWwfuryTIuG2M+1uxBzFPQx3tZMvY P81OxR0rdu7Cyzvor1NzkhjP5U/X4GOns52HudTg9/boyIERDCn9C1phXgUWf4NovgTl 4N3Kxl3OCvvu0VPWX8BTSxxUnErzEXeOyryljupJj2d59CSjAxf/O7XbZJ4Ztk6y6z/2 CDc5rLlfjp2g3iShoV4ZeS61d8DjI0U5KRjeMnsLfZDldA03kgbLFI7+gmxrc69xrHOh fo/02ufIbHLnLIX8rit3Z+m0wpxIOzTPwCuOQJAnniyF6VlEWOguYTcFElWspXDoRFxp JUCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eMj1yHR3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13-v6si8135514pgr.229.2018.07.29.11.27.58; Sun, 29 Jul 2018 11:28:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eMj1yHR3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728705AbeG2T6A (ORCPT + 99 others); Sun, 29 Jul 2018 15:58:00 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44790 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeG2T57 (ORCPT ); Sun, 29 Jul 2018 15:57:59 -0400 Received: by mail-wr1-f68.google.com with SMTP id r16-v6so10318441wrt.11; Sun, 29 Jul 2018 11:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vgRocl3UYCG8ifLkM3KBUizc2bW7OelkJnbxNkdPElU=; b=eMj1yHR3VLTBqjHtI+3p9QVEAmkmo8/kAKVPmVq3/qmtLkITqqGfbr1DfLxlgBLaz6 eMS7gXZXXhLZ+qWa9fKljxtD1ApekepofrUlQeOOOO3y3eVl+6O679OEVmqCSf8N+rAO eQRMJZJ/u6iAyN55Y5Bbrrjinu0tneuxgX++rKpFYh/CkGtF+nxYs1W4wM6/A3hf8rdW 61yTymsVwfE8g5fBhMl4XE3sBSdpEy90HOx6NOJmzLh1sXCrT2L7DTC+dx5mt2UDxe6L FS/pr1cSwTVSn3Bb5tjw5OQWllO0bycIhf4yQ3x+hM/sVorfvH/7xT3b7TLacLdKwIVi qrlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vgRocl3UYCG8ifLkM3KBUizc2bW7OelkJnbxNkdPElU=; b=tOv4oETEVK8uGIAHvgFPXjsfw+R935wYy/f7764dmb2A+Kl/MMozLt0aKvdZRKI7Dr V3XQTnO/7RLOGx2Lm5HFxTZid0auTYjoQkXbZCYjX1Sfj8J/YW4o2dLBQRXqq/lfQ29V JERT1ZPjbC7oD1iv4ITBe+7vlzP11tu5u6uGJO9iSy/4Xl781HeVsYOAgkkElXuyaBQc FquOQpl8JDQap7EUNrPINAKD+MMMQ/W466EHN+bVjD0fyJ0Gb+bnnwxgvGQHK0QRSY94 vosVkqxr8SQFZ8hspWq07+dir+EINzgjoZ/uEp+j9C02vYvGwZtSevxJLytSuNAmSZyX j+ww== X-Gm-Message-State: AOUpUlGJHyVR5oDvRnSh0dcZbUJErlelXbC56pAtk05f7r2OtGzbuc5w H3gimXMv/bFZv/r1sFae4qQzwi3H7eI= X-Received: by 2002:adf:b69c:: with SMTP id j28-v6mr14642201wre.200.1532888798483; Sun, 29 Jul 2018 11:26:38 -0700 (PDT) Received: from localhost.localdomain (p5DCFE1FB.dip0.t-ipconnect.de. [93.207.225.251]) by smtp.gmail.com with ESMTPSA id f6-v6sm8985217wrp.30.2018.07.29.11.26.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Jul 2018 11:26:37 -0700 (PDT) From: Saravanan Sekar To: manivannan.sadhasivam@linaro.org, linus.walleij@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, afaerber@suse.de, catalin.marinas@arm.com, will.deacon@arm.com Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, pn@denx.de, mp-cs@actions-semi.com, jeff.chen@actions-semi.com, thomas.liau@actions-semi.com, linux@cubietech.com, Saravanan Sekar Subject: [PATCH v2 2/5] pinctrl: actions: define pad control configurtion to SoC specific Date: Sun, 29 Jul 2018 20:25:48 +0200 Message-Id: <20180729182551.19383-3-sravanhome@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180729182551.19383-1-sravanhome@gmail.com> References: <20180729182551.19383-1-sravanhome@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pad control for s900 and s700 are differs in number of pull control configuraions s900 has 4 pull controls - high impedence, pull up, pull down, repeater s700, s500 has 2 pull controls - pull up and pull down so pad control configuration has to SoC specific, moved out from pinctrl common to s700, s900 specific. Signed-off-by: Parthiban Nallathambi Signed-off-by: Saravanan Sekar --- drivers/pinctrl/actions/pinctrl-owl.c | 64 ++++--------------------- drivers/pinctrl/actions/pinctrl-owl.h | 6 +++ drivers/pinctrl/actions/pinctrl-s900.c | 66 +++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 57 deletions(-) diff --git a/drivers/pinctrl/actions/pinctrl-owl.c b/drivers/pinctrl/actions/pinctrl-owl.c index 4fa9cc377b3b..004bdc66e158 100644 --- a/drivers/pinctrl/actions/pinctrl-owl.c +++ b/drivers/pinctrl/actions/pinctrl-owl.c @@ -246,60 +246,6 @@ static int owl_pad_pinconf_reg(const struct owl_padinfo *info, return 0; } -static int owl_pad_pinconf_arg2val(const struct owl_padinfo *info, - unsigned int param, - u32 *arg) -{ - switch (param) { - case PIN_CONFIG_BIAS_BUS_HOLD: - *arg = OWL_PINCONF_PULL_HOLD; - break; - case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: - *arg = OWL_PINCONF_PULL_HIZ; - break; - case PIN_CONFIG_BIAS_PULL_DOWN: - *arg = OWL_PINCONF_PULL_DOWN; - break; - case PIN_CONFIG_BIAS_PULL_UP: - *arg = OWL_PINCONF_PULL_UP; - break; - case PIN_CONFIG_INPUT_SCHMITT_ENABLE: - *arg = (*arg >= 1 ? 1 : 0); - break; - default: - return -ENOTSUPP; - } - - return 0; -} - -static int owl_pad_pinconf_val2arg(const struct owl_padinfo *padinfo, - unsigned int param, - u32 *arg) -{ - switch (param) { - case PIN_CONFIG_BIAS_BUS_HOLD: - *arg = *arg == OWL_PINCONF_PULL_HOLD; - break; - case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: - *arg = *arg == OWL_PINCONF_PULL_HIZ; - break; - case PIN_CONFIG_BIAS_PULL_DOWN: - *arg = *arg == OWL_PINCONF_PULL_DOWN; - break; - case PIN_CONFIG_BIAS_PULL_UP: - *arg = *arg == OWL_PINCONF_PULL_UP; - break; - case PIN_CONFIG_INPUT_SCHMITT_ENABLE: - *arg = *arg == 1; - break; - default: - return -ENOTSUPP; - } - - return 0; -} - static int owl_pin_config_get(struct pinctrl_dev *pctrldev, unsigned int pin, unsigned long *config) @@ -318,7 +264,10 @@ static int owl_pin_config_get(struct pinctrl_dev *pctrldev, arg = owl_read_field(pctrl, reg, bit, width); - ret = owl_pad_pinconf_val2arg(info, param, &arg); + if (!pctrl->soc->padctl_val2arg) + return -ENOTSUPP; + + ret = pctrl->soc->padctl_val2arg(info, param, &arg); if (ret) return ret; @@ -349,7 +298,10 @@ static int owl_pin_config_set(struct pinctrl_dev *pctrldev, if (ret) return ret; - ret = owl_pad_pinconf_arg2val(info, param, &arg); + if (!pctrl->soc->padctl_arg2val) + return -ENOTSUPP; + + ret = pctrl->soc->padctl_arg2val(info, param, &arg); if (ret) return ret; diff --git a/drivers/pinctrl/actions/pinctrl-owl.h b/drivers/pinctrl/actions/pinctrl-owl.h index a7bcacad11d5..dae2e8363fd5 100644 --- a/drivers/pinctrl/actions/pinctrl-owl.h +++ b/drivers/pinctrl/actions/pinctrl-owl.h @@ -298,6 +298,12 @@ struct owl_pinctrl_soc_data { unsigned int ngpios; const struct owl_gpio_port *ports; unsigned int nports; + int (*padctl_val2arg)(const struct owl_padinfo *padinfo, + unsigned int param, + u32 *arg); + int (*padctl_arg2val)(const struct owl_padinfo *info, + unsigned int param, + u32 *arg); }; int owl_pinctrl_probe(struct platform_device *pdev, diff --git a/drivers/pinctrl/actions/pinctrl-s900.c b/drivers/pinctrl/actions/pinctrl-s900.c index 0597009d8369..2e19fecbe5e9 100644 --- a/drivers/pinctrl/actions/pinctrl-s900.c +++ b/drivers/pinctrl/actions/pinctrl-s900.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "pinctrl-owl.h" /* Pinctrl registers offset */ @@ -1717,6 +1718,67 @@ static const struct owl_gpio_port s900_gpio_ports[] = { OWL_GPIO_PORT(F, 0x00F0, 8, 0x0, 0x4, 0x8, 0x460, 0x140, 0x144, 0x178, 0) }; +enum owl_pinconf_pull { + OWL_PINCONF_PULL_HIZ, + OWL_PINCONF_PULL_DOWN, + OWL_PINCONF_PULL_UP, + OWL_PINCONF_PULL_HOLD, +}; + +static int s900_pad_pinconf_arg2val(const struct owl_padinfo *info, + unsigned int param, + u32 *arg) +{ + switch (param) { + case PIN_CONFIG_BIAS_BUS_HOLD: + *arg = OWL_PINCONF_PULL_HOLD; + break; + case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: + *arg = OWL_PINCONF_PULL_HIZ; + break; + case PIN_CONFIG_BIAS_PULL_DOWN: + *arg = OWL_PINCONF_PULL_DOWN; + break; + case PIN_CONFIG_BIAS_PULL_UP: + *arg = OWL_PINCONF_PULL_UP; + break; + case PIN_CONFIG_INPUT_SCHMITT_ENABLE: + *arg = (*arg >= 1 ? 1 : 0); + break; + default: + return -ENOTSUPP; + } + + return 0; +} + +static int s900_pad_pinconf_val2arg(const struct owl_padinfo *padinfo, + unsigned int param, + u32 *arg) +{ + switch (param) { + case PIN_CONFIG_BIAS_BUS_HOLD: + *arg = *arg == OWL_PINCONF_PULL_HOLD; + break; + case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: + *arg = *arg == OWL_PINCONF_PULL_HIZ; + break; + case PIN_CONFIG_BIAS_PULL_DOWN: + *arg = *arg == OWL_PINCONF_PULL_DOWN; + break; + case PIN_CONFIG_BIAS_PULL_UP: + *arg = *arg == OWL_PINCONF_PULL_UP; + break; + case PIN_CONFIG_INPUT_SCHMITT_ENABLE: + *arg = *arg == 1; + break; + default: + return -ENOTSUPP; + } + + return 0; +} + static struct owl_pinctrl_soc_data s900_pinctrl_data = { .padinfo = s900_padinfo, .pins = (const struct pinctrl_pin_desc *)s900_pads, @@ -1727,7 +1789,9 @@ static struct owl_pinctrl_soc_data s900_pinctrl_data = { .ngroups = ARRAY_SIZE(s900_groups), .ngpios = NUM_GPIOS, .ports = s900_gpio_ports, - .nports = ARRAY_SIZE(s900_gpio_ports) + .nports = ARRAY_SIZE(s900_gpio_ports), + .padctl_arg2val = s900_pad_pinconf_arg2val, + .padctl_val2arg = s900_pad_pinconf_val2arg, }; static int s900_pinctrl_probe(struct platform_device *pdev) -- 2.18.0