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()
63 static void mfd_acpi_add_device(const struct mfd_cell *cell, in mfd_acpi_add_device() argument
66 const struct mfd_cell_acpi_match *match = cell->acpi_match; in mfd_acpi_add_device()
70 parent = ACPI_COMPANION(pdev->dev.parent); in mfd_acpi_add_device()
80 * though at least Intel Galileo Gen 2 is using it to distinguish in mfd_acpi_add_device()
84 if (match->pnpid) { in mfd_acpi_add_device()
85 struct acpi_device_id ids[2] = {}; in mfd_acpi_add_device()
87 strlcpy(ids[0].id, match->pnpid, sizeof(ids[0].id)); in mfd_acpi_add_device()
88 list_for_each_entry(child, &parent->children, node) { in mfd_acpi_add_device()
95 adev = acpi_find_child_device(parent, match->adr, false); in mfd_acpi_add_device()
99 ACPI_COMPANION_SET(&pdev->dev, adev ?: parent); in mfd_acpi_add_device()
102 static inline void mfd_acpi_add_device(const struct mfd_cell *cell, in mfd_acpi_add_device() argument
110 const struct mfd_cell *cell) in mfd_match_of_node_to_dev() argument
119 if (of_entry->np == np) in mfd_match_of_node_to_dev()
120 return -EAGAIN; in mfd_match_of_node_to_dev()
122 if (!cell->use_of_reg) in mfd_match_of_node_to_dev()
123 /* No of_reg defined - allocate first free compatible match */ in mfd_match_of_node_to_dev()
130 return -EAGAIN; in mfd_match_of_node_to_dev()
134 if (cell->of_reg != of_node_addr) in mfd_match_of_node_to_dev()
136 return -EAGAIN; in mfd_match_of_node_to_dev()
141 return -ENOMEM; in mfd_match_of_node_to_dev()
143 of_entry->dev = &pdev->dev; in mfd_match_of_node_to_dev()
144 of_entry->np = np; in mfd_match_of_node_to_dev()
145 list_add_tail(&of_entry->list, &mfd_of_node_list); in mfd_match_of_node_to_dev()
147 pdev->dev.of_node = np; in mfd_match_of_node_to_dev()
148 pdev->dev.fwnode = &np->fwnode; in mfd_match_of_node_to_dev()
154 const struct mfd_cell *cell, in mfd_add_device() argument
162 int ret = -ENOMEM; in mfd_add_device()
169 platform_id = id + cell->id; in mfd_add_device()
171 pdev = platform_device_alloc(cell->name, platform_id); in mfd_add_device()
175 pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL); in mfd_add_device()
176 if (!pdev->mfd_cell) in mfd_add_device()
179 res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL); in mfd_add_device()
183 pdev->dev.parent = parent; in mfd_add_device()
184 pdev->dev.type = &mfd_dev_type; in mfd_add_device()
185 pdev->dev.dma_mask = parent->dma_mask; in mfd_add_device()
186 pdev->dev.dma_parms = parent->dma_parms; in mfd_add_device()
187 pdev->dev.coherent_dma_mask = parent->coherent_dma_mask; in mfd_add_device()
190 &pdev->dev, cell->parent_supplies, in mfd_add_device()
191 parent, cell->parent_supplies, in mfd_add_device()
192 cell->num_parent_supplies); in mfd_add_device()
196 if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) { in mfd_add_device()
197 for_each_child_of_node(parent->of_node, np) { in mfd_add_device()
198 if (of_device_is_compatible(np, cell->of_compatible)) { in mfd_add_device()
205 ret = mfd_match_of_node_to_dev(pdev, np, cell); in mfd_add_device()
206 if (ret == -EAGAIN) in mfd_add_device()
215 if (!pdev->dev.of_node) in mfd_add_device()
217 cell->name, platform_id); in mfd_add_device()
220 mfd_acpi_add_device(cell, pdev); in mfd_add_device()
222 if (cell->pdata_size) { in mfd_add_device()
224 cell->platform_data, cell->pdata_size); in mfd_add_device()
229 if (cell->swnode) { in mfd_add_device()
230 ret = device_add_software_node(&pdev->dev, cell->swnode); in mfd_add_device()
235 for (r = 0; r < cell->num_resources; r++) { in mfd_add_device()
236 res[r].name = cell->resources[r].name; in mfd_add_device()
237 res[r].flags = cell->resources[r].flags; in mfd_add_device()
240 if ((cell->resources[r].flags & IORESOURCE_MEM) && mem_base) { in mfd_add_device()
242 res[r].start = mem_base->start + in mfd_add_device()
243 cell->resources[r].start; in mfd_add_device()
244 res[r].end = mem_base->start + in mfd_add_device()
245 cell->resources[r].end; in mfd_add_device()
246 } else if (cell->resources[r].flags & IORESOURCE_IRQ) { in mfd_add_device()
249 WARN_ON(cell->resources[r].start != in mfd_add_device()
250 cell->resources[r].end); in mfd_add_device()
252 domain, cell->resources[r].start); in mfd_add_device()
255 cell->resources[r].start; in mfd_add_device()
257 cell->resources[r].end; in mfd_add_device()
260 res[r].parent = cell->resources[r].parent; in mfd_add_device()
261 res[r].start = cell->resources[r].start; in mfd_add_device()
262 res[r].end = cell->resources[r].end; in mfd_add_device()
265 if (!cell->ignore_resource_conflicts) { in mfd_add_device()
266 if (has_acpi_companion(&pdev->dev)) { in mfd_add_device()
274 ret = platform_device_add_resources(pdev, res, cell->num_resources); in mfd_add_device()
282 if (cell->pm_runtime_no_callbacks) in mfd_add_device()
283 pm_runtime_no_callbacks(&pdev->dev); in mfd_add_device()
290 if (cell->swnode) in mfd_add_device()
291 device_remove_software_node(&pdev->dev); in mfd_add_device()
294 if (of_entry->dev == &pdev->dev) { in mfd_add_device()
295 list_del(&of_entry->list); in mfd_add_device()
299 regulator_bulk_unregister_supply_alias(&pdev->dev, in mfd_add_device()
300 cell->parent_supplies, in mfd_add_device()
301 cell->num_parent_supplies); in mfd_add_device()
311 * mfd_add_devices - register child devices
351 const struct mfd_cell *cell; in mfd_remove_devices_fn() local
354 if (dev->type != &mfd_dev_type) in mfd_remove_devices_fn()
358 cell = mfd_get_cell(pdev); in mfd_remove_devices_fn()
360 if (level && cell->level > *level) in mfd_remove_devices_fn()
363 if (cell->swnode) in mfd_remove_devices_fn()
364 device_remove_software_node(&pdev->dev); in mfd_remove_devices_fn()
366 regulator_bulk_unregister_supply_alias(dev, cell->parent_supplies, in mfd_remove_devices_fn()
367 cell->num_parent_supplies); in mfd_remove_devices_fn()
395 * devm_mfd_add_devices - Resource managed version of mfd_add_devices()
398 * All child-devices of the MFD will automatically be removed when it gets
421 return -ENOMEM; in devm_mfd_add_devices()