diff --git a/bonescript/bone.js b/bonescript/bone.js index 6ea32700..38db3cf6 100644 --- a/bonescript/bone.js +++ b/bonescript/bone.js @@ -33,7 +33,7 @@ exports.bone = P8_26: { name: "GPIO1_29", gpio: gpio1+29, mux: "gpmc_csn0", eeprom: 162 }, P8_27: { name: "GPIO2_22", gpio: gpio2+22, mux: "lcd_vsync", eeprom: 202 }, P8_28: { name: "GPIO2_24", gpio: gpio2+24, mux: "lcd_pclk", eeprom: 206 }, - P8_29: { name: "GPIO2_23", gpio: gpio2+23, mux: "lcd_hclk", eeprom: 204 }, + P8_29: { name: "GPIO2_23", gpio: gpio2+23, mux: "lcd_vsync", eeprom: 204 }, P8_30: { name: "GPIO2_25", gpio: gpio2+25, mux: "lcd_ac_bias_en", eeprom: 208 }, P8_31: { name: "UART5_CTSN", gpio: gpio0+10, mux: "lcd_data14", eeprom: 102 }, P8_32: { name: "UART5_RTSN", gpio: gpio0+11, mux: "lcd_data15", eeprom: 104 }, diff --git a/bonescript/eeprom.js b/bonescript/eeprom.js index 4a68cbfb..731d8490 100644 --- a/bonescript/eeprom.js +++ b/bonescript/eeprom.js @@ -1,4 +1,5 @@ var fs = require('fs'); +var path = require('path'); var buffer = require('buffer'); var util = require('util'); bone = require('./bone').bone; @@ -122,14 +123,27 @@ var parseCapeEeprom = function(x) { var pinOffset = bone[pin].eeprom; var pinData = x.readUint16BE(pinOffset); var pinObject = {}; - pinObject.used = (pinData & 0x8000) >> 15; + pinObject.used = (pinData & 0x8000) >> 15 ? 'used' : 'available'; if(pinData) { pinObject.direction = ((pinData & 0x4000) >> 14) ? 'in' : 'out'; - pinObject.pullup = (pinData & 0x3000) >> 12; + pinObject.pullup = (pinData & 0x3000) >> 12 ? 'pullup' : 'pulldown'; pinObject.mode = (pinData & 0x0007); + + pinObject.function = {}; + if(pinObject.used == "used") { + try { + // read mux from debugfs + muxReadout= fs.readFileSync("/sys/kernel/debug/omap_mux/" + bone[pin].mux, 'utf8'); + pinObject.function = muxReadout.split("\n")[2].split("|")[pinObject.mode].replace('signals:', '').trim(); + } catch(ex) { + //default mux + pinObject.function = bone[pin].name; + } + } + pinObject.data = x.hexSlice(pinOffset, pinOffset+2); - data.eeprom[bone[pin].name] = pinObject; } + data.eeprom[pin] = pinObject; } } return(data);