From owner-freebsd-current@FreeBSD.ORG Sat Oct 26 00:14:53 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 614F4105; Sat, 26 Oct 2013 00:14:53 +0000 (UTC) (envelope-from zbodek@gmail.com) Received: from mail-we0-x230.google.com (mail-we0-x230.google.com [IPv6:2a00:1450:400c:c03::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9765C2BCB; Sat, 26 Oct 2013 00:14:52 +0000 (UTC) Received: by mail-we0-f176.google.com with SMTP id w62so4476515wes.21 for ; Fri, 25 Oct 2013 17:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=Z3xllQRO0jqF5u77/jZ/MAvxmI/flYrNGm0/PcZJPvs=; b=BjWaHyjaO9MqPXEnowfUYZLlAjZyxaLpG4n4T9pJxd+8udwdtWpT27RLOlbNI12E8w dh0tdCLuJXrhwdGFhptehNLwMFFbfPaLWdYC6iG5eeWbJnj9mgCY/A7rsn8lJ9FESVHg fGt/8TVwjsRKY6vFr8nV6JecvhKV7CCpTepLcQmPWtAZSvEjdnfSk6hCNodSzwJYOmmq cSsjS9SijqqZLR4ICDOd1FdcYLBDnTv0bDvrauK+wSOE1x35rLR674pSKyE89F5fbvA1 8mBa5LZMTa7v4dU337JFESO13tjzgO+qAdzPS5Jz3qZF8PNz32T3CHyyH3s4o9W00Rr2 enfA== MIME-Version: 1.0 X-Received: by 10.194.176.163 with SMTP id cj3mr9477292wjc.8.1382746491120; Fri, 25 Oct 2013 17:14:51 -0700 (PDT) Sender: zbodek@gmail.com Received: by 10.216.209.194 with HTTP; Fri, 25 Oct 2013 17:14:50 -0700 (PDT) In-Reply-To: References: Date: Sat, 26 Oct 2013 02:14:50 +0200 X-Google-Sender-Auth: h6RAnr6P2r3Fv02KPefPv1btXeA Message-ID: Subject: Re: Changes to UART ns8250 From: Zbigniew Bodek To: "freebsd-embedded@freebsd.org" Content-Type: multipart/mixed; boundary=089e013cbfea6b0db604e999c193 Cc: "freebsd-arm@freebsd.org" , freebsd-current , Ganbold Tsagaankhuu X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Oct 2013 00:14:53 -0000 --089e013cbfea6b0db604e999c193 Content-Type: text/plain; charset=ISO-8859-1 Hello Everyone, I'm attaching the newest version of the ns8250 UART patch. After some discussions I decided to go with busy-wait + timeout solution. The applied delay should handle exotic corner cases (please notice that we can't use ns8250_delay() to get the actual single transmission time since we know that LCR is locked). If there are no objections then I would like to commit this soon. Best regards Zbigniew Bodek 2013/10/9 Zbigniew Bodek : > Hello Ganbold. > > Thank you for testing the patch and pointing those issue out. > My detection log from Armada XP: > > uart0: <16550 or compatible> mem 0xd0012000-0xd001201f irq 41 on simplebus0 > uart0: console (115200,n,8,1) > uart1: <16550 or compatible> mem 0xd0012100-0xd001211f irq 42 on simplebus0 > uart2: <16550 or compatible> mem 0xd0012200-0xd001221f irq 43 on simplebus0 > uart3: <16550 or compatible> mem 0xd0012300-0xd001231f irq 44 on simplebus0 > > Is there a possibility to download a datasheet for RK30xx so that I could > verify what is required for it's UART? > The patch is causing that we only wait until UART is not busy anymore. I > can't find why would that cause problems > if your UART requires busy detection anyway. > > Best regards > Zbigniew Bodek > > > > 2013/10/9 Ganbold Tsagaankhuu >> >> >> >> >> On Tue, Oct 8, 2013 at 9:58 AM, Ganbold Tsagaankhuu >> wrote: >>> >>> Zbigniew, >>> >>> >>> On Tue, Oct 8, 2013 at 3:54 AM, Zbigniew Bodek wrote: >>>> >>>> Hello. >>>> >>>> I would like to present a patch for ns8250 serial that I would like to >>>> commit in the near future (if there are no objections). >>>> >>>> The patch is fixing newest DesignWare UART with busy detection. >>>> During frequency divisors configuration when UART is busy transferring >>>> or >>>> receiving data, line control register manipulation will not take effect. >>>> Therefore, we will not set divisor latch access bit and we will corrupt >>>> LCR >>>> instead of configuring divisors. >>>> It is necessary to wait until UART finishes all transfers to proceed >>>> with >>>> the configuration. >>>> >>>> This was detected on Armada XP as UART fails on this issue 100/100 >>>> attempts. >>>> The patch was tested by kevlo@ and me and it works on our Armada XP - >>>> based >>>> systems. >>>> >>>> Please send your comment or remarks if there are any. >>> >>> >>> I'm trying your patch on r254983. >>> Tried on 2 boards (Cubieboard2 (Allwinner A20 SoC - dual Cortex A7) and >>> Radxa Rock (Rockchip RK3188 - Quad Cortex A9)). Both seem to have some sort >>> of DesignWare uart. >>> >>> 1. It works fine on Cubieboard2. Uart dmesg is like: >>> >>> uart0: <16750 or compatible> mem 0x1c28000-0x1c283ff irq 33 on simplebus0 >>> uart0: console (115200,n,8,1) >>> >>> 2. No any printing on screen in case of Radxa Rock. Without your patch >>> uart dmesg is like: >>> >>> uart0: <16650 or compatible> mem 0x20064000-0x200643ff irq 68 on >>> simplebus0 >>> uart0: console (115200,n,8,1) >>> >>> In case of RK3188 SoC, it seems booting FreeBSD kernel seems very >>> fragile, not sure yet what is causing the problem. >>> Even with stock ns8250 some version later than r254983 didn't show/print >>> anything on serial console few days ago. >>> Only thing so far I know is this r254983 (with some patch) works in my >>> case on RK3188 SoC based board. >> >> >> >> Zbigniew, >> >> Just tried again your patch on RK30xx board. I was able to see boot >> messages on screen. >> This uart detected as: >> ... >> uart0: <16650 or compatible> mem 0x20064000-0x200643ff irq 68 on >> simplebus0 >> uart0: console (115200,n,8,1) >> uart0: fast interrupt >> ... >> Can you show me your uart detection log? >> It seems this DW uart of RK30xx is different than DW uart of A10/A20. >> Boot simply stops printing "start_init: trying /sbin/init". >> >> thanks, >> >> Ganbold >> >> >>> >>> >>> thanks, >>> >>> Ganbold >>> >>> >>> >>>> >>>> >>>> Best regards >>>> Zbigniew Bodek >>>> >>>> _______________________________________________ >>>> freebsd-current@freebsd.org mailing list >>>> http://lists.freebsd.org/mailman/listinfo/freebsd-current >>>> To unsubscribe, send any mail to >>>> "freebsd-current-unsubscribe@freebsd.org" >>> >>> >> > --089e013cbfea6b0db604e999c193 Content-Type: application/octet-stream; name="0001-Wait-for-DesignWare-UART-transfers-completion-before.patch" Content-Disposition: attachment; filename="0001-Wait-for-DesignWare-UART-transfers-completion-before.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hn83jw4x0 RnJvbSAwYjIxZTI2MDYwZmM5Y2RmMjNlMTBmZDFiMWJlNTY2YjVjNzM4ZjJiIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBaYmlnbmlldyBCb2RlayA8emJiQHNlbWloYWxmLmNvbT4KRGF0 ZTogU2F0LCA1IE9jdCAyMDEzIDAyOjI1OjIzICswMjAwClN1YmplY3Q6IFtQQVRDSF0gV2FpdCBm b3IgRGVzaWduV2FyZSBVQVJUIHRyYW5zZmVycyBjb21wbGV0aW9uIGJlZm9yZQogYWNjZXNzaW5n IGxpbmUgY29udHJvbAoKV2hlbiB1c2luZyBEVyBVQVJUIHdpdGggQlVTWSBkZXRlY3Rpb24gaXQg aXMgbmVjZXNzYXJ5IHRvIHdhaXQKdW50aWwgYWxsIHNlcmlhbCB0cmFuc2ZlcnMgYXJlIGZpbmlz aGVkIGJlZm9yZSBtYW5pcHVsYXRpbmcgdGhlCmxpbmUgY29udHJvbC4gTENSIHdpbGwgbm90IGJl IGFmZmVjdGVkIHdoZW4gVUFSVCBpcyBidXN5LgpJbiBhZGRpdGlvbiwgaWYgRGl2aXNvciBMYXRj aCBBY2Nlc3MgQml0IGlzIGJlaW5nIHNldCBpbiBvcmRlciB0bwptb2RpZnkgVUFSVCBkaXZpc29y cz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