ARM: OMAP3+: PRM: fix up prm_handling
Subsystems (4)
cover ARM: OMAP3+: PRM: fix up prm_handling
The following series are various fixes and improvements for PRM for I/O Daisy chain support in OMAP4+ with device tree.
This is part 2/6 series which eventually enables framework for suspend-to-ram and cpuidle for OMAP5 and DRA7
Each of series is based on v3.17-rc1 and this specific series is available:
weblink: https://github.com/nmenon/linux-2.6-playground/commits/push/v3.17/prm-fixes
git repo: https://github.com/nmenon/linux-2.6-playground.git push/v3.17/prm-fixes
An complete integrated branch is available here: https://github.com/nmenon/linux-2.6-playground/commits/testing/v3.17/cpu-idle-suspend-dra7-omap5-framework
Nishanth Menon (6):
ARM: OMAP4+: prminst: provide function to find prm_dev instance
offset
ARM: OMAP4: PRM: use the generic prm_inst to allow logic to be
abstracted
ARM: OMAP4+: PRM: register interrupt information from DT
ARM: OMAP4+: PRM: remove "wkup" event
ARM: OMAP4+: PRM: Enable wakeup capability for OMAP5, DRA7
ARM: OMAP3+: PRM: register interrupt information from DT
arch/arm/mach-omap2/prm3xxx.c | 18 ++++++++ arch/arm/mach-omap2/prm44xx.c | 90 ++++++++++++++++++++++++++++++++----- arch/arm/mach-omap2/prminst44xx.c | 40 ++++++++++------- arch/arm/mach-omap2/prminst44xx.h | 3 ++ 4 files changed, 125 insertions(+), 26 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/6 ARM: OMAP4+: prminst: provide function to find prm_dev instance offset
PRM device instance can vary depending on SoC. We already handle the same during reset of the device, However, this is also needed for other logic instances. So, first abstract this out to a generic function.
---
Minor note: this patch has a 'CHECK: extern prototypes should be avoided in .h files' for prminst44xx.h but that is a continuation of existing style in the file.
arch/arm/mach-omap2/prminst44xx.c | 40 +++++++++++++++++++++++-------------- arch/arm/mach-omap2/prminst44xx.h | 3 +++ 2 files changed, 28 insertions(+), 15 deletions(-)
arch/arm/mach-omap2/prminst44xx.c +25 -15
@@ -31,6 +31,8 @@static void __iomem *_prm_bases[OMAP4_MAX_PRCM_PARTITIONS ]; +static s32 prm_dev_inst =PRM_INSTANCE_UNKNOWN ; +/** * omap_prm_base_init - Populates the prm partitions *
@@ -43,6 +45,24 @@ void omap_prm_base_init(void) _prm_bases[OMAP4430_PRCM_MPU_PARTITION ] = prcm_mpu_base; } +s32 omap4_prmst_get_prm_dev_inst (void ) +{ +if (prm_dev_inst !=PRM_INSTANCE_UNKNOWN ) +return prm_dev_inst; + +/* This cannot be done way early at boot.. as things are not setup */ +if (cpu_is_omap44xx ()) + prm_dev_inst =OMAP4430_PRM_DEVICE_INST ; +else if (soc_is_omap54xx ()) + prm_dev_inst =OMAP54XX_PRM_DEVICE_INST ; +else if (soc_is_dra7xx ()) + prm_dev_inst =DRA7XX_PRM_DEVICE_INST ; +else if (soc_is_am43xx ()) + prm_dev_inst =AM43XX_PRM_DEVICE_INST ; + +return prm_dev_inst; +} +/* Read a register in a PRM instance */ u32 omap4_prminst_read_inst_reg (u8 part,s16 inst,u16 idx) {
@@ -169,28 +189,18 @@ int omap4_prminst_deassert_hardreset(u8 shift, u8 part, s16 inst,void omap4_prminst_global_warm_sw_reset (void ) {u32 v; -s16 dev_inst; +s32 inst =omap4_prmst_get_prm_dev_inst (); -if (cpu_is_omap44xx ()) - dev_inst =OMAP4430_PRM_DEVICE_INST ; -else if (soc_is_omap54xx ()) - dev_inst =OMAP54XX_PRM_DEVICE_INST ; -else if (soc_is_dra7xx ()) - dev_inst =DRA7XX_PRM_DEVICE_INST ; -else if (soc_is_am43xx ()) - dev_inst =AM43XX_PRM_DEVICE_INST ; -else +if (inst ==PRM_INSTANCE_UNKNOWN )return ; - v =omap4_prminst_read_inst_reg (OMAP4430_PRM_PARTITION , dev_inst, + v =omap4_prminst_read_inst_reg (OMAP4430_PRM_PARTITION , inst,OMAP4_PRM_RSTCTRL_OFFSET ); v |=OMAP4430_RST_GLOBAL_WARM_SW_MASK ;omap4_prminst_write_inst_reg (v,OMAP4430_PRM_PARTITION , - dev_inst, -OMAP4_PRM_RSTCTRL_OFFSET ); + inst,OMAP4_PRM_RSTCTRL_OFFSET );/* OCP barrier */ v =omap4_prminst_read_inst_reg (OMAP4430_PRM_PARTITION , - dev_inst, -OMAP4_PRM_RSTCTRL_OFFSET ); + inst,OMAP4_PRM_RSTCTRL_OFFSET ); }
arch/arm/mach-omap2/prminst44xx.h +3 -0
@@ -12,6 +12,9 @@#ifndef __ARCH_ASM_MACH_OMAP2_PRMINST44XX_H#define __ARCH_ASM_MACH_OMAP2_PRMINST44XX_H +#define PRM_INSTANCE_UNKNOWN -1 +extern s32 omap4_prmst_get_prm_dev_inst (void ); +/* * In an ideal world, we would not export these low-level functions, * but this will probably take some time to fix properly
Signature · 1 line
1.7.9.5
PATCH 2/6 ARM: OMAP4: PRM: use the generic prm_inst to allow logic to be abstracted
In reply to Nishanth Menonuse the generic function to pick up the prm_instance for a generic logic which can be reused from OMAP4+
--- arch/arm/mach-omap2/prm44xx.c | 47 +++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-)
arch/arm/mach-omap2/prm44xx.c +38 -9
@@ -154,21 +154,36 @@ void omap4_prm_vp_clear_txdone(u8 vp_id)u32 omap4_prm_vcvp_read (u8 offset) { +s32 inst =omap4_prmst_get_prm_dev_inst (); + +if (inst ==PRM_INSTANCE_UNKNOWN ) +return 0 ; +return omap4_prminst_read_inst_reg (OMAP4430_PRM_PARTITION , -OMAP4430_PRM_DEVICE_INST , offset); + inst, offset); }void omap4_prm_vcvp_write (u32 val,u8 offset) { +s32 inst =omap4_prmst_get_prm_dev_inst (); + +if (inst ==PRM_INSTANCE_UNKNOWN ) +return ; +omap4_prminst_write_inst_reg (val,OMAP4430_PRM_PARTITION , -OMAP4430_PRM_DEVICE_INST , offset); + inst, offset); }u32 omap4_prm_vcvp_rmw (u32 mask,u32 bits,u8 offset) { +s32 inst =omap4_prmst_get_prm_dev_inst (); + +if (inst ==PRM_INSTANCE_UNKNOWN ) +return 0 ; +return omap4_prminst_rmw_inst_reg_bits (mask, bits,OMAP4430_PRM_PARTITION , -OMAP4430_PRM_DEVICE_INST , + inst, offset); }
@@ -275,14 +290,18 @@ void omap44xx_prm_restore_irqen(u32 *saved_mask)void omap44xx_prm_reconfigure_io_chain (void ) {int i =0 ; +s32 inst =omap4_prmst_get_prm_dev_inst (); + +if (inst ==PRM_INSTANCE_UNKNOWN ) +return ;/* Trigger WUCLKIN enable */ omap4_prm_rmw_inst_reg_bits (OMAP4430_WUCLK_CTRL_MASK ,OMAP4430_WUCLK_CTRL_MASK , -OMAP4430_PRM_DEVICE_INST , + inst,OMAP4_PRM_IO_PMCTRL_OFFSET ); omap_test_timeout( - (((omap4_prm_read_inst_reg(OMAP4430_PRM_DEVICE_INST, + (((omap4_prm_read_inst_reg(inst, OMAP4_PRM_IO_PMCTRL_OFFSET) & OMAP4430_WUCLK_STATUS_MASK) >> OMAP4430_WUCLK_STATUS_SHIFT) == 1),
@@ -292,10 +311,10 @@ void omap44xx_prm_reconfigure_io_chain(void)/* Trigger WUCLKIN disable */ omap4_prm_rmw_inst_reg_bits (OMAP4430_WUCLK_CTRL_MASK ,0x0 , -OMAP4430_PRM_DEVICE_INST , + inst,OMAP4_PRM_IO_PMCTRL_OFFSET ); omap_test_timeout( - (((omap4_prm_read_inst_reg(OMAP4430_PRM_DEVICE_INST, + (((omap4_prm_read_inst_reg(inst, OMAP4_PRM_IO_PMCTRL_OFFSET) & OMAP4430_WUCLK_STATUS_MASK) >> OMAP4430_WUCLK_STATUS_SHIFT) == 0),
@@ -316,9 +335,14 @@ void omap44xx_prm_reconfigure_io_chain(void)*/ static void __init omap44xx_prm_enable_io_wakeup (void ) { +s32 inst =omap4_prmst_get_prm_dev_inst (); + +if (inst ==PRM_INSTANCE_UNKNOWN ) +return ; +omap4_prm_rmw_inst_reg_bits (OMAP4430_GLOBAL_WUEN_MASK ,OMAP4430_GLOBAL_WUEN_MASK , -OMAP4430_PRM_DEVICE_INST , + inst,OMAP4_PRM_IO_PMCTRL_OFFSET ); }
@@ -333,8 +357,13 @@ static u32 omap44xx_prm_read_reset_sources(void)struct prm_reset_src_map *p;u32 r =0 ;u32 v; +s32 inst =omap4_prmst_get_prm_dev_inst (); + +if (inst ==PRM_INSTANCE_UNKNOWN ) +return 0 ; + - v =omap4_prm_read_inst_reg (OMAP4430_PRM_DEVICE_INST , + v =omap4_prm_read_inst_reg (inst,OMAP4_RM_RSTST ); p = omap44xx_prm_reset_src_map;
Signature · 1 line
1.7.9.5
PATCH 3/6 ARM: OMAP4+: PRM: register interrupt information from DT
In reply to Nishanth MenonAllow the PRM interrupt information to be picked up from device tree. the only exception is for OMAP4 which uses values pre-populated and allows compatibility with older dtb.
--- arch/arm/mach-omap2/prm44xx.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
arch/arm/mach-omap2/prm44xx.c +40 -0
@@ -17,6 +17,7 @@#include <linux/errno.h> #include <linux/err.h> #include <linux/io.h> +#include <linux/of_irq.h> #include "soc.h"
@@ -699,11 +700,50 @@ int __init omap44xx_prm_init(void)return prm_register (&omap44xx_prm_ll_data); } +static struct of_device_id omap_prm_dt_match_table[] = { + { .compatible ="ti,omap4-prm" }, + { .compatible ="ti,omap5-prm" }, + { .compatible ="ti,dra7-prm" }, + { } +}; +static int omap44xx_prm_late_init (void ) { +struct device_node *np; +int irq_num; +if (!(prm_features &PRM_HAS_IO_WAKEUP ))return 0 ; +/* OMAP4+ is DT only now */ +if (!of_have_populated_dt ()) +return 0 ; + + np =of_find_matching_node (NULL , omap_prm_dt_match_table); + +if (!np) { +/* Default loaded up with OMAP4 values */ +if (!cpu_is_omap44xx ()) +return 0 ; + }else { + irq_num =of_irq_get (np,0 ); +/* +* Already have OMAP4 IRQ num. For all other platforms, we need +* IRQ numbers from DT +*/ +if (irq_num <0 && !cpu_is_omap44xx ()) { +if (irq_num == -EPROBE_DEFER ) +return irq_num; + +/* Have nothing to do */ +return 0 ; + } + +/* Once OMAP4 DT is filled as well */ +if (irq_num >=0 ) + omap4_prcm_irq_setup.irq = irq_num; + } +omap44xx_prm_enable_io_wakeup ();return omap_prcm_register_chain_handler (&omap4_prcm_irq_setup);
Signature · 1 line
1.7.9.5
PATCH 4/6 ARM: OMAP4+: PRM: remove "wkup" event
In reply to Nishanth Menon"wkup" event at bit offset 0 exists only on OMAP3. OMAP4430/60 PRM_IRQSTATUS_A9, OMAP5/DRA7 PRM_IRQSTATUS_MPU
register bit 0 is DPLL_CORE_RECAL_ST not wakeup event like OMAP3.
The same applies to AM437x as well.
Remove the wrong definition.
--- arch/arm/mach-omap2/prm44xx.c | 1 - 1 file changed, 1 deletion(-)
arch/arm/mach-omap2/prm44xx.c +0 -1
@@ -33,7 +33,6 @@/* Static data */ static const struct omap_prcm_irq omap4_prcm_irqs[] = { -OMAP_PRCM_IRQ ("wkup" ,0 ,0 ),OMAP_PRCM_IRQ ("io" ,9 ,1 ), };
Signature · 1 line
1.7.9.5
PATCH 5/6 ARM: OMAP4+: PRM: Enable wakeup capability for OMAP5, DRA7
In reply to Nishanth MenonOMAP5 and DRA7 can now use pinctrl based I/O daisychain wakeup capability. So, enable the support.
--- arch/arm/mach-omap2/prm44xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-omap2/prm44xx.c +1 -1
@@ -693,7 +693,7 @@ static struct prm_ll_data omap44xx_prm_ll_data = {int __init omap44xx_prm_init (void ) { -if (cpu_is_omap44xx ()) +if (cpu_is_omap44xx () ||soc_is_omap54xx () ||soc_is_dra7xx ()) prm_features |=PRM_HAS_IO_WAKEUP ;return prm_register (&omap44xx_prm_ll_data);
Signature · 1 line
1.7.9.5
PATCH 6/6 ARM: OMAP3+: PRM: register interrupt information from DT
In reply to Nishanth MenonAllow the PRM interrupt information to be picked up from device tree. OMAP3 may use legacy boot and needs to be compatible with old dtbs (without interrupt populated), for these, we use the value which is pre-populated.
--- arch/arm/mach-omap2/prm3xxx.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/arm/mach-omap2/prm3xxx.c +18 -0
@@ -17,6 +17,7 @@#include <linux/err.h> #include <linux/io.h> #include <linux/irq.h> +#include <linux/of_irq.h> #include "soc.h" #include "common.h"
@@ -649,6 +650,11 @@ int __init omap3xxx_prm_init(void)return prm_register (&omap3xxx_prm_ll_data); } +static struct of_device_id omap3_prm_dt_match_table[] = { + { .compatible ="ti,omap3-prm" }, + { } +}; +static int omap3xxx_prm_late_init (void ) {int ret;
@@ -656,6 +662,18 @@ static int omap3xxx_prm_late_init(void)if (!(prm_features &PRM_HAS_IO_WAKEUP ))return 0 ; +if (of_have_populated_dt ()) { +struct device_node *np; +int irq_num; + + np =of_find_matching_node (NULL , omap3_prm_dt_match_table); +if (np) { + irq_num =of_irq_get (np,0 ); +if (irq_num >=0 ) + omap3_prcm_irq_setup.irq = irq_num; + } + } +omap3xxx_prm_enable_io_wakeup (); ret =omap_prcm_register_chain_handler (&omap3_prcm_irq_setup);if (!ret)
Signature · 1 line
1.7.9.5
Quoted 10 lines · Nishanth Menon
The following series are various fixes and improvements for PRM for I/O Daisy chain support in OMAP4+ with device tree.
This is part 2/6 series which eventually enables framework for suspend-to-ram and cpuidle for OMAP5 and DRA7
Each of series is based on v3.17-rc1 and this specific series is available:
weblink: https://github.com/nmenon/linux-2.6-playground/commits/push/v3.17/prm-fixes
Series also looks reasonable.