tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Mac suspend mode (was Re: Suspend mode?-



Hello

I followup my post on port-macppc@ about mac sleep mode.
The target is an iBook G4, and I am trying to port to NetBSD
the code from Linux:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/macintosh/via-pmu.c

In powerbook_sleep_Core99() we have a few calls for which I wonder
about a NetBSD equivalent. Do we have MI stuff for that? Should I
reimplement it?

First: cache state save/restore:

        /* Save the state of the L2 and L3 caches */
        save_l3cr = _get_L3CR();	/* (returns -1 if not available) */
        save_l2cr = _get_L2CR();	/* (returns -1 if not available) */
(...)
	/* Restore L2 cache */
	if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
 		_set_L2CR(save_l2cr);
	/* Restore L3 cache */
	if (save_l3cr != 0xffffffff && (save_l3cr & L3CR_L3E) != 0)
 		_set_L3CR(save_l3cr);

The implementations are in linux/arch/powerpc/kernel/l2cr_6xx.S

Second, a MMU state restoration on wakeup:
	/* Restore userland MMU context */
	switch_mmu_context(NULL, current->active_mm, NULL);

It seems to be defined in linux/arch/powerpc/kernel/head_32.S

And finaly GPU state restoration on wakeup:
	/* Restore video */
	pmac_call_early_video_resume();

The iBook G4 GPU is a radeon, therefore in Linux that seems to go to 
linux/drivers/video/fbdev/aty/radeon_pm.c:radeon_fb_realy_resume()
for which I am almost certain I will need to write some code.


On Sun, May 15, 2022 at 01:37:23AM +0000, Emmanuel Dreyfus wrote:
> On Fri, May 13, 2022 at 01:31:15AM +0000, Emmanuel Dreyfus wrote:
> > Did anyone have a look at suspend mode? 
> 
> Linux seems to have support for it in linux/drivers/macintosh/via-pmu.c
> 
> I tried sending this to PMU:
> PMU_PWR_CLR_WAKEUP_EVENTS { 0xff, 0xff }
> PMU_PWR_SET_WAKEUP_EVENTS { 0,  PMU_PWR_WAKEUP_KEY|PMU_PWR_WAKEUP_LID_OPEN }
> PMU_SLEEP { 'M', 'A', 'T', 'T' }
> 
> I get the blinking power LED which us the usual sleep behavior.
> Reopenoing the lid I get a power down, but looking at Linux sources, there
> is much more to save and restore, hence this is still encouraging;
> 
> -- 
> Emmanuel Dreyfus
> manu%netbsd.org@localhost

-- 
Emmanuel Dreyfus
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index