static int __init twl4030_usb_probe(struct platform_device *pdev) { struct twl4030_usb_data *pdata = pdev->dev.platform_data; struct twl4030_usb *twl; int status; twl = kzalloc(sizeof *twl, GFP_KERNEL); if (!twl) return -ENOMEM; if (!pdata) { dev_info(&pdev->dev, "platform_data not available\n"); return -EINVAL; } wake_lock_init(&twl->wake_lock, WAKE_LOCK_SUSPEND, "twl_usb"); twl->dev = &pdev->dev; twl->irq = platform_get_irq(pdev, 0); twl->otg.dev = twl->dev; twl->otg.label = "twl4030"; twl->otg.set_host = twl4030_set_host; twl->otg.set_peripheral = twl4030_set_peripheral; twl->otg.set_suspend = twl4030_set_suspend; twl->usb_mode = pdata->usb_mode; twl->asleep = 1; t2_transceiver = twl; t2_transceiver->link_context_restore_and_wakeup = NULL; /* init spinlock for workqueue */ spin_lock_init(&twl->lock); twl4030_usb_ldo_init(twl); otg_set_transceiver(&twl->otg); platform_set_drvdata(pdev, twl); if (device_create_file(&pdev->dev, &dev_attr_vbus)) dev_warn(&pdev->dev, "could not create sysfs file\n"); /* Our job is to use irqs and status from the power module * to keep the transceiver disabled when nothing's connected. * * FIXME we actually shouldn't start enabling it until the * USB controller drivers have said they're ready, by calling * set_host() and/or set_peripheral() ... OTG_capable boards * need both handles, otherwise just one suffices. */ twl->irq_enabled = true; status = request_irq(twl->irq, twl4030_usb_irq, IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, "twl4030_usb", twl); if (status < 0) { dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n", twl->irq, status); kfree(twl); return status; } #if defined(USB_LAT_CONST) && defined(CONFIG_OMAP3_PM) /* Get handle to USB Constraint for OFF/RETENTION */ twl->usb_power_constraint = constraint_get("usb", &cnstr_id); #endif #if 0 /* FIXME-TI: check this logic */ <<<<<<< HEAD:drivers/i2c/chips/twl4030-usb.c
PVRSRV_ERROR EnableSystemClocks(SYS_DATA *psSysData) { SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; struct clk *psCLK; IMG_INT res; PVRSRV_ERROR eError; IMG_BOOL bPowerLock; #if defined(DEBUG) || defined(TIMING) IMG_INT rate; struct clk *sys_ck; IMG_CPU_PHYADDR TimerRegPhysBase; IMG_HANDLE hTimerEnable; IMG_UINT32 *pui32TimerEnable; #endif PVR_TRACE(("EnableSystemClocks: Enabling System Clocks")); if (!psSysSpecData->bSysClocksOneTimeInit) { bPowerLock = IMG_FALSE; spin_lock_init(&psSysSpecData->sPowerLock); atomic_set(&psSysSpecData->sPowerLockCPU, -1); spin_lock_init(&psSysSpecData->sNotifyLock); atomic_set(&psSysSpecData->sNotifyLockCPU, -1); atomic_set(&psSysSpecData->sSGXClocksEnabled, 0); psCLK = clk_get(NULL, "sgx_ck"); if (IS_ERR(psCLK)) { PVR_DPF((PVR_DBG_ERROR, "EnableSsystemClocks: Couldn't get SGX Functional Clock")); goto ExitError; } psSysSpecData->psSGX_FCK = psCLK; psSysSpecData->bSysClocksOneTimeInit = IMG_TRUE; } else { bPowerLock = PowerLockWrappedOnCPU(psSysSpecData); if (bPowerLock) { PowerLockUnwrap(psSysSpecData); } } #if defined(CONSTRAINT_NOTIFICATIONS) psSysSpecData->pVdd2Handle = constraint_get(PVRSRV_MODNAME, &cnstr_id_vdd2); if (IS_ERR(psSysSpecData->pVdd2Handle)) { PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't get VDD2 constraint handle")); goto ExitError; } RegisterConstraintNotifications(); #endif #if defined(DEBUG) || defined(TIMING) if(cpu_is_ti816x()) { psCLK = clk_get(NULL, "gpt6_fck"); } else { psCLK = clk_get(NULL, "gpt7_fck"); } if (IS_ERR(psCLK)) { PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't get GPTIMER11 functional clock")); goto ExitUnRegisterConstraintNotifications; } psSysSpecData->psGPT11_FCK = psCLK; if(cpu_is_ti816x()) { psCLK = clk_get(NULL, "gpt6_ick"); } else { psCLK = clk_get(NULL, "gpt7_ick"); } if (IS_ERR(psCLK)) { PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't get GPTIMER11 interface clock")); goto ExitUnRegisterConstraintNotifications; } psSysSpecData->psGPT11_ICK = psCLK; rate = clk_get_rate(psSysSpecData->psGPT11_FCK); PVR_TRACE(("GPTIMER11 clock is %dMHz", HZ_TO_MHZ(rate))); res = clk_enable(psSysSpecData->psGPT11_FCK); if (res < 0) { PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't enable GPTIMER11 functional clock (%d)", res)); goto ExitUnRegisterConstraintNotifications; } res = clk_enable(psSysSpecData->psGPT11_ICK); if (res < 0) { PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't enable GPTIMER11 interface clock (%d)", res)); goto ExitDisableGPT11FCK; } TimerRegPhysBase.uiAddr = SYS_TI81xx_GP7TIMER_TSICR_SYS_PHYS_BASE; pui32TimerEnable = OSMapPhysToLin(TimerRegPhysBase, 4, PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, &hTimerEnable); if (pui32TimerEnable == IMG_NULL) { PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: OSMapPhysToLin failed")); goto ExitDisableGPT11ICK; } rate = *pui32TimerEnable; if(!(rate & 4)) { PVR_TRACE(("Setting GPTIMER11 mode to posted (currently is non-posted)")); *pui32TimerEnable = rate | 4; } OSUnMapPhysToLin(pui32TimerEnable, 4, PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, hTimerEnable); TimerRegPhysBase.uiAddr = SYS_TI81xx_GP7TIMER_ENABLE_SYS_PHYS_BASE; pui32TimerEnable = OSMapPhysToLin(TimerRegPhysBase, 4, PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, &hTimerEnable); if (pui32TimerEnable == IMG_NULL) { PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: OSMapPhysToLin failed")); goto ExitDisableGPT11ICK; } *pui32TimerEnable = 3; OSUnMapPhysToLin(pui32TimerEnable, 4, PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, hTimerEnable); #endif #if defined(PDUMP) && !defined(NO_HARDWARE) && defined(CONSTRAINT_NOTIFICATIONS) PVR_TRACE(("EnableSystemClocks: Setting SGX OPP constraint")); res = constraint_set(psSysSpecData->pVdd2Handle, max_vdd2_opp); if (res != 0) { PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: constraint_set failed (%d)", res)); goto ExitConstraintSetFailed; } #endif eError = PVRSRV_OK; goto Exit; #if defined(PDUMP) && !defined(NO_HARDWARE) && defined(CONSTRAINT_NOTIFICATIONS) ExitConstraintSetFailed: #endif #if defined(DEBUG) || defined(TIMING) ExitDisableGPT11ICK: clk_disable(psSysSpecData->psGPT11_ICK); ExitDisableGPT11FCK: clk_disable(psSysSpecData->psGPT11_FCK); ExitUnRegisterConstraintNotifications: #endif #if defined(CONSTRAINT_NOTIFICATIONS) UnRegisterConstraintNotifications(); constraint_put(psSysSpecData->pVdd2Handle); #endif Exit: if (bPowerLock) { PowerLockWrap(psSysSpecData); } ExitError: eError = PVRSRV_ERROR_DISABLE_CLOCK_FAILURE; return eError; }