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-t931/t931-hw.h>
10 
11 #include "sherlock.h"
12 
13 namespace sherlock {
14 
15 static const pbus_mmio_t clk_mmios[] = {
16     // CLK Registers
17     {
18         .base = T931_HIU_BASE,
19         .length = T931_HIU_LENGTH,
20     },
21     // CLK MSR block
22     {
23         .base = T931_MSR_CLK_BASE,
24         .length = T931_MSR_CLK_LENGTH,
25     },
26 };
27 
__anon127a0a410102() 28 static pbus_dev_t clk_dev = []() {
29     pbus_dev_t dev;
30     dev.name = "sherlock-clk",
31     dev.vid = PDEV_VID_AMLOGIC;
32     dev.did = PDEV_DID_AMLOGIC_G12B_CLK;
33     dev.mmio_list = clk_mmios;
34     dev.mmio_count = countof(clk_mmios);
35     return dev;
36 }();
37 
ClkInit()38 zx_status_t Sherlock::ClkInit() {
39     zx_status_t status = pbus_.ProtocolDeviceAdd(ZX_PROTOCOL_CLK, &clk_dev);
40     if (status != ZX_OK) {
41         zxlogf(ERROR, "%s: ProtocolDeviceAdd failed %d\n", __func__, status);
42         return status;
43     }
44 
45     return ZX_OK;
46 }
47 
48 } // namespace sherlock
49