patch-2.2.8 linux/drivers/macintosh/via-cuda.c
Next file: linux/drivers/macintosh/via-pmu.c
Previous file: linux/drivers/macintosh/nvram.c
Back to the patch index
Back to the overall index
- Lines: 142
- Date:
Thu Apr 29 12:53:48 1999
- Orig file:
v2.2.7/linux/drivers/macintosh/via-cuda.c
- Orig date:
Thu Nov 19 09:56:28 1998
diff -u --recursive --new-file v2.2.7/linux/drivers/macintosh/via-cuda.c linux/drivers/macintosh/via-cuda.c
@@ -74,6 +74,7 @@
static int reading_reply;
static int data_index;
static struct device_node *vias;
+static int cuda_fully_inited = 0;
static int init_via(void);
static void cuda_start(void);
@@ -81,7 +82,17 @@
static void cuda_input(unsigned char *buf, int nb, struct pt_regs *regs);
static int cuda_adb_send_request(struct adb_request *req, int sync);
static int cuda_adb_autopoll(int devs);
-static int cuda_reset_bus(void);
+static int cuda_adb_reset_bus(void);
+static int cuda_send_request(struct adb_request *req);
+
+
+static struct adb_controller cuda_controller = {
+ ADB_VIACUDA,
+ cuda_adb_send_request,
+ cuda_adb_autopoll,
+ cuda_adb_reset_bus,
+ cuda_poll
+};
__openfirmware
@@ -121,7 +132,7 @@
via = NULL;
}
- adb_hardware = ADB_VIACUDA;
+ adb_controller = &cuda_controller;
}
void
@@ -139,10 +150,7 @@
via[IFR] = 0x7f; eieio(); /* clear interrupts by writing 1s */
via[IER] = IER_SET|SR_INT; eieio(); /* enable interrupt from SR */
- /* Set function pointers */
- adb_send_request = cuda_adb_send_request;
- adb_autopoll = cuda_adb_autopoll;
- adb_reset_bus = cuda_reset_bus;
+ cuda_fully_inited = 1;
}
#define WAIT_FOR(cond, what) \
@@ -201,14 +209,17 @@
{
int i;
- for (i = req->nbytes; i > 0; --i)
- req->data[i] = req->data[i-1];
- req->data[0] = ADB_PACKET;
- ++req->nbytes;
+ if ((via == NULL) || !cuda_fully_inited) {
+ req->complete = 1;
+ return -ENXIO;
+ }
+
req->reply_expected = 1;
+
i = cuda_send_request(req);
if (i)
return i;
+
if (sync) {
while (!req->complete)
cuda_poll();
@@ -216,12 +227,16 @@
return 0;
}
+
/* Enable/disable autopolling */
static int
cuda_adb_autopoll(int devs)
{
struct adb_request req;
+ if ((via == NULL) || !cuda_fully_inited)
+ return -ENXIO;
+
cuda_request(&req, NULL, 3, CUDA_PACKET, CUDA_AUTOPOLL, (devs? 1: 0));
while (!req.complete)
cuda_poll();
@@ -230,10 +245,13 @@
/* Reset adb bus - how do we do this?? */
static int
-cuda_reset_bus(void)
+cuda_adb_reset_bus(void)
{
struct adb_request req;
+ if ((via == NULL) || !cuda_fully_inited)
+ return -ENXIO;
+
cuda_request(&req, NULL, 2, ADB_PACKET, 0); /* maybe? */
while (!req.complete)
cuda_poll();
@@ -248,6 +266,11 @@
va_list list;
int i;
+ if (via == NULL) {
+ req->complete = 1;
+ return -ENXIO;
+ }
+
req->nbytes = nbytes;
req->done = done;
va_start(list, nbytes);
@@ -258,15 +281,11 @@
return cuda_send_request(req);
}
-int
+static int
cuda_send_request(struct adb_request *req)
{
unsigned long flags;
- if (via == NULL) {
- req->complete = 1;
- return -ENXIO;
- }
if (req->nbytes < 2 || req->data[0] > CUDA_PACKET) {
req->complete = 1;
return -EINVAL;
@@ -472,3 +491,9 @@
printk("\n");
}
}
+
+int
+cuda_present(void)
+{
+ return (adb_controller && (adb_controller->kind == ADB_VIACUDA) && via);
+}
\ No newline at end of file
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)