summaryrefslogtreecommitdiff
path: root/board/karma/board.c
blob: 4e9f9166fff0eb6744b6ad06319428a964a96c97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Copyright 2019 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "console.h"
#include "gpio.h"
#include "hooks.h"
#include "oz554.h"

#define CPRINTS(format, args...) cprints(CC_I2C, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_I2C, format, ## args)

void oz554_board_init(void)
{
	int pin_status = 0;

	pin_status |= gpio_get_level(GPIO_PANEL_ID_0) << 0;
	pin_status |= gpio_get_level(GPIO_PANEL_ID_1) << 1;
	pin_status |= gpio_get_level(GPIO_PANEL_ID_2) << 2;

	switch (pin_status) {
	case 0x04:
		CPRINTS("PANEL_LM_SSE2");
		break;
	case 0x05:
		CPRINTS("PANEL_LM_SSK1");
		/* Reigster 0x02: Setting LED current: 55(mA) */
		if (oz554_set_config(2, 0x55))
			CPRINTS("oz554 config failed");
		break;
	case 0x06:
		CPRINTS("PANEL_LM_SSM1");
		if (oz554_set_config(2, 0x46))
			CPRINTS("oz554 config failed");
		if (oz554_set_config(5, 0x87))
			CPRINTS("oz554 config failed");
		break;
	default:
		CPRINTS("PANEL_UNKNOWN");
		break;
	}
}

static void init_oz554(void)
{
	oz554_board_init();
	gpio_enable_interrupt(GPIO_PANEL_BACKLIGHT_EN);
}
DECLARE_HOOK(HOOK_INIT, init_oz554, HOOK_PRIO_DEFAULT);