summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-08-02 13:45:21 -0700
committerChromeBot <chrome-bot@google.com>2013-08-02 17:32:35 -0700
commit93536fbe55d309d335682b1fd5223f5389d0c456 (patch)
tree717bfec42c981f1821c2a3efc281d5fc82eb9dbb
parent889f7bdd3b77151dd5b749974c94a84ae8b2aeb8 (diff)
downloadchrome-ec-93536fbe55d309d335682b1fd5223f5389d0c456.tar.gz
Change one-wire bus to use normal gpio interface
There's no need for it to directly access the GPIO registers. That was only necessary at the beginning of link, when gpio_set_flags() didn't exist. BUG=chrome-os-partner:21612 BRANCH=none TEST=onewire red / onewire green / onewire yellow all set the adapter LED (tested on link, since I don't have a bolt, but the EC chip and adapter are identical) Change-Id: I2386962ff039bb2251be38eaadcaeae8ffd1ea7b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/64375 Reviewed-by: Vic Yang <victoryang@chromium.org>
-rw-r--r--board/bolt/board.c1
-rw-r--r--board/bolt/board.h3
-rw-r--r--board/link/board.c1
-rw-r--r--board/link/board.h3
-rw-r--r--chip/lm4/onewire.c33
-rw-r--r--include/config.h6
6 files changed, 9 insertions, 38 deletions
diff --git a/board/bolt/board.c b/board/bolt/board.c
index c567749bff..ccdc8bce87 100644
--- a/board/bolt/board.c
+++ b/board/bolt/board.c
@@ -70,6 +70,7 @@ const struct gpio_info gpio_list[] = {
{"BOARD_VERSION2", LM4_GPIO_Q, (1<<6), GPIO_INPUT, NULL},
{"BOARD_VERSION3", LM4_GPIO_Q, (1<<7), GPIO_INPUT, NULL},
{"CPU_PGOOD", LM4_GPIO_C, (1<<4), GPIO_INPUT, NULL},
+ {"ONEWIRE", LM4_GPIO_F, (1<<7), GPIO_INPUT, NULL},
{"PCH_CATERR_L", LM4_GPIO_F, (1<<3), GPIO_INPUT, NULL},
{"THERMAL_DATA_READY_L", LM4_GPIO_B, (1<<0), GPIO_INPUT, NULL},
{"USB1_OC_L", LM4_GPIO_E, (1<<7), GPIO_INPUT, NULL},
diff --git a/board/bolt/board.h b/board/bolt/board.h
index 36e274011d..3fed8c42f4 100644
--- a/board/bolt/board.h
+++ b/board/bolt/board.h
@@ -26,8 +26,6 @@
#endif
#define CONFIG_LED_DRIVER_DS2413
#define CONFIG_ONEWIRE
-#define CONFIG_ONEWIRE_BANK LM4_GPIO_F
-#define CONFIG_ONEWIRE_PIN (1 << 7)
#define CONFIG_POWER_BUTTON
#define CONFIG_POWER_BUTTON_X86
#define CONFIG_WP_ACTIVE_HIGH
@@ -104,6 +102,7 @@ enum gpio_signal {
GPIO_BOARD_VERSION2, /* Board version stuffing resistor 2 */
GPIO_BOARD_VERSION3, /* Board version stuffing resistor 3 */
GPIO_CPU_PGOOD, /* Power good to the CPU */
+ GPIO_ONEWIRE, /* One-wire bus to adapter LED */
GPIO_PCH_CATERR_L, /* Catastrophic error signal from PCH */
GPIO_THERMAL_DATA_READY_L, /* From thermal sensor */
GPIO_USB1_OC_L, /* USB port overcurrent warning */
diff --git a/board/link/board.c b/board/link/board.c
index b4fa8818b4..cfcc695ecd 100644
--- a/board/link/board.c
+++ b/board/link/board.c
@@ -41,6 +41,7 @@ const struct gpio_info gpio_list[] = {
{"BOARD_VERSION1", LM4_GPIO_H, (1<<6), 0, NULL},
{"BOARD_VERSION2", LM4_GPIO_L, (1<<6), 0, NULL},
{"BOARD_VERSION3", LM4_GPIO_L, (1<<7), 0, NULL},
+ {"ONEWIRE", LM4_GPIO_H, (1<<2), 0, NULL},
{"PCH_BKLTEN", LM4_GPIO_J, (1<<3), GPIO_INT_BOTH,
backlight_interrupt},
{"PCH_SLP_A_L", LM4_GPIO_G, (1<<5), GPIO_INT_BOTH,
diff --git a/board/link/board.h b/board/link/board.h
index 422db1dfcd..ea6d2f1f62 100644
--- a/board/link/board.h
+++ b/board/link/board.h
@@ -26,8 +26,6 @@
#endif
#define CONFIG_LED_DRIVER_DS2413
#define CONFIG_ONEWIRE
-#define CONFIG_ONEWIRE_BANK LM4_GPIO_H
-#define CONFIG_ONEWIRE_PIN (1 << 2)
#define CONFIG_POWER_BUTTON
#define CONFIG_POWER_BUTTON_X86
#define CONFIG_PWM_FAN
@@ -95,6 +93,7 @@ enum gpio_signal {
GPIO_BOARD_VERSION1, /* Board version stuffing resistor 1 */
GPIO_BOARD_VERSION2, /* Board version stuffing resistor 2 */
GPIO_BOARD_VERSION3, /* Board version stuffing resistor 3 */
+ GPIO_ONEWIRE, /* One-wire bus to adapter LED */
GPIO_PCH_BKLTEN, /* Backlight enable signal from PCH */
GPIO_PCH_SLP_A_L, /* SLP_A# signal from PCH */
GPIO_PCH_SLP_ME_CSW_DEV_L, /* SLP_ME_CSW_DEV# signal from PCH */
diff --git a/chip/lm4/onewire.c b/chip/lm4/onewire.c
index 1147314b6b..e57d6db5a1 100644
--- a/chip/lm4/onewire.c
+++ b/chip/lm4/onewire.c
@@ -7,15 +7,9 @@
#include "common.h"
#include "gpio.h"
-#include "hooks.h"
-#include "registers.h"
#include "task.h"
#include "timer.h"
-#if !defined(CONFIG_ONEWIRE_BANK) || !defined(CONFIG_ONEWIRE_PIN)
-#error Unsupported board. CONFIG_ONEWIRE_BANK/PIN need to be defined.
-#endif
-
/*
* Standard speed; all timings padded by 2 usec for safety.
*
@@ -38,18 +32,10 @@
*/
static void output0(int usec)
{
- LM4_GPIO_DIR(CONFIG_ONEWIRE_BANK) |= CONFIG_ONEWIRE_PIN;
- LM4_GPIO_DATA(CONFIG_ONEWIRE_BANK, CONFIG_ONEWIRE_PIN) = 0;
+ gpio_set_flags(GPIO_ONEWIRE,
+ GPIO_OPEN_DRAIN | GPIO_OUTPUT | GPIO_OUT_LOW);
udelay(usec);
- LM4_GPIO_DIR(CONFIG_ONEWIRE_BANK) &= ~CONFIG_ONEWIRE_PIN;
-}
-
-/**
- * Read the signal line.
- */
-static int readline(void)
-{
- return LM4_GPIO_DATA(CONFIG_ONEWIRE_BANK, CONFIG_ONEWIRE_PIN) ? 1 : 0;
+ gpio_set_flags(GPIO_ONEWIRE, GPIO_INPUT);
}
/**
@@ -72,7 +58,7 @@ static int readbit(void)
udelay(T_MSR - T_RL);
/* Read bit */
- bit = readline();
+ bit = gpio_get_level(GPIO_ONEWIRE);
/*
* Enable interrupt as soon as we've read the bit. The delay to the
@@ -125,7 +111,7 @@ int onewire_reset(void)
*/
udelay(T_MSP);
- if (readline() != 0)
+ if (gpio_get_level(GPIO_ONEWIRE))
return EC_ERROR_UNKNOWN;
/*
@@ -156,12 +142,3 @@ void onewire_write(int data)
for (i = 0; i < 8; i++)
writebit((data >> i) & 0x01); /* LSB first */
}
-
-static void onewire_init(void)
-{
- /* Configure 1-wire pin as open-drain GPIO */
- gpio_set_alternate_function(CONFIG_ONEWIRE_BANK,
- CONFIG_ONEWIRE_PIN, -1);
- LM4_GPIO_ODR(CONFIG_ONEWIRE_BANK) |= CONFIG_ONEWIRE_PIN;
-}
-DECLARE_HOOK(HOOK_INIT, onewire_init, HOOK_PRIO_DEFAULT);
diff --git a/include/config.h b/include/config.h
index f86ab58a17..219a2c82bc 100644
--- a/include/config.h
+++ b/include/config.h
@@ -403,12 +403,6 @@
/* Compile support for one-wire interface */
#undef CONFIG_ONEWIRE
-/* GPIO bank for one-wire interface */
-#undef CONFIG_ONEWIRE_BANK
-
-/* Pin mask for one-wire interface */
-#undef CONFIG_ONEWIRE_PIN
-
/* Check for stack overflows on every context switch */
#undef CONFIG_OVERFLOW_DETECT