summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-12-14 16:18:50 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-17 20:47:01 -0800
commit1817c17273dac363a93e5a6b6169d88b79479bd4 (patch)
tree9b454ae9db6e329f8da4063d7f70c03471555b9e /chip
parent2577c1cddd38b7c0c04cb57f6941b10c205b99e7 (diff)
downloadchrome-ec-1817c17273dac363a93e5a6b6169d88b79479bd4.tar.gz
Keyboard: Consolidate keyboard factory tests
This patch consolidates keyboard factory tests, which are currently duplicated under the chip directories. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: I1ab8bc96808e1c284d991d3c2f1f82a37329676e Reviewed-on: https://chromium-review.googlesource.com/1378654 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/mchp/keyboard_raw.c70
-rw-r--r--chip/mec1322/keyboard_raw.c70
-rw-r--r--chip/npcx/keyboard_raw.c65
3 files changed, 7 insertions, 198 deletions
diff --git a/chip/mchp/keyboard_raw.c b/chip/mchp/keyboard_raw.c
index 4d146e85f8..ef968c0eb8 100644
--- a/chip/mchp/keyboard_raw.c
+++ b/chip/mchp/keyboard_raw.c
@@ -98,73 +98,7 @@ void keyboard_raw_interrupt(void)
}
DECLARE_IRQ(MCHP_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 keyboard_raw_is_input_low(int port, int id)
{
- int i, j, flags;
- uint16_t shorted = 0;
- uint32_t port, id, val;
-
- /* Disable keyboard scan while testing */
- keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_CLOSED);
-
- flags = gpio_get_default_flags(GPIO_KBD_KSO2);
-
- /* 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 = MCHP_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);
- gpio_set_flags(GPIO_KBD_KSO2, flags);
- keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_CLOSED);
-
- return shorted;
+ return (MCHP_GPIO_CTL(port, id) & (1 << 24)) == 0;
}
-#endif
diff --git a/chip/mec1322/keyboard_raw.c b/chip/mec1322/keyboard_raw.c
index 2befb00fe6..3269af2cf9 100644
--- a/chip/mec1322/keyboard_raw.c
+++ b/chip/mec1322/keyboard_raw.c
@@ -82,73 +82,7 @@ void keyboard_raw_interrupt(void)
}
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 keyboard_raw_is_input_low(int port, int id)
{
- int i, j, flags;
- uint16_t shorted = 0;
- uint32_t port, id, val;
-
- /* Disable keyboard scan while testing */
- keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_CLOSED);
-
- flags = gpio_get_default_flags(GPIO_KBD_KSO2);
-
- /* 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);
- gpio_set_flags(GPIO_KBD_KSO2, flags);
- keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_CLOSED);
-
- return shorted;
+ return (MEC1322_GPIO_CTL(port, id) & (1 << 24)) == 0;
}
-#endif
diff --git a/chip/npcx/keyboard_raw.c b/chip/npcx/keyboard_raw.c
index 9ab1b1cddf..97a563c53f 100644
--- a/chip/npcx/keyboard_raw.c
+++ b/chip/npcx/keyboard_raw.c
@@ -156,67 +156,8 @@ void keyboard_raw_interrupt(void)
}
DECLARE_IRQ(NPCX_IRQ_KSI_WKINTC_1, keyboard_raw_interrupt, 5);
-#ifdef CONFIG_KEYBOARD_FACTORY_TEST
-
-/* Run keyboard factory testing, scan out KSO/KSI if any shorted. */
-int keyboard_factory_test_scan(void)
+int keyboard_raw_is_input_low(int port, int id)
{
- int i, j, flags;
- uint16_t shorted = 0;
- uint32_t port, id;
-
- /* Disable keyboard scan while testing */
- keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_CLOSED);
-
- flags = gpio_get_default_flags(GPIO_KBD_KSO2);
-
- /* 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;
-
- if ((NPCX_PDIN(keyboard_factory_scan_pins[j][0]) &
- (1 << keyboard_factory_scan_pins[j][1])) == 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);
- gpio_set_flags(GPIO_KBD_KSO2, flags);
- keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_CLOSED);
-
- return shorted;
+ return (NPCX_PDIN(port) & (1 << id)) == 0;
}
-#endif
+