Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp152106pxj; Wed, 16 Jun 2021 23:01:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrUj74SCUZi10nV2P5ZGUw3GAHY0U1EVI2u4BgT+SNbyIJGIAzcQHnbdPM4gUf1jAawy2j X-Received: by 2002:a05:6602:2e8c:: with SMTP id m12mr2401340iow.152.1623909706473; Wed, 16 Jun 2021 23:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623909706; cv=none; d=google.com; s=arc-20160816; b=fHfHeRIK2ZHm8DdQqMiTGKOD5EXUJGy0KIOp1lpATlWNkxuPMLIg2FHDKBESd36jfm MHc0owauMW0+Pfcs/gECQX3PGApkwENFatF8lrc8BIZzult4jIWfvv7VYFORkrKEsbiI S34zHTz2nVKQhjkYHS6OdYdhEcEgtltWAZKAgyaV9qEjEvDdTMRI0mjvx3H4RMXo8jYI d/bqOfsyglc8cVv8GmQAY1myitY8pil3VrbteY9TiFHprDrR/cF2QbmV+xWGjAQbIbe/ F3/gszOFQo6138MBG/NHqCuoCG35IO2LIhMMAd0SkLPg5feEdtwDGSYRl95sgVRnIsNX /k6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nI7yEuG2ARK23uejO9nhB9zAo4xzWVauJN211Odr0ag=; b=ayHoArJJCLX7XVNJt53r4iINEZuvb7y2NCvRh6DC3tMZ3kLkgQixVjzomERBAgyIZl BXx+WKv6LxyapypODnDPy07h/WlkBcKw+an8Q8HPeh0z5uhyzqaXW83dq+rATEzyjbSv +QxrosHhlClSNKg6JuEztesV7Rgc3z96AZk/wv8nuZyVhNOZw+sIJpnqzsBctd7dMLM+ 3OHLLYgu0moJfUUhOyY/28y5pdu/icKnS6mvrtXU/WnaiG/3kbxdK4tR5n9YtLIZJu5o a1GbzIYLqHypst2ACgM3aNBazK+H1w1ASW/GbmmZg3tcII7FxmObgJJwTZiwu+U9XQ15 e/Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S3EyK0G1; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x99si4711216jah.122.2021.06.16.23.01.33; Wed, 16 Jun 2021 23:01:46 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S3EyK0G1; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229671AbhFQGCx (ORCPT + 99 others); Thu, 17 Jun 2021 02:02:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbhFQGCv (ORCPT ); Thu, 17 Jun 2021 02:02:51 -0400 Received: from mail-ua1-x935.google.com (mail-ua1-x935.google.com [IPv6:2607:f8b0:4864:20::935]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89161C061574; Wed, 16 Jun 2021 23:00:38 -0700 (PDT) Received: by mail-ua1-x935.google.com with SMTP id o3so1676623uaw.5; Wed, 16 Jun 2021 23:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nI7yEuG2ARK23uejO9nhB9zAo4xzWVauJN211Odr0ag=; b=S3EyK0G1UBktsOleWFm/MmnmHW2LeOl67vQAXqw+sSV/y6rb5Kzn8/0e/P2xbwqove boggjxcWiH4UnbuXOGKNbuBU364gWdeijLrnuQcI0aolnbkvF1MpdshBPi3W5GZI26iZ VE9ZJQxmSB86xzPT3SBE+PqwKbppwEuqNlhk8NyjiCGmSJ1ifz8JtJgtojOY+/fgtanv MOqv7LVJox0XJ2d1NN6HtmRUwyXaxp5pbsEH0rADbHrlKrejuIDhoW6G+0RbmMIUKvCu sDLKjaYJtfQ0HG+UyfHs6y04Ob8slrJFvpRTMSB3UomwoLt+0xr94/dR3ExVLicO83w6 dxGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nI7yEuG2ARK23uejO9nhB9zAo4xzWVauJN211Odr0ag=; b=Yyv8EU0czP3abKR+Mgo9oHWGNnoILneJSZluLd6P0zGTzmw+qrTyoGIEdauv3her9Y RnGXiPMvDsepY8LUjghHiZyZ6G2C3l+yk1PEcc36v+wGbUGMyOV3bKSwPpabc/FrN3oM 2QfvX+6Za9gPvIkdwztPOzadCMs1ShM3qQO4K7mb3VNmeBskGRD5+Cvf4FlzmszrNBkE dysSZJFukEprQuQgaZbpDBelhaEisrzcvBfXAJnuWFh17gWsxOC7F9aUY1tBXo8La4AZ /kirxAckK6jobNr2c9MDKe0h4m4rkiwFVDZFws1Pu+0gtkZe2/56LBZfetVkPSgGaTsX +kMA== X-Gm-Message-State: AOAM533WQ0xMO5WAGi2ThkBow4KSlR7lDkkV8FBKHScKHDZo8Hrntuv+ jizV53iOkkTyqTyoIIDQlxCNvZZ3D7mjFX8q5PeFajlY2iVwxg== X-Received: by 2002:ab0:49aa:: with SMTP id e39mr3733325uad.0.1623909637178; Wed, 16 Jun 2021 23:00:37 -0700 (PDT) MIME-Version: 1.0 References: <20210609140159.20476-1-sergio.paracuellos@gmail.com> In-Reply-To: <20210609140159.20476-1-sergio.paracuellos@gmail.com> From: Sergio Paracuellos Date: Thu, 17 Jun 2021 08:00:25 +0200 Message-ID: Subject: Re: [PATCH v2 0/3] PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver To: linux-pci@vger.kernel.org Cc: "open list:MIPS" , Thomas Bogendoerfer , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Matthias Brugger , John Crispin , Bjorn Helgaas , Rob Herring , linux-staging@lists.linux.dev, Greg KH , NeilBrown , Ilya Lipnitskiy , linux-kernel , =?UTF-8?Q?Pali_Roh=C3=A1r?= Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Jun 9, 2021 at 4:02 PM Sergio Paracuellos wrote: > > MediaTek MT7621 PCIe subsys supports single Root complex (RC) > with 3 Root Ports. Each Root Ports supports a Gen1 1-lane Link. > Topology is as follows: > > MT7621 PCIe HOST Topology > > .-------. > | | > | CPU | > | | > '-------' > | > | > | > v > .------------------. > .-----------| HOST/PCI Bridge |------------. > | '------------------' | Type1 > BUS0 | | | Access > v v v On Bus0 > .-------------. .-------------. .-------------. > | VIRTUAL P2P | | VIRTUAL P2P | | VIRTUAL P2P | > | BUS0 | | BUS0 | | BUS0 | > | DEV0 | | DEV1 | | DEV2 | > '-------------' '-------------' '-------------' > Type0 | Type0 | Type0 | > Access BUS1 | Access BUS2| Access BUS3| > On Bus1 v On Bus2 v On Bus3 v > .----------. .----------. .----------. > | Device 0 | | Device 0 | | Device 0 | > | Func 0 | | Func 0 | | Func 0 | > '----------' '----------' '----------' > > This driver has been very long time in staging and I have been cleaning > it from its first versions where there was code kaos and PCI_LEGACY support. > Original code came probably from openWRT based on mediatek's SDK code. There > is no documentation at all about the mt7621 PCI subsystem. > I have been cleaning it targeting mt7621 SoC which is the one I use in > my GNUBee PC1 board and HiLink HLK-MT7621A evaluation board. > > Now I think is clean enough to be moved into 'drivers/pci/controller'. > This driver is mips/ralink architecture and need 'mips_cps_numiocu()' > to properly configure iocu regions for mips. > > This driver also uses already mainlined pci phy driver located in > 'drivers/phy/ralink/phy-mt7621-pci.c'. There are two instances of > the phy being the first one dual ported for pci0 and pci1, and the > second one not dual ported dedicated to pci2. Because of writing twice > some phy registers of the dual-ported one sometimes become in not > confident boot cycles we have to take care of this when device link > is checked here in controller driver. We power on the dual ported-phy > if there is something connected in pcie0 or pcie1. In the same manner > we have to properly disable it only if nothing is connected in of both > pcie0 and pcie1 slots. > > Another thing that must be mentioned is that this driver uses IO > in physical address 0x001e160000. IO_SPACE_LIMIT for MIPS is 0xffff > so some generic PCI functions (like of_pci_range_to_resource) won't > work and the resource ranges part for IO is set manually. This has been fixed and now there is no need to set io resources manually. See [0]. > > Changes in v2: > - Make one commit moving driver directly from staging into > 'drivers/pci/controllers' instead of two commits making > one add and a later remove. > - Update binding documentation moving 'clocks', 'resets' and > 'phys' properties to child root bridge nodes. > - Update code to properly be able to use new bindings. > - Kconfig: add || (MIPS && COMPILE_TEST). > - Use {read/write}_relaxed versions. > - Use 'PCI_BASE_ADDRESS_0' instead of a custom definition. > - Avoid to set 'PCI_COMMAND_MASTER' and re-do functions > 'mt7621_pcie_enable_ports' and 'mt7621_pcie_enable_port'. I forgot to comment that all of these changes are rebased on the top of staging-next. Since this is a 'git mv' as I was told to do by Bjorn, last version of the code is available here [1] with the following added changes to the ones listed above from previously submitted v1 series: - Define PCI_IOBASE for mips (spaces.h) to avoid parsing io resources manually so 'mt7621_pci_parse_request_of_pci_ranges' is not needed anymore. - Don't store resources in driver private data but just get them to properly set io window register and mips iocu memory regions. Thanks in advance for your time. Best regards, Sergio Paracuellos [0]: https://lore.kernel.org/linux-staging/20210614100617.28753-1-sergio.paracuellos@gmail.com/T/#t [1]: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/mt7621-pci/pci-mt7621.c?h=staging-next > > NOTE: Greg, I have maintained your Acked-by from previous series in > delete driver commit and added in the one which is moving code here > and delete the remaining stuff. If you are not ok with this, just > let me now and I'll drop it and resend. > > Thanks in advance for your time. > > Best regards, > Sergio Paracuellos > > Sergio Paracuellos (3): > dt-bindings: mt7621-pci: PCIe binding documentation for MT7621 SoCs > PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver > MAINTAINERS: add myself as maintainer of the MT7621 PCI controller > driver > > .../bindings/pci/mediatek,mt7621-pci.yaml | 142 ++++++++++++++++++ > MAINTAINERS | 6 + > arch/mips/ralink/Kconfig | 2 +- > drivers/pci/controller/Kconfig | 8 + > drivers/pci/controller/Makefile | 1 + > .../controller}/pci-mt7621.c | 0 > drivers/staging/Kconfig | 2 - > drivers/staging/Makefile | 1 - > drivers/staging/mt7621-pci/Kconfig | 8 - > drivers/staging/mt7621-pci/Makefile | 2 - > drivers/staging/mt7621-pci/TODO | 4 - > .../mt7621-pci/mediatek,mt7621-pci.txt | 104 ------------- > 12 files changed, 158 insertions(+), 122 deletions(-) > create mode 100644 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml > rename drivers/{staging/mt7621-pci => pci/controller}/pci-mt7621.c (100%) > delete mode 100644 drivers/staging/mt7621-pci/Kconfig > delete mode 100644 drivers/staging/mt7621-pci/Makefile > delete mode 100644 drivers/staging/mt7621-pci/TODO > delete mode 100644 drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt > > -- > 2.25.1 >