brintos

brintos / linux-shallow public Read only

0
0
Text · 2.0 KiB · 2a56f7f Raw
75 lines · c
1// SPDX-License-Identifier: GPL-2.0-or-later2/*3 * Reset driver for the StarFive JH7100 SoC4 *5 * Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>6 */7 8#include <linux/mod_devicetable.h>9#include <linux/platform_device.h>10 11#include "reset-starfive-jh71x0.h"12 13#include <dt-bindings/reset/starfive-jh7100.h>14 15/* register offsets */16#define JH7100_RESET_ASSERT0	0x0017#define JH7100_RESET_ASSERT1	0x0418#define JH7100_RESET_ASSERT2	0x0819#define JH7100_RESET_ASSERT3	0x0c20#define JH7100_RESET_STATUS0	0x1021#define JH7100_RESET_STATUS1	0x1422#define JH7100_RESET_STATUS2	0x1823#define JH7100_RESET_STATUS3	0x1c24 25/*26 * Writing a 1 to the n'th bit of the m'th ASSERT register asserts27 * line 32m + n, and writing a 0 deasserts the same line.28 * Most reset lines have their status inverted so a 0 bit in the STATUS29 * register means the line is asserted and a 1 means it's deasserted. A few30 * lines don't though, so store the expected value of the status registers when31 * all lines are asserted.32 */33static const u32 jh7100_reset_asserted[4] = {34	/* STATUS0 */35	BIT(JH7100_RST_U74 % 32) |36	BIT(JH7100_RST_VP6_DRESET % 32) |37	BIT(JH7100_RST_VP6_BRESET % 32),38	/* STATUS1 */39	BIT(JH7100_RST_HIFI4_DRESET % 32) |40	BIT(JH7100_RST_HIFI4_BRESET % 32),41	/* STATUS2 */42	BIT(JH7100_RST_E24 % 32),43	/* STATUS3 */44	0,45};46 47static int __init jh7100_reset_probe(struct platform_device *pdev)48{49	void __iomem *base = devm_platform_ioremap_resource(pdev, 0);50 51	if (IS_ERR(base))52		return PTR_ERR(base);53 54	return reset_starfive_jh71x0_register(&pdev->dev, pdev->dev.of_node,55					      base + JH7100_RESET_ASSERT0,56					      base + JH7100_RESET_STATUS0,57					      jh7100_reset_asserted,58					      JH7100_RSTN_END,59					      THIS_MODULE);60}61 62static const struct of_device_id jh7100_reset_dt_ids[] = {63	{ .compatible = "starfive,jh7100-reset" },64	{ /* sentinel */ }65};66 67static struct platform_driver jh7100_reset_driver = {68	.driver = {69		.name = "jh7100-reset",70		.of_match_table = jh7100_reset_dt_ids,71		.suppress_bind_attrs = true,72	},73};74builtin_platform_driver_probe(jh7100_reset_driver, jh7100_reset_probe);75