1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Amlogic Meson Reset Controller driver
5 * Copyright (c) 2016-2024 BayLibre, SAS.
6 * Authors: Neil Armstrong <narmstrong@baylibre.com>
7 * Jerome Brunet <jbrunet@baylibre.com>
10 #include <linux/err.h>
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <linux/regmap.h>
16 #include <linux/reset-controller.h>
18 #include "reset-meson.h"
20 static const struct meson_reset_param meson8b_param
= {
21 .reset_ops
= &meson_reset_ops
,
25 .level_low_reset
= true,
28 static const struct meson_reset_param meson_a1_param
= {
29 .reset_ops
= &meson_reset_ops
,
33 .level_low_reset
= true,
36 static const struct meson_reset_param meson_s4_param
= {
37 .reset_ops
= &meson_reset_ops
,
41 .level_low_reset
= true,
44 static const struct meson_reset_param t7_param
= {
48 .level_low_reset
= true,
51 static const struct of_device_id meson_reset_dt_ids
[] = {
52 { .compatible
= "amlogic,meson8b-reset", .data
= &meson8b_param
},
53 { .compatible
= "amlogic,meson-gxbb-reset", .data
= &meson8b_param
},
54 { .compatible
= "amlogic,meson-axg-reset", .data
= &meson8b_param
},
55 { .compatible
= "amlogic,meson-a1-reset", .data
= &meson_a1_param
},
56 { .compatible
= "amlogic,meson-s4-reset", .data
= &meson_s4_param
},
57 { .compatible
= "amlogic,c3-reset", .data
= &meson_s4_param
},
58 { .compatible
= "amlogic,t7-reset", .data
= &t7_param
},
61 MODULE_DEVICE_TABLE(of
, meson_reset_dt_ids
);
63 static const struct regmap_config regmap_config
= {
69 static int meson_reset_probe(struct platform_device
*pdev
)
71 const struct meson_reset_param
*param
;
72 struct device
*dev
= &pdev
->dev
;
76 base
= devm_platform_ioremap_resource(pdev
, 0);
80 param
= device_get_match_data(dev
);
84 map
= devm_regmap_init_mmio(dev
, base
, ®map_config
);
86 return dev_err_probe(dev
, PTR_ERR(map
),
87 "can't init regmap mmio region\n");
89 return meson_reset_controller_register(dev
, map
, param
);
92 static struct platform_driver meson_reset_driver
= {
93 .probe
= meson_reset_probe
,
95 .name
= "meson_reset",
96 .of_match_table
= meson_reset_dt_ids
,
99 module_platform_driver(meson_reset_driver
);
101 MODULE_DESCRIPTION("Amlogic Meson Reset Controller driver");
102 MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
103 MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
104 MODULE_LICENSE("Dual BSD/GPL");
105 MODULE_IMPORT_NS("MESON_RESET");