Received: by 10.223.176.46 with SMTP id f43csp750007wra; Fri, 19 Jan 2018 01:06:42 -0800 (PST) X-Google-Smtp-Source: ACJfBotQF2Ax21CdQX9yIzqJcgyCm4RuDJwEpf8SpQ3J3cbXSWXIQFxPgksxmk7J9Tz9zX3YmC4L X-Received: by 10.98.61.22 with SMTP id k22mr35773173pfa.133.1516352802360; Fri, 19 Jan 2018 01:06:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516352802; cv=none; d=google.com; s=arc-20160816; b=nnMUoHoX6KCfMxScMQMZhW1NnW5097+H0/GIvUHZ2NpHf18i1WnKQn/6izeKkFVVeA rCQsef4iQeYwBHAgecnBhC/WBM8gUgv0G6qqL8Yvp2ooth8RWJMx5VUCgNDPKKenELLG KKpGSHzNZMEgjqNNvIDuuIiSj8dwdutGNxHzihxr412IMX0QX2RQaKsqrKdshXnoQ+sS kx040Eidvs/Lc8Oh76J7JDSFW1Tme9QPD0neSDTd6aL2/d88xDHUJBHKDb7CHU3CbKC+ 2EHiKlJ7OslBKNNiR7kHZ5XePXB2r/qeHU95lWk76RXJzO7mwsJ3p4RDGGj1CXodw3y6 dEBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=2RaNppOpqVCCvPONZrVtGtq90IS2ihXzz7hIa11VgE8=; b=Lgto/wc2HpRV8MaqlHjYYFko4v8p2jksLKF/6DX7+7BIDXI0AFZuFZK39VDdSuKyKw GnZJfiLO0i/EO+REyj7b7+2bAb/GtltjIPFNIx3bfQZn0WIFcbOqwnCTNwH0UfjqgrzF Qe1PwOQ9fKEq2vqmKpKgr5h5nhDC6FvkhAKmzjfC3h+f15RkQ9UASQK+awqq7yzjmg4S gvDSmiQsZJlg5PaNFqLrg0t4qTaYVcSOrDt9Ig/BxnoYGwzSe+f3fiJKyAokvbxx7qK8 CumtfYBJl8RhoylGxvhiIYiyfbVvdePTXL5fN1RezNFjuOFiwI0yFZmW+qJYH23wQGyf Jdcg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6-v6si673458pls.655.2018.01.19.01.06.28; Fri, 19 Jan 2018 01:06:42 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755634AbeASJFM (ORCPT + 99 others); Fri, 19 Jan 2018 04:05:12 -0500 Received: from mga06.intel.com ([134.134.136.31]:52690 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755020AbeASJDz (ORCPT ); Fri, 19 Jan 2018 04:03:55 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jan 2018 01:03:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,381,1511856000"; d="scan'208";a="197007731" Received: from raj-desk2.iind.intel.com ([10.223.107.30]) by fmsmga006.fm.intel.com with ESMTP; 19 Jan 2018 01:03:52 -0800 From: Rajneesh Bhardwaj To: platform-driver-x86@vger.kernel.org Cc: dvhart@infradead.org, andy@infradead.org, linux-kernel@vger.kernel.org, vishwanath.somayaji@intel.com, srinivas.pandruvada@linux.intel.com, Rajneesh Bhardwaj Subject: [Patch v1 2/8] platform/x86: intel_pmc_core: Substitute PCI with CPUID enumeration Date: Fri, 19 Jan 2018 14:28:21 +0530 Message-Id: <1516352307-20123-3-git-send-email-rajneesh.bhardwaj@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516352307-20123-1-git-send-email-rajneesh.bhardwaj@intel.com> References: <1516352307-20123-1-git-send-email-rajneesh.bhardwaj@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Pandruvada The Only use of PCI device enumeration here is to get the PMC base address which is a fixed value i.e. 0xFE000000. On some platforms this can be read through a non standard PCI BAR. But after Kabylake, PMC is not exposed as a PCI device anymore. There are other non standard methods like ACPI LPIT which can also be used for obtaining this value. For simplicity, this value can be hardcoded as it won't change. Since we don't have a PMC PCI device on any platform after Kabylake, this creates a foundation for future SoC support. Signed-off-by: Rajneesh Bhardwaj Signed-off-by: Srinivas Pandruvada --- drivers/platform/x86/intel_pmc_core.c | 91 ++++++++++++----------------------- drivers/platform/x86/intel_pmc_core.h | 3 +- 2 files changed, 33 insertions(+), 61 deletions(-) diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c index 43cee8877ee3..f7616600e8ab 100644 --- a/drivers/platform/x86/intel_pmc_core.c +++ b/drivers/platform/x86/intel_pmc_core.c @@ -18,12 +18,12 @@ * */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include -#include #include #include -#include #include #include @@ -119,13 +119,6 @@ static const struct pmc_reg_map spt_reg_map = { .pm_read_disable_bit = SPT_PMC_READ_DISABLE_BIT, }; -static const struct pci_device_id pmc_pci_ids[] = { - { PCI_VDEVICE(INTEL, SPT_PMC_PCI_DEVICE_ID), - (kernel_ulong_t)&spt_reg_map }, - { 0, }, -}; -MODULE_DEVICE_TABLE(pci, pmc_pci_ids); - static inline u8 pmc_core_reg_read_byte(struct pmc_dev *pmcdev, int offset) { return readb(pmcdev->regbase + offset); @@ -446,79 +439,59 @@ static inline void pmc_core_dbgfs_unregister(struct pmc_dev *pmcdev) static const struct x86_cpu_id intel_pmc_core_ids[] = { { X86_VENDOR_INTEL, 6, INTEL_FAM6_SKYLAKE_MOBILE, X86_FEATURE_MWAIT, - (kernel_ulong_t)NULL}, + (kernel_ulong_t)&spt_reg_map}, { X86_VENDOR_INTEL, 6, INTEL_FAM6_SKYLAKE_DESKTOP, X86_FEATURE_MWAIT, - (kernel_ulong_t)NULL}, + (kernel_ulong_t)&spt_reg_map}, { X86_VENDOR_INTEL, 6, INTEL_FAM6_KABYLAKE_MOBILE, X86_FEATURE_MWAIT, - (kernel_ulong_t)NULL}, + (kernel_ulong_t)&spt_reg_map}, { X86_VENDOR_INTEL, 6, INTEL_FAM6_KABYLAKE_DESKTOP, X86_FEATURE_MWAIT, - (kernel_ulong_t)NULL}, + (kernel_ulong_t)&spt_reg_map}, {} }; -static int pmc_core_probe(struct pci_dev *dev, const struct pci_device_id *id) +MODULE_DEVICE_TABLE(x86cpu, intel_pmc_core_ids); + +static int __init pmc_core_probe(void) { - struct device *ptr_dev = &dev->dev; - struct pmc_dev *pmcdev = &pmc; const struct x86_cpu_id *cpu_id; - const struct pmc_reg_map *map = (struct pmc_reg_map *)id->driver_data; + struct pmc_dev *pmcdev = &pmc; int err; cpu_id = x86_match_cpu(intel_pmc_core_ids); - if (!cpu_id) { - dev_dbg(&dev->dev, "PMC Core: cpuid mismatch.\n"); - return -EINVAL; - } - - err = pcim_enable_device(dev); - if (err < 0) { - dev_dbg(&dev->dev, "PMC Core: failed to enable Power Management Controller.\n"); - return err; - } - - err = pci_read_config_dword(dev, - SPT_PMC_BASE_ADDR_OFFSET, - &pmcdev->base_addr); - if (err < 0) { - dev_dbg(&dev->dev, "PMC Core: failed to read PCI config space.\n"); - return err; - } - pmcdev->base_addr &= PMC_BASE_ADDR_MASK; - dev_dbg(&dev->dev, "PMC Core: PWRMBASE is %#x\n", pmcdev->base_addr); - - pmcdev->regbase = devm_ioremap_nocache(ptr_dev, - pmcdev->base_addr, - SPT_PMC_MMIO_REG_LEN); - if (!pmcdev->regbase) { - dev_dbg(&dev->dev, "PMC Core: ioremap failed.\n"); + if (!cpu_id) + return -ENODEV; + + pmcdev->map = (struct pmc_reg_map *)cpu_id->driver_data; + pmcdev->base_addr = PMC_BASE_ADDR_DEFAULT; + pmcdev->regbase = ioremap(pmcdev->base_addr, + pmcdev->map->regmap_length); + if (!pmcdev->regbase) return -ENOMEM; - } mutex_init(&pmcdev->lock); - pmcdev->map = map; pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit(); err = pmc_core_dbgfs_register(pmcdev); - if (err < 0) - dev_warn(&dev->dev, "PMC Core: debugfs register failed.\n"); + if (err < 0) { + pr_warn(" debugfs register failed.\n"); + iounmap(pmcdev->regbase); + return err; + } + pr_info(" initialized\n"); return 0; } +module_init(pmc_core_probe) -static void pmc_core_remove(struct pci_dev *dev) +static void __exit pmc_core_remove(void) { - pmc_core_dbgfs_unregister(&pmc); - mutex_destroy(&pmc.lock); -} - -static struct pci_driver intel_pmc_core_driver = { - .name = "intel_pmc_core", - .id_table = pmc_pci_ids, - .probe = pmc_core_probe, - .remove = pmc_core_remove, -}; + struct pmc_dev *pmcdev = &pmc; -module_pci_driver(intel_pmc_core_driver); + pmc_core_dbgfs_unregister(pmcdev); + mutex_destroy(&pmcdev->lock); + iounmap(pmcdev->regbase); +} +module_exit(pmc_core_remove) MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Intel PMC Core Driver"); diff --git a/drivers/platform/x86/intel_pmc_core.h b/drivers/platform/x86/intel_pmc_core.h index e3be1d2b08cd..9df4a60a179f 100644 --- a/drivers/platform/x86/intel_pmc_core.h +++ b/drivers/platform/x86/intel_pmc_core.h @@ -21,8 +21,7 @@ #ifndef PMC_CORE_H #define PMC_CORE_H -/* Sunrise Point Power Management Controller PCI Device ID */ -#define SPT_PMC_PCI_DEVICE_ID 0x9d21 +#define PMC_BASE_ADDR_DEFAULT 0xFE000000 #define SPT_PMC_BASE_ADDR_OFFSET 0x48 #define SPT_PMC_SLP_S0_RES_COUNTER_OFFSET 0x13c -- 2.7.4