Lines Matching +full:2 +full:- +full:cell
1 // SPDX-License-Identifier: GPL-2.0-only
3 * drivers/mfd/mfd-core.c
46 if (!acpi_match_device_ids(adev, wd->ids)) { in match_device_ids()
47 wd->adev = adev; in match_device_ids()
54 static void mfd_acpi_add_device(const struct mfd_cell *cell, in mfd_acpi_add_device() argument
57 const struct mfd_cell_acpi_match *match = cell->acpi_match; in mfd_acpi_add_device()
61 parent = ACPI_COMPANION(pdev->dev.parent); in mfd_acpi_add_device()
71 * though at least Intel Galileo Gen 2 is using it to distinguish in mfd_acpi_add_device()
75 if (match->pnpid) { in mfd_acpi_add_device()
76 struct acpi_device_id ids[2] = {}; in mfd_acpi_add_device()
82 strscpy(ids[0].id, match->pnpid, sizeof(ids[0].id)); in mfd_acpi_add_device()
86 adev = acpi_find_child_device(parent, match->adr, false); in mfd_acpi_add_device()
90 device_set_node(&pdev->dev, acpi_fwnode_handle(adev ?: parent)); in mfd_acpi_add_device()
93 static inline void mfd_acpi_add_device(const struct mfd_cell *cell, in mfd_acpi_add_device() argument
101 const struct mfd_cell *cell) in mfd_match_of_node_to_dev() argument
109 if (of_entry->np == np) in mfd_match_of_node_to_dev()
110 return -EAGAIN; in mfd_match_of_node_to_dev()
112 if (!cell->use_of_reg) in mfd_match_of_node_to_dev()
113 /* No of_reg defined - allocate first free compatible match */ in mfd_match_of_node_to_dev()
119 return -EAGAIN; in mfd_match_of_node_to_dev()
121 if (cell->of_reg != of_node_addr) in mfd_match_of_node_to_dev()
123 return -EAGAIN; in mfd_match_of_node_to_dev()
128 return -ENOMEM; in mfd_match_of_node_to_dev()
130 of_entry->dev = &pdev->dev; in mfd_match_of_node_to_dev()
131 of_entry->np = np; in mfd_match_of_node_to_dev()
132 list_add_tail(&of_entry->list, &mfd_of_node_list); in mfd_match_of_node_to_dev()
134 device_set_node(&pdev->dev, of_fwnode_handle(np)); in mfd_match_of_node_to_dev()
140 const struct mfd_cell *cell, in mfd_add_device() argument
149 int ret = -ENOMEM; in mfd_add_device()
156 platform_id = id + cell->id; in mfd_add_device()
158 pdev = platform_device_alloc(cell->name, platform_id); in mfd_add_device()
162 pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL); in mfd_add_device()
163 if (!pdev->mfd_cell) in mfd_add_device()
166 res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL); in mfd_add_device()
170 pdev->dev.parent = parent; in mfd_add_device()
171 pdev->dev.type = &mfd_dev_type; in mfd_add_device()
172 pdev->dev.dma_mask = parent->dma_mask; in mfd_add_device()
173 pdev->dev.dma_parms = parent->dma_parms; in mfd_add_device()
174 pdev->dev.coherent_dma_mask = parent->coherent_dma_mask; in mfd_add_device()
177 &pdev->dev, cell->parent_supplies, in mfd_add_device()
178 parent, cell->parent_supplies, in mfd_add_device()
179 cell->num_parent_supplies); in mfd_add_device()
183 if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) { in mfd_add_device()
184 for_each_child_of_node(parent->of_node, np) { in mfd_add_device()
185 if (of_device_is_compatible(np, cell->of_compatible)) { in mfd_add_device()
192 ret = mfd_match_of_node_to_dev(pdev, np, cell); in mfd_add_device()
193 if (ret == -EAGAIN) in mfd_add_device()
210 if (!pdev->dev.of_node) in mfd_add_device()
212 cell->name, platform_id); in mfd_add_device()
215 mfd_acpi_add_device(cell, pdev); in mfd_add_device()
217 if (cell->pdata_size) { in mfd_add_device()
219 cell->platform_data, cell->pdata_size); in mfd_add_device()
224 if (cell->swnode) { in mfd_add_device()
225 ret = device_add_software_node(&pdev->dev, cell->swnode); in mfd_add_device()
230 for (r = 0; r < cell->num_resources; r++) { in mfd_add_device()
231 res[r].name = cell->resources[r].name; in mfd_add_device()
232 res[r].flags = cell->resources[r].flags; in mfd_add_device()
235 if ((cell->resources[r].flags & IORESOURCE_MEM) && mem_base) { in mfd_add_device()
237 res[r].start = mem_base->start + in mfd_add_device()
238 cell->resources[r].start; in mfd_add_device()
239 res[r].end = mem_base->start + in mfd_add_device()
240 cell->resources[r].end; in mfd_add_device()
241 } else if (cell->resources[r].flags & IORESOURCE_IRQ) { in mfd_add_device()
244 WARN_ON(cell->resources[r].start != in mfd_add_device()
245 cell->resources[r].end); in mfd_add_device()
247 domain, cell->resources[r].start); in mfd_add_device()
250 cell->resources[r].start; in mfd_add_device()
252 cell->resources[r].end; in mfd_add_device()
255 res[r].parent = cell->resources[r].parent; in mfd_add_device()
256 res[r].start = cell->resources[r].start; in mfd_add_device()
257 res[r].end = cell->resources[r].end; in mfd_add_device()
260 if (!cell->ignore_resource_conflicts) { in mfd_add_device()
261 if (has_acpi_companion(&pdev->dev)) { in mfd_add_device()
269 ret = platform_device_add_resources(pdev, res, cell->num_resources); in mfd_add_device()
277 if (cell->pm_runtime_no_callbacks) in mfd_add_device()
278 pm_runtime_no_callbacks(&pdev->dev); in mfd_add_device()
285 if (cell->swnode) in mfd_add_device()
286 device_remove_software_node(&pdev->dev); in mfd_add_device()
289 if (of_entry->dev == &pdev->dev) { in mfd_add_device()
290 list_del(&of_entry->list); in mfd_add_device()
294 regulator_bulk_unregister_supply_alias(&pdev->dev, in mfd_add_device()
295 cell->parent_supplies, in mfd_add_device()
296 cell->num_parent_supplies); in mfd_add_device()
306 * mfd_add_devices - register child devices
346 const struct mfd_cell *cell; in mfd_remove_devices_fn() local
350 if (dev->type != &mfd_dev_type) in mfd_remove_devices_fn()
354 cell = mfd_get_cell(pdev); in mfd_remove_devices_fn()
356 if (level && cell->level > *level) in mfd_remove_devices_fn()
359 if (cell->swnode) in mfd_remove_devices_fn()
360 device_remove_software_node(&pdev->dev); in mfd_remove_devices_fn()
363 if (of_entry->dev == &pdev->dev) { in mfd_remove_devices_fn()
364 list_del(&of_entry->list); in mfd_remove_devices_fn()
368 regulator_bulk_unregister_supply_alias(dev, cell->parent_supplies, in mfd_remove_devices_fn()
369 cell->num_parent_supplies); in mfd_remove_devices_fn()
397 * devm_mfd_add_devices - Resource managed version of mfd_add_devices()
400 * All child-devices of the MFD will automatically be removed when it gets
423 return -ENOMEM; in devm_mfd_add_devices()