Commit graph

54 commits

Author SHA1 Message Date
Uwe Kleine-König
9b19a31c20 staging: greybus: arche-apb-ctrl: 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-5-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-04-03 21:49:54 +02:00
Jaehee Park
5a9bdd6fd6 staging: greybus: correct typo in comment
Correct a spelling typo from 'Atleast' to 'At least' in comment.
Issue found by checkpatch.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jaehee Park <jhpark1013@gmail.com>
Link: https://lore.kernel.org/r/2feb03de97ca4dbd27c22cf40f8e185f7dfaae29.1649824370.git.jhpark1013@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-13 08:49:48 +02:00
Nishad Kamdar
fbacec8f2a staging: greybus: arche-apb-ctrl.c: 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
functions "deassert_reset()" and "assert_reset()" 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
Ioannis Valasakis
fea06c0ba4 staging: greybus: remove multiple blank lines
Remove continuous multiple blank lines.
Reported by checkpatch.

Signed-off-by: Ioannis Valasakis <code@wizofe.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-09 09:49:03 -08:00
Kamal Heib
339744e242 staging: greybus: arche-apb-ctrl.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
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
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
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
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
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
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
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
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
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
037a4028be greybus: arche-apb-ctrl: Remove extra delay in APB reset
With synchronization between SVC <=> AP over wake/detect line to
bring APB's out of reset, we do not need any extra delays now.
So remove it.

Testing Done: Tested for DB3.5 and EVT1.2 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
c5e7cbaf3a greybus: arche-apb-ctrl: Return immediately if in same state from state change fns
Have a check inside all individual operational state change functions
to check whether device is in same state, and if yes, then return
immediately.

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-23 22:43:06 -08:00
Vaibhav Hiremath
ee97e24ac6 greybus: arche-apb-ctrl: Do not coldboot APBs in probe
Since parent driver (SVC) is controlling APBs directly, we do not
need to bringup APBs in its own probe.

Testing Done: Tested on EVT1.2.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-16 19:11:34 -08:00
Vaibhav Hiremath
bc8eadd46c greybus: arche-apb-ctrl: Do not export any gpios
With addition of operational state in driver, user/developer
can switch to FW flashing state through sysfs. So no need to
export any gpios to userspace now.

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-15 13:18:40 -08:00
Vaibhav Hiremath
65fd5a5018 greybus: arche-apb-ctrl: Export operational fns from driver
In order to use single wake/detect line for both APB's we need to have
access to APB operational functions to parent/SVC driver.
So export coldboot, standby_boot, fw_flashing and poweroff operation
functions from the driver.

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-15 13:18:40 -08:00
Vaibhav Hiremath
80a057aa6c greybus: arche-apb-ctrl: Rename internal operational state fns
This is preparation for enabling export set of operational fns
to parent driver.
So it is important to differentiate internal ops function against
externally accessed (from parent).

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-15 13:18:40 -08:00
Vaibhav Hiremath
af3aae10f1 greybus: arche-apb-ctrl: Introduce ara,init-disable property for APB
New DT property "ara,init-disable" will allow user to disable
APB1 or APB2 during boot and enable it only when needed through
command prompt via sysfs interface.

 - To disable APB2 during boot, specify "ara,init-disable" property in
   respective APB node.

 - How to check the state
   # cat /sys/devices/arche_platform.*/apb*/state

   It should be 'off', if 'ara,init-disable' enabled in DT.

 - During runtime if user/developer desired to enable APB2 (strictly and
   only for development purpose) then respective APB can be enabled
   through,

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

Note:
  - If APB device is in 'off,disabled' state, then no state transitions
    are permitted.
  - User/developer must first activate APB device

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

    This will clear the 'init-disable' flag and allow state transition
    from here onwards.
    Note that, 'off,disabled' is only indicative state and is only
    applicable during init/boot.

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-15 13:18:40 -08:00
Vaibhav Hiremath
33d7629107 greybus: arche-apb-ctrl: Add sysfs to allow user to change state
This patch introduces sysfs interface for the user space to enable
state change of the driver. Driver supports below operational
states,

 - off
 - active
 - standby
 - fw_flashing

To see the current state

i # cat /sys/devices/arche_platform.*/apb*/state

And to change the state
 # echo [off/active/standby/fw_flashing] > /sys/devices/arche_platform.*/apb*/state

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-15 13:18:40 -08:00
Vaibhav Hiremath
6961e04665 greybus: arche-apb-ctrl: Pass only platform_device to _seq fns
Pass only pointer to platform_device to _seq fns and fetch handle to
arche_apb_ctrl_drvdata from platform_device.

This is preparation for support for dynamic switching between operational
states for the device, where these functions will be called from parent
driver.

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-15 13:18:40 -08:00
Vaibhav Hiremath
f2222a41db greybus: arche-apb-ctrl: Set default state value to OFF
Explicitly set default apb->state value to ARCHE_PLATFORM_STATE_OFF
in probe() fn.

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-15 13:18:40 -08:00
Vaibhav Hiremath
5667ab1799 greybus: arche-apb-ctrl: Rename init_seq and cleanup fn
apb_ctrl_coldboot_seq() and apb_ctrl_poweroff_seq()
is appropriate name as per spec and implementation, so rename it.
Also move apb_ctrl_poweroff_seq() fn above, to group it with
other _seq functions.

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-15 13:18:40 -08:00
Vaibhav Hiremath
6ceed512e6 greybus: arche-apb-ctrl: Re-arrange init sequence
In order to allow APB2 disable by default on boot/init, and also
provide interface to user to enable it later on, re-arrange the init_seq
fn.
The idea here is, the apb_ctrl_init_seq() fn will be renamed to
apb_ctrl_coldboot_seq(), and should not try to claim any resources.
All the resource claim should happen in apb_ctrl_get_devtree_data() fn.

And also uses devm_gpio_request_one() fn wherever possible.

Testing Done: Tested on EVT1.2 and DB3.5  platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-15 13:18:40 -08:00
Vaibhav Hiremath
a821adb47d greybus: arche-platform: make apb_state common to both platform drivers
Make 'enum apb_state' common to both platform drivers, so that
both drivers can make use of same state and user will have
unified control configuration across devices (SVC, APB1 and APB2)

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-12 23:01:32 -08:00
Vaibhav Hiremath
f6d6f5bd29 greybus: Revert "arche-apb-ctrl: Remove extra delay in APB reset"
We are seeing failures on DB3.1 board, and Axel root-caused it to this
commit, so revert it as of now.

This reverts commit 942627227684c187b727ba5fb581bc2d886b6708.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-09 09:56:14 -08:00
Vaibhav Hiremath
6084653541 greybus: arche-apb-ctrl: Remove extra delay in APB reset
With synchronization between SVC <=> AP over wake/detect line to
bring APB's out of reset, we do not need any extra delays now.
So remove it.

Testing Done: Tested for 10 iterations on EVT1

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-05 16:23:22 -08:00
Vaibhav Hiremath
d8b16338df greybus: arche-platform: Disable clock as part of driver remove
As part of driver remove (cleanup) function, disable the clock for both
SVC, APB1 & APB2.

Testing Done:
Tested on EVT1 platform with Connect=>disconnect=>connect
iteration, almost close to 100 iterations have passed (demo branch).
And also tested with kernel-only build.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-25 20:08:55 -08:00
Vaibhav Hiremath
aa187d3312 greybus: arche-apb-ctrl: Enable the clocks after regulator enable
It makes more sense to enable the clock after power is enabled
to the device, so move clock enable code after regulator_enable
and setting up BOOT_RET pin.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Tested-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-13 15:54:55 -08:00
Vaibhav Hiremath
f1e9cbd5a0 greybus: arche-apb-ctrl: deassert reset at the end of probe
Now the complete handshaking between AP<=>SVC would be
offloaded to parent driver (arche-platform) who is
responsible for SVC control, so the apb-ctrl driver can
just simply bring APB's out of reset during probe itself.

Along with deasserting reset, this patch renames the local fn
to exclusively use it for reset purpose.

Note that, driver is exporting reset gpio to
user, so user can still flash FW from prompt.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:10 -08:00
Vaibhav Hiremath
33036178bf greybus: arche-apb-ctrl: Remove wake_detect gpio and related code
With TIME_SYNC functionality, assignment of wake/detect pin
will change,
  WD_8A => to bring APB's out of reset
  WD_8B => TIME_SYNC operation

So in order to support this, we can no longer keep wake_detect
gpio in apb-ctrl driver. So remove it.
In the subsequent patches, wake_detect support will be added
to parent SVC driver (arche-platform) who is responsible for SVC control.

Note that, this patch also removes ISR related code.
The APB state still is maintained, for future use.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:10 -08:00
Viresh Kumar
3b858df01f greybus: arche: Remove unwanted headers and rearrange others
This removes few unwanted headers related to irq, interrupt, regulator,
spinlock, etc.

Also arrange the rest in alphabetical order to make it more readable.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Viresh Kumar
40989cf3c1 greybus: arche-apb: Drop unnecessary checks
wake_detect_gpio and resetn_gpio are guaranteed to be valid in
apb_ctrl_cleanup() and irq-handler, no need to check for their validity.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Viresh Kumar
d258432fb2 greybus: arche-apb: Do cleanup within apb_ctrl_init_seq() for error cases
Relying on apb_ctrl_cleanup() to do the cleanup for errors that occurred
within apb_ctrl_init_seq() isn't a very clean idea. Handle that
separately within apb_ctrl_init_seq().

This will clean apb_ctrl_cleanup() in later patches.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Viresh Kumar
a7a794ec54 greybus: arche-apb: Don't use gpio after failing to request it
If devm_gpio_request() returns an error, we shouldn't try to set the
direction of the same gpio.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Viresh Kumar
db0cff554a greybus: arche-apb: Properly use dev_err/info/warn
Use dev_err for errors after which we need to abort the currently
running routine and dev_warn for resource allocation failure, with which
we can continue to work.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Viresh Kumar
dcf77c3979 greybus: arche-apb: NULL is a valid regulator
Since NULL could in theory be a valid regulator we ought to check for
IS_ERR() rather than for NULL. In practice this is unlikely to be an
issue but it's better for neatness.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Viresh Kumar
bd62fa5e10 greybus: arche-apb: devm_regulator_get() doesn't return NULL
And so we don't need to check for it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Viresh Kumar
7541c1a1c6 greybus: arche-apb: Replace gpio_is_valid() with gpio < 0 checks
There can be no invalid values in the DTS. The actual pin numbers are
assigned by gpiolib when the gpio controller is registered.

And so a simple 'gpio < 0' is enough instead of gpio_is_valid() which
also checks for 'gpio < ARCH_NR_GPIOS'.

This will make the usage of of_get_named_gpio() similar with how it is
done in arche-platform driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Viresh Kumar
977ff25075 greybus: arche-apb: platform data 'apb' is guaranteed to be valid
Platform data 'apb' is guaranteed to be valid in arche_apb_ctrl_remove()
and so no need to check it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Viresh Kumar
3b538c399c greybus: arche-apb: Spelling and whitespace fixes
- s/premits/permits
- Remove blank lines at the end of the file

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Vaibhav Hiremath
e49268cc33 greybus: arche-apb-ctrl: Do not bring APB out of reset in probe
With addition of handshaking between AP <=> SVC, driver
brings out APB out of reset only on reception of WAKE_MOD
signal from SVC. So remove the deassertion from probe.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-06 20:03:18 -08:00
Vaibhav Hiremath
ae0bf3a628 greybus: arche-apb-ctrl: Set wake_detect gpio to low initially
This patch enables handshaking of AP and SVC using wake_detect
gpio (WD_8A and WD_8B).
Note that WAKE_DETECT polarity is active-high, so in order to
enable handshaking between AP <=> SVC, we need to set wake_detect
gpio to low initially, so that driver can send WAKE_DET signal
(active-high) to SVC and then SVC can send back WAKE_MOD signal
(active-low).
And on reception of WAKE_MOD signal, driver would bring respective
APB out of reset.

  WD_8A => APB1
  WD_8B => APB2

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-06 20:03:18 -08:00