omap: mailbox: hwmod support
Subsystems (4)
v3 cover omap: mailbox: hwmod support
Tested on 3430, based of pm-core branch. It may require rebase once the mailbox git pull is made.
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg39719.html
** v3 **
- Taken mailbox hwmod as is from Benoit original branch.
- Put back numbers for irq, addresses instead of considering them as magic numbers.
- Follow the declaration layout for omap4 hwmods.
- Using pm_runtime to enable the clocks.
TBD: Cleanup, once omap_device_get_rt_va can be called by drivers using pdev and the proper omap_device_reset API is submitted.
** v2 **
- Added omap4 hwmod support.
- Moved "mailbox_ick" from hwmod to hwmod_if (omap 2/3)
- Declared sysc classes for omap 2/3
** v1 **
1. omap: mailbox: initial hwmod support for omap3 Changes were made to:
- Rebase to latest code.
- Detect the hwmod by filling prcm union for omap2, without this it was unable to build the hwmod at runtime.
- Replace magic number for defines.
- Use ioremap again instead of relying on the one made by hwmod, as noted in http://patchwork.kernel.org/patch/101661/
2. omap: mailbox: initial hwmod support for omap2
Was only compiled tested!! Unfortunately I don't have the HW for it.
Benoit Cousson (1):
OMAP4: hwmod data: add mailbox data
Felipe Contreras (3):
OMAP3: hwmod data: add mailbox data
OMAP: mailbox: build device using omap_device/omap_hwmod
OMAP: mailbox: add omap_device latency information
omar ramirez (1):
OMAP2: hwmod data: add mailbox data
arch/arm/mach-omap2/devices.c | 102 ++++++---------------------- arch/arm/mach-omap2/mailbox.c | 18 ++--- arch/arm/mach-omap2/omap_hwmod_2420_data.c | 73 ++++++++++++++++++++ arch/arm/mach-omap2/omap_hwmod_2430_data.c | 72 +++++++++++++++++++ arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 71 +++++++++++++++++++ arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 68 ++++++++++++++++++ 6 files changed, 310 insertions(+), 94 deletions(-)
PATCH v3 1/5 OMAP2: hwmod data: add mailbox data
Mailbox hwmod data for omap2430 and 2420.
--- arch/arm/mach-omap2/omap_hwmod_2420_data.c | 73 ++++++++++++++++++++++++++++ arch/arm/mach-omap2/omap_hwmod_2430_data.c | 72 +++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod_2420_data.c +73 -0
@@ -778,6 +778,76 @@ static struct omap_hwmod omap2420_gpio4_hwmod = { .slaves_cnt = ARRAY_SIZE(omap2420_gpio4_slaves), .class = &omap242x_gpio_hwmod_class, .dev_attr = &gpio_dev_attr, + .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420), +}; + +/* +* 'mailbox' class +* mailbox module allowing communication between the on-chip processors +* using a queued mailbox-interrupt mechanism. +*/ + +static struct omap_hwmod_class_sysconfig omap2420_mailbox_sysc = { + .rev_offs =0x000 , + .sysc_offs =0x010 , + .syss_offs =0x014 , + .sysc_flags = (SYSC_HAS_CLOCKACTIVITY |SYSC_HAS_SIDLEMODE | +SYSC_HAS_SOFTRESET |SYSC_HAS_AUTOIDLE ), + .idlemodes = (SIDLE_FORCE |SIDLE_NO |SIDLE_SMART ), + .sysc_fields = &omap_hwmod_sysc_type1, +}; + +static struct omap_hwmod_class omap2420_mailbox_hwmod_class = { + .name ="mailbox" , + .sysc = &omap2420_mailbox_sysc, +}; + +/* mailbox */ +static struct omap_hwmod omap2420_mailbox_hwmod; +static struct omap_hwmod_irq_info omap2420_mailbox_irqs[] = { + { .name ="dsp" , .irq =26 , }, + { .name ="iva" , .irq =34 , }, +}; + +static struct omap_hwmod_addr_space omap2420_mailbox_addrs[] = { + { + .pa_start =0x48094000 , + .pa_end =0x480941ff , + .flags =ADDR_TYPE_RT , + }, +}; + +/* l4_core -> mailbox */ +static struct omap_hwmod_ocp_if omap2420_l4_core__mailbox = { + .master = &omap2420_l4_core_hwmod, + .slave = &omap2420_mailbox_hwmod, + .clk ="mailboxes_ick" , + .addr = omap2420_mailbox_addrs, + .addr_cnt =ARRAY_SIZE (omap2420_mailbox_addrs), + .user =OCP_USER_MPU |OCP_USER_SDMA , +}; + +/* mailbox slave ports */ +static struct omap_hwmod_ocp_if *omap2420_mailbox_slaves[] = { + &omap2420_l4_core__mailbox, +}; + +static struct omap_hwmod omap2420_mailbox_hwmod = { + .name ="mailbox" , + .class = &omap2420_mailbox_hwmod_class, + .mpu_irqs = omap2420_mailbox_irqs, + .mpu_irqs_cnt =ARRAY_SIZE (omap2420_mailbox_irqs), + .prcm = { + .omap2 = { + .prcm_reg_id =1 , + .module_bit =OMAP24XX_EN_MAILBOXES_SHIFT , + .module_offs =CORE_MOD , + .idlest_reg_id =1 , + .idlest_idle_bit =OMAP24XX_ST_MAILBOXES_SHIFT , + }, + }, + .slaves = omap2420_mailbox_slaves, + .slaves_cnt =ARRAY_SIZE (omap2420_mailbox_slaves), .omap_chip =OMAP_CHIP_INIT (CHIP_IS_OMAP2420 ), };
@@ -799,6 +869,9 @@ static __initdata struct omap_hwmod *omap2420_hwmods[] = { &omap2420_gpio2_hwmod, &omap2420_gpio3_hwmod, &omap2420_gpio4_hwmod, + +/* mailbox class */ + &omap2420_mailbox_hwmod, NULL, };
arch/arm/mach-omap2/omap_hwmod_2430_data.c +72 -0
84 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 2/5 OMAP3: hwmod data: add mailbox data
In reply to Omar Ramirez LunaFrom: Felipe Contreras <[email protected]>
Mailbox hwmod data for omap3.
--- arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 71 ++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +71 -0
@@ -1089,6 +1089,74 @@ static struct omap_hwmod omap3xxx_gpio6_hwmod = { .slaves_cnt = ARRAY_SIZE(omap3xxx_gpio6_slaves), .class = &omap3xxx_gpio_hwmod_class, .dev_attr = &gpio_dev_attr, + .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430), +}; + +/* +* 'mailbox' class +* mailbox module allowing communication between the on-chip processors +* using a queued mailbox-interrupt mechanism. +*/ + +static struct omap_hwmod_class_sysconfig omap3xxx_mailbox_sysc = { + .rev_offs =0x000 , + .sysc_offs =0x010 , + .syss_offs =0x014 , + .sysc_flags = (SYSC_HAS_CLOCKACTIVITY |SYSC_HAS_SIDLEMODE | +SYSC_HAS_SOFTRESET |SYSC_HAS_AUTOIDLE ), + .idlemodes = (SIDLE_FORCE |SIDLE_NO |SIDLE_SMART ), + .sysc_fields = &omap_hwmod_sysc_type1, +}; + +static struct omap_hwmod_class omap3xxx_mailbox_hwmod_class = { + .name ="mailbox" , + .sysc = &omap3xxx_mailbox_sysc, +}; + +static struct omap_hwmod omap3xxx_mailbox_hwmod; +static struct omap_hwmod_irq_info omap3xxx_mailbox_irqs[] = { + { .name ="dsp" , .irq =26 , }, +}; + +static struct omap_hwmod_addr_space omap3xxx_mailbox_addrs[] = { + { + .pa_start =0x48094000 , + .pa_end =0x480941ff , + .flags =ADDR_TYPE_RT , + }, +}; + +/* l4_core -> mailbox */ +static struct omap_hwmod_ocp_if omap3xxx_l4_core__mailbox = { + .master = &omap3xxx_l4_core_hwmod, + .slave = &omap3xxx_mailbox_hwmod, + .clk ="mailboxes_ick" , + .addr = omap3xxx_mailbox_addrs, + .addr_cnt =ARRAY_SIZE (omap3xxx_mailbox_addrs), + .user =OCP_USER_MPU |OCP_USER_SDMA , +}; + +/* mailbox slave ports */ +static struct omap_hwmod_ocp_if *omap3xxx_mailbox_slaves[] = { + &omap3xxx_l4_core__mailbox, +}; + +static struct omap_hwmod omap3xxx_mailbox_hwmod = { + .name ="mailbox" , + .class = &omap3xxx_mailbox_hwmod_class, + .mpu_irqs = omap3xxx_mailbox_irqs, + .mpu_irqs_cnt =ARRAY_SIZE (omap3xxx_mailbox_irqs), + .prcm = { + .omap2 = { + .prcm_reg_id =1 , + .module_bit =OMAP3430_EN_MAILBOXES_SHIFT , + .module_offs =CORE_MOD , + .idlest_reg_id =1 , + .idlest_idle_bit =OMAP3430_ST_MAILBOXES_SHIFT , + }, + }, + .slaves = omap3xxx_mailbox_slaves, + .slaves_cnt =ARRAY_SIZE (omap3xxx_mailbox_slaves), .omap_chip =OMAP_CHIP_INIT (CHIP_IS_OMAP3430 ), };
@@ -1115,6 +1183,9 @@ static __initdata struct omap_hwmod *omap3xxx_hwmods[] = { &omap3xxx_gpio4_hwmod, &omap3xxx_gpio5_hwmod, &omap3xxx_gpio6_hwmod, + +/* mailbox class */ + &omap3xxx_mailbox_hwmod, NULL, };
Signature · 1 line
1.7.1
PATCH v3 3/5 OMAP4: hwmod data: add mailbox data
In reply to Omar Ramirez LunaFrom: Benoit Cousson <[email protected]>
Mailbox hwmod data for omap4.
--- arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 68 ++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +68 -0
@@ -1380,6 +1380,71 @@ static struct omap_hwmod omap44xx_gpio6_hwmod = { .slaves_cnt = ARRAY_SIZE(omap44xx_gpio6_slaves), .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430), }; + +/* +* 'mailbox' class +* mailbox module allowing communication between the on-chip processors +* using a queued mailbox-interrupt mechanism. +*/ + +static struct omap_hwmod_class_sysconfig omap44xx_mailbox_sysc = { + .rev_offs =0x0000 , + .sysc_offs =0x0010 , + .sysc_flags = (SYSC_HAS_RESET_STATUS |SYSC_HAS_SIDLEMODE | +SYSC_HAS_SOFTRESET ), + .idlemodes = (SIDLE_FORCE |SIDLE_NO |SIDLE_SMART ), + .sysc_fields = &omap_hwmod_sysc_type2, +}; + +static struct omap_hwmod_class omap44xx_mailbox_hwmod_class = { + .name ="mailbox" , + .sysc = &omap44xx_mailbox_sysc, +}; + +/* mailbox */ +static struct omap_hwmod omap44xx_mailbox_hwmod; +static struct omap_hwmod_irq_info omap44xx_mailbox_irqs[] = { + { .name ="mbox" , .irq =26 +OMAP44XX_IRQ_GIC_START , }, +}; + +static struct omap_hwmod_addr_space omap44xx_mailbox_addrs[] = { + { + .pa_start =0x4a0f4000 , + .pa_end =0x4a0f41ff , + .flags =ADDR_TYPE_RT , + }, +}; + +/* l4_cfg -> mailbox */ +static struct omap_hwmod_ocp_if omap44xx_l4_cfg__mailbox = { + .master = &omap44xx_l4_cfg_hwmod, + .slave = &omap44xx_mailbox_hwmod, + .clk ="l4_div_ck" , + .addr = omap44xx_mailbox_addrs, + .addr_cnt =ARRAY_SIZE (omap44xx_mailbox_addrs), + .user =OCP_USER_MPU |OCP_USER_SDMA , +}; + +/* mailbox slave ports */ +static struct omap_hwmod_ocp_if *omap44xx_mailbox_slaves[] = { + &omap44xx_l4_cfg__mailbox, +}; + +static struct omap_hwmod omap44xx_mailbox_hwmod = { + .name ="mailbox" , + .class = &omap44xx_mailbox_hwmod_class, + .mpu_irqs = omap44xx_mailbox_irqs, + .mpu_irqs_cnt =ARRAY_SIZE (omap44xx_mailbox_irqs), + .prcm = { + .omap4 = { + .clkctrl_reg =OMAP4430_CM_L4CFG_MAILBOX_CLKCTRL , + }, + }, + .slaves = omap44xx_mailbox_slaves, + .slaves_cnt =ARRAY_SIZE (omap44xx_mailbox_slaves), + .omap_chip =OMAP_CHIP_INIT (CHIP_IS_OMAP4430 ), +}; +static __initdata struct omap_hwmod *omap44xx_hwmods[] = {/* dmm class */ &omap44xx_dmm_hwmod,
@@ -1422,6 +1487,9 @@ static __initdata struct omap_hwmod *omap44xx_hwmods[] = { &omap44xx_uart2_hwmod, &omap44xx_uart3_hwmod, &omap44xx_uart4_hwmod, + +/* mailbox class */ + &omap44xx_mailbox_hwmod, NULL, };
Signature · 1 line
1.7.1
PATCH v3 4/5 OMAP: mailbox: build device using omap_device/omap_hwmod
In reply to Omar Ramirez LunaFrom: Felipe Contreras <[email protected]>
Remove static platform_device and resource data within omap mailbox driver; use the one defined in the hwmod database along with omap_device framework for device build and registration.
--- arch/arm/mach-omap2/devices.c | 100 ++++++---------------------------------- 1 files changed, 15 insertions(+), 85 deletions(-)
arch/arm/mach-omap2/devices.c +15 -85
@@ -142,95 +142,25 @@ static inline void omap_init_camera(void)#endif #if defined(CONFIG_OMAP_MBOX_FWK ) || defined(CONFIG_OMAP_MBOX_FWK_MODULE ) - -#define MBOX_REG_SIZE 0x120 - -#ifdef CONFIG_ARCH_OMAP2 -static struct resource omap2_mbox_resources[] = { - { - .start =OMAP24XX_MAILBOX_BASE , - .end =OMAP24XX_MAILBOX_BASE +MBOX_REG_SIZE -1 , - .flags =IORESOURCE_MEM , - }, - { - .start =INT_24XX_MAIL_U0_MPU , - .flags =IORESOURCE_IRQ , - .name ="dsp" , - }, - { - .start =INT_24XX_MAIL_U3_MPU , - .flags =IORESOURCE_IRQ , - .name ="iva" , - }, -}; -static int omap2_mbox_resources_sz =ARRAY_SIZE (omap2_mbox_resources); -#else -#define omap2_mbox_resources NULL -#define omap2_mbox_resources_sz 0 -#endif - -#ifdef CONFIG_ARCH_OMAP3 -static struct resource omap3_mbox_resources[] = { - { - .start =OMAP34XX_MAILBOX_BASE , - .end =OMAP34XX_MAILBOX_BASE +MBOX_REG_SIZE -1 , - .flags =IORESOURCE_MEM , - }, - { - .start =INT_24XX_MAIL_U0_MPU , - .flags =IORESOURCE_IRQ , - .name ="dsp" , - }, -}; -static int omap3_mbox_resources_sz =ARRAY_SIZE (omap3_mbox_resources); -#else -#define omap3_mbox_resources NULL -#define omap3_mbox_resources_sz 0 -#endif - -#ifdef CONFIG_ARCH_OMAP4 - -#define OMAP4_MBOX_REG_SIZE 0x130 -static struct resource omap4_mbox_resources[] = { - { - .start =OMAP44XX_MAILBOX_BASE , - .end =OMAP44XX_MAILBOX_BASE + -OMAP4_MBOX_REG_SIZE -1 , - .flags =IORESOURCE_MEM , - }, - { - .start =OMAP44XX_IRQ_MAIL_U0 , - .flags =IORESOURCE_IRQ , - .name ="mbox" , - }, -}; -static int omap4_mbox_resources_sz =ARRAY_SIZE (omap4_mbox_resources); -#else -#define omap4_mbox_resources NULL -#define omap4_mbox_resources_sz 0 -#endif - -static struct platform_device mbox_device = { - .name ="omap-mailbox" , - .id =-1 , -}; -static inline void omap_init_mbox (void ) { -if (cpu_is_omap24xx ()) { - mbox_device.resource = omap2_mbox_resources; - mbox_device.num_resources = omap2_mbox_resources_sz; - }else if (cpu_is_omap34xx ()) { - mbox_device.resource = omap3_mbox_resources; - mbox_device.num_resources = omap3_mbox_resources_sz; - }else if (cpu_is_omap44xx ()) { - mbox_device.resource = omap4_mbox_resources; - mbox_device.num_resources = omap4_mbox_resources_sz; - }else { -pr_err ("%s: platform not supported\n" , __func__); +struct omap_hwmod *oh; +struct omap_device *od; + + oh =omap_hwmod_lookup ("mailbox" ); +if (!oh) { +pr_err ("%s: unable to find hwmod\n" , __func__); +return ; + } + + od =omap_device_build ("omap-mailbox" ,-1 , oh, +NULL ,0 , +NULL ,0 , +0 ); +if (!od) { +pr_err ("%s: could not build device\n" , __func__);return ; } -platform_device_register (&mbox_device); }#else static inline void omap_init_mbox (void ) { }
Signature · 1 line
1.7.1
PATCH v3 5/5 OMAP: mailbox: add omap_device latency information
In reply to Omar Ramirez LunaFrom: Felipe Contreras <[email protected]>
So that we can enable the main clock.
--- arch/arm/mach-omap2/devices.c | 10 +++++++++- arch/arm/mach-omap2/mailbox.c | 18 ++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-)
arch/arm/mach-omap2/devices.c +9 -1
@@ -142,6 +142,14 @@ static inline void omap_init_camera(void)#endif #if defined(CONFIG_OMAP_MBOX_FWK ) || defined(CONFIG_OMAP_MBOX_FWK_MODULE ) +static struct omap_device_pm_latency mbox_latencies[] = { + [0 ] = { + .activate_func = omap_device_enable_clocks, + .deactivate_func = omap_device_enable_clocks, + .flags =OMAP_DEVICE_LATENCY_AUTO_ADJUST , + }, +}; +static inline void omap_init_mbox (void ) {struct omap_hwmod *oh;
@@ -155,7 +163,7 @@ static inline void omap_init_mbox(void) od =omap_device_build ("omap-mailbox" ,-1 , oh,NULL ,0 , -NULL ,0 , + mbox_latencies,ARRAY_SIZE (mbox_latencies),0 );if (!od) {pr_err ("%s: could not build device\n" , __func__);
arch/arm/mach-omap2/mailbox.c +6 -12
@@ -14,6 +14,7 @@#include <linux/err.h> #include <linux/platform_device.h> #include <linux/io.h> +#include <linux/pm_runtime.h> #include <plat/mailbox.h> #include <mach/irqs.h>
@@ -52,6 +53,7 @@#define OMAP4_MBOX_NR_REGS (OMAP4_MBOX_REG_SIZE / sizeof(u32))static void __iomem *mbox_base; +static struct platform_device *mbox_pdev;struct omap_mbox2_fifo {unsigned long msg;
@@ -70,8 +72,6 @@ struct omap_mbox2_priv {unsigned long irqdisable; }; -static struct clk *mbox_ick_handle; -static void omap2_mbox_enable_irq (struct omap_mbox *mbox,omap_mbox_type_t irq);
@@ -91,13 +91,7 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)u32 l;unsigned long timeout; - mbox_ick_handle =clk_get (NULL ,"mailboxes_ick" ); -if (IS_ERR (mbox_ick_handle)) { -printk (KERN_ERR "Could not get mailboxes_ick: %ld\n" , -PTR_ERR (mbox_ick_handle)); -return PTR_ERR (mbox_ick_handle); - } -clk_enable (mbox_ick_handle); +pm_runtime_get_sync (&mbox_pdev->dev);if (cpu_is_omap44xx ()) {mbox_write_reg (OMAP4_SOFTRESET ,MAILBOX_SYSCONFIG );
@@ -143,9 +137,7 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)static void omap2_mbox_shutdown (struct omap_mbox *mbox) { -clk_disable (mbox_ick_handle); -clk_put (mbox_ick_handle); - mbox_ick_handle =NULL ; +pm_runtime_put_sync (&mbox_pdev->dev); }/* Mailbox FIFO handle functions */
@@ -427,6 +419,8 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)if (!mbox_base)return -ENOMEM ; + mbox_pdev = pdev; + ret =omap_mbox_register (&pdev->dev, list);if (ret) {iounmap (mbox_base);
Signature · 1 line
1.7.1
PATCH v3 5/5 OMAP: mailbox: add omap_device latency information
Quoted 3 lines · Omar Ramirez Luna
From: Felipe Contreras <[email protected]>
So that we can enable the main clock.
This should be:
Subject: OMAP: mailbox: use runtime pm for clk and sysc handling
Use runtime pm APIs to enable/disable mailbox clocks and to configure SYSCONFIG registers.
And if someone agrees, device_latency can be merged with the previous patch for device_build. I'll wait for comments and resubmit.
Regards,
Omar
PATCH v3 5/5 OMAP: mailbox: add omap_device latency information
Quoted 7 lines · Omar
Quoted 3 lines · Omar Ramirez Luna
From: Felipe Contreras<[email protected]>
So that we can enable the main clock.
This should be:
Quoted 7 lines
Subject: OMAP: mailbox: use runtime pm for clk and sysc handling
Use runtime pm APIs to enable/disable mailbox clocks and to configure SYSCONFIG registers.
And if someone agrees,
device_latencycan be merged with the previous patch fordevice_build. I'll wait for comments and resubmit.
Yes, you're right, the device latency has nothing to do in that patch. It should be in the previous patch: [PATCH v3 4/5] OMAP: mailbox: build device using omap_device/omap_hwmod.
regards,
Benoit
PATCH v3 5/5 OMAP: mailbox: add omap_device latency information
In reply to Omar Ramirez LunaQuoted 8 lines
- ? ? ?
mbox_ick_handle=clk_get(NULL, "mailboxes_ick");
- ? ? ? if (IS_ERR(mbox_ick_handle)) {
- ? ? ? ? ? ? ? printk(KERN_ERR "Could not getmailboxes_ick: %ld\n",
- ? ? ? ? ? ? ? ? ? ? ?PTR_ERR(mbox_ick_handle));
- ? ? ? ? ? ? ? returnPTR_ERR(mbox_ick_handle);
- ? ? ? }
- ? ? ?clk_enable(mbox_ick_handle);
+ ? ? ?pm_runtime_get_sync(&mbox_pdev->dev);
Might be good to check the return value.
Thank you,
Best regards,
Hari Kanigeri