All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: "Benoît Cousson" <bcousson@baylibre.com>,
	"Tony Lindgren" <tony@atomide.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Russell King" <linux@arm.linux.org.uk>,
	"Paul Walmsley" <paul@pwsan.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>
Cc: linux-omap@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	"Pavel Machek" <pavel@ucw.cz>, "Nishanth Menon" <nm@ti.com>,
	"Ivaylo Dimitrov" <ivo.g.dimitrov.75@gmail.com>,
	"Aaro Koskinen" <aaro.koskinen@iki.fi>,
	"Sebastian Reichel" <sre@kernel.org>,
	"Pali Rohár" <pali.rohar@gmail.com>
Subject: [PATCH 02/10] ARM: OMAP3: Fix crypto support for HS devices
Date: Thu, 26 Feb 2015 14:49:52 +0100	[thread overview]
Message-ID: <1424958600-18881-3-git-send-email-pali.rohar@gmail.com> (raw)
In-Reply-To: <1424958600-18881-1-git-send-email-pali.rohar@gmail.com>

Register crypto hwmod links only if they are not disabled in DT.
If DT information is missing, enable them only for GP devices.

Before this patch crypto hwmod links were always disabled for all HS devices
and it was not possible to use omap-aes and omap-sham linux drivers.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |   79 +++++++++++++++++++++++-----
 1 file changed, 66 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 4e8e93c..de13a06 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -3744,29 +3744,54 @@ static struct omap_hwmod_ocp_if *omap3xxx_hwmod_ocp_ifs[] __initdata = {
 /* GP-only hwmod links */
 static struct omap_hwmod_ocp_if *omap34xx_gp_hwmod_ocp_ifs[] __initdata = {
 	&omap3xxx_l4_sec__timer12,
-	&omap3xxx_l4_core__sham,
-	&omap3xxx_l4_core__aes,
 	NULL
 };
 
 static struct omap_hwmod_ocp_if *omap36xx_gp_hwmod_ocp_ifs[] __initdata = {
 	&omap3xxx_l4_sec__timer12,
-	&omap3xxx_l4_core__sham,
-	&omap3xxx_l4_core__aes,
 	NULL
 };
 
 static struct omap_hwmod_ocp_if *am35xx_gp_hwmod_ocp_ifs[] __initdata = {
 	&omap3xxx_l4_sec__timer12,
-	/*
-	 * Apparently the SHA/MD5 and AES accelerator IP blocks are
-	 * only present on some AM35xx chips, and no one knows which
-	 * ones.  See
-	 * http://www.spinics.net/lists/arm-kernel/msg215466.html So
-	 * if you need these IP blocks on an AM35xx, try uncommenting
-	 * the following lines.
-	 */
+	NULL
+};
+
+/* crypto hwmod links */
+static struct omap_hwmod_ocp_if *omap34xx_sham_hwmod_ocp_ifs[] __initdata = {
+	&omap3xxx_l4_core__sham,
+	NULL
+};
+
+static struct omap_hwmod_ocp_if *omap34xx_aes_hwmod_ocp_ifs[] __initdata = {
+	&omap3xxx_l4_core__aes,
+	NULL
+};
+
+static struct omap_hwmod_ocp_if *omap36xx_sham_hwmod_ocp_ifs[] __initdata = {
+	&omap3xxx_l4_core__sham,
+	NULL
+};
+
+static struct omap_hwmod_ocp_if *omap36xx_aes_hwmod_ocp_ifs[] __initdata = {
+	&omap3xxx_l4_core__aes,
+	NULL
+};
+
+/*
+ * Apparently the SHA/MD5 and AES accelerator IP blocks are
+ * only present on some AM35xx chips, and no one knows which
+ * ones.  See
+ * http://www.spinics.net/lists/arm-kernel/msg215466.html So
+ * if you need these IP blocks on an AM35xx, try uncommenting
+ * the following lines.
+ */
+static struct omap_hwmod_ocp_if *am35xx_sham_hwmod_ocp_ifs[] __initdata = {
 	/* &omap3xxx_l4_core__sham, */
+	NULL
+};
+
+static struct omap_hwmod_ocp_if *am35xx_aes_hwmod_ocp_ifs[] __initdata = {
 	/* &omap3xxx_l4_core__aes, */
 	NULL
 };
@@ -3871,7 +3896,8 @@ static struct omap_hwmod_ocp_if *omap3xxx_dss_hwmod_ocp_ifs[] __initdata = {
 int __init omap3xxx_hwmod_init(void)
 {
 	int r;
-	struct omap_hwmod_ocp_if **h = NULL, **h_gp = NULL;
+	struct omap_hwmod_ocp_if **h = NULL, **h_gp = NULL, **h_sham = NULL, **h_aes = NULL;
+	struct device_node *bus = NULL;
 	unsigned int rev;
 
 	omap_hwmod_init();
@@ -3893,13 +3919,19 @@ int __init omap3xxx_hwmod_init(void)
 	    rev == OMAP3430_REV_ES3_1 || rev == OMAP3430_REV_ES3_1_2) {
 		h = omap34xx_hwmod_ocp_ifs;
 		h_gp = omap34xx_gp_hwmod_ocp_ifs;
+		h_sham = omap34xx_sham_hwmod_ocp_ifs;
+		h_aes = omap34xx_aes_hwmod_ocp_ifs;
 	} else if (rev == AM35XX_REV_ES1_0 || rev == AM35XX_REV_ES1_1) {
 		h = am35xx_hwmod_ocp_ifs;
 		h_gp = am35xx_gp_hwmod_ocp_ifs;
+		h_sham = am35xx_sham_hwmod_ocp_ifs;
+		h_aes = am35xx_aes_hwmod_ocp_ifs;
 	} else if (rev == OMAP3630_REV_ES1_0 || rev == OMAP3630_REV_ES1_1 ||
 		   rev == OMAP3630_REV_ES1_2) {
 		h = omap36xx_hwmod_ocp_ifs;
 		h_gp = omap36xx_gp_hwmod_ocp_ifs;
+		h_sham = omap36xx_sham_hwmod_ocp_ifs;
+		h_aes = omap36xx_aes_hwmod_ocp_ifs;
 	} else {
 		WARN(1, "OMAP3 hwmod family init: unknown chip type\n");
 		return -EINVAL;
@@ -3916,6 +3948,27 @@ int __init omap3xxx_hwmod_init(void)
 			return r;
 	}
 
+	/*
+	 * Register crypto hwmod links only if they are not disabled in DT.
+	 * If DT information is missing, enable them only for GP devices.
+	 */
+
+	if (of_have_populated_dt())
+		bus = of_find_node_by_name(NULL, "ocp");
+
+	if (h_sham && ((!bus && omap_type() == OMAP2_DEVICE_TYPE_GP) ||
+	    (bus && of_device_is_available(of_find_node_by_name(bus, "sham"))))) {
+		r = omap_hwmod_register_links(h_sham);
+		if (r < 0)
+			return r;
+	}
+
+	if (h_aes && ((!bus && omap_type() == OMAP2_DEVICE_TYPE_GP) ||
+	    (bus && of_device_is_available(of_find_node_by_name(bus, "aes"))))) {
+		r = omap_hwmod_register_links(h_aes);
+		if (r < 0)
+			return r;
+	}
 
 	/*
 	 * Register hwmod links specific to certain ES levels of a
-- 
1.7.9.5

  parent reply	other threads:[~2015-02-26 13:49 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26 13:49 [PATCH 00/10] omap3 crypto fixes Pali Rohár
2015-02-26 13:49 ` [PATCH 01/10] ARM: OMAP2+: Return correct error values from device and hwmod Pali Rohár
2015-05-21 11:44   ` Pali Rohár
2015-02-26 13:49 ` Pali Rohár [this message]
2015-02-28 16:24   ` [PATCH 02/10] ARM: OMAP3: Fix crypto support for HS devices Pavel Machek
2015-05-26 10:54     ` Pali Rohár
2015-05-26 10:54       ` Pali Rohár
2015-06-02 18:36       ` Paul Walmsley
2015-02-26 13:49 ` [PATCH 03/10] crypto: omap-sham: Add support for omap3 devices Pali Rohár
     [not found]   ` <1424958600-18881-4-git-send-email-pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-02-28 16:25     ` Pavel Machek
2015-02-28 16:25       ` Pavel Machek
2015-05-15  9:19       ` Pali Rohár
2015-05-15  9:19         ` Pali Rohár
2015-05-18  4:30         ` Herbert Xu
2015-05-18  4:30           ` Herbert Xu
2015-02-26 13:49 ` [PATCH 04/10] crypto: omap-sham: Check for return value from pm_runtime_get_sync Pali Rohár
2015-02-28 16:39   ` Pavel Machek
2015-03-08 10:01   ` [PATCH v2] " Pali Rohár
2015-03-09 20:52     ` Pavel Machek
2015-05-14 21:40     ` Pali Rohár
2015-05-15  0:15       ` Herbert Xu
2015-05-15  7:02       ` Herbert Xu
2015-05-15  9:20         ` Pali Rohár
2015-02-26 13:49 ` [PATCH 05/10] ARM: dts: omap3 hs: Remove timer12 Pali Rohár
2015-02-28 16:54   ` Pavel Machek
2015-02-26 13:49 ` [PATCH 06/10] ARM: dts: omap3: Add missing dmas for crypto Pali Rohár
     [not found]   ` <1424958600-18881-7-git-send-email-pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-02-28 16:46     ` Pavel Machek
2015-02-28 16:46       ` Pavel Machek
2015-03-16 21:44       ` Tony Lindgren
2015-02-26 13:49 ` [PATCH 07/10] ARM: dts: n9/n950: Enable omap crypto support Pali Rohár
2015-02-26 13:49   ` Pali Rohár
2015-02-27 15:43   ` Tony Lindgren
2015-02-27 16:01     ` Pali Rohár
2015-02-27 16:10       ` Tony Lindgren
2015-02-27 16:10         ` Tony Lindgren
2015-02-28 16:41   ` Pavel Machek
2015-03-19 16:43     ` Tony Lindgren
2015-03-19 16:43       ` Tony Lindgren
2015-02-26 13:49 ` [PATCH 08/10] ARM: dts: n900: Enable omap sham and include directly omap34xx.dtsi Pali Rohár
2015-02-28 16:44   ` Pavel Machek
2015-02-26 13:49 ` [PATCH 09/10] ARM: dts: omap3-tao3530: Include " Pali Rohár
2015-02-28 16:44   ` Pavel Machek
2015-02-26 13:50 ` [PATCH 10/10] ARM: dts: Remove files omap34xx-hs.dtsi and omap36xx-hs.dtsi Pali Rohár
     [not found]   ` <1424958600-18881-11-git-send-email-pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-02-28 16:45     ` Pavel Machek
2015-02-28 16:45       ` Pavel Machek
2015-02-26 22:46 ` [PATCH 00/10] omap3 crypto fixes Aaro Koskinen
2015-02-27 12:40   ` Pali Rohár
2015-03-07 23:19     ` Aaro Koskinen
2015-03-07 23:19       ` Aaro Koskinen
2015-03-06 18:36 ` Tony Lindgren
2015-03-06 18:36   ` Tony Lindgren
     [not found]   ` <20150306183631.GA13520-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2015-03-06 19:16     ` Pali Rohár
2015-03-06 19:16       ` Pali Rohár
2015-03-06 19:18       ` Tony Lindgren
2015-03-06 22:23   ` Aaro Koskinen
     [not found]     ` <20150306222306.GB587-+UqvGBo8NkiJ/SmVcN9c7yH8jP4CeeTLqBW4ids5wwA@public.gmane.org>
2015-03-08 10:01       ` Pali Rohár
2015-03-08 10:01         ` Pali Rohár
2015-03-08 16:35         ` Paul Walmsley
2015-03-08 16:35           ` Paul Walmsley
2015-03-15  9:59           ` Pali Rohár
2015-05-14 21:17     ` Pali Rohár
2015-05-14 21:34       ` Tony Lindgren
     [not found]         ` <20150514213418.GP15563-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2015-05-14 21:39           ` Pali Rohár
2015-05-14 21:39             ` Pali Rohár
2015-05-14 22:03             ` Tony Lindgren
2015-05-14 22:03               ` Tony Lindgren

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=1424958600-18881-3-git-send-email-pali.rohar@gmail.com \
    --to=pali.rohar@gmail.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=bcousson@baylibre.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=ivo.g.dimitrov.75@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=nm@ti.com \
    --cc=paul@pwsan.com \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.