summaryrefslogtreecommitdiff
path: root/board/cr50/board.c
blob: fc0b87dc69e66ae8458fc6265fa20252cfa8301d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "clock.h"
#include "common.h"
#include "console.h"
#include "dcrypto/dcrypto.h"
#include "device_state.h"
#include "ec_version.h"
#include "flash_config.h"
#include "gpio.h"
#include "hooks.h"
#include "i2cs.h"
#include "init_chip.h"
#include "registers.h"
#include "nvmem.h"
#include "system.h"
#include "task.h"
#include "trng.h"
#include "uartn.h"
#include "usb_descriptor.h"
#include "usb_hid.h"
#include "util.h"
#include "spi.h"
#include "usb_spi.h"

/* Define interrupt and gpio structs */
#include "gpio_list.h"

#include "cryptoc/sha.h"

/*
 * Need to include Implementation.h here to make sure that NVRAM size
 * definitions match across different git repos.
 *
 * MAX() definition from include/utils.h does not work in Implementation.h, as
 * it is used in a preprocessor expression there;
 *
 * SHA_DIGEST_SIZE is defined to be the same in both git repos, but using
 * different expressions.
 *
 * To untangle compiler errors let's just undefine MAX() and SHA_DIGEST_SIZE
 * here, as nether is necessary in this case: all we want from
 * Implementation.h at this point is the definition for NV_MEMORY_SIZE.
 */
#undef MAX
#undef SHA_DIGEST_SIZE
#include "Implementation.h"

#define NVMEM_CR50_SIZE 300
#define NVMEM_TPM_SIZE ((sizeof((struct nvmem_partition *)0)->buffer) \
			- NVMEM_CR50_SIZE)

/*
 * Make sure NV memory size definition in Implementation.h matches reality. It
 * should be set to
 *
 * NVMEM_PARTITION_SIZE - NVMEM_CR50_SIZE - 8
 */
BUILD_ASSERT(NVMEM_TPM_SIZE == NV_MEMORY_SIZE);

/* NvMem user buffer lengths table */
uint32_t nvmem_user_sizes[NVMEM_NUM_USERS] = {
	NVMEM_TPM_SIZE,
	NVMEM_CR50_SIZE
};

/*  Board specific configuration settings */
static uint32_t board_properties;

/*
 * There's no way to trigger on both rising and falling edges, so force a
 * compiler error if we try. The workaround is to use the pinmux to connect
 * two GPIOs to the same input and configure each one for a separate edge.
 */
#define GPIO_INT(name, pin, flags, signal)	\
	BUILD_ASSERT(((flags) & GPIO_INT_BOTH) != GPIO_INT_BOTH);
#include "gpio.wrap"

static void init_pmu(void)
{
	clock_enable_module(MODULE_PMU, 1);

	/* This boot sequence may be a result of previous soft reset,
	 * in which case the PMU low power sequence register needs to
	 * be reset. */
	GREG32(PMU, LOW_POWER_DIS) = 0;

	/* Enable wakeup interrupt */
	task_enable_irq(GC_IRQNUM_PMU_INTR_WAKEUP_INT);
	GWRITE_FIELD(PMU, INT_ENABLE, INTR_WAKEUP, 1);
}

void pmu_wakeup_interrupt(void)
{
	int exiten, wakeup_src;

	delay_sleep_by(1 * MSEC);

	wakeup_src = GR_PMU_EXITPD_SRC;

	/* Clear interrupt state */
	GWRITE_FIELD(PMU, INT_STATE, INTR_WAKEUP, 1);

	/* Clear pmu reset */
	GWRITE(PMU, CLRRST, 1);

	if (wakeup_src & GC_PMU_EXITPD_SRC_PIN_PD_EXIT_MASK) {
		/*
		 * If any wake pins are edge triggered, the pad logic latches
		 * the wakeup. Clear EXITEN0 to reset the wakeup logic.
		 */
		exiten = GREG32(PINMUX, EXITEN0);
		GREG32(PINMUX, EXITEN0) = 0;
		GREG32(PINMUX, EXITEN0) = exiten;

		/*
		 * Delay sleep long enough for a SPI slave transaction to start
		 * or for the system to be reset.
		 */
		delay_sleep_by(3 * MINUTE);

		if (!gpio_get_level(GPIO_SYS_RST_L_IN))
			sys_rst_asserted(GPIO_SYS_RST_L_IN);
	}

	/* Trigger timer0 interrupt */
	if (wakeup_src & GC_PMU_EXITPD_SRC_TIMELS0_PD_EXIT_TIMER0_MASK)
		task_trigger_irq(GC_IRQNUM_TIMELS0_TIMINT0);

	/* Trigger timer1 interrupt */
	if (wakeup_src & GC_PMU_EXITPD_SRC_TIMELS0_PD_EXIT_TIMER1_MASK)
		task_trigger_irq(GC_IRQNUM_TIMELS0_TIMINT1);

}
DECLARE_IRQ(GC_IRQNUM_PMU_INTR_WAKEUP_INT, pmu_wakeup_interrupt, 1);

static void init_interrupts(void)
{
	int i;
	uint32_t exiten = GREG32(PINMUX, EXITEN0);

	/* Clear wake pin interrupts */
	GREG32(PINMUX, EXITEN0) = 0;
	GREG32(PINMUX, EXITEN0) = exiten;

	/* Enable all GPIO interrupts */
	for (i = 0; i < gpio_ih_count; i++)
		if (gpio_list[i].flags & GPIO_INT_ANY)
			gpio_enable_interrupt(i);
}

enum permission_level {
	PERMISSION_LOW = 0x00,
	PERMISSION_MEDIUM = 0x33,    /* APPS run at medium */
	PERMISSION_HIGH = 0x3C,
	PERMISSION_HIGHEST = 0x55
};

/* Drop run level to at least medium. */
static void init_runlevel(const enum permission_level desired_level)
{
	volatile uint32_t *const reg_addrs[] = {
		/* CPU's use of the system peripheral bus */
		GREG32_ADDR(GLOBALSEC, CPU0_S_PERMISSION),
		/* CPU's use of the system bus via the debug access port */
		GREG32_ADDR(GLOBALSEC, CPU0_S_DAP_PERMISSION),
		/* DMA's use of the system peripheral bus */
		GREG32_ADDR(GLOBALSEC, DDMA0_PERMISSION),
		/* Current software level affects which (if any) scratch
		 * registers can be used for a warm boot hardware-verified
		 * jump. */
		GREG32_ADDR(GLOBALSEC, SOFTWARE_LVL),
	};
	int i;

	/* Permission registers drop by 1 level (e.g. HIGHEST -> HIGH)
	 * each time a write is encountered (the value written does
	 * not matter).  So we repeat writes and reads, until the
	 * desired level is reached.
	 */
	for (i = 0; i < ARRAY_SIZE(reg_addrs); i++) {
		uint32_t current_level;

		while (1) {
			current_level = *reg_addrs[i];
			if (current_level <= desired_level)
				break;
			*reg_addrs[i] = desired_level;
		}
	}
}

static void configure_board_specific_gpios(void)
{
	/* Add a pullup to sys_rst_l */
	if (system_get_board_properties() & BOARD_NEEDS_SYS_RST_PULL_UP)
		GWRITE_FIELD(PINMUX, DIOM0_CTL, PU, 1);
}

/* Initialize board. */
static void board_init(void)
{
	configure_board_specific_gpios();
	init_pmu();
	init_interrupts();
	init_trng();
	init_jittery_clock(1);
	init_runlevel(PERMISSION_MEDIUM);
	/* Initialize NvMem partitions */
	nvmem_init();

	/* TODO(crosbug.com/p/49959): For now, leave flash WP unlocked */
	GREG32(RBOX, EC_WP_L) = 1;

	/* Indication that firmware is running, for debug purposes. */
	GREG32(PMU, PWRDN_SCRATCH16) = 0xCAFECAFE;
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);

#if defined(CONFIG_USB)
const void * const usb_strings[] = {
	[USB_STR_DESC] = usb_string_desc,
	[USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."),
	[USB_STR_PRODUCT] = USB_STRING_DESC("Cr50"),
	[USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32),
	[USB_STR_CONSOLE_NAME] = USB_STRING_DESC("Shell"),
	[USB_STR_BLOB_NAME] = USB_STRING_DESC("Blob"),
	[USB_STR_HID_NAME] = USB_STRING_DESC("PokeyPokey"),
	[USB_STR_AP_NAME] = USB_STRING_DESC("AP"),
	[USB_STR_EC_NAME] = USB_STRING_DESC("EC"),
	[USB_STR_UPGRADE_NAME] = USB_STRING_DESC("Firmware upgrade"),
	[USB_STR_SPI_NAME] = USB_STRING_DESC("AP EC upgrade"),
};
BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT);
#endif

/* SPI devices */
const struct spi_device_t spi_devices[] = {
	[CONFIG_SPI_FLASH_PORT] = {0, 2, GPIO_COUNT}
};
const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);

int flash_regions_to_enable(struct g_flash_region *regions,
			    int max_regions)
{
	/*
	 * This needs to account for two regions: the "other" RW partition and
	 * the NVRAM in TOP_B.
	 *
	 * When running from RW_A the two regions are adjacent, but it is
	 * simpler to keep function logic the same and always configure two
	 * separate regions.
	 */

	if (max_regions < 3)
		return 0;

	/* Enable access to the other RW image... */
	if (system_get_image_copy() == SYSTEM_IMAGE_RW)
		/* Running RW_A, enable RW_B */
		regions[0].reg_base = CONFIG_MAPPED_STORAGE_BASE +
			CONFIG_RW_B_MEM_OFF;
	else
		/* Running RW_B, enable RW_A */
		regions[0].reg_base = CONFIG_MAPPED_STORAGE_BASE +
			CONFIG_RW_MEM_OFF;
	/* Size is the same */
	regions[0].reg_size = CONFIG_RW_SIZE;
	regions[0].reg_perms = FLASH_REGION_EN_ALL;

	/* Enable access to the NVRAM partition A region */
	regions[1].reg_base = CONFIG_MAPPED_STORAGE_BASE +
		CONFIG_FLASH_NVMEM_OFFSET_A;
	regions[1].reg_size = NVMEM_PARTITION_SIZE;
	regions[1].reg_perms = FLASH_REGION_EN_ALL;

	/* Enable access to the NVRAM partition B region */
	regions[2].reg_base = CONFIG_MAPPED_STORAGE_BASE +
		CONFIG_FLASH_NVMEM_OFFSET_B;
	regions[2].reg_size = NVMEM_PARTITION_SIZE;
	regions[2].reg_perms = FLASH_REGION_EN_ALL;

	return 3;
}

#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)

void sys_rst_asserted(enum gpio_signal signal)
{
	/*
	 * Cr50 drives SYS_RST_L in certain scenarios, in those cases
	 * asserting this signal should not cause a system reset.
	 */
	CPRINTS("%s resceived signal %d)", __func__, signal);
	if (usb_spi_update_in_progress())
		return;

	cflush();
	system_reset(0);
}

void nvmem_compute_sha(uint8_t *p_buf, int num_bytes,
		       uint8_t *p_sha, int sha_len)
{
	uint8_t sha1_digest[SHA_DIGEST_SIZE];
	/*
	 * Taking advantage of the built in dcrypto engine to generate
	 * a CRC-like value that can be used to validate contents of an
	 * NvMem partition. Only using the lower 4 bytes of the sha1 hash.
	 */
	DCRYPTO_SHA1_hash((uint8_t *)p_buf,
			  num_bytes,
			  sha1_digest);
	memcpy(p_sha, sha1_digest, sha_len);
}

static void device_state_changed(enum device_type device,
				 enum device_state state)
{
	device_set_state(device, state);

	/* Disable interrupts */
	gpio_disable_interrupt(device_states[device].detect_on);
	gpio_disable_interrupt(device_states[device].detect_off);

	/*
	 * We've determined the device state, so cancel any deferred callbacks.
	 */
	hook_call_deferred(device_states[device].deferred, -1);
}

/*
 * If the UART is enabled we cant tell anything about the
 * servo state, so disable servo detection.
 */
static int servo_state_unknown(enum device_type device, int uart)
{
	if (uartn_enabled(UART_AP) && uartn_enabled(UART_EC))
		device_set_state(DEVICE_SERVO, DEVICE_STATE_UNKNOWN);

	if (uartn_enabled(uart)) {
		device_state_changed(device, DEVICE_STATE_UNKNOWN);
		return 1;
	}
	return 0;
}

static void servo_detached(enum device_type device, int uart)
{
	if (servo_state_unknown(device, uart) ||
	    device_get_state(device) == DEVICE_STATE_ON)
		return;
	device_state_changed(DEVICE_SERVO_AP, DEVICE_STATE_OFF);
	device_state_changed(DEVICE_SERVO_EC, DEVICE_STATE_OFF);

	device_set_state(DEVICE_SERVO, DEVICE_STATE_OFF);

	gpio_enable_interrupt(device_states[DEVICE_SERVO_AP].detect_on);
	gpio_enable_interrupt(device_states[DEVICE_SERVO_EC].detect_on);
}

static void device_powered_off(enum device_type device, int uart)
{
	if (device_get_state(device) == DEVICE_STATE_ON)
		return;

	device_state_changed(device, DEVICE_STATE_OFF);

	/* Disable RX and TX on the UART peripheral */
	uartn_disable(uart);

	/* Disconnect the TX pin from the UART peripheral */
	uartn_tx_disconnect(uart);

	gpio_enable_interrupt(device_states[device].detect_on);
}

static void servo_ap_deferred(void)
{
	servo_detached(DEVICE_SERVO_AP, UART_AP);
}
DECLARE_DEFERRED(servo_ap_deferred);

static void servo_ec_deferred(void)
{
	servo_detached(DEVICE_SERVO_EC, UART_EC);
}
DECLARE_DEFERRED(servo_ec_deferred);

static void ap_deferred(void)
{
	device_powered_off(DEVICE_AP, UART_AP);
}
DECLARE_DEFERRED(ap_deferred);

static void ec_deferred(void)
{
	device_powered_off(DEVICE_EC, UART_EC);
}
DECLARE_DEFERRED(ec_deferred);

struct device_config device_states[] = {
	[DEVICE_SERVO_AP] = {
		.deferred = &servo_ap_deferred_data,
		.detect_on = GPIO_SERVO_UART1_ON,
		.detect_off = GPIO_SERVO_UART1_OFF,
		.name = "Servo AP"
	},
	[DEVICE_SERVO_EC] = {
		.deferred = &servo_ec_deferred_data,
		.detect_on = GPIO_SERVO_UART2_ON,
		.detect_off = GPIO_SERVO_UART2_OFF,
		.name = "Servo EC"
	},
	[DEVICE_AP] = {
		.deferred = &ap_deferred_data,
		.detect_on = GPIO_AP_ON,
		.detect_off = GPIO_AP_OFF,
		.name = "AP"
	},
	[DEVICE_EC] = {
		.deferred = &ec_deferred_data,
		.detect_on = GPIO_EC_ON,
		.detect_off = GPIO_EC_OFF,
		.name = "EC"
	},
	[DEVICE_SERVO] = {
		.detect_on = GPIO_COUNT,
		.detect_off = GPIO_COUNT,
		.name = "Servo"
	},
};
BUILD_ASSERT(ARRAY_SIZE(device_states) == DEVICE_COUNT);

static void device_powered_on(enum device_type device, int uart)
{
	/* Update the device state */
	device_state_changed(device, DEVICE_STATE_ON);

	/* Enable RX and TX on the UART peripheral */
	uartn_enable(uart);

	/* Connect the TX pin to the UART TX Signal */
	if (device_get_state(DEVICE_SERVO) != DEVICE_STATE_ON &&
	    !uartn_enabled(uart))
		uartn_tx_connect(uart);
}

static void servo_attached(enum device_type device, int uart)
{
	if (servo_state_unknown(device, uart))
		return;

	/* Update the device state */
	device_state_changed(device, DEVICE_STATE_ON);
	device_set_state(DEVICE_SERVO, DEVICE_STATE_ON);

	/* Disconnect AP and EC UART when servo is attached */
	uartn_tx_disconnect(UART_AP);
	uartn_tx_disconnect(UART_EC);
}

void device_state_on(enum gpio_signal signal)
{
	switch (signal) {
	case GPIO_AP_ON:
		device_powered_on(DEVICE_AP, UART_AP);
		break;
	case GPIO_EC_ON:
		device_powered_on(DEVICE_EC, UART_EC);
		break;
	case GPIO_SERVO_UART1_ON:
		servo_attached(DEVICE_SERVO_AP, UART_AP);
		break;
	case GPIO_SERVO_UART2_ON:
		servo_attached(DEVICE_SERVO_EC, UART_EC);
		break;
	default:
		CPRINTS("Device not supported");
		return;
	}
}

void device_state_off(enum gpio_signal signal)
{
	switch (signal) {
	case GPIO_AP_OFF:
		board_update_device_state(DEVICE_AP);
		break;
	case GPIO_EC_OFF:
		board_update_device_state(DEVICE_EC);
		break;
	case GPIO_SERVO_UART1_OFF:
		board_update_device_state(DEVICE_SERVO_AP);
		break;
	case GPIO_SERVO_UART2_OFF:
		board_update_device_state(DEVICE_SERVO_EC);
		break;
	default:
		CPRINTS("Device not supported");
	}
}

void board_update_device_state(enum device_type device)
{
	int state;

	if (device == DEVICE_SERVO)
		return;

	if (device == DEVICE_SERVO_EC || device == DEVICE_SERVO_AP) {
		/*
		 * If either AP UART TX or EC UART TX are pulled high when
		 * cr50 uart is not enabled, then servo is attached
		 */
		state = (!uartn_enabled(UART_AP) &&
			gpio_get_level(GPIO_SERVO_UART1_ON)) ||
			(!uartn_enabled(UART_EC) &&
			gpio_get_level(GPIO_SERVO_UART2_ON));
	} else
		state = gpio_get_level(device_states[device].detect_on);

	/*
	 * If the device is currently on set its state immediately. If it
	 * thinks the device is powered off debounce the signal.
	 */
	if (state)
		device_state_on(device_states[device].detect_on);
	else {
		device_set_state(device, DEVICE_STATE_UNKNOWN);

		gpio_enable_interrupt(device_states[device].detect_on);
		/*
		 * Wait a bit. If cr50 detects this device is ever powered on
		 * during this time then the status wont be set to powered off.
		 */
		hook_call_deferred(device_states[device].deferred, 50);
	}
}

void system_init_board_properties(void)
{
	uint32_t properties;

	properties = GREG32(PMU, LONG_LIFE_SCRATCH1);

	/*
	 * This must be a power on reset or maybe restart due to a software
	 * update from a version not setting the register.
	 */
	if (!properties || system_get_reset_flags() & RESET_FLAG_HARD) {
		/*
		 * Reset the properties, because after a hard reset the register
		 * won't be cleared.
		 */
		properties = 0;

		/* Read DIOA1 strap pin */
		if (gpio_get_level(GPIO_STRAP0)) {
			/* Strap is pulled high -> Kevin SPI TPM option */
			properties |= BOARD_SLAVE_CONFIG_SPI;
			/* Add an internal pull up on sys_rst_l */
			/*
			 * TODO(crosbug.com/p/54059): Remove once SYS_RST_L can
			 * be pulled up externally.
			 */
			properties |= BOARD_NEEDS_SYS_RST_PULL_UP;
		} else {
			/* Strap is low -> Reef I2C TPM option */
			properties |= BOARD_SLAVE_CONFIG_I2C;
			/* One PHY is connected to the AP */
			properties |= BOARD_USB_AP;
			/*
			 * TODO(crosbug.com/p/56540): enable UART0 RX on Reef.
			 * Early reef boards dont have the necessary pullups on
			 * UART0RX so disable it until that is fixed.
			 */
			properties |= BOARD_DISABLE_UART0_RX;
			/*
			 * Use receiving a usb set address request as a
			 * benchmark for marking the updated image as good.
			 */
			properties |= BOARD_MARK_UPDATE_ON_USB_REQ;
		}

		/*
		 * Now save the properties value for future use.
		 *
		 * First enable write access to the LONG_LIFE_SCRATCH1 register.
		 */
		GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG1, 1);
		/* Save properties in LONG_LIFE register */
		GREG32(PMU, LONG_LIFE_SCRATCH1) = properties;
		/* Disabel write access to the LONG_LIFE_SCRATCH1 register */
		GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG1, 0);
	}

	/* Save this configuration setting */
	board_properties = properties;
}

uint32_t system_board_properties_callback(void)
{
	return board_properties;
}

void i2cs_set_pinmux(void)
{
	/* Connect I2CS SDA/SCL output to A1/A9 pads */
	GWRITE(PINMUX, DIOA1_SEL, GC_PINMUX_I2CS0_SDA_SEL);
	GWRITE(PINMUX, DIOA9_SEL, GC_PINMUX_I2CS0_SCL_SEL);
	/* Connect A1/A9 pads to I2CS input SDA/SCL */
	GWRITE(PINMUX, I2CS0_SDA_SEL, GC_PINMUX_DIOA1_SEL);
	GWRITE(PINMUX, I2CS0_SCL_SEL, GC_PINMUX_DIOA9_SEL);
	/* Enable SDA/SCL inputs from A1/A9 pads */
	GWRITE_FIELD(PINMUX, DIOA1_CTL, IE, 1);	 /* I2CS_SDA */
	GWRITE_FIELD(PINMUX, DIOA9_CTL, IE, 1);	 /* I2CS_SCL */
	/*
	 * Enable pull ups on both signals. TODO(vbendeb): consider
	 * adjusting pull strength.
	 */
	GWRITE_FIELD(PINMUX, DIOA1_CTL, PU, 1);
	GWRITE_FIELD(PINMUX, DIOA9_CTL, PU, 1);
	/* TODO(scollyer): Do we need to add wake on SCL activity here? */

}