Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Mar 2021 18:34:36 GMT
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: b6d8f3b517de - main - powerpc/powermac: Constrain 'cpu_sleep()' for AIM to mpc745x
Message-ID:  <202103311834.12VIYaNp007211@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhibbits:

URL: https://cgit.FreeBSD.org/src/commit/?id=b6d8f3b517dec010f3dfad1b33e9945eaa606be5

commit b6d8f3b517dec010f3dfad1b33e9945eaa606be5
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2021-03-31 16:54:11 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2021-03-31 18:34:06 +0000

    powerpc/powermac: Constrain 'cpu_sleep()' for AIM to mpc745x
    
    Rename cpu_sleep() to mpc745x_sleep() to denote what it's actually
    intended for.  This function is very G4-specific, and will not work on
    any other CPU.  This will afterward eliminate a
    platform_smp_timebase_sync() call by directly updating the timebase
    instead.
---
 sys/powerpc/aim/aim_machdep.c            |  4 +++-
 sys/powerpc/include/cpu.h                |  6 +++++-
 sys/powerpc/powermac/platform_powermac.c | 13 ++++++++++++-
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/sys/powerpc/aim/aim_machdep.c b/sys/powerpc/aim/aim_machdep.c
index 0ce7cf03403f..b09089069c28 100644
--- a/sys/powerpc/aim/aim_machdep.c
+++ b/sys/powerpc/aim/aim_machdep.c
@@ -721,8 +721,9 @@ flush_disable_caches(void)
 	mtmsr(msr);
 }
 
+#ifndef __powerpc64__
 void
-cpu_sleep()
+mpc745x_sleep()
 {
 	static u_quad_t timebase = 0;
 	static register_t sprgs[4];
@@ -785,3 +786,4 @@ cpu_sleep()
 		enable_vec(curthread);
 	powerpc_sync();
 }
+#endif
diff --git a/sys/powerpc/include/cpu.h b/sys/powerpc/include/cpu.h
index 9ae18e13900a..256e6d3eabf0 100644
--- a/sys/powerpc/include/cpu.h
+++ b/sys/powerpc/include/cpu.h
@@ -144,10 +144,14 @@ extern register_t lpcr;
 
 void	cpu_halt(void);
 void	cpu_reset(void);
-void	cpu_sleep(void);
 void	flush_disable_caches(void);
 void	fork_trampoline(void);
 void	swi_vm(void *);
 int	cpu_machine_check(struct thread *, struct trapframe *, int *);
 
+
+#ifndef __powerpc64__
+void	mpc745x_sleep(void);
+#endif
+
 #endif	/* _MACHINE_CPU_H_ */
diff --git a/sys/powerpc/powermac/platform_powermac.c b/sys/powerpc/powermac/platform_powermac.c
index d08b3fe9181c..7f78bc63c1ab 100644
--- a/sys/powerpc/powermac/platform_powermac.c
+++ b/sys/powerpc/powermac/platform_powermac.c
@@ -68,7 +68,9 @@ static int powermac_smp_get_bsp(platform_t, struct cpuref *cpuref);
 static int powermac_smp_start_cpu(platform_t, struct pcpu *cpu);
 static void powermac_smp_timebase_sync(platform_t, u_long tb, int ap);
 static void powermac_reset(platform_t);
+#ifndef __powerpc64__
 static void powermac_sleep(platform_t);
+#endif
 
 static platform_method_t powermac_methods[] = {
 	PLATFORMMETHOD(platform_probe, 		powermac_probe),
@@ -83,7 +85,9 @@ static platform_method_t powermac_methods[] = {
 	PLATFORMMETHOD(platform_smp_timebase_sync, powermac_smp_timebase_sync),
 
 	PLATFORMMETHOD(platform_reset,		powermac_reset),
+#ifndef __powerpc64__
 	PLATFORMMETHOD(platform_sleep,		powermac_sleep),
+#endif
 
 	PLATFORMMETHOD_END
 };
@@ -404,10 +408,17 @@ powermac_reset(platform_t platform)
 	OF_reboot();
 }
 
+#ifndef __powerpc64__
 void
 powermac_sleep(platform_t platform)
 {
+	/* Only supports MPC745x for now. */
+	if (!MPC745X_P(mfspr(SPR_PVR) >> 16)) {
+		printf("sleep only supported for G4 PowerMac hardware.\n");
+		return;
+	}
 
 	*(unsigned long *)0x80 = 0x100;
-	cpu_sleep();
+	mpc745x_sleep();
 }
+#endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103311834.12VIYaNp007211>