Re: [PATCH] mfd: regulator: initial support for pca9450

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

 



Hi Holger,

On Mon, Jul 24, 2023 at 09:52:58AM +0200, Holger Assmann wrote:
> +++ b/drivers/mfd/pca9450.c
> @@ -0,0 +1,106 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (C) 2023 Holger Assmann, Pengutronix
> + */
> +
> +#include <common.h>
> +#include <driver.h>
> +#include <errno.h>
> +#include <i2c/i2c.h>
> +#include <init.h>
> +#include <mfd/pca9450.h>
> +#include <of.h>
> +#include <regmap.h>
> +#include <reset_source.h>
> +
> +#define REASON_PMIC_RST		0x10
> +#define REASON_PWON		0x80
> +#define REASON_SW_RST		0x20
> +#define REASON_WDOG		0x40

Please sort these defines by register bit.

> +
> +static const struct regmap_config pca9450_regmap_i2c_config = {
> +	.reg_bits = 8,
> +	.val_bits = 8,
> +	.max_register = 0x2E,
> +};
> +
> +static int pca9450_get_reset_source(struct device *dev, struct regmap *map)
> +{
> +	enum reset_src_type type;
> +	int reg;
> +	int ret;
> +
> +	ret = regmap_read(map, PCA9450_PWRON_STAT, &reg);
> +	if (ret)
> +		return ret;
> +	
> +	switch (reg) {
> +		case REASON_PWON:
> +			dev_dbg(dev, "Power ON triggered by PMIC_ON_REQ.\n");
> +			type = RESET_POR;
> +			break;
> +		case REASON_WDOG:
> +			dev_dbg(dev, "Detected cold reset by WDOGB pin\n");
> +			type = RESET_WDG;
> +			break;
> +		case REASON_SW_RST:
> +			dev_dbg(dev, "Detected cold reset by SW_RST\n");
> +			type = RESET_RST;
> +			break;
> +		case REASON_PMIC_RST:
> +			dev_dbg(dev, "Detected cold reset by PMIC_RST_B\n");
> +			type = RESET_EXT;
> +			break;
> +		default:
> +			dev_warn(dev, "Could not determine reset reason.\n");
> +			type = RESET_UKWN;
> +	}

Coding style is to align the 'case' directly under 'switch'.

> +
> +	reset_source_set_device(dev, type);
> +
> +	return 0;
> +};
> +	

There are some trailing whitespaces here and elsewhere.

Otherwise looks good.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux