2021-09-19 05:21:05 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
/*
|
|
|
|
* Reset driver for the StarFive JH7100 SoC
|
|
|
|
*
|
|
|
|
* Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
2023-04-01 04:19:21 -07:00
|
|
|
#include "reset-starfive-jh71x0.h"
|
2021-09-19 05:21:05 -07:00
|
|
|
|
2023-04-01 04:19:22 -07:00
|
|
|
#include <dt-bindings/reset/starfive-jh7100.h>
|
|
|
|
|
|
|
|
/* register offsets */
|
|
|
|
#define JH7100_RESET_ASSERT0 0x00
|
|
|
|
#define JH7100_RESET_ASSERT1 0x04
|
|
|
|
#define JH7100_RESET_ASSERT2 0x08
|
|
|
|
#define JH7100_RESET_ASSERT3 0x0c
|
|
|
|
#define JH7100_RESET_STATUS0 0x10
|
|
|
|
#define JH7100_RESET_STATUS1 0x14
|
|
|
|
#define JH7100_RESET_STATUS2 0x18
|
|
|
|
#define JH7100_RESET_STATUS3 0x1c
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Writing a 1 to the n'th bit of the m'th ASSERT register asserts
|
|
|
|
* line 32m + n, and writing a 0 deasserts the same line.
|
|
|
|
* Most reset lines have their status inverted so a 0 bit in the STATUS
|
|
|
|
* register means the line is asserted and a 1 means it's deasserted. A few
|
|
|
|
* lines don't though, so store the expected value of the status registers when
|
|
|
|
* all lines are asserted.
|
|
|
|
*/
|
2023-04-01 04:19:24 -07:00
|
|
|
static const u32 jh7100_reset_asserted[4] = {
|
2023-04-01 04:19:22 -07:00
|
|
|
/* STATUS0 */
|
2023-04-01 04:19:24 -07:00
|
|
|
BIT(JH7100_RST_U74 % 32) |
|
|
|
|
BIT(JH7100_RST_VP6_DRESET % 32) |
|
|
|
|
BIT(JH7100_RST_VP6_BRESET % 32),
|
2023-04-01 04:19:22 -07:00
|
|
|
/* STATUS1 */
|
2023-04-01 04:19:24 -07:00
|
|
|
BIT(JH7100_RST_HIFI4_DRESET % 32) |
|
|
|
|
BIT(JH7100_RST_HIFI4_BRESET % 32),
|
2023-04-01 04:19:22 -07:00
|
|
|
/* STATUS2 */
|
2023-04-01 04:19:24 -07:00
|
|
|
BIT(JH7100_RST_E24 % 32),
|
2023-04-01 04:19:22 -07:00
|
|
|
/* STATUS3 */
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init jh7100_reset_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
void __iomem *base = devm_platform_ioremap_resource(pdev, 0);
|
|
|
|
|
|
|
|
if (IS_ERR(base))
|
|
|
|
return PTR_ERR(base);
|
|
|
|
|
2023-04-01 04:19:23 -07:00
|
|
|
return reset_starfive_jh71x0_register(&pdev->dev, pdev->dev.of_node,
|
2023-04-01 04:19:22 -07:00
|
|
|
base + JH7100_RESET_ASSERT0,
|
|
|
|
base + JH7100_RESET_STATUS0,
|
|
|
|
jh7100_reset_asserted,
|
|
|
|
JH7100_RSTN_END,
|
|
|
|
THIS_MODULE);
|
|
|
|
}
|
|
|
|
|
2021-09-19 05:21:05 -07:00
|
|
|
static const struct of_device_id jh7100_reset_dt_ids[] = {
|
|
|
|
{ .compatible = "starfive,jh7100-reset" },
|
|
|
|
{ /* sentinel */ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_driver jh7100_reset_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "jh7100-reset",
|
|
|
|
.of_match_table = jh7100_reset_dt_ids,
|
|
|
|
.suppress_bind_attrs = true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
builtin_platform_driver_probe(jh7100_reset_driver, jh7100_reset_probe);
|