Subject: Re: [PATCH v6 3/8] mfd: khadas-mcu: Add per-variant configuration infrastructure and VIM4 support

From: Lee Jones <[email-masked]>
Date: Wed, 27 May 2026 15:54:23 +0100

On Sat, 16 May 2026, Ronald Claveau via B4 Relay wrote:

> From: Ronald Claveau <[email-masked]>
> 
> Introduce a per-variant configuration structure (khadas_mcu_data)
> holding the regmap config and MFD cells,
> selected at probe time via the of_device_id match data.
> This makes adding other variants straightforward.
> 
> Add an enum khadas_mcu_type used as value to match.
> 
> Also introduce khadas_mcu_fan_pdata to pass fan register address and
> maximum level to the fan sub-driver, removing the hardcoded constants.
> 
> Reviewed-by: Neil Armstrong <[email-masked]>
> Signed-off-by: Ronald Claveau <[email-masked]>
> ---
>  include/linux/mfd/khadas-mcu.h | 44 ++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 42 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/mfd/khadas-mcu.h b/include/linux/mfd/khadas-mcu.h
> index a99ba2ed0e4e0..88de49b78f5e6 100644
> --- a/include/linux/mfd/khadas-mcu.h
> +++ b/include/linux/mfd/khadas-mcu.h
> @@ -70,6 +70,13 @@
>  #define KHADAS_MCU_WOL_INIT_START_REG		0x87 /* WO */
>  #define KHADAS_MCU_CMD_FAN_STATUS_CTRL_REG	0x88 /* WO */
>  
> +/* VIM4 specific registers */
> +#define KHADAS_MCU_VIM4_REST_CONF_REG		0x2c /* WO - reset EEPROM */
> +#define KHADAS_MCU_VIM4_LED_ON_RAM_REG		0x89 /* WO - LED volatile */
> +#define KHADAS_MCU_VIM4_FAN_CTRL_REG		0x8a /* WO */
> +#define KHADAS_MCU_VIM4_WDT_EN_REG		0x8b /* WO */
> +#define KHADAS_MCU_VIM4_SYS_RST_REG		0x91 /* WO */
> +
>  enum {
>  	KHADAS_BOARD_VIM1 = 0x1,
>  	KHADAS_BOARD_VIM2,
> @@ -82,10 +89,43 @@ enum {
>   * struct khadas_mcu - Khadas MCU structure
>   * @device:		device reference used for logs
>   * @regmap:		register map
> + * @data:		pointer to variant-specific config
>   */
>  struct khadas_mcu {
> -	struct device *dev;
> -	struct regmap *regmap;
> +	struct device			*dev;
> +	struct regmap			*regmap;
> +	const struct khadas_mcu_data	*data;
> +};
> +
> +/**
> + * struct khadas_mcu_data - per-variant configuration
> + * @regmap_config:	regmap configuration
> + * @cells:		MFD sub-devices
> + * @ncells:		number of sub-devices
> + * @fan_cells:		MFD fan sub-devices
> + * @nfan_cells:		number of fan sub-devices
> + */
> +struct khadas_mcu_data {
> +	const struct regmap_config	*regmap_config;
> +	const struct mfd_cell		*cells;
> +	int				ncells;
> +	const struct mfd_cell		*fan_cells;
> +	int				nfan_cells;
> +};

My alarm bells started ringing as soon as I saw this!

> +/**
> + * struct khadas_mcu_fan_pdata - fan sub-driver configuration
> + * @fan_reg: register address to write the fan level
> + * @max_level: maximum fan level
> + */
> +struct khadas_mcu_fan_pdata {
> +	unsigned int fan_reg;
> +	unsigned int max_level;
> +};
> +
> +enum khadas_mcu_type {
> +	KHADAS_MCU_GENERIC, /* VIM1/2/3, Edge, Edge-V */
> +	KHADAS_MCU_VIM4,
>  };
>  
>  #endif /* MFD_KHADAS_MCU_H */
> 
> -- 
> 2.49.0
> 
> 

-- 
Lee Jones