Skip to content
This repository
Browse code

Attempt at enabling more pins for A1 EEPROM format

  • Loading branch information...
commit c6cf41cf4e1beb59a857c98862139667581f30d7 1 parent debd593
Jason Kridner authored
4 node_modules/bonescript/bone.js
@@ -117,8 +117,8 @@ var bone =
117 117 P9_38: { name: "AIN3", ain: 3, eeprom: 70, scale: 4096 },
118 118 P9_39: { name: "AIN0", ain: 0, eeprom: 67, scale: 4096 },
119 119 P9_40: { name: "AIN1", ain: 1, eeprom: 68, scale: 4096 },
120   - P9_41: { name: "CLKOUT2", gpio: gpio0+20, mux: "xdma_event_intr1", eeprom: 13 },
121   - P9_42: { name: "GPIO0_7", gpio: gpio0+7, mux: "ecap0_in_pwm0_out", eeprom: 4,
  120 + P9_41: { name: "CLKOUT2", gpio: gpio0+20, mux: ["xdma_event_intr1", "mcasp0_axr1"], eeprom: [13, 74] },
  121 + P9_42: { name: "GPIO0_7", gpio: gpio0+7, mux: ["ecap0_in_pwm0_out", "mcasp0_aclkr"], eeprom: [4, 75],
122 122 pwm: { muxmode: 0, path: "ecap.0", name: "ECAPPWM0" }
123 123 },
124 124 P9_43: { name: "DGND" },
183 node_modules/bonescript/eeprom.js
@@ -185,56 +185,67 @@ var parseCapeEeprom = function(x) {
185 185 data.currentSYS_5V = x.readUint16BE(240);
186 186 data.DCSupplied = x.readUint16BE(242);
187 187 data.mux = {};
  188 + var readPinObject = function(pinEeprom, pinMux) {
  189 + var pinOffset = pinEeprom * 2 + 88;
  190 + if(pinEeprom >= 74) pinOffset += 8;
  191 + var pinData = x.readUint16BE(pinOffset);
  192 + var pinObject = {};
  193 + var used = (pinData & 0x8000) >> 15;
  194 + if(used || debug) {
  195 + pinObject.used = used ? 'used' : 'available';
  196 + if(debug) pinObject.data = x.hexSlice(pinOffset, pinOffset+2);
  197 + var direction = (pinData & 0x6000) >> 13;
  198 + switch(direction) {
  199 + case 1:
  200 + pinObject.direction = 'in';
  201 + break;
  202 + case 2:
  203 + pinObject.direction = 'out';
  204 + break;
  205 + case 3:
  206 + pinObject.direction = 'bidir';
  207 + break;
  208 + case 0:
  209 + default:
  210 + console.error('Unknown direction value: '+direction);
  211 + }
  212 + pinObject.slew = (pinData & 0x40) ? 'slow' : 'fast';
  213 + pinObject.rx = (pinData & 0x20) ? 'enabled' : 'disabled';
  214 + var pullup = (pinData & 0x18) >> 3;
  215 + switch(pullup) {
  216 + case 1:
  217 + pinObject.pullup = 'disabled';
  218 + break;
  219 + case 2:
  220 + pinObject.pullup = 'pullup';
  221 + break;
  222 + case 0:
  223 + pinObject.pullup = 'pulldown';
  224 + break;
  225 + case 3:
  226 + default:
  227 + console.error('Unknown pullup value: '+pullup);
  228 + }
  229 + pinObject.mode = (pinData & 0x0007);
  230 + try {
  231 + // read mux from debugfs
  232 + var muxReadout= fs.readFileSync('/sys/kernel/debug/omap_mux/'+pinMux, 'ascii');
  233 + pinObject.function = muxReadout.split("\n")[2].split("|")[pinObject.mode].replace('signals:', '').trim();
  234 + } catch(ex) {
  235 + console.warn('Unable to read pin mux function name: '+pinMux);
  236 + }
  237 + }
  238 + }
  239 +
188 240 for(pin in bone) {
189 241 if(bone[pin].eeprom) {
190   - var pinOffset = bone[pin].eeprom * 2 + 88;
191   - var pinData = x.readUint16BE(pinOffset);
192   - var pinObject = {};
193   - var used = (pinData & 0x8000) >> 15;
194   - if(used || debug) {
195   - pinObject.used = used ? 'used' : 'available';
196   - if(debug) pinObject.data = x.hexSlice(pinOffset, pinOffset+2);
197   - var direction = (pinData & 0x6000) >> 13;
198   - switch(direction) {
199   - case 1:
200   - pinObject.direction = 'in';
201   - break;
202   - case 2:
203   - pinObject.direction = 'out';
204   - break;
205   - case 3:
206   - pinObject.direction = 'bidir';
207   - break;
208   - case 0:
209   - default:
210   - console.error('Unknown direction value: '+direction);
211   - }
212   - pinObject.slew = (pinData & 0x40) ? 'slow' : 'fast';
213   - pinObject.rx = (pinData & 0x20) ? 'enabled' : 'disabled';
214   - var pullup = (pinData & 0x18) >> 3;
215   - switch(pullup) {
216   - case 1:
217   - pinObject.pullup = 'disabled';
218   - break;
219   - case 2:
220   - pinObject.pullup = 'pullup';
221   - break;
222   - case 0:
223   - pinObject.pullup = 'pulldown';
224   - break;
225   - case 3:
226   - default:
227   - console.error('Unknown pullup value: '+pullup);
  242 + if(typeof bone[pin].eeprom == 'number') {
  243 + var pinMux = bone[pin].mux;
  244 + data.mux[pin] = readPinObject(bone[pin].eeprom, pinMux);
  245 + } else if(typeof bone[pin].eeprom == 'object') {
  246 + for(var eeprom in bone[pin].eeprom) {
  247 + data.mux[pin] = readPinObject(bone[pin].eeprom[eeprom], pinMux);
228 248 }
229   - pinObject.mode = (pinData & 0x0007);
230   - try {
231   - // read mux from debugfs
232   - var muxReadout= fs.readFileSync('/sys/kernel/debug/omap_mux/'+bone[pin].mux, 'ascii');
233   - pinObject.function = muxReadout.split("\n")[2].split("|")[pinObject.mode].replace('signals:', '').trim();
234   - } catch(ex) {
235   - console.warn('Unable to read pin mux function name: '+bone[pin].mux);
236   - }
237   - data.mux[pin] = pinObject;
238 249 }
239 250 }
240 251 }
@@ -270,43 +281,51 @@ var fillCapeEepromData = exports.fillCapeEepromData = function(data) {
270 281 eepromData.writeUint16BE(data.currentVDD_5V, 238);
271 282 eepromData.writeUint16BE(data.currentSYS_5V, 240);
272 283 eepromData.writeUint16BE(data.DCSupplied, 242);
  284 + var writePinObject = function(pinEeprom, pin) {
  285 + var pinOffset = pinEeprom * 2 + 88; // 73*3 + 88 = 234
  286 + if(pinEeprom >= 74) pinOffset += 8;
  287 + var pinObject = data.mux[pin];
  288 + var pinData = 0;
  289 + if(pinObject.used == 'used') pinData |= 0x8000;
  290 + switch(pinObject.direction) {
  291 + case 'in':
  292 + pinData |= 0x2000;
  293 + break;
  294 + case 'out':
  295 + pinData |= 0x4000;
  296 + break;
  297 + case 'bidir':
  298 + pinData |= 0x6000;
  299 + break;
  300 + default:
  301 + console.error('Unknown direction value: '+pinObject.direction);
  302 + pinData |= 0x2000;
  303 + }
  304 + if(pinObject.slew == 'slow') pinData |= 0x40;
  305 + if(pinObject.rx == 'enabled') pinData |= 0x20;
  306 + var pullup = (pinData & 0x18) >> 3;
  307 + switch(pinObject.pullup) {
  308 + case 'disabled':
  309 + pinData |= 0x08;
  310 + break;
  311 + case 'pullup':
  312 + pinData |= 0x10;
  313 + break;
  314 + case 'pulldown':
  315 + break;
  316 + default:
  317 + console.error('Unknown pullup value: '+pullup);
  318 + }
  319 + pinData |= (pinObject.mode & 0x0007);
  320 + eepromData.writeUint16BE(pinData, pinOffset);
  321 + }
273 322 for(pin in data.mux) {
274   - if(bone[pin].eeprom) {
275   - var pinOffset = bone[pin].eeprom * 2 + 88;
276   - var pinObject = data.mux[pin];
277   - var pinData = 0;
278   - if(pinObject.used == 'used') pinData |= 0x8000;
279   - switch(pinObject.direction) {
280   - case 'in':
281   - pinData |= 0x2000;
282   - break;
283   - case 'out':
284   - pinData |= 0x4000;
285   - break;
286   - case 'bidir':
287   - pinData |= 0x6000;
288   - break;
289   - default:
290   - console.error('Unknown direction value: '+pinObject.direction);
291   - pinData |= 0x2000;
292   - }
293   - if(pinObject.slew == 'slow') pinData |= 0x40;
294   - if(pinObject.rx == 'enabled') pinData |= 0x20;
295   - var pullup = (pinData & 0x18) >> 3;
296   - switch(pinObject.pullup) {
297   - case 'disabled':
298   - pinData |= 0x08;
299   - break;
300   - case 'pullup':
301   - pinData |= 0x10;
302   - break;
303   - case 'pulldown':
304   - break;
305   - default:
306   - console.error('Unknown pullup value: '+pullup);
  323 + if(typeof bone[pin].eeprom == 'number') {
  324 + writePinObject(bone[pin].eeprom, pin);
  325 + } else if(typeof bone[pin].eeprom == 'object') {
  326 + for(var eeprom in bone[pin].eeprom) {
  327 + writePinObject(bone[pin].eeprom[eeprom], pin);
307 328 }
308   - pinData |= (pinObject.mode & 0x0007);
309   - eepromData.writeUint16BE(pinData, pinOffset);
310 329 }
311 330 }
312 331 return(eepromData);

0 comments on commit c6cf41c

Please sign in to comment.
Something went wrong with that request. Please try again.