linux/drivers/macintosh/adb-iop.c
<<
>>
Prefs
   1/*
   2 * I/O Processor (IOP) ADB Driver
   3 * Written and (C) 1999 by Joshua M. Thompson (funaho@jurai.org)
   4 * Based on via-cuda.c by Paul Mackerras.
   5 *
   6 * 1999-07-01 (jmt) - First implementation for new driver architecture.
   7 *
   8 * 1999-07-31 (jmt) - First working version.
   9 *
  10 * TODO:
  11 *
  12 * o Implement SRQ handling.
  13 */
  14
  15#include <linux/types.h>
  16#include <linux/kernel.h>
  17#include <linux/mm.h>
  18#include <linux/delay.h>
  19#include <linux/init.h>
  20#include <linux/proc_fs.h>
  21
  22#include <asm/macintosh.h> 
  23#include <asm/macints.h> 
  24#include <asm/mac_iop.h>
  25#include <asm/mac_oss.h>
  26#include <asm/adb_iop.h>
  27
  28#include <linux/adb.h> 
  29
  30/*#define DEBUG_ADB_IOP*/
  31
  32extern void iop_ism_irq(int, void *);
  33
  34static struct adb_request *current_req;
  35static struct adb_request *last_req;
  36#if 0
  37static unsigned char reply_buff[16];
  38static unsigned char *reply_ptr;
  39#endif
  40
  41static enum adb_iop_state {
  42    idle,
  43    sending,
  44    awaiting_reply
  45} adb_iop_state;
  46
  47static void adb_iop_start(void);
  48static int adb_iop_probe(void);
  49static int adb_iop_init(void);
  50static int adb_iop_send_request(struct adb_request *, int);
  51static int adb_iop_write(struct adb_request *);
  52static int adb_iop_autopoll(int);
  53static void adb_iop_poll(void);
  54static int adb_iop_reset_bus(void);
  55
  56struct adb_driver adb_iop_driver = {
  57        "ISM IOP",
  58        adb_iop_probe,
  59        adb_iop_init,
  60        adb_iop_send_request,
  61        adb_iop_autopoll,
  62        adb_iop_poll,
  63        adb_iop_reset_bus
  64};
  65
  66static void adb_iop_end_req(struct adb_request *req, int state)
  67{
  68        req->complete = 1;
  69        current_req = req->next;
  70        if (req->done) (*req->done)(req);
  71        adb_iop_state = state;
  72}
  73
  74/*
  75 * Completion routine for ADB commands sent to the IOP.
  76 *
  77 * This will be called when a packet has been successfully sent.
  78 */
  79
  80static void adb_iop_complete(struct iop_msg *msg)
  81{
  82        struct adb_request *req;
  83        unsigned long flags;
  84
  85        local_irq_save(flags);
  86
  87        req = current_req;
  88        if ((adb_iop_state == sending) && req && req->reply_expected) {
  89                adb_iop_state = awaiting_reply;
  90        }
  91
  92        local_irq_restore(flags);
  93}
  94
  95/*
  96 * Listen for ADB messages from the IOP.
  97 *
  98 * This will be called when unsolicited messages (usually replies to TALK
  99 * commands or autopoll packets) are received.
 100 */
 101
 102static void adb_iop_listen(struct iop_msg *msg)
 103{
 104        struct adb_iopmsg *amsg = (struct adb_iopmsg *) msg->message;
 105        struct adb_request *req;
 106        unsigned long flags;
 107#ifdef DEBUG_ADB_IOP
 108        int i;
 109#endif
 110
 111        local_irq_save(flags);
 112
 113        req = current_req;
 114
 115#ifdef DEBUG_ADB_IOP
 116        printk("adb_iop_listen %p: rcvd packet, %d bytes: %02X %02X", req,
 117                (uint) amsg->count + 2, (uint) amsg->flags, (uint) amsg->cmd);
 118        for (i = 0; i < amsg->count; i++)
 119                printk(" %02X", (uint) amsg->data[i]);
 120        printk("\n");
 121#endif
 122
 123        /* Handle a timeout. Timeout packets seem to occur even after */
 124        /* we've gotten a valid reply to a TALK, so I'm assuming tgat */
msg->>

printk1nb_requelas-of-ref=driversdef al.rs/macintosh/a/macintosh/adb-iop.c#L88" id="L88" c};p: rcvd include/asm-blackfin/adb1_iop.126acintosh/a href="drivers/macintos1iI_We ne->12      ) 
<12"sref">uintamsg->cmd);
(<_TIMEOUTef">cmd);
(<_TIMEOUTf">adb_iop_state =   31<1/a>
<130sref">uint)  105        struct cmd);
(<_TIMEOUTf">a |a href="drivers/k(<_AUTOPOLLef">cmd);
(<_AUTOPOLLlass="line" name="L115"> 115#ifdef iop131sref">uint)  105        struct  115#ifdef uint)  105        struct  115#ifdef   14<
uint) done)(req && sending,
 = current_req;
uint) ) s href="+code=uint" class="sref">uint)a href="drivers/sref">sending,
 115#ifdef ;
uint)   95 =  * + 2, (uint) rie orierf="drivs do. hs/macintosh/a/macintosh/adb-iop.c#L88" id="L88" cf="+code=1adb_iop_state" class="sr1ef">a140sref">uint) req && req->replysh/a/macintosh/adb-iop.c#L88" id="L88" cf="+code=1#L42" id="L42" class="li1ne" n141sref">uint) amsg->cmd);
(<_EXPLICITef">cmd);
(<_EXPLICITref=)db_iop_state =   43    1uint) )   89                        }
amsg->flags, ( = re14" class=1"line" name="L44">  44   143sref">uint) ) s href="+code=uint" class="sref">uint  struct  118        for (i = 0; uint 89                 115#ifdef uint)  =  145sref">uint) ) s-iop.s="line" name="L118"> 118        for (i = 0; amsg->flags, (amsga146sref">uint) ) ) amsg->cmd);
(<_AUTOPOLLef">cmd);
(<_AUTOPOLLlass)c"line" name="L115"> 115#ifdef ->  95s href="+code=uiame="L105"> 105        struct  105        struct adb(<_MSG_LENlass)c"line" name="L115"> 115#ifdef uint  95a1db_re15 id="L121" class="line" nameiop.c#L81" i_ode=adb_request" classiop.c#L81" i_ode=adbef">s href="+code=uiame="L105"> 105      )c"line" name="L115"> 115#ifdef adb_request1 *);
15sh/adb-iop.c#L112" id="L112" class="li="line" name="L93">  93}
  94
  74
adb_1drive15"line" name="L76">  761nb>

 = {
  518158" class="line" name="L78">  78>t much id=do orierfrivn rs/m>rie  */
 100(adb_iop_q_save(  63_iop_state =   84
  85        adb_iopmsg *)name="L106"> 106        unsigned long flags;
amsg->;
        printk("adb_iop_listen +code=req1" class="sref">req-&1gt;count + vers/macintosh/adb-iop.c#L110" id="L110" class="line" name="L110"> 110
 = 1;
 123        ->1;req<1a>->state1;
 114
 115#ifdef uint 114) return="line" name="L115"> 115#ifdef 
  751 * 174/adb-iop.c#L72" id="L72" cl class="line" name="L112"> 112
 113        (struct   771 * 17="sref">        printk("adb_iop_listen "drivers/1macintosh/adb-iop.c#L78"1 id="17p.c#L88" id="L88" class="linf="+code=req" class="sref">req,
" class="line" name="            (uint)"line" name="L70">  70        if (        sname=class="line" name="L113"> 113        
count; i++)
  70        if (        sname=clas code=i" class="sref">i++)
(" %02X&f="+code=1adb_iop_complete" class=1"sref17"sref">uint) amsg->data[i]);
 20        printk("\n");
op_msg" c1lass="sref">iop_msg 1* 121#endif
 122
 123        req;
Tmacint iakes MacII-sty hss="commc}hloca18op.c#L12yef">msg->ialb>
<_PACKET name.a/macintosh/a/macintosh/adb-iop.c#L88" id="L88" ccacintosh1);
req = 1, amsg->cmd);
(<_EXPLICITef">cmd);
(<_EXPLICITref= class="line" name="L122"> 122
amsg->flags, (  70        if (        sname=clas - 2 class="line" name="L122"> 122
sending) &&am1p; awaiting_rep1lypak cl>a/macintosh/a/macintosh/adb-iop.c#L88" id="L88" c"drivers/1macintosh/adb-iop.c#L92"1 id="19>-> op.cerfrrs/macbeginn cl>oft">versb>
l19h/adb-iop.c#L72" id="L72" clmemcpacintosh/adb-iopmemcpaef">s-iop.s="line" name="L118"> 118        for (.+code=cmd" clas"ss="sref">i = 0; uint 89              20          70        if (        sname=clas - 1" class="line" name="L122"> 122
flags);
 114href="+code=req" claacin" name="L114"> acin ( = re1nt">/*
 && -> = re1nacintosh1 * 19sh/adb-iop.c#L86" id="L86" class="line="line" name="L93">  93}
  94
current_re1L98">  981 * 19        99>uint) (struct  101
(uint) amsg2a href="+2ode=adb_iop_listen" clas2="sre201sref">uint) amsg->amsg-__u8ned lo) -iop.s="line" name="L118"> 118        for (  94
iop_msg *  74amsg2/a> = (struct adb_iop_iiop.c#L75" id="L75" class="line" name="2r5f">amsg2//a> 107#q" c!72" id="L72" cli.c#L34"p65" in" name="L114"> i.c#L34"p65" in) return -72" id="L72" clENODEV" name="L114"> ENODEVass=a> = re2op.c#L1082 id="L108" class="line" 2ame="20       115#ifdef  109#end2f
  74/*#def/macintosh/adb-iop.c#L112" id=20adb_iop_complete(struct l2cal_irvers/macintosh/adb-adb-iop.code=adb_iop_send_request" class="sref">aop_complete(struct );
reqreq,

<.#L122" id="L122" class="line" name="L122"> 122
;
2a href="drivers/macintos2/adb-2op.c#L114" id="L114" class="lief="drivers/macintosh/adi.c#L103" id="Ls/macintosh/adbe=printk" class="sref"k( 122
amsg2EBUG_ADB_IOP" class="sre2">DEB214      115#ifdef  e" name="L74">  74current_re2/a>-><2 href="+code=count" clas2="sre2">counvers/macintosh/adb-adb-iop.tosh/adb-iop.c#L51" id="L51" class="line" name="L51">  51static int ad href="+code=uint" class="sref">uint)"vers/macintosh/adb-syncode=reply_expectync)de=current_req" class="sref">current_re2/" class=2e=amsg" class="sref">ams2-2gt; */*#defn>, (uint"ISM IOernass=a> = re2"ISM IOernass=/a>        }
  5272" id="L72" cline" name="L114"> 114)a> = re2/* Handle a timeo2t. Ti222sref">uint"ISM IOernass=) return /macintosh/adb-erng">"ISM IOernass=a> = re2;
2"drivers/macintosh/adb-i2p.c#L22/adb-iop.c#L75" id="L75" class="line" name="2*/2q" c72" id="L72" clsyncode=reply_expectync)b_iop_state = uint)  114     current_rs/macintosh/adb-iohref="+code=adb_iop_reset_bus" class="sref")a> = re2<;p: rcvd2include/asm-blackfin/adb2_iop.226acintosh/a he" name="L74">  7422       115#ifdef   74  31<2/a>
<23est *, int);
  52static int adb_72" id="L72" cline" name="L114"> 114)op_complete(struct iop23db_request *uint  85          12<
current_req;
q" cs href="+code=uint" class="sref">uint  struct done)())b_iop_state = uint)  114     current_r ="/a> = re2ed char <2a href="+code=reply_buff2" cla236sref">uint) cmd);
  85          74uint 112
 113        a24al_irq_save( 114href="+code=req" class="sref">req->        }
cmd);
  85          43    2 114href="+code=req" claacin" name="L114"> acin ( 115#ifdef   44   24p.c#L114" id="L114" class="line" name="L114"> 114href="+code=req" clacurrent_req" class="sref">current_r ="+c"line" name="L115"> 115#ifdef 2="L45" class="line" name2="L45244/adb-iop.c#L72" id="L72" clclass="line" name="L89">  89                +c"line" name="L115"> 115#ifdef  24db_iop_end_req(struct a2407"> 107#q" c"+code=req" clacs/macintosh/adb-iop.c#L70" id="L70" class! = href="+code=req" class="sref">req->        }
flags;
/a>        }
flags;
uint = a2db_re250sref">uint)   70        if (;
adb_request2 *);
251sref">uint) /a>        }
flags;
  74  93}
  94
adb_2drive2557"> 107#q" c"+code=req" cla/a> && sending,
static int adbine" name="L94">  94
 = {
 107#return +c"line" name="L115"> 115#ifdef   528258" cle" name="L74">  74adbnt);
)op_complete(struct  =  */ 107#return +c"line" name="L115"> 115#ifdef   95
  48static int aop_complete(struct  = req-&2gt;count + v" c"+code=req" cla/a> && sending,
static int adbine" name="L94">  94
 i.c#L34"
adb0, "ef">105" class="line" ne=printk" class="sref"k(  94
  95req<27al_irq_save(state2;
aop_complete(struct   63_iop_state = static int adb        }
fl/a>_iop_state =  * 274/adb-iop.c#LLLLLLLLL.+code=cmd" clas   a/a>+) amsg2macintosh2/adb-iop.c#L76" id="L76"2 clas275sref">uint)         sname=clas = 2) amsg2mntosh/ad2 * 276sref">uint)         
<_PACKET_request" classk, 0 }) amsg2mL58" cla2macintosh/adb-iop.c#L78"2 id="27p.c#L88" id="}ne" name="L94">  94
uint  52-iop.s="line" name="ine" name="L114"> 114)a> = re2op_msg" c2lass="sref">iop_msg 2* 114.+code=cmd" clas" rrent_req" class="sref">current_rs/_iop_state = uint)  = re2ef">req;
uint) sending,
scheduefsref")a> = re2e/adb-iop2d="L84" class="line" nam2e="L8284" id="L124" e" name="L95">  95loca28_ADB_IOP
uint 115#ifdef req = 2  95
pmacoriginal LXR softw="drbyseie  name="L9http://sourcefrige.net/proj="ss/lxr">LXR maciunit91" clxr@ersux.no.
lxr.ersux.no kindlyshost"> bys name="L9http://www.redpill-erspro.no">Redpill Lrspro AS1" coftLrsux mansult cl>1nd os=rationmentrvicemenincee19a5.