devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jon Hunter <jon-hunter@ti.com>
To: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>,
	Tony Lindgren <tony@atomide.com>,
	Rob Herring <rob.herring@calxeda.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Paul Walmsley <paul@pwsan.com>,
	device-tree <devicetree-discuss@lists.ozlabs.org>,
	linux-omap <linux-omap@vger.kernel.org>,
	linux-arm <linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC RESEND 2/4] ARM: OMAP3: Dynamically disable secure timer nodes for secure devices
Date: Thu, 16 Aug 2012 11:57:42 -0500	[thread overview]
Message-ID: <502D2686.4090107@ti.com> (raw)
In-Reply-To: <502B6838.9080907@ti.com>


On 08/15/2012 04:13 AM, Vaibhav Hiremath wrote:
> 
> 
> On 7/14/2012 3:56 AM, Jon Hunter wrote:
>> OMAP3 devices may or may not have security features enabled. Security enabled
>> devices are known as high-secure (HS) and devices without security are known as
>> general purpose (GP).
>>
>> For OMAP3 devices there are 12 general purpose timers available. On secure
>> devices the 12th timer is reserved for secure usage and so cannot be used by
>> the kernel, where as for a GP device it is available. We can detect the OMAP
>> device type, secure or GP, at runtime via an on-chip register. Today, when not
>> using DT, we do not register the 12th timer as a linux device if the device is
>> secure.
>>
>> When using device tree, device tree is going to register all the timer devices
>> it finds in the device tree blob. To prevent device tree from registering 12th
>> timer on a secure OMAP3 device we can add a status property to the timer
>> binding with the value "disabled" at boot time. Note that timer 12 on a OMAP3
>> device has a property "ti,timer-secure" to indicate that it will not be
>> available on a secure device and so for secure OMAP3 devices, we search for
>> timers with this property and then disable them. Using the prom_add_property()
>> function to dynamically add a property was a recommended approach suggested by
>> Rob Herring [1].
>>
>> I have tested this on an OMAP3 GP device and faking it to pretend to be a
>> secure device to ensure that any timers marked with "ti,timer-secure" are not
>> registered on boot. I have also made sure that all timers are registered as
>> expected on a GP device by default.
>>
>> [1] http://comments.gmane.org/gmane.linux.ports.arm.omap/79203
>>
>> Signed-off-by: Jon Hunter <jon-hunter@ti.com>
>> ---
>>  arch/arm/mach-omap2/board-generic.c |    1 +
>>  arch/arm/mach-omap2/common.h        |    1 +
>>  arch/arm/mach-omap2/timer.c         |   36 +++++++++++++++++++++++++++++++++++
>>  3 files changed, 38 insertions(+)
>>
>> diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
>> index 6f93a20..20124d7 100644
>> --- a/arch/arm/mach-omap2/board-generic.c
>> +++ b/arch/arm/mach-omap2/board-generic.c
>> @@ -40,6 +40,7 @@ static struct of_device_id omap_dt_match_table[] __initdata = {
>>  static void __init omap_generic_init(void)
>>  {
>>  	omap_sdrc_init(NULL, NULL);
>> +	omap_dmtimer_init();
>>  
>>  	of_platform_populate(NULL, omap_dt_match_table, NULL, NULL);
>>  }
>> diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
>> index 1f65b18..d6a4875 100644
>> --- a/arch/arm/mach-omap2/common.h
>> +++ b/arch/arm/mach-omap2/common.h
>> @@ -326,6 +326,7 @@ extern void omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
>>  				      struct omap_sdrc_params *sdrc_cs1);
>>  struct omap2_hsmmc_info;
>>  extern int omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers);
>> +extern void omap_dmtimer_init(void);
>>  
>>  #endif /* __ASSEMBLER__ */
>>  #endif /* __ARCH_ARM_MACH_OMAP2PLUS_COMMON_H */
>> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
>> index 13d20c8..e3b9931 100644
>> --- a/arch/arm/mach-omap2/timer.c
>> +++ b/arch/arm/mach-omap2/timer.c
>> @@ -36,6 +36,7 @@
>>  #include <linux/clocksource.h>
>>  #include <linux/clockchips.h>
>>  #include <linux/slab.h>
>> +#include <linux/of.h>
>>  
>>  #include <asm/mach/time.h>
>>  #include <plat/dmtimer.h>
>> @@ -482,6 +483,41 @@ static int __init omap2_dm_timer_init(void)
>>  }
>>  arch_initcall(omap2_dm_timer_init);
>>  
>> +static struct property timer_disabled = {
>> +	.name = "status",
>> +	.length = sizeof("disabled"),
>> +	.value = "disabled",
>> +};
>> +
>> +static struct of_device_id omap3_timer_match[] __initdata = {
>> +	{ .compatible = "ti,omap3-timer", },
>> +	{ }
>> +};
>> +
>> +/**
>> + * omap_dmtimer_init - initialisation function when device tree is used
>> + *
>> + * For secure OMAP3 devices, timers with device type "timer-secure" cannot
>> + * be used by the kernel as they are reserved. Therefore, to prevent the
>> + * kernel registering these devices remove them dynamically from the device
>> + * tree on boot.
>> + */
>> +void __init omap_dmtimer_init(void)
>> +{
>> +	struct device_node *np;
>> +
>> +	if (!cpu_is_omap34xx())
>> +		return;
>> +
> 
> Sorry for responding so late, but why only omap34xx check here?
> Isn't this applicable to all omap & non-omap devices?

It is only applicable to omap3 devices as far as omap is concerned.

By non-omap, you are referring to the AMxxx stuff?

Do AMxxx devices even support security (ie. secure boot and have secure
peripherals)? If not then this will work for AMxxx devices too.

Let me know if the changelog is not clear why this is needed for an
omap3 device.

Jon



  reply	other threads:[~2012-08-16 16:57 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13 22:26 [RFC RESEND 0/4] ARM: OMAP3+: Add device-tree support for timers Jon Hunter
2012-07-13 22:26 ` [RFC RESEND 1/4] arm/dts: OMAP: Add timer nodes Jon Hunter
2012-07-14  2:15   ` Rob Herring
     [not found]     ` <5000D647.4090200-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-07-14  5:30       ` Mis?use of aliases Mitch Bradley
     [not found]         ` <50010402.3050502-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
2012-07-14 16:37           ` David Gibson
     [not found]             ` <20120714163701.GI11326-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2012-07-14 17:07               ` Mitch Bradley
     [not found]                 ` <5001A745.3000509-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
2012-07-15  7:39                   ` David Gibson
2012-07-14  6:56       ` [RFC RESEND 1/4] arm/dts: OMAP: Add timer nodes Paul Walmsley
2012-07-14 14:01         ` Rob Herring
     [not found]           ` <50017BB1.8010702-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-07-14 17:42             ` Paul Walmsley
2012-07-16 17:48               ` Paul Walmsley
2012-07-16 15:56     ` Jon Hunter
2012-07-18  7:19       ` Tony Lindgren
2012-07-18 15:11         ` Jon Hunter
2012-07-23 15:24       ` Jon Hunter
2012-08-15  9:11         ` Vaibhav Hiremath
2012-08-16 15:04           ` Jon Hunter
2012-08-30 20:14             ` Tony Lindgren
2012-09-07 20:26               ` Jon Hunter
2012-09-07 20:56                 ` Tony Lindgren
2012-09-07 21:16                   ` Jon Hunter
2012-09-06 13:45         ` Rob Herring
     [not found]           ` <5048A8F6.6080108-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-09-07  2:09             ` Jon Hunter
2012-07-13 22:26 ` [RFC RESEND 2/4] ARM: OMAP3: Dynamically disable secure timer nodes for secure devices Jon Hunter
2012-08-15  9:13   ` Vaibhav Hiremath
2012-08-16 16:57     ` Jon Hunter [this message]
     [not found]       ` <502D2686.4090107-l0cyMroinI0@public.gmane.org>
2012-08-17  5:32         ` Hiremath, Vaibhav
2012-08-17 12:24           ` Jon Hunter
2012-08-24 15:56             ` Hiremath, Vaibhav
2012-07-13 22:26 ` [RFC RESEND 3/4] ARM: OMAP4: Add timer clock aliases for device-tree Jon Hunter
2012-07-13 22:26 ` [RFC RESEND 4/4] ARM: OMAP: Add DT support for timer driver Jon Hunter
2012-07-13 23:41   ` Paul Walmsley
     [not found]     ` <alpine.DEB.2.00.1207131740460.25585-rwI8Ez+7Ko+d5PgPZx9QOdBPR1lH4CV8@public.gmane.org>
2012-07-14  0:57       ` Jon Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=502D2686.4090107@ti.com \
    --to=jon-hunter@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=hvaibhav@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    --cc=rob.herring@calxeda.com \
    --cc=tarun.kanti@ti.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).