omap: mailbox: hwmod support
Subsystems (4)
v6 cover omap: mailbox: hwmod support
Mailbox hwmod support for OMAP 2,3,4.
This was tested on OMAP3 (3430, 3630) by using
tidspbridge and OMAP4 (blaze). Also using Kevin's
mailbox test: http://bit.ly/fdk8Au
No testing on OMAP2 since I don't have the hardware.
Changes on v6 include:
- Dropping OMAP4 hwmod patch, as Benoit already sent it.
- Removing irq names in hwmod data for single irq, changed mailbox to use platform_request_irq in these cases.
- Moved ick to be the main_clk so it can be disabled on pm_runtime_put_sync.
Highlights from v5 include the comments received from previous version v4 (http://bit.ly/gfLaIs)
Felipe Contreras (2):
OMAP3: hwmod data: add mailbox data
OMAP: mailbox: build device using omap_device/omap_hwmod
Omar Ramirez Luna (2):
OMAP2: hwmod data: add mailbox data
OMAP: mailbox: use runtime pm for clk and sysc handling
arch/arm/mach-omap2/devices.c | 98 +++++----------------------- arch/arm/mach-omap2/mailbox.c | 72 ++------------------ 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 ++++++++++++++++++++ 5 files changed, 240 insertions(+), 146 deletions(-)
PATCH v6 1/4 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
@@ -904,6 +904,76 @@ static struct omap_hwmod omap2420_dma_system_hwmod = { };/* +* '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, + .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), + .main_clk ="mailboxes_ick" , + .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 ), +}; + +/* * 'mcspi' class * multichannel serial port interface (mcspi) / master/slave synchronous serial * bus
@@ -1038,6 +1108,9 @@ static __initdata struct omap_hwmod *omap2420_hwmods[] = {/* dma_system class*/ &omap2420_dma_system_hwmod, +/* mailbox class */ + &omap2420_mailbox_hwmod, +/* mcspi class */ &omap2420_mcspi1_hwmod, &omap2420_mcspi2_hwmod,
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 v6 2/4 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
@@ -1361,6 +1361,74 @@ static struct omap_hwmod omap36xx_sr2_hwmod = { .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3630ES1), }; +/* +* '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[] = { + { .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, + .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), + .main_clk ="mailboxes_ick" , + .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 ), +}; +/* l4 core -> mcspi1 interface */ static struct omap_hwmod_addr_space omap34xx_mcspi1_addr_space[] = { {
@@ -1662,6 +1730,9 @@ static __initdata struct omap_hwmod *omap3xxx_hwmods[] = {/* dma_system class*/ &omap3xxx_dma_system_hwmod, +/* mailbox class */ + &omap3xxx_mailbox_hwmod, +/* mcspi class */ &omap34xx_mcspi1, &omap34xx_mcspi2,
Signature · 1 line
1.7.1
PATCH v6 3/4 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.
Add device latency functions to be used, so clock can be enabled and sysconfig is configured.
--- arch/arm/mach-omap2/devices.c | 98 +++++++---------------------------------- arch/arm/mach-omap2/mailbox.c | 7 +-- 2 files changed, 19 insertions(+), 86 deletions(-)
arch/arm/mach-omap2/devices.c +16 -82
@@ -143,95 +143,29 @@ 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 struct omap_device_pm_latency mbox_latencies[] = { + [0 ] = { + .activate_func = omap_device_enable_hwmods, + .deactivate_func = omap_device_idle_hwmods, + .flags =OMAP_DEVICE_LATENCY_AUTO_ADJUST , }, }; -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 ; } -platform_device_register (&mbox_device); + + od =omap_device_build ("omap-mailbox" ,-1 , oh,NULL ,0 , + mbox_latencies,ARRAY_SIZE (mbox_latencies),0 ); +WARN (IS_ERR (od),"%s: could not build device, err %ld\n" , + __func__,PTR_ERR (od)); }#else static inline void omap_init_mbox (void ) { }
arch/arm/mach-omap2/mailbox.c +3 -4
@@ -398,14 +398,14 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev) else if (cpu_is_omap34xx()) { list = omap3_mboxes; - list[0 ]->irq =platform_get_irq_byname (pdev,"dsp" ); + list[0 ]->irq =platform_get_irq (pdev,0 ); }#endif #if defined(CONFIG_ARCH_OMAP2 ) else if (cpu_is_omap2430()) { list = omap2_mboxes; - list[0 ]->irq =platform_get_irq_byname (pdev,"dsp" ); + list[0 ]->irq =platform_get_irq (pdev,0 ); } else if (cpu_is_omap2420()) { list = omap2_mboxes;
@@ -417,8 +417,7 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev) else if (cpu_is_omap44xx()) { list = omap4_mboxes; - list[0 ]->irq = list[1 ]->irq = -platform_get_irq_byname (pdev,"mbox" ); + list[0 ]->irq = list[1 ]->irq =platform_get_irq (pdev,0 ); }#endif else {
Signature · 1 line
1.7.1
PATCH v6 4/4 OMAP: mailbox: use runtime pm for clk and sysc handling
In reply to Omar Ramirez LunaUse runtime pm APIs to enable/disable mailbox clocks and to configure SYSC register.
Based on the patch sent by Felipe Contreras:
https://patchwork.kernel.org/patch/101662/
--- arch/arm/mach-omap2/mailbox.c | 67 ++++------------------------------------- 1 files changed, 6 insertions(+), 61 deletions(-)
arch/arm/mach-omap2/mailbox.c +5 -60
@@ -14,12 +14,11 @@#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> #define MAILBOX_REVISION 0x000 -#define MAILBOX_SYSCONFIG 0x010 -#define MAILBOX_SYSSTATUS 0x014#define MAILBOX_MESSAGE (m) (0x040 + 4 * (m))#define MAILBOX_FIFOSTATUS (m) (0x080 + 4 * (m))#define MAILBOX_MSGSTATUS (m) (0x0c0 + 4 * (m))
@@ -33,17 +32,6 @@#define MAILBOX_IRQ_NEWMSG (m) (1 << (2 * (m)))#define MAILBOX_IRQ_NOTFULL (m) (1 << (2 * (m) + 1)) -/* SYSCONFIG: register bit definition */ -#define AUTOIDLE (1 << 0) -#define SOFTRESET (1 << 1) -#define SMARTIDLE (2 << 3) -#define OMAP4_SOFTRESET (1 << 0) -#define OMAP4_NOIDLE (1 << 2) -#define OMAP4_SMARTIDLE (2 << 2) - -/* SYSSTATUS: register bit definition */ -#define RESETDONE (1 << 0) -#define MBOX_REG_SIZE 0x120#define OMAP4_MBOX_REG_SIZE 0x130
@@ -70,8 +58,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);
@@ -89,53 +75,13 @@ static inline void mbox_write_reg(u32 val, size_t ofs)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); - -if (cpu_is_omap44xx ()) { -mbox_write_reg (OMAP4_SOFTRESET ,MAILBOX_SYSCONFIG ); - timeout = jiffies +msecs_to_jiffies (20 ); -do { - l =mbox_read_reg (MAILBOX_SYSCONFIG ); -if (!(l &OMAP4_SOFTRESET )) -break ; - }while (!time_after (jiffies, timeout)); - -if (l &OMAP4_SOFTRESET ) { -pr_err ("Can't take mailbox out of reset\n" ); -return -ENODEV ; - } - }else { -mbox_write_reg (SOFTRESET ,MAILBOX_SYSCONFIG ); - timeout = jiffies +msecs_to_jiffies (20 ); -do { - l =mbox_read_reg (MAILBOX_SYSSTATUS ); -if (l &RESETDONE ) -break ; - }while (!time_after (jiffies, timeout)); - -if (!(l &RESETDONE )) { -pr_err ("Can't take mailbox out of reset\n" ); -return -ENODEV ; - } - } +pm_runtime_enable (mbox->dev->parent); +pm_runtime_get_sync (mbox->dev->parent); l =mbox_read_reg (MAILBOX_REVISION );pr_debug ("omap mailbox rev %d.%d\n" , (l &0xf0 ) >>4 , (l &0x0f )); -if (cpu_is_omap44xx ()) - l =OMAP4_SMARTIDLE ; -else - l =SMARTIDLE |AUTOIDLE ; -mbox_write_reg (l,MAILBOX_SYSCONFIG ); -omap2_mbox_enable_irq (mbox,IRQ_RX );return 0 ;
@@ -143,9 +89,8 @@ 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->dev->parent); +pm_runtime_disable (mbox->dev->parent); }/* Mailbox FIFO handle functions */
Signature · 1 line
1.7.1
Tony Lindgren
maintainerv6 cover omap: mailbox: hwmod support
In reply to Omar Ramirez LunaQuoted 1 line · Omar Ramirez Luna
Mailbox hwmod support for OMAP 2,3,4.
Thanks, applying to devel-iommu-mailbox branch for the upcoming merge window.
Regards,
Tony