From patchwork Thu Sep 21 17:17:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hotran X-Patchwork-Id: 9964567 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 13D54600C5 for ; Thu, 21 Sep 2017 17:20:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE360285CE for ; Thu, 21 Sep 2017 17:20:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E315B294DD; Thu, 21 Sep 2017 17:20:50 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 870F9285CE for ; Thu, 21 Sep 2017 17:20:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753205AbdIURUo (ORCPT ); Thu, 21 Sep 2017 13:20:44 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:44288 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753091AbdIURUj (ORCPT ); Thu, 21 Sep 2017 13:20:39 -0400 Received: by mail-pf0-f172.google.com with SMTP id e1so3534366pfk.1 for ; Thu, 21 Sep 2017 10:20:39 -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:in-reply-to:references; bh=VAQysIq0X38bm/qby3GK0Ila41uMZ54SP2qmu6VTDX8=; b=R/2J13ycYTC5aiiJMRWrGYbzOEGoTWr7mATtgssAAg+1GDxmWCuu4R1gP0qweiEtVc WwKWrwJKsqQ7nbiarygGWve/5rcYCIMqMqu8g8aUx7iCnIQ0w7v1Oa0HYq3RCVPCwDfU aDgpDUCaW26LfVD7dmEB/TP/vA15zc+aDciZU= 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=VAQysIq0X38bm/qby3GK0Ila41uMZ54SP2qmu6VTDX8=; b=WQRxSOs7Kz/5hETaBN9HB9E8w4E/bEnhs4HK43YWgy3RTaq8kBrTcaWsP3QyKNjTRg C/FamW339pwBLXEMdu9AzQIR85ypBOIJB60aUOfq9Fvat6FDqw66uO6YD/aDUhfOdDoE F3TYmBNAO/M5CeVpNhufivvWnXo9wVr8Zfw8mdXPrAoJe8BJdqUsTTqKEbe1bCO8aslm F6+wM0et/qxl1L3hhd7SiAwrhdH1+lDt5c63qMr1hwoi4IVyPSMpCp0qAm7GHMSgjCSf sUe0vaI3nkGqhQj5HtE9Ah4NloVxel4/hcaj0ssajZxlmg9WPYVBTchPiyQgZGJ3y/uM 5zew== X-Gm-Message-State: AHPjjUi1HVJo+KikwSxiyVooh9BnlFf/UWzdofvZXTSISxSzg0GdUZ6B ZReVhCT7Os3xKOyFOa/FPJ+4rw== X-Google-Smtp-Source: AOwi7QDS5BLwOK/nH8ybVl6ZY8BpHjiWQnUN7BAtnVO2qJ74Zs4P/GzUty04FxcVp+1Ee5bfqnAOLQ== X-Received: by 10.101.78.7 with SMTP id r7mr6558402pgt.64.1506014438959; Thu, 21 Sep 2017 10:20:38 -0700 (PDT) Received: from hotran_localhost.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id y74sm4004935pfa.164.2017.09.21.10.20.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Sep 2017 10:20:38 -0700 (PDT) From: Hoan Tran To: Guenter Roeck , Jean Delvare Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Itaru Kitayama , lho@apm.com, kdinh@apm.com, patches@apm.com, Hoan Tran Subject: [PATCH 2/2] hwmon: xgene: Support PCC shared memory in IO region Date: Thu, 21 Sep 2017 10:17:10 -0700 Message-Id: <1506014230-13933-3-git-send-email-hotran@apm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506014230-13933-1-git-send-email-hotran@apm.com> References: <1506014230-13933-1-git-send-email-hotran@apm.com> 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 As the PCC shared memory could be in IO region which doesn't support caching, this patch simply uses ioremap() for IO region. Signed-off-by: Hoan Tran --- drivers/hwmon/xgene-hwmon.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c index 5cd327e..2dac1ed 100644 --- a/drivers/hwmon/xgene-hwmon.c +++ b/drivers/hwmon/xgene-hwmon.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -135,6 +136,14 @@ static u16 xgene_word_tst_and_clr(u16 *addr, u16 mask) return ret; } +static void __iomem *pcc_ioremap(phys_addr_t phys, size_t size) +{ + if (!memblock_is_memory(phys)) + return ioremap(phys, size); + + return memremap(phys, size, MEMREMAP_WB); +} + static int xgene_hwmon_pcc_rd(struct xgene_hwmon_dev *ctx, u32 *msg) { struct acpi_pcct_shared_memory *generic_comm_base = ctx->pcc_comm_addr; @@ -690,9 +699,8 @@ 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, - cppc_ss->length, - MEMREMAP_WB); + ctx->pcc_comm_addr = pcc_ioremap(ctx->comm_base_addr, + cppc_ss->length); } else { dev_err(&pdev->dev, "Failed to get PCC comm region\n"); rc = -ENODEV;