blob: 156cb7f4ca72612c5ffb785a0d034604f5302563 [file] [log] [blame]
Sughosh Ganu48571ff2010-11-30 11:25:01 -05001/*
2 * Modified for Hawkboard - Syed Mohammed Khasim <khasim@beagleboard.org>
3 *
4 * Copyright (C) 2008 Sekhar Nori, Texas Instruments, Inc. <nsekhar@ti.com>
5 * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
6 * Copyright (C) 2004 Texas Instruments.
Sughosh Ganu25f8bf62012-08-09 10:45:20 +00007 * Copyright (C) 2012 Sughosh Ganu <urwithsughosh@gmail.com>.
Sughosh Ganu48571ff2010-11-30 11:25:01 -05008 *
9 * ----------------------------------------------------------------------------
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
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.
19 *
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., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * ----------------------------------------------------------------------------
24 */
25
26#include <common.h>
27#include <asm/errno.h>
28#include <asm/arch/hardware.h>
29#include <asm/io.h>
30#include <asm/arch/davinci_misc.h>
Sughosh Ganu6b873dc2012-02-02 00:44:41 +000031#include <asm/arch/pinmux_defs.h>
Sughosh Ganu25f8bf62012-08-09 10:45:20 +000032#include <asm/arch/da8xx-usb.h>
Sughosh Ganu48571ff2010-11-30 11:25:01 -050033#include <ns16550.h>
Sughosh Ganu48571ff2010-11-30 11:25:01 -050034
35DECLARE_GLOBAL_DATA_PTR;
36
Sughosh Ganu6b873dc2012-02-02 00:44:41 +000037const struct pinmux_resource pinmuxes[] = {
38 PINMUX_ITEM(emac_pins_mii),
39 PINMUX_ITEM(emac_pins_mdio),
40 PINMUX_ITEM(emifa_pins_cs3),
41 PINMUX_ITEM(emifa_pins_cs4),
42 PINMUX_ITEM(emifa_pins_nand),
43 PINMUX_ITEM(uart2_pins_txrx),
44 PINMUX_ITEM(uart2_pins_rtscts),
45};
46
47const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
48
49const struct lpsc_resource lpsc[] = {
50 { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
51 { DAVINCI_LPSC_SPI1 }, /* Serial Flash */
52 { DAVINCI_LPSC_EMAC }, /* image download */
53 { DAVINCI_LPSC_UART2 }, /* console */
54 { DAVINCI_LPSC_GPIO },
55};
56
57const int lpsc_size = ARRAY_SIZE(lpsc);
58
Sughosh Ganu48571ff2010-11-30 11:25:01 -050059int board_init(void)
60{
61 /* arch number of the board */
62 gd->bd->bi_arch_number = MACH_TYPE_OMAPL138_HAWKBOARD;
63
64 /* address of boot parameters */
65 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
66
67 return 0;
68}
69
70int board_early_init_f(void)
71{
72 /*
73 * Kick Registers need to be set to allow access to Pin Mux registers
74 */
Christian Riesch581a8112011-11-19 00:45:44 +000075 writel(DV_SYSCFG_KICK0_UNLOCK, &davinci_syscfg_regs->kick0);
76 writel(DV_SYSCFG_KICK1_UNLOCK, &davinci_syscfg_regs->kick1);
Sughosh Ganu48571ff2010-11-30 11:25:01 -050077
78 /* set cfgchip3 to select mii */
79 writel(readl(&davinci_syscfg_regs->cfgchip3) &
80 ~(1 << 8), &davinci_syscfg_regs->cfgchip3);
81
82 return 0;
83}
84
85int misc_init_r(void)
86{
87 char buf[32];
88
89 printf("ARM Clock : %s MHz\n",
90 strmhz(buf, clk_get(DAVINCI_ARM_CLKID)));
91
92 return 0;
93}
Sughosh Ganu25f8bf62012-08-09 10:45:20 +000094
95int usb_phy_on(void)
96{
97 u32 timeout;
98 u32 cfgchip2;
99
100 cfgchip2 = readl(&davinci_syscfg_regs->cfgchip2);
101
102 cfgchip2 &= ~(CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN |
103 CFGCHIP2_OTGMODE | CFGCHIP2_REFFREQ |
104 CFGCHIP2_USB1PHYCLKMUX);
105 cfgchip2 |= CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN | CFGCHIP2_PHY_PLLON |
106 CFGCHIP2_REFFREQ_24MHZ | CFGCHIP2_USB2PHYCLKMUX |
107 CFGCHIP2_USB1SUSPENDM;
108
109 writel(cfgchip2, &davinci_syscfg_regs->cfgchip2);
110
111 /* wait until the usb phy pll locks */
112 timeout = DA8XX_USB_OTG_TIMEOUT;
113 while (timeout--)
114 if (readl(&davinci_syscfg_regs->cfgchip2) & CFGCHIP2_PHYCLKGD)
115 return 1;
116
117 /* USB phy was not turned on */
118 return 0;
119}
120
121void usb_phy_off(void)
122{
123 u32 cfgchip2;
124
125 /*
126 * Power down the on-chip PHY.
127 */
128 cfgchip2 = readl(&davinci_syscfg_regs->cfgchip2);
129 cfgchip2 &= ~(CFGCHIP2_PHY_PLLON | CFGCHIP2_USB1SUSPENDM);
130 cfgchip2 |= CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN | CFGCHIP2_RESET;
131 writel(cfgchip2, &davinci_syscfg_regs->cfgchip2);
132}