def read(self, node): nodes = node.childNodes for node in nodes: if node.nodeType == xml.dom.Node.ELEMENT_NODE: if node.nodeName == 'count': continue varNode = node.getElementsByTagName('varName') curNode = node.getElementsByTagName('current') key = re.findall( r'\D+', node.nodeName)[0].upper() + self.__suffix + '%s' % ( re.findall(r'\d+', node.nodeName)[0]) if key not in ModuleObj.get_data(self): continue data = ModuleObj.get_data(self)[key] if len(varNode): data.set_varName(varNode[0].childNodes[0].nodeValue) if len(curNode): data.set_current(curNode[0].childNodes[0].nodeValue) ModuleObj.set_data(self, key, data) return True
def fill_pinctrl_hFile(self): gen_str = '''#include <linux/pinctrl/pinctrl.h>\n''' gen_str += '''#include <pinctrl-mtk-common.h>\n\n''' gen_str += '''static const struct mtk_desc_pin mtk_pins_%s[] = {\n''' % ( ModuleObj.get_chipId().lower()) #sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare) for key in sorted_key(list(ModuleObj.get_data(self).keys())): #for key in sorted_list: value = ModuleObj.get_data(self)[key] gen_str += '''\tMTK_PIN(\n''' gen_str += '''\t\tPINCTRL_PIN(%s, \"%s\"),\n''' % (key[4:], key.upper()) gen_str += '''\t\tNULL, \"%s\",\n''' % ( ModuleObj.get_chipId().lower()) gen_str += '''\t\tMTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT)''' for i in range(0, GpioData._modNum): mode_name = GpioData.get_modeName(key, i) if mode_name != '': lst = [] if mode_name.find('//') != -1: lst = mode_name.split('//') else: lst.append(mode_name) for j in range(0, len(lst)): gen_str += ''',\n\t\tMTK_FUNCTION(%d, "%s")''' % ( i + j * 8, lst[j]) gen_str += '''\n\t),\n''' gen_str += '''};\n''' return gen_str
def fill_dtsiFile(self): gen_str = '''&auxadc {\n''' gen_str += '''\tadc_channel@ {\n''' gen_str += '''\t\tcompatible = "mediatek,adc_channel";\n''' val = -1 # sort by the key, or the sequence is dissorted #sorted_list = sorted(ModuleObj.get_data(self).keys()) for key in sorted_key(ModuleObj.get_data(self).keys()): value = ModuleObj.get_data(self)[key] if value == "TEMPERATURE": gen_str += '''\t\tmediatek,%s0 = <%d>;\n''' % ( value.lower(), string.atoi(key[3:])) else: gen_str += '''\t\tmediatek,%s = <%d>;\n''' % ( value.lower(), string.atoi(key[3:])) if value == "ADC_FDD_RF_PARAMS_DYNAMIC_CUSTOM_CH": val = string.atoi(key[3:]) gen_str += '''\t\tstatus = \"okay\";\n''' gen_str += '''\t};\n''' gen_str += '''};\n''' gen_str += self.fill_extraNode(val) return gen_str
def fill_dtsiFile(self): gen_str = '''#include <dt-bindings/interrupt-controller/irq.h>\n''' gen_str += '''#include <dt-bindings/interrupt-controller/arm-gic.h>\n''' gen_str += '''\n''' gen_str += self.fill_mappingTable() sorted_list = sorted(ModuleObj.get_data(self).keys(), key=compare) for key in sorted_list: value = ModuleObj.get_data(self)[key] gen_str += '''&%s {\n''' %(value.get_varName().lower()) gen_str += '''\tinterrupt-parent = <&eintc>;\n''' temp = '' polarity = value.get_polarity() sensitive = value.get_sensitiveLevel() if cmp(polarity, 'High') == 0 and cmp(sensitive, 'Edge') == 0: temp = 'IRQ_TYPE_EDGE_RISING' elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Edge') == 0: temp = 'IRQ_TYPE_EDGE_FALLING' elif cmp(polarity, 'High') == 0 and cmp(sensitive, 'Level') == 0: temp = 'IRQ_TYPE_LEVEL_HIGH' elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Level') == 0: temp = 'IRQ_TYPE_LEVEL_LOW' gen_str += '''\tinterrupts = <%s %s>;\n''' %(self.refGpio(key[4:], True)[0], temp) gen_str += '''\tdebounce = <%s %d>;\n''' %(self.refGpio(key[4:], True)[0], string.atoi(value.get_debounceTime()) * 1000) gen_str += '''\tstatus = \"okay\";\n''' gen_str += '''};\n''' gen_str += '''\n''' return gen_str
def fill_hFile(self): gen_str = '' sorted_list = sorted(ModuleObj.get_data(self).keys()) for key in sorted_list: value = ModuleObj.get_data(self)[key] gen_str += '''#define AUXADC_%s_CHANNEL\t\t\t%s\n''' %(value.upper(), key[3:]) return gen_str
def fill_hFile(self): gen_str = '' gen_str += '''#ifdef __cplusplus\n''' gen_str += '''extern \"C\" {\n''' gen_str += '''#endif\n''' gen_str += '''#define CUST_EINTF_TRIGGER_RISING\t\t\t1\n''' gen_str += '''#define CUST_EINTF_TRIGGER_FALLING\t\t\t2\n''' gen_str += '''#define CUST_EINTF_TRIGGER_HIGH\t\t\t4\n''' gen_str += '''#define CUST_EINTF_TRIGGER_LOW\t\t\t8\n''' gen_str += '''#define CUST_EINT_DEBOUNCE_DISABLE\t\t\t0\n''' gen_str += '''#define CUST_EINT_DEBOUNCE_ENABLE\t\t\t1\n''' gen_str += '''\n\n''' sorted_list = sorted(list(ModuleObj.get_data(self).keys()), key=compare) for key in sorted_list: value = ModuleObj.get_data(self)[key] gen_str += '''#define CUST_EINT_%s_NUM\t\t\t%s\n''' % ( value.get_varName().upper(), key[4:]) gen_str += '''#define CUST_EINT_%s_DEBOUNCE_CN\t\t%s\n''' % ( value.get_varName().upper(), value.get_debounceTime()) temp = '' polarity = value.get_polarity() sensitive = value.get_sensitiveLevel() if cmp(polarity, 'High') == 0 and cmp(sensitive, 'Edge') == 0: temp = 'CUST_EINTF_TRIGGER_RISING' elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Edge') == 0: temp = 'CUST_EINTF_TRIGGER_FALLING' elif cmp(polarity, 'High') == 0 and cmp(sensitive, 'Level') == 0: temp = 'CUST_EINTF_TRIGGER_HIGH' elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Level') == 0: temp = 'CUST_EINTF_TRIGGER_LOW' gen_str += '''#define CUST_EINT_%s_TYPE\t\t\t%s\n''' % ( value.get_varName().upper(), temp) temp = '' if cmp(value.get_debounceEnable(), 'Disable') == 0: temp = 'CUST_EINT_DEBOUNCE_DISABLE' elif cmp(value.get_debounceEnable(), 'Enable') == 0: temp = 'CUST_EINT_DEBOUNCE_ENABLE' gen_str += '''#define CUST_EINT_%s_DEBOUNCE_EN\t\t%s\n\n''' % ( value.get_varName().upper(), temp) gen_str += '''#ifdef __cplusplus\n''' gen_str += '''}\n''' gen_str += '''#endif\n''' return gen_str
def fill_hFile(self): gen_str = '' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if value.get_varName() == '': continue idx = string.atoi(key[5:]) name = self.__list[idx] gen_str += '''#define GPIO_%s\t\tGPIO_%s\n''' % ( name.upper(), value.get_varName()) return gen_str
def fill_mapping_dtsiFile(self): gen_str = '''&gpio_usage_mapping {\n''' #sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare) for key in sorted_key(list(ModuleObj.get_data(self).keys())): #for key in sorted_list: value = ModuleObj.get_data(self)[key] for varName in value.get_varNames(): if varName != '' and varName.lower() in GpioData._mapList: gen_str += '''\t%s = <&pio %s 0>;\n''' % (varName, key[4:]) gen_str += '''};\n''' return gen_str
def fill_hFile(self): gen_str = '''typedef enum {\n''' gen_str += '''\tCLOCK_BUFFER_DISABLE,\n''' gen_str += '''\tCLOCK_BUFFER_SW_CONTROL,\n''' gen_str += '''\tCLOCK_BUFFER_HW_CONTROL\n''' gen_str += '''} MTK_CLK_BUF_STATUS;\n''' gen_str += '''\n''' gen_str += '''typedef enum {\n''' gen_str += '''\tCLK_BUF_DRIVING_CURR_AUTO_K = -1,\n''' gen_str += '''\tCLK_BUF_DRIVING_CURR_0,\n''' gen_str += '''\tCLK_BUF_DRIVING_CURR_1,\n''' gen_str += '''\tCLK_BUF_DRIVING_CURR_2,\n''' gen_str += '''\tCLK_BUF_DRIVING_CURR_3\n''' gen_str += '''} MTK_CLK_BUF_DRIVING_CURR;\n''' gen_str += '''\n''' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if key.find('RF') != -1: gen_str += '''#define %s_STATUS\t\t\t\tCLOCK_BUFFER_%s\n''' % ( key[3:], value.get_varName()) gen_str += '''\n''' for key in sorted_key(list(ModuleObj.get_data(self).keys())): if key.find('RF') != -1: continue value = ModuleObj.get_data(self)[key] idx = value.get_curList().index(value.get_current()) if cmp(value.get_curList()[0], DEFAULT_AUTOK) == 0: idx -= 1 if idx >= 0: gen_str += '''#define %s_DRIVING_CURR\t\tCLK_BUF_DRIVING_CURR_%d\n''' % ( key, idx) else: gen_str += '''#define %s_DRIVING_CURR\t\tCLK_BUF_DRIVING_CURR_AUTO_K\n''' % ( key) gen_str += '''\n''' return gen_str
def fill_dtsiFile(self): gen_str = '''&auxadc {\n''' gen_str += '''\tadc_channel@ {\n''' gen_str += '''\t\tcompatible = "mediatek,adc_channel";\n''' # sort by the key, or the sequence is dissorted #sorted_list = sorted(ModuleObj.get_data(self).keys()) for key in sorted_key(ModuleObj.get_data(self).keys()): value = ModuleObj.get_data(self)[key] if value == "TEMPERATURE": gen_str += '''\t\tmediatek,%s0 = <%d>;\n''' %(value.lower(), string.atoi(key[3:])) else: gen_str += '''\t\tmediatek,%s = <%d>;\n''' %(value.lower(), string.atoi(key[3:])) gen_str += '''\t\tstatus = \"okay\";\n''' gen_str += '''\t};\n''' gen_str += '''};\n''' return gen_str
def fill_dtsiFile(self): gen_str = '''&rf_clock_buffer_ctrl {\n''' gen_str += '''\tmediatek,clkbuf-quantity = <%d>;\n''' % (self.__count) gen_str += '''\tmediatek,clkbuf-config = <''' #sorted_list = sorted(ModuleObj.get_data(self).keys()) for key in sorted_key(list(ModuleObj.get_data(self).keys())): if key.find('RF') == -1: continue value = ModuleObj.get_data(self)[key] gen_str += '''%d ''' % (ClkData._varList.index( value.get_varName())) gen_str = gen_str.rstrip() gen_str += '''>;\n''' gen_str += '''\tstatus = \"okay\";\n''' gen_str += '''};\n''' return gen_str
def fill_cFile(self): gen_str = '' for header in self.__headerList: gen_str += '''#include <%s>\n''' % (header) gen_str += '''\n''' gen_str += '''void pmu_drv_tool_customization_init(void)\n''' gen_str += '''{\n''' idx = 0 for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if value.get_defEnable() != 0: gen_str += '''\t%s(%s,%d);\n''' % (self.__func, self.__paraList[idx], value.get_defEnable() - 1) idx += 1 gen_str += '''}\n''' return gen_str
def fill_hFile(self): gen_str = '' gen_str += '''#define CUST_EINT_MD_LEVEL_SENSITIVE\t\t0\n''' gen_str += '''#define CUST_EINT_MD_EDGE_SENSITIVE\t\t1\n''' gen_str += '''\n''' if self.__bSrcPinEnable: for (key, value) in list(self.__srcPin.items()): gen_str += '''#define %s\t\t%s\n''' %(key, value) gen_str += '''\n''' gen_str += '''#define CUST_EINT_POLARITY_LOW\t\t0\n''' gen_str += '''#define CUST_EINT_POLARITY_HIGH\t\t1\n''' gen_str += '''\n''' gen_str += '''#define CUST_EINT_LEVEL_SENSITIVE\t\t0\n''' gen_str += '''#define CUST_EINT_EDGE_SENSITIVE\t\t1\n''' gen_str += '''\n''' count = 0 for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if cmp(value.get_varName(), 'NC') == 0: continue num = key[4:] count += 1 gen_str += '''#define CUST_EINT_MD1_%s_NAME\t\t\t"%s"\n''' %(num, value.get_varName()) gen_str += '''#define CUST_EINT_MD1_%s_NUM\t\t\t%s\n''' %(num, num) gen_str += '''#define CUST_EINT_MD1_%s_DEBOUNCE_CN\t\t%s\n''' %(num, value.get_debounceTime()) gen_str += '''#define CUST_EINT_MD1_%s_POLARITY\t\tCUST_EINT_POLARITY_%s\n''' %(num, value.get_polarity().upper()) gen_str += '''#define CUST_EINT_MD1_%s_SENSITIVE\t\tCUST_EINT_MD_%s_SENSITIVE\n''' %(num, value.get_sensitiveLevel().upper()) gen_str += '''#define CUST_EINT_MD1_%s_DEBOUNCE_EN\t\tCUST_EINT_DEBOUNCE_%s\n''' %(num, value.get_debounceEnable().upper()) gen_str += '''#define CUST_EINT_MD1_%s_DEDICATED_EN\t\t%s\n''' %(num, int(value.get_dedicatedEn())) if self.__bSrcPinEnable: gen_str += '''#define CUST_EINT_MD1_%s_SRCPIN\t\t\t%s\n''' %(num, value.get_srcPin()) gen_str += '''\n''' gen_str += '''#define CUST_EINT_MD1_CNT\t\t\t%d\n''' %(count) return gen_str
def fill_hFile(self): gen_str = '' used = [] for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] for name in value.get_nameList(): if name.strip() != '': used.append(name) gen_str += '''#define PMIC_APP_%s\t\t\t%s_POWER_LDO_%s\n''' % ( name, self.__chipName[5:11], value.get_ldoName()) gen_str += '''\n''' gen_str += '''/**********Output default name********************/\n''' for varName in PmicData._var_list: if not varName.upper() in used: gen_str += '''#define PMIC_APP_%s\t\t\t%s\n''' % ( varName.upper(), self.__defLdo) return gen_str
def fill_dtsiFile(self): gen_str = '' gen_str += '''&eintc {\n''' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if cmp(value.get_varName(), 'NC') == 0: continue num = key[4:] gen_str += '''\t%s@%s {\n''' %(value.get_varName(), num) gen_str += '''\t\tcompatible = \"mediatek,%s-eint\";\n''' %(value.get_varName()) type = 1 polarity = value.get_polarity() sensitive = value.get_sensitiveLevel() if cmp(polarity, 'High') == 0 and cmp(sensitive, 'Edge') == 0: type = 1 elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Edge') == 0: type = 2 elif cmp(polarity, 'High') == 0 and cmp(sensitive, 'Level') == 0: type = 4 elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Level') == 0: type = 8 gen_str += '''\t\tinterrupts = <%s %d>;\n''' %(num, type) gen_str += '''\t\tdebounce = <%s %d>;\n''' %(num, (string.atoi(value.get_debounceTime()))*1000) gen_str += '''\t\tdedicated = <%s %d>;\n''' %(num, int(value.get_dedicatedEn())) if self.__bSrcPinEnable: gen_str += '''\t\tsrc_pin = <%s %s>;\n''' %(num, self.__srcPin[value.get_srcPin()]) else: gen_str += '''\t\tsrc_pin = <%s %s>;\n''' %(num, -1) gen_str += '''\t\tsockettype = <%s %s>;\n''' %(num, value.get_socketType()) gen_str += '''\t\tstatus = \"okay\";\n''' gen_str += '''\t};\n''' gen_str += '''\n''' gen_str += '''};\n''' return gen_str
def fill_dtsiFile(self): gen_str = '' for i in range(0, I2cData._channel_count): if i >= len(self._busList): break gen_str += '''&i2c%d {\n''' % (i) gen_str += '''\t#address-cells = <1>;\n''' gen_str += '''\t#size-cells = <0>;\n''' if self._bBusEnable: gen_str += '''\tclock-frequency = <%d>;\n''' % ( string.atoi(self._busList[i].get_speed()) * 1000) temp_str = '' if cmp(self._busList[i].get_enable(), 'false') == 0: temp_str = 'use-open-drain' elif cmp(self._busList[i].get_enable(), 'true') == 0: temp_str = 'use-push-pull' gen_str += '''\tmediatek,%s;\n''' % (temp_str) for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] channel = 'I2C_CHANNEL_%d' % (i) if cmp(value.get_channel(), channel) == 0 and cmp( value.get_varName(), 'NC') != 0 and value.get_address().strip() != '': gen_str += '''\t%s_mtk:%s@%s {\n''' % ( value.get_varName().lower(), value.get_varName().lower(), value.get_address()[2:].lower()) gen_str += '''\t\tcompatible = \"mediatek,%s\";\n''' % ( value.get_varName().lower()) gen_str += '''\t\treg = <%s>;\n''' % ( value.get_address().lower()) gen_str += '''\t\tstatus = \"okay\";\n''' gen_str += '''\t};\n\n''' gen_str += '''};\n\n''' return gen_str
def fill_hFile(self): gen_str = '''typedef enum {\n''' gen_str += '''\tCLOCK_BUFFER_DISABLE,\n''' gen_str += '''\tCLOCK_BUFFER_SW_CONTROL,\n''' gen_str += '''\tCLOCK_BUFFER_HW_CONTROL\n''' gen_str += '''} MTK_CLK_BUF_STATUS;\n''' gen_str += '''\n''' gen_str += '''typedef enum {\n''' gen_str += '''\tCLK_BUF_DRIVING_CURR_0_4MA,\n''' gen_str += '''\tCLK_BUF_DRIVING_CURR_0_9MA,\n''' gen_str += '''\tCLK_BUF_DRIVING_CURR_1_4MA,\n''' gen_str += '''\tCLK_BUF_DRIVING_CURR_1_9MA\n''' gen_str += '''} MTK_CLK_BUF_DRIVING_CURR;\n''' gen_str += '''\n''' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if key.find(self.__pmic) != -1: gen_str += '''#define %s_STATUS_PMIC\t\t\t\tCLOCK_BUFFER_%s\n''' % ( key[5:], value.get_varName()) gen_str += '''\n''' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if key.find(self.__pmic) != -1: gen_str += '''#define %s_DRIVING_CURR\t\tCLK_BUF_DRIVING_CURR_%sMA\n''' % ( key, value.get_current().replace('.', '_')) gen_str += '''\n''' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if key.find(self.__rf) != -1: gen_str += '''#define %s_STATUS\t\tCLOCK_BUFFER_%s\n''' % ( key[3:], value.get_varName()) gen_str += '''\n''' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if key.find(self.__rf) != -1: gen_str += '''#define %s_DRIVING_CURR\t\tCLK_BUF_DRIVING_CURR_%sMA\n''' % ( key, value.get_current().replace('.', '_')) gen_str += '''\n''' return gen_str
def fill_dtsiFile(self): gen_str = '''&pmic_clock_buffer_ctrl {\n''' gen_str += '''\tmediatek,clkbuf-quantity = <%d>;\n''' % (self.__count) gen_str += '''\tmediatek,clkbuf-config = <''' #sorted_list = sorted(ModuleObj.get_data(self).keys()) for key in sorted_key(list(ModuleObj.get_data(self).keys())): if key.find('PMIC') == -1: continue value = ModuleObj.get_data(self)[key] gen_str += '''%d ''' % (ClkData._varList.index( value.get_varName())) gen_str = gen_str.rstrip() gen_str += '''>;\n''' gen_str += '''\tmediatek,clkbuf-driving-current = <''' #sorted_list = sorted(ModuleObj.get_data(self).keys()) for key in sorted_key(list(ModuleObj.get_data(self).keys())): if key.find('PMIC') == -1: continue value = ModuleObj.get_data(self)[key] idx = value.get_curList().index(value.get_current()) if cmp(value.get_curList()[0], DEFAULT_AUTOK) == 0: idx -= 1 if idx < 0: gen_str += '''(%d) ''' % (-1) else: gen_str += '''%d ''' % (idx) gen_str = gen_str.rstrip() gen_str += '''>;\n''' gen_str += '''\tstatus = \"okay\";\n''' gen_str += '''};\n''' return gen_str
def fill_dtsiFile(self): gen_str = '' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] gen_str += '''&mt_pmic_%s_ldo_reg {\n''' % ( value.get_ldoName().lower()) gen_str += '''\tregulator-name = \"%s\";\n''' % ( (value.get_ldoName().replace('_', '')).lower()) gen_str += '''\tregulator-default-on = <%d>; /* 0:skip, 1: off, 2:on */\n''' % ( value.get_defEnable()) gen_str += '''\tstatus = \"okay\";\n''' gen_str += '''};\n''' gen_str += '''\n''' gen_str += '''&kd_camera_hw1 {\n''' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] for varName in value.get_nameList(): #for i in range(0, self.__appCount): bExisted = False postFix = '' #varName = value.get_nameList()[i] if varName.find('CAMERA') != -1: postFix = varName[varName.rfind('_') + 1:] bExisted = True if varName.find('MAIN_CAMERA') != -1: gen_str += '''\tvcam%s-supply = <&mt_pmic_%s_ldo_reg>;\n''' % ( postFix.lower(), value.get_ldoName().lower()) if varName.find('SUB_CAMERA') != -1: gen_str += '''\tvcam%s_main2-supply = <&mt_pmic_%s_ldo_reg>;\n''' % ( postFix.lower(), value.get_ldoName().lower()) gen_str += '''\tvcam%s_sub-supply = <&mt_pmic_%s_ldo_reg>;\n''' % ( postFix.lower(), value.get_ldoName().lower()) #if bExisted == True: #gen_str += '''\n''' gen_str += '''\tstatus = \"okay\";\n''' gen_str += '''};\n\n''' gen_str += '''&touch {\n''' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] for name in value.get_nameList(): if name.find('TOUCH') != -1: gen_str += '''\tvtouch-supply = <&mt_pmic_%s_ldo_reg>;\n''' % ( value.get_ldoName().lower()) gen_str += '''\tstatus = \"okay\";\n''' gen_str += '''};\n''' return gen_str
def fill_pinfunc_hFile(self): gen_str = '''#include \"mt65xx.h\"\n\n''' #sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare) for key in sorted_key(list(ModuleObj.get_data(self).keys())): #for key in sorted_list: value = ModuleObj.get_data(self)[key] for i in range(0, GpioData._modNum): mode_name = GpioData.get_modeName(key, i) if mode_name != '': lst = [] if mode_name.find('//') != -1: lst = mode_name.split('//') else: lst.append(mode_name) for j in range(0, len(lst)): gen_str += '''#define PINMUX_GPIO%s__FUNC_%s (MTK_PIN_NO(%s) | %d)\n''' % ( key[4:], lst[j], key[4:], (i + j * 8)) gen_str += '''\n''' gen_str += '''\n''' return gen_str
def fill_hFile(self): gen_str = '' for i in range(0, I2cData._channel_count): gen_str += '''#define I2C_CHANNEL_%d\t\t\t%d\n''' % (i, i) gen_str += '''\n''' #sorted_lst = sorted(ModuleObj.get_data(self).keys(), key=compare) for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] temp = '' if value.get_address().strip() == '': temp = 'TRUE' else: temp = 'FALSE' gen_str += '''#define I2C_%s_AUTO_DETECT\t\t\t%s\n''' % ( value.get_varName(), temp) gen_str += '''#define I2C_%s_CHANNEL\t\t\t%s\n''' % ( value.get_varName(), value.get_channel()) gen_str += '''#define I2C_%s_SLAVE_7_BIT_ADDR\t\t%s\n''' % ( value.get_varName(), value.get_address().upper()) gen_str += '''\n''' return gen_str
def fill_dtsiFile(self): gen_str = ClkObj.fill_dtsiFile(self) gen_str += '''\n''' gen_str += '''&rf_clock_buffer_ctrl {\n''' gen_str += '''\tmediatek,clkbuf-quantity = <%d>;\n''' % ( len(ModuleObj.get_data(self)) - ClkData._count) msg = 'rf clk buff count : %d' % (len(ModuleObj.get_data(self)) - ClkData._count) log(LogLevel.info, msg) gen_str += '''\tmediatek,clkbuf-config = <''' #sorted_list = sorted(ModuleObj.get_data(self).keys()) for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if key.find(self.__rf) != -1: gen_str += '''%d ''' % (ClkData._varList.index( value.get_varName())) gen_str = gen_str.rstrip() gen_str += '''>;\n''' gen_str += '''\tmediatek,clkbuf-driving-current = <''' for key in sorted_key(list(ModuleObj.get_data(self).keys())): value = ModuleObj.get_data(self)[key] if key.find(self.__rf) != -1: idx = value.get_curList().index(value.get_current()) if cmp(value.get_curList()[0], DEFAULT_AUTOK) == 0: idx -= 1 gen_str += '''%d ''' % (idx) gen_str.rstrip() gen_str += '''>;\n''' gen_str += '''\tstatus = \"okay\";\n''' gen_str += '''};\n''' return gen_str
def get_gpioData(self, idx): if idx >= GpioData._count or idx < 0: return None key = 'gpio%s' % (idx) return ModuleObj.get_data(self)[key]
def fill_hFile(self): gen_str = '''//Configuration for GPIO SMT(Schmidt Trigger) Group output start\n''' temp_list = [] for key in sorted_key(list(ModuleObj.get_data(self).keys())): #for value in ModuleObj.get_data(self).values(): value = ModuleObj.get_data(self)[key] num = value.get_smtNum() if num in temp_list or num < 0: continue else: temp_list.append(num) if value.get_smtEn(): gen_str += '''#define GPIO_SMT_GROUP_%d\t\t1\n''' % (num) else: gen_str += '''#define GPIO_SMT_GROUP_%d\t\t0\n''' % (num) gen_str += '''\n\n''' sorted_list = sorted(list(ModuleObj.get_data(self).keys()), key=compare) for key in sorted_list: value = ModuleObj.get_data(self)[key] if self.is_i2cPadPin(value.get_modeName(key, value.get_defMode())): value.set_inpullEn(False) value.set_outHigh(False) value.set_inpullSelHigh(False) gen_str += '''//Configuration for %s\n''' % (key.upper()) mode_name = GpioData.get_modeName(key, value.get_defMode()) val = '' if mode_name != '': flag = False #val = '' if mode_name.find('//') != -1: flag = True value.get_modeVec()[value.get_defMode()] if flag: if value.get_modeVec()[value.get_defMode()] == '1': val = str(value.get_defMode()) elif value.get_modeVec()[value.get_defMode()] == '2': val = str(value.get_defMode() + GpioData._modNum) else: val = str(value.get_defMode()) if len(val) < 2: val = '0' + val pull_en = '' if value.get_inPullEn(): pull_en = 'ENABLE' else: pull_en = 'DISABLE' pull_sel = '' if value.get_inPullSelHigh(): pull_sel = 'UP' else: pull_sel = 'DOWN' out_high = '' if value.get_outHigh(): out_high = 'ONE' else: out_high = 'ZERO' smt_en = '' if value.get_smtEn(): smt_en = 'ENABLE' else: smt_en = 'DISABLE' ies_en = '' if value.get_iesEn(): ies_en = 'ENABLE' else: ies_en = 'DISABLE' gen_str += '''#define %s_MODE\t\t\tGPIO_MODE_%s\n''' % ( key.upper(), val) gen_str += '''#define %s_DIR\t\t\tGPIO_DIR_%s\n''' % ( key.upper(), value.get_defDir()) gen_str += '''#define %s_PULLEN\t\tGPIO_PULL_%s\n''' % ( key.upper(), pull_en) gen_str += '''#define %s_PULL\t\t\tGPIO_PULL_%s\n''' % ( key.upper(), pull_sel) gen_str += '''#define %s_DATAOUT\t\tGPIO_OUT_%s\n''' % ( key.upper(), out_high) gen_str += '''#define %s_SMT\t\t\tGPIO_SMT_%s\n''' % (key.upper(), smt_en) gen_str += '''#define %s_IES\t\t\tGPIO_IES_%s\n''' % (key.upper(), ies_en) if self.__drvCur: drv_cur = 'DRV_UNSUPPORTED' if value.get_drvCur() != '': drv_cur = value.get_drvCur() gen_str += '''#define %s_DRV\t\t\tGPIO_%s\n''' % (key.upper(), drv_cur) gen_str += '''\n''' return gen_str
def fill_dtsiFile(self): gen_str = '''&pio {\n\n''' gen_str += '''\tgpio_pins_default: gpiodef{\n\t};\n\n''' #sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare) for key in sorted_key(list(ModuleObj.get_data(self).keys())): #for key in sorted_list: value = ModuleObj.get_data(self)[key] gen_str += '''\t%s: gpio@%s {\n''' % (key.lower(), key[4:]) gen_str += '''\t\tpins_cmd_dat {\n''' mode = value.get_defMode() mode_name = GpioData.get_modeName(key, mode) mode_val = value.get_modeVec()[mode] if mode_val == '1': if mode_name.find('//') != -1: mode_name = mode_name.split('//')[0] elif mode_val == '2': if mode_name.find('//') != -1: mode_name = mode_name.split('//')[1] gen_str += '''\t\t\tpins = <PINMUX_GPIO%s__FUNC_%s>;\n''' % ( key[4:], mode_name) gen_str += '''\t\t\tslew-rate = <%d>;\n''' % (value.ge_defDirInt()) temp = '' if not value.get_inPullEn(): temp = 'bias-disable;' gen_str += '''\t\t\t%s\n''' % (temp) if value.get_inPullSelHigh(): temp = '11' else: temp = '00' gen_str += '''\t\t\tbias-pull-down = <%s>;\n''' % (temp) if value.get_outHigh(): temp = 'high' else: temp = 'low' gen_str += '''\t\t\toutput-%s;\n''' % (temp) gen_str += '''\t\t\tinput-schmitt-enable = <%d>;\n''' % ( value.get_smtEn()) gen_str += '''\t\t};\n''' gen_str += '''\t};\n''' gen_str += '''};\n\n''' gen_str += '''&gpio {\n''' lineLen = 0 gen_str += '''\tpinctrl-names = "default",''' lineLen += 30 for i in range(0, GpioData._count - 1): gen_str += '''"gpio%d",''' % (i) if i < 10: lineLen += 8 elif i < 100: lineLen += 9 elif i >= 100: lineLen += 10 if lineLen > 100: gen_str += '''\n''' lineLen = 0 gen_str += '''"gpio%d";\n''' % (GpioData._count - 1) gen_str += '''\tpinctrl-0 = <&gpio_pins_default>;\n''' for i in range(1, GpioData._count): gen_str += '''\tpinctrl-%d = <&gpio%d>;\n''' % (i, i - 1) gen_str += '''\n''' gen_str += '''\tstatus = \"okay\";\n''' gen_str += '''};\n''' return gen_str
def fill_cFile(self): gen_str = '' #sorted_list = sorted(ModuleObj.get_data(self).keys(), key = compare) for key in sorted_key(list(ModuleObj.get_data(self).keys())): #for key in sorted_list: value = ModuleObj.get_data(self)[key] for varName in value.get_varNames(): gen_str += '''#define %s\t\t\t(%s | 0x80000000)\n''' % ( varName.upper(), key.upper()) if value.get_eintMode(): gen_str += '''#define %s_M_EINT\t\tGPIO_MODE_00\n''' % ( varName) temp_list = [] for item in list(GpioData._specMap.keys()): regExp = '[_A-Z0-9:]*%s[_A-Z0-9:]*' % (item.upper()) pat = re.compile(regExp) for i in range(0, GpioData._modNum): list = value.get_modeVec() mode_name = GpioData.get_modeName(key, i) if list[i] == '1': if mode_name.find('//') != -1: mode_name = mode_name.split('//')[0] elif list[i] == '2': if mode_name.find('//') != -1: mode_name = mode_name.split('//')[1] if pat.match(mode_name): if cmp(item, 'eint') == 0 and ( (value.get_eintMode() or mode_name.find('MD_EINT') != -1)): continue gen_str += '''#define %s%s\t\tGPIO_MODE_0%d\n''' % ( varName.upper(), GpioData._specMap[item].upper(), i) temp_list.append(i) break if not value.get_eintMode(): list = value.get_modeVec() for i in range(0, GpioData._modNum): mode_name = GpioData.get_modeName(key, i) if list[i] == '0': continue elif list[i] == '1': if mode_name.find('//') != -1: mode_name = mode_name.split('//')[0] elif list[i] == '2': if mode_name.find('//') != -1: mode_name = mode_name.split('//')[1] if not i in temp_list: gen_str += '''#define %s_M_%s\t\tGPIO_MODE_0%d\n''' % ( varName, re.sub(r'\d{0,3}$', '', mode_name), i) regExp = r'CLKM\d' pat = re.compile(regExp) for i in range(0, GpioData._modNum): mode = GpioData.get_modeName(key, i) if pat.match(mode): gen_str += '''#define %s_CLK\t\tCLK_OUT%s\n''' % ( varName, mode[4:]) temp = '' if varName in list(GpioData._freqMap.keys()): temp = GpioData._freqMap[varName] else: temp = 'GPIO_CLKSRC_NONE' gen_str += '''#define %s_FREQ\t\t%s\n''' % (varName, temp) gen_str += '''\n''' return gen_str
def read(self, node): nodes = node.childNodes for node in nodes: if node.nodeType == xml.dom.Node.ELEMENT_NODE: if cmp(node.nodeName, 'count') == 0: GpioData._count = string.atoi(node.childNodes[0].nodeValue) continue eintNode = node.getElementsByTagName('eint_mode') defmNode = node.getElementsByTagName('def_mode') modsNode = node.getElementsByTagName('mode_arr') inpeNode = node.getElementsByTagName('inpull_en') inpsNode = node.getElementsByTagName('inpull_selhigh') defdNode = node.getElementsByTagName('def_dir') diriNode = node.getElementsByTagName('in') diroNode = node.getElementsByTagName('out') outhNode = node.getElementsByTagName('out_high') var0Node = node.getElementsByTagName('varName0') var1Node = node.getElementsByTagName('varName1') var2Node = node.getElementsByTagName('varName2') smtNode = node.getElementsByTagName('smt') iesNode = node.getElementsByTagName('ies') drvCurNode = node.getElementsByTagName('drv_cur') num = string.atoi(node.nodeName[4:]) if num >= len(ModuleObj.get_data(self)): break data = ModuleObj.get_data(self)[node.nodeName] if len(eintNode): flag = False if cmp(eintNode[0].childNodes[0].nodeValue, 'true') == 0: flag = True data.set_eintMode(flag) if len(defmNode): data.set_defMode( string.atoi(defmNode[0].childNodes[0].nodeValue)) if len(modsNode): str = modsNode[0].childNodes[0].nodeValue temp_list = [] for i in range(0, len(str)): temp_list.append(str[i]) data.set_modeVec(temp_list) if len(inpeNode): flag = False if cmp(inpeNode[0].childNodes[0].nodeValue, 'true') == 0: flag = True data.set_inpullEn(flag) if len(inpsNode): flag = False if cmp(inpsNode[0].childNodes[0].nodeValue, 'true') == 0: flag = True data.set_inpullSelHigh(flag) if len(defdNode): data.set_defDir(defdNode[0].childNodes[0].nodeValue) if len(diriNode): flag = False if cmp(diriNode[0].childNodes[0].nodeValue, 'true') == 0: flag = True data.set_inEn(flag) if len(diroNode): flag = False if cmp(diroNode[0].childNodes[0].nodeValue, 'true') == 0: flag = True data.set_outEn(flag) if len(outhNode): flag = False if cmp(outhNode[0].childNodes[0].nodeValue, 'true') == 0: flag = True data.set_outHigh(flag) temp_list = [] if len(var0Node) != 0 and len(var0Node[0].childNodes) != 0: temp_list.append(var0Node[0].childNodes[0].nodeValue) if len(var1Node) != 0 and len(var1Node[0].childNodes) != 0: temp_list.append(var1Node[0].childNodes[0].nodeValue) if len(var2Node) != 0 and len(var2Node[0].childNodes) != 0: temp_list.append(var2Node[0].childNodes[0].nodeValue) data.set_varNames(temp_list) if len(smtNode): flag = False if cmp(smtNode[0].childNodes[0].nodeValue, 'true') == 0: flag = True data.set_smtEn(flag) if len(iesNode): flag = False if cmp(iesNode[0].childNodes[0].nodeValue, 'true') == 0: flag = True data.set_iesEn(flag) if len(drvCurNode) != 0 and len(drvCurNode[0].childNodes) != 0: self.__drvCur = True data.set_drvCur(drvCurNode[0].childNodes[0].nodeValue) ModuleObj.set_data(self, node.nodeName, data) return True