/* * arch/arm/mach-tegra/board-nvodm.c * * Board registration for ODM-kit generic Tegra boards * * Copyright (c) 2009, NVIDIA Corporation. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include "nvodm_query_discovery.h" #include "nvodm_kbc.h" #include "nvodm_query_kbc.h" #include "nvodm_kbc_keymapping.h" #ifdef CONFIG_KEYBOARD_TEGRA struct tegra_kbc_plat *tegra_kbc_odm_to_plat(void) { struct tegra_kbc_plat *pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); const NvOdmPeripheralConnectivity *conn; NvOdmPeripheralSearch srch_attr = NvOdmPeripheralSearch_IoModule; const struct NvOdmKeyVirtTableDetail **vkeys; NvU32 srch_val = NvOdmIoModule_Kbd; NvU32 temp; NvU64 guid; NvU32 i, j, k; NvU32 cols=0; NvU32 rows=0; NvU32 *wake_row; NvU32 *wake_col; NvU32 wake_num; NvU32 vnum; if (!pdata) return NULL; pdata->keymap = kzalloc(sizeof(*pdata->keymap)*KBC_MAX_KEY, GFP_KERNEL); if (!pdata->keymap) { kfree(pdata->keymap); return NULL; } if (NvOdmKbcIsSelectKeysWkUpEnabled(&wake_row, &wake_col, &wake_num)) { BUG_ON(!wake_num || wake_num>=KBC_MAX_KEY); pdata->wake_cfg = kzalloc(sizeof(*pdata->wake_cfg)*wake_num, GFP_KERNEL); if (pdata->wake_cfg) { pdata->wake_cnt = (int)wake_num; for (i=0; iwake_cfg[i].row=wake_row[i]; pdata->wake_cfg[i].col=wake_col[i]; } } else pr_err("disabling wakeup key filtering due to " "out-of-memory error\n"); } NvOdmKbcGetParameter(NvOdmKbcParameter_DebounceTime, 1, &temp); pdata->debounce_cnt = temp; /* repeat cycle is reported from ODM in milliseconds, * but needs to be specified in 32KHz ticks */ NvOdmKbcGetParameter(NvOdmKbcParameter_RepeatCycleTime, 1, &temp); pdata->repeat_cnt = temp * 4096 / 125; temp = NvOdmPeripheralEnumerate(&srch_attr, &srch_val, 1, &guid, 1); if (!temp) { kfree(pdata); return NULL; } conn = NvOdmPeripheralGetGuid(guid); if (!conn) { kfree(pdata); return NULL; } for (i=0; iNumAddress; i++) { NvU32 addr = conn->AddressList[i].Address; if (conn->AddressList[i].Interface!=NvOdmIoModule_Kbd) continue; if (conn->AddressList[i].Instance) { pdata->pin_cfg[addr].num = cols++; pdata->pin_cfg[addr].is_col = true; } else { pdata->pin_cfg[addr].num = rows++; pdata->pin_cfg[addr].is_row = true; } } for (i=0; ikeymap[i] = -1; vnum = NvOdmKbcKeyMappingGetVirtualKeyMappingList(&vkeys); for (i=0; i= vkeys[k]->StartScanCode && sc <= vkeys[k]->EndScanCode) { sc -= vkeys[k]->StartScanCode; sc = vkeys[k]->pVirtualKeyTable[sc]; if (!sc) continue; pdata->keymap[kbc_indexof(i,j)]=sc; } } } } return pdata; } #endif