From nobody Wed Aug 31 07:24:31 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MHbKP55Xwz4bSbk; Wed, 31 Aug 2022 07:24:41 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mx.blih.net (mx.blih.net [212.83.155.74]) (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 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mx.blih.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MHbKP0nHKz3k2H; Wed, 31 Aug 2022 07:24:40 +0000 (UTC) (envelope-from manu@bidouilliste.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bidouilliste.com; s=mx; t=1661930673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xxj7nztR8DldkgO7hX9Wl6idSKmltrBYbZQ09r1c/Co=; b=Zs+RhzaUNDNRDEFREcv3aNXMvBuaPCLsy73qupQqbnYn17nhVXV7f4TWqrOVvFR2KrhODI cq9VmZyxALDMabpBhtBpTrS6yiMMNihflqW5WbACjcRqi0ztbFtqV8N5NsxsHFbugS2+HT hxZ8JJDPqCR/Xv9BbMYVNHVGYxLVlWw= Received: from skull.home.blih.net (static-176-182-94-247.ncc.abo.bbox.fr [176.182.94.247]) by mx.blih.net (OpenSMTPD) with ESMTPSA id a5644765 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 31 Aug 2022 07:24:32 +0000 (UTC) Date: Wed, 31 Aug 2022 09:24:31 +0200 From: Emmanuel Vadot To: Ganbold Tsagaankhuu Cc: Peter Jeremy , Ganbold Tsagaankhuu , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 901df07a4768 - main - Code refactoring for existing rk_gpio driver. It supports gpio type checking. Depending on gpio type some register addresses are different. Message-Id: <20220831092431.de8c7e3bd404feefde854533@bidouilliste.com> In-Reply-To: References: <202208191322.27JDMv0b007432@gitrepo.freebsd.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd14.0) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Rspamd-Queue-Id: 4MHbKP0nHKz3k2H X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Wed, 31 Aug 2022 11:15:18 +0800 Ganbold Tsagaankhuu wrote: > Peter, >=20 > On Sun, Aug 21, 2022 at 12:05 PM Peter Jeremy wrote: >=20 > > On 2022-Aug-19 13:22:57 +0000, Ganbold Tsagaankhuu > > wrote: > > >The branch main has been updated by ganbold: > > > > > >URL: > > https://cgit.FreeBSD.org/src/commit/?id=3D901df07a47684dca7b06f60d838a5= 6456d751a23 > > > > > >commit 901df07a47684dca7b06f60d838a56456d751a23 > > >Author: S=F8ren Schmidt > > >AuthorDate: 2022-08-19 13:22:01 +0000 > > >Commit: Ganbold Tsagaankhuu > > >CommitDate: 2022-08-19 13:22:01 +0000 > > > > > > Code refactoring for existing rk_gpio driver. > > > It supports gpio type checking. Depending on gpio type some > > > register addresses are different. > > > > > > Reviewed by: manu > > > Differential Revision: https://reviews.freebsd.org/D36262 > > > > My Rock64 is now hanging on boot as follows: > > rk_pinctrl0: on ofwbus0 > > gpio0: mem 0xff210000-0xff2100ff irq 53= on > > rk_pinctrl0 > > gpio0: Unknown gpio version 48000000 > > <> > > > > >@@ -170,6 +221,43 @@ rk_gpio_attach(device_t dev) > > > rk_gpio_detach(dev); > > > return (ENXIO); > > > } > > >+ RK_GPIO_LOCK(sc); > > >+ sc->version =3D rk_gpio_read_4(sc, RK_GPIO_VERSION); > > >+ RK_GPIO_UNLOCK(sc); > > > > This call to rk_gpio_read_4() looks wrong: > > a) rk_gpio_read_4() tests sc->version which this call is setting. > > b) The second argument to rk_gpio_read_4() is a "enum gpio_regs", not > > an actual offset - RK_GPIO_VERSION (=3D0x78) is way outside the > > sc->regs array. > > c) sc->regs is also uninitialised at this point. > > > > Maybe this should call RK_GPIO_READ() instead, but neither my RK3328 > > TRM (revision 1.2 from July 2017) nor my RK3399 TRM (revision 1.4 from > > April 2017) document a GPIO register at offset 0x78 - both only go to > > 0x60. (If you have a later TRM for either chip, I would be interested > > in a copy). > > >=20 > Does the following patch work for you? >=20 > diff --git a/sys/arm64/rockchip/rk_gpio.c b/sys/arm64/rockchip/rk_gpio.c > index c3b1044df2f7..d41a9077d0cc 100644 > --- a/sys/arm64/rockchip/rk_gpio.c > +++ b/sys/arm64/rockchip/rk_gpio.c > @@ -259,12 +259,13 @@ static int > rk_gpio_attach(device_t dev) > { > struct rk_gpio_softc *sc; > - phandle_t node; > + phandle_t parent_node, node; > int err, i; >=20 > sc =3D device_get_softc(dev); > sc->sc_dev =3D dev; > sc->pinctrl =3D device_get_parent(dev); > + parent_node =3D ofw_bus_get_node(sc->pinctrl); >=20 > node =3D ofw_bus_get_node(sc->sc_dev); > if (!OF_hasprop(node, "gpio-controller")) > @@ -303,9 +304,11 @@ rk_gpio_attach(device_t dev) > return (ENXIO); > } >=20 > - RK_GPIO_LOCK(sc); > - sc->version =3D rk_gpio_read_4(sc, RK_GPIO_VERSION); > - RK_GPIO_UNLOCK(sc); > + /* RK3568 has GPIO_VER_ID register */ > + if (ofw_bus_node_is_compatible(parent_node, > "rockchip,rk3568-pinctrl")) > + sc->version =3D RK_GPIO_TYPE_V2; > + else > + sc->version =3D RK_GPIO_TYPE_V1; >=20 > switch (sc->version) { > case RK_GPIO_TYPE_V1: >=20 >=20 > Ganbold It does for me, thanks. --=20 Emmanuel Vadot