static void Adt7461Isr(void* arg) { NvU8 Data; ADT7461PrivData* pPrivData = (ADT7461PrivData*)arg; NvOdmInterruptHandler volatile Callback = pPrivData->Callback; void* volatile CallbackArg = pPrivData->CallbackArg; const ADT7461RegisterInfo* pReg = NULL; if (Callback && CallbackArg) { Callback(CallbackArg); } #if ADT7461_ALERT_DEBOUNCE // New range limits set by callback are not guaranteed to take effect // before the next temperature conversion is completed, and interrupt // can not be cleared until then. Hence, the debounce delay below. NvOdmOsSleepMS(s_Adt7461SampleIntervalsMS[pPrivData->ShadowRate] + s_Adt7461ConversionTimesMS[pPrivData->ShadowRate] + 1); #endif // Read status and ARA to finish clearing interrupt after callback pReg = &pPrivData->pDeviceInfo->Status; (void)Adt7461ReadReg(pPrivData, pReg, &Data); Adt7461ReadAra(pPrivData); // Re-enable interrupt if (pPrivData->hGpioIntr) NvOdmGpioInterruptDone(pPrivData->hGpioIntr); }
void Set_MAX14526_Charger_Detect(NvU8 int_status_reg) { NvU8 reg_value; printk("-->> MUIC : %s\n",__func__); // charger type detection (0x02=0x02) Set_MAX14526_ADDR(CTRL2_REG, CHG_TYPE_M); // This line should be modified by a customer. NvOdmOsSleepMS(250); // Read INT_STAT_REG (0x04) reg_value = Get_MAX14526_ADDR(INT_STAT_REG); // Read STATUS_REG (0x05) reg_value = Get_MAX14526_ADDR(STATUS_REG); if (reg_value & CHPORT_M){ // High Current Host/Hub Detected printk("MUIC : %s:%d CHPORT \n",__func__,__LINE__); // Enable 200K, Charger Pump, and ADC (0x01=0x13) Set_MAX14526_ADDR(CTRL1_REG, ID_200_M | ADC_EN_M | CP_EN_M); // COMP2 to DP2 /COMN1 to DN1 (0x03=0x00) Set_MAX14526_ADDR(SW_CTRL_REG, COMN1_TO_DN1 | COMP2_TO_DP2); /* Enable charger IC in TA mode */ //20100526, [email protected], Enable charger IC in TA mode [START] #if defined(CONFIG_STAR_BATTERY_CHARGER) lprintk(D_MUIC, "%s: CHG_IC_TA_MODE(%d) \n", __func__, CHG_IC_TA_MODE); charging_ic_active(CHG_IC_TA_MODE); #endif /* CONFIG_STAR_BATTERY_CHARGER */ //20100526, [email protected], Enable charger IC in TA mode [END] wake_lock(&s_hMuicHandle.wlock); current_device = DEVICE_USB_CABLE; } else{ // Dedicated Charger(TA) Detected printk("MUIC : %s:%d ELSE \n",__func__,__LINE__); // COMP2 to H-Z /COMN1 to H-Z (0x03=0x24) Set_MAX14526_ADDR(SW_CTRL_REG, COMP2_TO_HZ | COMN1_TO_HZ); /* Enable charger IC in TA mode */ //20100526, [email protected], Enable charger IC in TA mode [START] #if defined(CONFIG_STAR_BATTERY_CHARGER) lprintk(D_MUIC, "%s: CHG_IC_TA_MODE(%d) \n", __func__, CHG_IC_TA_MODE); charging_ic_active(CHG_IC_TA_MODE); #endif /* CONFIG_STAR_BATTERY_CHARGER */ //20100526, [email protected], Enable charger IC in TA mode [END] current_device = DEVICE_TA_CHARGER; } // Enable 200K, Charger Pump, and ADC (0x01=0x13) Set_MAX14526_ADDR(CTRL1_REG, ID_200_M | ADC_EN_M | CP_EN_M); // Enable Interrupts (0x02 = 0x40) Set_MAX14526_ADDR(CTRL2_REG, INT_EN_M); }
NvOdmUsbUlpiHandle NvOdmUsbUlpiOpen(NvU32 Instance) { NvOdmUsbUlpi *pDevice = NULL; NvU32 ClockInstances[MAX_CLOCKS]; NvU32 ClockFrequencies[MAX_CLOCKS]; NvU32 NumClocks; NvOdmServicesGpioHandle hGpio; NvOdmGpioPinHandle hResetPin; NvU32 Port = NVODM_PORT('v'); NvU32 Pin = 1; pDevice = NvOdmOsAlloc(sizeof(NvOdmUsbUlpi)); if (pDevice == NULL) return NULL; if(!NvOdmExternalClockConfig(SMSC3317GUID, NV_FALSE, ClockInstances, ClockFrequencies, &NumClocks)) { NvOdmOsDebugPrintf("NvOdmUsbUlpiOpen: NvOdmExternalClockConfig fail\n"); goto ExitUlpiOdm; } NvOdmOsSleepMS(10); // Pull high on RESETB ( 22nd pin of smsc3315) hGpio = NvOdmGpioOpen(); hResetPin = NvOdmGpioAcquirePinHandle(hGpio, Port, Pin); // config as out put pin NvOdmGpioConfig(hGpio,hResetPin, NvOdmGpioPinMode_Output); // Set low to write high on ULPI_RESETB pin NvOdmGpioSetState(hGpio, hResetPin, 0x01); NvOdmGpioSetState(hGpio, hResetPin, 0x0); NvOdmOsSleepMS(5); NvOdmGpioSetState(hGpio, hResetPin, 0x01); pDevice->CurrentGUID = SMSC3317GUID; return pDevice; ExitUlpiOdm: NvOdmOsFree(pDevice); return NULL; }
static NvBool TPK_SetPage (TPK_TouchDevice* hTouch, NvU8 page) { #if TPK_PAGE_CHANGE_DELAY NvU32 SetPageDelayMs = 100; //Wait for 100 millisecond after change page #endif if (!TPK_WRITE(hTouch, TPK_PAGE_SELECT, page)) return NV_FALSE; #if TPK_PAGE_CHANGE_DELAY NvOdmOsSleepMS(SetPageDelayMs); #endif return NV_TRUE; }
static void tegra_onetouch_early_suspend(struct early_suspend *es) { struct tegra_onetouch_driver_data *onetouch; onetouch = container_of(es, struct tegra_onetouch_driver_data, early_suspend); printk("[ONETOUCH] tegra_onetouch_early_suspend\n"); if (onetouch && onetouch->hOneTouchDevice) { NvOdmOneTouchInterruptMask(onetouch->hOneTouchDevice, NV_TRUE); NvOdmOsSleepMS(50); if(onetouch->isReset){ NvOdmOsSleepMS(50); onetouch->isReset = 0; } if (!NvOdmOneTouchSleepMode(onetouch->hOneTouchDevice, NV_TRUE)) pr_err("[ONETOUCH] tegra_onetouch_suspend: fail onetouch sleepmode\n"); } else { pr_err("[ONETOUCH] tegra_touch_early_suspend: NULL handles passed\n"); } return; }
static void tegra_onetouch_shutdown(struct platform_device *pdev) { struct tegra_onetouch_driver_data *onetouch = platform_get_drvdata(pdev); printk("[ONETOUCH] tegra_onetouch_shutdown() \n"); #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&onetouch->early_suspend); #endif onetouch->shutdown = 1; NvOdmOneTouchInterruptMask(onetouch->hOneTouchDevice, NV_TRUE); NvOdmOsSleepMS(50); NvOdmOsSemaphoreDestroy(onetouch->semaphore); NvOdmOneTouchDeviceClose(onetouch->hOneTouchDevice); input_unregister_device(onetouch->input_dev); kfree(onetouch); return; }
static void star_vib_work_func(struct work_struct *work) { u32 gpio_state = 0; #if VIB_DEBUG printk("vibrator test... value = %d\n", toggle); #endif NvOdmGpioConfig( g_vib->h_vib_gpio, g_vib->h_vib_gpio_pin, NvOdmGpioPinMode_Output); NvOdmGpioSetState( g_vib->h_vib_gpio, g_vib->h_vib_gpio_pin, toggle ); if( toggle == 0 ) toggle++; else toggle = 0; NvOdmGpioGetState(g_vib->h_vib_gpio, g_vib->h_vib_gpio_pin, &gpio_state); #if VIB_DEBUG printk("[skhwang] VIB_EN = %d\n", gpio_state); #endif NvOdmOsSleepMS(1000); schedule_delayed_work(&g_vib->delayed_work_vib,150); }
static int __init muic_probe(struct platform_device *pdev) { int i, j, ret; #ifdef _MUIC_GPIO_I2C_ int ret_val; #else NvU32 I2cInstance = 0; #endif #if defined(CONFIG_MACH_STAR_REV_D) || defined(CONFIG_MACH_STAR_REV_E) || defined(CONFIG_MACH_STAR_REV_F) NvU32 pin[5], port[5]; #else NvU32 pin[4], port[4]; #endif const NvOdmPeripheralConnectivity *pConnectivity = NULL; printk(KERN_INFO "muic_probe\n"); pConnectivity = NvOdmPeripheralGetGuid(MUIC_GUID); for (i = 0, j = 0 ; i < pConnectivity->NumAddress; i++) { switch (pConnectivity->AddressList[i].Interface) { #ifndef _MUIC_GPIO_I2C_ case NvOdmIoModule_I2c: s_hMuicHandle.DeviceAddr = (pConnectivity->AddressList[i].Address << 1); I2cInstance = pConnectivity->AddressList[i].Instance; break; #endif case NvOdmIoModule_Gpio: port[j] = pConnectivity->AddressList[i].Instance; pin[j] = pConnectivity->AddressList[i].Address; j++; break; default: break; } } s_hMuicHandle.hGpio = NvOdmGpioOpen(); if (!s_hMuicHandle.hGpio) { lprintk(D_MUIC, "%s: NvOdmGpioOpen Error \n", __func__); goto err_open_gpio_fail; } s_hMuicHandle.h_INT_N_MUIC = NvOdmGpioAcquirePinHandle(s_hMuicHandle.hGpio, port[0], pin[0]); if (!s_hMuicHandle.h_INT_N_MUIC) { lprintk(D_MUIC, "%s: Couldn't NvOdmGpioAcquirePinHandle pin \n", __func__); goto err_open_gpio_pin_acquire_fail; } s_hMuicHandle.h_AP20_UART_SW = NvOdmGpioAcquirePinHandle(s_hMuicHandle.hGpio, port[1], pin[1]); if (!s_hMuicHandle.h_AP20_UART_SW) { lprintk(D_MUIC, "%s:Couldn't NvOdmGpioAcquirePinHandle pin \n", __func__); goto err_open_gpio_pin_acquire_fail; } s_hMuicHandle.h_IFX_UART_SW = NvOdmGpioAcquirePinHandle(s_hMuicHandle.hGpio, port[2], pin[2]); if (!s_hMuicHandle.h_IFX_UART_SW) { lprintk(D_MUIC, "%s:Couldn't NvOdmGpioAcquirePinHandle pin \n", __func__); goto err_open_gpio_pin_acquire_fail; } s_hMuicHandle.h_USIF1_SW = NvOdmGpioAcquirePinHandle(s_hMuicHandle.hGpio, port[3], pin[3]); if (!s_hMuicHandle.h_USIF1_SW) { lprintk(D_MUIC, "%s: Couldn't NvOdmGpioAcquirePinHandle pin \n", __func__); goto err_open_gpio_pin_acquire_fail; } #if defined(CONFIG_MACH_STAR_REV_D) || defined(CONFIG_MACH_STAR_REV_E) || defined(CONFIG_MACH_STAR_REV_F) s_hMuicHandle.h_USB_VBUS_EN = NvOdmGpioAcquirePinHandle(s_hMuicHandle.hGpio, port[4], pin[4]); if (!s_hMuicHandle.h_USB_VBUS_EN) { lprintk(D_MUIC, "%s: Couldn't NvOdmGpioAcquirePinHandle pin \n", __func__); goto err_open_gpio_pin_acquire_fail; } #endif NvOdmGpioConfig(s_hMuicHandle.hGpio, s_hMuicHandle.h_INT_N_MUIC, NvOdmGpioPinMode_InputData); NvOdmGpioConfig(s_hMuicHandle.hGpio, s_hMuicHandle.h_AP20_UART_SW, NvOdmGpioPinMode_Output); NvOdmGpioConfig(s_hMuicHandle.hGpio, s_hMuicHandle.h_IFX_UART_SW, NvOdmGpioPinMode_Output); NvOdmGpioConfig(s_hMuicHandle.hGpio, s_hMuicHandle.h_USIF1_SW, NvOdmGpioPinMode_Output); #if defined(CONFIG_MACH_STAR_REV_D) || defined(CONFIG_MACH_STAR_REV_E) || defined(CONFIG_MACH_STAR_REV_F) NvOdmGpioConfig(s_hMuicHandle.hGpio, s_hMuicHandle.h_USB_VBUS_EN, NvOdmGpioPinMode_Output); #endif #ifdef _MUIC_GPIO_I2C_ ret_val = MUIC_Gpio_i2c_init(&s_hMuicHandle); if (ret_val < 0) { lprintk(D_MUIC, "%s: MUIC_Gpio_i2c_init Error \n", __func__); goto err_open_i2c_handle; } #else s_hMuicHandle.hOdmI2c = NvOdmI2cOpen(NvOdmIoModule_I2c, I2cInstance); if (!s_hMuicHandle.hOdmI2c) { lprintk(D_MUIC, "%s: NvOdmI2cOpen Error \n", __func__); goto err_open_i2c_handle; } #endif wake_lock_init(&s_hMuicHandle.wlock, WAKE_LOCK_SUSPEND, "muic_active"); //20101117, [email protected], for autorun [START] #ifdef CONFIG_USB_SUPPORT_LGE_ANDROID_AUTORUN s_hMuicHandle.sdev_autorun.name = DRIVER_NAME_FOR_AUTORUN; s_hMuicHandle.sdev_autorun.print_name = print_switch_name_for_autorun; s_hMuicHandle.sdev_autorun.print_state = print_switch_state_for_autorun; ret = switch_dev_register(&s_hMuicHandle.sdev_autorun); if (ret) { goto err_sdev_unregister; } #endif //20101117, [email protected], for autorun [END] INIT_DELAYED_WORK(&muic_wq, muic_wq_func); if (NvOdmGpioInterruptRegister(s_hMuicHandle.hGpio, &s_hMuicHandle.hGpioInterrupt, s_hMuicHandle.h_INT_N_MUIC, NvOdmGpioPinMode_InputInterruptFallingEdge , muic_interrupt_handler, (void*)&s_hMuicHandle, 0) == NV_FALSE) { lprintk(D_MUIC, KERN_ERR "%s: cannot register interrupt.\n", __func__); goto err_get_interrupt_handler; } create_star_muic_proc_file(); current_device = DEVICE_NONE; muic_initialize_max(RESET); //20100915, [email protected], move to late_initcall [START] #if 0 NvOdmOsSleepMS(400) ; MAX14526_Device_Detection(); #endif //20100915, [email protected], move to late_initcall [STOP] return 0; err_get_interrupt_handler: #ifndef _MUIC_GPIO_I2C_ NvOdmI2cClose(s_hMuicHandle.hOdmI2c); #endif //20101117, [email protected], for autorun [START] #ifdef CONFIG_USB_SUPPORT_LGE_ANDROID_AUTORUN err_sdev_unregister: switch_dev_unregister(&s_hMuicHandle.sdev_autorun); #endif //20101117, [email protected], for autorun [END] err_open_i2c_handle: NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_INT_N_MUIC); NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_AP20_UART_SW); NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_IFX_UART_SW); NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_USIF1_SW); #if defined(CONFIG_MACH_STAR_REV_D) || defined(CONFIG_MACH_STAR_REV_E) || defined(CONFIG_MACH_STAR_REV_F) NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_USB_VBUS_EN); #endif err_open_gpio_pin_acquire_fail: NvOdmGpioClose(s_hMuicHandle.hGpio); err_open_gpio_fail: return -ENOSYS; }
void Set_MAX14526_Device_None_Detect(NvU8 int_status_reg) { NvU8 reg_value; // IDNO=0100? 130Kohm :: CP UART MODE if((int_status_reg & IDNO_M) == IDNO_0100) Set_MAX14526_Factory_Mode_Detect(); // IDNO=0010? 56Kohm :: CP USB MODE else if ((int_status_reg &IDNO_M )==IDNO_0010) Set_MAX14526_CP_USB_Mode(); // IDNO=0010? 910Kohm :: CP USB MODE else if ((int_status_reg &IDNO_M )==IDNO_1010) Set_MAX14526_CP_USB_Mode(); // CHGDET=1? :: HIGH CURRENT USB or TA? else if (int_status_reg & CHGDET_M) { Set_MAX14526_Charger_Detect(int_status_reg); } // VBUS=1? :: TA or AP USB? else if (int_status_reg & VBUS_M){ // COMP2 to H-Z / COMN1 to C1COMP (0x03=0x23) Set_MAX14526_ADDR(SW_CTRL_REG, COMP2_TO_HZ | COMN1_TO_C1COMP); NvOdmOsSleepMS(200) ; // Read STATUS_REG (0x05) reg_value = Get_MAX14526_ADDR(STATUS_REG); if (reg_value & C1COMP_M){ // Dedicated Charger(TA) Detected // COMP2 to H-Z / COMN1 to H-Z (0x03=0x24) Set_MAX14526_ADDR(SW_CTRL_REG, COMP2_TO_HZ | COMN1_TO_HZ); //20100526, [email protected], Enable charger IC in TA mode [START] #if defined(CONFIG_STAR_BATTERY_CHARGER) lprintk(D_MUIC, "%s: CHG_IC_TA_MODE(%d) \n", __func__, CHG_IC_TA_MODE); charging_ic_active(CHG_IC_TA_MODE); #endif /* CONFIG_STAR_BATTERY_CHARGER */ //20100526, [email protected], Enable charger IC in TA mode [END] current_device = DEVICE_TA_CHARGER; printk("-->> MUIC : %s : DEVICE_TA_CHARGER \n",__func__); } else { // USB Detected Set_MAX14526_Usb_Mode_Detect(); //20101117, [email protected], for autorun #ifdef CONFIG_USB_SUPPORT_LGE_ANDROID_AUTORUN switch_set_state(&s_hMuicHandle.sdev_autorun, 1); #endif } } else { // Accessory Not Supported current_device = DEVICE_NONE; muic_initialize_max(DEFAULT); } }
NvOdmUsbUlpiHandle NvOdmUsbUlpiOpen(NvU32 Instance) { NvOdmUsbUlpi*pDevice = NULL; NvU32 ClockInstances[MAX_CLOCKS]; NvU32 ClockFrequencies[MAX_CLOCKS]; NvU32 NumClocks; #if defined(CONFIG_TEGRA_ODM_BETELGEUSE) /* paul */ NvOdmInterruptHandler IntrHandler = (NvOdmInterruptHandler)UsbCurLimitGpioInterruptHandler; /* end */ #endif pDevice = NvOdmOsAlloc(sizeof(NvOdmUsbUlpi)); if(pDevice == NULL) return NULL; if(!NvOdmExternalClockConfig(SMSC3317GUID, NV_FALSE, ClockInstances, ClockFrequencies, &NumClocks)) { NV_DRIVER_TRACE (("ERROR NvOdmUsbUlpiOpen: " "NvOdmExternalClockConfig fail\n")); goto ExitUlpiOdm; } NvOdmOsSleepMS(10); if (!s_hGpio) s_hGpio = NvOdmGpioOpen(); if (!s_hGpio) { NV_DRIVER_TRACE (("ERROR NvOdmUsbUlpiOpen: " "Not able to open gpio handle\n")); goto ExitUlpiOdm; } if (!s_hResetPin) s_hResetPin = NvOdmGpioAcquirePinHandle(s_hGpio, ULPI_RESET_PORT, ULPI_RESET_PIN); if (!s_hResetPin) { NvOdmGpioClose(s_hGpio); s_hGpio = NULL; NV_DRIVER_TRACE (("ERROR NvOdmGpioAcquirePinHandle: " "Not able to Acq pinhandle\n")); goto ExitUlpiOdm; } #if defined(CONFIG_TEGRA_ODM_BETELGEUSE) if (!s_hOvrrCurPin) s_hOvrrCurPin = NvOdmGpioAcquirePinHandle(s_hGpio, ULPI_OVRCURR_PORT, ULPI_OVRCURR_PIN); if (!s_hOvrrCurPin) { NvOdmGpioClose(s_hGpio); s_hGpio = NULL; NV_DRIVER_TRACE (("ERROR NvOdmGpioAcquirePinHandle: " "Not able to Acq pinhandle\n")); goto ExitUlpiOdm; } NvOdmGpioConfig(s_hGpio,s_hOvrrCurPin, NvOdmGpioPinMode_InputData); #endif // Pull high on RESETB ( 22nd pin of smsc3315) // config as out put pin NvOdmGpioConfig(s_hGpio,s_hResetPin, NvOdmGpioPinMode_Output); // Set low to write high on ULPI_RESETB pin NvOdmGpioSetState(s_hGpio, s_hResetPin, 0x01); NvOdmGpioSetState(s_hGpio, s_hResetPin, 0x0); NvOdmOsSleepMS(5); NvOdmGpioSetState(s_hGpio, s_hResetPin, 0x01); #if defined(BUG_CONFIG_TEGRA_ODM_BETELGEUSE) /* paul merge smith begin */ /* create mutex for usb over current detect */ NvOsMutexCreate(&usbCurrLimit_lock); #if 0 /* create /proc/usbCurrLimitInfo for user space read */ /* S_IRUGO */ create_proc_read_entry("usbCurrLimitInfo", S_IRWXUGO, NULL, tegra_usbCurrLimit_read_proc, NULL); #else procfile_init(); #endif /* register interrupt handler for GPIO_PU3 status */ if (NvOdmGpioInterruptRegister(s_hGpio, &IntrHandle, s_hOvrrCurPin, NvOdmGpioPinMode_InputInterruptLow, IntrHandler, (void *)NULL, 0) == NV_FALSE) { NV_DRIVER_TRACE (("ERROR NvOdmGpioInterruptRegister: " "Not able to register intr hdlr for s_hCurLimitPin\n")); } /* paul merge smith end */ #endif pDevice->CurrentGUID = SMSC3317GUID; return pDevice; ExitUlpiOdm: NvOdmOsFree(pDevice); return NULL; }