diff options
110 files changed, 2105 insertions, 938 deletions
@@ -1,5 +1,5 @@ VERSION = 2013 -PATCHLEVEL = 04 +PATCHLEVEL = 05 SUBLEVEL = 0 EXTRAVERSION = NAME = Amissive Actinocutious Kiwi @@ -667,9 +667,6 @@ define rule_barebox-modpost $(Q)echo 'cmd_$@ := $(cmd_barebox-modpost)' > $(dot-target).cmd endef -quiet_cmd_objcopy = OBJCOPY $@ - cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ - OBJCOPYFLAGS_barebox.bin = -O binary barebox.bin: barebox FORCE diff --git a/arch/arm/boards/at91sam9m10g45ek/init.c b/arch/arm/boards/at91sam9m10g45ek/init.c index f32215deef..d9a2f1f28f 100644 --- a/arch/arm/boards/at91sam9m10g45ek/init.c +++ b/arch/arm/boards/at91sam9m10g45ek/init.c @@ -38,6 +38,7 @@ #include <mach/at91sam9_smc.h> #include <gpio_keys.h> #include <readkey.h> +#include <spi/spi.h> /* * board revision encoding @@ -125,6 +126,22 @@ static void ek_add_device_mci(void) static void ek_add_device_mci(void) {} #endif +static const struct spi_board_info ek_spi_devices[] = { + { + .name = "mtd_dataflash", + .chip_select = 0, + .max_speed_hz = 15 * 1000 * 1000, + .bus_num = 0, + } +}; + +static void ek_add_device_spi(void) +{ + spi_register_board_info(ek_spi_devices, + ARRAY_SIZE(ek_spi_devices)); + at91_add_device_spi(0, NULL); +} + #ifdef CONFIG_LED_GPIO struct gpio_led ek_leds[] = { { @@ -281,6 +298,7 @@ static void ek_add_device_lcdc(void) {} static int at91sam9m10g45ek_devices_init(void) { ek_add_device_nand(); + ek_add_device_spi(); at91_add_device_eth(0, &macb_pdata); ek_add_device_mci(); ek_add_device_usb(); diff --git a/arch/arm/boards/beaglebone/lowlevel.c b/arch/arm/boards/beaglebone/lowlevel.c index a9737d9f93..28959ff9ab 100644 --- a/arch/arm/boards/beaglebone/lowlevel.c +++ b/arch/arm/boards/beaglebone/lowlevel.c @@ -55,7 +55,7 @@ static void beaglebone_data_macro_config(int dataMacroNum) { - u32 BaseAddrOffset = 0x00;; + u32 BaseAddrOffset = 0x00; if (dataMacroNum == 1) BaseAddrOffset = 0xA4; diff --git a/arch/arm/boards/ccxmx51/ccxmx51.c b/arch/arm/boards/ccxmx51/ccxmx51.c index a14c9bc876..df565d97d5 100644 --- a/arch/arm/boards/ccxmx51/ccxmx51.c +++ b/arch/arm/boards/ccxmx51/ccxmx51.c @@ -196,7 +196,8 @@ static const struct spi_board_info ccxmx51_spi_board_info[] = { }; static struct imxusb_platformdata ccxmx51_otg_pdata = { - .flags = MXC_EHCI_MODE_UTMI_16_BIT | MXC_EHCI_POWER_PINS_ENABLED, + .flags = MXC_EHCI_MODE_UTMI_16_BIT | MXC_EHCI_INTERNAL_PHY | + MXC_EHCI_POWER_PINS_ENABLED, .mode = IMX_USB_MODE_HOST, }; diff --git a/arch/arm/boards/ccxmx51/ccxmx51js.c b/arch/arm/boards/ccxmx51/ccxmx51js.c index 8c1d2dcd63..ae31cafedf 100644 --- a/arch/arm/boards/ccxmx51/ccxmx51js.c +++ b/arch/arm/boards/ccxmx51/ccxmx51js.c @@ -20,6 +20,8 @@ #include <init.h> #include <mci.h> #include <asm/armlinux.h> +#include <mach/gpio.h> +#include <mach/generic.h> #include <mach/imx51-regs.h> #include <mach/iomux-mx51.h> #include <mach/devices-imx51.h> @@ -27,6 +29,8 @@ #include "ccxmx51.h" +#define CCXMX51JS_USBHOST1_RESET IMX_GPIO_NR(3, 8) + static iomux_v3_cfg_t ccxmx51js_pads[] = { /* SD1 */ MX51_PAD_SD1_CLK__SD1_CLK, @@ -74,6 +78,11 @@ static struct esdhc_platform_data sdhc3_pdata = { .caps = MMC_MODE_4BIT | MMC_MODE_8BIT, }; +static struct imxusb_platformdata ccxmx51js_usbhost1_pdata = { + .flags = MXC_EHCI_MODE_ULPI | MXC_EHCI_ITC_NO_THRESHOLD, + .mode = IMX_USB_MODE_HOST, +}; + static int ccxmx51js_init(void) { mxc_iomux_v3_setup_multiple_pads(ccxmx51js_pads, ARRAY_SIZE(ccxmx51js_pads)); @@ -83,6 +92,12 @@ static int ccxmx51js_init(void) imx51_add_mmc2(&sdhc3_pdata); } + gpio_direction_output(CCXMX51JS_USBHOST1_RESET, 0); + mdelay(10); + gpio_set_value(CCXMX51JS_USBHOST1_RESET, 1); + mdelay(10); + imx51_add_usbh1(&ccxmx51js_usbhost1_pdata); + armlinux_set_architecture(ccxmx51_id->wless ? MACH_TYPE_CCWMX51JS : MACH_TYPE_CCMX51JS); return 0; diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c index fd5bc4c07e..720fe325d4 100644 --- a/arch/arm/boards/chumby_falconwing/falconwing.c +++ b/arch/arm/boards/chumby_falconwing/falconwing.c @@ -293,7 +293,7 @@ static int falconwing_devices_init(void) imx_set_ioclk(480000000); /* enable IOCLK to run at the PLL frequency */ /* run the SSP unit clock at 100,000 kHz */ imx_set_sspclk(0, 100000000, 1); - add_generic_device("mxs_mci", 0, NULL, IMX_SSP1_BASE, 0, + add_generic_device("mxs_mci", 0, NULL, IMX_SSP1_BASE, 0x2000, IORESOURCE_MEM, &mci_pdata); add_generic_device("stmfb", 0, NULL, IMX_FB_BASE, 4096, IORESOURCE_MEM, &fb_mode); diff --git a/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c b/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c index 5e77f90322..523a805dcb 100644 --- a/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c +++ b/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c @@ -55,23 +55,23 @@ static iomux_v3_cfg_t eukrea_cpuimx51_pads[] = { MX51_PAD_UART1_RTS__UART1_RTS, MX51_PAD_UART1_CTS__UART1_CTS, /* FEC */ - MX51_PAD_DISP2_DAT1__FEC_RX_ER, + NEW_PAD_CTRL(MX51_PAD_DISP2_DAT1__FEC_RX_ER, MX51_PAD_CTRL_5), MX51_PAD_DISP2_DAT15__FEC_TDATA0, MX51_PAD_DISP2_DAT6__FEC_TDATA1, MX51_PAD_DISP2_DAT7__FEC_TDATA2, MX51_PAD_DISP2_DAT8__FEC_TDATA3, MX51_PAD_DISP2_DAT9__FEC_TX_EN, - MX51_PAD_DISP2_DAT10__FEC_COL, - MX51_PAD_DISP2_DAT11__FEC_RX_CLK, - MX51_PAD_DISP2_DAT12__FEC_RX_DV, + NEW_PAD_CTRL(MX51_PAD_DISP2_DAT10__FEC_COL, MX51_PAD_CTRL_5), + NEW_PAD_CTRL(MX51_PAD_DISP2_DAT11__FEC_RX_CLK, MX51_PAD_CTRL_5), + NEW_PAD_CTRL(MX51_PAD_DISP2_DAT12__FEC_RX_DV, MX51_PAD_CTRL_5), MX51_PAD_DISP2_DAT13__FEC_TX_CLK, MX51_PAD_DI2_PIN4__FEC_CRS, MX51_PAD_DI2_PIN2__FEC_MDC, - MX51_PAD_DI2_PIN3__FEC_MDIO, + NEW_PAD_CTRL(MX51_PAD_DI2_PIN3__FEC_MDIO, MX51_PAD_CTRL_5), MX51_PAD_DISP2_DAT14__FEC_RDATA0, MX51_PAD_DI2_DISP_CLK__FEC_RDATA1, - MX51_PAD_DI_GP4__FEC_RDATA2, - MX51_PAD_DISP2_DAT0__FEC_RDATA3, + NEW_PAD_CTRL(MX51_PAD_DI_GP4__FEC_RDATA2, MX51_PAD_CTRL_5), + NEW_PAD_CTRL(MX51_PAD_DISP2_DAT0__FEC_RDATA3, MX51_PAD_CTRL_5), MX51_PAD_DI_GP3__FEC_TX_ER, MX51_PAD_EIM_DTACK__GPIO2_31, /* LAN8700 reset pin */ /* NAND */ diff --git a/arch/arm/boards/highbank/env/boot.d/010-ahci-boot b/arch/arm/boards/highbank/env/boot.d/010-ahci-boot new file mode 120000 index 0000000000..3672f0495e --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/010-ahci-boot @@ -0,0 +1 @@ +../boot/ahci-boot
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot.d/011-ahci b/arch/arm/boards/highbank/env/boot.d/011-ahci new file mode 120000 index 0000000000..36b3b2815b --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/011-ahci @@ -0,0 +1 @@ +../boot/ahci
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot.d/020-mmc-boot b/arch/arm/boards/highbank/env/boot.d/020-mmc-boot new file mode 120000 index 0000000000..85c19bbd66 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/020-mmc-boot @@ -0,0 +1 @@ +../boot/mmc-boot
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot.d/021-mmc b/arch/arm/boards/highbank/env/boot.d/021-mmc new file mode 120000 index 0000000000..5af95d0ac7 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/021-mmc @@ -0,0 +1 @@ +../boot/mmc
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot.d/030-net b/arch/arm/boards/highbank/env/boot.d/030-net new file mode 120000 index 0000000000..70b8ea3965 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/030-net @@ -0,0 +1 @@ +../boot/net
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot.d/031-net-eth1 b/arch/arm/boards/highbank/env/boot.d/031-net-eth1 new file mode 120000 index 0000000000..5a30a308c7 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/031-net-eth1 @@ -0,0 +1 @@ +../boot/net-eth1
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot/ahci b/arch/arm/boards/highbank/env/boot/ahci new file mode 100644 index 0000000000..3bdb809932 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/ahci @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "AHCI" + exit +fi + +path="/mnt/ahci" + +global.bootm.image="${path}/zImage" + +. /env/data/oftree + +oftree=${path}/oftree +if [ -f $oftree ]; then + global.bootm.oftree="$oftree" +fi + +# The rootdevice may actually be mmcblk1p2 if a card +# is inserted to the back MMC slot +global.linux.bootargs.dyn.root="root=/dev/sda2" diff --git a/arch/arm/boards/highbank/env/boot/ahci-boot b/arch/arm/boards/highbank/env/boot/ahci-boot new file mode 100644 index 0000000000..0064a46fcc --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/ahci-boot @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "AHCI (UEFI boot partiton)" + exit +fi + +path="/mnt/ahci-boot" + +global.bootm.image="${path}/zImage" + +. /env/data/oftree + +oftree=${path}/oftree +if [ -f $oftree ]; then + global.bootm.oftree="$oftree" +fi + +# The rootdevice may actually be mmcblk1p2 if a card +# is inserted to the back MMC slot +global.linux.bootargs.dyn.root="root=/dev/sda2" diff --git a/arch/arm/boards/highbank/env/boot/mmc b/arch/arm/boards/highbank/env/boot/mmc new file mode 100644 index 0000000000..43a04b5d6b --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/mmc @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "MMC slot" + exit +fi + +path="/mnt/mmc" + +global.bootm.image="${path}/zimage" + +. /env/data/oftree + +oftree=${path}/oftree +if [ -f $oftree ]; then + global.bootm.oftree="$oftree" +fi + +# The rootdevice may actually be mmcblk1p2 if a card +# is inserted to the back MMC slot +global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2" diff --git a/arch/arm/boards/highbank/env/boot/mmc-boot b/arch/arm/boards/highbank/env/boot/mmc-boot new file mode 100644 index 0000000000..93cd99b684 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/mmc-boot @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "MMC slot (UEFI boot partiton)" + exit +fi + +path="/mnt/mmc-boot" + +global.bootm.image="${path}/zimage" + +. /env/data/oftree + +oftree=${path}/oftree +if [ -f $oftree ]; then + global.bootm.oftree="$oftree" +fi + +# The rootdevice may actually be mmcblk1p2 if a card +# is inserted to the back MMC slot +global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2" diff --git a/arch/arm/boards/highbank/env/boot/net b/arch/arm/boards/highbank/env/boot/net new file mode 100644 index 0000000000..80862cdac1 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/net @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "network (tftp, nfs) (eth0)" + exit +fi + +ethact eth0 + +path="/mnt/tftp" + +. /env/data/oftree + +global.bootm.image="${path}/${global.user}-linux-${global.hostname}" +#global.bootm.oftree="${path}/${global.user}-oftree-${global.hostname}" +nfsroot="/home/${global.user}/nfsroot/${global.hostname}" +bootargs-ip +global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp" diff --git a/arch/arm/boards/highbank/env/boot/net-eth1 b/arch/arm/boards/highbank/env/boot/net-eth1 new file mode 100644 index 0000000000..d9e9804a02 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/net-eth1 @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "network (tftp, nfs) (eth1)" + exit +fi + +ethact eth1 + +path="/mnt/tftp" + +. /env/data/oftree + +global.bootm.image="${path}/${global.user}-linux-${global.hostname}" +#global.bootm.oftree="${path}/${global.user}-oftree-${global.hostname}" +nfsroot="/home/${global.user}/nfsroot/${global.hostname}" +bootargs-ip +global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp" diff --git a/arch/arm/boards/highbank/env/config b/arch/arm/boards/highbank/env/config deleted file mode 100644 index 1bb2c493b2..0000000000 --- a/arch/arm/boards/highbank/env/config +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -# use 'dhcp' to do dhcp in barebox and in kernel -# use 'none' if you want to skip kernel ip autoconfiguration -ip=dhcp -global.dhcp.vendor_id=barebox-highbank - -# or set your networking parameters here -#eth0.ipaddr=a.b.c.d -#eth0.netmask=a.b.c.d -#eth0.gateway=a.b.c.d -#eth0.serverip=a.b.c.d - -# can be either 'nfs', 'tftp' or 'nor' -kernel_loc=tftp -# can be either 'net', 'nor' or 'initrd' -rootfs_loc=initrd - -# can be either 'jffs2' or 'ubifs' -rootfs_type=ubifs -rootfsimage=root.$rootfs_type - -kernelimage=zImage -#kernelimage=uImage -#kernelimage=Image -#kernelimage=Image.lzo - -autoboot_timeout=3 - -bootargs="console=ttyAMA0,115200n8 CONSOLE=/dev/ttyAMA0" - -# set a fancy prompt (if support is compiled in) -PS1="\e[1;31m[barebox@\h]:\w\e[0m\n# " diff --git a/arch/arm/boards/highbank/env/config-board b/arch/arm/boards/highbank/env/config-board new file mode 100644 index 0000000000..a64d9e3245 --- /dev/null +++ b/arch/arm/boards/highbank/env/config-board @@ -0,0 +1,11 @@ +#!/bin/sh + +# board defaults, do not change in running system. Change /env/config +# instead + +global.hostname=highbank +global.allow_color=true +global.autoboot_timeout=3 +global.bootm.oftree="/dev/dtb" +global.linux.bootargs.base="console=ttyAMA0,115200n8 CONSOLE=/dev/ttyAMA0" +global.boot.default=/env/boot.d diff --git a/arch/arm/boards/highbank/env/data/oftree b/arch/arm/boards/highbank/env/data/oftree new file mode 100644 index 0000000000..9a94b310c3 --- /dev/null +++ b/arch/arm/boards/highbank/env/data/oftree @@ -0,0 +1,4 @@ +#!/bin/sh + +#device tree provided by the firmware +global.bootm.oftree="/dev/dtb" diff --git a/arch/arm/boards/highbank/env/bin/init_board b/arch/arm/boards/highbank/env/init/001-dtb-probe index 610db1500e..610db1500e 100644 --- a/arch/arm/boards/highbank/env/bin/init_board +++ b/arch/arm/boards/highbank/env/init/001-dtb-probe diff --git a/arch/arm/boards/highbank/env/init/automount b/arch/arm/boards/highbank/env/init/automount new file mode 100644 index 0000000000..2c283c6eed --- /dev/null +++ b/arch/arm/boards/highbank/env/init/automount @@ -0,0 +1,27 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + init-menu-add-entry "$0" "Automountpoints" + exit +fi + +# automount tftp server based on $eth0.serverip + +mkdir -p /mnt/tftp +automount /mnt/tftp 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp' + +# SD card slot, boot partition +mkdir -p /mnt/mmc-boot +automount -d /mnt/mmc 'mount /dev/disk0.boot /mnt/mmc-boot' + +# SD card slot, first partition +mkdir -p /mnt/mmc +automount -d /mnt/mmc 'mount /dev/disk0.0 /mnt/mmc' + +# AHCI, boot partition +mkdir -p /mnt/ahci-boot +automount -d /mnt/ahci 'mount /dev/ata0.boot /mnt/ahci-boot' + +# AHCI, first partition +mkdir -p /mnt/ahci +automount -d /mnt/ahci 'mount /dev/ata0.0 /mnt/ahci' diff --git a/arch/arm/boards/highbank/env/init/ps1 b/arch/arm/boards/highbank/env/init/ps1 new file mode 100644 index 0000000000..a94acc14f8 --- /dev/null +++ b/arch/arm/boards/highbank/env/init/ps1 @@ -0,0 +1,9 @@ +#!/bin/sh + +/env/config + +if [ ${global.allow_color} = "true" ]; then + export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m\n# " +else + export PS1="barebox@\h:\w\n# " +fi diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c index df8b1f949c..4b2fa6c6ca 100644 --- a/arch/arm/boards/pcm038/pcm038.c +++ b/arch/arm/boards/pcm038/pcm038.c @@ -46,12 +46,15 @@ #include "pll.h" +#define PCM038_GPIO_FEC_RST (GPIO_PORTC + 30) +#define PCM038_GPIO_SPI_CS0 (GPIO_PORTD + 28) + static struct fec_platform_data fec_info = { .xcv_type = PHY_INTERFACE_MODE_MII, .phy_addr = 1, }; -static int pcm038_spi_cs[] = {GPIO_PORTD + 28}; +static int pcm038_spi_cs[] = { PCM038_GPIO_SPI_CS0 }; static struct spi_imx_master pcm038_spi_0_data = { .chipselect = pcm038_spi_cs, @@ -191,6 +194,7 @@ static int pcm038_devices_init(void) long sram_size; unsigned int mode[] = { + /* FEC */ PD0_AIN_FEC_TXD0, PD1_AIN_FEC_TXD1, PD2_AIN_FEC_TXD2, @@ -209,16 +213,19 @@ static int pcm038_devices_init(void) PD15_AOUT_FEC_COL, PD16_AIN_FEC_TX_ER, PF23_AIN_FEC_TX_EN, + PCM038_GPIO_FEC_RST | GPIO_GPIO | GPIO_OUT, + /* UART1 */ PE12_PF_UART1_TXD, PE13_PF_UART1_RXD, PE14_PF_UART1_CTS, PE15_PF_UART1_RTS, + /* CSPI1 */ PD25_PF_CSPI1_RDY, - GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT, + PCM038_GPIO_SPI_CS0 | GPIO_GPIO | GPIO_OUT, PD29_PF_CSPI1_SCLK, PD30_PF_CSPI1_MISO, PD31_PF_CSPI1_MOSI, - /* display */ + /* Display */ PA5_PF_LSCLK, PA6_PF_LD0, PA7_PF_LD1, @@ -298,6 +305,7 @@ static int pcm038_devices_init(void) /* Register the fec device after the PLL re-initialisation * as the fec depends on the (now higher) ipg clock */ + gpio_set_value(PCM038_GPIO_FEC_RST, 1); imx27_add_fec(&fec_info); switch (bootsource_get()) { diff --git a/arch/arm/configs/at91sam9m10g45ek_defconfig b/arch/arm/configs/at91sam9m10g45ek_defconfig index 1df34f7511..7e05e95760 100644 --- a/arch/arm/configs/at91sam9m10g45ek_defconfig +++ b/arch/arm/configs/at91sam9m10g45ek_defconfig @@ -64,8 +64,10 @@ CONFIG_NET_RESOLV=y CONFIG_DRIVER_NET_MACB=y CONFIG_NET_USB=y CONFIG_NET_USB_ASIX=y -# CONFIG_SPI is not set +CONFIG_DRIVER_SPI_ATMEL=y CONFIG_MTD=y +# CONFIG_MTD_OOB_DEVICE is not set +CONFIG_MTD_DATAFLASH=y CONFIG_NAND=y # CONFIG_NAND_ECC_HW is not set # CONFIG_NAND_ECC_HW_SYNDROME is not set diff --git a/arch/arm/configs/phycard_a_l1_defconfig b/arch/arm/configs/phycard_a_l1_defconfig index d90a333e0a..fabaa2d688 100644 --- a/arch/arm/configs/phycard_a_l1_defconfig +++ b/arch/arm/configs/phycard_a_l1_defconfig @@ -7,7 +7,6 @@ CONFIG_CPU_V7=y CONFIG_CPU_32v7=y CONFIG_BOARDINFO="Phytec phyCARD-A-L1" CONFIG_ARCH_OMAP3=y -CONFIG_OMAP_CLOCK_ALL=y CONFIG_OMAP_CLOCK_SOURCE_S32K=y CONFIG_OMAP3_CLOCK_CONFIG=y CONFIG_OMAP3_COPY_CLOCK_SRAM=n diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c index 34fe5c3515..e3ea3b6b9e 100644 --- a/arch/arm/cpu/mmu.c +++ b/arch/arm/cpu/mmu.c @@ -189,7 +189,7 @@ static int arm_mmu_remap_sdram(struct memory_bank *bank) ptes, ttb_start, ttb_end); for (i = 0; i < num_ptes; i++) { - ptes[i] = (phys + i * 4096) | PTE_TYPE_SMALL | + ptes[i] = (phys + i * PAGE_SIZE) | PTE_TYPE_SMALL | pte_flags_cached; } @@ -300,7 +300,7 @@ static int mmu_init(void) asm volatile ("mcr p15,0,%0,c3,c0,0" : : "r"(i) /*:*/); /* create a flat mapping using 1MiB sections */ - create_sections(0, 0, 4096, PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | + create_sections(0, 0, PAGE_SIZE, PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT); vectors_init(); @@ -332,7 +332,7 @@ void *dma_alloc_coherent(size_t size) void *ret; size = PAGE_ALIGN(size); - ret = xmemalign(4096, size); + ret = xmemalign(PAGE_SIZE, size); dma_inv_range((unsigned long)ret, (unsigned long)ret + size); @@ -353,6 +353,7 @@ void *phys_to_virt(unsigned long phys) void dma_free_coherent(void *mem, size_t size) { + size = PAGE_ALIGN(size); remap_range(mem, size, pte_flags_cached); free(mem); diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c index c2618c7b56..0e39a526d2 100644 --- a/arch/arm/mach-at91/gpio.c +++ b/arch/arm/mach-at91/gpio.c @@ -185,10 +185,10 @@ static struct at91_pinctrl_mux_ops at91sam9x5_ops = { int at91_mux_pin(unsigned pin, enum at91_mux mux, int use_pullup) { struct at91_gpio_chip *at91_gpio = pin_to_controller(pin); - void __iomem *pio = at91_gpio->regbase; + void __iomem *pio; + struct device_d *dev; unsigned mask = pin_to_mask(pin); int bank = pin_to_bank(pin); - struct device_d *dev = at91_gpio->chip.dev; if (!at91_gpio) return -EINVAL; @@ -197,6 +197,7 @@ int at91_mux_pin(unsigned pin, enum at91_mux mux, int use_pullup) if (!pio) return -EINVAL; + dev = at91_gpio->chip.dev; at91_mux_disable_interrupt(pio, mask); pin %= MAX_NB_GPIO_PER_BANK; diff --git a/arch/arm/mach-at91/sam9_smc.c b/arch/arm/mach-at91/sam9_smc.c index b48275e07e..a137da4266 100644 --- a/arch/arm/mach-at91/sam9_smc.c +++ b/arch/arm/mach-at91/sam9_smc.c @@ -120,12 +120,12 @@ void sam9_smc_read(int id, int cs, struct sam9_smc_config *config) static int at91sam9_smc_probe(struct device_d *dev) { - int id; + int id = dev->id; - if (dev->id < 0) { + if (id < 0) { id = 0; - } else if (dev->id > 1) { - dev_warn(dev, ": id > 2\n"); + } else if (id > 1) { + dev_warn(dev, "id > 1\n"); return -EIO; } diff --git a/arch/arm/mach-highbank/Kconfig b/arch/arm/mach-highbank/Kconfig index 47c6405eb1..9cfe53968b 100644 --- a/arch/arm/mach-highbank/Kconfig +++ b/arch/arm/mach-highbank/Kconfig @@ -12,6 +12,7 @@ choice config MACH_HIGHBANK bool "Calxeda Highbank" + select HAVE_DEFAULT_ENVIRONMENT_NEW endchoice diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 8ddec9d605..359b5cd091 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -17,9 +17,9 @@ config ARCH_TEXT_BASE default 0x87f00000 if MACH_PCM043 default 0x08f80000 if MACH_SCB9328 default 0xa7e00000 if MACH_NESO - default 0x97f00000 if MACH_MX51_PDK - default 0x7ff00000 if MACH_MX53_LOCO - default 0x7ff00000 if MACH_MX53_SMD + default 0x97f00000 if MACH_FREESCALE_MX51_PDK + default 0x7ff00000 if MACH_FREESCALE_MX53_LOCO + default 0x7ff00000 if MACH_FREESCALE_MX53_SMD default 0x87f00000 if MACH_GUF_CUPID default 0x93d00000 if MACH_TX25 default 0x7ff00000 if MACH_TQMA53 @@ -165,44 +165,53 @@ choice config ARCH_IMX1 bool "i.MX1" select CPU_ARM920T + select PINCTRL_IMX_IOMUX_V1 config ARCH_IMX21 bool "i.MX21" select CPU_ARM926T + select PINCTRL_IMX_IOMUX_V1 config ARCH_IMX25 bool "i.MX25" select CPU_ARM926T select ARCH_HAS_FEC_IMX + select PINCTRL_IMX_IOMUX_V3 config ARCH_IMX27 bool "i.MX27" select CPU_ARM926T select ARCH_HAS_FEC_IMX + select PINCTRL_IMX_IOMUX_V1 config ARCH_IMX31 select CPU_V6 bool "i.MX31" + select PINCTRL_IMX_IOMUX_V2 config ARCH_IMX35 bool "i.MX35" select CPU_V6 select ARCH_HAS_FEC_IMX + select PINCTRL_IMX_IOMUX_V3 config ARCH_IMX51 bool "i.MX51" select CPU_V7 select ARCH_HAS_FEC_IMX + select PINCTRL_IMX_IOMUX_V3 config ARCH_IMX53 bool "i.MX53" select CPU_V7 select ARCH_HAS_FEC_IMX + select PINCTRL_IMX_IOMUX_V3 config ARCH_IMX6 bool "i.MX6" select ARCH_HAS_FEC_IMX select CPU_V7 + select PINCTRL_IMX_IOMUX_V3 endchoice diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index ff8f15b8c0..72125e775b 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -1,14 +1,14 @@ -obj-y += clocksource.o gpio.o -obj-$(CONFIG_ARCH_IMX1) += imx1.o iomux-v1.o clk-imx1.o -obj-$(CONFIG_ARCH_IMX25) += imx25.o iomux-v3.o clk-imx25.o -obj-$(CONFIG_ARCH_IMX21) += imx21.o iomux-v1.o clk-imx21.o -obj-$(CONFIG_ARCH_IMX27) += imx27.o iomux-v1.o clk-imx27.o -obj-$(CONFIG_ARCH_IMX31) += imx31.o iomux-v2.o clk-imx31.o -obj-$(CONFIG_ARCH_IMX35) += imx35.o iomux-v3.o clk-imx35.o -obj-$(CONFIG_ARCH_IMX51) += imx51.o iomux-v3.o imx5.o clk-imx5.o -obj-$(CONFIG_ARCH_IMX53) += imx53.o iomux-v3.o imx5.o clk-imx5.o esdctl-v4.o +obj-y += clocksource.o +obj-$(CONFIG_ARCH_IMX1) += imx1.o clk-imx1.o +obj-$(CONFIG_ARCH_IMX25) += imx25.o clk-imx25.o +obj-$(CONFIG_ARCH_IMX21) += imx21.o clk-imx21.o +obj-$(CONFIG_ARCH_IMX27) += imx27.o clk-imx27.o +obj-$(CONFIG_ARCH_IMX31) += imx31.o clk-imx31.o +obj-$(CONFIG_ARCH_IMX35) += imx35.o clk-imx35.o +obj-$(CONFIG_ARCH_IMX51) += imx51.o imx5.o clk-imx5.o +obj-$(CONFIG_ARCH_IMX53) += imx53.o imx5.o clk-imx5.o esdctl-v4.o pbl-$(CONFIG_ARCH_IMX53) += imx53.o imx5.o esdctl-v4.o -obj-$(CONFIG_ARCH_IMX6) += imx6.o iomux-v3.o usb-imx6.o clk-imx6.o +obj-$(CONFIG_ARCH_IMX6) += imx6.o usb-imx6.o clk-imx6.o lwl-$(CONFIG_ARCH_IMX6) += imx6-mmdc.o obj-$(CONFIG_IMX_IIM) += iim.o obj-$(CONFIG_NAND_IMX) += nand.o diff --git a/arch/arm/mach-imx/include/mach/iomux-mx27.h b/arch/arm/mach-imx/include/mach/iomux-mx27.h index 7d2496708e..b6e334559d 100644 --- a/arch/arm/mach-imx/include/mach/iomux-mx27.h +++ b/arch/arm/mach-imx/include/mach/iomux-mx27.h @@ -25,12 +25,6 @@ #define PA2_PF_USBH2_DATA7 (GPIO_PORTA | GPIO_PF | 2) #define PA3_PF_USBH2_NXT (GPIO_PORTA | GPIO_PF | 3) #define PA4_PF_USBH2_STP (GPIO_PORTA | GPIO_PF | 4) -#define PB4_PF_SD2_D0 (GPIO_PORTB | GPIO_PF | 4) -#define PB5_PF_SD2_D1 (GPIO_PORTB | GPIO_PF | 5) -#define PB6_PF_SD2_D2 (GPIO_PORTB | GPIO_PF | 6) -#define PB7_PF_SD2_D3 (GPIO_PORTB | GPIO_PF | 7) -#define PB8_PF_SD2_CMD (GPIO_PORTB | GPIO_PF | 8) -#define PB9_PF_SD2_CLK (GPIO_PORTB | GPIO_PF | 9) #define PB22_PF_USBH1_SUSP (GPIO_PORTB | GPIO_PF | 22) #define PB25_PF_USBH1_RCV (GPIO_PORTB | GPIO_PF | 25) #define PC5_PF_I2C2_SDA (GPIO_PORTC | GPIO_PF | GPIO_IN | 5) diff --git a/arch/arm/mach-imx/include/mach/iomux-mx2x.h b/arch/arm/mach-imx/include/mach/iomux-mx2x.h index 2f9560fa71..15c2e2b060 100644 --- a/arch/arm/mach-imx/include/mach/iomux-mx2x.h +++ b/arch/arm/mach-imx/include/mach/iomux-mx2x.h @@ -86,12 +86,12 @@ #define PC31_PF_SSI3_CLK (GPIO_PORTC | GPIO_PF | GPIO_IN | 31) #define PD17_PF_I2C_DATA (GPIO_PORTD | GPIO_PF | GPIO_OUT | 17) #define PD18_PF_I2C_CLK (GPIO_PORTD | GPIO_PF | GPIO_OUT | 18) -#define PD19_PF_CSPI2_SS2 (GPIO_PORTD | GPIO_PF | 19) -#define PD20_PF_CSPI2_SS1 (GPIO_PORTD | GPIO_PF | 20) -#define PD21_PF_CSPI2_SS0 (GPIO_PORTD | GPIO_PF | 21) -#define PD22_PF_CSPI2_SCLK (GPIO_PORTD | GPIO_PF | 22) -#define PD23_PF_CSPI2_MISO (GPIO_PORTD | GPIO_PF | 23) -#define PD24_PF_CSPI2_MOSI (GPIO_PORTD | GPIO_PF | 24) +#define PD19_PF_CSPI2_SS2 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 19) +#define PD20_PF_CSPI2_SS1 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 20) +#define PD21_PF_CSPI2_SS0 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 21) +#define PD22_PF_CSPI2_SCLK (GPIO_PORTD | GPIO_PF | GPIO_OUT | 22) +#define PD23_PF_CSPI2_MISO (GPIO_PORTD | GPIO_PF | GPIO_IN | 23) +#define PD24_PF_CSPI2_MOSI (GPIO_PORTD | GPIO_PF | GPIO_OUT | 24) #define PD25_PF_CSPI1_RDY (GPIO_PORTD | GPIO_PF | GPIO_OUT | 25) #define PD26_PF_CSPI1_SS2 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 26) #define PD27_PF_CSPI1_SS1 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 27) diff --git a/arch/arm/mach-imx/include/mach/iomux-mx51.h b/arch/arm/mach-imx/include/mach/iomux-mx51.h index 0252d412c6..2623e7a2e1 100644 --- a/arch/arm/mach-imx/include/mach/iomux-mx51.h +++ b/arch/arm/mach-imx/include/mach/iomux-mx51.h @@ -107,11 +107,13 @@ #define MX51_PAD_EIM_D25__UART2_CTS IOMUX_PAD(0x414, 0x080, 4, __NA_, 0, MX51_UART_PAD_CTRL) #define MX51_PAD_EIM_D25__UART3_RXD IOMUX_PAD(0x414, 0x080, 3, 0x9f4, 0, MX51_UART_PAD_CTRL) #define MX51_PAD_EIM_D25__USBOTG_DATA1 IOMUX_PAD(0x414, 0x080, 2, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_EIM_D25__GPT_CMPOUT1 IOMUX_PAD(0x414, 0x080, 5, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D26__EIM_D26 IOMUX_PAD(0x418, 0x084, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D26__KEY_COL7 IOMUX_PAD(0x418, 0x084, 1, 0x9cc, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D26__UART2_RTS IOMUX_PAD(0x418, 0x084, 4, 0x9e8, 3, MX51_UART_PAD_CTRL) #define MX51_PAD_EIM_D26__UART3_TXD IOMUX_PAD(0x418, 0x084, 3, __NA_, 0, MX51_UART_PAD_CTRL) #define MX51_PAD_EIM_D26__USBOTG_DATA2 IOMUX_PAD(0x418, 0x084, 2, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_EIM_D26__GPT_CMPOUT2 IOMUX_PAD(0x418, 0x084, 5, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D27__AUD6_RXC IOMUX_PAD(0x41c, 0x088, 5, 0x8f4, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D27__EIM_D27 IOMUX_PAD(0x41c, 0x088, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D27__GPIO2_9 IOMUX_PAD(0x41c, 0x088, 1, __NA_, 0, MX51_GPIO_PAD_CTRL) @@ -228,6 +230,7 @@ #define MX51_PAD_EIM_CRE__EIM_CRE IOMUX_PAD(0x4a0, 0x100, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_CRE__GPIO3_2 IOMUX_PAD(0x4a0, 0x100, 1, 0x97c, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_DRAM_CS1__DRAM_CS1 IOMUX_PAD(0x4d0, 0x104, 0, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_DRAM_CS1__CCM_CLKO IOMUX_PAD(0x4d0, 0x104, 1, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_WE_B__GPIO3_3 IOMUX_PAD(0x4e4, 0x108, 3, 0x980, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_NANDF_WE_B__NANDF_WE_B IOMUX_PAD(0x4e4, 0x108, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_WE_B__PATA_DIOW IOMUX_PAD(0x4e4, 0x108, 1, __NA_, 0, NO_PAD_CTRL) @@ -256,12 +259,14 @@ #define MX51_PAD_NANDF_RB1__GPIO3_9 IOMUX_PAD(0x4fc, 0x120, 3, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_NANDF_RB1__NANDF_RB1 IOMUX_PAD(0x4fc, 0x120, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB1__PATA_IORDY IOMUX_PAD(0x4fc, 0x120, 1, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_NANDF_RB1__GPT_CMPOUT2 IOMUX_PAD(0x4fc, 0x120, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB1__SD4_CMD IOMUX_PAD(0x4fc, 0x120, 0x15, __NA_, 0, MX51_SDHCI_PAD_CTRL) #define MX51_PAD_NANDF_RB2__DISP2_WAIT IOMUX_PAD(0x500, 0x124, 5, 0x9a8, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB2__ECSPI2_SCLK IOMUX_PAD(0x500, 0x124, 2, __NA_, 0, MX51_ECSPI_PAD_CTRL) #define MX51_PAD_NANDF_RB2__FEC_COL IOMUX_PAD(0x500, 0x124, 1, 0x94c, 0, MX51_PAD_CTRL_2) #define MX51_PAD_NANDF_RB2__GPIO3_10 IOMUX_PAD(0x500, 0x124, 3, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_NANDF_RB2__NANDF_RB2 IOMUX_PAD(0x500, 0x124, 0, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_NANDF_RB2__GPT_CMPOUT3 IOMUX_PAD(0x500, 0x124, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB2__USBH3_H3_DP IOMUX_PAD(0x500, 0x124, 0x17, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB2__USBH3_NXT IOMUX_PAD(0x500, 0x124, 6, 0xa20, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB3__DISP1_WAIT IOMUX_PAD(0x504, 0x128, 5, __NA_, 0, NO_PAD_CTRL) @@ -637,7 +642,9 @@ #define MX51_PAD_DISP1_DAT23__DISP2_DAT17 IOMUX_PAD(0x728, 0x328, 5, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DISP1_DAT23__DISP2_SER_CS IOMUX_PAD(0x728, 0x328, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI1_PIN3__DI1_PIN3 IOMUX_PAD(0x72c, 0x32c, 0, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_DI1_DISP_CLK__DI1_DISP_CLK IOMUX_PAD(0x730, __NA_, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI1_PIN2__DI1_PIN2 IOMUX_PAD(0x734, 0x330, 0, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_DI1_PIN15__DI1_PIN15 IOMUX_PAD(0x738, __NA_, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI_GP2__DISP1_SER_CLK IOMUX_PAD(0x740, 0x338, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI_GP2__DISP2_WAIT IOMUX_PAD(0x740, 0x338, 2, 0x9a8, 1, NO_PAD_CTRL) #define MX51_PAD_DI_GP3__CSI1_DATA_EN IOMUX_PAD(0x744, 0x33c, 3, 0x9a0, 1, NO_PAD_CTRL) @@ -649,20 +656,20 @@ #define MX51_PAD_DI2_PIN2__DI2_PIN2 IOMUX_PAD(0x74c, 0x344, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI2_PIN2__FEC_MDC IOMUX_PAD(0x74c, 0x344, 2, __NA_, 0, MX51_PAD_CTRL_5) #define MX51_PAD_DI2_PIN3__DI2_PIN3 IOMUX_PAD(0x750, 0x348, 0, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DI2_PIN3__FEC_MDIO IOMUX_PAD(0x750, 0x348, 2, 0x954, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DI2_PIN3__FEC_MDIO IOMUX_PAD(0x750, 0x348, 2, 0x954, 1, NO_PAD_CTRL) #define MX51_PAD_DI2_DISP_CLK__DI2_DISP_CLK IOMUX_PAD(0x754, 0x34c, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI2_DISP_CLK__FEC_RDATA1 IOMUX_PAD(0x754, 0x34c, 2, 0x95c, 1, NO_PAD_CTRL) #define MX51_PAD_DI_GP4__DI2_PIN15 IOMUX_PAD(0x758, 0x350, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI_GP4__DISP1_SER_DIN IOMUX_PAD(0x758, 0x350, 0, 0x9c0, 1, NO_PAD_CTRL) #define MX51_PAD_DI_GP4__DISP2_PIN1 IOMUX_PAD(0x758, 0x350, 3, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DI_GP4__FEC_RDATA2 IOMUX_PAD(0x758, 0x350, 2, 0x960, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DI_GP4__FEC_RDATA2 IOMUX_PAD(0x758, 0x350, 2, 0x960, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT0__DISP2_DAT0 IOMUX_PAD(0x75c, 0x354, 0, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DISP2_DAT0__FEC_RDATA3 IOMUX_PAD(0x75c, 0x354, 2, 0x964, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DISP2_DAT0__FEC_RDATA3 IOMUX_PAD(0x75c, 0x354, 2, 0x964, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT0__KEY_COL6 IOMUX_PAD(0x75c, 0x354, 4, 0x9c8, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT0__UART3_RXD IOMUX_PAD(0x75c, 0x354, 5, 0x9f4, 8, MX51_UART_PAD_CTRL) #define MX51_PAD_DISP2_DAT0__USBH3_CLK IOMUX_PAD(0x75c, 0x354, 3, 0x9f8, 1, MX51_UART_PAD_CTRL) #define MX51_PAD_DISP2_DAT1__DISP2_DAT1 IOMUX_PAD(0x760, 0x358, 0, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DISP2_DAT1__FEC_RX_ER IOMUX_PAD(0x760, 0x358, 2, 0x970, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DISP2_DAT1__FEC_RX_ER IOMUX_PAD(0x760, 0x358, 2, 0x970, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT1__KEY_COL7 IOMUX_PAD(0x760, 0x358, 4, 0x9cc, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT1__UART3_TXD IOMUX_PAD(0x760, 0x358, 5, __NA_, 0, MX51_UART_PAD_CTRL) #define MX51_PAD_DISP2_DAT1__USBH3_DIR IOMUX_PAD(0x760, 0x358, 3, 0xa1c, 1, NO_PAD_CTRL) @@ -692,17 +699,17 @@ #define MX51_PAD_DISP2_DAT9__USBH3_DATA1 IOMUX_PAD(0x780, 0x378, 3, 0xa00, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT10__DISP2_DAT10 IOMUX_PAD(0x784, 0x37c, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT10__DISP2_SER_CS IOMUX_PAD(0x784, 0x37c, 5, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DISP2_DAT10__FEC_COL IOMUX_PAD(0x784, 0x37c, 2, 0x94c, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DISP2_DAT10__FEC_COL IOMUX_PAD(0x784, 0x37c, 2, 0x94c, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT10__KEY_ROW7 IOMUX_PAD(0x784, 0x37c, 4, 0x9dc, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT10__USBH3_DATA2 IOMUX_PAD(0x784, 0x37c, 3, 0xa04, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT11__AUD6_TXD IOMUX_PAD(0x788, 0x380, 4, 0x8f0, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT11__DISP2_DAT11 IOMUX_PAD(0x788, 0x380, 0, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DISP2_DAT11__FEC_RX_CLK IOMUX_PAD(0x788, 0x380, 2, 0x968, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DISP2_DAT11__FEC_RX_CLK IOMUX_PAD(0x788, 0x380, 2, 0x968, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT11__GPIO1_10 IOMUX_PAD(0x788, 0x380, 7, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_DISP2_DAT11__USBH3_DATA3 IOMUX_PAD(0x788, 0x380, 3, 0xa08, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT12__AUD6_RXD IOMUX_PAD(0x78c, 0x384, 4, 0x8ec, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT12__DISP2_DAT12 IOMUX_PAD(0x78c, 0x384, 0, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DISP2_DAT12__FEC_RX_DV IOMUX_PAD(0x78c, 0x384, 2, 0x96c, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DISP2_DAT12__FEC_RX_DV IOMUX_PAD(0x78c, 0x384, 2, 0x96c, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT12__USBH3_DATA4 IOMUX_PAD(0x78c, 0x384, 3, 0xa0c, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT13__AUD6_TXC IOMUX_PAD(0x790, 0x388, 4, 0x8fc, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT13__DISP2_DAT13 IOMUX_PAD(0x790, 0x388, 0, __NA_, 0, NO_PAD_CTRL) @@ -780,6 +787,8 @@ #define MX51_PAD_GPIO1_2__PWM1_PWMO IOMUX_PAD(0x7d4, 0x3cc, 1, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_3__GPIO1_3 IOMUX_PAD(0x7d8, 0x3d0, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_3__I2C2_SDA IOMUX_PAD(0x7d8, 0x3d0, 0x12, 0x9bc, 3, MX51_I2C_PAD_CTRL) +#define MX51_PAD_GPIO1_3__CCM_CLKO2 IOMUX_PAD(0x7d8, 0x3d0, 5, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_3__GPT_CLKIN IOMUX_PAD(0x7d8, 0x3d0, 6, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_3__PLL2_BYP IOMUX_PAD(0x7d8, 0x3d0, 7, 0x910, 1, NO_PAD_CTRL) #define MX51_PAD_GPIO1_3__PWM2_PWMO IOMUX_PAD(0x7d8, 0x3d0, 1, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_PMIC_INT_REQ__PMIC_INT_REQ IOMUX_PAD(0x7fc, 0x3d4, 0, __NA_, 0, NO_PAD_CTRL) @@ -788,13 +797,16 @@ #define MX51_PAD_GPIO1_4__EIM_RDY IOMUX_PAD(0x804, 0x3d8, 3, 0x938, 1, NO_PAD_CTRL) #define MX51_PAD_GPIO1_4__GPIO1_4 IOMUX_PAD(0x804, 0x3d8, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_4__WDOG1_WDOG_B IOMUX_PAD(0x804, 0x3d8, 2, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_4__GPT_CAPIN1 IOMUX_PAD(0x804, 0x3d8, 6, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_5__CSI2_MCLK IOMUX_PAD(0x808, 0x3dc, 6, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_5__DISP2_PIN16 IOMUX_PAD(0x808, 0x3dc, 3, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_5__GPIO1_5 IOMUX_PAD(0x808, 0x3dc, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_5__WDOG2_WDOG_B IOMUX_PAD(0x808, 0x3dc, 2, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_5__CCM_CLKO IOMUX_PAD(0x808, 0x3dc, 5, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_6__DISP2_PIN17 IOMUX_PAD(0x80c, 0x3e0, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_6__GPIO1_6 IOMUX_PAD(0x80c, 0x3e0, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_6__REF_EN_B IOMUX_PAD(0x80c, 0x3e0, 3, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_6__GPT_CAPIN2 IOMUX_PAD(0x80c, 0x3e0, 6, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_7__CCM_OUT_0 IOMUX_PAD(0x810, 0x3e4, 3, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_7__GPIO1_7 IOMUX_PAD(0x810, 0x3e4, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_7__SD2_WP IOMUX_PAD(0x810, 0x3e4, 6, __NA_, 0, MX51_ESDHC_PAD_CTRL) @@ -803,11 +815,13 @@ #define MX51_PAD_GPIO1_8__GPIO1_8 IOMUX_PAD(0x814, 0x3e8, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_8__SD2_CD IOMUX_PAD(0x814, 0x3e8, 6, __NA_, 0, MX51_ESDHC_PAD_CTRL) #define MX51_PAD_GPIO1_8__USBH3_PWR IOMUX_PAD(0x814, 0x3e8, 1, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_8__CCM_CLKO2 IOMUX_PAD(0x814, 0x3e8, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_9__CCM_OUT_1 IOMUX_PAD(0x818, 0x3ec, 3, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_9__DISP2_D1_CS IOMUX_PAD(0x818, 0x3ec, 2, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_9__DISP2_SER_CS IOMUX_PAD(0x818, 0x3ec, 7, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_9__GPIO1_9 IOMUX_PAD(0x818, 0x3ec, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_9__SD2_LCTL IOMUX_PAD(0x818, 0x3ec, 6, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_9__USBH3_OC IOMUX_PAD(0x818, 0x3ec, 1, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_9__CCM_CLKO IOMUX_PAD(0x818, 0x3ec, 4, __NA_, 0, NO_PAD_CTRL) #endif /* __MACH_IOMUX_MX51_H__ */ diff --git a/arch/arm/mach-imx/iomux-v3.c b/arch/arm/mach-imx/iomux-v3.c deleted file mode 100644 index 8a6064da6c..0000000000 --- a/arch/arm/mach-imx/iomux-v3.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved. - * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de> - * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH, - * <armlinux@phytec.de> - * - * 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. - * - */ -#include <common.h> -#include <init.h> -#include <io.h> -#include <mach/iomux-v3.h> - -static void __iomem *base; - -/* - * configures a single pad in the iomuxer - */ -int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad) -{ - u32 mux_ctrl_ofs = (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT; - u32 mux_mode = (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT; - u32 sel_input_ofs = (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT; - u32 sel_input = (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT; - u32 pad_ctrl_ofs = (pad & MUX_PAD_CTRL_OFS_MASK) >> MUX_PAD_CTRL_OFS_SHIFT; - u32 pad_ctrl = (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT; - - if (!base) - return -EINVAL; - - debug("%s: mux 0x%08x -> 0x%04x pad: 0x%08x -> 0x%04x sel_inp: 0x%08x -> 0x%04x\n", - __func__, mux_mode, mux_ctrl_ofs, pad_ctrl, pad_ctrl_ofs, sel_input, - sel_input_ofs); - - if (mux_ctrl_ofs) - __raw_writel(mux_mode, base + mux_ctrl_ofs); - - if (sel_input_ofs) - __raw_writel(sel_input, base + sel_input_ofs); - - if (!(pad_ctrl & NO_PAD_CTRL) && pad_ctrl_ofs) - __raw_writel(pad_ctrl, base + pad_ctrl_ofs); - - return 0; -} -EXPORT_SYMBOL(mxc_iomux_v3_setup_pad); - - -int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count) -{ - iomux_v3_cfg_t *p = pad_list; - int i; - int ret; - - for (i = 0; i < count; i++) { - ret = mxc_iomux_v3_setup_pad(*p); - if (ret) - return ret; - p++; - } - return 0; -} -EXPORT_SYMBOL(mxc_iomux_v3_setup_multiple_pads); - -static int imx_iomux_probe(struct device_d *dev) -{ - base = dev_request_mem_region(dev, 0); - - return 0; -} - -static __maybe_unused struct of_device_id imx_iomux_dt_ids[] = { - { - .compatible = "fsl,imx35-iomux", - }, { - /* sentinel */ - } -}; - -static struct platform_device_id imx_iomux_ids[] = { - { - .name = "imx35-iomux", - }, { - /* sentinel */ - }, -}; - -static struct driver_d imx_iomux_driver = { - .name = "imx-iomuxv3", - .probe = imx_iomux_probe, - .of_compatible = DRV_OF_COMPAT(imx_iomux_dt_ids), - .id_table = imx_iomux_ids, -}; - -static int imx_iomux_init(void) -{ - return platform_driver_register(&imx_iomux_driver); -} -postcore_initcall(imx_iomux_init); diff --git a/arch/arm/mach-mxs/soc-imx28.c b/arch/arm/mach-mxs/soc-imx28.c index 8972a3d909..ed931afc32 100644 --- a/arch/arm/mach-mxs/soc-imx28.c +++ b/arch/arm/mach-mxs/soc-imx28.c @@ -39,12 +39,16 @@ EXPORT_SYMBOL(reset_cpu); static int imx28_init(void) { + u32 reg; + /* * The default setting for the WDT is to do a POR. If the SoC is only * powered via battery, then a WDT reset powers the chip down instead * of resetting it. Use a software reset only. */ - writel(HW_CLKCTRL_WDOG_POR_DISABLE, IMX_CCM_BASE + HW_CLKCTRL_RESET); + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_RESET) | + HW_CLKCTRL_WDOG_POR_DISABLE; + writel(reg, IMX_CCM_BASE + HW_CLKCTRL_RESET); return 0; } diff --git a/arch/arm/mach-netx/Kconfig b/arch/arm/mach-netx/Kconfig index 8d8f49b85d..3c62d605a9 100644 --- a/arch/arm/mach-netx/Kconfig +++ b/arch/arm/mach-netx/Kconfig @@ -9,35 +9,19 @@ config BOARDINFO config NETX_SDRAM_CTRL hex - default 0x010D0001 if MACH_NXDKN default 0x010D0121 if MACH_NXDB500 - default 0x030D0111 if MACH_NXHMIBB - default 0x010D0111 if MACH_NXEB500HMI - default 0x030D0001 if MACH_NXHX config NETX_SDRAM_TIMING_CTRL hex - default 0x03C12151 if MACH_NXDKN default 0x03C13261 if MACH_NXDB500 - default 0x03C13251 if MACH_NXHMIBB - default 0x03C13251 if MACH_NXEB500HMI - default 0x03C23251 if MACH_NXHX config NETX_MEM_CTRL hex - default 0x0103030F if MACH_NXDKN default 0x0203030F if MACH_NXDB500 - default 0x0103030F if MACH_NXHMIBB - default 0x0103030F if MACH_NXEB500HMI - default 0x0103030F if MACH_NXHX config NETX_COOKIE hex - default 16 if MACH_NXDKN default 32 if MACH_NXDB500 - default 16 if MACH_NXHMIBB - default 16 if MACH_NXEB500HMI - default 16 if MACH_NXHX choice prompt "Netx Board Type" diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig index 42e5f4af07..f7aa8c5a28 100644 --- a/arch/arm/mach-omap/Kconfig +++ b/arch/arm/mach-omap/Kconfig @@ -104,6 +104,13 @@ config OMAP4_USBBOOT You need the utility program omap4_usbboot to boot from USB. Please read omap4_usb_booting.txt for more information. +config CMD_BOOT_ORDER + tristate + depends on ARCH_OMAP4 + prompt "boot_order" + help + A command to choose the next boot device on a warm reset. + config BOARDINFO default "Archos G9" if MACH_ARCHOSG9 default "Texas Instrument's SDP343x" if MACH_OMAP343xSDP @@ -134,7 +141,6 @@ config MACH_BEAGLE config MACH_BEAGLEBONE bool "Texas Instrument's Beagle Bone" - select OMAP_CLOCK_ALL depends on ARCH_AM33XX help Say Y here if you are using Beagle Bone @@ -179,7 +185,6 @@ config MACH_PCAAXL2 config MACH_PCM051 bool "Phytec phyCORE pcm051" - select OMAP_CLOCK_ALL select HAVE_DEFAULT_ENVIRONMENT_NEW depends on ARCH_AM33XX help diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile index d9e00f77ae..973068db58 100644 --- a/arch/arm/mach-omap/Makefile +++ b/arch/arm/mach-omap/Makefile @@ -30,4 +30,5 @@ obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o obj-$(CONFIG_SHELL_NONE) += xload.o obj-$(CONFIG_MFD_TWL6030) += omap4_twl6030_mmc.o obj-$(CONFIG_OMAP4_USBBOOT) += omap4_rom_usb.o +obj-$(CONFIG_CMD_BOOT_ORDER) += boot_order.o obj-y += gpio.o diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c index 059c55e3b0..96432c9ff2 100644 --- a/arch/arm/mach-omap/am33xx_generic.c +++ b/arch/arm/mach-omap/am33xx_generic.c @@ -19,12 +19,13 @@ */ #include <common.h> +#include <bootsource.h> +#include <init.h> #include <io.h> #include <net.h> #include <mach/am33xx-silicon.h> #include <mach/am33xx-clock.h> #include <mach/sys_info.h> -#include <mach/generic.h> #include <mach/am33xx-generic.h> void __noreturn reset_cpu(unsigned long addr) @@ -94,10 +95,13 @@ u32 running_in_sdram(void) return 0; /* running in SRAM or FLASH */ } -enum omap_boot_src am33xx_bootsrc(void) +static int am33xx_bootsource(void) { - return OMAP_BOOTSRC_MMC1; /* only MMC for now */ + bootsource_set(BOOTSOURCE_MMC); /* only MMC for now */ + bootsource_set_instance(0); + return 0; } +postcore_initcall(am33xx_bootsource); int am33xx_register_ethaddr(int eth_id, int mac_id) { diff --git a/arch/arm/mach-omap/boot_order.c b/arch/arm/mach-omap/boot_order.c new file mode 100644 index 0000000000..2f2846d119 --- /dev/null +++ b/arch/arm/mach-omap/boot_order.c @@ -0,0 +1,83 @@ +/* + * boot_order.c - configure omap warm boot + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +#include <common.h> +#include <command.h> +#include <complete.h> +#include <mach/omap4-silicon.h> + +struct bootsrc { + const char *name; + uint32_t sar; +}; + +const struct bootsrc src_list[] = { + {"xip" , OMAP44XX_SAR_BOOT_XIP }, + {"xipwait" , OMAP44XX_SAR_BOOT_XIPWAIT }, + {"nand" , OMAP44XX_SAR_BOOT_NAND }, + {"onenand" , OMAP44XX_SAR_BOOT_ONENAND }, + {"mmc1" , OMAP44XX_SAR_BOOT_MMC1 }, + {"mmc2_1" , OMAP44XX_SAR_BOOT_MMC2_1 }, + {"mmc2_2" , OMAP44XX_SAR_BOOT_MMC2_2 }, + {"uart" , OMAP44XX_SAR_BOOT_UART }, + {"usb_1" , OMAP44XX_SAR_BOOT_USB_1 }, + {"usb_ulpi", OMAP44XX_SAR_BOOT_USB_ULPI}, + {"usb_2" , OMAP44XX_SAR_BOOT_USB_2 }, +}; + +static uint32_t parse_device(char *str) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(src_list); i++) { + if (strcmp(str, src_list[i].name) == 0) + return src_list[i].sar; + } + printf("Unknown device '%s'\n", str); + return OMAP44XX_SAR_BOOT_VOID; +} + +static int cmd_boot_order(int argc, char *argv[]) +{ + uint32_t device_list[] = { + OMAP44XX_SAR_BOOT_VOID, + OMAP44XX_SAR_BOOT_VOID, + OMAP44XX_SAR_BOOT_VOID, + OMAP44XX_SAR_BOOT_VOID, + }; + int i; + + if (argc < 2) + return COMMAND_ERROR_USAGE; + for (i = 0; i + 1 < argc && i < ARRAY_SIZE(device_list); i++) { + device_list[i] = parse_device(argv[i + 1]); + if (device_list[i] == OMAP44XX_SAR_BOOT_VOID) + return COMMAND_ERROR_USAGE; + } + omap4_set_warmboot_order(device_list); + return 0; +} + +static const __maybe_unused char cmd_boot_order_help[] = +"Usage: boot_order <device 1> [<device n>]\n" +"Set warm boot order of up to four devices.\n" +"Each device can be one of:\n" +"xip xipwait nand onenand mmc1 mmc2_1 mmc2_2 uart usb_1 usb_ulpi usb_2\n"; + +BAREBOX_CMD_START(boot_order) + .cmd = cmd_boot_order, + .usage = "boot_order <device 1> [<device n>]", + BAREBOX_CMD_HELP(cmd_boot_order_help) + BAREBOX_CMD_COMPLETE(empty_complete) +BAREBOX_CMD_END diff --git a/arch/arm/mach-omap/include/mach/am33xx-clock.h b/arch/arm/mach-omap/include/mach/am33xx-clock.h index 39c107f9c7..2ecfc5fc8d 100644 --- a/arch/arm/mach-omap/include/mach/am33xx-clock.h +++ b/arch/arm/mach-omap/include/mach/am33xx-clock.h @@ -31,12 +31,12 @@ #define MPUPLL_M_600 600 /* 125 * n */ #define MPUPLL_M_720 720 /* 125 * n */ -#define MPUPLL_N 23 /* (n -1 ) */ +#define MPUPLL_N (OSC - 1) #define MPUPLL_M2 1 /* Core PLL Fdll = 1 GHZ, */ #define COREPLL_M 1000 /* 125 * n */ -#define COREPLL_N 23 /* (n -1 ) */ +#define COREPLL_N (OSC - 1) #define COREPLL_M4 10 /* CORE_CLKOUTM4 = 200 MHZ */ #define COREPLL_M5 8 /* CORE_CLKOUTM5 = 250 MHZ */ @@ -48,19 +48,13 @@ * For clkout = 192 MHZ, Fdll = 960 MHZ, divider values are given below */ #define PERPLL_M 960 -#define PERPLL_N 23 +#define PERPLL_N (OSC - 1) #define PERPLL_M2 5 -/* DDR Freq is 166 MHZ for now*/ +/* DDR Freq is 266 MHZ for now*/ /* Set Fdll = 400 MHZ , Fdll = M * 2 * CLKINP/ N + 1; clkout = Fdll /(2 * M2) */ -//#if (CONFIG_AM335X_EVM_IS_13x13 == 1) -#if 0 -#define DDRPLL_M 166 /* M/N + 1 = 25/3 */ -#else #define DDRPLL_M 266 -#endif - -#define DDRPLL_N 23 +#define DDRPLL_N (OSC - 1) #define DDRPLL_M2 1 /* PRCM */ @@ -139,7 +133,9 @@ #define CM_PER_CPGMAC0_CLKCTRL (CM_PER + 0x14) /* Ethernet */ #define CM_PER_CPSW_CLKSTCTRL (CM_PER + 0x144)/* Ethernet */ #define CM_PER_OCMCRAM_CLKCTRL (CM_PER + 0x2C) /* OCMC RAM */ +#define CM_PER_GPIO1_CLKCTRL (CM_PER + 0xAC) /* GPIO1 */ #define CM_PER_GPIO2_CLKCTRL (CM_PER + 0xB0) /* GPIO2 */ +#define CM_PER_GPIO3_CLKCTRL (CM_PER + 0xB4) /* GPIO3 */ #define CM_PER_UART3_CLKCTRL (CM_PER + 0x74) /* UART3 */ #define CM_PER_I2C1_CLKCTRL (CM_PER + 0x48) /* I2C1 */ #define CM_PER_I2C2_CLKCTRL (CM_PER + 0x44) /* I2C2 */ diff --git a/arch/arm/mach-omap/include/mach/am33xx-silicon.h b/arch/arm/mach-omap/include/mach/am33xx-silicon.h index e69d345b07..9edf4ca977 100644 --- a/arch/arm/mach-omap/include/mach/am33xx-silicon.h +++ b/arch/arm/mach-omap/include/mach/am33xx-silicon.h @@ -29,6 +29,12 @@ #define AM33XX_UART1_BASE (AM33XX_L4_PER_BASE + 0x22000) #define AM33XX_UART2_BASE (AM33XX_L4_PER_BASE + 0x24000) +/* GPIO */ +#define AM33XX_GPIO0_BASE (AM33XX_L4_WKUP_BASE + 0x207000 + 0x100) +#define AM33XX_GPIO1_BASE (AM33XX_L4_PER_BASE + 0x4C000 + 0x100) +#define AM33XX_GPIO2_BASE (AM33XX_L4_PER_BASE + 0x1AC000 + 0x100) +#define AM33XX_GPIO3_BASE (AM33XX_L4_PER_BASE + 0x1AE000 + 0x100) + /* EMFI Registers */ #define AM33XX_EMFI0_BASE 0x4C000000 diff --git a/arch/arm/mach-omap/include/mach/generic.h b/arch/arm/mach-omap/include/mach/generic.h index 7455404ca5..5a10a548a9 100644 --- a/arch/arm/mach-omap/include/mach/generic.h +++ b/arch/arm/mach-omap/include/mach/generic.h @@ -27,17 +27,4 @@ #define cpu_is_omap4xxx() (0) #endif -enum omap_boot_src { - OMAP_BOOTSRC_UNKNOWN, - OMAP_BOOTSRC_MMC1, - OMAP_BOOTSRC_NAND, - OMAP_BOOTSRC_SPI1, - OMAP_BOOTSRC_USB1, -}; - -enum omap_boot_src omap_bootsrc(void); -enum omap_boot_src am33xx_bootsrc(void); -enum omap_boot_src omap3_bootsrc(void); -enum omap_boot_src omap4_bootsrc(void); - #endif diff --git a/arch/arm/mach-omap/include/mach/omap4-silicon.h b/arch/arm/mach-omap/include/mach/omap4-silicon.h index 9e82435e9c..666e721551 100644 --- a/arch/arm/mach-omap/include/mach/omap4-silicon.h +++ b/arch/arm/mach-omap/include/mach/omap4-silicon.h @@ -161,6 +161,25 @@ #define OMAP44XX_PRM_RSTCTRL_RESET 0x01 /* + * SAR (Save & Rescue) memory region + */ +#define OMAP44XX_SAR_RAM_BASE 0x4a326000 +#define OMAP44XX_SAR_CH_ADDRESS (OMAP44XX_SAR_RAM_BASE + 0xA00) +#define OMAP44XX_SAR_CH_START (OMAP44XX_SAR_RAM_BASE + 0xA0C) +#define OMAP44XX_SAR_BOOT_VOID 0x00 +#define OMAP44XX_SAR_BOOT_XIP 0x01 +#define OMAP44XX_SAR_BOOT_XIPWAIT 0x02 +#define OMAP44XX_SAR_BOOT_NAND 0x03 +#define OMAP44XX_SAR_BOOT_ONENAND 0x04 +#define OMAP44XX_SAR_BOOT_MMC1 0x05 +#define OMAP44XX_SAR_BOOT_MMC2_1 0x06 +#define OMAP44XX_SAR_BOOT_MMC2_2 0x07 +#define OMAP44XX_SAR_BOOT_UART 0x43 +#define OMAP44XX_SAR_BOOT_USB_1 0x45 +#define OMAP44XX_SAR_BOOT_USB_ULPI 0x46 +#define OMAP44XX_SAR_BOOT_USB_2 0x47 + +/* * Non-secure SRAM Addresses * Non-secure RAM starts at 0x40300000 for GP devices. But we keep SRAM_BASE * at 0x40304000(EMU base) so that our code works for both EMU and GP @@ -212,6 +231,7 @@ void omap4_ddr_init(const struct ddr_regs *, const struct dpll_param *); void omap4_power_i2c_send(u32); unsigned int omap4_revision(void); noinline int omap4_scale_vcores(unsigned vsel0_pin); +void omap4_set_warmboot_order(u32 *device_list); #endif diff --git a/arch/arm/mach-omap/omap3_clock.c b/arch/arm/mach-omap/omap3_clock.c index bcde48ff64..03aca492a1 100644 --- a/arch/arm/mach-omap/omap3_clock.c +++ b/arch/arm/mach-omap/omap3_clock.c @@ -652,12 +652,6 @@ void prcm_init(void) /** * @brief Enable the clks & power for perifs * - * GPT2 Sysclk, ICLK,FCLK, 32k Sync is enabled by default - * Uses CONFIG_OMAP_CLOCK_UART to enable UART clocks - * Uses CONFIG_OMAP_CLOCK_I2C to enable I2C clocks - * Uses CONFIG_OMAP_CLOCK_ALL to enable All Clocks! - * - Not a wise idea in most cases - * * @return void */ static void per_clocks_enable(void) diff --git a/arch/arm/mach-omap/omap3_generic.c b/arch/arm/mach-omap/omap3_generic.c index 10e03aec02..f144813cf9 100644 --- a/arch/arm/mach-omap/omap3_generic.c +++ b/arch/arm/mach-omap/omap3_generic.c @@ -28,6 +28,7 @@ */ #include <common.h> +#include <bootsource.h> #include <init.h> #include <io.h> #include <mach/omap3-silicon.h> @@ -40,7 +41,6 @@ #include <mach/wdt.h> #include <mach/sys_info.h> #include <mach/syslib.h> -#include <mach/generic.h> /** * @brief Reset the CPU @@ -461,21 +461,25 @@ void omap3_core_init(void) #ifdef CONFIG_OMAP3_CLOCK_CONFIG prcm_init(); #endif - } #define OMAP3_TRACING_VECTOR1 0x4020ffb4 -enum omap_boot_src omap3_bootsrc(void) +static int omap3_bootsource(void) { + enum bootsource src = BOOTSOURCE_UNKNOWN; u32 bootsrc = readl(OMAP3_TRACING_VECTOR1); if (bootsrc & (1 << 2)) - return OMAP_BOOTSRC_NAND; + src = BOOTSOURCE_NAND; if (bootsrc & (1 << 6)) - return OMAP_BOOTSRC_MMC1; - return OMAP_BOOTSRC_UNKNOWN; + src = BOOTSOURCE_MMC; + bootsource_set(src); + bootsource_set_instance(0); + + return 0; } +postcore_initcall(omap3_bootsource); /* GPMC timing for OMAP3 nand device */ const struct gpmc_config omap3_nand_cfg = { diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c index e1edffa351..3d6ec25c93 100644 --- a/arch/arm/mach-omap/omap4_generic.c +++ b/arch/arm/mach-omap/omap4_generic.c @@ -1,11 +1,11 @@ #include <common.h> +#include <bootsource.h> #include <init.h> #include <io.h> #include <mach/omap4-clock.h> #include <mach/omap4-silicon.h> #include <mach/omap4-mux.h> #include <mach/syslib.h> -#include <mach/generic.h> #include <mach/gpmc.h> #include <mach/gpio.h> #include <mach/omap4_rom_usb.h> @@ -41,6 +41,26 @@ void __noreturn reset_cpu(unsigned long addr) while (1); } +void omap4_set_warmboot_order(u32 *device_list) +{ + const u32 CH[] = { + 0xCF00AA01, + 0x0000000C, + (device_list[0] << 16) | 0x0000, + (device_list[2] << 16) | device_list[1], + 0x0000 | device_list[3], + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000 + }; + int i; + + for (i = 0; i < ARRAY_SIZE(CH); i++) + writel(CH[i], OMAP44XX_SAR_CH_START + i*sizeof(CH[0])); + writel(OMAP44XX_SAR_CH_START, OMAP44XX_SAR_CH_ADDRESS); +} + #define WATCHDOG_WSPR 0x48 #define WATCHDOG_WWPS 0x34 @@ -339,7 +359,7 @@ void omap4_ddr_init(const struct ddr_regs *ddr_regs, /* PHY control values */ sr32(CM_MEMIF_EMIF_1_CLKCTRL, 0, 32, 0x1); - sr32(CM_MEMIF_EMIF_2_CLKCTRL, 0, 32, 0x1); + sr32(CM_MEMIF_EMIF_2_CLKCTRL, 0, 32, 0x1); /* Put the Core Subsystem PD to ON State */ @@ -466,7 +486,7 @@ static int omap_vector_init(void) * The ROM code uses interrupts for the transfers, so do not modify the * interrupt vectors in this case. */ - if (omap4_bootsrc() != OMAP_BOOTSRC_USB1) { + if (bootsource_get() != BOOTSOURCE_USB) { __asm__ __volatile__ ( "mov r0, #0;" "mcr p15, #0, r0, c12, c0, #0;" @@ -478,22 +498,28 @@ static int omap_vector_init(void) return 0; } -core_initcall(omap_vector_init); #define OMAP4_TRACING_VECTOR3 0x4030d048 -enum omap_boot_src omap4_bootsrc(void) +static int omap4_bootsource(void) { + enum bootsource src = BOOTSOURCE_UNKNOWN; u32 bootsrc = readl(OMAP4_TRACING_VECTOR3); if (bootsrc & (1 << 5)) - return OMAP_BOOTSRC_MMC1; + src = BOOTSOURCE_MMC; if (bootsrc & (1 << 3)) - return OMAP_BOOTSRC_NAND; + src = BOOTSOURCE_NAND; if (bootsrc & (1<<20)) - return OMAP_BOOTSRC_USB1; - return OMAP_BOOTSRC_UNKNOWN; + src = BOOTSOURCE_USB; + bootsource_set(src); + bootsource_set_instance(0); + + omap_vector_init(); + + return 0; } +core_initcall(omap4_bootsource); #define GPIO_MASK 0x1f diff --git a/arch/arm/mach-omap/omap_generic.c b/arch/arm/mach-omap/omap_generic.c index 580ed3e165..cfd3dec453 100644 --- a/arch/arm/mach-omap/omap_generic.c +++ b/arch/arm/mach-omap/omap_generic.c @@ -13,23 +13,12 @@ * */ #include <common.h> +#include <bootsource.h> #include <envfs.h> #include <init.h> #include <io.h> #include <fs.h> #include <linux/stat.h> -#include <mach/generic.h> - -enum omap_boot_src omap_bootsrc(void) -{ -#if defined(CONFIG_ARCH_OMAP3) - return omap3_bootsrc(); -#elif defined(CONFIG_ARCH_OMAP4) - return omap4_bootsrc(); -#elif defined(CONFIG_ARCH_AM33XX) - return am33xx_bootsrc(); -#endif -} #if defined(CONFIG_DEFAULT_ENVIRONMENT) && defined(CONFIG_MCI_STARTUP) static int omap_env_init(void) @@ -38,7 +27,7 @@ static int omap_env_init(void) char *diskdev = "/dev/disk0.0"; int ret; - if (omap_bootsrc() != OMAP_BOOTSRC_MMC1) + if (bootsource_get() != BOOTSOURCE_MMC) return 0; ret = stat(diskdev, &s); diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c index 72aa3791e4..3cce3f2be9 100644 --- a/arch/arm/mach-omap/xload.c +++ b/arch/arm/mach-omap/xload.c @@ -1,4 +1,5 @@ #include <common.h> +#include <bootsource.h> #include <partition.h> #include <nand.h> #include <init.h> @@ -6,7 +7,6 @@ #include <linux/mtd/mtd.h> #include <fs.h> #include <fcntl.h> -#include <mach/generic.h> #include <sizes.h> #include <filetype.h> @@ -165,30 +165,32 @@ static __noreturn int omap_xload(void) { int (*func)(void) = NULL; - switch (omap_bootsrc()) + switch (bootsource_get()) { - case OMAP_BOOTSRC_MMC1: - printf("booting from MMC1\n"); + case BOOTSOURCE_MMC: + printf("booting from MMC\n"); func = omap_xload_boot_mmc(); break; - case OMAP_BOOTSRC_USB1: + case BOOTSOURCE_USB: if (IS_ENABLED(CONFIG_FS_OMAP4_USBBOOT)) { - printf("booting from USB1\n"); + printf("booting from USB\n"); func = omap4_xload_boot_usb(); break; } else { - printf("booting from usb1 not enabled\n"); + printf("booting from USB not enabled\n"); } - case OMAP_BOOTSRC_UNKNOWN: - printf("unknown boot source. Fall back to nand\n"); - case OMAP_BOOTSRC_NAND: + case BOOTSOURCE_NAND: printf("booting from NAND\n"); func = omap_xload_boot_nand(SZ_128K); break; - case OMAP_BOOTSRC_SPI1: - printf("booting from SPI1\n"); + case BOOTSOURCE_SPI: + printf("booting from SPI\n"); func = omap_xload_boot_spi(SZ_128K); break; + default: + printf("unknown boot source. Fall back to nand\n"); + func = omap_xload_boot_nand(SZ_128K); + break; } if (!func) { diff --git a/commands/Kconfig b/commands/Kconfig index 00627580ef..6a759ce204 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -303,17 +303,65 @@ config CMD_IOMEM config CMD_MEMORY bool default y - prompt "md and mw" + +config CMD_MD + tristate + default y + select CMD_MEMORY + prompt "md" + help + the md command allows to display (hexdump) memory locations and files. + +config CMD_MW + tristate + default y + select CMD_MEMORY + prompt "mw" + help + the mw command allows to write to memory locations and files. + +config CMD_MM + tristate + select CMD_MEMORY + prompt "memory modify (mm)" + help + the mm command allows to read-modify-write registers by doing: + reg = (reg & ~mask) | (val & mask) + +config CMD_MEMCMP + tristate + default y + select CMD_MEMORY + prompt "memcmp" + help + the memcmp command allows to compare memory and file regions. + +config CMD_MEMCPY + tristate + default y + select CMD_MEMORY + prompt "memcpy" + help + the memcpy command allows to copy memory and file regions. + +config CMD_MEMSET + tristate + default y + select CMD_MEMORY + prompt "memset" + help + the memset command allows to set regions of memory and files to + a specific value. config CMD_CRC tristate select CRC32 - prompt "crc" + prompt "crc32" config CMD_CRC_CMP tristate depends on CMD_CRC - prompt "compare 2 files crc" + prompt "compare 2 files using crc32" config CMD_DIGEST tristate diff --git a/commands/Makefile b/commands/Makefile index 0ae6b9546a..953ecc284b 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -7,6 +7,12 @@ obj-$(CONFIG_CMD_LOADY) += loadxy.o obj-$(CONFIG_CMD_LOADS) += loads.o obj-$(CONFIG_CMD_ECHO) += echo.o obj-$(CONFIG_CMD_MEMORY) += mem.o +obj-$(CONFIG_CMD_MD) += md.o +obj-$(CONFIG_CMD_MM) += mm.o +obj-$(CONFIG_CMD_MW) += mw.o +obj-$(CONFIG_CMD_MEMCMP) += memcmp.o +obj-$(CONFIG_CMD_MEMCPY) += memcpy.o +obj-$(CONFIG_CMD_MEMSET) += memset.o obj-$(CONFIG_CMD_MTEST) += memtest.o obj-$(CONFIG_CMD_EDIT) += edit.o obj-$(CONFIG_CMD_EXEC) += exec.o diff --git a/commands/bootm.c b/commands/bootm.c index e5dfc6ab3c..5dd1703538 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -127,9 +127,6 @@ static int bootm_open_initrd_uimage(struct image_data *data) data->initrd = data->os; } - if (data->initrd_address == UIMAGE_SOME_ADDRESS) - data->initrd_address = data->initrd->header.ih_load; - return 0; } @@ -256,7 +253,7 @@ static int do_bootm(int argc, char *argv[]) memset(&data, 0, sizeof(struct image_data)); - data.initrd_address = UIMAGE_SOME_ADDRESS; + data.initrd_address = UIMAGE_INVALID_ADDRESS; data.os_address = UIMAGE_SOME_ADDRESS; data.verify = 0; data.verbose = 0; @@ -408,8 +405,6 @@ static int do_bootm(int argc, char *argv[]) #endif if (data.os_address == UIMAGE_SOME_ADDRESS) data.os_address = UIMAGE_INVALID_ADDRESS; - if (data.initrd_address == UIMAGE_SOME_ADDRESS) - data.initrd_address = UIMAGE_INVALID_ADDRESS; handler = bootm_find_handler(os_type, &data); if (!handler) { diff --git a/commands/i2c.c b/commands/i2c.c index 8370b43dab..626255d612 100644 --- a/commands/i2c.c +++ b/commands/i2c.c @@ -45,7 +45,7 @@ static int do_i2c_probe(int argc, char *argv[]) if (stopaddr > 0x7F) stopaddr = 0x7F; - printf("probing i2c range 0X%02x - 0x%02x :\n", startaddr, stopaddr); + printf("probing i2c range 0x%02x - 0x%02x :\n", startaddr, stopaddr); for (addr = startaddr; addr <= stopaddr; addr++) { client.addr = addr; ret = i2c_write_reg(&client, 0x00, ®, 0); diff --git a/commands/md.c b/commands/md.c new file mode 100644 index 0000000000..03c5905bb6 --- /dev/null +++ b/commands/md.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * 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 version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +/* + * Memory Functions + * + * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +extern char *mem_rw_buf; + +static int do_mem_md(int argc, char *argv[]) +{ + loff_t start = 0, size = 0x100; + int r, now; + int ret = 0; + int fd; + char *filename = "/dev/mem"; + int mode = O_RWSIZE_4; + int swab = 0; + + if (argc < 2) + return COMMAND_ERROR_USAGE; + + if (mem_parse_options(argc, argv, "bwls:x", &mode, &filename, NULL, + &swab) < 0) + return 1; + + if (optind < argc) { + if (parse_area_spec(argv[optind], &start, &size)) { + printf("could not parse: %s\n", argv[optind]); + return 1; + } + if (size == ~0) + size = 0x100; + } + + fd = open_and_lseek(filename, mode | O_RDONLY, start); + if (fd < 0) + return 1; + + do { + now = min(size, (loff_t)RW_BUF_SIZE); + r = read(fd, mem_rw_buf, now); + if (r < 0) { + perror("read"); + goto out; + } + if (!r) + goto out; + + if ((ret = memory_display(mem_rw_buf, start, r, + mode >> O_RWSIZE_SHIFT, swab))) + goto out; + + start += r; + size -= r; + } while (size); + +out: + close(fd); + + return ret ? 1 : 0; +} + +static const __maybe_unused char cmd_md_help[] = +"Usage md [OPTIONS] <region>\n" +"display (hexdump) a memory region.\n" +"options:\n" +" -s <file> display file (default /dev/mem)\n" +" -b output in bytes\n" +" -w output in halfwords (16bit)\n" +" -l output in words (32bit)\n" +" -x swap bytes at output\n" +"\n" +"Memory regions:\n" +"Memory regions can be specified in two different forms: start+size\n" +"or start-end, If <start> is omitted it defaults to 0. If end is omitted it\n" +"defaults to the end of the device, except for interactive commands like md\n" +"and mw for which it defaults to 0x100.\n" +"Sizes can be specified as decimal, or if prefixed with 0x as hexadecimal.\n" +"an optional suffix of k, M or G is for kibibytes, Megabytes or Gigabytes,\n" +"respectively\n"; + + +BAREBOX_CMD_START(md) + .cmd = do_mem_md, + .usage = "memory display", + BAREBOX_CMD_HELP(cmd_md_help) +BAREBOX_CMD_END diff --git a/commands/mem.c b/commands/mem.c index 51aa04daa2..7eb60afec3 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -39,80 +39,11 @@ #define PRINTF(fmt,args...) #endif -#define RW_BUF_SIZE 4096 -static char *rw_buf; +char *mem_rw_buf; static char *DEVMEM = "/dev/mem"; -/* Memory Display - * - * Syntax: - * md{.b, .w, .l} {addr} {len} - */ -#define DISP_LINE_LEN 16 - -int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab) -{ - ulong linebytes, i; - u_char *cp; - - /* Print the lines. - * - * We buffer all read data, so we can make sure data is read only - * once, and all accesses are with the specified bus width. - */ - do { - char linebuf[DISP_LINE_LEN]; - uint *uip = (uint *)linebuf; - ushort *usp = (ushort *)linebuf; - u_char *ucp = (u_char *)linebuf; - uint count = 52; - - printf("%08llx:", offs); - linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; - - for (i = 0; i < linebytes; i += size) { - if (size == 4) { - u32 res; - res = (*uip++ = *((uint *)addr)); - if (swab) - res = __swab32(res); - count -= printf(" %08x", res); - } else if (size == 2) { - u16 res; - res = (*usp++ = *((ushort *)addr)); - if (swab) - res = __swab16(res); - count -= printf(" %04x", res); - } else { - count -= printf(" %02x", (*ucp++ = *((u_char *)addr))); - } - addr += size; - offs += size; - } - - while(count--) - putchar(' '); - - cp = (u_char *)linebuf; - for (i=0; i<linebytes; i++) { - if ((*cp < 0x20) || (*cp > 0x7e)) - putchar('.'); - else - printf("%c", *cp); - cp++; - } - putchar('\n'); - nbytes -= linebytes; - if (ctrlc()) { - return -EINTR; - } - } while (nbytes > 0); - - return 0; -} - -static int open_and_lseek(const char *filename, int mode, loff_t pos) +int open_and_lseek(const char *filename, int mode, loff_t pos) { int fd, ret; @@ -135,7 +66,11 @@ static int open_and_lseek(const char *filename, int mode, loff_t pos) return fd; } -static int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, +/* + * Common function for parsing options for the 'md', 'mw', 'memcpy', 'memcmp' + * commands. + */ +int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, char **sourcefile, char **destfile, int *swab) { int opt; @@ -168,438 +103,6 @@ static int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, return 0; } -static int do_mem_md(int argc, char *argv[]) -{ - loff_t start = 0, size = 0x100; - int r, now; - int ret = 0; - int fd; - char *filename = DEVMEM; - int mode = O_RWSIZE_4; - int swab = 0; - - if (argc < 2) - return COMMAND_ERROR_USAGE; - - if (mem_parse_options(argc, argv, "bwls:x", &mode, &filename, NULL, - &swab) < 0) - return 1; - - if (optind < argc) { - if (parse_area_spec(argv[optind], &start, &size)) { - printf("could not parse: %s\n", argv[optind]); - return 1; - } - if (size == ~0) - size = 0x100; - } - - fd = open_and_lseek(filename, mode | O_RDONLY, start); - if (fd < 0) - return 1; - - do { - now = min(size, (loff_t)RW_BUF_SIZE); - r = read(fd, rw_buf, now); - if (r < 0) { - perror("read"); - goto out; - } - if (!r) - goto out; - - if ((ret = memory_display(rw_buf, start, r, - mode >> O_RWSIZE_SHIFT, swab))) - goto out; - - start += r; - size -= r; - } while (size); - -out: - close(fd); - - return ret ? 1 : 0; -} - -static const __maybe_unused char cmd_md_help[] = -"Usage md [OPTIONS] <region>\n" -"display (hexdump) a memory region.\n" -"options:\n" -" -s <file> display file (default /dev/mem)\n" -" -b output in bytes\n" -" -w output in halfwords (16bit)\n" -" -l output in words (32bit)\n" -" -x swap bytes at output\n" -"\n" -"Memory regions:\n" -"Memory regions can be specified in two different forms: start+size\n" -"or start-end, If <start> is omitted it defaults to 0. If end is omitted it\n" -"defaults to the end of the device, except for interactive commands like md\n" -"and mw for which it defaults to 0x100.\n" -"Sizes can be specified as decimal, or if prefixed with 0x as hexadecimal.\n" -"an optional suffix of k, M or G is for kibibytes, Megabytes or Gigabytes,\n" -"respectively\n"; - - -BAREBOX_CMD_START(md) - .cmd = do_mem_md, - .usage = "memory display", - BAREBOX_CMD_HELP(cmd_md_help) -BAREBOX_CMD_END - -static int do_mem_mw(int argc, char *argv[]) -{ - int ret = 0; - int fd; - char *filename = DEVMEM; - int mode = O_RWSIZE_4; - loff_t adr; - int swab = 0; - - if (mem_parse_options(argc, argv, "bwld:x", &mode, NULL, &filename, - &swab) < 0) - return 1; - - if (optind + 1 >= argc) - return COMMAND_ERROR_USAGE; - - adr = strtoull_suffix(argv[optind++], NULL, 0); - - fd = open_and_lseek(filename, mode | O_WRONLY, adr); - if (fd < 0) - return 1; - - while (optind < argc) { - u8 val8; - u16 val16; - u32 val32; - switch (mode) { - case O_RWSIZE_1: - val8 = simple_strtoul(argv[optind], NULL, 0); - ret = write(fd, &val8, 1); - break; - case O_RWSIZE_2: - val16 = simple_strtoul(argv[optind], NULL, 0); - if (swab) - val16 = __swab16(val16); - ret = write(fd, &val16, 2); - break; - case O_RWSIZE_4: - val32 = simple_strtoul(argv[optind], NULL, 0); - if (swab) - val32 = __swab32(val32); - ret = write(fd, &val32, 4); - break; - } - if (ret < 0) { - perror("write"); - break; - } - ret = 0; - optind++; - } - - close(fd); - - return ret ? 1 : 0; -} - -static const __maybe_unused char cmd_mw_help[] = -"Usage: mw [OPTIONS] <region> <value(s)>\n" -"Write value(s) to the specifies region.\n" -"options:\n" -" -b, -w, -l use byte, halfword, or word accesses\n" -" -d <file> write file (default /dev/mem)\n"; - -BAREBOX_CMD_START(mw) - .cmd = do_mem_mw, - .usage = "memory write (fill)", - BAREBOX_CMD_HELP(cmd_mw_help) -BAREBOX_CMD_END - -static int do_mem_cmp(int argc, char *argv[]) -{ - loff_t addr1, addr2, count = ~0; - int mode = O_RWSIZE_1; - char *sourcefile = DEVMEM; - char *destfile = DEVMEM; - int sourcefd, destfd; - char *rw_buf1; - int ret = 1; - int offset = 0; - struct stat statbuf; - - if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, - &destfile, NULL) < 0) - return 1; - - if (optind + 2 > argc) - return COMMAND_ERROR_USAGE; - - addr1 = strtoull_suffix(argv[optind], NULL, 0); - addr2 = strtoull_suffix(argv[optind + 1], NULL, 0); - - if (optind + 2 == argc) { - if (sourcefile == DEVMEM) { - printf("source and count not given\n"); - return 1; - } - if (stat(sourcefile, &statbuf)) { - perror("stat"); - return 1; - } - count = statbuf.st_size - addr1; - } else { - count = strtoull_suffix(argv[optind + 2], NULL, 0); - } - - sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, addr1); - if (sourcefd < 0) - return 1; - - destfd = open_and_lseek(destfile, mode | O_RDONLY, addr2); - if (destfd < 0) { - close(sourcefd); - return 1; - } - - rw_buf1 = xmalloc(RW_BUF_SIZE); - - while (count > 0) { - int now, r1, r2, i; - - now = min((loff_t)RW_BUF_SIZE, count); - - r1 = read(sourcefd, rw_buf, now); - if (r1 < 0) { - perror("read"); - goto out; - } - - r2 = read(destfd, rw_buf1, now); - if (r2 < 0) { - perror("read"); - goto out; - } - - if (r1 != now || r2 != now) { - printf("regions differ in size\n"); - goto out; - } - - for (i = 0; i < now; i++) { - if (rw_buf[i] != rw_buf1[i]) { - printf("files differ at offset %d\n", offset); - goto out; - } - offset++; - } - - count -= now; - } - - printf("OK\n"); - ret = 0; -out: - close(sourcefd); - close(destfd); - free(rw_buf1); - - return ret; -} - -static const __maybe_unused char cmd_memcmp_help[] = -"Usage: memcmp [OPTIONS] <addr1> <addr2> <count>\n" -"\n" -"options:\n" -" -b, -w, -l use byte, halfword, or word accesses\n" -" -s <file> source file (default /dev/mem)\n" -" -d <file> destination file (default /dev/mem)\n" -"\n" -"Compare memory regions specified with addr1 and addr2\n" -"of size <count> bytes. If source is a file count can\n" -"be left unspecified in which case the whole file is\n" -"compared\n"; - -BAREBOX_CMD_START(memcmp) - .cmd = do_mem_cmp, - .usage = "memory compare", - BAREBOX_CMD_HELP(cmd_memcmp_help) -BAREBOX_CMD_END - -static int do_mem_cp(int argc, char *argv[]) -{ - loff_t count, dest, src; - char *sourcefile = DEVMEM; - char *destfile = DEVMEM; - int sourcefd, destfd; - int mode = 0; - struct stat statbuf; - int ret = 0; - - if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, - &destfile, NULL) < 0) - return 1; - - if (optind + 2 > argc) - return COMMAND_ERROR_USAGE; - - src = strtoull_suffix(argv[optind], NULL, 0); - dest = strtoull_suffix(argv[optind + 1], NULL, 0); - - if (optind + 2 == argc) { - if (sourcefile == DEVMEM) { - printf("source and count not given\n"); - return 1; - } - if (stat(sourcefile, &statbuf)) { - perror("stat"); - return 1; - } - count = statbuf.st_size - src; - } else { - count = strtoull_suffix(argv[optind + 2], NULL, 0); - } - - sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, src); - if (sourcefd < 0) - return 1; - - destfd = open_and_lseek(destfile, O_WRONLY | O_CREAT | mode, dest); - if (destfd < 0) { - close(sourcefd); - return 1; - } - - while (count > 0) { - int now, r, w, tmp; - - now = min((loff_t)RW_BUF_SIZE, count); - - r = read(sourcefd, rw_buf, now); - if (r < 0) { - perror("read"); - goto out; - } - - if (!r) - break; - - tmp = 0; - now = r; - while (now) { - w = write(destfd, rw_buf + tmp, now); - if (w < 0) { - perror("write"); - goto out; - } - if (!w) - break; - - now -= w; - tmp += w; - } - - count -= r; - - if (ctrlc()) - goto out; - } - - if (count) { - printf("ran out of data\n"); - ret = 1; - } - -out: - close(sourcefd); - close(destfd); - - return ret; -} - -static const __maybe_unused char cmd_memcpy_help[] = -"Usage: memcpy [OPTIONS] <src> <dst> <count>\n" -"\n" -"options:\n" -" -b, -w, -l use byte, halfword, or word accesses\n" -" -s <file> source file (default /dev/mem)\n" -" -d <file> destination file (default /dev/mem)\n" -"\n" -"Copy memory at <src> of <count> bytes to <dst>\n"; - -BAREBOX_CMD_START(memcpy) - .cmd = do_mem_cp, - .usage = "memory copy", - BAREBOX_CMD_HELP(cmd_memcpy_help) -BAREBOX_CMD_END - -static int do_memset(int argc, char *argv[]) -{ - loff_t s, c, n; - int fd; - char *buf; - int mode = O_RWSIZE_1; - int ret = 1; - char *file = DEVMEM; - - if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &file, - NULL) < 0) - return 1; - - if (optind + 3 > argc) - return COMMAND_ERROR_USAGE; - - s = strtoull_suffix(argv[optind], NULL, 0); - c = strtoull_suffix(argv[optind + 1], NULL, 0); - n = strtoull_suffix(argv[optind + 2], NULL, 0); - - fd = open_and_lseek(file, mode | O_WRONLY, s); - if (fd < 0) - return 1; - - buf = xmalloc(RW_BUF_SIZE); - memset(buf, c, RW_BUF_SIZE); - - while (n > 0) { - int now; - - now = min((loff_t)RW_BUF_SIZE, n); - - ret = write(fd, buf, now); - if (ret < 0) { - perror("write"); - ret = 1; - goto out; - } - - n -= now; - } - - ret = 0; -out: - close(fd); - free(buf); - - return ret; -} - -static const __maybe_unused char cmd_memset_help[] = -"Usage: memset [OPTIONS] <addr> <c> <n>\n" -"\n" -"options:\n" -" -b, -w, -l use byte, halfword, or word accesses\n" -" -d <file> destination file (default /dev/mem)\n" -"\n" -"Fill the first <n> bytes at offset <addr> with byte <c>\n"; - -BAREBOX_CMD_START(memset) - .cmd = do_memset, - .usage = "memory fill", - BAREBOX_CMD_HELP(cmd_memset_help) -BAREBOX_CMD_END - static struct file_operations memops = { .read = mem_read, .write = mem_write, @@ -631,16 +134,11 @@ static struct driver_d mem_drv = { static int mem_init(void) { - rw_buf = malloc(RW_BUF_SIZE); - if(!rw_buf) { - printf("%s: Out of memory\n", __FUNCTION__); - return -1; - } + mem_rw_buf = malloc(RW_BUF_SIZE); + if(!mem_rw_buf) + return -ENOMEM; add_mem_device("mem", 0, ~0, IORESOURCE_MEM_WRITEABLE); - platform_driver_register(&mem_drv); - - return 0; + return platform_driver_register(&mem_drv); } - device_initcall(mem_init); diff --git a/commands/memcmp.c b/commands/memcmp.c new file mode 100644 index 0000000000..4a03862541 --- /dev/null +++ b/commands/memcmp.c @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * 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 version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +/* + * Memory Functions + * + * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +extern char *mem_rw_buf; + +static char *devmem = "/dev/mem"; + +static int do_memcmp(int argc, char *argv[]) +{ + loff_t addr1, addr2, count = ~0; + int mode = O_RWSIZE_1; + char *sourcefile = devmem; + char *destfile = devmem; + int sourcefd, destfd; + char *rw_buf1; + int ret = 1; + int offset = 0; + struct stat statbuf; + + if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, + &destfile, NULL) < 0) + return 1; + + if (optind + 2 > argc) + return COMMAND_ERROR_USAGE; + + addr1 = strtoull_suffix(argv[optind], NULL, 0); + addr2 = strtoull_suffix(argv[optind + 1], NULL, 0); + + if (optind + 2 == argc) { + if (sourcefile == devmem) { + printf("source and count not given\n"); + return 1; + } + if (stat(sourcefile, &statbuf)) { + perror("stat"); + return 1; + } + count = statbuf.st_size - addr1; + } else { + count = strtoull_suffix(argv[optind + 2], NULL, 0); + } + + sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, addr1); + if (sourcefd < 0) + return 1; + + destfd = open_and_lseek(destfile, mode | O_RDONLY, addr2); + if (destfd < 0) { + close(sourcefd); + return 1; + } + + rw_buf1 = xmalloc(RW_BUF_SIZE); + + while (count > 0) { + int now, r1, r2, i; + + now = min((loff_t)RW_BUF_SIZE, count); + + r1 = read(sourcefd, mem_rw_buf, now); + if (r1 < 0) { + perror("read"); + goto out; + } + + r2 = read(destfd, rw_buf1, now); + if (r2 < 0) { + perror("read"); + goto out; + } + + if (r1 != now || r2 != now) { + printf("regions differ in size\n"); + goto out; + } + + for (i = 0; i < now; i++) { + if (mem_rw_buf[i] != rw_buf1[i]) { + printf("files differ at offset %d\n", offset); + goto out; + } + offset++; + } + + count -= now; + } + + printf("OK\n"); + ret = 0; +out: + close(sourcefd); + close(destfd); + free(rw_buf1); + + return ret; +} + +static const __maybe_unused char cmd_memcmp_help[] = +"Usage: memcmp [OPTIONS] <addr1> <addr2> <count>\n" +"\n" +"options:\n" +" -b, -w, -l use byte, halfword, or word accesses\n" +" -s <file> source file (default /dev/mem)\n" +" -d <file> destination file (default /dev/mem)\n" +"\n" +"Compare memory regions specified with addr1 and addr2\n" +"of size <count> bytes. If source is a file count can\n" +"be left unspecified in which case the whole file is\n" +"compared\n"; + +BAREBOX_CMD_START(memcmp) + .cmd = do_memcmp, + .usage = "memory compare", + BAREBOX_CMD_HELP(cmd_memcmp_help) +BAREBOX_CMD_END diff --git a/commands/memcpy.c b/commands/memcpy.c new file mode 100644 index 0000000000..98f099f18d --- /dev/null +++ b/commands/memcpy.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * 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 version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +/* + * Memory Functions + * + * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +extern char *mem_rw_buf; + +static char *devmem = "/dev/mem"; + +static int do_memcpy(int argc, char *argv[]) +{ + loff_t count, dest, src; + char *sourcefile = devmem; + char *destfile = devmem; + int sourcefd, destfd; + int mode = 0; + struct stat statbuf; + int ret = 0; + + if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, + &destfile, NULL) < 0) + return 1; + + if (optind + 2 > argc) + return COMMAND_ERROR_USAGE; + + src = strtoull_suffix(argv[optind], NULL, 0); + dest = strtoull_suffix(argv[optind + 1], NULL, 0); + + if (optind + 2 == argc) { + if (sourcefile == devmem) { + printf("source and count not given\n"); + return 1; + } + if (stat(sourcefile, &statbuf)) { + perror("stat"); + return 1; + } + count = statbuf.st_size - src; + } else { + count = strtoull_suffix(argv[optind + 2], NULL, 0); + } + + sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, src); + if (sourcefd < 0) + return 1; + + destfd = open_and_lseek(destfile, O_WRONLY | O_CREAT | mode, dest); + if (destfd < 0) { + close(sourcefd); + return 1; + } + + while (count > 0) { + int now, r, w, tmp; + + now = min((loff_t)RW_BUF_SIZE, count); + + r = read(sourcefd, mem_rw_buf, now); + if (r < 0) { + perror("read"); + goto out; + } + + if (!r) + break; + + tmp = 0; + now = r; + while (now) { + w = write(destfd, mem_rw_buf + tmp, now); + if (w < 0) { + perror("write"); + goto out; + } + if (!w) + break; + + now -= w; + tmp += w; + } + + count -= r; + + if (ctrlc()) + goto out; + } + + if (count) { + printf("ran out of data\n"); + ret = 1; + } + +out: + close(sourcefd); + close(destfd); + + return ret; +} + +static const __maybe_unused char cmd_memcpy_help[] = +"Usage: memcpy [OPTIONS] <src> <dst> <count>\n" +"\n" +"options:\n" +" -b, -w, -l use byte, halfword, or word accesses\n" +" -s <file> source file (default /dev/mem)\n" +" -d <file> destination file (default /dev/mem)\n" +"\n" +"Copy memory at <src> of <count> bytes to <dst>\n"; + +BAREBOX_CMD_START(memcpy) + .cmd = do_memcpy, + .usage = "memory copy", + BAREBOX_CMD_HELP(cmd_memcpy_help) +BAREBOX_CMD_END diff --git a/commands/memset.c b/commands/memset.c new file mode 100644 index 0000000000..48e55bc68e --- /dev/null +++ b/commands/memset.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * 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 version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +/* + * Memory Functions + * + * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +extern char *mem_rw_buf; + +static int do_memset(int argc, char *argv[]) +{ + loff_t s, c, n; + int fd; + char *buf; + int mode = O_RWSIZE_1; + int ret = 1; + char *file = "/dev/mem"; + + if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &file, + NULL) < 0) + return 1; + + if (optind + 3 > argc) + return COMMAND_ERROR_USAGE; + + s = strtoull_suffix(argv[optind], NULL, 0); + c = strtoull_suffix(argv[optind + 1], NULL, 0); + n = strtoull_suffix(argv[optind + 2], NULL, 0); + + fd = open_and_lseek(file, mode | O_WRONLY, s); + if (fd < 0) + return 1; + + buf = xmalloc(RW_BUF_SIZE); + memset(buf, c, RW_BUF_SIZE); + + while (n > 0) { + int now; + + now = min((loff_t)RW_BUF_SIZE, n); + + ret = write(fd, buf, now); + if (ret < 0) { + perror("write"); + ret = 1; + goto out; + } + + n -= now; + } + + ret = 0; +out: + close(fd); + free(buf); + + return ret; +} + +static const __maybe_unused char cmd_memset_help[] = +"Usage: memset [OPTIONS] <addr> <c> <n>\n" +"\n" +"options:\n" +" -b, -w, -l use byte, halfword, or word accesses\n" +" -d <file> destination file (default /dev/mem)\n" +"\n" +"Fill the first <n> bytes at offset <addr> with byte <c>\n"; + +BAREBOX_CMD_START(memset) + .cmd = do_memset, + .usage = "memory fill", + BAREBOX_CMD_HELP(cmd_memset_help) +BAREBOX_CMD_END diff --git a/commands/mm.c b/commands/mm.c new file mode 100644 index 0000000000..f51fd27cb0 --- /dev/null +++ b/commands/mm.c @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2013 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * 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 version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +static int do_mem_mm(int argc, char *argv[]) +{ + int ret = 0; + int fd; + char *filename = "/dev/mem"; + int mode = O_RWSIZE_4; + loff_t adr; + int swab = 0; + u8 val8; + u16 val16; + u32 val32; + u32 value, mask; + + if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename, + &swab) < 0) + return 1; + + if (optind + 2 >= argc) + return COMMAND_ERROR_USAGE; + + adr = strtoull_suffix(argv[optind++], NULL, 0); + value = simple_strtoul(argv[optind++], NULL, 0); + mask = simple_strtoul(argv[optind++], NULL, 0); + + fd = open_and_lseek(filename, mode | O_RDWR, adr); + if (fd < 0) + return 1; + + switch (mode) { + case O_RWSIZE_1: + ret = pread(fd, &val8, 1, adr); + if (ret < 0) + goto out_read; + val8 &= ~mask; + val8 |= (value & mask); + ret = pwrite(fd, &val8, 1, adr); + if (ret < 0) + goto out_write; + break; + case O_RWSIZE_2: + ret = pread(fd, &val16, 2, adr); + if (ret < 0) + goto out_read; + val16 &= ~mask; + val16 |= (value & mask); + ret = pwrite(fd, &val16, 2, adr); + if (ret < 0) + goto out_write; + break; + case O_RWSIZE_4: + if (ret < 0) + goto out_read; + ret = pread(fd, &val32, 4, adr); + val32 &= ~mask; + val32 |= (value & mask); + ret = pwrite(fd, &val32, 4, adr); + if (ret < 0) + goto out_write; + break; + } + + close(fd); + + return 0; + +out_read: + perror("read"); + close(fd); + return 1; + +out_write: + perror("write"); + close(fd); + return 1; +} + +static const __maybe_unused char cmd_mm_help[] = +"Usage: mm [OPTIONS] <adr> <val> <mask>\n" +"set/clear bits specified with <mask> in <adr> to <value>\n" +"options:\n" +" -b, -w, -l use byte, halfword, or word accesses\n" +" -d <file> write file (default /dev/mem)\n"; + +BAREBOX_CMD_START(mm) + .cmd = do_mem_mm, + .usage = "memory modify write with mask", + BAREBOX_CMD_HELP(cmd_mm_help) +BAREBOX_CMD_END diff --git a/commands/mw.c b/commands/mw.c new file mode 100644 index 0000000000..d7d73a8f43 --- /dev/null +++ b/commands/mw.c @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * 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 version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +/* + * Memory Functions + * + * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +static int do_mem_mw(int argc, char *argv[]) +{ + int ret = 0; + int fd; + char *filename = "/dev/mem"; + int mode = O_RWSIZE_4; + loff_t adr; + int swab = 0; + + if (mem_parse_options(argc, argv, "bwld:x", &mode, NULL, &filename, + &swab) < 0) + return 1; + + if (optind + 1 >= argc) + return COMMAND_ERROR_USAGE; + + adr = strtoull_suffix(argv[optind++], NULL, 0); + + fd = open_and_lseek(filename, mode | O_WRONLY, adr); + if (fd < 0) + return 1; + + while (optind < argc) { + u8 val8; + u16 val16; + u32 val32; + switch (mode) { + case O_RWSIZE_1: + val8 = simple_strtoul(argv[optind], NULL, 0); + ret = write(fd, &val8, 1); + break; + case O_RWSIZE_2: + val16 = simple_strtoul(argv[optind], NULL, 0); + if (swab) + val16 = __swab16(val16); + ret = write(fd, &val16, 2); + break; + case O_RWSIZE_4: + val32 = simple_strtoul(argv[optind], NULL, 0); + if (swab) + val32 = __swab32(val32); + ret = write(fd, &val32, 4); + break; + } + if (ret < 0) { + perror("write"); + break; + } + ret = 0; + optind++; + } + + close(fd); + + return ret ? 1 : 0; +} + +static const __maybe_unused char cmd_mw_help[] = +"Usage: mw [OPTIONS] <region> <value(s)>\n" +"Write value(s) to the specifies region.\n" +"options:\n" +" -b, -w, -l use byte, halfword, or word accesses\n" +" -d <file> write file (default /dev/mem)\n"; + +BAREBOX_CMD_START(mw) + .cmd = do_mem_mw, + .usage = "memory write (fill)", + BAREBOX_CMD_HELP(cmd_mw_help) +BAREBOX_CMD_END diff --git a/commands/of_property.c b/commands/of_property.c index 6311b7022a..44bb38801e 100644 --- a/commands/of_property.c +++ b/commands/of_property.c @@ -62,7 +62,7 @@ static int of_parse_prop_cells(char * const *newval, int count, char *data, int /* If the ptr didn't advance, something went wrong */ if ((newp - cp) <= 0) { - printf("cannot not convert \"%s\"\n", cp); + printf("cannot convert \"%s\"\n", cp); return -EINVAL; } @@ -105,7 +105,7 @@ static int of_parse_prop_stream(char * const *newval, int count, char *data, int /* If the ptr didn't advance, something went wrong */ if ((newp - cp) <= 0) { - printf("cannot not convert \"%s\"\n", cp); + printf("cannot convert \"%s\"\n", cp); return -EINVAL; } } diff --git a/commands/ubi.c b/commands/ubi.c index 1653eaa486..73483948b7 100644 --- a/commands/ubi.c +++ b/commands/ubi.c @@ -47,7 +47,7 @@ static int do_ubimkvol(int argc, char *argv[]) static const __maybe_unused char cmd_ubimkvol_help[] = "Usage: ubimkvol <ubidev> <name> <size>\n" "Create an ubi volume on <ubidev> with name <name> and size <size>\n" -"If size os zero all available space is used for the volume\n"; +"If size is zero all available space is used for the volume\n"; BAREBOX_CMD_START(ubimkvol) .cmd = do_ubimkvol, diff --git a/common/Makefile b/common/Makefile index dcb07c271c..94601728d3 100644 --- a/common/Makefile +++ b/common/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_CMD_LOADS) += s_record.o obj-$(CONFIG_OFTREE) += oftree.o obj-y += memory.o +obj-y += memory_display.o obj-$(CONFIG_MALLOC_DLMALLOC) += dlmalloc.o obj-$(CONFIG_MALLOC_TLSF) += tlsf_malloc.o obj-$(CONFIG_MALLOC_TLSF) += tlsf.o diff --git a/common/filetype.c b/common/filetype.c index 8652f1d7af..1ff3dd202a 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -151,6 +151,28 @@ enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec) return filetype_mbr; } +enum filetype file_detect_partition_table(const void *_buf, size_t bufsize) +{ + const u8 *buf8 = _buf; + enum filetype type; + + if (bufsize < 512) + return filetype_unknown; + + /* + * EFI GPT need to be detected before MBR otherwise + * we will detect a MBR + */ + if (bufsize >= 520 && is_gpt_valid(buf8)) + return filetype_gpt; + + type = is_fat_or_mbr(buf8, NULL); + if (type != filetype_unknown) + return type; + + return filetype_unknown; +} + enum filetype file_detect_type(const void *_buf, size_t bufsize) { const u32 *buf = _buf; @@ -204,21 +226,11 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize) if (bufsize < 512) return filetype_unknown; - /* - * EFI GPT need to be detected before MBR otherwise - * we will detect a MBR - */ - if (bufsize >= 520 && is_gpt_valid(buf8)) - return filetype_gpt; - - type = is_fat_or_mbr(buf8, NULL); + type = file_detect_partition_table(_buf, bufsize); if (type != filetype_unknown) return type; - if (bufsize < 1536) - return filetype_unknown; - - if (buf16[512 + 28] == le16_to_cpu(0xef53)) + if (bufsize >= 1536 && buf16[512 + 28] == le16_to_cpu(0xef53)) return filetype_ext; return filetype_unknown; diff --git a/common/memory_display.c b/common/memory_display.c new file mode 100644 index 0000000000..eb188e1d79 --- /dev/null +++ b/common/memory_display.c @@ -0,0 +1,64 @@ +#include <common.h> + +#define DISP_LINE_LEN 16 + +int memory_display(char *addr, loff_t offs, unsigned nbytes, int size, int swab) +{ + ulong linebytes, i; + u_char *cp; + + /* Print the lines. + * + * We buffer all read data, so we can make sure data is read only + * once, and all accesses are with the specified bus width. + */ + do { + char linebuf[DISP_LINE_LEN]; + uint32_t *uip = (uint *)linebuf; + uint16_t *usp = (ushort *)linebuf; + uint8_t *ucp = (u_char *)linebuf; + unsigned count = 52; + + printf("%08llx:", offs); + linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; + + for (i = 0; i < linebytes; i += size) { + if (size == 4) { + u32 res; + res = (*uip++ = *((uint *)addr)); + if (swab) + res = __swab32(res); + count -= printf(" %08x", res); + } else if (size == 2) { + u16 res; + res = (*usp++ = *((ushort *)addr)); + if (swab) + res = __swab16(res); + count -= printf(" %04x", res); + } else { + count -= printf(" %02x", (*ucp++ = *((u_char *)addr))); + } + addr += size; + offs += size; + } + + while (count--) + putchar(' '); + + cp = (uint8_t *)linebuf; + for (i = 0; i < linebytes; i++) { + if ((*cp < 0x20) || (*cp > 0x7e)) + putchar('.'); + else + printf("%c", *cp); + cp++; + } + + putchar('\n'); + nbytes -= linebytes; + if (ctrlc()) + return -EINTR; + } while (nbytes > 0); + + return 0; +} diff --git a/common/partitions.c b/common/partitions.c index dd25160602..683b2586e4 100644 --- a/common/partitions.c +++ b/common/partitions.c @@ -89,7 +89,7 @@ static struct partition_parser *partition_parser_get_by_filetype(uint8_t *buf) struct partition_parser *parser; /* first new partition table as EFI GPT */ - type = file_detect_type(buf, SECTOR_SIZE * 2); + type = file_detect_partition_table(buf, SECTOR_SIZE * 2); list_for_each_entry(parser, &partition_parser_list, list) { if (parser->type == type) @@ -100,7 +100,7 @@ static struct partition_parser *partition_parser_get_by_filetype(uint8_t *buf) * so if EFI GPT not enable take it as MBR * useful for compatibility */ - type = file_detect_type(buf, SECTOR_SIZE); + type = file_detect_partition_table(buf, SECTOR_SIZE); list_for_each_entry(parser, &partition_parser_list, list) { if (parser->type == type) diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot index f7f460ea06..eed4b3c8b7 100644 --- a/defaultenv-2/base/bin/boot +++ b/defaultenv-2/base/bin/boot @@ -17,7 +17,7 @@ $0 [OPTIONS] [source]\n while getopt "vdhl" opt; do if [ ${opt} = v ]; then - BOOT_BOOTMOPTS="$BOOT_BOOTMOPTS -v" + BOOT_BOOTM_OPTS="$BOOT_BOOTM_OPTS -v" BOOT_VERBOSE=1 elif [ ${opt} = d ]; then BOOT_DRYRUN=1 diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init index 6a658d137c..ca02ba6427 100644 --- a/defaultenv-2/base/bin/init +++ b/defaultenv-2/base/bin/init @@ -16,12 +16,6 @@ global editcmd=sedit [ -e /env/config-board ] && /env/config-board /env/config -if [ -e /env/menu ]; then - echo -e -n "\nHit m for menu or any other key to stop autoboot: " -else - echo -e -n "\nHit any key to stop autoboot: " -fi - # allow to stop the boot before execute the /env/init/* # but without waiting timeout -s -a -v key 0 @@ -34,6 +28,12 @@ for i in /env/init/*; do . $i done +if [ -e /env/menu ]; then + echo -e -n "\nHit m for menu or any other key to stop autoboot: " +else + echo -e -n "\nHit any key to stop autoboot: " +fi + timeout -a $global.autoboot_timeout -v key autoboot="$?" diff --git a/defaultenv-2/base/boot/net b/defaultenv-2/base/boot/net index 90c25aa147..05bb728fa1 100644 --- a/defaultenv-2/base/boot/net +++ b/defaultenv-2/base/boot/net @@ -8,7 +8,12 @@ fi path="/mnt/tftp" global.bootm.image="${path}/${global.user}-linux-${global.hostname}" -#global.bootm.oftree="${path}/${global.user}-oftree-${global.hostname}" + +oftree="${path}/${global.user}-oftree-${global.hostname}" +if [ -f "${oftree}" ]; then + global.bootm.oftree="$oftree" +fi + nfsroot="/home/${global.user}/nfsroot/${global.hostname}" bootargs-ip global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp" diff --git a/drivers/Kconfig b/drivers/Kconfig index b213849af0..3a95e5140d 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -23,5 +23,6 @@ source "drivers/pwm/Kconfig" source "drivers/dma/Kconfig" source "drivers/gpio/Kconfig" source "drivers/w1/Kconfig" +source "drivers/pinctrl/Kconfig" endmenu diff --git a/drivers/Makefile b/drivers/Makefile index 03a10fbf2d..daf821c83c 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -22,3 +22,4 @@ obj-y += watchdog/ obj-y += gpio/ obj-$(CONFIG_OFTREE) += of/ obj-$(CONFIG_W1) += w1/ +obj-y += pinctrl/ diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 42f2065a61..9830cc07a8 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -35,7 +35,6 @@ config DISK_ATA config DISK_AHCI bool "AHCI support" select DISK_ATA - select DISK_DRIVE config DISK_AHCI_IMX depends on ARCH_IMX diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 487f478d69..edd49b367f 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -31,6 +31,7 @@ #include <fs.h> #include <linux/list.h> #include <complete.h> +#include <pinctrl.h> LIST_HEAD(device_list); EXPORT_SYMBOL(device_list); @@ -79,6 +80,8 @@ int device_probe(struct device_d *dev) { int ret; + pinctrl_select_state_default(dev); + ret = dev->bus->probe(dev); if (ret) { dev_err(dev, "probe failed: %s\n", strerror(-ret)); diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 338b9e8dfe..256927eb4e 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -182,7 +182,7 @@ int clk_register_clkdev(struct clk *clk, const char *con_id, va_list ap; if (IS_ERR(clk)) - return PTR_ERR(clk); + return PTR_ERR(clk); va_start(ap, dev_fmt); cl = clkdev_alloc(clk, con_id, dev_fmt, ap); diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index ea07028db5..74a4baa788 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -27,6 +27,9 @@ config GPIO_GENERIC_PLATFORM Say yes here to support basic platform memory-mapped GPIO controllers +config GPIO_IMX + def_bool ARCH_IMX + config GPIO_PL061 bool "PrimeCell PL061 GPIO support" depends on ARM_AMBA diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 00acb68b37..205d5531bb 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -1,6 +1,8 @@ -obj-$(CONFIG_GPIOLIB) += gpio.o +obj-$(CONFIG_GPIOLIB) += gpiolib.o + obj-$(CONFIG_GPIO_BCM2835) += gpio-bcm2835.o obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o +obj-$(CONFIG_GPIO_IMX) += gpio-imx.o obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o diff --git a/arch/arm/mach-imx/gpio.c b/drivers/gpio/gpio-imx.c index 1bf4100964..1bf4100964 100644 --- a/arch/arm/mach-imx/gpio.c +++ b/drivers/gpio/gpio-imx.c diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpiolib.c index 6398268eae..6398268eae 100644 --- a/drivers/gpio/gpio.c +++ b/drivers/gpio/gpiolib.c diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c index f032403109..c5fd306a9a 100644 --- a/drivers/mci/atmel_mci.c +++ b/drivers/mci/atmel_mci.c @@ -262,11 +262,13 @@ static int atmci_read_response(struct atmel_mci *host, unsigned int stat) { struct mci_cmd *cmd = host->cmd; int i; - u32 *resp = (u32 *)cmd->response; + u32 *resp; if (!cmd) return 0; + resp = (u32 *)cmd->response; + if (stat & (ATMCI_RTOE | ATMCI_DTOE)) { dev_err(host->hw_dev, "command/data timeout\n"); return -ETIMEDOUT; diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c index 8c2695cded..f4fdac8e01 100644 --- a/drivers/mci/imx-esdhc.c +++ b/drivers/mci/imx-esdhc.c @@ -61,14 +61,11 @@ struct fsl_esdhc { u32 fevt; char reserved2[168]; u32 hostver; - char reserved3[780]; - u32 scr; }; struct fsl_esdhc_host { struct mci_host mci; struct fsl_esdhc __iomem *regs; - u32 no_snoop; unsigned long cur_clock; struct device_d *dev; struct clk *clk; @@ -454,10 +451,6 @@ static int esdhc_init(struct mci_host *mci, struct device_d *dev) int timeout = 1000; int ret = 0; - /* Enable cache snooping */ - if (host && !host->no_snoop) - esdhc_write32(®s->scr, 0x00000040); - /* Reset the entire host controller */ esdhc_write32(®s->sysctl, SYSCTL_RSTA); diff --git a/drivers/mci/imx.c b/drivers/mci/imx.c index 3d9bd0deb1..c98596434e 100644 --- a/drivers/mci/imx.c +++ b/drivers/mci/imx.c @@ -225,12 +225,13 @@ static int mxcmci_read_response(struct mxcmci_host *host, unsigned int stat) { struct mci_cmd *cmd = host->cmd; int i; - u32 a, b, c; - u32 *resp = (u32 *)cmd->response; + u32 a, b, c, *resp; if (!cmd) return 0; + resp = (u32 *)cmd->response; + if (stat & STATUS_TIME_OUT_RESP) { printf("CMD TIMEOUT\n"); return -ETIMEDOUT; diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index 86e8d5de46..90ac2a3748 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -608,13 +608,17 @@ static void mci_set_clock(struct mci *mci, unsigned clock) { struct mci_host *host = mci->host; - /* check against any given limits */ + /* check against any given limits at the host's side */ if (clock > host->f_max) clock = host->f_max; if (clock < host->f_min) clock = host->f_min; + /* check against the limit at the card's side */ + if (mci->tran_speed != 0 && clock > mci->tran_speed) + clock = mci->tran_speed; + host->clock = clock; /* the new target frequency */ mci_set_ios(mci); } @@ -1376,7 +1380,8 @@ static int mci_card_probe(struct mci *mci) } mci_set_bus_width(mci, MMC_BUS_WIDTH_1); - mci_set_clock(mci, 1); /* set the lowest available clock */ + /* according to the SD card spec the detection can happen at 400 kHz */ + mci_set_clock(mci, 400000); /* reset the card */ rc = mci_go_idle(mci); diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c index 3657b3e496..c15461cf40 100644 --- a/drivers/mci/mxs.c +++ b/drivers/mci/mxs.c @@ -37,6 +37,7 @@ #include <clock.h> #include <io.h> #include <asm/bitops.h> +#include <mach/mxs.h> #include <mach/imx-regs.h> #include <mach/mci.h> #include <mach/clock.h> @@ -185,7 +186,7 @@ static int mxs_mci_read_data(struct mxs_mci_host *mxs_mci, void *buffer, unsigne if (length == 0) return 0; - return -EINVAL; + return -EIO; } @@ -222,7 +223,7 @@ static int mxs_mci_write_data(struct mxs_mci_host *mxs_mci, const void *buffer, if (length == 0) return 0; - return -EINVAL; + return -EIO; } /** @@ -446,19 +447,6 @@ static unsigned mxs_mci_setup_clock_speed(struct mxs_mci_host *mxs_mci, unsigned return ssp / div / rate; } -/** - * Reset the MCI engine (the hard way) - * @param hw_dev Host interface instance - * - * This will reset everything in all registers of this unit! (FIXME) - */ -static void mxs_mci_reset(struct mxs_mci_host *mxs_mci) -{ - writel(SSP_CTRL0_SFTRST, mxs_mci->regs + HW_SSP_CTRL0 + 8); - while (readl(mxs_mci->regs + HW_SSP_CTRL0) & SSP_CTRL0_SFTRST) - ; -} - /* ------------------------- MCI API -------------------------------------- */ /** @@ -475,7 +463,7 @@ static int mxs_mci_initialize(struct mci_host *host, struct device_d *mci_dev) writel(SSP_CTRL0_CLKGATE, mxs_mci->regs + HW_SSP_CTRL0 + 8); /* reset the unit */ - mxs_mci_reset(mxs_mci); + mxs_reset_block(mxs_mci->regs + HW_SSP_CTRL0, 0); /* restore the last settings */ mxs_mci_setup_timeout(mxs_mci, 0xffff); @@ -527,23 +515,23 @@ static void mxs_mci_set_ios(struct mci_host *host, struct mci_ios *ios) switch (ios->bus_width) { case MMC_BUS_WIDTH_8: mxs_mci->bus_width = 2; - host->bus_width = 8; /* 8 bit is possible */ + pr_debug("IO settings: changing bus width to 8 bits\n"); break; case MMC_BUS_WIDTH_4: mxs_mci->bus_width = 1; - host->bus_width = 4; /* 4 bit is possible */ + pr_debug("IO settings: changing bus width to 4 bits\n"); break; case MMC_BUS_WIDTH_1: mxs_mci->bus_width = 0; - host->bus_width = 1; /* 1 bit is possible */ + pr_debug("IO settings: changing bus width to 1 bit\n"); break; default: + pr_debug("IO settings: unsupported bus width!\n"); return; } mxs_mci->clock = mxs_mci_setup_clock_speed(mxs_mci, ios->clock); - pr_debug("IO settings: bus width=%d, frequency=%u Hz\n", host->bus_width, - mxs_mci->clock); + pr_debug("IO settings: frequency=%u Hz\n", mxs_mci->clock); } /* ----------------------------------------------------------------------- */ diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c index 384104ec27..c289e8d48e 100644 --- a/drivers/mtd/mtdraw.c +++ b/drivers/mtd/mtdraw.c @@ -98,6 +98,7 @@ static ssize_t mtdraw_read_unaligned(struct mtd_info *mtd, void *dst, if (!tmp) return -ENOMEM; ops.mode = MTD_OOB_RAW; + ops.ooboffs = 0; ops.datbuf = tmp; ops.len = mtd->writesize; ops.oobbuf = tmp + mtd->writesize; @@ -152,6 +153,7 @@ static ssize_t mtdraw_blkwrite(struct mtd_info *mtd, const void *buf, int ret; ops.mode = MTD_OOB_RAW; + ops.ooboffs = 0; ops.datbuf = (void *)buf; ops.len = mtd->writesize; ops.oobbuf = (void *)buf + mtd->writesize; diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 67e913aef4..e8103cf562 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1179,16 +1179,15 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, return ERR_PTR(-ENODEV); } - /* Lookup the flash id */ - for (i = 0; nand_flash_ids[i].name != NULL; i++) { - if (dev_id == nand_flash_ids[i].id) { - type = &nand_flash_ids[i]; + if (!type) + type = nand_flash_ids; + + for (; type->name != NULL; type++) + if (dev_id == type->id) break; - } - } chip->onfi_version = 0; - if (!type) { + if (!type->name || !type->pagesize) { /* Check is chip is ONFI compliant */ ret = nand_flash_detect_onfi(mtd, chip, &busw); if (ret) diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c index 72593d44a8..4f8fb021a9 100644 --- a/drivers/mtd/nand/nand_ids.c +++ b/drivers/mtd/nand/nand_ids.c @@ -178,7 +178,9 @@ struct nand_manufacturers nand_manuf_ids[] = { {NAND_MFR_STMICRO, __NANDSTR("ST Micro")}, {NAND_MFR_HYNIX, __NANDSTR("Hynix")}, {NAND_MFR_MICRON, __NANDSTR("Micron")}, - {NAND_MFR_AMD, __NANDSTR("AMD")}, + {NAND_MFR_AMD, __NANDSTR("AMD/Spansion")}, + {NAND_MFR_MACRONIX, __NANDSTR("Macronix")}, + {NAND_MFR_EON, __NANDSTR("Eon")}, {0x0, "Unknown"} }; diff --git a/drivers/mtd/nand/nand_imx_bbm.c b/drivers/mtd/nand/nand_imx_bbm.c index 03961a0fb3..135d74e664 100644 --- a/drivers/mtd/nand/nand_imx_bbm.c +++ b/drivers/mtd/nand/nand_imx_bbm.c @@ -91,7 +91,7 @@ static void *create_bbt(struct mtd_info *mtd) buf = malloc(mtd->writesize); if (!buf) { ret = -ENOMEM; - goto out; + goto out2; } numblocks = mtd->size >> (chip->bbt_erase_shift - 1); @@ -99,7 +99,7 @@ static void *create_bbt(struct mtd_info *mtd) for (i = 0; i < numblocks;) { ret = checkbad(mtd, from, buf); if (ret < 0) - goto out; + goto out1; if (ret) { bbt[i >> 3] |= 0x03 << (i & 0x6); @@ -112,8 +112,11 @@ static void *create_bbt(struct mtd_info *mtd) } return bbt; -out: + +out1: free(buf); +out2: + free(bbt); return ERR_PTR(ret); } diff --git a/drivers/of/base.c b/drivers/of/base.c index d22031f32f..8383549821 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -579,6 +579,52 @@ int of_property_read_string(struct device_node *np, const char *propname, } EXPORT_SYMBOL_GPL(of_property_read_string); +/** + * of_property_read_string_index - Find and read a string from a multiple + * strings property. + * @np: device node from which the property value is to be read. + * @propname: name of the property to be searched. + * @index: index of the string in the list of strings + * @out_string: pointer to null terminated return string, modified only if + * return value is 0. + * + * Search for a property in a device tree node and retrieve a null + * terminated string value (pointer to data, not a copy) in the list of strings + * contained in that property. + * Returns 0 on success, -EINVAL if the property does not exist, -ENODATA if + * property does not have a value, and -EILSEQ if the string is not + * null-terminated within the length of the property data. + * + * The out_string pointer is modified only if a valid string can be decoded. + */ +int of_property_read_string_index(struct device_node *np, const char *propname, + int index, const char **output) +{ + struct property *prop = of_find_property(np, propname); + int i = 0; + size_t l = 0, total = 0; + const char *p; + + if (!prop) + return -EINVAL; + if (!prop->value) + return -ENODATA; + if (strnlen(prop->value, prop->length) >= prop->length) + return -EILSEQ; + + p = prop->value; + + for (i = 0; total < prop->length; total += l, p += l) { + l = strlen(p) + 1; + if (i++ == index) { + *output = p; + return 0; + } + } + return -ENODATA; +} +EXPORT_SYMBOL_GPL(of_property_read_string_index); + struct device_node *of_get_root_node(void) { return root_node; @@ -782,7 +828,7 @@ static struct device_d *add_of_platform_device(struct device_node *node) dev->id = DEVICE_ID_SINGLE; dev->resource = node->resource; - dev->num_resources = 1; + dev->num_resources = node->num_resource; dev->device_node = node; node->device = dev; @@ -856,45 +902,65 @@ int of_add_memory(struct device_node *node, bool dump) sprintf(str, "ram%d", r); - barebox_add_memory_bank(str, base, size); + barebox_add_memory_bank(str, base, size); if (dump) pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base); r++; - } + } return 0; } static int add_of_device_resource(struct device_node *node) { - struct property *reg; - u64 address, size; - struct resource *res; + u64 address = 0, size; + struct resource *res, *resp; struct device_d *dev; - phandle phandle; - int ret; - - ret = of_property_read_u32(node, "phandle", &phandle); - if (!ret) { - node->phandle = phandle; - list_add_tail(&node->phandles, &phandle_list); - } + const __be32 *endp, *reg; + const char *resname; + int na, nc, n_resources; + int ret, len, index; ret = of_add_memory(node, false); if (ret != -ENXIO) return ret; - reg = of_find_property(node, "reg"); + reg = of_get_property(node, "reg", &len); if (!reg) - return -ENODEV; - - address = of_translate_address(node, reg->value); - if (address == OF_BAD_ADDR) return -EINVAL; - size = be32_to_cpu(((u32 *)reg->value)[1]); + of_bus_count_cells(node, &na, &nc); + + n_resources = (len / sizeof(__be32)) / (na + nc); + + res = resp = xzalloc(sizeof(*res) * n_resources); + + endp = reg + (len / sizeof(__be32)); + + index = 0; + + while ((endp - reg) >= (na + nc)) { + address = of_translate_address(node, reg); + if (address == OF_BAD_ADDR) { + ret = -EINVAL; + goto err_free; + } + + reg += na; + size = dt_mem_next_cell(nc, ®); + + resp->start = address; + resp->end = address + size - 1; + resname = NULL; + of_property_read_string_index(node, "reg-names", index, &resname); + if (resname) + resp->name = xstrdup(resname); + resp->flags = IORESOURCE_MEM; + resp++; + index++; + } /* * A device may already be registered as platform_device. @@ -909,20 +975,22 @@ static int add_of_device_resource(struct device_node *node) node->device = dev; dev->device_node = node; node->resource = dev->resource; - return 0; + ret = 0; + goto err_free; } } - res = xzalloc(sizeof(*res)); - res->start = address; - res->end = address + size - 1; - res->flags = IORESOURCE_MEM; - node->resource = res; + node->num_resource = n_resources; add_of_device(node); return 0; + +err_free: + free(res); + + return ret; } void of_free(struct device_node *node) @@ -975,6 +1043,22 @@ static void __of_probe(struct device_node *node) __of_probe(n); } +static void __of_parse_phandles(struct device_node *node) +{ + struct device_node *n; + phandle phandle; + int ret; + + ret = of_property_read_u32(node, "phandle", &phandle); + if (!ret) { + node->phandle = phandle; + list_add_tail(&node->phandles, &phandle_list); + } + + list_for_each_entry(n, &node->children, parent_list) + __of_parse_phandles(n); +} + struct device_node *of_chosen; const char *of_model; @@ -991,6 +1075,7 @@ int of_probe(void) of_chosen = of_find_node_by_path(root_node, "/chosen"); of_property_read_string(root_node, "model", &of_model); + __of_parse_phandles(root_node); __of_probe(root_node); return 0; @@ -1078,6 +1163,10 @@ int of_device_is_stdout_path(struct device_d *dev) * * Add initrd properties to the devicetree, or, if end is 0, * delete them. + * + * Note that Linux interprets end differently than barebox. For Linux end points + * to the first address after the memory occupied by the image while barebox + * lets end pointing to the last occupied byte. */ int of_add_initrd(struct device_node *root, resource_size_t start, resource_size_t end) @@ -1092,7 +1181,7 @@ int of_add_initrd(struct device_node *root, resource_size_t start, if (end) { of_write_number(buf, start, 2); of_set_property(chosen, "linux,initrd-start", buf, 8, 1); - of_write_number(buf, end, 2); + of_write_number(buf, end + 1, 2); of_set_property(chosen, "linux,initrd-end", buf, 8, 1); } else { struct property *pp; diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c index d4314f3e28..83b72c03f3 100644 --- a/drivers/of/gpio.c +++ b/drivers/of/gpio.c @@ -25,4 +25,3 @@ int of_get_named_gpio(struct device_node *np, return ret; } - diff --git a/drivers/of/partition.c b/drivers/of/partition.c index 6a57a6036e..2d70cf5353 100644 --- a/drivers/of/partition.c +++ b/drivers/of/partition.c @@ -21,9 +21,9 @@ #include <of.h> #include <malloc.h> #include <linux/mtd/mtd.h> +#include <nand.h> -int of_parse_partitions(const char *cdevname, - struct device_node *node) +int of_parse_partitions(struct cdev *cdev, struct device_node *node) { struct device_node *n; const char *partname; @@ -48,14 +48,17 @@ int of_parse_partitions(const char *cdevname, partname = of_get_property(n, "name", &len); name = (char *)partname; - debug("add partition: %s.%s 0x%08lx 0x%08lx\n", cdevname, partname, offset, size); + debug("add partition: %s.%s 0x%08lx 0x%08lx\n", cdev->name, partname, offset, size); if (of_get_property(n, "read-only", &len)) flags = DEVFS_PARTITION_READONLY; - filename = asprintf("%s.%s", cdevname, partname); + filename = asprintf("%s.%s", cdev->name, partname); - devfs_add_partition(cdevname, offset, size, flags, filename); + devfs_add_partition(cdev->name, offset, size, flags, filename); + + if (cdev->mtd && cdev->mtd->type == MTD_NANDFLASH) + dev_add_bb_dev(filename, NULL); free(filename); } diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig new file mode 100644 index 0000000000..e6aee50a5f --- /dev/null +++ b/drivers/pinctrl/Kconfig @@ -0,0 +1,28 @@ +menu "Pin controllers" + +config PINCTRL + bool "Pin controller core support" + depends on OFDEVICE + help + Pincontrollers allow to setup the iomux unit of SoCs. The pin + controller core is needed when pin muxing shall be configured + from the devicetree. Legacy drivers here may not need this core + support but instead provide their own SoC specific APIs + +config PINCTRL_IMX_IOMUX_V1 + bool "i.MX iomux v1" + help + This iomux controller is found on i.MX1,21,27. + +config PINCTRL_IMX_IOMUX_V2 + bool "i.MX iomux v2" + help + This iomux controller is found on i.MX31. + +config PINCTRL_IMX_IOMUX_V3 + select PINCTRL if OFDEVICE + bool "i.MX iomux v3" + help + This iomux controller is found on i.MX25,35,51,53,6. + +endmenu diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile new file mode 100644 index 0000000000..e9272d0fb0 --- /dev/null +++ b/drivers/pinctrl/Makefile @@ -0,0 +1,4 @@ +obj-$(CONFIG_PINCTRL) += pinctrl.o +obj-$(CONFIG_PINCTRL_IMX_IOMUX_V1) += imx-iomux-v1.o +obj-$(CONFIG_PINCTRL_IMX_IOMUX_V2) += imx-iomux-v2.o +obj-$(CONFIG_PINCTRL_IMX_IOMUX_V3) += imx-iomux-v3.o diff --git a/arch/arm/mach-imx/iomux-v1.c b/drivers/pinctrl/imx-iomux-v1.c index f8f90615c6..f8f90615c6 100644 --- a/arch/arm/mach-imx/iomux-v1.c +++ b/drivers/pinctrl/imx-iomux-v1.c diff --git a/arch/arm/mach-imx/iomux-v2.c b/drivers/pinctrl/imx-iomux-v2.c index cef0340909..cef0340909 100644 --- a/arch/arm/mach-imx/iomux-v2.c +++ b/drivers/pinctrl/imx-iomux-v2.c diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c new file mode 100644 index 0000000000..3ff3c1571d --- /dev/null +++ b/drivers/pinctrl/imx-iomux-v3.c @@ -0,0 +1,212 @@ +/* + * imx-iomux-v3.c - i.MX iomux-v3 pinctrl support + * + * Copyright (c) 2013 Sascha Hauer <s.hauer@pengutronix.de> + * + * 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 version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +#include <common.h> +#include <init.h> +#include <io.h> +#include <pinctrl.h> +#include <malloc.h> +#include <mach/iomux-v3.h> + +struct imx_iomux_v3 { + void __iomem *base; + struct pinctrl_device pinctrl; +}; + +static void __iomem *iomuxv3_base; +static struct device_d *iomuxv3_dev; + +static void imx_iomuxv3_setup_single(void __iomem *base, struct device_d *dev, + u32 mux_reg, u32 conf_reg, u32 input_reg, + u32 mux_val, u32 conf_val, u32 input_val) +{ + dev_dbg(dev, + "mux: 0x%08x -> 0x%04x, conf: 0x%08x -> 0x%04x input: 0x%08x -> 0x%04x\n", + mux_val, mux_reg, conf_val, conf_reg, input_val, input_reg); + + if (mux_reg) + writel(mux_val, base + mux_reg); + if (conf_reg) + writel(conf_val, base + conf_reg); + if (input_reg) + writel(input_val, base + input_reg); +} + +/* + * configures a single pad in the iomuxer + */ +int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad) +{ + u32 mux_reg = (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT; + u32 mux_val = (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT; + u32 input_reg = (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT; + u32 input_val = (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT; + u32 conf_reg = (pad & MUX_PAD_CTRL_OFS_MASK) >> MUX_PAD_CTRL_OFS_SHIFT; + u32 conf_val = (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT; + + if (!iomuxv3_base) + return -EINVAL; + + if (conf_val & NO_PAD_CTRL) + conf_reg = 0; + + imx_iomuxv3_setup_single(iomuxv3_base, iomuxv3_dev, + mux_reg, conf_reg, input_reg, + mux_val, conf_val, input_val); + + return 0; +} +EXPORT_SYMBOL(mxc_iomux_v3_setup_pad); + + +int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count) +{ + iomux_v3_cfg_t *p = pad_list; + int i; + int ret; + + for (i = 0; i < count; i++) { + ret = mxc_iomux_v3_setup_pad(*p); + if (ret) + return ret; + p++; + } + return 0; +} +EXPORT_SYMBOL(mxc_iomux_v3_setup_multiple_pads); + +/* + * Each pin represented in fsl,pins consists of 5 u32 PIN_FUNC_ID and + * 1 u32 CONFIG, so 24 types in total for each pin. + */ +#define FSL_PIN_SIZE 24 + +#define IMX_DT_NO_PAD_CTL (1 << 31) +#define IMX_PAD_SION (1 << 30) + +#define IOMUXC_CONFIG_SION (0x1 << 4) + +static int imx_iomux_v3_set_state(struct pinctrl_device *pdev, struct device_node *np) +{ + struct imx_iomux_v3 *iomux = container_of(pdev, struct imx_iomux_v3, pinctrl); + const __be32 *list; + int npins, size, i; + + dev_dbg(iomux->pinctrl.dev, "set state: %s\n", np->full_name); + + list = of_get_property(np, "fsl,pins", &size); + if (!list) + return -EINVAL; + + + if (!size || size % FSL_PIN_SIZE) { + dev_err(iomux->pinctrl.dev, "Invalid fsl,pins property\n"); + return -EINVAL; + } + + npins = size / FSL_PIN_SIZE; + + for (i = 0; i < npins; i++) { + u32 mux_reg = be32_to_cpu(*list++); + u32 conf_reg = be32_to_cpu(*list++); + u32 input_reg = be32_to_cpu(*list++); + u32 mux_val = be32_to_cpu(*list++); + u32 input_val = be32_to_cpu(*list++); + u32 conf_val = be32_to_cpu(*list++); + + if (conf_val & IMX_PAD_SION) + mux_val |= IOMUXC_CONFIG_SION; + + if (conf_val & IMX_DT_NO_PAD_CTL) + conf_reg = 0; + + imx_iomuxv3_setup_single(iomux->base, iomux->pinctrl.dev, + mux_reg, conf_reg, input_reg, + mux_val, conf_val, input_val); + } + + return 0; +} + +static struct pinctrl_ops imx_iomux_v3_ops = { + .set_state = imx_iomux_v3_set_state, +}; + +static int imx_pinctrl_dt(struct device_d *dev, void __iomem *base) +{ + struct imx_iomux_v3 *iomux; + int ret; + + iomux = xzalloc(sizeof(*iomux)); + + iomux->base = base; + + iomux->pinctrl.dev = dev; + iomux->pinctrl.ops = &imx_iomux_v3_ops; + + ret = pinctrl_register(&iomux->pinctrl); + if (ret) + free(iomux); + + return ret; +} + +static int imx_iomux_v3_probe(struct device_d *dev) +{ + int ret = 0; + + if (iomuxv3_base) + return -EBUSY; + + iomuxv3_base = dev_request_mem_region(dev, 0); + iomuxv3_dev = dev; + + if (IS_ENABLED(CONFIG_PINCTRL)) + ret = imx_pinctrl_dt(dev, iomuxv3_base); + + return ret; +} + +static __maybe_unused struct of_device_id imx_iomux_v3_dt_ids[] = { + { + .compatible = "fsl,imx25-iomuxc", + }, { + .compatible = "fsl,imx35-iomuxc", + }, { + .compatible = "fsl,imx51-iomuxc", + }, { + .compatible = "fsl,imx53-iomuxc", + }, { + .compatible = "fsl,imx6q-iomuxc", + }, { + /* sentinel */ + } +}; + +static struct driver_d imx_iomux_v3_driver = { + .name = "imx-iomuxv3", + .probe = imx_iomux_v3_probe, + .of_compatible = DRV_OF_COMPAT(imx_iomux_v3_dt_ids), +}; + +static int imx_iomux_v3_init(void) +{ + return platform_driver_register(&imx_iomux_v3_driver); +} +postcore_initcall(imx_iomux_v3_init); diff --git a/drivers/pinctrl/pinctrl.c b/drivers/pinctrl/pinctrl.c new file mode 100644 index 0000000000..fa979a1b78 --- /dev/null +++ b/drivers/pinctrl/pinctrl.c @@ -0,0 +1,149 @@ +/* + * pinctrl.c - barebox pinctrl support + * + * Copyright (c) 2013 Sascha Hauer <s.hauer@pengutronix.de> + * + * 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 version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ +#include <common.h> +#include <malloc.h> +#include <pinctrl.h> + +static LIST_HEAD(pinctrl_list); + +static struct pinctrl_device *find_pinctrl(struct device_node *node) +{ + struct pinctrl_device *pdev; + + list_for_each_entry(pdev, &pinctrl_list, list) + if (pdev->node == node) + return pdev; + return NULL; +} + +static int pinctrl_config_one(struct device_node *np) +{ + struct pinctrl_device *pdev; + struct device_node *pinctrl_node = np; + + while (1) { + pinctrl_node = pinctrl_node->parent; + if (!pinctrl_node) + return -ENODEV; + pdev = find_pinctrl(pinctrl_node); + if (pdev) + break; + } + + return pdev->ops->set_state(pdev, np); +} + +int pinctrl_select_state(struct device_d *dev, const char *name) +{ + int state, ret; + char *propname; + struct property *prop; + const __be32 *list; + int size, config; + phandle phandle; + struct device_node *np_config, *np; + const char *statename; + + np = dev->device_node; + if (!np) + return 0; + + if (!of_find_property(np, "pinctrl-0")) + return 0; + + /* For each defined state ID */ + for (state = 0; ; state++) { + /* Retrieve the pinctrl-* property */ + propname = asprintf("pinctrl-%d", state); + prop = of_find_property(np, propname); + free(propname); + + if (!prop) { + ret = -ENODEV; + break; + } + + size = prop->length; + + list = prop->value; + size /= sizeof(*list); + + /* Determine whether pinctrl-names property names the state */ + ret = of_property_read_string_index(np, "pinctrl-names", + state, &statename); + /* + * If not, statename is just the integer state ID. But rather + * than dynamically allocate it and have to free it later, + * just point part way into the property name for the string. + */ + if (ret < 0) { + /* strlen("pinctrl-") == 8 */ + statename = prop->name + 8; + } + + if (strcmp(name, statename)) + continue; + + /* For every referenced pin configuration node in it */ + for (config = 0; config < size; config++) { + phandle = be32_to_cpup(list++); + + /* Look up the pin configuration node */ + np_config = of_find_node_by_phandle(phandle); + if (!np_config) { + pr_err("prop %s %s index %i invalid phandle\n", + np->full_name, prop->name, config); + ret = -EINVAL; + goto err; + } + + /* Parse the node */ + ret = pinctrl_config_one(np_config); + if (ret < 0) + goto err; + } + + return 0; + } +err: + return ret; +} + +int pinctrl_select_state_default(struct device_d *dev) +{ + return pinctrl_select_state(dev, "default"); +} + +int pinctrl_register(struct pinctrl_device *pdev) +{ + BUG_ON(!pdev->dev->device_node); + + list_add_tail(&pdev->list, &pinctrl_list); + + pdev->node = pdev->dev->device_node; + + pinctrl_select_state_default(pdev->dev); + + return 0; +} + +void pinctrl_unregister(struct pinctrl_device *pdev) +{ + list_del(&pdev->list); +} diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c index 96cfe9a4f4..6ae4cf832f 100644 --- a/drivers/watchdog/im28wd.c +++ b/drivers/watchdog/im28wd.c @@ -33,16 +33,89 @@ #define MXS_RTC_WATCHDOG 0x50 +/* HW_RTC_PERSISTENT0 - holds bits used to configure various hardware settings */ #define MXS_RTC_PERSISTENT0 0x60 + +/* FIXME */ +# define MXS_RTC_PERSISTENT0_SPARE_ANALOG (1 << 22) /* dubious meaning from inside the SoC's firmware ROM */ # define MXS_RTC_PERSISTENT0_EXT_RST (1 << 21) /* dubious meaning from inside the SoC's firmware ROM */ # define MXS_RTC_PERSISTENT0_THM_RST (1 << 20) - +/* reserved on i.MX28 */ +# define MXS_RTC_PERSISTENT0_RELEASE_GND (1 << 19) +# define MXS_RTC_PERSISTENT0_ENABLE_LRADC_PWRUP (1 << 18) +# define MXS_RTC_PERSISTENT0_AUTO_RESTART (1 << 17) +# define MXS_RTC_PERSISTENT0_DISABLE_PSWITCH (1 << 16) +# define MXS_RTC_PERSISTENT0_LOWERBIAS (1 << 14) +# define MXS_RTC_PERSISTENT0_DISABLE_XTALOK (1 << 13) +# define MXS_RTC_PERSISTENT0_MSEC_RES (1 << 8) +# define MXS_RTC_PERSISTENT0_ALARM_WAKE (1 << 7) +# define MXS_RTC_PERSISTENT0_XTAL32_FREQ (1 << 6) +# define MXS_RTC_PERSISTENT0_XTAL32KHZ_PWRUP (1 << 5) +# define MXS_RTC_PERSISTENT0_XTAL24MHZ_PWRUP (1 << 4) +# define MXS_RTC_PERSISTENT0_LCK_SECS (1 << 3) +# define MXS_RTC_PERSISTENT0_ALARM_EN (1 << 2) +# define MXS_RTC_PERSISTENT0_ALARM_WAKE_EN (1 << 1) +# define MXS_RTC_PERSISTENT0_CLOCKSOURCE (1 << 0) + +/* HW_RTC_PERSISTENT1 - holds bits related to the ROM and redundant boot handling */ #define MXS_RTC_PERSISTENT1 0x70 + + +/* + * some of the following bits are for error reporting from ROM to the chained + * firmware. It seems, if the error reporting bits are not cleared when the + * chained firmware is running, the next time the following rule is active: + * "Loader enters recovery mode if any non-USB boot mode has an error. + * Which results into a system that seems not to start anymore. + */ + /* dubious meaning from inside the SoC's firmware ROM */ # define MXS_RTC_PERSISTENT1_FORCE_UPDATER (1 << 31) +/* names are from the i.MX28 datasheet. Undocumented behaviour */ +# define MXS_RTC_PERSISTENT1_ENUMERATE_500MA_TWICE (1 << 12) +# define MXS_RTC_PERSISTENT1_USB_BOOT_PLAYER_MODE (1 << 11) +# define MXS_RTC_PERSISTENT1_SKIP_CHECKDISK (1 << 10) +# define MXS_RTC_PERSISTENT1_USB_LOW_POWER_MODE (1 << 9) +# define MXS_RTC_PERSISTENT1_OTG_HNP_BIT (1 << 8) +# define MXS_RTC_PERSISTENT1_OTG_ATL_ROLE_BIT (1 << 7) +/* + * a few undocumented bits + */ +# define MXS_RTC_PERSISTENT1_SD_INIT_SEQ_2_ENABLE (1 << 6) +# define MXS_RTC_PERSISTENT1_SD_CMD0_DISABLE (1 << 5) +# define MXS_RTC_PERSISTENT1_SD_INIT_SEQ_1_DISABLE (1 << 4) +/* + * If this bit is set, ROM puts the SD/MMC card in high-speed mode. + * If this bit is set, the ROM driver will use a maximum speed based on the + * results of device identification and limited by choices available in the + * SSP clock index. + */ +# define MXS_RTC_PERSISTENT1_SD_SPEED_ENABLE (1 << 3) +/* + * The NAND driver sets this bit to indicate to the SDK that the boot image + * has ECC errors that reached the warning threshold. The SDK regenerates the + * firmware by copying it from the backup image. The SDK clears this bit. + * This bit had change its meaning from i.XM23 to i.MX28. Refer section + * 35.8 "NAND Boot Mode" for further details in the i.MX23 RM. + */ +# define MXS_RTC_PERSISTENT1_NAND_SDK_BLOCK_REWRITE (1 << 2) +/* + * When this bit is set, ROM attempts to boot from the secondary image if the + * boot driver supports it. This bit is set by the ROM boot driver and cleared + * by the SDK after repair. + * If not reset, the ROM seems to continue to start from the secondary image + * which will fail forever if there is no secondary image + */ +# define MXS_RTC_PERSISTENT1_NAND_SECONDARY_BOOT (1 << 1) +/* + * When this bit is set, the ROM code forces the system to boot in recovery + * mode, regardless of the selected mode. The ROM clears the bit. + */ +# define MXS_RTC_PERSISTENT1_FORCE_RECOVERY (1 << 0) + #define MXS_RTC_DEBUG 0xc0 #define WDOG_TICK_RATE 1000 /* the watchdog uses a 1 kHz clock rate */ diff --git a/include/common.h b/include/common.h index e559b94a71..59fcd35ac1 100644 --- a/include/common.h +++ b/include/common.h @@ -219,7 +219,12 @@ int run_shell(void); #define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) #define PAGE_ALIGN_DOWN(x) ((x) & ~(PAGE_SIZE - 1)) -int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab); +int memory_display(char *addr, loff_t offs, unsigned nbytes, int size, int swab); + +int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, + char **sourcefile, char **destfile, int *swab); +int open_and_lseek(const char *filename, int mode, loff_t pos); +#define RW_BUF_SIZE (unsigned)4096 extern const char version_string[]; #ifdef CONFIG_BANNER diff --git a/include/filetype.h b/include/filetype.h index 78ca5d2043..ee777acf99 100644 --- a/include/filetype.h +++ b/include/filetype.h @@ -31,6 +31,7 @@ enum filetype { const char *file_type_to_string(enum filetype f); const char *file_type_to_short_string(enum filetype f); +enum filetype file_detect_partition_table(const void *_buf, size_t bufsize); enum filetype file_detect_type(const void *_buf, size_t bufsize); enum filetype file_name_detect_type(const char *filename); enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec); diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index dc141a5186..25bae631e5 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -500,15 +500,17 @@ struct nand_chip { /* * NAND Flash Manufacturer ID Codes */ -#define NAND_MFR_TOSHIBA 0x98 -#define NAND_MFR_SAMSUNG 0xec -#define NAND_MFR_FUJITSU 0x04 -#define NAND_MFR_NATIONAL 0x8f -#define NAND_MFR_RENESAS 0x07 -#define NAND_MFR_STMICRO 0x20 -#define NAND_MFR_HYNIX 0xad -#define NAND_MFR_MICRON 0x2c -#define NAND_MFR_AMD 0x01 +#define NAND_MFR_TOSHIBA 0x98 +#define NAND_MFR_SAMSUNG 0xec +#define NAND_MFR_FUJITSU 0x04 +#define NAND_MFR_NATIONAL 0x8f +#define NAND_MFR_RENESAS 0x07 +#define NAND_MFR_STMICRO 0x20 +#define NAND_MFR_HYNIX 0xad +#define NAND_MFR_MICRON 0x2c +#define NAND_MFR_AMD 0x01 +#define NAND_MFR_MACRONIX 0xc2 +#define NAND_MFR_EON 0x92 /** * struct nand_flash_dev - NAND Flash Device ID Structure diff --git a/include/of.h b/include/of.h index 94ccfd8739..4dcf37e140 100644 --- a/include/of.h +++ b/include/of.h @@ -26,6 +26,7 @@ struct device_node { struct list_head parent_list; struct list_head list; struct resource *resource; + int num_resource; struct device_d *device; struct list_head phandles; phandle phandle; @@ -160,6 +161,8 @@ void of_delete_property(struct property *pp); int of_property_read_string(struct device_node *np, const char *propname, const char **out_string); +int of_property_read_string_index(struct device_node *np, const char *propname, + int index, const char **output); int of_set_property(struct device_node *node, const char *p, const void *val, int len, int create); struct device_node *of_create_node(struct device_node *root, const char *path); @@ -167,9 +170,10 @@ struct device_node *of_create_node(struct device_node *root, const char *path); struct device_node *of_get_root_node(void); int of_set_root_node(struct device_node *); +struct cdev; + #ifdef CONFIG_OFTREE -int of_parse_partitions(const char *cdevname, - struct device_node *node); +int of_parse_partitions(struct cdev *cdev, struct device_node *node); int of_alias_get_id(struct device_node *np, const char *stem); int of_device_is_stdout_path(struct device_d *dev); @@ -177,7 +181,7 @@ const char *of_get_model(void); void *of_flatten_dtb(struct device_node *node); int of_add_memory(struct device_node *node, bool dump); #else -static inline int of_parse_partitions(const char *cdevname, +static inline int of_parse_partitions(struct cdev *cdev, struct device_node *node) { return -EINVAL; diff --git a/include/pinctrl.h b/include/pinctrl.h new file mode 100644 index 0000000000..7323f8b2f2 --- /dev/null +++ b/include/pinctrl.h @@ -0,0 +1,35 @@ +#ifndef PINCTRL_H +#define PINCTRL_H + +struct pinctrl_device; + +struct pinctrl_ops { + int (*set_state)(struct pinctrl_device *, struct device_node *); +}; + +struct pinctrl_device { + struct device_d *dev; + struct pinctrl_ops *ops; + struct list_head list; + struct device_node *node; +}; + +int pinctrl_register(struct pinctrl_device *pdev); +void pinctrl_unregister(struct pinctrl_device *pdev); + +#ifdef CONFIG_PINCTRL +int pinctrl_select_state(struct device_d *dev, const char *state); +int pinctrl_select_state_default(struct device_d *dev); +#else +static inline int pinctrl_select_state(struct device_d *dev, const char *state) +{ + return -ENODEV; +} + +static inline int pinctrl_select_state_default(struct device_d *dev) +{ + return -ENODEV; +} +#endif + +#endif /* PINCTRL_H */ diff --git a/include/usb/usb.h b/include/usb/usb.h index afccf706d7..b2700127f3 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -196,7 +196,6 @@ struct usb_driver { extern struct bus_type usb_bus_type; int usb_driver_register(struct usb_driver *); -int usb_driver_unregister(struct usb_driver *); struct usb_host { int (*init)(struct usb_host *); diff --git a/lib/copy_file.c b/lib/copy_file.c index 484b2ca725..ab3d845a5b 100644 --- a/lib/copy_file.c +++ b/lib/copy_file.c @@ -6,8 +6,6 @@ #include <libbb.h> #include <progress.h> -#define RW_BUF_SIZE (ulong)4096 - /** * @param[in] src FIXME * @param[out] dst FIXME diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0d94f982fa..e80926fa0b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -209,7 +209,7 @@ our $typeTypedefs = qr{(?x: )}; our $logFunctions = qr{(?x: - printk| + printk|printf| pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)| (dev|netdev|netif)_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)| WARN| diff --git a/scripts/dtc/modules.order b/scripts/dtc/modules.order deleted file mode 100644 index e69de29bb2..0000000000 --- a/scripts/dtc/modules.order +++ /dev/null |