Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Igor Grinberg | a937fd1 | 2014-11-03 11:32:18 +0200 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il> |
| 4 | * |
| 5 | * Authors: Igor Grinberg <grinberg@compulab.co.il> |
Igor Grinberg | a937fd1 | 2014-11-03 11:32:18 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | 336d461 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 9 | #include <malloc.h> |
Igor Grinberg | a937fd1 | 2014-11-03 11:32:18 +0200 | [diff] [blame] | 10 | #include <asm/bootm.h> |
Igor Grinberg | 959bc1d | 2014-11-03 11:32:19 +0200 | [diff] [blame] | 11 | #include <asm/gpio.h> |
Simon Glass | 5d98285 | 2017-05-17 08:23:00 -0600 | [diff] [blame] | 12 | #include <asm/setup.h> |
Simon Glass | c05ed00 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 13 | #include <linux/delay.h> |
Igor Grinberg | a937fd1 | 2014-11-03 11:32:18 +0200 | [diff] [blame] | 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 | } |
Igor Grinberg | 959bc1d | 2014-11-03 11:32:19 +0200 | [diff] [blame] | 29 | |
Igor Grinberg | 0b6f358 | 2014-11-03 11:32:22 +0200 | [diff] [blame] | 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 | |
Igor Grinberg | 959bc1d | 2014-11-03 11:32:19 +0200 | [diff] [blame] | 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 |