Skip to contentSkip to conversation

split sharpsl_pm.c into generic and corgi/spitz specific parts

PATCH In review Pavel Machek 2 participants 5 messages Nov 23, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 split sharpsl_pm.c into generic and corgi/spitz specific parts

Hi!

This splits sharpsl_pm.c into sharpsl_pm.c (generic code) and sharpsl_pm_pxa.c (spitz/corgi specific code). sharpsl_pm.c code should be reusable by collie.

I'd like to see it applied...
Pavel

arch/arm/mach-pxa/Makefile +2 -2
@@ -11,8 +11,8 @@ obj-$(CONFIG_PXA27x) += pxa27x.o
 obj-$(CONFIG_ARCH_LUBBOCK) += lubbock.o
 obj-$(CONFIG_MACH_MAINSTONE) += mainstone.o
 obj-$(CONFIG_ARCH_PXA_IDP) += idp.o
-obj-$(CONFIG_PXA_SHARP_C7xx)	+= corgi.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o corgi_pm.o
-obj-$(CONFIG_PXA_SHARP_Cxx00)	+= spitz.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o spitz_pm.o
+obj-$(CONFIG_PXA_SHARP_C7xx)	+= corgi.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o sharpsl_pm_pxa.o corgi_pm.o
+obj-$(CONFIG_PXA_SHARP_Cxx00)	+= spitz.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o sharpsl_pm_pxa.o spitz_pm.o
 obj-$(CONFIG_MACH_AKITA)	+= akita-ioexp.o
 obj-$(CONFIG_MACH_POODLE)	+= poodle.o
 obj-$(CONFIG_MACH_TOSA)         += tosa.o
arch/arm/mach-pxa/corgi_pm.c +5 -0
@@ -33,6 +33,7 @@ static void corgi_charger_init(void)
 	pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT);
 	pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT);
 	pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN);
+	sharpsl_arch_pm_init();
 }
 
 static void corgi_charge_led(int val)
@@ -179,6 +180,10 @@ static int corgi_acin_status(void)
 
 static struct sharpsl_charger_machinfo corgi_pm_machinfo = {
 	.init            = corgi_charger_init,
+	.remove		 = sharpsl_arch_pm_remove,
+	.read_main_battery= sharpsl_read_main_battery,
+	.read_temp	  = sharpsl_read_temp,
+	.read_acin	  = sharpsl_read_acin,
 	.gpio_batlock    = CORGI_GPIO_BAT_COVER,
 	.gpio_acin       = CORGI_GPIO_AC_IN,
 	.gpio_batfull    = CORGI_GPIO_CHRG_FULL,
arch/arm/mach-pxa/sharpsl.h +17 -0
@@ -2,6 +2,8 @@
  * SharpSL SSP Driver
  */
 
+#include <linux/interrupt.h>
+
 struct corgissp_machinfo {
 	int port;
 	int cs_lcdcon;
@@ -51,8 +53,12 @@ struct sharpsl_charger_machinfo {
 	void (*measure_temp)(int);
 	void (*presuspend)(void);
 	void (*postsuspend)(void);
+	int (*read_main_battery)(void);
+	int (*read_temp)(void);
+	int (*read_acin)(void);
 	unsigned long (*charger_wakeup)(void);
 	int (*should_wakeup)(unsigned int resume_on_alarm);
+	int (*remove)(void);
 	int bat_levels;
 	struct battery_thresh *bat_levels_noac;
 	struct battery_thresh *bat_levels_acin;
@@ -119,3 +125,14 @@ extern struct battery_thresh spitz_batte
 #define STATUS_BATT_LOCKED()  READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock)
 #define STATUS_CHRG_FULL()  READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull)
 #define STATUS_FATAL()      READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal)
+
+extern irqreturn_t sharpsl_ac_isr(int irq, void *dev_id, struct pt_regs *fp);
+extern irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp);
+extern irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id, struct pt_regs *fp);
+
+extern int sharpsl_read_main_battery(void);
+extern int sharpsl_read_temp(void);
+extern int sharpsl_read_acin(void);
+
+extern int sharpsl_arch_pm_init(void);
+extern int sharpsl_arch_pm_remove(void);
arch/arm/mach-pxa/sharpsl_pm.c +13 -186

304 lines not on this page · raw message

arch/arm/mach-pxa/sharpsl_pm_pxa.c new file +217 -0

217 lines not on this page · raw message

arch/arm/mach-pxa/spitz_pm.c +5 -0
@@ -33,6 +33,7 @@ static void spitz_charger_init(void)
 {
 	pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN);
 	pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN);
+	sharpsl_arch_pm_init();
 }
 
 static void spitz_charge_led(int val)
@@ -182,6 +183,10 @@ static int spitz_acin_status(void)
 
 struct sharpsl_charger_machinfo spitz_pm_machinfo = {
 	.init             = spitz_charger_init,
+	.remove		  = sharpsl_arch_pm_remove,
+	.read_main_battery= sharpsl_read_main_battery,
+	.read_temp	  = sharpsl_read_temp,
+	.read_acin	  = sharpsl_read_acin,
 	.gpio_batlock     = SPITZ_GPIO_BAT_COVER,
 	.gpio_acin        = SPITZ_GPIO_AC_IN,
 	.gpio_batfull     = SPITZ_GPIO_CHRG_FULL,
Signature · 1 line
Thanks, Sharp!
#1 lore raw
Quoted 5 lines · Pavel Machek

This splits sharpsl_pm.c into sharpsl_pm.c (generic code) and sharpsl_pm_pxa.c (spitz/corgi specific code). sharpsl_pm.c code should be reusable by collie.

I'd like to see it applied...

This diff looks much neater than the last one and I agree with the principle of it. I don't think its the right time to apply it for two reasons:

1. We probably shouldn't (can't?) make changes like this in -rc kernels
2. I would like to see some signs that battery measurement, charging and suspend/resume are all working on collie before we start applying patches to support it. Only once that's happened do we know how much common code we have and what changes are needed. Currently you only appear to have covered battery measurement?

I have a proposal for how we proceed with this:

After 2.6.15 is released, I envisage a patch which splits the common sections of sharpsl_pm.c into arm/common and arm/mach-pxa/sharpsl.h into include/arm/hardware/sharpsl_pm.h. I'm happy to generate that patch if necessary and pass it to Russell. I'll try and create a patch to show the structure I'm aiming for in the next couple of days but at the moment we don't know exactly which code is common and I'd prefer to try and do the split in one go.

In the meantime, creating the diffs like the last one show where the split needs to be and converting those diffs to the final file locations should be straightforward.

Waiting for 2.6.15 should also give you some time to get the collie charging and suspend/resume code developed/tested and then point 2 above will no longer apply.

I did note your patch adds a copyright header to a file you're mostly deleting code from?

Richard

#2 lore raw

Hi!

Quoted 8 lines
Quoted 1 line

I'd like to see it applied...

This diff looks much neater than the last one and I agree with the principle of it. I don't think its the right time to apply it for two reasons:

1. We probably shouldn't (can't?) make changes like this in -rc kernels

No, it does not really belong in -rc. I was hoping you would merge it in your tree so I do not have big patch here and could keep only collie changes...

Quoted 9 lines

I have a proposal for how we proceed with this:

After 2.6.15 is released, I envisage a patch which splits the common sections of sharpsl_pm.c into arm/common and arm/mach-pxa/sharpsl.h into include/arm/hardware/sharpsl_pm.h. I'm happy to generate that patch if necessary and pass it to Russell. I'll try and create a patch to show the structure I'm aiming for in the next couple of days but at the moment we don't know exactly which code is common and I'd prefer to try and do the split in one go.

Ok, works for me. So I'll now concentrate on getting collie working and leave infrastructure to you...

Quoted 2 lines

I did note your patch adds a copyright header to a file you're mostly deleting code from?

I actually did add some collie parts into it, and then deleted everything #ifdef collie from that. Sorry.
Pavel

Signature · 1 line
Thanks, Sharp!
#3 lore raw
Quoted 6 lines · Pavel Machek
Quoted 2 lines

1. We probably shouldn't (can't?) make changes like this in -rc kernels

No, it does not really belong in -rc. I was hoping you would merge it in your tree so I do not have big patch here and could keep only collie changes...

Right, I misunderstood that. I'll happily maintain an in progress version of that split-up patch in the Zaurus tree.

Quoted 10 lines
Quoted 9 lines

I have a proposal for how we proceed with this:

After 2.6.15 is released, I envisage a patch which splits the common sections of sharpsl_pm.c into arm/common and arm/mach-pxa/sharpsl.h into include/arm/hardware/sharpsl_pm.h. I'm happy to generate that patch if necessary and pass it to Russell. I'll try and create a patch to show the structure I'm aiming for in the next couple of days but at the moment we don't know exactly which code is common and I'd prefer to try and do the split in one go.

Quoted 2 lines

Ok, works for me. So I'll now concentrate on getting collie working and leave infrastructure to you...

Sounds good to me.

Richard

#4 lore raw

Hi!

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

1. We probably shouldn't (can't?) make changes like this in -rc kernels

No, it does not really belong in -rc. I was hoping you would merge it in your tree so I do not have big patch here and could keep only collie changes...

Right, I misunderstood that. I'll happily maintain an in progress version of that split-up patch in the Zaurus tree.

Yes, that would be great for me.
Pavel

Signature · 1 line
Thanks, Sharp!