From patchwork Tue Jun 4 10:44:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 165752 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp5668314ili; Tue, 4 Jun 2019 03:45:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0YktuKj7Nz0HyLnFwwSUhVbYRasll0IFwLHwJDnUdGUborLOLgPovhMA+3ezvWiPjQide X-Received: by 2002:a17:902:8696:: with SMTP id g22mr11584836plo.249.1559645127749; Tue, 04 Jun 2019 03:45:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559645127; cv=none; d=google.com; s=arc-20160816; b=t1he3Dwd4rO1v+9FLjfFVJcNB9r6L1zDU/sXfOneLU2oPHEL8bg0cgSXF/iTabssuq d6IIrD8uqHnCNVim3WULZ1FE4nWRnNRVKWto1ijwdmIVQSMcgDfj57bejuXLYxc4MVEz Nay7Xb0UD4MyouhPJ8ivgePwqSsYcwvrBL6ZolfSBf2M/d7I7XIdBbcxzBL2+9LSGCC6 jyjFvoAWLsos7fsrnAxf5Dh147J20gf7yQb8UhdROxCtXg4eJnshNu+c2A8CRhtDr8cf 5Y7ubyh3vEJgm2Lgdit/QOyoKA/gGITj3Lx1nmeb+CmPnDZwzslRuUcH+FbXKOsF4IZe dvqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=nmWKh7PwMWUSmXx8hL09I0aV6DcSJSwvr9bLIGJ3tMI=; b=HGFA7b78fxFnAUxFVRJIN1MbRXM+8eZ2vJDmz9B1nbrDEW5GYw9C5CyfdYTyPLX7rU GARMV+9kGpDOLahQ/q5KiX3EenxQ6e3wr3Es8Tj2h5ckAeMtxHeXH+GePK9yx4wE9slh YfIZyEe/8UCobAP7TyXFEpor86U1LUvpKf5nIK01SvP9G9QiVwak2T/aJZieNQyCTS52 C35DtvSMTiiYVCbQD+DjJDGqEMy/NvhmkDN6BGO+RbS5pLtAb2uVlOA2yzXjaqYrsjRc 0LUZwlPd5s+KTLoEQwUGW7NvdpbTBkSYvFzfFa2WX/DfTIeBPgzwm+jNVro2vHJXJZxu Spow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LXWU9/Y5"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id v89si20598605pjb.14.2019.06.04.03.45.27; Tue, 04 Jun 2019 03:45:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LXWU9/Y5"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727551AbfFDKp0 (ORCPT + 30 others); Tue, 4 Jun 2019 06:45:26 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34253 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727425AbfFDKpG (ORCPT ); Tue, 4 Jun 2019 06:45:06 -0400 Received: by mail-wm1-f68.google.com with SMTP id w9so1980060wmd.1 for ; Tue, 04 Jun 2019 03:45:03 -0700 (PDT) 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=nmWKh7PwMWUSmXx8hL09I0aV6DcSJSwvr9bLIGJ3tMI=; b=LXWU9/Y5JBIKMtLWOdiKJLbb9tdjt33+6OiEvBHTA/jJhGCLzOGAQnnP00IEk2mgjn WdifvNhB5S3ZlZZ3pE4iYbadhQWIg6Ius7qy1bSWhBvMAlhsJAZJdS+CFPSuERNxNKn+ ZcCKs7/jHCkOe8iMYIR8/sz9OjaNcrk8Ed+L1GUEZ7uvYqJpq7Wph/IQTc0sel3X2fnF Gqojp9JUGPQu2bD8xZYvkFPH9j4n4DhBrwG9nhCy7PEPRUiAY52KXgO3DS5uOTWybdKF H/xieigYpZZPKJRTG/sj4lbfsgT2NaHAzfNowzeCGfGLM4pvPocT4MGXt5jDNXBpCFnO vl6A== 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=nmWKh7PwMWUSmXx8hL09I0aV6DcSJSwvr9bLIGJ3tMI=; b=FhbZN2QPE/dqGGV+h0Ug2q8BaLH9jaHPydfDqyppvMuvWUvJDtsdhgkExKsink5Yjj CAd+E0TE9tyK99Cu5rEyrwGg3tx74PqGh67J9Q/z2aObVc5WnTLP/j+5xXMuxjLYtNBM coe7myOwHn6q85QzfUqaOwS9o9uolsrV7fHXXF21aDjG26ITwb3fVAe8govinsy274sY c3u5WA0gGUOE9Z4qCkjDqU8SX1jjB0ZSZxgYUsRvopL03sfJGdGimcQQvKSXk6oIJT5n k5FRyL9cgtR3abYBUWRQVOWCEK67GeWNoIXFqqKbBIyg0o3VkXjjPEr2uWhNcqA6o06a /C/w== X-Gm-Message-State: APjAAAX4cPI6CjbdZhN8yCHjfoqDdmH9j96EQQc2p+vzMTHTI43bBKmg mtBTFO2J3R/br0j7QtLeAYl0kg== X-Received: by 2002:a1c:be12:: with SMTP id o18mr6011168wmf.124.1559645102805; Tue, 04 Jun 2019 03:45:02 -0700 (PDT) Received: from localhost.localdomain ([2.27.167.43]) by smtp.gmail.com with ESMTPSA id t140sm2718623wmt.0.2019.06.04.03.45.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 03:45:02 -0700 (PDT) From: Lee Jones To: alokc@codeaurora.org, kramasub@codeaurora.org, andy.gross@linaro.org, david.brown@linaro.org, wsa+renesas@sang-engineering.com, bjorn.andersson@linaro.org, linus.walleij@linaro.org, balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jlhugo@gmail.com, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-usb@vger.kernel.org, Lee Jones Subject: [PATCH 4/8] pinctrl: qcom: sdm845: Provide ACPI support Date: Tue, 4 Jun 2019 11:44:51 +0100 Message-Id: <20190604104455.8877-4-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604104455.8877-1-lee.jones@linaro.org> References: <20190604104455.8877-1-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch provides basic support for booting with ACPI instead of the currently supported Device Tree. When doing so there are a couple of differences which we need to taken into consideration. Firstly, the SDM850 ACPI tables omit information pertaining to the 4 reserved GPIOs on the platform. If Linux attempts to touch/ initialise any of these lines, the firmware will restart the platform. Secondly, when booting with ACPI, it is expected that the firmware will set-up things like; Regulators, Clocks, Pin Functions, etc in their ideal configuration. Thus, the possible Pin Functions available to this platform are not advertised when providing the higher GPIOD/Pinctrl APIs with pin information. Signed-off-by: Lee Jones --- drivers/pinctrl/qcom/Kconfig | 2 +- drivers/pinctrl/qcom/pinctrl-sdm845.c | 35 ++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig index 2e66ab72c10b..aafbe932424f 100644 --- a/drivers/pinctrl/qcom/Kconfig +++ b/drivers/pinctrl/qcom/Kconfig @@ -168,7 +168,7 @@ config PINCTRL_SDM660 config PINCTRL_SDM845 tristate "Qualcomm Technologies Inc SDM845 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-sdm845.c b/drivers/pinctrl/qcom/pinctrl-sdm845.c index c97f20fca5fd..7188bee3cf3e 100644 --- a/drivers/pinctrl/qcom/pinctrl-sdm845.c +++ b/drivers/pinctrl/qcom/pinctrl-sdm845.c @@ -3,6 +3,7 @@ * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -1277,6 +1278,10 @@ static const struct msm_pingroup sdm845_groups[] = { UFS_RESET(ufs_reset, 0x99f000), }; +static const int sdm845_acpi_reserved_gpios[] = { + 0, 1, 2, 3, 81, 82, 83, 84, -1 +}; + static const struct msm_pinctrl_soc_data sdm845_pinctrl = { .pins = sdm845_pins, .npins = ARRAY_SIZE(sdm845_pins), @@ -1284,14 +1289,41 @@ static const struct msm_pinctrl_soc_data sdm845_pinctrl = { .nfunctions = ARRAY_SIZE(sdm845_functions), .groups = sdm845_groups, .ngroups = ARRAY_SIZE(sdm845_groups), + .reserved_gpios = sdm845_acpi_reserved_gpios, + .ngpios = 150, +}; + +static const struct msm_pinctrl_soc_data sdm845_acpi_pinctrl = { + .pins = sdm845_pins, + .npins = ARRAY_SIZE(sdm845_pins), + .groups = sdm845_groups, + .ngroups = ARRAY_SIZE(sdm845_groups), + .reserved_gpios = sdm845_acpi_reserved_gpios, .ngpios = 150, }; static int sdm845_pinctrl_probe(struct platform_device *pdev) { - return msm_pinctrl_probe(pdev, &sdm845_pinctrl); + int ret; + + if (pdev->dev.of_node) { + ret = msm_pinctrl_probe(pdev, &sdm845_pinctrl); + } else if (ACPI_HANDLE(&pdev->dev)) { + ret = msm_pinctrl_probe(pdev, &sdm845_acpi_pinctrl); + } else { + dev_err(&pdev->dev, "DT and ACPI disabled\n"); + return -EINVAL; + } + + return ret; } +static const struct acpi_device_id sdm845_pinctrl_acpi_match[] = { + { "QCOM0217"}, + { }, +}; +MODULE_DEVICE_TABLE(acpi, sdm845_pinctrl_acpi_match); + static const struct of_device_id sdm845_pinctrl_of_match[] = { { .compatible = "qcom,sdm845-pinctrl", }, { }, @@ -1302,6 +1334,7 @@ static struct platform_driver sdm845_pinctrl_driver = { .name = "sdm845-pinctrl", .pm = &msm_pinctrl_dev_pm_ops, .of_match_table = sdm845_pinctrl_of_match, + .acpi_match_table = ACPI_PTR(sdm845_pinctrl_acpi_match), }, .probe = sdm845_pinctrl_probe, .remove = msm_pinctrl_remove, From patchwork Tue Jun 4 10:44:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 165750 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp5668048ili; Tue, 4 Jun 2019 03:45:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxgrMBvJAD86AzrIx5HxgkC0HL0UbyxjCrp08ZO6hNqbSndNkQJ5mANxoz5pZt6Ivo7jJa X-Received: by 2002:a63:4e10:: with SMTP id c16mr34046882pgb.214.1559645110873; Tue, 04 Jun 2019 03:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559645110; cv=none; d=google.com; s=arc-20160816; b=P/F05XskhrUU5e+E7U9ox0wYjbueJlrgGrsddJuprnKu8clTyzNqwJAvjw5BOrwFg8 t07sxTeuXzFUGLimk/vsA3IqFUp1YEfM1xnn4IHGmi359tg8XRY/dodmElBi1dFqxVEt 1fr3zCsEPF8ZG7tScbSohAtwlokjGu+4lcRc5zH4L2+odId2mvwZyLj/1iqMFlqjTvH3 Cg/rfpMNrj65ctxHYotW/r0Sq07+tru35B07TLZGT/OKRC+CJSh2bFyYpiGBUkajh5Ep KispXlYN8/dSieQuTtG+s9ddIJT59kXhlodRnZkBJbk80w81yx3ZKSDiwtHfdTAPoLtD hXDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=MkGVFZY1XhtlH3EXbDSeWCPiZrbaYk4zwPdOeyiIsNc=; b=oO0+8nSEKcqLQ0QvDsf3dRCfiuKoIQaLWhjvgIgOTXkp7aSrZHpIRCYIWCxY82XpjP Wnvk9tFhn2KOfHLz4CKjrSrgxv0HQHVf+/GrDpIrPcOtosjRPx4ZBsfrD4fNXEbHH/Qt t8CyvCRt8Q0TQtnhX+iUk4m1KYXyUtJ1gJew9SRUxWrK7RIoTExWE0PZNDmCSyfJJDrK W33iK0VXpBsZPQ5bNU7JyspuQXwVjGhCmi6YIeJvzaEJJxHB/tJ+21+1CgAhQKLvfJ7J K2i/mM4XqbIH6w70u0LnvLQps3hMDStKiDpwe//QNxrsUoIMnj2WfJEm3/5B5LOicHSl nMfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hljw8RsT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id v23si11740119plo.34.2019.06.04.03.45.10; Tue, 04 Jun 2019 03:45:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hljw8RsT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727509AbfFDKpK (ORCPT + 30 others); Tue, 4 Jun 2019 06:45:10 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43235 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727483AbfFDKpI (ORCPT ); Tue, 4 Jun 2019 06:45:08 -0400 Received: by mail-wr1-f66.google.com with SMTP id r18so6266056wrm.10 for ; Tue, 04 Jun 2019 03:45:07 -0700 (PDT) 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=MkGVFZY1XhtlH3EXbDSeWCPiZrbaYk4zwPdOeyiIsNc=; b=hljw8RsTFEcbuplHCj6D4tq/5nIpPFTXoAK24WDaO16R2lM4A4tkIl52AnrPf6JXw1 gT3EjpICXK9lQrDnqMtsHhdKD3i45MO0tlSwTZkOGsLnygeqnS1GEq42hVT5+HlqpNGw T+gYf8t0vIU7HSEAEdNBmet5opXalvHQjYcEdfz/km30EDtQQfXPpL8nTAL5/46rMhak gMuexpRELw1yz4AqSHcBpII97mOzlQXjdBv9q9uxJg0vY4L2Wkz4mWfTGT41kUyPjWyf oCCUVzTVMMLzv8BuVscDTyHO0HMHqetsCPsptCOLxfHbS+xv6PqNZFqqiN1cTF5Ezas/ RETA== 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=MkGVFZY1XhtlH3EXbDSeWCPiZrbaYk4zwPdOeyiIsNc=; b=l57Av9MD36F8vgWBE/ptZ9fmK2/SEdk4v1qGWsguPE0s14/jkEXAxwLDzbFvbmoyC/ /FpWUjzlEHYzdy7PiaSoKiazMC05Rqb7PoxoHtkvJrSNiaKJkn19GNnqY12D+JNydVkY k22teemySCgHVafnWg2enBPJIC74NwD1Krn8yQyO2rEkFs+HSwDva4LJ1U6h/rEHes70 i4GIodroZBYRkv8rGmeFMr8CtOdolCSdRFwYZHDhmx8oJ0/ECiRwJazT8ecEZqqXIqMh fEzfoeHd6RaDecy+2Xtd+yycDXJtkleV1Of5P4KnYMOSqu7RxAcNdzDs5wvV/cLTNToh ahjg== X-Gm-Message-State: APjAAAWhroxCPScAyycjIeuelG0ovpG/bo0JifwPCh54PcEZCeQspSYT dZ/Yft328vxsEhMpKHnvNHDngw== X-Received: by 2002:adf:a38d:: with SMTP id l13mr13613323wrb.187.1559645107190; Tue, 04 Jun 2019 03:45:07 -0700 (PDT) Received: from localhost.localdomain ([2.27.167.43]) by smtp.gmail.com with ESMTPSA id t140sm2718623wmt.0.2019.06.04.03.45.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 03:45:06 -0700 (PDT) From: Lee Jones To: alokc@codeaurora.org, kramasub@codeaurora.org, andy.gross@linaro.org, david.brown@linaro.org, wsa+renesas@sang-engineering.com, bjorn.andersson@linaro.org, linus.walleij@linaro.org, balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jlhugo@gmail.com, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-usb@vger.kernel.org, Lee Jones Subject: [PATCH 8/8] usb: dwc3: qcom: Improve error handling Date: Tue, 4 Jun 2019 11:44:55 +0100 Message-Id: <20190604104455.8877-8-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604104455.8877-1-lee.jones@linaro.org> References: <20190604104455.8877-1-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dwc3_qcom_clk_init() is called with of_count_phandle_with_args() as an argument. If of_count_phandle_with_args() returns an error, the number of clocks will be a negative value and will lead to undefined behaviour. Ensure we check for an error before attempting to blindly use the value. Signed-off-by: Lee Jones --- drivers/usb/dwc3/dwc3-qcom.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index f21fdd6cdd1a..633482926497 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -419,6 +419,9 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) if (!count || ACPI_HANDLE(dev)) return 0; + if (count < 0) + return count; + qcom->clks = devm_kcalloc(dev, qcom->num_clocks, sizeof(struct clk *), GFP_KERNEL); if (!qcom->clks)