summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Kconfig6
-rw-r--r--arch/arm/boards/at91sam9260ek/init.c2
-rw-r--r--arch/arm/boards/at91sam9261ek/init.c2
-rw-r--r--arch/arm/boards/at91sam9263ek/init.c2
-rw-r--r--arch/arm/boards/beagle/board.c2
-rw-r--r--arch/arm/boards/chumby_falconwing/falconwing.c2
-rw-r--r--arch/arm/boards/crystalfontz-cfa10036/env/init/automount2
-rw-r--r--arch/arm/boards/edb93xx/edb93xx.c2
-rw-r--r--arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c8
-rw-r--r--arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c4
-rw-r--r--arch/arm/boards/freescale-mx25-3-stack/3stack.c2
-rw-r--r--arch/arm/boards/freescale-mx35-3-stack/3stack.c2
-rw-r--r--arch/arm/boards/friendlyarm-tiny210/tiny210.c2
-rw-r--r--arch/arm/boards/guf-neso/board.c2
-rw-r--r--arch/arm/boards/imx21ads/imx21ads.c2
-rw-r--r--arch/arm/boards/imx27ads/imx27ads.c2
-rw-r--r--arch/arm/boards/mioa701/board.c2
-rw-r--r--arch/arm/boards/mioa701/env/bin/sdcard_override2
-rw-r--r--arch/arm/boards/netx/netx.c2
-rw-r--r--arch/arm/boards/nhk8815/setup.c2
-rw-r--r--arch/arm/boards/omap343xdsp/board.c2
-rw-r--r--arch/arm/boards/panda/board.c2
-rw-r--r--arch/arm/boards/pcm038/pcm038.c2
-rw-r--r--arch/arm/boards/pcm038/pcm970.c4
-rw-r--r--arch/arm/boards/pcm043/pcm043.c2
-rw-r--r--arch/arm/boards/pcm049/env/bin/nand_bootstrap2
-rw-r--r--arch/arm/boards/phycard-a-l1/pca-a-l1.c2
-rw-r--r--arch/arm/boards/phycard-a-xl2/env/bin/nand_bootstrap2
-rw-r--r--arch/arm/boards/phycard-a-xl2/pca-a-xl2.c4
-rw-r--r--arch/arm/boards/phycard-i.MX27/pca100.c4
-rw-r--r--arch/arm/boards/qil-a9260/init.c12
-rw-r--r--arch/arm/boards/scb9328/scb9328.c4
-rw-r--r--arch/arm/boards/tny-a926x/init.c4
-rw-r--r--arch/arm/boards/toshiba-ac100/serial.c2
-rw-r--r--arch/arm/boards/usb-a926x/init.c10
-rw-r--r--arch/arm/boards/versatile/versatilepb.c2
-rw-r--r--arch/arm/include/asm/barebox-arm-head.h4
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c4
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c4
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c4
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9_sdramc.h28
-rw-r--r--arch/arm/mach-at91/include/mach/barebox-arm-head.h33
-rw-r--r--arch/arm/mach-at91/include/mach/debug_ll.h37
-rw-r--r--arch/arm/mach-imx/gpio.c94
-rw-r--r--arch/arm/mach-imx/gpio.h4
-rw-r--r--arch/arm/mach-imx/imx1.c21
-rw-r--r--arch/arm/mach-imx/imx21.c23
-rw-r--r--arch/arm/mach-imx/imx25.c15
-rw-r--r--arch/arm/mach-imx/imx27.c19
-rw-r--r--arch/arm/mach-imx/imx31.c14
-rw-r--r--arch/arm/mach-imx/imx35.c14
-rw-r--r--arch/arm/mach-imx/imx51.c16
-rw-r--r--arch/arm/mach-imx/imx53.c21
-rw-r--r--arch/arm/mach-imx/imx6.c28
-rw-r--r--arch/arm/mach-mxs/bcb.c2
-rw-r--r--arch/blackfin/include/asm/unaligned.h11
-rw-r--r--arch/mips/boards/dlink-dir-320/serial.c2
-rw-r--r--arch/mips/boards/qemu-malta/init.c2
-rw-r--r--arch/mips/boards/rzx50/serial.c2
-rw-r--r--arch/nios2/boards/generic/generic.c2
-rw-r--r--arch/openrisc/boards/generic/generic.c2
-rw-r--r--arch/openrisc/include/asm/unaligned.h51
-rw-r--r--arch/ppc/boards/freescale-p2020rdb/p2020rdb.c4
-rw-r--r--arch/ppc/include/asm/unaligned.h16
-rw-r--r--arch/x86/boards/x86_generic/generic_pc.c2
-rw-r--r--commands/mount.c18
-rw-r--r--common/command.c20
-rw-r--r--common/filetype.c20
-rw-r--r--common/hush.c45
-rw-r--r--defaultenv-2/base/init/automount6
-rw-r--r--drivers/Kconfig1
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/gpio/Kconfig13
-rw-r--r--drivers/gpio/Makefile2
-rw-r--r--drivers/gpio/gpio-stmpe.c161
-rw-r--r--drivers/gpio/gpio.c134
-rw-r--r--drivers/mfd/Kconfig4
-rw-r--r--drivers/mfd/Makefile1
-rw-r--r--drivers/mfd/stmpe-i2c.c153
-rw-r--r--fs/Kconfig5
-rw-r--r--fs/fat/fat.c1
-rw-r--r--fs/fs.c30
-rw-r--r--include/driver.h4
-rw-r--r--include/filetype.h1
-rw-r--r--include/fs.h5
-rw-r--r--include/gpio.h27
-rw-r--r--include/mfd/stmpe-i2c.h53
88 files changed, 1052 insertions, 246 deletions
diff --git a/Makefile b/Makefile
index 969afbb173..5baa8c424a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
VERSION = 2012
-PATCHLEVEL = 08
+PATCHLEVEL = 09
SUBLEVEL = 0
EXTRAVERSION =
NAME = Amissive Actinocutious Kiwi
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 08c742bfb3..904c02d0fb 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -14,6 +14,9 @@ config ARM_LINUX
default y
depends on CMD_BOOTZ || CMD_BOOTU || CMD_BOOTM
+config HAVE_MACH_ARM_HEAD
+ bool
+
menu "System Type "
choice
@@ -23,6 +26,8 @@ config ARCH_AT91
bool "Atmel AT91"
select GENERIC_GPIO
select CLKDEV_LOOKUP
+ select HAS_DEBUG_LL
+ select HAVE_MACH_ARM_HEAD
config ARCH_EP93XX
bool "Cirrus Logic EP93xx"
@@ -32,6 +37,7 @@ config ARCH_EP93XX
config ARCH_IMX
bool "Freescale iMX-based"
select GENERIC_GPIO
+ select GPIOLIB
config ARCH_MXS
bool "Freescale i.MX23/28 (mxs) based"
diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
index daadf9489f..826f00e353 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -234,7 +234,7 @@ static void __init ek_add_led(void)
static int at91sam9260ek_mem_init(void)
{
- at91_add_device_sdram(64 * 1024 * 1024);
+ at91_add_device_sdram(0);
return 0;
}
diff --git a/arch/arm/boards/at91sam9261ek/init.c b/arch/arm/boards/at91sam9261ek/init.c
index b0cab5b0e6..5abe87c966 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/init.c
@@ -236,7 +236,7 @@ static void ek_device_add_leds(void) {}
static int at91sam9261ek_mem_init(void)
{
- at91_add_device_sdram(64 * 1024 * 1024);
+ at91_add_device_sdram(0);
return 0;
}
diff --git a/arch/arm/boards/at91sam9263ek/init.c b/arch/arm/boards/at91sam9263ek/init.c
index 68f4bfc3f1..573fac4562 100644
--- a/arch/arm/boards/at91sam9263ek/init.c
+++ b/arch/arm/boards/at91sam9263ek/init.c
@@ -166,7 +166,7 @@ static void __init ek_add_device_buttons(void)
static int at91sam9263ek_mem_init(void)
{
- at91_add_device_sdram(64 * 1024 * 1024);
+ at91_add_device_sdram(0);
return 0;
}
diff --git a/arch/arm/boards/beagle/board.c b/arch/arm/boards/beagle/board.c
index 9ddf3172f2..04a6611314 100644
--- a/arch/arm/boards/beagle/board.c
+++ b/arch/arm/boards/beagle/board.c
@@ -253,7 +253,7 @@ static struct NS16550_plat serial_plat = {
static int beagle_console_init(void)
{
/* Register the serial port */
- add_ns16550_device(-1, OMAP_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
+ add_ns16550_device(DEVICE_ID_DYNAMIC, OMAP_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
&serial_plat);
return 0;
diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c
index b40713d33b..60d1f6283c 100644
--- a/arch/arm/boards/chumby_falconwing/falconwing.c
+++ b/arch/arm/boards/chumby_falconwing/falconwing.c
@@ -318,7 +318,7 @@ static void falconwing_init_usb(void)
imx23_usb_phy_enable();
- add_generic_usb_ehci_device(-1, IMX_USB_BASE, NULL);
+ add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_USB_BASE, NULL);
}
static int falconwing_devices_init(void)
diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/init/automount b/arch/arm/boards/crystalfontz-cfa10036/env/init/automount
index fe67e55c5a..668775d89b 100644
--- a/arch/arm/boards/crystalfontz-cfa10036/env/init/automount
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/init/automount
@@ -6,4 +6,4 @@ if [ "$1" = menu ]; then
fi
mkdir -p /mnt/disk0.1
-automount -d /mnt/disk0.1 '[ -e /dev/disk0.1 ] && mount /dev/disk0.1 fat /mnt/disk0.1'
+automount -d /mnt/disk0.1 '[ -e /dev/disk0.1 ] && mount /dev/disk0.1 /mnt/disk0.1'
diff --git a/arch/arm/boards/edb93xx/edb93xx.c b/arch/arm/boards/edb93xx/edb93xx.c
index d32daf4923..3de4d4965e 100644
--- a/arch/arm/boards/edb93xx/edb93xx.c
+++ b/arch/arm/boards/edb93xx/edb93xx.c
@@ -57,7 +57,7 @@ mem_initcall(ep93xx_mem_init);
static int ep93xx_devices_init(void)
{
- add_cfi_flash_device(-1, 0x60000000, EDB93XX_CFI_FLASH_SIZE, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, 0x60000000, EDB93XX_CFI_FLASH_SIZE, 0);
/*
* Create partitions that should be
diff --git a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
index 193c277561..10466ba117 100644
--- a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -191,9 +191,9 @@ static int eukrea_cpuimx27_devices_init(void)
for (i = 0; i < ARRAY_SIZE(mode); i++)
imx_gpio_mode(mode[i]);
- add_cfi_flash_device(-1, 0xC0000000, 32 * 1024 * 1024, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, 0xC0000000, 32 * 1024 * 1024, 0);
#ifdef CONFIG_EUKREA_CPUIMX27_NOR_64MB
- add_cfi_flash_device(-1, 0xC2000000, 32 * 1024 * 1024, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, 0xC2000000, 32 * 1024 * 1024, 0);
#endif
imx27_add_nand(&nand_info);
@@ -227,13 +227,13 @@ device_initcall(eukrea_cpuimx27_devices_init);
static int eukrea_cpuimx27_console_init(void)
{
#ifdef CONFIG_DRIVER_SERIAL_IMX
- imx_add_uart((void *)IMX_UART1_BASE, -1);
+ imx_add_uart((void *)IMX_UART1_BASE, DEVICE_ID_DYNAMIC);
#endif
/* configure 8 bit UART on cs3 */
FMCR &= ~0x2;
imx27_setup_weimcs(3, 0x0000D603, 0x0D1D0D01, 0x00D20000);
#ifdef CONFIG_DRIVER_SERIAL_NS16550
- add_ns16550_device(-1, IMX_CS3_BASE + QUART_OFFSET, 0xf,
+ add_ns16550_device(DEVICE_ID_DYNAMIC, IMX_CS3_BASE + QUART_OFFSET, 0xf,
IORESOURCE_MEM_16BIT, &quad_uart_serial_plat);
#endif
return 0;
diff --git a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
index 49dbabc491..e657e77e51 100644
--- a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
+++ b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
@@ -220,13 +220,13 @@ static int eukrea_cpuimx35_devices_init(void)
#ifdef CONFIG_USB
imx35_usb_init();
- add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+ add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_OTG_BASE + 0x400, NULL);
#endif
#ifdef CONFIG_USB_GADGET
/* Workaround ENGcm09152 */
tmp = readl(IMX_OTG_BASE + 0x608);
writel(tmp | (1 << 23), IMX_OTG_BASE + 0x608);
- add_generic_device("fsl-udc", -1, NULL, IMX_OTG_BASE, 0x200,
+ add_generic_device("fsl-udc", DEVICE_ID_DYNAMIC, NULL, IMX_OTG_BASE, 0x200,
IORESOURCE_MEM, &usb_pdata);
#endif
armlinux_set_bootparams((void *)0x80000100);
diff --git a/arch/arm/boards/freescale-mx25-3-stack/3stack.c b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
index 97c1fd9427..f6162fd279 100644
--- a/arch/arm/boards/freescale-mx25-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
@@ -213,7 +213,7 @@ static int imx25_devices_init(void)
* the CPLD has to be initialized.
*/
imx25_usb_init();
- add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+ add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_OTG_BASE + 0x400, NULL);
#endif
imx25_iim_register_fec_ethaddr();
diff --git a/arch/arm/boards/freescale-mx35-3-stack/3stack.c b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
index 9b255a55fa..c71e668c93 100644
--- a/arch/arm/boards/freescale-mx35-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
@@ -159,7 +159,7 @@ static int f3s_devices_init(void)
* This platform supports NOR and NAND
*/
imx35_add_nand(&nand_info);
- add_cfi_flash_device(-1, IMX_CS0_BASE, 64 * 1024 * 1024, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, IMX_CS0_BASE, 64 * 1024 * 1024, 0);
switch ((reg >> 25) & 0x3) {
case 0x01: /* NAND is the source */
diff --git a/arch/arm/boards/friendlyarm-tiny210/tiny210.c b/arch/arm/boards/friendlyarm-tiny210/tiny210.c
index 1277649373..18494b0517 100644
--- a/arch/arm/boards/friendlyarm-tiny210/tiny210.c
+++ b/arch/arm/boards/friendlyarm-tiny210/tiny210.c
@@ -86,7 +86,7 @@ static int tiny210_console_init(void)
s3c_gpio_mode(GPA02_NCTS0 | ENABLE_PU);
s3c_gpio_mode(GPA03_NRTS0);
- add_generic_device("s3c_serial", -1, NULL,
+ add_generic_device("s3c_serial", DEVICE_ID_DYNAMIC, NULL,
S3C_UART1_BASE, S3C_UART1_SIZE,
IORESOURCE_MEM, NULL);
return 0;
diff --git a/arch/arm/boards/guf-neso/board.c b/arch/arm/boards/guf-neso/board.c
index fbb20c10e0..623dc0ad4e 100644
--- a/arch/arm/boards/guf-neso/board.c
+++ b/arch/arm/boards/guf-neso/board.c
@@ -280,7 +280,7 @@ static int neso_devices_init(void)
#ifdef CONFIG_USB
neso_usbh_init();
- add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+ add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_OTG_BASE + 0x400, NULL);
#endif
imx27_add_fec(&fec_info);
diff --git a/arch/arm/boards/imx21ads/imx21ads.c b/arch/arm/boards/imx21ads/imx21ads.c
index 2bbd5ede25..58086bca11 100644
--- a/arch/arm/boards/imx21ads/imx21ads.c
+++ b/arch/arm/boards/imx21ads/imx21ads.c
@@ -167,7 +167,7 @@ static int mx21ads_devices_init(void)
for (i = 0; i < ARRAY_SIZE(mode); i++)
imx_gpio_mode(mode[i]);
- add_cfi_flash_device(-1, 0xC8000000, 32 * 1024 * 1024, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, 0xC8000000, 32 * 1024 * 1024, 0);
imx21_add_nand(&nand_info);
add_generic_device("cs8900", DEVICE_ID_DYNAMIC, NULL, IMX_CS1_BASE, 0x1000,
IORESOURCE_MEM, NULL);
diff --git a/arch/arm/boards/imx27ads/imx27ads.c b/arch/arm/boards/imx27ads/imx27ads.c
index ff002249de..6b0fc724d8 100644
--- a/arch/arm/boards/imx27ads/imx27ads.c
+++ b/arch/arm/boards/imx27ads/imx27ads.c
@@ -108,7 +108,7 @@ static int mx27ads_devices_init(void)
for (i = 0; i < ARRAY_SIZE(mode); i++)
imx_gpio_mode(mode[i]);
- add_cfi_flash_device(-1, 0xC0000000, 32 * 1024 * 1024, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, 0xC0000000, 32 * 1024 * 1024, 0);
imx27_add_fec(&fec_info);
devfs_add_partition("nor0", 0x00000, 0x20000, DEVFS_PARTITION_FIXED, "self0");
diff --git a/arch/arm/boards/mioa701/board.c b/arch/arm/boards/mioa701/board.c
index ab5a493e76..b5c05a6eea 100644
--- a/arch/arm/boards/mioa701/board.c
+++ b/arch/arm/boards/mioa701/board.c
@@ -121,7 +121,7 @@ static int mioa701_devices_init(void)
pxa_add_pwm((void *)0x40b00000, 0);
pxa_add_fb((void *)0x44000000, &mioa701_pxafb_info);
- pxa_add_mmc((void *)0x41100000, -1, &mioa701_mmc_info);
+ pxa_add_mmc((void *)0x41100000, DEVICE_ID_DYNAMIC, &mioa701_mmc_info);
docg3_iospace = map_io_sections(0x0, (void *)0xe0000000, 0x2000);
add_generic_device("docg3", DEVICE_ID_DYNAMIC, NULL, (ulong) docg3_iospace,
0x2000, IORESOURCE_MEM, NULL);
diff --git a/arch/arm/boards/mioa701/env/bin/sdcard_override b/arch/arm/boards/mioa701/env/bin/sdcard_override
index 4b2ad51343..ab83534135 100644
--- a/arch/arm/boards/mioa701/env/bin/sdcard_override
+++ b/arch/arm/boards/mioa701/env/bin/sdcard_override
@@ -8,7 +8,7 @@
mci0.probe=1
if [ $mci0.probe = 1 ]; then
mkdir /sdcard
- mount /dev/disk0.0 fat /sdcard
+ mount /dev/disk0.0 /sdcard
if [ -f /sdcard/barebox.env ]; then
loadenv /sdcard/barebox.env /env.sd
/env.sd/bin/init
diff --git a/arch/arm/boards/netx/netx.c b/arch/arm/boards/netx/netx.c
index c4a8733aad..fde1b9416a 100644
--- a/arch/arm/boards/netx/netx.c
+++ b/arch/arm/boards/netx/netx.c
@@ -47,7 +47,7 @@ static int netx_mem_init(void)
mem_initcall(netx_mem_init);
static int netx_devices_init(void) {
- add_cfi_flash_device(-1, 0xC0000000, 32 * 1024 * 1024, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, 0xC0000000, 32 * 1024 * 1024, 0);
add_generic_device("netx-eth", DEVICE_ID_DYNAMIC, NULL, 0, 0, IORESOURCE_MEM,
&eth0_data);
diff --git a/arch/arm/boards/nhk8815/setup.c b/arch/arm/boards/nhk8815/setup.c
index ccc0510555..5820114307 100644
--- a/arch/arm/boards/nhk8815/setup.c
+++ b/arch/arm/boards/nhk8815/setup.c
@@ -63,7 +63,7 @@ static struct resource nhk8815_nand_resources[] = {
.flags = IORESOURCE_MEM,
}, {
.start = NAND_IO_DATA,
- .end = NAND_IO_CMD + 0xfff,
+ .end = NAND_IO_DATA + 0xfff,
.flags = IORESOURCE_MEM,
}
};
diff --git a/arch/arm/boards/omap343xdsp/board.c b/arch/arm/boards/omap343xdsp/board.c
index b5174f3a6e..8d4119331b 100644
--- a/arch/arm/boards/omap343xdsp/board.c
+++ b/arch/arm/boards/omap343xdsp/board.c
@@ -621,7 +621,7 @@ static struct NS16550_plat serial_plat = {
static int sdp3430_console_init(void)
{
/* Register the serial port */
- add_ns16550_device(-1, OMAP_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
+ add_ns16550_device(DEVICE_ID_DYNAMIC, OMAP_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
&serial_plat);
return 0;
diff --git a/arch/arm/boards/panda/board.c b/arch/arm/boards/panda/board.c
index 84b4ecd77e..98c05b2f41 100644
--- a/arch/arm/boards/panda/board.c
+++ b/arch/arm/boards/panda/board.c
@@ -92,7 +92,7 @@ static void panda_ehci_init(void)
/* enable power to hub */
gpio_set_value(GPIO_HUB_POWER, 1);
- add_usb_ehci_device(-1, 0x4a064c00,
+ add_usb_ehci_device(DEVICE_ID_DYNAMIC, 0x4a064c00,
0x4a064c00 + 0x10, &ehci_pdata);
}
#else
diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c
index 8f1271fa5e..912d6ea603 100644
--- a/arch/arm/boards/pcm038/pcm038.c
+++ b/arch/arm/boards/pcm038/pcm038.c
@@ -292,7 +292,7 @@ static int pcm038_devices_init(void)
pcm038_power_init();
- add_cfi_flash_device(-1, 0xC0000000, 32 * 1024 * 1024, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, 0xC0000000, 32 * 1024 * 1024, 0);
imx27_add_nand(&nand_info);
imx27_add_fb(&pcm038_fb_data);
diff --git a/arch/arm/boards/pcm038/pcm970.c b/arch/arm/boards/pcm038/pcm970.c
index b95648270b..31af383c20 100644
--- a/arch/arm/boards/pcm038/pcm970.c
+++ b/arch/arm/boards/pcm038/pcm970.c
@@ -48,7 +48,7 @@ static void pcm970_usbh2_init(void)
mdelay(10);
if (!ulpi_setup((void *)(IMX_OTG_BASE + 0x570), 1))
- add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+ add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_OTG_BASE + 0x400, NULL);
}
#endif
@@ -73,7 +73,7 @@ static struct ide_port_info pcm970_ide_pdata = {
};
static struct device_d pcm970_ide_device = {
- .id = -1,
+ .id = DEVICE_ID_DYNAMIC,
.name = "ide_intf",
.num_resources = ARRAY_SIZE(pcm970_ide_resources),
.resource = pcm970_ide_resources,
diff --git a/arch/arm/boards/pcm043/pcm043.c b/arch/arm/boards/pcm043/pcm043.c
index 152b47ce65..95e12fdcb5 100644
--- a/arch/arm/boards/pcm043/pcm043.c
+++ b/arch/arm/boards/pcm043/pcm043.c
@@ -148,7 +148,7 @@ static int imx35_devices_init(void)
* Up to 32MiB NOR type flash, connected to
* CS line 0, data width is 16 bit
*/
- add_cfi_flash_device(-1, IMX_CS0_BASE, 32 * 1024 * 1024, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, IMX_CS0_BASE, 32 * 1024 * 1024, 0);
if ((reg & 0xc00) == 0x800) { /* reset mode: external boot */
switch ( (reg >> 25) & 0x3) {
diff --git a/arch/arm/boards/pcm049/env/bin/nand_bootstrap b/arch/arm/boards/pcm049/env/bin/nand_bootstrap
index acd00dc904..f8873fabe2 100644
--- a/arch/arm/boards/pcm049/env/bin/nand_bootstrap
+++ b/arch/arm/boards/pcm049/env/bin/nand_bootstrap
@@ -4,7 +4,7 @@ echo "copying barebox to nand..."
mci0.probe=1
mkdir mnt
-mount /dev/disk0.0 fat /mnt
+mount /dev/disk0.0 /mnt
if [ $? != 0 ]; then
echo "failed to mount mmc card"
exit 1
diff --git a/arch/arm/boards/phycard-a-l1/pca-a-l1.c b/arch/arm/boards/phycard-a-l1/pca-a-l1.c
index 1dc7678771..00df240819 100644
--- a/arch/arm/boards/phycard-a-l1/pca-a-l1.c
+++ b/arch/arm/boards/phycard-a-l1/pca-a-l1.c
@@ -327,7 +327,7 @@ static struct NS16550_plat serial_plat = {
*/
static int pcaal1_init_console(void)
{
- add_ns16550_device(-1, OMAP_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
+ add_ns16550_device(DEVICE_ID_DYNAMIC, OMAP_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
&serial_plat);
return 0;
diff --git a/arch/arm/boards/phycard-a-xl2/env/bin/nand_bootstrap b/arch/arm/boards/phycard-a-xl2/env/bin/nand_bootstrap
index acd00dc904..f8873fabe2 100644
--- a/arch/arm/boards/phycard-a-xl2/env/bin/nand_bootstrap
+++ b/arch/arm/boards/phycard-a-xl2/env/bin/nand_bootstrap
@@ -4,7 +4,7 @@ echo "copying barebox to nand..."
mci0.probe=1
mkdir mnt
-mount /dev/disk0.0 fat /mnt
+mount /dev/disk0.0 /mnt
if [ $? != 0 ]; then
echo "failed to mount mmc card"
exit 1
diff --git a/arch/arm/boards/phycard-a-xl2/pca-a-xl2.c b/arch/arm/boards/phycard-a-xl2/pca-a-xl2.c
index 128cb8fd28..2132dc3c12 100644
--- a/arch/arm/boards/phycard-a-xl2/pca-a-xl2.c
+++ b/arch/arm/boards/phycard-a-xl2/pca-a-xl2.c
@@ -51,7 +51,7 @@ static struct NS16550_plat serial_plat = {
static int pcaaxl2_console_init(void)
{
/* Register the serial port */
- add_ns16550_device(-1, OMAP44XX_UART3_BASE, 1024,
+ add_ns16550_device(DEVICE_ID_DYNAMIC, OMAP44XX_UART3_BASE, 1024,
IORESOURCE_MEM_8BIT, &serial_plat);
return 0;
@@ -85,7 +85,7 @@ static void pcaaxl2_network_init(void)
{
gpmc_cs_config(5, &net_cfg);
- add_ks8851_device(-1, net_cfg.base, net_cfg.base + 2,
+ add_ks8851_device(DEVICE_ID_DYNAMIC, net_cfg.base, net_cfg.base + 2,
IORESOURCE_MEM_16BIT, NULL);
}
diff --git a/arch/arm/boards/phycard-i.MX27/pca100.c b/arch/arm/boards/phycard-i.MX27/pca100.c
index 126f9efbac..614bfc65eb 100644
--- a/arch/arm/boards/phycard-i.MX27/pca100.c
+++ b/arch/arm/boards/phycard-i.MX27/pca100.c
@@ -141,9 +141,9 @@ static void pca100_usb_register(void)
mdelay(10);
ulpi_setup((void *)(IMX_OTG_BASE + 0x170), 1);
- add_generic_usb_ehci_device(-1, IMX_OTG_BASE, NULL);
+ add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_OTG_BASE, NULL);
ulpi_setup((void *)(IMX_OTG_BASE + 0x570), 1);
- add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+ add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_OTG_BASE + 0x400, NULL);
}
#endif
diff --git a/arch/arm/boards/qil-a9260/init.c b/arch/arm/boards/qil-a9260/init.c
index 305d733a74..6b1ed85609 100644
--- a/arch/arm/boards/qil-a9260/init.c
+++ b/arch/arm/boards/qil-a9260/init.c
@@ -150,11 +150,7 @@ static void __init ek_add_led(void)
static int qil_a9260_mem_init(void)
{
-#ifdef CONFIG_AT91_HAVE_SRAM_128M
- at91_add_device_sdram(128 * 1024 * 1024);
-#else
- at91_add_device_sdram(64 * 1024 * 1024);
-#endif
+ at91_add_device_sdram(0);
return 0;
}
@@ -196,11 +192,17 @@ device_initcall(qil_a9260_devices_init);
static int qil_a9260_console_init(void)
{
at91_register_uart(0, 0);
+ at91_set_A_periph(AT91_PIN_PB14, 1); /* Enable pull-up on DRXD */
+
at91_register_uart(1, ATMEL_UART_CTS | ATMEL_UART_RTS
| ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
| ATMEL_UART_RI);
+
at91_register_uart(2, ATMEL_UART_CTS | ATMEL_UART_RTS);
+ at91_set_A_periph(AT91_PIN_PB7, 1); /* Enable pull-up on RXD1 */
+
at91_register_uart(3, ATMEL_UART_CTS | ATMEL_UART_RTS);
+ at91_set_A_periph(AT91_PIN_PB9, 1); /* Enable pull-up on RXD2 */
return 0;
}
diff --git a/arch/arm/boards/scb9328/scb9328.c b/arch/arm/boards/scb9328/scb9328.c
index 9a342a8170..671adbf274 100644
--- a/arch/arm/boards/scb9328/scb9328.c
+++ b/arch/arm/boards/scb9328/scb9328.c
@@ -88,8 +88,8 @@ static int scb9328_devices_init(void)
CS5U = 0x00008400;
CS5L = 0x00000D03;
- add_cfi_flash_device(-1, 0x10000000, 16 * 1024 * 1024, 0);
- add_dm9000_device(-1, 0x16000000, 0x16000004,
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, 0x10000000, 16 * 1024 * 1024, 0);
+ add_dm9000_device(DEVICE_ID_DYNAMIC, 0x16000000, 0x16000004,
IORESOURCE_MEM_16BIT, &dm9000_data);
devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self0");
diff --git a/arch/arm/boards/tny-a926x/init.c b/arch/arm/boards/tny-a926x/init.c
index 2cb7da7cff..5538a44a67 100644
--- a/arch/arm/boards/tny-a926x/init.c
+++ b/arch/arm/boards/tny-a926x/init.c
@@ -89,7 +89,7 @@ static struct sam9_smc_config tny_a9g20_nand_smc_config = {
.ncs_read_pulse = 4,
.nrd_pulse = 4,
.ncs_write_pulse = 4,
- .nwe_pulse = 2,
+ .nwe_pulse = 4,
.read_cycle = 7,
.write_cycle = 7,
@@ -171,7 +171,7 @@ static void __init ek_add_device_udc(void)
static int tny_a9260_mem_init(void)
{
- at91_add_device_sdram(64 * 1024 * 1024);
+ at91_add_device_sdram(0);
return 0;
}
diff --git a/arch/arm/boards/toshiba-ac100/serial.c b/arch/arm/boards/toshiba-ac100/serial.c
index 2ed0e3901c..39d2658a82 100644
--- a/arch/arm/boards/toshiba-ac100/serial.c
+++ b/arch/arm/boards/toshiba-ac100/serial.c
@@ -35,7 +35,7 @@ static struct NS16550_plat serial_plat = {
static int ac100_serial_console_init(void)
{
/* Register the serial port */
- add_ns16550_device(-1, TEGRA_UARTA_BASE, 8 << serial_plat.shift,
+ add_ns16550_device(DEVICE_ID_DYNAMIC, TEGRA_UARTA_BASE, 8 << serial_plat.shift,
IORESOURCE_MEM_8BIT, &serial_plat);
return 0;
diff --git a/arch/arm/boards/usb-a926x/init.c b/arch/arm/boards/usb-a926x/init.c
index 824a38a94d..00a215d140 100644
--- a/arch/arm/boards/usb-a926x/init.c
+++ b/arch/arm/boards/usb-a926x/init.c
@@ -90,7 +90,7 @@ static struct sam9_smc_config usb_a9g20_nand_smc_config = {
.ncs_read_pulse = 4,
.nrd_pulse = 4,
.ncs_write_pulse = 4,
- .nwe_pulse = 2,
+ .nwe_pulse = 4,
.read_cycle = 7,
.write_cycle = 7,
@@ -203,11 +203,7 @@ static void __init ek_add_led(void)
static int usb_a9260_mem_init(void)
{
-#ifdef CONFIG_AT91_HAVE_SRAM_128M
- at91_add_device_sdram(128 * 1024 * 1024);
-#else
- at91_add_device_sdram(64 * 1024 * 1024);
-#endif
+ at91_add_device_sdram(0);
return 0;
}
@@ -294,7 +290,7 @@ static void usb_a9260_keyboard_device_dab_mmx(void)
at91_set_deglitch(keys[i].gpio, 1);
}
- add_gpio_keys_device(-1, &gk_pdata);
+ add_gpio_keys_device(DEVICE_ID_DYNAMIC, &gk_pdata);
}
#else
static void usb_a9260_keyboard_device_dab_mmx(void) {}
diff --git a/arch/arm/boards/versatile/versatilepb.c b/arch/arm/boards/versatile/versatilepb.c
index b95e605ab2..b834bbbda2 100644
--- a/arch/arm/boards/versatile/versatilepb.c
+++ b/arch/arm/boards/versatile/versatilepb.c
@@ -50,7 +50,7 @@ mem_initcall(vpb_mem_init);
static int vpb_devices_init(void)
{
- add_cfi_flash_device(-1, VERSATILE_FLASH_BASE, VERSATILE_FLASH_SIZE, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, VERSATILE_FLASH_BASE, VERSATILE_FLASH_SIZE, 0);
devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self");
devfs_add_partition("nor0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
diff --git a/arch/arm/include/asm/barebox-arm-head.h b/arch/arm/include/asm/barebox-arm-head.h
index 2c250e948e..0b1d78644d 100644
--- a/arch/arm/include/asm/barebox-arm-head.h
+++ b/arch/arm/include/asm/barebox-arm-head.h
@@ -1,6 +1,9 @@
#ifndef __ASM_ARM_HEAD_H
#define __ASM_ARM_HEAD_H
+#ifdef CONFIG_HAVE_MACH_ARM_HEAD
+#include <mach/barebox-arm-head.h>
+#else
static inline void barebox_arm_head(void)
{
__asm__ __volatile__ (
@@ -31,5 +34,6 @@ static inline void barebox_arm_head(void)
".word _barebox_image_size\n" /* image size to copy */
);
}
+#endif
#endif /* __ASM_ARM_HEAD_H */
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index b56ca14d1d..9c9534eccf 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -16,6 +16,7 @@
#include <mach/board.h>
#include <mach/at91_pmc.h>
#include <mach/at91sam9260_matrix.h>
+#include <mach/at91sam9_sdramc.h>
#include <mach/gpio.h>
#include <mach/io.h>
#include <mach/cpu.h>
@@ -24,6 +25,9 @@
void at91_add_device_sdram(u32 size)
{
+ if (!size)
+ size = at91_get_sdram_size();
+
arm_add_mem_device("ram0", AT91_CHIPSELECT_1, size);
if (cpu_is_at91sam9g20()) {
add_mem_device("sram0", AT91SAM9G20_SRAM_BASE,
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index a109804139..0091e2dbe9 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -15,6 +15,7 @@
#include <asm/hardware.h>
#include <mach/at91_pmc.h>
#include <mach/at91sam9261_matrix.h>
+#include <mach/at91sam9_sdramc.h>
#include <mach/board.h>
#include <mach/gpio.h>
#include <mach/io.h>
@@ -24,6 +25,9 @@
void at91_add_device_sdram(u32 size)
{
+ if (!size)
+ size = at91_get_sdram_size();
+
arm_add_mem_device("ram0", AT91_CHIPSELECT_1, size);
if (cpu_is_at91sam9g10())
add_mem_device("sram0", AT91SAM9G10_SRAM_BASE,
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 7f916d21a4..e6864802b7 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -15,6 +15,7 @@
#include <asm/hardware.h>
#include <mach/at91_pmc.h>
#include <mach/at91sam9263_matrix.h>
+#include <mach/at91sam9_sdramc.h>
#include <mach/board.h>
#include <mach/gpio.h>
#include <mach/io.h>
@@ -23,6 +24,9 @@
void at91_add_device_sdram(u32 size)
{
+ if (!size)
+ size = at91_get_sdram_size();
+
arm_add_mem_device("ram0", AT91_CHIPSELECT_1, size);
add_mem_device("sram0", AT91SAM9263_SRAM0_BASE,
AT91SAM9263_SRAM0_SIZE, IORESOURCE_MEM_WRITEABLE);
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
index 5af2b54b12..1ab61e918b 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
@@ -83,5 +83,33 @@
#define AT91_SDRAMC_MD_SDRAM 0
#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1
+#ifndef __ASSEMBLY__
+#include <mach/io.h>
+static inline u32 at91_get_sdram_size(void)
+{
+ u32 val;
+ u32 size;
+
+ val = at91_sys_read(AT91_SDRAMC_CR);
+
+ /* Formula:
+ * size = bank << (col + row + 1);
+ * if (bandwidth == 32 bits)
+ * size <<= 1;
+ */
+ size = 1;
+ /* COL */
+ size += (val & AT91_SDRAMC_NC) + 8;
+ /* ROW */
+ size += ((val & AT91_SDRAMC_NR) >> 2) + 11;
+ /* BANK */
+ size = ((val & AT91_SDRAMC_NB) ? 4 : 2) << size;
+ /* bandwidth */
+ if (!(val & AT91_SDRAMC_DBW))
+ size <<= 1;
+
+ return size;
+}
+#endif
#endif
diff --git a/arch/arm/mach-at91/include/mach/barebox-arm-head.h b/arch/arm/mach-at91/include/mach/barebox-arm-head.h
new file mode 100644
index 0000000000..a9c8dd44a7
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/barebox-arm-head.h
@@ -0,0 +1,33 @@
+#ifndef __MACH_ARM_HEAD_H
+#define __MACH_ARM_HEAD_H
+
+#ifdef CONFIG_SHELL_NONE
+#define AT91_EXV6 ".word _barebox_image_size\n"
+#else
+#define AT91_EXV6 ".word _barebox_bare_init_size\n"
+#endif
+
+static inline void barebox_arm_head(void)
+{
+ __asm__ __volatile__ (
+#ifdef CONFIG_THUMB2_BAREBOX
+#error Thumb2 is not supported
+#else
+ "b reset\n"
+ "1: b 1b\n"
+ "1: b 1b\n"
+ "1: b 1b\n"
+ "1: b 1b\n"
+ AT91_EXV6 /* image size to load by the bootrom */
+ "1: b 1b\n"
+ "1: b 1b\n"
+#endif
+ ".asciz \"barebox\"\n"
+ ".word _text\n" /* text base. If copied there,
+ * barebox can skip relocation
+ */
+ ".word _barebox_image_size\n" /* image size to copy */
+ );
+}
+
+#endif /* __ASM_ARM_HEAD_H */
diff --git a/arch/arm/mach-at91/include/mach/debug_ll.h b/arch/arm/mach-at91/include/mach/debug_ll.h
new file mode 100644
index 0000000000..ee824cbf2f
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/debug_ll.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012
+ * Jean-Christophe PLAGNIOL-VILLARD <planioj@jcrosoft.com>
+ *
+ * Under GPLv2
+ */
+
+#ifndef __MACH_DEBUG_LL_H__
+#define __MACH_DEBUG_LL_H__
+
+#include <asm/io.h>
+#include <mach/hardware.h>
+
+#define UART_BASE (AT91_BASE_SYS + AT91_DBGU)
+
+#define ATMEL_US_CSR 0x0014
+#define ATMEL_US_THR 0x001c
+#define ATMEL_US_TXRDY (1 << 1)
+#define ATMEL_US_TXEMPTY (1 << 9)
+
+/*
+ * The following code assumes the serial port has already been
+ * initialized by the bootloader. If you didn't setup a port in
+ * your bootloader then nothing will appear (which might be desired).
+ *
+ * This does not append a newline
+ */
+static void putc(int c)
+{
+ while (!(__raw_readl(UART_BASE + ATMEL_US_CSR) & ATMEL_US_TXRDY))
+ barrier();
+ __raw_writel(c, UART_BASE + ATMEL_US_THR);
+
+ while (!(__raw_readl(UART_BASE + ATMEL_US_CSR) & ATMEL_US_TXEMPTY))
+ barrier();
+}
+#endif
diff --git a/arch/arm/mach-imx/gpio.c b/arch/arm/mach-imx/gpio.c
index fdee20b865..8d5d4ce2b0 100644
--- a/arch/arm/mach-imx/gpio.c
+++ b/arch/arm/mach-imx/gpio.c
@@ -27,7 +27,8 @@
#include <errno.h>
#include <io.h>
#include <mach/imx-regs.h>
-#include <mach/gpio.h>
+#include <gpio.h>
+#include <init.h>
#if defined CONFIG_ARCH_IMX1 || defined CONFIG_ARCH_IMX21 || defined CONFIG_ARCH_IMX27
#define GPIO_DR 0x1c
@@ -48,21 +49,15 @@
#define GPIO_ISR 0x18
#endif
-extern void __iomem *imx_gpio_base[];
-extern int imx_gpio_count;
+struct imx_gpio_chip {
+ void __iomem *base;
+ struct gpio_chip chip;
+};
-static void __iomem *gpio_get_base(unsigned gpio)
+static void imx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
{
- if (gpio >= imx_gpio_count)
- return NULL;
-
- return imx_gpio_base[gpio / 32];
-}
-
-void gpio_set_value(unsigned gpio, int value)
-{
- void __iomem *base = gpio_get_base(gpio);
- int shift = gpio % 32;
+ struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
+ void __iomem *base = imxgpio->base;
u32 val;
if (!base)
@@ -71,59 +66,88 @@ void gpio_set_value(unsigned gpio, int value)
val = readl(base + GPIO_DR);
if (value)
- val |= 1 << shift;
+ val |= 1 << gpio;
else
- val &= ~(1 << shift);
+ val &= ~(1 << gpio);
writel(val, base + GPIO_DR);
}
-int gpio_direction_input(unsigned gpio)
+static int imx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
{
- void __iomem *base = gpio_get_base(gpio);
- int shift = gpio % 32;
+ struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
+ void __iomem *base = imxgpio->base;
u32 val;
if (!base)
return -EINVAL;
val = readl(base + GPIO_GDIR);
- val &= ~(1 << shift);
+ val &= ~(1 << gpio);
writel(val, base + GPIO_GDIR);
return 0;
}
-int gpio_direction_output(unsigned gpio, int value)
+static int imx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value)
{
- void __iomem *base = gpio_get_base(gpio);
- int shift = gpio % 32;
+ struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
+ void __iomem *base = imxgpio->base;
u32 val;
- if (!base)
- return -EINVAL;
-
- gpio_set_value(gpio, value);
+ gpio_set_value(gpio + chip->base, value);
val = readl(base + GPIO_GDIR);
- val |= 1 << shift;
+ val |= 1 << gpio;
writel(val, base + GPIO_GDIR);
return 0;
}
-int gpio_get_value(unsigned gpio)
+static int imx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
{
- void __iomem *base = gpio_get_base(gpio);
- int shift = gpio % 32;
+ struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
+ void __iomem *base = imxgpio->base;
u32 val;
- if (!base)
- return -EINVAL;
-
val = readl(base + GPIO_PSR);
- return val & (1 << shift) ? 1 : 0;
+ return val & (1 << gpio) ? 1 : 0;
+}
+
+static struct gpio_ops imx_gpio_ops = {
+ .direction_input = imx_gpio_direction_input,
+ .direction_output = imx_gpio_direction_output,
+ .get = imx_gpio_get_value,
+ .set = imx_gpio_set_value,
+};
+
+static int imx_gpio_probe(struct device_d *dev)
+{
+ struct imx_gpio_chip *imxgpio;
+
+ imxgpio = xzalloc(sizeof(*imxgpio));
+ imxgpio->base = dev_request_mem_region(dev, 0);
+ imxgpio->chip.ops = &imx_gpio_ops;
+ imxgpio->chip.base = -1;
+ imxgpio->chip.ngpio = 32;
+ imxgpio->chip.dev = dev;
+ gpiochip_add(&imxgpio->chip);
+
+ dev_info(dev, "probed gpiochip%d with base %d\n", dev->id, imxgpio->chip.base);
+
+ return 0;
}
+static struct driver_d imx_gpio_driver = {
+ .name = "imx-gpio",
+ .probe = imx_gpio_probe,
+};
+
+static int imx_gpio_add(void)
+{
+ register_driver(&imx_gpio_driver);
+ return 0;
+}
+coredevice_initcall(imx_gpio_add);
diff --git a/arch/arm/mach-imx/gpio.h b/arch/arm/mach-imx/gpio.h
deleted file mode 100644
index 545cebef3b..0000000000
--- a/arch/arm/mach-imx/gpio.h
+++ /dev/null
@@ -1,4 +0,0 @@
-
-extern void *imx_gpio_base[];
-extern int imx_gpio_count;
-
diff --git a/arch/arm/mach-imx/imx1.c b/arch/arm/mach-imx/imx1.c
index 742a260f0a..5a000bc96a 100644
--- a/arch/arm/mach-imx/imx1.c
+++ b/arch/arm/mach-imx/imx1.c
@@ -16,16 +16,15 @@
*/
#include <common.h>
+#include <init.h>
-#include "gpio.h"
-
-void *imx_gpio_base[] = {
- (void *)0x0021c000,
- (void *)0x0021c100,
- (void *)0x0021c200,
- (void *)0x0021c300,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
+static int imx1_init(void)
+{
+ add_generic_device("imx-gpio", 0, NULL, 0x0021c000, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x0021c100, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x0021c200, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, 0x0021c300, 0x100, IORESOURCE_MEM, NULL);
+ return 0;
+}
+coredevice_initcall(imx1_init);
diff --git a/arch/arm/mach-imx/imx21.c b/arch/arm/mach-imx/imx21.c
index bbef33d2d4..85590ee8f4 100644
--- a/arch/arm/mach-imx/imx21.c
+++ b/arch/arm/mach-imx/imx21.c
@@ -18,8 +18,6 @@
#include <common.h>
#include <mach/imx-regs.h>
-#include "gpio.h"
-
int imx_silicon_revision(void)
{
// Known values:
@@ -28,14 +26,15 @@ int imx_silicon_revision(void)
return CID;
}
-void *imx_gpio_base[] = {
- (void *)0x10015000,
- (void *)0x10015100,
- (void *)0x10015200,
- (void *)0x10015300,
- (void *)0x10015400,
- (void *)0x10015500,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
+static int imx21_init(void)
+{
+ add_generic_device("imx-gpio", 0, NULL, 0x10015000, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x10015100, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x10015200, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, 0x10015300, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 4, NULL, 0x10015400, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 5, NULL, 0x10015500, 0x100, IORESOURCE_MEM, NULL);
+ return 0;
+}
+coredevice_initcall(imx21_init);
diff --git a/arch/arm/mach-imx/imx25.c b/arch/arm/mach-imx/imx25.c
index 19a2909e18..d605022516 100644
--- a/arch/arm/mach-imx/imx25.c
+++ b/arch/arm/mach-imx/imx25.c
@@ -22,17 +22,6 @@
#include <io.h>
#include <sizes.h>
-#include "gpio.h"
-
-void *imx_gpio_base[] = {
- (void *)0x53fcc000,
- (void *)0x53fd0000,
- (void *)0x53fa4000,
- (void *)0x53f9c000,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
u64 imx_uid(void)
{
u64 uid = 0;
@@ -59,6 +48,10 @@ static int imx25_init(void)
add_generic_device("imx_iim", 0, NULL, IMX_IIM_BASE, SZ_4K,
IORESOURCE_MEM, &imx25_iim_pdata);
+ add_generic_device("imx-gpio", 0, NULL, 0x53fcc000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x53fd0000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x53fa4000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, 0x53f9c000, 0x1000, IORESOURCE_MEM, NULL);
return 0;
}
coredevice_initcall(imx25_init);
diff --git a/arch/arm/mach-imx/imx27.c b/arch/arm/mach-imx/imx27.c
index 1af291d33a..c6e6942c58 100644
--- a/arch/arm/mach-imx/imx27.c
+++ b/arch/arm/mach-imx/imx27.c
@@ -21,24 +21,11 @@
#include <init.h>
#include <io.h>
-#include "gpio.h"
-
int imx_silicon_revision(void)
{
return CID >> 28;
}
-void *imx_gpio_base[] = {
- (void *)0x10015000,
- (void *)0x10015100,
- (void *)0x10015200,
- (void *)0x10015300,
- (void *)0x10015400,
- (void *)0x10015500,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
/*
* Initialize MAX on i.MX27. necessary to give the DMA engine
* higher priority to the memory than the CPU. Needed for proper
@@ -86,6 +73,12 @@ static int imx27_init(void)
imx27_init_max();
+ add_generic_device("imx-gpio", 0, NULL, 0x10015000, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x10015100, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x10015200, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, 0x10015300, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 4, NULL, 0x10015400, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 5, NULL, 0x10015500, 0x100, IORESOURCE_MEM, NULL);
return 0;
}
coredevice_initcall(imx27_init);
diff --git a/arch/arm/mach-imx/imx31.c b/arch/arm/mach-imx/imx31.c
index bb713ca876..90dc4e3180 100644
--- a/arch/arm/mach-imx/imx31.c
+++ b/arch/arm/mach-imx/imx31.c
@@ -20,21 +20,15 @@
#include <sizes.h>
#include <mach/imx-regs.h>
-#include "gpio.h"
-
-void *imx_gpio_base[] = {
- (void *)0x53fcc000,
- (void *)0x53fd0000,
- (void *)0x53fa4000,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
static int imx31_init(void)
{
add_generic_device("imx_iim", 0, NULL, IMX_IIM_BASE, SZ_4K,
IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 0, NULL, 0x53fcc000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x53fd0000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x53fa4000, 0x1000, IORESOURCE_MEM, NULL);
+
return 0;
}
coredevice_initcall(imx31_init);
diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c
index fe0c99ea72..efbee985d3 100644
--- a/arch/arm/mach-imx/imx35.c
+++ b/arch/arm/mach-imx/imx35.c
@@ -23,16 +23,6 @@
#include <mach/iim.h>
#include <mach/generic.h>
-#include "gpio.h"
-
-void *imx_gpio_base[] = {
- (void *)0x53fcc000,
- (void *)0x53fd0000,
- (void *)0x53fa4000,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
int imx_silicon_revision()
{
uint32_t reg;
@@ -66,6 +56,10 @@ static int imx35_init(void)
add_generic_device("imx_iim", 0, NULL, IMX_IIM_BASE, SZ_4K,
IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 0, NULL, 0x53fcc000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x53fd0000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x53fa4000, 0x1000, IORESOURCE_MEM, NULL);
+
return 0;
}
coredevice_initcall(imx35_init);
diff --git a/arch/arm/mach-imx/imx51.c b/arch/arm/mach-imx/imx51.c
index 53205a9215..e43cc65ecd 100644
--- a/arch/arm/mach-imx/imx51.c
+++ b/arch/arm/mach-imx/imx51.c
@@ -24,17 +24,6 @@
#include <mach/imx-regs.h>
#include <mach/clock-imx51_53.h>
-#include "gpio.h"
-
-void *imx_gpio_base[] = {
- (void *)MX51_GPIO1_BASE_ADDR,
- (void *)MX51_GPIO2_BASE_ADDR,
- (void *)MX51_GPIO3_BASE_ADDR,
- (void *)MX51_GPIO4_BASE_ADDR,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
#define SI_REV 0x48
static u32 mx51_silicon_revision;
@@ -89,6 +78,11 @@ static int imx51_init(void)
add_generic_device("imx_iim", 0, NULL, MX51_IIM_BASE_ADDR, SZ_4K,
IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 0, NULL, 0x73f84000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x73f88000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x73f8c000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, 0x73f90000, 0x1000, IORESOURCE_MEM, NULL);
+
return 0;
}
coredevice_initcall(imx51_init);
diff --git a/arch/arm/mach-imx/imx53.c b/arch/arm/mach-imx/imx53.c
index 7c679bbe79..cb945753b0 100644
--- a/arch/arm/mach-imx/imx53.c
+++ b/arch/arm/mach-imx/imx53.c
@@ -24,20 +24,6 @@
#include <mach/imx-regs.h>
#include <mach/clock-imx51_53.h>
-#include "gpio.h"
-
-void *imx_gpio_base[] = {
- (void *)MX53_GPIO1_BASE_ADDR,
- (void *)MX53_GPIO2_BASE_ADDR,
- (void *)MX53_GPIO3_BASE_ADDR,
- (void *)MX53_GPIO4_BASE_ADDR,
- (void *)MX53_GPIO5_BASE_ADDR,
- (void *)MX53_GPIO6_BASE_ADDR,
- (void *)MX53_GPIO7_BASE_ADDR,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
#define SI_REV 0x48
static u32 mx53_silicon_revision;
@@ -88,6 +74,13 @@ static int imx53_init(void)
add_generic_device("imx_iim", 0, NULL, MX53_IIM_BASE_ADDR, SZ_4K,
IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 0, NULL, MX53_GPIO1_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, MX53_GPIO2_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, MX53_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, MX53_GPIO4_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 4, NULL, MX53_GPIO5_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 5, NULL, MX53_GPIO6_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 6, NULL, MX53_GPIO7_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
return 0;
}
coredevice_initcall(imx53_init);
diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index a443343853..c693724a51 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -21,20 +21,6 @@
#include <sizes.h>
#include <mach/imx6-regs.h>
-#include "gpio.h"
-
-void *imx_gpio_base[] = {
- (void *)MX6_GPIO1_BASE_ADDR,
- (void *)MX6_GPIO2_BASE_ADDR,
- (void *)MX6_GPIO3_BASE_ADDR,
- (void *)MX6_GPIO4_BASE_ADDR,
- (void *)MX6_GPIO5_BASE_ADDR,
- (void *)MX6_GPIO6_BASE_ADDR,
- (void *)MX6_GPIO7_BASE_ADDR,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
void imx6_init_lowlevel(void)
{
void __iomem *aips1 = (void *)MX6_AIPS1_ON_BASE_ADDR;
@@ -69,3 +55,17 @@ void imx6_init_lowlevel(void)
writel(0xffffffff, 0x020c407c);
writel(0xffffffff, 0x020c4080);
}
+
+static int imx6_init(void)
+{
+ add_generic_device("imx-gpio", 0, NULL, MX6_GPIO1_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, MX6_GPIO2_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, MX6_GPIO3_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, MX6_GPIO4_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 4, NULL, MX6_GPIO5_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 5, NULL, MX6_GPIO6_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 6, NULL, MX6_GPIO7_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+
+ return 0;
+}
+coredevice_initcall(imx6_init);
diff --git a/arch/arm/mach-mxs/bcb.c b/arch/arm/mach-mxs/bcb.c
index d0a3ddc8d3..af51d24b03 100644
--- a/arch/arm/mach-mxs/bcb.c
+++ b/arch/arm/mach-mxs/bcb.c
@@ -236,7 +236,7 @@ static struct mx28_fcb *create_fcb(struct mtd_info *mtd, void *buf, unsigned fw1
fcb->fw1_start_page = fw1_start_block / mtd->writesize;
fcb->fw1_sectors = DIV_ROUND_UP(fw_size, mtd->writesize);
- if (fw2_start_block != 0 && fw2_start_block < mtd->size / mtd->erasesize) {
+ if (fw2_start_block) {
fcb->fw2_start_page = fw2_start_block / mtd->writesize;
fcb->fw2_sectors = fcb->fw1_sectors;
}
diff --git a/arch/blackfin/include/asm/unaligned.h b/arch/blackfin/include/asm/unaligned.h
new file mode 100644
index 0000000000..0f6c0987f2
--- /dev/null
+++ b/arch/blackfin/include/asm/unaligned.h
@@ -0,0 +1,11 @@
+#ifndef _ASM_BLACKFIN_UNALIGNED_H
+#define _ASM_BLACKFIN_UNALIGNED_H
+
+#include <linux/unaligned/le_struct.h>
+#include <linux/unaligned/be_byteshift.h>
+#include <linux/unaligned/generic.h>
+
+#define get_unaligned __get_unaligned_le
+#define put_unaligned __put_unaligned_le
+
+#endif /* _ASM_BLACKFIN_UNALIGNED_H */
diff --git a/arch/mips/boards/dlink-dir-320/serial.c b/arch/mips/boards/dlink-dir-320/serial.c
index 3eaab2a129..1185248d5d 100644
--- a/arch/mips/boards/dlink-dir-320/serial.c
+++ b/arch/mips/boards/dlink-dir-320/serial.c
@@ -35,7 +35,7 @@ static struct NS16550_plat serial_plat = {
static int dir320_console_init(void)
{
/* Register the serial port */
- add_ns16550_device(-1, DEBUG_LL_UART_ADDR, 8,
+ add_ns16550_device(DEVICE_ID_DYNAMIC, DEBUG_LL_UART_ADDR, 8,
IORESOURCE_MEM_8BIT, &serial_plat);
return 0;
diff --git a/arch/mips/boards/qemu-malta/init.c b/arch/mips/boards/qemu-malta/init.c
index 0efc92a141..45f66f243d 100644
--- a/arch/mips/boards/qemu-malta/init.c
+++ b/arch/mips/boards/qemu-malta/init.c
@@ -58,7 +58,7 @@ static struct NS16550_plat serial_plat = {
static int malta_console_init(void)
{
/* Register the serial port */
- add_ns16550_device(-1, DEBUG_LL_UART_ADDR, 8,
+ add_ns16550_device(DEVICE_ID_DYNAMIC, DEBUG_LL_UART_ADDR, 8,
IORESOURCE_MEM_8BIT, &serial_plat);
return 0;
diff --git a/arch/mips/boards/rzx50/serial.c b/arch/mips/boards/rzx50/serial.c
index 308cd18eaf..3f593c9a92 100644
--- a/arch/mips/boards/rzx50/serial.c
+++ b/arch/mips/boards/rzx50/serial.c
@@ -58,7 +58,7 @@ static struct NS16550_plat serial_plat = {
static int rzx50_console_init(void)
{
/* Register the serial port */
- add_ns16550_device(-1, UART1_BASE, 8 << JZ4750D_UART_SHIFT,
+ add_ns16550_device(DEVICE_ID_DYNAMIC, UART1_BASE, 8 << JZ4750D_UART_SHIFT,
IORESOURCE_MEM_8BIT, &serial_plat);
return 0;
diff --git a/arch/nios2/boards/generic/generic.c b/arch/nios2/boards/generic/generic.c
index 2c998fe3ac..cdaaa02062 100644
--- a/arch/nios2/boards/generic/generic.c
+++ b/arch/nios2/boards/generic/generic.c
@@ -34,7 +34,7 @@ static struct device_d mac_dev = {
static int generic_devices_init(void)
{
- add_cfi_flash_device(-1, NIOS_SOPC_FLASH_BASE, NIOS_SOPC_FLASH_SIZE, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, NIOS_SOPC_FLASH_BASE, NIOS_SOPC_FLASH_SIZE, 0);
add_mem_device("ram0", NIOS_SOPC_MEMORY_BASE, NIOS_SOPC_MEMORY_SIZE,
IORESOURCE_MEM_WRITEABLE);
register_device(&mac_dev);
diff --git a/arch/openrisc/boards/generic/generic.c b/arch/openrisc/boards/generic/generic.c
index 6a9ce5b864..54c73a5aa3 100644
--- a/arch/openrisc/boards/generic/generic.c
+++ b/arch/openrisc/boards/generic/generic.c
@@ -12,7 +12,7 @@ static struct NS16550_plat serial_plat = {
static int openrisc_console_init(void)
{
/* Register the serial port */
- add_ns16550_device(-1, OPENRISC_SOPC_UART_BASE, 1024, IORESOURCE_MEM_8BIT, &serial_plat);
+ add_ns16550_device(DEVICE_ID_DYNAMIC, OPENRISC_SOPC_UART_BASE, 1024, IORESOURCE_MEM_8BIT, &serial_plat);
return 0;
}
diff --git a/arch/openrisc/include/asm/unaligned.h b/arch/openrisc/include/asm/unaligned.h
new file mode 100644
index 0000000000..1141cbd6fd
--- /dev/null
+++ b/arch/openrisc/include/asm/unaligned.h
@@ -0,0 +1,51 @@
+/*
+ * OpenRISC Linux
+ *
+ * Linux architectural port borrowing liberally from similar works of
+ * others. All original copyrights apply as per the original source
+ * declaration.
+ *
+ * OpenRISC implementation:
+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
+ * et al.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __ASM_OPENRISC_UNALIGNED_H
+#define __ASM_OPENRISC_UNALIGNED_H
+
+/*
+ * This is copied from the generic implementation and the C-struct
+ * variant replaced with the memmove variant. The GCC compiler
+ * for the OR32 arch optimizes too aggressively for the C-struct
+ * variant to work, so use the memmove variant instead.
+ *
+ * It may be worth considering implementing the unaligned access
+ * exception handler and allowing unaligned accesses (access_ok.h)...
+ * not sure if it would be much of a performance win without further
+ * investigation.
+ */
+#include <asm/byteorder.h>
+
+#if defined(__LITTLE_ENDIAN)
+# include <linux/unaligned/le_memmove.h>
+# include <linux/unaligned/be_byteshift.h>
+# include <linux/unaligned/generic.h>
+# define get_unaligned __get_unaligned_le
+# define put_unaligned __put_unaligned_le
+#elif defined(__BIG_ENDIAN)
+# include <linux/unaligned/be_memmove.h>
+# include <linux/unaligned/le_byteshift.h>
+# include <linux/unaligned/generic.h>
+# define get_unaligned __get_unaligned_be
+# define put_unaligned __put_unaligned_be
+#else
+# error need to define endianess
+#endif
+
+#endif /* __ASM_OPENRISC_UNALIGNED_H */
diff --git a/arch/ppc/boards/freescale-p2020rdb/p2020rdb.c b/arch/ppc/boards/freescale-p2020rdb/p2020rdb.c
index b9d9b0fdc8..c5fae0d7aa 100644
--- a/arch/ppc/boards/freescale-p2020rdb/p2020rdb.c
+++ b/arch/ppc/boards/freescale-p2020rdb/p2020rdb.c
@@ -69,7 +69,7 @@ struct i2c_platform_data i2cplat = {
static int devices_init(void)
{
- add_cfi_flash_device(-1, CFG_FLASH_BASE, 16 << 20, 0);
+ add_cfi_flash_device(DEVICE_ID_DYNAMIC, CFG_FLASH_BASE, 16 << 20, 0);
add_generic_device("i2c-fsl", 0, NULL, I2C1_BASE_ADDR,
0x100, IORESOURCE_MEM, &i2cplat);
@@ -92,7 +92,7 @@ static int p2020_console_init(void)
{
serial_plat.clock = fsl_get_bus_freq(0);
- add_ns16550_device(-1, 0xffe04500, 16, IORESOURCE_MEM_8BIT,
+ add_ns16550_device(DEVICE_ID_DYNAMIC, 0xffe04500, 16, IORESOURCE_MEM_8BIT,
&serial_plat);
return 0;
}
diff --git a/arch/ppc/include/asm/unaligned.h b/arch/ppc/include/asm/unaligned.h
new file mode 100644
index 0000000000..a41fa8cb4a
--- /dev/null
+++ b/arch/ppc/include/asm/unaligned.h
@@ -0,0 +1,16 @@
+#ifndef _ASM_PPC_UNALIGNED_H
+#define _ASM_PPC_UNALIGNED_H
+
+#ifdef __KERNEL__
+
+/*
+ * The PowerPC can do unaligned accesses itself in big endian mode.
+ */
+#include <linux/unaligned/access_ok.h>
+#include <linux/unaligned/generic.h>
+
+#define get_unaligned __get_unaligned_be
+#define put_unaligned __put_unaligned_be
+
+#endif /* __KERNEL__ */
+#endif /* _ASM_PPC_UNALIGNED_H */
diff --git a/arch/x86/boards/x86_generic/generic_pc.c b/arch/x86/boards/x86_generic/generic_pc.c
index 4be1237607..046f76db72 100644
--- a/arch/x86/boards/x86_generic/generic_pc.c
+++ b/arch/x86/boards/x86_generic/generic_pc.c
@@ -78,7 +78,7 @@ static struct NS16550_plat serial_plat = {
static int pc_console_init(void)
{
/* Register the serial port */
- add_ns16550_device(-1, 0x3f8, 8, 0, &serial_plat);
+ add_ns16550_device(DEVICE_ID_DYNAMIC, 0x3f8, 8, 0, &serial_plat);
return 0;
}
diff --git a/commands/mount.c b/commands/mount.c
index b32faef709..5b12ad4d96 100644
--- a/commands/mount.c
+++ b/commands/mount.c
@@ -29,11 +29,14 @@
#include <command.h>
#include <fs.h>
#include <errno.h>
+#include <getopt.h>
static int do_mount(int argc, char *argv[])
{
+ int opt;
int ret = 0;
struct fs_device_d *fsdev;
+ char *type = NULL;
if (argc == 1) {
for_each_fs_device(fsdev) {
@@ -45,10 +48,18 @@ static int do_mount(int argc, char *argv[])
return 0;
}
- if (argc != 4)
+ while ((opt = getopt(argc, argv, "t:")) > 0) {
+ switch (opt) {
+ case 't':
+ type = optarg;
+ break;
+ }
+ }
+
+ if (argc < optind + 2)
return COMMAND_ERROR_USAGE;
- if ((ret = mount(argv[1], argv[2], argv[3]))) {
+ if ((ret = mount(argv[optind], type, argv[optind + 1]))) {
perror("mount");
return 1;
}
@@ -56,8 +67,9 @@ static int do_mount(int argc, char *argv[])
}
BAREBOX_CMD_HELP_START(mount)
-BAREBOX_CMD_HELP_USAGE("mount [<device> <fstype> <mountpoint>]\n")
+BAREBOX_CMD_HELP_USAGE("mount [[-t <fstype] <device> <mountpoint>]\n")
BAREBOX_CMD_HELP_SHORT("Mount a filesystem of a given type to a mountpoint.\n")
+BAREBOX_CMD_HELP_SHORT("If no fstpye is specified detected it.\n")
BAREBOX_CMD_HELP_SHORT("If no argument is given, list mounted filesystems.\n")
BAREBOX_CMD_HELP_END
diff --git a/common/command.c b/common/command.c
index c18998c129..2bfc5117e8 100644
--- a/common/command.c
+++ b/common/command.c
@@ -38,26 +38,6 @@
LIST_HEAD(command_list);
EXPORT_SYMBOL(command_list);
-#ifdef CONFIG_SHELL_HUSH
-
-static int do_exit(int argc, char *argv[])
-{
- int r;
-
- r = 0;
- if (argc > 1)
- r = simple_strtoul(argv[1], NULL, 0);
-
- return -r - 2;
-}
-
-BAREBOX_CMD_START(exit)
- .cmd = do_exit,
- .usage = "exit script",
-BAREBOX_CMD_END
-
-#endif
-
void barebox_cmd_usage(struct command *cmdtp)
{
#ifdef CONFIG_LONGHELP
diff --git a/common/filetype.c b/common/filetype.c
index 1a5b82da47..e736d43efe 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -22,6 +22,7 @@
#include <common.h>
#include <filetype.h>
#include <asm/byteorder.h>
+#include <asm/unaligned.h>
#include <fcntl.h>
#include <fs.h>
#include <malloc.h>
@@ -40,6 +41,7 @@ static const char *filetype_str[] = {
[filetype_aimage] = "Android boot image",
[filetype_sh] = "Bourne Shell",
[filetype_mips_barebox] = "MIPS barebox image",
+ [filetype_fat] = "FAT filesytem",
};
const char *file_type_to_string(enum filetype f)
@@ -50,6 +52,22 @@ const char *file_type_to_string(enum filetype f)
return NULL;
}
+static int is_fat(u8 *buf)
+{
+ if (get_unaligned_le16(&buf[510]) != 0xAA55)
+ return 0;
+
+ /* FAT */
+ if ((get_unaligned_le32(&buf[54]) & 0xFFFFFF) == 0x544146)
+ return 1;
+
+ /* FAT32 */
+ if ((get_unaligned_le32(&buf[82]) & 0xFFFFFF) == 0x544146)
+ return 1;
+
+ return 0;
+}
+
enum filetype file_detect_type(void *_buf)
{
u32 *buf = _buf;
@@ -81,6 +99,8 @@ enum filetype file_detect_type(void *_buf)
return filetype_aimage;
if (strncmp(buf8 + 0x10, "barebox", 7) == 0)
return filetype_mips_barebox;
+ if (is_fat(buf8))
+ return filetype_fat;
return filetype_unknown;
}
diff --git a/common/hush.c b/common/hush.c
index 8200931387..61aac13d1b 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -557,6 +557,18 @@ static int builtin_getopt(struct p_context *ctx, struct child_prog *child,
}
#endif
+static int builtin_exit(struct p_context *ctx, struct child_prog *child,
+ int argc, char *argv[])
+{
+ int r;
+
+ r = last_return_code;
+ if (argc > 1)
+ r = simple_strtoul(argv[1], NULL, 0);
+
+ return -r - 2;
+}
+
static void remove_quotes_in_str(char *src)
{
char *trg = src;
@@ -773,10 +785,17 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi)
remove_quotes(globbuf.gl_pathc, globbuf.gl_pathv);
- if (!strcmp(globbuf.gl_pathv[0], "getopt"))
+ if (!strcmp(globbuf.gl_pathv[0], "getopt")) {
ret = builtin_getopt(ctx, child, globbuf.gl_pathc, globbuf.gl_pathv);
- else
+ } else if (!strcmp(globbuf.gl_pathv[0], "exit")) {
+ ret = builtin_exit(ctx, child, globbuf.gl_pathc, globbuf.gl_pathv);
+ } else {
ret = execute_binfmt(globbuf.gl_pathc, globbuf.gl_pathv);
+ if (ret < 0) {
+ printf("%s: %s\n", globbuf.gl_pathv[0], strerror(-ret));
+ ret = 127;
+ }
+ }
globfree(&globbuf);
@@ -1885,16 +1904,28 @@ BAREBOX_CMD_START(source)
BAREBOX_CMD_HELP(cmd_source_help)
BAREBOX_CMD_END
-#ifdef CONFIG_HUSH_GETOPT
-static int do_getopt(int argc, char *argv[])
+static int do_dummy_command(int argc, char *argv[])
{
/*
- * This function is never reached. The 'getopt' command is
- * only here to provide a help text for the getopt builtin.
+ * This function is never reached. These commands are only here to
+ * provide help texts for the builtins.
*/
return 0;
}
+static const __maybe_unused char cmd_exit_help[] =
+"Usage: exit [n]\n"
+"\n"
+"exit script with a status of n. If n is omitted, the exit status is that\n"
+"of the last command executed\n";
+
+BAREBOX_CMD_START(exit)
+ .cmd = do_dummy_command,
+ .usage = "exit script",
+ BAREBOX_CMD_HELP(cmd_exit_help)
+BAREBOX_CMD_END
+
+#ifdef CONFIG_HUSH_GETOPT
static const __maybe_unused char cmd_getopt_help[] =
"Usage: getopt <optstring> <var>\n"
"\n"
@@ -1905,7 +1936,7 @@ static const __maybe_unused char cmd_getopt_help[] =
"can be accessed starting from $1\n";
BAREBOX_CMD_START(getopt)
- .cmd = do_getopt,
+ .cmd = do_dummy_command,
.usage = "getopt <optstring> <var>",
BAREBOX_CMD_HELP(cmd_getopt_help)
BAREBOX_CMD_END
diff --git a/defaultenv-2/base/init/automount b/defaultenv-2/base/init/automount
index 7b533094ff..fe56d920e7 100644
--- a/defaultenv-2/base/init/automount
+++ b/defaultenv-2/base/init/automount
@@ -8,15 +8,15 @@ fi
# automount tftp server based on $eth0.serverip
mkdir -p /mnt/tftp
-automount /mnt/tftp 'ifup eth0 && mount $eth0.serverip tftp /mnt/tftp'
+automount /mnt/tftp 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp'
# automount nfs server example
#nfshost=somehost
#mkdir -p /mnt/${nfshost}
-#automount /mnt/$nfshost "ifup eth0 && mount ${nfshost}:/tftpboot nfs /mnt/${nfshost}"
+#automount /mnt/$nfshost "ifup eth0 && mount -t nfs ${nfshost}:/tftpboot /mnt/${nfshost}"
# FAT on usb disk example
#mkdir -p /mnt/fat
-#automount -d /mnt/fat 'usb && [ -e /dev/disk0.0 ] && mount /dev/disk0.0 fat /mnt/fat'
+#automount -d /mnt/fat 'usb && [ -e /dev/disk0.0 ] && mount /dev/disk0.0 /mnt/fat'
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 883b0e7bc9..adf8fcd160 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -18,5 +18,6 @@ source "drivers/input/Kconfig"
source "drivers/watchdog/Kconfig"
source "drivers/pwm/Kconfig"
source "drivers/dma/Kconfig"
+source "drivers/gpio/Kconfig"
endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index ea3263f615..1d14e6c3c8 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_PWM) += pwm/
obj-y += input/
obj-y += dma/
obj-y += watchdog/
+obj-y += gpio/
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
new file mode 100644
index 0000000000..022a30988e
--- /dev/null
+++ b/drivers/gpio/Kconfig
@@ -0,0 +1,13 @@
+config GPIOLIB
+ bool
+
+if GPIOLIB
+
+menu "GPIO "
+
+config GPIO_STMPE
+ depends on I2C_STMPE
+ bool "STMPE GPIO Expander"
+endmenu
+
+endif
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
new file mode 100644
index 0000000000..945122b083
--- /dev/null
+++ b/drivers/gpio/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_GPIOLIB) += gpio.o
+obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
new file mode 100644
index 0000000000..fa3b041534
--- /dev/null
+++ b/drivers/gpio/gpio-stmpe.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2012 Pengutronix
+ * Steffen Trumtrar <s.trumtrar@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <io.h>
+#include <gpio.h>
+#include <init.h>
+#include <mfd/stmpe-i2c.h>
+
+#define GPIO_BASE 0x80
+#define GPIO_SET (GPIO_BASE + 0x02)
+#define GPIO_CLR (GPIO_BASE + 0x04)
+#define GPIO_MP (GPIO_BASE + 0x06)
+#define GPIO_SET_DIR (GPIO_BASE + 0x08)
+#define GPIO_ED (GPIO_BASE + 0x0a)
+#define GPIO_RE (GPIO_BASE + 0x0c)
+#define GPIO_FE (GPIO_BASE + 0x0e)
+#define GPIO_PULL_UP (GPIO_BASE + 0x10)
+#define GPIO_AF (GPIO_BASE + 0x12)
+#define GPIO_LT (GPIO_BASE + 0x16)
+
+#define OFFSET(gpio) (0xff & (1 << (gpio)) ? 1 : 0)
+
+struct stmpe_gpio_chip {
+ struct gpio_chip chip;
+ struct stmpe_client_info *ci;
+};
+
+static void stmpe_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
+{
+ struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct stmpe_gpio_chip, chip);
+ struct stmpe_client_info *ci = (struct stmpe_client_info *)stmpegpio->ci;
+ int ret;
+ u8 val;
+
+ ci->read_reg(ci->stmpe, GPIO_MP + OFFSET(gpio), &val);
+
+ val |= 1 << (gpio % 8);
+
+ if (value)
+ ret = ci->write_reg(ci->stmpe, GPIO_SET + OFFSET(gpio), val);
+ else
+ ret = ci->write_reg(ci->stmpe, GPIO_CLR + OFFSET(gpio), val);
+
+ if (ret)
+ dev_err(chip->dev, "write failed!\n");
+}
+
+static int stmpe_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
+{
+ struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct stmpe_gpio_chip, chip);
+ struct stmpe_client_info *ci = (struct stmpe_client_info *)stmpegpio->ci;
+ int ret;
+ u8 val;
+
+ ci->read_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), &val);
+ val &= ~(1 << (gpio % 8));
+ ret = ci->write_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), val);
+
+ if (ret)
+ dev_err(chip->dev, "couldn't change direction. Write failed!\n");
+
+ return ret;
+}
+
+static int stmpe_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value)
+{
+ struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct stmpe_gpio_chip, chip);
+ struct stmpe_client_info *ci = (struct stmpe_client_info *)stmpegpio->ci;
+ int ret;
+ u8 val;
+
+ ci->read_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), &val);
+ val |= 1 << (gpio % 8);
+ ret = ci->write_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), val);
+
+ stmpe_gpio_set_value(chip, gpio, value);
+
+ if (ret)
+ dev_err(chip->dev, "couldn't change direction. Write failed!\n");
+
+ return ret;
+}
+
+static int stmpe_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
+{
+ struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct stmpe_gpio_chip, chip);
+ struct stmpe_client_info *ci = (struct stmpe_client_info *)stmpegpio->ci;
+ u8 val;
+ int ret;
+
+ ret = ci->read_reg(ci->stmpe, GPIO_MP + OFFSET(gpio), &val);
+
+ if (ret)
+ dev_err(chip->dev, "read failed\n");
+
+ return val & (1 << (gpio % 8)) ? 1 : 0;
+}
+
+static struct gpio_ops stmpe_gpio_ops = {
+ .direction_input = stmpe_gpio_direction_input,
+ .direction_output = stmpe_gpio_direction_output,
+ .get = stmpe_gpio_get_value,
+ .set = stmpe_gpio_set_value,
+};
+
+static int stmpe_gpio_probe(struct device_d *dev)
+{
+ struct stmpe_gpio_chip *stmpegpio;
+ struct stmpe_client_info *ci;
+ int ret;
+
+ stmpegpio = xzalloc(sizeof(*stmpegpio));
+
+ stmpegpio->chip.ops = &stmpe_gpio_ops;
+ stmpegpio->ci = dev->platform_data;
+
+ ci = (struct stmpe_client_info *)stmpegpio->ci;
+
+ if (ci->stmpe->pdata->gpio_base)
+ stmpegpio->chip.base = ci->stmpe->pdata->gpio_base;
+ else
+ stmpegpio->chip.base = -1;
+ stmpegpio->chip.ngpio = 16;
+ stmpegpio->chip.dev = dev;
+
+ ret = gpiochip_add(&stmpegpio->chip);
+
+ if (ret) {
+ dev_err(dev, "couldn't add gpiochip\n");
+ return ret;
+ }
+
+ dev_info(dev, "probed stmpe gpiochip%d with base %d\n", dev->id, stmpegpio->chip.base);
+ return 0;
+}
+
+static struct driver_d stmpe_gpio_driver = {
+ .name = "stmpe-gpio",
+ .probe = stmpe_gpio_probe,
+};
+
+static int stmpe_gpio_add(void)
+{
+ return register_driver(&stmpe_gpio_driver);
+}
+coredevice_initcall(stmpe_gpio_add);
diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c
new file mode 100644
index 0000000000..6ad8d274e7
--- /dev/null
+++ b/drivers/gpio/gpio.c
@@ -0,0 +1,134 @@
+#include <common.h>
+#include <gpio.h>
+#include <errno.h>
+
+static LIST_HEAD(chip_list);
+
+#define ARCH_NR_GPIOS 256
+
+static struct gpio_chip *gpio_desc[ARCH_NR_GPIOS];
+
+static int gpio_is_valid(unsigned gpio)
+{
+ if (gpio < ARCH_NR_GPIOS)
+ return 1;
+ return 0;
+}
+
+void gpio_set_value(unsigned gpio, int value)
+{
+ struct gpio_chip *chip = gpio_desc[gpio];
+
+ if (!gpio_is_valid(gpio))
+ return;
+ if (!chip)
+ return;
+ if (!chip->ops->set)
+ return;
+ chip->ops->set(chip, gpio - chip->base, value);
+}
+EXPORT_SYMBOL(gpio_set_value);
+
+int gpio_get_value(unsigned gpio)
+{
+ struct gpio_chip *chip = gpio_desc[gpio];
+
+ if (!gpio_is_valid(gpio))
+ return -EINVAL;
+ if (!chip)
+ return -ENODEV;
+ if (!chip->ops->get)
+ return -ENOSYS;
+ return chip->ops->get(chip, gpio - chip->base);
+}
+EXPORT_SYMBOL(gpio_get_value);
+
+int gpio_direction_output(unsigned gpio, int value)
+{
+ struct gpio_chip *chip = gpio_desc[gpio];
+
+ if (!gpio_is_valid(gpio))
+ return -EINVAL;
+ if (!chip)
+ return -ENODEV;
+ if (!chip->ops->direction_output)
+ return -ENOSYS;
+ return chip->ops->direction_output(chip, gpio - chip->base, value);
+}
+EXPORT_SYMBOL(gpio_direction_output);
+
+int gpio_direction_input(unsigned gpio)
+{
+ struct gpio_chip *chip = gpio_desc[gpio];
+
+ if (!gpio_is_valid(gpio))
+ return -EINVAL;
+ if (!chip)
+ return -ENODEV;
+ if (!chip->ops->direction_input)
+ return -ENOSYS;
+ return chip->ops->direction_input(chip, gpio - chip->base);
+}
+EXPORT_SYMBOL(gpio_direction_input);
+
+static int gpiochip_find_base(int start, int ngpio)
+{
+ int i;
+ int spare = 0;
+ int base = -ENOSPC;
+
+ if (start < 0)
+ start = 0;
+
+ for (i = start; i < ARCH_NR_GPIOS; i++) {
+ struct gpio_chip *chip = gpio_desc[i];
+
+ if (!chip) {
+ spare++;
+ if (spare == ngpio) {
+ base = i + 1 - ngpio;
+ break;
+ }
+ } else {
+ spare = 0;
+ i += chip->ngpio - 1;
+ }
+ }
+
+ if (gpio_is_valid(base))
+ debug("%s: found new base at %d\n", __func__, base);
+ return base;
+}
+
+int gpiochip_add(struct gpio_chip *chip)
+{
+ int base, i;
+
+ base = gpiochip_find_base(chip->base, chip->ngpio);
+ if (base < 0)
+ return base;
+
+ if (chip->base >= 0 && chip->base != base)
+ return -EBUSY;
+
+ chip->base = base;
+
+ list_add_tail(&chip->list, &chip_list);
+
+ for (i = chip->base; i < chip->base + chip->ngpio; i++)
+ gpio_desc[i] = chip;
+
+ return 0;
+}
+
+int gpio_get_num(struct device_d *dev, int gpio)
+{
+ struct gpio_chip *chip;
+
+ list_for_each_entry(chip, &chip_list, list) {
+ if (chip->dev == dev)
+ return chip->base + gpio;
+ }
+
+ return -ENODEV;
+}
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index af67935092..20eef86e39 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -33,4 +33,8 @@ config I2C_TWL6030
select I2C_TWLCORE
bool "TWL6030 driver"
+config I2C_STMPE
+ depends on I2C
+ bool "STMPE-i2c driver"
+
endmenu
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index e11223b1f9..792ae2da8f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_I2C_LP3972) += lp3972.o
obj-$(CONFIG_I2C_TWLCORE) += twl-core.o
obj-$(CONFIG_I2C_TWL4030) += twl4030.o
obj-$(CONFIG_I2C_TWL6030) += twl6030.o
+obj-$(CONFIG_I2C_STMPE) += stmpe-i2c.o
diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
new file mode 100644
index 0000000000..4af8b7b88c
--- /dev/null
+++ b/drivers/mfd/stmpe-i2c.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2012 Pengutronix
+ * Steffen Trumtrar <s.trumtrar@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <driver.h>
+#include <xfuncs.h>
+#include <errno.h>
+
+#include <i2c/i2c.h>
+#include <mfd/stmpe-i2c.h>
+
+#define DRIVERNAME "stmpe-i2c"
+
+#define to_stmpe(a) container_of(a, struct stmpe, cdev)
+
+int stmpe_reg_read(struct stmpe *stmpe, u32 reg, u8 *val)
+{
+ int ret;
+
+ ret = i2c_read_reg(stmpe->client, reg, val, 1);
+
+ return ret == 1 ? 0 : ret;
+}
+EXPORT_SYMBOL(stmpe_reg_read)
+
+int stmpe_reg_write(struct stmpe *stmpe, u32 reg, u8 val)
+{
+ int ret;
+
+ ret = i2c_write_reg(stmpe->client, reg, &val, 1);
+
+ return ret == 1 ? 0 : ret;
+}
+EXPORT_SYMBOL(stmpe_reg_write)
+
+int stmpe_set_bits(struct stmpe *stmpe, u32 reg, u8 mask, u8 val)
+{
+ u8 tmp;
+ int err;
+
+ err = stmpe_reg_read(stmpe, reg, &tmp);
+ tmp = (tmp & ~mask) | val;
+
+ if (!err)
+ err = stmpe_reg_write(stmpe, reg, tmp);
+
+ return err;
+}
+EXPORT_SYMBOL(stmpe_set_bits);
+
+static ssize_t stmpe_read(struct cdev *cdev, void *_buf, size_t count, loff_t offset, ulong flags)
+{
+ struct stmpe *stmpe = to_stmpe(cdev);
+ u8 *buf = _buf;
+ size_t i = count;
+ int err;
+
+ while (i) {
+ err = stmpe_reg_read(stmpe, offset, buf);
+ if (err)
+ return (ssize_t)err;
+ buf++;
+ i--;
+ offset++;
+ }
+
+ return count;
+}
+
+static ssize_t stmpe_write(struct cdev *cdev, const void *_buf, size_t count, loff_t offset, ulong flags)
+{
+ struct stmpe *stmpe = to_stmpe(cdev);
+ const u8 *buf = _buf;
+ size_t i = count;
+ int err;
+
+ while (i) {
+ err = stmpe_reg_write(stmpe, offset, *buf);
+ if (err)
+ return (ssize_t)err;
+ buf++;
+ i--;
+ offset++;
+ }
+
+ return count;
+}
+
+static struct file_operations stmpe_fops = {
+ .lseek = dev_lseek_default,
+ .read = stmpe_read,
+ .write = stmpe_write,
+};
+
+static int stmpe_probe(struct device_d *dev)
+{
+ struct stmpe_platform_data *pdata = dev->platform_data;
+ struct stmpe *stmpe_dev;
+ struct stmpe_client_info *i2c_ci;
+
+ if (!pdata) {
+ dev_dbg(dev, "no platform data\n");
+ return -ENODEV;
+ }
+
+ stmpe_dev = xzalloc(sizeof(struct stmpe));
+ stmpe_dev->cdev.name = DRIVERNAME;
+ stmpe_dev->client = to_i2c_client(dev);
+ stmpe_dev->cdev.size = 191; /* 191 known registers */
+ stmpe_dev->cdev.dev = dev;
+ stmpe_dev->cdev.ops = &stmpe_fops;
+ stmpe_dev->pdata = pdata;
+ dev->priv = stmpe_dev;
+
+ i2c_ci = xzalloc(sizeof(struct stmpe_client_info));
+ i2c_ci->stmpe = stmpe_dev;
+ i2c_ci->read_reg = stmpe_reg_read;
+ i2c_ci->write_reg = stmpe_reg_write;
+
+ if (pdata->blocks &= STMPE_BLOCK_GPIO)
+ add_generic_device("stmpe-gpio", DEVICE_ID_DYNAMIC, NULL, 0, 0, IORESOURCE_MEM, i2c_ci);
+
+ devfs_create(&stmpe_dev->cdev);
+
+ return 0;
+}
+
+static struct driver_d stmpe_driver = {
+ .name = DRIVERNAME,
+ .probe = stmpe_probe,
+};
+
+static int stmpe_init(void)
+{
+ register_driver(&stmpe_driver);
+ return 0;
+}
+
+device_initcall(stmpe_init);
diff --git a/fs/Kconfig b/fs/Kconfig
index b75820f4a0..4c66543290 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1,6 +1,11 @@
menu "Filesystem support "
+config FS
+ bool
+ default y
+ select FILETYPE
+
config FS_AUTOMOUNT
bool
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 5e6c81c358..01724a234f 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -430,6 +430,7 @@ static struct fs_driver_d fat_driver = {
.write = fat_write,
.truncate = fat_truncate,
#endif
+ .type = filetype_fat,
.flags = 0,
.drv = {
.probe = fat_probe,
diff --git a/fs/fs.c b/fs/fs.c
index 0b376a544b..8ab1a3a7ef 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -954,6 +954,28 @@ int register_fs_driver(struct fs_driver_d *fsdrv)
}
EXPORT_SYMBOL(register_fs_driver);
+static const char *detect_fs(const char *filename)
+{
+ enum filetype type = file_name_detect_type(filename);
+ struct driver_d *drv;
+ struct fs_driver_d *fdrv;
+
+ if (type == filetype_unknown)
+ return NULL;
+
+ for_each_driver(drv) {
+ if (drv->bus != &fs_bus)
+ continue;
+
+ fdrv = drv_to_fs_driver(drv);
+
+ if (type == fdrv->type)
+ return drv->name;
+ }
+
+ return NULL;
+}
+
/*
* Mount a device to a directory.
* We do this by registering a new device on which the filesystem
@@ -985,6 +1007,12 @@ int mount(const char *device, const char *fsname, const char *_path)
}
}
+ if (!fsname)
+ fsname = detect_fs(device);
+
+ if (!fsname)
+ return -ENOENT;
+
fsdev = xzalloc(sizeof(struct fs_device_d));
fsdev->backingstore = xstrdup(device);
safe_strncpy(fsdev->dev.name, fsname, MAX_DRIVER_NAME);
@@ -1222,7 +1250,7 @@ int rmdir (const char *pathname)
fsdev = get_fs_device_and_root_path(&p);
if (!fsdev) {
- ret = -ENOENT;
+ ret = -ENODEV;
goto out;
}
fsdrv = fsdev->driver;
diff --git a/include/driver.h b/include/driver.h
index 0a8dc8edd3..0fecc7a670 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -127,9 +127,9 @@ struct driver_d {
#define RW_SIZE_MASK 0x7
/* dynamically assign the next free id */
-#define DEVICE_ID_DYNAMIC -1
+#define DEVICE_ID_DYNAMIC -2
/* do not use an id (only one device available */
-#define DEVICE_ID_SINGLE -2
+#define DEVICE_ID_SINGLE -1
/* Register devices and drivers.
*/
diff --git a/include/filetype.h b/include/filetype.h
index f5de8ed2b5..179ec0f5eb 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -18,6 +18,7 @@ enum filetype {
filetype_aimage,
filetype_sh,
filetype_mips_barebox,
+ filetype_fat,
};
const char *file_type_to_string(enum filetype f);
diff --git a/include/fs.h b/include/fs.h
index c0b9f71fbd..22470e6379 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -2,6 +2,7 @@
#define __FS_H
#include <driver.h>
+#include <filetype.h>
#define PATH_MAX 1024 /* include/linux/limits.h */
@@ -72,6 +73,8 @@ struct fs_driver_d {
struct driver_d drv;
+ enum filetype type;
+
unsigned long flags;
};
@@ -93,6 +96,8 @@ struct fs_device_d {
struct list_head list;
};
+#define drv_to_fs_driver(d) container_of(d, struct fs_driver_d, drv)
+
/*
* standard posix file functions
*/
diff --git a/include/gpio.h b/include/gpio.h
index b7d840211a..9fb11c3268 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -5,10 +5,35 @@
static inline int gpio_request(unsigned gpio, const char *label)
{
- return 0;
+ return 0;
}
static inline void gpio_free(unsigned gpio)
{
}
+
+struct gpio_chip;
+
+struct gpio_ops {
+ int (*direction_input)(struct gpio_chip *chip, unsigned offset);
+ int (*direction_output)(struct gpio_chip *chip, unsigned offset, int value);
+ int (*get)(struct gpio_chip *chip, unsigned offset);
+ void (*set)(struct gpio_chip *chip, unsigned offset, int value);
+};
+
+struct gpio_chip {
+ struct device_d *dev;
+
+ int base;
+ int ngpio;
+
+ struct gpio_ops *ops;
+
+ struct list_head list;
+};
+
+int gpiochip_add(struct gpio_chip *chip);
+
+int gpio_get_num(struct device_d *dev, int gpio);
+
#endif /* __GPIO_H */
diff --git a/include/mfd/stmpe-i2c.h b/include/mfd/stmpe-i2c.h
new file mode 100644
index 0000000000..5f073d22d2
--- /dev/null
+++ b/include/mfd/stmpe-i2c.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 Pengutronix
+ * Steffen Trumtrar <s.trumtrar@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#ifndef __ASM_ARCH_STMPE_H
+#define __ASM_ARCH_STMPE_H
+
+enum stmpe_revision {
+ STMPE610,
+ STMPE801,
+ STMPE811,
+ STMPE1601,
+ STMPE2401,
+ STMPE2403,
+ STMPE_NBR_PARTS
+};
+
+enum stmpe_blocks {
+ STMPE_BLOCK_GPIO = 1 << 0,
+ STMPE_BLOCK_KEYPAD = 1 << 1,
+ STMPE_BLOCK_TOUCHSCREEN = 1 << 2,
+ STMPE_BLOCK_ADC = 1 << 3,
+ STMPE_BLOCK_PWM = 1 << 4,
+ STMPE_BLOCK_ROTATOR = 1 << 5,
+};
+
+struct stmpe_platform_data {
+ enum stmpe_revision revision;
+ enum stmpe_blocks blocks;
+ int gpio_base;
+};
+
+struct stmpe {
+ struct cdev cdev;
+ struct i2c_client *client;
+ struct stmpe_platform_data *pdata;
+};
+
+struct stmpe_client_info {
+ struct stmpe *stmpe;
+ int (*read_reg)(struct stmpe *stmpe, u32 reg, u8 *val);
+ int (*write_reg)(struct stmpe *stmpe, u32 reg, u8 val);
+};
+
+int stmpe_reg_read(struct stmpe *priv, u32 reg, u8 *val);
+int stmpe_reg_write(struct stmpe *priv, u32 reg, u8 val);
+int stmpe_set_bits(struct stmpe *priv, u32 reg, u8 mask, u8 val);
+
+#endif /* __ASM_ARCH_STMPE_H */