xref: /rk3399_rockchip-uboot/board/freescale/p1022ds/p1022ds.c (revision 0e00a84cdedf7a1949486746225b35984b351eca)
1c59e1b4dSTimur Tabi /*
23d7506faSramneek mehresh  * Copyright 2010-2012 Freescale Semiconductor, Inc.
3c59e1b4dSTimur Tabi  * Authors: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
4c59e1b4dSTimur Tabi  *          Timur Tabi <timur@freescale.com>
5c59e1b4dSTimur Tabi  *
61a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
7c59e1b4dSTimur Tabi  */
8c59e1b4dSTimur Tabi 
9c59e1b4dSTimur Tabi #include <common.h>
10c59e1b4dSTimur Tabi #include <command.h>
11c59e1b4dSTimur Tabi #include <pci.h>
12c59e1b4dSTimur Tabi #include <asm/processor.h>
13c59e1b4dSTimur Tabi #include <asm/mmu.h>
14c59e1b4dSTimur Tabi #include <asm/cache.h>
15c59e1b4dSTimur Tabi #include <asm/immap_85xx.h>
16c59e1b4dSTimur Tabi #include <asm/fsl_pci.h>
175614e71bSYork Sun #include <fsl_ddr_sdram.h>
18c59e1b4dSTimur Tabi #include <asm/fsl_serdes.h>
19c59e1b4dSTimur Tabi #include <asm/io.h>
20*0e00a84cSMasahiro Yamada #include <linux/libfdt.h>
21c59e1b4dSTimur Tabi #include <fdt_support.h>
22063c1263SAndy Fleming #include <fsl_mdio.h>
23c59e1b4dSTimur Tabi #include <tsec.h>
24c59e1b4dSTimur Tabi #include <asm/fsl_law.h>
25c59e1b4dSTimur Tabi #include <netdev.h>
26c59e1b4dSTimur Tabi #include <i2c.h>
27a2d12f88STimur Tabi #include <hwconfig.h>
28c59e1b4dSTimur Tabi 
29c59e1b4dSTimur Tabi #include "../common/ngpixis.h"
30c59e1b4dSTimur Tabi 
31c59e1b4dSTimur Tabi DECLARE_GLOBAL_DATA_PTR;
32c59e1b4dSTimur Tabi 
board_early_init_f(void)33c59e1b4dSTimur Tabi int board_early_init_f(void)
34c59e1b4dSTimur Tabi {
35c59e1b4dSTimur Tabi 	ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
36c59e1b4dSTimur Tabi 
37c59e1b4dSTimur Tabi 	/* Set pmuxcr to allow both i2c1 and i2c2 */
38c59e1b4dSTimur Tabi 	setbits_be32(&gur->pmuxcr, 0x1000);
39af253608SMatthew McClintock #ifdef CONFIG_SYS_RAMBOOT
40af253608SMatthew McClintock 	setbits_be32(&gur->pmuxcr,
41af253608SMatthew McClintock 		in_be32(&gur->pmuxcr) | MPC85xx_PMUXCR_SD_DATA);
42af253608SMatthew McClintock #endif
43c59e1b4dSTimur Tabi 
44c59e1b4dSTimur Tabi 	/* Read back the register to synchronize the write. */
45c59e1b4dSTimur Tabi 	in_be32(&gur->pmuxcr);
46c59e1b4dSTimur Tabi 
47c59e1b4dSTimur Tabi 	/* Set the pin muxing to enable ETSEC2. */
48c59e1b4dSTimur Tabi 	clrbits_be32(&gur->pmuxcr2, 0x001F8000);
49c59e1b4dSTimur Tabi 
509b6e9d1cSJiang Yutang 	/* Enable the SPI */
519b6e9d1cSJiang Yutang 	clrsetbits_8(&pixis->brdcfg0, PIXIS_ELBC_SPI_MASK, PIXIS_SPI);
529b6e9d1cSJiang Yutang 
53c59e1b4dSTimur Tabi 	return 0;
54c59e1b4dSTimur Tabi }
55c59e1b4dSTimur Tabi 
checkboard(void)56c59e1b4dSTimur Tabi int checkboard(void)
57c59e1b4dSTimur Tabi {
58c59e1b4dSTimur Tabi 	u8 sw;
59c59e1b4dSTimur Tabi 
605d065c3eSTimur Tabi 	printf("Board: P1022DS Sys ID: 0x%02x, "
615d065c3eSTimur Tabi 	       "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
62c59e1b4dSTimur Tabi 		in_8(&pixis->id), in_8(&pixis->arch), in_8(&pixis->scver));
63c59e1b4dSTimur Tabi 
64c59e1b4dSTimur Tabi 	sw = in_8(&PIXIS_SW(PIXIS_LBMAP_SWITCH));
65c59e1b4dSTimur Tabi 
66c59e1b4dSTimur Tabi 	switch ((sw & PIXIS_LBMAP_MASK) >> 6) {
67c59e1b4dSTimur Tabi 	case 0:
68c59e1b4dSTimur Tabi 		printf ("vBank: %u\n", ((sw & 0x30) >> 4));
69c59e1b4dSTimur Tabi 		break;
70c59e1b4dSTimur Tabi 	case 1:
71c59e1b4dSTimur Tabi 		printf ("NAND\n");
72c59e1b4dSTimur Tabi 		break;
73c59e1b4dSTimur Tabi 	case 2:
74c59e1b4dSTimur Tabi 	case 3:
75c59e1b4dSTimur Tabi 		puts ("Promjet\n");
76c59e1b4dSTimur Tabi 		break;
77c59e1b4dSTimur Tabi 	}
78c59e1b4dSTimur Tabi 
79c59e1b4dSTimur Tabi 	return 0;
80c59e1b4dSTimur Tabi }
81c59e1b4dSTimur Tabi 
82c59e1b4dSTimur Tabi #define CONFIG_TFP410_I2C_ADDR	0x38
83c59e1b4dSTimur Tabi 
84a2d12f88STimur Tabi /* Masks for the SSI_TDM and AUDCLK bits of the ngPIXIS BRDCFG1 register. */
85a2d12f88STimur Tabi #define CONFIG_PIXIS_BRDCFG1_SSI_TDM_MASK	0x0c
86a2d12f88STimur Tabi #define CONFIG_PIXIS_BRDCFG1_AUDCLK_MASK	0x03
87a2d12f88STimur Tabi 
88a2d12f88STimur Tabi /* Route the I2C1 pins to the SSI port instead. */
89a2d12f88STimur Tabi #define CONFIG_PIXIS_BRDCFG1_SSI_TDM_SSI	0x08
90a2d12f88STimur Tabi 
91a2d12f88STimur Tabi /* Choose the 12.288Mhz codec reference clock */
92a2d12f88STimur Tabi #define CONFIG_PIXIS_BRDCFG1_AUDCLK_12		0x02
93a2d12f88STimur Tabi 
94a2d12f88STimur Tabi /* Choose the 11.2896Mhz codec reference clock */
95a2d12f88STimur Tabi #define CONFIG_PIXIS_BRDCFG1_AUDCLK_11		0x01
96a2d12f88STimur Tabi 
97b93f81a4SJiang Yutang /* Connect to USB2 */
98b93f81a4SJiang Yutang #define CONFIG_PIXIS_BRDCFG0_USB2		0x10
99b93f81a4SJiang Yutang /* Connect to TFM bus */
100b93f81a4SJiang Yutang #define CONFIG_PIXIS_BRDCFG1_TDM		0x0c
101b93f81a4SJiang Yutang /* Connect to SPI */
102b93f81a4SJiang Yutang #define CONFIG_PIXIS_BRDCFG0_SPI		0x80
103b93f81a4SJiang Yutang 
misc_init_r(void)104c59e1b4dSTimur Tabi int misc_init_r(void)
105c59e1b4dSTimur Tabi {
106c59e1b4dSTimur Tabi 	u8 temp;
107a2d12f88STimur Tabi 	const char *audclk;
108a2d12f88STimur Tabi 	size_t arglen;
109b93f81a4SJiang Yutang 	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
110c59e1b4dSTimur Tabi 
111a2d12f88STimur Tabi 	/* For DVI, enable the TFP410 Encoder. */
112c59e1b4dSTimur Tabi 
113c59e1b4dSTimur Tabi 	temp = 0xBF;
114c59e1b4dSTimur Tabi 	if (i2c_write(CONFIG_TFP410_I2C_ADDR, 0x08, 1, &temp, sizeof(temp)) < 0)
115c59e1b4dSTimur Tabi 		return -1;
116c59e1b4dSTimur Tabi 	if (i2c_read(CONFIG_TFP410_I2C_ADDR, 0x08, 1, &temp, sizeof(temp)) < 0)
117c59e1b4dSTimur Tabi 		return -1;
118c59e1b4dSTimur Tabi 	debug("DVI Encoder Read: 0x%02x\n", temp);
119c59e1b4dSTimur Tabi 
120c59e1b4dSTimur Tabi 	temp = 0x10;
121c59e1b4dSTimur Tabi 	if (i2c_write(CONFIG_TFP410_I2C_ADDR, 0x0A, 1, &temp, sizeof(temp)) < 0)
122c59e1b4dSTimur Tabi 		return -1;
123c59e1b4dSTimur Tabi 	if (i2c_read(CONFIG_TFP410_I2C_ADDR, 0x0A, 1, &temp, sizeof(temp)) < 0)
124c59e1b4dSTimur Tabi 		return -1;
125c59e1b4dSTimur Tabi 	debug("DVI Encoder Read: 0x%02x\n",temp);
126c59e1b4dSTimur Tabi 
127b93f81a4SJiang Yutang 	/* Enable the USB2 in PMUXCR2 and FGPA */
128b93f81a4SJiang Yutang 	if (hwconfig("usb2")) {
129b93f81a4SJiang Yutang 		clrsetbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_ETSECUSB_MASK,
130b93f81a4SJiang Yutang 			MPC85xx_PMUXCR2_USB);
131b93f81a4SJiang Yutang 		setbits_8(&pixis->brdcfg0, CONFIG_PIXIS_BRDCFG0_USB2);
132b93f81a4SJiang Yutang 	}
133b93f81a4SJiang Yutang 
134b93f81a4SJiang Yutang 	/* tdm and audio can not enable simultaneous*/
135b93f81a4SJiang Yutang 	if (hwconfig("tdm") && hwconfig("audclk")){
136b93f81a4SJiang Yutang 		printf("WARNING: TDM and AUDIO can not be enabled simultaneous !\n");
137b93f81a4SJiang Yutang 		return -1;
138b93f81a4SJiang Yutang 	}
139b93f81a4SJiang Yutang 
140b93f81a4SJiang Yutang 	/* Enable the TDM in PMUXCR and FGPA */
141b93f81a4SJiang Yutang 	if (hwconfig("tdm")) {
142b93f81a4SJiang Yutang 		clrsetbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_TDM_MASK,
143b93f81a4SJiang Yutang 			MPC85xx_PMUXCR_TDM);
144b93f81a4SJiang Yutang 		setbits_8(&pixis->brdcfg1, CONFIG_PIXIS_BRDCFG1_TDM);
145b93f81a4SJiang Yutang 		/* TDM need some configration option by SPI */
146b93f81a4SJiang Yutang 		clrsetbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_SPI_MASK,
147b93f81a4SJiang Yutang 			MPC85xx_PMUXCR_SPI);
148b93f81a4SJiang Yutang 		setbits_8(&pixis->brdcfg0, CONFIG_PIXIS_BRDCFG0_SPI);
149b93f81a4SJiang Yutang 	}
150b93f81a4SJiang Yutang 
151a2d12f88STimur Tabi 	/*
152a2d12f88STimur Tabi 	 * Enable the reference clock for the WM8776 codec, and route the MUX
153a2d12f88STimur Tabi 	 * pins for SSI. The default is the 12.288 MHz clock
154a2d12f88STimur Tabi 	 */
155a2d12f88STimur Tabi 
156b93f81a4SJiang Yutang 	if (hwconfig("audclk")) {
157a2d12f88STimur Tabi 		temp = in_8(&pixis->brdcfg1) & ~(CONFIG_PIXIS_BRDCFG1_SSI_TDM_MASK |
158a2d12f88STimur Tabi 			CONFIG_PIXIS_BRDCFG1_AUDCLK_MASK);
159a2d12f88STimur Tabi 		temp |= CONFIG_PIXIS_BRDCFG1_SSI_TDM_SSI;
160a2d12f88STimur Tabi 
161a2d12f88STimur Tabi 		audclk = hwconfig_arg("audclk", &arglen);
162a2d12f88STimur Tabi 		/* Check the first two chars only */
163a2d12f88STimur Tabi 		if (audclk && (strncmp(audclk, "11", 2) == 0))
164a2d12f88STimur Tabi 			temp |= CONFIG_PIXIS_BRDCFG1_AUDCLK_11;
165a2d12f88STimur Tabi 		else
166a2d12f88STimur Tabi 			temp |= CONFIG_PIXIS_BRDCFG1_AUDCLK_12;
167b93f81a4SJiang Yutang 		setbits_8(&pixis->brdcfg1, temp);
168b93f81a4SJiang Yutang 	}
169a2d12f88STimur Tabi 
170c59e1b4dSTimur Tabi 	return 0;
171c59e1b4dSTimur Tabi }
172c59e1b4dSTimur Tabi 
1739f43d799SKumar Gala /*
1749f43d799SKumar Gala  * A list of PCI and SATA slots
1759f43d799SKumar Gala  */
1769f43d799SKumar Gala enum slot_id {
1779f43d799SKumar Gala 	SLOT_PCIE1 = 1,
1789f43d799SKumar Gala 	SLOT_PCIE2,
1799f43d799SKumar Gala 	SLOT_PCIE3,
1809f43d799SKumar Gala 	SLOT_PCIE4,
1819f43d799SKumar Gala 	SLOT_PCIE5,
1829f43d799SKumar Gala 	SLOT_SATA1,
1839f43d799SKumar Gala 	SLOT_SATA2
1849f43d799SKumar Gala };
1859f43d799SKumar Gala 
1869f43d799SKumar Gala /*
1879f43d799SKumar Gala  * This array maps the slot identifiers to their names on the P1022DS board.
1889f43d799SKumar Gala  */
1899f43d799SKumar Gala static const char *slot_names[] = {
1909f43d799SKumar Gala 	[SLOT_PCIE1] = "Slot 1",
1919f43d799SKumar Gala 	[SLOT_PCIE2] = "Slot 2",
1929f43d799SKumar Gala 	[SLOT_PCIE3] = "Slot 3",
1939f43d799SKumar Gala 	[SLOT_PCIE4] = "Slot 4",
1949f43d799SKumar Gala 	[SLOT_PCIE5] = "Mini-PCIe",
1959f43d799SKumar Gala 	[SLOT_SATA1] = "SATA 1",
1969f43d799SKumar Gala 	[SLOT_SATA2] = "SATA 2",
1979f43d799SKumar Gala };
1989f43d799SKumar Gala 
1999f43d799SKumar Gala /*
2009f43d799SKumar Gala  * This array maps a given SERDES configuration and SERDES device to the PCI or
2019f43d799SKumar Gala  * SATA slot that it connects to.  This mapping is hard-coded in the FPGA.
2029f43d799SKumar Gala  */
2039f43d799SKumar Gala static u8 serdes_dev_slot[][SATA2 + 1] = {
2049f43d799SKumar Gala 	[0x01] = { [PCIE3] = SLOT_PCIE4, [PCIE2] = SLOT_PCIE5 },
2059f43d799SKumar Gala 	[0x02] = { [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
2069f43d799SKumar Gala 	[0x09] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE4,
2079f43d799SKumar Gala 		   [PCIE2] = SLOT_PCIE5 },
2089f43d799SKumar Gala 	[0x16] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE2,
2099f43d799SKumar Gala 		   [PCIE2] = SLOT_PCIE3,
2109f43d799SKumar Gala 		   [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
2119f43d799SKumar Gala 	[0x17] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE2,
2129f43d799SKumar Gala 		   [PCIE2] = SLOT_PCIE3 },
2139f43d799SKumar Gala 	[0x1a] = { [PCIE1] = SLOT_PCIE1, [PCIE2] = SLOT_PCIE3,
2149f43d799SKumar Gala 		   [PCIE2] = SLOT_PCIE3,
2159f43d799SKumar Gala 		   [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
2169f43d799SKumar Gala 	[0x1c] = { [PCIE1] = SLOT_PCIE1,
2179f43d799SKumar Gala 		   [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
2189f43d799SKumar Gala 	[0x1e] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE3 },
2199f43d799SKumar Gala 	[0x1f] = { [PCIE1] = SLOT_PCIE1 },
2209f43d799SKumar Gala };
2219f43d799SKumar Gala 
2229f43d799SKumar Gala 
2239f43d799SKumar Gala /*
2249f43d799SKumar Gala  * Returns the name of the slot to which the PCIe or SATA controller is
2259f43d799SKumar Gala  * connected
2269f43d799SKumar Gala  */
board_serdes_name(enum srds_prtcl device)227a4aafcc9SKumar Gala const char *board_serdes_name(enum srds_prtcl device)
2289f43d799SKumar Gala {
2299f43d799SKumar Gala 	ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
2309f43d799SKumar Gala 	u32 pordevsr = in_be32(&gur->pordevsr);
2319f43d799SKumar Gala 	unsigned int srds_cfg = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >>
2329f43d799SKumar Gala 				MPC85xx_PORDEVSR_IO_SEL_SHIFT;
2339f43d799SKumar Gala 	enum slot_id slot = serdes_dev_slot[srds_cfg][device];
2349f43d799SKumar Gala 	const char *name = slot_names[slot];
2359f43d799SKumar Gala 
2369f43d799SKumar Gala 	if (name)
2379f43d799SKumar Gala 		return name;
2389f43d799SKumar Gala 	else
2399f43d799SKumar Gala 		return "Nothing";
2409f43d799SKumar Gala }
2419f43d799SKumar Gala 
242c59e1b4dSTimur Tabi #ifdef CONFIG_PCI
pci_init_board(void)243c59e1b4dSTimur Tabi void pci_init_board(void)
244c59e1b4dSTimur Tabi {
245a4aafcc9SKumar Gala 	fsl_pcie_init_board(0);
246c59e1b4dSTimur Tabi }
247c59e1b4dSTimur Tabi #endif
248c59e1b4dSTimur Tabi 
board_early_init_r(void)249c59e1b4dSTimur Tabi int board_early_init_r(void)
250c59e1b4dSTimur Tabi {
251c59e1b4dSTimur Tabi 	const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
2529d045682SYork Sun 	int flash_esel = find_tlb_idx((void *)flashbase, 1);
253c59e1b4dSTimur Tabi 
254c59e1b4dSTimur Tabi 	/*
255c59e1b4dSTimur Tabi 	 * Remap Boot flash + PROMJET region to caching-inhibited
256c59e1b4dSTimur Tabi 	 * so that flash can be erased properly.
257c59e1b4dSTimur Tabi 	 */
258c59e1b4dSTimur Tabi 
259c59e1b4dSTimur Tabi 	/* Flush d-cache and invalidate i-cache of any FLASH data */
260c59e1b4dSTimur Tabi 	flush_dcache();
261c59e1b4dSTimur Tabi 	invalidate_icache();
262c59e1b4dSTimur Tabi 
2639d045682SYork Sun 	if (flash_esel == -1) {
2649d045682SYork Sun 		/* very unlikely unless something is messed up */
2659d045682SYork Sun 		puts("Error: Could not find TLB for FLASH BASE\n");
2669d045682SYork Sun 		flash_esel = 2;	/* give our best effort to continue */
2679d045682SYork Sun 	} else {
268c59e1b4dSTimur Tabi 		/* invalidate existing TLB entry for flash + promjet */
269c59e1b4dSTimur Tabi 		disable_tlb(flash_esel);
2709d045682SYork Sun 	}
271c59e1b4dSTimur Tabi 
272c59e1b4dSTimur Tabi 	set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
273c59e1b4dSTimur Tabi 			MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
274c59e1b4dSTimur Tabi 			0, flash_esel, BOOKE_PAGESZ_256M, 1);
275c59e1b4dSTimur Tabi 
276c59e1b4dSTimur Tabi 	return 0;
277c59e1b4dSTimur Tabi }
278c59e1b4dSTimur Tabi 
279c59e1b4dSTimur Tabi /*
280c59e1b4dSTimur Tabi  * Initialize on-board and/or PCI Ethernet devices
281c59e1b4dSTimur Tabi  *
282c59e1b4dSTimur Tabi  * Returns:
283c59e1b4dSTimur Tabi  *      <0, error
284c59e1b4dSTimur Tabi  *       0, no ethernet devices found
285c59e1b4dSTimur Tabi  *      >0, number of ethernet devices initialized
286c59e1b4dSTimur Tabi  */
board_eth_init(bd_t * bis)287c59e1b4dSTimur Tabi int board_eth_init(bd_t *bis)
288c59e1b4dSTimur Tabi {
289063c1263SAndy Fleming 	struct fsl_pq_mdio_info mdio_info;
290c59e1b4dSTimur Tabi 	struct tsec_info_struct tsec_info[2];
291c59e1b4dSTimur Tabi 	unsigned int num = 0;
292c59e1b4dSTimur Tabi 
293c59e1b4dSTimur Tabi #ifdef CONFIG_TSEC1
294c59e1b4dSTimur Tabi 	SET_STD_TSEC_INFO(tsec_info[num], 1);
295c59e1b4dSTimur Tabi 	num++;
296c59e1b4dSTimur Tabi #endif
297c59e1b4dSTimur Tabi #ifdef CONFIG_TSEC2
298c59e1b4dSTimur Tabi 	SET_STD_TSEC_INFO(tsec_info[num], 2);
299c59e1b4dSTimur Tabi 	num++;
300c59e1b4dSTimur Tabi #endif
301c59e1b4dSTimur Tabi 
302063c1263SAndy Fleming 	mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
303063c1263SAndy Fleming 	mdio_info.name = DEFAULT_MII_NAME;
304063c1263SAndy Fleming 	fsl_pq_mdio_init(bis, &mdio_info);
305063c1263SAndy Fleming 
306c59e1b4dSTimur Tabi 	return tsec_eth_init(bis, tsec_info, num) + pci_eth_init(bis);
307c59e1b4dSTimur Tabi }
308c59e1b4dSTimur Tabi 
309c59e1b4dSTimur Tabi #ifdef CONFIG_OF_BOARD_SETUP
310a2d12f88STimur Tabi /**
311a2d12f88STimur Tabi  * ft_codec_setup - fix up the clock-frequency property of the codec node
312a2d12f88STimur Tabi  *
313a2d12f88STimur Tabi  * Update the clock-frequency property based on the value of the 'audclk'
31429b83d98STimur Tabi  * hwconfig option.  If audclk is not specified, then don't write anything
31529b83d98STimur Tabi  * to the device tree, because it means that the codec clock is disabled.
316a2d12f88STimur Tabi  */
ft_codec_setup(void * blob,const char * compatible)317a2d12f88STimur Tabi static void ft_codec_setup(void *blob, const char *compatible)
318a2d12f88STimur Tabi {
319a2d12f88STimur Tabi 	const char *audclk;
320a2d12f88STimur Tabi 	size_t arglen;
321a2d12f88STimur Tabi 	u32 freq;
322a2d12f88STimur Tabi 
323a2d12f88STimur Tabi 	audclk = hwconfig_arg("audclk", &arglen);
32429b83d98STimur Tabi 	if (audclk) {
32529b83d98STimur Tabi 		if (strncmp(audclk, "11", 2) == 0)
326a2d12f88STimur Tabi 			freq = 11289600;
327a2d12f88STimur Tabi 		else
328a2d12f88STimur Tabi 			freq = 12288000;
329a2d12f88STimur Tabi 
33029b83d98STimur Tabi 		do_fixup_by_compat_u32(blob, compatible, "clock-frequency",
33129b83d98STimur Tabi 				       freq, 1);
33229b83d98STimur Tabi 	}
333a2d12f88STimur Tabi }
334a2d12f88STimur Tabi 
ft_board_setup(void * blob,bd_t * bd)335e895a4b0SSimon Glass int ft_board_setup(void *blob, bd_t *bd)
336c59e1b4dSTimur Tabi {
337c59e1b4dSTimur Tabi 	phys_addr_t base;
338c59e1b4dSTimur Tabi 	phys_size_t size;
339c59e1b4dSTimur Tabi 
340c59e1b4dSTimur Tabi 	ft_cpu_setup(blob, bd);
341c59e1b4dSTimur Tabi 
342723806ccSSimon Glass 	base = env_get_bootm_low();
343723806ccSSimon Glass 	size = env_get_bootm_size();
344c59e1b4dSTimur Tabi 
345c59e1b4dSTimur Tabi 	fdt_fixup_memory(blob, (u64)base, (u64)size);
346c59e1b4dSTimur Tabi 
3473d7506faSramneek mehresh #ifdef CONFIG_HAS_FSL_DR_USB
348a5c289b9SSriram Dash 	fsl_fdt_fixup_dr_usb(blob, bd);
3493d7506faSramneek mehresh #endif
3503d7506faSramneek mehresh 
3516525d51fSKumar Gala 	FT_FSL_PCI_SETUP;
352c59e1b4dSTimur Tabi 
353c59e1b4dSTimur Tabi #ifdef CONFIG_FSL_SGMII_RISER
354c59e1b4dSTimur Tabi 	fsl_sgmii_riser_fdt_fixup(blob);
355c59e1b4dSTimur Tabi #endif
356a2d12f88STimur Tabi 
357a2d12f88STimur Tabi 	/* Update the WM8776 node's clock frequency property */
358a2d12f88STimur Tabi 	ft_codec_setup(blob, "wlf,wm8776");
359e895a4b0SSimon Glass 
360e895a4b0SSimon Glass 	return 0;
361c59e1b4dSTimur Tabi }
362c59e1b4dSTimur Tabi #endif
363