Joseph Smith | 0fd8ccd | 2008-05-16 15:43:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Joseph Smith | 0d7a996 | 2010-03-17 03:18:29 +0000 | [diff] [blame] | 4 | * Copyright (C) 2008-2010 Joseph Smith <joe@settoplinux.org> |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 5 | * Copyright (C) 2010 Stefan Reinauer <stepan@openbios.org> |
Joseph Smith | 0fd8ccd | 2008-05-16 15:43:35 +0000 | [diff] [blame] | 6 | * |
| 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 Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 9 | * the Free Software Foundation; version 2 of the License. |
Joseph Smith | 0fd8ccd | 2008-05-16 15:43:35 +0000 | [diff] [blame] | 10 | * |
| 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 Smith | 0fd8ccd | 2008-05-16 15:43:35 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 17 | #include <console/console.h> |
Joseph Smith | 0fd8ccd | 2008-05-16 15:43:35 +0000 | [diff] [blame] | 18 | #include <device/device.h> |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 19 | #include <delay.h> |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 20 | #include <drivers/intel/gma/int15.h> |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 21 | #include <arch/io.h> |
Stefan Reinauer | 454744f | 2013-04-23 15:23:15 -0700 | [diff] [blame] | 22 | #include <arch/interrupt.h> |
Joseph Smith | 0fd8ccd | 2008-05-16 15:43:35 +0000 | [diff] [blame] | 23 | |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 24 | // 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 | |
| 30 | static u8 get_parport_gpio(void) |
| 31 | { |
| 32 | return inb(0x378); |
| 33 | } |
| 34 | |
| 35 | static void set_parport_gpio(u8 gpios) |
| 36 | { |
| 37 | outb(gpios, 0x378); |
| 38 | } |
| 39 | |
| 40 | static 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 Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 52 | printk(BIOS_DEBUG, " green led: %s\n", |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 53 | (pp_gpios & PARPORT_GPIO_LED_GREEN) ? "off" : "on"); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 54 | printk(BIOS_DEBUG, " orange led: %s\n", |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 55 | (pp_gpios & PARPORT_GPIO_LED_ORANGE) ? "off" : "on"); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 56 | printk(BIOS_DEBUG, " red led: %s\n", |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 57 | (pp_gpios & PARPORT_GPIO_LED_RED) ? "off" : "on"); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 58 | printk(BIOS_DEBUG, " IR port: %s\n", |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 59 | (pp_gpios & PARPORT_GPIO_IR_PORT) ? "off" : "on"); |
| 60 | } |
| 61 | |
| 62 | static void flash_gpios(void) |
| 63 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 64 | u8 manufacturer_id = read8((u8 *)0xffbc0000); |
| 65 | u8 device_id = read8((u8 *)0xffbc0001); |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 66 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 67 | if ((manufacturer_id == 0x20) && |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 68 | ((device_id == 0x2c) || (device_id == 0x2d))) { |
| 69 | printk(BIOS_DEBUG, "Detected ST M50FW0%c0 flash:\n", |
| 70 | (device_id==0x2c)?'4':'8'); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 71 | u8 fgpi = read8((u8 *)0xffbc0100); |
Stefan Reinauer | 1abf46c | 2010-04-13 21:31:42 +0000 | [diff] [blame] | 72 | printk(BIOS_DEBUG, " FGPI0 [%c] FGPI1 [%c] FGPI2 [%c] FGPI3 [%c] FGPI4 [%c]\n", |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 73 | (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 Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 83 | static void mainboard_init(device_t dev) |
| 84 | { |
Stefan Reinauer | 735c5ac | 2010-04-11 18:57:10 +0000 | [diff] [blame] | 85 | parport_gpios(); |
| 86 | flash_gpios(); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | static void mainboard_enable(device_t dev) |
| 90 | { |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 91 | dev->ops->init = mainboard_init; |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 92 | install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS, GMA_INT15_PANEL_FIT_DEFAULT, GMA_INT15_BOOT_DISPLAY_DEFAULT, 0); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 93 | } |
| 94 | |
Carl-Daniel Hailfinger | 7ad11e8 | 2009-02-18 20:41:57 +0000 | [diff] [blame] | 95 | struct chip_operations mainboard_ops = { |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 96 | .enable_dev = mainboard_enable, |
Joseph Smith | 0fd8ccd | 2008-05-16 15:43:35 +0000 | [diff] [blame] | 97 | }; |