Re: [PATCH 2/7] power: mxs_power: add driver for mxs power subsystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi,

On Sun, Mar 22, 2015 at 12:29:58AM +0000, Stefan Wahren wrote:
> This patch adds a minimal driver for the Freescale i.MX23, i.MX28
> power subsystem. It's required to trigger the probing of the underlying
> drivers like on-chip regulators.
> 
> [...]
>
> +config MXS_POWER
> +	tristate "Freescale MXS power subsystem support"
> +	depends on ARCH_MXS

please add "|| COMPILE_TEST"

> +	help
> +	  Say Y here to enable support for the Freescale i.MX23/i.MX28
> +	  power subsystem. This is a requirement to get access to on-chip
> +	  regulators, battery charger and many more.
>
> [...]
>
> +static int mxs_power_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct device_node *np = dev->of_node;
> +	struct resource *res;
> +	struct mxs_power_data *data;
> +	struct power_supply_config psy_cfg = {};
> +	void __iomem *v5ctrl_addr;
> +
> +	if (!np) {
> +		dev_err(dev, "missing device tree\n");
> +		return -EINVAL;
> +	}
> +
> +	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	data->base_addr = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(data->base_addr))
> +		return PTR_ERR(data->base_addr);
> +
> +	psy_cfg.drv_data = data;
> +
> +	data->ac = power_supply_register(dev, &ac_desc, &psy_cfg);
> +	if (IS_ERR(data->ac))
> +		return PTR_ERR(data->ac);

You can use devm_power_supply_register to simplify the driver
a bit more.

> +	platform_set_drvdata(pdev, data);
> +
> +	v5ctrl_addr = data->base_addr + HW_POWER_5VCTRL_OFFSET;
> +
> +	/* Make sure the current limit of the linregs are disabled. */
> +	writel(BM_POWER_5VCTRL_ENABLE_LINREG_ILIMIT,
> +	       v5ctrl_addr + HW_POWER_CTRL_CLR);
> +
> +	return of_platform_populate(np, NULL, NULL, dev);
> +}
> +
> [...]

-- Sebastian

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux