From patchwork Fri Oct 13 23:10:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hotran X-Patchwork-Id: 10006089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 325CD60325 for ; Fri, 13 Oct 2017 23:10:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 207F52916D for ; Fri, 13 Oct 2017 23:10:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13C4629185; Fri, 13 Oct 2017 23:10:43 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A7692916D for ; Fri, 13 Oct 2017 23:10:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753164AbdJMXKm (ORCPT ); Fri, 13 Oct 2017 19:10:42 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:45086 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753140AbdJMXKl (ORCPT ); Fri, 13 Oct 2017 19:10:41 -0400 Received: by mail-pg0-f46.google.com with SMTP id b192so2305121pga.2 for ; Fri, 13 Oct 2017 16:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=Wyv38z/Lk9FA1XNrddMLnn6yl1W/7q4Q6Z+G7j8jwhc=; b=bpwJPEpfr+GZSv7hXFy84L5nVEAIbhdwqsIszb63R06ZPXjjV9gGO5KfAKcJSQoOmn XEUodrQ2kMULXEKSsZ4777Er7GCE6Q3XZJG8gGQdyvoPkrkI9s8LrbNeCyRhyzDcvI0F OHvfRPa1f7WqO2bZwkvzeluNU6H0zHlkbEbw8= 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; bh=Wyv38z/Lk9FA1XNrddMLnn6yl1W/7q4Q6Z+G7j8jwhc=; b=FHNw1QzC5AgBDrL8NdnjVmRypRjkg5OCccQ80YYe5UUJ7FYyIbHrfQNhRqCIE0IkcO +/lffvKLd2zZKc6h0q5/U+D5H9X+MUkDz8g4O+ElyhboRZTNjNApN+q0H8PKJSQtsh2q QPSxn7E2YXzCYSUXlgxp/aAYbQUfMT8YeVbDiUUjwQcpoCS8qcd5gXGQsJke/dGdqBMJ +f3pkihjDQdI8ZgShES4GssrUK4S8KLrD35KekoKqpBWcGPsYMQEkMTkdX7DG09DsTyx CENR9k6B/zJUAvxmbWW6rS1FaZvrgrYEDA5HzTxjezCJQ+fKNGd+QlIjiETliRVWGd0M 4wWg== X-Gm-Message-State: AMCzsaW7mBadfyW5joQXW1nV3l7RdAY05g+tSiDFASJP+3zF6rt8ZO37 7lPgJyCnBLW1mlgrh0VZLWeh9J3/ X-Google-Smtp-Source: AOwi7QAdjItx1xcJRszaCtwIo2SOd7BUACs1GrasBc2cdbNuTvBiAsawlb3Su9mvf//RJEPcXC7A6A== X-Received: by 10.84.198.131 with SMTP id p3mr2662325pld.245.1507936240867; Fri, 13 Oct 2017 16:10:40 -0700 (PDT) Received: from hotran_localhost.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id g11sm4369936pfe.41.2017.10.13.16.10.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Oct 2017 16:10:40 -0700 (PDT) From: Hoan Tran To: Guenter Roeck , Jean Delvare Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, lho@apm.com, patches@apm.com, Hoan Tran Subject: [PATCH v3] hwmon: xgene: Support hwmon v2 Date: Fri, 13 Oct 2017 16:10:19 -0700 Message-Id: <1507936219-23893-1-git-send-email-hotran@apm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch supports xgene-hwmon v2 which uses the non-cachable memory as the PCC shared memory. Signed-off-by: Hoan Tran --- v3 - Use local version variable - Use inline calls instead of the private map function v2 - Map PCC shared mem by ioremap() in case hwmon is v2 drivers/hwmon/xgene-hwmon.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c index 9c0dbb8..6b6c732 100644 --- a/drivers/hwmon/xgene-hwmon.c +++ b/drivers/hwmon/xgene-hwmon.c @@ -91,6 +91,11 @@ #define to_xgene_hwmon_dev(cl) \ container_of(cl, struct xgene_hwmon_dev, mbox_client) +enum xgene_hwmon_version { + XGENE_HWMON_V1 = 0, + XGENE_HWMON_V2 = 1, +}; + struct slimpro_resp_msg { u32 msg; u32 param1; @@ -609,6 +614,15 @@ static void xgene_hwmon_tx_done(struct mbox_client *cl, void *msg, int ret) } } +#ifdef CONFIG_ACPI +static const struct acpi_device_id xgene_hwmon_acpi_match[] = { + {"APMC0D29", XGENE_HWMON_V1}, + {"APMC0D8A", XGENE_HWMON_V2}, + {}, +}; +MODULE_DEVICE_TABLE(acpi, xgene_hwmon_acpi_match); +#endif + static int xgene_hwmon_probe(struct platform_device *pdev) { struct xgene_hwmon_dev *ctx; @@ -650,6 +664,16 @@ static int xgene_hwmon_probe(struct platform_device *pdev) } } else { struct acpi_pcct_hw_reduced *cppc_ss; + const struct acpi_device_id *acpi_id; + int version; + +#ifdef CONFIG_ACPI + acpi_id = acpi_match_device(xgene_hwmon_acpi_match, &pdev->dev); + if (!acpi_id) + return -EINVAL; + + version = (int)acpi_id->driver_data; +#endif if (device_property_read_u32(&pdev->dev, "pcc-channel", &ctx->mbox_idx)) { @@ -690,7 +714,13 @@ static int xgene_hwmon_probe(struct platform_device *pdev) */ ctx->comm_base_addr = cppc_ss->base_address; if (ctx->comm_base_addr) { - ctx->pcc_comm_addr = memremap(ctx->comm_base_addr, + if (version == XGENE_HWMON_V2) + ctx->pcc_comm_addr = (void __force *)ioremap( + ctx->comm_base_addr, + cppc_ss->length); + else + ctx->pcc_comm_addr = memremap( + ctx->comm_base_addr, cppc_ss->length, MEMREMAP_WB); } else { @@ -758,14 +788,6 @@ static int xgene_hwmon_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_ACPI -static const struct acpi_device_id xgene_hwmon_acpi_match[] = { - {"APMC0D29", 0}, - {}, -}; -MODULE_DEVICE_TABLE(acpi, xgene_hwmon_acpi_match); -#endif - static const struct of_device_id xgene_hwmon_of_match[] = { {.compatible = "apm,xgene-slimpro-hwmon"}, {}