blob: 6ffebe6bdb413a6d863556907b9e682264e612ea [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Igor Grinberg3c5dc282014-11-03 11:32:18 +02002/*
3 * (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il>
4 *
5 * Authors: Igor Grinberg <grinberg@compulab.co.il>
Igor Grinberg3c5dc282014-11-03 11:32:18 +02006 */
7
Simon Glass9bc15642020-02-03 07:36:16 -07008#include <malloc.h>
Igor Grinberg3c5dc282014-11-03 11:32:18 +02009#include <asm/bootm.h>
Igor Grinberg9c687fd2014-11-03 11:32:19 +020010#include <asm/gpio.h>
Simon Glassd9a766f2017-05-17 08:23:00 -060011#include <asm/setup.h>
Simon Glassdbd79542020-05-10 11:40:11 -060012#include <linux/delay.h>
Igor Grinberg3c5dc282014-11-03 11:32:18 +020013
14#include "common.h"
15#include "eeprom.h"
16
17void 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}
Igor Grinberg9c687fd2014-11-03 11:32:19 +020028
Igor Grinbergb9e27fa2014-11-03 11:32:22 +020029#ifdef CONFIG_SERIAL_TAG
30void __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
Igor Grinberg9c687fd2014-11-03 11:32:19 +020041#ifdef CONFIG_CMD_USB
42int 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
56void cl_usb_hub_deinit(int gpio)
57{
58 gpio_free(gpio);
59}
60#endif