/sys/devices/platform/charger/BatteryCapacityCtrl
/sys/devices/platform/charger/FakeBatteryTemp
(220221_14:55:17.275)[ 61.765298] <6>.(6)[226:irq/161-mt6358-]mt6397 1000d000.pwrap:main_pmic: Reg[0x91a]=0x40,name=chrdet_edge,hwirq=54,type=0
(220221_14:55:17.277)[ 61.766739] <6>.(6)[226:irq/161-mt6358-]Isaac [chrdet_int_handler] enter
(220221_14:55:17.277)[ 61.767599] <6>.(6)[226:irq/161-mt6358-]chrdet_int_handler: chrdet:1
(220221_14:55:17.277)[ 61.768443] <6>.(6)[226:irq/161-mt6358-]Isaac [do_charger_detect] enter, en=1
(220221_14:55:17.277)[ 61.769355] <6>.(6)[226:irq/161-mt6358-][MUSB]usb20_check_vbus_on 121: vbus_on<0>
(220221_14:55:17.278)[ 61.770302] <6>.(6)[226:irq/161-mt6358-]Isaac [psy_chr_type_set_property]: prop:4 1
(220221_14:55:17.278)[ 61.771289] <6>.(6)[226:irq/161-mt6358-]Isaac [get_charger_type] mt6357-charger-type.c enter
(220221_14:55:17.493)[ 61.980244] <6>.(6)[226:irq/161-mt6358-]CDP, PASS
(220221_14:55:17.500)[ 62.040277] <0>-(0)[226:irq/161-mt6358-][MUSB]usb_6765_dpidle_request 92: USB_DPIDLE_FORBIDDEN, skip_cnt<0>
(220221_14:55:17.500)[ 62.041580] <0>-(0)[226:irq/161-mt6358-][MUSB]usb_6765_dpidle_request 85: USB_DPIDLE_ALLOWED, skip_cnt<0>
(220221_14:55:17.500)[ 62.042791] <0>.(0)[226:irq/161-mt6358-][MUSB]Charger_Detect_Init 812: Charger_Detect_Init
(220221_14:55:17.822)[ 62.308268] <1>.(1)[226:irq/161-mt6358-]charger type: DCP, keep DM voltage source in stepB2
(220221_14:55:17.823)[ 62.309341] <1>.(1)[226:irq/161-mt6358-]charger type: skip bc11 release for BC12 DCP SPEC
(220221_14:55:17.823)[ 62.310375] <1>.(1)[226:irq/161-mt6358-]charger type: 5, Standard Charger
(220221_14:55:17.823)[ 62.311238] <1>.(1)[226:irq/161-mt6358-]psy_chr_type_get_property: prop:58
(220221_14:55:17.823)[ 62.312109] <1>.(1)[226:irq/161-mt6358-]psy_chr_type_get_property: prop:59
(220221_14:55:17.823)[ 62.313018] <1>.(1)[226:irq/161-mt6358-]do_charger_detect type:5 usb_type:2
(220221_14:55:17.823)[ 62.313900] <1>.(1)[226:irq/161-mt6358-]Isaac [power_supply_changed] enter
(220221_14:55:17.823)[ 62.314778] <1>-(1)[226:irq/161-mt6358-]CPU: 1 PID: 226 Comm: irq/161-mt6358- Tainted: P W O 4.19.127 #41
(220221_14:55:17.823)[ 62.316128] <1>-(1)[226:irq/161-mt6358-]Hardware name: MT8768WA (DT)
(220221_14:55:17.823)[ 62.316936] <1>-(1)[226:irq/161-mt6358-]Call trace:
(220221_14:55:17.823)[ 62.317575] <1>-(1)[226:irq/161-mt6358-] dump_backtrace+0x0/0x164
(220221_14:55:17.823)[ 62.318353] <1>-(1)[226:irq/161-mt6358-] show_stack+0x20/0x2c
(220221_14:55:17.823)[ 62.319091] <1>-(1)[226:irq/161-mt6358-] dump_stack+0xb8/0xf0
(220221_14:55:17.823)[ 62.319826] <1>-(1)[226:irq/161-mt6358-] power_supply_changed+0x28/0x78
(220221_14:55:17.823)[ 62.320669] <1>-(1)[226:irq/161-mt6358-] do_charger_detect+0xd0/0xfc
(220221_14:55:17.823)[ 62.321497] <1>-(1)[226:irq/161-mt6358-] chrdet_int_handler+0xd4/0x104
(220221_14:55:17.823)[ 62.322332] <1>-(1)[226:irq/161-mt6358-] handle_nested_irq+0xbc/0x124
(220221_14:55:17.823)[ 62.323153] <1>-(1)[226:irq/161-mt6358-] mt6358_irq_handler+0x1ec/0x294
(220221_14:55:17.824)[ 62.323993] <1>-(1)[226:irq/161-mt6358-] irq_thread_fn+0x2c/0x60
(220221_14:55:17.824)[ 62.324756] <1>-(1)[226:irq/161-mt6358-] irq_thread+0x10c/0x19c
(220221_14:55:17.824)[ 62.325511] <1>-(1)[226:irq/161-mt6358-] kthread+0x114/0x124
(220221_14:55:17.824)[ 62.326233] <1>-(1)[226:irq/161-mt6358-] ret_from_fork+0x10/0x18
(220221_14:55:17.824)[ 62.327162] <1>.(1)[18:kworker/1:0]psy_chr_type_get_property: prop:4
(220221_14:55:17.824)[ 62.327972] <1>.(1)[18:kworker/1:0]psy_chr_type_get_property: prop:0
(220221_14:55:17.824)[ 62.329656] <1>.(1)[18:kworker/1:0][fg_sw_bat_cycle_accu]car[o:-47 n:-211],diff_car:-164,ncar[o:47 n:211 hw:0] thr 62660
(220221_14:55:17.824)[ 62.331031] <1>.(1)[18:kworker/1:0]Isaac [battery_update] enter
(220221_14:55:17.824)[ 62.331788] <1>-(1)[18:kworker/1:0]CPU: 1 PID: 18 Comm: kworker/1:0 Tainted: P W O 4.19.127 #41
(220221_14:55:17.824)[ 62.333026] <1>-(1)[18:kworker/1:0]Hardware name: MT8768WA (DT)
(220221_14:55:17.824)[ 62.333791] <1>-(1)[18:kworker/1:0]Workqueue: events power_supply_changed_work
(220221_14:55:17.824)[ 62.334709] <1>-(1)[18:kworker/1:0]Call trace:
(220221_14:55:17.824)[ 62.335280] <1>-(1)[18:kworker/1:0] dump_backtrace+0x0/0x164
(220221_14:55:17.824)[ 62.336002] <1>-(1)[18:kworker/1:0] show_stack+0x20/0x2c
(220221_14:55:17.824)[ 62.336682] <1>-(1)[18:kworker/1:0] dump_stack+0xb8/0xf0
(220221_14:55:17.825)[ 62.337360] <1>-(1)[18:kworker/1:0] battery_update+0x38/0x10c
(220221_14:55:17.825)[ 62.338092] <1>-(1)[18:kworker/1:0] mtk_battery_external_power_changed+0x108/0x1dc
(220221_14:55:17.825)[ 62.339052] <1>-(1)[18:kworker/1:0] __power_supply_changed_work+0x40/0x50
(220221_14:55:17.825)[ 62.339918] <1>-(1)[18:kworker/1:0] class_for_each_device+0x90/0xfc
(220221_14:55:17.825)[ 62.340716] <1>-(1)[18:kworker/1:0] power_supply_changed_work+0x60/0xc4
(220221_14:55:17.825)[ 62.341557] <1>-(1)[18:kworker/1:0] process_one_work+0x210/0x3e8
(220221_14:55:17.825)[ 62.342322] <1>-(1)[18:kworker/1:0] worker_thread+0x228/0x3c4
(220221_14:55:17.825)[ 62.343054] <1>-(1)[18:kworker/1:0] kthread+0x114/0x124
(220221_14:55:17.825)[ 62.343721] <1>-(1)[18:kworker/1:0] ret_from_fork+0x10/0x18
------------------------------------------------------------------------------------------------------------------------------------
/kernel-4.19/arch/arm64/boot/dts/mediatek/mt6357.dtsi
&main_pmic {
mtk_charger_type: mtk_charger_type {
compatible = "mediatek,mt6357-charger-type";
io-channels = <&pmic_auxadc AUXADC_VCDT>;
io-channel-names = "pmic_vbus";
bc12_active = <0>;
};
}
/kernel-4.19/arch/arm64/boot/dts/mediatek/tb8768p1_64_bsp.dts
&mtk_charger_type {
bc12_active = <1>;
};
/kernel-4.19/drivers/power/supply/mt6357-charger-type.c
static const struct of_device_id mt6357_charger_type_of_match[] = {
{.compatible = "mediatek,mt6357-charger-type",},
{},
};
static struct platform_driver mt6357_charger_type_driver = {
.probe = mt6357_charger_type_probe,
.remove = mt6357_charger_type_remove,
//.shutdown = mt6357_charger_type_shutdown,
.driver = {
.name = "mt6357-charger-type-detection",
.of_match_table = mt6357_charger_type_of_match,
},
};
static enum power_supply_usb_type mt6357_charger_usb_types[] = {
POWER_SUPPLY_USB_TYPE_UNKNOWN,
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
};
static char *mt6357_charger_supplied_to[] = {
"battery",
"mtk-master-charger"
};
static int mt6357_charger_type_probe(struct platform_device *pdev)
{
struct mtk_charger_type *info;
info->psy_desc.name = "mtk_charger_type";
info->psy_desc.type = POWER_SUPPLY_TYPE_UNKNOWN;
info->psy_desc.properties = chr_type_properties;
info->psy_desc.num_properties = ARRAY_SIZE(chr_type_properties);
info->psy_desc.get_property = psy_chr_type_get_property;
info->psy_desc.set_property = psy_chr_type_set_property;
info->psy_desc.property_is_writeable = psy_charger_type_property_is_writeable;
info->psy_desc.usb_types = mt6357_charger_usb_types,
info->psy_desc.num_usb_t