OMAP3: hwmod: support to specify the offset position of various SYSCONFIG register bits.
Subsystems (5)
PATCH v4 1/1 OMAP3: hwmod: support to specify the offset position of various SYSCONFIG register bits.
In OMAP3 Some modules like Smartreflex do not have the regular sysconfig register.Instead clockactivity bits are part of another register at a different bit position than the usual bit positions 8 and 9.
In OMAP4, a new scheme is available due to the new protocol between the PRCM and the IPs. Depending of the scheme, the SYSCONFIG bitfields position will be different.
The IP_REVISION register should be at offset 0x00.
It should contain a SCHEME field. From this we can determine whether the IP follows legacy scheme or the new scheme.
31:30 SCHEME Used to distinguish between old scheme and current.
Read 0x0: Legacy protocol.
Read 0x1: New PRCM protocol defined for new OMAP4 IPs
For legacy IP
13:12 MIDLEMODE
11:8 CLOCKACTIVITY 6 EMUSOFT 5 EMUFREE 4:3 SIDLEMODE 2 ENAWAKEUP 1 SOFTRESET 0 AUTOIDLE
For new OMAP4 IP's, the bit position in SYSCONFIG is (for simple target):
5:4 STANDBYMODE (Ex MIDLEMODE) 3:2 IDLEMODE (Ex SIDLEMODE) 1 FREEEMU (Ex EMUFREE) 0 SOFTRESET
Unfortunately In OMAP4 also some IPs will not follow any of these two schemes. This is the case at least for McASP, SmartReflex and some security IPs.
This patch introduces a new field sysc_fields in omap_hwmod_sysconfig which can be used by the hwmod structures to specify the offsets for the sysconfig register of the IP.Also two static structures omap_hwmod_sysc_type1 and omap_hwmod_sysc_type2 are defined which can be used directly to populate the sysc_fields if the IP follows legacy or new OMAP4 scheme. If the IP follows none of these two schemes a new omap_hwmod_sysc_fields structure has to be defined and passed as part of omap_hwmod_sysconfig.
--- arch/arm/mach-omap2/Makefile | 3 +- arch/arm/mach-omap2/omap_hwmod.c | 100 ++++++++++++++++++++++---- arch/arm/mach-omap2/omap_hwmod_common_data.c | 46 ++++++++++++ arch/arm/plat-omap/include/plat/omap_hwmod.h | 74 +++++++++++++++---- 4 files changed, 195 insertions(+), 28 deletions(-) create mode 100644 arch/arm/mach-omap2/omap_hwmod_common_data.c
arch/arm/mach-omap2/Makefile +2 -1
@@ -5,7 +5,8 @@ # Common support obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o -omap-2-3-common = irq.o sdrc.o omap_hwmod.o +omap-2-3-common = irq.o sdrc.o omap_hwmod.o \ + omap_hwmod_common_data.o omap-3-4-common = dpll3xxx.o prcm-common = prcm.o powerdomain.o clock-common = clock.o clock_common_data.o \
arch/arm/mach-omap2/omap_hwmod.c +87 -13
174 lines not on this page · raw message
arch/arm/mach-omap2/omap_hwmod_common_data.c new file +46 -0
46 lines not on this page · raw message
arch/arm/plat-omap/include/plat/omap_hwmod.h +60 -14
104 lines not on this page · raw message
Signature · 1 line
1.7.0.rc1.33.g07cf0f
Paul Walmsley
maintainerHi Thara,
I went ahead and queued this patch, but some minor changes were necessary; please note them for your future patches.
The revised patch is included at the end of the message.
Quoted 10 lines · Thara Gopinath
arch/arm/mach-omap2/omap_hwmod.c +2
-0@@ -137,12 +137,24 @@ static void _write_sysconfig(u32 v, struct omap_hwmod *oh)static int _set_master_standbymode (struct omap_hwmod *oh,u8 standbymode,u32 *v) { +u32 mstandby_mask; +u8 mstandby_shift;
arch/arm/mach-omap2/omap_hwmod.c static void _write_sysconfig(u32 v, struct omap_hwmod *oh) · line 149
Quoted 10 lines
arch/arm/mach-omap2/omap_hwmod.c +4
-2+if (!oh->sysconfig || !(oh->sysconfig->sysc_flags &SYSC_HAS_MIDLEMODE ))return -EINVAL ; - *v &= ~SYSC_MIDLEMODE_MASK ; - *v |=__ffs (standbymode) <<SYSC_MIDLEMODE_SHIFT ; +if (!oh->sysconfig->sysc_fields) { +WARN (!oh->sysconfig->sysc_fields,"offset struct for " +"sysconfig not provided!!!!\n" );
All but one of these exclamation points have been removed throughout the patch -- only one is needed, and probably not even that.
Quoted 34 lines
arch/arm/mach-omap2/omap_hwmod.c +8
-0+return -EINVAL ; + } + + mstandby_shift = oh->sysconfig->sysc_fields->midle_shift; + mstandby_mask = (0x3 << mstandby_shift); + + *v &= ~mstandby_mask; + *v |=__ffs (standbymode) << mstandby_shift;return 0 ; }arch/arm/plat-omap/include/plat/omap_hwmod.h +2
-13@@ -39,19 +39,39 @@struct omap_device ; -/* OCP SYSCONFIG bit shifts/masks */ -#define SYSC_MIDLEMODE_SHIFT 12 -#define SYSC_MIDLEMODE_MASK (0x3 << SYSC_MIDLEMODE_SHIFT) -#define SYSC_CLOCKACTIVITY_SHIFT 8 -#define SYSC_CLOCKACTIVITY_MASK (0x3 << SYSC_CLOCKACTIVITY_SHIFT) -#define SYSC_SIDLEMODE_SHIFT 3 -#define SYSC_SIDLEMODE_MASK (0x3 << SYSC_SIDLEMODE_SHIFT) -#define SYSC_ENAWAKEUP_SHIFT 2 -#define SYSC_ENAWAKEUP_MASK (1 << SYSC_ENAWAKEUP_SHIFT) -#define SYSC_SOFTRESET_SHIFT 1 -#define SYSC_SOFTRESET_MASK (1 << SYSC_SOFTRESET_SHIFT) -#define SYSC_AUTOIDLE_SHIFT 0 -#define SYSC_AUTOIDLE_MASK (1 << SYSC_AUTOIDLE_SHIFT) +extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type1; +extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2;
arch/arm/plat-omap/include/plat/omap_hwmod.h line 53
Quoted 10 lines
arch/arm/plat-omap/include/plat/omap_hwmod.h +10
-0+ +/* +* OCP SYSCONFIG bit shifts/masks TYPE1. These are for IPs compliant +* with the original PRCM protocol defined for OMAP2420 +*/ +#define SYSC_TYPE1_MIDLEMODE_SHIFT 12 +#define SYSC_TYPE1_MIDLEMODE_MASK (0x3 << SYSC_MIDLEMODE_SHIFT) +#define SYSC_TYPE1_CLOCKACTIVITY_SHIFT 8 +#define SYSC_TYPE1_CLOCKACTIVITY_MASK \ + (0x3 << SYSC_CLOCKACTIVITY_SHIFT)
All of these macro definitions have been adjusted to fit on one line. This is to make grepping through the codebase easier, since the macro name and the value will then appear on one line.
arch/arm/plat-omap/include/plat/omap_hwmod.h line 65
Quoted 12 lines
arch/arm/plat-omap/include/plat/omap_hwmod.h +12
-0+#define SYSC_TYPE1_SIDLEMODE_SHIFT 3 +#define SYSC_TYPE1_SIDLEMODE_MASK (0x3 << SYSC_SIDLEMODE_SHIFT) +#define SYSC_TYPE1_ENAWAKEUP_SHIFT 2 +#define SYSC_TYPE1_ENAWAKEUP_MASK (1 << SYSC_ENAWAKEUP_SHIFT) +#define SYSC_TYPE1_SOFTRESET_SHIFT 1 +#define SYSC_TYPE1_SOFTRESET_MASK (1 << SYSC_SOFTRESET_SHIFT) +#define SYSC_TYPE1_AUTOIDLE_SHIFT 0 +#define SYSC_TYPE1_AUTOIDLE_MASK (1 << SYSC_AUTOIDLE_SHIFT) + +/* OCP SYSCONFIG bit shifts/masks TYPE2. These are for IPs compliant +* with the new PRCM protocol defined for new OMAP4 IPs. +*/
This comment was not CodingStyle compliant; this has been fixed.
Quoted 21 lines
arch/arm/plat-omap/include/plat/omap_hwmod.h +9
-1+#define SYSC_TYPE2_SOFTRESET_SHIFT 0 +#define SYSC_TYPE2_SOFTRESET_MASK \ + (1 << SYSC_TYPE2_SOFTRESET_SHIFT) +#define SYSC_TYPE2_SIDLEMODE_SHIFT 2 +#define SYSC_TYPE2_SIDLEMODE_MASK \ + (0x3 << SYSC_TYPE2_SIDLEMODE_SHIFT) +#define SYSC_TYPE2_MIDLEMODE_SHIFT 4 +#define SYSC_TYPE2_MIDLEMODE_MASK \ + (0x3 << SYSC_TYPE2_MIDLEMODE_SHIFT)/* OCP SYSSTATUS bit shifts/masks */ #define SYSS_RESETDONE_SHIFT 0@@ -62,7 +82,6 @@ struct omap_device;#define HWMOD_IDLEMODE_NO (1 << 1)#define HWMOD_IDLEMODE_SMART (1 << 2) -/** * struct omap_hwmod_irq_info - MPU IRQs used by the hwmod * @name: name of the IRQ channel (module local name)
arch/arm/plat-omap/include/plat/omap_hwmod.h struct omap_hwmod_ocp_if { · line 264
Quoted 10 lines
arch/arm/plat-omap/include/plat/omap_hwmod.h +7
-0@@ -236,6 +255,24 @@ struct omap_hwmod_ocp_if {#define CLOCKACT_TEST_NONE 0x3/** +* struct omap_hwmod_sysc_fields - hwmod OCP_SYSCONFIG register field offsets. +* @midle_shift: Offset of the midle bit +* @clkact_shift: Offset of the clockactivity bit +* @sidle_shift: Offset of the sidle bit +* @enawkup_shift: Offset of the enawakeup bit +* @sreset_shift: Offset of the softreset bit +* @autoidle_shift: Offset of the autoidle bit.
The names of the fields in the kerneldoc comments need to match the the actual names of the fields in the structure.
Quoted 40 lines
arch/arm/plat-omap/include/plat/omap_hwmod.h +20
-0+*/ +struct omap_hwmod_sysc_fields { +u8 midle_shift; +u8 clkact_shift; +u8 sidle_shift; +u8 enwkup_shift; +u8 srst_shift; +u8 autoidle_shift; +}; + +/** * struct omap_hwmod_sysconfig - hwmod OCP_SYSCONFIG/OCP_SYSSTATUS data * @rev_offs: IP block revision register offset (from module base addr) * @sysc_offs: OCP_SYSCONFIG register offset (from module base addr) @@ -252,6 +289,14 @@ struct omap_hwmod_ocp_if {* been associated with the clocks marked in @clockact. This field is * only used if HWMOD_SET_DEFAULT_CLOCKACT is set (see below) * +* +* @sysc_fields: structure containing the offset positions of various bits in +* SYSCONFIG register. This can be populated using omap_hwmod_sysc_type1 or +* omap_hwmod_sysc_type2 defined in omap_hwmod_common_data.c depending on +* whether the device ip is compliant with the original PRCM protocol +* defined for OMAP2420 or the new PRCM protocol for new OMAP4 IPs. +* If the device follows a differnt scheme for the sysconfig register , +* then this field has to be populated with the correct offset structure. */ struct omap_hwmod_sysconfig {u16 rev_offs;@@ -260,6 +305,7 @@ struct omap_hwmod_sysconfig {u8 idlemodes;u8 sysc_flags;u8 clockact; +struct omap_hwmod_sysc_fields *sysc_fields; };/** Signature · 1 line
1.7.0.rc1.33.g07cf0f
- Paul
Quoted 1 line
From
23ca5546bc25dac526d5ff0204ac456e0a0ccd2dMon Sep 17 00:00:00 2001
From: Thara Gopinath <[email protected]>
Date: Mon, 8 Feb 2010 21:33:10 +0530
Subject: [PATCH] OMAP3: hwmod: support to specify the offset position of various SYSCONFIG register bits.
In OMAP3 Some modules like Smartreflex do not have the regular sysconfig register.Instead clockactivity bits are part of another register at a different bit position than the usual bit positions 8 and 9.
In OMAP4, a new scheme is available due to the new protocol between the PRCM and the IPs. Depending of the scheme, the SYSCONFIG bitfields position will be different.
The IP_REVISION register should be at offset 0x00.
It should contain a SCHEME field. From this we can determine whether the IP follows legacy scheme or the new scheme.
31:30 SCHEME Used to distinguish between old scheme and current.
Read 0x0: Legacy protocol.
Read 0x1: New PRCM protocol defined for new OMAP4 IPs
For legacy IP
13:12 MIDLEMODE
11:8 CLOCKACTIVITY 6 EMUSOFT 5 EMUFREE 4:3 SIDLEMODE 2 ENAWAKEUP 1 SOFTRESET 0 AUTOIDLE
For new OMAP4 IP's, the bit position in SYSCONFIG is (for simple target):
5:4 STANDBYMODE (Ex MIDLEMODE) 3:2 IDLEMODE (Ex SIDLEMODE) 1 FREEEMU (Ex EMUFREE) 0 SOFTRESET
Unfortunately In OMAP4 also some IPs will not follow any of these two schemes. This is the case at least for McASP, SmartReflex and some security IPs.
This patch introduces a new field sysc_fields in omap_hwmod_sysconfig which can be used by the hwmod structures to specify the offsets for the sysconfig register of the IP.Also two static structures omap_hwmod_sysc_type1 and omap_hwmod_sysc_type2 are defined which can be used directly to populate the sysc_fields if the IP follows legacy or new OMAP4 scheme. If the IP follows none of these two schemes a new omap_hwmod_sysc_fields structure has to be defined and passed as part of omap_hwmod_sysconfig.
--- arch/arm/mach-omap2/Makefile | 3 +- arch/arm/mach-omap2/omap_hwmod.c | 100 ++++++++++++++++++++++---- arch/arm/mach-omap2/omap_hwmod_common_data.c | 46 ++++++++++++ arch/arm/plat-omap/include/plat/omap_hwmod.h | 72 +++++++++++++++---- 4 files changed, 192 insertions(+), 29 deletions(-) create mode 100644 arch/arm/mach-omap2/omap_hwmod_common_data.c
arch/arm/mach-omap2/Makefile +2 -1
@@ -5,7 +5,8 @@ # Common support obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o -omap-2-3-common = irq.o sdrc.o omap_hwmod.o +omap-2-3-common = irq.o sdrc.o omap_hwmod.o \ + omap_hwmod_common_data.o omap-3-4-common = dpll3xxx.o prcm-common = prcm.o powerdomain.o clock-common = clock.o clock_common_data.o \
arch/arm/mach-omap2/omap_hwmod.c +87 -13
174 lines not on this page · raw message
arch/arm/mach-omap2/omap_hwmod_common_data.c new file +46 -0
46 lines not on this page · raw message
arch/arm/plat-omap/include/plat/omap_hwmod.h +57 -15
106 lines not on this page · raw message
Signature · 1 line
1.6.6.GIT
Paul Walmsley
maintainerAlso, the:
#include <linux/list.h>
has been moved from omap_hwmod_common_data.c to plat/omap_hwmod.h. This is because omap_hwmod_common_data.c does not need this header file at all, but plat/omap_hwmod.h does.
- Paul