Commit graph

49 commits

Author SHA1 Message Date
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
Vaibhav Hiremath
db5a3bca56 greybus: arche-platform: Convert delayed work to do only hub3613 configuration
This is preparation of interrupt handling support, where APB coldboot
and wake/detect handling will be handled as response to wake/detect
interrupt.
Due to slower I2C write operations in HUB configuration, it is important
to separate HUB configuration, and probably delay it after APB is
cold booted.

Note that delayed work will be scheduled from interrupt handler,
in following patches.

To satisfy build (and bisect), remove apb_cold_boot() fn, which will be
added back in the patch where it gets used again.

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
6743a6fd96 greybus: arche-platform: Fix exit path in probe fn
If SVC coldboot fails or if of_platform_populate() fn fails,
then state of device needs to be reverted.

Importantly, if of_platform_populate() fails, then poweroff the SVC.

Testing Done: Tested on DB3.5 platform.

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-24 17:36:16 -08:00
Vaibhav Hiremath
25847ee7c9 greybus: arche-platform: Avoid doing same thing again in poweroff fn
If user switches from fw_flashing => off mode, then we do not need
to do same things again, for example, clk_disable and wake/detect event,
as while switching to fw_flashing, driver makes sure that device goes
to off state and then brings back in fw_flashing state.

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
599159b687 greybus: arche-platform: 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
ad4d3f95c9 greybus: arche-platform: Control usb3613 from arche-platform
USB3613 hub driver exports control function, which allows caller
to switch the mode of operation of hub device.
As we know that, we have dependency between HUB3613 and APB's where,
HUB supposed to enter into HUB only after APB's brought out of reset.

Until now, we had all userspace driver sequences to control this,
but now since we are moving all resource management strictly to the
driver, it makes sense (even though it looks hacky) to enable control
of hub3613 from arche-platform driver.

Note that, there is another discussion where, the hub.connect IO pin may
get interfaced with MSM gpio, at that time, we can get rid of this hack
and replace it with gpio control.

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
b032493908 greybus: arche-platform: 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
fd60ac5856 greybus: arche-platform: Fix boot, poweroff and fw_flashing seq with APBs
Now SVC driver has an access to APBs operational functions
(coldboot, standby_boot, fw_flashing and poweroff), SVC driver
can control APB's as per below rules,

 - If SVC goes down (poweroff state), it will also power off APBs
   and vice a versa for all operational states.
 - On boot, SVC will probe/populate APB device, but will not coldboot
   it. APBs will coldboot only after handshaking with SVC over
   wake/detect line.
   Note that, both APBs share same wake/detect line.

So from user/developer perspective, it is highly recommended that
they should use arche-platform interfaces, instead of individual
apb interface,

 # echo [off/active/standby/fw_flashing] > /sys/devices/arche_platform.*/state

Note: 'standby' mode is not supported as of now.

Testing Done: Testd 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
7691fed20e greybus: arche-platform: Introduce FW_FLASHING state
Introduce FW_FLASHING state to arche-platform driver, to enable
user space to flash/upgrade SVC firmware.

Command to enter into flashing state:

  # echo fw_flashing > /sys/devices/arche_platform.*/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
2923c58eb5 greybus: arche_platform: Add sysfs to allow user to change state
This patch introduces sysfs interface for the user space to enable
operational state change of the driver.
Currently, driver supports, 'off', 'active' and 'standby'

Note that, driver doesn't do anything for standby state as of today.

To see the current state

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

And to change the state
      # echo [off/active/standby] > /sys/devices/arche_platform.*/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
b4c95fca6a greybus: arche-platform: Pull wake/detect low in poweroff
When SVC goes down, make sure that wake/detect is also pulled low.
Note that this is not the criteria for SVC poweroff, but it is required
to have right state on wake/detect line before powering off.
And on next boot, the boot-sequence code would take care of
handshaking with SVC.

Tested-on: 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
e74d04a581 greybus: arche-platform: Add state variable to driver data
This is preparation for operational state support.
So in order to provide operational state transitions, driver needs to
maintain state. So add 'enum arche_platform_state' variable to
'struct arche_platform_drvdata'

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
5993e2bfd8 greybus: arche-platform: Rename cleanup fn to poweroff_seq
In sync with operational states, rename arche_platform_cleanup() fn
to arche_platform_poweroff_seq() 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
49e6e04bb4 greybus: arche-platform: Cancel delayed_work in driver remove fn
This is a bug fix, where as part of cleanup, delayed work was not
canceled in driver remove function. So fix it.

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:17:04 -08:00
Vaibhav Hiremath
758ca99de9 greybus: arche-platform: Introduce coldboot_seq fn
This is preparation for support for different operational states
(defined by arche_platform_state) in the driver, to enable
user/developer to dynamically configure the state.

arche_platform_coldboot_seq() fn will be responsible for
rebooting SVC device.

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
Michael Scott
a3043d9e71 greybus: arche-platform: reduce wait between WAKE_OUT checks
SVC WAKE_OUT loop is estimated 400ms during which wake_detect line
is pulled low for AP detection.  On AP side we have 500ms delay
between checks.  To avoid timing issues, reduce delay between
checks and raise total # of checks so that overall time for sequence
is the same.

Testing Done:
- Used for DB3.5/EVT1.5 hardware during bringup
- Regression tested on DB3.1+ES2, DB3.1+ES3

Signed-off-by: Michael Scott <michael.scott@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-29 08:50:13 -08:00
Michael Scott
1e83ee3321 greybus: arche-platform: assert wake-detect to complete WAKE_OUT event
After SVC generates WAKE_OUT (pulling wake-detect pin low) and APB is
brought out of reset, we need to assert wake-detect again to complete
SVC WAKE_OUT logic.

Testing Done:
- Used for DB3.5/EVT1.5 hardware during bringup
- Regression tested on DB3.1+ES2, DB3.1+ES3

Signed-off-by: Michael Scott <michael.scott@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-29 08:50:13 -08:00
Michael Scott
9e1aef82af greybus: arche-platform: bring SVC out of reset later in probe
Move SVC deassert reset to after wake-detect pin has been pulled
low in probe.  Otherwise, SVC may trigger WAKE_OUT based on a
default high signal.

Testing Done:
- Used for DB3.5/EVT1.5 hardware during bringup
- Regression tested on DB3.1+ES2, DB3.1+ES3

Signed-off-by: Michael Scott <michael.scott@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-29 08:50:13 -08:00
Michael Scott
057aad29f9 greybus: arche-platform: ensure wake-detect pin is deasserted
During DB3.5 bringup, it was noted that wake_detect signal was not
properly generating SVC edge IRQ.  To ensure signal goes from low
to high correctly, let's bring signal low (regardless of default
pin state).

Testing Done:
- Used for DB3.5/EVT1.5 hardware during bringup
- Regression tested on DB3.1+ES2, DB3.1+ES3

Signed-off-by: Michael Scott <michael.scott@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-29 08:50:13 -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
a463fc1533 greybus: arche-platform: Add wake/detect support along with handshaking with AP
Add wake_detect support to arche-platform driver which is responsible
for SVC control. This patch also adds code for handshaking between
AP <=> SVC. The sequence is,

1.   AP boots
     To keep compatibility between DB3 and EVT platform, SVC will be
     help in reset and AP driver would release it at appropriate time.
	 wake/detect pin (WD8A) = Low
	 reset (SVC/APB1/APB2) = Asserted (as per polarity)
2.   AP Driver gets inserted
  2.1. AP will deassert reset to SVC (following power on sequence)
  2.2. SVC allows 360 milliseconds to elapse after switch boots to work
       around bug described in ENG-330.
  2.3. AP asserts wake/detect pin (WD8A = HIGH)
3.   SVC detects assertion of wake/detect pin, and sends "wake out" signal to AP
4.   AP receives "wake out" signal, takes AP Bridges through their power
     on reset sequence as defined in the bridge ASIC reference manuals
5.   AP takes USB3613 through its power on reset sequence
6.   AP should enumerates AP Bridges

Note: ISR has been deliberately removed (not merged) as we are still
not sure how it will be used, in runtime usage context. Driver as such
doesn't do anything for runtime assert-n-deassert of reset to SVC/APB's,
it just simply offloads it to user by exporting required gpio's.
The exported gpio's are required for FW flashing from user space.
When it comes to usersace manipulated control sequence, user has to manage.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
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
f1f251b59b greybus: arche-platform: propagate errors returned by gpiolib
Propagate errors returned by of_get_named_gpio() instead of sending
-ENODEV.

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
140741ec63 greybus: arche-platform: svc_reset_gpio can't be invalid in arche_platform_cleanup()
svc_reset_gpio is guaranteed to be valid in arche_platform_cleanup. Drop
the useless check.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-11 15:58:01 -08:00
Viresh Kumar
72a8c24b6d greybus: arche-platform: Put APB in reset if of_platform_populate() fails
The current implementation around of_platform_populate() is not so
great. On error, we first print an error message, followed by a success
message and finally we return an error.

And over that we don't undo what we did initially.

This patch puts the APB back into reset and create a separate error
path to make things clear.

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
8adf71d1b4 greybus: arche-platform: Export GPIOs after populating APBs
Populating APBs operation can potentially fail and it would be better if
we export the GPIOs towards then end of the routine, so that we don't
need to unexport them on error cases.

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
73658f2a28 greybus: arche-platform: arche_pdata is guaranteed to be valid
arche_pdata is guaranteed to be valid in arche_platform_remove().

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
6da86df3a4 greybus: arche-platform: Export gpio (reset & sys_boot) to user
In order to allow user to flash the firmware to,

SVC:
user need to assert the reset first, set sysboot pin and
deassert reset. And then issue a flashing command.

And APB:
User need to assert the reset first, and then issue flashing
command.

So this patch exports the gpio's to user.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-06 20:00:35 -08:00
Greg Kroah-Hartman
1e5dd1f827 greybus: arche-platform: merge arche-apb-ctrl and arche-platform
No need to have two separate arche platform drivers, that's just crazy,
so merge them both together to be only one kernel module.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
2016-01-04 16:05:25 -08:00
Vaibhav Hiremath
bc142bbb4c greybus: arche_platform: Remove child's platform device as part of _remove() fn
It seems we need to delete platform_dev of all childs explicitly,
in _remove() fn callback of parent driver.
There were some discussions about having of_platform_unpopulate(),
but it never made it to mainline.

https://lkml.org/lkml/2013/7/19/615

There are some drivers which are removing platform_dev explicitly,
as done in this patch.

Note that, without this, multiple insmod-rmmod won't work, as I see
driver probe gets invoked twice and leads to failure of probe.

Signed-off-by: Vaibhav Hiremath <hiremath_vaibhav@projectara.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-30 13:18:32 -08:00
Vaibhav Hiremath
7fa6065475 greybus: arche-platform: Rename db3-platform to arche-platform
With multiple platforms getting rolled into ara,
db3 name is confusing. And this driver is applicable
to all arche platforms, so make sense to rename it to
arche-platform.c. Also rename all internal functions
accordingly.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-22 17:40:43 -08:00
Renamed from drivers/staging/greybus/db3-platform.c (Browse further)