hansemro / kc1-linux

Documentation of mainline Linux on First Generation Kindle Fire
GNU General Public License v2.0
4 stars 0 forks source link

Add Sumit SMB347 support to device tree #10

Open hansemro opened 3 years ago

hansemro commented 3 years ago

Reference:

arch/arm/boot/dts/omap4-kc1.dts:

&i2c1 {
    ...
    charger@6 {
        compatible = "summit,smb347";
        reg = <0x06>;
        summit,usb-current-limit-microamp = <500000>;
        summit,enable-usb-charging;
        monitored-battery = <&bat>;
        /* Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml */
    };
    ...
};
hansemro commented 3 years ago

Kernel log:

[    3.506622] smb347: probe of 0-0006 failed with error -121
hansemro commented 3 years ago

Kernel log from 3.4.48:

[    2.719635] summit_smb347 4-0006: smb347_read_id: config = 0xd
[    2.726074] summit_smb347 4-0006: USBIN in use
[    2.747497] summit_smb347 4-0006: Summit SMB347 detected, chip_id=0x6 board id=6
hansemro commented 3 years ago

I realized I mistakenly placed the charger IC in i2c-1 and not i2c-4.

hansemro commented 3 years ago

arch/arm/boot/dts/omap4-kc1.dts:

&i2c4 {
    ...
    charger@6 {
        compatible = "summit,smb347";
        reg = <0x06>;
        summit,usb-current-limit-microamp = <500000>;
        summit,enable-usb-charging;
        monitored-battery = <&bat>;
        /* Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml */
    };
};

5.11.0 kernel log:

[    5.790832] power_supply smb347-usb: power_supply_changed
[    5.797027] power_supply smb347-usb: power_supply_changed_work
[    5.803253] power_supply smb347-usb: power_supply_update_gen_leds 1

Initial condition: device connected to computer via USB (fully charged)

amazon-otter:~# cat /sys/class/power_supply/smb347-usb/charge_type 
N/A
amazon-otter:~# cat /sys/class/power_supply/smb347-usb/online 
1
amazon-otter:~# cat /sys/class/power_supply/smb347-usb/status
Full
amazon-otter:~# cat /sys/class/power_supply/smb347-usb/type
USB
amazon-otter:~# cat /sys/class/power_supply/smb347-usb/constant_charge_current 
150000
amazon-otter:~# cat /sys/class/power_supply/smb347-usb/constant_charge_voltage 
4200000

After unplugging USB, smb347-usb driver reports an error when reading status property

amazon-otter:~# cat /sys/class/power_supply/smb347-usb/status
cat: /sys/class/power_supply/smb347-usb/status: Remote I/O error

Kernel log:

[  359.540740] power_supply smb347-usb: driver failed to report `status' property: -121

Replugging in, we can check status property again:

amazon-otter:~# cat /sys/class/power_supply/smb347-usb/status
Charging

After a while, the device reports full again (as expected):

amazon-otter:~# cat /sys/class/power_supply/smb347-usb/status
Full
hansemro commented 3 years ago

2344d5a46c579a743d8a16d72d5d130ef315a399: Added smb347 to device tree in the dtb_dev branch