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/protocol/platform-bus.h>
8#include <ddk/protocol/platform-defs.h>
9#include <soc/aml-s912/s912-hw.h>
10
11#include "vim.h"
12
13static const pbus_mmio_t clk_mmios[] = {
14    {
15        .base = S912_HIU_BASE,
16        .length = S912_HIU_LENGTH,
17    },
18};
19
20static const pbus_dev_t clk_dev = {
21    .name = "vim-clk",
22    .vid = PDEV_VID_AMLOGIC,
23    .pid = PDEV_PID_AMLOGIC_S912,
24    .did = PDEV_DID_AMLOGIC_AXG_CLK,
25    .mmios = clk_mmios,
26    .mmio_count = countof(clk_mmios),
27};
28
29zx_status_t vim_clk_init(vim_bus_t* bus) {
30    zx_status_t status = pbus_protocol_device_add(&bus->pbus, ZX_PROTOCOL_CLK, &clk_dev);
31    if (status != ZX_OK) {
32        zxlogf(ERROR, "vim_clk_init: pbus_protocol_device_add failed, st = %d\n", status);
33        return status;
34    }
35
36    return ZX_OK;
37}
38