From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932969AbbCEP3N (ORCPT ); Thu, 5 Mar 2015 10:29:13 -0500 Received: from webbox1416.server-home.net ([77.236.96.61]:58819 "EHLO webbox1416.server-home.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932834AbbCEP3M (ORCPT ); Thu, 5 Mar 2015 10:29:12 -0500 From: Alexander Stein To: Alexandre Belloni Cc: Nicolas Ferre , Jean-Christophe Plagniol-Villard , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Boris Brezillon Subject: Re: [PATCH v2 5/9] ARM: at91: add soc detection infrastructure Date: Thu, 05 Mar 2015 16:29:26 +0100 Message-ID: <1425580851.g2DuYFu1co@ws-stein> User-Agent: KMail/4.14.3 (Linux/3.18.7-gentoo; KDE/4.14.3; x86_64; ; ) In-Reply-To: <1425557486-3534-6-git-send-email-alexandre.belloni@free-electrons.com> References: <1425557486-3534-1-git-send-email-alexandre.belloni@free-electrons.com> <1425557486-3534-6-git-send-email-alexandre.belloni@free-electrons.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexandre, On Thursday 05 March 2015 13:11:22, Alexandre Belloni wrote: > From: Boris BREZILLON > > Add new structures and functions to handle AT91 SoC detection. > > [alexandre.belloni@free-electrons.com: reworked DBGU detection] > Signed-off-by: Alexandre Belloni > Signed-off-by: Boris BREZILLON > --- > arch/arm/Kconfig | 1 + > arch/arm/mach-at91/Makefile | 2 +- > arch/arm/mach-at91/soc.c | 111 ++++++++++++++++++++++++++++++++++++++++++++ > arch/arm/mach-at91/soc.h | 48 +++++++++++++++++++ > 4 files changed, 161 insertions(+), 1 deletion(-) > create mode 100644 arch/arm/mach-at91/soc.c > create mode 100644 arch/arm/mach-at91/soc.h > > [...] > diff --git a/arch/arm/mach-at91/soc.c b/arch/arm/mach-at91/soc.c > new file mode 100644 > index 000000000000..227872246fd9 > --- /dev/null > +++ b/arch/arm/mach-at91/soc.c > @@ -0,0 +1,111 @@ > +/* > + * Copyright (C) 2015 Atmel > + * > + * Alexandre Belloni + * Boris Brezillon + * > + * This file is licensed under the terms of the GNU General Public > + * License version 2. This program is licensed "as is" without any > + * warranty of any kind, whether express or implied. > + * > + */ > + > +#define pr_fmt(fmt) "AT91: " fmt > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "soc.h" > + > +#define AT91_DBGU_CIDR 0x40 > +#define AT91_DBGU_CIDR_ARCH(x) (((x) >> 20) & 0xff) > +#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 > + > +struct soc_device * __init at91_soc_init(const struct at91_soc_family *families) > +{ > + struct soc_device_attribute *soc_dev_attr; > + const struct at91_soc_family *family; > + 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) { > + 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"); > + iounmap(regs); I guess if regs == NULL there is no need to iounmap them, no? > + return NULL; > + } > + > + cidr = readl(regs + AT91_DBGU_CIDR); > + exid = readl(regs + AT91_DBGU_EXID); > + > + iounmap(regs); Best regards, Alexander -- Dipl.-Inf. Alexander Stein SYS TEC electronic GmbH Am Windrad 2 08468 Heinsdorfergrund Tel.: 03765 38600-1156 Fax: 03765 38600-4100 Email: alexander.stein@systec-electronic.com Website: www.systec-electronic.com Managing Director: Dipl.-Phys. Siegmar Schmidt Commercial registry: Amtsgericht Chemnitz, HRB 28082