Exemple #1
0
static int
usb_hub_port_status_changed(usbdev_t *const dev, const int port)
{
	unsigned short buf[2] = { 0, 0 };
	get_status (dev, port, DR_PORT, 4, buf);
	if (buf[1] & PORT_CONNECTION)
		clear_feature (dev, port, SEL_C_PORT_CONNECTION, DR_PORT);
	return buf[1] & PORT_CONNECTION;
}
//-----------------------------------------------------------------
// usb_process_request:
//-----------------------------------------------------------------
static void usb_process_request(struct device_request *request, unsigned char type, unsigned char req, unsigned char *data)
{
	if ( type == USB_STANDARD_REQUEST )
	{
        // Standard requests
        switch (req)
        {
        case REQ_GET_STATUS:
            get_status(request);
            break;
        case REQ_CLEAR_FEATURE:
            clear_feature(request);
            break;
        case REQ_SET_FEATURE:
            set_feature(request);
            break;
        case REQ_SET_ADDRESS:
            set_address(request);
            break;
        case REQ_GET_DESCRIPTOR:
            get_descriptor(request);
            break;
        case REQ_GET_CONFIGURATION:
            get_configuration(request);
            break;
        case REQ_SET_CONFIGURATION:
            set_configuration(request);
            break;
        case REQ_GET_INTERFACE:
            get_interface(request);
            break;
        case REQ_SET_INTERFACE:
            set_interface(request);
            break;
        default:
            log_printf(USBLOG_ERR, "USB: Unknown standard request %x\n", req);
		    usbhw_control_endpoint_stall();
            break;
        }
	}
	else if ( type == USB_VENDOR_REQUEST )
	{
        log_printf(USBLOG_ERR, "Vendor: Unknown command\n");

        // None supported
		usbhw_control_endpoint_stall();
	}
	else if ( type == USB_CLASS_REQUEST && _class_request)
	{
        _class_request(req, request->wValue, request->wIndex, data, request->wLength);
	}
	else
        usbhw_control_endpoint_stall();
}
Exemple #3
0
static int
usb_hub_port_status_changed(usbdev_t *const dev, const int port)
{
	unsigned short buf[2];
	int ret = get_status (dev, port, DR_PORT, sizeof(buf), buf);
	if (ret >= 0) {
		ret = buf[1] & PORT_CONNECTION;
		if (ret)
			clear_feature (dev, port, SEL_C_PORT_CONNECTION,
				       DR_PORT);
	}
	return ret;
}
Exemple #4
0
status_t
clear_feature_v2(const void *object, uint16 selector)
{
	return clear_feature((usb_id)(ssize_t)object, selector);
}
/*
 * This is function for Control Transfer.
 * If it occurs endpoint0 interrupt, this function is called.
 * This function check Device Request for Control Transfer type and
 * call each other functions.
 */
void s3c_ep0_int_hndlr(void)
{
	__u32 ep0sr;
	__u16 read_cnt, i;
	__u16 read_buf[4]={0x0000, };
	__u8 set_addr;

	UD_INDEX_REG = UD_INDEX_EP0;
	ep0sr = UD_EP0_STATUS_REG;

	LOG(" EP0 Status Register = %x \n", s3c_ep0_state);

	/* EP0 status register check */
	if (ep0sr & UD_EP0_SENT_STALL) {
		LOG(" Sent Stall \n");
		UD_EP0_STATUS_REG = UD_EP0_SENT_STALL;

		if (ep0sr & UD_EP0_RX_SUCCESS)
			UD_EP0_STATUS_REG = UD_EP0_RX_SUCCESS;

		s3c_ep0_state= EP0_STATE_IDLE;
		return;
	}

	if (ep0sr & UD_EP0_TX_SUCCESS) {
		LOG(" EP0_TX_SUCCESS \n");
		UD_EP0_STATUS_REG = UD_EP0_TX_SUCCESS;
	}

	LOG(" s3c_ep0_state = %x \n", s3c_ep0_state);

	if (s3c_ep0_state == EP0_STATE_IDLE) {
		read_cnt = UD_BYTE_READ_CNT_REG;

		for(i=0;i<4;i++)
			read_buf[i] = (__u16)UD_EP0_BUF_REG;

		UD_EP0_STATUS_REG = UD_EP0_RX_SUCCESS;

		dev_req->bmRequestType	= (__u8)read_buf[0];
		dev_req->bRequest	= (__u8)(read_buf[0]>>8);
		dev_req->wValue		= read_buf[1];
		dev_req->wIndex		= read_buf[2];
		dev_req->wLength	= read_buf[3];

		switch (dev_req->bRequest) {
		case USB_REQ_SET_ADDRESS:
			/* Set Address Update bit */
			set_addr = (__u8)(dev_req->wValue & 0xff);
			LOG("Func_ADDR_Setaddr : %d \n", set_addr);
			s3c_ep0_state = EP0_STATE_IDLE;
			break;

		case USB_REQ_SET_DESCRIPTOR:
			LOG("Set Descriptor \n");
			break;

		case USB_REQ_SET_CONFIGURATION:
			LOG("Set Configuration \n");
			config_value = dev_req->wValue;
			break;

		case USB_REQ_GET_CONFIGURATION:
			LOG("Get Configruation \n");
			UD_BYTE_WRITE_CNT_REG = 1;
			UD_EP0_BUF_REG = config_value;
			break;

		case USB_REQ_GET_DESCRIPTOR:
			LOG("Get Descriptor \n");
			get_desc();
			break;

		case USB_REQ_CLEAR_FEATURE:
			LOG("Clear Feature \n");
			clear_feature();
			break;

		case USB_REQ_SET_FEATURE:
			LOG("Set Feature \n");
			set_feature();
			break;

		case USB_REQ_GET_STATUS:
			LOG("Get Status \n");
			usb_get_status();
			break;

		case USB_REQ_GET_INTERFACE:
			LOG("Get Interface \n");
			s3c_ep0_state = USB_GET_INTERFACE;
			break;

		case USB_REQ_SET_INTERFACE:
			LOG("Set Interface \n");
			get_intf->AlternateSetting = (__u8)dev_req->wValue;
			s3c_ep0_state = EP0_STATE_IDLE;
			break;

		case USB_REQ_SYNCH_FRAME:
			LOG("Synch Frame \n");
			s3c_ep0_state = EP0_STATE_IDLE;
			break;

		default:
			break;
		}
	}