blob: de3f31266c57019f833a3f92ce70d1b4f2dcd3d4 [file] [log] [blame]
Zhu, Lejun7cf0a662014-06-03 13:26:03 +08001/*
2 * intel_soc_pmic_crc.c - Device access for Crystal Cove PMIC
3 *
4 * Copyright (C) 2013, 2014 Intel Corporation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * Author: Yang, Bin <bin.yang@intel.com>
16 * Author: Zhu, Lejun <lejun.zhu@linux.intel.com>
17 */
18
19#include <linux/mfd/core.h>
20#include <linux/interrupt.h>
21#include <linux/regmap.h>
22#include <linux/mfd/intel_soc_pmic.h>
23#include "intel_soc_pmic_core.h"
24
25#define CRYSTAL_COVE_MAX_REGISTER 0xC6
26
27#define CRYSTAL_COVE_REG_IRQLVL1 0x02
28#define CRYSTAL_COVE_REG_MIRQLVL1 0x0E
29
30#define CRYSTAL_COVE_IRQ_PWRSRC 0
31#define CRYSTAL_COVE_IRQ_THRM 1
32#define CRYSTAL_COVE_IRQ_BCU 2
33#define CRYSTAL_COVE_IRQ_ADC 3
34#define CRYSTAL_COVE_IRQ_CHGR 4
35#define CRYSTAL_COVE_IRQ_GPIO 5
36#define CRYSTAL_COVE_IRQ_VHDMIOCP 6
37
38static struct resource gpio_resources[] = {
Andy Shevchenko0ce8ea72018-08-30 19:52:50 +030039 DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_GPIO, "GPIO"),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080040};
41
42static struct resource pwrsrc_resources[] = {
Andy Shevchenko0ce8ea72018-08-30 19:52:50 +030043 DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_PWRSRC, "PWRSRC"),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080044};
45
46static struct resource adc_resources[] = {
Andy Shevchenko0ce8ea72018-08-30 19:52:50 +030047 DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_ADC, "ADC"),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080048};
49
50static struct resource thermal_resources[] = {
Andy Shevchenko0ce8ea72018-08-30 19:52:50 +030051 DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_THRM, "THERMAL"),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080052};
53
54static struct resource bcu_resources[] = {
Andy Shevchenko0ce8ea72018-08-30 19:52:50 +030055 DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_BCU, "BCU"),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080056};
57
Hans de Goede4d9ed622017-09-04 15:22:41 +020058static struct mfd_cell crystal_cove_byt_dev[] = {
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080059 {
60 .name = "crystal_cove_pwrsrc",
61 .num_resources = ARRAY_SIZE(pwrsrc_resources),
62 .resources = pwrsrc_resources,
63 },
64 {
65 .name = "crystal_cove_adc",
66 .num_resources = ARRAY_SIZE(adc_resources),
67 .resources = adc_resources,
68 },
69 {
70 .name = "crystal_cove_thermal",
71 .num_resources = ARRAY_SIZE(thermal_resources),
72 .resources = thermal_resources,
73 },
74 {
75 .name = "crystal_cove_bcu",
76 .num_resources = ARRAY_SIZE(bcu_resources),
77 .resources = bcu_resources,
78 },
79 {
80 .name = "crystal_cove_gpio",
81 .num_resources = ARRAY_SIZE(gpio_resources),
82 .resources = gpio_resources,
83 },
Aaron Lub1eea852014-11-24 17:21:54 +080084 {
85 .name = "crystal_cove_pmic",
86 },
Shobhit Kumar3d5e10e2015-06-26 14:32:06 +053087 {
88 .name = "crystal_cove_pwm",
89 },
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080090};
91
Hans de Goede4d9ed622017-09-04 15:22:41 +020092static struct mfd_cell crystal_cove_cht_dev[] = {
93 {
94 .name = "crystal_cove_gpio",
95 .num_resources = ARRAY_SIZE(gpio_resources),
96 .resources = gpio_resources,
97 },
98 {
99 .name = "crystal_cove_pwm",
100 },
101};
102
Krzysztof Kozlowski172cb302015-01-05 10:01:22 +0100103static const struct regmap_config crystal_cove_regmap_config = {
Zhu, Lejun7cf0a662014-06-03 13:26:03 +0800104 .reg_bits = 8,
105 .val_bits = 8,
106
107 .max_register = CRYSTAL_COVE_MAX_REGISTER,
108 .cache_type = REGCACHE_NONE,
109};
110
111static const struct regmap_irq crystal_cove_irqs[] = {
112 [CRYSTAL_COVE_IRQ_PWRSRC] = {
113 .mask = BIT(CRYSTAL_COVE_IRQ_PWRSRC),
114 },
115 [CRYSTAL_COVE_IRQ_THRM] = {
116 .mask = BIT(CRYSTAL_COVE_IRQ_THRM),
117 },
118 [CRYSTAL_COVE_IRQ_BCU] = {
119 .mask = BIT(CRYSTAL_COVE_IRQ_BCU),
120 },
121 [CRYSTAL_COVE_IRQ_ADC] = {
122 .mask = BIT(CRYSTAL_COVE_IRQ_ADC),
123 },
124 [CRYSTAL_COVE_IRQ_CHGR] = {
125 .mask = BIT(CRYSTAL_COVE_IRQ_CHGR),
126 },
127 [CRYSTAL_COVE_IRQ_GPIO] = {
128 .mask = BIT(CRYSTAL_COVE_IRQ_GPIO),
129 },
130 [CRYSTAL_COVE_IRQ_VHDMIOCP] = {
131 .mask = BIT(CRYSTAL_COVE_IRQ_VHDMIOCP),
132 },
133};
134
Krzysztof Kozlowski7ce7b262015-04-27 21:54:13 +0900135static const struct regmap_irq_chip crystal_cove_irq_chip = {
Zhu, Lejun7cf0a662014-06-03 13:26:03 +0800136 .name = "Crystal Cove",
137 .irqs = crystal_cove_irqs,
138 .num_irqs = ARRAY_SIZE(crystal_cove_irqs),
139 .num_regs = 1,
140 .status_base = CRYSTAL_COVE_REG_IRQLVL1,
141 .mask_base = CRYSTAL_COVE_REG_MIRQLVL1,
142};
143
Hans de Goede4d9ed622017-09-04 15:22:41 +0200144struct intel_soc_pmic_config intel_soc_pmic_config_byt_crc = {
Zhu, Lejun7cf0a662014-06-03 13:26:03 +0800145 .irq_flags = IRQF_TRIGGER_RISING,
Hans de Goede4d9ed622017-09-04 15:22:41 +0200146 .cell_dev = crystal_cove_byt_dev,
147 .n_cell_devs = ARRAY_SIZE(crystal_cove_byt_dev),
148 .regmap_config = &crystal_cove_regmap_config,
149 .irq_chip = &crystal_cove_irq_chip,
150};
151
152struct intel_soc_pmic_config intel_soc_pmic_config_cht_crc = {
153 .irq_flags = IRQF_TRIGGER_RISING,
154 .cell_dev = crystal_cove_cht_dev,
155 .n_cell_devs = ARRAY_SIZE(crystal_cove_cht_dev),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +0800156 .regmap_config = &crystal_cove_regmap_config,
157 .irq_chip = &crystal_cove_irq_chip,
158};