reset: Add Tegra BPMP reset driver

This contains a patch which implements a reset driver using the services
 provided by the BPMP firmware (via the MRQ_RESET request).
 -----BEGIN PGP SIGNATURE-----
 
 iQIwBAABCAAaBQJYLyWXExx0cmVkaW5nQG52aWRpYS5jb20ACgkQ3SOs138+s6Gd
 cBAAqPY+xhbFwTKID/tWuR0bJ1gPG3gN3rjz2ZhY6aEvaGdyjMC9b5TTfvUKjj72
 Az7ewYrEWJwNdQ5D1zNY5hF+NTexLggskGzynnjufGJNcc+pVTq25tbitA9//aUr
 DK/1JIvgph9K40JG8kXLjbdh8bAX9Zfq46R/ymkxIla70Wedf0GJQ7c7+EPCCt6q
 E3yA4n5FA84hO/Z9h28fCSJ2tiusWSEh6q6rqc+nXcSaneQu+To8Ve2NB6tz7Bov
 fRuc1c+FCmlMO67vQWLuY9LkpNfUPy7ohNKWBsMAN+xCAKvMc+C7LDqofxo8JRQ7
 wmpj9DPY1wr1J12uA/gcgB39LC1ZcaUEna8MvvE4+jJ4teoWy5x47BbE4FJ7anyB
 vHHyDFOF5Gye7TjNeQIIpRrD2Hvqv5uvVJO4YIf2tGSJh+fgNjvWVh1XMYfpBguF
 hHjZCwAE+Pyket6e2gG/O3xieFXMuOkANvaT2w5MTAFHEulyMAYiEDika2SMK2je
 zuSgLVU8rS6G2EXdIJMf46nzRrHc46+LCXes8yJkqD3B9ZraRsQFu8hIhKzKIEg/
 iBuM/Ajc7bn+jfqqhRD4kAr+SkXnQmUbfgaAgpfiu0LwYFdQGi5k2s8zLHQxnILt
 CIIS7qcwdWqkRYbohF/Mc+7pcEbEDtq4622OmJC03KhIZ3E=
 =t06j
 -----END PGP SIGNATURE-----

Merge tag 'tegra-for-4.10-reset' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into next/drivers

reset: Add Tegra BPMP reset driver

This contains a patch which implements a reset driver using the services
provided by the BPMP firmware (via the MRQ_RESET request).

* tag 'tegra-for-4.10-reset' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux:
  reset: Add Tegra BPMP reset driver

Signed-off-by: Olof Johansson <olof@lixom.net>
This commit is contained in:
Olof Johansson 2016-11-18 18:31:56 -08:00
commit 857ff3fddc
5 changed files with 76 additions and 0 deletions

View File

@ -94,5 +94,6 @@ config RESET_ZYNQ
source "drivers/reset/sti/Kconfig"
source "drivers/reset/hisilicon/Kconfig"
source "drivers/reset/tegra/Kconfig"
endif

View File

@ -1,6 +1,7 @@
obj-y += core.o
obj-y += hisilicon/
obj-$(CONFIG_ARCH_STI) += sti/
obj-$(CONFIG_ARCH_TEGRA) += tegra/
obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o

View File

@ -0,0 +1,2 @@
config RESET_TEGRA_BPMP
def_bool TEGRA_BPMP

View File

@ -0,0 +1 @@
obj-$(CONFIG_RESET_TEGRA_BPMP) += reset-bpmp.o

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2016 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/reset-controller.h>
#include <soc/tegra/bpmp.h>
#include <soc/tegra/bpmp-abi.h>
static struct tegra_bpmp *to_tegra_bpmp(struct reset_controller_dev *rstc)
{
return container_of(rstc, struct tegra_bpmp, rstc);
}
static int tegra_bpmp_reset_common(struct reset_controller_dev *rstc,
enum mrq_reset_commands command,
unsigned int id)
{
struct tegra_bpmp *bpmp = to_tegra_bpmp(rstc);
struct mrq_reset_request request;
struct tegra_bpmp_message msg;
memset(&request, 0, sizeof(request));
request.cmd = command;
request.reset_id = id;
memset(&msg, 0, sizeof(msg));
msg.mrq = MRQ_RESET;
msg.tx.data = &request;
msg.tx.size = sizeof(request);
return tegra_bpmp_transfer(bpmp, &msg);
}
static int tegra_bpmp_reset_module(struct reset_controller_dev *rstc,
unsigned long id)
{
return tegra_bpmp_reset_common(rstc, CMD_RESET_MODULE, id);
}
static int tegra_bpmp_reset_assert(struct reset_controller_dev *rstc,
unsigned long id)
{
return tegra_bpmp_reset_common(rstc, CMD_RESET_ASSERT, id);
}
static int tegra_bpmp_reset_deassert(struct reset_controller_dev *rstc,
unsigned long id)
{
return tegra_bpmp_reset_common(rstc, CMD_RESET_DEASSERT, id);
}
static const struct reset_control_ops tegra_bpmp_reset_ops = {
.reset = tegra_bpmp_reset_module,
.assert = tegra_bpmp_reset_assert,
.deassert = tegra_bpmp_reset_deassert,
};
int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp)
{
bpmp->rstc.ops = &tegra_bpmp_reset_ops;
bpmp->rstc.owner = THIS_MODULE;
bpmp->rstc.of_node = bpmp->dev->of_node;
bpmp->rstc.nr_resets = bpmp->soc->num_resets;
return devm_reset_controller_register(bpmp->dev, &bpmp->rstc);
}