Skip to content

Commit

Permalink
drivers: of: Override bootmode for offline charger
Browse files Browse the repository at this point in the history
Change-Id: Iab1d472d758159f89e5d100d35b9810642e7baa5
Signed-off-by: bengris32 <bengris32@protonmail.ch>
  • Loading branch information
bengris32 committed Sep 18, 2024
1 parent a6c1fe2 commit fc5e677
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions drivers/of/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,44 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
return 1;
}

#ifdef CONFIG_OPLUS_CHARGER
int __init early_init_dt_scan_android(unsigned long node, const char *uname,
int depth, void *data)
{
int err;
char *str, *cmdline = data;

pr_info("search \"/firmware/android\", depth: %d, uname: %s\n", depth, uname);

if (depth != 2 || !cmdline ||
strcmp(uname, "android") != 0)
return 0;

/*
* early_init_dt_scan_chosen() should have already
* set boot_command_line for us.
*/
str = strstr(cmdline, "androidboot.bootreason=usb");
if (!str)
/*
* We didn't find androidboot.bootreason=usb in the
* command line.
*
* In this case, just break out.
*/
return 1;

/* override mode to be charger. */
err = fdt_setprop_string(initial_boot_params, node, "mode", "charger");
if (err < 0) {
pr_err("Failed to update FDT property: %d.", err);
}

/* break now */
return 1;
}
#endif

#ifdef CONFIG_HAVE_MEMBLOCK
#ifndef MIN_MEMBLOCK_ADDR
#define MIN_MEMBLOCK_ADDR __pa(PAGE_OFFSET)
Expand Down Expand Up @@ -1359,6 +1397,11 @@ void __init early_init_dt_scan_nodes(void)

/* Setup memory, calling early_init_dt_add_memory_arch */
of_scan_flat_dt(early_init_dt_scan_memory, NULL);

#ifdef CONFIG_OPLUS_CHARGER
/* Fixup fdt for Android offline charger. */
of_scan_flat_dt(early_init_dt_scan_android, boot_command_line);
#endif
}

bool __init early_init_dt_scan(void *params)
Expand Down

0 comments on commit fc5e677

Please sign in to comment.