linux/drivers/pmdomain/renesas/rcar-sysc.c

// SPDX-License-Identifier: GPL-2.0
/*
 * R-Car SYSC Power management support
 *
 * Copyright (C) 2014  Magnus Damm
 * Copyright (C) 2015-2017 Glider bvba
 */

#include <linux/clk/renesas.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/mm.h>
#include <linux/of_address.h>
#include <linux/pm_domain.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/soc/renesas/rcar-sysc.h>

#include "rcar-sysc.h"

/* SYSC Common */
#define SYSCSR
#define SYSCISR
#define SYSCISCR
#define SYSCIER
#define SYSCIMR

/* SYSC Status Register */
#define SYSCSR_PONENB
#define SYSCSR_POFFENB

/*
 * Power Control Register Offsets inside the register block for each domain
 * Note: The "CR" registers for ARM cores exist on H1 only
 *	 Use WFI to power off, CPG/APMU to resume ARM cores on R-Car Gen2
 *	 Use PSCI on R-Car Gen3
 */
#define PWRSR_OFFS
#define PWROFFCR_OFFS
#define PWROFFSR_OFFS
#define PWRONCR_OFFS
#define PWRONSR_OFFS
#define PWRER_OFFS


#define SYSCSR_TIMEOUT
#define SYSCSR_DELAY_US

#define PWRER_RETRIES
#define PWRER_DELAY_US

#define SYSCISR_TIMEOUT
#define SYSCISR_DELAY_US

#define RCAR_PD_ALWAYS_ON

struct rcar_sysc_pd {};

static void __iomem *rcar_sysc_base;
static DEFINE_SPINLOCK(rcar_sysc_lock); /* SMP CPUs + I/O devices */
static u32 rcar_sysc_extmask_offs, rcar_sysc_extmask_val;

static int rcar_sysc_pwr_on_off(const struct rcar_sysc_pd *pd, bool on)
{}

static int rcar_sysc_power(const struct rcar_sysc_pd *pd, bool on)
{}

static bool rcar_sysc_power_is_off(const struct rcar_sysc_pd *pd)
{}

static inline struct rcar_sysc_pd *to_rcar_pd(struct generic_pm_domain *d)
{}

static int rcar_sysc_pd_power_off(struct generic_pm_domain *genpd)
{}

static int rcar_sysc_pd_power_on(struct generic_pm_domain *genpd)
{}

static bool has_cpg_mstp;

static int __init rcar_sysc_pd_setup(struct rcar_sysc_pd *pd)
{}

static const struct of_device_id rcar_sysc_matches[] __initconst =;

struct rcar_pm_domains {};

static struct genpd_onecell_data *rcar_sysc_onecell_data;

static int __init rcar_sysc_pd_init(void)
{}
early_initcall(rcar_sysc_pd_init);

#ifdef CONFIG_ARCH_R8A7779
static int rcar_sysc_power_cpu(unsigned int idx, bool on)
{
	struct generic_pm_domain *genpd;
	struct rcar_sysc_pd *pd;
	unsigned int i;

	if (!rcar_sysc_onecell_data)
		return -ENODEV;

	for (i = 0; i < rcar_sysc_onecell_data->num_domains; i++) {
		genpd = rcar_sysc_onecell_data->domains[i];
		if (!genpd)
			continue;

		pd = to_rcar_pd(genpd);
		if (!(pd->flags & PD_CPU) || pd->chan_bit != idx)
			continue;

		return rcar_sysc_power(pd, on);
	}

	return -ENOENT;
}

int rcar_sysc_power_down_cpu(unsigned int cpu)
{
	return rcar_sysc_power_cpu(cpu, false);
}

int rcar_sysc_power_up_cpu(unsigned int cpu)
{
	return rcar_sysc_power_cpu(cpu, true);
}
#endif /* CONFIG_ARCH_R8A7779 */