static void __init gps_gpio_init(void) { #ifdef CONFIG_S5PC110_DEMPSEY_BOARD gpio_request(GPIO_GPS_nRST, "GPS_nRST"); /* XMMC1CLK */ s3c_gpio_setpull(GPIO_GPS_nRST, S3C_GPIO_PULL_UP); #else gpio_request(GPIO_GPS_nRST, "GPS_nRST"); /* XMMC3CLK */ s3c_gpio_setpull(GPIO_GPS_nRST, S3C_GPIO_PULL_NONE); #endif s3c_gpio_cfgpin(GPIO_GPS_nRST, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_nRST, 1); #ifdef CONFIG_S5PC110_DEMPSEY_BOARD gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN"); /* XMMC1CMD */ s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_UP); #else gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN"); /* XMMC3CLK */ s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_NONE); #endif s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN, 0); s3c_gpio_setpull(GPIO_GPS_RXD, S3C_GPIO_PULL_UP); gpio_export(GPIO_GPS_nRST, 1); gpio_export(GPIO_GPS_PWR_EN, 1); BUG_ON(!gps_dev); gpio_export_link(gps_dev, "GPS_nRST", GPIO_GPS_nRST); gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); }
static void __init gps_pins_init(void) { gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); if (!gps_dev) pr_err("Failed to create device(gps)!\n"); nmk_config_pins(kyle_gps_pins, ARRAY_SIZE(kyle_gps_pins)); if (system_rev >= KYLE_ATT_R0_1){ nmk_config_pins(kyle_gps_r0_1_pins, ARRAY_SIZE(kyle_gps_r0_1_pins)); gpio_request(KYLE_GPIO_GBF_RESETN_R0_1, "GPS_nRST"); gpio_direction_output(KYLE_GPIO_GBF_RESETN_R0_1, 1); gpio_export(KYLE_GPIO_GBF_RESETN_R0_1, 1); } else if (system_rev == KYLE_ATT_R0_0){ nmk_config_pins(kyle_gps_r0_0_pins, ARRAY_SIZE(kyle_gps_r0_0_pins)); gpio_request(KYLE_GPIO_GPS_RST_N, "GPS_nRST"); gpio_direction_output(KYLE_GPIO_GPS_RST_N, 1); gpio_export(KYLE_GPIO_GPS_RST_N, 1); } gpio_request(KYLE_GPIO_GPS_ON_OFF, "GPS_ON_OFF"); gpio_direction_output(KYLE_GPIO_GPS_ON_OFF, 0); gpio_export(KYLE_GPIO_GPS_ON_OFF, 1); BUG_ON(!gps_dev); if (system_rev >= KYLE_ATT_R0_1){ gpio_export_link(gps_dev, "GPS_nRST", KYLE_GPIO_GBF_RESETN_R0_1); } else if (system_rev == KYLE_ATT_R0_0){ gpio_export_link(gps_dev, "GPS_nRST", KYLE_GPIO_GPS_RST_N); } gpio_export_link(gps_dev, "GPS_ON_OFF", KYLE_GPIO_GPS_ON_OFF); }
static void __init gps_pins_init(void) { gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); if (!gps_dev) pr_err("Failed to create device(gps)!\n"); BUG_ON(!gps_dev); printk("gps_pins_init!!\n"); nmk_config_pins(codina_gps_uart_pins, ARRAY_SIZE(codina_gps_uart_pins)); gpio_request(GPS_RST_N_CODINA_BRINGUP, "GPS_nRST"); gpio_direction_output(GPS_RST_N_CODINA_BRINGUP, 1); gpio_request(GPS_ON_OFF_CODINA_BRINGUP, "GPS_ON_OFF"); gpio_direction_output(GPS_ON_OFF_CODINA_BRINGUP, 0); gpio_export(GPS_RST_N_CODINA_BRINGUP, 1); gpio_export(GPS_ON_OFF_CODINA_BRINGUP, 1); gpio_export_link(gps_dev, "GPS_nRST", GPS_RST_N_CODINA_BRINGUP); gpio_export_link(gps_dev, "GPS_ON_OFF", GPS_ON_OFF_CODINA_BRINGUP); printk("gps_pins_init done!!\n"); }
static void __init gps_pins_init(void) { gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); if (!gps_dev) pr_err("Failed to create device(gps)!\n"); BUG_ON(!gps_dev); #ifdef CONFIG_DEBUG_PRINTK printk("gps_pins_init!!\n"); #else ; #endif nmk_config_pins(golden_gps_uart_pins, ARRAY_SIZE(golden_gps_uart_pins)); gpio_request(GPS_RST_N_GOLDEN_BRINGUP, "GPS_nRST"); gpio_direction_output(GPS_RST_N_GOLDEN_BRINGUP, 1); gpio_request(GPS_ON_OFF_GOLDEN_BRINGUP, "GPS_ON_OFF"); gpio_direction_output(GPS_ON_OFF_GOLDEN_BRINGUP, 0); gpio_export(GPS_RST_N_GOLDEN_BRINGUP, 1); gpio_export(GPS_ON_OFF_GOLDEN_BRINGUP, 1); gpio_export_link(gps_dev, "GPS_nRST", GPS_RST_N_GOLDEN_BRINGUP); gpio_export_link(gps_dev, "GPS_ON_OFF", GPS_ON_OFF_GOLDEN_BRINGUP); #ifdef CONFIG_DEBUG_PRINTK printk("gps_pins_init done!!\n"); #else ; #endif }
static void __init gps_pins_init(void) { gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); if (!gps_dev) pr_err("Failed to create device(gps)!\n"); if (system_rev < GAVINI_R0_0_B) { nmk_config_pins(gavini_gps_rev0_0_pins, ARRAY_SIZE(gavini_gps_rev0_0_pins)); } else if (system_rev == GAVINI_R0_0_B) { nmk_config_pins(gavini_gps_rev0_0_B_pins, ARRAY_SIZE(gavini_gps_rev0_0_B_pins)); } else if (system_rev >= GAVINI_R0_0_C) { nmk_config_pins(gavini_gps_rev0_0_C_pins, ARRAY_SIZE(gavini_gps_rev0_0_C_pins)); } gpio_request(GPS_RST_N_GAVINI_R0_0, "GPS_nRST"); gpio_direction_output(GPS_RST_N_GAVINI_R0_0, 1); gpio_request(GPS_ON_OFF_GAVINI_R0_0, "GPS_ON_OFF"); gpio_direction_output(GPS_ON_OFF_GAVINI_R0_0, 0); gpio_export(GPS_RST_N_GAVINI_R0_0, 1); gpio_export(GPS_ON_OFF_GAVINI_R0_0, 1); BUG_ON(!gps_dev); gpio_export_link(gps_dev, "GPS_nRST", GPS_RST_N_GAVINI_R0_0); gpio_export_link(gps_dev, "GPS_ON_OFF", GPS_ON_OFF_GAVINI_R0_0); if (system_rev < GAVINI_R0_0_B) { gpio_request(EN_GPS_GAVINI_R0_0, "GPS_PWR_EN"); gpio_direction_output(EN_GPS_GAVINI_R0_0, 1); gpio_export(EN_GPS_GAVINI_R0_0, 1); gpio_export_link(gps_dev, "GPS_PWR_EN", EN_GPS_GAVINI_R0_0); } }
static void tuna_gsd4t_gps_init(void) { struct device *gps_dev; gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); if (IS_ERR(gps_dev)) { pr_err("Failed to create device(gps)!\n"); goto err; } tuna_gsd4t_gps_gpio(); gpio_request(GPIO_AP_AGPS_TSYNC, "AP_AGPS_TSYNC"); gpio_direction_output(GPIO_AP_AGPS_TSYNC, 0); gpio_request(GPIO_GPS_nRST, "GPS_nRST"); gpio_direction_output(GPIO_GPS_nRST, 1); gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN"); gpio_direction_output(GPIO_GPS_PWR_EN, 0); gpio_request(GPIO_GPS_UART_SEL , "GPS_UART_SEL"); gpio_direction_output(GPIO_GPS_UART_SEL , 0); gpio_export(GPIO_GPS_nRST, 1); gpio_export(GPIO_GPS_PWR_EN, 1); gpio_export_link(gps_dev, "GPS_nRST", GPIO_GPS_nRST); gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); tuna_gps_rts_ctrl_init(); err: return; }
static int __init gps_bcm475x_init(void) { int n_rst_pin = 0; //int n_rst_nc_pin = 0; BUG_ON(!sec_class); gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); BUG_ON(!gps_dev); s3c_gpio_cfgpin(GPIO_GPS_RXD, S3C_GPIO_SFN(GPIO_GPS_RXD_AF)); s3c_gpio_setpull(GPIO_GPS_RXD, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(GPIO_GPS_TXD, S3C_GPIO_SFN(GPIO_GPS_TXD_AF)); s3c_gpio_setpull(GPIO_GPS_TXD, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_CTS, S3C_GPIO_SFN(GPIO_GPS_CTS_AF)); s3c_gpio_setpull(GPIO_GPS_CTS, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_RTS, S3C_GPIO_SFN(GPIO_GPS_RTS_AF)); s3c_gpio_setpull(GPIO_GPS_RTS, S3C_GPIO_PULL_NONE); #ifdef CONFIG_MACH_P2 n_rst_pin = system_rev >= 5 ? GPIO_GPS_nRST_28V : GPIO_GPS_nRST; #else n_rst_pin = GPIO_GPS_nRST; #endif if (gpio_request(n_rst_pin, "GPS_nRST")) { WARN(1, "fail to request gpio (GPS_nRST)\n"); device_destroy(sec_class, gps_dev->devt); return 1; } if (device_create_file(gps_dev, &dev_attr_hwrev) < 0) { pr_err("Failed to create device file(%s)!\n", dev_attr_hwrev.attr.name); } s3c_gpio_setpull(n_rst_pin, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(n_rst_pin, S3C_GPIO_OUTPUT); gpio_direction_output(n_rst_pin, 1); if (gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN")) { WARN(1, "fail to request gpio (GPS_PWR_EN)\n"); device_destroy(sec_class, gps_dev->devt); return 1; } s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN, 0); gpio_export(n_rst_pin, 1); gpio_export(GPIO_GPS_PWR_EN, 1); gpio_export_link(gps_dev, "GPS_nRST", n_rst_pin); gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); printk(KERN_DEBUG "%s - system_rev : %x\n", __func__, system_rev); return 0; }
static int __init gps_s5n6420_init(void) { int ret = 0; const char *gps_node = "samsung,lsi_s5n6420"; struct device_node *root_node = NULL; gps_dev = sec_device_create(NULL, "gps"); BUG_ON(!gps_dev); root_node = of_find_compatible_node(NULL, NULL, gps_node); if (!root_node) { WARN(1, "failed to get device node of ske\n"); ret = -ENODEV; goto err_sec_device_create; } gps_pwr_on = of_get_gpio(root_node, 0); if (!gpio_is_valid(gps_pwr_on)) { WARN(1, "----Invalied gpio pin : %d\n", gps_pwr_on); ret = -ENODEV; goto err_sec_device_create; } gps_reset = of_get_gpio(root_node, 1); if (!gpio_is_valid(gps_reset)) { WARN(1, "-----Invalied gpio pin : %d\n", gps_reset); ret = -ENODEV; goto err_sec_device_create; } if (gpio_request(gps_pwr_on, "GPS_PWR_EN")) { WARN(1, "fail to request gpio(GPS_PWR_EN)\n"); ret = -ENODEV; goto err_sec_device_create; } if (gpio_request(gps_reset, "GPS_RESET")) { WARN(1, "fail to request gpio(GPS_RESET)\n"); ret = -ENODEV; goto err_sec_device_create; } gpio_direction_output(gps_pwr_on, 0); gpio_export(gps_pwr_on, 1); gpio_export_link(gps_dev, "GPS_PWR_EN", gps_pwr_on); gpio_direction_output(gps_reset, 1); gpio_export(gps_reset, 1); gpio_export_link(gps_dev, "GPS_RESET", gps_reset); return 0; err_sec_device_create: WARN(1, "err_sec_device_create"); sec_device_destroy(gps_dev->devt); return ret; }
int __init dhd_wlan_init_gpio(void) { const char *wlan_node = "samsung,brcm-wlan"; unsigned int wlan_host_wake_up = -1; struct device_node *root_node = NULL; wlan_dev = sec_device_create(NULL, "wlan"); BUG_ON(!wlan_dev); root_node = of_find_compatible_node(NULL, NULL, wlan_node); if (!root_node) { WARN(1, "failed to get device node of bcm4354\n"); return -ENODEV; } /* ========== WLAN_PWR_EN ============ */ wlan_pwr_on = of_get_gpio(root_node, 0); if (!gpio_is_valid(wlan_pwr_on)) { WARN(1, "Invalied gpio pin : %d\n", wlan_pwr_on); return -ENODEV; } if (gpio_request(wlan_pwr_on, "WLAN_REG_ON")) { WARN(1, "fail to request gpio(WLAN_REG_ON)\n"); return -ENODEV; } #ifdef CONFIG_BCMDHD_PCIE gpio_direction_output(wlan_pwr_on, 1); #else gpio_direction_output(wlan_pwr_on, 0); #endif /* CONFIG_BCMDHD_PCIE */ gpio_export(wlan_pwr_on, 1); gpio_export_link(wlan_dev, "WLAN_REG_ON", wlan_pwr_on); msleep(WIFI_TURNON_DELAY); /* ========== WLAN_HOST_WAKE ============ */ wlan_host_wake_up = of_get_gpio(root_node, 1); if (!gpio_is_valid(wlan_host_wake_up)) { WARN(1, "Invalied gpio pin : %d\n", wlan_host_wake_up); return -ENODEV; } if (gpio_request(wlan_host_wake_up, "WLAN_HOST_WAKE")) { WARN(1, "fail to request gpio(WLAN_HOST_WAKE)\n"); return -ENODEV; } gpio_direction_input(wlan_host_wake_up); gpio_export(wlan_host_wake_up, 1); gpio_export_link(wlan_dev, "WLAN_HOST_WAKE", wlan_host_wake_up); wlan_host_wake_irq = gpio_to_irq(wlan_host_wake_up); return 0; }
static void __init gps_pins_init(void) { gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); if (!gps_dev) pr_err("Failed to create device(gps)!\n"); BUG_ON(!gps_dev); #ifdef CONFIG_DEBUG_PRINTK printk("gps_pins_init!!\n"); #else ; #endif nmk_config_pins(codina_gps_uart_pins, ARRAY_SIZE(codina_gps_uart_pins)); if(system_rev == CODINA_R0_5) { gpio_request(GPS_RST_N_CODINA_BRINGUP_R0_5, "GPS_nRST"); gpio_direction_output(GPS_RST_N_CODINA_BRINGUP_R0_5, 1); gpio_export(GPS_RST_N_CODINA_BRINGUP_R0_5, 1); gpio_export_link(gps_dev, "GPS_nRST", GPS_RST_N_CODINA_BRINGUP_R0_5); } #if defined(CONFIG_MACH_CODINA_EURO) else if(system_rev == CODINA_R0_4) { gpio_request(GPS_RST_N_CODINA_BRINGUP_R0_4, "GPS_nRST"); gpio_direction_output(GPS_RST_N_CODINA_BRINGUP_R0_4, 1); gpio_export(GPS_RST_N_CODINA_BRINGUP_R0_4, 1); gpio_export_link(gps_dev, "GPS_nRST", GPS_RST_N_CODINA_BRINGUP_R0_4); } #endif else { gpio_request(GPS_RST_N_CODINA_BRINGUP, "GPS_nRST"); gpio_direction_output(GPS_RST_N_CODINA_BRINGUP, 1); gpio_export(GPS_RST_N_CODINA_BRINGUP, 1); gpio_export_link(gps_dev, "GPS_nRST", GPS_RST_N_CODINA_BRINGUP); } gpio_request(GPS_ON_OFF_CODINA_BRINGUP, "GPS_ON_OFF"); gpio_direction_output(GPS_ON_OFF_CODINA_BRINGUP, 0); gpio_export(GPS_ON_OFF_CODINA_BRINGUP, 1); gpio_export_link(gps_dev, "GPS_ON_OFF", GPS_ON_OFF_CODINA_BRINGUP); #ifdef CONFIG_DEBUG_PRINTK printk("gps_pins_init done!!\n"); #else ; #endif }
static void __init gps_gpio_init(void) { #if 0 // for B04 board only gpio_request(GPIO_IrDA_SHUTDOWN, "IrDA_SHUTDOWN"); /* XMSMDATA_12 */ s3c_gpio_cfgpin(GPIO_IrDA_SHUTDOWN, S3C_GPIO_OUTPUT); s3c_gpio_setpull(GPIO_IrDA_SHUTDOWN, S3C_GPIO_PULL_NONE); gpio_direction_output(GPIO_IrDA_SHUTDOWN, 1); gpio_export(GPIO_IrDA_SHUTDOWN, 1); #endif if(HWREV >= 12) { gpio_request(GPIO_GPS_nRST_REV06, "GPS_nRST"); /* XMMC3CLK */ s3c_gpio_setpull(GPIO_GPS_nRST_REV06, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_nRST_REV06, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_nRST_REV06, 1); gpio_request(GPIO_GPS_PWR_EN_REV06, "GPS_PWR_EN"); /* XMMC3CLK */ s3c_gpio_setpull(GPIO_GPS_PWR_EN_REV06, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN_REV06, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN_REV06, 0); s3c_gpio_setpull(GPIO_GPS_RXD, S3C_GPIO_PULL_UP); gpio_export(GPIO_GPS_nRST_REV06, 1); gpio_export(GPIO_GPS_PWR_EN_REV06, 1); BUG_ON(!gps_dev); gpio_export_link(gps_dev, "GPS_nRST", GPIO_GPS_nRST_REV06); gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN_REV06); } else{ gpio_request(GPIO_GPS_nRST, "GPS_nRST"); /* XMMC3CLK */ s3c_gpio_setpull(GPIO_GPS_nRST, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_nRST, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_nRST, 1); gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN"); /* XMMC3CLK */ s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN, 0); s3c_gpio_setpull(GPIO_GPS_RXD, S3C_GPIO_PULL_UP); gpio_export(GPIO_GPS_nRST, 1); gpio_export(GPIO_GPS_PWR_EN, 1); BUG_ON(!gps_dev); gpio_export_link(gps_dev, "GPS_nRST", GPIO_GPS_nRST); gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); } }
static int __init gps_bcm4752_init(void) { BUG_ON(!sec_class); gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); BUG_ON(!gps_dev); s3c_gpio_cfgpin(GPIO_GPS_RXD, S3C_GPIO_SFN(GPIO_GPS_RXD_AF)); s3c_gpio_setpull(GPIO_GPS_RXD, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(GPIO_GPS_TXD, S3C_GPIO_SFN(GPIO_GPS_TXD_AF)); s3c_gpio_setpull(GPIO_GPS_TXD, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_CTS, S3C_GPIO_SFN(GPIO_GPS_CTS_AF)); s3c_gpio_setpull(GPIO_GPS_CTS, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_RTS, S3C_GPIO_SFN(GPIO_GPS_RTS_AF)); s3c_gpio_setpull(GPIO_GPS_RTS, S3C_GPIO_PULL_NONE); if (gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN")) { WARN(1, "fail to request gpio (GPS_PWR_EN)\n"); gpio_free(sec_class, gps_dev->devt); return 1; } s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN, 0); gpio_export(GPIO_GPS_PWR_EN, 1); gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); return 0; }
static int __init gps_bcm4753_init(void) { const char *gps_node = "samsung,exynos54xx-bcm4753"; struct device_node *root_node = NULL; gps_dev = sec_device_create(NULL, "gps"); BUG_ON(!gps_dev); root_node = of_find_compatible_node(NULL, NULL, gps_node); if (!root_node) { WARN(1, "failed to get device node of bcm4753\n"); return -ENODEV; } gps_pwr_on = of_get_gpio(root_node, 0); if (!gpio_is_valid(gps_pwr_on)) { WARN(1, "Invalied gpio pin : %d\n", gps_pwr_on); return -ENODEV; } if (gpio_request(gps_pwr_on, "GPS_PWR_EN")) { WARN(1, "fail to request gpio(GPS_PWR_EN)\n"); return -ENODEV; } gpio_direction_output(gps_pwr_on, 0); gpio_export(gps_pwr_on, 1); gpio_export_link(gps_dev, "GPS_PWR_EN", gps_pwr_on); return 0; }
int board_gpio_export(struct device *dev, unsigned gpio, bool dir, const char *name) { int ret = 0; if (!gpio_is_valid(gpio)) { mif_err("invalid gpio pins - %s\n", name); return -EINVAL; } ret = gpio_export(gpio, dir); if (ret) { mif_err("%s: failed to export gpio (%d)\n", name, ret); return ret; } ret = gpio_export_link(dev, name, gpio); if (ret) { mif_err("%s: failed to export link_gpio (%d)\n", name, ret); return ret; } mif_info("%s exported\n", name); return 0; }
static void __init gps_gpio_init(void) { gpio_request(GPIO_GPS_nRST, "GPS_nRST"); /* XMMC3CLK */ s3c_gpio_setpull(GPIO_GPS_nRST, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_nRST, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_nRST, 1); gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN"); /* XMMC3CLK */ s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN, 0); s3c_gpio_setpull(GPIO_GPS_RXD, S3C_GPIO_PULL_UP); gpio_export(GPIO_GPS_nRST, 1); gpio_export(GPIO_GPS_PWR_EN, 1); // BUG_ON(!gps_dev); gpio_export_link(gps_dev, "GPS_nRST", GPIO_GPS_nRST); gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); }
static int rmi4_char_dev_register(struct rmi4_function_device *fdev) { int err; struct device *device_ptr; struct rmi4_char_dev_drv_data *ddata = kzalloc(sizeof(*ddata), GFP_KERNEL); if (!ddata) { dev_err(&fdev->dev, "Failed to allocate driver data.\n"); return -ENOMEM; } mutex_init(&ddata->fop_lock); ddata->fdev = fdev; dev_set_drvdata(&fdev->dev, ddata); ddata->fdata = dev_get_platdata(&fdev->dev); device_ptr = rmi4_bus_create_char_dev(RMI4_CHAR_DEVICE_NAME, &rmi4_char_dev_fops, &ddata->cdev, &fdev->dev, ddata); if (IS_ERR(device_ptr)) { dev_err(&fdev->dev, "%s - Failed to create char dev\n", __func__); err = PTR_ERR(device_ptr); goto error; } err = gpio_export(ddata->fdata->gpio, false); if (err) { dev_warn(&fdev->dev, "WARNING: Failed to export ATTN gpio!\n"); goto error; } err = gpio_export_link(&fdev->dev, "attn", ddata->fdata->gpio); if (err) dev_warn(&fdev->dev, "WARNING: Failed to symlink ATTN gpio!\n"); else dev_info(&fdev->dev, "%s: Exported GPIO %d.", __func__, ddata->fdata->gpio); return 0; error: dev_set_drvdata(&fdev->dev, NULL); mutex_destroy(&ddata->fop_lock); kfree(ddata); return err; }
static void __init gps_pins_init(void) { gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); if (!gps_dev) pr_err("Failed to create device(gps)!\n"); nmk_config_pins(gti9060_gps_rev0_1_pins, ARRAY_SIZE(gti9060_gps_rev0_1_pins)); gpio_request(GPS_RST_N_GTI9060_R0_1, "GPS_nRST"); gpio_direction_output(GPS_RST_N_GTI9060_R0_1,0); gpio_request(EN_GPS_GTI060_R0_1, "GPS_PWR_EN"); gpio_direction_output(EN_GPS_GTI060_R0_1,1); gpio_request(GPS_ON_OFF_GTI9060_R0_1, "GPS_ON_OFF"); gpio_direction_output(GPS_ON_OFF_GTI9060_R0_1,0); gpio_export(GPS_RST_N_GTI9060_R0_1, 1); gpio_export(EN_GPS_GTI060_R0_1, 1); gpio_export(GPS_ON_OFF_GTI9060_R0_1, 1); BUG_ON(!gps_dev); gpio_export_link(gps_dev, "GPS_nRST", GPS_RST_N_GTI9060_R0_1); gpio_export_link(gps_dev, "GPS_PWR_EN", EN_GPS_GTI060_R0_1); gpio_export_link(gps_dev, "GPS_ON_OFF", GPS_ON_OFF_GTI9060_R0_1); }
static int mmi_factory_probe(struct platform_device *pdev) { struct mmi_factory_info *info; int ret; int i; if (!mmi_factory_cable_present()) { dev_dbg(&pdev->dev, "factory cable not present\n"); return -ENODEV; } info = mmi_parse_of(pdev); if (!info) { dev_err(&pdev->dev, "failed to parse node\n"); return -ENODEV; } ret = gpio_request_array(info->list, info->num_gpios); if (ret) { dev_err(&pdev->dev, "failed to request GPIOs\n"); return ret; } for (i = 0; i < info->num_gpios; i++) { ret = gpio_export(info->list[i].gpio, 1); if (ret) { dev_err(&pdev->dev, "Failed to export GPIO %s: %d\n", info->list[i].label, info->list[i].gpio); goto fail; } ret = gpio_export_link(&pdev->dev, info->list[i].label, info->list[i].gpio); if (ret) { dev_err(&pdev->dev, "Failed to link GPIO %s: %d\n", info->list[i].label, info->list[i].gpio); goto fail; } } platform_set_drvdata(pdev, info); return 0; fail: gpio_free_array(info->list, info->num_gpios); return ret; }
static int __init usb_switch_init(void) { int ret; gpio_request(GPIO_USB_SEL1, "GPIO_USB_SEL1"); gpio_request(GPIO_USB_SEL2, "GPIO_USB_SEL2"); gpio_request(GPIO_USB_SEL3, "GPIO_USB_SEL3"); #ifdef CONFIG_MACH_P8LTE gpio_request(GPIO_UART_SEL1, "GPIO_UART_SEL1"); gpio_request(GPIO_UART_SEL2, "GPIO_UART_SEL2"); #else gpio_request(GPIO_UART_SEL, "GPIO_UART_SEL"); #endif gpio_export(GPIO_USB_SEL1, 1); gpio_export(GPIO_USB_SEL2, 1); gpio_export(GPIO_USB_SEL3, 1); #ifdef CONFIG_MACH_P8LTE gpio_export(GPIO_UART_SEL1, 1); gpio_export(GPIO_UART_SEL2, 1); #else gpio_export(GPIO_UART_SEL, 1); #endif BUG_ON(!sec_class); sec_switch_dev = device_create(sec_class, NULL, 0, NULL, "sec_switch"); BUG_ON(!sec_switch_dev); gpio_export_link(sec_switch_dev, "GPIO_USB_SEL1", GPIO_USB_SEL1); gpio_export_link(sec_switch_dev, "GPIO_USB_SEL2", GPIO_USB_SEL2); gpio_export_link(sec_switch_dev, "GPIO_USB_SEL3", GPIO_USB_SEL3); #ifdef CONFIG_MACH_P8LTE gpio_export_link(sec_switch_dev, "GPIO_UART_SEL1", GPIO_UART_SEL1); gpio_export_link(sec_switch_dev, "GPIO_UART_SEL2", GPIO_UART_SEL2); #else gpio_export_link(sec_switch_dev, "GPIO_UART_SEL", GPIO_UART_SEL); #endif /*init_MUTEX(&usb_switch_sem);*/ sema_init(&usb_switch_sem, 1); if (!gpio_get_value(GPIO_USB_SEL1)) usb_switch_set_path(USB_PATH_CP); ret = device_create_file(sec_switch_dev, &dev_attr_usb_sel); BUG_ON(ret); ret = device_create_file(sec_switch_dev, &dev_attr_uart_sel); BUG_ON(ret); return 0; }
int u1_gps_ntt_init(void) { //int isntt = 1; //if(isntt!=1) return 0; s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_SLP_INPUT); s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_DOWN); gpio_unexport(GPIO_GPS_PWR_EN); gpio_free(GPIO_GPS_PWR_EN); if (gpio_request(GPIO_GPS_PWR_EN_NTT, "GPS_PWR_EN")) WARN(1, "fail to request gpio (GPS_PWR_EN)\n"); s3c_gpio_setpull(GPIO_GPS_PWR_EN_NTT, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN_NTT, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN_NTT, 0); gpio_export(GPIO_GPS_PWR_EN_NTT, 1); sysfs_remove_link(&gps_dev->kobj,"GPS_PWR_EN"); gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN_NTT); return 0; }
static int uart_switch_init(void) { int ret, val; ret = gpio_request(GPIO_UART_SEL, "UART_SEL"); if (ret < 0) { pr_err("Failed to request GPIO_UART_SEL!\n"); return -ENODEV; } s3c_gpio_setpull(GPIO_UART_SEL, S3C_GPIO_PULL_NONE); val = gpio_get_value(GPIO_UART_SEL); pr_info("##MUIC [ %s ]- func : %s !! val:-%d-\n", __FILE__, __func__, val); gpio_direction_output(GPIO_UART_SEL, val); gpio_export(GPIO_UART_SEL, 1); gpio_export_link(switch_dev, "uart_sel", GPIO_UART_SEL); return 0; }
static int c55_ctrl_gpio_setup(struct c55_ctrl_data *cdata, struct device *dev) { int i; if (of_gpio_count(dev->of_node) != NUM_GPIOS) { dev_err(dev, "%s: gpio count is not %d.\n", __func__, NUM_GPIOS); return -EINVAL; } for (i = 0; i < NUM_GPIOS; i++) { enum of_gpio_flags flags; int gpio; gpio = of_get_gpio_flags(dev->of_node, i, &flags); if (gpio < 0) { pr_err("%s: of_get_gpio failed: %d\n", __func__, gpio); return gpio; } gpio_request(gpio, gpio_labels[i]); gpio_export(gpio, false); gpio_export_link(dev, gpio_labels[i], gpio); if ((flags & GPIOF_IN) == GPIOF_IN) { gpio_direction_input(gpio); c55_ctrl_int_setup(cdata, gpio); } else { cdata->ap_c55_int_gpio = gpio; if ((flags & GPIOF_OUT_INIT_HIGH) == GPIOF_OUT_INIT_HIGH) gpio_direction_output(gpio, 1); else gpio_direction_output(gpio, 0); } } return 0; }
static int __init gps_bcm4752_init(void) { BUG_ON(!sec_class); gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); BUG_ON(!gps_dev); s3c_gpio_cfgpin(GPIO_GPS_RXD, S3C_GPIO_SFN(GPIO_GPS_RXD_AF)); s3c_gpio_setpull(GPIO_GPS_RXD, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(GPIO_GPS_TXD, S3C_GPIO_SFN(GPIO_GPS_TXD_AF)); s3c_gpio_setpull(GPIO_GPS_TXD, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_CTS, S3C_GPIO_SFN(GPIO_GPS_CTS_AF)); s3c_gpio_setpull(GPIO_GPS_CTS, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_RTS, S3C_GPIO_SFN(GPIO_GPS_RTS_AF)); s3c_gpio_setpull(GPIO_GPS_RTS, S3C_GPIO_PULL_NONE); if (device_create_file(gps_dev, &dev_attr_hwrev) < 0) { pr_err("Failed to create device file(%s)!\n", dev_attr_hwrev.attr.name); } if (gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN")) { WARN(1, "fail to request gpio (GPS_PWR_EN)\n"); // gpio_free(sec_class, gps_dev->devt); return 1; } s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN, 0); gpio_export(GPIO_GPS_PWR_EN, 1); gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); printk(KERN_DEBUG "%s - system_rev : %x\n", __func__, system_rev); return 0; }
static int __devinit chromeos_arm_probe(struct platform_device *pdev) { int gpio, err, active_low; enum of_gpio_flags flags; struct device_node *np = pdev->dev.of_node; if (!np) { err = -ENODEV; goto err; } gpio = of_get_named_gpio_flags(np, "write-protect-gpio", 0, &flags); if (!gpio_is_valid(gpio)) { dev_err(&pdev->dev, "invalid write-protect gpio descriptor\n"); err = -EINVAL; goto err; } active_low = !!(flags & OF_GPIO_ACTIVE_LOW); err = gpio_request_one(gpio, GPIOF_DIR_IN, "firmware-write-protect"); if (err) goto err; err = gpio_sysfs_set_active_low(gpio, active_low); if (err) goto err; gpio_export(gpio, 0); gpio_export_link(&pdev->dev, "write-protect", gpio); dev_info(&pdev->dev, "chromeos system detected\n"); err = 0; err: of_node_put(np); return err; }
static int __init gps_gsd4t_init(void) { BUG_ON(!sec_class); gps_dev = device_create(sec_class, NULL, 0, NULL, "gps"); BUG_ON(!gps_dev); s3c_gpio_cfgpin(GPIO_GPS_RXD, S3C_GPIO_SFN(GPIO_GPS_RXD_AF)); s3c_gpio_setpull(GPIO_GPS_RXD, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(GPIO_GPS_TXD, S3C_GPIO_SFN(GPIO_GPS_TXD_AF)); s3c_gpio_setpull(GPIO_GPS_TXD, S3C_GPIO_PULL_NONE); if (gpio_request(GPIO_GPS_nRST, "GPS_nRST")) WARN(1, "fail to request gpio (GPS_nRST)\n"); s3c_gpio_setpull(GPIO_GPS_nRST, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(GPIO_GPS_nRST, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_nRST, 1); #ifdef CONFIG_TARGET_LOCALE_NTT if (system_rev >= 11) { if (gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN")) WARN(1, "fail to request gpio (GPS_PWR_EN)\n"); s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN, 0); gpio_export(GPIO_GPS_nRST, 1); gpio_export(GPIO_GPS_PWR_EN, 1); } else { if (gpio_request(GPIO_GPS_PWR_EN_SPI, "GPS_PWR_EN")) WARN(1, "fail to request gpio (GPS_PWR_EN)\n"); s3c_gpio_setpull(GPIO_GPS_PWR_EN_SPI, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN_SPI, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN_SPI, 0); gpio_export(GPIO_GPS_nRST, 1); gpio_export(GPIO_GPS_PWR_EN_SPI, 1); } #else if (gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN")) WARN(1, "fail to request gpio (GPS_PWR_EN)\n"); s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN, 0); gpio_export(GPIO_GPS_nRST, 1); gpio_export(GPIO_GPS_PWR_EN, 1); #endif #ifdef CONFIG_TARGET_LOCALE_KOR if (system_rev >= 7) { if (gpio_request(GPIO_GPS_RTS, "GPS_RTS")) WARN(1, "fail to request gpio (GPS_RTS)\n"); s3c_gpio_setpull(GPIO_GPS_RTS, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(GPIO_GPS_RTS, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_RTS, 1); if (gpio_request(GPIO_GPS_CTS, "GPS_CTS")) WARN(1, "fail to request gpio (GPS_RTS)\n"); s3c_gpio_setpull(GPIO_GPS_CTS, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(GPIO_GPS_CTS, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_CTS, 1); } #endif gpio_export_link(gps_dev, "GPS_nRST", GPIO_GPS_nRST); #ifdef CONFIG_TARGET_LOCALE_NTT if (system_rev >= 11) gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); else gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN_SPI); #else gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); #endif return 0; }
static int mmi_factory_probe(struct platform_device *pdev) { const struct of_device_id *match; struct mmi_factory_info *info; int ret; int i; match = of_match_device(mmi_factory_of_tbl, &pdev->dev); if (!match) { dev_err(&pdev->dev, "No Match found\n"); return -ENODEV; } if (match && match->compatible) dev_info(&pdev->dev, "Using %s\n", match->compatible); info = mmi_parse_of(pdev); if (!info) { dev_err(&pdev->dev, "failed to parse node\n"); return -ENODEV; } ret = gpio_request_array(info->list, info->num_gpios); if (ret) { dev_err(&pdev->dev, "failed to request GPIOs\n"); return ret; } for (i = 0; i < info->num_gpios; i++) { ret = gpio_export(info->list[i].gpio, 1); if (ret) { dev_err(&pdev->dev, "Failed to export GPIO %s: %d\n", info->list[i].label, info->list[i].gpio); goto fail; } ret = gpio_export_link(&pdev->dev, info->list[i].label, info->list[i].gpio); if (ret) { dev_err(&pdev->dev, "Failed to link GPIO %s: %d\n", info->list[i].label, info->list[i].gpio); goto fail; } } if (!mmi_factory_cable_present()) { dev_dbg(&pdev->dev, "factory cable not present\n"); } else { pr_info("Factory Cable Attached at Power up!\n"); info->factory_cable = 1; } if (match && match->data) { info->dev = *(enum mmi_factory_device_list *)(match->data); } else { dev_err(&pdev->dev, "failed to find device match\n"); goto fail; } if ((info->dev == KUNGPOW) && (info->num_gpios == KP_NUM_GPIOS)) { /* Disable Kill if not powered up by a factory cable */ if (!info->factory_cable) gpio_direction_output(info->list[KP_KILL_INDEX].gpio, 1); else { ret = device_create_file(&pdev->dev, &dev_attr_usr_rst_sw_dis); if (ret) dev_err(&pdev->dev, "couldn't create usr_rst_sw_dis\n"); usr_rst_sw_dis_flg = 0; ret = device_create_file(&pdev->dev, &dev_attr_fac_kill_sw_dis); if (ret) dev_err(&pdev->dev, "couldn't create fac_kill_sw_dis\n"); fac_kill_sw_dis_flg = 0; } info->warn_irq = gpio_to_irq(info->list[KP_WARN_INDEX].gpio); info->fac_cbl_irq = gpio_to_irq(info->list[KP_CABLE_INDEX].gpio); INIT_DELAYED_WORK(&info->warn_irq_work, warn_irq_w); INIT_DELAYED_WORK(&info->fac_cbl_irq_work, fac_cbl_irq_w); if (info->warn_irq) { ret = request_irq(info->warn_irq, warn_irq_handler, IRQF_TRIGGER_FALLING, "mmi_factory_warn", info); if (ret) { dev_err(&pdev->dev, "request irq failed for Warn\n"); goto fail; } } else { ret = -ENODEV; dev_err(&pdev->dev, "IRQ for Warn doesn't exist\n"); goto fail; } if (info->fac_cbl_irq) { ret = request_irq(info->fac_cbl_irq, fac_cbl_irq_handler, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "mmi_factory_fac_cbl", info); if (ret) { dev_err(&pdev->dev, "irq failed for Factory Cable\n"); goto remove_warn; } } else { ret = -ENODEV; dev_err(&pdev->dev, "IRQ for Factory Cable doesn't exist\n"); goto remove_warn; } } platform_set_drvdata(pdev, info); return 0; remove_warn: free_irq(info->warn_irq, info); fail: gpio_free_array(info->list, info->num_gpios); return ret; }
static int __devinit rmi_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct rmi_phys_device *rmi_phys; struct rmi_i2c_data *data; struct rmi_device_platform_data *pdata = client->dev.platform_data; int error; if (!pdata) { dev_err(&client->dev, "no platform data\n"); return -EINVAL; } if (!hsad_get_rmi_enable()) { dev_err(&client->dev, "rmi not exits\n"); return -EINVAL; } dev_info(&client->dev, "Probing %s at %#02x (IRQ %d).\n", pdata->sensor_name ? pdata->sensor_name : "-no name-", client->addr, pdata->attn_gpio); error = set_touch_chip_info(TOUCH_INFO_RMI3250); if (error) { dev_err(&client->dev, "set_touch_chip_info error\n"); } dev_info(&client->dev, "Configuring GPIOs.\n"); error = synaptics_touchpad_gpio_setup(pdata->gpio_data); if (error < 0) { dev_err(&client->dev, "Failed to configure GPIOs, code: %d.\n", error); return error; } dev_info(&client->dev, "Done with GPIO configuration.\n"); error = i2c_check_functionality(client->adapter, I2C_FUNC_I2C); if (!error) { dev_err(&client->dev, "i2c_check_functionality error %d.\n", error); return error; } rmi_phys = kzalloc(sizeof(struct rmi_phys_device), GFP_KERNEL); if (!rmi_phys) return -ENOMEM; data = kzalloc(sizeof(struct rmi_i2c_data), GFP_KERNEL); if (!data) { error = -ENOMEM; goto err_phys; } data->enabled = true; /* We plan to come up enabled. */ data->irq = gpio_to_irq(pdata->attn_gpio); if (pdata->level_triggered) { data->irq_flags = IRQF_ONESHOT | ((pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH) ? IRQF_TRIGGER_HIGH : IRQF_TRIGGER_LOW); } else { data->irq_flags = (pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH) ? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING; } data->phys = rmi_phys; rmi_phys->data = data; rmi_phys->dev = &client->dev; rmi_phys->write = rmi_i2c_write; rmi_phys->write_block = rmi_i2c_write_block; rmi_phys->read = rmi_i2c_read; rmi_phys->read_block = rmi_i2c_read_block; rmi_phys->enable_device = enable_device; rmi_phys->disable_device = disable_device; rmi_phys->info.proto = phys_proto_name; mutex_init(&data->page_mutex); /* Setting the page to zero will (a) make sure the PSR is in a * known state, and (b) make sure we can talk to the device. */ msleep(100); error = rmi_set_page(rmi_phys, 0); if (error) { dev_err(&client->dev, "Failed to set page select to 0.\n"); goto err_data; } error = rmi_register_phys_device(rmi_phys); if (error) { dev_err(&client->dev, "failed to register physical driver at 0x%.2X.\n", client->addr); goto err_gpio; } i2c_set_clientdata(client, rmi_phys); rmi_phys->rmi_task = kthread_create(rmi_irq_thread, data, "rmi_irq_thread"); if (IS_ERR(rmi_phys->rmi_task)){ dev_err(&client->dev, "create thread failed!\n"); goto err_unregister; } if (pdata->attn_gpio > 0) { error = acquire_attn_irq(data); if (error < 0) { dev_err(&client->dev, "request_threaded_irq failed %d\n", pdata->attn_gpio); goto err_unregister; } } #if defined(CONFIG_RMI4_DEV) error = gpio_export(pdata->attn_gpio, false); if (error) { dev_warn(&client->dev, "WARNING: Failed to export ATTN gpio!\n"); error = 0; } else { error = gpio_export_link(&(rmi_phys->rmi_dev->dev), "attn", pdata->attn_gpio); if (error) { dev_warn(&(rmi_phys->rmi_dev->dev), "WARNING: Failed to symlink ATTN gpio!\n"); error = 0; } else { dev_info(&(rmi_phys->rmi_dev->dev), "%s: Exported ATTN GPIO %d.", __func__, pdata->attn_gpio); } } #endif /* CONFIG_RMI4_DEV */ dev_info(&client->dev, "registered rmi i2c driver at %#04x.\n", client->addr); return 0; err_unregister: rmi_unregister_phys_device(rmi_phys); err_gpio: synaptics_touchpad_gpio_free(pdata->gpio_data); err_data: kfree(data); err_phys: kfree(rmi_phys); return error; }
static int rmidev_init_device(struct synaptics_rmi4_data *rmi4_data) { int retval; dev_t dev_no; struct device *device_ptr; struct rmidev_handle *rmidev = NULL; rmidev = kzalloc(sizeof(struct rmidev_handle), GFP_KERNEL); if (!rmidev) { dev_err(&rmi4_data->i2c_client->dev, "%s: Failed to alloc mem for rmidev\n", __func__); retval = -ENOMEM; goto err_rmidev; } rmi4_data->rmidev = rmidev; rmidev->rmi4_data = rmi4_data; retval = rmidev_create_device_class(rmi4_data); if (retval < 0) { dev_err(&rmi4_data->i2c_client->dev, "%s: Failed to create device class\n", __func__); goto err_device_class; } if (rmidev_major_num) { dev_no = MKDEV(rmidev_major_num, DEV_NUMBER); retval = register_chrdev_region(dev_no, 1, CHAR_DEVICE_NAME); } else { retval = alloc_chrdev_region(&dev_no, 0, 1, CHAR_DEVICE_NAME); if (retval < 0) { dev_err(&rmi4_data->i2c_client->dev, "%s: Failed to allocate char device region\n", __func__); goto err_device_region; } rmidev_major_num = MAJOR(dev_no); dev_dbg(&rmi4_data->i2c_client->dev, "%s: Major number of rmidev = %d\n", __func__, rmidev_major_num); } mutex_init(&rmidev->dev_data.file_mutex); cdev_init(&rmidev->dev_data.main_dev, &rmidev_fops); retval = cdev_add(&rmidev->dev_data.main_dev, dev_no, 1); if (retval < 0) { dev_err(&rmi4_data->i2c_client->dev, "%s: Failed to add rmi char device\n", __func__); goto err_char_device; } dev_set_name(&rmidev->dev, "rmidev%d", MINOR(dev_no)); rmidev->dev_data.device_class = rmidev_device_class; device_ptr = device_create(rmidev->dev_data.device_class, NULL, dev_no, NULL, CHAR_DEVICE_NAME"%d", MINOR(dev_no)); if (IS_ERR(device_ptr)) { dev_err(&rmi4_data->i2c_client->dev, "%s: Failed to create rmi char device\n", __func__); retval = -ENODEV; goto err_char_device; } retval = gpio_export(rmi4_data->board->gpio, false); if (retval < 0) { dev_err(&rmi4_data->i2c_client->dev, "%s: Failed to export attention gpio\n", __func__); } else { retval = gpio_export_link(&(rmi4_data->input_dev->dev), "attn", rmi4_data->board->gpio); if (retval < 0) { dev_err(&rmi4_data->input_dev->dev, "%s Failed to create gpio symlink\n", __func__); } else { dev_dbg(&rmi4_data->input_dev->dev, "%s: Exported attention gpio %d\n", __func__, rmi4_data->board->gpio); } } rmidev->attr_dir = kobject_create_and_add(ATTRIBUTE_FOLDER_NAME, &rmi4_data->input_dev->dev.kobj); if (!rmidev->attr_dir) { dev_err(&rmi4_data->i2c_client->dev, "%s: Failed to create sysfs directory\n", __func__); retval = -ENODEV; goto err_attr_dir; } retval = sysfs_create_bin_file(rmidev->attr_dir, &attr_data); if (retval < 0) { dev_err(&rmi4_data->i2c_client->dev, "%s: Failed to create sysfs bin file\n", __func__); goto err_sysfs_bin; } retval = sysfs_create_group(rmidev->attr_dir, &attr_group); if (retval < 0) { dev_err(&rmi4_data->input_dev->dev, "%s: Failed to create sysfs attributes\n", __func__); retval = -ENODEV; goto err_sysfs_attrs; } return 0; err_sysfs_attrs: sysfs_remove_group(rmidev->attr_dir, &attr_group); sysfs_remove_bin_file(rmidev->attr_dir, &attr_data); err_sysfs_bin: kobject_put(rmidev->attr_dir); err_attr_dir: err_char_device: rmidev_device_cleanup(&rmidev->dev_data); mutex_destroy(&rmidev->dev_data.file_mutex); unregister_chrdev_region(dev_no, 1); err_device_region: class_destroy(rmidev_device_class); err_device_class: kfree(rmidev); rmi4_data->rmidev = NULL; err_rmidev: return retval; }
static int __devinit rmi_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct rmi_phys_device *rmi_phys; struct rmi_i2c_data *data; struct rmi_device_platform_data *pdata = client->dev.platform_data; int error; if (!pdata) { dev_err(&client->dev, "no platform data\n"); return -EINVAL; } pr_info("%s: Probing %s at %#02x (IRQ %d).\n", __func__, pdata->sensor_name ? pdata->sensor_name : "-no name-", client->addr, pdata->attn_gpio); error = i2c_check_functionality(client->adapter, I2C_FUNC_I2C); if (!error) { dev_err(&client->dev, "i2c_check_functionality error %d.\n", error); return error; } rmi_phys = kzalloc(sizeof(struct rmi_phys_device), GFP_KERNEL); if (!rmi_phys) return -ENOMEM; data = kzalloc(sizeof(struct rmi_i2c_data), GFP_KERNEL); if (!data) { error = -ENOMEM; goto err_phys; } data->enabled = true; /* We plan to come up enabled. */ data->irq = gpio_to_irq(pdata->attn_gpio); data->irq_flags = (pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH) ? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING; data->phys = rmi_phys; rmi_phys->data = data; rmi_phys->dev = &client->dev; rmi_phys->write = rmi_i2c_write; rmi_phys->write_block = rmi_i2c_write_block; rmi_phys->read = rmi_i2c_read; rmi_phys->read_block = rmi_i2c_read_block; rmi_phys->enable_device = enable_device; rmi_phys->disable_device = disable_device; rmi_phys->info.proto = phys_proto_name; mutex_init(&data->page_mutex); mdelay(1000); /* Setting the page to zero will (a) make sure the PSR is in a * known state, and (b) make sure we can talk to the device. */ error = rmi_set_page(rmi_phys, 0); if (error) { dev_err(&client->dev, "Failed to set page select to 0.\n"); goto err_data; } if (pdata->gpio_config) { error = pdata->gpio_config(pdata->gpio_data, true); if (error < 0) { dev_err(&client->dev, "failed to setup irq %d\n", pdata->attn_gpio); goto err_data; } } error = rmi_register_phys_device(rmi_phys); if (error) { dev_err(&client->dev, "failed to register physical driver at 0x%.2X.\n", client->addr); goto err_data; } i2c_set_clientdata(client, rmi_phys); if (pdata->attn_gpio > 0) { error = acquire_attn_irq(data); if (error < 0) { dev_err(&client->dev, "request_threaded_irq failed %d\n", pdata->attn_gpio); goto err_unregister; } } #if defined(CONFIG_RMI4_DEV) error = gpio_export(pdata->attn_gpio, false); if (error) { dev_warn(&client->dev, "%s: WARNING: Failed to " "export ATTN gpio!\n", __func__); error = 0; } else { error = gpio_export_link(&(rmi_phys->rmi_dev->dev), "attn", pdata->attn_gpio); if (error) { dev_warn(&(rmi_phys->rmi_dev->dev), "%s: WARNING: " "Failed to symlink ATTN gpio!\n", __func__); error = 0; } else { dev_info(&(rmi_phys->rmi_dev->dev), "%s: Exported GPIO %d.", __func__, pdata->attn_gpio); } } #endif /* CONFIG_RMI4_DEV */ dev_info(&client->dev, "registered rmi i2c driver at 0x%.2X.\n", client->addr); return 0; err_unregister: rmi_unregister_phys_device(rmi_phys); err_data: kfree(data); err_phys: kfree(rmi_phys); return error; }
static void __init gps_gpio_init(void) { if (gpio_request(GPIO_GPS_nRST, "GPS_nRST")) WARN(1, "fail to request gpio (GPS_nRST)\n"); s3c_gpio_setpull(GPIO_GPS_nRST, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(GPIO_GPS_nRST, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_nRST, 1); #ifdef CONFIG_TARGET_LOCALE_NTT if (system_rev >= 11) { if (gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN")) WARN(1, "fail to request gpio (GPS_PWR_EN)\n"); s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN, 0); gpio_export(GPIO_GPS_nRST, 1); gpio_export(GPIO_GPS_PWR_EN, 1); } else { if (gpio_request(GPIO_GPS_PWR_EN_SPI, "GPS_PWR_EN")) WARN(1, "fail to request gpio (GPS_PWR_EN)\n"); s3c_gpio_setpull(GPIO_GPS_PWR_EN_SPI, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN_SPI, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN_SPI, 0); gpio_export(GPIO_GPS_nRST, 1); gpio_export(GPIO_GPS_PWR_EN_SPI, 1); } #else if (gpio_request(GPIO_GPS_PWR_EN, "GPS_PWR_EN")) WARN(1, "fail to request gpio (GPS_PWR_EN)\n"); s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_NONE); s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_PWR_EN, 0); gpio_export(GPIO_GPS_nRST, 1); gpio_export(GPIO_GPS_PWR_EN, 1); #endif #ifdef CONFIG_TARGET_LOCALE_KOR if (system_rev >= 7) { if (gpio_request(GPIO_GPS_RTS, "GPS_RTS")) WARN(1, "fail to request gpio (GPS_RTS)\n"); s3c_gpio_setpull(GPIO_GPS_RTS, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(GPIO_GPS_RTS, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_RTS, 1); if (gpio_request(GPIO_GPS_CTS, "GPS_CTS")) WARN(1, "fail to request gpio (GPS_RTS)\n"); s3c_gpio_setpull(GPIO_GPS_CTS, S3C_GPIO_PULL_UP); s3c_gpio_cfgpin(GPIO_GPS_CTS, S3C_GPIO_OUTPUT); gpio_direction_output(GPIO_GPS_CTS, 1); } #endif BUG_ON(!gps_dev); gpio_export_link(gps_dev, "GPS_nRST", GPIO_GPS_nRST); #ifdef CONFIG_TARGET_LOCALE_NTT if (system_rev >= 11) gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); else gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN_SPI); #else gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN); #endif gps_uart_cfg_gpio(ARRAY_SIZE(gps_uart_on_table), gps_uart_on_table); }