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