133c02590SGregory CLEMENT // SPDX-License-Identifier: GPL-2.0+
233c02590SGregory CLEMENT /*
333c02590SGregory CLEMENT  * Marvell Armada AP and CP110 helper
433c02590SGregory CLEMENT  *
533c02590SGregory CLEMENT  * Copyright (C) 2018 Marvell
633c02590SGregory CLEMENT  *
733c02590SGregory CLEMENT  * Gregory Clement <gregory.clement@bootlin.com>
833c02590SGregory CLEMENT  *
933c02590SGregory CLEMENT  */
1033c02590SGregory CLEMENT 
1133c02590SGregory CLEMENT #include "armada_ap_cp_helper.h"
1233c02590SGregory CLEMENT #include <linux/device.h>
1333c02590SGregory CLEMENT #include <linux/of.h>
1433c02590SGregory CLEMENT #include <linux/of_address.h>
1533c02590SGregory CLEMENT 
ap_cp_unique_name(struct device * dev,struct device_node * np,const char * name)1633c02590SGregory CLEMENT char *ap_cp_unique_name(struct device *dev, struct device_node *np,
1733c02590SGregory CLEMENT 			const char *name)
1833c02590SGregory CLEMENT {
19*1fe8150dSRob Herring 	struct resource res;
2033c02590SGregory CLEMENT 
2133c02590SGregory CLEMENT 	/* Do not create a name if there is no clock */
2233c02590SGregory CLEMENT 	if (!name)
2333c02590SGregory CLEMENT 		return NULL;
2433c02590SGregory CLEMENT 
25*1fe8150dSRob Herring 	of_address_to_resource(np, 0, &res);
2633c02590SGregory CLEMENT 	return devm_kasprintf(dev, GFP_KERNEL, "%llx-%s",
27*1fe8150dSRob Herring 			      (unsigned long long)res.start, name);
2833c02590SGregory CLEMENT }
29