blob: 20d221641b6fd4586dc08d7e6bef830632263145 [file] [log] [blame]
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00001/*
2 * Copyright (C) 2012 Altera Corporation <www.altera.com>
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00005 */
6
7#include <common.h>
8#include <asm/arch/reset_manager.h>
9#include <asm/io.h>
10
Marek Vasut40f1d6b2014-11-04 04:25:09 +010011#include <usb.h>
12#include <usb/s3c_udc.h>
13#include <usb_mass_storage.h>
14
Dinh Nguyenf2b845e2014-11-13 11:23:41 -060015#include <micrel.h>
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000016#include <netdev.h>
Dinh Nguyenf2b845e2014-11-13 11:23:41 -060017#include <phy.h>
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000018
19DECLARE_GLOBAL_DATA_PTR;
20
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000021/*
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000022 * Miscellaneous platform dependent initialisations
23 */
24int board_init(void)
25{
Pavel Machek26ea1d92014-09-08 14:08:45 +020026 /* Address of boot parameters for ATAG (if ATAG is used) */
27 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
28
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000029 return 0;
30}
Marek Vasut40f1d6b2014-11-04 04:25:09 +010031
Pavel Machek4c587512014-12-11 18:06:31 +010032/*
33 * PHY configuration
34 */
35#ifdef CONFIG_PHY_MICREL_KSZ9021
Dinh Nguyenf2b845e2014-11-13 11:23:41 -060036int board_phy_config(struct phy_device *phydev)
37{
Pavel Machek4c587512014-12-11 18:06:31 +010038 int ret;
Dinh Nguyenf2b845e2014-11-13 11:23:41 -060039 /*
40 * These skew settings for the KSZ9021 ethernet phy is required for ethernet
41 * to work reliably on most flavors of cyclone5 boards.
42 */
Pavel Machek4c587512014-12-11 18:06:31 +010043 ret = ksz9021_phy_extended_write(phydev,
44 MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW,
45 0x0);
46 if (ret)
47 return ret;
48
49 ret = ksz9021_phy_extended_write(phydev,
50 MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW,
51 0x0);
52 if (ret)
53 return ret;
54
55 ret = ksz9021_phy_extended_write(phydev,
56 MII_KSZ9021_EXT_RGMII_CLOCK_SKEW,
57 0xf0f0);
58 if (ret)
59 return ret;
60
61 if (phydev->drv->config)
62 return phydev->drv->config(phydev);
63
64 return 0;
Dinh Nguyenf2b845e2014-11-13 11:23:41 -060065}
Pavel Machek4c587512014-12-11 18:06:31 +010066#endif
Dinh Nguyenf2b845e2014-11-13 11:23:41 -060067
Marek Vasut40f1d6b2014-11-04 04:25:09 +010068#ifdef CONFIG_USB_GADGET
69struct s3c_plat_otg_data socfpga_otg_data = {
70 .regs_otg = CONFIG_USB_DWC2_REG_ADDR,
71 .usb_gusbcfg = 0x1417,
72};
73
74int board_usb_init(int index, enum usb_init_type init)
75{
76 return s3c_udc_probe(&socfpga_otg_data);
77}
78
79int g_dnl_board_usb_cable_connected(void)
80{
81 return 1;
82}
83#endif