|
@@ -945,3 +945,193 @@ static void _omap4_enable_module(struct omap_hwmod *oh)
|
|
|
oh->name, __func__, oh->prcm.omap4.modulemode);
|
|
|
|
|
|
omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
|
|
|
+ oh->clkdm->prcm_partition,
|
|
|
+ oh->clkdm->cm_inst,
|
|
|
+ oh->clkdm->clkdm_offs,
|
|
|
+ oh->prcm.omap4.clkctrl_offs);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * _am33xx_enable_module - enable CLKCTRL modulemode on AM33XX
|
|
|
+ * @oh: struct omap_hwmod *
|
|
|
+ *
|
|
|
+ * Enables the PRCM module mode related to the hwmod @oh.
|
|
|
+ * No return value.
|
|
|
+ */
|
|
|
+static void _am33xx_enable_module(struct omap_hwmod *oh)
|
|
|
+{
|
|
|
+ if (!oh->clkdm || !oh->prcm.omap4.modulemode)
|
|
|
+ return;
|
|
|
+
|
|
|
+ pr_debug("omap_hwmod: %s: %s: %d\n",
|
|
|
+ oh->name, __func__, oh->prcm.omap4.modulemode);
|
|
|
+
|
|
|
+ am33xx_cm_module_enable(oh->prcm.omap4.modulemode, oh->clkdm->cm_inst,
|
|
|
+ oh->clkdm->clkdm_offs,
|
|
|
+ oh->prcm.omap4.clkctrl_offs);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * _omap4_wait_target_disable - wait for a module to be disabled on OMAP4
|
|
|
+ * @oh: struct omap_hwmod *
|
|
|
+ *
|
|
|
+ * Wait for a module @oh to enter slave idle. Returns 0 if the module
|
|
|
+ * does not have an IDLEST bit or if the module successfully enters
|
|
|
+ * slave idle; otherwise, pass along the return value of the
|
|
|
+ * appropriate *_cm*_wait_module_idle() function.
|
|
|
+ */
|
|
|
+static int _omap4_wait_target_disable(struct omap_hwmod *oh)
|
|
|
+{
|
|
|
+ if (!oh)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ if (oh->_int_flags & _HWMOD_NO_MPU_PORT || !oh->clkdm)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ if (oh->flags & HWMOD_NO_IDLEST)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ return omap4_cminst_wait_module_idle(oh->clkdm->prcm_partition,
|
|
|
+ oh->clkdm->cm_inst,
|
|
|
+ oh->clkdm->clkdm_offs,
|
|
|
+ oh->prcm.omap4.clkctrl_offs);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * _am33xx_wait_target_disable - wait for a module to be disabled on AM33XX
|
|
|
+ * @oh: struct omap_hwmod *
|
|
|
+ *
|
|
|
+ * Wait for a module @oh to enter slave idle. Returns 0 if the module
|
|
|
+ * does not have an IDLEST bit or if the module successfully enters
|
|
|
+ * slave idle; otherwise, pass along the return value of the
|
|
|
+ * appropriate *_cm*_wait_module_idle() function.
|
|
|
+ */
|
|
|
+static int _am33xx_wait_target_disable(struct omap_hwmod *oh)
|
|
|
+{
|
|
|
+ if (!oh)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ if (oh->_int_flags & _HWMOD_NO_MPU_PORT)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ if (oh->flags & HWMOD_NO_IDLEST)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ return am33xx_cm_wait_module_idle(oh->clkdm->cm_inst,
|
|
|
+ oh->clkdm->clkdm_offs,
|
|
|
+ oh->prcm.omap4.clkctrl_offs);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * _count_mpu_irqs - count the number of MPU IRQ lines associated with @oh
|
|
|
+ * @oh: struct omap_hwmod *oh
|
|
|
+ *
|
|
|
+ * Count and return the number of MPU IRQs associated with the hwmod
|
|
|
+ * @oh. Used to allocate struct resource data. Returns 0 if @oh is
|
|
|
+ * NULL.
|
|
|
+ */
|
|
|
+static int _count_mpu_irqs(struct omap_hwmod *oh)
|
|
|
+{
|
|
|
+ struct omap_hwmod_irq_info *ohii;
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ if (!oh || !oh->mpu_irqs)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ do {
|
|
|
+ ohii = &oh->mpu_irqs[i++];
|
|
|
+ } while (ohii->irq != -1);
|
|
|
+
|
|
|
+ return i-1;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * _count_sdma_reqs - count the number of SDMA request lines associated with @oh
|
|
|
+ * @oh: struct omap_hwmod *oh
|
|
|
+ *
|
|
|
+ * Count and return the number of SDMA request lines associated with
|
|
|
+ * the hwmod @oh. Used to allocate struct resource data. Returns 0
|
|
|
+ * if @oh is NULL.
|
|
|
+ */
|
|
|
+static int _count_sdma_reqs(struct omap_hwmod *oh)
|
|
|
+{
|
|
|
+ struct omap_hwmod_dma_info *ohdi;
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ if (!oh || !oh->sdma_reqs)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ do {
|
|
|
+ ohdi = &oh->sdma_reqs[i++];
|
|
|
+ } while (ohdi->dma_req != -1);
|
|
|
+
|
|
|
+ return i-1;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * _count_ocp_if_addr_spaces - count the number of address space entries for @oh
|
|
|
+ * @oh: struct omap_hwmod *oh
|
|
|
+ *
|
|
|
+ * Count and return the number of address space ranges associated with
|
|
|
+ * the hwmod @oh. Used to allocate struct resource data. Returns 0
|
|
|
+ * if @oh is NULL.
|
|
|
+ */
|
|
|
+static int _count_ocp_if_addr_spaces(struct omap_hwmod_ocp_if *os)
|
|
|
+{
|
|
|
+ struct omap_hwmod_addr_space *mem;
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ if (!os || !os->addr)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ do {
|
|
|
+ mem = &os->addr[i++];
|
|
|
+ } while (mem->pa_start != mem->pa_end);
|
|
|
+
|
|
|
+ return i-1;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * _get_mpu_irq_by_name - fetch MPU interrupt line number by name
|
|
|
+ * @oh: struct omap_hwmod * to operate on
|
|
|
+ * @name: pointer to the name of the MPU interrupt number to fetch (optional)
|
|
|
+ * @irq: pointer to an unsigned int to store the MPU IRQ number to
|
|
|
+ *
|
|
|
+ * Retrieve a MPU hardware IRQ line number named by @name associated
|
|
|
+ * with the IP block pointed to by @oh. The IRQ number will be filled
|
|
|
+ * into the address pointed to by @dma. When @name is non-null, the
|
|
|
+ * IRQ line number associated with the named entry will be returned.
|
|
|
+ * If @name is null, the first matching entry will be returned. Data
|
|
|
+ * order is not meaningful in hwmod data, so callers are strongly
|
|
|
+ * encouraged to use a non-null @name whenever possible to avoid
|
|
|
+ * unpredictable effects if hwmod data is later added that causes data
|
|
|
+ * ordering to change. Returns 0 upon success or a negative error
|
|
|
+ * code upon error.
|
|
|
+ */
|
|
|
+static int _get_mpu_irq_by_name(struct omap_hwmod *oh, const char *name,
|
|
|
+ unsigned int *irq)
|
|
|
+{
|
|
|
+ int i;
|
|
|
+ bool found = false;
|
|
|
+
|
|
|
+ if (!oh->mpu_irqs)
|
|
|
+ return -ENOENT;
|
|
|
+
|
|
|
+ i = 0;
|
|
|
+ while (oh->mpu_irqs[i].irq != -1) {
|
|
|
+ if (name == oh->mpu_irqs[i].name ||
|
|
|
+ !strcmp(name, oh->mpu_irqs[i].name)) {
|
|
|
+ found = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!found)
|
|
|
+ return -ENOENT;
|
|
|
+
|
|
|
+ *irq = oh->mpu_irqs[i].irq;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|