int lcd_io_init(void) { int ret = 0; if(RK_LCD_STANDBY_PIN != INVALID_GPIO){ rk30_mux_api_set(RK_LCD_STANDBY_MUX_NAME, RK_LCD_STANDBY_MUX_MODE); ret = gpio_request(RK_LCD_STANDBY_PIN, NULL); if(ret !=0){ printk(KERN_ERR "request lcd standby pin failed!\n"); }else{ gpio_direction_output(RK_LCD_STANDBY_PIN, GPIO_HIGH); gpio_set_value(RK_LCD_STANDBY_PIN, RK_LCD_STANDBY_VALUE); mdelay(5); } } if(RK_LCD_EN_PIN != INVALID_GPIO){ rk30_mux_api_set(RK_LCD_EN_MUX_NAME, RK_LCD_EN_MUX_MODE); ret = gpio_request(RK_LCD_EN_PIN, NULL); if (ret != 0){ printk(KERN_ERR "request lcd en2 pin fail!\n"); } else{ gpio_direction_output(RK_LCD_EN_PIN, 1); gpio_set_value(RK_LCD_EN_PIN, RK_LCD_EN_VALUE); } } if(RK_LCD_RESET_PIN != INVALID_GPIO){ rk30_mux_api_set(RK_LCD_RESET_MUX_NAME, RK_LCD_RESET_MUX_MODE); ret = gpio_request(RK_LCD_RESET_PIN, NULL); if(ret !=0){ printk(KERN_ERR "request lcd reset pin failed!\n"); }else{ mdelay(50); gpio_pull_updown(RK_LCD_RESET_PIN, GPIOPullUp); gpio_direction_output(RK_LCD_RESET_PIN, GPIO_HIGH); gpio_set_value(RK_LCD_RESET_PIN, RK_LCD_RESET_VALUE); } } if(LCD_CS_PIN != INVALID_GPIO){ rk30_mux_api_set(LCD_CS_MUX_NAME, LCD_CS_MUX_MODE); ret = gpio_request(LCD_CS_PIN, NULL); if (ret != 0){ printk(KERN_ERR "request lcd en pin fail!\n"); } else{ gpio_direction_output(LCD_CS_PIN, 1); gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE); } } if(LCD_SPI_CS_PIN != INVALID_GPIO){ rk30_mux_api_set(LCD_SPI_CS_MUX_NAME, LCD_SPI_CS_MUX_MODE); ret = gpio_request(LCD_SPI_CS_PIN, NULL); if (ret != 0){ printk(KERN_ERR "request lcd spi cs pin fail!\n"); }else{ gpio_direction_output(LCD_SPI_CS_PIN, 1); gpio_set_value(LCD_SPI_CS_PIN, GPIO_LOW); } } if(LCD_SPI_SCL_PIN != INVALID_GPIO){ rk30_mux_api_set(LCD_SPI_SCL_MUX_NAME, LCD_SPI_SCL_MUX_MODE); ret = gpio_request(LCD_SPI_SCL_PIN, NULL); if (ret != 0){ printk(KERN_ERR "request lcd spi scl pin fail!\n"); }else{ gpio_direction_output(LCD_SPI_SCL_PIN, 1); gpio_set_value(LCD_SPI_SCL_PIN, GPIO_LOW); } } if(LCD_SPI_SDA_PIN != INVALID_GPIO){ rk30_mux_api_set(LCD_SPI_SDA_MUX_NAME, LCD_SPI_SDA_MUX_MODE); ret = gpio_request(LCD_SPI_SDA_PIN, NULL); if (ret != 0){ printk(KERN_ERR "request lcd spi sda pin fail!\n"); }else{ gpio_direction_output(LCD_SPI_SDA_PIN, 1); gpio_set_value(LCD_SPI_SDA_PIN, GPIO_LOW); } } td043_init(); return 0; }
static int __devinit act8931_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct act8931 *act8931; struct act8931_platform_data *pdata = i2c->dev.platform_data; int ret; u8 val; act8931 = kzalloc(sizeof(struct act8931), GFP_KERNEL); if (act8931 == NULL) { ret = -ENOMEM; goto err; } act8931->i2c = i2c; act8931->dev = &i2c->dev; i2c_set_clientdata(i2c, act8931); mutex_init(&act8931->io_lock); ret = act8931_reg_read(act8931,0x22); if ((ret < 0) || (ret == 0xff)){ printk("The device is not act8931 \n"); return 0; } if (pdata) { ret = setup_regulators(act8931, pdata); if (ret < 0) goto err; } else dev_warn(act8931->dev, "No platform init data supplied\n"); ret = act8931_reg_read(act8931,0x01); if (ret < 0) goto err; ret = act8931_set_bits(act8931, 0x01,(0x1<<5) | (0x1<<0),(0x1<<0)); if (ret < 0) { printk("act8931 set 0x01 error!\n"); goto err; } g_act8931 = act8931; pdata->set_init(act8931); /* Initialize charge status */ val = act8931_reg_read(act8931,0x78); act8931_charge_det = (val & INDAT_MASK )? 1:0; act8931_charge_ok = (val & CHGDAT_MASK )? 1:0; DBG(act8931_charge_det? "connect! " : "disconnect! "); DBG(act8931_charge_ok? "charge ok!\n" : "charging or discharge!\n"); ret = act8931_set_bits(act8931, 0x78, INSTAT_MASK | CHGSTAT_MASK, INSTAT_MASK | CHGSTAT_MASK); if (ret < 0) { printk("act8931 set 0x78 error!\n"); goto err; } ret = act8931_set_bits(act8931, 0x79, INCON_MASK | CHGEOCIN_MASK | INDIS_MASK | CHGEOCOUT_MASK, INCON_MASK | CHGEOCIN_MASK | INDIS_MASK | CHGEOCOUT_MASK); if (ret < 0) { printk("act8931 set 0x79 error!\n"); goto err; } ret = gpio_request(i2c->irq, "act8931 gpio"); if(ret) { printk("act8931 gpio request fail\n"); gpio_free(i2c->irq); goto err; } act8931->irq = gpio_to_irq(i2c->irq); gpio_pull_updown(i2c->irq,GPIOPullUp); ret = request_threaded_irq(act8931->irq, NULL, act8931_irq_thread, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, i2c->dev.driver->name, act8931); if (ret < 0) { printk("request act8931 irq fail\n"); goto err; } enable_irq_wake(act8931->irq); #ifdef CONFIG_HAS_EARLYSUSPEND act8931->act8931_suspend.suspend = act8931_early_suspend, act8931->act8931_suspend.resume = act8931_late_resume, act8931->act8931_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1, register_early_suspend(&act8931->act8931_suspend); #endif return 0; err: return ret; }
static int __devinit bcm4329_rfkill_probe(struct platform_device *pdev) { int rc = 0; bool default_state = true; DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__); /* default to bluetooth off */ bcm4329_set_block(NULL, default_state); /* blocked -> bt off */ gBtCtrl.bt_rfk = rfkill_alloc(bt_name, NULL, RFKILL_TYPE_BLUETOOTH, &bcm4329_rfk_ops, NULL); if (!gBtCtrl.bt_rfk) { printk("fail to rfkill_allocate************\n"); return -ENOMEM; } rfkill_set_states(gBtCtrl.bt_rfk, default_state, false); rc = rfkill_register(gBtCtrl.bt_rfk); if (rc) { printk("failed to rfkill_register,rc=0x%x\n",rc); rfkill_destroy(gBtCtrl.bt_rfk); } gpio_request(BT_GPIO_POWER, NULL); gpio_request(BT_GPIO_RESET, NULL); gpio_request(BT_GPIO_WAKE_UP, NULL); #if BT_WAKE_HOST_SUPPORT init_timer(&(gBtCtrl.tl)); gBtCtrl.tl.expires = jiffies + BT_WAKE_LOCK_TIMEOUT*HZ; gBtCtrl.tl.function = timer_hostSleep; add_timer(&(gBtCtrl.tl)); gBtCtrl.b_HostWake = false; wake_lock_init(&(gBtCtrl.bt_wakelock), WAKE_LOCK_SUSPEND, "bt_wake"); rc = gpio_request(BT_GPIO_WAKE_UP_HOST, "bt_wake"); if (rc) { printk("%s:failed to request RAHO_BT_WAKE_UP_HOST\n",__FUNCTION__); } IOMUX_BT_GPIO_WAKE_UP_HOST(); gpio_pull_updown(BT_GPIO_WAKE_UP_HOST,GPIOPullUp); rc = request_irq(gpio_to_irq(BT_GPIO_WAKE_UP_HOST),bcm4329_wake_host_irq,IRQF_TRIGGER_FALLING,NULL,NULL); if(rc) { printk("%s:failed to request RAHO_BT_WAKE_UP_HOST irq\n",__FUNCTION__); gpio_free(BT_GPIO_WAKE_UP_HOST); } enable_irq_wake(gpio_to_irq(BT_GPIO_WAKE_UP_HOST)); // so RAHO_BT_WAKE_UP_HOST can wake up system printk(KERN_INFO "bcm4329 module has been initialized,rc=0x%x\n",rc); #endif return rc; }
static int it66121_i2c_probe(struct i2c_client *client,const struct i2c_device_id *id) { int rc = 0; struct hdmi *hdmi = NULL; struct rkdisplay_platform_data *hdmi_data = client->dev.platform_data; it66121 = kzalloc(sizeof(struct it66121), GFP_KERNEL); if(!it66121) { dev_err(&client->dev, "no memory for state\n"); goto err_kzalloc_it66121; } it66121->client = client; it66121->io_irq_pin = client->irq; it66121->enable = 1; i2c_set_clientdata(client, it66121); it66121_property.name = (char*)client->name; it66121_property.priv = it66121; // Register HDMI device if(hdmi_data) { it66121->io_pwr_pin = hdmi_data->io_pwr_pin; it66121->io_rst_pin = hdmi_data->io_reset_pin; it66121_property.videosrc = hdmi_data->video_source; it66121_property.display = hdmi_data->property; } else { it66121->io_pwr_pin = INVALID_GPIO; it66121->io_rst_pin = INVALID_GPIO; it66121_property.videosrc = DISPLAY_SOURCE_LCDC0; it66121_property.display = DISPLAY_MAIN; } it66121->hdmi = hdmi_register(&it66121_property, &it66121_ops); if(it66121->hdmi == NULL) { dev_err(&client->dev, "fail to register hdmi\n"); goto err_hdmi_register; } #ifdef CONFIG_HAS_EARLYSUSPEND it66121->early_suspend.suspend = it66121_early_suspend; it66121->early_suspend.resume = it66121_early_resume; it66121->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 10; register_early_suspend(&it66121->early_suspend); #endif //Power on it66121 if(it66121->io_pwr_pin != INVALID_GPIO) { rc = gpio_request(it66121->io_pwr_pin, NULL); if(rc) { gpio_free(it66121->io_pwr_pin); printk(KERN_ERR "request it66121 power control gpio error\n "); goto err_hdmi_register; } else gpio_direction_output(it66121->io_pwr_pin, GPIO_HIGH); } // Reset it66121 if(it66121->io_rst_pin != INVALID_GPIO) { rc = gpio_request(it66121->io_rst_pin, NULL); if(rc) { gpio_free(it66121->io_rst_pin); printk(KERN_ERR "request it66121 reset control gpio error\n "); goto err_hdmi_register; } else gpio_direction_output(it66121->io_rst_pin, GPIO_HIGH); } if(it66121_initial()) goto err_request_gpio; // hdmi_enable(hdmi); #if 0 if((rc = gpio_request(it66121->io_irq_pin, "hdmi gpio")) < 0) { dev_err(&client->dev, "fail to request gpio %d\n", client->irq); goto err_request_gpio; } gpio_pull_updown(it66121->io_irq_pin, PullDisable); gpio_direction_input(it66121->io_irq_pin); INIT_WORK(&it66121->irq_work, it66121_irq_work_func); it66121->irq = gpio_to_irq(it66121->io_irq_pin); if((rc = request_irq(it66121->irq, it66121_detect_irq,IRQF_TRIGGER_FALLING,NULL,it66121)) <0) { dev_err(&client->dev, "fail to request hdmi irq\n"); goto err_request_irq; } #endif { it66121->workqueue = create_singlethread_workqueue("it66121 irq"); INIT_DELAYED_WORK(&(it66121->delay_work), it66121_irq_work_func); it66121_irq_work_func(NULL); // queue_delayed_work(sii902x->workqueue, &sii902x->delay_work, 0); } printk(KERN_INFO "IT66121 probe success."); return 0; err_request_irq: gpio_free(client->irq); err_request_gpio: hdmi_unregister(it66121->hdmi); err_hdmi_register: kfree(it66121); it66121 = NULL; err_kzalloc_it66121: dev_err(&client->dev, "it66121 probe error\n"); return rc; }
static int rk29sdk_wifi_combo_module_gpio_init(void) { //VDDIO #ifdef RK30SDK_WIFI_GPIO_VCCIO_WL #ifdef RK30SDK_WIFI_GPIO_VCCIO_WL_PIN_NAME rk30_mux_api_set(rk_platform_wifi_gpio.vddio.iomux.name, rk_platform_wifi_gpio.vddio.iomux.fgpio); #endif gpio_request(rk_platform_wifi_gpio.vddio.io, "combo-VDDIO"); gpio_direction_output(rk_platform_wifi_gpio.vddio.io, !(rk_platform_wifi_gpio.power_n.enable)); #endif //BGF_INT_B #ifdef RK30SDK_WIFI_GPIO_BGF_INT_B_PIN_NAME rk30_mux_api_set(rk_platform_wifi_gpio.bgf_int_b.iomux.name, rk_platform_wifi_gpio.bgf_int_b.iomux.fgpio); #endif gpio_request(rk_platform_wifi_gpio.bgf_int_b.io, "combo-BGFINT"); gpio_pull_updown(rk_platform_wifi_gpio.bgf_int_b.io, GPIOPullUp); gpio_direction_input(rk_platform_wifi_gpio.bgf_int_b.io); //WIFI_INT_B #ifdef RK30SDK_WIFI_GPIO_WIFI_INT_B_PIN_NAME rk30_mux_api_set(rk_platform_wifi_gpio.bgf_int_b.iomux.name, rk_platform_wifi_gpio.bgf_int_b.iomux.fgpio); #endif gpio_request(rk_platform_wifi_gpio.wifi_int_b.io, "combo-WIFIINT"); gpio_pull_updown(rk_platform_wifi_gpio.wifi_int_b.io, GPIOPullUp); gpio_direction_input(rk_platform_wifi_gpio.wifi_int_b.io); //reset #ifdef RK30SDK_WIFI_GPIO_RESET_PIN_NAME rk30_mux_api_set(rk_platform_wifi_gpio.reset_n.iomux.name, rk_platform_wifi_gpio.reset_n.iomux.fgpio); #endif gpio_request(rk_platform_wifi_gpio.reset_n.io, "combo-RST"); gpio_direction_output(rk_platform_wifi_gpio.reset_n.io, !(rk_platform_wifi_gpio.reset_n.enable)); //power #ifdef RK30SDK_WIFI_GPIO_POWER_PIN_NAME rk30_mux_api_set(rk_platform_wifi_gpio.power_n.iomux.name, rk_platform_wifi_gpio.power_n.iomux.fgpio); #endif gpio_request(rk_platform_wifi_gpio.power_n.io, "combo-PMUEN"); gpio_direction_output(rk_platform_wifi_gpio.power_n.io, !(rk_platform_wifi_gpio.power_n.enable)); #if defined(COMBO_MODULE_MT6620_CDT) && COMBO_MODULE_MT6620_CDT //ANTSEL2 #ifdef RK30SDK_WIFI_GPIO_ANTSEL2 #ifdef RK30SDK_WIFI_GPIO_ANTSEL2_PIN_NAME rk30_mux_api_set(rk_platform_wifi_gpio.ANTSEL2.iomux.name, rk_platform_wifi_gpio.ANTSEL2.iomux.fgpio); #endif gpio_request(rk_platform_wifi_gpio.ANTSEL2.io, "combo-ANTSEL2"); gpio_direction_output(rk_platform_wifi_gpio.ANTSEL2.io, rk_platform_wifi_gpio.ANTSEL2.enable); #endif //ANTSEL3 #ifdef RK30SDK_WIFI_GPIO_ANTSEL3 #ifdef RK30SDK_WIFI_GPIO_ANTSEL3_PIN_NAME rk30_mux_api_set(rk_platform_wifi_gpio.ANTSEL3.iomux.name, rk_platform_wifi_gpio.ANTSEL3.iomux.fgpio); #endif gpio_request(rk_platform_wifi_gpio.ANTSEL3.io, "combo-ANTSEL3"); gpio_direction_output(rk_platform_wifi_gpio.ANTSEL3.io, !(rk_platform_wifi_gpio.ANTSEL3.enable)); #endif //GPS_LAN #ifdef RK30SDK_WIFI_GPIO_GPS_LAN #ifdef RK30SDK_WIFI_GPIO_GPS_LAN_PIN_NAME rk30_mux_api_set(rk_platform_wifi_gpio.GPS_LAN.iomux.name, rk_platform_wifi_gpio.GPS_LAN.iomux.fgpio); #endif gpio_request(rk_platform_wifi_gpio.GPS_LAN.io, "combo-GPSLAN"); gpio_direction_output(rk_platform_wifi_gpio.GPS_LAN.io, rk_platform_wifi_gpio.GPS_LAN.enable); #endif #endif//#if COMBO_MODULE_MT6620_CDT ---#endif return 0; }
static int rk2918_battery_probe(struct platform_device *pdev) { int ret; struct adc_client *client; struct rk2918_battery_data *data; struct rk2918_battery_platform_data *pdata = pdev->dev.platform_data; int irq_flag; int i = 0; dprint("func=%s, line=%d :\n", __func__, __LINE__); data = kzalloc(sizeof(*data), GFP_KERNEL); if (data == NULL) { ret = -ENOMEM; goto err_data_alloc_failed; } gBatteryData = data; //clear io data->dc_det_pin = INVALID_GPIO; data->batt_low_pin = INVALID_GPIO; data->charge_set_pin = INVALID_GPIO; data->charge_ok_pin = INVALID_GPIO; if (pdata && pdata->io_init) { ret = pdata->io_init(); if (ret) goto err_free_gpio1; } //dc det if (pdata->dc_det_pin != INVALID_GPIO) { #ifndef DC_DET_WITH_USB_INT ret = gpio_request(pdata->dc_det_pin, NULL); if (ret) { printk("failed to request dc_det gpio\n"); goto err_free_gpio1; } #endif if(pdata->dc_det_level) gpio_pull_updown(pdata->dc_det_pin, 0);//important else gpio_pull_updown(pdata->dc_det_pin, GPIOPullUp);//important ret = gpio_direction_input(pdata->dc_det_pin); if (ret) { printk("failed to set gpio dc_det input\n"); goto err_free_gpio1; } data->dc_det_pin = pdata->dc_det_pin; data->dc_det_level = pdata->dc_det_level; } if (pdata->charge_cur_ctl != INVALID_GPIO) { ret = gpio_request(pdata->charge_cur_ctl, "DC_CURRENT_CONTROL"); if (ret < 0) { printk("failed to request charge current control gpio\n"); goto err_free_gpio2; } ret = gpio_direction_output(pdata->charge_cur_ctl, !pdata->charge_cur_ctl_level); if (ret < 0) { printk("rk29_battery: failed to set charge current control gpio\n"); goto err_free_gpio2; } gpio_pull_updown(pdata->charge_cur_ctl, !pdata->charge_cur_ctl_level); gpio_set_value(pdata->charge_cur_ctl, !pdata->charge_cur_ctl_level); data->charge_cur_ctl = pdata->charge_cur_ctl; data->charge_cur_ctl_level = pdata->charge_cur_ctl_level; } //charge set for usb charge if (pdata->charge_set_pin != INVALID_GPIO) { ret = gpio_request(pdata->charge_set_pin, NULL); if (ret) { printk("failed to request dc_det gpio\n"); goto err_free_gpio2; } data->charge_set_pin = pdata->charge_set_pin; data->charge_set_level = pdata->charge_set_level; gpio_direction_output(pdata->charge_set_pin, 1 - pdata->charge_set_level); } //charge_ok if (pdata->charge_ok_pin != INVALID_GPIO) { ret = gpio_request(pdata->charge_ok_pin, NULL); if (ret) { printk("failed to request charge_ok gpio\n"); goto err_free_gpio3; } gpio_pull_updown(pdata->charge_ok_pin, GPIOPullUp);//important ret = gpio_direction_input(pdata->charge_ok_pin); if (ret) { printk("failed to set gpio charge_ok input\n"); goto err_free_gpio3; } data->charge_ok_pin = pdata->charge_ok_pin; data->charge_ok_level = pdata->charge_ok_level; } client = adc_register(0, rk2918_battery_callback, NULL); if(!client) goto err_adc_register_failed; memset(gBatVoltageSamples, 0, sizeof(gBatVoltageSamples)); spin_lock_init(&data->lock); data->adc_val = adc_sync_read(client); data->client = client; data->battery.properties = rk2918_battery_props; data->battery.num_properties = ARRAY_SIZE(rk2918_battery_props); data->battery.get_property = rk2918_battery_get_property; data->battery.name = "battery"; data->battery.type = POWER_SUPPLY_TYPE_BATTERY; data->adc_bat_divider = 414; data->bat_max = BATT_MAX_VOL_VALUE; data->bat_min = BATT_ZERO_VOL_VALUE; DBG("bat_min = %d\n",data->bat_min); #ifdef RK29_USB_CHARGE_SUPPORT data->usb.properties = rk2918_usb_props; data->usb.num_properties = ARRAY_SIZE(rk2918_usb_props); data->usb.get_property = rk2918_usb_get_property; data->usb.name = "usb"; data->usb.type = POWER_SUPPLY_TYPE_USB; #endif data->ac.properties = rk2918_ac_props; data->ac.num_properties = ARRAY_SIZE(rk2918_ac_props); data->ac.get_property = rk2918_ac_get_property; data->ac.name = "ac"; data->ac.type = POWER_SUPPLY_TYPE_MAINS; rk2918_low_battery_check(); ret = power_supply_register(&pdev->dev, &data->ac); if (ret) { printk(KERN_INFO "fail to ac power_supply_register\n"); goto err_ac_failed; } #if 0 ret = power_supply_register(&pdev->dev, &data->usb); if (ret) { printk(KERN_INFO "fail to usb power_supply_register\n"); goto err_usb_failed; } #endif ret = power_supply_register(&pdev->dev, &data->battery); if (ret) { printk(KERN_INFO "fail to battery power_supply_register\n"); goto err_battery_failed; } platform_set_drvdata(pdev, data); // irq_flag = (pdata->charge_ok_level) ? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING; // ret = request_irq(gpio_to_irq(pdata->charge_ok_pin), rk2918_battery_interrupt, irq_flag, "rk2918_battery", data); // if (ret) { // printk("failed to request irq\n"); // goto err_irq_failed; // } #ifndef DC_DET_WITH_USB_INT if (pdata->dc_det_pin != INVALID_GPIO) { irq_flag = (!gpio_get_value (pdata->dc_det_pin)) ? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING; ret = request_irq(gpio_to_irq(pdata->dc_det_pin), rk2918_dc_wakeup, irq_flag, "rk2918_battery", data); if (ret) { printk("failed to request dc det irq\n"); goto err_dcirq_failed; } data->dc_det_irq = gpio_to_irq(pdata->dc_det_pin); //data->wq = create_rt_workqueue("rk2918_battery"); data->wq = create_workqueue("rk2918_battery"); INIT_DELAYED_WORK(&data->work, rk2918_battery_work); enable_irq_wake(gpio_to_irq(pdata->dc_det_pin)); } #endif setup_timer(&data->timer, rk2918_batscan_timer, (unsigned long)data); // changed to notify android of status.... data->timer.expires = jiffies + 5000; // 2000 add_timer(&data->timer); INIT_WORK(&data->timer_work, rk2918_battery_timer_work); rk29_battery_dbg_class = class_create(THIS_MODULE, "rk29_battery"); battery_dev = device_create(rk29_battery_dbg_class, NULL, MKDEV(0, 1), NULL, "battery"); ret = device_create_file(battery_dev, &dev_attr_rk29_battery_dbg); if (ret) { printk("create file sys failed!!! \n"); goto err_dcirq_failed; } for(i = 0; i<10; i++) { ret = device_create_file(&pdev->dev, &dev_attr_startget); if (ret) { printk("make a mistake in creating devices attr file, failed times: %d\n\n ", i+1); continue; } break; } printk(KERN_INFO "rk2918_battery: driver initialized\n"); return 0; err_dcirq_failed: free_irq(gpio_to_irq(pdata->dc_det_pin), data); err_irq_failed: free_irq(gpio_to_irq(pdata->charge_ok_pin), data); err_battery_failed: // power_supply_unregister(&data->usb); //err_usb_failed: err_ac_failed: power_supply_unregister(&data->ac); err_adc_register_failed: err_free_gpio3: gpio_free(pdata->charge_ok_pin); err_free_gpio2: gpio_free(pdata->charge_cur_ctl); err_free_gpio1: gpio_free(pdata->dc_det_pin); err_data_alloc_failed: kfree(data); printk("rk2918_battery: error!\n"); return ret; }
static int __devinit hym8563_probe(struct i2c_client *client, const struct i2c_device_id *id) { int rc = 0; u8 reg = 0; struct hym8563 *hym8563; struct rtc_device *rtc = NULL; struct rtc_time tm_read, tm = { .tm_wday = 6, .tm_year = 111, .tm_mon = 0, .tm_mday = 1, .tm_hour = 12, .tm_min = 0, .tm_sec = 0, }; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) return -ENODEV; hym8563 = kzalloc(sizeof(struct hym8563), GFP_KERNEL); if (!hym8563) { return -ENOMEM; } gClient = client; hym8563->client = client; hym8563->alarm.enabled = 0; mutex_init(&hym8563->mutex); wake_lock_init(&hym8563->wake_lock, WAKE_LOCK_SUSPEND, "rtc_hym8563"); i2c_set_clientdata(client, hym8563); hym8563_init_device(client); hym8563_enable_count(client, 0); // check power down hym8563_i2c_read_regs(client,RTC_SEC,®,1); if (reg&0x80) { dev_info(&client->dev, "clock/calendar information is no longer guaranteed\n"); hym8563_set_time(client, &tm); } hym8563_read_datetime(client, &tm_read); //read time from hym8563 if(((tm_read.tm_year < 70) | (tm_read.tm_year > 137 )) | (tm_read.tm_mon == -1) | (rtc_valid_tm(&tm_read) != 0)) //if the hym8563 haven't initialized { hym8563_set_time(client, &tm); //initialize the hym8563 } if(gpio_request(client->irq, "rtc gpio")) { dev_err(&client->dev, "gpio request fail\n"); gpio_free(client->irq); goto exit; } hym8563->irq = gpio_to_irq(client->irq); gpio_pull_updown(client->irq,GPIOPullUp); if (request_threaded_irq(hym8563->irq, NULL, hym8563_wakeup_irq, IRQF_TRIGGER_LOW | IRQF_ONESHOT, client->dev.driver->name, hym8563) < 0) { printk("unable to request rtc irq\n"); goto exit; } enable_irq_wake(hym8563->irq); rtc = rtc_device_register(client->name, &client->dev, &hym8563_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) { rc = PTR_ERR(rtc); rtc = NULL; goto exit; } hym8563->rtc = rtc; return 0; exit: if (rtc) rtc_device_unregister(rtc); if (hym8563) { wake_lock_destroy(&hym8563->wake_lock); kfree(hym8563); } return rc; } static int __devexit hym8563_remove(struct i2c_client *client) { struct hym8563 *hym8563 = i2c_get_clientdata(client); if (hym8563->irq > 0) { mutex_lock(&hym8563->mutex); hym8563->exiting = 1; mutex_unlock(&hym8563->mutex); free_irq(hym8563->irq, hym8563); cancel_work_sync(&hym8563->work); } rtc_device_unregister(hym8563->rtc); wake_lock_destroy(&hym8563->wake_lock); kfree(hym8563); hym8563 = NULL; return 0; } void hym8563_shutdown(struct i2c_client * client) { u8 regs[2]; int ret; //disable clkout regs[0] = 0x00; ret=hym8563_i2c_set_regs(client, RTC_CLKOUT, regs, 1); if(ret<0) printk("rtc shutdown is error\n"); }
static int rk610_hdmi_i2c_probe(struct i2c_client *client,const struct i2c_device_id *id) { int rc = 0; struct hdmi *hdmi = NULL; struct rkdisplay_platform_data *hdmi_data = client->dev.platform_data; rk610_hdmi = kzalloc(sizeof(struct rk610_hdmi_pdata), GFP_KERNEL); if(!rk610_hdmi) { dev_err(&client->dev, "no memory for state\n"); goto err_kzalloc_rk610_hdmi; } rk610_hdmi->client = client; if(hdmi_data) hdmi = hdmi_register(&client->dev, &rk610_hdmi_ops, hdmi_data->video_source, hdmi_data->property); else hdmi = hdmi_register(&client->dev, &rk610_hdmi_ops, DISPLAY_SOURCE_LCDC0, DISPLAY_MAIN); if(hdmi == NULL) { dev_err(&client->dev, "fail to register hdmi\n"); goto err_hdmi_register; } hdmi->support_r2y = 1; rk610_hdmi->hdmi = hdmi; hdmi_set_privdata(hdmi, rk610_hdmi); i2c_set_clientdata(client, rk610_hdmi); { #ifdef HDMI_USE_IRQ // hdmi_changed(hdmi, 0); INIT_WORK(&rk610_hdmi->irq_work, rk610_irq_work_func); if((rc = gpio_request(client->irq, "hdmi gpio")) < 0) { dev_err(&client->dev, "fail to request gpio %d\n", client->irq); goto err_request_gpio; } rk610_hdmi->irq = gpio_to_irq(client->irq); rk610_hdmi->gpio = client->irq; gpio_pull_updown(client->irq,GPIOPullUp); gpio_direction_input(client->irq); if((rc = request_irq(rk610_hdmi->irq, rk610_irq,IRQF_TRIGGER_RISING,NULL,hdmi)) < 0) { dev_err(&client->dev, "fail to request hdmi irq\n"); goto err_request_irq; } #else HDMI_task(hdmi); queue_delayed_work(hdmi->workqueue, &hdmi->delay_work, 200); #endif hdmi_enable(hdmi); dev_info(&client->dev, "rk610 hdmi i2c probe ok\n"); } return 0; err_request_irq: gpio_free(client->irq); err_request_gpio: hdmi_unregister(hdmi); err_hdmi_register: kfree(rk610_hdmi); rk610_hdmi = NULL; err_kzalloc_rk610_hdmi: hdmi = NULL; dev_err(&client->dev, "rk610 hdmi probe error\n"); return rc; }
static int anx7150_i2c_probe(struct i2c_client *client,const struct i2c_device_id *id) { int rc = 0; struct hdmi *hdmi = NULL; struct anx7150_pdata *anx = NULL; struct rkdisplay_platform_data *hdmi_data = client->dev.platform_data; anx = kzalloc(sizeof(struct anx7150_pdata), GFP_KERNEL); if(!anx) { dev_err(&client->dev, "no memory for state\n"); goto err_kzalloc_anx; } anx->client = client; anx->dev.anx7150_detect = 0; anx->init = 1; // Register HDMI device if(hdmi_data) { anx->io_pwr_pin = hdmi_data->io_pwr_pin; anx->io_rst_pin = hdmi_data->io_reset_pin; hdmi = hdmi_register(&client->dev, &anx7150_ops, hdmi_data->video_source, hdmi_data->property); } else { anx->io_pwr_pin = INVALID_GPIO; anx->io_rst_pin = INVALID_GPIO; hdmi = hdmi_register(&client->dev, &anx7150_ops, DISPLAY_SOURCE_LCDC0, DISPLAY_MAIN); } if(hdmi == NULL) { dev_err(&client->dev, "fail to register hdmi\n"); goto err_hdmi_register; } // Set HDMI private data hdmi_set_privdata(hdmi, anx); anx->dev.hdmi = hdmi; i2c_set_clientdata(client, anx); //Power on anx7150 if(anx->io_pwr_pin != INVALID_GPIO) { rc = gpio_request(anx->io_pwr_pin, NULL); if(rc) { gpio_free(anx->io_pwr_pin); printk(KERN_ERR "request anx7150 power control gpio error\n "); goto err_hdmi_register; } else gpio_direction_output(anx->io_pwr_pin, GPIO_HIGH); } anx->dev.anx7150_detect = ANX7150_hw_detect_device(anx->client); if(anx->dev.anx7150_detect) { HDMI_task(hdmi); #ifdef HDMI_USE_IRQ hdmi_changed(hdmi, 1); if((rc = gpio_request(client->irq, "hdmi gpio")) < 0) { dev_err(&client->dev, "fail to request gpio %d\n", client->irq); goto err_request_gpio; } anx->irq = gpio_to_irq(client->irq); anx->io_irq_pin = client->irq; gpio_pull_updown(client->irq,GPIOPullDown); gpio_direction_input(client->irq); #ifndef CONFIG_ANX7150_IRQ_USE_CHIP anx->init = IRQF_TRIGGER_RISING; if((rc = request_irq(anx->irq, anx7150_detect_irq,IRQF_TRIGGER_RISING,NULL,hdmi)) <0) #else if((rc = request_irq(anx->irq, anx7150_detect_irq,IRQF_TRIGGER_FALLING,NULL,hdmi)) <0) #endif { dev_err(&client->dev, "fail to request hdmi irq\n"); goto err_request_irq; } #else queue_delayed_work(hdmi->workqueue, &hdmi->delay_work, 1); #endif hdmi_enable(hdmi); dev_info(&client->dev, "anx7150 probe ok\n"); } else goto err_request_irq; return 0; err_request_irq: gpio_free(client->irq); err_request_gpio: hdmi_unregister(hdmi); err_hdmi_register: kfree(anx); anx = NULL; err_kzalloc_anx: hdmi = NULL; dev_err(&client->dev, "anx7150 probe error\n"); return rc; }