Received: by 2002:a05:6a10:c7d3:0:0:0:0 with SMTP id h19csp1404157pxy; Sun, 15 Aug 2021 20:20:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjVyWtWzlBuYsOeJhZB1j2f12Q9dG4/Cy1YkVLcEYb3Y1DqGlTkOWtu2fQFq1zsivvQu6J X-Received: by 2002:a17:906:af4f:: with SMTP id ly15mr14213904ejb.175.1629084049242; Sun, 15 Aug 2021 20:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629084049; cv=none; d=google.com; s=arc-20160816; b=RGjqzKuq534fIe3BEujiWpQ4O981zTyuAk3iXLtMSljM+Nkb+lAIztlf7i2hu8rjjj VlWB+CPR8jpEHzL3f0kJorgU8rXSz3zTp9xpOQXmQ3B9oGLuu6TGrDylI/QqCs9PtYNm pLXqRabBZAbP7bWXF4OIGdctcmbb7x9WxvI/aTuy69qxLc2dKAJhcgbt3grZdYsV+l8b Dsk+Mn+GrGedmrWJiuH6/fQSoq2aPoaKc8oEQLUo5tr5Ij7q+rXOfp1xMBZv48TfB6uO FC3y7ag1ShXpt8QJzizX4ZcIHL6gYtiyeKYXrJmoCnwshuiNaFqLaQm+PyhkgDBZuUqK o/Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=fF1qx8CX8hav3QyaM1+1uQRYn2BM2wFTahFZ8EmyGgg=; b=AG/dDWeY7OgsJMCSv2f5DdS8Vtgj/QNkMcQ40N0p30WCYlJ731XdBHxtmsnYitOHJA 99gO32+EJBwQT6Z6GtV2MNTzcWS6+CcyGXIQveb2grPiesGKtJ7drCWDy60aSeWWjQ0W znWxjjEetCBUqDrvL5k2JumdIhohGa5cPJ9NCUxtar4jiHU3Jtw2MaOg1b4YiCRxU1Fw XktDdIl94FQLs6Wo7CVpE01jVNcptAmv0MEoX1QJH4APf7pgvXKdmYZnRz+91LygaJGi y4786RPShgEtkMyi1jJABrTrPHISLJfLhoeu5fvNomOhGyOAR47y+xeQgmkDDhtBFEgX S3VQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bv8si9262314ejb.87.2021.08.15.20.20.26; Sun, 15 Aug 2021 20:20:49 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232977AbhHPDTH (ORCPT + 99 others); Sun, 15 Aug 2021 23:19:07 -0400 Received: from [138.197.143.207] ([138.197.143.207]:45352 "EHLO rosenzweig.io" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S232421AbhHPDTH (ORCPT ); Sun, 15 Aug 2021 23:19:07 -0400 Date: Sun, 15 Aug 2021 21:45:37 -0400 From: Alyssa Rosenzweig To: Marc Zyngier Cc: linux-pci@vger.kernel.org, Bjorn Helgaas , Rob Herring , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Stan Skowronek , Mark Kettenis , Sven Peter , Hector Martin , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 2/2] PCI: apple: Add driver for the Apple M1 Message-ID: References: <20210815042525.36878-1-alyssa@rosenzweig.io> <20210815042525.36878-3-alyssa@rosenzweig.io> <87a6lj17d1.wl-maz@kernel.org> <877dgn12v4.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <877dgn12v4.wl-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > +static int apple_pcie_setup_refclk(void __iomem *rc, > > > + void __iomem *port, > > > + unsigned int idx) > > > +{ > > > + u32 stat; > > > + int res; > > > + > > > + res = readl_poll_timeout(rc + CORE_RC_PHYIF_STAT, stat, > > > + stat & CORE_RC_PHYIF_STAT_REFCLK, 100, 50000); > > > + if (res < 0) > > > + return res; > > > + > > > + rmwl(0, CORE_LANE_CTL_CFGACC, rc + CORE_LANE_CTL(idx)); > > > + rmwl(0, CORE_LANE_CFG_REFCLK0REQ, rc + CORE_LANE_CFG(idx)); > > > + > > > + res = readl_poll_timeout(rc + CORE_LANE_CFG(idx), stat, > > > + stat & CORE_LANE_CFG_REFCLK0ACK, 100, 50000); > > > + if (res < 0) > > > + return res; > > > + > > > + rmwl(0, CORE_LANE_CFG_REFCLK1, rc + CORE_LANE_CFG(idx)); > > > + res = readl_poll_timeout(rc + CORE_LANE_CFG(idx), stat, > > > + stat & CORE_LANE_CFG_REFCLK1, 100, 50000); > > > + > > > + if (res < 0) > > > + return res; > > > + > > > + rmwl(CORE_LANE_CTL_CFGACC, 0, rc + CORE_LANE_CTL(idx)); > > > + udelay(1); > > > + rmwl(0, CORE_LANE_CFG_REFCLKEN, rc + CORE_LANE_CFG(idx)); > > > + > > > + rmwl(0, PORT_REFCLK_EN, port + PORT_REFCLK); > > > + > > > + return 0; > > > +} > > This really wants to be moved to its own clock driver, unless there is > a strong guarantee that the clock tree isn't shared with anything > else. I expect that parts of that clock tree will need to be > refcounted, and that's where having a real clock driver will help. > > I also have the strong feeling that the clock hierarchy will need to > be described in DT one way or another, if only to be able to cope with > future revisions of this block. Could be, but this is the most magical part of the driver (no docs...) and that means it's prohibitively difficult to design useful DT bindings... For whatever it's worth the Corellium code doesn't expose any DT bindings here, so maybe this hasn't changed since older Apple SoCs. Orthogonal to this magic code, we /do/ need DT bindings for the clock/power gates. At the moment, m1n1 enables the PCIe clock and leaves it on, so it's not urgent for this series. But in the future when we want fine grained power management, we'll need it modeled. Sven has a WIP clock gate driver and proposed bindings, which can be added to the PCIe DT later nonintrusively. That shouldn't block this series, however.