xref: /openbmc/u-boot/board/compulab/common/common.c (revision cf0bcd7d)
1 /*
2  * (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il>
3  *
4  * Authors: Igor Grinberg <grinberg@compulab.co.il>
5  *
6  * SPDX-License-Identifier:	GPL-2.0+
7  */
8 
9 #include <common.h>
10 #include <asm/bootm.h>
11 #include <asm/gpio.h>
12 #include <asm/setup.h>
13 
14 #include "common.h"
15 #include "eeprom.h"
16 
17 void cl_print_pcb_info(void)
18 {
19 	u32 board_rev = get_board_rev();
20 	u32 rev_major = board_rev / 100;
21 	u32 rev_minor = board_rev - (rev_major * 100);
22 
23 	if ((rev_minor / 10) * 10 == rev_minor)
24 		rev_minor = rev_minor / 10;
25 
26 	printf("PCB:   %u.%u\n", rev_major, rev_minor);
27 }
28 
29 #ifdef CONFIG_SERIAL_TAG
30 void __weak get_board_serial(struct tag_serialnr *serialnr)
31 {
32 	/*
33 	 * This corresponds to what happens when we can communicate with the
34 	 * eeprom but don't get a valid board serial value.
35 	 */
36 	serialnr->low = 0;
37 	serialnr->high = 0;
38 };
39 #endif
40 
41 #ifdef CONFIG_CMD_USB
42 int cl_usb_hub_init(int gpio, const char *label)
43 {
44 	if (gpio_request(gpio, label)) {
45 		printf("Error: can't obtain GPIO%d for %s", gpio, label);
46 		return -1;
47 	}
48 
49 	gpio_direction_output(gpio, 0);
50 	udelay(10);
51 	gpio_set_value(gpio, 1);
52 	udelay(1000);
53 	return 0;
54 }
55 
56 void cl_usb_hub_deinit(int gpio)
57 {
58 	gpio_free(gpio);
59 }
60 #endif
61