Commit c945d022 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 platform updates from Ingo Molnar:
 "Misc platform updates: SGI UV4 support additions, intel-mid Merrifield
  enhancements and purge of old code"

* 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (21 commits)
  x86/platform/UV/NMI: Fix uneccessary kABI breakage
  x86/platform/UV: Clean up the NMI code to match current coding style
  x86/platform/UV: Ensure uv_system_init is called when necessary
  x86/platform/UV: Initialize PCH GPP_D_0 NMI Pin to be NMI source
  x86/platform/UV: Verify NMI action is valid, default is standard
  x86/platform/UV: Add basic CPU NMI health check
  x86/platform/UV: Add Support for UV4 Hubless NMIs
  x86/platform/UV: Add Support for UV4 Hubless systems
  x86/platform/UV: Clean up the UV APIC code
  x86/platform/intel-mid: Move watchdog registration to arch_initcall()
  x86/platform/intel-mid: Don't shadow error code of mp_map_gsi_to_irq()
  x86/platform/intel-mid: Allocate RTC interrupt for Merrifield
  x86/ioapic: Return suitable error code in mp_map_gsi_to_irq()
  x86/platform/UV: Fix 2 socket config problem
  x86/platform/UV: Fix panic with missing UVsystab support
  x86/platform/intel-mid: Enable RTC on Intel Merrifield
  x86/platform/intel: Remove PMIC GPIO block support
  x86/platform/intel-mid: Make intel_scu_device_register() static
  x86/platform/intel-mid: Enable GPIO keys on Merrifield
  x86/platform/intel-mid: Get rid of duplication of IPC handler
  ...
parents 8b5abde1 d48085f0
...@@ -27,7 +27,6 @@ extern void intel_mid_pwr_power_off(void); ...@@ -27,7 +27,6 @@ extern void intel_mid_pwr_power_off(void);
extern int intel_mid_pwr_get_lss_id(struct pci_dev *pdev); extern int intel_mid_pwr_get_lss_id(struct pci_dev *pdev);
extern int get_gpio_by_name(const char *name); extern int get_gpio_by_name(const char *name);
extern void intel_scu_device_register(struct platform_device *pdev);
extern int __init sfi_parse_mrtc(struct sfi_table_header *table); extern int __init sfi_parse_mrtc(struct sfi_table_header *table);
extern int __init sfi_parse_mtmr(struct sfi_table_header *table); extern int __init sfi_parse_mtmr(struct sfi_table_header *table);
extern int sfi_mrtc_num; extern int sfi_mrtc_num;
...@@ -42,10 +41,8 @@ struct devs_id { ...@@ -42,10 +41,8 @@ struct devs_id {
char name[SFI_NAME_LEN + 1]; char name[SFI_NAME_LEN + 1];
u8 type; u8 type;
u8 delay; u8 delay;
u8 msic;
void *(*get_platform_data)(void *info); void *(*get_platform_data)(void *info);
/* Custom handler for devices */
void (*device_handler)(struct sfi_device_table_entry *pentry,
struct devs_id *dev);
}; };
#define sfi_device(i) \ #define sfi_device(i) \
......
...@@ -10,6 +10,7 @@ struct mm_struct; ...@@ -10,6 +10,7 @@ struct mm_struct;
extern enum uv_system_type get_uv_system_type(void); extern enum uv_system_type get_uv_system_type(void);
extern int is_uv_system(void); extern int is_uv_system(void);
extern int is_uv_hubless(void);
extern void uv_cpu_init(void); extern void uv_cpu_init(void);
extern void uv_nmi_init(void); extern void uv_nmi_init(void);
extern void uv_system_init(void); extern void uv_system_init(void);
...@@ -23,6 +24,7 @@ extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask, ...@@ -23,6 +24,7 @@ extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; } static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; }
static inline int is_uv_system(void) { return 0; } static inline int is_uv_system(void) { return 0; }
static inline int is_uv_hubless(void) { return 0; }
static inline void uv_cpu_init(void) { } static inline void uv_cpu_init(void) { }
static inline void uv_system_init(void) { } static inline void uv_system_init(void) { }
static inline const struct cpumask * static inline const struct cpumask *
......
...@@ -772,6 +772,7 @@ static inline int uv_num_possible_blades(void) ...@@ -772,6 +772,7 @@ static inline int uv_num_possible_blades(void)
/* Per Hub NMI support */ /* Per Hub NMI support */
extern void uv_nmi_setup(void); extern void uv_nmi_setup(void);
extern void uv_nmi_setup_hubless(void);
/* BMC sets a bit this MMR non-zero before sending an NMI */ /* BMC sets a bit this MMR non-zero before sending an NMI */
#define UVH_NMI_MMR UVH_SCRATCH5 #define UVH_NMI_MMR UVH_SCRATCH5
...@@ -799,6 +800,8 @@ struct uv_hub_nmi_s { ...@@ -799,6 +800,8 @@ struct uv_hub_nmi_s {
atomic_t read_mmr_count; /* count of MMR reads */ atomic_t read_mmr_count; /* count of MMR reads */
atomic_t nmi_count; /* count of true UV NMIs */ atomic_t nmi_count; /* count of true UV NMIs */
unsigned long nmi_value; /* last value read from NMI MMR */ unsigned long nmi_value; /* last value read from NMI MMR */
bool hub_present; /* false means UV hubless system */
bool pch_owner; /* indicates this hub owns PCH */
}; };
struct uv_cpu_nmi_s { struct uv_cpu_nmi_s {
......
...@@ -1107,12 +1107,12 @@ int mp_map_gsi_to_irq(u32 gsi, unsigned int flags, struct irq_alloc_info *info) ...@@ -1107,12 +1107,12 @@ int mp_map_gsi_to_irq(u32 gsi, unsigned int flags, struct irq_alloc_info *info)
ioapic = mp_find_ioapic(gsi); ioapic = mp_find_ioapic(gsi);
if (ioapic < 0) if (ioapic < 0)
return -1; return -ENODEV;
pin = mp_find_ioapic_pin(ioapic, gsi); pin = mp_find_ioapic_pin(ioapic, gsi);
idx = find_irq_entry(ioapic, pin, mp_INT); idx = find_irq_entry(ioapic, pin, mp_INT);
if ((flags & IOAPIC_MAP_CHECK) && idx < 0) if ((flags & IOAPIC_MAP_CHECK) && idx < 0)
return -1; return -ENODEV;
return mp_map_pin_to_irq(gsi, idx, ioapic, pin, flags, info); return mp_map_pin_to_irq(gsi, idx, ioapic, pin, flags, info);
} }
......
This diff is collapsed.
...@@ -1347,7 +1347,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) ...@@ -1347,7 +1347,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
pr_info("CPU0: "); pr_info("CPU0: ");
print_cpu_info(&cpu_data(0)); print_cpu_info(&cpu_data(0));
if (is_uv_system())
uv_system_init(); uv_system_init();
set_mtrr_aps_delayed_init(); set_mtrr_aps_delayed_init();
......
...@@ -5,14 +5,12 @@ obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) += platform_mrfld_sd.o ...@@ -5,14 +5,12 @@ obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) += platform_mrfld_sd.o
# WiFi # WiFi
obj-$(subst m,y,$(CONFIG_BRCMFMAC_SDIO)) += platform_bcm43xx.o obj-$(subst m,y,$(CONFIG_BRCMFMAC_SDIO)) += platform_bcm43xx.o
# IPC Devices # IPC Devices
obj-y += platform_ipc.o
obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic.o obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic.o
obj-$(subst m,y,$(CONFIG_SND_MFLD_MACHINE)) += platform_msic_audio.o obj-$(subst m,y,$(CONFIG_SND_MFLD_MACHINE)) += platform_msic_audio.o
obj-$(subst m,y,$(CONFIG_GPIO_MSIC)) += platform_msic_gpio.o obj-$(subst m,y,$(CONFIG_GPIO_MSIC)) += platform_msic_gpio.o
obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic_ocd.o obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic_ocd.o
obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic_battery.o obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic_battery.o
obj-$(subst m,y,$(CONFIG_INTEL_MID_POWER_BUTTON)) += platform_msic_power_btn.o obj-$(subst m,y,$(CONFIG_INTEL_MID_POWER_BUTTON)) += platform_msic_power_btn.o
obj-$(subst m,y,$(CONFIG_GPIO_INTEL_PMIC)) += platform_pmic_gpio.o
obj-$(subst m,y,$(CONFIG_INTEL_MFLD_THERMAL)) += platform_msic_thermal.o obj-$(subst m,y,$(CONFIG_INTEL_MFLD_THERMAL)) += platform_msic_thermal.o
# SPI Devices # SPI Devices
obj-$(subst m,y,$(CONFIG_SPI_SPIDEV)) += platform_mrfld_spidev.o obj-$(subst m,y,$(CONFIG_SPI_SPIDEV)) += platform_mrfld_spidev.o
...@@ -28,4 +26,5 @@ obj-$(subst m,y,$(CONFIG_GPIO_PCA953X)) += platform_pcal9555a.o ...@@ -28,4 +26,5 @@ obj-$(subst m,y,$(CONFIG_GPIO_PCA953X)) += platform_pcal9555a.o
obj-$(subst m,y,$(CONFIG_GPIO_PCA953X)) += platform_tca6416.o obj-$(subst m,y,$(CONFIG_GPIO_PCA953X)) += platform_tca6416.o
# MISC Devices # MISC Devices
obj-$(subst m,y,$(CONFIG_KEYBOARD_GPIO)) += platform_gpio_keys.o obj-$(subst m,y,$(CONFIG_KEYBOARD_GPIO)) += platform_gpio_keys.o
obj-$(subst m,y,$(CONFIG_RTC_DRV_CMOS)) += platform_mrfld_rtc.o
obj-$(subst m,y,$(CONFIG_INTEL_MID_WATCHDOG)) += platform_mrfld_wdt.o obj-$(subst m,y,$(CONFIG_INTEL_MID_WATCHDOG)) += platform_mrfld_wdt.o
...@@ -32,6 +32,9 @@ static struct gpio_keys_button gpio_button[] = { ...@@ -32,6 +32,9 @@ static struct gpio_keys_button gpio_button[] = {
{SW_LID, -1, 1, "lid_switch", EV_SW, 0, 20}, {SW_LID, -1, 1, "lid_switch", EV_SW, 0, 20},
{KEY_VOLUMEUP, -1, 1, "vol_up", EV_KEY, 0, 20}, {KEY_VOLUMEUP, -1, 1, "vol_up", EV_KEY, 0, 20},
{KEY_VOLUMEDOWN, -1, 1, "vol_down", EV_KEY, 0, 20}, {KEY_VOLUMEDOWN, -1, 1, "vol_down", EV_KEY, 0, 20},
{KEY_MUTE, -1, 1, "mute_enable", EV_KEY, 0, 20},
{KEY_VOLUMEUP, -1, 1, "volume_up", EV_KEY, 0, 20},
{KEY_VOLUMEDOWN, -1, 1, "volume_down", EV_KEY, 0, 20},
{KEY_CAMERA, -1, 1, "camera_full", EV_KEY, 0, 20}, {KEY_CAMERA, -1, 1, "camera_full", EV_KEY, 0, 20},
{KEY_CAMERA_FOCUS, -1, 1, "camera_half", EV_KEY, 0, 20}, {KEY_CAMERA_FOCUS, -1, 1, "camera_half", EV_KEY, 0, 20},
{SW_KEYPAD_SLIDE, -1, 1, "MagSw1", EV_SW, 0, 20}, {SW_KEYPAD_SLIDE, -1, 1, "MagSw1", EV_SW, 0, 20},
......
/*
* platform_ipc.c: IPC platform library file
*
* (C) Copyright 2013 Intel Corporation
* Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/sfi.h>
#include <linux/gpio.h>
#include <asm/intel-mid.h>
#include "platform_ipc.h"
void __init ipc_device_handler(struct sfi_device_table_entry *pentry,
struct devs_id *dev)
{
struct platform_device *pdev;
void *pdata = NULL;
static struct resource res __initdata = {
.name = "IRQ",
.flags = IORESOURCE_IRQ,
};
pr_debug("IPC bus, name = %16.16s, irq = 0x%2x\n",
pentry->name, pentry->irq);
/*
* We need to call platform init of IPC devices to fill misc_pdata
* structure. It will be used in msic_init for initialization.
*/
if (dev != NULL)
pdata = dev->get_platform_data(pentry);
/*
* On Medfield the platform device creation is handled by the MSIC
* MFD driver so we don't need to do it here.
*/
if (intel_mid_has_msic())
return;
pdev = platform_device_alloc(pentry->name, 0);
if (pdev == NULL) {
pr_err("out of memory for SFI platform device '%s'.\n",
pentry->name);
return;
}
res.start = pentry->irq;
platform_device_add_resources(pdev, &res, 1);
pdev->dev.platform_data = pdata;
intel_scu_device_register(pdev);
}
static const struct devs_id pmic_audio_dev_id __initconst = {
.name = "pmic_audio",
.type = SFI_DEV_TYPE_IPC,
.delay = 1,
.device_handler = &ipc_device_handler,
};
sfi_device(pmic_audio_dev_id);
/*
* platform_ipc.h: IPC platform library header file
*
* (C) Copyright 2013 Intel Corporation
* Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
*/
#ifndef _PLATFORM_IPC_H_
#define _PLATFORM_IPC_H_
void __init
ipc_device_handler(struct sfi_device_table_entry *pentry, struct devs_id *dev);
#endif
/*
* Intel Merrifield legacy RTC initialization file
*
* (C) Copyright 2017 Intel Corporation
*
* Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
*/
#include <linux/init.h>
#include <asm/hw_irq.h>
#include <asm/intel-mid.h>
#include <asm/io_apic.h>
#include <asm/time.h>
#include <asm/x86_init.h>
static int __init mrfld_legacy_rtc_alloc_irq(void)
{
struct irq_alloc_info info;
int ret;
if (!x86_platform.legacy.rtc)
return -ENODEV;
ioapic_set_alloc_attr(&info, NUMA_NO_NODE, 1, 0);
ret = mp_map_gsi_to_irq(RTC_IRQ, IOAPIC_MAP_ALLOC, &info);
if (ret < 0) {
pr_info("Failed to allocate RTC interrupt. Disabling RTC\n");
x86_platform.legacy.rtc = 0;
return ret;
}
return 0;
}
static int __init mrfld_legacy_rtc_init(void)
{
if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
return -ENODEV;
return mrfld_legacy_rtc_alloc_irq();
}
arch_initcall(mrfld_legacy_rtc_init);
...@@ -28,9 +28,9 @@ static struct platform_device wdt_dev = { ...@@ -28,9 +28,9 @@ static struct platform_device wdt_dev = {
static int tangier_probe(struct platform_device *pdev) static int tangier_probe(struct platform_device *pdev)
{ {
int gsi;
struct irq_alloc_info info; struct irq_alloc_info info;
struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data; struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data;
int gsi, irq;
if (!pdata) if (!pdata)
return -EINVAL; return -EINVAL;
...@@ -38,10 +38,10 @@ static int tangier_probe(struct platform_device *pdev) ...@@ -38,10 +38,10 @@ static int tangier_probe(struct platform_device *pdev)
/* IOAPIC builds identity mapping between GSI and IRQ on MID */ /* IOAPIC builds identity mapping between GSI and IRQ on MID */
gsi = pdata->irq; gsi = pdata->irq;
ioapic_set_alloc_attr(&info, cpu_to_node(0), 1, 0); ioapic_set_alloc_attr(&info, cpu_to_node(0), 1, 0);
if (mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info) <= 0) { irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info);
dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n", if (irq < 0) {
gsi); dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n", gsi);
return -EINVAL; return irq;
} }
return 0; return 0;
...@@ -82,4 +82,4 @@ static int __init register_mid_wdt(void) ...@@ -82,4 +82,4 @@ static int __init register_mid_wdt(void)
return 0; return 0;
} }
rootfs_initcall(register_mid_wdt); arch_initcall(register_mid_wdt);
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <asm/intel-mid.h> #include <asm/intel-mid.h>
#include "platform_msic.h" #include "platform_msic.h"
#include "platform_ipc.h"
static void *msic_audio_platform_data(void *info) static void *msic_audio_platform_data(void *info)
{ {
...@@ -40,8 +39,8 @@ static const struct devs_id msic_audio_dev_id __initconst = { ...@@ -40,8 +39,8 @@ static const struct devs_id msic_audio_dev_id __initconst = {
.name = "msic_audio", .name = "msic_audio",
.type = SFI_DEV_TYPE_IPC, .type = SFI_DEV_TYPE_IPC,
.delay = 1, .delay = 1,
.msic = 1,
.get_platform_data = &msic_audio_platform_data, .get_platform_data = &msic_audio_platform_data,
.device_handler = &ipc_device_handler,
}; };
sfi_device(msic_audio_dev_id); sfi_device(msic_audio_dev_id);
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <asm/intel-mid.h> #include <asm/intel-mid.h>
#include "platform_msic.h" #include "platform_msic.h"
#include "platform_ipc.h"
static void __init *msic_battery_platform_data(void *info) static void __init *msic_battery_platform_data(void *info)
{ {
...@@ -30,8 +29,8 @@ static const struct devs_id msic_battery_dev_id __initconst = { ...@@ -30,8 +29,8 @@ static const struct devs_id msic_battery_dev_id __initconst = {
.name = "msic_battery", .name = "msic_battery",
.type = SFI_DEV_TYPE_IPC, .type = SFI_DEV_TYPE_IPC,
.delay = 1, .delay = 1,
.msic = 1,
.get_platform_data = &msic_battery_platform_data, .get_platform_data = &msic_battery_platform_data,
.device_handler = &ipc_device_handler,
}; };
sfi_device(msic_battery_dev_id); sfi_device(msic_battery_dev_id);
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <asm/intel-mid.h> #include <asm/intel-mid.h>
#include "platform_msic.h" #include "platform_msic.h"
#include "platform_ipc.h"
static void __init *msic_gpio_platform_data(void *info) static void __init *msic_gpio_platform_data(void *info)
{ {
...@@ -41,8 +40,8 @@ static const struct devs_id msic_gpio_dev_id __initconst = { ...@@ -41,8 +40,8 @@ static const struct devs_id msic_gpio_dev_id __initconst = {
.name = "msic_gpio", .name = "msic_gpio",
.type = SFI_DEV_TYPE_IPC, .type = SFI_DEV_TYPE_IPC,
.delay = 1, .delay = 1,
.msic = 1,
.get_platform_data = &msic_gpio_platform_data, .get_platform_data = &msic_gpio_platform_data,
.device_handler = &ipc_device_handler,
}; };
sfi_device(msic_gpio_dev_id); sfi_device(msic_gpio_dev_id);
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <asm/intel-mid.h> #include <asm/intel-mid.h>
#include "platform_msic.h" #include "platform_msic.h"
#include "platform_ipc.h"
static void __init *msic_ocd_platform_data(void *info) static void __init *msic_ocd_platform_data(void *info)
{ {
...@@ -42,8 +41,8 @@ static const struct devs_id msic_ocd_dev_id __initconst = { ...@@ -42,8 +41,8 @@ static const struct devs_id msic_ocd_dev_id __initconst = {
.name = "msic_ocd", .name = "msic_ocd",
.type = SFI_DEV_TYPE_IPC, .type = SFI_DEV_TYPE_IPC,
.delay = 1, .delay = 1,
.msic = 1,
.get_platform_data = &msic_ocd_platform_data, .get_platform_data = &msic_ocd_platform_data,
.device_handler = &ipc_device_handler,
}; };
sfi_device(msic_ocd_dev_id); sfi_device(msic_ocd_dev_id);
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <asm/intel-mid.h> #include <asm/intel-mid.h>
#include "platform_msic.h" #include "platform_msic.h"
#include "platform_ipc.h"
static void __init *msic_power_btn_platform_data(void *info) static void __init *msic_power_btn_platform_data(void *info)
{ {
...@@ -29,8 +28,8 @@ static const struct devs_id msic_power_btn_dev_id __initconst = { ...@@ -29,8 +28,8 @@ static const struct devs_id msic_power_btn_dev_id __initconst = {
.name = "msic_power_btn", .name = "msic_power_btn",
.type = SFI_DEV_TYPE_IPC, .type = SFI_DEV_TYPE_IPC,
.delay = 1, .delay = 1,
.msic = 1,
.get_platform_data = &msic_power_btn_platform_data, .get_platform_data = &msic_power_btn_platform_data,
.device_handler = &ipc_device_handler,
}; };
sfi_device(msic_power_btn_dev_id); sfi_device(msic_power_btn_dev_id);
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <asm/intel-mid.h> #include <asm/intel-mid.h>
#include "platform_msic.h" #include "platform_msic.h"
#include "platform_ipc.h"
static void __init *msic_thermal_platform_data(void *info) static void __init *msic_thermal_platform_data(void *info)
{ {
...@@ -30,8 +29,8 @@ static const struct devs_id msic_thermal_dev_id __initconst = { ...@@ -30,8 +29,8 @@ static const struct devs_id msic_thermal_dev_id __initconst = {
.name = "msic_thermal", .name = "msic_thermal",
.type = SFI_DEV_TYPE_IPC, .type = SFI_DEV_TYPE_IPC,
.delay = 1, .delay = 1,
.msic = 1,
.get_platform_data = &msic_thermal_platform_data, .get_platform_data = &msic_thermal_platform_data,
.device_handler = &ipc_device_handler,
}; };
sfi_device(msic_thermal_dev_id); sfi_device(msic_thermal_dev_id);
/*
* platform_pmic_gpio.c: PMIC GPIO platform data initialization file
*
* (C) Copyright 2013 Intel Corporation
* Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
*/
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/scatterlist.h>
#include <linux/gpio.h>
#include <linux/init.h>
#include <linux/sfi.h>
#include <linux/intel_pmic_gpio.h>
#include <asm/intel-mid.h>
#include "platform_ipc.h"
static void __init *pmic_gpio_platform_data(void *info)
{
static struct intel_pmic_gpio_platform_data pmic_gpio_pdata;
int gpio_base = get_gpio_by_name("pmic_gpio_base");
if (gpio_base < 0)
gpio_base = 64;
pmic_gpio_pdata.gpio_base = gpio_base;
pmic_gpio_pdata.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
pmic_gpio_pdata.gpiointr = 0xffffeff8;
return &pmic_gpio_pdata;
}
static const struct devs_id pmic_gpio_spi_dev_id __initconst = {
.name = "pmic_gpio",
.type = SFI_DEV_TYPE_SPI,
.delay = 1,
.get_platform_data = &pmic_gpio_platform_data,
};
static const struct devs_id pmic_gpio_ipc_dev_id __initconst = {
.name = "pmic_gpio",
.type = SFI_DEV_TYPE_IPC,
.delay = 1,
.get_platform_data = &pmic_gpio_platform_data,
.device_handler = &ipc_device_handler
};
sfi_device(pmic_gpio_spi_dev_id);
sfi_device(pmic_gpio_ipc_dev_id);
...@@ -91,6 +91,7 @@ static unsigned long __init tangier_calibrate_tsc(void) ...@@ -91,6 +91,7 @@ static unsigned long __init tangier_calibrate_tsc(void)
static void __init tangier_arch_setup(void) static void __init tangier_arch_setup(void)
{ {
x86_platform.calibrate_tsc = tangier_calibrate_tsc; x86_platform.calibrate_tsc = tangier_calibrate_tsc;
x86_platform.legacy.rtc = 1;
} }
/* tangier arch ops */ /* tangier arch ops */
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/sfi.h> #include <linux/sfi.h>
#include <linux/intel_pmic_gpio.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
...@@ -226,7 +225,7 @@ int get_gpio_by_name(const char *name) ...@@ -226,7 +225,7 @@ int get_gpio_by_name(const char *name)
return -EINVAL; return -EINVAL;
} }
void __init intel_scu_device_register(struct platform_device *pdev) static void __init intel_scu_ipc_device_register(struct platform_device *pdev)
{ {
if (ipc_next_dev == MAX_IPCDEVS) if (ipc_next_dev == MAX_IPCDEVS)
pr_err("too many SCU IPC devices"); pr_err("too many SCU IPC devices");
...@@ -335,10 +334,22 @@ static void __init sfi_handle_ipc_dev(struct sfi_device_table_entry *pentry, ...@@ -335,10 +334,22 @@ static void __init sfi_handle_ipc_dev(struct sfi_device_table_entry *pentry,
pr_debug("IPC bus, name = %16.16s, irq = 0x%2x\n", pr_debug("IPC bus, name = %16.16s, irq = 0x%2x\n",
pentry->name, pentry->irq); pentry->name, pentry->irq);
/*
* We need to call platform init of IPC devices to fill misc_pdata
* structure. It will be used in msic_init for initialization.
*/
pdata = intel_mid_sfi_get_pdata(dev, pentry); pdata = intel_mid_sfi_get_pdata(dev, pentry);
if (IS_ERR(pdata)) if (IS_ERR(pdata))
return; return;
/*
* On Medfield the platform device creation is handled by the MSIC
* MFD driver so we don't need to do it here.
*/
if (dev->msic && intel_mid_has_msic())
return;
pdev = platform_device_alloc(pentry->name, 0); pdev = platform_device_alloc(pentry->name, 0);
if (pdev == NULL) { if (pdev == NULL) {
pr_err("out of memory for SFI platform device '%s'.\n", pr_err("out of memory for SFI platform device '%s'.\n",
...@@ -348,6 +359,9 @@ static void __init sfi_handle_ipc_dev(struct sfi_device_table_entry *pentry, ...@@ -348,6 +359,9 @@ static void __init sfi_handle_ipc_dev(struct sfi_device_table_entry *pentry,
install_irq_resource(pdev, pentry->irq); install_irq_resource(pdev, pentry->irq);
pdev->dev.platform_data = pdata; pdev->dev.platform_data = pdata;
if (dev->delay)
intel_scu_ipc_device_register(pdev);
else
platform_device_add(pdev); platform_device_add(pdev);
} }
...@@ -503,9 +517,6 @@ static int __init sfi_parse_devs(struct sfi_table_header *table) ...@@ -503,9 +517,6 @@ static int __init sfi_parse_devs(struct sfi_table_header *table)
if (!dev) if (!dev)
continue; continue;
if (dev->device_handler) {
dev->device_handler(pentry, dev);
} else {
switch (pentry->type) { switch (pentry->type) {
case SFI_DEV_TYPE_IPC: case SFI_DEV_TYPE_IPC:
sfi_handle_ipc_dev(pentry, dev); sfi_handle_ipc_dev(pentry, dev);
...@@ -525,7 +536,6 @@ static int __init sfi_parse_devs(struct sfi_table_header *table) ...@@ -525,7 +536,6 @@ static int __init sfi_parse_devs(struct sfi_table_header *table)
break; break;
} }
} }
}
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -816,13 +816,6 @@ config INTEL_SCU_IPC_UTIL ...@@ -816,13 +816,6 @@ config INTEL_SCU_IPC_UTIL
low level access for debug work and updating the firmware. Say low level access for debug work and updating the firmware. Say
N unless you will be doing this on an Intel MID platform. N unless you will be doing this on an Intel MID platform.
config GPIO_INTEL_PMIC
bool "Intel PMIC GPIO support"
depends on INTEL_SCU_IPC && GPIOLIB
---help---
Say Y here to support GPIO via the SCU IPC interface
on Intel MID platforms.
config INTEL_MID_POWER_BUTTON config INTEL_MID_POWER_BUTTON
tristate "power button driver for Intel MID platforms" tristate "power button driver for Intel MID platforms"
depends on INTEL_SCU_IPC && INPUT depends on INTEL_SCU_IPC && INPUT
......
...@@ -50,7 +50,6 @@ obj-$(CONFIG_INTEL_SCU_IPC) += intel_scu_ipc.o ...@@ -50,7 +50,6 @@ obj-$(CONFIG_INTEL_SCU_IPC) += intel_scu_ipc.o
obj-$(CONFIG_INTEL_SCU_IPC_UTIL) += intel_scu_ipcutil.o obj-$(CONFIG_INTEL_SCU_IPC_UTIL) += intel_scu_ipcutil.o
obj-$(CONFIG_INTEL_MFLD_THERMAL) += intel_mid_thermal.o obj-$(CONFIG_INTEL_MFLD_THERMAL) += intel_mid_thermal.o
obj-$(CONFIG_INTEL_IPS) += intel_ips.o obj-$(CONFIG_INTEL_IPS) += intel_ips.o
obj-$(CONFIG_GPIO_INTEL_PMIC) += intel_pmic_gpio.o
obj-$(CONFIG_XO1_RFKILL) += xo1-rfkill.o obj-$(CONFIG_XO1_RFKILL) += xo1-rfkill.o
obj-$(CONFIG_XO15_EBOOK) += xo15-ebook.o obj-$(CONFIG_XO15_EBOOK) += xo15-ebook.o
obj-$(CONFIG_IBM_RTL) += ibm_rtl.o obj-$(CONFIG_IBM_RTL) += ibm_rtl.o
......
/* Moorestown PMIC GPIO (access through IPC) driver
* Copyright (c) 2008 - 2009, Intel Corporation.
*
* Author: Alek Du <alek.du@intel.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Supports:
* Moorestown platform PMIC chip
*/
#define pr_fmt(fmt) "%s: " fmt, __func__
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/stddef.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/gpio/driver.h>
#include <asm/intel_scu_ipc.h>
#include <linux/device.h>
#include <linux/intel_pmic_gpio.h>
#include <linux/platform_device.h>
#define DRIVER_NAME "pmic_gpio"
/* register offset that IPC driver should use
* 8 GPIO + 8 GPOSW (6 controllable) + 8GPO
*/
enum pmic_gpio_register {
GPIO0 = 0xE0,
GPIO7 = 0xE7,
GPIOINT = 0xE8,
GPOSWCTL0 = 0xEC,
GPOSWCTL5 = 0xF1,
GPO = 0xF4,
};
/* bits definition for GPIO & GPOSW */
#define GPIO_DRV 0x01
#define GPIO_DIR 0x02
#define GPIO_DIN 0x04
#define GPIO_DOU 0x08
#define GPIO_INTCTL 0x30
#define GPIO_DBC 0xc0
#define GPOSW_DRV 0x01
#define GPOSW_DOU 0x08
#define GPOSW_RDRV 0x30
#define GPIO_UPDATE_TYPE 0x80000000
#define NUM_GPIO 24
struct pmic_gpio {
struct mutex buslock;
struct gpio_chip chip;
void *gpiointr;
int irq;
unsigned irq_base;
unsigned int update_type;
u32 trigger_type;
};
static void pmic_program_irqtype(int gpio, int type)
{
if (type & IRQ_TYPE_EDGE_RISING)
intel_scu_ipc_update_register(GPIO0 + gpio, 0x20, 0x20);
else
intel_scu_ipc_update_register(GPIO0 + gpio, 0x00, 0x20);
if (type & IRQ_TYPE_EDGE_FALLING)
intel_scu_ipc_update_register(GPIO0 + gpio, 0x10, 0x10);
else
intel_scu_ipc_update_register(GPIO0 + gpio, 0x00, 0x10);
};
static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
{
if (offset >= 8) {
pr_err("only pin 0-7 support input\n");
return -1;/* we only have 8 GPIO can use as input */
}
return intel_scu_ipc_update_register(GPIO0 + offset,
GPIO_DIR, GPIO_DIR);
}
static int pmic_gpio_direction_output(struct gpio_chip *chip,
unsigned offset, int value)
{
int rc = 0;
if (offset < 8)/* it is GPIO */
rc = intel_scu_ipc_update_register(GPIO0 + offset,
GPIO_DRV | (value ? GPIO_DOU : 0),
GPIO_DRV | GPIO_DOU | GPIO_DIR);
else if (offset < 16)/* it is GPOSW */
rc = intel_scu_ipc_update_register(GPOSWCTL0 + offset - 8,
GPOSW_DRV | (value ? GPOSW_DOU : 0),
GPOSW_DRV | GPOSW_DOU | GPOSW_RDRV);
else if (offset > 15 && offset < 24)/* it is GPO */
rc = intel_scu_ipc_update_register(GPO,
value ? 1 << (offset - 16) : 0,
1 << (offset - 16));
else {
pr_err("invalid PMIC GPIO pin %d!\n", offset);
WARN_ON(1);
}
return rc;
}
static int pmic_gpio_get(struct gpio_chip *chip, unsigned offset)
{
u8 r;
int ret;
/* we only have 8 GPIO pins we can use as input */
if (offset >= 8)
return -EOPNOTSUPP;
ret = intel_scu_ipc_ioread8(GPIO0 + offset, &r);
if (ret < 0)
return ret;
return r & GPIO_DIN;
}
static void pmic_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{
if (offset < 8)/* it is GPIO */
intel_scu_ipc_update_register(GPIO0 + offset,
GPIO_DRV | (value ? GPIO_DOU : 0),
GPIO_DRV | GPIO_DOU);
else if (offset < 16)/* it is GPOSW */
intel_scu_ipc_update_register(GPOSWCTL0 + offset - 8,
GPOSW_DRV | (value ? GPOSW_DOU : 0),
GPOSW_DRV | GPOSW_DOU | GPOSW_RDRV);
else if (offset > 15 && offset < 24) /* it is GPO */
intel_scu_ipc_update_register(GPO,
value ? 1 << (offset - 16) : 0,
1 << (offset - 16));
}
/*
* This is called from genirq with pg->buslock locked and
* irq_desc->lock held. We can not access the scu bus here, so we
* store the change and update in the bus_sync_unlock() function below
*/
static int pmic_irq_type(struct irq_data *data, unsigned type)
{
struct pmic_gpio *pg = irq_data_get_irq_chip_data(data);
u32 gpio = data->irq - pg->irq_base;
if (gpio >= pg->chip.ngpio)
return -EINVAL;
pg->trigger_type = type;
pg->update_type = gpio | GPIO_UPDATE_TYPE;
return 0;
}
static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
{
struct pmic_gpio *pg = gpiochip_get_data(chip);
return pg->irq_base + offset;
}
static void pmic_bus_lock(struct irq_data *data)
{
struct pmic_gpio *pg = irq_data_get_irq_chip_data(data);
mutex_lock(&pg->buslock);
}
static void pmic_bus_sync_unlock(struct irq_data *data)
{
struct pmic_gpio *pg = irq_data_get_irq_chip_data(data);
if (pg->update_type) {
unsigned int gpio = pg->update_type & ~GPIO_UPDATE_TYPE;
pmic_program_irqtype(gpio, pg->trigger_type);
pg->update_type = 0;
}
mutex_unlock(&pg->buslock);
}
/* the gpiointr register is read-clear, so just do nothing. */
static void pmic_irq_unmask(struct irq_data *data) { }
static void pmic_irq_mask(struct irq_data *data) { }
static struct irq_chip pmic_irqchip = {
.name = "PMIC-GPIO",
.irq_mask = pmic_irq_mask,
.irq_unmask = pmic_irq_unmask,
.irq_set_type = pmic_irq_type,
.irq_bus_lock = pmic_bus_lock,
.irq_bus_sync_unlock = pmic_bus_sync_unlock,
};
static irqreturn_t pmic_irq_handler(int irq, void *data)
{
struct pmic_gpio *pg = data;
u8 intsts = *((u8 *)pg->gpiointr + 4);
int gpio;
irqreturn_t ret = IRQ_NONE;
for (gpio = 0; gpio < 8; gpio++) {
if (intsts & (1 << gpio)) {
pr_debug("pmic pin %d triggered\n", gpio);
generic_handle_irq(pg->irq_base + gpio);
ret = IRQ_HANDLED;
}
}
return ret;
}
static int platform_pmic_gpio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
int irq = platform_get_irq(pdev, 0);
struct intel_pmic_gpio_platform_data *pdata = dev->platform_data;
struct pmic_gpio *pg;
int retval;
int i;
if (irq < 0) {
dev_dbg(dev, "no IRQ line\n");
return -EINVAL;
}
if (!pdata || !pdata->gpio_base || !pdata->irq_base) {
dev_dbg(dev, "incorrect or missing platform data\n");
return -EINVAL;
}
pg = kzalloc(sizeof(*pg), GFP_KERNEL);
if (!pg)
return -ENOMEM;
dev_set_drvdata(dev, pg);
pg->irq = irq;
/* setting up SRAM mapping for GPIOINT register */
pg->gpiointr = ioremap_nocache(pdata->gpiointr, 8);
if (!pg->gpiointr) {
pr_err("Can not map GPIOINT\n");
retval = -EINVAL;
goto err2;
}
pg->irq_base = pdata->irq_base;
pg->chip.label = "intel_pmic";
pg->chip.direction_input = pmic_gpio_direction_input;
pg->chip.direction_output = pmic_gpio_direction_output;
pg->chip.get = pmic_gpio_get;
pg->chip.set = pmic_gpio_set;
pg->chip.to_irq = pmic_gpio_to_irq;
pg->chip.base = pdata->gpio_base;
pg->chip.ngpio = NUM_GPIO;
pg->chip.can_sleep = 1;
pg->chip.parent = dev;
mutex_init(&pg->buslock);
pg->chip.parent = dev;
retval = gpiochip_add_data(&pg->chip, pg);
if (retval) {
pr_err("Can not add pmic gpio chip\n");
goto err;
}
retval = request_irq(pg->irq, pmic_irq_handler, 0, "pmic", pg);
if (retval) {
pr_warn("Interrupt request failed\n");
goto fail_request_irq;
}
for (i = 0; i < 8; i++) {
irq_set_chip_and_handler_name(i + pg->irq_base,
&pmic_irqchip,
handle_simple_irq,
"demux");
irq_set_chip_data(i + pg->irq_base, pg);
}
return 0;
fail_request_irq:
gpiochip_remove(&pg->chip);
err:
iounmap(pg->gpiointr);
err2:
kfree(pg);
return retval;
}
/* at the same time, register a platform driver
* this supports the sfi 0.81 fw */
static struct platform_driver platform_pmic_gpio_driver = {
.driver = {
.name = DRIVER_NAME,
},
.probe = platform_pmic_gpio_probe,
};
static int __init platform_pmic_gpio_init(void)
{
return platform_driver_register(&platform_pmic_gpio_driver);
}
subsys_initcall(platform_pmic_gpio_init);
#ifndef LINUX_INTEL_PMIC_H
#define LINUX_INTEL_PMIC_H
struct intel_pmic_gpio_platform_data {
/* the first IRQ of the chip */
unsigned irq_base;
/* number assigned to the first GPIO */
unsigned gpio_base;
/* sram address for gpiointr register, the langwell chip will map
* the PMIC spi GPIO expander's GPIOINTR register in sram.
*/
unsigned gpiointr;
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment