Commit graph

80 commits

Author SHA1 Message Date
Uwe Kleine-König
7846a2ae5c staging: greybus: arche: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230403154014.2564054-6-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-04-03 21:49:54 +02:00
Nickalas Cason
3a9aaf047a staging: greybus: correct typo in comment
Correct misspelling in comment. Issue found with checkpatch.

Signed-off-by: Nickalas Cason <nickalas@cason.dev>
Link: https://lore.kernel.org/r/20220430230139.7i772mvejlhevamn@desktop
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-05-05 23:19:14 +02:00
Beatriz Martins de Carvalho
0778f04b0b staging: greybus: arche-platform: Ending line with argument
Remove checkpatch check "CHECK: Lines should not end with a '('"
with argument present in next line.

Signed-off-by: Beatriz Martins de Carvalho <martinsdecarvalhobeatriz@gmail.com>
Link: https://lore.kernel.org/r/20210401090754.116522-1-martinsdecarvalhobeatriz@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-04-02 14:56:34 +02:00
Greg Kroah-Hartman
ec0ad86817 staging: greybus: move core include files to include/linux/greybus/
With the goal of moving the core of the greybus code out of staging, the
include files need to be moved to include/linux/greybus.h and
include/linux/greybus/

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Cc: Rui Miguel Silva <rmfrfs@gmail.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Alex Elder <elder@kernel.org>
Link: https://lore.kernel.org/r/20190825055429.18547-8-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-27 19:02:59 +02:00
Nishad Kamdar
4207b5870d staging: greybus: arche-platform: Switch to the gpio descriptor interface
Use the gpiod interface instead of the deprecated old non-descriptor
interface while continuing to ignore gpio flags from device tree in
"svc_reset_onoff()" for now.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-15 16:18:14 +01:00
Arvind Yadav
a2e63709b5 staging: greybus: Use gpio_is_valid()
Replace the manual validity checks for the GPIO with the
gpio_is_valid().

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-29 15:25:52 +02:00
Wolfram Sang
1dab154ef1 staging: greybus: simplify getting .drvdata
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.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>
2018-04-23 15:39:08 +02:00
Kamal Heib
07df5b7c94 staging: greybus: arche-platform.c: Fix alignment should match open parenthesis
Fix "alignment should match open parenthesis" checkpatch.pl error.

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 14:58:30 +01:00
Greg Kroah-Hartman
863dbc52e7 staging: greybus: Remove redundant license text
Now that the SPDX tag is in all greybus files, that identifies the
license in a specific and legally-defined manner.  So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-11 14:46:21 +01:00
Greg Kroah-Hartman
eb50fd3a22 staging: greybus: add SPDX identifiers to all greybus driver files
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/staging/greybus files files with the correct SPDX
license identifier based on the license text in the file itself.  The
SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-11 14:46:20 +01:00
Eames Trinh
4a27e3e09d Staging: greybus: Fix spelling error in comment
Fixed a spelling error.

Signed-off-by: Eames Trinh <eamestrinh@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-22 18:33:19 -07:00
Amitoj Kaur Chawla
100330ecc4 staging: greybus: Remove unnecessary platform_set_drvdata
Unnecessary platform_set_drvdata() has been removed since the driver
core clears the driver data to NULL after device release or on
probe failure. There is no need to manually clear the device
driver data to NULL.

The Coccinelle semantic patch used to make this change is as follows:
//<smpl>
@@
struct platform_device *pdev;
@@
- platform_set_drvdata(pdev, NULL);
//</smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-27 21:48:06 -07:00
Mitchell Tasman
bf766625ae staging: greybus: arche: wrap over-length lines
Adjust formatting of several comments to keep line length within
the 80 column limit preferred by the Linux kernel coding style.

Signed-off-by: Mitchell Tasman <tasman@leaflabs.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-16 08:40:58 +02:00
Arnd Bergmann
0687090acf staging: greybus: mark PM functions as __maybe_unused
Enabling the arche platform for compile testing showed a harmless
warning with CONFIG_PM=n:

drivers/staging/greybus/arche-platform.c:632:12: error: 'arche_platform_resume' defined but not used [-Werror=unused-function]
drivers/staging/greybus/arche-platform.c:618:12: error: 'arche_platform_suspend' defined but not used [-Werror=unused-function]

This marks the functions as __maybe_unused to shut up the warnings.

Fixes: 2eccd4aa19 ("staging: greybus: enable compile testing of arche driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-18 16:07:08 +02:00
Johan Hovold
2eccd4aa19 staging: greybus: enable compile testing of arche driver
Add Arche platform-driver config option and allow the driver to be
compile tested also without the out-of-tree usb3613 driver.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-16 13:39:16 +02:00
Johan Hovold
1e029b8361 staging: greybus: arche: remove timesync remains
Remove the remaining timesync bits that were left in the arche platform
driver and which prevented the driver from being compiled.

Fixes: bdfb95c4ba ("staging: greybus: remove timesync protocol support")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-16 13:39:16 +02:00
Gioh Kim
461ab8077d staging: greybus: fix "line over 80 characters" coding style issues
This patch fixes only obvious lines.
There are still more issues.

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-12 13:26:14 +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
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
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
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
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
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
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
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
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
Bryan O'Donoghue
970dc85bd9 greybus: timesync: Add timesync core driver
This patch adds the core timesync functionality.

0. arche-platform.c/arche-apb-ctrl.c
   Modifies the platform layer to hook the incoming TIME_SYNC signal up to
   the timesync strobe IRQ handler. If the arche-platform driver can't
   satisfy the request for the wake-detect line, it will return -EAGAIN and
   the calling work-queue must reschedule the attempt to get exclusive
   access to the wake-detect pin logic. A private data field is added to
   the arche-platform driver to enable passing of a timesync pointer to the
   ISR responsible for synchronizing time.

1. timesync.c
   A new file added which contains all of the logic associated with sending
   greybus commands to SVC, APBx or Interfaces to enable, disable and
   disseminate timing information.

2. timesync_platform.c
   Any platform/arch specific code goes into timesync_platform.c.
   Originally the idea was to keep the x86 and ARM arch dependencies in a
   timesync_platform_arch.c file - however with further refinement that's
   currently not necessary however just-in-case it becomes necessary to
   resuscitate arch or platform specific methods for accessing timer
   resources that access shouldn't be part of the core timesync.c logic and
   so for the moment we access these timer resources through a thin access
   layer in timesync_platform.c. Expect this to go away long term ideally.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-06-06 20:37:47 -07:00
Vaibhav Hiremath
7a867d149f greybus: arche-platform: Enable SVC clock during FW_FLASHING state
The issue is, as part of kernel-only build we started seeing
failures in SVC FW flashing. It was reproducible easily in kernel-only
build, but never observed on Android build.

During debugging, there were couple of observations,

1. If SVC clock enabled and disables (which is REFCLK_MAIN), then SVC FW
   flashing works.
2. If we do not switch SVC to HSE (external clock source) it works.
   Recently, SVC code has been updated to switch HSE clock, so removing
   it (remove/skip rcc_switch_ara_pll() fn) would use internal clock only.

As per STM32 spec, for flashing through USART we do not need
to enable HSE, but the above observation contradicts with it.

There is still something missing in terms of understanding of how STM32
device functions as far as Flashing is concerned. There is something
hidden in HW, which probably still need to identify.

So as a interim solution we will enable clock for FW_FLASHING state,
which seems to be fixing the issue here.

Testing Done: Tested on EVT1.5 with arche6.0 and kernel-only build.

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-05-25 22:36:45 -07:00
Vaibhav Hiremath
0b1283e33f greybus: arche-platform: Enter ACTIVE state only from OFF state
Make sure that, transition to active state happens only from OFF state.
Instead of imposing the restriction to user-space, driver internally
switches to OFF state and then to ACTIVE state.

Testing Done: Tested on EVT1.5 platform.

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-05-25 22:36:45 -07:00
Vaibhav Hiremath
c61a8b4984 greybus: arche-platform: Make fw_flashing_seq() return error
Make arche_platform_fw_flashing_seq() return error value, needed
later when we add clock enable support for FW flashing.

Testing Done: Tested on EVT1.5 platform.

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-05-25 22:36:45 -07:00
Bryan O'Donoghue
d7be800f7a greybus: Fix unbalanced irq_enable() backtrace
Tip-of-tree is exhibiting a backtrace when loading-up the set of greybus
kernel modules due to calling arche_platform_wd_irq_en() directly after a
call to devm_request_threaded_irq().

At the point we call arch_platform_wd_irq_en() the relevant IRQ will
already be enabled. What we want to do in this situation is configure the
GPIO line as an input. This patch fixes the backtrace by supplanting
arche_platform_wd_irq_en() with
gpio_direction_input(arche_pdata->wake_detect_gpio) in
arche_platform_probe().

WARNING: at msm-ara-3.10/kernel/irq/manage.c:457 __enable_irq+0x74/0xc0()
Unbalanced enable for IRQ 687
Modules linked in: gb_arche(O+) gb_camera(O) gb_es2(O) gb_vibrator(O)
gb_raw(O) gb_power_supply(O) gb_loopback(O) gb_light(O) gb_hid(O)
greybus(O)
CPU: 0 PID: 415 Comm: insmod Tainted: G        W  O 3.10.78-g2a4dec8 #65
Call trace:
[<ffffffc000206adc>] dump_backtrace+0x0/0x248
[<ffffffc000206d34>] show_stack+0x10/0x1c
[<ffffffc000c6c698>] dump_stack+0x1c/0x28
[<ffffffc00021c95c>] warn_slowpath_common+0x74/0x9c
[<ffffffc00021c9d0>] warn_slowpath_fmt+0x4c/0x58
[<ffffffc000269d7c>] __enable_irq+0x70/0xc0
[<ffffffc000269e34>] enable_irq+0x68/0x7c
[<ffffffbffc0609b4>] arche_platform_probe+0x3b4/0x4f4 [gb_arche]
[<ffffffc0005ace30>] platform_drv_probe+0x14/0x20
[<ffffffc0005ab980>] driver_probe_device+0x160/0x374
[<ffffffc0005abc40>] __driver_attach+0x60/0x90
[<ffffffc0005aa768>] bus_for_each_dev+0x74/0x94
[<ffffffc0005ab2c4>] driver_attach+0x1c/0x28
[<ffffffc0005aae74>] bus_add_driver+0x124/0x248
[<ffffffc0005ac270>] driver_register+0x94/0x110
[<ffffffc0005ad3c4>] platform_driver_register+0x58/0x64
[<ffffffbffc065020>] $x+0x20/0x58 [gb_arche]
[<ffffffc0002007dc>] do_one_initcall+0xb0/0x14c
[<ffffffc00028252c>] load_module+0x19d0/0x1b18
[<ffffffc00028278c>] SyS_init_module+0x118/0x130

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiermath@linaro.org>
Tested-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-23 14:49:58 -07:00
Vaibhav Hiremath
7ba535ec69 greybus: arche-platform: Rename assert_wakedetect=>arche_platform_wd_irq_en
Now, since AP module does not send any signal to SVC, so it
automatically restricts the wake/detect gpio to input.
So rename assert_wakedetect() fn to arche_platform_wd_irq_en(),
as per implementation.

Testing Done: Tested on EVT1.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-20 16:31:26 -07:00
Vaibhav Hiremath
16fd976c39 greybus: arche-platform: Do not assert wake/detect signal to SVC
With new definition of AP module boot flow (from HotPlug camp),
AP is not supposed to send any wake/detect signal to SVC, instead,
during boot SVC would straight away send wake_out pulse on wake/detect
line.
Note that, pin configuration of wake/detect line would be set to
active-high by default, so wake/detect line would always stay high,
unless SVC drives it. AP module uses wake/detect line strictly in input
mode.

Testing Done: Tested on EVT1.5 platform.

Note: We are yet to decide on PM support for APBx, so we may need to
generate/handshake with SVC over wake/detect line in the future. As of
now, follow the implementation and add stuff as and when they come.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-20 16:31:26 -07:00
Sandeep Patil
a974f469ff greybus: arche-platform: Fix the MODULE_LICENSE to match with header
The header calls out the license to be GPL v2, while the module declares
itself as "GPL"

Testing Done: Trivial

Signed-off-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 11:20:53 +02:00
Bryan O'Donoghue
c4058b7926 greybus: arche-platform: Rework platform/wd-line state transition logic
This patch simplifies and improves the readability of the internal state
transition logic of arche platform driver state transition logic by:

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

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

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

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

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

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

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

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:49:02 -07:00
Viresh Kumar
7b62b61c75 greybus: arche-ctrl: Don't expose driver internals to arche-platform driver
We have chosen the *ugly* way of registering two platform drivers from
the module_init() of only one of them, so that we can avoid having two
separate modules for them.

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

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-23 09:37:21 +09:00
David Lin
9160b7c765 greybus: arche-platform: Power-off unipro subsystem upon suspend
Switch off APBs/SVC/Switch in the suspend call notifier. Note that
this is an interim solution to enable fishfooding.

Testing done:
 - Passed QA sanity test on EVT1.5
 - Suspend current measured at ~70mW

Signed-off-by: David Lin <dtwlin@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: Updated commit description]
Tested-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-15 14:42:53 -07:00
Vaibhav Hiremath
a7ddda1f5a greybus: arche-platfrom: Get rid of 2sec delay in USB3613 configuration
Earlier during boot sequence implementation, we had seen race between
USb3613 and APB boot, and since APB boot time is ~2sec, we delayed
USb3613 configuration for 2sec after APB deassertion of reset.

This obviously won't work in the case of suspend/resume, where we would
like to put APB into OFF state and coldboot in resume.

With the latest FW changes, we do not see any race issue. I have done
regression testing (> 50 iteration of reboot + unipro link up and down)
without any issues.

So lets get rid of the 2sec delay with this patch.

Testing Done: Tested on EVT 1.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: David Lin <dtwlin@google.com>
Reviewed-by: David Lin <dtwlin@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-12 22:20:11 -07:00
David Lin
7fe9301422 greybus: arche-platform: fix incorrect gpio variable type
GPIO number obtained from of_get_named_gpio() should be signed to allow
error handling.

Testing Done:
Built & booted on EVT1.5

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-08 06:21:21 -08:00
Vaibhav Hiremath
e915ce48ba greybus: arche-platform: Disable HUB3613 only in APB poweroff fn
HUB3613 configuration, either disable (Standby mode) or enable (HUB mode)
is related to APB. So it makes perfect sense to put both of them
together in one function.

HUB3613 enable happens only at one place, in hub_conf_delayed_work() fn,
but disable is initiated from multiple places.
Move all calls to usb3613_hub_mode_ctrl(false) to apb_poweroff().

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 16:28:17 -08:00
Vaibhav Hiremath
ff788de0b4 greybus: arche-platform: Make sure APB power cycles on coldboot
On first wake/detect pulse, everything works fine, as APB would be
in poweroff state initially.
But on subsequent wake/detect pulses, where APB is already in active
state, internal function just returns doing nothing, as it finds that
device is already in active state.

So the solution would be to make sure that, whenever execution reaches
to coldboot, make sure we power cycle it. Power off first, before
powering on.

Interrupt handler takes care of ignoring < 30msec pulses, so we should
be safe here to power cycle APB.

Testing Done: Testd on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 16:28:17 -08:00
Vaibhav Hiremath
d2320b2dbf greybus: arche-platform: Disable wake/detect interrupt in poweroff
In poweroff() fn, we are shutting down SVC, so disable interrupt
as well.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 16:24:23 -08:00
Vaibhav Hiremath
0786212d6c greybus: arche-platform: Set direction of wake/detect gpio in poweroff fn
With support of interrupt based mechanism, gpio is not longer set to
output mode, so gpio_set_value won't work. So use
gpio_direction_output() fn in poweroff(), while setting value on
wake/detect line.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 16:24:23 -08:00
Vaibhav Hiremath
16fe18ca9e greybus: arche-platform: Assert wake/detect after SVC reset without delay
Since now driver supports interrupt based mechanism to read events
from SVC over wake/detect line, no need to delay wake/detect assertion.
We can assert wake/detect after SVC reset deassertion, so during boot
itself SVC will start sending wake_out pulses.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 16:24:23 -08:00
Vaibhav Hiremath
f760bbfb5c greybus: arche-platform: Enable interrupt support on wake/detect line
This patch enabled interrupt support on events received over wake/detect
line. The driver follows below state machine,

Default: wake/detect line is high (WD_STATE_IDLE)
On Falling edge:
  SVC initiates boot (either cold/standby).
  On ES3, > 30msec = coldboot, else standby boot.
  Driver moves to WD_STATE_BOOT_INIT
On rising edge (> 30msec):
  SVC expects APB to coldboot
  Driver wakes irq thread which kicks off APB  coldboot
  (WD_STATE_COLDBOOT_TRIG)
On rising edge (< 30msec):
  Driver ignores it, do nothing.

After coldboot of APB, HUB configuration work is scheduled after 2 sec,
allowing enough time for APB<->SVC/Switch to linkup (in multiple
iterations)

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 16:24:23 -08:00
Vaibhav Hiremath
685353c12e greybus: arche-platform: Add wake detect state based on functionality
If driver needs to process wake/detect events from SVC, by enabling
interrupt support on wake/detect event, it becomes easier to maintain
state of wake/detect line based on functionality.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 16:24:23 -08:00