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>
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>
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>
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>
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>
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>
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>
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>
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
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>
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>
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>
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>
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>
Use correct format-specifier in debug-log to remove pointer
type-cast
Change-Id: I304d2e04185b694b14fba41124abba165df8dacf
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>