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
10#include <soc/aml-s905d2/s905d2-gpio.h>
11#include <soc/aml-s905d2/s905d2-hw.h>
12
13#include <limits.h>
14
15#include "astro.h"
16
17static const pbus_mmio_t astro_canvas_mmios[] = {
18    {
19        .base = S905D2_DMC_BASE,
20        .length = S905D2_DMC_LENGTH,
21    },
22};
23
24static const pbus_bti_t astro_canvas_btis[] = {
25    {
26        .iommu_index = 0,
27        .bti_id = BTI_CANVAS,
28    },
29};
30
31static const pbus_dev_t canvas_dev = {
32    .name = "canvas",
33    .vid = PDEV_VID_AMLOGIC,
34    .pid = PDEV_PID_GENERIC,
35    .did = PDEV_DID_AMLOGIC_CANVAS,
36    .mmios = astro_canvas_mmios,
37    .mmio_count = countof(astro_canvas_mmios),
38    .btis = astro_canvas_btis,
39    .bti_count = countof(astro_canvas_btis),
40};
41
42zx_status_t aml_canvas_init(aml_bus_t* bus) {
43    zx_status_t status = pbus_protocol_device_add(&bus->pbus, ZX_PROTOCOL_AMLOGIC_CANVAS,
44                                                  &canvas_dev);
45    if (status != ZX_OK) {
46        zxlogf(ERROR, "%s: pbus_protocol_device_add canvas failed: %d\n", __FUNCTION__, status);
47        return status;
48    }
49    return ZX_OK;
50}