Skip to content

Commit

Permalink
Merge tag 'reset-for-5.0-rc2' of git://git.pengutronix.de/git/pza/lin…
Browse files Browse the repository at this point in the history
…ux into fixes

Late reset controller changes for v5.0

This adds missing deassert functionality to the ARC HSDK reset driver,
fixes some indentation and grammar issues in the kernel docs, adds a
helper to count the number of resets on a device for the non-DT case
as well, adds an early reset driver for SoCFPGA and simple reset driver
support for Stratix10, and generalizes the uniphier USB3 glue layer
reset to also cover AHCI.

* tag 'reset-for-5.0-rc2' of git://git.pengutronix.de/git/pza/linux:
  reset: uniphier-glue: Add AHCI reset control support in glue layer
  dt-bindings: reset: uniphier: Add AHCI core reset description
  reset: uniphier-usb3: Rename to reset-uniphier-glue
  dt-bindings: reset: uniphier: Replace the expression of USB3 with generic peripherals
  ARM: socfpga: dts: document "altr,stratix10-rst-mgr" binding
  reset: socfpga: add an early reset driver for SoCFPGA
  reset: fix null pointer dereference on dev by dev_name
  reset: Add reset_control_get_count()
  reset: Improve reset controller kernel docs
  ARC: HSDK: improve reset driver

Signed-off-by: Olof Johansson <[email protected]>
  • Loading branch information
olofj committed Jan 13, 2019
2 parents 56acb3e + d0c2d21 commit 4656121
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 52 deletions.
3 changes: 2 additions & 1 deletion Documentation/devicetree/bindings/reset/socfpga-reset.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Altera SOCFPGA Reset Manager

Required properties:
- compatible : "altr,rst-mgr"
- compatible : "altr,rst-mgr" for (Cyclone5/Arria5/Arria10)
"altr,stratix10-rst-mgr","altr,rst-mgr" for Stratix10 ARM64 SoC
- reg : Should contain 1 register ranges(address and length)
- altr,modrst-offset : Should contain the offset of the first modrst register.
- #reset-cells: 1
Expand Down
25 changes: 14 additions & 11 deletions Documentation/devicetree/bindings/reset/uniphier-reset.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,30 @@ Example:
};


USB3 core reset
---------------
Peripheral core reset in glue layer
-----------------------------------

USB3 core reset belongs to USB3 glue layer. Before using the core reset,
it is necessary to control the clocks and resets to enable this layer.
These clocks and resets should be described in each property.
Some peripheral core reset belongs to its own glue layer. Before using
this core reset, it is necessary to control the clocks and resets to enable
this layer. These clocks and resets should be described in each property.

Required properties:
- compatible: Should be
"socionext,uniphier-pro4-usb3-reset" - for Pro4 SoC
"socionext,uniphier-pxs2-usb3-reset" - for PXs2 SoC
"socionext,uniphier-ld20-usb3-reset" - for LD20 SoC
"socionext,uniphier-pxs3-usb3-reset" - for PXs3 SoC
"socionext,uniphier-pro4-usb3-reset" - for Pro4 SoC USB3
"socionext,uniphier-pxs2-usb3-reset" - for PXs2 SoC USB3
"socionext,uniphier-ld20-usb3-reset" - for LD20 SoC USB3
"socionext,uniphier-pxs3-usb3-reset" - for PXs3 SoC USB3
"socionext,uniphier-pro4-ahci-reset" - for Pro4 SoC AHCI
"socionext,uniphier-pxs2-ahci-reset" - for PXs2 SoC AHCI
"socionext,uniphier-pxs3-ahci-reset" - for PXs3 SoC AHCI
- #reset-cells: Should be 1.
- reg: Specifies offset and length of the register set for the device.
- clocks: A list of phandles to the clock gate for USB3 glue layer.
- clocks: A list of phandles to the clock gate for the glue layer.
According to the clock-names, appropriate clocks are required.
- clock-names: Should contain
"gio", "link" - for Pro4 SoC
"link" - for others
- resets: A list of phandles to the reset control for USB3 glue layer.
- resets: A list of phandles to the reset control for the glue layer.
According to the reset-names, appropriate resets are required.
- reset-names: Should contain
"gio", "link" - for Pro4 SoC
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/mach-socfpga/socfpga.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ void __iomem *rst_manager_base_addr;
void __iomem *sdr_ctl_base_addr;
unsigned long socfpga_cpu1start_addr;

extern void __init socfpga_reset_init(void);

static void __init socfpga_sysmgr_init(void)
{
struct device_node *np;
Expand Down Expand Up @@ -64,6 +66,7 @@ static void __init socfpga_init_irq(void)

if (IS_ENABLED(CONFIG_EDAC_ALTERA_OCRAM))
socfpga_init_ocram_ecc();
socfpga_reset_init();
}

static void __init socfpga_arria10_init_irq(void)
Expand All @@ -74,6 +77,7 @@ static void __init socfpga_arria10_init_irq(void)
socfpga_init_arria10_l2_ecc();
if (IS_ENABLED(CONFIG_EDAC_ALTERA_OCRAM))
socfpga_init_arria10_ocram_ecc();
socfpga_reset_init();
}

static void socfpga_cyclone5_restart(enum reboot_mode mode, const char *cmd)
Expand Down
20 changes: 14 additions & 6 deletions drivers/reset/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ config RESET_QCOM_PDC

config RESET_SIMPLE
bool "Simple Reset Controller Driver" if COMPILE_TEST
default ARCH_SOCFPGA || ARCH_STM32 || ARCH_STRATIX10 || ARCH_SUNXI || ARCH_ZX || ARCH_ASPEED
default ARCH_STM32 || ARCH_STRATIX10 || ARCH_SUNXI || ARCH_ZX || ARCH_ASPEED
help
This enables a simple reset controller driver for reset lines that
that can be asserted and deasserted by toggling bits in a contiguous,
Expand All @@ -128,6 +128,14 @@ config RESET_STM32MP157
help
This enables the RCC reset controller driver for STM32 MPUs.

config RESET_SOCFPGA
bool "SoCFPGA Reset Driver" if COMPILE_TEST && !ARCH_SOCFPGA
default ARCH_SOCFPGA
select RESET_SIMPLE
help
This enables the reset driver for the SoCFPGA ARMv7 platforms. This
driver gets initialized early during platform init calls.

config RESET_SUNXI
bool "Allwinner SoCs Reset Driver" if COMPILE_TEST && !ARCH_SUNXI
default ARCH_SUNXI
Expand Down Expand Up @@ -163,15 +171,15 @@ config RESET_UNIPHIER
Say Y if you want to control reset signals provided by System Control
block, Media I/O block, Peripheral Block.

config RESET_UNIPHIER_USB3
tristate "USB3 reset driver for UniPhier SoCs"
config RESET_UNIPHIER_GLUE
tristate "Reset driver in glue layer for UniPhier SoCs"
depends on (ARCH_UNIPHIER || COMPILE_TEST) && OF
default ARCH_UNIPHIER
select RESET_SIMPLE
help
Support for the USB3 core reset on UniPhier SoCs.
Say Y if you want to control reset signals provided by
USB3 glue layer.
Support for peripheral core reset included in its own glue layer
on UniPhier SoCs. Say Y if you want to control reset signals
provided by the glue layer.

config RESET_ZYNQ
bool "ZYNQ Reset Driver" if COMPILE_TEST
Expand Down
3 changes: 2 additions & 1 deletion drivers/reset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ obj-$(CONFIG_RESET_QCOM_AOSS) += reset-qcom-aoss.o
obj-$(CONFIG_RESET_QCOM_PDC) += reset-qcom-pdc.o
obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o
obj-$(CONFIG_RESET_STM32MP157) += reset-stm32mp1.o
obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.o
obj-$(CONFIG_RESET_TI_SYSCON) += reset-ti-syscon.o
obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o
obj-$(CONFIG_RESET_UNIPHIER_USB3) += reset-uniphier-usb3.o
obj-$(CONFIG_RESET_UNIPHIER_GLUE) += reset-uniphier-glue.o
obj-$(CONFIG_RESET_ZYNQ) += reset-zynq.o

42 changes: 42 additions & 0 deletions drivers/reset/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,45 @@ devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
return rstc;
}
EXPORT_SYMBOL_GPL(devm_reset_control_array_get);

static int reset_control_get_count_from_lookup(struct device *dev)
{
const struct reset_control_lookup *lookup;
const char *dev_id;
int count = 0;

if (!dev)
return -EINVAL;

dev_id = dev_name(dev);
mutex_lock(&reset_lookup_mutex);

list_for_each_entry(lookup, &reset_lookup_list, list) {
if (!strcmp(lookup->dev_id, dev_id))
count++;
}

mutex_unlock(&reset_lookup_mutex);

if (count == 0)
count = -ENOENT;

return count;
}

/**
* reset_control_get_count - Count number of resets available with a device
*
* @dev: device for which to return the number of resets
*
* Returns positive reset count on success, or error number on failure and
* on count being zero.
*/
int reset_control_get_count(struct device *dev)
{
if (dev->of_node)
return of_reset_control_get_count(dev->of_node);

return reset_control_get_count_from_lookup(dev);
}
EXPORT_SYMBOL_GPL(reset_control_get_count);
1 change: 1 addition & 0 deletions drivers/reset/reset-hsdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static int hsdk_reset_reset(struct reset_controller_dev *rcdev,

static const struct reset_control_ops hsdk_reset_ops = {
.reset = hsdk_reset_reset,
.deassert = hsdk_reset_reset,
};

static int hsdk_reset_probe(struct platform_device *pdev)
Expand Down
13 changes: 3 additions & 10 deletions drivers/reset/reset-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct reset_simple_devdata {
#define SOCFPGA_NR_BANKS 8

static const struct reset_simple_devdata reset_simple_socfpga = {
.reg_offset = 0x10,
.reg_offset = 0x20,
.nr_resets = SOCFPGA_NR_BANKS * 32,
.status_active_low = true,
};
Expand All @@ -120,7 +120,8 @@ static const struct reset_simple_devdata reset_simple_active_low = {
};

static const struct of_device_id reset_simple_dt_ids[] = {
{ .compatible = "altr,rst-mgr", .data = &reset_simple_socfpga },
{ .compatible = "altr,stratix10-rst-mgr",
.data = &reset_simple_socfpga },
{ .compatible = "st,stm32-rcc", },
{ .compatible = "allwinner,sun6i-a31-clock-reset",
.data = &reset_simple_active_low },
Expand Down Expand Up @@ -166,14 +167,6 @@ static int reset_simple_probe(struct platform_device *pdev)
data->status_active_low = devdata->status_active_low;
}

if (of_device_is_compatible(dev->of_node, "altr,rst-mgr") &&
of_property_read_u32(dev->of_node, "altr,modrst-offset",
&reg_offset)) {
dev_warn(dev,
"missing altr,modrst-offset property, assuming 0x%x!\n",
reg_offset);
}

data->membase += reg_offset;

return devm_reset_controller_register(dev, &data->rcdev);
Expand Down
88 changes: 88 additions & 0 deletions drivers/reset/reset-socfpga.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2018, Intel Corporation
* Copied from reset-sunxi.c
*/

#include <linux/err.h>
#include <linux/io.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/reset-controller.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/types.h>

#include "reset-simple.h"

#define SOCFPGA_NR_BANKS 8
void __init socfpga_reset_init(void);

static int a10_reset_init(struct device_node *np)
{
struct reset_simple_data *data;
struct resource res;
resource_size_t size;
int ret;
u32 reg_offset = 0x10;

data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;

ret = of_address_to_resource(np, 0, &res);
if (ret)
goto err_alloc;

size = resource_size(&res);
if (!request_mem_region(res.start, size, np->name)) {
ret = -EBUSY;
goto err_alloc;
}

data->membase = ioremap(res.start, size);
if (!data->membase) {
ret = -ENOMEM;
goto err_alloc;
}

if (of_property_read_u32(np, "altr,modrst-offset", &reg_offset))
pr_warn("missing altr,modrst-offset property, assuming 0x10\n");
data->membase += reg_offset;

spin_lock_init(&data->lock);

data->rcdev.owner = THIS_MODULE;
data->rcdev.nr_resets = SOCFPGA_NR_BANKS * 32;
data->rcdev.ops = &reset_simple_ops;
data->rcdev.of_node = np;
data->status_active_low = true;

return reset_controller_register(&data->rcdev);

err_alloc:
kfree(data);
return ret;
};

/*
* These are the reset controller we need to initialize early on in
* our system, before we can even think of using a regular device
* driver for it.
* The controllers that we can register through the regular device
* model are handled by the simple reset driver directly.
*/
static const struct of_device_id socfpga_early_reset_dt_ids[] __initconst = {
{ .compatible = "altr,rst-mgr", },
{ /* sentinel */ },
};

void __init socfpga_reset_init(void)
{
struct device_node *np;

for_each_matching_node(np, socfpga_early_reset_dt_ids)
a10_reset_init(np);
}
Loading

0 comments on commit 4656121

Please sign in to comment.