Commit 571a354b1542a274d88617e1f6703f3fe7a517f1

Authored by Liam Girdwood
1 parent e2ce4eaa76

regulator: regulator driver interface

This allows regulator drivers to register their regulators and provide
operations to the core. It also has a notifier call chain for propagating
regulator events to clients.

Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Showing 1 changed file with 99 additions and 0 deletions Side-by-side Diff

include/linux/regulator/driver.h
  1 +/*
  2 + * driver.h -- SoC Regulator driver support.
  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 Driver Interface.
  13 + */
  14 +
  15 +#ifndef __LINUX_REGULATOR_DRIVER_H_
  16 +#define __LINUX_REGULATOR_DRIVER_H_
  17 +
  18 +#include <linux/device.h>
  19 +#include <linux/regulator/consumer.h>
  20 +
  21 +struct regulator_constraints;
  22 +struct regulator_dev;
  23 +
  24 +/**
  25 + * struct regulator_ops - regulator operations.
  26 + *
  27 + * This struct describes regulator operations.
  28 + */
  29 +struct regulator_ops {
  30 +
  31 + /* get/set regulator voltage */
  32 + int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV);
  33 + int (*get_voltage) (struct regulator_dev *);
  34 +
  35 + /* get/set regulator current */
  36 + int (*set_current_limit) (struct regulator_dev *,
  37 + int min_uA, int max_uA);
  38 + int (*get_current_limit) (struct regulator_dev *);
  39 +
  40 + /* enable/disable regulator */
  41 + int (*enable) (struct regulator_dev *);
  42 + int (*disable) (struct regulator_dev *);
  43 + int (*is_enabled) (struct regulator_dev *);
  44 +
  45 + /* get/set regulator operating mode (defined in regulator.h) */
  46 + int (*set_mode) (struct regulator_dev *, unsigned int mode);
  47 + unsigned int (*get_mode) (struct regulator_dev *);
  48 +
  49 + /* get most efficient regulator operating mode for load */
  50 + unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV,
  51 + int output_uV, int load_uA);
  52 +
  53 + /* the operations below are for configuration of regulator state when
  54 + * it's parent PMIC enters a global STANBY/HIBERNATE state */
  55 +
  56 + /* set regulator suspend voltage */
  57 + int (*set_suspend_voltage) (struct regulator_dev *, int uV);
  58 +
  59 + /* enable/disable regulator in suspend state */
  60 + int (*set_suspend_enable) (struct regulator_dev *);
  61 + int (*set_suspend_disable) (struct regulator_dev *);
  62 +
  63 + /* set regulator suspend operating mode (defined in regulator.h) */
  64 + int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode);
  65 +};
  66 +
  67 +/*
  68 + * Regulators can either control voltage or current.
  69 + */
  70 +enum regulator_type {
  71 + REGULATOR_VOLTAGE,
  72 + REGULATOR_CURRENT,
  73 +};
  74 +
  75 +/**
  76 + * struct regulator_desc - Regulator descriptor
  77 + *
  78 + */
  79 +struct regulator_desc {
  80 + const char *name;
  81 + int id;
  82 + struct regulator_ops *ops;
  83 + int irq;
  84 + enum regulator_type type;
  85 + struct module *owner;
  86 +};
  87 +
  88 +
  89 +struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
  90 + void *reg_data);
  91 +void regulator_unregister(struct regulator_dev *rdev);
  92 +
  93 +int regulator_notifier_call_chain(struct regulator_dev *rdev,
  94 + unsigned long event, void *data);
  95 +
  96 +void *rdev_get_drvdata(struct regulator_dev *rdev);
  97 +int rdev_get_id(struct regulator_dev *rdev);
  98 +
  99 +#endif