From patchwork Wed Aug 1 10:00:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 10552019 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 C671115E9 for ; Wed, 1 Aug 2018 10:01:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B43042AD16 for ; Wed, 1 Aug 2018 10:01:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A80AB2AD49; Wed, 1 Aug 2018 10:01:03 +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_SIGNED, DKIM_VALID,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 3C5382AD16 for ; Wed, 1 Aug 2018 10:01:03 +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=33iPjSVBEsOYpNDqinnWSADQ6FsoLeQGp74YBdEkxqk=; b=Bt3LJ4uPAlkp69H/NYYH+qYF12 bfj+9ThuwpLQ6p/JrtvvKgvJL0aEyHuy/Kb3x0sEDPcOi/RXF90SAJM/SeFCJeGonGSt/1dbb79Js oxGzv6KpmatwKFI9Va6IKaji/Ydxmlwkq5Eg9P4eTRjlXfdqRBCPK+rg2NaM7azXHA9JElAdjaVf8 aUN5cvAAKF5Ve34Zsg5zmZWccff9njk8zSYILSfXL0NPAG8AXMhy66zOXVgD3MqWKQsy+yarc8IyD iwvlvqeNU6jx/jl9li17GxgZx2cKoeFQ6yVcdapL6I9yIH8Zi76eEoYcL8JqacJf5Fgwz1rNK3i7W Pwu62uOg==; 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 1fknw9-0000zi-IW; Wed, 01 Aug 2018 10:00:57 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fknvu-0000hF-TO for linux-arm-kernel@lists.infradead.org; Wed, 01 Aug 2018 10:00:46 +0000 Received: by mail-wr1-x42e.google.com with SMTP id b15-v6so19483179wrv.10 for ; Wed, 01 Aug 2018 03:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kuBO+lRjS+AQcV6hL+v/rpCD0Zo/OVQAPDSiaaqeuys=; b=1/ymuEzKs6beJ9HR6UhbZuVnV+OZt1sRGMMs+/QL1apP+tnCEk/ZlfdlHUWOuIq8eH d1MLuXyFfyxJDEL0a+tkn/e2lBZaY+Gnd6/c+J5gEuV33ybwIeIuTQfWlnp6qz/FJAbx qDeKi4Q2fDOCvQRwg2JyFW5VCqFkUgduDCE3QUPy8qAP0EPa1zMrt56bml7ZQZp4M9oa bph+fy9ff7f7DaQf47F5mTQTVbRi/5p6qSqy7Wx+RJeLTo1jtkEjvvER9Mj1I75EzKNP E4M0C5ZtGb3XQ9vEJxZyO+AHa1/HmjpqhyJ+T/lIUVxfrbaWt76q44kHGOywuGT35CpO rEYw== 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=kuBO+lRjS+AQcV6hL+v/rpCD0Zo/OVQAPDSiaaqeuys=; b=LeinQhYtC/FVlZh9Ese9hF7TDRmflTgfk2n6nxgQIlI8RZ9ex57MOWvDZ1Ioff9zsS 3jnjYHbzWdcb/phZ8OJhsZIaZVp2/mPEfnKoh/Bxp01ZP4IfrNkWdQznjBh19miI+ok1 SWxUHpcH5Ec1mBl7PK7v+nnWDXSCsUZrJ6A3wshas8fzafJ/HUmvvIs1RuAmqsRnOkvz UXa6fGjaoLnGNHao7uR0Jaej7xUflMzOQwpKRIIQDhhuDYWXf6dz4t26yDzm1HBHbodE jtnp6cnM938slK5hmEogynWwViLCbXgDdIn7CVdB2L1Jx1yd+YCQ6MDreKB1//dK6os5 raSQ== X-Gm-Message-State: AOUpUlFeNPj7ojNQ25l/JmKRhCn886qKgG5pm389gNSENCIQQKum7q/j QOU36EnxGnZKSZEHdXs1zWqoUA== X-Google-Smtp-Source: AAOMgpfmEnPY2ZnCtLVp6HPIOnf2hnSolmMk9pcPCXg7zFYN08OSREUoQbbF91hCn3NNMsk9Qk4u7Q== X-Received: by 2002:adf:b243:: with SMTP id y3-v6mr24607182wra.90.1533117630927; Wed, 01 Aug 2018 03:00:30 -0700 (PDT) Received: from bender.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id u7-v6sm6317067wmd.46.2018.08.01.03.00.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 03:00:29 -0700 (PDT) From: Neil Armstrong To: khilman@baylibre.com, linus.walleij@linaro.org Subject: [PATCH 2/5] pinctrl: meson: Add support to set direction with a secure monitor call Date: Wed, 1 Aug 2018 12:00:20 +0200 Message-Id: <1533117623-27856-3-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533117623-27856-1-git-send-email-narmstrong@baylibre.com> References: <1533117623-27856-1-git-send-email-narmstrong@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180801_030042_954496_599E80CA X-CRM114-Status: GOOD ( 19.59 ) 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: linux-amlogic@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Neil Armstrong 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 The Amlogic Meson GX and AXG SoCs needs to do a Secure Monitor call to set the TEST_N pin direction. This patch adds a "smc" boolean to the bank structure to differentiate the TEST_N bank and call the Secure Monitor in the _input/_output functions. Signed-off-by: Neil Armstrong --- drivers/pinctrl/meson/Kconfig | 1 + drivers/pinctrl/meson/pinctrl-meson.c | 31 ++++++++++++++++++++++++++----- drivers/pinctrl/meson/pinctrl-meson.h | 10 +++++++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/meson/Kconfig b/drivers/pinctrl/meson/Kconfig index c80951d..1b90470 100644 --- a/drivers/pinctrl/meson/Kconfig +++ b/drivers/pinctrl/meson/Kconfig @@ -8,6 +8,7 @@ menuconfig PINCTRL_MESON select GPIOLIB select OF_GPIO select REGMAP_MMIO + select MESON_SM if PINCTRL_MESON diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 29a458d..8e445aa 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c @@ -54,6 +54,7 @@ #include #include #include +#include #include "../core.h" #include "../pinctrl-utils.h" @@ -99,8 +100,14 @@ static void meson_calc_reg_and_bit(struct meson_bank *bank, unsigned int pin, { struct meson_reg_desc *desc = &bank->regs[reg_type]; - *reg = desc->reg * 4; - *bit = desc->bit + pin - bank->first; + /* TEST_N pin direction needs to be set using a Secure Monitor call */ + if (reg_type == REG_DIR && bank->smc) { + *reg = desc->reg; + *bit = desc->bit; + } else { + *reg = desc->reg * 4; + *bit = desc->bit + pin - bank->first; + } } static int meson_get_groups_count(struct pinctrl_dev *pcdev) @@ -342,6 +349,12 @@ static int meson_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) meson_calc_reg_and_bit(bank, gpio, REG_DIR, ®, &bit); + /* TEST_N pin direction needs to be set using a Secure Monitor call */ + if (bank->smc) { + u32 smc_ret = 0; + return meson_sm_call(reg, &smc_ret, 0, 0, 0, 0, 0); + } + return regmap_update_bits(pc->reg_gpio, reg, BIT(bit), BIT(bit)); } @@ -358,9 +371,17 @@ static int meson_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, return ret; meson_calc_reg_and_bit(bank, gpio, REG_DIR, ®, &bit); - ret = regmap_update_bits(pc->reg_gpio, reg, BIT(bit), 0); - if (ret) - return ret; + /* TEST_N pin direction needs to be set using a Secure Monitor call */ + if (bank->smc) { + u32 smc_ret = 0; + ret = meson_sm_call(reg, &smc_ret, bit, 0, 0, 0, 0); + if (ret) + return ret; + } else { + ret = regmap_update_bits(pc->reg_gpio, reg, BIT(bit), 0); + if (ret) + return ret; + } meson_calc_reg_and_bit(bank, gpio, REG_OUT, ®, &bit); return regmap_update_bits(pc->reg_gpio, reg, BIT(bit), diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h index 12a39110..d32e9a9 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.h +++ b/drivers/pinctrl/meson/pinctrl-meson.h @@ -92,6 +92,7 @@ struct meson_bank { const char *name; unsigned int first; unsigned int last; + bool smc; /* Direction needs to use a Secure Monitor call */ int irq_first; int irq_last; struct meson_reg_desc regs[NUM_REG]; @@ -131,11 +132,12 @@ struct meson_pinctrl { .num_groups = ARRAY_SIZE(fn ## _groups), \ } -#define BANK(n, f, l, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib) \ +#define __BANK(n, f, l, sm, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib) \ { \ .name = n, \ .first = f, \ .last = l, \ + .smc = sm, \ .irq_first = fi, \ .irq_last = li, \ .regs = { \ @@ -147,6 +149,12 @@ struct meson_pinctrl { }, \ } +#define BANK(n, f, l, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib) \ + __BANK(n, f, l, false, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib) + +#define BANK_SMC(n, f, l, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib) \ + __BANK(n, f, l, true, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib) + #define MESON_PIN(x) PINCTRL_PIN(x, #x) /* Common pmx functions */