1fb4c3158SJerome Brunet // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2fb4c3158SJerome Brunet /*
3fb4c3158SJerome Brunet * Amlogic Meson Reset Auxiliary driver
4fb4c3158SJerome Brunet *
5fb4c3158SJerome Brunet * Copyright (c) 2024 BayLibre, SAS.
6fb4c3158SJerome Brunet * Author: Jerome Brunet <jbrunet@baylibre.com>
7fb4c3158SJerome Brunet */
8fb4c3158SJerome Brunet
9fb4c3158SJerome Brunet #include <linux/err.h>
10fb4c3158SJerome Brunet #include <linux/module.h>
11fb4c3158SJerome Brunet #include <linux/auxiliary_bus.h>
12fb4c3158SJerome Brunet #include <linux/regmap.h>
13fb4c3158SJerome Brunet #include <linux/reset-controller.h>
14fb4c3158SJerome Brunet
15fb4c3158SJerome Brunet #include "reset-meson.h"
16fb4c3158SJerome Brunet
17fb4c3158SJerome Brunet static const struct meson_reset_param meson_a1_audio_param = {
18fb4c3158SJerome Brunet .reset_ops = &meson_reset_toggle_ops,
19fb4c3158SJerome Brunet .reset_num = 32,
20fb4c3158SJerome Brunet .level_offset = 0x28,
21fb4c3158SJerome Brunet };
22fb4c3158SJerome Brunet
23fb4c3158SJerome Brunet static const struct meson_reset_param meson_a1_audio_vad_param = {
24fb4c3158SJerome Brunet .reset_ops = &meson_reset_toggle_ops,
25fb4c3158SJerome Brunet .reset_num = 6,
26fb4c3158SJerome Brunet .level_offset = 0x8,
27fb4c3158SJerome Brunet };
28fb4c3158SJerome Brunet
29fb4c3158SJerome Brunet static const struct meson_reset_param meson_g12a_audio_param = {
30fb4c3158SJerome Brunet .reset_ops = &meson_reset_toggle_ops,
31fb4c3158SJerome Brunet .reset_num = 26,
32fb4c3158SJerome Brunet .level_offset = 0x24,
33fb4c3158SJerome Brunet };
34fb4c3158SJerome Brunet
35fb4c3158SJerome Brunet static const struct meson_reset_param meson_sm1_audio_param = {
36fb4c3158SJerome Brunet .reset_ops = &meson_reset_toggle_ops,
37fb4c3158SJerome Brunet .reset_num = 39,
38fb4c3158SJerome Brunet .level_offset = 0x28,
39fb4c3158SJerome Brunet };
40fb4c3158SJerome Brunet
41fb4c3158SJerome Brunet static const struct auxiliary_device_id meson_reset_aux_ids[] = {
42fb4c3158SJerome Brunet {
43fb4c3158SJerome Brunet .name = "a1-audio-clkc.rst-a1",
44fb4c3158SJerome Brunet .driver_data = (kernel_ulong_t)&meson_a1_audio_param,
45fb4c3158SJerome Brunet }, {
46fb4c3158SJerome Brunet .name = "a1-audio-clkc.rst-a1-vad",
47fb4c3158SJerome Brunet .driver_data = (kernel_ulong_t)&meson_a1_audio_vad_param,
48fb4c3158SJerome Brunet }, {
49fb4c3158SJerome Brunet .name = "axg-audio-clkc.rst-g12a",
50fb4c3158SJerome Brunet .driver_data = (kernel_ulong_t)&meson_g12a_audio_param,
51fb4c3158SJerome Brunet }, {
52fb4c3158SJerome Brunet .name = "axg-audio-clkc.rst-sm1",
53fb4c3158SJerome Brunet .driver_data = (kernel_ulong_t)&meson_sm1_audio_param,
54fb4c3158SJerome Brunet }, {}
55fb4c3158SJerome Brunet };
56fb4c3158SJerome Brunet MODULE_DEVICE_TABLE(auxiliary, meson_reset_aux_ids);
57fb4c3158SJerome Brunet
meson_reset_aux_probe(struct auxiliary_device * adev,const struct auxiliary_device_id * id)58fb4c3158SJerome Brunet static int meson_reset_aux_probe(struct auxiliary_device *adev,
59fb4c3158SJerome Brunet const struct auxiliary_device_id *id)
60fb4c3158SJerome Brunet {
61fb4c3158SJerome Brunet const struct meson_reset_param *param =
62fb4c3158SJerome Brunet (const struct meson_reset_param *)(id->driver_data);
63fb4c3158SJerome Brunet struct regmap *map;
64fb4c3158SJerome Brunet
65fb4c3158SJerome Brunet map = dev_get_regmap(adev->dev.parent, NULL);
66fb4c3158SJerome Brunet if (!map)
67fb4c3158SJerome Brunet return -EINVAL;
68fb4c3158SJerome Brunet
69fb4c3158SJerome Brunet return meson_reset_controller_register(&adev->dev, map, param);
70fb4c3158SJerome Brunet }
71fb4c3158SJerome Brunet
72fb4c3158SJerome Brunet static struct auxiliary_driver meson_reset_aux_driver = {
73fb4c3158SJerome Brunet .probe = meson_reset_aux_probe,
74fb4c3158SJerome Brunet .id_table = meson_reset_aux_ids,
75fb4c3158SJerome Brunet };
76fb4c3158SJerome Brunet module_auxiliary_driver(meson_reset_aux_driver);
77fb4c3158SJerome Brunet
78fb4c3158SJerome Brunet MODULE_DESCRIPTION("Amlogic Meson Reset Auxiliary driver");
79fb4c3158SJerome Brunet MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
80fb4c3158SJerome Brunet MODULE_LICENSE("Dual BSD/GPL");
81fb4c3158SJerome Brunet MODULE_IMPORT_NS("MESON_RESET");
82fb4c3158SJerome Brunet