blob: b6ab72fa056971228a2948846fcd1a42c7cec13f [file] [log] [blame]
Andy Shevchenko26c7e052018-08-30 19:52:54 +03001// SPDX-License-Identifier: GPL-2.0
Zhu, Lejun7cf0a662014-06-03 13:26:03 +08002/*
Andy Shevchenko26c7e052018-08-30 19:52:54 +03003 * Device access for Crystal Cove PMIC
Zhu, Lejun7cf0a662014-06-03 13:26:03 +08004 *
5 * Copyright (C) 2013, 2014 Intel Corporation. All rights reserved.
6 *
Zhu, Lejun7cf0a662014-06-03 13:26:03 +08007 * Author: Yang, Bin <bin.yang@intel.com>
8 * Author: Zhu, Lejun <lejun.zhu@linux.intel.com>
9 */
10
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080011#include <linux/interrupt.h>
12#include <linux/regmap.h>
Andy Shevchenko51eeee82018-08-30 19:52:53 +030013#include <linux/mfd/core.h>
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080014#include <linux/mfd/intel_soc_pmic.h>
Andy Shevchenko51eeee82018-08-30 19:52:53 +030015
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080016#include "intel_soc_pmic_core.h"
17
18#define CRYSTAL_COVE_MAX_REGISTER 0xC6
19
20#define CRYSTAL_COVE_REG_IRQLVL1 0x02
21#define CRYSTAL_COVE_REG_MIRQLVL1 0x0E
22
23#define CRYSTAL_COVE_IRQ_PWRSRC 0
24#define CRYSTAL_COVE_IRQ_THRM 1
25#define CRYSTAL_COVE_IRQ_BCU 2
26#define CRYSTAL_COVE_IRQ_ADC 3
27#define CRYSTAL_COVE_IRQ_CHGR 4
28#define CRYSTAL_COVE_IRQ_GPIO 5
29#define CRYSTAL_COVE_IRQ_VHDMIOCP 6
30
31static struct resource gpio_resources[] = {
Andy Shevchenko0ce8ea712018-08-30 19:52:50 +030032 DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_GPIO, "GPIO"),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080033};
34
35static struct resource pwrsrc_resources[] = {
Andy Shevchenko0ce8ea712018-08-30 19:52:50 +030036 DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_PWRSRC, "PWRSRC"),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080037};
38
39static struct resource adc_resources[] = {
Andy Shevchenko0ce8ea712018-08-30 19:52:50 +030040 DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_ADC, "ADC"),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080041};
42
43static struct resource thermal_resources[] = {
Andy Shevchenko0ce8ea712018-08-30 19:52:50 +030044 DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_THRM, "THERMAL"),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080045};
46
47static struct resource bcu_resources[] = {
Andy Shevchenko0ce8ea712018-08-30 19:52:50 +030048 DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_BCU, "BCU"),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080049};
50
Hans de Goede4d9ed622017-09-04 15:22:41 +020051static struct mfd_cell crystal_cove_byt_dev[] = {
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080052 {
53 .name = "crystal_cove_pwrsrc",
54 .num_resources = ARRAY_SIZE(pwrsrc_resources),
55 .resources = pwrsrc_resources,
56 },
57 {
58 .name = "crystal_cove_adc",
59 .num_resources = ARRAY_SIZE(adc_resources),
60 .resources = adc_resources,
61 },
62 {
63 .name = "crystal_cove_thermal",
64 .num_resources = ARRAY_SIZE(thermal_resources),
65 .resources = thermal_resources,
66 },
67 {
68 .name = "crystal_cove_bcu",
69 .num_resources = ARRAY_SIZE(bcu_resources),
70 .resources = bcu_resources,
71 },
72 {
73 .name = "crystal_cove_gpio",
74 .num_resources = ARRAY_SIZE(gpio_resources),
75 .resources = gpio_resources,
76 },
Aaron Lub1eea852014-11-24 17:21:54 +080077 {
78 .name = "crystal_cove_pmic",
79 },
Shobhit Kumar3d5e10e2015-06-26 14:32:06 +053080 {
81 .name = "crystal_cove_pwm",
82 },
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080083};
84
Hans de Goede4d9ed622017-09-04 15:22:41 +020085static struct mfd_cell crystal_cove_cht_dev[] = {
86 {
87 .name = "crystal_cove_gpio",
88 .num_resources = ARRAY_SIZE(gpio_resources),
89 .resources = gpio_resources,
90 },
91 {
92 .name = "crystal_cove_pwm",
93 },
94};
95
Krzysztof Kozlowski172cb302015-01-05 10:01:22 +010096static const struct regmap_config crystal_cove_regmap_config = {
Zhu, Lejun7cf0a662014-06-03 13:26:03 +080097 .reg_bits = 8,
98 .val_bits = 8,
99
100 .max_register = CRYSTAL_COVE_MAX_REGISTER,
101 .cache_type = REGCACHE_NONE,
102};
103
104static const struct regmap_irq crystal_cove_irqs[] = {
Andy Shevchenko8bd2d032018-08-30 19:52:51 +0300105 REGMAP_IRQ_REG(CRYSTAL_COVE_IRQ_PWRSRC, 0, BIT(CRYSTAL_COVE_IRQ_PWRSRC)),
106 REGMAP_IRQ_REG(CRYSTAL_COVE_IRQ_THRM, 0, BIT(CRYSTAL_COVE_IRQ_THRM)),
107 REGMAP_IRQ_REG(CRYSTAL_COVE_IRQ_BCU, 0, BIT(CRYSTAL_COVE_IRQ_BCU)),
108 REGMAP_IRQ_REG(CRYSTAL_COVE_IRQ_ADC, 0, BIT(CRYSTAL_COVE_IRQ_ADC)),
109 REGMAP_IRQ_REG(CRYSTAL_COVE_IRQ_CHGR, 0, BIT(CRYSTAL_COVE_IRQ_CHGR)),
110 REGMAP_IRQ_REG(CRYSTAL_COVE_IRQ_GPIO, 0, BIT(CRYSTAL_COVE_IRQ_GPIO)),
111 REGMAP_IRQ_REG(CRYSTAL_COVE_IRQ_VHDMIOCP, 0, BIT(CRYSTAL_COVE_IRQ_VHDMIOCP)),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +0800112};
113
Krzysztof Kozlowski7ce7b262015-04-27 21:54:13 +0900114static const struct regmap_irq_chip crystal_cove_irq_chip = {
Zhu, Lejun7cf0a662014-06-03 13:26:03 +0800115 .name = "Crystal Cove",
116 .irqs = crystal_cove_irqs,
117 .num_irqs = ARRAY_SIZE(crystal_cove_irqs),
118 .num_regs = 1,
119 .status_base = CRYSTAL_COVE_REG_IRQLVL1,
120 .mask_base = CRYSTAL_COVE_REG_MIRQLVL1,
121};
122
Hans de Goede4d9ed622017-09-04 15:22:41 +0200123struct intel_soc_pmic_config intel_soc_pmic_config_byt_crc = {
Zhu, Lejun7cf0a662014-06-03 13:26:03 +0800124 .irq_flags = IRQF_TRIGGER_RISING,
Hans de Goede4d9ed622017-09-04 15:22:41 +0200125 .cell_dev = crystal_cove_byt_dev,
126 .n_cell_devs = ARRAY_SIZE(crystal_cove_byt_dev),
127 .regmap_config = &crystal_cove_regmap_config,
128 .irq_chip = &crystal_cove_irq_chip,
129};
130
131struct intel_soc_pmic_config intel_soc_pmic_config_cht_crc = {
132 .irq_flags = IRQF_TRIGGER_RISING,
133 .cell_dev = crystal_cove_cht_dev,
134 .n_cell_devs = ARRAY_SIZE(crystal_cove_cht_dev),
Zhu, Lejun7cf0a662014-06-03 13:26:03 +0800135 .regmap_config = &crystal_cove_regmap_config,
136 .irq_chip = &crystal_cove_irq_chip,
137};