2 * Broadcom HNDSoC utlities, only for AP router
5 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
14 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
16 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 #include <nand_core.h>
31 static int bootdev
= -1;
32 static int knldev
= -1;
35 soc_boot_dev(void *socp
)
37 si_t
*sih
= (si_t
*)socp
;
38 int bootfrom
= SOC_BOOTDEV_SFLASH
;
45 origidx
= si_coreidx(sih
);
47 /* Check 4707 (NorthStar) */
48 if (sih
->ccrev
== 42) {
49 if (si_setcore(sih
, NS_ROM_CORE_ID
, 0) != NULL
) {
50 option
= si_core_sflags(sih
, 0, 0) & SISF_NS_BOOTDEV_MASK
;
51 if (option
== SISF_NS_BOOTDEV_NOR
) {
52 bootfrom
= SOC_BOOTDEV_SFLASH
;
54 else if (option
== SISF_NS_BOOTDEV_NAND
) {
55 bootfrom
= SOC_BOOTDEV_NANDFLASH
;
58 /* This must be SISF_NS_BOOTDEV_ROM */
59 bootfrom
= SOC_BOOTDEV_ROM
;
67 if (sih
->ccrev
== 38) {
68 if ((sih
->chipst
& (1 << 4)) != 0) {
69 bootfrom
= SOC_BOOTDEV_NANDFLASH
;
72 else if ((sih
->chipst
& (1 << 5)) != 0) {
73 bootfrom
= SOC_BOOTDEV_ROM
;
78 /* Handle old soc, 4704, 4718 */
79 if ((cc
= (chipcregs_t
*)si_setcoreidx(sih
, SI_CC_IDX
))) {
80 option
= R_REG(NULL
, &cc
->capabilities
) & CC_CAP_FLASH_MASK
;
82 bootfrom
= SOC_BOOTDEV_PFLASH
;
84 bootfrom
= SOC_BOOTDEV_SFLASH
;
89 si_setcoreidx(sih
, origidx
);
96 soc_knl_dev(void *socp
)
98 si_t
*sih
= (si_t
*)socp
;
100 int knlfrom
= SOC_KNLDEV_NORFLASH
;
105 if (soc_boot_dev(socp
) == SOC_BOOTDEV_NANDFLASH
) {
106 knlfrom
= SOC_KNLDEV_NANDFLASH
;
110 if (((CHIPID(sih
->chip
) == BCM4706_CHIP_ID
) || sih
->ccrev
== 38) &&
111 (sih
->cccaps
& CC_CAP_NFLASH
)) {
114 else if (sih
->ccrev
== 42) {
119 origidx
= si_coreidx(sih
);
120 if ((nc
= (nandregs_t
*)si_setcore(sih
, NS_NAND_CORE_ID
, 0)) != NULL
) {
121 id
= R_REG(NULL
, &nc
->flash_device_id
);
123 si_setcoreidx(sih
, origidx
);
132 /* Default set to nor boot */
136 /* Check NVRAM here */
137 if ((val
= nvram_get("bootflags")) != NULL
) {
140 bootflags
= simple_strtol(val
, NULL
, 0);
142 bootflags
= atoi(val
);
144 if (bootflags
& FLASH_KERNEL_NFLASH
)
145 knlfrom
= SOC_KNLDEV_NANDFLASH
;