Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp625794yba; Fri, 5 Apr 2019 13:37:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqw99vZJfVnSLNlSlqHdL4uvDXjXW7ms0lNCcRHK8hPQ8Jk9e+br+WXEsh0BlyS19ypy9CpF X-Received: by 2002:a17:902:8a8b:: with SMTP id p11mr15129579plo.227.1554496653466; Fri, 05 Apr 2019 13:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554496653; cv=none; d=google.com; s=arc-20160816; b=F6cJ6I8Vudrc7YYADmKdo44ls7fYv4kTXqsmGJPhxuDBr6Ul2i3HenfuT2r6U4Sz2j jfKQ7EPBzRAVAMDlOrIgVYIusso79GxElMkq2Kxf9u7YzpmOQ3c8v2u0nY0zlIhGJLfq U6RRkgIFIz8wEaI8tIvmPjP666p5J08JQEvgpCjmfllqQ3igQIlgQVS+GxgJCDn8fR0p cSo37xxH0jS+BMztFZ1IzrMOm331Sn2Koj376qdt55KXqr+w6cqc9DV2oRh/GHhX5R+g Kbk8WjDOZ7z1i5tyvGtRF968LzPub1l+nJY4fUvQEpOhwyaoOPK1ef30N7dQhLDxmQP2 Wm4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=yWu1RUjcfHwzrSUGeytCPVbvT10jIUq0a7fK+aORuH8=; b=jjX6wf+h0QrPZtxXZwt/nipgcPZ1DU8jvs7cEs3fTh72ztl3Y7wmkCSbr/9YkIFPKv lqGKXwzChTRF5xsklLrsM/pZNqXFrGZToP+HJgB2FOZqT5dShkU7FZC4DDgJFaPGDg3S e/Y1jBN3zvTgeev28CQvMmX69DmAZF6MiqjcXfzyVxGf3n1nMS+Du+sD59TgMRe6i61O NQzdQ9CxMUHmJXYFXYmYTkulcr5AX1SY7/9OUvwpncUOLZhARtZw1D+pOzxYHqjQieVs mPm4ADMusraf4pwUqWhKkaz3OOj7IbasbXvY+1xKkghjBoP7Dw9e1ykdQzryHPnhm15i Haog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="pHHnS/3q"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v69si19271032pgd.276.2019.04.05.13.37.18; Fri, 05 Apr 2019 13:37:33 -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=@google.com header.s=20161025 header.b="pHHnS/3q"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726489AbfDEUgQ (ORCPT + 99 others); Fri, 5 Apr 2019 16:36:16 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:40904 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726124AbfDEUgO (ORCPT ); Fri, 5 Apr 2019 16:36:14 -0400 Received: by mail-pf1-f201.google.com with SMTP id f7so5178070pfd.7 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=uLngKfHMtuDVKRgjJaqmToXPUpdZXmk1nNs9Ok3qSUYH34uG4T/CNzQx+tr6eUOXu3 Ci8MsHfbL8ipiWl9xeJNUh7xxpu4Y3pZLm4TgBNn2FsuBblO3IeNvCPabfmwcdzHHD01 pSZyEdyXUhjcFVEmTuunXyOGh1t3nSlU91KZ4kV3xpLj5a/XAEEaNkO/aCRflLCFYc6P ssrkamyB9Z4EpfuzVwowcg+SvQPznU4BDK+l5ZuoVcnJw2+KNwKyMn27lraPd/f6nMDQ V4uJWdokwWsg76XrZMIhcwpkWFFkj4kbmQoyenb81wEiZLhySYUkY4Gss9vP3yb4e/Cz +wFg== X-Gm-Message-State: APjAAAXbFOoe7eLMv0o+DwjillhArxi6ASbAuAQWtmj6TgvgDrDuw/BO 4ndK3x8E6i+Qvfg5IHjiLKN5iwYhBRnp 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.21.0.392.gf8f6787159e-goog