static int mz_factory_test_parse_dt(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; pr_info("%s(), ++++++++++++\n", __func__); if (!np) { pr_info("%s(), Err!device_node is NULL\n", __func__); return -EINVAL; } gpio_factory_mode = of_get_gpio(np, 0); pr_info("gpio_factory_mode:%d\n", gpio_factory_mode); gpio_volup_irq = of_get_gpio(np, 1); pr_info("gpio_volup_irq:%d\n", gpio_volup_irq); gpio_voldown_irq = of_get_gpio(np, 2); pr_info("gpio_voldown_irq:%d\n", gpio_voldown_irq); #ifdef MX_FACTORY_HAS_LED gpio_test_led = of_get_gpio(np, 3); pr_info("gpio_test_led:%d\n", gpio_test_led); #endif return 0; }
static int w1_gpio_msm_probe_dt(struct platform_device *pdev) { struct w1_gpio_msm_platform_data *pdata = pdev->dev.platform_data; struct device_node *np = pdev->dev.of_node; int irq_num; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; if (of_get_property(np, "linux,open-drain", NULL)) pdata->is_open_drain = 1; if (of_get_property(np, "linux,slave-speed", NULL)) pdata->slave_speed= 1; pdata->irq_gpio = of_get_named_gpio(np, "w1,irq-gpio", 0); irq_num = pdata->irq_gpio; if (irq_num < 0) pdata->irq_gpio = -1; pdata->pin = of_get_gpio(np, 0); pdata->ext_pullup_enable_pin = of_get_gpio(np, 1); pdev->dev.platform_data = pdata; return 0; }
static int w1_gpio_probe_dt(struct platform_device *pdev) { struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); struct device_node *np = pdev->dev.of_node; int gpio; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; if (of_get_property(np, "linux,open-drain", NULL)) pdata->is_open_drain = 1; gpio = of_get_gpio(np, 0); if (gpio < 0) { if (gpio != -EPROBE_DEFER) dev_err(&pdev->dev, "Failed to parse gpio property for data pin (%d)\n", gpio); return gpio; } pdata->pin = gpio; gpio = of_get_gpio(np, 1); if (gpio == -EPROBE_DEFER) return gpio; /* ignore other errors as the pullup gpio is optional */ pdata->ext_pullup_enable_pin = gpio; pdev->dev.platform_data = pdata; return 0; }
static int wcnss_pronto_gpios_config(struct device *dev, bool enable) { int rc = 0; int i, j; int WCNSS_WLAN_NUM_GPIOS = 5; for (i = 0; i < WCNSS_WLAN_NUM_GPIOS; i++) { int gpio = of_get_gpio(dev->of_node, i); if (enable) { rc = gpio_request(gpio, "wcnss_wlan"); if (rc) { pr_err("WCNSS gpio_request %d err %d\n", gpio, rc); goto fail; } } else gpio_free(gpio); } return rc; fail: for (j = WCNSS_WLAN_NUM_GPIOS-1; j >= 0; j--) { int gpio = of_get_gpio(dev->of_node, i); gpio_free(gpio); } return rc; }
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 hdmi_set_gpio(struct hdmi_device *hdev) { struct device *dev = hdev->dev; struct hdmi_resources *res = &hdev->res; int ret = 0; if (of_get_property(dev->of_node, "gpios", NULL) != NULL) { /* HPD */ res->gpio_hpd = of_get_gpio(dev->of_node, 0); if (res->gpio_hpd < 0) { dev_err(dev, "failed to get gpio hpd\n"); return -ENODEV; } if (gpio_request(res->gpio_hpd, "hdmi-hpd")) { dev_err(dev, "failed to request hdmi-hpd\n"); ret = -ENODEV; } else { gpio_direction_input(res->gpio_hpd); dev_info(dev, "success request GPIO for hdmi-hpd\n"); } #ifndef CONFIG_SEC_MHL_SUPPORT /* Level shifter */ res->gpio_ls = of_get_gpio(dev->of_node, 1); if (res->gpio_ls < 0) { dev_info(dev, "There is no gpio for level shifter\n"); return 0; } if (gpio_request(res->gpio_ls, "hdmi-ls")) { dev_err(dev, "failed to request hdmi-ls\n"); ret = -ENODEV; } else { gpio_direction_output(res->gpio_ls, 1); gpio_set_value(res->gpio_ls, 1); dev_info(dev, "success request GPIO for hdmi-ls\n"); } /* DCDC */ res->gpio_dcdc = of_get_gpio(dev->of_node, 2); if (res->gpio_dcdc < 0) { dev_err(dev, "failed to get gpio dcdc\n"); return -ENODEV; } if (gpio_request(res->gpio_dcdc, "hdmi-dcdc")) { dev_err(dev, "failed to request hdmi-dcdc\n"); ret = -ENODEV; } else { gpio_direction_output(res->gpio_dcdc, 1); gpio_set_value(res->gpio_dcdc, 1); dev_info(dev, "success request GPIO for hdmi-dcdc\n"); } #endif } 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 int hdmi_set_gpio(struct hdmi_device *hdev) { struct device *dev = hdev->dev; struct hdmi_resources *res = &hdev->res; int ret = 0; if (of_get_property(dev->of_node, "gpios", NULL) != NULL) { /* HPD */ res->gpio_hpd = of_get_gpio(dev->of_node, 0); if (res->gpio_hpd < 0) { dev_err(dev, "failed to get gpio hpd\n"); return -ENODEV; } if (gpio_request(res->gpio_hpd, "hdmi-hpd")) { dev_err(dev, "failed to request hdmi-hpd\n"); ret = -ENODEV; } else { gpio_direction_input(res->gpio_hpd); s5p_v4l2_int_src_ext_hpd(hdev); dev_info(dev, "success request GPIO for hdmi-hpd\n"); } /* Level shifter */ res->gpio_ls = of_get_gpio(dev->of_node, 1); if (res->gpio_ls < 0) { dev_err(dev, "failed to get gpio ls\n"); return -ENODEV; } if (gpio_request(res->gpio_ls, "hdmi-ls")) { dev_err(dev, "failed to request hdmi-ls\n"); ret = -ENODEV; } else { gpio_direction_output(res->gpio_ls, 1); gpio_set_value(res->gpio_ls, 1); dev_info(dev, "success request GPIO for hdmi-ls\n"); } /* DDC */ res->gpio_dcdc = of_get_gpio(dev->of_node, 2); if (res->gpio_dcdc < 0) { dev_err(dev, "failed to get gpio dcdc\n"); return -ENODEV; } if (gpio_request(res->gpio_dcdc, "hdmi-dcdc")) { dev_err(dev, "failed to request hdmi-dcdc\n"); ret = -ENODEV; } else { gpio_direction_output(res->gpio_dcdc, 1); gpio_set_value(res->gpio_dcdc, 1); dev_info(dev, "success request GPIO for hdmi-dcdc\n"); } } return ret; }
static void getIoResourceDT(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; bt_power = of_get_gpio(np, 0); if (bt_power < 0) { printk("couldn't bt_power gpio\n"); } bt_reset = of_get_gpio(np, 1); if (bt_reset < 0) { printk("couldn't bt_reset gpio\n"); } printk("bt_reset = %ld, bt_power = %ld\n", bt_reset, bt_power); }
static int parse_dsi_drvdata(struct device_node *np) { u32 temp, i; DT_READ_U32_OPTIONAL(np, "e_interface", g_dsim_config.e_interface); DT_READ_U32_OPTIONAL(np, "e_pixel_format", g_dsim_config.e_pixel_format); DT_READ_U32_OPTIONAL(np, "auto_flush", g_dsim_config.auto_flush); DT_READ_U32_OPTIONAL(np, "eot_disable", g_dsim_config.eot_disable); DT_READ_U32_OPTIONAL(np, "auto_vertical_cnt", g_dsim_config.auto_vertical_cnt); DT_READ_U32_OPTIONAL(np, "hse", g_dsim_config.hse); DT_READ_U32_OPTIONAL(np, "hfp", g_dsim_config.hfp); DT_READ_U32_OPTIONAL(np, "hbp", g_dsim_config.hbp); DT_READ_U32_OPTIONAL(np, "hsa", g_dsim_config.hsa); DT_READ_U32_OPTIONAL(np, "e_no_data_lane", g_dsim_config.e_no_data_lane); DT_READ_U32_OPTIONAL(np, "e_byte_clk", g_dsim_config.e_byte_clk); DT_READ_U32_OPTIONAL(np, "e_burst_mode", g_dsim_config.e_burst_mode); DT_READ_U32_OPTIONAL(np, "p", g_dsim_config.p); DT_READ_U32_OPTIONAL(np, "m", g_dsim_config.m); DT_READ_U32_OPTIONAL(np, "s", g_dsim_config.s); DT_READ_U32_OPTIONAL(np, "pll_stable_time", g_dsim_config.pll_stable_time); DT_READ_U32_OPTIONAL(np, "esc_clk", g_dsim_config.esc_clk); DT_READ_U32_OPTIONAL(np, "stop_holding_cnt", g_dsim_config.stop_holding_cnt); DT_READ_U32_OPTIONAL(np, "bta_timeout", g_dsim_config.bta_timeout); DT_READ_U32_OPTIONAL(np, "rx_timeout", g_dsim_config.rx_timeout); for (i = 0; i < of_gpio_count(np); i++) g_disp_gpios.id[i] = of_get_gpio(np, i); return 0; }
static void sec_power_off(void) { int poweroff_try = 0; struct power_supply *ac_psy = power_supply_get_by_name("ac"); struct power_supply *usb_psy = power_supply_get_by_name("usb"); struct power_supply *wc_psy = power_supply_get_by_name("wireless"); union power_supply_propval ac_val; union power_supply_propval usb_val; union power_supply_propval wc_val; #ifdef CONFIG_OF int powerkey_gpio = -1; struct device_node *np, *pp; np = of_find_node_by_path("/gpio_keys"); if (!np) return; for_each_child_of_node(np, pp) { uint keycode = 0; if (!of_find_property(pp, "gpios", NULL)) continue; of_property_read_u32(pp, "linux,code", &keycode); if (keycode == KEY_POWER) { pr_info("%s: <%u>\n", __func__, keycode); powerkey_gpio = of_get_gpio(pp, 0); break; } }
static int of_tsu6721_muic_dt(struct device *dev, struct tsu6721_muic_data *muic_data) { struct device_node *np_muic = dev->of_node; int ret = 0; if (np_muic == NULL) { pr_err("%s np NULL\n", __func__); return -EINVAL; } else { muic_data->pdata->irq_gpio = of_get_named_gpio(np_muic, "muic,muic_int", 0); if (muic_data->pdata->irq_gpio < 0) { pr_err("%s error reading muic_irq = %d\n", __func__, muic_data->pdata->irq_gpio); muic_data->pdata->irq_gpio = 0; } if (of_gpio_count(np_muic) < 1) { dev_err(muic_data->dev, "could not find muic gpio\n"); muic_data->pdata->gpio_uart_sel = 0; } else { muic_data->pdata->gpio_uart_sel = of_get_gpio(np_muic, 0); } } return ret; }
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; }
/** * ti_bandgap_build() - parse DT and setup a struct ti_bandgap * @pdev: pointer to device struct platform_device * * Used to read the device tree properties accordingly to the bandgap * matching version. Based on bandgap version and its capabilities it * will build a struct ti_bandgap out of the required DT entries. * * Return: valid bandgap structure if successful, else returns ERR_PTR * return value must be verified with IS_ERR. */ static struct ti_bandgap *ti_bandgap_build(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; const struct of_device_id *of_id; struct ti_bandgap *bgp; struct resource *res; int i; /* just for the sake */ if (!node) { dev_err(&pdev->dev, "no platform information available\n"); return ERR_PTR(-EINVAL); } bgp = devm_kzalloc(&pdev->dev, sizeof(*bgp), GFP_KERNEL); if (!bgp) { dev_err(&pdev->dev, "Unable to allocate mem for driver ref\n"); return ERR_PTR(-ENOMEM); } of_id = of_match_device(of_ti_bandgap_match, &pdev->dev); if (of_id) bgp->conf = of_id->data; /* register shadow for context save and restore */ bgp->regval = devm_kzalloc(&pdev->dev, sizeof(*bgp->regval) * bgp->conf->sensor_count, GFP_KERNEL); if (!bgp) { dev_err(&pdev->dev, "Unable to allocate mem for driver ref\n"); return ERR_PTR(-ENOMEM); } i = 0; do { void __iomem *chunk; res = platform_get_resource(pdev, IORESOURCE_MEM, i); if (!res) break; chunk = devm_ioremap_resource(&pdev->dev, res); if (i == 0) bgp->base = chunk; if (IS_ERR(chunk)) return ERR_CAST(chunk); i++; } while (res); if (TI_BANDGAP_HAS(bgp, TSHUT)) { bgp->tshut_gpio = of_get_gpio(node, 0); if (!gpio_is_valid(bgp->tshut_gpio)) { dev_err(&pdev->dev, "invalid gpio for tshut (%d)\n", bgp->tshut_gpio); return ERR_PTR(-EINVAL); } } return bgp; }
static int __devinit usr_reset_of_init(struct usr_reset_warning_data *data, struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; data->gpio = of_get_gpio(np, 0); return ((data->gpio < 0) ? -EINVAL : 0); }
static int at91_cf_dt_init(struct platform_device *pdev) { struct at91_cf_data *board; board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL); if (!board) return -ENOMEM; board->irq_pin = of_get_gpio(pdev->dev.of_node, 0); board->det_pin = of_get_gpio(pdev->dev.of_node, 1); board->vcc_pin = of_get_gpio(pdev->dev.of_node, 2); board->rst_pin = of_get_gpio(pdev->dev.of_node, 3); pdev->dev.platform_data = board; return 0; }
static int w1_gpio_probe_dt(struct platform_device *pdev) { struct w1_gpio_platform_data *pdata = pdev->dev.platform_data; struct device_node *np = pdev->dev.of_node; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; if (of_get_property(np, "linux,open-drain", NULL)) pdata->is_open_drain = 1; pdata->pin = of_get_gpio(np, 0); pdata->ext_pullup_enable_pin = of_get_gpio(np, 1); pdev->dev.platform_data = pdata; return 0; }
static struct bcm2079x_platform_data * bcm2079x_of_init(struct i2c_client *client) { struct bcm2079x_platform_data *pdata; struct device_node *np = client->dev.of_node; pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) { dev_err(&client->dev, "pdata allocation failure\n"); return NULL; } pdata->wake_gpio = of_get_gpio(np, 0); pdata->irq_gpio = of_get_gpio(np, 1); pdata->en_gpio = of_get_gpio(np, 2); return pdata; }
static int __devinit fan5646_of_init(struct device *dev) { struct device_node *np, *sp; int rc = 0; struct fan5646_data *pdata = dev_get_drvdata(dev); np = dev->of_node; if (!np) return -ENODEV; rc = of_property_read_string(np, "linux-name", &pdata->led.name); if (rc) { dev_err(dev, "Error reading name rc %d\n", rc); return rc; } rc = of_property_read_string(np, "rgb-name", &pdata->rgb.name); if (rc) { dev_err(dev, "Error reading name rc %d\n", rc); return rc; } rc = of_property_read_u32(np, "full-current", &pdata->full_current); if (rc) { dev_err(dev, "Error reading current rc %d\n", rc); return rc; } rc = of_property_read_u32(np, "tsleep", &pdata->tsleep); if (rc) { dev_err(dev, "Error reading tsleep rc %d\n", rc); return rc; } pdata->com_gpio = of_get_gpio(np, 0); if (pdata->com_gpio < 0) { dev_err(dev, "Error getting comm gpio\n"); return -EINVAL; } /* Done reading fan5646 node. Find node describing our regulator */ /* For now we need only regulator-name */ sp = of_parse_phandle(np, "fan5646-supply", 0); if (!sp) { dev_err(dev, "Error getting vreg node\n"); return -ENODEV; } rc = of_property_read_string(sp, "regulator-name", &pdata->regname); if (rc) dev_err(dev, "Error reading regulator name rc %d\n", rc); of_node_put(sp); return rc; }
static int tpd_probe_of(struct platform_device *pdev) { struct panel_drv_data *ddata = platform_get_drvdata(pdev); struct device_node *node = pdev->dev.of_node; struct omap_dss_device *in; int gpio; /* CT CP HPD GPIO */ gpio = of_get_gpio(node, 0); if (!gpio_is_valid(gpio)) { dev_err(&pdev->dev, "failed to parse CT CP HPD gpio\n"); return gpio; } ddata->ct_cp_hpd_gpio = gpio; /* LS OE GPIO */ gpio = of_get_gpio(node, 1); if (gpio_is_valid(gpio) || gpio == -ENOENT) { ddata->ls_oe_gpio = gpio; } else { dev_err(&pdev->dev, "failed to parse LS OE gpio\n"); return gpio; } /* HPD GPIO */ gpio = of_get_gpio(node, 2); if (!gpio_is_valid(gpio)) { dev_err(&pdev->dev, "failed to parse HPD gpio\n"); return gpio; } ddata->hpd_gpio = gpio; in = omapdss_of_find_source_for_first_ep(node); if (IS_ERR(in)) { dev_err(&pdev->dev, "failed to find video source\n"); return PTR_ERR(in); } ddata->in = in; return 0; }
static int pika_setup_leds(void) { struct device_node *np, *child; np = of_find_compatible_node(NULL, NULL, "gpio-leds"); if (!np) { printk(KERN_ERR __FILE__ ": Unable to find leds\n"); return -ENOENT; } for_each_child_of_node(np, child) if (strcmp(child->name, "green") == 0) green_led = of_get_gpio(child, 0); else if (strcmp(child->name, "red") == 0) red_led = of_get_gpio(child, 0); of_node_put(np); return 0; }
static int wifi_plat_dev_drv_probe(struct platform_device *pdev) { struct resource *resource; wifi_adapter_info_t *adapter; #ifdef CONFIG_DTS int irq, gpio; #endif /* CONFIG_DTS */ /* Android style wifi platform data device ("bcmdhd_wlan" or "bcm4329_wlan") * is kept for backward compatibility and supports only 1 adapter */ ASSERT(dhd_wifi_platdata != NULL); ASSERT(dhd_wifi_platdata->num_adapters == 1); adapter = &dhd_wifi_platdata->adapters[0]; adapter->wifi_plat_data = (struct wifi_platform_data *)(pdev->dev.platform_data); resource = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "bcmdhd_wlan_irq"); if (resource == NULL) resource = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "bcm4329_wlan_irq"); if (resource) { adapter->irq_num = resource->start; adapter->intr_flags = resource->flags & IRQF_TRIGGER_MASK; } #ifdef CONFIG_DTS wifi_regulator = regulator_get(&pdev->dev, "wlreg_on"); if (wifi_regulator == NULL) { DHD_ERROR(("%s regulator is null\n", __FUNCTION__)); return -1; } /* This is to get the irq for the OOB */ gpio = of_get_gpio(pdev->dev.of_node, 0); if (gpio < 0) { DHD_ERROR(("%s gpio information is incorrect\n", __FUNCTION__)); return -1; } irq = gpio_to_irq(gpio); if (irq < 0) { DHD_ERROR(("%s irq information is incorrect\n", __FUNCTION__)); return -1; } adapter->irq_num = irq; /* need to change the flags according to our requirement */ adapter->intr_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE; #endif /* CONFIG_DTS */ wifi_plat_dev_probe_ret = dhd_wifi_platform_load(); return wifi_plat_dev_probe_ret; }
static int at91_cf_dt_init(struct platform_device *pdev) { struct at91_cf_data *board; board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL); if (!board) return -ENOMEM; board->irq_pin = of_get_gpio(pdev->dev.of_node, 0); board->det_pin = of_get_gpio(pdev->dev.of_node, 1); board->vcc_pin = of_get_gpio(pdev->dev.of_node, 2); board->rst_pin = of_get_gpio(pdev->dev.of_node, 3); pdev->dev.platform_data = board; mc = syscon_regmap_lookup_by_compatible("atmel,at91rm9200-sdramc"); if (IS_ERR(mc)) return PTR_ERR(mc); return 0; }
int __init __p2pm_poff_init(void) { int retval = 0; PINFO("initialize is started\n"); memset(¶m,0,sizeof(param)); #ifdef CONFIG_P2PF_PM_POFF_GPIO_OF { struct device_node *np; const u32 *prop; u32 len; np = of_find_compatible_node(NULL,NULL,compatible); if(!np){ PWARNING("NOT found a node for \"%s\"",compatible); goto fail; } prop = of_get_property(np,"poff",&len); len /= sizeof(u32); if(!prop||len<2){ PERROR("NOT found \"poff\" property or too few cells in this property\n"); retval = -EINVAL; goto fail; } param.gpio = of_get_gpio(np,prop[0]); if(param.gpio<0){ PERROR("NOT foud gpio port\n"); retval = param.gpio; goto fail; } param.pol = prop[1]?1:0; } #else /* ! CONFIG_P2PF_PM_POFF_GPIO_OF */ param.gpio = CONFIG_P2PF_PM_POFF_GPIO_PORT; #ifdef CONFIG_P2PF_PM_POFF_GPIO_POL_HIGH param.pol = 1; #else /* ! CONFIG_P2PF_PM_POFF_GPIO_POL_HIGH */ param.pol = 0; #endif /* CONFIG_P2PF_PM_POFF_GPIO_POL_HIGH */ #endif /* CONFIG_P2PF_PM_POFF_GPIO_OF */ PINFO("gpio=%d,pol=Active-%s\n",param.gpio,param.pol?"HIGH":"LOW"); fail: return retval; }
static struct leds_S5430_platform_data *leds_S5430_parse_dt(struct platform_device *pdev) { struct leds_S5430_platform_data *pdata; struct device_node *np = pdev->dev.of_node; int gpio; if (!np) return ERR_PTR(-ENOENT); pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) { dev_err(&pdev->dev, "failed to allocate platform data\n"); return ERR_PTR(-ENOMEM); } pdev->dev.platform_data = pdata; //BLUE gpio = of_get_gpio(np, 0); if (!gpio_is_valid(gpio)) { return ERR_PTR(-EINVAL); } led_info[LED_BLUE].gpio = gpio; //RED gpio = of_get_gpio(np, 1); if (!gpio_is_valid(gpio)) { return ERR_PTR(-EINVAL); } led_info[LED_RED].gpio = gpio; //GREEN gpio = of_get_gpio(np, 2); if (!gpio_is_valid(gpio)) { return ERR_PTR(-EINVAL); } led_info[LED_GREEN].gpio = gpio; return pdata; }
static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev) { struct auo_pixcir_ts_platdata *pdata; struct device_node *np = dev->of_node; if (!np) return ERR_PTR(-ENOENT); pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return ERR_PTR(-ENOMEM); pdata->gpio_int = of_get_gpio(np, 0); if (!gpio_is_valid(pdata->gpio_int)) { dev_err(dev, "failed to get interrupt gpio\n"); return ERR_PTR(-EINVAL); } pdata->gpio_rst = of_get_gpio(np, 1); if (!gpio_is_valid(pdata->gpio_rst)) { dev_err(dev, "failed to get reset gpio\n"); return ERR_PTR(-EINVAL); } if (of_property_read_u32(np, "x-size", &pdata->x_max)) { dev_err(dev, "failed to get x-size property\n"); return ERR_PTR(-EINVAL); } if (of_property_read_u32(np, "y-size", &pdata->y_max)) { dev_err(dev, "failed to get y-size property\n"); return ERR_PTR(-EINVAL); } /* default to asserting the interrupt when the screen is touched */ pdata->int_setting = AUO_PIXCIR_INT_TOUCH_IND; return pdata; }
static int __devinit find_phy(struct device_node *np, struct fs_platform_info *fpi) { struct device_node *phynode, *mdionode; int ret = 0, len, bus_id; const u32 *data; data = of_get_property(np, "fixed-link", NULL); if (data) { snprintf(fpi->bus_id, 16, "%x:%02x", 0, *data); return 0; } data = of_get_property(np, "phy-handle", &len); if (!data || len != 4) return -EINVAL; phynode = of_find_node_by_phandle(*data); if (!phynode) return -EINVAL; data = of_get_property(phynode, "reg", &len); if (!data || len != 4) { ret = -EINVAL; goto out_put_phy; } mdionode = of_get_parent(phynode); if (!mdionode) { ret = -EINVAL; goto out_put_phy; } bus_id = of_get_gpio(mdionode, 0); if (bus_id < 0) { struct resource res; ret = of_address_to_resource(mdionode, 0, &res); if (ret) goto out_put_mdio; bus_id = res.start; } snprintf(fpi->bus_id, 16, "%x:%02x", bus_id, *data); out_put_mdio: of_node_put(mdionode); out_put_phy: of_node_put(phynode); return ret; }
static struct pn544_i2c_platform_data * pn544_of_init(struct i2c_client *client) { struct pn544_i2c_platform_data *pdata; struct device_node *np = client->dev.of_node; pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) { dev_err(&client->dev, "pdata allocation failure\n"); return NULL; } of_property_read_u32(np, "nxp,pnxxx-discharge-delay", &pdata->discharge_delay); of_property_read_u32(np, "nxp,pnxxx-ven-inv-polarity", &pdata->ven_polarity); pdata->irq_gpio = of_get_gpio(np, 0); pdata->ven_gpio = of_get_gpio(np, 1); pdata->firmware_gpio = of_get_gpio(np, 2); return pdata; }
static void *mdio_gpio_of_get_data(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct mdio_gpio_platform_data *pdata; int ret; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return NULL; ret = of_get_gpio(np, 0); if (ret < 0) return NULL; pdata->mdc = ret; ret = of_get_gpio(np, 1); if (ret < 0) return NULL; pdata->mdio = ret; return pdata; }
static int wifi_plat_dev_drv_probe(struct platform_device *pdev) { struct resource *resource; wifi_adapter_info_t *adapter; #if defined(BCMPCIE) && defined(CONFIG_WIFI_CONTROL_FUNC) int irq, gpio; #endif /* Android style wifi platform data device ("bcmdhd_wlan" or "bcm4329_wlan") * is kept for backward compatibility and supports only 1 adapter */ ASSERT(dhd_wifi_platdata != NULL); ASSERT(dhd_wifi_platdata->num_adapters == 1); adapter = &dhd_wifi_platdata->adapters[0]; #if defined(BCMPCIE) && defined(CONFIG_WIFI_CONTROL_FUNC) adapter->wifi_plat_data = (void *)&somc_wifi_control; #else adapter->wifi_plat_data = (struct wifi_platform_data *)(pdev->dev.platform_data); #endif resource = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "bcmdhd_wlan_irq"); if (resource == NULL) resource = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "bcm4329_wlan_irq"); if (resource) { adapter->irq_num = resource->start; adapter->intr_flags = resource->flags & IRQF_TRIGGER_MASK; } #if defined(BCMPCIE) && defined(CONFIG_WIFI_CONTROL_FUNC) somc_wifi_init(pdev); gpio = of_get_gpio(pdev->dev.of_node, 1); if (gpio < 0) { DHD_ERROR(("%s gpio information is incorrect\n", __FUNCTION__)); return -1; } irq = gpio_to_irq(gpio); if (irq < 0) { DHD_ERROR(("%s irq information is incorrect\n", __FUNCTION__)); return -1; } adapter->irq_num = irq; /* need to change the flags according to our requirement */ adapter->intr_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE; #endif wifi_plat_dev_probe_ret = dhd_wifi_platform_load(); return wifi_plat_dev_probe_ret; }