static int inv_mpu_process_acpi_config(struct i2c_client *client, unsigned short *primary_addr, unsigned short *secondary_addr) { const struct acpi_device_id *id; struct acpi_device *adev; u32 i2c_addr = 0; LIST_HEAD(resources); int ret; id = acpi_match_device(client->dev.driver->acpi_match_table, &client->dev); if (!id) return -ENODEV; adev = ACPI_COMPANION(&client->dev); if (!adev) return -ENODEV; ret = acpi_dev_get_resources(adev, &resources, acpi_i2c_check_resource, &i2c_addr); if (ret < 0) return ret; acpi_dev_free_resource_list(&resources); *primary_addr = i2c_addr & 0x0000ffff; *secondary_addr = (i2c_addr & 0xffff0000) >> 16; return 0; }
static int dw_i2c_acpi_configure(struct platform_device *pdev) { struct dw_i2c_dev *dev = platform_get_drvdata(pdev); const struct acpi_device_id *id; dev->adapter.nr = -1; dev->tx_fifo_depth = 32; dev->rx_fifo_depth = 32; /* * Try to get SDA hold time and *CNT values from an ACPI method if * it exists for both supported speed modes. */ dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev->ss_lcnt, NULL); dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, &dev->sda_hold_time); /* * Provide a way for Designware I2C host controllers that are not * based on Intel LPSS to specify their input clock frequency via * id->driver_data. */ id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); if (id && id->driver_data) clk_register_fixed_rate(&pdev->dev, dev_name(&pdev->dev), NULL, CLK_IS_ROOT, id->driver_data); return 0; }
static int pwm_lpss_probe_platform(struct platform_device *pdev) { const struct pwm_lpss_boardinfo *info; const struct acpi_device_id *id; struct pwm_lpss_chip *lpwm; struct resource *r; id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); if (!id) return -ENODEV; info = (const struct pwm_lpss_boardinfo *)id->driver_data; r = platform_get_resource(pdev, IORESOURCE_MEM, 0); lpwm = pwm_lpss_probe(&pdev->dev, r, info); if (IS_ERR(lpwm)) return PTR_ERR(lpwm); platform_set_drvdata(pdev, lpwm); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; }
static int dw8250_probe_acpi(struct uart_8250_port *up) { const struct acpi_device_id *id; struct uart_port *p = &up->port; id = acpi_match_device(p->dev->driver->acpi_match_table, p->dev); if (!id) return -ENODEV; p->iotype = UPIO_MEM32; p->serial_in = dw8250_serial_in32; p->serial_out = dw8250_serial_out32; p->regshift = 2; if (!p->uartclk) p->uartclk = (unsigned int)id->driver_data; up->dma = devm_kzalloc(p->dev, sizeof(*up->dma), GFP_KERNEL); if (!up->dma) return -ENOMEM; up->dma->rxconf.src_maxburst = p->fifosize / 4; up->dma->txconf.dst_maxburst = p->fifosize / 4; return 0; }
static int inv_mpu_probe(struct spi_device *spi) { struct regmap *regmap; const struct spi_device_id *spi_id; const struct acpi_device_id *acpi_id; const char *name = NULL; enum inv_devices chip_type; if ((spi_id = spi_get_device_id(spi))) { chip_type = (enum inv_devices)spi_id->driver_data; name = spi_id->name; } else if ((acpi_id = acpi_match_device(spi->dev.driver->acpi_match_table, &spi->dev))) { chip_type = (enum inv_devices)acpi_id->driver_data; } else { return -ENODEV; } regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config); if (IS_ERR(regmap)) { dev_err(&spi->dev, "Failed to register spi regmap %d\n", (int)PTR_ERR(regmap)); return PTR_ERR(regmap); } return inv_mpu_core_probe(regmap, spi->irq, name, inv_mpu_i2c_disable, chip_type); }
static void dw_i2c_acpi_unconfigure(struct platform_device *pdev) { struct dw_i2c_dev *dev = platform_get_drvdata(pdev); const struct acpi_device_id *id; id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); if (id && id->driver_data) clk_unregister(dev->clk); }
static int intel_soc_pmic_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i2c_id) { struct device *dev = &i2c->dev; const struct acpi_device_id *id; struct intel_soc_pmic_config *config; struct intel_soc_pmic *pmic; int ret; id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!id || !id->driver_data) return -ENODEV; config = (struct intel_soc_pmic_config *)id->driver_data; pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL); if (!pmic) return -ENOMEM; dev_set_drvdata(dev, pmic); pmic->regmap = devm_regmap_init_i2c(i2c, config->regmap_config); if (IS_ERR(pmic->regmap)) return PTR_ERR(pmic->regmap); pmic->irq = i2c->irq; ret = regmap_add_irq_chip(pmic->regmap, pmic->irq, config->irq_flags | IRQF_ONESHOT, 0, config->irq_chip, &pmic->irq_chip_data); if (ret) return ret; ret = enable_irq_wake(pmic->irq); if (ret) dev_warn(dev, "Can't enable IRQ as wake source: %d\n", ret); /* Add lookup table binding for Panel Control to the GPIO Chip */ gpiod_add_lookup_table(&panel_gpio_table); /* Add lookup table for crc-pwm */ pwm_add_table(crc_pwm_lookup, ARRAY_SIZE(crc_pwm_lookup)); ret = mfd_add_devices(dev, -1, config->cell_dev, config->n_cell_devs, NULL, 0, regmap_irq_get_domain(pmic->irq_chip_data)); if (ret) goto err_del_irq_chip; return 0; err_del_irq_chip: regmap_del_irq_chip(pmic->irq, pmic->irq_chip_data); return ret; }
static enum da280_chipset da280_match_acpi_device(struct device *dev) { const struct acpi_device_id *id; id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!id) return -EINVAL; return (enum da280_chipset) id->driver_data; }
static int spt_pinctrl_probe(struct platform_device *pdev) { const struct intel_pinctrl_soc_data *soc_data; const struct acpi_device_id *id; id = acpi_match_device(spt_pinctrl_acpi_match, &pdev->dev); if (!id || !id->driver_data) return -ENODEV; soc_data = (const struct intel_pinctrl_soc_data *)id->driver_data; return intel_pinctrl_probe(pdev, soc_data); }
static const char *inv_mpu_match_acpi_device(struct device *dev, int *chip_id) { const struct acpi_device_id *id; id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!id) return NULL; *chip_id = (int)id->driver_data; return dev_name(dev); }
static char *ak8975_match_acpi_device(struct device *dev, enum asahi_compass_chipset *chipset) { const struct acpi_device_id *id; id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!id) return NULL; *chipset = (int)id->driver_data; return (char *)dev_name(dev); }
static int rfkill_gpio_acpi_probe(struct device *dev, struct rfkill_gpio_data *rfkill) { const struct acpi_device_id *id; id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!id) return -ENODEV; rfkill->name = dev_name(dev); rfkill->type = (unsigned)id->driver_data; return acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_rfkill_default_gpios); }
static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) { if (p->dev->of_node) { struct device_node *np = p->dev->of_node; int id; /* get index of serial line, if found in DT aliases */ id = of_alias_get_id(np, "serial"); if (id >= 0) p->line = id; #ifdef CONFIG_64BIT if (of_device_is_compatible(np, "cavium,octeon-3860-uart")) { p->serial_in = dw8250_serial_inq; p->serial_out = dw8250_serial_outq; p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; p->type = PORT_OCTEON; data->usr_reg = 0x27; data->skip_autocfg = true; } #endif if (of_device_is_big_endian(p->dev->of_node)) { p->iotype = UPIO_MEM32BE; p->serial_in = dw8250_serial_in32be; p->serial_out = dw8250_serial_out32be; } } else if (has_acpi_companion(p->dev)) { const struct acpi_device_id *id; id = acpi_match_device(p->dev->driver->acpi_match_table, p->dev); if (id && !strcmp(id->id, "APMC0D08")) { p->iotype = UPIO_MEM32; p->regshift = 2; p->serial_in = dw8250_serial_in32; data->uart_16550_compatible = true; } p->set_termios = dw8250_set_termios; } /* Platforms with iDMA */ if (platform_get_resource_byname(to_platform_device(p->dev), IORESOURCE_MEM, "lpss_priv")) { p->set_termios = dw8250_set_termios; data->dma.rx_param = p->dev->parent; data->dma.tx_param = p->dev->parent; data->dma.fn = dw8250_idma_filter; } }
static int soc_button_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct acpi_device_id *id; struct soc_button_info *button_info; struct soc_button_data *priv; struct platform_device *pd; int i; int error; id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!id) return -ENODEV; button_info = (struct soc_button_info *)id->driver_data; if (gpiod_count(dev, KBUILD_MODNAME) <= 0) { dev_dbg(dev, "no GPIO attached, ignoring...\n"); return -ENODEV; } priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; platform_set_drvdata(pdev, priv); for (i = 0; i < BUTTON_TYPES; i++) { pd = soc_button_device_create(pdev, button_info, i == 0); if (IS_ERR(pd)) { error = PTR_ERR(pd); if (error != -ENODEV) { soc_button_remove(pdev); return error; } continue; } priv->children[i] = pd; } if (!priv->children[0] && !priv->children[1]) return -ENODEV; return 0; }
static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev) { const struct acpi_device_id *acpi_id; const struct of_device_id *of_id; if (dev->of_node) { of_id = of_match_device(axp20x_of_match, dev); if (!of_id) { dev_err(dev, "Unable to match OF ID\n"); return -ENODEV; } axp20x->variant = (long) of_id->data; } else { acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!acpi_id || !acpi_id->driver_data) { dev_err(dev, "Unable to match ACPI ID and data\n"); return -ENODEV; } axp20x->variant = (long) acpi_id->driver_data; } switch (axp20x->variant) { case AXP202_ID: case AXP209_ID: axp20x->nr_cells = ARRAY_SIZE(axp20x_cells); axp20x->cells = axp20x_cells; axp20x->regmap_cfg = &axp20x_regmap_config; axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip; break; case AXP288_ID: axp20x->cells = axp288_cells; axp20x->nr_cells = ARRAY_SIZE(axp288_cells); axp20x->regmap_cfg = &axp288_regmap_config; axp20x->regmap_irq_chip = &axp288_regmap_irq_chip; break; default: dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant); return -EINVAL; } dev_info(dev, "AXP20x variant %s found\n", axp20x_model_names[axp20x->variant]); return 0; }
static int bxt_pinctrl_probe(struct platform_device *pdev) { const struct intel_pinctrl_soc_data *soc_data = NULL; const struct intel_pinctrl_soc_data **soc_table; struct acpi_device *adev; int i; adev = ACPI_COMPANION(&pdev->dev); if (adev) { const struct acpi_device_id *id; id = acpi_match_device(bxt_pinctrl_acpi_match, &pdev->dev); if (!id) return -ENODEV; soc_table = (const struct intel_pinctrl_soc_data **) id->driver_data; for (i = 0; soc_table[i]; i++) { if (!strcmp(adev->pnp.unique_id, soc_table[i]->uid)) { soc_data = soc_table[i]; break; } } } else { const struct platform_device_id *pid; pid = platform_get_device_id(pdev); if (!pid) return -ENODEV; soc_table = (const struct intel_pinctrl_soc_data **) pid->driver_data; soc_data = soc_table[pdev->id]; } if (!soc_data) return -ENODEV; return intel_pinctrl_probe(pdev, soc_data); }
static int intel_lpss_acpi_probe(struct platform_device *pdev) { struct intel_lpss_platform_info *info; const struct acpi_device_id *id; id = acpi_match_device(intel_lpss_acpi_ids, &pdev->dev); if (!id) return -ENODEV; info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); info->irq = platform_get_irq(pdev, 0); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); return intel_lpss_probe(&pdev->dev, info); }
static int silead_ts_set_default_fw_name(struct silead_ts_data *data, const struct i2c_device_id *id) { const struct acpi_device_id *acpi_id; struct device *dev = &data->client->dev; int i; if (ACPI_HANDLE(dev)) { acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!acpi_id) return -ENODEV; snprintf(data->fw_name, sizeof(data->fw_name), "silead/%s.fw", acpi_id->id); for (i = 0; i < strlen(data->fw_name); i++) data->fw_name[i] = tolower(data->fw_name[i]); } else { snprintf(data->fw_name, sizeof(data->fw_name), "silead/%s.fw", id->name); } return 0; }
writel(0, sgmii->base + EMAC_SGMII_PHY_INTERRUPT_MASK); synchronize_irq(sgmii->irq); return 0; } static int emac_sgmii_acpi_match(struct device *dev, void *data) { #ifdef CONFIG_ACPI static const struct acpi_device_id match_table[] = { { .id = "QCOM8071", }, {} }; const struct acpi_device_id *id = acpi_match_device(match_table, dev); emac_sgmii_function *initialize = data; if (id) { acpi_handle handle = ACPI_HANDLE(dev); unsigned long long hrv; acpi_status status; status = acpi_evaluate_integer(handle, "_HRV", NULL, &hrv); if (status) { if (status == AE_NOT_FOUND) /* Older versions of the QDF2432 ACPI tables do * not have an _HRV property. */ hrv = 1; else
static int sst_acpi_probe(struct platform_device *pdev) { const struct acpi_device_id *id; struct device *dev = &pdev->dev; struct sst_acpi_priv *sst_acpi; struct sst_pdata *sst_pdata; struct sst_acpi_mach *mach; struct sst_acpi_desc *desc; struct resource *mmio; int ret = 0; sst_acpi = devm_kzalloc(dev, sizeof(*sst_acpi), GFP_KERNEL); if (sst_acpi == NULL) return -ENOMEM; id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!id) return -ENODEV; desc = (struct sst_acpi_desc *)id->driver_data; mach = sst_acpi_find_machine(desc->machines); if (mach == NULL) { dev_err(dev, "No matching ASoC machine driver found\n"); return -ENODEV; } sst_pdata = &sst_acpi->sst_pdata; sst_pdata->id = desc->sst_id; sst_acpi->desc = desc; sst_acpi->mach = mach; if (desc->resindex_dma_base >= 0) { sst_pdata->dma_engine = desc->dma_engine; sst_pdata->dma_base = desc->resindex_dma_base; sst_pdata->dma_size = desc->dma_size; } if (desc->irqindex_host_ipc >= 0) sst_pdata->irq = platform_get_irq(pdev, desc->irqindex_host_ipc); if (desc->resindex_lpe_base >= 0) { mmio = platform_get_resource(pdev, IORESOURCE_MEM, desc->resindex_lpe_base); if (mmio) { sst_pdata->lpe_base = mmio->start; sst_pdata->lpe_size = resource_size(mmio); } } if (desc->resindex_pcicfg_base >= 0) { mmio = platform_get_resource(pdev, IORESOURCE_MEM, desc->resindex_pcicfg_base); if (mmio) { sst_pdata->pcicfg_base = mmio->start; sst_pdata->pcicfg_size = resource_size(mmio); } } if (desc->resindex_fw_base >= 0) { mmio = platform_get_resource(pdev, IORESOURCE_MEM, desc->resindex_fw_base); if (mmio) { sst_pdata->fw_base = mmio->start; sst_pdata->fw_size = resource_size(mmio); } } platform_set_drvdata(pdev, sst_acpi); /* register machine driver */ sst_acpi->pdev_mach = platform_device_register_data(dev, mach->drv_name, -1, sst_pdata, sizeof(*sst_pdata)); if (IS_ERR(sst_acpi->pdev_mach)) return PTR_ERR(sst_acpi->pdev_mach); /* continue SST probing after firmware is loaded */ ret = request_firmware_nowait(THIS_MODULE, true, mach->fw_filename, dev, GFP_KERNEL, pdev, sst_acpi_fw_cb); if (ret) platform_device_unregister(sst_acpi->pdev_mach); return ret; }
int axp20x_match_device(struct axp20x_dev *axp20x) { struct device *dev = axp20x->dev; const struct acpi_device_id *acpi_id; const struct of_device_id *of_id; if (dev->of_node) { of_id = of_match_device(dev->driver->of_match_table, dev); if (!of_id) { dev_err(dev, "Unable to match OF ID\n"); return -ENODEV; } axp20x->variant = (long)of_id->data; } else { acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!acpi_id || !acpi_id->driver_data) { dev_err(dev, "Unable to match ACPI ID and data\n"); return -ENODEV; } axp20x->variant = (long)acpi_id->driver_data; } switch (axp20x->variant) { case AXP152_ID: axp20x->nr_cells = ARRAY_SIZE(axp152_cells); axp20x->cells = axp152_cells; axp20x->regmap_cfg = &axp152_regmap_config; axp20x->regmap_irq_chip = &axp152_regmap_irq_chip; break; case AXP202_ID: case AXP209_ID: axp20x->nr_cells = ARRAY_SIZE(axp20x_cells); axp20x->cells = axp20x_cells; axp20x->regmap_cfg = &axp20x_regmap_config; axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip; break; case AXP221_ID: axp20x->nr_cells = ARRAY_SIZE(axp221_cells); axp20x->cells = axp221_cells; axp20x->regmap_cfg = &axp22x_regmap_config; axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip; break; case AXP223_ID: axp20x->nr_cells = ARRAY_SIZE(axp223_cells); axp20x->cells = axp223_cells; axp20x->regmap_cfg = &axp22x_regmap_config; axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip; break; case AXP288_ID: axp20x->cells = axp288_cells; axp20x->nr_cells = ARRAY_SIZE(axp288_cells); axp20x->regmap_cfg = &axp288_regmap_config; axp20x->regmap_irq_chip = &axp288_regmap_irq_chip; axp20x->irq_flags = IRQF_TRIGGER_LOW; break; case AXP803_ID: axp20x->nr_cells = ARRAY_SIZE(axp803_cells); axp20x->cells = axp803_cells; axp20x->regmap_cfg = &axp288_regmap_config; axp20x->regmap_irq_chip = &axp803_regmap_irq_chip; break; case AXP806_ID: axp20x->nr_cells = ARRAY_SIZE(axp806_cells); axp20x->cells = axp806_cells; axp20x->regmap_cfg = &axp806_regmap_config; axp20x->regmap_irq_chip = &axp806_regmap_irq_chip; break; case AXP809_ID: axp20x->nr_cells = ARRAY_SIZE(axp809_cells); axp20x->cells = axp809_cells; axp20x->regmap_cfg = &axp22x_regmap_config; axp20x->regmap_irq_chip = &axp809_regmap_irq_chip; break; case AXP813_ID: axp20x->nr_cells = ARRAY_SIZE(axp813_cells); axp20x->cells = axp813_cells; axp20x->regmap_cfg = &axp288_regmap_config; /* * The IRQ table given in the datasheet is incorrect. * In IRQ enable/status registers 1, there are separate * IRQs for ACIN and VBUS, instead of bits [7:5] being * the same as bits [4:2]. So it shares the same IRQs * as the AXP803, rather than the AXP288. */ axp20x->regmap_irq_chip = &axp803_regmap_irq_chip; break; default: dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant); return -EINVAL; } dev_info(dev, "AXP20x variant %s found\n", axp20x_model_names[axp20x->variant]); return 0; }
static struct dma_chan *dw_dma_of_xlate(struct of_phandle_args *dma_spec, struct of_dma *ofdma) { struct dw_dma *dw = ofdma->of_dma_data; struct dw_dma_slave slave = { .dma_dev = dw->dma.dev, }; dma_cap_mask_t cap; if (dma_spec->args_count != 3) return NULL; slave.src_id = dma_spec->args[0]; slave.dst_id = dma_spec->args[0]; slave.src_master = dma_spec->args[1]; slave.dst_master = dma_spec->args[2]; if (WARN_ON(slave.src_id >= DW_DMA_MAX_NR_REQUESTS || slave.dst_id >= DW_DMA_MAX_NR_REQUESTS || slave.src_master >= dw->nr_masters || slave.dst_master >= dw->nr_masters)) return NULL; dma_cap_zero(cap); dma_cap_set(DMA_SLAVE, cap); /* TODO: there should be a simpler way to do this */ return dma_request_channel(cap, dw_dma_filter, &slave); } #ifdef CONFIG_ACPI static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param) { struct acpi_dma_spec *dma_spec = param; struct dw_dma_slave slave = { .dma_dev = dma_spec->dev, .src_id = dma_spec->slave_id, .dst_id = dma_spec->slave_id, .src_master = 1, .dst_master = 0, }; return dw_dma_filter(chan, &slave); } static void dw_dma_acpi_controller_register(struct dw_dma *dw) { struct device *dev = dw->dma.dev; struct acpi_dma_filter_info *info; int ret; info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info) return; dma_cap_zero(info->dma_cap); dma_cap_set(DMA_SLAVE, info->dma_cap); info->filter_fn = dw_dma_acpi_filter; ret = devm_acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info); if (ret) dev_err(dev, "could not register acpi_dma_controller\n"); } #else /* !CONFIG_ACPI */ static inline void dw_dma_acpi_controller_register(struct dw_dma *dw) {} #endif /* !CONFIG_ACPI */ #ifdef CONFIG_OF static struct dw_dma_platform_data * dw_dma_parse_dt(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct dw_dma_platform_data *pdata; u32 tmp, arr[DW_DMA_MAX_NR_MASTERS]; if (!np) { dev_err(&pdev->dev, "Missing DT data\n"); return NULL; } pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return NULL; if (of_property_read_u32(np, "dma-channels", &pdata->nr_channels)) return NULL; if (of_property_read_bool(np, "is_private")) pdata->is_private = true; if (!of_property_read_u32(np, "chan_allocation_order", &tmp)) pdata->chan_allocation_order = (unsigned char)tmp; if (!of_property_read_u32(np, "chan_priority", &tmp)) pdata->chan_priority = tmp; if (!of_property_read_u32(np, "block_size", &tmp)) pdata->block_size = tmp; if (!of_property_read_u32(np, "dma-masters", &tmp)) { if (tmp > DW_DMA_MAX_NR_MASTERS) return NULL; pdata->nr_masters = tmp; } if (!of_property_read_u32_array(np, "data_width", arr, pdata->nr_masters)) for (tmp = 0; tmp < pdata->nr_masters; tmp++) pdata->data_width[tmp] = arr[tmp]; return pdata; } #else static inline struct dw_dma_platform_data * dw_dma_parse_dt(struct platform_device *pdev) { return NULL; } #endif static int dw_probe(struct platform_device *pdev) { struct dw_dma_chip *chip; struct device *dev = &pdev->dev; struct resource *mem; const struct acpi_device_id *id; struct dw_dma_platform_data *pdata; int err; chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; chip->irq = platform_get_irq(pdev, 0); if (chip->irq < 0) return chip->irq; mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); chip->regs = devm_ioremap_resource(dev, mem); if (IS_ERR(chip->regs)) return PTR_ERR(chip->regs); err = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); if (err) return err; pdata = dev_get_platdata(dev); if (!pdata) pdata = dw_dma_parse_dt(pdev); if (!pdata && has_acpi_companion(dev)) { id = acpi_match_device(dev->driver->acpi_match_table, dev); if (id) pdata = (struct dw_dma_platform_data *)id->driver_data; } chip->dev = dev; chip->clk = devm_clk_get(chip->dev, "hclk"); if (IS_ERR(chip->clk)) return PTR_ERR(chip->clk); err = clk_prepare_enable(chip->clk); if (err) return err; pm_runtime_enable(&pdev->dev); err = dw_dma_probe(chip, pdata); if (err) goto err_dw_dma_probe; platform_set_drvdata(pdev, chip); if (pdev->dev.of_node) { err = of_dma_controller_register(pdev->dev.of_node, dw_dma_of_xlate, chip->dw); if (err) dev_err(&pdev->dev, "could not register of_dma_controller\n"); } if (ACPI_HANDLE(&pdev->dev)) dw_dma_acpi_controller_register(chip->dw); return 0; err_dw_dma_probe: pm_runtime_disable(&pdev->dev); clk_disable_unprepare(chip->clk); return err; } static int dw_remove(struct platform_device *pdev) { struct dw_dma_chip *chip = platform_get_drvdata(pdev); if (pdev->dev.of_node) of_dma_controller_free(pdev->dev.of_node); dw_dma_remove(chip); pm_runtime_disable(&pdev->dev); clk_disable_unprepare(chip->clk); return 0; } static void dw_shutdown(struct platform_device *pdev) { struct dw_dma_chip *chip = platform_get_drvdata(pdev); dw_dma_disable(chip); clk_disable_unprepare(chip->clk); } #ifdef CONFIG_OF static const struct of_device_id dw_dma_of_id_table[] = { { .compatible = "snps,dma-spear1340" }, {} };
static int xgene_mdio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct mii_bus *mdio_bus; const struct of_device_id *of_id; struct resource *res; struct xgene_mdio_pdata *pdata; void __iomem *csr_base; int mdio_id = 0, ret = 0; of_id = of_match_device(xgene_mdio_of_match, &pdev->dev); if (of_id) { mdio_id = (enum xgene_mdio_id)of_id->data; } else { #ifdef CONFIG_ACPI const struct acpi_device_id *acpi_id; acpi_id = acpi_match_device(xgene_mdio_acpi_match, &pdev->dev); if (acpi_id) mdio_id = (enum xgene_mdio_id)acpi_id->driver_data; #endif } if (!mdio_id) return -ENODEV; pdata = devm_kzalloc(dev, sizeof(struct xgene_mdio_pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; pdata->mdio_id = mdio_id; pdata->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); csr_base = devm_ioremap_resource(dev, res); if (IS_ERR(csr_base)) return PTR_ERR(csr_base); pdata->mac_csr_addr = csr_base; pdata->mdio_csr_addr = csr_base + BLOCK_XG_MDIO_CSR_OFFSET; pdata->diag_csr_addr = csr_base + BLOCK_DIAG_CSR_OFFSET; if (mdio_id == XGENE_MDIO_RGMII) spin_lock_init(&pdata->mac_lock); if (dev->of_node) { pdata->clk = devm_clk_get(dev, NULL); if (IS_ERR(pdata->clk)) { dev_err(dev, "Unable to retrieve clk\n"); return PTR_ERR(pdata->clk); } } ret = xgene_mdio_reset(pdata); if (ret) return ret; mdio_bus = mdiobus_alloc(); if (!mdio_bus) { ret = -ENOMEM; goto out_clk; } mdio_bus->name = "APM X-Gene MDIO bus"; if (mdio_id == XGENE_MDIO_RGMII) { mdio_bus->read = xgene_mdio_rgmii_read; mdio_bus->write = xgene_mdio_rgmii_write; mdio_bus->priv = (void __force *)pdata; snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "%s", "xgene-mii-rgmii"); } else { mdio_bus->read = xgene_xfi_mdio_read; mdio_bus->write = xgene_xfi_mdio_write; mdio_bus->priv = (void __force *)pdata->mdio_csr_addr; snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "%s", "xgene-mii-xfi"); } mdio_bus->parent = dev; platform_set_drvdata(pdev, pdata); if (dev->of_node) { ret = of_mdiobus_register(mdio_bus, dev->of_node); } else { #ifdef CONFIG_ACPI /* Mask out all PHYs from auto probing. */ mdio_bus->phy_mask = ~0; ret = mdiobus_register(mdio_bus); if (ret) goto out_mdiobus; acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_HANDLE(dev), 1, acpi_register_phy, NULL, mdio_bus, NULL); #endif } if (ret) goto out_mdiobus; pdata->mdio_bus = mdio_bus; xgene_mdio_status = true; return 0; out_mdiobus: mdiobus_free(mdio_bus); out_clk: if (dev->of_node) clk_disable_unprepare(pdata->clk); return ret; }
static int sst_acpi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; int ret = 0; struct intel_sst_drv *ctx; const struct acpi_device_id *id; struct sst_acpi_mach *mach; struct platform_device *mdev; struct platform_device *plat_dev; struct sst_platform_info *pdata; unsigned int dev_id; id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!id) return -ENODEV; dev_dbg(dev, "for %s", id->id); mach = (struct sst_acpi_mach *)id->driver_data; mach = sst_acpi_find_machine(mach); if (mach == NULL) { dev_err(dev, "No matching machine driver found\n"); return -ENODEV; } pdata = mach->pdata; ret = kstrtouint(id->id, 16, &dev_id); if (ret < 0) { dev_err(dev, "Unique device id conversion error: %d\n", ret); return ret; } dev_dbg(dev, "ACPI device id: %x\n", dev_id); plat_dev = platform_device_register_data(dev, pdata->platform, -1, NULL, 0); if (IS_ERR(plat_dev)) { dev_err(dev, "Failed to create machine device: %s\n", pdata->platform); return PTR_ERR(plat_dev); } /* * Create platform device for sst machine driver, * pass machine info as pdata */ mdev = platform_device_register_data(dev, mach->drv_name, -1, (const void *)mach, sizeof(*mach)); if (IS_ERR(mdev)) { dev_err(dev, "Failed to create machine device: %s\n", mach->drv_name); return PTR_ERR(mdev); } ret = sst_alloc_drv_context(&ctx, dev, dev_id); if (ret < 0) return ret; /* Fill sst platform data */ ctx->pdata = pdata; strcpy(ctx->firmware_name, mach->fw_filename); ret = sst_platform_get_resources(ctx); if (ret) return ret; ret = sst_context_init(ctx); if (ret < 0) return ret; /* need to save shim registers in BYT */ ctx->shim_regs64 = devm_kzalloc(ctx->dev, sizeof(*ctx->shim_regs64), GFP_KERNEL); if (!ctx->shim_regs64) { ret = -ENOMEM; goto do_sst_cleanup; } sst_configure_runtime_pm(ctx); platform_set_drvdata(pdev, ctx); return ret; do_sst_cleanup: sst_context_cleanup(ctx); platform_set_drvdata(pdev, NULL); dev_err(ctx->dev, "failed with %d\n", ret); return ret; }