Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1197576pxb; Mon, 11 Oct 2021 00:03:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIPHLcAfGC5C5FwkXwQqcZaWZksu0KAMrX2ZQJYM2pNp9l0jxy12q+WUUUm3MVeMWbzudU X-Received: by 2002:a17:906:3842:: with SMTP id w2mr23898237ejc.28.1633935811597; Mon, 11 Oct 2021 00:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633935811; cv=none; d=google.com; s=arc-20160816; b=rUia24VSsDyaEpOZBMN6ig6cWiW1mfwNiwAPJBTNn8Bzw6iaAVyf43eWq8d3T4T942 XAjQBVdwWs2xpUmkN1oIHrTYKsMKejpw9oKzd0aoaSfsz3UrfVC15btVEmg0OCO7NAWz 9m4m9xodiCO/9+uHirR5LK0aZmh6q8TTom2B4jifMGpZgT4a/mZzYVO7+U5xqNwp5FrM SvAEE3vytmYpjL5+8Dyw+gHczxjz+PkIl8PdQcKBopoi8dyOzEz5ie6wq8BhBgKNBVcn pm7oNdGoxfNlvhqdamVtREgUqpcnu0G5wupc7K/6s1Y4fXVa2lle4y6prn36byZzb7Rp kkBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to; bh=eyUZkEBu+fJQ0p8g+U2a9zlj1GoYnWlRiQdBlCmwk2s=; b=FOqYW80hLTyiMPoVWYoWaupPoBm65XUOdIla6RtBS2+nybRZy803ZMYO+YhN4ZQ9xf vYVjr8t45/kwwsmsMEg52UZTik0/fF2H7IoZ9otsCzsgd5ai7Dh1B5hlr2UN74tnY6AT f2TTaTsbOLHlEYont3CKJ6h+hYaM5yqAiSYr3phw0LVAl8elGEYCMyIyRRp8zOYRqWqW KKM6mboWHze3m/LvZDhkRuUxap5e5wnPNBE5fHH9oorF+MYhyove+ebtnZa712E795pN V5/90SJ1TVFt1YIR7zETUNmQJTRpRtOCSTcbGm0qX6rezcyJPH6silD2odEGtXsoYb1I N1Pw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=marcan.st Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si13914408ede.422.2021.10.11.00.03.05; Mon, 11 Oct 2021 00:03:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=marcan.st Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233235AbhJKFT2 (ORCPT + 99 others); Mon, 11 Oct 2021 01:19:28 -0400 Received: from marcansoft.com ([212.63.210.85]:56662 "EHLO mail.marcansoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231966AbhJKFT1 (ORCPT ); Mon, 11 Oct 2021 01:19:27 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: marcan@marcan.st) by mail.marcansoft.com (Postfix) with ESMTPSA id 215C3425D6; Mon, 11 Oct 2021 05:17:21 +0000 (UTC) To: Krzysztof Kozlowski Cc: Rob Herring , linux-arm-kernel , Marc Zyngier , Arnd Bergmann , Linus Walleij , Alyssa Rosenzweig , Greg Kroah-Hartman , Mark Kettenis , Philipp Zabel , "Rafael J. Wysocki" , devicetree@vger.kernel.org, "open list:THERMAL" , "linux-kernel@vger.kernel.org" , linux-samsung-soc , "open list:SERIAL DRIVERS" References: <20211005155923.173399-1-marcan@marcan.st> <20211005155923.173399-3-marcan@marcan.st> From: Hector Martin Subject: Re: [PATCH 2/7] dt-bindings: power: Add apple,pmgr-pwrstate binding Message-ID: <2a1aaec7-25e6-f779-fd18-23378537bbd2@marcan.st> Date: Mon, 11 Oct 2021 14:17:19 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: es-ES Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/10/2021 16.50, Krzysztof Kozlowski wrote: > On Wed, 6 Oct 2021 at 17:56, Hector Martin wrote: >> Addendum: just found some prior art for this. See power/pd-samsung.yaml, >> which is another single-PD binding (though in that case they put them in >> the SoC node directly, not under a syscon). > > Maybe the design is actually similar. In the Exynos there is a entire > subblock managing power - called Power Management Unit (PMU). It > controls most of power-related parts, except clock gating. For example > it covers registers related to entering deep-sleep modes or power > domains. However we split this into two: > 1. Actual PMU driver which controls system-level power (and provides > syscon for other drivers needing to poke its registers... eh, life). > 2. Power domain driver which binds multiple devices to a small address > spaces (three registers) inside PMU address space. > > The address spaces above overlap, so the (1) PMU driver takes for > example 1004_0000 - 1004_5000 and power domain devices bind to e.g. > 1004_4000, 1004_4020, 1004_4040. It's similar, except Apple tends to group registers into uniform arrays, sometimes with gaps. They definitely do some ugly overlap stuff in their devicetree/OS which we'll try to avoid (e.g. the audio driver directly poking clock select registers...). Here's an incomplete memory map of the PMGR-related stuff in this SoC: 2_3b00_0000: Clocking 0_0000: PLLs 4_0000: Clock selects / dividers 000: 86 selects x 32bit (device clocks) 200: 8 selects x 32bit (aux clocks) 280: 2 selects x 32bit 4_4000: NCOs (used for audio) (5 x one 16KiB page each) 2_3b70_0000: PMGR 0_0000: Pwr-state registers 0000: 10 controls x 64bit (CPUs) 0100: 143 controls x 64bit (general devices) 0c00: 2 controls x 64bit (SEP) 4000: 13 controls x 64bit (ISP) 8000: 5 controls x 64bit (VENC) c000: 7 controls x 64bit (ANE) 1_0000: 10 controls x 64bit (DISP0) 1_c000: Power gates 10: 74 power gates (24 bytes each?) 3_4100: Performance counters? (16 bytes each, big array) 5_4000: Secondary CPU spin-up controls I believe the weird groupings into page-sized areas have to do with security, so they can map only those ranges to certain coprocessors and the like via the IOMMUs. There is also a MiniPMGR that uses the same register formats, but different counts/offsets, at 2_3d28_0000 (this one stays up in sleep mode, AIUI) So I think we won't need any overlaps, since e.g. the whole 00000-14000 subrange is all power state controls, so a driver doing system-level stuff wouldn't have to care about those. Those would just be bound by the syscon in this patchset. I chose to use a syscon to avoid having raw ioremaps for each domain instance, since each one of those eats up a whole page of mapping AIUI (and shows up in /proc/iomem individually). One question is whether if we need to poke at power gates directly (which isn't clear right now), we should have a separate top-level pmgr-pwrgate syscon as a parent, or just instantiate power gate subnodes under the same pmgr syscon at 1c000. -- Hector Martin (marcan@marcan.st) Public Key: https://mrcn.st/pub