Example #1
0
static void
initialize_descriptors(void)
{
	LOG("\n");

	desc.dev.bLength               = sizeof( device_desc_t );
	desc.dev.bDescriptorType       = USB_DESC_DEVICE;
	desc.dev.bcdUSB                = 0x100; /* 1.1 */
	desc.dev.bDeviceClass          = 0xFF;	/* vendor specific */
	desc.dev.bDeviceSubClass       = 0x0;
	desc.dev.bDeviceProtocol       = 0x0;
	desc.dev.bMaxPacketSize0       = 0x8;	/* ep0 max fifo size in s3c2410*/
	desc.dev.idVendor              = 0x49f; /* vendor ID undefined */
	desc.dev.idProduct             = 0x505a; /* product */
	desc.dev.bcdDevice             = 0x01 ; /* vendor assigned device release num */
	desc.dev.iManufacturer         = 0;	/* index of manufacturer string */
	desc.dev.iProduct              = 0; /* index of product description string */
	desc.dev.iSerialNumber         = 0;	/* index of string holding product s/n */
	desc.dev.bNumConfigurations    = 0x1;

	desc.b.cfg.bLength             = sizeof( config_desc_t );
	desc.b.cfg.bDescriptorType     = USB_DESC_CONFIG;
	desc.b.cfg.wTotalLength        = make_word_c( sizeof(struct cdb) );
	desc.b.cfg.bNumInterfaces      = 1;
	desc.b.cfg.bConfigurationValue = 1;
	desc.b.cfg.iConfiguration      = 0;
	desc.b.cfg.bmAttributes        = USB_CONFIG_BUSPOWERED;
	desc.b.cfg.MaxPower            = USB_POWER( 500 );

	desc.b.intf.bLength            = sizeof( intf_desc_t );
	desc.b.intf.bDescriptorType    = USB_DESC_INTERFACE;
	desc.b.intf.bInterfaceNumber   = 0x0; /* unique intf index*/
	desc.b.intf.bAlternateSetting  = 0x0;
	desc.b.intf.bNumEndpoints      = 2; /* endpoint number excluding ep0 */
	desc.b.intf.bInterfaceClass    = 0xFF; /* vendor specific */
	desc.b.intf.bInterfaceSubClass = 0x0;
	desc.b.intf.bInterfaceProtocol = 0x0;
	desc.b.intf.iInterface         = 0x0;

	desc.b.ep1.bLength             = sizeof( ep_desc_t );
        desc.b.ep1.bDescriptorType     = USB_DESC_ENDPOINT;
        desc.b.ep1.bEndpointAddress    = USB_EP_ADDRESS( 1, USB_OUT );
        desc.b.ep1.bmAttributes        = USB_EP_BULK;
        desc.b.ep1.wMaxPacketSize      = make_word_c( 64 );
        desc.b.ep1.bInterval	       = 0x0;		
	
	desc.b.ep2.bLength             = sizeof( ep_desc_t );
	desc.b.ep2.bDescriptorType     = USB_DESC_ENDPOINT;
	desc.b.ep2.bEndpointAddress    = USB_EP_ADDRESS( 2, USB_IN );
	desc.b.ep2.bmAttributes        = USB_EP_BULK;
	desc.b.ep2.wMaxPacketSize      = make_word_c( 64 );
	desc.b.ep2.bInterval           = 0x0;

	/* set language */
	/* See: http://www.usb.org/developers/data/USB_LANGIDs.pdf */
	sd_zero.bDescriptorType = USB_DESC_STRING;
	sd_zero.bLength         = sizeof( string_desc_t );
	sd_zero.bString[0]      = make_word_c( 0x409 ); /* American English */
	s3c2410_usb_set_string_descriptor( 0, &sd_zero );
}
Example #2
0
void initialize_descriptors(struct usbctl *ctl)
{
	struct usb_client *clnt = ctl->clnt;
	int r;

	ctl->ep_desc[0] = (struct usb_endpoint_descriptor *)&cdb.ep1;
	ctl->ep_desc[1] = (struct usb_endpoint_descriptor *)&cdb.ep2;

	cdb.cfg.bLength             = USB_DT_CONFIG_SIZE;
	cdb.cfg.bDescriptorType     = USB_DT_CONFIG;
	cdb.cfg.wTotalLength        = cpu_to_le16(sizeof(struct cdb));
	cdb.cfg.bNumInterfaces      = 1;
	cdb.cfg.bConfigurationValue = 1;
	cdb.cfg.iConfiguration      = 0;
	cdb.cfg.bmAttributes        = USB_CONFIG_ATT_ONE;
	cdb.cfg.bMaxPower           = USB_POWER( 500 );

	cdb.intf.bLength            = USB_DT_INTERFACE_SIZE;
	cdb.intf.bDescriptorType    = USB_DT_INTERFACE;
	cdb.intf.bInterfaceNumber   = 0;     /* unique intf index*/
	cdb.intf.bAlternateSetting  = 0;
	cdb.intf.bNumEndpoints      = 2;
	cdb.intf.bInterfaceClass    = 0xff;  /* vendor specific */
	cdb.intf.bInterfaceSubClass = 0;
	cdb.intf.bInterfaceProtocol = 0;
	cdb.intf.iInterface         = 0;

	cdb.ep1.bLength             = USB_DT_INTERFACE_SIZE;
	cdb.ep1.bDescriptorType     = USB_DT_ENDPOINT;
	cdb.ep1.bEndpointAddress    = USB_DIR_OUT | 1;
	cdb.ep1.bmAttributes        = USB_ENDPOINT_XFER_BULK;
	cdb.ep1.wMaxPacketSize      = cpu_to_le16(64);
	cdb.ep1.bInterval           = 0;

	cdb.ep2.bLength             = USB_DT_INTERFACE_SIZE;
	cdb.ep2.bDescriptorType     = USB_DT_ENDPOINT;
	cdb.ep2.bEndpointAddress    = USB_DIR_IN | 2;
	cdb.ep2.bmAttributes        = USB_ENDPOINT_XFER_BULK;
	cdb.ep2.wMaxPacketSize      = cpu_to_le16(64);
	cdb.ep2.bInterval           = 0;

	ctl->dev_desc->bLength            = USB_DT_DEVICE_SIZE;
	ctl->dev_desc->bDescriptorType    = USB_DT_DEVICE;
	ctl->dev_desc->bcdUSB             = cpu_to_le16(0x100); /* 1.0 */
	ctl->dev_desc->bDeviceClass       = clnt->class;
	ctl->dev_desc->bDeviceSubClass    = clnt->subclass;
	ctl->dev_desc->bDeviceProtocol    = clnt->protocol;
	ctl->dev_desc->bMaxPacketSize0    = 8;	/* ep0 max fifo size */
	ctl->dev_desc->idVendor           = cpu_to_le16(clnt->vendor);
	ctl->dev_desc->idProduct          = cpu_to_le16(clnt->product);
	ctl->dev_desc->bcdDevice          = cpu_to_le16(clnt->version);
	ctl->dev_desc->bNumConfigurations = 1;

	/* set language */
	/* See: http://www.usb.org/developers/data/USB_LANGIDs.pdf */
	r = sa1100_usb_add_language(ctl, 0x409);
	if (r < 0)
		printk(KERN_ERR "usbc: couldn't add language\n");

	r = sa1100_usb_add_string(ctl, clnt->manufacturer_str);
	if (r < 0)
		printk(KERN_ERR "usbc: couldn't add manufacturer string\n");

	ctl->dev_desc->iManufacturer = r > 0 ? r : 0;

	r = sa1100_usb_add_string(ctl, clnt->product_str);
	if (r < 0)
		printk(KERN_ERR "usbc: couldn't add product string\n");

	ctl->dev_desc->iProduct      = r > 0 ? r : 0;

	r = sa1100_usb_add_string(ctl, clnt->serial_str);
	if (r < 0)
		printk(KERN_ERR "usbc: couldn't add serial string\n");

	ctl->dev_desc->iSerialNumber = r > 0 ? r : 0;
}