Lines Matching +full:i2c +full:- +full:alias

1 // SPDX-License-Identifier: GPL-2.0+
3 * Serial multi-instantiate driver, pseudo driver to instantiate multiple
11 #include <linux/i2c.h>
55 switch (inst->flags & IRQ_RESOURCE_TYPE) { in smi_get_irq()
57 ret = acpi_dev_gpio_irq_get(adev, inst->irq_idx); in smi_get_irq()
59 dev_dbg(&pdev->dev, "Using gpio irq\n"); in smi_get_irq()
62 ret = platform_get_irq(pdev, inst->irq_idx); in smi_get_irq()
64 dev_dbg(&pdev->dev, "Using platform irq\n"); in smi_get_irq()
69 ret = acpi_dev_gpio_irq_get(adev, inst->irq_idx); in smi_get_irq()
72 ret = platform_get_irq(pdev, inst->irq_idx); in smi_get_irq()
78 return dev_err_probe(&pdev->dev, ret, "Error requesting irq at index %d\n", in smi_get_irq()
79 inst->irq_idx); in smi_get_irq()
87 while (smi->i2c_num--) in smi_devs_unregister()
88 i2c_unregister_device(smi->i2c_devs[smi->i2c_num]); in smi_devs_unregister()
92 while (smi->spi_num--) in smi_devs_unregister()
93 spi_unregister_device(smi->spi_devs[smi->spi_num]); in smi_devs_unregister()
98 * smi_spi_probe - Instantiate multiple SPI devices from inst array
108 struct device *dev = &pdev->dev; in smi_spi_probe()
119 return -ENOENT; in smi_spi_probe()
123 smi->spi_devs = devm_kcalloc(dev, count, sizeof(*smi->spi_devs), GFP_KERNEL); in smi_spi_probe()
124 if (!smi->spi_devs) in smi_spi_probe()
125 return -ENOMEM; in smi_spi_probe()
132 dev_name(&adev->dev)); in smi_spi_probe()
136 ctlr = spi_dev->controller; in smi_spi_probe()
138 strscpy(spi_dev->modalias, inst_array[i].type); in smi_spi_probe()
145 spi_dev->irq = ret; in smi_spi_probe()
147 snprintf(name, sizeof(name), "%s-%s-%s.%d", dev_name(&ctlr->dev), dev_name(dev), in smi_spi_probe()
149 spi_dev->dev.init_name = name; in smi_spi_probe()
153 dev_err_probe(&ctlr->dev, ret, "failed to add SPI device %s from ACPI\n", in smi_spi_probe()
154 dev_name(&adev->dev)); in smi_spi_probe()
162 smi->spi_devs[i] = spi_dev; in smi_spi_probe()
163 smi->spi_num++; in smi_spi_probe()
166 if (smi->spi_num < count) { in smi_spi_probe()
168 ret = -ENODEV; in smi_spi_probe()
172 dev_info(dev, "Instantiated %d SPI devices.\n", smi->spi_num); in smi_spi_probe()
182 * smi_i2c_probe - Instantiate multiple I2C devices from inst array
187 * Returns the number of I2C devices instantiate, Zero if none is found or a negative error code.
193 struct device *dev = &pdev->dev; in smi_i2c_probe()
202 return -ENOENT; in smi_i2c_probe()
206 smi->i2c_devs = devm_kcalloc(dev, count, sizeof(*smi->i2c_devs), GFP_KERNEL); in smi_i2c_probe()
207 if (!smi->i2c_devs) in smi_i2c_probe()
208 return -ENOMEM; in smi_i2c_probe()
213 snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev), inst_array[i].type, i); in smi_i2c_probe()
221 smi->i2c_devs[i] = i2c_acpi_new_device(dev, i, &board_info); in smi_i2c_probe()
222 if (IS_ERR(smi->i2c_devs[i])) { in smi_i2c_probe()
223 ret = dev_err_probe(dev, PTR_ERR(smi->i2c_devs[i]), in smi_i2c_probe()
224 "Error creating i2c-client, idx %d\n", i); in smi_i2c_probe()
227 smi->i2c_num++; in smi_i2c_probe()
229 if (smi->i2c_num < count) { in smi_i2c_probe()
231 ret = -ENODEV; in smi_i2c_probe()
235 dev_info(dev, "Instantiated %d I2C devices.\n", smi->i2c_num); in smi_i2c_probe()
246 struct device *dev = &pdev->dev; in smi_probe()
254 return -ENODEV; in smi_probe()
259 return -ENOMEM; in smi_probe()
263 switch (node->bus_type) { in smi_probe()
266 return smi_i2c_probe(pdev, smi, node->instances); in smi_probe()
268 return -ENODEV; in smi_probe()
271 return smi_spi_probe(pdev, smi, node->instances); in smi_probe()
273 return -ENODEV; in smi_probe()
276 * For backwards-compatibility with the existing nodes I2C in smi_probe()
277 * is checked first and if such entries are found ONLY I2C in smi_probe()
284 ret = smi_i2c_probe(pdev, smi, node->instances); in smi_probe()
285 if (ret != -ENOENT) in smi_probe()
290 return smi_spi_probe(pdev, smi, node->instances); in smi_probe()
292 return -ENODEV; in smi_probe()
294 return -EINVAL; in smi_probe()
339 { "cs35l41-hda", IRQ_RESOURCE_AUTO, 0 },
340 { "cs35l41-hda", IRQ_RESOURCE_AUTO, 0 },
341 { "cs35l41-hda", IRQ_RESOURCE_AUTO, 0 },
342 { "cs35l41-hda", IRQ_RESOURCE_AUTO, 0 },
350 { "cs35l54-hda", IRQ_RESOURCE_AUTO, 0 },
351 { "cs35l54-hda", IRQ_RESOURCE_AUTO, 0 },
352 { "cs35l54-hda", IRQ_RESOURCE_AUTO, 0 },
353 { "cs35l54-hda", IRQ_RESOURCE_AUTO, 0 },
354 /* a 5th entry is an alias address, not a real device */
355 { "cs35l54-hda_dummy_dev" },
363 { "cs35l56-hda", IRQ_RESOURCE_AUTO, 0 },
364 { "cs35l56-hda", IRQ_RESOURCE_AUTO, 0 },
365 { "cs35l56-hda", IRQ_RESOURCE_AUTO, 0 },
366 { "cs35l56-hda", IRQ_RESOURCE_AUTO, 0 },
367 /* a 5th entry is an alias address, not a real device */
368 { "cs35l56-hda_dummy_dev" },
376 { "cs35l57-hda", IRQ_RESOURCE_AUTO, 0 },
377 { "cs35l57-hda", IRQ_RESOURCE_AUTO, 0 },
378 { "cs35l57-hda", IRQ_RESOURCE_AUTO, 0 },
379 { "cs35l57-hda", IRQ_RESOURCE_AUTO, 0 },
380 /* a 5th entry is an alias address, not a real device */
381 { "cs35l57-hda_dummy_dev" },
388 * Note new device-ids must also be added to ignore_serial_bus_ids in
399 /* Non-conforming _HID for Cirrus Logic already released */