diff --git a/Kconfig b/Kconfig new file mode 100644 index 0000000..8e994df --- /dev/null +++ b/Kconfig @@ -0,0 +1,11 @@ +# +# For a description of the syntax of this configuration file, +# see Documentation/kbuild/kconfig-language.txt. +# +mainmenu "Linux/$ARCH $KERNELVERSION Barebox Configuration" + +config SRCARCH + string + option env="SRCARCH" + +source "arch/$SRCARCH/Kconfig" diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index f1536a5..bc54e58 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -39,8 +39,8 @@ bool "Freescale iMX-based" select GENERIC_GPIO -config ARCH_STM - bool "SigmaTel/FSL iMX-based" +config ARCH_MXS + bool "Freescale i.MX23/28 (mxs) based" select GENERIC_GPIO config ARCH_NETX @@ -71,13 +71,16 @@ source arch/arm/mach-at91/Kconfig source arch/arm/mach-ep93xx/Kconfig source arch/arm/mach-imx/Kconfig -source arch/arm/mach-stm/Kconfig +source arch/arm/mach-mxs/Kconfig source arch/arm/mach-netx/Kconfig source arch/arm/mach-nomadik/Kconfig source arch/arm/mach-omap/Kconfig source arch/arm/mach-s3c24xx/Kconfig source arch/arm/mach-versatile/Kconfig +config ARM_ASM_UNIFIED + bool + config AEABI bool "Use the ARM EABI to compile barebox" help diff --git a/arch/arm/Makefile b/arch/arm/Makefile index c90960e..57a045f 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -35,13 +35,14 @@ endif CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y) +AFLAGS += -include asm/unified.h # Machine directory name. This list is sorted alphanumerically # by CONFIG_* macro name. machine-$(CONFIG_ARCH_AT91) := at91 machine-$(CONFIG_ARCH_EP93XX) := ep93xx machine-$(CONFIG_ARCH_IMX) := imx -machine-$(CONFIG_ARCH_STM) := stm +machine-$(CONFIG_ARCH_MXS) := mxs machine-$(CONFIG_ARCH_NOMADIK) := nomadik machine-$(CONFIG_ARCH_NETX) := netx machine-$(CONFIG_ARCH_OMAP) := omap diff --git a/arch/arm/boards/at91sam9m10g45ek/init.c b/arch/arm/boards/at91sam9m10g45ek/init.c index bb8b7ba..77d51b7 100644 --- a/arch/arm/boards/at91sam9m10g45ek/init.c +++ b/arch/arm/boards/at91sam9m10g45ek/init.c @@ -40,6 +40,26 @@ #include #include +/* + * board revision encoding + * bit 0-3: lcd type + * 0 => truly TFT1N4633-E (sam9m10g45-ek) + * 1 => LG philips LB043WQ1 (sam9m10-ekes and sam9g45-ekes) + */ +#define HAVE_LCD_TRULY_TFT1N4633E (0 << 0) +#define HAVE_LCD_LG_LB043WQ1 (1 << 0) +static void ek_set_board_revision(void) +{ + u32 rev; + +#ifdef CONFIG_LCD_LG_LB043WQ1 + rev = HAVE_LCD_LG_LB043WQ1; +#else + rev = HAVE_LCD_TRULY_TFT1N4633E; +#endif + armlinux_set_revision(rev); +} + static struct atmel_nand_data nand_pdata = { .ale = 21, .cle = 22, @@ -103,6 +123,7 @@ armlinux_set_bootparams((void *)(AT91_CHIPSELECT_6 + 0x100)); armlinux_set_architecture(MACH_TYPE_AT91SAM9M10G45EK); + ek_set_board_revision(); return 0; } diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c index 76ff906..d46431c 100644 --- a/arch/arm/boards/chumby_falconwing/falconwing.c +++ b/arch/arm/boards/chumby_falconwing/falconwing.c @@ -22,13 +22,16 @@ #include #include #include +#include #include #include +#include #include #include #include #include #include +#include static struct memory_platform_data ram_pdata = { .name = "ram0", @@ -54,6 +57,22 @@ .platform_data = &mci_pdata, }; +#define GPIO_LCD_RESET 50 +#define GPIO_LCD_BACKLIGHT 60 + +static void chumby_fb_enable(int enable) +{ + gpio_direction_output(GPIO_LCD_RESET, enable); + + /* Give the display a chance to sync before we enable + * the backlight to avoid flickering + */ + if (enable) + mdelay(100); + + gpio_direction_output(GPIO_LCD_BACKLIGHT, enable); +} + static struct fb_videomode falconwing_vmode = { /* * Nanovision NMA35QV65-B2-K01 (directly connected) @@ -79,11 +98,12 @@ .flag = 0, }; -static struct imx_fb_videomode fb_mode = { +static struct imx_fb_platformdata fb_mode = { .mode_list = &falconwing_vmode, .mode_cnt = 1, /* the NMA35 is a 24 bit display, but only 18 bits are connected */ .ld_intf_width = STMLCDIF_18BIT, + .enable = chumby_fb_enable, }; static struct device_d ldcif_dev = { @@ -197,10 +217,10 @@ /* backlight control, to be controled by PWM, here we only want to disable it */ PWM2_GPIO | GPIO_OUT | GPIO_VALUE(0), /* 1 enables, 0 disables the backlight */ - /* send a reset signal to the USB hub */ + /* USB hub reset (active low) */ AUART1_TX_GPIO | GPIO_OUT | GPIO_VALUE(0), - /* USB power disable (FIXME what level to be switched off) */ + /* USB power (active high) */ AUART1_CTS_GPIO | GPIO_OUT | GPIO_VALUE(0), /* Detecting if a display is connected (0 = display attached) (external pull up) */ @@ -262,6 +282,28 @@ GPMI_RDY3_GPIO | GPIO_IN | PULLUP(1), }; +#ifdef CONFIG_MMU +static int falconwing_mmu_init(void) +{ + mmu_init(); + + arm_create_section(0x40000000, 0x40000000, 64, PMD_SECT_DEF_CACHED); + arm_create_section(0x50000000, 0x40000000, 64, PMD_SECT_DEF_UNCACHED); + + setup_dma_coherent(0x10000000); + +#if TEXT_BASE & (0x100000 - 1) +#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary +#else + arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED); +#endif + mmu_enable(); + + return 0; +} +postcore_initcall(falconwing_mmu_init); +#endif + /** * Try to register an environment storage on the attached MCI card * @return 0 on success @@ -298,6 +340,35 @@ return devfs_add_partition("disk0.1", 0, cdev->size, DEVFS_PARTITION_FIXED, "env0"); } +static struct ehci_platform_data chumby_usb_pdata = { + .flags = EHCI_HAS_TT, + .hccr_offset = 0x100, + .hcor_offset = 0x140, +}; + +static struct device_d usb_dev = { + .name = "ehci", + .id = -1, + .map_base = IMX_USB_BASE, + .size = 0x200, + .platform_data = &chumby_usb_pdata, +}; + +#define GPIO_USB_HUB_RESET 29 +#define GPIO_USB_HUB_POWER 26 + +static void falconwing_init_usb(void) +{ + /* power USB hub */ + gpio_direction_output(GPIO_USB_HUB_POWER, 1); + mdelay(1); + /* bring USB hub out of reset */ + gpio_direction_output(GPIO_USB_HUB_RESET, 1); + + imx_usb_phy_enable(); + register_device(&usb_dev); +} + static int falconwing_devices_init(void) { int i, rc; @@ -313,6 +384,8 @@ register_device(&mci_dev); register_device(&ldcif_dev); + falconwing_init_usb(); + armlinux_add_dram(&sdram_dev); armlinux_set_bootparams((void*)(sdram_dev.map_base + 0x100)); armlinux_set_architecture(MACH_TYPE_CHUMBY); diff --git a/arch/arm/boards/eukrea_cpuimx25/env/bin/_update b/arch/arm/boards/eukrea_cpuimx25/env/bin/_update deleted file mode 100644 index 014bce3..0000000 --- a/arch/arm/boards/eukrea_cpuimx25/env/bin/_update +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -if [ -z "$part" -o -z "$image" ]; then - echo "define \$part and \$image" - exit 1 -fi - -if [ ! -e "$part" ]; then - echo "Partition $part does not exist" - exit 1 -fi - -if [ $# = 1 ]; then - image=$1 -fi - -if [ x$ip = xdhcp ]; then - dhcp -fi - -ping $eth0.serverip -if [ $? -ne 0 ] ; then - echo "update aborted" - exit 1 -fi - -unprotect $part - -echo -echo "erasing partition $part" -erase $part - -echo -echo "flashing $image to $part" -echo -tftp $image $part diff --git a/arch/arm/boards/eukrea_cpuimx25/env/bin/boot b/arch/arm/boards/eukrea_cpuimx25/env/bin/boot deleted file mode 100644 index 2d9b3af..0000000 --- a/arch/arm/boards/eukrea_cpuimx25/env/bin/boot +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -. /env/config - -if [ x$1 = xjffS2 ]; then - root=jffs2 - kernel=nand -fi - -if [ x$1 = xubifs ]; then - root=ubifs - kernel=nand -fi - -if [ x$1 = xnet ]; then - root=net - kernel=net -fi - -if [ x$ip = xdhcp ]; then - bootargs="$bootargs ip=dhcp" -else - if [ x$ip = xoff ]; then - bootargs="$bootargs ip=off" - else - bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::" - fi -fi - -if [ x$root = xjffs2 ]; then - bootargs="$bootargs root=/dev/mtdblock$rootpartnum_nand rootfstype=jffs2" -fi - -if [ x$root = xubifs ]; then - bootargs="$bootargs root=ubi0:$ubiroot ubi.mtd=$rootpartnum_nand rootfstype=ubifs" -fi - -if [ x$root = xnet ]; then - bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp" -fi - -bootargs="$bootargs mtdparts=mxc_nand:$nand_parts" - -if [ $kernel = net ]; then - if [ x$ip = xdhcp ]; then - dhcp - fi - tftp $uimage uImage || exit 1 - bootm uImage -else - bootm /dev/nand0.kernel.bb -fi - diff --git a/arch/arm/boards/eukrea_cpuimx25/env/bin/hush_hack b/arch/arm/boards/eukrea_cpuimx25/env/bin/hush_hack deleted file mode 100644 index 5fffa92..0000000 --- a/arch/arm/boards/eukrea_cpuimx25/env/bin/hush_hack +++ /dev/null @@ -1 +0,0 @@ -nand -a /dev/nand0.* diff --git a/arch/arm/boards/eukrea_cpuimx25/env/bin/init b/arch/arm/boards/eukrea_cpuimx25/env/bin/init deleted file mode 100644 index 4732875..0000000 --- a/arch/arm/boards/eukrea_cpuimx25/env/bin/init +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -PATH=/env/bin -export PATH - -. /env/config -if [ -e /dev/nand0 ]; then - addpart /dev/nand0 $nand_parts - - # Uh, oh, hush first expands wildcards and then starts executing - # commands. What a bug! - source /env/bin/hush_hack -fi - -if [ -f /env/logo.bmp ]; then - bmp /env/logo.bmp - fb0.enable=1 -elif [ -f /env/logo.bmp.lzo ]; then - unlzo /env/logo.bmp.lzo /logo.bmp - bmp /logo.bmp - fb0.enable=1 -fi - -if [ -z $eth0.ethaddr ]; then - while [ -z $eth0.ethaddr ]; do - readline "no MAC address set for eth0. please enter the one found on your board: " eth0.ethaddr - done - echo -a /env/config "eth0.ethaddr=$eth0.ethaddr" - saveenv -fi - -echo -echo -n "Hit any key to stop autoboot: " -timeout -a $autoboot_timeout -if [ $? != 0 ]; then - echo - echo "type update_kernel [] to update kernel into flash" - echo "type update_root [] to update rootfs into flash" - echo - exit -fi - -boot diff --git a/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board b/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board new file mode 100644 index 0000000..72b4ab3 --- /dev/null +++ b/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ -f /env/logo.bmp ]; then + bmp /env/logo.bmp + fb0.enable=1 +elif [ -f /env/logo.bmp.lzo ]; then + unlzo /env/logo.bmp.lzo /logo.bmp + bmp /logo.bmp + fb0.enable=1 +fi + +if [ -z $eth0.ethaddr ]; then + while [ -z $eth0.ethaddr ]; do + readline "no MAC address set for eth0. please enter the one found on your board: " eth0.ethaddr + done + echo -a /env/config "eth0.ethaddr=$eth0.ethaddr" + saveenv +fi diff --git a/arch/arm/boards/eukrea_cpuimx25/env/bin/update_kernel b/arch/arm/boards/eukrea_cpuimx25/env/bin/update_kernel deleted file mode 100644 index c2d2cc3..0000000 --- a/arch/arm/boards/eukrea_cpuimx25/env/bin/update_kernel +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -. /env/config - -image=$uimage -part=/dev/nand0.kernel.bb - -. /env/bin/_update $1 diff --git a/arch/arm/boards/eukrea_cpuimx25/env/bin/update_root b/arch/arm/boards/eukrea_cpuimx25/env/bin/update_root deleted file mode 100644 index dd89a5a..0000000 --- a/arch/arm/boards/eukrea_cpuimx25/env/bin/update_root +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -. /env/config - -image=$rootfs -part=/dev/nand0.root.bb - -. /env/bin/_update $1 diff --git a/arch/arm/boards/eukrea_cpuimx25/env/config b/arch/arm/boards/eukrea_cpuimx25/env/config index 3e41ec8..927010c 100644 --- a/arch/arm/boards/eukrea_cpuimx25/env/config +++ b/arch/arm/boards/eukrea_cpuimx25/env/config @@ -1,27 +1,48 @@ #!/bin/sh -# can be either 'net' or 'jffs2' or 'ubifs' -kernel=nand -root=ubifs +# otg port mode : can be 'host' or 'device' +otg_mode="device" -basedir=cpuimx25 -uimage=$basedir/uImage -rootfs=$basedir/rootfs - -autoboot_timeout=1 - -nfsroot="" -bootargs="console=ttymxc0,115200" - -nand_parts="256k(barebox)ro,128k(bareboxenv),2432k(kernel),-(root)" -rootpartnum_nand=3 -ubiroot="eukrea-cpuimx25-rootfs" +machine=eukrea-cpuimx25 # use 'dhcp' to do dhcp in barebox and in kernel -ip=off +# use 'none' if you want to skip kernel ip autoconfiguration +ip=none # 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 'net' or 'nand' +kernel_loc=nand +# can be either 'net', 'nand' or 'initrd' +rootfs_loc=nand + +# rootfs +rootfs_type=ubifs +rootfsimage=$machine/rootfs.$rootfs_type + +# kernel +kernelimage_type=uimage +kernelimage=$machine/uImage-${machine}.bin + +# barebox and it's env +bareboximage=$machine/barebox-${machine}.bin +bareboxenvimage=$machine/bareboxenv-${machine}.bin + +nfsroot="$eth0.serverip:/srv/nfs/$machine" + +autoboot_timeout=1 + +bootargs="console=ttymxc0,115200 otg_mode=$otg_mode" + +nand_parts="256k(barebox)ro,128k(bareboxenv),3M(kernel),-(root)" +rootfs_mtdblock_nand=3 +nand_device="mxc_nand" +ubiroot="$machine-rootfs" +device_type="nand" + +# 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/eukrea_cpuimx25/eukrea_cpuimx25.c b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c index 3048c3f..ce9be97 100644 --- a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c +++ b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -132,6 +133,11 @@ .dmacr = 0x80040060, }; +struct gpio_led led0 = { + .gpio = 2 * 32 + 19, + .active_low = 1, +}; + #ifdef CONFIG_USB static void imx25_usb_init(void) { @@ -243,6 +249,8 @@ MX25_PAD_SD1_DATA1__DAT1, MX25_PAD_SD1_DATA2__DAT2, MX25_PAD_SD1_DATA3__DAT3, + /* LED */ + MX25_PAD_POWER_FAIL__GPIO19, }; static int eukrea_cpuimx25_devices_init(void) @@ -252,6 +260,8 @@ mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx25_pads, ARRAY_SIZE(eukrea_cpuimx25_pads)); + led_gpio_register(&led0); + imx25_add_fec(&fec_info); nand_info.width = 1; @@ -271,6 +281,9 @@ gpio_direction_output(26, 1); gpio_set_value(26, 1); + /* LED : default OFF */ + gpio_direction_output(2 * 32 + 19, 1); + imx25_add_fb(&eukrea_cpuimx25_fb_data); imx25_add_i2c0(NULL); diff --git a/arch/arm/boards/karo-tx28/tx28-stk5.c b/arch/arm/boards/karo-tx28/tx28-stk5.c index 6de41f7..e8338a3 100644 --- a/arch/arm/boards/karo-tx28/tx28-stk5.c +++ b/arch/arm/boards/karo-tx28/tx28-stk5.c @@ -19,7 +19,10 @@ #include #include #include +#include +#include #include +#include #include #include #include @@ -181,11 +184,15 @@ }, }; +#define MAX_FB_SIZE SZ_2M + static struct imx_fb_videomode imxfb_mode = { .mode_list = tx28evk_vmodes, .mode_cnt = ARRAY_SIZE(tx28evk_vmodes), .dotclk_delay = 0, /* no adaption required */ .ld_intf_width = STMLCDIF_24BIT, /* full 24 bit */ + .fixed_screen = (void *)(0x40000000 + SZ_128M - MAX_FB_SIZE), + .fixed_screen_size = MAX_FB_SIZE, }; static struct device_d ldcif_dev = { @@ -352,6 +359,12 @@ imx_set_sspclk(0, 100000000, 1); register_device(&mci_socket); + + if (imxfb_mode.fixed_screen < (void *)&_end) { + printf("Warning: fixed_screen overlaps barebox\n"); + imxfb_mode.fixed_screen = NULL; + } + register_device(&ldcif_dev); imx_enable_enetclk(); diff --git a/arch/arm/boards/karo-tx28/tx28.c b/arch/arm/boards/karo-tx28/tx28.c index 6f4ef4e..5692171 100644 --- a/arch/arm/boards/karo-tx28/tx28.c +++ b/arch/arm/boards/karo-tx28/tx28.c @@ -21,6 +21,7 @@ #include #include #include +#include static struct memory_platform_data ram_pdata = { .name = "ram0", @@ -82,6 +83,28 @@ extern void base_board_init(void); +#ifdef CONFIG_MMU +static int tx28_mmu_init(void) +{ + mmu_init(); + + arm_create_section(0x40000000, 0x40000000, 128, PMD_SECT_DEF_CACHED); + arm_create_section(0x50000000, 0x40000000, 128, PMD_SECT_DEF_UNCACHED); + + setup_dma_coherent(0x10000000); + +#if TEXT_BASE & (0x100000 - 1) +#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary +#else + arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED); +#endif + mmu_enable(); + + return 0; +} +postcore_initcall(tx28_mmu_init); +#endif + static int tx28_devices_init(void) { int i; diff --git a/arch/arm/boards/phycard-i.MX27/pca100.c b/arch/arm/boards/phycard-i.MX27/pca100.c index 32f7e74..c539ea1 100644 --- a/arch/arm/boards/phycard-i.MX27/pca100.c +++ b/arch/arm/boards/phycard-i.MX27/pca100.c @@ -66,6 +66,13 @@ }; #ifdef CONFIG_USB +static struct device_d usbotg_dev = { + .id = -1, + .name = "ehci", + .map_base = IMX_OTG_BASE, + .size = 0x200, +}; + static struct device_d usbh2_dev = { .id = -1, .name = "ehci", @@ -73,27 +80,19 @@ .size = 0x200, }; -static void pca100_usbh_init(void) +static void pca100_usb_register(void) { - uint32_t temp; - - temp = readl(IMX_OTG_BASE + 0x600); - temp &= ~((3 << 21) | 1); - temp |= (1 << 5) | (1 << 16) | (1 << 19) | (1 << 11) | (1 << 20); - writel(temp, IMX_OTG_BASE + 0x600); - - temp = readl(IMX_OTG_BASE + 0x584); - temp &= ~(3 << 30); - temp |= 2 << 30; - writel(temp, IMX_OTG_BASE + 0x584); - mdelay(10); gpio_direction_output(GPIO_PORTB + 24, 0); + gpio_direction_output(GPIO_PORTB + 23, 0); mdelay(10); + isp1504_set_vbus_power((void *)(IMX_OTG_BASE + 0x170), 1); + register_device(&usbotg_dev); isp1504_set_vbus_power((void *)(IMX_OTG_BASE + 0x570), 1); + register_device(&usbh2_dev); } #endif @@ -120,6 +119,38 @@ } #endif +static void pca100_usb_init(void) +{ + u32 reg; + + reg = readl(IMX_OTG_BASE + 0x600); + reg &= ~((3 << 21) | 1); + reg |= (1 << 5) | (1 << 16) | (1 << 19) | (1 << 11) | (1 << 20); + writel(reg, IMX_OTG_BASE + 0x600); + + /* + * switch usbotg and usbh2 to ulpi mode. Do this *before* + * the iomux setup to prevent funny hardware bugs from + * triggering. Also, do this even when USB support is + * disabled to give Linux USB support a good start. + */ + reg = readl(IMX_OTG_BASE + 0x584); + reg &= ~(3 << 30); + reg |= 2 << 30; + writel(reg, IMX_OTG_BASE + 0x584); + + reg = readl(IMX_OTG_BASE + 0x184); + reg &= ~(3 << 30); + reg |= 2 << 30; + writel(reg, IMX_OTG_BASE + 0x184); + + /* disable the usb phys */ + imx_gpio_mode((GPIO_PORTB | 23) | GPIO_GPIO | GPIO_IN); + gpio_direction_output(GPIO_PORTB + 23, 1); + imx_gpio_mode((GPIO_PORTB | 24) | GPIO_GPIO | GPIO_IN); + gpio_direction_output(GPIO_PORTB + 24, 1); +} + static int pca100_devices_init(void) { int i; @@ -175,15 +206,23 @@ PB7_PF_SD2_D3, PB8_PF_SD2_CMD, PB9_PF_SD2_CLK, + PC7_PF_USBOTG_DATA5, + PC8_PF_USBOTG_DATA6, + PC9_PF_USBOTG_DATA0, + PC10_PF_USBOTG_DATA2, + PC11_PF_USBOTG_DATA1, + PC12_PF_USBOTG_DATA4, + PC13_PF_USBOTG_DATA3, + PE0_PF_USBOTG_NXT, + PE1_PF_USBOTG_STP, + PE2_PF_USBOTG_DIR, + PE24_PF_USBOTG_CLK, + PE25_PF_USBOTG_DATA7, }; PCCR0 |= PCCR0_SDHC2_EN; - /* disable the usb phys */ - imx_gpio_mode((GPIO_PORTB | 23) | GPIO_GPIO | GPIO_IN); - gpio_direction_output(GPIO_PORTB + 23, 1); - imx_gpio_mode((GPIO_PORTB | 24) | GPIO_GPIO | GPIO_IN); - gpio_direction_output(GPIO_PORTB + 24, 1); + pca100_usb_init(); /* initizalize gpios */ for (i = 0; i < ARRAY_SIZE(mode); i++) @@ -197,8 +236,7 @@ PCCR1 |= PCCR1_PERCLK2_EN; #ifdef CONFIG_USB - pca100_usbh_init(); - register_device(&usbh2_dev); + pca100_usb_register(); #endif nand = get_device_by_name("nand0"); diff --git a/arch/arm/boards/scb9328/env/bin/init b/arch/arm/boards/scb9328/env/bin/init deleted file mode 100644 index 416669f..0000000 --- a/arch/arm/boards/scb9328/env/bin/init +++ /dev/null @@ -1,3 +0,0 @@ - -echo running init - diff --git a/arch/arm/boards/scb9328/scb9328.c b/arch/arm/boards/scb9328/scb9328.c index 4c08c50..35c7fdf 100644 --- a/arch/arm/boards/scb9328/scb9328.c +++ b/arch/arm/boards/scb9328/scb9328.c @@ -93,7 +93,7 @@ register_device(&sdram_dev); register_device(&dm9000_dev); - devfs_add_partition("nor0", 0x00000, 0x20000, PARTITION_FIXED, "self0"); + devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0"); devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0"); protect_file("/dev/env0", 1); diff --git a/arch/arm/configs/chumbyone_defconfig b/arch/arm/configs/chumbyone_defconfig index 45804a8..33d83a8 100644 --- a/arch/arm/configs/chumbyone_defconfig +++ b/arch/arm/configs/chumbyone_defconfig @@ -1,10 +1,15 @@ -CONFIG_ARCH_STM=y +CONFIG_ARCH_MXS=y CONFIG_MACH_CHUMBY=y CONFIG_AEABI=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y +CONFIG_MMU=y +CONFIG_MALLOC_SIZE=0x1000000 CONFIG_BROKEN=y CONFIG_PROMPT="chumby:" CONFIG_LONGHELP=y +CONFIG_GLOB=y +CONFIG_HUSH_FANCY_PROMPT=y +CONFIG_HUSH_GETOPT=y CONFIG_CMDLINE_EDITING=y CONFIG_AUTO_COMPLETE=y CONFIG_PARTITION=y @@ -18,14 +23,28 @@ CONFIG_CMD_PRINTENV=y CONFIG_CMD_READLINE=y CONFIG_CMD_ECHO_E=y +CONFIG_CMD_MEMINFO=y CONFIG_CMD_MTEST=y CONFIG_CMD_MTEST_ALTERNATIVE=y CONFIG_CMD_RESET=y +CONFIG_CMD_GO=y CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_BMP=y CONFIG_CMD_GPIO=y +CONFIG_NET=y +CONFIG_NET_DHCP=y +CONFIG_NET_NFS=y +CONFIG_NET_PING=y +CONFIG_NET_TFTP=y +CONFIG_NET_TFTP_PUSH=y +CONFIG_NET_NETCONSOLE=y +CONFIG_NET_RESOLV=y +CONFIG_NET_USB=y +CONFIG_NET_USB_ASIX=y # CONFIG_SPI is not set +CONFIG_USB=y +CONFIG_USB_EHCI=y CONFIG_VIDEO=y CONFIG_DRIVER_VIDEO_STM=y CONFIG_MCI=y diff --git a/arch/arm/configs/eukrea_cpuimx25_defconfig b/arch/arm/configs/eukrea_cpuimx25_defconfig index bc68804..7fa2042 100644 --- a/arch/arm/configs/eukrea_cpuimx25_defconfig +++ b/arch/arm/configs/eukrea_cpuimx25_defconfig @@ -9,10 +9,10 @@ CONFIG_GLOB=y CONFIG_PROMPT_HUSH_PS2="cpuimx25>" CONFIG_HUSH_FANCY_PROMPT=y -CONFIG_HUSH_GETOPT=y CONFIG_CMDLINE_EDITING=y CONFIG_AUTO_COMPLETE=y CONFIG_PARTITION=y +CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/eukrea_cpuimx25/env" CONFIG_CMD_EDIT=y CONFIG_CMD_SLEEP=y @@ -22,9 +22,8 @@ CONFIG_CMD_PRINTENV=y CONFIG_CMD_READLINE=y CONFIG_CMD_ECHO_E=y +CONFIG_CMD_LOADB=y CONFIG_CMD_MEMINFO=y -CONFIG_CMD_CRC=y -CONFIG_CMD_CRC_CMP=y CONFIG_CMD_MTEST=y CONFIG_CMD_FLASH=y CONFIG_CMD_BOOTM_ZLIB=y @@ -38,10 +37,14 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_UNLZO=y CONFIG_CMD_I2C=y +CONFIG_CMD_LED=y +CONFIG_CMD_LED_TRIGGER=y CONFIG_NET=y CONFIG_NET_DHCP=y +CONFIG_NET_NFS=y CONFIG_NET_PING=y CONFIG_NET_TFTP=y +CONFIG_NET_TFTP_PUSH=y CONFIG_DRIVER_NET_FEC_IMX=y # CONFIG_SPI is not set CONFIG_I2C=y @@ -51,9 +54,11 @@ CONFIG_NAND_IMX=y CONFIG_USB=y CONFIG_USB_EHCI=y -CONFIG_USB_GADGET=y CONFIG_VIDEO=y CONFIG_DRIVER_VIDEO_IMX=y CONFIG_MCI=y CONFIG_MCI_IMX_ESDHC=y CONFIG_MCI_IMX_ESDHC_PIO=y +CONFIG_LED=y +CONFIG_LED_GPIO=y +CONFIG_LED_TRIGGERS=y diff --git a/arch/arm/configs/imx23evk_defconfig b/arch/arm/configs/imx23evk_defconfig index 047a7e1..2fc6ebe 100644 --- a/arch/arm/configs/imx23evk_defconfig +++ b/arch/arm/configs/imx23evk_defconfig @@ -1,4 +1,4 @@ -CONFIG_ARCH_STM=y +CONFIG_ARCH_MXS=y CONFIG_AEABI=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_BROKEN=y diff --git a/arch/arm/configs/pca100_defconfig b/arch/arm/configs/pca100_defconfig index 8c72bdf..3450b8e 100644 --- a/arch/arm/configs/pca100_defconfig +++ b/arch/arm/configs/pca100_defconfig @@ -23,7 +23,6 @@ CONFIG_CMD_READLINE=y CONFIG_CMD_ECHO_E=y CONFIG_CMD_MEMINFO=y -CONFIG_CMD_CRC=y CONFIG_CMD_MTEST=y CONFIG_CMD_FLASH=y CONFIG_CMD_RESET=y @@ -31,6 +30,7 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_GPIO=y +CONFIG_CMD_UNLZO=y CONFIG_NET=y CONFIG_NET_DHCP=y CONFIG_NET_PING=y @@ -41,6 +41,11 @@ CONFIG_NET_USB=y CONFIG_NET_USB_ASIX=y # CONFIG_SPI is not set +CONFIG_MTD=y +CONFIG_NAND=y +CONFIG_NAND_IMX=y +CONFIG_NAND_IMX_BOOT=y +CONFIG_UBI=y CONFIG_USB=y CONFIG_USB_EHCI=y CONFIG_USB_ISP1504=y diff --git a/arch/arm/configs/scb9328_defconfig b/arch/arm/configs/scb9328_defconfig index 49bdc0d..ee0e2fc 100644 --- a/arch/arm/configs/scb9328_defconfig +++ b/arch/arm/configs/scb9328_defconfig @@ -1,11 +1,24 @@ CONFIG_ARCH_IMX=y CONFIG_MACH_SCB9328=y +CONFIG_AEABI=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_LONGHELP=y +CONFIG_GLOB=y +CONFIG_HUSH_FANCY_PROMPT=y CONFIG_CMDLINE_EDITING=y -CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/scb9328/env" +CONFIG_AUTO_COMPLETE=y +CONFIG_PARTITION=y +CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y +CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/scb9328/env/" +CONFIG_POLLER=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_MEMINFO=y CONFIG_CMD_FLASH=y CONFIG_CMD_RESET=y @@ -13,10 +26,23 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_GPIO=y +CONFIG_CMD_UNLZO=y +CONFIG_CMD_LED=y +CONFIG_CMD_LED_TRIGGER=y CONFIG_NET=y CONFIG_NET_DHCP=y +CONFIG_NET_NFS=y CONFIG_NET_PING=y CONFIG_NET_TFTP=y +CONFIG_NET_TFTP_PUSH=y +CONFIG_NET_NETCONSOLE=y +CONFIG_NET_RESOLV=y CONFIG_DRIVER_NET_DM9000=y CONFIG_DRIVER_CFI=y +# CONFIG_DRIVER_CFI_BANK_WIDTH_4 is not set CONFIG_CFI_BUFFER_WRITE=y +CONFIG_MTD=y +CONFIG_UBI=y +CONFIG_LED=y +CONFIG_LED_GPIO=y +CONFIG_LED_TRIGGERS=y diff --git a/arch/arm/configs/tx28stk5_defconfig b/arch/arm/configs/tx28stk5_defconfig index 0851d5e..384c1c9 100644 --- a/arch/arm/configs/tx28stk5_defconfig +++ b/arch/arm/configs/tx28stk5_defconfig @@ -1,7 +1,8 @@ -CONFIG_ARCH_STM=y +CONFIG_ARCH_MXS=y CONFIG_ARCH_IMX28=y CONFIG_AEABI=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y +CONFIG_MMU=y CONFIG_MALLOC_SIZE=0x800000 CONFIG_BROKEN=y CONFIG_LONGHELP=y diff --git a/arch/arm/cpu/Kconfig b/arch/arm/cpu/Kconfig index 3572a1f..8ee7d6c 100644 --- a/arch/arm/cpu/Kconfig +++ b/arch/arm/cpu/Kconfig @@ -73,6 +73,15 @@ port must properly enable any big-endian related features of your chipset/board/processor. +config BOOT_ENDIANNESS_SWITCH + bool "Support switching of Linux kernel endianness" + help + Say Y here if you need to switch CPU endianness before running + Linux kernel, e.g. if you want big-endian Barebox to run + little-endian Linux. + + Currently implemented only by "bootz" command. + config ARCH_HAS_L2X0 bool diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c index 08a57ce..df664f6 100644 --- a/arch/arm/cpu/mmu.c +++ b/arch/arm/cpu/mmu.c @@ -95,13 +95,7 @@ void *dma_alloc_coherent(size_t size) { - void *mem; - - mem = memalign(4096, size); - if (mem) - return mem + dma_coherent_offset; - - return NULL; + return xmemalign(4096, size) + dma_coherent_offset; } unsigned long virt_to_phys(void *virt) diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index b55df5d..e0fb712 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -25,6 +25,7 @@ #include #include #include +#include void __naked __section(.text_entry) exception_vectors(void) { @@ -40,8 +41,6 @@ ); } -extern char __bss_start, _end; - /* * The actual reset vector. This code is position independent and usually * does not run at the address it's linked at. @@ -108,7 +107,7 @@ (unsigned int)&__bss_start - TEXT_BASE); /* clear bss */ - memset(&__bss_start, 0, &_end - &__bss_start); + memset(__bss_start, 0, __bss_stop - __bss_start); /* call start_barebox with its absolute address */ r = (unsigned int)&start_barebox; diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h index fdd23b5..7789cc9 100644 --- a/arch/arm/include/asm/mmu.h +++ b/arch/arm/include/asm/mmu.h @@ -28,7 +28,7 @@ #else static inline void *dma_alloc_coherent(size_t size) { - return malloc(size); + return xmalloc(size); } static inline void dma_free_coherent(void *mem) diff --git a/arch/arm/include/asm/sections.h b/arch/arm/include/asm/sections.h new file mode 100644 index 0000000..2b8c516 --- /dev/null +++ b/arch/arm/include/asm/sections.h @@ -0,0 +1 @@ +#include diff --git a/arch/arm/include/asm/swab.h b/arch/arm/include/asm/swab.h new file mode 100644 index 0000000..9997ad2 --- /dev/null +++ b/arch/arm/include/asm/swab.h @@ -0,0 +1,69 @@ +/* + * arch/arm/include/asm/byteorder.h + * + * ARM Endian-ness. In little endian mode, the data bus is connected such + * that byte accesses appear as: + * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31 + * and word accesses (data or instruction) appear as: + * d0...d31 + * + * When in big endian mode, byte accesses appear as: + * 0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7 + * and word accesses (data or instruction) appear as: + * d0...d31 + */ +#ifndef __ASM_ARM_SWAB_H +#define __ASM_ARM_SWAB_H + +#include +#include + +#if !defined(__STRICT_ANSI__) || defined(__KERNEL__) +# define __SWAB_64_THRU_32__ +#endif + +#if defined(__KERNEL__) && __LINUX_ARM_ARCH__ >= 6 + +static inline __attribute_const__ __u16 __arch_swab16(__u16 x) +{ + __asm__ ("rev16 %0, %1" : "=r" (x) : "r" (x)); + return x; +} +#define __arch_swab16 __arch_swab16 + +static inline __attribute_const__ __u32 __arch_swab32(__u32 x) +{ + __asm__ ("rev %0, %1" : "=r" (x) : "r" (x)); + return x; +} +#define __arch_swab32 __arch_swab32 + +#else + +static inline __attribute_const__ __u32 __arch_swab32(__u32 x) +{ + __u32 t; + +#ifndef __thumb__ + if (!__builtin_constant_p(x)) { + /* + * The compiler needs a bit of a hint here to always do the + * right thing and not screw it up to different degrees + * depending on the gcc version. + */ + asm ("eor\t%0, %1, %1, ror #16" : "=r" (t) : "r" (x)); + } else +#endif + t = x ^ ((x << 16) | (x >> 16)); /* eor r1,r0,r0,ror #16 */ + + x = (x << 24) | (x >> 8); /* mov r0,r0,ror #8 */ + t &= ~0x00FF0000; /* bic r1,r1,#0x00FF0000 */ + x ^= (t >> 8); /* eor r0,r0,r1,lsr #8 */ + + return x; +} +#define __arch_swab32 __arch_swab32 + +#endif + +#endif diff --git a/arch/arm/include/asm/unified.h b/arch/arm/include/asm/unified.h new file mode 100644 index 0000000..bc63116 --- /dev/null +++ b/arch/arm/include/asm/unified.h @@ -0,0 +1,130 @@ +/* + * include/asm-arm/unified.h - Unified Assembler Syntax helper macros + * + * Copyright (C) 2008 ARM Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 __ASM_UNIFIED_H +#define __ASM_UNIFIED_H + +#if defined(__ASSEMBLY__) && defined(CONFIG_ARM_ASM_UNIFIED) + .syntax unified +#endif + +#ifdef CONFIG_THUMB2_KERNEL + +#if __GNUC__ < 4 +#error Thumb-2 kernel requires gcc >= 4 +#endif + +/* The CPSR bit describing the instruction set (Thumb) */ +#define PSR_ISETSTATE PSR_T_BIT + +#define ARM(x...) +#define THUMB(x...) x +#ifdef __ASSEMBLY__ +#define W(instr) instr.w +#endif +#define BSYM(sym) sym + 1 + +#else /* !CONFIG_THUMB2_KERNEL */ + +/* The CPSR bit describing the instruction set (ARM) */ +#define PSR_ISETSTATE 0 + +#define ARM(x...) x +#define THUMB(x...) +#ifdef __ASSEMBLY__ +#define W(instr) instr +#endif +#define BSYM(sym) sym + +#endif /* CONFIG_THUMB2_KERNEL */ + +#ifndef CONFIG_ARM_ASM_UNIFIED + +/* + * If the unified assembly syntax isn't used (in ARM mode), these + * macros expand to an empty string + */ +#ifdef __ASSEMBLY__ + .macro it, cond + .endm + .macro itt, cond + .endm + .macro ite, cond + .endm + .macro ittt, cond + .endm + .macro itte, cond + .endm + .macro itet, cond + .endm + .macro itee, cond + .endm + .macro itttt, cond + .endm + .macro ittte, cond + .endm + .macro ittet, cond + .endm + .macro ittee, cond + .endm + .macro itett, cond + .endm + .macro itete, cond + .endm + .macro iteet, cond + .endm + .macro iteee, cond + .endm +#else /* !__ASSEMBLY__ */ +__asm__( +" .macro it, cond\n" +" .endm\n" +" .macro itt, cond\n" +" .endm\n" +" .macro ite, cond\n" +" .endm\n" +" .macro ittt, cond\n" +" .endm\n" +" .macro itte, cond\n" +" .endm\n" +" .macro itet, cond\n" +" .endm\n" +" .macro itee, cond\n" +" .endm\n" +" .macro itttt, cond\n" +" .endm\n" +" .macro ittte, cond\n" +" .endm\n" +" .macro ittet, cond\n" +" .endm\n" +" .macro ittee, cond\n" +" .endm\n" +" .macro itett, cond\n" +" .endm\n" +" .macro itete, cond\n" +" .endm\n" +" .macro iteet, cond\n" +" .endm\n" +" .macro iteee, cond\n" +" .endm\n"); +#endif /* __ASSEMBLY__ */ + +#endif /* CONFIG_ARM_ASM_UNIFIED */ + +#endif /* !__ASM_UNIFIED_H */ diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 1d7f15a..89cb72b 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -1,12 +1,5 @@ obj-y += armlinux.o -obj-y += _ashldi3.o -obj-y += _ashrdi3.o obj-y += div0.o -obj-y += _divsi3.o -obj-y += _modsi3.o -obj-y += _udivsi3.o -obj-y += _umodsi3.o -obj-y += _lshrdi3.o obj-y += findbit.o obj-y += arm.o obj-y += io-readsb.o @@ -15,8 +8,10 @@ obj-y += io-writesb.o obj-y += io-writesw-armv4.o obj-y += io-writesl.o -obj-$(CONFIG_AEABI) += __aeabi_idivmod.o -obj-$(CONFIG_AEABI) += __aeabi_uidivmod.o +obj-y += lib1funcs.o +obj-y += ashrdi3.o +obj-y += ashldi3.o +obj-y += lshrdi3.o obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS) += memcpy.o obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS) += memset.o diff --git a/arch/arm/lib/__aeabi_idivmod.S b/arch/arm/lib/__aeabi_idivmod.S deleted file mode 100644 index 07de06b..0000000 --- a/arch/arm/lib/__aeabi_idivmod.S +++ /dev/null @@ -1,50 +0,0 @@ -/* - * linux/arch/arm/lib/lib1funcs.S: Optimized ARM division routines - * - * Author: Nicolas Pitre - * - contributed to gcc-3.4 on Sep 30, 2003 - * - adapted for the Linux kernel on Oct 2, 2003 - */ - -/* Copyright 1995, 1996, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. - -This file 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, or (at your option) any -later version. - -In addition to the permissions in the GNU General Public License, the -Free Software Foundation gives you unlimited permission to link the -compiled version of this file into combinations with other programs, -and to distribute those combinations without any restriction coming -from the use of this file. (The General Public License restrictions -do apply in other respects; for example, they cover modification of -the file, and distribution when not linked into a combine -executable.) - -This file 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; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -#include -#include - -.section .text.__aeabi_idivmod - -ENTRY(__aeabi_idivmod) - - stmfd sp!, {r0, r1, ip, lr} - bl __aeabi_idiv - ldmfd sp!, {r1, r2, ip, lr} - mul r3, r0, r2 - sub r1, r1, r3 - mov pc, lr - -ENDPROC(__aeabi_idivmod) diff --git a/arch/arm/lib/__aeabi_uidivmod.S b/arch/arm/lib/__aeabi_uidivmod.S deleted file mode 100644 index 0e7694c..0000000 --- a/arch/arm/lib/__aeabi_uidivmod.S +++ /dev/null @@ -1,51 +0,0 @@ -/* - * linux/arch/arm/lib/lib1funcs.S: Optimized ARM division routines - * - * Author: Nicolas Pitre - * - contributed to gcc-3.4 on Sep 30, 2003 - * - adapted for the Linux kernel on Oct 2, 2003 - */ - -/* Copyright 1995, 1996, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. - -This file 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, or (at your option) any -later version. - -In addition to the permissions in the GNU General Public License, the -Free Software Foundation gives you unlimited permission to link the -compiled version of this file into combinations with other programs, -and to distribute those combinations without any restriction coming -from the use of this file. (The General Public License restrictions -do apply in other respects; for example, they cover modification of -the file, and distribution when not linked into a combine -executable.) - -This file 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; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -#include -#include - -.section .text.__aeabi_uidivmod - -ENTRY(__aeabi_uidivmod) - - stmfd sp!, {r0, r1, ip, lr} - bl __aeabi_uidiv - ldmfd sp!, {r1, r2, ip, lr} - mul r3, r0, r2 - sub r1, r1, r3 - mov pc, lr - -ENDPROC(__aeabi_uidivmod) - diff --git a/arch/arm/lib/_ashldi3.S b/arch/arm/lib/_ashldi3.S deleted file mode 100644 index e1c1bf3..0000000 --- a/arch/arm/lib/_ashldi3.S +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 - Free Software Foundation, Inc. - -This file 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, or (at your option) any -later version. - -In addition to the permissions in the GNU General Public License, the -Free Software Foundation gives you unlimited permission to link the -compiled version of this file into combinations with other programs, -and to distribute those combinations without any restriction coming -from the use of this file. (The General Public License restrictions -do apply in other respects; for example, they cover modification of -the file, and distribution when not linked into a combine -executable.) - -This file 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; see the file COPYING. If not, write to -the Free Software Foundation, 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ - - -#ifdef __ARMEB__ -#define al r1 -#define ah r0 -#else -#define al r0 -#define ah r1 -#endif - - .section .text.__ashldi3 - -.globl __ashldi3 -__ashldi3: -.globl __aeabi_llsl -__aeabi_llsl: - - subs r3, r2, #32 - rsb ip, r2, #32 - movmi ah, ah, lsl r2 - movpl ah, al, lsl r3 - orrmi ah, ah, al, lsr ip - mov al, al, lsl r2 - mov pc, lr diff --git a/arch/arm/lib/_ashrdi3.S b/arch/arm/lib/_ashrdi3.S deleted file mode 100644 index e631554..0000000 --- a/arch/arm/lib/_ashrdi3.S +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 - Free Software Foundation, Inc. - -This file 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, or (at your option) any -later version. - -In addition to the permissions in the GNU General Public License, the -Free Software Foundation gives you unlimited permission to link the -compiled version of this file into combinations with other programs, -and to distribute those combinations without any restriction coming -from the use of this file. (The General Public License restrictions -do apply in other respects; for example, they cover modification of -the file, and distribution when not linked into a combine -executable.) - -This file 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; see the file COPYING. If not, write to -the Free Software Foundation, 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ - - -#ifdef __ARMEB__ -#define al r1 -#define ah r0 -#else -#define al r0 -#define ah r1 -#endif - - .section .text.__ashrdi3 - -.globl __ashrdi3 -__ashrdi3: -.globl __aeabi_lasr -__aeabi_lasr: - - subs r3, r2, #32 - rsb ip, r2, #32 - movmi al, al, lsr r2 - movpl al, ah, asr r3 - orrmi al, al, ah, lsl ip - mov ah, ah, asr r2 - mov pc, lr diff --git a/arch/arm/lib/_divsi3.S b/arch/arm/lib/_divsi3.S deleted file mode 100644 index 2fbb49d..0000000 --- a/arch/arm/lib/_divsi3.S +++ /dev/null @@ -1,144 +0,0 @@ - -.macro ARM_DIV_BODY dividend, divisor, result, curbit - -#if __LINUX_ARM_ARCH__ >= 5 - - clz \curbit, \divisor - clz \result, \dividend - sub \result, \curbit, \result - mov \curbit, #1 - mov \divisor, \divisor, lsl \result - mov \curbit, \curbit, lsl \result - mov \result, #0 - -#else - - @ Initially shift the divisor left 3 bits if possible, - @ set curbit accordingly. This allows for curbit to be located - @ at the left end of each 4 bit nibbles in the division loop - @ to save one loop in most cases. - tst \divisor, #0xe0000000 - moveq \divisor, \divisor, lsl #3 - moveq \curbit, #8 - movne \curbit, #1 - - @ Unless the divisor is very big, shift it up in multiples of - @ four bits, since this is the amount of unwinding in the main - @ division loop. Continue shifting until the divisor is - @ larger than the dividend. -1: cmp \divisor, #0x10000000 - cmplo \divisor, \dividend - movlo \divisor, \divisor, lsl #4 - movlo \curbit, \curbit, lsl #4 - blo 1b - - @ For very big divisors, we must shift it a bit at a time, or - @ we will be in danger of overflowing. -1: cmp \divisor, #0x80000000 - cmplo \divisor, \dividend - movlo \divisor, \divisor, lsl #1 - movlo \curbit, \curbit, lsl #1 - blo 1b - - mov \result, #0 - -#endif - - @ Division loop -1: cmp \dividend, \divisor - subhs \dividend, \dividend, \divisor - orrhs \result, \result, \curbit - cmp \dividend, \divisor, lsr #1 - subhs \dividend, \dividend, \divisor, lsr #1 - orrhs \result, \result, \curbit, lsr #1 - cmp \dividend, \divisor, lsr #2 - subhs \dividend, \dividend, \divisor, lsr #2 - orrhs \result, \result, \curbit, lsr #2 - cmp \dividend, \divisor, lsr #3 - subhs \dividend, \dividend, \divisor, lsr #3 - orrhs \result, \result, \curbit, lsr #3 - cmp \dividend, #0 @ Early termination? - movnes \curbit, \curbit, lsr #4 @ No, any more bits to do? - movne \divisor, \divisor, lsr #4 - bne 1b - -.endm - -.macro ARM_DIV2_ORDER divisor, order - -#if __LINUX_ARM_ARCH__ >= 5 - - clz \order, \divisor - rsb \order, \order, #31 - -#else - - cmp \divisor, #(1 << 16) - movhs \divisor, \divisor, lsr #16 - movhs \order, #16 - movlo \order, #0 - - cmp \divisor, #(1 << 8) - movhs \divisor, \divisor, lsr #8 - addhs \order, \order, #8 - - cmp \divisor, #(1 << 4) - movhs \divisor, \divisor, lsr #4 - addhs \order, \order, #4 - - cmp \divisor, #(1 << 2) - addhi \order, \order, #3 - addls \order, \order, \divisor, lsr #1 - -#endif - -.endm - - .section .text.__divsi3 - - .align 5 -.globl __divsi3 -__divsi3: -.globl __aeabi_idiv -__aeabi_idiv: - cmp r1, #0 - eor ip, r0, r1 @ save the sign of the result. - beq Ldiv0 - rsbmi r1, r1, #0 @ loops below use unsigned. - subs r2, r1, #1 @ division by 1 or -1 ? - beq 10f - movs r3, r0 - rsbmi r3, r0, #0 @ positive dividend value - cmp r3, r1 - bls 11f - tst r1, r2 @ divisor is power of 2 ? - beq 12f - - ARM_DIV_BODY r3, r1, r0, r2 - - cmp ip, #0 - rsbmi r0, r0, #0 - mov pc, lr - -10: teq ip, r0 @ same sign ? - rsbmi r0, r0, #0 - mov pc, lr - -11: movlo r0, #0 - moveq r0, ip, asr #31 - orreq r0, r0, #1 - mov pc, lr - -12: ARM_DIV2_ORDER r1, r2 - - cmp ip, #0 - mov r0, r3, lsr r2 - rsbmi r0, r0, #0 - mov pc, lr - -Ldiv0: - - str lr, [sp, #-4]! - bl __div0 - mov r0, #0 @ About as wrong as it could be. - ldr pc, [sp], #4 diff --git a/arch/arm/lib/_lshrdi3.S b/arch/arm/lib/_lshrdi3.S deleted file mode 100644 index 71e7f3e..0000000 --- a/arch/arm/lib/_lshrdi3.S +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 - Free Software Foundation, Inc. - -This file 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, or (at your option) any -later version. - -In addition to the permissions in the GNU General Public License, the -Free Software Foundation gives you unlimited permission to link the -compiled version of this file into combinations with other programs, -and to distribute those combinations without any restriction coming -from the use of this file. (The General Public License restrictions -do apply in other respects; for example, they cover modification of -the file, and distribution when not linked into a combine -executable.) - -This file 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; see the file COPYING. If not, write to -the Free Software Foundation, 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ - -#ifdef __ARMEB__ -#define al r1 -#define ah r0 -#else -#define al r0 -#define ah r1 -#endif - .section .text.__lshrdi3 - -.globl __lshrdi3 -__lshrdi3: -.globl __aeabi_llsr -__aeabi_llsr: - - subs r3, r2, #32 - rsb ip, r2, #32 - movmi al, al, lsr r2 - movpl al, ah, lsr r3 - orrmi al, al, ah, lsl ip - mov ah, ah, lsr r2 - mov pc, lr - diff --git a/arch/arm/lib/_modsi3.S b/arch/arm/lib/_modsi3.S deleted file mode 100644 index d17f8f0..0000000 --- a/arch/arm/lib/_modsi3.S +++ /dev/null @@ -1,101 +0,0 @@ - - .section .text.__modsi3 - -.macro ARM_MOD_BODY dividend, divisor, order, spare - -#if __LINUX_ARM_ARCH__ >= 5 - - clz \order, \divisor - clz \spare, \dividend - sub \order, \order, \spare - mov \divisor, \divisor, lsl \order - -#else - - mov \order, #0 - - @ Unless the divisor is very big, shift it up in multiples of - @ four bits, since this is the amount of unwinding in the main - @ division loop. Continue shifting until the divisor is - @ larger than the dividend. -1: cmp \divisor, #0x10000000 - cmplo \divisor, \dividend - movlo \divisor, \divisor, lsl #4 - addlo \order, \order, #4 - blo 1b - - @ For very big divisors, we must shift it a bit at a time, or - @ we will be in danger of overflowing. -1: cmp \divisor, #0x80000000 - cmplo \divisor, \dividend - movlo \divisor, \divisor, lsl #1 - addlo \order, \order, #1 - blo 1b - -#endif - - @ Perform all needed substractions to keep only the reminder. - @ Do comparisons in batch of 4 first. - subs \order, \order, #3 @ yes, 3 is intended here - blt 2f - -1: cmp \dividend, \divisor - subhs \dividend, \dividend, \divisor - cmp \dividend, \divisor, lsr #1 - subhs \dividend, \dividend, \divisor, lsr #1 - cmp \dividend, \divisor, lsr #2 - subhs \dividend, \dividend, \divisor, lsr #2 - cmp \dividend, \divisor, lsr #3 - subhs \dividend, \dividend, \divisor, lsr #3 - cmp \dividend, #1 - mov \divisor, \divisor, lsr #4 - subges \order, \order, #4 - bge 1b - - tst \order, #3 - teqne \dividend, #0 - beq 5f - - @ Either 1, 2 or 3 comparison/substractions are left. -2: cmn \order, #2 - blt 4f - beq 3f - cmp \dividend, \divisor - subhs \dividend, \dividend, \divisor - mov \divisor, \divisor, lsr #1 -3: cmp \dividend, \divisor - subhs \dividend, \dividend, \divisor - mov \divisor, \divisor, lsr #1 -4: cmp \dividend, \divisor - subhs \dividend, \dividend, \divisor -5: -.endm - - .align 5 -.globl __modsi3 -__modsi3: - cmp r1, #0 - beq Ldiv0 - rsbmi r1, r1, #0 @ loops below use unsigned. - movs ip, r0 @ preserve sign of dividend - rsbmi r0, r0, #0 @ if negative make positive - subs r2, r1, #1 @ compare divisor with 1 - cmpne r0, r1 @ compare dividend with divisor - moveq r0, #0 - tsthi r1, r2 @ see if divisor is power of 2 - andeq r0, r0, r2 - bls 10f - - ARM_MOD_BODY r0, r1, r2, r3 - -10: cmp ip, #0 - rsbmi r0, r0, #0 - mov pc, lr - - -Ldiv0: - - str lr, [sp, #-4]! - bl __div0 - mov r0, #0 @ About as wrong as it could be. - ldr pc, [sp], #4 diff --git a/arch/arm/lib/_udivsi3.S b/arch/arm/lib/_udivsi3.S deleted file mode 100644 index bc89b27..0000000 --- a/arch/arm/lib/_udivsi3.S +++ /dev/null @@ -1,81 +0,0 @@ -/* # 1 "libgcc1.S" */ -@ libgcc1 routines for ARM cpu. -@ Division routines, written by Richard Earnshaw, (rearnsha@armltd.co.uk) -dividend .req r0 -divisor .req r1 -result .req r2 -curbit .req r3 -/* ip .req r12 */ -/* sp .req r13 */ -/* lr .req r14 */ -/* pc .req r15 */ - .section .text.__udivsi3 - - .globl __udivsi3 - .type __udivsi3 ,function - .globl __aeabi_uidiv - .type __aeabi_uidiv ,function - .align 0 - __udivsi3 : -__aeabi_uidiv : - cmp divisor, #0 - beq Ldiv0 - mov curbit, #1 - mov result, #0 - cmp dividend, divisor - bcc Lgot_result -Loop1: - @ Unless the divisor is very big, shift it up in multiples of - @ four bits, since this is the amount of unwinding in the main - @ division loop. Continue shifting until the divisor is - @ larger than the dividend. - cmp divisor, #0x10000000 - cmpcc divisor, dividend - movcc divisor, divisor, lsl #4 - movcc curbit, curbit, lsl #4 - bcc Loop1 -Lbignum: - @ For very big divisors, we must shift it a bit at a time, or - @ we will be in danger of overflowing. - cmp divisor, #0x80000000 - cmpcc divisor, dividend - movcc divisor, divisor, lsl #1 - movcc curbit, curbit, lsl #1 - bcc Lbignum -Loop3: - @ Test for possible subtractions, and note which bits - @ are done in the result. On the final pass, this may subtract - @ too much from the dividend, but the result will be ok, since the - @ "bit" will have been shifted out at the bottom. - cmp dividend, divisor - subcs dividend, dividend, divisor - orrcs result, result, curbit - cmp dividend, divisor, lsr #1 - subcs dividend, dividend, divisor, lsr #1 - orrcs result, result, curbit, lsr #1 - cmp dividend, divisor, lsr #2 - subcs dividend, dividend, divisor, lsr #2 - orrcs result, result, curbit, lsr #2 - cmp dividend, divisor, lsr #3 - subcs dividend, dividend, divisor, lsr #3 - orrcs result, result, curbit, lsr #3 - cmp dividend, #0 @ Early termination? - movnes curbit, curbit, lsr #4 @ No, any more bits to do? - movne divisor, divisor, lsr #4 - bne Loop3 -Lgot_result: - mov r0, result - mov pc, lr -Ldiv0: - str lr, [sp, #-4]! - bl __div0 (PLT) - mov r0, #0 @ about as wrong as it could be - ldmia sp!, {pc} - .size __udivsi3 , . - __udivsi3 -/* # 235 "libgcc1.S" */ -/* # 320 "libgcc1.S" */ -/* # 421 "libgcc1.S" */ -/* # 433 "libgcc1.S" */ -/* # 456 "libgcc1.S" */ -/* # 500 "libgcc1.S" */ -/* # 580 "libgcc1.S" */ diff --git a/arch/arm/lib/_umodsi3.S b/arch/arm/lib/_umodsi3.S deleted file mode 100644 index 58186e9..0000000 --- a/arch/arm/lib/_umodsi3.S +++ /dev/null @@ -1,89 +0,0 @@ -/* # 1 "libgcc1.S" */ -@ libgcc1 routines for ARM cpu. -@ Division routines, written by Richard Earnshaw, (rearnsha@armltd.co.uk) -/* # 145 "libgcc1.S" */ -dividend .req r0 -divisor .req r1 -overdone .req r2 -curbit .req r3 -/* ip .req r12 */ -/* sp .req r13 */ -/* lr .req r14 */ -/* pc .req r15 */ - .section .text.__umodsi3 - - .globl __umodsi3 - .type __umodsi3 ,function - .align 0 - __umodsi3 : - cmp divisor, #0 - beq Ldiv0 - mov curbit, #1 - cmp dividend, divisor - movcc pc, lr -Loop1: - @ Unless the divisor is very big, shift it up in multiples of - @ four bits, since this is the amount of unwinding in the main - @ division loop. Continue shifting until the divisor is - @ larger than the dividend. - cmp divisor, #0x10000000 - cmpcc divisor, dividend - movcc divisor, divisor, lsl #4 - movcc curbit, curbit, lsl #4 - bcc Loop1 -Lbignum: - @ For very big divisors, we must shift it a bit at a time, or - @ we will be in danger of overflowing. - cmp divisor, #0x80000000 - cmpcc divisor, dividend - movcc divisor, divisor, lsl #1 - movcc curbit, curbit, lsl #1 - bcc Lbignum -Loop3: - @ Test for possible subtractions. On the final pass, this may - @ subtract too much from the dividend, so keep track of which - @ subtractions are done, we can fix them up afterwards... - mov overdone, #0 - cmp dividend, divisor - subcs dividend, dividend, divisor - cmp dividend, divisor, lsr #1 - subcs dividend, dividend, divisor, lsr #1 - orrcs overdone, overdone, curbit, ror #1 - cmp dividend, divisor, lsr #2 - subcs dividend, dividend, divisor, lsr #2 - orrcs overdone, overdone, curbit, ror #2 - cmp dividend, divisor, lsr #3 - subcs dividend, dividend, divisor, lsr #3 - orrcs overdone, overdone, curbit, ror #3 - mov ip, curbit - cmp dividend, #0 @ Early termination? - movnes curbit, curbit, lsr #4 @ No, any more bits to do? - movne divisor, divisor, lsr #4 - bne Loop3 - @ Any subtractions that we should not have done will be recorded in - @ the top three bits of "overdone". Exactly which were not needed - @ are governed by the position of the bit, stored in ip. - @ If we terminated early, because dividend became zero, - @ then none of the below will match, since the bit in ip will not be - @ in the bottom nibble. - ands overdone, overdone, #0xe0000000 - moveq pc, lr @ No fixups needed - tst overdone, ip, ror #3 - addne dividend, dividend, divisor, lsr #3 - tst overdone, ip, ror #2 - addne dividend, dividend, divisor, lsr #2 - tst overdone, ip, ror #1 - addne dividend, dividend, divisor, lsr #1 - mov pc, lr -Ldiv0: - str lr, [sp, #-4]! - bl __div0 (PLT) - mov r0, #0 @ about as wrong as it could be - ldmia sp!, {pc} - .size __umodsi3 , . - __umodsi3 -/* # 320 "libgcc1.S" */ -/* # 421 "libgcc1.S" */ -/* # 433 "libgcc1.S" */ -/* # 456 "libgcc1.S" */ -/* # 500 "libgcc1.S" */ -/* # 580 "libgcc1.S" */ diff --git a/arch/arm/lib/arm.c b/arch/arm/lib/arm.c index 8ac9ff4..6549118 100644 --- a/arch/arm/lib/arm.c +++ b/arch/arm/lib/arm.c @@ -3,7 +3,6 @@ #include #include #include -#include static int arm_mem_malloc_init(void) { diff --git a/arch/arm/lib/armlinux.c b/arch/arm/lib/armlinux.c index f826da6..9927b76 100644 --- a/arch/arm/lib/armlinux.c +++ b/arch/arm/lib/armlinux.c @@ -41,6 +41,7 @@ #include #include #include +#include static struct tag *params; static int armlinux_architecture = 0; @@ -85,9 +86,10 @@ } } -static void setup_commandline_tag(const char *commandline) +static void setup_commandline_tag(const char *commandline, int swap) { const char *p; + size_t words; if (!commandline) return; @@ -102,12 +104,20 @@ if (*p == '\0') return; + words = (strlen(p) + 1 /* NUL */ + 3 /* round up */) >> 2; params->hdr.tag = ATAG_CMDLINE; - params->hdr.size = - (sizeof (struct tag_header) + strlen(p) + 1 + 4) >> 2; + params->hdr.size = (sizeof(struct tag_header) >> 2) + words; strcpy(params->u.cmdline.cmdline, p); +#ifdef CONFIG_BOOT_ENDIANNESS_SWITCH + if (swap) { + u32 *cmd = (u32 *)params->u.cmdline.cmdline; + while (words--) + cmd[words] = swab32(cmd[words]); + } +#endif + params = tag_next(params); } @@ -156,13 +166,13 @@ params->hdr.size = 0; } -static void setup_tags(struct image_data *data) +static void setup_tags(struct image_data *data, int swap) { const char *commandline = getenv("bootargs"); setup_start_tag(); setup_memory_tags(); - setup_commandline_tag(commandline); + setup_commandline_tag(commandline, swap); if (data && data->initrd) setup_initrd_tag (&data->initrd->header); @@ -231,7 +241,7 @@ debug("## Transferring control to Linux (at address 0x%p) ...\n", theKernel); - setup_tags(data); + setup_tags(data, 0); if (relocate_image(data->os, (void *)image_get_load(os_header))) return -1; @@ -290,18 +300,21 @@ #ifdef CONFIG_CMD_BOOTZ struct zimage_header { - u32 unsused[9]; + u32 unused[9]; u32 magic; u32 start; u32 end; }; +#define ZIMAGE_MAGIC 0x016F2818 + static int do_bootz(struct command *cmdtp, int argc, char *argv[]) { void (*theKernel)(int zero, int arch, void *params); - int fd, ret; + int fd, ret, swap = 0; struct zimage_header header; void *zimage; + u32 end; if (argc != 2) { barebox_cmd_usage(cmdtp); @@ -320,27 +333,53 @@ goto err_out; } - if (header.magic != 0x016f2818) { + switch (header.magic) { +#ifdef CONFIG_BOOT_ENDIANNESS_SWITCH + case swab32(ZIMAGE_MAGIC): + swap = 1; + /* fall through */ +#endif + case ZIMAGE_MAGIC: + break; + default: printf("invalid magic 0x%08x\n", header.magic); goto err_out; } - zimage = xmalloc(header.end); + end = header.end; + + if (swap) + end = swab32(end); + + zimage = xmalloc(end); memcpy(zimage, &header, sizeof(header)); - ret = read(fd, zimage + sizeof(header), header.end - sizeof(header)); - if (ret < header.end - sizeof(header)) { + ret = read(fd, zimage + sizeof(header), end - sizeof(header)); + if (ret < end - sizeof(header)) { printf("could not read %s\n", argv[1]); goto err_out1; } + if (swap) { + void *ptr; + for (ptr = zimage; ptr < zimage + end; ptr += 4) + *(u32 *)ptr = swab32(*(u32 *)ptr); + } + theKernel = zimage; - printf("loaded zImage from %s with size %d\n", argv[1], header.end); + printf("loaded zImage from %s with size %d\n", argv[1], end); - setup_tags(NULL); + setup_tags(NULL, swap); shutdown_barebox(); + if (swap) { + u32 reg; + __asm__ __volatile__("mrc p15, 0, %0, c1, c0" : "=r" (reg)); + reg ^= CR_B; /* swap big-endian flag */ + __asm__ __volatile__("mcr p15, 0, %0, c1, c0" :: "r" (reg)); + } + theKernel(0, armlinux_architecture, armlinux_bootparams); return 0; @@ -382,7 +421,7 @@ if (!theKernel) theKernel = (void *)simple_strtoul(argv[1], NULL, 0); - setup_tags(NULL); + setup_tags(NULL, 0); shutdown_barebox(); theKernel(0, armlinux_architecture, armlinux_bootparams); diff --git a/arch/arm/lib/ashldi3.S b/arch/arm/lib/ashldi3.S new file mode 100644 index 0000000..638deb1 --- /dev/null +++ b/arch/arm/lib/ashldi3.S @@ -0,0 +1,53 @@ +/* Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 + Free Software Foundation, Inc. + +This file 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, or (at your option) any +later version. + +In addition to the permissions in the GNU General Public License, the +Free Software Foundation gives you unlimited permission to link the +compiled version of this file into combinations with other programs, +and to distribute those combinations without any restriction coming +from the use of this file. (The General Public License restrictions +do apply in other respects; for example, they cover modification of +the file, and distribution when not linked into a combine +executable.) + +This file 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; see the file COPYING. If not, write to +the Free Software Foundation, 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ + + +#include + +#ifdef __ARMEB__ +#define al r1 +#define ah r0 +#else +#define al r0 +#define ah r1 +#endif + +ENTRY(__ashldi3) +ENTRY(__aeabi_llsl) + + subs r3, r2, #32 + rsb ip, r2, #32 + movmi ah, ah, lsl r2 + movpl ah, al, lsl r3 + ARM( orrmi ah, ah, al, lsr ip ) + THUMB( lsrmi r3, al, ip ) + THUMB( orrmi ah, ah, r3 ) + mov al, al, lsl r2 + mov pc, lr + +ENDPROC(__ashldi3) +ENDPROC(__aeabi_llsl) diff --git a/arch/arm/lib/ashrdi3.S b/arch/arm/lib/ashrdi3.S new file mode 100644 index 0000000..015e8aa --- /dev/null +++ b/arch/arm/lib/ashrdi3.S @@ -0,0 +1,53 @@ +/* Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 + Free Software Foundation, Inc. + +This file 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, or (at your option) any +later version. + +In addition to the permissions in the GNU General Public License, the +Free Software Foundation gives you unlimited permission to link the +compiled version of this file into combinations with other programs, +and to distribute those combinations without any restriction coming +from the use of this file. (The General Public License restrictions +do apply in other respects; for example, they cover modification of +the file, and distribution when not linked into a combine +executable.) + +This file 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; see the file COPYING. If not, write to +the Free Software Foundation, 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ + + +#include + +#ifdef __ARMEB__ +#define al r1 +#define ah r0 +#else +#define al r0 +#define ah r1 +#endif + +ENTRY(__ashrdi3) +ENTRY(__aeabi_lasr) + + subs r3, r2, #32 + rsb ip, r2, #32 + movmi al, al, lsr r2 + movpl al, ah, asr r3 + ARM( orrmi al, al, ah, lsl ip ) + THUMB( lslmi r3, ah, ip ) + THUMB( orrmi al, al, r3 ) + mov ah, ah, asr r2 + mov pc, lr + +ENDPROC(__ashrdi3) +ENDPROC(__aeabi_lasr) diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S index 5bee0a1..cc74b2f 100644 --- a/arch/arm/lib/barebox.lds.S +++ b/arch/arm/lib/barebox.lds.S @@ -75,5 +75,6 @@ . = ALIGN(4); __bss_start = .; .bss : { *(.bss*) } + __bss_stop = .; _end = .; } diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S new file mode 100644 index 0000000..5143e90 --- /dev/null +++ b/arch/arm/lib/lib1funcs.S @@ -0,0 +1,348 @@ +/* + * linux/arch/arm/lib/lib1funcs.S: Optimized ARM division routines + * + * Author: Nicolas Pitre + * - contributed to gcc-3.4 on Sep 30, 2003 + * - adapted for the Linux kernel on Oct 2, 2003 + */ + +/* Copyright 1995, 1996, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. + +This file 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, or (at your option) any +later version. + +In addition to the permissions in the GNU General Public License, the +Free Software Foundation gives you unlimited permission to link the +compiled version of this file into combinations with other programs, +and to distribute those combinations without any restriction coming +from the use of this file. (The General Public License restrictions +do apply in other respects; for example, they cover modification of +the file, and distribution when not linked into a combine +executable.) + +This file 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; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +#include +#include + + +.macro ARM_DIV_BODY dividend, divisor, result, curbit + +#if __LINUX_ARM_ARCH__ >= 5 + + clz \curbit, \divisor + clz \result, \dividend + sub \result, \curbit, \result + mov \curbit, #1 + mov \divisor, \divisor, lsl \result + mov \curbit, \curbit, lsl \result + mov \result, #0 + +#else + + @ Initially shift the divisor left 3 bits if possible, + @ set curbit accordingly. This allows for curbit to be located + @ at the left end of each 4 bit nibbles in the division loop + @ to save one loop in most cases. + tst \divisor, #0xe0000000 + moveq \divisor, \divisor, lsl #3 + moveq \curbit, #8 + movne \curbit, #1 + + @ Unless the divisor is very big, shift it up in multiples of + @ four bits, since this is the amount of unwinding in the main + @ division loop. Continue shifting until the divisor is + @ larger than the dividend. +1: cmp \divisor, #0x10000000 + cmplo \divisor, \dividend + movlo \divisor, \divisor, lsl #4 + movlo \curbit, \curbit, lsl #4 + blo 1b + + @ For very big divisors, we must shift it a bit at a time, or + @ we will be in danger of overflowing. +1: cmp \divisor, #0x80000000 + cmplo \divisor, \dividend + movlo \divisor, \divisor, lsl #1 + movlo \curbit, \curbit, lsl #1 + blo 1b + + mov \result, #0 + +#endif + + @ Division loop +1: cmp \dividend, \divisor + subhs \dividend, \dividend, \divisor + orrhs \result, \result, \curbit + cmp \dividend, \divisor, lsr #1 + subhs \dividend, \dividend, \divisor, lsr #1 + orrhs \result, \result, \curbit, lsr #1 + cmp \dividend, \divisor, lsr #2 + subhs \dividend, \dividend, \divisor, lsr #2 + orrhs \result, \result, \curbit, lsr #2 + cmp \dividend, \divisor, lsr #3 + subhs \dividend, \dividend, \divisor, lsr #3 + orrhs \result, \result, \curbit, lsr #3 + cmp \dividend, #0 @ Early termination? + movnes \curbit, \curbit, lsr #4 @ No, any more bits to do? + movne \divisor, \divisor, lsr #4 + bne 1b + +.endm + + +.macro ARM_DIV2_ORDER divisor, order + +#if __LINUX_ARM_ARCH__ >= 5 + + clz \order, \divisor + rsb \order, \order, #31 + +#else + + cmp \divisor, #(1 << 16) + movhs \divisor, \divisor, lsr #16 + movhs \order, #16 + movlo \order, #0 + + cmp \divisor, #(1 << 8) + movhs \divisor, \divisor, lsr #8 + addhs \order, \order, #8 + + cmp \divisor, #(1 << 4) + movhs \divisor, \divisor, lsr #4 + addhs \order, \order, #4 + + cmp \divisor, #(1 << 2) + addhi \order, \order, #3 + addls \order, \order, \divisor, lsr #1 + +#endif + +.endm + + +.macro ARM_MOD_BODY dividend, divisor, order, spare + +#if __LINUX_ARM_ARCH__ >= 5 + + clz \order, \divisor + clz \spare, \dividend + sub \order, \order, \spare + mov \divisor, \divisor, lsl \order + +#else + + mov \order, #0 + + @ Unless the divisor is very big, shift it up in multiples of + @ four bits, since this is the amount of unwinding in the main + @ division loop. Continue shifting until the divisor is + @ larger than the dividend. +1: cmp \divisor, #0x10000000 + cmplo \divisor, \dividend + movlo \divisor, \divisor, lsl #4 + addlo \order, \order, #4 + blo 1b + + @ For very big divisors, we must shift it a bit at a time, or + @ we will be in danger of overflowing. +1: cmp \divisor, #0x80000000 + cmplo \divisor, \dividend + movlo \divisor, \divisor, lsl #1 + addlo \order, \order, #1 + blo 1b + +#endif + + @ Perform all needed substractions to keep only the reminder. + @ Do comparisons in batch of 4 first. + subs \order, \order, #3 @ yes, 3 is intended here + blt 2f + +1: cmp \dividend, \divisor + subhs \dividend, \dividend, \divisor + cmp \dividend, \divisor, lsr #1 + subhs \dividend, \dividend, \divisor, lsr #1 + cmp \dividend, \divisor, lsr #2 + subhs \dividend, \dividend, \divisor, lsr #2 + cmp \dividend, \divisor, lsr #3 + subhs \dividend, \dividend, \divisor, lsr #3 + cmp \dividend, #1 + mov \divisor, \divisor, lsr #4 + subges \order, \order, #4 + bge 1b + + tst \order, #3 + teqne \dividend, #0 + beq 5f + + @ Either 1, 2 or 3 comparison/substractions are left. +2: cmn \order, #2 + blt 4f + beq 3f + cmp \dividend, \divisor + subhs \dividend, \dividend, \divisor + mov \divisor, \divisor, lsr #1 +3: cmp \dividend, \divisor + subhs \dividend, \dividend, \divisor + mov \divisor, \divisor, lsr #1 +4: cmp \dividend, \divisor + subhs \dividend, \dividend, \divisor +5: +.endm + + +ENTRY(__udivsi3) +ENTRY(__aeabi_uidiv) + + subs r2, r1, #1 + moveq pc, lr + bcc Ldiv0 + cmp r0, r1 + bls 11f + tst r1, r2 + beq 12f + + ARM_DIV_BODY r0, r1, r2, r3 + + mov r0, r2 + mov pc, lr + +11: moveq r0, #1 + movne r0, #0 + mov pc, lr + +12: ARM_DIV2_ORDER r1, r2 + + mov r0, r0, lsr r2 + mov pc, lr + +ENDPROC(__udivsi3) +ENDPROC(__aeabi_uidiv) + +ENTRY(__umodsi3) + + subs r2, r1, #1 @ compare divisor with 1 + bcc Ldiv0 + cmpne r0, r1 @ compare dividend with divisor + moveq r0, #0 + tsthi r1, r2 @ see if divisor is power of 2 + andeq r0, r0, r2 + movls pc, lr + + ARM_MOD_BODY r0, r1, r2, r3 + + mov pc, lr + +ENDPROC(__umodsi3) + +ENTRY(__divsi3) +ENTRY(__aeabi_idiv) + + cmp r1, #0 + eor ip, r0, r1 @ save the sign of the result. + beq Ldiv0 + rsbmi r1, r1, #0 @ loops below use unsigned. + subs r2, r1, #1 @ division by 1 or -1 ? + beq 10f + movs r3, r0 + rsbmi r3, r0, #0 @ positive dividend value + cmp r3, r1 + bls 11f + tst r1, r2 @ divisor is power of 2 ? + beq 12f + + ARM_DIV_BODY r3, r1, r0, r2 + + cmp ip, #0 + rsbmi r0, r0, #0 + mov pc, lr + +10: teq ip, r0 @ same sign ? + rsbmi r0, r0, #0 + mov pc, lr + +11: movlo r0, #0 + moveq r0, ip, asr #31 + orreq r0, r0, #1 + mov pc, lr + +12: ARM_DIV2_ORDER r1, r2 + + cmp ip, #0 + mov r0, r3, lsr r2 + rsbmi r0, r0, #0 + mov pc, lr + +ENDPROC(__divsi3) +ENDPROC(__aeabi_idiv) + +ENTRY(__modsi3) + + cmp r1, #0 + beq Ldiv0 + rsbmi r1, r1, #0 @ loops below use unsigned. + movs ip, r0 @ preserve sign of dividend + rsbmi r0, r0, #0 @ if negative make positive + subs r2, r1, #1 @ compare divisor with 1 + cmpne r0, r1 @ compare dividend with divisor + moveq r0, #0 + tsthi r1, r2 @ see if divisor is power of 2 + andeq r0, r0, r2 + bls 10f + + ARM_MOD_BODY r0, r1, r2, r3 + +10: cmp ip, #0 + rsbmi r0, r0, #0 + mov pc, lr + +ENDPROC(__modsi3) + +#ifdef CONFIG_AEABI + +ENTRY(__aeabi_uidivmod) + + stmfd sp!, {r0, r1, ip, lr} + bl __aeabi_uidiv + ldmfd sp!, {r1, r2, ip, lr} + mul r3, r0, r2 + sub r1, r1, r3 + mov pc, lr + +ENDPROC(__aeabi_uidivmod) + +ENTRY(__aeabi_idivmod) + + stmfd sp!, {r0, r1, ip, lr} + bl __aeabi_idiv + ldmfd sp!, {r1, r2, ip, lr} + mul r3, r0, r2 + sub r1, r1, r3 + mov pc, lr + +ENDPROC(__aeabi_idivmod) + +#endif + +Ldiv0: + + str lr, [sp, #-8]! + bl __div0 + mov r0, #0 @ About as wrong as it could be. + ldr pc, [sp], #8 + + diff --git a/arch/arm/lib/lshrdi3.S b/arch/arm/lib/lshrdi3.S new file mode 100644 index 0000000..f83d449 --- /dev/null +++ b/arch/arm/lib/lshrdi3.S @@ -0,0 +1,53 @@ +/* Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 + Free Software Foundation, Inc. + +This file 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, or (at your option) any +later version. + +In addition to the permissions in the GNU General Public License, the +Free Software Foundation gives you unlimited permission to link the +compiled version of this file into combinations with other programs, +and to distribute those combinations without any restriction coming +from the use of this file. (The General Public License restrictions +do apply in other respects; for example, they cover modification of +the file, and distribution when not linked into a combine +executable.) + +This file 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; see the file COPYING. If not, write to +the Free Software Foundation, 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ + + +#include + +#ifdef __ARMEB__ +#define al r1 +#define ah r0 +#else +#define al r0 +#define ah r1 +#endif + +ENTRY(__lshrdi3) +ENTRY(__aeabi_llsr) + + subs r3, r2, #32 + rsb ip, r2, #32 + movmi al, al, lsr r2 + movpl al, ah, lsr r3 + ARM( orrmi al, al, ah, lsl ip ) + THUMB( lslmi r3, ah, ip ) + THUMB( orrmi al, al, r3 ) + mov ah, ah, lsr r2 + mov pc, lr + +ENDPROC(__lshrdi3) +ENDPROC(__aeabi_llsr) diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index 8795293..5df8526 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -175,7 +175,8 @@ bool "Atmel AT91SAM9M10G45-EK Evaluation Kit" select HAVE_NAND_ATMEL_BUSWIDTH_16 help - Select this if you are using Atmel's AT91SAM9M10G45-EK Evaluation Kit. + Select this if you are using Atmel's AT91SAM9M10G45-EK Evaluation Kit + or AT91SAM9G45-EKES or AT91SAM9M10-EKES (for those 2 select the LG LCD) config MACH_PM9G45 @@ -206,4 +207,20 @@ with 2 SD/MMC Slots. This is the case for AT91SAM9G20-EK rev. C and onwards. +choice + prompt "LCD type" + depends on MACH_AT91SAM9M10G45EK + +config LCD_TRULY_TFT1N4633E + bool "truly TFT1N4633-E" + help + Found on AT91SAM9M10G45-EK + +config LCD_LG_LB043WQ1 + bool "LG philips LB043WQ1" + help + Found on AT91SAM9G45-EKES and AT91SAM9M10-EKES + +endchoice + endif diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index d000683..3b2deaf 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -11,3 +11,4 @@ obj-$(CONFIG_NAND_IMX) += nand.o obj-y += speed.o obj-y += devices.o +obj-y += boot.o diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c new file mode 100644 index 0000000..b4bf93b --- /dev/null +++ b/arch/arm/mach-imx/boot.c @@ -0,0 +1,95 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include +#include + +#include +#include + +#if defined(CONFIG_ARCH_IMX25) || defined(CONFIG_ARCH_IMX35) +/* + * Saves the boot source media into the $barebox_loc enviroment variable + * + * This information is useful for barebox init scripts as we can then easily + * use a kernel image stored on the same media that we launch barebox with + * (for example). + * + * imx25 and imx35 can boot into barebox from several media such as + * nand, nor, mmc/sd cards, serial roms. "mmc" is used to represent several + * sources as its impossible to distinguish between them. + * + * Some sources such as serial roms can themselves have 3 different boot + * possibilities (i2c1, i2c2 etc). It is assumed that any board will + * only be using one of these at any one time. + * + * Note also that I suspect that the boot source pins are only sampled at + * power up. + */ +static int imx_boot_save_loc(void) +{ + const char *bareboxloc = NULL; + uint32_t reg; + unsigned int ctrl, type; + + /* [CTRL][TYPE] */ + const char *const locations[4][4] = { + { /* CTRL = WEIM */ + "nor", + NULL, + "onenand", + NULL, + }, { /* CTRL == NAND */ + "nand", + "nand", + "nand", + "nand", + }, { /* CTRL == ATA, (imx35 only) */ + NULL, + NULL, /* might be p-ata */ + NULL, + NULL, + }, { /* CTRL == expansion */ + "mmc", /* note imx25 could also be: movinand, ce-ata */ + NULL, + "i2c", + "spi", + } + }; + + reg = readl(IMX_CCM_BASE + CCM_RCSR); + ctrl = (reg >> CCM_RCSR_MEM_CTRL_SHIFT) & 0x3; + type = (reg >> CCM_RCSR_MEM_TYPE_SHIFT) & 0x3; + + bareboxloc = locations[ctrl][type]; + + if (bareboxloc) { + setenv("barebox_loc", bareboxloc); + export("barebox_loc"); + } + + return 0; +} + +/* + * This can only be called after env_push_context() has been called + * so it is a late_initcall. + */ +late_initcall(imx_boot_save_loc); + +#endif diff --git a/arch/arm/mach-imx/include/mach/imx25-regs.h b/arch/arm/mach-imx/include/mach/imx25-regs.h index ac590d9..78ec0cd 100644 --- a/arch/arm/mach-imx/include/mach/imx25-regs.h +++ b/arch/arm/mach-imx/include/mach/imx25-regs.h @@ -79,6 +79,9 @@ #define PDR0_AUTO_CON (1 << 0) #define PDR0_PER_SEL (1 << 26) +#define CCM_RCSR_MEM_CTRL_SHIFT 30 +#define CCM_RCSR_MEM_TYPE_SHIFT 28 + /* * Adresses and ranges of the external chip select lines */ diff --git a/arch/arm/mach-imx/include/mach/imx35-regs.h b/arch/arm/mach-imx/include/mach/imx35-regs.h index 75825e5..280d075 100644 --- a/arch/arm/mach-imx/include/mach/imx35-regs.h +++ b/arch/arm/mach-imx/include/mach/imx35-regs.h @@ -79,6 +79,9 @@ #define CCM_CGR1_SDHC1_SHIFT 26 #define CCM_CGR2_USB_SHIFT 22 +#define CCM_RCSR_MEM_CTRL_SHIFT 25 +#define CCM_RCSR_MEM_TYPE_SHIFT 23 + #define PDR0_AUTO_MUX_DIV(x) (((x) & 0x7) << 9) #define PDR0_CCM_PER_AHB(x) (((x) & 0x7) << 12) #define PDR0_CON_MUX_DIV(x) (((x) & 0xf) << 16) diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig new file mode 100644 index 0000000..f9cefaf --- /dev/null +++ b/arch/arm/mach-mxs/Kconfig @@ -0,0 +1,85 @@ +if ARCH_MXS + +config ARCH_TEXT_BASE + hex + default 0x41000000 if MACH_MX23EVK + default 0x42000000 if MACH_CHUMBY + default 0x47000000 if MACH_TX28 + +config BOARDINFO + default "Freescale i.MX23-EVK" if MACH_MX23EVK + default "Chumby Falconwing" if MACH_CHUMBY + default "Karo TX28" if MACH_TX28 + +comment "Freescale i.MX System-on-Chip" + +choice + prompt "Freescale i.MX Processor" + +config ARCH_IMX23 + bool "i.MX23" + select CPU_ARM926T + +config ARCH_IMX28 + bool "i.MX28" + select CPU_ARM926T + select ARCH_HAS_FEC_IMX + +endchoice + +if ARCH_IMX23 + +choice + prompt "i.MX23 Board Type" + +config MACH_MX23EVK + bool "mx23-evk" + help + Say Y here if you are using the Freescale i.MX23-EVK board + +config MACH_CHUMBY + bool "Chumby Falconwing" + select HAVE_MMU + help + Say Y here if you are using the "chumby one" aka falconwing from + Chumby Industries + +endchoice + +endif + +if ARCH_IMX28 + +choice + prompt "i.MX28 Board Type" + +config MACH_TX28 + bool "KARO tx28" + select HAVE_MMU + help + Say Y here if you are using the KARO TX28 CPU module. + +endchoice + +endif + +menu "Board specific settings " + +if MACH_TX28 + +choice + prompt "TX28 Base Board Type" + +config MACH_TX28STK5 + bool "TX28-stk5" + help + Select this entry if you are running the TX28 CPU module on the + KARO TX28 Starterkit5. + +endchoice + +endif + +endmenu + +endif diff --git a/arch/arm/mach-mxs/Makefile b/arch/arm/mach-mxs/Makefile new file mode 100644 index 0000000..f70a994 --- /dev/null +++ b/arch/arm/mach-mxs/Makefile @@ -0,0 +1,4 @@ +obj-y += imx.o iomux-imx.o reset-imx.o +obj-$(CONFIG_DRIVER_VIDEO_STM) += imx_lcd_clk.o +obj-$(CONFIG_ARCH_IMX23) += speed-imx23.o clocksource-imx23.o usb.o +obj-$(CONFIG_ARCH_IMX28) += speed-imx28.o clocksource-imx28.o diff --git a/arch/arm/mach-mxs/clocksource-imx23.c b/arch/arm/mach-mxs/clocksource-imx23.c new file mode 100644 index 0000000..f7c94c1 --- /dev/null +++ b/arch/arm/mach-mxs/clocksource-imx23.c @@ -0,0 +1,82 @@ +/* + * (C) Copyright 2010 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. + * + * 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 +#include +#include +#include +#include +#include +#include + +#define TIMROTCTRL 0x00 +#define TIMCTRL1 0x40 +#define TIMCTRL1_SET 0x44 +#define TIMCTRL1_CLR 0x48 +#define TIMCTRL1_TOG 0x4c +# define TIMCTRL_RELOAD (1 << 6) +# define TIMCTRL_UPDATE (1 << 7) +# define TIMCTRL_PRESCALE(x) ((x & 0x3) << 4) +# define TIMCTRL_SELECT(x) (x & 0xf) +#define TIMCOUNT1 0x50 + +static const unsigned long timer_base = IMX_TIM1_BASE; + +#define CLOCK_TICK_RATE (32000) + +static uint64_t imx23_clocksource_read(void) +{ + /* only the upper bits are the valid */ + return ~(readl(timer_base + TIMCOUNT1) >> 16); +} + +static struct clocksource cs = { + .read = imx23_clocksource_read, + .mask = CLOCKSOURCE_MASK(16), + .shift = 10, +}; + +static int imx23_clocksource_clock_change(struct notifier_block *nb, unsigned long event, void *data) +{ + cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE/*imx_get_xclk()*/, cs.shift); + return 0; +} + +static struct notifier_block imx23_clock_notifier = { + .notifier_call = imx23_clocksource_clock_change, +}; + +static int clocksource_init(void) +{ + /* enable the whole timer block */ + writel(0x3e000000, timer_base + TIMROTCTRL); + /* setup general purpose timer 1 */ + writel(0x00000000, timer_base + TIMCTRL1); + writel(TIMCTRL_UPDATE, timer_base + TIMCTRL1); + writel(0x0000ffff, timer_base + TIMCOUNT1); + + writel(TIMCTRL_UPDATE | TIMCTRL_RELOAD | TIMCTRL_PRESCALE(0) | TIMCTRL_SELECT(8), timer_base + TIMCTRL1); + cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE/*imx_get_xclk()*/, cs.shift); + init_clock(&cs); + + clock_register_client(&imx23_clock_notifier); + return 0; +} + +core_initcall(clocksource_init); diff --git a/arch/arm/mach-mxs/clocksource-imx28.c b/arch/arm/mach-mxs/clocksource-imx28.c new file mode 100644 index 0000000..15ae951 --- /dev/null +++ b/arch/arm/mach-mxs/clocksource-imx28.c @@ -0,0 +1,73 @@ +/* + * (C) Copyright 2010 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 +#include +#include +#include +#include +#include +#include + +#define TIMROTCTRL 0x00 +# define TIMROTCTRL_SFTRST +# define TIMROTCTRL_CLKGATE +# define TIMROTCTRL_DIVIDER(x) ((x & 0x3f) << 16) + +#define TIMCTRL1 0x60 +#define TIMCTRL1_SET 0x64 +#define TIMCTRL1_CLR 0x68 +#define TIMCTRL1_TOG 0x6c +# define TIMCTRL_RELOAD (1 << 6) +# define TIMCTRL_UPDATE (1 << 7) +# define TIMCTRL_PRESCALE(x) ((x & 0x3) << 4) +# define TIMCTRL_SELECT(x) (x & 0xf) +#define TIMCOUNT1 0x70 +#define TIMFIX1 0x80 + +static const void __iomem * timer_base = (void *)IMX_TIM1_BASE; + +/* we are using the 32 kHz reference */ +#define CLOCK_TICK_RATE 32000 + +static uint64_t imx28_clocksource_read(void) +{ + return ~(readl(timer_base + TIMCOUNT1)); +} + +static struct clocksource imx28_cs = { + .read = imx28_clocksource_read, + .mask = CLOCKSOURCE_MASK(32), + .shift = 17, +}; + +static int imx28_clocksource_init(void) +{ + /* enable the whole timer block */ + writel(0x00000000, timer_base + TIMROTCTRL); + /* setup start value of the general purpose timer */ + writel(0x00000000, timer_base + TIMCTRL1); + writel(TIMCTRL_UPDATE, timer_base + TIMCTRL1); + /* setup the reload value of the general purpose timer */ + writel(0xffffffff, timer_base + TIMFIX1); + + writel(TIMCTRL_UPDATE | TIMCTRL_RELOAD | TIMCTRL_PRESCALE(0) | + TIMCTRL_SELECT(0xb), timer_base + TIMCTRL1); + imx28_cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE, imx28_cs.shift); + init_clock(&imx28_cs); + + return 0; +} + +core_initcall(imx28_clocksource_init); diff --git a/arch/arm/mach-mxs/imx.c b/arch/arm/mach-mxs/imx.c new file mode 100644 index 0000000..14a4249 --- /dev/null +++ b/arch/arm/mach-mxs/imx.c @@ -0,0 +1,35 @@ +/* + * (C) Copyright 2010 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. + * + * 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 +#include + +extern void imx_dump_clocks(void); + +static int do_clocks(struct command *cmdtp, int argc, char *argv[]) +{ + imx_dump_clocks(); + + return 0; +} + +BAREBOX_CMD_START(dump_clocks) + .cmd = do_clocks, + .usage = "show clock frequencies", +BAREBOX_CMD_END diff --git a/arch/arm/mach-mxs/imx_lcd_clk.c b/arch/arm/mach-mxs/imx_lcd_clk.c new file mode 100644 index 0000000..65bfc6e --- /dev/null +++ b/arch/arm/mach-mxs/imx_lcd_clk.c @@ -0,0 +1,150 @@ +/* + * (C) Copyright 2010 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 +#include +#include +#include +#include + +#ifdef CONFIG_ARCH_IMX23 + +# define HW_CLKCTRL_DIS_LCDIF 0x060 +# define CLKCTRL_DIS_LCDIF_GATE (1 << 31) +# define CLKCTRL_DIS_LCDIF_BUSY (1 << 29) +# define MASK_DIS_LCDIF_DIV 0xfff +# define SET_DIS_LCDIF_DIV(x) ((x) & MASK_DIS_LCDIF_DIV) +# define GET_DIS_LCDIF_DIV(x) ((x) & MASK_DIS_LCDIF_DIV) + +# define HW_CLKCTRL_FRAC 0xf0 +# define MASK_PIXFRAC 0x3f +# define GET_PIXFRAC(x) (((x) >> 16) & MASK_PIXFRAC) +# define SET_PIXFRAC(x) (((x) & MASK_PIXFRAC) << 16) +# define CLKCTRL_FRAC_CLKGATEPIX (1 << 23) + +# define HW_CLKCTRL_CLKSEQ 0x110 +# define CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF (1 << 1) + +#endif + +#ifdef CONFIG_ARCH_IMX28 + +# define HW_CLKCTRL_DIS_LCDIF 0x120 +# define CLKCTRL_DIS_LCDIF_GATE (1 << 31) +# define CLKCTRL_DIS_LCDIF_BUSY (1 << 29) +# define MASK_DIS_LCDIF_DIV 0x1fff +# define SET_DIS_LCDIF_DIV(x) ((x) & MASK_DIS_LCDIF_DIV) +# define GET_DIS_LCDIF_DIV(x) ((x) & MASK_DIS_LCDIF_DIV) + +/* note: On i.MX28 this is called 'FRAC1' */ +# define HW_CLKCTRL_FRAC 0x1c0 +# define MASK_PIXFRAC 0x3f +# define GET_PIXFRAC(x) ((x) & MASK_PIXFRAC) +# define SET_PIXFRAC(x) ((x) & MASK_PIXFRAC) +# define CLKCTRL_FRAC_CLKGATEPIX (1 << 7) + +# define HW_CLKCTRL_CLKSEQ 0x1d0 +# define CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF (1 << 14) + +#endif + +unsigned imx_get_lcdifclk(void) +{ + unsigned rate = (imx_get_mpllclk() / 1000) * 18U; + unsigned div; + + div = GET_PIXFRAC(readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC)); + if (div != 0U) { + rate /= div; + div = GET_DIS_LCDIF_DIV(readl(IMX_CCM_BASE + + HW_CLKCTRL_DIS_LCDIF)); + if (div != 0U) + rate /= div; + else + pr_debug("LCDIF clock has divisor 0!\n"); + } else + pr_debug("LCDIF clock has frac divisor 0!\n"); + + return rate * 1000; +} + +/* + * The source of the pixel clock can be the external 24 MHz crystal or the + * internal PLL running at 480 MHz. In order to support at least VGA sized + * displays/resolutions this routine forces the PLL as the clock source. + */ +unsigned imx_set_lcdifclk(unsigned nc) +{ + unsigned frac, best_frac = 0, div, best_div = 0, result; + int delta, best_delta = 0xffffff; + unsigned i, parent_rate = imx_get_mpllclk() / 1000; + uint32_t reg; + +#define SH_DIV(NOM, DEN, LSH) ((((NOM) / (DEN)) << (LSH)) + \ + DIV_ROUND_CLOSEST(((NOM) % (DEN)) << (LSH), DEN)) +#define SHIFT 4 + + nc /= 1000; + nc <<= SHIFT; + + for (frac = 18; frac <= 35; ++frac) { + for (div = 1; div <= 255; ++div) { + result = DIV_ROUND_CLOSEST(parent_rate * + SH_DIV(18U, frac, SHIFT), div); + delta = nc - result; + if (abs(delta) < abs(best_delta)) { + best_delta = delta; + best_frac = frac; + best_div = div; + } + } + } + + if (best_delta == 0xffffff) { + pr_debug("Unable to match the pixelclock\n"); + return 0; + } + + pr_debug("Programming PFD=%u,DIV=%u ref_pix=%u MHz PIXCLK=%u kHz\n", + best_frac, best_div, 480 * 18 / best_frac, + 480000 * 18 / best_frac / best_div); + + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC); + reg &= ~SET_PIXFRAC(MASK_PIXFRAC); + reg |= SET_PIXFRAC(best_frac); + writel(reg, IMX_CCM_BASE + HW_CLKCTRL_FRAC); + writel(reg & ~CLKCTRL_FRAC_CLKGATEPIX, IMX_CCM_BASE + HW_CLKCTRL_FRAC); + + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_DIS_LCDIF) & ~MASK_DIS_LCDIF_DIV; + reg &= ~CLKCTRL_DIS_LCDIF_GATE; + reg |= SET_DIS_LCDIF_DIV(best_div); + writel(reg, IMX_CCM_BASE + HW_CLKCTRL_DIS_LCDIF); + + /* Wait for divider update */ + for (i = 0; i < 10000; i++) { + if (!(readl(IMX_CCM_BASE + HW_CLKCTRL_DIS_LCDIF) & + CLKCTRL_DIS_LCDIF_BUSY)) + break; + } + + if (i >= 10000) { + pr_debug("Setting LCD clock failed\n"); + return 0; + } + + writel(CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF, + IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ + BIT_CLR); + + return imx_get_lcdifclk(); +} diff --git a/arch/arm/mach-mxs/include/mach/clock-imx23.h b/arch/arm/mach-mxs/include/mach/clock-imx23.h new file mode 100644 index 0000000..723f343 --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/clock-imx23.h @@ -0,0 +1,28 @@ +/* + * 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. + */ + +#ifndef MACH_CLOCK_IMX23_H +# define MACH_CLOCK_IMX23_H + +unsigned imx_get_mpllclk(void); +unsigned imx_get_emiclk(void); +unsigned imx_get_ioclk(void); +unsigned imx_get_armclk(void); +unsigned imx_get_hclk(void); +unsigned imx_get_xclk(void); +unsigned imx_get_sspclk(unsigned); +unsigned imx_set_sspclk(unsigned, unsigned, int); +unsigned imx_set_ioclk(unsigned); +unsigned imx_set_lcdifclk(unsigned); +unsigned imx_get_lcdifclk(void); + +#endif /* MACH_CLOCK_IMX23_H */ diff --git a/arch/arm/mach-mxs/include/mach/clock-imx28.h b/arch/arm/mach-mxs/include/mach/clock-imx28.h new file mode 100644 index 0000000..45fb043 --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/clock-imx28.h @@ -0,0 +1,31 @@ +/* + * 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. + */ + +#ifndef MACH_CLOCK_IMX28_H +#define MACH_CLOCK_IMX28_H + +unsigned imx_get_mpllclk(void); +unsigned imx_get_emiclk(void); +unsigned imx_get_ioclk(unsigned); +unsigned imx_get_armclk(void); +unsigned imx_get_hclk(void); +unsigned imx_get_xclk(void); +unsigned imx_get_sspclk(unsigned); +unsigned imx_set_sspclk(unsigned, unsigned, int); +unsigned imx_set_ioclk(unsigned, unsigned); +unsigned imx_set_lcdifclk(unsigned); +unsigned imx_get_lcdifclk(void); +unsigned imx_get_fecclk(void); +void imx_enable_enetclk(void); + +#endif /* MACH_CLOCK_IMX28_H */ + diff --git a/arch/arm/mach-mxs/include/mach/clock.h b/arch/arm/mach-mxs/include/mach/clock.h new file mode 100644 index 0000000..bd1fa7c --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/clock.h @@ -0,0 +1,30 @@ +/* + * (C) Copyright 2010 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. + * + * 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 __MACH_CLOCK_H +# define __MACH_CLOCK_H + +#if defined CONFIG_ARCH_IMX23 +# include +#endif +#if defined CONFIG_ARCH_IMX28 +# include +#endif + +#endif /* __MACH_CLOCK_H */ diff --git a/arch/arm/mach-mxs/include/mach/fb.h b/arch/arm/mach-mxs/include/mach/fb.h new file mode 100644 index 0000000..2b6825f --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/fb.h @@ -0,0 +1,52 @@ +/* + * 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. + */ + +#ifndef __MACH_FB_H +# define __MACH_FB_H + +#include + +#define STMLCDIF_8BIT 1 /** pixel data bus to the display is of 8 bit width */ +#define STMLCDIF_16BIT 0 /** pixel data bus to the display is of 16 bit width */ +#define STMLCDIF_18BIT 2 /** pixel data bus to the display is of 18 bit width */ +#define STMLCDIF_24BIT 3 /** pixel data bus to the display is of 24 bit width */ + +/** LC display uses active high data enable signal */ +#define FB_SYNC_DE_HIGH_ACT (1 << 27) +/** LC display will latch its data at clock's rising edge */ +#define FB_SYNC_CLK_INVERT (1 << 28) +/** output RGB digital data inverted */ +#define FB_SYNC_DATA_INVERT (1 << 29) +/** Stop clock if no data is sent (required for passive displays) */ +#define FB_SYNC_CLK_IDLE_DIS (1 << 30) +/** swap RGB to BGR */ +#define FB_SYNC_SWAP_RGB (1 << 31) + +#define USE_LCD_RESET 1 + +struct imx_fb_platformdata { + struct fb_videomode *mode_list; + unsigned mode_cnt; + + unsigned dotclk_delay; /**< refer manual HW_LCDIF_VDCTRL4 register */ + unsigned ld_intf_width; /**< refer STMLCDIF_* macros */ + unsigned bits_per_pixel; + + void *fixed_screen; /**< if != NULL use this as framebuffer memory */ + unsigned fixed_screen_size; /**< framebuffer memory size for fixed_screen */ + + unsigned flags; + void (*enable)(int enable); /**< hook to enable backlight */ +}; + +#endif /* __MACH_FB_H */ + diff --git a/arch/arm/mach-mxs/include/mach/generic.h b/arch/arm/mach-mxs/include/mach/generic.h new file mode 100644 index 0000000..50f25c5 --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/generic.h @@ -0,0 +1,30 @@ +/* + * (C) Copyright 2010 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. + * + * 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 + */ + +#ifdef CONFIG_ARCH_IMX23 +# define cpu_is_mx23() (1) +#else +# define cpu_is_mx23() (0) +#endif + +#ifdef CONFIG_ARCH_IMX28 +# define cpu_is_mx28() (1) +#else +# define cpu_is_mx28() (0) +#endif diff --git a/arch/arm/mach-mxs/include/mach/gpio.h b/arch/arm/mach-mxs/include/mach/gpio.h new file mode 100644 index 0000000..c419926 --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/gpio.h @@ -0,0 +1,38 @@ +/* + * (C) Copyright 2010 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. + * + * 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 __ASM_MACH_GPIO_H +#define __ASM_MACH_GPIO_H + +#include + +#if defined CONFIG_ARCH_IMX23 +# include +#endif +#if defined CONFIG_ARCH_IMX28 +# include +#endif + +void imx_gpio_mode(uint32_t); +void gpio_set_value(unsigned, int); +int gpio_direction_input(unsigned); +int gpio_direction_output(unsigned, int); +int gpio_get_value(unsigned); + +#endif /* __ASM_MACH_GPIO_H */ diff --git a/arch/arm/mach-mxs/include/mach/imx-regs.h b/arch/arm/mach-mxs/include/mach/imx-regs.h new file mode 100644 index 0000000..9b33a06 --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/imx-regs.h @@ -0,0 +1,36 @@ +/* + * (C) Copyright 2010 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. + * + * 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 _IMX_REGS_H +# define _IMX_REGS_H + +/* Note: Some registers do not support this bit change feature! */ +#define BIT_SET 0x04 +#define BIT_CLR 0x08 +#define BIT_TGL 0x0C + +#if defined CONFIG_ARCH_IMX23 +# include +#endif + +#if defined CONFIG_ARCH_IMX28 +# include +#endif + +#endif /* _IMX_REGS_H */ diff --git a/arch/arm/mach-mxs/include/mach/imx23-regs.h b/arch/arm/mach-mxs/include/mach/imx23-regs.h new file mode 100644 index 0000000..cc8c03e --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/imx23-regs.h @@ -0,0 +1,46 @@ +/* + * (C) Copyright 2010 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. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef __ASM_ARCH_MX23_REGS_H +#define __ASM_ARCH_MX23_REGS_H + +/* + * sanity check + */ +#ifndef _IMX_REGS_H +# error "Please do not include directly. Use imx-regs.h instead." +#endif + +#define IMX_MEMORY_BASE 0x40000000 +#define IMX_UART1_BASE 0x8006c000 +#define IMX_UART2_BASE 0x8006e000 +#define IMX_DBGUART_BASE 0x80070000 +#define IMX_TIM1_BASE 0x80068000 +#define IMX_IOMUXC_BASE 0x80018000 +#define IMX_WDT_BASE 0x8005c000 +#define IMX_CCM_BASE 0x80040000 +#define IMX_I2C1_BASE 0x80058000 +#define IMX_SSP1_BASE 0x80010000 +#define IMX_FB_BASE 0x80030000 +#define IMX_SSP2_BASE 0x80034000 +#define IMX_POWER_BASE 0x80044000 +#define IMX_USBPHY_BASE 0x8007c000 +#define IMX_DIGCTL_BASE 0x8001c000 +#define IMX_USB_BASE 0x80080000 + +#endif /* __ASM_ARCH_MX23_REGS_H */ diff --git a/arch/arm/mach-mxs/include/mach/imx28-regs.h b/arch/arm/mach-mxs/include/mach/imx28-regs.h new file mode 100644 index 0000000..0c97c4c --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/imx28-regs.h @@ -0,0 +1,47 @@ +/* + * 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. + */ + +#ifndef __ASM_ARCH_MX28_REGS_H +#define __ASM_ARCH_MX28_REGS_H + +/* + * sanity check + */ +#ifndef _IMX_REGS_H +# error "Please do not include directly. Use imx-regs.h instead." +#endif + +#define IMX_SRAM_BASE 0x00000000 +#define IMX_MEMORY_BASE 0x40000000 + +#define IMX_NFC_BASE 0x8000C000 +#define IMX_SSP0_BASE 0x80010000 +#define IMX_SSP1_BASE 0x80012000 +#define IMX_SSP2_BASE 0x80014000 +#define IMX_SSP3_BASE 0x80016000 +#define IMX_IOMUXC_BASE 0x80018000 +#define IMX_FB_BASE 0x80030000 +#define IMX_CCM_BASE 0x80040000 +#define IMX_WDT_BASE 0x80056000 +#define IMX_I2C0_BASE 0x80058000 +#define IMX_I2C1_BASE 0x8005a000 +#define IMX_TIM1_BASE 0x80068000 +#define IMX_UART0_BASE 0x8006a000 +#define IMX_UART1_BASE 0x8006c000 +#define IMX_UART2_BASE 0x8006e000 +#define IMX_UART3_BASE 0x80070000 +#define IMX_UART4_BASE 0x80072000 +#define IMX_DBGUART_BASE 0x80074000 +#define IMX_FEC0_BASE 0x800F0000 +#define IMX_FEC1_BASE 0x800F4000 + +#endif /* __ASM_ARCH_MX28_REGS_H */ diff --git a/arch/arm/mach-mxs/include/mach/iomux-imx23.h b/arch/arm/mach-mxs/include/mach/iomux-imx23.h new file mode 100644 index 0000000..bebaf56 --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/iomux-imx23.h @@ -0,0 +1,424 @@ +/* + * (C) Copyright 2010 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. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +/* 3322222222221111111111 + * 10987654321098765432109876543210 + * ^^^_ Register Number + * ^^^^____ Bit offset + * ^^________ Function + * ^__________ Drive strength feature present + * ^___________ Pull up / bit keeper present + * ^^____________ Drive strength setting + * ^______________ Pull up / bit keeper setting + * ^_______________ Voltage select present + * ^________________ Voltage selection + * ^____________________ direction if enabled as GPIO (1 = output) + * ^_____________________ initial output value if enabled as GPIO and configured as output + */ +#ifndef __ASM_MACH_IOMUX_H +#define __ASM_MACH_IOMUX_H + +/* control pad's function */ +#define FBIT_SHIFT (3) +#define PORTF(bank,bit) (((bit) << FBIT_SHIFT) | (bank)) +#define GET_PORTF(x) ((x) & 0x7) +#define GET_FBITPOS(x) (((x) >> FBIT_SHIFT) & 0xf) +#define GET_GPIO_NO(x) ((GET_PORTF(x) << 4) + GET_FBITPOS(m)) +#define FUNC_SHIFT 7 +#define FUNC(x) ((x) << FUNC_SHIFT) +#define GET_FUNC(x) (((x) >> FUNC_SHIFT) & 3) +#define IS_GPIO (3) + +/* control pad's GPIO feature if enabled */ +#define GPIO_OUT (1 << 19) +#define GPIO_VALUE(x) ((x) << 20) +#define GPIO_IN (0 << 19) +#define GET_GPIODIR(x) (!!((x) & (1 << 19))) +#define GET_GPIOVAL(x) (!!((x) & (1 << 20))) + +/* control pad's drive strength */ +#define SE (1 << 9) +#define SE_PRESENT(x) (!!((x) & SE)) +#define STRENGTH(x) ((x) << 11) +#define S4MA 0 /* used to define a 4 mA drive strength */ +#define S8MA 1 /* used to define a 8 mA drive strength */ +#define S12MA 2 /* used to define a 12 mA drive strength */ +#define S16MA 3 /* used to define a 16 mA drive strength, not all pads can drive this current! */ +#define GET_STRENGTH(x) (((x) >> 11) & 0x3) + +/* control pad's pull up / bit keeper feature */ +#define PE (1 << 10) +#define PE_PRESENT(x) (!!((x) & PE)) +#define PULLUP(x) ((x) << 13) +#define GET_PULLUP(x) (!!((x) & (1 << 13))) + +/* control pad's voltage feature */ +#define VE (1 << 14) +#define VE_PRESENT(x) (!!((x) & VE)) +#define VE_1_8V (0 << 15) +#define VE_2_5V (0 << 15) /* don't ask my why, RTFM */ +#define GET_VOLTAGE(x) (!!((x) & (1 << 15))) + +/* Bank 0, pins 0 ... 15, GPIO pins 0 ... 15 */ +#define GPMI_D15 (FUNC(0) | PORTF(0, 15) | SE | PE) +#define GPMI_D15_AUART2_TX (FUNC(1) | PORTF(0, 15) | SE | PE) +#define GPMI_D15_GPMI_CE3N (FUNC(2) | PORTF(0, 15) | SE | PE) +#define GPMI_D15_GPIO (FUNC(3) | PORTF(0, 15) | SE | PE) +#define GPMI_D14 (FUNC(0) | PORTF(0, 14) | SE) +#define GPMI_D14_AUART2_RX (FUNC(1) | PORTF(0, 14) | SE) +#define GPMI_D14_GPIO (FUNC(3) | PORTF(0, 14) | SE) +#define GPMI_D13 (FUNC(0) | PORTF(0, 13) | SE) +#define GPMI_D13_LCD_D23 (FUNC(1) | PORTF(0, 13) | SE) +#define GPMI_D13_GPIO (FUNC(3) | PORTF(0, 13) | SE) +#define GPMI_D12 (FUNC(0) | PORTF(0, 12) | SE) +#define GPMI_D12_LCD_D22 (FUNC(1) | PORTF(0, 12) | SE) +#define GPMI_D12_GPIO (FUNC(3) | PORTF(0, 12) | SE) +#define GPMI_D11 (FUNC(0) | PORTF(0, 11) | SE | PE) +#define GPMI_D11_LCD_D21 (FUNC(1) | PORTF(0, 11) | SE | PE) +#define GPMI_D11_SSP1_D7 (FUNC(2) | PORTF(0, 11) | SE | PE) +#define GPMI_D11_GPIO (FUNC(3) | PORTF(0, 11) | SE | PE) +#define GPMI_D10 (FUNC(0) | PORTF(0, 10) | SE | PE) +#define GPMI_D10_LCD_D20 (FUNC(1) | PORTF(0, 10) | SE | PE) +#define GPMI_D10_SSP1_D6 (FUNC(2) | PORTF(0, 10) | SE | PE) +#define GPMI_D10_GPIO (FUNC(3) | PORTF(0, 10) | SE | PE) +#define GPMI_D09 (FUNC(0) | PORTF(0, 9) | SE | PE) +#define GPMI_D09_LCD_D19 (FUNC(1) | PORTF(0, 9) | SE | PE) +#define GPMI_D09_SSP1_D5 (FUNC(2) | PORTF(0, 9) | SE | PE) +#define GPMI_D09_GPIO (FUNC(3) | PORTF(0, 9) | SE | PE) +#define GPMI_D08 (FUNC(0) | PORTF(0, 8) | SE | PE) +#define GPMI_D08_LCD_D18 (FUNC(1) | PORTF(0, 8) | SE | PE) +#define GPMI_D08_SSP1_D4 (FUNC(2) | PORTF(0, 8) | SE | PE) +#define GPMI_D08_GPIO (FUNC(3) | PORTF(0, 8) | SE | PE) +#define GPMI_D07 (FUNC(0) | PORTF(0, 7) | SE | PE) +#define GPMI_D07_LCD_D15 (FUNC(1) | PORTF(0, 7) | SE | PE) +#define GPMI_D07_SSP2_D7 (FUNC(2) | PORTF(0, 7) | SE | PE) +#define GPMI_D07_GPIO (FUNC(3) | PORTF(0, 7) | SE | PE) +#define GPMI_D06 (FUNC(0) | PORTF(0, 6) | SE | PE) +#define GPMI_D06_LCD_D14 (FUNC(1) | PORTF(0, 6) | SE | PE) +#define GPMI_D06_SSP2_D6 (FUNC(2) | PORTF(0, 6) | SE | PE) +#define GPMI_D06_GPIO (FUNC(3) | PORTF(0, 6) | SE | PE) +#define GPMI_D05 (FUNC(0) | PORTF(0, 5) | SE | PE) +#define GPMI_D05_LCD_D13 (FUNC(1) | PORTF(0, 5) | SE | PE) +#define GPMI_D05_SSP2_D5 (FUNC(2) | PORTF(0, 5) | SE | PE) +#define GPMI_D05_GPIO (FUNC(3) | PORTF(0, 5) | SE | PE) +#define GPMI_D04 (FUNC(0) | PORTF(0, 4) | SE | PE) +#define GPMI_D04_LCD_D12 (FUNC(1) | PORTF(0, 4) | SE | PE) +#define GPMI_D04_SSP2_D4 (FUNC(2) | PORTF(0, 4) | SE | PE) +#define GPMI_D04_GPIO (FUNC(3) | PORTF(0, 4) | SE | PE) +#define GPMI_D03 (FUNC(0) | PORTF(0, 3) | SE | PE) +#define GPMI_D03_LCD_D11 (FUNC(1) | PORTF(0, 3) | SE | PE) +#define GPMI_D03_SSP2_D3 (FUNC(2) | PORTF(0, 3) | SE | PE) +#define GPMI_D03_GPIO (FUNC(3) | PORTF(0, 3) | SE | PE) +#define GPMI_D02 (FUNC(0) | PORTF(0, 2) | SE | PE) +#define GPMI_D02_LCD_D10 (FUNC(1) | PORTF(0, 2) | SE | PE) +#define GPMI_D02_SSP2_D2 (FUNC(2) | PORTF(0, 2) | SE | PE) +#define GPMI_D02_GPIO (FUNC(3) | PORTF(0, 2) | SE | PE) +#define GPMI_D01 (FUNC(0) | PORTF(0, 1) | SE | PE) +#define GPMI_D01_LCD_D9 (FUNC(1) | PORTF(0, 1) | SE | PE) +#define GPMI_D01_SSP2_D1 (FUNC(2) | PORTF(0, 1) | SE | PE) +#define GPMI_D01_GPIO (FUNC(3) | PORTF(0, 1) | SE | PE) +#define GPMI_D00 (FUNC(0) | PORTF(0, 0) | SE | PE) +#define GPMI_D00_LCD_D8 (FUNC(1) | PORTF(0, 0) | SE | PE) +#define GPMI_D00_SSP2_D0 (FUNC(2) | PORTF(0, 0) | SE | PE) +#define GPMI_D00_GPIO (FUNC(3) | PORTF(0, 0) | SE | PE) + +/* Bank 0, pins 16 ... 31 GPIO pins 16 ... 31 */ +#define I2C_SDA (FUNC(0) | PORTF(1, 15) | SE) +#define I2C_SDA_GPMI_CE2N (FUNC(1) | PORTF(1, 15) | SE) +#define I2C_SDA_AUART1_RX (FUNC(2) | PORTF(1, 15) | SE) +#define I2C_SDA_GPIO (FUNC(3) | PORTF(1, 15) | SE) +#define I2C_CLK (FUNC(0) | PORTF(1, 14) | SE | PE) +#define I2C_CLK_GPMI_RDY2 (FUNC(1) | PORTF(1, 14) | SE | PE) +#define I2C_CLK_AUART1_TX (FUNC(2) | PORTF(1, 14) | SE | PE) +#define I2C_CLK_GPIO (FUNC(3) | PORTF(1, 14) | SE | PE) +#define AUART1_TX (FUNC(0) | PORTF(1, 13) | SE | PE) +#define AUART1_TX_SSP1_D7 (FUNC(2) | PORTF(1, 13) | SE | PE) +#define AUART1_TX_GPIO (FUNC(3) | PORTF(1, 13) | SE | PE) +#define AUART1_RX (FUNC(0) | PORTF(1, 12) | SE | PE) +#define AUART1_RX_SSP1_D6 (FUNC(2) | PORTF(1, 12) | SE | PE) +#define AUART1_RX_GPIO (FUNC(3) | PORTF(1, 12) | SE | PE) +#define AUART1_RTS (FUNC(0) | PORTF(1, 11) | SE | PE) +#define AUART1_RTS_SSP1_D5 (FUNC(2) | PORTF(1, 11) | SE | PE) +#define AUART1_RTS_GPIO (FUNC(3) | PORTF(1, 11) | SE | PE) +#define AUART1_CTS (FUNC(0) | PORTF(1, 10) | SE | PE) +#define AUART1_CTS_SSP1_D4 (FUNC(2) | PORTF(1, 10) | SE | PE) +#define AUART1_CTS_GPIO (FUNC(3) | PORTF(1, 10) | SE | PE) +#define GPMI_RDN (FUNC(0) | PORTF(1, 9) | SE) +#define GPMI_RDN_GPIO (FUNC(3) | PORTF(1, 9) | SE) +#define GPMI_WRN (FUNC(0) | PORTF(1, 8) | SE) +#define GPMI_WRN_SSP2_SCK (FUNC(2) | PORTF(1, 8) | SE) +#define GPMI_WRN_GPIO (FUNC(3) | PORTF(1, 8) | SE) +#define GPMI_WPM (FUNC(0) | PORTF(1, 7) | SE) +#define GPMI_WPM_GPIO (FUNC(3) | PORTF(1, 7) | SE) +#define GPMI_RDY3 (FUNC(0) | PORTF(1, 6) | SE | PE) +#define GPMI_RDY3_GPIO (FUNC(3) | PORTF(1, 6) | SE | PE) +#define GPMI_RDY2 (FUNC(0) | PORTF(1, 5) | SE | PE) +#define GPMI_RDY2_GPIO (FUNC(3) | PORTF(1, 5) | SE | PE) +#define GPMI_RDY1 (FUNC(0) | PORTF(1, 4) | SE | PE) +#define GPMI_RDY1_SSP2_CMD (FUNC(2) | PORTF(1, 4) | SE | PE) +#define GPMI_RDY1_GPIO (FUNC(3) | PORTF(1, 4) | SE | PE) +#define GPMI_RDY0 (FUNC(0) | PORTF(1, 3) | SE | PE) +#define GPMI_RDY0_SSP2_DETECT (FUNC(2) | PORTF(1, 3) | SE | PE) +#define GPMI_RDY0_GPIO (FUNC(3) | PORTF(1, 3) | SE | PE) +#define GPMI_CE2N (FUNC(0) | PORTF(1, 2) | SE | PE) +#define GPMI_CE2N_GPIO (FUNC(3) | PORTF(1, 2) | SE | PE) +#define GPMI_ALE (FUNC(0) | PORTF(1, 1) | SE) +#define GPMI_ALE_LCD_D17 (FUNC(1) | PORTF(1, 1) | SE) +#define GPMI_ALE_GPIO (FUNC(3) | PORTF(1, 1) | SE) +#define GPMI_CLE (FUNC(0) | PORTF(1, 0) | SE) +#define GPMI_CLE_LCD_D16 (FUNC(1) | PORTF(1, 1) | SE) +#define GPMI_CLE_GPIO (FUNC(3) | PORTF(1, 0) | SE) + +/* Bank 1, pins 0 ... 15 GPIO pins 32 ... 47 */ +#define LCD_D15 (FUNC(0) | PORTF(2, 15) | SE) +#define LCD_D15_ETM_DA7 (FUNC(1) | PORTF(2, 15) | SE) +#define LCD_D15_SAIF1_SDATA1 (FUNC(2) | PORTF(2, 15) | SE) +#define LCD_D15_GPIO (FUNC(3) | PORTF(2, 15) | SE) +#define LCD_D14 (FUNC(0) | PORTF(2, 14) | SE) +#define LCD_D14_ETM_DA6 (FUNC(1) | PORTF(2, 14) | SE) +#define LCD_D14_SAIF1_SDATA2 (FUNC(2) | PORTF(2, 14) | SE) +#define LCD_D14_GPIO (FUNC(3) | PORTF(2, 14) | SE) +#define LCD_D13 (FUNC(0) | PORTF(2, 13) | SE) +#define LCD_D13_ETM_DA5 (FUNC(1) | PORTF(2, 13) | SE) +#define LCD_D13_SAIF2_SDATA2 (FUNC(2) | PORTF(2, 13) | SE) +#define LCD_D13_GPIO (FUNC(3) | PORTF(2, 13) | SE) +#define LCD_D12 (FUNC(0) | PORTF(2, 12) | SE) +#define LCD_D12_ETM_DA4 (FUNC(1) | PORTF(2, 12) | SE) +#define LCD_D12_SAIF2_SDATA1 (FUNC(2) | PORTF(2, 12) | SE) +#define LCD_D12_GPIO (FUNC(3) | PORTF(2, 12) | SE) +#define LCD_D11 (FUNC(0) | PORTF(2, 11) | SE) +#define LCD_D11_ETM_DA3 (FUNC(1) | PORTF(2, 11) | SE) +#define LCD_D11_SAIF_LRCLK (FUNC(2) | PORTF(2, 11) | SE) +#define LCD_D11_GPIO (FUNC(3) | PORTF(2, 11) | SE) +#define LCD_D10 (FUNC(0) | PORTF(2, 10) | SE) +#define LCD_D10_ETM_DA2 (FUNC(1) | PORTF(2, 10) | SE) +#define LCD_D10_SAIF_BITCLK (FUNC(2) | PORTF(2, 10) | SE) +#define LCD_D10_GPIO (FUNC(3) | PORTF(2, 10) | SE) +#define LCD_D9 (FUNC(0) | PORTF(2, 9) | SE) +#define LCD_D9_ETM_DA1 (FUNC(1) | PORTF(2, 9) | SE) +#define LCD_D9_SAIF1_SDATA0 (FUNC(2) | PORTF(2, 9) | SE) +#define LCD_D9_GPIO (FUNC(3) | PORTF(2, 9) | SE) +#define LCD_D8 (FUNC(0) | PORTF(2, 8) | SE) +#define LCD_D8_ETM_DA0 (FUNC(1) | PORTF(2, 8) | SE) +#define LCD_D8_SAIF2_SDATA0 (FUNC(2) | PORTF(2, 8) | SE) +#define LCD_D8_GPIO (FUNC(3) | PORTF(2, 8) | SE) +#define LCD_D7 (FUNC(0) | PORTF(2, 7) | SE) +#define LCD_D7_ETM_DA15 (FUNC(1) | PORTF(2, 7) | SE) +#define LCD_D7_GPIO (FUNC(3) | PORTF(2, 7) | SE) +#define LCD_D6 (FUNC(0) | PORTF(2, 6) | SE) +#define LCD_D6_ETM_DA14 (FUNC(1) | PORTF(2, 6) | SE) +#define LCD_D6_GPIO (FUNC(3) | PORTF(2, 6) | SE) +#define LCD_D5 (FUNC(0) | PORTF(2, 5) | SE) +#define LCD_D5_ETM_DA13 (FUNC(1) | PORTF(2, 5) | SE) +#define LCD_D5_GPIO (FUNC(3) | PORTF(2, 5) | SE) +#define LCD_D4 (FUNC(0) | PORTF(2, 4) | SE) +#define LCD_D4_ETM_DA12 (FUNC(1) | PORTF(2, 4) | SE) +#define LCD_D4_GPIO (FUNC(3) | PORTF(2, 4) | SE) +#define LCD_D3 (FUNC(0) | PORTF(2, 3) | SE) +#define LCD_D3_ETM_DA11 (FUNC(1) | PORTF(2, 3) | SE) +#define LCD_D3_GPIO (FUNC(3) | PORTF(2, 3) | SE) +#define LCD_D2 (FUNC(0) | PORTF(2, 2) | SE) +#define LCD_D2_ETM_DA10 (FUNC(1) | PORTF(2, 2) | SE) +#define LCD_D2_GPIO (FUNC(3) | PORTF(2, 2) | SE) +#define LCD_D1 (FUNC(0) | PORTF(2, 1) | SE) +#define LCD_D1_ETM_DA9 (FUNC(1) | PORTF(2, 1) | SE) +#define LCD_D1_GPIO (FUNC(3) | PORTF(2, 1) | SE) +#define LCD_D0 (FUNC(0) | PORTF(2, 0) | SE) +#define LCD_D0_ETM_DA8 (FUNC(1) | PORTF(2, 0) | SE) +#define LCD_D0_GPIO (FUNC(3) | PORTF(2, 0) | SE) + +/* Bank 1, pins 16 ... 30 GPIO pins 48 ... 63 */ +#define PWM4 (FUNC(0) | PORTF(3, 14) | SE) +#define PWM4_ETM_CLK (FUNC(1) | PORTF(3, 14) | SE) +#define PWM4_AUART1_RTS (FUNC(2) | PORTF(3, 14) | SE) +#define PWM4_GPIO (FUNC(3) | PORTF(3, 14) | SE) +#define PWM3 (FUNC(0) | PORTF(3, 13) | SE) +#define PWM3_ETM_TCTL (FUNC(1) | PORTF(3, 13) | SE) +#define PWM3_AUART1_CTS (FUNC(2) | PORTF(3, 13) | SE) +#define PWM3_GPIO (FUNC(3) | PORTF(3, 13) | SE) +#define PWM2 (FUNC(0) | PORTF(3, 12) | SE | PE) +#define PWM2_GPMI_READY3 (FUNC(1) | PORTF(3, 12) | SE | PE) +#define PWM2_GPIO (FUNC(3) | PORTF(3, 12) | SE | PE) +#define PWM1 (FUNC(0) | PORTF(3, 11) | SE) +#define PWM1_TIMROT2 (FUNC(1) | PORTF(3, 11) | SE) +#define PWM1_DUART_TX (FUNC(2) | PORTF(3, 11) | SE) +#define PWM1_GPIO (FUNC(3) | PORTF(3, 11) | SE) +#define PWM0 (FUNC(0) | PORTF(3, 10) | SE) +#define PWM0_TIMROT1 (FUNC(1) | PORTF(3, 10) | SE) +#define PWM0_DUART_RX (FUNC(2) | PORTF(3, 10) | SE) +#define PWM0_GPIO (FUNC(3) | PORTF(3, 10) | SE) +#define LCD_VSYNC (FUNC(0) | PORTF(3, 9) | SE) +#define LCD_VSYNC_LCD_BUSY (FUNC(1) | PORTF(3, 9) | SE) +#define LCD_VSYNC_GPIO (FUNC(3) | PORTF(3, 9) | SE) +#define LCD_HSYNC (FUNC(0) | PORTF(3, 8) | SE) +#define LCD_HSYNC_I2C_SD (FUNC(1) | PORTF(3, 8) | SE) +#define LCD_HSYNC_GPIO (FUNC(3) | PORTF(3, 8) | SE) +#define LCD_ENABE (FUNC(0) | PORTF(3, 7) | SE) +#define LCD_ENABE_I2C_CLK (FUNC(1) | PORTF(3, 7) | SE) +#define LCD_ENABE_GPIO (FUNC(3) | PORTF(3, 7) | SE) +#define LCD_DOTCLOCK (FUNC(0) | PORTF(3, 6) | SE | PE) +#define LCD_DOTCLOCK_GPMI_READY3 (FUNC(1) | PORTF(3, 6) | SE | PE) +#define LCD_DOTCLOCK_GPIO (FUNC(3) | PORTF(3, 6) | SE | PE) +#define LCD_CS (FUNC(0) | PORTF(3, 5) | SE) +#define LCD_CS_GPIO (FUNC(3) | PORTF(3, 5) | SE) +#define LCD_WR (FUNC(0) | PORTF(3, 4) | SE) +#define LCD_WR_GPIO (FUNC(3) | PORTF(3, 4) | SE) +#define LCD_RS (FUNC(0) | PORTF(3, 3) | SE) +#define LCD_RS_ETM_TCLK (FUNC(1) | PORTF(3, 3) | SE) +#define LCD_RS_GPIO (FUNC(3) | PORTF(3, 3) | SE) +#define LCD_RESET (FUNC(0) | PORTF(3, 2) | SE | PE) +#define LCD_RESET_ETM_TCTL (FUNC(1) | PORTF(3, 2) | SE | PE) +#define LCD_RESET_GPMI_CE3N (FUNC(2) | PORTF(3, 2) | SE | PE) +#define LCD_RESET_GPIO (FUNC(3) | PORTF(3, 2) | SE | PE) +#define LCD_D17 (FUNC(0) | PORTF(3, 1) | SE) +#define LCD_D17_GPIO (FUNC(3) | PORTF(3, 1) | SE) +#define LCD_D16 (FUNC(0) | PORTF(3, 0) | SE) +#define LCD_D16_SAIF_ALT_BITCLK (FUNC(2) | PORTF(3, 0) | SE) +#define LCD_D16_GPIO (FUNC(3) | PORTF(3, 0) | SE) + +/* Bank 2, pins 0 ... 15 GPIO pins 64 ... 79 */ +#define EMI_A6 (FUNC(0) | PORTF(4, 15) | SE | VE) +#define EMI_A6_GPIO (FUNC(3) | PORTF(4, 15) | SE | VE) +#define EMI_A5 (FUNC(0) | PORTF(4, 14) | SE | VE) +#define EMI_A5_GPIO (FUNC(3) | PORTF(4, 14) | SE | VE) +#define EMI_A4 (FUNC(0) | PORTF(4, 13) | SE | VE) +#define EMI_A4_GPIO (FUNC(3) | PORTF(4, 13) | SE | VE) +#define EMI_A3 (FUNC(0) | PORTF(4, 12) | SE | VE) +#define EMI_A3_GPIO (FUNC(3) | PORTF(4, 12) | SE | VE) +#define EMI_A2 (FUNC(0) | PORTF(4, 11) | SE | VE) +#define EMI_A2_GPIO (FUNC(3) | PORTF(4, 11) | SE | VE) +#define EMI_A1 (FUNC(0) | PORTF(4, 10) | SE | VE) +#define EMI_A1_GPIO (FUNC(3) | PORTF(4, 10) | SE | VE) +#define EMI_A0 (FUNC(0) | PORTF(4, 9) | SE | VE) +#define EMI_A0_GPIO (FUNC(3) | PORTF(4, 9) | SE | VE) +#define ROTARYB (FUNC(0) | PORTF(4, 8) | SE | PE) +#define ROTARYB_AUART2_CTS (FUNC(1) | PORTF(4, 8) | SE | PE) +#define ROTARYB_GPMI_CE3N (FUNC(2) | PORTF(4, 8) | SE | PE) +#define ROTARYB_GPIO (FUNC(3) | PORTF(4, 8) | SE | PE) +#define ROTARYA (FUNC(0) | PORTF(4, 7) | SE) +#define ROTARYA_AUART2_RTS (FUNC(1) | PORTF(4, 7) | SE) +#define ROTARYA_SPDIF (FUNC(2) | PORTF(4, 7) | SE) +#define ROTARYA_GPIO (FUNC(3) | PORTF(4, 7) | SE) +#define SSP1_SCK (FUNC(0) | PORTF(4, 6) | SE) +#define SSP1_SCK_ALT_JTAG_TRST (FUNC(2) | PORTF(4, 6) | SE) +#define SSP1_SCK_GPIO (FUNC(3) | PORTF(4, 6) | SE) +#define SSP1_DATA3 (FUNC(0) | PORTF(4, 5) | SE | PE) +#define SSP1_DATA3_ALT_JTAG_TMS (FUNC(2) | PORTF(4, 5) | SE | PE) +#define SSP1_DATA3_GPIO (FUNC(3) | PORTF(4, 5) | SE | PE) +#define SSP1_DATA2 (FUNC(0) | PORTF(4, 4) | SE | PE) +#define SSP1_DATA2_I2C_SD (FUNC(1) | PORTF(4, 4) | SE | PE) +#define SSP1_DATA2_ALT_JTAG_RTCK (FUNC(2) | PORTF(4, 4) | SE | PE) +#define SSP1_DATA2_GPIO (FUNC(3) | PORTF(4, 4) | SE | PE) +#define SSP1_DATA1 (FUNC(0) | PORTF(4, 3) | SE | PE) +#define SSP1_DATA1_I2C_CLK (FUNC(1) | PORTF(4, 3) | SE | PE) +#define SSP1_DATA1_ALT_JTAG_TCK (FUNC(2) | PORTF(4, 3) | SE | PE) +#define SSP1_DATA1_GPIO (FUNC(3) | PORTF(4, 3) | SE | PE) +#define SSP1_DATA0 (FUNC(0) | PORTF(4, 2) | SE | PE) +#define SSP1_DATA0_ALT_JTAG_TDI (FUNC(2) | PORTF(4, 2) | SE | PE) +#define SSP1_DATA0_GPIO (FUNC(3) | PORTF(4, 2) | SE | PE) +#define SSP1_DETECT (FUNC(0) | PORTF(4, 1) | SE | PE) +#define SSP1_DETECT_GPMI_CE3N (FUNC(1) | PORTF(4, 1) | SE | PE) +#define SSP1_DETECT_USB_ID (FUNC(2) | PORTF(4, 1) | SE | PE) +#define SSP1_DETECT_GPIO (FUNC(3) | PORTF(4, 1) | SE | PE) +#define SSP1_CMD (FUNC(0) | PORTF(4, 0) | SE | PE) +#define SSP1_CMD_JTAG_TDO (FUNC(2) | PORTF(4, 0) | SE | PE) +#define SSP1_CMD_GPIO (FUNC(3) | PORTF(4, 0) | SE | PE) + +/* Bank 2, pins 16 ... 31 GPIO pins 80 ... 95 */ +#define EMI_WEN (FUNC(0) | PORTF(5, 15) | SE | VE) +#define EMI_WEN_GPIO (FUNC(3) | PORTF(5, 15) | SE | VE) +#define EMI_RASN (FUNC(0) | PORTF(5, 14) | SE | VE) +#define EMI_RASN_GPIO (FUNC(3) | PORTF(5, 14) | SE | VE) +#define EMI_CKE (FUNC(0) | PORTF(5, 13) | SE | VE) +#define EMI_CKE_GPIO (FUNC(3) | PORTF(5, 13) | SE | VE) +#define GPMI_CE0N (FUNC(0) | PORTF(5, 12) | SE) +#define GPMI_CE0N_GPIO (FUNC(3) | PORTF(5, 12) | SE) +#define GPMI_CE1N (FUNC(0) | PORTF(5, 11) | SE | PE) +#define GPMI_CE1N_GPIO (FUNC(3) | PORTF(5, 11) | SE | PE) +#define EMI_CE1N (FUNC(0) | PORTF(5, 10) | SE | VE | PE) +#define EMI_CE1N_GPIO (FUNC(3) | PORTF(5, 10) | SE | VE | PE) +#define EMI_CE0N (FUNC(0) | PORTF(5, 9) | SE | VE) +#define EMI_CE0N_GPIO (FUNC(3) | PORTF(5, 9) | SE | VE) +#define EMI_CASN (FUNC(0) | PORTF(5, 8) | SE | VE) +#define EMI_CASN_GPIO (FUNC(3) | PORTF(5, 8) | SE | VE) +#define EMI_BA1 (FUNC(0) | PORTF(5, 7) | SE | VE) +#define EMI_BA1_GPIO (FUNC(3) | PORTF(5, 7) | SE | VE) +#define EMI_BA0 (FUNC(0) | PORTF(5, 6) | SE | VE) +#define EMI_BA0_GPIO (FUNC(3) | PORTF(5, 6) | SE | VE) +#define EMI_A12 (FUNC(0) | PORTF(5, 5) | SE | VE) +#define EMI_A12_GPIO (FUNC(3) | PORTF(5, 5) | SE | VE) +#define EMI_A11 (FUNC(0) | PORTF(5, 4) | SE | VE) +#define EMI_A11_GPIO (FUNC(3) | PORTF(5, 4) | SE | VE) +#define EMI_A10 (FUNC(0) | PORTF(5, 3) | SE | VE) +#define EMI_A10_GPIO (FUNC(3) | PORTF(5, 3) | SE | VE) +#define EMI_A9 (FUNC(0) | PORTF(5, 2) | SE | VE) +#define EMI_A9_GPIO (FUNC(3) | PORTF(5, 2) | SE | VE) +#define EMI_A8 (FUNC(0) | PORTF(5, 1) | SE | VE) +#define EMI_A8_GPIO (FUNC(3) | PORTF(5, 1) | SE | VE) +#define EMI_A7 (FUNC(0) | PORTF(5, 0) | SE | VE) +#define EMI_A7_GPIO (FUNC(3) | PORTF(5, 0) | SE | VE) + +/* Bank 3, pins 0 ... 15 GPIO pins 96 ... 111 */ +#define EMI_D15 (FUNC(0) | PORTF(6, 15) | SE | VE | PE) +#define EMI_D15_DISABLED (FUNC(3) | PORTF(6, 15) | SE | VE | PE) +#define EMI_D14 (FUNC(0) | PORTF(6, 14) | SE | VE | PE) +#define EMI_D14_DISABLED (FUNC(3) | PORTF(6, 14) | SE | VE | PE) +#define EMI_D13 (FUNC(0) | PORTF(6, 13) | SE | VE | PE) +#define EMI_D13_DISABLED (FUNC(3) | PORTF(6, 13) | SE | VE | PE) +#define EMI_D12 (FUNC(0) | PORTF(6, 12) | SE | VE | PE) +#define EMI_D12_DISABLED (FUNC(3) | PORTF(6, 12) | SE | VE | PE) +#define EMI_D11 (FUNC(0) | PORTF(6, 11) | SE | VE | PE) +#define EMI_D11_DISABLED (FUNC(3) | PORTF(6, 11) | SE | VE | PE) +#define EMI_D10 (FUNC(0) | PORTF(6, 10) | SE | VE | PE) +#define EMI_D10_DISABLED (FUNC(3) | PORTF(6, 10) | SE | VE | PE) +#define EMI_D9 (FUNC(0) | PORTF(6, 9) | SE | VE | PE) +#define EMI_D9_DISABLED (FUNC(3) | PORTF(6, 9) | SE | VE | PE) +#define EMI_D8 (FUNC(0) | PORTF(6, 8) | SE | VE | PE) +#define EMI_D8_DISABLED (FUNC(3) | PORTF(6, 8) | SE | VE | PE) +#define EMI_D7 (FUNC(0) | PORTF(6, 7) | SE | VE | PE) +#define EMI_D7_DISABLED (FUNC(3) | PORTF(6, 7) | SE | VE | PE) +#define EMI_D6 (FUNC(0) | PORTF(6, 6) | SE | VE | PE) +#define EMI_D6_DISABLED (FUNC(3) | PORTF(6, 6) | SE | VE | PE) +#define EMI_D5 (FUNC(0) | PORTF(6, 5) | SE | VE | PE) +#define EMI_D5_DISABLED (FUNC(3) | PORTF(6, 5) | SE | VE | PE) +#define EMI_D4 (FUNC(0) | PORTF(6, 4) | SE | VE | PE) +#define EMI_D4_DISABLED (FUNC(3) | PORTF(6, 4) | SE | VE | PE) +#define EMI_D3 (FUNC(0) | PORTF(6, 3) | SE | VE | PE) +#define EMI_D3_DISABLED (FUNC(3) | PORTF(6, 3) | SE | VE | PE) +#define EMI_D2 (FUNC(0) | PORTF(6, 2) | SE | VE | PE) +#define EMI_D2_DISABLED (FUNC(3) | PORTF(6, 2) | SE | VE | PE) +#define EMI_D1 (FUNC(0) | PORTF(6, 1) | SE | VE | PE) +#define EMI_D1_DISABLED (FUNC(3) | PORTF(6, 1) | SE | VE | PE) +#define EMI_D0 (FUNC(0) | PORTF(6, 0) | SE | VE | PE) +#define EMI_D0_DISABLED (FUNC(3) | PORTF(6, 0) | SE | VE | PE) + +/* Bank 3, pins 16 ... 21 GPIO pins 112 ... 117 */ +#define EMI_CLKN (FUNC(0) | PORTF(7, 5) | SE | VE) +#define EMI_CLKN_DISABLED (FUNC(3) | PORTF(7, 5) | SE | VE) +#define EMI_CLK (FUNC(0) | PORTF(7, 4) | SE | VE) +#define EMI_CLK_DISABLED (FUNC(3) | PORTF(7, 4) | SE | VE) +#define EMI_DQS1 (FUNC(0) | PORTF(7, 3) | SE | VE) +#define EMI_DQS1_DISABLED (FUNC(3) | PORTF(7, 3) | SE | VE) +#define EMI_DQS0 (FUNC(0) | PORTF(7, 2) | SE | VE) +#define EMI_DQS0_DISABLED (FUNC(3) | PORTF(7, 2) | SE | VE) +#define EMI_DQM1 (FUNC(0) | PORTF(7, 1) | SE | VE | PE) +#define EMI_DQM1_DISABLED (FUNC(3) | PORTF(7, 1) | SE | VE | PE) +#define EMI_DQM0 (FUNC(0) | PORTF(7, 0) | SE | VE | PE) +#define EMI_DQM0_DISABLED (FUNC(3) | PORTF(7, 0) | SE | VE | PE) + +#endif /* __ASM_MACH_IOMUX_H */ diff --git a/arch/arm/mach-mxs/include/mach/iomux-imx28.h b/arch/arm/mach-mxs/include/mach/iomux-imx28.h new file mode 100644 index 0000000..1e6d421 --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/iomux-imx28.h @@ -0,0 +1,552 @@ +/* + * 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. + */ + +/* 3322222222221111111111 + * 10987654321098765432109876543210 + * ^^^^^_ Bit offset + * ^^^______ Register Number + * ^^_________ Function + * ^___________ Drive strength feature present + * ^____________ Pull up / bit keeper present + * ^^_____________ Drive strength setting + * ^_______________ Pull up / bit keeper setting + * ^________________ Voltage select present + * ^_________________ Voltage selection + * ^_____________________ direction if enabled as GPIO (1 = output) + * ^______________________ initial output value if enabled as GPIO + * and configured as output + */ +#ifndef __MACH_IOMUX_IMX28_H +#define __MACH_IOMUX_IMX28_H + +/* control pad's function */ +#define FBANK_SHIFT (5) +#define PORTF(bank,bit) (((bank) << FBANK_SHIFT) | (bit)) +#define GET_GPIO_NO(x) ((x) & 0xff) +#define FUNC_SHIFT 8 +#define FUNC(x) ((x) << FUNC_SHIFT) +#define GET_FUNC(x) (((x) >> FUNC_SHIFT) & 3) +#define IS_GPIO (3) + +/* control pad's GPIO feature if enabled */ +#define GPIO_OUT (1 << 20) +#define GPIO_VALUE(x) ((x) << 21) +#define GPIO_IN (0 << 20) +#define GET_GPIODIR(x) (!!((x) & (1 << 20))) +#define GET_GPIOVAL(x) (!!((x) & (1 << 21))) + +/* control pad's drive strength */ +#define SE (1 << 10) +#define SE_PRESENT(x) (!!((x) & SE)) +#define STRENGTH(x) ((x) << 12) +#define S4MA 0 /* used to define a 4 mA drive strength */ +#define S8MA 1 /* used to define a 8 mA drive strength */ +#define S12MA 2 /* used to define a 12 mA drive strength */ +#define S16MA 3 /* used to define a 16 mA drive strength, + not all pads can drive this current! */ +#define GET_STRENGTH(x) (((x) >> 12) & 0x3) + +/* control pad's pull up / bit keeper feature */ +#define PE (1 << 11) +#define BK (1 << 11) /* FIXME useful to distinguish? */ +#define PE_PRESENT(x) (!!((x) & PE)) +#define BK_PRESENT(x) (!!((x) & BK)) +#define PULLUP(x) ((x) << 14) +#define BITKEEPER(x) ((x) << 14) +#define GET_PULLUP(x) (!!((x) & PULLUP(1))) +#define GET_BITKEEPER(x) (!!((x) & BITKEEPER(1))) + +/* control pad's voltage feature */ +#define VE (1 << 15) +#define VE_PRESENT(x) (!!((x) & VE)) +#define VE_1_8V (0 << 16) +#define VE_3_3V (1 << 16) +#define GET_VOLTAGE(x) (!!((x) & (1 << 16))) + +/* Bank 0, GPIO pins 0 ... 31 */ +#define GPMI_RESETN (FUNC(0) | PORTF(0, 28) | SE | VE | PE) +#define GPMI_RESETN_SSP3_CMD (FUNC(1) | PORTF(0, 28) | SE | VE | PE) +#define GPMI_RESETN_GPIO (FUNC(3) | PORTF(0, 28) | SE | VE | PE) +#define GPMI_CLE (FUNC(0) | PORTF(0, 27) | SE | VE | PE) +#define GPMI_CLE_SSP3_D2 (FUNC(1) | PORTF(0, 27) | SE | VE | PE) +#define GPMI_CLE_SSP3_D5 (FUNC(2) | PORTF(0, 27) | SE | VE | PE) +#define GPMI_CLE_GPIO (FUNC(3) | PORTF(0, 27) | SE | VE | PE) +#define GPMI_ALE (FUNC(0) | PORTF(0, 26) | SE | VE | PE) +#define GPMI_ALE_SSP3_D1 (FUNC(1) | PORTF(0, 26) | SE | VE | PE) +#define GPMI_ALE_SSP3_D4 (FUNC(2) | PORTF(0, 26) | SE | VE | PE) +#define GPMI_ALE_GPIO (FUNC(3) | PORTF(0, 26) | SE | VE | PE) +#define GPMI_WRN (FUNC(0) | PORTF(0, 25) | SE | VE | BK) +#define GPMI_WRN_SSP1_SCK (FUNC(1) | PORTF(0, 25) | SE | VE | BK) +#define GPMI_WRN_GPIO (FUNC(3) | PORTF(0, 25) | SE | VE | BK) +#define GPMI_RDN (FUNC(0) | PORTF(0, 24) | SE | VE | PE) +#define GPMI_RDN_SSP3_SCK (FUNC(1) | PORTF(0, 24) | SE | VE | PE) +#define GPMI_RDN_GPIO (FUNC(3) | PORTF(0, 24) | SE | VE | PE) +#define GPMI_READY3 (FUNC(0) | PORTF(0, 23) | SE | VE | PE) +#define GPMI_READY3_CAN0_RX (FUNC(1) | PORTF(0, 23) | SE | VE | PE) +#define GPMI_READY3_HSDAC_TRIG (FUNC(2) | PORTF(0, 23) | SE | VE | PE) +#define GPMI_READY3_GPIO (FUNC(3) | PORTF(0, 23) | SE | VE | PE) +#define GPMI_READY2 (FUNC(0) | PORTF(0, 22) | SE | VE | PE) +#define GPMI_READY2_CAN0_TX (FUNC(1) | PORTF(0, 22) | SE | VE | PE) +#define GPMI_READY2_ENET0_TX_ER (FUNC(2) | PORTF(0, 22) | SE | VE | PE) +#define GPMI_READY2_GPIO (FUNC(3) | PORTF(0, 22) | SE | VE | PE) +#define GPMI_READY1 (FUNC(0) | PORTF(0, 21) | SE | VE | PE) +#define GPMI_READY1_SSP1_CMD (FUNC(1) | PORTF(0, 21) | SE | VE | PE) +#define GPMI_READY1_GPIO (FUNC(3) | PORTF(0, 21) | SE | VE | PE) +#define GPMI_READY0 (FUNC(0) | PORTF(0, 20) | SE | VE | PE) +#define GPMI_READY0_SSP1_CD (FUNC(1) | PORTF(0, 20) | SE | VE | PE) +#define GPMI_READY0_USB0_ID (FUNC(2) | PORTF(0, 20) | SE | VE | PE) +#define GPMI_READY0_GPIO (FUNC(3) | PORTF(0, 20) | SE | VE | PE) +#define GPMI_CE3N (FUNC(0) | PORTF(0, 19) | SE | VE | PE) +#define GPMI_CE3N_CAN1_RX (FUNC(1) | PORTF(0, 19) | SE | VE | PE) +#define GPMI_CE3N_SAIF1_MCLK (FUNC(2) | PORTF(0, 19) | SE | VE | PE) +#define GPMI_CE3N_GPIO (FUNC(3) | PORTF(0, 19) | SE | VE | PE) +#define GPMI_CE2N (FUNC(0) | PORTF(0, 18) | SE | VE | PE) +#define GPMI_CE2N_CAN1_TX (FUNC(1) | PORTF(0, 18) | SE | VE | PE) +#define GPMI_CE2N_ENET0_RX_ER (FUNC(2) | PORTF(0, 18) | SE | VE | PE) +#define GPMI_CE2N_GPIO (FUNC(3) | PORTF(0, 18) | SE | VE | PE) +#define GPMI_CE1N (FUNC(0) | PORTF(0, 17) | SE | VE | PE) +#define GPMI_CE1N_SSP3_D3 (FUNC(1) | PORTF(0, 17) | SE | VE | PE) +#define GPMI_CE1N_GPIO (FUNC(3) | PORTF(0, 17) | SE | VE | PE) +#define GPMI_CE0N (FUNC(0) | PORTF(0, 16) | SE | VE | PE) +#define GPMI_CE0N_SSP3_D0 (FUNC(1) | PORTF(0, 16) | SE | VE | PE) +#define GPMI_CE0N_GPIO (FUNC(3) | PORTF(0, 16) | SE | VE | PE) +#define GPMI_D7 (FUNC(0) | PORTF(0, 7) | SE | VE | PE) +#define GPMI_D7_SSP1_D7 (FUNC(1) | PORTF(0, 7) | SE | VE | PE) +#define GPMI_D7_GPIO (FUNC(3) | PORTF(0, 7) | SE | VE | PE) +#define GPMI_D6 (FUNC(0) | PORTF(0, 6) | SE | VE | PE) +#define GPMI_D6_SSP1_D6 (FUNC(1) | PORTF(0, 6) | SE | VE | PE) +#define GPMI_D6_GPIO (FUNC(3) | PORTF(0, 6) | SE | VE | PE) +#define GPMI_D5 (FUNC(0) | PORTF(0, 5) | SE | VE | PE) +#define GPMI_D5_SSP1_D5 (FUNC(1) | PORTF(0, 5) | SE | VE | PE) +#define GPMI_D5_GPIO (FUNC(3) | PORTF(0, 5) | SE | VE | PE) +#define GPMI_D4 (FUNC(0) | PORTF(0, 4) | SE | VE | PE) +#define GPMI_D4_SSP1_D4 (FUNC(1) | PORTF(0, 4) | SE | VE | PE) +#define GPMI_D4_GPIO (FUNC(3) | PORTF(0, 4) | SE | VE | PE) +#define GPMI_D3 (FUNC(0) | PORTF(0, 3) | SE | VE | PE) +#define GPMI_D3_SSP1_D3 (FUNC(1) | PORTF(0, 3) | SE | VE | PE) +#define GPMI_D3_GPIO (FUNC(3) | PORTF(0, 3) | SE | VE | PE) +#define GPMI_D2 (FUNC(0) | PORTF(0, 2) | SE | VE | PE) +#define GPMI_D2_SSP1_D2 (FUNC(1) | PORTF(0, 2) | SE | VE | PE) +#define GPMI_D2_GPIO (FUNC(3) | PORTF(0, 2) | SE | VE | PE) +#define GPMI_D1 (FUNC(0) | PORTF(0, 1) | SE | VE | PE) +#define GPMI_D1_SSP1_D1 (FUNC(1) | PORTF(0, 1) | SE | VE | PE) +#define GPMI_D1_GPIO (FUNC(3) | PORTF(0, 1) | SE | VE | PE) +#define GPMI_D0 (FUNC(0) | PORTF(0, 0) | SE | VE | PE) +#define GPMI_D0_SSP1_D0 (FUNC(1) | PORTF(0, 0) | SE | VE | PE) +#define GPMI_D0_GPIO (FUNC(3) | PORTF(0, 0) | SE | VE | PE) + +/* Bank 1, GPIO pins 32 ... 63 */ + +#define LCD_ENABLE (FUNC(0) | PORTF(1, 31) | SE | VE | BK) +#define LCD_ENABLE_GPIO (FUNC(3) | PORTF(1, 31) | SE | VE | BK) + +#define LCD_DOTCLK (FUNC(0) | PORTF(1, 30) | SE | VE | BK) + +#define LCD_HSYNC (FUNC(0) | PORTF(1, 29) | SE | VE | BK) + +#define LCD_VSYNC (FUNC(0) | PORTF(1, 28) | SE | VE | BK) + +#define LCD_CS (FUNC(0) | PORTF(1, 27) | SE | VE | BK) +#define LCD_CS_LCD_ENABLE (FUNC(1) | PORTF(1, 27) | SE | VE | BK) +#define LCD_CS_GPIO (FUNC(3) | PORTF(1, 27) | SE | VE | BK) + +#define LCD_RS (FUNC(0) | PORTF(1, 26) | SE | VE | BK) +#define LCD_RS_LCD_DOTCLK (FUNC(1) | PORTF(1, 26) | SE | VE | BK) +#define LCD_RS_GPIO (FUNC(3) | PORTF(1, 26) | SE | VE | BK) +#define LCD_WR_RWN (FUNC(0) | PORTF(1, 25) | SE | VE | BK) +#define LCD_WR_RWN_LCD_HSYNC (FUNC(1) | PORTF(1, 25) | SE | VE | BK) +#define LCD_WR_RWN_ETM_TCLK (FUNC(2) | PORTF(1, 25) | SE | VE | BK) +#define LCD_WR_RWN_GPIO (FUNC(3) | PORTF(1, 25) | SE | VE | BK) +#define LCD_RD_E (FUNC(0) | PORTF(1, 24) | SE | VE | BK) +#define LCD_RD_E_LCD_VSYNC (FUNC(1) | PORTF(1, 24) | SE | VE | BK) +#define LCD_RD_E_ETM_TCTL (FUNC(2) | PORTF(1, 24) | SE | VE | BK) +#define LCD_RD_E_GPIO (FUNC(3) | PORTF(1, 24) | SE | VE | BK) + +#define LCD_D23 (FUNC(0) | PORTF(1, 23) | SE | VE | BK) + +#define LCD_D22 (FUNC(0) | PORTF(1, 22) | SE | VE | BK) + +#define LCD_D21 (FUNC(0) | PORTF(1, 21) | SE | VE | BK) + +#define LCD_D20 (FUNC(0) | PORTF(1, 20) | SE | VE | BK) + +#define LCD_D19 (FUNC(0) | PORTF(1, 19) | SE | VE | BK) + +#define LCD_D18 (FUNC(0) | PORTF(1, 18) | SE | VE | BK) + +#define LCD_D17 (FUNC(0) | PORTF(1, 17) | SE | VE | BK) + +#define LCD_D16 (FUNC(0) | PORTF(1, 16) | SE | VE | BK) + +#define LCD_D15 (FUNC(0) | PORTF(1, 15) | SE | VE | BK) +#define LCD_D15_ETM_DA15 (FUNC(2) | PORTF(1, 15) | SE | VE | BK) +#define LCD_D15_GPIO (FUNC(3) | PORTF(1, 15) | SE | VE | BK) +#define LCD_D14 (FUNC(0) | PORTF(1, 14) | SE | VE | BK) +#define LCD_D14_ETM_DA14 (FUNC(2) | PORTF(1, 14) | SE | VE | BK) +#define LCD_D14_GPIO (FUNC(3) | PORTF(1, 14) | SE | VE | BK) +#define LCD_D13 (FUNC(0) | PORTF(1, 13) | SE | VE | BK) +#define LCD_D13_ETM_DA13 (FUNC(2) | PORTF(1, 13) | SE | VE | BK) +#define LCD_D13_GPIO (FUNC(3) | PORTF(1, 13) | SE | VE | BK) +#define LCD_D12 (FUNC(0) | PORTF(1, 12) | SE | VE | BK) +#define LCD_D12_ETM_DA12 (FUNC(2) | PORTF(1, 12) | SE | VE | BK) +#define LCD_D12_GPIO (FUNC(3) | PORTF(1, 12) | SE | VE | BK) +#define LCD_D11 (FUNC(0) | PORTF(1, 11) | SE | VE | BK) +#define LCD_D11_ETM_DA11 (FUNC(2) | PORTF(1, 11) | SE | VE | BK) +#define LCD_D11_GPIO (FUNC(3) | PORTF(1, 11) | SE | VE | BK) +#define LCD_D10 (FUNC(0) | PORTF(1, 10) | SE | VE | BK) +#define LCD_D10_ETM_DA10 (FUNC(2) | PORTF(1, 10) | SE | VE | BK) +#define LCD_D10_GPIO (FUNC(3) | PORTF(1, 10) | SE | VE | BK) +#define LCD_D9 (FUNC(0) | PORTF(1, 9) | SE | VE | BK) +#define LCD_D9_ETM_DA4 (FUNC(1) | PORTF(1, 9) | SE | VE | BK) +#define LCD_D9_ETM_DA9 (FUNC(2) | PORTF(1, 9) | SE | VE | BK) +#define LCD_D9_GPIO (FUNC(3) | PORTF(1, 9) | SE | VE | BK) +#define LCD_D8 (FUNC(0) | PORTF(1, 8) | SE | VE | BK) +#define LCD_D8_ETM_DA3 (FUNC(1) | PORTF(1, 8) | SE | VE | BK) +#define LCD_D8_ETM_DA8 (FUNC(2) | PORTF(1, 8) | SE | VE | BK) +#define LCD_D8_GPIO (FUNC(3) | PORTF(1, 8) | SE | VE | BK) +#define LCD_D7 (FUNC(0) | PORTF(1, 7) | SE | VE | BK) +#define LCD_D7_ETM_DA7 (FUNC(2) | PORTF(1, 7) | SE | VE | BK) +#define LCD_D7_GPIO (FUNC(3) | PORTF(1, 7) | SE | VE | BK) +#define LCD_D6 (FUNC(0) | PORTF(1, 6) | SE | VE | BK) +#define LCD_D6_ETM_DA6 (FUNC(2) | PORTF(1, 6) | SE | VE | BK) +#define LCD_D6_GPIO (FUNC(3) | PORTF(1, 6) | SE | VE | BK) +#define LCD_D5 (FUNC(0) | PORTF(1, 5) | SE | VE | BK) +#define LCD_D5_ETM_DA5 (FUNC(2) | PORTF(1, 5) | SE | VE | BK) +#define LCD_D5_GPIO (FUNC(3) | PORTF(1, 5) | SE | VE | BK) +#define LCD_D4 (FUNC(0) | PORTF(1, 4) | SE | VE | BK) +#define LCD_D4_ETM_DA9 (FUNC(1) | PORTF(1, 4) | SE | VE | BK) +#define LCD_D4_ETM_DA4 (FUNC(2) | PORTF(1, 4) | SE | VE | BK) +#define LCD_D4_GPIO (FUNC(3) | PORTF(1, 4) | SE | VE | BK) +#define LCD_D3 (FUNC(0) | PORTF(1, 3) | SE | VE | BK) +#define LCD_D3_ETM_DA8 (FUNC(1) | PORTF(1, 3) | SE | VE | BK) +#define LCD_D3_ETM_DA3 (FUNC(2) | PORTF(1, 3) | SE | VE | BK) +#define LCD_D3_GPIO (FUNC(3) | PORTF(1, 3) | SE | VE | BK) +#define LCD_D2 (FUNC(0) | PORTF(1, 2) | SE | VE | BK) +#define LCD_D2_ETM_DA2 (FUNC(2) | PORTF(1, 2) | SE | VE | BK) +#define LCD_D2_GPIO (FUNC(3) | PORTF(1, 2) | SE | VE | BK) +#define LCD_D1 (FUNC(0) | PORTF(1, 1) | SE | VE | BK) +#define LCD_D1_ETM_DA1 (FUNC(2) | PORTF(1, 1) | SE | VE | BK) +#define LCD_D1_GPIO (FUNC(3) | PORTF(1, 1) | SE | VE | BK) +#define LCD_D0 (FUNC(0) | PORTF(1, 0) | SE | VE | BK) +#define LCD_D0_ETM_DA0 (FUNC(2) | PORTF(1, 0) | SE | VE | BK) +#define LCD_D0_GPIO (FUNC(3) | PORTF(1, 0) | SE | VE | BK) + +/* TODO */ + +/* Bank 2, GPIO pins 64 ... 95 */ + +/* TODO */ + +#define SSP1_D3 (FUNC(0) | PORTF(2, 15) | SE | VE | PE) +#define SSP1_D3_SSP2_D7 (FUNC(1) | PORTF(2, 15) | SE | VE | PE) +#define SSP1_D3_ENET_1588_EVENT3_IN (FUNC(2) | PORTF(4, 15) | SE | VE | PE) +#define SSP1_D3_GPIO (FUNC(3) | PORTF(2, 15) | SE | VE | PE) +#define SSP1_D0 (FUNC(0) | PORTF(2, 14) | SE | VE | PE) +#define SSP1_D0_SSP2_D6 (FUNC(1) | PORTF(2, 14) | SE | VE | PE) +#define SSP1_D0_ENET_1588_EVENT3_OUT (FUNC(2) | PORTF(2, 14) | SE | VE | PE) +#define SSP1_D0_GPIO (FUNC(3) | PORTF(2, 14) | SE | VE | PE) +#define SSP1_CMD (FUNC(0) | PORTF(2, 13) | SE | VE | PE) +#define SSP1_CMD_SSP2_D2 (FUNC(1) | PORTF(2, 13) | SE | VE | PE) +#define SSP1_CMD_ENET_1588_EVENT2_IN (FUNC(2) | PORTF(2, 13) | SE | VE | PE) +#define SSP1_CMD_GPIO (FUNC(3) | PORTF(2, 13) | SE | VE | PE) +#define SSP1_SCK (FUNC(0) | PORTF(2, 12) | SE | VE | PE) +#define SSP1_SCK_SSP2_D1 (FUNC(1) | PORTF(2, 12) | SE | VE | PE) +#define SSP1_SCK_ENET_1588_EVENT2_OUT (FUNC(2) | PORTF(2, 12) | SE | VE | PE) +#define SSP1_SCK_GPIO (FUNC(3) | PORTF(2, 12) | SE | VE | PE) +#define SSP0_SCK (FUNC(0) | PORTF(2, 10) | SE | VE | BK) +#define SSP0_SCK_GPIO (FUNC(3) | PORTF(2, 10) | SE | VE | BK) +#define SSP0_CD (FUNC(0) | PORTF(2, 9) | SE | VE | PE) +#define SSP0_CD_GPIO (FUNC(3) | PORTF(2, 9) | SE | VE | PE) +#define SSP0_CMD (FUNC(0) | PORTF(2, 8) | SE | VE | PE) +#define SSP0_CMD_GPIO (FUNC(3) | PORTF(2, 8) | SE | VE | PE) +#define SSP0_D7 (FUNC(0) | PORTF(2, 7) | SE | VE | PE) +#define SSP0_D7_SSP2_SCK (FUNC(1) | PORTF(2, 7) | SE | VE | PE) +#define SSP0_D7_GPIO (FUNC(3) | PORTF(2, 7) | SE | VE | PE) +#define SSP0_D6 (FUNC(0) | PORTF(2, 6) | SE | VE | PE) +#define SSP0_D6_SSP2_CMD (FUNC(1) | PORTF(2, 6) | SE | VE | PE) +#define SSP0_D6_GPIO (FUNC(3) | PORTF(2, 6) | SE | VE | PE) +#define SSP0_D5 (FUNC(0) | PORTF(2, 5) | SE | VE | PE) +#define SSP0_D5_SSP2_D3 (FUNC(1) | PORTF(2, 5) | SE | VE | PE) +#define SSP0_D5_GPIO (FUNC(3) | PORTF(2, 5) | SE | VE | PE) +#define SSP0_D4 (FUNC(0) | PORTF(2, 4) | SE | VE | PE) +#define SSP0_D4_SSP2_D0 (FUNC(1) | PORTF(2, 4) | SE | VE | PE) +#define SSP0_D4_GPIO (FUNC(3) | PORTF(2, 4) | SE | VE | PE) +#define SSP0_D3 (FUNC(0) | PORTF(2, 3) | SE | VE | PE) +#define SSP0_D3_GPIO (FUNC(3) | PORTF(2, 3) | SE | VE | PE) +#define SSP0_D2 (FUNC(0) | PORTF(2, 2) | SE | VE | PE) +#define SSP0_D2_GPIO (FUNC(3) | PORTF(2, 2) | SE | VE | PE) +#define SSP0_D1 (FUNC(0) | PORTF(2, 1) | SE | VE | PE) +#define SSP0_D1_GPIO (FUNC(3) | PORTF(2, 1) | SE | VE | PE) +#define SSP0_D0 (FUNC(0) | PORTF(2, 0) | SE | VE | PE) +#define SSP0_D0_GPIO (FUNC(3) | PORTF(2, 0) | SE | VE | PE) + +/* Bank 3, GPIO pins 96 ... 127 */ + +#define LCD_RESET (FUNC(0) | PORTF(3, 30)) +#define LCD_RESET_LCD_VSYNC (FUNC(1) | PORTF(3, 30)) +#define LCD_RESET_GPIO (FUNC(3) | PORTF(3, 30)) +#define PWM4 (FUNC(0) | PORTF(3, 29)) +#define PWM4_GPIO (FUNC(3) | PORTF(3, 29)) +#define PWM3 (FUNC(0) | PORTF(3 28)) +#define PWM3_GPIO (FUNC(3) | PORTF(3, 28)) + +#define PWM2 (FUNC(0) | PORTF(3, 18)) + +#define PWM1 (FUNC(0) | PORTF(3, 17)) + +#define PWM0 (FUNC(0) | PORTF(3, 16)) +#define PWM0_I2C1_SCL (FUNC(1) | PORTF(3, 16)) +#define PWM0_DUART_RX (FUNC(2) | PORTF(3, 16)) +#define PWM0_GPIO (FUNC(3) | PORTF(3, 16)) +#define AUART3_RTS (FUNC(0) | PORTF(3, 15) | SE | VE | BK) +#define AUART3_RTS_CAN1_RX (FUNC(1) | PORTF(3, 15) | SE | VE | BK) +#define AUART3_RTS_ENET0_1588_EVENT1_IN (FUNC(2) | PORTF(3, 15) | SE | VE | BK) +#define AUART3_RTS_GPIO (FUNC(3) | PORTF(3, 15) | SE | VE | BK) +#define AUART3_CTS (FUNC(0) | PORTF(3, 14) | SE | VE | BK | BK) +#define AUART3_CTS_CAN1_TX (FUNC(1) | PORTF(3, 14) | SE | VE | BK) +#define AUART3_CTS_ENET0_1588_EVENT1_OUT (FUNC(2) | PORTF(3, 14) | SE | VE | BK) +#define AUART3_CTS_GPIO (FUNC(3) | PORTF(3, 14) | SE | VE | BK) +#define AUART3_TX (FUNC(0) | PORTF(3, 13) | SE | VE | BK) +#define AUART3_TX_CAN0_RX (FUNC(1) | PORTF(3, 13) | SE | VE | BK) +#define AUART3_TX_ENET0_1588_EVENT0_IN (FUNC(2) | PORTF(3, 13) | SE | VE | BK) +#define AUART3_TX_GPIO (FUNC(3) | PORTF(3, 13) | SE | VE | BK) +#define AUART3_RX (FUNC(0) | PORTF(3, 12) | SE | VE | BK) +#define AUART3_RX_CAN0_TX (FUNC(1) | PORTF(3, 12) | SE | VE | BK) +#define AUART3_RX_ENET0_1588_EVENT0_OUT (FUNC(2) | PORTF(3, 12) | SE | VE | BK) +#define AUART3_RX_GPIO (FUNC(3) | PORTF(3, 12) | SE | VE | BK) +#define AUART2_RTS (FUNC(0) | PORTF(3, 11) | SE | VE | BK) +#define AUART2_RTS_I2C1_SDA (FUNC(1) | PORTF(3, 11) | SE | VE | BK) +#define AUART2_RTS_SAIF1_IRCLK (FUNC(2) | PORTF(3, 11) | SE | VE | BK) +#define AUART2_RTS_GPIO (FUNC(3) | PORTF(3, 11) | SE | VE | BK) +#define AUART2_CTS (FUNC(0) | PORTF(3, 10) | SE | VE | BK) +#define AUART2_CTS_I2C1_SCL (FUNC(1) | PORTF(3, 10) | SE | VE | BK) +#define AUART2_CTS_SAIF1_BITCLK (FUNC(2) | PORTF(3, 10) | SE | VE | BK) +#define AUART2_CTS_GPIO (FUNC(3) | PORTF(3, 10) | SE | VE | BK) +#define AUART2_TX (FUNC(0) | PORTF(3, 9) | SE | VE | PE) +#define AUART2_TX_SSP3_D2 (FUNC(1) | PORTF(3, 9) | SE | VE | PE) +#define AUART2_TX_SSP3_D5 (FUNC(2) | PORTF(3, 9) | SE | VE | PE) +#define AUART2_TX_GPIO (FUNC(3) | PORTF(3, 9) | SE | VE | PE) +#define AUART2_RX (FUNC(0) | PORTF(3, 8) | SE | VE | PE) +#define AUART2_RX_SSP3_D1 (FUNC(1) | PORTF(3, 8) | SE | VE | PE) +#define AUART2_RX_SSP3_D4 (FUNC(2) | PORTF(3, 8) | SE | VE | PE) +#define AUART2_RX_GPIO (FUNC(3) | PORTF(3, 8) | SE | VE | PE) +#define AUART1_RTS (FUNC(0) | PORTF(3, 7) | SE | VE | PE) +#define AUART1_RTS_USB0_ID (FUNC(1) | PORTF(3, 7) | SE | VE | PE) +#define AUART1_RTS_ROTARYB (FUNC(2) | PORTF(3, 7) | SE | VE | PE) +#define AUART1_RTS_GPIO (FUNC(3) | PORTF(3, 7) | SE | VE | PE) +#define AUART1_CTS (FUNC(0) | PORTF(3, 6) | SE | VE | PE) +#define AUART1_CTS_USB0_OC (FUNC(1) | PORTF(3, 6) | SE | VE | PE) +#define AUART1_CTS_ROTARYA (FUNC(2) | PORTF(3, 6) | SE | VE | PE) +#define AUART1_CTS_GPIO (FUNC(3) | PORTF(3, 6) | SE | VE | PE) +#define AUART1_TX (FUNC(0) | PORTF(3, 5) | SE | VE | BK) +#define AUART1_TX_SSP3_CD (FUNC(1) | PORTF(3, 5) | SE | VE | BK) +#define AUART1_TX_PWM1 (FUNC(2) | PORTF(3, 5) | SE | VE | BK) +#define AUART1_TX_GPIO (FUNC(3) | PORTF(3, 5) | SE | VE | BK) +#define AUART1_RX (FUNC(0) | PORTF(3, 4) | SE | VE | BK) +#define AUART1_RX_SSP2_CD (FUNC(1) | PORTF(3, 4) | SE | VE | BK) +#define AUART1_RX_PWM0 (FUNC(2) | PORTF(3, 4) | SE | VE | BK) +#define AUART1_RX_GPIO (FUNC(3) | PORTF(3, 4) | SE | VE | BK) +#define AUART0_RTS (FUNC(0) | PORTF(3, 3) | SE | VE | BK) +#define AUART0_RTS_AUART4_TX (FUNC(1) | PORTF(3, 3) | SE | VE | BK) +#define AUART0_RTS_DUART_TX (FUNC(2) | PORTF(3, 3) | SE | VE | BK) +#define AUART0_RTS_GPIO (FUNC(3) | PORTF(3, 3) | SE | VE | BK) +#define AUART0_CTS (FUNC(0) | PORTF(3, 2) | SE | VE | BK) +#define AUART0_CTS_AUART4_RX (FUNC(1) | PORTF(3, 2) | SE | VE | BK) +#define AUART0_CTS_DUART_RX (FUNC(2) | PORTF(3, 2) | SE | VE | BK) +#define AUART0_CTS_GPIO (FUNC(3) | PORTF(3, 2) | SE | VE | BK) +#define AUART0_TX (FUNC(0) | PORTF(3, 1) | SE | VE | BK) +#define AUART0_TX_I2C0_SDA (FUNC(1) | PORTF(3, 1) | SE | VE | BK) +#define AUART0_TX_DUART_RTS (FUNC(2) | PORTF(3, 1) | SE | VE | BK) +#define AUART0_TX_GPIO (FUNC(3) | PORTF(3, 1) | SE | VE | BK) +#define AUART0_RX (FUNC(0) | PORTF(3, 0) | SE | VE | BK) +#define AUART0_RX_I2C0_SCL (FUNC(1) | PORTF(3, 0) | SE | VE | BK) +#define AUART0_RX_DUART_CTS (FUNC(2) | PORTF(3, 0) | SE | VE | BK) +#define AUART0_RX_GPIO (FUNC(3) | PORTF(3, 0) | SE | VE | BK) + +/* Bank 4, GPIO pins 128 ... 159 */ + +#define JTAG_RTCK (FUNC(0) | PORTF(4, 20) | SE | VE | BK) +#define JTAG_RTCK_GPIO (FUNC(3) | PORTF(4, 20) | SE | VE | BK) +#define ENET_CLK (FUNC(0) | PORTF(4, 16) | SE | VE | BK) +#define ENET_CLK_GPIO (FUNC(3) | PORTF(4, 16) | SE | VE | BK) + +#define ENET0_CRS (FUNC(0) | PORTF(4, 15) | SE | VE | BK) + +#define ENET0_COL (FUNC(0) | PORTF(4, 14) | SE | VE | BK) + +#define ENET0_RX_CLK (FUNC(0) | PORTF(4, 13) | SE | VE | BK) +#define ENET0_RX_CLK_RX_ER (FUNC(1) | PORTF(4, 13) | SE | VE | BK) +#define ENET0_RX_ENET0_1588_EVENT2_IN (FUNC(2) | PORTF(4, 13) | SE | VE | BK) +#define ENET0_RX_CLK_GPIO (FUNC(3) | PORTF(4, 13) | SE | VE | BK) +#define ENET0_TXD3 (FUNC(0) | PORTF(4, 12) | SE | VE | BK) +#define ENET0_TXD3_ENET1_TXD1 (FUNC(1) | PORTF(4, 12) | SE | VE | BK) +#define ENET0_TXD3_ENET0_1588_EVENT1_IN (FUNC(2) | PORTF(4, 12) | SE | VE | BK) +#define ENET0_TXD3_GPIO (FUNC(3) | PORTF(4, 12) | SE | VE | BK) + +#define ENET0_TXD2 (FUNC(0) | PORTF(4, 11) | SE | VE | BK) + +#define ENET0_TXD2_GPIO (FUNC(3) | PORTF(4, 11) | SE | VE | BK) + +#define ENET0_RXD3 (FUNC(0) | PORTF(4, 10) | SE | VE | BK) +#define ENET0_RXD3_ENET1_RXD1 (FUNC(1) | PORTF(4, 10) | SE | VE | BK) +#define ENET0_RXD3_ENET0_1588_EVENT0_IN (FUNC(2) | PORTF(4, 10) | SE | VE | BK) +#define ENET0_RXD3_GPIO (FUNC(3) | PORTF(4, 10) | SE | VE | BK) + +#define ENET0_RXD2 (FUNC(0) | PORTF(4, 9) | SE | VE | BK) + +#define ENET0_RXD2_GPIO (FUNC(3) | PORTF(4, 9) | SE | VE | BK) + +#define ENET0_TXD1 (FUNC(0) | PORTF(4, 8) | SE | VE | PE) + +#define ENET0_TXD1_GPIO (FUNC(3) | PORTF(4, 8) | SE | VE | PE) + +#define ENET0_TXD0 (FUNC(0) | PORTF(4, 7) | SE | VE | PE) + +#define ENET0_TXD0_GPIO (FUNC(3) | PORTF(4, 7) | SE | VE | PE) + +#define ENET0_TX_EN (FUNC(0) | PORTF(4, 6) | SE | VE | PE) + +#define ENET0_TX_EN_GPIO (FUNC(3) | PORTF(4, 6) | SE | VE | PE) + +#define ENET0_TX_CLK (FUNC(0) | PORTF(4, 5) | SE | VE | BK) + +#define ENET0_TX_CLK_GPIO (FUNC(3) | PORTF(4, 5) | SE | VE | BK) + +#define ENET0_RXD1 (FUNC(0) | PORTF(4, 4) | SE | VE | PE) +#define ENET0_RXD1_GPMI_READY4 (FUNC(1) | PORTF(4, 4) | SE | VE | PE) +#define ENET0_RXD1_GPIO (FUNC(3) | PORTF(4, 4) | SE | VE | PE) +#define ENET0_RXD0 (FUNC(0) | PORTF(4, 3) | SE | VE | PE) +#define ENET0_RXD0_GPMI_CE7N (FUNC(1) | PORTF(4, 3) | SE | VE | PE) +#define ENET0_RXD0_SAIF1_SDATA2 (FUNC(2) | PORTF(4, 3) | SE | VE | PE) +#define ENET0_RXD0_GPIO (FUNC(3) | PORTF(4, 3) | SE | VE | PE) +#define ENET0_RX_EN (FUNC(0) | PORTF(4, 2) | SE | VE | PE) +#define ENET0_RX_EN_GPMI_CE6N (FUNC(1) | PORTF(4, 2) | SE | VE | PE) +#define ENET0_RX_EN_SAIF1_SDATA1 (FUNC(2) | PORTF(4, 2) | SE | VE | PE) +#define ENET0_RX_EN_GPIO (FUNC(3) | PORTF(4, 2) | SE | VE | PE) +#define ENET0_MDIO (FUNC(0) | PORTF(4, 1) | SE | VE | PE) +#define ENET0_MDIO_GPMI_CE5N (FUNC(1) | PORTF(4, 1) | SE | VE | PE) +#define ENET0_MDIO_SAIF0_SDATA2 (FUNC(2) | PORTF(4, 1) | SE | VE | PE) +#define ENET0_MDIO_GPIO (FUNC(3) | PORTF(4, 1) | SE | VE | PE) +#define ENET0_MDC (FUNC(0) | PORTF(4, 0) | SE | VE | PE) +#define ENET0_MDC_GPMI_CE4N (FUNC(1) | PORTF(4, 0) | SE | VE | PE) +#define ENET0_MDC_SAIF0_SDATA1 (FUNC(2) | PORTF(4, 0) | SE | VE | PE) +#define ENET0_MDC_GPIO (FUNC(3) | PORTF(4, 0) | SE | VE | PE) + +/* + * Bank 5, GPIO pins 160 ... 191 + * Note: These pins are disabled instead of being GPIOs + */ +#define EMI_DDR_OPEN (FUNC(0) | PORTF(5, 26) | BK) +#define EMI_DDR_OPEN_OFF (FUNC(3) | PORTF(5, 26) | BK) +#define EMI_DSQ1 (FUNC(0) | PORTF(5, 23) | BK) +#define EMI_DSQ1_OFF (FUNC(3) | PORTF(5, 23) | BK) +#define EMI_DSQ0 (FUNC(0) | PORTF(5, 22) | BK) +#define EMI_DSQ0_OFF (FUNC(3) | PORTF(5, 22) | BK) +#define EMI_CLK (FUNC(0) | PORTF(5, 21) | BK) +#define EMI_CLK_OFF (FUNC(3) | PORTF(5, 21) | BK) +#define EMI_DDR_OPEN_FB (FUNC(0) | PORTF(5, 20) | BK) +#define EMI_DDR_OPEN_FB_OFF (FUNC(3) | PORTF(5, 20) | BK) +#define EMI_DQM1 (FUNC(0) | PORTF(5, 19) | BK) +#define EMI_DQM1_OFF (FUNC(3) | PORTF(5, 19) | BK) +#define EMI_ODT1 (FUNC(0) | PORTF(5, 18) | BK) +#define EMI_ODT1_OFF (FUNC(3) | PORTF(5, 18) | BK) +#define EMI_DQM0 (FUNC(0) | PORTF(5, 17) | BK) +#define EMI_DQM0_OFF (FUNC(3) | PORTF(5, 17) | BK) +#define EMI_ODT0 (FUNC(0) | PORTF(5, 16) | BK) +#define EMI_ODT0_OFF (FUNC(3) | PORTF(5, 16) | BK) +#define EMI_DATA15 (FUNC(0) | PORTF(5, 15) | BK) +#define EMI_DATA15_OFF (FUNC(3) | PORTF(5, 15) | BK) +#define EMI_DATA14 (FUNC(0) | PORTF(5, 14) | BK) +#define EMI_DATA14_OFF (FUNC(3) | PORTF(5, 14) | BK) +#define EMI_DATA13 (FUNC(0) | PORTF(5, 13) | BK) +#define EMI_DATA13_OFF (FUNC(3) | PORTF(5, 13) | BK) +#define EMI_DATA12 (FUNC(0) | PORTF(5, 12) | BK) +#define EMI_DATA12_OFF (FUNC(3) | PORTF(5, 12) | BK) +#define EMI_DATA11 (FUNC(0) | PORTF(5, 11) | BK) +#define EMI_DATA10_OFF (FUNC(3) | PORTF(5, 10) | BK) +#define EMI_DATA10 (FUNC(0) | PORTF(5, 10) | BK) +#define EMI_DATA10_OFF (FUNC(3) | PORTF(5, 10) | BK) +#define EMI_DATA9 (FUNC(0) | PORTF(5, 9) | BK) +#define EMI_DATA9_OFF (FUNC(3) | PORTF(5, 9) | BK) +#define EMI_DATA8 (FUNC(0) | PORTF(5, 8) | BK) +#define EMI_DATA8_OFF (FUNC(3) | PORTF(5, 8) | BK) +#define EMI_DATA7 (FUNC(0) | PORTF(5, 7) | BK) +#define EMI_DATA7_OFF (FUNC(3) | PORTF(5, 7) | BK) +#define EMI_DATA6 (FUNC(0) | PORTF(5, 6) | BK) +#define EMI_DATA6_OFF (FUNC(3) | PORTF(5, 6) | BK) +#define EMI_DATA5 (FUNC(0) | PORTF(5, 5) | BK) +#define EMI_DATA5_OFF (FUNC(3) | PORTF(5, 5) | BK) +#define EMI_DATA4 (FUNC(0) | PORTF(5, 4) | BK) +#define EMI_DATA4_OFF (FUNC(3) | PORTF(5, 4) | BK) +#define EMI_DATA3 (FUNC(0) | PORTF(5, 3) | BK) +#define EMI_DATA3_OFF (FUNC(3) | PORTF(5, 3) | BK) +#define EMI_DATA2 (FUNC(0) | PORTF(5, 2) | BK) +#define EMI_DATA2_OFF (FUNC(3) | PORTF(5, 2) | BK) +#define EMI_DATA1 (FUNC(0) | PORTF(5, 1) | BK) +#define EMI_DATA1_OFF (FUNC(3) | PORTF(5, 1) | BK) +#define EMI_DATA0 (FUNC(0) | PORTF(5, 0) | BK) +#define EMI_DATA0_OFF (FUNC(3) | PORTF(5, 0) | BK) + +/* + * Bank 6, GPIO pins 192 ... 223 + * Note: This pins are disabled instead of being GPIOs + */ +#define EMI_CKE (FUNC(0) | PORTF(6, 24) | BK) +#define EMI_CKE_OFF (FUNC(3) | PORTF(6, 24) | BK) +#define EMI_CE1N (FUNC(0) | PORTF(6, 23) | BK) +#define EMI_CE1N_OFF (FUNC(3) | PORTF(6, 23) | BK) +#define EMI_CE0N (FUNC(0) | PORTF(6, 22) | BK) +#define EMI_CE0N_OFF (FUNC(3) | PORTF(6, 22) | BK) +#define EMI_WEN (FUNC(0) | PORTF(6, 21) | BK) +#define EMI_WEN_OFF (FUNC(3) | PORTF(6, 21) | BK) +#define EMI_RASN (FUNC(0) | PORTF(6, 20) | BK) +#define EMI_RASN_OFF (FUNC(3) | PORTF(6, 20) | BK) +#define EMI_CASN (FUNC(0) | PORTF(6, 19) | BK) +#define EMI_CASN_OFF (FUNC(3) | PORTF(6, 19) | BK) +#define EMI_BA2 (FUNC(0) | PORTF(6, 18) | BK) +#define EMI_BA2_OFF (FUNC(3) | PORTF(6, 18) | BK) +#define EMI_BA1 (FUNC(0) | PORTF(6, 17) | BK) +#define EMI_BA1_OFF (FUNC(3) | PORTF(6, 17) | BK) +#define EMI_BA0 (FUNC(0) | PORTF(6, 16) | BK) +#define EMI_BA0_OFF (FUNC(3) | PORTF(6, 16) | BK) +#define EMI_A14 (FUNC(0) | PORTF(6, 14) | BK) +#define EMI_A14_OFF (FUNC(3) | PORTF(6, 14) | BK) +#define EMI_A13 (FUNC(0) | PORTF(6, 13) | BK) +#define EMI_A13_OFF (FUNC(3) | PORTF(6, 13) | BK) +#define EMI_A12 (FUNC(0) | PORTF(6, 12) | BK) +#define EMI_A12_OFF (FUNC(3) | PORTF(6, 12) | BK) +#define EMI_A11 (FUNC(0) | PORTF(6, 11) | BK) +#define EMI_A11_OFF (FUNC(3) | PORTF(6, 11) | BK) +#define EMI_A10 (FUNC(0) | PORTF(6, 10) | BK) +#define EMI_A10_OFF (FUNC(3) | PORTF(6, 10) | BK) +#define EMI_A9 (FUNC(0) | PORTF(6, 9) | BK) +#define EMI_A9_OFF (FUNC(3) | PORTF(6, 9) | BK) +#define EMI_A8 (FUNC(0) | PORTF(6, 8) | BK) +#define EMI_A8_OFF (FUNC(3) | PORTF(6, 8) | BK) +#define EMI_A7 (FUNC(0) | PORTF(6, 7) | BK) +#define EMI_A7_OFF (FUNC(3) | PORTF(6, 7) | BK) +#define EMI_A6 (FUNC(0) | PORTF(6, 6) | BK) +#define EMI_A6_OFF (FUNC(3) | PORTF(6, 6) | BK) +#define EMI_A5 (FUNC(0) | PORTF(6, 5) | BK) +#define EMI_A5_OFF (FUNC(3) | PORTF(6, 5) | BK) +#define EMI_A4 (FUNC(0) | PORTF(6, 4) | BK) +#define EMI_A4_OFF (FUNC(3) | PORTF(6, 4) | BK) +#define EMI_A3 (FUNC(0) | PORTF(6, 3) | BK) +#define EMI_A3_OFF (FUNC(3) | PORTF(6, 3) | BK) +#define EMI_A2 (FUNC(0) | PORTF(6, 2) | BK) +#define EMI_A2_OFF (FUNC(3) | PORTF(6, 2) | BK) +#define EMI_A1 (FUNC(0) | PORTF(6, 1) | BK) +#define EMI_A1_OFF (FUNC(3) | PORTF(6, 1) | BK) +#define EMI_A0 (FUNC(0) | PORTF(6, 0) | BK) +#define EMI_A0_OFF (FUNC(3) | PORTF(6, 0) | BK) + +#endif /* __MACH_IOMUX_IMX28_H */ diff --git a/arch/arm/mach-mxs/include/mach/mci.h b/arch/arm/mach-mxs/include/mach/mci.h new file mode 100644 index 0000000..b924908 --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/mci.h @@ -0,0 +1,32 @@ +/* + * 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 __MACH_MMC_H +#define __MACH_MMC_H + +struct stm_mci_platform_data { + unsigned caps; /**< supported operating modes (MMC_MODE_*) */ + unsigned voltages; /**< supported voltage range (MMC_VDD_*) */ + unsigned f_min; /**< min operating frequency in Hz (0 -> no limit) */ + unsigned f_max; /**< max operating frequency in Hz (0 -> no limit) */ + /* TODO */ + /* function to modify the voltage */ + /* function to switch the voltage */ + /* function to detect the presence of a SD card in the socket */ +}; + +#endif /* __MACH_MMC_H */ diff --git a/arch/arm/mach-mxs/include/mach/usb.h b/arch/arm/mach-mxs/include/mach/usb.h new file mode 100644 index 0000000..af7d885 --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/usb.h @@ -0,0 +1,6 @@ +#ifndef __MACH_USB_H +#define __MACH_USB_H + +int imx_usb_phy_enable(void); + +#endif /* __MACH_USB_H */ diff --git a/arch/arm/mach-mxs/iomux-imx.c b/arch/arm/mach-mxs/iomux-imx.c new file mode 100644 index 0000000..bf6165f --- /dev/null +++ b/arch/arm/mach-mxs/iomux-imx.c @@ -0,0 +1,201 @@ +/* + * (C) Copyright 2010 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. + * + * 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 +#include +#include +#include +#include +#include + +#define HW_PINCTRL_CTRL 0x000 +#define HW_PINCTRL_MUXSEL0 0x100 + +#ifdef CONFIG_ARCH_IMX23 +#define HW_PINCTRL_DRIVE0 0x200 +#define HW_PINCTRL_PULL0 0x400 +#define HW_PINCTRL_DOUT0 0x500 +#define HW_PINCTRL_DIN0 0x600 +#define HW_PINCTRL_DOE0 0x700 + +#define MAX_GPIO_NO 95 +#endif + +#ifdef CONFIG_ARCH_IMX28 +#define HW_PINCTRL_DRIVE0 0x300 +#define HW_PINCTRL_PULL0 0x600 +#define HW_PINCTRL_DOUT0 0x700 +#define HW_PINCTRL_DIN0 0x900 +#define HW_PINCTRL_DOE0 0xb00 + +#define MAX_GPIO_NO 159 +#endif + +static unsigned calc_mux_reg(unsigned no) +{ + /* each register controls 16 pads */ + return ((no >> 4) << 4) + HW_PINCTRL_MUXSEL0; +} + +static unsigned calc_strength_reg(unsigned no) +{ + /* each register controls 8 pads */ + return ((no >> 3) << 4) + HW_PINCTRL_DRIVE0; +} + +static unsigned calc_pullup_reg(unsigned no) +{ + /* each register controls 32 pads */ + return ((no >> 5) << 4) + HW_PINCTRL_PULL0; +} + +static unsigned calc_output_enable_reg(unsigned no) +{ + /* each register controls 32 pads */ + return ((no >> 5) << 4) + HW_PINCTRL_DOE0; +} + +static unsigned calc_output_reg(unsigned no) +{ + /* each register controls 32 pads */ + return ((no >> 5) << 4) + HW_PINCTRL_DOUT0; +} + +static unsigned calc_input_reg(unsigned no) +{ + /* each register controls 32 pads */ + return ((no >> 5) << 4) + HW_PINCTRL_DIN0; +} + +/** + * @param[in] m One pin define per call from iomux-mx23.h/iomux-mx28.h + */ +void imx_gpio_mode(uint32_t m) +{ + uint32_t reg; + unsigned gpio_pin, reg_offset; + + gpio_pin = GET_GPIO_NO(m); + + /* configure the pad to its function (always) */ + reg_offset = calc_mux_reg(gpio_pin); + reg = readl(IMX_IOMUXC_BASE + reg_offset) & ~(0x3 << ((gpio_pin % 16) << 1)); + reg |= GET_FUNC(m) << ((gpio_pin % 16) << 1); + writel(reg, IMX_IOMUXC_BASE + reg_offset); + + /* some pins are disabled when configured for GPIO */ + if ((gpio_pin > MAX_GPIO_NO) && (GET_FUNC(m) == IS_GPIO)) { + printf("Cannot configure pad %d to GPIO\n", gpio_pin); + return; + } + + if (SE_PRESENT(m)) { + reg_offset = calc_strength_reg(gpio_pin); + reg = readl(IMX_IOMUXC_BASE + reg_offset) & ~(0x3 << ((gpio_pin % 8) << 2)); + reg |= GET_STRENGTH(m) << ((gpio_pin % 8) << 2); + writel(reg, IMX_IOMUXC_BASE + reg_offset); + } + + if (VE_PRESENT(m)) { + reg_offset = calc_strength_reg(gpio_pin); + if (GET_VOLTAGE(m) == 1) + writel(0x1 << (((gpio_pin % 8) << 2) + 2), + IMX_IOMUXC_BASE + reg_offset + BIT_SET); + else + writel(0x1 << (((gpio_pin % 8) << 2) + 2), + IMX_IOMUXC_BASE + reg_offset + BIT_CLR); + } + + if (PE_PRESENT(m)) { + reg_offset = calc_pullup_reg(gpio_pin); + writel(0x1 << (gpio_pin % 32), IMX_IOMUXC_BASE + reg_offset + + (GET_PULLUP(m) == 1 ? BIT_SET : BIT_CLR)); + } + + if (GET_FUNC(m) == IS_GPIO) { + if (GET_GPIODIR(m) == 1) { + /* first set the output value */ + reg_offset = calc_output_reg(gpio_pin); + writel(0x1 << (gpio_pin % 32), IMX_IOMUXC_BASE + + reg_offset + (GET_GPIOVAL(m) == 1 ? BIT_SET : BIT_CLR)); + /* then the direction */ + reg_offset = calc_output_enable_reg(gpio_pin); + writel(0x1 << (gpio_pin % 32), + IMX_IOMUXC_BASE + reg_offset + BIT_SET); + } else { + /* then the direction */ + reg_offset = calc_output_enable_reg(gpio_pin); + writel(0x1 << (gpio_pin % 32), + IMX_IOMUXC_BASE + reg_offset + BIT_CLR); + } + } +} + +int gpio_direction_input(unsigned gpio) +{ + unsigned reg_offset; + + if (gpio > MAX_GPIO_NO) + return -EINVAL; + + reg_offset = calc_output_enable_reg(gpio); + writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + reg_offset + BIT_CLR); + + return 0; +} + +int gpio_direction_output(unsigned gpio, int val) +{ + unsigned reg_offset; + + if (gpio > MAX_GPIO_NO) + return -EINVAL; + + /* first set the output value... */ + reg_offset = calc_output_reg(gpio); + writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + + reg_offset + (val != 0 ? BIT_SET : BIT_CLR)); + /* ...then the direction */ + reg_offset = calc_output_enable_reg(gpio); + writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + reg_offset + BIT_SET); + + return 0; +} + +void gpio_set_value(unsigned gpio, int val) +{ + unsigned reg_offset; + + reg_offset = calc_output_reg(gpio); + writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + + reg_offset + (val != 0 ? BIT_SET : BIT_CLR)); +} + +int gpio_get_value(unsigned gpio) +{ + uint32_t reg; + unsigned reg_offset; + + reg_offset = calc_input_reg(gpio); + reg = readl(IMX_IOMUXC_BASE + reg_offset); + if (reg & (0x1 << (gpio % 32))) + return 1; + + return 0; +} diff --git a/arch/arm/mach-mxs/reset-imx.c b/arch/arm/mach-mxs/reset-imx.c new file mode 100644 index 0000000..b35f796 --- /dev/null +++ b/arch/arm/mach-mxs/reset-imx.c @@ -0,0 +1,61 @@ +/* + * (C) Copyright 2010 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. + * + * 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 +#include +#include +#include +#include + +#define HW_RTC_CTRL 0x000 +# define BM_RTC_CTRL_WATCHDOGEN (1 << 4) +#define HW_RTC_CTRL_SET 0x004 +#define HW_RTC_CTRL_CLR 0x008 +#define HW_RTC_CTRL_TOG 0x00C + +#define HW_RTC_WATCHDOG 0x050 +#define HW_RTC_WATCHDOG_SET 0x054 +#define HW_RTC_WATCHDOG_CLR 0x058 +#define HW_RTC_WATCHDOG_TOG 0x05C + +#define WDOG_COUNTER_RATE 1000 /* 1 kHz clock */ + +#define HW_RTC_PERSISTENT1 0x070 +# define BV_RTC_PERSISTENT1_GENERAL__RTC_FORCE_UPDATER 0x80000000 +#define HW_RTC_PERSISTENT1_SET 0x074 +#define HW_RTC_PERSISTENT1_CLR 0x078 +#define HW_RTC_PERSISTENT1_TOG 0x07C + +/* + * Reset the cpu by setting up the watchdog timer and let it time out + * + * TODO There is a much easier way to reset the CPU: Refer bit 2 in + * the HW_CLKCTRL_RESET register, data sheet page 106/4-30 + */ +void __noreturn reset_cpu (unsigned long addr) +{ + writel(WDOG_COUNTER_RATE, IMX_WDT_BASE + HW_RTC_WATCHDOG); + writel(BM_RTC_CTRL_WATCHDOGEN, IMX_WDT_BASE + HW_RTC_CTRL_SET); + writel(BV_RTC_PERSISTENT1_GENERAL__RTC_FORCE_UPDATER, IMX_WDT_BASE + HW_RTC_PERSISTENT1); + + while (1) + ; + /*NOTREACHED*/ +} +EXPORT_SYMBOL(reset_cpu); diff --git a/arch/arm/mach-mxs/speed-imx23.c b/arch/arm/mach-mxs/speed-imx23.c new file mode 100644 index 0000000..a31139d --- /dev/null +++ b/arch/arm/mach-mxs/speed-imx23.c @@ -0,0 +1,278 @@ +/* + * (C) Copyright 2010 Juergen Beisert - Pengutronix + * + * This code is based partially on code of: + * + * (c) 2008 Embedded Alley Solutions, Inc. + * (C) Copyright 2009-2010 Freescale Semiconductor, 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 + */ + +#include +#include +#include +#include +#include +#include + +#define HW_CLKCTRL_PLLCTRL0 0x000 +#define HW_CLKCTRL_PLLCTRL1 0x010 +#define HW_CLKCTRL_CPU 0x20 +# define GET_CPU_XTAL_DIV(x) (((x) >> 16) & 0x3ff) +# define GET_CPU_PLL_DIV(x) ((x) & 0x3f) +#define HW_CLKCTRL_HBUS 0x30 +#define HW_CLKCTRL_XBUS 0x40 +#define HW_CLKCTRL_XTAL 0x050 +#define HW_CLKCTRL_PIX 0x060 +/* note: no set/clear register! */ +#define HW_CLKCTRL_SSP 0x070 +/* note: no set/clear register! */ +# define CLKCTRL_SSP_CLKGATE (1 << 31) +# define CLKCTRL_SSP_BUSY (1 << 29) +# define CLKCTRL_SSP_DIV_MASK 0x1ff +# define GET_SSP_DIV(x) ((x) & CLKCTRL_SSP_DIV_MASK) +# define SET_SSP_DIV(x) ((x) & CLKCTRL_SSP_DIV_MASK) +#define HW_CLKCTRL_GPMI 0x080 +/* note: no set/clear register! */ +#define HW_CLKCTRL_SPDIF 0x090 +/* note: no set/clear register! */ +#define HW_CLKCTRL_EMI 0xa0 +/* note: no set/clear register! */ +# define CLKCTRL_EMI_CLKGATE (1 << 31) +# define GET_EMI_XTAL_DIV(x) (((x) >> 8) & 0xf) +# define GET_EMI_PLL_DIV(x) ((x) & 0x3f) +#define HW_CLKCTRL_SAIF 0x0c0 +#define HW_CLKCTRL_TV 0x0d0 +#define HW_CLKCTRL_ETM 0x0e0 +#define HW_CLKCTRL_FRAC 0xf0 +# define CLKCTRL_FRAC_CLKGATEIO (1 << 31) +# define GET_IOFRAC(x) (((x) >> 24) & 0x3f) +# define SET_IOFRAC(x) (((x) & 0x3f) << 24) +# define CLKCTRL_FRAC_CLKGATEPIX (1 << 23) +# define GET_PIXFRAC(x) (((x) >> 16) & 0x3f) +# define CLKCTRL_FRAC_CLKGATEEMI (1 << 15) +# define GET_EMIFRAC(x) (((x) >> 8) & 0x3f) +# define CLKCTRL_FRAC_CLKGATECPU (1 << 7) +# define GET_CPUFRAC(x) ((x) & 0x3f) +#define HW_CLKCTRL_FRAC1 0x100 +#define HW_CLKCTRL_CLKSEQ 0x110 +# define CLKCTRL_CLKSEQ_BYPASS_ETM (1 << 8) +# define CLKCTRL_CLKSEQ_BYPASS_CPU (1 << 7) +# define CLKCTRL_CLKSEQ_BYPASS_EMI (1 << 6) +# define CLKCTRL_CLKSEQ_BYPASS_SSP (1 << 5) +# define CLKCTRL_CLKSEQ_BYPASS_GPMI (1 << 4) +#define HW_CLKCTRL_RESET 0x120 +#define HW_CLKCTRL_STATUS 0x130 +#define HW_CLKCTRL_VERSION 0x140 + +unsigned imx_get_mpllclk(void) +{ + /* the main PLL runs at 480 MHz */ + return 480000000; +} + +unsigned imx_get_xtalclk(void) +{ + /* the external reference runs at 24 MHz */ + return 24000000; +} + +/* used for the SDRAM controller */ +unsigned imx_get_emiclk(void) +{ + uint32_t reg; + unsigned rate; + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_EMI) & CLKCTRL_EMI_CLKGATE) + return 0U; /* clock is off */ + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & CLKCTRL_CLKSEQ_BYPASS_EMI) + return imx_get_xtalclk() / GET_EMI_XTAL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_EMI)); + + rate = imx_get_mpllclk() / 1000; + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC); + if (!(reg & CLKCTRL_FRAC_CLKGATEEMI)) { + rate *= 18U; + rate /= GET_EMIFRAC(reg); + } + + return (rate / GET_EMI_PLL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_EMI))) + * 1000; +} + +/* + * Source of ssp, gpmi, ir + */ +unsigned imx_get_ioclk(void) +{ + uint32_t reg; + unsigned rate = imx_get_mpllclk() / 1000; + + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC); + if (reg & CLKCTRL_FRAC_CLKGATEIO) + return 0U; /* clock is off */ + + rate *= 18U; + rate /= GET_IOFRAC(reg); + return rate * 1000; +} + +/** + * Setup a new frequency to the IOCLK domain. + * @param nc New frequency in [Hz] + * + * The FRAC divider for the IOCLK must be between 18 (* 18/18) and 35 (* 18/35) + */ +unsigned imx_set_ioclk(unsigned nc) +{ + uint32_t reg; + unsigned div; + + nc /= 1000; + div = (imx_get_mpllclk() / 1000) * 18; + div = DIV_ROUND_CLOSEST(div, nc); + if (div > 0x3f) + div = 0x3f; + /* mask the current settings */ + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC) & ~(SET_IOFRAC(0x3f)); + writel(reg | SET_IOFRAC(div), IMX_CCM_BASE + HW_CLKCTRL_FRAC); + /* enable the IO clock at its new frequency */ + writel(CLKCTRL_FRAC_CLKGATEIO, IMX_CCM_BASE + HW_CLKCTRL_FRAC + 8); + + return imx_get_ioclk(); +} + +/* this is CPU core clock */ +unsigned imx_get_armclk(void) +{ + uint32_t reg; + unsigned rate; + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & CLKCTRL_CLKSEQ_BYPASS_CPU) + return imx_get_xtalclk() / GET_CPU_XTAL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_CPU)); + + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC); + if (reg & CLKCTRL_FRAC_CLKGATECPU) + return 0U; /* should not possible, shouldn't it? */ + + rate = imx_get_mpllclk() / 1000; + rate *= 18U; + rate /= GET_CPUFRAC(reg); + + return (rate / GET_CPU_PLL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_CPU))) + * 1000; +} + +/* this is the AHB and APBH bus clock */ +unsigned imx_get_hclk(void) +{ + unsigned rate = imx_get_armclk() / 1000; + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x20) { + rate *= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f; + rate >>= 5U; /* / 32 */ + } else + rate /= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f; + return rate * 1000; +} + +/* + * Source of UART, debug UART, audio, PWM, dri, timer, digctl + */ +unsigned imx_get_xclk(void) +{ + unsigned rate = imx_get_xtalclk(); /* runs from the 24 MHz crystal reference */ + + return rate / (readl(IMX_CCM_BASE + HW_CLKCTRL_XBUS) & 0x3ff); +} + +/* 'index' gets ignored on i.MX23 */ +unsigned imx_get_sspclk(unsigned index) +{ + unsigned rate; + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_SSP) & CLKCTRL_SSP_CLKGATE) + return 0U; /* clock is off */ + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & CLKCTRL_CLKSEQ_BYPASS_SSP) + rate = imx_get_xtalclk(); + else + rate = imx_get_ioclk(); + + return rate / GET_SSP_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_SSP)); +} + +/** + * @param index Unit index (ignored on i.MX23) + * @param nc New frequency in [Hz] + * @param high != 0 if ioclk should be the source + * @return The new possible frequency in [kHz] + */ +unsigned imx_set_sspclk(unsigned index, unsigned nc, int high) +{ + uint32_t reg; + unsigned ssp_div; + + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_SSP) & ~CLKCTRL_SSP_CLKGATE; + /* Datasheet says: Do not change the DIV setting if the clock is off */ + writel(reg, IMX_CCM_BASE + HW_CLKCTRL_SSP); + /* Wait while clock is gated */ + while (readl(IMX_CCM_BASE + HW_CLKCTRL_SSP) & CLKCTRL_SSP_CLKGATE) + ; + + if (high) + ssp_div = imx_get_ioclk(); + else + ssp_div = imx_get_xtalclk(); + + if (nc > ssp_div) { + printf("Cannot setup SSP unit clock to %u Hz, base clock is only %u Hz\n", nc, ssp_div); + ssp_div = 1U; + } else { + ssp_div = DIV_ROUND_UP(ssp_div, nc); + if (ssp_div > CLKCTRL_SSP_DIV_MASK) + ssp_div = CLKCTRL_SSP_DIV_MASK; + } + + /* Set new divider value */ + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_SSP) & ~CLKCTRL_SSP_DIV_MASK; + writel(reg | SET_SSP_DIV(ssp_div), IMX_CCM_BASE + HW_CLKCTRL_SSP); + + /* Wait until new divider value is set */ + while (readl(IMX_CCM_BASE + HW_CLKCTRL_SSP) & CLKCTRL_SSP_BUSY) + ; + + if (high) + /* switch to ioclock */ + writel(CLKCTRL_CLKSEQ_BYPASS_SSP, IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ + 8); + else + /* switch to 24 MHz crystal */ + writel(CLKCTRL_CLKSEQ_BYPASS_SSP, IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ + 4); + + return imx_get_sspclk(index); +} + +void imx_dump_clocks(void) +{ + printf("mpll: %10u kHz\n", imx_get_mpllclk() / 1000); + printf("arm: %10u kHz\n", imx_get_armclk() / 1000); + printf("ioclk: %10u kHz\n", imx_get_ioclk() / 1000); + printf("emiclk: %10u kHz\n", imx_get_emiclk() / 1000); + printf("hclk: %10u kHz\n", imx_get_hclk() / 1000); + printf("xclk: %10u kHz\n", imx_get_xclk() / 1000); + printf("ssp: %10u kHz\n", imx_get_sspclk(0) / 1000); +} diff --git a/arch/arm/mach-mxs/speed-imx28.c b/arch/arm/mach-mxs/speed-imx28.c new file mode 100644 index 0000000..63c6b07 --- /dev/null +++ b/arch/arm/mach-mxs/speed-imx28.c @@ -0,0 +1,392 @@ +/* + * (C) Copyright 2010 Juergen Beisert - Pengutronix + * + * This code is based partially on code that has: + * + * (c) 2008 Embedded Alley Solutions, Inc. + * (C) Copyright 2009-2010 Freescale Semiconductor, 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. + */ +#include +#include +#include +#include +#include +#include + +#define HW_CLKCTRL_PLL0CTRL0 0x000 +#define HW_CLKCTRL_PLL0CTRL1 0x010 +#define HW_CLKCTRL_PLL1CTRL0 0x020 +#define HW_CLKCTRL_PLL1CTRL1 0x030 +#define HW_CLKCTRL_PLL2CTRL0 0x040 +# define CLKCTRL_PLL2CTRL0_CLKGATE (1 << 31) +# define CLKCTRL_PLL2CTRL0_POWER (1 << 23) +#define HW_CLKCTRL_CPU 0x50 +# define GET_CPU_XTAL_DIV(x) (((x) >> 16) & 0x3ff) +# define GET_CPU_PLL_DIV(x) ((x) & 0x3f) +#define HW_CLKCTRL_HBUS 0x60 +#define HW_CLKCTRL_XBUS 0x70 +#define HW_CLKCTRL_XTAL 0x080 +#define HW_CLKCTRL_SSP0 0x090 +#define HW_CLKCTRL_SSP1 0x0a0 +#define HW_CLKCTRL_SSP2 0x0b0 +#define HW_CLKCTRL_SSP3 0x0c0 +/* note: no set/clear register! */ +# define CLKCTRL_SSP_CLKGATE (1 << 31) +# define CLKCTRL_SSP_BUSY (1 << 29) +# define CLKCTRL_SSP_DIV_FRAC_EN (1 << 9) +# define CLKCTRL_SSP_DIV_MASK 0x1ff +# define GET_SSP_DIV(x) ((x) & CLKCTRL_SSP_DIV_MASK) +# define SET_SSP_DIV(x) ((x) & CLKCTRL_SSP_DIV_MASK) +#define HW_CLKCTRL_GPMI 0x0d0 +/* note: no set/clear register! */ +#define HW_CLKCTRL_SPDIF 0x0e0 +/* note: no set/clear register! */ +#define HW_CLKCTRL_EMI 0xf0 +/* note: no set/clear register! */ +# define CLKCTRL_EMI_CLKGATE (1 << 31) +# define GET_EMI_XTAL_DIV(x) (((x) >> 8) & 0xf) +# define GET_EMI_PLL_DIV(x) ((x) & 0x3f) +#define HW_CLKCTRL_SAIF0 0x100 +#define HW_CLKCTRL_SAIF1 0x110 +#define HW_CLKCTRL_DIS_LCDIF 0x120 +# define CLKCTRL_DIS_LCDIF_GATE (1 << 31) +# define CLKCTRL_DIS_LCDIF_BUSY (1 << 29) +# define SET_DIS_LCDIF_DIV(x) ((x) & 0x1fff) +# define GET_DIS_LCDIF_DIV(x) ((x) & 0x1fff) +#define HW_CLKCTRL_ETM 0x130 +#define HW_CLKCTRL_ENET 0x140 +# define SET_CLKCTRL_ENET_DIV(x) (((x) & 0x3f) << 21) +# define SET_CLKCTRL_ENET_SEL(x) (((x) & 0x3) << 19) +# define CLKCTRL_ENET_CLK_OUT_EN (1 << 18) +#define HW_CLKCTRL_HSADC 0x150 +#define HW_CLKCTRL_FLEXCAN 0x160 +#define HW_CLKCTRL_FRAC0 0x1b0 +# define CLKCTRL_FRAC_CLKGATEIO0 (1 << 31) +# define GET_IO0FRAC(x) (((x) >> 24) & 0x3f) +# define SET_IO0FRAC(x) (((x) & 0x3f) << 24) +# define CLKCTRL_FRAC_CLKGATEIO1 (1 << 23) +# define GET_IO1FRAC(x) (((x) >> 16) & 0x3f) +# define SET_IO1FRAC(x) (((x) & 0x3f) << 16) +# define CLKCTRL_FRAC_CLKGATEEMI (1 << 15) +# define GET_EMIFRAC(x) (((x) >> 8) & 0x3f) +# define CLKCTRL_FRAC_CLKGATECPU (1 << 7) +# define GET_CPUFRAC(x) ((x) & 0x3f) +#define HW_CLKCTRL_FRAC1 0x1c0 +# define CLKCTRL_FRAC_CLKGATEGPMI (1 << 23) +# define GET_GPMIFRAC(x) (((x) >> 16) & 0x3f) +# define CLKCTRL_FRAC_CLKGATEHSADC (1 << 15) +# define GET_HSADCFRAC(x) (((x) >> 8) & 0x3f) +# define CLKCTRL_FRAC_CLKGATEPIX (1 << 7) +# define GET_PIXFRAC(x) ((x) & 0x3f) +# define SET_PIXFRAC(x) ((x) & 0x3f) +#define HW_CLKCTRL_CLKSEQ 0x1d0 +# define CLKCTRL_CLKSEQ_BYPASS_CPU (1 << 18) +# define CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF (1 << 14) +# define CLKCTRL_CLKSEQ_BYPASS_ETM (1 << 8) +# define CLKCTRL_CLKSEQ_BYPASS_EMI (1 << 7) +# define CLKCTRL_CLKSEQ_BYPASS_SSP3 (1 << 6) +# define CLKCTRL_CLKSEQ_BYPASS_SSP2 (1 << 5) +# define CLKCTRL_CLKSEQ_BYPASS_SSP1 (1 << 4) +# define CLKCTRL_CLKSEQ_BYPASS_SSP0 (1 << 3) +# define CLKCTRL_CLKSEQ_BYPASS_GPMI (1 << 2) +# define CLKCTRL_CLKSEQ_BYPASS_SAIF1 (1 << 1) +# define CLKCTRL_CLKSEQ_BYPASS_SAIF0 (1 << 0) +#define HW_CLKCTRL_RESET 0x1e0 +#define HW_CLKCTRL_STATUS 0x1f0 +#define HW_CLKCTRL_VERSION 0x200 + +unsigned imx_get_mpllclk(void) +{ + /* the main PLL runs at 480 MHz */ + return 480000000; +} + +unsigned imx_get_xtalclk(void) +{ + /* the external reference runs at 24 MHz */ + return 24000000; +} + +unsigned imx_get_fecclk(void) +{ + /* this PLL always runs at 50 MHz */ + return 50000000; +} + + +/* used for the SDRAM controller */ +unsigned imx_get_emiclk(void) +{ + uint32_t reg; + unsigned rate; + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_EMI) & CLKCTRL_EMI_CLKGATE) + return 0; /* clock is off */ + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & CLKCTRL_CLKSEQ_BYPASS_EMI) + return imx_get_xtalclk() / + GET_EMI_XTAL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_EMI)); + + rate = imx_get_mpllclk() / 1000; + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC0); + if (!(reg & CLKCTRL_FRAC_CLKGATEEMI)) { + rate *= 18; + rate /= GET_EMIFRAC(reg); + } + + return (rate / GET_EMI_PLL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_EMI))) + * 1000; +} + +/* + * Source of ssp, gpmi, ir + * @param index 0 or 1 for ioclk0 or ioclock1 + */ +unsigned imx_get_ioclk(unsigned index) +{ + uint32_t reg; + unsigned rate = imx_get_mpllclk() / 1000; + + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC0); + switch (index) { + case 0: + if (reg & CLKCTRL_FRAC_CLKGATEIO0) + return 0; /* clock is off */ + + rate *= 18; + rate /= GET_IO0FRAC(reg); + break; + case 1: + if (reg & CLKCTRL_FRAC_CLKGATEIO1) + return 0; /* clock is off */ + + rate *= 18; + rate /= GET_IO1FRAC(reg); + break; + } + + return rate * 1000; +} + +/** + * Setup a new frequency to the IOCLK domain. + * @param index 0 or 1 for ioclk0 or ioclock1 + * @param nc New frequency in [Hz] + * + * The FRAC divider for the IOCLK must be between 18 (* 18/18) and 35 (* 18/35) + * + * ioclock0 is the shared clock source of SSP0/SSP1, ioclock1 the shared clock + * source of SSP2/SSP3 + */ +unsigned imx_set_ioclk(unsigned index, unsigned nc) +{ + uint32_t reg; + unsigned div; + + nc /= 1000; + div = (imx_get_mpllclk() / 1000) * 18; + div = DIV_ROUND_CLOSEST(div, nc); + if (div > 0x3f) + div = 0x3f; + + switch (index) { + case 0: + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC0) & + ~(SET_IO0FRAC(0x3f)); + /* mask the current settings */ + writel(reg | SET_IO0FRAC(div), IMX_CCM_BASE + HW_CLKCTRL_FRAC0); + /* enable the IO clock at its new frequency */ + writel(CLKCTRL_FRAC_CLKGATEIO0, + IMX_CCM_BASE + HW_CLKCTRL_FRAC0 + BIT_CLR); + break; + case 1: + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC0) & + ~(SET_IO1FRAC(0x3f)); + /* mask the current settings */ + writel(reg | SET_IO1FRAC(div), IMX_CCM_BASE + HW_CLKCTRL_FRAC0); + /* enable the IO clock at its new frequency */ + writel(CLKCTRL_FRAC_CLKGATEIO1, + IMX_CCM_BASE + HW_CLKCTRL_FRAC0 + BIT_CLR); + break; + } + + return imx_get_ioclk(index); +} + +/* this is CPU core clock */ +unsigned imx_get_armclk(void) +{ + uint32_t reg; + unsigned rate; + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & CLKCTRL_CLKSEQ_BYPASS_CPU) + return imx_get_xtalclk() / + GET_CPU_XTAL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_CPU)); + + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC0); + if (reg & CLKCTRL_FRAC_CLKGATECPU) + return 0; /* should not possible, shouldn't it? */ + + rate = (imx_get_mpllclk() / 1000) * 18; + rate /= GET_CPUFRAC(reg); + + return (rate / GET_CPU_PLL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_CPU))) + * 1000; +} + +/* this is the AHB and APBH bus clock */ +unsigned imx_get_hclk(void) +{ + unsigned rate = imx_get_armclk() / 1000; + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x20) { + rate *= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f; + rate /= 32; + } else + rate /= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f; + return rate * 1000; +} + +/* + * Source of UART, debug UART, audio, PWM, dri, timer, digctl + */ +unsigned imx_get_xclk(void) +{ + /* runs from the 24 MHz crystal reference */ + unsigned rate = imx_get_xtalclk(); + + return rate / (readl(IMX_CCM_BASE + HW_CLKCTRL_XBUS) & 0x3ff); +} + +/** + * @param index The SSP unit (0...3) + */ +unsigned imx_get_sspclk(unsigned index) +{ + unsigned rate, offset, shift, ioclk_index; + + if (index > 3) { + pr_debug("Unknown SSP unit: %u\n", index); + return 0; + } + + ioclk_index = index >> 1; + + offset = HW_CLKCTRL_SSP0 + (0x10 * index); + shift = CLKCTRL_CLKSEQ_BYPASS_SSP0 << index; + + if (readl(IMX_CCM_BASE + offset) & CLKCTRL_SSP_CLKGATE) + return 0; /* clock is off */ + + if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & shift) + rate = imx_get_xtalclk(); + else + rate = imx_get_ioclk(ioclk_index); + + return rate / GET_SSP_DIV(readl(IMX_CCM_BASE + offset)); +} + +/** + * @param index The SSP unit (0...3) + * @param nc New frequency in [Hz] + * @param high != 0 if ioclk should be the source + * @return The new possible frequency + */ +unsigned imx_set_sspclk(unsigned index, unsigned nc, int high) +{ + uint32_t reg; + unsigned ssp_div, offset, shift, ioclk_index; + + if (index > 3) { + pr_debug("Unknown SSP unit: %u\n", index); + return 0; + } + + ioclk_index = index >> 1; + + offset = HW_CLKCTRL_SSP0 + (0x10 * index); + shift = CLKCTRL_CLKSEQ_BYPASS_SSP0 << index; + + reg = readl(IMX_CCM_BASE + offset) & ~CLKCTRL_SSP_CLKGATE; + /* Datasheet says: Do not change the DIV setting if the clock is off */ + writel(reg, IMX_CCM_BASE + offset); + /* Wait while clock is gated */ + while (readl(IMX_CCM_BASE + offset) & CLKCTRL_SSP_CLKGATE) + ; + + if (high) + ssp_div = imx_get_ioclk(ioclk_index); + else + ssp_div = imx_get_xtalclk(); + + if (nc > ssp_div) { + printf("Cannot setup SSP unit clock to %u kHz, base clock is " + "only %u kHz\n", nc, ssp_div); + ssp_div = 1; + } else { + ssp_div = DIV_ROUND_UP(ssp_div, nc); + if (ssp_div > CLKCTRL_SSP_DIV_MASK) + ssp_div = CLKCTRL_SSP_DIV_MASK; + } + + /* Set new divider value */ + reg = readl(IMX_CCM_BASE + offset) & ~CLKCTRL_SSP_DIV_MASK; + writel(reg | SET_SSP_DIV(ssp_div), IMX_CCM_BASE + offset); + + /* Wait until new divider value is set */ + while (readl(IMX_CCM_BASE + offset) & CLKCTRL_SSP_BUSY) + ; + + if (high) + /* switch to ioclock */ + writel(shift, IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ + BIT_CLR); + else + /* switch to 24 MHz crystal */ + writel(shift, IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ + BIT_SET); + + return imx_get_sspclk(index); +} + +void imx_enable_enetclk(void) +{ + uint32_t reg; + + /* wake up main enet PLL */ + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_PLL2CTRL0); + if (!(reg & CLKCTRL_PLL2CTRL0_POWER)) { + reg |= CLKCTRL_PLL2CTRL0_POWER; + writel(reg, IMX_CCM_BASE + HW_CLKCTRL_PLL2CTRL0); + udelay(50); /* wait until this PLL locks */ + } + reg &= ~CLKCTRL_PLL2CTRL0_CLKGATE; + writel(reg, IMX_CCM_BASE + HW_CLKCTRL_PLL2CTRL0); + + writel(SET_CLKCTRL_ENET_DIV(1) | SET_CLKCTRL_ENET_SEL(0) | + CLKCTRL_ENET_CLK_OUT_EN, /* FIXME may be platform specific */ + IMX_CCM_BASE + HW_CLKCTRL_ENET); +} + +void imx_dump_clocks(void) +{ + printf("mpll: %10u kHz\n", imx_get_mpllclk() / 1000); + printf("arm: %10u kHz\n", imx_get_armclk() / 1000); + printf("ioclk0: %10u kHz\n", imx_get_ioclk(0) / 1000); + printf("ioclk1: %10u kHz\n", imx_get_ioclk(1) / 1000); + printf("emiclk: %10u kHz\n", imx_get_emiclk() / 1000); + printf("hclk: %10u kHz\n", imx_get_hclk() / 1000); + printf("xclk: %10u kHz\n", imx_get_xclk() / 1000); + printf("ssp0: %10u kHz\n", imx_get_sspclk(0) / 1000); + printf("ssp1: %10u kHz\n", imx_get_sspclk(1) / 1000); + printf("ssp2: %10u kHz\n", imx_get_sspclk(2) / 1000); + printf("ssp3: %10u kHz\n", imx_get_sspclk(3) / 1000); +} diff --git a/arch/arm/mach-mxs/usb.c b/arch/arm/mach-mxs/usb.c new file mode 100644 index 0000000..d232bb6 --- /dev/null +++ b/arch/arm/mach-mxs/usb.c @@ -0,0 +1,92 @@ +/* + * i.MX23/28 USBPHY setup + * + * Copyright 2011 Sascha Hauer, 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. + * + * 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 +#include +#include + +#define POWER_CTRL (IMX_POWER_BASE + 0x0) +#define POWER_CTRL_CLKGATE 0x40000000 + +#define POWER_STS (IMX_POWER_BASE + 0xc0) +#define POWER_STS_VBUSVALID 0x00000002 +#define POWER_STS_BVALID 0x00000004 +#define POWER_STS_AVALID 0x00000008 + +#define POWER_DEBUG (IMX_POWER_BASE + 0x110) +#define POWER_DEBUG_BVALIDPIOLOCK 0x00000002 +#define POWER_DEBUG_AVALIDPIOLOCK 0x00000004 +#define POWER_DEBUG_VBUSVALIDPIOLOCK 0x00000008 + +#define USBPHY_PWD (IMX_USBPHY_BASE + 0x0) + +#define USBPHY_CTRL (IMX_USBPHY_BASE + 0x30) +#define USBPHY_CTRL_SFTRST 0x80000000 +#define USBPHY_CTRL_CLKGATE 0x40000000 + +#define CLK_PLLCTRL0 (IMX_CCM_BASE + 0x0) +#define PLLCTRL0_EN_USB_CLKS 0x00040000 + +#define DIGCTRL_CTRL (IMX_DIGCTL_BASE + 0x0) +#define DIGCTL_CTRL_USB_CLKGATE 0x00000004 + +#define SET 0x4 +#define CLR 0x8 + +int imx_usb_phy_enable(void) +{ + u32 reg; + + /* + * Set these bits so that we can force the OTG bits high + * so the ARC core operates properly + */ + writel(POWER_CTRL_CLKGATE, POWER_CTRL + CLR); + + writel(POWER_DEBUG_VBUSVALIDPIOLOCK | + POWER_DEBUG_AVALIDPIOLOCK | + POWER_DEBUG_BVALIDPIOLOCK, POWER_DEBUG + SET); + + reg = readl(POWER_STS); + reg |= POWER_STS_BVALID | POWER_STS_AVALID | POWER_STS_VBUSVALID; + writel(reg, POWER_STS); + + /* Reset USBPHY module */ + writel(USBPHY_CTRL_SFTRST, USBPHY_CTRL + SET); + udelay(10); + + /* Remove CLKGATE and SFTRST */ + writel(USBPHY_CTRL_CLKGATE | USBPHY_CTRL_SFTRST, USBPHY_CTRL + CLR); + + /* Turn on the USB clocks */ + writel(PLLCTRL0_EN_USB_CLKS, CLK_PLLCTRL0 + SET); + writel(DIGCTL_CTRL_USB_CLKGATE, DIGCTRL_CTRL + CLR); + + /* Power up the PHY */ + writel(0, USBPHY_PWD); + + /* + * Set precharge bit to cure overshoot problems at the + * start of packets + */ + writel(1, USBPHY_CTRL + SET); + + return 0; +} + diff --git a/arch/arm/mach-stm/Kconfig b/arch/arm/mach-stm/Kconfig deleted file mode 100644 index e47d9f1..0000000 --- a/arch/arm/mach-stm/Kconfig +++ /dev/null @@ -1,84 +0,0 @@ -if ARCH_STM - -config ARCH_TEXT_BASE - hex - default 0x41000000 if MACH_MX23EVK - default 0x42000000 if MACH_CHUMBY - default 0x47000000 if MACH_TX28 - -config BOARDINFO - default "Freescale i.MX23-EVK" if MACH_MX23EVK - default "Chumby Falconwing" if MACH_CHUMBY - default "Karo TX28" if MACH_TX28 - -comment "SigmaTel/Freescale i.MX System-on-Chip" - -choice - prompt "Freescale i.MX Processor" - -config ARCH_IMX23 - bool "i.MX23" - select CPU_ARM926T - -config ARCH_IMX28 - bool "i.MX28" - select CPU_ARM926T - select ARCH_HAS_FEC_IMX - -endchoice - -if ARCH_IMX23 - -choice - prompt "i.MX23 Board Type" - -config MACH_MX23EVK - bool "mx23-evk" - help - Say Y here if you are using the Freescale i.MX23-EVK board - -config MACH_CHUMBY - bool "Chumby Falconwing" - select HAVE_MMU - help - Say Y here if you are using the "chumby one" aka falconwing from - Chumby Industries - -endchoice - -endif - -if ARCH_IMX28 - -choice - prompt "i.MX28 Board Type" - -config MACH_TX28 - bool "KARO tx28" - help - Say Y here if you are using the KARO TX28 CPU module. - -endchoice - -endif - -menu "Board specific settings " - -if MACH_TX28 - -choice - prompt "TX28 Base Board Type" - -config MACH_TX28STK5 - bool "TX28-stk5" - help - Select this entry if you are running the TX28 CPU module on the - KARO TX28 Starterkit5. - -endchoice - -endif - -endmenu - -endif diff --git a/arch/arm/mach-stm/Makefile b/arch/arm/mach-stm/Makefile deleted file mode 100644 index 0ff8fd1..0000000 --- a/arch/arm/mach-stm/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -obj-y += imx.o iomux-imx.o reset-imx.o -obj-$(CONFIG_DRIVER_VIDEO_STM) += imx_lcd_clk.o -obj-$(CONFIG_ARCH_IMX23) += speed-imx23.o clocksource-imx23.o -obj-$(CONFIG_ARCH_IMX28) += speed-imx28.o clocksource-imx28.o diff --git a/arch/arm/mach-stm/clocksource-imx23.c b/arch/arm/mach-stm/clocksource-imx23.c deleted file mode 100644 index f7c94c1..0000000 --- a/arch/arm/mach-stm/clocksource-imx23.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * (C) Copyright 2010 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. - * - * 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 -#include -#include -#include -#include -#include -#include - -#define TIMROTCTRL 0x00 -#define TIMCTRL1 0x40 -#define TIMCTRL1_SET 0x44 -#define TIMCTRL1_CLR 0x48 -#define TIMCTRL1_TOG 0x4c -# define TIMCTRL_RELOAD (1 << 6) -# define TIMCTRL_UPDATE (1 << 7) -# define TIMCTRL_PRESCALE(x) ((x & 0x3) << 4) -# define TIMCTRL_SELECT(x) (x & 0xf) -#define TIMCOUNT1 0x50 - -static const unsigned long timer_base = IMX_TIM1_BASE; - -#define CLOCK_TICK_RATE (32000) - -static uint64_t imx23_clocksource_read(void) -{ - /* only the upper bits are the valid */ - return ~(readl(timer_base + TIMCOUNT1) >> 16); -} - -static struct clocksource cs = { - .read = imx23_clocksource_read, - .mask = CLOCKSOURCE_MASK(16), - .shift = 10, -}; - -static int imx23_clocksource_clock_change(struct notifier_block *nb, unsigned long event, void *data) -{ - cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE/*imx_get_xclk()*/, cs.shift); - return 0; -} - -static struct notifier_block imx23_clock_notifier = { - .notifier_call = imx23_clocksource_clock_change, -}; - -static int clocksource_init(void) -{ - /* enable the whole timer block */ - writel(0x3e000000, timer_base + TIMROTCTRL); - /* setup general purpose timer 1 */ - writel(0x00000000, timer_base + TIMCTRL1); - writel(TIMCTRL_UPDATE, timer_base + TIMCTRL1); - writel(0x0000ffff, timer_base + TIMCOUNT1); - - writel(TIMCTRL_UPDATE | TIMCTRL_RELOAD | TIMCTRL_PRESCALE(0) | TIMCTRL_SELECT(8), timer_base + TIMCTRL1); - cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE/*imx_get_xclk()*/, cs.shift); - init_clock(&cs); - - clock_register_client(&imx23_clock_notifier); - return 0; -} - -core_initcall(clocksource_init); diff --git a/arch/arm/mach-stm/clocksource-imx28.c b/arch/arm/mach-stm/clocksource-imx28.c deleted file mode 100644 index 15ae951..0000000 --- a/arch/arm/mach-stm/clocksource-imx28.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * (C) Copyright 2010 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 -#include -#include -#include -#include -#include -#include - -#define TIMROTCTRL 0x00 -# define TIMROTCTRL_SFTRST -# define TIMROTCTRL_CLKGATE -# define TIMROTCTRL_DIVIDER(x) ((x & 0x3f) << 16) - -#define TIMCTRL1 0x60 -#define TIMCTRL1_SET 0x64 -#define TIMCTRL1_CLR 0x68 -#define TIMCTRL1_TOG 0x6c -# define TIMCTRL_RELOAD (1 << 6) -# define TIMCTRL_UPDATE (1 << 7) -# define TIMCTRL_PRESCALE(x) ((x & 0x3) << 4) -# define TIMCTRL_SELECT(x) (x & 0xf) -#define TIMCOUNT1 0x70 -#define TIMFIX1 0x80 - -static const void __iomem * timer_base = (void *)IMX_TIM1_BASE; - -/* we are using the 32 kHz reference */ -#define CLOCK_TICK_RATE 32000 - -static uint64_t imx28_clocksource_read(void) -{ - return ~(readl(timer_base + TIMCOUNT1)); -} - -static struct clocksource imx28_cs = { - .read = imx28_clocksource_read, - .mask = CLOCKSOURCE_MASK(32), - .shift = 17, -}; - -static int imx28_clocksource_init(void) -{ - /* enable the whole timer block */ - writel(0x00000000, timer_base + TIMROTCTRL); - /* setup start value of the general purpose timer */ - writel(0x00000000, timer_base + TIMCTRL1); - writel(TIMCTRL_UPDATE, timer_base + TIMCTRL1); - /* setup the reload value of the general purpose timer */ - writel(0xffffffff, timer_base + TIMFIX1); - - writel(TIMCTRL_UPDATE | TIMCTRL_RELOAD | TIMCTRL_PRESCALE(0) | - TIMCTRL_SELECT(0xb), timer_base + TIMCTRL1); - imx28_cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE, imx28_cs.shift); - init_clock(&imx28_cs); - - return 0; -} - -core_initcall(imx28_clocksource_init); diff --git a/arch/arm/mach-stm/imx.c b/arch/arm/mach-stm/imx.c deleted file mode 100644 index 14a4249..0000000 --- a/arch/arm/mach-stm/imx.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * (C) Copyright 2010 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. - * - * 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 -#include - -extern void imx_dump_clocks(void); - -static int do_clocks(struct command *cmdtp, int argc, char *argv[]) -{ - imx_dump_clocks(); - - return 0; -} - -BAREBOX_CMD_START(dump_clocks) - .cmd = do_clocks, - .usage = "show clock frequencies", -BAREBOX_CMD_END diff --git a/arch/arm/mach-stm/imx_lcd_clk.c b/arch/arm/mach-stm/imx_lcd_clk.c deleted file mode 100644 index 8938664..0000000 --- a/arch/arm/mach-stm/imx_lcd_clk.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * (C) Copyright 2010 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 -#include -#include -#include -#include - -#ifdef CONFIG_ARCH_IMX23 - -# define HW_CLKCTRL_DIS_LCDIF 0x060 -# define CLKCTRL_DIS_LCDIF_GATE (1 << 31) -# define CLKCTRL_DIS_LCDIF_BUSY (1 << 29) -# define MASK_DIS_LCDIF_DIV 0xfff -# define SET_DIS_LCDIF_DIV(x) ((x) & MASK_DIS_LCDIF_DIV) -# define GET_DIS_LCDIF_DIV(x) ((x) & MASK_DIS_LCDIF_DIV) - -# define HW_CLKCTRL_FRAC 0xf0 -# define MASK_PIXFRAC 0x3f -# define GET_PIXFRAC(x) (((x) >> 16) & MASK_PIXFRAC) -# define SET_PIXFRAC(x) (((x) & MASK_PIXFRAC) << 16) -# define CLKCTRL_FRAC_CLKGATEPIX (1 << 23) - -# define HW_CLKCTRL_CLKSEQ 0x110 -# define CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF (1 << 1) - -#endif - -#ifdef CONFIG_ARCH_IMX28 - -# define HW_CLKCTRL_DIS_LCDIF 0x120 -# define CLKCTRL_DIS_LCDIF_GATE (1 << 31) -# define CLKCTRL_DIS_LCDIF_BUSY (1 << 29) -# define MASK_DIS_LCDIF_DIV 0x1fff -# define SET_DIS_LCDIF_DIV(x) ((x) & MASK_DIS_LCDIF_DIV) -# define GET_DIS_LCDIF_DIV(x) ((x) & MASK_DIS_LCDIF_DIV) - -/* note: On i.MX28 this is called 'FRAC1' */ -# define HW_CLKCTRL_FRAC 0x1c0 -# define MASK_PIXFRAC 0x3f -# define GET_PIXFRAC(x) ((x) & MASK_PIXFRAC) -# define SET_PIXFRAC(x) ((x) & MASK_PIXFRAC) -# define CLKCTRL_FRAC_CLKGATEPIX (1 << 7) - -# define HW_CLKCTRL_CLKSEQ 0x1d0 -# define CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF (1 << 14) - -#endif - -unsigned imx_get_lcdifclk(void) -{ - unsigned rate = (imx_get_mpllclk() / 1000) * 18U; - unsigned div; - - div = GET_PIXFRAC(readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC)); - if (div != 0U) { - rate /= div; - div = GET_DIS_LCDIF_DIV(readl(IMX_CCM_BASE + - HW_CLKCTRL_DIS_LCDIF)); - if (div != 0U) - rate /= div; - else - pr_debug("LCDIF clock has divisor 0!\n"); - } else - pr_debug("LCDIF clock has frac divisor 0!\n"); - - return rate * 1000; -} - -/* - * The source of the pixel clock can be the external 24 MHz crystal or the - * internal PLL running at 480 MHz. In order to support at least VGA sized - * displays/resolutions this routine forces the PLL as the clock source. - */ -unsigned imx_set_lcdifclk(unsigned nc) -{ - unsigned frac, best_frac = 0, div, best_div = 0, result; - int delta, best_delta = 0xffffff; - unsigned i, parent_rate = imx_get_mpllclk() / 1000; - uint32_t reg; - -#define SH_DIV(NOM, DEN, LSH) ((((NOM) / (DEN)) << (LSH)) + \ - DIV_ROUND_CLOSEST(((NOM) % (DEN)) << (LSH), DEN)) -#define SHIFT 4 - - nc /= 1000; - nc <<= SHIFT; - - for (frac = 18; frac <= 35; ++frac) { - for (div = 1; div <= 255; ++div) { - result = DIV_ROUND_CLOSEST(parent_rate * - SH_DIV(18U, frac, SHIFT), div); - delta = nc - result; - if (abs(delta) < abs(best_delta)) { - best_delta = delta; - best_frac = frac; - best_div = div; - } - } - } - - if (best_delta == 0xffffff) { - pr_debug("Unable to match the pixelclock\n"); - return 0; - } - - pr_debug("Programming PFD=%u,DIV=%u ref_pix=%u MHz PIXCLK=%u kHz\n", - best_frac, best_div, 480 * 18 / best_frac, - 480000 * 18 / best_frac / best_div); - - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC) & ~MASK_PIXFRAC; - reg |= SET_PIXFRAC(best_frac); - writel(reg, IMX_CCM_BASE + HW_CLKCTRL_FRAC); - writel(reg & ~CLKCTRL_FRAC_CLKGATEPIX, IMX_CCM_BASE + HW_CLKCTRL_FRAC); - - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_DIS_LCDIF) & ~MASK_DIS_LCDIF_DIV; - reg &= ~CLKCTRL_DIS_LCDIF_GATE; - reg |= SET_DIS_LCDIF_DIV(best_div); - writel(reg, IMX_CCM_BASE + HW_CLKCTRL_DIS_LCDIF); - - /* Wait for divider update */ - for (i = 0; i < 10000; i++) { - if (!(readl(IMX_CCM_BASE + HW_CLKCTRL_DIS_LCDIF) & - CLKCTRL_DIS_LCDIF_BUSY)) - break; - } - - if (i >= 10000) { - pr_debug("Setting LCD clock failed\n"); - return 0; - } - - writel(CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF, - IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ + BIT_CLR); - - return imx_get_lcdifclk(); -} diff --git a/arch/arm/mach-stm/include/mach/clock-imx23.h b/arch/arm/mach-stm/include/mach/clock-imx23.h deleted file mode 100644 index 723f343..0000000 --- a/arch/arm/mach-stm/include/mach/clock-imx23.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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. - */ - -#ifndef MACH_CLOCK_IMX23_H -# define MACH_CLOCK_IMX23_H - -unsigned imx_get_mpllclk(void); -unsigned imx_get_emiclk(void); -unsigned imx_get_ioclk(void); -unsigned imx_get_armclk(void); -unsigned imx_get_hclk(void); -unsigned imx_get_xclk(void); -unsigned imx_get_sspclk(unsigned); -unsigned imx_set_sspclk(unsigned, unsigned, int); -unsigned imx_set_ioclk(unsigned); -unsigned imx_set_lcdifclk(unsigned); -unsigned imx_get_lcdifclk(void); - -#endif /* MACH_CLOCK_IMX23_H */ diff --git a/arch/arm/mach-stm/include/mach/clock-imx28.h b/arch/arm/mach-stm/include/mach/clock-imx28.h deleted file mode 100644 index 45fb043..0000000 --- a/arch/arm/mach-stm/include/mach/clock-imx28.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - */ - -#ifndef MACH_CLOCK_IMX28_H -#define MACH_CLOCK_IMX28_H - -unsigned imx_get_mpllclk(void); -unsigned imx_get_emiclk(void); -unsigned imx_get_ioclk(unsigned); -unsigned imx_get_armclk(void); -unsigned imx_get_hclk(void); -unsigned imx_get_xclk(void); -unsigned imx_get_sspclk(unsigned); -unsigned imx_set_sspclk(unsigned, unsigned, int); -unsigned imx_set_ioclk(unsigned, unsigned); -unsigned imx_set_lcdifclk(unsigned); -unsigned imx_get_lcdifclk(void); -unsigned imx_get_fecclk(void); -void imx_enable_enetclk(void); - -#endif /* MACH_CLOCK_IMX28_H */ - diff --git a/arch/arm/mach-stm/include/mach/clock.h b/arch/arm/mach-stm/include/mach/clock.h deleted file mode 100644 index bd1fa7c..0000000 --- a/arch/arm/mach-stm/include/mach/clock.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * (C) Copyright 2010 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. - * - * 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 __MACH_CLOCK_H -# define __MACH_CLOCK_H - -#if defined CONFIG_ARCH_IMX23 -# include -#endif -#if defined CONFIG_ARCH_IMX28 -# include -#endif - -#endif /* __MACH_CLOCK_H */ diff --git a/arch/arm/mach-stm/include/mach/fb.h b/arch/arm/mach-stm/include/mach/fb.h deleted file mode 100644 index 65e3be2..0000000 --- a/arch/arm/mach-stm/include/mach/fb.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ - -#ifndef __MACH_FB_H -# define __MACH_FB_H - -#include - -#define STMLCDIF_8BIT 1 /** pixel data bus to the display is of 8 bit width */ -#define STMLCDIF_16BIT 0 /** pixel data bus to the display is of 16 bit width */ -#define STMLCDIF_18BIT 2 /** pixel data bus to the display is of 18 bit width */ -#define STMLCDIF_24BIT 3 /** pixel data bus to the display is of 24 bit width */ - -/** LC display uses active high data enable signal */ -#define FB_SYNC_DE_HIGH_ACT (1 << 27) -/** LC display will latch its data at clock's rising edge */ -#define FB_SYNC_CLK_INVERT (1 << 28) -/** output RGB digital data inverted */ -#define FB_SYNC_DATA_INVERT (1 << 29) -/** Stop clock if no data is sent (required for passive displays) */ -#define FB_SYNC_CLK_IDLE_DIS (1 << 30) -/** swap RGB to BGR */ -#define FB_SYNC_SWAP_RGB (1 << 31) - -struct imx_fb_videomode { - struct fb_videomode *mode_list; - unsigned mode_cnt; - - unsigned dotclk_delay; /**< refer manual HW_LCDIF_VDCTRL4 register */ - unsigned ld_intf_width; /**< refer STMLCDIF_* macros */ -}; - -#endif /* __MACH_FB_H */ - diff --git a/arch/arm/mach-stm/include/mach/generic.h b/arch/arm/mach-stm/include/mach/generic.h deleted file mode 100644 index 50f25c5..0000000 --- a/arch/arm/mach-stm/include/mach/generic.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * (C) Copyright 2010 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. - * - * 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 - */ - -#ifdef CONFIG_ARCH_IMX23 -# define cpu_is_mx23() (1) -#else -# define cpu_is_mx23() (0) -#endif - -#ifdef CONFIG_ARCH_IMX28 -# define cpu_is_mx28() (1) -#else -# define cpu_is_mx28() (0) -#endif diff --git a/arch/arm/mach-stm/include/mach/gpio.h b/arch/arm/mach-stm/include/mach/gpio.h deleted file mode 100644 index c419926..0000000 --- a/arch/arm/mach-stm/include/mach/gpio.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright 2010 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. - * - * 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 __ASM_MACH_GPIO_H -#define __ASM_MACH_GPIO_H - -#include - -#if defined CONFIG_ARCH_IMX23 -# include -#endif -#if defined CONFIG_ARCH_IMX28 -# include -#endif - -void imx_gpio_mode(uint32_t); -void gpio_set_value(unsigned, int); -int gpio_direction_input(unsigned); -int gpio_direction_output(unsigned, int); -int gpio_get_value(unsigned); - -#endif /* __ASM_MACH_GPIO_H */ diff --git a/arch/arm/mach-stm/include/mach/imx-regs.h b/arch/arm/mach-stm/include/mach/imx-regs.h deleted file mode 100644 index 9b33a06..0000000 --- a/arch/arm/mach-stm/include/mach/imx-regs.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright 2010 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. - * - * 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 _IMX_REGS_H -# define _IMX_REGS_H - -/* Note: Some registers do not support this bit change feature! */ -#define BIT_SET 0x04 -#define BIT_CLR 0x08 -#define BIT_TGL 0x0C - -#if defined CONFIG_ARCH_IMX23 -# include -#endif - -#if defined CONFIG_ARCH_IMX28 -# include -#endif - -#endif /* _IMX_REGS_H */ diff --git a/arch/arm/mach-stm/include/mach/imx23-regs.h b/arch/arm/mach-stm/include/mach/imx23-regs.h deleted file mode 100644 index caac19b..0000000 --- a/arch/arm/mach-stm/include/mach/imx23-regs.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * (C) Copyright 2010 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. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ - -#ifndef __ASM_ARCH_MX23_REGS_H -#define __ASM_ARCH_MX23_REGS_H - -/* - * sanity check - */ -#ifndef _IMX_REGS_H -# error "Please do not include directly. Use imx-regs.h instead." -#endif - -#define IMX_MEMORY_BASE 0x40000000 -#define IMX_UART1_BASE 0x8006c000 -#define IMX_UART2_BASE 0x8006e000 -#define IMX_DBGUART_BASE 0x80070000 -#define IMX_TIM1_BASE 0x80068000 -#define IMX_IOMUXC_BASE 0x80018000 -#define IMX_WDT_BASE 0x8005c000 -#define IMX_CCM_BASE 0x80040000 -#define IMX_I2C1_BASE 0x80058000 -#define IMX_SSP1_BASE 0x80010000 -#define IMX_FB_BASE 0x80030000 -#define IMX_SSP2_BASE 0x80034000 - -#endif /* __ASM_ARCH_MX23_REGS_H */ diff --git a/arch/arm/mach-stm/include/mach/imx28-regs.h b/arch/arm/mach-stm/include/mach/imx28-regs.h deleted file mode 100644 index 0c97c4c..0000000 --- a/arch/arm/mach-stm/include/mach/imx28-regs.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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. - */ - -#ifndef __ASM_ARCH_MX28_REGS_H -#define __ASM_ARCH_MX28_REGS_H - -/* - * sanity check - */ -#ifndef _IMX_REGS_H -# error "Please do not include directly. Use imx-regs.h instead." -#endif - -#define IMX_SRAM_BASE 0x00000000 -#define IMX_MEMORY_BASE 0x40000000 - -#define IMX_NFC_BASE 0x8000C000 -#define IMX_SSP0_BASE 0x80010000 -#define IMX_SSP1_BASE 0x80012000 -#define IMX_SSP2_BASE 0x80014000 -#define IMX_SSP3_BASE 0x80016000 -#define IMX_IOMUXC_BASE 0x80018000 -#define IMX_FB_BASE 0x80030000 -#define IMX_CCM_BASE 0x80040000 -#define IMX_WDT_BASE 0x80056000 -#define IMX_I2C0_BASE 0x80058000 -#define IMX_I2C1_BASE 0x8005a000 -#define IMX_TIM1_BASE 0x80068000 -#define IMX_UART0_BASE 0x8006a000 -#define IMX_UART1_BASE 0x8006c000 -#define IMX_UART2_BASE 0x8006e000 -#define IMX_UART3_BASE 0x80070000 -#define IMX_UART4_BASE 0x80072000 -#define IMX_DBGUART_BASE 0x80074000 -#define IMX_FEC0_BASE 0x800F0000 -#define IMX_FEC1_BASE 0x800F4000 - -#endif /* __ASM_ARCH_MX28_REGS_H */ diff --git a/arch/arm/mach-stm/include/mach/iomux-imx23.h b/arch/arm/mach-stm/include/mach/iomux-imx23.h deleted file mode 100644 index bebaf56..0000000 --- a/arch/arm/mach-stm/include/mach/iomux-imx23.h +++ /dev/null @@ -1,424 +0,0 @@ -/* - * (C) Copyright 2010 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. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ - -/* 3322222222221111111111 - * 10987654321098765432109876543210 - * ^^^_ Register Number - * ^^^^____ Bit offset - * ^^________ Function - * ^__________ Drive strength feature present - * ^___________ Pull up / bit keeper present - * ^^____________ Drive strength setting - * ^______________ Pull up / bit keeper setting - * ^_______________ Voltage select present - * ^________________ Voltage selection - * ^____________________ direction if enabled as GPIO (1 = output) - * ^_____________________ initial output value if enabled as GPIO and configured as output - */ -#ifndef __ASM_MACH_IOMUX_H -#define __ASM_MACH_IOMUX_H - -/* control pad's function */ -#define FBIT_SHIFT (3) -#define PORTF(bank,bit) (((bit) << FBIT_SHIFT) | (bank)) -#define GET_PORTF(x) ((x) & 0x7) -#define GET_FBITPOS(x) (((x) >> FBIT_SHIFT) & 0xf) -#define GET_GPIO_NO(x) ((GET_PORTF(x) << 4) + GET_FBITPOS(m)) -#define FUNC_SHIFT 7 -#define FUNC(x) ((x) << FUNC_SHIFT) -#define GET_FUNC(x) (((x) >> FUNC_SHIFT) & 3) -#define IS_GPIO (3) - -/* control pad's GPIO feature if enabled */ -#define GPIO_OUT (1 << 19) -#define GPIO_VALUE(x) ((x) << 20) -#define GPIO_IN (0 << 19) -#define GET_GPIODIR(x) (!!((x) & (1 << 19))) -#define GET_GPIOVAL(x) (!!((x) & (1 << 20))) - -/* control pad's drive strength */ -#define SE (1 << 9) -#define SE_PRESENT(x) (!!((x) & SE)) -#define STRENGTH(x) ((x) << 11) -#define S4MA 0 /* used to define a 4 mA drive strength */ -#define S8MA 1 /* used to define a 8 mA drive strength */ -#define S12MA 2 /* used to define a 12 mA drive strength */ -#define S16MA 3 /* used to define a 16 mA drive strength, not all pads can drive this current! */ -#define GET_STRENGTH(x) (((x) >> 11) & 0x3) - -/* control pad's pull up / bit keeper feature */ -#define PE (1 << 10) -#define PE_PRESENT(x) (!!((x) & PE)) -#define PULLUP(x) ((x) << 13) -#define GET_PULLUP(x) (!!((x) & (1 << 13))) - -/* control pad's voltage feature */ -#define VE (1 << 14) -#define VE_PRESENT(x) (!!((x) & VE)) -#define VE_1_8V (0 << 15) -#define VE_2_5V (0 << 15) /* don't ask my why, RTFM */ -#define GET_VOLTAGE(x) (!!((x) & (1 << 15))) - -/* Bank 0, pins 0 ... 15, GPIO pins 0 ... 15 */ -#define GPMI_D15 (FUNC(0) | PORTF(0, 15) | SE | PE) -#define GPMI_D15_AUART2_TX (FUNC(1) | PORTF(0, 15) | SE | PE) -#define GPMI_D15_GPMI_CE3N (FUNC(2) | PORTF(0, 15) | SE | PE) -#define GPMI_D15_GPIO (FUNC(3) | PORTF(0, 15) | SE | PE) -#define GPMI_D14 (FUNC(0) | PORTF(0, 14) | SE) -#define GPMI_D14_AUART2_RX (FUNC(1) | PORTF(0, 14) | SE) -#define GPMI_D14_GPIO (FUNC(3) | PORTF(0, 14) | SE) -#define GPMI_D13 (FUNC(0) | PORTF(0, 13) | SE) -#define GPMI_D13_LCD_D23 (FUNC(1) | PORTF(0, 13) | SE) -#define GPMI_D13_GPIO (FUNC(3) | PORTF(0, 13) | SE) -#define GPMI_D12 (FUNC(0) | PORTF(0, 12) | SE) -#define GPMI_D12_LCD_D22 (FUNC(1) | PORTF(0, 12) | SE) -#define GPMI_D12_GPIO (FUNC(3) | PORTF(0, 12) | SE) -#define GPMI_D11 (FUNC(0) | PORTF(0, 11) | SE | PE) -#define GPMI_D11_LCD_D21 (FUNC(1) | PORTF(0, 11) | SE | PE) -#define GPMI_D11_SSP1_D7 (FUNC(2) | PORTF(0, 11) | SE | PE) -#define GPMI_D11_GPIO (FUNC(3) | PORTF(0, 11) | SE | PE) -#define GPMI_D10 (FUNC(0) | PORTF(0, 10) | SE | PE) -#define GPMI_D10_LCD_D20 (FUNC(1) | PORTF(0, 10) | SE | PE) -#define GPMI_D10_SSP1_D6 (FUNC(2) | PORTF(0, 10) | SE | PE) -#define GPMI_D10_GPIO (FUNC(3) | PORTF(0, 10) | SE | PE) -#define GPMI_D09 (FUNC(0) | PORTF(0, 9) | SE | PE) -#define GPMI_D09_LCD_D19 (FUNC(1) | PORTF(0, 9) | SE | PE) -#define GPMI_D09_SSP1_D5 (FUNC(2) | PORTF(0, 9) | SE | PE) -#define GPMI_D09_GPIO (FUNC(3) | PORTF(0, 9) | SE | PE) -#define GPMI_D08 (FUNC(0) | PORTF(0, 8) | SE | PE) -#define GPMI_D08_LCD_D18 (FUNC(1) | PORTF(0, 8) | SE | PE) -#define GPMI_D08_SSP1_D4 (FUNC(2) | PORTF(0, 8) | SE | PE) -#define GPMI_D08_GPIO (FUNC(3) | PORTF(0, 8) | SE | PE) -#define GPMI_D07 (FUNC(0) | PORTF(0, 7) | SE | PE) -#define GPMI_D07_LCD_D15 (FUNC(1) | PORTF(0, 7) | SE | PE) -#define GPMI_D07_SSP2_D7 (FUNC(2) | PORTF(0, 7) | SE | PE) -#define GPMI_D07_GPIO (FUNC(3) | PORTF(0, 7) | SE | PE) -#define GPMI_D06 (FUNC(0) | PORTF(0, 6) | SE | PE) -#define GPMI_D06_LCD_D14 (FUNC(1) | PORTF(0, 6) | SE | PE) -#define GPMI_D06_SSP2_D6 (FUNC(2) | PORTF(0, 6) | SE | PE) -#define GPMI_D06_GPIO (FUNC(3) | PORTF(0, 6) | SE | PE) -#define GPMI_D05 (FUNC(0) | PORTF(0, 5) | SE | PE) -#define GPMI_D05_LCD_D13 (FUNC(1) | PORTF(0, 5) | SE | PE) -#define GPMI_D05_SSP2_D5 (FUNC(2) | PORTF(0, 5) | SE | PE) -#define GPMI_D05_GPIO (FUNC(3) | PORTF(0, 5) | SE | PE) -#define GPMI_D04 (FUNC(0) | PORTF(0, 4) | SE | PE) -#define GPMI_D04_LCD_D12 (FUNC(1) | PORTF(0, 4) | SE | PE) -#define GPMI_D04_SSP2_D4 (FUNC(2) | PORTF(0, 4) | SE | PE) -#define GPMI_D04_GPIO (FUNC(3) | PORTF(0, 4) | SE | PE) -#define GPMI_D03 (FUNC(0) | PORTF(0, 3) | SE | PE) -#define GPMI_D03_LCD_D11 (FUNC(1) | PORTF(0, 3) | SE | PE) -#define GPMI_D03_SSP2_D3 (FUNC(2) | PORTF(0, 3) | SE | PE) -#define GPMI_D03_GPIO (FUNC(3) | PORTF(0, 3) | SE | PE) -#define GPMI_D02 (FUNC(0) | PORTF(0, 2) | SE | PE) -#define GPMI_D02_LCD_D10 (FUNC(1) | PORTF(0, 2) | SE | PE) -#define GPMI_D02_SSP2_D2 (FUNC(2) | PORTF(0, 2) | SE | PE) -#define GPMI_D02_GPIO (FUNC(3) | PORTF(0, 2) | SE | PE) -#define GPMI_D01 (FUNC(0) | PORTF(0, 1) | SE | PE) -#define GPMI_D01_LCD_D9 (FUNC(1) | PORTF(0, 1) | SE | PE) -#define GPMI_D01_SSP2_D1 (FUNC(2) | PORTF(0, 1) | SE | PE) -#define GPMI_D01_GPIO (FUNC(3) | PORTF(0, 1) | SE | PE) -#define GPMI_D00 (FUNC(0) | PORTF(0, 0) | SE | PE) -#define GPMI_D00_LCD_D8 (FUNC(1) | PORTF(0, 0) | SE | PE) -#define GPMI_D00_SSP2_D0 (FUNC(2) | PORTF(0, 0) | SE | PE) -#define GPMI_D00_GPIO (FUNC(3) | PORTF(0, 0) | SE | PE) - -/* Bank 0, pins 16 ... 31 GPIO pins 16 ... 31 */ -#define I2C_SDA (FUNC(0) | PORTF(1, 15) | SE) -#define I2C_SDA_GPMI_CE2N (FUNC(1) | PORTF(1, 15) | SE) -#define I2C_SDA_AUART1_RX (FUNC(2) | PORTF(1, 15) | SE) -#define I2C_SDA_GPIO (FUNC(3) | PORTF(1, 15) | SE) -#define I2C_CLK (FUNC(0) | PORTF(1, 14) | SE | PE) -#define I2C_CLK_GPMI_RDY2 (FUNC(1) | PORTF(1, 14) | SE | PE) -#define I2C_CLK_AUART1_TX (FUNC(2) | PORTF(1, 14) | SE | PE) -#define I2C_CLK_GPIO (FUNC(3) | PORTF(1, 14) | SE | PE) -#define AUART1_TX (FUNC(0) | PORTF(1, 13) | SE | PE) -#define AUART1_TX_SSP1_D7 (FUNC(2) | PORTF(1, 13) | SE | PE) -#define AUART1_TX_GPIO (FUNC(3) | PORTF(1, 13) | SE | PE) -#define AUART1_RX (FUNC(0) | PORTF(1, 12) | SE | PE) -#define AUART1_RX_SSP1_D6 (FUNC(2) | PORTF(1, 12) | SE | PE) -#define AUART1_RX_GPIO (FUNC(3) | PORTF(1, 12) | SE | PE) -#define AUART1_RTS (FUNC(0) | PORTF(1, 11) | SE | PE) -#define AUART1_RTS_SSP1_D5 (FUNC(2) | PORTF(1, 11) | SE | PE) -#define AUART1_RTS_GPIO (FUNC(3) | PORTF(1, 11) | SE | PE) -#define AUART1_CTS (FUNC(0) | PORTF(1, 10) | SE | PE) -#define AUART1_CTS_SSP1_D4 (FUNC(2) | PORTF(1, 10) | SE | PE) -#define AUART1_CTS_GPIO (FUNC(3) | PORTF(1, 10) | SE | PE) -#define GPMI_RDN (FUNC(0) | PORTF(1, 9) | SE) -#define GPMI_RDN_GPIO (FUNC(3) | PORTF(1, 9) | SE) -#define GPMI_WRN (FUNC(0) | PORTF(1, 8) | SE) -#define GPMI_WRN_SSP2_SCK (FUNC(2) | PORTF(1, 8) | SE) -#define GPMI_WRN_GPIO (FUNC(3) | PORTF(1, 8) | SE) -#define GPMI_WPM (FUNC(0) | PORTF(1, 7) | SE) -#define GPMI_WPM_GPIO (FUNC(3) | PORTF(1, 7) | SE) -#define GPMI_RDY3 (FUNC(0) | PORTF(1, 6) | SE | PE) -#define GPMI_RDY3_GPIO (FUNC(3) | PORTF(1, 6) | SE | PE) -#define GPMI_RDY2 (FUNC(0) | PORTF(1, 5) | SE | PE) -#define GPMI_RDY2_GPIO (FUNC(3) | PORTF(1, 5) | SE | PE) -#define GPMI_RDY1 (FUNC(0) | PORTF(1, 4) | SE | PE) -#define GPMI_RDY1_SSP2_CMD (FUNC(2) | PORTF(1, 4) | SE | PE) -#define GPMI_RDY1_GPIO (FUNC(3) | PORTF(1, 4) | SE | PE) -#define GPMI_RDY0 (FUNC(0) | PORTF(1, 3) | SE | PE) -#define GPMI_RDY0_SSP2_DETECT (FUNC(2) | PORTF(1, 3) | SE | PE) -#define GPMI_RDY0_GPIO (FUNC(3) | PORTF(1, 3) | SE | PE) -#define GPMI_CE2N (FUNC(0) | PORTF(1, 2) | SE | PE) -#define GPMI_CE2N_GPIO (FUNC(3) | PORTF(1, 2) | SE | PE) -#define GPMI_ALE (FUNC(0) | PORTF(1, 1) | SE) -#define GPMI_ALE_LCD_D17 (FUNC(1) | PORTF(1, 1) | SE) -#define GPMI_ALE_GPIO (FUNC(3) | PORTF(1, 1) | SE) -#define GPMI_CLE (FUNC(0) | PORTF(1, 0) | SE) -#define GPMI_CLE_LCD_D16 (FUNC(1) | PORTF(1, 1) | SE) -#define GPMI_CLE_GPIO (FUNC(3) | PORTF(1, 0) | SE) - -/* Bank 1, pins 0 ... 15 GPIO pins 32 ... 47 */ -#define LCD_D15 (FUNC(0) | PORTF(2, 15) | SE) -#define LCD_D15_ETM_DA7 (FUNC(1) | PORTF(2, 15) | SE) -#define LCD_D15_SAIF1_SDATA1 (FUNC(2) | PORTF(2, 15) | SE) -#define LCD_D15_GPIO (FUNC(3) | PORTF(2, 15) | SE) -#define LCD_D14 (FUNC(0) | PORTF(2, 14) | SE) -#define LCD_D14_ETM_DA6 (FUNC(1) | PORTF(2, 14) | SE) -#define LCD_D14_SAIF1_SDATA2 (FUNC(2) | PORTF(2, 14) | SE) -#define LCD_D14_GPIO (FUNC(3) | PORTF(2, 14) | SE) -#define LCD_D13 (FUNC(0) | PORTF(2, 13) | SE) -#define LCD_D13_ETM_DA5 (FUNC(1) | PORTF(2, 13) | SE) -#define LCD_D13_SAIF2_SDATA2 (FUNC(2) | PORTF(2, 13) | SE) -#define LCD_D13_GPIO (FUNC(3) | PORTF(2, 13) | SE) -#define LCD_D12 (FUNC(0) | PORTF(2, 12) | SE) -#define LCD_D12_ETM_DA4 (FUNC(1) | PORTF(2, 12) | SE) -#define LCD_D12_SAIF2_SDATA1 (FUNC(2) | PORTF(2, 12) | SE) -#define LCD_D12_GPIO (FUNC(3) | PORTF(2, 12) | SE) -#define LCD_D11 (FUNC(0) | PORTF(2, 11) | SE) -#define LCD_D11_ETM_DA3 (FUNC(1) | PORTF(2, 11) | SE) -#define LCD_D11_SAIF_LRCLK (FUNC(2) | PORTF(2, 11) | SE) -#define LCD_D11_GPIO (FUNC(3) | PORTF(2, 11) | SE) -#define LCD_D10 (FUNC(0) | PORTF(2, 10) | SE) -#define LCD_D10_ETM_DA2 (FUNC(1) | PORTF(2, 10) | SE) -#define LCD_D10_SAIF_BITCLK (FUNC(2) | PORTF(2, 10) | SE) -#define LCD_D10_GPIO (FUNC(3) | PORTF(2, 10) | SE) -#define LCD_D9 (FUNC(0) | PORTF(2, 9) | SE) -#define LCD_D9_ETM_DA1 (FUNC(1) | PORTF(2, 9) | SE) -#define LCD_D9_SAIF1_SDATA0 (FUNC(2) | PORTF(2, 9) | SE) -#define LCD_D9_GPIO (FUNC(3) | PORTF(2, 9) | SE) -#define LCD_D8 (FUNC(0) | PORTF(2, 8) | SE) -#define LCD_D8_ETM_DA0 (FUNC(1) | PORTF(2, 8) | SE) -#define LCD_D8_SAIF2_SDATA0 (FUNC(2) | PORTF(2, 8) | SE) -#define LCD_D8_GPIO (FUNC(3) | PORTF(2, 8) | SE) -#define LCD_D7 (FUNC(0) | PORTF(2, 7) | SE) -#define LCD_D7_ETM_DA15 (FUNC(1) | PORTF(2, 7) | SE) -#define LCD_D7_GPIO (FUNC(3) | PORTF(2, 7) | SE) -#define LCD_D6 (FUNC(0) | PORTF(2, 6) | SE) -#define LCD_D6_ETM_DA14 (FUNC(1) | PORTF(2, 6) | SE) -#define LCD_D6_GPIO (FUNC(3) | PORTF(2, 6) | SE) -#define LCD_D5 (FUNC(0) | PORTF(2, 5) | SE) -#define LCD_D5_ETM_DA13 (FUNC(1) | PORTF(2, 5) | SE) -#define LCD_D5_GPIO (FUNC(3) | PORTF(2, 5) | SE) -#define LCD_D4 (FUNC(0) | PORTF(2, 4) | SE) -#define LCD_D4_ETM_DA12 (FUNC(1) | PORTF(2, 4) | SE) -#define LCD_D4_GPIO (FUNC(3) | PORTF(2, 4) | SE) -#define LCD_D3 (FUNC(0) | PORTF(2, 3) | SE) -#define LCD_D3_ETM_DA11 (FUNC(1) | PORTF(2, 3) | SE) -#define LCD_D3_GPIO (FUNC(3) | PORTF(2, 3) | SE) -#define LCD_D2 (FUNC(0) | PORTF(2, 2) | SE) -#define LCD_D2_ETM_DA10 (FUNC(1) | PORTF(2, 2) | SE) -#define LCD_D2_GPIO (FUNC(3) | PORTF(2, 2) | SE) -#define LCD_D1 (FUNC(0) | PORTF(2, 1) | SE) -#define LCD_D1_ETM_DA9 (FUNC(1) | PORTF(2, 1) | SE) -#define LCD_D1_GPIO (FUNC(3) | PORTF(2, 1) | SE) -#define LCD_D0 (FUNC(0) | PORTF(2, 0) | SE) -#define LCD_D0_ETM_DA8 (FUNC(1) | PORTF(2, 0) | SE) -#define LCD_D0_GPIO (FUNC(3) | PORTF(2, 0) | SE) - -/* Bank 1, pins 16 ... 30 GPIO pins 48 ... 63 */ -#define PWM4 (FUNC(0) | PORTF(3, 14) | SE) -#define PWM4_ETM_CLK (FUNC(1) | PORTF(3, 14) | SE) -#define PWM4_AUART1_RTS (FUNC(2) | PORTF(3, 14) | SE) -#define PWM4_GPIO (FUNC(3) | PORTF(3, 14) | SE) -#define PWM3 (FUNC(0) | PORTF(3, 13) | SE) -#define PWM3_ETM_TCTL (FUNC(1) | PORTF(3, 13) | SE) -#define PWM3_AUART1_CTS (FUNC(2) | PORTF(3, 13) | SE) -#define PWM3_GPIO (FUNC(3) | PORTF(3, 13) | SE) -#define PWM2 (FUNC(0) | PORTF(3, 12) | SE | PE) -#define PWM2_GPMI_READY3 (FUNC(1) | PORTF(3, 12) | SE | PE) -#define PWM2_GPIO (FUNC(3) | PORTF(3, 12) | SE | PE) -#define PWM1 (FUNC(0) | PORTF(3, 11) | SE) -#define PWM1_TIMROT2 (FUNC(1) | PORTF(3, 11) | SE) -#define PWM1_DUART_TX (FUNC(2) | PORTF(3, 11) | SE) -#define PWM1_GPIO (FUNC(3) | PORTF(3, 11) | SE) -#define PWM0 (FUNC(0) | PORTF(3, 10) | SE) -#define PWM0_TIMROT1 (FUNC(1) | PORTF(3, 10) | SE) -#define PWM0_DUART_RX (FUNC(2) | PORTF(3, 10) | SE) -#define PWM0_GPIO (FUNC(3) | PORTF(3, 10) | SE) -#define LCD_VSYNC (FUNC(0) | PORTF(3, 9) | SE) -#define LCD_VSYNC_LCD_BUSY (FUNC(1) | PORTF(3, 9) | SE) -#define LCD_VSYNC_GPIO (FUNC(3) | PORTF(3, 9) | SE) -#define LCD_HSYNC (FUNC(0) | PORTF(3, 8) | SE) -#define LCD_HSYNC_I2C_SD (FUNC(1) | PORTF(3, 8) | SE) -#define LCD_HSYNC_GPIO (FUNC(3) | PORTF(3, 8) | SE) -#define LCD_ENABE (FUNC(0) | PORTF(3, 7) | SE) -#define LCD_ENABE_I2C_CLK (FUNC(1) | PORTF(3, 7) | SE) -#define LCD_ENABE_GPIO (FUNC(3) | PORTF(3, 7) | SE) -#define LCD_DOTCLOCK (FUNC(0) | PORTF(3, 6) | SE | PE) -#define LCD_DOTCLOCK_GPMI_READY3 (FUNC(1) | PORTF(3, 6) | SE | PE) -#define LCD_DOTCLOCK_GPIO (FUNC(3) | PORTF(3, 6) | SE | PE) -#define LCD_CS (FUNC(0) | PORTF(3, 5) | SE) -#define LCD_CS_GPIO (FUNC(3) | PORTF(3, 5) | SE) -#define LCD_WR (FUNC(0) | PORTF(3, 4) | SE) -#define LCD_WR_GPIO (FUNC(3) | PORTF(3, 4) | SE) -#define LCD_RS (FUNC(0) | PORTF(3, 3) | SE) -#define LCD_RS_ETM_TCLK (FUNC(1) | PORTF(3, 3) | SE) -#define LCD_RS_GPIO (FUNC(3) | PORTF(3, 3) | SE) -#define LCD_RESET (FUNC(0) | PORTF(3, 2) | SE | PE) -#define LCD_RESET_ETM_TCTL (FUNC(1) | PORTF(3, 2) | SE | PE) -#define LCD_RESET_GPMI_CE3N (FUNC(2) | PORTF(3, 2) | SE | PE) -#define LCD_RESET_GPIO (FUNC(3) | PORTF(3, 2) | SE | PE) -#define LCD_D17 (FUNC(0) | PORTF(3, 1) | SE) -#define LCD_D17_GPIO (FUNC(3) | PORTF(3, 1) | SE) -#define LCD_D16 (FUNC(0) | PORTF(3, 0) | SE) -#define LCD_D16_SAIF_ALT_BITCLK (FUNC(2) | PORTF(3, 0) | SE) -#define LCD_D16_GPIO (FUNC(3) | PORTF(3, 0) | SE) - -/* Bank 2, pins 0 ... 15 GPIO pins 64 ... 79 */ -#define EMI_A6 (FUNC(0) | PORTF(4, 15) | SE | VE) -#define EMI_A6_GPIO (FUNC(3) | PORTF(4, 15) | SE | VE) -#define EMI_A5 (FUNC(0) | PORTF(4, 14) | SE | VE) -#define EMI_A5_GPIO (FUNC(3) | PORTF(4, 14) | SE | VE) -#define EMI_A4 (FUNC(0) | PORTF(4, 13) | SE | VE) -#define EMI_A4_GPIO (FUNC(3) | PORTF(4, 13) | SE | VE) -#define EMI_A3 (FUNC(0) | PORTF(4, 12) | SE | VE) -#define EMI_A3_GPIO (FUNC(3) | PORTF(4, 12) | SE | VE) -#define EMI_A2 (FUNC(0) | PORTF(4, 11) | SE | VE) -#define EMI_A2_GPIO (FUNC(3) | PORTF(4, 11) | SE | VE) -#define EMI_A1 (FUNC(0) | PORTF(4, 10) | SE | VE) -#define EMI_A1_GPIO (FUNC(3) | PORTF(4, 10) | SE | VE) -#define EMI_A0 (FUNC(0) | PORTF(4, 9) | SE | VE) -#define EMI_A0_GPIO (FUNC(3) | PORTF(4, 9) | SE | VE) -#define ROTARYB (FUNC(0) | PORTF(4, 8) | SE | PE) -#define ROTARYB_AUART2_CTS (FUNC(1) | PORTF(4, 8) | SE | PE) -#define ROTARYB_GPMI_CE3N (FUNC(2) | PORTF(4, 8) | SE | PE) -#define ROTARYB_GPIO (FUNC(3) | PORTF(4, 8) | SE | PE) -#define ROTARYA (FUNC(0) | PORTF(4, 7) | SE) -#define ROTARYA_AUART2_RTS (FUNC(1) | PORTF(4, 7) | SE) -#define ROTARYA_SPDIF (FUNC(2) | PORTF(4, 7) | SE) -#define ROTARYA_GPIO (FUNC(3) | PORTF(4, 7) | SE) -#define SSP1_SCK (FUNC(0) | PORTF(4, 6) | SE) -#define SSP1_SCK_ALT_JTAG_TRST (FUNC(2) | PORTF(4, 6) | SE) -#define SSP1_SCK_GPIO (FUNC(3) | PORTF(4, 6) | SE) -#define SSP1_DATA3 (FUNC(0) | PORTF(4, 5) | SE | PE) -#define SSP1_DATA3_ALT_JTAG_TMS (FUNC(2) | PORTF(4, 5) | SE | PE) -#define SSP1_DATA3_GPIO (FUNC(3) | PORTF(4, 5) | SE | PE) -#define SSP1_DATA2 (FUNC(0) | PORTF(4, 4) | SE | PE) -#define SSP1_DATA2_I2C_SD (FUNC(1) | PORTF(4, 4) | SE | PE) -#define SSP1_DATA2_ALT_JTAG_RTCK (FUNC(2) | PORTF(4, 4) | SE | PE) -#define SSP1_DATA2_GPIO (FUNC(3) | PORTF(4, 4) | SE | PE) -#define SSP1_DATA1 (FUNC(0) | PORTF(4, 3) | SE | PE) -#define SSP1_DATA1_I2C_CLK (FUNC(1) | PORTF(4, 3) | SE | PE) -#define SSP1_DATA1_ALT_JTAG_TCK (FUNC(2) | PORTF(4, 3) | SE | PE) -#define SSP1_DATA1_GPIO (FUNC(3) | PORTF(4, 3) | SE | PE) -#define SSP1_DATA0 (FUNC(0) | PORTF(4, 2) | SE | PE) -#define SSP1_DATA0_ALT_JTAG_TDI (FUNC(2) | PORTF(4, 2) | SE | PE) -#define SSP1_DATA0_GPIO (FUNC(3) | PORTF(4, 2) | SE | PE) -#define SSP1_DETECT (FUNC(0) | PORTF(4, 1) | SE | PE) -#define SSP1_DETECT_GPMI_CE3N (FUNC(1) | PORTF(4, 1) | SE | PE) -#define SSP1_DETECT_USB_ID (FUNC(2) | PORTF(4, 1) | SE | PE) -#define SSP1_DETECT_GPIO (FUNC(3) | PORTF(4, 1) | SE | PE) -#define SSP1_CMD (FUNC(0) | PORTF(4, 0) | SE | PE) -#define SSP1_CMD_JTAG_TDO (FUNC(2) | PORTF(4, 0) | SE | PE) -#define SSP1_CMD_GPIO (FUNC(3) | PORTF(4, 0) | SE | PE) - -/* Bank 2, pins 16 ... 31 GPIO pins 80 ... 95 */ -#define EMI_WEN (FUNC(0) | PORTF(5, 15) | SE | VE) -#define EMI_WEN_GPIO (FUNC(3) | PORTF(5, 15) | SE | VE) -#define EMI_RASN (FUNC(0) | PORTF(5, 14) | SE | VE) -#define EMI_RASN_GPIO (FUNC(3) | PORTF(5, 14) | SE | VE) -#define EMI_CKE (FUNC(0) | PORTF(5, 13) | SE | VE) -#define EMI_CKE_GPIO (FUNC(3) | PORTF(5, 13) | SE | VE) -#define GPMI_CE0N (FUNC(0) | PORTF(5, 12) | SE) -#define GPMI_CE0N_GPIO (FUNC(3) | PORTF(5, 12) | SE) -#define GPMI_CE1N (FUNC(0) | PORTF(5, 11) | SE | PE) -#define GPMI_CE1N_GPIO (FUNC(3) | PORTF(5, 11) | SE | PE) -#define EMI_CE1N (FUNC(0) | PORTF(5, 10) | SE | VE | PE) -#define EMI_CE1N_GPIO (FUNC(3) | PORTF(5, 10) | SE | VE | PE) -#define EMI_CE0N (FUNC(0) | PORTF(5, 9) | SE | VE) -#define EMI_CE0N_GPIO (FUNC(3) | PORTF(5, 9) | SE | VE) -#define EMI_CASN (FUNC(0) | PORTF(5, 8) | SE | VE) -#define EMI_CASN_GPIO (FUNC(3) | PORTF(5, 8) | SE | VE) -#define EMI_BA1 (FUNC(0) | PORTF(5, 7) | SE | VE) -#define EMI_BA1_GPIO (FUNC(3) | PORTF(5, 7) | SE | VE) -#define EMI_BA0 (FUNC(0) | PORTF(5, 6) | SE | VE) -#define EMI_BA0_GPIO (FUNC(3) | PORTF(5, 6) | SE | VE) -#define EMI_A12 (FUNC(0) | PORTF(5, 5) | SE | VE) -#define EMI_A12_GPIO (FUNC(3) | PORTF(5, 5) | SE | VE) -#define EMI_A11 (FUNC(0) | PORTF(5, 4) | SE | VE) -#define EMI_A11_GPIO (FUNC(3) | PORTF(5, 4) | SE | VE) -#define EMI_A10 (FUNC(0) | PORTF(5, 3) | SE | VE) -#define EMI_A10_GPIO (FUNC(3) | PORTF(5, 3) | SE | VE) -#define EMI_A9 (FUNC(0) | PORTF(5, 2) | SE | VE) -#define EMI_A9_GPIO (FUNC(3) | PORTF(5, 2) | SE | VE) -#define EMI_A8 (FUNC(0) | PORTF(5, 1) | SE | VE) -#define EMI_A8_GPIO (FUNC(3) | PORTF(5, 1) | SE | VE) -#define EMI_A7 (FUNC(0) | PORTF(5, 0) | SE | VE) -#define EMI_A7_GPIO (FUNC(3) | PORTF(5, 0) | SE | VE) - -/* Bank 3, pins 0 ... 15 GPIO pins 96 ... 111 */ -#define EMI_D15 (FUNC(0) | PORTF(6, 15) | SE | VE | PE) -#define EMI_D15_DISABLED (FUNC(3) | PORTF(6, 15) | SE | VE | PE) -#define EMI_D14 (FUNC(0) | PORTF(6, 14) | SE | VE | PE) -#define EMI_D14_DISABLED (FUNC(3) | PORTF(6, 14) | SE | VE | PE) -#define EMI_D13 (FUNC(0) | PORTF(6, 13) | SE | VE | PE) -#define EMI_D13_DISABLED (FUNC(3) | PORTF(6, 13) | SE | VE | PE) -#define EMI_D12 (FUNC(0) | PORTF(6, 12) | SE | VE | PE) -#define EMI_D12_DISABLED (FUNC(3) | PORTF(6, 12) | SE | VE | PE) -#define EMI_D11 (FUNC(0) | PORTF(6, 11) | SE | VE | PE) -#define EMI_D11_DISABLED (FUNC(3) | PORTF(6, 11) | SE | VE | PE) -#define EMI_D10 (FUNC(0) | PORTF(6, 10) | SE | VE | PE) -#define EMI_D10_DISABLED (FUNC(3) | PORTF(6, 10) | SE | VE | PE) -#define EMI_D9 (FUNC(0) | PORTF(6, 9) | SE | VE | PE) -#define EMI_D9_DISABLED (FUNC(3) | PORTF(6, 9) | SE | VE | PE) -#define EMI_D8 (FUNC(0) | PORTF(6, 8) | SE | VE | PE) -#define EMI_D8_DISABLED (FUNC(3) | PORTF(6, 8) | SE | VE | PE) -#define EMI_D7 (FUNC(0) | PORTF(6, 7) | SE | VE | PE) -#define EMI_D7_DISABLED (FUNC(3) | PORTF(6, 7) | SE | VE | PE) -#define EMI_D6 (FUNC(0) | PORTF(6, 6) | SE | VE | PE) -#define EMI_D6_DISABLED (FUNC(3) | PORTF(6, 6) | SE | VE | PE) -#define EMI_D5 (FUNC(0) | PORTF(6, 5) | SE | VE | PE) -#define EMI_D5_DISABLED (FUNC(3) | PORTF(6, 5) | SE | VE | PE) -#define EMI_D4 (FUNC(0) | PORTF(6, 4) | SE | VE | PE) -#define EMI_D4_DISABLED (FUNC(3) | PORTF(6, 4) | SE | VE | PE) -#define EMI_D3 (FUNC(0) | PORTF(6, 3) | SE | VE | PE) -#define EMI_D3_DISABLED (FUNC(3) | PORTF(6, 3) | SE | VE | PE) -#define EMI_D2 (FUNC(0) | PORTF(6, 2) | SE | VE | PE) -#define EMI_D2_DISABLED (FUNC(3) | PORTF(6, 2) | SE | VE | PE) -#define EMI_D1 (FUNC(0) | PORTF(6, 1) | SE | VE | PE) -#define EMI_D1_DISABLED (FUNC(3) | PORTF(6, 1) | SE | VE | PE) -#define EMI_D0 (FUNC(0) | PORTF(6, 0) | SE | VE | PE) -#define EMI_D0_DISABLED (FUNC(3) | PORTF(6, 0) | SE | VE | PE) - -/* Bank 3, pins 16 ... 21 GPIO pins 112 ... 117 */ -#define EMI_CLKN (FUNC(0) | PORTF(7, 5) | SE | VE) -#define EMI_CLKN_DISABLED (FUNC(3) | PORTF(7, 5) | SE | VE) -#define EMI_CLK (FUNC(0) | PORTF(7, 4) | SE | VE) -#define EMI_CLK_DISABLED (FUNC(3) | PORTF(7, 4) | SE | VE) -#define EMI_DQS1 (FUNC(0) | PORTF(7, 3) | SE | VE) -#define EMI_DQS1_DISABLED (FUNC(3) | PORTF(7, 3) | SE | VE) -#define EMI_DQS0 (FUNC(0) | PORTF(7, 2) | SE | VE) -#define EMI_DQS0_DISABLED (FUNC(3) | PORTF(7, 2) | SE | VE) -#define EMI_DQM1 (FUNC(0) | PORTF(7, 1) | SE | VE | PE) -#define EMI_DQM1_DISABLED (FUNC(3) | PORTF(7, 1) | SE | VE | PE) -#define EMI_DQM0 (FUNC(0) | PORTF(7, 0) | SE | VE | PE) -#define EMI_DQM0_DISABLED (FUNC(3) | PORTF(7, 0) | SE | VE | PE) - -#endif /* __ASM_MACH_IOMUX_H */ diff --git a/arch/arm/mach-stm/include/mach/iomux-imx28.h b/arch/arm/mach-stm/include/mach/iomux-imx28.h deleted file mode 100644 index 1e6d421..0000000 --- a/arch/arm/mach-stm/include/mach/iomux-imx28.h +++ /dev/null @@ -1,552 +0,0 @@ -/* - * 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. - */ - -/* 3322222222221111111111 - * 10987654321098765432109876543210 - * ^^^^^_ Bit offset - * ^^^______ Register Number - * ^^_________ Function - * ^___________ Drive strength feature present - * ^____________ Pull up / bit keeper present - * ^^_____________ Drive strength setting - * ^_______________ Pull up / bit keeper setting - * ^________________ Voltage select present - * ^_________________ Voltage selection - * ^_____________________ direction if enabled as GPIO (1 = output) - * ^______________________ initial output value if enabled as GPIO - * and configured as output - */ -#ifndef __MACH_IOMUX_IMX28_H -#define __MACH_IOMUX_IMX28_H - -/* control pad's function */ -#define FBANK_SHIFT (5) -#define PORTF(bank,bit) (((bank) << FBANK_SHIFT) | (bit)) -#define GET_GPIO_NO(x) ((x) & 0xff) -#define FUNC_SHIFT 8 -#define FUNC(x) ((x) << FUNC_SHIFT) -#define GET_FUNC(x) (((x) >> FUNC_SHIFT) & 3) -#define IS_GPIO (3) - -/* control pad's GPIO feature if enabled */ -#define GPIO_OUT (1 << 20) -#define GPIO_VALUE(x) ((x) << 21) -#define GPIO_IN (0 << 20) -#define GET_GPIODIR(x) (!!((x) & (1 << 20))) -#define GET_GPIOVAL(x) (!!((x) & (1 << 21))) - -/* control pad's drive strength */ -#define SE (1 << 10) -#define SE_PRESENT(x) (!!((x) & SE)) -#define STRENGTH(x) ((x) << 12) -#define S4MA 0 /* used to define a 4 mA drive strength */ -#define S8MA 1 /* used to define a 8 mA drive strength */ -#define S12MA 2 /* used to define a 12 mA drive strength */ -#define S16MA 3 /* used to define a 16 mA drive strength, - not all pads can drive this current! */ -#define GET_STRENGTH(x) (((x) >> 12) & 0x3) - -/* control pad's pull up / bit keeper feature */ -#define PE (1 << 11) -#define BK (1 << 11) /* FIXME useful to distinguish? */ -#define PE_PRESENT(x) (!!((x) & PE)) -#define BK_PRESENT(x) (!!((x) & BK)) -#define PULLUP(x) ((x) << 14) -#define BITKEEPER(x) ((x) << 14) -#define GET_PULLUP(x) (!!((x) & PULLUP(1))) -#define GET_BITKEEPER(x) (!!((x) & BITKEEPER(1))) - -/* control pad's voltage feature */ -#define VE (1 << 15) -#define VE_PRESENT(x) (!!((x) & VE)) -#define VE_1_8V (0 << 16) -#define VE_3_3V (1 << 16) -#define GET_VOLTAGE(x) (!!((x) & (1 << 16))) - -/* Bank 0, GPIO pins 0 ... 31 */ -#define GPMI_RESETN (FUNC(0) | PORTF(0, 28) | SE | VE | PE) -#define GPMI_RESETN_SSP3_CMD (FUNC(1) | PORTF(0, 28) | SE | VE | PE) -#define GPMI_RESETN_GPIO (FUNC(3) | PORTF(0, 28) | SE | VE | PE) -#define GPMI_CLE (FUNC(0) | PORTF(0, 27) | SE | VE | PE) -#define GPMI_CLE_SSP3_D2 (FUNC(1) | PORTF(0, 27) | SE | VE | PE) -#define GPMI_CLE_SSP3_D5 (FUNC(2) | PORTF(0, 27) | SE | VE | PE) -#define GPMI_CLE_GPIO (FUNC(3) | PORTF(0, 27) | SE | VE | PE) -#define GPMI_ALE (FUNC(0) | PORTF(0, 26) | SE | VE | PE) -#define GPMI_ALE_SSP3_D1 (FUNC(1) | PORTF(0, 26) | SE | VE | PE) -#define GPMI_ALE_SSP3_D4 (FUNC(2) | PORTF(0, 26) | SE | VE | PE) -#define GPMI_ALE_GPIO (FUNC(3) | PORTF(0, 26) | SE | VE | PE) -#define GPMI_WRN (FUNC(0) | PORTF(0, 25) | SE | VE | BK) -#define GPMI_WRN_SSP1_SCK (FUNC(1) | PORTF(0, 25) | SE | VE | BK) -#define GPMI_WRN_GPIO (FUNC(3) | PORTF(0, 25) | SE | VE | BK) -#define GPMI_RDN (FUNC(0) | PORTF(0, 24) | SE | VE | PE) -#define GPMI_RDN_SSP3_SCK (FUNC(1) | PORTF(0, 24) | SE | VE | PE) -#define GPMI_RDN_GPIO (FUNC(3) | PORTF(0, 24) | SE | VE | PE) -#define GPMI_READY3 (FUNC(0) | PORTF(0, 23) | SE | VE | PE) -#define GPMI_READY3_CAN0_RX (FUNC(1) | PORTF(0, 23) | SE | VE | PE) -#define GPMI_READY3_HSDAC_TRIG (FUNC(2) | PORTF(0, 23) | SE | VE | PE) -#define GPMI_READY3_GPIO (FUNC(3) | PORTF(0, 23) | SE | VE | PE) -#define GPMI_READY2 (FUNC(0) | PORTF(0, 22) | SE | VE | PE) -#define GPMI_READY2_CAN0_TX (FUNC(1) | PORTF(0, 22) | SE | VE | PE) -#define GPMI_READY2_ENET0_TX_ER (FUNC(2) | PORTF(0, 22) | SE | VE | PE) -#define GPMI_READY2_GPIO (FUNC(3) | PORTF(0, 22) | SE | VE | PE) -#define GPMI_READY1 (FUNC(0) | PORTF(0, 21) | SE | VE | PE) -#define GPMI_READY1_SSP1_CMD (FUNC(1) | PORTF(0, 21) | SE | VE | PE) -#define GPMI_READY1_GPIO (FUNC(3) | PORTF(0, 21) | SE | VE | PE) -#define GPMI_READY0 (FUNC(0) | PORTF(0, 20) | SE | VE | PE) -#define GPMI_READY0_SSP1_CD (FUNC(1) | PORTF(0, 20) | SE | VE | PE) -#define GPMI_READY0_USB0_ID (FUNC(2) | PORTF(0, 20) | SE | VE | PE) -#define GPMI_READY0_GPIO (FUNC(3) | PORTF(0, 20) | SE | VE | PE) -#define GPMI_CE3N (FUNC(0) | PORTF(0, 19) | SE | VE | PE) -#define GPMI_CE3N_CAN1_RX (FUNC(1) | PORTF(0, 19) | SE | VE | PE) -#define GPMI_CE3N_SAIF1_MCLK (FUNC(2) | PORTF(0, 19) | SE | VE | PE) -#define GPMI_CE3N_GPIO (FUNC(3) | PORTF(0, 19) | SE | VE | PE) -#define GPMI_CE2N (FUNC(0) | PORTF(0, 18) | SE | VE | PE) -#define GPMI_CE2N_CAN1_TX (FUNC(1) | PORTF(0, 18) | SE | VE | PE) -#define GPMI_CE2N_ENET0_RX_ER (FUNC(2) | PORTF(0, 18) | SE | VE | PE) -#define GPMI_CE2N_GPIO (FUNC(3) | PORTF(0, 18) | SE | VE | PE) -#define GPMI_CE1N (FUNC(0) | PORTF(0, 17) | SE | VE | PE) -#define GPMI_CE1N_SSP3_D3 (FUNC(1) | PORTF(0, 17) | SE | VE | PE) -#define GPMI_CE1N_GPIO (FUNC(3) | PORTF(0, 17) | SE | VE | PE) -#define GPMI_CE0N (FUNC(0) | PORTF(0, 16) | SE | VE | PE) -#define GPMI_CE0N_SSP3_D0 (FUNC(1) | PORTF(0, 16) | SE | VE | PE) -#define GPMI_CE0N_GPIO (FUNC(3) | PORTF(0, 16) | SE | VE | PE) -#define GPMI_D7 (FUNC(0) | PORTF(0, 7) | SE | VE | PE) -#define GPMI_D7_SSP1_D7 (FUNC(1) | PORTF(0, 7) | SE | VE | PE) -#define GPMI_D7_GPIO (FUNC(3) | PORTF(0, 7) | SE | VE | PE) -#define GPMI_D6 (FUNC(0) | PORTF(0, 6) | SE | VE | PE) -#define GPMI_D6_SSP1_D6 (FUNC(1) | PORTF(0, 6) | SE | VE | PE) -#define GPMI_D6_GPIO (FUNC(3) | PORTF(0, 6) | SE | VE | PE) -#define GPMI_D5 (FUNC(0) | PORTF(0, 5) | SE | VE | PE) -#define GPMI_D5_SSP1_D5 (FUNC(1) | PORTF(0, 5) | SE | VE | PE) -#define GPMI_D5_GPIO (FUNC(3) | PORTF(0, 5) | SE | VE | PE) -#define GPMI_D4 (FUNC(0) | PORTF(0, 4) | SE | VE | PE) -#define GPMI_D4_SSP1_D4 (FUNC(1) | PORTF(0, 4) | SE | VE | PE) -#define GPMI_D4_GPIO (FUNC(3) | PORTF(0, 4) | SE | VE | PE) -#define GPMI_D3 (FUNC(0) | PORTF(0, 3) | SE | VE | PE) -#define GPMI_D3_SSP1_D3 (FUNC(1) | PORTF(0, 3) | SE | VE | PE) -#define GPMI_D3_GPIO (FUNC(3) | PORTF(0, 3) | SE | VE | PE) -#define GPMI_D2 (FUNC(0) | PORTF(0, 2) | SE | VE | PE) -#define GPMI_D2_SSP1_D2 (FUNC(1) | PORTF(0, 2) | SE | VE | PE) -#define GPMI_D2_GPIO (FUNC(3) | PORTF(0, 2) | SE | VE | PE) -#define GPMI_D1 (FUNC(0) | PORTF(0, 1) | SE | VE | PE) -#define GPMI_D1_SSP1_D1 (FUNC(1) | PORTF(0, 1) | SE | VE | PE) -#define GPMI_D1_GPIO (FUNC(3) | PORTF(0, 1) | SE | VE | PE) -#define GPMI_D0 (FUNC(0) | PORTF(0, 0) | SE | VE | PE) -#define GPMI_D0_SSP1_D0 (FUNC(1) | PORTF(0, 0) | SE | VE | PE) -#define GPMI_D0_GPIO (FUNC(3) | PORTF(0, 0) | SE | VE | PE) - -/* Bank 1, GPIO pins 32 ... 63 */ - -#define LCD_ENABLE (FUNC(0) | PORTF(1, 31) | SE | VE | BK) -#define LCD_ENABLE_GPIO (FUNC(3) | PORTF(1, 31) | SE | VE | BK) - -#define LCD_DOTCLK (FUNC(0) | PORTF(1, 30) | SE | VE | BK) - -#define LCD_HSYNC (FUNC(0) | PORTF(1, 29) | SE | VE | BK) - -#define LCD_VSYNC (FUNC(0) | PORTF(1, 28) | SE | VE | BK) - -#define LCD_CS (FUNC(0) | PORTF(1, 27) | SE | VE | BK) -#define LCD_CS_LCD_ENABLE (FUNC(1) | PORTF(1, 27) | SE | VE | BK) -#define LCD_CS_GPIO (FUNC(3) | PORTF(1, 27) | SE | VE | BK) - -#define LCD_RS (FUNC(0) | PORTF(1, 26) | SE | VE | BK) -#define LCD_RS_LCD_DOTCLK (FUNC(1) | PORTF(1, 26) | SE | VE | BK) -#define LCD_RS_GPIO (FUNC(3) | PORTF(1, 26) | SE | VE | BK) -#define LCD_WR_RWN (FUNC(0) | PORTF(1, 25) | SE | VE | BK) -#define LCD_WR_RWN_LCD_HSYNC (FUNC(1) | PORTF(1, 25) | SE | VE | BK) -#define LCD_WR_RWN_ETM_TCLK (FUNC(2) | PORTF(1, 25) | SE | VE | BK) -#define LCD_WR_RWN_GPIO (FUNC(3) | PORTF(1, 25) | SE | VE | BK) -#define LCD_RD_E (FUNC(0) | PORTF(1, 24) | SE | VE | BK) -#define LCD_RD_E_LCD_VSYNC (FUNC(1) | PORTF(1, 24) | SE | VE | BK) -#define LCD_RD_E_ETM_TCTL (FUNC(2) | PORTF(1, 24) | SE | VE | BK) -#define LCD_RD_E_GPIO (FUNC(3) | PORTF(1, 24) | SE | VE | BK) - -#define LCD_D23 (FUNC(0) | PORTF(1, 23) | SE | VE | BK) - -#define LCD_D22 (FUNC(0) | PORTF(1, 22) | SE | VE | BK) - -#define LCD_D21 (FUNC(0) | PORTF(1, 21) | SE | VE | BK) - -#define LCD_D20 (FUNC(0) | PORTF(1, 20) | SE | VE | BK) - -#define LCD_D19 (FUNC(0) | PORTF(1, 19) | SE | VE | BK) - -#define LCD_D18 (FUNC(0) | PORTF(1, 18) | SE | VE | BK) - -#define LCD_D17 (FUNC(0) | PORTF(1, 17) | SE | VE | BK) - -#define LCD_D16 (FUNC(0) | PORTF(1, 16) | SE | VE | BK) - -#define LCD_D15 (FUNC(0) | PORTF(1, 15) | SE | VE | BK) -#define LCD_D15_ETM_DA15 (FUNC(2) | PORTF(1, 15) | SE | VE | BK) -#define LCD_D15_GPIO (FUNC(3) | PORTF(1, 15) | SE | VE | BK) -#define LCD_D14 (FUNC(0) | PORTF(1, 14) | SE | VE | BK) -#define LCD_D14_ETM_DA14 (FUNC(2) | PORTF(1, 14) | SE | VE | BK) -#define LCD_D14_GPIO (FUNC(3) | PORTF(1, 14) | SE | VE | BK) -#define LCD_D13 (FUNC(0) | PORTF(1, 13) | SE | VE | BK) -#define LCD_D13_ETM_DA13 (FUNC(2) | PORTF(1, 13) | SE | VE | BK) -#define LCD_D13_GPIO (FUNC(3) | PORTF(1, 13) | SE | VE | BK) -#define LCD_D12 (FUNC(0) | PORTF(1, 12) | SE | VE | BK) -#define LCD_D12_ETM_DA12 (FUNC(2) | PORTF(1, 12) | SE | VE | BK) -#define LCD_D12_GPIO (FUNC(3) | PORTF(1, 12) | SE | VE | BK) -#define LCD_D11 (FUNC(0) | PORTF(1, 11) | SE | VE | BK) -#define LCD_D11_ETM_DA11 (FUNC(2) | PORTF(1, 11) | SE | VE | BK) -#define LCD_D11_GPIO (FUNC(3) | PORTF(1, 11) | SE | VE | BK) -#define LCD_D10 (FUNC(0) | PORTF(1, 10) | SE | VE | BK) -#define LCD_D10_ETM_DA10 (FUNC(2) | PORTF(1, 10) | SE | VE | BK) -#define LCD_D10_GPIO (FUNC(3) | PORTF(1, 10) | SE | VE | BK) -#define LCD_D9 (FUNC(0) | PORTF(1, 9) | SE | VE | BK) -#define LCD_D9_ETM_DA4 (FUNC(1) | PORTF(1, 9) | SE | VE | BK) -#define LCD_D9_ETM_DA9 (FUNC(2) | PORTF(1, 9) | SE | VE | BK) -#define LCD_D9_GPIO (FUNC(3) | PORTF(1, 9) | SE | VE | BK) -#define LCD_D8 (FUNC(0) | PORTF(1, 8) | SE | VE | BK) -#define LCD_D8_ETM_DA3 (FUNC(1) | PORTF(1, 8) | SE | VE | BK) -#define LCD_D8_ETM_DA8 (FUNC(2) | PORTF(1, 8) | SE | VE | BK) -#define LCD_D8_GPIO (FUNC(3) | PORTF(1, 8) | SE | VE | BK) -#define LCD_D7 (FUNC(0) | PORTF(1, 7) | SE | VE | BK) -#define LCD_D7_ETM_DA7 (FUNC(2) | PORTF(1, 7) | SE | VE | BK) -#define LCD_D7_GPIO (FUNC(3) | PORTF(1, 7) | SE | VE | BK) -#define LCD_D6 (FUNC(0) | PORTF(1, 6) | SE | VE | BK) -#define LCD_D6_ETM_DA6 (FUNC(2) | PORTF(1, 6) | SE | VE | BK) -#define LCD_D6_GPIO (FUNC(3) | PORTF(1, 6) | SE | VE | BK) -#define LCD_D5 (FUNC(0) | PORTF(1, 5) | SE | VE | BK) -#define LCD_D5_ETM_DA5 (FUNC(2) | PORTF(1, 5) | SE | VE | BK) -#define LCD_D5_GPIO (FUNC(3) | PORTF(1, 5) | SE | VE | BK) -#define LCD_D4 (FUNC(0) | PORTF(1, 4) | SE | VE | BK) -#define LCD_D4_ETM_DA9 (FUNC(1) | PORTF(1, 4) | SE | VE | BK) -#define LCD_D4_ETM_DA4 (FUNC(2) | PORTF(1, 4) | SE | VE | BK) -#define LCD_D4_GPIO (FUNC(3) | PORTF(1, 4) | SE | VE | BK) -#define LCD_D3 (FUNC(0) | PORTF(1, 3) | SE | VE | BK) -#define LCD_D3_ETM_DA8 (FUNC(1) | PORTF(1, 3) | SE | VE | BK) -#define LCD_D3_ETM_DA3 (FUNC(2) | PORTF(1, 3) | SE | VE | BK) -#define LCD_D3_GPIO (FUNC(3) | PORTF(1, 3) | SE | VE | BK) -#define LCD_D2 (FUNC(0) | PORTF(1, 2) | SE | VE | BK) -#define LCD_D2_ETM_DA2 (FUNC(2) | PORTF(1, 2) | SE | VE | BK) -#define LCD_D2_GPIO (FUNC(3) | PORTF(1, 2) | SE | VE | BK) -#define LCD_D1 (FUNC(0) | PORTF(1, 1) | SE | VE | BK) -#define LCD_D1_ETM_DA1 (FUNC(2) | PORTF(1, 1) | SE | VE | BK) -#define LCD_D1_GPIO (FUNC(3) | PORTF(1, 1) | SE | VE | BK) -#define LCD_D0 (FUNC(0) | PORTF(1, 0) | SE | VE | BK) -#define LCD_D0_ETM_DA0 (FUNC(2) | PORTF(1, 0) | SE | VE | BK) -#define LCD_D0_GPIO (FUNC(3) | PORTF(1, 0) | SE | VE | BK) - -/* TODO */ - -/* Bank 2, GPIO pins 64 ... 95 */ - -/* TODO */ - -#define SSP1_D3 (FUNC(0) | PORTF(2, 15) | SE | VE | PE) -#define SSP1_D3_SSP2_D7 (FUNC(1) | PORTF(2, 15) | SE | VE | PE) -#define SSP1_D3_ENET_1588_EVENT3_IN (FUNC(2) | PORTF(4, 15) | SE | VE | PE) -#define SSP1_D3_GPIO (FUNC(3) | PORTF(2, 15) | SE | VE | PE) -#define SSP1_D0 (FUNC(0) | PORTF(2, 14) | SE | VE | PE) -#define SSP1_D0_SSP2_D6 (FUNC(1) | PORTF(2, 14) | SE | VE | PE) -#define SSP1_D0_ENET_1588_EVENT3_OUT (FUNC(2) | PORTF(2, 14) | SE | VE | PE) -#define SSP1_D0_GPIO (FUNC(3) | PORTF(2, 14) | SE | VE | PE) -#define SSP1_CMD (FUNC(0) | PORTF(2, 13) | SE | VE | PE) -#define SSP1_CMD_SSP2_D2 (FUNC(1) | PORTF(2, 13) | SE | VE | PE) -#define SSP1_CMD_ENET_1588_EVENT2_IN (FUNC(2) | PORTF(2, 13) | SE | VE | PE) -#define SSP1_CMD_GPIO (FUNC(3) | PORTF(2, 13) | SE | VE | PE) -#define SSP1_SCK (FUNC(0) | PORTF(2, 12) | SE | VE | PE) -#define SSP1_SCK_SSP2_D1 (FUNC(1) | PORTF(2, 12) | SE | VE | PE) -#define SSP1_SCK_ENET_1588_EVENT2_OUT (FUNC(2) | PORTF(2, 12) | SE | VE | PE) -#define SSP1_SCK_GPIO (FUNC(3) | PORTF(2, 12) | SE | VE | PE) -#define SSP0_SCK (FUNC(0) | PORTF(2, 10) | SE | VE | BK) -#define SSP0_SCK_GPIO (FUNC(3) | PORTF(2, 10) | SE | VE | BK) -#define SSP0_CD (FUNC(0) | PORTF(2, 9) | SE | VE | PE) -#define SSP0_CD_GPIO (FUNC(3) | PORTF(2, 9) | SE | VE | PE) -#define SSP0_CMD (FUNC(0) | PORTF(2, 8) | SE | VE | PE) -#define SSP0_CMD_GPIO (FUNC(3) | PORTF(2, 8) | SE | VE | PE) -#define SSP0_D7 (FUNC(0) | PORTF(2, 7) | SE | VE | PE) -#define SSP0_D7_SSP2_SCK (FUNC(1) | PORTF(2, 7) | SE | VE | PE) -#define SSP0_D7_GPIO (FUNC(3) | PORTF(2, 7) | SE | VE | PE) -#define SSP0_D6 (FUNC(0) | PORTF(2, 6) | SE | VE | PE) -#define SSP0_D6_SSP2_CMD (FUNC(1) | PORTF(2, 6) | SE | VE | PE) -#define SSP0_D6_GPIO (FUNC(3) | PORTF(2, 6) | SE | VE | PE) -#define SSP0_D5 (FUNC(0) | PORTF(2, 5) | SE | VE | PE) -#define SSP0_D5_SSP2_D3 (FUNC(1) | PORTF(2, 5) | SE | VE | PE) -#define SSP0_D5_GPIO (FUNC(3) | PORTF(2, 5) | SE | VE | PE) -#define SSP0_D4 (FUNC(0) | PORTF(2, 4) | SE | VE | PE) -#define SSP0_D4_SSP2_D0 (FUNC(1) | PORTF(2, 4) | SE | VE | PE) -#define SSP0_D4_GPIO (FUNC(3) | PORTF(2, 4) | SE | VE | PE) -#define SSP0_D3 (FUNC(0) | PORTF(2, 3) | SE | VE | PE) -#define SSP0_D3_GPIO (FUNC(3) | PORTF(2, 3) | SE | VE | PE) -#define SSP0_D2 (FUNC(0) | PORTF(2, 2) | SE | VE | PE) -#define SSP0_D2_GPIO (FUNC(3) | PORTF(2, 2) | SE | VE | PE) -#define SSP0_D1 (FUNC(0) | PORTF(2, 1) | SE | VE | PE) -#define SSP0_D1_GPIO (FUNC(3) | PORTF(2, 1) | SE | VE | PE) -#define SSP0_D0 (FUNC(0) | PORTF(2, 0) | SE | VE | PE) -#define SSP0_D0_GPIO (FUNC(3) | PORTF(2, 0) | SE | VE | PE) - -/* Bank 3, GPIO pins 96 ... 127 */ - -#define LCD_RESET (FUNC(0) | PORTF(3, 30)) -#define LCD_RESET_LCD_VSYNC (FUNC(1) | PORTF(3, 30)) -#define LCD_RESET_GPIO (FUNC(3) | PORTF(3, 30)) -#define PWM4 (FUNC(0) | PORTF(3, 29)) -#define PWM4_GPIO (FUNC(3) | PORTF(3, 29)) -#define PWM3 (FUNC(0) | PORTF(3 28)) -#define PWM3_GPIO (FUNC(3) | PORTF(3, 28)) - -#define PWM2 (FUNC(0) | PORTF(3, 18)) - -#define PWM1 (FUNC(0) | PORTF(3, 17)) - -#define PWM0 (FUNC(0) | PORTF(3, 16)) -#define PWM0_I2C1_SCL (FUNC(1) | PORTF(3, 16)) -#define PWM0_DUART_RX (FUNC(2) | PORTF(3, 16)) -#define PWM0_GPIO (FUNC(3) | PORTF(3, 16)) -#define AUART3_RTS (FUNC(0) | PORTF(3, 15) | SE | VE | BK) -#define AUART3_RTS_CAN1_RX (FUNC(1) | PORTF(3, 15) | SE | VE | BK) -#define AUART3_RTS_ENET0_1588_EVENT1_IN (FUNC(2) | PORTF(3, 15) | SE | VE | BK) -#define AUART3_RTS_GPIO (FUNC(3) | PORTF(3, 15) | SE | VE | BK) -#define AUART3_CTS (FUNC(0) | PORTF(3, 14) | SE | VE | BK | BK) -#define AUART3_CTS_CAN1_TX (FUNC(1) | PORTF(3, 14) | SE | VE | BK) -#define AUART3_CTS_ENET0_1588_EVENT1_OUT (FUNC(2) | PORTF(3, 14) | SE | VE | BK) -#define AUART3_CTS_GPIO (FUNC(3) | PORTF(3, 14) | SE | VE | BK) -#define AUART3_TX (FUNC(0) | PORTF(3, 13) | SE | VE | BK) -#define AUART3_TX_CAN0_RX (FUNC(1) | PORTF(3, 13) | SE | VE | BK) -#define AUART3_TX_ENET0_1588_EVENT0_IN (FUNC(2) | PORTF(3, 13) | SE | VE | BK) -#define AUART3_TX_GPIO (FUNC(3) | PORTF(3, 13) | SE | VE | BK) -#define AUART3_RX (FUNC(0) | PORTF(3, 12) | SE | VE | BK) -#define AUART3_RX_CAN0_TX (FUNC(1) | PORTF(3, 12) | SE | VE | BK) -#define AUART3_RX_ENET0_1588_EVENT0_OUT (FUNC(2) | PORTF(3, 12) | SE | VE | BK) -#define AUART3_RX_GPIO (FUNC(3) | PORTF(3, 12) | SE | VE | BK) -#define AUART2_RTS (FUNC(0) | PORTF(3, 11) | SE | VE | BK) -#define AUART2_RTS_I2C1_SDA (FUNC(1) | PORTF(3, 11) | SE | VE | BK) -#define AUART2_RTS_SAIF1_IRCLK (FUNC(2) | PORTF(3, 11) | SE | VE | BK) -#define AUART2_RTS_GPIO (FUNC(3) | PORTF(3, 11) | SE | VE | BK) -#define AUART2_CTS (FUNC(0) | PORTF(3, 10) | SE | VE | BK) -#define AUART2_CTS_I2C1_SCL (FUNC(1) | PORTF(3, 10) | SE | VE | BK) -#define AUART2_CTS_SAIF1_BITCLK (FUNC(2) | PORTF(3, 10) | SE | VE | BK) -#define AUART2_CTS_GPIO (FUNC(3) | PORTF(3, 10) | SE | VE | BK) -#define AUART2_TX (FUNC(0) | PORTF(3, 9) | SE | VE | PE) -#define AUART2_TX_SSP3_D2 (FUNC(1) | PORTF(3, 9) | SE | VE | PE) -#define AUART2_TX_SSP3_D5 (FUNC(2) | PORTF(3, 9) | SE | VE | PE) -#define AUART2_TX_GPIO (FUNC(3) | PORTF(3, 9) | SE | VE | PE) -#define AUART2_RX (FUNC(0) | PORTF(3, 8) | SE | VE | PE) -#define AUART2_RX_SSP3_D1 (FUNC(1) | PORTF(3, 8) | SE | VE | PE) -#define AUART2_RX_SSP3_D4 (FUNC(2) | PORTF(3, 8) | SE | VE | PE) -#define AUART2_RX_GPIO (FUNC(3) | PORTF(3, 8) | SE | VE | PE) -#define AUART1_RTS (FUNC(0) | PORTF(3, 7) | SE | VE | PE) -#define AUART1_RTS_USB0_ID (FUNC(1) | PORTF(3, 7) | SE | VE | PE) -#define AUART1_RTS_ROTARYB (FUNC(2) | PORTF(3, 7) | SE | VE | PE) -#define AUART1_RTS_GPIO (FUNC(3) | PORTF(3, 7) | SE | VE | PE) -#define AUART1_CTS (FUNC(0) | PORTF(3, 6) | SE | VE | PE) -#define AUART1_CTS_USB0_OC (FUNC(1) | PORTF(3, 6) | SE | VE | PE) -#define AUART1_CTS_ROTARYA (FUNC(2) | PORTF(3, 6) | SE | VE | PE) -#define AUART1_CTS_GPIO (FUNC(3) | PORTF(3, 6) | SE | VE | PE) -#define AUART1_TX (FUNC(0) | PORTF(3, 5) | SE | VE | BK) -#define AUART1_TX_SSP3_CD (FUNC(1) | PORTF(3, 5) | SE | VE | BK) -#define AUART1_TX_PWM1 (FUNC(2) | PORTF(3, 5) | SE | VE | BK) -#define AUART1_TX_GPIO (FUNC(3) | PORTF(3, 5) | SE | VE | BK) -#define AUART1_RX (FUNC(0) | PORTF(3, 4) | SE | VE | BK) -#define AUART1_RX_SSP2_CD (FUNC(1) | PORTF(3, 4) | SE | VE | BK) -#define AUART1_RX_PWM0 (FUNC(2) | PORTF(3, 4) | SE | VE | BK) -#define AUART1_RX_GPIO (FUNC(3) | PORTF(3, 4) | SE | VE | BK) -#define AUART0_RTS (FUNC(0) | PORTF(3, 3) | SE | VE | BK) -#define AUART0_RTS_AUART4_TX (FUNC(1) | PORTF(3, 3) | SE | VE | BK) -#define AUART0_RTS_DUART_TX (FUNC(2) | PORTF(3, 3) | SE | VE | BK) -#define AUART0_RTS_GPIO (FUNC(3) | PORTF(3, 3) | SE | VE | BK) -#define AUART0_CTS (FUNC(0) | PORTF(3, 2) | SE | VE | BK) -#define AUART0_CTS_AUART4_RX (FUNC(1) | PORTF(3, 2) | SE | VE | BK) -#define AUART0_CTS_DUART_RX (FUNC(2) | PORTF(3, 2) | SE | VE | BK) -#define AUART0_CTS_GPIO (FUNC(3) | PORTF(3, 2) | SE | VE | BK) -#define AUART0_TX (FUNC(0) | PORTF(3, 1) | SE | VE | BK) -#define AUART0_TX_I2C0_SDA (FUNC(1) | PORTF(3, 1) | SE | VE | BK) -#define AUART0_TX_DUART_RTS (FUNC(2) | PORTF(3, 1) | SE | VE | BK) -#define AUART0_TX_GPIO (FUNC(3) | PORTF(3, 1) | SE | VE | BK) -#define AUART0_RX (FUNC(0) | PORTF(3, 0) | SE | VE | BK) -#define AUART0_RX_I2C0_SCL (FUNC(1) | PORTF(3, 0) | SE | VE | BK) -#define AUART0_RX_DUART_CTS (FUNC(2) | PORTF(3, 0) | SE | VE | BK) -#define AUART0_RX_GPIO (FUNC(3) | PORTF(3, 0) | SE | VE | BK) - -/* Bank 4, GPIO pins 128 ... 159 */ - -#define JTAG_RTCK (FUNC(0) | PORTF(4, 20) | SE | VE | BK) -#define JTAG_RTCK_GPIO (FUNC(3) | PORTF(4, 20) | SE | VE | BK) -#define ENET_CLK (FUNC(0) | PORTF(4, 16) | SE | VE | BK) -#define ENET_CLK_GPIO (FUNC(3) | PORTF(4, 16) | SE | VE | BK) - -#define ENET0_CRS (FUNC(0) | PORTF(4, 15) | SE | VE | BK) - -#define ENET0_COL (FUNC(0) | PORTF(4, 14) | SE | VE | BK) - -#define ENET0_RX_CLK (FUNC(0) | PORTF(4, 13) | SE | VE | BK) -#define ENET0_RX_CLK_RX_ER (FUNC(1) | PORTF(4, 13) | SE | VE | BK) -#define ENET0_RX_ENET0_1588_EVENT2_IN (FUNC(2) | PORTF(4, 13) | SE | VE | BK) -#define ENET0_RX_CLK_GPIO (FUNC(3) | PORTF(4, 13) | SE | VE | BK) -#define ENET0_TXD3 (FUNC(0) | PORTF(4, 12) | SE | VE | BK) -#define ENET0_TXD3_ENET1_TXD1 (FUNC(1) | PORTF(4, 12) | SE | VE | BK) -#define ENET0_TXD3_ENET0_1588_EVENT1_IN (FUNC(2) | PORTF(4, 12) | SE | VE | BK) -#define ENET0_TXD3_GPIO (FUNC(3) | PORTF(4, 12) | SE | VE | BK) - -#define ENET0_TXD2 (FUNC(0) | PORTF(4, 11) | SE | VE | BK) - -#define ENET0_TXD2_GPIO (FUNC(3) | PORTF(4, 11) | SE | VE | BK) - -#define ENET0_RXD3 (FUNC(0) | PORTF(4, 10) | SE | VE | BK) -#define ENET0_RXD3_ENET1_RXD1 (FUNC(1) | PORTF(4, 10) | SE | VE | BK) -#define ENET0_RXD3_ENET0_1588_EVENT0_IN (FUNC(2) | PORTF(4, 10) | SE | VE | BK) -#define ENET0_RXD3_GPIO (FUNC(3) | PORTF(4, 10) | SE | VE | BK) - -#define ENET0_RXD2 (FUNC(0) | PORTF(4, 9) | SE | VE | BK) - -#define ENET0_RXD2_GPIO (FUNC(3) | PORTF(4, 9) | SE | VE | BK) - -#define ENET0_TXD1 (FUNC(0) | PORTF(4, 8) | SE | VE | PE) - -#define ENET0_TXD1_GPIO (FUNC(3) | PORTF(4, 8) | SE | VE | PE) - -#define ENET0_TXD0 (FUNC(0) | PORTF(4, 7) | SE | VE | PE) - -#define ENET0_TXD0_GPIO (FUNC(3) | PORTF(4, 7) | SE | VE | PE) - -#define ENET0_TX_EN (FUNC(0) | PORTF(4, 6) | SE | VE | PE) - -#define ENET0_TX_EN_GPIO (FUNC(3) | PORTF(4, 6) | SE | VE | PE) - -#define ENET0_TX_CLK (FUNC(0) | PORTF(4, 5) | SE | VE | BK) - -#define ENET0_TX_CLK_GPIO (FUNC(3) | PORTF(4, 5) | SE | VE | BK) - -#define ENET0_RXD1 (FUNC(0) | PORTF(4, 4) | SE | VE | PE) -#define ENET0_RXD1_GPMI_READY4 (FUNC(1) | PORTF(4, 4) | SE | VE | PE) -#define ENET0_RXD1_GPIO (FUNC(3) | PORTF(4, 4) | SE | VE | PE) -#define ENET0_RXD0 (FUNC(0) | PORTF(4, 3) | SE | VE | PE) -#define ENET0_RXD0_GPMI_CE7N (FUNC(1) | PORTF(4, 3) | SE | VE | PE) -#define ENET0_RXD0_SAIF1_SDATA2 (FUNC(2) | PORTF(4, 3) | SE | VE | PE) -#define ENET0_RXD0_GPIO (FUNC(3) | PORTF(4, 3) | SE | VE | PE) -#define ENET0_RX_EN (FUNC(0) | PORTF(4, 2) | SE | VE | PE) -#define ENET0_RX_EN_GPMI_CE6N (FUNC(1) | PORTF(4, 2) | SE | VE | PE) -#define ENET0_RX_EN_SAIF1_SDATA1 (FUNC(2) | PORTF(4, 2) | SE | VE | PE) -#define ENET0_RX_EN_GPIO (FUNC(3) | PORTF(4, 2) | SE | VE | PE) -#define ENET0_MDIO (FUNC(0) | PORTF(4, 1) | SE | VE | PE) -#define ENET0_MDIO_GPMI_CE5N (FUNC(1) | PORTF(4, 1) | SE | VE | PE) -#define ENET0_MDIO_SAIF0_SDATA2 (FUNC(2) | PORTF(4, 1) | SE | VE | PE) -#define ENET0_MDIO_GPIO (FUNC(3) | PORTF(4, 1) | SE | VE | PE) -#define ENET0_MDC (FUNC(0) | PORTF(4, 0) | SE | VE | PE) -#define ENET0_MDC_GPMI_CE4N (FUNC(1) | PORTF(4, 0) | SE | VE | PE) -#define ENET0_MDC_SAIF0_SDATA1 (FUNC(2) | PORTF(4, 0) | SE | VE | PE) -#define ENET0_MDC_GPIO (FUNC(3) | PORTF(4, 0) | SE | VE | PE) - -/* - * Bank 5, GPIO pins 160 ... 191 - * Note: These pins are disabled instead of being GPIOs - */ -#define EMI_DDR_OPEN (FUNC(0) | PORTF(5, 26) | BK) -#define EMI_DDR_OPEN_OFF (FUNC(3) | PORTF(5, 26) | BK) -#define EMI_DSQ1 (FUNC(0) | PORTF(5, 23) | BK) -#define EMI_DSQ1_OFF (FUNC(3) | PORTF(5, 23) | BK) -#define EMI_DSQ0 (FUNC(0) | PORTF(5, 22) | BK) -#define EMI_DSQ0_OFF (FUNC(3) | PORTF(5, 22) | BK) -#define EMI_CLK (FUNC(0) | PORTF(5, 21) | BK) -#define EMI_CLK_OFF (FUNC(3) | PORTF(5, 21) | BK) -#define EMI_DDR_OPEN_FB (FUNC(0) | PORTF(5, 20) | BK) -#define EMI_DDR_OPEN_FB_OFF (FUNC(3) | PORTF(5, 20) | BK) -#define EMI_DQM1 (FUNC(0) | PORTF(5, 19) | BK) -#define EMI_DQM1_OFF (FUNC(3) | PORTF(5, 19) | BK) -#define EMI_ODT1 (FUNC(0) | PORTF(5, 18) | BK) -#define EMI_ODT1_OFF (FUNC(3) | PORTF(5, 18) | BK) -#define EMI_DQM0 (FUNC(0) | PORTF(5, 17) | BK) -#define EMI_DQM0_OFF (FUNC(3) | PORTF(5, 17) | BK) -#define EMI_ODT0 (FUNC(0) | PORTF(5, 16) | BK) -#define EMI_ODT0_OFF (FUNC(3) | PORTF(5, 16) | BK) -#define EMI_DATA15 (FUNC(0) | PORTF(5, 15) | BK) -#define EMI_DATA15_OFF (FUNC(3) | PORTF(5, 15) | BK) -#define EMI_DATA14 (FUNC(0) | PORTF(5, 14) | BK) -#define EMI_DATA14_OFF (FUNC(3) | PORTF(5, 14) | BK) -#define EMI_DATA13 (FUNC(0) | PORTF(5, 13) | BK) -#define EMI_DATA13_OFF (FUNC(3) | PORTF(5, 13) | BK) -#define EMI_DATA12 (FUNC(0) | PORTF(5, 12) | BK) -#define EMI_DATA12_OFF (FUNC(3) | PORTF(5, 12) | BK) -#define EMI_DATA11 (FUNC(0) | PORTF(5, 11) | BK) -#define EMI_DATA10_OFF (FUNC(3) | PORTF(5, 10) | BK) -#define EMI_DATA10 (FUNC(0) | PORTF(5, 10) | BK) -#define EMI_DATA10_OFF (FUNC(3) | PORTF(5, 10) | BK) -#define EMI_DATA9 (FUNC(0) | PORTF(5, 9) | BK) -#define EMI_DATA9_OFF (FUNC(3) | PORTF(5, 9) | BK) -#define EMI_DATA8 (FUNC(0) | PORTF(5, 8) | BK) -#define EMI_DATA8_OFF (FUNC(3) | PORTF(5, 8) | BK) -#define EMI_DATA7 (FUNC(0) | PORTF(5, 7) | BK) -#define EMI_DATA7_OFF (FUNC(3) | PORTF(5, 7) | BK) -#define EMI_DATA6 (FUNC(0) | PORTF(5, 6) | BK) -#define EMI_DATA6_OFF (FUNC(3) | PORTF(5, 6) | BK) -#define EMI_DATA5 (FUNC(0) | PORTF(5, 5) | BK) -#define EMI_DATA5_OFF (FUNC(3) | PORTF(5, 5) | BK) -#define EMI_DATA4 (FUNC(0) | PORTF(5, 4) | BK) -#define EMI_DATA4_OFF (FUNC(3) | PORTF(5, 4) | BK) -#define EMI_DATA3 (FUNC(0) | PORTF(5, 3) | BK) -#define EMI_DATA3_OFF (FUNC(3) | PORTF(5, 3) | BK) -#define EMI_DATA2 (FUNC(0) | PORTF(5, 2) | BK) -#define EMI_DATA2_OFF (FUNC(3) | PORTF(5, 2) | BK) -#define EMI_DATA1 (FUNC(0) | PORTF(5, 1) | BK) -#define EMI_DATA1_OFF (FUNC(3) | PORTF(5, 1) | BK) -#define EMI_DATA0 (FUNC(0) | PORTF(5, 0) | BK) -#define EMI_DATA0_OFF (FUNC(3) | PORTF(5, 0) | BK) - -/* - * Bank 6, GPIO pins 192 ... 223 - * Note: This pins are disabled instead of being GPIOs - */ -#define EMI_CKE (FUNC(0) | PORTF(6, 24) | BK) -#define EMI_CKE_OFF (FUNC(3) | PORTF(6, 24) | BK) -#define EMI_CE1N (FUNC(0) | PORTF(6, 23) | BK) -#define EMI_CE1N_OFF (FUNC(3) | PORTF(6, 23) | BK) -#define EMI_CE0N (FUNC(0) | PORTF(6, 22) | BK) -#define EMI_CE0N_OFF (FUNC(3) | PORTF(6, 22) | BK) -#define EMI_WEN (FUNC(0) | PORTF(6, 21) | BK) -#define EMI_WEN_OFF (FUNC(3) | PORTF(6, 21) | BK) -#define EMI_RASN (FUNC(0) | PORTF(6, 20) | BK) -#define EMI_RASN_OFF (FUNC(3) | PORTF(6, 20) | BK) -#define EMI_CASN (FUNC(0) | PORTF(6, 19) | BK) -#define EMI_CASN_OFF (FUNC(3) | PORTF(6, 19) | BK) -#define EMI_BA2 (FUNC(0) | PORTF(6, 18) | BK) -#define EMI_BA2_OFF (FUNC(3) | PORTF(6, 18) | BK) -#define EMI_BA1 (FUNC(0) | PORTF(6, 17) | BK) -#define EMI_BA1_OFF (FUNC(3) | PORTF(6, 17) | BK) -#define EMI_BA0 (FUNC(0) | PORTF(6, 16) | BK) -#define EMI_BA0_OFF (FUNC(3) | PORTF(6, 16) | BK) -#define EMI_A14 (FUNC(0) | PORTF(6, 14) | BK) -#define EMI_A14_OFF (FUNC(3) | PORTF(6, 14) | BK) -#define EMI_A13 (FUNC(0) | PORTF(6, 13) | BK) -#define EMI_A13_OFF (FUNC(3) | PORTF(6, 13) | BK) -#define EMI_A12 (FUNC(0) | PORTF(6, 12) | BK) -#define EMI_A12_OFF (FUNC(3) | PORTF(6, 12) | BK) -#define EMI_A11 (FUNC(0) | PORTF(6, 11) | BK) -#define EMI_A11_OFF (FUNC(3) | PORTF(6, 11) | BK) -#define EMI_A10 (FUNC(0) | PORTF(6, 10) | BK) -#define EMI_A10_OFF (FUNC(3) | PORTF(6, 10) | BK) -#define EMI_A9 (FUNC(0) | PORTF(6, 9) | BK) -#define EMI_A9_OFF (FUNC(3) | PORTF(6, 9) | BK) -#define EMI_A8 (FUNC(0) | PORTF(6, 8) | BK) -#define EMI_A8_OFF (FUNC(3) | PORTF(6, 8) | BK) -#define EMI_A7 (FUNC(0) | PORTF(6, 7) | BK) -#define EMI_A7_OFF (FUNC(3) | PORTF(6, 7) | BK) -#define EMI_A6 (FUNC(0) | PORTF(6, 6) | BK) -#define EMI_A6_OFF (FUNC(3) | PORTF(6, 6) | BK) -#define EMI_A5 (FUNC(0) | PORTF(6, 5) | BK) -#define EMI_A5_OFF (FUNC(3) | PORTF(6, 5) | BK) -#define EMI_A4 (FUNC(0) | PORTF(6, 4) | BK) -#define EMI_A4_OFF (FUNC(3) | PORTF(6, 4) | BK) -#define EMI_A3 (FUNC(0) | PORTF(6, 3) | BK) -#define EMI_A3_OFF (FUNC(3) | PORTF(6, 3) | BK) -#define EMI_A2 (FUNC(0) | PORTF(6, 2) | BK) -#define EMI_A2_OFF (FUNC(3) | PORTF(6, 2) | BK) -#define EMI_A1 (FUNC(0) | PORTF(6, 1) | BK) -#define EMI_A1_OFF (FUNC(3) | PORTF(6, 1) | BK) -#define EMI_A0 (FUNC(0) | PORTF(6, 0) | BK) -#define EMI_A0_OFF (FUNC(3) | PORTF(6, 0) | BK) - -#endif /* __MACH_IOMUX_IMX28_H */ diff --git a/arch/arm/mach-stm/include/mach/mci.h b/arch/arm/mach-stm/include/mach/mci.h deleted file mode 100644 index b924908..0000000 --- a/arch/arm/mach-stm/include/mach/mci.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 __MACH_MMC_H -#define __MACH_MMC_H - -struct stm_mci_platform_data { - unsigned caps; /**< supported operating modes (MMC_MODE_*) */ - unsigned voltages; /**< supported voltage range (MMC_VDD_*) */ - unsigned f_min; /**< min operating frequency in Hz (0 -> no limit) */ - unsigned f_max; /**< max operating frequency in Hz (0 -> no limit) */ - /* TODO */ - /* function to modify the voltage */ - /* function to switch the voltage */ - /* function to detect the presence of a SD card in the socket */ -}; - -#endif /* __MACH_MMC_H */ diff --git a/arch/arm/mach-stm/iomux-imx.c b/arch/arm/mach-stm/iomux-imx.c deleted file mode 100644 index bf6165f..0000000 --- a/arch/arm/mach-stm/iomux-imx.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * (C) Copyright 2010 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. - * - * 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 -#include -#include -#include -#include -#include - -#define HW_PINCTRL_CTRL 0x000 -#define HW_PINCTRL_MUXSEL0 0x100 - -#ifdef CONFIG_ARCH_IMX23 -#define HW_PINCTRL_DRIVE0 0x200 -#define HW_PINCTRL_PULL0 0x400 -#define HW_PINCTRL_DOUT0 0x500 -#define HW_PINCTRL_DIN0 0x600 -#define HW_PINCTRL_DOE0 0x700 - -#define MAX_GPIO_NO 95 -#endif - -#ifdef CONFIG_ARCH_IMX28 -#define HW_PINCTRL_DRIVE0 0x300 -#define HW_PINCTRL_PULL0 0x600 -#define HW_PINCTRL_DOUT0 0x700 -#define HW_PINCTRL_DIN0 0x900 -#define HW_PINCTRL_DOE0 0xb00 - -#define MAX_GPIO_NO 159 -#endif - -static unsigned calc_mux_reg(unsigned no) -{ - /* each register controls 16 pads */ - return ((no >> 4) << 4) + HW_PINCTRL_MUXSEL0; -} - -static unsigned calc_strength_reg(unsigned no) -{ - /* each register controls 8 pads */ - return ((no >> 3) << 4) + HW_PINCTRL_DRIVE0; -} - -static unsigned calc_pullup_reg(unsigned no) -{ - /* each register controls 32 pads */ - return ((no >> 5) << 4) + HW_PINCTRL_PULL0; -} - -static unsigned calc_output_enable_reg(unsigned no) -{ - /* each register controls 32 pads */ - return ((no >> 5) << 4) + HW_PINCTRL_DOE0; -} - -static unsigned calc_output_reg(unsigned no) -{ - /* each register controls 32 pads */ - return ((no >> 5) << 4) + HW_PINCTRL_DOUT0; -} - -static unsigned calc_input_reg(unsigned no) -{ - /* each register controls 32 pads */ - return ((no >> 5) << 4) + HW_PINCTRL_DIN0; -} - -/** - * @param[in] m One pin define per call from iomux-mx23.h/iomux-mx28.h - */ -void imx_gpio_mode(uint32_t m) -{ - uint32_t reg; - unsigned gpio_pin, reg_offset; - - gpio_pin = GET_GPIO_NO(m); - - /* configure the pad to its function (always) */ - reg_offset = calc_mux_reg(gpio_pin); - reg = readl(IMX_IOMUXC_BASE + reg_offset) & ~(0x3 << ((gpio_pin % 16) << 1)); - reg |= GET_FUNC(m) << ((gpio_pin % 16) << 1); - writel(reg, IMX_IOMUXC_BASE + reg_offset); - - /* some pins are disabled when configured for GPIO */ - if ((gpio_pin > MAX_GPIO_NO) && (GET_FUNC(m) == IS_GPIO)) { - printf("Cannot configure pad %d to GPIO\n", gpio_pin); - return; - } - - if (SE_PRESENT(m)) { - reg_offset = calc_strength_reg(gpio_pin); - reg = readl(IMX_IOMUXC_BASE + reg_offset) & ~(0x3 << ((gpio_pin % 8) << 2)); - reg |= GET_STRENGTH(m) << ((gpio_pin % 8) << 2); - writel(reg, IMX_IOMUXC_BASE + reg_offset); - } - - if (VE_PRESENT(m)) { - reg_offset = calc_strength_reg(gpio_pin); - if (GET_VOLTAGE(m) == 1) - writel(0x1 << (((gpio_pin % 8) << 2) + 2), - IMX_IOMUXC_BASE + reg_offset + BIT_SET); - else - writel(0x1 << (((gpio_pin % 8) << 2) + 2), - IMX_IOMUXC_BASE + reg_offset + BIT_CLR); - } - - if (PE_PRESENT(m)) { - reg_offset = calc_pullup_reg(gpio_pin); - writel(0x1 << (gpio_pin % 32), IMX_IOMUXC_BASE + reg_offset + - (GET_PULLUP(m) == 1 ? BIT_SET : BIT_CLR)); - } - - if (GET_FUNC(m) == IS_GPIO) { - if (GET_GPIODIR(m) == 1) { - /* first set the output value */ - reg_offset = calc_output_reg(gpio_pin); - writel(0x1 << (gpio_pin % 32), IMX_IOMUXC_BASE + - reg_offset + (GET_GPIOVAL(m) == 1 ? BIT_SET : BIT_CLR)); - /* then the direction */ - reg_offset = calc_output_enable_reg(gpio_pin); - writel(0x1 << (gpio_pin % 32), - IMX_IOMUXC_BASE + reg_offset + BIT_SET); - } else { - /* then the direction */ - reg_offset = calc_output_enable_reg(gpio_pin); - writel(0x1 << (gpio_pin % 32), - IMX_IOMUXC_BASE + reg_offset + BIT_CLR); - } - } -} - -int gpio_direction_input(unsigned gpio) -{ - unsigned reg_offset; - - if (gpio > MAX_GPIO_NO) - return -EINVAL; - - reg_offset = calc_output_enable_reg(gpio); - writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + reg_offset + BIT_CLR); - - return 0; -} - -int gpio_direction_output(unsigned gpio, int val) -{ - unsigned reg_offset; - - if (gpio > MAX_GPIO_NO) - return -EINVAL; - - /* first set the output value... */ - reg_offset = calc_output_reg(gpio); - writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + - reg_offset + (val != 0 ? BIT_SET : BIT_CLR)); - /* ...then the direction */ - reg_offset = calc_output_enable_reg(gpio); - writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + reg_offset + BIT_SET); - - return 0; -} - -void gpio_set_value(unsigned gpio, int val) -{ - unsigned reg_offset; - - reg_offset = calc_output_reg(gpio); - writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + - reg_offset + (val != 0 ? BIT_SET : BIT_CLR)); -} - -int gpio_get_value(unsigned gpio) -{ - uint32_t reg; - unsigned reg_offset; - - reg_offset = calc_input_reg(gpio); - reg = readl(IMX_IOMUXC_BASE + reg_offset); - if (reg & (0x1 << (gpio % 32))) - return 1; - - return 0; -} diff --git a/arch/arm/mach-stm/reset-imx.c b/arch/arm/mach-stm/reset-imx.c deleted file mode 100644 index b35f796..0000000 --- a/arch/arm/mach-stm/reset-imx.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * (C) Copyright 2010 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. - * - * 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 -#include -#include -#include -#include - -#define HW_RTC_CTRL 0x000 -# define BM_RTC_CTRL_WATCHDOGEN (1 << 4) -#define HW_RTC_CTRL_SET 0x004 -#define HW_RTC_CTRL_CLR 0x008 -#define HW_RTC_CTRL_TOG 0x00C - -#define HW_RTC_WATCHDOG 0x050 -#define HW_RTC_WATCHDOG_SET 0x054 -#define HW_RTC_WATCHDOG_CLR 0x058 -#define HW_RTC_WATCHDOG_TOG 0x05C - -#define WDOG_COUNTER_RATE 1000 /* 1 kHz clock */ - -#define HW_RTC_PERSISTENT1 0x070 -# define BV_RTC_PERSISTENT1_GENERAL__RTC_FORCE_UPDATER 0x80000000 -#define HW_RTC_PERSISTENT1_SET 0x074 -#define HW_RTC_PERSISTENT1_CLR 0x078 -#define HW_RTC_PERSISTENT1_TOG 0x07C - -/* - * Reset the cpu by setting up the watchdog timer and let it time out - * - * TODO There is a much easier way to reset the CPU: Refer bit 2 in - * the HW_CLKCTRL_RESET register, data sheet page 106/4-30 - */ -void __noreturn reset_cpu (unsigned long addr) -{ - writel(WDOG_COUNTER_RATE, IMX_WDT_BASE + HW_RTC_WATCHDOG); - writel(BM_RTC_CTRL_WATCHDOGEN, IMX_WDT_BASE + HW_RTC_CTRL_SET); - writel(BV_RTC_PERSISTENT1_GENERAL__RTC_FORCE_UPDATER, IMX_WDT_BASE + HW_RTC_PERSISTENT1); - - while (1) - ; - /*NOTREACHED*/ -} -EXPORT_SYMBOL(reset_cpu); diff --git a/arch/arm/mach-stm/speed-imx23.c b/arch/arm/mach-stm/speed-imx23.c deleted file mode 100644 index a31139d..0000000 --- a/arch/arm/mach-stm/speed-imx23.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * (C) Copyright 2010 Juergen Beisert - Pengutronix - * - * This code is based partially on code of: - * - * (c) 2008 Embedded Alley Solutions, Inc. - * (C) Copyright 2009-2010 Freescale Semiconductor, 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 - */ - -#include -#include -#include -#include -#include -#include - -#define HW_CLKCTRL_PLLCTRL0 0x000 -#define HW_CLKCTRL_PLLCTRL1 0x010 -#define HW_CLKCTRL_CPU 0x20 -# define GET_CPU_XTAL_DIV(x) (((x) >> 16) & 0x3ff) -# define GET_CPU_PLL_DIV(x) ((x) & 0x3f) -#define HW_CLKCTRL_HBUS 0x30 -#define HW_CLKCTRL_XBUS 0x40 -#define HW_CLKCTRL_XTAL 0x050 -#define HW_CLKCTRL_PIX 0x060 -/* note: no set/clear register! */ -#define HW_CLKCTRL_SSP 0x070 -/* note: no set/clear register! */ -# define CLKCTRL_SSP_CLKGATE (1 << 31) -# define CLKCTRL_SSP_BUSY (1 << 29) -# define CLKCTRL_SSP_DIV_MASK 0x1ff -# define GET_SSP_DIV(x) ((x) & CLKCTRL_SSP_DIV_MASK) -# define SET_SSP_DIV(x) ((x) & CLKCTRL_SSP_DIV_MASK) -#define HW_CLKCTRL_GPMI 0x080 -/* note: no set/clear register! */ -#define HW_CLKCTRL_SPDIF 0x090 -/* note: no set/clear register! */ -#define HW_CLKCTRL_EMI 0xa0 -/* note: no set/clear register! */ -# define CLKCTRL_EMI_CLKGATE (1 << 31) -# define GET_EMI_XTAL_DIV(x) (((x) >> 8) & 0xf) -# define GET_EMI_PLL_DIV(x) ((x) & 0x3f) -#define HW_CLKCTRL_SAIF 0x0c0 -#define HW_CLKCTRL_TV 0x0d0 -#define HW_CLKCTRL_ETM 0x0e0 -#define HW_CLKCTRL_FRAC 0xf0 -# define CLKCTRL_FRAC_CLKGATEIO (1 << 31) -# define GET_IOFRAC(x) (((x) >> 24) & 0x3f) -# define SET_IOFRAC(x) (((x) & 0x3f) << 24) -# define CLKCTRL_FRAC_CLKGATEPIX (1 << 23) -# define GET_PIXFRAC(x) (((x) >> 16) & 0x3f) -# define CLKCTRL_FRAC_CLKGATEEMI (1 << 15) -# define GET_EMIFRAC(x) (((x) >> 8) & 0x3f) -# define CLKCTRL_FRAC_CLKGATECPU (1 << 7) -# define GET_CPUFRAC(x) ((x) & 0x3f) -#define HW_CLKCTRL_FRAC1 0x100 -#define HW_CLKCTRL_CLKSEQ 0x110 -# define CLKCTRL_CLKSEQ_BYPASS_ETM (1 << 8) -# define CLKCTRL_CLKSEQ_BYPASS_CPU (1 << 7) -# define CLKCTRL_CLKSEQ_BYPASS_EMI (1 << 6) -# define CLKCTRL_CLKSEQ_BYPASS_SSP (1 << 5) -# define CLKCTRL_CLKSEQ_BYPASS_GPMI (1 << 4) -#define HW_CLKCTRL_RESET 0x120 -#define HW_CLKCTRL_STATUS 0x130 -#define HW_CLKCTRL_VERSION 0x140 - -unsigned imx_get_mpllclk(void) -{ - /* the main PLL runs at 480 MHz */ - return 480000000; -} - -unsigned imx_get_xtalclk(void) -{ - /* the external reference runs at 24 MHz */ - return 24000000; -} - -/* used for the SDRAM controller */ -unsigned imx_get_emiclk(void) -{ - uint32_t reg; - unsigned rate; - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_EMI) & CLKCTRL_EMI_CLKGATE) - return 0U; /* clock is off */ - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & CLKCTRL_CLKSEQ_BYPASS_EMI) - return imx_get_xtalclk() / GET_EMI_XTAL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_EMI)); - - rate = imx_get_mpllclk() / 1000; - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC); - if (!(reg & CLKCTRL_FRAC_CLKGATEEMI)) { - rate *= 18U; - rate /= GET_EMIFRAC(reg); - } - - return (rate / GET_EMI_PLL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_EMI))) - * 1000; -} - -/* - * Source of ssp, gpmi, ir - */ -unsigned imx_get_ioclk(void) -{ - uint32_t reg; - unsigned rate = imx_get_mpllclk() / 1000; - - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC); - if (reg & CLKCTRL_FRAC_CLKGATEIO) - return 0U; /* clock is off */ - - rate *= 18U; - rate /= GET_IOFRAC(reg); - return rate * 1000; -} - -/** - * Setup a new frequency to the IOCLK domain. - * @param nc New frequency in [Hz] - * - * The FRAC divider for the IOCLK must be between 18 (* 18/18) and 35 (* 18/35) - */ -unsigned imx_set_ioclk(unsigned nc) -{ - uint32_t reg; - unsigned div; - - nc /= 1000; - div = (imx_get_mpllclk() / 1000) * 18; - div = DIV_ROUND_CLOSEST(div, nc); - if (div > 0x3f) - div = 0x3f; - /* mask the current settings */ - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC) & ~(SET_IOFRAC(0x3f)); - writel(reg | SET_IOFRAC(div), IMX_CCM_BASE + HW_CLKCTRL_FRAC); - /* enable the IO clock at its new frequency */ - writel(CLKCTRL_FRAC_CLKGATEIO, IMX_CCM_BASE + HW_CLKCTRL_FRAC + 8); - - return imx_get_ioclk(); -} - -/* this is CPU core clock */ -unsigned imx_get_armclk(void) -{ - uint32_t reg; - unsigned rate; - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & CLKCTRL_CLKSEQ_BYPASS_CPU) - return imx_get_xtalclk() / GET_CPU_XTAL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_CPU)); - - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC); - if (reg & CLKCTRL_FRAC_CLKGATECPU) - return 0U; /* should not possible, shouldn't it? */ - - rate = imx_get_mpllclk() / 1000; - rate *= 18U; - rate /= GET_CPUFRAC(reg); - - return (rate / GET_CPU_PLL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_CPU))) - * 1000; -} - -/* this is the AHB and APBH bus clock */ -unsigned imx_get_hclk(void) -{ - unsigned rate = imx_get_armclk() / 1000; - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x20) { - rate *= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f; - rate >>= 5U; /* / 32 */ - } else - rate /= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f; - return rate * 1000; -} - -/* - * Source of UART, debug UART, audio, PWM, dri, timer, digctl - */ -unsigned imx_get_xclk(void) -{ - unsigned rate = imx_get_xtalclk(); /* runs from the 24 MHz crystal reference */ - - return rate / (readl(IMX_CCM_BASE + HW_CLKCTRL_XBUS) & 0x3ff); -} - -/* 'index' gets ignored on i.MX23 */ -unsigned imx_get_sspclk(unsigned index) -{ - unsigned rate; - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_SSP) & CLKCTRL_SSP_CLKGATE) - return 0U; /* clock is off */ - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & CLKCTRL_CLKSEQ_BYPASS_SSP) - rate = imx_get_xtalclk(); - else - rate = imx_get_ioclk(); - - return rate / GET_SSP_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_SSP)); -} - -/** - * @param index Unit index (ignored on i.MX23) - * @param nc New frequency in [Hz] - * @param high != 0 if ioclk should be the source - * @return The new possible frequency in [kHz] - */ -unsigned imx_set_sspclk(unsigned index, unsigned nc, int high) -{ - uint32_t reg; - unsigned ssp_div; - - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_SSP) & ~CLKCTRL_SSP_CLKGATE; - /* Datasheet says: Do not change the DIV setting if the clock is off */ - writel(reg, IMX_CCM_BASE + HW_CLKCTRL_SSP); - /* Wait while clock is gated */ - while (readl(IMX_CCM_BASE + HW_CLKCTRL_SSP) & CLKCTRL_SSP_CLKGATE) - ; - - if (high) - ssp_div = imx_get_ioclk(); - else - ssp_div = imx_get_xtalclk(); - - if (nc > ssp_div) { - printf("Cannot setup SSP unit clock to %u Hz, base clock is only %u Hz\n", nc, ssp_div); - ssp_div = 1U; - } else { - ssp_div = DIV_ROUND_UP(ssp_div, nc); - if (ssp_div > CLKCTRL_SSP_DIV_MASK) - ssp_div = CLKCTRL_SSP_DIV_MASK; - } - - /* Set new divider value */ - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_SSP) & ~CLKCTRL_SSP_DIV_MASK; - writel(reg | SET_SSP_DIV(ssp_div), IMX_CCM_BASE + HW_CLKCTRL_SSP); - - /* Wait until new divider value is set */ - while (readl(IMX_CCM_BASE + HW_CLKCTRL_SSP) & CLKCTRL_SSP_BUSY) - ; - - if (high) - /* switch to ioclock */ - writel(CLKCTRL_CLKSEQ_BYPASS_SSP, IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ + 8); - else - /* switch to 24 MHz crystal */ - writel(CLKCTRL_CLKSEQ_BYPASS_SSP, IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ + 4); - - return imx_get_sspclk(index); -} - -void imx_dump_clocks(void) -{ - printf("mpll: %10u kHz\n", imx_get_mpllclk() / 1000); - printf("arm: %10u kHz\n", imx_get_armclk() / 1000); - printf("ioclk: %10u kHz\n", imx_get_ioclk() / 1000); - printf("emiclk: %10u kHz\n", imx_get_emiclk() / 1000); - printf("hclk: %10u kHz\n", imx_get_hclk() / 1000); - printf("xclk: %10u kHz\n", imx_get_xclk() / 1000); - printf("ssp: %10u kHz\n", imx_get_sspclk(0) / 1000); -} diff --git a/arch/arm/mach-stm/speed-imx28.c b/arch/arm/mach-stm/speed-imx28.c deleted file mode 100644 index 63c6b07..0000000 --- a/arch/arm/mach-stm/speed-imx28.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * (C) Copyright 2010 Juergen Beisert - Pengutronix - * - * This code is based partially on code that has: - * - * (c) 2008 Embedded Alley Solutions, Inc. - * (C) Copyright 2009-2010 Freescale Semiconductor, 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. - */ -#include -#include -#include -#include -#include -#include - -#define HW_CLKCTRL_PLL0CTRL0 0x000 -#define HW_CLKCTRL_PLL0CTRL1 0x010 -#define HW_CLKCTRL_PLL1CTRL0 0x020 -#define HW_CLKCTRL_PLL1CTRL1 0x030 -#define HW_CLKCTRL_PLL2CTRL0 0x040 -# define CLKCTRL_PLL2CTRL0_CLKGATE (1 << 31) -# define CLKCTRL_PLL2CTRL0_POWER (1 << 23) -#define HW_CLKCTRL_CPU 0x50 -# define GET_CPU_XTAL_DIV(x) (((x) >> 16) & 0x3ff) -# define GET_CPU_PLL_DIV(x) ((x) & 0x3f) -#define HW_CLKCTRL_HBUS 0x60 -#define HW_CLKCTRL_XBUS 0x70 -#define HW_CLKCTRL_XTAL 0x080 -#define HW_CLKCTRL_SSP0 0x090 -#define HW_CLKCTRL_SSP1 0x0a0 -#define HW_CLKCTRL_SSP2 0x0b0 -#define HW_CLKCTRL_SSP3 0x0c0 -/* note: no set/clear register! */ -# define CLKCTRL_SSP_CLKGATE (1 << 31) -# define CLKCTRL_SSP_BUSY (1 << 29) -# define CLKCTRL_SSP_DIV_FRAC_EN (1 << 9) -# define CLKCTRL_SSP_DIV_MASK 0x1ff -# define GET_SSP_DIV(x) ((x) & CLKCTRL_SSP_DIV_MASK) -# define SET_SSP_DIV(x) ((x) & CLKCTRL_SSP_DIV_MASK) -#define HW_CLKCTRL_GPMI 0x0d0 -/* note: no set/clear register! */ -#define HW_CLKCTRL_SPDIF 0x0e0 -/* note: no set/clear register! */ -#define HW_CLKCTRL_EMI 0xf0 -/* note: no set/clear register! */ -# define CLKCTRL_EMI_CLKGATE (1 << 31) -# define GET_EMI_XTAL_DIV(x) (((x) >> 8) & 0xf) -# define GET_EMI_PLL_DIV(x) ((x) & 0x3f) -#define HW_CLKCTRL_SAIF0 0x100 -#define HW_CLKCTRL_SAIF1 0x110 -#define HW_CLKCTRL_DIS_LCDIF 0x120 -# define CLKCTRL_DIS_LCDIF_GATE (1 << 31) -# define CLKCTRL_DIS_LCDIF_BUSY (1 << 29) -# define SET_DIS_LCDIF_DIV(x) ((x) & 0x1fff) -# define GET_DIS_LCDIF_DIV(x) ((x) & 0x1fff) -#define HW_CLKCTRL_ETM 0x130 -#define HW_CLKCTRL_ENET 0x140 -# define SET_CLKCTRL_ENET_DIV(x) (((x) & 0x3f) << 21) -# define SET_CLKCTRL_ENET_SEL(x) (((x) & 0x3) << 19) -# define CLKCTRL_ENET_CLK_OUT_EN (1 << 18) -#define HW_CLKCTRL_HSADC 0x150 -#define HW_CLKCTRL_FLEXCAN 0x160 -#define HW_CLKCTRL_FRAC0 0x1b0 -# define CLKCTRL_FRAC_CLKGATEIO0 (1 << 31) -# define GET_IO0FRAC(x) (((x) >> 24) & 0x3f) -# define SET_IO0FRAC(x) (((x) & 0x3f) << 24) -# define CLKCTRL_FRAC_CLKGATEIO1 (1 << 23) -# define GET_IO1FRAC(x) (((x) >> 16) & 0x3f) -# define SET_IO1FRAC(x) (((x) & 0x3f) << 16) -# define CLKCTRL_FRAC_CLKGATEEMI (1 << 15) -# define GET_EMIFRAC(x) (((x) >> 8) & 0x3f) -# define CLKCTRL_FRAC_CLKGATECPU (1 << 7) -# define GET_CPUFRAC(x) ((x) & 0x3f) -#define HW_CLKCTRL_FRAC1 0x1c0 -# define CLKCTRL_FRAC_CLKGATEGPMI (1 << 23) -# define GET_GPMIFRAC(x) (((x) >> 16) & 0x3f) -# define CLKCTRL_FRAC_CLKGATEHSADC (1 << 15) -# define GET_HSADCFRAC(x) (((x) >> 8) & 0x3f) -# define CLKCTRL_FRAC_CLKGATEPIX (1 << 7) -# define GET_PIXFRAC(x) ((x) & 0x3f) -# define SET_PIXFRAC(x) ((x) & 0x3f) -#define HW_CLKCTRL_CLKSEQ 0x1d0 -# define CLKCTRL_CLKSEQ_BYPASS_CPU (1 << 18) -# define CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF (1 << 14) -# define CLKCTRL_CLKSEQ_BYPASS_ETM (1 << 8) -# define CLKCTRL_CLKSEQ_BYPASS_EMI (1 << 7) -# define CLKCTRL_CLKSEQ_BYPASS_SSP3 (1 << 6) -# define CLKCTRL_CLKSEQ_BYPASS_SSP2 (1 << 5) -# define CLKCTRL_CLKSEQ_BYPASS_SSP1 (1 << 4) -# define CLKCTRL_CLKSEQ_BYPASS_SSP0 (1 << 3) -# define CLKCTRL_CLKSEQ_BYPASS_GPMI (1 << 2) -# define CLKCTRL_CLKSEQ_BYPASS_SAIF1 (1 << 1) -# define CLKCTRL_CLKSEQ_BYPASS_SAIF0 (1 << 0) -#define HW_CLKCTRL_RESET 0x1e0 -#define HW_CLKCTRL_STATUS 0x1f0 -#define HW_CLKCTRL_VERSION 0x200 - -unsigned imx_get_mpllclk(void) -{ - /* the main PLL runs at 480 MHz */ - return 480000000; -} - -unsigned imx_get_xtalclk(void) -{ - /* the external reference runs at 24 MHz */ - return 24000000; -} - -unsigned imx_get_fecclk(void) -{ - /* this PLL always runs at 50 MHz */ - return 50000000; -} - - -/* used for the SDRAM controller */ -unsigned imx_get_emiclk(void) -{ - uint32_t reg; - unsigned rate; - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_EMI) & CLKCTRL_EMI_CLKGATE) - return 0; /* clock is off */ - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & CLKCTRL_CLKSEQ_BYPASS_EMI) - return imx_get_xtalclk() / - GET_EMI_XTAL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_EMI)); - - rate = imx_get_mpllclk() / 1000; - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC0); - if (!(reg & CLKCTRL_FRAC_CLKGATEEMI)) { - rate *= 18; - rate /= GET_EMIFRAC(reg); - } - - return (rate / GET_EMI_PLL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_EMI))) - * 1000; -} - -/* - * Source of ssp, gpmi, ir - * @param index 0 or 1 for ioclk0 or ioclock1 - */ -unsigned imx_get_ioclk(unsigned index) -{ - uint32_t reg; - unsigned rate = imx_get_mpllclk() / 1000; - - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC0); - switch (index) { - case 0: - if (reg & CLKCTRL_FRAC_CLKGATEIO0) - return 0; /* clock is off */ - - rate *= 18; - rate /= GET_IO0FRAC(reg); - break; - case 1: - if (reg & CLKCTRL_FRAC_CLKGATEIO1) - return 0; /* clock is off */ - - rate *= 18; - rate /= GET_IO1FRAC(reg); - break; - } - - return rate * 1000; -} - -/** - * Setup a new frequency to the IOCLK domain. - * @param index 0 or 1 for ioclk0 or ioclock1 - * @param nc New frequency in [Hz] - * - * The FRAC divider for the IOCLK must be between 18 (* 18/18) and 35 (* 18/35) - * - * ioclock0 is the shared clock source of SSP0/SSP1, ioclock1 the shared clock - * source of SSP2/SSP3 - */ -unsigned imx_set_ioclk(unsigned index, unsigned nc) -{ - uint32_t reg; - unsigned div; - - nc /= 1000; - div = (imx_get_mpllclk() / 1000) * 18; - div = DIV_ROUND_CLOSEST(div, nc); - if (div > 0x3f) - div = 0x3f; - - switch (index) { - case 0: - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC0) & - ~(SET_IO0FRAC(0x3f)); - /* mask the current settings */ - writel(reg | SET_IO0FRAC(div), IMX_CCM_BASE + HW_CLKCTRL_FRAC0); - /* enable the IO clock at its new frequency */ - writel(CLKCTRL_FRAC_CLKGATEIO0, - IMX_CCM_BASE + HW_CLKCTRL_FRAC0 + BIT_CLR); - break; - case 1: - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC0) & - ~(SET_IO1FRAC(0x3f)); - /* mask the current settings */ - writel(reg | SET_IO1FRAC(div), IMX_CCM_BASE + HW_CLKCTRL_FRAC0); - /* enable the IO clock at its new frequency */ - writel(CLKCTRL_FRAC_CLKGATEIO1, - IMX_CCM_BASE + HW_CLKCTRL_FRAC0 + BIT_CLR); - break; - } - - return imx_get_ioclk(index); -} - -/* this is CPU core clock */ -unsigned imx_get_armclk(void) -{ - uint32_t reg; - unsigned rate; - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & CLKCTRL_CLKSEQ_BYPASS_CPU) - return imx_get_xtalclk() / - GET_CPU_XTAL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_CPU)); - - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_FRAC0); - if (reg & CLKCTRL_FRAC_CLKGATECPU) - return 0; /* should not possible, shouldn't it? */ - - rate = (imx_get_mpllclk() / 1000) * 18; - rate /= GET_CPUFRAC(reg); - - return (rate / GET_CPU_PLL_DIV(readl(IMX_CCM_BASE + HW_CLKCTRL_CPU))) - * 1000; -} - -/* this is the AHB and APBH bus clock */ -unsigned imx_get_hclk(void) -{ - unsigned rate = imx_get_armclk() / 1000; - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x20) { - rate *= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f; - rate /= 32; - } else - rate /= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f; - return rate * 1000; -} - -/* - * Source of UART, debug UART, audio, PWM, dri, timer, digctl - */ -unsigned imx_get_xclk(void) -{ - /* runs from the 24 MHz crystal reference */ - unsigned rate = imx_get_xtalclk(); - - return rate / (readl(IMX_CCM_BASE + HW_CLKCTRL_XBUS) & 0x3ff); -} - -/** - * @param index The SSP unit (0...3) - */ -unsigned imx_get_sspclk(unsigned index) -{ - unsigned rate, offset, shift, ioclk_index; - - if (index > 3) { - pr_debug("Unknown SSP unit: %u\n", index); - return 0; - } - - ioclk_index = index >> 1; - - offset = HW_CLKCTRL_SSP0 + (0x10 * index); - shift = CLKCTRL_CLKSEQ_BYPASS_SSP0 << index; - - if (readl(IMX_CCM_BASE + offset) & CLKCTRL_SSP_CLKGATE) - return 0; /* clock is off */ - - if (readl(IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ) & shift) - rate = imx_get_xtalclk(); - else - rate = imx_get_ioclk(ioclk_index); - - return rate / GET_SSP_DIV(readl(IMX_CCM_BASE + offset)); -} - -/** - * @param index The SSP unit (0...3) - * @param nc New frequency in [Hz] - * @param high != 0 if ioclk should be the source - * @return The new possible frequency - */ -unsigned imx_set_sspclk(unsigned index, unsigned nc, int high) -{ - uint32_t reg; - unsigned ssp_div, offset, shift, ioclk_index; - - if (index > 3) { - pr_debug("Unknown SSP unit: %u\n", index); - return 0; - } - - ioclk_index = index >> 1; - - offset = HW_CLKCTRL_SSP0 + (0x10 * index); - shift = CLKCTRL_CLKSEQ_BYPASS_SSP0 << index; - - reg = readl(IMX_CCM_BASE + offset) & ~CLKCTRL_SSP_CLKGATE; - /* Datasheet says: Do not change the DIV setting if the clock is off */ - writel(reg, IMX_CCM_BASE + offset); - /* Wait while clock is gated */ - while (readl(IMX_CCM_BASE + offset) & CLKCTRL_SSP_CLKGATE) - ; - - if (high) - ssp_div = imx_get_ioclk(ioclk_index); - else - ssp_div = imx_get_xtalclk(); - - if (nc > ssp_div) { - printf("Cannot setup SSP unit clock to %u kHz, base clock is " - "only %u kHz\n", nc, ssp_div); - ssp_div = 1; - } else { - ssp_div = DIV_ROUND_UP(ssp_div, nc); - if (ssp_div > CLKCTRL_SSP_DIV_MASK) - ssp_div = CLKCTRL_SSP_DIV_MASK; - } - - /* Set new divider value */ - reg = readl(IMX_CCM_BASE + offset) & ~CLKCTRL_SSP_DIV_MASK; - writel(reg | SET_SSP_DIV(ssp_div), IMX_CCM_BASE + offset); - - /* Wait until new divider value is set */ - while (readl(IMX_CCM_BASE + offset) & CLKCTRL_SSP_BUSY) - ; - - if (high) - /* switch to ioclock */ - writel(shift, IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ + BIT_CLR); - else - /* switch to 24 MHz crystal */ - writel(shift, IMX_CCM_BASE + HW_CLKCTRL_CLKSEQ + BIT_SET); - - return imx_get_sspclk(index); -} - -void imx_enable_enetclk(void) -{ - uint32_t reg; - - /* wake up main enet PLL */ - reg = readl(IMX_CCM_BASE + HW_CLKCTRL_PLL2CTRL0); - if (!(reg & CLKCTRL_PLL2CTRL0_POWER)) { - reg |= CLKCTRL_PLL2CTRL0_POWER; - writel(reg, IMX_CCM_BASE + HW_CLKCTRL_PLL2CTRL0); - udelay(50); /* wait until this PLL locks */ - } - reg &= ~CLKCTRL_PLL2CTRL0_CLKGATE; - writel(reg, IMX_CCM_BASE + HW_CLKCTRL_PLL2CTRL0); - - writel(SET_CLKCTRL_ENET_DIV(1) | SET_CLKCTRL_ENET_SEL(0) | - CLKCTRL_ENET_CLK_OUT_EN, /* FIXME may be platform specific */ - IMX_CCM_BASE + HW_CLKCTRL_ENET); -} - -void imx_dump_clocks(void) -{ - printf("mpll: %10u kHz\n", imx_get_mpllclk() / 1000); - printf("arm: %10u kHz\n", imx_get_armclk() / 1000); - printf("ioclk0: %10u kHz\n", imx_get_ioclk(0) / 1000); - printf("ioclk1: %10u kHz\n", imx_get_ioclk(1) / 1000); - printf("emiclk: %10u kHz\n", imx_get_emiclk() / 1000); - printf("hclk: %10u kHz\n", imx_get_hclk() / 1000); - printf("xclk: %10u kHz\n", imx_get_xclk() / 1000); - printf("ssp0: %10u kHz\n", imx_get_sspclk(0) / 1000); - printf("ssp1: %10u kHz\n", imx_get_sspclk(1) / 1000); - printf("ssp2: %10u kHz\n", imx_get_sspclk(2) / 1000); - printf("ssp3: %10u kHz\n", imx_get_sspclk(3) / 1000); -} diff --git a/arch/blackfin/boards/ipe337/barebox.lds.S b/arch/blackfin/boards/ipe337/barebox.lds.S index 4299b82..571eeb1 100644 --- a/arch/blackfin/boards/ipe337/barebox.lds.S +++ b/arch/blackfin/boards/ipe337/barebox.lds.S @@ -82,6 +82,7 @@ . = ALIGN(4); __bss_start = .; .bss : { *(.bss) } + __bss_stop = .; _end = .; } diff --git a/arch/blackfin/include/asm/bitsperlong.h b/arch/blackfin/include/asm/bitsperlong.h new file mode 100644 index 0000000..6dc0bb0 --- /dev/null +++ b/arch/blackfin/include/asm/bitsperlong.h @@ -0,0 +1 @@ +#include diff --git a/arch/blackfin/include/asm/sections.h b/arch/blackfin/include/asm/sections.h new file mode 100644 index 0000000..2b8c516 --- /dev/null +++ b/arch/blackfin/include/asm/sections.h @@ -0,0 +1 @@ +#include diff --git a/arch/blackfin/include/asm/swab.h b/arch/blackfin/include/asm/swab.h new file mode 100644 index 0000000..89de650 --- /dev/null +++ b/arch/blackfin/include/asm/swab.h @@ -0,0 +1,50 @@ +/* + * Copyright 2009 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#ifndef _BLACKFIN_SWAB_H +#define _BLACKFIN_SWAB_H + +#include +#include + +#ifdef __GNUC__ + +static __inline__ __attribute_const__ __u32 __arch_swahb32(__u32 xx) +{ + __u32 tmp; + __asm__("%1 = %0 >> 8 (V);\n\t" + "%0 = %0 << 8 (V);\n\t" + "%0 = %0 | %1;\n\t" + : "+d"(xx), "=&d"(tmp)); + return xx; +} +#define __arch_swahb32 __arch_swahb32 + +static __inline__ __attribute_const__ __u32 __arch_swahw32(__u32 xx) +{ + __u32 rv; + __asm__("%0 = PACK(%1.L, %1.H);\n\t": "=d"(rv): "d"(xx)); + return rv; +} +#define __arch_swahw32 __arch_swahw32 + +static __inline__ __attribute_const__ __u32 __arch_swab32(__u32 xx) +{ + return __arch_swahb32(__arch_swahw32(xx)); +} +#define __arch_swab32 __arch_swab32 + +static __inline__ __attribute_const__ __u16 __arch_swab16(__u16 xx) +{ + __u32 xw = xx; + __asm__("%0 <<= 8;\n %0.L = %0.L + %0.H (NS);\n": "+d"(xw)); + return (__u16)xw; +} +#define __arch_swab16 __arch_swab16 + +#endif /* __GNUC__ */ + +#endif /* _BLACKFIN_SWAB_H */ diff --git a/arch/ppc/boards/pcm030/barebox.lds.S b/arch/ppc/boards/pcm030/barebox.lds.S index ab99335..21bf4a7 100644 --- a/arch/ppc/boards/pcm030/barebox.lds.S +++ b/arch/ppc/boards/pcm030/barebox.lds.S @@ -55,6 +55,8 @@ .plt : { *(.plt) } .text : { + _text = .; + _stext = .; arch/ppc/mach-mpc5xxx/start.o (.text) *(.text*) *(.got1*) @@ -134,6 +136,7 @@ *(.bss*) *(COMMON) } + __bss_stop = .; _end = . ; PROVIDE (end = .); } diff --git a/arch/ppc/include/asm/byteorder.h b/arch/ppc/include/asm/byteorder.h index d3e719b..aa6cc4f 100644 --- a/arch/ppc/include/asm/byteorder.h +++ b/arch/ppc/include/asm/byteorder.h @@ -1,79 +1,12 @@ -#ifndef _PPC_BYTEORDER_H -#define _PPC_BYTEORDER_H +#ifndef _ASM_POWERPC_BYTEORDER_H +#define _ASM_POWERPC_BYTEORDER_H -#include - -#ifdef __GNUC__ - -extern __inline__ unsigned ld_le16(const volatile unsigned short *addr) -{ - unsigned val; - - __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr)); - return val; -} - -extern __inline__ void st_le16(volatile unsigned short *addr, const unsigned val) -{ - __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); -} - -extern __inline__ unsigned ld_le32(const volatile unsigned *addr) -{ - unsigned val; - - __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr)); - return val; -} - -extern __inline__ void st_le32(volatile unsigned *addr, const unsigned val) -{ - __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); -} - -/* alas, egcs sounds like it has a bug in this code that doesn't use the - inline asm correctly, and can cause file corruption. Until I hear that - it's fixed, I can live without the extra speed. I hope. */ -#if !(__GNUC__ >= 2 && __GNUC_MINOR__ >= 90) -static __inline__ __attribute__((const)) __u16 ___arch__swab16(__u16 value) -{ - __u16 result; - - __asm__("rlwimi %0,%1,8,16,23" - : "=r" (result) - : "r" (value), "0" (value >> 8)); - return result; -} - -static __inline__ __attribute__((const)) __u32 ___arch__swab32(__u32 value) -{ - __u32 result; - - __asm__("rlwimi %0,%1,24,16,23\n\t" - "rlwimi %0,%1,8,8,15\n\t" - "rlwimi %0,%1,24,0,7" - : "=r" (result) - : "r" (value), "0" (value >> 24)); - return result; -} -#define __arch__swab32(x) ___arch__swab32(x) -#define __arch__swab16(x) ___arch__swab16(x) - -#endif - -/* The same, but returns converted value from the location pointer by addr. */ -#define __arch__swab16p(addr) ld_le16(addr) -#define __arch__swab32p(addr) ld_le32(addr) - -/* The same, but do the conversion in situ, ie. put the value back to addr. */ -#define __arch__swab16s(addr) st_le16(addr,*addr) -#define __arch__swab32s(addr) st_le32(addr,*addr) - -#endif /* __GNUC__ */ - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -#define __BYTEORDER_HAS_U64__ -#endif +/* + * 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 -#endif /* _PPC_BYTEORDER_H */ +#endif /* _ASM_POWERPC_BYTEORDER_H */ diff --git a/arch/ppc/include/asm/sections.h b/arch/ppc/include/asm/sections.h new file mode 100644 index 0000000..2b8c516 --- /dev/null +++ b/arch/ppc/include/asm/sections.h @@ -0,0 +1 @@ +#include diff --git a/arch/ppc/include/asm/swab.h b/arch/ppc/include/asm/swab.h new file mode 100644 index 0000000..c581e3e --- /dev/null +++ b/arch/ppc/include/asm/swab.h @@ -0,0 +1,90 @@ +#ifndef _ASM_POWERPC_SWAB_H +#define _ASM_POWERPC_SWAB_H + +/* + * 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 +#include + +#ifdef __GNUC__ + +#ifndef __powerpc64__ +#define __SWAB_64_THRU_32__ +#endif /* __powerpc64__ */ + +#ifdef __KERNEL__ + +static __inline__ __u16 ld_le16(const volatile __u16 *addr) +{ + __u16 val; + + __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr)); + return val; +} +#define __arch_swab16p ld_le16 + +static __inline__ void st_le16(volatile __u16 *addr, const __u16 val) +{ + __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); +} + +static inline void __arch_swab16s(__u16 *addr) +{ + st_le16(addr, *addr); +} +#define __arch_swab16s __arch_swab16s + +static __inline__ __u32 ld_le32(const volatile __u32 *addr) +{ + __u32 val; + + __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr)); + return val; +} +#define __arch_swab32p ld_le32 + +static __inline__ void st_le32(volatile __u32 *addr, const __u32 val) +{ + __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); +} + +static inline void __arch_swab32s(__u32 *addr) +{ + st_le32(addr, *addr); +} +#define __arch_swab32s __arch_swab32s + +static inline __attribute_const__ __u16 __arch_swab16(__u16 value) +{ + __u16 result; + + __asm__("rlwimi %0,%1,8,16,23" + : "=r" (result) + : "r" (value), "0" (value >> 8)); + return result; +} +#define __arch_swab16 __arch_swab16 + +static inline __attribute_const__ __u32 __arch_swab32(__u32 value) +{ + __u32 result; + + __asm__("rlwimi %0,%1,24,16,23\n\t" + "rlwimi %0,%1,8,8,15\n\t" + "rlwimi %0,%1,24,0,7" + : "=r" (result) + : "r" (value), "0" (value >> 24)); + return result; +} +#define __arch_swab32 __arch_swab32 + +#endif /* __KERNEL__ */ + +#endif /* __GNUC__ */ + +#endif /* _ASM_POWERPC_SWAB_H */ diff --git a/arch/sandbox/include/asm/sections.h b/arch/sandbox/include/asm/sections.h new file mode 100644 index 0000000..2b8c516 --- /dev/null +++ b/arch/sandbox/include/asm/sections.h @@ -0,0 +1 @@ +#include diff --git a/arch/sandbox/include/asm/swab.h b/arch/sandbox/include/asm/swab.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/arch/sandbox/include/asm/swab.h diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h index b9053d8..7c2386d 100644 --- a/arch/sandbox/mach-sandbox/include/mach/linux.h +++ b/arch/sandbox/mach-sandbox/include/mach/linux.h @@ -8,8 +8,6 @@ int linux_read_nonblock(int fd, void *buf, size_t count); ssize_t linux_write(int fd, const void *buf, size_t count); off_t linux_lseek(int fildes, off_t offset); -int linux_getc (void); -void linux_putc (const char c); int linux_tstc(int fd); int barebox_register_console(char *name_template, int stdinfd, int stdoutfd); diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 287be0d..dcaf0c8 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -73,17 +73,6 @@ tcsetattr(0, TCSANOW, &term_orig); } -void linux_putc(const char c) -{ - fputc(c, stdout); - - /* If \n, also do \r */ - if (c == '\n') - linux_putc ('\r'); - - fflush(stdout); -} - int linux_tstc(int fd) { struct timeval tv = { @@ -117,15 +106,6 @@ return 0; } -int linux_getc(void) -{ - char ret; - - read(0, &ret, 1); - - return ret; -} - uint64_t linux_get_time(void) { struct timespec ts; diff --git a/arch/x86/boot/main_entry.c b/arch/x86/boot/main_entry.c index 5f199e9..d1d8f34 100644 --- a/arch/x86/boot/main_entry.c +++ b/arch/x86/boot/main_entry.c @@ -24,10 +24,7 @@ */ #include - -/* These symbols are generated by the linker */ -extern char __bss_start; -extern char __bss_end; +#include extern void start_barebox(void); @@ -39,6 +36,6 @@ void uboot_entry(void) { /* clear the BSS first */ - memset(&__bss_start, 0x00, &__bss_end - &__bss_start); + memset(__bss_start, 0x00, __bss_stop - __bss_start); start_barebox(); } diff --git a/arch/x86/boot/pmjump.S b/arch/x86/boot/pmjump.S index 0e4cd38..d2fb8f0 100644 --- a/arch/x86/boot/pmjump.S +++ b/arch/x86/boot/pmjump.S @@ -51,7 +51,7 @@ .code32 .extern uboot_entry - .extern __bss_end + .extern __bss_stop .type in_pm32, @function in_pm32: @@ -65,7 +65,7 @@ * Our flat mode code uses its own stack area behind the bss. With this we * are still able to return to real mode temporarely */ - movl $__bss_end + 32768, %esp + movl $__bss_stop + 32768, %esp # Set up TR to make Intel VT happy ltr %di diff --git a/arch/x86/include/asm/sections.h b/arch/x86/include/asm/sections.h new file mode 100644 index 0000000..2b8c516 --- /dev/null +++ b/arch/x86/include/asm/sections.h @@ -0,0 +1 @@ +#include diff --git a/arch/x86/include/asm/swab.h b/arch/x86/include/asm/swab.h new file mode 100644 index 0000000..557cd9f --- /dev/null +++ b/arch/x86/include/asm/swab.h @@ -0,0 +1,61 @@ +#ifndef _ASM_X86_SWAB_H +#define _ASM_X86_SWAB_H + +#include +#include + +static inline __attribute_const__ __u32 __arch_swab32(__u32 val) +{ +#ifdef __i386__ +# ifdef CONFIG_X86_BSWAP + asm("bswap %0" : "=r" (val) : "0" (val)); +# else + asm("xchgb %b0,%h0\n\t" /* swap lower bytes */ + "rorl $16,%0\n\t" /* swap words */ + "xchgb %b0,%h0" /* swap higher bytes */ + : "=q" (val) + : "0" (val)); +# endif + +#else /* __i386__ */ + asm("bswapl %0" + : "=r" (val) + : "0" (val)); +#endif + return val; +} +#define __arch_swab32 __arch_swab32 + +static inline __attribute_const__ __u64 __arch_swab64(__u64 val) +{ +#ifdef __i386__ + union { + struct { + __u32 a; + __u32 b; + } s; + __u64 u; + } v; + v.u = val; +# ifdef CONFIG_X86_BSWAP + asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" + : "=r" (v.s.a), "=r" (v.s.b) + : "0" (v.s.a), "1" (v.s.b)); +# else + v.s.a = __arch_swab32(v.s.a); + v.s.b = __arch_swab32(v.s.b); + asm("xchgl %0,%1" + : "=r" (v.s.a), "=r" (v.s.b) + : "0" (v.s.a), "1" (v.s.b)); +# endif + return v.u; +#else /* __i386__ */ + asm("bswapq %0" + : "=r" (val) + : "0" (val)); + return val; +#endif +} +#define __arch_swab64 __arch_swab64 + +#endif /* _ASM_X86_SWAB_H */ diff --git a/arch/x86/lib/barebox.lds.S b/arch/x86/lib/barebox.lds.S index 2917d2f..e0919a6 100644 --- a/arch/x86/lib/barebox.lds.S +++ b/arch/x86/lib/barebox.lds.S @@ -188,7 +188,7 @@ __bss_start = .; *(.bss*); *( COMMON ) - __bss_end = .; + __bss_stop = .; _end = .; } > barebox } diff --git a/commands/bmp.c b/commands/bmp.c index 5bac031..644a977 100644 --- a/commands/bmp.c +++ b/commands/bmp.c @@ -25,6 +25,7 @@ *(u16 *)adr = px; break; case 32: + *(u32 *)adr = px; break; } } diff --git a/commands/edit.c b/commands/edit.c index ca40d59..3519b09 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -184,10 +184,8 @@ { int size = 32; - if (!line) { + if (!line) line = xzalloc(sizeof(struct line)); - line->data = malloc(32); - } while (size < len) size <<= 1; diff --git a/common/env.c b/common/env.c index f81bd46..b72b5d1 100644 --- a/common/env.c +++ b/common/env.c @@ -81,7 +81,7 @@ return 0; } -late_initcall(env_push_context); +device_initcall(env_push_context); /** * FIXME diff --git a/common/startup.c b/common/startup.c index 0d7ccb9..aa76cb7 100644 --- a/common/startup.c +++ b/common/startup.c @@ -40,6 +40,7 @@ #include #include #include +#include extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[], __barebox_initcalls_end[]; @@ -50,8 +51,8 @@ ulong mend = mem_malloc_end(); ulong msize = mend - mstart + 1; - debug("barebox code : 0x%08lX -> 0x%08lX BSS: -> 0x%08lX\n", - _barebox_start, _bss_start, _bss_end); + debug("barebox code: 0x%p -> 0x%p\n", _stext, _etext); + debug("bss segment: 0x%p -> 0x%p\n", __bss_start, __bss_stop); printf("Malloc space: 0x%08lx -> 0x%08lx (size %s)\n", mstart, mend, size_human_readable(msize)); #ifdef CONFIG_ARM diff --git a/defaultenv/bin/_update_help b/defaultenv/bin/_update_help index 22d940e..5e3ca45 100644 --- a/defaultenv/bin/_update_help +++ b/defaultenv/bin/_update_help @@ -1,6 +1,6 @@ #!/bin/sh -echo "usage: $0 -t -d [-m tftp|xmodem] [-f imagename] -c" +echo "usage: update -t -d [-m tftp|xmodem] [-f imagename] -c" echo "update tools." echo "" echo "options" @@ -10,3 +10,4 @@ echo "type update -t kernel -d [-m tftp|xmodem] [-f imagename] to update kernel into flash" echo "type update -t rootfs -d [-m tftp|xmodem] [-f imagename] to update rootfs into flash" echo "type update -t barebox -d [-m tftp|xmodem] [-f imagename] to update barebox into flash" +echo "type update -t bareboxenv -d [-m tftp|xmodem] [-f imagename] to update bareboxenv into flash" diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot index 4c2975d..788a781 100644 --- a/defaultenv/bin/boot +++ b/defaultenv/bin/boot @@ -34,7 +34,10 @@ fi if [ x$rootfs_type = xubifs ]; then - bootargs="$bootargs root=ubi0:root ubi.mtd=$rootfs_mtdblock" + if [ -z $ubiroot ]; then + ubiroot="root" + fi + bootargs="$bootargs root=ubi0:$ubiroot ubi.mtd=$rootfs_mtdblock" else bootargs="$bootargs root=/dev/mtdblock$rootfs_mtdblock" fi diff --git a/defaultenv/bin/init b/defaultenv/bin/init index 96a5716..b66f7d9 100644 --- a/defaultenv/bin/init +++ b/defaultenv/bin/init @@ -4,15 +4,15 @@ export PATH . /env/config -if [ -e /dev/nor0 ]; then +if [ -e /dev/nor0 -a -n "$nor_parts" ]; then addpart /dev/nor0 $nor_parts fi -if [ -e /dev/disk0 ]; then +if [ -e /dev/disk0 -a -n "$disk_parts" ]; then addpart /dev/disk0 $disk_parts fi -if [ -e /dev/nand0 ]; then +if [ -e /dev/nand0 -a -n "$nand_parts" ]; then addpart /dev/nand0 $nand_parts # Uh, oh, hush first expands wildcards and then starts executing @@ -28,9 +28,6 @@ echo -n "Hit any key to stop autoboot: " timeout -a $autoboot_timeout if [ $? != 0 ]; then - echo - update -h - echo exit fi diff --git a/defaultenv/bin/update b/defaultenv/bin/update index 29c240b..43d3097 100644 --- a/defaultenv/bin/update +++ b/defaultenv/bin/update @@ -1,12 +1,12 @@ #!/bin/sh -. /env/config - type="" device_type="" check=n mode=tftp +. /env/config + while getopt "ht:d:f:m:c" Option do if [ ${Option} = t ]; then @@ -35,6 +35,11 @@ if [ x${image} = x ]; then image=barebox.bin fi +elif [ x${type} = xbareboxenv ]; then + image=$bareboxenvimage + if [ x${image} = x ]; then + image=bareboxenv.bin + fi else . /env/bin/_update_help exit 1 diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 266cb52..93e978e 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -151,7 +151,7 @@ break; if (!for_busy && !(temp & I2SR_IBB)) break; - if (is_timeout(start, MSECOND)) { + if (is_timeout(start, 500 * MSECOND)) { dev_err(adapter->dev, "<%s> timeout waiting for I2C bus %s\n", __func__,for_busy ? "busy" : "not busy"); @@ -170,7 +170,7 @@ start = get_time_ns(); while (1) { unsigned int reg = readb(base + IMX_I2C_I2SR); - if (reg & I2SR_ICF) + if (reg & I2SR_IIF) break; if (is_timeout(start, 100 * MSECOND)) { @@ -178,26 +178,7 @@ return -EIO; } } - - return 0; -} - -static int i2c_imx_wait_iif(struct i2c_adapter *adapter) -{ - unsigned long base = adapter->dev->map_base; - uint64_t start; - - start = get_time_ns(); - while (1) { - unsigned int reg = readb(base + IMX_I2C_I2SR); - if (reg & I2SR_IIF) - break; - - if (is_timeout(start, 100 * MSECOND)) { - dev_err(adapter->dev, "<%s> IIF timeout\n", __func__); - return -EIO; - } - } + writeb(0, base + IMX_I2C_I2SR); return 0; } @@ -277,9 +258,13 @@ udelay(i2c_imx->disable_delay); } + if (!i2c_imx->stopped) { + i2c_imx_bus_busy(adapter, 0); + i2c_imx->stopped = 1; + } + /* Disable I2C controller, and force our state to stopped */ writeb(0, base + IMX_I2C_I2CR); - i2c_imx->stopped = 1; } static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, @@ -379,10 +364,6 @@ if (result) return result; - result = i2c_imx_wait_iif(adapter); - if (result) - return result; - /* setup bus to read data */ temp = readb(base + IMX_I2C_I2CR); temp &= ~I2CR_MTX; diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig index ee04079..7d214ac 100644 --- a/drivers/mci/Kconfig +++ b/drivers/mci/Kconfig @@ -29,7 +29,7 @@ config MCI_STM378X bool "i.MX23/i.MX28" - depends on ARCH_STM + depends on ARCH_MXS help Enable this entry to add support to read and write SD cards on a i.MX23/i.MX28 based system. diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index c562700..0137152 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -1333,10 +1333,7 @@ static int mci_init(void) { - sector_buf = memalign(32, 512); - if (!sector_buf) - return -ENOMEM; - + sector_buf = xmemalign(32, 512); return register_driver(&mci_driver); } diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c index 4563ff3..d5e26a1 100644 --- a/drivers/net/at91_ether.c +++ b/drivers/net/at91_ether.c @@ -263,7 +263,7 @@ struct eth_device *edev; int i; - edev = malloc(sizeof(struct eth_device)); + edev = xmalloc(sizeof(struct eth_device)); dev->priv = edev; edev->open = at91rm9200_eth_open; diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c index b8264d7..de6d038 100644 --- a/drivers/net/cs8900.c +++ b/drivers/net/cs8900.c @@ -440,14 +440,14 @@ debug("cs8900_init()\n"); - priv = (struct cs8900_priv *)malloc(sizeof(*priv)); + priv = (struct cs8900_priv *)xmalloc(sizeof(*priv)); priv->regs = (u16 *)dev->map_base; if (cs8900_check_id(priv)) { free(priv); return -1; } - edev = (struct eth_device *)malloc(sizeof(struct eth_device)); + edev = (struct eth_device *)xmalloc(sizeof(struct eth_device)); dev->type_data = edev; edev->priv = priv; diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c index 51cdb40..ca72e93 100644 --- a/drivers/net/fec_imx.c +++ b/drivers/net/fec_imx.c @@ -33,7 +33,7 @@ #include #include #include -#ifndef CONFIG_ARCH_STM +#ifndef CONFIG_ARCH_MXS # include #endif #include @@ -269,7 +269,7 @@ static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac) { -#ifdef CONFIG_ARCH_STM +#ifdef CONFIG_ARCH_MXS return -1; #else return imx_iim_get_mac(mac); @@ -565,7 +565,7 @@ if (cpu_is_mx28()) imx28_fix_endianess_rd( - (void *)readl(&rbd->data_pointer), + phys_to_virt(readl(&rbd->data_pointer)), (readw(&rbd->data_length) + 3) >> 2); /* diff --git a/drivers/net/fec_mpc5200.c b/drivers/net/fec_mpc5200.c index 8b2cb4d..7528316 100644 --- a/drivers/net/fec_mpc5200.c +++ b/drivers/net/fec_mpc5200.c @@ -661,9 +661,9 @@ struct eth_device *edev; mpc5xxx_fec_priv *fec; - edev = (struct eth_device *)malloc(sizeof(struct eth_device)); + edev = (struct eth_device *)xmalloc(sizeof(struct eth_device)); dev->type_data = edev; - fec = (mpc5xxx_fec_priv *)malloc(sizeof(*fec)); + fec = (mpc5xxx_fec_priv *)xmalloc(sizeof(*fec)); edev->priv = fec; edev->open = mpc5xxx_fec_open, edev->init = mpc5xxx_fec_init, diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 522a9f1..a30a9c8 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -79,7 +79,7 @@ struct tap_priv *priv; int ret = 0; - priv = malloc(sizeof(struct tap_priv)); + priv = xmalloc(sizeof(struct tap_priv)); priv->name = "barebox"; priv->fd = tap_alloc(priv->name); @@ -88,7 +88,7 @@ goto out; } - edev = malloc(sizeof(struct eth_device)); + edev = xmalloc(sizeof(struct eth_device)); dev->type_data = edev; edev->priv = priv; diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c index fccb008..39c2bf1 100644 --- a/drivers/nor/cfi_flash.c +++ b/drivers/nor/cfi_flash.c @@ -305,7 +305,7 @@ #endif /* first only malloc space for the first sector */ - info->start = malloc(sizeof(ulong)); + info->start = xmalloc(sizeof(ulong)); info->start[0] = base; info->protect = 0; @@ -394,8 +394,8 @@ cur_offset += erase_region_size * erase_region_count; /* increase the space malloced for the sector start addresses */ - info->start = realloc(info->start, sizeof(ulong) * (erase_region_count + sect_cnt)); - info->protect = realloc(info->protect, sizeof(uchar) * (erase_region_count + sect_cnt)); + info->start = xrealloc(info->start, sizeof(ulong) * (erase_region_count + sect_cnt)); + info->protect = xrealloc(info->protect, sizeof(uchar) * (erase_region_count + sect_cnt)); for (j = 0; j < erase_region_count; j++) { info->start[sect_cnt] = sector; diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 04d9b98..ffd877a 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -19,7 +19,7 @@ bool "i.MX serial driver" config DRIVER_SERIAL_STM378X - depends on ARCH_STM + depends on ARCH_MXS default y bool "i.MX23/i.MX28 serial driver" diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index bc9b0de..442dbc4 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c @@ -157,8 +157,7 @@ struct amba_uart_port *uart; struct console_device *cdev; - uart = malloc(sizeof(struct amba_uart_port)); - + uart = xmalloc(sizeof(struct amba_uart_port)); uart->clk = clk_get(dev, NULL); if (IS_ERR(uart->clk)) diff --git a/drivers/serial/atmel.c b/drivers/serial/atmel.c index b99ec4d..1098952 100644 --- a/drivers/serial/atmel.c +++ b/drivers/serial/atmel.c @@ -398,8 +398,7 @@ struct atmel_uart_port *uart; struct console_device *cdev; - uart = malloc(sizeof(struct atmel_uart_port)); - + uart = xmalloc(sizeof(struct atmel_uart_port)); cdev = &uart->uart; dev->type_data = cdev; cdev->dev = dev; diff --git a/drivers/serial/serial_blackfin.c b/drivers/serial/serial_blackfin.c index 2101b7e..59b2fbb 100644 --- a/drivers/serial/serial_blackfin.c +++ b/drivers/serial/serial_blackfin.c @@ -115,7 +115,7 @@ { struct console_device *cdev; - cdev = malloc(sizeof(struct console_device)); + cdev = xmalloc(sizeof(struct console_device)); dev->type_data = cdev; cdev->dev = dev; cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR; diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c index a7562f9..984d7f2 100644 --- a/drivers/serial/serial_imx.c +++ b/drivers/serial/serial_imx.c @@ -319,7 +319,7 @@ struct imx_serial_priv *priv; uint32_t val; - priv = malloc(sizeof(*priv)); + priv = xmalloc(sizeof(*priv)); cdev = &priv->cdev; priv->regs = (void __force __iomem *)dev->map_base; diff --git a/drivers/serial/serial_netx.c b/drivers/serial/serial_netx.c index 7c09519..9d4b29e 100644 --- a/drivers/serial/serial_netx.c +++ b/drivers/serial/serial_netx.c @@ -140,7 +140,7 @@ { struct console_device *cdev; - cdev = malloc(sizeof(struct console_device)); + cdev = xmalloc(sizeof(struct console_device)); dev->type_data = cdev; cdev->dev = dev; cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR; diff --git a/drivers/serial/serial_pl010.c b/drivers/serial/serial_pl010.c index 1a6366f..7923ebb 100644 --- a/drivers/serial/serial_pl010.c +++ b/drivers/serial/serial_pl010.c @@ -141,7 +141,7 @@ { struct console_device *cdev; - cdev = malloc(sizeof(struct console_device)); + cdev = xmalloc(sizeof(struct console_device)); dev->type_data = cdev; cdev->dev = dev; cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR; diff --git a/drivers/serial/serial_s3c24x0.c b/drivers/serial/serial_s3c24x0.c index d7eac8f..0a17967 100644 --- a/drivers/serial/serial_s3c24x0.c +++ b/drivers/serial/serial_s3c24x0.c @@ -121,8 +121,7 @@ { struct console_device *cdev; - cdev = malloc(sizeof(struct console_device)); - + cdev = xmalloc(sizeof(struct console_device)); dev->type_data = cdev; cdev->dev = dev; cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR; diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 978fdd1..fd70e62 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -903,9 +903,6 @@ int status = -ENOMEM; cdev = xzalloc(sizeof *cdev); - if (!cdev) - return status; - cdev->gadget = gadget; set_gadget_data(gadget, cdev); INIT_LIST_HEAD(&cdev->configs); diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c index 48fd0b5..20a5064 100644 --- a/drivers/usb/gadget/fsl_udc.c +++ b/drivers/usb/gadget/fsl_udc.c @@ -1016,8 +1016,6 @@ struct fsl_req *req; req = xzalloc(sizeof *req); - if (!req) - return NULL; INIT_LIST_HEAD(&req->queue); @@ -2095,7 +2093,7 @@ udc->status_req = container_of(fsl_alloc_request(NULL), struct fsl_req, req); /* allocate a small amount of memory to get valid address */ - udc->status_req->req.buf = kmalloc(8, GFP_KERNEL); + udc->status_req->req.buf = xmalloc(8); udc->resume_state = USB_STATE_NOTATTACHED; udc->usb_state = USB_STATE_POWERED; udc->ep0_dir = 0; diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c index cb65b19..d3baed7 100644 --- a/drivers/usb/gadget/u_serial.c +++ b/drivers/usb/gadget/u_serial.c @@ -205,11 +205,7 @@ if (req != NULL) { req->length = len; - req->buf = memalign(32, len); - if (req->buf == NULL) { - usb_ep_free_request(ep, req); - return NULL; - } + req->buf = xmemalign(32, len); } return req; diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 802c548..15f7bfd 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -919,6 +919,13 @@ host->submit_control_msg = submit_control_msg; host->submit_bulk_msg = submit_bulk_msg; + if (ehci->flags & EHCI_HAS_TT) { + /* Set to host mode */ + reg = ehci_readl(ehci->hcor + USBMODE); + reg |= USBMODE_CM_HC; + writel(reg, ehci->hcor + USBMODE); + } + usb_register_host(host); reg = HC_VERSION(ehci_readl(&ehci->hccr->cr_capbase)); diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index c69308e..c652622 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -22,7 +22,7 @@ config DRIVER_VIDEO_STM bool "i.MX23/28 framebuffer driver" - depends on ARCH_STM + depends on ARCH_MXS help Say 'Y' here to enable framebuffer and splash screen support for i.MX23 and i.MX28 based systems. diff --git a/drivers/video/stm.c b/drivers/video/stm.c index f0abe4c..ee2f026 100644 --- a/drivers/video/stm.c +++ b/drivers/video/stm.c @@ -48,6 +48,7 @@ # define CTRL1_FIFO_CLEAR (1 << 21) # define SET_BYTE_PACKAGING(x) (((x) & 0xf) << 16) # define GET_BYTE_PACKAGING(x) (((x) >> 16) & 0xf) +# define CTRL1_RESET (1 << 0) #ifdef CONFIG_ARCH_IMX28 # define HW_LCDIF_CTRL2 0x20 @@ -142,7 +143,7 @@ unsigned memory_size; struct fb_info info; struct device_d *hw_dev; - struct imx_fb_videomode *pdata; + struct imx_fb_platformdata *pdata; }; /* the RGB565 true colour mode */ @@ -209,24 +210,6 @@ return (ppl * bpp) >> 3; } -static int stmfb_memory_mmgt(struct fb_info *fb_info, unsigned size) -{ - struct imxfb_info *fbi = fb_info->priv; - - if (fbi->memory_size != 0) { - free(fb_info->screen_base); - fb_info->screen_base = NULL; - fbi->memory_size = 0; - } - - if (fbi->memory_size == 0) { - fb_info->screen_base = xzalloc(size); - fbi->memory_size = size; - } - - return 0; -} - static void stmfb_enable_controller(struct fb_info *fb_info) { struct imxfb_info *fbi = fb_info->priv; @@ -271,8 +254,16 @@ /* stop FIFO reset */ writel(CTRL1_FIFO_CLEAR, fbi->base + HW_LCDIF_CTRL1 + BIT_CLR); + + /* enable LCD using LCD_RESET signal*/ + if (fbi->pdata->flags & USE_LCD_RESET) + writel(CTRL1_RESET, fbi->base + HW_LCDIF_CTRL1 + BIT_SET); + /* start the engine right now */ writel(CTRL_RUN, fbi->base + HW_LCDIF_CTRL + BIT_SET); + + if (fbi->pdata->enable) + fbi->pdata->enable(1); } static void stmfb_disable_controller(struct fb_info *fb_info) @@ -281,6 +272,14 @@ unsigned loop; uint32_t reg; + + /* disable LCD using LCD_RESET signal*/ + if (fbi->pdata->flags & USE_LCD_RESET) + writel(CTRL1_RESET, fbi->base + HW_LCDIF_CTRL1 + BIT_CLR); + + if (fbi->pdata->enable) + fbi->pdata->enable(0); + /* * Even if we disable the controller here, it will still continue * until its FIFOs are running out of data @@ -305,10 +304,9 @@ static int stmfb_activate_var(struct fb_info *fb_info) { struct imxfb_info *fbi = fb_info->priv; - struct imx_fb_videomode *pdata = fbi->pdata; + struct imx_fb_platformdata *pdata = fbi->pdata; struct fb_videomode *mode = fb_info->mode; uint32_t reg; - int ret; unsigned size; /* @@ -317,10 +315,14 @@ size = calc_line_length(mode->xres, fb_info->bits_per_pixel) * mode->yres; - ret = stmfb_memory_mmgt(fb_info, size); - if (ret != 0) { - dev_err(fbi->hw_dev, "Cannot allocate framebuffer memory\n"); - return ret; + if (pdata->fixed_screen) { + if (pdata->fixed_screen_size < size) + return -ENOMEM; + fb_info->screen_base = pdata->fixed_screen; + fbi->memory_size = pdata->fixed_screen_size; + } else { + fb_info->screen_base = xrealloc(fb_info->screen_base, size); + fbi->memory_size = size; } /** @todo ensure HCLK is active at this point of time! */ @@ -451,7 +453,7 @@ static void stmfb_info(struct device_d *hw_dev) { - struct imx_fb_videomode *pdata = hw_dev->platform_data; + struct imx_fb_platformdata *pdata = hw_dev->platform_data; unsigned u; printf(" Supported video modes:\n"); @@ -478,7 +480,7 @@ static int stmfb_probe(struct device_d *hw_dev) { - struct imx_fb_videomode *pdata = hw_dev->platform_data; + struct imx_fb_platformdata *pdata = hw_dev->platform_data; int ret; /* just init */ @@ -495,7 +497,10 @@ fbi.info.mode = &fbi.info.mode_list[0]; fbi.info.xres = fbi.info.mode->xres; fbi.info.yres = fbi.info.mode->yres; - fbi.info.bits_per_pixel = 16; + if (pdata->bits_per_pixel) + fbi.info.bits_per_pixel = pdata->bits_per_pixel; + else + fbi.info.bits_per_pixel = 16; ret = register_framebuffer(&fbi.info); if (ret != 0) { @@ -533,8 +538,8 @@ * (platform specific). * * For the developer: Don't forget to set the data bus width to the display - * in the imx_fb_videomode structure. You will else end up with ugly colours. + * in the imx_fb_platformdata structure. You will else end up with ugly colours. * If you fight against jitter you can vary the clock delay. This is a feature * of the i.MX28 and you can vary it between 2 ns ... 8 ns in 2 ns steps. Give - * the required value in the imx_fb_videomode structure. + * the required value in the imx_fb_platformdata structure. */ diff --git a/fs/fs.c b/fs/fs.c index 7d8dea7..2f61929 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -765,6 +765,7 @@ } sprintf(fsdev->dev.name, "%s", fsname); fsdev->dev.type_data = fsdev; + fsdev->dev.id = get_free_deviceid(fsdev->dev.name); if ((ret = register_device(&fsdev->dev))) { free(fsdev); diff --git a/include/asm-generic/bitsperlong.h b/include/asm-generic/bitsperlong.h new file mode 100644 index 0000000..4ae54e0 --- /dev/null +++ b/include/asm-generic/bitsperlong.h @@ -0,0 +1,32 @@ +#ifndef __ASM_GENERIC_BITS_PER_LONG +#define __ASM_GENERIC_BITS_PER_LONG + +/* + * There seems to be no way of detecting this automatically from user + * space, so 64 bit architectures should override this in their + * bitsperlong.h. In particular, an architecture that supports + * both 32 and 64 bit user space must not rely on CONFIG_64BIT + * to decide it, but rather check a compiler provided macro. + */ +#ifndef __BITS_PER_LONG +#define __BITS_PER_LONG 32 +#endif + +#ifdef __KERNEL__ + +#ifdef CONFIG_64BIT +#define BITS_PER_LONG 64 +#else +#define BITS_PER_LONG 32 +#endif /* CONFIG_64BIT */ + +/* + * FIXME: The check currently breaks x86-64 build, so it's + * temporarily disabled. Please fix x86-64 and reenable + */ +#if 0 && BITS_PER_LONG != __BITS_PER_LONG +#error Inconsistent word size. Check asm/bitsperlong.h +#endif + +#endif /* __KERNEL__ */ +#endif /* __ASM_GENERIC_BITS_PER_LONG */ diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h new file mode 100644 index 0000000..c5d60a9 --- /dev/null +++ b/include/asm-generic/sections.h @@ -0,0 +1,8 @@ +#ifndef _ASM_GENERIC_SECTIONS_H_ +#define _ASM_GENERIC_SECTIONS_H_ + +extern char _text[], _stext[], _etext[]; +extern char __bss_start[], __bss_stop[]; +extern char _end[]; + +#endif /* _ASM_GENERIC_SECTIONS_H_ */ diff --git a/include/asm-generic/swab.h b/include/asm-generic/swab.h new file mode 100644 index 0000000..a8e9029 --- /dev/null +++ b/include/asm-generic/swab.h @@ -0,0 +1,18 @@ +#ifndef _ASM_GENERIC_SWAB_H +#define _ASM_GENERIC_SWAB_H + +#include + +/* + * 32 bit architectures typically (but not always) want to + * set __SWAB_64_THRU_32__. In user space, this is only + * valid if the compiler supports 64 bit data types. + */ + +#if __BITS_PER_LONG == 32 +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) +#define __SWAB_64_THRU_32__ +#endif +#endif + +#endif /* _ASM_GENERIC_SWAB_H */ diff --git a/include/linux/byteorder/big_endian.h b/include/linux/byteorder/big_endian.h index 19b0c86..09fb188 100644 --- a/include/linux/byteorder/big_endian.h +++ b/include/linux/byteorder/big_endian.h @@ -9,7 +9,7 @@ #endif #define __BYTE_ORDER __BIG_ENDIAN -#include +#include #define __constant_htonl(x) ((__u32)(x)) #define __constant_ntohl(x) ((__u32)(x)) diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h index a46f3ec..5870a6e 100644 --- a/include/linux/byteorder/little_endian.h +++ b/include/linux/byteorder/little_endian.h @@ -9,7 +9,7 @@ #endif #define __BYTE_ORDER __LITTLE_ENDIAN -#include +#include #define __constant_htonl(x) ___constant_swab32((x)) #define __constant_ntohl(x) ___constant_swab32((x)) diff --git a/include/linux/byteorder/swab.h b/include/linux/byteorder/swab.h deleted file mode 100644 index b1d570e..0000000 --- a/include/linux/byteorder/swab.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef _LINUX_BYTEORDER_SWAB_H -#define _LINUX_BYTEORDER_SWAB_H - -/* - * linux/byteorder/swab.h - * Byte-swapping, independently from CPU endianness - * swabXX[ps]?(foo) - * - * Francois-Rene Rideau 19971205 - * separated swab functions from cpu_to_XX, - * to clean up support for bizarre-endian architectures. - * - * See asm-i386/byteorder.h and suches for examples of how to provide - * architecture-dependent optimized versions - * - */ - -/* casts are necessary for constants, because we never know how for sure - * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way. - */ -#define ___swab16(x) \ - ((__u16)( \ - (((__u16)(x) & (__u16)0x00ffU) << 8) | \ - (((__u16)(x) & (__u16)0xff00U) >> 8) )) -#define ___swab32(x) \ - ((__u32)( \ - (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ - (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ - (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ - (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) -#define ___swab64(x) \ - ((__u64)( \ - (__u64)(((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \ - (__u64)(((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \ - (__u64)(((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \ - (__u64)(((__u64)(x) & (__u64)0x00000000ff000000ULL) << 8) | \ - (__u64)(((__u64)(x) & (__u64)0x000000ff00000000ULL) >> 8) | \ - (__u64)(((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \ - (__u64)(((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \ - (__u64)(((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56) )) - -/* - * provide defaults when no architecture-specific optimization is detected - */ -#ifndef __arch__swab16 -# define __arch__swab16(x) ___swab16(x) -#endif -#ifndef __arch__swab32 -# define __arch__swab32(x) ___swab32(x) -#endif -#ifndef __arch__swab64 -# define __arch__swab64(x) ___swab64(x) -#endif - -#ifndef __arch__swab16p -# define __arch__swab16p(x) __swab16(*(x)) -#endif -#ifndef __arch__swab32p -# define __arch__swab32p(x) __swab32(*(x)) -#endif -#ifndef __arch__swab64p -# define __arch__swab64p(x) __swab64(*(x)) -#endif - -#ifndef __arch__swab16s -# define __arch__swab16s(x) do { *(x) = __swab16p((x)); } while (0) -#endif -#ifndef __arch__swab32s -# define __arch__swab32s(x) do { *(x) = __swab32p((x)); } while (0) -#endif -#ifndef __arch__swab64s -# define __arch__swab64s(x) do { *(x) = __swab64p((x)); } while (0) -#endif - - -/* - * Allow constant folding - */ -#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(__OPTIMIZE__) -# define __swab16(x) \ -(__builtin_constant_p((__u16)(x)) ? \ - ___swab16((x)) : \ - __fswab16((x))) -# define __swab32(x) \ -(__builtin_constant_p((__u32)(x)) ? \ - ___swab32((x)) : \ - __fswab32((x))) -# define __swab64(x) \ -(__builtin_constant_p((__u64)(x)) ? \ - ___swab64((x)) : \ - __fswab64((x))) -#else -# define __swab16(x) __fswab16(x) -# define __swab32(x) __fswab32(x) -# define __swab64(x) __fswab64(x) -#endif /* OPTIMIZE */ - - -static __inline__ __attribute__((const)) __u16 __fswab16(__u16 x) -{ - return __arch__swab16(x); -} -static __inline__ __u16 __swab16p(__u16 *x) -{ - return __arch__swab16p(x); -} -static __inline__ void __swab16s(__u16 *addr) -{ - __arch__swab16s(addr); -} - -static __inline__ __attribute__((const)) __u32 __fswab32(__u32 x) -{ - return __arch__swab32(x); -} -static __inline__ __u32 __swab32p(__u32 *x) -{ - return __arch__swab32p(x); -} -static __inline__ void __swab32s(__u32 *addr) -{ - __arch__swab32s(addr); -} - -#ifdef __BYTEORDER_HAS_U64__ -static __inline__ __attribute__((const)) __u64 __fswab64(__u64 x) -{ -# ifdef __SWAB_64_THRU_32__ - __u32 h = x >> 32; - __u32 l = x & ((1ULL<<32)-1); - return (((__u64)__swab32(l)) << 32) | ((__u64)(__swab32(h))); -# else - return __arch__swab64(x); -# endif -} -static __inline__ __u64 __swab64p(__u64 *x) -{ - return __arch__swab64p(x); -} -static __inline__ void __swab64s(__u64 *addr) -{ - __arch__swab64s(addr); -} -#endif /* __BYTEORDER_HAS_U64__ */ - -#if defined(__KERNEL__) -#define swab16 __swab16 -#define swab32 __swab32 -#define swab64 __swab64 -#define swab16p __swab16p -#define swab32p __swab32p -#define swab64p __swab64p -#define swab16s __swab16s -#define swab32s __swab32s -#define swab64s __swab64s -#endif - -#endif /* _LINUX_BYTEORDER_SWAB_H */ diff --git a/include/linux/swab.h b/include/linux/swab.h new file mode 100644 index 0000000..ea0c02f --- /dev/null +++ b/include/linux/swab.h @@ -0,0 +1,299 @@ +#ifndef _LINUX_SWAB_H +#define _LINUX_SWAB_H + +#include +#include +#include + +/* + * casts are necessary for constants, because we never know how for sure + * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way. + */ +#define ___constant_swab16(x) ((__u16)( \ + (((__u16)(x) & (__u16)0x00ffU) << 8) | \ + (((__u16)(x) & (__u16)0xff00U) >> 8))) + +#define ___constant_swab32(x) ((__u32)( \ + (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ + (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ + (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ + (((__u32)(x) & (__u32)0xff000000UL) >> 24))) + +#define ___constant_swab64(x) ((__u64)( \ + (((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \ + (((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \ + (((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \ + (((__u64)(x) & (__u64)0x00000000ff000000ULL) << 8) | \ + (((__u64)(x) & (__u64)0x000000ff00000000ULL) >> 8) | \ + (((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \ + (((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \ + (((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56))) + +#define ___constant_swahw32(x) ((__u32)( \ + (((__u32)(x) & (__u32)0x0000ffffUL) << 16) | \ + (((__u32)(x) & (__u32)0xffff0000UL) >> 16))) + +#define ___constant_swahb32(x) ((__u32)( \ + (((__u32)(x) & (__u32)0x00ff00ffUL) << 8) | \ + (((__u32)(x) & (__u32)0xff00ff00UL) >> 8))) + +/* + * Implement the following as inlines, but define the interface using + * macros to allow constant folding when possible: + * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32 + */ + +static inline __attribute_const__ __u16 __fswab16(__u16 val) +{ +#ifdef __arch_swab16 + return __arch_swab16(val); +#else + return ___constant_swab16(val); +#endif +} + +static inline __attribute_const__ __u32 __fswab32(__u32 val) +{ +#ifdef __arch_swab32 + return __arch_swab32(val); +#else + return ___constant_swab32(val); +#endif +} + +static inline __attribute_const__ __u64 __fswab64(__u64 val) +{ +#ifdef __arch_swab64 + return __arch_swab64(val); +#elif defined(__SWAB_64_THRU_32__) + __u32 h = val >> 32; + __u32 l = val & ((1ULL << 32) - 1); + return (((__u64)__fswab32(l)) << 32) | ((__u64)(__fswab32(h))); +#else + return ___constant_swab64(val); +#endif +} + +static inline __attribute_const__ __u32 __fswahw32(__u32 val) +{ +#ifdef __arch_swahw32 + return __arch_swahw32(val); +#else + return ___constant_swahw32(val); +#endif +} + +static inline __attribute_const__ __u32 __fswahb32(__u32 val) +{ +#ifdef __arch_swahb32 + return __arch_swahb32(val); +#else + return ___constant_swahb32(val); +#endif +} + +/** + * __swab16 - return a byteswapped 16-bit value + * @x: value to byteswap + */ +#define __swab16(x) \ + (__builtin_constant_p((__u16)(x)) ? \ + ___constant_swab16(x) : \ + __fswab16(x)) + +/** + * __swab32 - return a byteswapped 32-bit value + * @x: value to byteswap + */ +#define __swab32(x) \ + (__builtin_constant_p((__u32)(x)) ? \ + ___constant_swab32(x) : \ + __fswab32(x)) + +/** + * __swab64 - return a byteswapped 64-bit value + * @x: value to byteswap + */ +#define __swab64(x) \ + (__builtin_constant_p((__u64)(x)) ? \ + ___constant_swab64(x) : \ + __fswab64(x)) + +/** + * __swahw32 - return a word-swapped 32-bit value + * @x: value to wordswap + * + * __swahw32(0x12340000) is 0x00001234 + */ +#define __swahw32(x) \ + (__builtin_constant_p((__u32)(x)) ? \ + ___constant_swahw32(x) : \ + __fswahw32(x)) + +/** + * __swahb32 - return a high and low byte-swapped 32-bit value + * @x: value to byteswap + * + * __swahb32(0x12345678) is 0x34127856 + */ +#define __swahb32(x) \ + (__builtin_constant_p((__u32)(x)) ? \ + ___constant_swahb32(x) : \ + __fswahb32(x)) + +/** + * __swab16p - return a byteswapped 16-bit value from a pointer + * @p: pointer to a naturally-aligned 16-bit value + */ +static inline __u16 __swab16p(const __u16 *p) +{ +#ifdef __arch_swab16p + return __arch_swab16p(p); +#else + return __swab16(*p); +#endif +} + +/** + * __swab32p - return a byteswapped 32-bit value from a pointer + * @p: pointer to a naturally-aligned 32-bit value + */ +static inline __u32 __swab32p(const __u32 *p) +{ +#ifdef __arch_swab32p + return __arch_swab32p(p); +#else + return __swab32(*p); +#endif +} + +/** + * __swab64p - return a byteswapped 64-bit value from a pointer + * @p: pointer to a naturally-aligned 64-bit value + */ +static inline __u64 __swab64p(const __u64 *p) +{ +#ifdef __arch_swab64p + return __arch_swab64p(p); +#else + return __swab64(*p); +#endif +} + +/** + * __swahw32p - return a wordswapped 32-bit value from a pointer + * @p: pointer to a naturally-aligned 32-bit value + * + * See __swahw32() for details of wordswapping. + */ +static inline __u32 __swahw32p(const __u32 *p) +{ +#ifdef __arch_swahw32p + return __arch_swahw32p(p); +#else + return __swahw32(*p); +#endif +} + +/** + * __swahb32p - return a high and low byteswapped 32-bit value from a pointer + * @p: pointer to a naturally-aligned 32-bit value + * + * See __swahb32() for details of high/low byteswapping. + */ +static inline __u32 __swahb32p(const __u32 *p) +{ +#ifdef __arch_swahb32p + return __arch_swahb32p(p); +#else + return __swahb32(*p); +#endif +} + +/** + * __swab16s - byteswap a 16-bit value in-place + * @p: pointer to a naturally-aligned 16-bit value + */ +static inline void __swab16s(__u16 *p) +{ +#ifdef __arch_swab16s + __arch_swab16s(p); +#else + *p = __swab16p(p); +#endif +} +/** + * __swab32s - byteswap a 32-bit value in-place + * @p: pointer to a naturally-aligned 32-bit value + */ +static inline void __swab32s(__u32 *p) +{ +#ifdef __arch_swab32s + __arch_swab32s(p); +#else + *p = __swab32p(p); +#endif +} + +/** + * __swab64s - byteswap a 64-bit value in-place + * @p: pointer to a naturally-aligned 64-bit value + */ +static inline void __swab64s(__u64 *p) +{ +#ifdef __arch_swab64s + __arch_swab64s(p); +#else + *p = __swab64p(p); +#endif +} + +/** + * __swahw32s - wordswap a 32-bit value in-place + * @p: pointer to a naturally-aligned 32-bit value + * + * See __swahw32() for details of wordswapping + */ +static inline void __swahw32s(__u32 *p) +{ +#ifdef __arch_swahw32s + __arch_swahw32s(p); +#else + *p = __swahw32p(p); +#endif +} + +/** + * __swahb32s - high and low byteswap a 32-bit value in-place + * @p: pointer to a naturally-aligned 32-bit value + * + * See __swahb32() for details of high and low byte swapping + */ +static inline void __swahb32s(__u32 *p) +{ +#ifdef __arch_swahb32s + __arch_swahb32s(p); +#else + *p = __swahb32p(p); +#endif +} + +#ifdef __KERNEL__ +# define swab16 __swab16 +# define swab32 __swab32 +# define swab64 __swab64 +# define swahw32 __swahw32 +# define swahb32 __swahb32 +# define swab16p __swab16p +# define swab32p __swab32p +# define swab64p __swab64p +# define swahw32p __swahw32p +# define swahb32p __swahb32p +# define swab16s __swab16s +# define swab32s __swab32s +# define swab64s __swab64s +# define swahw32s __swahw32s +# define swahb32s __swahb32s +#endif /* __KERNEL__ */ + +#endif /* _LINUX_SWAB_H */ diff --git a/include/net.h b/include/net.h index 2d28fee..33d8a32 100644 --- a/include/net.h +++ b/include/net.h @@ -392,7 +392,7 @@ static inline char *net_alloc_packet(void) { - return memalign(32, PKTSIZE); + return xmemalign(32, PKTSIZE); } struct net_connection *net_udp_new(IPaddr_t dest, uint16_t dport, diff --git a/include/reloc.h b/include/reloc.h index 22cb886..cc99866 100644 --- a/include/reloc.h +++ b/include/reloc.h @@ -1,7 +1,7 @@ #ifndef __RELOC_H #define __RELOC_H -extern unsigned long _barebox_start, _bss_start, _bss_end, _text_base; +extern unsigned long _text_base; #ifdef CONFIG_HAS_EARLY_INIT diff --git a/include/xfuncs.h b/include/xfuncs.h index 222ea41..261aaa5 100644 --- a/include/xfuncs.h +++ b/include/xfuncs.h @@ -7,5 +7,6 @@ void *xrealloc(void *ptr, size_t size); void *xzalloc(size_t size); char *xstrdup(const char *s); +void* xmemalign(size_t alignment, size_t bytes); #endif /* __XFUNCS_H */ diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c index 8f9cdcf..fc5c49f 100644 --- a/lib/decompress_unlzo.c +++ b/lib/decompress_unlzo.c @@ -47,98 +47,73 @@ #define LZO_BLOCK_SIZE (256*1024l) #define HEADER_HAS_FILTER 0x00000800L -static inline int parse_header(int in_fd) +static inline int parse_header(u8 *input, u8 *skip) { - u8 l; + int l; + u8 *parse = input; + u8 level = 0; u16 version; - int ret; - unsigned char buf[256]; /* maximum filename length + 1 */ - /* read magic (9), library version (2), 'need to be extracted' - * version (2) and method (1) - */ - ret = read(in_fd, buf, 9); - if (ret < 0) - return ret; - - /* check magic */ + /* read magic: 9 first bits */ for (l = 0; l < 9; l++) { - if (buf[l] != lzop_magic[l]) - return -EINVAL; + if (*parse++ != lzop_magic[l]) + return 0; } - - ret = read(in_fd, buf, 4); /* version, lib_version */ - if (ret < 0) - return ret; - version = get_unaligned_be16(buf); - - if (version >= 0x0940) { - ret = read(in_fd, buf, 2); /* version to extract */ - if (ret < 0) - return ret; - } - - ret = read(in_fd, buf, 1); /* method */ - if (ret < 0) - return ret; - + /* get version (2bytes), skip library version (2), + * 'need to be extracted' version (2) and + * method (1) */ + version = get_unaligned_be16(parse); + parse += 7; if (version >= 0x0940) - read(in_fd, buf, 1); /* level */ - - ret = read(in_fd, buf, 4); /* flags */ - if (ret < 0) - return ret; - - if (get_unaligned_be32(buf) & HEADER_HAS_FILTER) { - ret = read(in_fd, buf, 4); /* skip filter info */ - if (ret < 0) - return ret; - } + level = *parse++; + if (get_unaligned_be32(parse) & HEADER_HAS_FILTER) + parse += 8; /* flags + filter info */ + else + parse += 4; /* flags */ /* skip mode and mtime_low */ - ret = read(in_fd, buf, 8); - if (ret < 0) - return ret; + parse += 8; + if (version >= 0x0940) + parse += 4; /* skip mtime_high */ - if (version >= 0x0940) { - ret = read(in_fd, buf, 4); /* skip mtime_high */ - if (ret < 0) - return ret; - } - - ret = read(in_fd, &l, 1); - if (ret < 0) - return ret; + l = *parse++; /* don't care about the file name, and skip checksum */ - ret = read(in_fd, buf, l + 4); - if (ret < 0) - return ret; + parse += l + 4; - return 0; + *skip = parse - input; + return 1; } -int unlzo(int in_fd, int out_fd, int *dest_len) +static int __unlzo(int *dest_len, + int (*fill) (void *, unsigned int), + int (*flush) (void *, unsigned int)) { - u8 r = 0; + u8 skip = 0, r = 0; u32 src_len, dst_len; size_t tmp; - u8 *in_buf, *out_buf; + u8 *in_buf, *in_buf_save, *out_buf, *out_buf_save; int obytes_processed = 0; - unsigned char buf[8]; - int ret; - - if (parse_header(in_fd)) - return -EINVAL; + int ret = -1; out_buf = xmalloc(LZO_BLOCK_SIZE); in_buf = xmalloc(lzo1x_worst_compress(LZO_BLOCK_SIZE)); + in_buf_save = in_buf; + out_buf_save = out_buf; + + ret = fill(in_buf, lzo1x_worst_compress(LZO_BLOCK_SIZE)); + if (ret < 0) + goto exit_free; + + if (!parse_header(in_buf, &skip)) + return -EINVAL; + + in_buf += skip; + for (;;) { /* read uncompressed block size */ - ret = read(in_fd, buf, 4); - if (ret < 0) - goto exit_free; - dst_len = get_unaligned_be32(buf); + dst_len = get_unaligned_be32(in_buf); + in_buf += 4; /* exit if last block */ if (dst_len == 0) @@ -150,43 +125,53 @@ } /* read compressed block size, and skip block checksum info */ - ret = read(in_fd, buf, 8); - if (ret < 0) - goto exit_free; - - src_len = get_unaligned_be32(buf); + src_len = get_unaligned_be32(in_buf); + in_buf += 8; if (src_len <= 0 || src_len > dst_len) { printf("file corrupted"); goto exit_free; } - ret = read(in_fd, in_buf, src_len); - if (ret < 0) - goto exit_free; /* decompress */ tmp = dst_len; - if (src_len < dst_len) { - r = lzo1x_decompress_safe((u8 *) in_buf, src_len, - out_buf, &tmp); - if (r != LZO_E_OK || dst_len != tmp) { - printf("Compressed data violation"); - goto exit_free; - } - ret = write(out_fd, out_buf, dst_len); - if (ret < 0) - goto exit_free; - } else { + + /* When the input data is not compressed at all, + * lzo1x_decompress_safe will fail, so call memcpy() + * instead */ + if (unlikely(dst_len == src_len)) { if (src_len != dst_len) { printf("Compressed data violation"); goto exit_free; } - ret = write(out_fd, in_buf, dst_len); - if (ret < 0) + out_buf = in_buf; + } else { + r = lzo1x_decompress_safe((u8 *) in_buf, src_len, + out_buf, &tmp); + + if (r != LZO_E_OK || dst_len != tmp) { + printf("Compressed data violation"); goto exit_free; + } } + ret = flush(out_buf, dst_len); + if (ret < 0) + goto exit_free; + + out_buf = in_buf + src_len; + in_buf = in_buf_save; + ret = fill(in_buf, lzo1x_worst_compress(LZO_BLOCK_SIZE)); + if (ret < 0) + goto exit_free; + + if (ret == 0) + in_buf = out_buf; + + out_buf = out_buf_save; + obytes_processed += dst_len; + } exit_free: @@ -197,3 +182,22 @@ return 0; } +static int in_fd; +static int out_fd; + +static int unlzo_fill(void *buf, unsigned int len) +{ + return read(in_fd, buf, len); +} + +static int unlzo_flush(void *buf, unsigned int len) +{ + return write(out_fd, buf, len); +} + +int unlzo(int _in_fd, int _out_fd, int *dest_len) +{ + in_fd = _in_fd; + out_fd = _out_fd; + return __unlzo(dest_len, unlzo_fill, unlzo_flush); +} diff --git a/lib/xfuncs.c b/lib/xfuncs.c index 01a64cf..71394ff 100644 --- a/lib/xfuncs.c +++ b/lib/xfuncs.c @@ -70,3 +70,11 @@ } EXPORT_SYMBOL(xstrdup); +void* xmemalign(size_t alignment, size_t bytes) +{ + void *p = memalign(alignment, bytes); + if (!p) + panic("ERROR: out of memory\n"); + return p; +} +EXPORT_SYMBOL(xmemalign); diff --git a/net/net.c b/net/net.c index 9b4ab89..7495357 100644 --- a/net/net.c +++ b/net/net.c @@ -365,7 +365,7 @@ return ERR_PTR(-ENETDOWN); con = xzalloc(sizeof(*con)); - con->packet = memalign(32, PKTSIZE); + con->packet = xmemalign(32, PKTSIZE); memset(con->packet, 0, PKTSIZE); con->et = (struct ethernet *)con->packet; @@ -658,7 +658,7 @@ int i; for (i = 0; i < PKTBUFSRX; i++) - NetRxPackets[i] = memalign(32, PKTSIZE); + NetRxPackets[i] = xmemalign(32, PKTSIZE); return 0; } diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c index 0d4f5e7..9f6535d 100644 --- a/scripts/basic/docproc.c +++ b/scripts/basic/docproc.c @@ -122,8 +122,11 @@ void add_new_symbol(struct symfile *sym, char * symname) { - sym->symbollist = - realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *)); + sym->symbollist = realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *)); + if (!sym->symbollist) { + fprintf(stderr, "docproc: out of memory\n"); + exit(1); + } sym->symbollist[sym->symbolcnt++].name = strdup(symname); } diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index de934de..368ae30 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -8,7 +8,7 @@ ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG) else -Kconfig := arch/$(SRCARCH)/Kconfig +Kconfig := Kconfig endif xconfig: $(obj)/qconf @@ -145,11 +145,8 @@ # Use recursively expanded variables so we do not call gcc unless # we really need to do so. (Do not call gcc as part of make mrproper) -HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) -HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) - -HOST_EXTRACFLAGS += -DLOCALE - +HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \ + -DLOCALE # =========================================================================== # Shared Makefile for the various kconfig executables: @@ -208,7 +205,7 @@ PHONY += $(obj)/dochecklxdialog $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog $(obj)/dochecklxdialog: - $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES) + $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf) always := dochecklxdialog @@ -226,6 +223,8 @@ HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ -D LKC_DIRECT_LINK +HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) + HOSTLOADLIBES_nconf = -lmenu -lpanel -lncurses $(obj)/qconf.o: $(obj)/.tmp_qtcheck @@ -236,40 +235,48 @@ # QT needs some extra effort... $(obj)/.tmp_qtcheck: @set -e; echo " CHECK qt"; dir=""; pkg=""; \ - pkg-config --exists qt 2> /dev/null && pkg=qt; \ - pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \ - if [ -n "$$pkg" ]; then \ - cflags="\$$(shell pkg-config $$pkg --cflags)"; \ - libs="\$$(shell pkg-config $$pkg --libs)"; \ - moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \ - dir="$$(pkg-config $$pkg --variable=prefix)"; \ + if ! pkg-config --exists QtCore 2> /dev/null; then \ + echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \ + pkg-config --exists qt 2> /dev/null && pkg=qt; \ + pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \ + if [ -n "$$pkg" ]; then \ + cflags="\$$(shell pkg-config $$pkg --cflags)"; \ + libs="\$$(shell pkg-config $$pkg --libs)"; \ + moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \ + dir="$$(pkg-config $$pkg --variable=prefix)"; \ + else \ + for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \ + if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ + done; \ + if [ -z "$$dir" ]; then \ + echo "*"; \ + echo "* Unable to find any QT installation. Please make sure that"; \ + echo "* the QT4 or QT3 development package is correctly installed and"; \ + echo "* either qmake can be found or install pkg-config or set"; \ + echo "* the QTDIR environment variable to the correct location."; \ + echo "*"; \ + false; \ + fi; \ + libpath=$$dir/lib; lib=qt; osdir=""; \ + $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \ + osdir=x$$($(HOSTCXX) -print-multi-os-directory); \ + test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \ + test -f $$libpath/libqt-mt.so && lib=qt-mt; \ + cflags="-I$$dir/include"; \ + libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \ + moc="$$dir/bin/moc"; \ + fi; \ + if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \ + echo "*"; \ + echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \ + echo "*"; \ + moc="/usr/bin/moc"; \ + fi; \ else \ - for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \ - if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ - done; \ - if [ -z "$$dir" ]; then \ - echo "*"; \ - echo "* Unable to find the QT3 installation. Please make sure that"; \ - echo "* the QT3 development package is correctly installed and"; \ - echo "* either install pkg-config or set the QTDIR environment"; \ - echo "* variable to the correct location."; \ - echo "*"; \ - false; \ - fi; \ - libpath=$$dir/lib; lib=qt; osdir=""; \ - $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \ - osdir=x$$($(HOSTCXX) -print-multi-os-directory); \ - test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \ - test -f $$libpath/libqt-mt.so && lib=qt-mt; \ - cflags="-I$$dir/include"; \ - libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \ - moc="$$dir/bin/moc"; \ - fi; \ - if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \ - echo "*"; \ - echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \ - echo "*"; \ - moc="/usr/bin/moc"; \ + cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \ + libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \ + binpath="\$$(shell pkg-config QtCore --variable=prefix)"; \ + moc="$$binpath/bin/moc"; \ fi; \ echo "KC_QT_CFLAGS=$$cflags" > $@; \ echo "KC_QT_LIBS=$$libs" >> $@; \ diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 9a5399b..659326c 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -425,9 +425,9 @@ (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { if (input_mode == listnewconfig) { if (sym->name && !sym_is_choice_value(sym)) { - printf("CONFIG_%s\n", sym->name); + printf("%s%s\n", CONFIG_, sym->name); } - } else { + } else if (input_mode != oldnoconfig) { if (!conf_cnt++) printf(_("*\n* Restart config...\n*\n")); rootEntry = menu_get_parent_menu(menu); @@ -466,7 +466,7 @@ bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - while ((opt = getopt_long_only(ac, av, "", long_opts, NULL)) != -1) { + while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) { input_mode = (enum input_mode)opt; switch (opt) { case silentoldconfig: @@ -508,8 +508,7 @@ name = conf_get_configname(); if (stat(name, &tmpstat)) { fprintf(stderr, _("***\n" - "*** You have not yet configured your barebox!\n" - "*** (missing barebox config file \"%s\")\n" + "*** Configuration file \"%s\" not found!\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" @@ -530,8 +529,6 @@ } break; case savedefconfig: - conf_read(NULL); - break; case silentoldconfig: case oldaskconfig: case oldconfig: @@ -571,7 +568,7 @@ name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, - _("\n*** Barebox configuration requires explicit update.\n\n")); + _("\n*** The configuration requires explicit update.\n\n")); return 1; } } @@ -623,11 +620,11 @@ * All other commands are only used to generate a config. */ if (conf_get_changed() && conf_write(NULL)) { - fprintf(stderr, _("\n*** Error during writing of the barebox configuration.\n\n")); + fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); exit(1); } if (conf_write_autoconf()) { - fprintf(stderr, _("\n*** Error during update of the barebox configuration.\n\n")); + fprintf(stderr, _("\n*** Error during update of the configuration.\n\n")); return 1; } } else if (input_mode == savedefconfig) { @@ -638,7 +635,7 @@ } } else if (input_mode != listnewconfig) { if (conf_write(NULL)) { - fprintf(stderr, _("\n*** Error during writing of the barebox configuration.\n\n")); + fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); exit(1); } } diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 73afcba..61c35bf 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -18,6 +19,9 @@ static void conf_warning(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +static void conf_message(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + static const char *conf_filename; static int conf_lineno, conf_warnings, conf_unsaved; @@ -34,6 +38,29 @@ conf_warnings++; } +static void conf_default_message_callback(const char *fmt, va_list ap) +{ + printf("#\n# "); + vprintf(fmt, ap); + printf("\n#\n"); +} + +static void (*conf_message_callback) (const char *fmt, va_list ap) = + conf_default_message_callback; +void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) +{ + conf_message_callback = fn; +} + +static void conf_message(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (conf_message_callback) + conf_message_callback(fmt, ap); +} + const char *conf_get_configname(void) { char *name = getenv("KCONFIG_CONFIG"); @@ -183,9 +210,8 @@ name = conf_expand_value(prop->expr->left.sym->name); in = zconf_fopen(name); if (in) { - printf(_("#\n" - "# using defaults found in %s\n" - "#\n"), name); + conf_message(_("using defaults found in %s"), + name); goto load; } } @@ -220,24 +246,23 @@ while (fgets(line, sizeof(line), in)) { conf_lineno++; sym = NULL; - switch (line[0]) { - case '#': - if (memcmp(line + 2, "CONFIG_", 7)) + if (line[0] == '#') { + if (memcmp(line + 2, CONFIG_, strlen(CONFIG_))) continue; - p = strchr(line + 9, ' '); + p = strchr(line + 2 + strlen(CONFIG_), ' '); if (!p) continue; *p++ = 0; if (strncmp(p, "is not set", 10)) continue; if (def == S_DEF_USER) { - sym = sym_find(line + 9); + sym = sym_find(line + 2 + strlen(CONFIG_)); if (!sym) { sym_add_change_count(1); - break; + goto setsym; } } else { - sym = sym_lookup(line + 9, 0); + sym = sym_lookup(line + 2 + strlen(CONFIG_), 0); if (sym->type == S_UNKNOWN) sym->type = S_BOOLEAN; } @@ -253,13 +278,8 @@ default: ; } - break; - case 'C': - if (memcmp(line, "CONFIG_", 7)) { - conf_warning("unexpected data"); - continue; - } - p = strchr(line + 7, '='); + } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) { + p = strchr(line + strlen(CONFIG_), '='); if (!p) continue; *p++ = 0; @@ -270,13 +290,13 @@ *p2 = 0; } if (def == S_DEF_USER) { - sym = sym_find(line + 7); + sym = sym_find(line + strlen(CONFIG_)); if (!sym) { sym_add_change_count(1); - break; + goto setsym; } } else { - sym = sym_lookup(line + 7, 0); + sym = sym_lookup(line + strlen(CONFIG_), 0); if (sym->type == S_UNKNOWN) sym->type = S_OTHER; } @@ -285,14 +305,12 @@ } if (conf_set_sym_val(sym, def, def_flags, p)) continue; - break; - case '\r': - case '\n': - break; - default: - conf_warning("unexpected data"); + } else { + if (line[0] != '\r' && line[0] != '\n') + conf_warning("unexpected data"); continue; } +setsym: if (sym && sym_is_choice_value(sym)) { struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); switch (sym->def[def].tri) { @@ -405,9 +423,9 @@ { int l; if (headerfile) - fprintf(out, "#define CONFIG_%s \"", name); + fprintf(out, "#define %s%s \"", CONFIG_, name); else - fprintf(out, "CONFIG_%s=\"", name); + fprintf(out, "%s%s=\"", CONFIG_, name); while (1) { l = strcspn(str, "\"\\"); @@ -422,24 +440,24 @@ fputs("\"\n", out); } -static void conf_write_symbol(struct symbol *sym, enum symbol_type type, - FILE *out, bool write_no) +static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no) { const char *str; - switch (type) { + switch (sym->type) { case S_BOOLEAN: case S_TRISTATE: switch (sym_get_tristate_value(sym)) { case no: if (write_no) - fprintf(out, "# CONFIG_%s is not set\n", sym->name); + fprintf(out, "# %s%s is not set\n", + CONFIG_, sym->name); break; case mod: - fprintf(out, "CONFIG_%s=m\n", sym->name); + fprintf(out, "%s%s=m\n", CONFIG_, sym->name); break; case yes: - fprintf(out, "CONFIG_%s=y\n", sym->name); + fprintf(out, "%s%s=y\n", CONFIG_, sym->name); break; } break; @@ -449,7 +467,7 @@ case S_HEX: case S_INT: str = sym_get_string_value(sym); - fprintf(out, "CONFIG_%s=%s\n", sym->name, str); + fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str); break; case S_OTHER: case S_UNKNOWN: @@ -497,7 +515,9 @@ /* * If symbol is a choice value and equals to the * default for a choice - skip. - * But only if value is bool and equal to "y" . + * But only if value is bool and equal to "y" and + * choice is not "optional". + * (If choice is "optional" then all values can be "n") */ if (sym_is_choice_value(sym)) { struct symbol *cs; @@ -505,13 +525,13 @@ cs = prop_get_symbol(sym_get_choice_prop(sym)); ds = sym_choice_default(cs); - if (sym == ds) { + if (!sym_is_optional(cs) && sym == ds) { if ((sym->type == S_BOOLEAN) && sym_get_tristate_value(sym) == yes) goto next_menu; } } - conf_write_symbol(sym, sym->type, out, true); + conf_write_symbol(sym, out, true); } next_menu: if (menu->list != NULL) { @@ -539,8 +559,7 @@ struct menu *menu; const char *basename; const char *str; - char dirname[128], tmpname[128], newname[128]; - enum symbol_type type; + char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; time_t now; int use_timestamp = 1; char *env; @@ -579,8 +598,6 @@ if (!out) return 1; - sym = sym_lookup("KERNELVERSION", 0); - sym_calc_value(sym); time(&now); env = getenv("KCONFIG_NOTIMESTAMP"); if (env && *env) @@ -588,10 +605,10 @@ fprintf(out, _("#\n" "# Automatically generated make config: don't edit\n" - "# Linux barebox version: %s\n" + "# %s\n" "%s%s" "#\n"), - sym_get_string_value(sym), + rootmenu.prompt->text, use_timestamp ? "# " : "", use_timestamp ? ctime(&now) : ""); @@ -614,14 +631,8 @@ if (!(sym->flags & SYMBOL_WRITE)) goto next; sym->flags &= ~SYMBOL_WRITE; - type = sym->type; - if (type == S_TRISTATE) { - sym_calc_value(modules_sym); - if (modules_sym->curr.tri == no) - type = S_BOOLEAN; - } /* Write config symbol to file */ - conf_write_symbol(sym, type, out, true); + conf_write_symbol(sym, out, true); } next: @@ -648,9 +659,7 @@ return 1; } - printf(_("#\n" - "# configuration written to %s\n" - "#\n"), newname); + conf_message(_("configuration written to %s"), newname); sym_set_change_count(0); @@ -660,7 +669,7 @@ static int conf_split_config(void) { const char *name; - char path[128]; + char path[PATH_MAX+1]; char *s, *d, c; struct symbol *sym; struct stat sb; @@ -802,25 +811,22 @@ return 1; } - sym = sym_lookup("KERNELVERSION", 0); - sym_calc_value(sym); time(&now); fprintf(out, "#\n" "# Automatically generated make config: don't edit\n" - "# Linux barebox version: %s\n" + "# %s\n" "# %s" "#\n", - sym_get_string_value(sym), ctime(&now)); + rootmenu.prompt->text, ctime(&now)); fprintf(tristate, "#\n" "# Automatically generated - do not edit\n" "\n"); fprintf(out_h, "/*\n" " * Automatically generated C config: don't edit\n" - " * Linux barebox version: %s\n" + " * %s\n" " * %s" - " */\n" - "#define AUTOCONF_INCLUDED\n", - sym_get_string_value(sym), ctime(&now)); + " */\n", + rootmenu.prompt->text, ctime(&now)); for_all_symbols(i, sym) { sym_calc_value(sym); @@ -828,7 +834,7 @@ continue; /* write symbol to config file */ - conf_write_symbol(sym, sym->type, out, false); + conf_write_symbol(sym, out, false); /* update autoconf and tristate files */ switch (sym->type) { @@ -838,14 +844,17 @@ case no: break; case mod: - fprintf(tristate, "CONFIG_%s=M\n", sym->name); - fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); + fprintf(tristate, "%s%s=M\n", + CONFIG_, sym->name); + fprintf(out_h, "#define %s%s_MODULE 1\n", + CONFIG_, sym->name); break; case yes: if (sym->type == S_TRISTATE) - fprintf(tristate, "CONFIG_%s=Y\n", - sym->name); - fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); + fprintf(tristate,"%s%s=Y\n", + CONFIG_, sym->name); + fprintf(out_h, "#define %s%s 1\n", + CONFIG_, sym->name); break; } break; @@ -855,12 +864,14 @@ case S_HEX: str = sym_get_string_value(sym); if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { - fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); + fprintf(out_h, "#define %s%s 0x%s\n", + CONFIG_, sym->name, str); break; } case S_INT: str = sym_get_string_value(sym); - fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); + fprintf(out_h, "#define %s%s %s\n", + CONFIG_, sym->name, str); break; default: break; @@ -926,7 +937,7 @@ int cnt, def; /* - * If choice is mod then we may have more items slected + * If choice is mod then we may have more items selected * and if no then no-one. * In both cases stop. */ @@ -1022,10 +1033,10 @@ /* * We have different type of choice blocks. - * If curr.tri equal to mod then we can select several + * If curr.tri equals to mod then we can select several * choice symbols in one block. * In this case we do nothing. - * If curr.tri equal yes then only one symbol can be + * If curr.tri equals yes then only one symbol can be * selected in a choice block and we set it to yes, * and the rest to no. */ diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 330e7c0..0010034 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -64,7 +64,7 @@ return e2 ? expr_alloc_two(E_OR, e1, e2) : e1; } -struct expr *expr_copy(struct expr *org) +struct expr *expr_copy(const struct expr *org) { struct expr *e; @@ -1013,6 +1013,48 @@ #endif } +static inline struct expr * +expr_get_leftmost_symbol(const struct expr *e) +{ + + if (e == NULL) + return NULL; + + while (e->type != E_SYMBOL) + e = e->left.expr; + + return expr_copy(e); +} + +/* + * Given expression `e1' and `e2', returns the leaf of the longest + * sub-expression of `e1' not containing 'e2. + */ +struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) +{ + struct expr *ret; + + switch (e1->type) { + case E_OR: + return expr_alloc_and( + expr_simplify_unmet_dep(e1->left.expr, e2), + expr_simplify_unmet_dep(e1->right.expr, e2)); + case E_AND: { + struct expr *e; + e = expr_alloc_and(expr_copy(e1), expr_copy(e2)); + e = expr_eliminate_dups(e); + ret = (!expr_eq(e, e1)) ? e1 : NULL; + expr_free(e); + break; + } + default: + ret = e1; + break; + } + + return expr_get_leftmost_symbol(ret); +} + void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) { if (!e) { diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 6ee2e4f..3d238db 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -18,7 +18,7 @@ struct file { struct file *next; struct file *parent; - char *name; + const char *name; int lineno; int flags; }; @@ -164,8 +164,8 @@ struct menu *list; struct symbol *sym; struct property *prompt; + struct expr *visibility; struct expr *dep; - struct expr *dir_dep; unsigned int flags; char *help; struct file *file; @@ -192,7 +192,7 @@ struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); -struct expr *expr_copy(struct expr *org); +struct expr *expr_copy(const struct expr *org); void expr_free(struct expr *e); int expr_eq(struct expr *e1, struct expr *e2); void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); @@ -207,6 +207,7 @@ struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); +struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); void expr_fprint(struct expr *e, FILE *out); struct gstr; /* forward */ diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 9b84fee..4558961 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -133,7 +133,6 @@ GladeXML *xml; GtkWidget *widget; GtkTextBuffer *txtbuf; - char title[256]; GtkStyle *style; xml = glade_xml_new(glade_file, "window1", NULL); @@ -210,9 +209,7 @@ /*"style", PANGO_STYLE_OBLIQUE, */ NULL); - sprintf(title, _("Barebox v%s Configuration"), - getenv("KERNELVERSION")); - gtk_window_set_title(GTK_WINDOW(main_wnd), title); + gtk_window_set_title(GTK_WINDOW(main_wnd), rootmenu.prompt->text); gtk_widget_show(main_wnd); } @@ -671,8 +668,7 @@ { GtkWidget *dialog; const gchar *intro_text = _( - "Welcome to gkc, the GTK+ graphical barebox configuration tool\n" - "for Linux.\n" + "Welcome to gkc, the GTK+ graphical configuration tool\n" "For each option, a blank box indicates the feature is disabled, a\n" "check indicates it is enabled, and a dot indicates that it is to\n" "be compiled as a module. Clicking on the box will cycle through the three states.\n" @@ -1531,12 +1527,6 @@ else glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL); - /* Load the interface and connect signals */ - init_main_window(glade_file); - init_tree_model(); - init_left_tree(); - init_right_tree(); - /* Conf stuffs */ if (ac > 1 && av[1][0] == '-') { switch (av[1][1]) { @@ -1556,6 +1546,12 @@ fixup_rootmenu(&rootmenu); conf_read(NULL); + /* Load the interface and connect signals */ + init_main_window(glade_file); + init_tree_model(); + init_left_tree(); + init_right_tree(); + switch (view_mode) { case SINGLE_VIEW: display_tree_part(); diff --git a/scripts/kconfig/gconf.glade b/scripts/kconfig/gconf.glade index d52b0a7..aa483cb 100644 --- a/scripts/kconfig/gconf.glade +++ b/scripts/kconfig/gconf.glade @@ -1,5 +1,4 @@ - diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c index dcc3fcc..e9d8e79 100644 --- a/scripts/kconfig/kxgettext.c +++ b/scripts/kconfig/kxgettext.c @@ -63,11 +63,11 @@ struct file_line { struct file_line *next; - char* file; - int lineno; + const char *file; + int lineno; }; -static struct file_line *file_line__new(char *file, int lineno) +static struct file_line *file_line__new(const char *file, int lineno) { struct file_line *self = malloc(sizeof(*self)); @@ -90,7 +90,8 @@ static struct message *message__list; -static struct message *message__new(const char *msg, char *option, char *file, int lineno) +static struct message *message__new(const char *msg, char *option, + const char *file, int lineno) { struct message *self = malloc(sizeof(*self)); @@ -130,7 +131,8 @@ return m; } -static int message__add_file_line(struct message *self, char *file, int lineno) +static int message__add_file_line(struct message *self, const char *file, + int lineno) { int rc = -1; struct file_line *fl = file_line__new(file, lineno); @@ -145,7 +147,8 @@ return rc; } -static int message__add(const char *msg, char *option, char *file, int lineno) +static int message__add(const char *msg, char *option, const char *file, + int lineno) { int rc = 0; char bf[16384]; diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped index ca60fb7..3c11bed 100644 --- a/scripts/kconfig/lex.zconf.c_shipped +++ b/scripts/kconfig/lex.zconf.c_shipped @@ -2373,9 +2373,10 @@ memset(buf, 0, sizeof(*buf)); current_buf->state = YY_CURRENT_BUFFER; - zconfin = zconf_fopen(name); + zconfin = zconf_fopen(file->name); if (!zconfin) { - printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); + printf("%s:%d: can't open file \"%s\"\n", + zconf_curname(), zconf_lineno(), file->name); exit(1); } zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); @@ -2422,7 +2423,7 @@ return current_pos.lineno; } -char *zconf_curname(void) +const char *zconf_curname(void) { return current_pos.file ? current_pos.file->name : ""; } diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index bdf71bd..febf0c9 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -14,6 +14,7 @@ static inline const char *gettext(const char *txt) { return txt; } static inline void textdomain(const char *domainname) {} static inline void bindtextdomain(const char *name, const char *dir) {} +static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; } #endif #ifdef __cplusplus @@ -31,12 +32,18 @@ #define SRCTREE "srctree" +#ifndef PACKAGE #define PACKAGE "linux" +#endif + #define LOCALEDIR "/usr/share/locale" #define _(text) gettext(text) #define N_(text) (text) +#ifndef CONFIG_ +#define CONFIG_ "CONFIG_" +#endif #define TF_COMMAND 0x0001 #define TF_PARAM 0x0002 @@ -61,16 +68,18 @@ enum symbol_type stype; }; +#ifdef YYDEBUG +extern int zconfdebug; +#endif + int zconfparse(void); void zconfdump(FILE *out); - -extern int zconfdebug; void zconf_starthelp(void); FILE *zconf_fopen(const char *name); void zconf_initscan(const char *name); void zconf_nextfile(const char *name); int zconf_lineno(void); -char *zconf_curname(void); +const char *zconf_curname(void); /* conf.c */ void xfgets(char *str, int size, FILE *in); @@ -101,6 +110,7 @@ void menu_add_entry(struct symbol *sym); void menu_end_entry(void); void menu_add_dep(struct expr *dep); +void menu_add_visibility(struct expr *dep); struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 9a948c9..17342fe 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -1,3 +1,4 @@ +#include /* confdata.c */ P(conf_parse,void,(const char *name)); @@ -8,6 +9,7 @@ P(conf_write_autoconf,int,(void)); P(conf_get_changed,bool,(void)); P(conf_set_changed_callback, void,(void (*fn)(void))); +P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap))); /* menu.c */ P(rootmenu,struct menu,); @@ -28,6 +30,7 @@ P(sym_lookup,struct symbol *,(const char *name, int flags)); P(sym_find,struct symbol *,(const char *name)); +P(sym_expand_string_value,const char *,(const char *in)); P(sym_re_search,struct symbol **,(const char *pattern)); P(sym_type_name,const char *,(enum symbol_type type)); P(sym_calc_value,void,(struct symbol *sym)); diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh index fcef0f5..82cc3a8 100644 --- a/scripts/kconfig/lxdialog/check-lxdialog.sh +++ b/scripts/kconfig/lxdialog/check-lxdialog.sh @@ -23,6 +23,8 @@ echo '-I/usr/include/ncurses -DCURSES_LOC=""' elif [ -f /usr/include/ncurses/curses.h ]; then echo '-I/usr/include/ncurses -DCURSES_LOC=""' + elif [ -f /usr/include/ncursesw/curses.h ]; then + echo '-I/usr/include/ncursesw -DCURSES_LOC=""' elif [ -f /usr/include/ncurses.h ]; then echo '-DCURSES_LOC=""' else diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index f658904..d433c7a 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -25,11 +25,9 @@ static const char mconf_readme[] = N_( "Overview\n" "--------\n" -"Some barebox features may be built directly into the barebox.\n" -"Some may be made into loadable runtime modules. Some features\n" -"may be completely removed altogether. There are also certain\n" -"barebox parameters which are not really features, but must be\n" -"entered in as decimal or hexadecimal numbers or possibly text.\n" +"This interface let you select features and parameters for the build.\n" +"Features can either be built-in, modularized, or ignored. Parameters\n" +"must be entered in as decimal or hexadecimal numbers or text.\n" "\n" "Menu items beginning with following braces represent features that\n" " [ ] can be built in or removed\n" @@ -117,7 +115,7 @@ "-----------------------------\n" "Menuconfig supports the use of alternate configuration files for\n" "those who, for various reasons, find it necessary to switch\n" -"between different barebox configurations.\n" +"between different configurations.\n" "\n" "At the end of the main menu you will find two options. One is\n" "for saving the current configuration to a file of your choosing.\n" @@ -150,9 +148,9 @@ "\n" "Optional personality available\n" "------------------------------\n" -"If you prefer to have all of the barebox options listed in a single\n" -"menu, rather than the default multimenu hierarchy, run the menuconfig\n" -"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" +"If you prefer to have all of the options listed in a single menu, rather\n" +"than the default multimenu hierarchy, run the menuconfig with\n" +"MENUCONFIG_MODE environment variable set to single_menu. Example:\n" "\n" "make MENUCONFIG_MODE=single_menu menuconfig\n" "\n" @@ -207,12 +205,12 @@ "last retrieved. Leave blank to abort."), load_config_help[] = N_( "\n" - "For various reasons, one may wish to keep several different barebox\n" + "For various reasons, one may wish to keep several different\n" "configurations available on a single machine.\n" "\n" "If you have saved a previous configuration in a file other than the\n" - "barebox's default, entering the name of the file here will allow you\n" - "to modify that configuration.\n" + "default one, entering its name here will allow you to modify that\n" + "configuration.\n" "\n" "If you are uncertain, then you have probably never used alternate\n" "configuration files. You should therefore leave this blank to abort.\n"), @@ -221,8 +219,8 @@ "as an alternate. Leave blank to abort."), save_config_help[] = N_( "\n" - "For various reasons, one may wish to keep different barebox\n" - "configurations available on a single machine.\n" + "For various reasons, one may wish to keep different configurations\n" + "available on a single machine.\n" "\n" "Entering a file name here will allow you to later retrieve, modify\n" "and use the current configuration as an alternate to whatever\n" @@ -232,7 +230,7 @@ "leave this blank.\n"), search_help[] = N_( "\n" - "Search for CONFIG_ symbols and display their relations.\n" + "Search for symbols and display their relations.\n" "Regular expressions are allowed.\n" "Example: search for \"^FOO\"\n" "Result:\n" @@ -249,7 +247,7 @@ "Selected by: BAR\n" "-----------------------------------------------------------------\n" "o The line 'Prompt:' shows the text used in the menu structure for\n" - " this CONFIG_ symbol\n" + " this symbol\n" "o The 'Defined at' line tell at what file / line number the symbol\n" " is defined\n" "o The 'Depends on:' line tell what symbols needs to be defined for\n" @@ -265,9 +263,9 @@ "Only relevant lines are shown.\n" "\n\n" "Search examples:\n" - "Examples: USB => find all CONFIG_ symbols containing USB\n" - " ^USB => find all CONFIG_ symbols starting with USB\n" - " USB$ => find all CONFIG_ symbols ending with USB\n" + "Examples: USB => find all symbols containing USB\n" + " ^USB => find all symbols starting with USB\n" + " USB$ => find all symbols ending with USB\n" "\n"); static int indent; @@ -290,13 +288,9 @@ { static char menu_backtitle[PATH_MAX+128]; int size; - struct symbol *sym; - sym = sym_lookup("KERNELVERSION", 0); - sym_calc_value(sym); size = snprintf(menu_backtitle, sizeof(menu_backtitle), - _("%s - Barebox v%s Configuration"), - config_filename, sym_get_string_value(sym)); + "%s - %s", config_filename, rootmenu.prompt->text); if (size >= sizeof(menu_backtitle)) menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; set_dialog_backtitle(menu_backtitle); @@ -316,8 +310,8 @@ again: dialog_clear(); dres = dialog_inputbox(_("Search Configuration Parameter"), - _("Enter CONFIG_ (sub)string to search for " - "(with or without \"CONFIG\")"), + _("Enter " CONFIG_ " (sub)string to search for " + "(with or without \"" CONFIG_ "\")"), 10, 75, ""); switch (dres) { case 0: @@ -329,10 +323,10 @@ return; } - /* strip CONFIG_ if necessary */ + /* strip the prefix if necessary */ dialog_input = dialog_input_result; - if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) - dialog_input += 7; + if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) + dialog_input += strlen(CONFIG_); sym_arr = sym_re_search(dialog_input); res = get_relations_str(sym_arr); @@ -834,7 +828,7 @@ if (conf_get_changed()) res = dialog_yesno(NULL, _("Do you wish to save your " - "new barebox configuration?\n" + "new configuration?\n" " to continue."), 6, 60); else @@ -846,20 +840,20 @@ case 0: if (conf_write(filename)) { fprintf(stderr, _("\n\n" - "Error during writing of the barebox configuration.\n" - "Your barebox configuration changes were NOT saved." + "Error while writing of the configuration.\n" + "Your configuration changes were NOT saved." "\n\n")); return 1; } case -1: printf(_("\n\n" - "*** End of Linux barebox configuration.\n" - "*** Execute 'make' to build the barebox or try 'make help'." + "*** End of the configuration.\n" + "*** Execute 'make' to start the build or try 'make help'." "\n\n")); break; default: fprintf(stderr, _("\n\n" - "Your barebox configuration changes were NOT saved." + "Your configuration changes were NOT saved." "\n\n")); } diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 5213527..5fdf10d 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -10,7 +10,7 @@ #include "lkc.h" static const char nohelp_text[] = N_( - "There is no help available for this barebox option.\n"); + "There is no help available for this option.\n"); struct menu rootmenu; static struct menu **last_entry_ptr; @@ -107,7 +107,6 @@ void menu_add_dep(struct expr *dep) { current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); - current_entry->dir_dep = current_entry->dep; } void menu_set_type(int type) @@ -139,8 +138,22 @@ while (isspace(*prompt)) prompt++; } - if (current_entry->prompt) + if (current_entry->prompt && current_entry != &rootmenu) prop_warn(prop, "prompt redefined"); + + /* Apply all upper menus' visibilities to actual prompts. */ + if(type == P_PROMPT) { + struct menu *menu = current_entry; + + while ((menu = menu->parent) != NULL) { + if (!menu->visibility) + continue; + prop->visible.expr + = expr_alloc_and(prop->visible.expr, + menu->visibility); + } + } + current_entry->prompt = prop; } prop->text = prompt; @@ -153,6 +166,12 @@ return menu_add_prop(type, prompt, NULL, dep); } +void menu_add_visibility(struct expr *expr) +{ + current_entry->visibility = expr_alloc_and(current_entry->visibility, + expr); +} + void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) { menu_add_prop(type, NULL, expr, dep); @@ -184,7 +203,7 @@ } } -static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2) +static int menu_validate_number(struct symbol *sym, struct symbol *sym2) { return sym2->type == S_INT || sym2->type == S_HEX || (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name)); @@ -202,6 +221,15 @@ prop_warn(prop, "default for config symbol '%s'" " must be a single symbol", sym->name); + if (prop->expr->type != E_SYMBOL) + break; + sym2 = prop_get_symbol(prop); + if (sym->type == S_HEX || sym->type == S_INT) { + if (!menu_validate_number(sym, sym2)) + prop_warn(prop, + "'%s': number is invalid", + sym->name); + } break; case P_SELECT: sym2 = prop_get_symbol(prop); @@ -221,8 +249,8 @@ if (sym->type != S_INT && sym->type != S_HEX) prop_warn(prop, "range is only allowed " "for int or hex symbols"); - if (!menu_range_valid_sym(sym, prop->expr->left.sym) || - !menu_range_valid_sym(sym, prop->expr->right.sym)) + if (!menu_validate_number(sym, prop->expr->left.sym) || + !menu_validate_number(sym, prop->expr->right.sym)) prop_warn(prop, "range is invalid"); break; default: @@ -291,10 +319,6 @@ for (menu = parent->list; menu; menu = menu->next) menu_finalize(menu); } else if (sym) { - /* ignore inherited dependencies for dir_dep */ - sym->dir_dep.expr = expr_transform(expr_copy(parent->dir_dep)); - sym->dir_dep.expr = expr_eliminate_dups(sym->dir_dep.expr); - basedep = parent->prompt ? parent->prompt->visible.expr : NULL; basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); basedep = expr_eliminate_dups(expr_transform(basedep)); @@ -325,6 +349,8 @@ parent->next = last_menu->next; last_menu->next = NULL; } + + sym->dir_dep.expr = parent->dep; } for (menu = parent->list; menu; menu = menu->next) { if (sym && sym_is_choice(sym) && @@ -413,6 +439,11 @@ if (!menu->prompt) return false; + if (menu->visibility) { + if (expr_calc_value(menu->visibility) == no) + return no; + } + sym = menu->sym; if (sym) { sym_calc_value(sym); @@ -566,7 +597,7 @@ if (menu_has_help(menu)) { if (sym->name) { - str_printf(help, "CONFIG_%s:\n\n", sym->name); + str_printf(help, "%s%s:\n\n", CONFIG_, sym->name); str_append(help, _(menu_get_help(menu))); str_append(help, "\n"); } diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index a63b317..db56377 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -5,25 +5,26 @@ * Derived from menuconfig. * */ +#define _GNU_SOURCE +#include #define LKC_DIRECT_LINK #include "lkc.h" #include "nconf.h" +#include static const char nconf_readme[] = N_( "Overview\n" "--------\n" -"Some barebox features may be built directly into the barebox.\n" -"Some may be made into loadable runtime modules. Some features\n" -"may be completely removed altogether. There are also certain\n" -"barebox parameters which are not really features, but must be\n" -"entered in as decimal or hexadecimal numbers or possibly text.\n" +"This interface let you select features and parameters for the build.\n" +"Features can either be built-in, modularized, or ignored. Parameters\n" +"must be entered in as decimal or hexadecimal numbers or text.\n" "\n" "Menu items beginning with following braces represent features that\n" " [ ] can be built in or removed\n" " < > can be built in, modularized or removed\n" " { } can be built in or modularized (selected by other feature)\n" " - - are selected by other feature,\n" -" XXX cannot be selected. use Symbol Info to find out why,\n" +" XXX cannot be selected. Use Symbol Info to find out why,\n" "while *, M or whitespace inside braces means to build in, build as\n" "a module or to exclude the feature respectively.\n" "\n" @@ -41,9 +42,13 @@ " pressing of . Use or to go back.\n" " Submenus are designated by \"--->\".\n" "\n" -" Shortcut: Press the option's highlighted letter (hotkey).\n" -" Pressing a hotkey more than once will sequence\n" -" through all visible items which use that hotkey.\n" +" Searching: pressing '/' triggers interactive search mode.\n" +" nconfig performs a case insensitive search for the string\n" +" in the menu prompts (no regex support).\n" +" Pressing the up/down keys highlights the previous/next\n" +" matching item. Backspace removes one character from the\n" +" match string. Pressing either '/' again or ESC exits\n" +" search mode. All other keys behave normally.\n" "\n" " You may also use the and keys to scroll\n" " unseen options into view.\n" @@ -88,7 +93,7 @@ "-----------------------------\n" "nconfig supports the use of alternate configuration files for\n" "those who, for various reasons, find it necessary to switch\n" -"between different barebox configurations.\n" +"between different configurations.\n" "\n" "At the end of the main menu you will find two options. One is\n" "for saving the current configuration to a file of your choosing.\n" @@ -121,9 +126,9 @@ "\n" "Optional personality available\n" "------------------------------\n" -"If you prefer to have all of the barebox options listed in a single\n" -"menu, rather than the default multimenu hierarchy, run the nconfig\n" -"with NCONFIG_MODE environment variable set to single_menu. Example:\n" +"If you prefer to have all of the options listed in a single menu, rather\n" +"than the default multimenu hierarchy, run the nconfig with NCONFIG_MODE\n" +"environment variable set to single_menu. Example:\n" "\n" "make NCONFIG_MODE=single_menu nconfig\n" "\n" @@ -141,21 +146,21 @@ " or selects submenus --->.\n" " Capital Letters are hotkeys.\n" " Pressing includes, excludes, modularizes features.\n" -" Pressing SpaceBar toggles between the above options\n" -" Press or to go back one menu, \n" +" Pressing SpaceBar toggles between the above options.\n" +" Press or to go back one menu,\n" " or for Help, for Search.\n" -" <1> is interchangable with , <2> with , etc.\n" +" <1> is interchangeable with , <2> with , etc.\n" " Legend: [*] built-in [ ] excluded module < > module capable.\n" -" always leaves the current window\n"), +" always leaves the current window.\n"), menu_instructions[] = N_( " Arrow keys navigate the menu.\n" " or selects submenus --->.\n" " Capital Letters are hotkeys.\n" " Pressing includes, excludes, modularizes features.\n" " Pressing SpaceBar toggles between the above options\n" -" Press , or to go back one menu, \n" +" Press , or to go back one menu,\n" " , or for Help, for Search.\n" -" <1> is interchangable with , <2> with , etc.\n" +" <1> is interchangeable with , <2> with , etc.\n" " Legend: [*] built-in [ ] excluded module < > module capable.\n" " always leaves the current window\n"), radiolist_instructions[] = N_( @@ -178,19 +183,19 @@ "has been configured as a module.\n" "As a result, this feature will be built as a module."), nohelp_text[] = N_( -"There is no help available for this barebox option.\n"), +"There is no help available for this option.\n"), load_config_text[] = N_( "Enter the name of the configuration file you wish to load.\n" "Accept the name shown to restore the configuration you\n" "last retrieved. Leave blank to abort."), load_config_help[] = N_( "\n" -"For various reasons, one may wish to keep several different barebox\n" +"For various reasons, one may wish to keep several different\n" "configurations available on a single machine.\n" "\n" "If you have saved a previous configuration in a file other than the\n" -"barebox's default, entering the name of the file here will allow you\n" -"to modify that configuration.\n" +"default one, entering its name here will allow you to modify that\n" +"configuration.\n" "\n" "If you are uncertain, then you have probably never used alternate\n" "configuration files. You should therefor leave this blank to abort.\n"), @@ -199,8 +204,8 @@ "as an alternate. Leave blank to abort."), save_config_help[] = N_( "\n" -"For various reasons, one may wish to keep different barebox\n" -"configurations available on a single machine.\n" +"For various reasons, one may wish to keep different configurations\n" +"available on a single machine.\n" "\n" "Entering a file name here will allow you to later retrieve, modify\n" "and use the current configuration as an alternate to whatever\n" @@ -210,8 +215,8 @@ "leave this blank.\n"), search_help[] = N_( "\n" -"Search for CONFIG_ symbols and display their relations.\n" -"Regular expressions are allowed.\n" +"Search for symbols and display their relations. Regular expressions\n" +"are allowed.\n" "Example: search for \"^FOO\"\n" "Result:\n" "-----------------------------------------------------------------\n" @@ -227,7 +232,7 @@ "Selected by: BAR\n" "-----------------------------------------------------------------\n" "o The line 'Prompt:' shows the text used in the menu structure for\n" -" this CONFIG_ symbol\n" +" this symbol\n" "o The 'Defined at' line tell at what file / line number the symbol\n" " is defined\n" "o The 'Depends on:' line tell what symbols needs to be defined for\n" @@ -243,16 +248,15 @@ "Only relevant lines are shown.\n" "\n\n" "Search examples:\n" -"Examples: USB = > find all CONFIG_ symbols containing USB\n" -" ^USB => find all CONFIG_ symbols starting with USB\n" -" USB$ => find all CONFIG_ symbols ending with USB\n" +"Examples: USB => find all symbols containing USB\n" +" ^USB => find all symbols starting with USB\n" +" USB$ => find all symbols ending with USB\n" "\n"); struct mitem { char str[256]; char tag; void *usrptr; - int is_hot; int is_visible; }; @@ -275,14 +279,6 @@ static int global_exit; /* the currently selected button */ const char *current_instructions = menu_instructions; -/* this array is used to implement hot keys. it is updated in item_make and - * resetted in clean_items. It would be better to use a hash, but lets keep it - * simple... */ -#define MAX_SAME_KEY MAX_MENU_ITEMS -struct { - int count; - int ptrs[MAX_MENU_ITEMS]; -} hotkeys[1<<(sizeof(char)*8)]; static void conf(struct menu *menu); static void conf_choice(struct menu *menu); @@ -292,6 +288,7 @@ static void show_help(struct menu *menu); static int do_exit(void); static void setup_windows(void); +static void search_conf(void); typedef void (*function_key_handler_t)(int *key, struct menu *menu); static void handle_f1(int *key, struct menu *current_item); @@ -302,6 +299,7 @@ static void handle_f6(int *key, struct menu *current_item); static void handle_f7(int *key, struct menu *current_item); static void handle_f8(int *key, struct menu *current_item); +static void handle_f9(int *key, struct menu *current_item); struct function_keys { const char *key_str; @@ -310,7 +308,7 @@ function_key_handler_t handler; }; -static const int function_keys_num = 8; +static const int function_keys_num = 9; struct function_keys function_keys[] = { { .key_str = "F1", @@ -320,13 +318,13 @@ }, { .key_str = "F2", - .func = "Symbol Info", + .func = "Sym Info", .key = F_SYMBOL, .handler = handle_f2, }, { .key_str = "F3", - .func = "Instructions", + .func = "Insts", .key = F_INSTS, .handler = handle_f3, }, @@ -356,9 +354,15 @@ }, { .key_str = "F8", + .func = "Sym Search", + .key = F_SEARCH, + .handler = handle_f8, + }, + { + .key_str = "F9", .func = "Exit", .key = F_EXIT, - .handler = handle_f8, + .handler = handle_f9, }, }; @@ -444,9 +448,16 @@ return; } -/* exit */ +/* search */ static void handle_f8(int *key, struct menu *current_item) { + search_conf(); + return; +} + +/* exit */ +static void handle_f9(int *key, struct menu *current_item) +{ do_exit(); return; } @@ -479,110 +490,44 @@ free_item(curses_menu_items[i]); bzero(curses_menu_items, sizeof(curses_menu_items)); bzero(k_menu_items, sizeof(k_menu_items)); - bzero(hotkeys, sizeof(hotkeys)); items_num = 0; } -/* return the index of the next hot item, or -1 if no such item exists */ -static int get_next_hot(int c) +typedef enum {MATCH_TINKER_PATTERN_UP, MATCH_TINKER_PATTERN_DOWN, + FIND_NEXT_MATCH_DOWN, FIND_NEXT_MATCH_UP} match_f; + +/* return the index of the matched item, or -1 if no such item exists */ +static int get_mext_match(const char *match_str, match_f flag) { - static int hot_index; - static int hot_char; + int match_start = item_index(current_item(curses_menu)); + int index; - if (c < 0 || c > 255 || hotkeys[c].count <= 0) - return -1; + if (flag == FIND_NEXT_MATCH_DOWN) + ++match_start; + else if (flag == FIND_NEXT_MATCH_UP) + --match_start; - if (hot_char == c) { - hot_index = (hot_index+1)%hotkeys[c].count; - return hotkeys[c].ptrs[hot_index]; - } else { - hot_char = c; - hot_index = 0; - return hotkeys[c].ptrs[0]; + index = match_start; + index = (index + items_num) % items_num; + while (true) { + char *str = k_menu_items[index].str; + if (strcasestr(str, match_str) != 0) + return index; + if (flag == FIND_NEXT_MATCH_UP || + flag == MATCH_TINKER_PATTERN_UP) + --index; + else + ++index; + index = (index + items_num) % items_num; + if (index == match_start) + return -1; } } -/* can the char c be a hot key? no, if c is a common shortcut used elsewhere */ -static int canbhot(char c) -{ - c = tolower(c); - return isalnum(c) && c != 'y' && c != 'm' && c != 'h' && - c != 'n' && c != '?'; -} - -/* check if str already contains a hot key. */ -static int is_hot(int index) -{ - return k_menu_items[index].is_hot; -} - -/* find the first possible hot key, and mark it. - * index is the index of the item in the menu - * return 0 on success*/ -static int make_hot(char *dest, int len, const char *org, int index) -{ - int position = -1; - int i; - int tmp; - int c; - int org_len = strlen(org); - - if (org == NULL || is_hot(index)) - return 1; - - /* make sure not to make hot keys out of markers. - * find where to start looking for a hot key - */ - i = 0; - /* skip white space */ - while (i < org_len && org[i] == ' ') - i++; - if (i == org_len) - return -1; - /* if encountering '(' or '<' or '[', find the match and look from there - **/ - if (org[i] == '[' || org[i] == '<' || org[i] == '(') { - i++; - for (; i < org_len; i++) - if (org[i] == ']' || org[i] == '>' || org[i] == ')') - break; - } - if (i == org_len) - return -1; - for (; i < org_len; i++) { - if (canbhot(org[i]) && org[i-1] != '<' && org[i-1] != '(') { - position = i; - break; - } - } - if (position == -1) - return 1; - - /* ok, char at org[position] should be a hot key to this item */ - c = tolower(org[position]); - tmp = hotkeys[c].count; - hotkeys[c].ptrs[tmp] = index; - hotkeys[c].count++; - /* - snprintf(dest, len, "%.*s(%c)%s", position, org, org[position], - &org[position+1]); - */ - /* make org[position] uppercase, and all leading letter small case */ - strncpy(dest, org, len); - for (i = 0; i < position; i++) - dest[i] = tolower(dest[i]); - dest[position] = toupper(dest[position]); - k_menu_items[index].is_hot = 1; - return 0; -} - -/* Make a new item. Add a hotkey mark in the first possible letter. - * As ncurses does not allow any attributes inside menue item, we mark the - * hot key as the first capitalized letter in the string */ +/* Make a new item. */ static void item_make(struct menu *menu, char tag, const char *fmt, ...) { va_list ap; - char tmp_str[256]; if (items_num > MAX_MENU_ITEMS-1) return; @@ -597,16 +542,13 @@ k_menu_items[items_num].is_visible = 1; va_start(ap, fmt); - vsnprintf(tmp_str, sizeof(tmp_str), fmt, ap); - if (!k_menu_items[items_num].is_visible) - memcpy(tmp_str, "XXX", 3); + vsnprintf(k_menu_items[items_num].str, + sizeof(k_menu_items[items_num].str), + fmt, ap); va_end(ap); - if (make_hot( - k_menu_items[items_num].str, - sizeof(k_menu_items[items_num].str), tmp_str, items_num) != 0) - strncpy(k_menu_items[items_num].str, - tmp_str, - sizeof(k_menu_items[items_num].str)); + + if (!k_menu_items[items_num].is_visible) + memcpy(k_menu_items[items_num].str, "XXX", 3); curses_menu_items[items_num] = new_item( k_menu_items[items_num].str, @@ -638,11 +580,9 @@ va_end(ap); snprintf(tmp_str, sizeof(tmp_str), "%s%s", k_menu_items[index].str, new_str); - if (make_hot(k_menu_items[index].str, - sizeof(k_menu_items[index].str), tmp_str, index) != 0) - strncpy(k_menu_items[index].str, - tmp_str, - sizeof(k_menu_items[index].str)); + strncpy(k_menu_items[index].str, + tmp_str, + sizeof(k_menu_items[index].str)); free_item(curses_menu_items[index]); curses_menu_items[index] = new_item( @@ -693,13 +633,9 @@ static const char *set_config_filename(const char *config_filename) { int size; - struct symbol *sym; - sym = sym_lookup("KERNELVERSION", 0); - sym_calc_value(sym); size = snprintf(menu_backtitle, sizeof(menu_backtitle), - _("%s - Barebox v%s Configuration"), - config_filename, sym_get_string_value(sym)); + "%s - %s", config_filename, rootmenu.prompt->text); if (size >= sizeof(menu_backtitle)) menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; @@ -709,25 +645,6 @@ return menu_backtitle; } -/* command = 0 is supress, 1 is restore */ -static void supress_stdout(int command) -{ - static FILE *org_stdout; - static FILE *org_stderr; - - if (command == 0) { - org_stdout = stdout; - org_stderr = stderr; - stdout = fopen("/dev/null", "a"); - stderr = fopen("/dev/null", "a"); - } else { - fclose(stdout); - fclose(stderr); - stdout = org_stdout; - stderr = org_stderr; - } -} - /* return = 0 means we are successful. * -1 means go on doing what you were doing */ @@ -739,8 +656,7 @@ return 0; } res = btn_dialog(main_window, - _("Do you wish to save your " - "new barebox configuration?\n" + _("Do you wish to save your new configuration?\n" " to cancel and resume nconfig."), 2, " ", @@ -753,36 +669,19 @@ /* if we got here, the user really wants to exit */ switch (res) { case 0: - supress_stdout(0); res = conf_write(filename); - supress_stdout(1); if (res) btn_dialog( main_window, - _("Error during writing of the barebox " - "configuration.\n" - "Your barebox configuration " - "changes were NOT saved."), + _("Error during writing of configuration.\n" + "Your configuration changes were NOT saved."), 1, ""); - else { - char buf[1024]; - snprintf(buf, 1024, - _("Configuration written to %s\n" - "End of Linux barebox configuration.\n" - "Execute 'make' to build the barebox or try" - " 'make help'."), filename); - btn_dialog( - main_window, - buf, - 1, - ""); - } break; default: btn_dialog( main_window, - _("Your barebox configuration changes were NOT saved."), + _("Your configuration changes were NOT saved."), 1, ""); break; @@ -802,8 +701,8 @@ again: dres = dialog_inputbox(main_window, _("Search Configuration Parameter"), - _("Enter CONFIG_ (sub)string to search for " - "(with or without \"CONFIG\")"), + _("Enter " CONFIG_ " (sub)string to search for " + "(with or without \"" CONFIG_ "\")"), "", dialog_input_result, 99); switch (dres) { case 0: @@ -816,10 +715,10 @@ return; } - /* strip CONFIG_ if necessary */ + /* strip the prefix if necessary */ dialog_input = dialog_input_result; - if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) - dialog_input += 7; + if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) + dialog_input += strlen(CONFIG_); sym_arr = sym_re_search(dialog_input); res = get_relations_str(sym_arr); @@ -1027,23 +926,18 @@ static void center_item(int selected_index, int *last_top_row) { int toprow; - int maxy, maxx; - scale_menu(curses_menu, &maxy, &maxx); set_top_row(curses_menu, *last_top_row); toprow = top_row(curses_menu); - if (selected_index >= toprow && selected_index < toprow+maxy) { - /* we can only move the selected item. no need to scroll */ - set_current_item(curses_menu, - curses_menu_items[selected_index]); - } else { - toprow = max(selected_index-maxy/2, 0); - if (toprow >= item_count(curses_menu)-maxy) + if (selected_index < toprow || + selected_index >= toprow+mwin_max_lines) { + toprow = max(selected_index-mwin_max_lines/2, 0); + if (toprow >= item_count(curses_menu)-mwin_max_lines) toprow = item_count(curses_menu)-mwin_max_lines; set_top_row(curses_menu, toprow); - set_current_item(curses_menu, - curses_menu_items[selected_index]); } + set_current_item(curses_menu, + curses_menu_items[selected_index]); *last_top_row = toprow; post_menu(curses_menu); refresh_all_windows(main_window); @@ -1075,7 +969,7 @@ /* position the menu at the middle of the screen */ scale_menu(curses_menu, &maxy, &maxx); maxx = min(maxx, mwin_max_cols-2); - maxy = mwin_max_lines-2; + maxy = mwin_max_lines; menu_window = derwin(main_window, maxy, maxx, @@ -1099,10 +993,77 @@ refresh_all_windows(main_window); } +static void adj_match_dir(match_f *match_direction) +{ + if (*match_direction == FIND_NEXT_MATCH_DOWN) + *match_direction = + MATCH_TINKER_PATTERN_DOWN; + else if (*match_direction == FIND_NEXT_MATCH_UP) + *match_direction = + MATCH_TINKER_PATTERN_UP; + /* else, do no change.. */ +} + +struct match_state +{ + int in_search; + match_f match_direction; + char pattern[256]; +}; + +/* Return 0 means I have handled the key. In such a case, ans should hold the + * item to center, or -1 otherwise. + * Else return -1 . + */ +static int do_match(int key, struct match_state *state, int *ans) +{ + char c = (char) key; + int terminate_search = 0; + *ans = -1; + if (key == '/' || (state->in_search && key == 27)) { + move(0, 0); + refresh(); + clrtoeol(); + state->in_search = 1-state->in_search; + bzero(state->pattern, sizeof(state->pattern)); + state->match_direction = MATCH_TINKER_PATTERN_DOWN; + return 0; + } else if (!state->in_search) + return 1; + + if (isalnum(c) || isgraph(c) || c == ' ') { + state->pattern[strlen(state->pattern)] = c; + state->pattern[strlen(state->pattern)] = '\0'; + adj_match_dir(&state->match_direction); + *ans = get_mext_match(state->pattern, + state->match_direction); + } else if (key == KEY_DOWN) { + state->match_direction = FIND_NEXT_MATCH_DOWN; + *ans = get_mext_match(state->pattern, + state->match_direction); + } else if (key == KEY_UP) { + state->match_direction = FIND_NEXT_MATCH_UP; + *ans = get_mext_match(state->pattern, + state->match_direction); + } else if (key == KEY_BACKSPACE || key == 127) { + state->pattern[strlen(state->pattern)-1] = '\0'; + adj_match_dir(&state->match_direction); + } else + terminate_search = 1; + + if (terminate_search) { + state->in_search = 0; + bzero(state->pattern, sizeof(state->pattern)); + move(0, 0); + refresh(); + clrtoeol(); + return -1; + } + return 0; +} static void conf(struct menu *menu) { - char pattern[256]; struct menu *submenu = 0; const char *prompt = menu_get_prompt(menu); struct symbol *sym; @@ -1110,8 +1071,11 @@ int res; int current_index = 0; int last_top_row = 0; - - bzero(pattern, sizeof(pattern)); + struct match_state match_state = { + .in_search = 0, + .match_direction = MATCH_TINKER_PATTERN_DOWN, + .pattern = "", + }; while (!global_exit) { reset_menu(); @@ -1124,7 +1088,22 @@ _(menu_instructions), current_index, &last_top_row); keypad((menu_win(curses_menu)), TRUE); - while (!global_exit && (res = wgetch(menu_win(curses_menu)))) { + while (!global_exit) { + if (match_state.in_search) { + mvprintw(0, 0, + "searching: %s", match_state.pattern); + clrtoeol(); + } + refresh_all_windows(main_window); + res = wgetch(menu_win(curses_menu)); + if (!res) + break; + if (do_match(res, &match_state, ¤t_index) == 0) { + if (current_index != -1) + center_item(current_index, + &last_top_row); + continue; + } if (process_special_keys(&res, (struct menu *) item_data())) break; @@ -1155,19 +1134,13 @@ if (res == 10 || res == 27 || res == 32 || res == 'n' || res == 'y' || res == KEY_LEFT || res == KEY_RIGHT || - res == 'm' || res == '/') + res == 'm') break; - else if (canbhot(res)) { - /* check for hot keys: */ - int tmp = get_next_hot(res); - if (tmp != -1) - center_item(tmp, &last_top_row); - } refresh_all_windows(main_window); } refresh_all_windows(main_window); - /* if ESC or left*/ + /* if ESC or left*/ if (res == 27 || (menu != &rootmenu && res == KEY_LEFT)) break; @@ -1235,23 +1208,30 @@ if (item_is_tag('t')) sym_set_tristate_value(sym, mod); break; - case '/': - search_conf(); - break; } } } +static void conf_message_callback(const char *fmt, va_list ap) +{ + char buf[1024]; + + vsnprintf(buf, sizeof(buf), fmt, ap); + btn_dialog(main_window, buf, 1, ""); +} + static void show_help(struct menu *menu) { struct gstr help = str_new(); if (menu && menu->sym && menu_has_help(menu)) { if (menu->sym->name) { - str_printf(&help, "CONFIG_%s:\n\n", menu->sym->name); + str_printf(&help, "%s%s:\n\n", CONFIG_, menu->sym->name); str_append(&help, _(menu_get_help(menu))); str_append(&help, "\n"); get_symbol_str(&help, menu->sym); + } else { + str_append(&help, _(menu_get_help(menu))); } } else { str_append(&help, nohelp_text); @@ -1268,6 +1248,11 @@ int selected_index = 0; int last_top_row = 0; int res, i = 0; + struct match_state match_state = { + .in_search = 0, + .match_direction = MATCH_TINKER_PATTERN_DOWN, + .pattern = "", + }; active = sym_get_choice_value(menu->sym); /* this is mostly duplicated from the conf() function. */ @@ -1281,9 +1266,13 @@ if (child->sym == sym_get_choice_value(menu->sym)) item_make(child, ':', " %s", _(menu_get_prompt(child))); - else + else if (child->sym) item_make(child, ':', " %s", _(menu_get_prompt(child))); + else + item_make(child, ':', "*** %s ***", + _(menu_get_prompt(child))); + if (child->sym == active){ last_top_row = top_row(curses_menu); selected_index = i; @@ -1294,7 +1283,22 @@ _(radiolist_instructions), selected_index, &last_top_row); - while (!global_exit && (res = wgetch(menu_win(curses_menu)))) { + while (!global_exit) { + if (match_state.in_search) { + mvprintw(0, 0, "searching: %s", + match_state.pattern); + clrtoeol(); + } + refresh_all_windows(main_window); + res = wgetch(menu_win(curses_menu)); + if (!res) + break; + if (do_match(res, &match_state, &selected_index) == 0) { + if (selected_index != -1) + center_item(selected_index, + &last_top_row); + continue; + } if (process_special_keys( &res, (struct menu *) item_data())) @@ -1324,13 +1328,8 @@ break; } if (res == 10 || res == 27 || res == ' ' || - res == KEY_LEFT) + res == KEY_LEFT){ break; - else if (canbhot(res)) { - /* check for hot keys: */ - int tmp = get_next_hot(res); - if (tmp != -1) - center_item(tmp, &last_top_row); } refresh_all_windows(main_window); } @@ -1339,7 +1338,7 @@ break; child = item_data(); - if (!child || !menu_is_visible(child)) + if (!child || !menu_is_visible(child) || !child->sym) continue; switch (res) { case ' ': @@ -1449,16 +1448,8 @@ case 0: if (!dialog_input_result[0]) return; - supress_stdout(0); res = conf_write(dialog_input_result); - supress_stdout(1); if (!res) { - char buf[1024]; - sprintf(buf, "%s %s", - _("configuration file saved to: "), - dialog_input_result); - btn_dialog(main_window, - buf, 1, ""); set_config_filename(dialog_input_result); return; } @@ -1485,7 +1476,7 @@ /* set up the menu and menu window */ main_window = newwin(LINES-2, COLS-2, 2, 1); keypad(main_window, TRUE); - mwin_max_lines = LINES-6; + mwin_max_lines = LINES-7; mwin_max_cols = COLS-6; /* panels order is from bottom to top */ @@ -1532,9 +1523,10 @@ /* set btns menu */ curses_menu = new_menu(curses_menu_items); menu_opts_off(curses_menu, O_SHOWDESC); - menu_opts_off(curses_menu, O_SHOWMATCH); + menu_opts_on(curses_menu, O_SHOWMATCH); menu_opts_on(curses_menu, O_ONEVALUE); menu_opts_on(curses_menu, O_NONCYCLIC); + menu_opts_on(curses_menu, O_IGNORECASE); set_menu_mark(curses_menu, " "); set_menu_fore(curses_menu, attributes[MAIN_MENU_FORE]); set_menu_back(curses_menu, attributes[MAIN_MENU_BACK]); @@ -1550,8 +1542,7 @@ _(menu_no_f_instructions)); } - - + conf_set_message_callback(conf_message_callback); /* do the work */ while (!global_exit) { conf(&rootmenu); diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index a9d9344..f8137b3 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -137,7 +137,7 @@ if (has_colors()) { normal_color_theme(); } else { - /* give deafults */ + /* give defaults */ no_colors_theme(); } } @@ -167,7 +167,7 @@ length = strlen(string); temp = (width - length) / 2; x = startx + (int)temp; - wattrset(win, color); + (void) wattrset(win, color); mvwprintw(win, y, x, "%s", string); refresh(); } @@ -297,11 +297,11 @@ set_menu_fore(menu, attributes[DIALOG_MENU_FORE]); set_menu_back(menu, attributes[DIALOG_MENU_BACK]); - wattrset(win, attributes[DIALOG_BOX]); + (void) wattrset(win, attributes[DIALOG_BOX]); box(win, 0, 0); /* print message */ - wattrset(msg_win, attributes[DIALOG_TEXT]); + (void) wattrset(msg_win, attributes[DIALOG_TEXT]); fill_window(msg_win, msg); set_menu_win(menu, win); @@ -392,16 +392,16 @@ form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2); keypad(form_win, TRUE); - wattrset(form_win, attributes[INPUT_FIELD]); + (void) wattrset(form_win, attributes[INPUT_FIELD]); - wattrset(win, attributes[INPUT_BOX]); + (void) wattrset(win, attributes[INPUT_BOX]); box(win, 0, 0); - wattrset(win, attributes[INPUT_HEADING]); + (void) wattrset(win, attributes[INPUT_HEADING]); if (title) mvwprintw(win, 0, 3, "%s", title); /* print message */ - wattrset(prompt_win, attributes[INPUT_TEXT]); + (void) wattrset(prompt_win, attributes[INPUT_TEXT]); fill_window(prompt_win, prompt); mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); @@ -531,7 +531,7 @@ /* create the pad */ pad = newpad(total_lines+10, total_cols+10); - wattrset(pad, attributes[SCROLLWIN_TEXT]); + (void) wattrset(pad, attributes[SCROLLWIN_TEXT]); fill_window(pad, text); win_lines = min(total_lines+4, LINES-2); @@ -546,9 +546,9 @@ win = newwin(win_lines, win_cols, y, x); keypad(win, TRUE); /* show the help in the help window, and show the help panel */ - wattrset(win, attributes[SCROLLWIN_BOX]); + (void) wattrset(win, attributes[SCROLLWIN_BOX]); box(win, 0, 0); - wattrset(win, attributes[SCROLLWIN_HEADING]); + (void) wattrset(win, attributes[SCROLLWIN_HEADING]); mvwprintw(win, 0, 3, " %s ", title); panel = new_panel(win); diff --git a/scripts/kconfig/nconf.h b/scripts/kconfig/nconf.h index fb42966..58fbda8 100644 --- a/scripts/kconfig/nconf.h +++ b/scripts/kconfig/nconf.h @@ -69,7 +69,8 @@ F_BACK = 5, F_SAVE = 6, F_LOAD = 7, - F_EXIT = 8 + F_SEARCH = 8, + F_EXIT = 9, } function_key; void set_colors(void); diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 546c6bf..16b2674 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -3,25 +3,42 @@ * Released under the terms of the GNU GPL v2.0. */ -#include +#include + +#if QT_VERSION < 0x040000 #include +#include +#include +#include +#include +#include +#include +#include +#include +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include #include #include #include -#include #include -#include -#include #include #include #include #include #include -#include -#include -#include -#include #include +#include #include @@ -39,7 +56,7 @@ static QApplication *configApp; static ConfigSettings *configSettings; -QAction *ConfigMainWindow::saveAction; +Q3Action *ConfigMainWindow::saveAction; static inline QString qgettext(const char* str) { @@ -54,9 +71,9 @@ /** * Reads a list of integer values from the application settings. */ -QValueList ConfigSettings::readSizes(const QString& key, bool *ok) +Q3ValueList ConfigSettings::readSizes(const QString& key, bool *ok) { - QValueList result; + Q3ValueList result; QStringList entryList = readListEntry(key, ok); QStringList::Iterator it; @@ -69,10 +86,10 @@ /** * Writes a list of integer values to the application settings. */ -bool ConfigSettings::writeSizes(const QString& key, const QValueList& value) +bool ConfigSettings::writeSizes(const QString& key, const Q3ValueList& value) { QStringList stringList; - QValueList::ConstIterator it; + Q3ValueList::ConstIterator it; for (it = value.begin(); it != value.end(); ++it) stringList.push_back(QString::number(*it)); @@ -80,7 +97,6 @@ } -#if QT_VERSION >= 300 /* * set the new data * TODO check the value @@ -91,7 +107,6 @@ sym_set_string_value(menu->sym, text(dataColIdx).latin1()); listView()->updateList(this); } -#endif /* * update the displayed of a menu entry @@ -195,11 +210,9 @@ data = sym_get_string_value(sym); -#if QT_VERSION >= 300 int i = list->mapIdx(dataColIdx); if (i >= 0) setRenameEnabled(i, TRUE); -#endif setText(dataColIdx, data); if (type == S_STRING) prompt = QString("%1: %2").arg(prompt).arg(data); @@ -432,7 +445,7 @@ if (!rootEntry) { if (mode != listMode) goto update; - QListViewItemIterator it(this); + Q3ListViewItemIterator it(this); ConfigItem* item; for (; it.current(); ++it) { @@ -527,11 +540,9 @@ case S_INT: case S_HEX: case S_STRING: -#if QT_VERSION >= 300 if (colMap[dataColIdx] >= 0) item->startRename(colMap[dataColIdx]); else -#endif parent()->lineEdit->show(item); break; } @@ -563,7 +574,7 @@ return; setRootMenu(menu_get_parent_menu(rootEntry->parent)); - QListViewItemIterator it(this); + Q3ListViewItemIterator it(this); for (; (item = (ConfigItem*)it.current()); it++) { if (item->menu == oldroot) { setCurrentItem(item); @@ -645,7 +656,7 @@ void ConfigList::keyPressEvent(QKeyEvent* ev) { - QListViewItem* i = currentItem(); + Q3ListViewItem* i = currentItem(); ConfigItem* item; struct menu *menu; enum prop_type type; @@ -811,10 +822,10 @@ { if (e->y() <= header()->geometry().bottom()) { if (!headerPopup) { - QAction *action; + Q3Action *action; - headerPopup = new QPopupMenu(this); - action = new QAction(NULL, _("Show Name"), 0, this); + headerPopup = new Q3PopupMenu(this); + action = new Q3Action(NULL, _("Show Name"), 0, this); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowName(bool))); @@ -822,7 +833,7 @@ action, SLOT(setOn(bool))); action->setOn(showName); action->addTo(headerPopup); - action = new QAction(NULL, _("Show Range"), 0, this); + action = new Q3Action(NULL, _("Show Range"), 0, this); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowRange(bool))); @@ -830,7 +841,7 @@ action, SLOT(setOn(bool))); action->setOn(showRange); action->addTo(headerPopup); - action = new QAction(NULL, _("Show Data"), 0, this); + action = new Q3Action(NULL, _("Show Data"), 0, this); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowData(bool))); @@ -914,7 +925,7 @@ void ConfigList::setAllOpen(bool open) { - QListViewItemIterator it(this); + Q3ListViewItemIterator it(this); for (; it.current(); it++) it.current()->setOpen(open); @@ -937,7 +948,7 @@ } ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) - : Parent(parent, name), sym(0), menu(0) + : Parent(parent, name), sym(0), _menu(0) { if (name) { configSettings->beginGroup(name); @@ -960,7 +971,7 @@ { if (_showDebug != b) { _showDebug = b; - if (menu) + if (_menu) menuInfo(); else if (sym) symbolInfo(); @@ -970,11 +981,11 @@ void ConfigInfoView::setInfo(struct menu *m) { - if (menu == m) + if (_menu == m) return; - menu = m; + _menu = m; sym = NULL; - if (!menu) + if (!_menu) clear(); else menuInfo(); @@ -1001,11 +1012,11 @@ struct symbol* sym; QString head, debug, help; - sym = menu->sym; + sym = _menu->sym; if (sym) { - if (menu->prompt) { + if (_menu->prompt) { head += ""; - head += print_filter(_(menu->prompt->text)); + head += print_filter(_(_menu->prompt->text)); head += ""; if (sym->name) { head += " ("; @@ -1031,23 +1042,23 @@ debug = debug_info(sym); struct gstr help_gstr = str_new(); - menu_get_ext_help(menu, &help_gstr); + menu_get_ext_help(_menu, &help_gstr); help = print_filter(str_get(&help_gstr)); str_free(&help_gstr); - } else if (menu->prompt) { + } else if (_menu->prompt) { head += ""; - head += print_filter(_(menu->prompt->text)); + head += print_filter(_(_menu->prompt->text)); head += "

"; if (showDebug()) { - if (menu->prompt->visible.expr) { + if (_menu->prompt->visible.expr) { debug += "  dep: "; - expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); + expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); debug += "

"; } } } if (showDebug()) - debug += QString().sprintf("defined at %s:%d

", menu->file->name, menu->lineno); + debug += QString().sprintf("defined at %s:%d

", _menu->file->name, _menu->lineno); setText(head + debug + help); } @@ -1150,10 +1161,10 @@ *text += str2; } -QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos) +Q3PopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos) { - QPopupMenu* popup = Parent::createPopupMenu(pos); - QAction* action = new QAction(NULL, _("Show Debug Info"), 0, popup); + Q3PopupMenu* popup = Parent::createPopupMenu(pos); + Q3Action* action = new Q3Action(NULL, _("Show Debug Info"), 0, popup); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); @@ -1210,7 +1221,7 @@ y = configSettings->readNumEntry("/window y", 0, &ok); if (ok) move(x, y); - QValueList sizes = configSettings->readSizes("/split", &ok); + Q3ValueList sizes = configSettings->readSizes("/split", &ok); if (ok) split->setSizes(sizes); configSettings->endGroup(); @@ -1263,8 +1274,14 @@ char title[256]; QDesktopWidget *d = configApp->desktop(); - snprintf(title, sizeof(title), _("Barebox v%s Configuration"), - getenv("KERNELVERSION")); + snprintf(title, sizeof(title), "%s%s", + rootmenu.prompt->text, +#if QT_VERSION < 0x040000 + " (Qt3)" +#else + "" +#endif + ); setCaption(title); width = configSettings->readNumEntry("/window width", d->width() - 64); @@ -1297,42 +1314,42 @@ configList->setFocus(); menu = menuBar(); - toolBar = new QToolBar("Tools", this); + toolBar = new Q3ToolBar("Tools", this); - backAction = new QAction("Back", QPixmap(xpm_back), _("Back"), 0, this); + backAction = new Q3Action("Back", QPixmap(xpm_back), _("Back"), 0, this); connect(backAction, SIGNAL(activated()), SLOT(goBack())); backAction->setEnabled(FALSE); - QAction *quitAction = new QAction("Quit", _("&Quit"), Qt::CTRL + Qt::Key_Q, this); + Q3Action *quitAction = new Q3Action("Quit", _("&Quit"), Qt::CTRL + Qt::Key_Q, this); connect(quitAction, SIGNAL(activated()), SLOT(close())); - QAction *loadAction = new QAction("Load", QPixmap(xpm_load), _("&Load"), Qt::CTRL + Qt::Key_L, this); + Q3Action *loadAction = new Q3Action("Load", QPixmap(xpm_load), _("&Load"), Qt::CTRL + Qt::Key_L, this); connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); - saveAction = new QAction("Save", QPixmap(xpm_save), _("&Save"), Qt::CTRL + Qt::Key_S, this); + saveAction = new Q3Action("Save", QPixmap(xpm_save), _("&Save"), Qt::CTRL + Qt::Key_S, this); connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); conf_set_changed_callback(conf_changed); // Set saveAction's initial state conf_changed(); - QAction *saveAsAction = new QAction("Save As...", _("Save &As..."), 0, this); + Q3Action *saveAsAction = new Q3Action("Save As...", _("Save &As..."), 0, this); connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); - QAction *searchAction = new QAction("Find", _("&Find"), Qt::CTRL + Qt::Key_F, this); + Q3Action *searchAction = new Q3Action("Find", _("&Find"), Qt::CTRL + Qt::Key_F, this); connect(searchAction, SIGNAL(activated()), SLOT(searchConfig())); - QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this); + Q3Action *singleViewAction = new Q3Action("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this); connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); - QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this); + Q3Action *splitViewAction = new Q3Action("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this); connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); - QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this); + Q3Action *fullViewAction = new Q3Action("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this); connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); - QAction *showNameAction = new QAction(NULL, _("Show Name"), 0, this); + Q3Action *showNameAction = new Q3Action(NULL, _("Show Name"), 0, this); showNameAction->setToggleAction(TRUE); connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool))); showNameAction->setOn(configView->showName()); - QAction *showRangeAction = new QAction(NULL, _("Show Range"), 0, this); + Q3Action *showRangeAction = new Q3Action(NULL, _("Show Range"), 0, this); showRangeAction->setToggleAction(TRUE); connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool))); showRangeAction->setOn(configList->showRange); - QAction *showDataAction = new QAction(NULL, _("Show Data"), 0, this); + Q3Action *showDataAction = new Q3Action(NULL, _("Show Data"), 0, this); showDataAction->setToggleAction(TRUE); connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); @@ -1345,9 +1362,15 @@ connect(optGroup, SIGNAL(selected(QAction *)), menuView, SLOT(setOptionMode(QAction *))); - configView->showNormalAction = new QAction(NULL, _("Show Normal Options"), 0, optGroup); - configView->showAllAction = new QAction(NULL, _("Show All Options"), 0, optGroup); - configView->showPromptAction = new QAction(NULL, _("Show Prompt Options"), 0, optGroup); +#if QT_VERSION >= 0x040000 + configView->showNormalAction = new QAction(_("Show Normal Options"), optGroup); + configView->showAllAction = new QAction(_("Show All Options"), optGroup); + configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup); +#else + configView->showNormalAction = new QAction(_("Show Normal Options"), 0, optGroup); + configView->showAllAction = new QAction(_("Show All Options"), 0, optGroup); + configView->showPromptAction = new QAction(_("Show Prompt Options"), 0, optGroup); +#endif configView->showNormalAction->setToggleAction(TRUE); configView->showNormalAction->setOn(configList->optMode == normalOpt); configView->showAllAction->setToggleAction(TRUE); @@ -1355,15 +1378,15 @@ configView->showPromptAction->setToggleAction(TRUE); configView->showPromptAction->setOn(configList->optMode == promptOpt); - QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this); + Q3Action *showDebugAction = new Q3Action(NULL, _("Show Debug Info"), 0, this); showDebugAction->setToggleAction(TRUE); connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool))); showDebugAction->setOn(helpText->showDebug()); - QAction *showIntroAction = new QAction(NULL, _("Introduction"), 0, this); + Q3Action *showIntroAction = new Q3Action(NULL, _("Introduction"), 0, this); connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); - QAction *showAboutAction = new QAction(NULL, _("About"), 0, this); + Q3Action *showAboutAction = new Q3Action(NULL, _("About"), 0, this); connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); // init tool bar @@ -1377,7 +1400,7 @@ fullViewAction->addTo(toolBar); // create config menu - QPopupMenu* config = new QPopupMenu(this); + Q3PopupMenu* config = new Q3PopupMenu(this); menu->insertItem(_("&File"), config); loadAction->addTo(config); saveAction->addTo(config); @@ -1386,12 +1409,12 @@ quitAction->addTo(config); // create edit menu - QPopupMenu* editMenu = new QPopupMenu(this); + Q3PopupMenu* editMenu = new Q3PopupMenu(this); menu->insertItem(_("&Edit"), editMenu); searchAction->addTo(editMenu); // create options menu - QPopupMenu* optionMenu = new QPopupMenu(this); + Q3PopupMenu* optionMenu = new Q3PopupMenu(this); menu->insertItem(_("&Option"), optionMenu); showNameAction->addTo(optionMenu); showRangeAction->addTo(optionMenu); @@ -1399,10 +1422,9 @@ optionMenu->insertSeparator(); optGroup->addTo(optionMenu); optionMenu->insertSeparator(); - showDebugAction->addTo(optionMenu); // create help menu - QPopupMenu* helpMenu = new QPopupMenu(this); + Q3PopupMenu* helpMenu = new Q3PopupMenu(this); menu->insertSeparator(); menu->insertItem(_("&Help"), helpMenu); showIntroAction->addTo(helpMenu); @@ -1437,7 +1459,7 @@ showSplitView(); // UI setup done, restore splitter positions - QValueList sizes = configSettings->readSizes("/split1", &ok); + Q3ValueList sizes = configSettings->readSizes("/split1", &ok); if (ok) split1->setSizes(sizes); @@ -1448,7 +1470,7 @@ void ConfigMainWindow::loadConfig(void) { - QString s = QFileDialog::getOpenFileName(conf_get_configname(), NULL, this); + QString s = Q3FileDialog::getOpenFileName(conf_get_configname(), NULL, this); if (s.isNull()) return; if (conf_read(QFile::encodeName(s))) @@ -1464,7 +1486,7 @@ void ConfigMainWindow::saveConfigAs(void) { - QString s = QFileDialog::getSaveFileName(conf_get_configname(), NULL, this); + QString s = Q3FileDialog::getSaveFileName(conf_get_configname(), NULL, this); if (s.isNull()) return; if (conf_write(QFile::encodeName(s))) @@ -1633,7 +1655,7 @@ void ConfigMainWindow::showIntro(void) { - static const QString str = _("Welcome to the qconf graphical barebox configuration tool for Linux.\n\n" + static const QString str = _("Welcome to the qconf graphical configuration tool.\n\n" "For each option, a blank box indicates the feature is disabled, a check\n" "indicates it is enabled, and a dot indicates that it is to be compiled\n" "as a module. Clicking on the box will cycle through the three states.\n\n" diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 636a74b..91677d9 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -3,26 +3,25 @@ * Released under the terms of the GNU GPL v2.0. */ +#if QT_VERSION < 0x040000 #include -#if QT_VERSION >= 300 -#include #else -class QSettings { -public: - void beginGroup(const QString& group) { } - void endGroup(void) { } - bool readBoolEntry(const QString& key, bool def = FALSE, bool* ok = 0) const - { if (ok) *ok = FALSE; return def; } - int readNumEntry(const QString& key, int def = 0, bool* ok = 0) const - { if (ok) *ok = FALSE; return def; } - QString readEntry(const QString& key, const QString& def = QString::null, bool* ok = 0) const - { if (ok) *ok = FALSE; return def; } - QStringList readListEntry(const QString& key, bool* ok = 0) const - { if (ok) *ok = FALSE; return QStringList(); } - template - bool writeEntry(const QString& key, t value) - { return TRUE; } -}; +#include +#endif +#include + +#if QT_VERSION < 0x040000 +#define Q3ValueList QValueList +#define Q3PopupMenu QPopupMenu +#define Q3ListView QListView +#define Q3ListViewItem QListViewItem +#define Q3VBox QVBox +#define Q3TextBrowser QTextBrowser +#define Q3MainWindow QMainWindow +#define Q3Action QAction +#define Q3ToolBar QToolBar +#define Q3ListViewItemIterator QListViewItemIterator +#define Q3FileDialog QFileDialog #endif class ConfigView; @@ -31,11 +30,10 @@ class ConfigLineEdit; class ConfigMainWindow; - class ConfigSettings : public QSettings { public: - QValueList readSizes(const QString& key, bool *ok); - bool writeSizes(const QString& key, const QValueList& value); + Q3ValueList readSizes(const QString& key, bool *ok); + bool writeSizes(const QString& key, const Q3ValueList& value); }; enum colIdx { @@ -48,9 +46,9 @@ normalOpt = 0, allOpt, promptOpt }; -class ConfigList : public QListView { +class ConfigList : public Q3ListView { Q_OBJECT - typedef class QListView Parent; + typedef class Q3ListView Parent; public: ConfigList(ConfigView* p, const char *name = 0); void reinit(void); @@ -135,17 +133,17 @@ struct menu *rootEntry; QColorGroup disabledColorGroup; QColorGroup inactivedColorGroup; - QPopupMenu* headerPopup; + Q3PopupMenu* headerPopup; private: int colMap[colNr]; int colRevMap[colNr]; }; -class ConfigItem : public QListViewItem { - typedef class QListViewItem Parent; +class ConfigItem : public Q3ListViewItem { + typedef class Q3ListViewItem Parent; public: - ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v) + ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v) : Parent(parent, after), menu(m), visible(v), goParent(false) { init(); @@ -155,16 +153,14 @@ { init(); } - ConfigItem(QListView *parent, ConfigItem *after, bool v) + ConfigItem(Q3ListView *parent, ConfigItem *after, bool v) : Parent(parent, after), menu(0), visible(v), goParent(true) { init(); } ~ConfigItem(void); void init(void); -#if QT_VERSION >= 300 void okRename(int col); -#endif void updateMenu(void); void testUpdateMenu(bool v); ConfigList* listView() const @@ -219,9 +215,9 @@ ConfigItem *item; }; -class ConfigView : public QVBox { +class ConfigView : public Q3VBox { Q_OBJECT - typedef class QVBox Parent; + typedef class Q3VBox Parent; public: ConfigView(QWidget* parent, const char *name = 0); ~ConfigView(void); @@ -252,9 +248,9 @@ static QAction *showPromptAction; }; -class ConfigInfoView : public QTextBrowser { +class ConfigInfoView : public Q3TextBrowser { Q_OBJECT - typedef class QTextBrowser Parent; + typedef class Q3TextBrowser Parent; public: ConfigInfoView(QWidget* parent, const char *name = 0); bool showDebug(void) const { return _showDebug; } @@ -274,11 +270,11 @@ QString debug_info(struct symbol *sym); static QString print_filter(const QString &str); static void expr_print_help(void *data, struct symbol *sym, const char *str); - QPopupMenu* createPopupMenu(const QPoint& pos); + Q3PopupMenu* createPopupMenu(const QPoint& pos); void contentsContextMenuEvent(QContextMenuEvent *e); struct symbol *sym; - struct menu *menu; + struct menu *_menu; bool _showDebug; }; @@ -302,10 +298,10 @@ struct symbol **result; }; -class ConfigMainWindow : public QMainWindow { +class ConfigMainWindow : public Q3MainWindow { Q_OBJECT - static QAction *saveAction; + static Q3Action *saveAction; static void conf_changed(void); public: ConfigMainWindow(void); @@ -334,8 +330,8 @@ ConfigView *configView; ConfigList *configList; ConfigInfoView *helpText; - QToolBar *toolBar; - QAction *backAction; + Q3ToolBar *toolBar; + Q3Action *backAction; QSplitter* split1; QSplitter* split2; }; diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index bf941fa..4014971 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -42,6 +42,8 @@ # mv config_strip .config # make oldconfig # +use strict; + my $config = ".config"; my $uname = `uname -r`; @@ -123,7 +125,6 @@ my %prompts; my %objects; my $var; -my $cont = 0; my $iflevel = 0; my @ifdeps; @@ -137,19 +138,45 @@ my $config; my @kconfigs; - open(KIN, "$ksource/$kconfig") || die "Can't open $kconfig"; + my $cont = 0; + my $line; + + my $source = "$ksource/$kconfig"; + my $last_source = ""; + + # Check for any environment variables used + while ($source =~ /\$(\w+)/ && $last_source ne $source) { + my $env = $1; + $last_source = $source; + $source =~ s/\$$env/$ENV{$env}/; + } + + open(KIN, "$source") || die "Can't open $kconfig"; while () { chomp; + # Make sure that lines ending with \ continue + if ($cont) { + $_ = $line . " " . $_; + } + + if (s/\\$//) { + $cont = 1; + $line = $_; + next; + } + + $cont = 0; + # collect any Kconfig sources if (/^source\s*"(.*)"/) { $kconfigs[$#kconfigs+1] = $1; } # configs found - if (/^\s*config\s+(\S+)\s*$/) { + if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; - $config = $1; + $config = $2; for (my $i = 0; $i < $iflevel; $i++) { if ($i) { @@ -178,7 +205,7 @@ # configs without prompts must be selected } elsif ($state ne "NONE" && /^\s*tristate\s\S/) { # note if the config has a prompt - $prompt{$config} = 1; + $prompts{$config} = 1; # Check for if statements } elsif (/^if\s+(.*\S)\s*$/) { @@ -218,6 +245,8 @@ # Read all Makefiles to map the configs to the objects foreach my $makefile (@makefiles) { + my $cont = 0; + open(MIN,$makefile) || die "Can't open $makefile"; while () { my $objs; @@ -281,7 +310,7 @@ # see what modules are loaded on this system my $lsmod; - foreach $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) { + foreach my $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) { if ( -x "$dir/lsmod" ) { $lsmod = "$dir/lsmod"; last; @@ -363,7 +392,7 @@ parse_config_dep_select $depends{$config}; } - if (defined($prompt{$config}) || !defined($selects{$config})) { + if (defined($prompts{$config}) || !defined($selects{$config})) { next; } diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index e95718f..a796c95 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -351,12 +351,16 @@ } calc_newval: if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { + struct expr *e; + e = expr_simplify_unmet_dep(sym->rev_dep.expr, + sym->dir_dep.expr); fprintf(stderr, "warning: ("); - expr_fprint(sym->rev_dep.expr, stderr); + expr_fprint(e, stderr); fprintf(stderr, ") selects %s which has unmet direct dependencies (", sym->name); expr_fprint(sym->dir_dep.expr, stderr); fprintf(stderr, ")\n"); + expr_free(e); } newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); } @@ -686,7 +690,7 @@ switch (sym->type) { case S_BOOLEAN: case S_TRISTATE: - /* The visibility imay limit the value from yes => mod */ + /* The visibility may limit the value from yes => mod */ val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); break; default: @@ -840,6 +844,55 @@ return symbol; } +/* + * Expand symbol's names embedded in the string given in argument. Symbols' + * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to + * the empty string. + */ +const char *sym_expand_string_value(const char *in) +{ + const char *src; + char *res; + size_t reslen; + + reslen = strlen(in) + 1; + res = malloc(reslen); + res[0] = '\0'; + + while ((src = strchr(in, '$'))) { + char *p, name[SYMBOL_MAXLENGTH]; + const char *symval = ""; + struct symbol *sym; + size_t newlen; + + strncat(res, in, src - in); + src++; + + p = name; + while (isalnum(*src) || *src == '_') + *p++ = *src++; + *p = '\0'; + + sym = sym_find(name); + if (sym != NULL) { + sym_calc_value(sym); + symval = sym_get_string_value(sym); + } + + newlen = strlen(res) + strlen(symval) + strlen(src) + 1; + if (newlen > reslen) { + reslen = newlen; + res = realloc(res, reslen); + } + + strcat(res, symval); + in = src; + } + strcat(res, in); + + return res; +} + struct symbol **sym_re_search(const char *pattern) { struct symbol *sym, **sym_arr = NULL; @@ -937,6 +990,8 @@ sym = stack->sym; next_sym = stack->next ? stack->next->sym : last_sym; prop = stack->prop; + if (prop == NULL) + prop = stack->sym->prop; /* for choice values find the menu entry (used below) */ if (sym_is_choice(sym) || sym_is_choice_value(sym)) { diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 78b5c04..6330cc8 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -12,15 +12,18 @@ struct file *file_lookup(const char *name) { struct file *file; + const char *file_name = sym_expand_string_value(name); for (file = file_list; file; file = file->next) { - if (!strcmp(name, file->name)) + if (!strcmp(name, file->name)) { + free((void *)file_name); return file; + } } file = malloc(sizeof(*file)); memset(file, 0, sizeof(*file)); - file->name = strdup(name); + file->name = file_name; file->next = file_list; file_list = file; return file; diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf index d8bc742..c9e690e 100644 --- a/scripts/kconfig/zconf.gperf +++ b/scripts/kconfig/zconf.gperf @@ -38,6 +38,7 @@ string, T_TYPE, TF_COMMAND, S_STRING select, T_SELECT, TF_COMMAND range, T_RANGE, TF_COMMAND +visible, T_VISIBLE, TF_COMMAND option, T_OPTION, TF_COMMAND on, T_ON, TF_PARAM modules, T_OPT_MODULES, TF_OPTION diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped index c1748fa..4055d5d 100644 --- a/scripts/kconfig/zconf.hash.c_shipped +++ b/scripts/kconfig/zconf.hash.c_shipped @@ -32,7 +32,7 @@ struct kconf_id; static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); -/* maximum key range = 47, duplicates = 0 */ +/* maximum key range = 50, duplicates = 0 */ #ifdef __GNUC__ __inline @@ -46,32 +46,32 @@ { static unsigned char asso_values[] = { - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 11, 5, - 0, 0, 5, 49, 5, 20, 49, 49, 5, 20, - 5, 0, 30, 49, 0, 15, 0, 10, 0, 49, - 25, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49 + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 40, 5, + 0, 0, 5, 52, 0, 20, 52, 52, 10, 20, + 5, 0, 35, 52, 0, 30, 0, 15, 0, 52, + 15, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52 }; register int hval = len; @@ -102,25 +102,26 @@ char kconf_id_strings_str12[sizeof("default")]; char kconf_id_strings_str13[sizeof("def_bool")]; char kconf_id_strings_str14[sizeof("help")]; - char kconf_id_strings_str15[sizeof("bool")]; char kconf_id_strings_str16[sizeof("config")]; char kconf_id_strings_str17[sizeof("def_tristate")]; - char kconf_id_strings_str18[sizeof("boolean")]; + char kconf_id_strings_str18[sizeof("hex")]; char kconf_id_strings_str19[sizeof("defconfig_list")]; - char kconf_id_strings_str21[sizeof("string")]; char kconf_id_strings_str22[sizeof("if")]; char kconf_id_strings_str23[sizeof("int")]; - char kconf_id_strings_str26[sizeof("select")]; char kconf_id_strings_str27[sizeof("modules")]; char kconf_id_strings_str28[sizeof("tristate")]; char kconf_id_strings_str29[sizeof("menu")]; - char kconf_id_strings_str31[sizeof("source")]; char kconf_id_strings_str32[sizeof("comment")]; - char kconf_id_strings_str33[sizeof("hex")]; char kconf_id_strings_str35[sizeof("menuconfig")]; - char kconf_id_strings_str36[sizeof("prompt")]; - char kconf_id_strings_str37[sizeof("depends")]; + char kconf_id_strings_str36[sizeof("string")]; + char kconf_id_strings_str37[sizeof("visible")]; + char kconf_id_strings_str41[sizeof("prompt")]; + char kconf_id_strings_str42[sizeof("depends")]; + char kconf_id_strings_str44[sizeof("bool")]; + char kconf_id_strings_str46[sizeof("select")]; + char kconf_id_strings_str47[sizeof("boolean")]; char kconf_id_strings_str48[sizeof("mainmenu")]; + char kconf_id_strings_str51[sizeof("source")]; }; static struct kconf_id_strings_t kconf_id_strings_contents = { @@ -136,25 +137,26 @@ "default", "def_bool", "help", - "bool", "config", "def_tristate", - "boolean", + "hex", "defconfig_list", - "string", "if", "int", - "select", "modules", "tristate", "menu", - "source", "comment", - "hex", "menuconfig", + "string", + "visible", "prompt", "depends", - "mainmenu" + "bool", + "select", + "boolean", + "mainmenu", + "source" }; #define kconf_id_strings ((const char *) &kconf_id_strings_contents) #ifdef __GNUC__ @@ -168,11 +170,11 @@ { enum { - TOTAL_KEYWORDS = 31, + TOTAL_KEYWORDS = 32, MIN_WORD_LENGTH = 2, MAX_WORD_LENGTH = 14, MIN_HASH_VALUE = 2, - MAX_HASH_VALUE = 48 + MAX_HASH_VALUE = 51 }; static struct kconf_id wordlist[] = @@ -191,31 +193,35 @@ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str15, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_HEX}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION}, - {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_TYPE, TF_COMMAND, S_STRING}, + {-1}, {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT}, - {-1}, {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SELECT, TF_COMMAND}, + {-1}, {-1}, {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND}, - {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SOURCE, TF_COMMAND}, + {-1}, {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_TYPE, TF_COMMAND, S_HEX}, - {-1}, + {-1}, {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_PROMPT, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_DEPENDS, TF_COMMAND}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_TYPE, TF_COMMAND, S_STRING}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_VISIBLE, TF_COMMAND}, + {-1}, {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_PROMPT, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_DEPENDS, TF_COMMAND}, {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND} + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str44, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_SELECT, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND}, + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_SOURCE, TF_COMMAND} }; if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 7ad18f7..0c25978 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -304,9 +304,10 @@ memset(buf, 0, sizeof(*buf)); current_buf->state = YY_CURRENT_BUFFER; - yyin = zconf_fopen(name); + yyin = zconf_fopen(file->name); if (!yyin) { - printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); + printf("%s:%d: can't open file \"%s\"\n", + zconf_curname(), zconf_lineno(), file->name); exit(1); } yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); @@ -353,7 +354,7 @@ return current_pos.lineno; } -char *zconf_curname(void) +const char *zconf_curname(void) { return current_pos.file ? current_pos.file->name : ""; } diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped index 32a9eef..4c5495e 100644 --- a/scripts/kconfig/zconf.tab.c_shipped +++ b/scripts/kconfig/zconf.tab.c_shipped @@ -160,18 +160,19 @@ T_DEFAULT = 275, T_SELECT = 276, T_RANGE = 277, - T_OPTION = 278, - T_ON = 279, - T_WORD = 280, - T_WORD_QUOTE = 281, - T_UNEQUAL = 282, - T_CLOSE_PAREN = 283, - T_OPEN_PAREN = 284, - T_EOL = 285, - T_OR = 286, - T_AND = 287, - T_EQUAL = 288, - T_NOT = 289 + T_VISIBLE = 278, + T_OPTION = 279, + T_ON = 280, + T_WORD = 281, + T_WORD_QUOTE = 282, + T_UNEQUAL = 283, + T_CLOSE_PAREN = 284, + T_OPEN_PAREN = 285, + T_EOL = 286, + T_OR = 287, + T_AND = 288, + T_EQUAL = 289, + T_NOT = 290 }; #endif @@ -417,22 +418,22 @@ #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 3 +#define YYFINAL 11 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 259 +#define YYLAST 290 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 35 +#define YYNTOKENS 36 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 46 +#define YYNNTS 50 /* YYNRULES -- Number of rules. */ -#define YYNRULES 110 +#define YYNRULES 118 /* YYNRULES -- Number of states. */ -#define YYNSTATES 180 +#define YYNSTATES 191 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 289 +#define YYMAXUTOK 290 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -468,7 +469,8 @@ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35 }; #if YYDEBUG @@ -476,73 +478,75 @@ YYRHS. */ static const yytype_uint16 yyprhs[] = { - 0, 0, 3, 5, 6, 9, 12, 15, 20, 23, - 28, 33, 37, 39, 41, 43, 45, 47, 49, 51, - 53, 55, 57, 59, 61, 63, 67, 70, 74, 77, - 81, 84, 85, 88, 91, 94, 97, 100, 103, 107, - 112, 117, 122, 128, 132, 133, 137, 138, 141, 145, - 148, 150, 154, 155, 158, 161, 164, 167, 170, 175, - 179, 182, 187, 188, 191, 195, 197, 201, 202, 205, - 208, 211, 215, 218, 220, 224, 225, 228, 231, 234, - 238, 242, 245, 248, 251, 252, 255, 258, 261, 266, - 267, 270, 272, 274, 277, 280, 283, 285, 288, 289, - 292, 294, 298, 302, 306, 309, 313, 317, 319, 321, - 322 + 0, 0, 3, 6, 8, 11, 13, 14, 17, 20, + 23, 26, 31, 36, 40, 42, 44, 46, 48, 50, + 52, 54, 56, 58, 60, 62, 64, 66, 68, 72, + 75, 79, 82, 86, 89, 90, 93, 96, 99, 102, + 105, 108, 112, 117, 122, 127, 133, 137, 138, 142, + 143, 146, 150, 153, 155, 159, 160, 163, 166, 169, + 172, 175, 180, 184, 187, 192, 193, 196, 200, 202, + 206, 207, 210, 213, 216, 220, 224, 228, 230, 234, + 235, 238, 241, 244, 248, 252, 255, 258, 261, 262, + 265, 268, 271, 276, 277, 280, 283, 286, 287, 290, + 292, 294, 297, 300, 303, 305, 308, 309, 312, 314, + 318, 322, 326, 329, 333, 337, 339, 341, 342 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 36, 0, -1, 37, -1, -1, 37, 39, -1, 37, - 53, -1, 37, 64, -1, 37, 3, 74, 76, -1, - 37, 75, -1, 37, 25, 1, 30, -1, 37, 38, - 1, 30, -1, 37, 1, 30, -1, 16, -1, 18, - -1, 19, -1, 21, -1, 17, -1, 22, -1, 20, - -1, 30, -1, 59, -1, 68, -1, 42, -1, 44, - -1, 66, -1, 25, 1, 30, -1, 1, 30, -1, - 10, 25, 30, -1, 41, 45, -1, 11, 25, 30, - -1, 43, 45, -1, -1, 45, 46, -1, 45, 47, - -1, 45, 72, -1, 45, 70, -1, 45, 40, -1, - 45, 30, -1, 19, 73, 30, -1, 18, 74, 77, - 30, -1, 20, 78, 77, 30, -1, 21, 25, 77, - 30, -1, 22, 79, 79, 77, 30, -1, 23, 48, - 30, -1, -1, 48, 25, 49, -1, -1, 33, 74, - -1, 7, 80, 30, -1, 50, 54, -1, 75, -1, - 51, 56, 52, -1, -1, 54, 55, -1, 54, 72, - -1, 54, 70, -1, 54, 30, -1, 54, 40, -1, - 18, 74, 77, 30, -1, 19, 73, 30, -1, 17, - 30, -1, 20, 25, 77, 30, -1, -1, 56, 39, - -1, 14, 78, 76, -1, 75, -1, 57, 60, 58, - -1, -1, 60, 39, -1, 60, 64, -1, 60, 53, - -1, 4, 74, 30, -1, 61, 71, -1, 75, -1, - 62, 65, 63, -1, -1, 65, 39, -1, 65, 64, - -1, 65, 53, -1, 6, 74, 30, -1, 9, 74, - 30, -1, 67, 71, -1, 12, 30, -1, 69, 13, - -1, -1, 71, 72, -1, 71, 30, -1, 71, 40, - -1, 16, 24, 78, 30, -1, -1, 74, 77, -1, - 25, -1, 26, -1, 5, 30, -1, 8, 30, -1, - 15, 30, -1, 30, -1, 76, 30, -1, -1, 14, - 78, -1, 79, -1, 79, 33, 79, -1, 79, 27, - 79, -1, 29, 78, 28, -1, 34, 78, -1, 78, - 31, 78, -1, 78, 32, 78, -1, 25, -1, 26, - -1, -1, 25, -1 + 37, 0, -1, 81, 38, -1, 38, -1, 63, 39, + -1, 39, -1, -1, 39, 41, -1, 39, 55, -1, + 39, 67, -1, 39, 80, -1, 39, 26, 1, 31, + -1, 39, 40, 1, 31, -1, 39, 1, 31, -1, + 16, -1, 18, -1, 19, -1, 21, -1, 17, -1, + 22, -1, 20, -1, 23, -1, 31, -1, 61, -1, + 71, -1, 44, -1, 46, -1, 69, -1, 26, 1, + 31, -1, 1, 31, -1, 10, 26, 31, -1, 43, + 47, -1, 11, 26, 31, -1, 45, 47, -1, -1, + 47, 48, -1, 47, 49, -1, 47, 75, -1, 47, + 73, -1, 47, 42, -1, 47, 31, -1, 19, 78, + 31, -1, 18, 79, 82, 31, -1, 20, 83, 82, + 31, -1, 21, 26, 82, 31, -1, 22, 84, 84, + 82, 31, -1, 24, 50, 31, -1, -1, 50, 26, + 51, -1, -1, 34, 79, -1, 7, 85, 31, -1, + 52, 56, -1, 80, -1, 53, 58, 54, -1, -1, + 56, 57, -1, 56, 75, -1, 56, 73, -1, 56, + 31, -1, 56, 42, -1, 18, 79, 82, 31, -1, + 19, 78, 31, -1, 17, 31, -1, 20, 26, 82, + 31, -1, -1, 58, 41, -1, 14, 83, 81, -1, + 80, -1, 59, 62, 60, -1, -1, 62, 41, -1, + 62, 67, -1, 62, 55, -1, 3, 79, 81, -1, + 4, 79, 31, -1, 64, 76, 74, -1, 80, -1, + 65, 68, 66, -1, -1, 68, 41, -1, 68, 67, + -1, 68, 55, -1, 6, 79, 31, -1, 9, 79, + 31, -1, 70, 74, -1, 12, 31, -1, 72, 13, + -1, -1, 74, 75, -1, 74, 31, -1, 74, 42, + -1, 16, 25, 83, 31, -1, -1, 76, 77, -1, + 76, 31, -1, 23, 82, -1, -1, 79, 82, -1, + 26, -1, 27, -1, 5, 31, -1, 8, 31, -1, + 15, 31, -1, 31, -1, 81, 31, -1, -1, 14, + 83, -1, 84, -1, 84, 34, 84, -1, 84, 28, + 84, -1, 30, 83, 29, -1, 35, 83, -1, 83, + 32, 83, -1, 83, 33, 83, -1, 26, -1, 27, + -1, -1, 26, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 107, 107, 109, 111, 112, 113, 114, 115, 116, - 117, 121, 125, 125, 125, 125, 125, 125, 125, 129, - 130, 131, 132, 133, 134, 138, 139, 145, 153, 159, - 167, 177, 179, 180, 181, 182, 183, 184, 187, 195, - 201, 211, 217, 223, 226, 228, 239, 240, 245, 254, - 259, 267, 270, 272, 273, 274, 275, 276, 279, 285, - 296, 302, 312, 314, 319, 327, 335, 338, 340, 341, - 342, 347, 354, 359, 367, 370, 372, 373, 374, 377, - 385, 392, 399, 405, 412, 414, 415, 416, 419, 427, - 429, 434, 435, 438, 439, 440, 444, 445, 448, 449, - 452, 453, 454, 455, 456, 457, 458, 461, 462, 465, - 466 + 0, 108, 108, 108, 110, 110, 112, 114, 115, 116, + 117, 118, 119, 123, 127, 127, 127, 127, 127, 127, + 127, 127, 131, 132, 133, 134, 135, 136, 140, 141, + 147, 155, 161, 169, 179, 181, 182, 183, 184, 185, + 186, 189, 197, 203, 213, 219, 225, 228, 230, 241, + 242, 247, 256, 261, 269, 272, 274, 275, 276, 277, + 278, 281, 287, 298, 304, 314, 316, 321, 329, 337, + 340, 342, 343, 344, 349, 356, 363, 368, 376, 379, + 381, 382, 383, 386, 394, 401, 408, 414, 421, 423, + 424, 425, 428, 436, 438, 439, 442, 449, 451, 456, + 457, 460, 461, 462, 466, 467, 470, 471, 474, 475, + 476, 477, 478, 479, 480, 483, 484, 487, 488 }; #endif @@ -555,19 +559,19 @@ "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE", - "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", + "T_VISIBLE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL", - "T_NOT", "$accept", "input", "stmt_list", "option_name", "common_stmt", - "option_error", "config_entry_start", "config_stmt", + "T_NOT", "$accept", "input", "start", "stmt_list", "option_name", + "common_stmt", "option_error", "config_entry_start", "config_stmt", "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", "config_option", "symbol_option", "symbol_option_list", "symbol_option_arg", "choice", "choice_entry", "choice_end", "choice_stmt", "choice_option_list", "choice_option", "choice_block", - "if_entry", "if_end", "if_stmt", "if_block", "menu", "menu_entry", - "menu_end", "menu_stmt", "menu_block", "source_stmt", "comment", - "comment_stmt", "help_start", "help", "depends_list", "depends", - "prompt_stmt_opt", "prompt", "end", "nl", "if_expr", "expr", "symbol", - "word_opt", 0 + "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu", + "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt", + "comment", "comment_stmt", "help_start", "help", "depends_list", + "depends", "visibility_list", "visible", "prompt_stmt_opt", "prompt", + "end", "nl", "if_expr", "expr", "symbol", "word_opt", 0 }; #endif @@ -579,42 +583,42 @@ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289 + 285, 286, 287, 288, 289, 290 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 35, 36, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 38, 38, 38, 38, 38, 38, 38, 39, - 39, 39, 39, 39, 39, 40, 40, 41, 42, 43, - 44, 45, 45, 45, 45, 45, 45, 45, 46, 46, - 46, 46, 46, 47, 48, 48, 49, 49, 50, 51, - 52, 53, 54, 54, 54, 54, 54, 54, 55, 55, - 55, 55, 56, 56, 57, 58, 59, 60, 60, 60, - 60, 61, 62, 63, 64, 65, 65, 65, 65, 66, - 67, 68, 69, 70, 71, 71, 71, 71, 72, 73, - 73, 74, 74, 75, 75, 75, 76, 76, 77, 77, - 78, 78, 78, 78, 78, 78, 78, 79, 79, 80, - 80 + 0, 36, 37, 37, 38, 38, 39, 39, 39, 39, + 39, 39, 39, 39, 40, 40, 40, 40, 40, 40, + 40, 40, 41, 41, 41, 41, 41, 41, 42, 42, + 43, 44, 45, 46, 47, 47, 47, 47, 47, 47, + 47, 48, 48, 48, 48, 48, 49, 50, 50, 51, + 51, 52, 53, 54, 55, 56, 56, 56, 56, 56, + 56, 57, 57, 57, 57, 58, 58, 59, 60, 61, + 62, 62, 62, 62, 63, 64, 65, 66, 67, 68, + 68, 68, 68, 69, 70, 71, 72, 73, 74, 74, + 74, 74, 75, 76, 76, 76, 77, 78, 78, 79, + 79, 80, 80, 80, 81, 81, 82, 82, 83, 83, + 83, 83, 83, 83, 83, 84, 84, 85, 85 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 1, 0, 2, 2, 2, 4, 2, 4, - 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 2, 3, 2, 3, - 2, 0, 2, 2, 2, 2, 2, 2, 3, 4, - 4, 4, 5, 3, 0, 3, 0, 2, 3, 2, - 1, 3, 0, 2, 2, 2, 2, 2, 4, 3, - 2, 4, 0, 2, 3, 1, 3, 0, 2, 2, - 2, 3, 2, 1, 3, 0, 2, 2, 2, 3, - 3, 2, 2, 2, 0, 2, 2, 2, 4, 0, - 2, 1, 1, 2, 2, 2, 1, 2, 0, 2, - 1, 3, 3, 3, 2, 3, 3, 1, 1, 0, - 1 + 0, 2, 2, 1, 2, 1, 0, 2, 2, 2, + 2, 4, 4, 3, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, + 3, 2, 3, 2, 0, 2, 2, 2, 2, 2, + 2, 3, 4, 4, 4, 5, 3, 0, 3, 0, + 2, 3, 2, 1, 3, 0, 2, 2, 2, 2, + 2, 4, 3, 2, 4, 0, 2, 3, 1, 3, + 0, 2, 2, 2, 3, 3, 3, 1, 3, 0, + 2, 2, 2, 3, 3, 2, 2, 2, 0, 2, + 2, 2, 4, 0, 2, 2, 2, 0, 2, 1, + 1, 2, 2, 2, 1, 2, 0, 2, 1, 3, + 3, 3, 2, 3, 3, 1, 1, 0, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -622,158 +626,172 @@ means the default is an error. */ static const yytype_uint8 yydefact[] = { - 3, 0, 0, 1, 0, 0, 0, 0, 0, 109, - 0, 0, 0, 0, 0, 0, 12, 16, 13, 14, - 18, 15, 17, 0, 19, 0, 4, 31, 22, 31, - 23, 52, 62, 5, 67, 20, 84, 75, 6, 24, - 84, 21, 8, 11, 91, 92, 0, 0, 93, 0, - 110, 0, 94, 0, 0, 0, 107, 108, 0, 0, - 0, 100, 95, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 96, 7, 71, 79, 48, 80, 27, - 29, 0, 104, 0, 0, 64, 0, 0, 9, 10, - 0, 0, 0, 0, 89, 0, 0, 0, 44, 0, - 37, 36, 32, 33, 0, 35, 34, 0, 0, 89, - 0, 56, 57, 53, 55, 54, 63, 51, 50, 68, - 70, 66, 69, 65, 86, 87, 85, 76, 78, 74, - 77, 73, 97, 103, 105, 106, 102, 101, 26, 82, - 0, 98, 0, 98, 98, 98, 0, 0, 0, 83, - 60, 98, 0, 98, 0, 0, 0, 38, 90, 0, - 0, 98, 46, 43, 25, 0, 59, 0, 88, 99, - 39, 40, 41, 0, 0, 45, 58, 61, 42, 47 + 6, 0, 104, 0, 3, 0, 6, 6, 99, 100, + 0, 1, 0, 0, 0, 0, 117, 0, 0, 0, + 0, 0, 0, 14, 18, 15, 16, 20, 17, 19, + 21, 0, 22, 0, 7, 34, 25, 34, 26, 55, + 65, 8, 70, 23, 93, 79, 9, 27, 88, 24, + 10, 0, 105, 2, 74, 13, 0, 101, 0, 118, + 0, 102, 0, 0, 0, 115, 116, 0, 0, 0, + 108, 103, 0, 0, 0, 0, 0, 0, 0, 88, + 0, 0, 75, 83, 51, 84, 30, 32, 0, 112, + 0, 0, 67, 0, 0, 11, 12, 0, 0, 0, + 0, 97, 0, 0, 0, 47, 0, 40, 39, 35, + 36, 0, 38, 37, 0, 0, 97, 0, 59, 60, + 56, 58, 57, 66, 54, 53, 71, 73, 69, 72, + 68, 106, 95, 0, 94, 80, 82, 78, 81, 77, + 90, 91, 89, 111, 113, 114, 110, 109, 29, 86, + 0, 106, 0, 106, 106, 106, 0, 0, 0, 87, + 63, 106, 0, 106, 0, 96, 0, 0, 41, 98, + 0, 0, 106, 49, 46, 28, 0, 62, 0, 107, + 92, 42, 43, 44, 0, 0, 48, 61, 64, 45, + 50 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 2, 25, 26, 101, 27, 28, 29, 30, - 65, 102, 103, 147, 175, 31, 32, 117, 33, 67, - 113, 68, 34, 121, 35, 69, 36, 37, 129, 38, - 71, 39, 40, 41, 104, 105, 70, 106, 142, 143, - 42, 74, 156, 60, 61, 51 + -1, 3, 4, 5, 33, 34, 108, 35, 36, 37, + 38, 74, 109, 110, 157, 186, 39, 40, 124, 41, + 76, 120, 77, 42, 128, 43, 78, 6, 44, 45, + 137, 46, 80, 47, 48, 49, 111, 112, 81, 113, + 79, 134, 152, 153, 50, 7, 165, 69, 70, 60 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -80 +#define YYPACT_NINF -90 static const yytype_int16 yypact[] = { - -80, 2, 132, -80, -13, -1, -1, -2, -1, 9, - 33, -1, 27, 40, -3, 38, -80, -80, -80, -80, - -80, -80, -80, 71, -80, 77, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, 57, 61, -80, 63, - -80, 76, -80, 87, 101, 133, -80, -80, -3, -3, - 195, -6, -80, 136, 149, 39, 104, 65, 150, 5, - 194, 5, 167, -80, 176, -80, -80, -80, -80, -80, - -80, 68, -80, -3, -3, 176, 72, 72, -80, -80, - 177, 187, 78, -1, -1, -3, 196, 72, -80, 222, - -80, -80, -80, -80, 221, -80, -80, 205, -1, -1, - 211, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, 206, -80, -80, -80, -80, -80, - -3, 223, 209, 223, 197, 223, 72, 7, 210, -80, - -80, 223, 212, 223, 201, -3, 213, -80, -80, 214, - 215, 223, 208, -80, -80, 216, -80, 217, -80, 113, - -80, -80, -80, 218, -1, -80, -80, -80, -80, -80 + 4, 42, -90, 96, -90, 111, -90, 15, -90, -90, + 75, -90, 82, 42, 104, 42, 110, 107, 42, 115, + 125, -4, 121, -90, -90, -90, -90, -90, -90, -90, + -90, 162, -90, 163, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, 139, -90, -90, 138, -90, 142, -90, 143, -90, + 152, -90, 164, 167, 168, -90, -90, -4, -4, 77, + -18, -90, 177, 185, 33, 71, 195, 247, 236, -2, + 236, 171, -90, -90, -90, -90, -90, -90, 41, -90, + -4, -4, 138, 97, 97, -90, -90, 186, 187, 194, + 42, 42, -4, 196, 97, -90, 219, -90, -90, -90, + -90, 210, -90, -90, 204, 42, 42, 199, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, 222, -90, 223, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, 215, -90, -90, -90, -90, -90, + -4, 222, 228, 222, -5, 222, 97, 35, 229, -90, + -90, 222, 232, 222, -4, -90, 135, 233, -90, -90, + 234, 235, 222, 240, -90, -90, 237, -90, 239, -13, + -90, -90, -90, -90, 244, 42, -90, -90, -90, -90, + -90 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -80, -80, -80, -80, 122, -34, -80, -80, -80, -80, - 220, -80, -80, -80, -80, -80, -80, -80, 59, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, 125, - -80, -80, -80, -80, -80, 183, 219, 22, 142, -5, - 147, 192, 69, -54, -79, -80 + -90, -90, 269, 271, -90, 23, -70, -90, -90, -90, + -90, 243, -90, -90, -90, -90, -90, -90, -90, -48, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -20, -90, -90, -90, -90, -90, 206, 205, -68, + -90, -90, 169, -1, 27, -7, 118, -66, -89, -90 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -82 +#define YYTABLE_NINF -86 static const yytype_int16 yytable[] = { - 46, 47, 3, 49, 81, 82, 53, 136, 137, 6, - 7, 8, 9, 10, 11, 12, 13, 43, 146, 14, - 15, 86, 56, 57, 44, 45, 58, 87, 48, 134, - 135, 59, 162, 112, 50, 24, 125, 163, 125, -28, - 90, 144, -28, -28, -28, -28, -28, -28, -28, -28, - -28, 91, 54, -28, -28, 92, -28, 93, 94, 95, - 96, 97, 98, 52, 99, 55, 90, 161, 62, 100, - -49, -49, 63, -49, -49, -49, -49, 91, 64, -49, - -49, 92, 107, 108, 109, 110, 154, 73, 141, 115, - 99, 75, 126, 76, 126, 111, 133, 56, 57, 83, - 84, 169, 140, 151, -30, 90, 77, -30, -30, -30, - -30, -30, -30, -30, -30, -30, 91, 78, -30, -30, - 92, -30, 93, 94, 95, 96, 97, 98, 120, 99, - 128, 79, -2, 4, 100, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 83, 84, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 7, 8, 23, 10, 11, - 12, 13, 24, 80, 14, 15, 88, -81, 90, 179, - -81, -81, -81, -81, -81, -81, -81, -81, -81, 89, - 24, -81, -81, 92, -81, -81, -81, -81, -81, -81, - 116, 119, 99, 127, 122, 90, 130, 124, -72, -72, - -72, -72, -72, -72, -72, -72, 132, 138, -72, -72, - 92, 155, 158, 159, 160, 118, 123, 139, 131, 99, - 165, 145, 167, 148, 124, 73, 83, 84, 83, 84, - 173, 168, 83, 84, 149, 150, 153, 155, 84, 157, - 164, 174, 166, 170, 171, 172, 176, 177, 178, 66, - 114, 152, 85, 0, 0, 0, 0, 0, 0, 72 + 10, 88, 89, 54, 146, 147, 119, 1, 122, 164, + 93, 141, 56, 142, 58, 156, 94, 62, 1, 90, + 91, 131, 65, 66, 144, 145, 67, 90, 91, 132, + 127, 68, 136, -31, 97, 2, 154, -31, -31, -31, + -31, -31, -31, -31, -31, 98, 52, -31, -31, 99, + -31, 100, 101, 102, 103, 104, -31, 105, 129, 106, + 138, 173, 92, 141, 107, 142, 174, 172, 8, 9, + 143, -33, 97, 90, 91, -33, -33, -33, -33, -33, + -33, -33, -33, 98, 166, -33, -33, 99, -33, 100, + 101, 102, 103, 104, -33, 105, 11, 106, 179, 151, + 123, 126, 107, 135, 125, 130, 2, 139, 2, 90, + 91, -5, 12, 55, 161, 13, 14, 15, 16, 17, + 18, 19, 20, 65, 66, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 57, 59, 31, 61, -4, + 12, 63, 32, 13, 14, 15, 16, 17, 18, 19, + 20, 64, 71, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 72, 73, 31, 180, 90, 91, 52, + 32, -85, 97, 82, 83, -85, -85, -85, -85, -85, + -85, -85, -85, 84, 190, -85, -85, 99, -85, -85, + -85, -85, -85, -85, -85, 85, 97, 106, 86, 87, + -52, -52, 140, -52, -52, -52, -52, 98, 95, -52, + -52, 99, 114, 115, 116, 117, 96, 148, 149, 150, + 158, 106, 155, 159, 97, 163, 118, -76, -76, -76, + -76, -76, -76, -76, -76, 160, 164, -76, -76, 99, + 13, 14, 15, 16, 17, 18, 19, 20, 91, 106, + 21, 22, 14, 15, 140, 17, 18, 19, 20, 168, + 175, 21, 22, 177, 181, 182, 183, 32, 187, 167, + 188, 169, 170, 171, 185, 189, 53, 51, 32, 176, + 75, 178, 121, 0, 133, 162, 0, 0, 0, 0, + 184 }; static const yytype_int16 yycheck[] = { - 5, 6, 0, 8, 58, 59, 11, 86, 87, 4, - 5, 6, 7, 8, 9, 10, 11, 30, 97, 14, - 15, 27, 25, 26, 25, 26, 29, 33, 30, 83, - 84, 34, 25, 67, 25, 30, 70, 30, 72, 0, - 1, 95, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 25, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 30, 25, 25, 1, 146, 30, 30, - 5, 6, 1, 8, 9, 10, 11, 12, 1, 14, - 15, 16, 17, 18, 19, 20, 140, 30, 93, 67, - 25, 30, 70, 30, 72, 30, 28, 25, 26, 31, - 32, 155, 24, 108, 0, 1, 30, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 30, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 69, 25, - 71, 30, 0, 1, 30, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 31, 32, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 5, 6, 25, 8, 9, - 10, 11, 30, 30, 14, 15, 30, 0, 1, 174, - 3, 4, 5, 6, 7, 8, 9, 10, 11, 30, - 30, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 68, 69, 25, 71, 69, 1, 71, 30, 4, 5, - 6, 7, 8, 9, 10, 11, 30, 30, 14, 15, - 16, 14, 143, 144, 145, 68, 69, 30, 71, 25, - 151, 25, 153, 1, 30, 30, 31, 32, 31, 32, - 161, 30, 31, 32, 13, 30, 25, 14, 32, 30, - 30, 33, 30, 30, 30, 30, 30, 30, 30, 29, - 67, 109, 60, -1, -1, -1, -1, -1, -1, 40 + 1, 67, 68, 10, 93, 94, 76, 3, 76, 14, + 28, 81, 13, 81, 15, 104, 34, 18, 3, 32, + 33, 23, 26, 27, 90, 91, 30, 32, 33, 31, + 78, 35, 80, 0, 1, 31, 102, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 31, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 78, 26, + 80, 26, 69, 133, 31, 133, 31, 156, 26, 27, + 29, 0, 1, 32, 33, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 150, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 0, 26, 164, 100, + 77, 78, 31, 80, 77, 78, 31, 80, 31, 32, + 33, 0, 1, 31, 115, 4, 5, 6, 7, 8, + 9, 10, 11, 26, 27, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 31, 26, 26, 31, 0, + 1, 26, 31, 4, 5, 6, 7, 8, 9, 10, + 11, 26, 31, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 1, 1, 26, 31, 32, 33, 31, + 31, 0, 1, 31, 31, 4, 5, 6, 7, 8, + 9, 10, 11, 31, 185, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 31, 1, 26, 31, 31, + 5, 6, 31, 8, 9, 10, 11, 12, 31, 14, + 15, 16, 17, 18, 19, 20, 31, 31, 31, 25, + 1, 26, 26, 13, 1, 26, 31, 4, 5, 6, + 7, 8, 9, 10, 11, 31, 14, 14, 15, 16, + 4, 5, 6, 7, 8, 9, 10, 11, 33, 26, + 14, 15, 5, 6, 31, 8, 9, 10, 11, 31, + 31, 14, 15, 31, 31, 31, 31, 31, 31, 151, + 31, 153, 154, 155, 34, 31, 7, 6, 31, 161, + 37, 163, 76, -1, 79, 116, -1, -1, -1, -1, + 172 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 36, 37, 0, 1, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 25, 30, 38, 39, 41, 42, 43, - 44, 50, 51, 53, 57, 59, 61, 62, 64, 66, - 67, 68, 75, 30, 25, 26, 74, 74, 30, 74, - 25, 80, 30, 74, 25, 25, 25, 26, 29, 34, - 78, 79, 30, 1, 1, 45, 45, 54, 56, 60, - 71, 65, 71, 30, 76, 30, 30, 30, 30, 30, - 30, 78, 78, 31, 32, 76, 27, 33, 30, 30, - 1, 12, 16, 18, 19, 20, 21, 22, 23, 25, - 30, 40, 46, 47, 69, 70, 72, 17, 18, 19, - 20, 30, 40, 55, 70, 72, 39, 52, 75, 39, - 53, 58, 64, 75, 30, 40, 72, 39, 53, 63, - 64, 75, 30, 28, 78, 78, 79, 79, 30, 30, - 24, 74, 73, 74, 78, 25, 79, 48, 1, 13, - 30, 74, 73, 25, 78, 14, 77, 30, 77, 77, - 77, 79, 25, 30, 30, 77, 30, 77, 30, 78, - 30, 30, 30, 77, 33, 49, 30, 30, 30, 74 + 0, 3, 31, 37, 38, 39, 63, 81, 26, 27, + 79, 0, 1, 4, 5, 6, 7, 8, 9, 10, + 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 26, 31, 40, 41, 43, 44, 45, 46, 52, + 53, 55, 59, 61, 64, 65, 67, 69, 70, 71, + 80, 39, 31, 38, 81, 31, 79, 31, 79, 26, + 85, 31, 79, 26, 26, 26, 27, 30, 35, 83, + 84, 31, 1, 1, 47, 47, 56, 58, 62, 76, + 68, 74, 31, 31, 31, 31, 31, 31, 83, 83, + 32, 33, 81, 28, 34, 31, 31, 1, 12, 16, + 18, 19, 20, 21, 22, 24, 26, 31, 42, 48, + 49, 72, 73, 75, 17, 18, 19, 20, 31, 42, + 57, 73, 75, 41, 54, 80, 41, 55, 60, 67, + 80, 23, 31, 74, 77, 41, 55, 66, 67, 80, + 31, 42, 75, 29, 83, 83, 84, 84, 31, 31, + 25, 79, 78, 79, 83, 26, 84, 50, 1, 13, + 31, 79, 78, 26, 14, 82, 83, 82, 31, 82, + 82, 82, 84, 26, 31, 31, 82, 31, 82, 83, + 31, 31, 31, 31, 82, 34, 51, 31, 31, 31, + 79 }; #define yyerrok (yyerrstatus = 0) @@ -1284,7 +1302,7 @@ switch (yytype) { - case 51: /* "choice_entry" */ + case 53: /* "choice_entry" */ { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -1294,7 +1312,7 @@ }; break; - case 57: /* "if_entry" */ + case 59: /* "if_entry" */ { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -1304,7 +1322,7 @@ }; break; - case 62: /* "menu_entry" */ + case 65: /* "menu_entry" */ { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -1614,39 +1632,39 @@ YY_REDUCE_PRINT (yyn); switch (yyn) { - case 8: + case 10: { zconf_error("unexpected end statement"); ;} break; - case 9: + case 11: { zconf_error("unknown statement \"%s\"", (yyvsp[(2) - (4)].string)); ;} break; - case 10: + case 12: { zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[(2) - (4)].id)->name); ;} break; - case 11: + case 13: { zconf_error("invalid statement"); ;} break; - case 25: + case 28: { zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); ;} break; - case 26: + case 29: { zconf_error("invalid option"); ;} break; - case 27: + case 30: { struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0); @@ -1656,7 +1674,7 @@ ;} break; - case 28: + case 31: { menu_end_entry(); @@ -1664,7 +1682,7 @@ ;} break; - case 29: + case 32: { struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0); @@ -1674,7 +1692,7 @@ ;} break; - case 30: + case 33: { if (current_entry->prompt) @@ -1686,7 +1704,7 @@ ;} break; - case 38: + case 41: { menu_set_type((yyvsp[(1) - (3)].id)->stype); @@ -1696,7 +1714,7 @@ ;} break; - case 39: + case 42: { menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); @@ -1704,7 +1722,7 @@ ;} break; - case 40: + case 43: { menu_add_expr(P_DEFAULT, (yyvsp[(2) - (4)].expr), (yyvsp[(3) - (4)].expr)); @@ -1716,7 +1734,7 @@ ;} break; - case 41: + case 44: { menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr)); @@ -1724,7 +1742,7 @@ ;} break; - case 42: + case 45: { menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr)); @@ -1732,7 +1750,7 @@ ;} break; - case 45: + case 48: { struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string))); @@ -1744,17 +1762,17 @@ ;} break; - case 46: + case 49: { (yyval.string) = NULL; ;} break; - case 47: + case 50: { (yyval.string) = (yyvsp[(2) - (2)].string); ;} break; - case 48: + case 51: { struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), SYMBOL_CHOICE); @@ -1765,14 +1783,14 @@ ;} break; - case 49: + case 52: { (yyval.menu) = menu_add_menu(); ;} break; - case 50: + case 53: { if (zconf_endtoken((yyvsp[(1) - (1)].id), T_CHOICE, T_ENDCHOICE)) { @@ -1782,7 +1800,7 @@ ;} break; - case 58: + case 61: { menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); @@ -1790,7 +1808,7 @@ ;} break; - case 59: + case 62: { if ((yyvsp[(1) - (3)].id)->stype == S_BOOLEAN || (yyvsp[(1) - (3)].id)->stype == S_TRISTATE) { @@ -1803,7 +1821,7 @@ ;} break; - case 60: + case 63: { current_entry->sym->flags |= SYMBOL_OPTIONAL; @@ -1811,7 +1829,7 @@ ;} break; - case 61: + case 64: { if ((yyvsp[(1) - (4)].id)->stype == S_UNKNOWN) { @@ -1823,7 +1841,7 @@ ;} break; - case 64: + case 67: { printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); @@ -1833,7 +1851,7 @@ ;} break; - case 65: + case 68: { if (zconf_endtoken((yyvsp[(1) - (1)].id), T_IF, T_ENDIF)) { @@ -1843,7 +1861,14 @@ ;} break; - case 71: + case 74: + + { + menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL); +;} + break; + + case 75: { menu_add_entry(NULL); @@ -1852,14 +1877,14 @@ ;} break; - case 72: + case 76: { (yyval.menu) = menu_add_menu(); ;} break; - case 73: + case 77: { if (zconf_endtoken((yyvsp[(1) - (1)].id), T_MENU, T_ENDMENU)) { @@ -1869,7 +1894,7 @@ ;} break; - case 79: + case 83: { printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); @@ -1877,7 +1902,7 @@ ;} break; - case 80: + case 84: { menu_add_entry(NULL); @@ -1886,14 +1911,14 @@ ;} break; - case 81: + case 85: { menu_end_entry(); ;} break; - case 82: + case 86: { printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); @@ -1901,14 +1926,14 @@ ;} break; - case 83: + case 87: { current_entry->help = (yyvsp[(2) - (2)].string); ;} break; - case 88: + case 92: { menu_add_dep((yyvsp[(3) - (4)].expr)); @@ -1916,85 +1941,92 @@ ;} break; - case 90: + case 96: + + { + menu_add_visibility((yyvsp[(2) - (2)].expr)); +;} + break; + + case 98: { menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr)); ;} break; - case 93: - - { (yyval.id) = (yyvsp[(1) - (2)].id); ;} - break; - - case 94: - - { (yyval.id) = (yyvsp[(1) - (2)].id); ;} - break; - - case 95: - - { (yyval.id) = (yyvsp[(1) - (2)].id); ;} - break; - - case 98: - - { (yyval.expr) = NULL; ;} - break; - - case 99: - - { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} - break; - - case 100: - - { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;} - break; - case 101: - { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} + { (yyval.id) = (yyvsp[(1) - (2)].id); ;} break; case 102: - { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} + { (yyval.id) = (yyvsp[(1) - (2)].id); ;} break; case 103: - { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} - break; - - case 104: - - { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;} - break; - - case 105: - - { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.id) = (yyvsp[(1) - (2)].id); ;} break; case 106: - { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + { (yyval.expr) = NULL; ;} break; case 107: - { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;} + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} break; case 108: - { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;} + { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;} break; case 109: + { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} + break; + + case 110: + + { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} + break; + + case 111: + + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 112: + + { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;} + break; + + case 113: + + { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 114: + + { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 115: + + { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;} + break; + + case 116: + + { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;} + break; + + case 117: + { (yyval.string) = NULL; ;} break; @@ -2239,6 +2271,10 @@ prop = prop_alloc(P_DEFAULT, modules_sym); prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0)); } + + rootmenu.prompt->text = _(rootmenu.prompt->text); + rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); + menu_finalize(&rootmenu); for_all_symbols(i, sym) { if (sym_check_deps(sym)) @@ -2259,6 +2295,7 @@ case T_IF: return "if"; case T_ENDIF: return "endif"; case T_DEPENDS: return "depends"; + case T_VISIBLE: return "visible"; } return ""; } diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 23dfd3b..49fb4ab 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -36,7 +36,7 @@ #define YYERROR_VERBOSE #endif %} -%expect 26 +%expect 30 %union { @@ -68,6 +68,7 @@ %token T_DEFAULT %token T_SELECT %token T_RANGE +%token T_VISIBLE %token T_OPTION %token T_ON %token T_WORD @@ -104,14 +105,15 @@ %} %% -input: stmt_list; +input: nl start | start; + +start: mainmenu_stmt stmt_list | stmt_list; stmt_list: /* empty */ | stmt_list common_stmt | stmt_list choice_stmt | stmt_list menu_stmt - | stmt_list T_MAINMENU prompt nl | stmt_list end { zconf_error("unexpected end statement"); } | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } | stmt_list option_name error T_EOL @@ -122,7 +124,7 @@ ; option_name: - T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT + T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE ; common_stmt: @@ -342,6 +344,13 @@ | if_block choice_stmt ; +/* mainmenu entry */ + +mainmenu_stmt: T_MAINMENU prompt nl +{ + menu_add_prompt(P_MENU, $2, NULL); +}; + /* menu entry */ menu: T_MENU prompt T_EOL @@ -351,7 +360,7 @@ printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); }; -menu_entry: menu depends_list +menu_entry: menu visibility_list depends_list { $$ = menu_add_menu(); }; @@ -422,6 +431,19 @@ printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); }; +/* visibility option */ + +visibility_list: + /* empty */ + | visibility_list visible + | visibility_list T_EOL +; + +visible: T_VISIBLE if_expr +{ + menu_add_visibility($2); +}; + /* prompt statement */ prompt_stmt_opt: @@ -494,6 +516,10 @@ prop = prop_alloc(P_DEFAULT, modules_sym); prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0)); } + + rootmenu.prompt->text = _(rootmenu.prompt->text); + rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); + menu_finalize(&rootmenu); for_all_symbols(i, sym) { if (sym_check_deps(sym)) @@ -514,6 +540,7 @@ case T_IF: return "if"; case T_ENDIF: return "endif"; case T_DEPENDS: return "depends"; + case T_VISIBLE: return "visible"; } return ""; } diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 4075c35..08b75b6 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1317,7 +1317,7 @@ { if (buf->size - buf->pos < len) { buf->size += len + SZ; - buf->p = realloc(buf->p, buf->size); + buf->p = NOFAIL(realloc(buf->p, buf->size)); } strncpy(buf->p + buf->pos, s, len); buf->pos += len;