devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: Ludovic Desroches
	<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org,
	plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org,
	boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/3] ARM: at91: use chipid device for soc detection
Date: Fri, 18 Mar 2016 11:34:18 +0100	[thread overview]
Message-ID: <20160318103418.GA2531@piout.net> (raw)
In-Reply-To: <1458285681-25684-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

On 18/03/2016 at 08:21:19 +0100, Ludovic Desroches wrote :
> So far, the CIDR and EXID registers were in the DBGU interface. This device
> has disappeared with the SAMA5D2 family. These registers are exposed
> through a new device called chipid.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> [nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org: remove useless warnings]
Acked-by: Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

> ---
>  .../devicetree/bindings/arm/atmel-at91.txt         |  4 ++
>  arch/arm/mach-at91/soc.c                           | 81 +++++++++++++++++-----
>  2 files changed, 67 insertions(+), 18 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/arm/atmel-at91.txt b/Documentation/devicetree/bindings/arm/atmel-at91.txt
> index 7fd64ec..0b1fcbf 100644
> --- a/Documentation/devicetree/bindings/arm/atmel-at91.txt
> +++ b/Documentation/devicetree/bindings/arm/atmel-at91.txt
> @@ -41,6 +41,10 @@ compatible: must be one of:
>         - "atmel,sama5d43"
>         - "atmel,sama5d44"
>  
> +Chipid required properties:
> +- compatible: Should be "atmel,sama5d2-chipid"
> +- reg : Should contain registers location and length
> +
>  PIT Timer required properties:
>  - compatible: Should be "atmel,at91sam9260-pit"
>  - reg: Should contain registers location and length
> diff --git a/arch/arm/mach-at91/soc.c b/arch/arm/mach-at91/soc.c
> index 54343ff..034d563 100644
> --- a/arch/arm/mach-at91/soc.c
> +++ b/arch/arm/mach-at91/soc.c
> @@ -22,48 +22,93 @@
>  #include "soc.h"
>  
>  #define AT91_DBGU_CIDR			0x40
> -#define AT91_DBGU_CIDR_VERSION(x)	((x) & 0x1f)
> -#define AT91_DBGU_CIDR_EXT		BIT(31)
> -#define AT91_DBGU_CIDR_MATCH_MASK	0x7fffffe0
>  #define AT91_DBGU_EXID			0x44
> +#define AT91_CHIPID_CIDR		0x00
> +#define AT91_CHIPID_EXID		0x04
> +#define AT91_CIDR_VERSION(x)		((x) & 0x1f)
> +#define AT91_CIDR_EXT			BIT(31)
> +#define AT91_CIDR_MATCH_MASK		0x7fffffe0
>  
> -struct soc_device * __init at91_soc_init(const struct at91_soc *socs)
> +int __init at91_get_cidr_exid_from_dbgu(u32 *cidr, u32 *exid)
>  {
> -	struct soc_device_attribute *soc_dev_attr;
> -	const struct at91_soc *soc;
> -	struct soc_device *soc_dev;
>  	struct device_node *np;
>  	void __iomem *regs;
> -	u32 cidr, exid;
>  
>  	np = of_find_compatible_node(NULL, NULL, "atmel,at91rm9200-dbgu");
>  	if (!np)
>  		np = of_find_compatible_node(NULL, NULL,
>  					     "atmel,at91sam9260-dbgu");
> +	if (!np)
> +		return -ENODEV;
>  
> -	if (!np) {
> -		pr_warn("Could not find DBGU node");
> -		return NULL;
> +	regs = of_iomap(np, 0);
> +	of_node_put(np);
> +
> +	if (!regs) {
> +		pr_warn("Could not map DBGU iomem range");
> +		return -ENXIO;
>  	}
>  
> +	*cidr = readl(regs + AT91_DBGU_CIDR);
> +	*exid = readl(regs + AT91_DBGU_EXID);
> +
> +	iounmap(regs);
> +
> +	return 0;
> +}
> +
> +int __init at91_get_cidr_exid_from_chipid(u32 *cidr, u32 *exid)
> +{
> +	struct device_node *np;
> +	void __iomem *regs;
> +
> +	np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-chipid");
> +	if (!np)
> +		return -ENODEV;
> +
>  	regs = of_iomap(np, 0);
>  	of_node_put(np);
>  
>  	if (!regs) {
>  		pr_warn("Could not map DBGU iomem range");
> -		return NULL;
> +		return -ENXIO;
>  	}
>  
> -	cidr = readl(regs + AT91_DBGU_CIDR);
> -	exid = readl(regs + AT91_DBGU_EXID);
> +	*cidr = readl(regs + AT91_CHIPID_CIDR);
> +	*exid = readl(regs + AT91_CHIPID_EXID);
>  
>  	iounmap(regs);
>  
> +	return 0;
> +}
> +
> +struct soc_device * __init at91_soc_init(const struct at91_soc *socs)
> +{
> +	struct soc_device_attribute *soc_dev_attr;
> +	const struct at91_soc *soc;
> +	struct soc_device *soc_dev;
> +	u32 cidr, exid;
> +	int ret;
> +
> +	/*
> +	 * With SAMA5D2 and later SoCs, CIDR and EXID registers are no more
> +	 * in the dbgu device but in the chipid device whose purpose is only
> +	 * to expose these two registers.
> +	 */
> +	ret = at91_get_cidr_exid_from_dbgu(&cidr, &exid);
> +	if (ret)
> +		ret = at91_get_cidr_exid_from_chipid(&cidr, &exid);
> +	if (ret) {
> +		if (ret == -ENODEV)
> +			pr_warn("Could not find identification node");
> +		return NULL;
> +	}
> +
>  	for (soc = socs; soc->name; soc++) {
> -		if (soc->cidr_match != (cidr & AT91_DBGU_CIDR_MATCH_MASK))
> +		if (soc->cidr_match != (cidr & AT91_CIDR_MATCH_MASK))
>  			continue;
>  
> -		if (!(cidr & AT91_DBGU_CIDR_EXT) || soc->exid_match == exid)
> +		if (!(cidr & AT91_CIDR_EXT) || soc->exid_match == exid)
>  			break;
>  	}
>  
> @@ -79,7 +124,7 @@ struct soc_device * __init at91_soc_init(const struct at91_soc *socs)
>  	soc_dev_attr->family = soc->family;
>  	soc_dev_attr->soc_id = soc->name;
>  	soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%X",
> -					   AT91_DBGU_CIDR_VERSION(cidr));
> +					   AT91_CIDR_VERSION(cidr));
>  	soc_dev = soc_device_register(soc_dev_attr);
>  	if (IS_ERR(soc_dev)) {
>  		kfree(soc_dev_attr->revision);
> @@ -91,7 +136,7 @@ struct soc_device * __init at91_soc_init(const struct at91_soc *socs)
>  	if (soc->family)
>  		pr_info("Detected SoC family: %s\n", soc->family);
>  	pr_info("Detected SoC: %s, revision %X\n", soc->name,
> -		AT91_DBGU_CIDR_VERSION(cidr));
> +		AT91_CIDR_VERSION(cidr));
>  
>  	return soc_dev;
>  }
> -- 
> 2.5.0
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-03-18 10:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18  7:21 [PATCH 1/3] ARM: at91: use chipid device for soc detection Ludovic Desroches
     [not found] ` <1458285681-25684-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2016-03-18  7:21   ` [PATCH 2/3] ARM: at91/soc: reference the whole sama5d2 family Ludovic Desroches
     [not found]     ` <1458285681-25684-2-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2016-03-18 10:34       ` Alexandre Belloni
2016-03-18  7:21   ` [PATCH 3/3] ARM: at91/dt: sama5d2: add chipid node Ludovic Desroches
     [not found]     ` <1458285681-25684-3-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2016-03-18 10:34       ` Alexandre Belloni
2016-03-18 10:34   ` Alexandre Belloni [this message]
2016-03-23 11:22     ` [PATCH 1/3] ARM: at91: use chipid device for soc detection Nicolas Ferre
     [not found]       ` <56F27C89.9070004-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2016-03-23 13:47         ` Alexandre Belloni
     [not found]           ` <20160323134750.GC2570-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org>
2016-03-29 13:53             ` Nicolas Ferre
2016-03-20  0:45   ` Rob Herring
2016-03-29 13:55 ` Arnd Bergmann
2016-03-29 14:04   ` Nicolas Ferre
2016-03-29 14:10   ` [PATCH v2 " Nicolas Ferre
2016-03-29 14:30     ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160318103418.GA2531@piout.net \
    --to=alexandre.belloni-wi1+55scjutkeb57/3fjtnbpr1lh4cv8@public.gmane.org \
    --cc=boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org \
    --cc=nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org \
    --cc=plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).