From patchwork Fri Jun 24 09:41:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102099 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp854930qgy; Fri, 24 Jun 2016 02:41:21 -0700 (PDT) X-Received: by 10.66.253.70 with SMTP id zy6mr5682060pac.55.1466761281690; Fri, 24 Jun 2016 02:41:21 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id z73si5891643pfi.134.2016.06.24.02.41.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Jun 2016 02:41:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bGNb1-00062n-FX; Fri, 24 Jun 2016 09:40:19 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bGNaa-0004bt-Tt for linux-arm-kernel@lists.infradead.org; Fri, 24 Jun 2016 09:39:54 +0000 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue102) with ESMTPA (Nemesis) id 0LzJrN-1bTast2OuH-014Qa1; Fri, 24 Jun 2016 11:39:30 +0200 From: Arnd Bergmann To: Linus Walleij Subject: [PATCH 4/7] ARM: ux500: consolidate soc_device code in id.c Date: Fri, 24 Jun 2016 11:41:29 +0200 Message-Id: <20160624094132.1852086-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160624094132.1852086-1-arnd@arndb.de> References: <20160624094132.1852086-1-arnd@arndb.de> X-Provags-ID: V03:K0:ZsC9+yOLpP3f5Ukrt4TalZ6z7lwncsm9ti9hImK/zInL5Dww7Wo CvEZ/xlw4Lc2DjuW5aDS2E6IANKV++B2eBa3jEKZyBRoUerGklHZtdCc4m/wpi+jCAqY84+ DF5JrvXr2zUdzdgDeCYTbEKS+o6Qrq4HgqxyRqupSqa9JytwfM/z3mF2MEis1O8capb+sT5 WwQ8DDT61BLnv87dwTu8w== X-UI-Out-Filterresults: notjunk:1; V01:K0:cM+VMbxwtlU=:3vBELuah8BdZ8Svj4X+ntM TuR3+5aaMvwmqh7z8Z/i0jrvUbyYRr/bXDgoauMLl2BGgezJdWM77pJv7xHkmIFARksM4vKGq mH2gT3pLa5uME5sr9qQ84BMtEEujuGrXH2tvEg2eXoP5XEJlW1z5Pjj8Sy8NCCqNYr2ihWCBi hK3lAvQTh5Sn1dCrKFX2YP3bVqX2jZp+VlkaQNQvdYGVyNTElyFKXVfXl2I0az9Iu/3WSCjcT r1kzJ3xiJ3o0TpL1+tQap2nSAuc5+oiTEBF12fOR7coUoUs4oK4GZbXRcHYkkF7D7npfFcnZp 9tDSRB7VRNBXE80e1FGqxNgqXYRPKIhkGVauSHrrCIKYMtTPpdq1LkVKyw/vqFaN0KV2BXfxP sQk6it2X2UR48U94cufPwfmLP5SBdrjPmwt9mS4Jh6jIVAADOs6nZDKFPPLmwj0MPatTeGHWP xsavgygmB1Og91fxvqFD2V+kWE38QI+rYODl8FX5FicPuGpCpZ2toUx5MnQx5vhD/lxBqaWgm 9+v2OCLCIL9WsxKZ4BlkUHvGYYdBZ20leiNUDUIofu24AzW1ttkQNg6Kz82H3SUKg9FwnkzgE X6HdBuENWc5/ZHSVNSH1+rKUYRTuuGgOwGTKIYwAT1rXTkoXqfQpoUVuaHB6ukk8fe5vmvd2v l7TelDW0ByCdAGjAcUyUL6K+CBjjm/vbJcNmg65/JHyse7mRF09k5aLFY21mwVko/q0k= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160624_023953_294093_79DF6987 X-CRM114-Status: GOOD ( 19.75 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.17.24 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.17.24 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Lee Jones , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Nothing else uses the global dbx500_asic_id structure, so we can merge the two small files that reference it into one. Signed-off-by: Arnd Bergmann --- arch/arm/mach-ux500/cache-l2x0.c | 1 - arch/arm/mach-ux500/cpu-db8500.c | 28 +--------- arch/arm/mach-ux500/cpu.c | 70 ------------------------- arch/arm/mach-ux500/id.c | 110 +++++++++++++++++++++++++++++++++++++-- arch/arm/mach-ux500/id.h | 37 ------------- arch/arm/mach-ux500/platsmp.c | 1 - arch/arm/mach-ux500/setup.h | 4 +- 7 files changed, 107 insertions(+), 144 deletions(-) delete mode 100644 arch/arm/mach-ux500/id.h -- 2.9.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/mach-ux500/cache-l2x0.c b/arch/arm/mach-ux500/cache-l2x0.c index d7abc1187769..adec59cc2e1d 100644 --- a/arch/arm/mach-ux500/cache-l2x0.c +++ b/arch/arm/mach-ux500/cache-l2x0.c @@ -12,7 +12,6 @@ #include #include "db8500-regs.h" -#include "id.h" static int __init ux500_l2x0_unlock(void) { diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c index 3874e9c236e9..e7eba473d3bd 100644 --- a/arch/arm/mach-ux500/cpu-db8500.c +++ b/arch/arm/mach-ux500/cpu-db8500.c @@ -20,7 +20,6 @@ #include #include #include -#include #include @@ -60,31 +59,6 @@ static struct arm_pmu_platdata db8500_pmu_platdata = { .handle_irq = db8500_pmu_handler, }; -static const char *db8500_read_soc_id(void) -{ - void __iomem *uid; - const char *retstr; - - uid = ioremap(U8500_BB_UID_BASE, 0x20); - if (!uid) - return NULL; - /* Throw these device-specific numbers into the entropy pool */ - add_device_randomness(uid, 0x14); - retstr = kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x", - readl((u32 *)uid+0), - readl((u32 *)uid+1), readl((u32 *)uid+2), - readl((u32 *)uid+3), readl((u32 *)uid+4)); - iounmap(uid); - return retstr; -} - -static struct device * __init db8500_soc_device_init(void) -{ - const char *soc_id = db8500_read_soc_id(); - - return ux500_soc_device_init(soc_id); -} - static struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = { /* Requires call-back bindings. */ OF_DEV_AUXDATA("arm,cortex-a9-pmu", 0, "arm-pmu", &db8500_pmu_platdata), @@ -121,7 +95,7 @@ static const struct of_device_id u8500_local_bus_nodes[] = { static void __init u8500_init_machine(void) { - struct device *parent = db8500_soc_device_init(); + struct device *parent = ux500_soc_device_init(); /* automatically probe child nodes of dbx5x0 devices */ if (of_machine_is_compatible("st-ericsson,u8540")) diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c index 63853e76a4e1..a34af283ee23 100644 --- a/arch/arm/mach-ux500/cpu.c +++ b/arch/arm/mach-ux500/cpu.c @@ -27,7 +27,6 @@ #include "board-mop500.h" #include "db8500-regs.h" -#include "id.h" void ux500_restart(enum reboot_mode mode, const char *cmd) { @@ -66,72 +65,3 @@ void __init ux500_init_irq(void) ux500_pm_init(r.start, r.end-r.start); ux500_l2x0_init(); } - -static const char * __init ux500_get_machine(void) -{ - return kasprintf(GFP_KERNEL, "DB%4x", dbx500_partnumber()); -} - -static const char * __init ux500_get_family(void) -{ - return kasprintf(GFP_KERNEL, "ux500"); -} - -static const char * __init ux500_get_revision(void) -{ - unsigned int rev = dbx500_revision(); - - if (rev == 0x01) - return kasprintf(GFP_KERNEL, "%s", "ED"); - else if (rev >= 0xA0) - return kasprintf(GFP_KERNEL, "%d.%d", - (rev >> 4) - 0xA + 1, rev & 0xf); - - return kasprintf(GFP_KERNEL, "%s", "Unknown"); -} - -static ssize_t ux500_get_process(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - if (dbx500_id.process == 0x00) - return sprintf(buf, "Standard\n"); - - return sprintf(buf, "%02xnm\n", dbx500_id.process); -} - -static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr, - const char *soc_id) -{ - soc_dev_attr->soc_id = soc_id; - soc_dev_attr->machine = ux500_get_machine(); - soc_dev_attr->family = ux500_get_family(); - soc_dev_attr->revision = ux500_get_revision(); -} - -static const struct device_attribute ux500_soc_attr = - __ATTR(process, S_IRUGO, ux500_get_process, NULL); - -struct device * __init ux500_soc_device_init(const char *soc_id) -{ - struct device *parent; - struct soc_device *soc_dev; - struct soc_device_attribute *soc_dev_attr; - - soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); - if (!soc_dev_attr) - return ERR_PTR(-ENOMEM); - - soc_info_populate(soc_dev_attr, soc_id); - - soc_dev = soc_device_register(soc_dev_attr); - if (IS_ERR(soc_dev)) { - kfree(soc_dev_attr); - return NULL; - } - - parent = soc_device_to_device(soc_dev); - device_create_file(parent, &ux500_soc_attr); - - return parent; -} diff --git a/arch/arm/mach-ux500/id.c b/arch/arm/mach-ux500/id.c index 1e81e990044b..17f80ef44c58 100644 --- a/arch/arm/mach-ux500/id.c +++ b/arch/arm/mach-ux500/id.c @@ -8,6 +8,9 @@ #include #include #include +#include +#include +#include #include #include @@ -17,9 +20,20 @@ #include "setup.h" #include "db8500-regs.h" -#include "id.h" -struct dbx500_asic_id dbx500_id; +/** + * struct dbx500_asic_id - fields of the ASIC ID + * @process: the manufacturing process, 0x40 is 40 nm 0x00 is "standard" + * @partnumber: hithereto 0x8500 for DB8500 + * @revision: version code in the series + */ +struct dbx500_asic_id { + u16 partnumber; + u8 revision; + u8 process; +}; + +static struct dbx500_asic_id dbx500_id; static unsigned int __init ux500_read_asicid(phys_addr_t addr) { @@ -42,9 +56,9 @@ static unsigned int __init ux500_read_asicid(phys_addr_t addr) static void ux500_print_soc_info(unsigned int asicid) { - unsigned int rev = dbx500_revision(); + unsigned int rev = dbx500_id.revision; - pr_info("DB%4x ", dbx500_partnumber()); + pr_info("DB%4x ", dbx500_id.partnumber); if (rev == 0x01) pr_cont("Early Drop"); @@ -105,7 +119,7 @@ void __init ux500_setup_id(void) if (!asicid) { pr_err("Unable to identify SoC\n"); - ux500_unknown_soc(); + BUG(); } dbx500_id.process = asicid >> 24; @@ -114,3 +128,89 @@ void __init ux500_setup_id(void) ux500_print_soc_info(asicid); } + +static const char * __init ux500_get_machine(void) +{ + return kasprintf(GFP_KERNEL, "DB%4x", dbx500_id.partnumber); +} + +static const char * __init ux500_get_family(void) +{ + return kasprintf(GFP_KERNEL, "ux500"); +} + +static const char * __init ux500_get_revision(void) +{ + unsigned int rev = dbx500_id.revision; + + if (rev == 0x01) + return kasprintf(GFP_KERNEL, "%s", "ED"); + else if (rev >= 0xA0) + return kasprintf(GFP_KERNEL, "%d.%d", + (rev >> 4) - 0xA + 1, rev & 0xf); + + return kasprintf(GFP_KERNEL, "%s", "Unknown"); +} + +static ssize_t ux500_get_process(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + if (dbx500_id.process == 0x00) + return sprintf(buf, "Standard\n"); + + return sprintf(buf, "%02xnm\n", dbx500_id.process); +} + +static const char *db8500_read_soc_id(void) +{ + void __iomem *uid; + const char *retstr; + + uid = ioremap(U8500_BB_UID_BASE, 0x20); + if (!uid) + return NULL; + /* Throw these device-specific numbers into the entropy pool */ + add_device_randomness(uid, 0x14); + retstr = kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x", + readl((u32 *)uid+0), + readl((u32 *)uid+1), readl((u32 *)uid+2), + readl((u32 *)uid+3), readl((u32 *)uid+4)); + iounmap(uid); + return retstr; +} + +static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr) +{ + soc_dev_attr->soc_id = db8500_read_soc_id(); + soc_dev_attr->machine = ux500_get_machine(); + soc_dev_attr->family = ux500_get_family(); + soc_dev_attr->revision = ux500_get_revision(); +} + +static const struct device_attribute ux500_soc_attr = + __ATTR(process, S_IRUGO, ux500_get_process, NULL); + +struct device * __init ux500_soc_device_init(void) +{ + struct device *parent; + struct soc_device *soc_dev; + struct soc_device_attribute *soc_dev_attr; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return ERR_PTR(-ENOMEM); + + soc_info_populate(soc_dev_attr); + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + kfree(soc_dev_attr); + return NULL; + } + + parent = soc_device_to_device(soc_dev); + device_create_file(parent, &ux500_soc_attr); + + return parent; +} diff --git a/arch/arm/mach-ux500/id.h b/arch/arm/mach-ux500/id.h deleted file mode 100644 index 929f78ecf3df..000000000000 --- a/arch/arm/mach-ux500/id.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2010 - * - * Author: Rabin Vincent for ST-Ericsson - * License terms: GNU General Public License (GPL) version 2 - */ - -#ifndef __MACH_UX500_ID -#define __MACH_UX500_ID - -/** - * struct dbx500_asic_id - fields of the ASIC ID - * @process: the manufacturing process, 0x40 is 40 nm 0x00 is "standard" - * @partnumber: hithereto 0x8500 for DB8500 - * @revision: version code in the series - */ -struct dbx500_asic_id { - u16 partnumber; - u8 revision; - u8 process; -}; - -extern struct dbx500_asic_id dbx500_id; - -static inline unsigned int __attribute_const__ dbx500_partnumber(void) -{ - return dbx500_id.partnumber; -} - -static inline unsigned int __attribute_const__ dbx500_revision(void) -{ - return dbx500_id.revision; -} - -#define ux500_unknown_soc() BUG() - -#endif diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c index 88b8ab4f300c..8f2f615ff958 100644 --- a/arch/arm/mach-ux500/platsmp.c +++ b/arch/arm/mach-ux500/platsmp.c @@ -26,7 +26,6 @@ #include "setup.h" #include "db8500-regs.h" -#include "id.h" /* Magic triggers in backup RAM */ #define UX500_CPU1_JUMPADDR_OFFSET 0x1FF4 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h index 8b44b646b191..1e9e7c55df75 100644 --- a/arch/arm/mach-ux500/setup.h +++ b/arch/arm/mach-ux500/setup.h @@ -19,11 +19,9 @@ void ux500_l2x0_init(void); void ux500_restart(enum reboot_mode mode, const char *cmd); -void __init ux500_setup_id(void); - extern void __init ux500_init_irq(void); -extern struct device *ux500_soc_device_init(const char *soc_id); +extern struct device *ux500_soc_device_init(void); extern void ux500_cpu_die(unsigned int cpu);