machine.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * machine.h -- SoC Regulator support, machine/board driver API.
  3. *
  4. * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
  5. *
  6. * Author: Liam Girdwood <lg@opensource.wolfsonmicro.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Regulator Machine/Board Interface.
  13. */
  14. #ifndef __LINUX_REGULATOR_MACHINE_H_
  15. #define __LINUX_REGULATOR_MACHINE_H_
  16. #include <linux/regulator/consumer.h>
  17. #include <linux/suspend.h>
  18. struct regulator;
  19. /*
  20. * Regulator operation constraint flags. These flags are used to enable
  21. * certain regulator operations and can be OR'ed together.
  22. *
  23. * VOLTAGE: Regulator output voltage can be changed by software on this
  24. * board/machine.
  25. * CURRENT: Regulator output current can be changed by software on this
  26. * board/machine.
  27. * MODE: Regulator operating mode can be changed by software on this
  28. * board/machine.
  29. * STATUS: Regulator can be enabled and disabled.
  30. * DRMS: Dynamic Regulator Mode Switching is enabled for this regulator.
  31. */
  32. #define REGULATOR_CHANGE_VOLTAGE 0x1
  33. #define REGULATOR_CHANGE_CURRENT 0x2
  34. #define REGULATOR_CHANGE_MODE 0x4
  35. #define REGULATOR_CHANGE_STATUS 0x8
  36. #define REGULATOR_CHANGE_DRMS 0x10
  37. /**
  38. * struct regulator_state - regulator state during low power syatem states
  39. *
  40. * This describes a regulators state during a system wide low power state.
  41. */
  42. struct regulator_state {
  43. int uV; /* suspend voltage */
  44. unsigned int mode; /* suspend regulator operating mode */
  45. int enabled; /* is regulator enabled in this suspend state */
  46. };
  47. /**
  48. * struct regulation_constraints - regulator operating constraints.
  49. *
  50. * This struct describes regulator and board/machine specific constraints.
  51. */
  52. struct regulation_constraints {
  53. char *name;
  54. /* voltage output range (inclusive) - for voltage control */
  55. int min_uV;
  56. int max_uV;
  57. /* current output range (inclusive) - for current control */
  58. int min_uA;
  59. int max_uA;
  60. /* valid regulator operating modes for this machine */
  61. unsigned int valid_modes_mask;
  62. /* valid operations for regulator on this machine */
  63. unsigned int valid_ops_mask;
  64. /* regulator input voltage - only if supply is another regulator */
  65. int input_uV;
  66. /* regulator suspend states for global PMIC STANDBY/HIBERNATE */
  67. struct regulator_state state_disk;
  68. struct regulator_state state_mem;
  69. struct regulator_state state_standby;
  70. suspend_state_t initial_state; /* suspend state to set at init */
  71. /* constriant flags */
  72. unsigned always_on:1; /* regulator never off when system is on */
  73. unsigned boot_on:1; /* bootloader/firmware enabled regulator */
  74. unsigned apply_uV:1; /* apply uV constraint iff min == max */
  75. };
  76. /**
  77. * struct regulator_consumer_supply - supply -> device mapping
  78. *
  79. * This maps a supply name to a device.
  80. */
  81. struct regulator_consumer_supply {
  82. struct device *dev; /* consumer */
  83. const char *supply; /* consumer supply - e.g. "vcc" */
  84. };
  85. /**
  86. * struct regulator_init_data - regulator platform initialisation data.
  87. *
  88. * Initialisation constraints, our supply and consumers supplies.
  89. */
  90. struct regulator_init_data {
  91. struct device *supply_regulator_dev; /* or NULL for LINE */
  92. struct regulation_constraints constraints;
  93. int num_consumer_supplies;
  94. struct regulator_consumer_supply *consumer_supplies;
  95. /* optional regulator machine specific init */
  96. int (*regulator_init)(void *driver_data);
  97. void *driver_data; /* core does not touch this */
  98. };
  99. int regulator_suspend_prepare(suspend_state_t state);
  100. #endif