From patchwork Tue Jan 8 11:05:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13917 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 793C623E2D for ; Tue, 8 Jan 2013 11:06:16 +0000 (UTC) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id 14BF2A19405 for ; Tue, 8 Jan 2013 11:06:15 +0000 (UTC) Received: by mail-vc0-f180.google.com with SMTP id p16so233085vcq.11 for ; Tue, 08 Jan 2013 03:06:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :mime-version:content-type:x-gm-message-state; bh=nZNZshgCojcajGM6nexH4rh78PhfvpBKNm6qlnjVQok=; b=l0SXvqmykSwhvZQ89EDg26uG9F4qVoJO9d6WRi7E+X2W2hlol3Bb6Cy2Tq7xjyuqNI 8isGhoba/B+5UYVsH03NOxuJgy53v6MX8OBW5IceK/sfJVeh1h+WcYSPHYDSzzWUK3nZ aJWh9B2sKPxT2RR6OK2h5Uo4OKyUELGkrwCAbAc+Wutdv+EGKmATglDQr+U/sbtRFMSD XvZEtWrQYXbaIWWgZ1TSMoeIeM7fGqDYzTiFp9thQqZZfJrN/WFbr+MFAB0/RvxfbPgk vbakeOirNpOJ6RyL/Ljm4DFuNQ/7W1AJYbeM/bWk1NIDfz1zWP2Z+Y1FRQ/1zDOEp0MN x1hA== X-Received: by 10.58.74.196 with SMTP id w4mr1470183vev.7.1357643175514; Tue, 08 Jan 2013 03:06:15 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp104431veb; Tue, 8 Jan 2013 03:06:14 -0800 (PST) X-Received: by 10.14.219.3 with SMTP id l3mr172558409eep.5.1357643173717; Tue, 08 Jan 2013 03:06:13 -0800 (PST) Received: from eu1sys200aog115.obsmtp.com (eu1sys200aog115.obsmtp.com [207.126.144.139]) by mx.google.com with SMTP id r6si98242782eem.66.2013.01.08.03.06.03 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 03:06:13 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob115.postini.com ([207.126.147.11]) with SMTP ID DSNKUOv9m70UXxkiJFe4BBSSAROmFgBhQM9U@postini.com; Tue, 08 Jan 2013 11:06:13 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0DA2F1C8; Tue, 8 Jan 2013 11:05:55 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 89E872D2B; Tue, 8 Jan 2013 11:05:55 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id E5B75A8065; Tue, 8 Jan 2013 12:05:50 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 8 Jan 2013 12:05:54 +0100 From: Linus Walleij To: , Cc: Stephen Warren , Anmar Oueja , Gabriel Fernandez , Linus Walleij Subject: [PATCH v2] pinctrl: nomadik: Add "ste,config" property etc Date: Tue, 8 Jan 2013 12:05:50 +0100 Message-ID: <1357643150-20250-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmdI2YhLjih5sajP0sMqVGPfdMwrXoJfU81D3FeTlhFZ1xoRUTRjkV6uOUQU/73DXIJ8JSE From: Gabriel Fernandez The "ste,config" property will contain the pin config node. It will be easier to define a pin configuration and use it by reference without duplicating lines tedious. Other cleanups to the initial DT patch. This will all be squashed into the original DT submission. Signed-off-by: Gabriel Fernandez Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Moved bias definition into the pin controller in the documentation. --- .../devicetree/bindings/pinctrl/ste,nomadik.txt | 47 ++++++++++++++-------- drivers/pinctrl/pinctrl-nomadik.c | 40 ++++++++++++------ 2 files changed, 58 insertions(+), 29 deletions(-) diff --git a/Documentation/devicetree/bindings/pinctrl/ste,nomadik.txt b/Documentation/devicetree/bindings/pinctrl/ste,nomadik.txt index 8639234..9a2f3f4 100644 --- a/Documentation/devicetree/bindings/pinctrl/ste,nomadik.txt +++ b/Documentation/devicetree/bindings/pinctrl/ste,nomadik.txt @@ -26,11 +26,12 @@ Optional subnode-properties: - ste,function: A string containing the name of the function to mux to the pin or group. -- ste,input : <0/1/2/3> +- ste,config: Handle of pin configuration node (e.g. ste,config = <&slpm_in_wkup_pdis>) + +- ste,input : <0/1/2> 0: input with no pull 1: input with pull up, 2: input with pull down, - 3: input and keep last input configuration (no pull, pull up or pull down). - ste,output: <0/1/2> 0: output low, @@ -41,10 +42,11 @@ Optional subnode-properties: 0: sleep mode disable, 1: sleep mode enable. -- ste,sleep-input: <0/1/2> +- ste,sleep-input: <0/1/2/3> 0: sleep input with no pull, 1: sleep input with pull up, 2: sleep input with pull down. + 3: sleep input and keep last input configuration (no pull, pull up or pull down). - ste,sleep-output: <0/1/2> 0: sleep output low, @@ -70,14 +72,34 @@ Example board file extract: reg = <0x80157000 0x2000>; pinctrl-names = "default"; - pinctrl-0 = <&uart0_default_mode>; + + slpm_in_wkup_pdis: slpm_in_wkup_pdis { + ste,sleep = <1>; + ste,sleep-input = <3>; + ste,sleep-wakeup = <1>; + ste,sleep-pull-disable = <0>; + }; + + slpm_out_hi_wkup_pdis: slpm_out_hi_wkup_pdis { + ste,sleep = <1>; + ste,sleep-output = <1>; + ste,sleep-wakeup = <1>; + ste,sleep-pull-disable = <0>; + }; + + slpm_out_wkup_pdis: slpm_out_wkup_pdis { + ste,sleep = <1>; + ste,sleep-output = <2>; + ste,sleep-wakeup = <1>; + ste,sleep-pull-disable = <0>; + }; uart0 { uart0_default_mux: uart0_mux { u0_default_mux { ste,function = "u0"; ste,pins = "u0_a_1"; - }; + }; }; uart0_default_mode: uart0_default { uart0_default_cfg1 { @@ -93,24 +115,15 @@ Example board file extract: uart0_sleep_mode: uart0_sleep { uart0_sleep_cfg1 { ste,pins = "GPIO0", "GPIO2"; - ste,sleep = <0>; - ste,sleep-input = <0>; - ste,sleep-wakeup = <1>; - ste,sleep-pull-disable = <0>; + ste,config = <&slpm_in_wkup_pdis>; }; uart0_sleep_cfg2 { ste,pins = "GPIO1"; - ste,sleep = <0>; - ste,sleep-output = <1>; - ste,sleep-wakeup = <1>; - ste,sleep-pull-disable = <0>; + ste,config = <&slpm_out_hi_wkup_pdis>; }; uart0_sleep_cfg3 { ste,pins = "GPIO3"; - ste,sleep = <0>; - ste,sleep-output = <2>; - ste,sleep-wakeup = <1>; - ste,sleep-pull-disable = <0>; + ste,config = <&slpm_out_wkup_pdis>; }; }; }; diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c index 451c1ab..314bcbe 100644 --- a/drivers/pinctrl/pinctrl-nomadik.c +++ b/drivers/pinctrl/pinctrl-nomadik.c @@ -1659,36 +1659,52 @@ static const char *nmk_find_pin_name(struct pinctrl_dev *pctldev, const char *pi return NULL; } +static bool nmk_pinctrl_dt_get_config(struct device_node *np, + unsigned long *configs) +{ + bool has_config = 0; + unsigned long cfg = 0; + int i, val, ret; + + for (i = 0; i < ARRAY_SIZE(nmk_cfg_params); i++) { + ret = of_property_read_u32(np, + nmk_cfg_params[i].property, &val); + if (ret != -EINVAL) { + if (nmk_dt_pin_config(i, val, &cfg) == 0) { + *configs |= cfg; + has_config = 1; + } + } + } + + return has_config; +} + int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev, struct device_node *np, struct pinctrl_map **map, unsigned *reserved_maps, unsigned *num_maps) { - int ret, i; + int ret; const char *function = NULL; unsigned long configs = 0; bool has_config = 0; unsigned reserve = 0; struct property *prop; const char *group, *gpio_name; + struct device_node *np_config; ret = of_property_read_string(np, "ste,function", &function); if (ret >= 0) reserve = 1; - for (i = 0; i < ARRAY_SIZE(nmk_cfg_params); i++) { - unsigned long cfg = 0; - int val; + has_config = nmk_pinctrl_dt_get_config(np, &configs); + + np_config = of_parse_phandle(np, "ste,config", 0); + if (np_config) + has_config |= nmk_pinctrl_dt_get_config(np_config, &configs); - ret = of_property_read_u32(np, nmk_cfg_params[i].property, &val); - if (ret != -EINVAL) { - if (nmk_dt_pin_config(i, val, &cfg) == 0) { - configs |= cfg; - has_config = 1; - } - } - } ret = of_property_count_strings(np, "ste,pins"); if (ret < 0) goto exit;