aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/Kconfig30
-rw-r--r--arch/x86/include/asm/intel-mid.h48
-rw-r--r--arch/x86/pci/intel_mid_pci.c6
-rw-r--r--arch/x86/platform/intel-mid/Makefile4
-rw-r--r--arch/x86/platform/intel-mid/device_libs/platform_emc1403.c4
-rw-r--r--arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c2
-rw-r--r--arch/x86/platform/intel-mid/device_libs/platform_lis331.c4
-rw-r--r--arch/x86/platform/intel-mid/device_libs/platform_max7315.c2
-rw-r--r--arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c2
-rw-r--r--arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c2
-rw-r--r--arch/x86/platform/intel-mid/device_libs/platform_tca6416.c4
-rw-r--r--arch/x86/platform/intel-mid/intel-mid.c64
-rw-r--r--arch/x86/platform/intel-mid/intel_mid_weak_decls.h19
-rw-r--r--arch/x86/platform/intel-mid/mfld.c75
-rw-r--r--arch/x86/platform/intel-mid/mrfl.c103
-rw-r--r--arch/x86/platform/intel-mid/sfi.c46
16 files changed, 340 insertions, 75 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 838e7c34dd60..9b8ecfc00fa1 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -439,42 +439,26 @@ config X86_INTEL_CE
439 This option compiles in support for the CE4100 SOC for settop 439 This option compiles in support for the CE4100 SOC for settop
440 boxes and media devices. 440 boxes and media devices.
441 441
442config X86_WANT_INTEL_MID 442config X86_INTEL_MID
443 bool "Intel MID platform support" 443 bool "Intel MID platform support"
444 depends on X86_32 444 depends on X86_32
445 depends on X86_EXTENDED_PLATFORM 445 depends on X86_EXTENDED_PLATFORM
446 ---help---
447 Select to build a kernel capable of supporting Intel MID platform
448 systems which do not have the PCI legacy interfaces (Moorestown,
449 Medfield). If you are building for a PC class system say N here.
450
451if X86_WANT_INTEL_MID
452
453config X86_INTEL_MID
454 bool
455
456config X86_MDFLD
457 bool "Medfield MID platform"
458 depends on PCI 446 depends on PCI
459 depends on PCI_GOANY 447 depends on PCI_GOANY
460 depends on X86_IO_APIC 448 depends on X86_IO_APIC
461 select X86_INTEL_MID
462 select SFI 449 select SFI
450 select I2C
463 select DW_APB_TIMER 451 select DW_APB_TIMER
464 select APB_TIMER 452 select APB_TIMER
465 select I2C
466 select SPI
467 select INTEL_SCU_IPC 453 select INTEL_SCU_IPC
468 select X86_PLATFORM_DEVICES
469 select MFD_INTEL_MSIC 454 select MFD_INTEL_MSIC
470 ---help--- 455 ---help---
471 Medfield is Intel's Low Power Intel Architecture (LPIA) based Moblin 456 Select to build a kernel capable of supporting Intel MID (Mobile
472 Internet Device(MID) platform. 457 Internet Device) platform systems which do not have the PCI legacy
473 Unlike standard x86 PCs, Medfield does not have many legacy devices 458 interfaces. If you are building for a PC class system say N here.
474 nor standard legacy replacement devices/features. e.g. Medfield does
475 not contain i8259, i8254, HPET, legacy BIOS, most of the io ports.
476 459
477endif 460 Intel MID platforms are based on an Intel processor and chipset which
461 consume less power than most of the x86 derivatives.
478 462
479config X86_INTEL_LPSS 463config X86_INTEL_LPSS
480 bool "Intel Low Power Subsystem Support" 464 bool "Intel Low Power Subsystem Support"
diff --git a/arch/x86/include/asm/intel-mid.h b/arch/x86/include/asm/intel-mid.h
index 459769d39263..e34e097b6f9d 100644
--- a/arch/x86/include/asm/intel-mid.h
+++ b/arch/x86/include/asm/intel-mid.h
@@ -51,10 +51,41 @@ struct devs_id {
51enum intel_mid_cpu_type { 51enum intel_mid_cpu_type {
52 /* 1 was Moorestown */ 52 /* 1 was Moorestown */
53 INTEL_MID_CPU_CHIP_PENWELL = 2, 53 INTEL_MID_CPU_CHIP_PENWELL = 2,
54 INTEL_MID_CPU_CHIP_CLOVERVIEW,
55 INTEL_MID_CPU_CHIP_TANGIER,
54}; 56};
55 57
56extern enum intel_mid_cpu_type __intel_mid_cpu_chip; 58extern enum intel_mid_cpu_type __intel_mid_cpu_chip;
57 59
60/**
61 * struct intel_mid_ops - Interface between intel-mid & sub archs
62 * @arch_setup: arch_setup function to re-initialize platform
63 * structures (x86_init, x86_platform_init)
64 *
65 * This structure can be extended if any new interface is required
66 * between intel-mid & its sub arch files.
67 */
68struct intel_mid_ops {
69 void (*arch_setup)(void);
70};
71
72/* Helper API's for INTEL_MID_OPS_INIT */
73#define DECLARE_INTEL_MID_OPS_INIT(cpuname, cpuid) \
74 [cpuid] = get_##cpuname##_ops
75
76/* Maximum number of CPU ops */
77#define MAX_CPU_OPS(a) (sizeof(a)/sizeof(void *))
78
79/*
80 * For every new cpu addition, a weak get_<cpuname>_ops() function needs be
81 * declared in arch/x86/platform/intel_mid/intel_mid_weak_decls.h.
82 */
83#define INTEL_MID_OPS_INIT {\
84 DECLARE_INTEL_MID_OPS_INIT(penwell, INTEL_MID_CPU_CHIP_PENWELL), \
85 DECLARE_INTEL_MID_OPS_INIT(cloverview, INTEL_MID_CPU_CHIP_CLOVERVIEW), \
86 DECLARE_INTEL_MID_OPS_INIT(tangier, INTEL_MID_CPU_CHIP_TANGIER) \
87};
88
58#ifdef CONFIG_X86_INTEL_MID 89#ifdef CONFIG_X86_INTEL_MID
59 90
60static inline enum intel_mid_cpu_type intel_mid_identify_cpu(void) 91static inline enum intel_mid_cpu_type intel_mid_identify_cpu(void)
@@ -86,8 +117,21 @@ extern enum intel_mid_timer_options intel_mid_timer_options;
86 * Penwell uses spread spectrum clock, so the freq number is not exactly 117 * Penwell uses spread spectrum clock, so the freq number is not exactly
87 * the same as reported by MSR based on SDM. 118 * the same as reported by MSR based on SDM.
88 */ 119 */
89#define PENWELL_FSB_FREQ_83SKU 83200 120#define FSB_FREQ_83SKU 83200
90#define PENWELL_FSB_FREQ_100SKU 99840 121#define FSB_FREQ_100SKU 99840
122#define FSB_FREQ_133SKU 133000
123
124#define FSB_FREQ_167SKU 167000
125#define FSB_FREQ_200SKU 200000
126#define FSB_FREQ_267SKU 267000
127#define FSB_FREQ_333SKU 333000
128#define FSB_FREQ_400SKU 400000
129
130/* Bus Select SoC Fuse value */
131#define BSEL_SOC_FUSE_MASK 0x7
132#define BSEL_SOC_FUSE_001 0x1 /* FSB 133MHz */
133#define BSEL_SOC_FUSE_101 0x5 /* FSB 100MHz */
134#define BSEL_SOC_FUSE_111 0x7 /* FSB 83MHz */
91 135
92#define SFI_MTMR_MAX_NUM 8 136#define SFI_MTMR_MAX_NUM 8
93#define SFI_MRTC_MAX 8 137#define SFI_MRTC_MAX 8
diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
index 51384ca727ad..84b9d672843d 100644
--- a/arch/x86/pci/intel_mid_pci.c
+++ b/arch/x86/pci/intel_mid_pci.c
@@ -31,6 +31,7 @@
31#include <asm/pci_x86.h> 31#include <asm/pci_x86.h>
32#include <asm/hw_irq.h> 32#include <asm/hw_irq.h>
33#include <asm/io_apic.h> 33#include <asm/io_apic.h>
34#include <asm/intel-mid.h>
34 35
35#define PCIE_CAP_OFFSET 0x100 36#define PCIE_CAP_OFFSET 0x100
36 37
@@ -219,7 +220,10 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
219 irq_attr.ioapic = mp_find_ioapic(dev->irq); 220 irq_attr.ioapic = mp_find_ioapic(dev->irq);
220 irq_attr.ioapic_pin = dev->irq; 221 irq_attr.ioapic_pin = dev->irq;
221 irq_attr.trigger = 1; /* level */ 222 irq_attr.trigger = 1; /* level */
222 irq_attr.polarity = 1; /* active low */ 223 if (intel_mid_identify_cpu() == INTEL_MID_CPU_CHIP_TANGIER)
224 irq_attr.polarity = 0; /* active high */
225 else
226 irq_attr.polarity = 1; /* active low */
223 io_apic_set_pci_routing(&dev->dev, dev->irq, &irq_attr); 227 io_apic_set_pci_routing(&dev->dev, dev->irq, &irq_attr);
224 228
225 return 0; 229 return 0;
diff --git a/arch/x86/platform/intel-mid/Makefile b/arch/x86/platform/intel-mid/Makefile
index 01cc29ea5ff7..0a8ee703b9fa 100644
--- a/arch/x86/platform/intel-mid/Makefile
+++ b/arch/x86/platform/intel-mid/Makefile
@@ -1,6 +1,6 @@
1obj-$(CONFIG_X86_INTEL_MID) += intel-mid.o 1obj-$(CONFIG_X86_INTEL_MID) += intel-mid.o intel_mid_vrtc.o mfld.o mrfl.o
2obj-$(CONFIG_X86_INTEL_MID) += intel_mid_vrtc.o
3obj-$(CONFIG_EARLY_PRINTK_INTEL_MID) += early_printk_intel_mid.o 2obj-$(CONFIG_EARLY_PRINTK_INTEL_MID) += early_printk_intel_mid.o
3
4# SFI specific code 4# SFI specific code
5ifdef CONFIG_X86_INTEL_MID 5ifdef CONFIG_X86_INTEL_MID
6obj-$(CONFIG_SFI) += sfi.o device_libs/ 6obj-$(CONFIG_SFI) += sfi.o device_libs/
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c b/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c
index 0d942c1d26d5..69a783689d21 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c
@@ -22,7 +22,9 @@ static void __init *emc1403_platform_data(void *info)
22 int intr = get_gpio_by_name("thermal_int"); 22 int intr = get_gpio_by_name("thermal_int");
23 int intr2nd = get_gpio_by_name("thermal_alert"); 23 int intr2nd = get_gpio_by_name("thermal_alert");
24 24
25 if (intr == -1 || intr2nd == -1) 25 if (intr < 0)
26 return NULL;
27 if (intr2nd < 0)
26 return NULL; 28 return NULL;
27 29
28 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; 30 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
index a013a4834bbe..dccae6b0413f 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
@@ -66,7 +66,7 @@ static int __init pb_keys_init(void)
66 gb[i].gpio = get_gpio_by_name(gb[i].desc); 66 gb[i].gpio = get_gpio_by_name(gb[i].desc);
67 pr_debug("info[%2d]: name = %s, gpio = %d\n", i, gb[i].desc, 67 pr_debug("info[%2d]: name = %s, gpio = %d\n", i, gb[i].desc,
68 gb[i].gpio); 68 gb[i].gpio);
69 if (gb[i].gpio == -1) 69 if (gb[i].gpio < 0)
70 continue; 70 continue;
71 71
72 if (i != good) 72 if (i != good)
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_lis331.c b/arch/x86/platform/intel-mid/device_libs/platform_lis331.c
index 15278c11f714..54226de7541a 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_lis331.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_lis331.c
@@ -21,7 +21,9 @@ static void __init *lis331dl_platform_data(void *info)
21 int intr = get_gpio_by_name("accel_int"); 21 int intr = get_gpio_by_name("accel_int");
22 int intr2nd = get_gpio_by_name("accel_2"); 22 int intr2nd = get_gpio_by_name("accel_2");
23 23
24 if (intr == -1 || intr2nd == -1) 24 if (intr < 0)
25 return NULL;
26 if (intr2nd < 0)
25 return NULL; 27 return NULL;
26 28
27 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; 29 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_max7315.c b/arch/x86/platform/intel-mid/device_libs/platform_max7315.c
index 94ade10024ae..2c8acbc1e9ad 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_max7315.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_max7315.c
@@ -48,7 +48,7 @@ static void __init *max7315_platform_data(void *info)
48 gpio_base = get_gpio_by_name(base_pin_name); 48 gpio_base = get_gpio_by_name(base_pin_name);
49 intr = get_gpio_by_name(intr_pin_name); 49 intr = get_gpio_by_name(intr_pin_name);
50 50
51 if (gpio_base == -1) 51 if (gpio_base < 0)
52 return NULL; 52 return NULL;
53 max7315->gpio_base = gpio_base; 53 max7315->gpio_base = gpio_base;
54 if (intr != -1) { 54 if (intr != -1) {
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c b/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c
index dd28d63c84fb..cfe9a47a1e87 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c
@@ -19,7 +19,7 @@ static void *mpu3050_platform_data(void *info)
19 struct i2c_board_info *i2c_info = info; 19 struct i2c_board_info *i2c_info = info;
20 int intr = get_gpio_by_name("mpu3050_int"); 20 int intr = get_gpio_by_name("mpu3050_int");
21 21
22 if (intr == -1) 22 if (intr < 0)
23 return NULL; 23 return NULL;
24 24
25 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; 25 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c b/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c
index d87182a09263..65c2a9a19db4 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c
@@ -26,7 +26,7 @@ static void __init *pmic_gpio_platform_data(void *info)
26 static struct intel_pmic_gpio_platform_data pmic_gpio_pdata; 26 static struct intel_pmic_gpio_platform_data pmic_gpio_pdata;
27 int gpio_base = get_gpio_by_name("pmic_gpio_base"); 27 int gpio_base = get_gpio_by_name("pmic_gpio_base");
28 28
29 if (gpio_base == -1) 29 if (gpio_base < 0)
30 gpio_base = 64; 30 gpio_base = 64;
31 pmic_gpio_pdata.gpio_base = gpio_base; 31 pmic_gpio_pdata.gpio_base = gpio_base;
32 pmic_gpio_pdata.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET; 32 pmic_gpio_pdata.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c b/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c
index 22881c9a6737..33be0b3be6e1 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c
@@ -34,10 +34,10 @@ static void *tca6416_platform_data(void *info)
34 gpio_base = get_gpio_by_name(base_pin_name); 34 gpio_base = get_gpio_by_name(base_pin_name);
35 intr = get_gpio_by_name(intr_pin_name); 35 intr = get_gpio_by_name(intr_pin_name);
36 36
37 if (gpio_base == -1) 37 if (gpio_base < 0)
38 return NULL; 38 return NULL;
39 tca6416.gpio_base = gpio_base; 39 tca6416.gpio_base = gpio_base;
40 if (intr != -1) { 40 if (intr >= 0) {
41 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; 41 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
42 tca6416.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET; 42 tca6416.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
43 } else { 43 } else {
diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
index f90e290f689f..1bbedc4b0f88 100644
--- a/arch/x86/platform/intel-mid/intel-mid.c
+++ b/arch/x86/platform/intel-mid/intel-mid.c
@@ -35,6 +35,8 @@
35#include <asm/apb_timer.h> 35#include <asm/apb_timer.h>
36#include <asm/reboot.h> 36#include <asm/reboot.h>
37 37
38#include "intel_mid_weak_decls.h"
39
38/* 40/*
39 * the clockevent devices on Moorestown/Medfield can be APBT or LAPIC clock, 41 * the clockevent devices on Moorestown/Medfield can be APBT or LAPIC clock,
40 * cmdline option x86_intel_mid_timer can be used to override the configuration 42 * cmdline option x86_intel_mid_timer can be used to override the configuration
@@ -58,12 +60,16 @@
58 60
59enum intel_mid_timer_options intel_mid_timer_options; 61enum intel_mid_timer_options intel_mid_timer_options;
60 62
63/* intel_mid_ops to store sub arch ops */
64struct intel_mid_ops *intel_mid_ops;
65/* getter function for sub arch ops*/
66static void *(*get_intel_mid_ops[])(void) = INTEL_MID_OPS_INIT;
61enum intel_mid_cpu_type __intel_mid_cpu_chip; 67enum intel_mid_cpu_type __intel_mid_cpu_chip;
62EXPORT_SYMBOL_GPL(__intel_mid_cpu_chip); 68EXPORT_SYMBOL_GPL(__intel_mid_cpu_chip);
63 69
64static void intel_mid_power_off(void) 70static void intel_mid_power_off(void)
65{ 71{
66} 72};
67 73
68static void intel_mid_reboot(void) 74static void intel_mid_reboot(void)
69{ 75{
@@ -72,32 +78,6 @@ static void intel_mid_reboot(void)
72 78
73static unsigned long __init intel_mid_calibrate_tsc(void) 79static unsigned long __init intel_mid_calibrate_tsc(void)
74{ 80{
75 unsigned long fast_calibrate;
76 u32 lo, hi, ratio, fsb;
77
78 rdmsr(MSR_IA32_PERF_STATUS, lo, hi);
79 pr_debug("IA32 perf status is 0x%x, 0x%0x\n", lo, hi);
80 ratio = (hi >> 8) & 0x1f;
81 pr_debug("ratio is %d\n", ratio);
82 if (!ratio) {
83 pr_err("read a zero ratio, should be incorrect!\n");
84 pr_err("force tsc ratio to 16 ...\n");
85 ratio = 16;
86 }
87 rdmsr(MSR_FSB_FREQ, lo, hi);
88 if ((lo & 0x7) == 0x7)
89 fsb = PENWELL_FSB_FREQ_83SKU;
90 else
91 fsb = PENWELL_FSB_FREQ_100SKU;
92 fast_calibrate = ratio * fsb;
93 pr_debug("read penwell tsc %lu khz\n", fast_calibrate);
94 lapic_timer_frequency = fsb * 1000 / HZ;
95 /* mark tsc clocksource as reliable */
96 set_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE);
97
98 if (fast_calibrate)
99 return fast_calibrate;
100
101 return 0; 81 return 0;
102} 82}
103 83
@@ -125,13 +105,37 @@ static void __init intel_mid_time_init(void)
125 105
126static void intel_mid_arch_setup(void) 106static void intel_mid_arch_setup(void)
127{ 107{
128 if (boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x27) 108 if (boot_cpu_data.x86 != 6) {
129 __intel_mid_cpu_chip = INTEL_MID_CPU_CHIP_PENWELL;
130 else {
131 pr_err("Unknown Intel MID CPU (%d:%d), default to Penwell\n", 109 pr_err("Unknown Intel MID CPU (%d:%d), default to Penwell\n",
132 boot_cpu_data.x86, boot_cpu_data.x86_model); 110 boot_cpu_data.x86, boot_cpu_data.x86_model);
133 __intel_mid_cpu_chip = INTEL_MID_CPU_CHIP_PENWELL; 111 __intel_mid_cpu_chip = INTEL_MID_CPU_CHIP_PENWELL;
112 goto out;
134 } 113 }
114
115 switch (boot_cpu_data.x86_model) {
116 case 0x35:
117 __intel_mid_cpu_chip = INTEL_MID_CPU_CHIP_CLOVERVIEW;
118 break;
119 case 0x3C:
120 case 0x4A:
121 __intel_mid_cpu_chip = INTEL_MID_CPU_CHIP_TANGIER;
122 break;
123 case 0x27:
124 default:
125 __intel_mid_cpu_chip = INTEL_MID_CPU_CHIP_PENWELL;
126 break;
127 }
128
129 if (__intel_mid_cpu_chip < MAX_CPU_OPS(get_intel_mid_ops))
130 intel_mid_ops = get_intel_mid_ops[__intel_mid_cpu_chip]();
131 else {
132 intel_mid_ops = get_intel_mid_ops[INTEL_MID_CPU_CHIP_PENWELL]();
133 pr_info("ARCH: Uknown SoC, assuming PENWELL!\n");
134 }
135
136out:
137 if (intel_mid_ops->arch_setup)
138 intel_mid_ops->arch_setup();
135} 139}
136 140
137/* MID systems don't have i8042 controller */ 141/* MID systems don't have i8042 controller */
diff --git a/arch/x86/platform/intel-mid/intel_mid_weak_decls.h b/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
new file mode 100644
index 000000000000..a537ffc16299
--- /dev/null
+++ b/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
@@ -0,0 +1,19 @@
1/*
2 * intel_mid_weak_decls.h: Weak declarations of intel-mid.c
3 *
4 * (C) Copyright 2013 Intel Corporation
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; version 2
9 * of the License.
10 */
11
12
13/* __attribute__((weak)) makes these declarations overridable */
14/* For every CPU addition a new get_<cpuname>_ops interface needs
15 * to be added.
16 */
17extern void * __cpuinit get_penwell_ops(void) __attribute__((weak));
18extern void * __cpuinit get_cloverview_ops(void) __attribute__((weak));
19extern void * __init get_tangier_ops(void) __attribute__((weak));
diff --git a/arch/x86/platform/intel-mid/mfld.c b/arch/x86/platform/intel-mid/mfld.c
new file mode 100644
index 000000000000..4f7884eebc14
--- /dev/null
+++ b/arch/x86/platform/intel-mid/mfld.c
@@ -0,0 +1,75 @@
1/*
2 * mfld.c: Intel Medfield platform setup code
3 *
4 * (C) Copyright 2013 Intel Corporation
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; version 2
9 * of the License.
10 */
11
12#include <linux/init.h>
13
14#include <asm/apic.h>
15#include <asm/intel-mid.h>
16#include <asm/intel_mid_vrtc.h>
17
18#include "intel_mid_weak_decls.h"
19
20static void penwell_arch_setup(void);
21/* penwell arch ops */
22static struct intel_mid_ops penwell_ops = {
23 .arch_setup = penwell_arch_setup,
24};
25
26static void mfld_power_off(void)
27{
28}
29
30static unsigned long __init mfld_calibrate_tsc(void)
31{
32 unsigned long fast_calibrate;
33 u32 lo, hi, ratio, fsb;
34
35 rdmsr(MSR_IA32_PERF_STATUS, lo, hi);
36 pr_debug("IA32 perf status is 0x%x, 0x%0x\n", lo, hi);
37 ratio = (hi >> 8) & 0x1f;
38 pr_debug("ratio is %d\n", ratio);
39 if (!ratio) {
40 pr_err("read a zero ratio, should be incorrect!\n");
41 pr_err("force tsc ratio to 16 ...\n");
42 ratio = 16;
43 }
44 rdmsr(MSR_FSB_FREQ, lo, hi);
45 if ((lo & 0x7) == 0x7)
46 fsb = FSB_FREQ_83SKU;
47 else
48 fsb = FSB_FREQ_100SKU;
49 fast_calibrate = ratio * fsb;
50 pr_debug("read penwell tsc %lu khz\n", fast_calibrate);
51 lapic_timer_frequency = fsb * 1000 / HZ;
52 /* mark tsc clocksource as reliable */
53 set_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE);
54
55 if (fast_calibrate)
56 return fast_calibrate;
57
58 return 0;
59}
60
61static void __init penwell_arch_setup()
62{
63 x86_platform.calibrate_tsc = mfld_calibrate_tsc;
64 pm_power_off = mfld_power_off;
65}
66
67void * __cpuinit get_penwell_ops()
68{
69 return &penwell_ops;
70}
71
72void * __cpuinit get_cloverview_ops()
73{
74 return &penwell_ops;
75}
diff --git a/arch/x86/platform/intel-mid/mrfl.c b/arch/x86/platform/intel-mid/mrfl.c
new file mode 100644
index 000000000000..09d10159e7b7
--- /dev/null
+++ b/arch/x86/platform/intel-mid/mrfl.c
@@ -0,0 +1,103 @@
1/*
2 * mrfl.c: Intel Merrifield platform specific setup code
3 *
4 * (C) Copyright 2013 Intel Corporation
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; version 2
9 * of the License.
10 */
11
12#include <linux/init.h>
13
14#include <asm/apic.h>
15#include <asm/intel-mid.h>
16
17#include "intel_mid_weak_decls.h"
18
19static unsigned long __init tangier_calibrate_tsc(void)
20{
21 unsigned long fast_calibrate;
22 u32 lo, hi, ratio, fsb, bus_freq;
23
24 /* *********************** */
25 /* Compute TSC:Ratio * FSB */
26 /* *********************** */
27
28 /* Compute Ratio */
29 rdmsr(MSR_PLATFORM_INFO, lo, hi);
30 pr_debug("IA32 PLATFORM_INFO is 0x%x : %x\n", hi, lo);
31
32 ratio = (lo >> 8) & 0xFF;
33 pr_debug("ratio is %d\n", ratio);
34 if (!ratio) {
35 pr_err("Read a zero ratio, force tsc ratio to 4 ...\n");
36 ratio = 4;
37 }
38
39 /* Compute FSB */
40 rdmsr(MSR_FSB_FREQ, lo, hi);
41 pr_debug("Actual FSB frequency detected by SOC 0x%x : %x\n",
42 hi, lo);
43
44 bus_freq = lo & 0x7;
45 pr_debug("bus_freq = 0x%x\n", bus_freq);
46
47 if (bus_freq == 0)
48 fsb = FSB_FREQ_100SKU;
49 else if (bus_freq == 1)
50 fsb = FSB_FREQ_100SKU;
51 else if (bus_freq == 2)
52 fsb = FSB_FREQ_133SKU;
53 else if (bus_freq == 3)
54 fsb = FSB_FREQ_167SKU;
55 else if (bus_freq == 4)
56 fsb = FSB_FREQ_83SKU;
57 else if (bus_freq == 5)
58 fsb = FSB_FREQ_400SKU;
59 else if (bus_freq == 6)
60 fsb = FSB_FREQ_267SKU;
61 else if (bus_freq == 7)
62 fsb = FSB_FREQ_333SKU;
63 else {
64 BUG();
65 pr_err("Invalid bus_freq! Setting to minimal value!\n");
66 fsb = FSB_FREQ_100SKU;
67 }
68
69 /* TSC = FSB Freq * Resolved HFM Ratio */
70 fast_calibrate = ratio * fsb;
71 pr_debug("calculate tangier tsc %lu KHz\n", fast_calibrate);
72
73 /* ************************************ */
74 /* Calculate Local APIC Timer Frequency */
75 /* ************************************ */
76 lapic_timer_frequency = (fsb * 1000) / HZ;
77
78 pr_debug("Setting lapic_timer_frequency = %d\n",
79 lapic_timer_frequency);
80
81 /* mark tsc clocksource as reliable */
82 set_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE);
83
84 if (fast_calibrate)
85 return fast_calibrate;
86
87 return 0;
88}
89
90static void __init tangier_arch_setup(void)
91{
92 x86_platform.calibrate_tsc = tangier_calibrate_tsc;
93}
94
95/* tangier arch ops */
96static struct intel_mid_ops tangier_ops = {
97 .arch_setup = tangier_arch_setup,
98};
99
100void * __cpuinit get_tangier_ops()
101{
102 return &tangier_ops;
103}
diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c
index c84c1ca396bf..994c40bd7cb7 100644
--- a/arch/x86/platform/intel-mid/sfi.c
+++ b/arch/x86/platform/intel-mid/sfi.c
@@ -224,7 +224,7 @@ int get_gpio_by_name(const char *name)
224 if (!strncmp(name, pentry->pin_name, SFI_NAME_LEN)) 224 if (!strncmp(name, pentry->pin_name, SFI_NAME_LEN))
225 return pentry->pin_no; 225 return pentry->pin_no;
226 } 226 }
227 return -1; 227 return -EINVAL;
228} 228}
229 229
230void __init intel_scu_device_register(struct platform_device *pdev) 230void __init intel_scu_device_register(struct platform_device *pdev)
@@ -250,7 +250,7 @@ static void __init intel_scu_spi_device_register(struct spi_board_info *sdev)
250 sdev->modalias); 250 sdev->modalias);
251 return; 251 return;
252 } 252 }
253 memcpy(new_dev, sdev, sizeof(*sdev)); 253 *new_dev = *sdev;
254 254
255 spi_devs[spi_next_dev++] = new_dev; 255 spi_devs[spi_next_dev++] = new_dev;
256} 256}
@@ -271,7 +271,7 @@ static void __init intel_scu_i2c_device_register(int bus,
271 idev->type); 271 idev->type);
272 return; 272 return;
273 } 273 }
274 memcpy(new_dev, idev, sizeof(*idev)); 274 *new_dev = *idev;
275 275
276 i2c_bus[i2c_next_dev] = bus; 276 i2c_bus[i2c_next_dev] = bus;
277 i2c_devs[i2c_next_dev++] = new_dev; 277 i2c_devs[i2c_next_dev++] = new_dev;
@@ -337,6 +337,8 @@ static void __init sfi_handle_ipc_dev(struct sfi_device_table_entry *pentry,
337 pr_debug("IPC bus, name = %16.16s, irq = 0x%2x\n", 337 pr_debug("IPC bus, name = %16.16s, irq = 0x%2x\n",
338 pentry->name, pentry->irq); 338 pentry->name, pentry->irq);
339 pdata = intel_mid_sfi_get_pdata(dev, pentry); 339 pdata = intel_mid_sfi_get_pdata(dev, pentry);
340 if (IS_ERR(pdata))
341 return;
340 342
341 pdev = platform_device_alloc(pentry->name, 0); 343 pdev = platform_device_alloc(pentry->name, 0);
342 if (pdev == NULL) { 344 if (pdev == NULL) {
@@ -370,6 +372,8 @@ static void __init sfi_handle_spi_dev(struct sfi_device_table_entry *pentry,
370 spi_info.chip_select); 372 spi_info.chip_select);
371 373
372 pdata = intel_mid_sfi_get_pdata(dev, &spi_info); 374 pdata = intel_mid_sfi_get_pdata(dev, &spi_info);
375 if (IS_ERR(pdata))
376 return;
373 377
374 spi_info.platform_data = pdata; 378 spi_info.platform_data = pdata;
375 if (dev->delay) 379 if (dev->delay)
@@ -395,6 +399,8 @@ static void __init sfi_handle_i2c_dev(struct sfi_device_table_entry *pentry,
395 i2c_info.addr); 399 i2c_info.addr);
396 pdata = intel_mid_sfi_get_pdata(dev, &i2c_info); 400 pdata = intel_mid_sfi_get_pdata(dev, &i2c_info);
397 i2c_info.platform_data = pdata; 401 i2c_info.platform_data = pdata;
402 if (IS_ERR(pdata))
403 return;
398 404
399 if (dev->delay) 405 if (dev->delay)
400 intel_scu_i2c_device_register(pentry->host_num, &i2c_info); 406 intel_scu_i2c_device_register(pentry->host_num, &i2c_info);
@@ -443,13 +449,35 @@ static int __init sfi_parse_devs(struct sfi_table_header *table)
443 * so we have to enable them one by one here 449 * so we have to enable them one by one here
444 */ 450 */
445 ioapic = mp_find_ioapic(irq); 451 ioapic = mp_find_ioapic(irq);
446 irq_attr.ioapic = ioapic; 452 if (ioapic >= 0) {
447 irq_attr.ioapic_pin = irq; 453 irq_attr.ioapic = ioapic;
448 irq_attr.trigger = 1; 454 irq_attr.ioapic_pin = irq;
449 irq_attr.polarity = 1; 455 irq_attr.trigger = 1;
450 io_apic_set_pci_routing(NULL, irq, &irq_attr); 456 if (intel_mid_identify_cpu() ==
451 } else 457 INTEL_MID_CPU_CHIP_TANGIER) {
458 if (!strncmp(pentry->name,
459 "r69001-ts-i2c", 13))
460 /* active low */
461 irq_attr.polarity = 1;
462 else if (!strncmp(pentry->name,
463 "synaptics_3202", 14))
464 /* active low */
465 irq_attr.polarity = 1;
466 else if (irq == 41)
467 /* fast_int_1 */
468 irq_attr.polarity = 1;
469 else
470 /* active high */
471 irq_attr.polarity = 0;
472 } else {
473 /* PNW and CLV go with active low */
474 irq_attr.polarity = 1;
475 }
476 io_apic_set_pci_routing(NULL, irq, &irq_attr);
477 }
478 } else {
452 irq = 0; /* No irq */ 479 irq = 0; /* No irq */
480 }
453 481
454 dev = get_device_id(pentry->type, pentry->name); 482 dev = get_device_id(pentry->type, pentry->name);
455 483