From owner-freebsd-hackers@freebsd.org Mon Oct 28 19:19:57 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 927B215ACFD for ; Mon, 28 Oct 2019 19:19:57 +0000 (UTC) (envelope-from freebsd-hackers@dino.sk) Received: from mailhost.netlabit.sk (mailhost.netlabit.sk [84.245.65.72]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4724Kl74Tvz4PSM for ; Mon, 28 Oct 2019 19:19:55 +0000 (UTC) (envelope-from freebsd-hackers@dino.sk) Received: from zeta.dino.sk (fw3.dino.sk [84.245.95.254]) (AUTH: LOGIN milan) by mailhost.netlabit.sk with ESMTPA; Mon, 28 Oct 2019 20:19:53 +0100 id 00F407EB.5DB73F59.00000B82 Date: Mon, 28 Oct 2019 20:19:52 +0100 From: Milan Obuch To: Oleksandr Tymoshenko Cc: freebsd-hackers@freebsd.org, Oliver Pinter Subject: Re: UART driver as kld - how? Message-ID: <20191028201952.20a92307@zeta.dino.sk> In-Reply-To: <20191028191005.GA89835@bluezbox.com> References: <20191027214209.712d62ca@zeta.dino.sk> <20191027232956.28b11772@zeta.dino.sk> <20191028191005.GA89835@bluezbox.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i386-portbld-freebsd11.3) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4724Kl74Tvz4PSM X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of freebsd-hackers@dino.sk designates 84.245.65.72 as permitted sender) smtp.mailfrom=freebsd-hackers@dino.sk X-Spamd-Result: default: False [-4.21 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[dino.sk]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[72.65.245.84.list.dnswl.org : 127.0.10.0]; IP_SCORE(-2.91)[ip: (-8.17), ipnet: 84.245.64.0/18(-4.08), asn: 16160(-2.40), country: SK(0.08)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:16160, ipnet:84.245.64.0/18, country:SK]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Oct 2019 19:19:57 -0000 On Mon, 28 Oct 2019 12:10:05 -0700 Oleksandr Tymoshenko wrote: > Milan Obuch (freebsd-hackers@dino.sk) wrote: [ snip ] > > Hi, > > > > my problem is somewhere else - I am able to build kld, load and > > unload it, but in all uart_dev_xxxx.c files I saw there are no > > attach and detach function, so there must be something more to do. > > On the other side, uart_core.o is already present in kernel, but > > how should I make it work with newly loaded module? uart_bus_fdt.o > > is linked in kernel too, and there are attach and detach function, > > but how can my tables be added in list for it? > > From what I see in source code, UART drivers with FDT support are > tied to the UART subsystem using UART_FDT_CLASS_AND_DEVICE macro, > that adds compat data (list of compatible strings for the driver > with pointer to respective uart_class instance) to > uart_fdt_class_and_device_set dataset. This dataset is then traversed > by uart_fdt_find_device in uart_fdt_probe function. > > You need: > > - Add FDT node to device tree, with unique compatible property value > and "status" property set to "okay" > - In you driver do something like: > > static struct ofw_compat_data compat_data[] = { > {"xlnx,axilite", (uintptr_t)&uart_axilite_class}, > {NULL, (uintptr_t)NULL}, > }; > UART_FDT_CLASS_AND_DEVICE(compat_data); > > xlnx,axilite in this case is just something I've just made up, you > need to get the value from the vendor's DTS bindings documentation. > Hi, I found uart_dev_snps.c being somewhat near what I need. I am trying to extract necessary bits from this and other files (what you wrote is just one bit), it seems our docs are lacking in this area. Regards, Milan