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 "sherlock.h"
9 
10 namespace sherlock {
11 
12 namespace {
13 constexpr pbus_i2c_channel_t backlight_i2c_channels[] = {
14     {
15         .bus_id = SHERLOCK_I2C_3,
16         .address = 0x2C,
17     },
18 };
19 
__anon225b62900202() 20 static pbus_dev_t backlight_dev = []() {
21     pbus_dev_t dev;
22     dev.name = "backlight";
23     dev.vid = PDEV_VID_TI;
24     dev.pid = PDEV_PID_TI_LP8556;
25     dev.did = PDEV_DID_TI_BACKLIGHT;
26     dev.i2c_channel_list = backlight_i2c_channels;
27     dev.i2c_channel_count = countof(backlight_i2c_channels);
28     return dev;
29 }();
30 
31 } // namespace
32 
BacklightInit()33 zx_status_t Sherlock::BacklightInit() {
34 
35     zx_status_t status = pbus_.DeviceAdd(&backlight_dev);
36     if (status != ZX_OK) {
37         zxlogf(ERROR, "%s: DeviceAdd failed %d\n", __func__, status);
38         return status;
39     }
40 
41     return status;
42 }
43 
44 } // namespace sherlock