Sughosh Ganu | 48571ff | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 1 | /* |
| 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 Ganu | 25f8bf6 | 2012-08-09 10:45:20 +0000 | [diff] [blame] | 7 | * Copyright (C) 2012 Sughosh Ganu <urwithsughosh@gmail.com>. |
Sughosh Ganu | 48571ff | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 8 | * |
| 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 Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 31 | #include <asm/arch/pinmux_defs.h> |
Sughosh Ganu | 25f8bf6 | 2012-08-09 10:45:20 +0000 | [diff] [blame] | 32 | #include <asm/arch/da8xx-usb.h> |
Sughosh Ganu | 48571ff | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 33 | #include <ns16550.h> |
Sughosh Ganu | 48571ff | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 34 | |
| 35 | DECLARE_GLOBAL_DATA_PTR; |
| 36 | |
Sughosh Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 37 | const 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 | |
| 47 | const int pinmuxes_size = ARRAY_SIZE(pinmuxes); |
| 48 | |
| 49 | const 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 | |
| 57 | const int lpsc_size = ARRAY_SIZE(lpsc); |
| 58 | |
Sughosh Ganu | 48571ff | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 59 | int 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 | |
| 70 | int board_early_init_f(void) |
| 71 | { |
| 72 | /* |
| 73 | * Kick Registers need to be set to allow access to Pin Mux registers |
| 74 | */ |
Christian Riesch | 581a811 | 2011-11-19 00:45:44 +0000 | [diff] [blame] | 75 | writel(DV_SYSCFG_KICK0_UNLOCK, &davinci_syscfg_regs->kick0); |
| 76 | writel(DV_SYSCFG_KICK1_UNLOCK, &davinci_syscfg_regs->kick1); |
Sughosh Ganu | 48571ff | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 77 | |
| 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 | |
| 85 | int 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 Ganu | 25f8bf6 | 2012-08-09 10:45:20 +0000 | [diff] [blame] | 94 | |
| 95 | int 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 | |
| 121 | void 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 | } |