Vladimir Serbinenko (phcoder(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4778
-gerrit
commit 22399fc470d884042cb95c5166081e49077e84ce
Author: Vladimir Serbinenko <phcoder(a)gmail.com>
Date: Wed Jan 22 17:12:35 2014 +0100
lenovo/x230: Add missing copyright line.
Change-Id: I5ecd25e23cebf83d4ae9300307aaac527e05c377
Signed-off-by: Vladimir Serbinenko <phcoder(a)gmail.com>
---
src/mainboard/lenovo/x230/cmos.layout | 1 +
src/mainboard/lenovo/x230/dsdt.asl | 1 +
src/mainboard/lenovo/x230/fadt.c | 1 +
src/mainboard/lenovo/x230/gpio.h | 1 +
src/mainboard/lenovo/x230/hda_verb.h | 1 +
src/mainboard/lenovo/x230/mainboard.c | 1 +
src/mainboard/lenovo/x230/romstage.c | 1 +
src/mainboard/lenovo/x230/smihandler.c | 1 +
src/mainboard/lenovo/x230/thermal.h | 1 +
9 files changed, 9 insertions(+)
diff --git a/src/mainboard/lenovo/x230/cmos.layout b/src/mainboard/lenovo/x230/cmos.layout
index 49a5fc1..6f8822f 100644
--- a/src/mainboard/lenovo/x230/cmos.layout
+++ b/src/mainboard/lenovo/x230/cmos.layout
@@ -2,6 +2,7 @@
## This file is part of the coreboot project.
##
## Copyright (C) 2007-2008 coresystems GmbH
+## Copyright (C) 2014 Vladimir Serbinenko
##
## 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
diff --git a/src/mainboard/lenovo/x230/dsdt.asl b/src/mainboard/lenovo/x230/dsdt.asl
index db2a793..12f40f8 100644
--- a/src/mainboard/lenovo/x230/dsdt.asl
+++ b/src/mainboard/lenovo/x230/dsdt.asl
@@ -3,6 +3,7 @@
*
* Copyright (C) 2007-2009 coresystems GmbH
* Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
+ * Copyright (C) 2014 Vladimir Serbinenko
*
* 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
diff --git a/src/mainboard/lenovo/x230/fadt.c b/src/mainboard/lenovo/x230/fadt.c
index 0ce3c72..27e6303 100644
--- a/src/mainboard/lenovo/x230/fadt.c
+++ b/src/mainboard/lenovo/x230/fadt.c
@@ -2,6 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2007-2009 coresystems GmbH
+ * Copyright (C) 2014 Vladimir Serbinenko
*
* 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
diff --git a/src/mainboard/lenovo/x230/gpio.h b/src/mainboard/lenovo/x230/gpio.h
index 1ede56e..f0a32a8 100644
--- a/src/mainboard/lenovo/x230/gpio.h
+++ b/src/mainboard/lenovo/x230/gpio.h
@@ -2,6 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2011 The Chromium OS Authors. All rights reserved.
+ * Copyright (C) 2014 Vladimir Serbinenko
*
* 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
diff --git a/src/mainboard/lenovo/x230/hda_verb.h b/src/mainboard/lenovo/x230/hda_verb.h
index 2e5c7e5..a319c28 100644
--- a/src/mainboard/lenovo/x230/hda_verb.h
+++ b/src/mainboard/lenovo/x230/hda_verb.h
@@ -2,6 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
+ * Copyright (C) 2014 Vladimir Serbinenko
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/src/mainboard/lenovo/x230/mainboard.c b/src/mainboard/lenovo/x230/mainboard.c
index 2974e00..6ae01fa 100644
--- a/src/mainboard/lenovo/x230/mainboard.c
+++ b/src/mainboard/lenovo/x230/mainboard.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2007-2009 coresystems GmbH
* Copyright (C) 2011-2012 Google Inc.
+ * Copyright (C) 2014 Vladimir Serbinenko
*
* 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
diff --git a/src/mainboard/lenovo/x230/romstage.c b/src/mainboard/lenovo/x230/romstage.c
index 00ce5a6..7aa2332 100644
--- a/src/mainboard/lenovo/x230/romstage.c
+++ b/src/mainboard/lenovo/x230/romstage.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2007-2010 coresystems GmbH
* Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
+ * Copyright (C) 2014 Vladimir Serbinenko
*
* 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
diff --git a/src/mainboard/lenovo/x230/smihandler.c b/src/mainboard/lenovo/x230/smihandler.c
index ca92091..bbe08e2 100644
--- a/src/mainboard/lenovo/x230/smihandler.c
+++ b/src/mainboard/lenovo/x230/smihandler.c
@@ -2,6 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2008-2009 coresystems GmbH
+ * Copyright (C) 2014 Vladimir Serbinenko
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/src/mainboard/lenovo/x230/thermal.h b/src/mainboard/lenovo/x230/thermal.h
index bae0e7f..ab24bb1 100644
--- a/src/mainboard/lenovo/x230/thermal.h
+++ b/src/mainboard/lenovo/x230/thermal.h
@@ -2,6 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2011 The Chromium OS Authors. All rights reserved.
+ * Copyright (C) 2014 Vladimir Serbinenko
*
* 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
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4784
-gerrit
commit 4ca493f114fd06b5fde40fd0887216a5271ba844
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Thu Jan 23 22:12:25 2014 +1100
superio/fintek: Add initial support for Fintek F71869AD
Data-sheet can be found here:
http://www.fintek.com.tw/files/productfiles/F71869_V1.1.pdf
Change-Id: I41f1ee20517dd179a4dee914ab7f6332739e326e
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/superio/fintek/Kconfig | 2 +
src/superio/fintek/Makefile.inc | 1 +
src/superio/fintek/f71869ad/Makefile.inc | 21 +++++
src/superio/fintek/f71869ad/chip.h | 33 ++++++++
src/superio/fintek/f71869ad/f71869ad.h | 35 ++++++++
.../fintek/f71869ad/f71869ad_early_serial.c | 67 +++++++++++++++
src/superio/fintek/f71869ad/superio.c | 95 ++++++++++++++++++++++
7 files changed, 254 insertions(+)
diff --git a/src/superio/fintek/Kconfig b/src/superio/fintek/Kconfig
index 67d2847..938494a 100644
--- a/src/superio/fintek/Kconfig
+++ b/src/superio/fintek/Kconfig
@@ -23,6 +23,8 @@ config SUPERIO_FINTEK_F71859
bool
config SUPERIO_FINTEK_F71863FG
bool
+config SUPERIO_FINTEK_F71869AD
+ bool
config SUPERIO_FINTEK_F71872
bool
config SUPERIO_FINTEK_F71889
diff --git a/src/superio/fintek/Makefile.inc b/src/superio/fintek/Makefile.inc
index 036bb2d..541a893 100644
--- a/src/superio/fintek/Makefile.inc
+++ b/src/superio/fintek/Makefile.inc
@@ -20,6 +20,7 @@
subdirs-y += f71805f
subdirs-y += f71859
subdirs-y += f71863fg
+subdirs-y += f71869ad
subdirs-y += f71872
subdirs-y += f71889
subdirs-y += f81865f
diff --git a/src/superio/fintek/f71869ad/Makefile.inc b/src/superio/fintek/f71869ad/Makefile.inc
new file mode 100644
index 0000000..117239a
--- /dev/null
+++ b/src/superio/fintek/f71869ad/Makefile.inc
@@ -0,0 +1,21 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+
+ramstage-$(CONFIG_SUPERIO_FINTEK_F71869AD) += superio.c
diff --git a/src/superio/fintek/f71869ad/chip.h b/src/superio/fintek/f71869ad/chip.h
new file mode 100644
index 0000000..43721ee
--- /dev/null
+++ b/src/superio/fintek/f71869ad/chip.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef SUPERIO_FINTEK_F71869AD_CHIPH_H
+#define SUPERIO_FINTEK_F71869AD_CHIPH_H
+
+#include <pc80/keyboard.h>
+#include <device/device.h>
+#include <uart8250.h>
+
+struct superio_fintek_f71869ad_config {
+
+ struct pc_keyboard keyboard;
+};
+
+#endif /* SUPERIO_FINTEK_F71869AD_CHIPH_H */
diff --git a/src/superio/fintek/f71869ad/f71869ad.h b/src/superio/fintek/f71869ad/f71869ad.h
new file mode 100644
index 0000000..78452d4
--- /dev/null
+++ b/src/superio/fintek/f71869ad/f71869ad.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef SUPERIO_FINTEK_F71869AD_F71869AD_H
+#define SUPERIO_FINTEK_F71869AD_F71869AD_H
+
+/* Logical Device Numbers (LDN). */
+#define F71869AD_FDC 0x00 /* Floppy */
+#define F71869AD_SP1 0x01 /* UART1 */
+#define F71869AD_SP2 0x02 /* UART2 */
+#define F71869AD_PP 0x03 /* Parallel port */
+#define F71869AD_HWM 0x04 /* Hardware monitor */
+#define F71869AD_KBC 0x05 /* PS/2 keyboard and mouse */
+#define F71869AD_GPIO 0x06 /* General Purpose I/O (GPIO) */
+#define F71869AD_BSEL 0x07 /* BSEL */
+#define F71869AD_PME 0x0a /* Power Management Events (PME) and ACPI */
+
+#endif /* SUPERIO_FINTEK_F71869AD_F71869AD_H */
diff --git a/src/superio/fintek/f71869ad/f71869ad_early_serial.c b/src/superio/fintek/f71869ad/f71869ad_early_serial.c
new file mode 100644
index 0000000..329441b
--- /dev/null
+++ b/src/superio/fintek/f71869ad/f71869ad_early_serial.c
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Pre-RAM driver for the Fintek F71869AD Super I/O chip.
+ *
+ * Derived from p.34 in vendor data-sheet:
+ *
+ * - default index port : 0x4E
+ * - default data port : 0x4F
+ *
+ * - enable configuration : 0x87
+ * - disable configuration : 0xAA
+ *
+ */
+
+#include <arch/io.h>
+#include "f71869ad.h"
+
+/*
+ * Enable configuration: pass entry key '0x87' into index port dev.
+ */
+static void pnp_enter_conf_state(device_t dev)
+{
+ u16 port = dev >> 8;
+ outb(0x87, port);
+ outb(0x87, port);
+}
+
+/*
+ * Disable configuration: pass exit key '0xAA' into index port dev.
+ */
+static void pnp_exit_conf_state(device_t dev)
+{
+ u16 port = dev >> 8;
+ outb(0xaa, port);
+}
+
+/*
+ * Bring up early serial debugging output before the RAM is initialized.
+ */
+static void f71869ad_enable_serial(device_t dev, u16 iobase)
+{
+ pnp_enter_conf_state(dev);
+ pnp_set_logical_device(dev);
+ pnp_set_enable(dev, 0);
+ pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
+ pnp_set_enable(dev, 1);
+ pnp_exit_conf_state(dev);
+}
diff --git a/src/superio/fintek/f71869ad/superio.c b/src/superio/fintek/f71869ad/superio.c
new file mode 100644
index 0000000..73bb9d8
--- /dev/null
+++ b/src/superio/fintek/f71869ad/superio.c
@@ -0,0 +1,95 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <arch/io.h>
+#include <device/device.h>
+#include <device/pnp.h>
+#include <superio/conf_mode.h>
+#include <console/console.h>
+#include <stdlib.h>
+#include <uart8250.h>
+
+#include "chip.h"
+#include "f71869ad.h"
+
+static void f71869ad_init(device_t dev)
+{
+ struct superio_fintek_f71869ad_config *conf = dev->chip_info;
+
+ if (!dev->enabled)
+ return;
+
+ switch(dev->path.pnp.device) {
+ /* TODO: Might potentially need code for HWM or FDC etc. */
+ case F71869AD_KBC:
+ res0 = find_resource(dev, PNP_IDX_IO0);
+ pc_keyboard_init(&conf->keyboard);
+ break;
+ }
+}
+
+static struct device_operations ops = {
+ .read_resources = pnp_read_resources,
+ .set_resources = pnp_set_resources,
+ .enable_resources = pnp_enable_resources,
+ .enable = pnp_alt_enable,
+ .init = f71869ad_init,
+ .ops_pnp_mode = &pnp_conf_mode_8787_aa,
+};
+
+/*
+ * io_info contains the mask 0x07f8. Given 16 register, each 8 bits wide of a
+ * logical device we need a mask of the following form:
+ *
+ * MSB LSB
+ * v v
+ * 0x[15..11][10..3][2..0]
+ * ------ ^^^^^ ^^^^
+ * null | |
+ * | +------ Register index
+ * |
+ * +------------- Comparse against base address and
+ * asserts a chip_select on match.
+ *
+ * i.e., 0x07F8 = [00000][11111111][000]
+ *
+ * XXX: verify flags and masks are correct.
+ */
+static struct pnp_info pnp_dev_info[] = {
+ { &ops, F71869AD_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_SP1, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_SP2, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_HWM, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
+ { &ops, F71869AD_KBC, PNP_IO0 | PNP_IRQ0 | PNP_IRQ1, {0x07ff, 0}, },
+ { &ops, F71869AD_GPIO, },
+ { &ops, F71869AD_BSEL, PNP_IO0, {0x07f8, 0}, },
+ { &ops, F71869AD_PME, },
+};
+
+static void enable_dev(device_t dev)
+{
+ pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
+}
+
+struct chip_operations superio_fintek_f71869ad_ops = {
+ CHIP_NAME("Fintek F71869AD Super I/O")
+ .enable_dev = enable_dev
+};
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4784
-gerrit
commit 98dda49e9936691bcc7cf241ee78d6a7d4e919ea
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Thu Jan 23 22:12:25 2014 +1100
Add initial support for Fintek F71869AD Super I/O.
Data-sheet can be found here:
http://www.fintek.com.tw/files/productfiles/F71869_V1.1.pdf
Change-Id: I41f1ee20517dd179a4dee914ab7f6332739e326e
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/superio/fintek/Kconfig | 2 +
src/superio/fintek/Makefile.inc | 1 +
src/superio/fintek/f71869ad/Makefile.inc | 21 +++++
src/superio/fintek/f71869ad/chip.h | 33 ++++++++
src/superio/fintek/f71869ad/f71869ad.h | 35 ++++++++
.../fintek/f71869ad/f71869ad_early_serial.c | 67 +++++++++++++++
src/superio/fintek/f71869ad/superio.c | 95 ++++++++++++++++++++++
7 files changed, 254 insertions(+)
diff --git a/src/superio/fintek/Kconfig b/src/superio/fintek/Kconfig
index 67d2847..938494a 100644
--- a/src/superio/fintek/Kconfig
+++ b/src/superio/fintek/Kconfig
@@ -23,6 +23,8 @@ config SUPERIO_FINTEK_F71859
bool
config SUPERIO_FINTEK_F71863FG
bool
+config SUPERIO_FINTEK_F71869AD
+ bool
config SUPERIO_FINTEK_F71872
bool
config SUPERIO_FINTEK_F71889
diff --git a/src/superio/fintek/Makefile.inc b/src/superio/fintek/Makefile.inc
index 036bb2d..541a893 100644
--- a/src/superio/fintek/Makefile.inc
+++ b/src/superio/fintek/Makefile.inc
@@ -20,6 +20,7 @@
subdirs-y += f71805f
subdirs-y += f71859
subdirs-y += f71863fg
+subdirs-y += f71869ad
subdirs-y += f71872
subdirs-y += f71889
subdirs-y += f81865f
diff --git a/src/superio/fintek/f71869ad/Makefile.inc b/src/superio/fintek/f71869ad/Makefile.inc
new file mode 100644
index 0000000..117239a
--- /dev/null
+++ b/src/superio/fintek/f71869ad/Makefile.inc
@@ -0,0 +1,21 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+
+ramstage-$(CONFIG_SUPERIO_FINTEK_F71869AD) += superio.c
diff --git a/src/superio/fintek/f71869ad/chip.h b/src/superio/fintek/f71869ad/chip.h
new file mode 100644
index 0000000..43721ee
--- /dev/null
+++ b/src/superio/fintek/f71869ad/chip.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef SUPERIO_FINTEK_F71869AD_CHIPH_H
+#define SUPERIO_FINTEK_F71869AD_CHIPH_H
+
+#include <pc80/keyboard.h>
+#include <device/device.h>
+#include <uart8250.h>
+
+struct superio_fintek_f71869ad_config {
+
+ struct pc_keyboard keyboard;
+};
+
+#endif /* SUPERIO_FINTEK_F71869AD_CHIPH_H */
diff --git a/src/superio/fintek/f71869ad/f71869ad.h b/src/superio/fintek/f71869ad/f71869ad.h
new file mode 100644
index 0000000..78452d4
--- /dev/null
+++ b/src/superio/fintek/f71869ad/f71869ad.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef SUPERIO_FINTEK_F71869AD_F71869AD_H
+#define SUPERIO_FINTEK_F71869AD_F71869AD_H
+
+/* Logical Device Numbers (LDN). */
+#define F71869AD_FDC 0x00 /* Floppy */
+#define F71869AD_SP1 0x01 /* UART1 */
+#define F71869AD_SP2 0x02 /* UART2 */
+#define F71869AD_PP 0x03 /* Parallel port */
+#define F71869AD_HWM 0x04 /* Hardware monitor */
+#define F71869AD_KBC 0x05 /* PS/2 keyboard and mouse */
+#define F71869AD_GPIO 0x06 /* General Purpose I/O (GPIO) */
+#define F71869AD_BSEL 0x07 /* BSEL */
+#define F71869AD_PME 0x0a /* Power Management Events (PME) and ACPI */
+
+#endif /* SUPERIO_FINTEK_F71869AD_F71869AD_H */
diff --git a/src/superio/fintek/f71869ad/f71869ad_early_serial.c b/src/superio/fintek/f71869ad/f71869ad_early_serial.c
new file mode 100644
index 0000000..329441b
--- /dev/null
+++ b/src/superio/fintek/f71869ad/f71869ad_early_serial.c
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Pre-RAM driver for the Fintek F71869AD Super I/O chip.
+ *
+ * Derived from p.34 in vendor data-sheet:
+ *
+ * - default index port : 0x4E
+ * - default data port : 0x4F
+ *
+ * - enable configuration : 0x87
+ * - disable configuration : 0xAA
+ *
+ */
+
+#include <arch/io.h>
+#include "f71869ad.h"
+
+/*
+ * Enable configuration: pass entry key '0x87' into index port dev.
+ */
+static void pnp_enter_conf_state(device_t dev)
+{
+ u16 port = dev >> 8;
+ outb(0x87, port);
+ outb(0x87, port);
+}
+
+/*
+ * Disable configuration: pass exit key '0xAA' into index port dev.
+ */
+static void pnp_exit_conf_state(device_t dev)
+{
+ u16 port = dev >> 8;
+ outb(0xaa, port);
+}
+
+/*
+ * Bring up early serial debugging output before the RAM is initialized.
+ */
+static void f71869ad_enable_serial(device_t dev, u16 iobase)
+{
+ pnp_enter_conf_state(dev);
+ pnp_set_logical_device(dev);
+ pnp_set_enable(dev, 0);
+ pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
+ pnp_set_enable(dev, 1);
+ pnp_exit_conf_state(dev);
+}
diff --git a/src/superio/fintek/f71869ad/superio.c b/src/superio/fintek/f71869ad/superio.c
new file mode 100644
index 0000000..73bb9d8
--- /dev/null
+++ b/src/superio/fintek/f71869ad/superio.c
@@ -0,0 +1,95 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <arch/io.h>
+#include <device/device.h>
+#include <device/pnp.h>
+#include <superio/conf_mode.h>
+#include <console/console.h>
+#include <stdlib.h>
+#include <uart8250.h>
+
+#include "chip.h"
+#include "f71869ad.h"
+
+static void f71869ad_init(device_t dev)
+{
+ struct superio_fintek_f71869ad_config *conf = dev->chip_info;
+
+ if (!dev->enabled)
+ return;
+
+ switch(dev->path.pnp.device) {
+ /* TODO: Might potentially need code for HWM or FDC etc. */
+ case F71869AD_KBC:
+ res0 = find_resource(dev, PNP_IDX_IO0);
+ pc_keyboard_init(&conf->keyboard);
+ break;
+ }
+}
+
+static struct device_operations ops = {
+ .read_resources = pnp_read_resources,
+ .set_resources = pnp_set_resources,
+ .enable_resources = pnp_enable_resources,
+ .enable = pnp_alt_enable,
+ .init = f71869ad_init,
+ .ops_pnp_mode = &pnp_conf_mode_8787_aa,
+};
+
+/*
+ * io_info contains the mask 0x07f8. Given 16 register, each 8 bits wide of a
+ * logical device we need a mask of the following form:
+ *
+ * MSB LSB
+ * v v
+ * 0x[15..11][10..3][2..0]
+ * ------ ^^^^^ ^^^^
+ * null | |
+ * | +------ Register index
+ * |
+ * +------------- Comparse against base address and
+ * asserts a chip_select on match.
+ *
+ * i.e., 0x07F8 = [00000][11111111][000]
+ *
+ * XXX: verify flags and masks are correct.
+ */
+static struct pnp_info pnp_dev_info[] = {
+ { &ops, F71869AD_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_SP1, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_SP2, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_HWM, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
+ { &ops, F71869AD_KBC, PNP_IO0 | PNP_IRQ0 | PNP_IRQ1, {0x07ff, 0}, },
+ { &ops, F71869AD_GPIO, },
+ { &ops, F71869AD_BSEL, PNP_IO0, {0x07f8, 0}, },
+ { &ops, F71869AD_PME, },
+};
+
+static void enable_dev(device_t dev)
+{
+ pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
+}
+
+struct chip_operations superio_fintek_f71869ad_ops = {
+ CHIP_NAME("Fintek F71869AD Super I/O")
+ .enable_dev = enable_dev
+};
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4784
-gerrit
commit 7976113521a1c4f5a603222a38ba0e96a0a47469
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Thu Jan 23 22:12:25 2014 +1100
Add initial support for Fintek F71869AD Super I/O.
Data-sheet can be found here:
http://www.fintek.com.tw/files/productfiles/F71869_V1.1.pdf
Change-Id: I41f1ee20517dd179a4dee914ab7f6332739e326e
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/superio/fintek/Kconfig | 2 +
src/superio/fintek/Makefile.inc | 1 +
src/superio/fintek/f71869ad/Makefile.inc | 21 +++++
src/superio/fintek/f71869ad/chip.h | 33 ++++++++
src/superio/fintek/f71869ad/f71869ad.h | 35 ++++++++
.../fintek/f71869ad/f71869ad_early_serial.c | 67 +++++++++++++++
src/superio/fintek/f71869ad/superio.c | 96 ++++++++++++++++++++++
7 files changed, 255 insertions(+)
diff --git a/src/superio/fintek/Kconfig b/src/superio/fintek/Kconfig
index 67d2847..938494a 100644
--- a/src/superio/fintek/Kconfig
+++ b/src/superio/fintek/Kconfig
@@ -23,6 +23,8 @@ config SUPERIO_FINTEK_F71859
bool
config SUPERIO_FINTEK_F71863FG
bool
+config SUPERIO_FINTEK_F71869AD
+ bool
config SUPERIO_FINTEK_F71872
bool
config SUPERIO_FINTEK_F71889
diff --git a/src/superio/fintek/Makefile.inc b/src/superio/fintek/Makefile.inc
index 036bb2d..541a893 100644
--- a/src/superio/fintek/Makefile.inc
+++ b/src/superio/fintek/Makefile.inc
@@ -20,6 +20,7 @@
subdirs-y += f71805f
subdirs-y += f71859
subdirs-y += f71863fg
+subdirs-y += f71869ad
subdirs-y += f71872
subdirs-y += f71889
subdirs-y += f81865f
diff --git a/src/superio/fintek/f71869ad/Makefile.inc b/src/superio/fintek/f71869ad/Makefile.inc
new file mode 100644
index 0000000..117239a
--- /dev/null
+++ b/src/superio/fintek/f71869ad/Makefile.inc
@@ -0,0 +1,21 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+
+ramstage-$(CONFIG_SUPERIO_FINTEK_F71869AD) += superio.c
diff --git a/src/superio/fintek/f71869ad/chip.h b/src/superio/fintek/f71869ad/chip.h
new file mode 100644
index 0000000..43721ee
--- /dev/null
+++ b/src/superio/fintek/f71869ad/chip.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef SUPERIO_FINTEK_F71869AD_CHIPH_H
+#define SUPERIO_FINTEK_F71869AD_CHIPH_H
+
+#include <pc80/keyboard.h>
+#include <device/device.h>
+#include <uart8250.h>
+
+struct superio_fintek_f71869ad_config {
+
+ struct pc_keyboard keyboard;
+};
+
+#endif /* SUPERIO_FINTEK_F71869AD_CHIPH_H */
diff --git a/src/superio/fintek/f71869ad/f71869ad.h b/src/superio/fintek/f71869ad/f71869ad.h
new file mode 100644
index 0000000..78452d4
--- /dev/null
+++ b/src/superio/fintek/f71869ad/f71869ad.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef SUPERIO_FINTEK_F71869AD_F71869AD_H
+#define SUPERIO_FINTEK_F71869AD_F71869AD_H
+
+/* Logical Device Numbers (LDN). */
+#define F71869AD_FDC 0x00 /* Floppy */
+#define F71869AD_SP1 0x01 /* UART1 */
+#define F71869AD_SP2 0x02 /* UART2 */
+#define F71869AD_PP 0x03 /* Parallel port */
+#define F71869AD_HWM 0x04 /* Hardware monitor */
+#define F71869AD_KBC 0x05 /* PS/2 keyboard and mouse */
+#define F71869AD_GPIO 0x06 /* General Purpose I/O (GPIO) */
+#define F71869AD_BSEL 0x07 /* BSEL */
+#define F71869AD_PME 0x0a /* Power Management Events (PME) and ACPI */
+
+#endif /* SUPERIO_FINTEK_F71869AD_F71869AD_H */
diff --git a/src/superio/fintek/f71869ad/f71869ad_early_serial.c b/src/superio/fintek/f71869ad/f71869ad_early_serial.c
new file mode 100644
index 0000000..329441b
--- /dev/null
+++ b/src/superio/fintek/f71869ad/f71869ad_early_serial.c
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Pre-RAM driver for the Fintek F71869AD Super I/O chip.
+ *
+ * Derived from p.34 in vendor data-sheet:
+ *
+ * - default index port : 0x4E
+ * - default data port : 0x4F
+ *
+ * - enable configuration : 0x87
+ * - disable configuration : 0xAA
+ *
+ */
+
+#include <arch/io.h>
+#include "f71869ad.h"
+
+/*
+ * Enable configuration: pass entry key '0x87' into index port dev.
+ */
+static void pnp_enter_conf_state(device_t dev)
+{
+ u16 port = dev >> 8;
+ outb(0x87, port);
+ outb(0x87, port);
+}
+
+/*
+ * Disable configuration: pass exit key '0xAA' into index port dev.
+ */
+static void pnp_exit_conf_state(device_t dev)
+{
+ u16 port = dev >> 8;
+ outb(0xaa, port);
+}
+
+/*
+ * Bring up early serial debugging output before the RAM is initialized.
+ */
+static void f71869ad_enable_serial(device_t dev, u16 iobase)
+{
+ pnp_enter_conf_state(dev);
+ pnp_set_logical_device(dev);
+ pnp_set_enable(dev, 0);
+ pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
+ pnp_set_enable(dev, 1);
+ pnp_exit_conf_state(dev);
+}
diff --git a/src/superio/fintek/f71869ad/superio.c b/src/superio/fintek/f71869ad/superio.c
new file mode 100644
index 0000000..fbc6f47
--- /dev/null
+++ b/src/superio/fintek/f71869ad/superio.c
@@ -0,0 +1,96 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <arch/io.h>
+#include <device/device.h>
+#include <device/pnp.h>
+#include <superio/conf_mode.h>
+#include <console/console.h>
+#include <stdlib.h>
+#include <uart8250.h>
+
+#include "chip.h"
+#include "f71869ad.h"
+
+static void f71869ad_init(device_t dev)
+{
+ struct superio_fintek_f71869ad_config *conf = dev->chip_info;
+ struct resource *res0;
+
+ if (!dev->enabled)
+ return;
+
+ switch(dev->path.pnp.device) {
+ /* TODO: Might potentially need code for HWM or FDC etc. */
+ case F71869AD_KBC:
+ res0 = find_resource(dev, PNP_IDX_IO0);
+ pc_keyboard_init(&conf->keyboard);
+ break;
+ }
+}
+
+static struct device_operations ops = {
+ .read_resources = pnp_read_resources,
+ .set_resources = pnp_set_resources,
+ .enable_resources = pnp_enable_resources,
+ .enable = pnp_alt_enable,
+ .init = f71869ad_init,
+ .ops_pnp_mode = &pnp_conf_mode_8787_aa,
+};
+
+/*
+ * io_info contains the mask 0x07f8. Given 16 register, each 8 bits wide of a
+ * logical we device we need a mask of the following form:
+ *
+ * MSB LSB
+ * v v
+ * 0x[15..11][10..3][2..0]
+ * ------ ^^^^^ ^^^^
+ * null | |
+ * | +------ Register index
+ * |
+ * +------------- Comparses agients base address and
+ * asserts a chip_select on match.
+ *
+ * i.e., 0x07F8 = [00000][11111111][000]
+ *
+ * XXX: verify flags and masks are correct.
+ */
+static struct pnp_info pnp_dev_info[] = {
+ { &ops, F71869AD_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_SP1, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_SP2, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, },
+ { &ops, F71869AD_HWM, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
+ { &ops, F71869AD_KBC, PNP_IO0 | PNP_IRQ0 | PNP_IRQ1, {0x07ff, 0}, },
+ { &ops, F71869AD_GPIO, },
+ { &ops, F71869AD_BSEL, PNP_IO0, {0x07f8, 0}, },
+ { &ops, F71869AD_PME, },
+};
+
+static void enable_dev(device_t dev)
+{
+ pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
+}
+
+struct chip_operations superio_fintek_f71869ad_ops = {
+ CHIP_NAME("Fintek F71869AD Super I/O")
+ .enable_dev = enable_dev
+};
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4783
-gerrit
commit 0ca7f300e8bfbf26b98597bc4f7191443ee2ed4d
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Thu Jan 23 08:30:42 2014 +1100
[Trivial]: Fix two warnings while building libpayload.
Decompartmentalise AHCI driver and add a few superficial comments while
here.
Change-Id: Ia1fd545b39868a81cbc311f6ffc786f9f1f61415
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
payloads/libpayload/drivers/Makefile.inc | 4 +
payloads/libpayload/drivers/storage/ahci.c | 106 +--------------------
.../drivers/storage/ahci_ata_read_sectors.c | 100 +++++++++++++++++++
.../drivers/storage/ahci_identify_device.c | 56 +++++++++++
.../drivers/storage/ahci_packet_read_cmd.c | 67 +++++++++++++
payloads/libpayload/drivers/storage/ahci_private.h | 21 +++-
payloads/libpayload/libc/hexdump.c | 2 +-
7 files changed, 250 insertions(+), 106 deletions(-)
diff --git a/payloads/libpayload/drivers/Makefile.inc b/payloads/libpayload/drivers/Makefile.inc
index a1891be..1db0b7a 100644
--- a/payloads/libpayload/drivers/Makefile.inc
+++ b/payloads/libpayload/drivers/Makefile.inc
@@ -54,10 +54,14 @@ libc-$(CONFIG_GEODELX_VIDEO_CONSOLE) += video/font8x16.c
libc-$(CONFIG_COREBOOT_VIDEO_CONSOLE) += video/corebootfb.c
libc-$(CONFIG_COREBOOT_VIDEO_CONSOLE) += video/font8x16.c
+# AHCI/ATAPI driver
libc-$(CONFIG_STORAGE) += storage/storage.c
libc-$(CONFIG_STORAGE_ATA) += storage/ata.c
libc-$(CONFIG_STORAGE_ATAPI) += storage/atapi.c
libc-$(CONFIG_STORAGE_AHCI) += storage/ahci.c
+libc-$(CONFIG_STORAGE_AHCI) += storage/ahci_ata_read_sectors.c
+libc-$(CONFIG_STORAGE_AHCI) += storage/ahci_identify_device.c
+libc-$(CONFIG_STORAGE_AHCI) += storage/ahci_packet_read_cmd.c
# USB stack
libc-$(CONFIG_USB) += usb/usbinit.c
diff --git a/payloads/libpayload/drivers/storage/ahci.c b/payloads/libpayload/drivers/storage/ahci.c
index ec4db4c..6d8abff 100644
--- a/payloads/libpayload/drivers/storage/ahci.c
+++ b/payloads/libpayload/drivers/storage/ahci.c
@@ -189,7 +189,7 @@ static void ahci_prdbuf_finalize(ahci_dev_t *const dev)
dev->buflen = 0;
}
-static ssize_t ahci_cmdslot_exec(ahci_dev_t *const dev)
+ssize_t ahci_cmdslot_exec(ahci_dev_t *const dev)
{
const int slotnum = 0; /* We always use the first slot. */
@@ -221,7 +221,7 @@ static ssize_t ahci_cmdslot_exec(ahci_dev_t *const dev)
}
}
-static size_t ahci_cmdslot_prepare(ahci_dev_t *const dev,
+size_t ahci_cmdslot_prepare(ahci_dev_t *const dev,
u8 *const user_buf, size_t buf_len,
const int out)
{
@@ -268,108 +268,6 @@ static size_t ahci_cmdslot_prepare(ahci_dev_t *const dev,
return read_count;
}
-static ssize_t ahci_ata_read_sectors(ata_dev_t *const ata_dev,
- const lba_t start, size_t count,
- u8 *const buf)
-{
- ahci_dev_t *const dev = (ahci_dev_t *)ata_dev;
-
- if (count == 0)
- return 0;
-
- if (ata_dev->read_cmd == ATA_READ_DMA) {
- if (start >= (1 << 28)) {
- printf("ahci: Sector is not 28-bit addressable.\n");
- return -1;
- } else if (count > 256) {
- printf("ahci: Sector count too high (max. 256).\n");
- count = 256;
- }
-#ifdef CONFIG_STORAGE_64BIT_LBA
- } else if (ata_dev->read_cmd == ATA_READ_DMA_EXT) {
- if (start >= (1ULL << 48)) {
- printf("ahci: Sector is not 48-bit addressable.\n");
- return -1;
- } else if (count > (64 * 1024)) {
- printf("ahci: Sector count too high (max. 65536).\n");
- count = 64 * 1024;
- }
-#endif
- } else {
- printf("ahci: Unsupported ATA read command (0x%x).\n",
- ata_dev->read_cmd);
- return -1;
- }
-
- const size_t bytes = count << ata_dev->sector_size_shift;
- const size_t bytes_feasible = ahci_cmdslot_prepare(dev, buf, bytes, 0);
- const size_t sectors = bytes_feasible >> ata_dev->sector_size_shift;
-
- dev->cmdtable->fis[ 0] = FIS_HOST_TO_DEVICE;
- dev->cmdtable->fis[ 1] = FIS_H2D_CMD;
- dev->cmdtable->fis[ 2] = ata_dev->read_cmd;
- dev->cmdtable->fis[ 4] = (start >> 0) & 0xff;
- dev->cmdtable->fis[ 5] = (start >> 8) & 0xff;
- dev->cmdtable->fis[ 6] = (start >> 16) & 0xff;
- dev->cmdtable->fis[ 7] = FIS_H2D_DEV_LBA;
- dev->cmdtable->fis[ 8] = (start >> 24) & 0xff;
-#ifdef CONFIG_STORAGE_64BIT_LBA
- if (ata_dev->read_cmd == ATA_READ_DMA_EXT) {
- dev->cmdtable->fis[ 9] = (start >> 32) & 0xff;
- dev->cmdtable->fis[10] = (start >> 40) & 0xff;
- }
-#endif
- dev->cmdtable->fis[12] = (sectors >> 0) & 0xff;
- dev->cmdtable->fis[13] = (sectors >> 8) & 0xff;
-
- if (ahci_cmdslot_exec(dev) < 0)
- return -1;
- else
- return dev->cmdlist->prd_bytes >> ata_dev->sector_size_shift;
-}
-
-static ssize_t ahci_packet_read_cmd(atapi_dev_t *const _dev,
- const u8 *const cmd, const size_t cmdlen,
- u8 *const buf, const size_t buflen)
-{
- ahci_dev_t *const dev = (ahci_dev_t *)_dev;
-
- if ((cmdlen != 12) && (cmdlen != 16)) {
- printf("ahci: Only 12- and 16-byte packet commands allowed.\n");
- return -1;
- }
-
- const size_t len = ahci_cmdslot_prepare(dev, buf, buflen, 0);
- u16 byte_limit = MIN(len, 63 * 1024); /* like Linux */
- if (byte_limit & 1) ++byte_limit; /* even limit */
-
- dev->cmdlist[0].cmd |= CMD_ATAPI;
- dev->cmdtable->fis[0] = FIS_HOST_TO_DEVICE;
- dev->cmdtable->fis[1] = FIS_H2D_CMD;
- dev->cmdtable->fis[2] = ATA_PACKET;
- dev->cmdtable->fis[5] = byte_limit & 0xff;
- dev->cmdtable->fis[6] = byte_limit >> 8;
- memcpy((void *)dev->cmdtable->atapi_cmd, cmd, cmdlen);
-
- return ahci_cmdslot_exec(dev);
-}
-
-static int ahci_identify_device(ata_dev_t *const ata_dev, u8 *const buf)
-{
- ahci_dev_t *const dev = (ahci_dev_t *)ata_dev;
-
- ahci_cmdslot_prepare(dev, buf, 512, 0);
-
- dev->cmdtable->fis[0] = FIS_HOST_TO_DEVICE;
- dev->cmdtable->fis[1] = FIS_H2D_CMD;
- dev->cmdtable->fis[2] = ata_dev->identify_cmd;
-
- if ((ahci_cmdslot_exec(dev) < 0) || (dev->cmdlist->prd_bytes != 512))
- return -1;
- else
- return 0;
-}
-
static int ahci_dev_init(hba_ctrl_t *const ctrl,
hba_port_t *const port,
const int portnum)
diff --git a/payloads/libpayload/drivers/storage/ahci_ata_read_sectors.c b/payloads/libpayload/drivers/storage/ahci_ata_read_sectors.c
new file mode 100644
index 0000000..1efec23
--- /dev/null
+++ b/payloads/libpayload/drivers/storage/ahci_ata_read_sectors.c
@@ -0,0 +1,100 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2012 secunet Security Networks AG
+ * Copyright (C) 2013 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <libpayload.h>
+#include <pci.h>
+#include <storage/ata.h>
+#include <storage/ahci.h>
+
+#include "ahci_private.h"
+
+
+ssize_t ahci_ata_read_sectors(ata_dev_t *const ata_dev,
+ const lba_t start, size_t count,
+ u8 *const buf)
+{
+ ahci_dev_t *const dev = (ahci_dev_t *)ata_dev;
+
+ if (count == 0)
+ return 0;
+
+ if (ata_dev->read_cmd == ATA_READ_DMA) {
+ if (start >= (1 << 28)) {
+ printf("ahci: Sector is not 28-bit addressable.\n");
+ return -1;
+ } else if (count > 256) {
+ printf("ahci: Sector count too high (max. 256).\n");
+ count = 256;
+ }
+#ifdef CONFIG_STORAGE_64BIT_LBA
+ } else if (ata_dev->read_cmd == ATA_READ_DMA_EXT) {
+ if (start >= (1ULL << 48)) {
+ printf("ahci: Sector is not 48-bit addressable.\n");
+ return -1;
+ } else if (count > (64 * 1024)) {
+ printf("ahci: Sector count too high (max. 65536).\n");
+ count = 64 * 1024;
+ }
+#endif
+ } else {
+ printf("ahci: Unsupported ATA read command (0x%x).\n",
+ ata_dev->read_cmd);
+ return -1;
+ }
+
+ const size_t bytes = count << ata_dev->sector_size_shift;
+ const size_t bytes_feasible = ahci_cmdslot_prepare(dev, buf, bytes, 0);
+ const size_t sectors = bytes_feasible >> ata_dev->sector_size_shift;
+
+ dev->cmdtable->fis[ 0] = FIS_HOST_TO_DEVICE;
+ dev->cmdtable->fis[ 1] = FIS_H2D_CMD;
+ dev->cmdtable->fis[ 2] = ata_dev->read_cmd;
+ dev->cmdtable->fis[ 4] = (start >> 0) & 0xff;
+ dev->cmdtable->fis[ 5] = (start >> 8) & 0xff;
+ dev->cmdtable->fis[ 6] = (start >> 16) & 0xff;
+ dev->cmdtable->fis[ 7] = FIS_H2D_DEV_LBA;
+ dev->cmdtable->fis[ 8] = (start >> 24) & 0xff;
+#ifdef CONFIG_STORAGE_64BIT_LBA
+ if (ata_dev->read_cmd == ATA_READ_DMA_EXT) {
+ dev->cmdtable->fis[ 9] = (start >> 32) & 0xff;
+ dev->cmdtable->fis[10] = (start >> 40) & 0xff;
+ }
+#endif
+ dev->cmdtable->fis[12] = (sectors >> 0) & 0xff;
+ dev->cmdtable->fis[13] = (sectors >> 8) & 0xff;
+
+ if (ahci_cmdslot_exec(dev) < 0)
+ return -1;
+ else
+ return dev->cmdlist->prd_bytes >> ata_dev->sector_size_shift;
+}
diff --git a/payloads/libpayload/drivers/storage/ahci_identify_device.c b/payloads/libpayload/drivers/storage/ahci_identify_device.c
new file mode 100644
index 0000000..51812c2
--- /dev/null
+++ b/payloads/libpayload/drivers/storage/ahci_identify_device.c
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2012 secunet Security Networks AG
+ * Copyright (C) 2013 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <libpayload.h>
+#include <pci.h>
+#include <storage/ata.h>
+#include <storage/ahci.h>
+
+#include "ahci_private.h"
+
+
+int ahci_identify_device(ata_dev_t *const ata_dev, u8 *const buf)
+{
+ ahci_dev_t *const dev = (ahci_dev_t *)ata_dev;
+
+ ahci_cmdslot_prepare(dev, buf, 512, 0);
+
+ dev->cmdtable->fis[0] = FIS_HOST_TO_DEVICE;
+ dev->cmdtable->fis[1] = FIS_H2D_CMD;
+ dev->cmdtable->fis[2] = ata_dev->identify_cmd;
+
+ if ((ahci_cmdslot_exec(dev) < 0) || (dev->cmdlist->prd_bytes != 512))
+ return -1;
+ else
+ return 0;
+}
diff --git a/payloads/libpayload/drivers/storage/ahci_packet_read_cmd.c b/payloads/libpayload/drivers/storage/ahci_packet_read_cmd.c
new file mode 100644
index 0000000..11305c2
--- /dev/null
+++ b/payloads/libpayload/drivers/storage/ahci_packet_read_cmd.c
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2012 secunet Security Networks AG
+ * Copyright (C) 2013 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <libpayload.h>
+#include <pci.h>
+#include <storage/ata.h>
+#include <storage/ahci.h>
+
+
+#include "ahci_private.h"
+
+
+ssize_t ahci_packet_read_cmd(atapi_dev_t *const _dev,
+ const u8 *const cmd, const size_t cmdlen,
+ u8 *const buf, const size_t buflen)
+{
+ ahci_dev_t *const dev = (ahci_dev_t *)_dev;
+
+ if ((cmdlen != 12) && (cmdlen != 16)) {
+ printf("ahci: Only 12- and 16-byte packet commands allowed.\n");
+ return -1;
+ }
+
+ const size_t len = ahci_cmdslot_prepare(dev, buf, buflen, 0);
+ u16 byte_limit = MIN(len, 63 * 1024); /* like Linux */
+ if (byte_limit & 1) ++byte_limit; /* even limit */
+
+ dev->cmdlist[0].cmd |= CMD_ATAPI;
+ dev->cmdtable->fis[0] = FIS_HOST_TO_DEVICE;
+ dev->cmdtable->fis[1] = FIS_H2D_CMD;
+ dev->cmdtable->fis[2] = ATA_PACKET;
+ dev->cmdtable->fis[5] = byte_limit & 0xff;
+ dev->cmdtable->fis[6] = byte_limit >> 8;
+ memcpy((void *)dev->cmdtable->atapi_cmd, cmd, cmdlen);
+
+ return ahci_cmdslot_exec(dev);
+}
diff --git a/payloads/libpayload/drivers/storage/ahci_private.h b/payloads/libpayload/drivers/storage/ahci_private.h
index ba1471b..25d0f10 100644
--- a/payloads/libpayload/drivers/storage/ahci_private.h
+++ b/payloads/libpayload/drivers/storage/ahci_private.h
@@ -2,6 +2,7 @@
* This file is part of the libpayload project.
*
* Copyright (C) 2012 secunet Security Networks AG
+ * Copyright (C) 2013 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -198,4 +199,22 @@ typedef struct {
size_t buflen;
} ahci_dev_t;
-#endif
+ssize_t ahci_cmdslot_exec(ahci_dev_t *const dev);
+
+size_t ahci_cmdslot_prepare(ahci_dev_t *const dev,
+ u8 *const user_buf, size_t buf_len,
+ const int out);
+
+
+ssize_t ahci_ata_read_sectors(ata_dev_t *const ata_dev,
+ const lba_t start, size_t count,
+ u8 *const buf);
+
+ssize_t ahci_packet_read_cmd(atapi_dev_t *const _dev,
+ const u8 *const cmd, const size_t cmdlen,
+ u8 *const buf, const size_t buflen);
+
+int ahci_identify_device(ata_dev_t *const ata_dev, u8 *const buf);
+
+
+#endif /* _AHCI_PRIVATE_H */
diff --git a/payloads/libpayload/libc/hexdump.c b/payloads/libpayload/libc/hexdump.c
index e4aa8b9..44d1a45 100644
--- a/payloads/libpayload/libc/hexdump.c
+++ b/payloads/libpayload/libc/hexdump.c
@@ -49,7 +49,7 @@ void hexdump(void *memory, int length)
}
if (all_zero < 2) {
- printf("%08lx:", memory + i);
+ printf("%08lx:", (long unsigned int)memory + i);
for (j = 0; j < 16; j++)
printf(" %02x", m[i + j]);
printf(" ");