this small patch series enable the Ultrabay found in T60 and X60 Laptops. The X60 is a bit more ugly as the T60 because the X60 ultrabase notifies the system over some GPIO Lines about Ultrabay state, while the T60 uses PMH7 and the EC for status information.
I'm not sure if everyone likes modifying chip_info in the dev tree, so if anyone has a better solution please give me a hint.
Happy corebooting with Ultrabay devices,
Sven.
Signed-off-by: Sven Schnelle svens@stackframe.org --- src/ec/lenovo/h8/h8.c | 6 ++++++ src/ec/lenovo/h8/h8.h | 5 +++++ 2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c index 6a59525..fafaef2 100644 --- a/src/ec/lenovo/h8/h8.c +++ b/src/ec/lenovo/h8/h8.c @@ -87,6 +87,12 @@ void h8_disable_event(int event)
}
+int h8_ultrabay_device_present(void) +{ + return ec_read(H8_STATUS1) & 0x5 ? 0 : 1; +} + + static void h8_enable(device_t dev) { struct ec_lenovo_h8_config *conf = dev->chip_info; diff --git a/src/ec/lenovo/h8/h8.h b/src/ec/lenovo/h8/h8.h index d263313..b5d8f01 100644 --- a/src/ec/lenovo/h8/h8.h +++ b/src/ec/lenovo/h8/h8.h @@ -25,6 +25,7 @@ void h8_wlan_enable(int on); void h8_set_audio_mute(int on); void h8_enable_event(int event); void h8_disable_event(int event); +int h8_ultrabay_device_present(void);
/* EC registers */ #define H8_CONFIG0 0x00 @@ -102,6 +103,10 @@ void h8_disable_event(int event);
#define H8_EVENT_FN_PRESS 0x39
+#define H8_STATUS0 0x46 +#define H8_STATUS1 0x47 +#define H8_STATUS2 0x48 + #define H8_EVENT_BAT0 0x4a #define H8_EVENT_BAT0_STATE 0x4b
Signed-off-by: Sven Schnelle svens@stackframe.org --- src/ec/lenovo/pmh7/pmh7.c | 8 ++++++++ src/ec/lenovo/pmh7/pmh7.h | 1 + 2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/ec/lenovo/pmh7/pmh7.c b/src/ec/lenovo/pmh7/pmh7.c index d536d74..276a378 100644 --- a/src/ec/lenovo/pmh7/pmh7.c +++ b/src/ec/lenovo/pmh7/pmh7.c @@ -49,6 +49,14 @@ void pmh7_touchpad_enable(int onoff) else pmh7_register_set_bit(0x51, 2); } + +void pmh7_ultrabay_power_enable(int onoff) +{ + if (onoff) + pmh7_register_set_bit(0x62, 0); + else + pmh7_register_clear_bit(0x62, 0); +} void pmh7_register_set_bit(int reg, int bit) { char val; diff --git a/src/ec/lenovo/pmh7/pmh7.h b/src/ec/lenovo/pmh7/pmh7.h index 701013b..3543802 100644 --- a/src/ec/lenovo/pmh7/pmh7.h +++ b/src/ec/lenovo/pmh7/pmh7.h @@ -34,4 +34,5 @@ void pmh7_register_write(int reg, int val); void pmh7_backlight_enable(int onoff); void pmh7_dock_event_enable(int onoff); void pmh7_touchpad_enable(int onoff); +void pmh7_ultrabay_power_enable(int onoff); #endif
Signed-off-by: Sven Schnelle svens@stackframe.org --- src/mainboard/lenovo/t60/devicetree.cb | 2 +- src/mainboard/lenovo/t60/mainboard.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/mainboard/lenovo/t60/devicetree.cb b/src/mainboard/lenovo/t60/devicetree.cb index 9f41a30..da1cb43 100644 --- a/src/mainboard/lenovo/t60/devicetree.cb +++ b/src/mainboard/lenovo/t60/devicetree.cb @@ -180,7 +180,7 @@ chip northbridge/intel/i945 end end end - device pci 1f.1 off # IDE + device pci 1f.1 on # IDE subsystemid 0x17aa 0x200c end device pci 1f.2 on # SATA diff --git a/src/mainboard/lenovo/t60/mainboard.c b/src/mainboard/lenovo/t60/mainboard.c index e6a7679..d6321d2 100644 --- a/src/mainboard/lenovo/t60/mainboard.c +++ b/src/mainboard/lenovo/t60/mainboard.c @@ -38,7 +38,7 @@
static void mainboard_enable(device_t dev) { - device_t dev0; + device_t dev0, idedev; int touchpad;
/* enable Audio */ @@ -53,6 +53,17 @@ static void mainboard_enable(device_t dev) touchpad = 1;
pmh7_touchpad_enable(touchpad); + + idedev = dev_find_slot(0, PCI_DEVFN(0x1f,1)); + if (idedev && idedev->chip_info && h8_ultrabay_device_present()) { + struct southbridge_intel_i82801gx_config *config = idedev->chip_info; + config->ide_enable_primary = 1; + pmh7_ultrabay_power_enable(1); + ec_write(0x0c, 0x84); + } else { + pmh7_ultrabay_power_enable(0); + ec_write(0x0c, 0x04); + } }
struct chip_operations mainboard_ops = {
Signed-off-by: Sven Schnelle svens@stackframe.org --- src/mainboard/lenovo/x60/Makefile.inc | 1 + src/mainboard/lenovo/x60/devicetree.cb | 2 +- src/mainboard/lenovo/x60/dock.c | 6 +++++- src/mainboard/lenovo/x60/dock.h | 1 + src/mainboard/lenovo/x60/mainboard.c | 16 +++++++++++++++- 5 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/mainboard/lenovo/x60/Makefile.inc b/src/mainboard/lenovo/x60/Makefile.inc index 7515258..83cdeb9 100644 --- a/src/mainboard/lenovo/x60/Makefile.inc +++ b/src/mainboard/lenovo/x60/Makefile.inc @@ -19,3 +19,4 @@
smm-$(CONFIG_HAVE_SMI_HANDLER) += mainboard_smi.c dock.c romstage-y += dock.c +ramstage-y += dock.c diff --git a/src/mainboard/lenovo/x60/devicetree.cb b/src/mainboard/lenovo/x60/devicetree.cb index d5ba7d9..01a42eb 100644 --- a/src/mainboard/lenovo/x60/devicetree.cb +++ b/src/mainboard/lenovo/x60/devicetree.cb @@ -156,7 +156,7 @@ chip northbridge/intel/i945 end end end - device pci 1f.1 off # IDE + device pci 1f.1 on # IDE subsystemid 0x17aa 0x200c end device pci 1f.2 on # SATA diff --git a/src/mainboard/lenovo/x60/dock.c b/src/mainboard/lenovo/x60/dock.c index b64d864..2d6e686 100644 --- a/src/mainboard/lenovo/x60/dock.c +++ b/src/mainboard/lenovo/x60/dock.c @@ -230,7 +230,6 @@ int dock_connect(void) outb(0x82, 0x1622); outb(0xff, 0x1624);
- /* Enable USB and Ultrabay power */ outb(0x03, 0x1628); return 0; } @@ -247,3 +246,8 @@ int dock_present(void) { return !((inb(DEFAULT_GPIOBASE + 0x0c) >> 13) & 1); } + +int dock_ultrabay_device_present(void) +{ + return !(inb(0x1621) & 0x02); +} diff --git a/src/mainboard/lenovo/x60/dock.h b/src/mainboard/lenovo/x60/dock.h index 05c5cc4..cd68223 100644 --- a/src/mainboard/lenovo/x60/dock.h +++ b/src/mainboard/lenovo/x60/dock.h @@ -5,4 +5,5 @@ extern int dock_connect(void); extern void dock_disconnect(void); extern int dock_present(void); extern int dlpc_init(void); +extern int dock_ultrabay_device_present(void); #endif diff --git a/src/mainboard/lenovo/x60/mainboard.c b/src/mainboard/lenovo/x60/mainboard.c index b9416b5..f7bcb61 100644 --- a/src/mainboard/lenovo/x60/mainboard.c +++ b/src/mainboard/lenovo/x60/mainboard.c @@ -34,10 +34,11 @@ #include <ec/acpi/ec.h> #include <ec/lenovo/h8/h8.h> #include <northbridge/intel/i945/i945.h> +#include "dock.h"
static void mainboard_enable(device_t dev) { - device_t dev0; + device_t dev0, idedev;
/* enable Audio */ h8_set_audio_mute(0); @@ -46,6 +47,19 @@ static void mainboard_enable(device_t dev) dev0 = dev_find_slot(0, PCI_DEVFN(0,0)); if (dev0 && pci_read_config32(dev0, SKPAD) == 0xcafed00d) ec_write(0x0c, 0xc7); + + idedev = dev_find_slot(0, PCI_DEVFN(0x1f,1)); + if (idedev && idedev->chip_info && dock_ultrabay_device_present()) { + struct southbridge_intel_i82801gx_config *config = idedev->chip_info; + config->ide_enable_primary = 1; + /* enable Ultrabay power */ + outb(inb(0x1628) | 0x01, 0x1628); + ec_write(0x0c, 0x84); + } else { + /* disable Ultrabay power */ + outb(inb(0x1628) & ~0x01, 0x1628); + ec_write(0x0c, 0x04); + } }
struct chip_operations mainboard_ops = {
Sven Schnelle wrote:
this small patch series enable the Ultrabay found in T60 and X60 Laptops. The X60 is a bit more ugly as the T60 because the X60 ultrabase notifies the system over some GPIO Lines about Ultrabay state, while the T60 uses PMH7 and the EC for status information.
I'm not sure if everyone likes modifying chip_info in the dev tree, so if anyone has a better solution please give me a hint.
Happy corebooting with Ultrabay devices,
I pointed out some minor bits on IRC, after which the set is:
Acked-by: Peter Stuge peter@stuge.se