* published by the Free Software Foundation.
*/
+#include <linux/devfreq.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/err.h>
const struct rockchip_pmu_info *info;
struct mutex mutex; /* mutex lock for pmu */
struct genpd_onecell_data genpd_data;
+ struct devfreq *devfreq;
+ struct notifier_block dmc_nb;
struct generic_pm_domain *domains[];
};
+static struct rockchip_pmu *dmc_pmu;
+
#define to_rockchip_pd(gpd) container_of(gpd, struct rockchip_pm_domain, genpd)
#define DOMAIN(pwr, status, req, idle, ack, wakeup) \
return error;
}
+static int dmc_notify(struct notifier_block *nb, unsigned long event,
+ void *data)
+{
+ if (event == DEVFREQ_PRECHANGE)
+ mutex_lock(&dmc_pmu->mutex);
+ else if (event == DEVFREQ_POSTCHANGE)
+ mutex_unlock(&dmc_pmu->mutex);
+
+ return NOTIFY_OK;
+}
+
+int rockchip_pm_register_notify_to_dmc(struct devfreq *devfreq)
+{
+ if (!dmc_pmu)
+ return -ENOMEM;
+
+ dmc_pmu->devfreq = devfreq;
+ dmc_pmu->dmc_nb.notifier_call = dmc_notify;
+ devfreq_register_notifier(dmc_pmu->devfreq, &dmc_pmu->dmc_nb,
+ DEVFREQ_TRANSITION_NOTIFIER);
+ return 0;
+}
+EXPORT_SYMBOL(rockchip_pm_register_notify_to_dmc);
+
static int rockchip_pm_domain_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
of_genpd_add_provider_onecell(np, &pmu->genpd_data);
+ dmc_pmu = pmu;
+
return 0;
err_out:
--- /dev/null
+/*
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+#ifndef __SOC_ROCKCHIP_DMC_H
+#define __SOC_ROCKCHIP_DMC_H
+
+#include <linux/devfreq.h>
+
+int rockchip_pm_register_notify_to_dmc(struct devfreq *devfreq);
+
+#endif