Hi,
I'm trying to access one of the invensense sensors through the I2C0 (I'm working with the OMAPL138 LCDK). I followed the docs and configured my board to set it up using the following code:
static struct mpu_platform_data gyro_platform_data = {
.int_config = 0x00,
.level_shifter = 0,
.orientation = { -1, 0, 0,
0, 1, 0,
0, 0, -1 },
.sec_slave_type = SECONDARY_SLAVE_TYPE_COMPASS,
.sec_slave_id = COMPASS_ID_AK8975,
.secondary_i2c_addr = 0x0E
};
/* Init data for the MPU */
static struct i2c_board_info __initdata single_chip_board_info[] = {
{
I2C_BOARD_INFO("mpu9150", 0x68),
//.irq = (IH_GPIO_BASE + MPUIRQ_GPIO), Not really sure if these can be configured on this platform
.platform_data = &gyro_platform_data,
},
};
/* I2C0 PINMUX pins */
static short omapl138_i2c0_pins[] __initdata = {
DA850_I2C0_SDA, DA850_I2C0_SCL, -1
};
static struct davinci_i2c_platform_data i2c_pdata = {
.bus_freq = 400 /* kHz */,
.bus_delay = 0 /* usec */,
//.sda_pin; /* GPIO pin ID to use for SDA */
//.scl_pin; /* GPIO pin ID to use for SCL */
};
static __init void omapl138_config_i2c0(void)
{
int ret;
// Do the PINMUX
ret = davinci_cfg_reg_list(omapl138_i2c0_pins);
if (ret) {
pr_warning("%s: LCDK gpio mux setup failed: %d\n",
__func__, ret);
return;
}
// Init I2C
davinci_init_i2c(&i2c_pdata);
// Register the board
i2c_register_board_info(1, single_chip_board_info, ARRAY_SIZE(single_chip_board_info));
}
I'm loading the driver as a module but the IC20 clock doesn't change from a high value on the oscilloscope so something should be wrong. The booting messages:
NAND: 512 MiB
MMC: davinci: 0
Bad block table found at page 262080, version 0x01
Bad block table found at page 262016, version 0x01
In: serial
Out: serial
Err: serial
ARM Clock : 456000000 Hz
DDR Clock : 150000000 Hz
Net: Ethernet PHY: GENERIC @ 0x07
DaVinci-EMAC
Hit any key to stop autoboot: 0
BOOTP broadcast 1
DHCP client bound to address 192.168.1.133
Using DaVinci-EMAC device
TFTP from server 192.168.1.137; our IP address is 192.168.1.133
Filename 'uImage'.
Load address: 0xc0700000
Loading: ###########T #################################T #####################
#####T ################T #############################################
#################################################################
#################################################################
#################################################################
#################################################T ################
######
done
Bytes transferred = 2027192 (1eeeb8 hex)
Using DaVinci-EMAC device
TFTP from server 192.168.1.137; our IP address is 192.168.1.133
Filename 'uImage'.
Load address: 0xc0700000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
######
done
Bytes transferred = 2027192 (1eeeb8 hex)
## Booting kernel from Legacy Image at c0700000 ...
Image Name: Linux-3.3.0-g9287243-dirty
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2027128 Bytes = 1.9 MiB
Load Address: c0008000
Entry Point: c0008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0
Linux version 3.3.0-g9287243-dirty (root@victor-desktop) (gcc version 4.5.3 20110311 (prerelease) (GCC) ) #1 PREEMPT Sat Mar 9 12:33:23 CET 2013
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: AM18x/OMAP-L138 Hawkboard
Memory policy: ECC disabled, Data cache writeback
BUG: mapping for 0x80000000 at 0xfffe0000 out of vmalloc space
DaVinci da850/omap-l138/am18x variant 0x1
On node 0 totalpages: 32768
free_area_init_node: node 0, pgdat c03cf18c, node_mem_map c03ea000
DMA zone: 256 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 32512 pages, LIFO batch:7
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: ip=192.168.1.6 noinitrd console=ttyS2,115200n8 root=/dev/nfs rw nfsroot=192.168.1.137:/home/victor/PFC_material/LCDK/ti-sdk-omapl138-lcdk-01.00.00/erle-stuff/filesystem/fs_cre4
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 125896k/125896k available, 5176k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
vmalloc : 0xc8800000 - 0xff000000 ( 872 MB)
lowmem : 0xc0000000 - 0xc8000000 ( 128 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.text : 0xc0008000 - 0xc038cd80 (3604 kB)
.init : 0xc038d000 - 0xc03ae000 ( 132 kB)
.data : 0xc03ae000 - 0xc03cfb00 ( 135 kB)
.bss : 0xc03cfb24 - 0xc03e96ec ( 103 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:245
Console: colour dummy device 80x30
Calibrating delay loop... 227.32 BogoMIPS (lpj=1136640)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0xc02a4520 - 0xc02a455c
gpiochip_add: registered GPIOs 0 to 31 on device: DaVinci
gpiochip_add: registered GPIOs 32 to 63 on device: DaVinci
gpiochip_add: registered GPIOs 64 to 95 on device: DaVinci
gpiochip_add: registered GPIOs 96 to 127 on device: DaVinci
gpiochip_add: registered GPIOs 128 to 143 on device: DaVinci
DaVinci: 144 gpio irqs
NET: Registered protocol family 16
i2c-core: driver [dummy] registered
EMAC: MII PHY configured
MUX: initialized GPIO3_12
MUX: Setting register GPIO3_12
PINMUX7 (0x0000001c) = 0x10110110 -> 0x10118110
MUX: initialized GPIO3_13
MUX: Setting register GPIO3_13
PINMUX7 (0x0000001c) = 0x10118110 -> 0x10118810
MUX: initialized GPIO2_4
MUX: Setting register GPIO2_4
PINMUX6 (0x00000018) = 0x00000000 -> 0x00008000
MUX: initialized GPIO6_13
MUX: Setting register GPIO6_13
PINMUX13 (0x00000034) = 0x00000000 -> 0x00000800
MUX: initialized GPIO8_10
MUX: Setting register GPIO8_10
PINMUX18 (0x00000048) = 0x00000000 -> 0x80000000
MUX: initialized GPIO8_12
MUX: Setting register GPIO8_12
PINMUX18 (0x00000048) = 0x80000000 -> 0x80800000
------------[ cut here ]------------
WARNING: at fs/sysfs/dir.c:481 sysfs_add_one+0x94/0xc4()
sysfs: cannot create duplicate filename '/devices/platform/watchdog'
Modules linked in:
[<c000d5bc>] (unwind_backtrace+0x0/0xf0) from [<c0017518>] (warn_slowpath_common+0x4c/0x64)
[<c0017518>] (warn_slowpath_common+0x4c/0x64) from [<c00175c4>] (warn_slowpath_fmt+0x30/0x40)
[<c00175c4>] (warn_slowpath_fmt+0x30/0x40) from [<c00d6f70>] (sysfs_add_one+0x94/0xc4)
[<c00d6f70>] (sysfs_add_one+0x94/0xc4) from [<c00d7000>] (create_dir+0x60/0xc0)
[<c00d7000>] (create_dir+0x60/0xc0) from [<c00d7110>] (sysfs_create_dir+0x84/0xc0)
[<c00d7110>] (sysfs_create_dir+0x84/0xc0) from [<c014db98>] (kobject_add_internal+0xb4/0x1d8)
[<c014db98>] (kobject_add_internal+0xb4/0x1d8) from [<c014dff0>] (kobject_add+0x50/0x98)
[<c014dff0>] (kobject_add+0x50/0x98) from [<c0184b3c>] (device_add+0xc4/0x564)
[<c0184b3c>] (device_add+0xc4/0x564) from [<c01883c0>] (platform_device_add+0xfc/0x1b0)
[<c01883c0>] (platform_device_add+0xfc/0x1b0) from [<c0394154>] (davinci_init_devices+0x18/0x24)
[<c0394154>] (davinci_init_devices+0x18/0x24) from [<c000889c>] (do_one_initcall+0x30/0x16c)
[<c000889c>] (do_one_initcall+0x30/0x16c) from [<c038d810>] (kernel_init+0x78/0x11c)
[<c038d810>] (kernel_init+0x78/0x11c) from [<c0009d90>] (kernel_thread_exit+0x0/0x8)
---[ end trace 1b75b31a2719ed1c ]---
kobject_add_internal failed for watchdog with -EEXIST, don't try to register things with the same name in the same directory.
[<c000d5bc>] (unwind_backtrace+0x0/0xf0) from [<c014dca4>] (kobject_add_internal+0x1c0/0x1d8)
[<c014dca4>] (kobject_add_internal+0x1c0/0x1d8) from [<c014dff0>] (kobject_add+0x50/0x98)
[<c014dff0>] (kobject_add+0x50/0x98) from [<c0184b3c>] (device_add+0xc4/0x564)
[<c0184b3c>] (device_add+0xc4/0x564) from [<c01883c0>] (platform_device_add+0xfc/0x1b0)
[<c01883c0>] (platform_device_add+0xfc/0x1b0) from [<c0394154>] (davinci_init_devices+0x18/0x24)
[<c0394154>] (davinci_init_devices+0x18/0x24) from [<c000889c>] (do_one_initcall+0x30/0x16c)
[<c000889c>] (do_one_initcall+0x30/0x16c) from [<c038d810>] (kernel_init+0x78/0x11c)
[<c038d810>] (kernel_init+0x78/0x11c) from [<c0009d90>] (kernel_thread_exit+0x0/0x8)
bio: create slab <bio-0> at 0
i2c-core: driver [pca953x] registered
i2c-core: driver [pcf857x] registered
SCSI subsystem initialized
libata version 3.00 loaded.
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
i2c_davinci i2c_davinci.1: input_clock = 24000000, CLK = 10
i2c_davinci i2c_davinci.1: PSC = 2
i2c_davinci i2c_davinci.1: CLKL = 1
i2c_davinci i2c_davinci.1: CLKH = 5
i2c_davinci i2c_davinci.1: bus_freq = 400kHz, bus_delay = 0
i2c i2c-1: adapter [DaVinci I2C adapter] registered
i2c 1-0068: uevent
i2c i2c-1: client [mpu9150] registered with bus id 1-0068
Switching to clocksource timer0_1
musb-hdrc: version 6.0, ?dma?, otg (peripheral+host)
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
msgmni has been set to 245
io scheduler noop registered (default)
Serial: 8250/16550 driver, 3 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0x1c42000 (irq = 25) is a AR7
serial8250.0: ttyS1 at MMIO 0x1d0c000 (irq = 53) is a AR7
serial8250.0: ttyS2 at MMIO 0x1d0d000 (irq = 61) is a AR7
console [ttyS2] enabled
brd: module loaded
davinci_mdio davinci_mdio.0: davinci mdio revision 1.5
davinci_mdio davinci_mdio.0: detected phy mask ffffff7f
davinci_mdio.0: probed
davinci_mdio davinci_mdio.0: phy[7]: device davinci_mdio-0:07, driver unknown
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
ohci ohci.0: DA8xx OHCI
ohci ohci.0: new USB bus registered, assigned bus number 1
Waiting for USB PHY clock good...
ohci ohci.0: irq 59, io mem 0x01e25000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: DA8xx OHCI
usb usb1: Manufacturer: Linux 3.3.0-g9287243-dirty ohci_hcd
usb usb1: SerialNumber: ohci.0
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
i2c /dev entries driver
i2c-dev: adapter [DaVinci I2C adapter] registered as minor 1
davinci_mmc davinci_mmc.0: Using DMA, 4-bit mode
TCP cubic registered
NET: Registered protocol family 17
console [netcon0] enabled
netconsole: network logging started
davinci_emac davinci_emac.1: using random MAC addr: fa:c1:b0:61:b0:09
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
davinci_mdio davinci_mdio.0: resetting idled controller
net eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=davinci_mdio-0:07, id=7c0f1)
PHY: davinci_mdio-0:07 - Link is Up - 100/Full
IP-Config: Guessing netmask 255.255.255.0
IP-Config: Complete:
device=eth0, addr=192.168.1.6, mask=255.255.255.0, gw=255.255.255.255,
host=192.168.1.6, domain=, nis-domain=(none),
bootserver=255.255.255.255, rootserver=192.168.1.137, rootpath=
VFS: Mounted root (nfs filesystem) on device 0:14.
Freeing init memory: 132K
System initialization...
If I try to load the driver on Linux i get the following:
modprobe inv-mpu-iio
inv_mpu_iio: module is from the staging directory, the quality is unknown, you have been warned.
inv-mpu-iio 1-0068: probe
i2c i2c-1: master_xfer[0] W, addr=0x68, len=2
i2c_davinci i2c_davinci.1: i2c_davinci_xfer: msgs: 1
i2c_davinci i2c_davinci.1: controller timed out
i2c_davinci i2c_davinci.1: initiating i2c bus recovery
i2c_davinci i2c_davinci.1: input_clock = 24000000, CLK = 10
i2c_davinci i2c_davinci.1: PSC = 2
i2c_davinci i2c_davinci.1: CLKL = 1
i2c_davinci i2c_davinci.1: CLKH = 5
i2c_davinci i2c_davinci.1: bus_freq = 400kHz, bus_delay = 0
i2c_davinci i2c_davinci.1: i2c_davinci_xfer [1/1] ret: -110
i2c i2c-1: inv_mpu_probe failed -110
inv-mpu-iio: probe of 1-0068 failed with error -5
i2c-core: driver [inv-mpu-iio] registered
I'm going to try digging on the invensense drivers however the thing that is worrying me is that the I2C0 SCL signal is on high value all the time. Shouldn't it be changing as expected of a clock?
Any feedback is greatly appreciated.