static int max3355_probe(struct platform_device *pdev) { struct max3355_data *data; struct gpio_desc *gpiod; int irq, err; data = devm_kzalloc(&pdev->dev, sizeof(struct max3355_data), GFP_KERNEL); if (!data) return -ENOMEM; gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN); if (IS_ERR(gpiod)) { dev_err(&pdev->dev, "failed to get ID_OUT GPIO\n"); return PTR_ERR(gpiod); } data->id_gpiod = gpiod; gpiod = devm_gpiod_get(&pdev->dev, "maxim,shdn", GPIOD_OUT_HIGH); if (IS_ERR(gpiod)) { dev_err(&pdev->dev, "failed to get SHDN# GPIO\n"); return PTR_ERR(gpiod); } data->shdn_gpiod = gpiod; data->edev = devm_extcon_dev_allocate(&pdev->dev, max3355_cable); if (IS_ERR(data->edev)) { dev_err(&pdev->dev, "failed to allocate extcon device\n"); return PTR_ERR(data->edev); } err = devm_extcon_dev_register(&pdev->dev, data->edev); if (err < 0) { dev_err(&pdev->dev, "failed to register extcon device\n"); return err; } irq = gpiod_to_irq(data->id_gpiod); if (irq < 0) { dev_err(&pdev->dev, "failed to translate ID_OUT GPIO to IRQ\n"); return irq; } err = devm_request_threaded_irq(&pdev->dev, irq, NULL, max3355_id_irq, IRQF_ONESHOT | IRQF_NO_SUSPEND | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, pdev->name, data); if (err < 0) { dev_err(&pdev->dev, "failed to request ID_OUT IRQ\n"); return err; } platform_set_drvdata(pdev, data); /* Perform initial detection */ max3355_id_irq(irq, data); return 0; }
static int edp_gpio_config(struct edp_ctrl *ctrl) { struct device *dev = &ctrl->pdev->dev; int ret; ctrl->panel_hpd_gpio = devm_gpiod_get(dev, "panel-hpd", GPIOD_IN); if (IS_ERR(ctrl->panel_hpd_gpio)) { ret = PTR_ERR(ctrl->panel_hpd_gpio); ctrl->panel_hpd_gpio = NULL; pr_err("%s: cannot get panel-hpd-gpios, %d\n", __func__, ret); return ret; } ctrl->panel_en_gpio = devm_gpiod_get(dev, "panel-en", GPIOD_OUT_LOW); if (IS_ERR(ctrl->panel_en_gpio)) { ret = PTR_ERR(ctrl->panel_en_gpio); ctrl->panel_en_gpio = NULL; pr_err("%s: cannot get panel-en-gpios, %d\n", __func__, ret); return ret; } DBG("gpio on"); return 0; }
static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev) { struct tpm_chip *chip = spi_get_drvdata(spi_dev); struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); struct st33zp24_spi_phy *phy = tpm_dev->phy_id; struct gpio_desc *gpiod_lpcpd; struct device *dev = &spi_dev->dev; int ret; ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_st33zp24_gpios); if (ret) return ret; /* Get LPCPD GPIO from ACPI */ gpiod_lpcpd = devm_gpiod_get(dev, "lpcpd", GPIOD_OUT_HIGH); if (IS_ERR(gpiod_lpcpd)) { dev_err(dev, "Failed to retrieve lpcpd-gpios from acpi.\n"); phy->io_lpcpd = -1; /* * lpcpd pin is not specified. This is not an issue as * power management can be also managed by TPM specific * commands. So leave with a success status code. */ return 0; } phy->io_lpcpd = desc_to_gpio(gpiod_lpcpd); return 0; }
static int gpio_poweroff_probe(struct platform_device *pdev) { bool input = false; enum gpiod_flags flags; /* If a pm_power_off function has already been added, leave it alone */ if (pm_power_off != NULL) { dev_err(&pdev->dev, "%s: pm_power_off function already registered", __func__); return -EBUSY; } input = device_property_read_bool(&pdev->dev, "input"); if (input) flags = GPIOD_IN; else flags = GPIOD_OUT_LOW; device_property_read_u32(&pdev->dev, "active-delay-ms", &active_delay); device_property_read_u32(&pdev->dev, "inactive-delay-ms", &inactive_delay); device_property_read_u32(&pdev->dev, "timeout-ms", &timeout); reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags); if (IS_ERR(reset_gpio)) return PTR_ERR(reset_gpio); pm_power_off = &gpio_poweroff_do_poweroff; return 0; }
static int wm8524_codec_probe(struct platform_device *pdev) { struct wm8524_priv *wm8524; int ret; wm8524 = devm_kzalloc(&pdev->dev, sizeof(struct wm8524_priv), GFP_KERNEL); if (wm8524 == NULL) return -ENOMEM; platform_set_drvdata(pdev, wm8524); wm8524->mute = devm_gpiod_get(&pdev->dev, "wlf,mute", GPIOD_OUT_LOW); if (IS_ERR(wm8524->mute)) { ret = PTR_ERR(wm8524->mute); dev_err(&pdev->dev, "Failed to get mute line: %d\n", ret); return ret; } ret = devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_wm8524, &wm8524_dai, 1); if (ret < 0) dev_err(&pdev->dev, "Failed to register component: %d\n", ret); return ret; }
static int mst_pcmcia_hw_init(struct soc_pcmcia_socket *skt) { struct device *dev = skt->socket.dev.parent; struct max1600 *m; int ret; skt->stat[SOC_STAT_CD].name = skt->nr ? "bdetect" : "adetect"; skt->stat[SOC_STAT_BVD1].name = skt->nr ? "bbvd1" : "abvd1"; skt->stat[SOC_STAT_BVD2].name = skt->nr ? "bbvd2" : "abvd2"; skt->stat[SOC_STAT_RDY].name = skt->nr ? "bready" : "aready"; skt->stat[SOC_STAT_VS1].name = skt->nr ? "bvs1" : "avs1"; skt->stat[SOC_STAT_VS2].name = skt->nr ? "bvs2" : "avs2"; skt->gpio_reset = devm_gpiod_get(dev, skt->nr ? "breset" : "areset", GPIOD_OUT_HIGH); if (IS_ERR(skt->gpio_reset)) return PTR_ERR(skt->gpio_reset); ret = max1600_init(dev, &m, skt->nr ? MAX1600_CHAN_B : MAX1600_CHAN_A, MAX1600_CODE_HIGH); if (ret) return ret; skt->driver_data = m; return soc_pcmcia_request_gpiods(skt); }
static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev) { struct i2c_bus_recovery_info *rinfo = &dev->rinfo; struct i2c_adapter *adap = &dev->adapter; struct gpio_desc *gpio; int r; gpio = devm_gpiod_get(dev->dev, "scl", GPIOD_OUT_HIGH); if (IS_ERR(gpio)) { r = PTR_ERR(gpio); if (r == -ENOENT || r == -ENOSYS) return 0; return r; } rinfo->scl_gpiod = gpio; gpio = devm_gpiod_get_optional(dev->dev, "sda", GPIOD_IN); if (IS_ERR(gpio)) return PTR_ERR(gpio); rinfo->sda_gpiod = gpio; rinfo->recover_bus = i2c_generic_scl_recovery; rinfo->prepare_recovery = i2c_dw_prepare_recovery; rinfo->unprepare_recovery = i2c_dw_unprepare_recovery; adap->bus_recovery_info = rinfo; dev_info(dev->dev, "running with gpio recovery mode! scl%s", rinfo->sda_gpiod ? ",sda" : ""); return 0; }
static int st7735r_probe(struct spi_device *spi) { struct device *dev = &spi->dev; struct mipi_dbi *mipi; struct gpio_desc *dc; u32 rotation = 0; int ret; mipi = devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL); if (!mipi) return -ENOMEM; mipi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(mipi->reset)) { DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n"); return PTR_ERR(mipi->reset); } dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW); if (IS_ERR(dc)) { DRM_DEV_ERROR(dev, "Failed to get gpio 'dc'\n"); return PTR_ERR(dc); } mipi->backlight = devm_of_find_backlight(dev); if (IS_ERR(mipi->backlight)) return PTR_ERR(mipi->backlight); device_property_read_u32(dev, "rotation", &rotation); ret = mipi_dbi_spi_init(spi, mipi, dc); if (ret) return ret; /* Cannot read from Adafruit 1.8" display via SPI */ mipi->read_commands = NULL; ret = mipi_dbi_init(&spi->dev, mipi, &jd_t18003_t01_pipe_funcs, &st7735r_driver, &jd_t18003_t01_mode, rotation); if (ret) return ret; spi_set_drvdata(spi, mipi); return devm_tinydrm_register(&mipi->tinydrm); }
static int xdmsc_parse_of(struct xdmsc_dev *xdmsc) { struct device *dev = xdmsc->xvip.dev; struct device_node *node = dev->of_node; struct device_node *ports; struct device_node *port; u32 port_id = 0; int rval; rval = of_property_read_u32(node, "xlnx,max-height", &xdmsc->max_height); if (rval < 0) { dev_err(dev, "missing xlnx,max-height property!"); return -EINVAL; } else if (xdmsc->max_height > XDEMOSAIC_MAX_HEIGHT || xdmsc->max_height < XDEMOSAIC_MIN_HEIGHT) { dev_err(dev, "Invalid height in dt"); return -EINVAL; } rval = of_property_read_u32(node, "xlnx,max-width", &xdmsc->max_width); if (rval < 0) { dev_err(dev, "missing xlnx,max-width property!"); return -EINVAL; } else if (xdmsc->max_width > XDEMOSAIC_MAX_WIDTH || xdmsc->max_width < XDEMOSAIC_MIN_WIDTH) { dev_err(dev, "Invalid width in dt"); return -EINVAL; } ports = of_get_child_by_name(node, "ports"); if (!ports) ports = node; /* Get the format description for each pad */ for_each_child_of_node(ports, port) { if (port->name && (of_node_cmp(port->name, "port") == 0)) { rval = of_property_read_u32(port, "reg", &port_id); if (rval < 0) { dev_err(dev, "No reg in DT"); return rval; } if (port_id != 0 && port_id != 1) { dev_err(dev, "Invalid reg in DT"); return -EINVAL; } } } xdmsc->rst_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(xdmsc->rst_gpio)) { if (PTR_ERR(xdmsc->rst_gpio) != -EPROBE_DEFER) dev_err(dev, "Reset GPIO not setup in DT"); return PTR_ERR(xdmsc->rst_gpio); } return 0; }
static int st_nci_spi_probe(struct spi_device *dev) { struct st_nci_spi_phy *phy; int r; dev_dbg(&dev->dev, "%s\n", __func__); dev_dbg(&dev->dev, "IRQ: %d\n", dev->irq); /* Check SPI platform functionnalities */ if (!dev) { pr_debug("%s: dev is NULL. Device is not accessible.\n", __func__); return -ENODEV; } phy = devm_kzalloc(&dev->dev, sizeof(struct st_nci_spi_phy), GFP_KERNEL); if (!phy) return -ENOMEM; phy->spi_dev = dev; spi_set_drvdata(dev, phy); r = devm_acpi_dev_add_driver_gpios(&dev->dev, acpi_st_nci_gpios); if (r) dev_dbg(&dev->dev, "Unable to add GPIO mapping table\n"); /* Get RESET GPIO */ phy->gpiod_reset = devm_gpiod_get(&dev->dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(phy->gpiod_reset)) { nfc_err(&dev->dev, "Unable to get RESET GPIO\n"); return PTR_ERR(phy->gpiod_reset); } phy->se_status.is_ese_present = device_property_read_bool(&dev->dev, "ese-present"); phy->se_status.is_uicc_present = device_property_read_bool(&dev->dev, "uicc-present"); r = ndlc_probe(phy, &spi_phy_ops, &dev->dev, ST_NCI_FRAME_HEADROOM, ST_NCI_FRAME_TAILROOM, &phy->ndlc, &phy->se_status); if (r < 0) { nfc_err(&dev->dev, "Unable to register ndlc layer\n"); return r; } phy->irq_active = true; r = devm_request_threaded_irq(&dev->dev, dev->irq, NULL, st_nci_irq_thread_fn, IRQF_ONESHOT, ST_NCI_SPI_DRIVER_NAME, phy); if (r < 0) nfc_err(&dev->dev, "Unable to register IRQ handler\n"); return r; }
static int gpio_vibrator_probe(struct platform_device *pdev) { struct gpio_vibrator *vibrator; int err; vibrator = devm_kzalloc(&pdev->dev, sizeof(*vibrator), GFP_KERNEL); if (!vibrator) return -ENOMEM; vibrator->input = devm_input_allocate_device(&pdev->dev); if (!vibrator->input) return -ENOMEM; vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc"); err = PTR_ERR_OR_ZERO(vibrator->vcc); if (err) { if (err != -EPROBE_DEFER) dev_err(&pdev->dev, "Failed to request regulator: %d\n", err); return err; } vibrator->gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW); err = PTR_ERR_OR_ZERO(vibrator->gpio); if (err) { if (err != -EPROBE_DEFER) dev_err(&pdev->dev, "Failed to request main gpio: %d\n", err); return err; } INIT_WORK(&vibrator->play_work, gpio_vibrator_play_work); vibrator->input->name = "gpio-vibrator"; vibrator->input->id.bustype = BUS_HOST; vibrator->input->close = gpio_vibrator_close; input_set_drvdata(vibrator->input, vibrator); input_set_capability(vibrator->input, EV_FF, FF_RUMBLE); err = input_ff_create_memless(vibrator->input, NULL, gpio_vibrator_play_effect); if (err) { dev_err(&pdev->dev, "Couldn't create FF dev: %d\n", err); return err; } err = input_register_device(vibrator->input); if (err) { dev_err(&pdev->dev, "Couldn't register input dev: %d\n", err); return err; } platform_set_drvdata(pdev, vibrator); return 0; }
static int adp1653_of_init(struct i2c_client *client, struct adp1653_flash *flash, struct device_node *node) { struct adp1653_platform_data *pd; struct device_node *child; pd = devm_kzalloc(&client->dev, sizeof(*pd), GFP_KERNEL); if (!pd) return -ENOMEM; flash->platform_data = pd; child = of_get_child_by_name(node, "flash"); if (!child) return -EINVAL; if (of_property_read_u32(child, "flash-timeout-us", &pd->max_flash_timeout)) goto err; if (of_property_read_u32(child, "flash-max-microamp", &pd->max_flash_intensity)) goto err; pd->max_flash_intensity /= 1000; if (of_property_read_u32(child, "led-max-microamp", &pd->max_torch_intensity)) goto err; pd->max_torch_intensity /= 1000; of_node_put(child); child = of_get_child_by_name(node, "indicator"); if (!child) return -EINVAL; if (of_property_read_u32(child, "led-max-microamp", &pd->max_indicator_intensity)) goto err; of_node_put(child); pd->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW); if (!pd->enable_gpio) { dev_err(&client->dev, "Error getting GPIO\n"); return -EINVAL; } return 0; err: dev_err(&client->dev, "Required property not found\n"); of_node_put(child); return -EINVAL; }
static int hx8357d_probe(struct spi_device *spi) { struct device *dev = &spi->dev; struct drm_device *drm; struct mipi_dbi *mipi; struct gpio_desc *dc; u32 rotation = 0; int ret; mipi = kzalloc(sizeof(*mipi), GFP_KERNEL); if (!mipi) return -ENOMEM; drm = &mipi->drm; ret = devm_drm_dev_init(dev, drm, &hx8357d_driver); if (ret) { kfree(mipi); return ret; } drm_mode_config_init(drm); dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW); if (IS_ERR(dc)) { DRM_DEV_ERROR(dev, "Failed to get gpio 'dc'\n"); return PTR_ERR(dc); } mipi->backlight = devm_of_find_backlight(dev); if (IS_ERR(mipi->backlight)) return PTR_ERR(mipi->backlight); device_property_read_u32(dev, "rotation", &rotation); ret = mipi_dbi_spi_init(spi, mipi, dc); if (ret) return ret; ret = mipi_dbi_init(mipi, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation); if (ret) return ret; drm_mode_config_reset(drm); ret = drm_dev_register(drm, 0); if (ret) return ret; spi_set_drvdata(spi, drm); drm_fbdev_generic_setup(drm, 0); return 0; }
static int xcsc_parse_of(struct xilinx_csc *csc) { int ret; struct device_node *node = csc->dev->of_node; csc->aclk = devm_clk_get(csc->dev, NULL); if (IS_ERR(csc->aclk)) { ret = PTR_ERR(csc->aclk); dev_err(csc->dev, "failed to get aclk %d\n", ret); return ret; } ret = of_property_read_u32(node, "xlnx,video-width", &csc->color_depth); if (ret < 0) { dev_info(csc->dev, "video width not present in DT\n"); return ret; } if (csc->color_depth != 8 && csc->color_depth != 10 && csc->color_depth != 12 && csc->color_depth != 16) { dev_err(csc->dev, "Invalid video width in DT\n"); return -EINVAL; } /* Reset GPIO */ csc->rst_gpio = devm_gpiod_get(csc->dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(csc->rst_gpio)) { if (PTR_ERR(csc->rst_gpio) != -EPROBE_DEFER) dev_err(csc->dev, "Reset GPIO not setup in DT"); return PTR_ERR(csc->rst_gpio); } ret = of_property_read_u32(node, "xlnx,max-height", &csc->max_height); if (ret < 0) { dev_err(csc->dev, "xlnx,max-height is missing!"); return -EINVAL; } else if (csc->max_height > XCSC_MAX_HEIGHT || csc->max_height < XCSC_MIN_HEIGHT) { dev_err(csc->dev, "Invalid height in dt"); return -EINVAL; } ret = of_property_read_u32(node, "xlnx,max-width", &csc->max_width); if (ret < 0) { dev_err(csc->dev, "xlnx,max-width is missing!"); return -EINVAL; } else if (csc->max_width > XCSC_MAX_WIDTH || csc->max_width < XCSC_MIN_WIDTH) { dev_err(csc->dev, "Invalid width in dt"); return -EINVAL; } return 0; }
static int ams_delta_panel_probe(struct platform_device *pdev) { struct lcd_device *lcd_device = NULL; int ret; gpiod_vblen = devm_gpiod_get(&pdev->dev, "vblen", GPIOD_OUT_LOW); if (IS_ERR(gpiod_vblen)) { ret = PTR_ERR(gpiod_vblen); dev_err(&pdev->dev, "VBLEN GPIO request failed (%d)\n", ret); return ret; } gpiod_ndisp = devm_gpiod_get(&pdev->dev, "ndisp", GPIOD_OUT_LOW); if (IS_ERR(gpiod_ndisp)) { ret = PTR_ERR(gpiod_ndisp); dev_err(&pdev->dev, "NDISP GPIO request failed (%d)\n", ret); return ret; } #ifdef CONFIG_LCD_CLASS_DEVICE lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL, &ams_delta_lcd_ops); if (IS_ERR(lcd_device)) { ret = PTR_ERR(lcd_device); dev_err(&pdev->dev, "failed to register device\n"); return ret; } platform_set_drvdata(pdev, lcd_device); lcd_device->props.max_contrast = AMS_DELTA_MAX_CONTRAST; #endif ams_delta_lcd_set_contrast(lcd_device, AMS_DELTA_DEFAULT_CONTRAST); ams_delta_lcd_set_power(lcd_device, FB_BLANK_UNBLANK); omapfb_register_panel(&ams_delta_panel); return 0; }
static int edp_gpio_config(struct edp_ctrl *ctrl) { struct device *dev = &ctrl->pdev->dev; int ret; ctrl->panel_hpd_gpio = devm_gpiod_get(dev, "panel-hpd"); if (IS_ERR(ctrl->panel_hpd_gpio)) { ret = PTR_ERR(ctrl->panel_hpd_gpio); ctrl->panel_hpd_gpio = NULL; pr_err("%s: cannot get panel-hpd-gpios, %d\n", __func__, ret); return ret; } ret = gpiod_direction_input(ctrl->panel_hpd_gpio); if (ret) { pr_err("%s: Set direction for hpd failed, %d\n", __func__, ret); return ret; } ctrl->panel_en_gpio = devm_gpiod_get(dev, "panel-en"); if (IS_ERR(ctrl->panel_en_gpio)) { ret = PTR_ERR(ctrl->panel_en_gpio); ctrl->panel_en_gpio = NULL; pr_err("%s: cannot get panel-en-gpios, %d\n", __func__, ret); return ret; } ret = gpiod_direction_output(ctrl->panel_en_gpio, 0); if (ret) { pr_err("%s: Set direction for panel_en failed, %d\n", __func__, ret); return ret; } DBG("gpio on"); return 0; }
/** * phy_mdm6600_init_lines() - initialize mdm6600 GPIO lines * @ddata: device driver data */ static int phy_mdm6600_init_lines(struct phy_mdm6600 *ddata) { struct device *dev = ddata->dev; int i; /* MDM6600 control lines */ for (i = 0; i < ARRAY_SIZE(phy_mdm6600_ctrl_gpio_map); i++) { const struct phy_mdm6600_map *map = &phy_mdm6600_ctrl_gpio_map[i]; struct gpio_desc **gpio = &ddata->ctrl_gpios[i]; *gpio = devm_gpiod_get(dev, map->name, map->direction); if (IS_ERR(*gpio)) { dev_info(dev, "gpio %s error %li\n", map->name, PTR_ERR(*gpio)); return PTR_ERR(*gpio); } } /* MDM6600 USB start-up mode output lines */ ddata->mode_gpios = devm_gpiod_get_array(dev, "motorola,mode", GPIOD_OUT_LOW); if (IS_ERR(ddata->mode_gpios)) return PTR_ERR(ddata->mode_gpios); if (ddata->mode_gpios->ndescs != PHY_MDM6600_NR_MODE_LINES) return -EINVAL; /* MDM6600 status input lines */ ddata->status_gpios = devm_gpiod_get_array(dev, "motorola,status", GPIOD_IN); if (IS_ERR(ddata->status_gpios)) return PTR_ERR(ddata->status_gpios); if (ddata->status_gpios->ndescs != PHY_MDM6600_NR_STATUS_LINES) return -EINVAL; /* MDM6600 cmd output lines */ ddata->cmd_gpios = devm_gpiod_get_array(dev, "motorola,cmd", GPIOD_OUT_LOW); if (IS_ERR(ddata->cmd_gpios)) return PTR_ERR(ddata->cmd_gpios); if (ddata->cmd_gpios->ndescs != PHY_MDM6600_NR_CMD_LINES) return -EINVAL; return 0; }
static int panel_dpi_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 r; struct display_timing timing; struct videomode vm; struct gpio_desc *gpio; gpio = devm_gpiod_get(&pdev->dev, "enable"); if (IS_ERR(gpio)) { if (PTR_ERR(gpio) != -ENOENT) return PTR_ERR(gpio); else gpio = NULL; } else { gpiod_direction_output(gpio, 0); } ddata->enable_gpio = gpio; ddata->backlight_gpio = -ENOENT; r = of_get_display_timing(node, "panel-timing", &timing); if (r) { dev_err(&pdev->dev, "failed to get video timing\n"); return r; } videomode_from_timing(&timing, &vm); videomode_to_omap_video_timings(&vm, &ddata->videomode); 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 at803x_probe(struct phy_device *phydev) { struct device *dev = &phydev->dev; struct at803x_priv *priv; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; priv->gpiod_reset = devm_gpiod_get(dev, "reset"); if (IS_ERR(priv->gpiod_reset)) priv->gpiod_reset = NULL; else gpiod_direction_output(priv->gpiod_reset, 1); phydev->priv = priv; return 0; }
int soc_pcmcia_request_gpiods(struct soc_pcmcia_socket *skt) { struct device *dev = skt->socket.dev.parent; struct gpio_desc *desc; int i; for (i = 0; i < ARRAY_SIZE(skt->stat); i++) { if (!skt->stat[i].name) continue; desc = devm_gpiod_get(dev, skt->stat[i].name, GPIOD_IN); if (IS_ERR(desc)) { dev_err(dev, "Failed to get GPIO for %s: %ld\n", skt->stat[i].name, PTR_ERR(desc)); return PTR_ERR(desc); } skt->stat[i].desc = desc; } return 0; }
static int gpio_beeper_probe(struct platform_device *pdev) { struct gpio_beeper *beep; struct input_dev *input; int err; beep = devm_kzalloc(&pdev->dev, sizeof(*beep), GFP_KERNEL); if (!beep) return -ENOMEM; beep->desc = devm_gpiod_get(&pdev->dev, NULL); if (IS_ERR(beep->desc)) return PTR_ERR(beep->desc); input = devm_input_allocate_device(&pdev->dev); if (!input) return -ENOMEM; INIT_WORK(&beep->work, gpio_beeper_work); input->name = pdev->name; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; input->close = gpio_beeper_close; input->event = gpio_beeper_event; input_set_capability(input, EV_SND, SND_BELL); err = gpiod_direction_output(beep->desc, 0); if (err) return err; input_set_drvdata(input, beep); return input_register_device(input); }
int adau1977_probe(struct device *dev, struct regmap *regmap, enum adau1977_type type, void (*switch_mode)(struct device *dev)) { unsigned int power_off_mask; struct adau1977 *adau1977; int ret; if (IS_ERR(regmap)) return PTR_ERR(regmap); adau1977 = devm_kzalloc(dev, sizeof(*adau1977), GFP_KERNEL); if (adau1977 == NULL) return -ENOMEM; adau1977->dev = dev; adau1977->type = type; adau1977->regmap = regmap; adau1977->switch_mode = switch_mode; adau1977->max_master_fs = 192000; adau1977->constraints.list = adau1977_rates; adau1977->constraints.count = ARRAY_SIZE(adau1977_rates); adau1977->avdd_reg = devm_regulator_get(dev, "AVDD"); if (IS_ERR(adau1977->avdd_reg)) return PTR_ERR(adau1977->avdd_reg); adau1977->dvdd_reg = devm_regulator_get_optional(dev, "DVDD"); if (IS_ERR(adau1977->dvdd_reg)) { if (PTR_ERR(adau1977->dvdd_reg) != -ENODEV) return PTR_ERR(adau1977->dvdd_reg); adau1977->dvdd_reg = NULL; } adau1977->reset_gpio = devm_gpiod_get(dev, "reset"); if (IS_ERR(adau1977->reset_gpio)) { ret = PTR_ERR(adau1977->reset_gpio); if (ret != -ENOENT && ret != -ENOSYS) return PTR_ERR(adau1977->reset_gpio); adau1977->reset_gpio = NULL; } dev_set_drvdata(dev, adau1977); if (adau1977->reset_gpio) { ret = gpiod_direction_output(adau1977->reset_gpio, 0); if (ret) return ret; ndelay(100); } ret = adau1977_power_enable(adau1977); if (ret) return ret; if (type == ADAU1977) { ret = adau1977_setup_micbias(adau1977); if (ret) goto err_poweroff; } if (adau1977->dvdd_reg) power_off_mask = ~0; else power_off_mask = (unsigned int)~ADAU1977_BLOCK_POWER_SAI_LDO_EN; ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_BLOCK_POWER_SAI, power_off_mask, 0x00); if (ret) goto err_poweroff; ret = adau1977_power_disable(adau1977); if (ret) return ret; return snd_soc_register_codec(dev, &adau1977_codec_driver, &adau1977_dai, 1); err_poweroff: adau1977_power_disable(adau1977); return ret; }
static int fdp_nci_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct fdp_i2c_phy *phy; struct device *dev = &client->dev; u8 *fw_vsc_cfg; u8 clock_type; u32 clock_freq; int r = 0; dev_dbg(dev, "%s\n", __func__); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { nfc_err(dev, "No I2C_FUNC_I2C support\n"); return -ENODEV; } /* Checking if we have an irq */ if (client->irq <= 0) { nfc_err(dev, "IRQ not present\n"); return -ENODEV; } phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy), GFP_KERNEL); if (!phy) return -ENOMEM; phy->i2c_dev = client; phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD; i2c_set_clientdata(client, phy); r = request_threaded_irq(client->irq, NULL, fdp_nci_i2c_irq_thread_fn, IRQF_TRIGGER_RISING | IRQF_ONESHOT, FDP_I2C_DRIVER_NAME, phy); if (r < 0) { nfc_err(&client->dev, "Unable to register IRQ handler\n"); return r; } /* Requesting the power gpio */ phy->power_gpio = devm_gpiod_get(dev, FDP_DP_POWER_GPIO_NAME, GPIOD_OUT_LOW); if (IS_ERR(phy->power_gpio)) { nfc_err(dev, "Power GPIO request failed\n"); return PTR_ERR(phy->power_gpio); } /* read device properties to get the clock and production settings */ fdp_nci_i2c_read_device_properties(dev, &clock_type, &clock_freq, &fw_vsc_cfg); /* Call the NFC specific probe function */ r = fdp_nci_probe(phy, &i2c_phy_ops, &phy->ndev, FDP_FRAME_HEADROOM, FDP_FRAME_TAILROOM, clock_type, clock_freq, fw_vsc_cfg); if (r < 0) { nfc_err(dev, "NCI probing error\n"); return r; } dev_dbg(dev, "I2C driver loaded\n"); return 0; }
/** * pimhyp3_get_gpio_config - Get GPIO config from ACPI/DT * * @ts: pimhyp3_ts_data pointer */ static int pimhyp3_get_gpio_config(struct pimhyp3_ts_data *ts) { int error; struct device *dev; struct gpio_desc *gpiod; u32 sizeX, sizeY, refreshRate; if (!ts->client) return -EINVAL; dev = &ts->client->dev; /* Get the interrupt GPIO pin description */ gpiod = devm_gpiod_get(dev, PIMHYP3_GPIO_INT_NAME, GPIOD_IN); if (IS_ERR(gpiod)) { error = PTR_ERR(gpiod); if (error != -EPROBE_DEFER) dev_dbg(dev, "Failed to get %s GPIO: %d\n", PIMHYP3_GPIO_INT_NAME, error); return error; } /* Ensure the correct direction is set because this pin is also used to * program the LCD controller */ ts->gpiod_int = gpiod; gpiod_direction_input(ts->gpiod_int); /* Get the MOSI GPIO pin description */ gpiod = devm_gpiod_get(dev, PIMHYP3_GPIO_MOSI_NAME, GPIOD_OUT_LOW); if (IS_ERR(gpiod)) { error = PTR_ERR(gpiod); if (error != -EPROBE_DEFER) dev_dbg(dev, "Failed to get %s GPIO: %d\n", PIMHYP3_GPIO_MOSI_NAME, error); return error; } ts->gpiod_mosi = gpiod; /* Get the CS GPIO pin description */ gpiod = devm_gpiod_get(dev, PIMHYP3_GPIO_CS_NAME, GPIOD_OUT_HIGH); if (IS_ERR(gpiod)) { error = PTR_ERR(gpiod); if (error != -EPROBE_DEFER) dev_dbg(dev, "Failed to get %s GPIO: %d\n", PIMHYP3_GPIO_CS_NAME, error); return error; } ts->gpiod_cs = gpiod; ts->id = 0x1001; ts->version=0x0101; ts->last_numTouches=0; ts->max_touch_num=2; ts->abs_x_max = PIMHYP3_MAX_WIDTH; ts->abs_y_max = PIMHYP3_MAX_HEIGHT; ts->use_poll = false; ts->int_trigger_type = PIMHYP3_INT_TRIGGER; // Read DT configuration parameters ts->X2Y = device_property_read_bool(&ts->client->dev, "touchscreen-x2y"); dev_dbg(&ts->client->dev, "touchscreen-x2y %u", ts->X2Y); ts->use_poll = device_property_read_bool(&ts->client->dev, "touchscreen-poll"); dev_dbg(&ts->client->dev, "touchscreen-poll %u", ts->use_poll); if(device_property_read_u32(&ts->client->dev, "touchscreen-refresh-rate", &refreshRate)) { dev_dbg(&ts->client->dev, "touchscreen-refresh-rate not found"); ts->requestedRefreshRate = 17; } else { dev_dbg(&ts->client->dev, "touchscreen-refresh-rate found %u", refreshRate); ts->requestedRefreshRate = (u8)refreshRate; } if(device_property_read_u32(&ts->client->dev, "touchscreen-size-x", &sizeX)) { dev_dbg(&ts->client->dev, "touchscreen-size-x not found. Using default of %u",ts->abs_x_max); } else { ts->abs_x_max = (u16)sizeX; dev_dbg(&ts->client->dev, "touchscreen-size-x found %u", ts->abs_x_max); } if(device_property_read_u32(&ts->client->dev, "touchscreen-size-y", &sizeY)) { dev_dbg(&ts->client->dev, "touchscreen-size-y not found. Using default of %u",ts->abs_y_max); } else { ts->abs_y_max = (u16)sizeY; dev_dbg(&ts->client->dev, "touchscreen-size-y found %u", ts->abs_y_max); } dev_dbg(&ts->client->dev, "requested size (%u, %u)", ts->abs_x_max, ts->abs_y_max); ts->swapped_x_y = device_property_read_bool(&ts->client->dev, "touchscreen-swapped-x-y"); dev_dbg(&ts->client->dev, "touchscreen-swapped-x-y %u", ts->swapped_x_y); ts->inverted_x = device_property_read_bool(&ts->client->dev, "touchscreen-inverted-x"); dev_dbg(&ts->client->dev, "touchscreen-inverted-x %u", ts->inverted_x); ts->inverted_y = device_property_read_bool(&ts->client->dev, "touchscreen-inverted-y"); dev_dbg(&ts->client->dev, "touchscreen-inverted-y %u", ts->inverted_y); return 0; }
static int hx711_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct hx711_data *hx711_data; struct iio_dev *indio_dev; int ret; int i; indio_dev = devm_iio_device_alloc(dev, sizeof(struct hx711_data)); if (!indio_dev) { dev_err(dev, "failed to allocate IIO device\n"); return -ENOMEM; } hx711_data = iio_priv(indio_dev); hx711_data->dev = dev; mutex_init(&hx711_data->lock); /* * PD_SCK stands for power down and serial clock input of HX711 * in the driver it is an output */ hx711_data->gpiod_pd_sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW); if (IS_ERR(hx711_data->gpiod_pd_sck)) { dev_err(dev, "failed to get sck-gpiod: err=%ld\n", PTR_ERR(hx711_data->gpiod_pd_sck)); return PTR_ERR(hx711_data->gpiod_pd_sck); } /* * DOUT stands for serial data output of HX711 * for the driver it is an input */ hx711_data->gpiod_dout = devm_gpiod_get(dev, "dout", GPIOD_IN); if (IS_ERR(hx711_data->gpiod_dout)) { dev_err(dev, "failed to get dout-gpiod: err=%ld\n", PTR_ERR(hx711_data->gpiod_dout)); return PTR_ERR(hx711_data->gpiod_dout); } hx711_data->reg_avdd = devm_regulator_get(dev, "avdd"); if (IS_ERR(hx711_data->reg_avdd)) return PTR_ERR(hx711_data->reg_avdd); ret = regulator_enable(hx711_data->reg_avdd); if (ret < 0) return ret; /* * with * full scale differential input range: AVDD / GAIN * full scale output data: 2^24 * we can say: * AVDD / GAIN = 2^24 * therefore: * 1 LSB = AVDD / GAIN / 2^24 * AVDD is in uV, but we need 10^-9 mV * approximately to fit into a 32 bit number: * 1 LSB = (AVDD * 100) / GAIN / 1678 [10^-9 mV] */ ret = regulator_get_voltage(hx711_data->reg_avdd); if (ret < 0) { regulator_disable(hx711_data->reg_avdd); return ret; } /* we need 10^-9 mV */ ret *= 100; for (i = 0; i < HX711_GAIN_MAX; i++) hx711_gain_to_scale[i].scale = ret / hx711_gain_to_scale[i].gain / 1678; hx711_data->gain_set = 128; hx711_data->gain_chan_a = 128; platform_set_drvdata(pdev, indio_dev); indio_dev->name = "hx711"; indio_dev->dev.parent = &pdev->dev; indio_dev->info = &hx711_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = hx711_chan_spec; indio_dev->num_channels = ARRAY_SIZE(hx711_chan_spec); ret = iio_device_register(indio_dev); if (ret < 0) { dev_err(dev, "Couldn't register the device\n"); regulator_disable(hx711_data->reg_avdd); } return ret; }
static int s6e8aa0_probe(struct mipi_dsi_device *dsi) { struct device *dev = &dsi->dev; struct s6e8aa0 *ctx; int ret; ctx = devm_kzalloc(dev, sizeof(struct s6e8aa0), GFP_KERNEL); if (!ctx) return -ENOMEM; mipi_dsi_set_drvdata(dsi, ctx); ctx->dev = dev; dsi->lanes = 4; dsi->format = MIPI_DSI_FMT_RGB888; dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_HFP | MIPI_DSI_MODE_VIDEO_HBP | MIPI_DSI_MODE_VIDEO_HSA | MIPI_DSI_MODE_EOT_PACKET | MIPI_DSI_MODE_VSYNC_FLUSH | MIPI_DSI_MODE_VIDEO_AUTO_VERT; ret = s6e8aa0_parse_dt(ctx); if (ret < 0) return ret; ctx->supplies[0].supply = "vdd3"; ctx->supplies[1].supply = "vci"; ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies), ctx->supplies); if (ret < 0) { dev_err(dev, "failed to get regulators: %d\n", ret); return ret; } ctx->reset_gpio = devm_gpiod_get(dev, "reset"); if (IS_ERR(ctx->reset_gpio)) { dev_err(dev, "cannot get reset-gpios %ld\n", PTR_ERR(ctx->reset_gpio)); return PTR_ERR(ctx->reset_gpio); } ret = gpiod_direction_output(ctx->reset_gpio, 1); if (ret < 0) { dev_err(dev, "cannot configure reset-gpios %d\n", ret); return ret; } ctx->brightness = GAMMA_LEVEL_NUM - 1; drm_panel_init(&ctx->panel); ctx->panel.dev = dev; ctx->panel.funcs = &s6e8aa0_drm_funcs; ret = drm_panel_add(&ctx->panel); if (ret < 0) return ret; ret = mipi_dsi_attach(dsi); if (ret < 0) drm_panel_remove(&ctx->panel); return ret; }
static int cs35l32_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { struct cs35l32_private *cs35l32; struct cs35l32_platform_data *pdata = dev_get_platdata(&i2c_client->dev); int ret, i; unsigned int devid = 0; unsigned int reg; cs35l32 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs35l32_private), GFP_KERNEL); if (!cs35l32) { dev_err(&i2c_client->dev, "could not allocate codec\n"); return -ENOMEM; } i2c_set_clientdata(i2c_client, cs35l32); cs35l32->regmap = devm_regmap_init_i2c(i2c_client, &cs35l32_regmap); if (IS_ERR(cs35l32->regmap)) { ret = PTR_ERR(cs35l32->regmap); dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); return ret; } if (pdata) { cs35l32->pdata = *pdata; } else { pdata = devm_kzalloc(&i2c_client->dev, sizeof(struct cs35l32_platform_data), GFP_KERNEL); if (!pdata) { dev_err(&i2c_client->dev, "could not allocate pdata\n"); return -ENOMEM; } if (i2c_client->dev.of_node) { ret = cs35l32_handle_of_data(i2c_client, &cs35l32->pdata); if (ret != 0) return ret; } } for (i = 0; i < ARRAY_SIZE(cs35l32->supplies); i++) cs35l32->supplies[i].supply = cs35l32_supply_names[i]; ret = devm_regulator_bulk_get(&i2c_client->dev, ARRAY_SIZE(cs35l32->supplies), cs35l32->supplies); if (ret != 0) { dev_err(&i2c_client->dev, "Failed to request supplies: %d\n", ret); return ret; } ret = regulator_bulk_enable(ARRAY_SIZE(cs35l32->supplies), cs35l32->supplies); if (ret != 0) { dev_err(&i2c_client->dev, "Failed to enable supplies: %d\n", ret); return ret; } /* Reset the Device */ cs35l32->reset_gpio = devm_gpiod_get(&i2c_client->dev, "reset-gpios"); if (IS_ERR(cs35l32->reset_gpio)) { ret = PTR_ERR(cs35l32->reset_gpio); if (ret != -ENOENT && ret != -ENOSYS) return ret; cs35l32->reset_gpio = NULL; } else { ret = gpiod_direction_output(cs35l32->reset_gpio, 0); if (ret) return ret; gpiod_set_value_cansleep(cs35l32->reset_gpio, 1); } /* initialize codec */ ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_AB, ®); devid = (reg & 0xFF) << 12; ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_CD, ®); devid |= (reg & 0xFF) << 4; ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_E, ®); devid |= (reg & 0xF0) >> 4; if (devid != CS35L32_CHIP_ID) { ret = -ENODEV; dev_err(&i2c_client->dev, "CS35L32 Device ID (%X). Expected %X\n", devid, CS35L32_CHIP_ID); return ret; } ret = regmap_read(cs35l32->regmap, CS35L32_REV_ID, ®); if (ret < 0) { dev_err(&i2c_client->dev, "Get Revision ID failed\n"); return ret; } ret = regmap_register_patch(cs35l32->regmap, cs35l32_monitor_patch, ARRAY_SIZE(cs35l32_monitor_patch)); if (ret < 0) { dev_err(&i2c_client->dev, "Failed to apply errata patch\n"); return ret; } dev_info(&i2c_client->dev, "Cirrus Logic CS35L32, Revision: %02X\n", reg & 0xFF); /* Setup VBOOST Management */ if (cs35l32->pdata.boost_mng) regmap_update_bits(cs35l32->regmap, CS35L32_AUDIO_LED_MNGR, CS35L32_BOOST_MASK, cs35l32->pdata.boost_mng); /* Setup ADSP Format Config */ if (cs35l32->pdata.sdout_share) regmap_update_bits(cs35l32->regmap, CS35L32_ADSP_CTL, CS35L32_ADSP_SHARE_MASK, cs35l32->pdata.sdout_share << 3); /* Setup ADSP Data Configuration */ if (cs35l32->pdata.sdout_datacfg) regmap_update_bits(cs35l32->regmap, CS35L32_ADSP_CTL, CS35L32_ADSP_DATACFG_MASK, cs35l32->pdata.sdout_datacfg << 4); /* Setup Low Battery Recovery */ if (cs35l32->pdata.batt_recov) regmap_update_bits(cs35l32->regmap, CS35L32_BATT_THRESHOLD, CS35L32_BATT_REC_MASK, cs35l32->pdata.batt_recov << 1); /* Setup Low Battery Threshold */ if (cs35l32->pdata.batt_thresh) regmap_update_bits(cs35l32->regmap, CS35L32_BATT_THRESHOLD, CS35L32_BATT_THRESH_MASK, cs35l32->pdata.batt_thresh << 4); /* Power down the AMP */ regmap_update_bits(cs35l32->regmap, CS35L32_PWRCTL1, CS35L32_PDN_AMP, CS35L32_PDN_AMP); /* Clear MCLK Error Bit since we don't have the clock yet */ ret = regmap_read(cs35l32->regmap, CS35L32_INT_STATUS_1, ®); ret = snd_soc_register_codec(&i2c_client->dev, &soc_codec_dev_cs35l32, cs35l32_dai, ARRAY_SIZE(cs35l32_dai)); if (ret < 0) goto err_disable; return 0; err_disable: regulator_bulk_disable(ARRAY_SIZE(cs35l32->supplies), cs35l32->supplies); return ret; }
static int rx51_soc_probe(struct platform_device *pdev) { struct rx51_audio_pdata *pdata; struct device_node *np = pdev->dev.of_node; struct snd_soc_card *card = &rx51_sound_card; int err; if (!machine_is_nokia_rx51() && !of_machine_is_compatible("nokia,omap3-n900")) return -ENODEV; card->dev = &pdev->dev; if (np) { struct device_node *dai_node; dai_node = of_parse_phandle(np, "nokia,cpu-dai", 0); if (!dai_node) { dev_err(&pdev->dev, "McBSP node is not provided\n"); return -EINVAL; } rx51_dai[0].cpu_dai_name = NULL; rx51_dai[0].platform_name = NULL; rx51_dai[0].cpu_of_node = dai_node; rx51_dai[0].platform_of_node = dai_node; dai_node = of_parse_phandle(np, "nokia,audio-codec", 0); if (!dai_node) { dev_err(&pdev->dev, "Codec node is not provided\n"); return -EINVAL; } rx51_dai[0].codec_name = NULL; rx51_dai[0].codec_of_node = dai_node; dai_node = of_parse_phandle(np, "nokia,audio-codec", 1); if (!dai_node) { dev_err(&pdev->dev, "Auxiliary Codec node is not provided\n"); return -EINVAL; } rx51_aux_dev[0].codec_name = NULL; rx51_aux_dev[0].codec_of_node = dai_node; rx51_codec_conf[0].dev_name = NULL; rx51_codec_conf[0].of_node = dai_node; dai_node = of_parse_phandle(np, "nokia,headphone-amplifier", 0); if (!dai_node) { dev_err(&pdev->dev, "Headphone amplifier node is not provided\n"); return -EINVAL; } /* TODO: tpa6130a2a driver supports only a single instance, so * this driver ignores the headphone-amplifier node for now. * It's already mandatory in the DT binding to be future proof. */ } pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (pdata == NULL) { dev_err(card->dev, "failed to create private data\n"); return -ENOMEM; } snd_soc_card_set_drvdata(card, pdata); pdata->tvout_selection_gpio = devm_gpiod_get(card->dev, "tvout-selection", GPIOD_OUT_LOW); if (IS_ERR(pdata->tvout_selection_gpio)) { dev_err(card->dev, "could not get tvout selection gpio\n"); return PTR_ERR(pdata->tvout_selection_gpio); } pdata->jack_detection_gpio = devm_gpiod_get(card->dev, "jack-detection", GPIOD_ASIS); if (IS_ERR(pdata->jack_detection_gpio)) { dev_err(card->dev, "could not get jack detection gpio\n"); return PTR_ERR(pdata->jack_detection_gpio); } pdata->eci_sw_gpio = devm_gpiod_get(card->dev, "eci-switch", GPIOD_OUT_HIGH); if (IS_ERR(pdata->eci_sw_gpio)) { dev_err(card->dev, "could not get eci switch gpio\n"); return PTR_ERR(pdata->eci_sw_gpio); } pdata->speaker_amp_gpio = devm_gpiod_get(card->dev, "speaker-amplifier", GPIOD_OUT_LOW); if (IS_ERR(pdata->speaker_amp_gpio)) { dev_err(card->dev, "could not get speaker enable gpio\n"); return PTR_ERR(pdata->speaker_amp_gpio); } err = devm_snd_soc_register_card(card->dev, card); if (err) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", err); return err; } return 0; }
static int s6e3ha2_probe(struct mipi_dsi_device *dsi) { struct device *dev = &dsi->dev; struct s6e3ha2 *ctx; int ret; ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; mipi_dsi_set_drvdata(dsi, ctx); ctx->dev = dev; ctx->desc = of_device_get_match_data(dev); dsi->lanes = 4; dsi->format = MIPI_DSI_FMT_RGB888; dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS; ctx->supplies[0].supply = "vdd3"; ctx->supplies[1].supply = "vci"; ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies), ctx->supplies); if (ret < 0) { dev_err(dev, "failed to get regulators: %d\n", ret); return ret; } ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(ctx->reset_gpio)) { dev_err(dev, "cannot get reset-gpios %ld\n", PTR_ERR(ctx->reset_gpio)); return PTR_ERR(ctx->reset_gpio); } ctx->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH); if (IS_ERR(ctx->enable_gpio)) { dev_err(dev, "cannot get enable-gpios %ld\n", PTR_ERR(ctx->enable_gpio)); return PTR_ERR(ctx->enable_gpio); } ctx->bl_dev = backlight_device_register("s6e3ha2", dev, ctx, &s6e3ha2_bl_ops, NULL); if (IS_ERR(ctx->bl_dev)) { dev_err(dev, "failed to register backlight device\n"); return PTR_ERR(ctx->bl_dev); } ctx->bl_dev->props.max_brightness = S6E3HA2_MAX_BRIGHTNESS; ctx->bl_dev->props.brightness = S6E3HA2_DEFAULT_BRIGHTNESS; ctx->bl_dev->props.power = FB_BLANK_POWERDOWN; drm_panel_init(&ctx->panel); ctx->panel.dev = dev; ctx->panel.funcs = &s6e3ha2_drm_funcs; ret = drm_panel_add(&ctx->panel); if (ret < 0) goto unregister_backlight; ret = mipi_dsi_attach(dsi); if (ret < 0) goto remove_panel; return ret; remove_panel: drm_panel_remove(&ctx->panel); unregister_backlight: backlight_device_unregister(ctx->bl_dev); return ret; }
static int arche_platform_probe(struct platform_device *pdev) { struct arche_platform_drvdata *arche_pdata; struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; int ret; unsigned int flags; arche_pdata = devm_kzalloc(&pdev->dev, sizeof(*arche_pdata), GFP_KERNEL); if (!arche_pdata) return -ENOMEM; /* setup svc reset gpio */ arche_pdata->is_reset_act_hi = of_property_read_bool(np, "svc,reset-active-high"); if (arche_pdata->is_reset_act_hi) flags = GPIOD_OUT_HIGH; else flags = GPIOD_OUT_LOW; arche_pdata->svc_reset = devm_gpiod_get(dev, "svc,reset", flags); if (IS_ERR(arche_pdata->svc_reset)) { ret = PTR_ERR(arche_pdata->svc_reset); dev_err(dev, "failed to request svc-reset GPIO: %d\n", ret); return ret; } arche_platform_set_state(arche_pdata, ARCHE_PLATFORM_STATE_OFF); arche_pdata->svc_sysboot = devm_gpiod_get(dev, "svc,sysboot", GPIOD_OUT_LOW); if (IS_ERR(arche_pdata->svc_sysboot)) { ret = PTR_ERR(arche_pdata->svc_sysboot); dev_err(dev, "failed to request sysboot0 GPIO: %d\n", ret); return ret; } /* setup the clock request gpio first */ arche_pdata->svc_refclk_req = devm_gpiod_get(dev, "svc,refclk-req", GPIOD_IN); if (IS_ERR(arche_pdata->svc_refclk_req)) { ret = PTR_ERR(arche_pdata->svc_refclk_req); dev_err(dev, "failed to request svc-clk-req GPIO: %d\n", ret); return ret; } /* setup refclk2 to follow the pin */ arche_pdata->svc_ref_clk = devm_clk_get(dev, "svc_ref_clk"); if (IS_ERR(arche_pdata->svc_ref_clk)) { ret = PTR_ERR(arche_pdata->svc_ref_clk); dev_err(dev, "failed to get svc_ref_clk: %d\n", ret); return ret; } platform_set_drvdata(pdev, arche_pdata); arche_pdata->num_apbs = of_get_child_count(np); dev_dbg(dev, "Number of APB's available - %d\n", arche_pdata->num_apbs); arche_pdata->wake_detect = devm_gpiod_get(dev, "svc,wake-detect", GPIOD_IN); if (IS_ERR(arche_pdata->wake_detect)) { ret = PTR_ERR(arche_pdata->wake_detect); dev_err(dev, "Failed requesting wake_detect GPIO: %d\n", ret); return ret; } arche_platform_set_wake_detect_state(arche_pdata, WD_STATE_IDLE); arche_pdata->dev = &pdev->dev; spin_lock_init(&arche_pdata->wake_lock); mutex_init(&arche_pdata->platform_state_mutex); arche_pdata->wake_detect_irq = gpiod_to_irq(arche_pdata->wake_detect); ret = devm_request_threaded_irq(dev, arche_pdata->wake_detect_irq, arche_platform_wd_irq, arche_platform_wd_irq_thread, IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT, dev_name(dev), arche_pdata); if (ret) { dev_err(dev, "failed to request wake detect IRQ %d\n", ret); return ret; } disable_irq(arche_pdata->wake_detect_irq); ret = device_create_file(dev, &dev_attr_state); if (ret) { dev_err(dev, "failed to create state file in sysfs\n"); return ret; } ret = of_platform_populate(np, NULL, NULL, dev); if (ret) { dev_err(dev, "failed to populate child nodes %d\n", ret); goto err_device_remove; } arche_pdata->pm_notifier.notifier_call = arche_platform_pm_notifier; ret = register_pm_notifier(&arche_pdata->pm_notifier); if (ret) { dev_err(dev, "failed to register pm notifier %d\n", ret); goto err_device_remove; } /* Explicitly power off if requested */ if (!of_property_read_bool(pdev->dev.of_node, "arche,init-off")) { mutex_lock(&arche_pdata->platform_state_mutex); ret = arche_platform_coldboot_seq(arche_pdata); if (ret) { dev_err(dev, "Failed to cold boot svc %d\n", ret); goto err_coldboot; } arche_platform_wd_irq_en(arche_pdata); mutex_unlock(&arche_pdata->platform_state_mutex); } dev_info(dev, "Device registered successfully\n"); return 0; err_coldboot: mutex_unlock(&arche_pdata->platform_state_mutex); err_device_remove: device_remove_file(&pdev->dev, &dev_attr_state); return ret; }