一点点读懂regulator(三)

本节我们主要介绍Regulator Machine Driver Interface

The regulator machine driver interface用于配置regulator subsystemboard/machine特定初始化代码。

Consider the following machine:

Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
             |
             +-> [Consumer B @ 3.3V]

consumers A和B的驱动器必须映射到正确的regulator才能控制其电源。通过为每个regulator创建一个结构体 regulator_consumer_supply可以在machine initialisation code中实现此映射:

struct regulator_consumer_supply {
      const char *dev_name;   /* consumer dev_name() */
      const char *supply;     /* consumer supply - e.g. "vcc" */
};

e.g. for the machine above:

static struct regulator_consumer_supply regulator1_consumers[] = {
      REGULATOR_SUPPLY("Vcc", "consumer B"),
};
 
static struct regulator_consumer_supply regulator2_consumers[] = {
      REGULATOR_SUPPLY("Vcc", "consumer A"),
};

This maps Regulator-1 to the ‘Vcc’ supply for Consumer B and maps Regulator-2 to the ‘Vcc’ supply for Consumer A.

现在,可以通过为每个regulator电源域定义一个结构regulator_init_data来注册约束。此结构还将consumers映射到其supply regulators

static struct regulator_init_data regulator1_data = {
      .constraints = {
              .name = "Regulator-1",
              .min_uV = 3300000,
              .max_uV = 3300000,
              .valid_modes_mask = REGULATOR_MODE_NORMAL,
      },
      .num_consumer_supplies = ARRAY_SIZE(regulator1_consumers),
      .consumer_supplies = regulator1_consumers,
};

The name field should be set to something that is usefully descriptive for the board for configuration of supplies for other regulators and for use in logging and other diagnostic output. Normally the name used for the supply rail in the schematic is a good choice. If no name is provided then the subsystem will choose one.

Regulator-1 supplies power to Regulator-2. This relationship must be registered with the core so that Regulator-1 is also enabled when Consumer A enables its supply (Regulator-2). The supply regulator is set by the supply_regulator field below and co:

static struct regulator_init_data regulator2_data = {
      .supply_regulator = "Regulator-1",
      .constraints = {
              .min_uV = 1800000,
              .max_uV = 2000000,
              .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
              .valid_modes_mask = REGULATOR_MODE_NORMAL,
      },
      .num_consumer_supplies = ARRAY_SIZE(regulator2_consumers),
      .consumer_supplies = regulator2_consumers,
};

Finally the regulator devices must be registered in the usual manner:

static struct platform_device regulator_devices[] = {
      {
              .name = "regulator",
              .id = DCDC_1,
              .dev = {
                      .platform_data = &regulator1_data,
              },
      },
      {
              .name = "regulator",
              .id = DCDC_2,
              .dev = {
                      .platform_data = &regulator2_data,
              },
      },
};
/* register regulator 1 device */
platform_device_register(&regulator_devices[0]);
/* register regulator 2 device */
platform_device_register(&regulator_devices[1]);

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值