From owner-freebsd-drivers@freebsd.org Sun Sep 23 15:56:57 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3492A1091460 for ; Sun, 23 Sep 2018 15:56:57 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.cyclaero.com (ec2-18-195-62-44.eu-central-1.compute.amazonaws.com [18.195.62.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C43267A0B1 for ; Sun, 23 Sep 2018 15:56:56 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.obsigna.com (unknown [191.182.171.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.cyclaero.com (Postfix) with ESMTPSA id B990070 for ; Sun, 23 Sep 2018 17:56:48 +0200 (CEST) Received: from rolf.obsigna.com (rolf.obsigna.com [192.168.222.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.obsigna.com (Postfix) with ESMTPSA id 7EC3B1350F946 for ; Sun, 23 Sep 2018 12:56:43 -0300 (BRT) From: Dr. Rolf Jansen Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Writing a PCIe-Driver Message-Id: Date: Sun, 23 Sep 2018 12:56:41 -0300 To: freebsd-drivers@freebsd.org X-Mailer: Apple Mail (2.3445.9.1) X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Sep 2018 15:56:57 -0000 Hello, A couple of years ago, with the valuable help of people on this list, I = managed to write a PCI driver for the National Instruments DAQ card, NI = PCI-6251. The driver was kept very simple, only map the BAR=E2=80=99s = and some DMA memory into the user space. The DAC/ADC and DIO is then all = controlled from user space by writing command codes to certain offsets = from the mapped BAR=E2=80=99s, and reading data from the mapped DMA = memory and/or from other given offsets. See: How to map device addresses into user space = https://lists.freebsd.org/pipermail/freebsd-drivers/2013-January/thread.ht= ml Now, I need to do exactly the same for a PCIe card, namely the NI = PCIe-6351. However, I even cannot see where to start. For PCI cards, the = respective chapter 11 in the FreeBSD Architecture Handbook was quite = helpful, for getting started, in no time, I got the PCI card probed and = attached. https://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/pci.html The dumb approach, probing the device ID and attaching the PCI(e) driver = to the PCIe device in a similar fashion didn=E2=80=99t work - I didn=E2=80= =99t expect this either, however, where would I start? How do I attach = my driver to a PCIe card on FreeBSD 11 or 12? Please can somebody push me into the right direction. Once I got the = driver attached to the card, I guess, I would be able to adapt the = mem-mapping code of my old driver for the new card. Best regards Rolf From owner-freebsd-drivers@freebsd.org Mon Sep 24 02:45:26 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E0C210A24C4 for ; Mon, 24 Sep 2018 02:45:26 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.cyclaero.com (ec2-18-195-62-44.eu-central-1.compute.amazonaws.com [18.195.62.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E53488CB02 for ; Mon, 24 Sep 2018 02:45:25 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.obsigna.com (unknown [191.182.171.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.cyclaero.com (Postfix) with ESMTPSA id F1E3F6B for ; Mon, 24 Sep 2018 04:45:23 +0200 (CEST) Received: from rolf.obsigna.com (rolf.obsigna.com [192.168.222.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.obsigna.com (Postfix) with ESMTPSA id D0DBE1350F946 for ; Sun, 23 Sep 2018 23:45:19 -0300 (BRT) From: "Dr. Rolf Jansen" Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Writing a PCIe-Driver Message-Id: Date: Sun, 23 Sep 2018 23:45:18 -0300 To: freebsd-drivers@freebsd.org X-Mailer: Apple Mail (2.3445.9.1) X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 02:45:26 -0000 Hello, A couple of years ago, with the valuable help of people on this list, I = managed to write a PCI driver for the National Instruments DAQ card, NI = PCI-6251. The driver was kept very simple, only map the BAR=E2=80=99s = and some DMA memory into the user space. The DAC/ADC and DIO is then all = controlled from user space by writing command codes to certain offsets = from the mapped BAR=E2=80=99s, and reading data from the mapped DMA = memory and/or from other given offsets. See: How to map device addresses into user space = https://lists.freebsd.org/pipermail/freebsd-drivers/2013-January/thread.ht= ml Now, I need to do exactly the same for a PCIe card, namely the NI = PCIe-6351. However, I even cannot see where to start. For PCI cards, the = respective chapter 11 in the FreeBSD Architecture Handbook was quite = helpful, for getting started, in no time, I got the PCI card probed and = attached. https://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/pci.html The dumb approach, probing the device ID and attaching the PCI(e) driver = to the PCIe device in a similar fashion didn=E2=80=99t work - I didn=E2=80= =99t expect this either, however, where would I start? How do I attach = my driver to a PCIe card on FreeBSD 11 or 12? Please can somebody push me into the right direction. Once I got the = driver attached to the card, I guess, I would be able to adapt the = mem-mapping code of my old driver for the new card. Best regards Rolf From owner-freebsd-drivers@freebsd.org Mon Sep 24 04:54:04 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D214A10A43B0 for ; Mon, 24 Sep 2018 04:54:03 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: from mail-it1-x143.google.com (mail-it1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4816E8FC4A for ; Mon, 24 Sep 2018 04:54:03 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: by mail-it1-x143.google.com with SMTP id c23-v6so700486itd.5 for ; Sun, 23 Sep 2018 21:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=iwGj/JBelbefNTvsX6JNjrwVFw/1ivuLC4TLYKGd/Lo=; b=Sx30s9OFxJxQZnTZFgMBAIswl80H2NtOlU2XrGcmAWG/a/t60wyd1SEpV5q7iExfT7 VwB8nGOgwmCO2CZE8wAoO9Ikl4uJ0sOS+HAZ541qklZEMWI6JuGTHHeZhSsw/pNBtbTv lJIp352Bom4gECE13GXx1PVPVr/Emr/q8PFA5Nu0boNRVI2pOz0M62nbj2jDocPP7czq OnSb3hdS1FEyY/nN4Cknj+xrGZVnZrzMbOaAAVPLEtOXJEWsuq8lpq8N2h9d+yDP/IFy axGt4PNEgxPow9YU3uy9UmShBbmtZGA+8pb+s89j2iL51gLIYYYauZ59d9SqcQpjikvA F82A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=iwGj/JBelbefNTvsX6JNjrwVFw/1ivuLC4TLYKGd/Lo=; b=tigYsvJsfTpbajc5CB+lBE6TrVOWezt8HPDo3ZI6ngzuEgJfrzQ2PGQkzpTvnv91EX dlxw1SNwCXnuGUJvSLtAD3MkNS+Wk80PpQB87o6KQitSiiQNa0Lrh8NU9KylXxrxD2oE SKhi70h0eksS3r6WfRcAia7Jz+8xSETmdZhF9xn4r4pkjP3WjkIE7bJGRSIoLQYbHcT3 unuUvdyXDZ30hKJ7zVqNuLLILsDUKwHKoM26bY/SSrDNjj7eRky2Rzb51VkuCnNtAchX 3p4ggLIZvDkD0rdrc5CoqUU7AQxwXaKJ43I+m4wo7yn7+0M7a6JbdvvYs/Eos7cpOuTZ s+Ng== X-Gm-Message-State: ABuFfoifcweuVfscu8D/tcKQ12AoQG11/QU87TJzywrhcBUO8waJrZ+7 imhl3Kciu2o9Fjx4dVhpqJ7DdcMHRLwk2jrm27fVmNJi X-Google-Smtp-Source: ACcGV61MoWQCtWQO0F6OoxIRyZS0gzRqN+xG6BLKfhmt5sYqqBUSJTbQrMnDX1I87KdS0WLUKt3BRinQkYq56eFZrsQ= X-Received: by 2002:a24:b60a:: with SMTP id g10-v6mr6552358itf.55.1537764842230; Sun, 23 Sep 2018 21:54:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Farhan Khan Date: Mon, 24 Sep 2018 00:53:50 -0400 Message-ID: Subject: Re: Writing a PCIe-Driver To: rj@obsigna.com Cc: freebsd-drivers@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 04:54:04 -0000 Hi Rolf, I have been reading up on this code myself. I do not claim expertise, so hopefully others can chim in here if I make a mistake. On the WiFi side of things, I've pretty consistently I've seen the following routine: A call to pci_find_cap(9), typically as follows from the WiFi code I've looked into: pci_find_cap(dev, PCIY_EXPRESS, &sc->sc_cap_off); A write to clear the PCI Retry timeout, by writing 0x41 to the device with pci_write_config(9): pci_write_config(dev, 0x41, 0, 1); Obtain the base address registers using PCIR_BAR(), an abstraction of bus_alloc_resource(), and store that value. rid =3D PCIR_BAR(0) Allocate IO DMA memory to the device: sc->sc_mem =3D bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE)= ; Most drivers check this return value and return ENXIO if the value is NULL. I do not fully understand what rman_get_bustag(9) does, but I see this called on all drivers I've looked at as follows: sc->sc_st =3D rman_get_bustag(sc->sc_mem); sc->sc_sh =3D rman_get_bushandle(sc->sc_mem); Typically I see Interrupt handler code setup here. In the case of rtwn(4) and iwm(4). This might not be relevant to your driver, depending on what it does. I see a call to pci_alloc_msi as follows: rid =3D 1; if (pci_alloc_msi(dev, &rid) =3D=3D 0) rid =3D 1; else rid =3D 0; pci->irq =3D bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | (rid !=3D 0 ? 0 : RF_SHAREABLE)); Then assign an interrupt handler function as follows so you know to read from the DMA. error =3D bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_NET | INTR_MPSAFE, NULL, your_function_here, sc, &sc->sc_ih); Capture the DMA tag as follows: sc->sc_dmat =3D bus_get_dma_tag(sc->sc_dev); >From here, I see the following sequence: 1. bus_dma_tag_create(), where the first argument is the DMA tag (sc->sc_dmat), and the last argument is the memory it is mapped to. 2. bus_dmamem_alloc() 3. bus_dmamap_load() 4. bus_dmamap_sync() At this point, you may need to initialize the interrupts, depending on your hardware. If/when the interrupt arrives, you need to determine what type it is and read from the DMA memory, as allocated in the DMA sequence. On every assign and allocation you should also do error-checking on all return values. That is my understanding. Again, someone else can jump in if I made a mistake. I read rtwn(4), iwm(4) and iwi(4) while writing this and they are excellent references. Hope this helps! -- Farhan Khan PGP Fingerprint: B28D 2726 E2BC A97E 3854 5ABE 9A9F 00BC D525 16EE On Sun, Sep 23, 2018 at 10:46 PM Dr. Rolf Jansen wrote: > > Hello, > > A couple of years ago, with the valuable help of people on this list, I m= anaged to write a PCI driver for the National Instruments DAQ card, NI PCI-= 6251. The driver was kept very simple, only map the BAR=E2=80=99s and some = DMA memory into the user space. The DAC/ADC and DIO is then all controlled = from user space by writing command codes to certain offsets from the mapped= BAR=E2=80=99s, and reading data from the mapped DMA memory and/or from oth= er given offsets. > > See: How to map device addresses into user space > https://lists.freebsd.org/pipermail/freebsd-drivers/2013-January/thread.h= tml > > > Now, I need to do exactly the same for a PCIe card, namely the NI PCIe-63= 51. However, I even cannot see where to start. For PCI cards, the respectiv= e chapter 11 in the FreeBSD Architecture Handbook was quite helpful, for ge= tting started, in no time, I got the PCI card probed and attached. > > https://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/pci.html > > The dumb approach, probing the device ID and attaching the PCI(e) driver = to the PCIe device in a similar fashion didn=E2=80=99t work - I didn=E2=80= =99t expect this either, however, where would I start? How do I attach my d= river to a PCIe card on FreeBSD 11 or 12? > > Please can somebody push me into the right direction. Once I got the driv= er attached to the card, I guess, I would be able to adapt the mem-mapping = code of my old driver for the new card. > > Best regards > > Rolf > _______________________________________________ > freebsd-drivers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org= " From owner-freebsd-drivers@freebsd.org Mon Sep 24 10:04:50 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC11010A8340 for ; Mon, 24 Sep 2018 10:04:50 +0000 (UTC) (envelope-from fesse@mail.ru) Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [94.100.177.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 60FBB77E20 for ; Mon, 24 Sep 2018 10:04:50 +0000 (UTC) (envelope-from fesse@mail.ru) Received: by smtp52.i.mail.ru with esmtpa (envelope-from ) id 1g4NjM-0006k2-Sk for freebsd-drivers@freebsd.org; Mon, 24 Sep 2018 13:04:41 +0300 Date: Mon, 24 Sep 2018 13:04:39 +0300 From: fesse To: freebsd-drivers@freebsd.org Subject: Meaning of SND_FORMAT macro parameters (used in sound subsystem) Message-Id: <20180924130439.fcf1244b47d668bb632cefb9@mail.ru> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; amd64-portbld-freebsd11.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-7FA49CB5: 0D63561A33F958A5B2F8994611CA88B079CFC50F54B72682CE5E223FC43BDEDF8941B15DA834481FA18204E546F3947CB861051D4BA689FCF6B57BC7E64490618DEB871D839B7333395957E7521B51C2545D4CF71C94A83E9FA2833FD35BB23D27C277FBC8AE2E8BF80095D1E57F4578A471835C12D1D977C4224003CC8364767815B9869FA544D8090A508E0FED62991661749BA6B977352D242C3BD2E3F4C6E0C89D67371282C4A18204E546F3947CEB7D890E3377C531BA3038C0950A5D36581343779C53C132BD4B6F7A4D31EC0B7815B9869FA544D8EC76A7562686271E6BA297DBC24807EA089D37D7C0E48F6C8AA50765F7900637AB284148C4A7EEA4429A6EC72387C178089D37D7C0E48F6C5571747095F342E857739F23D657EF2B6825BDBE14D8E702ABEDDA51113D120200306258E7E6ABB4E4A6367B16DE6309 X-Mailru-Sender: 2B3E4445EA68B43AA08D39482F5388B72742E1506008065D5C830385768904967BA6DE242C35196B018169F45A5A01163DDE9B364B0DF289D592A919D7B92FD208E29FF3D9B2F13D0DA7A0AF5A3A8387 X-Mras: OK X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 10:04:51 -0000 Good day to everyone, SND_FORMAT macro is defined in sound.h: #define SND_FORMAT(f, c, e) (AFMTT_ENCODING(f) | (((c) << AFMT_CHANNEL_SHIFT) & AFMT_CHANNEL_MASK) | (((e) << AFMT_EXTCHANNEL_SHIFT) & AFMT_EXTCHANNEL_MASK)). Many sound drivers define data format like this: SND_FORMAT(AFMT_S16_LE, 2, 0); Sound guys, tell me please what means "2" and "0", i.e. "c" and "e" macro arguments. I really in doubt... From owner-freebsd-drivers@freebsd.org Mon Sep 24 13:23:01 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98FA710AC07B for ; Mon, 24 Sep 2018 13:23:01 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0187F808DE for ; Mon, 24 Sep 2018 13:23:01 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: by mail-wm1-x32b.google.com with SMTP id l7-v6so4879499wme.2 for ; Mon, 24 Sep 2018 06:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ZTLrnCFP0SJcEg8np66ETQyaflkZ5Dc+n7WA9wLCIuo=; b=RlZg4clQLacjvvoD96Qza4/e9Ei1UhQ/fB7xzxly1KX1iIrNhZzgZBXyHtY3rXVnhN 2QvXC8W7ncTpmiafT57LO41UI+ABYyVaWRagJeqpWCOBfCPxUsuozaLENuC5z+d5gON7 KKlSxZF9thHpABeeKbOjEEWFa48gtRQogkbgdYWer9yLmAdOtYFWWuPjtyZtAeW030Jp 8dHZ7jQtBj6XVElFttC9OiKOCFPjgF14Z163rC5iiWjbZevUG2VCEcbOoNak6vmKjJJa 749i2eC5kwrujFgy+3OhCloqUgXTOj5EaaIzbxpL+O9DOhkTPtvcWQVyIB+AVPlbJDo+ mZwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ZTLrnCFP0SJcEg8np66ETQyaflkZ5Dc+n7WA9wLCIuo=; b=l67088R4QeqkLnmCTVMlm4kILB1KO2ieUaVZODRN+Tx5dVvN1weNwBrUZAcCKLc+0T x/Lb23TlHtTOVBOF7sirq9ohizmu/mfn26faDu65iC9X5xXopISura9TsgcgXXJ9e2mx CaMdasYWKhpwtQ81sYiWh6ZZtbLZM3TgPZ8rmNv9B6GVJQBky0O2fazrjpKfAEFitqGb LTZOfzvidGEQVv690uv8bM/WItZ+ZCrhlBq+LmgVis4+IspZSzTs3vwHp7J9FT9TyoNc vKpdXnnDBauNATh9AWi1Druhh4XadeKlPEH4+TuiZ0tHjr54I/jP/sQ/Rtn9gMWO0x8N bJQg== X-Gm-Message-State: APzg51A4GW1FMMsriymPxljWYWJ0P9Vl1t1xu2thFP1p1+JQp/hYI6uC 18hRRY8xEzpUR9o0TV+lHtLMNZHzio8A+4dpFoQVWg== X-Google-Smtp-Source: ACcGV61uO9c5C9PKIYx0jAcBmWzsg9bAPPRYZMwAg8QBzQSw3d62YruwA8IYQm51C1fcQEioBbABCeXqOE2r0ZCTlGk= X-Received: by 2002:a1c:9c56:: with SMTP id f83-v6mr7025637wme.135.1537795379593; Mon, 24 Sep 2018 06:22:59 -0700 (PDT) MIME-Version: 1.0 From: Rajesh Kumar Date: Mon, 24 Sep 2018 18:52:47 +0530 Message-ID: Subject: Do we have a equivalent for Linux pinctrl framework in FreeBSD? To: freebsd-drivers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 13:23:01 -0000 Hi Everyone, Do we have a pinctrl subsystem in FreeBSD which is kind of equivalent to the Linux Pinctrl subsystem? I have a GPIO controller which is attached on the ACPI bus (on amd64 platform). I am trying to add the support to configure the pins as interrupts. I looked to use the INTRNG framework, but that seems to be not available for amd64 platforms. So, I am exploring the pinctrl framework available in FreeBSD, but that seems available only for FDT devices. So, Is there any way I can use this pinctrl framework for my purpose (or) is there anything else I need to look after? Thanks, Rajesh. From owner-freebsd-drivers@freebsd.org Mon Sep 24 13:40:43 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CCE8210AC5E9 for ; Mon, 24 Sep 2018 13:40:43 +0000 (UTC) (envelope-from gurenchan@gmail.com) Received: from mail-it1-x12a.google.com (mail-it1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 09F8581032 for ; Mon, 24 Sep 2018 13:40:43 +0000 (UTC) (envelope-from gurenchan@gmail.com) Received: by mail-it1-x12a.google.com with SMTP id w200-v6so2303743itc.4 for ; Mon, 24 Sep 2018 06:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hTsLHH+x1icl+bodtHd7ci9rPD/4iwamJOqH7Rk/IQo=; b=MKCd98oOOkBRMJOhKwbIVYN8qvHjuiVVH2baUx55t6Dm7L8GTYQrjUVE7llCvtOxS4 s9l1czMJbmN7eCLFwfbNIYfkKVl8zMTFjRgOaRMDAc5zqb5qVk2XRBxUAMw/oTeb6ebX 0ovdEMoyAd4bCjimva0DRaT4PRXc7FovW2Q4aqt5L5ywYHs00nvY2M89XAF6SqMC/Hmq JBzQURiCG5rjmUbL3i/iXjy6lZF5KIMO57XEcrCAEBkMbgQn9Ga/3uGq/zaxlU+Ukc2P I2N5jnCIbhw+GJFF9DUIlbBPNUhUNDlO4jSy5y4mde2bSvMLt8fomepD2TlH/2dKDwvq L8vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hTsLHH+x1icl+bodtHd7ci9rPD/4iwamJOqH7Rk/IQo=; b=bP+yLxhoQyepRRtmKSLD1kQNq+IOB6kY3Zb+zqV/0h9FKsyhmnHNuNoh1IcdYbQRog kLh58a4BpOtHIxl+8hS/NA4kDERJXmIT9XhVR/ghGr/UkCZtritdMt6VtWO1lQ66BJF8 fs9x/fGM1Id1zFb7zzNSbLi4sgw3TEmhjkdPufPSwF2qNwE4N0MPfaSImgbunSoCNAnN FLwjETVILuh/BSGeiXE66CqEYy+5LlvE9+uTkX6XxJz2WPcOl/pUTHgML+LROjmNErHN lMGdSqM7R6Y6DYUfKy3tBpV41FvzTiFHzAp0rkOYCHycRdbUawOq7m9O7fRp8+plZdCe Meyw== X-Gm-Message-State: ABuFfog14LbcWKPr0gaSbYHHHQjwRtpwoL5J0WAmDBixx5tgQ1N3/RN7 ljcEB891i0ELM52nE/gfs+3dzrFxYFSOGs3yQjA= X-Google-Smtp-Source: ACcGV61ljbKfjGYKoaHb8gNuCdi3WAwhrvqAHkvELQXVgPTYD77I5A7LlFHhgK0Rs+f/78YCVMxU9BxjzKkYmmCIbws= X-Received: by 2002:a24:7c4a:: with SMTP id a71-v6mr7817748itd.69.1537796442474; Mon, 24 Sep 2018 06:40:42 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: blubee blubeeme Date: Mon, 24 Sep 2018 21:41:39 +0800 Message-ID: Subject: Re: Do we have a equivalent for Linux pinctrl framework in FreeBSD? To: Rajesh Kumar Cc: freebsd-drivers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 13:40:44 -0000 On Mon, Sep 24, 2018, 21:23 Rajesh Kumar wrote: > Hi Everyone, > > Do we have a pinctrl subsystem in FreeBSD which is kind of equivalent to > the Linux Pinctrl subsystem? > > I have a GPIO controller which is attached on the ACPI bus (on amd64 > platform). I am trying to add the support to configure the pins as > interrupts. I looked to use the INTRNG framework, but that seems to be not > available for amd64 platforms. So, I am exploring the pinctrl framework > available in FreeBSD, but that seems available only for FDT devices. So, > Is there any way I can use this pinctrl framework for my purpose (or) is > there anything else I need to look after? > > Thanks, > Rajesh. > _______________________________________________ > freebsd-drivers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.or > This might be helpful: https://reviews.freebsd.org/D14104?id=38750 > > From owner-freebsd-drivers@freebsd.org Mon Sep 24 14:14:10 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 34CE710AD3CA for ; Mon, 24 Sep 2018 14:14:10 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A9B0E8260F for ; Mon, 24 Sep 2018 14:14:09 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: by mail-wm1-x32a.google.com with SMTP id l7-v6so5078840wme.2 for ; Mon, 24 Sep 2018 07:14:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jG02SFFPEMaUXjqUMajIgyhojw4G54R3n9ppaJXEFQQ=; b=LmSCwyrCX+idPUK8B31j/yAHl1uXbP7jhwtkI6wUZbX8QA4z32dZmq9ajnnlZwFJiy kp8Rvl0nMMvhszED1B+9g4qrawikSN5Ae8bGWUQpMWSs3jTgI0ZLgxxc/7p1ObwoEjCP n1LmAfzwJUMgTxveUiFkWZs8k4JPD32kW6wbKyiPX1e03441EU9jy0MiCcUWoF4Zm1kt S3OizFBUbGqXBeLSeVKoBk89hm8kJhy4D57tdM9FT4WAzU0gSMlnFFDiDuiE7yl8cxGv u5giz1VbeAU80WBPxls3yEHOkhBb1j/mGNzLqq1AlqOrszrkTx7w48HxtlM+JXguEFxH oZeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jG02SFFPEMaUXjqUMajIgyhojw4G54R3n9ppaJXEFQQ=; b=O59mE70wWseJ+AkJqu/cJxvtvUdHGDPNagwk8BS/agKr1+Ua2tYPGbFFYS/lXc8Npq TKbVHBejjFVR6yBIu3Vq1s06R7YrRCAqA0/eX122UglMeP1qTZReLMHm9E6hjaq2hxcV 23ZH1j9yMhQnoRnhcdWT4eypiy/604Uvz1uYTo2QYmlDKkI1LGJkd9RLXB04W8G0RWGe /dw1HvRLQCP/7FpBTlWjnYO2AsCw423SwRvFoUmKWs7x52G/1rIjul1EyltWBE4JV/V4 3bHwTziKi9sxejUbj0upBI8KDcFucr6QSy7v1tIkOnjgaST9pSEncPJzx69bRa91AnEu JG6g== X-Gm-Message-State: APzg51DyHCrvCWkXbQIzuN3rclEL5K1uBw/4NfB79DPKBA5/RUH7A1ST hqN/u8NVbzwlUmaeZlSbCj02kcO0bWdq6V5dghWndA== X-Google-Smtp-Source: ACcGV60+4qsVnlMS2/pf/5u5fQhYsjy134L2IrQu+NMgQyFl1BWKxFsAtUa0LbTWDGAfldccg9qmS3KSHxE3/P1vHm4= X-Received: by 2002:a1c:9c56:: with SMTP id f83-v6mr7238472wme.135.1537798448514; Mon, 24 Sep 2018 07:14:08 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rajesh Kumar Date: Mon, 24 Sep 2018 19:43:56 +0530 Message-ID: Subject: Re: Do we have a equivalent for Linux pinctrl framework in FreeBSD? To: blubee blubeeme Cc: freebsd-drivers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 14:14:10 -0000 Thanks for your response Blubee. This show the usage of pinctrl framework with FDT attached devices with ARM platform. I guess fdt_pinctrl will work with amd64 also, but will it be working with ACPI attached devices? On Mon, Sep 24, 2018 at 7:10 PM blubee blubeeme wrote: > > > On Mon, Sep 24, 2018, 21:23 Rajesh Kumar wrote: > >> Hi Everyone, >> >> Do we have a pinctrl subsystem in FreeBSD which is kind of equivalent to >> the Linux Pinctrl subsystem? >> >> I have a GPIO controller which is attached on the ACPI bus (on amd64 >> platform). I am trying to add the support to configure the pins as >> interrupts. I looked to use the INTRNG framework, but that seems to be >> not >> available for amd64 platforms. So, I am exploring the pinctrl framework >> available in FreeBSD, but that seems available only for FDT devices. So, >> Is there any way I can use this pinctrl framework for my purpose (or) is >> there anything else I need to look after? >> >> Thanks, >> Rajesh. >> _______________________________________________ >> freebsd-drivers@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers >> To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.or >> > > > This might be helpful: https://reviews.freebsd.org/D14104?id=38750 > >> >> From owner-freebsd-drivers@freebsd.org Mon Sep 24 14:21:21 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CF60C10AD684 for ; Mon, 24 Sep 2018 14:21:20 +0000 (UTC) (envelope-from gurenchan@gmail.com) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 602E382A08 for ; Mon, 24 Sep 2018 14:21:20 +0000 (UTC) (envelope-from gurenchan@gmail.com) Received: by mail-io1-xd2f.google.com with SMTP id q5-v6so17736457iop.3 for ; Mon, 24 Sep 2018 07:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FjE6sH0Y5FR2yB8vVzV1wbbAZK6guUjY3fy0zCkShvE=; b=bF2b5WN0Bv6DJyT4VI41GegI+2Oe1O3S6Ujcd0/HK8L0mhTuicmcP7OBfwoB12O+Je ZwYQUGB360yev17wz9IsU/d/giW2yeMHeRiF9rh0L7XosqJ0BChSjAUdqLPtkA/Xg0Y9 K4xms24XS6mSfYxDOHaTc+/ykGQPrZu5dv1esjfTSDKcn9idICNcNQFdz6JZGwq5B+aP HolODvyTKjfqcqzHIGUdfNRl8+P1sdUOGKQFof+BCufjio9pVVbfJRz5bujf2kWkW4Ev DaOvVtGdpd1Neg3fsJFr79Ex/xgTIgwfFx1pBxc4ltkKvviVXXXGjKGvq3cTWWGfgNfD LSlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FjE6sH0Y5FR2yB8vVzV1wbbAZK6guUjY3fy0zCkShvE=; b=rMnDdSYK7MTSa6FsC9pZcxnRdCkLwO/esdIRHNBU2WArLcL6RWdWGxzwSsEmH1b45f eU/NBM07Pg9Um8NTOtxL3PkOPks7SXXwmsRDXNnZ4BdXGgxlZOh6Sx8h5ShXjhZBnpHE TI0ZlIcLoAG+Z81MeBQzjZaslXhN/rmKZxzaKv91EIGYP8evZ+Mz64EvGVzyT7DhDNgW CNWqoH8NOBX36gzwT6SlCrlWw844qWJyynWpBIobT5wLzWp4h2NMzo9/rynUlY1eSv9U udzqOSScctDy02bhwG/T6rkAYcqwdLL9bmSjw0Fz5rpZ1ac8A9Z9lF/0A0mEnQMQO9v0 NKQQ== X-Gm-Message-State: ABuFfohGQyC39ti9h4wAaF5hf40jG97mgudWdnqALsroeY/E0yzy1d+H jpikCB0NKgHHuKSL2YsKLnmgpMBh0mnnTCYwJlPXHg== X-Google-Smtp-Source: ACcGV624rN/cc9+ZN5k6iyc4/bgNkU7YTSjOVGKlFFrxZHQwW01l7RnXOD3KHL+EjrUsBCL7UPOEZgK+4sGxIC9nvuY= X-Received: by 2002:a5e:890c:: with SMTP id k12-v6mr7885071ioj.136.1537798879800; Mon, 24 Sep 2018 07:21:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: blubee blubeeme Date: Mon, 24 Sep 2018 22:22:17 +0800 Message-ID: Subject: Re: Do we have a equivalent for Linux pinctrl framework in FreeBSD? To: Rajesh Kumar Cc: freebsd-drivers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 14:21:21 -0000 On Mon, Sep 24, 2018, 22:14 Rajesh Kumar wrote: > Thanks for your response Blubee. > > This show the usage of pinctrl framework with FDT attached devices with > ARM platform. I guess fdt_pinctrl will work with amd64 also, but will it > be working with ACPI attached devices? > > On Mon, Sep 24, 2018 at 7:10 PM blubee blubeeme > wrote: > >> >> >> On Mon, Sep 24, 2018, 21:23 Rajesh Kumar wrote: >> >>> Hi Everyone, >>> >>> Do we have a pinctrl subsystem in FreeBSD which is kind of equivalent to >>> the Linux Pinctrl subsystem? >>> >>> I have a GPIO controller which is attached on the ACPI bus (on amd64 >>> platform). I am trying to add the support to configure the pins as >>> interrupts. I looked to use the INTRNG framework, but that seems to be >>> not >>> available for amd64 platforms. So, I am exploring the pinctrl framework >>> available in FreeBSD, but that seems available only for FDT devices. So, >>> Is there any way I can use this pinctrl framework for my purpose (or) is >>> there anything else I need to look after? >>> >>> Thanks, >>> Rajesh. >>> _______________________________________________ >>> freebsd-drivers@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers >>> To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.or >>> >> >> >> This might be helpful: https://reviews.freebsd.org/D14104?id=38750 >> >>> I'm not 100% certain on that, I am also doing some stuff with the gpio and decided to just get the pi running FreeBSD and do most of my work through that. Best, Owen From owner-freebsd-drivers@freebsd.org Mon Sep 24 17:10:53 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86BF610B26FC for ; Mon, 24 Sep 2018 17:10:53 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 03A678A656 for ; Mon, 24 Sep 2018 17:10:53 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: by mail-wm1-x32d.google.com with SMTP id n11-v6so10812061wmc.2 for ; Mon, 24 Sep 2018 10:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2YmYwjGVE0BUQAjkTZoOjS3AgavEobzD0YOqBHwQ7a0=; b=HW8FFtEN4EskemKa0uATZCYorKcMMRDoyEHT6evEbMi42BYxHLecIaM3j5VoxCQsej Fp5Z2/Pwn6rZBB69rmoAMtG/c25FDZbth+ZxW9P2n3R9luNdTmahQyMFGPAMnof77l5b F4dtyMoh3MZu+GmdTank1X3mW4+YonVRVuKE0Ngc231d28GsYMppiDon5s8IE3W6VBjT kAM8DcPG4v9mjSFmSwZsvm5iRjkWiyQr/akIn6VBGSeDVmluiF6CrA4MT6A0sDrS/rA2 ymjROShI5i9ZQbP2aybnt1SzJaEEQZImDUp2n9f94bsGNvWGkKY3D48Aq84JnIg2o3Qp F4IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2YmYwjGVE0BUQAjkTZoOjS3AgavEobzD0YOqBHwQ7a0=; b=mpFdsrkX/hdP590Ohp7T/sj42OCxWJgt+iI3Z60miONp42ONcKRID5vfs6R+vzyOyy Angx24n8Kcymh2DLQYYPYlfNUBSN+cLmh660ycvsn3XYLtzfGdZc0N5dj+ZBZ4n7Yvjf RnTnp1thONSf6YFafg0Td0ulkkW/bpwudT1USX9e7JDPn5KD5GdFLksLp7A/d6vcxin8 ObdYgJ1lhadU0Pgibyzm1UKZwJYwbWQhBkHiC1J8CsTH5jt2epgu3tKErxt5NqUy/5zu zfdu6jeSQzvr+b6Q7fW2YrLmJFcSL8fZw6sfreQmWe0bTU+ZoomwUaLTLQgQO9K5Zvde FM4Q== X-Gm-Message-State: APzg51CXWEa6arF7y6ECCRUyNGHsF0k17IkjeCrsD++A2TR08zxGLeeW RSB7rGM4nIm1kyBV5MKNOOuO3d2/Upt7r7Ng1dRhwQ== X-Google-Smtp-Source: ACcGV62pLokwQZdCUKsbp/RsJwve589Q1A0hc0mHdXc8QM/zC6Yr5rEGKFmgXjU5aa9LUCneb8llHTliBLvbQgnIaI4= X-Received: by 2002:a1c:9c56:: with SMTP id f83-v6mr7969462wme.135.1537809051760; Mon, 24 Sep 2018 10:10:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rajesh Kumar Date: Mon, 24 Sep 2018 22:40:39 +0530 Message-ID: Subject: Re: Do we have a equivalent for Linux pinctrl framework in FreeBSD? To: blubee blubeeme Cc: freebsd-drivers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 17:10:53 -0000 Fine Blubee. For ARM based platforms, necessary support like INTRNG, FDT etc., are in place. So, I hope things should be good to get FreeBSD running properly in Pi. All the best. Anyway, Thanks again for your time Blubee. On Mon, Sep 24, 2018 at 7:51 PM blubee blubeeme wrote: > > > On Mon, Sep 24, 2018, 22:14 Rajesh Kumar wrote: > >> Thanks for your response Blubee. >> >> This show the usage of pinctrl framework with FDT attached devices with >> ARM platform. I guess fdt_pinctrl will work with amd64 also, but will it >> be working with ACPI attached devices? >> >> On Mon, Sep 24, 2018 at 7:10 PM blubee blubeeme >> wrote: >> >>> >>> >>> On Mon, Sep 24, 2018, 21:23 Rajesh Kumar wrote: >>> >>>> Hi Everyone, >>>> >>>> Do we have a pinctrl subsystem in FreeBSD which is kind of equivalent to >>>> the Linux Pinctrl subsystem? >>>> >>>> I have a GPIO controller which is attached on the ACPI bus (on amd64 >>>> platform). I am trying to add the support to configure the pins as >>>> interrupts. I looked to use the INTRNG framework, but that seems to be >>>> not >>>> available for amd64 platforms. So, I am exploring the pinctrl framework >>>> available in FreeBSD, but that seems available only for FDT devices. >>>> So, >>>> Is there any way I can use this pinctrl framework for my purpose (or) is >>>> there anything else I need to look after? >>>> >>>> Thanks, >>>> Rajesh. >>>> _______________________________________________ >>>> freebsd-drivers@freebsd.org mailing list >>>> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers >>>> To unsubscribe, send any mail to " >>>> freebsd-drivers-unsubscribe@freebsd.or >>>> >>> >>> >>> This might be helpful: https://reviews.freebsd.org/D14104?id=38750 >>> >>>> I'm not 100% certain on that, I am also doing some stuff with the gpio > and decided to just get the pi running FreeBSD and do most of my work > through that. > > Best, > Owen > From owner-freebsd-drivers@freebsd.org Mon Sep 24 18:37:07 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44E3310B44DF for ; Mon, 24 Sep 2018 18:37:07 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.cyclaero.com (ec2-18-195-62-44.eu-central-1.compute.amazonaws.com [18.195.62.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B6D3C8D9E5 for ; Mon, 24 Sep 2018 18:37:05 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.obsigna.com (unknown [191.182.171.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.cyclaero.com (Postfix) with ESMTPSA id 3EC8971; Mon, 24 Sep 2018 20:30:19 +0200 (CEST) Received: from rolf.obsigna.com (rolf.obsigna.com [192.168.222.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.obsigna.com (Postfix) with ESMTPSA id 4CBD61350F946; Mon, 24 Sep 2018 15:30:16 -0300 (BRT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: Writing a PCIe-Driver From: "Dr. Rolf Jansen" In-Reply-To: Date: Mon, 24 Sep 2018 15:30:14 -0300 Cc: freebsd-drivers@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <0E9C0EFE-F2EE-47A3-B7E6-60E9404E3904@obsigna.com> References: To: Farhan Khan X-Mailer: Apple Mail (2.3445.9.1) X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 18:37:07 -0000 Farhan, Thank you very much for sharing your findings. I will also look into the = code, and I started with checking out the FreeBSD source tree to my = development machine, so examine the code of the various drivers is more = easy. Anyway, the outline which you revealed is already a good starting = point, and it will help me a lot to find my way in the jungle. Best regards Rolf > Am 24.09.2018 um 01:53 schrieb Farhan Khan : >=20 > Hi Rolf, >=20 > I have been reading up on this code myself. I do not claim expertise, > so hopefully others can chim in here if I make a mistake. On the WiFi > side of things, I've pretty consistently I've seen the following > routine: >=20 > A call to pci_find_cap(9), typically as follows from the WiFi code > I've looked into: > pci_find_cap(dev, PCIY_EXPRESS, &sc->sc_cap_off); >=20 > A write to clear the PCI Retry timeout, by writing 0x41 to the device > with pci_write_config(9): > pci_write_config(dev, 0x41, 0, 1); >=20 > Obtain the base address registers using PCIR_BAR(), an abstraction of > bus_alloc_resource(), and store that value. > rid =3D PCIR_BAR(0) >=20 > Allocate IO DMA memory to the device: > sc->sc_mem =3D bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, = RF_ACTIVE); > Most drivers check this return value and return ENXIO if the value is = NULL. >=20 > I do not fully understand what rman_get_bustag(9) does, but I see this > called on all drivers I've looked at as follows: > sc->sc_st =3D rman_get_bustag(sc->sc_mem); > sc->sc_sh =3D rman_get_bushandle(sc->sc_mem); >=20 > Typically I see Interrupt handler code setup here. In the case of > rtwn(4) and iwm(4). This might not be relevant to your driver, > depending on what it does. I see a call to pci_alloc_msi as follows: > rid =3D 1; > if (pci_alloc_msi(dev, &rid) =3D=3D 0) > rid =3D 1; > else > rid =3D 0; > pci->irq =3D bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE = | > (rid !=3D 0 ? 0 : RF_SHAREABLE)); >=20 > Then assign an interrupt handler function as follows so you know to > read from the DMA. > error =3D bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_NET | INTR_MPSAFE, > NULL, your_function_here, sc, &sc->sc_ih); >=20 > Capture the DMA tag as follows: > sc->sc_dmat =3D bus_get_dma_tag(sc->sc_dev); >=20 > =46rom here, I see the following sequence: > 1. bus_dma_tag_create(), where the first argument is the DMA tag > (sc->sc_dmat), and the last argument is the memory it is mapped to. > 2. bus_dmamem_alloc() > 3. bus_dmamap_load() > 4. bus_dmamap_sync() >=20 > At this point, you may need to initialize the interrupts, depending on > your hardware. If/when the interrupt arrives, you need to determine > what type it is and read from the DMA memory, as allocated in the DMA > sequence. On every assign and allocation you should also do > error-checking on all return values. >=20 > That is my understanding. Again, someone else can jump in if I made a > mistake. I read rtwn(4), iwm(4) and iwi(4) while writing this and they > are excellent references. >=20 > Hope this helps! > -- > Farhan Khan > PGP Fingerprint: B28D 2726 E2BC A97E 3854 5ABE 9A9F 00BC D525 16EE >=20 >=20 > On Sun, Sep 23, 2018 at 10:46 PM Dr. Rolf Jansen = wrote: >>=20 >> Hello, >>=20 >> A couple of years ago, with the valuable help of people on this list, = I managed to write a PCI driver for the National Instruments DAQ card, = NI PCI-6251. The driver was kept very simple, only map the BAR=E2=80=99s = and some DMA memory into the user space. The DAC/ADC and DIO is then all = controlled from user space by writing command codes to certain offsets = from the mapped BAR=E2=80=99s, and reading data from the mapped DMA = memory and/or from other given offsets. >>=20 >> See: How to map device addresses into user space >> = https://lists.freebsd.org/pipermail/freebsd-drivers/2013-January/thread.ht= ml >>=20 >>=20 >> Now, I need to do exactly the same for a PCIe card, namely the NI = PCIe-6351. However, I even cannot see where to start. For PCI cards, the = respective chapter 11 in the FreeBSD Architecture Handbook was quite = helpful, for getting started, in no time, I got the PCI card probed and = attached. >>=20 >> = https://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/pci.html >>=20 >> The dumb approach, probing the device ID and attaching the PCI(e) = driver to the PCIe device in a similar fashion didn=E2=80=99t work - I = didn=E2=80=99t expect this either, however, where would I start? How do = I attach my driver to a PCIe card on FreeBSD 11 or 12? >>=20 >> Please can somebody push me into the right direction. Once I got the = driver attached to the card, I guess, I would be able to adapt the = mem-mapping code of my old driver for the new card. >>=20 >> Best regards >>=20 >> Rolf >> _______________________________________________ >> freebsd-drivers@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers >> To unsubscribe, send any mail to = "freebsd-drivers-unsubscribe@freebsd.org" From owner-freebsd-drivers@freebsd.org Wed Sep 26 08:17:32 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7883B10A4EC6 for ; Wed, 26 Sep 2018 08:17:32 +0000 (UTC) (envelope-from shreyankfbsd@gmail.com) Received: from mail-yw1-xc36.google.com (mail-yw1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F39D173922 for ; Wed, 26 Sep 2018 08:17:31 +0000 (UTC) (envelope-from shreyankfbsd@gmail.com) Received: by mail-yw1-xc36.google.com with SMTP id z143-v6so10450921ywa.7 for ; Wed, 26 Sep 2018 01:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=kiHLP+/G2hw1OAE/7b1WE5i/LwYZEBtNExWxMLE+p3o=; b=KNivtwxlaSuXqc2ZsQTso0BCAODfZwSHNW+F0/Bi9/dq1fPoby0TOwk/Ug1g4hA6nQ Iso2Bji3BYAZcYokmf9ImVEqtyvY+tQumsMDJWYd8TYAhRxrffAOEc3/QOmRZSqj0yOb CCFcW67EKPe9zLqxj3acJvaKbMxtKY52sz7p3o9/oVLFuikQODipSe6CzwIBC1gc6/NU hF9Oo90YPF8uJ07skCkqPjQpjn2PZGcmmaHyBHTFUpfIig2DHjDMvsa5ECofosetyQQi BLLcpC1xUtB+in0oIY035V0eqyKPjIzVnYbk1KalTvlI3cmAQHyrH1WJRoU1xBMQgAvG 0A0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=kiHLP+/G2hw1OAE/7b1WE5i/LwYZEBtNExWxMLE+p3o=; b=R5cXrzHxZWXNBDhdR88lbY/j3yI0ngUNJNgJv2zNh6McFbv3LYV5HkKqQoWAAUMOie hTbrk4WsgBUAYoMQWlr6536xhIRVKqFbhdQeAFsQvlREF4gw29MAWcVPSpJfWY842Y+W cJxpqgYfrPLF1NbnrdTyJ/COLKy31Vd4u8EJS/YuUPXs+gPoGS3MxFWUW6TSqOrQvRxS +69/yh6dSfpXjOD3kV7aGQY57mZo4K/sj9unPtRwPj+n/ldVoSLV83Mt/7jZe+boZk/B PjKcZGaDCY/K1p9Fz8tNBZeXtnU/FVBSYj+PSuwHJGMGzujtZfHEY08hVtkShOBFxu/4 X2JQ== X-Gm-Message-State: ABuFfohv9pePE1vUDcXWF52/lUsSEgNDmiL7dbzl4jb15cq2LtmWrJju a+2I5CVAW6H1b5wCJ7aj6KS4RjvFLqweOrOszBNz X-Google-Smtp-Source: ACcGV60HUur8uCfII4t2hw+RAjxP55AmHq7rm+53+wsUJjST3775DRArRiF3bdipETePjD9UV8Yq9qqymus2Ubm9ZWw= X-Received: by 2002:a81:72d5:: with SMTP id n204-v6mr2311140ywc.57.1537949851272; Wed, 26 Sep 2018 01:17:31 -0700 (PDT) MIME-Version: 1.0 From: shreyank amartya Date: Wed, 26 Sep 2018 13:47:20 +0530 Message-ID: Subject: Device Driver Debugging To: freebsd-drivers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Sep 2018 08:17:32 -0000 Hi, I have modified a driver source for eMMC controller (added a new device in the table) and I want to debug an issue (HS400 mode not working) with the device. I compiled and loaded the sdhci_acpi module, now I'm new to FreeBSD and device driver development, so I was wondering what are the ways I can debug this issue, any resources, and utilities that would make it easier to debug this problem. I see there is a debug flag (hw.sdhci_acpi.debug), which I enabled using sysctl, but I'm not sure how to utilize it. Any help is appreciated :) Thanks Shreyank From owner-freebsd-drivers@freebsd.org Wed Sep 26 17:04:52 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 168D810B1DD4 for ; Wed, 26 Sep 2018 17:04:52 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.cyclaero.com (ec2-18-195-62-44.eu-central-1.compute.amazonaws.com [18.195.62.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A1C9985C29 for ; Wed, 26 Sep 2018 17:04:50 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.obsigna.com (unknown [191.182.171.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.cyclaero.com (Postfix) with ESMTPSA id 3D3745D; Wed, 26 Sep 2018 19:04:44 +0200 (CEST) Received: from rolf.obsigna.com (rolf.obsigna.com [192.168.222.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.obsigna.com (Postfix) with ESMTPSA id 947E01350F946; Wed, 26 Sep 2018 14:04:39 -0300 (BRT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: Writing a PCIe-Driver From: "Dr. Rolf Jansen" In-Reply-To: <0E9C0EFE-F2EE-47A3-B7E6-60E9404E3904@obsigna.com> Date: Wed, 26 Sep 2018 14:04:38 -0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <0E9C0EFE-F2EE-47A3-B7E6-60E9404E3904@obsigna.com> To: freebsd-drivers@freebsd.org X-Mailer: Apple Mail (2.3445.9.1) X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Sep 2018 17:04:52 -0000 I got it working. Actually, it was more easy than expected. I was looking at the output of pciconf -lcbv and there I confused the = card identifier (card=3D0x742f1093) with the chip identifier = (chip=3D0xc4c41093) of the NI PCIe-6351 board, and in the first place I = took the first one for the probe function of my driver, vendor =3D = 0x1093 (National Instruments) device =3D 0x742f (wrong). Looking closer = at the respective output of the old PCI board NI PCI-6251, I saw, that = this one doesn=E2=80=99t got a card ID assigned (0x00000000). I only = need to use the corrected device ID 0xc4c4 in the probe routine of my = driver, and now I got it attached: # kldload ./cydaq.ko; tail /var/log/messages ... Sep 26 12:39:25 CyStat-220 kernel: cydaq0: CyDAQ found DAQ-Board NI = PCIe-6351; VendorID 0x1093, DeviceID 0xC4C4 Sep 26 12:39:25 CyStat-220 kernel: cydaq0: = mem 0xdf000000-0xdf03ffff irq 18 at device 0.0 on pci2 Sep 26 12:39:25 CyStat-220 kernel: cydaq0: CyDAQ PCI device driver = has been loaded # kldstat Id Refs Address Size Name ... 14 1 0xffffffff827da000 1700 cydaq.ko # sysctl -a | grep cydaq cydaq.AO_dma_buffer_size: 50331648 cydaq.AI_dma_buffer_size: 268435456 dev.cydaq.0.%parent: pci2 dev.cydaq.0.%pnpinfo: vendor=3D0x1093 device=3D0xc4c4 = subvendor=3D0x1093 subdevice=3D0x742f class=3D0x118000 dev.cydaq.0.%location: slot=3D0 function=3D0 dbsf=3Dpci0:2:0:0 = handle=3D\_SB_.PCI0.RP11.PXSX dev.cydaq.0.%driver: cydaq dev.cydaq.0.%desc: DAQ-Board NI PCIe-6351 dev.cydaq.%parent:=20 Everything looks good now. As I said already, the actual DAC/ADC/DIO is = all controlled from user space. The driver only provides the base = addresses of the DAQ board and of the reserved DMA ranges via respective = ioctl calls. Some measurement tasks are very math intensive, and the = kernel is anyway not the right place for doing this. Best regards Rolf > Am 24.09.2018 um 15:30 schrieb Dr. Rolf Jansen : >=20 > Farhan, >=20 > Thank you very much for sharing your findings. I will also look into = the code, and I started with checking out the FreeBSD source tree to my = development machine, so examine the code of the various drivers is more = easy. Anyway, the outline which you revealed is already a good starting = point, and it will help me a lot to find my way in the jungle. >=20 > Best regards >=20 > Rolf >=20 >> Am 24.09.2018 um 01:53 schrieb Farhan Khan : >>=20 >> Hi Rolf, >>=20 >> I have been reading up on this code myself. I do not claim expertise, >> so hopefully others can chim in here if I make a mistake. On the WiFi >> side of things, I've pretty consistently I've seen the following >> routine: >>=20 >> A call to pci_find_cap(9), typically as follows from the WiFi code >> I've looked into: >> pci_find_cap(dev, PCIY_EXPRESS, &sc->sc_cap_off); >>=20 >> A write to clear the PCI Retry timeout, by writing 0x41 to the device >> with pci_write_config(9): >> pci_write_config(dev, 0x41, 0, 1); >>=20 >> Obtain the base address registers using PCIR_BAR(), an abstraction of >> bus_alloc_resource(), and store that value. >> rid =3D PCIR_BAR(0) >>=20 >> Allocate IO DMA memory to the device: >> sc->sc_mem =3D bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, = RF_ACTIVE); >> Most drivers check this return value and return ENXIO if the value is = NULL. >>=20 >> I do not fully understand what rman_get_bustag(9) does, but I see = this >> called on all drivers I've looked at as follows: >> sc->sc_st =3D rman_get_bustag(sc->sc_mem); >> sc->sc_sh =3D rman_get_bushandle(sc->sc_mem); >>=20 >> Typically I see Interrupt handler code setup here. In the case of >> rtwn(4) and iwm(4). This might not be relevant to your driver, >> depending on what it does. I see a call to pci_alloc_msi as follows: >> rid =3D 1; >> if (pci_alloc_msi(dev, &rid) =3D=3D 0) >> rid =3D 1; >> else >> rid =3D 0; >> pci->irq =3D bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE = | >> (rid !=3D 0 ? 0 : RF_SHAREABLE)); >>=20 >> Then assign an interrupt handler function as follows so you know to >> read from the DMA. >> error =3D bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_NET | = INTR_MPSAFE, >> NULL, your_function_here, sc, &sc->sc_ih); >>=20 >> Capture the DMA tag as follows: >> sc->sc_dmat =3D bus_get_dma_tag(sc->sc_dev); >>=20 >> =46rom here, I see the following sequence: >> 1. bus_dma_tag_create(), where the first argument is the DMA tag >> (sc->sc_dmat), and the last argument is the memory it is mapped to. >> 2. bus_dmamem_alloc() >> 3. bus_dmamap_load() >> 4. bus_dmamap_sync() >>=20 >> At this point, you may need to initialize the interrupts, depending = on >> your hardware. If/when the interrupt arrives, you need to determine >> what type it is and read from the DMA memory, as allocated in the DMA >> sequence. On every assign and allocation you should also do >> error-checking on all return values. >>=20 >> That is my understanding. Again, someone else can jump in if I made a >> mistake. I read rtwn(4), iwm(4) and iwi(4) while writing this and = they >> are excellent references. >>=20 >> Hope this helps! >> -- >> Farhan Khan >> PGP Fingerprint: B28D 2726 E2BC A97E 3854 5ABE 9A9F 00BC D525 16EE >>=20 >>=20 >> On Sun, Sep 23, 2018 at 10:46 PM Dr. Rolf Jansen = wrote: >>>=20 >>> Hello, >>>=20 >>> A couple of years ago, with the valuable help of people on this = list, I managed to write a PCI driver for the National Instruments DAQ = card, NI PCI-6251. The driver was kept very simple, only map the BAR=E2=80= =99s and some DMA memory into the user space. The DAC/ADC and DIO is = then all controlled from user space by writing command codes to certain = offsets from the mapped BAR=E2=80=99s, and reading data from the mapped = DMA memory and/or from other given offsets. >>>=20 >>> See: How to map device addresses into user space >>> = https://lists.freebsd.org/pipermail/freebsd-drivers/2013-January/thread.ht= ml >>>=20 >>>=20 >>> Now, I need to do exactly the same for a PCIe card, namely the NI = PCIe-6351. However, I even cannot see where to start. For PCI cards, the = respective chapter 11 in the FreeBSD Architecture Handbook was quite = helpful, for getting started, in no time, I got the PCI card probed and = attached. >>>=20 >>> = https://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/pci.html >>>=20 >>> The dumb approach, probing the device ID and attaching the PCI(e) = driver to the PCIe device in a similar fashion didn=E2=80=99t work - I = didn=E2=80=99t expect this either, however, where would I start? How do = I attach my driver to a PCIe card on FreeBSD 11 or 12? >>>=20 >>> Please can somebody push me into the right direction. Once I got the = driver attached to the card, I guess, I would be able to adapt the = mem-mapping code of my old driver for the new card. >>>=20 >>> Best regards >>>=20 >>> Rolf >>> _______________________________________________ >>> freebsd-drivers@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers >>> To unsubscribe, send any mail to = "freebsd-drivers-unsubscribe@freebsd.org" >=20 > _______________________________________________ > freebsd-drivers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to = "freebsd-drivers-unsubscribe@freebsd.org" From owner-freebsd-drivers@freebsd.org Fri Sep 28 16:12:09 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA9A510B4064 for ; Fri, 28 Sep 2018 16:12:08 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gate2.funkthat.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5DF1F7875F for ; Fri, 28 Sep 2018 16:12:08 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (localhost [127.0.0.1]) by gold.funkthat.com (8.15.2/8.15.2) with ESMTPS id w8SGC6aE064693 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 28 Sep 2018 09:12:07 -0700 (PDT) (envelope-from jmg@gold.funkthat.com) Received: (from jmg@localhost) by gold.funkthat.com (8.15.2/8.15.2/Submit) id w8SGC5Fx064691; Fri, 28 Sep 2018 09:12:05 -0700 (PDT) (envelope-from jmg) Date: Fri, 28 Sep 2018 09:12:05 -0700 From: John-Mark Gurney To: "Dr. Rolf Jansen" Cc: freebsd-drivers@freebsd.org Subject: Re: Writing a PCIe-Driver Message-ID: <20180928161205.GN75530@funkthat.com> Mail-Followup-To: "Dr. Rolf Jansen" , freebsd-drivers@freebsd.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 11.0-RELEASE-p7 amd64 X-PGP-Fingerprint: D87A 235F FB71 1F3F 55B7 ED9B D5FF 5A51 C0AC 3D65 X-Files: The truth is out there X-URL: https://www.funkthat.com/ X-Resume: https://www.funkthat.com/~jmg/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (gold.funkthat.com [127.0.0.1]); Fri, 28 Sep 2018 09:12:07 -0700 (PDT) X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Sep 2018 16:12:09 -0000 Dr. Rolf Jansen wrote this message on Sun, Sep 23, 2018 at 12:56 -0300: > A couple of years ago, with the valuable help of people on this list, I managed to write a PCI driver for the National Instruments DAQ card, NI PCI-6251. The driver was kept very simple, only map the BAR???s and some DMA memory into the user space. The DAC/ADC and DIO is then all controlled from user space by writing command codes to certain offsets from the mapped BAR???s, and reading data from the mapped DMA memory and/or from other given offsets. > > See: How to map device addresses into user space > https://lists.freebsd.org/pipermail/freebsd-drivers/2013-January/thread.html > > > Now, I need to do exactly the same for a PCIe card, namely the NI PCIe-6351. However, I even cannot see where to start. For PCI cards, the respective chapter 11 in the FreeBSD Architecture Handbook was quite helpful, for getting started, in no time, I got the PCI card probed and attached. > > https://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/pci.html > > The dumb approach, probing the device ID and attaching the PCI(e) driver to the PCIe device in a similar fashion didn???t work - I didn???t expect this either, however, where would I start? How do I attach my driver to a PCIe card on FreeBSD 11 or 12? I'm a bit surprised that this didn't work, as PCIe is effectively backwards compatible w/ PCI except a few exceptions like MSI... Many drivers like em (sys/dev/e1000/if_em.c) are used for both PCI and PCIe cards.. Maybe look at what they are doing differently than your driver... > Please can somebody push me into the right direction. Once I got the driver attached to the card, I guess, I would be able to adapt the mem-mapping code of my old driver for the new card. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-drivers@freebsd.org Fri Sep 28 16:43:51 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65BB310B4A26 for ; Fri, 28 Sep 2018 16:43:51 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.cyclaero.com (ec2-18-195-62-44.eu-central-1.compute.amazonaws.com [18.195.62.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D3D2279CB8 for ; Fri, 28 Sep 2018 16:43:50 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.obsigna.com (unknown [191.182.171.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.cyclaero.com (Postfix) with ESMTPSA id D3F8089; Fri, 28 Sep 2018 18:43:42 +0200 (CEST) Received: from rolf-mini.obsigna.com (rolf-mini.obsigna.com [192.168.222.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.obsigna.com (Postfix) with ESMTPSA id A153C1350F946; Fri, 28 Sep 2018 13:43:37 -0300 (BRT) From: "Dr. Rolf Jansen" Message-Id: Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: Writing a PCIe-Driver Date: Fri, 28 Sep 2018 13:43:36 -0300 In-Reply-To: <20180928161205.GN75530@funkthat.com> Cc: freebsd-drivers@freebsd.org To: John-Mark Gurney References: <20180928161205.GN75530@funkthat.com> X-Mailer: Apple Mail (2.3445.9.1) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Sep 2018 16:43:51 -0000 > Am 28.09.2018 um 13:12 schrieb John-Mark Gurney : >=20 > Dr. Rolf Jansen wrote this message on Sun, Sep 23, 2018 at 12:56 = -0300: >> A couple of years ago, with the valuable help of people on this list, = I managed to write a PCI driver for the National Instruments DAQ card, = NI PCI-6251. The driver was kept very simple, only map the BAR???s and = some DMA memory into the user space. The DAC/ADC and DIO is then all = controlled from user space by writing command codes to certain offsets = from the mapped BAR???s, and reading data from the mapped DMA memory = and/or from other given offsets. >>=20 >> See: How to map device addresses into user space >> = https://lists.freebsd.org/pipermail/freebsd-drivers/2013-January/thread.ht= ml >>=20 >> Now, I need to do exactly the same for a PCIe card, namely the NI = PCIe-6351. However, I even cannot see where to start. For PCI cards, the = respective chapter 11 in the FreeBSD Architecture Handbook was quite = helpful, for getting started, in no time, I got the PCI card probed and = attached. >>=20 >> = https://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/pci.html >>=20 >> The dumb approach, probing the device ID and attaching the PCI(e) = driver to the PCIe device in a similar fashion didn???t work - I = didn???t expect this either, however, where would I start? How do I = attach my driver to a PCIe card on FreeBSD 11 or 12? >=20 > I'm a bit surprised that this didn't work, as PCIe is effectively > backwards compatible w/ PCI except a few exceptions like MSI... >=20 > Many drivers like em (sys/dev/e1000/if_em.c) are used for both PCI and > PCIe cards.. Maybe look at what they are doing differently than your > driver... In the meantime, the issue has been resolved. See my other post on this = list: = https://lists.freebsd.org/pipermail/freebsd-drivers/2018-September/002129.= html = The driver is working now, and I am able to address the basic = functionality of the NI PCIe-6351 DAQ board from user space. I didn=E2=80=99= t come to check whether interrupts and DMA do work like it did with the = older PCI DAQ boards. Best regards Rolf=20=