+ memcpy((void *)pc->data, &ph, sizeof(ph));
+ fdt_setprop_cell(blob, off, "pinctrl-0", ph);
+}
+
+void karo_fdt_fixup_flexcan(void *blob, int xcvr_present)
+{
+ int ret;
+ const char *xcvr_status = "disabled";
+ const char *otg_mode = getenv("otg_mode");
+
+ if (xcvr_present) {
+ if (karo_fdt_flexcan_enabled(blob)) {
+ if (!is_lvds()) {
+ debug("Changing LCD to use 23bits only\n");
+ karo_fdt_set_lcd_pins(blob, "lcdif-23bit-pins-a");
+ /* handle legacy alias name */
+ karo_fdt_set_lcd_pins(blob, "lcdif_23bit_pins_a");
+ xcvr_status = NULL;
+ }
+ } else if (!is_lvds()) {
+ debug("Changing LCD to use 24bits\n");
+ karo_fdt_set_lcd_pins(blob, "lcdif-24bit-pins-a");
+ /* handle legacy alias name */
+ karo_fdt_set_lcd_pins(blob, "lcdif_24bit_pins_a");
+ }
+ } else {
+ int off = fdt_path_offset(blob, "can0");
+
+ if (off >= 0)
+ fdt_delprop(blob, off, "xceiver-supply");
+ off = fdt_path_offset(blob, "can1");
+ if (off >= 0)
+ fdt_delprop(blob, off, "xceiver-supply");
+ if (!is_lvds()) {
+ karo_fdt_set_lcd_pins(blob, "lcdif-24bit-pins-a");
+ /* handle legacy alias name */
+ karo_fdt_set_lcd_pins(blob, "lcdif_24bit_pins_a");
+ }
+ }
+
+ if (otg_mode && strcasecmp(otg_mode, "host") == 0)
+ karo_fdt_enable_node(blob, "can1", 0);
+
+ if (xcvr_status) {
+ debug("Disabling CAN XCVR\n");
+ ret = fdt_find_and_setprop(blob, "reg-can-xcvr", "status",
+ xcvr_status, strlen(xcvr_status) + 1, 1);
+ if (ret == -FDT_ERR_NOTFOUND || ret == -FDT_ERR_BADPATH)
+ ret = fdt_find_and_setprop(blob, "reg_can_xcvr", "status",
+ xcvr_status, strlen(xcvr_status) + 1, 1);
+ if (ret && ret != -FDT_ERR_NOTFOUND && ret != -FDT_ERR_BADPATH)
+ printf("Failed to disable CAN transceiver switch: %s\n",
+ fdt_strerror(ret));
+ }
+}
+
+void karo_fdt_del_prop(void *blob, const char *compat, u32 offs,
+ const char *propname)
+{
+ int offset = -1;
+ const fdt32_t *reg = NULL;
+
+ while (1) {
+ offset = fdt_node_offset_by_compatible(blob, offset, compat);
+ if (offset <= 0)
+ return;
+
+ reg = fdt_getprop(blob, offset, "reg", NULL);
+ if (reg == NULL)
+ return;
+
+ if (fdt32_to_cpu(*reg) == offs)
+ break;
+ }
+ debug("Removing property '%s' from node %s@%x\n",
+ propname, compat, offs);
+ fdt_delprop(blob, offset, propname);
+