From patchwork Sat May 5 10:53:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 135075 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1089190lji; Sat, 5 May 2018 03:58:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqRXkX6a86PSy5TVAOLs8OdAJyKWoqRAK2wjNhATijEYU7mjTZDUfZdy/d49S9oQZswXMFQ X-Received: by 2002:a50:a845:: with SMTP id j63-v6mr40720927edc.210.1525517900415; Sat, 05 May 2018 03:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525517900; cv=none; d=google.com; s=arc-20160816; b=f9UpTh6fWx9ZdP4esqFLh4p+/ff+zPM5Y3TZMTVSNQD1PHlEfmvlXwGLlOTD/SRae/ 07/7Ju7la0C1+1kk3KBu99plDGU5To52mWQVbC9szQHjCgrkmZe+3EfKVZpXH86RNz4u /iMnFD6GmRN9pZxDEBO06hF5NkNFkztO4gLOBZ1AXF27hx2FlKbnCDJnwzCHY374rW9h M5zn8ydgTI1Ak4fH/JSVkjDw4BjLfYPGjrYNtYBWfNuKzYnO8emn7j6+f8mE1sIH7hjN SUZIKclaQdz/whitz6liTfCDoTKB4aBqi3rzSixsTe5e57HTTK+gqAinMNxmlU2fOJ8b gJtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=AdKS3sRGvrkyB9btTejZWGZmjuIwGJCP2JZIOfNouA0=; b=ISB2ZmoxdTBj9spLeW85YAzp7Pw0qF3HlgPXcL3B35N6z3NOB2/GClZpQ4lB5KkykB Hc/jP2TwCNnTAxOz5cGO4Ny3NEj8BX9Y1VIodXgSE5TVAnW8iFdlLeHA9dNxZl6ZEXb1 2Sf6ORiqySdxietM2Zxg9ilRnPWfgPcadwtdn4Kkg0w80T+ALTnmwUdFveJ26amoqs/Q Ic5hR65jkDc5Z2mGYMGHivXffVTps56qRjrAzfREuCXFpgdp2IFSYsHll6gfyoLndgw9 xluiu1i4oe3rJjjo/B+4NG5qYEB0kPCCVfiX+TfFw0K20Jpj8giNUczlUSu+qasdEG0B xQRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=PO1palut; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id y100-v6si3868684ede.117.2018.05.05.03.58.20; Sat, 05 May 2018 03:58:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=PO1palut; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 0E8BEC21FD8; Sat, 5 May 2018 10:56:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BCEECC21FCB; Sat, 5 May 2018 10:54:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 431B7C21E16; Sat, 5 May 2018 10:54:15 +0000 (UTC) Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lists.denx.de (Postfix) with ESMTPS id DDA1DC21F4D for ; Sat, 5 May 2018 10:54:14 +0000 (UTC) Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-08.nifty.com with ESMTP id w45As4Eu023712; Sat, 5 May 2018 19:54:06 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w45As4Eu023712 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1525517646; bh=ZxZbReuO/4I/XgBr/ULrvf25FBaZj4RreE18anifxS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PO1palutpoRw3zyVvk8gO2cvR/MGuv1Hc1Zd4SZ4uOi/2419+pKCmXAd/VUgD/ERp IYtoNC6u9cNLXTgY5EWaRCY8E7n51KIzthD5VaJjlWRaogUm519EnZVUoc38RLpMue Xe67YGAWKnWgBlIuvnMbzBadD8sLCGUML5DrVTR3gRgFYPHxmnIjEVXsdcVj89dbGD /WubrJ2lWg5pF4NQsCaCyoGOWQcqwvzYrMXyEaAjn1y04THMykdDz3kXAfdCxPLu+B HGCkLfB2ZkF38XxbagTzIInxaCy/kffZszYkJisG2C5FjGB35Y9CrCRIZ3QMCISqVb 0e3putbeU3SQg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Sat, 5 May 2018 19:53:54 +0900 Message-Id: <1525517637-17603-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525517637-17603-1-git-send-email-yamada.masahiro@socionext.com> References: <1525517637-17603-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH 4/7] pinctrl: uniphier: support per-pin configuration via DT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Currently, the UniPhier pinctrl drivers expose only the pin-group interface to device tree. Provide .get_pins_count, .get_pin_name, .pinconf_set hooks to support pin configuration via 'pins' DT property. Signed-off-by: Masahiro Yamada --- drivers/pinctrl/uniphier/pinctrl-uniphier-core.c | 37 ++++++++++++++++++++++-- drivers/pinctrl/uniphier/pinctrl-uniphier.h | 3 +- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c index ac6c82d..03103b3 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c @@ -22,6 +22,34 @@ static const char *uniphier_pinctrl_dummy_name = "_dummy"; +static int uniphier_pinctrl_get_pins_count(struct udevice *dev) +{ + struct uniphier_pinctrl_priv *priv = dev_get_priv(dev); + const struct uniphier_pinctrl_pin *pins = priv->socdata->pins; + int pins_count = priv->socdata->pins_count; + + /* + * We do not list all pins in the pin table to save memory footprint. + * Report the max pin number + 1 to fake the framework. + */ + return pins[pins_count - 1].number + 1; +} + +static const char *uniphier_pinctrl_get_pin_name(struct udevice *dev, + unsigned int selector) +{ + struct uniphier_pinctrl_priv *priv = dev_get_priv(dev); + const struct uniphier_pinctrl_pin *pins = priv->socdata->pins; + int pins_count = priv->socdata->pins_count; + int i; + + for (i = 0; i < pins_count; i++) + if (pins[i].number == selector) + return pins[i].name; + + return uniphier_pinctrl_dummy_name; +} + static int uniphier_pinctrl_get_groups_count(struct udevice *dev) { struct uniphier_pinctrl_priv *priv = dev_get_priv(dev); @@ -158,8 +186,8 @@ static int uniphier_pinconf_bias_set(struct udevice *dev, unsigned int pin, return 0; } -static int uniphier_pinconf_set_one(struct udevice *dev, unsigned int pin, - unsigned int param, unsigned int arg) +static int uniphier_pinconf_set(struct udevice *dev, unsigned int pin, + unsigned int param, unsigned int arg) { int ret; @@ -191,7 +219,7 @@ static int uniphier_pinconf_group_set(struct udevice *dev, int i, ret; for (i = 0; i < grp->num_pins; i++) { - ret = uniphier_pinconf_set_one(dev, grp->pins[i], param, arg); + ret = uniphier_pinconf_set(dev, grp->pins[i], param, arg); if (ret) return ret; } @@ -269,6 +297,8 @@ static int uniphier_pinmux_group_set(struct udevice *dev, } const struct pinctrl_ops uniphier_pinctrl_ops = { + .get_pins_count = uniphier_pinctrl_get_pins_count, + .get_pin_name = uniphier_pinctrl_get_pin_name, .get_groups_count = uniphier_pinctrl_get_groups_count, .get_group_name = uniphier_pinctrl_get_group_name, .get_functions_count = uniphier_pinmux_get_functions_count, @@ -277,6 +307,7 @@ const struct pinctrl_ops uniphier_pinctrl_ops = { #if CONFIG_IS_ENABLED(PINCONF) .pinconf_num_params = ARRAY_SIZE(uniphier_pinconf_params), .pinconf_params = uniphier_pinconf_params, + .pinconf_set = uniphier_pinconf_set, .pinconf_group_set = uniphier_pinconf_group_set, #endif .set_state = pinctrl_generic_set_state, diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier.h b/drivers/pinctrl/uniphier/pinctrl-uniphier.h index 40e5ad7..8884b08 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier.h +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier.h @@ -28,7 +28,8 @@ static inline unsigned int uniphier_pin_get_iectrl(unsigned long data) */ struct uniphier_pinctrl_pin { unsigned number; - unsigned long data; + const char *name; + unsigned int data; }; /**