fwohci.c revision 199767f8919635c4928607450d9e0abb932109ce
/*
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the acknowledgement as bellow:
*
* This product includes software developed by K. Kobayashi and H. Shimokawa
*
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*
*/
#include <stand.h>
#include <btxv86.h>
#include <bootstrap.h>
#include "fwohci.h"
#include "fwohcireg.h"
int firewire_debug=0;
#if 0
#else
#define device_printf(a, x, ...)
#endif
#define device_t int
#define MAX_SPEED 3
#define MAXREC(x) (2 << (x))
char *linkspeed[] = {
"S100", "S200", "S400", "S800",
"S1600", "S3200", "undef", "undef"
};
#define FW_EUI64_BYTE(eui, x) \
((((x)<4)? \
) & 0xff)
/*
* Communication with PHY device
*/
static uint32_t
{
addr &= 0xf;
data &= 0xff;
DELAY(100);
}
static uint32_t
{
addr &= 0xf;
#define MAX_RETRY 100
for ( i = 0 ; i < MAX_RETRY ; i ++ ){
break;
DELAY(100);
}
if(i >= MAX_RETRY) {
if (firewire_debug)
DELAY(100);
goto again;
}
}
/* Make sure that SCLK is started */
if ((stat & OHCI_INT_REG_FAIL) != 0 ||
if (firewire_debug)
DELAY(100);
goto again;
}
}
}
static int
{
int e1394a = 1;
/*
* probe PHY parameters
* 0. to prove PHY version, whether compliance of 1394a.
* 1. to probe maximum speed supported by the PHY and
* number of port supported by core-logic.
* It is not actually available port on your PC .
*/
DELAY(500);
}
"Phy 1394 only %s, %d ports.\n",
}else{
}
"Phy 1394a available %s, %d ports.\n",
/* check programPhyEnable */
#if 0
#else /* XXX force to enable 1394a */
if (e1394a) {
#endif
if (firewire_debug)
"Enable 1394a Enhancements\n");
/* enable EAA EMC */
reg2 |= 0x03;
/* set aPhyEnhanceEnable */
} else {
/* for safe */
reg2 &= ~0x83;
}
}
}
return 0;
}
void
{
/* Disable interrupts */
/* FLUSH FIFO and reset Transmitter/Reciever */
if (firewire_debug)
i = 0;
if (i++ > 100) break;
DELAY(1000);
}
if (firewire_debug)
printf("done (loop=%d)\n", i);
/* Probe phy */
/* Probe link */
/* XXX fix max_rec */
}
if (firewire_debug)
/* Initialize registers */
#if 0
#endif
#if 0
#endif
/* Enable link */
}
int
{
int i, mver;
/* OHCI version */
return (ENXIO);
}
/* Available Isochronous DMA channel probe */
for (i = 0; i < 0x20; i++)
if ((reg & (1 << i)) == 0)
break;
if (i == 0)
return (ENXIO);
#if 0
/* SID recieve buffer must align 2^11 */
return ENOMEM;
}
#endif
for( i = 0 ; i < 8 ; i ++)
return 0;
}
void
{
/*
* Make sure our cached values from the config rom are
* initialised.
*/
/*
* Set root hold-off bit so that non cyclemaster capable node
* shouldn't became the root node.
*/
#if 1
fun |= FW_PHY_IBR;
#else /* Short bus reset */
fun |= FW_PHY_ISBR;
#endif
}
void
{
int plen;
if (!(node_id & OHCI_NODE_VALID)) {
#if 0
printf("Bus reset failure\n");
#endif
return;
}
/* Enable bus reset interrupt */
/* Allow async. request to us */
/* XXX insecure ?? */
/* Set ATRetries register */
/*
** Checking whether the node is root or not. If root, turn on
** cycle master.
*/
if (node_id & OHCI_NODE_ROOT) {
} else {
}
if (plen & OHCI_SID_ERR) {
return;
}
}
static void
{
#ifdef OHCI_DEBUG
#if 0
#else
if (1)
#endif
);
#endif
/* Bus reset */
if(stat & OHCI_INT_PHY_BUS_R ){
goto busresetout;
/* Disable bus reset interrupt until sid recv. */
fwohci_sid(sc);
}
return;
}
static uint32_t
{
if (stat == 0xffffffff) {
"device physically ejected?\n");
return(stat);
}
if (stat)
return(stat);
}
void
{
if (stat != 0xffffffff)
}