Commit Graph

16 Commits

Author SHA1 Message Date
David Collins fcea656ff7 bif: qpnp-bsi: request BSI interrupts with level high triggering
Request the BSI RX, TX and ERR interrupts using level high
triggering instead of rising edge triggering.  If an interrupt
is edge triggered, then its interrupt handler will be called upon
enabling the interrupt if it physically triggered while it was
disabled in software.  This leads to unexpected interrupt
handler calls in the qpnp-bsi driver when the following sequence
occurs: BIF transaction using interrupts (IRQs enabled), BIF
transaction using polling (IRQs disabled), BIF transaction to
enter interrupt mode bus state (IRQs enabled).

Switching the interrupts to use level triggering fixes the issue
because any interrupt physically triggered during a polling
transaction with the BSI interrupts disabled will be ignored by
the irq framework.

Change-Id: I57a6fb6f75af14970b5a186009ec506e240c151d
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-12-03 09:54:04 -08:00
David Collins 253ec77614 bif: bif-core: add BIF NVM object writing support
Add a function to the bif-core driver which provides a means to
write new BIF data objects into the non-volatile memory (NVM)
of a BIF slave.  Also add functions which can be used to
overwrite or delete an existing BIF object.

Change-Id: I6cd48409c696bd60a4d52b0fac8782c58d744df1
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-10-10 13:29:46 -07:00
David Collins 5bfb07eada bif: bif-core: add BIF object matching support
Update the BIF slave matching criteria so that BIF consumer
drivers can find BIF slaves which contain BIF objects of a
certain type.  Also add functions which allow consumers to get
handles for the BIF objects which match specified search
criteria.

Change-Id: Ice7042ecb3829db8f5601d91940c5f7bef383d3d
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-10-10 13:29:45 -07:00
David Collins 356ab1e444 bif: bif-core: add support for BIF slave NVM read and write
Add support for reading and writing the non-volatile memory (NVM)
of BIF slaves.

Change-Id: Ie422ec57327102584bab2b039a733505320b065b
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-10-10 13:29:44 -07:00
David Collins d53a2a36f3 bif: bif-core: add auto task triggering support
Add support in the bif-core driver for enabling and disabling
automatic task triggering for specified tasks.  One example of
auto task triggering is the periodic polling method employed by
the BIF slave temperature function to check for high or low
temperature conditions.

Change-Id: If01071debd430c084be344549ecf2e8b281d4e05
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-10-10 13:29:41 -07:00
David Collins 8f25604579 bif: bif-core: do not read past the end of NVM when parsing BIF objects
Add a length check in the non-volatile memory (NVM) BIF object
parsing function so that it does not attempt to read past the
end of the NVM address space of the BIF slave.

Change-Id: Iafd40e61e7ca0bfa2e2be95c294a0e17d5cf515c
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-10-02 08:57:20 -07:00
David Collins 93599b9657 bif: qpnp-bsi: move BSI error and flag clearing to immediately before TX
Move functions calls which clear PMIC BSI hardware errors and
reset IRQ flags to immediately before BIF transmit calls.  This
ensures that the BSI RX and TX blocks are in the correct state
before errors are cleared.

Change-Id: Id266f076968d48484a9366274d30e8ff6f47dc23
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-09-25 17:40:49 -07:00
David Collins 9e7a15568c bif: qpnp-bsi: eliminate redundant RBL1 command during register read
When performing a BIF slave register read of a single register
there is no need to specify a burst read length of 1.  All reads
are assumed to be of length 1 unless specified otherwise.
Therefore, remove the redundant RBL1 BIF bus command.

Change-Id: I000637a4bec5f6d2c9b48fa848c63779745b662a
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-09-25 17:40:48 -07:00
David Collins 25b61f7112 bif: qpnp-bsi: correct maximum transaction delay time
The value QPNP_BSI_MAX_TRANSMIT_CYCLES is used to define the
timeout interval when sending or receiving BIF data words.
The MIPI-BIF specification allows for some skew in the length
of bits received from a slave.  A '1' can take up to 3.5 tau_bif
and a '0' can take up to 1.5 tau_bif.  Therefore, the maximum word
transmission time can be calculated as follows.

max-transmission-time =
= n(1)_max * t(1)_max + (17 - n(1)_max) * t(0)_max + t(stop)_min
= 8 * 3.5 tau_bif + 9 * 1.5 tau_bif + 4.5 tau_bif
= 46 tau_bif

Change QPNP_BSI_MAX_TRANSMIT_CYCLES to 46 in order to match the
value calculated from the MIPI-BIF specification.

Change-Id: Ibb199b54c99cc2de29ae54f6f891a667a30213b2
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-09-25 17:40:47 -07:00
David Collins 1fb2dc25e4 bif: bif-core: fall back on time-invariant transactions for read and write
Fall back and use time-invariant individual transactions for BIF
slave register read and write operations if high level read or
write controller callback functions fail.

Change-Id: Ieaf479717383719dc1f5b94cc4be72f2e8901127
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-09-25 17:40:47 -07:00
David Collins 8d63656e06 bif: bif-core: parse secondary slave data
Ensure that BIF data of secondary slaves is parsed when selecting
the secondary slaves based on a BIF secondary slave object read
out of the primary slave.

Change-Id: Id0daceb37c5c052fd149cd7f8015bb54e5b425fb
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-09-25 17:40:46 -07:00
David Collins d4153def8b bif: core: set BIF bus state master-disabled when no slaves are found
Modify the bif_ctrl_register() function so that the bus state is
changed to master-disabled if no BIF slaves are detected.  This
can save power when a smart battery pack is not connected.

Change-Id: Ie50203240f10d09656f41e0feab9971bf265e161
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-09-13 09:49:47 -07:00
David Collins 10714d01ef bif: qpnp-bsi: disable BSI during master-disabled bus state
Disable the BSI PMIC peripheral when the bus state is changed
to master-disabled.  This can be used to save power when no
smart battery pack is detect.

Change-Id: Ic0ce8c11153a6bfa32e4661bf8d791265ebf4f95
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-09-13 09:49:46 -07:00
Siddartha Mohanadoss 000325beb7 hwmon: qpnp-voltage: Support multiple device instance
Support multiple voltage ADC device instance. Clients
need to register with the voltage ADC using the device
consumer name used to associate with the corresponding
phandle of the VADC. Clients receive the device instance
which is to be used everytime an ADC request is made.

This change involves changing the interface to issue
ADC request and the corresponding clients changes.

Change-Id: If0557bc657fecd172a8cf960900ee93b4bce37f8
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 17:14:32 -07:00
David Collins a250e9396b bif: Add PMIC qpnp-bsi BIF controller driver
Add a BIF controller driver which is able to interact with the
BSI (battery serial interface) module found within QPNP compliant
PMIC devices.

Change-Id: I6d63da38e3e7e2b41ee29e75a861123ad3ce3c75
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-09-04 16:05:27 -07:00
David Collins 352e072ee9 bif: Add BIF core framework driver
Add a BIF framework which implements core features of the MIPI
(Mobile Industry Processor Interace) BIF (Battery Interface)
specification.  MIPI-BIF defines an interface which can be used
to communicate with smart battery packs.

BIF controller drivers register with the BIF framework and
implement hardware specific features.  BIF consumers can make use
of an extensive API to communicate with BIF slaves present on a
BIF bus.

Change-Id: Id640344aadf878a49e93b12b16a5ecb181dd5aeb
Signed-off-by: David Collins <collinsd@codeaurora.org>
2013-09-04 16:04:15 -07:00