Commit a0e34432 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Linus Torvalds

[PATCH] M68k update (part 2)

Mac/m68k ADB updates (from 2.4.x)
 - Add support for m68k Macs
 - Add missing call to VIA CUDA initialization routine
 - Update Mac II VIA support
 - Make local functions static and add their prototypes
 - Add missing defines for Mac/m68k PMUs
parent d045260c
...@@ -64,7 +64,7 @@ static struct adb_driver *adb_driver_list[] = { ...@@ -64,7 +64,7 @@ static struct adb_driver *adb_driver_list[] = {
#ifdef CONFIG_ADB_IOP #ifdef CONFIG_ADB_IOP
&adb_iop_driver, &adb_iop_driver,
#endif #endif
#ifdef CONFIG_ADB_PMU #if defined(CONFIG_ADB_PMU) || defined(CONFIG_ADB_PMU68K)
&via_pmu_driver, &via_pmu_driver,
#endif #endif
#ifdef CONFIG_ADB_MACIO #ifdef CONFIG_ADB_MACIO
...@@ -311,9 +311,11 @@ int __init adb_init(void) ...@@ -311,9 +311,11 @@ int __init adb_init(void)
#ifdef CONFIG_PMAC_PBOOK #ifdef CONFIG_PMAC_PBOOK
pmu_register_sleep_notifier(&adb_sleep_notifier); pmu_register_sleep_notifier(&adb_sleep_notifier);
#endif /* CONFIG_PMAC_PBOOK */ #endif /* CONFIG_PMAC_PBOOK */
#ifdef CONFIG_PPC
if (machine_is_compatible("AAPL,PowerBook1998") || if (machine_is_compatible("AAPL,PowerBook1998") ||
machine_is_compatible("PowerBook1,1")) machine_is_compatible("PowerBook1,1"))
sleepy_trackpad = 1; sleepy_trackpad = 1;
#endif /* CONFIG_PPC */
init_completion(&adb_probe_task_comp); init_completion(&adb_probe_task_comp);
adbdev_init(); adbdev_init();
adb_reset_bus(); adb_reset_bus();
......
...@@ -944,8 +944,10 @@ init_ms_a3(int id) ...@@ -944,8 +944,10 @@ init_ms_a3(int id)
static int __init adbhid_init(void) static int __init adbhid_init(void)
{ {
#ifndef CONFIG_MAC
if ( (_machine != _MACH_chrp) && (_machine != _MACH_Pmac) ) if ( (_machine != _MACH_chrp) && (_machine != _MACH_Pmac) )
return 0; return 0;
#endif
led_request.complete = 1; led_request.complete = 1;
......
...@@ -191,7 +191,9 @@ static int __init via_cuda_start(void) ...@@ -191,7 +191,9 @@ static int __init via_cuda_start(void)
if (via == NULL) if (via == NULL)
return -ENODEV; return -ENODEV;
#ifdef CONFIG_PPC
request_OF_resource(vias, 0, NULL); request_OF_resource(vias, 0, NULL);
#endif
if (request_irq(CUDA_IRQ, cuda_interrupt, 0, "ADB", cuda_interrupt)) { if (request_irq(CUDA_IRQ, cuda_interrupt, 0, "ADB", cuda_interrupt)) {
printk(KERN_ERR "cuda_init: can't get irq %d\n", CUDA_IRQ); printk(KERN_ERR "cuda_init: can't get irq %d\n", CUDA_IRQ);
...@@ -224,12 +226,19 @@ cuda_probe() ...@@ -224,12 +226,19 @@ cuda_probe()
static int __init static int __init
cuda_init(void) cuda_init(void)
{ {
#ifdef CONFIG_PPC
if (via == NULL) if (via == NULL)
return -ENODEV; return -ENODEV;
#ifndef CONFIG_PPC return 0;
#else
int err = cuda_init_via();
if (err) {
printk(KERN_ERR "cuda_init_via() failed\n");
return -ENODEV;
}
return via_cuda_start(); return via_cuda_start();
#endif #endif
return 0;
} }
#endif /* CONFIG_ADB */ #endif /* CONFIG_ADB */
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
* Rewrite for Unified ADB by Joshua M. Thompson (funaho@jurai.org) * Rewrite for Unified ADB by Joshua M. Thompson (funaho@jurai.org)
* *
* 1999-08-02 (jmt) - Initial rewrite for Unified ADB. * 1999-08-02 (jmt) - Initial rewrite for Unified ADB.
* 2000-03-29 Tony Mantler <tonym@mac.linux-m68k.org>
* - Big overhaul, should actually work now.
*/ */
#include <stdarg.h> #include <stdarg.h>
...@@ -98,7 +100,6 @@ struct adb_driver via_macii_driver = { ...@@ -98,7 +100,6 @@ struct adb_driver via_macii_driver = {
static enum macii_state { static enum macii_state {
idle, idle,
sent_first_byte,
sending, sending,
reading, reading,
read_done, read_done,
...@@ -133,7 +134,7 @@ static int macii_probe(void) ...@@ -133,7 +134,7 @@ static int macii_probe(void)
via = via1; via = via1;
printk("adb: Mac II ADB Driver v0.4 for Unified ADB\n"); printk("adb: Mac II ADB Driver v1.0 for Unified ADB\n");
return 0; return 0;
} }
...@@ -186,7 +187,7 @@ static void macii_queue_poll(void) ...@@ -186,7 +187,7 @@ static void macii_queue_poll(void)
static int in_poll=0; static int in_poll=0;
static struct adb_request req; static struct adb_request req;
unsigned long flags; unsigned long flags;
if (in_poll) printk("macii_queue_poll: double poll!\n"); if (in_poll) printk("macii_queue_poll: double poll!\n");
in_poll++; in_poll++;
...@@ -212,7 +213,7 @@ static void macii_retransmit(int device) ...@@ -212,7 +213,7 @@ static void macii_retransmit(int device)
static int in_retransmit = 0; static int in_retransmit = 0;
static struct adb_request rt; static struct adb_request rt;
unsigned long flags; unsigned long flags;
if (in_retransmit) printk("macii_retransmit: double retransmit!\n"); if (in_retransmit) printk("macii_retransmit: double retransmit!\n");
in_retransmit++; in_retransmit++;
...@@ -256,11 +257,11 @@ static int macii_write(struct adb_request *req) ...@@ -256,11 +257,11 @@ static int macii_write(struct adb_request *req)
{ {
unsigned long flags; unsigned long flags;
if (req->nbytes < 2 || req->data[0] != ADB_PACKET) { if (req->nbytes < 2 || req->data[0] != ADB_PACKET || req->nbytes > 15) {
req->complete = 1; req->complete = 1;
return -EINVAL; return -EINVAL;
} }
req->next = 0; req->next = 0;
req->sent = 0; req->sent = 0;
req->complete = 0; req->complete = 0;
...@@ -319,7 +320,7 @@ static void macii_start(void) ...@@ -319,7 +320,7 @@ static void macii_start(void)
req = current_req; req = current_req;
if (!req) return; if (!req) return;
/* assert macii_state == idle */ /* assert macii_state == idle */
if (macii_state != idle) { if (macii_state != idle) {
printk("macii_start: called while driver busy (%p %x %x)!\n", printk("macii_start: called while driver busy (%p %x %x)!\n",
...@@ -333,7 +334,9 @@ static void macii_start(void) ...@@ -333,7 +334,9 @@ static void macii_start(void)
* IRQ signaled ?? (means ADB controller wants to send, or might * IRQ signaled ?? (means ADB controller wants to send, or might
* be end of packet if we were reading) * be end of packet if we were reading)
*/ */
#if 0 /* FIXME: This is broke broke broke, for some reason */
if ((via[B] & TREQ) == 0) { if ((via[B] & TREQ) == 0) {
printk("macii_start: weird poll stuff. huh?\n");
/* /*
* FIXME - we need to restart this on a timer * FIXME - we need to restart this on a timer
* or a collision at boot hangs us. * or a collision at boot hangs us.
...@@ -359,6 +362,7 @@ static void macii_start(void) ...@@ -359,6 +362,7 @@ static void macii_start(void)
need_poll = 0; need_poll = 0;
} }
} }
#endif
/* /*
* Another retry pending? (sanity check) * Another retry pending? (sanity check)
*/ */
...@@ -368,7 +372,7 @@ static void macii_start(void) ...@@ -368,7 +372,7 @@ static void macii_start(void)
/* Now send it. Be careful though, that first byte of the request */ /* Now send it. Be careful though, that first byte of the request */
/* is actually ADB_PACKET; the real data begins at index 1! */ /* is actually ADB_PACKET; the real data begins at index 1! */
/* store command byte */ /* store command byte */
command_byte = req->data[1]; command_byte = req->data[1];
/* Output mode */ /* Output mode */
...@@ -378,7 +382,7 @@ static void macii_start(void) ...@@ -378,7 +382,7 @@ static void macii_start(void)
/* set ADB state to 'command' */ /* set ADB state to 'command' */
via[B] = (via[B] & ~ST_MASK) | ST_CMD; via[B] = (via[B] & ~ST_MASK) | ST_CMD;
macii_state = sent_first_byte; macii_state = sending;
data_index = 2; data_index = 2;
restore_flags(flags); restore_flags(flags);
...@@ -441,7 +445,7 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs) ...@@ -441,7 +445,7 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs)
reply_len = 1; reply_len = 1;
prefix_len = 1; prefix_len = 1;
reading_reply = 0; reading_reply = 0;
macii_state = reading; macii_state = reading;
break; break;
...@@ -461,15 +465,14 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs) ...@@ -461,15 +465,14 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs)
macii_state = reading; macii_state = reading;
break; break;
case sent_first_byte: case sending:
req = current_req; req = current_req;
/* maybe we're already done (Talk, or Poll)? */
if (data_index >= req->nbytes) { if (data_index >= req->nbytes) {
/* reset to shift in */ /* print an error message if a listen command has no data */
/* If it's a Listen command and we're done, someone's doing weird stuff. */
if (((command_byte & 0x0C) == 0x08) if (((command_byte & 0x0C) == 0x08)
&& (console_loglevel == 10)) /* && (console_loglevel == 10) */
printk("macii_interrupt: listen command with no data: %x!\n", && (data_index == 2))
printk("MacII ADB: listen command with no data: %x!\n",
command_byte); command_byte);
/* reset to shift in */ /* reset to shift in */
via[ACR] &= ~SR_OUT; via[ACR] &= ~SR_OUT;
...@@ -492,42 +495,15 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs) ...@@ -492,42 +495,15 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs)
macii_retransmit((command_byte & 0xF0) >> 4); macii_retransmit((command_byte & 0xF0) >> 4);
} }
} else { } else {
/* SR already set to shift out; send byte */ via[SR] = req->data[data_index++];
via[SR] = current_req->data[data_index++];
/* set state to ST_EVEN (first byte was: ST_CMD) */
via[B] = (via[B] & ~ST_MASK) | ST_EVEN;
macii_state = sending;
}
break;
case sending:
req = current_req;
if (data_index >= req->nbytes) {
/* reset to shift in */
via[ACR] &= ~SR_OUT;
x = via[SR];
/* set ADB state idle - might get SRQ */
via[B] = (via[B] & ~ST_MASK) | ST_IDLE;
req->sent = 1;
if (req->reply_expected) { if ( (via[B] & ST_MASK) == ST_CMD ) {
macii_state = awaiting_reply; /* just sent the command byte, set to EVEN */
via[B] = (via[B] & ~ST_MASK) | ST_EVEN;
} else { } else {
req->complete = 1; /* invert state bits, toggle ODD/EVEN */
current_req = req->next; via[B] ^= ST_MASK;
if (req->done) (*req->done)(req);
macii_state = idle;
if (current_req || retry_req)
macii_start();
else
macii_retransmit((command_byte & 0xF0) >> 4);
} }
} else {
via[SR] = req->data[data_index++];
/* invert state bits, toggle ODD/EVEN */
via[B] ^= ST_MASK;
} }
break; break;
...@@ -551,7 +527,7 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs) ...@@ -551,7 +527,7 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs)
* on /INT, meaning we missed it :-( * on /INT, meaning we missed it :-(
*/ */
x = via[SR]; x = via[SR];
if (x != 0xFF) printk("macii_interrupt: mistaken timeout/SRQ!\n"); if (x != 0xFF) printk("MacII ADB: mistaken timeout/SRQ!\n");
if ((status & TREQ) == (last_status & TREQ)) { if ((status & TREQ) == (last_status & TREQ)) {
/* Not a timeout. Unsolicited SRQ? weird. */ /* Not a timeout. Unsolicited SRQ? weird. */
...@@ -598,7 +574,7 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs) ...@@ -598,7 +574,7 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs)
* byte of timeout packet! * byte of timeout packet!
* Timeouts are signaled by 4x FF. * Timeouts are signaled by 4x FF.
*/ */
if (!(status & TREQ) && (x == 0x00)) { /* != 0xFF */ if (((status & TREQ) == 0) && (x == 0x00)) { /* != 0xFF */
/* invert state bits, toggle ODD/EVEN */ /* invert state bits, toggle ODD/EVEN */
via[B] ^= ST_MASK; via[B] ^= ST_MASK;
...@@ -646,12 +622,12 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs) ...@@ -646,12 +622,12 @@ void macii_interrupt(int irq, void *arg, struct pt_regs *regs)
need_poll = 0; need_poll = 0;
break; break;
} }
/* set ADB state to idle */
via[B] = (via[B] & ~ST_MASK) | ST_IDLE;
/* /IRQ seen, so the ADB controller has data for us */ /* /IRQ seen, so the ADB controller has data for us */
if (!(status & TREQ)) { if ((via[B] & TREQ) != 0) {
/* set ADB state to idle */
via[B] = (via[B] & ~ST_MASK) | ST_IDLE;
macii_state = reading; macii_state = reading;
reply_buf[0] = command_byte; reply_buf[0] = command_byte;
......
This diff is collapsed.
...@@ -120,6 +120,8 @@ static void pmu_done(struct adb_request *req); ...@@ -120,6 +120,8 @@ static void pmu_done(struct adb_request *req);
static void pmu_handle_data(unsigned char *data, int len, static void pmu_handle_data(unsigned char *data, int len,
struct pt_regs *regs); struct pt_regs *regs);
static void set_volume(int level); static void set_volume(int level);
static void pmu_enable_backlight(int on);
static void pmu_set_brightness(int level);
struct adb_driver via_pmu_driver = { struct adb_driver via_pmu_driver = {
"68K PMU", "68K PMU",
...@@ -746,7 +748,7 @@ int backlight_enabled = 0; ...@@ -746,7 +748,7 @@ int backlight_enabled = 0;
#define LEVEL_TO_BRIGHT(lev) ((lev) < 1? 0x7f: 0x4a - ((lev) << 1)) #define LEVEL_TO_BRIGHT(lev) ((lev) < 1? 0x7f: 0x4a - ((lev) << 1))
void static void
pmu_enable_backlight(int on) pmu_enable_backlight(int on)
{ {
struct adb_request req; struct adb_request req;
...@@ -780,7 +782,7 @@ pmu_enable_backlight(int on) ...@@ -780,7 +782,7 @@ pmu_enable_backlight(int on)
backlight_enabled = on; backlight_enabled = on;
} }
void static void
pmu_set_brightness(int level) pmu_set_brightness(int level)
{ {
int bright; int bright;
......
...@@ -75,6 +75,8 @@ enum { ...@@ -75,6 +75,8 @@ enum {
PMU_HEATHROW_BASED, /* PowerBook G3 series */ PMU_HEATHROW_BASED, /* PowerBook G3 series */
PMU_PADDINGTON_BASED, /* 1999 PowerBook G3 */ PMU_PADDINGTON_BASED, /* 1999 PowerBook G3 */
PMU_KEYLARGO_BASED, /* Core99 motherboard (PMU99) */ PMU_KEYLARGO_BASED, /* Core99 motherboard (PMU99) */
PMU_68K_V1, /* 68K PMU, version 1 */
PMU_68K_V2, /* 68K PMU, version 2 */
}; };
/* PMU PMU_POWER_EVENTS commands */ /* PMU PMU_POWER_EVENTS commands */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment