[MinnowBoard] MinnowMax how to access SMBus under Linux

Michael Jones mike at proclivis.com
Thu Mar 5 21:46:17 UTC 2015


extern "C"
{
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
}


    file_ = open("/dev/i2c-7", O_RDWR);
    if (file_ < 0)
        exit(EXIT_FAILURE);
 
    if (ioctl(file_, (unsigned long int)I2C_PEC, 0) < 0)
        exit(EXIT_FAILURE);

writeWord(uint8_t address, uint8_t command, uint16_t data)
{
    if (ioctl(file_, (unsigned long int)I2C_SLAVE, address) < 0)
        exit(EXIT_FAILURE);
 
    if (i2c_smbus_write_word_data(file_, command, data) == -1)
        printf("Write Word: fail.\n");
}


On Mar 4, 2015, at 11:34 PM, Krause Martin <Martin.Krause at tq-group.com> wrote:

> Hi,
>  
> how can I access the SMBus of the MinnowMax under Linux?
>  
> I’ve successfully build an sdcard with a current Yocto-Linux (top of tree, with 3.19.0er kernel).
>  
> There are two modules (automatically) loaded with i2c-support:
>  
> - i2c_i801
> - i2c_designware_core
>  
> root at intel-corei7-64:~# lsmod
> Module                  Size  Used by
> i2c_i801               10830  0
> uio                     9941  0
> iwlwifi               109670  0
> cfg80211              525235  1 iwlwifi
> snd_hda_codec_hdmi     39400  1
> snd_hda_intel          22091  0
> efivars                 7981  0
> snd_hda_controller     22700  1 snd_hda_intel
> snd_hda_codec         109749  3 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_controller
> snd_pcm                93059  4 snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intel,snd_hda_controller
> snd_timer              20730  1 snd_pcm
> dw_dmac                 2803  0
> dw_dmac_core           15959  1 dw_dmac
> spi_pxa2xx_platform    16651  0
> i2c_designware_platform     3843  0
> i2c_designware_core     7249  1 i2c_designware_platform
> root at intel-corei7-64:~#
>  
> I think the i2c_i801 is the driver for the smbus, the i2c_designware_xxx is for the i2c busses?
> Is this correct?
>  
> I see nine i2c device-nodes (= buses):
>  
> root at intel-corei7-64:~# ls -la /dev/i2c*
> crw------- 1 root root 89, 0 Mar  3 10:00 /dev/i2c-0
> crw------- 1 root root 89, 1 Mar  3 10:00 /dev/i2c-1
> crw------- 1 root root 89, 2 Mar  3 10:00 /dev/i2c-2
> crw------- 1 root root 89, 3 Mar  3 10:00 /dev/i2c-3
> crw------- 1 root root 89, 4 Mar  3 10:00 /dev/i2c-4
> crw------- 1 root root 89, 5 Mar  3 10:00 /dev/i2c-5
> crw------- 1 root root 89, 6 Mar  3 10:00 /dev/i2c-6
> crw------- 1 root root 89, 7 Mar  3 10:00 /dev/i2c-7
> crw------- 1 root root 89, 8 Mar  3 10:00 /dev/i2c-8
> root at intel-corei7-64:~#
>  
> Is one of this the smbus?
>  
> The buses 0 to 6 could be accessed with i2cdetect (i2c-0 for example):
>  
> root at intel-corei7-64:~# i2cdetect 0
> WARNING! This program can confuse your I2C bus, cause data loss and worse!
> I will probe file /dev/i2c-0.
> I will probe address range 0x03-0x77.
> Continue? [Y/n]
>      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
> 00:          -- -- -- -- -- -- -- -- -- -- -- -- --
> 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 70: -- -- -- -- -- -- -- --
> root at intel-corei7-64:~#
>  
> When I try to access the busses 7 or 8 with i2cdetect, I get an error:
>  
> root at intel-corei7-64:~# i2cdetect 7
> Error: Can't use SMBus Quick Write command on this bus
> root at intel-corei7-64:~#
>  
> I would expect to see at least two devices on the smbus, one on address
> 0x50 (24C02 EEPROM) and on address 0x6c (NCT3012S). But on the
> i2c buses 0-6 - which could be accessed with i2cdetect - there is nothing
> detected on this addresses.
>  
> Best regards,
> Martin
>  
>  
> _______________________________________________
> elinux-MinnowBoard mailing list
> elinux-MinnowBoard at lists.elinux.org
> http://lists.elinux.org/mailman/listinfo/elinux-minnowboard

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.elinux.org/pipermail/elinux-minnowboard/attachments/20150305/772de08d/attachment-0001.html>


More information about the elinux-MinnowBoard mailing list