Thank you Mark for the changes to add bus frequency control to the i2c
driver. I tested your changes (with the addition of logging of the
frequency).

 

Before changing the dtb (no clock-frequency entry):

 

sxidog0 at simplebus0

com0 at simplebus0: ns16550, no working fifo

com0: console

sxitwi0 at simplebus0: clock frequency 100000.

iic0 at sxitwi0

bme0 at iic0 addr 0x77: BME280 60

sxitwi1 at simplebus0: clock frequency 100000.

iic1 at sxitwi1

bme1 at iic1 addr 0x76: BME280 60

ampintc0 at simplebus0 nirq 160, ncpu 4

sxirtc0 at simplebus0

 

Then I added a frequency of 50kHz to i2c-0 and 200kHz to i2c-1:

 

                i2c@1c2ac00 {

                        compatible = "allwinner,sun6i-a31-i2c";

                        reg = <0x1c2ac00 0x400>;

                        interrupts = <0x0 0x6 0x4>;

                        clocks = <0x2 0x3b>;

                        resets = <0x2 0x2e>;

                        pinctrl-names = "default";

                        pinctrl-0 = <0x16>;

                        status = "okay";

                        #address-cells = <0x1>;

                        #size-cells = <0x0>;

                        clock-frequency = <0x0000c350>;

 

                        bme@0 {

                                reg = <0x77>;

                                interrupts = <0x0>;

                                compatible = "bosch,bme280";

                        };

                };

 

                i2c@1c2b000 {

                        compatible = "allwinner,sun6i-a31-i2c";

                        reg = <0x1c2b000 0x400>;

                        interrupts = <0x0 0x7 0x4>;

                        clocks = <0x2 0x3c>;

                        resets = <0x2 0x2f>;

                        pinctrl-names = "default";

                        pinctrl-0 = <0x17>;

                        status = "okay";

                        #address-cells = <0x1>;

                        #size-cells = <0x0>;

                        clock-frequency = <0x00030d40>;

 

                        bme@1 {

                                reg = <0x76>;

                                interrupts = <0x0>;

                                compatible = "bosch,bme280";

                        };

                };

 

com0: console

sxitwi0 at simplebus0: clock frequency 50000.

iic0 at sxitwi0

bme0 at iic0 addr 0x77: BME280 60

sxitwi1 at simplebus0: clock frequency 200000.

iic1 at sxitwi1

bme1 at iic1 addr 0x76: BME280 60

ampintc0 at simplebus0 nirq 160, ncpu 4

sxirtc0 at simplebus0

 

I checked the 50 and 200 kHz with a scope on the clock lines.

Reply via email to