From patchwork Tue Oct 17 18:28:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hotran X-Patchwork-Id: 10012743 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 A1C0A60211 for ; Tue, 17 Oct 2017 18:29:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 981DC289D6 for ; Tue, 17 Oct 2017 18:29:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BFDF289DA; Tue, 17 Oct 2017 18:29:03 +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 F1672289D6 for ; Tue, 17 Oct 2017 18:29:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937361AbdJQS3C (ORCPT ); Tue, 17 Oct 2017 14:29:02 -0400 Received: from mail-pf0-f180.google.com ([209.85.192.180]:53653 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937342AbdJQS3B (ORCPT ); Tue, 17 Oct 2017 14:29:01 -0400 Received: by mail-pf0-f180.google.com with SMTP id t188so1947484pfd.10 for ; Tue, 17 Oct 2017 11:29:01 -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=nHueJ6G5GXryub3XgsjcQlbIjIw54ruTwwiVoifSMxY=; b=JABEXe0M5+iGFwWgd35v2pe7V/7V0kqjmQAf6+SEbV4+vAMqsX8gvOOMgioGnfZ5ET RPCxDdF1cOoPNbKESFqPFS8rPcpQ6hMVXSh1iOqD1lrAeEdXBr/RGrusoRFdm/fFmbgv b9Dqyz1X7Htr5rwfrIWUahpxgKhMwuUPXq+dQ= 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=nHueJ6G5GXryub3XgsjcQlbIjIw54ruTwwiVoifSMxY=; b=KStlpDrn6DyIJdW3TnmKIhtWq4+zNbGZB+2QBWruTJRt6/2Guvpl+eg371bOWlRZH/ qa6nPHYcoTSJ1dHjSR6wWLWVLT3wif8OIcAwXINL2vYvC5HRjICKCZFzVo9W994n3Vr6 rN8mVhoSKgMHOtj9vnE6CeCP4Hse6h70OZwBziZJ7xbb9LqYQMCuY1O0o89d3NOGCyPV FKnYEkB2kq98KR4Za2xHJ3wCg2D/5ilFotY9APQeg/RZTWXQ+3GBRBm0qw02fAx7upu6 4B2y8bm5C8XVBnXdLpkhmUa2S6Ky7/sa1Pyq1H/2F9NkAJsd5VfQNP9PADqIGlf+SAya FR7Q== X-Gm-Message-State: AMCzsaWfbsaU8d62cWMgHIkfFdrVCrvRgFekFXt7hW2w1ViD68aBIL+c Zj9RVqxheMHU8ZOwagl5tCOAGw== X-Google-Smtp-Source: AOwi7QBJljRQ55yLtHJXJgA6Qe3BRPHEfE4zHZrpO2BiU73ZHzPEf7uX95focP6EN5gUx/EYVDkSzg== X-Received: by 10.84.131.111 with SMTP id 102mr12856272pld.178.1508264941080; Tue, 17 Oct 2017 11:29:01 -0700 (PDT) Received: from hotran_localhost.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id q70sm21022669pfj.39.2017.10.17.11.29.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Oct 2017 11:29:00 -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 v4] hwmon: xgene: Support hwmon v2 Date: Tue, 17 Oct 2017 11:28:34 -0700 Message-Id: <1508264914-4614-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 --- v4 - Initialize version variable 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..b4e3f11 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; + int version = XGENE_HWMON_V1; +#ifdef CONFIG_ACPI + const struct acpi_device_id *acpi_id; + + 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"}, {}