From patchwork Wed Mar 3 13:26:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 392209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51706C433DB for ; Wed, 3 Mar 2021 21:52:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BC6B64F1D for ; Wed, 3 Mar 2021 21:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389563AbhCCVjc (ORCPT ); Wed, 3 Mar 2021 16:39:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380351AbhCCN3m (ORCPT ); Wed, 3 Mar 2021 08:29:42 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 168C0C061226 for ; Wed, 3 Mar 2021 05:26:34 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id i14so4146900pjz.4 for ; Wed, 03 Mar 2021 05:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=maMPLvANosgrYXfleNw2KezYU5GopvAbj7n4eI0AXJo=; b=HuI0vBnp6+7MEaHvxNDPYWOGA3vmjF5IhGt2Df7AwIxK1LTd4czI6kuCC3RrAdH58r igJvaexKKCVc4fnzeM/IccWYsw4woZwOeVCHMVnFZQR/pUMDtEDWJHDnavH2Vj8MW6pg o6zxl3oaJQxunRZZrjS2/JnIO9nffA1gdbc0rGBeHlLpqnaIOWJdpa5U0vudmP9xDQCg kdxZFC62uMI0VNOGli86hsfdY6g80tPCVgsqyIpuGvqnZrEN7nAYvprjrvvIOTDMKVyU T3dx1T8UKpZXSN10/JHEKAu8XySstobPoCRtv7Nz/l5BnVe8ZxQMrVVVQMhEW6oX0wep T1Vw== 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=maMPLvANosgrYXfleNw2KezYU5GopvAbj7n4eI0AXJo=; b=eISXm8nd5aypbW+BeJClUOg2ZYos6URwwCHtvnHM8s5uOd58KjVLZp77o9mdnXaRqP 5PsFS1bc50jicBCpSNHUhyjU4BW1oIFi7BUYbKTxvhiUDLFCO1g57MIFtRND7OhR6Goh EaaBCf2xzNL+ki9Tw60qNHMbNhM/SrehlxWpTYVY+Nz929ZD8x71teb09ly+D1NNivWV RQaM+yBGK36kpBrSsux4FFZ/LfpvNIg+NLZr2whRBxvXe9qSYFngtGiNqe0moaAb+nBw wNNXLKrh3InJ9U/HbXHcvOfkvfaD/zEZRYkrknlWq/RF5fEhkvIz4go+yB+3bItU4hey oZkQ== X-Gm-Message-State: AOAM532WaHWp+UMXWDUTpm+4/CpCZlN2OYejYQr11L6mTQdgEwYKof6e 9EabLgzl0yK/Mvjjb0Z0r+AY5Q== X-Google-Smtp-Source: ABdhPJygHQyIB6VqqEcNEMhUPxgw49z8OAmZMWX5IvTxAdw8YZcNkAL0WiRetK57D3KBfItLfUYr/A== X-Received: by 2002:a17:902:464:b029:e2:ebb4:9251 with SMTP id 91-20020a1709020464b02900e2ebb49251mr2745367ple.29.1614777993667; Wed, 03 Mar 2021 05:26:33 -0800 (PST) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id y20sm24425044pfo.210.2021.03.03.05.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 05:26:33 -0800 (PST) From: Shawn Guo To: Linus Walleij Cc: Bjorn Andersson , Andy Shevchenko , linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org, Shawn Guo Subject: [PATCH v2 1/2] pinctrl: qcom: handle tiles for ACPI boot Date: Wed, 3 Mar 2021 21:26:21 +0800 Message-Id: <20210303132622.4115-2-shawn.guo@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210303132622.4115-1-shawn.guo@linaro.org> References: <20210303132622.4115-1-shawn.guo@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org It's not always the case that DT and ACPI describe hardware resource in the same schema, even for a single platform. For example, on SC8180X, DT uses the tiles schema while ACPI describe memory resource as a single region. It patches msm_pinctrl_probe() function to map tiles regions only for DT. While for ACPI, it maps the single memory resource and calculate tile bases with offsets passed from SoC data. Signed-off-by: Shawn Guo --- drivers/pinctrl/qcom/pinctrl-msm.c | 27 +++++++++++++++++++++++---- drivers/pinctrl/qcom/pinctrl-msm.h | 1 + 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index d70caecd21d2..af6ed7f43058 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -4,6 +4,7 @@ * Copyright (c) 2013, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -1396,6 +1397,7 @@ int msm_pinctrl_probe(struct platform_device *pdev, { struct msm_pinctrl *pctrl; struct resource *res; + void __iomem *base; int ret; int i; @@ -1412,7 +1414,8 @@ int msm_pinctrl_probe(struct platform_device *pdev, raw_spin_lock_init(&pctrl->lock); - if (soc_data->tiles) { + if (soc_data->tiles && !has_acpi_companion(&pdev->dev)) { + /* DT boot with multiple tile resources */ for (i = 0; i < soc_data->ntiles; i++) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, soc_data->tiles[i]); @@ -1421,10 +1424,26 @@ int msm_pinctrl_probe(struct platform_device *pdev, return PTR_ERR(pctrl->regs[i]); } } else { + /* + * DT boot with one single resource or ACPI boot (always + * one memory resource in DSDT) + */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - pctrl->regs[0] = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(pctrl->regs[0])) - return PTR_ERR(pctrl->regs[0]); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + if (soc_data->tiles) { + /* + * ACPI boot with SoC driver using titles like + * pinctrl-sc8180x. + */ + for (i = 0; i < soc_data->ntiles; i++) + pctrl->regs[i] = base + + soc_data->tile_offsets[i]; + } else { + pctrl->regs[0] = base; + } pctrl->phys_base[0] = res->start; } diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h index e31a5167c91e..91333942d53c 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.h +++ b/drivers/pinctrl/qcom/pinctrl-msm.h @@ -131,6 +131,7 @@ struct msm_pinctrl_soc_data { bool pull_no_keeper; const char *const *tiles; unsigned int ntiles; + const u32 *tile_offsets; const int *reserved_gpios; const struct msm_gpio_wakeirq_map *wakeirq_map; unsigned int nwakeirq_map; From patchwork Wed Mar 3 13:26:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 392655 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp5616057jap; Wed, 3 Mar 2021 18:00:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVoQUYJpIpcjjXekJXuEBZNJ03QEAtk6BthAosi29IFv6EJHvUeqQauqClBGy4lnBbFJCS X-Received: by 2002:a17:906:a86:: with SMTP id y6mr1675083ejf.354.1614822752292; Wed, 03 Mar 2021 17:52:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614822752; cv=none; d=google.com; s=arc-20160816; b=wlB+BrHdkmocHxpD1dyyq4lhTHDfcH6mfwg371KDtbTIocT+5YiRUT7vFUCoWVPhAu C5aQvh1C38hw1t0sQatZznfNhsPPuhZH6l+WM21BnUCENRnSO3SQLOFJcrGRxmerv9XZ CnEBV8qx+0CGLgny7VJhCqaH97+BIxPGUb4axYp2rc7+ZGx0jhAxfaGZzLuG81+dr17b eBcmd2bTwFJbp8kAjFSWNkanpJLvX+PoMndcynKQcZlqEYG4r6ZPHzoNALYacsvZLv0V rHQn/qSqhmmaFZLuJLuxJ4r7EC9vn88mwfWqVQQfrpPgScyxPadHeiN3nknSn+PBrj64 //Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=oS9tdC9Z8IoMZXBDO08ijI5tila7vbTI9+MBWjUlrPE=; b=AS1+9g4udD7EdXoJLC5wGlEkBO3xeNd4wjZxs74QoAGArlITW2Sc35xmYsCONRH6rZ W2lp/hVazDgAWFKR7u/8cfIqFhkrBC9qCfiYoruFpkoX4rS96Zbxu/8C5LZEZQmWe0tg uPSZioI5kGbvMlQ2hK6Xfo+U63h8PmZuUwvJoTM75a5RAc5hPpJFqbiJNE8pAFp8X6lM OxoB0WDqfsCRT7Vge+Th4TIVku9HPns8Dq/pux4bF57x/PP7cbLwPs2lpD1J3Yqfti9+ T9x3ObMbF7o71Ow7DkNmLQHQoNbqW2LKEHh+LmaL1OyZVGriasb0Du0zGn94iyhIGdIf PlRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jN2+VCZ8; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si16189393ejd.307.2021.03.03.17.52.32; Wed, 03 Mar 2021 17:52:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jN2+VCZ8; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389559AbhCCVj0 (ORCPT + 16 others); Wed, 3 Mar 2021 16:39:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380733AbhCCN3m (ORCPT ); Wed, 3 Mar 2021 08:29:42 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74D3BC0611C1 for ; Wed, 3 Mar 2021 05:26:36 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id a24so14012650plm.11 for ; Wed, 03 Mar 2021 05:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oS9tdC9Z8IoMZXBDO08ijI5tila7vbTI9+MBWjUlrPE=; b=jN2+VCZ8qhkcG9kSkKR4Rm+4Qxby1UZ1QSj6jnzn3clp+XpQm3YybKOgRHN2zhmrKw egKARPxkkfAfN49nQPFzu/lXBlMMmQEIfkyMLwybVDSMvJhb6omFiByUhYjkHLg8zFIT YoxI/Y+On9DuZWNHP2hn+wyB2+s+J/bEoR4kVmh7wbL71ajpWwFf+Gi50xTXFwvdnFTW rBJAkycWvNzY4HD22IVCgLSDFrgvsT+az8+5ZbRBgxP/lG6y+mQTWLaOqyg5LpRJWptw j1j08YEyePo+fHh23+LVCL7aYjPZT4ko00GWAh0nyvXRgyPK5YaSE8D1mScrO9H9SMzr BnTQ== 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=oS9tdC9Z8IoMZXBDO08ijI5tila7vbTI9+MBWjUlrPE=; b=UFUIp056QiGmzjDU7XHBvLuFQ7fY8bliu/n9dCEv9V67Aek69qT+NTsVXKVSz2wJzc 3UgNuD0kapzNSfsM8M4o55E8YOGMquhjCDlOvv0dUQvyHbqAKgLXRpsbYWWUKu6/kikI VLnIxgYy0PIJ//tAYW72JzibP5Oxu+IzOKXgxX45lBoXcSH7mmQxTSI3G+qN7JYg3KD2 lE/mJ+E6eVD70iN+p8mT2NoHW9bILg9yrBxec8nOlYLyM4YxmD9s+tLZcgvOx9RQTl2/ v0fyILEdV+Kiv39W4QhEe1H0Bf6tsnd/X63AfAlNu2Cf0/e3Rg1bc01nrDPbpcbVkQfq sF4Q== X-Gm-Message-State: AOAM530iNdaREpZlhG/7KAKeVsZcHech4KZDeZOSZNpwsw2ko0Llqz2E J5OM7pV0yxbeLFccCoScx5+9dHTok52jgQ== X-Received: by 2002:a17:902:e806:b029:e5:cb85:dc4d with SMTP id u6-20020a170902e806b02900e5cb85dc4dmr2024856plg.11.1614777996033; Wed, 03 Mar 2021 05:26:36 -0800 (PST) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id y20sm24425044pfo.210.2021.03.03.05.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 05:26:35 -0800 (PST) From: Shawn Guo To: Linus Walleij Cc: Bjorn Andersson , Andy Shevchenko , linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org, Shawn Guo Subject: [PATCH v2 2/2] pinctrl: qcom: sc8180x: add ACPI probe support Date: Wed, 3 Mar 2021 21:26:22 +0800 Message-Id: <20210303132622.4115-3-shawn.guo@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210303132622.4115-1-shawn.guo@linaro.org> References: <20210303132622.4115-1-shawn.guo@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org It adds ACPI probe support with tile offsets passed over to msm core driver via sc8180x_tile_offsets, as TLMM is described a single memory region in ACPI DSDT. Signed-off-by: Shawn Guo --- drivers/pinctrl/qcom/Kconfig | 2 +- drivers/pinctrl/qcom/pinctrl-sc8180x.c | 49 ++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig index 6853a896c476..9f0218c4f9b3 100644 --- a/drivers/pinctrl/qcom/Kconfig +++ b/drivers/pinctrl/qcom/Kconfig @@ -222,7 +222,7 @@ config PINCTRL_SC7280 config PINCTRL_SC8180X tristate "Qualcomm Technologies Inc SC8180x pin controller driver" - depends on GPIOLIB && OF + depends on GPIOLIB && (OF || ACPI) select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the diff --git a/drivers/pinctrl/qcom/pinctrl-sc8180x.c b/drivers/pinctrl/qcom/pinctrl-sc8180x.c index b765bf667574..3ec74ea37c1b 100644 --- a/drivers/pinctrl/qcom/pinctrl-sc8180x.c +++ b/drivers/pinctrl/qcom/pinctrl-sc8180x.c @@ -4,6 +4,7 @@ * Copyright (c) 2020-2021, Linaro Ltd. */ +#include #include #include #include @@ -17,6 +18,12 @@ static const char * const sc8180x_tiles[] = { "west" }; +static const u32 sc8180x_tile_offsets[] = { + 0x00d00000, + 0x00500000, + 0x00100000 +}; + enum { SOUTH, EAST, @@ -1557,6 +1564,13 @@ static const struct msm_pingroup sc8180x_groups[] = { [193] = SDC_QDSD_PINGROUP(sdc2_data, 0x4b2000, 9, 0), }; +static const int sc8180x_acpi_reserved_gpios[] = { + 0, 1, 2, 3, + 47, 48, 49, 50, + 126, 127, 128, 129, + -1 /* terminator */ +}; + static const struct msm_gpio_wakeirq_map sc8180x_pdc_map[] = { { 3, 31 }, { 5, 32 }, { 8, 33 }, { 9, 34 }, { 10, 100 }, { 12, 104 }, { 24, 37 }, { 26, 38 }, { 27, 41 }, { 28, 42 }, { 30, 39 }, { 36, 43 }, @@ -1588,13 +1602,43 @@ static struct msm_pinctrl_soc_data sc8180x_pinctrl = { .nwakeirq_map = ARRAY_SIZE(sc8180x_pdc_map), }; +static const struct msm_pinctrl_soc_data sc8180x_acpi_pinctrl = { + .tiles = sc8180x_tiles, + .ntiles = ARRAY_SIZE(sc8180x_tiles), + .tile_offsets = sc8180x_tile_offsets, + .pins = sc8180x_pins, + .npins = ARRAY_SIZE(sc8180x_pins), + .groups = sc8180x_groups, + .ngroups = ARRAY_SIZE(sc8180x_groups), + .reserved_gpios = sc8180x_acpi_reserved_gpios, + .ngpios = 191, +}; + static int sc8180x_pinctrl_probe(struct platform_device *pdev) { - return msm_pinctrl_probe(pdev, &sc8180x_pinctrl); + const struct msm_pinctrl_soc_data *soc_data; + + soc_data = device_get_match_data(&pdev->dev); + if (!soc_data) + return -EINVAL; + + return msm_pinctrl_probe(pdev, soc_data); } +static const struct acpi_device_id sc8180x_pinctrl_acpi_match[] = { + { + .id = "QCOM040D", + .driver_data = (kernel_ulong_t) &sc8180x_acpi_pinctrl, + }, + { } +}; +MODULE_DEVICE_TABLE(acpi, sc8180x_pinctrl_acpi_match); + static const struct of_device_id sc8180x_pinctrl_of_match[] = { - { .compatible = "qcom,sc8180x-tlmm", }, + { + .compatible = "qcom,sc8180x-tlmm", + .data = &sc8180x_pinctrl, + }, { }, }; MODULE_DEVICE_TABLE(of, sc8180x_pinctrl_of_match); @@ -1603,6 +1647,7 @@ static struct platform_driver sc8180x_pinctrl_driver = { .driver = { .name = "sc8180x-pinctrl", .of_match_table = sc8180x_pinctrl_of_match, + .acpi_match_table = sc8180x_pinctrl_acpi_match, }, .probe = sc8180x_pinctrl_probe, .remove = msm_pinctrl_remove,