riverajl
Posts: 10
Joined: Thu Dec 06, 2018 10:03 am

Re: CSUD - Chadderz's Simple USB Driver (Source)

Tue Dec 11, 2018 11:01 am

Hi, thanks.

I already did this interfacing with mailbox. I will try tonight.

Att,

José Luiz

riverajl
Posts: 10
Joined: Thu Dec 06, 2018 10:03 am

Re: CSUD - Chadderz's Simple USB Driver (Source)

Tue Dec 11, 2018 9:01 pm

It worked.

Thanks a lot

riverajl
Posts: 10
Joined: Thu Dec 06, 2018 10:03 am

Re: CSUD - Chadderz's Simple USB Driver (Source)

Wed Dec 12, 2018 10:23 am

Dear. Does your single source for csud solution implements interrupt for usb?

If not, is there any direction for getting it?

Tkanks.

José Luiz

LdB
Posts: 1169
Joined: Wed Dec 07, 2016 2:29 pm

Re: CSUD - Chadderz's Simple USB Driver (Source)

Wed Dec 12, 2018 2:32 pm

It doesn't have it .. but given you got the rest sorted you have the skill to do it

Below is the register setup on DWC core itself to pass the interrupt out to the ARM
The 3rd section interrupt handler I assume you already have or will do yourself I will throw a sample of it at end

Code: Select all

static void dwc_setup_interrupts(void)
{
    union dwc_core_interrupts core_interrupt_mask;

    /* Clear all pending core interrupts.  */
    regs->core_interrupt_mask.val = 0;
    regs->core_interrupts.val = 0xffffffff;

    /* Enable core host channel and port interrupts.  */
    core_interrupt_mask.val = 0;
    core_interrupt_mask.host_channel_intr = 1;
    core_interrupt_mask.port_intr = 1;
    regs->core_interrupt_mask = core_interrupt_mask;

    /* Enable the interrupt line that goes to the USB controller and register
     * the interrupt handler.  .... You will need to do this yourself */
    interruptVector[IRQ_USB] = dwc_interrupt_handler;
    enable_irq(IRQ_USB);

    /* Enable interrupts for entire USB host controller.  (Yes that's what we
     * just did, but this one is controlled by the host controller itself.)  */
    regs->ahb_configuration |= DWC_AHB_INTERRUPT_ENABLE;
}
You simply have to respond to each interrupt, read the interrupt source and clear it like any peripheral interrupt.

So this is my multicore version of an irq system, in your case you probably only want 1 core so just hard code coreId as 0 you can even simplify it.
It just reads the 3 interrupts registers on the ARM and assign numbers to the interrupts. Those irq's are numbered
0..83 assuming a Pi3 (72 on a Pi1) and you can assign a function to call if that irq is seen etc I am sure you will understand it.
It ends up pretty much as the table on Page 113 of the datasheet BCM2835-ARM-Peripherals.pdf
From memory the usb is bit9 in the pending1 register so on my system it will be Irq 41

You direct your irq vector table entry in your bootstub to here

Code: Select all

/* Entry point for all core interrupt handlers, each core must direct it's Irq vector to here */
void irqHandler(void);
Anyhow here is the system .. hopefully it helps mainly look at rpi-Irq.c
https://github.com/LdB-ECM/Exchange/tree/master/Irq

riverajl
Posts: 10
Joined: Thu Dec 06, 2018 10:03 am

Re: CSUD - Chadderz's Simple USB Driver (Source)

Wed Dec 12, 2018 6:16 pm

I already have used interrupts.

There are ever a register to enable, to disable, to know the source and to clear the irq pending. Searching BCM2837 datasheet I could not find any register to clear USB interrupt.

Is there any one?

Tks

LdB
Posts: 1169
Joined: Wed Dec 07, 2016 2:29 pm

Re: CSUD - Chadderz's Simple USB Driver (Source)

Wed Dec 12, 2018 11:32 pm

The clear is on the peripheral not the BCM system on chip.
CSUD .... designware20.h and look at the interrupt registers.

User avatar
Ultibo
Posts: 158
Joined: Wed Sep 30, 2015 10:29 am
Location: Australia
Contact: Website

Re: CSUD - Chadderz's Simple USB Driver (Source)

Thu Dec 13, 2018 11:31 pm

riverajl wrote:
Wed Dec 12, 2018 6:16 pm
I already have used interrupts.

There are ever a register to enable, to disable, to know the source and to clear the irq pending. Searching BCM2837 datasheet I could not find any register to clear USB interrupt.

Is there any one?

Tks
The documentation for the USB host in the Pi has never been made public so anything that is known comes from existing sources.

If you are interested in going beyond the capabilities of the CSUD driver you might want to look at some of the other projects that implement much more of the functionality including interrupts.

Here's a few to look at:

Circle (https://github.com/rsta2/circle)

USPi (https://github.com/rsta2/uspi)

XINU (https://github.com/xinu-os/xinu)

Ultibo (https://github.com/ultibohub/Core)
Ultibo.org | Make something amazing
https://ultibo.org

Threads, multi-core, OpenGL, Camera, FAT, NTFS, TCP/IP, USB and more in 3MB with 2 second boot!

Return to “Bare metal, Assembly language”