⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 superh.c

📁 Linux2.4.20针对三星公司的s3c2440内核基础上的一些设备驱动代码
💻 C
📖 第 1 页 / 共 2 页
字号:
		superh_in_epn (3, 0);	// XXX status?	}	if (f1_status & EP3_TS) {		printk (KERN_DEBUG "superh_int_hndlr_f1[%x]: EP3 TS\n", udc_interrupts);	}	superh_in_epn (3, 0);	// XXX status?}/* ********************************************************************************************* *//* ********************************************************************************************* *//* Start of public functions.  *//** * udc_start_in_irq - start transmit * @endpoint: endpoint instance * * Called by bus interface driver to see if we need to start a data transmission. */void udc_start_in_irq (struct usb_endpoint_instance *endpoint){	if (endpoint) {		// XXX should verify logical address mapping to physical 2		superh_in_epn (2, 0);	}}/** * udc_init - initialize * * Return non-zero if we cannot see device. **/int udc_init (void){	// XXX move clock enable to udc_enable, add code to udc_disable to disable them	// Reset and then Select Function USB1_pwr_en out (USB) c.f. Section 26, Table 26.1 PTE2	and_w (PN_PB2_MSK, PECR);	or_w (PN_PB2_OF, PECR);	// Reset and then Select Function UCLK c.f. Section 26, Table 26.1, PTD6	and_w (PN_PB6_MSK, PDCR);	or_w (PN_PB6_OF, PDCR);	// Stop USB module prior to setting clocks c.f. Section 9.2.3	and_b (~MSTP14, STBCR3);	or_b (MSTP14, STBCR3);	// Select external clock, 1/1 divisor c.f. Section 11.3.1	or_b (USBDIV_11 | USBCKS_EC, EXCPGCR);	// Start USB c.f. Section 9.2.3	and_b (~MSTP14, STBCR3);	// Disable pullup c.f. Section 23.5.19	printk (KERN_DEBUG "udc_init:\n");	printk (KERN_DEBUG "udc_init: Disable Pullup\n");	or_b (PULLUP_E, USBDMA);	//and_b(~PULLUP_E, USBDMA);	// Set port 1 to function, disabled c.f. Section 22.2.1	or_w (USB_TRANS_TRAN | USB_SEL_FUNC, EXPFC);	// Enable pullup c.f. Section 23.5.19	printk (KERN_DEBUG "udc_init:\n");	printk (KERN_DEBUG "udc_init: Enable Pullup\n");	and_b (~PULLUP_E, USBDMA);	//or_b(PULLUP_E, USBDMA);	// reset fifo's and stall's	or_b (EP3_CLEAR | EP1_CLEAR | EP2_CLEAR | EP0o_CLEAR | EP0i_CLEAR, USBFCLR);	or_b (0, USBEPSTL);	// setup interrupt priority by using the interrupt select registers	ctrl_outb (F0_LOW, USBISR0);	ctrl_outb (F1_LOW, USBISR1);	printk (KERN_DEBUG "udc_init:\n");	return 0;}/** * udc_stall_ep - stall endpoint * @ep: physical endpoint * * Stall the endpoint. */void udc_stall_ep (unsigned int ep){	if (ep < UDC_MAX_ENDPOINTS) {		// stall	}}/** * udc_reset_ep - reset endpoint * @ep: physical endpoint * reset the endpoint. * * returns : 0 if ok, -1 otherwise */void udc_reset_ep (unsigned int ep){	if (ep < UDC_MAX_ENDPOINTS) {		// reset	}}/** * udc_endpoint_halted - is endpoint halted * @ep: * * Return non-zero if endpoint is halted */int udc_endpoint_halted (unsigned int ep){	return 0;}/** * udc_set_address - set the USB address for this device * @address: * * Called from control endpoint function after it decodes a set address setup packet. */void udc_set_address (unsigned char address){	// address cannot be setup until ack received	usb_address = address;}/** * udc_serial_init - set a serial number if available */int __init udc_serial_init (struct usb_bus_instance *bus){	return -EINVAL;}/* ********************************************************************************************* *//** * udc_max_endpoints - max physical endpoints  * * Return number of physical endpoints. */int udc_max_endpoints (void){	return UDC_MAX_ENDPOINTS;}/** * udc_check_ep - check logical endpoint  * @lep: * * Return physical endpoint number to use for this logical endpoint or zero if not valid. */int udc_check_ep (int logical_endpoint, int packetsize){	return (((logical_endpoint & 0xf) >= UDC_MAX_ENDPOINTS)		|| (packetsize > 64)) ? 0 : (logical_endpoint & 0xf);}/** * udc_set_ep - setup endpoint  * @ep: * @endpoint: * * Associate a physical endpoint with endpoint_instance */void udc_setup_ep (struct usb_device_instance *device, unsigned int ep,		   struct usb_endpoint_instance *endpoint){	printk (KERN_DEBUG "udc_setup_ep: ep: %d\n", ep);	if (ep < UDC_MAX_ENDPOINTS) {		ep_endpoints[ep] = endpoint;		// ep0		if (ep == 0) {		}		// IN		else if (endpoint->endpoint_address & 0x80) {		}		// OUT		else if (endpoint->endpoint_address) {			usbd_fill_rcv (device, endpoint, 5);			endpoint->rcv_urb = first_urb_detached (&endpoint->rdy);		}	}}/** * udc_disable_ep - disable endpoint * @ep: * * Disable specified endpoint  */void udc_disable_ep (unsigned int ep){	if (ep < UDC_MAX_ENDPOINTS) {		struct usb_endpoint_instance *endpoint;		if ((endpoint = ep_endpoints[ep])) {			ep_endpoints[ep] = NULL;			usbd_flush_ep (endpoint);		}	}}/* ********************************************************************************************* *//** * udc_connected - is the USB cable connected * * Return non-zero if cable is connected. */int udc_connected (){	return (ctrl_inb (USBIFR1) & VBUSMN) ? 1 : 0;}/** * udc_connect - enable pullup resistor * * Turn on the USB connection by enabling the pullup resistor. */void udc_connect (void){	// enable pullup	printk (KERN_DEBUG "udc_connect:\n");	and_b (~PULLUP_E, USBDMA);}/** * udc_disconnect - disable pullup resistor * * Turn off the USB connection by disabling the pullup resistor. */void udc_disconnect (void){	// enable pullup	printk (KERN_DEBUG "udc_disconnect:\n");	or_b (PULLUP_E, USBDMA);}/* ********************************************************************************************* *//** * udc_enable_interrupts - enable interrupts * * Switch on UDC interrupts. * */void udc_all_interrupts (struct usb_device_instance *device){	// set interrupt mask	or_b (BRST | EP1_FULL | SETUP_TS | EP0o_TS | EP0i_TR | EP0i_TS, USBIER0);	or_b (EP3_TR | EP3_TS | VBUSF, USBIER1);}/** * udc_suspended_interrupts - enable suspended interrupts * * Switch on only UDC resume interrupt. * */void udc_suspended_interrupts (struct usb_device_instance *device){}/** * udc_disable_interrupts - disable interrupts. * * switch off interrupts */void udc_disable_interrupts (struct usb_device_instance *device){	// reset interrupt mask	ctrl_outb (0x0, USBIER0);	ctrl_outb (0x0, USBIER1);}/* ********************************************************************************************* *//** * udc_ep0_packetsize - return ep0 packetsize */int udc_ep0_packetsize (void){	return EP0_PACKETSIZE;}/** * udc_enable - enable the UDC * * Switch on the UDC */void udc_enable (struct usb_device_instance *device){	// save the device structure pointer	udc_device = device;	// ep0 urb	if (!ep0_urb) {		if ((ep0_urb = usbd_alloc_urb (device, device->function_instance_array, 0, 512))) {			printk (KERN_ERR "ep0_enable: usbd_alloc_urb failed\n");		}	} else {		printk (KERN_ERR "udc_enable: ep0_urb already allocated\n");	}	// XXX enable UDC}/** * udc_disable - disable the UDC * * Switch off the UDC */void udc_disable (void){	// XXX disable UDC	// reset device pointer	udc_device = NULL;	// ep0 urb	if (ep0_urb) {		usbd_dealloc_urb (ep0_urb);		ep0_urb = NULL;	}}/** * udc_startup_events - allow udc code to do any additional startup */void udc_startup_events (struct usb_device_instance *device){	printk (KERN_DEBUG "udc_startup_events:\n");	usbd_device_event (device, DEVICE_INIT, 0);	usbd_device_event (device, DEVICE_CREATE, 0);	usbd_device_event (device, DEVICE_HUB_CONFIGURED, 0);	// XXX the following could be snuck into get descriptor LANGID#if 0	usbd_device_event (device, DEVICE_ADDRESS_ASSIGNED, 0);	device->configuration = 0;	usbd_device_event (device, DEVICE_CONFIGURED, 0);	device->interface = 1;	device->alternate = 0;	usbd_device_event (device, DEVICE_SET_INTERFACE, 0);#endif}/* ********************************************************************************************* *//** * udc_name - return name of USB Device Controller */char *udc_name (void){	return UDC_NAME;}/** * udc_request_udc_irq - request UDC interrupt */int udc_request_udc_irq (){	if (request_irq (USBF0_IRQ, superh_int_hndlr_f0, SA_INTERRUPT | SA_SAMPLE_RANDOM, UDC_NAME			 " USBD Bus Interface (high priority)", NULL) != 0) {		printk (KERN_DEBUG "usb_ctl: Couldn't request USB irq F0\n");		return -EINVAL;	}	return 0;}/** * udc_request_cable_irq - request Cable interrupt */int udc_request_cable_irq (){	if (request_irq (USBF1_IRQ, superh_int_hndlr_f1, SA_INTERRUPT | SA_SAMPLE_RANDOM,			 UDC_NAME " USBD Bus Interface (low priority)", NULL) != 0) {		printk (KERN_DEBUG "usb_ctl: Couldn't request USB irq F1\n");		free_irq (USBF0_IRQ, NULL);		return -EINVAL;	}	return 0;}/** * udc_request_udc_io - request UDC io region */int udc_request_io (){	return 0;}/** * udc_release_udc_irq - release UDC irq */void udc_release_udc_irq (){	free_irq (USBF0_IRQ, NULL);}/** * udc_release_cable_irq - release Cable irq */void udc_release_cable_irq (){	free_irq (USBF1_IRQ, NULL);}/** * udc_release_release_io - release UDC io region */void udc_release_io (){}/** * udc_regs - dump registers */void udc_regs (void){	printk (KERN_DEBUG		"[%d:%d:%d] IFR[%02x:%02x] IER[%02x:%02x] ISR[%02x:%02x] DASTS[%02x] EPSTL[%02x] EPSZ1[%02x] DMA[%02x]\n",		udc_interrupts, udc_f0_interrupts, udc_f1_interrupts,		ctrl_inb (USBIFR0), ctrl_inb (USBIFR1), ctrl_inb (USBIER0), ctrl_inb (USBIER1),		ctrl_inb (USBISR0), ctrl_inb (USBISR1), ctrl_inb (USBDASTS), ctrl_inb (USBEPSTL),		ctrl_inb (USBEPSZ1), ctrl_inb (USBDMA)	    );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -