Skip to content

Commit 140e39c

Browse files
chenhuacairalfbaechle
authored andcommitted
MIPS: Loongson: Modify ChipConfig register definition
This patch is prepared for Multi-chip interconnection. Since each chip has a ChipConfig register, LOONGSON_CHIPCFG should be an array. Signed-off-by: Huacai Chen <[email protected]> Cc: John Crispin <[email protected]> Cc: Steven J. Hill <[email protected]> Cc: Aurelien Jarno <[email protected]> Cc: [email protected] Cc: Fuxin Zhang <[email protected]> Cc: Zhangjin Wu <[email protected]> Patchwork: https://patchwork.linux-mips.org/patch/7185/ Signed-off-by: Ralf Baechle <[email protected]>
1 parent bda4584 commit 140e39c

File tree

7 files changed

+28
-14
lines changed

7 files changed

+28
-14
lines changed

arch/mips/include/asm/mach-loongson/loongson.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,11 @@ static inline void do_perfcnt_IRQ(void)
249249
#define LOONGSON_PXARB_CFG LOONGSON_REG(LOONGSON_REGBASE + 0x68)
250250
#define LOONGSON_PXARB_STATUS LOONGSON_REG(LOONGSON_REGBASE + 0x6c)
251251

252-
/* Chip Config */
253-
#define LOONGSON_CHIPCFG0 LOONGSON_REG(LOONGSON_REGBASE + 0x80)
252+
#define MAX_PACKAGES 4
253+
254+
/* Chip Config registor of each physical cpu package, PRid >= Loongson-2F */
255+
extern u64 loongson_chipcfg[MAX_PACKAGES];
256+
#define LOONGSON_CHIPCFG(id) (*(volatile u32 *)(loongson_chipcfg[id]))
254257

255258
/* pcimap */
256259

arch/mips/loongson/common/env.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ EXPORT_SYMBOL(cpu_clock_freq);
2727
struct efi_memory_map_loongson *loongson_memmap;
2828
struct loongson_system_configuration loongson_sysconf;
2929

30+
u64 loongson_chipcfg[MAX_PACKAGES] = {0xffffffffbfc00180};
31+
3032
#define parse_even_earlier(res, option, p) \
3133
do { \
3234
unsigned int tmp __maybe_unused; \
@@ -77,6 +79,15 @@ void __init prom_init_env(void)
7779

7880
cpu_clock_freq = ecpu->cpu_clock_freq;
7981
loongson_sysconf.cputype = ecpu->cputype;
82+
if (ecpu->cputype == Loongson_3A) {
83+
loongson_chipcfg[0] = 0x900000001fe00180;
84+
loongson_chipcfg[1] = 0x900010001fe00180;
85+
loongson_chipcfg[2] = 0x900020001fe00180;
86+
loongson_chipcfg[3] = 0x900030001fe00180;
87+
} else {
88+
loongson_chipcfg[0] = 0x900000001fe00180;
89+
}
90+
8091
loongson_sysconf.nr_cpus = ecpu->nr_cpus;
8192
if (ecpu->nr_cpus > NR_CPUS || ecpu->nr_cpus == 0)
8293
loongson_sysconf.nr_cpus = NR_CPUS;

arch/mips/loongson/common/pm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int __weak wakeup_loongson(void)
7979
static void wait_for_wakeup_events(void)
8080
{
8181
while (!wakeup_loongson())
82-
LOONGSON_CHIPCFG0 &= ~0x7;
82+
LOONGSON_CHIPCFG(0) &= ~0x7;
8383
}
8484

8585
/*
@@ -102,15 +102,15 @@ static void loongson_suspend_enter(void)
102102

103103
stop_perf_counters();
104104

105-
cached_cpu_freq = LOONGSON_CHIPCFG0;
105+
cached_cpu_freq = LOONGSON_CHIPCFG(0);
106106

107107
/* Put CPU into wait mode */
108-
LOONGSON_CHIPCFG0 &= ~0x7;
108+
LOONGSON_CHIPCFG(0) &= ~0x7;
109109

110110
/* wait for the given events to wakeup cpu from wait mode */
111111
wait_for_wakeup_events();
112112

113-
LOONGSON_CHIPCFG0 = cached_cpu_freq;
113+
LOONGSON_CHIPCFG(0) = cached_cpu_freq;
114114
mmiowb();
115115
}
116116

arch/mips/loongson/lemote-2f/clock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
114114

115115
clk->rate = rate;
116116

117-
regval = LOONGSON_CHIPCFG0;
117+
regval = LOONGSON_CHIPCFG(0);
118118
regval = (regval & ~0x7) | (pos->driver_data - 1);
119-
LOONGSON_CHIPCFG0 = regval;
119+
LOONGSON_CHIPCFG(0) = regval;
120120

121121
return ret;
122122
}

arch/mips/loongson/lemote-2f/reset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void reset_cpu(void)
2828
* reset cpu to full speed, this is needed when enabling cpu frequency
2929
* scalling
3030
*/
31-
LOONGSON_CHIPCFG0 |= 0x7;
31+
LOONGSON_CHIPCFG(0) |= 0x7;
3232
}
3333

3434
/* reset support for fuloong2f */

arch/mips/loongson/loongson-3/smp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,12 @@ static int loongson3_cpu_callback(struct notifier_block *nfb,
399399
case CPU_POST_DEAD:
400400
case CPU_POST_DEAD_FROZEN:
401401
pr_info("Disable clock for CPU#%d\n", cpu);
402-
LOONGSON_CHIPCFG0 &= ~(1 << (12 + cpu));
402+
LOONGSON_CHIPCFG(0) &= ~(1 << (12 + cpu));
403403
break;
404404
case CPU_UP_PREPARE:
405405
case CPU_UP_PREPARE_FROZEN:
406406
pr_info("Enable clock for CPU#%d\n", cpu);
407-
LOONGSON_CHIPCFG0 |= 1 << (12 + cpu);
407+
LOONGSON_CHIPCFG(0) |= 1 << (12 + cpu);
408408
break;
409409
}
410410

drivers/cpufreq/loongson2_cpufreq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ static void loongson2_cpu_wait(void)
148148
u32 cpu_freq;
149149

150150
spin_lock_irqsave(&loongson2_wait_lock, flags);
151-
cpu_freq = LOONGSON_CHIPCFG0;
152-
LOONGSON_CHIPCFG0 &= ~0x7; /* Put CPU into wait mode */
153-
LOONGSON_CHIPCFG0 = cpu_freq; /* Restore CPU state */
151+
cpu_freq = LOONGSON_CHIPCFG(0);
152+
LOONGSON_CHIPCFG(0) &= ~0x7; /* Put CPU into wait mode */
153+
LOONGSON_CHIPCFG(0) = cpu_freq; /* Restore CPU state */
154154
spin_unlock_irqrestore(&loongson2_wait_lock, flags);
155155
local_irq_enable();
156156
}

0 commit comments

Comments
 (0)