ux500 suspend-resume
Subsystems (13)
v2 cover ux500 suspend-resume
This patch series adds support for ux500 suspend/resume operations with the sleep state ApSleep. (That is sleeping with APE power domain turned off and ARM power domain in retention).
Also this series adds the APE power domain to genpd and introduces a new type of genpd notifiers that are used for the special case when the context of a device needs to be restored directly after a CPU coupled power domain (APE) is turned on. Devices that need to be restored in such a way are also included in this series.
Note that I will be out of office for three weeks and will not be able to respond myself to comments on this patch set. But comments are much appreciated.
Changes v1->v2:
* Added ICN driver and device
* Added TPIU driver and device
* Updated u8500 clk driver and device
Rickard Andersson (12):
mfd: db8500: Add IO force function
ARM: ux500: Add platform suspend ops
PM / Domains: Add on-off notifiers
PM / Domains: Lookup domain by name
ARM: ux500: Create APE generic power domain
clk: ux500: Add PRCC power management
ARM: ux500: Create u8500-clk device
ARM: ux500: Add ApSleep state to suspend
drivers: bus: ux500: Add ICN driver
ARM: ux500: Create ICN device
misc: ux500: Add TPIU driver
ARM: ux500: Create TPIU device
arch/arm/boot/dts/dbx5x0.dtsi | 19 ++ arch/arm/mach-ux500/Kconfig | 1 + arch/arm/mach-ux500/Makefile | 1 + arch/arm/mach-ux500/board-mop500.c | 27 +- arch/arm/mach-ux500/cpu-db8500.c | 3 + arch/arm/mach-ux500/devices-common.c | 32 +++ arch/arm/mach-ux500/devices-common.h | 2 + arch/arm/mach-ux500/devices-db8500.c | 41 +++ arch/arm/mach-ux500/devices-db8500.h | 1 + arch/arm/mach-ux500/suspend.c | 90 ++++++ drivers/base/power/domain.c | 65 ++++- drivers/bus/Makefile | 1 + drivers/bus/dbx500-icn.c | 522 +++++++++++++++++++++++++++++++++++ drivers/clk/ux500/clk-prcc.c | 71 ++++- drivers/clk/ux500/clk.h | 5 + drivers/clk/ux500/u8500_clk.c | 88 ++++++ drivers/mfd/db8500-prcmu.c | 9 + drivers/misc/Makefile | 1 + drivers/misc/dbx500-tpiu.c | 182 ++++++++++++ include/linux/mfd/db8500-prcmu.h | 1 + include/linux/mfd/dbx500-prcmu.h | 5 + include/linux/pm_domain.h | 28 +- 22 files changed, 1191 insertions(+), 4 deletions(-) create mode 100644 arch/arm/mach-ux500/suspend.c create mode 100644 drivers/bus/dbx500-icn.c create mode 100644 drivers/misc/dbx500-tpiu.c
Signature · 1 line
1.8.2
PATCH v2 1/12 mfd: db8500: Add IO force function
The IO force signal needs to be controlled when the system enters/exits the sleep state ApSleep. This hardware signal tells the system that some pins could be driven by GPIO settings instead of directly from the hardware block.
--- drivers/mfd/db8500-prcmu.c | 9 +++++++++ include/linux/mfd/db8500-prcmu.h | 1 + include/linux/mfd/dbx500-prcmu.h | 5 +++++ 3 files changed, 15 insertions(+)
drivers/mfd/db8500-prcmu.c +9 -0
@@ -879,6 +879,15 @@ bool db8500_prcmu_pending_irq(void)return false; } +void db8500_prcmu_set_ioforce (bool enable) +{ +u32 val =readl (PRCM_IOCR ) & ~PRCM_IOCR_IOFORCE ; + +if (enable) + val |=PRCM_IOCR_IOFORCE ; +writel (val,PRCM_IOCR ); +} +/* * This function checks if the specified cpu is in in WFI. It's usage * makes sense only if the gic is decoupled with the db8500_prcmu_gic_decouple
include/linux/mfd/db8500-prcmu.h +1 -0
@@ -547,6 +547,7 @@ int db8500_prcmu_gic_recouple(void);int db8500_prcmu_copy_gic_settings (void );bool db8500_prcmu_gic_pending_irq (void );bool db8500_prcmu_pending_irq (void ); +void db8500_prcmu_set_ioforce (bool enable);bool db8500_prcmu_is_cpu_in_wfi (int cpu);void db8500_prcmu_enable_wakeups (u32 wakeups);int db8500_prcmu_set_epod (u16 epod_id,u8 epod_state);
include/linux/mfd/dbx500-prcmu.h +5 -0
@@ -267,6 +267,11 @@ static inline bool prcmu_pending_irq(void)return db8500_prcmu_pending_irq (); } +static inline void prcmu_set_ioforce (bool force) +{ +return db8500_prcmu_set_ioforce (force); +} +static inline int prcmu_set_epod (u16 epod_id,u8 epod_state) {return db8500_prcmu_set_epod (epod_id, epod_state);
Signature · 1 line
1.8.2
PATCH v2 2/12 ARM: ux500: Add platform suspend ops
In reply to Rickard AnderssonSupport for platform suspend operation
WFI (Wait For Interrupt) is added.
--- arch/arm/mach-ux500/Makefile | 1 + arch/arm/mach-ux500/suspend.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 arch/arm/mach-ux500/suspend.c
arch/arm/mach-ux500/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-y := cpu.o devices.o devices-common.o \ id.o usb.o timer.o obj-$(CONFIG_CPU_IDLE) += cpuidle.o +obj-$(CONFIG_SUSPEND) += suspend.o obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o obj-$(CONFIG_UX500_SOC_DB8500) += cpu-db8500.o devices-db8500.o obj-$(CONFIG_MACH_MOP500) += board-mop500.o board-mop500-sdi.o \
arch/arm/mach-ux500/suspend.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (C) STMicroelectronics 2009 +* Copyright (C) ST-Ericsson SA 2010-2013 +* +* License Terms: GNU General Public License v2 +* +* Authors: Rickard Andersson <[email protected]>, +* Jonas Aaberg <[email protected]>, +* Sundar Iyer for ST-Ericsson. +*/ + +#include <linux/suspend.h> + +static int ux500_suspend_enter (suspend_state_t state) +{ +cpu_do_idle (); +return 0 ; +} + +static int ux500_suspend_valid (suspend_state_t state) +{ +return state ==PM_SUSPEND_MEM || state ==PM_SUSPEND_STANDBY ; +} + +static const struct platform_suspend_ops ux500_suspend_ops = { + .enter = ux500_suspend_enter, + .valid = ux500_suspend_valid, +}; + +static __init int ux500_suspend_init (void ) +{ +suspend_set_ops (&ux500_suspend_ops); +return 0 ; +} +device_initcall (ux500_suspend_init);
Signature · 1 line
1.8.2
PATCH v2 3/12 PM / Domains: Add on-off notifiers
In reply to Rickard AnderssonSome drivers needs to restore their context directly when a power domain is activated. For example a driver handling system bus settings must be able to restore context before the bus is being used for the first time. Other examples could be clock settings hardware blocks and special debugging hardware blocks which should be restored as early as possible in order to be able to debug direcly from waking up. Typically these notifers are needed in systems with CPU coupled power domains. The notifiers are intended to be trigged by cpuidle driver or the suspend ops hooks.
The drivers that needs to use these notifiers are some special cases. Most drivers should not use this method and instead control their context via the pm_runtime interface.
---
I believe notifiers are the best solution to the problem of restoring context early when waking up after sleep. It is similar to what is done in /kernel/cpu_pm.c but but for a generic power domain instead.
An alternative solution could be to try to call the drivers runtime_resume/runtime_suspend callbacks instead via genpd from cpuidle or suspend/resume. I do not recommend that solution for the following reasons:
* Altered use of runtime PM. As it is today the driver itself controls when to runtime-suspend/runtime-resume.
* Runtime PM is disabled during late stages of suspend.
* Complicates runtime PM for a few special cases.
--- drivers/base/power/domain.c | 63 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 22 ++++++++++++++++ 2 files changed, 85 insertions(+)
drivers/base/power/domain.c +63 -0
@@ -1956,6 +1956,68 @@ int pm_genpd_name_detach_cpuidle(const char *name)return pm_genpd_detach_cpuidle (pm_genpd_lookup_name (name)); } +/** +* pm_genpd_register_on_off_notifier - Register to early power on / +* late power off notifications. +* Only use this function if absolutly needed. It is only intended to be +* used for power domains that are coupled with the CPU, that is, power +* domains being controlled from cpuidle and the platform suspend ops hooks. +* Also only devices that needs their context to be restored directly when +* leaving a sleep state should use this method. Most devices should be +* fine handling their context and power domains via pm_runtime. +* @dev: Device to register. +* @nb: Notifier block to be registered. +*/ +int pm_genpd_register_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +struct generic_pm_domain *genpd; + +dev_dbg (dev,"%s()\n" , __func__); + + genpd =dev_to_genpd (dev); + +return atomic_notifier_chain_register (&genpd->on_off_notifier, nb); +} + +/** +* pm_genpd_unregister_on_off_notifier - Unregister to early power on / +* late power off notification. +* @dev: Device to unregister. +* @nb: Notifier block to be unregistered. +*/ +int pm_genpd_unregister_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +struct generic_pm_domain *genpd; + +dev_dbg (dev,"%s()\n" , __func__); + + genpd =dev_to_genpd (dev); + +return atomic_notifier_chain_unregister (&genpd->on_off_notifier, nb); +} + +/** +* pm_genpd_notify_power_on_off - Notify that the CPU coupled power +* domain is going to be powered off or has been powered on.5D +* Intended users of this function are cpuidle drivers and the platform +* suspend operations implementation. +* @genpd: pm domain that will change state. +* @power_on_off: true = has been powered on, false = will power off. +*/ +int pm_genpd_notify_power_on_off (struct generic_pm_domain *genpd, +bool power_on_off) +{ +if (IS_ERR_OR_NULL (genpd)) +return -EINVAL ; + +atomic_notifier_call_chain ((&genpd->on_off_notifier), + power_on_off,NULL ); + +return 0 ; +} +/* Default device callbacks for generic PM domains. */ /**
@@ -2137,6 +2199,7 @@ void pm_genpd_init(struct generic_pm_domain *genpd,atomic_set (&genpd->sd_count,0 ); genpd->status = is_off ?GPD_STATE_POWER_OFF :GPD_STATE_ACTIVE ;init_waitqueue_head (&genpd->status_wait_queue); +ATOMIC_INIT_NOTIFIER_HEAD (&genpd->on_off_notifier); genpd->poweroff_task =NULL ; genpd->resume_count =0 ; genpd->device_count =0 ;
include/linux/pm_domain.h +22 -0
@@ -82,6 +82,7 @@ struct generic_pm_domain {bool cached_power_down_ok;struct device_node *of_node;/* Node in device tree */ struct gpd_cpu_data *cpu_data; +struct atomic_notifier_head on_off_notifier; };static inline struct generic_pm_domain *pd_to_genpd (struct dev_pm_domain *pd)
@@ -159,6 +160,12 @@ extern int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state);extern int pm_genpd_name_attach_cpuidle (const char *name,int state);extern int pm_genpd_detach_cpuidle (struct generic_pm_domain *genpd);extern int pm_genpd_name_detach_cpuidle (const char *name); +extern int pm_genpd_register_on_off_notifier (struct device *dev, +struct notifier_block *nb); +extern int pm_genpd_unregister_on_off_notifier (struct device *dev, +struct notifier_block *nb); +extern int pm_genpd_notify_power_on_off (struct generic_pm_domain *genpd, +bool power_on_off);extern void pm_genpd_init (struct generic_pm_domain *genpd,struct dev_power_governor *gov,bool is_off);
@@ -243,6 +250,21 @@ static inline int pm_genpd_name_detach_cpuidle(const char *name) {return -ENOSYS ; } +static inline int pm_genpd_register_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +return -ENOSYS ; +} +static inline int pm_genpd_unregister_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +return -ENOSYS ; +} +static inline int pm_genpd_notify_power_on_off (struct generic_pm_domain *genpd, +bool power_on_off) +{ +return -ENOSYS ; +}static inline void pm_genpd_init (struct generic_pm_domain *genpd,struct dev_power_governor *gov,bool is_off) {
Signature · 1 line
1.8.2
PATCH v2 3/12 PM / Domains: Add on-off notifiers
Quoted 17 lines · Rickard Andersson
Some drivers needs to restore their context directly when a power domain is activated. For example a driver handling system bus settings must be able to restore context before the bus is being used for the first time. Other examples could be clock settings hardware blocks and special debugging hardware blocks which should be restored as early as possible in order to be able to debug direcly from waking up. Typically these notifers are needed in systems with CPU coupled power domains. The notifiers are intended to be trigged by cpuidle driver or the suspend ops hooks.
The drivers that needs to use these notifiers are some special cases. Most drivers should not use this method and instead control their context via the
pm_runtimeinterface.
Quoted 4 lines
Signed-off-by Rickard Andersson <[email protected]>---
I believe notifiers are the best solution to the problem of restoring context early when waking up after sleep.
I don't.
Quoted 1 line
It is similar to what is done in /kernel/cpu_pm.c
Which is causing tons of problems to happen.
Quoted 1 line
but but for a generic power domain instead.
Which has a potential of being even worse.
Quoted 7 lines
An alternative solution could be to try to call the drivers runtime_resume/runtime_suspend callbacks instead via genpd from cpuidle or suspend/resume. I do not recommend that solution for the following reasons:
* Altered use of runtime PM. As it is today the driver itself controls when to runtime-suspend/runtime-resume.
That's not correct.
Quoted 2 lines
* Runtime PM is disabled during late stages of suspend.
* Complicates runtime PM for a few special cases.
Well, quite frankly, it is hard to say what problem this is supposed to address from your description. Care to give some more details?
Rafael
Quoted 134 lines
--- drivers/base/power/domain.c | 63 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 22 ++++++++++++++++ 2 files changed, 85 insertions(+)drivers/base/power/domain.c +63
-0@@ -1956,6 +1956,68 @@ int pm_genpd_name_detach_cpuidle(const char *name)return pm_genpd_detach_cpuidle (pm_genpd_lookup_name (name)); } +/** +* pm_genpd_register_on_off_notifier - Register to early power on / +* late power off notifications. +* Only use this function if absolutly needed. It is only intended to be +* used for power domains that are coupled with the CPU, that is, power +* domains being controlled from cpuidle and the platform suspend ops hooks. +* Also only devices that needs their context to be restored directly when +* leaving a sleep state should use this method. Most devices should be +* fine handling their context and power domains via pm_runtime. +* @dev: Device to register. +* @nb: Notifier block to be registered. +*/ +int pm_genpd_register_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +struct generic_pm_domain *genpd; + +dev_dbg (dev,"%s()\n" , __func__); + + genpd =dev_to_genpd (dev); + +return atomic_notifier_chain_register (&genpd->on_off_notifier, nb); +} + +/** +* pm_genpd_unregister_on_off_notifier - Unregister to early power on / +* late power off notification. +* @dev: Device to unregister. +* @nb: Notifier block to be unregistered. +*/ +int pm_genpd_unregister_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +struct generic_pm_domain *genpd; + +dev_dbg (dev,"%s()\n" , __func__); + + genpd =dev_to_genpd (dev); + +return atomic_notifier_chain_unregister (&genpd->on_off_notifier, nb); +} + +/** +* pm_genpd_notify_power_on_off - Notify that the CPU coupled power +* domain is going to be powered off or has been powered on.5D +* Intended users of this function are cpuidle drivers and the platform +* suspend operations implementation. +* @genpd: pm domain that will change state. +* @power_on_off: true = has been powered on, false = will power off. +*/ +int pm_genpd_notify_power_on_off (struct generic_pm_domain *genpd, +bool power_on_off) +{ +if (IS_ERR_OR_NULL (genpd)) +return -EINVAL ; + +atomic_notifier_call_chain ((&genpd->on_off_notifier), + power_on_off,NULL ); + +return 0 ; +} +/* Default device callbacks for generic PM domains. */ /** @@ -2137,6 +2199,7 @@ void pm_genpd_init(struct generic_pm_domain *genpd,atomic_set (&genpd->sd_count,0 ); genpd->status = is_off ?GPD_STATE_POWER_OFF :GPD_STATE_ACTIVE ;init_waitqueue_head (&genpd->status_wait_queue); +ATOMIC_INIT_NOTIFIER_HEAD (&genpd->on_off_notifier); genpd->poweroff_task =NULL ; genpd->resume_count =0 ; genpd->device_count =0 ;include/linux/pm_domain.h +22
-0@@ -82,6 +82,7 @@ struct generic_pm_domain {bool cached_power_down_ok;struct device_node *of_node;/* Node in device tree */ struct gpd_cpu_data *cpu_data; +struct atomic_notifier_head on_off_notifier; };static inline struct generic_pm_domain *pd_to_genpd (struct dev_pm_domain *pd)@@ -159,6 +160,12 @@ extern int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state);extern int pm_genpd_name_attach_cpuidle (const char *name,int state);extern int pm_genpd_detach_cpuidle (struct generic_pm_domain *genpd);extern int pm_genpd_name_detach_cpuidle (const char *name); +extern int pm_genpd_register_on_off_notifier (struct device *dev, +struct notifier_block *nb); +extern int pm_genpd_unregister_on_off_notifier (struct device *dev, +struct notifier_block *nb); +extern int pm_genpd_notify_power_on_off (struct generic_pm_domain *genpd, +bool power_on_off);extern void pm_genpd_init (struct generic_pm_domain *genpd,struct dev_power_governor *gov,bool is_off);@@ -243,6 +250,21 @@ static inline int pm_genpd_name_detach_cpuidle(const char *name) {return -ENOSYS ; } +static inline int pm_genpd_register_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +return -ENOSYS ; +} +static inline int pm_genpd_unregister_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +return -ENOSYS ; +} +static inline int pm_genpd_notify_power_on_off (struct generic_pm_domain *genpd, +bool power_on_off) +{ +return -ENOSYS ; +}static inline void pm_genpd_init (struct generic_pm_domain *genpd,struct dev_power_governor *gov,bool is_off) {
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
PATCH v2 3/12 PM / Domains: Add on-off notifiers
Quoted 18 lines · Rafael J. Wysocki
Quoted 17 lines · Rickard Andersson
Some drivers needs to restore their context directly when a power domain is activated. For example a driver handling system bus settings must be able to restore context before the bus is being used for the first time. Other examples could be clock settings hardware blocks and special debugging hardware blocks which should be restored as early as possible in order to be able to debug direcly from waking up. Typically these notifers are needed in systems with CPU coupled power domains. The notifiers are intended to be trigged by cpuidle driver or the suspend ops hooks.
The drivers that needs to use these notifiers are some special cases. Most drivers should not use this method and instead control their context via the
pm_runtimeinterface.
Quoted 5 lines
Quoted 4 lines
Signed-off-by Rickard Andersson<[email protected]>---
I believe notifiers are the best solution to the problem of restoring context early when waking up after sleep.I don't.
Some motivation would be good.
Quoted 2 lines
Quoted 1 line
It is similar to what is done in /kernel/cpu_pm.c
Which is causing tons of problems to happen.
What type of problems have you seen with the notifiers in "/kernel/cpu_pm.c"?
Quoted 10 lines
Quoted 1 line
but but for a generic power domain instead.
Which has a potential of being even worse.
Quoted 7 lines
An alternative solution could be to try to call the drivers runtime_resume/runtime_suspend callbacks instead via genpd from cpuidle or suspend/resume. I do not recommend that solution for the following reasons:
* Altered use of runtime PM. As it is today the driver itself controls when to runtime-suspend/runtime-resume.
Quoted 8 lines
That's not correct.
Quoted 2 lines
* Runtime PM is disabled during late stages of suspend.
* Complicates runtime PM for a few special cases.Well, quite frankly, it is hard to say what problem this is supposed to address from your description. Care to give some more details?
Rafael
The problem is that some hardware blocks needs to be restored as early as possible after leaving the U8500 CPU coupled sleep state ApSleep (APE power domain being off). This is comparable to CPU needing early restore using "/kernel/cpu_pm.c" but for the APE power domain instead. One could argue that one should save/restore the context directly in the cpuidle driver instead but that means duplicated code since hardware block registers will be modified both in the block driver and in the cpuidle driver. With the notifiers solution the cpuidle driver does not need to be aware of which hardware blocks that is being included in the APE power domain (needing early context restore), it is the same for system suspend/resume. Cpuidle and system suspend/resume should use the function pm_genpd_notify_power_on_off(..) to tell the system that it will change/has changed the state of a certain power domain. Note that only a few of the hardware blocks in the APE power domain needs to use these notifiers, most drivers will do fine using pm_runtime.
If you for example look at patch "[PATCH V2 06/12] clk: ux500: Add PRCC power management" you can see that all PRCC clock registers are handled in the clock driver. There is no need to put duplicated code handling clocks context in "/arch/arm/mach-ux500/" for suspend/resume and cpuidle. Clock settings should be set directly as soon as possible after leaving the sleep state ApSleep, that is why the notifiers are being used.
If you do not think this mechanism is a way forward then please advice how you think is should be solved.
Thanks
Rickard
Quoted 135 lines
Quoted 135 lines
--- drivers/base/power/domain.c | 63 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 22 ++++++++++++++++ 2 files changed, 85 insertions(+)drivers/base/power/domain.c +63
-0@@ -1956,6 +1956,68 @@ int pm_genpd_name_detach_cpuidle(const char *name)return pm_genpd_detach_cpuidle (pm_genpd_lookup_name (name)); } +/** +* pm_genpd_register_on_off_notifier - Register to early power on / +* late power off notifications. +* Only use this function if absolutly needed. It is only intended to be +* used for power domains that are coupled with the CPU, that is, power +* domains being controlled from cpuidle and the platform suspend ops hooks. +* Also only devices that needs their context to be restored directly when +* leaving a sleep state should use this method. Most devices should be +* fine handling their context and power domains via pm_runtime. +* @dev: Device to register. +* @nb: Notifier block to be registered. +*/ +int pm_genpd_register_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +struct generic_pm_domain *genpd; + +dev_dbg (dev,"%s()\n" , __func__); + + genpd =dev_to_genpd (dev); + +return atomic_notifier_chain_register (&genpd->on_off_notifier, nb); +} + +/** +* pm_genpd_unregister_on_off_notifier - Unregister to early power on / +* late power off notification. +* @dev: Device to unregister. +* @nb: Notifier block to be unregistered. +*/ +int pm_genpd_unregister_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +struct generic_pm_domain *genpd; + +dev_dbg (dev,"%s()\n" , __func__); + + genpd =dev_to_genpd (dev); + +return atomic_notifier_chain_unregister (&genpd->on_off_notifier, nb); +} + +/** +* pm_genpd_notify_power_on_off - Notify that the CPU coupled power +* domain is going to be powered off or has been powered on.5D +* Intended users of this function are cpuidle drivers and the platform +* suspend operations implementation. +* @genpd: pm domain that will change state. +* @power_on_off: true = has been powered on, false = will power off. +*/ +int pm_genpd_notify_power_on_off (struct generic_pm_domain *genpd, +bool power_on_off) +{ +if (IS_ERR_OR_NULL (genpd)) +return -EINVAL ; + +atomic_notifier_call_chain ((&genpd->on_off_notifier), + power_on_off,NULL ); + +return 0 ; +} +/* Default device callbacks for generic PM domains. */ /** @@ -2137,6 +2199,7 @@ void pm_genpd_init(struct generic_pm_domain *genpd,atomic_set (&genpd->sd_count,0 ); genpd->status = is_off ?GPD_STATE_POWER_OFF :GPD_STATE_ACTIVE ;init_waitqueue_head (&genpd->status_wait_queue); +ATOMIC_INIT_NOTIFIER_HEAD (&genpd->on_off_notifier); genpd->poweroff_task =NULL ; genpd->resume_count =0 ; genpd->device_count =0 ;include/linux/pm_domain.h +22
-0@@ -82,6 +82,7 @@ struct generic_pm_domain {bool cached_power_down_ok;struct device_node *of_node;/* Node in device tree */ struct gpd_cpu_data *cpu_data; +struct atomic_notifier_head on_off_notifier; };static inline struct generic_pm_domain *pd_to_genpd (struct dev_pm_domain *pd)@@ -159,6 +160,12 @@ extern int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state);extern int pm_genpd_name_attach_cpuidle (const char *name,int state);extern int pm_genpd_detach_cpuidle (struct generic_pm_domain *genpd);extern int pm_genpd_name_detach_cpuidle (const char *name); +extern int pm_genpd_register_on_off_notifier (struct device *dev, +struct notifier_block *nb); +extern int pm_genpd_unregister_on_off_notifier (struct device *dev, +struct notifier_block *nb); +extern int pm_genpd_notify_power_on_off (struct generic_pm_domain *genpd, +bool power_on_off);extern void pm_genpd_init (struct generic_pm_domain *genpd,struct dev_power_governor *gov,bool is_off);@@ -243,6 +250,21 @@ static inline int pm_genpd_name_detach_cpuidle(const char *name) {return -ENOSYS ; } +static inline int pm_genpd_register_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +return -ENOSYS ; +} +static inline int pm_genpd_unregister_on_off_notifier (struct device *dev, +struct notifier_block *nb) +{ +return -ENOSYS ; +} +static inline int pm_genpd_notify_power_on_off (struct generic_pm_domain *genpd, +bool power_on_off) +{ +return -ENOSYS ; +}static inline void pm_genpd_init (struct generic_pm_domain *genpd,struct dev_power_governor *gov,bool is_off) {
PATCH v2 3/12 PM / Domains: Add on-off notifiers
Quoted 9 lines · Rickard Andersson
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Rickard Andersson
I believe notifiers are the best solution to the problem of restoring context early when waking up after sleep.
I don't.
Some motivation would be good.
(...)
Quoted 6 lines
Quoted 2 lines
Well, quite frankly, it is hard to say what problem this is supposed to address from your description. Care to give some more details?
The problem is that some hardware blocks needs to be restored as early as possible after leaving the U8500 CPU coupled sleep state ApSleep (APE power domain being off).
(APE = Application Processor Environment, on embedded)
I just have this vague feeling that this is one of those embedded SoC vs desktop things where worlds collide.
Isn't it so that on common x86 (desktop, server, laptop) the context of the system is saved by some BIOS/ACPI call, and then the ROM takes you back up with all devices put back into context?
On embedded SoC's we don't have this, all states in the hardware has to be saved and restored with kernel code.
Then there is a question about whether this shall be done centrally (there is one piece of code that knows all volatile registers of all hardware blocks in the system) which is close to what the desktop BIOS may do, or whether you want to do this in a distributed manner, so that each driver saves and restores the context of it's particular hardware.
The suggested mechanism is useful for the latter design pattern, where drivers know for themselves how to save and restore their contexts.
Yours,
Linus Walleij
PATCH v2 3/12 PM / Domains: Add on-off notifiers
Quoted 26 lines · Linus Walleij
Quoted 6 lines · Rickard Andersson
Quoted 4 lines · Rafael J. Wysocki
Quoted 2 lines · Rickard Andersson
I believe notifiers are the best solution to the problem of restoring context early when waking up after sleep.
I don't.
Some motivation would be good.
(...)
Quoted 5 lines
Quoted 2 lines
Well, quite frankly, it is hard to say what problem this is supposed to address from your description. Care to give some more details?
The problem is that some hardware blocks needs to be restored as early as possible after leaving the U8500 CPU coupled sleep state ApSleep (APE power domain being off).
(APE = Application Processor Environment, on embedded)
I just have this vague feeling that this is one of those embedded SoC vs desktop things where worlds collide.
Isn't it so that on common x86 (desktop, server, laptop) the context of the system is saved by some BIOS/ACPI call, and then the ROM takes you back up with all devices put back into context?
On embedded SoC's we don't have this, all states in the hardware has to be saved and restored with kernel code.
Quoted 7 lines
Then there is a question about whether this shall be done centrally (there is one piece of code that knows all volatile registers of all hardware blocks in the system) which is close to what the desktop BIOS may do, or whether you want to do this in a distributed manner, so that each driver saves and restores the context of it's particular hardware.
The advantage with using the distributed approach is that all knowledge of a certain hardware block can be handled in one place, the driver. Having all knowledge in one place is a standard software design pattern.
Most drivers in the APE domain will be fine using runtime pm, but a few needs their context (i.e. registers) to be restored directly when leaving a sleep state where the APE power domain has been off. For example the following hardware blocks: APE clocks, ICN (main interconnect bus) and TPIU (Trace Port Interface Unit). Using the TPIU block as an example: tracing with debugger (using TPIU block) needs to be active (context restored) directly after sleep in order to be able to record the execution also after waking up from sleep. If the TPIU context is not restored after waking up from sleep then the debuggers recording of the execution will also stop after waking up from sleep which is not a good thing when looking for difficult errors using a debugger.
Rafael: Can you please share your view?
Thanks in advance!
/Rickard
PATCH v2 4/12 PM / Domains: Lookup domain by name
In reply to Rickard AnderssonMake the function pm_genpd_lookup_name(..) non static. This is done to limit the need for "name functions" as e.g. pm_genpd_name_attach_cpuidle. Also the name lookup takes a mutex and should not be called when IRQ's are off. So by exporting this function the name lookup can be done before IRQ's are off.
--- drivers/base/power/domain.c | 2 +- include/linux/pm_domain.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/base/power/domain.c +1 -1
@@ -53,7 +53,7 @@static LIST_HEAD (gpd_list);static DEFINE_MUTEX (gpd_list_lock); -static struct generic_pm_domain *pm_genpd_lookup_name (const char *domain_name) +struct generic_pm_domain *pm_genpd_lookup_name (const char *domain_name) {struct generic_pm_domain *genpd =NULL , *gpd;
include/linux/pm_domain.h +5 -1
@@ -129,7 +129,7 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) }extern struct dev_power_governor simple_qos_governor; - +extern struct generic_pm_domain *pm_genpd_lookup_name (const char *domain_name);extern struct generic_pm_domain *dev_to_genpd (struct device *dev); extern int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
@@ -181,6 +181,10 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) {return ERR_PTR (-ENOSYS ); } +static struct generic_pm_domain *pm_genpd_lookup_name (const char *domain_name) +{ +return ERR_PTR (-ENOSYS ); +}static inline struct generic_pm_domain *dev_to_genpd (struct device *dev) {return ERR_PTR (-ENOSYS );
Signature · 1 line
1.8.2
PATCH v2 5/12 ARM: ux500: Create APE generic power domain
In reply to Rickard AnderssonThe APE generic power domain is created and
initiated. This power domain is turned off in
the sleep states ApSleep and ApDeepSleep
--- arch/arm/mach-ux500/Kconfig | 1 + arch/arm/mach-ux500/board-mop500.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
arch/arm/mach-ux500/Kconfig +1 -0
@@ -12,6 +12,7 @@ config UX500_SOC_COMMON select PINCTRL select PINCTRL_NOMADIK select PL310_ERRATA_753970 if CACHE_PL310 + select PM_GENERIC_DOMAINS if PM config UX500_SOC_DB8500 bool
arch/arm/mach-ux500/board-mop500.c +16 -1
@@ -37,7 +37,7 @@#include <linux/pinctrl/consumer.h> #include <linux/platform_data/pinctrl-nomadik.h> #include <linux/platform_data/dma-ste-dma40.h> - +#include <linux/pm_domain.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> #include <asm/hardware/gic.h>
@@ -645,6 +645,15 @@ static struct platform_device *snowball_platform_devs[] __initdata = { &u8500_cpufreq_cooling_device, }; +struct generic_pm_domain ape_domain = { + .name ="APE" , +}; + +static void __init init_pm_domains (void ) +{ +pm_genpd_init (&ape_domain,NULL , false); +} +static void __init mop500_init_machine (void ) {struct device *parent =NULL ;
@@ -668,6 +677,8 @@ static void __init mop500_init_machine(void)mop500_audio_init (parent);mop500_uart_init (parent); +init_pm_domains (); +u8500_cryp1_hash1_init (parent); i2c0_devs =ARRAY_SIZE (mop500_i2c0_devices);
@@ -700,6 +711,8 @@ static void __init snowball_init_machine(void)mop500_audio_init (parent);mop500_uart_init (parent); +init_pm_domains (); +/* This board has full regulator constraints */ regulator_has_full_constraints (); }
@@ -732,6 +745,8 @@ static void __init hrefv60_init_machine(void)mop500_audio_init (parent);mop500_uart_init (parent); +init_pm_domains (); + i2c0_devs =ARRAY_SIZE (mop500_i2c0_devices); i2c0_devs -=NUM_PRE_V60_I2C0_DEVICES ;
Signature · 1 line
1.8.2
PATCH v2 6/12 clk: ux500: Add PRCC power management
In reply to Rickard AnderssonWhen reaching a sleep state where the APE power domain is being turned off the context of the PRCC block needs to saved. When the power domain is turned on again the context is restored in order for the PRCC clocks to function correctly.
--- drivers/clk/ux500/clk-prcc.c | 71 ++++++++++++++++++++++++++++++++++++- drivers/clk/ux500/clk.h | 5 +++ drivers/clk/ux500/u8500_clk.c | 82 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 1 deletion(-)
drivers/clk/ux500/clk-prcc.c +70 -1
@@ -3,7 +3,8 @@* * Copyright (C) 2012 ST-Ericsson SA * Author: Ulf Hansson <[email protected]> -* +* Rickard Andersson <[email protected]> +* Jonas Aaberg <[email protected]> * License terms: GNU General Public License (GPL) version 2 */
@@ -13,10 +14,13 @@#include <linux/io.h> #include <linux/err.h> #include <linux/types.h> +#include <linux/platform_device.h> #include <mach/hardware.h> #include "clk.h" +#define UX500_NR_PRCC_BANKS 5 +#define PRCC_PCKEN 0x000#define PRCC_PCKDIS 0x004#define PRCC_KCKEN 0x008
@@ -33,6 +37,12 @@ struct clk_prcc {int is_enabled; }; +static struct { +void __iomem *base; +u32 bus_clk; +u32 kern_clk; +} context_prcc[UX500_NR_PRCC_BANKS ]; +/* PRCC clock operations. */ static int clk_prcc_pclk_enable (struct clk_hw *hw)
@@ -162,3 +172,62 @@ struct clk *clk_reg_prcc_kclk(const char *name,return clk_reg_prcc (name, parent_name, phy_base, cg_sel, flags, &clk_prcc_kclk_ops); } + +void clk_prcc_save_context (void ) +{ +int i; + +for (i =0 ; i <UX500_NR_PRCC_BANKS ; i++) { + context_prcc[i].bus_clk = +readl (context_prcc[i].base +PRCC_PCKSR ); + context_prcc[i].kern_clk = +readl (context_prcc[i].base +PRCC_KCKSR ); + } +} + +void clk_prcc_restore_context (void ) +{ +int i; + +for (i =0 ; i <UX500_NR_PRCC_BANKS ; i++) { +writel (~context_prcc[i].bus_clk, + context_prcc[i].base +PRCC_PCKDIS ); +writel (~context_prcc[i].kern_clk, + context_prcc[i].base +PRCC_KCKDIS ); + +writel (context_prcc[i].bus_clk, + context_prcc[i].base +PRCC_PCKEN ); +writel (context_prcc[i].kern_clk, + context_prcc[i].base +PRCC_KCKEN ); + } +} + +int __init clk_prcc_init (struct platform_device *pdev) +{ +int i; +struct resource *res; +int ret =0 ; + +for (i =0 ; i <UX500_NR_PRCC_BANKS ; i++) { + res =platform_get_resource (pdev,IORESOURCE_MEM , i); +if (!res) { + ret = -EINVAL ; + goto err_iounmap; + } + + context_prcc[i].base =ioremap (res->start,resource_size (res)); +if (!context_prcc[i].base) { + ret = -ENOMEM ; + goto err_iounmap; + } + } + +return ret; + + err_iounmap: +for (i =0 ; i <UX500_NR_PRCC_BANKS ; i++) { +if (context_prcc[i].base) +iounmap (context_prcc[i].base); + } +return ret; +}
drivers/clk/ux500/clk.h +5 -0
@@ -11,6 +11,7 @@#define __UX500_CLK_H#include <linux/clk.h> +#include <linux/platform_device.h> struct clk *clk_reg_prcc_pclk(const char *name, const char *parent_name,
@@ -57,4 +58,8 @@ struct clk *clk_reg_prcmu_opp_volt_scalable(const char *name,unsigned long rate, unsigned long flags); +void clk_prcc_save_context (void ); +void clk_prcc_restore_context (void ); +int __init clk_prcc_init (struct platform_device *pdev); +#endif /* __UX500_CLK_H */
drivers/clk/ux500/u8500_clk.c +82 -0
94 lines not on this page · raw message
Signature · 1 line
1.8.2
PATCH v2 7/12 ARM: ux500: Create u8500-clk device
In reply to Rickard AnderssonAdd platform device for u8500-clk. Also add
the device to the generic power domain APE.
--- arch/arm/boot/dts/dbx5x0.dtsi | 9 ++++++++ arch/arm/mach-ux500/board-mop500.c | 8 +++++++ arch/arm/mach-ux500/cpu-db8500.c | 1 + arch/arm/mach-ux500/devices-db8500.c | 41 ++++++++++++++++++++++++++++++++++++ arch/arm/mach-ux500/devices-db8500.h | 1 + drivers/clk/ux500/u8500_clk.c | 6 ++++++ 6 files changed, 66 insertions(+)
arch/arm/boot/dts/dbx5x0.dtsi +9 -0
@@ -657,6 +657,15 @@ status = "disabled"; }; + clk { + compatible = "stericsson,u8500-clk"; + reg = <0x8012f000 0x1000>, + <0x8011f000 0x1000>, + <0x8000f000 0x1000>, + <0xa03ff000 0x1000>, + <0xa03cf000 0x1000>; + }; + external-bus at 50000000 { compatible = "simple-bus"; reg = <0x50000000 0x4000000>;
arch/arm/mach-ux500/board-mop500.c +8 -0
@@ -649,9 +649,17 @@ struct generic_pm_domain ape_domain = { .name = "APE", }; +static __init void add_platform_device_to_genpd (struct platform_device *pdev, +struct generic_pm_domain *genpd) +{ +pm_genpd_add_device (genpd, &pdev->dev); +} +static void __init init_pm_domains (void ) {pm_genpd_init (&ape_domain,NULL , false); + +add_platform_device_to_genpd (&db8500_clk_device, &ape_domain); }static void __init mop500_init_machine (void )
arch/arm/mach-ux500/cpu-db8500.c +1 -0
@@ -142,6 +142,7 @@ static struct platform_device db8500_prcmu_device = { };static struct platform_device *platform_devs[]__initdata = { + &db8500_clk_device, &u8500_dma40_device, &db8500_pmu_device, &db8500_prcmu_device,
arch/arm/mach-ux500/devices-db8500.c +41 -0
44 lines not on this page · raw message
arch/arm/mach-ux500/devices-db8500.h +1 -0
@@ -14,6 +14,7 @@struct ske_keypad_platform_data ;struct pl022_ssp_controller ; +extern struct platform_device db8500_clk_device;static inline struct platform_device * db8500_add_ske_keypad(struct device *parent,
drivers/clk/ux500/u8500_clk.c +6 -0
@@ -566,9 +566,15 @@ static struct notifier_block prcc_context_notifier = { .notifier_call = prcc_context_call, }; +static const struct of_device_id u8500_clk_match[] = { + { .compatible ="stericsson,u8500-clk" , }, + {}, +}; +static struct platform_driver u8500_clk_plat_driver = { .driver = { .name ="u8500-clk" , + .of_match_table = u8500_clk_match, }, };
Signature · 1 line
1.8.2
PATCH v2 8/12 ARM: ux500: Add ApSleep state to suspend
In reply to Rickard AnderssonSupport for power save state ApSleep is
added to the platform suspend operation
hook.
--- arch/arm/mach-ux500/suspend.c | 57 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-)
arch/arm/mach-ux500/suspend.c +56 -1
@@ -10,11 +10,60 @@*/ #include <linux/suspend.h> +#include <linux/pm_domain.h> +#include <linux/mfd/dbx500-prcmu.h> + +static u32 suspend_wakeups; +static u32 running_wakeups; +static struct generic_pm_domain *ape_domain;static int ux500_suspend_enter (suspend_state_t state) { +int ret =0 ; + +/* Configure the PRCMU for a sleep wakeup */ +prcmu_enable_wakeups (suspend_wakeups); + +pm_genpd_notify_power_on_off (ape_domain, false); + +prcmu_gic_decouple (); + +/* Copy GIC interrupt settings to PRCMU interrupt settings */ +prcmu_copy_gic_settings (); + +if (prcmu_gic_pending_irq ()) { +pr_info ("suspend/resume: pending interrupt\n" ); + +/* Recouple GIC with the interrupt bus */ +prcmu_gic_recouple (); + ret = -EBUSY ; + goto exit; + } + +if (prcmu_pending_irq ()) { +pr_info ("suspend/resume: pending interrupt prcmu\n" ); + +/* Recouple GIC with the interrupt bus */ +prcmu_gic_recouple (); + ret = -EBUSY ; + goto exit; + } + +prcmu_set_ioforce (true); + +prcmu_set_power_state (PRCMU_AP_SLEEP , false, false); +cpu_do_idle (); -return 0 ; + +pm_genpd_notify_power_on_off (ape_domain, true); + +prcmu_set_ioforce (false); + + exit: +/* Configure the prcmu with the wake-ups that cpuidle needs */ +prcmu_enable_wakeups (running_wakeups); + +return ret; }static int ux500_suspend_valid (suspend_state_t state)
@@ -29,6 +78,12 @@ static const struct platform_suspend_ops ux500_suspend_ops = {static __init int ux500_suspend_init (void ) { + suspend_wakeups =PRCMU_WAKEUP (ABB ) |PRCMU_WAKEUP (RTC ); + running_wakeups = (PRCMU_WAKEUP (ARM ) |PRCMU_WAKEUP (RTC ) | +PRCMU_WAKEUP (ABB )); + + ape_domain =pm_genpd_lookup_name ("APE" ); +suspend_set_ops (&ux500_suspend_ops);return 0 ; }
Signature · 1 line
1.8.2
PATCH v2 9/12 drivers: bus: ux500: Add ICN driver
In reply to Rickard AnderssonAdd driver for the U8500 main interconnect bus. The settings of these hardware registers are lost when the APE power domain is powered off.
The ICN default settings are done during early boot.
--- drivers/bus/dbx500-icn.c | 522 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 522 insertions(+) create mode 100644 drivers/bus/dbx500-icn.c
drivers/bus/dbx500-icn.c new file +522 -0
@@ -0,0 +1,522 @@ +/* +* U8500 interconnect driver +* +* Copyright (C) STMicroelectronics 2009 +* Copyright (C) ST-Ericsson SA 2010-2013 +* +* License Terms: GNU General Public License v2 +* Author: Sundar Iyer for ST-Ericsson +* Rickard Andersson <[email protected]> +* +*/ + +#include <linux/io.h> +#include <linux/platform_device.h> +#include <linux/pm_domain.h> +#include <mach/hardware.h> + +/* Priority, BW limiter register offsets */ +#define NODE_HIBW1_ESRAM_IN_0_PRIORITY 0x00 +#define NODE_HIBW1_ESRAM_IN_1_PRIORITY 0x04 +#define NODE_HIBW1_ESRAM_IN_2_PRIORITY 0x08 +#define NODE_HIBW1_ESRAM_IN_0_ARB_1_LIMIT 0x24 +#define NODE_HIBW1_ESRAM_IN_0_ARB_2_LIMIT 0x28 +#define NODE_HIBW1_ESRAM_IN_0_ARB_3_LIMIT 0x2C +#define NODE_HIBW1_ESRAM_IN_1_ARB_1_LIMIT 0x30 +#define NODE_HIBW1_ESRAM_IN_1_ARB_2_LIMIT 0x34 +#define NODE_HIBW1_ESRAM_IN_1_ARB_3_LIMIT 0x38 +#define NODE_HIBW1_ESRAM_IN_2_ARB_1_LIMIT 0x3C +#define NODE_HIBW1_ESRAM_IN_2_ARB_2_LIMIT 0x40 +#define NODE_HIBW1_ESRAM_IN_2_ARB_3_LIMIT 0x44 +#define NODE_HIBW1_DDR_IN_0_PRIORITY 0x400 +#define NODE_HIBW1_DDR_IN_1_PRIORITY 0x404 +#define NODE_HIBW1_DDR_IN_2_PRIORITY 0x408 +#define NODE_HIBW1_DDR_IN_0_LIMIT 0x424 +#define NODE_HIBW1_DDR_IN_1_LIMIT 0x428 +#define NODE_HIBW1_DDR_IN_2_LIMIT 0x42C +#define NODE_HIBW1_DDR_OUT_0_PRIORITY 0x430 +#define NODE_HIBW2_ESRAM_IN_0_PRIORITY 0x800 +#define NODE_HIBW2_ESRAM_IN_1_PRIORITY 0x804 +#define NODE_HIBW2_ESRAM_IN_0_ARB_1_LIMIT 0x818 +#define NODE_HIBW2_ESRAM_IN_0_ARB_2_LIMIT 0x81C +#define NODE_HIBW2_ESRAM_IN_0_ARB_3_LIMIT 0x820 +#define NODE_HIBW2_ESRAM_IN_1_ARB_1_LIMIT 0x824 +#define NODE_HIBW2_ESRAM_IN_1_ARB_2_LIMIT 0x828 +#define NODE_HIBW2_ESRAM_IN_1_ARB_3_LIMIT 0x82C +#define NODE_HIBW2_DDR_IN_0_PRIORITY 0xC00 +#define NODE_HIBW2_DDR_IN_1_PRIORITY 0xC04 +#define NODE_HIBW2_DDR_IN_2_PRIORITY 0xC08 + +#define NODE_HIBW2_DDR_IN_0_LIMIT 0xC24 +#define NODE_HIBW2_DDR_IN_1_LIMIT 0xC28 +#define NODE_HIBW2_DDR_IN_2_LIMIT 0xC2C +#define NODE_HIBW2_DDR_OUT_0_PRIORITY 0xC30 + +/* +* Note the following addresses are presented in +* db8500 design spec v3.1 and v3.3, table 10. +* But their addresses are not the same as in the +* description. The addresses in the description +* of each registers are correct. +* NODE_HIBW2_DDR_IN_3_LIMIT is only present in v1. +* +* Faulty registers addresses in table 10: +* NODE_HIBW2_DDR_IN_2_LIMIT 0xC38 +* NODE_HIBW2_DDR_IN_3_LIMIT 0xC3C +* NODE_HIBW2_DDR_OUT_0_PRIORITY 0xC40 +*/ + +#define NODE_ESRAM0_IN_0_PRIORITY 0x1000 +#define NODE_ESRAM0_IN_1_PRIORITY 0x1004 +#define NODE_ESRAM0_IN_2_PRIORITY 0x1008 +#define NODE_ESRAM0_IN_3_PRIORITY 0x100C +#define NODE_ESRAM0_IN_0_LIMIT 0x1030 +#define NODE_ESRAM0_IN_1_LIMIT 0x1034 +#define NODE_ESRAM0_IN_2_LIMIT 0x1038 +#define NODE_ESRAM0_IN_3_LIMIT 0x103C +/* Common */ +#define NODE_ESRAM1_2_IN_0_PRIORITY 0x1400 +#define NODE_ESRAM1_2_IN_1_PRIORITY 0x1404 +#define NODE_ESRAM1_2_IN_2_PRIORITY 0x1408 +#define NODE_ESRAM1_2_IN_3_PRIORITY 0x140C +#define NODE_ESRAM1_2_IN_0_ARB_1_LIMIT 0x1430 +#define NODE_ESRAM1_2_IN_0_ARB_2_LIMIT 0x1434 +#define NODE_ESRAM1_2_IN_1_ARB_1_LIMIT 0x1438 +#define NODE_ESRAM1_2_IN_1_ARB_2_LIMIT 0x143C +#define NODE_ESRAM1_2_IN_2_ARB_1_LIMIT 0x1440 +#define NODE_ESRAM1_2_IN_2_ARB_2_LIMIT 0x1444 +#define NODE_ESRAM1_2_IN_3_ARB_1_LIMIT 0x1448 +#define NODE_ESRAM1_2_IN_3_ARB_2_LIMIT 0x144C + +#define NODE_ESRAM3_4_IN_0_PRIORITY 0x1800 +#define NODE_ESRAM3_4_IN_1_PRIORITY 0x1804 +#define NODE_ESRAM3_4_IN_2_PRIORITY 0x1808 +#define NODE_ESRAM3_4_IN_3_PRIORITY 0x180C +#define NODE_ESRAM3_4_IN_0_ARB_1_LIMIT 0x1830 +#define NODE_ESRAM3_4_IN_0_ARB_2_LIMIT 0x1834 +#define NODE_ESRAM3_4_IN_1_ARB_1_LIMIT 0x1838 +#define NODE_ESRAM3_4_IN_1_ARB_2_LIMIT 0x183C +#define NODE_ESRAM3_4_IN_2_ARB_1_LIMIT 0x1840 +#define NODE_ESRAM3_4_IN_2_ARB_2_LIMIT 0x1844 +#define NODE_ESRAM3_4_IN_3_ARB_1_LIMIT 0x1848 +#define NODE_ESRAM3_4_IN_3_ARB_2_LIMIT 0x184C + +static struct { +void __iomem *base; +u32 hibw1_esram_in_pri[3 ]; +u32 hibw1_esram_in0_arb[3 ]; +u32 hibw1_esram_in1_arb[3 ]; +u32 hibw1_esram_in2_arb[3 ]; +u32 hibw1_ddr_in_prio[3 ]; +u32 hibw1_ddr_in_limit[3 ]; +u32 hibw1_ddr_out_prio; + +/* HiBw2 node registers */ +u32 hibw2_esram_in_pri[2 ]; +u32 hibw2_esram_in0_arblimit[3 ]; +u32 hibw2_esram_in1_arblimit[3 ]; +u32 hibw2_ddr_in_prio[4 ]; +u32 hibw2_ddr_in_limit[4 ]; +u32 hibw2_ddr_out_prio; + +/* ESRAM node registers */ +u32 esram_in_prio[4 ]; +u32 esram_in_lim[4 ]; +u32 esram0_in_prio[4 ]; +u32 esram0_in_lim[4 ]; +u32 esram12_in_prio[4 ]; +u32 esram12_in_arb_lim[8 ]; +u32 esram34_in_prio[4 ]; +u32 esram34_in_arb_lim[8 ]; +} context_icn; + +/** +* icn_save_context() - Save interconnect context +*/ +static void icn_save_context (void ) +{ +void __iomem *b = context_icn.base; + + context_icn.hibw1_esram_in_pri[0 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_0_PRIORITY ); + context_icn.hibw1_esram_in_pri[1 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_1_PRIORITY ); + context_icn.hibw1_esram_in_pri[2 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_2_PRIORITY ); + + context_icn.hibw1_esram_in0_arb[0 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_0_ARB_1_LIMIT ); + context_icn.hibw1_esram_in0_arb[1 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_0_ARB_2_LIMIT ); + context_icn.hibw1_esram_in0_arb[2 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_0_ARB_3_LIMIT ); + + context_icn.hibw1_esram_in1_arb[0 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_1_ARB_1_LIMIT ); + context_icn.hibw1_esram_in1_arb[1 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_1_ARB_2_LIMIT ); + context_icn.hibw1_esram_in1_arb[2 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_1_ARB_3_LIMIT ); + + context_icn.hibw1_esram_in2_arb[0 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_2_ARB_1_LIMIT ); + context_icn.hibw1_esram_in2_arb[1 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_2_ARB_2_LIMIT ); + context_icn.hibw1_esram_in2_arb[2 ] = +readl_relaxed (b +NODE_HIBW1_ESRAM_IN_2_ARB_3_LIMIT ); + + context_icn.hibw1_ddr_in_prio[0 ] = +readl_relaxed (b +NODE_HIBW1_DDR_IN_0_PRIORITY ); + context_icn.hibw1_ddr_in_prio[1 ] = +readl_relaxed (b +NODE_HIBW1_DDR_IN_1_PRIORITY ); + context_icn.hibw1_ddr_in_prio[2 ] = +readl_relaxed (b +NODE_HIBW1_DDR_IN_2_PRIORITY ); + + context_icn.hibw1_ddr_in_limit[0 ] = +readl_relaxed (b +NODE_HIBW1_DDR_IN_0_LIMIT ); + context_icn.hibw1_ddr_in_limit[1 ] = +readl_relaxed (b +NODE_HIBW1_DDR_IN_1_LIMIT ); + context_icn.hibw1_ddr_in_limit[2 ] = +readl_relaxed (b +NODE_HIBW1_DDR_IN_2_LIMIT ); + + context_icn.hibw1_ddr_out_prio = +readl_relaxed (b +NODE_HIBW1_DDR_OUT_0_PRIORITY ); + + context_icn.hibw2_esram_in_pri[0 ] = +readl_relaxed (b +NODE_HIBW2_ESRAM_IN_0_PRIORITY ); + context_icn.hibw2_esram_in_pri[1 ] = +readl_relaxed (b +NODE_HIBW2_ESRAM_IN_1_PRIORITY ); + + context_icn.hibw2_esram_in0_arblimit[0 ] = +readl_relaxed (b +NODE_HIBW2_ESRAM_IN_0_ARB_1_LIMIT ); + context_icn.hibw2_esram_in0_arblimit[1 ] = +readl_relaxed (b +NODE_HIBW2_ESRAM_IN_0_ARB_2_LIMIT ); + context_icn.hibw2_esram_in0_arblimit[2 ] = +readl_relaxed (b +NODE_HIBW2_ESRAM_IN_0_ARB_3_LIMIT ); + + context_icn.hibw2_esram_in1_arblimit[0 ] = +readl_relaxed (b +NODE_HIBW2_ESRAM_IN_1_ARB_1_LIMIT ); + context_icn.hibw2_esram_in1_arblimit[1 ] = +readl_relaxed (b +NODE_HIBW2_ESRAM_IN_1_ARB_2_LIMIT ); + context_icn.hibw2_esram_in1_arblimit[2 ] = +readl_relaxed (b +NODE_HIBW2_ESRAM_IN_1_ARB_3_LIMIT ); + + context_icn.hibw2_ddr_in_prio[0 ] = +readl_relaxed (b +NODE_HIBW2_DDR_IN_0_PRIORITY ); + context_icn.hibw2_ddr_in_prio[1 ] = +readl_relaxed (b +NODE_HIBW2_DDR_IN_1_PRIORITY ); + context_icn.hibw2_ddr_in_prio[2 ] = +readl_relaxed (b +NODE_HIBW2_DDR_IN_2_PRIORITY ); + + context_icn.hibw2_ddr_in_limit[0 ] = +readl_relaxed (b +NODE_HIBW2_DDR_IN_0_LIMIT ); + context_icn.hibw2_ddr_in_limit[1 ] = +readl_relaxed (b +NODE_HIBW2_DDR_IN_1_LIMIT ); + + context_icn.hibw2_ddr_in_limit[2 ] = +readl_relaxed (b +NODE_HIBW2_DDR_IN_2_LIMIT ); + + context_icn.hibw2_ddr_out_prio = +readl_relaxed (b +NODE_HIBW2_DDR_OUT_0_PRIORITY ); + + context_icn.esram0_in_prio[0 ] = +readl_relaxed (b +NODE_ESRAM0_IN_0_PRIORITY ); + context_icn.esram0_in_prio[1 ] = +readl_relaxed (b +NODE_ESRAM0_IN_1_PRIORITY ); + context_icn.esram0_in_prio[2 ] = +readl_relaxed (b +NODE_ESRAM0_IN_2_PRIORITY ); + context_icn.esram0_in_prio[3 ] = +readl_relaxed (b +NODE_ESRAM0_IN_3_PRIORITY ); + + context_icn.esram0_in_lim[0 ] = +readl_relaxed (b +NODE_ESRAM0_IN_0_LIMIT ); + context_icn.esram0_in_lim[1 ] = +readl_relaxed (b +NODE_ESRAM0_IN_1_LIMIT ); + context_icn.esram0_in_lim[2 ] = +readl_relaxed (b +NODE_ESRAM0_IN_2_LIMIT ); + context_icn.esram0_in_lim[3 ] = +readl_relaxed (b +NODE_ESRAM0_IN_3_LIMIT ); + + context_icn.esram12_in_prio[0 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_0_PRIORITY ); + context_icn.esram12_in_prio[1 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_1_PRIORITY ); + context_icn.esram12_in_prio[2 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_2_PRIORITY ); + context_icn.esram12_in_prio[3 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_3_PRIORITY ); + + context_icn.esram12_in_arb_lim[0 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_0_ARB_1_LIMIT ); + context_icn.esram12_in_arb_lim[1 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_0_ARB_2_LIMIT ); + context_icn.esram12_in_arb_lim[2 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_1_ARB_1_LIMIT ); + context_icn.esram12_in_arb_lim[3 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_1_ARB_2_LIMIT ); + context_icn.esram12_in_arb_lim[4 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_2_ARB_1_LIMIT ); + context_icn.esram12_in_arb_lim[5 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_2_ARB_2_LIMIT ); + context_icn.esram12_in_arb_lim[6 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_3_ARB_1_LIMIT ); + context_icn.esram12_in_arb_lim[7 ] = +readl_relaxed (b +NODE_ESRAM1_2_IN_3_ARB_2_LIMIT ); + + context_icn.esram34_in_prio[0 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_0_PRIORITY ); + context_icn.esram34_in_prio[1 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_1_PRIORITY ); + context_icn.esram34_in_prio[2 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_2_PRIORITY ); + context_icn.esram34_in_prio[3 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_3_PRIORITY ); + + context_icn.esram34_in_arb_lim[0 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_0_ARB_1_LIMIT ); + context_icn.esram34_in_arb_lim[1 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_0_ARB_2_LIMIT ); + context_icn.esram34_in_arb_lim[2 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_1_ARB_1_LIMIT ); + context_icn.esram34_in_arb_lim[3 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_1_ARB_2_LIMIT ); + context_icn.esram34_in_arb_lim[4 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_2_ARB_1_LIMIT ); + context_icn.esram34_in_arb_lim[5 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_2_ARB_2_LIMIT ); + context_icn.esram34_in_arb_lim[6 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_3_ARB_1_LIMIT ); + context_icn.esram34_in_arb_lim[7 ] = +readl_relaxed (b +NODE_ESRAM3_4_IN_3_ARB_2_LIMIT ); +} + +/** +* icn_restore_context() - Restore interconnect context +*/ +static void icn_restore_context (void ) +{ +void __iomem *b = context_icn.base; + +writel_relaxed (context_icn.hibw1_esram_in_pri[0 ], + b +NODE_HIBW1_ESRAM_IN_0_PRIORITY ); +writel_relaxed (context_icn.hibw1_esram_in_pri[1 ], + b +NODE_HIBW1_ESRAM_IN_1_PRIORITY ); +writel_relaxed (context_icn.hibw1_esram_in_pri[2 ], + b +NODE_HIBW1_ESRAM_IN_2_PRIORITY ); + +writel_relaxed (context_icn.hibw1_esram_in0_arb[0 ], + b +NODE_HIBW1_ESRAM_IN_0_ARB_1_LIMIT ); +writel_relaxed (context_icn.hibw1_esram_in0_arb[1 ], + b +NODE_HIBW1_ESRAM_IN_0_ARB_2_LIMIT ); +writel_relaxed (context_icn.hibw1_esram_in0_arb[2 ], + b +NODE_HIBW1_ESRAM_IN_0_ARB_3_LIMIT ); + +writel_relaxed (context_icn.hibw1_esram_in1_arb[0 ], + b +NODE_HIBW1_ESRAM_IN_1_ARB_1_LIMIT ); +writel_relaxed (context_icn.hibw1_esram_in1_arb[1 ], + b +NODE_HIBW1_ESRAM_IN_1_ARB_2_LIMIT ); +writel_relaxed (context_icn.hibw1_esram_in1_arb[2 ], + b +NODE_HIBW1_ESRAM_IN_1_ARB_3_LIMIT ); + +writel_relaxed (context_icn.hibw1_esram_in2_arb[0 ], + b +NODE_HIBW1_ESRAM_IN_2_ARB_1_LIMIT ); +writel_relaxed (context_icn.hibw1_esram_in2_arb[1 ], + b +NODE_HIBW1_ESRAM_IN_2_ARB_2_LIMIT ); +writel_relaxed (context_icn.hibw1_esram_in2_arb[2 ], + b +NODE_HIBW1_ESRAM_IN_2_ARB_3_LIMIT ); + +writel_relaxed (context_icn.hibw1_ddr_in_prio[0 ], + b +NODE_HIBW1_DDR_IN_0_PRIORITY ); +writel_relaxed (context_icn.hibw1_ddr_in_prio[1 ], + b +NODE_HIBW1_DDR_IN_1_PRIORITY ); +writel_relaxed (context_icn.hibw1_ddr_in_prio[2 ], + b +NODE_HIBW1_DDR_IN_2_PRIORITY ); + +writel_relaxed (context_icn.hibw1_ddr_in_limit[0 ], + b +NODE_HIBW1_DDR_IN_0_LIMIT ); +writel_relaxed (context_icn.hibw1_ddr_in_limit[1 ], + b +NODE_HIBW1_DDR_IN_1_LIMIT ); +writel_relaxed (context_icn.hibw1_ddr_in_limit[2 ], + b +NODE_HIBW1_DDR_IN_2_LIMIT ); + +writel_relaxed (context_icn.hibw1_ddr_out_prio, + b +NODE_HIBW1_DDR_OUT_0_PRIORITY ); + +writel_relaxed (context_icn.hibw2_esram_in_pri[0 ], + b +NODE_HIBW2_ESRAM_IN_0_PRIORITY ); +writel_relaxed (context_icn.hibw2_esram_in_pri[1 ], + b +NODE_HIBW2_ESRAM_IN_1_PRIORITY ); + +writel_relaxed (context_icn.hibw2_esram_in0_arblimit[0 ], + b +NODE_HIBW2_ESRAM_IN_0_ARB_1_LIMIT ); +writel_relaxed (context_icn.hibw2_esram_in0_arblimit[1 ], + b +NODE_HIBW2_ESRAM_IN_0_ARB_2_LIMIT ); +writel_relaxed (context_icn.hibw2_esram_in0_arblimit[2 ], + b +NODE_HIBW2_ESRAM_IN_0_ARB_3_LIMIT ); + +writel_relaxed (context_icn.hibw2_esram_in1_arblimit[0 ], + b +NODE_HIBW2_ESRAM_IN_1_ARB_1_LIMIT ); +writel_relaxed (context_icn.hibw2_esram_in1_arblimit[1 ], + b +NODE_HIBW2_ESRAM_IN_1_ARB_2_LIMIT ); +writel_relaxed (context_icn.hibw2_esram_in1_arblimit[2 ], + b +NODE_HIBW2_ESRAM_IN_1_ARB_3_LIMIT ); + +writel_relaxed (context_icn.hibw2_ddr_in_prio[0 ], + b +NODE_HIBW2_DDR_IN_0_PRIORITY ); +writel_relaxed (context_icn.hibw2_ddr_in_prio[1 ], + b +NODE_HIBW2_DDR_IN_1_PRIORITY ); +writel_relaxed (context_icn.hibw2_ddr_in_prio[2 ], + b +NODE_HIBW2_DDR_IN_2_PRIORITY ); +writel_relaxed (context_icn.hibw2_ddr_in_limit[0 ], + b +NODE_HIBW2_DDR_IN_0_LIMIT ); +writel_relaxed (context_icn.hibw2_ddr_in_limit[1 ], + b +NODE_HIBW2_DDR_IN_1_LIMIT ); +writel_relaxed (context_icn.hibw2_ddr_in_limit[2 ], + b +NODE_HIBW2_DDR_IN_2_LIMIT ); +writel_relaxed (context_icn.hibw2_ddr_out_prio, + b +NODE_HIBW2_DDR_OUT_0_PRIORITY ); + +writel_relaxed (context_icn.esram0_in_prio[0 ], + b +NODE_ESRAM0_IN_0_PRIORITY ); +writel_relaxed (context_icn.esram0_in_prio[1 ], + b +NODE_ESRAM0_IN_1_PRIORITY ); +writel_relaxed (context_icn.esram0_in_prio[2 ], + b +NODE_ESRAM0_IN_2_PRIORITY ); +writel_relaxed (context_icn.esram0_in_prio[3 ], + b +NODE_ESRAM0_IN_3_PRIORITY ); + +writel_relaxed (context_icn.esram0_in_lim[0 ], + b +NODE_ESRAM0_IN_0_LIMIT ); +writel_relaxed (context_icn.esram0_in_lim[1 ], + b +NODE_ESRAM0_IN_1_LIMIT ); +writel_relaxed (context_icn.esram0_in_lim[2 ], + b +NODE_ESRAM0_IN_2_LIMIT ); +writel_relaxed (context_icn.esram0_in_lim[3 ], + b +NODE_ESRAM0_IN_3_LIMIT ); + +writel_relaxed (context_icn.esram12_in_prio[0 ], + b +NODE_ESRAM1_2_IN_0_PRIORITY ); +writel_relaxed (context_icn.esram12_in_prio[1 ], + b +NODE_ESRAM1_2_IN_1_PRIORITY ); +writel_relaxed (context_icn.esram12_in_prio[2 ], + b +NODE_ESRAM1_2_IN_2_PRIORITY ); +writel_relaxed (context_icn.esram12_in_prio[3 ], + b +NODE_ESRAM1_2_IN_3_PRIORITY ); + +writel_relaxed (context_icn.esram12_in_arb_lim[0 ], + b +NODE_ESRAM1_2_IN_0_ARB_1_LIMIT ); +writel_relaxed (context_icn.esram12_in_arb_lim[1 ], + b +NODE_ESRAM1_2_IN_0_ARB_2_LIMIT ); +writel_relaxed (context_icn.esram12_in_arb_lim[2 ], + b +NODE_ESRAM1_2_IN_1_ARB_1_LIMIT ); +writel_relaxed (context_icn.esram12_in_arb_lim[3 ], + b +NODE_ESRAM1_2_IN_1_ARB_2_LIMIT ); +writel_relaxed (context_icn.esram12_in_arb_lim[4 ], + b +NODE_ESRAM1_2_IN_2_ARB_1_LIMIT ); +writel_relaxed (context_icn.esram12_in_arb_lim[5 ], + b +NODE_ESRAM1_2_IN_2_ARB_2_LIMIT ); +writel_relaxed (context_icn.esram12_in_arb_lim[6 ], + b +NODE_ESRAM1_2_IN_3_ARB_1_LIMIT ); +writel_relaxed (context_icn.esram12_in_arb_lim[7 ], + b +NODE_ESRAM1_2_IN_3_ARB_2_LIMIT ); + +writel_relaxed (context_icn.esram34_in_prio[0 ], + b +NODE_ESRAM3_4_IN_0_PRIORITY ); +writel_relaxed (context_icn.esram34_in_prio[1 ], + b +NODE_ESRAM3_4_IN_1_PRIORITY ); +writel_relaxed (context_icn.esram34_in_prio[2 ], + b +NODE_ESRAM3_4_IN_2_PRIORITY ); +writel_relaxed (context_icn.esram34_in_prio[3 ], + b +NODE_ESRAM3_4_IN_3_PRIORITY ); + +writel_relaxed (context_icn.esram34_in_arb_lim[0 ], + b +NODE_ESRAM3_4_IN_0_ARB_1_LIMIT ); +writel_relaxed (context_icn.esram34_in_arb_lim[1 ], + b +NODE_ESRAM3_4_IN_0_ARB_2_LIMIT ); +writel_relaxed (context_icn.esram34_in_arb_lim[2 ], + b +NODE_ESRAM3_4_IN_1_ARB_1_LIMIT ); +writel_relaxed (context_icn.esram34_in_arb_lim[3 ], + b +NODE_ESRAM3_4_IN_1_ARB_2_LIMIT ); +writel_relaxed (context_icn.esram34_in_arb_lim[4 ], + b +NODE_ESRAM3_4_IN_2_ARB_1_LIMIT ); +writel_relaxed (context_icn.esram34_in_arb_lim[5 ], + b +NODE_ESRAM3_4_IN_2_ARB_2_LIMIT ); +writel_relaxed (context_icn.esram34_in_arb_lim[6 ], + b +NODE_ESRAM3_4_IN_3_ARB_1_LIMIT ); +writel_relaxed (context_icn.esram34_in_arb_lim[7 ], + b +NODE_ESRAM3_4_IN_3_ARB_2_LIMIT ); +} + +static int icn_context_call (struct notifier_block *this, +unsigned long event,void *data) +{ +bool power_on = (bool )event; + +if (power_on) +icn_restore_context (); +else +icn_save_context (); + +return 0 ; +} + +static struct notifier_block icn_context_notifier = { + .notifier_call = icn_context_call, +}; + +static const struct of_device_id dbx500_icn_match[] = { + { .compatible ="stericsson,db8500-icn" , }, + {}, +}; + +static struct platform_driver dbx500_icn_plat_driver = { + .driver = { + .name ="dbx500-icn" , + .of_match_table = dbx500_icn_match, + }, +}; + +static int __init dbx500_icn_probe (struct platform_device *pdev) +{ +int ret =0 ; +struct resource *res; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (&pdev->dev,"missing platform resources\n" ); +return -EINVAL ; + } + +if (!request_mem_region (res->start,resource_size (res), pdev->name)) { +dev_err (&pdev->dev,"failed to request I/O memory\n" ); +return -EBUSY ; + } + + context_icn.base =ioremap (res->start,resource_size (res)); +if (!context_icn.base) { + ret = -ENOMEM ; + goto err_free_mem_region; + } + + ret =pm_genpd_register_on_off_notifier (&pdev->dev, + &icn_context_notifier); +if (ret) + goto err_iounmap; + +return ret; + + err_iounmap: +iounmap (context_icn.base); + err_free_mem_region: +release_mem_region (res->start,resource_size (res)); +return ret; + +} + +static int __init dbx500_icn_init (void ) +{ +return platform_driver_probe (&dbx500_icn_plat_driver, + dbx500_icn_probe); +} + +arch_initcall (dbx500_icn_init);
Signature · 1 line
1.8.2
PATCH v2 10/12 ARM: ux500: Create ICN device
In reply to Rickard AnderssonAdd platform device for dbx500-icn. Also add
the device to the generic power domain APE.
--- arch/arm/boot/dts/dbx5x0.dtsi | 5 +++++ arch/arm/mach-ux500/board-mop500.c | 1 + arch/arm/mach-ux500/cpu-db8500.c | 1 + arch/arm/mach-ux500/devices-common.c | 16 ++++++++++++++++ arch/arm/mach-ux500/devices-common.h | 1 + drivers/bus/Makefile | 1 + 6 files changed, 25 insertions(+)
arch/arm/boot/dts/dbx5x0.dtsi +5 -0
@@ -666,6 +666,11 @@ <0xa03cf000 0x1000>; }; + icn { + compatible = "stericsson,db8500-icn"; + reg = <0x81000000 0x2000>; + }; + external-bus at 50000000 { compatible = "simple-bus"; reg = <0x50000000 0x4000000>;
arch/arm/mach-ux500/board-mop500.c +1 -0
@@ -660,6 +660,7 @@ static void __init init_pm_domains(void)pm_genpd_init (&ape_domain,NULL , false);add_platform_device_to_genpd (&db8500_clk_device, &ape_domain); +add_platform_device_to_genpd (&dbx500_icn_device, &ape_domain); }static void __init mop500_init_machine (void )
arch/arm/mach-ux500/cpu-db8500.c +1 -0
@@ -143,6 +143,7 @@ static struct platform_device db8500_prcmu_device = {static struct platform_device *platform_devs[]__initdata = { &db8500_clk_device, + &dbx500_icn_device, &u8500_dma40_device, &db8500_pmu_device, &db8500_prcmu_device,
arch/arm/mach-ux500/devices-common.c +16 -0
@@ -18,6 +18,22 @@#include "devices-common.h" +static struct resource icn_resources[] = { + [0 ] = { + .start =U8500_ICN_BASE , + .end =U8500_ICN_BASE +SZ_8K -1 , + .flags =IORESOURCE_MEM , + .name ="base" , + }, +}; + +struct platform_device dbx500_icn_device = { + .name ="dbx500-icn" , + .id =-1 , + .num_resources =ARRAY_SIZE (icn_resources), + .resource = icn_resources +}; +static struct platform_device *dbx500_add_gpio (struct device *parent,int id,resource_size_t addr,int irq,struct nmk_gpio_platform_data *pdata)
arch/arm/mach-ux500/devices-common.h +1 -0
@@ -16,6 +16,7 @@#include <linux/platform_data/crypto-ux500.h> struct spi_master_cntlr ; +extern struct platform_device dbx500_icn_device;static inline struct amba_device * dbx500_add_msp_spi(struct device *parent, const char *name,
drivers/bus/Makefile +1 -0
@@ -2,6 +2,7 @@ # Makefile for the bus drivers. # +obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-icn.o obj-$(CONFIG_OMAP_OCP2SCP) += omap-ocp2scp.o # Interconnect bus driver for OMAP SoCs.
Signature · 1 line
1.8.2
PATCH v2 11/12 misc: ux500: Add TPIU driver
In reply to Rickard AnderssonTPIU is Trace Port Interface Unit. Ux500 needs a TPIU driver because in Ux500 the TPIU hardware block loses its settings when the APE power domain is turned off. Settings needs to be saved before the sleep state ApSleep or ApDeepSleep is reached and the block needs to be unlocked and restored when leaving those sleep states. If this is not done PTM tracing with debugger stops working after the first sleep where the power domain is off.
--- drivers/misc/Makefile | 1 + drivers/misc/dbx500-tpiu.c | 182 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 drivers/misc/dbx500-tpiu.c
drivers/misc/Makefile +1 -0
@@ -49,3 +49,4 @@ obj-y += carma/ obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/ obj-$(CONFIG_INTEL_MEI) += mei/ +obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-tpiu.o
drivers/misc/dbx500-tpiu.c new file +182 -0
182 lines not on this page · raw message
Signature · 1 line
1.8.2
PATCH v2 12/12 ARM: ux500: Create TPIU device
In reply to Rickard AnderssonAdd platform device for the ux500 TPIU driver. TPIU is Trace Port Interface Unit. Also add the device to the generic power domain APE.
--- arch/arm/boot/dts/dbx5x0.dtsi | 5 +++++ arch/arm/mach-ux500/board-mop500.c | 1 + arch/arm/mach-ux500/cpu-db8500.c | 1 + arch/arm/mach-ux500/devices-common.c | 16 ++++++++++++++++ arch/arm/mach-ux500/devices-common.h | 1 + 5 files changed, 24 insertions(+)
arch/arm/boot/dts/dbx5x0.dtsi +5 -0
@@ -671,6 +671,11 @@ reg = <0x81000000 0x2000>; }; + tpiu { + compatible = "stericsson,dbx500-tpiu"; + reg = <0x80190000 0x1000>; + }; + external-bus at 50000000 { compatible = "simple-bus"; reg = <0x50000000 0x4000000>;
arch/arm/mach-ux500/board-mop500.c +1 -0
@@ -661,6 +661,7 @@ static void __init init_pm_domains(void)add_platform_device_to_genpd (&db8500_clk_device, &ape_domain);add_platform_device_to_genpd (&dbx500_icn_device, &ape_domain); +add_platform_device_to_genpd (&dbx500_tpiu_device, &ape_domain); }static void __init mop500_init_machine (void )
arch/arm/mach-ux500/cpu-db8500.c +1 -0
@@ -144,6 +144,7 @@ static struct platform_device db8500_prcmu_device = {static struct platform_device *platform_devs[]__initdata = { &db8500_clk_device, &dbx500_icn_device, + &dbx500_tpiu_device, &u8500_dma40_device, &db8500_pmu_device, &db8500_prcmu_device,
arch/arm/mach-ux500/devices-common.c +16 -0
@@ -34,6 +34,22 @@ struct platform_device dbx500_icn_device = { .resource = icn_resources }; +static struct resource tpiu_resources[] = { + [0 ] = { + .start =U8500_TPIU_BASE , + .end =U8500_TPIU_BASE +SZ_4K -1 , + .flags =IORESOURCE_MEM , + .name ="base" , + }, +}; + +struct platform_device dbx500_tpiu_device = { + .name ="dbx500-tpiu" , + .id =-1 , + .num_resources =ARRAY_SIZE (tpiu_resources), + .resource = tpiu_resources +}; +static struct platform_device *dbx500_add_gpio (struct device *parent,int id,resource_size_t addr,int irq,struct nmk_gpio_platform_data *pdata)
arch/arm/mach-ux500/devices-common.h +1 -0
@@ -17,6 +17,7 @@struct spi_master_cntlr ;extern struct platform_device dbx500_icn_device; +extern struct platform_device dbx500_tpiu_device;static inline struct amba_device * dbx500_add_msp_spi(struct device *parent, const char *name,
Signature · 1 line
1.8.2