world leader in high performance signal processing
This version (06 Feb 2014 11:40) was approved by larsc.The Previously approved version (16 Nov 2012 13:38) is available.Diff

ADP150 Regulator Fixed Voltage Linux Driver

Supported Devices

Evaluation Boards

Reference Circuits

Description

The fixed regulator voltage driver can be used to control these chips. Please connect the ENable switch pin to any available GPIO port on your CPU. This driver adapts to voltage and current regulator framework in Linux kernel.

Configuration

Software configurable features

Source Code

Status

Source Mainlined?
git Yes

Files

Example platform device initialization

The default platform info defined in bf537-stamp board file is for ad122. If you want to customize this driver for other switch only regulator, you should revise the platform information accordingly.

  • Define device supply name exported by the adp_switch driver.

file: arch/blackfin/mach-bf537/boards/stamp.c

static struct regulator_consumer_supply adp122_consumers = {
		.supply = REGULATOR_ADP122,
};
  • Define regulator init data of this supply.

file: arch/blackfin/mach-bf537/boards/stamp.c

static struct regulator_init_data adp_switch_regulator_data = {
	.constraints = {
		.name = REGULATOR_ADP122,
		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
		.min_uV = REGULATOR_ADP122_UV,
		.max_uV = REGULATOR_ADP122_UV,
		.min_uA = 0,
		.max_uA = 300000,
	},
	.num_consumer_supplies = 1,	/* only 1 */
	.consumer_supplies     = &adp122_consumers,
};
  • Add new userspace consumer platform device for this supply.

file: arch/blackfin/mach-bf537/boards/stamp.c

static struct regulator_bulk_data adp122_bulk_data = {
	.supply = REGULATOR_ADP122,
};

file: arch/blackfin/mach-bf537/boards/stamp.c

static struct regulator_userspace_consumer_data adp122_userspace_comsumer_data = {
	.name = REGULATOR_ADP122,
	.num_supplies = 1,
	.supplies = &adp122_bulk_data,
};

file: arch/blackfin/mach-bf537/boards/stamp.c

static struct platform_device adp122_userspace_consumer_device = {
	.name = "reg-userspace-consumer",
	.id = 0,
	.dev = {
		.platform_data = &adp122_userspace_comsumer_data,
	},
};

Adding Linux driver support

Enable generic GPIO lib in kernel option.

Device Drivers  --->
[*] GPIO Support  --->

Select voltage and current regulator framework support and enable adp_switch driver. Don't forget to select userspace regulator consumer driver as a module. adp_switch driver is initialized after userspace consumer driver, if both are built into kernel.

Device Drivers  --->
[*] Voltage and Current Regulator Support  --->
    <*>   Fixed voltage regulator support
    <*>   Userspace regulator consumer support

Hardware configuration

Driver testing

Check regulator driver initialization information at kernel booting.

regulator: core version 0.5
regulator: adp122: 2500 mV                                                                     

Check if adp122 is probed properly.

root:/> ls sys/class/regulator/
regulator.0
root:/> ls sys/class/regulator/regulator.0/
device      name        power       subsystem   uevent
microvolts  num_users   state       type
root:/> cat sys/class/regulator/regulator.0/name
adp122
root:/> cat sys/class/regulator/regulator.0/type
voltage
root:/> cat sys/class/regulator/regulator.0/microvolts
2500000
root:/> cat sys/class/regulator/regulator.0/state
disabled
root:/> cat sys/class/regulator/regulator.0/num_users
0

Insert user space consumer driver module and check usability.

root:/> modprobe userspace-consumer
root:/> ls sys/devices/platform/reg-userspace-consumer.0/
driver                      power
microamps_requested_adp122  state
modalias                    subsystem
name                        uevent
root:/> cat sys/devices/platform/reg-userspace-consumer.0/name
adp122
root:/> cat sys/devices/platform/reg-userspace-consumer.0/state
disabled
root:/> echo enabled > sys/devices/platform/reg-userspace-consumer.0/state
root:/> cat sys/devices/platform/reg-userspace-consumer.0/state
enabled

More Information