summaryrefslogtreecommitdiff
path: root/board/toradex/colibri_imx6/pf0100.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/toradex/colibri_imx6/pf0100.c')
-rw-r--r--board/toradex/colibri_imx6/pf0100.c81
1 files changed, 39 insertions, 42 deletions
diff --git a/board/toradex/colibri_imx6/pf0100.c b/board/toradex/colibri_imx6/pf0100.c
index 49c8f68cfb..3e31907227 100644
--- a/board/toradex/colibri_imx6/pf0100.c
+++ b/board/toradex/colibri_imx6/pf0100.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014, Toradex AG
+ * Copyright (C) 2014-2016, Toradex AG
*
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -38,17 +38,17 @@ unsigned pmic_init(void)
uchar devid, revid, val;
puts("PMIC: ");
- if(!(0 == i2c_set_bus_num(bus) && (0 == i2c_probe(PFUZE100_I2C_ADDR))))
- {
+ if (!((0 == i2c_set_bus_num(bus)) &&
+ (0 == i2c_probe(PFUZE100_I2C_ADDR)))) {
puts("i2c bus failed\n");
return 0;
}
/* get device ident */
- if( i2c_read(PFUZE100_I2C_ADDR, PFUZE100_DEVICEID, 1, &devid, 1) < 0) {
+ if (i2c_read(PFUZE100_I2C_ADDR, PFUZE100_DEVICEID, 1, &devid, 1) < 0) {
puts("i2c pmic devid read failed\n");
return 0;
}
- if( i2c_read(PFUZE100_I2C_ADDR, PFUZE100_REVID, 1, &revid, 1) < 0) {
+ if (i2c_read(PFUZE100_I2C_ADDR, PFUZE100_REVID, 1, &revid, 1) < 0) {
puts("i2c pmic revid read failed\n");
return 0;
}
@@ -56,13 +56,13 @@ unsigned pmic_init(void)
#ifdef DEBUG
{
- unsigned i,j;
+ unsigned i, j;
- for(i=0; i<16; i++)
- printf("\t%x",i);
- for(j=0; j<0x80; ) {
- printf("\n%2x",j);
- for(i=0; i<16; i++) {
+ for (i = 0; i < 16; i++)
+ printf("\t%x", i);
+ for (j = 0; j < 0x80; ) {
+ printf("\n%2x", j);
+ for (i = 0; i < 16; i++) {
i2c_read(PFUZE100_I2C_ADDR, j+i, 1, &val, 1);
printf("\t%2x", val);
}
@@ -71,15 +71,15 @@ unsigned pmic_init(void)
printf("\nEXT Page 1");
val = PFUZE100_PAGE_REGISTER_PAGE1;
- if( i2c_write(PFUZE100_I2C_ADDR, PFUZE100_PAGE_REGISTER, 1,
- &val, 1)) {
+ if (i2c_write(PFUZE100_I2C_ADDR, PFUZE100_PAGE_REGISTER, 1,
+ &val, 1)) {
puts("i2c write failed\n");
return 0;
}
- for(j=0x80; j<0x100; ) {
- printf("\n%2x",j);
- for(i=0; i<16; i++) {
+ for (j = 0x80; j < 0x100; ) {
+ printf("\n%2x", j);
+ for (i = 0; i < 16; i++) {
i2c_read(PFUZE100_I2C_ADDR, j+i, 1, &val, 1);
printf("\t%2x", val);
}
@@ -88,17 +88,15 @@ unsigned pmic_init(void)
printf("\nEXT Page 2");
val = PFUZE100_PAGE_REGISTER_PAGE2;
- if( i2c_write(PFUZE100_I2C_ADDR, PFUZE100_PAGE_REGISTER, 1,
- &val, 1)) {
+ if (i2c_write(PFUZE100_I2C_ADDR, PFUZE100_PAGE_REGISTER, 1,
+ &val, 1)) {
puts("i2c write failed\n");
return 0;
}
- for(j=0x80; j<0x100; )
- {
- printf("\n%2x",j);
- for(i=0; i<16; i++)
- {
+ for (j = 0x80; j < 0x100; ) {
+ printf("\n%2x", j);
+ for (i = 0; i < 16; i++) {
i2c_read(PFUZE100_I2C_ADDR, j+i, 1, &val, 1);
printf("\t%2x", val);
}
@@ -109,30 +107,29 @@ unsigned pmic_init(void)
#endif
/* get device programmed state */
val = PFUZE100_PAGE_REGISTER_PAGE1;
- if( i2c_write(PFUZE100_I2C_ADDR, PFUZE100_PAGE_REGISTER, 1, &val, 1))
- {
+ if (i2c_write(PFUZE100_I2C_ADDR, PFUZE100_PAGE_REGISTER, 1, &val, 1)) {
puts("i2c write failed\n");
return 0;
}
- if( i2c_read(PFUZE100_I2C_ADDR, PFUZE100_FUSE_POR1, 1, &val, 1) < 0) {
+ if (i2c_read(PFUZE100_I2C_ADDR, PFUZE100_FUSE_POR1, 1, &val, 1) < 0) {
puts("i2c fuse_por read failed\n");
return 0;
}
- if(val & PFUZE100_FUSE_POR_M)
+ if (val & PFUZE100_FUSE_POR_M)
programmed++;
- if( i2c_read(PFUZE100_I2C_ADDR, PFUZE100_FUSE_POR2, 1, &val, 1) < 0) {
+ if (i2c_read(PFUZE100_I2C_ADDR, PFUZE100_FUSE_POR2, 1, &val, 1) < 0) {
puts("i2c fuse_por read failed\n");
return programmed;
}
- if(val & PFUZE100_FUSE_POR_M)
+ if (val & PFUZE100_FUSE_POR_M)
programmed++;
- if( i2c_read(PFUZE100_I2C_ADDR, PFUZE100_FUSE_POR3, 1, &val, 1) < 0) {
+ if (i2c_read(PFUZE100_I2C_ADDR, PFUZE100_FUSE_POR3, 1, &val, 1) < 0) {
puts("i2c fuse_por read failed\n");
return programmed;
}
- if(val & PFUZE100_FUSE_POR_M)
+ if (val & PFUZE100_FUSE_POR_M)
programmed++;
switch (programmed) {
@@ -156,29 +153,29 @@ int pf0100_prog(void)
unsigned char val;
unsigned char bus = 1;
- if(pmic_init() == 3) {
+ if (pmic_init() == 3) {
puts("PMIC already programmed, exiting\n");
return CMD_RET_FAILURE;
}
/* set up gpio to manipulate vprog, initially off */
imx_iomux_v3_setup_multiple_pads(pmic_prog_pads,
- ARRAY_SIZE(pmic_prog_pads));
+ ARRAY_SIZE(pmic_prog_pads));
gpio_direction_output(PMIC_PROG_VOLTAGE, 0);
- if(!(0 == i2c_set_bus_num(bus) && (0 == i2c_probe(PFUZE100_I2C_ADDR))))
- {
+ if (!((0 == i2c_set_bus_num(bus)) &&
+ (0 == i2c_probe(PFUZE100_I2C_ADDR)))) {
puts("i2c bus failed\n");
return CMD_RET_FAILURE;
}
- for (i=0; i<ARRAY_SIZE(pmic_otp_prog); i++) {
- switch(pmic_otp_prog[i].cmd) {
+ for (i = 0; i < ARRAY_SIZE(pmic_otp_prog); i++) {
+ switch (pmic_otp_prog[i].cmd) {
case pmic_i2c:
val = (unsigned char) (pmic_otp_prog[i].value & 0xff);
- if( i2c_write(PFUZE100_I2C_ADDR, pmic_otp_prog[i].reg,
- 1, &val, 1)) {
- printf("i2c write failed, reg 0x%2x, value"
- "0x%2x\n", pmic_otp_prog[i].reg, val);
+ if (i2c_write(PFUZE100_I2C_ADDR, pmic_otp_prog[i].reg,
+ 1, &val, 1)) {
+ printf("i2c write failed, reg 0x%2x, value 0x%2x\n",
+ pmic_otp_prog[i].reg, val);
return CMD_RET_FAILURE;
}
break;
@@ -187,7 +184,7 @@ int pf0100_prog(void)
break;
case pmic_vpgm:
gpio_direction_output(PMIC_PROG_VOLTAGE,
- pmic_otp_prog[i].value);
+ pmic_otp_prog[i].value);
break;
case pmic_pwr:
/* TODO */