Skip to contentSkip to conversation

Add suspend/resume support to locomo.c

PATCH In review Pavel Machek 5 participants 9 messages Jul 21, 2005 – Sep 11, 2005 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add suspend/resume support to locomo.c

From: John Lenz <[email protected]>

This adds low-level suspend/resume support to locomo.c.

arch/arm/common/locomo.c +101 -0
@@ -541,6 +541,103 @@ locomo_init_one_child(struct locomo *lch
 	return ret;
 }
 
+#ifdef CONFIG_PM
+
+struct locomo_save_data {
+	u16	LCM_GPO;
+	u16	LCM_SPICT;
+	u16	LCM_GPE;
+	u16	LCM_ASD;
+	u16	LCM_SPIMD;
+};
+
+static int locomo_suspend(struct device *dev, u32 pm_message_t, u32 level)
+{
+	struct locomo *lchip = dev_get_drvdata(dev);
+	struct locomo_save_data *save;
+	unsigned long flags;
+
+	if (level != SUSPEND_DISABLE)
+		return 0;
+
+	save = kmalloc(sizeof(struct locomo_save_data), GFP_KERNEL);
+	if (!save)
+		return -ENOMEM;
+
+	dev->power.saved_state = (void *) save;
+
+	spin_lock_irqsave(&lchip->lock, flags);
+
+	save->LCM_GPO     = locomo_readl(lchip->base + LOCOMO_GPO);	/* GPIO */
+	locomo_writel(0x00, lchip->base + LOCOMO_GPO);
+	save->LCM_SPICT   = locomo_readl(lchip->base + LOCOMO_SPICT);	/* SPI */
+	locomo_writel(0x40, lchip->base + LOCOMO_SPICT);
+	save->LCM_GPE     = locomo_readl(lchip->base + LOCOMO_GPE);	/* GPIO */
+	locomo_writel(0x00, lchip->base + LOCOMO_GPE);
+	save->LCM_ASD     = locomo_readl(lchip->base + LOCOMO_ASD);	/* ADSTART */
+	locomo_writel(0x00, lchip->base + LOCOMO_ASD);
+	save->LCM_SPIMD   = locomo_readl(lchip->base + LOCOMO_SPIMD);	/* SPI */
+	locomo_writel(0x3C14, lchip->base + LOCOMO_SPIMD);
+
+	locomo_writel(0x00, lchip->base + LOCOMO_PAIF);
+	locomo_writel(0x00, lchip->base + LOCOMO_DAC);
+	locomo_writel(0x00, lchip->base + LOCOMO_BACKLIGHT + LOCOMO_TC);
+
+	if ( (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT0) & 0x88) && (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT1) & 0x88) )
+		locomo_writel(0x00, lchip->base + LOCOMO_C32K); 	/* CLK32 off */
+	else
+		/* 18MHz already enabled, so no wait */
+		locomo_writel(0xc1, lchip->base + LOCOMO_C32K); 	/* CLK32 on */
+
+	locomo_writel(0x00, lchip->base + LOCOMO_TADC);		/* 18MHz clock off*/
+	locomo_writel(0x00, lchip->base + LOCOMO_AUDIO + LOCOMO_ACC);			/* 22MHz/24MHz clock off */
+	locomo_writel(0x00, lchip->base + LOCOMO_FRONTLIGHT + LOCOMO_ALS);			/* FL */
+
+	spin_unlock_irqrestore(&lchip->lock, flags);
+
+	return 0;
+}
+
+static int locomo_resume(struct device *dev, u32 level)
+{
+	struct locomo *lchip = dev_get_drvdata(dev);
+	struct locomo_save_data *save;
+	unsigned long r;
+	unsigned long flags;
+	
+	if (level != RESUME_ENABLE)
+		return 0;
+
+	save = (struct locomo_save_data *) dev->power.saved_state;
+	if (!save)
+		return 0;
+
+	spin_lock_irqsave(&lchip->lock, flags);
+
+	locomo_writel(save->LCM_GPO, lchip->base + LOCOMO_GPO);
+	locomo_writel(save->LCM_SPICT, lchip->base + LOCOMO_SPICT);
+	locomo_writel(save->LCM_GPE, lchip->base + LOCOMO_GPE);
+	locomo_writel(save->LCM_ASD, lchip->base + LOCOMO_ASD);
+	locomo_writel(save->LCM_SPIMD, lchip->base + LOCOMO_SPIMD);
+
+	locomo_writel(0x00, lchip->base + LOCOMO_C32K);
+	locomo_writel(0x90, lchip->base + LOCOMO_TADC);
+
+	locomo_writel(0, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KSC);
+	r = locomo_readl(lchip->base + LOCOMO_KEYBOARD + LOCOMO_KIC);
+	r &= 0xFEFF;
+	locomo_writel(r, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KIC);
+	locomo_writel(0x1, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KCMD);
+
+	spin_unlock_irqrestore(&lchip->lock, flags);
+
+	dev->power.saved_state = NULL;
+	kfree(save);
+
+	return 0;
+}
+#endif
+
 /**
  *	locomo_probe - probe for a single LoCoMo chip.
  *	@phys_addr: physical address of device.
@@ -707,6 +810,10 @@ static struct device_driver locomo_devic
 	.bus		= &platform_bus_type,
 	.probe		= locomo_probe,
 	.remove		= locomo_remove,
+#ifdef CONFIG_PM
+	.suspend	= locomo_suspend,
+	.resume		= locomo_resume,
+#endif
 };
 
 /*
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
#1 lore raw
Quoted 5 lines · Pavel Machek

From: John Lenz <[email protected]>

This adds low-level suspend/resume support to locomo.c.

Shouldn't this be signed off by John himself? Not applied.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#2 lore raw

Hi!

Quoted 7 lines
Quoted 5 lines

From: John Lenz <[email protected]>

This adds low-level suspend/resume support to locomo.c.

Shouldn't this be signed off by John himself? Not applied.

Well, it would be nice if it was signed off by him, but John is nowhere to be reached.

So I signed it off myself, as in:

(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or

; that should be okay.
Pavel

Signature · 1 line
if you have sharp zaurus hardware you don't need... you know my address
#3 lore raw
Quoted 2 lines · Pavel Machek

Well, it would be nice if it was signed off by him, but John is nowhere to be reached.

Hmm, ok, applied.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#4 lore raw
In reply to Pavel Machek
Quoted 4 lines · Pavel Machek

Hi!

Quoted 2 lines
Quoted 2 lines

From: John Lenz <[email protected]>

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

This adds low-level suspend/resume support to locomo.c.

Shouldn't this be signed off by John himself? Not applied.

Well, it would be nice if it was signed off by him, but John is nowhere to be reached.

Sorry. I have been away from the internet (somewhat unexpectedly) the past three weeks... so I am not up to date on what has been happening. For the near future as I try and come back up to speed, patches can be applied from Pavel.

Pavel, perhaps you could send me an email about what you (and others) have done the past few weeks? The patches on my site and such are probably a
ways out of date. What/where is the latest code located? What progress
has been made... Hopefully sometime next week I can start working on this stuff again.

Thanks,
John

#5 lore raw

Hi!

Quoted 16 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

From: John Lenz <[email protected]>

This adds low-level suspend/resume support to locomo.c.

Shouldn't this be signed off by John himself? Not applied.

Well, it would be nice if it was signed off by him, but John is nowhere to be reached.

Sorry. I have been away from the internet (somewhat unexpectedly) the past three weeks... so I am not up to date on what has been happening. For the near future as I try and come back up to speed, patches can be applied from Pavel.

Quoted 5 lines

Pavel, perhaps you could send me an email about what you (and others) have done the past few weeks? The patches on my site and such are probably a
ways out of date. What/where is the latest code located? What progress
has been made... Hopefully sometime next week I can start working on this stuff again.

[I have just came back from 3 days horse trip... you'll get replies to other mails later.]

There's git tree at www.kernel.org/git ... its called linux-z. It worked for before I got to 2.6.13, but it is now broken (IIRC, maybe its okay). PCMCIA never worked for me. linux-z is probably good start for new work. It should have all your patches IIRC.

I started work on battery control, and it does something, but I do not dare enabling charging juts yet.

Pavel

Signature · 1 line
if you have sharp zaurus hardware you don't need... you know my address
#6 lore raw
Quoted 10 lines · Pavel Machek

[I have just came back from 3 days horse trip... you'll get replies to other mails later.]

There's git tree at www.kernel.org/git ... its called linux-z. It worked for before I got to 2.6.13, but it is now broken (IIRC, maybe its okay). PCMCIA never worked for me. linux-z is probably good start for new work. It should have all your patches IIRC.

I started work on battery control, and it does something, but I do not dare enabling charging juts yet.

It might be worth looking at:

http://www.rpsys.net/openzaurus/patches/sharpsl_pm-r8.patch

This is a more general and much cleaned up version of the Sharp power management code. I've not studied the collie specifics so I don't know how adaptable this would be for your uses. Examples of machine specific support code are:

http://www.rpsys.net/openzaurus/patches/spitz_pm-r3.patch
http://www.rpsys.net/openzaurus/patches/corgi_pm-r3.patch

I'm still cleaning this up but its getting there...

Richard

#7 lore raw
In reply to Pavel Machek

Hi!

Quoted 22 lines
Quoted 16 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

From: John Lenz <[email protected]>

This adds low-level suspend/resume support to locomo.c.

Shouldn't this be signed off by John himself? Not applied.

Well, it would be nice if it was signed off by him, but John is nowhere to be reached.

Sorry. I have been away from the internet (somewhat unexpectedly) the past three weeks... so I am not up to date on what has been happening. For the near future as I try and come back up to speed, patches can be applied from Pavel.

Quoted 5 lines

Pavel, perhaps you could send me an email about what you (and others) have done the past few weeks? The patches on my site and such are probably a
ways out of date. What/where is the latest code located? What progress
has been made... Hopefully sometime next week I can start working on this stuff again.

Quoted 7 lines

[I have just came back from 3 days horse trip... you'll get replies to other mails later.]

There's git tree at www.kernel.org/git ... its called linux-z. It worked for before I got to 2.6.13, but it is now broken (IIRC, maybe its okay). PCMCIA never worked for me. linux-z is probably good start for new work. It should have all your patches IIRC.

Okay, it was really stupid problem, I #if-0ed collie-specific code. No wonder it did not boot. I'll start push to kernel.org but it will take a while. FYI, bigdiff against mainline is attached, split version will appear on kernel.org in few hours.
Pavel

Signature · 1 line
if you have sharp zaurus hardware you don't need... you know my address
#8 lore raw

Hi!

Quoted 14 lines
Quoted 6 lines
Quoted 5 lines

Pavel, perhaps you could send me an email about what you (and others) have done the past few weeks? The patches on my site and such are probably a
ways out of date. What/where is the latest code located? What progress
has been made... Hopefully sometime next week I can start working on this stuff again.

Quoted 7 lines

[I have just came back from 3 days horse trip... you'll get replies to other mails later.]

There's git tree at www.kernel.org/git ... its called linux-z. It worked for before I got to 2.6.13, but it is now broken (IIRC, maybe its okay). PCMCIA never worked for me. linux-z is probably good start for new work. It should have all your patches IIRC.

Quoted 4 lines

Okay, it was really stupid problem, I #if-0ed collie-specific code. No wonder it did not boot. I'll start push to kernel.org but it will take a while. FYI, bigdiff against mainline is attached, split version will appear on kernel.org in few hours.

Okay, I played a bit with Richard's patches, and broke my tree again. Last good one is

commit 4c8a125f9906fda6a43224ad0bad99a8583eb488 tree 14796040835cd69c635dc4b15430b49e2721630b parent fc0058795a7bd2a9b87e7368dc30ad6701888c7b author <pavel@amd.(none)> Sun, 11 Sep 2005 23:30:36 +0200 committer <pavel@amd.(none)> Sun, 11 Sep 2005 23:30:36 +0200

Remove include/asm-arm/arch-sa1100/ucb1x00.h and fix stuff that breaks.

Pavel

Signature · 1 line
if you have sharp zaurus hardware you don't need... you know my address