summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-05-17 12:19:11 -0700
committerRandall Spangler <rspangler@chromium.org>2012-05-17 12:22:39 -0700
commit39149579a47f274b0a4326a8828f35bfc2a59837 (patch)
tree43863041d75c804e7fd4970879abc7c71cf2bc9d /board
parent103e055ddac9b3810d74be1336e61ecbebb4fd6d (diff)
downloadchrome-ec-39149579a47f274b0a4326a8828f35bfc2a59837.tar.gz
Add a list of I2C ports
This cleans up I2C init and debug commands across boards. Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=none TEST=on link and bds: i2cscan lightbar run powerbtn (to power on system) temps (to read i2c temp sensors) battery (to read battery) charger (to read charger) Change-Id: If3fb0cdb8d3178592bf68cbb2e72bc4b7f71dec5
Diffstat (limited to 'board')
-rw-r--r--board/bds/board.c14
-rw-r--r--board/bds/board.h10
-rw-r--r--board/link/board.c14
-rw-r--r--board/link/board.h9
4 files changed, 26 insertions, 21 deletions
diff --git a/board/bds/board.c b/board/bds/board.c
index b9c6ee564d..50c4a079e9 100644
--- a/board/bds/board.c
+++ b/board/bds/board.c
@@ -4,16 +4,16 @@
*/
/* Stellaris EKB-LM4F-EAC board-specific configuration */
+#include "adc.h"
#include "board.h"
#include "gpio.h"
+#include "i2c.h"
+#include "lm4_adc.h"
#include "registers.h"
#include "util.h"
-#include "lm4_adc.h"
-#include "adc.h"
/* ADC channels. Must be in the exactly same order as in enum adc_channel. */
-const struct adc_t adc_channels[ADC_CH_COUNT] =
-{
+const struct adc_t adc_channels[ADC_CH_COUNT] = {
/* EC internal temperature is calculated by
* 273 + (295 - 450 * ADC_VALUE / ADC_READ_MAX) / 2
* = -225 * ADC_VALUE / ADC_READ_MAX + 420.5
@@ -32,6 +32,12 @@ const struct adc_t adc_channels[ADC_CH_COUNT] =
};
+/* I2C ports */
+const struct i2c_port_t i2c_ports[I2C_PORTS_USED] = {
+ {"lightbar", I2C_PORT_LIGHTBAR, 400},
+};
+
+
/* GPIO signal list. Must match order from enum gpio_signal. */
const struct gpio_info gpio_list[GPIO_COUNT] = {
{"RECOVERYn", LM4_GPIO_D, (1<<1), GPIO_PULL_UP, NULL},
diff --git a/board/bds/board.h b/board/bds/board.h
index b570dfdeb3..dd4d887ad0 100644
--- a/board/bds/board.h
+++ b/board/bds/board.h
@@ -16,15 +16,9 @@ enum adc_channel
};
/* I2C ports */
-#define I2C_PORT_BATTERY 5 // port 0 / PB2:3 on Link, open on badger
-#define I2C_PORT_CHARGER 5 // port 1 / PA6:7 on Link, user LED on badger
-#define I2C_PORT_THERMAL 5 // port 5 / PB6:7 on link, but PG6:7 on badger
#define I2C_PORT_LIGHTBAR 5 // port 5 / PA6:7 on link, but PG6:7 on badger
-/* I2C port speeds in kbps. All the same because they all share a port */
-#define I2C_SPEED_BATTERY 400
-#define I2C_SPEED_CHARGER 400
-#define I2C_SPEED_LIGHTBAR 400
-#define I2C_SPEED_THERMAL 400
+/* Number of I2C ports used */
+#define I2C_PORTS_USED 1
/* GPIO signal list */
enum gpio_signal {
diff --git a/board/link/board.c b/board/link/board.c
index 4524da3955..3ff559c1a9 100644
--- a/board/link/board.c
+++ b/board/link/board.c
@@ -8,6 +8,7 @@
#include "board.h"
#include "config.h"
#include "gpio.h"
+#include "i2c.h"
#include "lm4_adc.h"
#include "power_button.h"
#include "registers.h"
@@ -114,8 +115,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = {
};
/* ADC channels. Must be in the exactly same order as in enum adc_channel. */
-const struct adc_t adc_channels[ADC_CH_COUNT] =
-{
+const struct adc_t adc_channels[ADC_CH_COUNT] = {
/* EC internal temperature is calculated by
* 273 + (295 - 450 * ADC_VALUE / ADC_READ_MAX) / 2
* = -225 * ADC_VALUE / ADC_READ_MAX + 420.5
@@ -130,6 +130,16 @@ const struct adc_t adc_channels[ADC_CH_COUNT] =
LM4_AIN(11), 0x06 /* IE0 | END0 */},
};
+/* I2C ports */
+const struct i2c_port_t i2c_ports[I2C_PORTS_USED] = {
+ /* Note: battery and charger share a port. Only include it once in
+ * this list so we don't double-initialize it. */
+ {"batt_chg", I2C_PORT_BATTERY, 100},
+ {"lightbar", I2C_PORT_LIGHTBAR, 400},
+ /* TODO: TMP007 supports 3.4Mbps operation; use faster speed? */
+ {"thermal", I2C_PORT_THERMAL, 400},
+};
+
void configure_board(void)
{
}
diff --git a/board/link/board.h b/board/link/board.h
index 3972ac481d..e7ba6abfed 100644
--- a/board/link/board.h
+++ b/board/link/board.h
@@ -88,18 +88,13 @@ enum adc_channel
#define EEPROM_BLOCK_START_PSTORE 16 /* Host persistent storage */
#define EEPROM_BLOCK_COUNT_PSTORE 16
-
/* I2C ports */
#define I2C_PORT_BATTERY 0
#define I2C_PORT_CHARGER 0 /* Note: proto0 used port 1 */
#define I2C_PORT_THERMAL 5
#define I2C_PORT_LIGHTBAR 1
-/* I2C port speeds in kbps */
-#define I2C_SPEED_BATTERY 100
-#define I2C_SPEED_CHARGER 100
-#define I2C_SPEED_THERMAL 400 /* TODO: TMP007 supports 3.4Mbps
- operation; use faster speed? */
-#define I2C_SPEED_LIGHTBAR 400
+/* There are only 3 I2C ports used because battery and charger share a port */
+#define I2C_PORTS_USED 3
/* Keyboard scanner uses an entire GPIO bank for row inputs */
#define KB_SCAN_ROW_IRQ LM4_IRQ_GPION