blob: bdcc1fa00b40af6c9844348398a05a51a4522c27 [file] [log] [blame]
Joseph Smith0fd8ccd2008-05-16 15:43:35 +00001/*
2 * This file is part of the coreboot project.
3 *
Joseph Smith0d7a9962010-03-17 03:18:29 +00004 * Copyright (C) 2008-2010 Joseph Smith <joe@settoplinux.org>
Stefan Reinauer735c5ac2010-04-11 18:57:10 +00005 * Copyright (C) 2010 Stefan Reinauer <stepan@openbios.org>
Joseph Smith0fd8ccd2008-05-16 15:43:35 +00006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
Stefan Reinauer735c5ac2010-04-11 18:57:10 +00009 * the Free Software Foundation; version 2 of the License.
Joseph Smith0fd8ccd2008-05-16 15:43:35 +000010 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Joseph Smith0fd8ccd2008-05-16 15:43:35 +000015 */
16
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000017#include <console/console.h>
Joseph Smith0fd8ccd2008-05-16 15:43:35 +000018#include <device/device.h>
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000019#include <delay.h>
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +020020#include <drivers/intel/gma/int15.h>
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000021#include <arch/io.h>
Stefan Reinauer454744f2013-04-23 15:23:15 -070022#include <arch/interrupt.h>
Joseph Smith0fd8ccd2008-05-16 15:43:35 +000023
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000024// setting the bit disables the led.
25#define PARPORT_GPIO_LED_GREEN (1 << 0)
26#define PARPORT_GPIO_LED_ORANGE (1 << 1)
27#define PARPORT_GPIO_LED_RED (1 << 2)
28#define PARPORT_GPIO_IR_PORT (1 << 6)
29
30static u8 get_parport_gpio(void)
31{
32 return inb(0x378);
33}
34
35static void set_parport_gpio(u8 gpios)
36{
37 outb(gpios, 0x378);
38}
39
40static void parport_gpios(void)
41{
42 u8 pp_gpios = get_parport_gpio();
43
44 /* disable red led */
45 pp_gpios |= PARPORT_GPIO_LED_RED;
46 set_parport_gpio(pp_gpios);
47
48 pp_gpios = get_parport_gpio();
49
50 printk(BIOS_DEBUG, "IP1000 GPIOs:\n");
51 printk(BIOS_DEBUG, " GPIO mask: %02x\n", pp_gpios);
Stefan Reinauer14e22772010-04-27 06:56:47 +000052 printk(BIOS_DEBUG, " green led: %s\n",
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000053 (pp_gpios & PARPORT_GPIO_LED_GREEN) ? "off" : "on");
Stefan Reinauer14e22772010-04-27 06:56:47 +000054 printk(BIOS_DEBUG, " orange led: %s\n",
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000055 (pp_gpios & PARPORT_GPIO_LED_ORANGE) ? "off" : "on");
Stefan Reinauer14e22772010-04-27 06:56:47 +000056 printk(BIOS_DEBUG, " red led: %s\n",
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000057 (pp_gpios & PARPORT_GPIO_LED_RED) ? "off" : "on");
Stefan Reinauer14e22772010-04-27 06:56:47 +000058 printk(BIOS_DEBUG, " IR port: %s\n",
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000059 (pp_gpios & PARPORT_GPIO_IR_PORT) ? "off" : "on");
60}
61
62static void flash_gpios(void)
63{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080064 u8 manufacturer_id = read8((u8 *)0xffbc0000);
65 u8 device_id = read8((u8 *)0xffbc0001);
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000066
Stefan Reinauer14e22772010-04-27 06:56:47 +000067 if ((manufacturer_id == 0x20) &&
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000068 ((device_id == 0x2c) || (device_id == 0x2d))) {
69 printk(BIOS_DEBUG, "Detected ST M50FW0%c0 flash:\n",
Elyes HAOUASa5aad2e2016-09-19 09:47:16 -060070 (device_id == 0x2c)?'4':'8');
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080071 u8 fgpi = read8((u8 *)0xffbc0100);
Stefan Reinauer1abf46c2010-04-13 21:31:42 +000072 printk(BIOS_DEBUG, " FGPI0 [%c] FGPI1 [%c] FGPI2 [%c] FGPI3 [%c] FGPI4 [%c]\n",
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000073 (fgpi & (1 << 0)) ? 'X' : ' ',
74 (fgpi & (1 << 1)) ? 'X' : ' ',
75 (fgpi & (1 << 2)) ? 'X' : ' ',
76 (fgpi & (1 << 3)) ? 'X' : ' ',
77 (fgpi & (1 << 4)) ? 'X' : ' ');
78 } else {
79 printk(BIOS_DEBUG, "No ST M50FW040/M50FW080 flash, don't read FGPI.\n");
80 }
81}
82
Stefan Reinauer800379f2010-03-01 08:34:19 +000083static void mainboard_init(device_t dev)
84{
Stefan Reinauer735c5ac2010-04-11 18:57:10 +000085 parport_gpios();
86 flash_gpios();
Stefan Reinauer800379f2010-03-01 08:34:19 +000087}
88
89static void mainboard_enable(device_t dev)
90{
Stefan Reinauer800379f2010-03-01 08:34:19 +000091 dev->ops->init = mainboard_init;
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +020092 install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS, GMA_INT15_PANEL_FIT_DEFAULT, GMA_INT15_BOOT_DISPLAY_DEFAULT, 0);
Stefan Reinauer800379f2010-03-01 08:34:19 +000093}
94
Carl-Daniel Hailfinger7ad11e82009-02-18 20:41:57 +000095struct chip_operations mainboard_ops = {
Stefan Reinauer800379f2010-03-01 08:34:19 +000096 .enable_dev = mainboard_enable,
Joseph Smith0fd8ccd2008-05-16 15:43:35 +000097};