[PATCH 3/3] memory: brcmstb_memc: Add new DDR attributes

Krzysztof Kozlowski krzysztof.kozlowski at linaro.org
Mon Mar 27 09:04:13 PDT 2023


On 24/03/2023 17:52, Florian Fainelli wrote:
> Provide information about the DDR size, type, width, total width,
> dual/single rank. This is useful for reporting purposes and inventory of
> the system(s).
> 
> Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>
> ---
>  drivers/memory/brcmstb_memc.c | 80 ++++++++++++++++++++++++++++++++++-
>  1 file changed, 79 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/memory/brcmstb_memc.c b/drivers/memory/brcmstb_memc.c
> index 67c75e21c95e..032567dfd6e2 100644
> --- a/drivers/memory/brcmstb_memc.c
> +++ b/drivers/memory/brcmstb_memc.c
> @@ -13,7 +13,14 @@
>  
>  #define REG_MEMC_CNTRLR_CONFIG		0x00
>  #define  CNTRLR_CONFIG_LPDDR4_SHIFT	5
> -#define  CNTRLR_CONFIG_MASK		0xf
> +#define  CNTRLR_CONFIG_MASK		GENMASK(3, 0)
> +#define  CNTRLR_CONFIG_SIZE_SHIFT	4
> +#define  CNTRLR_CONFIG_SIZE_MASK	GENMASK(7, 4)
> +#define  CNTRLR_CONFIG_WIDTH_SHIFT	8
> +#define  CNTRLR_CONFIG_WIDTH_MASK	GENMASK(9, 8)
> +#define  CNTRLR_CONFIG_TOT_WIDTH_SHIFT	10
> +#define  CNTRLR_CONFIG_TOT_WIDTH_MASK	GENMASK(11, 10)
> +#define  CNTRLR_CONFIG_RANK_SHIFT	16
>  #define REG_MEMC_SRPD_CFG_21		0x20
>  #define REG_MEMC_SRPD_CFG_20		0x34
>  #define REG_MEMC_SRPD_CFG_1x		0x3c
> @@ -63,6 +70,67 @@ static int brcmstb_memc_srpd_config(struct brcmstb_memc *memc,
>  	return 0;
>  }
>  
> +static ssize_t ddr_rank_show(struct device *dev,
> +			     struct device_attribute *attr, char *buf)
> +{
> +	struct brcmstb_memc *memc = dev_get_drvdata(dev);
> +
> +	return sprintf(buf, "%s\n",
> +		       memc->config_reg & CNTRLR_CONFIG_RANK_SHIFT ?
> +		       "dual" : "single");

Why all these are not sysfs_emit()? I think it is the preferred (safer)
interface.

Best regards,
Krzysztof




More information about the linux-arm-kernel mailing list