Commit c508d22abbf0bcf2ee0fe649810ed62dcb58acaa

Authored by Max Krummenacher
Committed by Stefano Babic
1 parent eaa50e08be

colibri imx6: pf0100: reorder and cleanup message printing

Keep debug code at the end of the function.
Use a one line informational message for the PMIC only.

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>

Showing 1 changed file with 41 additions and 41 deletions Side-by-side Diff

board/toradex/colibri_imx6/pf0100.c
... ... @@ -35,7 +35,7 @@
35 35 uchar bus = 1;
36 36 uchar devid, revid, val;
37 37  
38   - puts("PMIC: ");
  38 + puts("PMIC: ");
39 39 rc = i2c_get_chip_for_busnum(bus, PFUZE100_I2C_ADDR, 1, &dev);
40 40 if (rc) {
41 41 printf("failed to get device for PMIC at address 0x%x\n",
42 42  
... ... @@ -51,8 +51,47 @@
51 51 puts("i2c pmic revid read failed\n");
52 52 return 0;
53 53 }
54   - printf("device id: 0x%.2x, revision id: 0x%.2x\n", devid, revid);
  54 + printf("device id: 0x%.2x, revision id: 0x%.2x, ", devid, revid);
55 55  
  56 + /* get device programmed state */
  57 + val = PFUZE100_PAGE_REGISTER_PAGE1;
  58 + if (dm_i2c_write(dev, PFUZE100_PAGE_REGISTER, &val, 1)) {
  59 + puts("i2c write failed\n");
  60 + return 0;
  61 + }
  62 + if (dm_i2c_read(dev, PFUZE100_FUSE_POR1, &val, 1) < 0) {
  63 + puts("i2c fuse_por read failed\n");
  64 + return 0;
  65 + }
  66 + if (val & PFUZE100_FUSE_POR_M)
  67 + programmed++;
  68 +
  69 + if (dm_i2c_read(dev, PFUZE100_FUSE_POR2, &val, 1) < 0) {
  70 + puts("i2c fuse_por read failed\n");
  71 + return programmed;
  72 + }
  73 + if (val & PFUZE100_FUSE_POR_M)
  74 + programmed++;
  75 +
  76 + if (dm_i2c_read(dev, PFUZE100_FUSE_POR3, &val, 1) < 0) {
  77 + puts("i2c fuse_por read failed\n");
  78 + return programmed;
  79 + }
  80 + if (val & PFUZE100_FUSE_POR_M)
  81 + programmed++;
  82 +
  83 + switch (programmed) {
  84 + case 0:
  85 + puts("not programmed\n");
  86 + break;
  87 + case 3:
  88 + puts("programmed\n");
  89 + break;
  90 + default:
  91 + puts("undefined programming state\n");
  92 + break;
  93 + }
  94 +
56 95 #ifdef DEBUG
57 96 {
58 97 unsigned int i, j;
... ... @@ -102,45 +141,6 @@
102 141 printf("\n");
103 142 }
104 143 #endif /* DEBUG */
105   -
106   - /* get device programmed state */
107   - val = PFUZE100_PAGE_REGISTER_PAGE1;
108   - if (dm_i2c_write(dev, PFUZE100_PAGE_REGISTER, &val, 1)) {
109   - puts("i2c write failed\n");
110   - return 0;
111   - }
112   - if (dm_i2c_read(dev, PFUZE100_FUSE_POR1, &val, 1) < 0) {
113   - puts("i2c fuse_por read failed\n");
114   - return 0;
115   - }
116   - if (val & PFUZE100_FUSE_POR_M)
117   - programmed++;
118   -
119   - if (dm_i2c_read(dev, PFUZE100_FUSE_POR2, &val, 1) < 0) {
120   - puts("i2c fuse_por read failed\n");
121   - return programmed;
122   - }
123   - if (val & PFUZE100_FUSE_POR_M)
124   - programmed++;
125   -
126   - if (dm_i2c_read(dev, PFUZE100_FUSE_POR3, &val, 1) < 0) {
127   - puts("i2c fuse_por read failed\n");
128   - return programmed;
129   - }
130   - if (val & PFUZE100_FUSE_POR_M)
131   - programmed++;
132   -
133   - switch (programmed) {
134   - case 0:
135   - printf("PMIC: not programmed\n");
136   - break;
137   - case 3:
138   - printf("PMIC: programmed\n");
139   - break;
140   - default:
141   - printf("PMIC: undefined programming state\n");
142   - break;
143   - }
144 144  
145 145 return programmed;
146 146 }