Skip to content

Commit 7ad91e9

Browse files
committed
mdomain: Merge branch rockchip into next
Merge the immutable branch rockchip into next, to allow it to be tested together with the changes that are targeted for v6.15. Signed-off-by: Ulf Hansson <[email protected]>
2 parents 43b73a5 + 58ebba3 commit 7ad91e9

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

drivers/pmdomain/core.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,37 @@ bool dev_pm_genpd_get_hwmode(struct device *dev)
697697
}
698698
EXPORT_SYMBOL_GPL(dev_pm_genpd_get_hwmode);
699699

700+
/**
701+
* dev_pm_genpd_rpm_always_on() - Control if the PM domain can be powered off.
702+
*
703+
* @dev: Device for which the PM domain may need to stay on for.
704+
* @on: Value to set or unset for the condition.
705+
*
706+
* For some usecases a consumer driver requires its device to remain power-on
707+
* from the PM domain perspective during runtime. This function allows the
708+
* behaviour to be dynamically controlled for a device attached to a genpd.
709+
*
710+
* It is assumed that the users guarantee that the genpd wouldn't be detached
711+
* while this routine is getting called.
712+
*
713+
* Return: Returns 0 on success and negative error values on failures.
714+
*/
715+
int dev_pm_genpd_rpm_always_on(struct device *dev, bool on)
716+
{
717+
struct generic_pm_domain *genpd;
718+
719+
genpd = dev_to_genpd_safe(dev);
720+
if (!genpd)
721+
return -ENODEV;
722+
723+
genpd_lock(genpd);
724+
dev_gpd_data(dev)->rpm_always_on = on;
725+
genpd_unlock(genpd);
726+
727+
return 0;
728+
}
729+
EXPORT_SYMBOL_GPL(dev_pm_genpd_rpm_always_on);
730+
700731
static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed)
701732
{
702733
unsigned int state_idx = genpd->state_idx;
@@ -868,6 +899,10 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
868899
if (!pm_runtime_suspended(pdd->dev) ||
869900
irq_safe_dev_in_sleep_domain(pdd->dev, genpd))
870901
not_suspended++;
902+
903+
/* The device may need its PM domain to stay powered on. */
904+
if (to_gpd_data(pdd)->rpm_always_on)
905+
return -EBUSY;
871906
}
872907

873908
if (not_suspended > 1 || (not_suspended == 1 && !one_dev_on))

drivers/pmdomain/rockchip/pm-domains.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright (c) 2015 ROCKCHIP, Co. Ltd.
66
*/
77

8+
#include <linux/arm-smccc.h>
89
#include <linux/io.h>
910
#include <linux/iopoll.h>
1011
#include <linux/err.h>
@@ -20,6 +21,7 @@
2021
#include <linux/regmap.h>
2122
#include <linux/mfd/syscon.h>
2223
#include <soc/rockchip/pm_domains.h>
24+
#include <soc/rockchip/rockchip_sip.h>
2325
#include <dt-bindings/power/px30-power.h>
2426
#include <dt-bindings/power/rockchip,rv1126-power.h>
2527
#include <dt-bindings/power/rk3036-power.h>
@@ -540,6 +542,7 @@ static void rockchip_do_pmu_set_power_domain(struct rockchip_pm_domain *pd,
540542
struct generic_pm_domain *genpd = &pd->genpd;
541543
u32 pd_pwr_offset = pd->info->pwr_offset;
542544
bool is_on, is_mem_on = false;
545+
struct arm_smccc_res res;
543546

544547
if (pd->info->pwr_mask == 0)
545548
return;
@@ -567,6 +570,11 @@ static void rockchip_do_pmu_set_power_domain(struct rockchip_pm_domain *pd,
567570
genpd->name, is_on);
568571
return;
569572
}
573+
574+
/* Inform firmware to keep this pd on or off */
575+
arm_smccc_smc(ROCKCHIP_SIP_SUSPEND_MODE, ROCKCHIP_SLEEP_PD_CONFIG,
576+
pmu->info->pwr_offset + pd_pwr_offset,
577+
pd->info->pwr_mask, on, 0, 0, 0, &res);
570578
}
571579

572580
static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on)

include/linux/pm_domain.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ struct generic_pm_domain_data {
261261
unsigned int rpm_pstate;
262262
unsigned int opp_token;
263263
bool hw_mode;
264+
bool rpm_always_on;
264265
void *data;
265266
};
266267

@@ -293,6 +294,7 @@ ktime_t dev_pm_genpd_get_next_hrtimer(struct device *dev);
293294
void dev_pm_genpd_synced_poweroff(struct device *dev);
294295
int dev_pm_genpd_set_hwmode(struct device *dev, bool enable);
295296
bool dev_pm_genpd_get_hwmode(struct device *dev);
297+
int dev_pm_genpd_rpm_always_on(struct device *dev, bool on);
296298

297299
extern struct dev_power_governor simple_qos_governor;
298300
extern struct dev_power_governor pm_domain_always_on_gov;
@@ -376,6 +378,11 @@ static inline bool dev_pm_genpd_get_hwmode(struct device *dev)
376378
return false;
377379
}
378380

381+
static inline int dev_pm_genpd_rpm_always_on(struct device *dev, bool on)
382+
{
383+
return -EOPNOTSUPP;
384+
}
385+
379386
#define simple_qos_governor (*(struct dev_power_governor *)(NULL))
380387
#define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL))
381388
#endif

include/soc/rockchip/rockchip_sip.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#ifndef __SOC_ROCKCHIP_SIP_H
77
#define __SOC_ROCKCHIP_SIP_H
88

9+
#define ROCKCHIP_SIP_SUSPEND_MODE 0x82000003
10+
#define ROCKCHIP_SLEEP_PD_CONFIG 0xff
11+
912
#define ROCKCHIP_SIP_DRAM_FREQ 0x82000008
1013
#define ROCKCHIP_SIP_CONFIG_DRAM_INIT 0x00
1114
#define ROCKCHIP_SIP_CONFIG_DRAM_SET_RATE 0x01

0 commit comments

Comments
 (0)