summaryrefslogtreecommitdiff
path: root/chip/mec1322
diff options
context:
space:
mode:
authorDevn Lu <Devin.lu@quantatw.com>2016-03-14 15:23:05 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-04-01 00:21:35 -0700
commit93be0c3b0ac3ed49d7d1d99c5ace8cd0487de7f5 (patch)
treed1862b3dbd160bd2983f1a966047c5830d0f7346 /chip/mec1322
parent55cd6e4c75895c5727ea6fd87b047a39a8730490 (diff)
downloadchrome-ec-93be0c3b0ac3ed49d7d1d99c5ace8cd0487de7f5.tar.gz
ectool: Support keyboard factory scanning
This is keyboard test mechanism request for "multiple key press test", we can thru the testing to scan out kso ksi pins shortting or keyboard has multiple key pressing, below was the testing steps: 1. Turn off internal keyboard scan function. 2. Set all scan & sense pins to input and internal push up. 3. Set start one pin to output low. 4. check other pins status if any sense low level. 5. repeat step 3~4 for all keyboard KSO/KSI pins. 6. Turn on internal keyboard scan function. BUG=chrome-os-partner:49235 BRANCH=ToT TEST=manual Short any KSO or KSI pins and excute "ectool kbfactorytest", it shows failed. if no pins short together, it shows passed. Change-Id: Id2c4310d45e892aebc6d2c0795db22eba5a30641 Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/332322 Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'chip/mec1322')
-rw-r--r--chip/mec1322/keyboard_raw.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/chip/mec1322/keyboard_raw.c b/chip/mec1322/keyboard_raw.c
index 8569472682..729ab9bda0 100644
--- a/chip/mec1322/keyboard_raw.c
+++ b/chip/mec1322/keyboard_raw.c
@@ -81,3 +81,71 @@ void keyboard_raw_interrupt(void)
task_wake(TASK_ID_KEYSCAN);
}
DECLARE_IRQ(MEC1322_IRQ_KSC_INT, keyboard_raw_interrupt, 1);
+
+#ifdef CONFIG_KEYBOARD_FACTORY_TEST
+
+/* Run keyboard factory testing, scan out KSO/KSI if any shorted. */
+int keyboard_factory_test_scan(void)
+{
+ int i, j;
+ uint16_t shorted = 0;
+ uint32_t port, id, val;
+
+ /* Disable keyboard scan while testing */
+ keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_CLOSED);
+
+ /* Set all of KSO/KSI pins to internal pull-up and input */
+ for (i = 0; i < keyboard_factory_scan_pins_used; i++) {
+
+ if (keyboard_factory_scan_pins[i][0] < 0)
+ continue;
+
+ port = keyboard_factory_scan_pins[i][0];
+ id = keyboard_factory_scan_pins[i][1];
+
+ gpio_set_alternate_function(port, 1 << id, -1);
+ gpio_set_flags_by_mask(port, 1 << id,
+ GPIO_INPUT | GPIO_PULL_UP);
+ }
+
+ /*
+ * Set start pin to output low, then check other pins
+ * going to low level, it indicate the two pins are shorted.
+ */
+ for (i = 0; i < keyboard_factory_scan_pins_used; i++) {
+
+ if (keyboard_factory_scan_pins[i][0] < 0)
+ continue;
+
+ port = keyboard_factory_scan_pins[i][0];
+ id = keyboard_factory_scan_pins[i][1];
+
+ gpio_set_flags_by_mask(port, 1 << id, GPIO_OUT_LOW);
+
+ for (j = 0; j < i; j++) {
+
+ if (keyboard_factory_scan_pins[j][0] < 0)
+ continue;
+
+ /*
+ * Get gpio pin control register,
+ * bit 24 indicate GPIO input from the pad.
+ */
+ val = MEC1322_GPIO_CTL(keyboard_factory_scan_pins[j][0],
+ keyboard_factory_scan_pins[j][1]);
+
+ if ((val & (1 << 24)) == 0) {
+ shorted = i << 8 | j;
+ goto done;
+ }
+ }
+ gpio_set_flags_by_mask(port, 1 << id,
+ GPIO_INPUT | GPIO_PULL_UP);
+ }
+done:
+ gpio_config_module(MODULE_KEYBOARD_SCAN, 1);
+ keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_CLOSED);
+
+ return shorted;
+}
+#endif