Commit Graph

1976 Commits

Author SHA1 Message Date
Jeffrey Carlyle 140026b32f greybus: svc: implement svc_intf_activate
With upcoming firmware changes we will switch from an SVC-driven module
boot sequence to an AP-driven module sequence. This operation allows the
AP to request the SVC to boot a module to which the AP has previouslt
requested power be applied. This operation will also determine if the
remote interface is a dummy module, UniPro-only module, or full Greybus
module.

Testing done: Tested together with "new" firmware boot sequence to
              verify that modules are detected and booted as expected.

Signed-off-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-09 08:47:18 +02:00
Jeffrey Carlyle 144763bf8e greybus: svc: implement svc_intf_{vsys,refclk,unipro}_{enable,disable} operations
Add SVC operations for fine grain control over vsys, refclk, and unipro
port power.

Testing done: used "new" firmware boot sequence to verify that modules
              were correctly detected and booted.

Signed-off-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-09 08:47:18 +02:00
Jeffrey Carlyle 03b4fa4b5d greybus: Revert "bootrom: Implement timeouts to detect Module failures"
This reverts commit 571348253032a86e4f0102d4dfadd390d0ea7e64.

With this patch gb_bootrom_timedout was getting called in interrupt
context and then proceeding to call functions that might block. In
practical terms, this was leading to a kernel BUG at mm/vmalloc.c:1650.

Signed-off-by: Jeffrey Carlyle <jcarlyle@google.com>
Acked-by: Johan Hovold <johan@hovoldconsulting.com>
2016-05-06 11:54:55 -07:00
Viresh Kumar 69c8763eb8 greybus: fw-download: Introduce timeouts for firmware downloads
As per greybus specification, the AP can apply, implementation
dependent, timeouts for:

- The time interval between the Find Firmware Response and the first
  Fetch Firmware Request.
- The time interval between a Fetch Firmware Response and the next Fetch
  Firmware Request.
- The time interval between a Fetch Firmware Response and the Release
  Firmware Request.
- The time interval between the Find Firmware Response and the Release
  Firmware Request.

This patch implements those timeouts.

The timeout period for the first three cases is fixed to one-second and
the timeout for the last one is finalized at runtime, dependent on the
total size of the firmware.

There can be two possible paths now, which may race for freeing or
getting the 'struct fw_request'. They are:
- Request handler: initiated from the Module side.
- Timeout handler: initiated on timeout of the programmed timer.

And so a mutex is added to avoid races.

Every caller which needs to access the 'struct fw_request' increments
the reference count, so that the structure doesn't get freed in
parallel. Once the structure is freed and reference is put by all the
users, the structure is freed.

If we timeout while waiting for a request from the Module, the AP frees
the 'struct fw_request', but does *not* free the request-id. This is
done to guarantee that a delayed request from the Module for the expired
id, doesn't get access to a new 'struct fw_request' allocated later with
the same id.

Tested with gbsim by hacking its code to delay the release request and
indefinitely fetch the same section of the firmware package. Both timed
out on the AP side and the 'struct fw_request' is free properly. Further
requests work fine after few are timed out. And rmmod (followed by more
similar testing) works just fine.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:52:06 -07:00
Viresh Kumar f63a896e53 greybus: fw-download: Manage firmware requests with kref
This patch updates the fw-download core to manage firmware requests with
kref. This is required for the next patch, which will introduce timeouts
for firmware downloads.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:52:06 -07:00
Bryan O'Donoghue c4058b7926 greybus: arche-platform: Rework platform/wd-line state transition logic
This patch simplifies and improves the readability of the internal state
transition logic of arche platform driver state transition logic by:

1. Making a dedicated function to state-transition the platform code.
2. Condense the decision to swtich states down to a single switch
   statement instead of four separate if/else clauses.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Suggested-by: Alex Elder <elder@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:49:02 -07:00
Vaibhav Hiremath 886aba558b greybus: arche-platform: Export fn to allow timesync driver to change the state
With the addition of the timesync driver and looking at the hardware
interfaces we have, its clear we need to add a new arche-platform state.

This patch adds ARCHE_PLATFORM_STATE_TIME_SYNC to the arche-platform driver
to facilitate transition to the TIME_SYNC state if-and-only-if the
arche-platform driver is in the ACTIVE state.

This is mainly needed as wake/detect lines are shared between TIMESYNC
operation and basic control functionality of APBs. So during TIMESYNC
we want to make sure that the events on wake/detect lines are
ignored by the arche-platform APB reset logic.

This patch adds one exported function, which can be invoked from
timesync driver code, allowing, switching between
ARCHE_PLATFORM_STATE_TIME_SYNC <=> ARCHE_PLATFORM_STATE_ACTIVE states.

[ bryan.odonoghue@linaro.org: Added mutex, massaged commit text ]

Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Suggested-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:49:02 -07:00
Vaibhav Hiremath 6c1ca56d85 greybus: arche-platform: Rename spinlock variable lock => wake_detect_lock
With addition of exported function, required for TIMESYNC operation,
we need more locking mechanism for driver state, so to avoid confusion
rename existing spinlock variable to its appropriate name.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:49:02 -07:00
Bryan O'Donoghue 521d0d5380 greybus: greybus_protocols.h Add SVC_TIMESYNC_PING
In order to verify TimeSync functionality we require a TimeSync-ping
operation where the AP can command the SVC to initiate a single strobe of
downstream TimeSync slaves, and report the FrameTime at the strobe. Ping
will only be valid after the system has transitioned to a TIMESYNC_ACTIVE
state.

In the active state each TimeSync slave will graph a single incoming SVC
strobe as a ping and will store its frame time. The AP will then gather
each last-event FrameTime for presentation to user-space in the AP and/or
further automation based on the reported FrameTimes at the SVC ping.

This patch adds the SVC ping command definition to greybus_protocols.h.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:49:02 -07:00
Bryan O'Donoghue 596e4a1933 greybus: greybus_protocols.h Add SVC_TIMESYNC_WAKE_PINS_ACQUIRE/RELEASE
Its necessary to establish an initial state on the wake-detect lines before
enabling timesync on APB/GPB in order to ensure all GPIO edge-transitions are
correctly interpreted by the receiving processor.

This patch adds the operations defined in the Greybus specification to
greybus_protocols.h, this involves adding the
SVC_TIMESYNC_WAKE_PINS_ACQUIRE and SVC_TIMESYNC_WAKE_PINS_RELEASE commands
and moving the 'strobe_mask' parameter from 'struct
gb_svc_timesync_enable_request' to 'struct
gb_svc_timesync_wd_pins_acquire_request' since the communication of the
strobe_mask will be communicated before preparing any of the bridges to
receive the TimeSync pulses.

A separate patch to the greybus specification describes the transition
between the wake sub-state and the timesync sub-state.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:49:02 -07:00
Bryan O'Donoghue 5015d5cff9 greybus: greybus_trace.h: Fix dodgy indentation
We should use tabs not spaces when indenting multi-line macros and ensure
that the relevant '\' characters are aligned to each-other.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:49:02 -07:00
Viresh Kumar 73d292d838 greybus: uart: Kill reference_count hack
This was done long back and was probably the best bet then, but it looks
really bad to have it this way now.

Kill the hack and implement proper driver init()/exit() routines to do
the same thing.

Tested using gbsim by hotplugging uart manifest and removing it later.
Also tried removing the gb-phy module to test the exit path properly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Vaibhav Hiremath ceadf9def1 greybus: Documentation: Add sysfs information about bridged-phy device
Update the documentation (sysfs-bus-greybus) for recent conversion of
bridged-phy drivers to real drivers.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Greg Kroah-Hartman 4dda7e96cf greybus: USB: convert to a gpbridge driver
This converts the USB driver to be a gpbridge driver, moving it away
from the "legacy" interface.

It's not like this code even does anything at the moment, how much
trouble could we cause with this change?  :)

Testing Done: Tested on gbsim.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of
drivers. 2.Exit path fix. 3. Fixed review comments]
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Greg Kroah-Hartman ba3e67001b greybus: SPI: convert to a gpbridge driver
This converts the SPI driver to be a gpbridge driver, moving it away
from the "legacy" interface.

Testing Done: Tested on gbsim.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of
drivers. 2.Exit path fix. 3. Fixed review comments]
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Greg Kroah-Hartman dcd2086aa8 greybus: SDIO: convert to a gpbridge driver
This converts the SDIO driver to be a gpbridge driver, moving it away
from the "legacy" interface.

Testing Done: Tested on gbsim.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of
drivers. 2.Exit path fix. 3. Fixed review comments]
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Greg Kroah-Hartman 315bea0e96 greybus: GPIO: convert to a gpbridge driver
This converts the GPIO driver to be a gpbridge driver, moving it away
from the "legacy" interface.

Testing Done: Tested on gbsim.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of
drivers. 2.Exit path fix. 3. Fixed review comments]
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Greg Kroah-Hartman cf1d8bee59 greybus: I2C: convert to a gpbridge driver
This converts the I2C driver to be a gpbridge driver, moving it away
from the "legacy" interface.

Testing Done: Tested on gbsim.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of
drivers. 2.Exit path fix. 3. Fixed review comments]
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Greg Kroah-Hartman 320549086d greybus: PWM: convert to a gpbridge driver
This converts the PWM driver to be a gpbridge driver, moving it away
from the "legacy" interface.

Testing Done: Tested on gbsim.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of
drivers. 2.Exit path fix. 3. Fixed review comments]
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Greg Kroah-Hartman 7dbe1f497b greybus: UART: convert to a gpbridge driver
This converts the UART driver to be a gpbridge driver, moving it away
from the "legacy" interface.

Testing Done: Tested on gbsim.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of
drivers. 2.Exit path fix. 3. Fixed review comments]
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Vaibhav Hiremath 6d58e71444 greybus: connection: export gb_connection_disable_rx() fn
gb_connection_disable_rx() fn is required to be used by other modules
(e.g. bridged-phy drivers) and so export it.

Testing Done: Tested on gbsim.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Vaibhav Hiremath ac4cbc5751 greybus: gpbridge: Add gpbridge driver init/exit helper macros
In order to help bridged-phy drivers to define init()/exit()
functions, define helper macro in gpbridge.h file.

Testing Done: Tested on gbsim.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Greg Kroah-Hartman 1d5f9ef9ef greybus: gpbridge: implement gpbridge "bus" logic
This creates a gpbridge "bus" that will be used to create devices that
are the bridged phy devices that correspond to the protocols being
implemented.

Testing Done: Tested on gbsim.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of
drivers. 2.Exit path fix. 3. Fixed review comments]
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Viresh Kumar 0decdd55b3 greybus: Revert "interface: Fetch and expose version of interface's firmware"
This reverts commit b957ade7b3e4ab8c149c53346dbf02e977b7f3a7.

The interface version is now managed as part of the firmware-management
protocol. This operation is already removed from the greybus
specifications.

Drop interface version support from greybus.

Tested with gbsim (sysfs file not available after this patch).

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Acked-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:33:20 -07:00
Dinko Mironov c77f85bbc9 greybus: audio: Fix incorrect counting of 'ida'
Function gb_audio_manager_remove_all() to remove all audio modules,
doesn't control correctly 'ida' counting.

Signed-off-by: Dinko Mironov <dmironov@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:33:20 -07:00
Mitchell Tasman ee2f2074fd greybus: svc: reconfig APBridgeA-Switch link to handle required load
SW-4894, SW-4389, and share a common root cause, namely that
the power-on reset configuration of the APBridgeA-Switch link of PWM
Gear 1, 1 Lane, Slow Auto, is insufficient to handle some required
traffic loads, such as 3 audio streams plus boot-over-UniPro or 4 audio
streams.

The correct long-term solution is to implement a UniPro Power Mode
Manager as in that considers the demands placed on the network,
and adjusts power modes accordingly.

The present commit implements a short-term, brute-force hack to allow
continued system testing:
- Upon receiving an SVC HELLO request, schedule deferred work to
  reconfigure the APB1-Switch link to PWM G2, 1 lane, Slow Auto
- When the Camera driver transitions a White Camera module from active to
  inactive, return the APB1-Switch link to PWM G2, 1 lane, Slow Auto

The Camera driver already steps up the APBridgeA-Camera link speed while a
camera module is active, which affords sufficient margin for simultaneous
audio and hotplug activity, and the Camera driver already steps down the
link speed thereafter: the change made by the present patch is simply to
tweak the stepped-down power mode to match the new baseline configuration.

Signed-off-by: Mitchell Tasman <tasman@leaflabs.com>
Tested-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04 18:41:05 -07:00
Sandeep Patil 3e29bcf4b1 greybus: core: add MODULE uevent var for all control devices
The new ctrl device under interface is missing a MODULE uevent var,
add it.

Testing Done:
cat 'uevent' from ctrl device.
$ cat 1-3.3.ctrl/uevent
DEVTYPE=greybus_control
BUS=1
MODULE=3
INTERFACE=3
GREYBUS_ID=fffe0001/ffee0011

Signed-off-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04 18:41:05 -07:00
Viresh Kumar c81b1ec785 greybus: bootrom: Implement timeouts to detect Module failures
Its possible that the Module may fail to download the next stage
firmware, or to jump into it and boot into the new personality.

We have already seen examples of both of these cases on EVT 1.5.

This patch implements timeouts in the bootrom bundle driver, which now
expects the next request from the Module to be received at the AP within
1 second of the previous request/response. The time interval can be
increased later if required.

The timeouts are added between:
- AP_READY and FIRMWARE_SIZE operations
- FIRMWARE_SIZE and GET_FIRMWARE operations
- Two GET_FIRMWARE operations
- GET_FIRMWARE and READY_TO_BOOT operations
- READY_TO_BOOT operation and the call to the ->disconnect() event of
  the bootrom bundle (once the new hotplug request is received).

The timeout for the last case is kept at 5 seconds right now (random
value), as it may take a bit longer.

Because 'bootrom->fw' can be accessed simultaneously (from timeout
handler and incoming requests) and one of them can potentially free the
'->fw' structure, a mutex is also added to take care of such races while
accessing 'bootrom->fw' structure.

Also note that the '!bootrom->fw' check is moved to free_firmware()
routine.

Tested on EVT 1.5, by faking errors on certain requests, so that the
bootrom doesn't send any more requests. Normal case is working just
fine for audio and GP modules.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04 11:33:18 -07:00
Vaibhav Agarwal 0634874a58 greybus: audio: Use standard API to set connections' private data
Use standard API greybus_set_drvdata() while setting private
data pointers for mgmt & data connection.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04 11:30:20 -07:00
Vaibhav Agarwal c188fdc817 greybus: audio: Reduce codec->lock granularity
Earlier codec->lock protects almost complete register/unregister
module function. This can be reduced to specific operations.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04 11:30:20 -07:00
Vaibhav Agarwal bb9986ef6b greybus: audio: Reorganize sequence in GB audio bundle & codec driver
Modify sequence of register_module & unregister_module in bundle
driver. This would affect the uevent generated for above user
space. Accordingly, we need to modify snd_soc_xxx sequence in
register_module() in codec driver.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04 11:30:20 -07:00
Vaibhav Agarwal 852859ab81 greybus: audio: Remove redundant lock protection & is_connected field
Each module maintains connected status & a lock to protect it.
Using codec->lock we can safely serialize ASoC specific callbacks
(in response to mixer_ctl update or dai_ops) and gb module
disconnect. Thus is_connected field can be removed.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04 11:29:06 -07:00
Vaibhav Agarwal e6ab7a154c greybus: audio: Cleanup GB Audio bundle driver.
Remove unnecessary lock & list maintained in GB audio bundle
driver

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04 11:29:06 -07:00
Vaibhav Agarwal 84e0e38744 greybus: audio:gb_manager: Use proper locking around kobject_xxx
read/write_lock_irqsave mechanism was used to protect modules
list & kobject_xxx() in gb_audio_manager. Since kobject_xxx calls
can sleep spin_lock variants can't be used there. So use rw_sem
for protecting modules_list.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04 11:29:06 -07:00
Viresh Kumar 7557d0481b greybus: fw-download: Create a macro for length of firmware file's name
Create a macro representing the length of the firmware file's name and
use that instead of using magic number in the code.

Suggested-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-03 17:26:36 -07:00
Viresh Kumar cca2220767 greybus: firmware: Add firmware-download protocol driver
This patch adds Firmware Download Protocol support to firmware core,
which allows an Interface to download a firmware package over Unipro.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Jun Li <li_jun@projectara.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:34:32 -07:00
Johan Hovold 7adb32b429 greybus: operation: fix definition of the invalid type
The invalid request type has been redefined as 0x7f.

Also remove the redundant redefinition of the invalid type from the
operation header.

Note that operation type 0x00 has been repurposed for the new generic
ping operation, which will be used to implement proper connection tear
down.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:27:05 -07:00
Johan Hovold a2cf2e5946 greybus: svc: define the version request
Define the SVC version request, which need not need to stay the same as
the legacy version request.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:27:05 -07:00
Johan Hovold b1f8bfea65 greybus: loopback: remove unsupported version request
Remove the unsupported version request from the loopback-driver request
handler.

Unsupported requests are already handled and logged using the default
case.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:27:05 -07:00
Johan Hovold 1c3aead12e greybus: control: implement mode-switch operation
Implement the unidirectional mode-switch operation.

This operation will be used in the implementation of the new generic
mode-switch functionality.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:27:05 -07:00
Johan Hovold 5fdc027d54 greybus: operation: add helper functions for unidirectional operations
Add helper functions for initiating unidirectional operations and
waiting for them to have been acknowledged as sent by the host device.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:27:05 -07:00
Johan Hovold 3e2ee2c1e5 greybus: operation: add support for initiating unidirectional operations
Add support for initiating unidirectional operations, that is, sending
requests that do not require responses.

Note that we already handle incoming unidirectional operations.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:27:05 -07:00
Johan Hovold 613c15e86b greybus: operation: update gb_operation_request_send() documentation
Fix and update gb_operation_request_send() documentation and add
kernel-doc formatting.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:27:05 -07:00
Johan Hovold 410abddb03 greybus: fix outdated kernel-doc comment
Update the function name, which has gained a timeout suffix.

Also fix the kernel-doc formatting.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:27:05 -07:00
Johan Hovold cca69fabeb greybus: interface: remove unused prototype
Remove unused function prototype that was left after a recent change.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:27:05 -07:00
Sandeep Patil 16ba59cedf greybus: Documentation/sysfs: fix sysfs paths
correct sysfs paths typo. (s/device/devices).

Signed-off-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:09:44 -07:00
Sandeep Patil dc9e9cf450 greybus: Documentation/sysfs: add entry for host device bus_id
Add description for greybus host device bus_id attribute

Signed-off-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:09:44 -07:00
Sandeep Patil fbbd2b7c08 greybus: hd: add bus_id attribute
The greybus host device id can only be read by parsing the uevent if one
wants to identify a specific host device 'or' bus. This is 'lsgb' uses
today.

This change adds a bus_id attribute so libraries can identify multiple
host devices 'or' bus if they exist.

Testing Done:
Tested on Arche,
'cat /sys/bus/greybus/devices/greysbus1/bus_id'

Signed-off-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:09:44 -07:00
Johan Hovold 6ddbed5766 greybus: interface: fix broken UniPro flow control
A recent commit inadvertently disabled E2EFC on all interface
connections, due to a failure to clear the ES3 bootrom quirk flags
during mode switch.

Testing Done: Verified that the CPort flags are again set to 0x7 for
non-bootrom interface connections.

Fixes: 5b638080e94e ("svc: keep interfaces registered during
mode switch")
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-28 08:13:46 -07:00
Viresh Kumar 9e04fb7b16 greybus: firmware: Add firmware management bundle driver
All firmware packages on the Modules or Interfaces are now managed by a
special Firmware Management Protocol. The Interface Manifest shall
at least contain the Firmware Management Bundle and a Firmware
Management Protocol CPort within it.

The bundle may contain additional CPorts based on the extra
functionality required to manage firmware packages.

For example, this is how the Firmware Management Bundle of the Interface
Manifest may look like:

	; Firmware Management Bundle (Bundle 1):
	[bundle-descriptor 1]
	class = 0x16

	; (Mandatory) Firmware Management Protocol on CPort 1
	[cport-descriptor 1]
	bundle = 1
	protocol = 0x18

	; (Optional) Firmware Download Protocol on CPort 2
	[cport-descriptor 2]
	bundle = 1
	protocol = 0x17

	; (Optional) SPI protocol on CPort 3
	[cport-descriptor 3]
	bundle = 1
	protocol = 0x0b

	; (Optional) Component Authentication Protocol (CAP) on CPort 4
	[cport-descriptor 4]
	bundle = 1
	protocol = 0xXX //TBD

This patch adds the basic firmware-management bundle driver, which just
creates a firmware-management connection. Support for individual
protocols will be added separately.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-27 11:10:44 -07:00
Vaibhav Agarwal 05ab5f0daa greybus: audio: Identify jack type based on attributes reported
Originally, idea was to use widget_type to identify jack_type.
However, suggestive way is to identify jack based on jack
attributes.

Changes already exists in codec FW to report jack attributes.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 18:02:57 -07:00
Vaibhav Agarwal 475f498bce greybus: audio: Rename widget_type to jack_attrubute
This fields actually populates jack attribute. Thus, renamed to
reflect the real purpose.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 18:02:57 -07:00
Vaibhav Agarwal 54e9070b24 greybus: audio: Reorder gb_deactivate sequence to avoid protocol error
gb_activate_tx/rx is triggered from _prepare() & gb_deactivate
from shutdown(). This may cause protocol error in case shutdown
executes without _prepare due to some hw_params failure.

Also, reorganise _prepare & _shutdown calls to make it more
readable & cleaner.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 17:37:10 -07:00
Vaibhav Agarwal 2b8c2b5100 greybus: audio: Changes in response to ASoC cleanup
Update Makefile in response to SND_SOC_DYNAMIC_DAILINK cflag
removal.

Update files for msm-dynamic-dailink.h header file removal.

Update in response to API name changes. Also, acquire sound card
controls_rwsem before adding kcontrols to avoid deadlock.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 17:37:10 -07:00
Viresh Kumar dc0f0285f8 greybus: Bundle: Initialize dma_mask for bundle device
We missed this only for bundle device, fix it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 15:14:28 -07:00
David Lin 9983ea6b76 greybus: svc: free pwrmon_rails memory upon exit
For every time SVC instance is created, memories for storing the rail IDs
are allocated, however, they are not freed when the SVC is destroyed.
This patch fixes the memory leak by freeing the memory when debugfs for
SVC is no longer needed.

Testing Done:
- Check pwrmon debugfs after turning on and off SVC

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:13:59 -07:00
David Lin 3fd747a63e greybus: svc: clean up gb_svc struct for pwrmon
The power rail names and counts are unnecessarily stored in the gb_svc
structure once the SVC created, this causes waste of memory usage. This
patch removes rail names and rail counts storage from th gb_svc
structure.

Testing Done:
- Validated the readings from /d/greybus/1-svc/pwrmon/*

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:13:59 -07:00
Johan Hovold b482b0d6f0 greybus: svc: implement interface mailbox event
Implement the new interface mailbox-event operation.

The event is sent by the SVC under certain conditions when an interface
updates its mailbox value. Specifically, this event will be used to
implement the new mode-switch functionality.

Upon reception the AP verifies that the interface is known and that the
mailbox has the expected MAILBOX_GREYBUS value. If so, the interface is
disabled before being re-enabled (re-enumerated).

Note that during mode-switch, the interface will typically already be in
a disabled state when the mailbox is written (with the ES3 bootrom being
the notable exception).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold 22bb9380d6 greybus: svc: implement module inserted and removed operations
Implement the new module inserted and removed operations.

The SVC sends these after detecting a module insertion or removal, and
in the former case after having determined the module geometry (i.e.
position and size).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold ec562f28a7 greybus: interface: implement interface activation and power down
Implement the interface activation and power-down sequences.

Note that all the required SVC operations have not yet been implemented
so some stub functions are used for now.

Support for hibernating the UniPro link depends on future
power-management work so a stub function is used also for this.

Interface type handling will be refined later.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold 1e8e22b5cb greybus: svc: add stub interface-activate function
Add message structures (based on the current spec) for the SVC Interface
Activate operation, and a stub function that always return the Greybus
interface type.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold 017482b28d greybus: svc: add stub functions for v_sys, refclk and unipro
Add stub functions for v_sys, refclk and unipro resource management.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold 1e1565e5fe greybus: interface: add active state flag
Add active state flag to avoid deactivating an interface which is
already off.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold 36602a2981 greybus: module: implement controlled module removal
Implement controlled module removal through a new module attribute
"eject".

When a non-zero argument is written to the attribute, all interfaces of
the module are disabled (e.g. bundles are deregistered) and deactivated
(e.g. powered off) before instructing the SVC to physically eject the
module.

Note that the module device is not deregistered until the SVC has
reported the physical removal of all of its interfaces.

A new interface mutex is added to enforce interface state-change
serialisation.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold b15d97d770 greybus: core: add module abstraction
Add Greybus module abstraction that will be used to implement controlled
module removal (eject) and represent module geometry.

Greybus module devices correspond to physical modules and have one or
more interfaces. Modules have an id that is identical to the id of their
primary interface, which in turn is the interface with lowest numbered
id. The module name is constructed from the bus and module id:

        <bus_id>-<module_id>

Interfaces, bundles, and control devices are consequently renamed as

        <bus_id>-<module_id>.<interface_id>
        <bus_id>-<module_id>.<interface_id>.<bundle_id>
        <bus_id>-<module_id>.<interface_id>.ctrl

As before, interface ids (and therefore in a sense now also module ids)
correspond to physical interface positions on the frame.

Modules have the following attributes:

        module_id
        num_interfaces

where module_id is the id of the module and num_interface the number of
interfaces the module has.

Note that until SVC module-size detection has been implemented, all
interfaces are considered to be part of 1x2 modules. Specifically, the
two interfaces of a 2x2 module will be presented as two 1x2 modules for
now.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold 844fcbfeb6 greybus: svc: refactor interface re-enable
Add interface re-enable helper that is used during mode switch to
disable and re-enable (enumerate) an interface.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold deba0c03e9 greybus: Documentation/sysfs: sort entries alphabetically
The attribute entries have been kept mostly sorted within each device
type. Let's move the three more-recently added interface attributes
that were not.

Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold 4ff80a59ac greybus: Documentation/sysfs: add entry for control device
Add an entry for the recently added interface control device.

Also move the bundle-device entry below the control-device entries.

Reported-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold 12185197ea greybus: svc: use a common prefix for debugfs functions
Use the common gb_svc functions also for the recently added svc
functions. Having a common prefix clearly signals where the code
resides, something which improves readability and helps during
debugging (e.g. stack traces).

Note that all functions in svc.c except for these three use the common
prefix with the exception of the pwr_debugfs callbacks (that still use
*a* common prefix) and the attribute accessors (than can not have a
common prefix due to some macro magic).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Vaibhav Agarwal d7ed7cbfe6 greybus: audio: acquire wakelock during active playback
This change was missed while merging original patch
commit-id: 53c765c33f4a69c31027ec012e717d303bd4feca
Thus submitting it again.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 10:09:45 -07:00
Viresh Kumar 7b62b61c75 greybus: arche-ctrl: Don't expose driver internals to arche-platform driver
We have chosen the *ugly* way of registering two platform drivers from
the module_init() of only one of them, so that we can avoid having two
separate modules for them.

But we should still be doing this in a sane way. There is no need to
expose internals of arche-ctrl to arche-platform, like PM-ops, probe,
resume, id-table, etc. Just expose an init and a exit callback.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-23 09:37:21 +09:00
Vaibhav Agarwal f2bf63a365 greybus: audio: acquire wakelock during active playback
use pm_stay_awake & pm_relax to avoid suspend sequence during
active playback

testing Done:
Music Playback ongoing
$ cat /sys/devices/soc.0/qcom,ara-codec.82/power/wakeup_active
1
Music Playback stopped
$ cat /sys/devices/soc.0/qcom,ara-codec.82/power/wakeup_active
0

Tested-by: David Lin <dtwlin@google.com>
Reviewed-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Akash Choudhari <akashtc@google.com>
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
2016-04-22 11:29:21 -07:00
Johan Hovold f35fdb2fbd greybus: svc: fix function-parameter indentation
We really shouldn't be passing response structures around this way, but
since we now are, let's at least make sure not to break the 80 col
limit.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 20:19:33 +09:00
Johan Hovold 5b35ef95ef greybus: svc: fix pwrmon return value
Errno -ENOSYS is reserved for missing syscalls, replace it with ENOMSG.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 20:19:33 +09:00
Johan Hovold 89f2df438b greybus: svc: keep error messages uniform
All SVC error messages, except for a few recently added ones, place the
errno last after a colon (:). Let's at least try to be consistent
within the svc code.

Note that this format also allows for more concise messages without risk
for ambiguity.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 20:19:33 +09:00
Viresh Kumar 2437f1c6b5 greybus: es2: move ap_disconnect() below ap_probe()
This makes it more readable, as the functions are present in this order
in the structure as well. Also keeping these two makes more sense.

Tested by removing the gb-es2.ko module on both EVT1.5 and qemu with
gbsim.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 16:11:15 +09:00
Viresh Kumar 62de6e0a72 greybus: es2: don't protest when getting -ENOENT/ESHUTDOWN USB errors
-ENOENT or -ESHUTDOWN happens when the urbs are being killed from
->disconnect() callback.  Don't complain to userspace about this, as the
user will see this on es2 module removal.

Tested by removing the gb-es2.ko module on both EVT1.5 and qemu with
gbsim. The driver doesn't throw anymore errors like:
"urb cport in error -2 (dropped)".

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 16:11:15 +09:00
Viresh Kumar ecdd3a2d59 greybus: es2: disable cport-in after remove greybus host device
This allows greybus to do operations before being removed.

Tested by removing the gb-es2.ko module on both EVT1.5 and qemu with
gbsim. The driver removes the greybus host device successfully before
disabling the urbs. The errors are still coming ("urb cport in error -2
(dropped)"), but with an error value -2 (ENOENT) instead of -108. And
that happens while the urbs are disabled, not while doing greybus
operations.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 16:11:15 +09:00
Viresh Kumar a0f997bd5d greybus: es2: Allow proper release of greybus host device
The usb core disables the Interface prior to calling ->disconnect() for
the usb driver. That disallows the es2 driver to remove the greybus host
device and every entity below it in a clean way, as the greybus core may
want to do few operations over the usb connection before getting
removed.

And so we see bunch of errors while we remove the es2 module, like:
"urb cport in error -108 (dropped)"

The usb core has a special per-driver flag, 'soft_unbind', for such usb
drivers. If this flag is set by a driver, the usb core doesn't disable
the Interface prior to calling ->disconnect().

Set that flag for es2.

Tested by removing the gb-es2.ko module on both EVT1.5 and qemu with
gbsim. The interface isn't disabled by the core and the driver is still
able initiate greybus operations over the Interface. This can be
properly tested only after the next patch which removes the greybus host
device before disabling the urbs.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 16:11:15 +09:00
Viresh Kumar 36460e8a89 greybus: audio-codec: Staticize few routines to fix build warnings
This fixes below warnings ..

greybus/audio_codec.c:20:32: warning: symbol 'find_data' was not declared. Should it be static?
greybus/audio_codec.c:955:6: warning: symbol 'gbaudio_codec_cleanup' was not declared. Should it be static?

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 11:44:44 +09:00
Viresh Kumar de86e251f8 greybus: bootrom: fix typo
s/Firware/Firmware

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 11:43:35 +09:00
Evgeniy Borisov 698bdcbf87 greybus: camera-gb: Remove hardcode for CSI TX number of lanes
The number of CSI TX lanes is hardcoded to 4. Removing
this and start using value from configure stream response.

NOTE: The patch depends on the CSI init change:
"Use GB CSI params to init camera sub-devs"

Signed-off-by: Evgeniy Borisov <eborisov@mm-sol.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 11:19:28 +09:00
David Lin 9504677c9a greybus: svc: add AP power measurements debugfs support
This change adds the AP Power Monitor functions to
read out all the rails power information monitored by
the SVC.

Testing Done:
- $ cat /d/greybus/1-svc/pwrmon/*/*
  and validate the output with the svc stub power
  monitor functions
- $ tree /d/greybus/1-svc/pwrmon
  | | | |---pwrmon
  | | | | |---DUMMY_RAIL_1
  | | | | | |---current_now
  | | | | | |---power_now
  | | | | | |---voltage_now
  | | | | |---DUMMY_RAIL_2
  | | | | | |---current_now
  | | | | | |---power_now
  | | | | | |---voltage_now
  | | | | |---DUMMY_RAIL_3
  | | | | | |---current_now
  | | | | | |---power_now
  | | | | | |---voltage_now
  | | | | |---DUMMY_RAIL_4
  | | | | | |---current_now
  | | | | | |---power_now
  | | | | | |---voltage_now

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:50:56 +09:00
David Lin 05a849191f greybus: es2: Fix apb_log null pointer exception
Read on apb_log causes null pointer exception due to the missing es2
device pointer passing to the debugfs.

Testing done:
- Enable apb_log and cat it

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:41:08 +09:00
Axel Haslam b4b1b7eda9 greybus: uart: Update line coding settings only when needed
The check for line coding changed should use memcmp and not memcpy.

Testing done: trivial

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:33:47 +09:00
Johan Hovold 41d514020f greybus: svc: remove interface-remove helper
Remove unnecessary interface-remove helper.

Also add comment about why the disconnected flag is set.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:09:03 +09:00
Johan Hovold 96fb6c340b greybus: svc: keep interfaces registered during mode switch
Keep a detected interface registered until it is physically removed.
Specifically, do not re-register an interface that is switching mode.

Note that this also allows us to get rid of some nasty hacks from core.
The Ara VID/PID bootrom hack for ES2 will continue to work, but is now
mostly confined to the bootrom driver.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:09:03 +09:00
Johan Hovold 87a4c819a5 greybus: svc: make sure to deactivate all interfaces on disconnect
Make sure to deactivate all interfaces when the svc is going away.

This is needed to eventually be able to do controlled teardown of the
unipro network.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:09:03 +09:00
Johan Hovold 49605839bc greybus: interface: reduce control-device lifetime
Make the control-device lifetime coincide with when the interface is
enabled (enumerated).

This is needed to be able register a new control device after a mode
switch.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:09:03 +09:00
Johan Hovold b6147e4fb1 greybus: control: return error pointer when failing to create control device
Return an error pointer when failing to create a control device.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:09:03 +09:00
Johan Hovold 7c8eb12dbb greybus: interface: move vendor and product strings to control device
The control device is an abstraction of the control connection over
which a greybus manifest is retrieved. As interfaces switch modes (e.g.
after boot-over-unipro) they expose new manifests, which can contain
different vendor and product strings.

Eventually control devices will be deregistered and recreated after an
interface mode switch, while the interface itself remains registered.

Note that only interfaces of type greybus will have control devices.
Specifically, dummy interfaces will not.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:09:03 +09:00
Johan Hovold 7326e07b58 greybus: interface: register control device at hotplug
Make sure to register also the control device along with any bundles
when registering an interface.

Note that we currently ignore failures to register the control device
just as we do for bundle devices.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:06:00 +09:00
Johan Hovold a6e5b014b8 greybus: core: make the control object be a device
Make the control object be a greybus device.

The control device will be used to expose attributes specific to
greybus-type interfaces.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:06:00 +09:00
Johan Hovold 1ed8cdef40 greybus: control: move timesync-operation functions
Move the timesync-operation functions above the control-object
management functions, which is where all other operation implementations
reside.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:06:00 +09:00
Johan Hovold a530a8be39 greybus: interface: disable interface on registration failures
Disable and deactivate an interface immediately on registration
failures.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:06:00 +09:00
Johan Hovold 078ef067bc greybus: Documentation/sysfs: add example control devices
Add control devices to the example sysfs tree.

Control devices are named

	<bus_id>-<module_id>.<intf_id>.ctrl

and expose attributes that are specific to the greybus interface type.
Specifically, dummy interfaces do not have a control device.

Currently, only the vendor and product strings extracted from the
manifest are exported.

A subtree of the example tree now looks as follows:

greybus1/
├── 1-5
│   ├── 1-5.5
│   │   ├── 1-5.5.2
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   └── state
│   │   ├── 1-5.5.ctrl
│   │   │   ├── product_string
│   │   │   └── vendor_string
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   └── vendor_id
│   ├── 1-5.6
│   │   └── interface_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
└── 1-svc

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:03:13 +09:00
Johan Hovold 9e5e6fa6bf greybus: Documentation/sysfs: rename the svc eject attribute
The svc eject attribute was added as an interim solution and is still
used to implement a form of forced ejection.

This will soon be superseded by the module eject attribute, which will
provide an interface for clean eject. We may keep the forced-eject
mechanism around indefinitely, albeit possibly with a different name
(e.g. forced_intf_eject). Either way, update the example tree to reflect
the actual name, intf_eject, which currently used for this svc attribute.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:03:13 +09:00
Johan Hovold 78b609b14c greybus: Documentation/sysfs: remove interface unique_id attribute
Remove the interface unique_id attribute, which there is currently no
plan to ever implement.

Note that the Ara serial numbers are already exposed through the
serial_number attribute.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:03:13 +09:00
Johan Hovold aba2fc626e greybus: Documentation: move the interface power attributes
Move the interface power attributes after the other interface attributes
to keep the attributes grouped by device type.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:03:13 +09:00
Johan Hovold 7d963cbe83 greybus: manifest: fix illegal free in error path
The manifest-parsing code could end up leaving the interface
vendor_string set to an error pointer that we'd eventually try to free
when destroying the interface.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:03:13 +09:00