From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757082AbcBWD51 (ORCPT ); Mon, 22 Feb 2016 22:57:27 -0500 Received: from e28smtp07.in.ibm.com ([125.16.236.7]:42856 "EHLO e28smtp07.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757056AbcBWD5Y (ORCPT ); Mon, 22 Feb 2016 22:57:24 -0500 X-IBM-Helo: d28relay01.in.ibm.com X-IBM-MailFrom: maddy@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org From: Madhavan Srinivasan To: linux-kernel@vger.kernel.org Cc: Madhavan Srinivasan , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Anton Blanchard , Daniel Axtens , Stephane Eranian , Sukadev Bhattiprolu Subject: [PATCH v8 3/7] powerpc/powernv: autoload nest unit driver module Date: Tue, 23 Feb 2016 09:16:34 +0530 Message-Id: <1456199198-11056-4-git-send-email-maddy@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456199198-11056-1-git-send-email-maddy@linux.vnet.ibm.com> References: <1456199198-11056-1-git-send-email-maddy@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 16022303-0025-0000-0000-00000A15D954 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Device tree parsing of nest units and events are separated from pmu code and are placed in powernv/ as "opal-nest.c". Makefile is updated to up pick the file. Code added to "opal.c" to create a platform device for the nest unit. Nest device module code with a probe function to get the nest counter memory address information for each chip is added in this patch. "ibm,opal-in-memory-counters" compatible string is used for autoload device_id match. Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Anton Blanchard Cc: Daniel Axtens Cc: Stephane Eranian Cc: Sukadev Bhattiprolu Signed-off-by: Madhavan Srinivasan --- arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/opal-nest.c | 97 ++++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal.c | 12 ++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/platforms/powernv/opal-nest.c diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile index f1516b5ecec9..ffc54cd49656 100644 --- a/arch/powerpc/platforms/powernv/Makefile +++ b/arch/powerpc/platforms/powernv/Makefile @@ -2,7 +2,7 @@ obj-y += setup.o opal-wrappers.o opal.o opal-async.o idle.o obj-y += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o obj-y += rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o obj-y += opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o -obj-y += opal-kmsg.o +obj-y += opal-kmsg.o opal-nest.o obj-$(CONFIG_SMP) += smp.o subcore.o subcore-asm.o obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o npu-dma.o diff --git a/arch/powerpc/platforms/powernv/opal-nest.c b/arch/powerpc/platforms/powernv/opal-nest.c new file mode 100644 index 000000000000..2ca879fdf159 --- /dev/null +++ b/arch/powerpc/platforms/powernv/opal-nest.c @@ -0,0 +1,97 @@ +/* + * OPAL Nest detection interface driver + * Supported on POWERNV platform + * + * Copyright IBM Corporation 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern struct perchip_nest_info nest_perchip_info[NEST_MAX_CHIPS]; + +static int opal_nest_counters_probe(struct platform_device *pdev) +{ + struct device_node *child, *parent; + struct perchip_nest_info *pcni; + u32 idx, range[4], pages; + int rc=0, i=0; + + if (!pdev || !pdev->dev.of_node) + return -ENODEV; + + /* + * "nest-counters" folder contains two things, + * a) per-chip reserved memory region for Nest PMU Counter data + * b) Support Nest PMU units and their event files + */ + parent = pdev->dev.of_node; + for_each_child_of_node(parent, child) { + if (of_property_read_u32(child, "ibm,chip-id", &idx)) { + pr_err("opal-nest-counters: device %s missing property\n", + child->full_name); + return -ENODEV; + } + + /* + *"ranges" property will have four u32 cells. + */ + if (of_property_read_u32_array(child, "ranges", range, 4)) { + pr_err("opal-nest-counters: range property value wrong\n"); + return -1; + } + + pcni = &nest_perchip_info[idx]; + pcni->pbase = range[1]; + pcni->pbase = pcni->pbase << 32 | range[2]; + pcni->size = range[3]; + + do + { + pages = PAGE_SIZE * i; + pcni->vbase[i++] = (u64)phys_to_virt(pcni->pbase + pages); + } while( i < (pcni->size/PAGE_SIZE)); + } + + return rc; +} + +static const struct of_device_id opal_nest_match[] = { + { .compatible = "ibm,opal-in-memory-counters" }, + { }, +}; + +static struct platform_driver opal_nest_driver = { + .driver = { + .name = "opal-nest-counters", + .of_match_table = opal_nest_match, + }, + .probe = opal_nest_counters_probe, +}; + +MODULE_DEVICE_TABLE(of, opal_nest_match); +module_platform_driver(opal_nest_driver); +MODULE_DESCRIPTION("PowerNV OPAL Nest Counters driver"); +MODULE_LICENSE("GPL"); diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index 4e0da5af94a1..60b576d1fc94 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -651,6 +651,15 @@ static void opal_i2c_create_devs(void) of_platform_device_create(np, NULL, NULL); } +static void opal_nest_create_dev(void) +{ + struct device_node *np; + + np = of_find_compatible_node(NULL, NULL, "ibm,opal-in-memory-counters"); + if (np) + of_platform_device_create(np, NULL, NULL); +} + static int kopald(void *unused) { __be64 events; @@ -717,6 +726,9 @@ static int __init opal_init(void) /* Setup a heatbeat thread if requested by OPAL */ opal_init_heartbeat(); + /* Create nest platform devices */ + opal_nest_create_dev(); + /* Create leds platform devices */ leds = of_find_node_by_path("/ibm,opal/leds"); if (leds) { -- 1.9.1