Commit graph

2639 commits

Author SHA1 Message Date
Greg Kroah-Hartman
bdfb95c4ba staging: greybus: remove timesync protocol support
While the timesync protocol was a great idea, it never ended up getting
implemented by any known hardware devices.  It's also a bit
"interesting" in how it ties into the platform controller.

So, just remove it for now.  It's not needed, no one uses it, and it's a
stumbling block in getting the greybus core code merged out of the
staging tree.  If anyone wants it in the future, reverting this patch is
a great place to start from.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Alex Elder <elder@kernel.org>
Acked-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-07 17:00:57 +01:00
Emmanuil Chatzipetru
588bfea910 staging: greybus: log: Fix line over 80 characters.
Fix coding style issue caught by checkpatch.pl related to the following
warning:
	- CHECK: WARNING: line over 80 characters
This is done by dropping a redundant cast and by replacing the format specifier
in dev_err(); to "%zu" instead of "%d", in order to silence the warnings of the
compiler.

Also, while at it, drop the redundant cast in the comparison as well to maintain
consistency.

Signed-off-by: Emmanuil Chatzipetru <chatzi.emanuel@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-05 18:22:20 +01:00
Emmanuil Chatzipetru
8a983614ca staging: greybus: audio_topology: Fix spaces between operator and string
Fix coding style issue caught by checkpatch.pl related to the following
warning:
	- "CHECK: spaces preferred around that '*' (ctx:VxV) "

Signed-off-by: Emmanuil Chatzipetru <chatzi.emanuel@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-05 18:22:20 +01:00
Thierry Reding
8c0216f377 pwm: Remove .can_sleep from struct pwm_chip
All PWM devices have been marked as "might sleep" since v4.5, there is
no longer a need to differentiate on a per-chip basis.

Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2017-01-04 09:40:54 +01:00
Emmanuil Chatzipetru
62730c9571 staging: greybus: svc_watchdog: replace printk() with pr_err()
Fix coding style issue caught by checkpatch.pl related to the following
warning:
	- "WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then
dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ."

Signed-off-by: Emmanuil Chatzipetru <chatzi.emanuel@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 16:47:52 +01:00
Emmanuil Chatzipetru
28cf203524 staging: greybus: svc_watchdog: Fix spaces on a single definition statement
Fix coding style issue caught by checkpatch.pl related to the following
warning:
	- "CHECK: spaces preferred around that '*' (ctx:VxV) "

Signed-off-by: Emmanuil Chatzipetru <chatzi.emanuel@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 16:47:52 +01:00
Jérémy Lefaure
6da8086375 staging: greybus: arche-apb-ctrl: fix unused warnings on resume/suspend
When CONFIG_PM_SLEEP is disabled, SIMPLE_DEV_PM_OPS does not use
arche_apb_ctrl_resume and arche_apb_ctrl_suspend functions:

drivers/staging/greybus/arche-apb-ctrl.c:478:12: warning:
‘arche_apb_ctrl_resume’ defined but not used [-Wunused-function]
 static int arche_apb_ctrl_resume(struct device *dev)
            ^~~~~~~~~~~~~~~~~~~~~
drivers/staging/greybus/arche-apb-ctrl.c:464:12: warning:
‘arche_apb_ctrl_suspend’ defined but not used [-Wunused-function]
 static int arche_apb_ctrl_suspend(struct device *dev)
            ^~~~~~~~~~~~~~~~~~~~~~

Adding __maybe_unused to the declaration of these functions removes the
warnings.

Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 16:47:52 +01:00
Jason Hrycay
f05a88a39c staging: greybus: add host device function pointer checks
Add sanity checks for cport_quiesce and cport_clear before invoking the
callbacks as these function pointers are not required during the host
device registration. This follows the logic implemented elsewhere for
various other function pointers.

Signed-off-by: Jason Hrycay <jhrycay@gmail.com>
Reviewed-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 16:47:52 +01:00
Bryan O'Donoghue
a072a72da9 staging: greybus: loopback: use gb_loopback_async_wait_all don't spin
Currently the greybus-loopback thread logic spins around waiting for
send_count == iteration_max which on real hardware doesn't make a
difference to us but in simulation is excruciatingly slow, anti-social and
bad manners. Use the existing gb_loopback_async_wait_all() function to gate
continuing when the send_count == iteration_max and go to sleep until
there's something worthwhile to-do.

Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 16:45:01 +01:00
Linus Torvalds
9a19a6db37 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro:

 - more ->d_init() stuff (work.dcache)

 - pathname resolution cleanups (work.namei)

 - a few missing iov_iter primitives - copy_from_iter_full() and
   friends. Either copy the full requested amount, advance the iterator
   and return true, or fail, return false and do _not_ advance the
   iterator. Quite a few open-coded callers converted (and became more
   readable and harder to fuck up that way) (work.iov_iter)

 - several assorted patches, the big one being logfs removal

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  logfs: remove from tree
  vfs: fix put_compat_statfs64() does not handle errors
  namei: fold should_follow_link() with the step into not-followed link
  namei: pass both WALK_GET and WALK_MORE to should_follow_link()
  namei: invert WALK_PUT logics
  namei: shift interpretation of LOOKUP_FOLLOW inside should_follow_link()
  namei: saner calling conventions for mountpoint_last()
  namei.c: get rid of user_path_parent()
  switch getfrag callbacks to ..._full() primitives
  make skb_add_data,{_nocache}() and skb_copy_to_page_nocache() advance only on success
  [iov_iter] new primitives - copy_from_iter_full() and friends
  don't open-code file_inode()
  ceph: switch to use of ->d_init()
  ceph: unify dentry_operations instances
  lustre: switch to use of ->d_init()
2016-12-16 10:24:44 -08:00
Srikant Ritolia
3282998c80 staging: greybus: audio_module: remove redundant OOM message
All kmalloc-based functions print enough information on failure

Signed-off-by: Srikant Ritolia <s.ritolia@samsung.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-12-07 11:41:17 +01:00
Al Viro
450630975d don't open-code file_inode()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-12-04 18:29:28 -05:00
Rahul Krishnan
db1a4194c8 staging: Greybus: Remove unnecessary braces for single statement block
This patch fixes the following checkpath.pl warning
WARNING: braces {} are not necessary for single statement blocks

Signed-off-by: Rahul Krishnan <mrahul.krishnan@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-19 14:23:09 +01:00
Greg Kroah-Hartman
ce0347c2b0 Merge 4.9-rc5 into staging-next
We want the staging/iio fixes in here as well to resolve issues and
merge problems.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-14 08:53:56 +01:00
Johan Hovold
424a4b595e staging: greybus: use get_icount tty operation
Use the tty get_icount operation instead of implementing TIOCGICOUNT
directly.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-10 14:06:23 +01:00
Johan Hovold
4dfc109c71 staging: greybus: uart: fix invalid user-pointer check
Drop invalid user-pointer check from TIOCGSERIAL handler.

A NULL-pointer can be valid in user space and copy_to_user() takes care
of sanity checking.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-10 14:04:12 +01:00
Johan Hovold
d9966f1de9 staging: greybus: arche-platform: fix device reference leak
Make sure to drop the device reference taken by of_find_device_by_node()
before returning from arche_platform_change_state().

Note that this code is expected to be removed, but let's fix up the leak
nonetheless.

Fixes: 886aba558b ("greybus: arche-platform: Export fn to allow...")
Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-07 11:45:42 +01:00
Greg Kroah-Hartman
bdc065666a Merge 4.9-rc3 into staging-next
This resolves a merge issue with
drivers/staging/iio/accel/sca3000_core.c and we want the fixes all in
here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-30 06:38:44 -04:00
Dan Carpenter
e866dd8aab greybus: fix a leak on error in gb_module_create()
We should release ->interfaces[0] as well.

Fixes: b15d97d770 ("greybus: core: add module abstraction")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-24 15:51:00 +02:00
Wei Yongjun
1305f2b2f5 greybus: es2: fix error return code in ap_probe()
Fix to return a negative error code from the es2_arpc_in_enable() error
handling case instead of 0, as done elsewhere in this function.

Fixes: 9d9d3777a9 ("greybus: es2: Add a new bulk in endpoint for APBridgeA RPC")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-24 15:51:00 +02:00
Wei Yongjun
25633d1f5d greybus: arche-platform: Add missing of_node_put() in arche_platform_change_state()
This node pointer is returned by of_find_compatible_node() with
refcount incremented in this function. of_node_put() on it before
exitting this function.

This is detected by Coccinelle semantic patch.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-24 15:51:00 +02:00
Pankaj Bharadiya
49b9137a60 staging: greybus: audio: remove redundant slot field
gb_audio_manager_module_descriptor's intf_id field maintains the
information about the interface on which module is connected hence
having an extra slot field is redundant.

Thus remove the slot field and its associated code.

Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-24 15:48:02 +02:00
Rahul Krishnan
73270bb498 Staging: Greybus: Fix trailing */ in block comments
This patch fixes the following checkpath.pl warning
WARNING: Block comments use a trailing */ on a separate line

Signed-off-by: Rahul Krishnan  <mrahul.krishnan@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-24 15:48:02 +02:00
Rui Miguel Silva
7fec2bc90a staging: greybus: es2: fix arpc request size
Fix size field of arpc message request by using the header size and not
the pointer size.

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-24 15:48:02 +02:00
Elise Lennion
f9a21a3f49 staging: greybus: audio_manager_sysfs: Replace sscanf with kstrto* to single variable conversion.
Fix checkpatch warning:

WARNING: Prefer kstrto<type> to single variable sscanf

kstrto* is designed to convert string to numerical value and makes
it easier to understand what the code does.

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-24 15:35:03 +02:00
Bhumika Goyal
4d79f43191 Staging: greybus: uart: constify tty_port_operations structure
Declare tty_port_operations structure as const as it is only stored in
the ops field of a tty_port structure which is a field of a gb_tty
structure. The ops field is of type const struct tty_port_operations *,
so tty_port_operations structures having this property can be
declared as const.
Done using Coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct tty_port_operations i@p = {...};

@ok1@
identifier r1.i;
position p;
struct gb_tty q;
@@
q.port.ops=&i@p

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct tty_port_operations i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct tty_port_operations i;

File size before:
   text	   data	    bss	    dec	    hex	filename
   7646	    512	     56	   8214	   2016	drivers/staging/greybus/uart.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   7710	    448	     56	   8214	   2016	drivers/staging/greybus/uart.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Reviewed-by: David Lin <dtwlin@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-17 09:38:37 +02:00
sayli karnik
9edae49285 staging: greybus: es2: Use kmemdup instead of kmalloc and memcpy
This patch replaces kmalloc and memcpy with kmemdup for duplication of
memory.

Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-17 09:38:37 +02:00
Pankaj Bharadiya
d0af1bd5f6 staging: greybus: audio: Rename cport with intf_id
gb_audio_manager_module_descriptor's cport field is actually used to
manage and pass interface id to user space.

Thus rename gb_audio_manager_module_descriptor's 'cport' field and
few other things to avoid confusion.

Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@gmail.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-17 09:38:37 +02:00
Viresh Kumar
4fa589126f Staging: greybus: uart: Use gbphy_dev->dev instead of bundle->dev
Some of the print messages are using the incorrect device pointer, fix
them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-17 09:14:55 +02:00
Viresh Kumar
039bea8440 Staging: greybus: gpio: Use gbphy_dev->dev instead of bundle->dev
Some of the print messages are using the incorrect device pointer, fix
them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-17 09:14:55 +02:00
Elise Lennion
3f98afe0b6 staging: greybus: audio_codec: Remove useless return statement.
Remove return statement that is immediately followed by the function
closing bracket.

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:35 +02:00
Chase Metzger
cb2ec2eff2 staging: greybus: timesync.c: Fixed WARNING for brace issue
Removed a checkpatch warning for braces on single argument if and else
statement.

Signed-off-by: Chase Metzger <chasemetzger15@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:25 +02:00
Elise Lennion
cf3ba55dca staging: greybus: arche-platform: Format block comments.
Fix checkpatch warning:

WARNING: Block comments use a trailing */ on a separate line

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:24 +02:00
Elise Lennion
c4fc2ebcbf staging: greybus: camera: Use kcalloc for array's memory allocation.
Fix checkpatch warning:

WARNING: Prefer kcalloc over kzalloc with multiply

kcalloc is designed to allocate memory for arrays, its use is
preferable than kzalloc in these cases.

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:23 +02:00
Elise Lennion
9d3318f48c staging: greybus: camera: Replace blank spaces with tabstops.
Fix checkpatch warning:

WARNING: Statements should start on a tabstop

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:22 +02:00
Elise Lennion
cd7b701f52 staging: greybus: camera: Add blank lines after variable declarations.
Fix checkpatch warning:

WARNING: Missing a blank line after declarations

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:21 +02:00
Chase Metzger
2072763cf0 drivers: staging: greybus: audio_manager_sysfs.c: Fixed CHECK for brace issue
Added braces to else and else if statements where checkpatch complained.

Signed-off-by: Chase Metzger <chasemetzger15@gmail.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:31 +02:00
Chase Metzger
9ae7a47f7f drivers: staging: greybus: audio_codec.c: Fixed CHECKS for brace issues
Added braces to else statement where checkpatch complained.

Signed-off-by: Chase Metzger <chasemetzger15@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:08 +02:00
Chase Metzger
02ae32f754 drivers: staging: greybus: Fixed CHECKS for brace issues
Added braces to else statements where checkpatch complained.

Signed-off-by: Chase Metzger <chasemetzger15@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:24:21 +02:00
Elizabeth Ferdman
a2a87b224b staging: greybus: Add blank line after declaration
Add a blank line after a declaration. Error found by checkpatch.

Signed-off-by: Elizabeth Ferdman <gnudevliz@gmail.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:24:20 +02:00
Hisao Tanabe
1047cc1359 staging: greybus: fix block comment
This patch fix the coding style problem of block comment detected by the
checkpatch.pl.

WARNING: Block comments use a trailing */ on a separate line

Signed-off-by: Hisao Tanabe <xtanabe@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar  <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:24:20 +02:00
Sidhant Gupta
cb026e3988 staging: greybus: Fix a commit coding style issue.
Fixes a comment coding style warning by adding 2 blank lines. Issue
found by checkpatch.

Signed-off-by: Sidhant Gupta <guptasidhant004@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:24:19 +02:00
Rui Miguel Silva
5cf6267915 staging: greybus: light: check the correct value of delay_on
When checking the value of delay_on to set the channel as active, it was
checked the pointer and not the value, as it should be.

Fixes: cc43368a3c ("greybus: lights: Control runtime pm suspend/resume on AP side")

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-02 15:49:26 +02:00
Rui Miguel Silva
dc875c7790 staging: greybus: light: check delay_{on|off} before use
Even though we trust leds core that the pointers should be valid, we are
safer to check delay_{on|off} before use.

Also, this avoid a smatch warning:
drivers/staging/greybus/light.c:484 gb_blink_set()
warn: variable dereferenced before check 'delay_on' (see line 476)

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-02 15:49:26 +02:00
Rui Miguel Silva
3855eeec1a staging: greybus: light: fix attributes allocation
Fix allocation of attributes with the correct size, this also fix smatch
warning:

drivers/staging/greybus/light.c:293 channel_attr_groups_set()
warn: double check that we're allocating correct size: 8 vs 16

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-02 15:49:26 +02:00
Rui Miguel Silva
85a42dc867 staging: greybus: sdio: fix cmd_flags check for none response
When checking for command flags field if response is not available we
really need to compare it with the right define and not bitwise AND it.

smatch warn:
        drivers/staging/greybus/sdio.c:481 gb_sdio_command()
        warn: bitwise AND condition is false here

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-02 15:49:25 +02:00
Quentin Lambert
3dd22268d7 greybus: manifest: style fix missing space before '('
Checkpatch printed a style ERROR concerning a missing space before '('.
This patch fixes this issue.

Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-27 12:59:51 +02:00
Bryan O'Donoghue
659849cdc0 staging: greybus/timesync: avoid divide by zero on X86 Qemu
A system configured without CONFIG_CPUFREQ will return 0 for cpufreq_get().
greybus-timesync can subsequently then do a divide-by-zero as result. This
patch fixes by checking for a zero return value from cpufreq_get() and
setting to a default value of 19.2MHz.

Reported-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-27 12:59:51 +02:00
Chase Metzger
3d7f358855 drivers/staging/greybus: gpio.c - Fixed a checkpatch generated warning
Removed braces for single line if statement.

Signed-off-by: Chase Metzger <chasemetzger15@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-27 12:59:51 +02:00
Vaibhav Agarwal
7224a2a50a greybus: audio: fix uninitialized variable errors found by cppcheck
Currently, if info is null, the dev_err message is dereferencing an
uninitialized module pointer.  Instead, it should use codec->dev pointer
in dev_err call and better align with other err msg in this function.

Also, ret variable might be used uninitialized in a specific case.
Avoid using it this way.

Found using static analysis with cppcheck:
Checking drivers/staging/greybus/audio_topology.c...
[drivers/staging/greybus/audio_topology.c:175]: (error) Uninitialized
variable: module
[drivers/staging/greybus/audio_topology.c:495]: (error) Uninitialized
variable: ret

Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-27 12:59:51 +02:00
sayli karnik
82af03f7b9 staging: greybus: Use setup_timer function
This patch uses setup_timer function instead of initializing timer with the
function and data fields.

Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-23 19:00:43 +02:00
Eva Rachel Retuya
5c925fe2a4 staging: greybus: arche-apb-ctrl: declare struct of_device_id as const
Declare the 'arche_apb_ctrl_of_match' array as const. This array is only stored
in the .of_match_table field of a device_driver structure, which is declared as
const. This addresses the checkpatch warning:

WARNING: struct of_device_id should be normally const

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-23 14:11:46 +02:00
Eva Rachel Retuya
cdcffc0cdf staging: greybus: arche-platform: declare struct of_device_id as const
Declare the arrays 'arche_platform_of_match' and 'arche_combined_id' as const.

'arche_platform_of_match' is only stored in the .of_match_table field of a
device_driver structure, which is declared as const.

'arche_combined_id' is passed to MODULE_DEVICE_TABLE. This macro does not
modify the array and therefore the array can be declared as const. Checkpatch
pointed out both issues.

WARNING: struct of_device_id should be normally const

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-23 14:11:45 +02:00
Chaehyun Lim
319b78c3c4 staging: greybus: uart.c: fix alignment to match open parenthesis
Fixes checkpatch.pl warning:
CHECK: Alignment should match open parenthesis

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-22 11:54:47 +02:00
Chaehyun Lim
26746a3603 staging: greybus: uart.c: change 'unsigned' to 'unsigned int'
Fixes checkpatch.pl warning:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-22 11:54:47 +02:00
Richard Groux
3311157455 staging: greybus: audio_codec.c: code indent should use tabs where possible
Minor error spotted by checkpatch.pl in greybus
code indent should use tabs where possible

Signed-off-by: Richard Groux <rgroux@sauron-mordor.net>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-22 11:54:47 +02:00
Richard Groux
0c8d9c73e6 staging: greybus: audio_codec.c: space required before the open brace
Minor error spotted by checkpatch.pl in greybus
space required before the open brace '{'

Signed-off-by: Richard Groux <rgroux@sauron-mordor.net>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-22 11:54:47 +02:00
Eva Rachel Retuya
5a420d15d1 staging: greybus: arche-platform: compress return logic into one line
Modify return statement to use the value being returned directly instead of
assigning it first to 'ret' and returning this variable. Coccinelle semantic
patch used:

@@
expression e;
local idexpression ret;
@@

-ret =
+return
	e;
-return ret;

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-22 11:54:47 +02:00
Eva Rachel Retuya
4f1cbe2a7b staging: greybus: audio: delete unnecessary parentheses
Eliminate unneeded parentheses around the right hand side of an assignment.
Coccinelle semantic patch used:

@@
expression e1, e2;
identifier v;
@@

(
 v = (e1 == e2)
|
 v = (e1 != e2)
|
 v = (e1 <= e2)
|
 v = (e1 >= e2)
|
 v =
- (
	e1
- )
)

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-22 11:54:47 +02:00
Eva Rachel Retuya
ce35e9be62 staging: greybus: camera: simplify NULL test
Replace direct comparisons to NULL i.e. 'x == NULL' with '!x' for consistency.
Coccinelle semantic patch used:

@@
identifier func;
expression x;
statement Z;
@@

x = func(...);

if (
(
+	!
	x
-	== NULL
|
+	!
-	NULL ==
	x
)
   ) Z

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-22 11:54:47 +02:00
Greg Kroah-Hartman
abf095b5c5 staging: greybus: fix up camera Kconfig dependancies
CONFIG_MEDIA is not a thing, but CONFIG_MEDIA_SUPPORT is, so use that.

Reported-by: Valentin Rothberg <valentinrothberg@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-21 12:35:13 +02:00
Chaehyun Lim
79cb2b26f5 staging: greybus: use preferred kernel type u16
As suggested by checkpatch.pl:

CHECK: Prefer kernel type 'u16' over 'uint16_t'

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-20 13:24:46 +02:00
Chaehyun Lim
31959392c7 staging: greybus: use preferred kernel type u8
As suggested by checkpatch.pl:

CHECK: Prefer kernel type 'u8' over 'uint8_t'

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-20 13:24:46 +02:00
Greg Kroah-Hartman
948c6227e7 staging: greybus: remove CONFIG_PM_RUNTIME from kernel_ver.h
The last thing remaining in kernel_ver.h was the setting of
CONFIG_PM_RUNTIME, which isn't needed in a in-tree implementation.  So
remove the setting of this value, and the .h file entirely as that was
the last thing left in it.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:52:07 +02:00
Rui Miguel Silva
a0cf5951de staging: greybus: Kconfig: enable possibility to select light driver
Remove BROKEN keyword to allow the light driver to be select now that
we fixed the kernel version dependencies. Also fix the module name in
the help section.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:50:48 +02:00
Rui Miguel Silva
b04f56c6e7 staging: greybus: makefile: fix dependency of spi to spilib
Greybus SPI driver depends on gb-spilib and we need to state that at
makefile to make it link correctly.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:49:53 +02:00
Rui Miguel Silva
722a133a6a staging: greybus: power_supply: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus Power Supply
driver, so remove the checks as needed, we can now rely on all of the
correct Power Supply core apis being present. Also move some properties
definitions to the power supply greybus code.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:48:44 +02:00
Rui Miguel Silva
2064ae5741 staging: greybus: sdio: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus SDIO driver, so
remove the checks as needed, we can now rely on all of the correct SDIO
core apis being present.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:47:49 +02:00
Rui Miguel Silva
a7af2fe6d1 staging: greybus: light: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus Light driver, so
remove the checks as needed, we can now rely on all of the correct LED
core apis being present. And compile only if flash and v4l2 flash is
reachable.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:46:34 +02:00
Greg Kroah-Hartman
7434564ca1 staging: greybus: sdio: fix min() type check
The 0-day bot pointed out a type difference in one min() call, so fix it
up by being explicit about the type being compared.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:44:41 +02:00
Greg Kroah-Hartman
148e0b8f48 staging: greybus: spi: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus SPI and spilib
driver, so remove the checks as needed, we can now rely on all of the
correct SPI core apis being present.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:43:27 +02:00
Greg Kroah-Hartman
3e4b5b8837 staging: greybus: gpio: it's CONFIG_GPIOLIB, not CONFIG_GPIO
The GPIO dependancy is CONFIG_GPIOLIB, not CONFIG_GPIO, no wonder it
wasn't building properly...

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:41:54 +02:00
Greg Kroah-Hartman
b14bb97626 staging: greybus: gpio: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus GPIO driver, so
remove the checks as needed, we can now rely on all of the correct
GPIO core apis being present.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:41:45 +02:00
Greg Kroah-Hartman
06000c0317 staging: greybus: vibrator: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus Vibrator driver,
so remove the checks as needed, we can now rely on all of the correct
driver core apis being present.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:30:41 +02:00
Greg Kroah-Hartman
be21106d67 staging: greybus: hid: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus HID driver, so
remove the checks as needed, we can now rely on all of the "new" apis
being present.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:30:41 +02:00
Greg Kroah-Hartman
887520884b staging: greybus: kernel_ver.h: remove lots of stuff
Now that we do not care about the kernel version we are building
against, we can strip out lots of backward compatibilty that was added
to kernel_ver.h in order to write semi-portable driver code.

To start with, remove the functions and #defines that are now in the
kernel tree, no need to have duplicate copies of them all.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:30:40 +02:00
Greg Kroah-Hartman
d4f56b47a8 staging: greybus: Add drivers/staging/greybus to the build
This adds a proper Kconfig file for drivers/staging/greybus and fixes up
the Makefile to work correctly within the kernel build system (modules
depend on the .config options, etc.)

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:30:37 +02:00
Greg Kroah-Hartman
526dec0642 staging: greybus: remove old es1 endpoint description
The Toshiba ES1 chip is no longer around, so remove the USB descriptor
documentation for it as no one cares anymore.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:40:33 +02:00
Greg Kroah-Hartman
ecfea541e6 staging: greybus: remove .gitignore file
Only the tools subdirectory needs a .gitignore entry, so move it there
and fix it up to only list the needed file.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:37:09 +02:00
Greg Kroah-Hartman
0be6dfc296 staging: greybus: remove README and LICENSE
We don't need yet-another-copy of the GPLv2 in the tree, and the README
is now pointless, so remove both of these files.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:36:24 +02:00
Greg Kroah-Hartman
bc5aa3a079 staging: greybus: Documentation: remove sysfs tree
We do not need an example of the sysfs tree in the kernel code itself,
so remove these files, as they are now pointless.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:35:16 +02:00
Greg Kroah-Hartman
dae0901111 greybus: remove local checkpatch.pl copy
When the greybus tree was external, it contained a copy of checkpatch.pl
to keep everyone "in line".  This is no longer needed and can now be
removed.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:33:38 +02:00
Axel Haslam
7398a66f10 greybus: gbphy: fix compile error with CONFIG_PM_RUNTIME disabled
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>
2016-09-08 19:50:57 +02:00
Viresh Kumar
88f6ba61f2 greybus: gpio: create irqdomain before registering gpio controller
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>
2016-09-05 09:16:47 +02:00
Greg Kroah-Hartman
272291008f greybus: es2: fix up usb probe error messages
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>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
1521eb6b69 greybus: es2: No need to check before freeing an urb
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>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
fc994f0f83 greybus: es2: remove unneeded BULK_* #defines
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>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
7330c48ec0 greybus: es2: remove bulk_in array
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>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
403074b50b greybus: es2: remove bulk_out array
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>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
84d5077cae greybus: es2: remove struct cport_to_ep
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>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
b6c1bd3a8e greybus: es2: remove #if 0 code
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>
2016-09-02 14:20:56 +02:00
Sandeep Patil
4de02894a2 greybus: es2: use a single bulk ep pair for all greybus data
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>
2016-09-02 14:20:56 +02:00
Johan Hovold
6fa4d3d5bb greybus: greybus_protocols: remove svc key-event type
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>
2016-09-02 14:13:39 +02:00
Philip Yang
4e013b64c1 greybus: power_supply: Add runtime pm support
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>
2016-09-02 14:13:39 +02:00
Vaibhav Agarwal
6a57ddc97a greybus: audio: Avoid reporting spurious button events
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>
2016-09-02 14:13:39 +02:00
Vaibhav Agarwal
cec89df446 greybus: audio: Report jack events conditionally
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>
2016-09-02 14:13:39 +02:00
Vaibhav Agarwal
847175e8e6 greybus: audio: Fetch jack_mask, button_mask from module's topology data
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>
2016-09-02 14:13:39 +02:00
Vaibhav Agarwal
a695c302b4 greybus: audio: Added jack_type support in topology struct
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>
2016-09-02 14:13:39 +02:00
Vaibhav Agarwal
79c222bcb7 greybus: audio: Remove unnecessary num_jack field from module_info
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>
2016-09-02 14:13:39 +02:00
Johan Hovold
1f3e09e759 greybus: svc: fix timeout indentation
Make sure the timeout values are aligned.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:21:13 +02:00
Johan Hovold
1b1732c4c4 greybus: es2: remove obsolete cport-reset ARPC
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>
2016-08-26 13:21:13 +02:00
Johan Hovold
2045c9f265 greybus: hd/es2: remove obsolete callbacks
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>
2016-08-26 13:21:13 +02:00
Johan Hovold
aac0839ea2 greybus: connection: implement new connection handling
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>
2016-08-26 13:21:13 +02:00
Johan Hovold
77e52b3b0b greybus: es2: implement shutdown callback
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>
2016-08-26 13:21:13 +02:00
Johan Hovold
d2dee94b66 greybus: es2: implement flush callback
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>
2016-08-26 13:21:13 +02:00
Rui Miguel Silva
6ac9166d4e greybus: power_supply: fix name setting location
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>
2016-08-26 13:16:11 +02:00
Kris Huang
cc43368a3c greybus: lights: Control runtime pm suspend/resume on AP side
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>
2016-08-26 13:16:11 +02:00
David Lin
0e352343c2 greybus: light: fix incorrect led attribute files allocation
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>
2016-08-26 13:16:11 +02:00
Mark Greer
f0ec8cd5eb greybus: audio: Fix incorrect direction value when enabling RX
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>
2016-08-26 13:16:11 +02:00
Johan Hovold
be67e7e54b greybus: svc: drop unnecessary symbol exports
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>
2016-08-19 09:57:28 +02:00
Greg Kroah-Hartman
46bb647b1c greybus: Revert "svc: drop all symbol exports"
This reverts commit a0e559d03bbb3f9774a091e31c0f77d98db1f60d.

It breaks the camera driver :(

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-18 21:30:19 +02:00
Johan Hovold
6d13b6ff11 greybus: svc: drop all symbol exports
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>
2016-08-18 17:52:23 +02:00
Rui Miguel Silva
b5fbe819af greybus: power_supply: invalidate cache at update request
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>
2016-08-18 17:34:01 +02:00
Rui Miguel Silva
5f66d62e83 greybus: power_supply: fix update interval check at request handler
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>
2016-08-18 17:34:01 +02:00
Rui Miguel Silva
c4582f9d79 greybus: power_supply: add callback to handle power supply changes
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>
2016-08-18 17:34:01 +02:00
Vaibhav Agarwal
6198f892fa greybus: Use valid control pointer while freeing memory
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>
2016-08-18 17:32:39 +02:00
Vaibhav Agarwal
15c726ea52 greybus: audio: Add check for invalid index while mapping control
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>
2016-08-18 17:32:39 +02:00
Ann Chen
0900845ab7 greybus: Add workqueue to handle vibrator timeout
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>
2016-08-18 13:36:28 +02:00
Johan Hovold
5f62eab04a greybus: es2: fix memory leak in probe error path
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>
2016-08-17 15:59:13 +02:00
Jacopo Mondi
c9161d72b3 greybus: camera: Remove support for legacy modules
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>
2016-08-12 18:50:15 +02:00
Viresh Kumar
ac96a609dc greybus: firmware: add comment to show size calculations
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>
2016-08-12 17:38:19 +02:00
Viresh Kumar
0675363ac7 greybus: firmware: s/should/must
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>
2016-08-12 17:38:19 +02:00
Viresh Kumar
b2abeaa10d greybus: firmware: s/_LEN/_SIZE
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>
2016-08-12 17:38:19 +02:00
Viresh Kumar
769cb83704 greybus: firmware: Remove extra parenthesis
Remove the unnecessary parenthesis.

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>
2016-08-12 17:38:19 +02:00
Viresh Kumar
d581bc88cb greybus: firmware: Fix typo in documentation
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>
2016-08-11 14:14:54 +02:00
Viresh Kumar
295b5269d6 greybus: firmware: use 'tag' instead of 'firmware_tag'
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>
2016-08-11 14:14:54 +02:00
Johan Hovold
9f77b80fdf greybus: control: make disconnecting a core operation
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>
2016-08-11 14:13:07 +02:00
Johan Hovold
8f71a975d4 greybus: hd: add cport_shutdown callback
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>
2016-08-11 14:13:07 +02:00
Johan Hovold
6471c0039c greybus: hd/es2: add cport_clear callback and ARPC
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>
2016-08-11 14:13:07 +02:00
Johan Hovold
0e7cd0d259 greybus: hd/es2: add cport_quiesce callback and ARPC
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>
2016-08-11 14:13:07 +02:00
Johan Hovold
a9dc1cf5b7 greybus: hd/es2: add cport_connected callback and ARPC
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>
2016-08-11 14:13:07 +02:00
Greg Kroah-Hartman
b3136a77a4 greybus: fix up copyright dates on arpc.h
I got them wrong, Johan was right, my fault.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-10 17:02:05 +02:00
Kris Huang
811b1f5861 greybus: lights: enable multi color LED support
A backport (commit 79c4de08c0e5a26b04a4ac9e6543dad6379f0b40) was
applied in kernel which adding attribute-group support in led-class.
Remove the LED_HAVE_GROUPS flag check entirely that allow led
drivers to create custom attributes like color/fade_in/fade_out.

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>
2016-08-10 15:47:30 +02:00
Georgi Dobrev
57fa2de1e5 greybus: greybus-driver: Add intf_oops operation
Add intf_oops operation to SVC Protocol. This
operation will notify the AP about a fatal error
in a module. The request has two arguments:
    -u8 intf - the interface in question
    -u8 reason - reason of the error
The response has no payload.
Upon receiving the Request, the driver disables
the Interface.

Signed-off-by: Georgi Dobrev <gdobrev@mm-sol.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Ashwin Chaugule <ashwinch@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-10 15:44:03 +02:00
Jacopo Mondi
127bada1a1 greybus: camera: Remove reference to ara subdevice
Remove last occurrence of "ara" term in camera driver.
Replace reference to "ara subdevice" with "gmp subdevice"

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-10 15:40:05 +02:00
Johan Hovold
7d0e76d6cb greybus: arpc: move arpc definitions to their own header
Move the ARPC definitions to their own header.

ARPC is not part of greybus, but is rather an implementation-specific
means of communicating with a certain class of host-device hardware.

Note that the same is true for the APBA USB vendor requests, but we keep
them in the greybus header for the time being.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-10 15:36:34 +02:00
Johan Hovold
83d474f7aa greybus: es2: fix USB vendor-request prefixes
Make sure to use the common GB_APB prefix for all APBA USB vendor
requests.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-10 15:36:34 +02:00
Johan Hovold
a4fe35072f greybus: greybus_protocols: fix apba vendor-request comment
Fix copy-paste error in an APBA USB vendor-request comment.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-10 15:36:34 +02:00
Rui Miguel Silva
afbf72505b greybus: sdio: increase maximum segment size
Adjust maximum segment size of the sg list to meet the maximum request
size, this will allow to have less segments which increase the
performance of data movement during transfer operations.

Test Done: using mmc_test with best-case read/write performance and see
that only one segment is used and that the results are better (288KiB vs
300KiB in read operation).

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-10 12:00:32 +02:00
Rui Miguel Silva
64f28ada93 greybus: greybus_protocol: fix order of sdio get caps response
Order of the field of the sdio get caps operation response were wrong,
that influence later the frequencies used by core, during normal
operation.

Tested: verified that the values inserted by the fw are the correct ones
for the field.

Suggested-by: Jackson Chang <jacksonc@bsquare.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-10 12:00:32 +02:00
David Lin
4523eae6f8 greybus: interface: fix timesync registration sequencing
When enabling an interface, control device should be registered after
having successfully added the timesync. Similarly for the interface
disable path, control device should be removed first before removing
timesync.

Testing Done:
 - Enable and disable the interface

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: David Lin <dtwlin@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-06 11:08:48 +02:00
Vaibhav Agarwal
33cc283928 greybus: audio: Report jack removal along with module removal
For GB module with jack slot supported, headset/headphone can still
be inserted at the time of module removal. In this case, above layer is
unaware about jack removal event which happened due to module removal.
This may lead to inconsistent state in above HAL layer.  Fix this by
reporting jack removal event explicitly.

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-08-05 20:14:48 +02:00
Kris Huang
9141ad8773 greybus: lights: Add runtime pm support
Modify Lights greybus driver to support runtime PM framework.
The suspend and resume function have been tested with gpbridge-test
image by sysfs. Lights functions work well on suspend/resume.

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: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-05 20:14:48 +02:00
Jackson Chang
8f3972f78f greybus: SDIO: Add runtime pm support
Modify SDIO greybus driver to support runtime PM framework.
To enable SDIO runtime PM, it needs to remove MMC_CAP_NEEDS_POLL
and add MMC_CAP2_CORE_RUNTIME_PM in set_host_caps().
The suspend function and resume function have been tested
with micron-sdio image by sysfs. SDIO functions work well
on suspend/resume.

Testing Done: Compiled and verified on EVT2.0 + Micron ARA
              SD module with USB connector

Signed-off-by: Jackson Chang <chang_jackson@projectara.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-05 20:14:48 +02:00
Vaibhav Agarwal
591c45227a greybus: audio: Maintain module stream state for each data connection
For SPK module, each data connection corresponds to codec DAI. Now
stream state is maintained for each DAI. So, need to maintain stream
state for each DAI/data connection for individual module as well.

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
19866603be greybus: audio: Maintain runtime stream params for each DAI
Runtime streams are required while configuring GB module plugged-in
during active stream. Currently, it is maintained for single stream.
However, this should be maintained for a stream corresponding to each
DAI. Fix this!

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
c388ae7696 greybus: audio: Update pm runtime support in dai_ops callback
Ensure pm runtime get_sync/put protection in codec_dai ops callback
functions before accessing apbridge.

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
956adf749d greybus: Remove unused field from data_connection
Audio codec driver internally maintains a struct containing info about
module's data connection. Remove unused field from this struct.

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
60e7327d54 greybus: audio: Find data connection based on id
Currently we are using dai->name to identify data connection from list
for a module. Now since we are enabling data path based on widget,
dai->name might be invalid by the time driver receives disable request
for a widget. So, use id fetched from AIF widget->sname to identify data
connection for a module.

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
b7e7dc0083 greybus: audio: Add id to identify data connection
Added id field to data connection struct. This is used to identify which
data connection to use while enabling interface between module & APB.

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
487dcbd6ba greybus: audio: Use AIF widget to enable path between module & APB
Currently, SPK Amp switch is used to identify when to enable data path
between module and APB. With headset, other switch controls added, it is
not possible to use this switch to control data path. Instead path
should be established based on AIF widget.

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
4ffca62a05 greybus: audio: Update parameters for gbaudio_module_update API
Earlier, module path was enabled based on module's control switch e.g.
'SPK Amp switch'.  Thus widget's name was sufficient to parse and
identify the direction. Now individual modules' path will be enabled
based on AIF widget status. So, it is required to get complete widget
details, say w->type is used to identify direction (playback/capture)
and w->sname is used to identify module's DATA connection used for
communication via greybus.

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
1568159868 greybus: audio: Update dai_driver table with appropriate fields
Currently, the stream name for the DAI driver is generically set to "GB
Audio Playback" and "GB Audio Capture". This is OK since we use a single
interface on APB1 but that could change in the future.  Update the DAI
driver table entries to properly reflect the interface used.

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
aaef32a6cc greybus: audio: Split helper APIs based on stream direction
Now, module is enabled/disabled based on widget event only and not
during startup/shutdown callbacks. Thus, we needn't compare codec_state
in enable/disable module helper APIs. Also, these can be further
simplified based on stream direction.

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
ce9413062f greybus: audio: Enable audio path based on control switch state only
As per current implementation, audio data is played from each individual
SPK module connected to endo frame. This is not a valid requirement in
case of capture/headset path. So, provide a mechanism to enable
individual module path based on it's control switch state.

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-08-04 19:07:30 +02:00
Vaibhav Agarwal
90579d4b57 greybus: audio: Remove un-necessary goto statement
For most of the helper functions, goto statement is widely used.  It was
originally used with an intent of single exit point for the function
with some cleanup required. This is no more the case. So, simplify code
by avoiding un-necessary gotos.

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-08-04 19:07:30 +02:00
Vaibhav Hiremath
921dbe52b4 greybus: arche-platform: Add support for SPI bus sharing for Mihi
In case of Mihi, SPI bus is shared between APB1 and APB2
SPI ROMs, so their FW flashing must be sequential and
arche-platform driver should make sure that they are mutual
exclusive in nature.

So this patch adds certain restrictions to the user of the
arche-platform driver,

 - User can no longer flash APB1 and APB2 SPI ROM in parallel
 - SPI bus becomes an resource, so user must claim it by moving
   respective APB device into FW_FLASHING mode and release it
   by exiting FW_FLASHING mode. User can exit FW_FLASHING mode by
   switching to any other modes (ACTIVE, OFF, STANDBY).
 - If APB1 is in FW_FLASHING mode, APB2 can no longer enter into
   FW_FLASHING mode. User will get -EBUSY.

Having said that, while APB1 is into FW_FLASHING mode,
APB2 can independently boot from its own SPI ROM.

Testing Done: Tested by simulating usecase on EVT2.
 - Made sure that APB1 and APB2 FW_FLASHING mode is mutual exclusive
   in nature. Confirmed that an attempt on second device return -EBUSY.
 - Added simulating code, where printed state of dummy gpio for
   spi-en and verified that it shows right pin status for both APBs

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 15:45:08 +02:00
Vaibhav Hiremath
8ef0b53831 greybus: arche-platform: Reset SVC & APB only if turned off by SUSPEND_PREPARE
There is possible race condition in arche platform driver for
maintaining of ->state field, when shared with timesync driver.

Assume device booted fine, all connected modules have been enumerated
correctly. As part of suspend-resume operation we have pm_notifier
callback, where we turn off SVC & APB and coldboot on resume.
In the process of resume, all modules gets enumerated again, and
timesync driver does come into picture everytime.
So when timesync driver requests arche-platform to change the state
to TIMESYNC and in the middle of sync operation, if suspend gets
triggered, then execution lands into arche-platform->pm_notifier callback,
leading to race condition in the driver, where it checks for (state != ACTIVE)
in PM_SUSPEND_PREPARE and returns, but in PM_POST_SUSPEND it just simply
coldboots SVC & APB, which would inbalance all resources (including IRQ).

So we need a add check in PM_POST_SUSPEND, to make sure that, we only
coldboot devices if they are in to off state,
i.e. if (state != OFF) then return.

Testing Done: Done regressive suspend/resume testing on EVT2 platform.
Note that, I some time hit issue.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 15:43:51 +02:00
Johan Hovold
60793c9be9 greybus: es2: rename USB vendor-request timeout define
Give the USB vendor-request timeout define a more descriptive name.

Also drop the since-long obsolete comments about allowing "the SVC to do
something" and "SVC messages go down our control pipe".

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 15:42:38 +02:00
Johan Hovold
54f34e1e4d greybus: es2: add define for ARPC CPort requests
Add dedicated define for ARPC CPort requests instead of using the
default timeout for USB vendor requests.

We still allow responses to take 500 ms to arrive, but note that this
adds on top of the 500ms already allowed for a requests to be
acknowledged. This should probably be tightened up at some point.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 15:42:38 +02:00
Johan Hovold
121bae2bec greybus: es2: allow ARPC result to be ignored
Allow user of ARPC to pass a NULL pointer for the ARPC result.

For simple requests there may only be one error code for remote errors,
or the caller may simply not care to differentiate them.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 15:42:38 +02:00
Johan Hovold
4ae2d96263 greybus: es2: always set result value
Make sure to always set the result value for ARPC instead of forcing
every caller to do it in order to avoid compiler warnings.

The ARPC result should still be ignored unless arpc_sync returns
-EREMOTEIO.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 15:42:38 +02:00
Johan Hovold
c468999e6a greybus: es2: clean up ARPC symbol names
Add a _req suffix to request message structures, and a _TYPE_ infix to
request type defines.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 15:42:38 +02:00
Johan Hovold
06d8b7d9cf greybus: connection: fix offloaded-connection ping cport id
The host-device cport_ping callback expects the AP side cport id, but
was incorrectly passed the interface cport id.

Note that no host-device driver currently implements this callback, and
that it is soon even to be removed.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 15:42:38 +02:00
Johan Hovold
081ee14ab4 greybus: control: remove some braces
Remove some no-longer-needed braces around an error path.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 15:42:38 +02:00
Johan Hovold
6e8fc8c4c9 greybus: remove unused protocol-version messages
Remove the unused protocol-version messages.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 15:42:38 +02:00
Mark Greer
8f60ce76a4 greybus: audio: Remove GET_TX/RX_DELAY message types
The 'GB_AUDIO_TYPE_GET_TX_DELAY' and 'GB_AUDIO_TYPE_GET_RX_DELAY'
are no longer a part of the Greybus Audio Device Class Protocol
so remove support for them.  The message numbers are not coalesced
to prevent compatibility issues between the AP and the module.

Testing Done: Played music using a speaker module

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 10:59:13 +02:00
Mark Greer
ccc57e20d1 greybus: audio: apbridgea: Remove GET_TX/RX_DELAY message types
The 'AUDIO_APBRIDGEA_TYPE_GET_TX_DELAY' and
'AUDIO_APBRIDGEA_TYPE_GET_RX_DELAY' message types have been
removed from the AP <-> APBrigdeA Audio Protocol so remove
them from the code.  Do not coalesce the message type numbers
to prevent compatibility issues between the AP and APBridgeA.

Testing Done: Played music using a speaker module

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 10:59:13 +02:00
Bryan O'Donoghue
ca9551f681 greybus: timesync: Printout strobe count on sync failure
If we failed to synchronize the FrameTime it would be useful to know how
many of the expected strobes arrived, for example a value of 0/5 would
indicate the SVC was completely dead but a value of 4/5 would indicate one
GPIO pulse got lost i.e. the AP was too slow reacting to an interrupt and
completely missed one of the strobe events. In either case the actual
number of strobes is a useful thing to print out.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 10:59:13 +02:00
Bryan O'Donoghue
5cb74976b9 greybus: timesync: Ensure parallel synchronous calls succeed
The guard for initiating a new synchronization operation should allow for
that resync to happen in every single state except for INVALID. This patch
fixes by ensuring the guard does just that. With local testing it was
possible to break a sync to a Module. This hasn't been observed in a buglog
but should be fixed anyway.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: David Lin <dtwlin@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 10:59:13 +02:00
Bryan O'Donoghue
7aa278b771 greybus: timesync: Implement a retry mechanism
It's possible the AP could miss an incoming SVC timesync pulse i.e. the AP
could have interrupts switched off for long enough that one SVC GPIO strobe
ends up over-lapping another one. TimeSync should be able to deal with this
type of transitory failure by retrying a failed synchronous TimeSync resync
up to 'n' number of times. For this patch 'n' has been set to five, which
is a hand-wavy choice that 'feels' right.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 10:59:13 +02:00
David Lin
b6fc2876a0 greybus: svc_watchdog: use schedule_delayed_work helper
Instead of using the queue_delayed_work call for delayed work on
system_wq, use the schedule_delayed_work helper to be more consistent on
the style.

Testing Done:
 - Check SVC watchdog is pining after the change.

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 10:59:13 +02:00
David Lin
ea2ff95ab4 greybus: interface: delete control device upon enable failure
There is an issue that when an interface failed to be enabled due to
timesync failure, a previously added control device is not deleted as
part of the error clean-up. This causes a leak in the sysfs file when
the interface is disabled. This would eventually cause this particular
interface to be unable to register future control device even after
unipro_reset. See failure logs below:

[  906.495261] greybus 1-3.3: failed to add to timesync: -19
[  906.516497] greybus 1-3.3: failed to re-enable interface: -19
[  907.016016] greybus 1-3.3: Interface removed
...
[ 1623.677343] ------------[ cut here ]------------
[ 1623.681116] WARNING: at kernel/arche/fs/sysfs/dir.c:530 sysfs_add_one+0x98/0xb4()
[ 1623.681128] sysfs: cannot create duplicate filename '/bus/greybus/devices/1-3.3.ctrl'
[ 1623.681252] Call trace:
[ 1623.681265] [<ffffffc000207b40>] dump_backtrace+0x0/0x268
[ 1623.681272] [<ffffffc000207db8>] show_stack+0x10/0x1c
[ 1623.681284] [<ffffffc000ccb890>] dump_stack+0x1c/0x28
[ 1623.681295] [<ffffffc00021f9dc>] warn_slowpath_common+0x74/0x9c
[ 1623.681301] [<ffffffc00021fa60>] warn_slowpath_fmt+0x5c/0x80
[ 1623.681307] [<ffffffc000366624>] sysfs_add_one+0x94/0xb4
[ 1623.681315] [<ffffffc0003670b4>] sysfs_do_create_link_sd+0x100/0x1c8
[ 1623.681320] [<ffffffc0003671a8>] sysfs_create_link+0x2c/0x38
[ 1623.681332] [<ffffffc0005d5890>] bus_add_device+0xd8/0x190
[ 1623.681338] [<ffffffc0005d39ec>] device_add+0x2b4/0x604
[ 1623.681349] [<ffffffbffc006dfc>] gb_control_add+0x10/0x40 [greybus]
[ 1623.681362] [<ffffffbffc003dac>] gb_interface_enable+0x20c/0x3b8 [greybus]
[ 1623.681373] [<ffffffbffc002a30>] gb_module_add+0x124/0x174 [greybus]
[ 1623.681385] [<ffffffbffc0082cc>] gb_svc_intf_set_power_mode+0xdd4/0xfe8 [greybus]
[ 1623.681394] [<ffffffc00023888c>] process_one_work+0x268/0x3c8
[ 1623.681400] [<ffffffc000239a64>] worker_thread+0x204/0x358
[ 1623.681410] [<ffffffc00023f43c>] kthread+0xb8/0xc4
[ 1623.681414] ---[ end trace 44489577dd9220db ]---
[ 1623.681818] greybus 1-3.3.ctrl: failed to register control device: -17

Testing Done:
 - Continuous unipro_reset stress test

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-03 10:52:20 +02:00
Johan Hovold
c0219cbf72 greybus: es2: fix arpc active-list corruption
Fix ARPC active-list corruption due to incorrect list-interface usage.

The corruption manifested itself as ARPC timeouts due to expected
responses not being recognised whenever more than one ARPC was active.

This could be seen for example when two interfaces were being runtime
suspended in parallel:

[  165.739896] usb 1-1.1: invalid arpc response id received: 13
[  165.794743] greybus 1-5.5: gb_interface_refclk_set - 0
[  166.241202] usb 1-1.1: failed to execute ARPC: -110

Fortunately the impact of this bug has so far been limited to such
timeouts and error messages due to ARPC currently only being used for
CPort reset in the connection tear-down path.

Reported-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-28 10:04:06 -07:00
Johan Hovold
178457e171 greybus: es2: fix arpc error message
Add missing le16_to_cpu() to an ARPC error message in the receive path,
and also use %u to print the unsigned id.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-28 10:04:06 -07:00
Johan Hovold
fcba5d04c8 greybus: es2: fix arpc response-allocation error handling
The wrong pointer was checked for allocation failures when allocating
the ARPC response buffer, something which would lead to allocation
failures going undetected.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-28 10:04:06 -07:00
Johan Hovold
23931ffb9a greybus: replace Ara references
Replace all occurrences of the term "Ara" with "GMP" in core.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-28 07:30:13 -07:00
Johan Hovold
6c298035a1 greybus: Documentation/sysfs: replace Ara references
Refer to the MDK as GMP MDK.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-28 07:30:13 -07:00
Vaibhav Hiremath
20de72f5de greybus: arche-apb-ctrl: Rename ara,init-disable => arche,init-disable
Inline with other properties used for arche-platform driver,
rename ara,init-disable => arche,init-disable.

Testing Done: Boot tested on EVT2 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-28 07:27:38 -07:00
Gjorgji Rosikopulos
563c742ada greybus: camera: Rename debug and metadata mbus formats
Change ARA prefix to GB_CAM for greyus camera specific
formats.

Change-Id: I1a0552516e8ea727c48085c59fc49f2409a89486
Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Blagovest Borisov Kolenichev <kolenichev_blagovest@projectara.com>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
2016-07-27 17:26:52 -07:00
David Lin
9d3717f71c greybus: audio: add runtime pm to enumerated control and DAPM widget
There's an issue that the userspace is not able to control both the
enumerated control and DAPM widget when audio bundle is in the SUSPEND
state. This patch fixes the issue by adding pm_runtime_get/put() calls
for the both controls.

Testing Done:
 - Use tinymix to get and put both enumerated control and DAPM widget as
   the followings, and observe audio bundle is able to wake up from
   suspend.

$ tinymix "GB 3 PB source" 1
$ tinymix "GB 3 PB source"
GB 3 PB source:	AIF1	>AIF2

$ tinymix "GB 3 AIF1_RX MUX" 2
$ tinymix "GB 3 AIF1_RX MUX"
GB 3 AIF1_RX MUX:	Stereo	Left	>Right

Reported-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 20:58:37 -07:00
David Lin
7c4a0edb38 greybus: svc_watchdog: Add sysfs file to change the behavior of bite
Currently, AP performs unipro_reset if SVC fails to response to its
ping. While this error recovery is best suited for the end-user
experience, errors in the UniPro network could potentially go unnoticed
by the QA and fishfooders in the development phase of the project. This
patch adds an option to trigger a kernel panic so logs can be collected
for analysis.

Testing Done:
 - Reproduce issue and observe kernel panic when
   watchdob_control is changed to 'panic'

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-07-26 20:58:37 -07:00
Viresh Kumar
6136cce89c greybus: firmware: Update Documentation and sample application
Update documentation and sample application to capture the 'status' byte
in backend version operation and new error types in backend firmware
update operation.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 16:16:15 -07:00
Viresh Kumar
5e10f0047a greybus: firmware: Add 'status' byte to backend fw version response
The backend processor may not be ready to return the version of firmware
it is running by the time AP requests for it. The greybus specification
is updated to return 1-byte 'status' to return the error type, RETRY is
one of them.

This patch implements that in greybus now.

Note that the version structure was common across interface and backend
version requests earlier, but that is changing as well.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 16:16:15 -07:00
Viresh Kumar
911415ae6e greybus: firmware: Add new status types for backend updated request
The specification got updated with two more status values, add their
support in greybus.

As retry isn't really an error, skip printing error messages for it as
well.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 16:16:15 -07:00
Viresh Kumar
0c543f9bb2 greybus: interface: Add quirk for no PM for S2 Loader
S2 Loader doesn't support runtime PM operations currently and we will
fail to suspend/resume the bundle for firmware management protocols.

Once that happens, the bundle and its connections will be pretty much
useless as we would have tried to disable/enable all connections during
such an operation and the S2 loader doesn't expect the connections to go
away during normal operation (except in the case of mode-switch).

This patch defines a new quirk GB_INTERFACE_QUIRK_NO_PM and uses a new
interface init status value (GB_INIT_S2_LOADER_INITIALIZED) which will
be advertised by S2 Loader now in the init status.

After detecting the currently running stage as S2 Loader, the kernel
wouldn't attempt suspending or resuming the bundle.

Reviewed-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 15:29:00 -07:00
Viresh Kumar
47cbaf5e55 greybus: interface: Rename *_NO_PM as *_NO_BUNDLE_ACTIVATE
Its a special quirk just for the bootrom as it doesn't have any PM
operations implemented. As the greybus bootrom bundle driver doesn't try
to do any PM stuff, this quirk is used only to skip bundle activate
operation currently.

Rename the GB_INTERFACE_QUIRK_NO_PM quirk to
GB_INTERFACE_QUIRK_NO_BUNDLE_ACTIVATE to suit its purpose better as the
GB_INTERFACE_QUIRK_NO_PM will be used for other quirk now.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 15:29:00 -07:00
Viresh Kumar
c57fbb404a greybus: firmware: Add runtime PM support
This patch implements runtime PM support for firmware management bundle.
This guarantees that the bundle will be active, while the AP or the
Module is trying to exchange any operations over any of the CPorts.

- Firmware Management CPort:

  Runtime PM get/put calls are placed around the ioctl calls, which are
  all implemented as blocking ioctls.

- Component Authentication CPort:

  Runtime PM get/put calls are placed around the ioctl calls, which are
  all implemented as blocking ioctls.

- SPI:

  Uses the interface provided by spilib.c and runtime PM get/put are
  called around connection usage.

- firmware-download:

  This is the most tricky one. All operations on this CPort are
  initiated from the Module and not from the AP. And the AP needs to do
  runtime_pm_get() before any request is received over this CPort.

  The module doesn't send any request over this connection, unless the
  AP has requested the module over firmware management CPort to download
  a firmware package over firmware download CPort.

  And so the runtime PM get/put calls around the ioctls in
  fw-management.c are sufficient to handle the firmware management CPort
  as well.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 15:29:00 -07:00
Johan Hovold
2321f049a9 greybus: operation: clean up request handler
Clean up the incoming request handler somewhat by passing a properly
aligned header and dropping the now redundant id and type parameters.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 14:53:19 -07:00
Johan Hovold
112f563e18 greybus: operation: fix broken response tracepoint
The response-received tracepoint is currently broken. Instead of parsing
the received message header it was tracing a bunch of zeroed fields from
an uninitialised response buffer.

Fix this by moving the tracepoint after were the response buffer is
initialised.

Fixes: 7cb496e6890e ("greybus: tracing: fix message traces")
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 14:53:19 -07:00
Johan Hovold
dfcba8626f greybus: operation: fix broken response error messages
The operation type included in the error message printed for malformed
responses has never been correct. An uninitialised buffer was used to
retrieve the type, resulting in the type always being reported as 0.

Fix this by passing a properly aligned header to the response handler,
and drop the now redundant id and result parameters.

Fixes: cb0ef0c019ab ("operation: print message type on errors")
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 14:53:19 -07:00
Philip Yang
43c85a09b1 greybus: HID: Add runtime pm support
Modify HID greybus driver to support runtime PM framework.
The suspend and resume fucntion have been test with tutorial-hid,
e-ink-display and gpbridge-test image by sysfs resume, all HID
buttons work well on suspend/resume.

Testing Done: Compiled and verified on EVT2, DB3.5, GPB test module
              with daughter board, Red module.

Signed-off-by: Philip Yang <yang_philip@projectara.com>
Reviewed-by: David Lin <dtwlin@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-22 15:25:18 -07:00
Viresh Kumar
68793c4c88 greybus: bootrom: Rename download_firmware() as find_firmware()
The download_firmware() function isn't downloading the firmware but just
finding if one is available or not. The same applies to the error
message printed by it.

Replace 'download' with 'find' to make it sound better.

Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-22 15:25:18 -07:00
Viresh Kumar
40d276ede9 greybus: bootrom: Create gb_bootrom_cancel_timeout()
We set timeouts using gb_bootrom_set_timeout(), which hides the internal
implementation, i.e. workqueues.

While canceling timeouts, we do cancel_delayed_work_sync(), which
exposes the internal implementation and doesn't look that clean.

Create gb_bootrom_cancel_timeout() to hide the internal implementation
here as well.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-22 15:25:18 -07:00
Viresh Kumar
6d9e6ffca4 greybus: bootrom: Set timeout before sending AP_READY
A special race is observed in the case where the phone boots with
modules attached to it.

In that case, the AP processes a later FIRMWARE_SIZE request from the
bootrom, before processing the response to the earlier AP_READY request.
And because of that, we set the timeout from gb_bootrom_probe() after
trying to cancel it from gb_bootrom_firmware_size_request().

And with that, if the firmware package isn't available for the kernel to
directly read from, then we get a timeout print message like below:

[   23.669764] bootrom 1-3.3.1: Firmware file 'ara_00000126_00001001_fffe0001_ffe5001a_s2l.tftf' requested
[   24.680528] bootrom 1-3.3.1: Timed out waiting for Firmware Size Request from the Module

Note that this doesn't happen if the module is inserted into the frame,
after the phone is already booted.

This behavior is the result of an earlier commit cdd1cb3f4943
("operation: add completion work queue").

This perhaps happens only at boot time because the UNBOUND wq
(connection->wq) gets a chance to run on other CPUs, while the BOUND wq
(gb_operation_completion_wq) doesn't at that stage (24 seconds since
boot).

Setting the timeout before sending the AP_READY request fixes it for
now.

Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-22 15:25:18 -07:00
Viresh Kumar
2d6f1c2998 greybus: bootrom: Don't print duplicate error messages
On failing to find a firmware image, we get these today:

bootrom 1-3.3.1: Firmware request for ara_00000126_00001001_fffe0001_ffe5001a_s2l.tftf has failed : -12
bootrom 1-3.3.1: gb_bootrom_firmware_size_request: failed to download firmware (-12)

Which are more or less duplicate, as they print error for the same root
cause.

With this patch this is all we get now:

bootrom 1-3.3.1: failed to download ara_00000126_00001001_fffe0001_ffe5001a_s2l.tftf firmware (-12)

Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-22 15:25:18 -07:00
Viresh Kumar
cc90d6fce8 greybus: bootrom: Skip setting timeout in failure path of size request
The currently set value of next_request_type in the error path of
gb_bootrom_firmware_size_request() is not correct, as it should have
been NEXT_REQ_FIRMWARE_SIZE for the failure case (as we should be
waiting for another similar request).

But, if an error occurs in gb_bootrom_firmware_size_request(), then the
ES3 bootrom will never be able to recover from it and send another
request. And so there is no point waiting for another request and timing
out.

Skip doing that in error path.

Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-22 15:25:18 -07:00
Ann Chen
633e45eaac greybus: vibrator: integrate runtime pm
Integrate greybus drivers with the Linux Kernel RuntimePM framework
for vibrator driver.

Testing Done: AP side (kernel) can control the vibrator driver with
suspend and resume.

Signed-off-by: Ann Chen <chen_ann@projectara.com>
Reviewed-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-22 14:06:39 -07:00
Viresh Kumar
553cba82b1 greybus: control: Print bundle-id in print messages
The new power management specific operations added to the control
protocol do not print the bundle-id in the error messages and it is not
possible to identify which bundle-id the operation failed for.

Fix that and do minor rewriting of the print messages to make them more
readable.

Tested on EVT 2.0 with gpbridge-test module.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-22 13:57:11 -07:00
David Lin
e514dec730 greybus: operation: print id when synchronous operation timeout
In case of a synchronous operation timeout error, it's helpful for
purpose of debugging to print the operation id in the error message, so
that we know if the response is received at a later time after operation
time out.

Testing Done:
 - Observe the error message below when response comes later after
operation timeout:

[  792.973978] greybus greybus1: 0/0:0: synchronous operation id 0x0005
of type 0x21 failed: -110
[  800.646694] greybus greybus1: 0/0:0: unexpected response id 0x0005
received

Signed-off-by: David Lin <dtwlin@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-22 13:57:11 -07:00
Vaibhav Agarwal
098dfaf45e greybus: audio: Avoid using ARA keyword
It is suggested to avoid using ARA keyword externally. So we need to
update GB codec driver. Also, codec name is currently set to 'gb-codec'.
However, it makes more sense to name it as apb-dummy-codec, since it is
used to control various audio modules connected to APB via greybus.

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-07-22 10:26:01 -07:00
Viresh Kumar
92bcaddea3 greybus: spilib: make spilib independent of gbphy
spilib is used by multiple users currently (spi.c and fw-core.c) but
commit aa52b62a0556 broke that hierarchy and introduced gbphy dependent
code in spilib.

This may have unreliable consequences as we are doing following
operation unconditionally now:

	gbphy_dev = to_gbphy_dev(spi->parent);
	gbphy_runtime_get_sync(gbphy_dev);

which may not go well when the parent is of type &bundle->dev
(fw-core.c).

This patch introduces spilib_ops and lets the users of the core register
them. This shall have no functional change for the spi.c usecase and
shall fix the unreliable results for the fw-core.c usecase.

Tested by writing to mtd0 dev and verifying (with print messages) that
the below routines are getting called for a gpbridge-test module.

Fixes: aa52b62a0556 ("spi: Add runtime_pm support")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-21 19:03:05 -07:00
Viresh Kumar
adac4b9594 greybus: firmware: Improve test application
It can take arguments not and we can perform all the operations with a
single binary, sorry for missing that initially.

Usage: ./firmware <gb-fw-mgmt-X> <type: interface/backend> <firmware-tag> <timeout>

And all of them have default values, etc.

Tested with a semco 13 MP module.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-21 19:00:26 -07:00
David Lin
db2951835b greybus: timesync: do not print frametime by default
Currently frametime are being printed whenever an Interface is
runtime-resumed. This is unnecessarily chatty. This patch moves the
frametime print from using pr_info() to dev_dbg().

Testing Done:
 - $ echo "module greybus +p" > /d/dynamic_debug/control

[   97.699395] greybus 1-svc: greybus frametime: ap=2042778707
1-svc=2042775185 greybus1=2042778397 1-6.6=2042778390

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-21 18:58:35 -07:00
Bartosz Golaszewski
f5c93dea8f greybus: pm: add error handling to bundle activation
The firmware now keeps the underlying hardware disabled until
receiving the first Bundle Activate request. Additionally: requesting
transition to a state the bundle is already in is no longer an error.

We can now add proper error handling to the bundle activate call.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-21 18:54:11 -07:00
Johan Hovold
2358024b67 greybus: control: suppress bundle_activate() for bootrom
We always knew backward compatibility with the ES3 bootrom, which was
finalised about a year ago, would be a pain. Here we go again.

The bootrom does not support control requests added after it was burnt
into ROM for obvious reasons. This means that we need to suppress
sending the new bundle_activate() operation to any interface executing
the legacy bootrom.

Do so by adding a new NO_PM interface quirk (we can use the
control-protocol version for this later once we bump it).

Note that the interface-disable path (e.g. for power down) is already
handled by the FORCED_DISABLE quirk, and that the suspend/resume
paths are currently avoided by making sure that the bootrom bundle
never suspends.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-21 16:36:48 -07:00
Joel Porquet
350e3ac2ce greybus: firmware.h: rename TFTF firmware filenames
Replace prefix "ara_" with prefix "gmp_" for TFTF firmware filenames.

Testing Done: compiled and flashed EVT2 (bootimage) and tested that
              "gmp_" prefixed tftf files are expected. Pushed one from
	      FDK and checked that it's properly loaded.

Signed-off-by: Joel Porquet <porquet_joel@projectara.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-21 16:33:25 -07:00
Johan Hovold
b5d1d1282b greybus: interface: fix interface_id attribute group
All interfaces, regardless of type, should have an interface_id
attribute reflecting its position on the frame.

This has been reported to cause an assertion failure in libmoduleutil
for dummy modules.

Testing done: Verified that the attribute is present for registered
dummy interfaces.

Reported-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Tested-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
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-07-21 10:07:00 -07:00
Bryan O'Donoghue
10a24b7c09 greybus: timesync: probe shouldn't complete until FrameTime sync does
Currently the probe() function contains the asynchronous() variant of
FrameTime synchronization. This patch converts to the synchronous() version
of synchronization. This is required for two reasons first a probe() cannot
reasonably be considered to be complete without successfully completing a
time synchronization for Interfaces that care about that sync. Secondly
scheduling the operation asynchronously means its possible the PM-runtime
suspend() path can execute before the async timesync operation completes.
For both reasons we want to run synchronization - synchronously.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 12:07:35 -07:00
Ryan Lim
346bae656e greybus: loopback_test: Add -f argument to cancel all tests
To make sure tests on all devices, enabled or not, are cancelled,
specify -f when starting new loopback test.

Signed-off-by: Ryan Lim <limryan@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 11:23:03 -07:00
Ryan Lim
bf32654a24 greybus: loopback_test: Fix -z argument bug
The -z argument was missing the break statement needed in the switch
block and was not in the getopt list.

Signed-off-by: Ryan Lim <limryan@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 11:23:03 -07:00
Ryan Lim
2861e20790 greybus: loopback_test: Cancel only the tests running on selected devices
When starting a loopback test, it cancels all currently running tests on
all loopback devices. When -m argument is given, which runs the test on
specific loopback devices, only the tests running on the selected
devices need to be cancelled before starting new tests.

Signed-off-by: Ryan Lim <limryan@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 11:23:03 -07:00
Bryan O'Donoghue
93a7388943 greybus: timesync: reduce initial startup time
Currently we have a long initial delay when initiating the first operation
to synchronize the FrameTime. That made sense during development of the
feature since we did synchronization asynchronously and wanted to give some
grace time for new Interfaces to be added before initiating a new
synchronization. On the PM runtime resume path though we do a synchronous
restoration of FrameTime and in this case waiting for 1 second before
initiating the first operation is clearly wrong.

This patch reduces the initial operation time bringing the synchronous call
time down by 990 milliseconds.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 11:16:25 -07:00
Greg Kroah-Hartman
8a704565eb greybus: move all firmware prefix strings to one place
The firmware prefix is hard-coded in a few different places.  Put it all
in one handy #define, for when/if we ever decide to change it in the
future...

Testing: 'strings gb-firmware.ko gb-bootrom.ko | grep ara_' produced the
	 same output before and after this patch.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.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>
2016-07-20 10:29:07 -07:00
Johan Hovold
4f7e413b2d greybus: interface: hibernate UniPro link in activation error path
To be well-behaved, we should hibernate the link before disabling UniPro
in case the link has already been established (i.e. when the interface
type has been detected as UniPro or Greybus).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 10:16:54 -07:00
Johan Hovold
e21e6bad3f greybus: interface: fix power_state documentation
Reword the power_state attribute documentation to make it clear that an
attempt to boot and possibly enumerate an interface is made when writing
"on" to the file, and that on errors the interface will again be powered
down.

Drop the incorrect claim that writing the currently read value has no
effect, since no such guarantees can be made (e.g. several writers may
be sleeping on the interface mutex).

Also fix some minor language issues.

Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 10:16:54 -07:00
Viresh Kumar
93e29c8530 greybus: interface: add power_state attribute
User space needs the capability of powering ON or OFF an Interface for
multiple use cases. For example, userspace may want an Interface
currently in its S3 boot stage, to boot into its S2 Loader stage to
update the bridge SPI flash. Or the Interface is running its S2 Loader
stage and updated the SPI flash with the new S2 Loader firmware and
wants to boot into the new S2 Loader firmware.

Another use case can be, Android wants to disable (not eject) a
misbehaving module.

Add a 'power_state' sysfs file within the interface directory. It can be
read to know the current power state of the Interface and can be written
to power ON or power OFF an Interface. Possible values that can be
written or read from it are: "on" and "off".

Testing Done: Tested by enabling/disabling camera module on EVT 2.0.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
CC: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
[johan: drop es3-quirk duplication, add to power attribute group, fix
return value, drop tags ]
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 10:16:54 -07:00
Johan Hovold
12169bc914 greybus: interface: prevent reactivation during removal
Make sure to prevent an interface that is going away from being
reactivated.

This is needed to preemptively close a race between the upcoming feature
to reactivate a powered-down interface and physical removal (i.e.
module_removed event processing) as well as logical removal (e.g. the
current system-suspend hack).

Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 10:16:54 -07:00
Johan Hovold
62491622db greybus: interface: make sure type is invariant during reactivation
An interface is not expected to change its type after a power down and
reactivation so make sure to treat that as a fatal error.

This is complicated by the current Toshiba ES3 hack which requires us
to retry activation as Greybus interfaces are sometimes misdetected as
UniPro interfaces. Handle that by only retrying activation the first
time an interface is activated, and for interfaces already detected as
having Greybus type.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 10:16:54 -07:00
Johan Hovold
3e93cb6abb greybus: interface: clean up ES3 activation-retry hack
Clean up the ES3 activation retry-hack and isolate it in the interface
code.

This way the retry hack can be reused when we soon start allowing
interfaces to be reactivated after having been powered down.

Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 10:16:54 -07:00
Johan Hovold
27b9e257dd greybus: interface: do not read DME during reactivation
It will soon be possible to reactivate an interface that has been
powered down after already having been activated. In that case there's
no need to re-read the DME attributes as part of activation as the
values are already cached.

Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 10:16:54 -07:00
Johan Hovold
a212b75867 greybus: interface: use an enum for interface type
Use an enum for the interface type instead of using the SVC protocol
values directly.

Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 10:16:54 -07:00
Johan Hovold
6633d80afb greybus: module: suppress activation error message for dummy interfaces
We currently handle dummy interfaces by deactivating them using
activation error paths, but we don't want the corresponding
module_inserted error message to be printed.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-19 19:06:34 -07:00
Johan Hovold
c80a982fc1 greybus: interface: amend interface registration message
Amend the interface registration message with the detected interface
type, and only print the Ara VID/PID and DDBL1 attributes for the types
for which they exist.

Also drop the now redundant message about a detected dummy interface
from the activate operation helper.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-19 19:06:34 -07:00
Johan Hovold
835642526e greybus: interface: make attributes type dependent
Make most interface attributes type dependent (e.g only UniPro and
Greybus interfaces should have a DDBL1 Manufacturer ID attribute).

Note that the power attributes (e.g. current_now) will only be visible
for UniPro- and Greybus-type interfaces (i.e. interfaces that can draw
power).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-19 19:06:34 -07:00
Johan Hovold
441ac1fa9e greybus: interface: partition attribute group
Partition the current attribute group into four groups for UniPro,
Greybus, power and common attributes.

This is a step in refining the interface-type handling as attributes are
type dependent.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-19 19:06:34 -07:00
Johan Hovold
1bb61840c4 greybus: interface: add interface-type attribute
Add an interface-type string attribute that represents the detected
interface type as either "dummy", "unipro", "greybus", or "unknown".

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-19 19:03:32 -07:00
Vaibhav Hiremath
d29b67d44a greybus: arche-platform: Add support for init-off feature
Disable wake_detect interrupt after request

As part of SW-4344/SW-7061, now we are enabling FW flashing
to all builds. That means check for need of FW upgrade is
going to be present in all builds, and moving to FW_FlASHING
mode from active is heavy operation; so the idea here is
simplify this process and save the boot time due to switching
back-n-forth between ACTIVE<=>FW_FLASHING modes.

So we decided to put unipro into OFF state by default on boot,
which can be changed through DT property. If arche-platform
device node has "arche,init-off" property set, then unipro
will be in OFF state on boot. User can bring it back by

 # echo active > /sys/devices/arche_platform*/state

And to simply the exit code of probe() fn the
arche_platform_coldboot_seq() has been shifted to the
bottom of the _probe() fn.

Testing Done: Tested on EVT2 platform, with and without
"arche,init-off" property, multiple times.
Note: I am seeing SW-7128, which is not related to these changes.

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>
2016-07-19 18:31:00 -07:00
Johan Hovold
042fd749ab greybus: connection: drop the svc quiescing operation
Connection tear down is being reworked, and the SVC quiescing operation
is going away.

Let's remove this operation now along with the coupled second ping from
our intermediate tear down implementation.

This both avoids unnecessary noise in the logs resulting from the fact
that the SVC side of the quiescing operation was never merged, and
speeds up connection tear down slightly.

Testing done: Tested on EVT2 using runtime PM.

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>
2016-07-19 18:27:35 -07:00
Rui Miguel Silva
d53cc1c37e greybus: sdio: add switch voltage operation
Core sd/mmc needs the start_signal_voltage_switch operation to be
defined to issue a voltage switch command. So, we define it here even
though we do not need to take in action on it, since all voltage control
is done in the Module.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-19 16:38:24 -07:00
Rui Miguel Silva
484a4d6677 greybus: sdio: convert vdd kernel values to greybus
We need to convert vdd kernel values to greybus ones. And we get this by
shifting the kernel values by 8.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-19 16:38:24 -07:00
Viresh Kumar
56c78715ea greybus: bootrom: Use "s2l" instead of boot stage in package name
The S3 firmware and S3-BFU firmware images will be named like this going
forward:

S3: ara_00000126_00001001_fffe0001_ffe70018_s3f.tftf
S3-BFU: ara_00000126_00001001_fffe0001_ffe70018_s3_bfu.tftf

But the current naming for S2 loader image is:

ara_00000126_00001001_fffe0001_ffe70018_02.tftf

It makes sense to use similar encoding for all three packages and so it
should be named as:

ara_00000126_00001001_fffe0001_ffe70018_s2l.tftf

Because the boot stage is passed from ES3 bootrom, we can't change its
value now. But the string created to match the package name is created
in bootrom.c and that is the only string we create from bootrom.c.

Update bootrom.c to use "s2l" instead of "02" in the package name.

Compile Tested only.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Karthik Ravi Shankar <karthikrs@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-19 13:52:26 -07:00
Bryan O'Donoghue
52764bd8aa greybus: timesync: Bugfix ping should not result in -EAGAIN
gb_timesync_schedule_synchronous() is currently making a synchronous
FrameTime synchronization happen. It does a wait_event_interruptible() and
then goes to check the status of the state-machine. Occasionally the state
indicates PING - which is a completely valid state and should result in a
result code of 0 not -EAGAIN. This patch fixes by making
__gb_timesync_get_status() return 0 instead of -EAGAIN for the PING state.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Tested-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-19 11:16:25 -07:00
Bryan O'Donoghue
1455db9e1b greybus: greybus_protocols.h: convert __u32 to __le32
All 32 bit declarations associated with data interchange to the greybus
network need to be declared explicitly as little-endian since that is the
byte order we use on the greybus network. struct gb_audio_topology is
declaring its variables as u32. Fortunately this structure isn't currently
used so we can do a conversion from u32 to __le32 without any ancillary
code-churn.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-18 09:22:45 -07:00
Bryan O'Donoghue
6a1d29595e greybus: greybus_protocols.h/es2: Ensure __le32 is used not u32
There is a dangling u32 in es2/greybus_protocols.h that is only obvious
when you try to compile up gbsim. We need to do a cpu_to_le32 and declare
the 32-bit int in the header as __le32. This patch does that and splits out
the assignment of the req->flags parameter to a temporary variable to allow
for later printing.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-18 09:22:45 -07:00
Jacopo Mondi
433aa123f5 greybus: camera: Update CSI config parameters
Remove lines_per_second parameter from csi configuration
structure as VFE driver dropped dependency on it

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>
2016-07-17 10:31:21 +09:00
Jacopo Mondi
f88b94ec2a greybus: camera: Configure APB-A with new params
Update the configuration supplied to APB-A to use new parameters, while
keeping compatibility with legacy camera modules.
Substitute hard-coded clock frequency with information provided by camera
module, and retrieve the maximum CSI Long Packet length from the
returned stream configuration.

This patch requires APB-A csi-tx driver to be updated to comply with
newly defined bandwidth requirements.

Testing Done: preview, capture and video recording with updated csi-tx
driver on APB-A side, and legacy white camera module firmware

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>
2016-07-17 10:31:21 +09:00
Jacopo Mondi
d165a618a1 greybus: camera: Update Configure Streams Response
As camera specification gets updated, and Configure Stream Response
payload modified, define here the new response structure.
In order to not break non up-to-date camera modules, keep the existing
structure and add the _deprecated suffix to it.

Add the size of both new and old structure in order to discriminate
dynamically which version of Camera Specification the camera module
implements and translate deprecated version of configure_streams response
in the new one.

In order not to break camera functionalities, for testing purposes,
hard-code values the APB-A CSI Tx driver still requires for proper
interface configuration (lines_per_second and num_lanes)

Testing Done: Preview, capture and video recording with white camera
module and APB-A with legacy firmware implementations

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>
2016-07-17 10:31:21 +09:00
Laurent Pinchart
24f9a6e494 greybus: camera: Hardcode the APB-A CSI-2 TX parameters
Camera modules will stop reporting the number of lines per second,
hardcode the parameter in the driver until the APB-A CSI-2 TX
configuration protocol gets updated as well to use a more appropriate
form of bandwidth information.

The number of data lanes is also hardcoded as it should not depend on
the module's CSI-2 bus configuration.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-17 10:31:21 +09:00
Jacopo Mondi
fdf73c00c8 greybus: camera: Add wrapper for sync operation with flags
The greybus operation core synchronous operation call doesn't support
operation flags. Create a new synchronous operation wrapper with flags,
and modify the capabilities operation implementation to use it.

The code could be later moved to the greybus core if other drivers have
a similar need.

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-17 10:31:21 +09:00
Jacopo Mondi
6cc270483c greybus: camera: Add bpp to Greybus Format description
Add the bytes per pixel value to the structure describing a Greybus
Protocol Image Format.
The bpp information will be used to compute the length in bytes of a
line of pixel data

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-17 10:31:21 +09:00
Viresh Kumar
a0de502ed3 greybus: audio_topology: Fix compile warning
Fix following compile warning by staticizing gb_generate_enum_strings().

greybus/audio_topology.c:134:12: warning: symbol 'gb_generate_enum_strings' was not declared. Should it be static?

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-17 10:12:59 +09:00
Rui Miguel Silva
7a0d4eae83 greybus: power_supply: add missing defines present in the specification
Some of the Greybus properties values (capacity level and scope) even
though they are defined in the specification were missing from the
protocol header.

They still match the kernel ones, but they should be present in there
for protocol sake.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-16 08:05:33 +09:00
Rui Miguel Silva
c10b4ea3b2 greybus: power_supply: remove references to kernel header
In Greybus power supply macro definitions we have a comment that point
to a kernel header, remove it since we have a specification for that.

As at it, align the status values to the upper values.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-16 08:05:33 +09:00
Bryan O'Donoghue
fddd7eafc7 greybus: timesync/pm: Make synchronous call to restore FrameTime
When we discussed and agreed a serialized way to-do PM runtime
suspend/resume we omitted the necessity to restore the FrameTime on resume.
This patch restores the FrameTime synchronously such that when an Interface
PM resume callback completes we have either successfully restored the
FrameTime including the new Interface or we've produced a result code to
indicate what went wrong when trying.

Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Tested-by: David Lin <dtwlin@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-16 08:01:17 +09:00
David Lin
1f77b363be greybus: hd: arche-platform: implement greybus shutdown
Implement platform driver shutdown callback to perform proper greybus
shutdown so that the userspace unipro_shutdown service that shuts down
the APB/SVC abruptly can be removed. The shutdown callback in
arche-platform will first remove SVC so that all the Interface can be
Deactivated in a sequence according to the spec before powering off the
APB:

Before:
 -> Arche/APB power off
 -> SoC power off

After this patch:
 -> HD shutdown
     -> SVC shutdown
         -> Module shutdown
             -> Interface shutdown
                 -> Bundle shutdown
 -> Arche/APB power off
 -> SoC power off

Testing Done:
 - Observe all Interfaces are deactivated in the log during shutdown
 - Measure power off current and make sure no regression

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-16 07:58:52 +09:00
Rui Miguel Silva
47becc556d greybus: power_supply: convert greybus properties to power supply properties
We need to translate greybus properties to power supply core properties,
for that when parsing the properties that were fetch during
configuration we check if there is a match to the running kernel version
and store it in a new field (gb_prop) in the gb_power_supply_prop
struct.

If the corresponding property does not exist in the running
kernel (because of version or vendor specific property) we drop that
property.

A collection of properties that, at this time, may diverge are defined
in the kernel_ver.h to avoid breakage at build time and run time if this
properties are not supported by the kernel.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-16 07:55:41 +09:00
Rui Miguel Silva
6e720c277a greybus: power_supply: change property values to integer
To align with power supply core values type (integer) move the val and
previous_val to integer also.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-16 07:55:41 +09:00
Alex Elder
fc0c38b3d1 greybus: use memdup_user()
Coccinelle reports that there are two opportunities to use memdup_user()
in "authentication.c".  This patch simplifies the code in cap_ioctl() by
taking advantage of that.  Make use of a local variable "size" to improve
readability.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-15 09:14:27 +09:00
Alex Elder
99ade1766d greybus: get rid of a compile warning
The compiler has no way of knowing whether a called function will
actually assign something to the object whose address is passed as
an argument.  So it must assume it won't happen, and this leads to a
compile warning.  Fix this.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-15 09:14:27 +09:00