fireHydrantDataOperation.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * OMAP Voltage Controller (VC) interface
  3. *
  4. * Copyright (C) 2011 Texas Instruments, Inc.
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/delay.h>
  12. #include <linux/init.h>
  13. #include <linux/bug.h>
  14. #include <linux/io.h>
  15. #include <asm/div64.h>
  16. #include "iomap.h"
  17. #include "soc.h"
  18. #include "voltage.h"
  19. #include "vc.h"
  20. #include "prm-regbits-34xx.h"
  21. #include "prm-regbits-44xx.h"
  22. #include "prm44xx.h"
  23. #include "pm.h"
  24. #include "scrm44xx.h"
  25. #include "control.h"
  26. /**
  27. * struct omap_vc_channel_cfg - describe the cfg_channel bitfield
  28. * @sa: bit for slave address
  29. * @rav: bit for voltage configuration register
  30. * @rac: bit for command configuration register
  31. * @racen: enable bit for RAC
  32. * @cmd: bit for command value set selection
  33. *
  34. * Channel configuration bits, common for OMAP3+
  35. * OMAP3 register: PRM_VC_CH_CONF
  36. * OMAP4 register: PRM_VC_CFG_CHANNEL
  37. * OMAP5 register: PRM_VC_SMPS_<voltdm>_CONFIG
  38. */
  39. struct omap_vc_channel_cfg {
  40. u8 sa;
  41. u8 rav;
  42. u8 rac;
  43. u8 racen;
  44. u8 cmd;
  45. };
  46. static struct omap_vc_channel_cfg vc_default_channel_cfg = {
  47. .sa = BIT(0),
  48. .rav = BIT(1),
  49. .rac = BIT(2),
  50. .racen = BIT(3),
  51. .cmd = BIT(4),
  52. };
  53. /*
  54. * On OMAP3+, all VC channels have the above default bitfield
  55. * configuration, except the OMAP4 MPU channel. This appears
  56. * to be a freak accident as every other VC channel has the
  57. * default configuration, thus creating a mutant channel config.
  58. */
  59. static struct omap_vc_channel_cfg vc_mutant_channel_cfg = {
  60. .sa = BIT(0),
  61. .rav = BIT(2),
  62. .rac = BIT(3),
  63. .racen = BIT(4),
  64. .cmd = BIT(1),
  65. };
  66. static struct omap_vc_channel_cfg *vc_cfg_bits;
  67. /* Default I2C trace length on pcb, 6.3cm. Used for capacitance calculations. */
  68. static u32 sr_i2c_pcb_length = 63;
  69. #define CFG_CHANNEL_MASK 0x1f
  70. /**
  71. * omap_vc_config_channel - configure VC channel to PMIC mappings
  72. * @voltdm: pointer to voltagdomain defining the desired VC channel
  73. *
  74. * Configures the VC channel to PMIC mappings for the following
  75. * PMIC settings
  76. * - i2c slave address (SA)
  77. * - voltage configuration address (RAV)
  78. * - command configuration address (RAC) and enable bit (RACEN)
  79. * - command values for ON, ONLP, RET and OFF (CMD)
  80. *
  81. * This function currently only allows flexible configuration of the
  82. * non-default channel. Starting with OMAP4, there are more than 2
  83. * channels, with one defined as the default (on OMAP4, it's MPU.)
  84. * Only the non-default channel can be configured.
  85. */
  86. static int omap_vc_config_channel(struct voltagedomain *voltdm)
  87. {
  88. struct omap_vc_channel *vc = voltdm->vc;
  89. /*
  90. * For default channel, the only configurable bit is RACEN.
  91. * All others must stay at zero (see function comment above.)
  92. */
  93. if (vc->flags & OMAP_VC_CHANNEL_DEFAULT)
  94. vc->cfg_channel &= vc_cfg_bits->racen;