Skip to content

Commit 4c277e2

Browse files
committed
Merge branch 'pm-opp'
* pm-opp: opp: Don't parse icc paths unnecessarily opp: Remove bandwidth votes when target_freq is zero opp: core: add regulators enable and disable opp: Reorder the code for !target_freq case opp: Expose bandwidth information via debugfs cpufreq: dt: Add support for interconnect bandwidth scaling opp: Update the bandwidth on OPP frequency changes opp: Add sanity checks in _read_opp_key() opp: Add support for parsing interconnect bandwidth interconnect: Remove unused module exit code from core interconnect: Disallow interconnect core to be built as a module interconnect: Add of_icc_get_by_index() helper function OPP: Add helpers for reading the binding properties dt-bindings: opp: Introduce opp-peak-kBps and opp-avg-kBps bindings
2 parents afd8d7c + 4573e9e commit 4c277e2

File tree

11 files changed

+473
-57
lines changed

11 files changed

+473
-57
lines changed

Documentation/devicetree/bindings/opp/opp.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,14 @@ properties.
8383

8484
Required properties:
8585
- opp-hz: Frequency in Hz, expressed as a 64-bit big-endian integer. This is a
86-
required property for all device nodes but devices like power domains. The
87-
power domain nodes must have another (implementation dependent) property which
88-
uniquely identifies the OPP nodes.
86+
required property for all device nodes, unless another "required" property to
87+
uniquely identify the OPP nodes exists. Devices like power domains must have
88+
another (implementation dependent) property.
89+
90+
- opp-peak-kBps: Peak bandwidth in kilobytes per second, expressed as an array
91+
of 32-bit big-endian integers. Each element of the array represents the
92+
peak bandwidth value of each interconnect path. The number of elements should
93+
match the number of interconnect paths.
8994

9095
Optional properties:
9196
- opp-microvolt: voltage in micro Volts.
@@ -132,6 +137,12 @@ Optional properties:
132137
- opp-level: A value representing the performance level of the device,
133138
expressed as a 32-bit integer.
134139

140+
- opp-avg-kBps: Average bandwidth in kilobytes per second, expressed as an array
141+
of 32-bit big-endian integers. Each element of the array represents the
142+
average bandwidth value of each interconnect path. The number of elements
143+
should match the number of interconnect paths. This property is only
144+
meaningful in OPP tables where opp-peak-kBps is present.
145+
135146
- clock-latency-ns: Specifies the maximum possible transition latency (in
136147
nanoseconds) for switching to this OPP from any other OPP.
137148

Documentation/devicetree/bindings/property-units.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ Temperature
4141
Pressure
4242
----------------------------------------
4343
-kpascal : kilopascal
44+
45+
Throughput
46+
----------------------------------------
47+
-kBps : kilobytes per second

drivers/cpufreq/cpufreq-dt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ static int resources_available(void)
121121

122122
clk_put(cpu_clk);
123123

124+
ret = dev_pm_opp_of_find_icc_paths(cpu_dev, NULL);
125+
if (ret)
126+
return ret;
127+
124128
name = find_supply_name(cpu_dev);
125129
/* Platform doesn't require regulator */
126130
if (!name)

drivers/interconnect/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
menuconfig INTERCONNECT
3-
tristate "On-Chip Interconnect management support"
3+
bool "On-Chip Interconnect management support"
44
help
55
Support for management of the on-chip interconnects.
66

drivers/interconnect/core.c

Lines changed: 73 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,9 @@ static struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec)
351351
}
352352

353353
/**
354-
* of_icc_get() - get a path handle from a DT node based on name
354+
* of_icc_get_by_index() - get a path handle from a DT node based on index
355355
* @dev: device pointer for the consumer device
356-
* @name: interconnect path name
356+
* @idx: interconnect path index
357357
*
358358
* This function will search for a path between two endpoints and return an
359359
* icc_path handle on success. Use icc_put() to release constraints when they
@@ -365,13 +365,12 @@ static struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec)
365365
* Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned
366366
* when the API is disabled or the "interconnects" DT property is missing.
367367
*/
368-
struct icc_path *of_icc_get(struct device *dev, const char *name)
368+
struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
369369
{
370-
struct icc_path *path = ERR_PTR(-EPROBE_DEFER);
370+
struct icc_path *path;
371371
struct icc_node *src_node, *dst_node;
372-
struct device_node *np = NULL;
372+
struct device_node *np;
373373
struct of_phandle_args src_args, dst_args;
374-
int idx = 0;
375374
int ret;
376375

377376
if (!dev || !dev->of_node)
@@ -391,12 +390,6 @@ struct icc_path *of_icc_get(struct device *dev, const char *name)
391390
* lets support only global ids and extend this in the future if needed
392391
* without breaking DT compatibility.
393392
*/
394-
if (name) {
395-
idx = of_property_match_string(np, "interconnect-names", name);
396-
if (idx < 0)
397-
return ERR_PTR(idx);
398-
}
399-
400393
ret = of_parse_phandle_with_args(np, "interconnects",
401394
"#interconnect-cells", idx * 2,
402395
&src_args);
@@ -439,19 +432,62 @@ struct icc_path *of_icc_get(struct device *dev, const char *name)
439432
return path;
440433
}
441434

442-
if (name)
443-
path->name = kstrdup_const(name, GFP_KERNEL);
444-
else
445-
path->name = kasprintf(GFP_KERNEL, "%s-%s",
446-
src_node->name, dst_node->name);
447-
435+
path->name = kasprintf(GFP_KERNEL, "%s-%s",
436+
src_node->name, dst_node->name);
448437
if (!path->name) {
449438
kfree(path);
450439
return ERR_PTR(-ENOMEM);
451440
}
452441

453442
return path;
454443
}
444+
EXPORT_SYMBOL_GPL(of_icc_get_by_index);
445+
446+
/**
447+
* of_icc_get() - get a path handle from a DT node based on name
448+
* @dev: device pointer for the consumer device
449+
* @name: interconnect path name
450+
*
451+
* This function will search for a path between two endpoints and return an
452+
* icc_path handle on success. Use icc_put() to release constraints when they
453+
* are not needed anymore.
454+
* If the interconnect API is disabled, NULL is returned and the consumer
455+
* drivers will still build. Drivers are free to handle this specifically,
456+
* but they don't have to.
457+
*
458+
* Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned
459+
* when the API is disabled or the "interconnects" DT property is missing.
460+
*/
461+
struct icc_path *of_icc_get(struct device *dev, const char *name)
462+
{
463+
struct device_node *np;
464+
int idx = 0;
465+
466+
if (!dev || !dev->of_node)
467+
return ERR_PTR(-ENODEV);
468+
469+
np = dev->of_node;
470+
471+
/*
472+
* When the consumer DT node do not have "interconnects" property
473+
* return a NULL path to skip setting constraints.
474+
*/
475+
if (!of_find_property(np, "interconnects", NULL))
476+
return NULL;
477+
478+
/*
479+
* We use a combination of phandle and specifier for endpoint. For now
480+
* lets support only global ids and extend this in the future if needed
481+
* without breaking DT compatibility.
482+
*/
483+
if (name) {
484+
idx = of_property_match_string(np, "interconnect-names", name);
485+
if (idx < 0)
486+
return ERR_PTR(idx);
487+
}
488+
489+
return of_icc_get_by_index(dev, idx);
490+
}
455491
EXPORT_SYMBOL_GPL(of_icc_get);
456492

457493
/**
@@ -478,6 +514,24 @@ void icc_set_tag(struct icc_path *path, u32 tag)
478514
}
479515
EXPORT_SYMBOL_GPL(icc_set_tag);
480516

517+
/**
518+
* icc_get_name() - Get name of the icc path
519+
* @path: reference to the path returned by icc_get()
520+
*
521+
* This function is used by an interconnect consumer to get the name of the icc
522+
* path.
523+
*
524+
* Returns a valid pointer on success, or NULL otherwise.
525+
*/
526+
const char *icc_get_name(struct icc_path *path)
527+
{
528+
if (!path)
529+
return NULL;
530+
531+
return path->name;
532+
}
533+
EXPORT_SYMBOL_GPL(icc_get_name);
534+
481535
/**
482536
* icc_set_bw() - set bandwidth constraints on an interconnect path
483537
* @path: reference to the path returned by icc_get()
@@ -908,12 +962,7 @@ static int __init icc_init(void)
908962
return 0;
909963
}
910964

911-
static void __exit icc_exit(void)
912-
{
913-
debugfs_remove_recursive(icc_debugfs_dir);
914-
}
915-
module_init(icc_init);
916-
module_exit(icc_exit);
965+
device_initcall(icc_init);
917966

918967
MODULE_AUTHOR("Georgi Djakov <[email protected]>");
919968
MODULE_DESCRIPTION("Interconnect Driver Core");

0 commit comments

Comments
 (0)