200 lines
5.4 KiB
Diff
200 lines
5.4 KiB
Diff
|
From 78c3d2e796a28ad55f6c2310a11ab22e91bb52fc Mon Sep 17 00:00:00 2001
|
||
|
From: Jonas Gorski <jogo@openwrt.org>
|
||
|
Date: Mon, 2 Dec 2013 12:30:44 +0100
|
||
|
Subject: [PATCH 8/8] MIPS: BCM63XX: remove !RUNTIME_DETECT code for
|
||
|
bcmcpu_get_id
|
||
|
|
||
|
Use the same pattern as with get_*_cpu_type() to allow the compiler
|
||
|
to remove code for non enabled devices.
|
||
|
|
||
|
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||
|
---
|
||
|
arch/mips/bcm63xx/cpu.c | 11 +--
|
||
|
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h | 120 +++++++----------------
|
||
|
2 files changed, 38 insertions(+), 93 deletions(-)
|
||
|
|
||
|
--- a/arch/mips/bcm63xx/cpu.c
|
||
|
+++ b/arch/mips/bcm63xx/cpu.c
|
||
|
@@ -24,7 +24,9 @@ EXPORT_SYMBOL(bcm63xx_regs_base);
|
||
|
const int *bcm63xx_irqs;
|
||
|
EXPORT_SYMBOL(bcm63xx_irqs);
|
||
|
|
||
|
-static u16 bcm63xx_cpu_id;
|
||
|
+u16 bcm63xx_cpu_id __read_mostly;
|
||
|
+EXPORT_SYMBOL(bcm63xx_cpu_id);
|
||
|
+
|
||
|
static u8 bcm63xx_cpu_rev;
|
||
|
static unsigned int bcm63xx_cpu_freq;
|
||
|
static unsigned int bcm63xx_memory_size;
|
||
|
@@ -97,13 +99,6 @@ static const int bcm6368_irqs[] = {
|
||
|
|
||
|
};
|
||
|
|
||
|
-u16 __bcm63xx_get_cpu_id(void)
|
||
|
-{
|
||
|
- return bcm63xx_cpu_id;
|
||
|
-}
|
||
|
-
|
||
|
-EXPORT_SYMBOL(__bcm63xx_get_cpu_id);
|
||
|
-
|
||
|
u8 bcm63xx_get_cpu_rev(void)
|
||
|
{
|
||
|
return bcm63xx_cpu_rev;
|
||
|
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
|
||
|
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
|
||
|
@@ -19,118 +19,68 @@
|
||
|
#define BCM6368_CPU_ID 0x6368
|
||
|
|
||
|
void __init bcm63xx_cpu_init(void);
|
||
|
-u16 __bcm63xx_get_cpu_id(void);
|
||
|
u8 bcm63xx_get_cpu_rev(void);
|
||
|
unsigned int bcm63xx_get_cpu_freq(void);
|
||
|
|
||
|
+static inline u16 __pure __bcm63xx_get_cpu_id(const u16 cpu_id)
|
||
|
+{
|
||
|
+ switch (cpu_id) {
|
||
|
#ifdef CONFIG_BCM63XX_CPU_3368
|
||
|
-# ifdef bcm63xx_get_cpu_id
|
||
|
-# undef bcm63xx_get_cpu_id
|
||
|
-# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
|
||
|
-# define BCMCPU_RUNTIME_DETECT
|
||
|
-# else
|
||
|
-# define bcm63xx_get_cpu_id() BCM3368_CPU_ID
|
||
|
-# endif
|
||
|
-# define BCMCPU_IS_3368() (bcm63xx_get_cpu_id() == BCM3368_CPU_ID)
|
||
|
-#else
|
||
|
-# define BCMCPU_IS_3368() (0)
|
||
|
+ case BCM3368_CPU_ID:
|
||
|
#endif
|
||
|
|
||
|
#ifdef CONFIG_BCM63XX_CPU_6328
|
||
|
-# ifdef bcm63xx_get_cpu_id
|
||
|
-# undef bcm63xx_get_cpu_id
|
||
|
-# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
|
||
|
-# define BCMCPU_RUNTIME_DETECT
|
||
|
-# else
|
||
|
-# define bcm63xx_get_cpu_id() BCM6328_CPU_ID
|
||
|
-# endif
|
||
|
-# define BCMCPU_IS_6328() (bcm63xx_get_cpu_id() == BCM6328_CPU_ID)
|
||
|
-#else
|
||
|
-# define BCMCPU_IS_6328() (0)
|
||
|
+ case BCM6328_CPU_ID:
|
||
|
#endif
|
||
|
|
||
|
#ifdef CONFIG_BCM63XX_CPU_6338
|
||
|
-# ifdef bcm63xx_get_cpu_id
|
||
|
-# undef bcm63xx_get_cpu_id
|
||
|
-# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
|
||
|
-# define BCMCPU_RUNTIME_DETECT
|
||
|
-# else
|
||
|
-# define bcm63xx_get_cpu_id() BCM6338_CPU_ID
|
||
|
-# endif
|
||
|
-# define BCMCPU_IS_6338() (bcm63xx_get_cpu_id() == BCM6338_CPU_ID)
|
||
|
-#else
|
||
|
-# define BCMCPU_IS_6338() (0)
|
||
|
+ case BCM6338_CPU_ID:
|
||
|
#endif
|
||
|
|
||
|
#ifdef CONFIG_BCM63XX_CPU_6345
|
||
|
-# ifdef bcm63xx_get_cpu_id
|
||
|
-# undef bcm63xx_get_cpu_id
|
||
|
-# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
|
||
|
-# define BCMCPU_RUNTIME_DETECT
|
||
|
-# else
|
||
|
-# define bcm63xx_get_cpu_id() BCM6345_CPU_ID
|
||
|
-# endif
|
||
|
-# define BCMCPU_IS_6345() (bcm63xx_get_cpu_id() == BCM6345_CPU_ID)
|
||
|
-#else
|
||
|
-# define BCMCPU_IS_6345() (0)
|
||
|
+ case BCM6345_CPU_ID:
|
||
|
#endif
|
||
|
|
||
|
#ifdef CONFIG_BCM63XX_CPU_6348
|
||
|
-# ifdef bcm63xx_get_cpu_id
|
||
|
-# undef bcm63xx_get_cpu_id
|
||
|
-# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
|
||
|
-# define BCMCPU_RUNTIME_DETECT
|
||
|
-# else
|
||
|
-# define bcm63xx_get_cpu_id() BCM6348_CPU_ID
|
||
|
-# endif
|
||
|
-# define BCMCPU_IS_6348() (bcm63xx_get_cpu_id() == BCM6348_CPU_ID)
|
||
|
-#else
|
||
|
-# define BCMCPU_IS_6348() (0)
|
||
|
+ case BCM6348_CPU_ID:
|
||
|
#endif
|
||
|
|
||
|
#ifdef CONFIG_BCM63XX_CPU_6358
|
||
|
-# ifdef bcm63xx_get_cpu_id
|
||
|
-# undef bcm63xx_get_cpu_id
|
||
|
-# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
|
||
|
-# define BCMCPU_RUNTIME_DETECT
|
||
|
-# else
|
||
|
-# define bcm63xx_get_cpu_id() BCM6358_CPU_ID
|
||
|
-# endif
|
||
|
-# define BCMCPU_IS_6358() (bcm63xx_get_cpu_id() == BCM6358_CPU_ID)
|
||
|
-#else
|
||
|
-# define BCMCPU_IS_6358() (0)
|
||
|
+ case BCM6358_CPU_ID:
|
||
|
#endif
|
||
|
|
||
|
#ifdef CONFIG_BCM63XX_CPU_6362
|
||
|
-# ifdef bcm63xx_get_cpu_id
|
||
|
-# undef bcm63xx_get_cpu_id
|
||
|
-# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
|
||
|
-# define BCMCPU_RUNTIME_DETECT
|
||
|
-# else
|
||
|
-# define bcm63xx_get_cpu_id() BCM6362_CPU_ID
|
||
|
-# endif
|
||
|
-# define BCMCPU_IS_6362() (bcm63xx_get_cpu_id() == BCM6362_CPU_ID)
|
||
|
-#else
|
||
|
-# define BCMCPU_IS_6362() (0)
|
||
|
+ case BCM6362_CPU_ID:
|
||
|
#endif
|
||
|
|
||
|
-
|
||
|
#ifdef CONFIG_BCM63XX_CPU_6368
|
||
|
-# ifdef bcm63xx_get_cpu_id
|
||
|
-# undef bcm63xx_get_cpu_id
|
||
|
-# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
|
||
|
-# define BCMCPU_RUNTIME_DETECT
|
||
|
-# else
|
||
|
-# define bcm63xx_get_cpu_id() BCM6368_CPU_ID
|
||
|
-# endif
|
||
|
-# define BCMCPU_IS_6368() (bcm63xx_get_cpu_id() == BCM6368_CPU_ID)
|
||
|
-#else
|
||
|
-# define BCMCPU_IS_6368() (0)
|
||
|
-#endif
|
||
|
-
|
||
|
-#ifndef bcm63xx_get_cpu_id
|
||
|
-#error "No CPU support configured"
|
||
|
+ case BCM6368_CPU_ID:
|
||
|
#endif
|
||
|
+ break;
|
||
|
+ default:
|
||
|
+ unreachable();
|
||
|
+ }
|
||
|
+
|
||
|
+ return cpu_id;
|
||
|
+}
|
||
|
+
|
||
|
+extern u16 bcm63xx_cpu_id;
|
||
|
+
|
||
|
+static inline u16 __pure bcm63xx_get_cpu_id(void)
|
||
|
+{
|
||
|
+ const u16 cpu_id = bcm63xx_cpu_id;
|
||
|
+
|
||
|
+ return __bcm63xx_get_cpu_id(cpu_id);
|
||
|
+}
|
||
|
+
|
||
|
+#define BCMCPU_IS_3368() (bcm63xx_get_cpu_id() == BCM3368_CPU_ID)
|
||
|
+#define BCMCPU_IS_6328() (bcm63xx_get_cpu_id() == BCM6328_CPU_ID)
|
||
|
+#define BCMCPU_IS_6338() (bcm63xx_get_cpu_id() == BCM6338_CPU_ID)
|
||
|
+#define BCMCPU_IS_6345() (bcm63xx_get_cpu_id() == BCM6345_CPU_ID)
|
||
|
+#define BCMCPU_IS_6348() (bcm63xx_get_cpu_id() == BCM6348_CPU_ID)
|
||
|
+#define BCMCPU_IS_6358() (bcm63xx_get_cpu_id() == BCM6358_CPU_ID)
|
||
|
+#define BCMCPU_IS_6362() (bcm63xx_get_cpu_id() == BCM6362_CPU_ID)
|
||
|
+#define BCMCPU_IS_6368() (bcm63xx_get_cpu_id() == BCM6368_CPU_ID)
|
||
|
|
||
|
/*
|
||
|
* While registers sets are (mostly) the same across 63xx CPU, base
|