Case study – Intersil ISL6271A voltage regulator

This PMIC provides three regulator's devices, among which only one can have its output value changed. The two others provide fixed voltages:

struct isl_pmic { 
   struct i2c_client *client; 
   struct regulator_dev    *rdev[3]; 
   struct mutex            mtx; 
}; 

First, we define ops callbacks, to set up a struct regulator_desc:

  1. A callback to handle a get_voltage_sel operation:
static int isl6271a_get_voltage_sel(struct regulator_dev *rdev) 
{ 
   struct isl_pmic *pmic = rdev_get_drvdata(dev); 
   int idx = rdev_get_id(rdev); 
   idx = i2c_smbus_read_byte(pmic->client); 
   if (idx < 0) 
         [...] /* handle this error */ 
 
   return idx; 
} 

The following is the callback to handle a set_voltage_sel operation:

static int isl6271a_set_voltage_sel( ...

Get Linux Device Drivers Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.