kernel_optimize_test/arch/arm/plat-omap/debug-leds.c
Linus Torvalds 8f446a7a06 ARM: soc: driver specific changes
- A long-coming conversion of various platforms to a common LED
   infrastructure
 - AT91 is moved over to use the newer MCI driver for MMC
 - Pincontrol conversions for samsung platforms
 - DT bindings for gscaler on samsung
 - i2c driver fixes for tegra, acked by i2c maintainer
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJQaO48AAoJEIwa5zzehBx3excP/ieEkRhvfnWxdYST6ekvGIQr
 nEyskOh2rVjgYKmSXUJyKSbvG+7bZ8VIxvPvojeAJ/R84pTFMzbR2F0CaPKzAuSW
 inDt6c0Bnx1NZlfUTAoXcz7feyq9zHYNs9BCLoPU0bYNchCCqcWSKzqnpXk2ph/P
 LFnmNa0j6a4E3QJYAjM2zFvc3Tgk+MWTq1fWwNFvsWTh2WbQtmB/iGnzT5Xs4XQh
 u1SSx5tz0lcF5zQRGmJhXgL5+nnIP4sRwRUBAkpe3Gv5cM6WBVEBRDANa5QpbUL2
 RXK5YyCTIln2Me4bPk32zEBLjiZ/WXbmiA2uwoqVgy6XToubemDXd0PtKmjj5tZ1
 BkTD1DND7BKBEQnJj/GBECEdvx2FbrKfruoPcJHvXPZ7Svn5Dt/MWYJQIkRFkuhL
 zlVNoDGWlU8nScGrgmTM56UvWmGWC3UFsWSgdVQNfW9yEva+G1FvRUwUH02Ip5Ad
 4r28JFIn6zyjtM99ZHipU6C6Rze2ordC7fl5X5LBLkVOobioblxCAhIhcqkhfKsk
 rFriNsdfYs7SrJA7mK7GzvaMEJgp/5o1noJKXI7ZBcLI8yYagzbQbPu/vGi6G6d3
 0xC7NaTEJbtoXoDAtmtilLRxmw0YCXgVBBGua0K2YKpcRwnzCHNbV4gsLMnDuOXS
 HP4M96LxLHJlLGCxhEme
 =ck7M
 -----END PGP SIGNATURE-----

Merge tag 'drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc

Pull ARM soc driver specific changes from Olof Johansson:
 - A long-coming conversion of various platforms to a common LED
   infrastructure
 - AT91 is moved over to use the newer MCI driver for MMC
 - Pincontrol conversions for samsung platforms
 - DT bindings for gscaler on samsung
 - i2c driver fixes for tegra, acked by i2c maintainer

Fix up conflicts as per Olof.

* tag 'drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (48 commits)
  drivers: bus: omap_l3: use resources instead of hardcoded irqs
  pinctrl: exynos: Fix wakeup IRQ domain registration check
  pinctrl: samsung: Uninline samsung_pinctrl_get_soc_data
  pinctrl: exynos: Correct the detection of wakeup-eint node
  pinctrl: exynos: Mark exynos_irq_demux_eint as inline
  pinctrl: exynos: Handle only unmasked wakeup interrupts
  pinctrl: exynos: Fix typos in gpio/wkup _irq_mask
  pinctrl: exynos: Set pin function to EINT in irq_set_type of GPIO EINTa
  drivers: bus: Move the OMAP interconnect driver to drivers/bus/
  i2c: tegra: dynamically control fast clk
  i2c: tegra: I2_M_NOSTART functionality not supported in Tegra20
  ARM: tegra: clock: remove unused clock entry for i2c
  ARM: tegra: clock: add connection name in i2c clock entry
  i2c: tegra: pass proper name for getting clock
  ARM: tegra: clock: add i2c fast clock entry in clock table
  ARM: EXYNOS: Adds G-Scaler device from Device Tree
  ARM: EXYNOS: Add clock support for G-Scaler
  ARM: EXYNOS: Enable pinctrl driver support for EXYNOS4 device tree enabled platform
  ARM: dts: Add pinctrl node entries for SAMSUNG EXYNOS4210 SoC
  ARM: EXYNOS: skip wakeup interrupt setup if pinctrl driver is used
  ...
2012-10-01 18:46:13 -07:00

158 lines
3.3 KiB
C

/*
* linux/arch/arm/plat-omap/debug-leds.c
*
* Copyright 2011 by Bryan Wu <bryan.wu@canonical.com>
* Copyright 2003 by Texas Instruments Incorporated
*
* 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.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/leds.h>
#include <linux/io.h>
#include <linux/platform_data/gpio-omap.h>
#include <linux/slab.h>
#include <mach/hardware.h>
#include <asm/mach-types.h>
#include <plat/fpga.h>
/* Many OMAP development platforms reuse the same "debug board"; these
* platforms include H2, H3, H4, and Perseus2. There are 16 LEDs on the
* debug board (all green), accessed through FPGA registers.
*/
static struct h2p2_dbg_fpga __iomem *fpga;
static u16 fpga_led_state;
struct dbg_led {
struct led_classdev cdev;
u16 mask;
};
static const struct {
const char *name;
const char *trigger;
} dbg_leds[] = {
{ "dbg:d4", "heartbeat", },
{ "dbg:d5", "cpu0", },
{ "dbg:d6", "default-on", },
{ "dbg:d7", },
{ "dbg:d8", },
{ "dbg:d9", },
{ "dbg:d10", },
{ "dbg:d11", },
{ "dbg:d12", },
{ "dbg:d13", },
{ "dbg:d14", },
{ "dbg:d15", },
{ "dbg:d16", },
{ "dbg:d17", },
{ "dbg:d18", },
{ "dbg:d19", },
};
/*
* The triggers lines up below will only be used if the
* LED triggers are compiled in.
*/
static void dbg_led_set(struct led_classdev *cdev,
enum led_brightness b)
{
struct dbg_led *led = container_of(cdev, struct dbg_led, cdev);
u16 reg;
reg = __raw_readw(&fpga->leds);
if (b != LED_OFF)
reg |= led->mask;
else
reg &= ~led->mask;
__raw_writew(reg, &fpga->leds);
}
static enum led_brightness dbg_led_get(struct led_classdev *cdev)
{
struct dbg_led *led = container_of(cdev, struct dbg_led, cdev);
u16 reg;
reg = __raw_readw(&fpga->leds);
return (reg & led->mask) ? LED_FULL : LED_OFF;
}
static int fpga_probe(struct platform_device *pdev)
{
struct resource *iomem;
int i;
iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!iomem)
return -ENODEV;
fpga = ioremap(iomem->start, H2P2_DBG_FPGA_SIZE);
__raw_writew(0xff, &fpga->leds);
for (i = 0; i < ARRAY_SIZE(dbg_leds); i++) {
struct dbg_led *led;
led = kzalloc(sizeof(*led), GFP_KERNEL);
if (!led)
break;
led->cdev.name = dbg_leds[i].name;
led->cdev.brightness_set = dbg_led_set;
led->cdev.brightness_get = dbg_led_get;
led->cdev.default_trigger = dbg_leds[i].trigger;
led->mask = BIT(i);
if (led_classdev_register(NULL, &led->cdev) < 0) {
kfree(led);
break;
}
}
return 0;
}
static int fpga_suspend_noirq(struct device *dev)
{
fpga_led_state = __raw_readw(&fpga->leds);
__raw_writew(0xff, &fpga->leds);
return 0;
}
static int fpga_resume_noirq(struct device *dev)
{
__raw_writew(~fpga_led_state, &fpga->leds);
return 0;
}
static const struct dev_pm_ops fpga_dev_pm_ops = {
.suspend_noirq = fpga_suspend_noirq,
.resume_noirq = fpga_resume_noirq,
};
static struct platform_driver led_driver = {
.driver.name = "omap_dbg_led",
.driver.pm = &fpga_dev_pm_ops,
.probe = fpga_probe,
};
static int __init fpga_init(void)
{
if (machine_is_omap_h4()
|| machine_is_omap_h3()
|| machine_is_omap_h2()
|| machine_is_omap_perseus2()
)
return platform_driver_register(&led_driver);
return 0;
}
fs_initcall(fpga_init);