Skip to content
Browse files

Attempt at enabling more pins for A1 EEPROM format

  • Loading branch information...
1 parent debd593 commit c6cf41cf4e1beb59a857c98862139667581f30d7 @jadonk committed Aug 8, 2012
Showing with 103 additions and 84 deletions.
  1. +2 −2 node_modules/bonescript/bone.js
  2. +101 −82 node_modules/bonescript/eeprom.js
View
4 node_modules/bonescript/bone.js
@@ -117,8 +117,8 @@ var bone =
P9_38: { name: "AIN3", ain: 3, eeprom: 70, scale: 4096 },
P9_39: { name: "AIN0", ain: 0, eeprom: 67, scale: 4096 },
P9_40: { name: "AIN1", ain: 1, eeprom: 68, scale: 4096 },
- P9_41: { name: "CLKOUT2", gpio: gpio0+20, mux: "xdma_event_intr1", eeprom: 13 },
- P9_42: { name: "GPIO0_7", gpio: gpio0+7, mux: "ecap0_in_pwm0_out", eeprom: 4,
+ P9_41: { name: "CLKOUT2", gpio: gpio0+20, mux: ["xdma_event_intr1", "mcasp0_axr1"], eeprom: [13, 74] },
+ P9_42: { name: "GPIO0_7", gpio: gpio0+7, mux: ["ecap0_in_pwm0_out", "mcasp0_aclkr"], eeprom: [4, 75],
pwm: { muxmode: 0, path: "ecap.0", name: "ECAPPWM0" }
},
P9_43: { name: "DGND" },
View
183 node_modules/bonescript/eeprom.js
@@ -185,56 +185,67 @@ var parseCapeEeprom = function(x) {
data.currentSYS_5V = x.readUint16BE(240);
data.DCSupplied = x.readUint16BE(242);
data.mux = {};
+ var readPinObject = function(pinEeprom, pinMux) {
+ var pinOffset = pinEeprom * 2 + 88;
+ if(pinEeprom >= 74) pinOffset += 8;
+ var pinData = x.readUint16BE(pinOffset);
+ var pinObject = {};
+ var used = (pinData & 0x8000) >> 15;
+ if(used || debug) {
+ pinObject.used = used ? 'used' : 'available';
+ if(debug) pinObject.data = x.hexSlice(pinOffset, pinOffset+2);
+ var direction = (pinData & 0x6000) >> 13;
+ switch(direction) {
+ case 1:
+ pinObject.direction = 'in';
+ break;
+ case 2:
+ pinObject.direction = 'out';
+ break;
+ case 3:
+ pinObject.direction = 'bidir';
+ break;
+ case 0:
+ default:
+ console.error('Unknown direction value: '+direction);
+ }
+ pinObject.slew = (pinData & 0x40) ? 'slow' : 'fast';
+ pinObject.rx = (pinData & 0x20) ? 'enabled' : 'disabled';
+ var pullup = (pinData & 0x18) >> 3;
+ switch(pullup) {
+ case 1:
+ pinObject.pullup = 'disabled';
+ break;
+ case 2:
+ pinObject.pullup = 'pullup';
+ break;
+ case 0:
+ pinObject.pullup = 'pulldown';
+ break;
+ case 3:
+ default:
+ console.error('Unknown pullup value: '+pullup);
+ }
+ pinObject.mode = (pinData & 0x0007);
+ try {
+ // read mux from debugfs
+ var muxReadout= fs.readFileSync('/sys/kernel/debug/omap_mux/'+pinMux, 'ascii');
+ pinObject.function = muxReadout.split("\n")[2].split("|")[pinObject.mode].replace('signals:', '').trim();
+ } catch(ex) {
+ console.warn('Unable to read pin mux function name: '+pinMux);
+ }
+ }
+ }
+
for(pin in bone) {
if(bone[pin].eeprom) {
- var pinOffset = bone[pin].eeprom * 2 + 88;
- var pinData = x.readUint16BE(pinOffset);
- var pinObject = {};
- var used = (pinData & 0x8000) >> 15;
- if(used || debug) {
- pinObject.used = used ? 'used' : 'available';
- if(debug) pinObject.data = x.hexSlice(pinOffset, pinOffset+2);
- var direction = (pinData & 0x6000) >> 13;
- switch(direction) {
- case 1:
- pinObject.direction = 'in';
- break;
- case 2:
- pinObject.direction = 'out';
- break;
- case 3:
- pinObject.direction = 'bidir';
- break;
- case 0:
- default:
- console.error('Unknown direction value: '+direction);
- }
- pinObject.slew = (pinData & 0x40) ? 'slow' : 'fast';
- pinObject.rx = (pinData & 0x20) ? 'enabled' : 'disabled';
- var pullup = (pinData & 0x18) >> 3;
- switch(pullup) {
- case 1:
- pinObject.pullup = 'disabled';
- break;
- case 2:
- pinObject.pullup = 'pullup';
- break;
- case 0:
- pinObject.pullup = 'pulldown';
- break;
- case 3:
- default:
- console.error('Unknown pullup value: '+pullup);
+ if(typeof bone[pin].eeprom == 'number') {
+ var pinMux = bone[pin].mux;
+ data.mux[pin] = readPinObject(bone[pin].eeprom, pinMux);
+ } else if(typeof bone[pin].eeprom == 'object') {
+ for(var eeprom in bone[pin].eeprom) {
+ data.mux[pin] = readPinObject(bone[pin].eeprom[eeprom], pinMux);
}
- pinObject.mode = (pinData & 0x0007);
- try {
- // read mux from debugfs
- var muxReadout= fs.readFileSync('/sys/kernel/debug/omap_mux/'+bone[pin].mux, 'ascii');
- pinObject.function = muxReadout.split("\n")[2].split("|")[pinObject.mode].replace('signals:', '').trim();
- } catch(ex) {
- console.warn('Unable to read pin mux function name: '+bone[pin].mux);
- }
- data.mux[pin] = pinObject;
}
}
}
@@ -270,43 +281,51 @@ var fillCapeEepromData = exports.fillCapeEepromData = function(data) {
eepromData.writeUint16BE(data.currentVDD_5V, 238);
eepromData.writeUint16BE(data.currentSYS_5V, 240);
eepromData.writeUint16BE(data.DCSupplied, 242);
+ var writePinObject = function(pinEeprom, pin) {
+ var pinOffset = pinEeprom * 2 + 88; // 73*3 + 88 = 234
+ if(pinEeprom >= 74) pinOffset += 8;
+ var pinObject = data.mux[pin];
+ var pinData = 0;
+ if(pinObject.used == 'used') pinData |= 0x8000;
+ switch(pinObject.direction) {
+ case 'in':
+ pinData |= 0x2000;
+ break;
+ case 'out':
+ pinData |= 0x4000;
+ break;
+ case 'bidir':
+ pinData |= 0x6000;
+ break;
+ default:
+ console.error('Unknown direction value: '+pinObject.direction);
+ pinData |= 0x2000;
+ }
+ if(pinObject.slew == 'slow') pinData |= 0x40;
+ if(pinObject.rx == 'enabled') pinData |= 0x20;
+ var pullup = (pinData & 0x18) >> 3;
+ switch(pinObject.pullup) {
+ case 'disabled':
+ pinData |= 0x08;
+ break;
+ case 'pullup':
+ pinData |= 0x10;
+ break;
+ case 'pulldown':
+ break;
+ default:
+ console.error('Unknown pullup value: '+pullup);
+ }
+ pinData |= (pinObject.mode & 0x0007);
+ eepromData.writeUint16BE(pinData, pinOffset);
+ }
for(pin in data.mux) {
- if(bone[pin].eeprom) {
- var pinOffset = bone[pin].eeprom * 2 + 88;
- var pinObject = data.mux[pin];
- var pinData = 0;
- if(pinObject.used == 'used') pinData |= 0x8000;
- switch(pinObject.direction) {
- case 'in':
- pinData |= 0x2000;
- break;
- case 'out':
- pinData |= 0x4000;
- break;
- case 'bidir':
- pinData |= 0x6000;
- break;
- default:
- console.error('Unknown direction value: '+pinObject.direction);
- pinData |= 0x2000;
- }
- if(pinObject.slew == 'slow') pinData |= 0x40;
- if(pinObject.rx == 'enabled') pinData |= 0x20;
- var pullup = (pinData & 0x18) >> 3;
- switch(pinObject.pullup) {
- case 'disabled':
- pinData |= 0x08;
- break;
- case 'pullup':
- pinData |= 0x10;
- break;
- case 'pulldown':
- break;
- default:
- console.error('Unknown pullup value: '+pullup);
+ if(typeof bone[pin].eeprom == 'number') {
+ writePinObject(bone[pin].eeprom, pin);
+ } else if(typeof bone[pin].eeprom == 'object') {
+ for(var eeprom in bone[pin].eeprom) {
+ writePinObject(bone[pin].eeprom[eeprom], pin);
}
- pinData |= (pinObject.mode & 0x0007);
- eepromData.writeUint16BE(pinData, pinOffset);
}
}
return(eepromData);

0 comments on commit c6cf41c

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