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 <limits.h>
11
12#include "vim.h"
13
14static const pbus_i2c_channel_t pcf8563_rtc_i2c[] = {
15    {
16        .bus_id = 1,
17        .address = 0x51,
18    },
19};
20
21static pbus_dev_t pcf8563_rtc_dev = {
22    .name = "pcf8563-rtc",
23    .vid = PDEV_VID_NXP,
24    .pid = PDEV_PID_PCF8563,
25    .did = PDEV_DID_PCF8563_RTC,
26    .i2c_channels = pcf8563_rtc_i2c,
27    .i2c_channel_count = countof(pcf8563_rtc_i2c),
28};
29
30zx_status_t vim_rtc_init(vim_bus_t* bus) {
31
32    zx_status_t status = pbus_device_add(&bus->pbus, &pcf8563_rtc_dev);
33    if (status != ZX_OK) {
34        zxlogf(ERROR, "%s(pcf8563): pbus_device_add failed: %d\n", __FUNCTION__, status);
35    }
36
37    return status;
38}
39