Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Altera Corporation <www.altera.com> |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/arch/reset_manager.h> |
| 9 | #include <asm/io.h> |
| 10 | |
Marek Vasut | 40f1d6b | 2014-11-04 04:25:09 +0100 | [diff] [blame] | 11 | #include <usb.h> |
| 12 | #include <usb/s3c_udc.h> |
| 13 | #include <usb_mass_storage.h> |
| 14 | |
Dinh Nguyen | f2b845e | 2014-11-13 11:23:41 -0600 | [diff] [blame] | 15 | #include <micrel.h> |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 16 | #include <netdev.h> |
Dinh Nguyen | f2b845e | 2014-11-13 11:23:41 -0600 | [diff] [blame] | 17 | #include <phy.h> |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Dinh Nguyen | 571c9e0 | 2015-04-15 16:44:31 -0500 | [diff] [blame] | 21 | void s_init(void) {} |
| 22 | |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 23 | /* |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 24 | * Miscellaneous platform dependent initialisations |
| 25 | */ |
| 26 | int board_init(void) |
| 27 | { |
Pavel Machek | 26ea1d9 | 2014-09-08 14:08:45 +0200 | [diff] [blame] | 28 | /* Address of boot parameters for ATAG (if ATAG is used) */ |
| 29 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
| 30 | |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 31 | return 0; |
| 32 | } |
Marek Vasut | 40f1d6b | 2014-11-04 04:25:09 +0100 | [diff] [blame] | 33 | |
Pavel Machek | 4c58751 | 2014-12-11 18:06:31 +0100 | [diff] [blame] | 34 | /* |
| 35 | * PHY configuration |
| 36 | */ |
| 37 | #ifdef CONFIG_PHY_MICREL_KSZ9021 |
Dinh Nguyen | f2b845e | 2014-11-13 11:23:41 -0600 | [diff] [blame] | 38 | int board_phy_config(struct phy_device *phydev) |
| 39 | { |
Pavel Machek | 4c58751 | 2014-12-11 18:06:31 +0100 | [diff] [blame] | 40 | int ret; |
Dinh Nguyen | f2b845e | 2014-11-13 11:23:41 -0600 | [diff] [blame] | 41 | /* |
| 42 | * These skew settings for the KSZ9021 ethernet phy is required for ethernet |
| 43 | * to work reliably on most flavors of cyclone5 boards. |
| 44 | */ |
Pavel Machek | 4c58751 | 2014-12-11 18:06:31 +0100 | [diff] [blame] | 45 | ret = ksz9021_phy_extended_write(phydev, |
| 46 | MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW, |
| 47 | 0x0); |
| 48 | if (ret) |
| 49 | return ret; |
| 50 | |
| 51 | ret = ksz9021_phy_extended_write(phydev, |
| 52 | MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW, |
| 53 | 0x0); |
| 54 | if (ret) |
| 55 | return ret; |
| 56 | |
| 57 | ret = ksz9021_phy_extended_write(phydev, |
| 58 | MII_KSZ9021_EXT_RGMII_CLOCK_SKEW, |
| 59 | 0xf0f0); |
| 60 | if (ret) |
| 61 | return ret; |
| 62 | |
| 63 | if (phydev->drv->config) |
| 64 | return phydev->drv->config(phydev); |
| 65 | |
| 66 | return 0; |
Dinh Nguyen | f2b845e | 2014-11-13 11:23:41 -0600 | [diff] [blame] | 67 | } |
Pavel Machek | 4c58751 | 2014-12-11 18:06:31 +0100 | [diff] [blame] | 68 | #endif |
Dinh Nguyen | f2b845e | 2014-11-13 11:23:41 -0600 | [diff] [blame] | 69 | |
Marek Vasut | 40f1d6b | 2014-11-04 04:25:09 +0100 | [diff] [blame] | 70 | #ifdef CONFIG_USB_GADGET |
| 71 | struct s3c_plat_otg_data socfpga_otg_data = { |
| 72 | .regs_otg = CONFIG_USB_DWC2_REG_ADDR, |
| 73 | .usb_gusbcfg = 0x1417, |
| 74 | }; |
| 75 | |
| 76 | int board_usb_init(int index, enum usb_init_type init) |
| 77 | { |
| 78 | return s3c_udc_probe(&socfpga_otg_data); |
| 79 | } |
| 80 | |
| 81 | int g_dnl_board_usb_cable_connected(void) |
| 82 | { |
| 83 | return 1; |
| 84 | } |
| 85 | #endif |