diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 95045e9e968a..95cf2a8ef03e 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -99,12 +99,6 @@ config OF_RESERVED_MEM_CHECK config OF_RESOLVE bool -config OF_SLIMBUS - def_tristate SLIMBUS - depends on SLIMBUS - help - OpenFirmware SLIMBUS accessors - config OF_OVERLAY bool "Device Tree overlays" select OF_DYNAMIC diff --git a/drivers/of/Makefile b/drivers/of/Makefile index 021bf0081d67..663a4af0cccd 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -12,7 +12,6 @@ obj-$(CONFIG_OF_UNITTEST) += unittest.o obj-$(CONFIG_OF_MDIO) += of_mdio.o obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o obj-$(CONFIG_OF_RESOLVE) += resolver.o -obj-$(CONFIG_OF_SLIMBUS) += of_slimbus.o obj-$(CONFIG_OF_OVERLAY) += overlay.o obj-$(CONFIG_OF_NUMA) += of_numa.o diff --git a/drivers/of/of_slimbus.c b/drivers/of/of_slimbus.c deleted file mode 100644 index 9283f1110308..000000000000 --- a/drivers/of/of_slimbus.c +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. - */ - -/* OF helpers for SLIMbus */ -#include -#include -#include -#include -#include -#include - -int of_register_slim_devices(struct slim_controller *ctrl) -{ - struct device_node *node; - struct slim_boardinfo *binfo = NULL; - struct slim_boardinfo *temp; - int n = 0; - int ret = 0; - - if (!ctrl->dev.of_node) - return -EINVAL; - - for_each_available_child_of_node(ctrl->dev.of_node, node) { - struct property *prop; - struct slim_device *slim; - char *name; - - prop = of_find_property(node, "elemental-addr", NULL); - if (!prop || prop->length != 6) { - dev_err(&ctrl->dev, "of_slim: invalid E-addr\n"); - continue; - } - name = kzalloc(SLIMBUS_NAME_SIZE, GFP_KERNEL); - if (!name) { - ret = -ENOMEM; - of_node_put(node); - goto of_slim_err; - } - if (of_modalias_node(node, name, SLIMBUS_NAME_SIZE) < 0) { - dev_err(&ctrl->dev, "of_slim: modalias failure on %s\n", - node->full_name); - kfree(name); - continue; - } - slim = kzalloc(sizeof(struct slim_device), GFP_KERNEL); - if (!slim) { - ret = -ENOMEM; - kfree(name); - of_node_put(node); - goto of_slim_err; - } - memcpy(slim->e_addr, prop->value, 6); - - temp = krealloc(binfo, (n + 1) * sizeof(struct slim_boardinfo), - GFP_KERNEL); - if (!temp) { - kfree(name); - kfree(slim); - ret = -ENOMEM; - of_node_put(node); - goto of_slim_err; - } - binfo = temp; - - slim->dev.of_node = of_node_get(node); - slim->name = (const char *)name; - binfo[n].bus_num = ctrl->nr; - binfo[n].slim_slave = slim; - n++; - } - ret = slim_register_board_info(binfo, n); - if (!ret) - goto of_slim_ret; -of_slim_err: - while (n-- > 0) { - kfree(binfo[n].slim_slave->name); - kfree(binfo[n].slim_slave); - } -of_slim_ret: - kfree(binfo); - return ret; -} -EXPORT_SYMBOL(of_register_slim_devices); diff --git a/drivers/slimbus/Kconfig b/drivers/slimbus/Kconfig index ba1f3601c1e4..071d28c64338 100644 --- a/drivers/slimbus/Kconfig +++ b/drivers/slimbus/Kconfig @@ -3,7 +3,7 @@ # SLIMbus driver configuration # menuconfig SLIMBUS - bool "SLIMbus support" + tristate "SLIMbus support" depends on HAS_IOMEM help Slimbus is standard interface between baseband and @@ -50,4 +50,5 @@ config SLIMBUS_MSM_NGD the bus using messaging interface, and communicating with master component residing on ADSP for bandwidth and data-channel management. + endif diff --git a/drivers/slimbus/Makefile b/drivers/slimbus/Makefile index 2c538edbb993..aed1447531c9 100644 --- a/drivers/slimbus/Makefile +++ b/drivers/slimbus/Makefile @@ -4,4 +4,5 @@ # obj-$(CONFIG_SLIMBUS) += slimbus.o obj-$(CONFIG_SLIMBUS_MSM_CTRL) += slim-msm.o slim-msm-ctrl.o -obj-$(CONFIG_SLIMBUS_MSM_NGD) += slim-msm.o slim-msm-ngd.o +obj-$(CONFIG_SLIMBUS_MSM_NGD) += slimbus-ngd.o +slimbus-ngd-y := slim-msm.o slim-msm-ngd.o diff --git a/drivers/slimbus/slim-msm-ctrl.c b/drivers/slimbus/slim-msm-ctrl.c index 68512de3a5e4..001fb9ef7025 100644 --- a/drivers/slimbus/slim-msm-ctrl.c +++ b/drivers/slimbus/slim-msm-ctrl.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #include @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include "slim-msm.h" diff --git a/drivers/slimbus/slim-msm-ngd.c b/drivers/slimbus/slim-msm-ngd.c index ee9844113f67..ebe8de1589dd 100644 --- a/drivers/slimbus/slim-msm-ngd.c +++ b/drivers/slimbus/slim-msm-ngd.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/slimbus/slimbus.c b/drivers/slimbus/slimbus.c index 1aab3e0e498f..7bbab7885f74 100644 --- a/drivers/slimbus/slimbus.c +++ b/drivers/slimbus/slimbus.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #include @@ -11,6 +11,10 @@ #include #include #include +#include +#include +#include +#include #define SLIM_PORT_HDL(la, f, p) ((la)<<24 | (f) << 16 | (p)) @@ -3437,4 +3441,77 @@ clk_pause_ret: } EXPORT_SYMBOL(slim_ctrl_clk_pause); +int of_register_slim_devices(struct slim_controller *ctrl) +{ + struct device_node *node; + struct slim_boardinfo *binfo = NULL; + struct slim_boardinfo *temp; + int n = 0; + int ret = 0; + + if (!ctrl->dev.of_node) + return -EINVAL; + + for_each_available_child_of_node(ctrl->dev.of_node, node) { + struct property *prop; + struct slim_device *slim; + char *name; + + prop = of_find_property(node, "elemental-addr", NULL); + if (!prop || prop->length != 6) { + dev_err(&ctrl->dev, "of_slim: invalid E-addr\n"); + continue; + } + name = kzalloc(SLIMBUS_NAME_SIZE, GFP_KERNEL); + if (!name) { + ret = -ENOMEM; + of_node_put(node); + goto of_slim_err; + } + if (of_modalias_node(node, name, SLIMBUS_NAME_SIZE) < 0) { + dev_err(&ctrl->dev, "of_slim: modalias failure on %s\n", + node->full_name); + kfree(name); + continue; + } + slim = kzalloc(sizeof(struct slim_device), GFP_KERNEL); + if (!slim) { + ret = -ENOMEM; + kfree(name); + of_node_put(node); + goto of_slim_err; + } + memcpy(slim->e_addr, prop->value, 6); + + temp = krealloc(binfo, (n + 1) * sizeof(struct slim_boardinfo), + GFP_KERNEL); + if (!temp) { + kfree(name); + kfree(slim); + ret = -ENOMEM; + of_node_put(node); + goto of_slim_err; + } + binfo = temp; + + slim->dev.of_node = of_node_get(node); + slim->name = (const char *)name; + binfo[n].bus_num = ctrl->nr; + binfo[n].slim_slave = slim; + n++; + } + ret = slim_register_board_info(binfo, n); + if (!ret) + goto of_slim_ret; +of_slim_err: + while (n-- > 0) { + kfree(binfo[n].slim_slave->name); + kfree(binfo[n].slim_slave); + } +of_slim_ret: + kfree(binfo); + return ret; +} +EXPORT_SYMBOL(of_register_slim_devices); + MODULE_LICENSE("GPL v2"); diff --git a/include/linux/of_slimbus.h b/include/linux/of_slimbus.h deleted file mode 100644 index 112a9304a32d..000000000000 --- a/include/linux/of_slimbus.h +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. - */ - -#include -#include - -#if IS_ENABLED(CONFIG_OF_SLIMBUS) -/* - * of_slim_register_devices() - Register devices in the SLIMbus Device Tree - * @ctrl: slim_controller which devices should be registered to. - * - * This routine scans the SLIMbus Device Tree, allocating resources and - * creating slim_devices according to the SLIMbus Device Tree - * hierarchy. Details of this hierarchy can be found in - * Documentation/devicetree/bindings/slimbus. This routine is normally - * called from the probe routine of the driver registering as a - * slim_controller. - */ -extern int of_register_slim_devices(struct slim_controller *ctrl); -#else -static int of_register_slim_devices(struct slim_controller *ctrl) -{ - return 0; -} -#endif /* CONFIG_OF_SLIMBUS */ diff --git a/include/linux/slimbus/slimbus.h b/include/linux/slimbus/slimbus.h index f6e46c0ecc7e..5178c62a4e23 100644 --- a/include/linux/slimbus/slimbus.h +++ b/include/linux/slimbus/slimbus.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #ifndef _LINUX_SLIMBUS_H @@ -9,6 +9,7 @@ #include #include #include +#include /* Interfaces between SLIMbus manager drivers and SLIMbus infrastructure. */ @@ -1168,6 +1169,7 @@ extern void slim_ctrl_add_boarddevs(struct slim_controller *ctrl); extern const struct slim_device_id *slim_get_device_id(const struct slim_device *sdev); +#if IS_ENABLED(CONFIG_SLIMBUS) /* * slim_register_board_info: Board-initialization routine. * @info: List of all devices on all controllers present on the board. @@ -1175,16 +1177,36 @@ struct slim_device_id *slim_get_device_id(const struct slim_device *sdev); * API enumerates respective devices on corresponding controller. * Called from board-init function. */ -#ifdef CONFIG_SLIMBUS extern int slim_register_board_info(struct slim_boardinfo const *info, unsigned int n); + +/* + * of_slim_register_devices() - Register devices in the SLIMbus Device Tree + * @ctrl: slim_controller which devices should be registered to. + * + * This routine scans the SLIMbus Device Tree, allocating resources and + * creating slim_devices according to the SLIMbus Device Tree + * hierarchy. Details of this hierarchy can be found in + * Documentation/devicetree/bindings/slimbus. This routine is normally + * called from the probe routine of the driver registering as a + * slim_controller. + */ +extern int of_register_slim_devices(struct slim_controller *ctrl); + #else + static inline int slim_register_board_info(struct slim_boardinfo const *info, unsigned int n) { return 0; } -#endif + +static int of_register_slim_devices(struct slim_controller *ctrl) +{ + return 0; +} + +#endif /* CONFIG_OF_SLIMBUS */ static inline void *slim_get_ctrldata(const struct slim_controller *dev) { @@ -1205,4 +1227,5 @@ static inline void slim_set_clientdata(struct slim_device *dev, void *data) { dev_set_drvdata(&dev->dev, data); } + #endif /* _LINUX_SLIMBUS_H */