From owner-freebsd-arm@freebsd.org Fri Aug 31 12:34:53 2018 Return-Path: Delivered-To: freebsd-arm@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 E5551F7F7DA for ; Fri, 31 Aug 2018 12:34:52 +0000 (UTC) (envelope-from nmingotti@gmail.com) Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (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 3B9B070D87; Fri, 31 Aug 2018 12:34:52 +0000 (UTC) (envelope-from nmingotti@gmail.com) Received: by mail-wm0-x22c.google.com with SMTP id y139-v6so5062195wmc.2; Fri, 31 Aug 2018 05:34:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=bFqw6/VFyGl04evfgpUtzGsBYNVXL84zpIRG/tFe79o=; b=h7mPQiRyGJEB8QwnOhA5OoKvVZkKMPH26Fc7jTWxhh3x6MRAjfPqOeKUmHJK81qpQL j54WaAFkaZV/lfKZql9erdbRGLJtth2HUEMu9+lbY58p0yYQ0FR59z2N83jW7zmM1Iqd srji1SI5O2aWeyw0NR1aT7XIQsXJEWNQGC355IDiQGvwPe2A2akHgf/wBtxy+EkPVCus AuhKSjCcNin7Co80lvSuu89QiWxey7mQjGEYmUgH5szOpL80Rs2vDTTEdzHgxVcbxuoR nt9GTJRh8PsHqM+aDIjZFjLKKhsolGlk79iHeSFAQZdO16rbgX/C9YPLsgK219xQMZS3 hf8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=bFqw6/VFyGl04evfgpUtzGsBYNVXL84zpIRG/tFe79o=; b=BwNTWVhJTGWKIbhAG7H6f6JZrahB1Gg4fXZScagrY8liwJ8lPT3aUR1FCGMBI8kqD7 +aLis5s8t3FKIkcQxpEVcRvBQ7HQ9FFUjcHJYAeYt9DBo/0ScPBTdzppxokxLVq3rfzk Y9SdqjtcnPswyJ4sD0pSq19I+xH2Pt9L0+zfrlqcfV08TRSx+4C03PLAfFvw1w9HnVr2 8nhE8n6oAK9USWfOXhc5Ab8YEc5CjgGVKzVhz/FrNcxx9SKG6i0j2HXM3+Uh4Jz7LFPg 6UFowPkGmUaHEE83DwuBfLwk5prcjogMxKRMeMYd4vZZ4EmmLIbk2Kg9XzBLhyN5kMuy ll+Q== X-Gm-Message-State: APzg51BLThNfDhaVWDUOrqBocQnTVeSu9I/LO1Ot5SJzJZEMYGEUyk7A xq9sMdmhv1RUDaV868ZEydE= X-Google-Smtp-Source: ANB0VdaEumKyz/63WSUgADSf3lNdftzax04RMA9zz5AqRXTtM8Nz7OKC0KJO5N7aq/Gbf9qrGp2SGw== X-Received: by 2002:a1c:e70b:: with SMTP id e11-v6mr4451343wmh.22.1535718890311; Fri, 31 Aug 2018 05:34:50 -0700 (PDT) Received: from [172.16.0.150] (net-188-219-105-237.cust.vodafonedsl.it. [188.219.105.237]) by smtp.gmail.com with ESMTPSA id d10-v6sm14630055wrv.70.2018.08.31.05.34.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Aug 2018 05:34:48 -0700 (PDT) Subject: Re: utility for pin in BBB: PX.Y --> pin_mode, pin_name To: Ian Lepore , Russell Haley Cc: freebsd-arm , Nicola Mingotti References: <4661fc41-935a-56d5-2cc2-125085daf30a@gmail.com> <1535568374.33841.47.camel@freebsd.org> <1535576856.33841.58.camel@freebsd.org> <1535643488.33841.74.camel@freebsd.org> From: Nicola Mingotti Message-ID: <0245623d-20a9-c1a8-e8db-89c9cf2c181d@gmail.com> Date: Fri, 31 Aug 2018 14:34:46 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1535643488.33841.74.camel@freebsd.org> Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Aug 2018 12:34:53 -0000 On 08/30/18 17:38, Ian Lepore wrote: > On Wed, 2018-08-29 at 23:40 +0200, Nicola Mingotti wrote: >> On 08/29/18 23:07, Ian Lepore wrote: >>> On Wed, 2018-08-29 at 22:26 +0200, Nicola Mingotti wrote: >>>> On 08/29/18 20:46, Ian Lepore wrote: >>>>> On Wed, 2018-08-29 at 20:01 +0200, Nicola Mingotti wrote: >>>>>> Thank you for suggestion Russel, >>>>>> >>>>>> but unfortunately, at best of my knowldege, >>>>>> $> man 3 gpio_open >>>>>> and its shell command brother >>>>>> $> man 8 gpioctl >>>>>> >>>>>> are not appropriate, they are useful only if a pin >>>>>> has been configured as GPIO pin. >>>>>> >>>>>> The program i look for would be useful instead to esablish >>>>>> which physical pin has been configured as GPIO pin or >>>>>> PWM, PRU, I2C etc. >>>>>> >>>>>> I asked also in the Forum, but the only one aswering >>>>>> (@Phishry) has given me your same suggestion. >>>>>> >>>>>> If nobody knows of such a program i will start the >>>>>> implementation, >>>>>> maybe >>>>>> tomorrow. >>>>>> >>>>>> bye >>>>>> Nicola >>>>>> >>>>> Please bottom-post when replying to freebsd mailing lists. >>>> ok ! >>>>> There is no interface defined for getting an fdt_pinctrl driver >>>>> to >>>>> return info about the current configuration. Even if such an >>>>> interface >>>>> existed, there would also need to be a new driver providing a >>>>> cdev >>>>> so >>>>> that userland can access the information. >>>> ok, no interface. >>>>> There is also nothing in freebsd equivelent to the linux >>>>> devmem2 >>>>> program. A driver would have to be written to provide access to >>>>> device- >>>>> mapped memory before such a program could be written. You can't >>>>> access >>>>> arm hardware registers via /dev/mem or /dev/kmem. >>>>> >>>>> -- Ian >>>> I just compiled devmem2 and it seems to work. I did silly >>>> modifications. >>>> The code is here: http://euriscom.it/data/dm2.c >>>> (forget the first comment lines, they are poor, I did not intend >>>> to >>>> share this, it is my working copy) >>>> >>>> if i run it: >>>> --------------------------------- >>>> #> ./dm2 0x44e10998 b >>>> /dev/mem opened. >>>> Memory mapped at address 0x20221000. >>>> Value at address 0x44E10998 (0x20221998): 0x5 >>>> --------------------------------- >>>> >>>> Whic corresponds to what i wrote in the DTO. >>>> ----- >>>>              pru_pru_pins: pinmux_pru_pru_pins { >>>>                         pinctrl-single,pins = < >>>>                             // 0x1a4 0x05   /* P9.27 >>>> pr1_pru0_pru_r30_5, >>>> Mode 5 output pull-down   */ >>>>                             0x19c 0x26   /* P9.28 >>>> pr1_pru0_pru_r31_3, >>>> Mode 6 input pull-down    */ >>>>                             0x198 0x05    /* PRU0-2 -- P9.30 -- >>>> pr1_pru0_pru_r30_2 ... se in MODE-5  */ >>>>                             >; >>>>                     }; >>>> ----- >>>> >>>> This is the only test i made but it seems improbable I got the >>>> same >>>> value by chance;) >>>> >>>> It goes without saying that I don't understand all what i wrote, >>>> so, i could be boldly wrong ;) >>>> >>>> If it turns out it works let me know, i can make the port. >>>> >>>> bye >>>> n. >>> You might accidentally get /dev/mem access to work, but it's not by >>> design. The rules of the arm memory model forbid mapping the same >>> physical memory to different virtual addresses using different >>> attributes (normal cacheable memory versus Device memory), and I >>> don't >>> see anything in the arm devmem code that handles memory attributes. >>> >>> -- Ian >> I would like to discuss more this thing but really, i am too ignorant >> on >> this subject. >> >> What i can say is this, I learnt to use devmem2 from D.Molloy book >> "Exploring BeagleBone", >> see pg. 218. The author says this way "bypasses the Linux OS". I >> used >> the thing >> in Linux, it works, as it seems to do in FreeBSD-12-APLHA. >> >> If can tell you also I remember i used it one day in FreeBSD-11.1, >> it >> was working. >> >> I don't have the background to go deeper. >> >> If you can understand why it works and establish that it is realiable >> (even only for reading) let me (us) know ! ;) >> >> bye >> n. >> > I think it should be possible to do a bit of kernel work to change it > from "works by accident" to "does the right thing", except I'm not sure > it'll be possible to automatically detect when Device memory is being > accessed/mapped. It may be necessary to use the mem(4) ioctls to set > the region to MDF_UNCACHEABLE, or even better, define a new MDF_MMIO > for mapping ranges of device registers that arm systems have to treat > as memory type Device. I'll look into it when I have some time. > > -- Ian Great Ian, In the manwhile I will write the little application software I need, when you will consider the thing solved let me know, I will mark the application "safe" and most probably I will make the port, of devmem2 and my little utility. bye nico -- -------------------------- Dr. Nicola Mingotti R&D - Borghi Srl CTO - BondInsider --------------------------