Srinirajini
Posts: 10
Joined: Fri Oct 05, 2018 4:17 am

Does uboot has I2c drivers for Raspberry Pi CM3

Mon Oct 22, 2018 11:22 am

Dear All,
I wonder do we need to write/port I2C driver for Raspberry Pi CM3 for u-boot because under the u-boot menuconfig option I could not see any I2C driver relating to Raspberry, I had blindly enabled the I2C command and tried to access the bus but nothing has turned out. My u-boot version is "u-boot-2018.09"

U-Boot>
No I2C bus selected
Current bus is -1
U-Boot>


I had verified the pinctrl driver module which has been enabled for bcm283x device, but I am not clear whether we need to enable the bcm2835 pin control device please help me clarify. finally, my goal is to use the I2C Bus from U-boot to control my I2c Chip device.

By the way the configuration that I am using for building the u-boot is "rpi_3_32b_defconfig" and with this configuration I could do everything else except accessing the I2C Bus, even after the kernel boot, I could access the I2C device using the command "i2cdetect - y 1" , so I doubt whether the device tree "bcm2837-rpi-3-b.dts" loaded by the default configuration is correct or not?, At kernel I tried inserting the i2c_bcm2835 and i2c_dev modules manually, but still the bus is not created under the /dev/
I have enabled the I2C device tree param to "ON" (dtparam=i2c_arm=on ) in /boot/config file , Please provide some pointer

Thanks In Advance.
Srini.

W. H. Heydt
Posts: 13627
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Does uboot has I2c drivers for Raspberry Pi CM3

Mon Oct 22, 2018 3:06 pm

I would suggest asking this question on whatever support forums exist for u-boot.

drgeoff
Posts: 11243
Joined: Wed Jan 25, 2012 6:39 pm

Re: Does uboot has I2c drivers for Raspberry Pi CM3

Mon Oct 22, 2018 3:23 pm

Have I been labouring for years under these two misapprehensions?

1. uboot is not an Operating System. It is a bootloader - some code that loads and starts an OS.

2. Drivers run as part of or on top of the OS.
Quis custodiet ipsos custodes?

Srinirajini
Posts: 10
Joined: Fri Oct 05, 2018 4:17 am

Re: Does uboot has I2c drivers for Raspberry Pi CM3

Tue Oct 23, 2018 10:33 am

drgeoff wrote:
Mon Oct 22, 2018 3:23 pm
Have I been labouring for years under these two misapprehensions?

1. uboot is not an Operating System. It is a bootloader - some code that loads and starts an OS.

2. Drivers run as part of or on top of the OS.
Firstly, thanks for the response, and I completely agree with your point that the u-boot is the minimal initial code that load and execute the kernel, but then I believe even the bootlader can support accessing peripherals of the system. and I could see from the u-boot terminal that it list all other devices either through Pincontrol subsystem or through individual driver model. but I wonder why only the I2C is missing. also, my concern is if I load the same kernel which is properly probing the I2C bus, if loaded and executed straight away by the "start.elf" which is not probing the I2C bus if loaded through u-boot.
Any Idea pointer is greatly appreciated.

Regards,
Srini.

epoch1970
Posts: 5735
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Does uboot has I2c drivers for Raspberry Pi CM3

Tue Oct 23, 2018 12:58 pm

IIRC the DT passed by the pi bootloader is used as is, unless you actively replace it with your own (with the "dt" commands available in u-boot)
I tend to believe the issue might be in u-boot's code instead.

I would try with one of the repos owned by Alexander Graf, https://github.com/agraf/u-boot/
He is the current u-boot maintainer for the RPI platform, his tree gets merged upstream but I've had denx releases fail where agraf's would work.

Personally I am using agraf's "rpi-stable" branch and have no experience with i2c.
There is an "rpi-next" branch that is more recent, but the current effort seems to be around 64-bit u-boot with EFI support.

Good luck.
PS: I you have any practical experience to share about LED control on Pi 3 within u-boot, I'd be keen on a few hints ;)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Srinirajini
Posts: 10
Joined: Fri Oct 05, 2018 4:17 am

Re: Does uboot has I2c drivers for Raspberry Pi CM3

Wed Oct 24, 2018 1:30 am

epoch1970 wrote:
Tue Oct 23, 2018 12:58 pm
IIRC the DT passed by the pi bootloader is used as is, unless you actively replace it with your own (with the "dt" commands available in u-boot)
I tend to believe the issue might be in u-boot's code instead.

I would try with one of the repos owned by Alexander Graf, https://github.com/agraf/u-boot/
He is the current u-boot maintainer for the RPI platform, his tree gets merged upstream but I've had denx releases fail where agraf's would work.

Personally I am using agraf's "rpi-stable" branch and have no experience with i2c.
There is an "rpi-next" branch that is more recent, but the current effort seems to be around 64-bit u-boot with EFI support.

Good luck.
PS: I you have any practical experience to share about LED control on Pi 3 within u-boot, I'd be keen on a few hints ;)
Thank you so much for pointer let me try with Alexander Graf's repo probably "RPI_Stable", and try to explore I2C, even I need to start with LED from u-Boot using Pinctrl, that's propriety next to the I2C access. sure I will give you an update on led as soon as work on it.

Srinirajini
Posts: 10
Joined: Fri Oct 05, 2018 4:17 am

Re: Does uboot has I2c drivers for Raspberry Pi CM3

Wed Oct 24, 2018 2:44 am

No Luck I tried most of the different branches but I2C is not working in none of the branches for Raspberry "rpi_3_32b_defconfig" configuration, I notice gpio staus of the Pin 2 and 3 is not assigned with Function Alterative_0 rather it is kept open as General I/O pin. I am checking with pinctrl drivers, let me update if I get through. meantime if anybody could help, please provide suggestions.

Thanks,

nicklat
Posts: 2
Joined: Fri Aug 07, 2020 9:44 am

Re: Does uboot has I2c drivers for Raspberry Pi CM3

Fri Aug 07, 2020 10:09 am

Hello everyone,

I'm writing in this thread as I also have the exact same issue with the I2C driver activation in U-Boot for the RPI-CM3 module.

The problem is that the i2c command does not return any available bus when issued from the U-boot environment. Nevertheless it seems to work right under the Linux kernel. Both the U-Boot and the Kernel use the same device tree (custom-made).

By running the command "dm tree", I notice that indeed the i2c device was never probed. (serial, usb, mmc, eth are successfully probed at this point).

FInally, the following configuration options are also set in order to activate I2C support.
- CONFIG_DM_I2C=y
- CONFIG_DM_I2C_COMPAT=y
- CONFIG_I2C_SET_DEFAULT_BUS_NUM=y
- CONFIG_I2C_DEFAULT_BUS_NUMBER=0x00
- CONFIG_DM_I2C_GPIO=y

(e.g. issuing >>i2c dev 0 returns "Failure changing bus number (-19)").

PS: The device tree is correctly configured and both i2c0, i2c1 are enabled.

Any help would be much appreciated.

Thanks in advance!

Rergards,
Nick

swahren
Posts: 149
Joined: Mon Sep 19, 2016 5:24 pm
Location: Germany

Re: Does uboot has I2c drivers for Raspberry Pi CM3

Sun Aug 09, 2020 9:11 am

nicklat wrote:
Fri Aug 07, 2020 10:09 am
The problem is that the i2c command does not return any available bus when issued from the U-boot environment. Nevertheless it seems to work right under the Linux kernel. Both the U-Boot and the Kernel use the same device tree (custom-made).
Providing the i2c relevant part would be very helpful
Which u-boot version do you use?
What is your actual use case (there are a lot of I2C devices)?
nicklat wrote:
Fri Aug 07, 2020 10:09 am
PS: The device tree is correctly configured and both i2c0, i2c1 are enabled.
Instead of your interpretation the actual settings would be more helpful for diagnostics.

nicklat
Posts: 2
Joined: Fri Aug 07, 2020 9:44 am

Re: Does uboot has I2c drivers for Raspberry Pi CM3

Wed Aug 26, 2020 2:06 pm

1. The I2C settings as configured from .config:

#
# I2C support
#
CONFIG_DM_I2C=y
CONFIG_DM_I2C_COMPAT=y
CONFIG_I2C_SET_DEFAULT_BUS_NUM=y
CONFIG_I2C_DEFAULT_BUS_NUMBER=0x0
CONFIG_DM_I2C_GPIO=y
# CONFIG_SYS_I2C_FSL is not set
# CONFIG_SYS_I2C_DW is not set
# CONFIG_SYS_I2C_INTEL is not set
# CONFIG_SYS_I2C_IMX_LPI2C is not set
# CONFIG_SYS_I2C_MXC is not set
# CONFIG_SYS_I2C_ROCKCHIP is not set
# CONFIG_SYS_I2C_MVTWSI is not set
# CONFIG_SYS_I2C_IHS is not set
# CONFIG_I2C_MUX is not set
CONFIG_INPUT=y
CONFIG_DM_KEYBOARD=y
# CONFIG_CROS_EC_KEYB is not set
# CONFIG_I8042_KEYB is not set
# CONFIG_TWL4030_INPUT is not set


2. U-Boot version: 2019.01-00003

3. On I2C bus 0 there is only a single device connected (eeprom)

4. Device tree settings

i2c@7e205000 {
compatible = "brcm,bcm2835-i2c";
reg = <0x7e205000 0x200>;
interrupts = <0x2 0x15>;
clocks = <0x6 0x14>;
#address-cells = <0x1>;
#size-cells = <0x0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <0x11>;
clock-frequency = <0x186a0>;
phandle = <0x2d>;

eeprom@52 {
compatible = "atmel,24c32";
reg = <0x52>;
pagesize = <0x20>;
num-addresses = <0x8>;
};
};

i2c@7e804000 {
compatible = "brcm,bcm2835-i2c";
reg = <0x7e804000 0x1000>;
interrupts = <0x2 0x15>;
clocks = <0x6 0x14>;
#address-cells = <0x1>;
#size-cells = <0x0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <0x1d>;
clock-frequency = <0x186a2>;
phandle = <0x2e>;

...[other devices]...
};

i2c@7e805000 {
compatible = "brcm,bcm2835-i2c";
reg = <0x7e805000 0x1000>;
interrupts = <0x2 0x15>;
clocks = <0x6 0x14>;
#address-cells = <0x1>;
#size-cells = <0x0>;
status = "disabled";
clock-frequency = <0x186a0>;
phandle = <0x1e>;
};

i2c0 {
brcm,pins = <0x0 0x1>;
brcm,function = <0x4>;
phandle = <0x11>;
};

i2c1 {
brcm,pins = <0x2 0x3>;
brcm,function = <0x4>;
phandle = <0x1d>;
};

i2c0 = "/soc/i2c@7e205000";
i2c1 = "/soc/i2c@7e804000";
i2c2 = "/soc/i2c@7e805000";


5. Output from U-Boot:

U-Boot> i2c dev 0
Setting bus to 0
uclass_find_device_by_seq: 0 0
- not found
uclass_find_device_by_seq: 1 0
- not found
Failure changing bus number (-19)


Thanks for your response and sorry for the delayed answer.

Best regards,
Nick

Return to “Advanced users”