1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2015 Compulab, Ltd.
11 #include <asm/arch/sys_proto.h>
13 #include <power/pmic.h>
14 #include <power/tps65218.h>
17 #include <asm/omap_common.h>
19 DECLARE_GLOBAL_DATA_PTR;
21 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
23 /* setup board specific PMIC */
24 int power_init_board(void)
29 power_tps65218_init(I2C_PMIC);
30 p = pmic_get("TPS65218_PMIC");
31 if (p && !pmic_probe(p)) {
32 puts("PMIC: TPS65218\n");
33 /* We don't care if fseal is locked, but we do need it set */
34 tps65218_lock_fseal();
35 tps65218_reg_read(TPS65218_STATUS, &tps_status);
36 if (!(tps_status & TPS65218_FSEAL))
37 printf("WARNING: RTC not backed by battery!\n");
45 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
48 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
49 i2c_probe(TPS65218_CHIP_PM);
54 int board_usb_init(int index, enum usb_init_type init)
56 enable_usb_clocks(index);
60 int board_usb_cleanup(int index, enum usb_init_type init)
62 disable_usb_clocks(index);
66 #ifdef CONFIG_DRIVER_TI_CPSW
68 static void cpsw_control(int enabled)
73 static struct cpsw_slave_data cpsw_slaves[] = {
75 .slave_reg_ofs = 0x208,
76 .sliver_reg_ofs = 0xd80,
78 .phy_if = PHY_INTERFACE_MODE_RGMII,
81 .slave_reg_ofs = 0x308,
82 .sliver_reg_ofs = 0xdc0,
84 .phy_if = PHY_INTERFACE_MODE_RGMII,
88 static struct cpsw_platform_data cpsw_data = {
89 .mdio_base = CPSW_MDIO_BASE,
90 .cpsw_base = CPSW_BASE,
93 .cpdma_reg_ofs = 0x800,
95 .slave_data = cpsw_slaves,
98 .host_port_reg_ofs = 0x108,
99 .hw_stats_reg_ofs = 0x900,
100 .bd_ram_ofs = 0x2000,
101 .mac_control = (1 << 5),
102 .control = cpsw_control,
104 .version = CPSW_CTRL_VERSION_2,
107 #define GPIO_PHY1_RST 170
108 #define GPIO_PHY2_RST 168
110 int board_phy_config(struct phy_device *phydev)
114 /* introduce tx clock delay */
115 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x5);
116 val = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e);
118 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, val);
120 if (phydev->drv->config)
121 return phydev->drv->config(phydev);
126 static void board_phy_init(void)
129 writel(0x40003, 0x44e10a74); /* Mux pin as clkout2 */
130 writel(0x10006, 0x44df4108); /* Select EXTDEV as clock source */
131 writel(0x4, 0x44df2e60); /* Set EXTDEV as MNbypass */
134 writel(0x2000009, 0x44df2e6c);
135 writel(0x38a, 0x44df2e70);
139 gpio_request(GPIO_PHY1_RST, "phy1_rst");
140 gpio_request(GPIO_PHY2_RST, "phy2_rst");
141 gpio_direction_output(GPIO_PHY1_RST, 0);
142 gpio_direction_output(GPIO_PHY2_RST, 0);
145 gpio_set_value(GPIO_PHY1_RST, 1);
146 gpio_set_value(GPIO_PHY2_RST, 1);
150 int board_eth_init(bd_t *bis)
155 writel(RGMII_MODE_ENABLE | RGMII_INT_DELAY, &cdev->miisel);
158 rv = cpsw_register(&cpsw_data);
160 printf("Error %d registering CPSW switch\n", rv);