Patchwork IP1000 board specific GPIOs

login
register
about
Submitter Stefan Reinauer
Date 2010-04-11 16:09:53
Message ID <4BC1F451.9090007@coresystems.de>
Download mbox | patch
Permalink /patch/1220/
State Accepted, archived
Headers show

Comments

Stefan Reinauer - 2010-04-11 16:09:53
See patch
add support for reading ip1000 gpios.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
ron minnich - 2010-04-11 18:15:20
Acked-by: Ronald G. Minnich <rminnich@gmail.com>
Joseph Smith - 2010-04-11 18:24:38
On 04/11/2010 12:09 PM, Stefan Reinauer wrote:
> See patch
>
Could we also add M50FW080 to probe for also?

Some variations have either M50FW040 or M50FW080.
Carl-Daniel Hailfinger - 2010-04-11 19:00:36
On 11.04.2010 20:24, Joseph Smith wrote:
> On 04/11/2010 12:09 PM, Stefan Reinauer wrote:
>> See patch
>>
> Could we also add M50FW080 to probe for also?
>
> Some variations have either M50FW040 or M50FW080.

Hm. Since those are flash chips, I think we may want to think about GPIO
reads in flashrom instead. OTOH, GPIO read/write is not a classic
flashrom task at all.

Thoughts?

Regards,
Carl-Daniel
Joseph Smith - 2010-04-11 19:03:58
On 04/11/2010 03:00 PM, Carl-Daniel Hailfinger wrote:
> On 11.04.2010 20:24, Joseph Smith wrote:
>> On 04/11/2010 12:09 PM, Stefan Reinauer wrote:
>>> See patch
>>>
>> Could we also add M50FW080 to probe for also?
>>
>> Some variations have either M50FW040 or M50FW080.
>
> Hm. Since those are flash chips, I think we may want to think about GPIO
> reads in flashrom instead. OTOH, GPIO read/write is not a classic
> flashrom task at all.
>
Carl-Daniel,
The only reason we need to probe these is because the IDE cable_detect 
pin is connected to a FWH GPI pin. This way we can Boot ATA100 instead 
of slow ATA33. Not sure if it is needed in flashrom, but it may make 
interesting util?
Stefan Reinauer - 2010-04-11 19:05:23
>
> On 11.04.2010 20:24, Joseph Smith wrote:
>   
>> On 04/11/2010 12:09 PM, Stefan Reinauer wrote:
>>     
>>> See patch
>>>
>>>       
>> Could we also add M50FW080 to probe for also?
>>
>> Some variations have either M50FW040 or M50FW080.
>>     
> Hm. Since those are flash chips, I think we may want to think about GPIO
> reads in flashrom instead. OTOH, GPIO read/write is not a classic
> flashrom task at all.
>
> Thoughts?
>
> Regards,
> Carl-Daniel
>
>   
By the time flashrom could be running it's a bit late to find out
whether the connected IDE device can do UDMA :-)

So we need to find out while coreboot device init is still running. In
fact the current place might even be too late already (should be
mainboard enable, not init).

Of course you might decide to add support to dumping those GPIOs to
flashrom, but I don't really mind either way.

Stefan

Patch

Index: src/mainboard/thomson/ip1000/mainboard.c
===================================================================
--- src/mainboard/thomson/ip1000/mainboard.c	(revision 5402)
+++ src/mainboard/thomson/ip1000/mainboard.c	(working copy)
@@ -2,11 +2,11 @@ 
  * This file is part of the coreboot project.
  *
  * Copyright (C) 2008-2010 Joseph Smith <joe@settoplinux.org>
+ * Copyright (C) 2010 Stefan Reinauer <stepan@openbios.org>
  *
  * 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.
+ * the Free Software Foundation; version 2 of the License.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,9 +18,12 @@ 
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <console/console.h>
 #include <device/device.h>
 #include <boot/tables.h>
+#include <delay.h>
 #include <arch/coreboot_tables.h>
+#include <arch/io.h>
 #include "chip.h"
 
 int add_mainboard_resources(struct lb_memory *mem)
@@ -28,14 +31,84 @@ 
 	return add_northbridge_resources(mem);
 }
 
+// setting the bit disables the led.
+#define PARPORT_GPIO_LED_GREEN	(1 << 0)
+#define PARPORT_GPIO_LED_ORANGE	(1 << 1)
+#define PARPORT_GPIO_LED_RED	(1 << 2)
+#define PARPORT_GPIO_IR_PORT	(1 << 6)
+
+static u8 get_parport_gpio(void)
+{
+	return inb(0x378);
+}
+
+static void set_parport_gpio(u8 gpios)
+{
+	outb(gpios, 0x378);
+}
+
+static void parport_gpios(void)
+{
+	u8 pp_gpios = get_parport_gpio();
+
+	/* disable red led */
+	pp_gpios |= PARPORT_GPIO_LED_RED;
+	set_parport_gpio(pp_gpios);
+
+	pp_gpios = get_parport_gpio();
+
+	printk(BIOS_DEBUG, "IP1000 GPIOs:\n");
+	printk(BIOS_DEBUG, "  GPIO mask:  %02x\n", pp_gpios);
+	printk(BIOS_DEBUG, "  green led:  %s\n", 
+			(pp_gpios & PARPORT_GPIO_LED_GREEN) ? "off" : "on");
+	printk(BIOS_DEBUG, "  orange led: %s\n", 
+			(pp_gpios & PARPORT_GPIO_LED_ORANGE) ? "off" : "on");
+	printk(BIOS_DEBUG, "  red led:    %s\n", 
+			(pp_gpios & PARPORT_GPIO_LED_RED) ? "off" : "on");
+	printk(BIOS_DEBUG, "  IR port:    %s\n", 
+			(pp_gpios & PARPORT_GPIO_IR_PORT) ? "off" : "on");
+}
+
+static void flash_gpios(void)
+{
+	u32 flash_base = 0xfff80000;
+	u8 manufacturer_id, device_id;
+
+	// reset mode
+	write8(flash_base, 0xff);
+	udelay(10);
+	// read id
+	write8(flash_base, 0x90);
+	udelay(10);
+	manufacturer_id = read8(flash_base);
+	device_id = read8(flash_base + 1);
+	// reset mode
+	write8(flash_base, 0xff);
+	udelay(10);
+
+	if ((manufacturer_id == 0x20) && (device_id == 0x2c)) {
+		printk(BIOS_DEBUG, "Detected ST M50FW040 flash:\n");
+		u8 fgpi = read8(0xffbc0100);
+		printk(BIOS_DEBUG, "  FGPI0 [%c] FGPI1 [%c] FGPI2 [%c] FGPI3 [%c] FGPI4 [%c]",
+			(fgpi & (1 << 0)) ? 'X' : ' ',
+			(fgpi & (1 << 1)) ? 'X' : ' ',
+			(fgpi & (1 << 2)) ? 'X' : ' ',
+			(fgpi & (1 << 3)) ? 'X' : ' ',
+			(fgpi & (1 << 4)) ? 'X' : ' ');
+	} else {
+		printk(BIOS_DEBUG, "No ST M50FW040 flash, don't read FGPI (no UDMA)\n");
+	}
+}
+
+
 static void mainboard_init(device_t dev)
 {
-	// TODO Switch parport LEDs again
+	parport_gpios();
+	flash_gpios();
 }
 
 static void mainboard_enable(device_t dev)
 {
-	// TODO Switch parport LEDs
 	dev->ops->init = mainboard_init;
 }