gb_phy runtime functions use struct gbphy_device *gbphy_dev,
and not struct device. When CONFIG_PM_RUNTIME is not enabled
a compile error will show.
Fix this by passing struct gbphy_device * as parameter
Testing Done: compile with CONFIG_PM_RUNTIME disabled
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
If a gpio line is getting used for an irq, gpio core will create
/proc/irq/X/gpiolib/ directory for it. This directory gets removed while
the gpio controller is unregistered.
In case of greybus, gb_gpio_irqchip_add() creates an irqdomain and
creates irq mappings for the gpio lines. Currently they are added after
registering the gpio controller and removed before the gpio controller
is removed. On the removal path, while the core tries to remove the irq
directory (/proc/irq/X), it finds that the irq is still getting used and
a "gpiolib" directory is present within it and so it gives this warning:
Steps to reproduce:
$ cd /sys/class/gpio
$ echo X > export
$ echo both > gpioX/edge
$ echo <interface-number> > /sys/bus/greybus/devices/1-svc/intf_eject
[ 139.171436] ------------[ cut here ]------------
[ 139.171468] WARNING: at /home/vireshk/all/work/repos/ara/arche/kernel/arche/fs/proc/generic.c:552 remove_proc_entry+0x154/0x188()
[ 139.171476] remove_proc_entry: removing non-empty directory 'irq/683', leaking at least 'gpiolib'
[ 139.171589] Modules linked in: gb_vibrator(O) gb_usb(O) gb_uart(O) gb_spi(O) gb_sdio(O) gb_raw(O) gb_pwm(O) gb_power_supply(O) gb_loopback(O) gb_log(O) gb_light(O) gb_i2c(O) gb_hid(O) gb_gpio(O) gb_gbphy(O) gb_firmware(O) gb_spilib(O) gb_es2(O) gb_camera(O) gb_bootrom(O) gb_audio_module(O) gb_audio_manager(O) gb_audio_codec(O) gb_audio_gb(O) gb_audio_apbridgea(O) gb_arche(O) greybus(O)
[ 139.171605] CPU: 1 PID: 280 Comm: kworker/u16:4 Tainted: G W O 3.10.83-g9771b10cbeed #107
[ 139.171652] Workqueue: greybus1:svc gb_svc_intf_set_power_mode [greybus]
[ 139.171657] Call trace:
[ 139.171677] [<ffffffc000207b40>] dump_backtrace+0x0/0x268
[ 139.171689] [<ffffffc000207db8>] show_stack+0x10/0x1c
[ 139.171707] [<ffffffc000ccad78>] dump_stack+0x1c/0x28
[ 139.171723] [<ffffffc00021f9dc>] warn_slowpath_common+0x74/0x9c
[ 139.171735] [<ffffffc00021fa60>] warn_slowpath_fmt+0x5c/0x80
[ 139.171747] [<ffffffc00035fa38>] remove_proc_entry+0x150/0x188
[ 139.171763] [<ffffffc00027464c>] unregister_irq_proc+0xb4/0xdc
[ 139.171779] [<ffffffc00026e3f4>] free_desc+0x2c/0x70
[ 139.171791] [<ffffffc00026e48c>] irq_free_descs+0x54/0x9c
[ 139.171802] [<ffffffc000273448>] irq_dispose_mapping+0x54/0x64
[ 139.171814] [<ffffffbffc0621e8>] 0xffffffbffc0621e8
[ 139.171825] [<ffffffbffc05e01c>] 0xffffffbffc05e01c
[ 139.171843] [<ffffffc0005d4e30>] __device_release_driver+0x90/0xe4
[ 139.171854] [<ffffffc0005d4ea4>] device_release_driver+0x20/0x38
[ 139.171867] [<ffffffc0005d4634>] bus_remove_device+0x12c/0x148
[ 139.171878] [<ffffffc0005d1cb0>] device_del+0x108/0x16c
[ 139.171888] [<ffffffc0005d1d64>] device_unregister+0x50/0x68
[ 139.171901] [<ffffffbffc05e2bc>] gb_gbphy_deregister_driver+0xf0/0x4ec [gb_gbphy]
[ 139.171924] [<ffffffbffc0014c4>] greybus_disabled+0x14c4/0x1760 [greybus]
[ 139.171936] [<ffffffc0005d4e30>] __device_release_driver+0x90/0xe4
[ 139.171948] [<ffffffc0005d4ea4>] device_release_driver+0x20/0x38
[ 139.171959] [<ffffffc0005d4634>] bus_remove_device+0x12c/0x148
[ 139.171969] [<ffffffc0005d1cb0>] device_del+0x108/0x16c
[ 139.171992] [<ffffffbffc004cec>] gb_bundle_destroy+0x7c/0x1b0 [greybus]
[ 139.172017] [<ffffffbffc004074>] gb_interface_disable+0xb4/0x178 [greybus]
[ 139.172040] [<ffffffbffc002ae4>] gb_module_del+0x5c/0xf8 [greybus]
[ 139.172063] [<ffffffbffc008418>] gb_svc_intf_set_power_mode+0xea0/0xfe8 [greybus]
[ 139.172078] [<ffffffc00023888c>] process_one_work+0x268/0x3c8
[ 139.172089] [<ffffffc000239a64>] worker_thread+0x204/0x358
[ 139.172108] [<ffffffc00023f43c>] kthread+0xb8/0xc4
[ 139.172114] ---[ end trace 6fa3314e8c6157ca ]---
Also note that registering the gpio controller before creating irqdomain
is incorrect as well and may lead to kernel panic, as a gpio may get
requested as an interrupt source right after the controller is
registered, and the greybus gpio driver wouldn't be fully ready by then.
This patch changes the sequence in both probe() and remove() to fix it.
Fixes: 426e88a47d39 ("greybus: gpio: add interrupt handling support")
Reported-by: David Hsu <davidhsu@google.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Properly report which endpoints are being ignored and which ones are
"unknown" to the driver.
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
usb_kill_urb() and usb_free_urb() can be called with NULL pointers, so
no need to check before calling them.
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We don't need the defines for the number of bulk in or out endpoints
anymore, as the driver just grabs the first ones it finds and runs with
it.
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We only care about one bulk IN endpoint for cports, and one for ARPC, so
drop the array of bulk IN endpoints to simplify things.
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We only care about one bulk out endpoint, the first one, so remove
the pretense of keeping an array of these things. Just grab the first
one in the list and run away!
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We were not really using this structure at all, it was only returning
'0' when asked what cport matched to what pair, so remove it all.
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
These functions were never used, and we are about to remove the
structures it was trying to reference, so let's remove it to get it out
of the way.
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This matches a corresponding firmware change to declare a single
BULK EP pair for all greybus traffic and 1 BULK IN ep for ARPC.
Thus, avoiding URB submittions for all the other unused BULK IN
endpoints on the HOST side that took considerable amount
of bus time.
Testing Done:
Tested with modified AP<->APB1 loopback test and also with GPBridge
modules to ensure there are no regressions
Signed-off-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Remove the deprecated svc key-event type, which has already been removed
from the specification.
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>
Modify Power_supply greybus driver to support runtime PM framework.
During charging state, the driver will block remote device of suspending,
and then enables runtime suspend when remote device is in none chargin
state.
Testing Done: Compiled and verified on EVT2, EVT2 1x2 GPB test module
and Device class daughter board.
Signed-off-by: Philip Yang <yang_philip@projectara.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Now jack-button are registered to snd framework based on capabilities
populated by codec module's topology data. Thus, valid ids for button
events can also vary for different modules. This patch modifies existing
button reporting mechanism to avoid reporting spurious button events for
invalid button ids.
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>
Now jack & jack-buttons are registered to snd_jack framework based on
the capability shared by module's topology data. Thus, jack events
should be reported to above snd framework only in case corresponding
jack type is registered. This patch adds additional checks to avoid
reporting fake jack events.
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>
Added extra fields namely jack_mask & button_mask for each module_info.
These fields are required while registering jack & reporting jack
events.
Earlier, these were hard coded values assuming fixed capabilities say
HEADSET, LINEOUT, etc. supported by GB-codec driver. Now these are
computed dynamically based on module's jack capability shared via
topology data.
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>
This patch adds extra field jack_type to gb_audio_topology struct. Also,
it defines bit fields to be used by module while defining it's jack and
jack-button capabilities.
Currently, module can populate a single jack and associated buttons. In
case multiple jacks are supported data routing (say duplicating, etc.)
should be handled within module's FW. It can populate additional mixer
controls to do so.
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>
snd_jack will be registered based on real capabilities shared by
module's FW instead of parsing widgets and register it with fixed
capabilities. Remove module_info->num_jack, since it is no more
required.
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>
Make sure the timeout values are aligned.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Remove the now obsolete and redundant cport-reset ARPC, along with the
consequently unused cport_disable callback.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Remove the now obsolete ping and cport_features_enable/disable
callbacks.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Implement the new connection setup and tear-down sequences for control
connections and bundle connections (offloaded and non-offloaded).
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Implement the shutdown callback which is used to execute shutdown
operations on offloaded connections.
This adds a new shutdown ARPC.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Implement the flush callback which is called as part of connection tear
down to flush host-device queues and stop any ongoing transfers.
Note that this should be considered an optimisation of sort since if
the CPort is stuck waiting for credit, the CPort is likely still stuck
when we try to send the cport_shutdown request over it after the
callback returns.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We were checking for existing power supply names in the wrong place,
i.e, we were checking before any of the module power supply were
registered, because of that of course no name collision was detected.
Move the check to the register loop and with that we guarantee that this
mechanism works for greybus power supply naming.
Tested: using gbsim and using power supply with the same name and check
that: 1. no problems creating sysfs entries; 2. naming is done following
the desired rules.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
According to runtime pm architecture, the kernel side driver should be
as smart as needed to know when the module is idle or active, so that it can
issue the suspend/resume operations to the firmware side at the right time.
To add logics prevents AP from issuing the suspend request to the firmware
when a channel turning to active state, and put it to suspend if the state
is going to inactive with still holding a reference.
Testing Done: Compiled and verified on EVT2 and gpbridge-test module
with device class daughter board.
Signed-off-by: Kris Huang <huang_kris@projectara.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Fix incorrect attribute size when the channel supports fader, as well as
fixing the issue that the attribute list is not null terminated.
Testing Done:
- Verified by setting brightness and color on red/green/blue leds
of the device class test board.
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The direction value passed to gb_audio_apbridgea_register_cport()
in the gbaudio_module_enable_rx() routine is TX and not RX like
it should be so fix it.
Testing Done: Recorded microphone data from a headset.
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Fixes: c80e7c6fafa5 ("audio: Split helper APIs based on stream direction")
Tested-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewd-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The svc functions are only supposed to be called by core and should not
be exported.
Most of these functions should never have been exported in the first
place, while a few no longer needs to be (e.g. since core gained support
for offloaded connections).
The only remaining exception is gb_svc_intf_set_power_mode() which is
needed by the camera driver until proper link management is in place.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The svc functions are only supposed to be called by core and should not
be exported.
Most of these functions should never have been exported in the first
place, while a few no longer needs to be (e.g. since core gained support
for offloaded connections).
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
When we receive a update request we shall not trust the cache mechanism
and for that we need a way to invalidate the cache. Add a field that
will control the cache status and refactor the code to check if cache is
valid in a helper function.
This will fix the scenario where an update request is received within
the cache expiration time after a previous update as happened and would
be ignored.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We use the update interval to control the remove path and we set it to
zero when we do not want to have more updates in transit. That means
that the check in the request handler needs to be for interval update
zero to discard the newly received request and not the other way around
like it is.
This will fix the issue that all incoming requests were being discard.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
When checking for property changes we may need to act upon that change
besides reporting it using power_supply_changed. So, add a function that
will be call if the specific property changed.
As at it, adjust some indentation of the psy_props_changes array.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
While releasing memory during error path exit, invalid memory pointer
was used for dapm_routes. Use a valid one.
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>
While mapping control id to define DAPM routes, invalid control index
may cause kernel oops. Add extra check to validate index while mapping
names to control_id.
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>
In the beginning, module side can control the vibrator timeout value,
it can disable vibrator until timeout. But after Runtime PM control added
in, AP side didn't know when module can be suspended, the vibrator
task will be interrupted by suspending event.
Because of this problem, the module can not be in charge of counting down
the timeout value, it is now up to the AP to manage this. So add workqueue
to handle the vibrator timeout.
Signed-off-by: Ann Chen <chen_ann@projectara.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
In case a bulk-in transfer-buffer allocation failed during probe, we'd
currently leak the corresponding URB.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Remove support for module implementing legacy version of camera bandwidth
requirements specifications, now that all available camera modules have
been updated to use the new version
Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The firmware file name's maximum length is set to 56 right now, but it
isn't very much readable how we got to that value (unless someone reads
that line).
Update the comment to show calculations.
Reported-by: Alex Elder <alex.elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Replace 'should' with 'must' to clear the expectation a bit more.
Reported-by: Alex Elder <alex.elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder pointed out that the macros also count the trailing NULL
('\0') character and so it should be using SIZE instead of LEN.
This patch makes that change.
Reported-by: Alex Elder <alex.elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
s/shall be used the user/shall be used by the user/
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We already have another direct pointer for this, use that instead.
Testing Done: Compiled.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Make the control-protocol disconnecting operation a "core" operation.
This is needed to be able to use the operation in the new connection
tear-down sequence of control connections, which moves disconnecting
after the flush barrier.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add a host-device cport_shutdown callback which will be called as part
of the new connection tear-down sequence for offloaded connection in
order to do a cport_shutdown operation on behalf of the AP.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add a host-device cport_clear callback, which will be called as part
of the new connection tear-down sequence to reset the CPort state.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add a host-device cport_quiesce callback, which will be called as part
of the new connection tear-down sequence to disable flow control after
first making sure that enough peer buffer space is available for the
next messages about to be sent.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add a host-device cport_connected callback, which will be called after a
connection has been created and that can be used by the host-device
driver to make sure its internal state is updated to match the CPort
attributes set by the SVC.
This callback will eventually replace the cport_features_enable
callback.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>