devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
To: Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Cc: Ohad Ben-Cohen <ohad-Ix1uc/W3ht7QT0dZR+AlfA@public.gmane.org>,
	Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>,
	Benoit Cousson <bcousson-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>,
	Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCHv2 1/9] hwspinlock/core: add common dt bindings and OF helpers
Date: Fri, 27 Sep 2013 11:48:57 -0500	[thread overview]
Message-ID: <5245B6F9.7030505@ti.com> (raw)
In-Reply-To: <14DB8294-1148-446A-A6D3-34E66BA8732C-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>

Kumar,

On 09/27/2013 11:04 AM, Kumar Gala wrote:
> 
> On Sep 17, 2013, at 2:30 PM, Suman Anna wrote:
> 
>> All the platform-specific hwlock driver implementations need the
>> number of locks and the associated base id for registering the
>> locks present within a hwspinlock device with the driver core.
>> These two variables are represented by 'hwlock-num-locks' and
>> 'hwlock-base-id' properties. The documentation and OF helpers to
>> retrieve these common properties have been added to the driver core.
>>
>> Signed-off-by: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
>> ---
>> .../devicetree/bindings/hwlock/hwlock.txt          | 26 +++++++++
>> drivers/hwspinlock/hwspinlock_core.c               | 61 +++++++++++++++++++++-
>> include/linux/hwspinlock.h                         | 11 ++--
>> 3 files changed, 93 insertions(+), 5 deletions(-)
>> create mode 100644 Documentation/devicetree/bindings/hwlock/hwlock.txt
>>
>> diff --git a/Documentation/devicetree/bindings/hwlock/hwlock.txt b/Documentation/devicetree/bindings/hwlock/hwlock.txt
>> new file mode 100644
>> index 0000000..789930e
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/hwlock/hwlock.txt
>> @@ -0,0 +1,26 @@
>> +Generic hwlock bindings
>> +=======================
>> +
>> +Generic bindings that are common to all the hwlock platform specific driver
>> +implementations, the retrieved values are used for registering the device
>> +specific parameters with the hwspinlock core.
>> +
>> +The validity and need of these common properties may vary from one driver
>> +implementation to another. Look through the individual hwlock driver
>> +binding documentations for identifying which are mandatory and which are
>> +optional for that specific driver.
>> +
>> +Common properties:
>> +- hwlock-base-id:	Base Id for the locks for a particular hwlock device.
>> +			This property is used for representing a set of locks
>> +			present in a hwlock device with a unique base id in
>> +			the driver core. This property is mandatory ONLY if a
>> +			SoC has several hwlock devices.
>> +
>> +			See documentation on struct hwspinlock_pdata in
>> +			linux/hwspinlock.h for more details.
>> +
>> +- hwlock-num-locks:	Number of locks present in a hwlock device. This
>> +			property is needed on hwlock devices, where the number
>> +			of supported locks within a hwlock device cannot be
>> +			read from a register.
>> diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c
>> index 461a0d7..aec32e7 100644
>> --- a/drivers/hwspinlock/hwspinlock_core.c
>> +++ b/drivers/hwspinlock/hwspinlock_core.c
>> @@ -1,7 +1,7 @@
>> /*
>>  * Hardware spinlock framework
>>  *
>> - * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
>> + * Copyright (C) 2010-2013 Texas Instruments Incorporated - http://www.ti.com
>>  *
>>  * Contact: Ohad Ben-Cohen <ohad-Ix1uc/W3ht7QT0dZR+AlfA@public.gmane.org>
>>  *
>> @@ -27,6 +27,7 @@
>> #include <linux/hwspinlock.h>
>> #include <linux/pm_runtime.h>
>> #include <linux/mutex.h>
>> +#include <linux/of.h>
>>
>> #include "hwspinlock_internal.h"
>>
>> @@ -308,6 +309,64 @@ out:
>> }
>>
>> /**
>> + * of_hwspin_lock_get_base_id() - OF helper to retrieve base id
>> + * @dn: device node pointer
>> + *
>> + * This is an OF helper function that can be called by the underlying
>> + * platform-specific implementations, to retrieve the base id for the
>> + * set of locks present within a hwspinlock device instance.
>> + *
>> + * Returns the base id value on success, -ENODEV on generic failure or
>> + * an appropriate error code as returned by the OF layer
>> + */
>> +int of_hwspin_lock_get_base_id(struct device_node *dn)
>> +{
>> +	unsigned int val;
>> +	int ret = -ENODEV;
>> +
>> +#ifdef CONFIG_OF
>> +	if (!dn)
>> +		return -ENODEV;
> 
> Checking !dn is done in of_property_read_u32, so you don't need to duplicate

I have added this specifically since my intention is to differentiate
the validity of the node vs the presence of the property within a node.
This property may be optional for some platforms and a must for some
others, and differentiating would allow the individual driver
implementations to make the distinction.

> 
>> +
>> +	ret = of_property_read_u32(dn, "hwlock-base-id", &val);
>> +	if (!ret)
>> +		ret = val;
>> +#endif
>> +
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(of_hwspin_lock_get_base_id);
>> +
>> +/**
>> + * of_hwspin_lock_get_num_locks() - OF helper to retrieve number of locks
>> + * @dn: device node pointer
>> + *
>> + * This is an OF helper function that can be called by the underlying
>> + * platform-specific implementations, to retrieve the number of locks
>> + * present within a hwspinlock device instance.
>> + *
>> + * Returns a positive number of locks on success, -ENODEV on generic
>> + * failure or an appropriate error code as returned by the OF layer
>> + */
>> +int of_hwspin_lock_get_num_locks(struct device_node *dn)
>> +{
>> +	unsigned int val;
>> +	int ret = -ENODEV;
>> +
>> +#ifdef CONFIG_OF
>> +	if (!dn)
>> +		return -ENODEV;
> 
> Checking !dn is done in of_property_read_u32, so you don't need to duplicate

Same comment as above.

regards
Suman

> 
>> +
>> +	ret = of_property_read_u32(dn, "hwlock-num-locks", &val);
>> +	if (!ret)
>> +		ret = val ? val : -ENODEV;
>> +#endif
>> +
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(of_hwspin_lock_get_num_locks);
>> +
>> +/**
>>  * hwspin_lock_register() - register a new hw spinlock device
>>  * @bank: the hwspinlock device, which usually provides numerous hw locks
>>  * @dev: the backing device
>> diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h
>> index 3343298..1f6a5b8 100644
>> --- a/include/linux/hwspinlock.h
>> +++ b/include/linux/hwspinlock.h
>> @@ -1,7 +1,7 @@
>> /*
>>  * Hardware spinlock public header
>>  *
>> - * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
>> + * Copyright (C) 2010-2013 Texas Instruments Incorporated - http://www.ti.com
>>  *
>>  * Contact: Ohad Ben-Cohen <ohad-Ix1uc/W3ht7QT0dZR+AlfA@public.gmane.org>
>>  *
>> @@ -26,6 +26,7 @@
>> #define HWLOCK_IRQ	0x02	/* Disable interrupts, don't save state */
>>
>> struct device;
>> +struct device_node;
>> struct hwspinlock;
>> struct hwspinlock_device;
>> struct hwspinlock_ops;
>> @@ -60,6 +61,8 @@ struct hwspinlock_pdata {
>>
>> #if defined(CONFIG_HWSPINLOCK) || defined(CONFIG_HWSPINLOCK_MODULE)
>>
>> +int of_hwspin_lock_get_base_id(struct device_node *dn);
>> +int of_hwspin_lock_get_num_locks(struct device_node *dn);
>> int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev,
>> 		const struct hwspinlock_ops *ops, int base_id, int num_locks);
>> int hwspin_lock_unregister(struct hwspinlock_device *bank);
>> @@ -80,9 +83,9 @@ void __hwspin_unlock(struct hwspinlock *, int, unsigned long *);
>>  * code path get compiled away. This way, if CONFIG_HWSPINLOCK is not
>>  * required on a given setup, users will still work.
>>  *
>> - * The only exception is hwspin_lock_register/hwspin_lock_unregister, with which
>> - * we _do_ want users to fail (no point in registering hwspinlock instances if
>> - * the framework is not available).
>> + * The only exception is hwspin_lock_register/hwspin_lock_unregister and
>> + * associated OF helpers, with which we _do_ want users to fail (no point
>> + * in registering hwspinlock instances if the framework is not available).
>>  *
>>  * Note: ERR_PTR(-ENODEV) will still be considered a success for NULL-checking
>>  * users. Others, which care, can still check this with IS_ERR.
>> -- 
>> 1.8.3.3
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe devicetree" in
>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-09-27 16:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-17 19:30 [PATCHv2 0/9] omap hwspinlock dt support Suman Anna
2013-09-17 19:30 ` [PATCHv2 1/9] hwspinlock/core: add common dt bindings and OF helpers Suman Anna
2013-09-27 16:04   ` Kumar Gala
     [not found]     ` <14DB8294-1148-446A-A6D3-34E66BA8732C-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2013-09-27 16:48       ` Suman Anna [this message]
     [not found]         ` <5245B6F9.7030505-l0cyMroinI0@public.gmane.org>
2013-09-27 17:14           ` Kumar Gala
     [not found]             ` <3C582FCF-7A24-48AC-B98B-AF1D18C1E22B-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2013-09-27 19:26               ` Suman Anna
2013-10-01  8:36       ` Mark Rutland
2013-10-03  4:04         ` Suman Anna
     [not found]           ` <524CECBF.2070805-l0cyMroinI0@public.gmane.org>
2013-10-09 21:40             ` Mark Rutland
2013-09-17 19:30 ` [PATCHv2 2/9] hwspinlock/omap: add support for dt nodes Suman Anna
2013-09-27 16:06   ` Kumar Gala
2013-09-27 16:21     ` Suman Anna
     [not found]       ` <5245B076.1090008-l0cyMroinI0@public.gmane.org>
2013-09-27 17:14         ` Kumar Gala
     [not found]     ` <AE597DCC-83D7-4BCD-8990-3D63540F32EA-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2013-10-01  8:40       ` Mark Rutland
2013-10-03  4:12         ` Suman Anna
     [not found]           ` <524CEE9F.8060407-l0cyMroinI0@public.gmane.org>
2013-10-09 21:46             ` Mark Rutland
2013-10-10 20:29               ` Suman Anna
2013-09-17 19:31 ` [PATCHv2 3/9] ARM: dts: OMAP4: Add hwspinlock node Suman Anna
2013-09-17 19:31 ` [PATCHv2 4/9] ARM: OMAP5: hwmod data: Add spinlock data Suman Anna
2013-10-09  7:12   ` Paul Walmsley
     [not found]     ` <alpine.DEB.2.02.1310090712440.30199-rwI8Ez+7Ko+d5PgPZx9QOdBPR1lH4CV8@public.gmane.org>
2013-10-09 17:49       ` Suman Anna
2013-09-17 19:31 ` [PATCHv2 5/9] ARM: dts: OMAP5: Add hwspinlock node Suman Anna
2013-09-17 19:31 ` [PATCHv2 6/9] hwspinlock/omap: support AM33xx Suman Anna
2013-09-17 19:31 ` [PATCHv2 7/9] hwspinlock/omap: enable module before reading SYSSTATUS register Suman Anna
2013-09-17 19:31 ` [PATCHv2 8/9] ARM: dts: AM33XX: Add hwspinlock node Suman Anna
2013-09-17 19:31 ` [PATCHv2 9/9] ARM: AM33xx: hwmod_data: add the sysc configuration for spinlock Suman Anna
2013-10-09  7:12   ` Paul Walmsley
     [not found] ` <cover.1379445653.git.s-anna-l0cyMroinI0@public.gmane.org>
2013-09-27 15:48   ` [PATCHv2 0/9] omap hwspinlock dt support Suman Anna
     [not found]     ` <5245A8CA.4020805-l0cyMroinI0@public.gmane.org>
2013-09-30  3:12       ` Paul Walmsley
     [not found]         ` <alpine.DEB.2.02.1309300309530.17980-rwI8Ez+7Ko+d5PgPZx9QOdBPR1lH4CV8@public.gmane.org>
2013-09-30 15:56           ` Suman Anna

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5245B6F9.7030505@ti.com \
    --to=s-anna-l0cymroini0@public.gmane.org \
    --cc=bcousson-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ohad-Ix1uc/W3ht7QT0dZR+AlfA@public.gmane.org \
    --cc=paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).