blob: 834b29d2bc05c4db027130595c78e2ee87a2a0ae [file] [log] [blame]
Shimrit Malichid1c7efd2015-01-21 08:58:48 +02001/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
2
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <reg.h>
30#include <board.h>
31
32#define PERPH_SUBTYPE(base) (base + 0x05)
33#define RGB_LED_PERPH_TYPE(base) (base + 0x04)
34#define RGB_LED_SRC_SEL(base) (base + 0x45)
35#define RGB_LED_EN_CTL(base) (base + 0x46)
36#define RGB_LED_ATC_CTL(base) (base + 0x47)
37#define LPG_PERPH_TYPE(base) (base + 0x04)
38#define LPG_PERPH_SUBTYPE(base) (base + 0x05)
39#define LPG_PATTERN_CONFIG(base) (base + 0x40)
40#define LPG_PWM_SIZE_CLK(base) (base + 0x41)
41#define LPG_PWM_FREQ_PREDIV_CLK(base) (base + 0x42)
42#define LPG_PWM_TYPE_CONFIG(base) (base + 0x43)
43#define PWM_VALUE_LSB(base) (base + 0x44)
44#define PWM_VALUE_MSB(base) (base + 0x45)
45#define LPG_ENABLE_CONTROL(base) (base + 0x46)
46#define PWM_SYNC(base) (base + 0x47)
47
48#define RGB_LED_ENABLE_BLUE 0x20
49#define RGB_LED_ENABLE_GREEN 0x40
50#define RGB_LED_ENABLE_RED 0x80
51#define RGB_LED_SOURCE_VPH_PWR 0x01
52#define RGB_LED_ENABLE_MASK 0xE0
53#define RGB_LED_SRC_MASK 0xfc
54#define PWM_6BIT_1KHZ_CLK 0x01
55#define PWM_FREQ 0x05
56#define RGB_LED_ENABLE_PWM 0xe4
57
58enum qpnp_led_op {
59 QPNP_LED_RED,
60 QPNP_LED_GREEN,
61 QPNP_LED_BLUE,
62};
63
64struct qpnp_led_data {
65 uint16_t base;
66 uint16_t lpg_base;
67 enum qpnp_led_op color_sel;
68};
69
70/* LED Initial Setup */
71void qpnp_led_init(enum qpnp_led_op color, uint16_t led_base_addr,
72 uint16_t lpg_base_addr);