Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 38 | static struct resource gpio_resources[] = { |
Andy Shevchenko | 0ce8ea7 | 2018-08-30 19:52:50 +0300 | [diff] [blame^] | 39 | DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_GPIO, "GPIO"), |
Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | static struct resource pwrsrc_resources[] = { |
Andy Shevchenko | 0ce8ea7 | 2018-08-30 19:52:50 +0300 | [diff] [blame^] | 43 | DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_PWRSRC, "PWRSRC"), |
Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | static struct resource adc_resources[] = { |
Andy Shevchenko | 0ce8ea7 | 2018-08-30 19:52:50 +0300 | [diff] [blame^] | 47 | DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_ADC, "ADC"), |
Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | static struct resource thermal_resources[] = { |
Andy Shevchenko | 0ce8ea7 | 2018-08-30 19:52:50 +0300 | [diff] [blame^] | 51 | DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_THRM, "THERMAL"), |
Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | static struct resource bcu_resources[] = { |
Andy Shevchenko | 0ce8ea7 | 2018-08-30 19:52:50 +0300 | [diff] [blame^] | 55 | DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_BCU, "BCU"), |
Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 56 | }; |
| 57 | |
Hans de Goede | 4d9ed62 | 2017-09-04 15:22:41 +0200 | [diff] [blame] | 58 | static struct mfd_cell crystal_cove_byt_dev[] = { |
Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 59 | { |
| 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 Lu | b1eea85 | 2014-11-24 17:21:54 +0800 | [diff] [blame] | 84 | { |
| 85 | .name = "crystal_cove_pmic", |
| 86 | }, |
Shobhit Kumar | 3d5e10e | 2015-06-26 14:32:06 +0530 | [diff] [blame] | 87 | { |
| 88 | .name = "crystal_cove_pwm", |
| 89 | }, |
Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 90 | }; |
| 91 | |
Hans de Goede | 4d9ed62 | 2017-09-04 15:22:41 +0200 | [diff] [blame] | 92 | static 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 Kozlowski | 172cb30 | 2015-01-05 10:01:22 +0100 | [diff] [blame] | 103 | static const struct regmap_config crystal_cove_regmap_config = { |
Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 104 | .reg_bits = 8, |
| 105 | .val_bits = 8, |
| 106 | |
| 107 | .max_register = CRYSTAL_COVE_MAX_REGISTER, |
| 108 | .cache_type = REGCACHE_NONE, |
| 109 | }; |
| 110 | |
| 111 | static 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 Kozlowski | 7ce7b26 | 2015-04-27 21:54:13 +0900 | [diff] [blame] | 135 | static const struct regmap_irq_chip crystal_cove_irq_chip = { |
Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 136 | .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 Goede | 4d9ed62 | 2017-09-04 15:22:41 +0200 | [diff] [blame] | 144 | struct intel_soc_pmic_config intel_soc_pmic_config_byt_crc = { |
Zhu, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 145 | .irq_flags = IRQF_TRIGGER_RISING, |
Hans de Goede | 4d9ed62 | 2017-09-04 15:22:41 +0200 | [diff] [blame] | 146 | .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 | |
| 152 | struct 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, Lejun | 7cf0a66 | 2014-06-03 13:26:03 +0800 | [diff] [blame] | 156 | .regmap_config = &crystal_cove_regmap_config, |
| 157 | .irq_chip = &crystal_cove_irq_chip, |
| 158 | }; |