From patchwork Tue Sep 13 13:41:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Seidel X-Patchwork-Id: 9329173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 09EA16048F for ; Tue, 13 Sep 2016 13:58:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F12D0294BE for ; Tue, 13 Sep 2016 13:58:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E60B2294C8; Tue, 13 Sep 2016 13:58:06 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 43DB8294BE for ; Tue, 13 Sep 2016 13:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756644AbcIMN6D (ORCPT ); Tue, 13 Sep 2016 09:58:03 -0400 Received: from mail.teration.net ([213.136.64.78]:49624 "EHLO mail.teration.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751633AbcIMN6C (ORCPT ); Tue, 13 Sep 2016 09:58:02 -0400 X-Greylist: delayed 658 seconds by postgrey-1.27 at vger.kernel.org; Tue, 13 Sep 2016 09:58:02 EDT Received: from ezra.home.teration.net.net (unknown [82.113.98.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: public@stefanseidel.info) by mail.teration.net (Postfix) with ESMTPSA id 655797F97A; Tue, 13 Sep 2016 15:41:50 +0200 (CEST) Authentication-Results: contabo.teration.net; dmarc=none header.from=stefanseidel.info DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stefanseidel.info; s=dkim_57; t=1473774110; bh=mo3wsVmFYo/5/WvkwSxuD7RTH0B9r1Ik0Ex76ZWKc3U=; h=From:To:Cc:Subject:Date:From; b=jLWd9Vo4yH+baNshOkX+2hHdwwj7JJxAsK4fxoludLj2/5NGdgwIHGFuRL+lWnv57 UM+ARFKiFy3QPMY4hgerBH8IjB9ySR58wYmcaXtoWgBW5d/P36+F/0Zbf+pQSVuoQo geK69HTBhv0B0EgAr3L62HR6EJilzJzn+Z0e/IkM= From: Stefan Seidel To: platform-driver-x86@vger.kernel.org Cc: Darren Hart , Mattia Dongili , Stefan Seidel Subject: [PATCH] sony-laptop: add new thermal control handle and setting Date: Tue, 13 Sep 2016 13:41:09 +0000 Message-Id: <20160913134109.5614-1-lkml@stefanseidel.info> X-Mailer: git-send-email 2.9.3 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 On at least the SVD11 there is an additional thermal control handle that is found at a different handle address but otherwise behaves the same as the other one. This patch also introduces an additional thermal control setting "cooling", which, however, may not be available on all platforms. Signed-off-by: Stefan Seidel --- drivers/platform/x86/sony-laptop.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index 1dba359..6c9deb3 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c @@ -148,7 +148,8 @@ static int sony_nc_battery_care_setup(struct platform_device *pd, unsigned int handle); static void sony_nc_battery_care_cleanup(struct platform_device *pd); -static int sony_nc_thermal_setup(struct platform_device *pd); +static int sony_nc_thermal_setup(struct platform_device *pd, + unsigned int handle); static void sony_nc_thermal_cleanup(struct platform_device *pd); static int sony_nc_lid_resume_setup(struct platform_device *pd, @@ -1363,7 +1364,8 @@ static void sony_nc_function_setup(struct acpi_device *device, result); break; case 0x0122: - result = sony_nc_thermal_setup(pf_device); + case 0x015F: + result = sony_nc_thermal_setup(pf_device, handle); if (result) pr_err("couldn't set up thermal profile function (%d)\n", result); @@ -1476,6 +1478,7 @@ static void sony_nc_function_cleanup(struct platform_device *pd) sony_nc_lid_resume_cleanup(pd); break; case 0x0122: + case 0x015F: sony_nc_thermal_cleanup(pd); break; case 0x0128: @@ -1547,6 +1550,7 @@ static void sony_nc_function_resume(void) sony_call_snc_handle(handle, 0x100, &result); break; case 0x0122: + case 0x015F: sony_nc_thermal_resume(); break; case 0x0124: @@ -2150,14 +2154,16 @@ struct snc_thermal_ctrl { unsigned int profiles; struct device_attribute mode_attr; struct device_attribute profiles_attr; + unsigned int handle; }; static struct snc_thermal_ctrl *th_handle; -#define THM_PROFILE_MAX 3 +#define THM_PROFILE_MAX 4 static const char * const snc_thermal_profiles[] = { "balanced", "silent", - "performance" + "performance", + "cooling" }; static int sony_nc_thermal_mode_set(unsigned short mode) @@ -2173,7 +2179,8 @@ static int sony_nc_thermal_mode_set(unsigned short mode) if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX) return -EINVAL; - if (sony_call_snc_handle(0x0122, mode << 0x10 | 0x0200, &result)) + if (sony_call_snc_handle(th_handle->handle, mode << 0x10 | 0x0200, + &result)) return -EIO; th_handle->mode = mode; @@ -2185,7 +2192,7 @@ static int sony_nc_thermal_mode_get(void) { unsigned int result; - if (sony_call_snc_handle(0x0122, 0x0100, &result)) + if (sony_call_snc_handle(th_handle->handle, 0x0100, &result)) return -EIO; return result & 0xff; @@ -2245,14 +2252,17 @@ static ssize_t sony_nc_thermal_mode_show(struct device *dev, return count; } -static int sony_nc_thermal_setup(struct platform_device *pd) +static int sony_nc_thermal_setup(struct platform_device *pd, + unsigned int handle) { int ret = 0; th_handle = kzalloc(sizeof(struct snc_thermal_ctrl), GFP_KERNEL); if (!th_handle) return -ENOMEM; - ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles); + th_handle->handle = handle; + + ret = sony_call_snc_handle(handle, 0x0000, &th_handle->profiles); if (ret) { pr_warn("couldn't to read the thermal profiles\n"); goto outkzalloc;