linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] ARM: ux500: cleanup of CPU id handling
@ 2016-06-24  9:41 Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 1/7] ARM: ux500: move l2x0 init to .init_irq Arnd Bergmann
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Arnd Bergmann @ 2016-06-24  9:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, linux-arm-kernel, linux-kernel, Arnd Bergmann

I stumbled over the cpu_is_u*() function in ux500 and decided to
see if I could simplify that code a bit. I ended up with a
significant reduction of code in arch/arm/mach-ux500/.

The new version is compile-tested with lots of randconfig builds,
but I did not run it on actual hardware, so it needs to be
tested by someone who has access to at least one of the
machines.

I had an earlier series to cleanup the ux500 platform data,
and this is based on top of those changes but should also be
easy to rebase as a standalone series. It's probably best
to merge both patch sets as a single branch for v4.8 through
the arm-soc tree, provided the testing is successful.

Patch 6/7 is the only one that should be user-visible, so
please review carefully if the change is desired or not.

	Arnd

Arnd Bergmann (7):
  ARM: ux500: move l2x0 init to .init_irq
  ARM: ux500: use CLK_OF_DECLARE()
  ARM: ux500: remove cpu_is_u* helpers
  ARM: ux500: consolidate soc_device code in id.c
  ARM: ux500: call ux500_setup_id later
  ARM: ux500: move soc_id driver to drivers/soc
  ARM: ux500: consolidate base platform files

 MAINTAINERS                             |   1 -
 arch/arm/mach-ux500/Makefile            |   3 +-
 arch/arm/mach-ux500/cache-l2x0.c        |  67 ----------
 arch/arm/mach-ux500/cpu-db8500.c        | 124 ++++++++++++------
 arch/arm/mach-ux500/cpu.c               | 148 ---------------------
 arch/arm/mach-ux500/id.c                | 116 -----------------
 arch/arm/mach-ux500/id.h                | 144 ---------------------
 arch/arm/mach-ux500/platsmp.c           |   1 -
 arch/arm/mach-ux500/setup.h             |  11 --
 drivers/clk/ux500/u8500_of_clk.c        |  16 +--
 drivers/clk/ux500/u8540_clk.c           |  16 +--
 drivers/clk/ux500/u9540_clk.c           |   4 +-
 drivers/soc/Kconfig                     |   1 +
 drivers/soc/Makefile                    |   1 +
 drivers/soc/ux500/Kconfig               |   7 +
 drivers/soc/ux500/ux500-soc-id.c        | 222 ++++++++++++++++++++++++++++++++
 include/linux/platform_data/clk-ux500.h |  17 ---
 17 files changed, 326 insertions(+), 573 deletions(-)
 delete mode 100644 arch/arm/mach-ux500/cache-l2x0.c
 delete mode 100644 arch/arm/mach-ux500/cpu.c
 delete mode 100644 arch/arm/mach-ux500/id.c
 delete mode 100644 arch/arm/mach-ux500/id.h
 create mode 100644 drivers/soc/ux500/Kconfig
 create mode 100644 drivers/soc/ux500/ux500-soc-id.c
 delete mode 100644 include/linux/platform_data/clk-ux500.h

-- 
2.9.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/7] ARM: ux500: move l2x0 init to .init_irq
  2016-06-24  9:41 [PATCH 0/7] ARM: ux500: cleanup of CPU id handling Arnd Bergmann
@ 2016-06-24  9:41 ` Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 2/7] ARM: ux500: use CLK_OF_DECLARE() Arnd Bergmann
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2016-06-24  9:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, linux-arm-kernel, linux-kernel, Arnd Bergmann

The generic IRQ init function also enables the l2 cache
implicitly when the machine descriptor sets an .l2c_aux_mask.

Let's use that on ux500 and remove the ux500_l2x0_init()
along with the cpu_is_u8500_family checks.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm/mach-ux500/cache-l2x0.c | 8 +-------
 arch/arm/mach-ux500/cpu-db8500.c | 3 ++-
 arch/arm/mach-ux500/cpu.c        | 1 +
 arch/arm/mach-ux500/setup.h      | 3 +++
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-ux500/cache-l2x0.c b/arch/arm/mach-ux500/cache-l2x0.c
index 780bd13cd7e3..d7abc1187769 100644
--- a/arch/arm/mach-ux500/cache-l2x0.c
+++ b/arch/arm/mach-ux500/cache-l2x0.c
@@ -51,17 +51,11 @@ static void ux500_l2c310_write_sec(unsigned long val, unsigned reg)
 	 */
 }
 
-static int __init ux500_l2x0_init(void)
+void __init ux500_l2x0_init(void)
 {
-	/* Multiplatform guard */
-	if (!((cpu_is_u8500_family() || cpu_is_ux540_family())))
-		return -ENODEV;
-
 	/* Unlock before init */
 	ux500_l2x0_unlock();
 	outer_cache.write_sec = ux500_l2c310_write_sec;
-	l2x0_of_init(0, ~0);
 
 	return 0;
 }
-early_initcall(ux500_l2x0_init);
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index bbd1b4b8d441..3874e9c236e9 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -141,10 +141,11 @@ static const char * stericsson_dt_platform_compat[] = {
 };
 
 DT_MACHINE_START(U8500_DT, "ST-Ericsson Ux5x0 platform (Device Tree Support)")
+	.l2c_aux_val    = 0,
+	.l2c_aux_mask	= ~0,
 	.map_io		= u8500_map_io,
 	.init_irq	= ux500_init_irq,
 	.init_machine	= u8500_init_machine,
-	.init_late	= NULL,
 	.dt_compat      = stericsson_dt_platform_compat,
 	.restart        = ux500_restart,
 MACHINE_END
diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
index 82156cbc22ce..f8c2d6f2fb7e 100644
--- a/arch/arm/mach-ux500/cpu.c
+++ b/arch/arm/mach-ux500/cpu.c
@@ -65,6 +65,7 @@ void __init ux500_init_irq(void)
 	}
 	prcmu_early_init(r.start, r.end-r.start);
 	ux500_pm_init(r.start, r.end-r.start);
+	ux500_l2x0_init();
 
 	/*
 	 * Init clocks here so that they are available for system timer
diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
index e606847c8b58..8b44b646b191 100644
--- a/arch/arm/mach-ux500/setup.h
+++ b/arch/arm/mach-ux500/setup.h
@@ -14,6 +14,9 @@
 #include <asm/mach/arch.h>
 #include <linux/init.h>
 
+
+void ux500_l2x0_init(void);
+
 void ux500_restart(enum reboot_mode mode, const char *cmd);
 
 void __init ux500_setup_id(void);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/7] ARM: ux500: use CLK_OF_DECLARE()
  2016-06-24  9:41 [PATCH 0/7] ARM: ux500: cleanup of CPU id handling Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 1/7] ARM: ux500: move l2x0 init to .init_irq Arnd Bergmann
@ 2016-06-24  9:41 ` Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 3/7] ARM: ux500: remove cpu_is_u* helpers Arnd Bergmann
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2016-06-24  9:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, linux-arm-kernel, linux-kernel, Arnd Bergmann

The ux500 DT support predates the CLK_OF_DECLARE macro and calls
directly into the clk driver from platform code.

Converting this to CLK_OF_DECLARE makes the code much nicer and
similar to how modern platforms do it today. It also removes the
last user of cpu_is_u8500_family() etc.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 MAINTAINERS                             |  1 -
 arch/arm/mach-ux500/cpu.c               | 12 ------------
 drivers/clk/ux500/u8500_of_clk.c        | 16 ++--------------
 drivers/clk/ux500/u8540_clk.c           | 16 ++--------------
 drivers/clk/ux500/u9540_clk.c           |  4 ++--
 include/linux/platform_data/clk-ux500.h | 17 -----------------
 6 files changed, 6 insertions(+), 60 deletions(-)
 delete mode 100644 include/linux/platform_data/clk-ux500.h

diff --git a/MAINTAINERS b/MAINTAINERS
index eff103763782..e78251a18255 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1842,7 +1842,6 @@ L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 T:	git git://git.linaro.org/people/ulfh/clk.git
 S:	Maintained
 F:	drivers/clk/ux500/
-F:	include/linux/platform_data/clk-ux500.h
 
 ARM/VERSATILE EXPRESS PLATFORM
 M:	Liviu Dudau <liviu.dudau@arm.com>
diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
index f8c2d6f2fb7e..63853e76a4e1 100644
--- a/arch/arm/mach-ux500/cpu.c
+++ b/arch/arm/mach-ux500/cpu.c
@@ -19,7 +19,6 @@
 #include <linux/irq.h>
 #include <linux/irqchip.h>
 #include <linux/irqchip/arm-gic.h>
-#include <linux/platform_data/clk-ux500.h>
 #include <linux/platform_data/arm-ux500-pm.h>
 
 #include <asm/mach/map.h>
@@ -66,17 +65,6 @@ void __init ux500_init_irq(void)
 	prcmu_early_init(r.start, r.end-r.start);
 	ux500_pm_init(r.start, r.end-r.start);
 	ux500_l2x0_init();
-
-	/*
-	 * Init clocks here so that they are available for system timer
-	 * initialization.
-	 */
-	if (cpu_is_u8500_family())
-		u8500_clk_init();
-	else if (cpu_is_u9540())
-		u9540_clk_init();
-	else if (cpu_is_u8540())
-		u8540_clk_init();
 }
 
 static const char * __init ux500_get_machine(void)
diff --git a/drivers/clk/ux500/u8500_of_clk.c b/drivers/clk/ux500/u8500_of_clk.c
index 9a736d939806..e960d686d9db 100644
--- a/drivers/clk/ux500/u8500_of_clk.c
+++ b/drivers/clk/ux500/u8500_of_clk.c
@@ -11,7 +11,6 @@
 #include <linux/of_address.h>
 #include <linux/clk-provider.h>
 #include <linux/mfd/dbx500-prcmu.h>
-#include <linux/platform_data/clk-ux500.h>
 #include "clk.h"
 
 #define PRCC_NUM_PERIPH_CLUSTERS 6
@@ -48,11 +47,6 @@ static struct clk *ux500_twocell_get(struct of_phandle_args *clkspec,
 	return PRCC_SHOW(clk_data, base, bit);
 }
 
-static const struct of_device_id u8500_clk_of_match[] = {
-	{ .compatible = "stericsson,u8500-clks", },
-	{ },
-};
-
 /* CLKRST4 is missing making it hard to index things */
 enum clkrst_index {
 	CLKRST1_INDEX = 0,
@@ -63,22 +57,15 @@ enum clkrst_index {
 	CLKRST_MAX,
 };
 
-void u8500_clk_init(void)
+static void u8500_clk_init(struct device_node *np)
 {
 	struct prcmu_fw_version *fw_version;
-	struct device_node *np = NULL;
 	struct device_node *child = NULL;
 	const char *sgaclk_parent = NULL;
 	struct clk *clk, *rtc_clk, *twd_clk;
 	u32 bases[CLKRST_MAX];
 	int i;
 
-	if (of_have_populated_dt())
-		np = of_find_matching_node(NULL, u8500_clk_of_match);
-	if (!np) {
-		pr_err("Either DT or U8500 Clock node not found\n");
-		return;
-	}
 	for (i = 0; i < ARRAY_SIZE(bases); i++) {
 		struct resource r;
 
@@ -573,3 +560,4 @@ void u8500_clk_init(void)
 			of_clk_add_provider(child, of_clk_src_simple_get, twd_clk);
 	}
 }
+CLK_OF_DECLARE(u8500_clks, "stericsson,u8500-clks", u8500_clk_init);
diff --git a/drivers/clk/ux500/u8540_clk.c b/drivers/clk/ux500/u8540_clk.c
index 86549e59fb42..133859f0e2bf 100644
--- a/drivers/clk/ux500/u8540_clk.c
+++ b/drivers/clk/ux500/u8540_clk.c
@@ -12,14 +12,8 @@
 #include <linux/clkdev.h>
 #include <linux/clk-provider.h>
 #include <linux/mfd/dbx500-prcmu.h>
-#include <linux/platform_data/clk-ux500.h>
 #include "clk.h"
 
-static const struct of_device_id u8540_clk_of_match[] = {
-	{ .compatible = "stericsson,u8540-clks", },
-	{ }
-};
-
 /* CLKRST4 is missing making it hard to index things */
 enum clkrst_index {
 	CLKRST1_INDEX = 0,
@@ -30,19 +24,12 @@ enum clkrst_index {
 	CLKRST_MAX,
 };
 
-void u8540_clk_init(void)
+static void u8540_clk_init(struct device_node *np)
 {
 	struct clk *clk;
-	struct device_node *np = NULL;
 	u32 bases[CLKRST_MAX];
 	int i;
 
-	if (of_have_populated_dt())
-		np = of_find_matching_node(NULL, u8540_clk_of_match);
-	if (!np) {
-		pr_err("Either DT or U8540 Clock node not found\n");
-		return;
-	}
 	for (i = 0; i < ARRAY_SIZE(bases); i++) {
 		struct resource r;
 
@@ -607,3 +594,4 @@ void u8540_clk_init(void)
 			bases[CLKRST6_INDEX], BIT(0), CLK_SET_RATE_GATE);
 	clk_register_clkdev(clk, NULL, "rng");
 }
+CLK_OF_DECLARE(u8540_clks, "stericsson,u8540-clks", u8540_clk_init);
diff --git a/drivers/clk/ux500/u9540_clk.c b/drivers/clk/ux500/u9540_clk.c
index 2138a4c8cbca..7b6bca49ce42 100644
--- a/drivers/clk/ux500/u9540_clk.c
+++ b/drivers/clk/ux500/u9540_clk.c
@@ -9,10 +9,10 @@
 
 #include <linux/clk-provider.h>
 #include <linux/mfd/dbx500-prcmu.h>
-#include <linux/platform_data/clk-ux500.h>
 #include "clk.h"
 
-void u9540_clk_init(void)
+static void u9540_clk_init(struct device_node *np)
 {
 	/* register clocks here */
 }
+CLK_OF_DECLARE(u9540_clks, "stericsson,u9540-clks", u9540_clk_init);
diff --git a/include/linux/platform_data/clk-ux500.h b/include/linux/platform_data/clk-ux500.h
deleted file mode 100644
index 3af0da1f3be5..000000000000
--- a/include/linux/platform_data/clk-ux500.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Clock definitions for ux500 platforms
- *
- * Copyright (C) 2012 ST-Ericsson SA
- * Author: Ulf Hansson <ulf.hansson@linaro.org>
- *
- * License terms: GNU General Public License (GPL) version 2
- */
-
-#ifndef __CLK_UX500_H
-#define __CLK_UX500_H
-
-void u8500_clk_init(void);
-void u9540_clk_init(void);
-void u8540_clk_init(void);
-
-#endif /* __CLK_UX500_H */
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/7] ARM: ux500: remove cpu_is_u* helpers
  2016-06-24  9:41 [PATCH 0/7] ARM: ux500: cleanup of CPU id handling Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 1/7] ARM: ux500: move l2x0 init to .init_irq Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 2/7] ARM: ux500: use CLK_OF_DECLARE() Arnd Bergmann
@ 2016-06-24  9:41 ` Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 4/7] ARM: ux500: consolidate soc_device code in id.c Arnd Bergmann
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2016-06-24  9:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, linux-arm-kernel, linux-kernel, Arnd Bergmann

These functions are all unused now and can be removed.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm/mach-ux500/id.h | 107 -----------------------------------------------
 1 file changed, 107 deletions(-)

diff --git a/arch/arm/mach-ux500/id.h b/arch/arm/mach-ux500/id.h
index bcc58a8cccbc..929f78ecf3df 100644
--- a/arch/arm/mach-ux500/id.h
+++ b/arch/arm/mach-ux500/id.h
@@ -32,113 +32,6 @@ static inline unsigned int __attribute_const__ dbx500_revision(void)
 	return dbx500_id.revision;
 }
 
-/*
- * SOCs
- */
-
-static inline bool __attribute_const__ cpu_is_u8500(void)
-{
-	return dbx500_partnumber() == 0x8500;
-}
-
-static inline bool __attribute_const__ cpu_is_u8520(void)
-{
-	return dbx500_partnumber() == 0x8520;
-}
-
-static inline bool cpu_is_u8500_family(void)
-{
-	return cpu_is_u8500() || cpu_is_u8520();
-}
-
-static inline bool __attribute_const__ cpu_is_u9540(void)
-{
-	return dbx500_partnumber() == 0x9540;
-}
-
-static inline bool __attribute_const__ cpu_is_u8540(void)
-{
-	return dbx500_partnumber() == 0x8540;
-}
-
-static inline bool __attribute_const__ cpu_is_u8580(void)
-{
-	return dbx500_partnumber() == 0x8580;
-}
-
-static inline bool cpu_is_ux540_family(void)
-{
-	return cpu_is_u9540() || cpu_is_u8540() || cpu_is_u8580();
-}
-
-/*
- * 8500 revisions
- */
-
-static inline bool __attribute_const__ cpu_is_u8500ed(void)
-{
-	return cpu_is_u8500() && dbx500_revision() == 0x00;
-}
-
-static inline bool __attribute_const__ cpu_is_u8500v1(void)
-{
-	return cpu_is_u8500() && (dbx500_revision() & 0xf0) == 0xA0;
-}
-
-static inline bool __attribute_const__ cpu_is_u8500v10(void)
-{
-	return cpu_is_u8500() && dbx500_revision() == 0xA0;
-}
-
-static inline bool __attribute_const__ cpu_is_u8500v11(void)
-{
-	return cpu_is_u8500() && dbx500_revision() == 0xA1;
-}
-
-static inline bool __attribute_const__ cpu_is_u8500v2(void)
-{
-	return cpu_is_u8500() && ((dbx500_revision() & 0xf0) == 0xB0);
-}
-
-static inline bool cpu_is_u8500v20(void)
-{
-	return cpu_is_u8500() && (dbx500_revision() == 0xB0);
-}
-
-static inline bool cpu_is_u8500v21(void)
-{
-	return cpu_is_u8500() && (dbx500_revision() == 0xB1);
-}
-
-static inline bool cpu_is_u8500v22(void)
-{
-	return cpu_is_u8500() && (dbx500_revision() == 0xB2);
-}
-
-static inline bool cpu_is_u8500v20_or_later(void)
-{
-	return (cpu_is_u8500() && !cpu_is_u8500v10() && !cpu_is_u8500v11());
-}
-
-/*
- * 8540 revisions
- */
-
-static inline bool __attribute_const__ cpu_is_u8540v10(void)
-{
-	return cpu_is_u8540() && dbx500_revision() == 0xA0;
-}
-
-static inline bool __attribute_const__ cpu_is_u8580v10(void)
-{
-	return cpu_is_u8580() && dbx500_revision() == 0xA0;
-}
-
-static inline bool ux500_is_svp(void)
-{
-	return false;
-}
-
 #define ux500_unknown_soc()	BUG()
 
 #endif
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/7] ARM: ux500: consolidate soc_device code in id.c
  2016-06-24  9:41 [PATCH 0/7] ARM: ux500: cleanup of CPU id handling Arnd Bergmann
                   ` (2 preceding siblings ...)
  2016-06-24  9:41 ` [PATCH 3/7] ARM: ux500: remove cpu_is_u* helpers Arnd Bergmann
@ 2016-06-24  9:41 ` Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 5/7] ARM: ux500: call ux500_setup_id later Arnd Bergmann
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2016-06-24  9:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, linux-arm-kernel, linux-kernel, Arnd Bergmann

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 <arnd@arndb.de>
---
 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

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 <asm/hardware/cache-l2x0.h>
 
 #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 <linux/of_platform.h>
 #include <linux/perf/arm_pmu.h>
 #include <linux/regulator/machine.h>
-#include <linux/random.h>
 
 #include <asm/mach/map.h>
 
@@ -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 <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/random.h>
+#include <linux/slab.h>
+#include <linux/sys_soc.h>
 
 #include <asm/cputype.h>
 #include <asm/tlbflush.h>
@@ -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 <rabin.vincent@stericsson.com> 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);
 
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/7] ARM: ux500: call ux500_setup_id later
  2016-06-24  9:41 [PATCH 0/7] ARM: ux500: cleanup of CPU id handling Arnd Bergmann
                   ` (3 preceding siblings ...)
  2016-06-24  9:41 ` [PATCH 4/7] ARM: ux500: consolidate soc_device code in id.c Arnd Bergmann
@ 2016-06-24  9:41 ` Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 6/7] ARM: ux500: move soc_id driver to drivers/soc Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 7/7] ARM: ux500: consolidate base platform files Arnd Bergmann
  6 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2016-06-24  9:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, linux-arm-kernel, linux-kernel, Arnd Bergmann

ux500_setup_id is currently called from u8500_map_io(), which is
really early, but nothing relies on the ID any more, other than
a printk message that is not really all that important to
have early during boot.

If we move the call to ux500_setup_id() into ux500_soc_device_init(),
that file becomes usuable almost entirely standalone, and we can kill
off the u8500_map_io() callback as it just does the default
debug_ll_io_init() now.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm/mach-ux500/cpu-db8500.c |  8 --------
 arch/arm/mach-ux500/id.c         | 23 ++++++++++-------------
 2 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index e7eba473d3bd..881cafbc4d97 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -27,13 +27,6 @@
 
 #include "board-mop500.h"
 #include "db8500-regs.h"
-#include "id.h"
-
-static void __init u8500_map_io(void)
-{
-	debug_ll_io_init();
-	ux500_setup_id();
-}
 
 /*
  * The PMU IRQ lines of two cores are wired together into a single interrupt.
@@ -117,7 +110,6 @@ static const char * stericsson_dt_platform_compat[] = {
 DT_MACHINE_START(U8500_DT, "ST-Ericsson Ux5x0 platform (Device Tree Support)")
 	.l2c_aux_val    = 0,
 	.l2c_aux_mask	= ~0,
-	.map_io		= u8500_map_io,
 	.init_irq	= ux500_init_irq,
 	.init_machine	= u8500_init_machine,
 	.dt_compat      = stericsson_dt_platform_compat,
diff --git a/arch/arm/mach-ux500/id.c b/arch/arm/mach-ux500/id.c
index 17f80ef44c58..983004d0fef2 100644
--- a/arch/arm/mach-ux500/id.c
+++ b/arch/arm/mach-ux500/id.c
@@ -37,21 +37,16 @@ static struct dbx500_asic_id dbx500_id;
 
 static unsigned int __init ux500_read_asicid(phys_addr_t addr)
 {
-	phys_addr_t base = addr & ~0xfff;
-	struct map_desc desc = {
-		.virtual	= (unsigned long)UX500_VIRT_ROM,
-		.pfn		= __phys_to_pfn(base),
-		.length		= SZ_16K,
-		.type		= MT_DEVICE,
-	};
+	void __iomem *virt = ioremap(addr, 4);
+	unsigned int asicid;
 
-	iotable_init(&desc, 1);
+	if (!virt)
+		return 0;
 
-	/* As in devicemaps_init() */
-	local_flush_tlb_all();
-	flush_cache_all();
+	asicid = readl(virt);
+	iounmap(virt);
 
-	return readl(UX500_VIRT_ROM + (addr & 0xfff));
+	return asicid;
 }
 
 static void ux500_print_soc_info(unsigned int asicid)
@@ -86,7 +81,7 @@ static unsigned int partnumber(unsigned int asicid)
  * DB9540	0x413fc090	0xFFFFDBF4		0x009540xx
  */
 
-void __init ux500_setup_id(void)
+static void __init ux500_setup_id(void)
 {
 	unsigned int cpuid = read_cpuid_id();
 	unsigned int asicid = 0;
@@ -197,6 +192,8 @@ struct device * __init ux500_soc_device_init(void)
 	struct soc_device *soc_dev;
 	struct soc_device_attribute *soc_dev_attr;
 
+	ux500_setup_id();
+
 	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
 	if (!soc_dev_attr)
 		return ERR_PTR(-ENOMEM);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/7] ARM: ux500: move soc_id driver to drivers/soc
  2016-06-24  9:41 [PATCH 0/7] ARM: ux500: cleanup of CPU id handling Arnd Bergmann
                   ` (4 preceding siblings ...)
  2016-06-24  9:41 ` [PATCH 5/7] ARM: ux500: call ux500_setup_id later Arnd Bergmann
@ 2016-06-24  9:41 ` Arnd Bergmann
  2016-06-24  9:41 ` [PATCH 7/7] ARM: ux500: consolidate base platform files Arnd Bergmann
  6 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2016-06-24  9:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, linux-arm-kernel, linux-kernel, Arnd Bergmann

As the ux500 id code is basically a standalone driver, we can move it
out of the arch code into drivers/soc/ux500.

This is a user-visible change, as it moves all the devices in sysfs
from /sys/devices/soc0/ to /sys/devices/ and leaves the soc0 node as a
separate device.

Originally the idea was to put all on-chip devices under the soc node,
and ux500 was the first platform to have this device, but later platforms
almost all didn't follow that pattern, so this makes the platform do
the same thing as everyone else.

Since the platform is really obsolete now, I am optimistic that nothing
will break after moving the devices around.

As the SoC driver no longer has access to the private header files,
I'm changing the code to instead look up the address of the backupram
from devicetree, which is a good idea anyway.

Finally, having a separate Kconfig symbol means the driver is now
optional and could even be a loadable module rather than always being
built-in if we allowed that for soc_device.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm/mach-ux500/Makefile                       |  2 +-
 arch/arm/mach-ux500/cpu-db8500.c                   |  6 ++--
 arch/arm/mach-ux500/setup.h                        |  2 --
 drivers/soc/Kconfig                                |  1 +
 drivers/soc/Makefile                               |  1 +
 drivers/soc/ux500/Kconfig                          |  7 ++++
 .../id.c => drivers/soc/ux500/ux500-soc-id.c       | 39 +++++++++++++---------
 7 files changed, 36 insertions(+), 22 deletions(-)
 create mode 100644 drivers/soc/ux500/Kconfig
 rename arch/arm/mach-ux500/id.c => drivers/soc/ux500/ux500-soc-id.c (86%)

diff --git a/arch/arm/mach-ux500/Makefile b/arch/arm/mach-ux500/Makefile
index ea8893fd128f..753d3eed1985 100644
--- a/arch/arm/mach-ux500/Makefile
+++ b/arch/arm/mach-ux500/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel, U8500 machine.
 #
 
-obj-y				:= cpu.o id.o pm.o
+obj-y				:= cpu.o pm.o
 obj-$(CONFIG_CACHE_L2X0)	+= cache-l2x0.o
 obj-$(CONFIG_UX500_SOC_DB8500)	+= cpu-db8500.o
 obj-$(CONFIG_MACH_MOP500)	+= board-mop500-audio.o
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index 881cafbc4d97..c9c9832f79e9 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -88,15 +88,13 @@ static const struct of_device_id u8500_local_bus_nodes[] = {
 
 static void __init u8500_init_machine(void)
 {
-	struct device *parent = ux500_soc_device_init();
-
 	/* automatically probe child nodes of dbx5x0 devices */
 	if (of_machine_is_compatible("st-ericsson,u8540"))
 		of_platform_populate(NULL, u8500_local_bus_nodes,
-				     u8540_auxdata_lookup, parent);
+				     u8540_auxdata_lookup, NULL);
 	else
 		of_platform_populate(NULL, u8500_local_bus_nodes,
-				     u8500_auxdata_lookup, parent);
+				     u8500_auxdata_lookup, NULL);
 }
 
 static const char * stericsson_dt_platform_compat[] = {
diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
index 1e9e7c55df75..85b7819a40ab 100644
--- a/arch/arm/mach-ux500/setup.h
+++ b/arch/arm/mach-ux500/setup.h
@@ -21,8 +21,6 @@ void ux500_restart(enum reboot_mode mode, const char *cmd);
 
 extern void __init ux500_init_irq(void);
 
-extern struct device *ux500_soc_device_init(void);
-
 extern void ux500_cpu_die(unsigned int cpu);
 
 #endif /*  __ASM_ARCH_SETUP_H */
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 58547f48ebcd..f31bceb69c0d 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -9,6 +9,7 @@ source "drivers/soc/samsung/Kconfig"
 source "drivers/soc/sunxi/Kconfig"
 source "drivers/soc/tegra/Kconfig"
 source "drivers/soc/ti/Kconfig"
+source "drivers/soc/ux500/Kconfig"
 source "drivers/soc/versatile/Kconfig"
 
 endmenu
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index b75e3bd0a01e..50c23d0bd457 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -14,4 +14,5 @@ obj-$(CONFIG_SOC_SAMSUNG)	+= samsung/
 obj-$(CONFIG_ARCH_SUNXI)	+= sunxi/
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
 obj-$(CONFIG_SOC_TI)		+= ti/
+obj-$(CONFIG_ARCH_U8500)	+= ux500/
 obj-$(CONFIG_PLAT_VERSATILE)	+= versatile/
diff --git a/drivers/soc/ux500/Kconfig b/drivers/soc/ux500/Kconfig
new file mode 100644
index 000000000000..025a44aef5db
--- /dev/null
+++ b/drivers/soc/ux500/Kconfig
@@ -0,0 +1,7 @@
+config UX500_SOC_ID
+	bool "SoC bus for ST-Ericsson ux500"
+	depends on ARCH_U8500 || COMPILE_TEST
+	default ARCH_U8500
+	help
+	  Include support for the SoC bus on the ARM RealView platforms
+	  providing some sysfs information about the ASIC variant.
diff --git a/arch/arm/mach-ux500/id.c b/drivers/soc/ux500/ux500-soc-id.c
similarity index 86%
rename from arch/arm/mach-ux500/id.c
rename to drivers/soc/ux500/ux500-soc-id.c
index 983004d0fef2..49a811edce25 100644
--- a/arch/arm/mach-ux500/id.c
+++ b/drivers/soc/ux500/ux500-soc-id.c
@@ -8,8 +8,11 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/module.h>
 #include <linux/random.h>
 #include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/sys_soc.h>
 
 #include <asm/cputype.h>
@@ -17,10 +20,6 @@
 #include <asm/cacheflush.h>
 #include <asm/mach/map.h>
 
-#include "setup.h"
-
-#include "db8500-regs.h"
-
 /**
  * struct dbx500_asic_id - fields of the ASIC ID
  * @process: the manufacturing process, 0x40 is 40 nm 0x00 is "standard"
@@ -157,27 +156,31 @@ static ssize_t ux500_get_process(struct device *dev,
 	return sprintf(buf, "%02xnm\n", dbx500_id.process);
 }
 
-static const char *db8500_read_soc_id(void)
+static const char *db8500_read_soc_id(struct device_node *backupram)
 {
+	void __iomem *base;
 	void __iomem *uid;
 	const char *retstr;
 
-	uid = ioremap(U8500_BB_UID_BASE, 0x20);
-	if (!uid)
+	base = of_iomap(backupram, 0);
+	if (!base)
 		return NULL;
+	uid = base + 0xfc0;
+
 	/* 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);
+	iounmap(base);
 	return retstr;
 }
 
-static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr)
+static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr,
+				     struct device_node *backupram)
 {
-	soc_dev_attr->soc_id   = db8500_read_soc_id();
+	soc_dev_attr->soc_id   = db8500_read_soc_id(backupram);
 	soc_dev_attr->machine  = ux500_get_machine();
 	soc_dev_attr->family   = ux500_get_family();
 	soc_dev_attr->revision = ux500_get_revision();
@@ -186,28 +189,34 @@ static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr)
 static const struct device_attribute ux500_soc_attr =
 	__ATTR(process,  S_IRUGO, ux500_get_process,  NULL);
 
-struct device * __init ux500_soc_device_init(void)
+static int __init ux500_soc_device_init(void)
 {
 	struct device *parent;
 	struct soc_device *soc_dev;
 	struct soc_device_attribute *soc_dev_attr;
+	struct device_node *backupram;
+
+	backupram = of_find_compatible_node(NULL, NULL, "ste,dbx500-backupram");
+	if (!backupram)
+		return 0;
 
 	ux500_setup_id();
 
 	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
 	if (!soc_dev_attr)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
-	soc_info_populate(soc_dev_attr);
+	soc_info_populate(soc_dev_attr, backupram);
 
 	soc_dev = soc_device_register(soc_dev_attr);
 	if (IS_ERR(soc_dev)) {
 	        kfree(soc_dev_attr);
-		return NULL;
+		return PTR_ERR(soc_dev);
 	}
 
 	parent = soc_device_to_device(soc_dev);
 	device_create_file(parent, &ux500_soc_attr);
 
-	return parent;
+	return 0;
 }
+subsys_initcall(ux500_soc_device_init);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 7/7] ARM: ux500: consolidate base platform files
  2016-06-24  9:41 [PATCH 0/7] ARM: ux500: cleanup of CPU id handling Arnd Bergmann
                   ` (5 preceding siblings ...)
  2016-06-24  9:41 ` [PATCH 6/7] ARM: ux500: move soc_id driver to drivers/soc Arnd Bergmann
@ 2016-06-24  9:41 ` Arnd Bergmann
  6 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2016-06-24  9:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, linux-arm-kernel, linux-kernel, Arnd Bergmann

The cpu.c and cache-l2x0.c files hold only two or three simple
functions each, and they are all called from the machine
descriptors, so we can just move them all into the same file
for simplicity and consistency.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm/mach-ux500/Makefile     |  3 +-
 arch/arm/mach-ux500/cache-l2x0.c | 60 ---------------------------
 arch/arm/mach-ux500/cpu-db8500.c | 87 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-ux500/cpu.c        | 67 -------------------------------
 arch/arm/mach-ux500/setup.h      | 10 -----
 5 files changed, 88 insertions(+), 139 deletions(-)
 delete mode 100644 arch/arm/mach-ux500/cache-l2x0.c
 delete mode 100644 arch/arm/mach-ux500/cpu.c

diff --git a/arch/arm/mach-ux500/Makefile b/arch/arm/mach-ux500/Makefile
index 753d3eed1985..56d0eb6e254e 100644
--- a/arch/arm/mach-ux500/Makefile
+++ b/arch/arm/mach-ux500/Makefile
@@ -2,8 +2,7 @@
 # Makefile for the linux kernel, U8500 machine.
 #
 
-obj-y				:= cpu.o pm.o
-obj-$(CONFIG_CACHE_L2X0)	+= cache-l2x0.o
+obj-y				:= pm.o
 obj-$(CONFIG_UX500_SOC_DB8500)	+= cpu-db8500.o
 obj-$(CONFIG_MACH_MOP500)	+= board-mop500-audio.o
 obj-$(CONFIG_SMP)		+= platsmp.o
diff --git a/arch/arm/mach-ux500/cache-l2x0.c b/arch/arm/mach-ux500/cache-l2x0.c
deleted file mode 100644
index adec59cc2e1d..000000000000
--- a/arch/arm/mach-ux500/cache-l2x0.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) ST-Ericsson SA 2011
- *
- * License terms: GNU General Public License (GPL) version 2
- */
-
-#include <linux/io.h>
-#include <linux/of.h>
-#include <linux/of_address.h>
-
-#include <asm/outercache.h>
-#include <asm/hardware/cache-l2x0.h>
-
-#include "db8500-regs.h"
-
-static int __init ux500_l2x0_unlock(void)
-{
-	int i;
-	struct device_node *np;
-	void __iomem *l2x0_base;
-
-	np = of_find_compatible_node(NULL, NULL, "arm,pl310-cache");
-	l2x0_base = of_iomap(np, 0);
-	of_node_put(np);
-	if (!l2x0_base)
-		return -ENODEV;
-
-	/*
-	 * Unlock Data and Instruction Lock if locked. Ux500 U-Boot versions
-	 * apparently locks both caches before jumping to the kernel. The
-	 * l2x0 core will not touch the unlock registers if the l2x0 is
-	 * already enabled, so we do it right here instead. The PL310 has
-	 * 8 sets of registers, one per possible CPU.
-	 */
-	for (i = 0; i < 8; i++) {
-		writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_D_BASE +
-			       i * L2X0_LOCKDOWN_STRIDE);
-		writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_I_BASE +
-			       i * L2X0_LOCKDOWN_STRIDE);
-	}
-	iounmap(l2x0_base);
-	return 0;
-}
-
-static void ux500_l2c310_write_sec(unsigned long val, unsigned reg)
-{
-	/*
-	 * We can't write to secure registers as we are in non-secure
-	 * mode, until we have some SMI service available.
-	 */
-}
-
-void __init ux500_l2x0_init(void)
-{
-	/* Unlock before init */
-	ux500_l2x0_unlock();
-	outer_cache.write_sec = ux500_l2c310_write_sec;
-
-	return 0;
-}
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index c9c9832f79e9..46b1da1bf5d2 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -12,22 +12,109 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/amba/bus.h>
+#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/irqchip.h>
+#include <linux/irqchip/arm-gic.h>
+#include <linux/mfd/dbx500-prcmu.h>
+#include <linux/platform_data/arm-ux500-pm.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/perf/arm_pmu.h>
 #include <linux/regulator/machine.h>
 
+#include <asm/outercache.h>
+#include <asm/hardware/cache-l2x0.h>
 #include <asm/mach/map.h>
+#include <asm/mach/arch.h>
 
 #include "setup.h"
 
 #include "board-mop500.h"
 #include "db8500-regs.h"
 
+static int __init ux500_l2x0_unlock(void)
+{
+	int i;
+	struct device_node *np;
+	void __iomem *l2x0_base;
+
+	np = of_find_compatible_node(NULL, NULL, "arm,pl310-cache");
+	l2x0_base = of_iomap(np, 0);
+	of_node_put(np);
+	if (!l2x0_base)
+		return -ENODEV;
+
+	/*
+	 * Unlock Data and Instruction Lock if locked. Ux500 U-Boot versions
+	 * apparently locks both caches before jumping to the kernel. The
+	 * l2x0 core will not touch the unlock registers if the l2x0 is
+	 * already enabled, so we do it right here instead. The PL310 has
+	 * 8 sets of registers, one per possible CPU.
+	 */
+	for (i = 0; i < 8; i++) {
+		writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_D_BASE +
+			       i * L2X0_LOCKDOWN_STRIDE);
+		writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_I_BASE +
+			       i * L2X0_LOCKDOWN_STRIDE);
+	}
+	iounmap(l2x0_base);
+	return 0;
+}
+
+static void ux500_l2c310_write_sec(unsigned long val, unsigned reg)
+{
+	/*
+	 * We can't write to secure registers as we are in non-secure
+	 * mode, until we have some SMI service available.
+	 */
+}
+
+/*
+ * FIXME: Should we set up the GPIO domain here?
+ *
+ * The problem is that we cannot put the interrupt resources into the platform
+ * device until the irqdomain has been added. Right now, we set the GIC interrupt
+ * domain from init_irq(), then load the gpio driver from
+ * core_initcall(nmk_gpio_init) and add the platform devices from
+ * arch_initcall(customize_machine).
+ *
+ * This feels fragile because it depends on the gpio device getting probed
+ * _before_ any device uses the gpio interrupts.
+*/
+static void __init ux500_init_irq(void)
+{
+	struct device_node *np;
+	struct resource r;
+
+	irqchip_init();
+	np = of_find_compatible_node(NULL, NULL, "stericsson,db8500-prcmu");
+	of_address_to_resource(np, 0, &r);
+	of_node_put(np);
+	if (!r.start) {
+		pr_err("could not find PRCMU base resource\n");
+		return;
+	}
+	prcmu_early_init(r.start, r.end-r.start);
+	ux500_pm_init(r.start, r.end-r.start);
+
+	/* Unlock before init */
+	ux500_l2x0_unlock();
+	outer_cache.write_sec = ux500_l2c310_write_sec;
+}
+
+static void ux500_restart(enum reboot_mode mode, const char *cmd)
+{
+	local_irq_disable();
+	local_fiq_disable();
+
+	prcmu_system_reset(0);
+}
+
 /*
  * The PMU IRQ lines of two cores are wired together into a single interrupt.
  * Bounce the interrupt to the other core if it's not ours.
diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
deleted file mode 100644
index a34af283ee23..000000000000
--- a/arch/arm/mach-ux500/cpu.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) ST-Ericsson SA 2010
- *
- * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
- * Author: Lee Jones <lee.jones@linaro.org> for ST-Ericsson
- * License terms: GNU General Public License (GPL) version 2
- */
-
-#include <linux/platform_device.h>
-#include <linux/io.h>
-#include <linux/mfd/dbx500-prcmu.h>
-#include <linux/sys_soc.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/stat.h>
-#include <linux/of.h>
-#include <linux/of_irq.h>
-#include <linux/of_address.h>
-#include <linux/irq.h>
-#include <linux/irqchip.h>
-#include <linux/irqchip/arm-gic.h>
-#include <linux/platform_data/arm-ux500-pm.h>
-
-#include <asm/mach/map.h>
-
-#include "setup.h"
-
-#include "board-mop500.h"
-#include "db8500-regs.h"
-
-void ux500_restart(enum reboot_mode mode, const char *cmd)
-{
-	local_irq_disable();
-	local_fiq_disable();
-
-	prcmu_system_reset(0);
-}
-
-/*
- * FIXME: Should we set up the GPIO domain here?
- *
- * The problem is that we cannot put the interrupt resources into the platform
- * device until the irqdomain has been added. Right now, we set the GIC interrupt
- * domain from init_irq(), then load the gpio driver from
- * core_initcall(nmk_gpio_init) and add the platform devices from
- * arch_initcall(customize_machine).
- *
- * This feels fragile because it depends on the gpio device getting probed
- * _before_ any device uses the gpio interrupts.
-*/
-void __init ux500_init_irq(void)
-{
-	struct device_node *np;
-	struct resource r;
-
-	irqchip_init();
-	np = of_find_compatible_node(NULL, NULL, "stericsson,db8500-prcmu");
-	of_address_to_resource(np, 0, &r);
-	of_node_put(np);
-	if (!r.start) {
-		pr_err("could not find PRCMU base resource\n");
-		return;
-	}
-	prcmu_early_init(r.start, r.end-r.start);
-	ux500_pm_init(r.start, r.end-r.start);
-	ux500_l2x0_init();
-}
diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
index 85b7819a40ab..988e7c77068d 100644
--- a/arch/arm/mach-ux500/setup.h
+++ b/arch/arm/mach-ux500/setup.h
@@ -11,16 +11,6 @@
 #ifndef __ASM_ARCH_SETUP_H
 #define __ASM_ARCH_SETUP_H
 
-#include <asm/mach/arch.h>
-#include <linux/init.h>
-
-
-void ux500_l2x0_init(void);
-
-void ux500_restart(enum reboot_mode mode, const char *cmd);
-
-extern void __init ux500_init_irq(void);
-
 extern void ux500_cpu_die(unsigned int cpu);
 
 #endif /*  __ASM_ARCH_SETUP_H */
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-06-24  9:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-24  9:41 [PATCH 0/7] ARM: ux500: cleanup of CPU id handling Arnd Bergmann
2016-06-24  9:41 ` [PATCH 1/7] ARM: ux500: move l2x0 init to .init_irq Arnd Bergmann
2016-06-24  9:41 ` [PATCH 2/7] ARM: ux500: use CLK_OF_DECLARE() Arnd Bergmann
2016-06-24  9:41 ` [PATCH 3/7] ARM: ux500: remove cpu_is_u* helpers Arnd Bergmann
2016-06-24  9:41 ` [PATCH 4/7] ARM: ux500: consolidate soc_device code in id.c Arnd Bergmann
2016-06-24  9:41 ` [PATCH 5/7] ARM: ux500: call ux500_setup_id later Arnd Bergmann
2016-06-24  9:41 ` [PATCH 6/7] ARM: ux500: move soc_id driver to drivers/soc Arnd Bergmann
2016-06-24  9:41 ` [PATCH 7/7] ARM: ux500: consolidate base platform files Arnd Bergmann

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).