summaryrefslogtreecommitdiffstats
path: root/board/compulab/common/common.c
blob: f2ce522fa68535a9685f1da4420c3f3e75d81c41 (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
/*
 * (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il>
 *
 * Authors: Igor Grinberg <grinberg@compulab.co.il>
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */

#include <common.h>
#include <asm/bootm.h>
#include <asm/gpio.h>

#include "common.h"
#include "eeprom.h"

void cl_print_pcb_info(void)
{
	u32 board_rev = get_board_rev();
	u32 rev_major = board_rev / 100;
	u32 rev_minor = board_rev - (rev_major * 100);

	if ((rev_minor / 10) * 10 == rev_minor)
		rev_minor = rev_minor / 10;

	printf("PCB:   %u.%u\n", rev_major, rev_minor);
}

#ifdef CONFIG_CMD_USB
int cl_usb_hub_init(int gpio, const char *label)
{
	if (gpio_request(gpio, label)) {
		printf("Error: can't obtain GPIO%d for %s", gpio, label);
		return -1;
	}

	gpio_direction_output(gpio, 0);
	udelay(10);
	gpio_set_value(gpio, 1);
	udelay(1000);
	return 0;
}

void cl_usb_hub_deinit(int gpio)
{
	gpio_free(gpio);
}
#endif