三、linux電源フレーム

17389 ワード

転載先:http://www.cnblogs.com/connectfuture/
参照:linux-2.6.32.61Documentationpowerregulator
一、紹介
電源フレームは、電源出力を動的に調整し、省電力効果を達成します.
二、基本用語
  • Regulator

  • 他の設備の電源を供給する電子設備で、一部の電源はスイッチと出力を制御する電圧電流を持っている.
  • PMIC(Power Management IC)

  • 電源管理チップは、複数の電源、さらには他のサブシステムを内包しています.
  • Consumer

  • regulatorによって電力を供給する装置をconsumerと総称し、静的と動的の2種類に分けることができる.
    静的:電圧電流を変える必要はなく、スイッチング電源だけが必要で、通常bootloader、firmware、kernel board段階で設定されます.
    ダイナミック:操作ニーズに応じて電圧電流を変更します.
  • Power Domain

  • 電源または他の電源領域の出力を入力する回路.
    電源はスイッチの後、下図のようになります.
     Regulator -+-> Switch-1 -+-> Switch-2 --> [Consumer A]                              |             |                              |             +-> [Consumer B], [Consumer C]                              |                              +-> [Consumer D], [Consumer E]
    1つの電源ドメインと3つの電源ドメインです.
    Domain 1: Switch-1, Consumers D & E.Domain 2: Switch-2, Consumers B & C.Domain 3: Consumer A.
    3つの出力関係(1の出力は2の入力、2の出力は3の入力):
    Domain-1 --> Domain-2 --> Domain-3.
    1つの電源ドメインの電源は、次のような他の電源から供給することもできます.
    Regulator-1 -+-> Regulator-2 -+-> [Consumer A]                                |                                +-> [Consumer B]
    ここには2つの電源ドメインがあります.
    Domain 1:Regulator-2,Consumer B.Domain 2:Consumer A.出力関係:
    Domain-1 --> Domain-2
  • Constraints

  • 電源プロパティの定義とハードウェアの保護に使用される制約は、次の3つに分けられます.
    Regulator Level:
    次のように、電源ハードウェアのパラメータ仕様を定義します.
    - voltage output is in the range 800mV -> 3500mV.- regulator current output limit is 20mA @ 5V but is 10mA @ 10V.
    Power Domain Level:
    kernel board初期化コードによって定義され、次のような電源ドメインの電源範囲を制約します.
    - Domain-1 voltage is 3300mV- Domain-2 voltage is 1400mV -> 1600mV- Domain-3 current limit is 0mA -> 20mA.
    Consumer Level:
    駆動設定により、電流電圧を動的に調整します.
    制約の例:
    e.g. a consumer backlight driver asks for a current increase from 5mA to 10mA to increase LCD illumination. This passes to through the levels as follows :-Consumer: need to increase LCD brightness. Lookup and request next current mA value in brightness table (the consumer driver could be used on several different personalities based upon the same reference device).Power Domain: is the new current limit within the domain operating limits for this domain and system state (e.g.battery power, USB power)Regulator Domains: is the new current limit within the regulator operating parameters for input/output voltage.If the regulator request passes all the constraint tests then the new regulator value is applied.
    三、Regulator Consumer Driver Interface
  • Consumer Regulator Access (static & dynamic drivers)

  • regulator = regulator_get(dev, "Vcc");
    このインタフェースを使用して、ドライバに対応するregulatorを取得します.devは駆動対応のデバイスポインタで、「Vcc」は電源IDです.カーネルは電源ID対応のregulatorを調べます.
    regulator_put(regulator);
    このインタフェースでregulatorを解放します.
    regulator_getとregulator_putは通常driverのprobeおよびremoveで呼び出されます.
  • Regulator Output Enable & Disable (static & dynamic drivers)

  • int regulator_enable(regulator);
    このインタフェースで電源を出力します.
    注意:この関数を調整する前に、電源出力が使用可能になっている可能性があります.
    NOTE: The supply may already be enabled before regulator_enabled() is called.This may happen if the consumer shares the regulator or the regulator has beenpreviously enabled by bootloader or kernel board initialization code.
    int regulator_is_enabled(regulator);
    このインタフェースで電源出力が使用可能かどうかを判断します.戻り値が0より大きい場合に使用できます.
    int regulator_disable(regulator);
    このインタフェースで電源出力をオフにします.
    注意:この関数を調整すると、電源がすぐに切れるとは限りません.共有電源シーンがあります.
    NOTE: This may not disable the supply if it's shared with other consumers. Theregulator will only be disabled when the enabled reference count is zero.
    int regulator_force_disable(regulator);
    このインタフェースですぐに電源を切ります.
  • Regulator Voltage Control & Status (dynamic drivers)

  • int regulator_set_voltage(regulator, min_uV, max_uV);
    このインタフェースにより、電圧の最小出力と最大出力を調整できます.
    注意:呼び出しタイミング
    NOTE: this can be called when the regulator is enabled or disabled. If calledwhen enabled, then the voltage changes instantly, otherwise the voltageconfiguration changes and the voltage is physically set when the regulator isnext enabled.
    int regulator_get_voltage(regulator);
    このインタフェースから構成された出力電圧を取得します.
    NOTE: get_voltage() will return the configured output voltage whether theregulator is enabled or disabled and should NOT be used to determine regulatoroutput state. However this can be used in conjunction with is_enabled() todetermine the regulator physical output voltage.
    四、Regulator Machine Driver Interface
    前述した電源ドメインにはトポロジーがあり、サブノードの電源がオンの場合、対応する一連の親ノードもオンになります.次のregulator machineで説明します.

     1 Regulator Machine Driver Interface
    
     2 ===================================
    
     3 
    
     4 The regulator machine driver interface is intended for board/machine specific
    
     5 initialisation code to configure the regulator subsystem.
    
     6 
    
     7 Consider the following machine :-
    
     8 
    
     9   Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
    
    10                |
    
    11                +-> [Consumer B @ 3.3V]
    
    12 
    
    13 The drivers for consumers A & B must be mapped to the correct regulator in
    
    14 order to control their power supply. This mapping can be achieved in machine
    
    15 initialisation code by creating a struct regulator_consumer_supply for
    
    16 each regulator.
    
    17 
    
    18 struct regulator_consumer_supply {
    
    19     struct device *dev;    /* consumer */
    
    20     const char *supply;    /* consumer supply - e.g. "vcc" */
    
    21 };
    
    22 
    
    23 e.g. for the machine above
    
    24 
    
    25 static struct regulator_consumer_supply regulator1_consumers[] = {
    
    26 {
    
    27     .dev    = &platform_consumerB_device.dev,
    
    28     .supply    = "Vcc",
    
    29 },};
    
    30 
    
    31 static struct regulator_consumer_supply regulator2_consumers[] = {
    
    32 {
    
    33     .dev    = &platform_consumerA_device.dev,
    
    34     .supply    = "Vcc",
    
    35 },};
    
    36 
    
    37 This maps Regulator-1 to the 'Vcc' supply for Consumer B and maps Regulator-2
    
    38 to the 'Vcc' supply for Consumer A.
    
    39 
    
    40 Constraints can now be registered by defining a struct regulator_init_data
    
    41 for each regulator power domain. This structure also maps the consumers
    
    42 to their supply regulator :-
    
    43 
    
    44 static struct regulator_init_data regulator1_data = {
    
    45     .constraints = {
    
    46         .min_uV = 3300000,
    
    47         .max_uV = 3300000,
    
    48         .valid_modes_mask = REGULATOR_MODE_NORMAL,
    
    49     },
    
    50     .num_consumer_supplies = ARRAY_SIZE(regulator1_consumers),
    
    51     .consumer_supplies = regulator1_consumers,
    
    52 };
    
    53 
    
    54 Regulator-1 supplies power to Regulator-2. This relationship must be registered
    
    55 with the core so that Regulator-1 is also enabled when Consumer A enables it's
    
    56 supply (Regulator-2). The supply regulator is set by the supply_regulator_dev
    
    57 field below:-
    
    58 
    
    59 static struct regulator_init_data regulator2_data = {
    
    60     .supply_regulator_dev = &platform_regulator1_device.dev,
    
    61     .constraints = {
    
    62         .min_uV = 1800000,
    
    63         .max_uV = 2000000,
    
    64         .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
    
    65         .valid_modes_mask = REGULATOR_MODE_NORMAL,
    
    66     },
    
    67     .num_consumer_supplies = ARRAY_SIZE(regulator2_consumers),
    
    68     .consumer_supplies = regulator2_consumers,
    
    69 };
    
    70 
    
    71 Finally the regulator devices must be registered in the usual manner.
    
    72 
    
    73 static struct platform_device regulator_devices[] = {
    
    74 {
    
    75     .name = "regulator",
    
    76     .id = DCDC_1,
    
    77     .dev = {
    
    78         .platform_data = &regulator1_data,
    
    79     },
    
    80 },
    
    81 {
    
    82     .name = "regulator",
    
    83     .id = DCDC_2,
    
    84     .dev = {
    
    85         .platform_data = &regulator2_data,
    
    86     },
    
    87 },
    
    88 };
    
    89 /* register regulator 1 device */
    
    90 platform_device_register(&regulator_devices[0]);
    
    91 
    
    92 /* register regulator 2 device */
    
    93 platform_device_register(&regulator_devices[1]);

    regulator machine driver interface