public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] PCI USB Driver
@ 2007-03-29 19:00 Lance Ware
  2007-03-30 13:56 ` Matthias Fuchs
  0 siblings, 1 reply; 2+ messages in thread
From: Lance Ware @ 2007-03-29 19:00 UTC (permalink / raw)
  To: u-boot

I have start to write a PCI usb_lowlevel_init i think that i might need 
something else as i am not getting any back from the registers but 0's.  I 
wanted to know how you guys are taking care of the pci write and read commands 
for readl and writel.  Here is my example code.


Code for usb_lowlevel_init 
busdevfunc=pci_find_device(USB_UHCI_VEND_ID,USB_UHCI_DEV_ID,0); /* get PCI 
Device ID */

	if(busdevfunc == -1) {
		printf("Error USB OHCI (%04X,%04X) not 
found\n",USB_UHCI_VEND_ID,USB_UHCI_DEV_ID);
		return -1;
	}
    
    pci_read_config_byte(busdevfunc,PCI_INTERRUPT_LINE,&temp);
	irqvec = temp;
	irq_free_handler(irqvec);
	pci_read_config_byte(busdevfunc,PCI_INTERRUPT_PIN,&temp);
	pci_read_config_dword(busdevfunc,PCI_BASE_ADDRESS_0,&pci_io_addr);

	pci_io_addr &= ~0xf;

    printf("usb_ohci_pci: io_base:0x%08X irq: %d\n", 
		   (unsigned long)pci_io_addr, irqvec);
	
	pci_write_config_dword(busdevfunc, PCI_COMMAND,
				       PCI_COMMAND_MEMORY | 
PCI_COMMAND_MASTER);

	// Find out what hose we are on...
	usb_hose = pci_bus_to_hose(0);
	
	/* Check if I/O accesses and Bus Mastering are enabled. */
	pci_read_config_dword(busdevfunc, PCI_COMMAND, &PciCommandWord);
	if (!(PciCommandWord & PCI_COMMAND_MEMORY)) {
		printf("Error: Can not enable MEM access.\n");
    } 

	/* align the storage */
	if ((__u32)&ghcca[0] & 0xff) {
		err("HCCA not aligned!!");
		return -1;
	}
	phcca = &ghcca[0];
	info("aligned ghcca %p", phcca);
	memset(&ohci_dev, 0, sizeof(struct ohci_device));
	if ((__u32)&ohci_dev.ed[0] & 0x7) {
		err("EDs not aligned!!");
		return -1;
	}
	memset(gtd, 0, sizeof(td_t) * (NUM_TD + 1));
	if ((__u32)gtd & 0x7) {
		err("TDs not aligned!!");
		return -1;
	}
	ptd = gtd;
	gohci.hcca = phcca;
	memset (phcca, 0, sizeof (struct ohci_hcca));

	gohci.disabled = 1;
	gohci.sleeping = 0;
	gohci.irq = -1;
	gohci.regs = bus_to_phys(busdevfunc,pci_io_addr);


	gohci.flags = 0;
	gohci.slot_name = "pci-usb";

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-30 13:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-29 19:00 [U-Boot-Users] PCI USB Driver Lance Ware
2007-03-30 13:56 ` Matthias Fuchs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox