]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/compulab/cm_t43/cm_t43.c
arm: am437x: cm-t43: split board file
[people/ms/u-boot.git] / board / compulab / cm_t43 / cm_t43.c
CommitLineData
5dc5a8ca
NK
1/*
2 * Copyright (C) 2015 Compulab, Ltd.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <i2c.h>
9#include <miiphy.h>
10#include <cpsw.h>
11#include <asm/gpio.h>
12#include <asm/arch/sys_proto.h>
13#include <asm/emif.h>
14#include <power/pmic.h>
15#include <power/tps65218.h>
16#include "board.h"
17
18DECLARE_GLOBAL_DATA_PTR;
19
20static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
21
22/* setup board specific PMIC */
23int power_init_board(void)
24{
25 struct pmic *p;
26
27 power_tps65218_init(I2C_PMIC);
28 p = pmic_get("TPS65218_PMIC");
29 if (p && !pmic_probe(p))
30 puts("PMIC: TPS65218\n");
31
32 return 0;
33}
34
35int board_init(void)
36{
37 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
38 gpmc_init();
39 set_i2c_pin_mux();
40 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
41 i2c_probe(TPS65218_CHIP_PM);
42
43 return 0;
44}
45
46#ifdef CONFIG_DRIVER_TI_CPSW
47
48static void cpsw_control(int enabled)
49{
50 return;
51}
52
53static struct cpsw_slave_data cpsw_slaves[] = {
54 {
55 .slave_reg_ofs = 0x208,
56 .sliver_reg_ofs = 0xd80,
57 .phy_addr = 0,
58 .phy_if = PHY_INTERFACE_MODE_RGMII,
59 },
60 {
61 .slave_reg_ofs = 0x308,
62 .sliver_reg_ofs = 0xdc0,
63 .phy_addr = 1,
64 .phy_if = PHY_INTERFACE_MODE_RGMII,
65 },
66};
67
68static struct cpsw_platform_data cpsw_data = {
69 .mdio_base = CPSW_MDIO_BASE,
70 .cpsw_base = CPSW_BASE,
71 .mdio_div = 0xff,
72 .channels = 8,
73 .cpdma_reg_ofs = 0x800,
74 .slaves = 2,
75 .slave_data = cpsw_slaves,
76 .ale_reg_ofs = 0xd00,
77 .ale_entries = 1024,
78 .host_port_reg_ofs = 0x108,
79 .hw_stats_reg_ofs = 0x900,
80 .bd_ram_ofs = 0x2000,
81 .mac_control = (1 << 5),
82 .control = cpsw_control,
83 .host_port_num = 0,
84 .version = CPSW_CTRL_VERSION_2,
85};
86
87#define GPIO_PHY1_RST 170
88#define GPIO_PHY2_RST 168
89
90int board_phy_config(struct phy_device *phydev)
91{
92 unsigned short val;
93
94 /* introduce tx clock delay */
95 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x5);
96 val = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e);
97 val |= 0x0100;
98 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, val);
99
100 if (phydev->drv->config)
101 return phydev->drv->config(phydev);
102
103 return 0;
104}
105
106static void board_phy_init(void)
107{
108 set_mdio_pin_mux();
109 writel(0x40003, 0x44e10a74); /* Mux pin as clkout2 */
110 writel(0x10006, 0x44df4108); /* Select EXTDEV as clock source */
111 writel(0x4, 0x44df2e60); /* Set EXTDEV as MNbypass */
112
113 /* For revision A */
114 writel(0x2000009, 0x44df2e6c);
115 writel(0x38a, 0x44df2e70);
116
117 mdelay(10);
118
119 gpio_request(GPIO_PHY1_RST, "phy1_rst");
120 gpio_request(GPIO_PHY2_RST, "phy2_rst");
121 gpio_direction_output(GPIO_PHY1_RST, 0);
122 gpio_direction_output(GPIO_PHY2_RST, 0);
123 mdelay(2);
124
125 gpio_set_value(GPIO_PHY1_RST, 1);
126 gpio_set_value(GPIO_PHY2_RST, 1);
127 mdelay(2);
128}
129
130int board_eth_init(bd_t *bis)
131{
132 int rv;
133
134 set_rgmii_pin_mux();
135 writel(RGMII_MODE_ENABLE | RGMII_INT_DELAY, &cdev->miisel);
136 board_phy_init();
137
138 rv = cpsw_register(&cpsw_data);
139 if (rv < 0)
140 printf("Error %d registering CPSW switch\n", rv);
141
142 return rv;
143}
144#endif