/* init the led timer */ init_timer(&hfc->led_timer); hfc->led_timer.data = (long) hfc; hfc->led_timer.function = (void *) led_timer;  /* trigger 4 hz led timer */ if (!timer_pending(&hfc->led_timer)) { hfc->led_timer.expires = jiffies + (LED_TIME * HZ) / 1000; add_timer(&hfc->led_timer); }  
usb_init(hfcusb_data * hfc){	usb_fifo *fifo;	int i, err;	u_char b;	struct hisax_b_if *p_b_if[2];	/* check the chip id */	if (read_usb(hfc, HFCUSB_CHIP_ID, &b) != 1) {		printk(KERN_INFO "HFC-USB: cannot read chip id\n");		return (1);	}	if (b != HFCUSB_CHIPID) {		printk(KERN_INFO "HFC-S USB: Invalid chip id 0x%02x\n", b);		return (1);	}	/* first set the needed config, interface and alternate */	err = usb_set_interface(hfc->dev, hfc->if_used, hfc->alt_used);	/* do Chip reset */	write_usb(hfc, HFCUSB_CIRM, 8);	/* aux = output, reset off */	write_usb(hfc, HFCUSB_CIRM, 0x10);	/* set USB_SIZE to match the the wMaxPacketSize for INT or BULK transfers */	write_usb(hfc, HFCUSB_USB_SIZE,		  (hfc->packet_size / 8) | ((hfc->packet_size / 8) << 4));	/* set USB_SIZE_I to match the the wMaxPacketSize for ISO transfers */	write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size);	/* enable PCM/GCI master mode */	write_usb(hfc, HFCUSB_MST_MODE1, 0);	/* set default values */	write_usb(hfc, HFCUSB_MST_MODE0, 1);	/* enable master mode */	/* init the fifos */	write_usb(hfc, HFCUSB_F_THRES,		  (HFCUSB_TX_THRESHOLD /		   8) | ((HFCUSB_RX_THRESHOLD / 8) << 4));	fifo = hfc->fifos;	for (i = 0; i < HFCUSB_NUM_FIFOS; i++) {		write_usb(hfc, HFCUSB_FIFO, i);	/* select the desired fifo */		fifo[i].skbuff = NULL;	/* init buffer pointer */		fifo[i].max_size =		    (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN;		fifo[i].last_urblen = 0;		/* set 2 bit for D- & E-channel */		write_usb(hfc, HFCUSB_HDLC_PAR,			  ((i <= HFCUSB_B2_RX) ? 0 : 2));		/* rx hdlc, enable IFF for D-channel */		write_usb(hfc, HFCUSB_CON_HDLC,			  ((i == HFCUSB_D_TX) ? 0x09 : 0x08));		write_usb(hfc, HFCUSB_INC_RES_F, 2);	/* reset the fifo */	}	write_usb(hfc, HFCUSB_CLKDEL, 0x0f);	/* clock delay value */	write_usb(hfc, HFCUSB_STATES, 3 | 0x10);	/* set deactivated mode */	write_usb(hfc, HFCUSB_STATES, 3);	/* enable state machine */	write_usb(hfc, HFCUSB_SCTRL_R, 0);	/* disable both B receivers */	write_usb(hfc, HFCUSB_SCTRL, 0x40);	/* disable B transmitters + capacitive mode */	/* set both B-channel to not connected */	hfc->b_mode[0] = L1_MODE_NULL;	hfc->b_mode[1] = L1_MODE_NULL;	hfc->l1_activated = FALSE;	hfc->disc_flag = FALSE;	hfc->led_state = 0;	hfc->led_new_data = 0;	hfc->old_led_state = 0;	/* init the t3 timer */	init_timer(&hfc->t3_timer);	hfc->t3_timer.data = (long) hfc;	hfc->t3_timer.function = (void *) l1_timer_expire_t3;	/* init the t4 timer */	init_timer(&hfc->t4_timer);	hfc->t4_timer.data = (long) hfc;	hfc->t4_timer.function = (void *) l1_timer_expire_t4;	/* init the led timer */	init_timer(&hfc->led_timer);	hfc->led_timer.data = (long) hfc;	hfc->led_timer.function = (void *) led_timer;	/* trigger 4 hz led timer */	if (!timer_pending(&hfc->led_timer)) {		hfc->led_timer.expires = jiffies + (LED_TIME * HZ) / 1000;		add_timer(&hfc->led_timer);	}	/* init the background machinery for control requests */	hfc->ctrl_read.bRequestType = 0xc0;	hfc->ctrl_read.bRequest = 1;	hfc->ctrl_read.wLength = 1;	hfc->ctrl_write.bRequestType = 0x40;	hfc->ctrl_write.bRequest = 0;	hfc->ctrl_write.wLength = 0;	usb_fill_control_urb(hfc->ctrl_urb,			     hfc->dev,			     hfc->ctrl_out_pipe,			     (u_char *) & hfc->ctrl_write,			     NULL, 0, ctrl_complete, hfc);	/* Init All Fifos */	for (i = 0; i < HFCUSB_NUM_FIFOS; i++) {		hfc->fifos[i].iso[0].purb = NULL;		hfc->fifos[i].iso[1].purb = NULL;		hfc->fifos[i].active = 0;	}	/* register Modul to upper Hisax Layers */	hfc->d_if.owner = THIS_MODULE;	hfc->d_if.ifc.priv = &hfc->fifos[HFCUSB_D_TX];	hfc->d_if.ifc.l2l1 = hfc_usb_l2l1;	for (i = 0; i < 2; i++) {		hfc->b_if[i].ifc.priv = &hfc->fifos[HFCUSB_B1_TX + i * 2];		hfc->b_if[i].ifc.l2l1 = hfc_usb_l2l1;		p_b_if[i] = &hfc->b_if[i];	}	/* default Prot: EURO ISDN, should be a module_param */	hfc->protocol = 2;	hisax_register(&hfc->d_if, p_b_if, "hfc_usb", hfc->protocol);#ifdef CONFIG_HISAX_DEBUG	hfc_debug = debug;#endif	for (i = 0; i < 4; i++)		hfc->fifos[i].hif = &p_b_if[i / 2]->ifc;	for (i = 4; i < 8; i++)		hfc->fifos[i].hif = &hfc->d_if.ifc;	/* 3 (+1) INT IN + 3 ISO OUT */	if (hfc->cfg_used == CNF_3INT3ISO || hfc->cfg_used == CNF_4INT3ISO) {		start_int_fifo(hfc->fifos + HFCUSB_D_RX);		if (hfc->fifos[HFCUSB_PCM_RX].pipe)			start_int_fifo(hfc->fifos + HFCUSB_PCM_RX);		start_int_fifo(hfc->fifos + HFCUSB_B1_RX);		start_int_fifo(hfc->fifos + HFCUSB_B2_RX);	}	/* 3 (+1) ISO IN + 3 ISO OUT */	if (hfc->cfg_used == CNF_3ISO3ISO || hfc->cfg_used == CNF_4ISO3ISO) {		start_isoc_chain(hfc->fifos + HFCUSB_D_RX, ISOC_PACKETS_D,				 rx_iso_complete, 16);		if (hfc->fifos[HFCUSB_PCM_RX].pipe)			start_isoc_chain(hfc->fifos + HFCUSB_PCM_RX,					 ISOC_PACKETS_D, rx_iso_complete,					 16);		start_isoc_chain(hfc->fifos + HFCUSB_B1_RX, ISOC_PACKETS_B,				 rx_iso_complete, 16);		start_isoc_chain(hfc->fifos + HFCUSB_B2_RX, ISOC_PACKETS_B,				 rx_iso_complete, 16);	}	start_isoc_chain(hfc->fifos + HFCUSB_D_TX, ISOC_PACKETS_D,			 tx_iso_complete, 1);	start_isoc_chain(hfc->fifos + HFCUSB_B1_TX, ISOC_PACKETS_B,			 tx_iso_complete, 1);	start_isoc_chain(hfc->fifos + HFCUSB_B2_TX, ISOC_PACKETS_B,			 tx_iso_complete, 1);	handle_led(hfc, LED_POWER_ON);	return (0);}				/* usb_init */
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/597a107b1d5587dc230dbbe3faeca242daed494e/hfc_usb.c/buggy/drivers/isdn/hisax/hfc_usb.c