Skip to contentSkip to conversation

ppc4xx_pm.c

RFC/Patch akuster 2 participants 5 messages Jul 23, 2002 – Jul 27, 2002

Subsystems (2)
lore
Share & tools
lore

akuster

author
#0 lore raw

I am in the process of fixing the init of the pm for 4xx in ppc4xx_pm.c so that it can be used and I and others have discussed having the drivers enable/disable their own power managment bits at init & exit times.

So what I would like to do is have each core header define a default set of what is required to be powered on and then have each driver enable them selves. These changes would be done in two stages

1) fix ppc4xx_pm.c init and have the default pm bitmap set to all ocp drivers on.

2) update ocp drivers to enable/disable their pm settings and remove their enable bits from the default bitmap in the core headers.

armin

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

author
#1 lore raw
Quoted 11 lines · akuster

I am in the process of fixing the init of the pm for 4xx in ppc4xx_pm.c so that it can be used and I and others have discussed having the drivers enable/disable their own power managment bits at init & exit times.

So what I would like to do is have each core header define a default set of what is required to be powered on and then have each driver enable them selves. These changes would be done in two stages

1) fix ppc4xx_pm.c init and have the default pm bitmap set to all ocp drivers on.

These patches are the changes to the core header files and for ppc4xx_pm.c.

Please _note_ that if you enable the Power Managment in the config
that most kernels might hang if you use an ocp device since the drivers are not updated yet. :)

If no one has an objection, then I will get it submitted

armin

author
#2 lore raw
In reply to akuster
Quoted 9 lines · akuster

I am in the process of fixing the init of the pm for 4xx in ppc4xx_pm.c so that it can be used and I and others have discussed having the drivers enable/disable their own power managment bits at init & exit times.

2) update ocp drivers to enable/disable their pm settings and remove their enable bits from the default bitmap in the core headers.

Here are the ocp driver changes to help support enabling/disabling the device clock. currently these wount work on the 440 until a soon to follow on 440 patch is checked in

armin

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux 2.4 for PowerPC development tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1096 -> 1.1097
# drivers/net/ibm_ocp/ibm_ocp_enet.c 1.53 -> 1.54
# drivers/net/ibm_ocp/ibm_ocp_enet.h 1.29 -> 1.30
# drivers/i2c/i2c-adap-ibm_ocp.c 1.9 -> 1.10
# drivers/char/ibm_ocp_gpio.c 1.13 -> 1.14
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/07/26 [email protected] 1.1097

# udated drivers for CPM support
# --------------------------------------------
#
diff -Nru a/drivers/char/ibm_ocp_gpio.c b/drivers/char/ibm_ocp_gpio.c
--- a/drivers/char/ibm_ocp_gpio.c	Fri Jul 26 10:04:10 2002
+++ b/drivers/char/ibm_ocp_gpio.c	Fri Jul 26 10:04:10 2002
@@ -58,9 +58,12 @@
  *	an accessible area.  Add ioctl to configure
  *	multiplexed GPIO pins.
  *
+ *	1.7 07/25/02 - Armin
+ *	added CPM to enable/disable in init/exit
+ *
  */

-#define VUFX "06.04.02"
+#define VUFX "07.25.02"

#include <linux/module.h>
#include <linux/config.h>
@@ -283,7 +286,7 @@
return -EFAULT;

return ibm_gpio_config(ioctl_data.device,
- ioctl_data.mask, ioctl_data.data);
+ ioctl_data.mask, ioctl_data.data);

break;

@@ -322,7 +325,12 @@
ibm_gpio_miscdev.fops = &ibm_gpio_fops;
misc_register(&ibm_gpio_miscdev); /*ibm_gpio_miscdev); */

- gpiop = (struct gpio_regs *)ioremap(gpio_dev->paddr, sizeof(struct gpio_regs));
+ gpiop =
+ (struct gpio_regs *) ioremap(gpio_dev->paddr,
+ sizeof (struct
+ gpio_regs));
+ mtdcr(DCRN_CPMFR,
+ mfdcr(DCRN_CPMFR) & ~ocp_get_pm(GPIO, curr_gpio));
printk("GPIO #%d at 0x%lx\n", curr_gpio,
(unsigned long) gpiop);

@@ -341,6 +349,7 @@
for (i = 0; i < ocp_get_max(GPIO); i++) {
gpio_dev = ocp_get_dev(GPIO, i); misc_deregister(&ibm_gpio_miscdev);
+ mtdcr(DCRN_CPMFR, mfdcr(DCRN_CPMFR) | ocp_get_pm(GPIO, i));
ocp_unregister(gpio_dev);
}
}

drivers/i2c/i2c-adap-ibm_ocp.c +5 -0
diff -Nru a/drivers/i2c/i2c-adap-ibm_ocp.c b/drivers/i2c/i2c-adap-ibm_ocp.c
@@ -66,6 +66,9 @@
     Version: 1.9 - Armin
        changed irq_resource to just irq
 
+    Version: 2.0 - Armin
+    	added CPM enable/disable in init/exit
+
    TODO: add PM hooks
 
 */
@@ -269,6 +272,7 @@
 			adap->dec_use = iic_ibmocp_dec_use;
 			adap->client_register = iic_ibmocp_reg;
 			adap->client_unregister = iic_ibmocp_unreg;
+			mtdcr(DCRN_CPMFR, mfdcr(DCRN_CPMFR) & ~ocp_get_pm(IIC, curr_iic));
 
 			init_waitqueue_head(&(iic_wait[curr_iic]));
 
@@ -312,6 +316,7 @@
 		iic_drv = ocp_get_dev(IIC, i);
 		adap = (struct i2c_adapter *) iic_drv->ocpdev;
 		i2c_iic_del_bus(adap);
+		mtdcr(DCRN_CPMFR, mfdcr(DCRN_CPMFR) | ocp_get_pm(IIC, i));
 	}
 
 	iic_ibmocp_release();
drivers/net/ibm_ocp/ibm_ocp_enet.c +17 -0
diff -Nru a/drivers/net/ibm_ocp/ibm_ocp_enet.c b/drivers/net/ibm_ocp/ibm_ocp_enet.c
@@ -167,6 +167,8 @@
  *      removed need for irq_resource
  *	removed need for loop in request & free irq
  *	changed interrupt handles to static
+ *	 Version 4.7 07/25/02 - Armin
+ *	    added CPM enable/diable in init/exit
  *
  */
 #include <linux/module.h>
@@ -619,6 +621,10 @@
 	rx_virt_addr = (mal_desc_t *)
 	    consistent_alloc(GFP_KERNEL, PAGE_SIZE * emac_max, &rx_phys_addr);
 	for (curr_emac = 0; curr_emac < emac_max; curr_emac++) {
+		if(ocp_get_pm(EMAC, curr_emac)){
+			mtdcr(DCRN_CPMFR,
+			      mfdcr(DCRN_CPMFR) & ~IBM_CPM_EMAC(ocp_get_pm(EMAC, curr_emac)));
+		}
 		ocp_enet_probe(curr_emac);
 	}
 
@@ -1193,6 +1199,17 @@
 static void __exit
 exit_ppc405_enet(void)
 {
+	int i;
+	struct ocp_dev *emac_dev;
+
+	for (i = 0; i < ocp_get_max(EMAC); i++) {
+		emac_dev = ocp_get_dev(EMAC, i);
+		if(ocp_get_pm(EMAC, i)){
+			mtdcr(DCRN_CPMFR, mfdcr(DCRN_CPMFR) | IBM_CPM_EMAC(ocp_get_pm(EMAC, i)));
+			ocp_unregister(emac_dev);
+		}
+	}
+
 	/*
 	 * Unmap the non cached memory space.
 	 */
drivers/net/ibm_ocp/ibm_ocp_enet.h +5 -0
diff -Nru a/drivers/net/ibm_ocp/ibm_ocp_enet.h b/drivers/net/ibm_ocp/ibm_ocp_enet.h
@@ -93,6 +93,11 @@
 #define MDIO_DELAY		2
 #define NMII				20
 
+/* Power managment shift registers */
+#define IBM_CPM_EMMII	0	/* Shift value for MII */
+#define IBM_CPM_EMRX	1	/* Shift value for recv */
+#define IBM_CPM_EMTX	2	/* Shift value for MAC */
+#define IBM_CPM_EMAC(x)	(((x)<<IBM_CPM_EMMII) | ((x)<<IBM_CPM_EMRX) | ((x)<<IBM_CPM_EMTX))
 
 #ifdef CONFIG_IBM_OCP_ENET_ERROR_MSG
 void ppc405_serr_dump_0(struct net_device *dev);
#3 lore raw
Quoted 16 lines

+++ b/drivers/net/ibm_ocp/ibm_ocp_enet.c

drivers/net/ibm_ocp/ibm_ocp_enet.c +5 -0
 	for (curr_emac = 0; curr_emac < emac_max; curr_emac++) {
+		if(ocp_get_pm(EMAC, curr_emac)){
+			mtdcr(DCRN_CPMFR,
+			      mfdcr(DCRN_CPMFR) & ~IBM_CPM_EMAC(ocp_get_pm(EMAC, curr_emac)));
+		}
 		ocp_enet_probe(curr_emac);
 	}
@@ -1193,6 +1199,17 @@
 static void __exit
 exit_ppc405_enet(void)
 {
+	int i;

drivers/net/ibm_ocp/ibm_ocp_enet.c line 1212

Quoted 10 lines
drivers/net/ibm_ocp/ibm_ocp_enet.c +10 -0
+	struct ocp_dev *emac_dev;
+
+	for (i = 0; i < ocp_get_max(EMAC); i++) {
+		emac_dev = ocp_get_dev(EMAC, i);
+		if(ocp_get_pm(EMAC, i)){
+			mtdcr(DCRN_CPMFR, mfdcr(DCRN_CPMFR) | IBM_CPM_EMAC(ocp_get_pm(EMAC, i)));
+			ocp_unregister(emac_dev);
+		}
+	}
+

(1) Also do CPM on/off at open/close hooks, so that closed EMACs are powered down and powered back up when re-opened?

(2) Move ocp_unregister() call outside "if(ocp_get_pm()" test.

--
Todd

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

author
#4 lore raw
Quoted 24 lines · Todd Poynor
Quoted 24 lines

+++ b/drivers/net/ibm_ocp/ibm_ocp_enet.c

     for (curr_emac = 0; curr_emac < emac_max; curr_emac++) {
drivers/net/ibm_ocp/ibm_ocp_enet.c +3 -0
+        if(ocp_get_pm(EMAC, curr_emac)){
+            mtdcr(DCRN_CPMFR,
+                  mfdcr(DCRN_CPMFR) & ~IBM_CPM_EMAC(ocp_get_pm(EMAC,

curr_emac)));

drivers/net/ibm_ocp/ibm_ocp_enet.c +8 -0
+        }
         ocp_enet_probe(curr_emac);
     }
@@ -1193,6 +1199,17 @@
 static void __exit
 exit_ppc405_enet(void)
 {
+    int i;
+    struct ocp_dev *emac_dev;
+
+    for (i = 0; i < ocp_get_max(EMAC); i++) {
+        emac_dev = ocp_get_dev(EMAC, i);
+        if(ocp_get_pm(EMAC, i)){
+            mtdcr(DCRN_CPMFR, mfdcr(DCRN_CPMFR) |
 IBM_CPM_EMAC(ocp_get_pm(EMAC, i)));
Quoted 8 lines

drivers/net/ibm_ocp/ibm_ocp_enet.c line 1212

Quoted 4 lines
drivers/net/ibm_ocp/ibm_ocp_enet.c +4 -0
+            ocp_unregister(emac_dev);
+        }
+    }
+

(1) Also do CPM on/off at open/close hooks, so that closed EMACs are powered down and powered back up when re-opened?

This idea should be applied to all ocp drivers. I am not sure if forcing (CPMFR) it the best method @ open/close or requesting/enabling power down (CPMER). mmm... gota think about :)

Quoted 2 lines

(2) Move ocp_unregister() call outside "if(ocp_get_pm()" test.

Thanks

Quoted 2 lines

Armin

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/