1 --- a/arch/arm/mach-kirkwood/Kconfig
2 +++ b/arch/arm/mach-kirkwood/Kconfig
3 @@ -25,6 +25,9 @@ config TARGET_LSXL
7 +config TARGET_POGOPLUGV4
8 + bool "Pogoplug V4 Board"
13 @@ -77,6 +80,7 @@ source "board/Marvell/guruplug/Kconfig"
14 source "board/Marvell/sheevaplug/Kconfig"
15 source "board/buffalo/lsxl/Kconfig"
16 source "board/cloudengines/pogo_e02/Kconfig"
17 +source "board/cloudengines/pogoplugv4/Kconfig"
18 source "board/d-link/dns325/Kconfig"
19 source "board/iomega/iconnect/Kconfig"
20 source "board/keymile/km_arm/Kconfig"
21 --- a/arch/arm/mach-kirkwood/include/mach/config.h
22 +++ b/arch/arm/mach-kirkwood/include/mach/config.h
24 * Ethernet Driver configuration
27 +#define CONFIG_FEATURE_COMMAND_EDITING
28 #define CONFIG_NETCONSOLE /* include NetConsole support */
29 #define CONFIG_MII /* expose smi ove miiphy interface */
30 #define CONFIG_MVGBE /* Enable Marvell Gbe Controller Driver */
32 #define CONFIG_SYS_ATA_STRIDE 4
33 /* Controller supports 48-bits LBA addressing */
35 +#define CONFIG_SYS_64BIT_LBA
36 /* CONFIG_IDE requires some #defines for ATA registers */
37 #define CONFIG_SYS_IDE_MAXBUS 2
38 #define CONFIG_SYS_IDE_MAXDEVICE 2
40 #define CONFIG_SYS_TIMER_COUNTER (MVEBU_TIMER_BASE + 0x14)
41 #define CONFIG_SYS_TIMER_RATE CONFIG_SYS_TCLK
46 +#define CONFIG_CMD_BOOTZ
51 +#define CONFIG_CMD_GPIO
52 +#define CONFIG_KIRKWOOD_GPIO
54 #endif /* _KW_CONFIG_H */
55 --- a/arch/arm/mach-kirkwood/include/mach/kw88f6192.h
56 +++ b/arch/arm/mach-kirkwood/include/mach/kw88f6192.h
58 #define KW_REGS_PHY_BASE KW88F6192_REGS_PHYS_BASE
60 /* TCLK Core Clock defination */
61 -#define CONFIG_SYS_TCLK 166000000 /* 166MHz */
62 +#define CONFIG_SYS_TCLK 166666667 /* 166MHz */
64 #endif /* _CONFIG_KW88F6192_H */
65 --- a/arch/arm/mach-kirkwood/include/mach/mpp.h
66 +++ b/arch/arm/mach-kirkwood/include/mach/mpp.h
68 #define MPP33_GPIO MPP( 33, 0x0, 1, 1, 0, 1, 1, 1 )
69 #define MPP33_TDM_DTX MPP( 33, 0x2, 0, 1, 0, 0, 1, 1 )
70 #define MPP33_GE1_13 MPP( 33, 0x3, 0, 0, 0, 1, 1, 1 )
71 +#define MPP33_SATA1_ACTn MPP( 33, 0x5, 0, 1, 0, 1, 1, 1 )
73 #define MPP34_GPIO MPP( 34, 0x0, 1, 1, 0, 1, 1, 1 )
74 #define MPP34_TDM_SPI_CS1 MPP( 34, 0x2, 0, 1, 0, 0, 1, 1 )
75 #define MPP34_GE1_14 MPP( 34, 0x3, 0, 0, 0, 1, 1, 1 )
76 +#define MPP34_SATA1_ACTn MPP( 34, 0x5, 0, 1, 0, 1, 1, 1 )
78 #define MPP35_GPIO MPP( 35, 0x0, 1, 1, 1, 1, 1, 1 )
79 #define MPP35_TDM_CH0_TX_QL MPP( 35, 0x2, 0, 1, 0, 0, 1, 1 )
80 --- a/arch/arm/mach-mvebu/include/mach/soc.h
81 +++ b/arch/arm/mach-mvebu/include/mach/soc.h
83 #define SOC_88F6810_ID 0x6810
84 #define SOC_88F6820_ID 0x6820
85 #define SOC_88F6828_ID 0x6828
86 +#define SOC_88F6192_ID 0x6192
87 +#define SOC_88F6702_ID 0x6702
90 #define MV_88F67XX_A0_ID 0x3
92 +++ b/board/cloudengines/pogoplugv4/Kconfig
97 + default "pogoplugv4"
100 + default "cloudengines"
102 +config SYS_CONFIG_NAME
103 + default "pogoplugv4"
107 +++ b/board/cloudengines/pogoplugv4/MAINTAINERS
110 +M: Alberto Bursi <alberto.bursi@outlook.it>
112 +F: board/cloudengines/pogoplugv4/
113 +F: include/configs/pogoplugv4.h
114 +F: configs/pogoplugv4_defconfig
116 +++ b/board/cloudengines/pogoplugv4/Makefile
119 +# (C) Copyright 2009 bodhi <mibodhi@gmail.com>
122 +# Marvell Semiconductor <www.marvell.com>
123 +# Written-by: Prafulla Wadaskar <prafulla@marvell.com>
125 +# SPDX-License-Identifier: GPL-2.0+
128 +obj-y := pogoplugv4.o
130 +++ b/board/cloudengines/pogoplugv4/kwbimage.cfg
133 +# Copyright (C) 2012
134 +# David Purdy <david.c.purdy@gmail.com>
136 +# Based on Kirkwood support:
137 +# (C) Copyright 2009
138 +# Marvell Semiconductor <www.marvell.com>
139 +# Written-by: Prafulla Wadaskar <prafulla <at> marvell.com>
141 +# See file CREDITS for list of people who contributed to this
144 +# This program is free software; you can redistribute it and/or
145 +# modify it under the terms of the GNU General Public License as
146 +# published by the Free Software Foundation; either version 2 of
147 +# the License, or (at your option) any later version.
149 +# This program is distributed in the hope that it will be useful,
150 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
151 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
152 +# GNU General Public License for more details.
154 +# You should have received a copy of the GNU General Public License
155 +# along with this program; If not, see <http://www.gnu.org/licenses/>.
157 +# Refer docs/README.kwimage for more details about how-to configure
158 +# and create kirkwood boot image
161 +# Boot Media configurations (DONE)
163 +NAND_ECC_MODE default
164 +NAND_PAGE_SIZE 0x0800
166 +# SOC registers configuration using bootrom header extension
167 +# Maximum KWBIMAGE_MAX_CONFIG configurations allowed
169 +# Configure RGMII-0 interface pad voltage to 1.8V (SHOULD BE SAME)
170 +DATA 0xffd100e0 0x1b1b1b9b
172 +#Dram initalization for SINGLE x16 CL=3 @ 200MHz (need CL=3 @ 200MHz?)
173 +DATA 0xffd01400 0x43000618 # DDR Configuration register
174 +# bit13-0: 0x200 (200 DDR2 clks refresh rate)
176 +# bit24: 1= enable exit self refresh mode on DDR access
181 +DATA 0xffd01404 0x34143000 # DDR Controller Control Low
182 +# bit 4: 0=addr/cmd in smame cycle
183 +# bit 5: 0=clk is driven during self refresh, we don't care for APX
184 +# bit 6: 0=use recommended falling edge of clk for addr/cmd
185 +# bit14: 0=input buffer always powered up
186 +# bit18: 1=cpu lock transaction enabled
187 +# bit23-20: 3=recommended value for CL=3 and STARTBURST_DEL disabled bit31=0
188 +# bit27-24: 6= CL+3, STARTBURST sample stages, for freqs 400MHz, unbuffered DIMM
189 +# bit30-28: 3 required
190 +# bit31: 0=no additional STARTBURST delay
192 +DATA 0xffd01408 0x11012227 # DDR Timing (Low) (active cycles value +1)
203 +DATA 0xffd0140c 0x00000819 # DDR Timing (High)
208 +# bit31-13: zero required
210 +DATA 0xffd01410 0x00000001 # DDR Address Control (changed to Dockstar vals)
211 +# bit1-0: 00, Cs0width=x16
212 +# bit3-2: 10, Cs0size=512Mb
213 +# bit5-4: 00, Cs2width=nonexistent
214 +# bit7-6: 00, Cs1size =nonexistent
215 +# bit9-8: 00, Cs2width=nonexistent
216 +# bit11-10: 00, Cs2size =nonexistent
217 +# bit13-12: 00, Cs3width=nonexistent
218 +# bit15-14: 00, Cs3size =nonexistent
219 +# bit16: 0, Cs0AddrSel
220 +# bit17: 0, Cs1AddrSel
221 +# bit18: 0, Cs2AddrSel
222 +# bit19: 0, Cs3AddrSel
223 +# bit31-20: 0 required
225 +DATA 0xffd01414 0x00000000 # DDR Open Pages Control
226 +# bit0: 0, OpenPage enabled
227 +# bit31-1: 0 required
229 +DATA 0xffd01418 0x00000000 # DDR Operation
230 +# bit3-0: 0x0, DDR cmd
231 +# bit31-4: 0 required
233 +DATA 0xffd0141c 0x00000632 # DDR Mode
234 +# bit2-0: 2, BurstLen=2 required
235 +# bit3: 0, BurstType=0 required
236 +# bit6-4: 4, CL=5 (<===== change to CL=3 ?)
237 +# bit7: 0, TestMode=0 normal
238 +# bit8: 0, DLL reset=0 normal
239 +# bit11-9: 6, auto-precharge write recovery ????????????
240 +# bit12: 0, PD must be zero
241 +# bit31-13: 0 required
243 +DATA 0xffd01420 0x00000040 # DDR Extended Mode
244 +# bit0: 0, DDR DLL enabled
245 +# bit1: 0, DDR drive strenght normal
246 +# bit2: 0, DDR ODT control lsd (disabled)
247 +# bit5-3: 000, required
248 +# bit6: 1, DDR ODT control msb, (disabled)
249 +# bit9-7: 000, required
250 +# bit10: 0, differential DQS enabled
251 +# bit11: 0, required
252 +# bit12: 0, DDR output buffer enabled
253 +# bit31-13: 0 required
255 +DATA 0xffd01424 0x0000F07F # DDR Controller Control High
256 +# bit2-0: 111, required
257 +# bit3 : 1 , MBUS Burst Chop disabled
258 +# bit6-4: 111, required
260 +# bit8 : 0 , no sample stage
261 +# bit9 : 0 , no half clock cycle addition to dataout
262 +# bit10 : 0 , 1/4 clock cycle skew enabled for addr/ctl signals
263 +# bit11 : 0 , 1/4 clock cycle skew disabled for write mesh
264 +# bit15-12: 1111 required
265 +# bit31-16: 0 required
267 +DATA 0xffd01428 0x00085520 # DDR2 ODT Read Timing (default values)
268 +DATA 0xffd0147c 0x00008552 # DDR2 ODT Write Timing (default values)
270 +DATA 0xFFD01500 0x00000000 # CS[0]n Base address to 0x0
271 +DATA 0xFFD01504 0x07FFFFF1 # CS[0]n Size
272 +# bit0: 1, Window enabled
273 +# bit1: 0, Write Protect disabled
274 +# bit3-2: 00, CS0 hit selected
275 +# bit23-4: ones, required
276 +# bit31-24: 0x07, Size (i.e. 128MB)
278 +DATA 0xFFD0150C 0x00000000 # CS[1]n Size, window disabled
279 +DATA 0xFFD01514 0x00000000 # CS[2]n Size, window disabled
280 +DATA 0xFFD0151C 0x00000000 # CS[3]n Size, window disabled
282 +DATA 0xffd01494 0x00030000 # DDR ODT Control (Low) (DONE)
283 +# bit3-0: 2, ODT0Rd, MODT[0] asserted during read from DRAM CS1
284 +# bit7-4: 1, ODT0Rd, MODT[0] asserted during read from DRAM CS0
285 +# bit19-16:2, ODT0Wr, MODT[0] asserted during write to DRAM CS1
286 +# bit23-20:1, ODT0Wr, MODT[0] asserted during write to DRAM CS0
288 +DATA 0xffd01498 0x00000000 # DDR ODT Control (High) (DONE)
289 +# bit1-0: 00, ODT0 controlled by ODT Control (low) register above
290 +# bit3-2: 01, ODT1 active NEVER!
291 +# bit31-4: zero, required
293 +DATA 0xffd0149c 0x0000e803 # CPU ODT Control (DONE)
294 +DATA 0xffd01480 0x00000001 # DDR Initialization Control (DONE)
295 +#bit0=1, enable DDR init upon this register write
297 +# End of Header extension
300 +++ b/board/cloudengines/pogoplugv4/pogoplugv4.c
303 + * Copyright (C) 2016 bodhi <mibodhi@gmail.com>
304 + * Copyright (C) 2014 bodhi <mibodhi@gmail.com>
308 + * Copyright (C) 2014 <ebbes.ebbes@gmail.com>
310 + * Copyright (C) 2012
311 + * David Purdy <david.c.purdy@gmail.com>
313 + * Based on Kirkwood support:
314 + * (C) Copyright 2009
315 + * Marvell Semiconductor <www.marvell.com>
316 + * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
318 + * See file CREDITS for list of people who contributed to this
321 + * This program is free software; you can redistribute it and/or
322 + * modify it under the terms of the GNU General Public License as
323 + * published by the Free Software Foundation; either version 2 of
324 + * the License, or (at your option) any later version.
326 + * This program is distributed in the hope that it will be useful,
327 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
328 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
329 + * GNU General Public License for more details.
331 + * You should have received a copy of the GNU General Public License
332 + * along with this program; If not, see <http://www.gnu.org/licenses/>.
337 +#include <asm/arch/cpu.h>
338 +#include <asm/arch/soc.h>
339 +#include <asm/arch/mpp.h>
341 +#include "pogoplugv4.h"
342 +#include <asm/arch/gpio.h>
344 +#ifdef CONFIG_KIRKWOOD_MMC
345 +#include <kirkwood_mmc.h>
346 +#endif /* CONFIG_KIRKWOOD_MMC */
349 +DECLARE_GLOBAL_DATA_PTR;
351 +int board_early_init_f(void)
354 + * default gpio configuration
355 + * There are maximum 64 gpios controlled through 2 sets of registers
356 + * the below configuration configures mainly initial LED status
358 + mvebu_config_gpio(POGOPLUGV4_OE_VAL_LOW,
359 + POGOPLUGV4_OE_VAL_HIGH,
360 + POGOPLUGV4_OE_LOW, POGOPLUGV4_OE_HIGH);
362 + /* Multi-Purpose Pins Functionality configuration */
363 + u32 kwmpp_config[] = {
386 + MPP22_GPIO, /* Green LED */
388 + MPP24_GPIO, /* Red LED */
393 + MPP29_GPIO, /* Eject button */
399 + MPP35_GPIO, /* FR6192 has only 36 GPIOs */
402 + kirkwood_mpp_conf(kwmpp_config, NULL);
407 +int board_init(void)
409 + /* Boot parameters address */
410 + gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
412 + kw_gpio_set_valid(20, 1);
413 + kw_gpio_set_valid(21, 1);
414 + kw_gpio_set_valid(22, 1);
415 + kw_gpio_set_valid(24, 1);
420 +#ifdef CONFIG_RESET_PHY_R
421 +/* Configure and initialize PHY */
422 +void reset_phy(void)
426 + char *name = "egiga0";
428 + if (miiphy_set_current_dev(name))
431 + /* command to read PHY dev address */
432 + if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
433 + printf("Err..(%s) could not read PHY dev address\n", __func__);
438 + * Enable RGMII delay on Tx and Rx for CPU port
439 + * Ref: sec 4.7.2 of chip datasheet
441 + miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
442 + miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®);
443 + reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
444 + miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
445 + miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
447 + /* reset the phy */
448 + miiphy_reset(name, devadr);
450 + debug("88E1116 Initialized on %s\n", name);
452 +#endif /* CONFIG_RESET_PHY_R */
454 +#ifdef CONFIG_KIRKWOOD_MMC
455 +int board_mmc_init(bd_t *bis)
457 + kw_mmc_initialize(bis);
460 +#endif /* CONFIG_KIRKWOOD_MMC */
463 +#define GREEN_LED (1 << 22)
464 +#define RED_LED (1 << 24)
465 +#define BOTH_LEDS (GREEN_LED | RED_LED)
466 +#define NEITHER_LED 0
468 +static void set_leds(u32 leds, u32 blinking)
470 + struct kwgpio_registers *r;
474 + r = (struct kwgpio_registers *)MVEBU_GPIO0_BASE;
475 + oe = readl(&r->oe) | BOTH_LEDS;
476 + writel(oe & ~leds, &r->oe); /* active low */
477 + bl = readl(&r->blink_en) & ~BOTH_LEDS;
478 + writel(bl | blinking, &r->blink_en);
481 +void show_boot_progress(int val)
484 + case BOOTSTAGE_ID_RUN_OS: /* booting Linux */
485 + set_leds(BOTH_LEDS, NEITHER_LED);
487 + case BOOTSTAGE_ID_NET_ETH_START: /* Ethernet initialization */
488 + set_leds(GREEN_LED, GREEN_LED);
491 + if (val < 0) /* error */
492 + set_leds(RED_LED, RED_LED);
497 +#if defined(CONFIG_KIRKWOOD_GPIO)
498 +/* Return GPIO button status */
501 + gpio-29 (Eject Button ) in hi (act lo) - IRQ edge (clear )
503 + gpio-29 (Eject Button ) in lo (act hi) - IRQ edge (clear )
507 +do_read_button(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
509 + if (strcmp(argv[1], "eject") == 0) {
510 + kw_gpio_set_valid(BTN_EJECT, GPIO_INPUT_OK);
511 + kw_gpio_direction_input(BTN_EJECT);
512 + return kw_gpio_get_value(BTN_EJECT);
519 +U_BOOT_CMD(button, 2, 0, do_read_button,
520 + "Return GPIO button status 0=off 1=on",
521 + "- button eject: test buttons states\n"
526 +++ b/board/cloudengines/pogoplugv4/pogoplugv4.h
529 + * Copyright (C) 2016
530 + * bodhi <mibodhi@gmail.com>
532 + * Copyright (C) 2012
533 + * David Purdy <david.c.purdy@gmail.com>
535 + * Based on Kirkwood support:
536 + * (C) Copyright 2009
537 + * Marvell Semiconductor <www.marvell.com>
538 + * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
540 + * See file CREDITS for list of people who contributed to this
543 + * This program is free software; you can redistribute it and/or
544 + * modify it under the terms of the GNU General Public License as
545 + * published by the Free Software Foundation; either version 2 of
546 + * the License, or (at your option) any later version.
548 + * This program is distributed in the hope that it will be useful,
549 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
550 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
551 + * GNU General Public License for more details.
553 + * You should have received a copy of the GNU General Public License
554 + * along with this program; If not, see <http://www.gnu.org/licenses/>.
557 +#ifndef __POGOPLUGV4_H
558 +#define __POGOPLUGV4_H
560 +/* GPIO configuration */
561 +#define POGOPLUGV4_OE_LOW (~(0))
562 +#define POGOPLUGV4_OE_HIGH (~(0))
563 +#define POGOPLUGV4_OE_VAL_LOW (1 << 29)
564 +#define POGOPLUGV4_OE_VAL_HIGH 0
567 +#define MV88E1116_LED_FCTRL_REG 10
568 +#define MV88E1116_CPRSP_CR3_REG 21
569 +#define MV88E1116_MAC_CTRL_REG 21
570 +#define MV88E1116_PGADR_REG 22
571 +#define MV88E1116_RGMII_TXTM_CTRL (1 << 4)
572 +#define MV88E1116_RGMII_RXTM_CTRL (1 << 5)
575 +#define BTN_EJECT 29
577 +#endif /* __POGOPLUGV4_H */
579 +++ b/configs/pogoplugv4_defconfig
583 +CONFIG_TARGET_POGOPLUGV4=y
584 +CONFIG_SYS_PROMPT="pogoplugv4> "
585 +CONFIG_IDENT_STRING="\nPogoplug V4"
587 +# CONFIG_CMD_IMLS is not set
588 +# CONFIG_CMD_FLASH is not set
589 +CONFIG_SYS_NS16550=y
592 +CONFIG_CMD_SETEXPR=y
604 +CONFIG_CMD_MTDPARTS=y
608 +CONFIG_EFI_PARTITION=y
609 +CONFIG_ENV_IS_IN_NAND=y
612 +CONFIG_USB_EHCI_HCD=y
613 +CONFIG_USB_STORAGE=y
616 --- a/drivers/gpio/kw_gpio.c
617 +++ b/drivers/gpio/kw_gpio.c
618 @@ -148,3 +148,36 @@ void kw_gpio_set_blink(unsigned pin, int
620 __set_blinking(pin, blink);
625 + * Hooks to GENERIC_GPIO primitives
628 +int gpio_direction_input(unsigned pin)
630 + return kw_gpio_direction_input(pin);
633 +int gpio_direction_output(unsigned pin, int value)
635 + return kw_gpio_direction_output(pin, value);
638 +void gpio_set_value(unsigned pin, int value) {
639 + kw_gpio_set_value(pin, value);
642 +int gpio_get_value(unsigned pin) {
643 + return kw_gpio_get_value(pin);
646 +int gpio_request(unsigned gpio, const char *label)
651 +int gpio_free(unsigned gpio)
655 --- a/drivers/mmc/Makefile
656 +++ b/drivers/mmc/Makefile
657 @@ -61,6 +61,7 @@ obj-$(CONFIG_MMC_SDHCI_TANGIER) += tang
658 obj-$(CONFIG_MMC_SDHCI_TEGRA) += tegra_mmc.o
659 obj-$(CONFIG_MMC_SDHCI_XENON) += xenon_sdhci.o
660 obj-$(CONFIG_MMC_SDHCI_ZYNQ) += zynq_sdhci.o
661 +obj-$(CONFIG_KIRKWOOD_MMC) += kirkwood_mmc.o
663 obj-$(CONFIG_MMC_SUNXI) += sunxi_mmc.o
664 obj-$(CONFIG_MMC_UNIPHIER) += uniphier-sd.o
666 +++ b/drivers/mmc/kirkwood_mmc.c
669 + * (C) Copyright 2014 bodhi <mibodhi@gmail.com>
673 + * (C) Copyright 2014 <ebbes.ebbes@gmail.com>
677 + * Driver for Marvell SDIO/MMC controller
679 + * (C) Copyright 2012
680 + * Marvell Semiconductor <www.marvell.com>
681 + * Written-by: Gérald Kerma <uboot at doukki.net>
682 + * See file CREDITS for list of people who contributed to this
685 + * This program is free software; you can redistribute it and/or
686 + * modify it under the terms of the GNU General Public License as
687 + * published by the Free Software Foundation; either version 2 of
688 + * the License, or (at your option) any later version.
690 + * This program is distributed in the hope that it will be useful,
691 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
692 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
693 + * GNU General Public License for more details.
695 + * You should have received a copy of the GNU General Public License
696 + * along with this program; if not, write to the Free Software
697 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
698 + * MA 02111-1307 USA
706 +#include <asm/arch/cpu.h>
707 +#include <asm/arch/soc.h>
709 +#include <kirkwood_mmc.h>
711 +#define DRIVER_NAME "kwsdio"
713 +static int kw_mmc_setup_data(struct mmc_data *data)
718 + printf("%s, data %s : blocks=%d blksz=%d\n", DRIVER_NAME,
719 + (data->flags & MMC_DATA_READ) ? "read" : "write",
720 + data->blocks, data->blocksize);
723 + /* default to maximum timeout */
724 + ctrl_reg = kwsd_read(SDIO_HOST_CTRL);
725 + ctrl_reg |= SDIO_HOST_CTRL_TMOUT(SDIO_HOST_CTRL_TMOUT_MAX);
726 + kwsd_write(SDIO_HOST_CTRL, ctrl_reg);
728 + if (data->flags & MMC_DATA_READ) {
729 + kwsd_write(SDIO_SYS_ADDR_LOW,(u32)data->dest & 0xffff);
730 + kwsd_write(SDIO_SYS_ADDR_HI,(u32)data->dest >> 16);
732 + kwsd_write(SDIO_SYS_ADDR_LOW,(u32)data->src & 0xffff);
733 + kwsd_write(SDIO_SYS_ADDR_HI,(u32)data->src >> 16);
736 + kwsd_write(SDIO_BLK_COUNT, data->blocks);
737 + kwsd_write(SDIO_BLK_SIZE, data->blocksize);
742 +static int kw_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
746 + ushort waittype = 0;
747 + ushort resptype = 0;
748 + ushort xfertype = 0;
749 + ushort resp_indx = 0;
751 +#ifdef CONFIG_MMC_DEBUG
752 + printf("cmdidx [0x%x] resp_type[0x%x] cmdarg[0x%x]\n", cmd->cmdidx, cmd->resp_type, cmd->cmdarg);
757 +#ifdef CONFIG_MMC_DEBUG
758 + printf("%s: cmd %d (hw state 0x%04x)\n", DRIVER_NAME, cmd->cmdidx, kwsd_read(SDIO_HW_STATE));
761 + /* Checking if card is busy */
762 + while ((kwsd_read(SDIO_HW_STATE) & CARD_BUSY)) {
763 + if (timeout == 0) {
764 + printf("%s: card busy!\n", DRIVER_NAME);
771 + /* Set up for a data transfer if we have one */
773 + if ((err = kw_mmc_setup_data(data)))
777 + resptype = SDIO_CMD_INDEX(cmd->cmdidx);
779 + /* Analyzing resptype/xfertype/waittype for the command */
780 + if (cmd->resp_type & MMC_RSP_BUSY)
781 + resptype |= SDIO_CMD_RSP_48BUSY;
782 + else if (cmd->resp_type & MMC_RSP_136)
783 + resptype |= SDIO_CMD_RSP_136;
784 + else if (cmd->resp_type & MMC_RSP_PRESENT)
785 + resptype |= SDIO_CMD_RSP_48;
787 + resptype |= SDIO_CMD_RSP_NONE;
789 + if (cmd->resp_type & MMC_RSP_CRC)
790 + resptype |= SDIO_CMD_CHECK_CMDCRC;
792 + if (cmd->resp_type & MMC_RSP_OPCODE)
793 + resptype |= SDIO_CMD_INDX_CHECK;
795 + if (cmd->resp_type & MMC_RSP_PRESENT) {
796 + resptype |= SDIO_UNEXPECTED_RESP;
797 + waittype |= SDIO_NOR_UNEXP_RSP;
801 + resptype |= SDIO_CMD_DATA_PRESENT | SDIO_CMD_CHECK_DATACRC16;
802 + xfertype |= SDIO_XFER_MODE_HW_WR_DATA_EN;
803 + if (data->flags & MMC_DATA_READ) {
804 + xfertype |= SDIO_XFER_MODE_TO_HOST;
805 + waittype = SDIO_NOR_DMA_INI;
807 + waittype |= SDIO_NOR_XFER_DONE;
809 + waittype |= SDIO_NOR_CMD_DONE;
811 + /* Setting cmd arguments */
812 + kwsd_write(SDIO_ARG_LOW, cmd->cmdarg & 0xffff);
813 + kwsd_write(SDIO_ARG_HI, cmd->cmdarg >> 16);
815 + /* Setting Xfer mode */
816 + kwsd_write(SDIO_XFER_MODE, xfertype);
818 + kwsd_write(SDIO_NOR_INTR_STATUS, ~SDIO_NOR_CARD_INT);
819 + kwsd_write(SDIO_ERR_INTR_STATUS, SDIO_POLL_MASK);
821 + /* Sending command */
822 + kwsd_write(SDIO_CMD, resptype);
824 + kwsd_write(SDIO_CMD, KW_MMC_MAKE_CMD(cmd->cmdidx, resptype));
827 + kwsd_write(SDIO_NOR_INTR_EN, SDIO_POLL_MASK);
828 + kwsd_write(SDIO_ERR_INTR_EN, SDIO_POLL_MASK);
830 + /* Waiting for completion */
833 + while (!((kwsd_read(SDIO_NOR_INTR_STATUS)) & waittype)) {
834 + if (kwsd_read(SDIO_NOR_INTR_STATUS) & SDIO_NOR_ERROR) {
836 + printf("%s: kw_mmc_send_cmd: error! cmdidx : %d, err reg: %04x\n", DRIVER_NAME, cmd->cmdidx,
837 +wsd_read(SDIO_ERR_INTR_STATUS));
839 + if (kwsd_read(SDIO_ERR_INTR_STATUS) & (SDIO_ERR_CMD_TIMEOUT | SDIO_ERR_DATA_TIMEOUT)) {
847 + if (timeout <= 0) {
848 + printf("%s: command timed out\n", DRIVER_NAME);
853 + /* Handling response */
854 + if (cmd->resp_type & MMC_RSP_136) {
856 + for (resp_indx = 0; resp_indx < 8; resp_indx++)
857 + response[resp_indx] = kwsd_read(SDIO_RSP(resp_indx));
859 + cmd->response[0] = ((response[0] & 0x03ff) << 22) |
860 + ((response[1] & 0xffff) << 6) |
861 + ((response[2] & 0xfc00) >> 10);
862 + cmd->response[1] = ((response[2] & 0x03ff) << 22) |
863 + ((response[3] & 0xffff) << 6) |
864 + ((response[4] & 0xfc00) >> 10);
865 + cmd->response[2] = ((response[4] & 0x03ff) << 22) |
866 + ((response[5] & 0xffff) << 6) |
867 + ((response[6] & 0xfc00) >> 10);
868 + cmd->response[3] = ((response[6] & 0x03ff) << 22) |
869 + ((response[7] & 0x3fff) << 8);
870 + } else if (cmd->resp_type & MMC_RSP_PRESENT) {
872 + for (resp_indx = 0; resp_indx < 3; resp_indx++)
873 + response[resp_indx] = kwsd_read(SDIO_RSP(resp_indx));
875 + cmd->response[0] = ((response[2] & 0x003f) << (8 - 8)) |
876 + ((response[1] & 0xffff) << (14 - 8)) |
877 + ((response[0] & 0x03ff) << (30 - 8));
878 + cmd->response[1] = ((response[0] & 0xfc00) >> 10);
879 + cmd->response[2] = 0;
880 + cmd->response[3] = 0;
883 +#ifdef CONFIG_MMC_DEBUG
884 + printf("%s: resp[0x%x] ", DRIVER_NAME, cmd->resp_type);
885 + printf("[0x%x] ", cmd->response[0]);
886 + printf("[0x%x] ", cmd->response[1]);
887 + printf("[0x%x] ", cmd->response[2]);
888 + printf("[0x%x] ", cmd->response[3]);
896 +/* Disable these three functions as they are not used anyway */
898 +static void kwsd_power_up(void)
901 + printf("%s: power up\n", DRIVER_NAME);
903 + /* disable interrupts */
904 + kwsd_write(SDIO_NOR_INTR_EN, 0);
905 + kwsd_write(SDIO_ERR_INTR_EN, 0);
908 + kwsd_write(SDIO_SW_RESET, SDIO_SW_RESET_NOW);
910 + kwsd_write(SDIO_XFER_MODE, 0);
912 + /* enable status */
913 + kwsd_write(SDIO_NOR_STATUS_EN, SDIO_POLL_MASK);
914 + kwsd_write(SDIO_ERR_STATUS_EN, SDIO_POLL_MASK);
916 + /* enable interrupts status */
917 + kwsd_write(SDIO_NOR_INTR_STATUS, SDIO_POLL_MASK);
918 + kwsd_write(SDIO_ERR_INTR_STATUS, SDIO_POLL_MASK);
921 +static void kwsd_power_down(void)
924 + printf("%s: power down\n", DRIVER_NAME);
926 + /* disable interrupts */
927 + kwsd_write(SDIO_NOR_INTR_EN, 0);
928 + kwsd_write(SDIO_ERR_INTR_EN, 0);
931 + kwsd_write(SDIO_SW_RESET, SDIO_SW_RESET_NOW);
933 + kwsd_write(SDIO_XFER_MODE, SDIO_XFER_MODE_STOP_CLK);
935 + /* disable status */
936 + kwsd_write(SDIO_NOR_STATUS_EN, 0);
937 + kwsd_write(SDIO_ERR_STATUS_EN, 0);
939 + /* enable interrupts status */
940 + kwsd_write(SDIO_NOR_INTR_STATUS, SDIO_POLL_MASK);
941 + kwsd_write(SDIO_ERR_INTR_STATUS, SDIO_POLL_MASK);
944 +static u32 kw_mmc_get_base_clock(void)
946 + /* Original version did a check for board device id and revision id
947 + * and assigned one of these clocks:
948 + * KW_MMC_BASE_FAST_CLK_100 (revid == 0 && devid != MV88F6282_DEV_ID)
949 + * KW_MMC_BASE_FAST_CLK_200 (revid != 0 || devid == MV88F6282_DEV_ID)
950 + * However, this check was disabled and
951 + * KW_MMC_BASE_FAST_CLOCK
952 + * was returned in every case.
953 + * Therefore, all of the dead logic was removed. */
954 + return KW_MMC_BASE_FAST_CLOCK;
958 +static inline u32 kw_mmc_get_base_clock(void)
960 + /* get MMC base clock. If any logic other than just returning
961 + * a fixed value is ever used, remove inline modifier. */
963 + /* Possible values:
964 + * - KW_MMC_BASE_FAST_CLOCK (166 MHz)
965 + * - KW_MMC_BASE_FAST_CLK_100 (100 MHz)
966 + * - KW_MMC_BASE_FAST_CLK_200 (200 MHz)
968 + * Tests have shown that 200 MHz is more reliable than
969 + * 166 MHz, so this value is used. */
970 + return KW_MMC_BASE_FAST_CLK_200;
973 +static void kw_mmc_set_clk(unsigned int clock)
979 + printf("%s: clock off\n", DRIVER_NAME);
981 + kwsd_write(SDIO_XFER_MODE, SDIO_XFER_MODE_STOP_CLK);
982 + kwsd_write(SDIO_CLK_DIV, KW_MMC_BASE_DIV_MAX);
984 + m = kw_mmc_get_base_clock() / (2 * clock) - 1;
985 + if (m > KW_MMC_BASE_DIV_MAX)
986 + m = KW_MMC_BASE_DIV_MAX;
988 + printf("%s: kw_mmc_set_clk: base = %d dividor = 0x%x clock=%d\n", DRIVER_NAME,
989 +w_mmc_get_base_clock(), m, clock);
991 + kwsd_write(SDIO_CLK_DIV, m & KW_MMC_BASE_DIV_MAX);
996 +static void kw_mmc_set_bus(unsigned int bus)
1000 + ctrl_reg = kwsd_read(SDIO_HOST_CTRL);
1001 + ctrl_reg &= ~SDIO_HOST_CTRL_DATA_WIDTH_4_BITS;
1005 + ctrl_reg |= SDIO_HOST_CTRL_DATA_WIDTH_4_BITS;
1009 + ctrl_reg |= SDIO_HOST_CTRL_DATA_WIDTH_1_BIT;
1011 + /* default transfer mode */
1012 + ctrl_reg |= SDIO_HOST_CTRL_BIG_ENDIAN;
1013 + ctrl_reg &= ~SDIO_HOST_CTRL_LSB_FIRST;
1015 + /* default to maximum timeout */
1016 + ctrl_reg |= SDIO_HOST_CTRL_TMOUT(SDIO_HOST_CTRL_TMOUT_MAX);
1018 + ctrl_reg |= SDIO_HOST_CTRL_PUSH_PULL_EN;
1020 + ctrl_reg |= SDIO_HOST_CTRL_CARD_TYPE_MEM_ONLY;
1023 + * The HI_SPEED_EN bit is causing trouble with many (but not all)
1024 + * high speed SD, SDHC and SDIO cards. Not enabling that bit
1025 + * makes all cards work. So let's just ignore that bit for now
1026 + * and revisit this issue if problems for not enabling this bit
1027 + * are ever reported.
1030 + if (ios->timing == MMC_TIMING_MMC_HS ||
1031 + ios->timing == MMC_TIMING_SD_HS)
1032 + ctrl_reg |= SDIO_HOST_CTRL_HI_SPEED_EN;
1036 + printf("%s: ctrl 0x%04x: %s %s %s\n", DRIVER_NAME, ctrl_reg,
1037 + (ctrl_reg & SDIO_HOST_CTRL_PUSH_PULL_EN) ?
1038 + "push-pull" : "open-drain",
1039 + (ctrl_reg & SDIO_HOST_CTRL_DATA_WIDTH_4_BITS) ?
1040 + "4bit-width" : "1bit-width",
1041 + (ctrl_reg & SDIO_HOST_CTRL_HI_SPEED_EN) ?
1042 + "high-speed" : "");
1045 + kwsd_write(SDIO_HOST_CTRL, ctrl_reg);
1049 +static void kw_mmc_set_ios(struct mmc *mmc)
1052 + printf("%s: bus[%d] clock[%d]\n", DRIVER_NAME, mmc->bus_width, mmc->clock);
1054 + kw_mmc_set_bus(mmc->bus_width);
1055 + kw_mmc_set_clk(mmc->clock);
1058 +static int kw_mmc_init(struct mmc *mmc)
1061 + printf("%s: kw_mmc_init\n", DRIVER_NAME);
1065 + * Setting host parameters
1066 + * Initial Host Ctrl : Timeout : max , Normal Speed mode, 4-bit data mode
1067 + * Big Endian, SD memory Card, Push_pull CMD Line
1069 + kwsd_write(SDIO_HOST_CTRL,
1070 + SDIO_HOST_CTRL_TMOUT(SDIO_HOST_CTRL_TMOUT_MAX) |
1071 + SDIO_HOST_CTRL_DATA_WIDTH_4_BITS |
1072 + SDIO_HOST_CTRL_BIG_ENDIAN |
1073 + SDIO_HOST_CTRL_PUSH_PULL_EN |
1074 + SDIO_HOST_CTRL_CARD_TYPE_MEM_ONLY);
1076 + kwsd_write(SDIO_CLK_CTRL, 0);
1078 + /* enable status */
1079 + kwsd_write(SDIO_NOR_STATUS_EN, SDIO_POLL_MASK);
1080 + kwsd_write(SDIO_ERR_STATUS_EN, SDIO_POLL_MASK);
1082 + /* disable interrupts */
1083 + kwsd_write(SDIO_NOR_INTR_EN, 0);
1084 + kwsd_write(SDIO_ERR_INTR_EN, 0);
1087 + kwsd_write(SDIO_SW_RESET, SDIO_SW_RESET_NOW);
1093 +int kw_mmc_initialize(bd_t *bis)
1095 + struct mmc *mmc = NULL;
1096 + struct mmc_config *cfg = NULL;
1097 + struct mmc_ops *ops = NULL;
1098 + char *name = NULL;
1101 + printf("%s: %s base_clock = %d\n", DRIVER_NAME, kirkwood_id(), kw_mmc_get_base_clock());
1103 + mmc = malloc(sizeof(struct mmc));
1106 + memset(mmc, 0, sizeof(*mmc));
1108 + cfg = malloc(sizeof(*cfg));
1111 + memset(cfg, 0, sizeof(*cfg));
1112 + mmc->cfg = cfg; /* provided configuration */
1114 + ops = malloc(sizeof(*ops));
1117 + memset(ops, 0, sizeof(*ops));
1120 + name = malloc(sizeof(DRIVER_NAME)+1);
1125 + sprintf(cfg->name, DRIVER_NAME);
1127 + ops->send_cmd = kw_mmc_send_cmd;
1128 + ops->set_ios = kw_mmc_set_ios;
1129 + ops->init = kw_mmc_init;
1131 + cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
1132 + cfg->host_caps = MMC_MODE_4BIT | MMC_MODE_HS;
1134 + cfg->f_min = kw_mmc_get_base_clock()/KW_MMC_BASE_DIV_MAX;
1135 + cfg->f_max = KW_MMC_CLOCKRATE_MAX;
1136 + cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
1138 + mmc = mmc_create (cfg, NULL);
1140 + if (mmc == NULL) {
1144 + printf("\nFailed to Initialize MMC\n");
1150 --- a/include/configs/mv-common.h
1151 +++ b/include/configs/mv-common.h
1152 @@ -130,4 +130,16 @@
1153 #define CONFIG_MTD_PARTITIONS
1159 +#if defined(CONFIG_KIRKWOOD) && defined(CONFIG_CMD_MMC)
1160 +#define CONFIG_SYS_MMC_BASE KW_SDIO_BASE
1161 +#endif /* defined(CONFIG_KIRKWOOD) && defined(CONFIG_CMD_MMC) */
1164 + * GPIO command for all Kirkwood boxes
1166 +#define CONFIG_CMD_GPIO
1168 #endif /* _MV_COMMON_H */
1170 +++ b/include/configs/pogoplugv4.h
1173 + * Copyright (C) 2014-2016 bodhi <mibodhi@gmail.com>
1176 + * Copyright (C) 2012
1177 + * David Purdy <david.c.purdy@gmail.com>
1179 + * Based on Kirkwood support:
1180 + * (C) Copyright 2009
1181 + * Marvell Semiconductor <www.marvell.com>
1182 + * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
1184 + * See file CREDITS for list of people who contributed to this
1187 + * This program is free software; you can redistribute it and/or
1188 + * modify it under the terms of the GNU General Public License as
1189 + * published by the Free Software Foundation; either version 2 of
1190 + * the License, or (at your option) any later version.
1192 + * This program is distributed in the hope that it will be useful,
1193 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1194 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1195 + * GNU General Public License for more details.
1197 + * You should have received a copy of the GNU General Public License
1198 + * along with this program; If not, see <http://www.gnu.org/licenses/>.
1201 +#ifndef _CONFIG_POGOPLUGV4_H
1202 +#define _CONFIG_POGOPLUGV4_H
1205 + * Machine type definition and ID
1207 +#define MACH_TYPE_POGOPLUGV4 3960
1208 +#define CONFIG_MACH_TYPE MACH_TYPE_POGOPLUGV4
1211 + * High Level Configuration Options (easy to change)
1213 +#define CONFIG_FEROCEON_88FR131 /* #define CPU Core subversion */
1214 +#define CONFIG_KW88F6192 /* SOC Name */
1215 +#define CONFIG_SKIP_LOWLEVEL_INIT /* disable board lowlevel_init */
1218 + * Commands configuration
1221 +#define CONFIG_SYS_LONGHELP
1222 +#define CONFIG_PREBOOT
1225 + * mv-common.h should be defined after CMD configs since it used them
1226 + * to enable certain macros
1228 +#include "mv-common.h"
1231 + * Environment variables configurations
1233 +#ifdef CONFIG_CMD_NAND
1235 +#define CONFIG_ENV_SECT_SIZE 0x20000 /* 128K */
1240 +#define CONFIG_ENV_SIZE 0x20000 /* 128k */
1241 +#define CONFIG_ENV_ADDR 0x1c0000
1242 +#define CONFIG_ENV_OFFSET 0x1c0000 /* env starts here */
1245 + * Default environment variables
1247 +#define CONFIG_BOOTCOMMAND \
1249 + "fatload usb 0:1 0x2000000 initramfs.bin ; "\
1250 + "bootm 0x2000000 ; " \
1251 + "ubi part ubi; " \
1252 + "ubi read 0x800000 kernel; " \
1255 +#define CONFIG_MTDPARTS \
1256 + "mtdparts=orion_nand:" \
1257 + "0x1c0000(uboot)," \
1258 + "0x40000(uboot_env)," \
1259 + "0x7e00000(ubi)\0"
1261 +#define CONFIG_EXTRA_ENV_SETTINGS \
1262 + "console=console=ttyS0,115200\0" \
1263 + "mtdids=nand0=orion_nand\0" \
1264 + "mtdparts="CONFIG_MTDPARTS \
1265 + "bootargs_root=\0"
1268 + * Ethernet Driver configuration
1270 +#ifdef CONFIG_CMD_NET
1271 +#define CONFIG_NETCONSOLE
1272 +#define CONFIG_MVGBE_PORTS {1, 0} /* enable port 0 only */
1273 +#define CONFIG_PHY_BASE_ADR 0
1274 +#endif /* CONFIG_CMD_NET */
1279 +#define CONFIG_JFFS2_NAND
1280 +#define CONFIG_JFFS2_LZO
1281 +#define CONFIG_MTD_DEVICE /* needed for mtdparts commands */
1282 +#define CONFIG_MTD_PARTITIONS
1287 +#ifdef CONFIG_MVSATA_IDE
1288 +#define CONFIG_SYS_ATA_IDE0_OFFSET MV_SATA_PORT0_OFFSET
1294 +#ifdef CONFIG_CMD_DATE
1295 +#define CONFIG_RTC_MV
1296 +#endif /* CONFIG_CMD_DATE */
1301 +#define CONFIG_KIRKWOOD_GPIO
1303 +#endif /* _CONFIG_POGOPLUGV4_H */
1305 +++ b/include/kirkwood_mmc.h
1308 + * (C) Copyright 2014 <ebbes.ebbes@gmail.com>
1312 + * (C) Copyright 2012
1313 + * Marvell Semiconductor <www.marvell.com>
1314 + * Written-by: Gérald Kerma <uboot at doukki.net>
1315 + * See file CREDITS for list of people who contributed to this
1318 + * This program is free software; you can redistribute it and/or
1319 + * modify it under the terms of the GNU General Public License as
1320 + * published by the Free Software Foundation; either version 2 of
1321 + * the License, or (at your option) any later version.
1323 + * This program is distributed in the hope that it will be useful,
1324 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1325 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1326 + * GNU General Public License for more details.
1328 + * You should have received a copy of the GNU General Public License
1329 + * along with this program; if not, write to the Free Software
1330 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1331 + * MA 02111-1307 USA
1334 +#ifndef __KIRKWOOD_MMC_H__
1335 +#define __KIRKWOOD_MMC_H__
1341 +#define KW_MMC_CLOCKRATE_MAX 50000000
1342 +#define KW_MMC_BASE_DIV_MAX 0x7ff
1343 +#define KW_MMC_BASE_FAST_CLOCK CONFIG_SYS_TCLK
1344 +#define KW_MMC_BASE_FAST_CLK_100 100000000
1345 +#define KW_MMC_BASE_FAST_CLK_200 200000000
1350 +#define kwsd_write(offs, val) writel(val, CONFIG_SYS_MMC_BASE + (offs))
1351 +#define kwsd_read(offs) readl(CONFIG_SYS_MMC_BASE + (offs))
1353 +#define KW_MMC_MAKE_CMD(c, f) (((c & 0xff) << 8) | (f & 0xff))
1355 +/* SDIO register */
1356 +#define SDIO_SYS_ADDR_LOW 0x000
1357 +#define SDIO_SYS_ADDR_HI 0x004
1358 +#define SDIO_BLK_SIZE 0x008
1359 +#define SDIO_BLK_COUNT 0x00c
1360 +#define SDIO_ARG_LOW 0x010
1361 +#define SDIO_ARG_HI 0x014
1362 +#define SDIO_XFER_MODE 0x018
1363 +#define SDIO_CMD 0x01c
1364 +#define SDIO_RSP(i) (0x020 + ((i)<<2))
1365 +#define SDIO_RSP0 0x020
1366 +#define SDIO_RSP1 0x024
1367 +#define SDIO_RSP2 0x028
1368 +#define SDIO_RSP3 0x02c
1369 +#define SDIO_RSP4 0x030
1370 +#define SDIO_RSP5 0x034
1371 +#define SDIO_RSP6 0x038
1372 +#define SDIO_RSP7 0x03c
1373 +#define SDIO_BUF_DATA_PORT 0x040
1374 +#define SDIO_RSVED 0x044
1375 +#define SDIO_HW_STATE 0x048
1376 +#define SDIO_PRESENT_STATE0 0x048
1377 +#define SDIO_PRESENT_STATE1 0x04c
1378 +#define SDIO_HOST_CTRL 0x050
1379 +#define SDIO_BLK_GAP_CTRL 0x054
1380 +#define SDIO_CLK_CTRL 0x058
1381 +#define SDIO_SW_RESET 0x05c
1382 +#define SDIO_NOR_INTR_STATUS 0x060
1383 +#define SDIO_ERR_INTR_STATUS 0x064
1384 +#define SDIO_NOR_STATUS_EN 0x068
1385 +#define SDIO_ERR_STATUS_EN 0x06c
1386 +#define SDIO_NOR_INTR_EN 0x070
1387 +#define SDIO_ERR_INTR_EN 0x074
1388 +#define SDIO_AUTOCMD12_ERR_STATUS 0x078
1389 +#define SDIO_CURR_BYTE_LEFT 0x07c
1390 +#define SDIO_CURR_BLK_LEFT 0x080
1391 +#define SDIO_AUTOCMD12_ARG_LOW 0x084
1392 +#define SDIO_AUTOCMD12_ARG_HI 0x088
1393 +#define SDIO_AUTOCMD12_INDEX 0x08c
1394 +#define SDIO_AUTO_RSP(i) (0x090 + ((i)<<2))
1395 +#define SDIO_AUTO_RSP0 0x090
1396 +#define SDIO_AUTO_RSP1 0x094
1397 +#define SDIO_AUTO_RSP2 0x098
1398 +#define SDIO_CLK_DIV 0x128
1400 +#define WINDOW_CTRL(i) (0x108 + ((i) << 3))
1401 +#define WINDOW_BASE(i) (0x10c + ((i) << 3))
1403 +/* SDIO_PRESENT_STATE */
1404 +#define CARD_BUSY (1 << 1)
1405 +#define CMD_INHIBIT (1 << 0)
1406 +#define CMD_TXACTIVE (1 << 8)
1407 +#define CMD_RXACTIVE (1 << 9)
1408 +#define CMD_AUTOCMD12ACTIVE (1 << 14)
1409 +#define CMD_BUS_BUSY (CMD_AUTOCMD12ACTIVE | \
1419 +#define SDIO_CMD_RSP_NONE (0 << 0)
1420 +#define SDIO_CMD_RSP_136 (1 << 0)
1421 +#define SDIO_CMD_RSP_48 (2 << 0)
1422 +#define SDIO_CMD_RSP_48BUSY (3 << 0)
1424 +#define SDIO_CMD_CHECK_DATACRC16 (1 << 2)
1425 +#define SDIO_CMD_CHECK_CMDCRC (1 << 3)
1426 +#define SDIO_CMD_INDX_CHECK (1 << 4)
1427 +#define SDIO_CMD_DATA_PRESENT (1 << 5)
1428 +#define SDIO_UNEXPECTED_RESP (1 << 7)
1430 +#define SDIO_CMD_INDEX(x) ((x) << 8)
1436 +#define SDIO_XFER_MODE_STOP_CLK (1 << 5)
1437 +#define SDIO_XFER_MODE_HW_WR_DATA_EN (1 << 1)
1438 +#define SDIO_XFER_MODE_AUTO_CMD12 (1 << 2)
1439 +#define SDIO_XFER_MODE_INT_CHK_EN (1 << 3)
1440 +#define SDIO_XFER_MODE_TO_HOST (1 << 4)
1441 +#define SDIO_XFER_MODE_DMA (0 << 6)
1447 +#define SDIO_HOST_CTRL_PUSH_PULL_EN (1 << 0)
1449 +#define SDIO_HOST_CTRL_CARD_TYPE_MEM_ONLY (0 << 1)
1450 +#define SDIO_HOST_CTRL_CARD_TYPE_IO_ONLY (1 << 1)
1451 +#define SDIO_HOST_CTRL_CARD_TYPE_IO_MEM_COMBO (2 << 1)
1452 +#define SDIO_HOST_CTRL_CARD_TYPE_IO_MMC (3 << 1)
1453 +#define SDIO_HOST_CTRL_CARD_TYPE_MASK (3 << 1)
1455 +#define SDIO_HOST_CTRL_BIG_ENDIAN (1 << 3)
1456 +#define SDIO_HOST_CTRL_LSB_FIRST (1 << 4)
1457 +#define SDIO_HOST_CTRL_DATA_WIDTH_1_BIT (0 << 9)
1458 +#define SDIO_HOST_CTRL_DATA_WIDTH_4_BITS (1 << 9)
1459 +#define SDIO_HOST_CTRL_HI_SPEED_EN (1 << 10)
1461 +#define SDIO_HOST_CTRL_TMOUT_MAX 0xf
1462 +#define SDIO_HOST_CTRL_TMOUT_MASK (0xf << 11)
1463 +#define SDIO_HOST_CTRL_TMOUT(x) ((x) << 11)
1464 +#define SDIO_HOST_CTRL_TMOUT_EN (1 << 15)
1470 +#define SDIO_SW_RESET_NOW (1 << 8)
1473 + * Normal interrupt status bits
1476 +#define SDIO_NOR_ERROR (1 << 15)
1477 +#define SDIO_NOR_UNEXP_RSP (1 << 14)
1478 +#define SDIO_NOR_AUTOCMD12_DONE (1 << 13)
1479 +#define SDIO_NOR_SUSPEND_ON (1 << 12)
1480 +#define SDIO_NOR_LMB_FF_8W_AVAIL (1 << 11)
1481 +#define SDIO_NOR_LMB_FF_8W_FILLED (1 << 10)
1482 +#define SDIO_NOR_READ_WAIT_ON (1 << 9)
1483 +#define SDIO_NOR_CARD_INT (1 << 8)
1484 +#define SDIO_NOR_READ_READY (1 << 5)
1485 +#define SDIO_NOR_WRITE_READY (1 << 4)
1486 +#define SDIO_NOR_DMA_INI (1 << 3)
1487 +#define SDIO_NOR_BLK_GAP_EVT (1 << 2)
1488 +#define SDIO_NOR_XFER_DONE (1 << 1)
1489 +#define SDIO_NOR_CMD_DONE (1 << 0)
1492 + * Error status bits
1495 +#define SDIO_ERR_CRC_STATUS (1 << 14)
1496 +#define SDIO_ERR_CRC_STARTBIT (1 << 13)
1497 +#define SDIO_ERR_CRC_ENDBIT (1 << 12)
1498 +#define SDIO_ERR_RESP_TBIT (1 << 11)
1499 +#define SDIO_ERR_XFER_SIZE (1 << 10)
1500 +#define SDIO_ERR_CMD_STARTBIT (1 << 9)
1501 +#define SDIO_ERR_AUTOCMD12 (1 << 8)
1502 +#define SDIO_ERR_DATA_ENDBIT (1 << 6)
1503 +#define SDIO_ERR_DATA_CRC (1 << 5)
1504 +#define SDIO_ERR_DATA_TIMEOUT (1 << 4)
1505 +#define SDIO_ERR_CMD_INDEX (1 << 3)
1506 +#define SDIO_ERR_CMD_ENDBIT (1 << 2)
1507 +#define SDIO_ERR_CMD_CRC (1 << 1)
1508 +#define SDIO_ERR_CMD_TIMEOUT (1 << 0)
1509 +#define SDIO_POLL_MASK 0xffff /* enable all for polling */
1511 +#define MMC_BLOCK_SIZE 512
1514 + * CMD12 error status bits
1517 +#define SDIO_AUTOCMD12_ERR_NOTEXE (1 << 0)
1518 +#define SDIO_AUTOCMD12_ERR_TIMEOUT (1 << 1)
1519 +#define SDIO_AUTOCMD12_ERR_CRC (1 << 2)
1520 +#define SDIO_AUTOCMD12_ERR_ENDBIT (1 << 3)
1521 +#define SDIO_AUTOCMD12_ERR_INDEX (1 << 4)
1522 +#define SDIO_AUTOCMD12_ERR_RESP_T_BIT (1 << 5)
1523 +#define SDIO_AUTOCMD12_ERR_RESP_STARTBIT (1 << 6)
1525 +#define MMC_RSP_PRESENT (1 << 0)
1526 +#define MMC_RSP_136 (1 << 1) /* 136 bit response */
1527 +#define MMC_RSP_CRC (1 << 2) /* expect valid crc */
1528 +#define MMC_RSP_BUSY (1 << 3) /* card may send busy */
1529 +#define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */
1531 +#define MMC_BUSMODE_OPENDRAIN 1
1532 +#define MMC_BUSMODE_PUSHPULL 2
1534 +#define MMC_BUS_WIDTH_1 0
1535 +#define MMC_BUS_WIDTH_4 2
1536 +#define MMC_BUS_WIDTH_8 3
1538 +#define MMC_CAP_4_BIT_DATA (1 << 0) /* Can the host do 4 bit transfers */
1539 +#define MMC_CAP_MMC_HIGHSPEED (1 << 1) /* Can do MMC high-speed timing */
1540 +#define MMC_CAP_SD_HIGHSPEED (1 << 2) /* Can do SD high-speed timing */
1541 +#define MMC_CAP_SDIO_IRQ (1 << 3) /* Can signal pending SDIO IRQs */
1542 +#define MMC_CAP_SPI (1 << 4) /* Talks only SPI protocols */
1543 +#define MMC_CAP_NEEDS_POLL (1 << 5) /* Needs polling for card-detection */
1544 +#define MMC_CAP_8_BIT_DATA (1 << 6) /* Can the host do 8 bit transfers */
1546 +#define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */
1547 +#define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */
1548 +#define MMC_CAP_ERASE (1 << 10) /* Allow erase/trim commands */
1549 +#define MMC_CAP_1_8V_DDR (1 << 11) /* can support */
1550 + /* DDR mode at 1.8V */
1551 +#define MMC_CAP_1_2V_DDR (1 << 12) /* can support */
1552 + /* DDR mode at 1.2V */
1553 +#define MMC_CAP_POWER_OFF_CARD (1 << 13) /* Can power off after boot */
1554 +#define MMC_CAP_BUS_WIDTH_TEST (1 << 14) /* CMD14/CMD19 bus width ok */
1555 +#define MMC_CAP_UHS_SDR12 (1 << 15) /* Host supports UHS SDR12 mode */
1556 +#define MMC_CAP_UHS_SDR25 (1 << 16) /* Host supports UHS SDR25 mode */
1557 +#define MMC_CAP_UHS_SDR50 (1 << 17) /* Host supports UHS SDR50 mode */
1558 +#define MMC_CAP_UHS_SDR104 (1 << 18) /* Host supports UHS SDR104 mode */
1559 +#define MMC_CAP_UHS_DDR50 (1 << 19) /* Host supports UHS DDR50 mode */
1560 +#define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */
1561 +#define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */
1562 +#define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */
1563 +#define MMC_CAP_CMD23 (1 << 30) /* CMD23 supported. */
1564 +#define MMC_CAP_HW_RESET (1 << 31) /* Hardware reset */
1567 + * Functions prototypes
1569 + * Original patch had static function declarations in this header file.
1570 + * Those should rather not be declared in the header as they only cause compiler warnings.
1572 +int kw_mmc_initialize(bd_t *bis);
1574 +#endif /* __KIRKWOOD_MMC_H__ */