diff options
360 files changed, 5906 insertions, 1986 deletions
@@ -1,5 +1,5 @@ VERSION = 2013 -PATCHLEVEL = 02 +PATCHLEVEL = 03 SUBLEVEL = 0 EXTRAVERSION = NAME = Amissive Actinocutious Kiwi diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5ae5bd0217..7ac134e159 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -7,9 +7,6 @@ config ARM select HAVE_IMAGE_COMPRESSION default y -config ARM_AMBA - bool - config ARM_LINUX bool default y @@ -49,6 +46,18 @@ config ARCH_EP93XX select CPU_ARM920T select GENERIC_GPIO +config ARCH_HIGHBANK + bool "Calxeda Highbank" + select HAS_DEBUG_LL + select HAS_POWEROFF + select ARCH_HAS_L2X0 + select CPU_V7 + select ARM_AMBA + select AMBA_SP804 + select CLKDEV_LOOKUP + select COMMON_CLK + select GPIOLIB + config ARCH_IMX bool "Freescale iMX-based" select GENERIC_GPIO @@ -126,6 +135,7 @@ source arch/arm/mach-at91/Kconfig source arch/arm/mach-bcm2835/Kconfig source arch/arm/mach-clps711x/Kconfig source arch/arm/mach-ep93xx/Kconfig +source arch/arm/mach-highbank/Kconfig source arch/arm/mach-imx/Kconfig source arch/arm/mach-mxs/Kconfig source arch/arm/mach-netx/Kconfig diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 73631ba23e..b98d6b86a7 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -55,6 +55,7 @@ machine-$(CONFIG_ARCH_AT91) := at91 machine-$(CONFIG_ARCH_BCM2835) := bcm2835 machine-$(CONFIG_ARCH_CLPS711X) := clps711x machine-$(CONFIG_ARCH_EP93XX) := ep93xx +machine-$(CONFIG_ARCH_HIGHBANK) := highbank machine-$(CONFIG_ARCH_IMX) := imx machine-$(CONFIG_ARCH_MXS) := mxs machine-$(CONFIG_ARCH_NOMADIK) := nomadik @@ -99,6 +100,7 @@ board-$(CONFIG_MACH_EUKREA_CPUIMX51SD) := eukrea_cpuimx51 board-$(CONFIG_MACH_FREESCALE_MX25_3STACK) := freescale-mx25-3-stack board-$(CONFIG_MACH_FREESCALE_MX35_3STACK) := freescale-mx35-3-stack board-$(CONFIG_MACH_GE863) := telit-evk-pro3 +board-$(CONFIG_MACH_HIGHBANK) := highbank board-$(CONFIG_MACH_IMX21ADS) := imx21ads board-$(CONFIG_MACH_IMX27ADS) := imx27ads board-$(CONFIG_MACH_IMX233_OLINUXINO) := imx233-olinuxino @@ -159,6 +161,7 @@ board-$(CONFIG_MACH_SABRELITE) := freescale-mx6-sabrelite board-$(CONFIG_MACH_TX53) := karo-tx53 board-$(CONFIG_MACH_GUF_VINCELL) := guf-vincell board-$(CONFIG_MACH_EFIKA_MX_SMARTBOOK) := efika-mx-smartbook +board-$(CONFIG_MACH_SABRESD) := freescale-mx6-sabresd machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y)) diff --git a/arch/arm/boards/a9m2410/Makefile b/arch/arm/boards/a9m2410/Makefile index 6842c844b2..4bf737c1fc 100644 --- a/arch/arm/boards/a9m2410/Makefile +++ b/arch/arm/boards/a9m2410/Makefile @@ -1,4 +1,3 @@ -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o +lwl-y += lowlevel_init.o obj-y += a9m2410.o diff --git a/arch/arm/boards/a9m2440/Makefile b/arch/arm/boards/a9m2440/Makefile index 8a8f36df02..f21d389c14 100644 --- a/arch/arm/boards/a9m2440/Makefile +++ b/arch/arm/boards/a9m2440/Makefile @@ -1,5 +1,4 @@ -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o +lwl-y += lowlevel_init.o obj-y += a9m2440.o obj-$(CONFIG_MACH_A9M2410DEV) += a9m2410dev.o diff --git a/arch/arm/boards/archosg9/Makefile b/arch/arm/boards/archosg9/Makefile index 4cc5a2ef13..a78956f4e4 100644 --- a/arch/arm/boards/archosg9/Makefile +++ b/arch/arm/boards/archosg9/Makefile @@ -1,4 +1,3 @@ obj-y += board.o obj-$(CONFIG_ARM_BOARD_APPEND_ATAG) += archos_features.o -obj-y += lowlevel.o mux.o -pbl-y += lowlevel.o mux.o +lwl-y += lowlevel.o mux.o diff --git a/arch/arm/boards/archosg9/lowlevel.c b/arch/arm/boards/archosg9/lowlevel.c index 552268f408..0334693966 100644 --- a/arch/arm/boards/archosg9/lowlevel.c +++ b/arch/arm/boards/archosg9/lowlevel.c @@ -63,15 +63,18 @@ static noinline void archosg9_init_lowlevel(void) omap4_configure_usb_dpll(&usb); omap4_ddr_init(&ddr_regs_400_mhz_2cs, &core); - - barebox_arm_entry(0x80000000, SZ_1G, 0); } void __naked __bare_init barebox_arm_reset_vector(void) { arm_cpu_lowlevel_init(); + if (get_pc() > 0x80000000) + goto out; + arm_setup_stack(0x4030d000); archosg9_init_lowlevel(); +out: + barebox_arm_entry(0x80000000, SZ_1G, 0); } diff --git a/arch/arm/boards/at91sam9260ek/env/bin/init_board b/arch/arm/boards/at91sam9260ek/env/bin/init_board index 977430debd..27d767d33c 100644 --- a/arch/arm/boards/at91sam9260ek/env/bin/init_board +++ b/arch/arm/boards/at91sam9260ek/env/bin/init_board @@ -8,43 +8,33 @@ vendor_id=0x4321 dfu_config="/dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.rootfs.bb(rootfs)r" -if [ $at91_udc0.vbus != 1 ] -then +if [ $at91_udc0.vbus != 1 ]; then echo "No USB Device cable plugged, normal boot" exit fi gpio_get_value ${dfu_button} -if [ $? != 0 ] -then - autoboot_timeout=16 - echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s" - usbserial - exit -fi - -echo "${button_name} pressed detected wait ${button_wait}s" -timeout -s -a ${button_wait} - -if [ $at91_udc0.vbus != 1 ] -then - echo "No USB Device cable plugged, normal boot" - exit -fi - -gpio_get_value ${dfu_button} -if [ $? != 0 ] -then +if [ $? = 0 ]; then + echo "${button_name} pressed detected wait ${button_wait}s" + timeout -s -a ${button_wait} + + if [ $at91_udc0.vbus != 1 ]; then + echo "No USB Device cable plugged, normal boot" + exit + fi + + gpio_get_value ${dfu_button} + if [ $? = 0 ]; then + echo "" + echo "Start DFU Mode" + echo "" + led ds5 1 + dfu ${dfu_config} -P ${product_id} -V ${vendor_id} + exit + fi echo "${button_name} released, normal boot" - autoboot_timeout=16 - echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s" - usbserial - exit fi -echo "" -echo "Start DFU Mode" -echo "" - -led ds5 1 -dfu ${dfu_config} -P ${product_id} -V ${vendor_id} +autoboot_timeout=16 +echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s" +usbserial diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c index 2d52f5a3f8..dc2976a0c4 100644 --- a/arch/arm/boards/at91sam9260ek/init.c +++ b/arch/arm/boards/at91sam9260ek/init.c @@ -10,31 +10,21 @@ * 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 <net.h> #include <init.h> #include <environment.h> -#include <fec.h> #include <asm/armlinux.h> #include <generated/mach-types.h> -#include <partition.h> -#include <fs.h> -#include <fcntl.h> -#include <io.h> -#include <asm/hardware.h> #include <nand.h> #include <sizes.h> -#include <linux/mtd/nand.h> #include <mach/board.h> #include <mach/at91sam9_smc.h> #include <gpio.h> #include <mach/io.h> -#include <mach/at91_pmc.h> #include <mach/at91_rstc.h> +#include <linux/clk.h> /* * board revision encoding @@ -47,9 +37,8 @@ static void ek_set_board_type(void) { if (machine_is_at91sam9g20ek()) { armlinux_set_architecture(MACH_TYPE_AT91SAM9G20EK); -#ifdef CONFIG_AT91_HAVE_2MMC - armlinux_set_revision(HAVE_2MMC); -#endif + if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC)) + armlinux_set_revision(HAVE_2MMC); } else { armlinux_set_architecture(MACH_TYPE_AT91SAM9260EK); } @@ -61,11 +50,6 @@ static struct atmel_nand_data nand_pdata = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PC13, .enable_pin = AT91_PIN_PC14, -#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16) - .bus_width_16 = 1, -#else - .bus_width_16 = 0, -#endif .on_flash_bbt = 1, }; @@ -83,7 +67,8 @@ static struct sam9_smc_config ek_9260_nand_smc_config = { .read_cycle = 5, .write_cycle = 5, - .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE, + .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | + AT91_SMC_EXNWMODE_DISABLE, .tdf_cycles = 2, }; @@ -101,7 +86,8 @@ static struct sam9_smc_config ek_9g20_nand_smc_config = { .read_cycle = 7, .write_cycle = 7, - .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE, + .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | + AT91_SMC_EXNWMODE_DISABLE, .tdf_cycles = 3, }; @@ -115,10 +101,12 @@ static void ek_add_device_nand(void) smc = &ek_9260_nand_smc_config; /* setup bus-width (8 or 16) */ - if (nand_pdata.bus_width_16) + if (IS_ENABLED(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)) { + nand_pdata.bus_width_16 = 1; smc->mode |= AT91_SMC_DBW_16; - else + } else { smc->mode |= AT91_SMC_DBW_8; + } /* configure chip-select 3 (NAND) */ sam9_smc_configure(0, 3, smc); @@ -134,7 +122,9 @@ static struct at91_ether_platform_data macb_pdata = { static void at91sam9260ek_phy_reset(void) { unsigned long rstc; - at91_pmc_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_EMAC); + struct clk *clk = clk_get(NULL, "macb_clk"); + + clk_enable(clk); at91_set_gpio_input(AT91_PIN_PA14, 0); at91_set_gpio_input(AT91_PIN_PA15, 0); @@ -153,33 +143,33 @@ static void at91sam9260ek_phy_reset(void) at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST); /* Wait for end hardware reset */ - while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL)); + while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL)) + ; /* Restore NRST value */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (rstc) | - AT91_RSTC_URSTEN); + at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | (rstc) | AT91_RSTC_URSTEN); } /* * MCI (SD/MMC) */ -#if defined(CONFIG_MCI_ATMEL) static struct atmel_mci_platform_data __initdata ek_mci_data = { .bus_width = 4, .slot_b = 1, + .detect_pin = -EINVAL, + .wp_pin = -EINVAL, }; static void ek_usb_add_device_mci(void) { + if (!IS_ENABLED(CONFIG_MCI_ATMEL)) + return; + if (machine_is_at91sam9g20ek()) ek_mci_data.detect_pin = AT91_PIN_PC9; at91_add_device_mci(0, &ek_mci_data); } -#else -static void ek_usb_add_device_mci(void) {} -#endif /* * USB Host port @@ -216,10 +206,10 @@ static void __init ek_add_led(void) { int i; -#ifdef CONFIG_AT91_HAVE_2MMC - leds[0].gpio = AT91_PIN_PB8; - leds[1].gpio = AT91_PIN_PB9; -#endif + if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC)) { + leds[0].gpio = AT91_PIN_PB8; + leds[1].gpio = AT91_PIN_PB9; + } for (i = 0; i < ARRAY_SIZE(leds); i++) { at91_set_gpio_output(leds[i].gpio, leds[i].active_low); @@ -271,7 +261,6 @@ static int at91sam9260ek_devices_init(void) return 0; } - device_initcall(at91sam9260ek_devices_init); static int at91sam9260ek_console_init(void) @@ -279,5 +268,4 @@ static int at91sam9260ek_console_init(void) at91_register_uart(0, 0); return 0; } - console_initcall(at91sam9260ek_console_init); diff --git a/arch/arm/boards/at91sam9261ek/Makefile b/arch/arm/boards/at91sam9261ek/Makefile index 1702783170..1398c26a0f 100644 --- a/arch/arm/boards/at91sam9261ek/Makefile +++ b/arch/arm/boards/at91sam9261ek/Makefile @@ -1,5 +1,3 @@ obj-y += init.o -obj-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o - -pbl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o +lwl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o diff --git a/arch/arm/boards/at91sam9263ek/Makefile b/arch/arm/boards/at91sam9263ek/Makefile index 1702783170..1398c26a0f 100644 --- a/arch/arm/boards/at91sam9263ek/Makefile +++ b/arch/arm/boards/at91sam9263ek/Makefile @@ -1,5 +1,3 @@ obj-y += init.o -obj-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o - -pbl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o +lwl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o diff --git a/arch/arm/boards/at91sam9m10g45ek/init.c b/arch/arm/boards/at91sam9m10g45ek/init.c index 5b5e31b554..0ae7171359 100644 --- a/arch/arm/boards/at91sam9m10g45ek/init.c +++ b/arch/arm/boards/at91sam9m10g45ek/init.c @@ -114,6 +114,7 @@ static struct at91_ether_platform_data macb_pdata = { static struct atmel_mci_platform_data ek_mci_data = { .bus_width = 4, .detect_pin = AT91_PIN_PD10, + .wp_pin = -EINVAL, }; static void ek_add_device_mci(void) diff --git a/arch/arm/boards/at91sam9m10ihd/init.c b/arch/arm/boards/at91sam9m10ihd/init.c index f258caf2b4..df63a91760 100644 --- a/arch/arm/boards/at91sam9m10ihd/init.c +++ b/arch/arm/boards/at91sam9m10ihd/init.c @@ -96,6 +96,7 @@ static void ek_add_device_eth(void) static struct atmel_mci_platform_data ek_mci0_data = { .bus_width = 4, .detect_pin = AT91_PIN_PC25, + .wp_pin = -EINVAL, }; static void ek_add_device_mci(void) diff --git a/arch/arm/boards/beagle/Makefile b/arch/arm/boards/beagle/Makefile index 88c223aa6f..01c7a259e9 100644 --- a/arch/arm/boards/beagle/Makefile +++ b/arch/arm/boards/beagle/Makefile @@ -1,3 +1,2 @@ obj-y += board.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/beagle/env/init/config-board b/arch/arm/boards/beagle/env/config-board index cc0820a089..cc0820a089 100644 --- a/arch/arm/boards/beagle/env/init/config-board +++ b/arch/arm/boards/beagle/env/config-board diff --git a/arch/arm/boards/beaglebone/Makefile b/arch/arm/boards/beaglebone/Makefile index 3b7261c7c1..092c31d6b2 100644 --- a/arch/arm/boards/beaglebone/Makefile +++ b/arch/arm/boards/beaglebone/Makefile @@ -1,5 +1,2 @@ -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o obj-y += board.o -obj-y += lowlevel.o -pbl-y += lowlevel.o diff --git a/arch/arm/boards/ccxmx51/Makefile b/arch/arm/boards/ccxmx51/Makefile index d392533295..422c91916a 100644 --- a/arch/arm/boards/ccxmx51/Makefile +++ b/arch/arm/boards/ccxmx51/Makefile @@ -1,5 +1,4 @@ -obj-y += flash_header.o ccxmx51.o -pbl-y += flash_header.o +obj-y += ccxmx51.o +lwl-y += flash_header.o +lwl-y += lowlevel.o obj-$(CONFIG_MACH_CCMX51_BASEBOARD) += ccxmx51js.o -obj-y += lowlevel.o -pbl-y += lowlevel.o diff --git a/arch/arm/boards/ccxmx51/ccxmx51.c b/arch/arm/boards/ccxmx51/ccxmx51.c index a9bf16a3d6..b1c579b14a 100644 --- a/arch/arm/boards/ccxmx51/ccxmx51.c +++ b/arch/arm/boards/ccxmx51/ccxmx51.c @@ -80,12 +80,10 @@ struct imx_nand_platform_data nand_info = { .flash_bbt = 1, }; -#ifdef CONFIG_DRIVER_NET_FEC_IMX static struct fec_platform_data fec_info = { .xcv_type = MII100, .phy_addr = 7, }; -#endif static iomux_v3_cfg_t ccxmx51_pads[] = { /* UART1 */ @@ -366,8 +364,10 @@ static int ccxmx51_power_init(void) /* GP02 - LAN9221 Power */ /* GP03 - FEC Reset */ /* GP04 - Wireless Power */ - if (IS_ENABLED(CONFIG_DRIVER_NET_SMC911X) && ccxmx51_id->eth1) + if (IS_ENABLED(CONFIG_DRIVER_NET_SMC911X) && ccxmx51_id->eth1) { val |= (1 << 8); + mdelay(50); + } if (IS_ENABLED(CONFIG_DRIVER_NET_FEC_IMX) && ccxmx51_id->eth0) val |= (1 << 10); if (ccxmx51_id->wless) @@ -392,7 +392,7 @@ static int ccxmx51_devices_init(void) printf("Module Variant: %s (0x%02x)\n", ccxmx51_id->id_string, hwid[0]); if (hwid[0]) { - printf("Module HW Rev : %02x\n", hwid[1]); + printf("Module HW Rev : %02x\n", hwid[1] + 1); switch (hwid[2] & 0xc0) { case 0x00: manloc = 'B'; @@ -431,15 +431,12 @@ static int ccxmx51_devices_init(void) devfs_add_partition("nand0", 0x80000, 0x40000, DEVFS_PARTITION_FIXED, "env_raw"); dev_add_bb_dev("env_raw", "env0"); -#ifdef CONFIG_DRIVER_NET_FEC_IMX - if (ccxmx51_id->eth0 && !pwr) { + if (IS_ENABLED(CONFIG_DRIVER_NET_FEC_IMX) && ccxmx51_id->eth0 && !pwr) { eth_register_ethaddr(0, hwid); imx51_add_fec(&fec_info); } -#endif -#ifdef CONFIG_DRIVER_NET_SMC911X - if (ccxmx51_id->eth1 && !pwr) { + if (IS_ENABLED(CONFIG_DRIVER_NET_SMC911X) && ccxmx51_id->eth1 && !pwr) { /* Configure the WEIM CS5 timming, bus width, etc */ /* 16 bit on DATA[31..16], not multiplexed, async */ writel(0x00420081, MX51_WEIM_BASE_ADDR + WEIM_CSxGCR1(5)); @@ -455,7 +452,6 @@ static int ccxmx51_devices_init(void) /* LAN9221 network controller */ add_generic_device("smc911x", 1, NULL, MX51_CS5_BASE_ADDR, SZ_4K, IORESOURCE_MEM, NULL); } -#endif ccxmx51_otghost_init(); diff --git a/arch/arm/boards/chumby_falconwing/Makefile b/arch/arm/boards/chumby_falconwing/Makefile index 360b55cf48..cf92c6a9ea 100644 --- a/arch/arm/boards/chumby_falconwing/Makefile +++ b/arch/arm/boards/chumby_falconwing/Makefile @@ -1,3 +1,2 @@ obj-y = falconwing.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c index 0818666f60..fd5bc4c07e 100644 --- a/arch/arm/boards/chumby_falconwing/falconwing.c +++ b/arch/arm/boards/chumby_falconwing/falconwing.c @@ -16,6 +16,7 @@ #include <init.h> #include <gpio.h> #include <environment.h> +#include <envfs.h> #include <errno.h> #include <mci.h> #include <sizes.h> @@ -265,42 +266,6 @@ static int falconwing_mem_init(void) } mem_initcall(falconwing_mem_init); -/** - * Try to register an environment storage on the attached MCI card - * @return 0 on success - * - * We rely on the existence of a usable SD card, already attached to - * our system, to get something like a persistent memory for our environment. - * If this SD card is also the boot media, we can use the second partition - * for our environment purpose (if present!). - */ -static int register_persistant_environment(void) -{ - struct cdev *cdev; - - /* - * The chumby one only has one MCI card socket. - * So, we expect its name as "disk0". - */ - cdev = cdev_by_name("disk0"); - if (cdev == NULL) { - pr_err("No MCI card preset\n"); - return -ENODEV; - } - - /* MCI card is present, also a useable partition on it? */ - cdev = cdev_by_name("disk0.1"); - if (cdev == NULL) { - pr_err("No second partition available\n"); - pr_info("Please create at least a second partition with" - " 256 kiB...512 kiB in size (your choice)\n"); - return -ENODEV; - } - - /* use the full partition as our persistent environment storage */ - return devfs_add_partition("disk0.1", 0, cdev->size, DEVFS_PARTITION_FIXED, "env0"); -} - #define GPIO_USB_HUB_RESET 29 #define GPIO_USB_HUB_POWER 26 @@ -338,9 +303,9 @@ static int falconwing_devices_init(void) armlinux_set_bootparams((void *)IMX_MEMORY_BASE + 0x100); armlinux_set_architecture(MACH_TYPE_CHUMBY); - rc = register_persistant_environment(); + rc = envfs_register_partition("disk0", 1); if (rc != 0) - printf("Cannot create the 'env0' persistant environment storage (%d)\n", rc); + printf("Cannot create the 'env0' persistent environment storage (%d)\n", rc); return 0; } diff --git a/arch/arm/boards/clep7212/Makefile b/arch/arm/boards/clep7212/Makefile index a63aeaef39..4b0304feb3 100644 --- a/arch/arm/boards/clep7212/Makefile +++ b/arch/arm/boards/clep7212/Makefile @@ -1,2 +1,2 @@ -obj-y += lowlevel.o clep7212.o -pbl-y += lowlevel.o +obj-y += clep7212.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/clep7212/clep7212.c b/arch/arm/boards/clep7212/clep7212.c index a32337fafe..ec9a9cbdc7 100644 --- a/arch/arm/boards/clep7212/clep7212.c +++ b/arch/arm/boards/clep7212/clep7212.c @@ -14,24 +14,16 @@ #include <io.h> #include <sizes.h> #include <asm/armlinux.h> +#include <asm/mmu.h> #include <generated/mach-types.h> #include <mach/clps711x.h> #include <mach/devices.h> -static int clps711x_mem_init(void) -{ - ulong memsize = get_ram_size((ulong *)SDRAM0_BASE, SZ_32M); - - arm_add_mem_device("ram0", SDRAM0_BASE, memsize); - - return 0; -} -mem_initcall(clps711x_mem_init); - static int clps711x_devices_init(void) { u32 serial_h = 0, serial_l = readl(UNIQID); + void *cfi_io; /* Setup Chipselects */ clps711x_setup_memcfg(0, MEMCFG_WAITSTATE_6_1 | MEMCFG_BUS_WIDTH_16); @@ -40,7 +32,9 @@ static int clps711x_devices_init(void) MEMCFG_CLKENB); clps711x_setup_memcfg(3, MEMCFG_WAITSTATE_6_1 | MEMCFG_BUS_WIDTH_32); - add_cfi_flash_device(0, CS0_BASE, SZ_32M, 0); + cfi_io = map_io_sections(CS0_BASE, (void *)0x90000000, SZ_32M); + add_cfi_flash_device(DEVICE_ID_DYNAMIC, (unsigned long)cfi_io, SZ_32M, + IORESOURCE_MEM); devfs_add_partition("nor0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "self0"); diff --git a/arch/arm/boards/clep7212/env/bin/mtdparts-add b/arch/arm/boards/clep7212/env/bin/mtdparts-add deleted file mode 100644 index ef1bc0215f..0000000000 --- a/arch/arm/boards/clep7212/env/bin/mtdparts-add +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -if [ "$1" = menu ]; then - init-menu-add-entry "$0" "Partitions" - exit -fi - -norparts="256k(barebox),256k(bareboxenv),3584k(kernel),-(root)" -ramparts="-(ramdisk)" - -if [ -e /dev/nor0 ]; then - addpart -n /dev/nor0 "${norparts}" - - global linux.mtdparts.nor - global.linux.mtdparts.nor="physmap-flash.0:${norparts}" -else - echo "NOR Flash not found." -fi - -global linux.mtdparts.ram -global.linux.mtdparts.ram="mtd-ram.0:${ramparts}" diff --git a/arch/arm/boards/clep7212/env/boot/nor b/arch/arm/boards/clep7212/env/boot/nor index 5cf1e15833..df8c983884 100644 --- a/arch/arm/boards/clep7212/env/boot/nor +++ b/arch/arm/boards/clep7212/env/boot/nor @@ -6,4 +6,4 @@ if [ "$1" = menu ]; then fi global.bootm.image="/dev/kernel" -global.linux.bootargs.dyn.root="root=/dev/mtdblock4 ro" +global.linux.bootargs.dyn.root="root=/dev/mtdblock3 ro" diff --git a/arch/arm/boards/clep7212/env/config b/arch/arm/boards/clep7212/env/config new file mode 100644 index 0000000000..e8f2c3ab1b --- /dev/null +++ b/arch/arm/boards/clep7212/env/config @@ -0,0 +1,20 @@ +#!/bin/sh + +global.hostname=clps711x + +# set to false if you do not want to have colors +global.allow_color=true + +# user (used for network filenames) +global.user=anonymous + +# timeout in seconds before the default boot entry is started +global.autoboot_timeout=2 + +# default boot entry (one of /env/boot/*) +if [ -e /dev/nor0 ]; then + global.boot.default=nor +fi + +# default bootargs +global.linux.bootargs.base="earlyprintk console=ttyCL0,57600n8" diff --git a/arch/arm/boards/clep7212/env/init/automount b/arch/arm/boards/clep7212/env/init/automount deleted file mode 100644 index 978b96450d..0000000000 --- a/arch/arm/boards/clep7212/env/init/automount +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -if [ "$1" = menu ]; then - init-menu-add-entry "$0" "Automountpoints" - exit -fi diff --git a/arch/arm/boards/clep7212/env/init/bootargs-base b/arch/arm/boards/clep7212/env/init/bootargs-base deleted file mode 100644 index ec08e39181..0000000000 --- a/arch/arm/boards/clep7212/env/init/bootargs-base +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -if [ "$1" = menu ]; then - init-menu-add-entry "$0" "Base bootargs" - exit -fi - -global.linux.bootargs.base="earlyprintk console=ttyCL0,57600n8" diff --git a/arch/arm/boards/clep7212/env/init/general b/arch/arm/boards/clep7212/env/init/general deleted file mode 100644 index 77e6a59e6b..0000000000 --- a/arch/arm/boards/clep7212/env/init/general +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -if [ "$1" = menu ]; then - init-menu-add-entry "$0" "general config settings" - exit -fi - -global.user=barebox -global.autoboot_timeout=2 -global.boot.default=nor - -/env/bin/mtdparts-add diff --git a/arch/arm/boards/clep7212/env/init/hostname b/arch/arm/boards/clep7212/env/init/hostname deleted file mode 100644 index 684ee63ba5..0000000000 --- a/arch/arm/boards/clep7212/env/init/hostname +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -if [ "$1" = menu ]; then - init-menu-add-entry "$0" "hostname" - exit -fi - -global.hostname=clep7212 diff --git a/arch/arm/boards/clep7212/env/init/mtdparts-nor b/arch/arm/boards/clep7212/env/init/mtdparts-nor new file mode 100644 index 0000000000..7910299c8a --- /dev/null +++ b/arch/arm/boards/clep7212/env/init/mtdparts-nor @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + init-menu-add-entry "$0" "NOR partitions" + exit +fi + +mtdparts="256k(barebox),256k(bareboxenv),3584k(kernel),-(root)" +kernelname="physmap-flash.0" + +mtdparts-add -d nor0 -k ${kernelname} -p ${mtdparts} diff --git a/arch/arm/boards/clep7212/lowlevel.c b/arch/arm/boards/clep7212/lowlevel.c index b4d1bf11db..fcf828500d 100644 --- a/arch/arm/boards/clep7212/lowlevel.c +++ b/arch/arm/boards/clep7212/lowlevel.c @@ -9,49 +9,18 @@ #include <common.h> #include <init.h> -#include <sizes.h> -#include <asm/io.h> -#include <asm/barebox-arm.h> #include <asm/barebox-arm-head.h> #include <mach/clps711x.h> -#define MAIN_CLOCK 3686400 -#define CPU_SPEED 92160000 -#define BUS_SPEED (CPU_SPEED / 2) - -#define PLL_VALUE (((CPU_SPEED * 2) / MAIN_CLOCK) << 24) -#define SDRAM_REFRESH_RATE (64 * (BUS_SPEED / (8192 * 1000))) +#if (CONFIG_CLPS711X_CPU_PLL_MULT < 20) || (CONFIG_CLPS711X_CPU_PLL_MULT > 50) +# error "CPU PLL multiplier out of range" +#endif void __naked __bare_init barebox_arm_reset_vector(void) { - u32 tmp; - arm_cpu_lowlevel_init(); - /* Setup base clock */ - writel(SYSCON3_CLKCTL0 | SYSCON3_CLKCTL1, SYSCON3); - asm("nop"); - - /* Setup PLL */ - writel(PLL_VALUE, PLLW); - asm("nop"); - - /* CLKEN select, SDRAM width=32 */ - writel(SYSCON2_CLKENSL, SYSCON2); - - /* Enable SDQM pins */ - tmp = readl(SYSCON3); - tmp &= ~SYSCON3_ENPD67; - writel(tmp, SYSCON3); - - /* Setup Refresh Rate (64ms 8K Blocks) */ - writel(SDRAM_REFRESH_RATE, SDRFPR); - - /* Setup SDRAM (32MB, 16Bit*2, CAS=3) */ - writel(SDCONF_CASLAT_3 | SDCONF_SIZE_256 | SDCONF_WIDTH_16 | - SDCONF_CLKCTL | SDCONF_ACTIVE, SDCONF); - - barebox_arm_entry(SDRAM0_BASE, SZ_32M, 0); + clps711x_barebox_entry(CONFIG_CLPS711X_CPU_PLL_MULT); } diff --git a/arch/arm/boards/crystalfontz-cfa10036/Makefile b/arch/arm/boards/crystalfontz-cfa10036/Makefile index 0b701ed5af..5b764a6981 100644 --- a/arch/arm/boards/crystalfontz-cfa10036/Makefile +++ b/arch/arm/boards/crystalfontz-cfa10036/Makefile @@ -1,3 +1,2 @@ obj-y += cfa10036.o hwdetect.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c index b59dbab4a6..1bc20cf21c 100644 --- a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +++ b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c @@ -17,6 +17,7 @@ #include <common.h> #include <environment.h> +#include <envfs.h> #include <errno.h> #include <fec.h> #include <gpio.h> @@ -99,7 +100,7 @@ mem_initcall(cfa10036_mem_init); static int cfa10036_devices_init(void) { - int i; + int i, ret; /* initizalize muxing */ for (i = 0; i < ARRAY_SIZE(cfa10036_pads); i++) @@ -124,6 +125,11 @@ static int cfa10036_devices_init(void) cfa10036_detect_hw(); + ret = envfs_register_partition("disk0", 1); + if (ret != 0) + printf("Cannot create the 'env0' persistent " + "environment storage (%d)\n", ret); + return 0; } device_initcall(cfa10036_devices_init); diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 b/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 index 5e508f95f6..4d830edc69 100644 --- a/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 +++ b/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 @@ -5,6 +5,6 @@ if [ "$1" = menu ]; then exit fi -global.bootm.image="/mnt/disk0.1/zImage-${global.hostname}" -global.bootm.oftree="/mnt/disk0.1/oftree-${global.board.variant}" +global.bootm.image="/mnt/disk0.2/boot/zImage-${global.hostname}" +global.bootm.oftree="/mnt/disk0.2/boot/oftree-${global.board.variant}" global.linux.bootargs.dyn.root="root=/dev/mmcblk0p3 rootfstype=ext3 rootwait" diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/init/config-board b/arch/arm/boards/crystalfontz-cfa10036/env/config-board index b99866ecfe..b99866ecfe 100644 --- a/arch/arm/boards/crystalfontz-cfa10036/env/init/config-board +++ b/arch/arm/boards/crystalfontz-cfa10036/env/config-board diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/init/automount b/arch/arm/boards/crystalfontz-cfa10036/env/init/automount index 668775d89b..8fdca7cd47 100644 --- a/arch/arm/boards/crystalfontz-cfa10036/env/init/automount +++ b/arch/arm/boards/crystalfontz-cfa10036/env/init/automount @@ -5,5 +5,5 @@ if [ "$1" = menu ]; then exit fi -mkdir -p /mnt/disk0.1 -automount -d /mnt/disk0.1 '[ -e /dev/disk0.1 ] && mount /dev/disk0.1 /mnt/disk0.1' +mkdir -p /mnt/disk0.2 +automount -d /mnt/disk0.2 '[ -e /dev/disk0.2 ] && mount /dev/disk0.2 /mnt/disk0.2' diff --git a/arch/arm/boards/dss11/init.c b/arch/arm/boards/dss11/init.c index 2920d5e80a..77ae46fcce 100644 --- a/arch/arm/boards/dss11/init.c +++ b/arch/arm/boards/dss11/init.c @@ -113,6 +113,8 @@ static void dss11_phy_reset(void) static struct atmel_mci_platform_data dss11_mci_data = { .slot_b = 1, .bus_width = 4, + .detect_pin = -EINVAL, + .wp_pin = -EINVAL, }; static struct at91_usbh_data dss11_usbh_data = { diff --git a/arch/arm/boards/edb93xx/Makefile b/arch/arm/boards/edb93xx/Makefile index 945c963ffd..eec5ed2658 100644 --- a/arch/arm/boards/edb93xx/Makefile +++ b/arch/arm/boards/edb93xx/Makefile @@ -1,3 +1,3 @@ -obj-y += edb93xx.o flash_cfg.o pll_cfg.o sdram_cfg.o -pbl-y += edb93xx.o flash_cfg.o pll_cfg.o sdram_cfg.o +obj-y += edb93xx.o +lwl-y += flash_cfg.o pll_cfg.o sdram_cfg.o diff --git a/arch/arm/boards/efika-mx-smartbook/Makefile b/arch/arm/boards/efika-mx-smartbook/Makefile index 6ca1c069c4..a2c3104e6c 100644 --- a/arch/arm/boards/efika-mx-smartbook/Makefile +++ b/arch/arm/boards/efika-mx-smartbook/Makefile @@ -1,5 +1,3 @@ -obj-y += lowlevel.o -pbl-y += lowlevel.o obj-y += board.o -obj-y += flash_header.o -pbl-y += flash_header.o +lwl-y += lowlevel.o +lwl-y += flash_header.o diff --git a/arch/arm/boards/efika-mx-smartbook/env/init/config-board b/arch/arm/boards/efika-mx-smartbook/env/config-board index 22993f9c29..22993f9c29 100644 --- a/arch/arm/boards/efika-mx-smartbook/env/init/config-board +++ b/arch/arm/boards/efika-mx-smartbook/env/config-board diff --git a/arch/arm/boards/eukrea_cpuimx25/Makefile b/arch/arm/boards/eukrea_cpuimx25/Makefile index 56ed63f555..203fcfb7f1 100644 --- a/arch/arm/boards/eukrea_cpuimx25/Makefile +++ b/arch/arm/boards/eukrea_cpuimx25/Makefile @@ -16,8 +16,6 @@ # # -obj-y += lowlevel.o -pbl-y += lowlevel.o obj-y += eukrea_cpuimx25.o -obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o -pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o +lwl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/eukrea_cpuimx27/Makefile b/arch/arm/boards/eukrea_cpuimx27/Makefile index fe6d376159..2c3148abd0 100644 --- a/arch/arm/boards/eukrea_cpuimx27/Makefile +++ b/arch/arm/boards/eukrea_cpuimx27/Makefile @@ -1,4 +1,3 @@ -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o +lwl-y += lowlevel_init.o obj-y += eukrea_cpuimx27.o diff --git a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c index 65b6c44843..d6905815a6 100644 --- a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c +++ b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c @@ -230,14 +230,14 @@ console_initcall(eukrea_cpuimx27_console_init); static int eukrea_cpuimx27_late_init(void) { -#ifdef CONFIG_I2C_LP3972 +#ifdef CONFIG_MFD_LP3972 struct i2c_client *client; u8 reg[1]; #endif console_flush(); imx27_add_fec(&fec_info); -#ifdef CONFIG_I2C_LP3972 +#ifdef CONFIG_MFD_LP3972 client = lp3972_get_client(); if (!client) return -ENODEV; diff --git a/arch/arm/boards/eukrea_cpuimx35/Makefile b/arch/arm/boards/eukrea_cpuimx35/Makefile index bdf06124fd..227b76bbb8 100644 --- a/arch/arm/boards/eukrea_cpuimx35/Makefile +++ b/arch/arm/boards/eukrea_cpuimx35/Makefile @@ -16,8 +16,6 @@ # # -obj-y += lowlevel.o -pbl-y += lowlevel.o obj-y += eukrea_cpuimx35.o -obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o -pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o +lwl-y += lowlevel.o +lwl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o diff --git a/arch/arm/boards/eukrea_cpuimx51/Makefile b/arch/arm/boards/eukrea_cpuimx51/Makefile index 1a237971bc..1509c92455 100644 --- a/arch/arm/boards/eukrea_cpuimx51/Makefile +++ b/arch/arm/boards/eukrea_cpuimx51/Makefile @@ -1,5 +1,3 @@ obj-y += eukrea_cpuimx51.o -obj-y += flash_header.o -pbl-y += flash_header.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += flash_header.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/freescale-mx23-evk/Makefile b/arch/arm/boards/freescale-mx23-evk/Makefile index 93866033ab..3e0026252c 100644 --- a/arch/arm/boards/freescale-mx23-evk/Makefile +++ b/arch/arm/boards/freescale-mx23-evk/Makefile @@ -1,4 +1,3 @@ # obj-y := mx23-evk.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/freescale-mx23-evk/mx23-evk.c b/arch/arm/boards/freescale-mx23-evk/mx23-evk.c index 0c5fa4b513..76377b1a36 100644 --- a/arch/arm/boards/freescale-mx23-evk/mx23-evk.c +++ b/arch/arm/boards/freescale-mx23-evk/mx23-evk.c @@ -24,10 +24,13 @@ #include <mach/imx-regs.h> #include <mach/clock.h> #include <mach/mci.h> +#include <usb/fsl_usb2.h> +#include <mach/usb.h> static struct mxs_mci_platform_data mci_pdata = { - .caps = MMC_MODE_4BIT, + .caps = MMC_MODE_4BIT | MMC_MODE_HS | MMC_MODE_HS_52MHz, .voltages = MMC_VDD_32_33 | MMC_VDD_33_34, /* fixed to 3.3 V */ + .f_min = 400000, }; static const uint32_t pad_setup[] = { @@ -41,6 +44,13 @@ static const uint32_t pad_setup[] = { SSP1_DETECT | PULLUP(1), }; +#ifdef CONFIG_USB_GADGET_DRIVER_ARC +static struct fsl_usb2_platform_data usb_pdata = { + .operating_mode = FSL_USB2_DR_DEVICE, + .phy_mode = FSL_USB2_PHY_UTMI, +}; +#endif + static int mx23_evk_mem_init(void) { arm_add_mem_device("ram0", IMX_MEMORY_BASE, 32 * 1024 * 1024); @@ -49,9 +59,48 @@ static int mx23_evk_mem_init(void) } mem_initcall(mx23_evk_mem_init); +/** + * Try to register an environment storage on the attached MCI card + * @return 0 on success + * + * We rely on the existence of a usable SD card, already attached to + * our system, to get something like a persistent memory for our environment. + * If this SD card is also the boot media, we can use the second partition + * for our environment purpose (if present!). + */ +static int register_persistant_environment(void) +{ + struct cdev *cdev; + + /* + * The imx23-olinuxino only has one MCI card socket. + * So, we expect its name as "disk0". + */ + cdev = cdev_by_name("disk0"); + if (cdev == NULL) { + pr_err("No MCI card preset\n"); + return -ENODEV; + } + + + + /* MCI card is present, also a useable partition on it? */ + cdev = cdev_by_name("disk0.1"); + if (cdev == NULL) { + pr_err("No second partition available\n"); + pr_info("Please create at least a second partition with" + " 256 kiB...512 kiB in size (your choice)\n"); + return -ENODEV; + } + + /* use the full partition as our persistent environment storage */ + return devfs_add_partition("disk0.1", 0, cdev->size, + DEVFS_PARTITION_FIXED, "env0"); +} + static int mx23_evk_devices_init(void) { - int i; + int i, rc; /* initizalize gpios */ for (i = 0; i < ARRAY_SIZE(pad_setup); i++) @@ -62,9 +111,21 @@ static int mx23_evk_devices_init(void) imx_set_ioclk(480000000); /* enable IOCLK to run at the PLL frequency */ imx_set_sspclk(0, 100000000, 1); - add_generic_device("mxs_mci", 0, NULL, IMX_SSP1_BASE, 0, - IORESOURCE_MEM, &mci_pdata); + add_generic_device("mxs_mci", DEVICE_ID_DYNAMIC, NULL, IMX_SSP1_BASE, + 0x8000, IORESOURCE_MEM, &mci_pdata); + + rc = register_persistant_environment(); + if (rc != 0) + printf("Cannot create the 'env0' persistant " + "environment storage (%d)\n", rc); + +#ifdef CONFIG_USB_GADGET_DRIVER_ARC + imx23_usb_phy_enable(); + add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_USB_BASE, NULL); + add_generic_device("fsl-udc", DEVICE_ID_DYNAMIC, NULL, IMX_USB_BASE, + 0x200, IORESOURCE_MEM, &usb_pdata); +#endif return 0; } diff --git a/arch/arm/boards/freescale-mx25-3-stack/Makefile b/arch/arm/boards/freescale-mx25-3-stack/Makefile index 2c02406383..52c416e3a5 100644 --- a/arch/arm/boards/freescale-mx25-3-stack/Makefile +++ b/arch/arm/boards/freescale-mx25-3-stack/Makefile @@ -16,6 +16,5 @@ # # -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o +lwl-y += lowlevel_init.o obj-y += 3stack.o diff --git a/arch/arm/boards/freescale-mx28-evk/Makefile b/arch/arm/boards/freescale-mx28-evk/Makefile index 20396107f6..a74ec2451b 100644 --- a/arch/arm/boards/freescale-mx28-evk/Makefile +++ b/arch/arm/boards/freescale-mx28-evk/Makefile @@ -1,3 +1,2 @@ obj-y += mx28-evk.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/freescale-mx28-evk/mx28-evk.c b/arch/arm/boards/freescale-mx28-evk/mx28-evk.c index 4311473e65..2e866a3351 100644 --- a/arch/arm/boards/freescale-mx28-evk/mx28-evk.c +++ b/arch/arm/boards/freescale-mx28-evk/mx28-evk.c @@ -30,6 +30,7 @@ #include <mach/mci.h> #include <mach/fb.h> #include <mach/ocotp.h> +#include <spi/spi.h> #include <asm/armlinux.h> #include <asm/mmu.h> @@ -126,6 +127,12 @@ static const uint32_t mx28evk_pads[] = { GPMI_ALE | VE_3_3V, GPMI_CLE | VE_3_3V, GPMI_RESETN, /* act as WP, external PU */ + + /* SSP */ + SSP2_D0 | VE_3_3V | PULLUP(1) | STRENGTH(S8MA), /* MISO DO */ + SSP2_D3 | VE_3_3V | PULLUP(1) | STRENGTH(S8MA), /* SS0 !CS */ + SSP2_CMD | VE_3_3V | PULLUP(1) | STRENGTH(S8MA), /* MOSI DIO */ + SSP2_SCK | VE_3_3V | PULLUP(1) | STRENGTH(S8MA), /* CLK */ }; static struct mxs_mci_platform_data mci_pdata = { @@ -225,6 +232,19 @@ static int mx28_evk_mem_init(void) } mem_initcall(mx28_evk_mem_init); +static const struct spi_board_info mx28evk_spi_board_info[] = { + { + .name = "m25p80", + /* + * we leave this with the lower frequency + * as the ssp unit otherwise locks up + */ + .max_speed_hz = 32000000, + .bus_num = 2, + .chip_select = 0, + } +}; + static int mx28_evk_devices_init(void) { int i; @@ -235,8 +255,11 @@ static int mx28_evk_devices_init(void) /* enable IOCLK0 to run at the PLL frequency */ imx_set_ioclk(0, 480000000); + imx_set_ioclk(1, 320000000); /* run the SSP unit clock at 100 MHz */ imx_set_sspclk(0, 100000000, 1); + /* run the SSP unit 2 clock at 160Mhz */ + imx_set_sspclk(2, 160000000, 1); armlinux_set_bootparams((void *)IMX_MEMORY_BASE + 0x100); armlinux_set_architecture(MACH_TYPE_MX28EVK); @@ -259,6 +282,12 @@ static int mx28_evk_devices_init(void) add_generic_device("mxs_nand", 0, NULL, MXS_GPMI_BASE, 0x2000, IORESOURCE_MEM, NULL); + spi_register_board_info(mx28evk_spi_board_info, + ARRAY_SIZE(mx28evk_spi_board_info)); + + add_generic_device("mxs_spi", 2, NULL, IMX_SSP2_BASE, 0x2000, + IORESOURCE_MEM, NULL); + return 0; } device_initcall(mx28_evk_devices_init); diff --git a/arch/arm/boards/freescale-mx35-3-stack/Makefile b/arch/arm/boards/freescale-mx35-3-stack/Makefile index 3f224f6ad2..a1110c2e0b 100644 --- a/arch/arm/boards/freescale-mx35-3-stack/Makefile +++ b/arch/arm/boards/freescale-mx35-3-stack/Makefile @@ -1,6 +1,4 @@ -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o obj-y += 3stack.o -obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o -pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o +lwl-y += lowlevel_init.o +lwl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o diff --git a/arch/arm/boards/freescale-mx51-pdk/Makefile b/arch/arm/boards/freescale-mx51-pdk/Makefile index 2f45976184..d44f697718 100644 --- a/arch/arm/boards/freescale-mx51-pdk/Makefile +++ b/arch/arm/boards/freescale-mx51-pdk/Makefile @@ -1,5 +1,3 @@ obj-y += board.o -obj-y += flash_header.o -pbl-y += flash_header.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += flash_header.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/freescale-mx51-pdk/env/init/config-board b/arch/arm/boards/freescale-mx51-pdk/env/config-board index cfc483eb3d..cfc483eb3d 100644 --- a/arch/arm/boards/freescale-mx51-pdk/env/init/config-board +++ b/arch/arm/boards/freescale-mx51-pdk/env/config-board diff --git a/arch/arm/boards/freescale-mx53-loco/Makefile b/arch/arm/boards/freescale-mx53-loco/Makefile index 2f45976184..d44f697718 100644 --- a/arch/arm/boards/freescale-mx53-loco/Makefile +++ b/arch/arm/boards/freescale-mx53-loco/Makefile @@ -1,5 +1,3 @@ obj-y += board.o -obj-y += flash_header.o -pbl-y += flash_header.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += flash_header.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/freescale-mx53-loco/env/init/config-board b/arch/arm/boards/freescale-mx53-loco/env/config-board index a6cf69ddbc..a6cf69ddbc 100644 --- a/arch/arm/boards/freescale-mx53-loco/env/init/config-board +++ b/arch/arm/boards/freescale-mx53-loco/env/config-board diff --git a/arch/arm/boards/freescale-mx53-smd/Makefile b/arch/arm/boards/freescale-mx53-smd/Makefile index 2f45976184..d44f697718 100644 --- a/arch/arm/boards/freescale-mx53-smd/Makefile +++ b/arch/arm/boards/freescale-mx53-smd/Makefile @@ -1,5 +1,3 @@ obj-y += board.o -obj-y += flash_header.o -pbl-y += flash_header.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += flash_header.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/freescale-mx6-arm2/Makefile b/arch/arm/boards/freescale-mx6-arm2/Makefile index 21fb7d9f93..d44f697718 100644 --- a/arch/arm/boards/freescale-mx6-arm2/Makefile +++ b/arch/arm/boards/freescale-mx6-arm2/Makefile @@ -1,4 +1,3 @@ -obj-y += board.o flash_header.o -pbl-y += flash_header.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +obj-y += board.o +lwl-y += flash_header.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/freescale-mx6-sabrelite/Makefile b/arch/arm/boards/freescale-mx6-sabrelite/Makefile index 21fb7d9f93..d44f697718 100644 --- a/arch/arm/boards/freescale-mx6-sabrelite/Makefile +++ b/arch/arm/boards/freescale-mx6-sabrelite/Makefile @@ -1,4 +1,3 @@ -obj-y += board.o flash_header.o -pbl-y += flash_header.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +obj-y += board.o +lwl-y += flash_header.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/freescale-mx6-sabrelite/env/init/config-board b/arch/arm/boards/freescale-mx6-sabrelite/env/config-board index e39e4b6141..e39e4b6141 100644 --- a/arch/arm/boards/freescale-mx6-sabrelite/env/init/config-board +++ b/arch/arm/boards/freescale-mx6-sabrelite/env/config-board diff --git a/arch/arm/boards/freescale-mx6-sabresd/Makefile b/arch/arm/boards/freescale-mx6-sabresd/Makefile new file mode 100644 index 0000000000..21fb7d9f93 --- /dev/null +++ b/arch/arm/boards/freescale-mx6-sabresd/Makefile @@ -0,0 +1,4 @@ +obj-y += board.o flash_header.o +pbl-y += flash_header.o +obj-y += lowlevel.o +pbl-y += lowlevel.o diff --git a/arch/arm/boards/freescale-mx6-sabresd/board.c b/arch/arm/boards/freescale-mx6-sabresd/board.c new file mode 100644 index 0000000000..1cdb0aa6c3 --- /dev/null +++ b/arch/arm/boards/freescale-mx6-sabresd/board.c @@ -0,0 +1,244 @@ +/* + * Copyright (C) 2013 Hubert Feurstein <h.feurstein@gmail.com> + * + * based on arch/arm/boards/freescale-mx6-sabrelite/board.c + * Copyright (C) 2012 Steffen Trumtrar, Pengutronix + * + * 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 <environment.h> +#include <mach/imx6-regs.h> +#include <fec.h> +#include <mach/gpio.h> +#include <asm/armlinux.h> +#include <generated/mach-types.h> +#include <partition.h> +#include <linux/phy.h> +#include <asm/io.h> +#include <asm/mmu.h> +#include <mach/generic.h> +#include <sizes.h> +#include <net.h> +#include <mach/imx6.h> +#include <mach/devices-imx6.h> +#include <mach/iomux-mx6.h> +#include <mach/gpio.h> +#include <spi/spi.h> +#include <mach/spi.h> +#include <mach/usb.h> + +#define PHY_ID_AR8031 0x004dd074 +#define AR_PHY_ID_MASK 0xffffffff + +#define SABRESD_SD2_CD IMX_GPIO_NR(2, 2) +#define SABRESD_SD2_WP IMX_GPIO_NR(2, 3) + +#define SABRESD_SD3_CD IMX_GPIO_NR(2, 0) +#define SABRESD_SD3_WP IMX_GPIO_NR(2, 1) + +static iomux_v3_cfg_t sabresd_pads[] = { + /* UART1 */ + MX6Q_PAD_CSI0_DAT11__UART1_RXD, + MX6Q_PAD_CSI0_DAT10__UART1_TXD, + + /* Ethernet */ + MX6Q_PAD_ENET_MDC__ENET_MDC, + MX6Q_PAD_ENET_MDIO__ENET_MDIO, + MX6Q_PAD_ENET_REF_CLK__ENET_TX_CLK, + + MX6Q_PAD_RGMII_TXC__ENET_RGMII_TXC, + MX6Q_PAD_RGMII_TD0__ENET_RGMII_TD0, + MX6Q_PAD_RGMII_TD1__ENET_RGMII_TD1, + MX6Q_PAD_RGMII_TD2__ENET_RGMII_TD2, + MX6Q_PAD_RGMII_TD3__ENET_RGMII_TD3, + MX6Q_PAD_RGMII_TX_CTL__ENET_RGMII_TX_CTL, + + MX6Q_PAD_RGMII_RXC__ENET_RGMII_RXC, + MX6Q_PAD_RGMII_RD0__ENET_RGMII_RD0, + MX6Q_PAD_RGMII_RD1__ENET_RGMII_RD1, + MX6Q_PAD_RGMII_RD2__ENET_RGMII_RD2, + MX6Q_PAD_RGMII_RD3__ENET_RGMII_RD3, + MX6Q_PAD_RGMII_RX_CTL__ENET_RGMII_RX_CTL, + + MX6Q_PAD_ENET_CRS_DV__GPIO_1_25, /* AR8031 PHY Reset */ + MX6Q_PAD_GPIO_16__ENET_ANATOP_ETHERNET_REF_OUT, + + /* SD2 */ + MX6Q_PAD_SD2_CLK__USDHC2_CLK, + MX6Q_PAD_SD2_CMD__USDHC2_CMD, + MX6Q_PAD_SD2_DAT0__USDHC2_DAT0, + MX6Q_PAD_SD2_DAT1__USDHC2_DAT1, + MX6Q_PAD_SD2_DAT2__USDHC2_DAT2, + MX6Q_PAD_SD2_DAT3__USDHC2_DAT3, + MX6Q_PAD_NANDF_D4__USDHC2_DAT4, + MX6Q_PAD_NANDF_D5__USDHC2_DAT5, + MX6Q_PAD_NANDF_D6__USDHC2_DAT6, + MX6Q_PAD_NANDF_D7__USDHC2_DAT7, + MX6Q_PAD_NANDF_D2__GPIO_2_2, /* CD */ + MX6Q_PAD_NANDF_D3__GPIO_2_3, /* WP */ + + /* SD3 */ + MX6Q_PAD_SD3_CMD__USDHC3_CMD, + MX6Q_PAD_SD3_CLK__USDHC3_CLK, + MX6Q_PAD_SD3_DAT0__USDHC3_DAT0, + MX6Q_PAD_SD3_DAT1__USDHC3_DAT1, + MX6Q_PAD_SD3_DAT2__USDHC3_DAT2, + MX6Q_PAD_SD3_DAT3__USDHC3_DAT3, + MX6Q_PAD_SD3_DAT4__USDHC3_DAT4, + MX6Q_PAD_SD3_DAT5__USDHC3_DAT5, + MX6Q_PAD_SD3_DAT6__USDHC3_DAT6, + MX6Q_PAD_SD3_DAT7__USDHC3_DAT7, + MX6Q_PAD_NANDF_D0__GPIO_2_0, /* CD */ + MX6Q_PAD_NANDF_D1__GPIO_2_1, /* WP */ + + /* SD4 */ + MX6Q_PAD_SD4_CLK__USDHC4_CLK, + MX6Q_PAD_SD4_CMD__USDHC4_CMD, + MX6Q_PAD_SD4_DAT0__USDHC4_DAT0, + MX6Q_PAD_SD4_DAT1__USDHC4_DAT1, + MX6Q_PAD_SD4_DAT2__USDHC4_DAT2, + MX6Q_PAD_SD4_DAT3__USDHC4_DAT3, + MX6Q_PAD_SD4_DAT4__USDHC4_DAT4, + MX6Q_PAD_SD4_DAT5__USDHC4_DAT5, + MX6Q_PAD_SD4_DAT6__USDHC4_DAT6, + MX6Q_PAD_SD4_DAT7__USDHC4_DAT7, + + /* I2C0 */ + MX6Q_PAD_CSI0_DAT8__I2C1_SDA, + MX6Q_PAD_CSI0_DAT9__I2C1_SCL, + + /* I2C1 */ + MX6Q_PAD_KEY_COL3__I2C2_SCL, + MX6Q_PAD_KEY_ROW3__I2C2_SDA, + + /* I2C2 */ + MX6Q_PAD_GPIO_3__I2C3_SCL, + MX6Q_PAD_GPIO_6__I2C3_SDA, +}; + +static int sabresd_mem_init(void) +{ + arm_add_mem_device("ram0", 0x10000000, SZ_1G); + + return 0; +} +mem_initcall(sabresd_mem_init); + +static int ar8031_phy_fixup(struct phy_device *dev) +{ + u16 val; + + /* To enable AR8031 ouput a 125MHz clk from CLK_25M */ + phy_write(dev, 0xd, 0x7); + phy_write(dev, 0xe, 0x8016); + phy_write(dev, 0xd, 0x4007); + + val = phy_read(dev, 0xe); + val &= 0xffe3; + val |= 0x18; + phy_write(dev, 0xe, val); + + /* introduce tx clock delay */ + phy_write(dev, 0x1d, 0x5); + val = phy_read(dev, 0x1e); + val |= 0x0100; + phy_write(dev, 0x1e, val); + + return 0; +} + +static struct fec_platform_data fec_info = { + .xcv_type = RGMII, + .phy_addr = 1, +}; + +static void sabresd_phy_reset(void) +{ + /* Reset AR8031 PHY */ + gpio_direction_output(IMX_GPIO_NR(1, 25) , 0); + udelay(500); + gpio_set_value(IMX_GPIO_NR(1, 25), 1); +} + +static inline int imx6_iim_register_fec_ethaddr(void) +{ + u32 value; + u8 buf[6]; + + value = readl(MX6_OCOTP_BASE_ADDR + 0x630); + buf[0] = (value >> 8); + buf[1] = value; + + value = readl(MX6_OCOTP_BASE_ADDR + 0x620); + buf[2] = value >> 24; + buf[3] = value >> 16; + buf[4] = value >> 8; + buf[5] = value; + + eth_register_ethaddr(0, buf); + + return 0; +} + +static struct esdhc_platform_data sabresd_sd2_data = { + .cd_gpio = SABRESD_SD2_CD, + .cd_type = ESDHC_CD_GPIO, + .wp_gpio = SABRESD_SD2_WP, + .wp_type = ESDHC_WP_GPIO, +}; + +static struct esdhc_platform_data sabresd_sd3_data = { + .cd_gpio = SABRESD_SD3_CD, + .cd_type = ESDHC_CD_GPIO, + .wp_gpio = SABRESD_SD3_WP, + .wp_type = ESDHC_WP_GPIO, +}; + +static struct esdhc_platform_data sabresd_sd4_data = { + .cd_type = ESDHC_CD_PERMANENT, + .wp_type = ESDHC_WP_CONTROLLER, +}; + +static int sabresd_devices_init(void) +{ + imx6_add_mmc3(&sabresd_sd4_data); + imx6_add_mmc1(&sabresd_sd2_data); + imx6_add_mmc2(&sabresd_sd3_data); + + phy_register_fixup_for_uid(PHY_ID_AR8031, AR_PHY_ID_MASK, ar8031_phy_fixup); + + sabresd_phy_reset(); + imx6_iim_register_fec_ethaddr(); + imx6_add_fec(&fec_info); + + armlinux_set_bootparams((void *)0x10000100); + armlinux_set_architecture(3980); + + devfs_add_partition("disk0", 0, SZ_1M, DEVFS_PARTITION_FIXED, "self0"); + devfs_add_partition("disk0", SZ_1M + SZ_1M, SZ_512K, DEVFS_PARTITION_FIXED, "env0"); + return 0; +} +device_initcall(sabresd_devices_init); + +static int sabresd_console_init(void) +{ + mxc_iomux_v3_setup_multiple_pads(sabresd_pads, ARRAY_SIZE(sabresd_pads)); + + imx6_init_lowlevel(); + + imx6_add_uart0(); + + return 0; +} +console_initcall(sabresd_console_init); diff --git a/arch/arm/boards/freescale-mx6-sabresd/config.h b/arch/arm/boards/freescale-mx6-sabresd/config.h new file mode 100644 index 0000000000..ca15136817 --- /dev/null +++ b/arch/arm/boards/freescale-mx6-sabresd/config.h @@ -0,0 +1,4 @@ +#ifndef __CONFIG_H +#define __CONFIG_H + +#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/freescale-mx6-sabresd/env/init/config-board b/arch/arm/boards/freescale-mx6-sabresd/env/init/config-board new file mode 100644 index 0000000000..cf936fb949 --- /dev/null +++ b/arch/arm/boards/freescale-mx6-sabresd/env/init/config-board @@ -0,0 +1,7 @@ +#!/bin/sh + +# board defaults, do not change in running system. Change /env/config +# instead + +global.hostname=SabreSD +global.linux.bootargs.base="console=ttymxc0,115200" diff --git a/arch/arm/boards/freescale-mx6-sabresd/flash_header.c b/arch/arm/boards/freescale-mx6-sabresd/flash_header.c new file mode 100644 index 0000000000..61d482b437 --- /dev/null +++ b/arch/arm/boards/freescale-mx6-sabresd/flash_header.c @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2011 Marc Kleine-Budde <mkl@pengutronix.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 <asm/byteorder.h> +#include <mach/imx-flash-header.h> +#include <mach/imx6-regs.h> +#include <asm/barebox-arm-head.h> + +void __naked __flash_header_start go(void) +{ + barebox_arm_head(); +} + +#define DCD(a, v) { .addr = cpu_to_be32(a), .val = cpu_to_be32(v), } + +struct imx_dcd_v2_entry __dcd_entry_section dcd_entry[] = { + DCD(MX6_IOMUXC_BASE_ADDR + 0x5a8, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x5b0, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x524, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x51c, 0x00000030), + + DCD(MX6_IOMUXC_BASE_ADDR + 0x518, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x50c, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x5b8, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x5c0, 0x00000030), + + DCD(MX6_IOMUXC_BASE_ADDR + 0x5ac, 0x00020030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x5b4, 0x00020030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x528, 0x00020030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x520, 0x00020030), + + DCD(MX6_IOMUXC_BASE_ADDR + 0x514, 0x00020030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x510, 0x00020030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x5bc, 0x00020030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x5c4, 0x00020030), + + DCD(MX6_IOMUXC_BASE_ADDR + 0x56c, 0x00020030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x578, 0x00020030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x588, 0x00020030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x594, 0x00020030), + + DCD(MX6_IOMUXC_BASE_ADDR + 0x57c, 0x00020030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x590, 0x00003000), + DCD(MX6_IOMUXC_BASE_ADDR + 0x598, 0x00003000), + DCD(MX6_IOMUXC_BASE_ADDR + 0x58c, 0x00000000), + + DCD(MX6_IOMUXC_BASE_ADDR + 0x59c, 0x00003030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x5a0, 0x00003030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x784, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x788, 0x00000030), + + DCD(MX6_IOMUXC_BASE_ADDR + 0x794, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x79c, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x7a0, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x7a4, 0x00000030), + + DCD(MX6_IOMUXC_BASE_ADDR + 0x7a8, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x748, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x74c, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x750, 0x00020000), + + DCD(MX6_IOMUXC_BASE_ADDR + 0x758, 0x00000000), + DCD(MX6_IOMUXC_BASE_ADDR + 0x774, 0x00020000), + DCD(MX6_IOMUXC_BASE_ADDR + 0x78c, 0x00000030), + DCD(MX6_IOMUXC_BASE_ADDR + 0x798, 0x000C0000), + + DCD(MX6_MMDC_P0_BASE_ADDR + 0x81c, 0x33333333), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x820, 0x33333333), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x824, 0x33333333), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x828, 0x33333333), + + DCD(MX6_MMDC_P1_BASE_ADDR + 0x81c, 0x33333333), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x820, 0x33333333), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x824, 0x33333333), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x828, 0x33333333), + + DCD(MX6_MMDC_P0_BASE_ADDR + 0x018, 0x00081740), + + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x00008000), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x00c, 0x555A7975), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x010, 0xFF538E64), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x014, 0x01FF00DB), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x02c, 0x000026D2), + + DCD(MX6_MMDC_P0_BASE_ADDR + 0x030, 0x005B0E21), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x008, 0x09444040), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x004, 0x00025576), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x040, 0x00000027), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x000, 0x831A0000), + + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x04088032), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x0408803A), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x00008033), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x0000803B), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x00428031), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x00428039), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x09408030), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x09408038), + + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x04008040), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x04008048), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x800, 0xA1380003), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x800, 0xA1380003), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x020, 0x00005800), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x818, 0x00022227), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x818, 0x00022227), + + DCD(MX6_MMDC_P0_BASE_ADDR + 0x83c, 0x434B0350), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x840, 0x034C0359), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x83c, 0x434B0350), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x840, 0x03650348), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x848, 0x4436383B), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x848, 0x39393341), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x850, 0x35373933), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x850, 0x48254A36), + + DCD(MX6_MMDC_P0_BASE_ADDR + 0x80c, 0x001F001F), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x810, 0x001F001F), + + DCD(MX6_MMDC_P1_BASE_ADDR + 0x80c, 0x00440044), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x810, 0x00440044), + + DCD(MX6_MMDC_P0_BASE_ADDR + 0x8b8, 0x00000800), + DCD(MX6_MMDC_P1_BASE_ADDR + 0x8b8, 0x00000800), + + DCD(MX6_MMDC_P0_BASE_ADDR + 0x01c, 0x00000000), + DCD(MX6_MMDC_P0_BASE_ADDR + 0x404, 0x00011006), + + DCD(MX6_CCM_BASE_ADDR + 0x068, 0x00c03f3f), + DCD(MX6_CCM_BASE_ADDR + 0x06c, 0x0030fc03), + DCD(MX6_CCM_BASE_ADDR + 0x070, 0x0fffc000), + DCD(MX6_CCM_BASE_ADDR + 0x074, 0x3ff00000), + DCD(MX6_CCM_BASE_ADDR + 0x078, 0x00fff300), + DCD(MX6_CCM_BASE_ADDR + 0x07c, 0x0f0000c3), + DCD(MX6_CCM_BASE_ADDR + 0x080, 0x000003ff), + + /* enable AXI cache for VDOA/VPU/IPU */ + DCD(MX6_IOMUXC_BASE_ADDR + 0x010, 0xf00000cf), + /* set IPU AXI-id0 Qos=0xf(bypass) AXI-id1 Qos=0x7 */ + DCD(MX6_IOMUXC_BASE_ADDR + 0x018, 0x007f007f), + DCD(MX6_IOMUXC_BASE_ADDR + 0x01c, 0x007f007f), +}; + +#define APP_DEST CONFIG_TEXT_BASE + +struct imx_flash_header_v2 __flash_header_section flash_header = { + .header.tag = IVT_HEADER_TAG, + .header.length = cpu_to_be16(32), + .header.version = IVT_VERSION, + .entry = (u32)_stext, + .dcd_ptr = APP_DEST + FLASH_HEADER_OFFSET + offsetof(struct imx_flash_header_v2, dcd), + .boot_data_ptr = APP_DEST + FLASH_HEADER_OFFSET + offsetof(struct imx_flash_header_v2, boot_data), + .self = APP_DEST + FLASH_HEADER_OFFSET, + + .boot_data.start = APP_DEST, + .boot_data.size = barebox_image_size, + + .dcd.header.tag = DCD_HEADER_TAG, + .dcd.header.length = cpu_to_be16(sizeof(struct imx_dcd) + sizeof(dcd_entry)), + .dcd.header.version = DCD_VERSION, + + .dcd.command.tag = DCD_COMMAND_WRITE_TAG, + .dcd.command.length = cpu_to_be16(sizeof(struct imx_dcd_command) + sizeof(dcd_entry)), + .dcd.command.param = DCD_COMMAND_WRITE_PARAM, +}; diff --git a/arch/arm/boards/freescale-mx6-sabresd/lowlevel.c b/arch/arm/boards/freescale-mx6-sabresd/lowlevel.c new file mode 100644 index 0000000000..aec46fd8cc --- /dev/null +++ b/arch/arm/boards/freescale-mx6-sabresd/lowlevel.c @@ -0,0 +1,10 @@ +#include <common.h> +#include <sizes.h> +#include <asm/barebox-arm-head.h> +#include <asm/barebox-arm.h> + +void __naked barebox_arm_reset_vector(void) +{ + arm_cpu_lowlevel_init(); + barebox_arm_entry(0x10000000, SZ_1G, 0); +} diff --git a/arch/arm/boards/friendlyarm-mini2440/Makefile b/arch/arm/boards/friendlyarm-mini2440/Makefile index f56e80382a..da3520cc81 100644 --- a/arch/arm/boards/friendlyarm-mini2440/Makefile +++ b/arch/arm/boards/friendlyarm-mini2440/Makefile @@ -1,3 +1,3 @@ -obj-y += mini2440.o lowlevel_init.o -pbl-y += lowlevel_init.o +obj-y += mini2440.o +lwl-y += lowlevel_init.o diff --git a/arch/arm/boards/friendlyarm-mini6410/Makefile b/arch/arm/boards/friendlyarm-mini6410/Makefile index d5fa853e2d..0710d3929a 100644 --- a/arch/arm/boards/friendlyarm-mini6410/Makefile +++ b/arch/arm/boards/friendlyarm-mini6410/Makefile @@ -1,3 +1,2 @@ obj-y += mini6410.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/friendlyarm-tiny210/Makefile b/arch/arm/boards/friendlyarm-tiny210/Makefile index 20060a53e3..7deb178739 100644 --- a/arch/arm/boards/friendlyarm-tiny210/Makefile +++ b/arch/arm/boards/friendlyarm-tiny210/Makefile @@ -1,2 +1,2 @@ -obj-y += tiny210.o lowlevel.o -pbl-y += lowlevel.o +obj-y += tiny210.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/friendlyarm-tiny6410/Makefile b/arch/arm/boards/friendlyarm-tiny6410/Makefile index eb0e0edc94..bf17eaa2ef 100644 --- a/arch/arm/boards/friendlyarm-tiny6410/Makefile +++ b/arch/arm/boards/friendlyarm-tiny6410/Makefile @@ -1,4 +1,3 @@ obj-y += tiny6410.o -obj-y += lowlevel.o -pbl-y += lowlevel.o -obj-$(CONFIG_MACH_TINY6410_FA) += development-board.o +lwl-y += lowlevel.o +lwl-$(CONFIG_MACH_TINY6410_FA) += development-board.o diff --git a/arch/arm/boards/guf-cupid/Makefile b/arch/arm/boards/guf-cupid/Makefile index e2e53c0ada..b33952c2b7 100644 --- a/arch/arm/boards/guf-cupid/Makefile +++ b/arch/arm/boards/guf-cupid/Makefile @@ -16,6 +16,5 @@ # # -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o obj-y += board.o diff --git a/arch/arm/boards/guf-neso/Makefile b/arch/arm/boards/guf-neso/Makefile index 89f0aba1af..81263ccab0 100644 --- a/arch/arm/boards/guf-neso/Makefile +++ b/arch/arm/boards/guf-neso/Makefile @@ -1,4 +1,3 @@ -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o obj-y += board.o obj-y += pll_init.o diff --git a/arch/arm/boards/guf-vincell/Makefile b/arch/arm/boards/guf-vincell/Makefile index 8f4f9787d2..aa30b7f2e7 100644 --- a/arch/arm/boards/guf-vincell/Makefile +++ b/arch/arm/boards/guf-vincell/Makefile @@ -1,3 +1,2 @@ obj-y += board.o -obj-y += flash_header.o lowlevel.o -pbl-y += flash_header.o lowlevel.o +lwl-y += flash_header.o lowlevel.o diff --git a/arch/arm/boards/highbank/Makefile b/arch/arm/boards/highbank/Makefile new file mode 100644 index 0000000000..98921a48b4 --- /dev/null +++ b/arch/arm/boards/highbank/Makefile @@ -0,0 +1,4 @@ +obj-y += init.o + +obj-y += lowlevel.o +pbl-y += lowlevel.o diff --git a/arch/arm/boards/highbank/config.h b/arch/arm/boards/highbank/config.h new file mode 100644 index 0000000000..25bb18f787 --- /dev/null +++ b/arch/arm/boards/highbank/config.h @@ -0,0 +1,5 @@ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/highbank/env/bin/init_board b/arch/arm/boards/highbank/env/bin/init_board new file mode 100644 index 0000000000..610db1500e --- /dev/null +++ b/arch/arm/boards/highbank/env/bin/init_board @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -e /dev/dtb ] +then + oftree -l /dev/dtb + oftree -p +fi diff --git a/arch/arm/boards/highbank/env/config b/arch/arm/boards/highbank/env/config new file mode 100644 index 0000000000..1bb2c493b2 --- /dev/null +++ b/arch/arm/boards/highbank/env/config @@ -0,0 +1,33 @@ +#!/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/init.c b/arch/arm/boards/highbank/init.c new file mode 100644 index 0000000000..e36674f0eb --- /dev/null +++ b/arch/arm/boards/highbank/init.c @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com> + * + * GPLv2 only + */ + +#include <common.h> +#include <init.h> +#include <asm/armlinux.h> +#include <asm/system_info.h> +#include <generated/mach-types.h> +#include <mach/devices.h> +#include <mach/hardware.h> +#include <mach/sysregs.h> +#include <environment.h> +#include <partition.h> +#include <sizes.h> +#include <io.h> +#include <libfdt.h> + +#define FIRMWARE_DTB_BASE 0x1000 + +#define HB_OPP_VERSION 0 + +struct fdt_header *fdt = NULL; + +static int hb_fixup(struct fdt_header *fdt) +{ + u32 reg = readl(sregs_base + HB_SREG_A9_PWRDOM_DATA); + u32 *opp_table = (u32 *)HB_SYSRAM_OPP_TABLE_BASE; + u32 dtb_table[2*10]; + u32 i; + u32 num_opps; + __be32 latency; + + if (!(reg & HB_PWRDOM_STAT_SATA)) + do_fixup_by_compatible_string(fdt, "calxeda,hb-ahci", "status", + "disabled", 1); + + if (!(reg & HB_PWRDOM_STAT_EMMC)) + do_fixup_by_compatible_string(fdt, "calxeda,hb-sdhci", "status", + "disabled", 1); + + if ((opp_table[0] >> 16) != HB_OPP_VERSION) + return 0; + + num_opps = opp_table[0] & 0xff; + + for (i = 0; i < num_opps; i++) { + dtb_table[2 * i] = cpu_to_be32(opp_table[3 + 3 * i]); + dtb_table[2 * i + 1] = cpu_to_be32(opp_table[2 + 3 * i]); + } + + latency = cpu_to_be32(opp_table[1]); + + fdt_find_and_setprop(fdt, "/cpus/cpu@0", "transition-latency", + &latency, 4, 1); + fdt_find_and_setprop(fdt, "/cpus/cpu@0", "operating-points", + dtb_table, 8 * num_opps, 1); + + return 0; +} + +static int highbank_mem_init(void) +{ + struct device_node *np; + int ret; + + /* load by the firmware at 0x1000 */ + fdt = IOMEM(FIRMWARE_DTB_BASE); + + ret = of_unflatten_dtb(fdt); + if (ret) { + pr_warn("no dtb found at 0x1000 use default configuration\n"); + fdt = NULL; + goto not_found; + } + + np = of_find_node_by_path("/memory"); + if (!np) { + pr_warn("no memory node use default configuration\n"); + goto not_found; + } + + ret = of_add_memory(np, true); + if (ret) { + pr_warn("memory node: probe failed use default configuration\n"); + goto not_found; + } + + pr_info("highbank: dtb probed memory size\n"); + + return 0; +not_found: + highbank_add_ddram(4089 << 20); + return 0; +} +mem_initcall(highbank_mem_init); + +static int highbank_devices_init(void) +{ + of_register_fixup(hb_fixup); + if (!fdt) { + highbank_register_gpio(0); + highbank_register_gpio(1); + highbank_register_gpio(2); + highbank_register_gpio(3); + highbank_register_ahci(); + highbank_register_xgmac(0); + highbank_register_xgmac(1); + } else { + fdt = of_get_fixed_tree(fdt); + add_mem_device("dtb", (unsigned long)fdt, fdt_totalsize(fdt), + IORESOURCE_MEM_WRITEABLE); + devfs_add_partition("ram0", FIRMWARE_DTB_BASE, SZ_64K, DEVFS_PARTITION_FIXED, "firmware-dtb"); + } + + armlinux_set_bootparams((void *)(0x00000100)); + + devfs_add_partition("nvram", 0x00000, SZ_16K, DEVFS_PARTITION_FIXED, "env0"); + + return 0; +} +device_initcall(highbank_devices_init); + +static int highbank_console_init(void) +{ + highbank_register_uart(); + + return 0; +} +console_initcall(highbank_console_init); diff --git a/arch/arm/boards/highbank/lowlevel.c b/arch/arm/boards/highbank/lowlevel.c new file mode 100644 index 0000000000..b862a1f857 --- /dev/null +++ b/arch/arm/boards/highbank/lowlevel.c @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com> + * + * GPLv2 only + */ + +#include <common.h> +#include <sizes.h> +#include <asm/barebox-arm-head.h> +#include <asm/barebox-arm.h> +#include <asm/system_info.h> + +void __naked barebox_arm_reset_vector(void) +{ + arm_cpu_lowlevel_init(); + barebox_arm_entry(0x00000000, SZ_512M, 0); +} diff --git a/arch/arm/boards/imx21ads/Makefile b/arch/arm/boards/imx21ads/Makefile index e18f7d9c3c..a43425b9ea 100644 --- a/arch/arm/boards/imx21ads/Makefile +++ b/arch/arm/boards/imx21ads/Makefile @@ -1,3 +1,2 @@ -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o +lwl-y += lowlevel_init.o obj-y += imx21ads.o diff --git a/arch/arm/boards/imx233-olinuxino/Makefile b/arch/arm/boards/imx233-olinuxino/Makefile index b8d92234ce..644f7e5802 100644 --- a/arch/arm/boards/imx233-olinuxino/Makefile +++ b/arch/arm/boards/imx233-olinuxino/Makefile @@ -1,3 +1,2 @@ obj-y = imx23-olinuxino.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c b/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c index 04826388d4..9620e85f9a 100644 --- a/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c +++ b/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c @@ -25,6 +25,7 @@ #include <init.h> #include <gpio.h> #include <environment.h> +#include <envfs.h> #include <errno.h> #include <mci.h> #include <asm/armlinux.h> @@ -111,46 +112,6 @@ static void olinuxino_init_usb(void) add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_USB_BASE, NULL); } -/** - * Try to register an environment storage on the attached MCI card - * @return 0 on success - * - * We rely on the existence of a usable SD card, already attached to - * our system, to get something like a persistent memory for our environment. - * If this SD card is also the boot media, we can use the second partition - * for our environment purpose (if present!). - */ -static int register_persistant_environment(void) -{ - struct cdev *cdev; - - /* - * The imx23-olinuxino only has one MCI card socket. - * So, we expect its name as "disk0". - */ - cdev = cdev_by_name("disk0"); - if (cdev == NULL) { - pr_err("No MCI card preset\n"); - return -ENODEV; - } - - - - /* MCI card is present, also a useable partition on it? */ - cdev = cdev_by_name("disk0.1"); - if (cdev == NULL) { - pr_err("No second partition available\n"); - pr_info("Please create at least a second partition with" - " 256 kiB...512 kiB in size (your choice)\n"); - return -ENODEV; - } - - /* use the full partition as our persistent environment storage */ - return devfs_add_partition("disk0.1", 0, cdev->size, - DEVFS_PARTITION_FIXED, "env0"); -} - - static int imx23_olinuxino_devices_init(void) { int i, rc; @@ -174,9 +135,9 @@ static int imx23_olinuxino_devices_init(void) olinuxino_init_usb(); - rc = register_persistant_environment(); + rc = envfs_register_partition("disk0", 1); if (rc != 0) - printf("Cannot create the 'env0' persistant " + printf("Cannot create the 'env0' persistent " "environment storage (%d)\n", rc); return 0; diff --git a/arch/arm/boards/imx27ads/Makefile b/arch/arm/boards/imx27ads/Makefile index 88d1baf619..398db9b6b9 100644 --- a/arch/arm/boards/imx27ads/Makefile +++ b/arch/arm/boards/imx27ads/Makefile @@ -1,4 +1,3 @@ -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o +lwl-y += lowlevel_init.o obj-y += imx27ads.o diff --git a/arch/arm/boards/karo-tx25/Makefile b/arch/arm/boards/karo-tx25/Makefile index 62a546e699..58453b66cd 100644 --- a/arch/arm/boards/karo-tx25/Makefile +++ b/arch/arm/boards/karo-tx25/Makefile @@ -16,6 +16,5 @@ # # -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o obj-y += board.o diff --git a/arch/arm/boards/karo-tx28/Makefile b/arch/arm/boards/karo-tx28/Makefile index c90bf360ea..c7d7398cf3 100644 --- a/arch/arm/boards/karo-tx28/Makefile +++ b/arch/arm/boards/karo-tx28/Makefile @@ -1,4 +1,3 @@ obj-y += tx28.o obj-$(CONFIG_MACH_TX28STK5) += tx28-stk5.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/karo-tx51/Makefile b/arch/arm/boards/karo-tx51/Makefile index 00f2b0521e..988abea5ad 100644 --- a/arch/arm/boards/karo-tx51/Makefile +++ b/arch/arm/boards/karo-tx51/Makefile @@ -1,5 +1,3 @@ obj-y += tx51.o -obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o -pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/karo-tx53/Makefile b/arch/arm/boards/karo-tx53/Makefile index 2f45976184..d44f697718 100644 --- a/arch/arm/boards/karo-tx53/Makefile +++ b/arch/arm/boards/karo-tx53/Makefile @@ -1,5 +1,3 @@ obj-y += board.o -obj-y += flash_header.o -pbl-y += flash_header.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += flash_header.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/karo-tx53/env/init/config-board b/arch/arm/boards/karo-tx53/env/config-board index 3ebfac6c9b..3ebfac6c9b 100644 --- a/arch/arm/boards/karo-tx53/env/init/config-board +++ b/arch/arm/boards/karo-tx53/env/config-board diff --git a/arch/arm/boards/mioa701/Makefile b/arch/arm/boards/mioa701/Makefile index 88c223aa6f..01c7a259e9 100644 --- a/arch/arm/boards/mioa701/Makefile +++ b/arch/arm/boards/mioa701/Makefile @@ -1,3 +1,2 @@ obj-y += board.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/mmccpu/Makefile b/arch/arm/boards/mmccpu/Makefile index 1702783170..1398c26a0f 100644 --- a/arch/arm/boards/mmccpu/Makefile +++ b/arch/arm/boards/mmccpu/Makefile @@ -1,5 +1,3 @@ obj-y += init.o -obj-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o - -pbl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o +lwl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o diff --git a/arch/arm/boards/netx/Makefile b/arch/arm/boards/netx/Makefile index ad694cd272..90979ace8f 100644 --- a/arch/arm/boards/netx/Makefile +++ b/arch/arm/boards/netx/Makefile @@ -1,2 +1,2 @@ -obj-y += netx.o platform.o -pbl-y += platform.o +obj-y += netx.o +lwl-y += platform.o diff --git a/arch/arm/boards/nhk8815/Makefile b/arch/arm/boards/nhk8815/Makefile index dbb2a713f0..f4298529a0 100644 --- a/arch/arm/boards/nhk8815/Makefile +++ b/arch/arm/boards/nhk8815/Makefile @@ -1,3 +1,2 @@ obj-y += setup.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/omap343xdsp/Makefile b/arch/arm/boards/omap343xdsp/Makefile index 88c223aa6f..01c7a259e9 100644 --- a/arch/arm/boards/omap343xdsp/Makefile +++ b/arch/arm/boards/omap343xdsp/Makefile @@ -1,3 +1,2 @@ obj-y += board.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/omap3evm/Makefile b/arch/arm/boards/omap3evm/Makefile index 88c223aa6f..01c7a259e9 100644 --- a/arch/arm/boards/omap3evm/Makefile +++ b/arch/arm/boards/omap3evm/Makefile @@ -1,3 +1,2 @@ obj-y += board.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/panda/Makefile b/arch/arm/boards/panda/Makefile index 53b9d5b88b..5d4eb10b9b 100644 --- a/arch/arm/boards/panda/Makefile +++ b/arch/arm/boards/panda/Makefile @@ -1,3 +1,2 @@ obj-y += board.o -obj-y += lowlevel.o mux.o -pbl-y += lowlevel.o mux.o +lwl-y += lowlevel.o mux.o diff --git a/arch/arm/boards/panda/env/init/config-board b/arch/arm/boards/panda/env/config-board index 27e7339658..27e7339658 100644 --- a/arch/arm/boards/panda/env/init/config-board +++ b/arch/arm/boards/panda/env/config-board diff --git a/arch/arm/boards/pcm027/Makefile b/arch/arm/boards/pcm027/Makefile index 1602c0a572..040cf93944 100644 --- a/arch/arm/boards/pcm027/Makefile +++ b/arch/arm/boards/pcm027/Makefile @@ -1,3 +1,2 @@ obj-y += board.o -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o +lwl-y += lowlevel_init.o diff --git a/arch/arm/boards/pcm037/Makefile b/arch/arm/boards/pcm037/Makefile index 859501ce92..6c9ca6942f 100644 --- a/arch/arm/boards/pcm037/Makefile +++ b/arch/arm/boards/pcm037/Makefile @@ -16,6 +16,5 @@ # # -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o obj-y += pcm037.o diff --git a/arch/arm/boards/pcm037/env/init/config-board b/arch/arm/boards/pcm037/env/config-board index 03f9e97fca..03f9e97fca 100644 --- a/arch/arm/boards/pcm037/env/init/config-board +++ b/arch/arm/boards/pcm037/env/config-board diff --git a/arch/arm/boards/pcm038/Makefile b/arch/arm/boards/pcm038/Makefile index 2c1b74d306..bfb55d398e 100644 --- a/arch/arm/boards/pcm038/Makefile +++ b/arch/arm/boards/pcm038/Makefile @@ -1,3 +1,3 @@ -obj-y += lowlevel.o pcm038.o -pbl-y += lowlevel.o +obj-y += pcm038.o +lwl-y += lowlevel.o obj-$(CONFIG_MACH_PCM970_BASEBOARD) += pcm970.o diff --git a/arch/arm/boards/pcm038/env/init/config-board b/arch/arm/boards/pcm038/env/config-board index 93fd41bcf1..93fd41bcf1 100644 --- a/arch/arm/boards/pcm038/env/init/config-board +++ b/arch/arm/boards/pcm038/env/config-board diff --git a/arch/arm/boards/pcm038/lowlevel.c b/arch/arm/boards/pcm038/lowlevel.c index 85b9391d8e..77b7bf54d1 100644 --- a/arch/arm/boards/pcm038/lowlevel.c +++ b/arch/arm/boards/pcm038/lowlevel.c @@ -98,8 +98,6 @@ void __bare_init __naked barebox_arm_reset_vector(void) arm_setup_stack(MX27_IRAM_BASE_ADDR + MX27_IRAM_SIZE - 8); imx27_barebox_boot_nand_external(); -#else - imx27_barebox_entry(0); #endif out: imx27_barebox_entry(0); diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c index 5e9c0fdecc..587ace8733 100644 --- a/arch/arm/boards/pcm038/pcm038.c +++ b/arch/arm/boards/pcm038/pcm038.c @@ -21,6 +21,7 @@ #include <environment.h> #include <mach/imx27-regs.h> #include <fec.h> +#include <sizes.h> #include <notifier.h> #include <mach/gpio.h> #include <asm/armlinux.h> @@ -186,6 +187,7 @@ static int pcm038_devices_init(void) int i; u64 uid = 0; char *envdev; + long sram_size; unsigned int mode[] = { PD0_AIN_FEC_TXD0, @@ -270,9 +272,11 @@ static int pcm038_devices_init(void) /* configure SRAM on cs1 */ imx27_setup_weimcs(1, 0x0000d843, 0x22252521, 0x22220a00); - /* Can be up to 2MiB */ - add_mem_device("ram1", 0xc8000000, 512 * 1024, - IORESOURCE_MEM_WRITEABLE); + /* SRAM can be up to 2MiB */ + sram_size = get_ram_size((ulong *)MX27_CS1_BASE_ADDR, SZ_2M); + if (sram_size) + add_mem_device("ram1", MX27_CS1_BASE_ADDR, sram_size, + IORESOURCE_MEM_WRITEABLE); /* initizalize gpios */ for (i = 0; i < ARRAY_SIZE(mode); i++) @@ -318,7 +322,7 @@ static int pcm038_devices_init(void) pr_notice("Using environment in %s Flash\n", envdev); - if (imx_iim_read(1, 1, &uid, 6) == 6) + if (imx_iim_read(1, 0, &uid, 6) == 6) armlinux_set_serial(uid); armlinux_set_bootparams((void *)0xa0000100); armlinux_set_architecture(MACH_TYPE_PCM038); diff --git a/arch/arm/boards/pcm038/pcm970.c b/arch/arm/boards/pcm038/pcm970.c index a50a1f2e97..b176d8dd09 100644 --- a/arch/arm/boards/pcm038/pcm970.c +++ b/arch/arm/boards/pcm038/pcm970.c @@ -27,7 +27,6 @@ #define GPIO_IDE_PCOE (GPIO_PORTF + 7) #define GPIO_IDE_RESET (GPIO_PORTF + 10) -#ifdef CONFIG_DISK_INTF_PLATFORM_IDE static struct resource pcm970_ide_resources[] = { { .start = MX27_PCMCIA_MEM_BASE_ADDR, @@ -120,12 +119,11 @@ static void pcm970_ide_init(void) writel(0x0000001f, MX27_PCMCIA_CTL_BASE_ADDR + MX27_PCMCIA_PGSR); /* Make PCMCIA bank0 valid */ - writel(readl(MX27_PCMCIA_POR(0)) | (1 << 29), - MX27_PCMCIA_CTL_BASE_ADDR + MX27_PCMCIA_POR(0)); + i = readl(MX27_PCMCIA_CTL_BASE_ADDR + MX27_PCMCIA_POR(0)); + writel(i | (1 << 29), MX27_PCMCIA_CTL_BASE_ADDR + MX27_PCMCIA_POR(0)); platform_device_register(&pcm970_ide_device); } -#endif static void pcm970_mmc_init(void) { @@ -185,9 +183,8 @@ static int pcm970_init(void) imx27_add_usbh2(&pcm970_usbh2_pdata); } -#ifdef CONFIG_DISK_INTF_PLATFORM_IDE - pcm970_ide_init(); -#endif + if (IS_ENABLED(CONFIG_DISK_INTF_PLATFORM_IDE)) + pcm970_ide_init(); if (IS_ENABLED(CONFIG_MCI_IMX)) pcm970_mmc_init(); diff --git a/arch/arm/boards/pcm043/Makefile b/arch/arm/boards/pcm043/Makefile index 08d9a3606f..72275ead78 100644 --- a/arch/arm/boards/pcm043/Makefile +++ b/arch/arm/boards/pcm043/Makefile @@ -16,6 +16,5 @@ # # -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o obj-y += pcm043.o diff --git a/arch/arm/boards/pcm043/env/boot/nand-ubi b/arch/arm/boards/pcm043/env/boot/nand-ubi new file mode 100644 index 0000000000..67b0cb4afe --- /dev/null +++ b/arch/arm/boards/pcm043/env/boot/nand-ubi @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "nand (UBI)" + exit +fi + +global.bootm.image="/dev/nand0.kernel.bb" +#global.bootm.oftree="/env/oftree" +global.linux.bootargs.dyn.root="root=ubi0:root ubi.mtd=nand0.root rootfstype=ubifs" diff --git a/arch/arm/boards/pcm043/env/config b/arch/arm/boards/pcm043/env/config deleted file mode 100644 index 491305352e..0000000000 --- a/arch/arm/boards/pcm043/env/config +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -global.hostname=pcm043 -eth0.serverip= -user= - -# use 'dhcp' to do dhcp in barebox and in kernel -# use 'none' if you want to skip kernel ip autoconfiguration -ip=dhcp - -# 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', 'nor' or 'nand' -kernel_loc=tftp -# can be either 'net', 'nor', 'nand' or 'initrd' -rootfs_loc=net - -# can be either 'jffs2' or 'ubifs' -rootfs_type=ubifs -rootfsimage=root-${global.hostname}.$rootfs_type - -kernelimage=zImage-${global.hostname} -#kernelimage=uImage-${global.hostname} -#kernelimage=Image-${global.hostname} -#kernelimage=Image-${global.hostname}.lzo - -if [ -n $user ]; then - kernelimage="$user"-"$kernelimage" - nfsroot="$eth0.serverip:/home/$user/nfsroot/${global.hostname}" - rootfsimage="$user"-"$rootfsimage" -else - nfsroot="$eth0.serverip:/path/to/nfs/root" -fi - -autoboot_timeout=3 - -bootargs="console=ttymxc0,115200" - -bootargs="$bootargs video=mx3fb:CTP-CLAA070LC0ACW" - -nor_parts="256k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)" -rootfs_mtdblock_nor=3 - -nand_parts="256k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)" -rootfs_mtdblock_nand=7 - -# set a fancy prompt (if support is compiled in) -PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m " - diff --git a/arch/arm/boards/pcm043/env/config-board b/arch/arm/boards/pcm043/env/config-board new file mode 100644 index 0000000000..545fdffe14 --- /dev/null +++ b/arch/arm/boards/pcm043/env/config-board @@ -0,0 +1,7 @@ +#!/bin/sh + +# board defaults, do not change in running system. Change /env/config +# instead + +global.hostname=pcm043 +global.linux.bootargs.base="console=ttymxc0,115200" diff --git a/arch/arm/boards/pcm043/env/init/mtdparts-nand b/arch/arm/boards/pcm043/env/init/mtdparts-nand new file mode 100644 index 0000000000..8a41f62810 --- /dev/null +++ b/arch/arm/boards/pcm043/env/init/mtdparts-nand @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + init-menu-add-entry "$0" "NAND partitions" + exit +fi + +mtdparts="512k(nand0.barebox),256k(nand0.bareboxenv),4M(nand0.kernel),-(nand0.root)" +kernelname="mxc_nand" + +mtdparts-add -b -d nand0 -k ${kernelname} -p ${mtdparts} diff --git a/arch/arm/boards/pcm043/env/init/mtdparts-nor b/arch/arm/boards/pcm043/env/init/mtdparts-nor new file mode 100644 index 0000000000..f787f28442 --- /dev/null +++ b/arch/arm/boards/pcm043/env/init/mtdparts-nor @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + init-menu-add-entry "$0" "NOR partitions" + exit +fi + +mtdparts="512k(nor0.barebox),128k(nor0.bareboxenv),4M(nor0.kernel),-(nor0.root)" +kernelname="physmap-flash.0" + +mtdparts-add -d nor0 -k ${kernelname} -p ${mtdparts} diff --git a/arch/arm/boards/pcm043/pcm043.c b/arch/arm/boards/pcm043/pcm043.c index 95da8f0b10..04418fbdc6 100644 --- a/arch/arm/boards/pcm043/pcm043.c +++ b/arch/arm/boards/pcm043/pcm043.c @@ -43,6 +43,7 @@ #include <mach/imx-pll.h> #include <mach/iomux-mx35.h> #include <mach/devices-imx35.h> +#include <mach/generic.h> static struct fec_platform_data fec_info = { .xcv_type = MII100, @@ -113,6 +114,7 @@ struct gpio_led led0 = { static int imx35_devices_init(void) { uint32_t reg; + char *envstr; /* CS0: Nor Flash */ imx35_setup_weimcs(5, 0x22C0CF00, 0x75000D01, 0x00000900); @@ -137,23 +139,24 @@ static int imx35_devices_init(void) */ add_cfi_flash_device(DEVICE_ID_DYNAMIC, MX35_CS0_BASE_ADDR, 32 * 1024 * 1024, 0); - if ((reg & 0xc00) == 0x800) { /* reset mode: external boot */ - switch ( (reg >> 25) & 0x3) { - case 0x01: /* NAND is the source */ - devfs_add_partition("nand0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self_raw"); - dev_add_bb_dev("self_raw", "self0"); - devfs_add_partition("nand0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env_raw"); - dev_add_bb_dev("env_raw", "env0"); - break; - - case 0x00: /* NOR is the source */ - devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self0"); /* ourself */ - devfs_add_partition("nor0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0"); /* environment */ - protect_file("/dev/env0", 1); - break; - } + switch (imx_bootsource()) { + case bootsource_nand: + devfs_add_partition("nand0", 0x00000, SZ_512K, DEVFS_PARTITION_FIXED, "self_raw"); + dev_add_bb_dev("self_raw", "self0"); + devfs_add_partition("nand0", SZ_512K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw"); + dev_add_bb_dev("env_raw", "env0"); + envstr = "NAND"; + break; + case bootsource_nor: + default: + devfs_add_partition("nor0", 0x00000, SZ_512K, DEVFS_PARTITION_FIXED, "self0"); /* ourself */ + devfs_add_partition("nor0", SZ_512K, SZ_128K, DEVFS_PARTITION_FIXED, "env0"); /* environment */ + protect_file("/dev/env0", 1); + envstr = "NOR"; + break; } + pr_info("using environment from %s flash\n", envstr); imx35_add_fb(&ipu_fb_data); diff --git a/arch/arm/boards/pcm049/Makefile b/arch/arm/boards/pcm049/Makefile index df3764ca6a..5d4eb10b9b 100644 --- a/arch/arm/boards/pcm049/Makefile +++ b/arch/arm/boards/pcm049/Makefile @@ -1,2 +1,2 @@ -obj-y += board.o mux.o lowlevel.o -pbl-y += lowlevel.o mux.o +obj-y += board.o +lwl-y += lowlevel.o mux.o diff --git a/arch/arm/boards/pcm051/Makefile b/arch/arm/boards/pcm051/Makefile index 8a571d9098..092c31d6b2 100644 --- a/arch/arm/boards/pcm051/Makefile +++ b/arch/arm/boards/pcm051/Makefile @@ -1,3 +1,2 @@ -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o obj-y += board.o diff --git a/arch/arm/boards/phycard-a-l1/Makefile b/arch/arm/boards/phycard-a-l1/Makefile index 5565c3d060..a71feec396 100644 --- a/arch/arm/boards/phycard-a-l1/Makefile +++ b/arch/arm/boards/phycard-a-l1/Makefile @@ -15,5 +15,4 @@ # obj-y += pca-a-l1.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/phycard-a-l1/lowlevel.c b/arch/arm/boards/phycard-a-l1/lowlevel.c index d00efcc3c0..30379d80fb 100644 --- a/arch/arm/boards/phycard-a-l1/lowlevel.c +++ b/arch/arm/boards/phycard-a-l1/lowlevel.c @@ -1,3 +1,4 @@ +#include <common.h> #include <io.h> #include <init.h> #include <sizes.h> diff --git a/arch/arm/boards/phycard-a-xl2/Makefile b/arch/arm/boards/phycard-a-xl2/Makefile index ae02089394..64782e0fc2 100644 --- a/arch/arm/boards/phycard-a-xl2/Makefile +++ b/arch/arm/boards/phycard-a-xl2/Makefile @@ -13,5 +13,5 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # -obj-y += pca-a-xl2.o mux.o lowlevel.o -pbl-y += mux.o lowlevel.o +obj-y += pca-a-xl2.o +lwl-y += mux.o lowlevel.o diff --git a/arch/arm/boards/phycard-i.MX27/Makefile b/arch/arm/boards/phycard-i.MX27/Makefile index 60253e55b9..bbff2893ff 100644 --- a/arch/arm/boards/phycard-i.MX27/Makefile +++ b/arch/arm/boards/phycard-i.MX27/Makefile @@ -1,4 +1,3 @@ -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o +lwl-y += lowlevel_init.o obj-y += pca100.o diff --git a/arch/arm/boards/pm9261/Makefile b/arch/arm/boards/pm9261/Makefile index 1702783170..1398c26a0f 100644 --- a/arch/arm/boards/pm9261/Makefile +++ b/arch/arm/boards/pm9261/Makefile @@ -1,5 +1,3 @@ obj-y += init.o -obj-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o - -pbl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o +lwl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o diff --git a/arch/arm/boards/pm9263/Makefile b/arch/arm/boards/pm9263/Makefile index 1702783170..1398c26a0f 100644 --- a/arch/arm/boards/pm9263/Makefile +++ b/arch/arm/boards/pm9263/Makefile @@ -1,5 +1,3 @@ obj-y += init.o -obj-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o - -pbl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o +lwl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o diff --git a/arch/arm/boards/pm9g45/init.c b/arch/arm/boards/pm9g45/init.c index 720099b125..69c66d5aaa 100644 --- a/arch/arm/boards/pm9g45/init.c +++ b/arch/arm/boards/pm9g45/init.c @@ -83,8 +83,8 @@ static void pm_add_device_nand(void) #if defined(CONFIG_MCI_ATMEL) static struct atmel_mci_platform_data __initdata mci_data = { .bus_width = 4, - .wp_pin = 0, .detect_pin = AT91_PIN_PD6, + .wp_pin = -EINVAL, }; static void pm9g45_add_device_mci(void) diff --git a/arch/arm/boards/qil-a9260/init.c b/arch/arm/boards/qil-a9260/init.c index 2e131fee8e..e96204aa78 100644 --- a/arch/arm/boards/qil-a9260/init.c +++ b/arch/arm/boards/qil-a9260/init.c @@ -66,6 +66,8 @@ static void qil_a9260_add_device_nand(void) #if defined(CONFIG_MCI_ATMEL) static struct atmel_mci_platform_data __initdata qil_a9260_mci_data = { .bus_width = 4, + .detect_pin = -EINVAL, + .wp_pin = -EINVAL, }; static void qil_a9260_add_device_mci(void) diff --git a/arch/arm/boards/raspberry-pi/Makefile b/arch/arm/boards/raspberry-pi/Makefile index 825b30b3cb..978383aeaa 100644 --- a/arch/arm/boards/raspberry-pi/Makefile +++ b/arch/arm/boards/raspberry-pi/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_MACH_RPI) += rpi.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/scb9328/Makefile b/arch/arm/boards/scb9328/Makefile index 69d3970223..002f218391 100644 --- a/arch/arm/boards/scb9328/Makefile +++ b/arch/arm/boards/scb9328/Makefile @@ -1,4 +1,3 @@ -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o +lwl-y += lowlevel_init.o obj-y += scb9328.o diff --git a/arch/arm/boards/telit-evk-pro3/env/init/config-board b/arch/arm/boards/telit-evk-pro3/env/config-board index 741b90213f..741b90213f 100644 --- a/arch/arm/boards/telit-evk-pro3/env/init/config-board +++ b/arch/arm/boards/telit-evk-pro3/env/config-board diff --git a/arch/arm/boards/tny-a926x/Makefile b/arch/arm/boards/tny-a926x/Makefile index caa71639fe..45b10ec63f 100644 --- a/arch/arm/boards/tny-a926x/Makefile +++ b/arch/arm/boards/tny-a926x/Makefile @@ -5,6 +5,4 @@ obj-$(CONFIG_AT91_BOOTSTRAP) += $(bootstrap-y) lowlevel_init-$(CONFIG_MACH_TNY_A9263) = tny_a9263_lowlevel_init.o -obj-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += $(lowlevel_init-y) - -pbl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += $(lowlevel_init-y) +lwl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += $(lowlevel_init-y) diff --git a/arch/arm/boards/toshiba-ac100/Makefile b/arch/arm/boards/toshiba-ac100/Makefile index 5b74351178..4d321e1622 100644 --- a/arch/arm/boards/toshiba-ac100/Makefile +++ b/arch/arm/boards/toshiba-ac100/Makefile @@ -1,4 +1,3 @@ obj-y += board.o obj-$(CONFIG_DRIVER_SERIAL_NS16550) += serial.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/tqma53/Makefile b/arch/arm/boards/tqma53/Makefile index 2f45976184..d44f697718 100644 --- a/arch/arm/boards/tqma53/Makefile +++ b/arch/arm/boards/tqma53/Makefile @@ -1,5 +1,3 @@ obj-y += board.o -obj-y += flash_header.o -pbl-y += flash_header.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += flash_header.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/tqma53/env/init/config-board b/arch/arm/boards/tqma53/env/config-board index 4776438315..4776438315 100644 --- a/arch/arm/boards/tqma53/env/init/config-board +++ b/arch/arm/boards/tqma53/env/config-board diff --git a/arch/arm/boards/usb-a926x/Makefile b/arch/arm/boards/usb-a926x/Makefile index 88f163f5fb..f1370a4df0 100644 --- a/arch/arm/boards/usb-a926x/Makefile +++ b/arch/arm/boards/usb-a926x/Makefile @@ -5,6 +5,4 @@ obj-$(CONFIG_AT91_BOOTSTRAP) += $(bootstrap-y) lowlevel_init-$(CONFIG_MACH_USB_A9263) = usb_a9263_lowlevel_init.o -obj-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += $(lowlevel_init-y) - -pbl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += $(lowlevel_init-y) +lwl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += $(lowlevel_init-y) diff --git a/arch/arm/boards/usb-a926x/init.c b/arch/arm/boards/usb-a926x/init.c index 2e3bbfa400..7ae9020300 100644 --- a/arch/arm/boards/usb-a926x/init.c +++ b/arch/arm/boards/usb-a926x/init.c @@ -213,6 +213,8 @@ static void usb_a9260_add_spi(void) {} #if defined(CONFIG_MCI_ATMEL) static struct atmel_mci_platform_data __initdata usb_a9260_mci_data = { .bus_width = 4, + .detect_pin = -EINVAL, + .wp_pin = -EINVAL, }; static void usb_a9260_add_device_mci(void) diff --git a/arch/arm/boards/versatile/Makefile b/arch/arm/boards/versatile/Makefile index 9dc6869a4c..89232a7884 100644 --- a/arch/arm/boards/versatile/Makefile +++ b/arch/arm/boards/versatile/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_MACH_VERSATILEPB) += versatilepb.o -obj-y += lowlevel.o -pbl-y += lowlevel.o +lwl-y += lowlevel.o diff --git a/arch/arm/configs/archosg9_defconfig b/arch/arm/configs/archosg9_defconfig index 9a051dac81..452d2ec475 100644 --- a/arch/arm/configs/archosg9_defconfig +++ b/arch/arm/configs/archosg9_defconfig @@ -59,8 +59,8 @@ CONFIG_BAUDRATE=115200 # CONFIG_SPI is not set CONFIG_I2C=y CONFIG_I2C_OMAP=y -CONFIG_I2C_TWLCORE=y -CONFIG_I2C_TWL6030=y +CONFIG_MFD_TWLCORE=y +CONFIG_MFD_TWL6030=y CONFIG_MCI=y CONFIG_MCI_STARTUP=y CONFIG_MCI_OMAP_HSMMC=y diff --git a/arch/arm/configs/at91sam9n12ek_defconfig b/arch/arm/configs/at91sam9n12ek_defconfig index 3e3bd51098..55cf5bc48e 100644 --- a/arch/arm/configs/at91sam9n12ek_defconfig +++ b/arch/arm/configs/at91sam9n12ek_defconfig @@ -1,5 +1,4 @@ CONFIG_ARCH_AT91SAM9N12=y -CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x40000 CONFIG_AEABI=y # CONFIG_CMD_ARM_CPUINFO is not set CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y diff --git a/arch/arm/configs/cfa10036_defconfig b/arch/arm/configs/cfa10036_defconfig index c55d50dcd2..277a3ec9e4 100644 --- a/arch/arm/configs/cfa10036_defconfig +++ b/arch/arm/configs/cfa10036_defconfig @@ -39,5 +39,6 @@ CONFIG_I2C=y CONFIG_MCI=y CONFIG_MCI_STARTUP=y CONFIG_MCI_MXS=y +CONFIG_FS_EXT4=y CONFIG_FS_FAT=y CONFIG_FS_FAT_LFN=y diff --git a/arch/arm/configs/clps711x_defconfig b/arch/arm/configs/clps711x_defconfig index cf2b3b6825..3c81776b45 100644 --- a/arch/arm/configs/clps711x_defconfig +++ b/arch/arm/configs/clps711x_defconfig @@ -1,13 +1,14 @@ CONFIG_ARCH_CLPS711X=y +CONFIG_CLPS711X_CPU_PLL_MULT=50 CONFIG_AEABI=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y # CONFIG_MEMINFO is not set -CONFIG_TEXT_BASE=0xc0780000 +CONFIG_PBL_IMAGE=y +CONFIG_MMU=y CONFIG_EXPERIMENTAL=y CONFIG_BAUDRATE=57600 CONFIG_CMDLINE_EDITING=y CONFIG_AUTO_COMPLETE=y -CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED_LZO=y CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/clep7212/env" CONFIG_CMD_EDIT=y diff --git a/arch/arm/configs/edb93xx_defconfig b/arch/arm/configs/edb93xx_defconfig index 363e51172b..86b1040266 100644 --- a/arch/arm/configs/edb93xx_defconfig +++ b/arch/arm/configs/edb93xx_defconfig @@ -30,4 +30,5 @@ CONFIG_CMD_TFTP=y CONFIG_FS_TFTP=y CONFIG_DRIVER_NET_EP93XX=y # CONFIG_SPI is not set +CONFIG_MTD=y CONFIG_DRIVER_CFI=y diff --git a/arch/arm/configs/eukrea_cpuimx27_defconfig b/arch/arm/configs/eukrea_cpuimx27_defconfig index 880941d2f1..bbcd454e3e 100644 --- a/arch/arm/configs/eukrea_cpuimx27_defconfig +++ b/arch/arm/configs/eukrea_cpuimx27_defconfig @@ -45,7 +45,8 @@ CONFIG_DRIVER_NET_FEC_IMX=y # CONFIG_SPI is not set CONFIG_I2C=y CONFIG_I2C_IMX=y -CONFIG_I2C_LP3972=y +CONFIG_MFD_LP3972=y +CONFIG_MTD=y CONFIG_DRIVER_CFI=y # CONFIG_DRIVER_CFI_AMD is not set # CONFIG_DRIVER_CFI_BANK_WIDTH_1 is not set diff --git a/arch/arm/configs/freescale-mx6-sabresd_defconfig b/arch/arm/configs/freescale-mx6-sabresd_defconfig new file mode 100644 index 0000000000..a2a7dccd8d --- /dev/null +++ b/arch/arm/configs/freescale-mx6-sabresd_defconfig @@ -0,0 +1,71 @@ +CONFIG_ARCH_IMX=y +CONFIG_ARCH_IMX6=y +CONFIG_MACH_SABRESD=y +CONFIG_IMX_IIM=y +CONFIG_IMX_IIM_FUSE_BLOW=y +CONFIG_THUMB2_BAREBOX=y +CONFIG_CMD_ARM_MMUINFO=y +CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y +CONFIG_ARM_UNWIND=y +CONFIG_MMU=y +CONFIG_MALLOC_SIZE=0x4000000 +CONFIG_MALLOC_TLSF=y +CONFIG_KALLSYMS=y +CONFIG_LONGHELP=y +CONFIG_HUSH_FANCY_PROMPT=y +CONFIG_CMDLINE_EDITING=y +CONFIG_AUTO_COMPLETE=y +CONFIG_MENU=y +CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y +CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/freescale-mx6-sabresd/env" +CONFIG_CMD_EDIT=y +CONFIG_CMD_SLEEP=y +CONFIG_CMD_MSLEEP=y +CONFIG_CMD_SAVEENV=y +CONFIG_CMD_EXPORT=y +CONFIG_CMD_READLINE=y +CONFIG_CMD_MENU=y +CONFIG_CMD_MENU_MANAGEMENT=y +CONFIG_CMD_TIME=y +CONFIG_CMD_DIRNAME=y +CONFIG_CMD_TFTP=y +CONFIG_CMD_ECHO_E=y +CONFIG_CMD_MEMINFO=y +CONFIG_CMD_IOMEM=y +CONFIG_CMD_CRC=y +CONFIG_CMD_CRC_CMP=y +CONFIG_CMD_MD5SUM=y +CONFIG_CMD_FLASH=y +CONFIG_CMD_BOOTM_SHOW_TYPE=y +CONFIG_CMD_BOOTM_VERBOSE=y +CONFIG_CMD_BOOTM_INITRD=y +CONFIG_CMD_BOOTM_OFTREE=y +CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y +CONFIG_CMD_BOOTM_AIMAGE=y +# CONFIG_CMD_BOOTU is not set +CONFIG_CMD_RESET=y +CONFIG_CMD_GO=y +CONFIG_CMD_TIMEOUT=y +CONFIG_CMD_PARTITION=y +CONFIG_CMD_MAGICVAR=y +CONFIG_CMD_MAGICVAR_HELP=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_UNCOMPRESS=y +CONFIG_NET=y +CONFIG_NET_DHCP=y +CONFIG_NET_PING=y +CONFIG_NET_NETCONSOLE=y +CONFIG_NET_RESOLV=y +CONFIG_DRIVER_NET_FEC_IMX=y +CONFIG_DRIVER_SPI_IMX=y +CONFIG_MTD=y +CONFIG_MTD_M25P80=y +CONFIG_MTD_SST25L=y +CONFIG_MCI=y +CONFIG_MCI_STARTUP=y +CONFIG_MCI_IMX_ESDHC=y +CONFIG_FS_TFTP=y +CONFIG_FS_NFS=y +CONFIG_FS_FAT=y +CONFIG_FS_FAT_LFN=y +CONFIG_LZO_DECOMPRESS=y diff --git a/arch/arm/configs/freescale_mx51_babbage_defconfig b/arch/arm/configs/freescale_mx51_babbage_defconfig index 0817cfa957..97963c1dca 100644 --- a/arch/arm/configs/freescale_mx51_babbage_defconfig +++ b/arch/arm/configs/freescale_mx51_babbage_defconfig @@ -55,6 +55,7 @@ CONFIG_NET_PING=y CONFIG_NET_RESOLV=y CONFIG_DRIVER_NET_FEC_IMX=y CONFIG_DRIVER_SPI_IMX=y +CONFIG_MTD=y CONFIG_DRIVER_CFI=y CONFIG_CFI_BUFFER_WRITE=y CONFIG_MCI=y diff --git a/arch/arm/configs/highbank_defconfig b/arch/arm/configs/highbank_defconfig new file mode 100644 index 0000000000..b034ed1ebd --- /dev/null +++ b/arch/arm/configs/highbank_defconfig @@ -0,0 +1,62 @@ +CONFIG_ARCH_HIGHBANK=y +CONFIG_AEABI=y +CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y +CONFIG_PBL_IMAGE=y +CONFIG_MMU=y +CONFIG_MALLOC_SIZE=0xa00000 +CONFIG_MALLOC_TLSF=y +CONFIG_PROMPT="vexpress: " +CONFIG_LONGHELP=y +CONFIG_GLOB=y +CONFIG_HUSH_FANCY_PROMPT=y +CONFIG_CMDLINE_EDITING=y +CONFIG_AUTO_COMPLETE=y +CONFIG_MENU=y +CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y +CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/highbank/env" +CONFIG_CMD_EDIT=y +CONFIG_CMD_SLEEP=y +CONFIG_CMD_SAVEENV=y +CONFIG_CMD_EXPORT=y +CONFIG_CMD_PRINTENV=y +CONFIG_CMD_READLINE=y +CONFIG_CMD_MENU=y +CONFIG_CMD_MENU_MANAGEMENT=y +CONFIG_CMD_PASSWD=y +CONFIG_CMD_TFTP=y +CONFIG_CMD_ECHO_E=y +CONFIG_CMD_LOADB=y +CONFIG_CMD_MEMINFO=y +CONFIG_CMD_BOOTM_SHOW_TYPE=y +CONFIG_CMD_BOOTM_VERBOSE=y +CONFIG_CMD_BOOTM_INITRD=y +CONFIG_CMD_BOOTM_OFTREE=y +CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y +CONFIG_CMD_UIMAGE=y +# CONFIG_CMD_BOOTU is not set +CONFIG_CMD_RESET=y +CONFIG_CMD_POWEROFF=y +CONFIG_CMD_GO=y +CONFIG_CMD_OFTREE=y +CONFIG_CMD_OFTREE_PROBE=y +CONFIG_CMD_MTEST=y +CONFIG_CMD_MTEST_ALTERNATIVE=y +CONFIG_CMD_TIMEOUT=y +CONFIG_CMD_PARTITION=y +CONFIG_CMD_UNCOMPRESS=y +CONFIG_CMD_CLK=y +CONFIG_NET=y +CONFIG_NET_DHCP=y +CONFIG_NET_NFS=y +CONFIG_NET_PING=y +CONFIG_NET_NETCONSOLE=y +CONFIG_NET_RESOLV=y +CONFIG_SERIAL_AMBA_PL011=y +CONFIG_DRIVER_NET_CALXEDA_XGMAC=y +# CONFIG_SPI is not set +CONFIG_DISK=y +CONFIG_DISK_AHCI=y +CONFIG_GPIO_PL061=y +CONFIG_FS_TFTP=y +CONFIG_SHA1=y +CONFIG_SHA256=y diff --git a/arch/arm/configs/imx23evk_defconfig b/arch/arm/configs/imx23evk_defconfig index 2fc6ebe993..1502d22460 100644 --- a/arch/arm/configs/imx23evk_defconfig +++ b/arch/arm/configs/imx23evk_defconfig @@ -5,20 +5,29 @@ CONFIG_BROKEN=y CONFIG_LONGHELP=y CONFIG_CMDLINE_EDITING=y CONFIG_AUTO_COMPLETE=y -CONFIG_PARTITION=y -# CONFIG_DEFAULT_ENVIRONMENT is not set +CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y +CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y +CONFIG_RESET_SOURCE=y CONFIG_DEBUG_INFO=y CONFIG_CMD_EDIT=y CONFIG_CMD_SLEEP=y CONFIG_CMD_SAVEENV=y -CONFIG_CMD_LOADENV=y CONFIG_CMD_EXPORT=y CONFIG_CMD_PRINTENV=y CONFIG_CMD_READLINE=y CONFIG_CMD_ECHO_E=y +CONFIG_CMD_RESET=y CONFIG_CMD_MTEST=y CONFIG_CMD_MTEST_ALTERNATIVE=y -CONFIG_CMD_RESET=y CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y # CONFIG_SPI is not set +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_DFU=y +CONFIG_MCI=y +CONFIG_MCI_STARTUP=y +CONFIG_MCI_MXS=y +CONFIG_FS_EXT4=y +CONFIG_FS_FAT=y +CONFIG_FS_FAT_WRITE=y +CONFIG_FS_FAT_LFN=y diff --git a/arch/arm/configs/mmccpu_defconfig b/arch/arm/configs/mmccpu_defconfig index 334c5e85d1..0e6914fd6c 100644 --- a/arch/arm/configs/mmccpu_defconfig +++ b/arch/arm/configs/mmccpu_defconfig @@ -34,5 +34,6 @@ CONFIG_FS_TFTP=y CONFIG_DRIVER_NET_MACB=y # CONFIG_SPI is not set CONFIG_I2C=y +CONFIG_MTD=y CONFIG_DRIVER_CFI=y CONFIG_CFI_BUFFER_WRITE=y diff --git a/arch/arm/configs/mx21ads_defconfig b/arch/arm/configs/mx21ads_defconfig index 28ad01325c..dbc296279d 100644 --- a/arch/arm/configs/mx21ads_defconfig +++ b/arch/arm/configs/mx21ads_defconfig @@ -35,6 +35,7 @@ CONFIG_CMD_TFTP=y CONFIG_FS_TFTP=y CONFIG_DRIVER_NET_CS8900=y # CONFIG_SPI is not set +CONFIG_MTD=y CONFIG_DRIVER_CFI=y # CONFIG_DRIVER_CFI_INTEL is not set CONFIG_CFI_BUFFER_WRITE=y diff --git a/arch/arm/configs/mx27ads_defconfig b/arch/arm/configs/mx27ads_defconfig index 077e799dd0..b3fdf84fad 100644 --- a/arch/arm/configs/mx27ads_defconfig +++ b/arch/arm/configs/mx27ads_defconfig @@ -33,6 +33,7 @@ CONFIG_NET_PING=y CONFIG_CMD_TFTP=y CONFIG_FS_TFTP=y CONFIG_DRIVER_SPI_IMX=y +CONFIG_MTD=y CONFIG_DRIVER_CFI=y # CONFIG_DRIVER_CFI_INTEL is not set CONFIG_CFI_BUFFER_WRITE=y diff --git a/arch/arm/configs/netx_nxdb500_defconfig b/arch/arm/configs/netx_nxdb500_defconfig index 6d32c56378..8e7a0b3cce 100644 --- a/arch/arm/configs/netx_nxdb500_defconfig +++ b/arch/arm/configs/netx_nxdb500_defconfig @@ -26,5 +26,6 @@ CONFIG_NET_PING=y CONFIG_CMD_TFTP=y CONFIG_FS_TFTP=y CONFIG_DRIVER_NET_NETX=y +CONFIG_MTD=y CONFIG_DRIVER_CFI=y CONFIG_CFI_BUFFER_WRITE=y diff --git a/arch/arm/configs/omap3530_beagle_defconfig b/arch/arm/configs/omap3530_beagle_defconfig index 1807e04d39..e3eee8dfc1 100644 --- a/arch/arm/configs/omap3530_beagle_defconfig +++ b/arch/arm/configs/omap3530_beagle_defconfig @@ -80,7 +80,7 @@ CONFIG_USB_TWL4030=y CONFIG_MCI=y CONFIG_MCI_STARTUP=y CONFIG_MCI_OMAP_HSMMC=y -CONFIG_I2C_TWL4030=y +CONFIG_MFD_TWL4030=y CONFIG_FS_TFTP=y CONFIG_FS_NFS=y CONFIG_FS_FAT=y diff --git a/arch/arm/configs/pcm027_defconfig b/arch/arm/configs/pcm027_defconfig index ac9269d3c7..f911951276 100644 --- a/arch/arm/configs/pcm027_defconfig +++ b/arch/arm/configs/pcm027_defconfig @@ -54,6 +54,7 @@ CONFIG_FS_TFTP=y CONFIG_DRIVER_SERIAL_PXA=y CONFIG_DRIVER_NET_SMC91111=y # CONFIG_SPI is not set +CONFIG_MTD=y CONFIG_DRIVER_CFI=y CONFIG_VIDEO=y CONFIG_DRIVER_VIDEO_PXA=y diff --git a/arch/arm/configs/pcm043_defconfig b/arch/arm/configs/pcm043_defconfig index 7c6219380e..5447777486 100644 --- a/arch/arm/configs/pcm043_defconfig +++ b/arch/arm/configs/pcm043_defconfig @@ -1,9 +1,9 @@ CONFIG_ARCH_IMX=y CONFIG_CACHE_L2X0=y CONFIG_ARCH_IMX_EXTERNAL_BOOT=y +CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND=y CONFIG_ARCH_IMX35=y CONFIG_MACH_PCM043=y -CONFIG_IMX_CLKO=y CONFIG_IMX_IIM=y CONFIG_IMX_IIM_FUSE_BLOW=y CONFIG_AEABI=y @@ -15,24 +15,37 @@ CONFIG_MALLOC_SIZE=0x1000000 CONFIG_MALLOC_TLSF=y CONFIG_KALLSYMS=y CONFIG_LONGHELP=y -CONFIG_GLOB=y CONFIG_HUSH_FANCY_PROMPT=y CONFIG_CMDLINE_EDITING=y CONFIG_AUTO_COMPLETE=y +CONFIG_MENU=y CONFIG_PARTITION=y -CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y +CONFIG_PARTITION_DISK=y +CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/pcm043/env" +CONFIG_RESET_SOURCE=y CONFIG_CMD_EDIT=y CONFIG_CMD_SLEEP=y +CONFIG_CMD_MSLEEP=y CONFIG_CMD_SAVEENV=y -CONFIG_CMD_LOADENV=y CONFIG_CMD_EXPORT=y CONFIG_CMD_PRINTENV=y CONFIG_CMD_READLINE=y +CONFIG_CMD_LET=y +CONFIG_CMD_MENU=y +CONFIG_CMD_MENU_MANAGEMENT=y CONFIG_CMD_TIME=y +CONFIG_CMD_DIRNAME=y +CONFIG_CMD_LN=y +CONFIG_CMD_READLINK=y +CONFIG_CMD_TFTP=y +CONFIG_CMD_FILETYPE=y CONFIG_CMD_ECHO_E=y CONFIG_CMD_MEMINFO=y CONFIG_CMD_IOMEM=y +CONFIG_CMD_CRC=y +CONFIG_CMD_CRC_CMP=y +CONFIG_CMD_MD5SUM=y CONFIG_CMD_FLASH=y CONFIG_CMD_BOOTM_SHOW_TYPE=y CONFIG_CMD_BOOTM_VERBOSE=y @@ -40,22 +53,26 @@ CONFIG_CMD_BOOTM_INITRD=y CONFIG_CMD_BOOTM_OFTREE=y CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y CONFIG_CMD_UIMAGE=y -# CONFIG_CMD_BOOTZ is not set # CONFIG_CMD_BOOTU is not set CONFIG_CMD_RESET=y CONFIG_CMD_GO=y +CONFIG_CMD_OFTREE=y +CONFIG_CMD_OFTREE_PROBE=y +CONFIG_CMD_OF_PROPERTY=y +CONFIG_CMD_OF_NODE=y CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y +CONFIG_CMD_MIITOOL=y +CONFIG_CMD_CLK=y +CONFIG_CMD_WD=y CONFIG_NET=y CONFIG_NET_DHCP=y CONFIG_NET_NFS=y CONFIG_NET_PING=y -CONFIG_CMD_TFTP=y -CONFIG_FS_TFTP=y CONFIG_NET_NETCONSOLE=y CONFIG_DRIVER_NET_FEC_IMX=y # CONFIG_SPI is not set @@ -65,5 +82,8 @@ CONFIG_MTD=y CONFIG_NAND=y CONFIG_NAND_IMX=y CONFIG_UBI=y +CONFIG_WATCHDOG=y +CONFIG_WATCHDOG_IMX=y +CONFIG_FS_TFTP=y CONFIG_ZLIB=y CONFIG_LZO_DECOMPRESS=y diff --git a/arch/arm/configs/pcm049_defconfig b/arch/arm/configs/pcm049_defconfig index 19df95a3c8..80dbd710f6 100644 --- a/arch/arm/configs/pcm049_defconfig +++ b/arch/arm/configs/pcm049_defconfig @@ -64,7 +64,7 @@ CONFIG_USB=y CONFIG_MCI=y CONFIG_MCI_STARTUP=y CONFIG_MCI_OMAP_HSMMC=y -CONFIG_I2C_TWL6030=y +CONFIG_MFD_TWL6030=y CONFIG_FS_TFTP=y CONFIG_FS_FAT=y CONFIG_FS_FAT_WRITE=y diff --git a/arch/arm/configs/pm9263_defconfig b/arch/arm/configs/pm9263_defconfig index e223e773f0..c9a7141f97 100644 --- a/arch/arm/configs/pm9263_defconfig +++ b/arch/arm/configs/pm9263_defconfig @@ -33,6 +33,7 @@ CONFIG_CMD_TFTP=y CONFIG_FS_TFTP=y CONFIG_DRIVER_NET_MACB=y # CONFIG_SPI is not set +CONFIG_MTD=y CONFIG_DRIVER_CFI=y CONFIG_CFI_BUFFER_WRITE=y CONFIG_W1=y diff --git a/arch/arm/configs/scb9328_defconfig b/arch/arm/configs/scb9328_defconfig index 818bbd0d7d..21a2571d4f 100644 --- a/arch/arm/configs/scb9328_defconfig +++ b/arch/arm/configs/scb9328_defconfig @@ -52,6 +52,7 @@ CONFIG_FS_TFTP=y CONFIG_NET_NETCONSOLE=y CONFIG_NET_RESOLV=y CONFIG_DRIVER_NET_DM9K=y +CONFIG_MTD=y CONFIG_DRIVER_CFI=y # CONFIG_DRIVER_CFI_BANK_WIDTH_4 is not set CONFIG_CFI_BUFFER_WRITE=y diff --git a/arch/arm/cpu/cache-l2x0.c b/arch/arm/cpu/cache-l2x0.c index b300e6ffb0..2be562d7de 100644 --- a/arch/arm/cpu/cache-l2x0.c +++ b/arch/arm/cpu/cache-l2x0.c @@ -2,42 +2,12 @@ #include <init.h> #include <io.h> #include <asm/mmu.h> +#include <asm/cache-l2x0.h> #define CACHE_LINE_SIZE 32 static void __iomem *l2x0_base; -#define L2X0_CACHE_ID 0x000 -#define L2X0_CACHE_TYPE 0x004 -#define L2X0_CTRL 0x100 -#define L2X0_AUX_CTRL 0x104 -#define L2X0_TAG_LATENCY_CTRL 0x108 -#define L2X0_DATA_LATENCY_CTRL 0x10C -#define L2X0_EVENT_CNT_CTRL 0x200 -#define L2X0_EVENT_CNT1_CFG 0x204 -#define L2X0_EVENT_CNT0_CFG 0x208 -#define L2X0_EVENT_CNT1_VAL 0x20C -#define L2X0_EVENT_CNT0_VAL 0x210 -#define L2X0_INTR_MASK 0x214 -#define L2X0_MASKED_INTR_STAT 0x218 -#define L2X0_RAW_INTR_STAT 0x21C -#define L2X0_INTR_CLEAR 0x220 -#define L2X0_CACHE_SYNC 0x730 -#define L2X0_INV_LINE_PA 0x770 -#define L2X0_INV_WAY 0x77C -#define L2X0_CLEAN_LINE_PA 0x7B0 -#define L2X0_CLEAN_LINE_IDX 0x7B8 -#define L2X0_CLEAN_WAY 0x7BC -#define L2X0_CLEAN_INV_LINE_PA 0x7F0 -#define L2X0_CLEAN_INV_LINE_IDX 0x7F8 -#define L2X0_CLEAN_INV_WAY 0x7FC -#define L2X0_LOCKDOWN_WAY_D 0x900 -#define L2X0_LOCKDOWN_WAY_I 0x904 -#define L2X0_TEST_OPERATION 0xF00 -#define L2X0_LINE_DATA 0xF10 -#define L2X0_LINE_TAG 0xF30 -#define L2X0_DEBUG_CTRL 0xF40 - static inline void cache_wait(void __iomem *reg, unsigned long mask) { /* wait for the operation to complete */ diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c index 7761f5cd4e..5f697d7916 100644 --- a/arch/arm/cpu/cpu.c +++ b/arch/arm/cpu/cpu.c @@ -34,6 +34,8 @@ #include <asm/cache.h> #include <asm/ptrace.h> +#include "mmu.h" + /** * Enable processor's instruction cache */ @@ -67,6 +69,24 @@ int icache_status(void) return (get_cr () & CR_I) != 0; } +/* + * SoC like the ux500 have the l2x0 always enable + * with or without MMU enable + */ +struct outer_cache_fns outer_cache; + +/* + * Clean and invalide caches, disable MMU + */ +void mmu_disable(void) +{ + if (outer_cache.disable) + outer_cache.disable(); + + __mmu_cache_flush(); + __mmu_cache_off(); +} + /** * Disable MMU and D-cache, flush caches * @return 0 (always) @@ -78,9 +98,7 @@ void arch_shutdown(void) { uint32_t r; -#ifdef CONFIG_MMU mmu_disable(); -#endif flush_icache(); /* * barebox normally does not use interrupts, but some functionalities diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c index 99f12b5ffb..219f50a478 100644 --- a/arch/arm/cpu/mmu.c +++ b/arch/arm/cpu/mmu.c @@ -325,21 +325,6 @@ static int mmu_init(void) } mmu_initcall(mmu_init); -struct outer_cache_fns outer_cache; - -/* - * Clean and invalide caches, disable MMU - */ -void mmu_disable(void) -{ - - if (outer_cache.disable) - outer_cache.disable(); - - __mmu_cache_flush(); - __mmu_cache_off(); -} - void *dma_alloc_coherent(size_t size) { void *ret; diff --git a/arch/arm/cpu/mmu.h b/arch/arm/cpu/mmu.h index 618968bc82..79ebc80d7d 100644 --- a/arch/arm/cpu/mmu.h +++ b/arch/arm/cpu/mmu.h @@ -1,8 +1,14 @@ #ifndef __ARM_MMU_H #define __ARM_MMU_H +#ifdef CONFIG_MMU void __mmu_cache_on(void); void __mmu_cache_off(void); void __mmu_cache_flush(void); +#else +static inline void __mmu_cache_on(void) {} +static inline void __mmu_cache_off(void) {} +static inline void __mmu_cache_flush(void) {} +#endif #endif /* __ARM_MMU_H */ diff --git a/arch/arm/include/asm/cache-l2x0.h b/arch/arm/include/asm/cache-l2x0.h index e2368889df..963dd99f64 100644 --- a/arch/arm/include/asm/cache-l2x0.h +++ b/arch/arm/include/asm/cache-l2x0.h @@ -17,33 +17,85 @@ #ifndef __ASM_ARM_HARDWARE_L2X0_H #define __ASM_ARM_HARDWARE_L2X0_H -#define L2X0_CACHE_ID 0x000 -#define L2X0_CACHE_TYPE 0x004 -#define L2X0_CTRL 0x100 -#define L2X0_AUX_CTRL 0x104 -#define L2X0_EVENT_CNT_CTRL 0x200 -#define L2X0_EVENT_CNT1_CFG 0x204 -#define L2X0_EVENT_CNT0_CFG 0x208 -#define L2X0_EVENT_CNT1_VAL 0x20C -#define L2X0_EVENT_CNT0_VAL 0x210 -#define L2X0_INTR_MASK 0x214 -#define L2X0_MASKED_INTR_STAT 0x218 -#define L2X0_RAW_INTR_STAT 0x21C -#define L2X0_INTR_CLEAR 0x220 -#define L2X0_CACHE_SYNC 0x730 -#define L2X0_INV_LINE_PA 0x770 -#define L2X0_INV_WAY 0x77C -#define L2X0_CLEAN_LINE_PA 0x7B0 -#define L2X0_CLEAN_LINE_IDX 0x7B8 -#define L2X0_CLEAN_WAY 0x7BC -#define L2X0_CLEAN_INV_LINE_PA 0x7F0 -#define L2X0_CLEAN_INV_LINE_IDX 0x7F8 -#define L2X0_CLEAN_INV_WAY 0x7FC -#define L2X0_LOCKDOWN_WAY_D 0x900 -#define L2X0_LOCKDOWN_WAY_I 0x904 -#define L2X0_TEST_OPERATION 0xF00 -#define L2X0_LINE_DATA 0xF10 -#define L2X0_LINE_TAG 0xF30 -#define L2X0_DEBUG_CTRL 0xF40 +#define L2X0_CACHE_ID 0x000 +#define L2X0_CACHE_TYPE 0x004 +#define L2X0_CTRL 0x100 +#define L2X0_AUX_CTRL 0x104 +#define L2X0_TAG_LATENCY_CTRL 0x108 +#define L2X0_DATA_LATENCY_CTRL 0x10C +#define L2X0_EVENT_CNT_CTRL 0x200 +#define L2X0_EVENT_CNT1_CFG 0x204 +#define L2X0_EVENT_CNT0_CFG 0x208 +#define L2X0_EVENT_CNT1_VAL 0x20C +#define L2X0_EVENT_CNT0_VAL 0x210 +#define L2X0_INTR_MASK 0x214 +#define L2X0_MASKED_INTR_STAT 0x218 +#define L2X0_RAW_INTR_STAT 0x21C +#define L2X0_INTR_CLEAR 0x220 +#define L2X0_CACHE_SYNC 0x730 +#define L2X0_DUMMY_REG 0x740 +#define L2X0_INV_LINE_PA 0x770 +#define L2X0_INV_WAY 0x77C +#define L2X0_CLEAN_LINE_PA 0x7B0 +#define L2X0_CLEAN_LINE_IDX 0x7B8 +#define L2X0_CLEAN_WAY 0x7BC +#define L2X0_CLEAN_INV_LINE_PA 0x7F0 +#define L2X0_CLEAN_INV_LINE_IDX 0x7F8 +#define L2X0_CLEAN_INV_WAY 0x7FC +/* + * The lockdown registers repeat 8 times for L310, the L210 has only one + * D and one I lockdown register at 0x0900 and 0x0904. + */ +#define L2X0_LOCKDOWN_WAY_D_BASE 0x900 +#define L2X0_LOCKDOWN_WAY_I_BASE 0x904 +#define L2X0_LOCKDOWN_STRIDE 0x08 +#define L2X0_ADDR_FILTER_START 0xC00 +#define L2X0_ADDR_FILTER_END 0xC04 +#define L2X0_TEST_OPERATION 0xF00 +#define L2X0_LINE_DATA 0xF10 +#define L2X0_LINE_TAG 0xF30 +#define L2X0_DEBUG_CTRL 0xF40 +#define L2X0_PREFETCH_CTRL 0xF60 +#define L2X0_POWER_CTRL 0xF80 +#define L2X0_DYNAMIC_CLK_GATING_EN (1 << 1) +#define L2X0_STNDBY_MODE_EN (1 << 0) + +/* Registers shifts and masks */ +#define L2X0_CACHE_ID_PART_MASK (0xf << 6) +#define L2X0_CACHE_ID_PART_L210 (1 << 6) +#define L2X0_CACHE_ID_PART_L310 (3 << 6) +#define L2X0_CACHE_ID_RTL_MASK 0x3f +#define L2X0_CACHE_ID_RTL_R0P0 0x0 +#define L2X0_CACHE_ID_RTL_R1P0 0x2 +#define L2X0_CACHE_ID_RTL_R2P0 0x4 +#define L2X0_CACHE_ID_RTL_R3P0 0x5 +#define L2X0_CACHE_ID_RTL_R3P1 0x6 +#define L2X0_CACHE_ID_RTL_R3P2 0x8 + +#define L2X0_AUX_CTRL_MASK 0xc0000fff +#define L2X0_AUX_CTRL_DATA_RD_LATENCY_SHIFT 0 +#define L2X0_AUX_CTRL_DATA_RD_LATENCY_MASK 0x7 +#define L2X0_AUX_CTRL_DATA_WR_LATENCY_SHIFT 3 +#define L2X0_AUX_CTRL_DATA_WR_LATENCY_MASK (0x7 << 3) +#define L2X0_AUX_CTRL_TAG_LATENCY_SHIFT 6 +#define L2X0_AUX_CTRL_TAG_LATENCY_MASK (0x7 << 6) +#define L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT 9 +#define L2X0_AUX_CTRL_DIRTY_LATENCY_MASK (0x7 << 9) +#define L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT 16 +#define L2X0_AUX_CTRL_WAY_SIZE_SHIFT 17 +#define L2X0_AUX_CTRL_WAY_SIZE_MASK (0x7 << 17) +#define L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT 22 +#define L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT 26 +#define L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT 27 +#define L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT 28 +#define L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT 29 +#define L2X0_AUX_CTRL_EARLY_BRESP_SHIFT 30 + +#define L2X0_LATENCY_CTRL_SETUP_SHIFT 0 +#define L2X0_LATENCY_CTRL_RD_SHIFT 4 +#define L2X0_LATENCY_CTRL_WR_SHIFT 8 + +#define L2X0_ADDR_FILTER_EN 1 + #endif diff --git a/arch/arm/lib/armlinux.c b/arch/arm/lib/armlinux.c index 40a63ea7e1..4dd84ed79c 100644 --- a/arch/arm/lib/armlinux.c +++ b/arch/arm/lib/armlinux.c @@ -266,6 +266,8 @@ void start_linux(void *adr, int swap, unsigned long initrd_address, if (oftree) { printf("booting Linux kernel with devicetree\n"); + fdt_initrd(oftree, initrd_address, + initrd_address + initrd_size, 1); params = oftree; } else { setup_tags(initrd_address, initrd_size, swap); diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S index b4e5ddd76f..5e35d7f5f6 100644 --- a/arch/arm/lib/memset.S +++ b/arch/arm/lib/memset.S @@ -19,9 +19,9 @@ 1: subs r2, r2, #4 @ 1 do we have enough blt 5f @ 1 bytes to align with? cmp r3, #2 @ 1 - strltb r1, [r0], #1 @ 1 - strleb r1, [r0], #1 @ 1 - strb r1, [r0], #1 @ 1 + strltb r1, [ip], #1 @ 1 + strleb r1, [ip], #1 @ 1 + strb r1, [ip], #1 @ 1 add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3)) /* * The pointer is now aligned and the length is adjusted. Try doing the @@ -29,10 +29,14 @@ */ ENTRY(memset) - ands r3, r0, #3 @ 1 unaligned? +/* + * Preserve the contents of r0 for the return value. + */ + mov ip, r0 + ands r3, ip, #3 @ 1 unaligned? bne 1b @ 1 /* - * we know that the pointer in r0 is aligned to a word boundary. + * we know that the pointer in ip is aligned to a word boundary. */ orr r1, r1, r1, lsl #8 orr r1, r1, r1, lsl #16 @@ -43,29 +47,28 @@ ENTRY(memset) #if ! CALGN(1)+0 /* - * We need an extra register for this loop - save the return address and - * use the LR + * We need an 2 extra registers for this loop - use r8 and the LR */ - str lr, [sp, #-4]! - mov ip, r1 + stmfd sp!, {r8, lr} + mov r8, r1 mov lr, r1 2: subs r2, r2, #64 - stmgeia r0!, {r1, r3, ip, lr} @ 64 bytes at a time. - stmgeia r0!, {r1, r3, ip, lr} - stmgeia r0!, {r1, r3, ip, lr} - stmgeia r0!, {r1, r3, ip, lr} + stmgeia ip!, {r1, r3, r8, lr} @ 64 bytes at a time. + stmgeia ip!, {r1, r3, r8, lr} + stmgeia ip!, {r1, r3, r8, lr} + stmgeia ip!, {r1, r3, r8, lr} bgt 2b - ldmeqfd sp!, {pc} @ Now <64 bytes to go. + ldmeqfd sp!, {r8, pc} @ Now <64 bytes to go. /* * No need to correct the count; we're only testing bits from now on */ tst r2, #32 - stmneia r0!, {r1, r3, ip, lr} - stmneia r0!, {r1, r3, ip, lr} + stmneia ip!, {r1, r3, r8, lr} + stmneia ip!, {r1, r3, r8, lr} tst r2, #16 - stmneia r0!, {r1, r3, ip, lr} - ldr lr, [sp], #4 + stmneia ip!, {r1, r3, r8, lr} + ldmfd sp!, {r8, lr} #else @@ -74,55 +77,55 @@ ENTRY(memset) * whole cache lines at once. */ - stmfd sp!, {r4-r7, lr} + stmfd sp!, {r4-r8, lr} mov r4, r1 mov r5, r1 mov r6, r1 mov r7, r1 - mov ip, r1 + mov r8, r1 mov lr, r1 cmp r2, #96 - tstgt r0, #31 + tstgt ip, #31 ble 3f - and ip, r0, #31 - rsb ip, ip, #32 - sub r2, r2, ip - movs ip, ip, lsl #(32 - 4) - stmcsia r0!, {r4, r5, r6, r7} - stmmiia r0!, {r4, r5} - tst ip, #(1 << 30) - mov ip, r1 - strne r1, [r0], #4 + and r8, ip, #31 + rsb r8, r8, #32 + sub r2, r2, r8 + movs r8, r8, lsl #(32 - 4) + stmcsia ip!, {r4, r5, r6, r7} + stmmiia ip!, {r4, r5} + tst r8, #(1 << 30) + mov r8, r1 + strne r1, [ip], #4 3: subs r2, r2, #64 - stmgeia r0!, {r1, r3-r7, ip, lr} - stmgeia r0!, {r1, r3-r7, ip, lr} + stmgeia ip!, {r1, r3-r8, lr} + stmgeia ip!, {r1, r3-r8, lr} bgt 3b - ldmeqfd sp!, {r4-r7, pc} + ldmeqfd sp!, {r4-r8, pc} tst r2, #32 - stmneia r0!, {r1, r3-r7, ip, lr} + stmneia ip!, {r1, r3-r8, lr} tst r2, #16 - stmneia r0!, {r4-r7} - ldmfd sp!, {r4-r7, lr} + stmneia ip!, {r4-r7} + ldmfd sp!, {r4-r8, lr} #endif 4: tst r2, #8 - stmneia r0!, {r1, r3} + stmneia ip!, {r1, r3} tst r2, #4 - strne r1, [r0], #4 + strne r1, [ip], #4 /* * When we get here, we've got less than 4 bytes to zero. We * may have an unaligned pointer as well. */ 5: tst r2, #2 - strneb r1, [r0], #1 - strneb r1, [r0], #1 + strneb r1, [ip], #1 + strneb r1, [ip], #1 tst r2, #1 - strneb r1, [r0], #1 + strneb r1, [ip], #1 mov pc, lr ENDPROC(memset) diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index 53ca570436..f098e0eabb 100644 --- a/arch/arm/mach-at91/Makefile +++ b/arch/arm/mach-at91/Makefile @@ -12,9 +12,7 @@ lowlevel_init-$(CONFIG_SOC_AT91SAM9X5) += at91sam9x5_lowlevel_init.o lowlevel_init-$(CONFIG_SOC_AT91SAM9N12) += at91sam9n12_lowlevel_init.o lowlevel_init-$(CONFIG_ARCH_AT91RM9200) = at91rm9200_lowlevel_init.o lowlevel_init-$(CONFIG_ARCH_SAMA5D3) += sama5d3_lowlevel_init.o -obj-y += $(lowlevel_init-y) - -pbl-y += $(lowlevel_init-y) +lwl-y += $(lowlevel_init-y) obj-$(CONFIG_AT91SAM9_RESET) += at91sam9_reset.o obj-$(CONFIG_AT91SAM9G45_RESET) += at91sam9g45_reset.o diff --git a/arch/arm/mach-clps711x/Kconfig b/arch/arm/mach-clps711x/Kconfig index f0adeda647..d2873b4c0a 100644 --- a/arch/arm/mach-clps711x/Kconfig +++ b/arch/arm/mach-clps711x/Kconfig @@ -10,6 +10,19 @@ config MACH_CLEP7212 endchoice +menu "CLPS711X specific settings" + +config CLPS711X_CPU_PLL_MULT + int "CPU PLL multiplier (20-50)" + range 20 50 + default "40" + help + Define CPU PLL multiplier. PLL is calculated by formula: + PLL Frequency = (PLL Multiplier / 2) * 3686400 Hz + Default value is 40, for achieve 73 MHz. + +endmenu + config BOARDINFO default "Cirrus Logic CLEP7212" if MACH_CLEP7212 diff --git a/arch/arm/mach-clps711x/Makefile b/arch/arm/mach-clps711x/Makefile index 41012bc016..69a4a3c47c 100644 --- a/arch/arm/mach-clps711x/Makefile +++ b/arch/arm/mach-clps711x/Makefile @@ -1 +1,2 @@ -obj-y += clock.o devices.o reset.o +obj-y += clock.o devices.o lowlevel.o reset.o +pbl-y += lowlevel.o diff --git a/arch/arm/mach-clps711x/clock.c b/arch/arm/mach-clps711x/clock.c index 5cafba98e9..09cbaf961c 100644 --- a/arch/arm/mach-clps711x/clock.c +++ b/arch/arm/mach-clps711x/clock.c @@ -15,13 +15,11 @@ #include <mach/clps711x.h> -struct clk { +static struct clk { unsigned long rate; -}; - -static struct clk uart_clk, bus_clk; +} uart_clk, bus_clk; -uint64_t clocksource_read(void) +static uint64_t clocksource_read(void) { return ~readw(TC2D); } diff --git a/arch/arm/mach-clps711x/devices.c b/arch/arm/mach-clps711x/devices.c index 08f27d26be..6c760db944 100644 --- a/arch/arm/mach-clps711x/devices.c +++ b/arch/arm/mach-clps711x/devices.c @@ -9,12 +9,24 @@ #include <common.h> #include <init.h> +#include <sizes.h> #include <asm/io.h> +#include <asm/memory.h> #include <mach/clps711x.h> -inline void _clps711x_setup_memcfg(int bank, u32 addr, u32 val) +static int clps711x_mem_init(void) +{ + ulong memsize = get_ram_size((ulong *)SDRAM0_BASE, SZ_64M); + + arm_add_mem_device("ram0", SDRAM0_BASE, memsize); + + return 0; +} +mem_initcall(clps711x_mem_init); + +inline static void _clps711x_setup_memcfg(int bank, u32 addr, u32 val) { u32 tmp = readl(addr); diff --git a/arch/arm/mach-clps711x/include/mach/clps711x.h b/arch/arm/mach-clps711x/include/mach/clps711x.h index 048992a361..cc65cc85f9 100644 --- a/arch/arm/mach-clps711x/include/mach/clps711x.h +++ b/arch/arm/mach-clps711x/include/mach/clps711x.h @@ -281,4 +281,6 @@ #define MEMCFG_WAITSTATE_2_0 (14 << 2) #define MEMCFG_WAITSTATE_1_0 (15 << 2) +void clps711x_barebox_entry(u32); + #endif diff --git a/arch/arm/mach-clps711x/lowlevel.c b/arch/arm/mach-clps711x/lowlevel.c new file mode 100644 index 0000000000..193f61aa6e --- /dev/null +++ b/arch/arm/mach-clps711x/lowlevel.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012 Alexander Shiyan <shc_work@mail.ru> + * + * 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. + */ + +#include <common.h> +#include <init.h> +#include <sizes.h> + +#include <asm/io.h> +#include <asm/barebox-arm.h> +#include <asm/barebox-arm-head.h> + +#include <mach/clps711x.h> + +void __naked __bare_init clps711x_barebox_entry(u32 pllmult) +{ + u32 cpu, bus; + + /* Setup base clocking, Enable SDQM pins */ + writel(SYSCON3_CLKCTL0 | SYSCON3_CLKCTL1, SYSCON3); + asm("nop"); + + /* Check if we running from external 13 MHz clock */ + if (!(readl(SYSFLG2) & SYSFLG2_CKMODE)) { + /* Check valid multiplier, default to 74 MHz */ + if ((pllmult < 20) || (pllmult > 50)) + pllmult = 40; + + /* Setup PLL */ + writel(pllmult << 24, PLLW); + asm("nop"); + + /* Check for old CPUs without PLL */ + if ((readl(PLLR) >> 24) != pllmult) + cpu = 73728000; + else + cpu = pllmult * 3686400; + + if (cpu >= 36864000) + bus = cpu /2; + else + bus = 36864000 / 2; + } else + bus = 13000000; + + /* CLKEN select, SDRAM width=32 */ + writel(SYSCON2_CLKENSL, SYSCON2); + + /* Setup SDRAM params (64MB, 16Bit*2, CAS=3) */ + writel(SDCONF_CASLAT_3 | SDCONF_SIZE_256 | SDCONF_WIDTH_16 | + SDCONF_CLKCTL | SDCONF_ACTIVE, SDCONF); + + /* Setup Refresh Rate (64ms 8K Blocks) */ + writel((64 * bus) / (8192 * 1000), SDRFPR); + + /* Disable UART, IrDa, LCD */ + writel(0, SYSCON1); + /* Disable PWM */ + writew(0, PMPCON); + /* Disable LED flasher */ + writew(0, LEDFLSH); + + barebox_arm_entry(SDRAM0_BASE, SZ_8M, 0); +} diff --git a/arch/arm/mach-clps711x/reset.c b/arch/arm/mach-clps711x/reset.c index 4a42ef412d..67c9c8b8c5 100644 --- a/arch/arm/mach-clps711x/reset.c +++ b/arch/arm/mach-clps711x/reset.c @@ -9,8 +9,6 @@ #include <common.h> -extern void start(void); - void __noreturn reset_cpu(unsigned long addr) { arch_shutdown(); diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile index 0ff0b66920..fc0cb1afcd 100644 --- a/arch/arm/mach-ep93xx/Makefile +++ b/arch/arm/mach-ep93xx/Makefile @@ -1,4 +1,3 @@ -obj-y += clocksource.o gpio.o led.o header.o +obj-y += clocksource.o gpio.o header.o -obj-y += lowlevel_init.o -pbl-y += lowlevel_init.o led.o +lwl-y += lowlevel_init.o led.o diff --git a/arch/arm/mach-highbank/Kconfig b/arch/arm/mach-highbank/Kconfig new file mode 100644 index 0000000000..47c6405eb1 --- /dev/null +++ b/arch/arm/mach-highbank/Kconfig @@ -0,0 +1,18 @@ +if ARCH_HIGHBANK + +config ARCH_TEXT_BASE + hex + default 0x03f00000 + +config BOARDINFO + default "Calxeda Highbank" if MACH_HIGHBANK + +choice + prompt "Calxeda Board type" + +config MACH_HIGHBANK + bool "Calxeda Highbank" + +endchoice + +endif diff --git a/arch/arm/mach-highbank/Makefile b/arch/arm/mach-highbank/Makefile new file mode 100644 index 0000000000..6a7330f633 --- /dev/null +++ b/arch/arm/mach-highbank/Makefile @@ -0,0 +1,4 @@ +obj-y += core.o +obj-y += devices.o +obj-y += reset.o +obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o smc.o diff --git a/arch/arm/mach-highbank/cache-l2x0.c b/arch/arm/mach-highbank/cache-l2x0.c new file mode 100644 index 0000000000..f1e39dc968 --- /dev/null +++ b/arch/arm/mach-highbank/cache-l2x0.c @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com> + * + * 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; version 2 of + * the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +#include <common.h> +#include <init.h> +#include <io.h> + +#include <asm/mmu.h> +#include <asm/cache-l2x0.h> + +#include "core.h" + +static void highbank_l2x0_disable(void) +{ + /* Disable PL310 L2 Cache controller */ + highbank_smc1(0x102, 0x0); +} + +static int highbank_l2x0_init(void) +{ + /* Enable PL310 L2 Cache controller */ + highbank_smc1(0x102, 0x1); + l2x0_init(IOMEM(0xfff12000), 0, ~0UL); + outer_cache.disable = highbank_l2x0_disable; + + return 0; +} +postmmu_initcall(highbank_l2x0_init); diff --git a/arch/arm/mach-highbank/core.c b/arch/arm/mach-highbank/core.c new file mode 100644 index 0000000000..967d13f939 --- /dev/null +++ b/arch/arm/mach-highbank/core.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com> + * + * GPLv2 only + */ + +#include <common.h> +#include <init.h> +#include <io.h> + +#include <linux/clk.h> +#include <linux/clkdev.h> +#include <linux/amba/bus.h> + +#include <asm/hardware/arm_timer.h> + +#include <mach/devices.h> +#include <mach/hardware.h> +#include <mach/sysregs.h> + +void __iomem *sregs_base = IOMEM(HB_SREG_A9_BASE); + +static void highbank_clk_init(void) +{ + struct clk *clk; + + clk = clk_fixed("dummy_apb_pclk", 0); + clk_register_clkdev(clk, "apb_pclk", NULL); + + clk = clk_fixed("pclk", 150000000); + clk_register_clkdev(clk, NULL, "sp804"); + clk_register_clkdev(clk, NULL, "uart-pl011"); +} + +static void highbank_sp804_init(void) +{ + amba_apb_device_add(NULL, "sp804", DEVICE_ID_SINGLE, 0xfff34000, 4096, NULL, 0); +} + +static int highbank_init(void) +{ + highbank_clk_init(); + highbank_sp804_init(); + + return 0; +} +postcore_initcall(highbank_init); diff --git a/arch/arm/mach-highbank/core.h b/arch/arm/mach-highbank/core.h new file mode 100644 index 0000000000..e3f19b2e56 --- /dev/null +++ b/arch/arm/mach-highbank/core.h @@ -0,0 +1,2 @@ + +extern void highbank_smc1(int fn, int arg); diff --git a/arch/arm/mach-highbank/devices.c b/arch/arm/mach-highbank/devices.c new file mode 100644 index 0000000000..6d75864306 --- /dev/null +++ b/arch/arm/mach-highbank/devices.c @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com> + * + * GPLv2 only + */ + +#include <common.h> +#include <sizes.h> + +#include <linux/amba/bus.h> + +#include <asm/memory.h> + +#include <mach/devices.h> + +void highbank_add_ddram(u32 size) +{ + arm_add_mem_device("ram1", 0x00000000, size); + add_mem_device("nvram", 0xfff88000, SZ_32K, IORESOURCE_MEM_WRITEABLE); +} + +void highbank_register_uart(void) +{ + amba_apb_device_add(NULL, "uart-pl011", DEVICE_ID_SINGLE, 0xfff36000, 4096, NULL, 0); +} + +void highbank_register_ahci(void) +{ + add_generic_device("ahci", DEVICE_ID_SINGLE, NULL, 0xffe08000, + 0x10000, IORESOURCE_MEM, NULL); +} + +void highbank_register_xgmac(unsigned id) +{ + resource_size_t start; + + switch (id) { + case 0: + start = 0xfff50000; + break; + case 1: + start = 0xfff51000; + break; + default: + return; + } + + add_generic_device("hb-xgmac", id, NULL, start, 0x1000, + IORESOURCE_MEM, NULL); +} + +void highbank_register_gpio(unsigned id) +{ + resource_size_t start; + + switch (id) { + case 0: + start = 0xfff30000; + break; + case 1: + start = 0xfff31000; + break; + case 2: + start = 0xfff32000; + break; + case 3: + start = 0xfff33000; + break; + default: + return; + } + + amba_apb_device_add(NULL, "pl061_gpio", id, start, 0x1000, NULL, 0); +} diff --git a/arch/arm/mach-highbank/include/mach/clkdev.h b/arch/arm/mach-highbank/include/mach/clkdev.h new file mode 100644 index 0000000000..04b37a8980 --- /dev/null +++ b/arch/arm/mach-highbank/include/mach/clkdev.h @@ -0,0 +1,7 @@ +#ifndef __ASM_MACH_CLKDEV_H +#define __ASM_MACH_CLKDEV_H + +#define __clk_get(clk) ({ 1; }) +#define __clk_put(clk) do { } while (0) + +#endif diff --git a/arch/arm/mach-highbank/include/mach/debug_ll.h b/arch/arm/mach-highbank/include/mach/debug_ll.h new file mode 100644 index 0000000000..4cdbb3ce51 --- /dev/null +++ b/arch/arm/mach-highbank/include/mach/debug_ll.h @@ -0,0 +1,26 @@ +/* + * Copyright 2013 Jean-Christophe PLAGNIOL-VILLARD <plagniol@jcrosoft.com> + * + * GPLv2 only + */ + +#ifndef __MACH_DEBUG_LL_H__ +#define __MACH_DEBUG_LL_H__ + +#include <linux/amba/serial.h> +#include <io.h> + +#define UART_BASE 0xfff36000 + +static inline void PUTC_LL(char c) +{ + /* Wait until there is space in the FIFO */ + while (readl(UART_BASE + UART01x_FR) & UART01x_FR_TXFF); + + /* Send the character */ + writel(c, UART_BASE + UART01x_DR); + + /* Wait to make sure it hits the line, in case we die too soon. */ + while (readl(UART_BASE + UART01x_FR) & UART01x_FR_TXFF); +} +#endif diff --git a/arch/arm/mach-highbank/include/mach/devices.h b/arch/arm/mach-highbank/include/mach/devices.h new file mode 100644 index 0000000000..2cf2b6161c --- /dev/null +++ b/arch/arm/mach-highbank/include/mach/devices.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com> + * + * GPLv2 only + */ + +#ifndef __ASM_ARCH_DEVICES_H__ +#define __ASM_ARCH_DEVICES_H__ + +void highbank_add_ddram(u32 size); + +void highbank_register_uart(void); +void highbank_register_ahci(void); +void highbank_register_xgmac(unsigned id); +void highbank_register_gpio(unsigned id); + +#endif /* __ASM_ARCH_DEVICES_H__ */ diff --git a/arch/arm/mach-highbank/include/mach/gpio.h b/arch/arm/mach-highbank/include/mach/gpio.h new file mode 100644 index 0000000000..306ab4c9f2 --- /dev/null +++ b/arch/arm/mach-highbank/include/mach/gpio.h @@ -0,0 +1 @@ +#include <asm-generic/gpio.h> diff --git a/arch/arm/mach-highbank/include/mach/hardware.h b/arch/arm/mach-highbank/include/mach/hardware.h new file mode 100644 index 0000000000..db7fff242f --- /dev/null +++ b/arch/arm/mach-highbank/include/mach/hardware.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2010-2011 Calxeda, Inc + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com> + * + * GPLv2 only + */ + +#ifndef __MACH_HARDWARE_H__ +#define __MACH_HARDWARE_H__ + +#define HB_SREG_A9_BASE 0xfff3c000 +#define HB_SYSRAM_OPP_TABLE_BASE 0xfff8f000 + +#endif /* __MACH_HARDWARE_H__ */ diff --git a/arch/arm/mach-highbank/include/mach/sysregs.h b/arch/arm/mach-highbank/include/mach/sysregs.h new file mode 100644 index 0000000000..2f058f2d96 --- /dev/null +++ b/arch/arm/mach-highbank/include/mach/sysregs.h @@ -0,0 +1,57 @@ +/* + * Copyright 2011 Calxeda, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef _MACH_HIGHBANK__SYSREGS_H_ +#define _MACH_HIGHBANK__SYSREGS_H_ + +#include <io.h> + +extern void __iomem *sregs_base; + +#define HB_SREG_A9_PWR_REQ 0xf00 +#define HB_SREG_A9_BOOT_STAT 0xf04 +#define HB_SREG_A9_BOOT_DATA 0xf08 +#define HB_SREG_A9_PWRDOM_DATA 0xf20 + +#define HB_PWRDOM_STAT_SATA 0x80000000 +#define HB_PWRDOM_STAT_PCI 0x40000000 +#define HB_PWRDOM_STAT_EMMC 0x20000000 + +#define HB_PWR_SUSPEND 0 +#define HB_PWR_SOFT_RESET 1 +#define HB_PWR_HARD_RESET 2 +#define HB_PWR_SHUTDOWN 3 + +static inline void hingbank_set_pwr_suspend(void) +{ + writel(HB_PWR_SUSPEND, sregs_base + HB_SREG_A9_PWR_REQ); +} + +static inline void hingbank_set_pwr_shutdown(void) +{ + writel(HB_PWR_SHUTDOWN, sregs_base + HB_SREG_A9_PWR_REQ); +} + +static inline void hingbank_set_pwr_soft_reset(void) +{ + writel(HB_PWR_SOFT_RESET, sregs_base + HB_SREG_A9_PWR_REQ); +} + +static inline void hingbank_set_pwr_hard_reset(void) +{ + writel(HB_PWR_HARD_RESET, sregs_base + HB_SREG_A9_PWR_REQ); +} + +#endif diff --git a/arch/arm/mach-highbank/reset.c b/arch/arm/mach-highbank/reset.c new file mode 100644 index 0000000000..b9664e41bb --- /dev/null +++ b/arch/arm/mach-highbank/reset.c @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com> + * + * GPLv2 only + */ + +#include <common.h> +#include <io.h> + +#include <mach/devices.h> +#include <mach/sysregs.h> + +void __noreturn reset_cpu(ulong addr) +{ + hingbank_set_pwr_hard_reset(); + asm(" wfi"); + + while(1); +} + +void __noreturn poweroff() +{ + shutdown_barebox(); + + hingbank_set_pwr_shutdown(); + asm(" wfi"); + + while(1); +} diff --git a/arch/arm/mach-highbank/smc.S b/arch/arm/mach-highbank/smc.S new file mode 100644 index 0000000000..b2118b4a84 --- /dev/null +++ b/arch/arm/mach-highbank/smc.S @@ -0,0 +1,27 @@ +/* + * Copied from omap44xx-smc.S Copyright (C) 2010 Texas Instruments, Inc. + * Copyright 2012 Calxeda, Inc. + * + * 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. + */ + +#include <linux/linkage.h> + +/* + * This is common routine to manage secure monitor API + * used to modify the PL310 secure registers. + * 'r0' contains the value to be modified and 'r12' contains + * the monitor API number. + * Function signature : void highbank_smc1(u32 fn, u32 arg) + */ + +ENTRY(highbank_smc1) + stmfd sp!, {r4-r11, lr} + mov r12, r0 + mov r0, r1 + dsb + smc #0 + ldmfd sp!, {r4-r11, pc} +ENDPROC(highbank_smc1) diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 4115d35ccb..1308f3c3db 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -30,6 +30,7 @@ config ARCH_TEXT_BASE default 0x8fe00000 if MACH_TX53 default 0x7fc00000 if MACH_GUF_VINCELL default 0x97f00000 if MACH_EFIKA_MX_SMARTBOOK + default 0x17800000 if MACH_SABRESD config BOARDINFO default "Eukrea CPUIMX25" if MACH_EUKREA_CPUIMX25 @@ -59,6 +60,7 @@ config BOARDINFO default "Sabre Lite" if MACH_SABRELITE default "Ka-Ro tx53" if MACH_TX53 default "Garz+Fricke Vincell" if MACH_GUF_VINCELL + default "SabreSD" if MACH_SABRESD choice prompt "Select boot mode" @@ -247,7 +249,7 @@ config MACH_EUKREA_CPUIMX25 config MACH_FREESCALE_MX25_3STACK bool "Freescale MX25 3stack" select I2C - select I2C_MC34704 + select MFD_MC34704 help Say Y here if you are using the Freescale MX25 3stack board equipped with a Freescale i.MX25 Processor @@ -289,6 +291,7 @@ config MACH_PCA100 config MACH_PCM038 bool "phyCORE-i.MX27" + select IMX_IIM select SPI select DRIVER_SPI_IMX select MFD_MC13XXX @@ -354,7 +357,7 @@ config MACH_FREESCALE_MX35_3STACK select I2C select I2C_IMX select MFD_MC13XXX - select I2C_MC9SDZ60 + select MFD_MC9SDZ60 help Say Y here if you are using the Freescale MX35 3stack board equipped with a Freescale i.MX35 Processor @@ -362,6 +365,7 @@ config MACH_FREESCALE_MX35_3STACK config MACH_PCM043 bool "phyCORE-i.MX35" select ARCH_HAS_L2X0 + select HAVE_DEFAULT_ENVIRONMENT_NEW help Say Y here if you are using Phytec's phyCORE-i.MX35 (pcm043) equipped with a Freescale i.MX35 Processor @@ -489,6 +493,9 @@ config MACH_MX6Q_ARM2 config MACH_SABRELITE bool "Freescale i.MX6 Sabre Lite" +config MACH_SABRESD + bool "Freescale i.MX6 SabreSD" + endchoice endif diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index 1c280353bd..4adf522219 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -11,11 +11,7 @@ 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_IMX_IIM) += iim.o obj-$(CONFIG_NAND_IMX) += nand.o -ifdef CONFIG_PBL_IMAGE -pbl-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o -else -obj-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o -endif +lwl-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-pfd.o obj-y += devices.o imx.o esdctl.o obj-y += boot.o diff --git a/arch/arm/mach-imx/clk-imx35.c b/arch/arm/mach-imx/clk-imx35.c index 5b5a9e7882..f50c07d30f 100644 --- a/arch/arm/mach-imx/clk-imx35.c +++ b/arch/arm/mach-imx/clk-imx35.c @@ -99,7 +99,7 @@ static int imx35_ccm_probe(struct device_d *dev) writel(0xffffffff, base + CCM_CGR0); writel(0xffffffff, base + CCM_CGR1); - writel(0xffffffff, base + CCM_CGR2); + writel(0xfbffffff, base + CCM_CGR2); writel(0xffffffff, base + CCM_CGR3); pdr0 = __raw_readl(base + CCM_PDR0); diff --git a/arch/arm/mach-imx/clk-imx5.c b/arch/arm/mach-imx/clk-imx5.c index d7548aea01..8b5bffd6c6 100644 --- a/arch/arm/mach-imx/clk-imx5.c +++ b/arch/arm/mach-imx/clk-imx5.c @@ -272,6 +272,7 @@ int __init mx53_clocks_init(void __iomem *regs, unsigned long rate_ckil, unsigne clkdev_add_physbase(clks[uart_root], MX53_UART3_BASE_ADDR, NULL); clkdev_add_physbase(clks[per_root], MX53_I2C1_BASE_ADDR, NULL); clkdev_add_physbase(clks[per_root], MX53_I2C2_BASE_ADDR, NULL); + clkdev_add_physbase(clks[per_root], MX53_I2C3_BASE_ADDR, NULL); clkdev_add_physbase(clks[per_root], MX53_GPT1_BASE_ADDR, NULL); clkdev_add_physbase(clks[ipg], MX53_CSPI_BASE_ADDR, NULL); clkdev_add_physbase(clks[ecspi_podf], MX53_ECSPI1_BASE_ADDR, NULL); diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c index 3585e27719..cc2bdc1ad9 100644 --- a/arch/arm/mach-imx/esdctl.c +++ b/arch/arm/mach-imx/esdctl.c @@ -355,7 +355,7 @@ void __naked __noreturn imx1_barebox_entry(uint32_t boarddata) unsigned long base; unsigned long size; - base = 0x08000000; + base = MX1_CSD0_BASE_ADDR; size = imx_v1_sdram_size((void *)MX1_SDRAMC_BASE_ADDR, 0); if (size == SZ_64M) diff --git a/arch/arm/mach-imx/external-nand-boot.c b/arch/arm/mach-imx/external-nand-boot.c index 2c353d7e3a..73c4ccdfbb 100644 --- a/arch/arm/mach-imx/external-nand-boot.c +++ b/arch/arm/mach-imx/external-nand-boot.c @@ -280,7 +280,7 @@ static __bare_init __naked void jump_sdram(unsigned long offset) * running inside the NFC address space. If not, barebox is started from the * currently running address without loading anything from NAND. */ -void __bare_init imx_barebox_boot_nand_external(unsigned long nfc_base) +int __bare_init imx_barebox_boot_nand_external(unsigned long nfc_base) { u32 r; u32 *src, *trg; @@ -289,7 +289,7 @@ void __bare_init imx_barebox_boot_nand_external(unsigned long nfc_base) /* skip NAND boot if not running from NFC space */ r = get_pc(); if (r < nfc_base || r > nfc_base + 0x800) - return; + return 0; src = (unsigned int *)nfc_base; trg = (unsigned int *)_text; @@ -297,6 +297,8 @@ void __bare_init imx_barebox_boot_nand_external(unsigned long nfc_base) /* Move ourselves out of NFC SRAM */ for (i = 0; i < 0x800 / sizeof(int); i++) *trg++ = *src++; + + return 1; } /* @@ -310,9 +312,11 @@ void __bare_init __noreturn imx21_barebox_boot_nand_external(void) { unsigned long nfc_base = MX21_NFC_BASE_ADDR; - imx_barebox_boot_nand_external(nfc_base); - jump_sdram(nfc_base - (unsigned long)_text); - imx_nand_load_image((void *)_text, barebox_image_size); + if (imx_barebox_boot_nand_external(nfc_base)) { + jump_sdram(nfc_base - (unsigned long)_text); + imx_nand_load_image((void *)_text, barebox_image_size); + } + imx21_barebox_entry(0); } #endif @@ -322,9 +326,11 @@ void __bare_init __noreturn imx25_barebox_boot_nand_external(void) { unsigned long nfc_base = MX25_NFC_BASE_ADDR; - imx_barebox_boot_nand_external(nfc_base); - jump_sdram(nfc_base - (unsigned long)_text); - imx_nand_load_image((void *)_text, barebox_image_size); + if (imx_barebox_boot_nand_external(nfc_base)) { + jump_sdram(nfc_base - (unsigned long)_text); + imx_nand_load_image((void *)_text, barebox_image_size); + } + imx25_barebox_entry(0); } #endif @@ -334,9 +340,11 @@ void __bare_init __noreturn imx27_barebox_boot_nand_external(void) { unsigned long nfc_base = MX27_NFC_BASE_ADDR; - imx_barebox_boot_nand_external(nfc_base); - jump_sdram(nfc_base - (unsigned long)_text); - imx_nand_load_image((void *)_text, barebox_image_size); + if (imx_barebox_boot_nand_external(nfc_base)) { + jump_sdram(nfc_base - (unsigned long)_text); + imx_nand_load_image((void *)_text, barebox_image_size); + } + imx27_barebox_entry(0); } #endif @@ -346,9 +354,11 @@ void __bare_init __noreturn imx31_barebox_boot_nand_external(void) { unsigned long nfc_base = MX31_NFC_BASE_ADDR; - imx_barebox_boot_nand_external(nfc_base); - jump_sdram(nfc_base - (unsigned long)_text); - imx_nand_load_image((void *)_text, barebox_image_size); + if (imx_barebox_boot_nand_external(nfc_base)) { + jump_sdram(nfc_base - (unsigned long)_text); + imx_nand_load_image((void *)_text, barebox_image_size); + } + imx31_barebox_entry(0); } #endif @@ -358,9 +368,11 @@ void __bare_init __noreturn imx35_barebox_boot_nand_external(void) { unsigned long nfc_base = MX35_NFC_BASE_ADDR; - imx_barebox_boot_nand_external(nfc_base); - jump_sdram(nfc_base - (unsigned long)_text); - imx_nand_load_image((void *)_text, barebox_image_size); + if (imx_barebox_boot_nand_external(nfc_base)) { + jump_sdram(nfc_base - (unsigned long)_text); + imx_nand_load_image((void *)_text, barebox_image_size); + } + imx35_barebox_entry(0); } #endif diff --git a/arch/arm/mach-imx/imx21.c b/arch/arm/mach-imx/imx21.c index cddf3c088e..91cd4bde48 100644 --- a/arch/arm/mach-imx/imx21.c +++ b/arch/arm/mach-imx/imx21.c @@ -30,12 +30,12 @@ static int imx21_init(void) add_generic_device("imx21-ccm", 0, NULL, MX21_CCM_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); add_generic_device("imx1-gpt", 0, NULL, MX21_GPT1_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); - add_generic_device("imx-gpio", 0, NULL, MX21_GPIO1_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); - add_generic_device("imx-gpio", 1, NULL, MX21_GPIO2_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); - add_generic_device("imx-gpio", 2, NULL, MX21_GPIO3_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); - add_generic_device("imx-gpio", 3, NULL, MX21_GPIO4_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); - add_generic_device("imx-gpio", 4, NULL, MX21_GPIO5_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); - add_generic_device("imx-gpio", 5, NULL, MX21_GPIO6_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); + add_generic_device("imx1-gpio", 0, NULL, MX21_GPIO1_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); + add_generic_device("imx1-gpio", 1, NULL, MX21_GPIO2_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); + add_generic_device("imx1-gpio", 2, NULL, MX21_GPIO3_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); + add_generic_device("imx1-gpio", 3, NULL, MX21_GPIO4_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); + add_generic_device("imx1-gpio", 4, NULL, MX21_GPIO5_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); + add_generic_device("imx1-gpio", 5, NULL, MX21_GPIO6_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); add_generic_device("imx21-wdt", 0, NULL, MX21_WDOG_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); return 0; diff --git a/arch/arm/mach-imx/imx27.c b/arch/arm/mach-imx/imx27.c index 6d30276284..e9d6197d55 100644 --- a/arch/arm/mach-imx/imx27.c +++ b/arch/arm/mach-imx/imx27.c @@ -103,12 +103,13 @@ static int imx27_init(void) imx_iomuxv1_init((void *)MX27_GPIO1_BASE_ADDR); - add_generic_device("imx_iim", 0, NULL, MX27_IIM_BASE_ADDR, SZ_4K, - IORESOURCE_MEM, NULL); + add_generic_device("imx_iim", DEVICE_ID_SINGLE, NULL, + MX27_IIM_BASE_ADDR, SZ_4K, IORESOURCE_MEM, NULL); imx27_init_max(); - add_generic_device("imx27-ccm", 0, NULL, MX27_CCM_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); + add_generic_device("imx27-ccm", DEVICE_ID_SINGLE, NULL, + MX27_CCM_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx1-gpt", 0, NULL, MX27_GPT1_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); add_generic_device("imx1-gpio", 0, NULL, MX27_GPIO1_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); add_generic_device("imx1-gpio", 1, NULL, MX27_GPIO2_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); @@ -117,7 +118,8 @@ static int imx27_init(void) add_generic_device("imx1-gpio", 4, NULL, MX27_GPIO5_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); add_generic_device("imx1-gpio", 5, NULL, MX27_GPIO6_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); add_generic_device("imx21-wdt", 0, NULL, MX27_WDOG_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); - add_generic_device("imx27-esdctl", 0, NULL, MX27_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); + add_generic_device("imx27-esdctl", DEVICE_ID_SINGLE, NULL, + MX27_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx27-usb-misc", 0, NULL, MX27_USB_OTG_BASE_ADDR + 0x600, 0x100, IORESOURCE_MEM, NULL); return 0; diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c index 21c7e90fcf..7b68783b3e 100644 --- a/arch/arm/mach-imx/imx35.c +++ b/arch/arm/mach-imx/imx35.c @@ -73,9 +73,9 @@ static int imx35_init(void) add_generic_device("imx-iomuxv3", 0, NULL, MX35_IOMUXC_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx35-ccm", 0, NULL, MX35_CCM_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx31-gpt", 0, NULL, MX35_GPT1_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL); - add_generic_device("imx-gpio", 0, NULL, MX35_GPIO1_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); - add_generic_device("imx-gpio", 1, NULL, MX35_GPIO2_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); - add_generic_device("imx-gpio", 2, NULL, MX35_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); + add_generic_device("imx31-gpio", 0, NULL, MX35_GPIO1_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); + add_generic_device("imx31-gpio", 1, NULL, MX35_GPIO2_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); + add_generic_device("imx31-gpio", 2, NULL, MX35_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx21-wdt", 0, NULL, MX35_WDOG_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL); add_generic_device("imx35-esdctl", 0, NULL, MX35_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); diff --git a/arch/arm/mach-imx/imx53.c b/arch/arm/mach-imx/imx53.c index 52fb8f78fd..3135ada312 100644 --- a/arch/arm/mach-imx/imx53.c +++ b/arch/arm/mach-imx/imx53.c @@ -60,7 +60,7 @@ static int imx53_init(void) add_generic_device("imx-iomuxv3", 0, NULL, MX53_IOMUXC_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx53-ccm", 0, NULL, MX53_CCM_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); - add_generic_device("imx31-gpt", 0, NULL, 0X53fa0000, 0x1000, IORESOURCE_MEM, NULL); + add_generic_device("imx31-gpt", 0, NULL, MX53_GPT1_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx31-gpio", 0, NULL, MX53_GPIO1_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx31-gpio", 1, NULL, MX53_GPIO2_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx31-gpio", 2, NULL, MX53_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c index b62f4128cc..7a7ce15c46 100644 --- a/arch/arm/mach-imx/imx6.c +++ b/arch/arm/mach-imx/imx6.c @@ -59,7 +59,7 @@ static int imx6_init(void) add_generic_device("imx-iomuxv3", 0, NULL, MX6_IOMUXC_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx6-ccm", 0, NULL, MX6_CCM_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL); - add_generic_device("imx31-gpt", 0, NULL, 0x02098000, 0x1000, IORESOURCE_MEM, NULL); + add_generic_device("imx31-gpt", 0, NULL, MX6_GPT_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL); add_generic_device("imx31-gpio", 0, NULL, MX6_GPIO1_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL); add_generic_device("imx31-gpio", 1, NULL, MX6_GPIO2_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL); add_generic_device("imx31-gpio", 2, NULL, MX6_GPIO3_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL); diff --git a/arch/arm/mach-imx/include/mach/devices-imx53.h b/arch/arm/mach-imx/include/mach/devices-imx53.h index 4c330549cd..5bdcf32291 100644 --- a/arch/arm/mach-imx/include/mach/devices-imx53.h +++ b/arch/arm/mach-imx/include/mach/devices-imx53.h @@ -21,6 +21,11 @@ static inline struct device_d *imx53_add_i2c1(struct i2c_platform_data *pdata) return imx_add_i2c((void *)MX53_I2C2_BASE_ADDR, 1, pdata); } +static inline struct device_d *imx53_add_i2c2(struct i2c_platform_data *pdata) +{ + return imx_add_i2c((void *)MX53_I2C3_BASE_ADDR, 2, pdata); +} + static inline struct device_d *imx53_add_uart0(void) { return imx_add_uart_imx21((void *)MX53_UART1_BASE_ADDR, 0); diff --git a/arch/arm/mach-imx/include/mach/iomux-mx6.h b/arch/arm/mach-imx/include/mach/iomux-mx6.h index f50fd8af16..57d1a3bf9f 100644 --- a/arch/arm/mach-imx/include/mach/iomux-mx6.h +++ b/arch/arm/mach-imx/include/mach/iomux-mx6.h @@ -83,6 +83,9 @@ MX6_PAD_CTL_DSE_40ohm | MX6_PAD_CTL_HYS | \ MX6_PAD_CTL_ODE | MX6_PAD_CTL_SRE_FAST) +#define MX6Q_USB_HSIC_PAD_CTRL (MX6_PAD_CTL_HYS | MX6_PAD_CTL_PKE | MX6_PAD_CTL_PUE | \ + MX6_PAD_CTL_DSE_40ohm) + #define MX6Q_HIGH_DRV (MX6_PAD_CTL_DSE_120ohm) #define _MX6Q_PAD_SD2_DAT1__USDHC2_DAT1 \ @@ -135,7 +138,7 @@ IOMUX_PAD(0x0368, 0x0054, 7, 0x0000, 0, 0) #define _MX6Q_PAD_RGMII_TXC__USBOH3_H2_DATA \ - IOMUX_PAD(0x036C, 0x0058, 0, 0x0000, 0, 0) + IOMUX_PAD(0x036C, 0x0058, IOMUX_CONFIG_SION, 0x0000, 0, 0) #define _MX6Q_PAD_RGMII_TXC__ENET_RGMII_TXC \ IOMUX_PAD(0x036C, 0x0058, 1, 0x0000, 0, 0) #define _MX6Q_PAD_RGMII_TXC__SPDIF_SPDIF_EXTCLK \ @@ -188,7 +191,7 @@ IOMUX_PAD(0x037C, 0x0068, 6, 0x0000, 0, 0) #define _MX6Q_PAD_RGMII_RX_CTL__USBOH3_H3_DATA \ - IOMUX_PAD(0x0380, 0x006C, 0, 0x0000, 0, 0) + IOMUX_PAD(0x0380, 0x006C, IOMUX_CONFIG_SION, 0x0000, 0, 0) #define _MX6Q_PAD_RGMII_RX_CTL__ENET_RGMII_RX_CTL \ IOMUX_PAD(0x0380, 0x006C, 1, 0x0858, 0, 0) #define _MX6Q_PAD_RGMII_RX_CTL__GPIO_6_24 \ @@ -206,7 +209,7 @@ IOMUX_PAD(0x0384, 0x0070, 6, 0x0000, 0, 0) #define _MX6Q_PAD_RGMII_TX_CTL__USBOH3_H2_STROBE \ - IOMUX_PAD(0x0388, 0x0074, 0, 0x0000, 0, 0) + IOMUX_PAD(0x0388, 0x0074, IOMUX_CONFIG_SION, 0x0000, 0, 0) #define _MX6Q_PAD_RGMII_TX_CTL__ENET_RGMII_TX_CTL \ IOMUX_PAD(0x0388, 0x0074, 1, 0x0000, 0, 0) #define _MX6Q_PAD_RGMII_TX_CTL__GPIO_6_26 \ @@ -246,7 +249,7 @@ IOMUX_PAD(0x0394, 0x0080, 6, 0x0000, 0, 0) #define _MX6Q_PAD_RGMII_RXC__USBOH3_H3_STROBE \ - IOMUX_PAD(0x0398, 0x0084, 0, 0x0000, 0, 0) + IOMUX_PAD(0x0398, 0x0084, IOMUX_CONFIG_SION, 0x0000, 0, 0) #define _MX6Q_PAD_RGMII_RXC__ENET_RGMII_RXC \ IOMUX_PAD(0x0398, 0x0084, 1, 0x0844, 0, 0) #define _MX6Q_PAD_RGMII_RXC__GPIO_6_30 \ @@ -3695,7 +3698,7 @@ #define MX6Q_PAD_SD2_DAT0__DCIC2_DCIC_OUT (_MX6Q_PAD_SD2_DAT0__DCIC2_DCIC_OUT | MUX_PAD_CTRL(NO_PAD_CTRL)) #define MX6Q_PAD_SD2_DAT0__ANATOP_ANATOP_TESTO_2 (_MX6Q_PAD_SD2_DAT0__ANATOP_ANATOP_TESTO_2 | MUX_PAD_CTRL(NO_PAD_CTRL)) -#define MX6Q_PAD_RGMII_TXC__USBOH3_H2_DATA (_MX6Q_PAD_RGMII_TXC__USBOH3_H2_DATA | MUX_PAD_CTRL(NO_PAD_CTRL)) +#define MX6Q_PAD_RGMII_TXC__USBOH3_H2_DATA (_MX6Q_PAD_RGMII_TXC__USBOH3_H2_DATA | MUX_PAD_CTRL(MX6Q_USB_HSIC_PAD_CTRL)) #define MX6Q_PAD_RGMII_TXC__ENET_RGMII_TXC (_MX6Q_PAD_RGMII_TXC__ENET_RGMII_TXC | MUX_PAD_CTRL(MX6Q_ENET_PAD_CTRL)) #define MX6Q_PAD_RGMII_TXC__SPDIF_SPDIF_EXTCLK (_MX6Q_PAD_RGMII_TXC__SPDIF_SPDIF_EXTCLK | MUX_PAD_CTRL(NO_PAD_CTRL)) #define MX6Q_PAD_RGMII_TXC__GPIO_6_19 (_MX6Q_PAD_RGMII_TXC__GPIO_6_19 | MUX_PAD_CTRL(NO_PAD_CTRL)) @@ -3724,7 +3727,7 @@ #define MX6Q_PAD_RGMII_TD3__GPIO_6_23 (_MX6Q_PAD_RGMII_TD3__GPIO_6_23 | MUX_PAD_CTRL(NO_PAD_CTRL)) #define MX6Q_PAD_RGMII_TD3__MIPI_CORE_DPHY_TEST_IN_4 (_MX6Q_PAD_RGMII_TD3__MIPI_CORE_DPHY_TEST_IN_4 | MUX_PAD_CTRL(NO_PAD_CTRL)) -#define MX6Q_PAD_RGMII_RX_CTL__USBOH3_H3_DATA (_MX6Q_PAD_RGMII_RX_CTL__USBOH3_H3_DATA | MUX_PAD_CTRL(NO_PAD_CTRL)) +#define MX6Q_PAD_RGMII_RX_CTL__USBOH3_H3_DATA (_MX6Q_PAD_RGMII_RX_CTL__USBOH3_H3_DATA | MUX_PAD_CTRL(MX6Q_USB_HSIC_PAD_CTRL)) #define MX6Q_PAD_RGMII_RX_CTL__ENET_RGMII_RX_CTL (_MX6Q_PAD_RGMII_RX_CTL__ENET_RGMII_RX_CTL | MUX_PAD_CTRL(MX6Q_ENET_PAD_CTRL)) #define MX6Q_PAD_RGMII_RX_CTL__GPIO_6_24 (_MX6Q_PAD_RGMII_RX_CTL__GPIO_6_24 | MUX_PAD_CTRL(NO_PAD_CTRL)) #define MX6Q_PAD_RGMII_RX_CTL__MIPI_CORE_DPHY_TEST_IN_5 (_MX6Q_PAD_RGMII_RX_CTL__MIPI_CORE_DPHY_TEST_IN_5 | MUX_PAD_CTRL(NO_PAD_CTRL)) @@ -3734,7 +3737,7 @@ #define MX6Q_PAD_RGMII_RD0__GPIO_6_25 (_MX6Q_PAD_RGMII_RD0__GPIO_6_25 | MUX_PAD_CTRL(NO_PAD_CTRL)) #define MX6Q_PAD_RGMII_RD0__MIPI_CORE_DPHY_TEST_IN_6 (_MX6Q_PAD_RGMII_RD0__MIPI_CORE_DPHY_TEST_IN_6 | MUX_PAD_CTRL(NO_PAD_CTRL)) -#define MX6Q_PAD_RGMII_TX_CTL__USBOH3_H2_STROBE (_MX6Q_PAD_RGMII_TX_CTL__USBOH3_H2_STROBE | MUX_PAD_CTRL(NO_PAD_CTRL)) +#define MX6Q_PAD_RGMII_TX_CTL__USBOH3_H2_STROBE (_MX6Q_PAD_RGMII_TX_CTL__USBOH3_H2_STROBE | MUX_PAD_CTRL(MX6Q_USB_HSIC_PAD_CTRL)) #define MX6Q_PAD_RGMII_TX_CTL__ENET_RGMII_TX_CTL (_MX6Q_PAD_RGMII_TX_CTL__ENET_RGMII_TX_CTL | MUX_PAD_CTRL(MX6Q_ENET_PAD_CTRL)) #define MX6Q_PAD_RGMII_TX_CTL__GPIO_6_26 (_MX6Q_PAD_RGMII_TX_CTL__GPIO_6_26 | MUX_PAD_CTRL(NO_PAD_CTRL)) #define MX6Q_PAD_RGMII_TX_CTL__MIPI_CORE_DPHY_TEST_IN_7 (_MX6Q_PAD_RGMII_TX_CTL__MIPI_CORE_DPHY_TEST_IN_7 | MUX_PAD_CTRL(NO_PAD_CTRL)) @@ -3756,7 +3759,7 @@ #define MX6Q_PAD_RGMII_RD3__GPIO_6_29 (_MX6Q_PAD_RGMII_RD3__GPIO_6_29 | MUX_PAD_CTRL(NO_PAD_CTRL)) #define MX6Q_PAD_RGMII_RD3__MIPI_CORE_DPHY_TEST_IN_10 (_MX6Q_PAD_RGMII_RD3__MIPI_CORE_DPHY_TEST_IN_10 | MUX_PAD_CTRL(NO_PAD_CTRL)) -#define MX6Q_PAD_RGMII_RXC__USBOH3_H3_STROBE (_MX6Q_PAD_RGMII_RXC__USBOH3_H3_STROBE | MUX_PAD_CTRL(NO_PAD_CTRL)) +#define MX6Q_PAD_RGMII_RXC__USBOH3_H3_STROBE (_MX6Q_PAD_RGMII_RXC__USBOH3_H3_STROBE | MUX_PAD_CTRL(MX6Q_USB_HSIC_PAD_CTRL)) #define MX6Q_PAD_RGMII_RXC__ENET_RGMII_RXC (_MX6Q_PAD_RGMII_RXC__ENET_RGMII_RXC | MUX_PAD_CTRL(MX6Q_ENET_PAD_CTRL)) #define MX6Q_PAD_RGMII_RXC__GPIO_6_30 (_MX6Q_PAD_RGMII_RXC__GPIO_6_30 | MUX_PAD_CTRL(NO_PAD_CTRL)) #define MX6Q_PAD_RGMII_RXC__MIPI_CORE_DPHY_TEST_IN_11 (_MX6Q_PAD_RGMII_RXC__MIPI_CORE_DPHY_TEST_IN_11 | MUX_PAD_CTRL(NO_PAD_CTRL)) diff --git a/arch/arm/mach-mxs/include/mach/ssp.h b/arch/arm/mach-mxs/include/mach/ssp.h new file mode 100644 index 0000000000..5eee5c010a --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/ssp.h @@ -0,0 +1,120 @@ +/* + * Freescale MXS SSP + * + * Copyright (C) 2013 Michael Grzeschik <mgr@pengutronix.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. + * + */ + +#ifndef __SSP_H__ +#define __SSP_H__ + +#ifdef CONFIG_ARCH_IMX23 +# define HW_SSP_CTRL0 0x000 +# define HW_SSP_CMD0 0x010 +# define HW_SSP_CMD1 0x020 +# define HW_SSP_COMPREF 0x030 +# define HW_SSP_COMPMASK 0x040 +# define HW_SSP_TIMING 0x050 +# define HW_SSP_CTRL1 0x060 +# define HW_SSP_DATA 0x070 +# define HW_SSP_SDRESP0 0x080 +# define HW_SSP_SDRESP1 0x090 +# define HW_SSP_SDRESP2 0x0A0 +# define HW_SSP_SDRESP3 0x0B0 +# define HW_SSP_STATUS 0x0C0 +# define HW_SSP_DEBUG 0x100 +# define HW_SSP_VERSION 0x110 +#endif + +#ifdef CONFIG_ARCH_IMX28 +# define HW_SSP_CTRL0 0x000 +# define HW_SSP_CMD0 0x010 +# define HW_SSP_CMD1 0x020 +# define HW_SSP_XFER_COUNT 0x030 +# define HW_SSP_BLOCK_SIZE 0x040 +# define HW_SSP_COMPREF 0x050 +# define HW_SSP_COMPMASK 0x060 +# define HW_SSP_TIMING 0x070 +# define HW_SSP_CTRL1 0x080 +# define HW_SSP_DATA 0x090 +# define HW_SSP_SDRESP0 0x0A0 +# define HW_SSP_SDRESP1 0x0B0 +# define HW_SSP_SDRESP2 0x0C0 +# define HW_SSP_SDRESP3 0x0D0 +# define HW_SSP_DDR_CTRL 0x0E0 +# define HW_SSP_DLL_CTRL 0x0F0 +# define HW_SSP_STATUS 0x100 +# define HW_SSP_DLL_STS 0x110 +# define HW_SSP_DEBUG 0x120 +# define HW_SSP_VERSION 0x130 +#endif + +#define SSP_CTRL0_SFTRST (1 << 31) +#define SSP_CTRL0_CLKGATE (1 << 30) +#define SSP_CTRL0_RUN (1 << 29) +#define SSP_CTRL0_LOCK_CS (1 << 27) +#define SSP_CTRL0_READ (1 << 25) +#define SSP_CTRL0_IGNORE_CRC (1 << 26) +#define SSP_CTRL0_DATA_XFER (1 << 24) +#define SSP_CTRL0_BUS_WIDTH(x) (((x) & 0x3) << 22) +#define SSP_CTRL0_WAIT_FOR_IRQ (1 << 21) +#define SSP_CTRL0_WAIT_FOR_CMD (1 << 20) +#define SSP_CTRL0_SSP_ASSERT_OUT(x) (((x) & 0x3) << 20) +#define SSP_CTRL0_LONG_RESP (1 << 19) +#define SSP_CTRL0_GET_RESP (1 << 17) +#define SSP_CTRL0_ENABLE (1 << 16) + +#define SSP_CMD0_SLOW_CLK (1 << 22) +#define SSP_CMD0_CONT_CLK (1 << 21) +#define SSP_CMD0_APPEND_8CYC (1 << 20) +#ifdef CONFIG_ARCH_IMX23 +# define SSP_CTRL0_XFER_COUNT(x) ((x) & 0xffff) +# define SSP_CMD0_BLOCK_SIZE(x) (((x) & 0xf) << 16) +# define SSP_CMD0_BLOCK_COUNT(x) (((x) & 0xff) << 8) +#endif +#define SSP_CMD0_CMD(x) ((x) & 0xff) + +#ifdef CONFIG_ARCH_IMX28 +# define SSP_BLOCK_SIZE(x) ((x) & 0xf) +# define SSP_BLOCK_COUNT(x) (((x) & 0xffffff) << 4) +#endif + +/* bit definition for register HW_SSP_TIMING */ +#define SSP_TIMING_TIMEOUT_MASK (0xffff0000) +#define SSP_TIMING_TIMEOUT(x) ((x) << 16) +#define SSP_TIMING_CLOCK_DIVIDE(x) (((x) & 0xff) << 8) +#define SSP_TIMING_CLOCK_RATE(x) ((x) & 0xff) + +/* bit definition for register HW_SSP_CTRL1 */ +#define SSP_CTRL1_POLARITY (1 << 9) +#define SSP_CTRL1_PHASE (1 << 10) +#define SSP_CTRL1_DMA_ENABLE (1 << 13) +#define SSP_CTRL1_WORD_LENGTH(x) (((x) & 0xf) << 4) +#define SSP_CTRL1_SSP_MODE(x) ((x) & 0xf) + +/* bit definition for register HW_SSP_STATUS */ +# define SSP_STATUS_PRESENT (1 << 31) +# define SSP_STATUS_SD_PRESENT (1 << 29) +# define SSP_STATUS_CARD_DETECT (1 << 28) +# define SSP_STATUS_RESP_CRC_ERR (1 << 16) +# define SSP_STATUS_RESP_ERR (1 << 15) +# define SSP_STATUS_RESP_TIMEOUT (1 << 14) +# define SSP_STATUS_DATA_CRC_ERR (1 << 13) +# define SSP_STATUS_TIMEOUT (1 << 12) +# define SSP_STATUS_FIFO_OVRFLW (1 << 9) +# define SSP_STATUS_FIFO_FULL (1 << 8) +# define SSP_STATUS_FIFO_EMPTY (1 << 5) +# define SSP_STATUS_FIFO_UNDRFLW (1 << 4) +# define SSP_STATUS_CMD_BUSY (1 << 3) +# define SSP_STATUS_DATA_BUSY (1 << 2) +# define SSP_STATUS_BUSY (1 << 0) +# define SSP_STATUS_ERROR (SSP_STATUS_FIFO_OVRFLW | SSP_STATUS_FIFO_UNDRFLW | \ + SSP_STATUS_RESP_CRC_ERR | SSP_STATUS_RESP_ERR | \ + SSP_STATUS_RESP_TIMEOUT | SSP_STATUS_DATA_CRC_ERR | SSP_STATUS_TIMEOUT) + +#endif /* __SSP_H__ */ diff --git a/arch/arm/mach-mxs/soc-imx28.c b/arch/arm/mach-mxs/soc-imx28.c index a181b759cb..8972a3d909 100644 --- a/arch/arm/mach-mxs/soc-imx28.c +++ b/arch/arm/mach-mxs/soc-imx28.c @@ -21,6 +21,7 @@ #define HW_CLKCTRL_RESET 0x1e0 # define HW_CLKCTRL_RESET_CHIP (1 << 1) +#define HW_CLKCTRL_WDOG_POR_DISABLE (1 << 5) /* Reset the full i.MX28 SoC via a chipset feature */ void __noreturn reset_cpu(unsigned long addr) @@ -35,3 +36,16 @@ void __noreturn reset_cpu(unsigned long addr) /*NOTREACHED*/ } EXPORT_SYMBOL(reset_cpu); + +static int imx28_init(void) +{ + /* + * 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); + + return 0; +} +postcore_initcall(imx28_init); diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile index 94e42c6e75..aaa0ceaa62 100644 --- a/arch/arm/mach-omap/Makefile +++ b/arch/arm/mach-omap/Makefile @@ -28,6 +28,6 @@ obj-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock.o pbl-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock.o obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o obj-$(CONFIG_SHELL_NONE) += xload.o -obj-$(CONFIG_I2C_TWL6030) += omap4_twl6030_mmc.o +obj-$(CONFIG_MFD_TWL6030) += omap4_twl6030_mmc.o obj-$(CONFIG_OMAP4_USBBOOT) += omap4_rom_usb.o obj-y += gpio.o diff --git a/arch/blackfin/configs/ipe337_defconfig b/arch/blackfin/configs/ipe337_defconfig index d01c7e7566..086a9716d9 100644 --- a/arch/blackfin/configs/ipe337_defconfig +++ b/arch/blackfin/configs/ipe337_defconfig @@ -25,5 +25,6 @@ CONFIG_NET_PING=y CONFIG_CMD_TFTP=y CONFIG_FS_TFTP=y CONFIG_DRIVER_NET_SMC911X=y +CONFIG_MTD=y CONFIG_DRIVER_CFI=y CONFIG_CFI_BUFFER_WRITE=y diff --git a/arch/nios2/configs/generic_defconfig b/arch/nios2/configs/generic_defconfig index 5e27cc8d65..41899904bf 100644 --- a/arch/nios2/configs/generic_defconfig +++ b/arch/nios2/configs/generic_defconfig @@ -27,6 +27,7 @@ CONFIG_CMD_PARTITION=y CONFIG_NET=y CONFIG_NET_PING=y CONFIG_DRIVER_NET_TSE=y +CONFIG_MTD=y CONFIG_DRIVER_CFI=y CONFIG_FS_TFTP=y CONFIG_ZLIB=y diff --git a/arch/ppc/configs/pcm030_defconfig b/arch/ppc/configs/pcm030_defconfig index d2ff16c71b..97438416cf 100644 --- a/arch/ppc/configs/pcm030_defconfig +++ b/arch/ppc/configs/pcm030_defconfig @@ -36,6 +36,7 @@ CONFIG_FS_TFTP=y CONFIG_ARCH_MPC5XXX=y CONFIG_MACH_PHYCORE_MPC5200B_TINY=y CONFIG_DRIVER_NET_MPC5200=y +CONFIG_MTD=y CONFIG_DRIVER_CFI=y CONFIG_CFI_BUFFER_WRITE=y CONFIG_ZLIB=y diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index a3ebe19fa5..48c6ea35a8 100644 --- a/arch/sandbox/board/hostfile.c +++ b/arch/sandbox/board/hostfile.c @@ -89,13 +89,7 @@ static struct driver_d hf_drv = { .probe = hf_probe, .info = hf_info, }; - -static int hf_init(void) -{ - return platform_driver_register(&hf_drv); -} - -device_initcall(hf_init); +device_platform_driver(hf_drv); int barebox_register_filedev(struct hf_platform_data *hf) { diff --git a/commands/Kconfig b/commands/Kconfig index d3c338c832..c1454c708b 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -487,6 +487,13 @@ config CMD_OFTREE The oftree command has support for dumping devicetrees and, if enabled, to probe devices from the devicetree +config CMD_OFTREE_PROBE + bool + depends on CMD_OFTREE + prompt "oftree probe support" + help + This enables the -p option to probe devices from the devicetree + config CMD_OF_PROPERTY tristate select OFTREE diff --git a/commands/automount.c b/commands/automount.c index 4713932610..511d18b69a 100644 --- a/commands/automount.c +++ b/commands/automount.c @@ -60,6 +60,7 @@ BAREBOX_CMD_HELP_START(automount) BAREBOX_CMD_HELP_USAGE("automount [OPTIONS] <PATH> <cmd>\n") BAREBOX_CMD_HELP_SHORT("execute <cmd> when <PATH> is first accessed\n") BAREBOX_CMD_HELP_OPT("-l", "List currently registered automountpoints\n") +BAREBOX_CMD_HELP_OPT("-d", "Create the mount path\n") BAREBOX_CMD_HELP_OPT("-r <PATH>", "remove an automountpoint\n") BAREBOX_CMD_HELP_END diff --git a/commands/nandtest.c b/commands/nandtest.c index f08f8eb886..ba15ecfb33 100644 --- a/commands/nandtest.c +++ b/commands/nandtest.c @@ -43,41 +43,17 @@ static unsigned int ecc_stats_over; static unsigned int ecc_failed_cnt; /* - * Implementation of pread with lseek and read. - */ -static ssize_t pread(int fd, void *buf, size_t count, loff_t offset) -{ - int ret; - - /* Seek to offset */ - ret = lseek(fd, offset, SEEK_SET); - if (ret < 0) - perror("lseek"); - - /* Read from flash and put it into buf */ - ret = read(fd, buf, count); - if (ret < 0) - perror("read"); - - return 0; -} - -/* * Implementation of pwrite with lseek and write. */ -static ssize_t pwrite(int fd, const void *buf, +static ssize_t __pwrite(int fd, const void *buf, size_t count, loff_t offset, loff_t length) { - int ret; - - ret = lseek(fd, offset, SEEK_SET); - if (ret < 0) - perror("lseek"); + ssize_t ret; /* Write buf to flash */ - ret = write(fd, buf, count); + ret = pwrite(fd, buf, count, offset); if (ret < 0) { - perror("write"); + perror("pwrite"); if (markbad) { printf("\nMark block bad at 0x%08llx\n", offset + memregion.offset); @@ -88,7 +64,7 @@ static ssize_t pwrite(int fd, const void *buf, } flush(fd); - return 0; + return ret; } /* @@ -119,7 +95,7 @@ static int erase_and_write(loff_t ofs, unsigned char *data, for (i = 0; i < meminfo.erasesize; i += meminfo.writesize) { /* Write data to given offset */ - pwrite(fd, data + i, meminfo.writesize, + __pwrite(fd, data + i, meminfo.writesize, ofs + i, length); /* Read data from offset */ @@ -136,7 +112,7 @@ static int erase_and_write(loff_t ofs, unsigned char *data, newstats.corrected - oldstats.corrected, ofs + memregion.offset + i); init_progression_bar(length); - show_progress(ofs); + show_progress(ofs + i); if ((newstats.corrected-oldstats.corrected) >= MAX_ECC_BITS) { /* Increment ECC stats that @@ -154,7 +130,7 @@ static int erase_and_write(loff_t ofs, unsigned char *data, printf("\nECC failed at page 0x%08llx\n", ofs + memregion.offset + i); init_progression_bar(length); - show_progress(ofs); + show_progress(ofs + i); oldstats.failed = newstats.failed; ecc_failed_cnt++; } @@ -316,8 +292,8 @@ static int do_nandtest(int argc, char *argv[]) for (iter = 0; iter < nr_iterations; iter++) { init_progression_bar(length); - for (test_ofs = flash_offset; - test_ofs < flash_offset + length; + for (test_ofs = 0; + test_ofs < length; test_ofs += meminfo.erasesize) { show_progress(test_ofs); srand(seed); diff --git a/commands/ubiformat.c b/commands/ubiformat.c index 3bb2c9a9f5..47941bedba 100644 --- a/commands/ubiformat.c +++ b/commands/ubiformat.c @@ -233,7 +233,7 @@ static int open_file(off_t *sz) return sys_errmsg("cannot open \"%s\"", args.image); *sz = st.st_size; - fd = open(args.image, O_RDWR); + fd = open(args.image, O_RDONLY); if (fd < 0) return sys_errmsg("cannot open \"%s\"", args.image); @@ -338,7 +338,7 @@ static int flash_image(const struct mtd_dev_info *mtd, normsg_cont("eraseblock %d: erase", eb); } - err = mtd_erase(mtd, args.node_fd, eb); + err = libmtd_erase(mtd, args.node_fd, eb); if (err) { if (!args.quiet) printf("\n"); @@ -384,7 +384,7 @@ static int flash_image(const struct mtd_dev_info *mtd, new_len = drop_ffs(mtd, buf, mtd->eb_size); - err = mtd_write(mtd, args.node_fd, eb, 0, buf, new_len); + err = libmtd_write(mtd, args.node_fd, eb, 0, buf, new_len); if (err) { sys_errmsg("cannot write eraseblock %d", eb); @@ -453,7 +453,7 @@ static int format(const struct mtd_dev_info *mtd, normsg_cont("eraseblock %d: erase", eb); } - err = mtd_erase(mtd, args.node_fd, eb); + err = libmtd_erase(mtd, args.node_fd, eb); if (err) { if (!args.quiet) printf("\n"); @@ -484,7 +484,7 @@ static int format(const struct mtd_dev_info *mtd, printf(", write EC %lld\n", ec); } - err = mtd_write(mtd, args.node_fd, eb, 0, hdr, write_size); + err = libmtd_write(mtd, args.node_fd, eb, 0, hdr, write_size); if (err) { if (!args.quiet && !args.verbose) printf("\n"); diff --git a/common/Kconfig b/common/Kconfig index 3f6c11ec5c..3a55e017f4 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -478,19 +478,7 @@ config PARTITION bool prompt "Enable Partitions" -config PARTITION_DISK - depends on PARTITION - bool "DISK partition support" - help - Add support for handling common partition tables on all kind of disk - like devices (harddisks, CF cards, SD cards and so on) - -config PARTITION_DISK_DOS - depends on PARTITION_DISK - default y - bool "DOS partition support" - help - Add support to handle partitions in DOS style. +source common/partitions/Kconfig config DEFAULT_ENVIRONMENT bool diff --git a/common/Makefile b/common/Makefile index 7206eed8b1..1b3b009a3a 100644 --- a/common/Makefile +++ b/common/Makefile @@ -7,7 +7,7 @@ obj-$(CONFIG_ENV_HANDLING) += environment.o obj-$(CONFIG_AUTO_COMPLETE) += complete.o obj-$(CONFIG_POLLER) += poller.o obj-$(CONFIG_BLOCK) += block.o -obj-$(CONFIG_PARTITION_DISK) += partitions.o +obj-$(CONFIG_PARTITION_DISK) += partitions.o partitions/ obj-$(CONFIG_CMD_LOADS) += s_record.o obj-$(CONFIG_OFTREE) += oftree.o @@ -23,7 +23,7 @@ obj-$(CONFIG_MEMINFO) += meminfo.o obj-$(CONFIG_COMMAND_SUPPORT) += command.o obj-$(CONFIG_CONSOLE_FULL) += console.o obj-$(CONFIG_CONSOLE_SIMPLE) += console_simple.o -obj-$(CONFIG_CONSOLE_NONE) += console_none.o +obj-y += console_common.o obj-$(CONFIG_DIGEST) += digest.o obj-$(CONFIG_ENVIRONMENT_VARIABLES) += env.o obj-$(CONFIG_UIMAGE) += image.o diff --git a/common/console.c b/common/console.c index a085e2dfd3..beb37bddc1 100644 --- a/common/console.c +++ b/common/console.c @@ -305,24 +305,6 @@ void console_putc(unsigned int ch, char c) } EXPORT_SYMBOL(console_putc); -int fputc(int fd, char c) -{ - if(list_empty(&console_list)) { - if(!fd) - console_putc(0, c); - return 0; - } - - if (fd == 1) - putchar(c); - else if (fd == 2) - eputc(c); - else - return write(fd, &c, 1); - return 0; -} -EXPORT_SYMBOL(fputc); - int console_puts(unsigned int ch, const char *str) { const char *s = str; @@ -341,17 +323,6 @@ int console_puts(unsigned int ch, const char *str) } EXPORT_SYMBOL(console_puts); -int fputs(int fd, const char *s) -{ - if (fd == 1) - return puts(s); - else if (fd == 2) - return eputs(s); - else - return write(fd, s, strlen(s)); -} -EXPORT_SYMBOL(fputs); - void console_flush(void) { struct console_device *cdev; @@ -363,62 +334,6 @@ void console_flush(void) } EXPORT_SYMBOL(console_flush); -int fprintf(int file, const char *fmt, ...) -{ - va_list args; - char printbuffer[CFG_PBSIZE]; - - va_start (args, fmt); - - /* For this to work, printbuffer must be larger than - * anything we ever want to print. - */ - vsprintf (printbuffer, fmt, args); - va_end (args); - - /* Print the string */ - return fputs(file, printbuffer); -} -EXPORT_SYMBOL(fprintf); - -int printf (const char *fmt, ...) -{ - va_list args; - uint i; - char printbuffer[CFG_PBSIZE]; - - va_start (args, fmt); - - /* For this to work, printbuffer must be larger than - * anything we ever want to print. - */ - i = vsprintf (printbuffer, fmt, args); - va_end (args); - - /* Print the string */ - puts (printbuffer); - - return i; -} -EXPORT_SYMBOL(printf); - -int vprintf (const char *fmt, va_list args) -{ - uint i; - char printbuffer[CFG_PBSIZE]; - - /* For this to work, printbuffer must be larger than - * anything we ever want to print. - */ - i = vsprintf (printbuffer, fmt, args); - - /* Print the string */ - puts (printbuffer); - - return i; -} -EXPORT_SYMBOL(vprintf); - #ifndef ARCH_HAS_CTRLC /* test if ctrl-c was pressed */ int ctrlc (void) diff --git a/common/console_common.c b/common/console_common.c new file mode 100644 index 0000000000..d139d1a8fe --- /dev/null +++ b/common/console_common.c @@ -0,0 +1,110 @@ +/* + * based on code: + * + * (C) Copyright 2000 Paolo Scaffardi, AIRVENT SAM s.p.a - + * RIMINI(ITALY), arsenio@tin.it + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include <common.h> +#include <fs.h> +#include <errno.h> + +#ifndef CONFIG_CONSOLE_NONE + +int printf(const char *fmt, ...) +{ + va_list args; + uint i; + char printbuffer[CFG_PBSIZE]; + + va_start(args, fmt); + + /* + * For this to work, printbuffer must be larger than + * anything we ever want to print. + */ + i = vsprintf (printbuffer, fmt, args); + va_end(args); + + /* Print the string */ + puts(printbuffer); + + return i; +} +EXPORT_SYMBOL(printf); + +int vprintf(const char *fmt, va_list args) +{ + uint i; + char printbuffer[CFG_PBSIZE]; + + /* + * For this to work, printbuffer must be larger than + * anything we ever want to print. + */ + i = vsprintf(printbuffer, fmt, args); + + /* Print the string */ + puts(printbuffer); + + return i; +} +EXPORT_SYMBOL(vprintf); + +#endif /* !CONFIG_CONSOLE_NONE */ + +int fprintf(int file, const char *fmt, ...) +{ + va_list args; + char printbuffer[CFG_PBSIZE]; + + va_start(args, fmt); + + /* + * For this to work, printbuffer must be larger than + * anything we ever want to print. + */ + vsprintf(printbuffer, fmt, args); + va_end(args); + + /* Print the string */ + return fputs(file, printbuffer); +} +EXPORT_SYMBOL(fprintf); + +int fputs(int fd, const char *s) +{ + if (fd == 1) + return puts(s); + else if (fd == 2) + return eputs(s); + else + return write(fd, s, strlen(s)); +} +EXPORT_SYMBOL(fputs); + +int fputc(int fd, char c) +{ + if (fd == 1) + putchar(c); + else if (fd == 2) + eputc(c); + else + return write(fd, &c, 1); + + return 0; +} +EXPORT_SYMBOL(fputc); diff --git a/common/console_none.c b/common/console_none.c deleted file mode 100644 index b6018148d2..0000000000 --- a/common/console_none.c +++ /dev/null @@ -1,42 +0,0 @@ -#include <config.h> -#include <common.h> -#include <fs.h> -#include <errno.h> -#include <debug_ll.h> - -int fputc(int fd, char c) -{ - if (fd != 1 && fd != 2) - return write(fd, &c, 1); - return 0; -} -EXPORT_SYMBOL(fputc); - -int fputs(int fd, const char *s) -{ - if (fd != 1 && fd != 2) - return write(fd, s, strlen(s)); - return 0; -} -EXPORT_SYMBOL(fputs); - -int fprintf(int file, const char *fmt, ...) -{ - va_list args; - uint i; - char printbuffer[CFG_PBSIZE]; - - va_start (args, fmt); - - /* For this to work, printbuffer must be larger than - * anything we ever want to print. - */ - i = vsprintf (printbuffer, fmt, args); - va_end (args); - - /* Print the string */ - fputs(file, printbuffer); - - return i; -} -EXPORT_SYMBOL(fprintf); diff --git a/common/console_simple.c b/common/console_simple.c index a4d4315c72..1fe569ef9d 100644 --- a/common/console_simple.c +++ b/common/console_simple.c @@ -8,65 +8,6 @@ LIST_HEAD(console_list); EXPORT_SYMBOL(console_list); static struct console_device *console; -int printf (const char *fmt, ...) -{ - va_list args; - uint i; - char printbuffer[CFG_PBSIZE]; - - va_start (args, fmt); - - /* For this to work, printbuffer must be larger than - * anything we ever want to print. - */ - i = vsprintf (printbuffer, fmt, args); - va_end (args); - - /* Print the string */ - puts(printbuffer); - - return i; -} -EXPORT_SYMBOL(printf); - -int vprintf (const char *fmt, va_list args) -{ - uint i; - char printbuffer[CFG_PBSIZE]; - - /* For this to work, printbuffer must be larger than - * anything we ever want to print. - */ - i = vsprintf (printbuffer, fmt, args); - - /* Print the string */ - puts (printbuffer); - - return i; -} -EXPORT_SYMBOL(vprintf); - -int fprintf(int file, const char *fmt, ...) -{ - va_list args; - uint i; - char printbuffer[CFG_PBSIZE]; - - va_start (args, fmt); - - /* For this to work, printbuffer must be larger than - * anything we ever want to print. - */ - i = vsprintf (printbuffer, fmt, args); - va_end (args); - - /* Print the string */ - fputs(file, printbuffer); - - return i; -} -EXPORT_SYMBOL(fprintf); - int console_puts(unsigned int ch, const char *str) { const char *s = str; @@ -97,30 +38,6 @@ void console_putc(unsigned int ch, char c) } EXPORT_SYMBOL(console_putc); -int fputc(int fd, char c) -{ - if (fd == 1) - putchar(c); - else if (fd == 2) - eputc(c); - else - return write(fd, &c, 1); - return 0; -} -EXPORT_SYMBOL(fputc); - -int fputs(int fd, const char *s) -{ - if (fd == 1) - puts(s); - else if (fd == 2) - eputs(s); - else - return write(fd, s, strlen(s)); - return 0; -} -EXPORT_SYMBOL(fputs); - int tstc(void) { if (!console) diff --git a/common/environment.c b/common/environment.c index e8d623f7e4..78cd45cce7 100644 --- a/common/environment.c +++ b/common/environment.c @@ -363,3 +363,43 @@ out: free(buf_free); return ret; } + +#ifdef __BAREBOX__ +/** + * Try to register an environment storage on a device's partition + * @return 0 on success + * + * We rely on the existence of a usable storage device, already attached to + * our system, to get something like a persistent memory for our environment. + * We need to specify the partition number to use on this device. + * @param[in] devname Name of the device + * @param[in] partnr Partition number + * @return 0 on success, anything else in case of failure + */ + +int envfs_register_partition(const char *devname, unsigned int partnr) +{ + struct cdev *cdev; + char *partname; + + if (!devname) + return -EINVAL; + + cdev = cdev_by_name(devname); + if (cdev == NULL) { + pr_err("No %s present\n", devname); + return -ENODEV; + } + partname = asprintf("%s.%d", devname, partnr); + cdev = cdev_by_name(partname); + if (cdev == NULL) { + pr_err("No %s partition available\n", partname); + pr_info("Please create the partition %s to store the env\n", partname); + return -ENODEV; + } + + return devfs_add_partition(partname, 0, cdev->size, + DEVFS_PARTITION_FIXED, "env0"); +} +EXPORT_SYMBOL(envfs_register_partition); +#endif diff --git a/common/filetype.c b/common/filetype.c index 22fc621a14..8652f1d7af 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -48,6 +48,7 @@ static const struct filetype_str filetype_str[] = { [filetype_bmp] = { "BMP image", "bmp" }, [filetype_png] = { "PNG image", "png" }, [filetype_ext] = { "ext filesystem", "ext" }, + [filetype_gpt] = { "GUID Partition Table", "gpt" }, }; const char *file_type_to_string(enum filetype f) @@ -69,9 +70,53 @@ const char *file_type_to_short_string(enum filetype f) #define MBR_StartSector 8 /* MBR: Offset of Starting Sector in Partition Table Entry */ #define BS_55AA 510 /* Boot sector signature (2) */ #define MBR_Table 446 /* MBR: Partition table offset (2) */ +#define MBR_partition_size 16 /* MBR: Partition table offset (2) */ #define BS_FilSysType32 82 /* File system type (1) */ #define BS_FilSysType 54 /* File system type (1) */ +#define MBR_PART_sys_ind 4 +#define MBR_PART_start_sect 8 +#define MBR_OSTYPE_EFI_GPT 0xee + +static inline int pmbr_part_valid(const uint8_t *buf) +{ + if (buf[MBR_PART_sys_ind] == MBR_OSTYPE_EFI_GPT && + get_unaligned_le32(&buf[MBR_PART_start_sect]) == 1UL) { + return 1; + } + + return 0; +} + +/** + * is_gpt_valid(): test Protective MBR for validity and EFI PART + * @mbr: pointer to a legacy mbr structure + * + * Description: Returns 1 if PMBR is valid and EFI PART, 0 otherwise. + * Validity depends on three things: + * 1) MSDOS signature is in the last two bytes of the MBR + * 2) One partition of type 0xEE is found + * 3) EFI GPT signature is at offset 512 + */ +static int is_gpt_valid(const uint8_t *buf) +{ + int i; + + if (get_unaligned_le16(&buf[BS_55AA]) != 0xAA55) + return 0; + + if (strncmp(&buf[512], "EFI PART", 8)) + return 0; + + buf += MBR_Table; + + for (i = 0; i < 4; i++, buf += MBR_partition_size) { + if (pmbr_part_valid(buf)) + return 1; + } + return 0; +} + enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec) { /* @@ -159,6 +204,13 @@ 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); if (type != filetype_unknown) return type; diff --git a/common/hush.c b/common/hush.c index 1f468f601a..b5e111a019 100644 --- a/common/hush.c +++ b/common/hush.c @@ -335,6 +335,19 @@ static int b_addchr(o_string *o, int ch) return 0; } +static int b_addstr(o_string *o, const char *str) +{ + int ret; + + while (*str) { + ret = b_addchr(o, *str++); + if (ret) + return ret; + } + + return 0; +} + static void b_reset(o_string *o) { o->length = 0; @@ -782,7 +795,8 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi) remove_quotes(globbuf.gl_pathc, globbuf.gl_pathv); - if (!strcmp(globbuf.gl_pathv[0], "getopt")) { + if (!strcmp(globbuf.gl_pathv[0], "getopt") && + IS_ENABLED(CONFIG_HUSH_GETOPT)) { ret = builtin_getopt(ctx, child, globbuf.gl_pathc, globbuf.gl_pathv); } else if (!strcmp(globbuf.gl_pathv[0], "exit")) { ret = builtin_exit(ctx, child, globbuf.gl_pathc, globbuf.gl_pathv); @@ -1406,6 +1420,14 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i } b_addchr(dest, SPECIAL_VAR_SYMBOL); break; + case '*': + for (i = 1; i < ctx->global_argc; i++) { + b_addstr(dest, ctx->global_argv[i]); + b_addchr(dest, ' '); + } + + advance = 1; + break; default: b_addchr(dest, '$'); } diff --git a/common/memsize.c b/common/memsize.c index d149e41845..ef6381babd 100644 --- a/common/memsize.c +++ b/common/memsize.c @@ -33,6 +33,9 @@ * Check memory range for valid RAM. A simple memory test determines * the actually available RAM size between addresses `base' and * `base + maxsize'. + * + * This function modifies the RAM. Do not use it if you're running from + * the RAM you are going to detect! */ long get_ram_size(volatile long *base, long maxsize) { diff --git a/common/menu.c b/common/menu.c index ce93838f74..a672e59c0b 100644 --- a/common/menu.c +++ b/common/menu.c @@ -274,7 +274,7 @@ int menu_show(struct menu *m) printf("Auto Select in"); } else { auto_display_len = strlen(m->auto_display); - printf(m->auto_display); + printf("%s", m->auto_display); } printf(" %2d", countdown--); } diff --git a/common/oftree.c b/common/oftree.c index 0df5209bda..82e5ddd60b 100644 --- a/common/oftree.c +++ b/common/oftree.c @@ -229,6 +229,33 @@ void do_fixup_by_path_u32(struct fdt_header *fdt, const char *path, do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create); } +void do_fixup_by_compatible(struct fdt_header *fdt, const char *compatible, + const char *prop, const void *val, int len, int create) +{ + int off = -1; + + off = fdt_node_offset_by_compatible(fdt, -1, compatible); + while (off != -FDT_ERR_NOTFOUND) { + if (create || (fdt_get_property(fdt, off, prop, 0) != NULL)) + fdt_setprop(fdt, off, prop, val, len); + off = fdt_node_offset_by_compatible(fdt, off, compatible); + } +} + +void do_fixup_by_compatible_u32(struct fdt_header *fdt, const char *compatible, + const char *prop, u32 val, int create) +{ + val = cpu_to_fdt32(val); + do_fixup_by_compatible(fdt, compatible, prop, &val, 4, create); +} + +void do_fixup_by_compatible_string(struct fdt_header *fdt, const char *compatible, + const char *prop, const char *val, int create) +{ + do_fixup_by_compatible(fdt, compatible, prop, val, strlen(val) + 1, + create); +} + int fdt_get_path_or_create(struct fdt_header *fdt, const char *path) { int nodeoffset; @@ -246,6 +273,72 @@ int fdt_get_path_or_create(struct fdt_header *fdt, const char *path) return nodeoffset; } +int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force) +{ + int nodeoffset; + int err, j, total; + u32 tmp; + const char *path; + uint64_t addr, size; + + /* Find the "chosen" node */ + nodeoffset = fdt_path_offset(fdt, "/chosen"); + + /* If there is no "chosen" node in the blob return */ + if (nodeoffset < 0) { + printf("fdt_initrd: %s\n", fdt_strerror(nodeoffset)); + return nodeoffset; + } + + /* just return if initrd_start/end aren't valid */ + if ((initrd_start == 0) || (initrd_end == 0)) + return 0; + + total = fdt_num_mem_rsv(fdt); + + /* + * Look for an existing entry and update it. If we don't find + * the entry, we will j be the next available slot. + */ + for (j = 0; j < total; j++) { + err = fdt_get_mem_rsv(fdt, j, &addr, &size); + if (addr == initrd_start) { + fdt_del_mem_rsv(fdt, j); + break; + } + } + + err = fdt_add_mem_rsv(fdt, initrd_start, initrd_end - initrd_start); + if (err < 0) { + printf("fdt_initrd: %s\n", fdt_strerror(err)); + return err; + } + + path = fdt_getprop(fdt, nodeoffset, "linux,initrd-start", NULL); + if (!path || force) { + tmp = __cpu_to_be32(initrd_start); + err = fdt_setprop(fdt, nodeoffset, + "linux,initrd-start", &tmp, sizeof(tmp)); + if (err < 0) { + printf("WARNING: " + "could not set linux,initrd-start %s.\n", + fdt_strerror(err)); + return err; + } + tmp = __cpu_to_be32(initrd_end); + err = fdt_setprop(fdt, nodeoffset, + "linux,initrd-end", &tmp, sizeof(tmp)); + if (err < 0) { + printf("WARNING: could not set linux,initrd-end %s.\n", + fdt_strerror(err)); + + return err; + } + } + + return 0; +} + static int of_fixup_bootargs(struct fdt_header *fdt) { int nodeoffset; diff --git a/common/partitions.c b/common/partitions.c index 24310a3a4f..dd25160602 100644 --- a/common/partitions.c +++ b/common/partitions.c @@ -27,112 +27,87 @@ #include <block.h> #include <asm/unaligned.h> #include <disks.h> -#include <dma.h> #include <filetype.h> +#include <dma.h> -struct partition { - uint64_t first_sec; - uint64_t size; -}; +#include "partitions/parser.h" -struct partition_desc { - int used_entries; - struct partition parts[8]; -}; +static LIST_HEAD(partition_parser_list); /** - * Guess the size of the disk, based on the partition table entries - * @param dev device to create partitions for - * @param table partition table - * @return sector count + * Register one partition on the given block device + * @param blk Block device to register to + * @param part Partition description + * @param no Partition number + * @return 0 on success */ -static int disk_guess_size(struct device_d *dev, struct partition_entry *table) +static int register_one_partition(struct block_device *blk, + struct partition *part, int no) { - uint64_t size = 0; - int i; - - for (i = 0; i < 4; i++) { - if (table[i].partition_start != 0) { - size += get_unaligned_le32(&table[i].partition_start) - size; - size += get_unaligned_le32(&table[i].partition_size); - } - } + char *partition_name; + int ret; + uint64_t start = part->first_sec * SECTOR_SIZE; + uint64_t size = part->size * SECTOR_SIZE; + + partition_name = asprintf("%s.%d", blk->cdev.name, no); + if (!partition_name) + return -ENOMEM; + dev_dbg(blk->dev, "Registering partition %s on drive %s\n", + partition_name, blk->cdev.name); + ret = devfs_add_partition(blk->cdev.name, + start, size, 0, partition_name); + if (ret) + goto out; - return (int)size; -} + free(partition_name); -/** - * Check if a DOS like partition describes this block device - * @param blk Block device to register to - * @param pd Where to store the partition information - * - * It seems at least on ARM this routine canot use temp. stack space for the - * sector. So, keep the malloc/free. - */ -static void __maybe_unused try_dos_partition(struct block_device *blk, - struct partition_desc *pd) -{ - uint8_t *buffer; - struct partition_entry *table; - struct partition pentry; - int i, rc; + if (!part->name[0]) + return 0; - buffer = dma_alloc(SECTOR_SIZE); + partition_name = asprintf("%s.%s", blk->cdev.name, part->name); + if (!partition_name) + return -ENOMEM; - /* read in the MBR to get the partition table */ - rc = blk->ops->read(blk, buffer, 0, 1); - if (rc != 0) { - dev_err(blk->dev, "Cannot read MBR/partition table\n"); - goto on_error; - } + dev_dbg(blk->dev, "Registering partition %s on drive %s\n", + partition_name, blk->cdev.name); + ret = devfs_add_partition(blk->cdev.name, + start, size, 0, partition_name); - if (is_fat_or_mbr(buffer, NULL) != filetype_mbr) { - dev_info(blk->dev, "No partition table found\n"); - goto on_error; - } + if (ret) + dev_warn(blk->dev, "Registering partition %s on drive %s failed\n", + partition_name, blk->cdev.name); - table = (struct partition_entry *)&buffer[446]; + ret = 0; +out: + free(partition_name); + return 0; +} - /* valid for x86 BIOS based disks only */ - if (IS_ENABLED(CONFIG_DISK_BIOS) && blk->num_blocks == 0) - blk->num_blocks = disk_guess_size(blk->dev, table); +static struct partition_parser *partition_parser_get_by_filetype(uint8_t *buf) +{ + enum filetype type; + struct partition_parser *parser; - for (i = 0; i < 4; i++) { - pentry.first_sec = get_unaligned_le32(&table[i].partition_start); - pentry.size = get_unaligned_le32(&table[i].partition_size); + /* first new partition table as EFI GPT */ + type = file_detect_type(buf, SECTOR_SIZE * 2); - if (pentry.first_sec != 0) { - pd->parts[pd->used_entries].first_sec = pentry.first_sec; - pd->parts[pd->used_entries].size = pentry.size; - pd->used_entries++; - } else { - dev_dbg(blk->dev, "Skipping empty partition %d\n", i); - } + list_for_each_entry(parser, &partition_parser_list, list) { + if (parser->type == type) + return parser; } -on_error: - dma_free(buffer); -} + /* if not parser found search for old one + * so if EFI GPT not enable take it as MBR + * useful for compatibility + */ + type = file_detect_type(buf, SECTOR_SIZE); -/** - * Register one partition on the given block device - * @param blk Block device to register to - * @param part Partition description - * @param no Partition number - * @return 0 on success - */ -static int register_one_partition(struct block_device *blk, - struct partition *part, int no) -{ - char partition_name[19]; + list_for_each_entry(parser, &partition_parser_list, list) { + if (parser->type == type) + return parser; + } - sprintf(partition_name, "%s.%d", blk->cdev.name, no); - dev_dbg(blk->dev, "Registering partition %s on drive %s\n", - partition_name, blk->cdev.name); - return devfs_add_partition(blk->cdev.name, - part->first_sec * SECTOR_SIZE, - part->size * SECTOR_SIZE, - 0, partition_name); + return NULL; } /** @@ -144,19 +119,33 @@ static int register_one_partition(struct block_device *blk, */ int parse_partition_table(struct block_device *blk) { - struct partition_desc pdesc = { .used_entries = 0, }; + struct partition_desc *pdesc; int i; int rc = 0; + struct partition_parser *parser; + uint8_t *buf; -#ifdef CONFIG_PARTITION_DISK_DOS - try_dos_partition(blk, &pdesc); -#endif - if (!pdesc.used_entries) - return 0; + pdesc = xzalloc(sizeof(*pdesc)); + buf = dma_alloc(SECTOR_SIZE * 2); + + rc = blk->ops->read(blk, buf, 0, 2); + if (rc != 0) { + dev_err(blk->dev, "Cannot read MBR/partition table\n"); + goto on_error; + } + + parser = partition_parser_get_by_filetype(buf); + if (!parser) + goto on_error; + + parser->parse(buf, blk, pdesc); + + if (!pdesc->used_entries) + goto on_error; /* at least one partition description found */ - for (i = 0; i < pdesc.used_entries; i++) { - rc = register_one_partition(blk, &pdesc.parts[i], i); + for (i = 0; i < pdesc->used_entries; i++) { + rc = register_one_partition(blk, &pdesc->parts[i], i); if (rc != 0) dev_err(blk->dev, "Failed to register partition %d on %s (%d)\n", @@ -165,5 +154,15 @@ int parse_partition_table(struct block_device *blk) rc = 0; } +on_error: + dma_free(buf); + free(pdesc); return rc; } + +int partition_parser_register(struct partition_parser *p) +{ + list_add_tail(&p->list, &partition_parser_list); + + return 0; +} diff --git a/common/partitions/Kconfig b/common/partitions/Kconfig new file mode 100644 index 0000000000..077091cde2 --- /dev/null +++ b/common/partitions/Kconfig @@ -0,0 +1,32 @@ +config PARTITION_DISK + depends on PARTITION + bool "DISK partition support" + help + Add support for handling common partition tables on all kind of disk + like devices (harddisks, CF cards, SD cards and so on) + +config PARTITION_DISK_DOS + depends on PARTITION_DISK + default y + bool "DOS partition support" + help + Add support to handle partitions in DOS style. + +config PARTITION_DISK_EFI + depends on PARTITION_DISK + select CRC32 + bool "EFI: GPT partition support" + help + Add support to handle partitions in GUID Partition Table style. + +config PARTITION_DISK_EFI_GPT_NO_FORCE + depends on PARTITION_DISK_EFI + default y + bool "EFI: GPT: force test Protective MBR for validity" + help + This will be added to the EFI Spec. per Intel after v1.02 + +config PARTITION_DISK_EFI_GPT_COMPARE + depends on PARTITION_DISK_EFI + default y + bool "EFI: GPT: compare primary and Alternate GPT header for validity" diff --git a/common/partitions/Makefile b/common/partitions/Makefile new file mode 100644 index 0000000000..2b0c5b4b9c --- /dev/null +++ b/common/partitions/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_PARTITION_DISK_DOS) += dos.o +obj-$(CONFIG_PARTITION_DISK_EFI) += efi.o diff --git a/common/partitions/dos.c b/common/partitions/dos.c new file mode 100644 index 0000000000..597f9ba581 --- /dev/null +++ b/common/partitions/dos.c @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2009...2011 Juergen Beisert, Pengutronix + * + * 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 <disks.h> +#include <init.h> +#include <asm/unaligned.h> + +#include "parser.h" + +/** + * Guess the size of the disk, based on the partition table entries + * @param dev device to create partitions for + * @param table partition table + * @return sector count + */ +static int disk_guess_size(struct device_d *dev, struct partition_entry *table) +{ + uint64_t size = 0; + int i; + + for (i = 0; i < 4; i++) { + if (table[i].partition_start != 0) { + size += get_unaligned_le32(&table[i].partition_start) - size; + size += get_unaligned_le32(&table[i].partition_size); + } + } + + return (int)size; +} + +/** + * Check if a DOS like partition describes this block device + * @param blk Block device to register to + * @param pd Where to store the partition information + * + * It seems at least on ARM this routine canot use temp. stack space for the + * sector. So, keep the malloc/free. + */ +static void dos_partition(void *buf, struct block_device *blk, + struct partition_desc *pd) +{ + struct partition_entry *table; + struct partition pentry; + uint8_t *buffer = buf; + int i; + + table = (struct partition_entry *)&buffer[446]; + + /* valid for x86 BIOS based disks only */ + if (IS_ENABLED(CONFIG_DISK_BIOS) && blk->num_blocks == 0) + blk->num_blocks = disk_guess_size(blk->dev, table); + + for (i = 0; i < 4; i++) { + pentry.first_sec = get_unaligned_le32(&table[i].partition_start); + pentry.size = get_unaligned_le32(&table[i].partition_size); + + if (pentry.first_sec != 0) { + pd->parts[pd->used_entries].first_sec = pentry.first_sec; + pd->parts[pd->used_entries].size = pentry.size; + pd->used_entries++; + } else { + dev_dbg(blk->dev, "Skipping empty partition %d\n", i); + } + } +} + +static struct partition_parser dos = { + .parse = dos_partition, + .type = filetype_mbr, +}; + +static int dos_partition_init(void) +{ + return partition_parser_register(&dos); +} +postconsole_initcall(dos_partition_init); diff --git a/common/partitions/efi.c b/common/partitions/efi.c new file mode 100644 index 0000000000..e450eebf77 --- /dev/null +++ b/common/partitions/efi.c @@ -0,0 +1,477 @@ +/************************************************************ + * EFI GUID Partition Table handling + * + * http://www.uefi.org/specs/ + * http://www.intel.com/technology/efi/ + * + * efi.[ch] by Matt Domsch <Matt_Domsch@dell.com> + * Copyright 2000,2001,2002,2004 Dell Inc. + * + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> + * + * Under GPLv2 only + */ + +#include <common.h> +#include <disks.h> +#include <init.h> +#include <asm/unaligned.h> +#include <dma.h> +#include <linux/ctype.h> + +#include "efi.h" +#include "parser.h" + +static int force_gpt = IS_ENABLED(CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE); + +/** + * efi_crc32() - EFI version of crc32 function + * @buf: buffer to calculate crc32 of + * @len - length of buf + * + * Description: Returns EFI-style CRC32 value for @buf + * + * This function uses the little endian Ethernet polynomial + * but seeds the function with ~0, and xor's with ~0 at the end. + * Note, the EFI Specification, v1.02, has a reference to + * Dr. Dobbs Journal, May 1994 (actually it's in May 1992). + */ +static inline u32 +efi_crc32(const void *buf, unsigned long len) +{ + return crc32(0, buf, len); +} + +/** + * last_lba(): return number of last logical block of device + * @bdev: block device + * + * Description: Returns last LBA value on success, 0 on error. + * This is stored (by sd and ide-geometry) in + * the part[0] entry for this disk, and is the number of + * physical sectors available on the disk. + */ +static u64 last_lba(struct block_device *bdev) +{ + if (!bdev) + return 0; + return bdev->num_blocks; +} + +/** + * alloc_read_gpt_entries(): reads partition entries from disk + * @dev_desc + * @gpt - GPT header + * + * Description: Returns ptes on success, NULL on error. + * Allocates space for PTEs based on information found in @gpt. + * Notes: remember to free pte when you're done! + */ +static gpt_entry *alloc_read_gpt_entries(struct block_device *blk, + gpt_header * pgpt_head) +{ + size_t count = 0; + gpt_entry *pte = NULL; + unsigned long from, size; + int ret; + + count = le32_to_cpu(pgpt_head->num_partition_entries) * + le32_to_cpu(pgpt_head->sizeof_partition_entry); + + if (!count) + return NULL; + pte = kzalloc(count, GFP_KERNEL); + if (!pte) + return NULL; + + from = le64_to_cpu(pgpt_head->partition_entry_lba); + size = count / GPT_BLOCK_SIZE; + ret = blk->ops->read(blk, pte, from, size); + if (ret) { + kfree(pte); + pte=NULL; + return NULL; + } + return pte; +} + +static inline unsigned short bdev_logical_block_size(struct block_device +*bdev) +{ + return SECTOR_SIZE; +} + +/** + * alloc_read_gpt_header(): Allocates GPT header, reads into it from disk + * @state + * @lba is the Logical Block Address of the partition table + * + * Description: returns GPT header on success, NULL on error. Allocates + * and fills a GPT header starting at @ from @state->bdev. + * Note: remember to free gpt when finished with it. + */ +static gpt_header *alloc_read_gpt_header(struct block_device *blk, + u64 lba) +{ + gpt_header *gpt; + unsigned ssz = bdev_logical_block_size(blk); + int ret; + + gpt = kzalloc(ssz, GFP_KERNEL); + if (!gpt) + return NULL; + + ret = blk->ops->read(blk, gpt, lba, 1); + if (ret) { + kfree(gpt); + gpt=NULL; + return NULL; + } + + return gpt; +} + +/** + * is_gpt_valid() - tests one GPT header and PTEs for validity + * + * lba is the logical block address of the GPT header to test + * gpt is a GPT header ptr, filled on return. + * ptes is a PTEs ptr, filled on return. + * + * Description: returns 1 if valid, 0 on error. + * If valid, returns pointers to PTEs. + */ +static int is_gpt_valid(struct block_device *blk, u64 lba, + gpt_header **gpt, gpt_entry **ptes) +{ + u32 crc, origcrc; + u64 lastlba; + + if (!ptes) + return 0; + if (!(*gpt = alloc_read_gpt_header(blk, lba))) + return 0; + + /* Check the GPT header signature */ + if (le64_to_cpu((*gpt)->signature) != GPT_HEADER_SIGNATURE) { + dev_dbg(blk->dev, "GUID Partition Table Header signature is wrong:" + "0x%llX != 0x%llX\n", + (unsigned long long)le64_to_cpu((*gpt)->signature), + (unsigned long long)GPT_HEADER_SIGNATURE); + goto fail; + } + + /* Check the GUID Partition Table CRC */ + origcrc = le32_to_cpu((*gpt)->header_crc32); + (*gpt)->header_crc32 = 0; + crc = efi_crc32((const unsigned char *) (*gpt), le32_to_cpu((*gpt)->header_size)); + + if (crc != origcrc) { + dev_dbg(blk->dev, "GUID Partition Table Header CRC is wrong: %x != %x\n", + crc, origcrc); + goto fail; + } + (*gpt)->header_crc32 = cpu_to_le32(origcrc); + + /* Check that the my_lba entry points to the LBA that contains + * the GUID Partition Table */ + if (le64_to_cpu((*gpt)->my_lba) != lba) { + dev_dbg(blk->dev, "GPT: my_lba incorrect: %llX != %llX\n", + (unsigned long long)le64_to_cpu((*gpt)->my_lba), + (unsigned long long)lba); + goto fail; + } + + /* Check the first_usable_lba and last_usable_lba are within the disk. */ + lastlba = last_lba(blk); + if (le64_to_cpu((*gpt)->first_usable_lba) > lastlba) { + dev_dbg(blk->dev, "GPT: first_usable_lba incorrect: %lld > %lld\n", + (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba), + (unsigned long long)lastlba); + goto fail; + } + if (le64_to_cpu((*gpt)->last_usable_lba) > lastlba) { + dev_dbg(blk->dev, "GPT: last_usable_lba incorrect: %lld > %lld\n", + (unsigned long long)le64_to_cpu((*gpt)->last_usable_lba), + (unsigned long long)lastlba); + goto fail; + } + + if (!(*ptes = alloc_read_gpt_entries(blk, *gpt))) + goto fail; + + /* Check the GUID Partition Table Entry Array CRC */ + crc = efi_crc32((const unsigned char *)*ptes, + le32_to_cpu((*gpt)->num_partition_entries) * + le32_to_cpu((*gpt)->sizeof_partition_entry)); + + if (crc != le32_to_cpu((*gpt)->partition_entry_array_crc32)) { + dev_dbg(blk->dev, "GUID Partitition Entry Array CRC check failed.\n"); + goto fail_ptes; + } + + /* We're done, all's well */ + return 1; + + fail_ptes: + kfree(*ptes); + *ptes = NULL; + fail: + kfree(*gpt); + *gpt = NULL; + return 0; +} + +/** + * is_pte_valid() - tests one PTE for validity + * @pte is the pte to check + * @lastlba is last lba of the disk + * + * Description: returns 1 if valid, 0 on error. + */ +static inline int +is_pte_valid(const gpt_entry *pte, const u64 lastlba) +{ + if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) || + le64_to_cpu(pte->starting_lba) > lastlba || + le64_to_cpu(pte->ending_lba) > lastlba) + return 0; + return 1; +} + +/** + * compare_gpts() - Search disk for valid GPT headers and PTEs + * @pgpt is the primary GPT header + * @agpt is the alternate GPT header + * @lastlba is the last LBA number + * Description: Returns nothing. Sanity checks pgpt and agpt fields + * and prints warnings on discrepancies. + * + */ +static void +compare_gpts(struct device_d *dev, gpt_header *pgpt, gpt_header *agpt, u64 lastlba) +{ + int error_found = 0; + if (!pgpt || !agpt) + return; + if (le64_to_cpu(pgpt->my_lba) != le64_to_cpu(agpt->alternate_lba)) { + dev_warn(dev, + "GPT:Primary header LBA != Alt. header alternate_lba\n"); + dev_warn(dev, "GPT:%lld != %lld\n", + (unsigned long long)le64_to_cpu(pgpt->my_lba), + (unsigned long long)le64_to_cpu(agpt->alternate_lba)); + error_found++; + } + if (le64_to_cpu(pgpt->alternate_lba) != le64_to_cpu(agpt->my_lba)) { + dev_warn(dev, + "GPT:Primary header alternate_lba != Alt. header my_lba\n"); + dev_warn(dev, "GPT:%lld != %lld\n", + (unsigned long long)le64_to_cpu(pgpt->alternate_lba), + (unsigned long long)le64_to_cpu(agpt->my_lba)); + error_found++; + } + if (le64_to_cpu(pgpt->first_usable_lba) != + le64_to_cpu(agpt->first_usable_lba)) { + dev_warn(dev, "GPT:first_usable_lbas don't match.\n"); + dev_warn(dev, "GPT:%lld != %lld\n", + (unsigned long long)le64_to_cpu(pgpt->first_usable_lba), + (unsigned long long)le64_to_cpu(agpt->first_usable_lba)); + error_found++; + } + if (le64_to_cpu(pgpt->last_usable_lba) != + le64_to_cpu(agpt->last_usable_lba)) { + dev_warn(dev, "GPT:last_usable_lbas don't match.\n"); + dev_warn(dev, "GPT:%lld != %lld\n", + (unsigned long long)le64_to_cpu(pgpt->last_usable_lba), + (unsigned long long)le64_to_cpu(agpt->last_usable_lba)); + error_found++; + } + if (efi_guidcmp(pgpt->disk_guid, agpt->disk_guid)) { + dev_warn(dev, "GPT:disk_guids don't match.\n"); + error_found++; + } + if (le32_to_cpu(pgpt->num_partition_entries) != + le32_to_cpu(agpt->num_partition_entries)) { + dev_warn(dev, "GPT:num_partition_entries don't match: " + "0x%x != 0x%x\n", + le32_to_cpu(pgpt->num_partition_entries), + le32_to_cpu(agpt->num_partition_entries)); + error_found++; + } + if (le32_to_cpu(pgpt->sizeof_partition_entry) != + le32_to_cpu(agpt->sizeof_partition_entry)) { + dev_warn(dev, + "GPT:sizeof_partition_entry values don't match: " + "0x%x != 0x%x\n", + le32_to_cpu(pgpt->sizeof_partition_entry), + le32_to_cpu(agpt->sizeof_partition_entry)); + error_found++; + } + if (le32_to_cpu(pgpt->partition_entry_array_crc32) != + le32_to_cpu(agpt->partition_entry_array_crc32)) { + dev_warn(dev, + "GPT:partition_entry_array_crc32 values don't match: " + "0x%x != 0x%x\n", + le32_to_cpu(pgpt->partition_entry_array_crc32), + le32_to_cpu(agpt->partition_entry_array_crc32)); + error_found++; + } + if (le64_to_cpu(pgpt->alternate_lba) != lastlba) { + dev_warn(dev, + "GPT:Primary header thinks Alt. header is not at the end of the disk.\n"); + dev_warn(dev, "GPT:%lld != %lld\n", + (unsigned long long)le64_to_cpu(pgpt->alternate_lba), + (unsigned long long)lastlba); + error_found++; + } + + if (le64_to_cpu(agpt->my_lba) != lastlba) { + dev_warn(dev, + "GPT:Alternate GPT header not at the end of the disk.\n"); + dev_warn(dev, "GPT:%lld != %lld\n", + (unsigned long long)le64_to_cpu(agpt->my_lba), + (unsigned long long)lastlba); + error_found++; + } + + if (error_found) + dev_warn(dev, "GPT: Use GNU Parted to correct GPT errors.\n"); + return; +} + +/** + * find_valid_gpt() - Search disk for valid GPT headers and PTEs + * @state + * @gpt is a GPT header ptr, filled on return. + * @ptes is a PTEs ptr, filled on return. + * Description: Returns 1 if valid, 0 on error. + * If valid, returns pointers to newly allocated GPT header and PTEs. + * Validity depends on PMBR being valid (or being overridden by the + * 'gpt' kernel command line option) and finding either the Primary + * GPT header and PTEs valid, or the Alternate GPT header and PTEs + * valid. If the Primary GPT header is not valid, the Alternate GPT header + * is not checked unless the 'gpt' kernel command line option is passed. + * This protects against devices which misreport their size, and forces + * the user to decide to use the Alternate GPT. + */ +static int find_valid_gpt(void *buf, struct block_device *blk, gpt_header **gpt, + gpt_entry **ptes) +{ + int good_pgpt = 0, good_agpt = 0; + gpt_header *pgpt = NULL, *agpt = NULL; + gpt_entry *pptes = NULL, *aptes = NULL; + u64 lastlba; + + if (!ptes) + return 0; + + lastlba = last_lba(blk); + if (force_gpt) { + /* This will be added to the EFI Spec. per Intel after v1.02. */ + if (file_detect_type(buf, SECTOR_SIZE * 2) != filetype_gpt) + goto fail; + } + + good_pgpt = is_gpt_valid(blk, GPT_PRIMARY_PARTITION_TABLE_LBA, + &pgpt, &pptes); + if (good_pgpt) + good_agpt = is_gpt_valid(blk, + le64_to_cpu(pgpt->alternate_lba), + &agpt, &aptes); + if (!good_agpt && force_gpt) + good_agpt = is_gpt_valid(blk, lastlba, &agpt, &aptes); + + /* The obviously unsuccessful case */ + if (!good_pgpt && !good_agpt) + goto fail; + + if (IS_ENABLED(CONFIG_PARTITION_DISK_EFI_GPT_COMPARE)) + compare_gpts(blk->dev, pgpt, agpt, lastlba); + + /* The good cases */ + if (good_pgpt) { + *gpt = pgpt; + *ptes = pptes; + kfree(agpt); + kfree(aptes); + if (!good_agpt) + dev_warn(blk->dev, "Alternate GPT is invalid, using primary GPT.\n"); + return 1; + } + else if (good_agpt) { + *gpt = agpt; + *ptes = aptes; + kfree(pgpt); + kfree(pptes); + dev_warn(blk->dev, "Primary GPT is invalid, using alternate GPT.\n"); + return 1; + } + + fail: + kfree(pgpt); + kfree(agpt); + kfree(pptes); + kfree(aptes); + *gpt = NULL; + *ptes = NULL; + return 0; +} + +static void part_set_efi_name(gpt_entry *pte, char *dest) +{ + int i; + + for (i = 0; i < GPT_PARTNAME_MAX_SIZE ; i++) { + u8 c; + c = pte->partition_name[i] & 0xff; + c = (c && !isprint(c)) ? '.' : c; + dest[i] = c; + } + dest[i] = 0; +} + +static void efi_partition(void *buf, struct block_device *blk, + struct partition_desc *pd) +{ + gpt_header *gpt = NULL; + gpt_entry *ptes = NULL; + int i = 0; + int nb_part; + struct partition *pentry; + + if (!find_valid_gpt(buf, blk, &gpt, &ptes) || !gpt || !ptes) { + kfree(gpt); + kfree(ptes); + return; + } + + nb_part = le32_to_cpu(gpt->num_partition_entries); + for (i = 0; i < MAX_PARTITION && i < nb_part; i++) { + if (!is_pte_valid(&ptes[i], last_lba(blk))) { + dev_dbg(blk->dev, "Invalid pte %d\n", i); + return; + } + + pentry = &pd->parts[pd->used_entries]; + pentry->first_sec = le64_to_cpu(ptes[i].starting_lba); + pentry->size = le64_to_cpu(ptes[i].ending_lba) - pentry->first_sec; + pentry->size++; + part_set_efi_name(&ptes[i], pentry->name); + pd->used_entries++; + } + + if (i > MAX_PARTITION) + dev_warn(blk->dev, "num_partition_entries (%d) > max partition number (%d)\n", + nb_part, MAX_PARTITION); +} + +static struct partition_parser efi_partition_parser = { + .parse = efi_partition, + .type = filetype_gpt, +}; + +static int efi_partition_init(void) +{ + return partition_parser_register(&efi_partition_parser); +} +postconsole_initcall(efi_partition_init); diff --git a/common/partitions/efi.h b/common/partitions/efi.h new file mode 100644 index 0000000000..c7734bd403 --- /dev/null +++ b/common/partitions/efi.h @@ -0,0 +1,123 @@ +/************************************************************ + * EFI GUID Partition Table + * Per Intel EFI Specification v1.02 + * http://developer.intel.com/technology/efi/efi.htm + * + * By Matt Domsch <Matt_Domsch@dell.com> Fri Sep 22 22:15:56 CDT 2000 + * Copyright 2000,2001 Dell Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************/ + +#ifndef FS_PART_EFI_H_INCLUDED +#define FS_PART_EFI_H_INCLUDED + +#include <linux/efi.h> + +#define MSDOS_MBR_SIGNATURE 0xaa55 +#define EFI_PMBR_OSTYPE_EFI 0xEF +#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE + +#define GPT_BLOCK_SIZE 512 +#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL +#define GPT_HEADER_REVISION_V1 0x00010000 +#define GPT_PRIMARY_PARTITION_TABLE_LBA 1 + +#define PARTITION_SYSTEM_GUID \ + EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \ + 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B) +#define LEGACY_MBR_PARTITION_GUID \ + EFI_GUID( 0x024DEE41, 0x33E7, 0x11d3, \ + 0x9D, 0x69, 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F) +#define PARTITION_MSFT_RESERVED_GUID \ + EFI_GUID( 0xE3C9E316, 0x0B5C, 0x4DB8, \ + 0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE) +#define PARTITION_BASIC_DATA_GUID \ + EFI_GUID( 0xEBD0A0A2, 0xB9E5, 0x4433, \ + 0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7) +#define PARTITION_LINUX_RAID_GUID \ + EFI_GUID( 0xa19d880f, 0x05fc, 0x4d3b, \ + 0xa0, 0x06, 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e) +#define PARTITION_LINUX_SWAP_GUID \ + EFI_GUID( 0x0657fd6d, 0xa4ab, 0x43c4, \ + 0x84, 0xe5, 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f) +#define PARTITION_LINUX_LVM_GUID \ + EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \ + 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28) + +/* based on linux/include/genhd.h */ +struct legacy_partition { + unsigned char boot_ind; /* 0x80 - active */ + unsigned char head; /* starting head */ + unsigned char sector; /* starting sector */ + unsigned char cyl; /* starting cylinder */ + unsigned char sys_ind; /* What partition type */ + unsigned char end_head; /* end head */ + unsigned char end_sector; /* end sector */ + unsigned char end_cyl; /* end cylinder */ + __le32 start_sect; /* starting sector counting from 0 */ + __le32 nr_sects; /* nr of sectors in partition */ +} __attribute__ ((packed)); + +/* based on linux/fs/partitions/efi.h */ +typedef struct _gpt_header { + __le64 signature; + __le32 revision; + __le32 header_size; + __le32 header_crc32; + __le32 reserved1; + __le64 my_lba; + __le64 alternate_lba; + __le64 first_usable_lba; + __le64 last_usable_lba; + efi_guid_t disk_guid; + __le64 partition_entry_lba; + __le32 num_partition_entries; + __le32 sizeof_partition_entry; + __le32 partition_entry_array_crc32; + + /* The rest of the logical block is reserved by UEFI and must be zero. + * EFI standard handles this by: + * + * uint8_t reserved2[ BlockSize - 92 ]; + */ +} __attribute__ ((packed)) gpt_header; + +typedef struct _gpt_entry_attributes { + u64 required_to_function:1; + u64 reserved:47; + u64 type_guid_specific:16; +} __attribute__ ((packed)) gpt_entry_attributes; + +#define GPT_PARTNAME_MAX_SIZE (72 / sizeof (efi_char16_t)) +typedef struct _gpt_entry { + efi_guid_t partition_type_guid; + efi_guid_t unique_partition_guid; + __le64 starting_lba; + __le64 ending_lba; + gpt_entry_attributes attributes; + efi_char16_t partition_name[GPT_PARTNAME_MAX_SIZE]; +} __attribute__ ((packed)) gpt_entry; + +typedef struct _legacy_mbr { + u8 boot_code[440]; + __le32 unique_mbr_signature; + __le16 unknown; + struct legacy_partition partition_record[4]; + __le16 signature; +} __attribute__ ((packed)) legacy_mbr; + +#endif /* _DISK_PART_EFI_H */ diff --git a/common/partitions/parser.h b/common/partitions/parser.h new file mode 100644 index 0000000000..f5bdbd1442 --- /dev/null +++ b/common/partitions/parser.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> + * + * Under GPLv2 only + */ + +#ifndef __PARTITIONS_PARSER_H__ +#define __PARTITIONS_PARSER_H__ + +#include <block.h> +#include <filetype.h> +#include <linux/list.h> + +#define MAX_PARTITION 8 +#define MAX_PARTITION_NAME 38 + +struct partition { + char name[MAX_PARTITION_NAME]; + uint64_t first_sec; + uint64_t size; +}; + +struct partition_desc { + int used_entries; + struct partition parts[MAX_PARTITION]; +}; + +struct partition_parser { + void (*parse)(void *buf, struct block_device *blk, struct partition_desc *pd); + enum filetype type; + + struct list_head list; +}; + +int partition_parser_register(struct partition_parser *p); + +#endif /* __PARTITIONS_PARSER_H__ */ diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init index b606b634a2..e4a7feef79 100644 --- a/defaultenv-2/base/bin/init +++ b/defaultenv-2/base/bin/init @@ -13,6 +13,7 @@ global linux.bootargs.dyn.ip global linux.bootargs.dyn.root global editcmd=sedit +/env/config-board /env/config if [ -e /env/menu ]; then diff --git a/defaultenv-2/base/config b/defaultenv-2/base/config index 189e5a68f2..dec0595333 100644 --- a/defaultenv-2/base/config +++ b/defaultenv-2/base/config @@ -6,16 +6,16 @@ #global.hostname= # set to false if you do not want to have colors -global.allow_color=true +#global.allow_color=true # user (used for network filenames) -global.user=none +#global.user=none # timeout in seconds before the default boot entry is started -global.autoboot_timeout=3 +#global.autoboot_timeout=3 # default boot entry (one of /env/boot/*) -global.boot.default=net +#global.boot.default=net # base bootargs #global.linux.bootargs.base="console=ttyS0,115200" diff --git a/defaultenv-2/base/init/ps1 b/defaultenv-2/base/init/ps1 index fcbf4b63f4..02d7b4b780 100644 --- a/defaultenv-2/base/init/ps1 +++ b/defaultenv-2/base/init/ps1 @@ -1,7 +1,5 @@ #!/bin/sh -/env/config - if [ ${global.allow_color} = "true" ]; then export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m " else diff --git a/drivers/Kconfig b/drivers/Kconfig index 988ec9ee06..16ca5b99b0 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -1,10 +1,10 @@ menu "Drivers" +source "drivers/amba/Kconfig" source "drivers/serial/Kconfig" source "drivers/net/Kconfig" source "drivers/spi/Kconfig" source "drivers/i2c/Kconfig" -source "drivers/nor/Kconfig" source "drivers/mtd/Kconfig" source "drivers/ata/Kconfig" source "drivers/usb/Kconfig" diff --git a/drivers/Makefile b/drivers/Makefile index 1fddee0dd4..f81bf99ac4 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -3,7 +3,6 @@ obj-$(CONFIG_ARM_AMBA) += amba/ obj-y += net/ obj-y += serial/ obj-y += mtd/ -obj-y += nor/ obj-y += usb/ obj-$(CONFIG_DISK) += ata/ obj-$(CONFIG_SPI) += spi/ diff --git a/drivers/amba/Kconfig b/drivers/amba/Kconfig new file mode 100644 index 0000000000..d1cba6a9b3 --- /dev/null +++ b/drivers/amba/Kconfig @@ -0,0 +1,2 @@ +config ARM_AMBA + bool diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 65385be64d..7d7a6541ac 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -208,6 +208,7 @@ struct amba_device *amba_device_alloc(const char *name, int id, resource_size_t dev->res.start = base; dev->res.end = base + size - 1; dev->res.flags = IORESOURCE_MEM; + dev->dev.resource = &dev->res; return dev; } diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index ff6528acf4..42f2065a61 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -38,6 +38,7 @@ config DISK_AHCI select DISK_DRIVE config DISK_AHCI_IMX + depends on ARCH_IMX depends on DISK_AHCI bool "i.MX AHCI support" diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 14de3c5061..4d5b52afe5 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -385,14 +385,21 @@ static int ahci_init_port(struct ahci_port *ahci_port) ahci_port_info(ahci_port, "Spinning up device...\n"); ret = wait_on_timeout(WAIT_SPINUP, - (readl(port_mmio + PORT_TFDATA) & - (ATA_STATUS_BUSY | ATA_STATUS_DRQ)) == 0); + ((readl(port_mmio + PORT_TFDATA) & + (ATA_STATUS_BUSY | ATA_STATUS_DRQ)) == 0) + || !((readl(port_mmio + PORT_SCR_STAT) & 0xf) == 1)); if (ret) { ahci_port_info(ahci_port, "timeout.\n"); ret = -ENODEV; goto err_init; } + if ((readl(port_mmio + PORT_SCR_STAT) & 0xf) == 1) { + ahci_port_info(ahci_port, "down.\n"); + ret = -ENODEV; + goto err_init; + } + ahci_port_info(ahci_port, "ok.\n"); val = ahci_port_read(ahci_port, PORT_SCR_ERR); @@ -664,15 +671,18 @@ static int ahci_probe(struct device_d *dev) return ret; } +static __maybe_unused struct of_device_id ahci_dt_ids[] = { + { + .compatible = "calxeda,hb-ahci", + }, { + /* sentinel */ + } +}; + static struct driver_d ahci_driver = { .name = "ahci", .probe = ahci_probe, .info = ahci_info, + .of_compatible = DRV_OF_COMPAT(ahci_dt_ids), }; - -static int ahci_init(void) -{ - return platform_driver_register(&ahci_driver); -} - -device_initcall(ahci_init); +device_platform_driver(ahci_driver); diff --git a/drivers/ata/intf_platform_ide.c b/drivers/ata/intf_platform_ide.c index 6473b38ba3..0b56eb4aa8 100644 --- a/drivers/ata/intf_platform_ide.c +++ b/drivers/ata/intf_platform_ide.c @@ -108,13 +108,7 @@ static struct driver_d platform_ide_driver = { .name = "ide_intf", .probe = platform_ide_probe, }; - -static int platform_ide_init(void) -{ - return platform_driver_register(&platform_ide_driver); -} - -device_initcall(platform_ide_init); +device_platform_driver(platform_ide_driver); /** * @file diff --git a/drivers/ata/pata-imx.c b/drivers/ata/pata-imx.c index 202f537569..5d44883453 100644 --- a/drivers/ata/pata-imx.c +++ b/drivers/ata/pata-imx.c @@ -194,10 +194,4 @@ static struct driver_d imx_pata_driver = { .name = "imx-pata", .probe = imx_pata_probe, }; - -static int imx_pata_init(void) -{ - return platform_driver_register(&imx_pata_driver); -} - -device_initcall(imx_pata_init); +device_platform_driver(imx_pata_driver); diff --git a/drivers/ata/sata-imx.c b/drivers/ata/sata-imx.c index fc57f5f104..bd48fae1f4 100644 --- a/drivers/ata/sata-imx.c +++ b/drivers/ata/sata-imx.c @@ -146,10 +146,4 @@ static struct driver_d imx_sata_driver = { .info = ahci_info, .id_table = imx_sata_ids, }; - -static int ahci_init(void) -{ - return platform_driver_register(&imx_sata_driver); -} - -device_initcall(ahci_init); +device_platform_driver(imx_sata_driver); diff --git a/drivers/base/driver.c b/drivers/base/driver.c index d4066fc178..fa30c68059 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -230,7 +230,7 @@ int register_driver(struct driver_d *drv) } EXPORT_SYMBOL(register_driver); -static struct resource *dev_get_resource(struct device_d *dev, int num) +struct resource *dev_get_resource(struct device_d *dev, int num) { int i, n = 0; diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 89be6843ae..5500ad1121 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -17,7 +17,7 @@ config GPIO_PL061 Say yes here to support the PrimeCell PL061 GPIO device config GPIO_STMPE - depends on I2C_STMPE + depends on MFD_STMPE bool "STMPE GPIO Expander" endmenu diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 98ce2d59ab..8b49c2c1bf 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -169,9 +169,4 @@ static struct driver_d i2c_gpio_driver = { .name = "i2c-gpio", .probe = i2c_gpio_probe, }; - -static int __init i2c_gpio_init(void) -{ - return platform_driver_register(&i2c_gpio_driver); -} -device_initcall(i2c_gpio_init); +device_platform_driver(i2c_gpio_driver); diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 68348eb159..9fcfd5c6f7 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -576,9 +576,4 @@ static struct driver_d i2c_fsl_driver = { .probe = i2c_fsl_probe, .name = DRIVER_NAME, }; - -static int __init i2c_adap_fsl_init(void) -{ - return platform_driver_register(&i2c_fsl_driver); -} -device_initcall(i2c_adap_fsl_init); +device_platform_driver(i2c_fsl_driver); diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index f371875aad..503443f9bf 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -860,13 +860,7 @@ static struct driver_d omap_i2c_driver = { .probe = i2c_omap_probe, .name = DRIVER_NAME, }; - -/* I2C may be needed to bring up other drivers */ -static int __init omap_i2c_init_driver(void) -{ - return platform_driver_register(&omap_i2c_driver); -} -device_initcall(omap_i2c_init_driver); +device_platform_driver(omap_i2c_driver); MODULE_AUTHOR("MontaVista Software, Inc. (and others)"); MODULE_DESCRIPTION("TI OMAP I2C bus adapter"); diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c index 7c993226f8..d395e1d2fd 100644 --- a/drivers/i2c/busses/i2c-versatile.c +++ b/drivers/i2c/busses/i2c-versatile.c @@ -103,10 +103,4 @@ static struct driver_d i2c_versatile_driver = { .name = "versatile-i2c", .probe = i2c_versatile_probe, }; - -static int __init i2c_versatile_init(void) -{ - return platform_driver_register(&i2c_versatile_driver); -} - -device_initcall(i2c_versatile_init); +device_platform_driver(i2c_versatile_driver); diff --git a/drivers/input/gpio_keys.c b/drivers/input/gpio_keys.c index 543ad1a470..b02e0ede34 100644 --- a/drivers/input/gpio_keys.c +++ b/drivers/input/gpio_keys.c @@ -106,10 +106,4 @@ static struct driver_d gpio_keys_driver = { .name = "gpio_keys", .probe = gpio_keys_probe, }; - -static int gpio_keys_init(void) -{ - platform_driver_register(&gpio_keys_driver); - return 0; -} -device_initcall(gpio_keys_init); +device_platform_driver(gpio_keys_driver); diff --git a/drivers/input/imx_keypad.c b/drivers/input/imx_keypad.c index f6c3b1b8bb..2ee3d0fa00 100644 --- a/drivers/input/imx_keypad.c +++ b/drivers/input/imx_keypad.c @@ -454,10 +454,4 @@ static struct driver_d imx_keypad_driver = { .name = "imx-kpp", .probe = imx_keypad_probe, }; - -static int imx_keypad_init(void) -{ - platform_driver_register(&imx_keypad_driver); - return 0; -} -device_initcall(imx_keypad_init); +device_platform_driver(imx_keypad_driver); diff --git a/drivers/mci/Makefile b/drivers/mci/Makefile index b7bb846291..d46d5f50e8 100644 --- a/drivers/mci/Makefile +++ b/drivers/mci/Makefile @@ -4,7 +4,7 @@ obj-$(CONFIG_MCI_S3C) += s3c.o obj-$(CONFIG_MCI_IMX) += imx.o obj-$(CONFIG_MCI_IMX_ESDHC) += imx-esdhc.o obj-$(CONFIG_MCI_OMAP_HSMMC) += omap_hsmmc.o -obj-$(CONFIG_I2C_TWL6030) += twl6030.o +obj-$(CONFIG_MFD_TWL6030) += twl6030.o obj-$(CONFIG_MCI_PXA) += pxamci.o obj-$(CONFIG_MCI_ATMEL) += atmel_mci.o obj-$(CONFIG_MCI_SPI) += mci_spi.o diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c index dbfb53cb42..f032403109 100644 --- a/drivers/mci/atmel_mci.c +++ b/drivers/mci/atmel_mci.c @@ -619,10 +619,4 @@ static struct driver_d atmci_driver = { .info = atmci_info, #endif }; - -static int atmci_init_driver(void) -{ - platform_driver_register(&atmci_driver); - return 0; -} -device_initcall(atmci_init_driver); +device_platform_driver(atmci_driver); diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c index aad1b86962..8c2695cded 100644 --- a/drivers/mci/imx-esdhc.c +++ b/drivers/mci/imx-esdhc.c @@ -583,11 +583,4 @@ static struct driver_d fsl_esdhc_driver = { .probe = fsl_esdhc_probe, .of_compatible = DRV_OF_COMPAT(fsl_esdhc_compatible), }; - -static int fsl_esdhc_init_driver(void) -{ - platform_driver_register(&fsl_esdhc_driver); - return 0; -} - -device_initcall(fsl_esdhc_init_driver); +device_platform_driver(fsl_esdhc_driver); diff --git a/drivers/mci/imx.c b/drivers/mci/imx.c index 072ca93794..1210a1d2b1 100644 --- a/drivers/mci/imx.c +++ b/drivers/mci/imx.c @@ -524,12 +524,4 @@ static struct driver_d mxcmci_driver = { .name = DRIVER_NAME, .probe = mxcmci_probe, }; - -static int mxcmci_init_driver(void) -{ - platform_driver_register(&mxcmci_driver); - return 0; -} - -device_initcall(mxcmci_init_driver); - +device_platform_driver(mxcmci_driver); diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c index b5b36650bf..3657b3e496 100644 --- a/drivers/mci/mxs.c +++ b/drivers/mci/mxs.c @@ -40,127 +40,11 @@ #include <mach/imx-regs.h> #include <mach/mci.h> #include <mach/clock.h> +#include <mach/ssp.h> #define CLOCKRATE_MIN (1 * 1000 * 1000) #define CLOCKRATE_MAX (480 * 1000 * 1000) -#define HW_SSP_CTRL0 0x000 -# define SSP_CTRL0_SFTRST (1 << 31) -# define SSP_CTRL0_CLKGATE (1 << 30) -# define SSP_CTRL0_RUN (1 << 29) -# define SSP_CTRL0_LOCK_CS (1 << 27) -# define SSP_CTRL0_READ (1 << 25) -# define SSP_CTRL0_IGNORE_CRC (1 << 26) -# define SSP_CTRL0_DATA_XFER (1 << 24) -# define SSP_CTRL0_BUS_WIDTH(x) (((x) & 0x3) << 22) -# define SSP_CTRL0_WAIT_FOR_IRQ (1 << 21) -# define SSP_CTRL0_LONG_RESP (1 << 19) -# define SSP_CTRL0_GET_RESP (1 << 17) -# define SSP_CTRL0_ENABLE (1 << 16) -#ifdef CONFIG_ARCH_IMX23 -# define SSP_CTRL0_XFER_COUNT(x) ((x) & 0xffff) -#endif - -#define HW_SSP_CMD0 0x010 -# define SSP_CMD0_SLOW_CLK (1 << 22) -# define SSP_CMD0_CONT_CLK (1 << 21) -# define SSP_CMD0_APPEND_8CYC (1 << 20) -#ifdef CONFIG_ARCH_IMX23 -# define SSP_CMD0_BLOCK_SIZE(x) (((x) & 0xf) << 16) -# define SSP_CMD0_BLOCK_COUNT(x) (((x) & 0xff) << 8) -#endif -# define SSP_CMD0_CMD(x) ((x) & 0xff) - -#define HW_SSP_CMD1 0x020 - -#ifdef CONFIG_ARCH_IMX23 -# define HW_SSP_COMPREF 0x030 -# define HW_SSP_COMPMASK 0x040 -# define HW_SSP_TIMING 0x050 -# define HW_SSP_CTRL1 0x060 -# define HW_SSP_DATA 0x070 -#endif -#ifdef CONFIG_ARCH_IMX28 -# define HW_SSP_XFER_COUNT 0x30 -# define HW_SSP_BLOCK_SIZE 0x40 -# define SSP_BLOCK_SIZE(x) ((x) & 0xf) -# define SSP_BLOCK_COUNT(x) (((x) & 0xffffff) << 4) -# define HW_SSP_COMPREF 0x050 -# define HW_SSP_COMPMASK 0x060 -# define HW_SSP_TIMING 0x070 -# define HW_SSP_CTRL1 0x080 -# define HW_SSP_DATA 0x090 -#endif -/* bit definition for register HW_SSP_TIMING */ -# define SSP_TIMING_TIMEOUT_MASK (0xffff0000) -# define SSP_TIMING_TIMEOUT(x) ((x) << 16) -# define SSP_TIMING_CLOCK_DIVIDE(x) (((x) & 0xff) << 8) -# define SSP_TIMING_CLOCK_RATE(x) ((x) & 0xff) - -/* bit definition for register HW_SSP_CTRL1 */ -# define SSP_CTRL1_POLARITY (1 << 9) -# define SSP_CTRL1_WORD_LENGTH(x) (((x) & 0xf) << 4) -# define SSP_CTRL1_SSP_MODE(x) ((x) & 0xf) - -#ifdef CONFIG_ARCH_IMX23 -# define HW_SSP_SDRESP0 0x080 -# define HW_SSP_SDRESP1 0x090 -# define HW_SSP_SDRESP2 0x0A0 -# define HW_SSP_SDRESP3 0x0B0 -#endif -#ifdef CONFIG_ARCH_IMX28 -# define HW_SSP_SDRESP0 0x0A0 -# define HW_SSP_SDRESP1 0x0B0 -# define HW_SSP_SDRESP2 0x0C0 -# define HW_SSP_SDRESP3 0x0D0 -#endif - -#ifdef CONFIG_ARCH_IMX28 -# define HW_SSP_DDR_CTRL 0x0E0 -# define HW_SSP_DLL_CTRL 0x0F0 -#endif - -#ifdef CONFIG_ARCH_IMX23 -# define HW_SSP_STATUS 0x0C0 -#endif -#ifdef CONFIG_ARCH_IMX28 -# define HW_SSP_STATUS 0x100 -#endif - -/* bit definition for register HW_SSP_STATUS */ -# define SSP_STATUS_PRESENT (1 << 31) -# define SSP_STATUS_SD_PRESENT (1 << 29) -# define SSP_STATUS_CARD_DETECT (1 << 28) -# define SSP_STATUS_RESP_CRC_ERR (1 << 16) -# define SSP_STATUS_RESP_ERR (1 << 15) -# define SSP_STATUS_RESP_TIMEOUT (1 << 14) -# define SSP_STATUS_DATA_CRC_ERR (1 << 13) -# define SSP_STATUS_TIMEOUT (1 << 12) -# define SSP_STATUS_FIFO_OVRFLW (1 << 9) -# define SSP_STATUS_FIFO_FULL (1 << 8) -# define SSP_STATUS_FIFO_EMPTY (1 << 5) -# define SSP_STATUS_FIFO_UNDRFLW (1 << 4) -# define SSP_STATUS_CMD_BUSY (1 << 3) -# define SSP_STATUS_DATA_BUSY (1 << 2) -# define SSP_STATUS_BUSY (1 << 0) -# define SSP_STATUS_ERROR (SSP_STATUS_FIFO_OVRFLW | SSP_STATUS_FIFO_UNDRFLW | \ - SSP_STATUS_RESP_CRC_ERR | SSP_STATUS_RESP_ERR | \ - SSP_STATUS_RESP_TIMEOUT | SSP_STATUS_DATA_CRC_ERR | SSP_STATUS_TIMEOUT) - -#ifdef CONFIG_ARCH_IMX28 -# define HW_SSP_DLL_STS 0x110 -#endif - -#ifdef CONFIG_ARCH_IMX23 -# define HW_SSP_DEBUG 0x100 -# define HW_SSP_VERSION 0x110 -#endif - -#ifdef CONFIG_ARCH_IMX28 -# define HW_SSP_DEBUG 0x120 -# define HW_SSP_VERSION 0x130 -#endif - struct mxs_mci_host { struct mci_host host; void __iomem *regs; @@ -760,11 +644,4 @@ static struct driver_d mxs_mci_driver = { .info = mxs_mci_info, #endif }; - -static int mxs_mci_init_driver(void) -{ - platform_driver_register(&mxs_mci_driver); - return 0; -} - -device_initcall(mxs_mci_init_driver); +device_platform_driver(mxs_mci_driver); diff --git a/drivers/mci/omap_hsmmc.c b/drivers/mci/omap_hsmmc.c index ffcb4ae75c..b379c31fae 100644 --- a/drivers/mci/omap_hsmmc.c +++ b/drivers/mci/omap_hsmmc.c @@ -29,7 +29,7 @@ #include <mach/omap_hsmmc.h> -#if defined(CONFIG_I2C_TWL6030) && \ +#if defined(CONFIG_MFD_TWL6030) && \ defined(CONFIG_MCI_OMAP_HSMMC) && \ defined(CONFIG_ARCH_OMAP4) #include <mach/omap4_twl6030_mmc.h> @@ -235,7 +235,7 @@ static int mmc_init_setup(struct mci_host *mci, struct device_d *dev) * It's necessary to do this here, because * you need to set up this at probetime. */ -#if defined(CONFIG_I2C_TWL6030) && \ +#if defined(CONFIG_MFD_TWL6030) && \ defined(CONFIG_MCI_OMAP_HSMMC) && \ defined(CONFIG_ARCH_OMAP4) set_up_mmc_voltage_omap4(); @@ -630,11 +630,4 @@ static struct driver_d omap_mmc_driver = { .probe = omap_mmc_probe, .id_table = omap_mmc_ids, }; - -static int omap_mmc_init_driver(void) -{ - platform_driver_register(&omap_mmc_driver); - return 0; -} - -device_initcall(omap_mmc_init_driver); +device_platform_driver(omap_mmc_driver); diff --git a/drivers/mci/pxamci.c b/drivers/mci/pxamci.c index c18e63a00b..c1380d1fd8 100644 --- a/drivers/mci/pxamci.c +++ b/drivers/mci/pxamci.c @@ -378,11 +378,4 @@ static struct driver_d pxamci_driver = { .name = DRIVER_NAME, .probe = pxamci_probe, }; - -static int __init pxamci_init_driver(void) -{ - platform_driver_register(&pxamci_driver); - return 0; -} - -device_initcall(pxamci_init_driver); +device_platform_driver(pxamci_driver); diff --git a/drivers/mci/s3c.c b/drivers/mci/s3c.c index 3e5d6d986c..4e7345c8d5 100644 --- a/drivers/mci/s3c.c +++ b/drivers/mci/s3c.c @@ -767,11 +767,4 @@ static struct driver_d s3c_mci_driver = { .info = s3c_info, #endif }; - -static int s3c_mci_init_driver(void) -{ - platform_driver_register(&s3c_mci_driver); - return 0; -} - -device_initcall(s3c_mci_init_driver); +device_platform_driver(s3c_mci_driver); diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index a253de3806..c506d6782b 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1,10 +1,14 @@ menu MFD +config MFD_LP3972 + depends on I2C + bool "LP3972 driver" + config MFD_MC13XXX depends on I2C || SPI bool "MC13XXX a.k.a. PMIC driver (MC13783, MC13892)" -config I2C_MC34704 +config MFD_MC34704 depends on I2C bool "MC34704 PMIC driver" @@ -12,29 +16,25 @@ config MFD_MC34708 depends on I2C || SPI bool "MC34708 PMIC driver" -config I2C_MC9SDZ60 +config MFD_MC9SDZ60 depends on I2C bool "MC9SDZ60 driver" -config I2C_LP3972 +config MFD_STMPE depends on I2C - bool "LP3972 driver" + bool "STMPE-i2c driver" -config I2C_TWLCORE +config MFD_TWLCORE bool -config I2C_TWL4030 +config MFD_TWL4030 depends on I2C - select I2C_TWLCORE + select MFD_TWLCORE bool "TWL4030 driver" -config I2C_TWL6030 +config MFD_TWL6030 depends on I2C - select I2C_TWLCORE + select MFD_TWLCORE bool "TWL6030 driver" -config I2C_STMPE - depends on I2C - bool "STMPE-i2c driver" - endmenu diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index a242eaf677..542fb0fb3a 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -1,9 +1,9 @@ -obj-$(CONFIG_MFD_MC13XXX) += mc13xxx.o -obj-$(CONFIG_I2C_MC34704) += mc34704.o -obj-$(CONFIG_MFD_MC34708) += mc34708.o -obj-$(CONFIG_I2C_MC9SDZ60) += mc9sdz60.o -obj-$(CONFIG_I2C_LP3972) += lp3972.o -obj-$(CONFIG_I2C_TWLCORE) += twl-core.o -obj-$(CONFIG_I2C_TWL4030) += twl4030.o -obj-$(CONFIG_I2C_TWL6030) += twl6030.o -obj-$(CONFIG_I2C_STMPE) += stmpe-i2c.o +obj-$(CONFIG_MFD_LP3972) += lp3972.o +obj-$(CONFIG_MFD_MC13XXX) += mc13xxx.o +obj-$(CONFIG_MFD_MC34704) += mc34704.o +obj-$(CONFIG_MFD_MC34708) += mc34708.o +obj-$(CONFIG_MFD_MC9SDZ60) += mc9sdz60.o +obj-$(CONFIG_MFD_STMPE) += stmpe-i2c.o +obj-$(CONFIG_MFD_TWLCORE) += twl-core.o +obj-$(CONFIG_MFD_TWL4030) += twl4030.o +obj-$(CONFIG_MFD_TWL6030) += twl6030.o diff --git a/drivers/misc/jtag.c b/drivers/misc/jtag.c index 6c5dea4f2b..d302237e37 100644 --- a/drivers/misc/jtag.c +++ b/drivers/misc/jtag.c @@ -376,13 +376,7 @@ static struct driver_d jtag_driver = { .remove = jtag_remove, .info = jtag_info, }; - -static int jtag_module_init(void) -{ - return platform_driver_register(&jtag_driver); -} - -device_initcall(jtag_module_init); +device_platform_driver(jtag_driver); MODULE_AUTHOR("Davide Rizzo <elpa.rizzo@gmail.com>"); MODULE_AUTHOR("Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com>"); diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig index 9450f5de8b..e94e6b1f63 100644 --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig @@ -21,6 +21,7 @@ config MTD_RAW_DEVICE prompt "mtdraw device to read/write both data+oob" source "drivers/mtd/devices/Kconfig" +source "drivers/mtd/nor/Kconfig" source "drivers/mtd/nand/Kconfig" source "drivers/mtd/ubi/Kconfig" diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile index 4f97d9a6f3..82b2cc9e68 100644 --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile @@ -1,4 +1,5 @@ obj-$(CONFIG_NAND) += nand/ +obj-$(CONFIG_DRIVER_CFI) += nor/ obj-$(CONFIG_UBI) += ubi/ obj-y += devices/ obj-$(CONFIG_PARTITION_NEED_MTD) += partition.o diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c index 070fda652b..b6c1d01434 100644 --- a/drivers/mtd/core.c +++ b/drivers/mtd/core.c @@ -30,16 +30,39 @@ static LIST_HEAD(mtd_register_hooks); -int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs) +int mtd_all_ff(const void *buf, unsigned int len) { - if (!mtd->block_isbad) - return 0; - if (ofs < 0 || ofs > mtd->size) - return -EINVAL; - return mtd->block_isbad(mtd, ofs); + while ((unsigned long)buf & 0x3) { + if (*(const uint8_t *)buf != 0xff) + return 0; + len--; + if (!len) + return 1; + buf++; + } + + while (len > 0x3) { + if (*(const uint32_t *)buf != 0xffffffff) + return 0; + + len -= sizeof(uint32_t); + if (!len) + return 1; + + buf += sizeof(uint32_t); + } + + while (len) { + if (*(const uint8_t *)buf != 0xff) + return 0; + len--; + buf++; + } + + return 1; } -static ssize_t mtd_read(struct cdev *cdev, void* buf, size_t count, +static ssize_t mtd_op_read(struct cdev *cdev, void* buf, size_t count, loff_t _offset, ulong flags) { struct mtd_info *mtd = cdev->priv; @@ -47,9 +70,10 @@ static ssize_t mtd_read(struct cdev *cdev, void* buf, size_t count, int ret; unsigned long offset = _offset; - debug("mtd_read: 0x%08lx 0x%08x\n", offset, count); + dev_dbg(cdev->dev, "read ofs: 0x%08lx count: 0x%08x\n", + offset, count); - ret = mtd->read(mtd, offset, count, &retlen, buf); + ret = mtd_read(mtd, offset, count, &retlen, buf); if(ret) { printf("err %d\n", ret); @@ -62,19 +86,19 @@ static ssize_t mtd_read(struct cdev *cdev, void* buf, size_t count, #define MTDPGALG(x) ((x) & ~(mtd->writesize - 1)) #ifdef CONFIG_MTD_WRITE -static ssize_t mtd_write(struct cdev* cdev, const void *buf, size_t _count, +static ssize_t mtd_op_write(struct cdev* cdev, const void *buf, size_t _count, loff_t _offset, ulong flags) { struct mtd_info *mtd = cdev->priv; size_t retlen; int ret; - ret = mtd->write(mtd, _offset, _count, &retlen, buf); + ret = mtd_write(mtd, _offset, _count, &retlen, buf); return ret ? ret : _count; } -static int mtd_erase(struct cdev *cdev, size_t count, loff_t offset) +static int mtd_op_erase(struct cdev *cdev, size_t count, loff_t offset) { struct mtd_info *mtd = cdev->priv; struct erase_info erase; @@ -92,7 +116,7 @@ static int mtd_erase(struct cdev *cdev, size_t count, loff_t offset) if (ret > 0) { printf("Skipping bad block at 0x%08x\n", erase.addr); } else { - ret = mtd->erase(mtd, &erase); + ret = mtd_erase(mtd, &erase); if (ret) return ret; } @@ -103,6 +127,20 @@ static int mtd_erase(struct cdev *cdev, size_t count, loff_t offset) return 0; } + +static ssize_t mtd_op_protect(struct cdev *cdev, size_t count, loff_t offset, int prot) +{ + struct mtd_info *mtd = cdev->priv; + + if (!mtd->unlock || !mtd->lock) + return -ENOSYS; + + if (prot) + return mtd_lock(mtd, offset, count); + else + return mtd_unlock(mtd, offset, count); +} + #endif /* CONFIG_MTD_WRITE */ int mtd_ioctl(struct cdev *cdev, int request, void *buf) @@ -127,10 +165,10 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf) #ifdef CONFIG_MTD_WRITE case MEMSETBADBLOCK: dev_dbg(cdev->dev, "MEMSETBADBLOCK: 0x%08llx\n", *offset); - ret = mtd->block_markbad(mtd, *offset); + ret = mtd_block_markbad(mtd, *offset); break; case MEMERASE: - ret = mtd_erase(cdev, ei->length, ei->start + cdev->offset); + ret = mtd_op_erase(cdev, ei->length, ei->start + cdev->offset); break; #endif case MEMGETINFO: @@ -169,11 +207,74 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf) return ret; } +int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) +{ + if (!mtd->lock) + return -EOPNOTSUPP; + if (ofs < 0 || ofs > mtd->size || len > mtd->size - ofs) + return -EINVAL; + if (!len) + return 0; + return mtd->lock(mtd, ofs, len); +} + +int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) +{ + if (!mtd->unlock) + return -EOPNOTSUPP; + if (ofs < 0 || ofs > mtd->size || len > mtd->size - ofs) + return -EINVAL; + if (!len) + return 0; + return mtd->unlock(mtd, ofs, len); +} + +int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs) +{ + if (!mtd->block_isbad) + return 0; + + if (ofs < 0 || ofs > mtd->size) + return -EINVAL; + + return mtd->block_isbad(mtd, ofs); +} + +int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs) +{ + int ret; + + if (mtd->block_markbad) + ret = mtd->block_markbad(mtd, ofs); + else + ret = -ENOSYS; + + return ret; +} + +int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, + u_char *buf) +{ + return mtd->read(mtd, from, len, retlen, buf); +} + +int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, + const u_char *buf) +{ + return mtd->write(mtd, to, len, retlen, buf); +} + +int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) +{ + return mtd->erase(mtd, instr); +} + static struct file_operations mtd_ops = { - .read = mtd_read, + .read = mtd_op_read, #ifdef CONFIG_MTD_WRITE - .write = mtd_write, - .erase = mtd_erase, + .write = mtd_op_write, + .erase = mtd_op_erase, + .protect = mtd_op_protect, #endif .ioctl = mtd_ioctl, .lseek = dev_lseek_default, diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c index 2f89900e43..af3d174cd6 100644 --- a/drivers/mtd/devices/docg3.c +++ b/drivers/mtd/devices/docg3.c @@ -1199,10 +1199,4 @@ static struct driver_d g3_driver = { .name = "docg3", .probe = docg3_probe, }; - -static int __init docg3_init(void) -{ - return platform_driver_register(&g3_driver); -} - -device_initcall(docg3_init); +device_platform_driver(g3_driver); diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c index ec7769249b..5aaa0172da 100644 --- a/drivers/mtd/mtdraw.c +++ b/drivers/mtd/mtdraw.c @@ -245,7 +245,7 @@ static int mtdraw_erase(struct cdev *cdev, size_t count, loff_t _offset) if (ret > 0) { printf("Skipping bad block at 0x%08x\n", erase.addr); } else { - ret = mtd->erase(mtd, &erase); + ret = mtd_erase(mtd, &erase); if (ret) return ret; } diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 2a57dbbd71..63484f8196 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -1242,13 +1242,7 @@ static struct driver_d atmel_nand_driver = { .name = "atmel_nand", .probe = atmel_nand_probe, }; - -static int __init atmel_nand_init(void) -{ - return platform_driver_register(&atmel_nand_driver); -} - -device_initcall(atmel_nand_init); +device_platform_driver(atmel_nand_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Rick Bronson"); diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index f7ae7cd717..56396bfd86 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c @@ -160,7 +160,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, while (totlen) { len = min(totlen, (size_t) (1 << this->bbt_erase_shift)); - res = mtd->read(mtd, from, len, &retlen, buf); + res = mtd_read(mtd, from, len, &retlen, buf); if (res < 0) { if (retlen != len) { pr_info("nand_bbt: Error reading bad block table\n"); @@ -669,7 +669,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, /* Make it block aligned */ to &= ~((loff_t) ((1 << this->bbt_erase_shift) - 1)); len = 1 << this->bbt_erase_shift; - res = mtd->read(mtd, to, len, &retlen, buf); + res = mtd_read(mtd, to, len, &retlen, buf); if (res < 0) { if (retlen != len) { pr_info("nand_bbt: Error " diff --git a/drivers/mtd/nand/nand_imx.c b/drivers/mtd/nand/nand_imx.c index a56c65ff8c..dd668619d5 100644 --- a/drivers/mtd/nand/nand_imx.c +++ b/drivers/mtd/nand/nand_imx.c @@ -1277,17 +1277,7 @@ static struct driver_d imx_nand_driver = { .name = "imx_nand", .probe = imxnd_probe, }; - -/* - * Main initialization routine - * @return 0 if successful; non-zero otherwise - */ -static int __init imx_nand_init(void) -{ - return platform_driver_register(&imx_nand_driver); -} - -device_initcall(imx_nand_init); +device_platform_driver(imx_nand_driver); MODULE_AUTHOR("Freescale Semiconductor, Inc."); MODULE_DESCRIPTION("MXC NAND MTD driver"); diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c index bc345262ad..3812ac9ddb 100644 --- a/drivers/mtd/nand/nand_mxs.c +++ b/drivers/mtd/nand/nand_mxs.c @@ -1265,13 +1265,7 @@ static struct driver_d mxs_nand_driver = { .name = "mxs_nand", .probe = mxs_nand_probe, }; - -static int __init mxs_nand_init(void) -{ - return platform_driver_register(&mxs_nand_driver); -} - -device_initcall(mxs_nand_init); +device_platform_driver(mxs_nand_driver); MODULE_AUTHOR("Denx Software Engeneering and Wolfram Sang"); MODULE_DESCRIPTION("MXS NAND MTD driver"); diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c index 9050a8d0bc..7849db5b11 100644 --- a/drivers/mtd/nand/nand_omap_gpmc.c +++ b/drivers/mtd/nand/nand_omap_gpmc.c @@ -1081,10 +1081,4 @@ static struct driver_d gpmc_nand_driver = { .name = "gpmc_nand", .probe = gpmc_nand_probe, }; - -static int gpmc_nand_init(void) -{ - return platform_driver_register(&gpmc_nand_driver); -} - -device_initcall(gpmc_nand_init); +device_platform_driver(gpmc_nand_driver); diff --git a/drivers/mtd/nand/nand_s3c24xx.c b/drivers/mtd/nand/nand_s3c24xx.c index aef7fa9ba1..fef94328b1 100644 --- a/drivers/mtd/nand/nand_s3c24xx.c +++ b/drivers/mtd/nand/nand_s3c24xx.c @@ -494,6 +494,7 @@ static struct driver_d s3c24x0_nand_driver = { .name = "s3c24x0_nand", .probe = s3c24x0_nand_probe, }; +device_platform_driver(s3c24x0_nand_driver); #ifdef CONFIG_S3C_NAND_BOOT @@ -646,17 +647,6 @@ BAREBOX_CMD_END #endif /* CONFIG_S3C_NAND_BOOT */ -/* - * Main initialization routine - * @return 0 if successful; non-zero otherwise - */ -static int __init s3c24x0_nand_init(void) -{ - return platform_driver_register(&s3c24x0_nand_driver); -} - -device_initcall(s3c24x0_nand_init); - /** * @file * @brief Support for various kinds of NAND devices diff --git a/drivers/mtd/nand/nand_write.c b/drivers/mtd/nand/nand_write.c index 12a57a0e4d..eea511366f 100644 --- a/drivers/mtd/nand/nand_write.c +++ b/drivers/mtd/nand/nand_write.c @@ -320,10 +320,12 @@ int nand_do_write_ops(struct mtd_info *mtd, loff_t to, memset(chip->oob_poi, 0xff, mtd->oobsize); } - ret = chip->write_page(mtd, chip, wbuf, page, cached, - (ops->mode == MTD_OOB_RAW)); - if (ret) - break; + if (oob || !mtd_all_ff(wbuf, mtd->writesize)) { + ret = chip->write_page(mtd, chip, wbuf, page, cached, + (ops->mode == MTD_OOB_RAW)); + if (ret) + break; + } writelen -= bytes; if (!writelen) diff --git a/drivers/mtd/nand/nomadik_nand.c b/drivers/mtd/nand/nomadik_nand.c index 768b19c7be..834b6ac32a 100644 --- a/drivers/mtd/nand/nomadik_nand.c +++ b/drivers/mtd/nand/nomadik_nand.c @@ -234,14 +234,7 @@ static struct driver_d nomadik_nand_driver = { .probe = nomadik_nand_probe, .name = "nomadik_nand", }; - -static int __init nand_nomadik_init(void) -{ - pr_info("Nomadik NAND driver\n"); - return platform_driver_register(&nomadik_nand_driver); -} - -device_initcall(nand_nomadik_init); +device_platform_driver(nomadik_nand_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("ST Microelectronics (sachin.verma@st.com)"); diff --git a/drivers/nor/Kconfig b/drivers/mtd/nor/Kconfig index c8ce24ff03..44a418405b 100644 --- a/drivers/nor/Kconfig +++ b/drivers/mtd/nor/Kconfig @@ -1,7 +1,5 @@ -menu "flash drivers" - menuconfig DRIVER_CFI - bool "CFI" + bool "CFI NOR flash support" help If you have NOR Flash devices connected to your system and wish to use them say yes here. @@ -10,17 +8,14 @@ if DRIVER_CFI config DRIVER_CFI_INTEL default y - depends on DRIVER_CFI bool "Support Intel flash chips" config DRIVER_CFI_AMD default y - depends on DRIVER_CFI bool "support AMD flash chips" config DRIVER_CFI_BANK_WIDTH_1 bool "Support 8-bit buswidth" - depends on DRIVER_CFI default y help If you wish to support CFI devices on a physical bus which is @@ -28,7 +23,6 @@ config DRIVER_CFI_BANK_WIDTH_1 config DRIVER_CFI_BANK_WIDTH_2 bool "Support 16-bit buswidth" - depends on DRIVER_CFI default y help If you wish to support CFI devices on a physical bus which is @@ -36,7 +30,6 @@ config DRIVER_CFI_BANK_WIDTH_2 config DRIVER_CFI_BANK_WIDTH_4 bool "Support 32-bit buswidth" - depends on DRIVER_CFI default y help If you wish to support CFI devices on a physical bus which is @@ -44,16 +37,11 @@ config DRIVER_CFI_BANK_WIDTH_4 config DRIVER_CFI_BANK_WIDTH_8 bool "Support 64-bit buswidth" - depends on DRIVER_CFI - default n help If you wish to support CFI devices on a physical bus which is 64 bits wide, say 'Y'. config CFI_BUFFER_WRITE bool "use cfi driver with buffer write" - depends on DRIVER_CFI || DRIVER_CFI endif - -endmenu diff --git a/drivers/nor/Makefile b/drivers/mtd/nor/Makefile index d2550436d2..d2550436d2 100644 --- a/drivers/nor/Makefile +++ b/drivers/mtd/nor/Makefile diff --git a/drivers/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c index 637f98b10a..0cfac2d036 100644 --- a/drivers/nor/cfi_flash.c +++ b/drivers/mtd/nor/cfi_flash.c @@ -454,10 +454,8 @@ flash_sect_t find_sector (struct flash_info *info, ulong addr) return sector; } -static int __cfi_erase(struct cdev *cdev, size_t count, loff_t offset, - int verbose) +static int cfi_erase(struct flash_info *finfo, size_t count, loff_t offset) { - struct flash_info *finfo = (struct flash_info *)cdev->priv; unsigned long start, end; int i, ret = 0; @@ -467,9 +465,6 @@ static int __cfi_erase(struct cdev *cdev, size_t count, loff_t offset, end = find_sector(finfo, (unsigned long)finfo->base + offset + count - 1); - if (verbose) - init_progression_bar(end - start); - for (i = start; i <= end; i++) { ret = finfo->cfi_cmd_set->flash_erase_one(finfo, i); if (ret) @@ -479,21 +474,11 @@ static int __cfi_erase(struct cdev *cdev, size_t count, loff_t offset, ret = -EINTR; goto out; } - - if (verbose) - show_progress(i - start); } out: - if (verbose) - putchar('\n'); return ret; } -static int cfi_erase(struct cdev *cdev, size_t count, loff_t offset) -{ - return __cfi_erase(cdev, count, offset, 1); -} - /* * Copy memory to flash, returns: * 0 - OK @@ -626,18 +611,13 @@ static int flash_real_protect (struct flash_info *info, long sector, int prot) return retcode; } -static int cfi_protect(struct cdev *cdev, size_t count, loff_t offset, int prot) +static int cfi_mtd_protect(struct flash_info *finfo, loff_t offset, size_t len, int prot) { - struct flash_info *finfo = (struct flash_info *)cdev->priv; unsigned long start, end; int i, ret = 0; - const char *action = (prot? "protect" : "unprotect"); - - printf("%s: %s 0x%p (size %zu)\n", __func__, - action, finfo->base + offset, count); start = find_sector(finfo, (unsigned long)finfo->base + offset); - end = find_sector(finfo, (unsigned long)finfo->base + offset + count - 1); + end = find_sector(finfo, (unsigned long)finfo->base + offset + len - 1); for (i = start; i <= end; i++) { ret = flash_real_protect (finfo, i, prot); @@ -645,20 +625,21 @@ static int cfi_protect(struct cdev *cdev, size_t count, loff_t offset, int prot) goto out; } out: - putchar('\n'); return ret; } -static ssize_t cfi_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags) +static int cfi_mtd_lock(struct mtd_info *mtd, loff_t offset, size_t len) { - struct flash_info *finfo = (struct flash_info *)cdev->priv; - int ret; + struct flash_info *finfo = container_of(mtd, struct flash_info, mtd); - debug("cfi_write: buf=0x%p addr=0x%p count=0x%08zx\n", - buf, finfo->base + offset, count); + return cfi_mtd_protect(finfo, offset, len, 1); +} - ret = write_buff(finfo, buf, (unsigned long)finfo->base + offset, count); - return ret == 0 ? count : -1; +static int cfi_mtd_unlock(struct mtd_info *mtd, loff_t offset, size_t len) +{ + struct flash_info *finfo = container_of(mtd, struct flash_info, mtd); + + return cfi_mtd_protect(finfo, offset, len, 0); } static void cfi_info (struct device_d* dev) @@ -908,15 +889,6 @@ int flash_isset(struct flash_info *info, flash_sect_t sect, return retval; } -struct file_operations cfi_ops = { - .read = mem_read, - .write = cfi_write, - .lseek = dev_lseek_default, - .erase = cfi_erase, - .protect = cfi_protect, - .memmap = generic_memmap_ro, -}; - static int cfi_mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { @@ -943,10 +915,9 @@ static int cfi_mtd_write(struct mtd_info *mtd, loff_t to, size_t len, static int cfi_mtd_erase(struct mtd_info *mtd, struct erase_info *instr) { struct flash_info *info = container_of(mtd, struct flash_info, mtd); - struct cdev *cdev = &info->cdev; int ret; - ret = __cfi_erase(cdev, instr->len, instr->addr, 0); + ret = cfi_erase(info, instr->len, instr->addr); if (ret) { instr->state = MTD_ERASE_FAILED; @@ -966,21 +937,23 @@ static void cfi_init_mtd(struct flash_info *info) mtd->read = cfi_mtd_read; mtd->write = cfi_mtd_write; mtd->erase = cfi_mtd_erase; + mtd->lock = cfi_mtd_lock; + mtd->unlock = cfi_mtd_unlock; mtd->size = info->size; - mtd->name = info->cdev.name; mtd->erasesize = info->eraseregions[1].erasesize; /* FIXME */ mtd->writesize = 1; mtd->subpage_sft = 0; mtd->eraseregions = info->eraseregions; mtd->numeraseregions = info->numeraseregions; mtd->flags = MTD_CAP_NORFLASH; - info->cdev.mtd = mtd; + mtd->type = MTD_NORFLASH; + + add_mtd_device(mtd, "nor"); } static int cfi_probe (struct device_d *dev) { struct flash_info *info = xzalloc(sizeof(*info)); - int cfinum; dev->priv = (void *)info; @@ -999,24 +972,7 @@ static int cfi_probe (struct device_d *dev) dev_info(dev, "found cfi flash at %p, size %ld\n", info->base, info->size); - if (dev->id < 0) - cfinum = cdev_find_free_index("nor"); - else - cfinum = dev->id; - - info->cdev.name = asprintf("nor%d", cfinum); - info->cdev.size = info->size; - info->cdev.dev = dev; - info->cdev.ops = &cfi_ops; - info->cdev.priv = info; - - if (IS_ENABLED(CONFIG_PARTITION_NEED_MTD)) - cfi_init_mtd(info); - - devfs_create(&info->cdev); - - if (dev->device_node) - of_parse_partitions(info->cdev.name, dev->device_node); + cfi_init_mtd(info); return 0; } @@ -1035,10 +991,4 @@ static struct driver_d cfi_driver = { .info = cfi_info, .of_compatible = DRV_OF_COMPAT(cfi_dt_ids), }; - -static int cfi_init(void) -{ - return platform_driver_register(&cfi_driver); -} - -device_initcall(cfi_init); +device_platform_driver(cfi_driver); diff --git a/drivers/nor/cfi_flash.h b/drivers/mtd/nor/cfi_flash.h index 944cdde660..bcf5c40c73 100644 --- a/drivers/nor/cfi_flash.h +++ b/drivers/mtd/nor/cfi_flash.h @@ -74,7 +74,6 @@ struct flash_info { ulong addr_unlock1; /* unlock address 1 for AMD flash roms */ ulong addr_unlock2; /* unlock address 2 for AMD flash roms */ struct cfi_cmd_set *cfi_cmd_set; - struct cdev cdev; struct mtd_info mtd; int numeraseregions; struct mtd_erase_region_info *eraseregions; diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/mtd/nor/cfi_flash_amd.c index 45c59b9d01..45c59b9d01 100644 --- a/drivers/nor/cfi_flash_amd.c +++ b/drivers/mtd/nor/cfi_flash_amd.c diff --git a/drivers/nor/cfi_flash_intel.c b/drivers/mtd/nor/cfi_flash_intel.c index 32e581a395..32e581a395 100644 --- a/drivers/nor/cfi_flash_intel.c +++ b/drivers/mtd/nor/cfi_flash_intel.c diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index e3598b9d9d..000fc5d921 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -151,7 +151,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, addr = (loff_t)pnum * ubi->peb_size + offset; retry: - err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); + err = mtd_read(ubi->mtd, addr, len, &read, buf); if (err) { if (err == -EUCLEAN) { /* @@ -265,7 +265,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, } addr = (loff_t)pnum * ubi->peb_size + offset; - err = ubi->mtd->write(ubi->mtd, addr, len, &written, buf); + err = mtd_write(ubi->mtd, addr, len, &written, buf); if (err) { ubi_err("error %d while writing %d bytes to PEB %d:%d, written" " %zd bytes", err, len, pnum, offset, written); @@ -315,7 +315,7 @@ retry: ei.callback = erase_callback; ei.priv = (unsigned long)&wq; - err = ubi->mtd->erase(ubi->mtd, &ei); + err = mtd_erase(ubi->mtd, &ei); if (err) { if (retries++ < UBI_IO_RETRIES) { dbg_io("error %d while erasing PEB %d, retry", @@ -1239,7 +1239,7 @@ static int paranoid_check_all_ff(struct ubi_device *ubi, int pnum, int offset, loff_t addr = (loff_t)pnum * ubi->peb_size + offset; mutex_lock(&ubi->dbg_buf_mutex); - err = ubi->mtd->read(ubi->mtd, addr, len, &read, ubi->dbg_peb_buf); + err = mtd_read(ubi->mtd, addr, len, &read, ubi->dbg_peb_buf); if (err && err != -EUCLEAN) { ubi_err("error %d while reading %d bytes from PEB %d:%d, " "read %zd bytes", err, len, pnum, offset, read); diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index cf6ceee06a..2736094b8b 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -27,12 +27,16 @@ menu "Network drivers" source "drivers/net/phy/Kconfig" +config DRIVER_NET_CALXEDA_XGMAC + bool "Calxeda xgmac" + config DRIVER_NET_CS8900 bool "cs8900 ethernet driver" depends on HAS_CS8900 config DRIVER_NET_CPSW bool "CPSW ethernet driver" + depends on ARCH_OMAP select PHYLIB config DRIVER_NET_SMC911X diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 6e1aeaaadf..42136f87c8 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -1,3 +1,4 @@ +obj-$(CONFIG_DRIVER_NET_CALXEDA_XGMAC) += xgmac.o obj-$(CONFIG_DRIVER_NET_CS8900) += cs8900.o obj-$(CONFIG_DRIVER_NET_CPSW) += cpsw.o obj-$(CONFIG_DRIVER_NET_SMC911X) += smc911x.o diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c index f0e907e78e..1a442781a9 100644 --- a/drivers/net/altera_tse.c +++ b/drivers/net/altera_tse.c @@ -557,12 +557,4 @@ static struct driver_d altera_tse_driver = { .name = "altera_tse", .probe = tse_probe, }; - -static int tse_init(void) -{ - platform_driver_register(&altera_tse_driver); - return 0; -} - -device_initcall(tse_init); - +device_platform_driver(altera_tse_driver); diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c index a0854dff52..dad78155fa 100644 --- a/drivers/net/at91_ether.c +++ b/drivers/net/at91_ether.c @@ -366,10 +366,4 @@ static struct driver_d at91_ether_driver = { .probe = at91_ether_probe, .remove = at91_ether_remove, }; - -static int at91_ether_driver_init(void) -{ - platform_driver_register(&at91_ether_driver); - return 0; -} -device_initcall(at91_ether_driver_init); +device_platform_driver(at91_ether_driver); diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c index 58c097afe4..e51a8b1b6e 100644 --- a/drivers/net/cpsw.c +++ b/drivers/net/cpsw.c @@ -1061,10 +1061,4 @@ static struct driver_d cpsw_driver = { .name = "cpsw", .probe = cpsw_probe, }; - -static int cpsw_register(void) -{ - return platform_driver_register(&cpsw_driver); -} - -device_initcall(cpsw_register); +device_platform_driver(cpsw_driver); diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c index b1ef3902c4..b0d045a4e9 100644 --- a/drivers/net/cs8900.c +++ b/drivers/net/cs8900.c @@ -468,11 +468,4 @@ static struct driver_d cs8900_driver = { .probe = cs8900_probe, .info = cs8900_info, }; - -static int cs8900_init(void) -{ - platform_driver_register(&cs8900_driver); - return 0; -} - -device_initcall(cs8900_init); +device_platform_driver(cs8900_driver); diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index 989e119c38..7848f50b9b 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -608,11 +608,4 @@ static struct driver_d davinci_emac_driver = { .probe = davinci_emac_probe, .remove = davinci_emac_remove, }; - -static int davinci_emac_register(void) -{ - platform_driver_register(&davinci_emac_driver); - return 0; -} - -device_initcall(davinci_emac_register); +device_platform_driver(davinci_emac_driver); diff --git a/drivers/net/designware.c b/drivers/net/designware.c index f803e6693a..a6b32b9b2e 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -455,10 +455,4 @@ static struct driver_d dwc_ether_driver = { .probe = dwc_ether_probe, .remove = dwc_ether_remove, }; - -static int dwc_ether_driver_init(void) -{ - platform_driver_register(&dwc_ether_driver); - return 0; -} -device_initcall(dwc_ether_driver_init); +device_platform_driver(dwc_ether_driver); diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c index 8be0f16646..090482c0ad 100644 --- a/drivers/net/dm9k.c +++ b/drivers/net/dm9k.c @@ -780,11 +780,4 @@ static struct driver_d dm9k_driver = { .name = "dm9000", .probe = dm9k_probe, }; - -static int dm9k_init(void) -{ - platform_driver_register(&dm9k_driver); - return 0; -} - -device_initcall(dm9k_init); +device_platform_driver(dm9k_driver); diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c index 37c9f0a81e..1ecef13394 100644 --- a/drivers/net/ep93xx.c +++ b/drivers/net/ep93xx.c @@ -663,11 +663,4 @@ static struct driver_d ep93xx_eth_driver = { .name = "ep93xx_eth", .probe = ep93xx_eth_probe, }; - -static int ep93xx_eth_init(void) -{ - platform_driver_register(&ep93xx_eth_driver); - return 0; -} - -device_initcall(ep93xx_eth_init); +device_platform_driver(ep93xx_eth_driver); diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c index 2378a19366..578000ac1b 100644 --- a/drivers/net/fec_imx.c +++ b/drivers/net/fec_imx.c @@ -86,7 +86,7 @@ static int fec_miibus_read(struct mii_bus *bus, int phyAddr, int regAddr) start = get_time_ns(); while (!(readl(fec->regs + FEC_IEVENT) & FEC_IEVENT_MII)) { if (is_timeout(start, MSECOND)) { - printf("Read MDIO failed...\n"); + dev_err(&fec->edev.dev, "Read MDIO failed...\n"); return -1; } } @@ -126,7 +126,7 @@ static int fec_miibus_write(struct mii_bus *bus, int phyAddr, start = get_time_ns(); while (!(readl(fec->regs + FEC_IEVENT) & FEC_IEVENT_MII)) { if (is_timeout(start, MSECOND)) { - printf("Write MDIO failed...\n"); + dev_err(&fec->edev.dev, "Write MDIO failed...\n"); return -1; } } @@ -309,7 +309,7 @@ static int fec_init(struct eth_device *dev) } if (fec->xcv_type == RMII) { - if (fec_is_imx28(fec)) { + if (fec_is_imx28(fec) || fec_is_imx6(fec)) { rcntl |= FEC_R_CNTRL_RMII_MODE | FEC_R_CNTRL_FCE | FEC_R_CNTRL_NO_LGTH_CHECK; } else { @@ -361,12 +361,18 @@ static int fec_init(struct eth_device *dev) static void fec_update_linkspeed(struct eth_device *edev) { struct fec_priv *fec = (struct fec_priv *)edev->priv; + int speed = edev->phydev->speed; + u32 rcntl = readl(fec->regs + FEC_R_CNTRL) & ~FEC_R_CNTRL_RMII_10T; + u32 ecntl = readl(fec->regs + FEC_ECNTRL) & ~FEC_ECNTRL_SPEED; - if (edev->phydev->speed == SPEED_10) { - u32 rcntl = readl(fec->regs + FEC_R_CNTRL); + if (speed == SPEED_10) rcntl |= FEC_R_CNTRL_RMII_10T; - writel(rcntl, fec->regs + FEC_R_CNTRL); - } + + if (speed == SPEED_1000) + ecntl |= FEC_ECNTRL_SPEED; + + writel(rcntl, fec->regs + FEC_R_CNTRL); + writel(ecntl, fec->regs + FEC_ECNTRL); } /** @@ -425,15 +431,20 @@ static int fec_open(struct eth_device *edev) static void fec_halt(struct eth_device *dev) { struct fec_priv *fec = (struct fec_priv *)dev->priv; - int counter = 0xffff; + uint64_t tmo; /* issue graceful stop command to the FEC transmitter if necessary */ writel(readl(fec->regs + FEC_X_CNTRL) | FEC_ECNTRL_RESET, fec->regs + FEC_X_CNTRL); /* wait for graceful stop to register */ - while ((counter--) && (!(readl(fec->regs + FEC_IEVENT) & FEC_IEVENT_GRA))) - ; /* FIXME ensure time */ + tmo = get_time_ns(); + while (!(readl(fec->regs + FEC_IEVENT) & FEC_IEVENT_GRA)) { + if (is_timeout(tmo, 1 * SECOND)) { + dev_err(&dev->dev, "graceful stop timeout\n"); + break; + } + } /* Disable SmartDMA tasks */ fec_tx_task_disable(fec); @@ -468,12 +479,12 @@ static int fec_send(struct eth_device *dev, void *eth_data, int data_length) /* Check for valid length of data. */ if ((data_length > 1500) || (data_length <= 0)) { - printf("Payload (%d) to large!\n", data_length); + dev_err(&dev->dev, "Payload (%d) to large!\n", data_length); return -1; } if ((uint32_t)eth_data & (DB_DATA_ALIGNMENT-1)) - printf("%s: Warning: Transmit data not aligned: %p!\n", __FUNCTION__, eth_data); + dev_warn(&dev->dev, "Transmit data not aligned: %p!\n", eth_data); /* * Setup the transmit buffer @@ -506,7 +517,7 @@ static int fec_send(struct eth_device *dev, void *eth_data, int data_length) tmo = get_time_ns(); while (readw(&fec->tbd_base[fec->tbd_index].status) & FEC_TBD_READY) { if (is_timeout(tmo, 1 * SECOND)) { - printf("transmission timeout\n"); + dev_err(&dev->dev, "transmission timeout\n"); break; } } @@ -544,7 +555,7 @@ static int fec_recv(struct eth_device *dev) /* BABT, Rx/Tx FIFO errors */ fec_halt(dev); fec_init(dev); - printf("some error: 0x%08x\n", ievent); + dev_err(&dev->dev, "some error: 0x%08x\n", ievent); return 0; } if (!fec_is_imx28(fec)) { @@ -587,7 +598,7 @@ static int fec_recv(struct eth_device *dev) len = frame_length; } else { if (bd_status & FEC_RBD_ERR) { - printf("error frame: 0x%p 0x%08x\n", rbd, bd_status); + dev_warn(&dev->dev, "error frame: 0x%p 0x%08x\n", rbd, bd_status); } } /* @@ -768,14 +779,7 @@ static struct driver_d fec_driver = { .of_compatible = DRV_OF_COMPAT(imx_fec_dt_ids), .id_table = imx_fec_ids, }; - -static int fec_register(void) -{ - platform_driver_register(&fec_driver); - return 0; -} - -device_initcall(fec_register); +device_platform_driver(fec_driver); /** * @file diff --git a/drivers/net/fec_imx.h b/drivers/net/fec_imx.h index 1eb1eba5a1..29aea852df 100644 --- a/drivers/net/fec_imx.h +++ b/drivers/net/fec_imx.h @@ -92,6 +92,7 @@ #define FEC_ECNTRL_RESET 0x00000001 /**< reset the FEC */ #define FEC_ECNTRL_ETHER_EN 0x00000002 /**< enable the FEC */ +#define FEC_ECNTRL_SPEED 0x00000020 /**< i.MX6: enable 1000Mbps mode */ /** * @brief Descriptor buffer alignment diff --git a/drivers/net/fec_mpc5200.c b/drivers/net/fec_mpc5200.c index a14c8d1c4f..9ef5350aaf 100644 --- a/drivers/net/fec_mpc5200.c +++ b/drivers/net/fec_mpc5200.c @@ -717,12 +717,4 @@ static struct driver_d mpc5xxx_driver = { .probe = mpc5xxx_fec_probe, .remove = mpc5xxx_fec_remove, }; - -static int mpc5xxx_fec_register(void) -{ - platform_driver_register(&mpc5xxx_driver); - return 0; -} - -device_initcall(mpc5xxx_fec_register); - +device_platform_driver(mpc5xxx_driver); diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 55675baea6..96055bd39c 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c @@ -528,11 +528,4 @@ static struct driver_d gfar_eth_driver = { .name = "gfar", .probe = gfar_probe, }; - -static int gfar_eth_init(void) -{ - platform_driver_register(&gfar_eth_driver); - return 0; -} - -device_initcall(gfar_eth_init); +device_platform_driver(gfar_eth_driver); diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c index 79b88f216a..9c0e5a7a10 100644 --- a/drivers/net/ks8851_mll.c +++ b/drivers/net/ks8851_mll.c @@ -873,11 +873,4 @@ static struct driver_d ks8851_driver = { .name = "ks8851_mll", .probe = ks8851_probe, }; - -static int ks8851_init(void) -{ - platform_driver_register(&ks8851_driver); - return 0; -} - -device_initcall(ks8851_init); +device_platform_driver(ks8851_driver); diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 0cfad05406..8602437a09 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -666,11 +666,4 @@ static struct driver_d macb_driver = { .name = "macb", .probe = macb_probe, }; - -static int macb_driver_init(void) -{ - debug("%s\n", __func__); - platform_driver_register(&macb_driver); - return 0; -} -device_initcall(macb_driver_init); +device_platform_driver(macb_driver); diff --git a/drivers/net/netx_eth.c b/drivers/net/netx_eth.c index e2b5591d25..9ca9bce1f8 100644 --- a/drivers/net/netx_eth.c +++ b/drivers/net/netx_eth.c @@ -276,12 +276,4 @@ static struct driver_d netx_eth_driver = { .name = "netx-eth", .probe = netx_eth_probe, }; - -static int netx_eth_init(void) -{ - platform_driver_register(&netx_eth_driver); - return 0; -} - -device_initcall(netx_eth_init); - +device_platform_driver(netx_eth_driver); diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index d1d802b57b..e1bb7b1235 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -167,10 +167,14 @@ static int mdio_bus_probe(struct device_d *_dev) dev->speed = SPEED_10; dev->duplex = DUPLEX_FULL; dev->autoneg = !AUTONEG_ENABLE; + dev->force = 1; + dev->link = 1; } else if (dev->dev_flags & PHYLIB_FORCE_100) { dev->speed = SPEED_100; dev->duplex = DUPLEX_FULL; dev->autoneg = !AUTONEG_ENABLE; + dev->force = 1; + dev->link = 1; } } diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 1cf2cb97a3..12739ff361 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -549,6 +549,10 @@ int genphy_read_status(struct phy_device *phydev) int lpa; int lpagb = 0; + /* if force the status and link are set */ + if (phydev->force) + return 0; + /* Update the link, but return if there * was an error */ err = genphy_update_link(phydev); diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c index ac978d91dc..48183dd4fa 100644 --- a/drivers/net/smc91111.c +++ b/drivers/net/smc91111.c @@ -935,7 +935,7 @@ static int smc91c111_eth_send(struct eth_device *edev, void *packet, if (numPages > 7) { printf ("%s: Far too big packet error. \n", SMC_DEV_NAME); - return 0; + return -EOVERFLOW; } /* now, try to allocate the memory */ @@ -965,7 +965,7 @@ again: if (try < SMC_ALLOC_MAX_TRY) goto again; else - return 0; + return -ETIMEDOUT; } PRINTK2 ("%s: memory allocation, try %d succeeded ...\n", @@ -980,7 +980,7 @@ again: if (packet_no & AR_FAILED) { /* or isn't there? BAD CHIP! */ printf ("%s: Memory allocation failed. \n", SMC_DEV_NAME); - return 0; + return -ENOMEM; } /* we have a packet address, so tell the card to use it */ @@ -1046,7 +1046,7 @@ again: SMC_outb(priv, saved_pnr, PN_REG ); SMC_outw(priv, saved_ptr, PTR_REG ); - return length; + return 0; } static void smc91c111_eth_halt(struct eth_device *edev) @@ -1152,10 +1152,10 @@ static int smc91c111_eth_rx(struct eth_device *edev) if (!is_error) { /* Pass the packet up to the protocol layers. */ net_receive(NetRxPackets[0], packet_length); - return packet_length; + return 0; } - return 0; + return -EINVAL; } static int smc91c111_get_ethaddr(struct eth_device *edev, unsigned char *m) @@ -1319,11 +1319,4 @@ static struct driver_d smc91c111_driver = { .name = "smc91c111", .probe = smc91c111_probe, }; - -static int smc91c111_init(void) -{ - platform_driver_register(&smc91c111_driver); - return 0; -} - -device_initcall(smc91c111_init); +device_platform_driver(smc91c111_driver); diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 28c69ba872..3b94779cd9 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -638,12 +638,4 @@ static struct driver_d smc911x_driver = { .name = "smc911x", .probe = smc911x_probe, }; - -static int smc911x_init(void) -{ - platform_driver_register(&smc911x_driver); - return 0; -} - -device_initcall(smc911x_init); - +device_platform_driver(smc911x_driver); diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 1cf4e1861b..436b0e085a 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -109,11 +109,4 @@ static struct driver_d tap_driver = { .name = "tap", .probe = tap_probe, }; - -static int tap_init(void) -{ - platform_driver_register(&tap_driver); - return 0; -} - -device_initcall(tap_init); +device_platform_driver(tap_driver); diff --git a/drivers/net/xgmac.c b/drivers/net/xgmac.c new file mode 100644 index 0000000000..203e6827ee --- /dev/null +++ b/drivers/net/xgmac.c @@ -0,0 +1,740 @@ +/* + * Copyright 2010-2011 Calxeda, Inc. + * + * 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 it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <common.h> +#include <net.h> +#include <clock.h> +#include <malloc.h> +#include <xfuncs.h> +#include <init.h> +#include <errno.h> +#include <io.h> +#include <linux/err.h> +#include <asm/mmu.h> + +#define TX_NUM_DESC 1 +#define RX_NUM_DESC 32 + +#define ETH_BUF_SZ 2048 +#define TX_BUF_SZ (ETH_BUF_SZ * TX_NUM_DESC) +#define RX_BUF_SZ (ETH_BUF_SZ * RX_NUM_DESC) + +/* XGMAC Register definitions */ +#define XGMAC_CONTROL 0x00000000 /* MAC Configuration */ +#define XGMAC_FRAME_FILTER 0x00000004 /* MAC Frame Filter */ +#define XGMAC_FLOW_CTRL 0x00000018 /* MAC Flow Control */ +#define XGMAC_VLAN_TAG 0x0000001C /* VLAN Tags */ +#define XGMAC_VERSION 0x00000020 /* Version */ +#define XGMAC_VLAN_INCL 0x00000024 /* VLAN tag for tx frames */ +#define XGMAC_LPI_CTRL 0x00000028 /* LPI Control and Status */ +#define XGMAC_LPI_TIMER 0x0000002C /* LPI Timers Control */ +#define XGMAC_TX_PACE 0x00000030 /* Transmit Pace and Stretch */ +#define XGMAC_VLAN_HASH 0x00000034 /* VLAN Hash Table */ +#define XGMAC_DEBUG 0x00000038 /* Debug */ +#define XGMAC_INT_STAT 0x0000003C /* Interrupt and Control */ +#define XGMAC_ADDR_HIGH(reg) (0x00000040 + ((reg) * 8)) +#define XGMAC_ADDR_LOW(reg) (0x00000044 + ((reg) * 8)) +#define XGMAC_HASH(n) (0x00000300 + (n) * 4) /* HASH table regs */ +#define XGMAC_NUM_HASH 16 +#define XGMAC_OMR 0x00000400 +#define XGMAC_REMOTE_WAKE 0x00000700 /* Remote Wake-Up Frm Filter */ +#define XGMAC_PMT 0x00000704 /* PMT Control and Status */ +#define XGMAC_MMC_CTRL 0x00000800 /* XGMAC MMC Control */ +#define XGMAC_MMC_INTR_RX 0x00000804 /* Recieve Interrupt */ +#define XGMAC_MMC_INTR_TX 0x00000808 /* Transmit Interrupt */ +#define XGMAC_MMC_INTR_MASK_RX 0x0000080c /* Recieve Interrupt Mask */ +#define XGMAC_MMC_INTR_MASK_TX 0x00000810 /* Transmit Interrupt Mask */ + + +/* Hardware TX Statistics Counters */ +#define XGMAC_MMC_TXOCTET_GB_LO 0x00000814 +#define XGMAC_MMC_TXOCTET_GB_HI 0x00000818 +#define XGMAC_MMC_TXFRAME_GB_LO 0x0000081C +#define XGMAC_MMC_TXFRAME_GB_HI 0x00000820 +#define XGMAC_MMC_TXBCFRAME_G 0x00000824 +#define XGMAC_MMC_TXMCFRAME_G 0x0000082C +#define XGMAC_MMC_TXUCFRAME_GB 0x00000864 +#define XGMAC_MMC_TXMCFRAME_GB 0x0000086C +#define XGMAC_MMC_TXBCFRAME_GB 0x00000874 +#define XGMAC_MMC_TXUNDERFLOW 0x0000087C +#define XGMAC_MMC_TXOCTET_G_LO 0x00000884 +#define XGMAC_MMC_TXOCTET_G_HI 0x00000888 +#define XGMAC_MMC_TXFRAME_G_LO 0x0000088C +#define XGMAC_MMC_TXFRAME_G_HI 0x00000890 +#define XGMAC_MMC_TXPAUSEFRAME 0x00000894 +#define XGMAC_MMC_TXVLANFRAME 0x0000089C + +/* Hardware RX Statistics Counters */ +#define XGMAC_MMC_RXFRAME_GB_LO 0x00000900 +#define XGMAC_MMC_RXFRAME_GB_HI 0x00000904 +#define XGMAC_MMC_RXOCTET_GB_LO 0x00000908 +#define XGMAC_MMC_RXOCTET_GB_HI 0x0000090C +#define XGMAC_MMC_RXOCTET_G_LO 0x00000910 +#define XGMAC_MMC_RXOCTET_G_HI 0x00000914 +#define XGMAC_MMC_RXBCFRAME_G 0x00000918 +#define XGMAC_MMC_RXMCFRAME_G 0x00000920 +#define XGMAC_MMC_RXCRCERR 0x00000928 +#define XGMAC_MMC_RXRUNT 0x00000930 +#define XGMAC_MMC_RXJABBER 0x00000934 +#define XGMAC_MMC_RXUCFRAME_G 0x00000970 +#define XGMAC_MMC_RXLENGTHERR 0x00000978 +#define XGMAC_MMC_RXPAUSEFRAME 0x00000988 +#define XGMAC_MMC_RXOVERFLOW 0x00000990 +#define XGMAC_MMC_RXVLANFRAME 0x00000998 +#define XGMAC_MMC_RXWATCHDOG 0x000009a0 + +/* DMA Control and Status Registers */ +#define XGMAC_DMA_BUS_MODE 0x00000f00 /* Bus Mode */ +#define XGMAC_DMA_TX_POLL 0x00000f04 /* Transmit Poll Demand */ +#define XGMAC_DMA_RX_POLL 0x00000f08 /* Received Poll Demand */ +#define XGMAC_DMA_RX_BASE_ADDR 0x00000f0c /* Receive List Base */ +#define XGMAC_DMA_TX_BASE_ADDR 0x00000f10 /* Transmit List Base */ +#define XGMAC_DMA_STATUS 0x00000f14 /* Status Register */ +#define XGMAC_DMA_CONTROL 0x00000f18 /* Ctrl (Operational Mode) */ +#define XGMAC_DMA_INTR_ENA 0x00000f1c /* Interrupt Enable */ +#define XGMAC_DMA_MISS_FRAME_CTR 0x00000f20 /* Missed Frame Counter */ +#define XGMAC_DMA_RI_WDOG_TIMER 0x00000f24 /* RX Intr Watchdog Timer */ +#define XGMAC_DMA_AXI_BUS 0x00000f28 /* AXI Bus Mode */ +#define XGMAC_DMA_AXI_STATUS 0x00000f2C /* AXI Status */ +#define XGMAC_DMA_HW_FEATURE 0x00000f58 /* Enabled Hardware Features */ + +#define XGMAC_ADDR_AE 0x80000000 +#define XGMAC_MAX_FILTER_ADDR 31 + +/* PMT Control and Status */ +#define XGMAC_PMT_POINTER_RESET 0x80000000 +#define XGMAC_PMT_GLBL_UNICAST 0x00000200 +#define XGMAC_PMT_WAKEUP_RX_FRM 0x00000040 +#define XGMAC_PMT_MAGIC_PKT 0x00000020 +#define XGMAC_PMT_WAKEUP_FRM_EN 0x00000004 +#define XGMAC_PMT_MAGIC_PKT_EN 0x00000002 +#define XGMAC_PMT_POWERDOWN 0x00000001 + +#define XGMAC_CONTROL_SPD 0x40000000 /* Speed control */ +#define XGMAC_CONTROL_SPD_MASK 0x60000000 +#define XGMAC_CONTROL_SPD_1G 0x60000000 +#define XGMAC_CONTROL_SPD_2_5G 0x40000000 +#define XGMAC_CONTROL_SPD_10G 0x00000000 +#define XGMAC_CONTROL_SARC 0x10000000 /* Source Addr Insert/Replace */ +#define XGMAC_CONTROL_SARK_MASK 0x18000000 +#define XGMAC_CONTROL_CAR 0x04000000 /* CRC Addition/Replacement */ +#define XGMAC_CONTROL_CAR_MASK 0x06000000 +#define XGMAC_CONTROL_DP 0x01000000 /* Disable Padding */ +#define XGMAC_CONTROL_WD 0x00800000 /* Disable Watchdog on rx */ +#define XGMAC_CONTROL_JD 0x00400000 /* Jabber disable */ +#define XGMAC_CONTROL_JE 0x00100000 /* Jumbo frame */ +#define XGMAC_CONTROL_LM 0x00001000 /* Loop-back mode */ +#define XGMAC_CONTROL_IPC 0x00000400 /* Checksum Offload */ +#define XGMAC_CONTROL_ACS 0x00000080 /* Automatic Pad/FCS Strip */ +#define XGMAC_CONTROL_DDIC 0x00000010 /* Disable Deficit Idle Count */ +#define XGMAC_CONTROL_TE 0x00000008 /* Transmitter Enable */ +#define XGMAC_CONTROL_RE 0x00000004 /* Receiver Enable */ + +/* XGMAC Frame Filter defines */ +#define XGMAC_FRAME_FILTER_PR 0x00000001 /* Promiscuous Mode */ +#define XGMAC_FRAME_FILTER_HUC 0x00000002 /* Hash Unicast */ +#define XGMAC_FRAME_FILTER_HMC 0x00000004 /* Hash Multicast */ +#define XGMAC_FRAME_FILTER_DAIF 0x00000008 /* DA Inverse Filtering */ +#define XGMAC_FRAME_FILTER_PM 0x00000010 /* Pass all multicast */ +#define XGMAC_FRAME_FILTER_DBF 0x00000020 /* Disable Broadcast frames */ +#define XGMAC_FRAME_FILTER_SAIF 0x00000100 /* Inverse Filtering */ +#define XGMAC_FRAME_FILTER_SAF 0x00000200 /* Source Address Filter */ +#define XGMAC_FRAME_FILTER_HPF 0x00000400 /* Hash or perfect Filter */ +#define XGMAC_FRAME_FILTER_VHF 0x00000800 /* VLAN Hash Filter */ +#define XGMAC_FRAME_FILTER_VPF 0x00001000 /* VLAN Perfect Filter */ +#define XGMAC_FRAME_FILTER_RA 0x80000000 /* Receive all mode */ + +#define FIFO_MINUS_1K 0x0 +#define FIFO_MINUS_2K 0x1 +#define FIFO_MINUS_3K 0x2 +#define FIFO_MINUS_4K 0x3 +#define FIFO_MINUS_6K 0x4 +#define FIFO_MINUS_8K 0x5 +#define FIFO_MINUS_12K 0x6 +#define FIFO_MINUS_16K 0x7 + +/* XGMAC FLOW CTRL defines */ +#define XGMAC_FLOW_CTRL_PT_MASK 0xffff0000 /* Pause Time Mask */ +#define XGMAC_FLOW_CTRL_PT_SHIFT 16 +#define XGMAC_FLOW_CTRL_DZQP 0x00000080 /* Disable Zero-Quanta Phase */ +#define XGMAC_FLOW_CTRL_PLT 0x00000020 /* Pause Low Threshhold */ +#define XGMAC_FLOW_CTRL_PLT_SHIFT 4 +#define XGMAC_FLOW_CTRL_PLT_MASK 0x00000030 /* PLT MASK */ +#define XGMAC_FLOW_CTRL_UP 0x00000008 /* Unicast Pause Frame Detect */ +#define XGMAC_FLOW_CTRL_RFE 0x00000004 /* Rx Flow Control Enable */ +#define XGMAC_FLOW_CTRL_TFE 0x00000002 /* Tx Flow Control Enable */ +#define XGMAC_FLOW_CTRL_FCB_BPA 0x00000001 /* Flow Control Busy ... */ + +/* XGMAC_INT_STAT reg */ +#define XGMAC_INT_STAT_PMT 0x0080 /* PMT Interrupt Status */ +#define XGMAC_INT_STAT_LPI 0x0040 /* LPI Interrupt Status */ + +/* DMA Bus Mode register defines */ +#define DMA_BUS_MODE_SFT_RESET 0x00000001 /* Software Reset */ +#define DMA_BUS_MODE_DSL_MASK 0x0000007c /* Descriptor Skip Length */ +#define DMA_BUS_MODE_DSL_SHIFT 2 /* (in DWORDS) */ +#define DMA_BUS_MODE_ATDS 0x00000080 /* Alternate Descriptor Size */ + +/* Programmable burst length */ +#define DMA_BUS_MODE_PBL_MASK 0x00003f00 /* Programmable Burst Len */ +#define DMA_BUS_MODE_PBL_SHIFT 8 +#define DMA_BUS_MODE_FB 0x00010000 /* Fixed burst */ +#define DMA_BUS_MODE_RPBL_MASK 0x003e0000 /* Rx-Programmable Burst Len */ +#define DMA_BUS_MODE_RPBL_SHIFT 17 +#define DMA_BUS_MODE_USP 0x00800000 +#define DMA_BUS_MODE_8PBL 0x01000000 +#define DMA_BUS_MODE_AAL 0x02000000 + +#define DMA_AXIMODE_ENLPI 0x80000000 +#define DMA_AXIMODE_MGK 0x40000000 +#define DMA_AXIMODE_WROSR 0x00100000 +#define DMA_AXIMODE_WROSR_MASK 0x00F00000 +#define DMA_AXIMODE_WROSR_SHIFT 20 +#define DMA_AXIMODE_RDOSR 0x00010000 +#define DMA_AXIMODE_RDOSR_MASK 0x000F0000 +#define DMA_AXIMODE_RDOSR_SHIFT 16 +#define DMA_AXIMODE_AAL 0x00001000 +#define DMA_AXIMODE_BLEN256 0x00000080 +#define DMA_AXIMODE_BLEN128 0x00000040 +#define DMA_AXIMODE_BLEN64 0x00000020 +#define DMA_AXIMODE_BLEN32 0x00000010 +#define DMA_AXIMODE_BLEN16 0x00000008 +#define DMA_AXIMODE_BLEN8 0x00000004 +#define DMA_AXIMODE_BLEN4 0x00000002 +#define DMA_AXIMODE_UNDEF 0x00000001 + +/* DMA Bus Mode register defines */ +#define DMA_BUS_PR_RATIO_MASK 0x0000c000 /* Rx/Tx priority ratio */ +#define DMA_BUS_PR_RATIO_SHIFT 14 +#define DMA_BUS_FB 0x00010000 /* Fixed Burst */ + +/* DMA Control register defines */ +#define DMA_CONTROL_ST 0x00002000 /* Start/Stop Transmission */ +#define DMA_CONTROL_SR 0x00000002 /* Start/Stop Receive */ +#define DMA_CONTROL_DFF 0x01000000 /* Disable flush of rx frames */ + +/* DMA Normal interrupt */ +#define DMA_INTR_ENA_NIE 0x00010000 /* Normal Summary */ +#define DMA_INTR_ENA_AIE 0x00008000 /* Abnormal Summary */ +#define DMA_INTR_ENA_ERE 0x00004000 /* Early Receive */ +#define DMA_INTR_ENA_FBE 0x00002000 /* Fatal Bus Error */ +#define DMA_INTR_ENA_ETE 0x00000400 /* Early Transmit */ +#define DMA_INTR_ENA_RWE 0x00000200 /* Receive Watchdog */ +#define DMA_INTR_ENA_RSE 0x00000100 /* Receive Stopped */ +#define DMA_INTR_ENA_RUE 0x00000080 /* Receive Buffer Unavailable */ +#define DMA_INTR_ENA_RIE 0x00000040 /* Receive Interrupt */ +#define DMA_INTR_ENA_UNE 0x00000020 /* Tx Underflow */ +#define DMA_INTR_ENA_OVE 0x00000010 /* Receive Overflow */ +#define DMA_INTR_ENA_TJE 0x00000008 /* Transmit Jabber */ +#define DMA_INTR_ENA_TUE 0x00000004 /* Transmit Buffer Unavail */ +#define DMA_INTR_ENA_TSE 0x00000002 /* Transmit Stopped */ +#define DMA_INTR_ENA_TIE 0x00000001 /* Transmit Interrupt */ + +#define DMA_INTR_NORMAL (DMA_INTR_ENA_NIE | DMA_INTR_ENA_RIE | \ + DMA_INTR_ENA_TUE) + +#define DMA_INTR_ABNORMAL (DMA_INTR_ENA_AIE | DMA_INTR_ENA_FBE | \ + DMA_INTR_ENA_RWE | DMA_INTR_ENA_RSE | \ + DMA_INTR_ENA_RUE | DMA_INTR_ENA_UNE | \ + DMA_INTR_ENA_OVE | DMA_INTR_ENA_TJE | \ + DMA_INTR_ENA_TSE) + +/* DMA default interrupt mask */ +#define DMA_INTR_DEFAULT_MASK (DMA_INTR_NORMAL | DMA_INTR_ABNORMAL) + +/* DMA Status register defines */ +#define DMA_STATUS_GMI 0x08000000 /* MMC interrupt */ +#define DMA_STATUS_GLI 0x04000000 /* GMAC Line interface int */ +#define DMA_STATUS_EB_MASK 0x00380000 /* Error Bits Mask */ +#define DMA_STATUS_EB_TX_ABORT 0x00080000 /* Error Bits - TX Abort */ +#define DMA_STATUS_EB_RX_ABORT 0x00100000 /* Error Bits - RX Abort */ +#define DMA_STATUS_TS_MASK 0x00700000 /* Transmit Process State */ +#define DMA_STATUS_TS_SHIFT 20 +#define DMA_STATUS_RS_MASK 0x000e0000 /* Receive Process State */ +#define DMA_STATUS_RS_SHIFT 17 +#define DMA_STATUS_NIS 0x00010000 /* Normal Interrupt Summary */ +#define DMA_STATUS_AIS 0x00008000 /* Abnormal Interrupt Summary */ +#define DMA_STATUS_ERI 0x00004000 /* Early Receive Interrupt */ +#define DMA_STATUS_FBI 0x00002000 /* Fatal Bus Error Interrupt */ +#define DMA_STATUS_ETI 0x00000400 /* Early Transmit Interrupt */ +#define DMA_STATUS_RWT 0x00000200 /* Receive Watchdog Timeout */ +#define DMA_STATUS_RPS 0x00000100 /* Receive Process Stopped */ +#define DMA_STATUS_RU 0x00000080 /* Receive Buffer Unavailable */ +#define DMA_STATUS_RI 0x00000040 /* Receive Interrupt */ +#define DMA_STATUS_UNF 0x00000020 /* Transmit Underflow */ +#define DMA_STATUS_OVF 0x00000010 /* Receive Overflow */ +#define DMA_STATUS_TJT 0x00000008 /* Transmit Jabber Timeout */ +#define DMA_STATUS_TU 0x00000004 /* Transmit Buffer Unavail */ +#define DMA_STATUS_TPS 0x00000002 /* Transmit Process Stopped */ +#define DMA_STATUS_TI 0x00000001 /* Transmit Interrupt */ + +/* Common MAC defines */ +#define MAC_ENABLE_TX 0x00000008 /* Transmitter Enable */ +#define MAC_ENABLE_RX 0x00000004 /* Receiver Enable */ + +/* XGMAC Operation Mode Register */ +#define XGMAC_OMR_TSF 0x00200000 /* TX FIFO Store and Forward */ +#define XGMAC_OMR_FTF 0x00100000 /* Flush Transmit FIFO */ +#define XGMAC_OMR_TTC 0x00020000 /* Transmit Threshhold Ctrl */ +#define XGMAC_OMR_TTC_SHIFT 16 +#define XGMAC_OMR_TTC_MASK 0x00030000 +#define XGMAC_OMR_RFD 0x00006000 /* FC Deactivation Threshhold */ +#define XGMAC_OMR_RFD_SHIFT 12 +#define XGMAC_OMR_RFD_MASK 0x00007000 /* FC Deact Threshhold MASK */ +#define XGMAC_OMR_RFA 0x00000600 /* FC Activation Threshhold */ +#define XGMAC_OMR_RFA_SHIFT 9 +#define XGMAC_OMR_RFA_MASK 0x00000E00 /* FC Act Threshhold MASK */ +#define XGMAC_OMR_EFC 0x00000100 /* Enable Hardware FC */ +#define XGMAC_OMR_FEF 0x00000080 /* Forward Error Frames */ +#define XGMAC_OMR_DT 0x00000040 /* Drop TCP/IP csum Errors */ +#define XGMAC_OMR_RSF 0x00000020 /* RX FIFO Store and Forward */ +#define XGMAC_OMR_RTC_256 0x00000018 /* RX Threshhold Ctrl */ +#define XGMAC_OMR_RTC_MASK 0x00000018 /* RX Threshhold Ctrl MASK */ + +/* XGMAC HW Features Register */ +#define DMA_HW_FEAT_TXCOESEL 0x00010000 /* TX Checksum offload */ + +#define XGMAC_MMC_CTRL_CNT_FRZ 0x00000008 + +/* XGMAC Descriptor Defines */ +#define MAX_DESC_BUF_SZ (0x2000 - 8) + +#define RXDESC_EXT_STATUS 0x00000001 +#define RXDESC_CRC_ERR 0x00000002 +#define RXDESC_RX_ERR 0x00000008 +#define RXDESC_RX_WDOG 0x00000010 +#define RXDESC_FRAME_TYPE 0x00000020 +#define RXDESC_GIANT_FRAME 0x00000080 +#define RXDESC_LAST_SEG 0x00000100 +#define RXDESC_FIRST_SEG 0x00000200 +#define RXDESC_VLAN_FRAME 0x00000400 +#define RXDESC_OVERFLOW_ERR 0x00000800 +#define RXDESC_LENGTH_ERR 0x00001000 +#define RXDESC_SA_FILTER_FAIL 0x00002000 +#define RXDESC_DESCRIPTOR_ERR 0x00004000 +#define RXDESC_ERROR_SUMMARY 0x00008000 +#define RXDESC_FRAME_LEN_OFFSET 16 +#define RXDESC_FRAME_LEN_MASK 0x3fff0000 +#define RXDESC_DA_FILTER_FAIL 0x40000000 + +#define RXDESC1_END_RING 0x00008000 + +#define RXDESC_IP_PAYLOAD_MASK 0x00000003 +#define RXDESC_IP_PAYLOAD_UDP 0x00000001 +#define RXDESC_IP_PAYLOAD_TCP 0x00000002 +#define RXDESC_IP_PAYLOAD_ICMP 0x00000003 +#define RXDESC_IP_HEADER_ERR 0x00000008 +#define RXDESC_IP_PAYLOAD_ERR 0x00000010 +#define RXDESC_IPV4_PACKET 0x00000040 +#define RXDESC_IPV6_PACKET 0x00000080 +#define TXDESC_UNDERFLOW_ERR 0x00000001 +#define TXDESC_JABBER_TIMEOUT 0x00000002 +#define TXDESC_LOCAL_FAULT 0x00000004 +#define TXDESC_REMOTE_FAULT 0x00000008 +#define TXDESC_VLAN_FRAME 0x00000010 +#define TXDESC_FRAME_FLUSHED 0x00000020 +#define TXDESC_IP_HEADER_ERR 0x00000040 +#define TXDESC_PAYLOAD_CSUM_ERR 0x00000080 +#define TXDESC_ERROR_SUMMARY 0x00008000 +#define TXDESC_SA_CTRL_INSERT 0x00040000 +#define TXDESC_SA_CTRL_REPLACE 0x00080000 +#define TXDESC_2ND_ADDR_CHAINED 0x00100000 +#define TXDESC_END_RING 0x00200000 +#define TXDESC_CSUM_IP 0x00400000 +#define TXDESC_CSUM_IP_PAYLD 0x00800000 +#define TXDESC_CSUM_ALL 0x00C00000 +#define TXDESC_CRC_EN_REPLACE 0x01000000 +#define TXDESC_CRC_EN_APPEND 0x02000000 +#define TXDESC_DISABLE_PAD 0x04000000 +#define TXDESC_FIRST_SEG 0x10000000 +#define TXDESC_LAST_SEG 0x20000000 +#define TXDESC_INTERRUPT 0x40000000 + +#define DESC_OWN 0x80000000 +#define DESC_BUFFER1_SZ_MASK 0x00001fff +#define DESC_BUFFER2_SZ_MASK 0x1fff0000 +#define DESC_BUFFER2_SZ_OFFSET 16 + +struct xgmac_dma_desc { + __le32 flags; + __le32 buf_size; + __le32 buf1_addr; /* Buffer 1 Address Pointer */ + __le32 buf2_addr; /* Buffer 2 Address Pointer */ + __le32 ext_status; + __le32 res[3]; +}; + +struct xgmac_priv { + struct xgmac_dma_desc *rx_chain; + struct xgmac_dma_desc *tx_chain; + char *rxbuffer; + + u32 tx_currdesc; + u32 rx_currdesc; + + void __iomem *base; + + struct eth_device edev; + struct device_d *dev; +}; + +/* XGMAC Descriptor Access Helpers */ +static inline void desc_set_buf_len(struct xgmac_dma_desc *p, u32 buf_sz) +{ + if (buf_sz > MAX_DESC_BUF_SZ) + p->buf_size = cpu_to_le32(MAX_DESC_BUF_SZ | + (buf_sz - MAX_DESC_BUF_SZ) << DESC_BUFFER2_SZ_OFFSET); + else + p->buf_size = cpu_to_le32(buf_sz); +} + +static inline int desc_get_buf_len(struct xgmac_dma_desc *p) +{ + u32 len = le32_to_cpu(p->buf_size); + return (len & DESC_BUFFER1_SZ_MASK) + + ((len & DESC_BUFFER2_SZ_MASK) >> DESC_BUFFER2_SZ_OFFSET); +} + +static inline void desc_init_rx_desc(struct xgmac_dma_desc *p, int ring_size, + int buf_sz) +{ + struct xgmac_dma_desc *end = p + ring_size - 1; + + memset(p, 0, sizeof(*p) * ring_size); + + for (; p <= end; p++) + desc_set_buf_len(p, buf_sz); + + end->buf_size |= cpu_to_le32(RXDESC1_END_RING); +} + +static inline void desc_init_tx_desc(struct xgmac_dma_desc *p, u32 ring_size) +{ + memset(p, 0, sizeof(*p) * ring_size); + p[ring_size - 1].flags = cpu_to_le32(TXDESC_END_RING); +} + +static inline int desc_get_owner(struct xgmac_dma_desc *p) +{ + return le32_to_cpu(p->flags) & DESC_OWN; +} + +static inline void desc_set_rx_owner(struct xgmac_dma_desc *p) +{ + /* Clear all fields and set the owner */ + p->flags = cpu_to_le32(DESC_OWN); +} + +static inline void desc_set_tx_owner(struct xgmac_dma_desc *p, u32 flags) +{ + u32 tmpflags = le32_to_cpu(p->flags); + tmpflags &= TXDESC_END_RING; + tmpflags |= flags | DESC_OWN; + p->flags = cpu_to_le32(tmpflags); +} + +static inline void *desc_get_buf_addr(struct xgmac_dma_desc *p) +{ + return (void *)le32_to_cpu(p->buf1_addr); +} + +static inline void desc_set_buf_addr(struct xgmac_dma_desc *p, + void *paddr, int len) +{ + p->buf1_addr = cpu_to_le32(paddr); + if (len > MAX_DESC_BUF_SZ) + p->buf2_addr = cpu_to_le32(paddr + MAX_DESC_BUF_SZ); +} + +static inline void desc_set_buf_addr_and_size(struct xgmac_dma_desc *p, + void *paddr, int len) +{ + desc_set_buf_len(p, len); + desc_set_buf_addr(p, paddr, len); +} + +static inline int desc_get_rx_frame_len(struct xgmac_dma_desc *p) +{ + u32 data = le32_to_cpu(p->flags); + u32 len = (data & RXDESC_FRAME_LEN_MASK) >> RXDESC_FRAME_LEN_OFFSET; + if (data & RXDESC_FRAME_TYPE) + len -= 4; + + return len; +} + +/* + * Initialize a descriptor ring. Calxeda XGMAC is configured to use + * advanced descriptors. + */ + +static void init_rx_desc(struct xgmac_priv *priv) +{ + struct xgmac_dma_desc *rxdesc = priv->rx_chain; + void *rxbuffer = priv->rxbuffer; + int i; + + desc_init_rx_desc(rxdesc, RX_NUM_DESC, ETH_BUF_SZ); + writel((ulong)rxdesc, priv->base + XGMAC_DMA_RX_BASE_ADDR); + + for (i = 0; i < RX_NUM_DESC; i++) { + desc_set_buf_addr(rxdesc + i, rxbuffer + (i * ETH_BUF_SZ), + ETH_BUF_SZ); + desc_set_rx_owner(rxdesc + i); + } +} + +static void init_tx_desc(struct xgmac_priv *priv) +{ + desc_init_tx_desc(priv->tx_chain, TX_NUM_DESC); + writel((ulong)priv->tx_chain, priv->base + XGMAC_DMA_TX_BASE_ADDR); +} + +static int xgmac_reset(struct eth_device *dev) +{ + struct xgmac_priv *priv = dev->priv; + int ret; + u32 value; + + value = readl(priv->base + XGMAC_CONTROL) & XGMAC_CONTROL_SPD_MASK; + + writel(DMA_BUS_MODE_SFT_RESET, priv->base + XGMAC_DMA_BUS_MODE); + + ret = wait_on_timeout(100 * MSECOND, + !(readl(priv->base + XGMAC_DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET)); + + writel(value, priv->base + XGMAC_CONTROL); + + return ret; +} + +static int xgmac_open(struct eth_device *edev) +{ + struct xgmac_priv *priv = edev->priv; + int value; + int ret; + + ret = xgmac_reset(edev); + if (ret) + return ret; + + /* set the AXI bus modes */ + value = DMA_BUS_MODE_ATDS | + (16 << DMA_BUS_MODE_PBL_SHIFT) | + DMA_BUS_MODE_FB | DMA_BUS_MODE_AAL; + writel(value, priv->base + XGMAC_DMA_BUS_MODE); + + value = DMA_AXIMODE_AAL | DMA_AXIMODE_BLEN16 | + DMA_AXIMODE_BLEN8 | DMA_AXIMODE_BLEN4; + writel(value, priv->base + XGMAC_DMA_AXI_BUS); + + /* set flow control parameters and store and forward mode */ + value = (FIFO_MINUS_12K << XGMAC_OMR_RFD_SHIFT) | + (FIFO_MINUS_4K << XGMAC_OMR_RFA_SHIFT) | + XGMAC_OMR_EFC | XGMAC_OMR_TSF | XGMAC_OMR_RSF; + writel(value, priv->base + XGMAC_OMR); + + /* enable pause frames */ + value = (1024 << XGMAC_FLOW_CTRL_PT_SHIFT) | + (1 << XGMAC_FLOW_CTRL_PLT_SHIFT) | + XGMAC_FLOW_CTRL_UP | XGMAC_FLOW_CTRL_RFE | XGMAC_FLOW_CTRL_TFE; + writel(value, priv->base + XGMAC_FLOW_CTRL); + + /* Initialize the descriptor chains */ + init_rx_desc(priv); + init_tx_desc(priv); + + /* must set to 0, or when started up will cause issues */ + priv->tx_currdesc = 0; + priv->rx_currdesc = 0; + + /* set default core values */ + value = readl(priv->base + XGMAC_CONTROL); + value &= XGMAC_CONTROL_SPD_MASK; + value |= XGMAC_CONTROL_DDIC | XGMAC_CONTROL_ACS | + XGMAC_CONTROL_IPC | XGMAC_CONTROL_CAR; + + /* Everything is ready enable both mac and DMA */ + value |= XGMAC_CONTROL_RE | XGMAC_CONTROL_TE; + writel(value, priv->base + XGMAC_CONTROL); + + value = readl(priv->base + XGMAC_DMA_CONTROL); + value |= DMA_CONTROL_SR | DMA_CONTROL_ST; + writel(value, priv->base + XGMAC_DMA_CONTROL); + + return 0; +} + +static int xgmac_send(struct eth_device *edev, void *packet, int length) +{ + struct xgmac_priv *priv = edev->priv; + u32 currdesc = priv->tx_currdesc; + struct xgmac_dma_desc *txdesc = &priv->tx_chain[currdesc]; + int ret; + + dma_flush_range((ulong) packet, (ulong)packet + length); + desc_set_buf_addr_and_size(txdesc, packet, length); + desc_set_tx_owner(txdesc, TXDESC_FIRST_SEG | + TXDESC_LAST_SEG | TXDESC_CRC_EN_APPEND); + + /* write poll demand */ + writel(1, priv->base + XGMAC_DMA_TX_POLL); + + ret = wait_on_timeout(1 * SECOND, !desc_get_owner(txdesc)); + if (ret) { + dev_err(priv->dev, "TX timeout\n"); + return ret; + } + + priv->tx_currdesc = (currdesc + 1) & (TX_NUM_DESC - 1); + return 0; +} + +static int xgmac_recv(struct eth_device *edev) +{ + struct xgmac_priv *priv = edev->priv; + u32 currdesc = priv->rx_currdesc; + struct xgmac_dma_desc *rxdesc = &priv->rx_chain[currdesc]; + int length = 0; + + /* check if the host has the desc */ + if (desc_get_owner(rxdesc)) + return -1; /* something bad happened */ + + length = desc_get_rx_frame_len(rxdesc); + + net_receive(desc_get_buf_addr(rxdesc), length); + + /* set descriptor back to owned by XGMAC */ + desc_set_rx_owner(rxdesc); + writel(1, priv->base + XGMAC_DMA_RX_POLL); + + priv->rx_currdesc = (currdesc + 1) & (RX_NUM_DESC - 1); + + return length; +} + +static void xgmac_halt(struct eth_device *edev) +{ + struct xgmac_priv *priv = edev->priv; + int value; + + /* Disable TX/RX */ + value = readl(priv->base + XGMAC_CONTROL); + value &= ~(XGMAC_CONTROL_RE | XGMAC_CONTROL_TE); + writel(value, priv->base + XGMAC_CONTROL); + + /* Disable DMA */ + value = readl(priv->base + XGMAC_DMA_CONTROL); + value &= ~(DMA_CONTROL_SR | DMA_CONTROL_ST); + writel(value, priv->base + XGMAC_DMA_CONTROL); + + /* must set to 0, or when started up will cause issues */ + priv->tx_currdesc = 0; + priv->rx_currdesc = 0; +} + +static int xgmac_get_ethaddr(struct eth_device *edev, unsigned char *addr) +{ + struct xgmac_priv *priv = edev->priv; + u32 hi_addr, lo_addr; + + /* Read the MAC address from the hardware */ + hi_addr = readl(priv->base + XGMAC_ADDR_HIGH(0)); + lo_addr = readl(priv->base + XGMAC_ADDR_LOW(0)); + + /* Extract the MAC address from the high and low words */ + addr[0] = lo_addr & 0xff; + addr[1] = (lo_addr >> 8) & 0xff; + addr[2] = (lo_addr >> 16) & 0xff; + addr[3] = (lo_addr >> 24) & 0xff; + addr[4] = hi_addr & 0xff; + addr[5] = (hi_addr >> 8) & 0xff; + + return 0; +} + +static int xgmac_set_ethaddr(struct eth_device *dev, unsigned char *addr) +{ + struct xgmac_priv *priv = dev->priv; + u32 data; + + data = (addr[5] << 8) | addr[4]; + writel(data, priv->base + XGMAC_ADDR_HIGH(0)); + data = (addr[3] << 24) | (addr[2] << 16) | (addr[1] << 8) | addr[0]; + writel(data, priv->base + XGMAC_ADDR_LOW(0)); + + return 0; +} + +static int hb_xgmac_probe(struct device_d *dev) +{ + struct eth_device *edev; + struct xgmac_priv *priv; + void __iomem *base; + + base = dev_request_mem_region(dev, 0); + + /* check hardware version */ + if (readl(base + XGMAC_VERSION) != 0x1012) + return -EINVAL; + + priv = xzalloc(sizeof(*priv)); + + priv->dev = dev; + priv->base = base; + + priv->rxbuffer = dma_alloc_coherent(RX_BUF_SZ); + priv->rx_chain = dma_alloc_coherent(RX_NUM_DESC * sizeof(struct xgmac_dma_desc)); + priv->tx_chain = dma_alloc_coherent(TX_NUM_DESC * sizeof(struct xgmac_dma_desc)); + + edev = &priv->edev; + edev->priv = priv; + + edev->open = xgmac_open; + edev->send = xgmac_send; + edev->recv = xgmac_recv; + edev->halt = xgmac_halt; + edev->get_ethaddr = xgmac_get_ethaddr; + edev->set_ethaddr = xgmac_set_ethaddr; + edev->parent = dev; + + eth_register(edev); + + return 0; +} + +static __maybe_unused struct of_device_id xgmac_dt_ids[] = { + { + .compatible = "calxeda,hb-xgmac", + }, { + /* sentinel */ + } +}; + +static struct driver_d hb_xgmac_driver = { + .name = "hb-xgmac", + .probe = hb_xgmac_probe, + .of_compatible = DRV_OF_COMPAT(xgmac_dt_ids), +}; + +static int hb_xgmac_driver_init(void) +{ + debug("%s\n", __func__); + return platform_driver_register(&hb_xgmac_driver); +} +device_initcall(hb_xgmac_driver_init); diff --git a/drivers/of/base.c b/drivers/of/base.c index eaaeaf4f49..fd9b8e14a3 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -26,6 +26,7 @@ #include <memory.h> #include <sizes.h> #include <linux/ctype.h> +#include <linux/amba/bus.h> /** * struct alias_prop - Alias property in 'aliases' node @@ -641,18 +642,44 @@ void of_delete_property(struct property *pp) free(pp); } -static struct device_d *add_of_device(struct device_node *node) +static struct device_d *add_of_amba_device(struct device_node *node) { - struct device_d *dev; + struct amba_device *dev; char *name, *at; - const struct property *cp; - if (of_node_disabled(node)) - return NULL; + dev = xzalloc(sizeof(*dev)); - cp = of_get_property(node, "compatible", NULL); - if (!cp) - return NULL; + name = xstrdup(node->name); + at = strchr(name, '@'); + if (at) { + *at = 0; + snprintf(dev->dev.name, MAX_DRIVER_NAME, "%s.%s", at + 1, name); + } else { + strncpy(dev->dev.name, node->name, MAX_DRIVER_NAME); + } + + dev->dev.id = DEVICE_ID_SINGLE; + memcpy(&dev->res, &node->resource[0], sizeof(struct resource)); + dev->dev.resource = node->resource; + dev->dev.num_resources = 1; + dev->dev.device_node = node; + node->device = &dev->dev; + + of_property_read_u32(node, "arm,primecell-periphid", &dev->periphid); + + debug("register device 0x%08x\n", node->resource[0].start); + + amba_device_add(dev); + + free(name); + + return &dev->dev; +} + +static struct device_d *add_of_platform_device(struct device_node *node) +{ + struct device_d *dev; + char *name, *at; dev = xzalloc(sizeof(*dev)); @@ -679,6 +706,24 @@ static struct device_d *add_of_device(struct device_node *node) return dev; } + +static struct device_d *add_of_device(struct device_node *node) +{ + const struct property *cp; + + if (of_node_disabled(node)) + return NULL; + + cp = of_get_property(node, "compatible", NULL); + if (!cp) + return NULL; + + if (IS_ENABLED(CONFIG_ARM_AMBA) && + of_device_is_compatible(node, "arm,primecell") == 1) + return add_of_amba_device(node); + else + return add_of_platform_device(node); +} EXPORT_SYMBOL(add_of_device); u64 dt_mem_next_cell(int s, const __be32 **cellp) @@ -689,18 +734,26 @@ u64 dt_mem_next_cell(int s, const __be32 **cellp) return of_read_number(p, s); } -static int of_add_memory(struct device_node *node) +int of_add_memory(struct device_node *node, bool dump) { int na, nc; const __be32 *reg, *endp; - int len, r = 0; + int len, r = 0, ret; static char str[6]; + const char *device_type; + + ret = of_property_read_string(node, "device_type", &device_type); + if (ret) + return -ENXIO; + + if (strcmp(device_type, "memory")) + return -ENXIO; of_bus_count_cells(node, &na, &nc); reg = of_get_property(node, "reg", &len); if (!reg) - return 0; + return -EINVAL; endp = reg + (len / sizeof(__be32)); @@ -717,6 +770,9 @@ static int of_add_memory(struct device_node *node) barebox_add_memory_bank(str, base, size); + if (dump) + pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base); + r++; } @@ -725,7 +781,7 @@ static int of_add_memory(struct device_node *node) static int add_of_device_resource(struct device_node *node) { - struct property *reg, *type; + struct property *reg; u64 address, size; struct resource *res; struct device_d *dev; @@ -738,9 +794,9 @@ static int add_of_device_resource(struct device_node *node) list_add_tail(&node->phandles, &phandle_list); } - type = of_find_property(node, "device_type"); - if (type) - return of_add_memory(node); + ret = of_add_memory(node, false); + if (ret != -ENXIO) + return ret; reg = of_find_property(node, "reg"); if (!reg) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index f61d6708a4..48bea603e8 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -22,7 +22,11 @@ config DRIVER_SERIAL_IMX config DRIVER_SERIAL_STM378X depends on ARCH_MXS default y - bool "i.MX23/i.MX28 serial driver" + bool "i.MX23/i.MX28 debug UART serial driver" + +config DRIVER_SERIAL_AUART + depends on ARCH_MXS + bool "i.MX23/i.MX28 application UART serial driver" config DRIVER_SERIAL_NETX depends on ARCH_NETX diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 893e282c63..4a23aefddb 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -1,9 +1,3 @@ -# atmel_usart.o -# ns9750_serial.o -# s3c4510b_uart.o -# serial_max3100.o -# serial_pl010.o -# serial_xuartlite.o obj-$(CONFIG_DRIVER_SERIAL_ARM_DCC) += arm_dcc.o obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o obj-$(CONFIG_DRIVER_SERIAL_IMX) += serial_imx.o @@ -21,3 +15,4 @@ obj-$(CONFIG_DRIVER_SERIAL_ALTERA) += serial_altera.o obj-$(CONFIG_DRIVER_SERIAL_ALTERA_JTAG) += serial_altera_jtag.o obj-$(CONFIG_DRIVER_SERIAL_PXA) += serial_pxa.o obj-$(CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT) += serial_omap4_usbboot.o +obj-$(CONFIG_DRIVER_SERIAL_AUART) += serial_auart.o diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index 58c69e5c2d..0e075880e0 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c @@ -175,7 +175,7 @@ int pl011_init_port (struct console_device *cdev) /* ** Finally, enable the UART */ - writel((UART01x_CR_UARTEN | UART011_CR_TXE | UART011_CR_RXE), + writel((UART01x_CR_UARTEN | UART011_CR_TXE | UART011_CR_RXE | UART011_CR_RTS), uart->base + UART011_CR); return 0; diff --git a/drivers/serial/serial_auart.c b/drivers/serial/serial_auart.c new file mode 100644 index 0000000000..fa2e04f447 --- /dev/null +++ b/drivers/serial/serial_auart.c @@ -0,0 +1,238 @@ +/* + * (C) 2013 Marc Kleine-Budde <mkl@pengutronix.de> + * + * Based on the stm-serial driver: + * + * (C) Copyright 2010 Juergen Beisert - Pengutronix + * + * ...also based on the u-boot auart driver: + * + * (C) 2011 Wolfgang Ocker <weo@reccoware.de> + * + * Based on the standard DUART serial driver: + * + * (C) 2007 Sascha Hauer <s.hauer@pengutronix.de> + * + * (C) Copyright 2009-2010 Freescale Semiconductor, Inc. + * + * Further based on the Linux mxs-auart.c driver: + * + * Freescale STMP37XX/STMP378X Application UART driver + * + * Author: dmitry pervushin <dimka@embeddedalley.com> + * + * Copyright 2008-2010 Freescale Semiconductor, Inc. + * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved. + * + * 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 <gpio.h> +#include <init.h> +#include <io.h> +#include <malloc.h> +#include <notifier.h> + +#include <mach/clock.h> +#include <mach/mxs.h> +#include <mach/imx-regs.h> + +#define HW_UARTAPP_CTRL0 (0x00000000) + +#define HW_UARTAPP_CTRL2 (0x00000020) +#define HW_UARTAPP_CTRL2_SET (0x00000024) +#define HW_UARTAPP_CTRL2_CLR (0x00000028) +#define BM_UARTAPP_CTRL2_CTSEN (0x00008000) +#define BM_UARTAPP_CTRL2_RTSEN (0x00004000) +#define BM_UARTAPP_CTRL2_RXE (0x00000200) +#define BM_UARTAPP_CTRL2_TXE (0x00000100) +#define BM_UARTAPP_CTRL2_USE_LCR2 (0x00000040) +#define BM_UARTAPP_CTRL2_UARTEN (0x00000001) + +#define HW_UARTAPP_LINECTRL (0x00000030) +#define BM_UARTAPP_LINECTRL_FEN (0x00000010) + +#define BM_UARTAPP_LINECTRL_BAUD_DIVFRAC (0x00003F00) +#define BF_UARTAPP_LINECTRL_BAUD_DIVFRAC(v) \ + (((v) << 8) & BM_UARTAPP_LINECTRL_BAUD_DIVFRAC) + +#define BP_UARTAPP_LINECTRL_BAUD_DIVINT (16) +#define BM_UARTAPP_LINECTRL_BAUD_DIVINT (0xFFFF0000) +#define BF_UARTAPP_LINECTRL_BAUD_DIVINT(v) \ + (((v) << 16) & BM_UARTAPP_LINECTRL_BAUD_DIVINT) + +#define BP_UARTAPP_LINECTRL_WLEN (5) +#define BM_UARTAPP_LINECTRL_WLEN (0x00000060) +#define BF_UARTAPP_LINECTRL_WLEN(v) \ + (((v) << 5) & BM_UARTAPP_LINECTRL_WLEN) + +#define HW_UARTAPP_LINECTRL2_SET (0x00000044) + +#define HW_UARTAPP_INTR (0x00000050) + +#define HW_UARTAPP_DATA (0x00000060) +#define BM_UARTAPP_STAT_RXFE (0x01000000) +#define BM_UARTAPP_STAT_TXFE (0x08000000) + +#define HW_UARTAPP_STAT (0x00000070) +#define BM_UARTAPP_STAT_TXFF (0x02000000) + +struct auart_priv { + struct console_device cdev; + int baudrate; + struct notifier_block notify; + void __iomem *base; +}; + +static void auart_serial_putc(struct console_device *cdev, char c) +{ + struct auart_priv *priv = container_of(cdev, struct auart_priv, cdev); + + /* Wait for room in TX FIFO */ + while (readl(priv->base + HW_UARTAPP_STAT) & BM_UARTAPP_STAT_TXFF) + ; + + writel(c, priv->base + HW_UARTAPP_DATA); +} + +static int auart_serial_tstc(struct console_device *cdev) +{ + struct auart_priv *priv = container_of(cdev, struct auart_priv, cdev); + + /* Check if RX FIFO is not empty */ + return !(readl(priv->base + HW_UARTAPP_STAT) & BM_UARTAPP_STAT_RXFE); +} + +static int auart_serial_getc(struct console_device *cdev) +{ + struct auart_priv *priv = container_of(cdev, struct auart_priv, cdev); + + /* Wait while RX FIFO is empty */ + while (!auart_serial_tstc(cdev)) + ; + + return readl(priv->base + HW_UARTAPP_DATA) & 0xff; +} + +static void auart_serial_flush(struct console_device *cdev) +{ + struct auart_priv *priv = container_of(cdev, struct auart_priv, cdev); + + /* Wait for TX FIFO empty */ + while (readl(priv->base + HW_UARTAPP_STAT) & BM_UARTAPP_STAT_TXFE) + ; +} + +static int auart_serial_setbaudrate(struct console_device *cdev, int new_baudrate) +{ + struct auart_priv *priv = container_of(cdev, struct auart_priv, cdev); + uint32_t ctrl2, quot, reg; + + /* Disable everything */ + ctrl2 = readl(priv->base + HW_UARTAPP_CTRL2); + writel(0x0, priv->base + HW_UARTAPP_CTRL2); + + /* Calculate and set baudrate */ + quot = (imx_get_xclk() * 32) / new_baudrate; + reg = BF_UARTAPP_LINECTRL_BAUD_DIVFRAC(quot & 0x3F) | + BF_UARTAPP_LINECTRL_BAUD_DIVINT(quot >> 6) | + BF_UARTAPP_LINECTRL_WLEN(3) | + BM_UARTAPP_LINECTRL_FEN; + + writel(reg, priv->base + HW_UARTAPP_LINECTRL); + + /* Re-enable UART */ + writel(ctrl2, priv->base + HW_UARTAPP_CTRL2); + + priv->baudrate = new_baudrate; + + return 0; +} + +static int auart_clocksource_clock_change(struct notifier_block *nb, unsigned long event, void *data) +{ + struct auart_priv *priv = container_of(nb, struct auart_priv, notify); + + return auart_serial_setbaudrate(&priv->cdev, priv->baudrate); +} + +static void auart_serial_init_port(struct auart_priv *priv) +{ + mxs_reset_block(priv->base + HW_UARTAPP_CTRL0, 0); + + /* Disable UART */ + writel(0x0, priv->base + HW_UARTAPP_CTRL2); + /* Mask interrupts */ + writel(0x0, priv->base + HW_UARTAPP_INTR); +} + +static int auart_serial_probe(struct device_d *dev) +{ + struct auart_priv *priv; + struct console_device *cdev; + + priv = xzalloc(sizeof *priv); + cdev = &priv->cdev; + + cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR; + cdev->tstc = auart_serial_tstc; + cdev->putc = auart_serial_putc; + cdev->getc = auart_serial_getc; + cdev->flush = auart_serial_flush; + cdev->setbrg = auart_serial_setbaudrate; + cdev->dev = dev; + + dev->priv = priv; + priv->base = dev_request_mem_region(dev, 0); + + auart_serial_init_port(priv); + auart_serial_setbaudrate(cdev, CONFIG_BAUDRATE); + + /* Disable RTS/CTS, enable Rx, Tx, UART */ + writel(BM_UARTAPP_CTRL2_RTSEN | BM_UARTAPP_CTRL2_CTSEN | + BM_UARTAPP_CTRL2_USE_LCR2, + priv->base + HW_UARTAPP_CTRL2_CLR); + writel(BM_UARTAPP_CTRL2_RXE | BM_UARTAPP_CTRL2_TXE | + BM_UARTAPP_CTRL2_UARTEN, + priv->base + HW_UARTAPP_CTRL2_SET); + + console_register(cdev); + priv->notify.notifier_call = auart_clocksource_clock_change; + clock_register_client(&priv->notify); + + return 0; +} + + +static void auart_serial_remove(struct device_d *dev) +{ + struct auart_priv *priv = dev->priv; + + auart_serial_flush(&priv->cdev); + console_unregister(&priv->cdev); + free(priv); +} + +static struct driver_d auart_serial_driver = { + .name = "auart_serial", + .probe = auart_serial_probe, + .remove = auart_serial_remove, +}; + +static int auart_serial_init(void) +{ + platform_driver_register(&auart_serial_driver); + return 0; +} + +console_initcall(auart_serial_init); diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 10b8fea7bd..f14e28f545 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -33,6 +33,11 @@ config DRIVER_SPI_IMX_2_3 depends on ARCH_IMX51 || ARCH_IMX53 || ARCH_IMX6 default y +config DRIVER_SPI_MXS + bool "i.MX (23,28) SPI Master driver" + depends on ARCH_IMX23 || ARCH_IMX28 + depends on SPI + config DRIVER_SPI_OMAP3 bool "OMAP3 McSPI Master driver" depends on ARCH_OMAP3 diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index b53061edfc..642b7ecc4a 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -1,5 +1,6 @@ obj-$(CONFIG_SPI) += spi.o obj-$(CONFIG_DRIVER_SPI_IMX) += imx_spi.o +obj-$(CONFIG_DRIVER_SPI_MXS) += mxs_spi.o obj-$(CONFIG_DRIVER_SPI_ALTERA) += altera_spi.o obj-$(CONFIG_DRIVER_SPI_ATMEL) += atmel_spi.o obj-$(CONFIG_DRIVER_SPI_OMAP3) += omap3_spi.o diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index a089761278..60e124ff77 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -239,10 +239,4 @@ static struct driver_d altera_spi_driver = { .name = "altera_spi", .probe = altera_spi_probe, }; - -static int altera_spi_driver_init(void) -{ - return platform_driver_register(&altera_spi_driver); -} - -device_initcall(altera_spi_driver_init); +device_platform_driver(altera_spi_driver); diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index 478f5d3b61..a0f63d84f5 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -437,11 +437,4 @@ static struct driver_d atmel_spi_driver = { .name = "atmel_spi", .probe = atmel_spi_probe, }; - -static int atmel_spi_init(void) -{ - platform_driver_register(&atmel_spi_driver); - return 0; -} - -device_initcall(atmel_spi_init); +device_platform_driver(atmel_spi_driver); diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c index 71fac3de3b..b749337daf 100644 --- a/drivers/spi/imx_spi.c +++ b/drivers/spi/imx_spi.c @@ -533,6 +533,7 @@ static int imx_spi_probe(struct device_d *dev) master = &imx->master; master->dev = dev; + master->bus_num = dev->id; master->setup = imx_spi_setup; master->transfer = imx_spi_transfer; @@ -597,12 +598,4 @@ static struct driver_d imx_spi_driver = { .probe = imx_spi_probe, .of_compatible = DRV_OF_COMPAT(imx_spi_dt_ids), }; - -static int imx_spi_init(void) -{ - platform_driver_register(&imx_spi_driver); - return 0; -} - -device_initcall(imx_spi_init); - +device_platform_driver(imx_spi_driver); diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c new file mode 100644 index 0000000000..89b4d19b59 --- /dev/null +++ b/drivers/spi/mxs_spi.c @@ -0,0 +1,289 @@ +/* + * Freescale i.MX28 SPI driver + * + * Copyright (C) 2013 Michael Grzeschik <mgr@pengutronix.de> + * + * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com> + * on behalf of DENX Software Engineering GmbH + * + * 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. + * + */ + +#include <common.h> +#include <init.h> +#include <malloc.h> +#include <spi/spi.h> +#include <clock.h> +#include <errno.h> +#include <io.h> +#include <linux/clk.h> +#include <asm/mmu.h> +#include <mach/generic.h> +#include <mach/imx-regs.h> +#include <mach/mxs.h> +#include <mach/clock.h> +#include <mach/ssp.h> + +#define MXS_SPI_MAX_TIMEOUT (10 * MSECOND) + +#define SPI_XFER_BEGIN 0x01 /* Assert CS before transfer */ +#define SPI_XFER_END 0x02 /* Deassert CS after transfer */ + +struct mxs_spi { + struct spi_master master; + uint32_t max_khz; + uint32_t mode; + struct clk *clk; + void __iomem *regs; +}; + +static inline struct mxs_spi *to_mxs(struct spi_master *master) +{ + return container_of(master, struct mxs_spi, master); +} + +/* + * Set SSP/MMC bus frequency, in kHz + */ +static void imx_set_ssp_busclock(struct spi_master *master, uint32_t freq) +{ + struct mxs_spi *mxs = to_mxs(master); + const uint32_t sspclk = imx_get_sspclk(master->bus_num); + uint32_t val; + uint32_t divide, rate, tgtclk; + + /* + * SSP bit rate = SSPCLK / (CLOCK_DIVIDE * (1 + CLOCK_RATE)), + * CLOCK_DIVIDE has to be an even value from 2 to 254, and + * CLOCK_RATE could be any integer from 0 to 255. + */ + for (divide = 2; divide < 254; divide += 2) { + rate = sspclk / freq / divide; + if (rate <= 256) + break; + } + + tgtclk = sspclk / divide / rate; + while (tgtclk > freq) { + rate++; + tgtclk = sspclk / divide / rate; + } + if (rate > 256) + rate = 256; + + /* Always set timeout the maximum */ + val = SSP_TIMING_TIMEOUT_MASK | + SSP_TIMING_CLOCK_DIVIDE(divide) | + SSP_TIMING_CLOCK_RATE(rate - 1); + writel(val, mxs->regs + HW_SSP_TIMING); + + dev_dbg(master->dev, "SPI%d: Set freq rate to %d KHz (requested %d KHz)\n", + master->bus_num, tgtclk, freq); +} + +static int mxs_spi_setup(struct spi_device *spi) +{ + struct spi_master *master = spi->master; + struct mxs_spi *mxs = to_mxs(master); + uint32_t val = 0; + + /* MXS SPI: 4 ports and 3 chip selects maximum */ + if (master->bus_num > 3 || spi->chip_select > 2) { + dev_err(master->dev, "mxs_spi: invalid bus %d / chip select %d\n", + master->bus_num, spi->chip_select); + return -EINVAL; + } + + mxs_reset_block(mxs->regs + HW_SSP_CTRL0, 0); + + val |= SSP_CTRL0_SSP_ASSERT_OUT(spi->chip_select); + val |= SSP_CTRL0_BUS_WIDTH(0); + writel(val, mxs->regs + HW_SSP_CTRL0 + BIT_SET); + + val = SSP_CTRL1_SSP_MODE(0) | SSP_CTRL1_WORD_LENGTH(7); + val |= (mxs->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0; + val |= (mxs->mode & SPI_CPHA) ? SSP_CTRL1_PHASE : 0; + writel(val, mxs->regs + HW_SSP_CTRL1); + + writel(0x0, mxs->regs + HW_SSP_CMD0); + writel(0x0, mxs->regs + HW_SSP_CMD1); + + imx_set_ssp_busclock(master, spi->max_speed_hz); + + return 0; +} + +static void mxs_spi_start_xfer(struct mxs_spi *mxs) +{ + writel(SSP_CTRL0_LOCK_CS, mxs->regs + HW_SSP_CTRL0 + BIT_SET); + writel(SSP_CTRL0_IGNORE_CRC, mxs->regs + HW_SSP_CTRL0 + BIT_CLR); +} + +static void mxs_spi_end_xfer(struct mxs_spi *mxs) +{ + writel(SSP_CTRL0_LOCK_CS, mxs->regs + HW_SSP_CTRL0 + BIT_CLR); + writel(SSP_CTRL0_IGNORE_CRC, mxs->regs + HW_SSP_CTRL0 + BIT_SET); +} + +static void mxs_spi_set_cs(struct spi_device *spi) +{ + struct mxs_spi *mxs = to_mxs(spi->master); + const uint32_t mask = SSP_CTRL0_WAIT_FOR_CMD | SSP_CTRL0_WAIT_FOR_IRQ; + uint32_t select = SSP_CTRL0_SSP_ASSERT_OUT(spi->chip_select); + + writel(mask, mxs->regs + HW_SSP_CTRL0 + BIT_CLR); + writel(select, mxs->regs + HW_SSP_CTRL0 + BIT_SET); +} + +static int mxs_spi_xfer_pio(struct spi_device *spi, + char *data, int length, int write, unsigned long flags) +{ + struct mxs_spi *mxs = to_mxs(spi->master); + struct spi_master *master = spi->master; + + if (flags & SPI_XFER_BEGIN) + mxs_spi_start_xfer(mxs); + + mxs_spi_set_cs(spi); + + while (length--) { + if ((flags & SPI_XFER_END) && !length) + mxs_spi_end_xfer(mxs); + + /* We transfer 1 byte */ + writel(1, mxs->regs + HW_SSP_XFER_COUNT); + + if (write) + writel(SSP_CTRL0_READ, mxs->regs + HW_SSP_CTRL0 + BIT_CLR); + else + writel(SSP_CTRL0_READ, mxs->regs + HW_SSP_CTRL0 + BIT_SET); + + writel(SSP_CTRL0_RUN, mxs->regs + HW_SSP_CTRL0 + BIT_SET); + + if (wait_on_timeout(MXS_SPI_MAX_TIMEOUT, + (readl(mxs->regs + HW_SSP_CTRL0) & SSP_CTRL0_RUN) == SSP_CTRL0_RUN)) { + dev_err(master->dev, "MXS SPI: Timeout waiting for start\n"); + return -ETIMEDOUT; + } + + if (write) + writel(*data++, mxs->regs + HW_SSP_DATA); + + writel(SSP_CTRL0_DATA_XFER, mxs->regs + HW_SSP_CTRL0 + BIT_SET); + + if (!write) { + if (wait_on_timeout(MXS_SPI_MAX_TIMEOUT, + !(readl(mxs->regs + HW_SSP_STATUS) & SSP_STATUS_FIFO_EMPTY))) { + dev_err(master->dev, "MXS SPI: Timeout waiting for data\n"); + return -ETIMEDOUT; + } + + *data++ = readl(mxs->regs + HW_SSP_DATA) & 0xff; + } + + if (wait_on_timeout(MXS_SPI_MAX_TIMEOUT, + !(readl(mxs->regs + HW_SSP_CTRL0) & SSP_CTRL0_RUN))) { + dev_err(master->dev, "MXS SPI: Timeout waiting for finish\n"); + return -ETIMEDOUT; + } + } + + return 0; +} + +static int mxs_spi_transfer(struct spi_device *spi, struct spi_message *mesg) +{ + struct mxs_spi *mxs = to_mxs(spi->master); + struct spi_master *master = spi->master; + struct spi_transfer *t = NULL; + char dummy; + unsigned long flags = 0; + int write = 0; + char *data = NULL; + int ret; + mesg->actual_length = 0; + + list_for_each_entry(t, &mesg->transfers, transfer_list) { + flags = 0; + + if (t->tx_buf) { + data = (char *) t->tx_buf; + write = 1; + } else if (t->rx_buf) { + data = (char *) t->rx_buf; + write = 0; + } else if (t->rx_buf && t->tx_buf) { + dev_err(master->dev, "Cannot send and receive simultaneously\n"); + return -EIO; + } else if (!t->rx_buf && !t->tx_buf) { + dev_err(master->dev, "No Data\n"); + return -EIO; + } + + if (&t->transfer_list == mesg->transfers.next) + flags |= SPI_XFER_BEGIN; + + if (&t->transfer_list == mesg->transfers.prev) + flags |= SPI_XFER_END; + + if (t->len == 0) { + if (flags == SPI_XFER_END) { + t->len = 1; + t->rx_buf = (void *) &dummy; + } else { + return 0; + } + } + + writel(SSP_CTRL1_DMA_ENABLE, mxs->regs + HW_SSP_CTRL1 + BIT_CLR); + ret = mxs_spi_xfer_pio(spi, data, t->len, write, flags); + if (ret < 0) + return ret; + mesg->actual_length += t->len; + } + + return 0; +} + +static int mxs_spi_probe(struct device_d *dev) +{ + struct spi_master *master; + struct mxs_spi *mxs; + + mxs = xzalloc(sizeof(*mxs)); + + master = &mxs->master; + master->dev = dev; + + master->bus_num = dev->id; + master->setup = mxs_spi_setup; + master->transfer = mxs_spi_transfer; + master->num_chipselect = 3; + mxs->mode = SPI_CPOL | SPI_CPHA; + + mxs->regs = dev_request_mem_region(dev, 0); + + spi_register_master(master); + + return 0; +} + +static struct driver_d mxs_spi_driver = { + .name = "mxs_spi", + .probe = mxs_spi_probe, +}; + +static int __init mxs_spi_init(void) +{ + return platform_driver_register(&mxs_spi_driver); +} + +device_initcall(mxs_spi_init); + +MODULE_AUTHOR("Denx Software Engeneering and Michael Grzeschik"); +MODULE_DESCRIPTION("MXS SPI driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c index f81b4aa9d1..e6581dfd32 100644 --- a/drivers/spi/omap3_spi.c +++ b/drivers/spi/omap3_spi.c @@ -390,10 +390,4 @@ static struct driver_d omap3_spi_driver = { .name = "omap3_spi", .probe = omap3_spi_probe, }; - -static int omap3_spi_init(void) -{ - return platform_driver_register(&omap3_spi_driver); -} - -device_initcall(omap3_spi_init); +device_platform_driver(omap3_spi_driver); diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 3899db29f2..917ec4d006 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -1537,10 +1537,4 @@ static struct driver_d at91_udc_driver = { .name = driver_name, .probe = at91udc_probe, }; - -static int at91_udc_init(void) -{ - platform_driver_register(&at91_udc_driver); - return 0; -} -device_initcall(at91_udc_init); +device_platform_driver(at91_udc_driver); diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c index 0a7c3ae269..81715f9e9a 100644 --- a/drivers/usb/gadget/fsl_udc.c +++ b/drivers/usb/gadget/fsl_udc.c @@ -2257,7 +2257,7 @@ static struct poller_struct poller = { .func = fsl_udc_poller }; -static int fsl_udc_probe(struct device_d *dev) +int ci_udc_register(struct device_d *dev, void __iomem *regs) { int ret, i; u32 dccparams; @@ -2265,7 +2265,7 @@ static int fsl_udc_probe(struct device_d *dev) udc_controller = xzalloc(sizeof(*udc_controller)); udc_controller->stopped = 1; - dr_regs = dev_request_mem_region(dev, 0); + dr_regs = regs; /* Read Device Controller Capability Parameters register */ dccparams = readl(&dr_regs->dccparams); @@ -2326,15 +2326,15 @@ err_out: return ret; } +static int fsl_udc_probe(struct device_d *dev) +{ + void __iomem *regs = dev_request_mem_region(dev, 0); + + return ci_udc_register(dev, regs); +} + static struct driver_d fsl_udc_driver = { .name = "fsl-udc", .probe = fsl_udc_probe, }; - -static int fsl_udc_init(void) -{ - platform_driver_register(&fsl_udc_driver); - return 0; -} - -device_initcall(fsl_udc_init); +device_platform_driver(fsl_udc_driver); diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 1ccc232484..b18d7c5dbd 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c @@ -1512,11 +1512,4 @@ static struct driver_d udc_driver = { .name = "pxa27x-udc", .probe = pxa_udc_probe, }; - -static int __init pxa27x_udc_init(void) -{ - platform_driver_register(&udc_driver); - return 0; -} - -device_initcall(pxa27x_udc_init); +device_platform_driver(udc_driver); diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index 5957b8e1d0..11b1a894e1 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c @@ -87,10 +87,4 @@ static struct driver_d atmel_ehci_driver = { .probe = atmel_ehci_probe, .remove = atmel_ehci_remove, }; - -static int atmel_ehci_init(void) -{ - platform_driver_register(&atmel_ehci_driver); - return 0; -} -device_initcall(atmel_ehci_init); +device_platform_driver(atmel_ehci_driver); diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index d0d6ae4cc3..0c789e479f 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -42,6 +42,10 @@ struct ehci_priv { struct qTD *td; int portreset; unsigned long flags; + + int (*init)(void *drvdata); + int (*post_init)(void *drvdata); + void *drvdata; }; #define to_ehci(ptr) container_of(ptr, struct ehci_priv, host) @@ -748,6 +752,9 @@ static int ehci_init(struct usb_host *host) if (ehci_reset(ehci) != 0) return -1; + if (ehci->init) + ehci->init(ehci->drvdata); + ehci->qh_list->qh_link = cpu_to_hc32((uint32_t)ehci->qh_list | QH_LINK_TYPE_QH); ehci->qh_list->qh_endpt1 = cpu_to_hc32((1 << 15) | (USB_SPEED_HIGH << 12)); ehci->qh_list->qh_curtd = cpu_to_hc32(QT_NEXT_TERMINATE); @@ -788,6 +795,9 @@ static int ehci_init(struct usb_host *host) ehci->rootdev = 0; + if (ehci->post_init) + ehci->post_init(ehci->drvdata); + return 0; } @@ -856,6 +866,10 @@ int ehci_register(struct device_d *dev, struct ehci_data *data) ehci->hcor = (void __iomem *)ehci->hccr + HC_LENGTH(ehci_readl(&ehci->hccr->cr_capbase)); + ehci->drvdata = data->drvdata; + ehci->init = data->init; + ehci->post_init = data->post_init; + ehci->qh_list = dma_alloc_coherent(sizeof(struct QH) * NUM_TD); ehci->td = dma_alloc_coherent(sizeof(struct qTD) * NUM_TD); @@ -909,12 +923,4 @@ static struct driver_d ehci_driver = { .probe = ehci_probe, .remove = ehci_remove, }; - -static int ehcil_init(void) -{ - platform_driver_register(&ehci_driver); - return 0; -} - -device_initcall(ehcil_init); - +device_platform_driver(ehci_driver); diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index b2598f2a5d..0f5c8f1307 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c @@ -85,10 +85,4 @@ static struct driver_d at91_ohci_driver = { .probe = at91_ohci_probe, .remove = at91_ohci_remove, }; - -static int at91_ohci_init(void) -{ - platform_driver_register(&at91_ohci_driver); - return 0; -} -device_initcall(at91_ohci_init); +device_platform_driver(at91_ohci_driver); diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index d9b5f608a8..ad39bcf6ad 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1819,12 +1819,4 @@ static struct driver_d ohci_driver = { .name = "ohci", .probe = ohci_probe, }; - -static int ohcil_init(void) -{ - platform_driver_register(&ohci_driver); - return 0; -} - -device_initcall(ohcil_init); - +device_platform_driver(ohci_driver); diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c index 5b4c0812cf..483484e117 100644 --- a/drivers/usb/imx/chipidea-imx.c +++ b/drivers/usb/imx/chipidea-imx.c @@ -19,15 +19,45 @@ #include <usb/ehci.h> #include <usb/chipidea-imx.h> #include <usb/ulpi.h> +#include <usb/fsl_usb2.h> -#define MXC_EHCI_PORTSC_MASK (0xf << 28) +#define MXC_EHCI_PORTSC_MASK ((0xf << 28) | (1 << 25)) + +static int imx_chipidea_port_init(void *drvdata) +{ + struct device_d *dev = drvdata; + struct imxusb_platformdata *pdata = dev->platform_data; + int ret; + + ret = imx_usbmisc_port_init(dev->id, pdata->flags); + if (ret) + dev_err(dev, "misc init failed: %s\n", strerror(-ret)); + + if (pdata->init) + pdata->init(dev->id); + + return ret; +} + +static int imx_chipidea_port_post_init(void *drvdata) +{ + struct device_d *dev = drvdata; + struct imxusb_platformdata *pdata = dev->platform_data; + int ret; + + ret = imx_usbmisc_port_post_init(dev->id, pdata->flags); + if (ret) + dev_err(dev, "post misc init failed: %s\n", strerror(-ret)); + + return ret; +} static int imx_chipidea_probe(struct device_d *dev) { struct imxusb_platformdata *pdata = dev->platform_data; int ret; void __iomem *base; - struct ehci_data data; + struct ehci_data data = {}; uint32_t portsc; if (!pdata) { @@ -39,17 +69,17 @@ static int imx_chipidea_probe(struct device_d *dev) if (!base) return -ENODEV; + data.init = imx_chipidea_port_init; + data.post_init = imx_chipidea_port_post_init; + data.drvdata = dev; + + imx_chipidea_port_init(dev); + portsc = readl(base + 0x184); portsc &= ~MXC_EHCI_PORTSC_MASK; portsc |= pdata->flags & MXC_EHCI_PORTSC_MASK; writel(portsc, base + 0x184); - ret = imx_usbmisc_port_init(dev->id, pdata->flags); - if (ret) { - dev_err(dev, "failed to init misc regs: %s\n", strerror(-ret)); - return ret; - } - if ((pdata->flags & MXC_EHCI_PORTSC_MASK) == MXC_EHCI_MODE_ULPI) { dev_dbg(dev, "using ULPI phy\n"); if (IS_ENABLED(CONFIG_USB_ULPI)) { @@ -67,13 +97,13 @@ static int imx_chipidea_probe(struct device_d *dev) data.hcor = base + 0x140; data.flags = EHCI_HAS_TT; - if (pdata->mode == IMX_USB_MODE_HOST) { + if (pdata->mode == IMX_USB_MODE_HOST && IS_ENABLED(CONFIG_USB_EHCI)) { ret = ehci_register(dev, &data); + } else if (pdata->mode == IMX_USB_MODE_DEVICE && IS_ENABLED(CONFIG_USB_GADGET_DRIVER_ARC)) { + ret = ci_udc_register(dev, base); } else { - /* - * Not yet implemented. Register USB gadget driver here. - */ - ret = -ENOSYS; + dev_err(dev, "No supported role\n"); + ret = -ENODEV; } return ret; @@ -83,9 +113,4 @@ static struct driver_d imx_chipidea_driver = { .name = "imx-usb", .probe = imx_chipidea_probe, }; - -static int imx_chipidea_init(void) -{ - return platform_driver_register(&imx_chipidea_driver); -} -device_initcall(imx_chipidea_init); +device_platform_driver(imx_chipidea_driver); diff --git a/drivers/usb/imx/imx-usb-misc.c b/drivers/usb/imx/imx-usb-misc.c index 4cdf5ab3af..901ced485d 100644 --- a/drivers/usb/imx/imx-usb-misc.c +++ b/drivers/usb/imx/imx-usb-misc.c @@ -17,6 +17,8 @@ #include <init.h> #include <io.h> #include <usb/chipidea-imx.h> +#include <mach/imx6-regs.h> +#include <mach/iomux-mx6.h> #define MX25_OTG_SIC_SHIFT 29 #define MX25_OTG_SIC_MASK (0x3 << MX25_OTG_SIC_SHIFT) @@ -34,6 +36,11 @@ #define MX25_H1_USBTE_BIT (1 << 4) #define MX25_H1_OCPOL_BIT (1 << 2) +struct imx_usb_misc_data { + int (*init)(void __iomem *base, int port, unsigned int flags); + int (*post_init)(void __iomem *base, int port, unsigned int flags); +}; + static __maybe_unused int mx25_initialize_usb_hw(void __iomem *base, int port, unsigned int flags) { unsigned int v; @@ -93,6 +100,10 @@ static __maybe_unused int mx25_initialize_usb_hw(void __iomem *base, int port, u return 0; } +static __maybe_unused struct imx_usb_misc_data mx25_data = { + .init = mx25_initialize_usb_hw, +}; + #define MX27_OTG_SIC_SHIFT 29 #define MX27_OTG_SIC_MASK (0x3 << MX27_OTG_SIC_SHIFT) #define MX27_OTG_PM_BIT (1 << 24) @@ -152,6 +163,10 @@ static __maybe_unused int mx27_mx31_initialize_usb_hw(void __iomem *base, int po return 0; } +static __maybe_unused struct imx_usb_misc_data mx27_mx31_data = { + .init = mx27_mx31_initialize_usb_hw, +}; + #define USBCTRL_OTGBASE_OFFSET 0x600 #define MX35_OTG_SIC_SHIFT 29 @@ -229,6 +244,10 @@ static __maybe_unused int mx35_initialize_usb_hw(void __iomem *base, int port, u return 0; } +static __maybe_unused struct imx_usb_misc_data mx35_data = { + .init = mx35_initialize_usb_hw, +}; + /* USB_CTRL */ #define MX5_OTG_UCTRL_OWIE_BIT (1 << 27) /* OTG wakeup intr enable */ #define MX5_OTG_UCTRL_OPM_BIT (1 << 24) /* OTG power mask */ @@ -324,53 +343,119 @@ static __maybe_unused int mx5_initialize_usb_hw(void __iomem *base, int port, return 0; } +static __maybe_unused struct imx_usb_misc_data mx5_data = { + .init = mx5_initialize_usb_hw, +}; + +static void mx6_hsic_pullup(unsigned long reg, int on) +{ + u32 val; + + val = readl(MX6_IOMUXC_BASE_ADDR + reg); + + if (on) + val |= MX6_PAD_CTL_PUS_47K_UP; + else + val &= ~MX6_PAD_CTL_PUS_47K_UP; + + writel(val, MX6_IOMUXC_BASE_ADDR + reg); +} + static __maybe_unused int mx6_initialize_usb_hw(void __iomem *base, int port, unsigned int flags) { + switch (port) { + case 0: + break; + case 1: + break; + case 2: /* HSIC port */ + mx6_hsic_pullup(0x388, 0); + + writel(0x00003000, base + 0x8); + writel(0x80001842, base + 0x10); + + break; + case 3: /* HSIC port */ + writel(0x00003000, base + 0xc); + writel(0x80001842, base + 0x14); + + mx6_hsic_pullup(0x398, 0); + break; + default: + return -EINVAL; + } + return 0; } +static __maybe_unused int mx6_post_init(void __iomem *base, int port, + unsigned int flags) +{ + switch (port) { + case 0: + break; + case 1: + break; + case 2: /* HSIC port */ + mx6_hsic_pullup(0x388, 1); + break; + case 3: /* HSIC port */ + mx6_hsic_pullup(0x398, 1); + break; + default: + return -EINVAL; + } + + return 0; +} + +static __maybe_unused struct imx_usb_misc_data mx6_data = { + .init = mx6_initialize_usb_hw, + .post_init = mx6_post_init, +}; + static struct platform_device_id imx_usbmisc_ids[] = { #ifdef CONFIG_ARCH_IMX25 { .name = "imx25-usb-misc", - .driver_data = (unsigned long)&mx25_initialize_usb_hw, + .driver_data = (unsigned long)&mx25_data, }, #endif #ifdef CONFIG_ARCH_IMX27 { .name = "imx27-usb-misc", - .driver_data = (unsigned long)&mx27_mx31_initialize_usb_hw, + .driver_data = (unsigned long)&mx27_mx31_data, }, #endif #ifdef CONFIG_ARCH_IMX31 { .name = "imx31-usb-misc", - .driver_data = (unsigned long)&mx27_mx31_initialize_usb_hw, + .driver_data = (unsigned long)&mx27_mx31_data, }, #endif #ifdef CONFIG_ARCH_IMX35 { .name = "imx35-usb-misc", - .driver_data = (unsigned long)&mx35_initialize_usb_hw, + .driver_data = (unsigned long)&mx35_data, }, #endif #ifdef CONFIG_ARCH_IMX51 { .name = "imx51-usb-misc", - .driver_data = (unsigned long)&mx5_initialize_usb_hw, + .driver_data = (unsigned long)&mx5_data, }, #endif #ifdef CONFIG_ARCH_IMX53 { .name = "imx53-usb-misc", - .driver_data = (unsigned long)&mx5_initialize_usb_hw, + .driver_data = (unsigned long)&mx5_data, }, #endif #ifdef CONFIG_ARCH_IMX6 { .name = "imx6-usb-misc", - .driver_data = (unsigned long)&mx6_initialize_usb_hw, + .driver_data = (unsigned long)&mx6_data, }, #endif { @@ -378,20 +463,34 @@ static struct platform_device_id imx_usbmisc_ids[] = { }, }; -static int (*__imx_usbmisc_port_init)(void __iomem *base, int port, unsigned flags); +static struct imx_usb_misc_data *imxusbmisc_data; static void __iomem *usbmisc_base; int imx_usbmisc_port_init(int port, unsigned flags) { - if (!__imx_usbmisc_port_init) + if (!imxusbmisc_data) + return -ENODEV; + + if (!imxusbmisc_data->init) + return 0; + + return imxusbmisc_data->init(usbmisc_base, port, flags); +} + +int imx_usbmisc_port_post_init(int port, unsigned flags) +{ + if (!imxusbmisc_data) return -ENODEV; - return __imx_usbmisc_port_init(usbmisc_base, port, flags); + if (!imxusbmisc_data->post_init) + return 0; + + return imxusbmisc_data->post_init(usbmisc_base, port, flags); } static int imx_usbmisc_probe(struct device_d *dev) { - struct imx_serial_devtype_data *devtype; + struct imx_usb_misc_data *devtype; int ret; ret = dev_get_drvdata(dev, (unsigned long *)&devtype); @@ -402,7 +501,7 @@ static int imx_usbmisc_probe(struct device_d *dev) if (!usbmisc_base) return -ENOMEM; - __imx_usbmisc_port_init = (void *)devtype; + imxusbmisc_data = devtype; return 0; } diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index 892c21ebee..2c9fb46e4d 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig @@ -4,5 +4,5 @@ config USB_ULPI Support for transceivers that conforms ULPI specification. config USB_TWL4030 - depends on I2C_TWL4030 + depends on MFD_TWL4030 bool "TWL4030 Transceiver support" diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c index 78a737d0b9..29565981c9 100644 --- a/drivers/video/atmel_hlcdfb.c +++ b/drivers/video/atmel_hlcdfb.c @@ -289,9 +289,4 @@ static struct driver_d atmel_hlcdc_driver = { .name = "atmel_hlcdfb", .probe = atmel_hlcdc_probe, }; - -static int atmel_hlcdc_init(void) -{ - return platform_driver_register(&atmel_hlcdc_driver); -} -device_initcall(atmel_hlcdc_init); +device_platform_driver(atmel_hlcdc_driver); diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 08888cc9ba..e9164e32db 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -255,9 +255,4 @@ static struct driver_d atmel_lcdc_driver = { .name = "atmel_lcdfb", .probe = atmel_lcdc_probe, }; - -static int atmel_lcdc_init(void) -{ - return platform_driver_register(&atmel_lcdc_driver); -} -device_initcall(atmel_lcdc_init); +device_platform_driver(atmel_lcdc_driver); diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c index a29920d7dd..db8b8323b0 100644 --- a/drivers/video/imx-ipu-fb.c +++ b/drivers/video/imx-ipu-fb.c @@ -1039,13 +1039,7 @@ static struct driver_d imx3fb_driver = { .probe = imxfb_probe, .remove = imxfb_remove, }; - -static int imx3fb_init(void) -{ - return platform_driver_register(&imx3fb_driver); -} - -device_initcall(imx3fb_init); +device_platform_driver(imx3fb_driver); /** * @file diff --git a/drivers/video/imx.c b/drivers/video/imx.c index a1ccf0aec8..736e8d08e2 100644 --- a/drivers/video/imx.c +++ b/drivers/video/imx.c @@ -597,11 +597,4 @@ static struct driver_d imxfb_driver = { .probe = imxfb_probe, .remove = imxfb_remove, }; - -static int imxfb_init(void) -{ - return platform_driver_register(&imxfb_driver); -} - -device_initcall(imxfb_init); - +device_platform_driver(imxfb_driver); diff --git a/drivers/video/pxa.c b/drivers/video/pxa.c index cec9d147d2..529190baec 100644 --- a/drivers/video/pxa.c +++ b/drivers/video/pxa.c @@ -545,10 +545,4 @@ static struct driver_d pxafb_driver = { .probe = pxafb_probe, .remove = pxafb_remove, }; - -static int pxafb_init(void) -{ - return platform_driver_register(&pxafb_driver); -} - -device_initcall(pxafb_init); +device_platform_driver(pxafb_driver); diff --git a/drivers/video/s3c24xx.c b/drivers/video/s3c24xx.c index 6dd49e249b..d641cfaa27 100644 --- a/drivers/video/s3c24xx.c +++ b/drivers/video/s3c24xx.c @@ -406,13 +406,7 @@ static struct driver_d s3cfb_driver = { .info = s3cfb_info, #endif }; - -static int s3cfb_init(void) -{ - return platform_driver_register(&s3cfb_driver); -} - -device_initcall(s3cfb_init); +device_platform_driver(s3cfb_driver); /** * The S3C244x LCD controller supports passive (CSTN/STN) and active (TFT) LC displays diff --git a/drivers/video/sdl.c b/drivers/video/sdl.c index 0021a06866..8dec5e5778 100644 --- a/drivers/video/sdl.c +++ b/drivers/video/sdl.c @@ -93,9 +93,4 @@ static struct driver_d sdlfb_driver = { .probe = sdlfb_probe, .remove = sdlfb_remove, }; - -static int sdlfb_init(void) -{ - return platform_driver_register(&sdlfb_driver); -} -device_initcall(sdlfb_init); +device_platform_driver(sdlfb_driver); diff --git a/drivers/video/stm.c b/drivers/video/stm.c index 28c7b6eb55..cefdef2ab5 100644 --- a/drivers/video/stm.c +++ b/drivers/video/stm.c @@ -516,13 +516,7 @@ static struct driver_d stmfb_driver = { .probe = stmfb_probe, .info = stmfb_info, }; - -static int stmfb_init(void) -{ - return platform_driver_register(&stmfb_driver); -} - -device_initcall(stmfb_init); +device_platform_driver(stmfb_driver); /** * @file diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c index 0a3794d144..946e9d3340 100644 --- a/drivers/w1/masters/w1-gpio.c +++ b/drivers/w1/masters/w1-gpio.c @@ -108,9 +108,4 @@ static struct driver_d w1_gpio_driver = { .name = "w1-gpio", .probe = w1_gpio_probe, }; - -static int __init w1_gpio_init(void) -{ - return platform_driver_register(&w1_gpio_driver); -} -device_initcall(w1_gpio_init); +device_platform_driver(w1_gpio_driver); diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c index bc19369782..96cfe9a4f4 100644 --- a/drivers/watchdog/im28wd.c +++ b/drivers/watchdog/im28wd.c @@ -150,11 +150,4 @@ static struct driver_d imx28_wd_driver = { .probe = imx28_wd_probe, .remove = imx28_wd_remove, }; - -static int imx28_wd_init(void) -{ - platform_driver_register(&imx28_wd_driver); - return 0; -} - -device_initcall(imx28_wd_init); +device_platform_driver(imx28_wd_driver); diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c index c422f9819c..78f0f38290 100644 --- a/drivers/watchdog/imxwd.c +++ b/drivers/watchdog/imxwd.c @@ -226,10 +226,4 @@ static struct driver_d imx_wd_driver = { .of_compatible = DRV_OF_COMPAT(imx_wdt_dt_ids), .id_table = imx_wdt_ids, }; - -static int imx_wd_init(void) -{ - return platform_driver_register(&imx_wd_driver); -} - -device_initcall(imx_wd_init); +device_platform_driver(imx_wd_driver); @@ -754,17 +754,12 @@ int ioctl(int fd, int request, void *buf) return ret; } -int read(int fd, void *buf, size_t count) +static ssize_t __read(FILE *f, void *buf, size_t count) { struct device_d *dev; struct fs_driver_d *fsdrv; - FILE *f; int ret; - if (check_fd(fd)) - return -errno; - - f = &files[fd]; dev = f->dev; fsdrv = dev_to_fs_driver(dev); @@ -777,18 +772,14 @@ int read(int fd, void *buf, size_t count) ret = fsdrv->read(dev, f, buf, count); - if (ret > 0) - f->pos += ret; if (ret < 0) errno = -ret; return ret; } -EXPORT_SYMBOL(read); -ssize_t write(int fd, const void *buf, size_t count) +ssize_t pread(int fd, void *buf, size_t count, loff_t offset) { - struct device_d *dev; - struct fs_driver_d *fsdrv; + loff_t pos; FILE *f; int ret; @@ -796,6 +787,40 @@ ssize_t write(int fd, const void *buf, size_t count) return -errno; f = &files[fd]; + + pos = f->pos; + f->pos = offset; + ret = __read(f, buf, count); + f->pos = pos; + + return ret; +} +EXPORT_SYMBOL(pread); + +ssize_t read(int fd, void *buf, size_t count) +{ + FILE *f; + int ret; + + if (check_fd(fd)) + return -errno; + + f = &files[fd]; + + ret = __read(f, buf, count); + + if (ret > 0) + f->pos += ret; + return ret; +} +EXPORT_SYMBOL(read); + +static ssize_t __write(FILE *f, const void *buf, size_t count) +{ + struct device_d *dev; + struct fs_driver_d *fsdrv; + int ret; + dev = f->dev; fsdrv = dev_to_fs_driver(dev); @@ -812,13 +837,48 @@ ssize_t write(int fd, const void *buf, size_t count) } } ret = fsdrv->write(dev, f, buf, count); - if (ret > 0) - f->pos += ret; out: if (ret < 0) errno = -ret; return ret; } + +ssize_t pwrite(int fd, const void *buf, size_t count, loff_t offset) +{ + loff_t pos; + FILE *f; + int ret; + + if (check_fd(fd)) + return -errno; + + f = &files[fd]; + + pos = f->pos; + f->pos = offset; + ret = __write(f, buf, count); + f->pos = pos; + + return ret; +} +EXPORT_SYMBOL(pwrite); + +ssize_t write(int fd, const void *buf, size_t count) +{ + FILE *f; + int ret; + + if (check_fd(fd)) + return -errno; + + f = &files[fd]; + + ret = __write(f, buf, count); + + if (ret > 0) + f->pos += ret; + return ret; +} EXPORT_SYMBOL(write); int flush(int fd) diff --git a/include/driver.h b/include/driver.h index 31f5d69848..46c56c0acf 100644 --- a/include/driver.h +++ b/include/driver.h @@ -193,6 +193,10 @@ static inline const char *dev_name(const struct device_d *dev) } /* + * get resource 'num' for a device + */ +struct resource *dev_get_resource(struct device_d *dev, int num); +/* * get resource base 'name' for a device */ struct resource *dev_get_resource_by_name(struct device_d *dev, @@ -390,6 +394,18 @@ extern struct list_head bus_list; extern struct bus_type platform_bus; int platform_driver_register(struct driver_d *drv); + +/* device_platform_driver() - Helper macro for drivers that don't do + * anything special in module registration. This eliminates a lot of + * boilerplate. Each module may only use this macro once. + */ +#define device_platform_driver(drv) \ + static int __init drv ## _register(void) \ + { \ + return platform_driver_register(&drv); \ + } \ + device_initcall(drv ## _register) + int platform_device_register(struct device_d *new_device); struct file_operations { diff --git a/include/envfs.h b/include/envfs.h index 2db55ed6a4..e9372b3867 100644 --- a/include/envfs.h +++ b/include/envfs.h @@ -96,4 +96,6 @@ int envfs_save(char *filename, char *dirname); /* defaults to /dev/env0 */ extern char *default_environment_path; +int envfs_register_partition(const char *devname, unsigned int partnr); + #endif /* _ENVFS_H */ diff --git a/include/filetype.h b/include/filetype.h index 4d43757b8c..78ca5d2043 100644 --- a/include/filetype.h +++ b/include/filetype.h @@ -23,6 +23,7 @@ enum filetype { filetype_bmp, filetype_png, filetype_ext, + filetype_gpt, filetype_max, }; diff --git a/include/fs.h b/include/fs.h index 919daab673..7c4e46175a 100644 --- a/include/fs.h +++ b/include/fs.h @@ -113,9 +113,11 @@ int close(int fd); int flush(int fd); int lstat(const char *filename, struct stat *s); int stat(const char *filename, struct stat *s); -int read(int fd, void *buf, size_t count); +ssize_t read(int fd, void *buf, size_t count); +ssize_t pread(int fd, void *buf, size_t count, loff_t offset); int ioctl(int fd, int request, void *buf); ssize_t write(int fd, const void *buf, size_t count); +ssize_t pwrite(int fd, const void *buf, size_t count, loff_t offset); #define SEEK_SET 1 #define SEEK_CUR 2 diff --git a/include/getopt.h b/include/getopt.h index f23175fb87..4f48ba8fd9 100644 --- a/include/getopt.h +++ b/include/getopt.h @@ -35,7 +35,7 @@ extern char *optarg; * - options can be mixed with nonoptions (like ls /bin -R) */ -int getopt(int argc, char *argv[], char *optstring); +int getopt(int argc, char *argv[], const char *optstring); struct getopt_context { int opterr; diff --git a/include/linux/efi.h b/include/linux/efi.h new file mode 100644 index 0000000000..570eff75de --- /dev/null +++ b/include/linux/efi.h @@ -0,0 +1,547 @@ +#ifndef _LINUX_EFI_H +#define _LINUX_EFI_H + +/* + * Extensible Firmware Interface + * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999 + * + * Copyright (C) 1999 VA Linux Systems + * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> + * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co. + * David Mosberger-Tang <davidm@hpl.hp.com> + * Stephane Eranian <eranian@hpl.hp.com> + */ +#include <linux/string.h> +#include <linux/types.h> + +#define EFI_SUCCESS 0 +#define EFI_LOAD_ERROR ( 1 | (1UL << (BITS_PER_LONG-1))) +#define EFI_INVALID_PARAMETER ( 2 | (1UL << (BITS_PER_LONG-1))) +#define EFI_UNSUPPORTED ( 3 | (1UL << (BITS_PER_LONG-1))) +#define EFI_BAD_BUFFER_SIZE ( 4 | (1UL << (BITS_PER_LONG-1))) +#define EFI_BUFFER_TOO_SMALL ( 5 | (1UL << (BITS_PER_LONG-1))) +#define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG-1))) + +typedef unsigned long efi_status_t; +typedef u8 efi_bool_t; +typedef u16 efi_char16_t; /* UNICODE character */ + + +typedef struct { + u8 b[16]; +} efi_guid_t; + +#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ +((efi_guid_t) \ +{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ + (b) & 0xff, ((b) >> 8) & 0xff, \ + (c) & 0xff, ((c) >> 8) & 0xff, \ + (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) + +/* + * Generic EFI table header + */ +typedef struct { + u64 signature; + u32 revision; + u32 headersize; + u32 crc32; + u32 reserved; +} efi_table_hdr_t; + +/* + * Memory map descriptor: + */ + +/* Memory types: */ +#define EFI_RESERVED_TYPE 0 +#define EFI_LOADER_CODE 1 +#define EFI_LOADER_DATA 2 +#define EFI_BOOT_SERVICES_CODE 3 +#define EFI_BOOT_SERVICES_DATA 4 +#define EFI_RUNTIME_SERVICES_CODE 5 +#define EFI_RUNTIME_SERVICES_DATA 6 +#define EFI_CONVENTIONAL_MEMORY 7 +#define EFI_UNUSABLE_MEMORY 8 +#define EFI_ACPI_RECLAIM_MEMORY 9 +#define EFI_ACPI_MEMORY_NVS 10 +#define EFI_MEMORY_MAPPED_IO 11 +#define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12 +#define EFI_PAL_CODE 13 +#define EFI_MAX_MEMORY_TYPE 14 + +/* Attribute values: */ +#define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */ +#define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */ +#define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */ +#define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */ +#define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */ +#define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */ +#define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */ +#define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */ +#define EFI_MEMORY_DESCRIPTOR_VERSION 1 + +#define EFI_PAGE_SHIFT 12 + +typedef struct { + u32 type; + u32 pad; + u64 phys_addr; + u64 virt_addr; + u64 num_pages; + u64 attribute; +} efi_memory_desc_t; + +typedef struct { + efi_guid_t guid; + u32 headersize; + u32 flags; + u32 imagesize; +} efi_capsule_header_t; + +/* + * Allocation types for calls to boottime->allocate_pages. + */ +#define EFI_ALLOCATE_ANY_PAGES 0 +#define EFI_ALLOCATE_MAX_ADDRESS 1 +#define EFI_ALLOCATE_ADDRESS 2 +#define EFI_MAX_ALLOCATE_TYPE 3 + +typedef int (*efi_freemem_callback_t) (u64 start, u64 end, void *arg); + +/* + * Types and defines for Time Services + */ +#define EFI_TIME_ADJUST_DAYLIGHT 0x1 +#define EFI_TIME_IN_DAYLIGHT 0x2 +#define EFI_UNSPECIFIED_TIMEZONE 0x07ff + +typedef struct { + u16 year; + u8 month; + u8 day; + u8 hour; + u8 minute; + u8 second; + u8 pad1; + u32 nanosecond; + s16 timezone; + u8 daylight; + u8 pad2; +} efi_time_t; + +typedef struct { + u32 resolution; + u32 accuracy; + u8 sets_to_zero; +} efi_time_cap_t; + +/* + * EFI Boot Services table + */ +typedef struct { + efi_table_hdr_t hdr; + void *raise_tpl; + void *restore_tpl; + void *allocate_pages; + void *free_pages; + void *get_memory_map; + void *allocate_pool; + void *free_pool; + void *create_event; + void *set_timer; + void *wait_for_event; + void *signal_event; + void *close_event; + void *check_event; + void *install_protocol_interface; + void *reinstall_protocol_interface; + void *uninstall_protocol_interface; + void *handle_protocol; + void *__reserved; + void *register_protocol_notify; + void *locate_handle; + void *locate_device_path; + void *install_configuration_table; + void *load_image; + void *start_image; + void *exit; + void *unload_image; + void *exit_boot_services; + void *get_next_monotonic_count; + void *stall; + void *set_watchdog_timer; + void *connect_controller; + void *disconnect_controller; + void *open_protocol; + void *close_protocol; + void *open_protocol_information; + void *protocols_per_handle; + void *locate_handle_buffer; + void *locate_protocol; + void *install_multiple_protocol_interfaces; + void *uninstall_multiple_protocol_interfaces; + void *calculate_crc32; + void *copy_mem; + void *set_mem; + void *create_event_ex; +} efi_boot_services_t; + +/* + * Types and defines for EFI ResetSystem + */ +#define EFI_RESET_COLD 0 +#define EFI_RESET_WARM 1 +#define EFI_RESET_SHUTDOWN 2 + +/* + * EFI Runtime Services table + */ +#define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL) +#define EFI_RUNTIME_SERVICES_REVISION 0x00010000 + +typedef struct { + efi_table_hdr_t hdr; + unsigned long get_time; + unsigned long set_time; + unsigned long get_wakeup_time; + unsigned long set_wakeup_time; + unsigned long set_virtual_address_map; + unsigned long convert_pointer; + unsigned long get_variable; + unsigned long get_next_variable; + unsigned long set_variable; + unsigned long get_next_high_mono_count; + unsigned long reset_system; + unsigned long update_capsule; + unsigned long query_capsule_caps; + unsigned long query_variable_info; +} efi_runtime_services_t; + +typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc); +typedef efi_status_t efi_set_time_t (efi_time_t *tm); +typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending, + efi_time_t *tm); +typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm); +typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr, + unsigned long *data_size, void *data); +typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name, + efi_guid_t *vendor); +typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor, + u32 attr, unsigned long data_size, + void *data); +typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count); +typedef void efi_reset_system_t (int reset_type, efi_status_t status, + unsigned long data_size, efi_char16_t *data); +typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size, + unsigned long descriptor_size, + u32 descriptor_version, + efi_memory_desc_t *virtual_map); +typedef efi_status_t efi_query_variable_info_t(u32 attr, + u64 *storage_space, + u64 *remaining_space, + u64 *max_variable_size); +typedef efi_status_t efi_update_capsule_t(efi_capsule_header_t **capsules, + unsigned long count, + unsigned long sg_list); +typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules, + unsigned long count, + u64 *max_size, + int *reset_type); + +/* + * EFI Configuration Table and GUID definitions + */ +#define NULL_GUID \ + EFI_GUID( 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ) + +#define MPS_TABLE_GUID \ + EFI_GUID( 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) + +#define ACPI_TABLE_GUID \ + EFI_GUID( 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) + +#define ACPI_20_TABLE_GUID \ + EFI_GUID( 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 ) + +#define SMBIOS_TABLE_GUID \ + EFI_GUID( 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) + +#define SAL_SYSTEM_TABLE_GUID \ + EFI_GUID( 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) + +#define HCDP_TABLE_GUID \ + EFI_GUID( 0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 ) + +#define UGA_IO_PROTOCOL_GUID \ + EFI_GUID( 0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 ) + +#define EFI_GLOBAL_VARIABLE_GUID \ + EFI_GUID( 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c ) + +#define UV_SYSTEM_TABLE_GUID \ + EFI_GUID( 0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93 ) + +#define LINUX_EFI_CRASH_GUID \ + EFI_GUID( 0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0 ) + +#define LOADED_IMAGE_PROTOCOL_GUID \ + EFI_GUID( 0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b ) + +#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ + EFI_GUID( 0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a ) + +#define EFI_UGA_PROTOCOL_GUID \ + EFI_GUID( 0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 ) + +#define EFI_PCI_IO_PROTOCOL_GUID \ + EFI_GUID( 0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a ) + +#define EFI_FILE_INFO_ID \ + EFI_GUID( 0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b ) + +#define EFI_FILE_SYSTEM_GUID \ + EFI_GUID( 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b ) + +typedef struct { + efi_guid_t guid; + u64 table; +} efi_config_table_64_t; + +typedef struct { + efi_guid_t guid; + u32 table; +} efi_config_table_32_t; + +typedef struct { + efi_guid_t guid; + unsigned long table; +} efi_config_table_t; + +#define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) + +#define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30)) +#define EFI_2_20_SYSTEM_TABLE_REVISION ((2 << 16) | (20)) +#define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | (10)) +#define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | (00)) +#define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | (10)) +#define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | (02)) + +typedef struct { + efi_table_hdr_t hdr; + u64 fw_vendor; /* physical addr of CHAR16 vendor string */ + u32 fw_revision; + u32 __pad1; + u64 con_in_handle; + u64 con_in; + u64 con_out_handle; + u64 con_out; + u64 stderr_handle; + u64 _stderr; + u64 runtime; + u64 boottime; + u32 nr_tables; + u32 __pad2; + u64 tables; +} efi_system_table_64_t; + +typedef struct { + efi_table_hdr_t hdr; + u32 fw_vendor; /* physical addr of CHAR16 vendor string */ + u32 fw_revision; + u32 con_in_handle; + u32 con_in; + u32 con_out_handle; + u32 con_out; + u32 stderr_handle; + u32 _stderr; + u32 runtime; + u32 boottime; + u32 nr_tables; + u32 tables; +} efi_system_table_32_t; + +typedef struct { + efi_table_hdr_t hdr; + unsigned long fw_vendor; /* physical addr of CHAR16 vendor string */ + u32 fw_revision; + unsigned long con_in_handle; + unsigned long con_in; + unsigned long con_out_handle; + unsigned long con_out; + unsigned long stderr_handle; + unsigned long _stderr; + efi_runtime_services_t *runtime; + efi_boot_services_t *boottime; + unsigned long nr_tables; + unsigned long tables; +} efi_system_table_t; + +struct efi_memory_map { + void *phys_map; + void *map; + void *map_end; + int nr_map; + unsigned long desc_version; + unsigned long desc_size; +}; + +typedef struct { + u32 revision; + void *parent_handle; + efi_system_table_t *system_table; + void *device_handle; + void *file_path; + void *reserved; + u32 load_options_size; + void *load_options; + void *image_base; + __aligned_u64 image_size; + unsigned int image_code_type; + unsigned int image_data_type; + unsigned long unload; +} efi_loaded_image_t; + +typedef struct { + u64 revision; + void *open_volume; +} efi_file_io_interface_t; + +typedef struct { + u64 size; + u64 file_size; + u64 phys_size; + efi_time_t create_time; + efi_time_t last_access_time; + efi_time_t modification_time; + __aligned_u64 attribute; + efi_char16_t filename[1]; +} efi_file_info_t; + +typedef struct { + u64 revision; + void *open; + void *close; + void *delete; + void *read; + void *write; + void *get_position; + void *set_position; + void *get_info; + void *set_info; + void *flush; +} efi_file_handle_t; + +#define EFI_FILE_MODE_READ 0x0000000000000001 +#define EFI_FILE_MODE_WRITE 0x0000000000000002 +#define EFI_FILE_MODE_CREATE 0x8000000000000000 + +#define EFI_INVALID_TABLE_ADDR (~0UL) + +/* + * All runtime access to EFI goes through this structure: + */ +extern struct efi { + efi_system_table_t *systab; /* EFI system table */ + unsigned int runtime_version; /* Runtime services version */ + unsigned long mps; /* MPS table */ + unsigned long acpi; /* ACPI table (IA64 ext 0.71) */ + unsigned long acpi20; /* ACPI table (ACPI 2.0) */ + unsigned long smbios; /* SM BIOS table */ + unsigned long sal_systab; /* SAL system table */ + unsigned long boot_info; /* boot info table */ + unsigned long hcdp; /* HCDP table */ + unsigned long uga; /* UGA table */ + unsigned long uv_systab; /* UV system table */ + efi_get_time_t *get_time; + efi_set_time_t *set_time; + efi_get_wakeup_time_t *get_wakeup_time; + efi_set_wakeup_time_t *set_wakeup_time; + efi_get_variable_t *get_variable; + efi_get_next_variable_t *get_next_variable; + efi_set_variable_t *set_variable; + efi_query_variable_info_t *query_variable_info; + efi_update_capsule_t *update_capsule; + efi_query_capsule_caps_t *query_capsule_caps; + efi_get_next_high_mono_count_t *get_next_high_mono_count; + efi_reset_system_t *reset_system; + efi_set_virtual_address_map_t *set_virtual_address_map; +} efi; + +static inline int +efi_guidcmp (efi_guid_t left, efi_guid_t right) +{ + return memcmp(&left, &right, sizeof (efi_guid_t)); +} + +static inline char * +efi_guid_unparse(efi_guid_t *guid, char *out) +{ + sprintf(out, "%pUl", guid->b); + return out; +} + +/* + * Variable Attributes + */ +#define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001 +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002 +#define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004 +#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008 +#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010 +#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020 +#define EFI_VARIABLE_APPEND_WRITE 0x0000000000000040 + +#define EFI_VARIABLE_MASK (EFI_VARIABLE_NON_VOLATILE | \ + EFI_VARIABLE_BOOTSERVICE_ACCESS | \ + EFI_VARIABLE_RUNTIME_ACCESS | \ + EFI_VARIABLE_HARDWARE_ERROR_RECORD | \ + EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \ + EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \ + EFI_VARIABLE_APPEND_WRITE) +/* + * The type of search to perform when calling boottime->locate_handle + */ +#define EFI_LOCATE_ALL_HANDLES 0 +#define EFI_LOCATE_BY_REGISTER_NOTIFY 1 +#define EFI_LOCATE_BY_PROTOCOL 2 + +/* + * EFI Device Path information + */ +#define EFI_DEV_HW 0x01 +#define EFI_DEV_PCI 1 +#define EFI_DEV_PCCARD 2 +#define EFI_DEV_MEM_MAPPED 3 +#define EFI_DEV_VENDOR 4 +#define EFI_DEV_CONTROLLER 5 +#define EFI_DEV_ACPI 0x02 +#define EFI_DEV_BASIC_ACPI 1 +#define EFI_DEV_EXPANDED_ACPI 2 +#define EFI_DEV_MSG 0x03 +#define EFI_DEV_MSG_ATAPI 1 +#define EFI_DEV_MSG_SCSI 2 +#define EFI_DEV_MSG_FC 3 +#define EFI_DEV_MSG_1394 4 +#define EFI_DEV_MSG_USB 5 +#define EFI_DEV_MSG_USB_CLASS 15 +#define EFI_DEV_MSG_I20 6 +#define EFI_DEV_MSG_MAC 11 +#define EFI_DEV_MSG_IPV4 12 +#define EFI_DEV_MSG_IPV6 13 +#define EFI_DEV_MSG_INFINIBAND 9 +#define EFI_DEV_MSG_UART 14 +#define EFI_DEV_MSG_VENDOR 10 +#define EFI_DEV_MEDIA 0x04 +#define EFI_DEV_MEDIA_HARD_DRIVE 1 +#define EFI_DEV_MEDIA_CDROM 2 +#define EFI_DEV_MEDIA_VENDOR 3 +#define EFI_DEV_MEDIA_FILE 4 +#define EFI_DEV_MEDIA_PROTOCOL 5 +#define EFI_DEV_BIOS_BOOT 0x05 +#define EFI_DEV_END_PATH 0x7F +#define EFI_DEV_END_PATH2 0xFF +#define EFI_DEV_END_INSTANCE 0x01 +#define EFI_DEV_END_ENTIRE 0xFF + +#endif /* _LINUX_EFI_H */ diff --git a/include/linux/log2.h b/include/linux/log2.h index 389043a93c..d9913f06bd 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h @@ -54,6 +54,15 @@ bool is_power_of_2(unsigned long n) return (n != 0 && ((n & (n - 1)) == 0)); } +/* + * round up to nearest power of two + */ +static inline __attribute__((const)) +unsigned long __roundup_pow_of_two(unsigned long n) +{ + return 1UL << fls(n - 1); +} + /** * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value * @n - parameter diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index cb8b3bcaef..e5568377be 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -207,6 +207,12 @@ struct mtd_info { char *size_str; }; +int mtd_erase(struct mtd_info *mtd, struct erase_info *instr); +int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, + u_char *buf); +int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, + const u_char *buf); + static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) { do_div(sz, mtd->erasesize); @@ -251,7 +257,12 @@ static inline void mtd_erase_callback(struct erase_info *instr) } #endif +int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); +int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs); +int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs); + +int mtd_all_ff(const void *buf, unsigned int len); /* * Debugging macro and defines diff --git a/include/linux/phy.h b/include/linux/phy.h index 6c9cac973e..99c96390c7 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -158,6 +158,7 @@ struct phy_device { u32 advertising; int autoneg; + int force; /* private data pointer */ diff --git a/include/linux/types.h b/include/linux/types.h index 76c6b670a2..14f8315410 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -142,6 +142,19 @@ typedef __u64 __bitwise __be64; typedef __u16 __bitwise __sum16; typedef __u32 __bitwise __wsum; +/* + * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid + * common 32/64-bit compat problems. + * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other + * architectures) and to 8-byte boundaries on 64-bit architectures. The new + * aligned_64 type enforces 8-byte alignment so that structs containing + * aligned_64 values have the same alignment on 32-bit and 64-bit architectures. + * No conversions are necessary between 32-bit user-space and a 64-bit kernel. + */ +#define __aligned_u64 __u64 __attribute__((aligned(8))) +#define __aligned_be64 __be64 __attribute__((aligned(8))) +#define __aligned_le64 __le64 __attribute__((aligned(8))) + #ifdef CONFIG_PHYS_ADDR_T_64BIT typedef u64 phys_addr_t; typedef u64 phys_size_t; diff --git a/include/mfd/mc34704.h b/include/mfd/mc34704.h index a3723d72a9..c42546d7c5 100644 --- a/include/mfd/mc34704.h +++ b/include/mfd/mc34704.h @@ -10,8 +10,8 @@ * */ -#ifndef __I2C_MC34704_H -#define __I2C_MC34704_H +#ifndef __MFD_MC34704_H +#define __MFD_MC34704_H struct mc34704 { struct cdev cdev; @@ -23,4 +23,4 @@ extern struct mc34704 *mc34704_get(void); extern int mc34704_reg_read(struct mc34704 *mc34704, u8 reg, u8 *val); extern int mc34704_reg_write(struct mc34704 *mc34704, u8 reg, u8 val); -#endif /* __I2C_MC34704_H */ +#endif /* __MFD_MC34704_H */ diff --git a/include/mfd/twl-core.h b/include/mfd/twl-core.h index 2ab6169433..f090032b3f 100644 --- a/include/mfd/twl-core.h +++ b/include/mfd/twl-core.h @@ -9,8 +9,8 @@ * */ -#ifndef __I2C_TWLCORE_H__ -#define __I2C_TWLCORE_H__ +#ifndef __MFD_TWLCORE_H__ +#define __MFD_TWLCORE_H__ #include <common.h> #include <i2c/i2c.h> @@ -27,4 +27,4 @@ extern int twlcore_reg_read(struct twlcore *twlcore, u16 reg, u8 *val); extern int twlcore_reg_write(struct twlcore *twlcore, u16 reg, u8 val); extern int twlcore_set_bits(struct twlcore *twlcore, u16 reg, u8 mask, u8 val); -#endif /* __I2C_TWLCORE_H__ */ +#endif /* __MFD_TWLCORE_H__ */ diff --git a/include/mfd/twl4030.h b/include/mfd/twl4030.h index bc54ea66a1..c045071527 100644 --- a/include/mfd/twl4030.h +++ b/include/mfd/twl4030.h @@ -6,8 +6,8 @@ * */ -#ifndef __I2C_TWL4030_H__ -#define __I2C_TWL4030_H__ +#ifndef __MFD_TWL4030_H__ +#define __MFD_TWL4030_H__ #include <mfd/twl-core.h> @@ -469,4 +469,4 @@ static inline int twl4030_set_bits(struct twl4030 *twl4030, return twlcore_set_bits(&(twl4030->core), reg, mask, val); } -#endif /* __I2C_TWL4030_H__ */ +#endif /* __MFD_TWL4030_H__ */ diff --git a/include/mfd/twl6030.h b/include/mfd/twl6030.h index bb4f773225..733a670973 100644 --- a/include/mfd/twl6030.h +++ b/include/mfd/twl6030.h @@ -5,8 +5,8 @@ * */ -#ifndef __I2C_TWL6030_H__ -#define __I2C_TWL6030_H__ +#ifndef __MFD_TWL6030_H__ +#define __MFD_TWL6030_H__ #include <mfd/twl-core.h> @@ -424,4 +424,4 @@ static inline int twl6030_set_bits(struct twl6030 *twl6030, return twlcore_set_bits(&twl6030->core, reg, mask, val); } -#endif /* __I2C_TWL6030_H__ */ +#endif /* __MFD_TWL6030_H__ */ diff --git a/include/mtd/libmtd.h b/include/mtd/libmtd.h index e88a9a249a..65c390aff3 100644 --- a/include/mtd/libmtd.h +++ b/include/mtd/libmtd.h @@ -69,7 +69,7 @@ struct mtd_dev_info int mtd_get_dev_info(const char *node, struct mtd_dev_info *mtd); /** - * mtd_erase - erase an eraseblock. + * libmtd_erase - erase an eraseblock. * @desc: MTD library descriptor * @mtd: MTD device description object * @fd: MTD device node file descriptor @@ -78,7 +78,7 @@ int mtd_get_dev_info(const char *node, struct mtd_dev_info *mtd); * This function erases eraseblock @eb of MTD device described by @fd. Returns * %0 in case of success and %-1 in case of failure. */ -int mtd_erase(const struct mtd_dev_info *mtd, int fd, int eb); +int libmtd_erase(const struct mtd_dev_info *mtd, int fd, int eb); /** * mtd_torture - torture an eraseblock. @@ -127,7 +127,7 @@ int mtd_mark_bad(const struct mtd_dev_info *mtd, int fd, int eb); * of the MTD device defined by @mtd and stores the read data at buffer @buf. * Returns %0 in case of success and %-1 in case of failure. */ -int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs, +int libmtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs, void *buf, int len); /** @@ -143,7 +143,7 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs, * of the MTD device defined by @mtd. Returns %0 in case of success and %-1 in * case of failure. */ -int mtd_write(const struct mtd_dev_info *mtd, int fd, int eb, int offs, +int libmtd_write(const struct mtd_dev_info *mtd, int fd, int eb, int offs, void *buf, int len); #endif /* __LIBMTD_H__ */ diff --git a/include/of.h b/include/of.h index d3a310f2ff..95d970201b 100644 --- a/include/of.h +++ b/include/of.h @@ -17,7 +17,21 @@ void do_fixup_by_path(struct fdt_header *fdt, const char *path, const char *prop const void *val, int len, int create); void do_fixup_by_path_u32(struct fdt_header *fdt, const char *path, const char *prop, u32 val, int create); +void do_fixup_by_compatible(struct fdt_header *fdt, const char *compatible, + const char *prop, const void *val, int len, int create); +void do_fixup_by_compatible_u32(struct fdt_header *fdt, const char *compatible, + const char *prop, u32 val, int create); +void do_fixup_by_compatible_string(struct fdt_header *fdt, const char *compatible, + const char *prop, const char *val, int create); int fdt_get_path_or_create(struct fdt_header *fdt, const char *path); +#ifdef CONFIG_FDT +int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force); +#else +static inline int fdt_initrd(void *fdt, ulong start, ulong end, int force) +{ + return 0; +} +#endif #define OF_BAD_ADDR ((u64)-1) @@ -124,6 +138,7 @@ int of_alias_get_id(struct device_node *np, const char *stem); int of_device_is_stdout_path(struct device_d *dev); const char *of_get_model(void); void *of_flatten_dtb(void); +int of_add_memory(struct device_node *node, bool dump); #else static inline int of_parse_partitions(const char *cdevname, struct device_node *node) @@ -155,6 +170,11 @@ static inline void *of_flatten_dtb(void) { return NULL; } + +static inline int of_add_memory(struct device_node *node, bool dump) +{ + return -EINVAL; +} #endif #endif /* __OF_H */ diff --git a/include/printk.h b/include/printk.h index 1d45616f54..3de890547e 100644 --- a/include/printk.h +++ b/include/printk.h @@ -23,10 +23,7 @@ int dev_printf(const struct device_d *dev, const char *format, ...) #define __dev_printf(level, dev, format, args...) \ ({ \ - int ret = 0; \ - if (level <= LOGLEVEL) \ - ret = dev_printf(dev, format, ##args); \ - ret; \ + (level) <= LOGLEVEL ? dev_printf((dev), (format), ##args) : 0; \ }) diff --git a/include/sizes.h b/include/sizes.h index c47f906853..6f91e9b4bd 100644 --- a/include/sizes.h +++ b/include/sizes.h @@ -17,7 +17,19 @@ #define __sizes_h 1 /* handy sizes */ +#define SZ_1 0x00000001 +#define SZ_2 0x00000002 +#define SZ_4 0x00000004 +#define SZ_8 0x00000008 +#define SZ_16 0x00000010 +#define SZ_32 0x00000020 +#define SZ_64 0x00000040 +#define SZ_128 0x00000080 +#define SZ_256 0x00000100 +#define SZ_512 0x00000200 + #define SZ_1K 0x00000400 +#define SZ_2K 0x00000800 #define SZ_4K 0x00001000 #define SZ_8K 0x00002000 #define SZ_16K 0x00004000 diff --git a/include/usb/chipidea-imx.h b/include/usb/chipidea-imx.h index e98cc891b7..3f9f61ee17 100644 --- a/include/usb/chipidea-imx.h +++ b/include/usb/chipidea-imx.h @@ -9,6 +9,7 @@ #define MXC_EHCI_MODE_UTMI_16_BIT ((0 << 30) | (1 << 28)) #define MXC_EHCI_MODE_PHILIPS (1 << 30) #define MXC_EHCI_MODE_ULPI (2 << 30) +#define MXC_EHCI_MODE_HSIC (1 << 25) #define MXC_EHCI_MODE_SERIAL (3 << 30) /* @@ -39,8 +40,10 @@ enum imx_usb_mode { struct imxusb_platformdata { unsigned long flags; enum imx_usb_mode mode; + int (*init)(int port); }; int imx_usbmisc_port_init(int port, unsigned flags); +int imx_usbmisc_port_post_init(int port, unsigned flags); #endif /* __USB_CHIPIDEA_IMX_H */ diff --git a/include/usb/ehci.h b/include/usb/ehci.h index 437711697d..93f980d34f 100644 --- a/include/usb/ehci.h +++ b/include/usb/ehci.h @@ -11,6 +11,11 @@ struct ehci_data { void __iomem *hccr; void __iomem *hcor; unsigned long flags; + + /* platform specific init functions */ + int (*init)(void *drvdata); + int (*post_init)(void *drvdata); + void *drvdata; }; #ifdef CONFIG_USB_EHCI diff --git a/include/usb/fsl_usb2.h b/include/usb/fsl_usb2.h index fd37adebc8..dec3933d82 100644 --- a/include/usb/fsl_usb2.h +++ b/include/usb/fsl_usb2.h @@ -1,3 +1,6 @@ +#ifndef __USB_FSL_USB2_H +#define __USB_FSL_USB2_H + enum fsl_usb2_operating_modes { FSL_USB2_MPH_HOST, FSL_USB2_DR_HOST, @@ -20,3 +23,6 @@ struct fsl_usb2_platform_data { unsigned int port_enables; }; +int ci_udc_register(struct device_d *dev, void __iomem *regs); + +#endif /* __USB_FSL_USB2_H */ diff --git a/include/usb/usb.h b/include/usb/usb.h index 4649ee2a9e..afccf706d7 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -270,7 +270,7 @@ void usb_rescan(void); #ifdef __LITTLE_ENDIAN # define swap_16(x) (x) # define swap_32(x) (x) -#elif defined BIG_ENDIAN +#elif defined __BIG_ENDIAN # define swap_16(x) __swap_16(x) # define swap_32(x) __swap_32(x) #else diff --git a/lib/getopt.c b/lib/getopt.c index ead9150994..fd12a886ec 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -56,10 +56,10 @@ void getopt_context_restore(struct getopt_context *gc) } EXPORT_SYMBOL(getopt_context_restore); -int getopt(int argc, char *argv[], char *optstring) +int getopt(int argc, char *argv[], const char *optstring) { char curopt; /* current option character */ - char *curoptp; /* pointer to the current option in optstring */ + const char *curoptp; /* pointer to the current option in optstring */ while(1) { debug("optindex: %d nonopts: %d optind: %d\n", optindex, nonopts, optind); diff --git a/lib/libmtd.c b/lib/libmtd.c index 8c4152eb79..eecc760548 100644 --- a/lib/libmtd.c +++ b/lib/libmtd.c @@ -56,7 +56,7 @@ static int mtd_valid_erase_block(const struct mtd_dev_info *mtd, int eb) return 0; } -int mtd_erase(const struct mtd_dev_info *mtd, int fd, int eb) +int libmtd_erase(const struct mtd_dev_info *mtd, int fd, int eb) { int ret; struct erase_info_user ei; @@ -107,12 +107,12 @@ int mtd_torture(const struct mtd_dev_info *mtd, int fd, int eb) buf = xmalloc(mtd->eb_size); for (i = 0; i < patt_count; i++) { - err = mtd_erase(mtd, fd, eb); + err = libmtd_erase(mtd, fd, eb); if (err) goto out; /* Make sure the PEB contains only 0xFF bytes */ - err = mtd_read(mtd, fd, eb, 0, buf, mtd->eb_size); + err = libmtd_read(mtd, fd, eb, 0, buf, mtd->eb_size); if (err) goto out; @@ -125,12 +125,12 @@ int mtd_torture(const struct mtd_dev_info *mtd, int fd, int eb) /* Write a pattern and check it */ memset(buf, patterns[i], mtd->eb_size); - err = mtd_write(mtd, fd, eb, 0, buf, mtd->eb_size); + err = libmtd_write(mtd, fd, eb, 0, buf, mtd->eb_size); if (err) goto out; memset(buf, ~patterns[i], mtd->eb_size); - err = mtd_read(mtd, fd, eb, 0, buf, mtd->eb_size); + err = libmtd_read(mtd, fd, eb, 0, buf, mtd->eb_size); if (err) goto out; @@ -191,7 +191,7 @@ int mtd_mark_bad(const struct mtd_dev_info *mtd, int fd, int eb) return 0; } -int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs, +int libmtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs, void *buf, int len) { int ret, rd = 0; @@ -225,7 +225,7 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs, return 0; } -int mtd_write(const struct mtd_dev_info *mtd, int fd, int eb, int offs, +int libmtd_write(const struct mtd_dev_info *mtd, int fd, int eb, int offs, void *buf, int len) { int ret; diff --git a/lib/libscan.c b/lib/libscan.c index af55269ec4..c59acfa610 100644 --- a/lib/libscan.c +++ b/lib/libscan.c @@ -90,7 +90,7 @@ int libscan_ubi_scan(struct mtd_dev_info *mtd, int fd, struct ubi_scan_info **in continue; } - ret = mtd_read(mtd, fd, eb, 0, &ech, sizeof(struct ubi_ec_hdr)); + ret = libmtd_read(mtd, fd, eb, 0, &ech, sizeof(struct ubi_ec_hdr)); if (ret < 0) goto out_ec; diff --git a/net/dhcp.c b/net/dhcp.c index 768255e184..8233ec3502 100644 --- a/net/dhcp.c +++ b/net/dhcp.c @@ -829,8 +829,8 @@ BAREBOX_MAGICVAR_NAMED(global_hostname, global.hostname, "hostname to send or re BAREBOX_MAGICVAR_NAMED(global_dhcp_bootfile, global.dhcp.bootfile, "bootfile returned from DHCP request"); BAREBOX_MAGICVAR_NAMED(global_dhcp_rootpath, global.dhcp.rootpath, "rootpath returned from DHCP request"); BAREBOX_MAGICVAR_NAMED(global_dhcp_vendor_id, global.dhcp.vendor_id, "vendor id to send to the DHCP server"); -BAREBOX_MAGICVAR_NAMED(global_dhcp_client_uuid, global.dhcp.client_uuid, "cliend uuid to send to the DHCP server"); -BAREBOX_MAGICVAR_NAMED(global_dhcp_client_id, global.dhcp.client_id, "cliend id to send to the DHCP server"); +BAREBOX_MAGICVAR_NAMED(global_dhcp_client_uuid, global.dhcp.client_uuid, "client uuid to send to the DHCP server"); +BAREBOX_MAGICVAR_NAMED(global_dhcp_client_id, global.dhcp.client_id, "client id to send to the DHCP server"); BAREBOX_MAGICVAR_NAMED(global_dhcp_user_class, global.dhcp.user_class, "user class to send to the DHCP server"); BAREBOX_MAGICVAR_NAMED(global_dhcp_tftp_server_name, global.dhcp.tftp_server_name, "TFTP server Name returned from DHCP request"); BAREBOX_MAGICVAR_NAMED(global_dhcp_oftree_file, global.dhcp.oftree_file, "OF tree returned from DHCP request (option 224)"); diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index f7d672160c..871c44b482 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -21,6 +21,14 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) # o if we encounter foo/ in $(obj-m), remove it from $(obj-m) # and add the directory to the list of dirs to descend into: $(subdir-m) +# lowlevel is present in the PBL if enabled +# otherwise in barebox +ifeq ($(CONFIG_PBL_IMAGE), y) +pbl-y += $(lwl-y) +else +obj-y += $(lwl-y) +endif + # for non dirs add pbl- prefix to the target # so we recompile the source with custom flags and custom quiet __pbl-y := $(notdir $(pbl-y)) diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c index 9284c0b083..6d6d55b1db 100644 --- a/scripts/bareboxenv.c +++ b/scripts/bareboxenv.c @@ -137,7 +137,7 @@ void usage(char *prgname) int main(int argc, char *argv[]) { int opt; - int save = 0, load = 0, pad = 0, fd; + int save = 0, load = 0, pad = 0, err = 0, fd; char *filename = NULL, *dirname = NULL; int verbose = 0; @@ -190,12 +190,20 @@ int main(int argc, char *argv[]) if (load) { if (verbose) printf("loading env from file %s to %s\n", filename, dirname); - envfs_load(filename, dirname, 0); + + err = envfs_load(filename, dirname, 0); + + if (verbose && err) + printf("loading env failed: %d\n", err); } if (save) { if (verbose) printf("saving contents of %s to file %s\n", dirname, filename); - envfs_save(filename, dirname); + + err = envfs_save(filename, dirname); + + if (verbose && err) + printf("saving env failed: %d\n", err); } - exit(0); + exit(err ? 1 : 0); } diff --git a/scripts/omap4_usbboot.c b/scripts/omap4_usbboot.c index 8c5775d840..e52108614b 100644 --- a/scripts/omap4_usbboot.c +++ b/scripts/omap4_usbboot.c @@ -78,7 +78,7 @@ int read_asic_id(struct usb_handle *usb) const uint32_t msg_getid = 0xF0030003; int i, j, k, ret; uint8_t id[81]; - char line[LINEWIDTH*3+8]; + char line[LINEWIDTH*3+5]; printf("reading ASIC ID\n"); memset(id , 0xee, sizeof(id)); @@ -96,9 +96,8 @@ int read_asic_id(struct usb_handle *usb) sprintf(line, "%02X: ", i); for (j = 0; j < LINEWIDTH && j < sizeof(id)-i; j++) sprintf(line+4+j*3, "%02X ", id[i+j]); - line[4+j*3+0] = '\n'; - line[4+j*3+1] = 0; - printf(line); + line[4+j*3] = 0; + puts(line); } ret = 0; for (i = 1, j = 0; i < sizeof(id) && j < id[0]; i += 2+id[i+1], j++) { |