1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <ddk/debug.h>
6 #include <ddk/device.h>
7 #include <ddk/platform-defs.h>
8 #include <ddk/protocol/platform/bus.h>
9 #include <soc/aml-s905d2/s905d2-hw.h>
10
11 #include "astro.h"
12
13 static const pbus_mmio_t clk_mmios[] = {
14 // CLK Registers
15 {
16 .base = S905D2_HIU_BASE,
17 .length = S905D2_HIU_LENGTH,
18 },
19 // CLK MSR block
20 {
21 .base = S905D2_MSR_CLK_BASE,
22 .length = S905D2_MSR_CLK_LENGTH,
23 },
24 };
25
26 static const pbus_dev_t clk_dev = {
27 .name = "astro-clk",
28 .vid = PDEV_VID_AMLOGIC,
29 .pid = PDEV_PID_AMLOGIC_S905D2,
30 .did = PDEV_DID_AMLOGIC_G12A_CLK,
31 .mmio_list = clk_mmios,
32 .mmio_count = countof(clk_mmios),
33 };
34
aml_clk_init(aml_bus_t * bus)35 zx_status_t aml_clk_init(aml_bus_t* bus) {
36 zx_status_t status = pbus_protocol_device_add(&bus->pbus, ZX_PROTOCOL_CLK, &clk_dev);
37 if (status != ZX_OK) {
38 zxlogf(ERROR, "aml_clk_init: pbus_protocol_device_add failed, st = %d\n", status);
39 return status;
40 }
41
42 return ZX_OK;
43 }
44