From patchwork Sun Jul 22 16:35:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: saravanan sekar X-Patchwork-Id: 10539345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63BD31822 for ; Sun, 22 Jul 2018 16:36:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EA1D283C3 for ; Sun, 22 Jul 2018 16:36:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40B9B283CF; Sun, 22 Jul 2018 16:36:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9816D283C3 for ; Sun, 22 Jul 2018 16:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6VwYkfN9XDZxoKKxIFGafDdf4LVyrb/oXAy7JFiLtlE=; b=VCcAGsa/mVh+1+9jikEa8w0oxg 2emy+pzUscJY3KdDn+CeNW2uR2dzoSwth2E5qw+w6y8Hrgoq095O1VkrJR1WN5qZZ4qOhVVJIbo4J /k2EzXvVxbDxLJio8dVn5WccA7DrLpWUVyqHiBQI7WX/7RYNzxDFlXyKqx8fF5bapBZZ+dIREsP7s 8bKE+Nph5vC8I/WVRBs7N3jAV8D3CZ891McCmnsiY6747FtxrxSebd2jh8Jp8EfCChNIfyJUkAHZG Ezlt/1ITQjSVwV7ix0N3oQnYwM4n43aUsMPvSOTdg+tQejGj49HFHGuP943D0B1uprqSyNQ46K7ui NcWJnXRg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhHLj-00056x-Re; Sun, 22 Jul 2018 16:36:47 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhHLT-0004nv-GY for linux-arm-kernel@lists.infradead.org; Sun, 22 Jul 2018 16:36:33 +0000 Received: by mail-wr1-x441.google.com with SMTP id j5-v6so15573602wrr.8 for ; Sun, 22 Jul 2018 09:36:20 -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=V6idYKvEMTvQJEuXFzefixdyM5hS1c5SiJub9Sb6NZs=; b=NLquVh4QIjBpVQUuslsinD8+oIUL8Ye3AFCca2QC0B06+iASSAByVYfTnwrfxr1X9o vu0A4HWUeAh9zxX3TFwhgBT9XQA6bIMWNWdNY9R2yHZid/D9ssayjpYVzpf5mkdJLXP1 6KZSA3GC8BjKBiTKvk3Cf0oLCV7Aou8g5NqRzPqb6ILi30NNT6L9MIzx9pR5rQKh8/Y8 FpmYaWStbLCPJILK7RuhhcAEoSlNQA1z0BjTYmWAECcc/NdcJDT9d00E/P/YFBzwYx3H KRfJZ5Gu4nmkpmHlnKfvH3/DCV0f4WYZycX6OzVXd6jCQ513HuA8771ER7jmObjDxpxY hzTg== 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=V6idYKvEMTvQJEuXFzefixdyM5hS1c5SiJub9Sb6NZs=; b=EbGAb/Yi2UisX38LUyFvKsU6aoZ0LaCzlR337lOO1FqHMKfN0NUf8DMK/UsFZmUVmp L75JaQsSpWu56xS2fNHSjJYv2Mo0o9r1RmFuJmif0GQXDBvDjtrOEfrIz+g/O1p0F2Lo SODylHvcYtkhOLeGi+RfWHhZO6/9jx1GS27d+VCS33PwN1ojeI+fUI1z7652N2peJHdL PbE/e9wTeoF365NJxq5/ohVR8zItSUonefRaPG6CSDiqqMRPgBH+1zggWV63z22qQFqe 14NqnnR1LH6HI41/dRSSVw5oIvLSBW6aWpA5awBkgFh7Sj22Zdi24mpYK3dNrKcYbrKr bUvg== X-Gm-Message-State: AOUpUlGkAzlvU/9SRTZv2pEKAV61PGTJdhcZ9VjkkIKkLjwQkn2Ocd9W 1zQnqrZ1bOdzRDbzgg166c8= X-Google-Smtp-Source: AAOMgpe4TsiP29ysHrmcEUAR92diZu8TC6zZ+IwYxe90IvAYX4yv2gtRr/rozdue0ghe0FTfN1A2rA== X-Received: by 2002:adf:96c3:: with SMTP id u61-v6mr6285574wrb.72.1532277378904; Sun, 22 Jul 2018 09:36:18 -0700 (PDT) Received: from parthiban.fritz.box ([62.91.37.46]) by smtp.gmail.com with ESMTPSA id z8-v6sm15195653wrp.54.2018.07.22.09.36.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jul 2018 09:36:18 -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 Subject: [PATCH 2/5] pinctrl: actions: define pad control configurtion to SoC specific Date: Sun, 22 Jul 2018 18:35:58 +0200 Message-Id: <20180722163601.28346-3-sravanhome@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180722163601.28346-1-sravanhome@gmail.com> References: <20180722163601.28346-1-sravanhome@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180722_093631_548953_1D1C0891 X-CRM114-Status: GOOD ( 14.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux@cubietech.com, Saravanan Sekar , jeff.chen@actions-semi.com, linux-kernel@vger.kernel.org, thomas.liau@actions-semi.com, linux-gpio@vger.kernel.org, mp-cs@actions-semi.com, pn@denx.de, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Parthiban Nallathambi Signed-off-by: Saravanan Sekar --- drivers/pinctrl/actions/pinctrl-owl.c | 64 ++++--------------------- drivers/pinctrl/actions/pinctrl-owl.h | 13 +++-- drivers/pinctrl/actions/pinctrl-s900.c | 66 +++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 64 deletions(-) diff --git a/drivers/pinctrl/actions/pinctrl-owl.c b/drivers/pinctrl/actions/pinctrl-owl.c index b5c880b50bb3..f72da7aae4ff 100644 --- a/drivers/pinctrl/actions/pinctrl-owl.c +++ b/drivers/pinctrl/actions/pinctrl-owl.c @@ -242,60 +242,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) @@ -314,7 +260,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; @@ -345,7 +294,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 42635366e68f..669591c5400e 100644 --- a/drivers/pinctrl/actions/pinctrl-owl.h +++ b/drivers/pinctrl/actions/pinctrl-owl.h @@ -139,13 +139,6 @@ .st = &name##_st_conf, \ } -enum owl_pinconf_pull { - OWL_PINCONF_PULL_HIZ, - OWL_PINCONF_PULL_DOWN, - OWL_PINCONF_PULL_UP, - OWL_PINCONF_PULL_HOLD, -}; - enum owl_pinconf_drv { OWL_PINCONF_DRV_2MA, OWL_PINCONF_DRV_4MA, @@ -278,6 +271,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 baa2f4847418..dc7bdc1f5cde 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) }; +enum owl_pinconf_pull { + OWL_PINCONF_PULL_HIZ, + OWL_PINCONF_PULL_DOWN, + OWL_PINCONF_PULL_UP, + OWL_PINCONF_PULL_HOLD, +}; + +static int owl_pad_pinconf_s900_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_s900_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 = owl_pad_pinconf_s900_arg2val, + .padctl_val2arg = owl_pad_pinconf_s900_val2arg, }; static int s900_pinctrl_probe(struct platform_device *pdev)