void turnon_mem_rail(int mv) { unsigned int value; HW_POWER_CTRL_CLR(BM_POWER_CTRL_CLKGATE); value = BM_POWER_VDDMEMCTRL_ENABLE_ILIMIT| BM_POWER_VDDMEMCTRL_ENABLE_LINREG| BM_POWER_VDDMEMCTRL_PULLDOWN_ACTIVE| (mv-1700)/50; HW_POWER_VDDMEMCTRL_WR(value); delay(20000); value &= ~(BM_POWER_VDDMEMCTRL_ENABLE_ILIMIT| BM_POWER_VDDMEMCTRL_PULLDOWN_ACTIVE); HW_POWER_VDDMEMCTRL_WR(value); }
//////////////////////////////////////////////////////////////////////////////// //! \brief Prepares the power block for the application. //! //! \return SUCCESS(0) Power block ready. //////////////////////////////////////////////////////////////////////////////// //int PowerPrep( void ) int _start( void ) { int iRtn = SUCCESS; auart_init(); #ifndef mx28 HW_DIGCTL_CTRL_SET(BM_DIGCTL_CTRL_USE_SERIAL_JTAG); #else #define SSP0_PIN_DRIVE_12mA 0x2 // For EMI 200MHz,must enable SSP0 pin drive to 12mA,or the SD boot will fail. HW_PINCTRL_DRIVE8_CLR( BM_PINCTRL_DRIVE8_BANK2_PIN07_MA | BM_PINCTRL_DRIVE8_BANK2_PIN06_MA | BM_PINCTRL_DRIVE8_BANK2_PIN05_MA | BM_PINCTRL_DRIVE8_BANK2_PIN04_MA | BM_PINCTRL_DRIVE8_BANK2_PIN03_MA | BM_PINCTRL_DRIVE8_BANK2_PIN02_MA | BM_PINCTRL_DRIVE8_BANK2_PIN01_MA | BM_PINCTRL_DRIVE8_BANK2_PIN00_MA); HW_PINCTRL_DRIVE9_CLR( BM_PINCTRL_DRIVE9_BANK2_PIN10_MA | BM_PINCTRL_DRIVE9_BANK2_PIN09_MA | BM_PINCTRL_DRIVE9_BANK2_PIN08_MA); HW_PINCTRL_DRIVE8_SET( (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN07_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN06_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN05_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN04_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN03_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN02_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN01_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN00_MA)); HW_PINCTRL_DRIVE9_SET( (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE9_BANK2_PIN10_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE9_BANK2_PIN09_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE9_BANK2_PIN08_MA)); #endif PowerPrep_CPUClock2XTAL(); PowerPrep_ClearAutoRestart(); hw_power_SetPowerClkGate( false ); printf("\r\nPowerPrep start initialize power...\r\n"); HW_POWER_VDDDCTRL.B.LINREG_OFFSET = HW_POWER_LINREG_OFFSET_STEP_BELOW; HW_POWER_VDDACTRL.B.LINREG_OFFSET = HW_POWER_LINREG_OFFSET_STEP_BELOW; HW_POWER_VDDIOCTRL.B.LINREG_OFFSET = HW_POWER_LINREG_OFFSET_STEP_BELOW; // Ready the power block for 5V detection. PowerPrep_Setup5vDetect(); PowerPrep_SetupBattDetect(); // Ensure the power source that turned on the device is sufficient to // power the device. PowerPrep_ConfigurePowerSource(); PowerPrep_EnableOutputRailProtection(); /* 3.3V is necessary to achieve best power supply capability * and best EMI I/O performance. */ ddi_power_SetVddio(3300, 3150); #ifdef mx28 ddi_power_SetVddd(1350, 1200); #endif HW_POWER_CTRL_CLR(BM_POWER_CTRL_VDDD_BO_IRQ | BM_POWER_CTRL_VDDA_BO_IRQ | BM_POWER_CTRL_VDDIO_BO_IRQ | BM_POWER_CTRL_VDD5V_DROOP_IRQ | BM_POWER_CTRL_VBUSVALID_IRQ | BM_POWER_CTRL_BATT_BO_IRQ | BM_POWER_CTRL_DCDC4P2_BO_IRQ ); /* If Battery not ready,setup the auto power down if we lost 5V.*/ if (!bBatteryReady) HW_POWER_5VCTRL_SET(BM_POWER_5VCTRL_PWDN_5VBRNOUT); return iRtn; }
//////////////////////////////////////////////////////////////////////////////// //! \brief Prepares the power block for the application. //! //! \return SUCCESS(0) Power block ready. //////////////////////////////////////////////////////////////////////////////// //int PowerPrep( void ) int _start( void ) { int iRtn = SUCCESS; #ifndef mx28 HW_DIGCTL_CTRL_SET(BM_DIGCTL_CTRL_USE_SERIAL_JTAG); #else #define SSP0_PIN_DRIVE_12mA 0x2 // For EMI 200MHz,must enable SSP0 pin drive to 12mA,or the SD boot will fail. HW_PINCTRL_DRIVE8_CLR( BM_PINCTRL_DRIVE8_BANK2_PIN07_MA | BM_PINCTRL_DRIVE8_BANK2_PIN06_MA | BM_PINCTRL_DRIVE8_BANK2_PIN05_MA | BM_PINCTRL_DRIVE8_BANK2_PIN04_MA | BM_PINCTRL_DRIVE8_BANK2_PIN03_MA | BM_PINCTRL_DRIVE8_BANK2_PIN02_MA | BM_PINCTRL_DRIVE8_BANK2_PIN01_MA | BM_PINCTRL_DRIVE8_BANK2_PIN00_MA); HW_PINCTRL_DRIVE9_CLR( BM_PINCTRL_DRIVE9_BANK2_PIN10_MA | BM_PINCTRL_DRIVE9_BANK2_PIN09_MA | BM_PINCTRL_DRIVE9_BANK2_PIN08_MA); HW_PINCTRL_DRIVE8_SET( (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN07_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN06_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN05_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN04_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN03_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN02_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN01_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE8_BANK2_PIN00_MA)); HW_PINCTRL_DRIVE9_SET( (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE9_BANK2_PIN10_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE9_BANK2_PIN09_MA) | (SSP0_PIN_DRIVE_12mA << BP_PINCTRL_DRIVE9_BANK2_PIN08_MA)); #endif PowerPrep_CPUClock2XTAL(); PowerPrep_ClearAutoRestart(); hw_power_SetPowerClkGate( false ); printf("\r\nPowerPrep start initialize power...\r\n"); HW_POWER_VDDDCTRL.B.LINREG_OFFSET = HW_POWER_LINREG_OFFSET_STEP_BELOW; HW_POWER_VDDACTRL.B.LINREG_OFFSET = HW_POWER_LINREG_OFFSET_STEP_BELOW; HW_POWER_VDDIOCTRL.B.LINREG_OFFSET = HW_POWER_LINREG_OFFSET_STEP_BELOW; // Ready the power block for 5V detection. PowerPrep_Setup5vDetect(); PowerPrep_SetupBattDetect(); // Ensure the power source that turned on the device is sufficient to // power the device. PowerPrep_ConfigurePowerSource(); PowerPrep_EnableOutputRailProtection(); /* 3.3V is necessary to achieve best power supply capability * and best EMI I/O performance. */ ddi_power_SetVddio(3300, 3150); HW_POWER_CTRL_CLR(BM_POWER_CTRL_VDDD_BO_IRQ | BM_POWER_CTRL_VDDA_BO_IRQ | BM_POWER_CTRL_VDDIO_BO_IRQ | BM_POWER_CTRL_VDD5V_DROOP_IRQ | BM_POWER_CTRL_VBUSVALID_IRQ | BM_POWER_CTRL_BATT_BO_IRQ | BM_POWER_CTRL_DCDC4P2_BO_IRQ ); /* If Battery not ready,setup the auto power down if we lost 5V.*/ if (!bBatteryReady) { HW_POWER_5VCTRL_SET(BM_POWER_5VCTRL_PWDN_5VBRNOUT); #if defined(NO_DCDC_BATT_SOURCE) && defined(mx28) /* On i.MX28, a new bit has been added to allow automatic hardware * shutdown if VDD4P2 browns out. If we permanently only have a VDD5V * source, we want to enable this bit. For devices with dead batteries, * we could also temporarily set this bit until the kernel battery * charger sufficiently charges the battery but we won't do this for * now as the latest release kernel versions aren't aware of it * and thus don't handle the proper setting/clearing of this bit. */ HW_POWER_REFCTRL_SET(1<<7); #endif } return iRtn; }
/* called during probe() after chip reset completes */ static int ehci_fsl_setup(struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); int retval; struct fsl_usb2_platform_data *pdata; pdata = hcd->self.controller->platform_data; ehci->big_endian_desc = pdata->big_endian_desc; ehci->big_endian_mmio = pdata->big_endian_mmio; /* EHCI registers start at offset 0x100 */ ehci->caps = hcd->regs + 0x100; ehci->regs = hcd->regs + 0x100 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); dbg_hcs_params(ehci, "reset"); dbg_hcc_params(ehci, "reset"); /* cache this readonly data; minimize chip reads */ ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); retval = ehci_halt(ehci); /* data structure init */ retval = ehci_init(hcd); if (retval) return retval; hcd->has_tt = 1; ehci->sbrn = 0x20; ehci_reset(ehci); retval = ehci_fsl_reinit(ehci); #ifdef CHUMBY_USB_MODIFICATIONS /* Also, disable the IRQ for the 5V line. Turning on the screen causes * a massive drop in power, and the battery circuitry thinks we've * pulled the 5V line. */ HW_POWER_CTRL_CLR(1); /* Wait just enough time for the brownout. Any less than this and it * reboots when we bring the USB card up, or segfaults. */ msleep(5); /* Set bank 0, pins 26 and 28 to GPIO. */ HW_PINCTRL_MUXSEL1_SET(0x03300000); /* Set both pins to low, which ensures a reset takes place. */ HW_PINCTRL_DOUT0_CLR(0x24000000); HW_PINCTRL_DOE0_SET(0x24000000); HW_PINCTRL_DOUT0_CLR(0x24000000); msleep(5); /* Delay for one second, giving most USB devices the chance to * recognize they've been "unplugged". */ msleep(1000); /* Write a "1" to bank 0, pin 28. */ HW_PINCTRL_DOUT0_SET(0x20000000); msleep(5); /* Write a "1" to bank 0, pin 26, to disable USB. This ensures a reset. * Wait a short time after, then re-enable the IRQ that fires when power * is pulled. This is because by now, the voltages should have * stabilized. */ HW_PINCTRL_DOUT0_SET(0x04000000); msleep(5); /* Re-enable the power interrupt. */ HW_POWER_CTRL_SET(1); #endif /*CHUMBY_USB_MODIFICATIONS*/ return retval; }