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#pragma once
6
7#include <ddk/device.h>
8#include <ddk/io-buffer.h>
9#include <ddk/protocol/gpio-impl.h>
10#include <ddk/protocol/iommu.h>
11#include <ddk/protocol/platform-bus.h>
12#include <soc/aml-s905d2/s905d2-gpio.h>
13
14// BTI IDs for our devices
15enum {
16    BTI_BOARD,
17    BTI_USB_XHCI,
18    BTI_DISPLAY,
19    BTI_MALI,
20    BTI_VIDEO,
21    BTI_AML_RAW_NAND,
22    BTI_SDIO,
23    BTI_CANVAS,
24    BTI_THERMAL,
25    BTI_AUDIO_IN,
26    BTI_AUDIO_OUT,
27    BTI_TEE,
28};
29
30typedef struct {
31    zx_device_t* parent;
32    platform_bus_protocol_t pbus;
33    gpio_impl_protocol_t gpio;
34    iommu_protocol_t iommu;
35} aml_bus_t;
36
37// astro-gpio.c
38zx_status_t aml_gpio_init(aml_bus_t* bus);
39
40// astro-i2c.c
41zx_status_t aml_i2c_init(aml_bus_t* bus);
42
43// astro-bluetooth.c
44zx_status_t aml_bluetooth_init(aml_bus_t* bus);
45
46// astro-usb.c
47zx_status_t aml_usb_init(aml_bus_t* bus);
48
49// astro-display.c
50zx_status_t aml_display_init(aml_bus_t* bus);
51
52// These should match the mmio table defined in astro-i2c.c
53enum {
54    ASTRO_I2C_A0_0,
55    ASTRO_I2C_2,
56    ASTRO_I2C_3,
57};
58
59// Astro Board Revs
60enum {
61    BOARD_REV_P1            = 0,
62    BOARD_REV_P2            = 1,
63    BOARD_REV_EVT_1         = 2,
64    BOARD_REV_EVT_2         = 3,
65
66    MAX_SUPPORTED_REV, // This must be last entry
67};
68
69// Astro GPIO Pins used for board rev detection
70#define GPIO_HW_ID0             (S905D2_GPIOZ(7))
71#define GPIO_HW_ID1             (S905D2_GPIOZ(8))
72#define GPIO_HW_ID2             (S905D2_GPIOZ(3))
73
74/* Astro I2C Devices */
75#define I2C_BACKLIGHT_ADDR    (0x2C)
76#define I2C_AMBIENTLIGHT_ADDR (0x39)
77// astro-touch.c
78zx_status_t astro_touch_init(aml_bus_t* bus);
79// aml-raw_nand.c
80zx_status_t aml_raw_nand_init(aml_bus_t* bus);
81// astro-sdio.c
82zx_status_t aml_sdio_init(aml_bus_t* bus);
83// astro-canvas.c
84zx_status_t aml_canvas_init(aml_bus_t* bus);
85// astro-light.c
86zx_status_t ams_light_init(aml_bus_t* bus);
87// astro-thermal.c
88zx_status_t aml_thermal_init(aml_bus_t* bus);
89// astro-video.c
90zx_status_t aml_video_init(aml_bus_t* bus);
91// astro-clk.c
92zx_status_t aml_clk_init(aml_bus_t* bus);
93// astro-audio.c
94zx_status_t astro_tdm_init(aml_bus_t* bus);
95// astro-tee.c
96zx_status_t astro_tee_init(aml_bus_t* bus);
97