diff options
Diffstat (limited to 'arch/x86/platform')
24 files changed, 959 insertions, 429 deletions
diff --git a/arch/x86/platform/intel-mid/Makefile b/arch/x86/platform/intel-mid/Makefile index b11e5b2de336..01cc29ea5ff7 100644 --- a/arch/x86/platform/intel-mid/Makefile +++ b/arch/x86/platform/intel-mid/Makefile | |||
@@ -1,5 +1,7 @@ | |||
1 | obj-$(CONFIG_X86_INTEL_MID) += intel-mid.o | 1 | obj-$(CONFIG_X86_INTEL_MID) += intel-mid.o |
2 | obj-$(CONFIG_X86_INTEL_MID) += intel_mid_vrtc.o | 2 | obj-$(CONFIG_X86_INTEL_MID) += intel_mid_vrtc.o |
3 | obj-$(CONFIG_EARLY_PRINTK_INTEL_MID) += early_printk_intel_mid.o | 3 | obj-$(CONFIG_EARLY_PRINTK_INTEL_MID) += early_printk_intel_mid.o |
4 | # SFI specific code | 4 | # SFI specific code |
5 | obj-$(CONFIG_SFI) += sfi.o | 5 | ifdef CONFIG_X86_INTEL_MID |
6 | obj-$(CONFIG_SFI) += sfi.o device_libs/ | ||
7 | endif | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/Makefile b/arch/x86/platform/intel-mid/device_libs/Makefile new file mode 100644 index 000000000000..097e7a7940d8 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/Makefile | |||
@@ -0,0 +1,22 @@ | |||
1 | # IPC Devices | ||
2 | obj-y += platform_ipc.o | ||
3 | obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic.o | ||
4 | obj-$(subst m,y,$(CONFIG_SND_MFLD_MACHINE)) += platform_msic_audio.o | ||
5 | obj-$(subst m,y,$(CONFIG_GPIO_MSIC)) += platform_msic_gpio.o | ||
6 | obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic_ocd.o | ||
7 | obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic_battery.o | ||
8 | obj-$(subst m,y,$(CONFIG_INTEL_MID_POWER_BUTTON)) += platform_msic_power_btn.o | ||
9 | obj-$(subst m,y,$(CONFIG_GPIO_INTEL_PMIC)) += platform_pmic_gpio.o | ||
10 | obj-$(subst m,y,$(CONFIG_INTEL_MFLD_THERMAL)) += platform_msic_thermal.o | ||
11 | # I2C Devices | ||
12 | obj-$(subst m,y,$(CONFIG_SENSORS_EMC1403)) += platform_emc1403.o | ||
13 | obj-$(subst m,y,$(CONFIG_SENSORS_LIS3LV02D)) += platform_lis331.o | ||
14 | obj-$(subst m,y,$(CONFIG_GPIO_PCA953X)) += platform_max7315.o | ||
15 | obj-$(subst m,y,$(CONFIG_INPUT_MPU3050)) += platform_mpu3050.o | ||
16 | obj-$(subst m,y,$(CONFIG_INPUT_BMA150)) += platform_bma023.o | ||
17 | obj-$(subst m,y,$(CONFIG_GPIO_PCA953X)) += platform_tca6416.o | ||
18 | obj-$(subst m,y,$(CONFIG_DRM_MEDFIELD)) += platform_tc35876x.o | ||
19 | # SPI Devices | ||
20 | obj-$(subst m,y,$(CONFIG_SERIAL_MRST_MAX3110)) += platform_max3111.o | ||
21 | # MISC Devices | ||
22 | obj-$(subst m,y,$(CONFIG_KEYBOARD_GPIO)) += platform_gpio_keys.o | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_bma023.c b/arch/x86/platform/intel-mid/device_libs/platform_bma023.c new file mode 100644 index 000000000000..0ae7f2ae2296 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_bma023.c | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * platform_bma023.c: bma023 platform data initilization file | ||
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 <asm/intel-mid.h> | ||
13 | |||
14 | static const struct devs_id bma023_dev_id __initconst = { | ||
15 | .name = "bma023", | ||
16 | .type = SFI_DEV_TYPE_I2C, | ||
17 | .delay = 1, | ||
18 | }; | ||
19 | |||
20 | sfi_device(bma023_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c b/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c new file mode 100644 index 000000000000..0d942c1d26d5 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * platform_emc1403.c: emc1403 platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/init.h> | ||
14 | #include <linux/gpio.h> | ||
15 | #include <linux/i2c.h> | ||
16 | #include <asm/intel-mid.h> | ||
17 | |||
18 | static void __init *emc1403_platform_data(void *info) | ||
19 | { | ||
20 | static short intr2nd_pdata; | ||
21 | struct i2c_board_info *i2c_info = info; | ||
22 | int intr = get_gpio_by_name("thermal_int"); | ||
23 | int intr2nd = get_gpio_by_name("thermal_alert"); | ||
24 | |||
25 | if (intr == -1 || intr2nd == -1) | ||
26 | return NULL; | ||
27 | |||
28 | i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
29 | intr2nd_pdata = intr2nd + INTEL_MID_IRQ_OFFSET; | ||
30 | |||
31 | return &intr2nd_pdata; | ||
32 | } | ||
33 | |||
34 | static const struct devs_id emc1403_dev_id __initconst = { | ||
35 | .name = "emc1403", | ||
36 | .type = SFI_DEV_TYPE_I2C, | ||
37 | .delay = 1, | ||
38 | .get_platform_data = &emc1403_platform_data, | ||
39 | }; | ||
40 | |||
41 | sfi_device(emc1403_dev_id); | ||
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 new file mode 100644 index 000000000000..a013a4834bbe --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * platform_gpio_keys.c: gpio_keys platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/input.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/gpio.h> | ||
17 | #include <linux/gpio_keys.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <asm/intel-mid.h> | ||
20 | |||
21 | #define DEVICE_NAME "gpio-keys" | ||
22 | |||
23 | /* | ||
24 | * we will search these buttons in SFI GPIO table (by name) | ||
25 | * and register them dynamically. Please add all possible | ||
26 | * buttons here, we will shrink them if no GPIO found. | ||
27 | */ | ||
28 | static struct gpio_keys_button gpio_button[] = { | ||
29 | {KEY_POWER, -1, 1, "power_btn", EV_KEY, 0, 3000}, | ||
30 | {KEY_PROG1, -1, 1, "prog_btn1", EV_KEY, 0, 20}, | ||
31 | {KEY_PROG2, -1, 1, "prog_btn2", EV_KEY, 0, 20}, | ||
32 | {SW_LID, -1, 1, "lid_switch", EV_SW, 0, 20}, | ||
33 | {KEY_VOLUMEUP, -1, 1, "vol_up", EV_KEY, 0, 20}, | ||
34 | {KEY_VOLUMEDOWN, -1, 1, "vol_down", EV_KEY, 0, 20}, | ||
35 | {KEY_CAMERA, -1, 1, "camera_full", EV_KEY, 0, 20}, | ||
36 | {KEY_CAMERA_FOCUS, -1, 1, "camera_half", EV_KEY, 0, 20}, | ||
37 | {SW_KEYPAD_SLIDE, -1, 1, "MagSw1", EV_SW, 0, 20}, | ||
38 | {SW_KEYPAD_SLIDE, -1, 1, "MagSw2", EV_SW, 0, 20}, | ||
39 | }; | ||
40 | |||
41 | static struct gpio_keys_platform_data gpio_keys = { | ||
42 | .buttons = gpio_button, | ||
43 | .rep = 1, | ||
44 | .nbuttons = -1, /* will fill it after search */ | ||
45 | }; | ||
46 | |||
47 | static struct platform_device pb_device = { | ||
48 | .name = DEVICE_NAME, | ||
49 | .id = -1, | ||
50 | .dev = { | ||
51 | .platform_data = &gpio_keys, | ||
52 | }, | ||
53 | }; | ||
54 | |||
55 | /* | ||
56 | * Shrink the non-existent buttons, register the gpio button | ||
57 | * device if there is some | ||
58 | */ | ||
59 | static int __init pb_keys_init(void) | ||
60 | { | ||
61 | struct gpio_keys_button *gb = gpio_button; | ||
62 | int i, num, good = 0; | ||
63 | |||
64 | num = sizeof(gpio_button) / sizeof(struct gpio_keys_button); | ||
65 | for (i = 0; i < num; i++) { | ||
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, | ||
68 | gb[i].gpio); | ||
69 | if (gb[i].gpio == -1) | ||
70 | continue; | ||
71 | |||
72 | if (i != good) | ||
73 | gb[good] = gb[i]; | ||
74 | good++; | ||
75 | } | ||
76 | |||
77 | if (good) { | ||
78 | gpio_keys.nbuttons = good; | ||
79 | return platform_device_register(&pb_device); | ||
80 | } | ||
81 | return 0; | ||
82 | } | ||
83 | late_initcall(pb_keys_init); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_ipc.c b/arch/x86/platform/intel-mid/device_libs/platform_ipc.c new file mode 100644 index 000000000000..a84b73d6c4a0 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_ipc.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * platform_ipc.c: IPC platform library file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/init.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/sfi.h> | ||
17 | #include <linux/gpio.h> | ||
18 | #include <asm/intel-mid.h> | ||
19 | #include "platform_ipc.h" | ||
20 | |||
21 | void __init ipc_device_handler(struct sfi_device_table_entry *pentry, | ||
22 | struct devs_id *dev) | ||
23 | { | ||
24 | struct platform_device *pdev; | ||
25 | void *pdata = NULL; | ||
26 | static struct resource res __initdata = { | ||
27 | .name = "IRQ", | ||
28 | .flags = IORESOURCE_IRQ, | ||
29 | }; | ||
30 | |||
31 | pr_debug("IPC bus, name = %16.16s, irq = 0x%2x\n", | ||
32 | pentry->name, pentry->irq); | ||
33 | |||
34 | /* | ||
35 | * We need to call platform init of IPC devices to fill misc_pdata | ||
36 | * structure. It will be used in msic_init for initialization. | ||
37 | */ | ||
38 | if (dev != NULL) | ||
39 | pdata = dev->get_platform_data(pentry); | ||
40 | |||
41 | /* | ||
42 | * On Medfield the platform device creation is handled by the MSIC | ||
43 | * MFD driver so we don't need to do it here. | ||
44 | */ | ||
45 | if (intel_mid_has_msic()) | ||
46 | return; | ||
47 | |||
48 | pdev = platform_device_alloc(pentry->name, 0); | ||
49 | if (pdev == NULL) { | ||
50 | pr_err("out of memory for SFI platform device '%s'.\n", | ||
51 | pentry->name); | ||
52 | return; | ||
53 | } | ||
54 | res.start = pentry->irq; | ||
55 | platform_device_add_resources(pdev, &res, 1); | ||
56 | |||
57 | pdev->dev.platform_data = pdata; | ||
58 | intel_scu_device_register(pdev); | ||
59 | } | ||
60 | |||
61 | static const struct devs_id pmic_audio_dev_id __initconst = { | ||
62 | .name = "pmic_audio", | ||
63 | .type = SFI_DEV_TYPE_IPC, | ||
64 | .delay = 1, | ||
65 | .device_handler = &ipc_device_handler, | ||
66 | }; | ||
67 | |||
68 | sfi_device(pmic_audio_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_ipc.h b/arch/x86/platform/intel-mid/device_libs/platform_ipc.h new file mode 100644 index 000000000000..8f568dd79605 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_ipc.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* | ||
2 | * platform_ipc.h: IPC platform library header file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | #ifndef _PLATFORM_IPC_H_ | ||
13 | #define _PLATFORM_IPC_H_ | ||
14 | |||
15 | extern void __init ipc_device_handler(struct sfi_device_table_entry *pentry, | ||
16 | struct devs_id *dev) __attribute__((weak)); | ||
17 | #endif | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_lis331.c b/arch/x86/platform/intel-mid/device_libs/platform_lis331.c new file mode 100644 index 000000000000..15278c11f714 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_lis331.c | |||
@@ -0,0 +1,39 @@ | |||
1 | /* | ||
2 | * platform_lis331.c: lis331 platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/i2c.h> | ||
14 | #include <linux/gpio.h> | ||
15 | #include <asm/intel-mid.h> | ||
16 | |||
17 | static void __init *lis331dl_platform_data(void *info) | ||
18 | { | ||
19 | static short intr2nd_pdata; | ||
20 | struct i2c_board_info *i2c_info = info; | ||
21 | int intr = get_gpio_by_name("accel_int"); | ||
22 | int intr2nd = get_gpio_by_name("accel_2"); | ||
23 | |||
24 | if (intr == -1 || intr2nd == -1) | ||
25 | return NULL; | ||
26 | |||
27 | i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
28 | intr2nd_pdata = intr2nd + INTEL_MID_IRQ_OFFSET; | ||
29 | |||
30 | return &intr2nd_pdata; | ||
31 | } | ||
32 | |||
33 | static const struct devs_id lis331dl_dev_id __initconst = { | ||
34 | .name = "i2c_accel", | ||
35 | .type = SFI_DEV_TYPE_I2C, | ||
36 | .get_platform_data = &lis331dl_platform_data, | ||
37 | }; | ||
38 | |||
39 | sfi_device(lis331dl_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_max3111.c b/arch/x86/platform/intel-mid/device_libs/platform_max3111.c new file mode 100644 index 000000000000..afd1df94e0e5 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_max3111.c | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * platform_max3111.c: max3111 platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/gpio.h> | ||
14 | #include <linux/spi/spi.h> | ||
15 | #include <asm/intel-mid.h> | ||
16 | |||
17 | static void __init *max3111_platform_data(void *info) | ||
18 | { | ||
19 | struct spi_board_info *spi_info = info; | ||
20 | int intr = get_gpio_by_name("max3111_int"); | ||
21 | |||
22 | spi_info->mode = SPI_MODE_0; | ||
23 | if (intr == -1) | ||
24 | return NULL; | ||
25 | spi_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
26 | return NULL; | ||
27 | } | ||
28 | |||
29 | static const struct devs_id max3111_dev_id __initconst = { | ||
30 | .name = "spi_max3111", | ||
31 | .type = SFI_DEV_TYPE_SPI, | ||
32 | .get_platform_data = &max3111_platform_data, | ||
33 | }; | ||
34 | |||
35 | sfi_device(max3111_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_max7315.c b/arch/x86/platform/intel-mid/device_libs/platform_max7315.c new file mode 100644 index 000000000000..94ade10024ae --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_max7315.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /* | ||
2 | * platform_max7315.c: max7315 platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/init.h> | ||
14 | #include <linux/gpio.h> | ||
15 | #include <linux/i2c.h> | ||
16 | #include <linux/platform_data/pca953x.h> | ||
17 | #include <asm/intel-mid.h> | ||
18 | |||
19 | #define MAX7315_NUM 2 | ||
20 | |||
21 | static void __init *max7315_platform_data(void *info) | ||
22 | { | ||
23 | static struct pca953x_platform_data max7315_pdata[MAX7315_NUM]; | ||
24 | static int nr; | ||
25 | struct pca953x_platform_data *max7315 = &max7315_pdata[nr]; | ||
26 | struct i2c_board_info *i2c_info = info; | ||
27 | int gpio_base, intr; | ||
28 | char base_pin_name[SFI_NAME_LEN + 1]; | ||
29 | char intr_pin_name[SFI_NAME_LEN + 1]; | ||
30 | |||
31 | if (nr == MAX7315_NUM) { | ||
32 | pr_err("too many max7315s, we only support %d\n", | ||
33 | MAX7315_NUM); | ||
34 | return NULL; | ||
35 | } | ||
36 | /* we have several max7315 on the board, we only need load several | ||
37 | * instances of the same pca953x driver to cover them | ||
38 | */ | ||
39 | strcpy(i2c_info->type, "max7315"); | ||
40 | if (nr++) { | ||
41 | sprintf(base_pin_name, "max7315_%d_base", nr); | ||
42 | sprintf(intr_pin_name, "max7315_%d_int", nr); | ||
43 | } else { | ||
44 | strcpy(base_pin_name, "max7315_base"); | ||
45 | strcpy(intr_pin_name, "max7315_int"); | ||
46 | } | ||
47 | |||
48 | gpio_base = get_gpio_by_name(base_pin_name); | ||
49 | intr = get_gpio_by_name(intr_pin_name); | ||
50 | |||
51 | if (gpio_base == -1) | ||
52 | return NULL; | ||
53 | max7315->gpio_base = gpio_base; | ||
54 | if (intr != -1) { | ||
55 | i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
56 | max7315->irq_base = gpio_base + INTEL_MID_IRQ_OFFSET; | ||
57 | } else { | ||
58 | i2c_info->irq = -1; | ||
59 | max7315->irq_base = -1; | ||
60 | } | ||
61 | return max7315; | ||
62 | } | ||
63 | |||
64 | static const struct devs_id max7315_dev_id __initconst = { | ||
65 | .name = "i2c_max7315", | ||
66 | .type = SFI_DEV_TYPE_I2C, | ||
67 | .delay = 1, | ||
68 | .get_platform_data = &max7315_platform_data, | ||
69 | }; | ||
70 | |||
71 | static const struct devs_id max7315_2_dev_id __initconst = { | ||
72 | .name = "i2c_max7315_2", | ||
73 | .type = SFI_DEV_TYPE_I2C, | ||
74 | .delay = 1, | ||
75 | .get_platform_data = &max7315_platform_data, | ||
76 | }; | ||
77 | |||
78 | sfi_device(max7315_dev_id); | ||
79 | sfi_device(max7315_2_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c b/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c new file mode 100644 index 000000000000..dd28d63c84fb --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * platform_mpu3050.c: mpu3050 platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/gpio.h> | ||
14 | #include <linux/i2c.h> | ||
15 | #include <asm/intel-mid.h> | ||
16 | |||
17 | static void *mpu3050_platform_data(void *info) | ||
18 | { | ||
19 | struct i2c_board_info *i2c_info = info; | ||
20 | int intr = get_gpio_by_name("mpu3050_int"); | ||
21 | |||
22 | if (intr == -1) | ||
23 | return NULL; | ||
24 | |||
25 | i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
26 | return NULL; | ||
27 | } | ||
28 | |||
29 | static const struct devs_id mpu3050_dev_id __initconst = { | ||
30 | .name = "mpu3050", | ||
31 | .type = SFI_DEV_TYPE_I2C, | ||
32 | .delay = 1, | ||
33 | .get_platform_data = &mpu3050_platform_data, | ||
34 | }; | ||
35 | |||
36 | sfi_device(mpu3050_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic.c b/arch/x86/platform/intel-mid/device_libs/platform_msic.c new file mode 100644 index 000000000000..9f4a775a69d6 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_msic.c | |||
@@ -0,0 +1,87 @@ | |||
1 | /* | ||
2 | * platform_msic.c: MSIC platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/scatterlist.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/sfi.h> | ||
18 | #include <linux/mfd/intel_msic.h> | ||
19 | #include <asm/intel_scu_ipc.h> | ||
20 | #include <asm/intel-mid.h> | ||
21 | #include "platform_msic.h" | ||
22 | |||
23 | struct intel_msic_platform_data msic_pdata; | ||
24 | |||
25 | static struct resource msic_resources[] = { | ||
26 | { | ||
27 | .start = INTEL_MSIC_IRQ_PHYS_BASE, | ||
28 | .end = INTEL_MSIC_IRQ_PHYS_BASE + 64 - 1, | ||
29 | .flags = IORESOURCE_MEM, | ||
30 | }, | ||
31 | }; | ||
32 | |||
33 | static struct platform_device msic_device = { | ||
34 | .name = "intel_msic", | ||
35 | .id = -1, | ||
36 | .dev = { | ||
37 | .platform_data = &msic_pdata, | ||
38 | }, | ||
39 | .num_resources = ARRAY_SIZE(msic_resources), | ||
40 | .resource = msic_resources, | ||
41 | }; | ||
42 | |||
43 | static int msic_scu_status_change(struct notifier_block *nb, | ||
44 | unsigned long code, void *data) | ||
45 | { | ||
46 | if (code == SCU_DOWN) { | ||
47 | platform_device_unregister(&msic_device); | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | return platform_device_register(&msic_device); | ||
52 | } | ||
53 | |||
54 | static int __init msic_init(void) | ||
55 | { | ||
56 | static struct notifier_block msic_scu_notifier = { | ||
57 | .notifier_call = msic_scu_status_change, | ||
58 | }; | ||
59 | |||
60 | /* | ||
61 | * We need to be sure that the SCU IPC is ready before MSIC device | ||
62 | * can be registered. | ||
63 | */ | ||
64 | if (intel_mid_has_msic()) | ||
65 | intel_scu_notifier_add(&msic_scu_notifier); | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | arch_initcall(msic_init); | ||
70 | |||
71 | /* | ||
72 | * msic_generic_platform_data - sets generic platform data for the block | ||
73 | * @info: pointer to the SFI device table entry for this block | ||
74 | * @block: MSIC block | ||
75 | * | ||
76 | * Function sets IRQ number from the SFI table entry for given device to | ||
77 | * the MSIC platform data. | ||
78 | */ | ||
79 | void *msic_generic_platform_data(void *info, enum intel_msic_block block) | ||
80 | { | ||
81 | struct sfi_device_table_entry *entry = info; | ||
82 | |||
83 | BUG_ON(block < 0 || block >= INTEL_MSIC_BLOCK_LAST); | ||
84 | msic_pdata.irq[block] = entry->irq; | ||
85 | |||
86 | return NULL; | ||
87 | } | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic.h b/arch/x86/platform/intel-mid/device_libs/platform_msic.h new file mode 100644 index 000000000000..917eb56d77da --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_msic.h | |||
@@ -0,0 +1,19 @@ | |||
1 | /* | ||
2 | * platform_msic.h: MSIC platform data header file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | #ifndef _PLATFORM_MSIC_H_ | ||
13 | #define _PLATFORM_MSIC_H_ | ||
14 | |||
15 | extern struct intel_msic_platform_data msic_pdata; | ||
16 | |||
17 | extern void *msic_generic_platform_data(void *info, | ||
18 | enum intel_msic_block block) __attribute__((weak)); | ||
19 | #endif | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic_audio.c b/arch/x86/platform/intel-mid/device_libs/platform_msic_audio.c new file mode 100644 index 000000000000..29629397d2b3 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_msic_audio.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * platform_msic_audio.c: MSIC audio platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/scatterlist.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/sfi.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/mfd/intel_msic.h> | ||
20 | #include <asm/intel-mid.h> | ||
21 | |||
22 | #include "platform_msic.h" | ||
23 | #include "platform_ipc.h" | ||
24 | |||
25 | static void *msic_audio_platform_data(void *info) | ||
26 | { | ||
27 | struct platform_device *pdev; | ||
28 | |||
29 | pdev = platform_device_register_simple("sst-platform", -1, NULL, 0); | ||
30 | |||
31 | if (IS_ERR(pdev)) { | ||
32 | pr_err("failed to create audio platform device\n"); | ||
33 | return NULL; | ||
34 | } | ||
35 | |||
36 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_AUDIO); | ||
37 | } | ||
38 | |||
39 | static const struct devs_id msic_audio_dev_id __initconst = { | ||
40 | .name = "msic_audio", | ||
41 | .type = SFI_DEV_TYPE_IPC, | ||
42 | .delay = 1, | ||
43 | .get_platform_data = &msic_audio_platform_data, | ||
44 | .device_handler = &ipc_device_handler, | ||
45 | }; | ||
46 | |||
47 | sfi_device(msic_audio_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic_battery.c b/arch/x86/platform/intel-mid/device_libs/platform_msic_battery.c new file mode 100644 index 000000000000..f446c33df1a8 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_msic_battery.c | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * platform_msic_battery.c: MSIC battery platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/scatterlist.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/sfi.h> | ||
18 | #include <linux/mfd/intel_msic.h> | ||
19 | #include <asm/intel-mid.h> | ||
20 | |||
21 | #include "platform_msic.h" | ||
22 | #include "platform_ipc.h" | ||
23 | |||
24 | static void __init *msic_battery_platform_data(void *info) | ||
25 | { | ||
26 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_BATTERY); | ||
27 | } | ||
28 | |||
29 | static const struct devs_id msic_battery_dev_id __initconst = { | ||
30 | .name = "msic_battery", | ||
31 | .type = SFI_DEV_TYPE_IPC, | ||
32 | .delay = 1, | ||
33 | .get_platform_data = &msic_battery_platform_data, | ||
34 | .device_handler = &ipc_device_handler, | ||
35 | }; | ||
36 | |||
37 | sfi_device(msic_battery_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c b/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c new file mode 100644 index 000000000000..2a4f7b1dd917 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * platform_msic_gpio.c: MSIC GPIO platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/scatterlist.h> | ||
16 | #include <linux/sfi.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/mfd/intel_msic.h> | ||
20 | #include <asm/intel-mid.h> | ||
21 | |||
22 | #include "platform_msic.h" | ||
23 | #include "platform_ipc.h" | ||
24 | |||
25 | static void __init *msic_gpio_platform_data(void *info) | ||
26 | { | ||
27 | static struct intel_msic_gpio_pdata msic_gpio_pdata; | ||
28 | |||
29 | int gpio = get_gpio_by_name("msic_gpio_base"); | ||
30 | |||
31 | if (gpio < 0) | ||
32 | return NULL; | ||
33 | |||
34 | msic_gpio_pdata.gpio_base = gpio; | ||
35 | msic_pdata.gpio = &msic_gpio_pdata; | ||
36 | |||
37 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_GPIO); | ||
38 | } | ||
39 | |||
40 | static const struct devs_id msic_gpio_dev_id __initconst = { | ||
41 | .name = "msic_gpio", | ||
42 | .type = SFI_DEV_TYPE_IPC, | ||
43 | .delay = 1, | ||
44 | .get_platform_data = &msic_gpio_platform_data, | ||
45 | .device_handler = &ipc_device_handler, | ||
46 | }; | ||
47 | |||
48 | sfi_device(msic_gpio_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c b/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c new file mode 100644 index 000000000000..6497111ddb54 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * platform_msic_ocd.c: MSIC OCD platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/scatterlist.h> | ||
16 | #include <linux/sfi.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/mfd/intel_msic.h> | ||
20 | #include <asm/intel-mid.h> | ||
21 | |||
22 | #include "platform_msic.h" | ||
23 | #include "platform_ipc.h" | ||
24 | |||
25 | static void __init *msic_ocd_platform_data(void *info) | ||
26 | { | ||
27 | static struct intel_msic_ocd_pdata msic_ocd_pdata; | ||
28 | int gpio; | ||
29 | |||
30 | gpio = get_gpio_by_name("ocd_gpio"); | ||
31 | |||
32 | if (gpio < 0) | ||
33 | return NULL; | ||
34 | |||
35 | msic_ocd_pdata.gpio = gpio; | ||
36 | msic_pdata.ocd = &msic_ocd_pdata; | ||
37 | |||
38 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_OCD); | ||
39 | } | ||
40 | |||
41 | static const struct devs_id msic_ocd_dev_id __initconst = { | ||
42 | .name = "msic_ocd", | ||
43 | .type = SFI_DEV_TYPE_IPC, | ||
44 | .delay = 1, | ||
45 | .get_platform_data = &msic_ocd_platform_data, | ||
46 | .device_handler = &ipc_device_handler, | ||
47 | }; | ||
48 | |||
49 | sfi_device(msic_ocd_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic_power_btn.c b/arch/x86/platform/intel-mid/device_libs/platform_msic_power_btn.c new file mode 100644 index 000000000000..83a3459bc337 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_msic_power_btn.c | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * platform_msic_power_btn.c: MSIC power btn platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/interrupt.h> | ||
14 | #include <linux/scatterlist.h> | ||
15 | #include <linux/sfi.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/mfd/intel_msic.h> | ||
18 | #include <asm/intel-mid.h> | ||
19 | |||
20 | #include "platform_msic.h" | ||
21 | #include "platform_ipc.h" | ||
22 | |||
23 | static void __init *msic_power_btn_platform_data(void *info) | ||
24 | { | ||
25 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_POWER_BTN); | ||
26 | } | ||
27 | |||
28 | static const struct devs_id msic_power_btn_dev_id __initconst = { | ||
29 | .name = "msic_power_btn", | ||
30 | .type = SFI_DEV_TYPE_IPC, | ||
31 | .delay = 1, | ||
32 | .get_platform_data = &msic_power_btn_platform_data, | ||
33 | .device_handler = &ipc_device_handler, | ||
34 | }; | ||
35 | |||
36 | sfi_device(msic_power_btn_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic_thermal.c b/arch/x86/platform/intel-mid/device_libs/platform_msic_thermal.c new file mode 100644 index 000000000000..a351878b96bc --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_msic_thermal.c | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * platform_msic_thermal.c: msic_thermal platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/input.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/gpio.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/mfd/intel_msic.h> | ||
19 | #include <asm/intel-mid.h> | ||
20 | |||
21 | #include "platform_msic.h" | ||
22 | #include "platform_ipc.h" | ||
23 | |||
24 | static void __init *msic_thermal_platform_data(void *info) | ||
25 | { | ||
26 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_THERMAL); | ||
27 | } | ||
28 | |||
29 | static const struct devs_id msic_thermal_dev_id __initconst = { | ||
30 | .name = "msic_thermal", | ||
31 | .type = SFI_DEV_TYPE_IPC, | ||
32 | .delay = 1, | ||
33 | .get_platform_data = &msic_thermal_platform_data, | ||
34 | .device_handler = &ipc_device_handler, | ||
35 | }; | ||
36 | |||
37 | sfi_device(msic_thermal_dev_id); | ||
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 new file mode 100644 index 000000000000..d87182a09263 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | * platform_pmic_gpio.c: PMIC GPIO platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/scatterlist.h> | ||
16 | #include <linux/gpio.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/sfi.h> | ||
19 | #include <linux/intel_pmic_gpio.h> | ||
20 | #include <asm/intel-mid.h> | ||
21 | |||
22 | #include "platform_ipc.h" | ||
23 | |||
24 | static void __init *pmic_gpio_platform_data(void *info) | ||
25 | { | ||
26 | static struct intel_pmic_gpio_platform_data pmic_gpio_pdata; | ||
27 | int gpio_base = get_gpio_by_name("pmic_gpio_base"); | ||
28 | |||
29 | if (gpio_base == -1) | ||
30 | gpio_base = 64; | ||
31 | pmic_gpio_pdata.gpio_base = gpio_base; | ||
32 | pmic_gpio_pdata.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET; | ||
33 | pmic_gpio_pdata.gpiointr = 0xffffeff8; | ||
34 | |||
35 | return &pmic_gpio_pdata; | ||
36 | } | ||
37 | |||
38 | static const struct devs_id pmic_gpio_spi_dev_id __initconst = { | ||
39 | .name = "pmic_gpio", | ||
40 | .type = SFI_DEV_TYPE_SPI, | ||
41 | .delay = 1, | ||
42 | .get_platform_data = &pmic_gpio_platform_data, | ||
43 | }; | ||
44 | |||
45 | static const struct devs_id pmic_gpio_ipc_dev_id __initconst = { | ||
46 | .name = "pmic_gpio", | ||
47 | .type = SFI_DEV_TYPE_IPC, | ||
48 | .delay = 1, | ||
49 | .get_platform_data = &pmic_gpio_platform_data, | ||
50 | .device_handler = &ipc_device_handler | ||
51 | }; | ||
52 | |||
53 | sfi_device(pmic_gpio_spi_dev_id); | ||
54 | sfi_device(pmic_gpio_ipc_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c b/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c new file mode 100644 index 000000000000..740fc757050c --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * platform_tc35876x.c: tc35876x platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/gpio.h> | ||
14 | #include <linux/i2c/tc35876x.h> | ||
15 | #include <asm/intel-mid.h> | ||
16 | |||
17 | /*tc35876x DSI_LVDS bridge chip and panel platform data*/ | ||
18 | static void *tc35876x_platform_data(void *data) | ||
19 | { | ||
20 | static struct tc35876x_platform_data pdata; | ||
21 | |||
22 | /* gpio pins set to -1 will not be used by the driver */ | ||
23 | pdata.gpio_bridge_reset = get_gpio_by_name("LCMB_RXEN"); | ||
24 | pdata.gpio_panel_bl_en = get_gpio_by_name("6S6P_BL_EN"); | ||
25 | pdata.gpio_panel_vadd = get_gpio_by_name("EN_VREG_LCD_V3P3"); | ||
26 | |||
27 | return &pdata; | ||
28 | } | ||
29 | |||
30 | static const struct devs_id tc35876x_dev_id __initconst = { | ||
31 | .name = "i2c_disp_brig", | ||
32 | .type = SFI_DEV_TYPE_I2C, | ||
33 | .get_platform_data = &tc35876x_platform_data, | ||
34 | }; | ||
35 | |||
36 | sfi_device(tc35876x_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c b/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c new file mode 100644 index 000000000000..22881c9a6737 --- /dev/null +++ b/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | * platform_tca6416.c: tca6416 platform data initilization file | ||
3 | * | ||
4 | * (C) Copyright 2013 Intel Corporation | ||
5 | * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/platform_data/pca953x.h> | ||
14 | #include <linux/i2c.h> | ||
15 | #include <linux/gpio.h> | ||
16 | #include <asm/intel-mid.h> | ||
17 | |||
18 | #define TCA6416_NAME "tca6416" | ||
19 | #define TCA6416_BASE "tca6416_base" | ||
20 | #define TCA6416_INTR "tca6416_int" | ||
21 | |||
22 | static void *tca6416_platform_data(void *info) | ||
23 | { | ||
24 | static struct pca953x_platform_data tca6416; | ||
25 | struct i2c_board_info *i2c_info = info; | ||
26 | int gpio_base, intr; | ||
27 | char base_pin_name[SFI_NAME_LEN + 1]; | ||
28 | char intr_pin_name[SFI_NAME_LEN + 1]; | ||
29 | |||
30 | strcpy(i2c_info->type, TCA6416_NAME); | ||
31 | strcpy(base_pin_name, TCA6416_BASE); | ||
32 | strcpy(intr_pin_name, TCA6416_INTR); | ||
33 | |||
34 | gpio_base = get_gpio_by_name(base_pin_name); | ||
35 | intr = get_gpio_by_name(intr_pin_name); | ||
36 | |||
37 | if (gpio_base == -1) | ||
38 | return NULL; | ||
39 | tca6416.gpio_base = gpio_base; | ||
40 | if (intr != -1) { | ||
41 | i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
42 | tca6416.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET; | ||
43 | } else { | ||
44 | i2c_info->irq = -1; | ||
45 | tca6416.irq_base = -1; | ||
46 | } | ||
47 | return &tca6416; | ||
48 | } | ||
49 | |||
50 | static const struct devs_id tca6416_dev_id __initconst = { | ||
51 | .name = "tca6416", | ||
52 | .type = SFI_DEV_TYPE_I2C, | ||
53 | .delay = 1, | ||
54 | .get_platform_data = &tca6416_platform_data, | ||
55 | }; | ||
56 | |||
57 | sfi_device(tca6416_dev_id); | ||
diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c index 40915698b9b7..523a1c8f7f07 100644 --- a/arch/x86/platform/intel-mid/intel-mid.c +++ b/arch/x86/platform/intel-mid/intel-mid.c | |||
@@ -61,8 +61,6 @@ enum intel_mid_timer_options intel_mid_timer_options; | |||
61 | enum intel_mid_cpu_type __intel_mid_cpu_chip; | 61 | enum intel_mid_cpu_type __intel_mid_cpu_chip; |
62 | EXPORT_SYMBOL_GPL(__intel_mid_cpu_chip); | 62 | EXPORT_SYMBOL_GPL(__intel_mid_cpu_chip); |
63 | 63 | ||
64 | static void __init ipc_device_handler(struct sfi_device_table_entry *pentry, | ||
65 | struct devs_id *dev); | ||
66 | static void intel_mid_power_off(void) | 64 | static void intel_mid_power_off(void) |
67 | { | 65 | { |
68 | } | 66 | } |
@@ -213,420 +211,3 @@ static inline int __init setup_x86_intel_mid_timer(char *arg) | |||
213 | } | 211 | } |
214 | __setup("x86_intel_mid_timer=", setup_x86_intel_mid_timer); | 212 | __setup("x86_intel_mid_timer=", setup_x86_intel_mid_timer); |
215 | 213 | ||
216 | /* the offset for the mapping of global gpio pin to irq */ | ||
217 | #define INTEL_MID_IRQ_OFFSET 0x100 | ||
218 | |||
219 | static void __init *pmic_gpio_platform_data(void *info) | ||
220 | { | ||
221 | static struct intel_pmic_gpio_platform_data pmic_gpio_pdata; | ||
222 | int gpio_base = get_gpio_by_name("pmic_gpio_base"); | ||
223 | |||
224 | if (gpio_base == -1) | ||
225 | gpio_base = 64; | ||
226 | pmic_gpio_pdata.gpio_base = gpio_base; | ||
227 | pmic_gpio_pdata.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET; | ||
228 | pmic_gpio_pdata.gpiointr = 0xffffeff8; | ||
229 | |||
230 | return &pmic_gpio_pdata; | ||
231 | } | ||
232 | |||
233 | static void __init *max3111_platform_data(void *info) | ||
234 | { | ||
235 | struct spi_board_info *spi_info = info; | ||
236 | int intr = get_gpio_by_name("max3111_int"); | ||
237 | |||
238 | spi_info->mode = SPI_MODE_0; | ||
239 | if (intr == -1) | ||
240 | return NULL; | ||
241 | spi_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
242 | return NULL; | ||
243 | } | ||
244 | |||
245 | /* we have multiple max7315 on the board ... */ | ||
246 | #define MAX7315_NUM 2 | ||
247 | static void __init *max7315_platform_data(void *info) | ||
248 | { | ||
249 | static struct pca953x_platform_data max7315_pdata[MAX7315_NUM]; | ||
250 | static int nr; | ||
251 | struct pca953x_platform_data *max7315 = &max7315_pdata[nr]; | ||
252 | struct i2c_board_info *i2c_info = info; | ||
253 | int gpio_base, intr; | ||
254 | char base_pin_name[SFI_NAME_LEN + 1]; | ||
255 | char intr_pin_name[SFI_NAME_LEN + 1]; | ||
256 | |||
257 | if (nr == MAX7315_NUM) { | ||
258 | pr_err("too many max7315s, we only support %d\n", | ||
259 | MAX7315_NUM); | ||
260 | return NULL; | ||
261 | } | ||
262 | /* we have several max7315 on the board, we only need load several | ||
263 | * instances of the same pca953x driver to cover them | ||
264 | */ | ||
265 | strcpy(i2c_info->type, "max7315"); | ||
266 | if (nr++) { | ||
267 | sprintf(base_pin_name, "max7315_%d_base", nr); | ||
268 | sprintf(intr_pin_name, "max7315_%d_int", nr); | ||
269 | } else { | ||
270 | strcpy(base_pin_name, "max7315_base"); | ||
271 | strcpy(intr_pin_name, "max7315_int"); | ||
272 | } | ||
273 | |||
274 | gpio_base = get_gpio_by_name(base_pin_name); | ||
275 | intr = get_gpio_by_name(intr_pin_name); | ||
276 | |||
277 | if (gpio_base == -1) | ||
278 | return NULL; | ||
279 | max7315->gpio_base = gpio_base; | ||
280 | if (intr != -1) { | ||
281 | i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
282 | max7315->irq_base = gpio_base + INTEL_MID_IRQ_OFFSET; | ||
283 | } else { | ||
284 | i2c_info->irq = -1; | ||
285 | max7315->irq_base = -1; | ||
286 | } | ||
287 | return max7315; | ||
288 | } | ||
289 | |||
290 | static void *tca6416_platform_data(void *info) | ||
291 | { | ||
292 | static struct pca953x_platform_data tca6416; | ||
293 | struct i2c_board_info *i2c_info = info; | ||
294 | int gpio_base, intr; | ||
295 | char base_pin_name[SFI_NAME_LEN + 1]; | ||
296 | char intr_pin_name[SFI_NAME_LEN + 1]; | ||
297 | |||
298 | strcpy(i2c_info->type, "tca6416"); | ||
299 | strcpy(base_pin_name, "tca6416_base"); | ||
300 | strcpy(intr_pin_name, "tca6416_int"); | ||
301 | |||
302 | gpio_base = get_gpio_by_name(base_pin_name); | ||
303 | intr = get_gpio_by_name(intr_pin_name); | ||
304 | |||
305 | if (gpio_base == -1) | ||
306 | return NULL; | ||
307 | tca6416.gpio_base = gpio_base; | ||
308 | if (intr != -1) { | ||
309 | i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
310 | tca6416.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET; | ||
311 | } else { | ||
312 | i2c_info->irq = -1; | ||
313 | tca6416.irq_base = -1; | ||
314 | } | ||
315 | return &tca6416; | ||
316 | } | ||
317 | |||
318 | static void *mpu3050_platform_data(void *info) | ||
319 | { | ||
320 | struct i2c_board_info *i2c_info = info; | ||
321 | int intr = get_gpio_by_name("mpu3050_int"); | ||
322 | |||
323 | if (intr == -1) | ||
324 | return NULL; | ||
325 | |||
326 | i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
327 | return NULL; | ||
328 | } | ||
329 | |||
330 | static void __init *emc1403_platform_data(void *info) | ||
331 | { | ||
332 | static short intr2nd_pdata; | ||
333 | struct i2c_board_info *i2c_info = info; | ||
334 | int intr = get_gpio_by_name("thermal_int"); | ||
335 | int intr2nd = get_gpio_by_name("thermal_alert"); | ||
336 | |||
337 | if (intr == -1 || intr2nd == -1) | ||
338 | return NULL; | ||
339 | |||
340 | i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
341 | intr2nd_pdata = intr2nd + INTEL_MID_IRQ_OFFSET; | ||
342 | |||
343 | return &intr2nd_pdata; | ||
344 | } | ||
345 | |||
346 | static void __init *lis331dl_platform_data(void *info) | ||
347 | { | ||
348 | static short intr2nd_pdata; | ||
349 | struct i2c_board_info *i2c_info = info; | ||
350 | int intr = get_gpio_by_name("accel_int"); | ||
351 | int intr2nd = get_gpio_by_name("accel_2"); | ||
352 | |||
353 | if (intr == -1 || intr2nd == -1) | ||
354 | return NULL; | ||
355 | |||
356 | i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; | ||
357 | intr2nd_pdata = intr2nd + INTEL_MID_IRQ_OFFSET; | ||
358 | |||
359 | return &intr2nd_pdata; | ||
360 | } | ||
361 | |||
362 | static void __init *no_platform_data(void *info) | ||
363 | { | ||
364 | return NULL; | ||
365 | } | ||
366 | |||
367 | static struct resource msic_resources[] = { | ||
368 | { | ||
369 | .start = INTEL_MSIC_IRQ_PHYS_BASE, | ||
370 | .end = INTEL_MSIC_IRQ_PHYS_BASE + 64 - 1, | ||
371 | .flags = IORESOURCE_MEM, | ||
372 | }, | ||
373 | }; | ||
374 | |||
375 | static struct intel_msic_platform_data msic_pdata; | ||
376 | |||
377 | static struct platform_device msic_device = { | ||
378 | .name = "intel_msic", | ||
379 | .id = -1, | ||
380 | .dev = { | ||
381 | .platform_data = &msic_pdata, | ||
382 | }, | ||
383 | .num_resources = ARRAY_SIZE(msic_resources), | ||
384 | .resource = msic_resources, | ||
385 | }; | ||
386 | |||
387 | static inline bool intel_mid_has_msic(void) | ||
388 | { | ||
389 | return intel_mid_identify_cpu() == INTEL_MID_CPU_CHIP_PENWELL; | ||
390 | } | ||
391 | |||
392 | static int msic_scu_status_change(struct notifier_block *nb, | ||
393 | unsigned long code, void *data) | ||
394 | { | ||
395 | if (code == SCU_DOWN) { | ||
396 | platform_device_unregister(&msic_device); | ||
397 | return 0; | ||
398 | } | ||
399 | |||
400 | return platform_device_register(&msic_device); | ||
401 | } | ||
402 | |||
403 | static int __init msic_init(void) | ||
404 | { | ||
405 | static struct notifier_block msic_scu_notifier = { | ||
406 | .notifier_call = msic_scu_status_change, | ||
407 | }; | ||
408 | |||
409 | /* | ||
410 | * We need to be sure that the SCU IPC is ready before MSIC device | ||
411 | * can be registered. | ||
412 | */ | ||
413 | if (intel_mid_has_msic()) | ||
414 | intel_scu_notifier_add(&msic_scu_notifier); | ||
415 | |||
416 | return 0; | ||
417 | } | ||
418 | arch_initcall(msic_init); | ||
419 | |||
420 | /* | ||
421 | * msic_generic_platform_data - sets generic platform data for the block | ||
422 | * @info: pointer to the SFI device table entry for this block | ||
423 | * @block: MSIC block | ||
424 | * | ||
425 | * Function sets IRQ number from the SFI table entry for given device to | ||
426 | * the MSIC platform data. | ||
427 | */ | ||
428 | static void *msic_generic_platform_data(void *info, enum intel_msic_block block) | ||
429 | { | ||
430 | struct sfi_device_table_entry *entry = info; | ||
431 | |||
432 | BUG_ON(block < 0 || block >= INTEL_MSIC_BLOCK_LAST); | ||
433 | msic_pdata.irq[block] = entry->irq; | ||
434 | |||
435 | return no_platform_data(info); | ||
436 | } | ||
437 | |||
438 | static void *msic_battery_platform_data(void *info) | ||
439 | { | ||
440 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_BATTERY); | ||
441 | } | ||
442 | |||
443 | static void *msic_gpio_platform_data(void *info) | ||
444 | { | ||
445 | static struct intel_msic_gpio_pdata pdata; | ||
446 | int gpio = get_gpio_by_name("msic_gpio_base"); | ||
447 | |||
448 | if (gpio < 0) | ||
449 | return NULL; | ||
450 | |||
451 | pdata.gpio_base = gpio; | ||
452 | msic_pdata.gpio = &pdata; | ||
453 | |||
454 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_GPIO); | ||
455 | } | ||
456 | |||
457 | static void *msic_audio_platform_data(void *info) | ||
458 | { | ||
459 | struct platform_device *pdev; | ||
460 | |||
461 | pdev = platform_device_register_simple("sst-platform", -1, NULL, 0); | ||
462 | if (IS_ERR(pdev)) { | ||
463 | pr_err("failed to create audio platform device\n"); | ||
464 | return NULL; | ||
465 | } | ||
466 | |||
467 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_AUDIO); | ||
468 | } | ||
469 | |||
470 | static void *msic_power_btn_platform_data(void *info) | ||
471 | { | ||
472 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_POWER_BTN); | ||
473 | } | ||
474 | |||
475 | static void *msic_ocd_platform_data(void *info) | ||
476 | { | ||
477 | static struct intel_msic_ocd_pdata pdata; | ||
478 | int gpio = get_gpio_by_name("ocd_gpio"); | ||
479 | |||
480 | if (gpio < 0) | ||
481 | return NULL; | ||
482 | |||
483 | pdata.gpio = gpio; | ||
484 | msic_pdata.ocd = &pdata; | ||
485 | |||
486 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_OCD); | ||
487 | } | ||
488 | |||
489 | static void *msic_thermal_platform_data(void *info) | ||
490 | { | ||
491 | return msic_generic_platform_data(info, INTEL_MSIC_BLOCK_THERMAL); | ||
492 | } | ||
493 | |||
494 | /* tc35876x DSI-LVDS bridge chip and panel platform data */ | ||
495 | static void *tc35876x_platform_data(void *data) | ||
496 | { | ||
497 | static struct tc35876x_platform_data pdata; | ||
498 | |||
499 | /* gpio pins set to -1 will not be used by the driver */ | ||
500 | pdata.gpio_bridge_reset = get_gpio_by_name("LCMB_RXEN"); | ||
501 | pdata.gpio_panel_bl_en = get_gpio_by_name("6S6P_BL_EN"); | ||
502 | pdata.gpio_panel_vadd = get_gpio_by_name("EN_VREG_LCD_V3P3"); | ||
503 | |||
504 | return &pdata; | ||
505 | } | ||
506 | |||
507 | static const struct devs_id __initconst device_ids[] = { | ||
508 | {"bma023", SFI_DEV_TYPE_I2C, 1, &no_platform_data, NULL}, | ||
509 | {"pmic_gpio", SFI_DEV_TYPE_SPI, 1, &pmic_gpio_platform_data, NULL}, | ||
510 | {"pmic_gpio", SFI_DEV_TYPE_IPC, 1, &pmic_gpio_platform_data, &ipc_device_handler}, | ||
511 | {"spi_max3111", SFI_DEV_TYPE_SPI, 0, &max3111_platform_data, NULL}, | ||
512 | {"i2c_max7315", SFI_DEV_TYPE_I2C, 1, &max7315_platform_data, NULL}, | ||
513 | {"i2c_max7315_2", SFI_DEV_TYPE_I2C, 1, &max7315_platform_data, NULL}, | ||
514 | {"tca6416", SFI_DEV_TYPE_I2C, 1, &tca6416_platform_data, NULL}, | ||
515 | {"emc1403", SFI_DEV_TYPE_I2C, 1, &emc1403_platform_data, NULL}, | ||
516 | {"i2c_accel", SFI_DEV_TYPE_I2C, 0, &lis331dl_platform_data, NULL}, | ||
517 | {"pmic_audio", SFI_DEV_TYPE_IPC, 1, &no_platform_data, &ipc_device_handler}, | ||
518 | {"mpu3050", SFI_DEV_TYPE_I2C, 1, &mpu3050_platform_data, NULL}, | ||
519 | {"i2c_disp_brig", SFI_DEV_TYPE_I2C, 0, &tc35876x_platform_data, NULL}, | ||
520 | |||
521 | /* MSIC subdevices */ | ||
522 | {"msic_battery", SFI_DEV_TYPE_IPC, 1, &msic_battery_platform_data, &ipc_device_handler}, | ||
523 | {"msic_gpio", SFI_DEV_TYPE_IPC, 1, &msic_gpio_platform_data, &ipc_device_handler}, | ||
524 | {"msic_audio", SFI_DEV_TYPE_IPC, 1, &msic_audio_platform_data, &ipc_device_handler}, | ||
525 | {"msic_power_btn", SFI_DEV_TYPE_IPC, 1, &msic_power_btn_platform_data, &ipc_device_handler}, | ||
526 | {"msic_ocd", SFI_DEV_TYPE_IPC, 1, &msic_ocd_platform_data, &ipc_device_handler}, | ||
527 | {"msic_thermal", SFI_DEV_TYPE_IPC, 1, &msic_thermal_platform_data, &ipc_device_handler}, | ||
528 | { 0 } | ||
529 | }; | ||
530 | |||
531 | static void __init ipc_device_handler(struct sfi_device_table_entry *pentry, | ||
532 | struct devs_id *dev) | ||
533 | { | ||
534 | struct platform_device *pdev; | ||
535 | void *pdata = NULL; | ||
536 | static struct resource res __initdata = { | ||
537 | .name = "IRQ", | ||
538 | .flags = IORESOURCE_IRQ, | ||
539 | }; | ||
540 | |||
541 | pr_debug("IPC bus, name = %16.16s, irq = 0x%2x\n", | ||
542 | pentry->name, pentry->irq); | ||
543 | |||
544 | /* | ||
545 | * We need to call platform init of IPC devices to fill misc_pdata | ||
546 | * structure. It will be used in msic_init for initialization. | ||
547 | */ | ||
548 | if (dev != NULL) | ||
549 | pdata = dev->get_platform_data(pentry); | ||
550 | |||
551 | /* | ||
552 | * On Medfield the platform device creation is handled by the MSIC | ||
553 | * MFD driver so we don't need to do it here. | ||
554 | */ | ||
555 | if (intel_mid_has_msic()) | ||
556 | return; | ||
557 | |||
558 | pdev = platform_device_alloc(pentry->name, 0); | ||
559 | if (pdev == NULL) { | ||
560 | pr_err("out of memory for SFI platform device '%s'.\n", | ||
561 | pentry->name); | ||
562 | return; | ||
563 | } | ||
564 | res.start = pentry->irq; | ||
565 | platform_device_add_resources(pdev, &res, 1); | ||
566 | |||
567 | pdev->dev.platform_data = pdata; | ||
568 | intel_scu_device_register(pdev); | ||
569 | } | ||
570 | |||
571 | |||
572 | /* | ||
573 | * we will search these buttons in SFI GPIO table (by name) | ||
574 | * and register them dynamically. Please add all possible | ||
575 | * buttons here, we will shrink them if no GPIO found. | ||
576 | */ | ||
577 | static struct gpio_keys_button gpio_button[] = { | ||
578 | {KEY_POWER, -1, 1, "power_btn", EV_KEY, 0, 3000}, | ||
579 | {KEY_PROG1, -1, 1, "prog_btn1", EV_KEY, 0, 20}, | ||
580 | {KEY_PROG2, -1, 1, "prog_btn2", EV_KEY, 0, 20}, | ||
581 | {SW_LID, -1, 1, "lid_switch", EV_SW, 0, 20}, | ||
582 | {KEY_VOLUMEUP, -1, 1, "vol_up", EV_KEY, 0, 20}, | ||
583 | {KEY_VOLUMEDOWN, -1, 1, "vol_down", EV_KEY, 0, 20}, | ||
584 | {KEY_CAMERA, -1, 1, "camera_full", EV_KEY, 0, 20}, | ||
585 | {KEY_CAMERA_FOCUS, -1, 1, "camera_half", EV_KEY, 0, 20}, | ||
586 | {SW_KEYPAD_SLIDE, -1, 1, "MagSw1", EV_SW, 0, 20}, | ||
587 | {SW_KEYPAD_SLIDE, -1, 1, "MagSw2", EV_SW, 0, 20}, | ||
588 | }; | ||
589 | |||
590 | static struct gpio_keys_platform_data intel_mid_gpio_keys = { | ||
591 | .buttons = gpio_button, | ||
592 | .rep = 1, | ||
593 | .nbuttons = -1, /* will fill it after search */ | ||
594 | }; | ||
595 | |||
596 | static struct platform_device pb_device = { | ||
597 | .name = "gpio-keys", | ||
598 | .id = -1, | ||
599 | .dev = { | ||
600 | .platform_data = &intel_mid_gpio_keys, | ||
601 | }, | ||
602 | }; | ||
603 | |||
604 | /* | ||
605 | * Shrink the non-existent buttons, register the gpio button | ||
606 | * device if there is some | ||
607 | */ | ||
608 | static int __init pb_keys_init(void) | ||
609 | { | ||
610 | struct gpio_keys_button *gb = gpio_button; | ||
611 | int i, num, good = 0; | ||
612 | |||
613 | num = sizeof(gpio_button) / sizeof(struct gpio_keys_button); | ||
614 | for (i = 0; i < num; i++) { | ||
615 | gb[i].gpio = get_gpio_by_name(gb[i].desc); | ||
616 | pr_debug("info[%2d]: name = %s, gpio = %d\n", i, gb[i].desc, | ||
617 | gb[i].gpio); | ||
618 | if (gb[i].gpio == -1) | ||
619 | continue; | ||
620 | |||
621 | if (i != good) | ||
622 | gb[good] = gb[i]; | ||
623 | good++; | ||
624 | } | ||
625 | |||
626 | if (good) { | ||
627 | intel_mid_gpio_keys.nbuttons = good; | ||
628 | return platform_device_register(&pb_device); | ||
629 | } | ||
630 | return 0; | ||
631 | } | ||
632 | late_initcall(pb_keys_init); \ No newline at end of file | ||
diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c index 3f1c171e5ce3..c84c1ca396bf 100644 --- a/arch/x86/platform/intel-mid/sfi.c +++ b/arch/x86/platform/intel-mid/sfi.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <asm/intel_scu_ipc.h> | 42 | #include <asm/intel_scu_ipc.h> |
43 | #include <asm/apb_timer.h> | 43 | #include <asm/apb_timer.h> |
44 | #include <asm/reboot.h> | 44 | #include <asm/reboot.h> |
45 | #include "intel_mid_weak_decls.h" | ||
46 | 45 | ||
47 | #define SFI_SIG_OEM0 "OEM0" | 46 | #define SFI_SIG_OEM0 "OEM0" |
48 | #define MAX_IPCDEVS 24 | 47 | #define MAX_IPCDEVS 24 |
@@ -403,19 +402,20 @@ static void __init sfi_handle_i2c_dev(struct sfi_device_table_entry *pentry, | |||
403 | i2c_register_board_info(pentry->host_num, &i2c_info, 1); | 402 | i2c_register_board_info(pentry->host_num, &i2c_info, 1); |
404 | } | 403 | } |
405 | 404 | ||
405 | extern struct devs_id *const __x86_intel_mid_dev_start[], | ||
406 | *const __x86_intel_mid_dev_end[]; | ||
407 | |||
406 | static struct devs_id __init *get_device_id(u8 type, char *name) | 408 | static struct devs_id __init *get_device_id(u8 type, char *name) |
407 | { | 409 | { |
408 | struct devs_id *dev = device_ids; | 410 | struct devs_id *const *dev_table; |
409 | |||
410 | if (device_ids == NULL) | ||
411 | return NULL; | ||
412 | 411 | ||
413 | while (dev->name[0]) { | 412 | for (dev_table = __x86_intel_mid_dev_start; |
413 | dev_table < __x86_intel_mid_dev_end; dev_table++) { | ||
414 | struct devs_id *dev = *dev_table; | ||
414 | if (dev->type == type && | 415 | if (dev->type == type && |
415 | !strncmp(dev->name, name, SFI_NAME_LEN)) { | 416 | !strncmp(dev->name, name, SFI_NAME_LEN)) { |
416 | return dev; | 417 | return dev; |
417 | } | 418 | } |
418 | dev++; | ||
419 | } | 419 | } |
420 | 420 | ||
421 | return NULL; | 421 | return NULL; |