Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp122589imj; Thu, 14 Feb 2019 16:47:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IZJbZ2trsNip4DjkLj1kB2LS3wy2UvI9wv31TnTB8B3ltDm6QNckAU1bwKtUsv4f0jDazij X-Received: by 2002:a17:902:e492:: with SMTP id cj18mr7220664plb.341.1550191652923; Thu, 14 Feb 2019 16:47:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191652; cv=none; d=google.com; s=arc-20160816; b=SKA7cyilGPKZhD+7fGLomFRgqoeM3VzERga6NHijOMQjcHihomHOn5avmtc28GDOPz jZHFa3+ONh2BNW2M3sIMTLk5TOG/VxpQtrbX7KY4yV2D0Azv8OBkFILHemNbGps4UODW 8EL65VjgvNT8r6hUXuKmsOOXp+jL6VEIaneOJJrjxN4lPPSG05vGYlviaqi+ALJXVGwt 05QiIJKUyT7tcazOng6NpqXCn6bm4o324cA4MZ2/JfvzonL98rBnbUiBHEv2tAIVzoU3 2fEVeeNhckIwEAHfO/7uHQyobeGegHsCzb8U7M5vjpX6bRkrLyQtFnRRb3Deh66HWbbl AdWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=LkOf4AXprBcZmK6IkpkA8L6T1j3cs6bJ6JoAmzTYlbo=; b=XJkGguzKWkRhQYAAGgrvjatkBk5slRE2jCphN0GNVRqfpDsXZWO0f8NqNW9HCWaRH2 BLFLsIR045EpeSK9gyQPU7cWuML2luUfvL0BOCF6j8XCxq0n2A4xpEOK0Iy3Mn7ZXm2w tHU+etF4SvrCHxKPfBiKgJxOGKkrxfbZJm4UCU/TkVWsxn0swtiAfJPfA/WHefz8Tj+r YDxAK4TIkoEgmOyzxwWp9O74c71MGPH1FAln6Raj2to64RDeoKpZbqvoBr/KGlIM6VIT meeqO+sfOkN/xklrphs8mcsj9JpPu5I8HkHipN/T3ZQiLlaEDKrBjI7KQeefOrBV5KFP ZMjA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si3931766plm.3.2019.02.14.16.47.17; Thu, 14 Feb 2019 16:47:32 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502172AbfBNPcl (ORCPT + 99 others); Thu, 14 Feb 2019 10:32:41 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:45082 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502158AbfBNPck (ORCPT ); Thu, 14 Feb 2019 10:32:40 -0500 Received: by mail-ed1-f65.google.com with SMTP id d9so5322163edh.12 for ; Thu, 14 Feb 2019 07:32:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=LkOf4AXprBcZmK6IkpkA8L6T1j3cs6bJ6JoAmzTYlbo=; b=Q1Q5jaq11huQcszhIaCbLq/mdV5E18PhGyHyeA1mOc88Bs5zXONfQRXytVkgOh/WNR dREdnHVkD6/bcaZaRh7LoSc4ddiCNPzR9o2/xrRZrn6a6crC0by8usrXFZLKiSUAVdif NKuowFVE5Krx7zuVv4CXK4444WTcr3dgARtbeSTwaMa6LSSJW2+j3O34NPtYyvCEFfmB h+aQ6bl51F9ai/dvnukCH5S4/eCgbpm07DkfqlrCc6i9jkeQvPNmgIglWw3VjX8+j8gJ 1XE3q1bexbQ4jLPDYNMHyrQSisQnJ+mjKOiI4mgzV4V+mXBNPvFnwrViiBFhforrb+9c E5KA== X-Gm-Message-State: AHQUAuYu0CE0jmcqj6loP89rHxWsRgqK3M3zKIqsEGx3DZiZBAtFa5iE +w0WD7+1hE+eIF1JvYB0IBqpLQ== X-Received: by 2002:a17:906:50a:: with SMTP id j10mr3217030eja.236.1550158358856; Thu, 14 Feb 2019 07:32:38 -0800 (PST) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id z15sm607007eju.7.2019.02.14.07.32.37 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 07:32:37 -0800 (PST) Subject: Re: [PATCH 1/2] extcon-intel-cht-wc: Make charger detection co-existed with OTG host mode To: Yauhen Kharuzhy Cc: linux-kernel@vger.kernel.org, MyungJoo Ham , Andy Shevchenko References: <20190210203649.21691-1-jekhor@gmail.com> <20190210203649.21691-2-jekhor@gmail.com> <767c3d5e-f521-4d59-3922-a322b4124126@redhat.com> <20190214070943.GB16597@jeknote.loshitsa1.net> From: Hans de Goede Message-ID: <4bda8c03-5517-3627-f82e-d6bce0c4f340@redhat.com> Date: Thu, 14 Feb 2019 16:32:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190214070943.GB16597@jeknote.loshitsa1.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 14-02-19 08:09, Yauhen Kharuzhy wrote: > On Thu, Feb 14, 2019 at 12:15:00AM +0100, Hans de Goede wrote: >> Hi, >> >> On 10-02-19 21:36, Yauhen Kharuzhy wrote: >>> Whiskey Cove Cherry Trail PMIC requires disabling OTG host mode before >>> of charger detection procedure. Do this by manipulationg of CHGRCTRL1 >>> register. >>> >>> Source: APCI DSDT code of Lenovo Yoga Book YB1-X91L and open-sourced >>> Intel's drivers. >> >> Hmm, of the ACPI code is updating the otg-mode, then there should be >> no reason for us to do this, can you provide an acpidump of your >> device please? > > sure: https://github.com/jekhor/yogabook-linux/blob/master/yoga/acpi/yoga.acpidump.log > > Yes, there is ACPI routine for switching this but it is not called at > IRQ handling because it is handled by extcon driver. See my notes here: > https://github.com/jekhor/yogabook-linux/blob/master/yoga/acpi/investigate.txt#L364 The reason the _E12 and/or _E1F methods are not called is because they are GPIO interrupt handlers for virtual GPIOs on the PMIC, this is another abomination on these devices, that the ACPI GPIO interface is abused to make it look like the PMIC has more GPIOs then it really does and a bunch if them are used either to create event handlers for no-one knows which events exactly, where as the 0x20 - 0x55 ones are write-only virtual GPIOs where writing them is supposed to do no-one knows what. For some reason the people who engineered this decided it was not a good idea to have the AML code actually just directly talk to the hardware (except that in other cases it does of course) and it goes through these fake GPIOs which presumably are implemented by the Windows GPIO driver for the PMIC Note that we do implement the custom opregion 0x8F for the INT34D3 / PMI5 device, so the GET/SET calls could work, except that we have the following bug: -drivers/acpi/pmic/intel_pmic.c intel_pmic_regs_handler is wrong, assumes everything is a write, read of address 3 should return last value read on writing 0 to address 4, see the GET method on INT34D3 / PMI5 Even if we fix that bug though, there still is the issues that we: 1) Do not know when to execute the _E12 and/or _E1F methods 2) Do not know what to do of any of the "virtual" GPIOs are written 3) There is no valid ACPI battery interface for querying battery status So we are better of just not executing the _E12 and/or _E1F methods ever and directly talking to the hardware. If only the engineers who did the firmware interface for these devices had actually known what they were doing. Regards, Hans