Skip to content

Commit f13acab

Browse files
committed
Merge tag 'omap-devel-a-for-3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/pjw/omap-pending into omap-for-v3.10/crypto
For OMAP2+ SoCs, convert the SHA/MD5 and AES accelerator integration code and data to use hwmod and omap_device. This is a prerequisite for moving the hwmod code out of arch/arm. Basic test logs are available at: http://www.pwsan.com/omap/testlogs/sham_aes_integration_devel_3.10/20130330155313/
2 parents 78e52e0 + 1cb804b commit f13acab

11 files changed

+401
-153
lines changed

arch/arm/mach-omap2/cclock2430_data.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,9 +1978,11 @@ static struct omap_clk omap2430_clks[] = {
19781978
CLK(NULL,"sdrc_ick",&sdrc_ick),
19791979
CLK(NULL,"des_ick",&des_ick),
19801980
CLK("omap-sham","ick",&sha_ick),
1981-
CLK("omap_rng","ick",&rng_ick),
1981+
CLK(NULL,"sha_ick",&sha_ick),
1982+
CLK("omap_rng", "ick",&rng_ick),
19821983
CLK(NULL,"rng_ick",&rng_ick),
19831984
CLK("omap-aes","ick",&aes_ick),
1985+
CLK(NULL,"aes_ick",&aes_ick),
19841986
CLK(NULL,"pka_ick",&pka_ick),
19851987
CLK(NULL,"usb_fck",&usb_fck),
19861988
CLK("musb-omap2430","ick",&usbhs_ick),

arch/arm/mach-omap2/cclock33xx_data.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,14 @@ static struct clk smartreflex1_fck;
413413
DEFINE_STRUCT_CLK_HW_OMAP(smartreflex1_fck, NULL);
414414
DEFINE_STRUCT_CLK(smartreflex1_fck, dpll_core_ck_parents, clk_ops_null);
415415

416+
static struct clk sha0_fck;
417+
DEFINE_STRUCT_CLK_HW_OMAP(sha0_fck, NULL);
418+
DEFINE_STRUCT_CLK(sha0_fck, dpll_core_ck_parents, clk_ops_null);
419+
420+
static struct clk aes0_fck;
421+
DEFINE_STRUCT_CLK_HW_OMAP(aes0_fck, NULL);
422+
DEFINE_STRUCT_CLK(aes0_fck, dpll_core_ck_parents, clk_ops_null);
423+
416424
/*
417425
* Modules clock nodes
418426
*
@@ -878,6 +886,8 @@ static struct omap_clk am33xx_clks[] = {
878886
CLK(NULL,"mmu_fck",&mmu_fck),
879887
CLK(NULL,"smartreflex0_fck",&smartreflex0_fck),
880888
CLK(NULL,"smartreflex1_fck",&smartreflex1_fck),
889+
CLK(NULL,"sha0_fck",&sha0_fck),
890+
CLK(NULL,"aes0_fck",&aes0_fck),
881891
CLK(NULL,"timer1_fck",&timer1_fck),
882892
CLK(NULL,"timer2_fck",&timer2_fck),
883893
CLK(NULL,"timer3_fck",&timer3_fck),

arch/arm/mach-omap2/cclock3xxx_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,8 +3471,10 @@ static struct omap_clk omap3xxx_clks[] = {
34713471
CLK("usbhs_tll","usb_tll_hs_usb_ch1_clk",&dummy_ck),
34723472
CLK(NULL,"init_60m_fclk",&dummy_ck),
34733473
CLK(NULL,"gpt1_fck",&gpt1_fck),
3474+
CLK(NULL,"aes2_ick",&aes2_ick),
34743475
CLK(NULL,"wkup_32k_fck",&wkup_32k_fck),
34753476
CLK(NULL,"gpio1_dbck",&gpio1_dbck),
3477+
CLK(NULL,"sha12_ick",&sha12_ick),
34763478
CLK(NULL,"wdt2_fck",&wdt2_fck),
34773479
CLK("omap_wdt","ick",&wdt2_ick),
34783480
CLK(NULL,"wdt2_ick",&wdt2_ick),

arch/arm/mach-omap2/devices.c

Lines changed: 20 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -504,140 +504,31 @@ static void omap_init_rng(void)
504504
WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
505505
}
506506

507-
#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
508-
509-
#ifdef CONFIG_ARCH_OMAP2
510-
static struct resource omap2_sham_resources[] = {
511-
{
512-
.start= OMAP24XX_SEC_SHA1MD5_BASE,
513-
.end= OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
514-
.flags= IORESOURCE_MEM,
515-
},
516-
{
517-
.start= 51 + OMAP_INTC_START,
518-
.flags= IORESOURCE_IRQ,
519-
}
520-
};
521-
static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
522-
#else
523-
#define omap2_sham_resourcesNULL
524-
#define omap2_sham_resources_sz0
525-
#endif
526-
527-
#ifdef CONFIG_ARCH_OMAP3
528-
static struct resource omap3_sham_resources[] = {
529-
{
530-
.start= OMAP34XX_SEC_SHA1MD5_BASE,
531-
.end= OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
532-
.flags= IORESOURCE_MEM,
533-
},
534-
{
535-
.start= 49 + OMAP_INTC_START,
536-
.flags= IORESOURCE_IRQ,
537-
},
538-
{
539-
.start= OMAP34XX_DMA_SHA1MD5_RX,
540-
.flags= IORESOURCE_DMA,
541-
}
542-
};
543-
static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
544-
#else
545-
#define omap3_sham_resourcesNULL
546-
#define omap3_sham_resources_sz0
547-
#endif
548-
549-
static struct platform_device sham_device = {
550-
.name= "omap-sham",
551-
.id= -1,
552-
};
553-
554-
static void omap_init_sham(void)
507+
static void __init omap_init_sham(void)
555508
{
556-
if (cpu_is_omap24xx()) {
557-
sham_device.resource = omap2_sham_resources;
558-
sham_device.num_resources = omap2_sham_resources_sz;
559-
} else if (cpu_is_omap34xx()) {
560-
sham_device.resource = omap3_sham_resources;
561-
sham_device.num_resources = omap3_sham_resources_sz;
562-
} else {
563-
pr_err("%s: platform not supported\n", __func__);
564-
return;
565-
}
566-
platform_device_register(&sham_device);
567-
}
568-
#else
569-
static inline void omap_init_sham(void) { }
570-
#endif
571-
572-
#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
573-
574-
#ifdef CONFIG_ARCH_OMAP2
575-
static struct resource omap2_aes_resources[] = {
576-
{
577-
.start= OMAP24XX_SEC_AES_BASE,
578-
.end= OMAP24XX_SEC_AES_BASE + 0x4C,
579-
.flags= IORESOURCE_MEM,
580-
},
581-
{
582-
.start= OMAP24XX_DMA_AES_TX,
583-
.flags= IORESOURCE_DMA,
584-
},
585-
{
586-
.start= OMAP24XX_DMA_AES_RX,
587-
.flags= IORESOURCE_DMA,
588-
}
589-
};
590-
static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
591-
#else
592-
#define omap2_aes_resourcesNULL
593-
#define omap2_aes_resources_sz0
594-
#endif
509+
struct omap_hwmod *oh;
510+
struct platform_device *pdev;
595511

596-
#ifdef CONFIG_ARCH_OMAP3
597-
static struct resource omap3_aes_resources[] = {
598-
{
599-
.start= OMAP34XX_SEC_AES_BASE,
600-
.end= OMAP34XX_SEC_AES_BASE + 0x4C,
601-
.flags= IORESOURCE_MEM,
602-
},
603-
{
604-
.start= OMAP34XX_DMA_AES2_TX,
605-
.flags= IORESOURCE_DMA,
606-
},
607-
{
608-
.start= OMAP34XX_DMA_AES2_RX,
609-
.flags= IORESOURCE_DMA,
610-
}
611-
};
612-
static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
613-
#else
614-
#define omap3_aes_resourcesNULL
615-
#define omap3_aes_resources_sz0
616-
#endif
512+
oh = omap_hwmod_lookup("sham");
513+
if (!oh)
514+
return;
617515

618-
static struct platform_device aes_device = {
619-
.name= "omap-aes",
620-
.id= -1,
621-
};
516+
pdev = omap_device_build("omap-sham", -1, oh, NULL, 0);
517+
WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
518+
}
622519

623-
static void omap_init_aes(void)
520+
static void __init omap_init_aes(void)
624521
{
625-
if (cpu_is_omap24xx()) {
626-
aes_device.resource = omap2_aes_resources;
627-
aes_device.num_resources = omap2_aes_resources_sz;
628-
} else if (cpu_is_omap34xx()) {
629-
aes_device.resource = omap3_aes_resources;
630-
aes_device.num_resources = omap3_aes_resources_sz;
631-
} else {
632-
pr_err("%s: platform not supported\n", __func__);
522+
struct omap_hwmod *oh;
523+
struct platform_device *pdev;
524+
525+
oh = omap_hwmod_lookup("aes");
526+
if (!oh)
633527
return;
634-
}
635-
platform_device_register(&aes_device);
636-
}
637528

638-
#else
639-
static inline void omap_init_aes(void) { }
640-
#endif
529+
pdev = omap_device_build("omap-aes", -1, oh, NULL, 0);
530+
WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n");
531+
}
641532

642533
/*-------------------------------------------------------------------------*/
643534

@@ -764,11 +655,11 @@ static int __init omap2_init_devices(void)
764655
omap_init_dmic();
765656
omap_init_mcpdm();
766657
omap_init_mcspi();
658+
omap_init_sham();
659+
omap_init_aes();
767660
}
768661
omap_init_sti();
769662
omap_init_rng();
770-
omap_init_sham();
771-
omap_init_aes();
772663
omap_init_vout();
773664
omap_init_ocp2scp();
774665

arch/arm/mach-omap2/omap_hwmod_2420_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ static struct omap_hwmod_ocp_if *omap2420_hwmod_ocp_ifs[] __initdata = {
610610
&omap2420_l4_core__mcbsp2,
611611
&omap2420_l4_core__msdi1,
612612
&omap2xxx_l4_core__rng,
613+
&omap2xxx_l4_core__sham,
614+
&omap2xxx_l4_core__aes,
613615
&omap2420_l4_core__hdq1w,
614616
&omap2420_l4_wkup__counter_32k,
615617
&omap2420_l3__gpmc,

arch/arm/mach-omap2/omap_hwmod_2430_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,8 @@ static struct omap_hwmod_ocp_if *omap2430_hwmod_ocp_ifs[] __initdata = {
963963
&omap2430_l4_core__mcbsp5,
964964
&omap2430_l4_core__hdq1w,
965965
&omap2xxx_l4_core__rng,
966+
&omap2xxx_l4_core__sham,
967+
&omap2xxx_l4_core__aes,
966968
&omap2430_l4_wkup__counter_32k,
967969
&omap2430_l3__gpmc,
968970
NULL,

arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,24 @@ static struct omap_hwmod_addr_space omap2_rng_addr_space[] = {
138138
{ }
139139
};
140140

141+
static struct omap_hwmod_addr_space omap2xxx_sham_addrs[] = {
142+
{
143+
.pa_start= 0x480a4000,
144+
.pa_end= 0x480a4000 + 0x64 - 1,
145+
.flags= ADDR_TYPE_RT
146+
},
147+
{ }
148+
};
149+
150+
static struct omap_hwmod_addr_space omap2xxx_aes_addrs[] = {
151+
{
152+
.pa_start= 0x480a6000,
153+
.pa_end= 0x480a6000 + 0x50 - 1,
154+
.flags= ADDR_TYPE_RT
155+
},
156+
{ }
157+
};
158+
141159
/*
142160
* Common interconnect data
143161
*/
@@ -389,3 +407,21 @@ struct omap_hwmod_ocp_if omap2xxx_l4_core__rng = {
389407
.addr= omap2_rng_addr_space,
390408
.user= OCP_USER_MPU | OCP_USER_SDMA,
391409
};
410+
411+
/* l4 core -> sham interface */
412+
struct omap_hwmod_ocp_if omap2xxx_l4_core__sham = {
413+
.master= &omap2xxx_l4_core_hwmod,
414+
.slave= &omap2xxx_sham_hwmod,
415+
.clk= "sha_ick",
416+
.addr= omap2xxx_sham_addrs,
417+
.user= OCP_USER_MPU | OCP_USER_SDMA,
418+
};
419+
420+
/* l4 core -> aes interface */
421+
struct omap_hwmod_ocp_if omap2xxx_l4_core__aes = {
422+
.master= &omap2xxx_l4_core_hwmod,
423+
.slave= &omap2xxx_aes_hwmod,
424+
.clk= "aes_ick",
425+
.addr= omap2xxx_aes_addrs,
426+
.user= OCP_USER_MPU | OCP_USER_SDMA,
427+
};

arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,3 +864,84 @@ struct omap_hwmod omap2xxx_rng_hwmod = {
864864
.flags= HWMOD_INIT_NO_RESET,
865865
.class= &omap2_rng_hwmod_class,
866866
};
867+
868+
/* SHAM */
869+
870+
static struct omap_hwmod_class_sysconfig omap2_sham_sysc = {
871+
.rev_offs= 0x5c,
872+
.sysc_offs= 0x60,
873+
.syss_offs= 0x64,
874+
.sysc_flags= (SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE |
875+
SYSS_HAS_RESET_STATUS),
876+
.sysc_fields= &omap_hwmod_sysc_type1,
877+
};
878+
879+
static struct omap_hwmod_class omap2xxx_sham_class = {
880+
.name= "sham",
881+
.sysc= &omap2_sham_sysc,
882+
};
883+
884+
static struct omap_hwmod_irq_info omap2_sham_mpu_irqs[] = {
885+
{ .irq = 51 + OMAP_INTC_START, },
886+
{ .irq = -1 }
887+
};
888+
889+
static struct omap_hwmod_dma_info omap2_sham_sdma_chs[] = {
890+
{ .name = "rx", .dma_req = 13 },
891+
{ .dma_req = -1 }
892+
};
893+
894+
struct omap_hwmod omap2xxx_sham_hwmod = {
895+
.name= "sham",
896+
.mpu_irqs= omap2_sham_mpu_irqs,
897+
.sdma_reqs= omap2_sham_sdma_chs,
898+
.main_clk= "l4_ck",
899+
.prcm= {
900+
.omap2 = {
901+
.module_offs = CORE_MOD,
902+
.prcm_reg_id = 4,
903+
.module_bit = OMAP24XX_EN_SHA_SHIFT,
904+
.idlest_reg_id = 4,
905+
.idlest_idle_bit = OMAP24XX_ST_SHA_SHIFT,
906+
},
907+
},
908+
.class= &omap2xxx_sham_class,
909+
};
910+
911+
/* AES */
912+
913+
static struct omap_hwmod_class_sysconfig omap2_aes_sysc = {
914+
.rev_offs= 0x44,
915+
.sysc_offs= 0x48,
916+
.syss_offs= 0x4c,
917+
.sysc_flags= (SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE |
918+
SYSS_HAS_RESET_STATUS),
919+
.sysc_fields= &omap_hwmod_sysc_type1,
920+
};
921+
922+
static struct omap_hwmod_class omap2xxx_aes_class = {
923+
.name= "aes",
924+
.sysc= &omap2_aes_sysc,
925+
};
926+
927+
static struct omap_hwmod_dma_info omap2_aes_sdma_chs[] = {
928+
{ .name = "tx", .dma_req = 9 },
929+
{ .name = "rx", .dma_req = 10 },
930+
{ .dma_req = -1 }
931+
};
932+
933+
struct omap_hwmod omap2xxx_aes_hwmod = {
934+
.name= "aes",
935+
.sdma_reqs= omap2_aes_sdma_chs,
936+
.main_clk= "l4_ck",
937+
.prcm= {
938+
.omap2 = {
939+
.module_offs = CORE_MOD,
940+
.prcm_reg_id = 4,
941+
.module_bit = OMAP24XX_EN_AES_SHIFT,
942+
.idlest_reg_id = 4,
943+
.idlest_idle_bit = OMAP24XX_ST_AES_SHIFT,
944+
},
945+
},
946+
.class= &omap2xxx_aes_class,
947+
};

0 commit comments

Comments
 (0)