From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE893C10F0E for ; Tue, 16 Apr 2019 03:22:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF31820870 for ; Tue, 16 Apr 2019 03:22:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oq3u7J2e"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="E2khNjBd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF31820870 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oHWR0yY3Px+Lrrq7LkOdnUgpx9PJMH8ls18GUxb7ic4=; b=oq3u7J2e7mRO4V H6xnGOC9RTIvSjKqG/IR/8iZV96UN8I2h153/nN/mBlp85D1NQ0EkGW4yVluVVzDHpOG0OFyiEW5x itLfe+C/f6ycwWGSFAPwb1og2tJ6bnWU3cMtLFv5Jcce16RrYTQ3zU4gVwx/dYS7MRQkoNIdJ1tv0 EW1oyxGNPCjApFV4G9GhSyX6WCVwDP4QIGT7DP2KQHFLW92Ximda4EdxS6rkZw21W3rK1czvbjPE9 a4KCPoIZOBCdNC9NTuee5i8wDWWGVM3AklDcxbrxU/HnTo4Eb5Ih0iT9Ig3tr05XCU78t5DEE4zkN eoMp1nV6oMwfDEZjMcZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGEg2-0007jW-Rx; Tue, 16 Apr 2019 03:22:30 +0000 Received: from mail-he1eur04on0622.outbound.protection.outlook.com ([2a01:111:f400:fe0d::622] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGEft-0007Wy-Id for linux-arm-kernel@lists.infradead.org; Tue, 16 Apr 2019 03:22:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6Y1qJnNfkOM3Ow2YFkmqivAVweRaWhs19+5fyvCNQ3A=; b=E2khNjBdUWxQQW59fMmWyfPFt7eT5uekcq9wy60cA1L6pPU4M3WIMUJKydjbaFR/m0KoK0wz2wVzRx6QDerpeT+8xJLNLeYgSmv3bv1oFx1ZlJXIQIdOwDn2osVXS9NCzWRJrIheRo1O1evJ+cGN1lxadSutfooTcflS78AJjIU= Received: from AM6PR0402MB3911.eurprd04.prod.outlook.com (52.133.30.10) by AM6PR0402MB3895.eurprd04.prod.outlook.com (52.133.29.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.11; Tue, 16 Apr 2019 03:22:17 +0000 Received: from AM6PR0402MB3911.eurprd04.prod.outlook.com ([fe80::c854:fc94:f9ed:2ca2]) by AM6PR0402MB3911.eurprd04.prod.outlook.com ([fe80::c854:fc94:f9ed:2ca2%6]) with mapi id 15.20.1792.020; Tue, 16 Apr 2019 03:22:17 +0000 From: Anson Huang To: "robh+dt@kernel.org" , "mark.rutland@arm.com" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , "catalin.marinas@arm.com" , "will.deacon@arm.com" , "rui.zhang@intel.com" , "edubezval@gmail.com" , "daniel.lezcano@linaro.org" , Aisheng Dong , "ulf.hansson@linaro.org" , Daniel Baluta , Peng Fan , "heiko@sntech.de" , "horms+renesas@verge.net.au" , "agross@kernel.org" , "olof@lixom.net" , "bjorn.andersson@linaro.org" , "jagan@amarulasolutions.com" , "enric.balletbo@collabora.com" , "marc.w.gonzalez@free.fr" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-pm@vger.kernel.org" Subject: [PATCH V12 2/5] thermal: of-thermal: add API for getting sensor ID from DT Thread-Topic: [PATCH V12 2/5] thermal: of-thermal: add API for getting sensor ID from DT Thread-Index: AQHU9AOYmR6BJ3silEqzBa3crqYckQ== Date: Tue, 16 Apr 2019 03:22:17 +0000 Message-ID: <1555384609-7030-2-git-send-email-Anson.Huang@nxp.com> References: <1555384609-7030-1-git-send-email-Anson.Huang@nxp.com> In-Reply-To: <1555384609-7030-1-git-send-email-Anson.Huang@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK2PR02CA0133.apcprd02.prod.outlook.com (2603:1096:202:16::17) To AM6PR0402MB3911.eurprd04.prod.outlook.com (2603:10a6:209:1c::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anson.huang@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f05a450b-eb62-4362-819e-08d6c21aba5a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600140)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:AM6PR0402MB3895; x-ms-traffictypediagnostic: AM6PR0402MB3895: x-microsoft-antispam-prvs: x-forefront-prvs: 000947967F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(136003)(396003)(346002)(376002)(199004)(189003)(6512007)(106356001)(105586002)(53936002)(2501003)(36756003)(6116002)(3846002)(66066001)(68736007)(486006)(110136005)(316002)(5660300002)(11346002)(446003)(476003)(2616005)(97736004)(71190400001)(71200400001)(81166006)(99286004)(8936002)(81156014)(8676002)(50226002)(52116002)(102836004)(256004)(14454004)(478600001)(6506007)(386003)(26005)(7736002)(4326008)(76176011)(86362001)(2906002)(7416002)(186003)(2201001)(25786009)(6486002)(6436002)(305945005)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0402MB3895; H:AM6PR0402MB3911.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 2lTIscw5KFDqFnh6h0QVSqOr2m3B8jRxzXOFmam/zHivjYcDk2t/gKsIdTWUFrhpMSQehAjzidWsw2csHyDBO3+5Eo+wRNvEm7waXJoUceEcVK2t5hNVD4FZ+FTLGik1Tiqc9r2XmO9Pk75bS3TnhOol0Z9W3+Tlbc6KQ/oFCYX8P/FKdkzab5YUggqX93msJG7WvSj/CE+IdIIMtFO+SpVK8ToJJMc8JfUAYN1vk2bqmD19jL/MdU13I2JQuR7zu4NiTLrUzp0d8PlZwFOHi9ZfW+YONKS/Z7vyBJo/n3laxqOL8nZijz7kM5BirXmuPVosYyoRYiqTXODSnfPf9Jdcazi4ta0mNTAZzWCWGczaLMuR2Z0j3sPlhmTdL/GjudiV7S5em3mmKCUUfondPzZI6Qfky/6GfmV1EwrKDj8= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f05a450b-eb62-4362-819e-08d6c21aba5a X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Apr 2019 03:22:17.8220 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3895 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190415_202221_774499_55D81489 X-CRM114-Status: GOOD ( 18.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dl-linux-imx Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On some platforms like i.MX8QXP, the thermal driver needs a real HW sensor ID from DT thermal zone, the HW sensor ID is used to get temperature from SCU firmware, and the virtual sensor ID starting from 0 to N is NOT used at all, this patch adds new API thermal_zone_of_get_sensor_id() to provide the feature of getting sensor ID from DT thermal zone's node. Signed-off-by: Anson Huang --- New patch. --- drivers/thermal/of-thermal.c | 53 ++++++++++++++++++++++++++++++++++---------- include/linux/thermal.h | 10 +++++++++ 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 2df059c..2e4320c 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -446,6 +446,46 @@ thermal_zone_of_add_sensor(struct device_node *zone, } /** + * thermal_zone_of_get_sensor_id - get sensor ID from a DT thermal zone + * @tz_np: a valid thermal zone device node. + * @sensor_specs: pointer to output arguments structure will be passed back. + * @id: a sensor ID pointer will be passed back. + * + * This function will get sensor ID from a given thermal zone node, use + * "thermal-sensors" as list name, and get sensor ID from first phandle's + * argument. + * + * Return: 0 on success, proper error code otherwise. + */ + +int thermal_zone_of_get_sensor_id(struct device_node *tz_np, + struct of_phandle_args *sensor_specs, + u32 *id) +{ + int ret; + + ret = of_parse_phandle_with_args(tz_np, + "thermal-sensors", + "#thermal-sensor-cells", + 0, + sensor_specs); + if (ret) + return ret; + + if (sensor_specs->args_count >= 1) { + *id = sensor_specs->args[0]; + WARN(sensor_specs->args_count > 1, + "%pOFn: too many cells in sensor specifier %d\n", + sensor_specs->np, sensor_specs->args_count); + } else { + *id = 0; + } + + return 0; +} +EXPORT_SYMBOL_GPL(thermal_zone_of_get_sensor_id); + +/** * thermal_zone_of_sensor_register - registers a sensor to a DT thermal zone * @dev: a valid struct device pointer of a sensor device. Must contain * a valid .of_node, for the sensor node. @@ -500,21 +540,10 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, int ret, id; /* For now, thermal framework supports only 1 sensor per zone */ - ret = of_parse_phandle_with_args(child, "thermal-sensors", - "#thermal-sensor-cells", - 0, &sensor_specs); + ret = thermal_zone_of_get_sensor_id(child, &sensor_specs, &id); if (ret) continue; - if (sensor_specs.args_count >= 1) { - id = sensor_specs.args[0]; - WARN(sensor_specs.args_count > 1, - "%pOFn: too many cells in sensor specifier %d\n", - sensor_specs.np, sensor_specs.args_count); - } else { - id = 0; - } - if (sensor_specs.np == sensor_np && id == sensor_id) { tzd = thermal_zone_of_add_sensor(child, sensor_np, data, ops); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 5f4705f..970fb37 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -375,6 +375,9 @@ struct thermal_trip { /* Function declarations */ #ifdef CONFIG_THERMAL_OF +int thermal_zone_of_get_sensor_id(struct device_node *tz_np, + struct of_phandle_args *sensor_specs, + u32 *id); struct thermal_zone_device * thermal_zone_of_sensor_register(struct device *dev, int id, void *data, const struct thermal_zone_of_device_ops *ops); @@ -386,6 +389,13 @@ struct thermal_zone_device *devm_thermal_zone_of_sensor_register( void devm_thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone_device *tz); #else + +static int thermal_zone_of_get_sensor_id(struct device_node *tz_np, + struct of_phandle_args *sensor_specs, + u32 *id) +{ + return -ENOENT; +} static inline struct thermal_zone_device * thermal_zone_of_sensor_register(struct device *dev, int id, void *data, const struct thermal_zone_of_device_ops *ops) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel