2 * Copyright (C) 2015 Compulab, Ltd.
4 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/arch/sys_proto.h>
14 #include <power/pmic.h>
15 #include <power/tps65218.h>
18 DECLARE_GLOBAL_DATA_PTR
;
20 static struct ctrl_dev
*cdev
= (struct ctrl_dev
*)CTRL_DEVICE_BASE
;
22 /* setup board specific PMIC */
23 int power_init_board(void)
28 power_tps65218_init(I2C_PMIC
);
29 p
= pmic_get("TPS65218_PMIC");
30 if (p
&& !pmic_probe(p
)) {
31 puts("PMIC: TPS65218\n");
32 /* We don't care if fseal is locked, but we do need it set */
33 tps65218_lock_fseal();
34 tps65218_reg_read(TPS65218_STATUS
, &tps_status
);
35 if (!(tps_status
& TPS65218_FSEAL
))
36 printf("WARNING: RTC not backed by battery!\n");
44 gd
->bd
->bi_boot_params
= CONFIG_SYS_SDRAM_BASE
+ 0x100;
47 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED
, CONFIG_SYS_OMAP24_I2C_SLAVE
);
48 i2c_probe(TPS65218_CHIP_PM
);
53 #ifdef CONFIG_DRIVER_TI_CPSW
55 static void cpsw_control(int enabled
)
60 static struct cpsw_slave_data cpsw_slaves
[] = {
62 .slave_reg_ofs
= 0x208,
63 .sliver_reg_ofs
= 0xd80,
65 .phy_if
= PHY_INTERFACE_MODE_RGMII
,
68 .slave_reg_ofs
= 0x308,
69 .sliver_reg_ofs
= 0xdc0,
71 .phy_if
= PHY_INTERFACE_MODE_RGMII
,
75 static struct cpsw_platform_data cpsw_data
= {
76 .mdio_base
= CPSW_MDIO_BASE
,
77 .cpsw_base
= CPSW_BASE
,
80 .cpdma_reg_ofs
= 0x800,
82 .slave_data
= cpsw_slaves
,
85 .host_port_reg_ofs
= 0x108,
86 .hw_stats_reg_ofs
= 0x900,
88 .mac_control
= (1 << 5),
89 .control
= cpsw_control
,
91 .version
= CPSW_CTRL_VERSION_2
,
94 #define GPIO_PHY1_RST 170
95 #define GPIO_PHY2_RST 168
97 int board_phy_config(struct phy_device
*phydev
)
101 /* introduce tx clock delay */
102 phy_write(phydev
, MDIO_DEVAD_NONE
, 0x1d, 0x5);
103 val
= phy_read(phydev
, MDIO_DEVAD_NONE
, 0x1e);
105 phy_write(phydev
, MDIO_DEVAD_NONE
, 0x1e, val
);
107 if (phydev
->drv
->config
)
108 return phydev
->drv
->config(phydev
);
113 static void board_phy_init(void)
116 writel(0x40003, 0x44e10a74); /* Mux pin as clkout2 */
117 writel(0x10006, 0x44df4108); /* Select EXTDEV as clock source */
118 writel(0x4, 0x44df2e60); /* Set EXTDEV as MNbypass */
121 writel(0x2000009, 0x44df2e6c);
122 writel(0x38a, 0x44df2e70);
126 gpio_request(GPIO_PHY1_RST
, "phy1_rst");
127 gpio_request(GPIO_PHY2_RST
, "phy2_rst");
128 gpio_direction_output(GPIO_PHY1_RST
, 0);
129 gpio_direction_output(GPIO_PHY2_RST
, 0);
132 gpio_set_value(GPIO_PHY1_RST
, 1);
133 gpio_set_value(GPIO_PHY2_RST
, 1);
137 int board_eth_init(bd_t
*bis
)
142 writel(RGMII_MODE_ENABLE
| RGMII_INT_DELAY
, &cdev
->miisel
);
145 rv
= cpsw_register(&cpsw_data
);
147 printf("Error %d registering CPSW switch\n", rv
);