I2C

Victor910

New Member


Messages: 12

HI,

I just move from Debian to Freebsd.
How to communicate with I2C devices?
Under Linux, I had use I2c-tools, and sending codes to my device from console use command i2cset.
How to make possible working under Freebsd? I use the absolutely same hardware.
 

obsigna

Daemon

Reaction score: 608
Messages: 1,006

You may want to start your research with: apropos i2c

Perhaps, you are looking for i2c(8)

That said, one obstacle might be that the particular I2C device is not routed to the pinouts of your board. In this case you would need to provide a device tree overlay and inform this to /boot/loader.conf. For example, in order to get I2C working on the BeagleBone Blacks, I wrote a respective overlay:

Code:
/dts-v1/;
/plugin/;

/ {
    compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";

    part-number = "I2C1";
    version = "0001";
    exclusive-use = "i2c1", "P9.17", "P9.18";
};

&am33xx_pinmux {
    i2c1_pins: pinmux_i2c1_pins {
        pinctrl-single,pins = <0x158 0x32 0x15c 0x32>;
    };
};

&i2c1 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&i2c1_pins>;
    clock-frequency = <400000>;
    #address-cells = <0x1>;
    #size-cells = <0x0>;
};
 
OP
OP
V

Victor910

New Member


Messages: 12

You may want to start your research with: apropos i2c

Perhaps, you are looking for i2c(8)

That said, one obstacle might be that the particular I2C device is not routed to the pinouts of your board. In this case you would need to provide a device tree overlay and inform this to /boot/loader.conf. For example, in order to get I2C working on the BeagleBone Blacks, I wrote a respective overlay:

Code:
/dts-v1/;
/plugin/;

/ {
    compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";

    part-number = "I2C1";
    version = "0001";
    exclusive-use = "i2c1", "P9.17", "P9.18";
};

&am33xx_pinmux {
    i2c1_pins: pinmux_i2c1_pins {
        pinctrl-single,pins = <0x158 0x32 0x15c 0x32>;
    };
};

&i2c1 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&i2c1_pins>;
    clock-frequency = <400000>;
    #address-cells = <0x1>;
    #size-cells = <0x0>;
};
Can i have more detailed information?
Wheres i must write this codes?
Why you use this data for your device?
Wheres i can find data for my device?
Thanks for help
 

obsigna

Daemon

Reaction score: 608
Messages: 1,006

Wheres i must write this codes?
In general, device tree overlays are written in text form and then compiled into a binary blob using the dtc(1) utility. You can place this binary device tree overlay anywhere on the system which is readable at boot time. On the BeagleBones, I usually create the directory /boot/dtbo and place all the overlays in there. Let's assume the path to the device tree overlay source file, whose content I gave in my previous post, would be: ~/am335x-boneblack-i2c1.dtso. Then this would be compiled with the following command sequence into the respective binary blob and directly placed into the directory /boot/dtbo:
# cd
# dts -O dtb -b0 -@ -o /boot/dtbo/am335x-boneblack-i2c1.dtbo am335x-boneblack-i2c1.dtso

Finally, the location of the overlays to be loaded at boot time must be informed by a respective directive in /boot/loader.conf
Code:
...
fdt_overlays="/boot/dtbo/am335x-boneblack-i2c1.dtbo"
...
Then I restart, and the BeagleBone comes up with an activated I2C1 device.

Why you use this data for your device?
The BBB manual tells the pinout, and I looked up the codes for the pin multiplexer of the BeagleBone here:

There are other sources though, which would give the same information, for example:

Wheres i can find data for my device?
Good question. Do you know the name of your device, or is this secret?

Perhaps, it is listed here:
and/or in some other sub-directories of the following one:
 
OP
OP
V

Victor910

New Member


Messages: 12

that what I have in my PC:

pciconf -vl
hostb0@pci0:0:0:0: class=0x060000 card=0x20158086 chip=0x59048086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = 'Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers'
class = bridge
subclass = HOST-PCI
vgapci0@pci0:0:2:0: class=0x030000 card=0x00008086 chip=0x59168086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = 'HD Graphics 620'
class = display
subclass = VGA
xhci0@pci0:0:20:0: class=0x0c0330 card=0x72708086 chip=0x9d2f8086 rev=0x21 hdr=0x00
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP USB 3.0 xHCI Controller'
class = serial bus
subclass = USB
none0@pci0:0:22:0: class=0x078000 card=0x19998086 chip=0x9d3a8086 rev=0x21 hdr=0x00
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP CSME HECI'
class = simple comms
ahci0@pci0:0:23:0: class=0x010601 card=0x72708086 chip=0x9d038086 rev=0x21 hdr=0x00
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP SATA Controller [AHCI mode]'
class = mass storage
subclass = SATA
pcib1@pci0:0:28:0: class=0x060400 card=0x72708086 chip=0x9d128086 rev=0xf1 hdr=0x01
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP PCI Express Root Port'
class = bridge
subclass = PCI-PCI
pcib2@pci0:0:28:3: class=0x060400 card=0x72708086 chip=0x9d138086 rev=0xf1 hdr=0x01
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP PCI Express Root Port'
class = bridge
subclass = PCI-PCI
pcib3@pci0:0:28:4: class=0x060400 card=0x72708086 chip=0x9d148086 rev=0xf1 hdr=0x01
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP PCI Express Root Port'
class = bridge
subclass = PCI-PCI
isab0@pci0:0:31:0: class=0x060100 card=0x72708086 chip=0x9d4e8086 rev=0x21 hdr=0x00
vendor = 'Intel Corporation'
device = 'Sunrise Point LPC Controller/eSPI Controller'
class = bridge
subclass = PCI-ISA
none1@pci0:0:31:2: class=0x058000 card=0x72708086 chip=0x9d218086 rev=0x21 hdr=0x00
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP PMC'
class = memory
none2@pci0:0:31:4: class=0x0c0500 card=0x72708086 chip=0x9d238086 rev=0x21 hdr=0x00
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP SMBus'
class = serial bus
subclass = SMBus
re0@pci0:1:0:0: class=0x020000 card=0x012310ec chip=0x816810ec rev=0x07 hdr=0x00
vendor = 'Realtek Semiconductor Co., Ltd.'
device = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
class = network
subclass = ethernet
re1@pci0:2:0:0: class=0x020000 card=0x012310ec chip=0x816810ec rev=0x07 hdr=0x00
vendor = 'Realtek Semiconductor Co., Ltd.'
device = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
class = network
subclass = ethernet
iwm0@pci0:3:0:0: class=0x028000 card=0x40608086 chip=0x08b18086 rev=0x73 hdr=0x00
vendor = 'Intel Corporation'
device = 'Wireless 7260'
class = network

I have found someone another report with the same hardware https://lists.freebsd.org/pipermail/freebsd-questions/2017-December/280239.html


very interesting moment,
I do not have in my report all devices with class = dasp, include I2c controller, this from someone another report:

none0 at pci0:0:4:0: class=0x118000 card=0x07a81028 chip=0x19038086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = 'Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal
Subsystem'
class = dasp
none1 at pci0:0:20:2: class=0x118000 card=0x07a81028 chip=0x9d318086 rev=0x21 hdr=0x00
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP Thermal subsystem'
class = dasp
none2 at pci0:0:21:0: class=0x118000 card=0x07a81028 chip=0x9d608086 rev=0x21 hdr=0x00
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP Serial IO I2C Controller'
class = dasp
none3 at pci0:0:21:1: class=0x118000 card=0x07a81028 chip=0x9d618086 rev=0x21 hdr=0x00
vendor = 'Intel Corporation'
device = 'Sunrise Point-LP Serial IO I2C Controller'
class = dasp


all these devices do not present in my pciconf -vl output.

The question, how to fix this, I believe this is will be the first step in the right direction.

I have FreeBSD 12.0
 
Top