driver_name associated with dev_name was hard coded earlier.
This limits, audio codec module to be detected on Port#5 only.
Now, driver_name is generated dynamically based on dev_name.
This enables codec module detection on any 1x2 slot.
Also, Update dev_id based on slot number, instead of bundle->id.
bundle->id is not unique for multiple modules added, thus now
using slot number for unique identification.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We need to clean up GB protocl connections, otherwise successive
codec insertions fails repeatedly.
NOTE: As per suggestion, since codec is already removed, one should
not trigger any GB command. It'll cause a delay of atleast TIMEOUT
value.
HOwever, failing to cleanup GB protocol, causes successive module
insertion to fail
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Replace unnecessary dev_err msg with dev_dbg.
Same were added during development to trace topology
parser progress.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
GB-Audio-manager module is currently used to report uevent
to above layer in response to any codec module inserted or
removed.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
GB Audio class driver provides APIs to configure GB codec module.
This patch adds relevant operations in DAI ops callback functions to
configure codec module as per DAPM sequence triggered.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
For each GB codec module inserted, DAPM widgets, kcontrols, routes
and DAIs can be fetched through greybus in a binary chunk and parsed
locally to create & populate DAPM graph for the specific module.
It is required by each codec module to populate a minimum set of
kcontrols with fixed names to support basic audio usecase.
To support advanced features of codec module, the same can be polpulated
with existing topology parser. However, to use them for different usecase
separate mechanism (may be via MSP) is required to inform userspace about
their configuration value & enable/disable sequence.
ToDos:
Currently, support for enumerated kcontrol/dapm control is hardcoded.
Need to add complete logic within the parser.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Use GB Audio mgmt, data protocol ids to register codec module with
GB protocol. And in response to mgmt->connection_init(), register
GB codec driver with ASoC.
Now, using msm8994 machine to register DAI link dynamically on
codec insertion.
ToDos:
- snd_soc_register_codec() uses driver->name to identify device id.
However, for GB device, .driver{} is not yet populated by GB core.
Thus, defining dummy structure within codec driver. This should
come from GB core itself.
Even existing .driver{} may cause problem in case of multiple
modules inserted or inserted at a different slot.
- Fix logic for gbcodec->dais & gbcodec->dailinks. Current
implementation contains some hard coded data with assumption of
count=1.
- Evaluate definition of 'gbaudio_dailink.be_id' in case of multiple
DAI links.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We really only want to build the module if the config is set, not all
the time like the current code does.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Added CONFIG_XXX flag check before compiling audio module.
Once we add dynamic DAI link registration from audio driver,
this check wil be required to avoid compilation failures with
other kernel revisions.
Also, renamed header file to better align with .c file name.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This is a simple module that keeps a list of connected GB audio
modules.
Whenever a device is attached, an appropriate uevent is sent to
userspace:
UDEV [4941.803215] add /kernel/gb_audio_manager/0 (gb_audio_manager)
ACTION=add
CPORT=99
DEVICES=0x10
DEVPATH=/kernel/gb_audio_manager/0
NAME=naim
PID=64
SEQNUM=1828
SLOT=2
SUBSYSTEM=gb_audio_manager
USEC_INITIALIZED=802416
VID=128
And whenever removed:
UDEV [4941.836588] remove /kernel/gb_audio_manager/0 (gb_audio_manager)
ACTION=remove
DEVPATH=/kernel/gb_audio_manager/0
SEQNUM=1833
SUBSYSTEM=gb_audio_manager
USEC_INITIALIZED=835681
The API consists of functions for adding, removing and inspecting
added device module descriptions (struct gb_audio_module):
int gb_audio_manager_add(struct gb_audio_module_descriptor *desc);
int gb_audio_manager_remove(int id);
int gb_audio_manager_remove_all(void);
struct gb_audio_module* gb_audio_manager_get_module(int id);
void gb_audio_manager_put_module(struct gb_audio_module *module);
int gb_audio_manager_dump_module(int id);
void gb_audio_manager_dump_all(void);
Devices can be inspected through sysfs in /sys/kernel/gb_audio_manager/{id}/*
If GB_AUDIO_MANAGER_SYSFS is exported as 'true', managing devices can be done
via the SYSFS as well. For instance:
echo name=naim slot=2 vid=128 pid=64 cport=99 devices=0x10 > /sys/kernel/gb_audio_manager/add
echo all > /sys/kernel/gb_audio_manager/dump
echo 2 > /sys/kernel/gb_audio_manager/dump
echo 2 > /sys/kernel/gb_audio_manager/remove
Signed-off-by: Svetlin Ankov <ankov_svetlin@projectara.com>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The latest audio architecture does not stream audio data over the
USB link between the AP and APBridgeA. Instead, audio data is
streamed directly over the I2S link between the two.
To support the Greybus audio driver in setting up the I2S port and
controling packeting/depacketizing of audio data to/from Greybus
audio messages, define a set of commands and their parameters.
These commands and parameters will be placed into a request and sent
over the USB control channel to APBridgeA. A corresponding driver
on APBridgeA will receive and process the requests.
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add helper routines to make communicating with audio modules easier.
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add the macros and structures for the Greybus Audio Device
Class Protocol.
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
For consistency with most other files in the Greybus repository,
change 'audio-codec.c' to use an underscore instead of a hyphen
in its name.
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
It makes more sense to enable the clock after power is enabled
to the device, so move clock enable code after regulator_enable
and setting up BOOT_RET pin.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Tested-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This change implements gb camera interface and register
gb camera to the HOST driver.
This implementation need to be reworked after the demo.
Tested with db3 with two camera modules.
Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Gb camera need to communicate with HOST driver.
as temporary solution there will be shared header
between gb camera HOST camera.
Both need to be in sync since gb drivers are compiled
out of the kernel tree.
Gb camera register camera operation functions when is created.
Currently unregister is not supported.
Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
In kernel v4.5 there is a change in LED api, which remove the need for
individual work queue and rename the set_sync operation to set_blocking.
This patch add the handling of this case and avoid compilation failure
for this kernel versions.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
In v4.5 the LED API is changed related to the set brightness
operations, set_sync is removed and the workqueue handling is now done
by leds core, so no need for individual drivers to have one.
This will be done by removing the SET_SYNC macro and add a new
SET_BLOCKING.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This adds the GREYBUS_ID environment variable to all interface uevents
to let userspace know the vendor/product id of the module interface that
has been added or removed from the system.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
To support key events coming from the svc (ara key) it is needed to add
the input core as an required config option.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Refactor connection enable and disable.
This is a step towards removing the legacy-protocol handling from core.
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>
Set connection state to ENABLE before sending the control connected
message, and set state DISABLE after sending the control disconnected
event.
Remove the now unused ERROR connection state.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add a new write-only svc attribute to send an eject request to the svc
giving the interface number.
So, doing:
echo 3 > /sys/bus/greybus/devices/1-svc/intf_eject
will force eject the module on interface 3 (module slot 1 on EVT1).
This can take some seconds as the pulse width for module release is
large.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Add a new svc operation which will be used to send a request to eject a
given interface.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
The correct check for if the power supply is ready to receive event is
wrong and it should check for the registered flag.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This moves all of the APBridge request protocol commands that are
currently used to a common .h file for everyone to be able to use them
in the future, where needed.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Tested-by: Mark Greer <mgreer@animalcreek.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Provide a new function, gb_hd_output() to send data to the apbridge.
This is useful for the camera and audio drivers that need to do this
type of messaging.
The camera driver is converted to use this new function, the audio
driver can use it when it gets merged later.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Tested-by: Mark Greer <mgreer@animalcreek.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Individual power supply were being freed and checked using the wrong
pointers and at the wrong place, which would make several issues, like
used after free and so on.
Fix it by freeing all allocated memory after release individual power
supply.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
When fetching string properties, memory was being allocated and leaked
when it was not necessary to do so.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
If something goes wrong at setup time for the supplies, we need to
release all the resources allocated already.
Call the supplies release function which will handle the correct
teardown of the supplies.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
After freeing each individual power_supply, free the top controller, if
not it will leak memory at each module insert/remove.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
If setup fail the release for each supply needs to know the status at
unregister time. So, add the field to the structure, update it at setup
time and use it at release.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
If allocation of memory for each supply fail, we should get out of
release any individual supply.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Make sure to release the supplies_lock before returning on errors in
gb_power_supplies_setup().
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add wake_detect support to arche-platform driver which is responsible
for SVC control. This patch also adds code for handshaking between
AP <=> SVC. The sequence is,
1. AP boots
To keep compatibility between DB3 and EVT platform, SVC will be
help in reset and AP driver would release it at appropriate time.
wake/detect pin (WD8A) = Low
reset (SVC/APB1/APB2) = Asserted (as per polarity)
2. AP Driver gets inserted
2.1. AP will deassert reset to SVC (following power on sequence)
2.2. SVC allows 360 milliseconds to elapse after switch boots to work
around bug described in ENG-330.
2.3. AP asserts wake/detect pin (WD8A = HIGH)
3. SVC detects assertion of wake/detect pin, and sends "wake out" signal to AP
4. AP receives "wake out" signal, takes AP Bridges through their power
on reset sequence as defined in the bridge ASIC reference manuals
5. AP takes USB3613 through its power on reset sequence
6. AP should enumerates AP Bridges
Note: ISR has been deliberately removed (not merged) as we are still
not sure how it will be used, in runtime usage context. Driver as such
doesn't do anything for runtime assert-n-deassert of reset to SVC/APB's,
it just simply offloads it to user by exporting required gpio's.
The exported gpio's are required for FW flashing from user space.
When it comes to usersace manipulated control sequence, user has to manage.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Now the complete handshaking between AP<=>SVC would be
offloaded to parent driver (arche-platform) who is
responsible for SVC control, so the apb-ctrl driver can
just simply bring APB's out of reset during probe itself.
Along with deasserting reset, this patch renames the local fn
to exclusively use it for reset purpose.
Note that, driver is exporting reset gpio to
user, so user can still flash FW from prompt.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
With TIME_SYNC functionality, assignment of wake/detect pin
will change,
WD_8A => to bring APB's out of reset
WD_8B => TIME_SYNC operation
So in order to support this, we can no longer keep wake_detect
gpio in apb-ctrl driver. So remove it.
In the subsequent patches, wake_detect support will be added
to parent SVC driver (arche-platform) who is responsible for SVC control.
Note that, this patch also removes ISR related code.
The APB state still is maintained, for future use.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This removes few unwanted headers related to irq, interrupt, regulator,
spinlock, etc.
Also arrange the rest in alphabetical order to make it more readable.
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>
wake_detect_gpio and resetn_gpio are guaranteed to be valid in
apb_ctrl_cleanup() and irq-handler, no need to check for their validity.
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>
Relying on apb_ctrl_cleanup() to do the cleanup for errors that occurred
within apb_ctrl_init_seq() isn't a very clean idea. Handle that
separately within apb_ctrl_init_seq().
This will clean apb_ctrl_cleanup() in later patches.
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>
If devm_gpio_request() returns an error, we shouldn't try to set the
direction of the same gpio.
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>
Use dev_err for errors after which we need to abort the currently
running routine and dev_warn for resource allocation failure, with which
we can continue to work.
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>
Since NULL could in theory be a valid regulator we ought to check for
IS_ERR() rather than for NULL. In practice this is unlikely to be an
issue but it's better for neatness.
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>
And so we don't need to check for it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
There can be no invalid values in the DTS. The actual pin numbers are
assigned by gpiolib when the gpio controller is registered.
And so a simple 'gpio < 0' is enough instead of gpio_is_valid() which
also checks for 'gpio < ARCH_NR_GPIOS'.
This will make the usage of of_get_named_gpio() similar with how it is
done in arche-platform driver.
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>
Platform data 'apb' is guaranteed to be valid in arche_apb_ctrl_remove()
and so no need to check it.
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>
- s/premits/permits
- Remove blank lines at the end of the file
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>
svc_reset_gpio is guaranteed to be valid in arche_platform_cleanup. Drop
the useless check.
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>