From patchwork Fri Apr 5 20:35:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10887815 X-Patchwork-Delegate: andy.shevchenko@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27F041708 for ; Fri, 5 Apr 2019 20:36:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 124A328B35 for ; Fri, 5 Apr 2019 20:36:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00DBC28B22; Fri, 5 Apr 2019 20:36:16 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 7414C28B22 for ; Fri, 5 Apr 2019 20:36:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726451AbfDEUgP (ORCPT ); Fri, 5 Apr 2019 16:36:15 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:53332 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbfDEUgO (ORCPT ); Fri, 5 Apr 2019 16:36:14 -0400 Received: by mail-pf1-f202.google.com with SMTP id j18so5165390pfi.20 for ; Fri, 05 Apr 2019 13:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=yWu1RUjcfHwzrSUGeytCPVbvT10jIUq0a7fK+aORuH8=; b=pHHnS/3qolS+LTmPIPuK54JaaZYV1CijFMFfIWlQ4cPIIrF8atlQG2EPAu/oxTl+V9 GBhOtTFzO7TLv+yRQLOVCkrS6xlpeM3IManrPHaROLMEVBvAfMcXHXc8yoY8cn1pHTOF 5NRx0IkQqhfWkQdEdFrDU0gwjeCYXnHNfGnnfFLa8YbnxnAPLXzSxC9QAOMOQbWAxyl+ iWJGftcjXPEDR+WMZwKfN0DkcV9HEX9f2FGhHU4ZbR4aayhb1v9E6Am25oJ22KrJ+M1o 8nThxaUIkLUeyaE3jG/LMfWw6K6+y0V2lb0WFgJDS4UA0PpxQzEyLn4ge8obcscddUoN GDXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=yWu1RUjcfHwzrSUGeytCPVbvT10jIUq0a7fK+aORuH8=; b=EGCgGBkiMNdhFoUGzJ7VDwEPvzZ2ga9itT8KMUgdbDnXIwEW5pZhiFBTTifsynB1Jj KqoShV7SVBV/2tr4QOdreyiOsvw5ko+LkOH1GApthVeKXVEt13dp20yrNwAFwqX/gMR3 XotdWlsgVSL9K1v+6eS5QL02SjijY2TXTmWjTFMAqyQ/VmmRLEPmaMVnHMxmJMtYT/x+ bTncVBN6J6FXLUXFXBVUg/ol1hEpaCBjDc3PulQpUO1KMbMhWP8KOsIn0Oi/0NEWOCJ1 4Di8kMw/gActXosBf7w+SOwe2ikbRp7d4oMojDVlMfIoBbbCBvrKH63e3yII+1Ht+PHa WBiQ== X-Gm-Message-State: APjAAAUywaFeZHuduXtsYcZn418sRJ/9XiRtApHoGiDk70kXlq6NU0Yn LVKWJI1KT1wpX9khVJr/EK3duI5FMdQA X-Google-Smtp-Source: APXvYqwe19MR+4izfsWOiIwvNcVDwkPcmmFxYGaTf4Y3uUbmho5ugm/2xN3d9OzKlR54VDbG3m00pRC1rxQp X-Received: by 2002:aa7:8099:: with SMTP id v25mr564414pff.68.1554496573301; Fri, 05 Apr 2019 13:36:13 -0700 (PDT) Date: Fri, 5 Apr 2019 13:35:58 -0700 In-Reply-To: <20190405203558.19160-1-rajatja@google.com> Message-Id: <20190405203558.19160-3-rajatja@google.com> Mime-Version: 1.0 References: <20190313222124.229371-1-rajatja@google.com> <20190405203558.19160-1-rajatja@google.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH v3 3/3] platform/x86: intel_pmc_core: Instantiate pmc_core device on legacy platforms From: Rajat Jain To: Rajneesh Bhardwaj , Vishwanath Somayaji , Darren Hart , Andy Shevchenko , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Wysocki@google.com, Rafael J , Srinivas Pandruvada Cc: Rajat Jain , furquan@google.com, evgreen@google.com, rajatxjain@gmail.com Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add code to instantiate the pmc_core platform device and thus attach to the driver, if the ACPI device for the same ("INT33A1") is not present in a system where it should be. This was discussed here: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1966991.html Signed-off-by: Rajat Jain --- v3: (first version of *this* patch -to go with rest of v3 patchset) v2: (does not exist) v1: (does not exist) drivers/platform/x86/Makefile | 2 +- .../platform/x86/intel_pmc_core_plat_init.c | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/x86/intel_pmc_core_plat_init.c diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 86cb76677bc8..83d0bb9a14bb 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -89,7 +89,7 @@ obj-$(CONFIG_INTEL_BXTWC_PMIC_TMU) += intel_bxtwc_tmu.o obj-$(CONFIG_INTEL_TELEMETRY) += intel_telemetry_core.o \ intel_telemetry_pltdrv.o \ intel_telemetry_debugfs.o -obj-$(CONFIG_INTEL_PMC_CORE) += intel_pmc_core.o +obj-$(CONFIG_INTEL_PMC_CORE) += intel_pmc_core.o intel_pmc_core_plat_init.o obj-$(CONFIG_PMC_ATOM) += pmc_atom.o obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o diff --git a/drivers/platform/x86/intel_pmc_core_plat_init.c b/drivers/platform/x86/intel_pmc_core_plat_init.c new file mode 100644 index 000000000000..45be89e7586c --- /dev/null +++ b/drivers/platform/x86/intel_pmc_core_plat_init.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Intel PMC Core platform init + * Copyright (c) 2019, Google Inc. + * Author - Rajat Jain + * + * This code instantiates platform devices for intel_pmc_core driver, only + * on supported platforms that may not have the ACPI devices in the ACPI tables. + * No new platforms should be added here, because we expect that new platforms + * should all have the ACPI device, which is the preferred way of enumeration. + */ + +#include +#include + +#include +#include + +static struct platform_device pmc_core_device = { + .name = "pmc_core", +}; + +static int dummy; +/* + * INTEL_CPU_FAM6 macro won't take NULL for driver_data (uses &driver_data), + * thus provide a dummy driver_data. + */ +static const struct x86_cpu_id intel_pmc_core_ids[] = { + INTEL_CPU_FAM6(SKYLAKE_MOBILE, dummy), + INTEL_CPU_FAM6(SKYLAKE_DESKTOP, dummy), + INTEL_CPU_FAM6(KABYLAKE_MOBILE, dummy), + INTEL_CPU_FAM6(KABYLAKE_DESKTOP, dummy), + INTEL_CPU_FAM6(CANNONLAKE_MOBILE, dummy), + INTEL_CPU_FAM6(ICELAKE_MOBILE, dummy), + {} +}; +MODULE_DEVICE_TABLE(x86cpu, intel_pmc_core_ids); + +static int __init pmc_core_platform_init(void) +{ + int ret; + + /* Skip creating the platform device if ACPI already has a device */ + if (acpi_dev_present("INT33A1", NULL, -1) || + !x86_match_cpu(intel_pmc_core_ids)) + return -ENODEV; + + ret = platform_device_register(&pmc_core_device); + if (ret) + return ret; + + return 0; +} + +static void __exit pmc_core_platform_exit(void) +{ + if (!acpi_dev_present("INT33A1", NULL, -1) && + x86_match_cpu(intel_pmc_core_ids)) + platform_device_unregister(&pmc_core_device); +} + +module_init(pmc_core_platform_init); +module_exit(pmc_core_platform_exit);