Commit Graph

11 Commits

Author SHA1 Message Date
Biswajit Paul 1231732736 spmi: prevent showing the address of spmidev
Creating devices with the address of the container spmidev is not
indicative of the actual hardware device it represents.

Instead use an unique id to indicate the device it represents.

Bug: 28760543
CRs-Fixed: 1024197
Change-Id: Id18e2a19f4fa1249901a3f275defa8f589270d69
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Biswajit Paul <biswajitpaul@codeaurora.org>
2016-07-14 23:43:35 +00:00
Gilad Avidov 8d4bc024d5 spmi-pmic-arb: improve error reporting
Add additional information on error return code and
log dump. Introduce a new return code for transient
failures and add to log dump information  such as:
slave-id, address, op-code, byte-count, data buffer
content, and values of relevant registers.

Change-Id: I6ac785cf78a84a448f96057b93c94df0b72e39ce
Signed-off-by: Gilad Avidov <gavidov@codeaurora.org>
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
2014-06-09 17:00:53 +05:30
Kenneth Heitke 1bdc124ead spmi: Add del_controller functionality
The del_controller function is required to release any client device
resources as well as the debugfs entries.  This patch adds that
functionality.

Change-Id: I91c6b840acfe002f096570cbe1867b302c475e60
Signed-off-by: Kenneth Heitke <kheitke@codeaurora.org>
2013-09-04 16:48:09 -07:00
Kenneth Heitke 2863503001 spmi: Remove redundant controller list
Registered controllers are maintained in a linked list as well as in an
idr (ID management) object which is redundant.  This patch removes the
linked list and just uses the idr to manage the controllers.

Change-Id: Ief36e6870b036304e34d4eec4e22e50c6c028d43
Signed-off-by: Kenneth Heitke <kheitke@codeaurora.org>
2013-09-04 16:47:42 -07:00
Michael Bohan 888e172220 spmi: Add spmi_resource for non spmi-dev-container cases
The devnode array is currently being used for non
spmi-dev-container devices as a special case where the number of
devnodes is 1. This obfuscates the code and also removes the
ability to store the dev-container's device resource information,
since in that special case the devnode array is dedicated for the
child devices.

Add a new spmi_resource entry used for typical spmi_devices, and
treat the devnode array as the special case for
spmi-dev-container.

Also add a new API spmi_get_primary_dev_name() to return the name
of the device assigned with the 'label' binding if it exists.

Change-Id: Ibe7b12285e37bb0529024558550a96d71393bc10
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
2013-09-04 14:57:31 -07:00
Michael Bohan 430b932c92 of: spmi: Add support for device naming and lookups
Since we support multiple device_nodes per spmi_device when used
with the spmi-dev-container flag, it's often unclear how a driver
should make reference to a particular device. Therefore,
introduce the spmi specific binding spmi-dev-name that specifies
the device name for the device_node.

Also introduce an API that can be used from
the driver to lookup the specific device node associated with a
particular device name.

Note that it may seem at first glance that the binding 'label' is
redundant with device_node->name. However, per the ePAPR,
device_node->name is intended to be as generic as possible,
representing the function of the device and not the precise
programming model. 'label' is used to give a platform
specific name that can be queried from device drivers.

Change-Id: I28eca35d0b625372c26a6d8ad81e7679f200d14b
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
2013-09-04 14:57:30 -07:00
Michael Bohan 441ab7c9d4 of: spmi: Support resource naming
reg-names and interrupt-names are standard bindings to map device
tree reg and interrupt indices to particular names. This way the
driver does not need to be concerned with hard coded assignments.
Therefore, add spmi support for these bindings.

Explicit support for reg-names is required since the
implementation does not make use of of_address_to_resource(),
which happens to already support this.
This is because of_address_to_resource() mandates address
translation, which is not relevant to spmi.

interrupt-names is already implicitly handled by
of_irq_to_resource(), which is used in the spmi implementation.
Add additional documentation to state clearly that this binding
is also supported.

Also add supporting routines to easily lookup a resource by name
for both registers and interrupts.

Change-Id: I94faf950da5106ecd4ff36f47e5b46102d9bd426
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
2013-09-04 14:57:29 -07:00
Michael Bohan 58a7cae082 spmi: qpnp: Change APIs to take a spmi_resource pointer instead of index
Pointers are more flexible than index numbers, since index
numbers depend upon an additional reference to the array in
question. In particular, we'd like to add a new API to lookup a
devnode based on a predefined name in the Device Tree. This API
will return a spmi_resource, and so it's natural to want to use
this pointer directly with the other existing APIs.

Also introduce a new API spmi_for_each_devnode that can be used
to iterate each spmi_resource in the dev_node array. This
abstracts the traversal of the array, which was previously done
within the existing APIs.

Change-Id: I18f9397e5d78770e840a9f95dd8061201931df6e
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
2013-09-04 14:57:29 -07:00
Michael Bohan 6b556ed08f spmi: Rename qpnp library to be part of the spmi framework
It turns out that the only use cases for the qpnp library use
the existing spmi data structures. As such, there's really
no justification for having the library not be called 'spmi'.
There is nothing Qualcomm specific about this code.

Also cleanup some inconsistencies in the Kernel Doc comments
while we're here.

Change-Id: I1c73c88be740b6f5d38ba2de62de1737981b30fa
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
2013-09-04 14:57:28 -07:00
Michael Bohan c046a24e19 of: of_spmi: Add support for spmi-dev-container binding
The spmi-dev-container binding is intended for SPMI
configurations that have multiple device nodes associated with
only one spmi_device. By default, if this flag is not specified,
each device node will create a new spmi_device.

Sometimes having multiple spmi_devices for SPMI device nodes is
superfluous. One example of this is gpios. In some architectures,
a single gpio is treated as a unique device. But from a gpio_chip
perspective, the chip is comprised of many gpios. Beyond wasting
memory allocating a unique spmi_device per gpio, the implication
of not coalescing spmi_devices is that the clients probe() routine
would be called N number of times. But this sort of behavior makes
it difficult to realize when a gpio_chip starts and stops. If we
assume that one gpio_chip represents one call to probe(), then
this problem is solved, since all gpios in that chip will be
passed as resources.

In order to support multiple device nodes per spmi_device, we
also need to extend the data structures for spmi_resources.

This change also makes an effort to cleanup some of the error
handling for illegal combinations of device bindings, as well as
adding some additional documentation.

Change-Id: If3ce2aaaa07bdf79e0d9fdedf16419e74a00fbec
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
2013-09-04 14:49:56 -07:00
Kenneth Heitke fddd00f89d spmi: Linux driver framework for SPMI
SPMI (System Power Management Interface) is a specification
developed by the MIPI (Mobile Industry Process Interface) Alliance
optimized for the real time control of Power Management ICs (PMIC).

SPMI is a two-wire serial interface that supports up to 4 master
devices and up to 16 logical slaves.  A physical PMIC device may
consist of multiple logical slave interfaces.

The framework supports message APIs, multiple busses (1 controller
per bus) and multiple clients/slave devices per controller.

Change-Id: Ib6319047b4ab9cea6dfb0879312c4c1f63462439
Signed-off-by: Kenneth Heitke <kheitke@codeaurora.org>
2013-09-04 14:49:50 -07:00