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