summaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorMichel Stam <m.stam@fugro.nl>2014-04-07 12:01:21 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-04-08 08:17:55 +0200
commit9c8f73ba86884026f4bbfc6f593d73741cfebcdc (patch)
treebaaf34e77043e6e264f5320210e1303ba8e7793a /arch/x86
parent4d94f56c6c5ba00d35d6b3e3a1862439b2ced3f0 (diff)
downloadbarebox-9c8f73ba86884026f4bbfc6f593d73741cfebcdc.tar.gz
x86: Add support for IDE on the legacy I/O ports
Signed-off-by: Michel Stam <michel@reverze.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/boards/x86_generic/Makefile3
-rw-r--r--arch/x86/boards/x86_generic/disk_bios_drive.c46
-rw-r--r--arch/x86/boards/x86_generic/envsector.h36
-rw-r--r--arch/x86/boards/x86_generic/generic_pc.c53
-rw-r--r--arch/x86/boards/x86_generic/intf_platform_ide.c93
-rw-r--r--arch/x86/boards/x86_generic/serial_ns16550.c47
6 files changed, 226 insertions, 52 deletions
diff --git a/arch/x86/boards/x86_generic/Makefile b/arch/x86/boards/x86_generic/Makefile
index 248240d..fca707d 100644
--- a/arch/x86/boards/x86_generic/Makefile
+++ b/arch/x86/boards/x86_generic/Makefile
@@ -1 +1,4 @@
obj-y += generic_pc.o
+obj-$(CONFIG_DISK_INTF_PLATFORM_IDE) += intf_platform_ide.o
+obj-$(CONFIG_DISK_BIOS) += disk_bios_drive.o
+obj-$(CONFIG_DRIVER_SERIAL_NS16550) += serial_ns16550.o
diff --git a/arch/x86/boards/x86_generic/disk_bios_drive.c b/arch/x86/boards/x86_generic/disk_bios_drive.c
new file mode 100644
index 0000000..f33f48c
--- /dev/null
+++ b/arch/x86/boards/x86_generic/disk_bios_drive.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2009 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.
+ *
+ *
+ */
+
+/**
+ * @file
+ * @brief Generic PC support for the BIOS disk interface
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <init.h>
+#include <linux/err.h>
+#include "envsector.h"
+
+static int bios_disk_init(void)
+{
+ struct cdev *cdev;
+
+ add_generic_device("biosdrive", DEVICE_ID_DYNAMIC, NULL, 0, 0,
+ IORESOURCE_MEM, NULL);
+
+ if (pers_env_size != PATCH_AREA_PERS_SIZE_UNUSED) {
+ cdev = devfs_add_partition("biosdisk0",
+ pers_env_storage * 512,
+ (unsigned)pers_env_size * 512,
+ DEVFS_PARTITION_FIXED, "env0");
+ printf("Partition: %ld\n", IS_ERR(cdev) ? PTR_ERR(cdev) : 0);
+ } else
+ printf("No persistent storage defined\n");
+
+ return 0;
+}
+device_initcall(bios_disk_init);
diff --git a/arch/x86/boards/x86_generic/envsector.h b/arch/x86/boards/x86_generic/envsector.h
new file mode 100644
index 0000000..86511c8
--- /dev/null
+++ b/arch/x86/boards/x86_generic/envsector.h
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ *
+ */
+
+/**
+ * @file
+ * @brief x86 Generic PC common definitions
+ */
+#ifndef __X86_ENVSECTOR_H
+#define __ENVSECTOR_H
+
+/*
+ * These datas are from the MBR, created by the linker and filled by the
+ * setup tool while installing barebox on the disk drive
+ */
+extern uint64_t pers_env_storage;
+extern uint16_t pers_env_size;
+extern uint8_t pers_env_drive;
+
+/**
+ * Persistent environment "not used" marker.
+ * Note: Must be in accordance to the value the tool "setup_mbr" writes.
+ */
+#define PATCH_AREA_PERS_SIZE_UNUSED 0x000
+
+#endif
diff --git a/arch/x86/boards/x86_generic/generic_pc.c b/arch/x86/boards/x86_generic/generic_pc.c
index 74a7224..5560efc 100644
--- a/arch/x86/boards/x86_generic/generic_pc.c
+++ b/arch/x86/boards/x86_generic/generic_pc.c
@@ -24,67 +24,16 @@
#include <driver.h>
#include <init.h>
#include <asm/syslib.h>
-#include <ns16550.h>
#include <linux/err.h>
-/*
- * These datas are from the MBR, created by the linker and filled by the
- * setup tool while installing barebox on the disk drive
- */
-extern uint64_t pers_env_storage;
-extern uint16_t pers_env_size;
-extern uint8_t pers_env_drive;
-
-/**
- * Persistent environment "not used" marker.
- * Note: Must be in accordance to the value the tool "setup_mbr" writes.
- */
-#define PATCH_AREA_PERS_SIZE_UNUSED 0x000
-
static int devices_init(void)
{
- struct cdev *cdev;
-
/* extended memory only */
add_mem_device("ram0", 0x0, bios_get_memsize() << 10,
IORESOURCE_MEM_WRITEABLE);
- add_generic_device("biosdrive", DEVICE_ID_DYNAMIC, NULL, 0, 0, IORESOURCE_MEM,
- NULL);
-
- if (pers_env_size != PATCH_AREA_PERS_SIZE_UNUSED) {
- cdev = devfs_add_partition("biosdisk0",
- pers_env_storage * 512,
- (unsigned)pers_env_size * 512,
- DEVFS_PARTITION_FIXED, "env0");
- printf("Partition: %ld\n", IS_ERR(cdev) ? PTR_ERR(cdev) : 0);
- } else
- printf("No persistent storage defined\n");
-
- return 0;
-}
-device_initcall(devices_init);
-
-#ifdef CONFIG_DRIVER_SERIAL_NS16550
-
-static struct NS16550_plat serial_plat = {
- .clock = 1843200,
- .reg_read = x86_uart_read,
- .reg_write = x86_uart_write,
-};
-
-static int pc_console_init(void)
-{
- barebox_set_model("X86 generic barebox");
- barebox_set_hostname("x86");
-
- /* Register the serial port */
- add_ns16550_device(DEVICE_ID_DYNAMIC, 0x3f8, 8, 0, &serial_plat);
-
return 0;
}
-console_initcall(pc_console_init);
-
-#endif
+device_initcall(devices_init);
/** @page generic_pc Generic PC based bootloader
diff --git a/arch/x86/boards/x86_generic/intf_platform_ide.c b/arch/x86/boards/x86_generic/intf_platform_ide.c
new file mode 100644
index 0000000..18a2620
--- /dev/null
+++ b/arch/x86/boards/x86_generic/intf_platform_ide.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2014 Juergen Beisert, Pengutronix, Michel Stam,
+ * Fugro Intersite
+ *
+ * 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.
+ *
+ *
+ */
+
+/**
+ * @file
+ * @brief Generic PC support for the IDE platform driver
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <init.h>
+#include <linux/err.h>
+#include <platform_ide.h>
+#include "envsector.h"
+
+static struct ide_port_info ide_plat = {
+ .ioport_shift = 0,
+ .dataif_be = 0,
+};
+
+static struct resource primary_ide_resources[] = {
+ {
+ .name = "base",
+ .start = 0x1f0,
+ .end = 0x1f7,
+ .flags = IORESOURCE_IO
+ },
+ {
+ .name = "alt",
+ .start = 0x3f6,
+ .end = 0x3f7,
+ .flags = IORESOURCE_IO
+ }
+};
+
+static struct resource secondary_ide_resources[] = {
+ {
+ .name = "base",
+ .start = 0x170,
+ .end = 0x177,
+ .flags = IORESOURCE_IO
+ },
+};
+
+static struct device_d primary_ide_device = {
+ .name = "ide_intf",
+ .id = 0,
+ .platform_data = &ide_plat,
+ .resource = primary_ide_resources,
+ .num_resources = ARRAY_SIZE(primary_ide_resources),
+};
+
+static struct device_d secondary_ide_device = {
+ .name = "ide_intf",
+ .id = 1,
+ .platform_data = &ide_plat,
+ .resource = secondary_ide_resources,
+ .num_resources = ARRAY_SIZE(secondary_ide_resources),
+};
+
+static int platform_ide_init(void)
+{
+ struct cdev *cdev;
+
+ platform_device_register(&primary_ide_device);
+ platform_device_register(&secondary_ide_device);
+
+ if (pers_env_size != PATCH_AREA_PERS_SIZE_UNUSED) {
+ cdev = devfs_add_partition("ata0",
+ pers_env_storage * 512,
+ (unsigned)pers_env_size * 512,
+ DEVFS_PARTITION_FIXED, "env0");
+ printf("Partition: %ld\n", IS_ERR(cdev) ? PTR_ERR(cdev) : 0);
+ } else
+ printf("No persistent storage defined\n");
+
+ return 0;
+}
+device_initcall(platform_ide_init);
diff --git a/arch/x86/boards/x86_generic/serial_ns16550.c b/arch/x86/boards/x86_generic/serial_ns16550.c
new file mode 100644
index 0000000..cae61df
--- /dev/null
+++ b/arch/x86/boards/x86_generic/serial_ns16550.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2009 Juergen Beisert, Pengutronix, Michel Stam,
+ * Fugro Intersite
+ *
+ * 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.
+ *
+ *
+ */
+
+/**
+ * @file
+ * @brief Generic PC support to let barebox acting as a boot loader
+ */
+
+#include <common.h>
+#include <types.h>
+#include <driver.h>
+#include <init.h>
+#include <asm/syslib.h>
+#include <ns16550.h>
+#include <linux/err.h>
+
+static struct NS16550_plat serial_plat = {
+ .clock = 1843200,
+ .reg_read = x86_uart_read,
+ .reg_write = x86_uart_write,
+};
+
+static int pc_console_init(void)
+{
+ barebox_set_model("X86 generic barebox");
+ barebox_set_hostname("x86");
+
+ /* Register the serial port */
+ add_ns16550_device(DEVICE_ID_DYNAMIC, 0x3f8, 8, 0, &serial_plat);
+
+ return 0;
+}
+console_initcall(pc_console_init);