Skip to content

Commit 6a24f56

Browse files
Orson ZhaiLee Jones
authored andcommitted
mfd: syscon: Add arguments support for syscon reference
There are a lot of similar global registers being used across multiple SoCs from Unisoc. But most of these registers are assigned with different offset for different SoCs. It is hard to handle all of them in an all-in-one kernel image. Add a helper function to get regmap with arguments where we could put some extra information such as the offset value. Signed-off-by: Orson Zhai <[email protected]> Tested-by: Baolin Wang <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent 2f3dc25 commit 6a24f56

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

drivers/mfd/syscon.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,35 @@ struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
224224
}
225225
EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle);
226226

227+
struct regmap *syscon_regmap_lookup_by_phandle_args(struct device_node *np,
228+
const char *property,
229+
int arg_count,
230+
unsigned int *out_args)
231+
{
232+
struct device_node *syscon_np;
233+
struct of_phandle_args args;
234+
struct regmap *regmap;
235+
unsigned int index;
236+
int rc;
237+
238+
rc = of_parse_phandle_with_fixed_args(np, property, arg_count,
239+
0, &args);
240+
if (rc)
241+
return ERR_PTR(rc);
242+
243+
syscon_np = args.np;
244+
if (!syscon_np)
245+
return ERR_PTR(-ENODEV);
246+
247+
regmap = syscon_node_to_regmap(syscon_np);
248+
for (index = 0; index < arg_count; index++)
249+
out_args[index] = args.args[index];
250+
of_node_put(syscon_np);
251+
252+
return regmap;
253+
}
254+
EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle_args);
255+
227256
static int syscon_probe(struct platform_device *pdev)
228257
{
229258
struct device *dev = &pdev->dev;

include/linux/mfd/syscon.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ extern struct regmap *syscon_regmap_lookup_by_compatible(const char *s);
2323
extern struct regmap *syscon_regmap_lookup_by_phandle(
2424
struct device_node *np,
2525
const char *property);
26+
extern struct regmap *syscon_regmap_lookup_by_phandle_args(
27+
struct device_node *np,
28+
const char *property,
29+
int arg_count,
30+
unsigned int *out_args);
2631
#else
2732
static inline struct regmap *device_node_to_regmap(struct device_node *np)
2833
{
@@ -45,6 +50,15 @@ static inline struct regmap *syscon_regmap_lookup_by_phandle(
4550
{
4651
return ERR_PTR(-ENOTSUPP);
4752
}
53+
54+
static struct regmap *syscon_regmap_lookup_by_phandle_args(
55+
struct device_node *np,
56+
const char *property,
57+
int arg_count,
58+
unsigned int *out_args)
59+
{
60+
return ERR_PTR(-ENOTSUPP);
61+
}
4862
#endif
4963

5064
#endif /* __LINUX_MFD_SYSCON_H__ */

0 commit comments

Comments
 (0)