blob: 528c97df19a4cdf1c82adef340cf7394fdd5ad04 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Igor Grinberga937fd12014-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 Grinberga937fd12014-11-03 11:32:18 +02006 */
7
8#include <common.h>
Simon Glass336d4612020-02-03 07:36:16 -07009#include <malloc.h>
Igor Grinberga937fd12014-11-03 11:32:18 +020010#include <asm/bootm.h>
Igor Grinberg959bc1d2014-11-03 11:32:19 +020011#include <asm/gpio.h>
Simon Glass5d982852017-05-17 08:23:00 -060012#include <asm/setup.h>
Simon Glassc05ed002020-05-10 11:40:11 -060013#include <linux/delay.h>
Igor Grinberga937fd12014-11-03 11:32:18 +020014
15#include "common.h"
16#include "eeprom.h"
17
18void 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}
Igor Grinberg959bc1d2014-11-03 11:32:19 +020029
Igor Grinberg0b6f3582014-11-03 11:32:22 +020030#ifdef CONFIG_SERIAL_TAG
31void __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
Igor Grinberg959bc1d2014-11-03 11:32:19 +020042#ifdef CONFIG_CMD_USB
43int 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
57void cl_usb_hub_deinit(int gpio)
58{
59 gpio_free(gpio);
60}
61#endif