3 * (c) 2008 Embedded Alley Solutions, Inc.
5 * (C) Copyright 2009-2010 Freescale Semiconductor, Inc.
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <asm/arch/mx23.h>
29 #include <asm/arch/clkctrl.h>
30 #include <asm/arch/pinmux.h>
31 #include <asm/arch/spi.h>
33 DECLARE_GLOBAL_DATA_PTR;
36 #define MHz (1000 * KHz)
38 static void set_pinmux(void)
41 #if defined(CONFIG_SPI_SSP1)
43 /* Configure SSP1 pins for ENC28j60: 8maA */
44 REG_CLR(PINCTRL_BASE + PINCTRL_MUXSEL(4), 0x00003fff);
46 REG_CLR(PINCTRL_BASE + PINCTRL_DRIVE(8), 0X03333333);
47 REG_SET(PINCTRL_BASE + PINCTRL_DRIVE(8), 0x01111111);
49 REG_CLR(PINCTRL_BASE + PINCTRL_PULL(2), 0x0000003f);
52 #if defined(CONFIG_SPI_SSP2)
54 /* Configure SSP2 pins for ENC28j60: 8maA */
55 REG_CLR(PINCTRL_BASE + PINCTRL_MUXSEL(0), 0x00000fc3);
56 REG_SET(PINCTRL_BASE + PINCTRL_MUXSEL(0), 0x00000a82);
58 REG_CLR(PINCTRL_BASE + PINCTRL_MUXSEL(1), 0x00030300);
59 REG_SET(PINCTRL_BASE + PINCTRL_MUXSEL(1), 0x00020200);
61 REG_CLR(PINCTRL_BASE + PINCTRL_DRIVE(0), 0X00333003);
62 REG_SET(PINCTRL_BASE + PINCTRL_DRIVE(0), 0x00111001);
64 REG_CLR(PINCTRL_BASE + PINCTRL_DRIVE(2), 0x00030000);
65 REG_SET(PINCTRL_BASE + PINCTRL_DRIVE(2), 0x00010000);
67 REG_CLR(PINCTRL_BASE + PINCTRL_DRIVE(3), 0x00000003);
68 REG_SET(PINCTRL_BASE + PINCTRL_DRIVE(3), 0x00000001);
70 REG_CLR(PINCTRL_BASE + PINCTRL_PULL(0), 0x00100039);
76 static void set_clocks(void)
78 u32 ssp_source_clk, ssp_clk;
83 * Configure 480Mhz IO clock
86 /* Ungate IO_CLK and set divider */
87 REG_CLR(CLKCTRL_BASE + CLKCTRL_FRAC, FRAC_CLKGATEIO);
88 REG_CLR(CLKCTRL_BASE + CLKCTRL_FRAC, 0x3f << FRAC_IOFRAC);
89 REG_SET(CLKCTRL_BASE + CLKCTRL_FRAC, IO_DIVIDER << FRAC_IOFRAC);
92 * Set SSP CLK to desired value
95 /* Calculate SSP_CLK divider relatively to 480Mhz IO_CLK*/
96 ssp_source_clk = 480 * MHz;
97 ssp_clk = CONFIG_SSP_CLK;
98 ssp_div = (ssp_source_clk + ssp_clk - 1) / ssp_clk;
100 /* Enable SSP clock */
101 val = REG_RD(CLKCTRL_BASE + CLKCTRL_SSP);
103 REG_WR(CLKCTRL_BASE + CLKCTRL_SSP, val);
105 /* Wait while clock is gated */
106 while (REG_RD(CLKCTRL_BASE + CLKCTRL_SSP) & SSP_CLKGATE)
109 /* Set SSP clock divider */
110 val &= ~(0x1ff << SSP_DIV);
111 val |= ssp_div << SSP_DIV;
112 REG_WR(CLKCTRL_BASE + CLKCTRL_SSP, val);
114 /* Wait until new divider value is set */
115 while (REG_RD(CLKCTRL_BASE + CLKCTRL_SSP) & SSP_BUSY)
118 /* Set SSP clock source to IO_CLK */
119 REG_SET(CLKCTRL_BASE + CLKCTRL_CLKSEQ, CLKSEQ_BYPASS_SSP);
120 REG_CLR(CLKCTRL_BASE + CLKCTRL_CLKSEQ, CLKSEQ_BYPASS_SSP);
125 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
126 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
133 /* arch number of Freescale STMP 378x development board */
134 gd->bd->bi_arch_number = MACH_TYPE_MX23EVK;
136 /* adress of boot parameters */
137 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
143 /* Configure SPI on SSP1 or SSP2 */
149 int misc_init_r(void)
156 printf("Board: MX23 EVK. \n");