From owner-freebsd-arm@freebsd.org Thu Sep 21 06:26:11 2017 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D3438E172B5 for ; Thu, 21 Sep 2017 06:26:11 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.blih.net", Issuer "mail.blih.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 1A9206BA06; Thu, 21 Sep 2017 06:26:10 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) by mail.blih.net (OpenSMTPD) with ESMTP id 5b8d7571; Thu, 21 Sep 2017 08:26:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bidouilliste.com; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mail; bh=DwGI70uo09SajNBt9h25Oz7yDTc=; b=eBt6gBL+yCzI5ioqlyr8erP1+xtJ G3iij6J0VK27/yeHydPf/dSjgAX502nCUOJQVCxibmhAWqQzPE+tPHf1KgVUd/BM EJn/Z1IZtdO1WfMAvcCA9f+9ra7zneAxRwElH8ITWMpveF9ab/4cxtY8L7ERX8/k 4B9cqU1eyRVhFGE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=bidouilliste.com; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= mail; b=lCzL3fXI7ixTCfWIzYwpC+pVYQXa+Ltjv3kqPxWMQz/SvQLPD1rmq25U wDHgqCUW4u1qhx3a6Z+yzbi5R0rk3+M4P0nTlEWzNdUWFWqCQJ7if5AEwmw9eOA4 ipXMULtpiEbWa6zZgXrQUUyZ07V93ActhZ9AhT+5ojBRwpjaabQ= Received: from knuckles.blih.net (ip-54.net-82-216-203.roubaix.rev.numericable.fr [82.216.203.54]) by mail.blih.net (OpenSMTPD) with ESMTPSA id 33bcd313 TLS version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO; Thu, 21 Sep 2017 08:26:08 +0200 (CEST) Date: Thu, 21 Sep 2017 08:26:08 +0200 From: Emmanuel Vadot To: Mark Millard Cc: Emmanuel Vadot , freebsd-arm Subject: Re: allwinner question reformulalted: sc->phy_ctrl vs. sc->pmu[phyno], which should be used with PMU_UNK_H3 and PMU_UNK_H3_CLR? (sc->phy_ctrl actually used currently) Message-Id: <20170921082608.5e892da463226e8a80c032a8@bidouilliste.com> In-Reply-To: <3EFEF9A2-774E-4321-ABF0-49C1CD52ECFB@dsl-only.net> References: <5830ABC8-6544-4588-BDB6-483C2D1B3D3E@dsl-only.net> <3EFEF9A2-774E-4321-ABF0-49C1CD52ECFB@dsl-only.net> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; amd64-portbld-freebsd12.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Sep 2017 06:26:11 -0000 On Tue, 19 Sep 2017 10:51:46 -0700 Mark Millard wrote: > The modern, updated sys/arm/allwinner/aw_usbphy.c code uses > PMU_UNK_H3 and PMU_UNK_H3_CLR with sc->phy_ctrl : > > if (sc->phy_conf->pmu_unk1 == true) > CLR4(sc->phy_ctrl, PMU_UNK_H3, PMU_UNK_H3_CLR); This is a mistake, it should write using sc->pmu[phyno] as base, I'll correct that soon. > but uses sc->pmu[phyno] for PMU_IRQ_ENABLE and: > > PMU_ULPI_BYPASS | PMU_AHB_INCR8 | PMU_AHB_INCR4 | PMU_AHB_INCRX_ALIGN > > in: > SET4(sc->pmu[phyno], PMU_IRQ_ENABLE, PMU_ULPI_BYPASS | > PMU_AHB_INCR8 | PMU_AHB_INCR4 | PMU_AHB_INCRX_ALIGN); > > Having PMU_ not used with sc->pmu[phyno] looks a little odd. > > > For reference: the older code used: > > if (sc->phy_type == AWUSBPHY_TYPE_A64) { > CLR4(sc, phyno, PMU_UNK_H3, PMU_UNK_H3_CLR); > > and: > > if (phyno > 0) { > /* Enable passby */ > SET4(sc, phyno, PMU_IRQ_ENABLE, PMU_ULPI_BYPASS | > PMU_AHB_INCR8 | PMU_AHB_INCR4 | PMU_AHB_INCRX_ALIGN); > } > > > where: that involved use of: > > (sc)->res[(phyno)] > > via: > > #define RD4(sc, i, o) bus_read_4((sc)->res[(i)], (o)) > #define WR4(sc, i, o, v) bus_write_4((sc)->res[(i)], (o), (v)) > #define CLR4(sc, i, o, m) WR4(sc, i, o, RD4(sc, i, o) & ~(m)) > #define SET4(sc, i, o, m) WR4(sc, i, o, RD4(sc, i, o) | (m)) > > > === > Mark Millard > markmi at dsl-only.net > > On 2017-Sep-18, at 1:42 PM, Mark Millard wrote: > > > On 2017-Sep-18, at 1:30 PM, Mark Millard wrote: > > > It probably just my ignorance of the code's intent > > but for A64 it used to be that phyno ==1 had code > > that did CLR4 for phyno==0 (hard coded): > > > > if (sc->phy_type == AWUSBPHY_TYPE_A64) { > > CLR4(sc, phyno, PMU_UNK_H3, PMU_UNK_H3_CLR); > > > > /* EHCI0 and OTG share a PHY */ > > if (phyno == 0) > > SET4(sc, 0, OTG_PHY_CFG, OTG_PHY_ROUTE_OTG); > > else if (phyno == 1) > > CLR4(sc, 0, OTG_PHY_CFG, OTG_PHY_ROUTE_OTG); > > } > > > > So: that last CLR4 manipulated phyno==0 as far as I can tell, > > no matter what the passed-in phyno was. > > > > In the new code there seems to be no hook for phyno==1 > > to manipulate phyno==0 similarly: > > > > if (sc->phy_conf->phy0_route == true) { > > if (phyno == 0) > > SET4(sc->phy_ctrl, OTG_PHY_CFG, OTG_PHY_ROUTE_OTG); > > else > > CLR4(sc->phy_ctrl, OTG_PHY_CFG, OTG_PHY_ROUTE_OTG); > > } > > > > That CLR4 seems to be manipulating phyno==1 instead and > > seems to have no means of doing otherwise. > > > > Was the old code wrong? > > May be I asked the reverse of the right question: > that first CLR 4 in the old code varied by phyno but > now always uses phy_ctrl: > > if (sc->phy_conf->pmu_unk1 == true) > CLR4(sc->phy_ctrl, PMU_UNK_H3, PMU_UNK_H3_CLR); > > > Overall one part or the other seems to be a mismatch with the > old code for A64. > > === > Mark Millard > markmi at dsl-only.net > > _______________________________________________ > freebsd-arm@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-arm > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" > > _______________________________________________ > freebsd-arm@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-arm > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" -- Emmanuel Vadot