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#include "vim.h"
11
12static const pbus_mmio_t vim_canvas_mmios[] = {
13    {
14        .base =     S912_DMC_REG_BASE,
15        .length =   S912_DMC_REG_LENGTH,
16    },
17};
18
19static const pbus_bti_t vim_canvas_btis[] = {
20    {
21        .iommu_index = 0,
22        .bti_id = BTI_CANVAS,
23    },
24};
25
26static const pbus_dev_t canvas_dev = {
27    .name = "canvas",
28    .vid = PDEV_VID_AMLOGIC,
29    .pid = PDEV_PID_GENERIC,
30    .did = PDEV_DID_AMLOGIC_CANVAS,
31    .mmios = vim_canvas_mmios,
32    .mmio_count = countof(vim_canvas_mmios),
33    .btis = vim_canvas_btis,
34    .bti_count = countof(vim_canvas_btis),
35};
36
37zx_status_t vim2_canvas_init(vim_bus_t* bus) {
38    zx_status_t status = pbus_protocol_device_add(&bus->pbus, ZX_PROTOCOL_AMLOGIC_CANVAS,
39                                                  &canvas_dev);
40    if (status != ZX_OK) {
41        zxlogf(ERROR, "vim2_canvas_init: pbus_protocol_device_add Canvas failed: %d\n", status);
42        return status;
43    }
44    return ZX_OK;
45}
46