From: "Joseph P. Garcia" <jpgarcia@execpc.com>
To: linuxppc-dev@lists.linuxppc.org
Subject: 2.4 sleep power consumption patch; final buttons patch
Date: Thu, 16 Aug 2001 04:00:22 -0500 [thread overview]
Message-ID: <20010816040022.28de2b71.jpgarcia@execpc.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1128 bytes --]
Attached is a patch that addresses sleep-time fan activation on wallstreets, and probably other pre-UMA systems. The code existed in 2.2, and removed in 2.4 for some reason I am unaware of. The patch is the missing 2.2 code almost verbatim.
the gist:
- mediabay IOBUS_enable/disable at sleep (not sure if its related to the fan)
- sleep notification to control power of MESH SCSI chip's host (most likely cause)
This works on my system. This should be reviewed and merged at next convenience. If some system crashes in sleep from it, then just don't have it map mio_base for that system. Shouldn't affect pismo and later as they shouldn't have MESH.
Not sure about the mediabay mod tho. It was in 2.2. <shrug>
I wonder if Darwin forgot about MESH also.. OSX has the fan problem too.
=====
the second attachment is the volume/eject powerbook button NIL support posted a while ago, now in a final form. Since nobody has had any negative feedback or comments, that too can be merged. It doesn't break anything. I promise. Thanks to Bastien for helping out with this.
--
Joseph P. Garcia
http://www.lycestra.com/
[-- Attachment #2: sleepyfan.patch --]
[-- Type: application/octet-stream, Size: 4750 bytes --]
diff -ruP -X ../ignorediff linux-2.4.8-ben0-benh20010814.pre/drivers/macintosh/mediabay.c linux-2.4.8-ben0-benh20010814-JPG1/drivers/macintosh/mediabay.c
--- linux-2.4.8-ben0-benh20010814.pre/drivers/macintosh/mediabay.c Tue Aug 7 07:48:53 2001
+++ linux-2.4.8-ben0-benh20010814-JPG1/drivers/macintosh/mediabay.c Thu Aug 16 02:01:43 2001
@@ -599,6 +599,7 @@
bay = &media_bays[i];
set_mb_power(i, 0);
mdelay(10);
+ feature_clear(bay->dev_node, FEATURE_IOBUS_enable);
}
break;
case PBOOK_WAKE:
@@ -609,6 +610,7 @@
they seem to help the 3400 get it right.
*/
/* Force MB power to 0 */
+ feature_set(bay->dev_node, FEATURE_IOBUS_enable);
set_mb_power(i, 0);
mdelay(MB_POWER_DELAY);
if (!bay->pismo)
diff -ruP -X ../ignorediff linux-2.4.8-ben0-benh20010814.pre/drivers/scsi/mesh.c linux-2.4.8-ben0-benh20010814-JPG1/drivers/scsi/mesh.c
--- linux-2.4.8-ben0-benh20010814.pre/drivers/scsi/mesh.c Sat Aug 11 05:35:40 2001
+++ linux-2.4.8-ben0-benh20010814-JPG1/drivers/scsi/mesh.c Thu Aug 16 02:41:33 2001
@@ -29,6 +29,10 @@
#include <asm/hydra.h>
#include <asm/processor.h>
#include <asm/feature.h>
+#ifdef CONFIG_PMAC_PBOOK
+#include <linux/adb.h>
+#include <linux/pmu.h>
+#endif
#include "scsi.h"
#include "hosts.h"
@@ -122,6 +126,14 @@
#endif
};
+#ifdef CONFIG_PMAC_PBOOK
+static int mesh_notify_sleep(struct pmu_sleep_notifier *self, int when);
+static struct pmu_sleep_notifier mesh_sleep_notifier = {
+ mesh_notify_sleep,
+ SLEEP_LEVEL_BLOCK,
+};
+#endif
+
struct mesh_state {
volatile struct mesh_regs *mesh;
int meshintr;
@@ -151,6 +163,7 @@
struct mesh_target tgts[8];
void *dma_cmd_space;
struct device_node *ofnode;
+ unsigned char *mio_base;
#ifndef MESH_NEW_STYLE_EH
Scsi_Cmnd *completed_q;
Scsi_Cmnd *completed_qtail;
@@ -210,6 +223,7 @@
static void halt_dma(struct mesh_state *);
static int data_goes_out(Scsi_Cmnd *);
static void do_abort(struct mesh_state *ms);
+static void set_mesh_power(struct mesh_state *ms, int state);
static struct notifier_block mesh_notifier = {
mesh_notify_reboot,
@@ -309,9 +323,25 @@
if (mesh_sync_period < minper)
mesh_sync_period = minper;
- feature_set(mesh, FEATURE_MESH_enable);
- mdelay(200);
-
+#if 1
+ {
+ struct device_node *mio;
+ ms->mio_base = 0;
+ for (mio = ms->ofnode->parent; mio; mio = mio->parent)
+ if (strcmp(mio->name, "mac-io") == 0 && mio->n_addrs > 0)
+ break;
+ if (mio)
+ ms->mio_base = (unsigned char *)
+ ioremap(mio->addrs[0].address, 0x40);
+ }
+ if(ms->mio_base)
+ set_mesh_power(ms, 1);
+ else
+#endif
+ {
+ feature_set(mesh, FEATURE_MESH_enable);
+ mdelay(200);
+ }
mesh_init(ms);
if (request_irq(ms->meshintr, do_mesh_interrupt, 0, "MESH", ms)) {
@@ -321,8 +351,12 @@
++nmeshes;
}
- if ((_machine == _MACH_Pmac) && (nmeshes > 0))
+ if ((_machine == _MACH_Pmac) && (nmeshes > 0)){
+#ifdef CONFIG_PMAC_PBOOK
+ pmu_register_sleep_notifier(&mesh_sleep_notifier);
+#endif /* CONFIG_PMAC_PBOOK */
register_reboot_notifier(&mesh_notifier);
+ }
return nmeshes;
}
@@ -338,11 +372,70 @@
iounmap((void *) ms->mesh);
if (ms->dma)
iounmap((void *) ms->dma);
+ if (ms->mio_base)
+ iounmap((void *) ms->mio_base);
kfree(ms->dma_cmd_space);
free_irq(ms->meshintr, ms);
feature_clear(ms->ofnode, FEATURE_MESH_enable);
return 0;
}
+
+static void
+set_mesh_power(struct mesh_state *ms, int state)
+{
+ if (_machine != _MACH_Pmac || ms->mio_base == 0)
+ return;
+
+ if (state) {
+ feature_set(ms->ofnode, FEATURE_MESH_enable);
+ /* This seems to enable the termination power. strangely
+ this doesn't fully agree with OF, but with MacOS */
+ if (ms->mio_base)
+ out_8(ms->mio_base + 0x36, 0x70);
+ mdelay(200);
+ } else {
+ feature_clear(ms->ofnode, FEATURE_MESH_enable);
+ if (ms->mio_base)
+ out_8(ms->mio_base + 0x36, 0x34);
+ mdelay(10);
+ }
+}
+
+#ifdef CONFIG_PMAC_PBOOK
+/*
+ * notify clients before sleep and reset bus afterwards
+ */
+int
+mesh_notify_sleep(struct pmu_sleep_notifier *self, int when)
+{
+ struct mesh_state *ms;
+
+ switch (when) {
+ case PBOOK_SLEEP_REQUEST:
+ /* XXX We should wait for current transactions and queue
+ * new ones that would be posted beyond this point
+ */
+ break;
+ case PBOOK_SLEEP_REJECT:
+ break;
+
+ case PBOOK_SLEEP_NOW:
+ for (ms = all_meshes; ms != 0; ms = ms->next) {
+ disable_irq(ms->meshintr);
+ set_mesh_power(ms, 0);
+ }
+ break;
+ case PBOOK_WAKE:
+ for (ms = all_meshes; ms != 0; ms = ms->next) {
+ set_mesh_power(ms, 1);
+ mesh_init(ms);
+ enable_irq(ms->meshintr);
+ }
+ break;
+ }
+ return PBOOK_SLEEP_OK;
+}
+#endif /* CONFIG_PMAC_PBOOK */
int
mesh_queue(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
[-- Attachment #3: vol-eject.patch --]
[-- Type: application/octet-stream, Size: 5403 bytes --]
diff -ruP -X ../ignorediff linux-2.4.7-ben0-benh20010729.orij/drivers/macintosh/adbhid.c linux-2.4.7-ben0-benh20010729-buttons/drivers/macintosh/adbhid.c
--- linux-2.4.7-ben0-benh20010729.orij/drivers/macintosh/adbhid.c Thu Jul 26 15:19:01 2001
+++ linux-2.4.7-ben0-benh20010729-buttons/drivers/macintosh/adbhid.c Sun Jul 29 22:40:32 2001
@@ -275,22 +275,28 @@
{
#ifdef CONFIG_PMAC_BACKLIGHT
int backlight = get_backlight_level();
-
+#endif
/*
* XXX: Where is the contrast control for the passive?
* -- Cort
*/
- switch (data[1]) {
+ switch (data[1]&0xf) {
case 0x8: /* mute */
+ input_report_key(&adbhid[id]->input, KEY_MUTE, data[1] == (data[1] & 0xf));
break;
- case 0x7: /* contrast decrease */
+ case 0x7: /* volume decrease */
+ input_report_key(&adbhid[id]->input, KEY_VOLUMEDOWN, data[1] == (data[1] & 0xf));
break;
- case 0x6: /* contrast increase */
+ case 0x6: /* volume increase */
+ input_report_key(&adbhid[id]->input, KEY_VOLUMEUP, data[1] == (data[1] & 0xf));
break;
-
+ case 0xb: /* eject */
+ input_report_key(&adbhid[id]->input, KEY_EJECTCD, data[1] == (data[1] & 0xf));
+ break;
+#ifdef CONFIG_PMAC_BACKLIGHT
case 0xa: /* brightness decrease */
if (backlight < 0)
break;
@@ -308,8 +314,8 @@
else
set_backlight_level(BACKLIGHT_MAX);
break;
+#endif
}
-#endif /* CONFIG_PMAC_BACKLIGHT */
}
break;
}
@@ -504,6 +510,11 @@
case 0x1f: /* Powerbook button device */
sprintf(adbhid[id]->name, "ADB Powerbook buttons on ID %d:%d.%02x",
id, default_id, original_handler_id);
+ adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+ set_bit(KEY_MUTE, adbhid[id]->input.keybit);
+ set_bit(KEY_VOLUMEUP, adbhid[id]->input.keybit);
+ set_bit(KEY_VOLUMEDOWN, adbhid[id]->input.keybit);
+ set_bit(KEY_EJECTCD, adbhid[id]->input.keybit);
break;
}
if (adbhid[id]->name[0])
@@ -541,17 +552,35 @@
adbhid[id] = 0;
}
+static u16
+adbhid_input_reregister(int id, int default_id, int org_handler_id,
+ int cur_handler_id, int mk)
+{
+ if(adbhid[id]){
+ if(adbhid[id]->input.idproduct!=((id << 12)|(default_id << 8)|org_handler_id)){
+ adbhid_input_unregister(id);
+ adbhid_input_register(id, default_id, org_handler_id, cur_handler_id, mk);
+ }
+ }else
+ adbhid_input_register(id, default_id, org_handler_id, cur_handler_id, mk);
+ return 1<<id;
+}
+
+static void
+adbhid_input_devcleanup(u16 exist)
+{
+ int i;
+ for(i=1;i<16;i++)
+ if(adbhid[i]&&!(exist&(1<<i)))
+ adbhid_input_unregister(i);
+}
static void
adbhid_probe(void)
{
struct adb_request req;
int i, default_id, org_handler_id, cur_handler_id;
-
- for (i = 1; i < 16; i++) {
- if (adbhid[i])
- adbhid_input_unregister(i);
- }
+ u16 reg=0;
adb_register(ADB_MOUSE, 0, &mouse_ids, adbhid_mouse_input);
adb_register(ADB_KEYBOARD, 0, &keyboard_ids, adbhid_keyboard_input);
@@ -580,14 +609,14 @@
printk("ADB keyboard at %d, handler 1\n", id);
adb_get_infos(id, &default_id, &cur_handler_id);
- adbhid_input_register(id, default_id, org_handler_id, cur_handler_id, 0);
+ reg|=adbhid_input_reregister(id, default_id, org_handler_id, cur_handler_id, 0);
}
for (i = 0; i < buttons_ids.nids; i++) {
int id = buttons_ids.id[i];
adb_get_infos(id, &default_id, &org_handler_id);
- adbhid_input_register(id, default_id, org_handler_id, org_handler_id, 0);
+ reg|=adbhid_input_reregister(id, default_id, org_handler_id, org_handler_id, 0);
}
/* Try to switch all mice to handler 4, or 2 for three-button
@@ -676,9 +705,10 @@
printk("\n");
adb_get_infos(id, &default_id, &cur_handler_id);
- adbhid_input_register(id, default_id, org_handler_id,
+ reg|=adbhid_input_reregister(id, default_id, org_handler_id,
cur_handler_id, mouse_kind);
}
+ adbhid_input_devcleanup(reg);
}
static void
diff -ruP -X ../ignorediff linux-2.4.7-ben0-benh20010729.orij/drivers/macintosh/mac_hid.c linux-2.4.7-ben0-benh20010729-buttons/drivers/macintosh/mac_hid.c
--- linux-2.4.7-ben0-benh20010729.orij/drivers/macintosh/mac_hid.c Thu Jun 28 09:29:50 2001
+++ linux-2.4.7-ben0-benh20010729-buttons/drivers/macintosh/mac_hid.c Sun Jul 29 18:11:40 2001
@@ -200,15 +200,15 @@
0, 0, 0, KEY_KPCOMMA, 0, KEY_INTL3, 0, 0, /* 0x00-0x07 */
0, 0, 0, 0, KEY_LANG1, KEY_LANG2, 0, 0, /* 0x08-0x0f */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */
- 0, 0, 0, 0, KEY_KPENTER, KEY_RIGHTCTRL, 0, 0, /* 0x18-0x1f */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */
+ 0, 0, 0, 0, KEY_KPENTER, KEY_RIGHTCTRL, KEY_VOLUMEUP, 0, /* 0x18-0x1f */
+ 0, 0, 0, 0, 0, KEY_VOLUMEDOWN, KEY_MUTE, 0, /* 0x20-0x27 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */
0, 0, 0, 0, 0, KEY_KPSLASH, 0, KEY_SYSRQ, /* 0x30-0x37 */
- KEY_RIGHTALT, 0, 0, 0, 0, 0, 0, 0, /* 0x38-0x3f */
+ KEY_RIGHTALT, 0, 0, KEY_EJECTCD, 0, 0, 0, 0, /* 0x38-0x3f */
0, 0, 0, 0, 0, 0, 0, KEY_HOME, /* 0x40-0x47 */
KEY_UP, KEY_PAGEUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END, /* 0x48-0x4f */
KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0, 0, 0, 0, /* 0x50-0x57 */
- 0, 0, 0, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_COMPOSE, 0, 0, /* 0x58-0x5f */
+ 0, 0, 0, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_COMPOSE, KEY_POWER, 0, /* 0x58-0x5f */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */
0, 0, 0, 0, 0, 0, 0, KEY_MACRO, /* 0x68-0x6f */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */
next reply other threads:[~2001-08-16 9:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-16 9:00 Joseph P. Garcia [this message]
2001-08-16 9:43 ` 2.4 sleep power consumption patch; final buttons patch Benjamin Herrenschmidt
2001-08-16 16:23 ` Joseph P. Garcia
2001-08-17 20:19 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010816040022.28de2b71.jpgarcia@execpc.com \
--to=jpgarcia@execpc.com \
--cc=linuxppc-dev@lists.linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).