/* * This driver can only access the non-USB portions of STw4811, the register * range 0x00-0x10 dealing with USB is bound to the two special I2C pins used * for USB control.
*/
/* Registers inside the power control address space */ #define STW_PC_VCORE_SEL 0x05U #define STW_PC_VAUX_SEL 0x06U #define STW_PC_VPLL_SEL 0x07U
/** * stw481x_get_pctl_reg() - get a power control register * @stw481x: handle to the stw481x chip * @reg: power control register to fetch * * The power control registers is a set of one-time-programmable registers * in its own register space, accessed by writing addess bits to these * two registers: bits 7,6,5 of PCTL_REG_LO corresponds to the 3 LSBs of * the address and bits 8,9 of PCTL_REG_HI corresponds to the 2 MSBs of * the address, forming an address space of 5 bits, i.e. 32 registers * 0x00 ... 0x1f can be obtained.
*/ staticint stw481x_get_pctl_reg(struct stw481x *stw481x, u8 reg)
{
u8 msb = (reg >> 3) & 0x03;
u8 lsb = (reg << 5) & 0xe0; unsignedint val;
u8 vrfy; int ret;
ret = regmap_write(stw481x->map, STW_PCTL_REG_HI, msb); if (ret) return ret;
ret = regmap_write(stw481x->map, STW_PCTL_REG_LO, lsb); if (ret) return ret;
ret = regmap_read(stw481x->map, STW_PCTL_REG_HI, &val); if (ret) return ret;
vrfy = (val & 0x03) << 3;
ret = regmap_read(stw481x->map, STW_PCTL_REG_LO, &val); if (ret) return ret;
vrfy |= ((val >> 5) & 0x07); if (vrfy != reg) return -EIO; return (val >> 1) & 0x0f;
}
ret = regmap_read(stw481x->map, STW_VCORE_SLEEP, &val); if (ret) return ret;
vcore_slp = val & 0x0f;
dev_info(&stw481x->client->dev, "VCORE SLEEP: %u.%uV\n",
vcore_val[vcore_slp] / 100, vcore_val[vcore_slp] % 100);
return 0;
}
/* * MFD cells - we have one cell which is selected operation * mode, and we always have a GPIO cell.
*/ staticstruct mfd_cell stw481x_cells[] = {
{
.of_compatible = "st,stw481x-vmmc",
.name = "stw481x-vmmc-regulator",
.id = -1,
},
};
staticint stw481x_probe(struct i2c_client *client)
{ struct stw481x *stw481x; int ret; int i;
stw481x = devm_kzalloc(&client->dev, sizeof(*stw481x), GFP_KERNEL); if (!stw481x) return -ENOMEM;
i2c_set_clientdata(client, stw481x);
stw481x->client = client;
stw481x->map = devm_regmap_init_i2c(client, &stw481x_regmap_config); if (IS_ERR(stw481x->map)) {
ret = PTR_ERR(stw481x->map);
dev_err(&client->dev, "Failed to allocate register map: %d\n",
ret); return ret;
}
ret = stw481x_startup(stw481x); if (ret) {
dev_err(&client->dev, "chip initialization failed\n"); return ret;
}
/* Set up and register the platform devices. */ for (i = 0; i < ARRAY_SIZE(stw481x_cells); i++) { /* One state holder for all drivers, this is simple */
stw481x_cells[i].platform_data = stw481x;
stw481x_cells[i].pdata_size = sizeof(*stw481x);
}
ret = devm_mfd_add_devices(&client->dev, 0, stw481x_cells,
ARRAY_SIZE(stw481x_cells), NULL, 0, NULL); if (ret) return ret;
/* * This ID table is completely unused, as this is a pure * device-tree probed driver, but it has to be here due to * the structure of the I2C core.
*/ staticconststruct i2c_device_id stw481x_id[] = {
{ "stw481x" },
{ }
};
MODULE_DEVICE_TABLE(i2c, stw481x_id);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.