Lines Matching +full:2 +full:- +full:cell

1 // SPDX-License-Identifier: GPL-2.0-only
3 * drivers/mfd/mfd-core.c
38 const struct mfd_cell *cell = mfd_get_cell(pdev); in mfd_cell_enable() local
40 if (!cell->enable) { in mfd_cell_enable()
41 dev_dbg(&pdev->dev, "No .enable() call-back registered\n"); in mfd_cell_enable()
45 return cell->enable(pdev); in mfd_cell_enable()
51 const struct mfd_cell *cell = mfd_get_cell(pdev); in mfd_cell_disable() local
53 if (!cell->disable) { in mfd_cell_disable()
54 dev_dbg(&pdev->dev, "No .disable() call-back registered\n"); in mfd_cell_disable()
58 return cell->disable(pdev); in mfd_cell_disable()
72 if (!acpi_match_device_ids(adev, wd->ids)) { in match_device_ids()
73 wd->adev = adev; in match_device_ids()
80 static void mfd_acpi_add_device(const struct mfd_cell *cell, in mfd_acpi_add_device() argument
83 const struct mfd_cell_acpi_match *match = cell->acpi_match; in mfd_acpi_add_device()
87 parent = ACPI_COMPANION(pdev->dev.parent); in mfd_acpi_add_device()
97 * though at least Intel Galileo Gen 2 is using it to distinguish in mfd_acpi_add_device()
101 if (match->pnpid) { in mfd_acpi_add_device()
102 struct acpi_device_id ids[2] = {}; in mfd_acpi_add_device()
108 strscpy(ids[0].id, match->pnpid, sizeof(ids[0].id)); in mfd_acpi_add_device()
112 adev = acpi_find_child_device(parent, match->adr, false); in mfd_acpi_add_device()
116 ACPI_COMPANION_SET(&pdev->dev, adev ?: parent); in mfd_acpi_add_device()
119 static inline void mfd_acpi_add_device(const struct mfd_cell *cell, in mfd_acpi_add_device() argument
127 const struct mfd_cell *cell) in mfd_match_of_node_to_dev() argument
136 if (of_entry->np == np) in mfd_match_of_node_to_dev()
137 return -EAGAIN; in mfd_match_of_node_to_dev()
139 if (!cell->use_of_reg) in mfd_match_of_node_to_dev()
140 /* No of_reg defined - allocate first free compatible match */ in mfd_match_of_node_to_dev()
147 return -EAGAIN; in mfd_match_of_node_to_dev()
151 if (cell->of_reg != of_node_addr) in mfd_match_of_node_to_dev()
153 return -EAGAIN; in mfd_match_of_node_to_dev()
158 return -ENOMEM; in mfd_match_of_node_to_dev()
160 of_entry->dev = &pdev->dev; in mfd_match_of_node_to_dev()
161 of_entry->np = np; in mfd_match_of_node_to_dev()
162 list_add_tail(&of_entry->list, &mfd_of_node_list); in mfd_match_of_node_to_dev()
164 pdev->dev.of_node = np; in mfd_match_of_node_to_dev()
165 pdev->dev.fwnode = &np->fwnode; in mfd_match_of_node_to_dev()
171 const struct mfd_cell *cell, in mfd_add_device() argument
179 int ret = -ENOMEM; in mfd_add_device()
186 platform_id = id + cell->id; in mfd_add_device()
188 pdev = platform_device_alloc(cell->name, platform_id); in mfd_add_device()
192 pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL); in mfd_add_device()
193 if (!pdev->mfd_cell) in mfd_add_device()
196 res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL); in mfd_add_device()
200 pdev->dev.parent = parent; in mfd_add_device()
201 pdev->dev.type = &mfd_dev_type; in mfd_add_device()
202 pdev->dev.dma_mask = parent->dma_mask; in mfd_add_device()
203 pdev->dev.dma_parms = parent->dma_parms; in mfd_add_device()
204 pdev->dev.coherent_dma_mask = parent->coherent_dma_mask; in mfd_add_device()
207 &pdev->dev, cell->parent_supplies, in mfd_add_device()
208 parent, cell->parent_supplies, in mfd_add_device()
209 cell->num_parent_supplies); in mfd_add_device()
213 if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) { in mfd_add_device()
214 for_each_child_of_node(parent->of_node, np) { in mfd_add_device()
215 if (of_device_is_compatible(np, cell->of_compatible)) { in mfd_add_device()
223 ret = mfd_match_of_node_to_dev(pdev, np, cell); in mfd_add_device()
224 if (ret == -EAGAIN) in mfd_add_device()
234 if (!pdev->dev.of_node) in mfd_add_device()
236 cell->name, platform_id); in mfd_add_device()
239 mfd_acpi_add_device(cell, pdev); in mfd_add_device()
241 if (cell->pdata_size) { in mfd_add_device()
243 cell->platform_data, cell->pdata_size); in mfd_add_device()
248 if (cell->swnode) { in mfd_add_device()
249 ret = device_add_software_node(&pdev->dev, cell->swnode); in mfd_add_device()
254 for (r = 0; r < cell->num_resources; r++) { in mfd_add_device()
255 res[r].name = cell->resources[r].name; in mfd_add_device()
256 res[r].flags = cell->resources[r].flags; in mfd_add_device()
259 if ((cell->resources[r].flags & IORESOURCE_MEM) && mem_base) { in mfd_add_device()
261 res[r].start = mem_base->start + in mfd_add_device()
262 cell->resources[r].start; in mfd_add_device()
263 res[r].end = mem_base->start + in mfd_add_device()
264 cell->resources[r].end; in mfd_add_device()
265 } else if (cell->resources[r].flags & IORESOURCE_IRQ) { in mfd_add_device()
268 WARN_ON(cell->resources[r].start != in mfd_add_device()
269 cell->resources[r].end); in mfd_add_device()
271 domain, cell->resources[r].start); in mfd_add_device()
274 cell->resources[r].start; in mfd_add_device()
276 cell->resources[r].end; in mfd_add_device()
279 res[r].parent = cell->resources[r].parent; in mfd_add_device()
280 res[r].start = cell->resources[r].start; in mfd_add_device()
281 res[r].end = cell->resources[r].end; in mfd_add_device()
284 if (!cell->ignore_resource_conflicts) { in mfd_add_device()
285 if (has_acpi_companion(&pdev->dev)) { in mfd_add_device()
293 ret = platform_device_add_resources(pdev, res, cell->num_resources); in mfd_add_device()
301 if (cell->pm_runtime_no_callbacks) in mfd_add_device()
302 pm_runtime_no_callbacks(&pdev->dev); in mfd_add_device()
309 if (cell->swnode) in mfd_add_device()
310 device_remove_software_node(&pdev->dev); in mfd_add_device()
313 if (of_entry->dev == &pdev->dev) { in mfd_add_device()
314 list_del(&of_entry->list); in mfd_add_device()
318 regulator_bulk_unregister_supply_alias(&pdev->dev, in mfd_add_device()
319 cell->parent_supplies, in mfd_add_device()
320 cell->num_parent_supplies); in mfd_add_device()
330 * mfd_add_devices - register child devices
370 const struct mfd_cell *cell; in mfd_remove_devices_fn() local
374 if (dev->type != &mfd_dev_type) in mfd_remove_devices_fn()
378 cell = mfd_get_cell(pdev); in mfd_remove_devices_fn()
380 if (level && cell->level > *level) in mfd_remove_devices_fn()
383 if (cell->swnode) in mfd_remove_devices_fn()
384 device_remove_software_node(&pdev->dev); in mfd_remove_devices_fn()
387 if (of_entry->dev == &pdev->dev) { in mfd_remove_devices_fn()
388 list_del(&of_entry->list); in mfd_remove_devices_fn()
392 regulator_bulk_unregister_supply_alias(dev, cell->parent_supplies, in mfd_remove_devices_fn()
393 cell->num_parent_supplies); in mfd_remove_devices_fn()
421 * devm_mfd_add_devices - Resource managed version of mfd_add_devices()
424 * All child-devices of the MFD will automatically be removed when it gets
447 return -ENOMEM; in devm_mfd_add_devices()