From owner-freebsd-arm@freebsd.org Wed Aug 8 14:00:14 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 25E96105CD60 for ; Wed, 8 Aug 2018 14:00:14 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.cyclaero.de (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 A10B07F3EE for ; Wed, 8 Aug 2018 14:00:12 +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.de (Postfix) with ESMTPSA id 70F9873 for ; Wed, 8 Aug 2018 16:00:04 +0200 (CEST) Received: from rolf.projectworld.net (rolf.projectworld.net [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 CE5081350F91A for ; Wed, 8 Aug 2018 10:59:59 -0300 (BRT) From: "Dr. Rolf Jansen" Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: BeagleBone Black with a I2C Digital Analog Converter Message-Id: <3C191052-1E2C-4D85-8CF1-AAC64F0500B7@obsigna.com> Date: Wed, 8 Aug 2018 10:59:58 -0300 To: freebsd-arm@FreeBSD.org 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-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: Wed, 08 Aug 2018 14:00:14 -0000 Hello, I got a BeagleBone Black running the latest FreeBSD 12.0-CURRENT = (snapshot o July, 2nd). I am in the process of getting a tiny I2C Digital Analog Converter board = to work with it. It got a MCP4725 DAC chip and it is designed to work = with the Arduino system. = https://learn.sparkfun.com/tutorials/mcp4725-digital-to-analog-converter-h= ookup-guide = However, it should be possible to get it to work with FreeBSD on the = BeagleBone as well, since the operation principle looks very simple, = e.g. write to the base address 0x60 the update command byte 0x40 = followed by two bytes in network byte order which constitutes for the = desired voltage output as a 12bit value. I managed to create a DTB overlay: /dts-v1/; /plugin/; / { compatible =3D "ti,am335x-bone-black", "ti,am335x-bone", = "ti,am33xx"; part-number =3D "MCP4725-I2C1"; version =3D "0001"; exclusive-use =3D "P9.17","P9.18","i2c1"; fragment@0 { target =3D <&am33xx_pinmux>; __overlay__ { pinmux_i2c1_pins { pinctrl-single,pins =3D <0x158 0x32 = 0x15c 0x32>; phandle =3D <0xff>; # pinctrl-single,pins =3D < # AM33XX_IOPAD(0x958, = PIN_INPUT_PULLUP | MUX_MODE2) /* spi0_d1.i2c1_sda */ # AM33XX_IOPAD(0x95c, = PIN_INPUT_PULLUP | MUX_MODE2) /* spi0_cs0.i2c1_scl */ # >; }; }; }; fragment@1 { target =3D <&i2c1>; __overlay__ { status =3D "okay"; pinctrl-names =3D "default"; pinctrl-0 =3D <0xff>; MCP4725 { comaptible =3D "Microchip,MCP4725"; reg =3D <0x60>; }; }; }; }; This actually activates the I2C1 device, and creates a node for the = MCP4725 I2C chip. Since I see the additional iic device in /dev: ls -l /dev/iic* ls -l /dev/iic* crw------- 1 root wheel 0x43 Aug 8 10:36 /dev/iic0 crw------- 1 root wheel 0x45 Aug 8 10:36 /dev/iic1 crw------- 1 root wheel 0x46 Aug 8 10:36 /dev/iic2 Without the overlay, only 2 device show up. Furthermore, the nodes for = nodes activated I2C1, its sub node for the DAC chip and the additional = pinmux node show up in the ofwdump: ... Node 0x2f00: scm@210000 Node 0x2fa0: pinmux@800 Node 0x3064: pinmux_i2c1_pins ... Node 0x5290: i2c@4802a000 Node 0x5360: MCP4725 ... My doubts are now, whether I got the specs of the pinmux right. I read = several documents in the and according to this = https://github.com/jadonk/bonescript/blob/master/src/bone.js, the = addresses of P9.17 and P9.18 should be 0x15c and 0x158 respectively. I = deduced the order and options from other pinmuxes of a decompiled device = tree. Please can somebody, check this, and perhaps give some hints in case I = got something wrong? I don't have an oscilloscope, a multimeter only, = can I check somehow if I specified the correct pins? What needs to be done next? I guess, I need to write a simple device = driver, don't I? Or can I use somehow the iicbb(4) =E2=80=93 I2C generic = bit-banging driver, since actually that DAC chip needs bit banging only = -- repeatedly write 3 byte in row. I yes, how can I use it for my = purpose? Best regards Rolf=