blob: 227b5e2f3245ea4f33c6e5b8b1fd7902a2181d9c [file] [log] [blame]
/*
* Copyright (c) 2013 Qualcomm Atheros, Inc.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <command.h>
#include <asm/mipsregs.h>
#include <asm/addrspace.h>
#include <config.h>
#include <version.h>
#include "ar7240_soc.h"
extern int wasp_ddr_initial_config(uint32_t refresh);
extern int ar7240_ddr_find_size(void);
#ifdef COMPRESSED_UBOOT
# define prmsg(...)
#else
# define prmsg printf
#endif
void
wasp_usb_initial_config(void)
{
#define unset(a) (~(a))
if ((ar7240_reg_rd(WASP_BOOTSTRAP_REG) & WASP_REF_CLK_25) == 0) {
ar7240_reg_wr_nf(AR934X_SWITCH_CLOCK_SPARE,
ar7240_reg_rd(AR934X_SWITCH_CLOCK_SPARE) |
SWITCH_CLOCK_SPARE_USB_REFCLK_FREQ_SEL_SET(2));
} else {
ar7240_reg_wr_nf(AR934X_SWITCH_CLOCK_SPARE,
ar7240_reg_rd(AR934X_SWITCH_CLOCK_SPARE) |
SWITCH_CLOCK_SPARE_USB_REFCLK_FREQ_SEL_SET(5));
}
udelay(1000);
ar7240_reg_wr(AR7240_RESET,
ar7240_reg_rd(AR7240_RESET) |
RST_RESET_USB_PHY_SUSPEND_OVERRIDE_SET(1));
udelay(1000);
ar7240_reg_wr(AR7240_RESET,
ar7240_reg_rd(AR7240_RESET) &
unset(RST_RESET_USB_PHY_RESET_SET(1)));
udelay(1000);
ar7240_reg_wr(AR7240_RESET,
ar7240_reg_rd(AR7240_RESET) &
unset(RST_RESET_USB_PHY_ARESET_SET(1)));
udelay(1000);
ar7240_reg_wr(AR7240_RESET,
ar7240_reg_rd(AR7240_RESET) &
unset(RST_RESET_USB_HOST_RESET_SET(1)));
udelay(1000);
if ((ar7240_reg_rd(AR7240_REV_ID) & 0xf) == 0) {
/* Only for WASP 1.0 */
ar7240_reg_wr(0xb8116c84 ,
ar7240_reg_rd(0xb8116c84) & unset(1<<20));
}
}
void wasp_gpio_config(void)
{
#if 0
/* Disable clock obs */
ar7240_reg_wr (AR7240_GPIO_FUNC, (ar7240_reg_rd(AR7240_GPIO_FUNC) & 0xffe7e0ff));
/* Enable eth Switch LEDs */
#ifdef CONFIG_K31
ar7240_reg_wr (AR7240_GPIO_FUNC, (ar7240_reg_rd(AR7240_GPIO_FUNC) | 0xd8));
#else
ar7240_reg_wr (AR7240_GPIO_FUNC, (ar7240_reg_rd(AR7240_GPIO_FUNC) | 0xfa));
#endif
#endif
}
int
wasp_mem_config(void)
{
unsigned int type, reg32;
type = wasp_ddr_initial_config(CFG_DDR_REFRESH_VAL);
/* Take WMAC out of reset */
reg32 = ar7240_reg_rd(AR7240_RESET);
reg32 = reg32 & ~AR7240_RESET_WMAC;
ar7240_reg_wr_nf(AR7240_RESET, reg32);
/* Switching regulator settings */
ar7240_reg_wr_nf(0x18116c40, 0x633c8176); /* AR_PHY_PMU1 */
#if !defined(CONFIG_ATH_NAND_BR)
if (ar7240_reg_rd(AR7240_REV_ID) & 0xf) {
if (type == 2) {
// ddr1
ar7240_reg_wr_nf(0x18116c44, 0x10000000); /* AR_PHY_PMU2 */
} else {
// ddr2 & sdram
ar7240_reg_wr_nf(0x18116c44, 0x10380000); /* AR_PHY_PMU2 */
}
} else {
ar7240_reg_wr_nf(0x18116c44, 0x10380000); /* AR_PHY_PMU2 */
}
#endif
wasp_usb_initial_config();
wasp_gpio_config();
reg32 = ar7240_ddr_find_size();
return reg32;
}
long int initdram(int board_type)
{
return (wasp_mem_config());
}
#ifdef COMPRESSED_UBOOT
int checkboard(char *s)
#else
int checkboard(void)
#endif
{
#ifdef COMPRESSED_UBOOT
#if CONFIG_AP123
strcpy(s, "U-boot AP123\n");
#elif CONFIG_MI124
strcpy(s, "U-boot MI124\n");
#else
strcpy(s, "U-boot DB120\n");
#endif
#endif
#if CONFIG_AP123
prmsg("U-boot AP123\n");
#elif CONFIG_MI124
prmsg("U-boot MI124\n");
#else
prmsg("U-boot DB120\n");
#endif
return 0;
}