From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id EBF0F1BF2E9 for ; Sun, 18 Nov 2018 21:52:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E9645862D2 for ; Sun, 18 Nov 2018 21:52:06 +0000 (UTC) Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bToln0WE2cA1 for ; Sun, 18 Nov 2018 21:52:05 +0000 (UTC) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by hemlock.osuosl.org (Postfix) with ESMTPS id 9D0B7861A2 for ; Sun, 18 Nov 2018 21:52:04 +0000 (UTC) From: NeilBrown Date: Mon, 19 Nov 2018 08:51:55 +1100 Subject: Re: [PATCH v6 01/33] staging: mt7621-pci: parse and init port data from device tree In-Reply-To: <1541328599-18396-2-git-send-email-sergio.paracuellos@gmail.com> References: <1541328599-18396-1-git-send-email-sergio.paracuellos@gmail.com> <1541328599-18396-2-git-send-email-sergio.paracuellos@gmail.com> Message-ID: <87muq6cav8.fsf@notabene.neil.brown.name> MIME-Version: 1.0 List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============2398645989631855694==" Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" To: Sergio Paracuellos , gregkh@linuxfoundation.org Cc: driverdev-devel@linuxdriverproject.org --===============2398645989631855694== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sun, Nov 04 2018, Sergio Paracuellos wrote: > Add initialization of each PCIe port reading and initializing > data using device tree. > > Signed-off-by: Sergio Paracuellos > --- > drivers/staging/mt7621-pci/pci-mt7621.c | 75 +++++++++++++++++++++++++++= ++++-- > 1 file changed, 71 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt= 7621-pci/pci-mt7621.c > index 8371a9c..b7cb273 100644 > --- a/drivers/staging/mt7621-pci/pci-mt7621.c > +++ b/drivers/staging/mt7621-pci/pci-mt7621.c > @@ -126,16 +126,20 @@ static int pcie_link_status; >=20=20 > /** > * struct mt7621_pcie_port - PCIe port information > - * @base: IO mapped register base > + * @base: I/O mapped register base > * @list: port list > * @pcie: pointer to PCIe host info > - * @reset: pointer to port reset control > + * @pcie_rst: pointer to port reset control > + * @pcie_clk: PCIe clock > + * @slot: port slot > */ > struct mt7621_pcie_port { > void __iomem *base; > struct list_head list; > struct mt7621_pcie *pcie; > - struct reset_control *reset; > + struct reset_control *pcie_rst; > + struct clk *pcie_clk; > + u32 slot; > }; >=20=20 > /** > @@ -382,10 +386,57 @@ static int mt7621_pci_parse_request_of_pci_ranges(s= truct mt7621_pcie *pcie) > return 0; > } >=20=20 > +static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie, > + struct device_node *node, > + int slot) > +{ > + struct mt7621_pcie_port *port; > + struct device *dev =3D pcie->dev; > + struct device_node *pnode =3D dev->of_node; > + struct resource regs; > + char name[6]; > + int err; > + > + port =3D devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); > + if (!port) > + return -ENOMEM; > + > + err =3D of_address_to_resource(pnode, slot + 1, ®s); > + if (err) { > + dev_err(dev, "missing \"reg\" property\n"); > + return err; > + } > + > + port->base =3D devm_ioremap_resource(dev, ®s); > + if (IS_ERR(port->base)) > + return PTR_ERR(port->base); > + > + snprintf(name, sizeof(name), "pcie%d", slot); > + port->pcie_clk =3D devm_clk_get(dev, name); > + if (IS_ERR(port->pcie_clk)) { > + dev_err(dev, "failed to get pcie%d clock\n", slot); > + return PTR_ERR(port->pcie_clk); > + } This is problematic. The clocks are defined in the dtsi as: clocks =3D <&clkctrl 24 &clkctrl 25 &clkctrl 26>; clock-names =3D "pcie0", "pcie1", "pcie2"; and clkctrl is clkctrl: clkctrl { compatible =3D "ralink,rt2880-clock"; #clock-cells =3D <1>; }; but there is no driver that declares compatibility with ralink,rt2880-clock. So devm_clk_get() cannot find any clocks, and returns an error. I worked around this by just ignoring the error, but then something else went wrong in a subsequent patch - haven't worked out what yet. Probably the *right* way to fix this is to add a driver for ralink,rt2880-clock but I don't know what such a driver would do. In any case, I don't plan to pursue this particular issue further until I understand the other things that are happening with this patch set. Thanks, NeilBrown > + > + port->pcie_rst =3D devm_reset_control_get_exclusive(dev, name); > + if (PTR_ERR(port->pcie_rst) =3D=3D -EPROBE_DEFER) { > + dev_err(dev, "failed to get pcie%d reset control\n", slot); > + return PTR_ERR(port->pcie_rst); > + } > + > + port->slot =3D slot; > + port->pcie =3D pcie; > + > + INIT_LIST_HEAD(&port->list); > + list_add_tail(&port->list, &pcie->ports); > + > + return 0; > +} > + > static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) > { > struct device *dev =3D pcie->dev; > - struct device_node *node =3D dev->of_node; > + struct device_node *node =3D dev->of_node, *child; > struct resource regs; > int err; >=20=20 > @@ -399,6 +450,22 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *= pcie) > if (IS_ERR(pcie->base)) > return PTR_ERR(pcie->base); >=20=20 > + for_each_available_child_of_node(node, child) { > + int slot; > + > + err =3D of_pci_get_devfn(child); > + if (err < 0) { > + dev_err(dev, "failed to parse devfn: %d\n", err); > + return err; > + } > + > + slot =3D PCI_SLOT(err); > + > + err =3D mt7621_pcie_parse_port(pcie, child, slot); > + if (err) > + return err; > + } > + > return 0; > } >=20=20 > --=20 > 2.7.4 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlvx3vsACgkQOeye3VZi gbkZlxAApjIbyvoCQrVnQI+6r820ZdXLJfSbdz8VEcE8pCyJeoFy+8P/etA6GIpf 5I1Mo2DsyiLXMvOFYwKT5hEbyi5uw1i/KqUl70xN2B1kRQf00oqWBsy9oFkBRSFN vhvNwetVC07XbTEvDfhY7hjv51nhd/UwlaNctMlbtBoX+Ne1XTvx2E4D+7fCWB9v OKNwZvnoDUszYa8qdFwQfSPdnAhBpHapPhbXQz0n/upImqUn4y4yXWarl8RhvKn9 wKdLXZn3r1qYZgqh9RQ5NU4x8LfmkEOBI0SbzRlTiU+4MG8eRmaAjmnTdVmCeOR6 aBko7yodR8aDpTG4wms60UJBCc8v59BXNM75idS2igjrs71gkX3yG3j57KRpToj6 sNOVWWu+ibAs7PeBrN8opM5WLfn/dtXIZwNFfQIIMvHhPDTcmy4g1ryqH9K7uJmg C/4prVkGqA4rkzOZtg7V4pCxtbNy5S4eVq8W6+311J/iqwP82ziR3eHOVsxL0eDL 8NgVM/HF8CXIix9M9o36GXdisPHzBOWXyG2HoTdB5R0j0Uw5aIQKexERHCWdBvS0 UjBwp1yZ+Wllb+ptPek0pp2QhC7/W/ednw+1tmfk7Dft/Sp3o8ey+BxWrn6Xxpdy a9RsGOqACBqBT+MgHJVZvl9ygzVey3waDObTb5ZtZ6Im3AmG2u0= =094x -----END PGP SIGNATURE----- --=-=-=-- --===============2398645989631855694== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel --===============2398645989631855694==--