Skip to contentSkip to conversation

New API to modify the autoidle bits of sysconfig register

RFC PATCH In review Kishon Vijay Abraham I 5 participants 7 messages Aug 26, 2010 – Sep 3, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 New API to modify the autoidle bits of sysconfig register

Though the sysconfig register values shouldn't be modified directly by the driver, MCBSP should be considered a special case where sysconfig registers need to be modified dynamically by the driver.

For e.g MCBSP 2 and 3 in OMAP3 has sidetone feature which requires autoidle to be disabled before starting the sidetone.

This patch creates a new API that forms a wrapper to _set_module_autoidle() to modify the AUTOIDLE bit.

Cc Paul Walmsley<[email protected]>
Cc Benoit Cousson<[email protected]>
Cc Partha Basak <[email protected]>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   29 ++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    1 +
 2 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +29 -0
index 9bd99ad..0d38404 100644
@@ -969,6 +969,35 @@ int _omap_hwmod_idle(struct omap_hwmod *oh)
 }
 
 /**
+ * omap_hwmod_set_module_autoidle - set the hwmod's OCP slave autoidle
+ * @oh: struct omap_hwmod *
+ * @autoidle: desired AUTOIDLE bitfield value (0 or 1)
+ *
+ * Sets the IP block's OCP slave autoidle in hardware, and updates our
+ * local copy. Intended to be used by drivers that have some erratum
+ * that requires direct manipulation of the AUTOIDLE bits.  Returns
+ * -EINVAL if @oh is null, or passes along the return value from
+ * _set_module_autoidle().
+ */
+int omap_hwmod_set_module_autoidle(struct omap_hwmod *oh, u8 autoidle)
+{
+	u32 v;
+	int retval = 0;
+
+	if (!oh)
+		return -EINVAL;
+
+	v = oh->_sysc_cache;
+
+	retval = _set_module_autoidle(oh, autoidle, &v);
+
+	if (!retval)
+		_write_sysconfig(v, oh);
+
+	return retval;
+}
+
+/**
  * _shutdown - shutdown an omap_hwmod
  * @oh: struct omap_hwmod *
  *
arch/arm/plat-omap/include/plat/omap_hwmod.h +1 -0
index 6adbb63..7042b86 100644
@@ -526,6 +526,7 @@ int omap_hwmod_hardreset_deassert(struct omap_hwmod *oh, const char *name);
 int omap_hwmod_hardreset_state(struct omap_hwmod *oh, const char *name);
 
 int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode);
+int omap_hwmod_set_module_autoidle(struct omap_hwmod *oh, u8 autoidle)
 
 int omap_hwmod_reset(struct omap_hwmod *oh);
 void omap_hwmod_ocp_barrier(struct omap_hwmod *oh);
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 9 lines · Kishon Vijay Abraham I

Though the sysconfig register values shouldn't be modified directly by the driver, MCBSP should be considered a special case where sysconfig registers need to be modified dynamically by the driver.

For e.g MCBSP 2 and 3 in OMAP3 has sidetone feature which requires autoidle to be disabled before starting the sidetone.

This patch creates a new API that forms a wrapper to _set_module_autoidle() to modify the AUTOIDLE bit.

Since driver should not be using hwmod directly, how is this API going to be used? Will this only be called from arch/arm/mach-omap2/mcbsp.c?

Quoted 7 lines
Cc Paul Walmsley<[email protected]>
Cc Benoit Cousson<[email protected]>
Cc Partha Basak <[email protected]>

Subject should contain prefix like 'OMAP: hwmod: ...'

Kevin

Quoted 57 lines
---
 arch/arm/mach-omap2/omap_hwmod.c             |   29 ++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    1 +
 2 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +29 -0
index 9bd99ad..0d38404 100644
@@ -969,6 +969,35 @@ int _omap_hwmod_idle(struct omap_hwmod *oh)
 }
 
 /**
+ * omap_hwmod_set_module_autoidle - set the hwmod's OCP slave autoidle
+ * @oh: struct omap_hwmod *
+ * @autoidle: desired AUTOIDLE bitfield value (0 or 1)
+ *
+ * Sets the IP block's OCP slave autoidle in hardware, and updates our
+ * local copy. Intended to be used by drivers that have some erratum
+ * that requires direct manipulation of the AUTOIDLE bits.  Returns
+ * -EINVAL if @oh is null, or passes along the return value from
+ * _set_module_autoidle().
+ */
+int omap_hwmod_set_module_autoidle(struct omap_hwmod *oh, u8 autoidle)
+{
+	u32 v;
+	int retval = 0;
+
+	if (!oh)
+		return -EINVAL;
+
+	v = oh->_sysc_cache;
+
+	retval = _set_module_autoidle(oh, autoidle, &v);
+
+	if (!retval)
+		_write_sysconfig(v, oh);
+
+	return retval;
+}
+
+/**
  * _shutdown - shutdown an omap_hwmod
  * @oh: struct omap_hwmod *
  *
arch/arm/plat-omap/include/plat/omap_hwmod.h +1 -0
index 6adbb63..7042b86 100644
@@ -526,6 +526,7 @@ int omap_hwmod_hardreset_deassert(struct omap_hwmod *oh, const char *name);
 int omap_hwmod_hardreset_state(struct omap_hwmod *oh, const char *name);
 
 int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode);
+int omap_hwmod_set_module_autoidle(struct omap_hwmod *oh, u8 autoidle)
 
 int omap_hwmod_reset(struct omap_hwmod *oh);
 void omap_hwmod_ocp_barrier(struct omap_hwmod *oh);
#2 lore raw

Re: [RFC: PATCH] OMAP: hwmod: New API to modify the autoidle bits of sysconfig register

Quoted 7 lines · Kevin Hilman
Quoted 4 lines · Kishon Vijay Abraham I

Though the sysconfig register values shouldn't be modified directly by the driver, MCBSP should be considered a special case where sysconfig registers need to be modified dynamically by the driver.

Quoted 9 lines
Quoted 6 lines

For e.g MCBSP 2 and 3 in OMAP3 has sidetone feature which requires autoidle to be disabled before starting the sidetone.

This patch creates a new API that forms a wrapper to _set_module_autoidle() to modify the AUTOIDLE bit.

Since driver should not be using hwmod directly, how is this API going to be used? Will this only be called from arch/arm/mach-omap2/mcbsp.c?

Though driver shouldn't be using hwmod directly, there is no
corresponding API in omap_device to do the same. So we are planning to
store the omap_hwmod structure in platform_data during
arch_initcall (in the callback to omap_hwmod_for_each_by_class). So whenever the
AUTOIDLE bits need to be reset or set, we pass the stored
omap_hwmod structure to this API. Currently, the functions that needs AUTOIDLE
bit to be modified (omap_st_on, omap_st_off) resides in plat-omap.

-Kishon

Quoted 72 lines
Quoted 9 lines
Cc Paul Walmsley<[email protected]>
Cc Benoit Cousson<[email protected]>
Cc Partha Basak<[email protected]>

Subject should contain prefix like 'OMAP: hwmod: ...'

Kevin

Quoted 58 lines
---
  arch/arm/mach-omap2/omap_hwmod.c             |   29 ++++++++++++++++++++++++++
  arch/arm/plat-omap/include/plat/omap_hwmod.h |    1 +
  2 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +29 -0
index 9bd99ad..0d38404 100644
@@ -969,6 +969,35 @@ int _omap_hwmod_idle(struct omap_hwmod *oh)
  }
 
  /**
+ * omap_hwmod_set_module_autoidle - set the hwmod's OCP slave autoidle
+ * @oh: struct omap_hwmod *
+ * @autoidle: desired AUTOIDLE bitfield value (0 or 1)
+ *
+ * Sets the IP block's OCP slave autoidle in hardware, and updates our
+ * local copy. Intended to be used by drivers that have some erratum
+ * that requires direct manipulation of the AUTOIDLE bits.  Returns
+ * -EINVAL if @oh is null, or passes along the return value from
+ * _set_module_autoidle().
+ */
+int omap_hwmod_set_module_autoidle(struct omap_hwmod *oh, u8 autoidle)
+{
+	u32 v;
+	int retval = 0;
+
+	if (!oh)
+		return -EINVAL;
+
+	v = oh->_sysc_cache;
+
+	retval = _set_module_autoidle(oh, autoidle,&v);
+
+	if (!retval)
+		_write_sysconfig(v, oh);
+
+	return retval;
+}
+
+/**
   * _shutdown - shutdown an omap_hwmod
   * @oh: struct omap_hwmod *
   *
arch/arm/plat-omap/include/plat/omap_hwmod.h +1 -0
index 6adbb63..7042b86 100644
@@ -526,6 +526,7 @@ int omap_hwmod_hardreset_deassert(struct omap_hwmod *oh, const char *name);
  int omap_hwmod_hardreset_state(struct omap_hwmod *oh, const char *name);
 
  int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode);
+int omap_hwmod_set_module_autoidle(struct omap_hwmod *oh, u8 autoidle);
 
  int omap_hwmod_reset(struct omap_hwmod *oh);
  void omap_hwmod_ocp_barrier(struct omap_hwmod *oh);
#3 lore raw

Re: [RFC: PATCH] OMAP: hwmod: New API to modify the autoidle bits of sysconfig register

Quoted 9 lines · kishon

Though driver shouldn't be using hwmod directly, there is no
corresponding API in omap_device to do the same. So we are planning to
store the omap_hwmod structure in platform_data during
arch_initcall (in the callback to omap_hwmod_for_each_by_class). So whenever the
AUTOIDLE bits need to be reset or set, we pass the stored
omap_hwmod structure to this API. Currently, the functions that needs AUTOIDLE
bit to be modified (omap_st_on, omap_st_off) resides in plat-omap.

couldn't your API instead be something like:

int omap_hwmod_set_autoidle(struct device *dev, u8 autoidle)

{
	struct omap_hwmod *oh = dev_to_hwmod(dev);

	if (!oh)
		return -ENODEV;
	[...]

	return 0;
}
Signature · 1 line
balbi
#4 lore raw

Re: [RFC: PATCH] OMAP: hwmod: New API to modify the autoidle bits of sysconfig register

Quoted 15 lines · Felipe Balbi
Quoted 10 lines · kishon

Though driver shouldn't be using hwmod directly, there is no
corresponding API in omap_device to do the same. So we are planning to
store the omap_hwmod structure in platform_data during
arch_initcall (in the callback to omap_hwmod_for_each_by_class). So whenever the
AUTOIDLE bits need to be reset or set, we pass the stored
omap_hwmod structure to this API. Currently, the functions that needs AUTOIDLE
bit to be modified (omap_st_on, omap_st_off) resides in plat-omap.

couldn't your API instead be something like:

int omap_hwmod_set_autoidle(struct device *dev, u8 autoidle)

Quoted 10 lines
{
	struct omap_hwmod *oh = dev_to_hwmod(dev);

	if (!oh)
		return -ENODEV;
	[...]

	return 0;
}

Balbi,
I couldn't find "dev_to_hwmod()" function. Do you actually mean
implementing dev_to_hwmod() function?
I created this API based on "omap_hwmod_set_slave_idlemode()"
present in lo (omap_hwmod.c) for changing the smart idle bit
of SYSCONFIG register.

-Kishon

#5 lore raw

Re: [RFC: PATCH] OMAP: hwmod: New API to modify the autoidle bits of sysconfig register

Quoted 28 lines · KISHON VIJAY
Quoted 15 lines · Felipe Balbi
Quoted 10 lines · kishon

Though driver shouldn't be using hwmod directly, there is no
corresponding API in omap_device to do the same. So we are planning to
store the omap_hwmod structure in platform_data during
arch_initcall (in the callback to omap_hwmod_for_each_by_class). So whenever the
AUTOIDLE bits need to be reset or set, we pass the stored
omap_hwmod structure to this API. Currently, the functions that needs AUTOIDLE
bit to be modified (omap_st_on, omap_st_off) resides in plat-omap.

couldn't your API instead be something like:

int omap_hwmod_set_autoidle(struct device *dev, u8 autoidle)

Quoted 10 lines
{
	struct omap_hwmod *oh = dev_to_hwmod(dev);

	if (!oh)
		return -ENODEV;
	[...]

	return 0;
}
Quoted 8 lines

Balbi,
I couldn't find "dev_to_hwmod()" function. Do you actually mean
implementing dev_to_hwmod() function?
I created this API based on "omap_hwmod_set_slave_idlemode()"
present in lo (omap_hwmod.c) for changing the smart idle bit
of SYSCONFIG register.

-Kishon

That API does not exist. And since a device can contains several hwmods, like in your case, this API cannot exist in that form.

The real issue is that we do not want to expose any API relative to PRCM management to the driver. Even if you hide that behind some pdata, it is still the driver that will call it.

I know that some IPs like MUSB or McBSP requires some unusual idle mode change due to HW bugs, but in general, you should try to find a better way to handle that in the core framework if possible.

Regards,
Benoit

#6 lore raw

Re: [RFC: PATCH] OMAP: hwmod: New API to modify the autoidle bits of sysconfig register

Quoted 45 lines · Benoit
Quoted 31 lines · KISHON VIJAY
Quoted 17 lines · Felipe Balbi
Quoted 11 lines · kishon

Though driver shouldn't be using hwmod directly, there is no
corresponding API in omap_device to do the same. So we are planning to
store the omap_hwmod structure in platform_data during
arch_initcall (in the callback to omap_hwmod_for_each_by_class). So whenever the
AUTOIDLE bits need to be reset or set, we pass the stored
omap_hwmod structure to this API. Currently, the functions that needs AUTOIDLE
bit to be modified (omap_st_on, omap_st_off) resides in plat-omap.

couldn't your API instead be something like:

int omap_hwmod_set_autoidle(struct device *dev, u8 autoidle)

Quoted 11 lines
{
	struct omap_hwmod *oh = dev_to_hwmod(dev);

	if (!oh)
		return -ENODEV;
	[...]

	return 0;
}
Quoted 9 lines

Balbi,
I couldn't find "dev_to_hwmod()" function. Do you actually mean
implementing dev_to_hwmod() function?
I created this API based on "omap_hwmod_set_slave_idlemode()"
present in lo (omap_hwmod.c) for changing the smart idle bit
of SYSCONFIG register.

-Kishon

That API does not exist. And since a device can contains several hwmods, like in your case, this API cannot exist in that form.

Quoted 9 lines

The real issue is that we do not want to expose any API relative to PRCM management to the driver. Even if you hide that behind some pdata, it is still the driver that will call it.

I know that some IPs like MUSB or McBSP requires some unusual idle mode change due to HW bugs, but in general, you should try to find a better way to handle that in the core framework if possible.

Benoit,

I see the trend of using specific flags in hwmod which gets set in pm_runtime_get_sync() for scenarios like this where auto idle bits or smart idle bits need to be set/reset at runtime. The problem in the case of sidetone in MCBSP is that we don't call get_sync or put_sync for sidetone separately.
There is only two options we can think of for sidetone
1) Always disable autoidle for sidetone (I'm not sure if this will
have some power implications).
2) Use of the above API.

Would be helpful if you can also suggest us some other options as well.

-Kishon

Quoted 3 lines

Regards,
Benoit