Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+76
+1
drivers/reset/Kconfig
··· 94 94 95 95 source "drivers/reset/sti/Kconfig" 96 96 source "drivers/reset/hisilicon/Kconfig" 97 + source "drivers/reset/tegra/Kconfig" 97 98 98 99 endif
+1
drivers/reset/Makefile
··· 1 1 obj-y += core.o 2 2 obj-y += hisilicon/ 3 3 obj-$(CONFIG_ARCH_STI) += sti/ 4 + obj-$(CONFIG_ARCH_TEGRA) += tegra/ 4 5 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o 5 6 obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o 6 7 obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
+2
drivers/reset/tegra/Kconfig
··· 1 + config RESET_TEGRA_BPMP 2 + def_bool TEGRA_BPMP
+1
drivers/reset/tegra/Makefile
··· 1 + obj-$(CONFIG_RESET_TEGRA_BPMP) += reset-bpmp.o
+71
drivers/reset/tegra/reset-bpmp.c
··· 1 + /* 2 + * Copyright (C) 2016 NVIDIA Corporation 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License version 2 as 6 + * published by the Free Software Foundation. 7 + */ 8 + 9 + #include <linux/reset-controller.h> 10 + 11 + #include <soc/tegra/bpmp.h> 12 + #include <soc/tegra/bpmp-abi.h> 13 + 14 + static struct tegra_bpmp *to_tegra_bpmp(struct reset_controller_dev *rstc) 15 + { 16 + return container_of(rstc, struct tegra_bpmp, rstc); 17 + } 18 + 19 + static int tegra_bpmp_reset_common(struct reset_controller_dev *rstc, 20 + enum mrq_reset_commands command, 21 + unsigned int id) 22 + { 23 + struct tegra_bpmp *bpmp = to_tegra_bpmp(rstc); 24 + struct mrq_reset_request request; 25 + struct tegra_bpmp_message msg; 26 + 27 + memset(&request, 0, sizeof(request)); 28 + request.cmd = command; 29 + request.reset_id = id; 30 + 31 + memset(&msg, 0, sizeof(msg)); 32 + msg.mrq = MRQ_RESET; 33 + msg.tx.data = &request; 34 + msg.tx.size = sizeof(request); 35 + 36 + return tegra_bpmp_transfer(bpmp, &msg); 37 + } 38 + 39 + static int tegra_bpmp_reset_module(struct reset_controller_dev *rstc, 40 + unsigned long id) 41 + { 42 + return tegra_bpmp_reset_common(rstc, CMD_RESET_MODULE, id); 43 + } 44 + 45 + static int tegra_bpmp_reset_assert(struct reset_controller_dev *rstc, 46 + unsigned long id) 47 + { 48 + return tegra_bpmp_reset_common(rstc, CMD_RESET_ASSERT, id); 49 + } 50 + 51 + static int tegra_bpmp_reset_deassert(struct reset_controller_dev *rstc, 52 + unsigned long id) 53 + { 54 + return tegra_bpmp_reset_common(rstc, CMD_RESET_DEASSERT, id); 55 + } 56 + 57 + static const struct reset_control_ops tegra_bpmp_reset_ops = { 58 + .reset = tegra_bpmp_reset_module, 59 + .assert = tegra_bpmp_reset_assert, 60 + .deassert = tegra_bpmp_reset_deassert, 61 + }; 62 + 63 + int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp) 64 + { 65 + bpmp->rstc.ops = &tegra_bpmp_reset_ops; 66 + bpmp->rstc.owner = THIS_MODULE; 67 + bpmp->rstc.of_node = bpmp->dev->of_node; 68 + bpmp->rstc.nr_resets = bpmp->soc->num_resets; 69 + 70 + return devm_reset_controller_register(bpmp->dev, &bpmp->rstc); 71 + }