intel_soc_pmic_crc.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. #include <linux/mfd/core.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/regmap.h>
  21. #include <linux/mfd/intel_soc_pmic.h>
  22. #include "intel_soc_pmic_core.h"
  23. #define CRYSTAL_COVE_MAX_REGISTER 0xC6
  24. #define CRYSTAL_COVE_REG_IRQLVL1 0x02
  25. #define CRYSTAL_COVE_REG_MIRQLVL1 0x0E
  26. #define CRYSTAL_COVE_IRQ_PWRSRC 0
  27. #define CRYSTAL_COVE_IRQ_THRM 1
  28. #define CRYSTAL_COVE_IRQ_BCU 2
  29. #define CRYSTAL_COVE_IRQ_ADC 3
  30. #define CRYSTAL_COVE_IRQ_CHGR 4
  31. #define CRYSTAL_COVE_IRQ_GPIO 5
  32. #define CRYSTAL_COVE_IRQ_VHDMIOCP 6
  33. static struct resource gpio_resources[] = {
  34. {
  35. .name = "GPIO",
  36. .start = CRYSTAL_COVE_IRQ_GPIO,
  37. .end = CRYSTAL_COVE_IRQ_GPIO,
  38. .flags = IORESOURCE_IRQ,
  39. },
  40. };
  41. static struct resource pwrsrc_resources[] = {
  42. {
  43. .name = "PWRSRC",
  44. .start = CRYSTAL_COVE_IRQ_PWRSRC,
  45. .end = CRYSTAL_COVE_IRQ_PWRSRC,
  46. .flags = IORESOURCE_IRQ,
  47. },
  48. };
  49. static struct resource adc_resources[] = {
  50. {
  51. .name = "ADC",
  52. .start = CRYSTAL_COVE_IRQ_ADC,
  53. .end = CRYSTAL_COVE_IRQ_ADC,
  54. .flags = IORESOURCE_IRQ,
  55. },
  56. };
  57. static struct resource thermal_resources[] = {
  58. {
  59. .name = "THERMAL",
  60. .start = CRYSTAL_COVE_IRQ_THRM,
  61. .end = CRYSTAL_COVE_IRQ_THRM,
  62. .flags = IORESOURCE_IRQ,
  63. },
  64. };
  65. static struct resource bcu_resources[] = {
  66. {
  67. .name = "BCU",
  68. .start = CRYSTAL_COVE_IRQ_BCU,
  69. .end = CRYSTAL_COVE_IRQ_BCU,
  70. .flags = IORESOURCE_IRQ,
  71. },
  72. };
  73. static struct mfd_cell crystal_cove_dev[] = {
  74. {
  75. .name = "crystal_cove_pwrsrc",
  76. .num_resources = ARRAY_SIZE(pwrsrc_resources),
  77. .resources = pwrsrc_resources,
  78. },
  79. {
  80. .name = "crystal_cove_adc",
  81. .num_resources = ARRAY_SIZE(adc_resources),
  82. .resources = adc_resources,
  83. },
  84. {
  85. .name = "crystal_cove_thermal",
  86. .num_resources = ARRAY_SIZE(thermal_resources),
  87. .resources = thermal_resources,
  88. },
  89. {
  90. .name = "crystal_cove_bcu",
  91. .num_resources = ARRAY_SIZE(bcu_resources),
  92. .resources = bcu_resources,
  93. },
  94. {
  95. .name = "crystal_cove_gpio",
  96. .num_resources = ARRAY_SIZE(gpio_resources),
  97. .resources = gpio_resources,
  98. },
  99. {
  100. .name = "crystal_cove_pmic",
  101. },
  102. {
  103. .name = "crystal_cove_pwm",
  104. },
  105. };
  106. static const struct regmap_config crystal_cove_regmap_config = {
  107. .reg_bits = 8,
  108. .val_bits = 8,
  109. .max_register = CRYSTAL_COVE_MAX_REGISTER,
  110. .cache_type = REGCACHE_NONE,
  111. };
  112. static const struct regmap_irq crystal_cove_irqs[] = {
  113. [CRYSTAL_COVE_IRQ_PWRSRC] = {
  114. .mask = BIT(CRYSTAL_COVE_IRQ_PWRSRC),
  115. },
  116. [CRYSTAL_COVE_IRQ_THRM] = {
  117. .mask = BIT(CRYSTAL_COVE_IRQ_THRM),
  118. },
  119. [CRYSTAL_COVE_IRQ_BCU] = {
  120. .mask = BIT(CRYSTAL_COVE_IRQ_BCU),
  121. },
  122. [CRYSTAL_COVE_IRQ_ADC] = {
  123. .mask = BIT(CRYSTAL_COVE_IRQ_ADC),
  124. },
  125. [CRYSTAL_COVE_IRQ_CHGR] = {
  126. .mask = BIT(CRYSTAL_COVE_IRQ_CHGR),
  127. },
  128. [CRYSTAL_COVE_IRQ_GPIO] = {
  129. .mask = BIT(CRYSTAL_COVE_IRQ_GPIO),
  130. },
  131. [CRYSTAL_COVE_IRQ_VHDMIOCP] = {
  132. .mask = BIT(CRYSTAL_COVE_IRQ_VHDMIOCP),
  133. },
  134. };
  135. static const struct regmap_irq_chip crystal_cove_irq_chip = {
  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. struct intel_soc_pmic_config intel_soc_pmic_config_crc = {
  144. .irq_flags = IRQF_TRIGGER_RISING,
  145. .cell_dev = crystal_cove_dev,
  146. .n_cell_devs = ARRAY_SIZE(crystal_cove_dev),
  147. .regmap_config = &crystal_cove_regmap_config,
  148. .irq_chip = &crystal_cove_irq_chip,
  149. };