More information: if I set the DP bit in OTGSC then the internal DP line is pulled up and enumeration begins. The problem is that no interrupts are generated apart from SOF. I believe the root cause is that when I set the RS bit in the USBCMD_D register the LPC does not pull up DP because it is not seeing voltage on USB0_VBUS. I can't test the connection to the VBUS pin because of the BGA device and that the pin is dedicated, so the function can't be changed, but it does the same thing on two commercially assembled devices, so I doubt it is a bad connection on the LPC chip.
Initialization code is:
// PLL0 is 480 MHz, CLK_M4_USB0 is running, CLK_USB0_CFG is on
LPC_RGU->RESET_CTRL0 = (1<<17);
LPC_USB0->USBCMD_D = USBCMD_RST;
while (LPC_USB0->USBCMD_D & USBCMD_RST);
LPC_USB0->USBMODE_D = USBMODE_CM_DEV | USBMODE_SLOM;
LPC_CREG->CREG0 &= ~(1<<5); // turn on USB0 PHY
USBD_Reset();
USBD_SetAddress(0, FALSE);
LPC_USB0->OTGSC = (1UL<<0) | (1UL<<3); // OTG discharge VBUS, set DM termination pull down
LPC_USB0->PORTSC1_D &= ~(1UL << 24); // HS
LPC_USBx->USBINTR_D = (1UL << 0 ) | (1UL << 2 ) | (1UL << 8 ) | (1UL << 16) | (1UL << 6 ) | (1UL << 7) | (1UL << 1) ;
NVIC_EnableIRQ(USB0_IRQn);
// endpoint setup stuff here ...
LPC_USB0->USBCMD_D |= 1; // connect
When running I see:
LPC_CREG->CREG0 = 0xFIC = 111100011100 = USB0 PHY enabled
LPC_USB0->USBMODE_D = 0xA = 1010 = device, setup lockout off
LPC_USB0->USBSTS_D = 0
LPC_USB0->OTGSC = 0x201109 = vbus dischrg, OTG term, B-device, B session end, 1ms int
LPC_USB0->USBINTR_D = 0x101C7 = USB int, error int, port change int, reset int, SOF int, sleep int
LPC_USB0->PORTSC1_D = 0x3D000804 = port enabled, full speed only, high speed
I think the OTGSC "B-session end" bit being set shows that the VBUS is below 0.8V, which is stopping the LPC from first pulling up DP and then enabling the SIE. No VBUS sensing control on the LPC43xx?