Commit Graph

43 Commits

Author SHA1 Message Date
Sagar Dharia a404cc5d84 slimbus: Reset data channels for a controller when framer reboots
Framer is responsible for clocking slimbus, and when it reboots, state
of all associated data channels is reset to be consistent with HW
state.

Change-Id: Ie74ace2b20ad6c255440ff6ce593f7d5503bf388
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2016-02-08 01:29:48 -08:00
Sagar Dharia 56b3d9e2f2 slimbus: Use irq-safe methods for transaction lock
Slimbus transactions are process-completed in interrupt context.
This involves signaling appropriate transaction from transaction table
and/or invalidating transaction in error case. Due to this, the
transaction need to be accessed from interrupt context as well. Use
irq-safe methods to avoid interrupt accessing the lock while thread
has acquired it.

Change-Id: Ibe800a64a7594cc435d229e05dda91baea8c9b6e
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2015-07-19 10:44:19 -07:00
Linux Build Service Account 9d81827781 Merge "slimbus: Support multiple message transactions per call" 2015-07-05 02:35:39 -07:00
Sagar Dharia 159728155d slimbus: Support multiple message transactions per call
Bandwidth intensive operations (such as firmware download) need
lot of messages to be sent over the bus. This API adds support to
queue multiple messages to HW and provides controller implementation
using BAM.
The API can also be used in places where slimbus slaves have strict
ordering/timing restrictions (e.g. send 2 specific register-writes
back-to-back).

Change-Id: I9a0779e0c4b957d4f4e3b31567b983457d367193
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2015-07-03 02:26:49 -07:00
Dilip Kota 9d1a97fab0 slim-msm: Configure push pull protocol on MSM Controller
Configures push pull protocol parameters on
MSM controller. It makes sure to program the
push pull protocol per channel in the framework.
Irresepective of client request, configure to
ISO protocol if channel frequency is multiple
of super frame frequency.

Change-Id: I7f9fc4d7af682d27f617d0220bab2d9b79ade6c8
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
2015-06-16 20:16:00 +05:30
Linux Build Service Account 8001c627f9 Merge "slimbus: Add support to specify port config and options" 2015-06-11 13:07:53 -07:00
Sagar Dharia e577f13f94 slimbus: Protect transaction-id assignment
Transaction ID is used by slimbus for reply-information or
reply-value messages. Ensure transaction ID assignment is protected
to avoid race condition between 2 or more transactions.

Change-Id: Ie8943de0bcbb9d7fddc22025af051d74e6c9901a
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2015-05-15 16:06:55 -07:00
Sagar Dharia d382ee5e19 slimbus: Add support to specify port config and options
Client should be able to specify port configuration if it differs
from the default configuration

Change-Id: Iecc019de0b10c6931f5c1e521efd4f6fee178fe9
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2015-05-01 15:07:53 -06:00
Sagar Dharia 68e2f99712 slimbus: Optimize transaction handling in the framework
Avoid overhead of allocating/freeing structure for transaction
if that transaction is synchronous. For synchronous transactions,
structure is defined on stack using a macro for simplicity. Since
structure is not allocated per transaction and locking is required
only for a few simple instructons, spinlock can be
used to protect the transaction table.

Change-Id: I79ea64b98907ab71fd727d76cf78a2d6feaf0eb0
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2015-02-13 15:59:21 -07:00
Sagar Dharia 6b4bbcba3a slimbus: Support push-pull data channel protocol
Start supporting push-pull data channel protocol in slimbus driver
since the slimbus HW supports it now.

Change-Id: If6b26a696cd2a459a5c5215588711ea037e778ac
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2014-12-16 12:34:21 -07:00
Naveen Kaje 9776549cde slimbus: Cleanup dev_list when device is removed
Remove a device's list-entry from controller's
device-list when that device is removed.

Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Change-Id: I068bf34b6692dad33332f4b9baf49e768f5b2736
2014-09-05 17:26:00 -06:00
Sagar Dharia 6085240248 slim_msm: support non-blocking writes from slimbus MSM controller
Provide non-blocking write support so that clients can queue multiple
writes, or larger transfers without performance implications.
TX buffer is created and descriptors out of this buffer
are submitted to HW to transmit data.
Descriptor is returned to 'available' pool of TX buffer when HW
interrupt for transmission status is recieved.

Change-Id: Icc2af6bf4f770c8cadb9bd2ef7be0f95eb22c5d8
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2014-07-15 15:57:28 -06:00
Linux Build Service Account 72d541c4f7 Merge "slim-ngd: NULL pointer check for client buffer" 2014-02-26 21:23:13 -08:00
Sagar Dharia 1f66f596a0 slimbus: Use physical address type where physical address is used
Use physical address type for buffers using physical address.
(e.g. interaction with data-mover engine)

Change-Id: If0c02f13562c762c6effcea82a1e3c351ec2e288
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2014-02-12 20:39:15 -07:00
Sagar Dharia e7b7f90367 slimbus: Enable clients to send user messages to devices.
Slimbus protocol allows user messages of destination referred, or
source referred type to be sent to a slimbus device.
Provide framework to support such messages. Note that, controller
may not support all user messages.

CRs-Fixed: 503461
Change-Id: I3644c6d671a620122095ace64da64c4e71eb9607
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2014-02-12 20:30:52 -07:00
Kiran Gunda 64e29070fd slim-ngd: NULL pointer check for client buffer
There is the chance of passing NULL pointer by the client
during the Slimbus/Codec transactions. Hence add NULL
pointer check for client buffer aswell.

CRs-Fixed: 608324
Change-Id: I161e8f04401afebb64ed72d5f392a67feb6ec13a
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
2014-02-04 07:45:27 +05:30
Linux Build Service Account f2f2c38e38 Merge "slim_ngd: Fix logical address notification mechanism" 2014-01-28 01:16:48 -08:00
Sagar Dharia b29669b783 slim_ngd: Fix logical address notification mechanism
It's possible that multiple slaves report present/absent and expect
corresponding notifications concurrently. Avoid using controller
resources where possible, and use list_for_each_safe to allow
changes to the device-list during list traversal.

Change-Id: I371c48d25a0953f5f1909c904e8fd80b599d16b3
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2014-01-24 18:18:18 -07:00
Sagar Dharia dc70628cfe slimbus: Remove unnecessary pointer type-cast
Use correct format-specifier in debug-log to remove pointer
type-cast

Change-Id: I304d2e04185b694b14fba41124abba165df8dacf
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2014-01-08 19:00:02 -07:00
Sagar Dharia df8e3c868a slimbus: Provide framer-booted notification to slimbus device drivers
When slimbus resets (due to bus reset sequence, or after it shuts down
and comes up), framer boots up and starts clocking the bus.
Devices on the bus may be in undefined state at that time. Callback
is provided to slimbus device drivers so that controller can report
framer-booted notification so that drivers can take necessary action
to put devices in reset state so that they can acquire sync, report
present, and be operational.

Change-Id: I6068063ef32c91a67c246f9ee727b4724c11f5f2
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2014-01-02 14:37:49 -08:00
Kiran Gunda 90789f1e00 Slimbus: Correct the conditional check during channel removal
Use actual channel number to check if the channel to be
removed is present in the define_chan list before removing
it, instead of using the internal channel number used by
the frame work.

CRs-Fixed: 555260
Change-Id: I4c9521f7d228ca43c155fedf2c9ba5b8f86e2d3a
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
2013-11-19 15:26:14 +05:30
Sagar Dharia 7700a04250 slimbus: Manage channel slots only if framework manages bandwidth
If slimbus controller overrides bandwidth management, channel slots
should not be managed since controller is expected to do that.
Slimbus controller will go into idle mode due to this change when
channel setup/teardown is done. Make sure controller can transition
states correctly in runtime-pm suspend, and system-suspend case.

Change-Id: Id41aed822e3c98af8c1fe7db3a3527a1206739be
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-10-24 12:40:18 -06:00
Sagar Dharia 3083c46358 slim_ngd: Handle runtime-pm resume error gracefully
Runtime-pm resume for satellite driver may fail if ADSP is going
through subsystem-restart. Handle that error, and set runtime-pm's
status to suspended if resume fails. Resume typically fails due to
failure to wake slimbus from pause_clock. Make sure another wakeup
can be tried later when ADSP comes back up

Change-Id: Ie9b798f5506de89a37491dbc3798acaa24b98808
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 17:20:39 -07:00
Sagar Dharia 2364ccc170 slimbus: Add support for report-absent and device-down notification
device_down callback will be called when the device sends
report-absent message per slimbus specification, or if the device
cannot be reached due to some other reason (e.g. bus going down).
device_up will be called when the device sends reports present again.

Change-Id: Ie48c2e3891b55cb1ec9c675a32cdb0a568fdcc18
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 17:18:28 -07:00
Sagar Dharia 43c2d0f718 slimbus: Fix port allocation and deallocation for manager's ports
Since Manager's ports don't have any direction when allocated, make
sure the direction is not checked when connect-port is called on a
manager port. Ensure that controller's port resourced are freed-up
when dealloc_mgrports is called.

Change-Id: I588408276cbee020623666b08433b57475cf47cc
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 17:03:59 -07:00
Sagar Dharia 727626b5dd slimbus: Handle channel control correctly if controller manages BW
If bandwidth allocation is managed by controller (and not framework),
channel control commands from all clients should be sent to the
controller.

Change-Id: Ibdd27c35a48818efdd55a0a84c52fbb9671cdb77
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 16:08:45 -07:00
Sagar Dharia b4e076fa32 slimbus: Add slimbus device driver unregistration function
slim_driver_unregister is added to reverse effects of
slim_driver_register. That way a slimbus device driver can be
registered when driver module is loaded, and unregistered when
the driver module is unloaded.

CRs-Fixed: 441540
Change-Id: Iae64f84c99d5027c9b55c3fde5fe71c6a550354e
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:53:26 -07:00
Sagar Dharia 8fc83c694f slim_ngd: Re-initialize Slimbus NGD controller when ADSP restarts
Slimbus manager HW is controlled from ADSP. When ADSP restarts, NGD
controller goes in inactive state, and BAM pipes are disconnected.
When ADSP comes up later, controller is re-initialized and all slaves
on this controller are re-assigned logical address. BAM pipes are
reconnected as well. These steps are done after ADSP slimbus HW
informs NGD controller that it has come up.

CRs-Fixed: 419384
Change-Id: Ic1ba1fe14adeb9661de3735a0afc8e4b05fa4606
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:48:53 -07:00
Sagar Dharia d87960ed2f slimbus: Refine scope of controller and scheduler mutex locks
Controller mutex scope is restricted to controller specific data
structures, such as addressing table, transaction table.
Scheduler lock is used to protect scheduling data structures (such
as channels, and bandwidth).
This way, controller mutex is not needed when expensive
reconfiguration sequence(used for channel scheduling, bandwidth
management) is in progress. Transactions over messaging channel (such
as element read/writes, logical address assignment) can happen in
parallel and don't have to block on reconfiguration sequence which
only affects data channels.

CRs-Fixed: 426945
Change-Id: I2ca20aa76901ee19dba62874c86c2108fac9fa02
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:41:25 -07:00
Sagar Dharia 1d75479f73 slimbus: Populate slimbus device's logical address during assignment
Slimbus device is assigned logical address when it reports present.
Make sure to populate the device's logical address (laddr) during
this assignment.

CRs-Fixed: 412148
Change-Id: Icb8d74f6ea71aff8f6cb30523002f7839e2cb028
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:34:11 -07:00
Sagar Dharia 3fd6449dd0 slimbus: Specify number of channels for the group in group handle
Use group handle instead of next element in channel's data structure
to identify how many channels were specified by a client in the group.
That way clients can specify different number of channels for shared
channels, and work with their own client-handle. Note that sequence of
channel still matters (so 2 clients sharing a channel should not
specify channels in different order, otherwise scheduling of the
channels will not be in the correct order)

CRs-Fixed: 415109
Change-Id: Idd636a500ee6449b16648a234b9e76fad21f2fcc
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:34:11 -07:00
Kiran Gunda 3c92fe1486 slimbus: Avoid same channel definition, removal in same sequence
Do not add the channel removal request to the remove list
when the client sends it right after the channel definition
without sending reconfigure_now request. Also remove the
channel define request from define list. This avoids
channel definition count being inconsistent, which may
lead to slimbus driver going into wrong state.

CRs-fixed: 409161
Change-Id: Iec4dd51d98416b7d769176bb1ef6cd2f5bacfa12
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
2013-09-04 15:29:44 -07:00
Sagar Dharia d7ada53d7a slimbus: Allow controller to specify logical addresses
It is possible that the controller has fixed addressing table for
enumeration devices. In that case, logical address will be set by
controller and not by framework. get_laddr allows a controller to
assign logical address. Make sure framework allows such addressing
by not assuming that index into address table will represent logical
address.

Change-Id: I0e3873980c2ee2ece01237f450ecefff4e99aedc
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:20:29 -07:00
Sagar Dharia ca1c8dba3d slimbus: Allow controller to override default scheduling algorithm
Framework provides a slimbus scheduling algorithm and controller may
choose to override it. e.g. controller will override this if it
supports fixed set of channels at a fixed clock gear.
In that case, it is controller's responsibility to act on client
requests and update channel scheduling, subframe coding information.

Change-Id: I31fe72ef85f931900467b737652da7516d173dc5
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:20:13 -07:00
Sagar Dharia 5cb587b479 slimbus: Clear slimbus read transaction if synchronous read fails
Failed read transaction is removed from the table of active
transactions if the transaction fails

CRs-fixed: 396237
Change-Id: Idda4d8b5fa2cdfde8a049cc4af4d92e9e57f678a
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:16:15 -07:00
Sagar Dharia ed25c6ef69 slimbus: Decrement channel reference during reconfigure now
Slimbus clients can specify multiple add/remove channel requests
through control_ch API, followed by reconfiguration request (also
known as "commit request"). Clients may rely on the reconfiguration
request to actuate the channel activation/removal and not the
control-channel API.
So the channel reference should be decremented during reconfiguration
request, and not control_ch API.

CRs-Fixed: 389518
Change-Id: Id6ff57c6a4cad878e35004937fb08daf3b9afe7b
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:14:32 -07:00
Sagar Dharia 5cf36039d9 slimbus: Add slave devices to controller after controller HW is up
Register controller is only responsible for making sure slimbus
controller structure is initialized with framework. This should not
assume that slimbus controller's hardware programming is done (e.g. if
slave's probe is trying to get logical address, then that will fail if
controller is registered, but slimbus hardware programming is not
complete, since probe is called synchrounously when device is added.
So this API separates register controller from slave device
registration. It should be called by controller when its hardware
programming is complete.

Change-Id: I52fa5567fc072951c89f99c70507aa3b1e4e22af
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:13:22 -07:00
Sagar Dharia 5213d06dd9 slimbus: Callback to indicate device report present message
Clients can register a callback (just like probe) and that callback
will be called when the client's device reports present per slimbus
specification. The callback is hosted in a workqueue to avoid doing
it in same context from which probe is called (and/or in the context
receiving report present message). Callback is called when the device
reports present for the first time after the bus is initialized.

Change-Id: I8396b87121950f99a09764d497bf2d4b1535565d
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:10:41 -07:00
Sagar Dharia ae0100b285 slimbus: Fix channel concurrent usage during reconfiguration sequence
Reconfiguration sequence can lead to changes in channel segment
distribution and state. Since multiple clients can use 1 channel,
make sure channels cannot be manipulated when reconfiguration
sequence is in progress, and make sure that client doesn't send
reconfiguration sequence when no changes are pending to be sent
in the sequence from it.

CRs-Fixed: 383406
Change-Id: Ib5f0bc32f67f51f118fa417a2e580c8dc87ef0d0
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:07:04 -07:00
Sagar Dharia 10ff35e796 slimbus: Export clock pause function
Previously this function was left-out to be exported by mistake.
Exporting the function helps any caller driver to be a module.

Change-Id: I2b9caca62821caea5ae92123689c6f8ddf2b207a
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:05:56 -07:00
Sagar Dharia 2e035f464d slimbus: Disconnect source port if source end is removed by client
If source end of a channel removes its vote, it should be allowed to
be reclaimed by other client (or by other source port by same client)
who wants to be the source for this channel.

CRs-Fixed: 376731
Change-Id: Ia30c6a4b07de7df98cde8bc928205b4f4598036d
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 15:03:35 -07:00
Sagar Dharia a5432d4a4f slimbus: Modify check for empty slots
There was a corner case where the open slot count was going -ve
indicating that there are no slots left for messaging. The current
check to ensure non-zero messaging slots does not take that into
account. This commit fixes that check.

CRs-fixed: 370229
Change-Id: I832ce0a26f1919d3d03b4ef0311603a5a778685e
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2013-09-04 14:57:51 -07:00
David Brown bec91b0ce8 slimbus: Add Qualcomm Slimbus driver
Signed-off-by: David Brown <davidb@codeaurora.org>
2013-09-04 14:49:49 -07:00