Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5c55731 authored by Kyle Yan's avatar Kyle Yan Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drm/dsi-staging: add support to get regulator data from device tree" into msm-4.8

parents 7d96c5ca 485f736c
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -445,6 +445,61 @@ static int dsi_pwr_enable_vregs(struct dsi_regulator_info *regs, bool enable)
	return rc;
}

/**
* dsi_clk_pwr_of_get_vreg_data - Parse regulator supply information
* @of_node:        Device of node to parse for supply information.
* @regs:           Pointer where regulator information will be copied to.
* @supply_name:    Name of the supply node.
*
* return: error code in case of failure or 0 for success.
*/
int dsi_clk_pwr_of_get_vreg_data(struct device_node *of_node,
				 struct dsi_regulator_info *regs,
				 char *supply_name)
{
	int rc = 0;
	struct device_node *supply_root_node = NULL;

	if (!of_node || !regs) {
		pr_err("Bad params\n");
		return -EINVAL;
	}

	regs->count = 0;
	supply_root_node = of_get_child_by_name(of_node, supply_name);
	if (!supply_root_node) {
		supply_root_node = of_parse_phandle(of_node, supply_name, 0);
		if (!supply_root_node) {
			pr_err("No supply entry present for %s\n", supply_name);
			return -EINVAL;
		}
	}

	regs->count = of_get_available_child_count(supply_root_node);
	if (regs->count == 0) {
		pr_err("No vregs defined for %s\n", supply_name);
		return -EINVAL;
	}

	regs->vregs = kcalloc(regs->count, sizeof(*regs->vregs), GFP_KERNEL);
	if (!regs->vregs) {
		regs->count = 0;
		return -ENOMEM;
	}

	rc = dsi_pwr_parse_supply_node(supply_root_node, regs);
	if (rc) {
		pr_err("failed to parse supply node for %s, rc = %d\n",
			supply_name, rc);

		kfree(regs->vregs);
		regs->vregs = NULL;
		regs->count = 0;
	}

	return rc;
}

/**
 * dsi_clk_pwr_get_dt_vreg_data - parse regulator supply information
 * @dev:            Device whose of_node needs to be parsed.
+1 −1
Original line number Diff line number Diff line
@@ -1371,7 +1371,7 @@ static struct platform_driver dsi_ctrl_driver = {
	.probe = dsi_ctrl_dev_probe,
	.remove = dsi_ctrl_dev_remove,
	.driver = {
		.name = "mdss_dsi_ctrl",
		.name = "drm_dsi_ctrl",
		.of_match_table = msm_dsi_of_match,
	},
};