overdue-scratch

Author Topic: Backporting the Meklort patches for auto patching mach_kernel's CPUID panic etc.  (Read 63805 times)

0 Members and 2 Guests are viewing this topic.

THe KiNG

  • Observer
  • Posts: 10
@ Slice is not working:
Quote
Jan 28 17:10:37 localhost kernel[0]: USBF:   4.729   AppleUSBOHCI[0x4c6d000]::InitializeOperationalRegisters Non-NULL hcDoneHead: 0xbfd9d620

Code: [Select]
UHCI controller [10de:0aa5] at 00:04.0 base 0(0)
Setting Legacy USB Off on controller [10de:0aa6] at 00:04.1
Legacy USB Off Done
EHCI controller [10de:0aa6] at 00:04.1 DMA @d3109200
UHCI controller [10de:0aa7] at 00:06.0 base 0(0)
Setting Legacy USB Off on controller [10de:0aa9] at 00:06.1
Legacy USB Off Done
EHCI controller [10de:0aa9] at 00:06.1 DMA @d3109100


I'm looking on Linux code: http://lxr.free-electrons.com/source/drivers/usb/host/pci-quirks.c
OHCI reset is not the same as UHCI one...
« Last Edit: January 28, 2011, 04:26:02 PM by THe KiNG »

THe KiNG

  • Observer
  • Posts: 10
OK, I gave up coding is not my thing, need help.
Linux code:
Code: [Select]
static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
{
void __iomem *base;
u32 control;

if (!mmio_resource_enabled(pdev, 0))
return;

base = pci_ioremap_bar(pdev, 0);
if (base == NULL)
return;

control = readl(base + OHCI_CONTROL);

...

/* reset controller, preserving RWC (and possibly IR) */
writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL);

/*
* disable interrupts
*/
writel(~(u32)0, base + OHCI_INTRDISABLE);
writel(~(u32)0, base + OHCI_INTRSTATUS);

iounmap(base);
}

What I did(don't laugh):
Code: [Select]
int uhci_reset (pci_dt_t *pci_dev)
{
uint32_t base, control;
#define OHCI_CTRL_MASK (1 << 9)
#define OHCI_CONTROL 0x04
#define OHCI_INTRDISABLE 0x14
#define OHCI_INTRSTATUS 0x0c

base = pci_config_read32(pci_dev->dev.addr, 0x10);
control = base + OHCI_CONTROL;

verbose("OHCI controller [%04x:%04x] at %02x:%2x.%x control %x(base %x)\n",
pci_dev->vendor_id, pci_dev->device_id,
pci_dev->dev.bits.bus, pci_dev->dev.bits.dev, pci_dev->dev.bits.func,
control, base);

/* reset controller, preserving RWC (and possibly IR) */

outl (control & OHCI_CTRL_MASK, control);
delay(10);

/*
* disable interrupts
*/
outl(~(UInt32)0, base + OHCI_INTRDISABLE);
outl(~(UInt32)0, base + OHCI_INTRSTATUS);
return 1;
}

Code: [Select]
OHCI controller [10de:0aa5] at 00:04.0 control d3108004(base d3108000)
Setting Legacy USB Off on controller [10de:0aa6] at 00:04.1
Legacy USB Off Done
EHCI controller [10de:0aa6] at 00:04.1 DMA @d3109200
OHCI controller [10de:0aa7] at 00:06.0 control d3107004(base d3107000)
Setting Legacy USB Off on controller [10de:0aa9] at 00:06.1
Legacy USB Off Done
EHCI controller [10de:0aa9] at 00:06.1 DMA @d3109100
Is not OK since I still get that damn message from apple driver, so what I did wrong?

Kabyl

  • VoodooLabs
  • Posts: 158
You want to do something like this:
Code: [Select]
...
*(uint32_t *)(base + OHCI_CONTROL) = control & OHCI_CTRL_MASK;
...

Is disabling interrupts needed?

Slice

  • VoodooLabs
  • Posts: 52
And before
Code: [Select]
control = *(base + OHCI_CONTROL);
Because of absence of other experience I was considering my patch is enough
Code: [Select]
execute_hook: Executing 'Kernel Start' with callback 0x83A293B.
UHCI controller [1002:4347] at 00:13.0 base 0(0) reset
UHCI controller [1033:0035] at 02:06.0 base 0(0) reset
UHCI controller [1033:0035] at 02:06.1 base 0(0) reset
Setting Legacy USB Off on controller [1033:00e0] at 02:06.2
Legacy USB Off Done
EHCI controller [1033:00e0] at 02:06.2 DMA @c0200800
EHCI Acquire OS Ownership done
execute_hook: Hook 'Kernel Start' executed.
Without the patch I see 100 messages and USB is not working during 2 minutes after start.
Now all seems to be OK. Kernel.log is clean.
My be in my case this reset is not needed.
I just need to implement cosmetics UHCI ->OHCI.

Slice

  • VoodooLabs
  • Posts: 52
Is disabling interrupts needed?
Linux made
Code: [Select]
writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
...
writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL);
...
writel(~(u32)0, base + OHCI_INTRDISABLE);
Not sure it is needed in our case (OSX).

I propose the procedure should be as follow
Code: [Select]
int ohci_handsoff (pci_dt_t *pci_dev)
{
uint32_t base, control;
#define OHCI_CTRL_MASK (1 << 9)
#define OHCI_CONTROL 0x04
#define OHCI_INTRDISABLE 0x14
#define OHCI_INTRSTATUS 0x0c

base = pci_config_read32(pci_dev->dev.addr, 0x10);
msglog("OHCI controller [%04x:%04x] at %02x:%2x.%x base %x reset\n",
   pci_dev->vendor_id, pci_dev->device_id,
   pci_dev->dev.bits.bus, pci_dev->dev.bits.dev, pci_dev->dev.bits.func,
   base);

control = *(uint32_t *)(base + OHCI_CONTROL);
*(uint32_t *)(base + OHCI_CONTROL) = control & OHCI_CTRL_MASK;
return 1;
}
tests needed.

Linux also has a patch for XHCI (USB3.0?). Is it a time to implement it also?
« Last Edit: January 29, 2011, 06:00:05 PM by Slice »

THe KiNG

  • Observer
  • Posts: 10
Still not working:
Code: [Select]
Starting Darwin x86
OHCI controller [10de:0aa5] at 00:04.0 base d3108000 reset
OHCI controller [10de:0aa7] at 00:06.0 base d3107000 reset

Quote
Jan 30 17:07:37 localhost kernel[0]: USBF:   2.134   AppleUSBOHCI[0x4c6b000]::InitializeOperationalRegisters Non-NULL hcDoneHead: 0xbfd9d620

I will look better on what apple does to clean the hcDoneHead

L.E. Again ACPI saved me...much more easier to do it, for some reason same thing on boot loader has no effect, but it does with DSDT help.
Case closed, now I can remove USB module from boot loader.
« Last Edit: January 31, 2011, 08:41:31 AM by THe KiNG »