Merge tag 'reset-gpio-for-v6.19' of https://git.pengutronix.de/git/pza/linux into soc/drivers-late
Reset/GPIO/swnode changes for v6.19 * Extend software node implementation, allowing its properties to reference existing firmware nodes. * Update the GPIO property interface to use reworked swnode macros. * Rework reset-gpio code to use GPIO lookup via swnode. * Fix spi-cs42l43 driver to work with swnode changes. * tag 'reset-gpio-for-v6.19' of https://git.pengutronix.de/git/pza/linux: reset: gpio: use software nodes to setup the GPIO lookup reset: gpio: convert the driver to using the auxiliary bus reset: make the provider of reset-gpios the parent of the reset device reset: order includes alphabetically in reset/core.c gpio: swnode: allow referencing GPIO chips by firmware nodes spi: cs42l43: Use actual ACPI firmware node for chip selects software node: allow referencing firmware nodes software node: increase the reference of the swnode by its fwnode software node: read the reference args via the fwnode API Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
@@ -535,14 +535,29 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
|
|||||||
ref_array = prop->pointer;
|
ref_array = prop->pointer;
|
||||||
ref = &ref_array[index];
|
ref = &ref_array[index];
|
||||||
|
|
||||||
refnode = software_node_fwnode(ref->node);
|
/*
|
||||||
|
* A software node can reference other software nodes or firmware
|
||||||
|
* nodes (which are the abstraction layer sitting on top of them).
|
||||||
|
* This is done to ensure we can create references to static software
|
||||||
|
* nodes before they're registered with the firmware node framework.
|
||||||
|
* At the time the reference is being resolved, we expect the swnodes
|
||||||
|
* in question to already have been registered and to be backed by
|
||||||
|
* a firmware node. This is why we use the fwnode API below to read the
|
||||||
|
* relevant properties and bump the reference count.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (ref->swnode)
|
||||||
|
refnode = software_node_fwnode(ref->swnode);
|
||||||
|
else if (ref->fwnode)
|
||||||
|
refnode = ref->fwnode;
|
||||||
|
else
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (!refnode)
|
if (!refnode)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
if (nargs_prop) {
|
if (nargs_prop) {
|
||||||
error = property_entry_read_int_array(ref->node->properties,
|
error = fwnode_property_read_u32(refnode, nargs_prop, &nargs_prop_val);
|
||||||
nargs_prop, sizeof(u32),
|
|
||||||
&nargs_prop_val, 1);
|
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -555,7 +570,7 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
|
|||||||
if (!args)
|
if (!args)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
args->fwnode = software_node_get(refnode);
|
args->fwnode = fwnode_handle_get(refnode);
|
||||||
args->nargs = nargs;
|
args->nargs = nargs;
|
||||||
|
|
||||||
for (i = 0; i < nargs; i++)
|
for (i = 0; i < nargs; i++)
|
||||||
@@ -635,7 +650,10 @@ software_node_graph_get_remote_endpoint(const struct fwnode_handle *fwnode)
|
|||||||
|
|
||||||
ref = prop->pointer;
|
ref = prop->pointer;
|
||||||
|
|
||||||
return software_node_get(software_node_fwnode(ref[0].node));
|
if (!ref->swnode)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return software_node_get(software_node_fwnode(ref->swnode));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct fwnode_handle *
|
static struct fwnode_handle *
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
|
|||||||
|
|
||||||
gdev_node = to_software_node(fwnode);
|
gdev_node = to_software_node(fwnode);
|
||||||
if (!gdev_node || !gdev_node->name)
|
if (!gdev_node || !gdev_node->name)
|
||||||
return ERR_PTR(-EINVAL);
|
goto fwnode_lookup;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for a special node that identifies undefined GPIOs, this is
|
* Check for a special node that identifies undefined GPIOs, this is
|
||||||
@@ -41,6 +41,7 @@ static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
|
|||||||
!strcmp(gdev_node->name, GPIOLIB_SWNODE_UNDEFINED_NAME))
|
!strcmp(gdev_node->name, GPIOLIB_SWNODE_UNDEFINED_NAME))
|
||||||
return ERR_PTR(-ENOENT);
|
return ERR_PTR(-ENOENT);
|
||||||
|
|
||||||
|
fwnode_lookup:
|
||||||
gdev = gpio_device_find_by_fwnode(fwnode);
|
gdev = gpio_device_find_by_fwnode(fwnode);
|
||||||
return gdev ?: ERR_PTR(-EPROBE_DEFER);
|
return gdev ?: ERR_PTR(-EPROBE_DEFER);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ config RESET_EYEQ
|
|||||||
config RESET_GPIO
|
config RESET_GPIO
|
||||||
tristate "GPIO reset controller"
|
tristate "GPIO reset controller"
|
||||||
depends on GPIOLIB
|
depends on GPIOLIB
|
||||||
|
select AUXILIARY_BUS
|
||||||
help
|
help
|
||||||
This enables a generic reset controller for resets attached via
|
This enables a generic reset controller for resets attached via
|
||||||
GPIOs. Typically for OF platforms this driver expects "reset-gpios"
|
GPIOs. Typically for OF platforms this driver expects "reset-gpios"
|
||||||
|
|||||||
@@ -4,20 +4,22 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2013 Philipp Zabel, Pengutronix
|
* Copyright 2013 Philipp Zabel, Pengutronix
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/acpi.h>
|
||||||
#include <linux/atomic.h>
|
#include <linux/atomic.h>
|
||||||
|
#include <linux/auxiliary_bus.h>
|
||||||
#include <linux/cleanup.h>
|
#include <linux/cleanup.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/export.h>
|
#include <linux/export.h>
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/kref.h>
|
|
||||||
#include <linux/gpio/driver.h>
|
#include <linux/gpio/driver.h>
|
||||||
#include <linux/gpio/machine.h>
|
#include <linux/gpio/machine.h>
|
||||||
|
#include <linux/gpio/property.h>
|
||||||
#include <linux/idr.h>
|
#include <linux/idr.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/kref.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/acpi.h>
|
|
||||||
#include <linux/platform_device.h>
|
|
||||||
#include <linux/reset.h>
|
#include <linux/reset.h>
|
||||||
#include <linux/reset-controller.h>
|
#include <linux/reset-controller.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
@@ -76,10 +78,12 @@ struct reset_control_array {
|
|||||||
/**
|
/**
|
||||||
* struct reset_gpio_lookup - lookup key for ad-hoc created reset-gpio devices
|
* struct reset_gpio_lookup - lookup key for ad-hoc created reset-gpio devices
|
||||||
* @of_args: phandle to the reset controller with all the args like GPIO number
|
* @of_args: phandle to the reset controller with all the args like GPIO number
|
||||||
|
* @swnode: Software node containing the reference to the GPIO provider
|
||||||
* @list: list entry for the reset_gpio_lookup_list
|
* @list: list entry for the reset_gpio_lookup_list
|
||||||
*/
|
*/
|
||||||
struct reset_gpio_lookup {
|
struct reset_gpio_lookup {
|
||||||
struct of_phandle_args of_args;
|
struct of_phandle_args of_args;
|
||||||
|
struct fwnode_handle *swnode;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -848,56 +852,45 @@ static void __reset_control_put_internal(struct reset_control *rstc)
|
|||||||
kref_put(&rstc->refcnt, __reset_control_release);
|
kref_put(&rstc->refcnt, __reset_control_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __reset_add_reset_gpio_lookup(int id, struct device_node *np,
|
static void reset_gpio_aux_device_release(struct device *dev)
|
||||||
unsigned int gpio,
|
|
||||||
unsigned int of_flags)
|
|
||||||
{
|
{
|
||||||
const struct fwnode_handle *fwnode = of_fwnode_handle(np);
|
struct auxiliary_device *adev = to_auxiliary_dev(dev);
|
||||||
unsigned int lookup_flags;
|
|
||||||
const char *label_tmp;
|
|
||||||
|
|
||||||
/*
|
kfree(adev);
|
||||||
* Later we map GPIO flags between OF and Linux, however not all
|
}
|
||||||
* constants from include/dt-bindings/gpio/gpio.h and
|
|
||||||
* include/linux/gpio/machine.h match each other.
|
static int reset_add_gpio_aux_device(struct device *parent,
|
||||||
*/
|
struct fwnode_handle *swnode,
|
||||||
if (of_flags > GPIO_ACTIVE_LOW) {
|
int id, void *pdata)
|
||||||
pr_err("reset-gpio code does not support GPIO flags %u for GPIO %u\n",
|
{
|
||||||
of_flags, gpio);
|
struct auxiliary_device *adev;
|
||||||
return -EINVAL;
|
int ret;
|
||||||
|
|
||||||
|
adev = kzalloc(sizeof(*adev), GFP_KERNEL);
|
||||||
|
if (!adev)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
adev->id = id;
|
||||||
|
adev->name = "gpio";
|
||||||
|
adev->dev.parent = parent;
|
||||||
|
adev->dev.platform_data = pdata;
|
||||||
|
adev->dev.release = reset_gpio_aux_device_release;
|
||||||
|
device_set_node(&adev->dev, swnode);
|
||||||
|
|
||||||
|
ret = auxiliary_device_init(adev);
|
||||||
|
if (ret) {
|
||||||
|
kfree(adev);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct gpio_device *gdev __free(gpio_device_put) = gpio_device_find_by_fwnode(fwnode);
|
ret = __auxiliary_device_add(adev, "reset");
|
||||||
if (!gdev)
|
if (ret) {
|
||||||
return -EPROBE_DEFER;
|
auxiliary_device_uninit(adev);
|
||||||
|
kfree(adev);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
label_tmp = gpio_device_get_label(gdev);
|
return ret;
|
||||||
if (!label_tmp)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
char *label __free(kfree) = kstrdup(label_tmp, GFP_KERNEL);
|
|
||||||
if (!label)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
/* Size: one lookup entry plus sentinel */
|
|
||||||
struct gpiod_lookup_table *lookup __free(kfree) = kzalloc(struct_size(lookup, table, 2),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!lookup)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
lookup->dev_id = kasprintf(GFP_KERNEL, "reset-gpio.%d", id);
|
|
||||||
if (!lookup->dev_id)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
lookup_flags = GPIO_PERSISTENT;
|
|
||||||
lookup_flags |= of_flags & GPIO_ACTIVE_LOW;
|
|
||||||
lookup->table[0] = GPIO_LOOKUP(no_free_ptr(label), gpio, "reset",
|
|
||||||
lookup_flags);
|
|
||||||
|
|
||||||
/* Not freed on success, because it is persisent subsystem data. */
|
|
||||||
gpiod_add_lookup_table(no_free_ptr(lookup));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -905,8 +898,10 @@ static int __reset_add_reset_gpio_lookup(int id, struct device_node *np,
|
|||||||
*/
|
*/
|
||||||
static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
|
static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
|
||||||
{
|
{
|
||||||
|
struct property_entry properties[2] = { };
|
||||||
|
unsigned int offset, of_flags, lflags;
|
||||||
struct reset_gpio_lookup *rgpio_dev;
|
struct reset_gpio_lookup *rgpio_dev;
|
||||||
struct platform_device *pdev;
|
struct device *parent;
|
||||||
int id, ret;
|
int id, ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -925,6 +920,28 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
|
|||||||
*/
|
*/
|
||||||
lockdep_assert_not_held(&reset_list_mutex);
|
lockdep_assert_not_held(&reset_list_mutex);
|
||||||
|
|
||||||
|
offset = args->args[0];
|
||||||
|
of_flags = args->args[1];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Later we map GPIO flags between OF and Linux, however not all
|
||||||
|
* constants from include/dt-bindings/gpio/gpio.h and
|
||||||
|
* include/linux/gpio/machine.h match each other.
|
||||||
|
*
|
||||||
|
* FIXME: Find a better way of translating OF flags to GPIO lookup
|
||||||
|
* flags.
|
||||||
|
*/
|
||||||
|
if (of_flags > GPIO_ACTIVE_LOW) {
|
||||||
|
pr_err("reset-gpio code does not support GPIO flags %u for GPIO %u\n",
|
||||||
|
of_flags, offset);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct gpio_device *gdev __free(gpio_device_put) =
|
||||||
|
gpio_device_find_by_fwnode(of_fwnode_handle(args->np));
|
||||||
|
if (!gdev)
|
||||||
|
return -EPROBE_DEFER;
|
||||||
|
|
||||||
guard(mutex)(&reset_gpio_lookup_mutex);
|
guard(mutex)(&reset_gpio_lookup_mutex);
|
||||||
|
|
||||||
list_for_each_entry(rgpio_dev, &reset_gpio_lookup_list, list) {
|
list_for_each_entry(rgpio_dev, &reset_gpio_lookup_list, list) {
|
||||||
@@ -934,6 +951,10 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lflags = GPIO_PERSISTENT | (of_flags & GPIO_ACTIVE_LOW);
|
||||||
|
parent = gpio_device_to_device(gdev);
|
||||||
|
properties[0] = PROPERTY_ENTRY_GPIO("reset-gpios", parent->fwnode, offset, lflags);
|
||||||
|
|
||||||
id = ida_alloc(&reset_gpio_ida, GFP_KERNEL);
|
id = ida_alloc(&reset_gpio_ida, GFP_KERNEL);
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
return id;
|
return id;
|
||||||
@@ -945,11 +966,6 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
|
|||||||
goto err_ida_free;
|
goto err_ida_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = __reset_add_reset_gpio_lookup(id, args->np, args->args[0],
|
|
||||||
args->args[1]);
|
|
||||||
if (ret < 0)
|
|
||||||
goto err_kfree;
|
|
||||||
|
|
||||||
rgpio_dev->of_args = *args;
|
rgpio_dev->of_args = *args;
|
||||||
/*
|
/*
|
||||||
* We keep the device_node reference, but of_args.np is put at the end
|
* We keep the device_node reference, but of_args.np is put at the end
|
||||||
@@ -957,20 +973,26 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
|
|||||||
* Hold reference as long as rgpio_dev memory is valid.
|
* Hold reference as long as rgpio_dev memory is valid.
|
||||||
*/
|
*/
|
||||||
of_node_get(rgpio_dev->of_args.np);
|
of_node_get(rgpio_dev->of_args.np);
|
||||||
pdev = platform_device_register_data(NULL, "reset-gpio", id,
|
|
||||||
&rgpio_dev->of_args,
|
rgpio_dev->swnode = fwnode_create_software_node(properties, NULL);
|
||||||
sizeof(rgpio_dev->of_args));
|
if (IS_ERR(rgpio_dev->swnode)) {
|
||||||
ret = PTR_ERR_OR_ZERO(pdev);
|
ret = PTR_ERR(rgpio_dev->swnode);
|
||||||
|
goto err_put_of_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = reset_add_gpio_aux_device(parent, rgpio_dev->swnode, id,
|
||||||
|
&rgpio_dev->of_args);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_put;
|
goto err_del_swnode;
|
||||||
|
|
||||||
list_add(&rgpio_dev->list, &reset_gpio_lookup_list);
|
list_add(&rgpio_dev->list, &reset_gpio_lookup_list);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_put:
|
err_del_swnode:
|
||||||
|
fwnode_remove_software_node(rgpio_dev->swnode);
|
||||||
|
err_put_of_node:
|
||||||
of_node_put(rgpio_dev->of_args.np);
|
of_node_put(rgpio_dev->of_args.np);
|
||||||
err_kfree:
|
|
||||||
kfree(rgpio_dev);
|
kfree(rgpio_dev);
|
||||||
err_ida_free:
|
err_ida_free:
|
||||||
ida_free(&reset_gpio_ida, id);
|
ida_free(&reset_gpio_ida, id);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
#include <linux/auxiliary_bus.h>
|
||||||
#include <linux/gpio/consumer.h>
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/mod_devicetable.h>
|
#include <linux/mod_devicetable.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/platform_device.h>
|
|
||||||
#include <linux/reset-controller.h>
|
#include <linux/reset-controller.h>
|
||||||
|
|
||||||
struct reset_gpio_priv {
|
struct reset_gpio_priv {
|
||||||
@@ -61,9 +61,10 @@ static void reset_gpio_of_node_put(void *data)
|
|||||||
of_node_put(data);
|
of_node_put(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int reset_gpio_probe(struct platform_device *pdev)
|
static int reset_gpio_probe(struct auxiliary_device *adev,
|
||||||
|
const struct auxiliary_device_id *id)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &adev->dev;
|
||||||
struct of_phandle_args *platdata = dev_get_platdata(dev);
|
struct of_phandle_args *platdata = dev_get_platdata(dev);
|
||||||
struct reset_gpio_priv *priv;
|
struct reset_gpio_priv *priv;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -75,7 +76,7 @@ static int reset_gpio_probe(struct platform_device *pdev)
|
|||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
platform_set_drvdata(pdev, &priv->rc);
|
auxiliary_set_drvdata(adev, &priv->rc);
|
||||||
|
|
||||||
priv->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
|
priv->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
|
||||||
if (IS_ERR(priv->reset))
|
if (IS_ERR(priv->reset))
|
||||||
@@ -99,20 +100,20 @@ static int reset_gpio_probe(struct platform_device *pdev)
|
|||||||
return devm_reset_controller_register(dev, &priv->rc);
|
return devm_reset_controller_register(dev, &priv->rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct platform_device_id reset_gpio_ids[] = {
|
static const struct auxiliary_device_id reset_gpio_ids[] = {
|
||||||
{ .name = "reset-gpio", },
|
{ .name = "reset.gpio" },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(platform, reset_gpio_ids);
|
MODULE_DEVICE_TABLE(auxiliary, reset_gpio_ids);
|
||||||
|
|
||||||
static struct platform_driver reset_gpio_driver = {
|
static struct auxiliary_driver reset_gpio_driver = {
|
||||||
.probe = reset_gpio_probe,
|
.probe = reset_gpio_probe,
|
||||||
.id_table = reset_gpio_ids,
|
.id_table = reset_gpio_ids,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "reset-gpio",
|
.name = "reset-gpio",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
module_platform_driver(reset_gpio_driver);
|
module_auxiliary_driver(reset_gpio_driver);
|
||||||
|
|
||||||
MODULE_AUTHOR("Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>");
|
MODULE_AUTHOR("Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>");
|
||||||
MODULE_DESCRIPTION("Generic GPIO reset driver");
|
MODULE_DESCRIPTION("Generic GPIO reset driver");
|
||||||
|
|||||||
@@ -52,20 +52,6 @@ static struct spi_board_info amp_info_template = {
|
|||||||
.mode = SPI_MODE_0,
|
.mode = SPI_MODE_0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct software_node cs42l43_gpiochip_swnode = {
|
|
||||||
.name = "cs42l43-pinctrl",
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct software_node_ref_args cs42l43_cs_refs[] = {
|
|
||||||
SOFTWARE_NODE_REFERENCE(&cs42l43_gpiochip_swnode, 0, GPIO_ACTIVE_LOW),
|
|
||||||
SOFTWARE_NODE_REFERENCE(&swnode_gpio_undefined),
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct property_entry cs42l43_cs_props[] = {
|
|
||||||
PROPERTY_ENTRY_REF_ARRAY("cs-gpios", cs42l43_cs_refs),
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
static int cs42l43_spi_tx(struct regmap *regmap, const u8 *buf, unsigned int len)
|
static int cs42l43_spi_tx(struct regmap *regmap, const u8 *buf, unsigned int len)
|
||||||
{
|
{
|
||||||
const u8 *end = buf + len;
|
const u8 *end = buf + len;
|
||||||
@@ -324,11 +310,6 @@ static void cs42l43_release_of_node(void *data)
|
|||||||
fwnode_handle_put(data);
|
fwnode_handle_put(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cs42l43_release_sw_node(void *data)
|
|
||||||
{
|
|
||||||
software_node_unregister(&cs42l43_gpiochip_swnode);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int cs42l43_spi_probe(struct platform_device *pdev)
|
static int cs42l43_spi_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct cs42l43 *cs42l43 = dev_get_drvdata(pdev->dev.parent);
|
struct cs42l43 *cs42l43 = dev_get_drvdata(pdev->dev.parent);
|
||||||
@@ -391,6 +372,15 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
|
|||||||
fwnode_property_read_u32(xu_fwnode, "01fa-sidecar-instances", &nsidecars);
|
fwnode_property_read_u32(xu_fwnode, "01fa-sidecar-instances", &nsidecars);
|
||||||
|
|
||||||
if (nsidecars) {
|
if (nsidecars) {
|
||||||
|
struct software_node_ref_args args[] = {
|
||||||
|
SOFTWARE_NODE_REFERENCE(fwnode, 0, GPIO_ACTIVE_LOW),
|
||||||
|
SOFTWARE_NODE_REFERENCE(&swnode_gpio_undefined),
|
||||||
|
};
|
||||||
|
struct property_entry props[] = {
|
||||||
|
PROPERTY_ENTRY_REF_ARRAY("cs-gpios", args),
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
ret = fwnode_property_read_u32(xu_fwnode, "01fa-spk-id-val", &spkid);
|
ret = fwnode_property_read_u32(xu_fwnode, "01fa-spk-id-val", &spkid);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
dev_dbg(priv->dev, "01fa-spk-id-val = %d\n", spkid);
|
dev_dbg(priv->dev, "01fa-spk-id-val = %d\n", spkid);
|
||||||
@@ -403,17 +393,7 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
|
|||||||
"Failed to get spk-id-gpios\n");
|
"Failed to get spk-id-gpios\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = software_node_register(&cs42l43_gpiochip_swnode);
|
ret = device_create_managed_software_node(&priv->ctlr->dev, props, NULL);
|
||||||
if (ret)
|
|
||||||
return dev_err_probe(priv->dev, ret,
|
|
||||||
"Failed to register gpio swnode\n");
|
|
||||||
|
|
||||||
ret = devm_add_action_or_reset(priv->dev, cs42l43_release_sw_node, NULL);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = device_create_managed_software_node(&priv->ctlr->dev,
|
|
||||||
cs42l43_cs_props, NULL);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return dev_err_probe(priv->dev, ret, "Failed to add swnode\n");
|
return dev_err_probe(priv->dev, ret, "Failed to add swnode\n");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -355,19 +355,26 @@ struct software_node;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* struct software_node_ref_args - Reference property with additional arguments
|
* struct software_node_ref_args - Reference property with additional arguments
|
||||||
* @node: Reference to a software node
|
* @swnode: Reference to a software node
|
||||||
|
* @fwnode: Alternative reference to a firmware node handle
|
||||||
* @nargs: Number of elements in @args array
|
* @nargs: Number of elements in @args array
|
||||||
* @args: Integer arguments
|
* @args: Integer arguments
|
||||||
*/
|
*/
|
||||||
struct software_node_ref_args {
|
struct software_node_ref_args {
|
||||||
const struct software_node *node;
|
const struct software_node *swnode;
|
||||||
|
struct fwnode_handle *fwnode;
|
||||||
unsigned int nargs;
|
unsigned int nargs;
|
||||||
u64 args[NR_FWNODE_REFERENCE_ARGS];
|
u64 args[NR_FWNODE_REFERENCE_ARGS];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SOFTWARE_NODE_REFERENCE(_ref_, ...) \
|
#define SOFTWARE_NODE_REFERENCE(_ref_, ...) \
|
||||||
(const struct software_node_ref_args) { \
|
(const struct software_node_ref_args) { \
|
||||||
.node = _ref_, \
|
.swnode = _Generic(_ref_, \
|
||||||
|
const struct software_node *: _ref_, \
|
||||||
|
default: NULL), \
|
||||||
|
.fwnode = _Generic(_ref_, \
|
||||||
|
struct fwnode_handle *: _ref_, \
|
||||||
|
default: NULL), \
|
||||||
.nargs = COUNT_ARGS(__VA_ARGS__), \
|
.nargs = COUNT_ARGS(__VA_ARGS__), \
|
||||||
.args = { __VA_ARGS__ }, \
|
.args = { __VA_ARGS__ }, \
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user