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:
This patch adds the basic firmware-management bundle driver, which just
creates a firmware-management connection. Support for individual
protocols will be added separately.
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.
David Lin [Sat, 23 Apr 2016 02:03:43 +0000 (19:03 -0700)]
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>
David Lin [Sat, 23 Apr 2016 02:03:42 +0000 (19:03 -0700)]
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>
Johan Hovold [Sat, 23 Apr 2016 16:47:31 +0000 (18:47 +0200)]
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>
Johan Hovold [Sat, 23 Apr 2016 16:47:30 +0000 (18:47 +0200)]
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>
Johan Hovold [Sat, 23 Apr 2016 16:47:28 +0000 (18:47 +0200)]
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>
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>
Johan Hovold [Sat, 23 Apr 2016 16:47:24 +0000 (18:47 +0200)]
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
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>
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.
Johan Hovold [Sat, 23 Apr 2016 16:47:20 +0000 (18:47 +0200)]
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>
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.
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>
Johan Hovold [Thu, 21 Apr 2016 09:43:36 +0000 (11:43 +0200)]
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.
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>
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>
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.
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?
Johan Hovold [Wed, 13 Apr 2016 17:19:08 +0000 (19:19 +0200)]
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.
Johan Hovold [Wed, 13 Apr 2016 17:19:04 +0000 (19:19 +0200)]
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.
Johan Hovold [Wed, 13 Apr 2016 17:18:59 +0000 (19:18 +0200)]
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
Johan Hovold [Wed, 13 Apr 2016 17:18:58 +0000 (19:18 +0200)]
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.
Johan Hovold [Wed, 13 Apr 2016 17:18:55 +0000 (19:18 +0200)]
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.
When transfer speed is too slow (less than 17Khz) the operation can take
longer than the default greybus timeout. Because of this we need to use
the request_send_sync_timeout and calculate the correct timeout for each
operation.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Tested-by: Philip Yang <philipy@bsquare.com> Tested-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The actual implementation of transfer_one_message have problems with
some cases in the possible transfer options. We try to maximize the
number of spi transfers in one greybus operation and need to save state
until the full message is dispatch over greybus.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Tested-by: Philip Yang <philipy@bsquare.com> Tested-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: Fixup __u64, __u32 to __le64, __le32 in timesync declarations
A number of data in TimeSync command structures are declared __u64/__u32
instead of __le64/__le32, I forgot to put this through an x86_64 compile
before presentation for merge and as a result didn't catch this error. This
patch fixes.
greybus: arche-platfrom: Get rid of 2sec delay in USB3613 configuration
Earlier during boot sequence implementation, we had seen race between
USb3613 and APB boot, and since APB boot time is ~2sec, we delayed
USb3613 configuration for 2sec after APB deassertion of reset.
This obviously won't work in the case of suspend/resume, where we would
like to put APB into OFF state and coldboot in resume.
With the latest FW changes, we do not see any race issue. I have done
regression testing (> 50 iteration of reboot + unipro link up and down)
without any issues.
So lets get rid of the 2sec delay with this patch.
Testing Done: Tested on EVT 1.5 platform.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Tested-by: David Lin <dtwlin@google.com> Reviewed-by: David Lin <dtwlin@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: camera-gb: Extend the configure streams interface
Extending the configure streams interface with CSI params.
Getting CSI frequency data form configure streams response.
* num_lanes - Number of CSI data lanes
* clk_freq - CSI clock frequency in Hz
* lines_per_second - Total number of lines in a second of
transmission (blanking included)
From the AP side we need to know for the CSI speed
configuration. This information is needed for dynamically
bandwidth calculations.
NOTE: Change should be along merged with corresponding
interface change in kernel:
"camera: Extend the configure streams
interface with CSI params"
Vaibhav Agarwal [Wed, 30 Mar 2016 07:53:56 +0000 (13:23 +0530)]
greybus: audio: Update device type based on widget types
Device type info shared to above HAL is currently hard coded
to SPK only. Actual device type is identifed while parsing
widget types from topology FW shared by codec module.
Vaibhav Agarwal [Wed, 30 Mar 2016 07:53:55 +0000 (13:23 +0530)]
greybus: audio_manager: Split device type into i/p & o/p devices
Currently, single field is used to report device type say SPK,
MIC, HS, HP, etc. However above HAL expects separate fields for
input & ouput device types.
greybus: checkpatch.pl: Mark --no-tree as default option
Don't know why, but checkpatch checks if we are running it from top of a
kernel tree or not, but then it also provides an option to suppress the
warning using --no-tree.
Instead of forcing everyone to use this every time, lets make this
behavior default.
Georgi Dobrev [Thu, 24 Mar 2016 11:37:21 +0000 (13:37 +0200)]
greybus: Added a sysfs entry to power down the SVC
Added a sysfs entry called pwr_off. When a "1" is passed to it,
it sends a GB_SVC_TYPE_PWR_DOWN command to the SVC, powering it down
along with the switch and INA231 chips.
Testing Done: Tested on EVT1_5, works.
Signed-off-by: Georgi Dobrev <dobrev_georgi@projectara.com>
For those who are stuck using old kernel trees, let's include the latest
version of checkpatch.pl into our tree to help prevent coding style
mistakes from creeping in.
Also add spelling.txt to catch spelling errors in comments.
Vaibhav Agarwal [Tue, 29 Mar 2016 11:02:36 +0000 (16:32 +0530)]
greybus: audio: Added jack support to audio module
Register jack with ASoC sound card in case audio module
populates it via codec FW. Currently, only a single jack
with 4 buttons can be registered for each module.
Johan Hovold [Tue, 29 Mar 2016 22:56:08 +0000 (18:56 -0400)]
greybus: interface: read DME attributes at activation
Read the DDBL1 and Ara DME attributes when activating an interface.
These values are currently provided by the SVC in the intf_hotplug
request, which is about to go away.
Note that there are currently no standard Ara VID and PID attributes and
that Toshiba uses attributes from the reserved space in ES3. For now, we
therefore refuse to enumerate any non-Toshiba bridges.
Also note that the Ara serial number is currently not supported.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Tue, 29 Mar 2016 22:56:04 +0000 (18:56 -0400)]
greybus: interface: move route creation to interface activation
Creating and destroying a route to an interface is arguably an interface
operation and belongs with the interface code.
Add new interface_activate and interface_deactivate helpers that will be
used to activate and deactivate an interface in the new interface boot
sequence.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Tue, 29 Mar 2016 22:56:03 +0000 (18:56 -0400)]
greybus: interface: clean up ES3-bootroom-quirk handling
Clean up handling of the ES3-bootrom quirks by adding an interface
quirk-flags field that is set appropriately when we detect that the ES3
bootrom is running.
Note that we need to reserve the DME_DIS_UNIPRO_BOOT_STARTED and
DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED status values for the ES3 bootrom,
which does not support any CPort features (unlike later boot stages).
Add a BOOTROM infix to the defines to make this more clear.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Agarwal [Tue, 29 Mar 2016 18:01:41 +0000 (23:31 +0530)]
greybus: audio: Use single codec driver registration
We have single I2S port via APB1 for communication with all
audio modules. Thus, we should register single codec driver
and manage all individual audio modules internally within
this driver.
greybus: convert drivers to use connection->private set/get
This converts all drivers to use the gb_connection_get_data() and
gb_connection_set_data() functions to make it a bit more explicit as to
what is going on.
Registering more then one module at same time was not
possible with previous implementation. Also unregistering
of the module was missing leading to many instability issues
when camera module is ejected when camera is still active.