static void ds2482_set_slp_n(unsigned n) { gpio_direction_output(MAHIMAHI_GPIO_DS2482_SLP_N, n); }
static int aw_leds_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret = 0; struct aw_leds_data *data; const struct device_node *np = client->dev.of_node; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_BYTE | I2C_FUNC_SMBUS_READ_BYTE_DATA)) { dev_err(&client->dev, "need I2C_FUNC_SMBUS*.\n"); return -ENODEV; } data = kzalloc(sizeof(struct aw_leds_data),GFP_KERNEL); if (!data) { dev_err(&client->dev, "failed to allocate driver data\n"); return -ENOMEM; } if (of_property_read_u32(np, "aw_leds,gpio", &data->gpio)) { dev_err(&client->dev, "failed to read aw_leds,gpio from dt\n"); goto exit; } data->leds[0] = AW_LED_INVALID; if (of_property_read_u32(np, "aw_leds,led0", &data->leds[0])) { dev_warn(&client->dev, "failed to read aw_leds,led0 from dt\n"); } data->leds[1] = AW_LED_INVALID; if (of_property_read_u32(np, "aw_leds,led1", &data->leds[1])) { dev_warn(&client->dev, "failed to read aw_leds,led1 from dt\n"); } data->leds[2] = AW_LED_INVALID; if (of_property_read_u32(np, "aw_leds,led2", &data->leds[2])) { dev_warn(&client->dev, "failed to read aw_leds,led2 from dt\n"); } dev_dbg(&client->dev, "leds: %d %d %d\n", data->leds[0], data->leds[1], data->leds[2]); ret = gpio_request(data->gpio, "aw_leds-gpio"); if (ret) { dev_err(&client->dev, "failed to request gpio %d\n", data->gpio); goto exit; } gpio_direction_output(data->gpio, 1); dev_dbg(&client->dev, "using gpio %d\n", data->gpio); data->vana = regulator_get(&client->dev, "vdd_ana"); if (IS_ERR(data->vana)) { ret = PTR_ERR(data->vana); dev_err(&client->dev, "regulator get vdd_ana failed\n"); goto reg_failed; } ret = regulator_enable(data->vana); if (ret) { dev_err(&client->dev, "regulator vdd_ana enable failed\n"); goto reg_en_failed; } data->client = client; i2c_set_clientdata(client, data); mutex_init(&data->mutex); data->dev.minor = MISC_DYNAMIC_MINOR; data->dev.name = "aw-leds"; data->dev.fops = &aw_leds_fops; ret = misc_register(&data->dev); if (ret < 0) { dev_err(&client->adapter->dev, "misc_register returned %d\n", ret); goto register_failed; } dev_dbg(&client->dev, "success\n"); return 0; register_failed: mutex_destroy(&data->mutex); reg_en_failed: regulator_put(data->vana); reg_failed: gpio_free(data->gpio); exit: kfree(data); return ret; }
static int melfas_touchkey_late_resume(struct early_suspend *h) { int status; set_touchkey_debug('R'); printk(KERN_DEBUG "[TouchKey] melfas_touchkey_late_resume\n"); /* Avoid race condition with LED notification disable */ down(&enable_sem); /* enable ldo11 */ touchkey_ldo_on(1); if (touchkey_enable < 0) { printk(KERN_DEBUG "[TouchKey] ---%s---touchkey_enable: %d\n", __func__, touchkey_enable); up(&enable_sem); return 0; } gpio_direction_output(_3_GPIO_TOUCH_EN, 1); gpio_direction_output(_3_TOUCH_SDA_28V, 1); gpio_direction_output(_3_TOUCH_SCL_28V, 1); gpio_direction_output(_3_GPIO_TOUCH_INT, 1); set_irq_type(IRQ_TOUCH_INT, IRQF_TRIGGER_FALLING); s3c_gpio_cfgpin(_3_GPIO_TOUCH_INT, _3_GPIO_TOUCH_INT_AF); s3c_gpio_setpull(_3_GPIO_TOUCH_INT, S3C_GPIO_PULL_NONE); touchkey_led_ldo_on(1); touchkey_enable = 1; screen_on = 1; /* see if late_resume is running before DISABLE_BL */ if (led_on) { /* if a notification timeout was set, disable the timer */ if (notification_timeout > 0) { del_timer(¬ification_timer); } /* we were using a wakelock, unlock it */ if (wake_lock_active(&led_wake_lock)) { wake_unlock(&led_wake_lock); } /* force DISABLE_BL to ignore the led state because we want it left on */ #ifdef CONFIG_TARGET_CM_KERNEL led_on = 0; #else led_on = -1; #endif } if (led_timeout != BL_ALWAYS_OFF) { /* ensure the light is ON */ status = 1; i2c_touchkey_write((u8 *)&status, 1); } /* restart the timer if needed */ if (led_timeout > 0) { mod_timer(&led_timer, jiffies + msecs_to_jiffies(led_timeout)); } /* all done, turn on IRQ */ enable_irq(IRQ_TOUCH_INT); /* Avoid race condition with LED notification disable */ up(&enable_sem); return 0; }
static int s3c64xx_spigpio_probe(struct platform_device *dev) { struct s3c2410_spigpio_info *info; struct spi_master *master; struct s3c64xx_spigpio *spi; int ret; int i; master = spi_alloc_master(&dev->dev, sizeof(struct s3c64xx_spigpio)); if (master == NULL) { dev_err(&dev->dev, "failed to allocate spi master\n"); ret = -ENOMEM; goto err; } spi = spi_master_get_devdata(master); /* copy in the platform data */ info = spi->info = dev->dev.platform_data; /* setup spi bitbang adaptor */ spi->bitbang.master = spi_master_get(master); spi->bitbang.master->bus_num = info->bus_num; spi->bitbang.master->num_chipselect=0xFFFF; spi->bitbang.chipselect = s3c64xx_spigpio_chipselect; spi->bitbang.txrx_word[SPI_MODE_0] = s3c64xx_spigpio_txrx_mode0; spi->bitbang.txrx_word[SPI_MODE_1] = s3c64xx_spigpio_txrx_mode1; spi->bitbang.txrx_word[SPI_MODE_2] = s3c64xx_spigpio_txrx_mode2; spi->bitbang.txrx_word[SPI_MODE_3] = s3c64xx_spigpio_txrx_mode3; /* set state of spi pins. */ gpio_direction_output(info->pin_clk, 0); s3c_gpio_cfgpin(info->pin_clk, S3C_GPIO_OUTPUT); ret = spi_bitbang_start(&spi->bitbang); if (ret) goto err_no_bitbang; /* register the chips to go with the board */ for (i = 0; i < spi->info->board_size; i++) { struct spi_device *spidev; dev_info(&dev->dev, "registering %p: %s\n", &spi->info->board_info[i], spi->info->board_info[i].modalias); spi->info->board_info[i].controller_data = spi; spidev = spi_new_device(master, spi->info->board_info + i); if (spidev) spidev->max_speed_hz = spi->info->board_info[i].max_speed_hz; } return 0; err_no_bitbang: spi_master_put(spi->bitbang.master); err: return ret; }
/*---backlight--------------------------------------------------------------------*/ static void boxer_backlight_set_power(struct omap_pwm_led_platform_data *self, int on_off) { gpio_direction_output(LCD_BACKLIGHT_EN_EVT2, !on_off); gpio_set_value(LCD_BACKLIGHT_EN_EVT2, !on_off); }
static int __devinit lp8720_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct lp8720 *lp8720; struct lp8720_platform_data *pdata = i2c->dev.platform_data; int ret; u8 readbyte = 0; u8 enable = 0; if (!pdata) { dev_dbg(&i2c->dev, "No platform init data supplied\n"); return -ENODEV; } lp8720 = kzalloc(sizeof(struct lp8720), GFP_KERNEL); if (!lp8720) return -ENOMEM; lp8720->i2c = i2c; lp8720->dev = &i2c->dev; mutex_init(&lp8720->io_lock); #if 0 /* don't verify pmic register because pmic register is changed by bootloader */ ret = lp8720_i2c_read(i2c, 0x00, 1, &readbyte); if (ret == 0 && readbyte != 0x05) { ret = -ENODEV; dev_err(&i2c->dev, "chip reported: [00h]= 0x%x\n", readbyte); } if (ret < 0) { dev_err(&i2c->dev, "failed to detect device. ret = %d\n", ret); goto err_detect; } #endif ret = setup_regulators(lp8720, pdata); if (ret < 0) goto err_detect; i2c_set_clientdata(i2c, lp8720); ret = gpio_request(pdata->en_pin, pdata->name); if (ret) { printk(KERN_ERR "%s, ERROR [%s] - gpio_request(%d) failed\n", __func__, pdata->name, pdata->en_pin); } ret = gpio_direction_output(pdata->en_pin, 1); if (ret) { printk(KERN_ERR "%s, ERROR [%s] - gpio_direction_output(%d) failed\n", __func__, pdata->name, pdata->en_pin); } /* EXT_DVS_CTRL, EXT_SLEEP_CTRL => serial interface control */ lp8720_i2c_read(i2c, LP8720_GENERAL_SETTINGS_REG, 1, &readbyte); enable = readbyte & ~0x06; lp8720_i2c_write(i2c, LP8720_GENERAL_SETTINGS_REG, 1, enable); #if 0 /* keep pmic state set by bootloader */ /* all ldo & buck disabled */ lp8720_i2c_read(i2c, LP8720_ENABLE_REG, 1, &readbyte); enable = readbyte & 0xC0; lp8720_i2c_write(i2c, LP8720_ENABLE_REG, 1, enable); #endif lp8720_i2c_read(i2c, LP8720_ENABLE_REG, 1, &readbyte); printk(KERN_DEBUG "%s, [%s] - ENABLE_REG : 0x%2x\n", __func__, pdata->name, readbyte); return 0; err_detect: kfree(lp8720); return ret; }
static int msm8930_s5k4e5yx_vreg_on(void) { int rc; pr_info("[CAM] %s\n", __func__); /* VCM */ rc = camera_sensor_power_enable("8038_l17", 2800000, ®_8038_l17); pr_info("[CAM] vcm sensor_power_enable(\"8038_l17\", 2.8V) == %d\n", rc); if (rc < 0) { pr_err("[CAM] sensor_power_enable(\"8038_l17\", 2.8V) FAILED %d\n", rc); goto enable_s5k4e5yx_vcm_fail; } udelay(50); /* digital */ rc = gpio_request(CAM_PIN_GPIO_V_CAM_D1V8_EN, "V_CAM_D1V8_EN"); pr_info("[CAM] digital gpio_request, %d\n", CAM_PIN_GPIO_V_CAM_D1V8_EN); if (rc < 0) { pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM_D1V8_EN); goto enable_s5k4e5yx_digital_fail; } gpio_tlmm_config( GPIO_CFG(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_direction_output(CAM_PIN_GPIO_V_CAM_D1V8_EN, 1); gpio_free(CAM_PIN_GPIO_V_CAM_D1V8_EN); udelay(50); /* analog */ rc = camera_sensor_power_enable("8038_l8", 2800000, ®_8038_l8); pr_info("[CAM] analog sensor_power_enable(\"8038_l8\", 2.8V) == %d\n", rc); if (rc < 0) { pr_err("[CAM] sensor_power_enable(\"8038_l8\", 2.8V) FAILED %d\n", rc); goto enable_s5k4e5yx_analog_fail; } udelay(50); /* IO */ rc = gpio_request(CAM_PIN_GPIO_V_CAMIO_1V8_EN, "V_CAMIO_1V8_EN"); pr_info("[CAM] cam io gpio_request, %d\n", CAM_PIN_GPIO_V_CAMIO_1V8_EN); if (rc < 0) { pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAMIO_1V8_EN); goto enable_s5k4e5yx_io_fail; } gpio_direction_output(CAM_PIN_GPIO_V_CAMIO_1V8_EN, 1); gpio_free(CAM_PIN_GPIO_V_CAMIO_1V8_EN); udelay(50); return rc; enable_s5k4e5yx_io_fail: camera_sensor_power_disable(reg_8038_l8); enable_s5k4e5yx_analog_fail: rc = gpio_request(CAM_PIN_GPIO_V_CAM_D1V8_EN, "V_CAM_D1V8_EN"); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM_D1V8_EN); else { gpio_direction_output(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0); gpio_free(CAM_PIN_GPIO_V_CAM_D1V8_EN); } enable_s5k4e5yx_digital_fail: camera_sensor_power_disable(reg_8038_l17); enable_s5k4e5yx_vcm_fail: return rc; }
static void __init mini210_machine_init(void) { arm_pm_restart = smdkc110_pm_restart; s3c_pm_init(); mini210_wifi_init(); #ifdef CONFIG_DM9000 mini210_dm9000_init(); #endif platform_add_devices(mini210_devices, ARRAY_SIZE(mini210_devices)); #ifdef CONFIG_ANDROID_PMEM android_pmem_set_platdata(); #endif #ifdef CONFIG_KEYBOARD_SAMSUNG samsung_keypad_set_platdata(&mini210_keypad_data); #endif #ifdef CONFIG_TOUCHSCREEN_S3C2410 s3c24xx_ts_set_platdata(&s3c_ts_platform); #endif s3c_i2c0_set_platdata(NULL); s3c_i2c1_set_platdata(NULL); #ifdef CONFIG_TOUCHSCREEN_GOODIX if (mini210_get_ctp() == CTP_GT80X) { i2c2_data.frequency = 260*1000; } #endif s3c_i2c2_set_platdata(&i2c2_data); i2c_register_board_info(0, mini210_i2c_devs0, ARRAY_SIZE(mini210_i2c_devs0)); i2c_register_board_info(1, mini210_i2c_devs1, ARRAY_SIZE(mini210_i2c_devs1)); i2c_register_board_info(2, mini210_i2c_devs2, ARRAY_SIZE(mini210_i2c_devs2)); #ifdef CONFIG_TOUCHSCREEN_EGALAX i2c_register_board_info(5, i2c_devs5, ARRAY_SIZE(i2c_devs5)); #endif #ifdef CONFIG_S5PV210_SETUP_IDE s3c_ide_set_platdata(&mini210_ide_pdata); #endif #ifdef CONFIG_FB_S3C_MINI210 { struct s3cfb_lcd *mlcd = mini210_get_lcd(); if (!(mlcd->args & 0x0f)) { if (readl(S5PV210_GPF0_BASE + 0x184) & 0x10) mlcd->args |= (1 << 7); } mini210_fb_data.lcd = mlcd; s3c_fb_set_platdata(&mini210_fb_data); } #endif #ifdef CONFIG_S3C_DEV_HSMMC s3c_sdhci0_set_platdata(&mini210_hsmmc0_pdata); #endif #ifdef CONFIG_S3C_DEV_HSMMC1 s3c_sdhci1_set_platdata(&mini210_hsmmc1_pdata); #endif #ifdef CONFIG_S3C_DEV_HSMMC2 s3c_sdhci2_set_platdata(&mini210_hsmmc2_pdata); #endif #ifdef CONFIG_S3C_DEV_HSMMC3 s3c_sdhci3_set_platdata(&mini210_hsmmc3_pdata); #endif #ifdef CONFIG_VIDEO_FIMC /* fimc */ s3c_fimc0_set_platdata(&fimc_plat_lsi); s3c_fimc1_set_platdata(&fimc_plat_lsi); s3c_fimc2_set_platdata(&fimc_plat_lsi); #ifdef CONFIG_VIDEO_S5K4BA #ifdef CAM_ITU_CH_A smdkv210_cam0_power(1); #else smdkv210_cam1_power(1); #endif #endif #endif #ifdef CONFIG_VIDEO_FIMC_MIPI s3c_csis_set_platdata(NULL); #endif #ifdef CONFIG_VIDEO_JPEG_V2 s3c_jpeg_set_platdata(&jpeg_plat); #endif #ifdef CONFIG_VIDEO_MFC50 /* mfc */ s3c_mfc_set_platdata(NULL); #endif /* spi */ #ifdef CONFIG_SPI_S3C64XX if (!gpio_request(S5PV210_GPB(1), "SPI_CS0")) { gpio_direction_output(S5PV210_GPB(1), 1); s3c_gpio_cfgpin(S5PV210_GPB(1), S3C_GPIO_SFN(1)); s3c_gpio_setpull(S5PV210_GPB(1), S3C_GPIO_PULL_UP); s5pv210_spi_set_info(0, S5PV210_SPI_SRCCLK_PCLK, ARRAY_SIZE(smdk_spi0_csi)); } if (!gpio_request(S5PV210_GPB(5), "SPI_CS1")) { gpio_direction_output(S5PV210_GPB(5), 1); s3c_gpio_cfgpin(S5PV210_GPB(5), S3C_GPIO_SFN(1)); s3c_gpio_setpull(S5PV210_GPB(5), S3C_GPIO_PULL_UP); s5pv210_spi_set_info(1, S5PV210_SPI_SRCCLK_PCLK, ARRAY_SIZE(smdk_spi1_csi)); } spi_register_board_info(s3c_spi_devs, ARRAY_SIZE(s3c_spi_devs)); #endif mini210_otg_init(); mini210_ehci_init(); mini210_ohci_init(); clk_xusbxti.rate = 24000000; regulator_has_full_constraints(); mini210_setup_clocks(); /* write something into the INFORM6 register that we can use to * differentiate an unclear reboot from a clean reboot (which * writes a small integer code to INFORM6). */ __raw_writel(0xee, S5P_INFORM6); }
static void __init VAR_SOM_OM3X_init(void) { VAR_SOM_OM3X_twldata.vaux2 = &VAR_SOM_OM3X_vaux2; omap3_mux_init(board_mux, OMAP_PACKAGE_CUS); // USB phy enable if (gpio_request(24,"GPIO24")<0) printk(KERN_ERR "Can't get GPIO24 for USB phy reset\n"); gpio_direction_output(24, 1); gpio_set_value(24, 1); // SMSC 9221 interrupt if (gpio_request(29,"GPIO29")<0) printk(KERN_ERR "Can't get GPIO29 for ETH0\n"); gpio_direction_input(29); #if 0 #ifdef VER_2_1 omap_mux_init_gpio(VAR_SOM_OM3X_USB3_PWR_ENn, OMAP_PIN_INPUT_PULLUP); if (gpio_request(VAR_SOM_OM3X_USB3_PWR_ENn,"USB3_PWR_ENn")<0) printk(KERN_ERR "Can't get 167 for USB3 power enable\n"); gpio_direction_output(VAR_SOM_OM3X_USB3_PWR_ENn, 1); gpio_set_value(VAR_SOM_OM3X_USB3_PWR_ENn, 1); #endif #endif VAR_SOM_OM3X_i2c_init(); platform_add_devices(VAR_SOM_OM3X_devices, ARRAY_SIZE(VAR_SOM_OM3X_devices)); #if defined (CONFIG_TOUCHSCREEN_CTW6120) || defined (CONFIG_TOUCHSCREEN_ADS7846) spi_register_board_info(VAR_SOM_OM3X_spi_board_info, ARRAY_SIZE(VAR_SOM_OM3X_spi_board_info)); #endif omap_serial_init(); #ifdef CONFIG_NOP_USB_XCEIV usb_nop_xceiv_register(); #endif omap_mux_init_gpio(VAR_SOM_OM3X_DVI_PANEL_EN_GPIO, OMAP_PIN_INPUT_PULLUP); usb_musb_init(); usb_ehci_init(&ehci_pdata); VAR_SOM_OM3X_flash_init(); ads7846_dev_init(); ctw6120_dev_init(); VAR_SOM_OM3X_init_smsc911x(); #ifdef CONFIG_PANEL_VARISCITE VAR_SOM_OM3X_display_init(); #endif /* Ensure SDRC pins are mux'd for self-refresh */ omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT); /* Push Buttons */ bp_add_device_buttons(); }
static int __devinit switch_key_probe(struct platform_device *pdev) { int err; struct device *dev = &pdev->dev; printk("switch_key probe! \n"); switch_key_obj.flag_initialed = false; switch_key_obj.pdata = kzalloc(sizeof(struct switch_key_platform_data), GFP_KERNEL); if (!switch_key_obj.pdata) { DEBUG_ERR("Cannot allocate memory for switch_key_platform_data.\n"); err = -ENOMEM; goto exit; } switch_key_obj.pdata->irq_gpio = of_get_named_gpio_flags(dev->of_node, "goso,irq-gpio", 0, NULL); if(switch_key_obj.pdata->irq_gpio < 0){ DEBUG_ERR("get irq gpio failed\n"); err = -EINVAL; goto exit; } //init irq gpio err = gpio_request(switch_key_obj.pdata->irq_gpio, "switch_key irq"); if(err < 0){ DEBUG_ERR("request irq_gpio failed, err = %d\n", err); goto exit; } err = gpio_tlmm_config(GPIO_CFG(switch_key_obj.pdata->irq_gpio, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (err < 0) { DEBUG_ERR("gpio_tlmm_config irq_gpio failed, err = %d\n", err); goto error_gpio_init; } err = gpio_direction_output(switch_key_obj.pdata->irq_gpio, 1); if (err < 0) { DEBUG_ERR("gpio_direction_output irq_gpio failed, err = %d\n", err); goto error_gpio_init; } err = gpio_direction_input(switch_key_obj.pdata->irq_gpio); if (err < 0) { DEBUG_ERR("gpio_direction_input irq_gpio failed, err = %d\n", err); goto error_gpio_init; } //request irq switch_key_obj.pdata->irq = gpio_to_irq(switch_key_obj.pdata->irq_gpio); err = request_irq(switch_key_obj.pdata->irq, switch_key_irq_handler, \ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "switch_key", &(pdev->dev)); if(err){ DEBUG_ERR("Request IRQ for switch_key failed, return:%d\n",err); goto error_gpio_init; } INIT_DELAYED_WORK(&switch_key_obj.irq_work, switch_key_work_func); disable_irq(switch_key_obj.pdata->irq); enable_irq(switch_key_obj.pdata->irq); wake_lock_init(&switch_key_obj.wakelock, WAKE_LOCK_SUSPEND, "switch_key"); switch_key_obj.flag_initialed = true; printk("switch_key probe sucess! \n"); error_gpio_init: gpio_free(switch_key_obj.pdata->irq_gpio); exit: kfree(switch_key_obj.pdata); return err; }
static void enable_backlight(void) { imx_iomux_v3_setup_multiple_pads(bl_pads, ARRAY_SIZE(bl_pads)); gpio_direction_output(DISP0_PWR_EN, 1); }
void native_machine_restart(char *cmd) { /* workaround pull up on cpld / flash pin not being strong enough */ gpio_request(GPIO_PF0, "flash_cpld"); gpio_direction_output(GPIO_PF0, 0); }
static int __devinit init_matrix_gpio(struct platform_device *pdev, struct matrix_keypad *keypad) { const struct matrix_keypad_platform_data *pdata = keypad->pdata; int i, err = -EINVAL; /* initialized strobe lines as outputs, activated */ for (i = 0; i < pdata->num_col_gpios; i++) { err = gpio_request(pdata->col_gpios[i], "matrix_kbd_col"); if (err) { dev_err(&pdev->dev, "failed to request GPIO%d for COL%d\n", pdata->col_gpios[i], i); goto err_free_cols; } gpio_direction_output(pdata->col_gpios[i], !pdata->active_low); } for (i = 0; i < pdata->num_row_gpios; i++) { err = gpio_request(pdata->row_gpios[i], "matrix_kbd_row"); if (err) { dev_err(&pdev->dev, "failed to request GPIO%d for ROW%d\n", pdata->row_gpios[i], i); goto err_free_rows; } gpio_direction_input(pdata->row_gpios[i]); } if (pdata->clustered_irq > 0) { err = request_irq(pdata->clustered_irq, matrix_keypad_interrupt, pdata->clustered_irq_flags, "matrix-keypad", keypad); if (err < 0) { dev_err(&pdev->dev, "Unable to acquire clustered interrupt\n"); goto err_free_rows; } } else { for (i = 0; i < pdata->num_row_gpios; i++) { err = request_threaded_irq( gpio_to_irq(pdata->row_gpios[i]), NULL, matrix_keypad_interrupt, IRQF_DISABLED | IRQF_ONESHOT | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "matrix-keypad", keypad); if (err < 0) { dev_err(&pdev->dev, "Unable to acquire interrupt " "for GPIO line %i\n", pdata->row_gpios[i]); goto err_free_irqs; } } } /* initialized as disabled - enabled by input->open */ disable_row_irqs(keypad); return 0; err_free_irqs: while (--i >= 0) free_irq(gpio_to_irq(pdata->row_gpios[i]), keypad); i = pdata->num_row_gpios; err_free_rows: while (--i >= 0) gpio_free(pdata->row_gpios[i]); i = pdata->num_col_gpios; err_free_cols: while (--i >= 0) gpio_free(pdata->col_gpios[i]); return err; }
static int pn544_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; struct pn544_dev *pn544_dev = NULL; pn544_client = client; dprintk(PN544_DRV_NAME ": pn544_probe() start\n"); pn544_dev = kzalloc(sizeof(*pn544_dev), GFP_KERNEL); if (pn544_dev == NULL) { dev_err(&client->dev, "failed to allocate memory for module data\n"); ret = -ENOMEM; goto err_exit; } pn544_parse_dt(&client->dev, pn544_dev); pn544_dev->client = client; dprintk(PN544_DRV_NAME ":IRQ : %d\nVEN : %d\nFIRM : %d\n", pn544_dev->irq_gpio, pn544_dev->ven_gpio, pn544_dev->firm_gpio); ret = gpio_request(pn544_dev->irq_gpio, "nfc_int"); if (ret) { dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_int request failed!\n"); goto err_int; } ret = gpio_request(pn544_dev->ven_gpio, "nfc_ven"); if (ret) { dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_ven request failed!\n"); goto err_ven; } ret = gpio_request(pn544_dev->firm_gpio, "nfc_firm"); if (ret) { dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_firm request failed!\n"); goto err_firm; } pn544_gpio_enable(pn544_dev); ret = gpio_direction_output(pn544_dev->ven_gpio,1); ret = gpio_direction_output(pn544_dev->firm_gpio,0); ret = gpio_direction_input(pn544_dev->irq_gpio); /* init mutex and queues */ init_waitqueue_head(&pn544_dev->read_wq); mutex_init(&pn544_dev->read_mutex); #ifdef CONFIG_LGE_NFC_PRESTANDBY mutex_init(&mode_mutex); #endif spin_lock_init(&pn544_dev->irq_enabled_lock); pn544_dev->pn544_device.minor = MISC_DYNAMIC_MINOR; pn544_dev->pn544_device.name = PN544_DRV_NAME; pn544_dev->pn544_device.fops = &pn544_dev_fops; ret = misc_register(&pn544_dev->pn544_device); if (ret) { pr_err("%s : misc_register failed\n", __FILE__); goto err_misc_register; } /* request irq. the irq is set whenever the chip has data available * for reading. it is cleared when all data has been read. */ pr_info("%s : requesting IRQ %d\n", __func__, client->irq); pn544_dev->irq_enabled = true; ret = request_irq(pn544_gpio_to_irq(pn544_dev), pn544_dev_irq_handler, IRQF_TRIGGER_HIGH, client->name, pn544_dev); if (ret) { dev_err(&client->dev, "request_irq failed\n"); goto err_request_irq_failed; } #if !defined(LGE_NFC_HW_QCT_MSM8660)&&!defined(CONFIG_LGE_NFC_HW_QCT_MSM8255) enable_irq_wake(pn544_get_irq_pin(pn544_dev)); #endif pn544_disable_irq(pn544_dev); i2c_set_clientdata(client, pn544_dev); dprintk(PN544_DRV_NAME ": pn544_probe() end\n"); /* */ #ifdef CONFIG_LGE_NFC_PRESTANDBY if (pn544_validate_boot_mode()) { dprintk("%s : get in the standbyset\n", __func__); #ifdef CONFIG_LGE_NFC_MULTICORE_FASTBOOT { struct task_struct *th; th = kthread_create(pn544_factory_standby_set_thread, NULL, "pn544_factory_standby"); if (IS_ERR(th)) { ret = PTR_ERR(th); goto err_request_irq_failed; } wake_up_process(th); } #else pn544_factory_standby_set(); #endif /* */ } #endif return 0; err_request_irq_failed: misc_deregister(&pn544_dev->pn544_device); err_misc_register: mutex_destroy(&pn544_dev->read_mutex); #ifdef CONFIG_LGE_NFC_PRESTANDBY mutex_destroy(&mode_mutex); #endif gpio_free(pn544_dev->firm_gpio); err_firm: gpio_free(pn544_dev->ven_gpio); err_ven: gpio_free(pn544_dev->irq_gpio); err_int: kfree(pn544_dev); err_exit: pr_err(PN544_DRV_NAME ": pn544_dev is null\n"); pr_err(PN544_DRV_NAME ": pn544_probe() end with error!\n"); return ret; }
static int __init atmel_pwm_bl_probe(struct platform_device *pdev) { struct backlight_properties props; const struct atmel_pwm_bl_platform_data *pdata; struct backlight_device *bldev; struct atmel_pwm_bl *pwmbl; int retval; pwmbl = devm_kzalloc(&pdev->dev, sizeof(struct atmel_pwm_bl), GFP_KERNEL); if (!pwmbl) return -ENOMEM; pwmbl->pdev = pdev; pdata = pdev->dev.platform_data; if (!pdata) { retval = -ENODEV; goto err_free_mem; } if (pdata->pwm_compare_max < pdata->pwm_duty_max || pdata->pwm_duty_min > pdata->pwm_duty_max || pdata->pwm_frequency == 0) { retval = -EINVAL; goto err_free_mem; } pwmbl->pdata = pdata; pwmbl->gpio_on = pdata->gpio_on; retval = pwm_channel_alloc(pdata->pwm_channel, &pwmbl->pwmc); if (retval) goto err_free_mem; if (pwmbl->gpio_on != -1) { retval = devm_gpio_request(&pdev->dev, pwmbl->gpio_on, "gpio_atmel_pwm_bl"); if (retval) { pwmbl->gpio_on = -1; goto err_free_pwm; } /* Turn display off by default. */ retval = gpio_direction_output(pwmbl->gpio_on, 0 ^ pdata->on_active_low); if (retval) goto err_free_pwm; } memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min; bldev = backlight_device_register("atmel-pwm-bl", &pdev->dev, pwmbl, &atmel_pwm_bl_ops, &props); if (IS_ERR(bldev)) { retval = PTR_ERR(bldev); goto err_free_pwm; } pwmbl->bldev = bldev; platform_set_drvdata(pdev, pwmbl); /* Power up the backlight by default at middle intesity. */ bldev->props.power = FB_BLANK_UNBLANK; bldev->props.brightness = bldev->props.max_brightness / 2; retval = atmel_pwm_bl_init_pwm(pwmbl); if (retval) goto err_free_bl_dev; atmel_pwm_bl_set_intensity(bldev); return 0; err_free_bl_dev: platform_set_drvdata(pdev, NULL); backlight_device_unregister(bldev); err_free_pwm: pwm_channel_free(&pwmbl->pwmc); err_free_mem: return retval; }
static int __devinit bd60910_bl_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct bd60910_bl_data *data = kzalloc(sizeof(struct bd60910_bl_data), GFP_KERNEL); int ret = 0; TRACE_CALL() ; if (!data) return -ENOMEM; // FORTE data->comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj; ret = gpio_request(BL_ENABLE, "backlight"); if (ret) { dev_dbg(&data->bl->dev, "Unable to request gpio!\n"); goto err_gpio_bl; } ret = gpio_direction_output(BL_ENABLE, 1); // TODO: FORTE Rev0.1 timing ??? if (ret) goto err_gpio_dir; i2c_set_clientdata(client, data); data->i2c = client; bl_i2c_client = client ; data->bl = backlight_device_register("s5p_bl" /*"bd60910"*/, &client->dev, data, &bl_ops, NULL); /* YUNG@DISYS GB */ if (IS_ERR(data->bl)) { ret = PTR_ERR(data->bl); goto err_reg; } data->bl->props.brightness = 69; data->bl->props.max_brightness = 255 ; data->bl->props.power = FB_BLANK_UNBLANK; backlight_update_status(data->bl); #ifdef CONFIG_BL_HAS_EARLYSUSPEND #ifdef CONFIG_MACH_TREBON bl_early_suspend.suspend = NULL; bl_early_suspend.resume = NULL; #else bl_early_suspend.suspend = bd60910_bl_early_suspend; bl_early_suspend.resume = bd60910_bl_late_resume; #endif #if defined(CONFIG_MACH_CHIEF) && !defined(CONFIG_TIKAL_MPCS) bl_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; #else bl_early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN; #endif register_early_suspend(&bl_early_suspend); #endif #if defined(CONFIG_MACH_CHIEF) && !defined(CONFIG_MACH_TREBON) INIT_WORK(&bd60910_bl_work,bd60910_bl_workfunc); #endif return 0; err_reg: data->bl = NULL; i2c_set_clientdata(client, NULL); err_gpio_dir: gpio_free(BL_ENABLE); err_gpio_bl: kfree(data); return ret; }
int tdmb_fc8050_spi_write_read(uint8* tx_data, int tx_length, uint8 *rx_data, int rx_length) { int rc; struct spi_transfer t = { .tx_buf = tx_data, .rx_buf = rx_data, .len = tx_length+rx_length, }; struct spi_message m; if (fc8050_ctrl_info.spi_ptr == NULL) { printk("tdmb_fc8050_spi_write_read error txdata=0x%x, length=%d\n", (unsigned int)tx_data, tx_length+rx_length); } mutex_lock(&fc8050_ctrl_info.mutex); spi_message_init(&m); spi_message_add_tail(&t, &m); rc = spi_sync(fc8050_ctrl_info.spi_ptr, &m); if ( rc < 0 ) { printk("tdmb_fc8050_spi_read_burst result(%d), actual_len=%d\n",rc, m.actual_length); } mutex_unlock(&fc8050_ctrl_info.mutex); return TRUE; } #ifdef FEATURE_DMB_USE_WORKQUEUE static irqreturn_t broadcast_tdmb_spi_isr(int irq, void *handle) { struct tdmb_fc8050_ctrl_blk* fc8050_info_p; unsigned long flag; fc8050_info_p = (struct tdmb_fc8050_ctrl_blk *)handle; if ( fc8050_info_p && fc8050_info_p->TdmbPowerOnState ) { if (fc8050_info_p->spi_irq_status) { printk("######### spi read function is so late skip #########\n"); return IRQ_HANDLED; } // printk("***** broadcast_tdmb_spi_isr coming *******\n"); spin_lock_irqsave(&fc8050_info_p->spin_lock, flag); queue_work(fc8050_info_p->spi_wq, &fc8050_info_p->spi_work); spin_unlock_irqrestore(&fc8050_info_p->spin_lock, flag); } else { printk("broadcast_tdmb_spi_isr is called, but device is off state\n"); } return IRQ_HANDLED; } static void broacast_tdmb_spi_work(struct work_struct *tdmb_work) { struct tdmb_fc8050_ctrl_blk *pTdmbWorkData; pTdmbWorkData = container_of(tdmb_work, struct tdmb_fc8050_ctrl_blk, spi_work); if ( pTdmbWorkData ) { // printk("broadcast_tdmb_spi_work START\n"); fc8050_isr_control(0); pTdmbWorkData->spi_irq_status = TRUE; broadcast_drv_if_isr(); pTdmbWorkData->spi_irq_status = FALSE; fc8050_isr_control(1); // printk("broadcast_tdmb_spi_work END\n"); // printk("broacast_tdmb_spi_work is called handle=0x%x\n", (unsigned int)pTdmbWorkData); } else { printk("~~~~~~~broadcast_tdmb_spi_work call but pTdmbworkData is NULL ~~~~~~~\n"); } } #else static irqreturn_t broadcast_tdmb_spi_event_handler(int irq, void *handle) { struct tdmb_fc8050_ctrl_blk *fc8050_info_p; fc8050_info_p = (struct tdmb_fc8050_ctrl_blk *)handle; if ( fc8050_info_p && fc8050_info_p->TdmbPowerOnState ) { if (fc8050_info_p->spi_irq_status) { printk("######### spi read function is so late skip ignore #########\n"); return IRQ_HANDLED; } fc8050_isr_control(0); fc8050_info_p->spi_irq_status = TRUE; broadcast_drv_if_isr(); fc8050_info_p->spi_irq_status = FALSE; fc8050_isr_control(1); } else { printk("broadcast_tdmb_spi_isr is called, but device is off state\n"); } return IRQ_HANDLED; } #endif static int broadcast_tdmb_fc8050_probe(struct spi_device *spi) { int rc; #ifdef ANTENNA_SWITCHING struct pm_gpio GPIO11_CFG = { .direction = PM_GPIO_DIR_OUT, .pull = PM_GPIO_PULL_NO, .function = PM_GPIO_FUNC_NORMAL, .vin_sel = 2, /* for ESD TEST in I-pjt */ .inv_int_pol = 0, }; struct pm_gpio GPIO12_CFG = { .direction = PM_GPIO_DIR_OUT, .pull = PM_GPIO_PULL_NO, .function = PM_GPIO_FUNC_NORMAL, .vin_sel = 2, /* for ESD TEST in I-pjt */ .inv_int_pol = 0, }; #endif /* ANTENNA_SWITCHING */ fc8050_ctrl_info.TdmbPowerOnState = FALSE; fc8050_ctrl_info.spi_ptr = spi; fc8050_ctrl_info.spi_ptr->mode = SPI_MODE_0; fc8050_ctrl_info.spi_ptr->bits_per_word = 8; fc8050_ctrl_info.spi_ptr->max_speed_hz = ( 24000*1000 ); rc = spi_setup(spi); printk("broadcast_tdmb_fc8050_probe spi_setup=%d\n", rc); BBM_HOSTIF_SELECT(NULL, 1); #ifdef FEATURE_DMB_USE_WORKQUEUE INIT_WORK(&fc8050_ctrl_info.spi_work, broacast_tdmb_spi_work); fc8050_ctrl_info.spi_wq = create_singlethread_workqueue("tdmb_spi_wq"); if(fc8050_ctrl_info.spi_wq == NULL){ printk("Failed to setup tdmb spi workqueue \n"); return -ENOMEM; } #endif #ifdef FEATURE_DMB_USE_WORKQUEUE rc = request_irq(spi->irq, broadcast_tdmb_spi_isr, IRQF_DISABLED | IRQF_TRIGGER_FALLING, spi->dev.driver->name, &fc8050_ctrl_info); #else rc = request_threaded_irq(spi->irq, NULL, broadcast_tdmb_spi_event_handler, IRQF_DISABLED | IRQF_TRIGGER_FALLING, spi->dev.driver->name, &fc8050_ctrl_info); #endif printk("broadcast_tdmb_fc8050_probe request_irq=%d\n", rc); gpio_request(101, "DMB_RESET_N"); gpio_request(102, "DMB_EN"); gpio_request(107, "DMB_INT_N"); gpio_direction_output(DMB_RESET_N, false); gpio_direction_output(DMB_EN, false); gpio_direction_output(DMB_INT_N, false); #ifdef ANTENNA_SWITCHING pm8xxx_gpio_config(DMB_ANT_SEL_P, &GPIO11_CFG); pm8xxx_gpio_config(DMB_ANT_SEL_N, &GPIO12_CFG); gpio_set_value_cansleep(DMB_ANT_SEL_P, 1); /* for ESD TEST in I-pjt */ gpio_set_value_cansleep(DMB_ANT_SEL_N, 0); /* for ESD TEST in I-pjt */ #endif /* ANTENNA_SWITCHING */ tdmb_fc8050_interrupt_lock(); mutex_init(&fc8050_ctrl_info.mutex); wake_lock_init(&fc8050_ctrl_info.wake_lock, WAKE_LOCK_SUSPEND, dev_name(&spi->dev)); spin_lock_init(&fc8050_ctrl_info.spin_lock); #ifdef PM_QOS pm_qos_add_request(&fc8050_ctrl_info.pm_req_list, PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE); #endif /* PM_QOS */ printk("broadcast_fc8050_probe End\n"); return rc; } static int broadcast_tdmb_fc8050_remove(struct spi_device *spi) { printk("broadcast_tdmb_fc8050_remove \n"); #ifdef FEATURE_DMB_USE_WORKQUEUE if (fc8050_ctrl_info.spi_wq) { flush_workqueue(fc8050_ctrl_info.spi_wq); destroy_workqueue(fc8050_ctrl_info.spi_wq); } #endif free_irq(spi->irq, &fc8050_ctrl_info); mutex_destroy(&fc8050_ctrl_info.mutex); wake_lock_destroy(&fc8050_ctrl_info.wake_lock); #ifdef PM_QOS pm_qos_remove_request(&fc8050_ctrl_info.pm_req_list); #endif /* PM_QOS */ memset((unsigned char*)&fc8050_ctrl_info, 0x0, sizeof(struct tdmb_fc8050_ctrl_blk)); return 0; } static int broadcast_tdmb_fc8050_suspend(struct spi_device *spi, pm_message_t mesg) { printk("broadcast_tdmb_fc8050_suspend \n"); return 0; }
static int __init bd60910_bl_init(void) { #ifdef BD60910_DRIVER_LEGACY TRACE_CALL() ; return i2c_add_driver(&bd60910_bl_driver); #else struct i2c_board_info info ; struct i2c_adapter *adapter ; int ret ; TRACE_CALL() ; #if 0 // backlight_check {{ s3c_gpio_cfgpin(GPIO_DISPLAY_ID, S3C_GPIO_INPUT); s3c_gpio_setpull(GPIO_DISPLAY_ID, S3C_GPIO_PULL_UP); ret = gpio_get_value(GPIO_DISPLAY_ID); if(0/*ret*/) // for chief { printk(KERN_ERR "===============================================\n"); printk(KERN_ERR " NOT CONNECT BACKLIGHT"); printk(KERN_ERR "===============================================\n"); s3c_gpio_setpull(GPIO_DISPLAY_ID, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(BL_SCL, S3C_GPIO_INPUT); s3c_gpio_setpull(BL_SCL, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(BL_SDA, S3C_GPIO_INPUT); s3c_gpio_setpull(BL_SCL, S3C_GPIO_PULL_NONE); gpio_direction_output(BL_ENABLE, GPIO_LEVEL_LOW); return; } // backlight_check }} #endif ret = i2c_add_driver(&bd60910_bl_driver) ; if (ret != 0) { printk(KERN_ERR "%s i2c fail %d\n", __FUNCTION__, ret) ; return ret ; } memset(&info, 0, sizeof(info)) ; info.addr = BD60910_I2C_ADDR>>1 ; strlcpy(info.type, "bd60910-i2c", I2C_NAME_SIZE) ; adapter = i2c_get_adapter(BD60910_I2C_BUS_NUM) ; // TODO: if (!adapter) { printk(KERN_ERR "not found apater i2c %d\n", BD60910_I2C_BUS_NUM) ; goto err_driver ; } i2c_new_device(adapter, &info) ; // printk(KERN_ERR "info type=%s addr=%02x\n", info.type, info.addr) ; i2c_put_adapter(adapter) ; return 0 ; err_driver : i2c_del_driver(&bd60910_bl_driver) ; return -ENODEV ; #endif }
static int msm8930_s5k6a2ya_vreg_off(void) { int rc = 0; pr_info("[CAM] %s\n", __func__); /* reset pin */ rc = gpio_request(CAM_PIN_GPIO_CAM2_RSTz, "s5k6a2ya"); pr_info("[CAM] reset pin gpio_request, %d\n", CAM_PIN_GPIO_CAM2_RSTz); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_RSTz); else { gpio_direction_output(CAM_PIN_GPIO_CAM2_RSTz, 0); gpio_free(CAM_PIN_GPIO_CAM2_RSTz); } udelay(50); /* analog */ pr_info("[CAM] sensor_power_disable(\"8038_l8\") == %d\n", rc); rc = camera_sensor_power_disable(reg_8038_l8); if (rc < 0) pr_err("[CAM] sensor_power_disable(\"reg_8038_l8\") FAILED %d\n", rc); udelay(50); /* 2nd digital */ rc = gpio_request(CAM_PIN_GPIO_V_CAM2_D1V2_EN, "V_CAM2_D1V2_EN"); pr_info("[CAM] 2nd cam digital gpio_request, %d\n", CAM_PIN_GPIO_V_CAM2_D1V2_EN); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM2_D1V2_EN); else { gpio_direction_output(CAM_PIN_GPIO_V_CAM2_D1V2_EN, 0); gpio_free(CAM_PIN_GPIO_V_CAM2_D1V2_EN); } msleep(1); /* digital */ rc = gpio_request(CAM_PIN_GPIO_V_CAM_D1V8_EN, "V_CAM_D1V8_EN"); pr_info("[CAM] digital gpio_request, %d\n", CAM_PIN_GPIO_V_CAM_D1V8_EN); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM_D1V8_EN); else { gpio_tlmm_config( GPIO_CFG(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_direction_output(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0); gpio_free(CAM_PIN_GPIO_V_CAM_D1V8_EN); } udelay(50); /* IO */ rc = gpio_request(CAM_PIN_GPIO_V_CAMIO_1V8_EN, "V_CAMIO_1V8_EN"); pr_info("[CAM] cam io gpio_request, %d\n", CAM_PIN_GPIO_V_CAMIO_1V8_EN); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAMIO_1V8_EN); else { gpio_direction_output(CAM_PIN_GPIO_V_CAMIO_1V8_EN, 0); gpio_free(CAM_PIN_GPIO_V_CAMIO_1V8_EN); } /* VCM PD */ rc = gpio_request(CAM_PIN_GPIO_CAM_VCM_PD, "CAM_VCM_PD"); pr_info("[CAM] vcm pd gpio_request, %d\n", CAM_PIN_GPIO_CAM_VCM_PD); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM_VCM_PD); else { gpio_direction_output(CAM_PIN_GPIO_CAM_VCM_PD, 0); gpio_free(CAM_PIN_GPIO_CAM_VCM_PD); } udelay(50); /* VCM */ pr_info("[CAM] sensor_power_disable(\"reg_8038_l17\") == %d\n", rc); rc = camera_sensor_power_disable(reg_8038_l17); if (rc < 0) pr_err("[CAM] sensor_power_disable(\"reg_8038_l17\") FAILED %d\n", rc); /* MIPI Switch */ rc = gpio_request(CAM_PIN_GPIO_CAM2_SEL, "CAM2_SEL"); pr_info("[CAM] cam sel gpio_request, %d\n", CAM_PIN_GPIO_CAM2_SEL); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_SEL); else { gpio_direction_output(CAM_PIN_GPIO_CAM2_SEL, 0); gpio_free(CAM_PIN_GPIO_CAM2_SEL); } udelay(50); return rc; }
static void __init incrediblec_init(void) { int ret; struct kobject *properties_kobj; printk("incrediblec_init() revision=%d, engineerid=%d\n", system_rev, engineerid); msm_hw_reset_hook = incrediblec_reset; if (0 == engineerid || 0xF == engineerid) { mdp_pmem_pdata.start = MSM_PMEM_MDP_XA_BASE; android_pmem_adsp_pdata.start = MSM_PMEM_ADSP_XA_BASE; msm_kgsl_resources[1].start = MSM_GPU_MEM_XA_BASE; msm_kgsl_resources[1].end = MSM_GPU_MEM_XA_BASE + MSM_GPU_MEM_SIZE - 1; } else if (engineerid >= 3) { mdp_pmem_pdata.start = MSM_PMEM_MDP_BASE + MSM_MEM_128MB_OFFSET; android_pmem_adsp_pdata.start = MSM_PMEM_ADSP_BASE + MSM_MEM_128MB_OFFSET; msm_kgsl_resources[1].start = MSM_GPU_MEM_BASE; msm_kgsl_resources[1].end = msm_kgsl_resources[1].start + MSM_GPU_MEM_SIZE - 1; } OJ_BMA_power(); gpio_direction_output(INCREDIBLEC_GPIO_PROXIMITY_EN_N, 0); msm_acpu_clock_init(&incrediblec_clock_data); perflock_init(&incrediblec_perflock_data); #if defined(CONFIG_MSM_SERIAL_DEBUGGER) msm_serial_debug_init(MSM_UART1_PHYS, INT_UART1, &msm_device_uart1.dev, 1, INT_UART1_RX); #endif #ifdef CONFIG_ARCH_QSD8X50 bt_export_bd_address(); #endif /* set the gpu power rail to manual mode so clk en/dis will not * turn off gpu power, and hang it on resume */ incrediblec_kgsl_power_rail_mode(0); incrediblec_kgsl_power(true); #ifdef CONFIG_SERIAL_MSM_HS msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata; msm_device_uart_dm1.name = "msm_serial_hs_bcm"; /* for bcm */ #endif incrediblec_config_uart_gpios(); config_gpio_table(camera_off_gpio_table, ARRAY_SIZE(camera_off_gpio_table)); /*gpio_direction_output(INCREDIBLEC_GPIO_TP_LS_EN, 0);*/ gpio_direction_output(INCREDIBLEC_GPIO_TP_EN, 0); incrediblec_audio_init(); msm_device_i2c_init(); #ifdef CONFIG_MICROP_COMMON incrediblec_microp_init(); #endif msm_init_ums_lun(2); /*0: sd card, 1: moving nand*/ msm_register_usb_phy_init_seq(incrediblec_phy_init_seq); msm_hsusb_set_product(incrediblec_usb_products, ARRAY_SIZE(incrediblec_usb_products)); msm_register_uart_usb_switch(NULL); msm_add_usb_id_pin_gpio(INCREDIBLEC_GPIO_USB_ID_PIN); msm_add_usb_devices(msm_hsusb_8x50_phy_reset, NULL); if (system_rev >= 2) { microp_data.num_functions = ARRAY_SIZE(microp_functions_1); microp_data.microp_function = microp_functions_1; } platform_add_devices(devices, ARRAY_SIZE(devices)); i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices)); ret = incrediblec_init_mmc(system_rev); if (ret != 0) pr_crit("%s: Unable to initialize MMC\n", __func__); properties_kobj = kobject_create_and_add("board_properties", NULL); if (properties_kobj) ret = sysfs_create_group(properties_kobj, &incrediblec_properties_attr_group); if (!properties_kobj || ret) pr_err("failed to create board_properties\n"); msm_init_pmic_vibrator(); config_gpio_table(incrediblec_usb_phy_3v3_table, ARRAY_SIZE(incrediblec_usb_phy_3v3_table)); config_gpio_table(usb_ID_PIN_table, ARRAY_SIZE(usb_ID_PIN_table)); gpio_direction_output(INCREDIBLEC_USB_PHY_3V3_ENABLE, 1); }
static int msm8930_s5k6a1gx_vreg_on(void) { int rc; pr_info("[CAM] %s\n", __func__); /* VCM */ rc = camera_sensor_power_enable("8038_l17", 2800000, ®_8038_l17); pr_info("[CAM] sensor_power_enable(\"8038_l17\", 2.8V) == %d\n", rc); if (rc < 0) { pr_err("[CAM] sensor_power_enable(\"8038_l17\", 2.8V) FAILED %d\n", rc); goto enable_s5k6a1gx_vcm_fail; } udelay(50); /* digital */ rc = gpio_request(CAM_PIN_GPIO_V_CAM_D1V8_EN, "V_CAM_D1V8_EN"); pr_info("[CAM] digital gpio_request, %d\n", CAM_PIN_GPIO_V_CAM_D1V8_EN); if (rc < 0) { pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM_D1V8_EN); goto enable_s5k6a1gx_digital_fail; } gpio_tlmm_config( GPIO_CFG(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_direction_output(CAM_PIN_GPIO_V_CAM_D1V8_EN, 1); gpio_free(CAM_PIN_GPIO_V_CAM_D1V8_EN); /* VCM PD */ /* TODO */ rc = gpio_request(CAM_PIN_GPIO_CAM_VCM_PD, "CAM_VCM_PD"); pr_info("[CAM] vcm pd gpio_request, %d\n", CAM_PIN_GPIO_CAM_VCM_PD); if (rc < 0 && rc != -EBUSY) { pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM_VCM_PD); goto enable_s5k6a1gx_vcm_pd; } else rc = 0; gpio_direction_output(CAM_PIN_GPIO_CAM_VCM_PD, 1); gpio_free(CAM_PIN_GPIO_CAM_VCM_PD); udelay(500); /* analog */ rc = camera_sensor_power_enable("8038_l8", 2800000, ®_8038_l8); pr_info("[CAM] sensor_power_enable(\"8038_l8\", 2.8V) == %d\n", rc); if (rc < 0) { pr_err("[CAM] sensor_power_enable(\"8038_l8\", 2.8V) FAILED %d\n", rc); goto enable_s5k6a1gx_analog_fail; } udelay(50); /* IO */ rc = gpio_request(CAM_PIN_GPIO_V_CAMIO_1V8_EN, "V_CAMIO_1V8_EN"); pr_info("[CAM] cam io gpio_request, %d\n", CAM_PIN_GPIO_V_CAMIO_1V8_EN); if (rc < 0) { pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAMIO_1V8_EN); goto enable_s5k6a1gx_io_fail; } gpio_direction_output(CAM_PIN_GPIO_V_CAMIO_1V8_EN, 1); gpio_free(CAM_PIN_GPIO_V_CAMIO_1V8_EN); udelay(50); /* reset pin */ rc = gpio_request(CAM_PIN_GPIO_CAM2_RSTz, "s5k6a1gx"); pr_info("[CAM] reset pin gpio_request, %d\n", CAM_PIN_GPIO_CAM2_RSTz); if (rc < 0) { pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_RSTz); goto enable_s5k6a1gx_rst_fail; } gpio_direction_output(CAM_PIN_GPIO_CAM2_RSTz, 1); gpio_free(CAM_PIN_GPIO_CAM2_RSTz); udelay(50); /* 2nd cam digital */ rc = gpio_request(CAM_PIN_GPIO_V_CAM2_D1V2_EN, "V_CAM2_D1V2_EN"); pr_info("[CAM] 2nd cam digital gpio_request, %d\n", CAM_PIN_GPIO_V_CAM2_D1V2_EN); if (rc < 0) { pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM2_D1V2_EN); goto enable_s5k6a1gx_2nd_digital_fail; } gpio_direction_output(CAM_PIN_GPIO_V_CAM2_D1V2_EN, 1); gpio_free(CAM_PIN_GPIO_V_CAM2_D1V2_EN); msleep(1); return rc; enable_s5k6a1gx_2nd_digital_fail: rc = gpio_request(CAM_PIN_GPIO_CAM2_RSTz, "s5k6a1gx"); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_RSTz); else { gpio_direction_output(CAM_PIN_GPIO_CAM2_RSTz, 0); gpio_free(CAM_PIN_GPIO_CAM2_RSTz); } enable_s5k6a1gx_rst_fail: rc = gpio_request(CAM_PIN_GPIO_V_CAMIO_1V8_EN, "V_CAMIO_1V8_EN"); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAMIO_1V8_EN); else { gpio_direction_output(CAM_PIN_GPIO_V_CAMIO_1V8_EN, 0); gpio_free(CAM_PIN_GPIO_V_CAMIO_1V8_EN); } enable_s5k6a1gx_io_fail: camera_sensor_power_disable(reg_8038_l8); enable_s5k6a1gx_analog_fail: rc = gpio_request(CAM_PIN_GPIO_CAM_VCM_PD, "CAM_VCM_PD"); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM_VCM_PD); else { gpio_direction_output(CAM_PIN_GPIO_CAM_VCM_PD, 0); gpio_free(CAM_PIN_GPIO_CAM_VCM_PD); } enable_s5k6a1gx_vcm_pd: rc = gpio_request(CAM_PIN_GPIO_V_CAM_D1V8_EN, "V_CAM_D1V8_EN"); if (rc < 0) pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM_D1V8_EN); else { gpio_direction_output(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0); gpio_free(CAM_PIN_GPIO_V_CAM_D1V8_EN); } enable_s5k6a1gx_digital_fail: camera_sensor_power_disable(reg_8038_l17); enable_s5k6a1gx_vcm_fail: return rc; }
static void init_sk_gpios(void) { gpio_direction_output(CONFIG_PM_EMMC_RESET_GPIO, 1); }
static inline void setmosi(struct spi_device *dev, int on) { struct s3c64xx_spigpio *sg = spidev_to_sg(dev); gpio_direction_output(sg->info->pin_mosi, on ? 1 : 0); }
static int ijb_vzw_bluetooth_power(int on) { int ret, pin; printk(KERN_ERR"[LG_BTUI] %s power : %d ", __func__, on); if(on) { if(configure_uart_gpios(1)) { printk(KERN_ERR"bluetooth_power on fail"); return -EIO; } if(configure_pcm_gpios(1)) { printk(KERN_ERR "bluetooth_power on fail"); return -EIO; } for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on); pin++) { ret = gpio_tlmm_config(bt_config_power_on[pin],GPIO_CFG_ENABLE); if (ret) { printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=fg%d\n",__func__, bt_config_power_on[pin], ret); return -EIO; } gpio_direction_output(BT_RESET_N, 0); mdelay(100); gpio_direction_output(BT_RESET_N, 1); mdelay(100); } } else { gpio_direction_output(BT_RESET_N,0); if(configure_uart_gpios(0)) { printk(KERN_ERR"bluetooth_power on fail"); return -EIO; } if(configure_pcm_gpios(0)) { printk(KERN_ERR "bluetooth_power on fail"); return -EIO; } for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off); pin++) { ret = gpio_tlmm_config(bt_config_power_off[pin],GPIO_CFG_ENABLE); if (ret) { printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",__func__, bt_config_power_off[pin], ret); return -EIO; } } } return 0; }
static int lbee9qmb_rfkill_btwake_probe(struct platform_device *pdev) { struct lbee9qmb_platform_data *plat = pdev->dev.platform_data; struct rfkill *rfkill; int rc; int irq; int ret; int host_wake; if (!plat) { dev_err(&pdev->dev, "no platform data\n"); return -ENOSYS; } wake_lock_init(&bt_lpm.bt_wake_lock, WAKE_LOCK_SUSPEND, "bt_wake"); #ifdef BRCM_HOST_WAKE wake_lock_init(&bt_lpm.host_wake_lock, WAKE_LOCK_SUSPEND, "host_wake"); bt_lpm.gpio_host_wake=plat->gpio_hostwake; //spin_lock_init(&bt_lpm.bt_lock); INIT_WORK(&bt_lpm.host_wake_work, brcm_host_wake_work_func); #endif rc = gpio_request(plat->gpio_btwake, "lbee9qmb_reset_btwake"); if (rc < 0) { dev_err(&pdev->dev, "gpio_request failed\n"); return rc; } rfkill = rfkill_alloc("lbee9qmb-rfkill_btwake", &pdev->dev, RFKILL_TYPE_BLUETOOTH, &lbee9qmb_rfkill_btwake_ops, pdev); if (!rfkill) { rc = -ENOMEM; goto fail_gpio; } platform_set_drvdata(pdev, rfkill); gpio_direction_output(plat->gpio_btwake, 1); rc = rfkill_register(rfkill); if (rc < 0) goto fail_alloc; #ifdef BRCM_HOST_WAKE rc = gpio_request(plat->gpio_hostwake, "lbee9qmb_reset_hostwake"); gpio_direction_input(plat->gpio_hostwake); host_wake=gpio_get_value(bt_lpm.gpio_host_wake); irq = gpio_to_irq(plat->gpio_hostwake); bt_lpm.host_wake_irq=irq; #ifdef BRCM_WAKELOCKTIMEOUT hrtimer_init(&bt_lpm.check_hostwakeup_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); bt_lpm.check_hostwakeup_delay = ktime_set(5, 0); /* 5 sec */ bt_lpm.check_hostwakeup_timer.function = check_hostwakeup; set_irq_type(irq, IRQ_TYPE_EDGE_RISING); ret = request_irq(irq, host_wake_isr, 0, "bt host_wake", NULL); #else ret = request_irq(irq, host_wake_isr, IRQF_TRIGGER_HIGH, "bt host_wake", NULL); #endif printk(KERN_ERR "BRCM_LPM: irq=%d ret=%d HOST_WAKE=%d\n",irq,ret,host_wake); #endif return 0; fail_alloc: rfkill_destroy(rfkill); fail_gpio: gpio_free(plat->gpio_btwake); return rc; }
static int charging_ic_probe(struct platform_device *dev) { int ret = 0; ret = gpio_request(CHG_EN_SET_N_OMAP, "hub charging_ic_en"); if (ret < 0) { printk(KERN_ERR "%s: Failed to request GPIO_%d for " "charging_ic\n", __func__, CHG_EN_SET_N_OMAP); return -ENOSYS; } gpio_direction_output(CHG_EN_SET_N_OMAP, 0); ret = gpio_request(CHG_STATUS_N_OMAP, "hub charging_ic_status"); if (ret < 0) { printk(KERN_ERR "%s: Failed to request GPIO_%d for " "charging_ic_status\n", __func__, CHG_STATUS_N_OMAP); goto err_gpio_request_failed; } gpio_direction_input(CHG_STATUS_N_OMAP); ret = request_irq(gpio_to_irq(CHG_STATUS_N_OMAP), charging_ic_interrupt_handler, IRQF_TRIGGER_RISING, "Charging_ic_driver", NULL); if (ret < 0) { printk(KERN_ERR "%s: Failed to request IRQ for " "charging_ic_status\n", __func__); goto err_request_irq_failed; } #ifdef CONFIG_LGE_CHARGE_CONTROL_BATTERY_FET ret = gpio_request(CHAR_CONTROL, "hub battery_fet"); if (ret < 0) { printk(KERN_ERR "%s: Failed to request GPIO_%d for " "charging_ic\n", __func__, CHAR_CONTROL); goto err_gpio_request_char_control; } gpio_direction_output(CHAR_CONTROL, 0); #endif INIT_DELAYED_WORK(&charging_ic_int_work, charging_ic_work_func); wake_lock_init(&power_off_charging_lock, WAKE_LOCK_SUSPEND, "Power Off Charging"); charging_ic_status = CHARGING_IC_DEACTIVE; hub_charging_ic_intialize(); // for AT Command AT%CHARGE // sysfs path : /sys/devices/platform/hub_charging_ic/charging_state ret = device_create_file(&dev->dev, &dev_attr_charging_state); if (ret < 0) { pr_err("%s:File device creation failed: %d\n", __func__, ret); //ret = -ENODEV; } // for Power Off Charging // sysfs path : /sys/devices/platform/hub_charging_ic/power_off_charging ret = device_create_file(&dev->dev, &dev_attr_power_off_charging); if (ret < 0) { pr_err("%s:File device creation failed: %d\n", __func__, ret); //ret = -ENODEV; } enable_irq_wake(gpio_to_irq(CHG_STATUS_N_OMAP)); //20101104 [email protected] enable charger wakeup return 0; #ifdef CONFIG_LGE_CHARGE_CONTROL_BATTERY_FET gpio_free(CHAR_CONTROL); err_gpio_request_char_control: #endif free_irq(gpio_to_irq(CHG_STATUS_N_OMAP), NULL); err_request_irq_failed: gpio_free(CHG_STATUS_N_OMAP); err_gpio_request_failed: gpio_free(CHG_EN_SET_N_OMAP); return ret; }
void touchkey_work_func(struct work_struct *p) { u8 data[10]; int ret; int retry = 10; int status; #if 0 if (gpio_get_value(_3_GPIO_TOUCH_INT)) { printk(KERN_DEBUG "[TouchKey] Unknown state.\n", __func__); enable_irq(IRQ_TOUCH_INT); return; } #endif set_touchkey_debug('a'); #ifdef CONFIG_CPU_FREQ /* set_dvfs_target_level(LEV_800MHZ); */ #endif ret = i2c_touchkey_read(KEYCODE_REG, data, 3); /****************************************************************** typedef struct I2CReg { unsigned char BtnStatus; // 0 : unsigned char Version; // 1 :FW Version unsigned char PcbStatus; // 2 :Module Version unsigned char Cmd; // 3 : unsigned char Chip_id; // 4 :0x55(DEFAULT_CHIP_ID) 0 unsigned char Sens; // 5 :sensitivity grade(0x00(slow),0x01(mid),0x02(fast)) WORD DiffData[CSD_TotalSensorCount]; // 6, 7 - 8, 9 WORD RawData[CSD_TotalSensorCount]; // 10,11 - 12,13 WORD Baseline[CSD_TotalSensorCount]; // 14,15 - 16,17 }I2CReg; ******************************************************************/ set_touchkey_debug(data[0]); if ((data[0] & ESD_STATE_BIT) || (ret != 0)) { printk(KERN_DEBUG "[TouchKey] ESD_STATE_BIT set or I2C fail: data: %d, retry: %d\n", data[0], retry); /* release key */ input_report_key(touchkey_driver->input_dev, touchkey_keycode[1], 0); input_report_key(touchkey_driver->input_dev, touchkey_keycode[2], 0); retry = 10; while (retry--) { gpio_direction_output(_3_GPIO_TOUCH_EN, 0); mdelay(300); init_hw(); if (i2c_touchkey_read(KEYCODE_REG, data, 3) >= 0) { printk(KERN_DEBUG "[TouchKey] %s touchkey init success\n", __func__); set_touchkey_debug('O'); enable_irq(IRQ_TOUCH_INT); return; } printk(KERN_ERR "[TouchKey] %s %d i2c transfer error retry = %d\n", __func__, __LINE__, retry); } /* touchkey die , do not enable touchkey enable_irq(IRQ_TOUCH_INT); */ touchkey_enable = -1; gpio_direction_output(_3_GPIO_TOUCH_EN, 0); gpio_direction_output(_3_TOUCH_SDA_28V, 0); gpio_direction_output(_3_TOUCH_SCL_28V, 0); printk(KERN_DEBUG "[TouchKey] %s touchkey died\n", __func__); set_touchkey_debug('D'); return; } if (touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_MENU && touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_BACK) { enable_irq(IRQ_TOUCH_INT); return ; } if (data[0] & UPDOWN_EVENT_BIT) { input_report_key(touchkey_driver->input_dev, touchkey_keycode[data[0] & KEYCODE_BIT], 0); input_sync(touchkey_driver->input_dev); /* printk(KERN_DEBUG "[TouchKey] release keycode:%d \n", touchkey_keycode[data[0] & KEYCODE_BIT]); */ } else { if (touch_is_pressed) { printk(KERN_DEBUG "[TouchKey] touchkey pressed but don't send event because touch is pressed. \n"); set_touchkey_debug('P'); } else { if ((data[0] & KEYCODE_BIT) == 2) { /* if back key is pressed, release multitouch */ /* printk(KERN_DEBUG "[TouchKey] touchkey release tsp input. \n"); */ touch_forced_release(); } input_report_key(touchkey_driver->input_dev, touchkey_keycode[data[0] & KEYCODE_BIT], 1); input_sync(touchkey_driver->input_dev); /* printk(KERN_DEBUG "[TouchKey] press keycode:%d \n", touchkey_keycode[data[0] & KEYCODE_BIT]); */ } } /* we have timed out or the lights should be on */ if (led_timer.expires > jiffies || led_timeout != BL_ALWAYS_OFF) { status = 1; i2c_touchkey_write((u8 *)&status, 1); /* turn on */ } /* restart the timer */ if (led_timeout > 0) { mod_timer(&led_timer, jiffies + msecs_to_jiffies(led_timeout)); } set_touchkey_debug('A'); enable_irq(IRQ_TOUCH_INT); }
static int mipi_dsi_cdp_panel_power(int on) { static struct regulator *reg_l8, *reg_l23, *reg_l2; int rc; pr_debug("%s: state : %d\n", __func__, on); if (!dsi_power_on) { reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdc"); if (IS_ERR(reg_l8)) { pr_err("could not get 8038_l8, rc = %ld\n", PTR_ERR(reg_l8)); return -ENODEV; } reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vddio"); if (IS_ERR(reg_l23)) { pr_err("could not get 8038_l23, rc = %ld\n", PTR_ERR(reg_l23)); return -ENODEV; } reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdda"); if (IS_ERR(reg_l2)) { pr_err("could not get 8038_l2, rc = %ld\n", PTR_ERR(reg_l2)); return -ENODEV; } rc = regulator_set_voltage(reg_l8, 2800000, 3000000); if (rc) { pr_err("set_voltage l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_voltage(reg_l23, 1800000, 1800000); if (rc) { pr_err("set_voltage l23 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_voltage(reg_l2, 1200000, 1200000); if (rc) { pr_err("set_voltage l2 failed, rc=%d\n", rc); return -EINVAL; } rc = gpio_request(DISP_RST_GPIO, "disp_rst_n"); if (rc) { pr_err("request gpio DISP_RST_GPIO failed, rc=%d\n", rc); gpio_free(DISP_RST_GPIO); return -ENODEV; } rc = gpio_request(DISP_3D_2D_MODE, "disp_3d_2d"); if (rc) { pr_err("request gpio DISP_3D_2D_MODE failed, rc=%d\n", rc); gpio_free(DISP_3D_2D_MODE); return -ENODEV; } rc = gpio_direction_output(DISP_3D_2D_MODE, 0); if (rc) { pr_err("gpio_direction_output failed for %d gpio rc=%d\n", DISP_3D_2D_MODE, rc); return -ENODEV; } dsi_power_on = true; } if (on) { rc = regulator_set_optimum_mode(reg_l8, 100000); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l23, 100000); if (rc < 0) { pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l2, 100000); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_enable(reg_l8); if (rc) { pr_err("enable l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_enable(reg_l23); if (rc) { pr_err("enable l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_enable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } usleep(10000); gpio_set_value(DISP_RST_GPIO, 1); usleep(10); gpio_set_value(DISP_RST_GPIO, 0); usleep(20); gpio_set_value(DISP_RST_GPIO, 1); gpio_set_value(DISP_3D_2D_MODE, 1); usleep(20); } else { gpio_set_value(DISP_RST_GPIO, 0); rc = regulator_disable(reg_l2); if (rc) { pr_err("disable reg_l2 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_l8); if (rc) { pr_err("disable reg_l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_l23); if (rc) { pr_err("disable reg_l23 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_l8, 100); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l23, 100); if (rc < 0) { pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l2, 100); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } gpio_set_value(DISP_3D_2D_MODE, 0); usleep(20); } return 0; }
static int __init omap3pandora_soc_init(void) { int ret; if (!machine_is_omap3_pandora()) return -ENODEV; pr_info("OMAP3 Pandora SoC init\n"); ret = gpio_request(OMAP3_PANDORA_DAC_POWER_GPIO, "dac_power"); if (ret) { pr_err(PREFIX "Failed to get DAC power GPIO\n"); return ret; } ret = gpio_direction_output(OMAP3_PANDORA_DAC_POWER_GPIO, 0); if (ret) { pr_err(PREFIX "Failed to set DAC power GPIO direction\n"); goto fail0; } ret = gpio_request(OMAP3_PANDORA_AMP_POWER_GPIO, "amp_power"); if (ret) { pr_err(PREFIX "Failed to get amp power GPIO\n"); goto fail0; } ret = gpio_direction_output(OMAP3_PANDORA_AMP_POWER_GPIO, 0); if (ret) { pr_err(PREFIX "Failed to set amp power GPIO direction\n"); goto fail1; } omap3pandora_snd_device = platform_device_alloc("soc-audio", -1); if (omap3pandora_snd_device == NULL) { pr_err(PREFIX "Platform device allocation failed\n"); ret = -ENOMEM; goto fail1; } platform_set_drvdata(omap3pandora_snd_device, &omap3pandora_snd_data); omap3pandora_snd_data.dev = &omap3pandora_snd_device->dev; *(unsigned int *)omap_mcbsp_dai[0].private_data = 1; /* McBSP2 */ *(unsigned int *)omap_mcbsp_dai[1].private_data = 3; /* McBSP4 */ ret = platform_device_add(omap3pandora_snd_device); if (ret) { pr_err(PREFIX "Unable to add platform device\n"); goto fail2; } return 0; fail2: platform_device_put(omap3pandora_snd_device); fail1: gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO); fail0: gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO); return ret; }
static void __init mahimahi_init(void) { int ret; struct kobject *properties_kobj; printk("mahimahi_init() revision=%d\n", system_rev); if (is_cdma_version(system_rev)) smd_set_channel_list(smd_cdma_default_channels, ARRAY_SIZE(smd_cdma_default_channels)); msm_hw_reset_hook = mahimahi_reset; if (is_cdma_version(system_rev)) msm_acpu_clock_init(&mahimahi_cdma_clock_data); else msm_acpu_clock_init(&mahimahi_clock_data); msm_serial_debug_init(MSM_UART1_PHYS, INT_UART1, &msm_device_uart1.dev, 1, MSM_GPIO_TO_INT(139)); config_gpio_table(misc_gpio_table, ARRAY_SIZE(misc_gpio_table)); if (is_cdma_version(system_rev)) { bcm_bt_lpm_pdata.gpio_wake = MAHIMAHI_CDMA_GPIO_BT_WAKE; mahimahi_flashlight_data.torch = MAHIMAHI_CDMA_GPIO_FLASHLIGHT_TORCH; config_gpio_table(bt_gpio_table_rev_CX, ARRAY_SIZE(bt_gpio_table_rev_CX)); } else { config_gpio_table(bt_gpio_table, ARRAY_SIZE(bt_gpio_table)); } gpio_request(MAHIMAHI_GPIO_TP_LS_EN, "tp_ls_en"); gpio_direction_output(MAHIMAHI_GPIO_TP_LS_EN, 0); gpio_request(MAHIMAHI_GPIO_TP_EN, "tp_en"); gpio_direction_output(MAHIMAHI_GPIO_TP_EN, 0); gpio_request(MAHIMAHI_GPIO_PROXIMITY_EN, "proximity_en"); gpio_direction_output(MAHIMAHI_GPIO_PROXIMITY_EN, 1); gpio_request(MAHIMAHI_GPIO_COMPASS_RST_N, "compass_rst"); gpio_direction_output(MAHIMAHI_GPIO_COMPASS_RST_N, 1); gpio_request(MAHIMAHI_GPIO_COMPASS_INT_N, "compass_int"); gpio_direction_input(MAHIMAHI_GPIO_COMPASS_INT_N); gpio_request(MAHIMAHI_GPIO_DS2482_SLP_N, "ds2482_slp_n"); /* set the gpu power rail to manual mode so clk en/dis will not * turn off gpu power, and hang it on resume */ mahimahi_kgsl_power_rail_mode(0); mahimahi_kgsl_power(true); msm_device_hsusb.dev.platform_data = &msm_hsusb_pdata; msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata; platform_add_devices(devices, ARRAY_SIZE(devices)); i2c_register_board_info(0, base_i2c_devices, ARRAY_SIZE(base_i2c_devices)); if (system_rev == 0) { /* Only board after XB with Audience A1026 */ i2c_register_board_info(0, rev0_i2c_devices, ARRAY_SIZE(rev0_i2c_devices)); } if (system_rev > 0) { /* Only board after XB with Audience A1026 */ i2c_register_board_info(0, rev1_i2c_devices, ARRAY_SIZE(rev1_i2c_devices)); } if (is_cdma_version(system_rev)) { /* Only CDMA version with TI TPA2018D1 Speaker Amp. */ i2c_register_board_info(0, rev_CX_i2c_devices, ARRAY_SIZE(rev_CX_i2c_devices)); if ((system_rev & 0x0F) == 0x00) { a1026_data.gpio_a1026_clk = MAHIMAHI_CDMA_XA_AUD_A1026_CLK; } else if ((system_rev & 0x0F) >= 0x01) { a1026_data.gpio_a1026_wakeup = MAHIMAHI_CDMA_XB_AUD_A1026_WAKEUP; a1026_data.gpio_a1026_reset = MAHIMAHI_CDMA_XB_AUD_A1026_RESET; a1026_data.gpio_a1026_clk = MAHIMAHI_CDMA_XB_AUD_A1026_CLK; } } ret = mahimahi_init_mmc(system_rev, debug_uart); if (ret != 0) pr_crit("%s: Unable to initialize MMC\n", __func__); properties_kobj = kobject_create_and_add("board_properties", NULL); if (properties_kobj) ret = sysfs_create_group(properties_kobj, &mahimahi_properties_attr_group); if (!properties_kobj || ret) pr_err("failed to create board_properties\n"); mahimahi_audio_init(); mahimahi_headset_init(); if (system_rev > 0) platform_device_register(&mahimahi_timed_gpios); else msm_init_pmic_vibrator(); ds2784_battery_init(); }