[PATCH v2 0/4] cbus/retu drivers

2012-10-31 Thread Aaro Koskinen
This patch set introduces drivers for CBUS access and Retu multifunction
chip found on Nokia Internet Tablets (770, N800, N810). It would be
nice get these patches applied as the functionality of these devices is
severely lacking without Retu. E.g. watchdog support is mandatory at
least on Nokia N800, you cannot currently run the mainline kernel for
longer than ~60 seconds (there is no way to disable the watchdog).

Drivers originate from linux-omap cbus branch and have been cleaned
up/rewritten around i2c and MFD core.

Patches have been tested on top of 3.7-rc3 with Nokia N800 (watchdog
feeding works, power off shuts down the device, power button triggers
IRQs and input events).

Changes since the first version (https://lkml.org/lkml/2012/9/3/265):
- i2c-cbus:
- use devres
- improve comments
- simplify and delete redundant code
- refactoring  bug fixes on error handling
- discard input parameter from cbus_send_bit/data()
- retu-mfd:
- use devres
- use regmap
- retu_wdt: use devres
- retu-pwrbutton: use devres

Changes since the RFC version
(http://marc.info/?l=linux-omapm=134618967116737w=2):
- added DT support for getting i2c-cbus GPIO pins
- merged n8x0 board file changes into i2c-cbus patch
- corrected typo in Kconfig for MFD_RETU
- added power off functionality to retu-mfd
- added IRQ functionality to retu-mfd
- added power button key driver
- some cleanups

Aaro Koskinen (4):
  i2c: introduce i2c-cbus driver
  mfd: introduce retu-mfd driver
  watchdog: introduce retu_wdt driver
  input: misc: introduce retu-pwrbutton

 arch/arm/mach-omap2/board-n8x0.c|   42 +
 drivers/i2c/busses/Kconfig  |   10 ++
 drivers/i2c/busses/Makefile |1 +
 drivers/i2c/busses/i2c-cbus.c   |  300 +++
 drivers/input/misc/Kconfig  |   10 ++
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/retu-pwrbutton.c |  118 ++
 drivers/mfd/Kconfig |9 +
 drivers/mfd/Makefile|1 +
 drivers/mfd/retu-mfd.c  |  264 ++
 drivers/watchdog/Kconfig|   12 ++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/retu_wdt.c |  178 +
 include/linux/i2c-cbus.h|   27 +++
 include/linux/mfd/retu.h|   22 +++
 15 files changed, 996 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-cbus.c
 create mode 100644 drivers/input/misc/retu-pwrbutton.c
 create mode 100644 drivers/mfd/retu-mfd.c
 create mode 100644 drivers/watchdog/retu_wdt.c
 create mode 100644 include/linux/i2c-cbus.h
 create mode 100644 include/linux/mfd/retu.h

-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 4/4] input: misc: introduce retu-pwrbutton

2012-10-31 Thread Aaro Koskinen
Add Retu power button driver.

Cc: linux-in...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/input/misc/Kconfig  |   10 +++
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/retu-pwrbutton.c |  118 +++
 3 files changed, 129 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/retu-pwrbutton.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7c0f1ec..e5be189 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -367,6 +367,16 @@ config INPUT_CM109
  To compile this driver as a module, choose M here: the module will be
  called cm109.
 
+config INPUT_RETU_PWRBUTTON
+   tristate Retu Power button Driver
+   depends on MFD_RETU
+   help
+ Say Y here if you want to enable power key reporting via the
+ Retu chips found in Nokia Internet Tablets (770, N800, N810).
+
+ To compile this driver as a module, choose M here. The module will
+ be called retu-pwrbutton.
+
 config INPUT_TWL4030_PWRBUTTON
tristate TWL4030 Power button Driver
depends on TWL4030_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 83fe6f5..4fbee0d 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)   += pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_POWERMATE)  += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)   += rb532_button.o
+obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SPARCSPKR)  += sparcspkr.o
diff --git a/drivers/input/misc/retu-pwrbutton.c 
b/drivers/input/misc/retu-pwrbutton.c
new file mode 100644
index 000..51e94a7
--- /dev/null
+++ b/drivers/input/misc/retu-pwrbutton.c
@@ -0,0 +1,118 @@
+/*
+ * Retu power button driver.
+ *
+ * Copyright (C) 2004-2010 Nokia Corporation
+ *
+ * Original code written by Ari Saastamoinen, Juha Yrjölä and Felipe Balbi.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/irq.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/input.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+
+#define RETU_STATUS_PWRONX (1  5)
+
+struct retu_pwrbutton {
+   struct input_dev*idev;
+   struct retu_dev *rdev;
+   struct device   *dev;
+   boolpressed;
+   int irq;
+};
+
+static irqreturn_t retu_pwrbutton_irq(int irq, void *_pwr)
+{
+   struct retu_pwrbutton *pwr = _pwr;
+   bool state;
+
+   state = !(retu_read(pwr-rdev, RETU_REG_STATUS)  RETU_STATUS_PWRONX);
+
+   if (pwr-pressed != state) {
+   input_report_key(pwr-idev, KEY_POWER, state);
+   input_sync(pwr-idev);
+   pwr-pressed = state;
+   }
+
+   return IRQ_HANDLED;
+}
+
+static int __devinit retu_pwrbutton_probe(struct platform_device *pdev)
+{
+   struct retu_dev *rdev = dev_get_drvdata(pdev-dev.parent);
+   struct retu_pwrbutton *pwr;
+   int ret;
+
+   pwr = devm_kzalloc(pdev-dev, sizeof(*pwr), GFP_KERNEL);
+   if (!pwr)
+   return -ENOMEM;
+
+   pwr-rdev = rdev;
+   pwr-dev  = pdev-dev;
+   pwr-irq  = platform_get_irq(pdev, 0);
+   platform_set_drvdata(pdev, pwr);
+
+   ret = devm_request_threaded_irq(pdev-dev, pwr-irq, NULL,
+   retu_pwrbutton_irq, 0, retu-pwrbutton,
+   pwr);
+   if (ret  0)
+   return ret;
+
+   pwr-idev = input_allocate_device();
+   if (!pwr-idev)
+   return -ENOMEM;
+
+   pwr-idev-evbit[0] = BIT_MASK(EV_KEY);
+   pwr-idev-keybit[BIT_WORD(KEY_POWER)]  = BIT_MASK(KEY_POWER);
+   pwr-idev-name = retu-pwrbutton;
+
+   ret = input_register_device(pwr-idev);
+   if (ret  0) {
+   input_free_device(pwr-idev);
+   return ret;
+   }
+
+   return 0;
+}
+
+static int __devexit retu_pwrbutton_remove(struct platform_device *pdev)
+{
+   struct retu_pwrbutton *pwr = platform_get_drvdata(pdev

[PATCH v2 1/4] i2c: introduce i2c-cbus driver

2012-10-31 Thread Aaro Koskinen
Add i2c driver to enable access to devices behind CBUS on Nokia Internet
Tablets.

The patch also adds CBUS I2C configuration for N8x0 which is one of the
users of this driver.

Cc: linux-...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/arm/mach-omap2/board-n8x0.c |   42 ++
 drivers/i2c/busses/Kconfig   |   10 ++
 drivers/i2c/busses/Makefile  |1 +
 drivers/i2c/busses/i2c-cbus.c|  300 ++
 include/linux/i2c-cbus.h |   27 
 5 files changed, 380 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-cbus.c
 create mode 100644 include/linux/i2c-cbus.h

diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index d95f727..7ea0348 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -16,8 +16,10 @@
 #include linux/gpio.h
 #include linux/init.h
 #include linux/io.h
+#include linux/irq.h
 #include linux/stddef.h
 #include linux/i2c.h
+#include linux/i2c-cbus.h
 #include linux/spi/spi.h
 #include linux/usb/musb.h
 #include linux/platform_data/spi-omap2-mcspi.h
@@ -39,6 +41,45 @@
 #define TUSB6010_GPIO_ENABLE   0
 #define TUSB6010_DMACHAN   0x3f
 
+#if defined(CONFIG_I2C_CBUS) || defined(CONFIG_I2C_CBUS_MODULE)
+static struct i2c_cbus_platform_data n8x0_cbus_data = {
+   .clk_gpio = 66,
+   .dat_gpio = 65,
+   .sel_gpio = 64,
+};
+
+static struct platform_device n8x0_cbus_device = {
+   .name   = i2c-cbus,
+   .id = 3,
+   .dev= {
+   .platform_data = n8x0_cbus_data,
+   },
+};
+
+static struct i2c_board_info n8x0_i2c_board_info_3[] __initdata = {
+   {
+   I2C_BOARD_INFO(retu-mfd, 0x01),
+   },
+};
+
+static void __init n8x0_cbus_init(void)
+{
+   const int retu_irq_gpio = 108;
+
+   if (gpio_request_one(retu_irq_gpio, GPIOF_IN, Retu IRQ))
+   return;
+   irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
+   n8x0_i2c_board_info_3[0].irq = gpio_to_irq(retu_irq_gpio);
+   i2c_register_board_info(3, n8x0_i2c_board_info_3,
+   ARRAY_SIZE(n8x0_i2c_board_info_3));
+   platform_device_register(n8x0_cbus_device);
+}
+#else /* CONFIG_I2C_CBUS */
+static void __init n8x0_cbus_init(void)
+{
+}
+#endif /* CONFIG_I2C_CBUS */
+
 #if defined(CONFIG_USB_MUSB_TUSB6010) || 
defined(CONFIG_USB_MUSB_TUSB6010_MODULE)
 /*
  * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
@@ -677,6 +718,7 @@ static void __init n8x0_init_machine(void)
gpmc_onenand_init(board_onenand_data);
n8x0_mmc_init();
n8x0_usb_init();
+   n8x0_cbus_init();
 }
 
 MACHINE_START(NOKIA_N800, Nokia N800)
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 65dd599..d01c8ef 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -338,6 +338,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
help
  The unit of the TWI clock is kHz.
 
+config I2C_CBUS
+   tristate CBUS I2C driver
+   depends on GENERIC_GPIO
+   help
+ Support for CBUS access using I2C API. Mostly relevant for Nokia
+ Internet Tablets (770, N800 and N810).
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-cbus.
+
 config I2C_CPM
tristate Freescale CPM1 or CPM2 (MPC8xx/826x)
depends on (CPM1 || CPM2)  OF_I2C
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 2d33d62..3c548b1 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_I2C_POWERMAC)+= i2c-powermac.o
 obj-$(CONFIG_I2C_AT91) += i2c-at91.o
 obj-$(CONFIG_I2C_AU1550)   += i2c-au1550.o
 obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
+obj-$(CONFIG_I2C_CBUS) += i2c-cbus.o
 obj-$(CONFIG_I2C_CPM)  += i2c-cpm.o
 obj-$(CONFIG_I2C_DAVINCI)  += i2c-davinci.o
 obj-$(CONFIG_I2C_DESIGNWARE_CORE)  += i2c-designware-core.o
diff --git a/drivers/i2c/busses/i2c-cbus.c b/drivers/i2c/busses/i2c-cbus.c
new file mode 100644
index 000..1ea7667
--- /dev/null
+++ b/drivers/i2c/busses/i2c-cbus.c
@@ -0,0 +1,300 @@
+/*
+ * CBUS I2C driver for Nokia Internet Tablets.
+ *
+ * Copyright (C) 2004-2010 Nokia Corporation
+ *
+ * Based on code written by Juha Yrjölä, David Weinehall, Mikko Ylinen and
+ * Felipe Balbi. Converted to I2C driver by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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

[PATCH v2 2/4] mfd: introduce retu-mfd driver

2012-10-31 Thread Aaro Koskinen
Retu is a multi-function device found on Nokia Internet Tablets
implementing at least watchdog, RTC, headset detection and power button
functionality.

This patch implements minimum functionality providing register access,
IRQ handling and power off functions.

Cc: sa...@linux.intel.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/mfd/Kconfig  |9 ++
 drivers/mfd/Makefile |1 +
 drivers/mfd/retu-mfd.c   |  264 ++
 include/linux/mfd/retu.h |   22 
 4 files changed, 296 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/retu-mfd.c
 create mode 100644 include/linux/mfd/retu.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index acab3ef..7528c5e 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1044,6 +1044,15 @@ config MFD_PALMAS
  If you say yes here you get support for the Palmas
  series of PMIC chips from Texas Instruments.
 
+config MFD_RETU
+   tristate Support for Retu multi-function device
+   select MFD_CORE
+   depends on I2C
+   select REGMAP_IRQ
+   help
+ Retu is a multi-function device found on Nokia Internet Tablets
+ (770, N800 and N810).
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index d8ccb63..ad7879f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -138,3 +138,4 @@ obj-$(CONFIG_MFD_RC5T583)   += rc5t583.o rc5t583-irq.o
 obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o
 obj-$(CONFIG_MFD_SYSCON)   += syscon.o
 obj-$(CONFIG_MFD_LM3533)   += lm3533-core.o lm3533-ctrlbank.o
+obj-$(CONFIG_MFD_RETU) += retu-mfd.o
diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c
new file mode 100644
index 000..8f81566
--- /dev/null
+++ b/drivers/mfd/retu-mfd.c
@@ -0,0 +1,264 @@
+/*
+ * Retu MFD driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Juha Yrjölä, David Weinehall and Mikko Ylinen.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/err.h
+#include linux/i2c.h
+#include linux/irq.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/mutex.h
+#include linux/module.h
+#include linux/regmap.h
+#include linux/mfd/core.h
+#include linux/mfd/retu.h
+#include linux/interrupt.h
+#include linux/moduleparam.h
+
+/* Registers */
+#define RETU_REG_ASICR 0x00/* ASIC ID and revision */
+#define RETU_REG_ASICR_VILMA   (1  7)/* Bit indicating Vilma */
+#define RETU_REG_IDR   0x01/* Interrupt ID */
+#define RETU_REG_IMR   0x02/* Interrupt mask */
+
+/* Interrupt sources */
+#define RETU_INT_PWR   0   /* Power button */
+
+struct retu_dev {
+   struct regmap   *regmap;
+   struct device   *dev;
+   struct mutexmutex;
+   struct regmap_irq_chip_data *irq_data;
+};
+
+static struct resource retu_pwrbutton_res[] = {
+   {
+   .name   = retu-pwrbutton,
+   .start  = RETU_INT_PWR,
+   .end= RETU_INT_PWR,
+   .flags  = IORESOURCE_IRQ,
+   },
+};
+
+static struct mfd_cell retu_devs[] = {
+   {
+   .name   = retu-wdt
+   },
+   {
+   .name   = retu-pwrbutton,
+   .resources  = retu_pwrbutton_res[0],
+   .num_resources  = ARRAY_SIZE(retu_pwrbutton_res),
+   }
+};
+
+static struct regmap_irq retu_irqs[] = {
+   [RETU_INT_PWR] = {
+   .mask = 1  RETU_INT_PWR,
+   }
+};
+
+static struct regmap_irq_chip retu_irq_chip = {
+   .name   = RETU,
+   .irqs   = retu_irqs,
+   .num_irqs   = ARRAY_SIZE(retu_irqs),
+   .num_regs   = 1,
+   .status_base= RETU_REG_IDR,
+   .mask_base  = RETU_REG_IMR,
+   .ack_base   = RETU_REG_IDR,
+};
+
+/* Retu device registered for the power off. */
+static struct retu_dev *retu_pm_power_off;
+
+int retu_read(struct retu_dev *rdev, u8 reg)
+{
+   int ret;
+   int value;
+
+   mutex_lock(rdev-mutex);
+   ret = regmap_read(rdev-regmap, reg, value);
+   mutex_unlock(rdev-mutex);
+
+   return ret ? ret : value;
+}
+EXPORT_SYMBOL_GPL(retu_read);
+
+int retu_write(struct retu_dev *rdev, u8 reg, u16 data)
+{
+   int ret;
+
+   mutex_lock(rdev-mutex);
+   ret = regmap_write(rdev-regmap, reg, data

[PATCH v2 3/4] watchdog: introduce retu_wdt driver

2012-10-31 Thread Aaro Koskinen
Introduce Retu watchdog driver.

Cc: linux-watch...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/Kconfig|   12 +++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/retu_wdt.c |  178 +++
 3 files changed, 191 insertions(+), 0 deletions(-)
 create mode 100644 drivers/watchdog/retu_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ad1bb93..c3a836d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -352,6 +352,18 @@ config IMX2_WDT
  To compile this driver as a module, choose M here: the
  module will be called imx2_wdt.
 
+config RETU_WATCHDOG
+   tristate Retu watchdog
+   depends on MFD_RETU
+   select WATCHDOG_CORE
+   help
+ Retu watchdog driver for Nokia Internet Tablets (700, N800,
+ N810). At least on N800 the watchdog cannot be disabled, so
+ this driver is essential and you should enable it.
+
+ To compile this driver as a module, choose M here: the
+ module will be called retu_wdt.
+
 # AVR32 Architecture
 
 config AT32AP700X_WDT
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 572b39b..d2f1c0c 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o
 obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
 obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
 obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
+obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o
 
 # AVR32 Architecture
 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c
new file mode 100644
index 000..aeb0f39
--- /dev/null
+++ b/drivers/watchdog/retu_wdt.c
@@ -0,0 +1,178 @@
+/*
+ * Retu watchdog driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Amit Kucheria and Michael Buesch.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/device.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/watchdog.h
+#include linux/platform_device.h
+
+/* Watchdog timer values in seconds */
+#define RETU_WDT_MAX_TIMER 63
+
+struct retu_wdt_dev {
+   struct retu_dev *rdev;
+   struct device   *dev;
+   struct delayed_work ping_work;
+};
+
+/*
+ * Since Retu watchdog cannot be disabled in hardware, we must kick it
+ * with a timer until userspace watchdog software takes over. If
+ * CONFIG_WATCHDOG_NOWAYOUT is set, we never start the feeding.
+ */
+static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   schedule_delayed_work(wdev-ping_work,
+   round_jiffies_relative(RETU_WDT_MAX_TIMER * HZ / 2));
+}
+
+static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   cancel_delayed_work_sync(wdev-ping_work);
+}
+
+static void retu_wdt_ping_work(struct work_struct *work)
+{
+   struct retu_wdt_dev *wdev = container_of(to_delayed_work(work),
+   struct retu_wdt_dev, ping_work);
+   retu_wdt_ping_enable(wdev);
+}
+
+static int retu_wdt_start(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_disable(wdev);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_stop(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_enable(wdev);
+
+   return 0;
+}
+
+static int retu_wdt_ping(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_set_timeout(struct watchdog_device *wdog,
+   unsigned int timeout)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   wdog-timeout = timeout;
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static const struct watchdog_info retu_wdt_info = {
+   .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+   .identity = Retu watchdog,
+};
+
+static const struct

[PATCH v3 0/4] cbus/retu drivers

2012-11-01 Thread Aaro Koskinen
This patch set introduces drivers for CBUS access and Retu multifunction
chip found on Nokia Internet Tablets (770, N800, N810). It would be
nice get these patches applied as the functionality of these devices is
severely lacking without Retu. E.g. watchdog support is mandatory at
least on Nokia N800, you cannot currently run the mainline kernel for
longer than ~60 seconds (there is no way to disable the watchdog).

Drivers originate from linux-omap cbus branch and have been cleaned
up/rewritten around i2c and MFD core.

Patches have been tested on top of 3.7-rc3 with Nokia N800 (watchdog
feeding works, power off shuts down the device, power button triggers
IRQs and input events, loading and unloading retu-pwrbutton module in a
loop while manically pressing the power button does not crash the kernel).

Changes since the second version (https://lkml.org/lkml/2012/10/31/520):
- i2c-cbus:
- move i2c-cbus.h under linux/platform_data
- retu-mfd
- replace retu_pwrbutton_res[0] expression with simpler
  retu_pwrbutton_res.
- retu-pwrbutton:
- eliminate struct retu_pwrbutton
- delete checks for duplicate events
- rework probe to avoid races
- disable IRQ before unregister in retu_pwrbutton_remove() to
  avoid races
- eliminate double free in retu_pwrbutton_remove()
- add .owner = THIS_MODULE

Changes since the first version (https://lkml.org/lkml/2012/9/3/265):
- i2c-cbus:
- use devres
- improve comments
- simplify and delete redundant code
- refactoring  bug fixes on error handling
- discard input parameter from cbus_send_bit/data()
- retu-mfd:
- use devres
- use regmap
- retu_wdt: use devres
- retu-pwrbutton: use devres

Changes since the RFC version
(http://marc.info/?l=linux-omapm=134618967116737w=2):
- added DT support for getting i2c-cbus GPIO pins
- merged n8x0 board file changes into i2c-cbus patch
- corrected typo in Kconfig for MFD_RETU
- added power off functionality to retu-mfd
- added IRQ functionality to retu-mfd
- added power button key driver
- some cleanups

Aaro Koskinen (4):
  i2c: introduce i2c-cbus driver
  mfd: introduce retu-mfd driver
  watchdog: introduce retu_wdt driver
  input: misc: introduce retu-pwrbutton

 arch/arm/mach-omap2/board-n8x0.c   |   42 +
 drivers/i2c/busses/Kconfig |   10 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-cbus.c  |  300 
 drivers/input/misc/Kconfig |   10 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/retu-pwrbutton.c|  102 +++
 drivers/mfd/Kconfig|9 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/retu-mfd.c |  264 
 drivers/watchdog/Kconfig   |   12 ++
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/retu_wdt.c|  178 +++
 include/linux/mfd/retu.h   |   22 +++
 include/linux/platform_data/i2c-cbus.h |   27 +++
 15 files changed, 980 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-cbus.c
 create mode 100644 drivers/input/misc/retu-pwrbutton.c
 create mode 100644 drivers/mfd/retu-mfd.c
 create mode 100644 drivers/watchdog/retu_wdt.c
 create mode 100644 include/linux/mfd/retu.h
 create mode 100644 include/linux/platform_data/i2c-cbus.h

-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 2/4] mfd: introduce retu-mfd driver

2012-11-01 Thread Aaro Koskinen
Retu is a multi-function device found on Nokia Internet Tablets
implementing at least watchdog, RTC, headset detection and power button
functionality.

This patch implements minimum functionality providing register access,
IRQ handling and power off functions.

Cc: sa...@linux.intel.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/mfd/Kconfig  |9 ++
 drivers/mfd/Makefile |1 +
 drivers/mfd/retu-mfd.c   |  264 ++
 include/linux/mfd/retu.h |   22 
 4 files changed, 296 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/retu-mfd.c
 create mode 100644 include/linux/mfd/retu.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index acab3ef..7528c5e 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1044,6 +1044,15 @@ config MFD_PALMAS
  If you say yes here you get support for the Palmas
  series of PMIC chips from Texas Instruments.
 
+config MFD_RETU
+   tristate Support for Retu multi-function device
+   select MFD_CORE
+   depends on I2C
+   select REGMAP_IRQ
+   help
+ Retu is a multi-function device found on Nokia Internet Tablets
+ (770, N800 and N810).
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index d8ccb63..ad7879f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -138,3 +138,4 @@ obj-$(CONFIG_MFD_RC5T583)   += rc5t583.o rc5t583-irq.o
 obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o
 obj-$(CONFIG_MFD_SYSCON)   += syscon.o
 obj-$(CONFIG_MFD_LM3533)   += lm3533-core.o lm3533-ctrlbank.o
+obj-$(CONFIG_MFD_RETU) += retu-mfd.o
diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c
new file mode 100644
index 000..7ff4a37
--- /dev/null
+++ b/drivers/mfd/retu-mfd.c
@@ -0,0 +1,264 @@
+/*
+ * Retu MFD driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Juha Yrjölä, David Weinehall and Mikko Ylinen.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/err.h
+#include linux/i2c.h
+#include linux/irq.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/mutex.h
+#include linux/module.h
+#include linux/regmap.h
+#include linux/mfd/core.h
+#include linux/mfd/retu.h
+#include linux/interrupt.h
+#include linux/moduleparam.h
+
+/* Registers */
+#define RETU_REG_ASICR 0x00/* ASIC ID and revision */
+#define RETU_REG_ASICR_VILMA   (1  7)/* Bit indicating Vilma */
+#define RETU_REG_IDR   0x01/* Interrupt ID */
+#define RETU_REG_IMR   0x02/* Interrupt mask */
+
+/* Interrupt sources */
+#define RETU_INT_PWR   0   /* Power button */
+
+struct retu_dev {
+   struct regmap   *regmap;
+   struct device   *dev;
+   struct mutexmutex;
+   struct regmap_irq_chip_data *irq_data;
+};
+
+static struct resource retu_pwrbutton_res[] = {
+   {
+   .name   = retu-pwrbutton,
+   .start  = RETU_INT_PWR,
+   .end= RETU_INT_PWR,
+   .flags  = IORESOURCE_IRQ,
+   },
+};
+
+static struct mfd_cell retu_devs[] = {
+   {
+   .name   = retu-wdt
+   },
+   {
+   .name   = retu-pwrbutton,
+   .resources  = retu_pwrbutton_res,
+   .num_resources  = ARRAY_SIZE(retu_pwrbutton_res),
+   }
+};
+
+static struct regmap_irq retu_irqs[] = {
+   [RETU_INT_PWR] = {
+   .mask = 1  RETU_INT_PWR,
+   }
+};
+
+static struct regmap_irq_chip retu_irq_chip = {
+   .name   = RETU,
+   .irqs   = retu_irqs,
+   .num_irqs   = ARRAY_SIZE(retu_irqs),
+   .num_regs   = 1,
+   .status_base= RETU_REG_IDR,
+   .mask_base  = RETU_REG_IMR,
+   .ack_base   = RETU_REG_IDR,
+};
+
+/* Retu device registered for the power off. */
+static struct retu_dev *retu_pm_power_off;
+
+int retu_read(struct retu_dev *rdev, u8 reg)
+{
+   int ret;
+   int value;
+
+   mutex_lock(rdev-mutex);
+   ret = regmap_read(rdev-regmap, reg, value);
+   mutex_unlock(rdev-mutex);
+
+   return ret ? ret : value;
+}
+EXPORT_SYMBOL_GPL(retu_read);
+
+int retu_write(struct retu_dev *rdev, u8 reg, u16 data)
+{
+   int ret;
+
+   mutex_lock(rdev-mutex);
+   ret = regmap_write(rdev-regmap, reg, data

[PATCH v3 1/4] i2c: introduce i2c-cbus driver

2012-11-01 Thread Aaro Koskinen
Add i2c driver to enable access to devices behind CBUS on Nokia Internet
Tablets.

The patch also adds CBUS I2C configuration for N8x0 which is one of the
users of this driver.

Cc: linux-...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/arm/mach-omap2/board-n8x0.c   |   42 +
 drivers/i2c/busses/Kconfig |   10 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-cbus.c  |  300 
 include/linux/platform_data/i2c-cbus.h |   27 +++
 5 files changed, 380 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-cbus.c
 create mode 100644 include/linux/platform_data/i2c-cbus.h

diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index d95f727..8e8a09d 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -16,10 +16,12 @@
 #include linux/gpio.h
 #include linux/init.h
 #include linux/io.h
+#include linux/irq.h
 #include linux/stddef.h
 #include linux/i2c.h
 #include linux/spi/spi.h
 #include linux/usb/musb.h
+#include linux/platform_data/i2c-cbus.h
 #include linux/platform_data/spi-omap2-mcspi.h
 #include linux/platform_data/mtd-onenand-omap2.h
 #include sound/tlv320aic3x.h
@@ -39,6 +41,45 @@
 #define TUSB6010_GPIO_ENABLE   0
 #define TUSB6010_DMACHAN   0x3f
 
+#if defined(CONFIG_I2C_CBUS) || defined(CONFIG_I2C_CBUS_MODULE)
+static struct i2c_cbus_platform_data n8x0_cbus_data = {
+   .clk_gpio = 66,
+   .dat_gpio = 65,
+   .sel_gpio = 64,
+};
+
+static struct platform_device n8x0_cbus_device = {
+   .name   = i2c-cbus,
+   .id = 3,
+   .dev= {
+   .platform_data = n8x0_cbus_data,
+   },
+};
+
+static struct i2c_board_info n8x0_i2c_board_info_3[] __initdata = {
+   {
+   I2C_BOARD_INFO(retu-mfd, 0x01),
+   },
+};
+
+static void __init n8x0_cbus_init(void)
+{
+   const int retu_irq_gpio = 108;
+
+   if (gpio_request_one(retu_irq_gpio, GPIOF_IN, Retu IRQ))
+   return;
+   irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
+   n8x0_i2c_board_info_3[0].irq = gpio_to_irq(retu_irq_gpio);
+   i2c_register_board_info(3, n8x0_i2c_board_info_3,
+   ARRAY_SIZE(n8x0_i2c_board_info_3));
+   platform_device_register(n8x0_cbus_device);
+}
+#else /* CONFIG_I2C_CBUS */
+static void __init n8x0_cbus_init(void)
+{
+}
+#endif /* CONFIG_I2C_CBUS */
+
 #if defined(CONFIG_USB_MUSB_TUSB6010) || 
defined(CONFIG_USB_MUSB_TUSB6010_MODULE)
 /*
  * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
@@ -677,6 +718,7 @@ static void __init n8x0_init_machine(void)
gpmc_onenand_init(board_onenand_data);
n8x0_mmc_init();
n8x0_usb_init();
+   n8x0_cbus_init();
 }
 
 MACHINE_START(NOKIA_N800, Nokia N800)
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 65dd599..d01c8ef 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -338,6 +338,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
help
  The unit of the TWI clock is kHz.
 
+config I2C_CBUS
+   tristate CBUS I2C driver
+   depends on GENERIC_GPIO
+   help
+ Support for CBUS access using I2C API. Mostly relevant for Nokia
+ Internet Tablets (770, N800 and N810).
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-cbus.
+
 config I2C_CPM
tristate Freescale CPM1 or CPM2 (MPC8xx/826x)
depends on (CPM1 || CPM2)  OF_I2C
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 2d33d62..3c548b1 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_I2C_POWERMAC)+= i2c-powermac.o
 obj-$(CONFIG_I2C_AT91) += i2c-at91.o
 obj-$(CONFIG_I2C_AU1550)   += i2c-au1550.o
 obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
+obj-$(CONFIG_I2C_CBUS) += i2c-cbus.o
 obj-$(CONFIG_I2C_CPM)  += i2c-cpm.o
 obj-$(CONFIG_I2C_DAVINCI)  += i2c-davinci.o
 obj-$(CONFIG_I2C_DESIGNWARE_CORE)  += i2c-designware-core.o
diff --git a/drivers/i2c/busses/i2c-cbus.c b/drivers/i2c/busses/i2c-cbus.c
new file mode 100644
index 000..e6086cf
--- /dev/null
+++ b/drivers/i2c/busses/i2c-cbus.c
@@ -0,0 +1,300 @@
+/*
+ * CBUS I2C driver for Nokia Internet Tablets.
+ *
+ * Copyright (C) 2004-2010 Nokia Corporation
+ *
+ * Based on code written by Juha Yrjölä, David Weinehall, Mikko Ylinen and
+ * Felipe Balbi. Converted to I2C driver by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even

[PATCH v3 4/4] input: misc: introduce retu-pwrbutton

2012-11-01 Thread Aaro Koskinen
Add Retu power button driver.

Cc: linux-in...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/input/misc/Kconfig  |   10 
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/retu-pwrbutton.c |  102 +++
 3 files changed, 113 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/retu-pwrbutton.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7c0f1ec..e5be189 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -367,6 +367,16 @@ config INPUT_CM109
  To compile this driver as a module, choose M here: the module will be
  called cm109.
 
+config INPUT_RETU_PWRBUTTON
+   tristate Retu Power button Driver
+   depends on MFD_RETU
+   help
+ Say Y here if you want to enable power key reporting via the
+ Retu chips found in Nokia Internet Tablets (770, N800, N810).
+
+ To compile this driver as a module, choose M here. The module will
+ be called retu-pwrbutton.
+
 config INPUT_TWL4030_PWRBUTTON
tristate TWL4030 Power button Driver
depends on TWL4030_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 83fe6f5..4fbee0d 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)   += pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_POWERMATE)  += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)   += rb532_button.o
+obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SPARCSPKR)  += sparcspkr.o
diff --git a/drivers/input/misc/retu-pwrbutton.c 
b/drivers/input/misc/retu-pwrbutton.c
new file mode 100644
index 000..043a12b
--- /dev/null
+++ b/drivers/input/misc/retu-pwrbutton.c
@@ -0,0 +1,102 @@
+/*
+ * Retu power button driver.
+ *
+ * Copyright (C) 2004-2010 Nokia Corporation
+ *
+ * Original code written by Ari Saastamoinen, Juha Yrjölä and Felipe Balbi.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/irq.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/input.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+
+#define RETU_STATUS_PWRONX (1  5)
+
+static irqreturn_t retu_pwrbutton_irq(int irq, void *_pwr)
+{
+   bool state;
+   struct input_dev *idev = _pwr;
+   struct retu_dev *rdev = input_get_drvdata(idev);
+
+   state = !(retu_read(rdev, RETU_REG_STATUS)  RETU_STATUS_PWRONX);
+   input_report_key(idev, KEY_POWER, state);
+   input_sync(idev);
+
+   return IRQ_HANDLED;
+}
+
+static int __devinit retu_pwrbutton_probe(struct platform_device *pdev)
+{
+   struct retu_dev *rdev = dev_get_drvdata(pdev-dev.parent);
+   struct input_dev *idev;
+   int ret;
+
+   idev = input_allocate_device();
+   if (!idev)
+   return -ENOMEM;
+
+   idev-evbit[0]  = BIT_MASK(EV_KEY);
+   idev-keybit[BIT_WORD(KEY_POWER)]   = BIT_MASK(KEY_POWER);
+   idev-name  = retu-pwrbutton;
+
+   platform_set_drvdata(pdev, idev);
+   input_set_drvdata(idev, rdev);
+
+   ret = input_register_device(idev);
+   if (ret  0) {
+   input_free_device(idev);
+   return ret;
+   }
+
+   ret = devm_request_threaded_irq(pdev-dev, platform_get_irq(pdev, 0),
+   NULL, retu_pwrbutton_irq, 0,
+   retu-pwrbutton, idev);
+   if (ret  0)
+   input_unregister_device(idev);
+
+   return ret;
+}
+
+static int __devexit retu_pwrbutton_remove(struct platform_device *pdev)
+{
+   struct input_dev *idev = platform_get_drvdata(pdev);
+
+   disable_irq(platform_get_irq(pdev, 0));
+   input_unregister_device(idev);
+
+   return 0;
+}
+
+static struct platform_driver retu_pwrbutton_driver = {
+   .probe  = retu_pwrbutton_probe,
+   .remove = __devexit_p(retu_pwrbutton_remove),
+   .driver = {
+   .name   = retu-pwrbutton,
+   .owner  = THIS_MODULE,
+   },
+};
+module_platform_driver(retu_pwrbutton_driver

[PATCH v3 3/4] watchdog: introduce retu_wdt driver

2012-11-01 Thread Aaro Koskinen
Introduce Retu watchdog driver.

Cc: linux-watch...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/Kconfig|   12 +++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/retu_wdt.c |  178 +++
 3 files changed, 191 insertions(+), 0 deletions(-)
 create mode 100644 drivers/watchdog/retu_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ad1bb93..c3a836d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -352,6 +352,18 @@ config IMX2_WDT
  To compile this driver as a module, choose M here: the
  module will be called imx2_wdt.
 
+config RETU_WATCHDOG
+   tristate Retu watchdog
+   depends on MFD_RETU
+   select WATCHDOG_CORE
+   help
+ Retu watchdog driver for Nokia Internet Tablets (700, N800,
+ N810). At least on N800 the watchdog cannot be disabled, so
+ this driver is essential and you should enable it.
+
+ To compile this driver as a module, choose M here: the
+ module will be called retu_wdt.
+
 # AVR32 Architecture
 
 config AT32AP700X_WDT
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 572b39b..d2f1c0c 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o
 obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
 obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
 obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
+obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o
 
 # AVR32 Architecture
 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c
new file mode 100644
index 000..aeb0f39
--- /dev/null
+++ b/drivers/watchdog/retu_wdt.c
@@ -0,0 +1,178 @@
+/*
+ * Retu watchdog driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Amit Kucheria and Michael Buesch.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/device.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/watchdog.h
+#include linux/platform_device.h
+
+/* Watchdog timer values in seconds */
+#define RETU_WDT_MAX_TIMER 63
+
+struct retu_wdt_dev {
+   struct retu_dev *rdev;
+   struct device   *dev;
+   struct delayed_work ping_work;
+};
+
+/*
+ * Since Retu watchdog cannot be disabled in hardware, we must kick it
+ * with a timer until userspace watchdog software takes over. If
+ * CONFIG_WATCHDOG_NOWAYOUT is set, we never start the feeding.
+ */
+static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   schedule_delayed_work(wdev-ping_work,
+   round_jiffies_relative(RETU_WDT_MAX_TIMER * HZ / 2));
+}
+
+static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   cancel_delayed_work_sync(wdev-ping_work);
+}
+
+static void retu_wdt_ping_work(struct work_struct *work)
+{
+   struct retu_wdt_dev *wdev = container_of(to_delayed_work(work),
+   struct retu_wdt_dev, ping_work);
+   retu_wdt_ping_enable(wdev);
+}
+
+static int retu_wdt_start(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_disable(wdev);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_stop(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_enable(wdev);
+
+   return 0;
+}
+
+static int retu_wdt_ping(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_set_timeout(struct watchdog_device *wdog,
+   unsigned int timeout)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   wdog-timeout = timeout;
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static const struct watchdog_info retu_wdt_info = {
+   .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+   .identity = Retu watchdog,
+};
+
+static const struct

[PATCH v3 2/6] watchdog: omap_wdt: convert kzalloc() to devm_kzalloc()

2012-10-10 Thread Aaro Koskinen
Use devm_kzalloc() to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/omap_wdt.c |   23 ++-
 1 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index d28ad5e..d6722db 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -208,24 +208,20 @@ static int __devinit omap_wdt_probe(struct 
platform_device *pdev)
struct omap_wdt_dev *wdev;
int ret;
 
-   omap_wdt = kzalloc(sizeof(*omap_wdt), GFP_KERNEL);
+   omap_wdt = devm_kzalloc(pdev-dev, sizeof(*omap_wdt), GFP_KERNEL);
if (!omap_wdt)
return -ENOMEM;
 
/* reserve static register mappings */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   ret = -ENOENT;
-   goto err_get_resource;
-   }
+   if (!res)
+   return -ENOENT;
 
mem = request_mem_region(res-start, resource_size(res), pdev-name);
-   if (!mem) {
-   ret = -EBUSY;
-   goto err_busy;
-   }
+   if (!mem)
+   return -EBUSY;
 
-   wdev = kzalloc(sizeof(struct omap_wdt_dev), GFP_KERNEL);
+   wdev = devm_kzalloc(pdev-dev, sizeof(*wdev), GFP_KERNEL);
if (!wdev) {
ret = -ENOMEM;
goto err_kzalloc;
@@ -292,14 +288,10 @@ err_misc:
 
 err_ioremap:
wdev-base = NULL;
-   kfree(wdev);
 
 err_kzalloc:
release_mem_region(res-start, resource_size(res));
 
-err_busy:
-err_get_resource:
-   kfree(omap_wdt);
return ret;
 }
 
@@ -329,9 +321,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
 
iounmap(wdev-base);
 
-   kfree(wdev);
-   kfree(wdog);
-
return 0;
 }
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 0/6] watchdog: omap_wdt: convert to new watchdog core

2012-10-10 Thread Aaro Koskinen
Hello,

This is a third version of the patch to convert omap_wdt to new watchdog
core. On OMAP boards, there are usually multiple watchdogs. Since the new
watchdog core supports multiple watchdogs, all watchdog drivers used on
OMAP should be converted. This is especially important on devices like
Nokia N9 or N800 where multiple watchdogs are present and watchdog HW
cannot be disabled on devices available to consumers/hobbyists.

I have also done additional cleanups to utilize devres. They are separate
patches to make reviewing easier.

Please review and consider applying/queueing these patches, perhaps
maybe for 3.8. Thanks.

Tested on top of current mainline
(2474542f64432398f503373f53bdf620491bcfa8) on Nokia N950.

Patch set history:

v3: Patch 1 rebased on top of current mainline. Added received
Tested by -tags. Added patches 2..6.

v2 (https://lkml.org/lkml/2012/9/8/134): Fix a bug in the
first version of the patch: __omap_wdt_disable() in probe was
mistakenly moved outside PM runtime calls. This caused a crash
as device was probably accessed with some clocks off. Thanks to
Jarkko Nikula jarkko.nik...@bitmer.com for reporting this.

v1 (https://lkml.org/lkml/2012/9/4/217): The initial version.

Aaro Koskinen (6):
  watchdog: omap_wdt: convert to new watchdog core
  watchdog: omap_wdt: convert kzalloc() to devm_kzalloc()
  watchdog: omap_wdt: convert request_mem_region() to
devm_request_mem_region()
  watchdog: omap_wdt: convert ioremap() to devm_ioremap()
  watchdog: omap_wdt: delete redundant platform_set_drvdata() calls
  watchdog: omap_wdt: eliminate goto

 drivers/watchdog/Kconfig|1 +
 drivers/watchdog/omap_wdt.c |  329 +--
 2 files changed, 131 insertions(+), 199 deletions(-)

-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 4/6] watchdog: omap_wdt: convert ioremap() to devm_ioremap()

2012-10-10 Thread Aaro Koskinen
Use devm_ioremap() to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/omap_wdt.c |   14 +++---
 1 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 45019b0..7e8d3e0 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -255,11 +255,9 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
wdev-wdt_trgr_pattern  = 0x1234;
mutex_init(wdev-lock);
 
-   wdev-base = ioremap(res-start, resource_size(res));
-   if (!wdev-base) {
-   ret = -ENOMEM;
-   goto err_ioremap;
-   }
+   wdev-base = devm_ioremap(pdev-dev, res-start, resource_size(res));
+   if (!wdev-base)
+   return -ENOMEM;
 
platform_set_drvdata(pdev, omap_wdt);
 
@@ -283,10 +281,6 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
 err_misc:
pm_runtime_disable(wdev-dev);
platform_set_drvdata(pdev, NULL);
-   iounmap(wdev-base);
-
-err_ioremap:
-   wdev-base = NULL;
 
return ret;
 }
@@ -314,8 +308,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
watchdog_unregister_device(wdog);
platform_set_drvdata(pdev, NULL);
 
-   iounmap(wdev-base);
-
return 0;
 }
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 5/6] watchdog: omap_wdt: delete redundant platform_set_drvdata() calls

2012-10-10 Thread Aaro Koskinen
It's not needed to manually reset the driver data.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/omap_wdt.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 7e8d3e0..af1e72e 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -280,7 +280,6 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
 
 err_misc:
pm_runtime_disable(wdev-dev);
-   platform_set_drvdata(pdev, NULL);
 
return ret;
 }
@@ -306,7 +305,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
 
pm_runtime_disable(wdev-dev);
watchdog_unregister_device(wdog);
-   platform_set_drvdata(pdev, NULL);
 
return 0;
 }
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 3/6] watchdog: omap_wdt: convert request_mem_region() to devm_request_mem_region()

2012-10-10 Thread Aaro Koskinen
Use devm_request_mem_region() to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/omap_wdt.c |   13 -
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index d6722db..45019b0 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -217,15 +217,14 @@ static int __devinit omap_wdt_probe(struct 
platform_device *pdev)
if (!res)
return -ENOENT;
 
-   mem = request_mem_region(res-start, resource_size(res), pdev-name);
+   mem = devm_request_mem_region(pdev-dev, res-start,
+ resource_size(res), pdev-name);
if (!mem)
return -EBUSY;
 
wdev = devm_kzalloc(pdev-dev, sizeof(*wdev), GFP_KERNEL);
-   if (!wdev) {
-   ret = -ENOMEM;
-   goto err_kzalloc;
-   }
+   if (!wdev)
+   return -ENOMEM;
 
omap_wdt-info= omap_wdt_info;
omap_wdt-ops = omap_wdt_ops;
@@ -289,9 +288,6 @@ err_misc:
 err_ioremap:
wdev-base = NULL;
 
-err_kzalloc:
-   release_mem_region(res-start, resource_size(res));
-
return ret;
 }
 
@@ -316,7 +312,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
 
pm_runtime_disable(wdev-dev);
watchdog_unregister_device(wdog);
-   release_mem_region(res-start, resource_size(res));
platform_set_drvdata(pdev, NULL);
 
iounmap(wdev-base);
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 6/6] watchdog: omap_wdt: eliminate goto

2012-10-10 Thread Aaro Koskinen
Eliminate a goto to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/omap_wdt.c |   11 ---
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index af1e72e..bee43a9 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -267,8 +267,10 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
__omap_wdt_disable(wdev);
 
ret = watchdog_register_device(omap_wdt);
-   if (ret)
-   goto err_misc;
+   if (ret) {
+   pm_runtime_disable(wdev-dev);
+   return ret;
+   }
 
pr_info(OMAP Watchdog Timer Rev 0x%02x: initial timeout %d sec\n,
__raw_readl(wdev-base + OMAP_WATCHDOG_REV)  0xFF,
@@ -277,11 +279,6 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
pm_runtime_put_sync(wdev-dev);
 
return 0;
-
-err_misc:
-   pm_runtime_disable(wdev-dev);
-
-   return ret;
 }
 
 static void omap_wdt_shutdown(struct platform_device *pdev)
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 1/6] watchdog: omap_wdt: convert to new watchdog core

2012-10-10 Thread Aaro Koskinen
Convert omap_wdt to new watchdog core. On OMAP boards, there are usually
multiple watchdogs. Since the new watchdog core supports multiple
watchdogs, all watchdog drivers used on OMAP should be converted.

The legacy watchdog device node is still created, so this should not
break existing users.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Tested-by: Jarkko Nikula jarkko.nik...@jollamobile.com
Tested-by: Lokesh Vutla lokeshvu...@ti.com
---
 drivers/watchdog/Kconfig|1 +
 drivers/watchdog/omap_wdt.c |  274 ++-
 2 files changed, 118 insertions(+), 157 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ad1bb93..a7f5590 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -232,6 +232,7 @@ config EP93XX_WATCHDOG
 config OMAP_WATCHDOG
tristate OMAP Watchdog
depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS
+   select WATCHDOG_CORE
help
  Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog. 
 Say 'Y'
  here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 
watchdog timer.
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index f5db18db..d28ad5e 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -31,18 +31,14 @@
 #include linux/module.h
 #include linux/types.h
 #include linux/kernel.h
-#include linux/fs.h
 #include linux/mm.h
-#include linux/miscdevice.h
 #include linux/watchdog.h
 #include linux/reboot.h
 #include linux/init.h
 #include linux/err.h
 #include linux/platform_device.h
 #include linux/moduleparam.h
-#include linux/bitops.h
 #include linux/io.h
-#include linux/uaccess.h
 #include linux/slab.h
 #include linux/pm_runtime.h
 #include mach/hardware.h
@@ -51,24 +47,20 @@
 
 #include omap_wdt.h
 
-static struct platform_device *omap_wdt_dev;
-
 static unsigned timer_margin;
 module_param(timer_margin, uint, 0);
 MODULE_PARM_DESC(timer_margin, initial watchdog timeout (in seconds));
 
-static unsigned int wdt_trgr_pattern = 0x1234;
-static DEFINE_SPINLOCK(wdt_lock);
-
 struct omap_wdt_dev {
void __iomem*base;  /* physical */
struct device   *dev;
-   int omap_wdt_users;
+   boolomap_wdt_users;
struct resource *mem;
-   struct miscdevice omap_wdt_miscdev;
+   int wdt_trgr_pattern;
+   struct mutexlock;   /* to avoid races with PM */
 };
 
-static void omap_wdt_ping(struct omap_wdt_dev *wdev)
+static void __omap_wdt_ping(struct omap_wdt_dev *wdev)
 {
void __iomem*base = wdev-base;
 
@@ -76,8 +68,8 @@ static void omap_wdt_ping(struct omap_wdt_dev *wdev)
while ((__raw_readl(base + OMAP_WATCHDOG_WPS))  0x08)
cpu_relax();
 
-   wdt_trgr_pattern = ~wdt_trgr_pattern;
-   __raw_writel(wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
+   wdev-wdt_trgr_pattern = ~wdev-wdt_trgr_pattern;
+   __raw_writel(wdev-wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
 
/* wait for posted write to complete */
while ((__raw_readl(base + OMAP_WATCHDOG_WPS))  0x08)
@@ -85,7 +77,7 @@ static void omap_wdt_ping(struct omap_wdt_dev *wdev)
/* reloaded WCRR from WLDR */
 }
 
-static void omap_wdt_enable(struct omap_wdt_dev *wdev)
+static void __omap_wdt_enable(struct omap_wdt_dev *wdev)
 {
void __iomem *base = wdev-base;
 
@@ -99,7 +91,7 @@ static void omap_wdt_enable(struct omap_wdt_dev *wdev)
cpu_relax();
 }
 
-static void omap_wdt_disable(struct omap_wdt_dev *wdev)
+static void __omap_wdt_disable(struct omap_wdt_dev *wdev)
 {
void __iomem *base = wdev-base;
 
@@ -113,18 +105,10 @@ static void omap_wdt_disable(struct omap_wdt_dev *wdev)
cpu_relax();
 }
 
-static void omap_wdt_adjust_timeout(unsigned new_timeout)
-{
-   if (new_timeout  TIMER_MARGIN_MIN)
-   new_timeout = TIMER_MARGIN_DEFAULT;
-   if (new_timeout  TIMER_MARGIN_MAX)
-   new_timeout = TIMER_MARGIN_MAX;
-   timer_margin = new_timeout;
-}
-
-static void omap_wdt_set_timeout(struct omap_wdt_dev *wdev)
+static void __omap_wdt_set_timeout(struct omap_wdt_dev *wdev,
+  unsigned int timeout)
 {
-   u32 pre_margin = GET_WLDR_VAL(timer_margin);
+   u32 pre_margin = GET_WLDR_VAL(timeout);
void __iomem *base = wdev-base;
 
/* just count up at 32 KHz */
@@ -136,16 +120,14 @@ static void omap_wdt_set_timeout(struct omap_wdt_dev 
*wdev)
cpu_relax();
 }
 
-/*
- * Allow only one task to hold it open
- */
-static int omap_wdt_open(struct inode *inode, struct file *file)
+static int omap_wdt_start(struct watchdog_device *wdog)
 {
-   struct omap_wdt_dev *wdev = platform_get_drvdata(omap_wdt_dev);
+   struct omap_wdt_dev *wdev = watchdog_get_drvdata(wdog);
void __iomem *base = wdev-base;
 
-   if (test_and_set_bit(1, (unsigned

[RESEND PATCH v3 3/6] watchdog: omap_wdt: convert request_mem_region() to devm_request_mem_region()

2012-10-25 Thread Aaro Koskinen
Use devm_request_mem_region() to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/omap_wdt.c |   13 -
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index d6722db..45019b0 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -217,15 +217,14 @@ static int __devinit omap_wdt_probe(struct 
platform_device *pdev)
if (!res)
return -ENOENT;
 
-   mem = request_mem_region(res-start, resource_size(res), pdev-name);
+   mem = devm_request_mem_region(pdev-dev, res-start,
+ resource_size(res), pdev-name);
if (!mem)
return -EBUSY;
 
wdev = devm_kzalloc(pdev-dev, sizeof(*wdev), GFP_KERNEL);
-   if (!wdev) {
-   ret = -ENOMEM;
-   goto err_kzalloc;
-   }
+   if (!wdev)
+   return -ENOMEM;
 
omap_wdt-info= omap_wdt_info;
omap_wdt-ops = omap_wdt_ops;
@@ -289,9 +288,6 @@ err_misc:
 err_ioremap:
wdev-base = NULL;
 
-err_kzalloc:
-   release_mem_region(res-start, resource_size(res));
-
return ret;
 }
 
@@ -316,7 +312,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
 
pm_runtime_disable(wdev-dev);
watchdog_unregister_device(wdog);
-   release_mem_region(res-start, resource_size(res));
platform_set_drvdata(pdev, NULL);
 
iounmap(wdev-base);
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 6/6] watchdog: omap_wdt: eliminate goto

2012-10-25 Thread Aaro Koskinen
Eliminate a goto to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/omap_wdt.c |   11 ---
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index af1e72e..bee43a9 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -267,8 +267,10 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
__omap_wdt_disable(wdev);
 
ret = watchdog_register_device(omap_wdt);
-   if (ret)
-   goto err_misc;
+   if (ret) {
+   pm_runtime_disable(wdev-dev);
+   return ret;
+   }
 
pr_info(OMAP Watchdog Timer Rev 0x%02x: initial timeout %d sec\n,
__raw_readl(wdev-base + OMAP_WATCHDOG_REV)  0xFF,
@@ -277,11 +279,6 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
pm_runtime_put_sync(wdev-dev);
 
return 0;
-
-err_misc:
-   pm_runtime_disable(wdev-dev);
-
-   return ret;
 }
 
 static void omap_wdt_shutdown(struct platform_device *pdev)
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 0/6] watchdog: omap_wdt: convert to new watchdog core

2012-10-25 Thread Aaro Koskinen
Hello,

This is a third version of the patch to convert omap_wdt to new watchdog
core. On OMAP boards, there are usually multiple watchdogs. Since the new
watchdog core supports multiple watchdogs, all watchdog drivers used on
OMAP should be converted. This is especially important on devices like
Nokia N9 or N800 where multiple watchdogs are present and watchdog HW
cannot be disabled on devices available to consumers/hobbyists.

I have also done additional cleanups to utilize devres. They are separate
patches to make reviewing easier.

Please review and consider applying/queueing these patches, perhaps
maybe for 3.8. Thanks.

Tested on top of current mainline
(4864ccbb5a6f99e4c44dc816304007547a268b9f) on Nokia N950.

Patch set history:

v3 (https://lkml.org/lkml/2012/10/10/402): Patch 1 rebased on
top of current mainline. Added received Tested by -tags. Added
patches 2..6.

v2 (https://lkml.org/lkml/2012/9/8/134): Fix a bug in the
first version of the patch: __omap_wdt_disable() in probe was
mistakenly moved outside PM runtime calls. This caused a crash
as device was probably accessed with some clocks off. Thanks to
Jarkko Nikula jarkko.nik...@bitmer.com for reporting this.

v1 (https://lkml.org/lkml/2012/9/4/217): The initial version.

Aaro Koskinen (6):
  watchdog: omap_wdt: convert to new watchdog core
  watchdog: omap_wdt: convert kzalloc() to devm_kzalloc()
  watchdog: omap_wdt: convert request_mem_region() to
devm_request_mem_region()
  watchdog: omap_wdt: convert ioremap() to devm_ioremap()
  watchdog: omap_wdt: delete redundant platform_set_drvdata() calls
  watchdog: omap_wdt: eliminate goto

 drivers/watchdog/Kconfig|1 +
 drivers/watchdog/omap_wdt.c |  329 +--
 2 files changed, 131 insertions(+), 199 deletions(-)

-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 1/6] watchdog: omap_wdt: convert to new watchdog core

2012-10-25 Thread Aaro Koskinen
Convert omap_wdt to new watchdog core. On OMAP boards, there are usually
multiple watchdogs. Since the new watchdog core supports multiple
watchdogs, all watchdog drivers used on OMAP should be converted.

The legacy watchdog device node is still created, so this should not
break existing users.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Tested-by: Jarkko Nikula jarkko.nik...@jollamobile.com
Tested-by: Lokesh Vutla lokeshvu...@ti.com
---
 drivers/watchdog/Kconfig|1 +
 drivers/watchdog/omap_wdt.c |  274 ++-
 2 files changed, 118 insertions(+), 157 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ad1bb93..a7f5590 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -232,6 +232,7 @@ config EP93XX_WATCHDOG
 config OMAP_WATCHDOG
tristate OMAP Watchdog
depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS
+   select WATCHDOG_CORE
help
  Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog. 
 Say 'Y'
  here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 
watchdog timer.
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index f5db18db..d28ad5e 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -31,18 +31,14 @@
 #include linux/module.h
 #include linux/types.h
 #include linux/kernel.h
-#include linux/fs.h
 #include linux/mm.h
-#include linux/miscdevice.h
 #include linux/watchdog.h
 #include linux/reboot.h
 #include linux/init.h
 #include linux/err.h
 #include linux/platform_device.h
 #include linux/moduleparam.h
-#include linux/bitops.h
 #include linux/io.h
-#include linux/uaccess.h
 #include linux/slab.h
 #include linux/pm_runtime.h
 #include mach/hardware.h
@@ -51,24 +47,20 @@
 
 #include omap_wdt.h
 
-static struct platform_device *omap_wdt_dev;
-
 static unsigned timer_margin;
 module_param(timer_margin, uint, 0);
 MODULE_PARM_DESC(timer_margin, initial watchdog timeout (in seconds));
 
-static unsigned int wdt_trgr_pattern = 0x1234;
-static DEFINE_SPINLOCK(wdt_lock);
-
 struct omap_wdt_dev {
void __iomem*base;  /* physical */
struct device   *dev;
-   int omap_wdt_users;
+   boolomap_wdt_users;
struct resource *mem;
-   struct miscdevice omap_wdt_miscdev;
+   int wdt_trgr_pattern;
+   struct mutexlock;   /* to avoid races with PM */
 };
 
-static void omap_wdt_ping(struct omap_wdt_dev *wdev)
+static void __omap_wdt_ping(struct omap_wdt_dev *wdev)
 {
void __iomem*base = wdev-base;
 
@@ -76,8 +68,8 @@ static void omap_wdt_ping(struct omap_wdt_dev *wdev)
while ((__raw_readl(base + OMAP_WATCHDOG_WPS))  0x08)
cpu_relax();
 
-   wdt_trgr_pattern = ~wdt_trgr_pattern;
-   __raw_writel(wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
+   wdev-wdt_trgr_pattern = ~wdev-wdt_trgr_pattern;
+   __raw_writel(wdev-wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
 
/* wait for posted write to complete */
while ((__raw_readl(base + OMAP_WATCHDOG_WPS))  0x08)
@@ -85,7 +77,7 @@ static void omap_wdt_ping(struct omap_wdt_dev *wdev)
/* reloaded WCRR from WLDR */
 }
 
-static void omap_wdt_enable(struct omap_wdt_dev *wdev)
+static void __omap_wdt_enable(struct omap_wdt_dev *wdev)
 {
void __iomem *base = wdev-base;
 
@@ -99,7 +91,7 @@ static void omap_wdt_enable(struct omap_wdt_dev *wdev)
cpu_relax();
 }
 
-static void omap_wdt_disable(struct omap_wdt_dev *wdev)
+static void __omap_wdt_disable(struct omap_wdt_dev *wdev)
 {
void __iomem *base = wdev-base;
 
@@ -113,18 +105,10 @@ static void omap_wdt_disable(struct omap_wdt_dev *wdev)
cpu_relax();
 }
 
-static void omap_wdt_adjust_timeout(unsigned new_timeout)
-{
-   if (new_timeout  TIMER_MARGIN_MIN)
-   new_timeout = TIMER_MARGIN_DEFAULT;
-   if (new_timeout  TIMER_MARGIN_MAX)
-   new_timeout = TIMER_MARGIN_MAX;
-   timer_margin = new_timeout;
-}
-
-static void omap_wdt_set_timeout(struct omap_wdt_dev *wdev)
+static void __omap_wdt_set_timeout(struct omap_wdt_dev *wdev,
+  unsigned int timeout)
 {
-   u32 pre_margin = GET_WLDR_VAL(timer_margin);
+   u32 pre_margin = GET_WLDR_VAL(timeout);
void __iomem *base = wdev-base;
 
/* just count up at 32 KHz */
@@ -136,16 +120,14 @@ static void omap_wdt_set_timeout(struct omap_wdt_dev 
*wdev)
cpu_relax();
 }
 
-/*
- * Allow only one task to hold it open
- */
-static int omap_wdt_open(struct inode *inode, struct file *file)
+static int omap_wdt_start(struct watchdog_device *wdog)
 {
-   struct omap_wdt_dev *wdev = platform_get_drvdata(omap_wdt_dev);
+   struct omap_wdt_dev *wdev = watchdog_get_drvdata(wdog);
void __iomem *base = wdev-base;
 
-   if (test_and_set_bit(1, (unsigned

[RESEND PATCH v3 5/6] watchdog: omap_wdt: delete redundant platform_set_drvdata() calls

2012-10-25 Thread Aaro Koskinen
It's not needed to manually reset the driver data.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/omap_wdt.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 7e8d3e0..af1e72e 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -280,7 +280,6 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
 
 err_misc:
pm_runtime_disable(wdev-dev);
-   platform_set_drvdata(pdev, NULL);
 
return ret;
 }
@@ -306,7 +305,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
 
pm_runtime_disable(wdev-dev);
watchdog_unregister_device(wdog);
-   platform_set_drvdata(pdev, NULL);
 
return 0;
 }
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 4/6] watchdog: omap_wdt: convert ioremap() to devm_ioremap()

2012-10-25 Thread Aaro Koskinen
Use devm_ioremap() to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/omap_wdt.c |   14 +++---
 1 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 45019b0..7e8d3e0 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -255,11 +255,9 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
wdev-wdt_trgr_pattern  = 0x1234;
mutex_init(wdev-lock);
 
-   wdev-base = ioremap(res-start, resource_size(res));
-   if (!wdev-base) {
-   ret = -ENOMEM;
-   goto err_ioremap;
-   }
+   wdev-base = devm_ioremap(pdev-dev, res-start, resource_size(res));
+   if (!wdev-base)
+   return -ENOMEM;
 
platform_set_drvdata(pdev, omap_wdt);
 
@@ -283,10 +281,6 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
 err_misc:
pm_runtime_disable(wdev-dev);
platform_set_drvdata(pdev, NULL);
-   iounmap(wdev-base);
-
-err_ioremap:
-   wdev-base = NULL;
 
return ret;
 }
@@ -314,8 +308,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
watchdog_unregister_device(wdog);
platform_set_drvdata(pdev, NULL);
 
-   iounmap(wdev-base);
-
return 0;
 }
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 2/6] watchdog: omap_wdt: convert kzalloc() to devm_kzalloc()

2012-10-25 Thread Aaro Koskinen
Use devm_kzalloc() to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/omap_wdt.c |   23 ++-
 1 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index d28ad5e..d6722db 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -208,24 +208,20 @@ static int __devinit omap_wdt_probe(struct 
platform_device *pdev)
struct omap_wdt_dev *wdev;
int ret;
 
-   omap_wdt = kzalloc(sizeof(*omap_wdt), GFP_KERNEL);
+   omap_wdt = devm_kzalloc(pdev-dev, sizeof(*omap_wdt), GFP_KERNEL);
if (!omap_wdt)
return -ENOMEM;
 
/* reserve static register mappings */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   ret = -ENOENT;
-   goto err_get_resource;
-   }
+   if (!res)
+   return -ENOENT;
 
mem = request_mem_region(res-start, resource_size(res), pdev-name);
-   if (!mem) {
-   ret = -EBUSY;
-   goto err_busy;
-   }
+   if (!mem)
+   return -EBUSY;
 
-   wdev = kzalloc(sizeof(struct omap_wdt_dev), GFP_KERNEL);
+   wdev = devm_kzalloc(pdev-dev, sizeof(*wdev), GFP_KERNEL);
if (!wdev) {
ret = -ENOMEM;
goto err_kzalloc;
@@ -292,14 +288,10 @@ err_misc:
 
 err_ioremap:
wdev-base = NULL;
-   kfree(wdev);
 
 err_kzalloc:
release_mem_region(res-start, resource_size(res));
 
-err_busy:
-err_get_resource:
-   kfree(omap_wdt);
return ret;
 }
 
@@ -329,9 +321,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
 
iounmap(wdev-base);
 
-   kfree(wdev);
-   kfree(wdog);
-
return 0;
 }
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 3/6] watchdog: omap_wdt: convert request_mem_region() to devm_request_mem_region()

2012-11-12 Thread Aaro Koskinen
Use devm_request_mem_region() to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wim Van Sebroeck w...@iguana.be
---
 drivers/watchdog/omap_wdt.c |   13 -
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index d6722db..45019b0 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -217,15 +217,14 @@ static int __devinit omap_wdt_probe(struct 
platform_device *pdev)
if (!res)
return -ENOENT;
 
-   mem = request_mem_region(res-start, resource_size(res), pdev-name);
+   mem = devm_request_mem_region(pdev-dev, res-start,
+ resource_size(res), pdev-name);
if (!mem)
return -EBUSY;
 
wdev = devm_kzalloc(pdev-dev, sizeof(*wdev), GFP_KERNEL);
-   if (!wdev) {
-   ret = -ENOMEM;
-   goto err_kzalloc;
-   }
+   if (!wdev)
+   return -ENOMEM;
 
omap_wdt-info= omap_wdt_info;
omap_wdt-ops = omap_wdt_ops;
@@ -289,9 +288,6 @@ err_misc:
 err_ioremap:
wdev-base = NULL;
 
-err_kzalloc:
-   release_mem_region(res-start, resource_size(res));
-
return ret;
 }
 
@@ -316,7 +312,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
 
pm_runtime_disable(wdev-dev);
watchdog_unregister_device(wdog);
-   release_mem_region(res-start, resource_size(res));
platform_set_drvdata(pdev, NULL);
 
iounmap(wdev-base);
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 1/6] watchdog: omap_wdt: convert to new watchdog core

2012-11-12 Thread Aaro Koskinen
Convert omap_wdt to new watchdog core. On OMAP boards, there are usually
multiple watchdogs. Since the new watchdog core supports multiple
watchdogs, all watchdog drivers used on OMAP should be converted.

The legacy watchdog device node is still created, so this should not
break existing users.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Tested-by: Jarkko Nikula jarkko.nik...@jollamobile.com
Tested-by: Lokesh Vutla lokeshvu...@ti.com
Cc: Wim Van Sebroeck w...@iguana.be
---
 drivers/watchdog/Kconfig|1 +
 drivers/watchdog/omap_wdt.c |  274 ++-
 2 files changed, 118 insertions(+), 157 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ad1bb93..a7f5590 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -232,6 +232,7 @@ config EP93XX_WATCHDOG
 config OMAP_WATCHDOG
tristate OMAP Watchdog
depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS
+   select WATCHDOG_CORE
help
  Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog. 
 Say 'Y'
  here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 
watchdog timer.
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index f5db18db..d28ad5e 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -31,18 +31,14 @@
 #include linux/module.h
 #include linux/types.h
 #include linux/kernel.h
-#include linux/fs.h
 #include linux/mm.h
-#include linux/miscdevice.h
 #include linux/watchdog.h
 #include linux/reboot.h
 #include linux/init.h
 #include linux/err.h
 #include linux/platform_device.h
 #include linux/moduleparam.h
-#include linux/bitops.h
 #include linux/io.h
-#include linux/uaccess.h
 #include linux/slab.h
 #include linux/pm_runtime.h
 #include mach/hardware.h
@@ -51,24 +47,20 @@
 
 #include omap_wdt.h
 
-static struct platform_device *omap_wdt_dev;
-
 static unsigned timer_margin;
 module_param(timer_margin, uint, 0);
 MODULE_PARM_DESC(timer_margin, initial watchdog timeout (in seconds));
 
-static unsigned int wdt_trgr_pattern = 0x1234;
-static DEFINE_SPINLOCK(wdt_lock);
-
 struct omap_wdt_dev {
void __iomem*base;  /* physical */
struct device   *dev;
-   int omap_wdt_users;
+   boolomap_wdt_users;
struct resource *mem;
-   struct miscdevice omap_wdt_miscdev;
+   int wdt_trgr_pattern;
+   struct mutexlock;   /* to avoid races with PM */
 };
 
-static void omap_wdt_ping(struct omap_wdt_dev *wdev)
+static void __omap_wdt_ping(struct omap_wdt_dev *wdev)
 {
void __iomem*base = wdev-base;
 
@@ -76,8 +68,8 @@ static void omap_wdt_ping(struct omap_wdt_dev *wdev)
while ((__raw_readl(base + OMAP_WATCHDOG_WPS))  0x08)
cpu_relax();
 
-   wdt_trgr_pattern = ~wdt_trgr_pattern;
-   __raw_writel(wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
+   wdev-wdt_trgr_pattern = ~wdev-wdt_trgr_pattern;
+   __raw_writel(wdev-wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
 
/* wait for posted write to complete */
while ((__raw_readl(base + OMAP_WATCHDOG_WPS))  0x08)
@@ -85,7 +77,7 @@ static void omap_wdt_ping(struct omap_wdt_dev *wdev)
/* reloaded WCRR from WLDR */
 }
 
-static void omap_wdt_enable(struct omap_wdt_dev *wdev)
+static void __omap_wdt_enable(struct omap_wdt_dev *wdev)
 {
void __iomem *base = wdev-base;
 
@@ -99,7 +91,7 @@ static void omap_wdt_enable(struct omap_wdt_dev *wdev)
cpu_relax();
 }
 
-static void omap_wdt_disable(struct omap_wdt_dev *wdev)
+static void __omap_wdt_disable(struct omap_wdt_dev *wdev)
 {
void __iomem *base = wdev-base;
 
@@ -113,18 +105,10 @@ static void omap_wdt_disable(struct omap_wdt_dev *wdev)
cpu_relax();
 }
 
-static void omap_wdt_adjust_timeout(unsigned new_timeout)
-{
-   if (new_timeout  TIMER_MARGIN_MIN)
-   new_timeout = TIMER_MARGIN_DEFAULT;
-   if (new_timeout  TIMER_MARGIN_MAX)
-   new_timeout = TIMER_MARGIN_MAX;
-   timer_margin = new_timeout;
-}
-
-static void omap_wdt_set_timeout(struct omap_wdt_dev *wdev)
+static void __omap_wdt_set_timeout(struct omap_wdt_dev *wdev,
+  unsigned int timeout)
 {
-   u32 pre_margin = GET_WLDR_VAL(timer_margin);
+   u32 pre_margin = GET_WLDR_VAL(timeout);
void __iomem *base = wdev-base;
 
/* just count up at 32 KHz */
@@ -136,16 +120,14 @@ static void omap_wdt_set_timeout(struct omap_wdt_dev 
*wdev)
cpu_relax();
 }
 
-/*
- * Allow only one task to hold it open
- */
-static int omap_wdt_open(struct inode *inode, struct file *file)
+static int omap_wdt_start(struct watchdog_device *wdog)
 {
-   struct omap_wdt_dev *wdev = platform_get_drvdata(omap_wdt_dev);
+   struct omap_wdt_dev *wdev = watchdog_get_drvdata(wdog);
void __iomem *base = wdev-base

[RESEND PATCH v3 5/6] watchdog: omap_wdt: delete redundant platform_set_drvdata() calls

2012-11-12 Thread Aaro Koskinen
It's not needed to manually reset the driver data.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wim Van Sebroeck w...@iguana.be
---
 drivers/watchdog/omap_wdt.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 7e8d3e0..af1e72e 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -280,7 +280,6 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
 
 err_misc:
pm_runtime_disable(wdev-dev);
-   platform_set_drvdata(pdev, NULL);
 
return ret;
 }
@@ -306,7 +305,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
 
pm_runtime_disable(wdev-dev);
watchdog_unregister_device(wdog);
-   platform_set_drvdata(pdev, NULL);
 
return 0;
 }
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 2/6] watchdog: omap_wdt: convert kzalloc() to devm_kzalloc()

2012-11-12 Thread Aaro Koskinen
Use devm_kzalloc() to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wim Van Sebroeck w...@iguana.be
---
 drivers/watchdog/omap_wdt.c |   23 ++-
 1 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index d28ad5e..d6722db 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -208,24 +208,20 @@ static int __devinit omap_wdt_probe(struct 
platform_device *pdev)
struct omap_wdt_dev *wdev;
int ret;
 
-   omap_wdt = kzalloc(sizeof(*omap_wdt), GFP_KERNEL);
+   omap_wdt = devm_kzalloc(pdev-dev, sizeof(*omap_wdt), GFP_KERNEL);
if (!omap_wdt)
return -ENOMEM;
 
/* reserve static register mappings */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   ret = -ENOENT;
-   goto err_get_resource;
-   }
+   if (!res)
+   return -ENOENT;
 
mem = request_mem_region(res-start, resource_size(res), pdev-name);
-   if (!mem) {
-   ret = -EBUSY;
-   goto err_busy;
-   }
+   if (!mem)
+   return -EBUSY;
 
-   wdev = kzalloc(sizeof(struct omap_wdt_dev), GFP_KERNEL);
+   wdev = devm_kzalloc(pdev-dev, sizeof(*wdev), GFP_KERNEL);
if (!wdev) {
ret = -ENOMEM;
goto err_kzalloc;
@@ -292,14 +288,10 @@ err_misc:
 
 err_ioremap:
wdev-base = NULL;
-   kfree(wdev);
 
 err_kzalloc:
release_mem_region(res-start, resource_size(res));
 
-err_busy:
-err_get_resource:
-   kfree(omap_wdt);
return ret;
 }
 
@@ -329,9 +321,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
 
iounmap(wdev-base);
 
-   kfree(wdev);
-   kfree(wdog);
-
return 0;
 }
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 0/6] watchdog: omap_wdt: convert to new watchdog core

2012-11-12 Thread Aaro Koskinen
Hello,

This is a third version of the patch to convert omap_wdt to new watchdog
core. On OMAP boards, there are usually multiple watchdogs. Since the new
watchdog core supports multiple watchdogs, all watchdog drivers used on
OMAP should be converted. This is especially important on devices like
Nokia N9 or N800 where multiple watchdogs are present and watchdog HW
cannot be disabled on devices available to consumers/hobbyists.

I have also done additional cleanups to utilize devres. They are separate
patches to make reviewing easier.

Please review and consider applying/queueing these patches, perhaps
maybe for 3.8. Thanks.

Tested on top of 3.7-rc5 on Nokia N950.

Patch set history:

v3 (https://lkml.org/lkml/2012/10/10/402): Patch 1 rebased on
top of current mainline. Added received Tested by -tags. Added
patches 2..6.

v2 (https://lkml.org/lkml/2012/9/8/134): Fix a bug in the
first version of the patch: __omap_wdt_disable() in probe was
mistakenly moved outside PM runtime calls. This caused a crash
as device was probably accessed with some clocks off. Thanks to
Jarkko Nikula jarkko.nik...@bitmer.com for reporting this.

v1 (https://lkml.org/lkml/2012/9/4/217): The initial version.

Aaro Koskinen (6):
  watchdog: omap_wdt: convert to new watchdog core
  watchdog: omap_wdt: convert kzalloc() to devm_kzalloc()
  watchdog: omap_wdt: convert request_mem_region() to
devm_request_mem_region()
  watchdog: omap_wdt: convert ioremap() to devm_ioremap()
  watchdog: omap_wdt: delete redundant platform_set_drvdata() calls
  watchdog: omap_wdt: eliminate goto

 drivers/watchdog/Kconfig|1 +
 drivers/watchdog/omap_wdt.c |  329 +--
 2 files changed, 131 insertions(+), 199 deletions(-)

-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 4/6] watchdog: omap_wdt: convert ioremap() to devm_ioremap()

2012-11-12 Thread Aaro Koskinen
Use devm_ioremap() to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wim Van Sebroeck w...@iguana.be
---
 drivers/watchdog/omap_wdt.c |   14 +++---
 1 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 45019b0..7e8d3e0 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -255,11 +255,9 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
wdev-wdt_trgr_pattern  = 0x1234;
mutex_init(wdev-lock);
 
-   wdev-base = ioremap(res-start, resource_size(res));
-   if (!wdev-base) {
-   ret = -ENOMEM;
-   goto err_ioremap;
-   }
+   wdev-base = devm_ioremap(pdev-dev, res-start, resource_size(res));
+   if (!wdev-base)
+   return -ENOMEM;
 
platform_set_drvdata(pdev, omap_wdt);
 
@@ -283,10 +281,6 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
 err_misc:
pm_runtime_disable(wdev-dev);
platform_set_drvdata(pdev, NULL);
-   iounmap(wdev-base);
-
-err_ioremap:
-   wdev-base = NULL;
 
return ret;
 }
@@ -314,8 +308,6 @@ static int __devexit omap_wdt_remove(struct platform_device 
*pdev)
watchdog_unregister_device(wdog);
platform_set_drvdata(pdev, NULL);
 
-   iounmap(wdev-base);
-
return 0;
 }
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 6/6] watchdog: omap_wdt: eliminate goto

2012-11-12 Thread Aaro Koskinen
Eliminate a goto to simplify the code.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wim Van Sebroeck w...@iguana.be
---
 drivers/watchdog/omap_wdt.c |   11 ---
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index af1e72e..bee43a9 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -267,8 +267,10 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
__omap_wdt_disable(wdev);
 
ret = watchdog_register_device(omap_wdt);
-   if (ret)
-   goto err_misc;
+   if (ret) {
+   pm_runtime_disable(wdev-dev);
+   return ret;
+   }
 
pr_info(OMAP Watchdog Timer Rev 0x%02x: initial timeout %d sec\n,
__raw_readl(wdev-base + OMAP_WATCHDOG_REV)  0xFF,
@@ -277,11 +279,6 @@ static int __devinit omap_wdt_probe(struct platform_device 
*pdev)
pm_runtime_put_sync(wdev-dev);
 
return 0;
-
-err_misc:
-   pm_runtime_disable(wdev-dev);
-
-   return ret;
 }
 
 static void omap_wdt_shutdown(struct platform_device *pdev)
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 2/4] mfd: introduce retu-mfd driver

2012-11-12 Thread Aaro Koskinen
Retu is a multi-function device found on Nokia Internet Tablets
implementing at least watchdog, RTC, headset detection and power button
functionality.

This patch implements minimum functionality providing register access,
IRQ handling and power off functions.

Cc: sa...@linux.intel.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/mfd/Kconfig  |9 ++
 drivers/mfd/Makefile |1 +
 drivers/mfd/retu-mfd.c   |  264 ++
 include/linux/mfd/retu.h |   22 
 4 files changed, 296 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/retu-mfd.c
 create mode 100644 include/linux/mfd/retu.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index acab3ef..7528c5e 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1044,6 +1044,15 @@ config MFD_PALMAS
  If you say yes here you get support for the Palmas
  series of PMIC chips from Texas Instruments.
 
+config MFD_RETU
+   tristate Support for Retu multi-function device
+   select MFD_CORE
+   depends on I2C
+   select REGMAP_IRQ
+   help
+ Retu is a multi-function device found on Nokia Internet Tablets
+ (770, N800 and N810).
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index d8ccb63..ad7879f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -138,3 +138,4 @@ obj-$(CONFIG_MFD_RC5T583)   += rc5t583.o rc5t583-irq.o
 obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o
 obj-$(CONFIG_MFD_SYSCON)   += syscon.o
 obj-$(CONFIG_MFD_LM3533)   += lm3533-core.o lm3533-ctrlbank.o
+obj-$(CONFIG_MFD_RETU) += retu-mfd.o
diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c
new file mode 100644
index 000..7ff4a37
--- /dev/null
+++ b/drivers/mfd/retu-mfd.c
@@ -0,0 +1,264 @@
+/*
+ * Retu MFD driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Juha Yrjölä, David Weinehall and Mikko Ylinen.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/err.h
+#include linux/i2c.h
+#include linux/irq.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/mutex.h
+#include linux/module.h
+#include linux/regmap.h
+#include linux/mfd/core.h
+#include linux/mfd/retu.h
+#include linux/interrupt.h
+#include linux/moduleparam.h
+
+/* Registers */
+#define RETU_REG_ASICR 0x00/* ASIC ID and revision */
+#define RETU_REG_ASICR_VILMA   (1  7)/* Bit indicating Vilma */
+#define RETU_REG_IDR   0x01/* Interrupt ID */
+#define RETU_REG_IMR   0x02/* Interrupt mask */
+
+/* Interrupt sources */
+#define RETU_INT_PWR   0   /* Power button */
+
+struct retu_dev {
+   struct regmap   *regmap;
+   struct device   *dev;
+   struct mutexmutex;
+   struct regmap_irq_chip_data *irq_data;
+};
+
+static struct resource retu_pwrbutton_res[] = {
+   {
+   .name   = retu-pwrbutton,
+   .start  = RETU_INT_PWR,
+   .end= RETU_INT_PWR,
+   .flags  = IORESOURCE_IRQ,
+   },
+};
+
+static struct mfd_cell retu_devs[] = {
+   {
+   .name   = retu-wdt
+   },
+   {
+   .name   = retu-pwrbutton,
+   .resources  = retu_pwrbutton_res,
+   .num_resources  = ARRAY_SIZE(retu_pwrbutton_res),
+   }
+};
+
+static struct regmap_irq retu_irqs[] = {
+   [RETU_INT_PWR] = {
+   .mask = 1  RETU_INT_PWR,
+   }
+};
+
+static struct regmap_irq_chip retu_irq_chip = {
+   .name   = RETU,
+   .irqs   = retu_irqs,
+   .num_irqs   = ARRAY_SIZE(retu_irqs),
+   .num_regs   = 1,
+   .status_base= RETU_REG_IDR,
+   .mask_base  = RETU_REG_IMR,
+   .ack_base   = RETU_REG_IDR,
+};
+
+/* Retu device registered for the power off. */
+static struct retu_dev *retu_pm_power_off;
+
+int retu_read(struct retu_dev *rdev, u8 reg)
+{
+   int ret;
+   int value;
+
+   mutex_lock(rdev-mutex);
+   ret = regmap_read(rdev-regmap, reg, value);
+   mutex_unlock(rdev-mutex);
+
+   return ret ? ret : value;
+}
+EXPORT_SYMBOL_GPL(retu_read);
+
+int retu_write(struct retu_dev *rdev, u8 reg, u16 data)
+{
+   int ret;
+
+   mutex_lock(rdev-mutex);
+   ret = regmap_write(rdev-regmap, reg, data

[RESEND PATCH v3 0/4] cbus/retu drivers

2012-11-12 Thread Aaro Koskinen
This patch set introduces drivers for CBUS access and Retu multifunction
chip found on Nokia Internet Tablets (770, N800, N810). It would be
nice get these patches applied as the functionality of these devices is
severely lacking without Retu. E.g. watchdog support is mandatory at
least on Nokia N800, you cannot currently run the mainline kernel for
longer than ~60 seconds (there is no way to disable the watchdog).

Drivers originate from linux-omap cbus branch and have been cleaned
up/rewritten around i2c and MFD core.

Patches have been tested on top of 3.7-rc5 with Nokia N800 (watchdog
feeding works, power off shuts down the device, power button triggers
IRQs and input events, loading and unloading retu-pwrbutton module in a
loop while manically pressing the power button does not crash the kernel).

Changes since the second version (https://lkml.org/lkml/2012/10/31/520):
- i2c-cbus:
- move i2c-cbus.h under linux/platform_data
- retu-mfd
- replace retu_pwrbutton_res[0] expression with simpler
  retu_pwrbutton_res.
- retu-pwrbutton:
- eliminate struct retu_pwrbutton
- delete checks for duplicate events
- rework probe to avoid races
- disable IRQ before unregister in retu_pwrbutton_remove() to
  avoid races
- eliminate double free in retu_pwrbutton_remove()
- add .owner = THIS_MODULE

Changes since the first version (https://lkml.org/lkml/2012/9/3/265):
- i2c-cbus:
- use devres
- improve comments
- simplify and delete redundant code
- refactoring  bug fixes on error handling
- discard input parameter from cbus_send_bit/data()
- retu-mfd:
- use devres
- use regmap
- retu_wdt: use devres
- retu-pwrbutton: use devres

Changes since the RFC version
(http://marc.info/?l=linux-omapm=134618967116737w=2):
- added DT support for getting i2c-cbus GPIO pins
- merged n8x0 board file changes into i2c-cbus patch
- corrected typo in Kconfig for MFD_RETU
- added power off functionality to retu-mfd
- added IRQ functionality to retu-mfd
- added power button key driver
- some cleanups

Aaro Koskinen (4):
  i2c: introduce i2c-cbus driver
  mfd: introduce retu-mfd driver
  watchdog: introduce retu_wdt driver
  input: misc: introduce retu-pwrbutton

 arch/arm/mach-omap2/board-n8x0.c   |   42 +
 drivers/i2c/busses/Kconfig |   10 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-cbus.c  |  300 
 drivers/input/misc/Kconfig |   10 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/retu-pwrbutton.c|  102 +++
 drivers/mfd/Kconfig|9 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/retu-mfd.c |  264 
 drivers/watchdog/Kconfig   |   12 ++
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/retu_wdt.c|  178 +++
 include/linux/mfd/retu.h   |   22 +++
 include/linux/platform_data/i2c-cbus.h |   27 +++
 15 files changed, 980 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-cbus.c
 create mode 100644 drivers/input/misc/retu-pwrbutton.c
 create mode 100644 drivers/mfd/retu-mfd.c
 create mode 100644 drivers/watchdog/retu_wdt.c
 create mode 100644 include/linux/mfd/retu.h
 create mode 100644 include/linux/platform_data/i2c-cbus.h

-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v3 3/4] watchdog: introduce retu_wdt driver

2012-11-12 Thread Aaro Koskinen
Introduce Retu watchdog driver.

Cc: linux-watch...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wim Van Sebroeck w...@iguana.be
---
 drivers/watchdog/Kconfig|   12 +++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/retu_wdt.c |  178 +++
 3 files changed, 191 insertions(+), 0 deletions(-)
 create mode 100644 drivers/watchdog/retu_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ad1bb93..c3a836d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -352,6 +352,18 @@ config IMX2_WDT
  To compile this driver as a module, choose M here: the
  module will be called imx2_wdt.
 
+config RETU_WATCHDOG
+   tristate Retu watchdog
+   depends on MFD_RETU
+   select WATCHDOG_CORE
+   help
+ Retu watchdog driver for Nokia Internet Tablets (700, N800,
+ N810). At least on N800 the watchdog cannot be disabled, so
+ this driver is essential and you should enable it.
+
+ To compile this driver as a module, choose M here: the
+ module will be called retu_wdt.
+
 # AVR32 Architecture
 
 config AT32AP700X_WDT
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 572b39b..d2f1c0c 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o
 obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
 obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
 obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
+obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o
 
 # AVR32 Architecture
 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c
new file mode 100644
index 000..aeb0f39
--- /dev/null
+++ b/drivers/watchdog/retu_wdt.c
@@ -0,0 +1,178 @@
+/*
+ * Retu watchdog driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Amit Kucheria and Michael Buesch.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/device.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/watchdog.h
+#include linux/platform_device.h
+
+/* Watchdog timer values in seconds */
+#define RETU_WDT_MAX_TIMER 63
+
+struct retu_wdt_dev {
+   struct retu_dev *rdev;
+   struct device   *dev;
+   struct delayed_work ping_work;
+};
+
+/*
+ * Since Retu watchdog cannot be disabled in hardware, we must kick it
+ * with a timer until userspace watchdog software takes over. If
+ * CONFIG_WATCHDOG_NOWAYOUT is set, we never start the feeding.
+ */
+static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   schedule_delayed_work(wdev-ping_work,
+   round_jiffies_relative(RETU_WDT_MAX_TIMER * HZ / 2));
+}
+
+static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   cancel_delayed_work_sync(wdev-ping_work);
+}
+
+static void retu_wdt_ping_work(struct work_struct *work)
+{
+   struct retu_wdt_dev *wdev = container_of(to_delayed_work(work),
+   struct retu_wdt_dev, ping_work);
+   retu_wdt_ping_enable(wdev);
+}
+
+static int retu_wdt_start(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_disable(wdev);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_stop(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_enable(wdev);
+
+   return 0;
+}
+
+static int retu_wdt_ping(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_set_timeout(struct watchdog_device *wdog,
+   unsigned int timeout)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   wdog-timeout = timeout;
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static const struct watchdog_info retu_wdt_info = {
+   .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+   .identity = Retu

[RESEND PATCH v3 4/4] input: misc: introduce retu-pwrbutton

2012-11-12 Thread Aaro Koskinen
Add Retu power button driver.

Cc: linux-in...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Dmitry Torokhov dmitry.torok...@gmail.com
---
 drivers/input/misc/Kconfig  |   10 
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/retu-pwrbutton.c |  102 +++
 3 files changed, 113 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/retu-pwrbutton.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7c0f1ec..e5be189 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -367,6 +367,16 @@ config INPUT_CM109
  To compile this driver as a module, choose M here: the module will be
  called cm109.
 
+config INPUT_RETU_PWRBUTTON
+   tristate Retu Power button Driver
+   depends on MFD_RETU
+   help
+ Say Y here if you want to enable power key reporting via the
+ Retu chips found in Nokia Internet Tablets (770, N800, N810).
+
+ To compile this driver as a module, choose M here. The module will
+ be called retu-pwrbutton.
+
 config INPUT_TWL4030_PWRBUTTON
tristate TWL4030 Power button Driver
depends on TWL4030_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 83fe6f5..4fbee0d 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)   += pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_POWERMATE)  += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)   += rb532_button.o
+obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SPARCSPKR)  += sparcspkr.o
diff --git a/drivers/input/misc/retu-pwrbutton.c 
b/drivers/input/misc/retu-pwrbutton.c
new file mode 100644
index 000..043a12b
--- /dev/null
+++ b/drivers/input/misc/retu-pwrbutton.c
@@ -0,0 +1,102 @@
+/*
+ * Retu power button driver.
+ *
+ * Copyright (C) 2004-2010 Nokia Corporation
+ *
+ * Original code written by Ari Saastamoinen, Juha Yrjölä and Felipe Balbi.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/irq.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/input.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+
+#define RETU_STATUS_PWRONX (1  5)
+
+static irqreturn_t retu_pwrbutton_irq(int irq, void *_pwr)
+{
+   bool state;
+   struct input_dev *idev = _pwr;
+   struct retu_dev *rdev = input_get_drvdata(idev);
+
+   state = !(retu_read(rdev, RETU_REG_STATUS)  RETU_STATUS_PWRONX);
+   input_report_key(idev, KEY_POWER, state);
+   input_sync(idev);
+
+   return IRQ_HANDLED;
+}
+
+static int __devinit retu_pwrbutton_probe(struct platform_device *pdev)
+{
+   struct retu_dev *rdev = dev_get_drvdata(pdev-dev.parent);
+   struct input_dev *idev;
+   int ret;
+
+   idev = input_allocate_device();
+   if (!idev)
+   return -ENOMEM;
+
+   idev-evbit[0]  = BIT_MASK(EV_KEY);
+   idev-keybit[BIT_WORD(KEY_POWER)]   = BIT_MASK(KEY_POWER);
+   idev-name  = retu-pwrbutton;
+
+   platform_set_drvdata(pdev, idev);
+   input_set_drvdata(idev, rdev);
+
+   ret = input_register_device(idev);
+   if (ret  0) {
+   input_free_device(idev);
+   return ret;
+   }
+
+   ret = devm_request_threaded_irq(pdev-dev, platform_get_irq(pdev, 0),
+   NULL, retu_pwrbutton_irq, 0,
+   retu-pwrbutton, idev);
+   if (ret  0)
+   input_unregister_device(idev);
+
+   return ret;
+}
+
+static int __devexit retu_pwrbutton_remove(struct platform_device *pdev)
+{
+   struct input_dev *idev = platform_get_drvdata(pdev);
+
+   disable_irq(platform_get_irq(pdev, 0));
+   input_unregister_device(idev);
+
+   return 0;
+}
+
+static struct platform_driver retu_pwrbutton_driver = {
+   .probe  = retu_pwrbutton_probe,
+   .remove = __devexit_p(retu_pwrbutton_remove),
+   .driver = {
+   .name   = retu-pwrbutton,
+   .owner  = THIS_MODULE

[RESEND PATCH v3 1/4] i2c: introduce i2c-cbus driver

2012-11-12 Thread Aaro Koskinen
Add i2c driver to enable access to devices behind CBUS on Nokia Internet
Tablets.

The patch also adds CBUS I2C configuration for N8x0 which is one of the
users of this driver.

Cc: linux-...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wolfram Sang w.s...@pengutronix.de
---
 arch/arm/mach-omap2/board-n8x0.c   |   42 +
 drivers/i2c/busses/Kconfig |   10 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-cbus.c  |  300 
 include/linux/platform_data/i2c-cbus.h |   27 +++
 5 files changed, 380 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-cbus.c
 create mode 100644 include/linux/platform_data/i2c-cbus.h

diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index d95f727..8e8a09d 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -16,10 +16,12 @@
 #include linux/gpio.h
 #include linux/init.h
 #include linux/io.h
+#include linux/irq.h
 #include linux/stddef.h
 #include linux/i2c.h
 #include linux/spi/spi.h
 #include linux/usb/musb.h
+#include linux/platform_data/i2c-cbus.h
 #include linux/platform_data/spi-omap2-mcspi.h
 #include linux/platform_data/mtd-onenand-omap2.h
 #include sound/tlv320aic3x.h
@@ -39,6 +41,45 @@
 #define TUSB6010_GPIO_ENABLE   0
 #define TUSB6010_DMACHAN   0x3f
 
+#if defined(CONFIG_I2C_CBUS) || defined(CONFIG_I2C_CBUS_MODULE)
+static struct i2c_cbus_platform_data n8x0_cbus_data = {
+   .clk_gpio = 66,
+   .dat_gpio = 65,
+   .sel_gpio = 64,
+};
+
+static struct platform_device n8x0_cbus_device = {
+   .name   = i2c-cbus,
+   .id = 3,
+   .dev= {
+   .platform_data = n8x0_cbus_data,
+   },
+};
+
+static struct i2c_board_info n8x0_i2c_board_info_3[] __initdata = {
+   {
+   I2C_BOARD_INFO(retu-mfd, 0x01),
+   },
+};
+
+static void __init n8x0_cbus_init(void)
+{
+   const int retu_irq_gpio = 108;
+
+   if (gpio_request_one(retu_irq_gpio, GPIOF_IN, Retu IRQ))
+   return;
+   irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
+   n8x0_i2c_board_info_3[0].irq = gpio_to_irq(retu_irq_gpio);
+   i2c_register_board_info(3, n8x0_i2c_board_info_3,
+   ARRAY_SIZE(n8x0_i2c_board_info_3));
+   platform_device_register(n8x0_cbus_device);
+}
+#else /* CONFIG_I2C_CBUS */
+static void __init n8x0_cbus_init(void)
+{
+}
+#endif /* CONFIG_I2C_CBUS */
+
 #if defined(CONFIG_USB_MUSB_TUSB6010) || 
defined(CONFIG_USB_MUSB_TUSB6010_MODULE)
 /*
  * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
@@ -677,6 +718,7 @@ static void __init n8x0_init_machine(void)
gpmc_onenand_init(board_onenand_data);
n8x0_mmc_init();
n8x0_usb_init();
+   n8x0_cbus_init();
 }
 
 MACHINE_START(NOKIA_N800, Nokia N800)
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index e9df461..fdfc222 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -337,6 +337,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
help
  The unit of the TWI clock is kHz.
 
+config I2C_CBUS
+   tristate CBUS I2C driver
+   depends on GENERIC_GPIO
+   help
+ Support for CBUS access using I2C API. Mostly relevant for Nokia
+ Internet Tablets (770, N800 and N810).
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-cbus.
+
 config I2C_CPM
tristate Freescale CPM1 or CPM2 (MPC8xx/826x)
depends on (CPM1 || CPM2)  OF_I2C
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 395b516..0a71da5 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_I2C_POWERMAC)+= i2c-powermac.o
 obj-$(CONFIG_I2C_AT91) += i2c-at91.o
 obj-$(CONFIG_I2C_AU1550)   += i2c-au1550.o
 obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
+obj-$(CONFIG_I2C_CBUS) += i2c-cbus.o
 obj-$(CONFIG_I2C_CPM)  += i2c-cpm.o
 obj-$(CONFIG_I2C_DAVINCI)  += i2c-davinci.o
 obj-$(CONFIG_I2C_DESIGNWARE_CORE)  += i2c-designware-core.o
diff --git a/drivers/i2c/busses/i2c-cbus.c b/drivers/i2c/busses/i2c-cbus.c
new file mode 100644
index 000..e6086cf
--- /dev/null
+++ b/drivers/i2c/busses/i2c-cbus.c
@@ -0,0 +1,300 @@
+/*
+ * CBUS I2C driver for Nokia Internet Tablets.
+ *
+ * Copyright (C) 2004-2010 Nokia Corporation
+ *
+ * Based on code written by Juha Yrjölä, David Weinehall, Mikko Ylinen and
+ * Felipe Balbi. Converted to I2C driver by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful

[PATCH] ARM: kexec: fix segment memory addresses check

2012-10-16 Thread Aaro Koskinen
Commit c564df4db85aac8d1d65a56176a0a25f46138064 (ARM: 7540/1: kexec:
Check segment memory addresses) added a safety check with accidentally
reversed condition, and broke kexec functionality on ARM. Fix this.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/arm/kernel/machine_kexec.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index e29c333..8ef8c93 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -45,10 +45,9 @@ int machine_kexec_prepare(struct kimage *image)
for (i = 0; i  image-nr_segments; i++) {
current_segment = image-segment[i];
 
-   err = memblock_is_region_memory(current_segment-mem,
-   current_segment-memsz);
-   if (err)
-   return - EINVAL;
+   if (!memblock_is_region_memory(current_segment-mem,
+  current_segment-memsz))
+   return -EINVAL;
 
err = get_user(header, (__be32*)current_segment-buf);
if (err)
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] OMAP3 ROM Random Number Generator support

2013-04-01 Thread Aaro Koskinen
Hi,

On Sun, Mar 31, 2013 at 03:05:42PM +0300, Ивайло Димитров wrote:
 Yep, the code looks almost identical, I guess with some tweaks all SMC
 code from that patch could be removed and instead used the one from SMC
 PPA API.
 
 What I don't get, is why one needs to disable/enable fiqs/irqs:

[..]

 Do you have any idea why is that needed? Any other code I've ever seen
 to call SM, does not disable fiqs/irqs, is RNG SMC somehow special? I
 know this is Nokia's code, but still, if we can get some understanding...

I think without disabling irqs you may suffer some strange crashes when
heavily stressing the RNG... that's why you also have cache flushes before
and after the SMC. With proper test suite you could probably verify this.
How are you testing this driver?

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drm/nouveau: fix NULL ptr dereference from nv50_disp_intr()

2013-03-24 Thread Aaro Koskinen
Hi,

On Sun, Mar 24, 2013 at 12:56:30PM +0100, Maarten Lankhorst wrote:
 Op 23-03-13 12:47, Peter Hurley schreef:
  On Tue, 2013-03-19 at 11:13 -0400, Peter Hurley wrote:
  On vanilla 3.9.0-rc3, I get this 100% repeatable oops after login when
  the user X session is coming up:
  Perhaps I wasn't clear that this happens on every boot and is a
  regression from 3.8
 
  I'd be happy to help resolve this but time is of the essence; it would
  be a shame to have to revert all of this for 3.9
 
 Well it broke on my system too, so it was easy to fix.
 
 I didn't even need gdm to trigger it!
 
 8
 This fixes regression caused by 1d7c71a3e2f7 (drm/nouveau/disp: port vblank 
 handling to event interface),

This patch fixes the boot crashes also on my G5 iMac
(http://marc.info/?l=linux-kernelm=136285469916031w=2).

Tested-by: Aaro Koskinen aaro.koski...@iki.fi

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Driver lis3lv02d_i2c not working on Nokia RX-51

2013-03-26 Thread Aaro Koskinen
Hi,

On Tue, Mar 26, 2013 at 04:02:39PM +0100, Pali Rohár wrote:
 CCing Aaro and Tony. Look at this thread on: 
 https://lkml.org/lkml/2013/2/16/152
 
 What do you think how to fix this problem? I do not know about any 
 HW regulator for n900 accelerometer and possible solutions could 
 be revert that commit or adding fake regulator to board code...

I think the following should work:

...

From: Aaro Koskinen aaro.koski...@iki.fi
Date: Tue, 26 Mar 2013 21:34:22 +0200
Subject: [PATCH] OMAP: RX-51: add missing regulator supply definitions for 
lis3lv02d

Add missing regulator definitions for lis3lv02d accelerometer. Fixes
the following probe issue:

[   57.737518] lis3lv02d_i2c 3-001d: Failed to get supply 'Vdd': -517
[   57.747100] i2c 3-001d: Driver lis3lv02d_i2c requests probe deferral

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/arm/mach-omap2/board-rx51-peripherals.c |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c 
b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 3a077df..1a88467 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -547,12 +547,16 @@ static struct regulator_consumer_supply 
rx51_vio_supplies[] = {
REGULATOR_SUPPLY(DVDD, 2-0019),
/* Si4713 IO supply */
REGULATOR_SUPPLY(vio, 2-0063),
+   /* lis3lv02d */
+   REGULATOR_SUPPLY(Vdd_IO, 3-001d),
 };
 
 static struct regulator_consumer_supply rx51_vaux1_consumers[] = {
REGULATOR_SUPPLY(vdds_sdi, omapdss),
/* Si4713 supply */
REGULATOR_SUPPLY(vdd, 2-0063),
+   /* lis3lv02d */
+   REGULATOR_SUPPLY(Vdd, 3-001d),
 };
 
 static struct regulator_init_data rx51_vaux1 = {
-- 
1.7.10.4

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ARM: OMAP: drop select MACH_NOKIA_RM696

2013-03-08 Thread Aaro Koskinen
On Fri, Mar 08, 2013 at 11:29:56AM +0100, Paul Bolle wrote:
 When support was added for Nokia N9 (RM-696), with commit
 63fc5f3bb3d0ca9ab4767a801b518aa6335f87ad (ARM: OMAP: add minimal
 support for Nokia RM-696), a select statement for MACH_NOKIA_RM696 was
 added to the tree. But there's no Kconfig symbol with that name. That
 symbol would be superfluous, since support for that machine piggybacks
 on MACH_NOKIA_RM680. So drop that select.

This is needed because of arch/arm/tools/mach-types. See
include/generated/mach-types.h.

If you have just CONFIG_MACH_NOKIA_RM680 and run the kernel on RM-696,
then machine_is_nokia_rm696() will return false. If I rememeber correctly,
this broke at least early printk / uncompressor output at the time.

I guess people may still want to use machine_is_... macros e.g. for
debugging.

 Signed-off-by: Paul Bolle pebo...@tiscali.nl
 ---
 0) Tested with git grep.

git grep won't search generated source files.

 1) Some searching on the web didn't return a config MACH_NOKIA_RM696.
 So apparently there's not even a development tree that uses this symbol.

You can see machine_is_nokia_rm696() used in the public kernel source
for Nokia N9 product. :-)

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux 3.9-rc1: nouveau crash on PPC

2013-03-09 Thread Aaro Koskinen
Hi,

There's nouveau crash during boot with 3.9-rc1 on iMac G5 (nVidia GeForce
FX 5200 Ultra). This happens also with current mainline kernel HEAD
(0aefda3e8188ad71168bd32152d41b3d72f04087).

git bisect tells the first bad commit is
1d7c71a3e2f77336df536855b0efd2dc5bdeb41b (drm/nouveau/disp: port vblank
handling to event interface).

The crash is (manually copied from screen):

[...]

Unable to handle kernel paging request for data at address 0x1

call trace:
nouveau_event_trigger
nv04_disp_intr
nouveau_mc_intr
nouveau_irq_handler

[...]

I also tried to capture it with netconsole, and got this much:

[   23.114208] nouveau  [  DEVICE][:f0:10.0] BOOT0  : 0x034900b1
[   23.114257] nouveau  [  DEVICE][:f0:10.0] Chipset: NV34 (NV34)
[   23.114266] nouveau  [  DEVICE][:f0:10.0] Family : NV30
[   23.114672] nouveau  [   VBIOS][:f0:10.0] checking OpenFirmware for 
image...
[   23.114712] nouveau  [   VBIOS][:f0:10.0] ... checksum invalid
[   23.114720] nouveau  [   VBIOS][:f0:10.0] checking PRAMIN for image...
[   23.114754] nouveau  [   VBIOS][:f0:10.0] ... signature not found
[   23.114761] nouveau  [   VBIOS][:f0:10.0] checking PROM for image...
[   23.114845] nouveau  [   VBIOS][:f0:10.0] ... signature not found
[   23.114853] nouveau  [   VBIOS][:f0:10.0] checking ACPI for image...
[   23.114862] nouveau  [   VBIOS][:f0:10.0] ... signature not found
[   23.114881] nouveau  [   VBIOS][:f0:10.0] checking PCIROM for image...
[   23.114930] nouveau :f0:10.0: Invalid ROM contents
[   23.114946] nouveau  [   VBIOS][:f0:10.0] ... signature not found
[   23.114976] nouveau  [   VBIOS][:f0:10.0] using image from OpenFirmware
[   23.114987] nouveau  [   VBIOS][:f0:10.0] BMP version 5.26
[   23.115035] nouveau  [   VBIOS][:f0:10.0] version 04.34.20.18.00
[   23.134608] nouveau W[   VBIOS][:f0:10.0] unknown i2c type 3
[   23.134637] nouveau W[   VBIOS][:f0:10.0] unknown i2c type 3
[   23.136488] nouveau W[  PTIMER][:f0:10.0] unknown input clock freq
[   23.136536] nouveau  [ PFB][:f0:10.0] RAM type: DDR1
[   23.136544] nouveau  [ PFB][:f0:10.0] RAM size: 32 MiB
[   23.136552] nouveau  [ PFB][:f0:10.0]ZCOMP: 0 tags
[   23.150773] [TTM] Zone  kernel: Available graphics memory: 744988 kiB
[   23.150800] [TTM] Initializing pool allocator
[   23.150882] nouveau  [ DRM] VRAM: 31 MiB
[   23.150890] nouveau  [ DRM] GART: 128 MiB
[   23.150927] nouveau  [ DRM] BMP version 5.38
[   23.150937] nouveau  [ DRM] DCB version 2.2
[   23.150971] nouveau  [ DRM] DCB outp 00: 01000122 0004
[   23.150981] nouveau  [ DRM] DCB outp 01: 02010200 11b088b8
[   23.150988] nouveau  [ DRM] DCB outp 02: 02010201 11b00703
[   23.151040] nouveau  [ DRM] Loading NV17 power sequencing microcode
[   23.170180] [drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
[   23.170212] [drm] No driver support for vblank timestamp query.
[   23.170277] nouveau E[ DRM] Pixel clock comparison table not found
[   23.171010] nouveau  [ DRM] 0 available performance level(s)
[   23.171028] nouveau  [ DRM] c: core 241MHz memory 475MHz
[   23.177822] nouveau  [ DRM] MM: using M2MF for buffer copies
[   23.177917] nouveau  [ DRM] Setting dpms mode 3 on TV encoder (output 2)
[   23.285783] nouveau  [ DRM] allocated 1680x1050 fb: 0x9000, bo 
c00056d52c00
[   23.306569] nouveau E[ DRM] Pixel clock comparison table not found
[   23.317565] Console: switching to colour frame buffer device 210x65
[   23.321370] nouveau :f0:10.0: fb0: nouveaufb frame buffer device
[   23.321386] nouveau :f0:10.0: registered panic notifier
[   23.321444] [drm] Initialized nouveau 1.1.0 20120801 for :f0:10.0 on 
minor 0
[   23.329860] Unable to handle kernel paging request for data at address 
0x1
[   23.329918] Faulting instruction address: 0xd0801394
[   23.329939] Oops: Kernel access of bad area, sig: 11 [#1]
[   23.329953] PREEMPT PowerMac
[   23.329982] Modules linked in: nouveau ttm drm_kms_helper
[   23.330035] NIP: d0801394 LR: d08013a8 CTR: c00178e0
[   23.330052] REGS: cfff78b0 TRAP: 0300   Not tainted  
(3.9.0-rc1-imac-00277-g0aefda3-dirty)
[   23.330065] MSR: 90009032 SF,HV,EE,ME,IR,DR,RI  CR: 2884  XER: 

[   23.330174] SOFTE: 0
[   23.330187] DAR: 0001, DSISR: 4000
[   23.330202] TASK = c0805aa0[0] 'swapper' THREAD: c0894000
GPR00: d08013a8 cfff7b30 d09272c0 c00056de5458 
GPR04:   0002  
GPR08: [   24.321933] Kernel panic - not syncing: Fatal exception in interrupt
[   24.321951] drm_kms_helper: panic occurred, switching back to text console
[   24.322013] [ cut here ]
[   24.322029] WARNING: at drivers/gpu/drm/drm_crtc.c:82
[   24.322041] Modules linked in: nouveau ttm 

Re: linux 3.9-rc1: nouveau crash on PPC

2013-03-13 Thread Aaro Koskinen
Hi,

On Sat, Mar 09, 2013 at 08:44:31PM +0200, Aaro Koskinen wrote:
 There's nouveau crash during boot with 3.9-rc1 on iMac G5 (nVidia GeForce
 FX 5200 Ultra). This happens also with current mainline kernel HEAD
 (0aefda3e8188ad71168bd32152d41b3d72f04087).
 
 git bisect tells the first bad commit is
 1d7c71a3e2f77336df536855b0efd2dc5bdeb41b (drm/nouveau/disp: port vblank
 handling to event interface).
 
 The crash is (manually copied from screen):
 
 [...]
 
 Unable to handle kernel paging request for data at address 0x1
 
 call trace:
 nouveau_event_trigger

The cause is event handling linked lists getting corrupted.

I'm not sure how that code is intented to work, but with the below HACK
I can at least boot the iMac without crashing, and get a working display:

diff --git a/drivers/gpu/drm/nouveau/core/core/event.c 
b/drivers/gpu/drm/nouveau/core/core/event.c
index 6d01e0f..ab8d6c7 100644
--- a/drivers/gpu/drm/nouveau/core/core/event.c
+++ b/drivers/gpu/drm/nouveau/core/core/event.c
@@ -29,7 +29,7 @@ nouveau_event_put_locked(struct nouveau_event *event, int 
index,
 {
if (!--event-index[index].refs)
event-disable(event, index);
-   list_del(handler-head);
+   list_del(handler-heads[index]);
 }
 
 void
@@ -39,7 +39,7 @@ nouveau_event_put(struct nouveau_event *event, int index,
unsigned long flags;
 
spin_lock_irqsave(event-lock, flags);
-   if (index  event-index_nr)
+   if (index  ARRAY_SIZE(handler-heads)  index  event-index_nr)
nouveau_event_put_locked(event, index, handler);
spin_unlock_irqrestore(event-lock, flags);
 }
@@ -51,8 +51,8 @@ nouveau_event_get(struct nouveau_event *event, int index,
unsigned long flags;
 
spin_lock_irqsave(event-lock, flags);
-   if (index  event-index_nr) {
-   list_add(handler-head, event-index[index].list);
+   if (index  ARRAY_SIZE(handler-heads)  index  event-index_nr) {
+   list_add(handler-heads[index], event-index[index].list);
if (!event-index[index].refs++)
event-enable(event, index);
}
@@ -69,7 +69,7 @@ nouveau_event_trigger(struct nouveau_event *event, int index)
return;
 
spin_lock_irqsave(event-lock, flags);
-   list_for_each_entry_safe(handler, temp, event-index[index].list, 
head) {
+   list_for_each_entry_safe(handler, temp, event-index[index].list, 
heads[index]) {
if (handler-func(handler, index) == NVKM_EVENT_DROP) {
nouveau_event_put_locked(event, index, handler);
}
diff --git a/drivers/gpu/drm/nouveau/core/include/core/event.h 
b/drivers/gpu/drm/nouveau/core/include/core/event.h
index 9e09440..ba52172 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/event.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/event.h
@@ -6,7 +6,7 @@
 #define NVKM_EVENT_KEEP 1
 
 struct nouveau_eventh {
-   struct list_head head;
+   struct list_head heads[2];
int (*func)(struct nouveau_eventh *, int index);
 };
 
A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND] MIPS: loongson: fix random early boot hang

2013-03-04 Thread Aaro Koskinen
Some Loongson boards (e.g. Lemote FuLoong mini-PC) use ISA/southbridge
device (CS5536 general purpose timer) for the timer interrupt. It starts
running early and is already enabled during the PCI configuration,
during which there is a small window in pci_read_base() when the register
access is temporarily disabled. If the timer interrupts at this point,
the system will hang. Fix this by adding a fixup that keeps the register
access always enabled.

The hang the patch fixes usually looks like this:

[0.844000] pci :00:0e.0: [1022:2090] type 00 class 0x060100
[0.848000] pci :00:0e.0: reg 10: [io  0xb410-0xb417]
[0.852000] pci :00:0e.0: reg 14: [io  0xb000-0xb0ff]
[0.856000] pci :00:0e.0: reg 18: [io  0xb380-0xb3bf]
[   28.14] BUG: soft lockup - CPU#0 stuck for 23s! [swapper:1]
[   28.14] Modules linked in:
[   28.14] irq event stamp: 37965
[   28.14] hardirqs last  enabled at (37964): [80204c0c] 
restore_partial+0x6c/0x13c
[   28.14] hardirqs last disabled at (37965): [80204f8c] 
handle_int+0x144/0x15c
[   28.14] softirqs last  enabled at (24316): [802381f4] 
__do_softirq+0x1cc/0x258
[   28.14] softirqs last disabled at (24327): [80238420] 
do_softirq+0xc8/0xd0
[   28.14] Cpu 0
[   28.14] $ 0   :  140044e1 98009f09 
0001
[   28.14] $ 4   : 98009f09  0100 
03b7fff87fbde011
[   28.14] $ 8   : 812b1928 0001e000 04387fbde011 
fff87fbde011
[   28.14] $12   : 000e 807a 0698 

[   28.14] $16   : 0002 81055e20 80786810 

[   28.14] $20   : 000a 807bc244 807e6350 
8077
[   28.14] $24   : 0d80 fffedbe0
[   28.14] $28   : 98009f07c000 98009f07fa10 8105 
802380f8
[   28.14] Hi: 00d0fc00
[   28.14] Lo: 00f82b40
[   28.14] epc   : 8023810c __do_softirq+0xe4/0x258
[   28.14] Not tainted
[   28.14] ra: 802380f8 __do_softirq+0xd0/0x258
[   28.14] Status: 140044e3KX SX UX KERNEL EXL IE
[   28.14] Cause : 10008400
[   28.14] PrId  : 6303 (ICT Loongson-2)

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: sta...@vger.kernel.org
---
 arch/mips/loongson/common/cs5536/cs5536_isa.c |   14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/mips/loongson/common/cs5536/cs5536_isa.c 
b/arch/mips/loongson/common/cs5536/cs5536_isa.c
index a6eb2e8..924be39 100644
--- a/arch/mips/loongson/common/cs5536/cs5536_isa.c
+++ b/arch/mips/loongson/common/cs5536/cs5536_isa.c
@@ -13,6 +13,7 @@
  * option) any later version.
  */
 
+#include linux/pci.h
 #include cs5536/cs5536.h
 #include cs5536/cs5536_pci.h
 
@@ -314,3 +315,16 @@ u32 pci_isa_read_reg(int reg)
 
return conf_data;
 }
+
+/*
+ * The mfgpt timer interrupt is running early, so we must keep the south bridge
+ * mmio always enabled. Otherwise we may race with the PCI configuration which
+ * may temporarily disable it. When that happens and the timer interrupt fires,
+ * we are not able to clear it and the system will hang.
+ */
+static void cs5536_isa_mmio_always_on(struct pci_dev *dev)
+{
+   dev-mmio_always_on = 1;
+}
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA,
+   PCI_CLASS_BRIDGE_ISA, 8, cs5536_isa_mmio_always_on);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


macintosh/windfarm: possible circular locking dependency detected

2013-02-08 Thread Aaro Koskinen
Hi,

On iMac G5 (the first model, windfarm_pm81 reports model 3), enabling
LOCKDEP results in the following warnings when overtemp condition is
encountered.

The kernel is 3.8-rc6+ / 6bacaa9.

[ 7060.058340] windfarm: Clamping CPU frequency to minimum !
[ 7060.229688] 
[ 7060.229756] ==
[ 7060.229799] [ INFO: possible circular locking dependency detected ]
[ 7060.229847] 3.8.0-rc6-imac-00113-g6bacaa9 #2 Not tainted
[ 7060.229882] ---
[ 7060.229923] kwindfarm/475 is trying to acquire lock:
[ 7060.229958]  (wf_lock){+.+.+.}, at: [c0447b54] 
.wf_set_overtemp+0x34/0xb0
[ 7060.230070] 
[ 7060.230070] but task is already holding lock:
[ 7060.230111]  ((wf_client_list).rwsem){.+.+.+}, at: [c00851a8] 
.__blocking_notifier_call_chain+0x78/0x110
[ 7060.230219] 
[ 7060.230219] which lock already depends on the new lock.
[ 7060.230219] 
[ 7060.230275] 
[ 7060.230275] the existing dependency chain (in reverse order) is:
[ 7060.230326] 
[ 7060.230326] - #1 ((wf_client_list).rwsem){.+.+.+}:
[ 7060.230407][c06cbf98] .down_read+0x58/0xa0
[ 7060.230463][c00851a8] 
.__blocking_notifier_call_chain+0x78/0x110
[ 7060.230521][c0447d70] .wf_register_client+0xb0/0x1b0
[ 7060.230573][c0449f0c] .wf_smu_probe+0x1c/0x40
[ 7060.230621][c042e7d0] .platform_drv_probe+0x30/0x50
[ 7060.230681][c042c868] .driver_probe_device+0xa8/0x290
[ 7060.230735][c042cb5c] .__driver_attach+0x10c/0x110
[ 7060.230787][c042a10c] .bus_for_each_dev+0x7c/0xe0
[ 7060.230837][c042c1c8] .driver_attach+0x28/0x40
[ 7060.230888][c042bba8] .bus_add_driver+0x1f8/0x330
[ 7060.230937][c042d4f4] .driver_register+0xa4/0x230
[ 7060.230989][c042eb10] .platform_driver_register+0x60/0x80
[ 7060.231044][c0949924] .wf_smu_init+0x8c/0xa8
[ 7060.231098][c0009aa8] .do_one_initcall+0x168/0x1e0
[ 7060.231151][c0927b70] .kernel_init_freeable+0x134/0x204
[ 7060.231209][c000a1bc] .kernel_init+0x1c/0x120
[ 7060.231256][c0008aa0] .ret_from_kernel_thread+0x64/0xc4
[ 7060.231311] 
[ 7060.231311] - #0 (wf_lock){+.+.+.}:
[ 7060.231381][c00a3efc] .lock_acquire+0x5c/0x90
[ 7060.231434][c06cb5b0] .mutex_lock_nested+0x90/0x3b0
[ 7060.231488][c0447b54] .wf_set_overtemp+0x34/0xb0
[ 7060.231539][c044a844] .wf_smu_notify+0x914/0xf90
[ 7060.231590][c0084e2c] .notifier_call_chain+0xcc/0x1f0
[ 7060.231643][c00851c4] 
.__blocking_notifier_call_chain+0x94/0x110
[ 7060.231699][c0448a18] .wf_thread_func+0x88/0x150
[ 7060.231747][c007c22c] .kthread+0xec/0x100
[ 7060.231794][c0008aa0] .ret_from_kernel_thread+0x64/0xc4
[ 7060.231850] 
[ 7060.231850] other info that might help us debug this:
[ 7060.231850] 
[ 7060.231905]  Possible unsafe locking scenario:
[ 7060.231905] 
[ 7060.231945]CPU0CPU1
[ 7060.231976]
[ 7060.232007]   lock((wf_client_list).rwsem);
[ 7060.232054]lock(wf_lock);
[ 7060.232104]lock((wf_client_list).rwsem);
[ 7060.232160]   lock(wf_lock);
[ 7060.233707] 
[ 7060.233707]  *** DEADLOCK ***
[ 7060.233707] 
[ 7060.238238] 1 lock held by kwindfarm/475:
[ 7060.239756]  #0:  ((wf_client_list).rwsem){.+.+.+}, at: [c00851a8] 
.__blocking_notifier_call_chain+0x78/0x110
[ 7060.241354] 
[ 7060.241354] stack backtrace:
[ 7060.244453] Call Trace:
[ 7060.246001] [c000564534f0] [c0012978] .show_stack+0x78/0x1b0 
(unreliable)
[ 7060.247582] [c000564535a0] [c06d09c8] 
.print_circular_bug+0x2e8/0x320
[ 7060.249157] [c00056453650] [c00a36c0] 
.__lock_acquire+0x17b0/0x1a70
[ 7060.250734] [c000564537d0] [c00a3efc] .lock_acquire+0x5c/0x90
[ 7060.252305] [c00056453870] [c06cb5b0] 
.mutex_lock_nested+0x90/0x3b0
[ 7060.253879] [c00056453960] [c0447b54] .wf_set_overtemp+0x34/0xb0
[ 7060.255460] [c000564539f0] [c044a844] .wf_smu_notify+0x914/0xf90
[ 7060.257019] [c00056453ad0] [c0084e2c] 
.notifier_call_chain+0xcc/0x1f0
[ 7060.258598] [c00056453b80] [c00851c4] 
.__blocking_notifier_call_chain+0x94/0x110
[ 7060.260169] [c00056453c30] [c0448a18] .wf_thread_func+0x88/0x150
[ 7060.261725] [c00056453cc0] [c007c22c] .kthread+0xec/0x100
[ 7060.263267] [c00056453e30] [c0008aa0] 
.ret_from_kernel_thread+0x64/0xc4
[ 7060.270273] windfarm: Overtemp condition detected !
[ 7062.033879] windfarm: CPU frequency unclamped !
[ 7062.035508] windfarm: Overtemp condition cleared !
[ 7221.058391] windfarm: Clamping CPU frequency to 

[PATCH] MIPS: early_printk: drop __init annotations

2013-02-11 Thread Aaro Koskinen
We cannot use __init for earlyprintk code or data, since the kernel
parameter keep_bootcon allows leaving the boot console enabled.

Currently MIPS will crash/hang/die if you use keep_bootcon. The patch
fixes it at least on Lemote FuLoong mini-PC. Changes for other boards
were done based on what I could find with grep...

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/bcm63xx/early_printk.c  |4 ++--
 arch/mips/kernel/early_printk.c   |5 ++---
 arch/mips/loongson1/common/prom.c |2 +-
 arch/mips/sgi-ip27/ip27-console.c |2 +-
 arch/mips/txx9/generic/setup.c|8 
 5 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/mips/bcm63xx/early_printk.c b/arch/mips/bcm63xx/early_printk.c
index bf353c9..aa8f7f9 100644
--- a/arch/mips/bcm63xx/early_printk.c
+++ b/arch/mips/bcm63xx/early_printk.c
@@ -10,7 +10,7 @@
 #include bcm63xx_io.h
 #include bcm63xx_regs.h
 
-static void __init wait_xfered(void)
+static void wait_xfered(void)
 {
unsigned int val;
 
@@ -22,7 +22,7 @@ static void __init wait_xfered(void)
} while (1);
 }
 
-void __init prom_putchar(char c)
+void prom_putchar(char c)
 {
wait_xfered();
bcm_uart0_writel(c, UART_FIFO_REG);
diff --git a/arch/mips/kernel/early_printk.c b/arch/mips/kernel/early_printk.c
index 9ae813e..9e6440e 100644
--- a/arch/mips/kernel/early_printk.c
+++ b/arch/mips/kernel/early_printk.c
@@ -14,8 +14,7 @@
 
 extern void prom_putchar(char);
 
-static void __init
-early_console_write(struct console *con, const char *s, unsigned n)
+static void early_console_write(struct console *con, const char *s, unsigned n)
 {
while (n--  *s) {
if (*s == '\n')
@@ -25,7 +24,7 @@ early_console_write(struct console *con, const char *s, 
unsigned n)
}
 }
 
-static struct console early_console __initdata = {
+static struct console early_console = {
.name   = early,
.write  = early_console_write,
.flags  = CON_PRINTBUFFER | CON_BOOT,
diff --git a/arch/mips/loongson1/common/prom.c 
b/arch/mips/loongson1/common/prom.c
index 1f8e49f..54dee09 100644
--- a/arch/mips/loongson1/common/prom.c
+++ b/arch/mips/loongson1/common/prom.c
@@ -73,7 +73,7 @@ void __init prom_free_prom_memory(void)
 
 #define PORT(offset)   (u8 *)(KSEG1ADDR(LS1X_UART0_BASE + offset))
 
-void __init prom_putchar(char c)
+void prom_putchar(char c)
 {
int timeout;
 
diff --git a/arch/mips/sgi-ip27/ip27-console.c 
b/arch/mips/sgi-ip27/ip27-console.c
index 984e561..b952d5b 100644
--- a/arch/mips/sgi-ip27/ip27-console.c
+++ b/arch/mips/sgi-ip27/ip27-console.c
@@ -31,7 +31,7 @@ static inline struct ioc3_uartregs *console_uart(void)
return ioc3-sregs.uarta;
 }
 
-void __init prom_putchar(char c)
+void prom_putchar(char c)
 {
struct ioc3_uartregs *uart = console_uart();
 
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 560fe89..5524f2c 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -513,19 +513,19 @@ void __init txx9_sio_init(unsigned long baseaddr, int irq,
 }
 
 #ifdef CONFIG_EARLY_PRINTK
-static void __init null_prom_putchar(char c)
+static void null_prom_putchar(char c)
 {
 }
-void (*txx9_prom_putchar)(char c) __initdata = null_prom_putchar;
+void (*txx9_prom_putchar)(char c) = null_prom_putchar;
 
-void __init prom_putchar(char c)
+void prom_putchar(char c)
 {
txx9_prom_putchar(c);
 }
 
 static void __iomem *early_txx9_sio_port;
 
-static void __init early_txx9_sio_putchar(char c)
+static void early_txx9_sio_putchar(char c)
 {
 #define TXX9_SICISR0x0c
 #define TXX9_SITFIFO   0x1c
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 01/10] staging/xgifb: Simplify XGI_GetRatePtrCRT2

2013-02-04 Thread Aaro Koskinen
Hi,

On Sun, Feb 03, 2013 at 10:54:30PM +0100, Peter Huewe wrote:
 Since the smaller LCDRefreshIndex is contained identically in LCDARefreshIndex
 we can simply use LCDARefreshIndex and skip the if/else.
 
 Since LCDARefreshIndex is only used readonly and contains only small
 unsigned values we also change its declaration to const u8.
 
 In order to prevent an out-of-bounds access I changed the mask from 0x0F
 to 0x07 and added a dummy value.
 
 Signed-off-by: Peter Huewe peterhu...@gmx.de
 ---
 Please apply this series after my previous one 
  [PATCH 1/6] staging/xgifb: Remove unused variables and dead assignments
  [PATCH 2/6] staging/xgifb: Remove unused variable
  [PATCH 3/6] staging/xgifb: Remove unused variable and dead assignment
  [PATCH 4/6] staging/xgifb: Remove unused variables
  [PATCH 5/6] staging/xgifb: Remove redundant if statement
  [PATCH 6/6] staging/xgifb: remove unused variables

I think both of these series are good. I boot tested them with Z9/XG21,
and at least fb console seems to work fine. I also checked compilation
for warnings with GCC+sparse and could not see any. So:

Tested-by: Aaro Koskinen aaro.koski...@iki.fi

for all of the patches.

Thanks,

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arm: omap: RX-51: ARM errata 430973 workaround

2013-03-01 Thread Aaro Koskinen
On Fri, Mar 01, 2013 at 12:09:12PM +0200, Ивайло Димитров wrote:
 Unfortunately it is necessary, on RX-51 PPA/NOLO leaves IBE bit unset.

You sure? I think you need to explain this more - the commit message in
the original patch is empty/missing...

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mips: Move __virt_addr_valid() to a place for MIPS 64

2013-01-26 Thread Aaro Koskinen
Hi,

On Fri, Jan 25, 2013 at 01:13:15PM -0500, Steven Rostedt wrote:
 Commit d3ce88431892 MIPS: Fix modpost error in modules attepting to use
 virt_addr_valid() moved __virt_addr_valid() from a macro in a header
 file to a function in ioremap.c. But ioremap.c is only compiled for MIPS
 32, and not for MIPS 64.
 
 When compiling for my yeeloong2, which supposedly supports hibernation,
 which compiles kernel/power/snapshot.c which calls virt_addr_valid(), I
 got this error:

This has been reported also here:

http://marc.info/?l=linux-mipsm=135788867604856w=2

and here:

http://marc.info/?l=linux-mipsm=135876719403187w=2

It's pretty sad that MIPS has been pretty much broken during the whole
3.8-rc cycle. :-(

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mips: Move __virt_addr_valid() to a place for MIPS 64

2013-01-26 Thread Aaro Koskinen
Hi,

On Sat, Jan 26, 2013 at 04:01:44PM -0500, Steven Rostedt wrote:
 On Sat, 2013-01-26 at 22:15 +0200, Aaro Koskinen wrote:
  On Fri, Jan 25, 2013 at 01:13:15PM -0500, Steven Rostedt wrote:
   Commit d3ce88431892 MIPS: Fix modpost error in modules attepting to use
   virt_addr_valid() moved __virt_addr_valid() from a macro in a header
   file to a function in ioremap.c. But ioremap.c is only compiled for MIPS
   32, and not for MIPS 64.
   
   When compiling for my yeeloong2, which supposedly supports hibernation,
   which compiles kernel/power/snapshot.c which calls virt_addr_valid(), I
   got this error:
  
  This has been reported also here:
  
  http://marc.info/?l=linux-mipsm=135788867604856w=2
  
  and here:
  
  http://marc.info/?l=linux-mipsm=135876719403187w=2
  
 
 Hmm, interesting. Although, I prefer my change as it doesn't require
 compiling all of ioremap.c where it's not needed.

Yes, I think your solution is fine.

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5] watchdog: introduce retu_wdt driver

2013-01-28 Thread Aaro Koskinen
Hi,

On Thu, Dec 27, 2012 at 10:58:29PM +0200, Aaro Koskinen wrote:
 Introduce Retu watchdog driver.

Wim, any comments about this driver? Do you think it could be queued
for 3.9?

Thanks,

A.

 Cc: linux-watch...@vger.kernel.org
 Acked-by: Felipe Balbi ba...@ti.com
 Acked-by: Tony Lindgren t...@atomide.com
 Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
 Cc: Wim Van Sebroeck w...@iguana.be
 ---
 
   v5: Deleted __dev* annotations.
   Fixed a typo in Kconfig help text (Nokia 700 - 770).
 
   For earlier history, see:
   http://marc.info/?l=linux-kernelm=135325660302114w=2
 
  drivers/watchdog/Kconfig|   12 +++
  drivers/watchdog/Makefile   |1 +
  drivers/watchdog/retu_wdt.c |  178 
 +++
  3 files changed, 191 insertions(+)
  create mode 100644 drivers/watchdog/retu_wdt.c
 
 diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
 index 7f809fd..75afc76 100644
 --- a/drivers/watchdog/Kconfig
 +++ b/drivers/watchdog/Kconfig
 @@ -364,6 +364,18 @@ config IMX2_WDT
 To compile this driver as a module, choose M here: the
 module will be called imx2_wdt.
  
 +config RETU_WATCHDOG
 + tristate Retu watchdog
 + depends on MFD_RETU
 + select WATCHDOG_CORE
 + help
 +   Retu watchdog driver for Nokia Internet Tablets (770, N800,
 +   N810). At least on N800 the watchdog cannot be disabled, so
 +   this driver is essential and you should enable it.
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called retu_wdt.
 +
  # AVR32 Architecture
  
  config AT32AP700X_WDT
 diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
 index 97bbdb3a..157bc61 100644
 --- a/drivers/watchdog/Makefile
 +++ b/drivers/watchdog/Makefile
 @@ -52,6 +52,7 @@ obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o
  obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
  obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
  obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
 +obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o
  
  # AVR32 Architecture
  obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
 diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c
 new file mode 100644
 index 000..f53615d
 --- /dev/null
 +++ b/drivers/watchdog/retu_wdt.c
 @@ -0,0 +1,178 @@
 +/*
 + * Retu watchdog driver
 + *
 + * Copyright (C) 2004, 2005 Nokia Corporation
 + *
 + * Based on code written by Amit Kucheria and Michael Buesch.
 + * Rewritten by Aaro Koskinen.
 + *
 + * This file is subject to the terms and conditions of the GNU General
 + * Public License. See the file COPYING in the main directory of this
 + * archive for more details.
 + *
 + * 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.
 + */
 +
 +#include linux/init.h
 +#include linux/slab.h
 +#include linux/errno.h
 +#include linux/device.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/mfd/retu.h
 +#include linux/watchdog.h
 +#include linux/platform_device.h
 +
 +/* Watchdog timer values in seconds */
 +#define RETU_WDT_MAX_TIMER   63
 +
 +struct retu_wdt_dev {
 + struct retu_dev *rdev;
 + struct device   *dev;
 + struct delayed_work ping_work;
 +};
 +
 +/*
 + * Since Retu watchdog cannot be disabled in hardware, we must kick it
 + * with a timer until userspace watchdog software takes over. If
 + * CONFIG_WATCHDOG_NOWAYOUT is set, we never start the feeding.
 + */
 +static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev)
 +{
 + retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
 + schedule_delayed_work(wdev-ping_work,
 + round_jiffies_relative(RETU_WDT_MAX_TIMER * HZ / 2));
 +}
 +
 +static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev)
 +{
 + retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
 + cancel_delayed_work_sync(wdev-ping_work);
 +}
 +
 +static void retu_wdt_ping_work(struct work_struct *work)
 +{
 + struct retu_wdt_dev *wdev = container_of(to_delayed_work(work),
 + struct retu_wdt_dev, ping_work);
 + retu_wdt_ping_enable(wdev);
 +}
 +
 +static int retu_wdt_start(struct watchdog_device *wdog)
 +{
 + struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
 +
 + retu_wdt_ping_disable(wdev);
 +
 + return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
 +}
 +
 +static int retu_wdt_stop(struct watchdog_device *wdog)
 +{
 + struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
 +
 + retu_wdt_ping_enable(wdev);
 +
 + return 0;
 +}
 +
 +static int retu_wdt_ping(struct watchdog_device *wdog)
 +{
 + struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
 +
 + return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout

[PATCH] MIPS: fix 64-bit kernel build

2013-01-21 Thread Aaro Koskinen
Commit d3ce88431892b703b04769566338a89eda6b0477 (MIPS: Fix modpost
error in modules attepting to use virt_addr_valid()) in 3.8-rc3 broke
the 64-bit MIPS build:

  LD  init/built-in.o
kernel/built-in.o: In function `memory_bm_free':
snapshot.c:(.text+0x3c76c): undefined reference to `__virt_addr_valid'
snapshot.c:(.text+0x3c800): undefined reference to `__virt_addr_valid'
kernel/built-in.o: In function `snapshot_write_next':
(.text+0x3e094): undefined reference to `__virt_addr_valid'
kernel/built-in.o: In function `snapshot_write_next':
(.text+0x3e468): undefined reference to `__virt_addr_valid'

Fix by providing __virt_addr_valid also when CONFIG_32BIT is not set.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/mm/Makefile  |6 +++---
 arch/mips/mm/ioremap.c |4 
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
index 90ceb963..cbfec8c 100644
--- a/arch/mips/mm/Makefile
+++ b/arch/mips/mm/Makefile
@@ -3,10 +3,10 @@
 #
 
 obj-y  += cache.o dma-default.o extable.o fault.o \
-  gup.o init.o mmap.o page.o page-funcs.o \
-  tlbex.o tlbex-fault.o uasm.o
+  gup.o init.o ioremap.o mmap.o page.o \
+  page-funcs.o tlbex.o tlbex-fault.o uasm.o
 
-obj-$(CONFIG_32BIT)+= ioremap.o pgtable-32.o
+obj-$(CONFIG_32BIT)+= pgtable-32.o
 obj-$(CONFIG_64BIT)+= pgtable-64.o
 obj-$(CONFIG_HIGHMEM)  += highmem.o
 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
diff --git a/arch/mips/mm/ioremap.c b/arch/mips/mm/ioremap.c
index 7657fd2..a7a14e3 100644
--- a/arch/mips/mm/ioremap.c
+++ b/arch/mips/mm/ioremap.c
@@ -16,6 +16,8 @@
 #include asm/io.h
 #include asm/tlbflush.h
 
+#ifdef CONFIG_32BIT
+
 static inline void remap_area_pte(pte_t * pte, unsigned long address,
phys_t size, phys_t phys_addr, unsigned long flags)
 {
@@ -191,6 +193,8 @@ void __iounmap(const volatile void __iomem *addr)
 EXPORT_SYMBOL(__ioremap);
 EXPORT_SYMBOL(__iounmap);
 
+#endif /* CONFIG_32BIT */
+
 int __virt_addr_valid(const volatile void *kaddr)
 {
return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/11] ARM: samsung: fix assembly syntax for new gas

2013-02-16 Thread Aaro Koskinen
Hi,

On Thu, Feb 14, 2013 at 02:49:18PM +0100, Arnd Bergmann wrote:
 Recent assembler versions complain about extraneous
 whitespace inside [] brackets. This fixes all of
 these instances for the samsung platforms. We should
 backport this to all kernels that might need to
 be built with new binutils.

Which binutils version is this?

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ADP1653 board code for Nokia RX-51

2013-02-17 Thread Aaro Koskinen
Hi,

On Sun, Feb 17, 2013 at 04:16:49PM +0100, Pali Rohár wrote:
 I'm sending ADP1653 flash torch board code for Nokia RX-51. Kernel
 driver ADP1653 is already in upstream kernel. Board code was extracted
 from this big camera meego patch:
 
 https://api.pub.meego.com/public/source/CE:Adaptation:N900/kernel-adaptation-n900/linux-2.6-Camera-for-Meego-N900-Adaptation-kernel-2.6.37-patch.patch

You need to sign-off the patch.

 --- /dev/null
 +++ b/arch/arm/mach-omap2/board-rx51-camera.c

I'm not sure if adding a new file is sensible. There are already 3 board
files for RX-51, which I think is overkill.

 @@ -0,0 +1,177 @@
 +/*
 + * arch/arm/mach-omap2/board-rx51-camera.c
 + *
 + * Copyright (C) 2008 Nokia Corporation
 + *
 + * Contact: Sakari Ailus sakari.ai...@nokia.com
 + *  Tuukka Toivonen tuukka.o.toivo...@nokia.com

You should put these people to CC... Just to see if the addresses are
still valid (which I doubt).

 +static int __init rx51_adp1653_init(void)
 +{
 + int err;
 +
 + err = gpio_request(ADP1653_GPIO_ENABLE, adp1653 enable);
 + if (err) {
 + printk(KERN_ERR ADP1653_NAME
 + Failed to request EN gpio\n);
 + err = -ENODEV;
 + goto err_omap_request_gpio;
 + }
 +
 + err = gpio_request(ADP1653_GPIO_INT, adp1653 interrupt);
 + if (err) {
 + printk(KERN_ERR ADP1653_NAME  Failed to request IRQ gpio\n);
 + err = -ENODEV;
 + goto err_omap_request_gpio_2;
 + }
 +
 + err = gpio_request(ADP1653_GPIO_STROBE, adp1653 strobe);
 + if (err) {
 + printk(KERN_ERR ADP1653_NAME
 + Failed to request STROBE gpio\n);
 + err = -ENODEV;
 + goto err_omap_request_gpio_3;
 + }
 +
 + gpio_direction_output(ADP1653_GPIO_ENABLE, 0);
 + gpio_direction_input(ADP1653_GPIO_INT);
 + gpio_direction_output(ADP1653_GPIO_STROBE, 0);

gpio_request_array() should be used.

 +void __init rx51_camera_init(void)
 +{
 + if (rx51_camera_hw_init()) {
 + printk(KERN_WARNING %s: Unable to initialize camera\n,
 +__func__);
 + return;
 + }
 +
 + if (omap3_init_camera(rx51_isp_platform_data)  0)
 + printk(KERN_WARNING %s: Unable to register camera platform 
 +device\n, __func__);

pr_warn() should be used.

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] MIPS: loongson: fix random early boot hang

2013-02-18 Thread Aaro Koskinen
Some Loongson boards (e.g. Lemote FuLoong mini-PC) use ISA/southbridge
device (CS5536 general purpose timer) for the timer interrupt. It starts
running early and is already enabled during the PCI configuration,
during which there is a small window in pci_read_base() when the register
access is temporarily disabled. If the timer interrupts at this point,
the system will hang. Fix this by adding a fixup that keeps the register
access always enabled.

The hang the patch fixes usually looks like this:

[0.844000] pci :00:0e.0: [1022:2090] type 00 class 0x060100
[0.848000] pci :00:0e.0: reg 10: [io  0xb410-0xb417]
[0.852000] pci :00:0e.0: reg 14: [io  0xb000-0xb0ff]
[0.856000] pci :00:0e.0: reg 18: [io  0xb380-0xb3bf]
[   28.14] BUG: soft lockup - CPU#0 stuck for 23s! [swapper:1]
[   28.14] Modules linked in:
[   28.14] irq event stamp: 37965
[   28.14] hardirqs last  enabled at (37964): [80204c0c] 
restore_partial+0x6c/0x13c
[   28.14] hardirqs last disabled at (37965): [80204f8c] 
handle_int+0x144/0x15c
[   28.14] softirqs last  enabled at (24316): [802381f4] 
__do_softirq+0x1cc/0x258
[   28.14] softirqs last disabled at (24327): [80238420] 
do_softirq+0xc8/0xd0
[   28.14] Cpu 0
[   28.14] $ 0   :  140044e1 98009f09 
0001
[   28.14] $ 4   : 98009f09  0100 
03b7fff87fbde011
[   28.14] $ 8   : 812b1928 0001e000 04387fbde011 
fff87fbde011
[   28.14] $12   : 000e 807a 0698 

[   28.14] $16   : 0002 81055e20 80786810 

[   28.14] $20   : 000a 807bc244 807e6350 
8077
[   28.14] $24   : 0d80 fffedbe0
[   28.14] $28   : 98009f07c000 98009f07fa10 8105 
802380f8
[   28.14] Hi: 00d0fc00
[   28.14] Lo: 00f82b40
[   28.14] epc   : 8023810c __do_softirq+0xe4/0x258
[   28.14] Not tainted
[   28.14] ra: 802380f8 __do_softirq+0xd0/0x258
[   28.14] Status: 140044e3KX SX UX KERNEL EXL IE
[   28.14] Cause : 10008400
[   28.14] PrId  : 6303 (ICT Loongson-2)

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/loongson/common/cs5536/cs5536_isa.c |   14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/mips/loongson/common/cs5536/cs5536_isa.c 
b/arch/mips/loongson/common/cs5536/cs5536_isa.c
index 4d9f65a..7b31ea7 100644
--- a/arch/mips/loongson/common/cs5536/cs5536_isa.c
+++ b/arch/mips/loongson/common/cs5536/cs5536_isa.c
@@ -13,6 +13,7 @@
  * option) any later version.
  */
 
+#include linux/pci.h
 #include cs5536/cs5536.h
 #include cs5536/cs5536_pci.h
 
@@ -314,3 +315,16 @@ u32 pci_isa_read_reg(int reg)
 
return conf_data;
 }
+
+/*
+ * The mfgpt timer interrupt is running early, so we must keep the south bridge
+ * mmio always enabled. Otherwise we may race with the PCI configuration which
+ * may temporarily disable it. When that happens and the timer interrupt fires,
+ * we are not able to clear it and the system will hang.
+ */
+static void cs5536_isa_mmio_always_on(struct pci_dev *dev)
+{
+   dev-mmio_always_on = 1;
+}
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA,
+   PCI_CLASS_BRIDGE_ISA, 8, cs5536_isa_mmio_always_on);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: bug: keep_bootcon and early printk together can lead to (invisible) kernel panic

2013-02-21 Thread Aaro Koskinen
On Thu, Feb 21, 2013 at 03:37:17PM +0100, Patrik, Kluba wrote:
 I had a silent lockup on one of our embedded system under development.
 It was not easy to track it down, so here's what I discovered, in case
 somebody runs into similar trouble.
 Using 'keep_bootcon' command line parameter, and enabling early printk
 can lead to a kernel panic. At least on MIPS, it does. The problem is
 that in arch/mips/kernel/early_printk.c everything is declared as
 __init and __initdata, so they are being freed, when the kernel
 frees .init.* sections. If 'keep_bootcon' is given, the early console
 does not get unregistered, and the entry in the console_drivers list
 can point (will, believe me) to garbage data. It's up to you to imagine
 the effects...

I also ran into this recently, this should fix it:

http://marc.info/?l=linux-kernelm=136062078931024w=2

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] watchdog: omap_wdt: convert to new watchdog core

2012-09-07 Thread Aaro Koskinen
On Fri, Sep 07, 2012 at 04:31:07PM +0300, Jarkko Nikula wrote:
 On Tue, Sep 04, 2012 at 05:41:24PM +0300, Aaro Koskinen wrote:
  Convert omap_wdt to new watchdog core. On OMAP boards, there are usually
  multiple watchdogs. Since the new watchdog core supports multiple
  watchdogs, all watchdog drivers used on OMAP should be converted.
  
  The legacy watchdog device node is still created, so this should not
  break existing users.
  
  Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
  ---
   drivers/watchdog/Kconfig|1 +
   drivers/watchdog/omap_wdt.c |  268 
  ++-
   2 files changed, 115 insertions(+), 154 deletions(-)
  
 Am I missing some extra patch but this causes a crash on top of v3.6-rc4
 commit eeea3ac?
 
 Crash happens in omap_wdt.c:99 on Nokia N9.

Thanks for the report! I'll look into this and test with other
Nokia boards. I tested the patch only with N800 and v3.6-rc4
(4cbe5a555fa58a79b6ecbb6c531b8bab0650778d) and did not see any issues
with normal use cases (boot, watchdog open, feeding, watchdog close).

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] watchdog: omap_wdt: convert to new watchdog core

2012-09-08 Thread Aaro Koskinen
Convert omap_wdt to new watchdog core. On OMAP boards, there are usually
multiple watchdogs. Since the new watchdog core supports multiple
watchdogs, all watchdog drivers used on OMAP should be converted.

The legacy watchdog device node is still created, so this should not
break existing users.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---

v2: Fix a bug in the first version of the patch: __omap_wdt_disable()
in probe was mistakenly moved outside PM runtime calls. This caused a
crash as device was probably accessed with some clocks off. Thanks to
Jarkko Nikula jarkko.nik...@bitmer.com for reporting this.

 drivers/watchdog/Kconfig|1 +
 drivers/watchdog/omap_wdt.c |  266 ++-
 2 files changed, 114 insertions(+), 153 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 0526c7a..212b566 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -232,6 +232,7 @@ config EP93XX_WATCHDOG
 config OMAP_WATCHDOG
tristate OMAP Watchdog
depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS
+   select WATCHDOG_CORE
help
  Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog. 
 Say 'Y'
  here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 
watchdog timer.
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index fceec4f..1636f2c 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -31,18 +31,14 @@
 #include linux/module.h
 #include linux/types.h
 #include linux/kernel.h
-#include linux/fs.h
 #include linux/mm.h
-#include linux/miscdevice.h
 #include linux/watchdog.h
 #include linux/reboot.h
 #include linux/init.h
 #include linux/err.h
 #include linux/platform_device.h
 #include linux/moduleparam.h
-#include linux/bitops.h
 #include linux/io.h
-#include linux/uaccess.h
 #include linux/slab.h
 #include linux/pm_runtime.h
 #include mach/hardware.h
@@ -50,24 +46,20 @@
 
 #include omap_wdt.h
 
-static struct platform_device *omap_wdt_dev;
-
 static unsigned timer_margin;
 module_param(timer_margin, uint, 0);
 MODULE_PARM_DESC(timer_margin, initial watchdog timeout (in seconds));
 
-static unsigned int wdt_trgr_pattern = 0x1234;
-static DEFINE_SPINLOCK(wdt_lock);
-
 struct omap_wdt_dev {
void __iomem*base;  /* physical */
struct device   *dev;
-   int omap_wdt_users;
+   boolomap_wdt_users;
struct resource *mem;
-   struct miscdevice omap_wdt_miscdev;
+   int wdt_trgr_pattern;
+   struct mutexlock;   /* to avoid races with PM */
 };
 
-static void omap_wdt_ping(struct omap_wdt_dev *wdev)
+static void __omap_wdt_ping(struct omap_wdt_dev *wdev)
 {
void __iomem*base = wdev-base;
 
@@ -75,8 +67,8 @@ static void omap_wdt_ping(struct omap_wdt_dev *wdev)
while ((__raw_readl(base + OMAP_WATCHDOG_WPS))  0x08)
cpu_relax();
 
-   wdt_trgr_pattern = ~wdt_trgr_pattern;
-   __raw_writel(wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
+   wdev-wdt_trgr_pattern = ~wdev-wdt_trgr_pattern;
+   __raw_writel(wdev-wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
 
/* wait for posted write to complete */
while ((__raw_readl(base + OMAP_WATCHDOG_WPS))  0x08)
@@ -84,7 +76,7 @@ static void omap_wdt_ping(struct omap_wdt_dev *wdev)
/* reloaded WCRR from WLDR */
 }
 
-static void omap_wdt_enable(struct omap_wdt_dev *wdev)
+static void __omap_wdt_enable(struct omap_wdt_dev *wdev)
 {
void __iomem *base = wdev-base;
 
@@ -98,7 +90,7 @@ static void omap_wdt_enable(struct omap_wdt_dev *wdev)
cpu_relax();
 }
 
-static void omap_wdt_disable(struct omap_wdt_dev *wdev)
+static void __omap_wdt_disable(struct omap_wdt_dev *wdev)
 {
void __iomem *base = wdev-base;
 
@@ -112,18 +104,10 @@ static void omap_wdt_disable(struct omap_wdt_dev *wdev)
cpu_relax();
 }
 
-static void omap_wdt_adjust_timeout(unsigned new_timeout)
-{
-   if (new_timeout  TIMER_MARGIN_MIN)
-   new_timeout = TIMER_MARGIN_DEFAULT;
-   if (new_timeout  TIMER_MARGIN_MAX)
-   new_timeout = TIMER_MARGIN_MAX;
-   timer_margin = new_timeout;
-}
-
-static void omap_wdt_set_timeout(struct omap_wdt_dev *wdev)
+static void __omap_wdt_set_timeout(struct omap_wdt_dev *wdev,
+  unsigned int timeout)
 {
-   u32 pre_margin = GET_WLDR_VAL(timer_margin);
+   u32 pre_margin = GET_WLDR_VAL(timeout);
void __iomem *base = wdev-base;
 
/* just count up at 32 KHz */
@@ -135,16 +119,14 @@ static void omap_wdt_set_timeout(struct omap_wdt_dev 
*wdev)
cpu_relax();
 }
 
-/*
- * Allow only one task to hold it open
- */
-static int omap_wdt_open(struct inode *inode, struct file *file)
+static int omap_wdt_start(struct watchdog_device *wdog)
 {
-   struct omap_wdt_dev *wdev

Re: [PATCH 1/4] i2c: introduce i2c-cbus driver

2012-09-19 Thread Aaro Koskinen
On Fri, Sep 14, 2012 at 12:08:06PM +0200, Wolfram Sang wrote:
 On Mon, Sep 03, 2012 at 11:23:22PM +0300, Aaro Koskinen wrote:
  Add i2c driver to enable access to devices behind CBUS on Nokia Internet
  Tablets.
  
  The patch also adds CBUS I2C configuration for N8x0 which is one of the
  users of this driver.
  
  Cc: linux-...@vger.kernel.org
  Acked-by: Felipe Balbi ba...@ti.com
  Acked-by: Tony Lindgren t...@atomide.com
  Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
 
 OK, I found the short paragrahp about CBUS in the I2C spec, so I2C might
 be an appropriate place. Still, before deciding if it should rather be
 in the core directory, I still have a few questions.

Thanks for your feedback. I will fix up the incorrect comments, and do
other improvements (e.g. use devm_* stuff) in the next version.

The questions about delays and bit counts are very valid, but it's
difficult to do anything with them due to lack of documentation and HW on
which to test - I have Nokia tablets to test the driver, and the driver
is very reliable, but I do not know of any other HW with CBUS. :-/

A.

 Also, does anybody know of a generic bit-banging implementation in the
 kernel which could be used here?
 
 Jean: I'd appreciate your general opinion here, too.
 
  diff --git a/drivers/i2c/busses/i2c-cbus.c b/drivers/i2c/busses/i2c-cbus.c
  new file mode 100644
  index 000..bacf2a9
  --- /dev/null
  +++ b/drivers/i2c/busses/i2c-cbus.c
  @@ -0,0 +1,369 @@
  +/*
  + * CBUS I2C driver for Nokia Internet Tablets.
  + *
  + * Copyright (C) 2004-2010 Nokia Corporation
  + *
  + * Based on code written by Juha Yrjölä, David Weinehall, Mikko Ylinen and
  + * Felipe Balbi. Converted to I2C driver by Aaro Koskinen.
  + *
  + * This file is subject to the terms and conditions of the GNU General
  + * Public License. See the file COPYING in the main directory of this
  + * archive for more details.
  + *
  + * 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.
  + */
  +
  +#include linux/io.h
  +#include linux/i2c.h
  +#include linux/gpio.h
  +#include linux/init.h
  +#include linux/slab.h
  +#include linux/delay.h
  +#include linux/errno.h
  +#include linux/kernel.h
  +#include linux/module.h
  +#include linux/of_gpio.h
  +#include linux/i2c-cbus.h
  +#include linux/interrupt.h
  +#include linux/platform_device.h
  +
  +struct cbus_host {
  +   /* host lock */
  +   spinlock_t  lock;
  +
  +   struct device   *dev;
  +
  +   int clk_gpio;
  +   int dat_gpio;
  +   int sel_gpio;
  +};
  +
  +/**
  + * cbus_send_bit - sends one bit over the bus
  + * @host: the host we're using
  + * @bit: one bit of information to send
  + * @input: whether to set data pin as input after sending
  + */
  +static int cbus_send_bit(struct cbus_host *host, unsigned bit,
  +   unsigned input)
  +{
  +   int ret = 0;
  +
  +   gpio_set_value(host-dat_gpio, bit ? 1 : 0);
  +   gpio_set_value(host-clk_gpio, 1);
  +
  +   /* The data bit is read on the rising edge of CLK */
 
 This comment doesn't belong to the if-block, or?
 
  +   if (input)
  +   ret = gpio_direction_input(host-dat_gpio);
 
 No minimum delay for the signal to be on the bus?
 
  +
  +   gpio_set_value(host-clk_gpio, 0);
  +
  +   return ret;
  +}
  +
  +/**
  + * cbus_send_data - sends @len amount of data over the bus
  + * @host: the host we're using
  + * @data: the data to send
  + * @len: size of the transfer
  + * @input: whether to set data pin as input after sending
  + */
  +static int cbus_send_data(struct cbus_host *host, unsigned data, unsigned 
  len,
  +   unsigned input)
  +{
  +   int ret = 0;
  +   int i;
  +
  +   for (i = len; i  0; i--) {
  +   ret = cbus_send_bit(host, data  (1  (i - 1)),
  +   input  (i == 1));
  +   if (ret  0)
  +   goto out;
  +   }
  +
  +out:
  +   return ret;
  +}
  +
  +/**
  + * cbus_receive_bit - receives one bit from the bus
  + * @host: the host we're using
  + */
  +static int cbus_receive_bit(struct cbus_host *host)
  +{
  +   int ret;
  +
  +   gpio_set_value(host-clk_gpio, 1);
 
 No delays to ensure the signal has stabilized?
 
  +   ret = gpio_get_value(host-dat_gpio);
  +   if (ret  0)
  +   goto out;
  +   gpio_set_value(host-clk_gpio, 0);
  +
  +out:
  +   return ret;
  +}
  +
  +/**
  + * cbus_receive_word - receives 16-bit word from the bus
  + * @host: the host we're using
  + */
  +static int cbus_receive_word(struct cbus_host *host)
  +{
  +   int ret = 0;
  +   int i;
  +
  +   for (i = 16; i  0; i--) {
  +   int bit = cbus_receive_bit(host);
  +
  +   if (bit  0)
  +   goto out;
  +
  +   if (bit)
  +   ret |= 1  (i - 1);
  +   }
  +
  +out

Re: [PATCH 2/4] mfd: introduce retu-mfd driver

2012-09-19 Thread Aaro Koskinen
Hi,

On Wed, Sep 19, 2012 at 06:02:30PM +0200, Samuel Ortiz wrote:
 On Mon, Sep 03, 2012 at 11:23:23PM +0300, Aaro Koskinen wrote:
  Retu is a multi-function device found on Nokia Internet Tablets
  implementing at least watchdog, RTC, headset detection and power button
  functionality.
  
  This patch implements minimum functionality providing register access,
  IRQ handling and power off functions.
  
  Cc: sa...@linux.intel.com
  Acked-by: Tony Lindgren t...@atomide.com
  Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
  ---
   drivers/mfd/Kconfig  |8 +
   drivers/mfd/Makefile |1 +
   drivers/mfd/retu-mfd.c   |  347 
  ++
   include/linux/mfd/retu.h |   22 +++
   4 files changed, 378 insertions(+), 0 deletions(-)
   create mode 100644 drivers/mfd/retu-mfd.c
   create mode 100644 include/linux/mfd/retu.h
 Now with the IRQ chip code, using the regmap APIs would be even more
 benefitial.

Thanks for feedback, I'll look into this.

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] i2c: introduce i2c-cbus driver

2012-09-13 Thread Aaro Koskinen
On Thu, Sep 13, 2012 at 12:53:09PM +0200, Wolfram Sang wrote:
 On Mon, Sep 03, 2012 at 11:23:22PM +0300, Aaro Koskinen wrote:
  Add i2c driver to enable access to devices behind CBUS on Nokia Internet
  Tablets.
  
  The patch also adds CBUS I2C configuration for N8x0 which is one of the
  users of this driver.
  
  Cc: linux-...@vger.kernel.org
  Acked-by: Felipe Balbi ba...@ti.com
  Acked-by: Tony Lindgren t...@atomide.com
  Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
 
 My main question is: what is CBUS? It doesn't look like an I2C/SMBUS
 host controller, but some bit-banging protocol? As such, it shouldn't go
 to i2c/busses/. And the protocol doesn't look much like I2C, neither.
 There is no ACK/NACK/START/STOP, so I wonder if it should be in i2c
 after all...

It's some legacy 3-wire bus protocol. Not much info is available,
there's some references to CBUS in i2c spec, so I thought it wouldn't
be a completly wrong place for it...

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] i2c: introduce i2c-cbus driver

2012-09-03 Thread Aaro Koskinen
Add i2c driver to enable access to devices behind CBUS on Nokia Internet
Tablets.

The patch also adds CBUS I2C configuration for N8x0 which is one of the
users of this driver.

Cc: linux-...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/arm/mach-omap2/board-n8x0.c |   42 +
 drivers/i2c/busses/Kconfig   |   10 +
 drivers/i2c/busses/Makefile  |1 +
 drivers/i2c/busses/i2c-cbus.c|  369 ++
 include/linux/i2c-cbus.h |   27 +++
 5 files changed, 449 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-cbus.c
 create mode 100644 include/linux/i2c-cbus.h

diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index 677357f..2495f2d 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -16,8 +16,10 @@
 #include linux/gpio.h
 #include linux/init.h
 #include linux/io.h
+#include linux/irq.h
 #include linux/stddef.h
 #include linux/i2c.h
+#include linux/i2c-cbus.h
 #include linux/spi/spi.h
 #include linux/usb/musb.h
 #include sound/tlv320aic3x.h
@@ -42,6 +44,45 @@
 #define TUSB6010_GPIO_ENABLE   0
 #define TUSB6010_DMACHAN   0x3f
 
+#if defined(CONFIG_I2C_CBUS) || defined(CONFIG_I2C_CBUS_MODULE)
+static struct i2c_cbus_platform_data n8x0_cbus_data = {
+   .clk_gpio = 66,
+   .dat_gpio = 65,
+   .sel_gpio = 64,
+};
+
+static struct platform_device n8x0_cbus_device = {
+   .name   = i2c-cbus,
+   .id = 3,
+   .dev= {
+   .platform_data = n8x0_cbus_data,
+   },
+};
+
+static struct i2c_board_info n8x0_i2c_board_info_3[] __initdata = {
+   {
+   I2C_BOARD_INFO(retu-mfd, 0x01),
+   },
+};
+
+static void __init n8x0_cbus_init(void)
+{
+   const int retu_irq_gpio = 108;
+
+   if (gpio_request_one(retu_irq_gpio, GPIOF_IN, Retu IRQ))
+   return;
+   irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
+   n8x0_i2c_board_info_3[0].irq = gpio_to_irq(retu_irq_gpio);
+   i2c_register_board_info(3, n8x0_i2c_board_info_3,
+   ARRAY_SIZE(n8x0_i2c_board_info_3));
+   platform_device_register(n8x0_cbus_device);
+}
+#else /* CONFIG_I2C_CBUS */
+static void __init n8x0_cbus_init(void)
+{
+}
+#endif /* CONFIG_I2C_CBUS */
+
 #if defined(CONFIG_USB_MUSB_TUSB6010) || 
defined(CONFIG_USB_MUSB_TUSB6010_MODULE)
 /*
  * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
@@ -681,6 +722,7 @@ static void __init n8x0_init_machine(void)
gpmc_onenand_init(board_onenand_data);
n8x0_mmc_init();
n8x0_usb_init();
+   n8x0_cbus_init();
 }
 
 MACHINE_START(NOKIA_N800, Nokia N800)
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index b4aaa1b..184ef43 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -331,6 +331,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
help
  The unit of the TWI clock is kHz.
 
+config I2C_CBUS
+   tristate CBUS I2C driver
+   depends on GENERIC_GPIO
+   help
+ Support for CBUS access using I2C API. Mostly relevant for Nokia
+ Internet Tablets (770, N800 and N810).
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-cbus.
+
 config I2C_CPM
tristate Freescale CPM1 or CPM2 (MPC8xx/826x)
depends on (CPM1 || CPM2)  OF_I2C
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index ce3c2be..44dbfd1 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_I2C_POWERMAC)+= i2c-powermac.o
 obj-$(CONFIG_I2C_AT91) += i2c-at91.o
 obj-$(CONFIG_I2C_AU1550)   += i2c-au1550.o
 obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
+obj-$(CONFIG_I2C_CBUS) += i2c-cbus.o
 obj-$(CONFIG_I2C_CPM)  += i2c-cpm.o
 obj-$(CONFIG_I2C_DAVINCI)  += i2c-davinci.o
 obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM)  += i2c-designware-platform.o
diff --git a/drivers/i2c/busses/i2c-cbus.c b/drivers/i2c/busses/i2c-cbus.c
new file mode 100644
index 000..bacf2a9
--- /dev/null
+++ b/drivers/i2c/busses/i2c-cbus.c
@@ -0,0 +1,369 @@
+/*
+ * CBUS I2C driver for Nokia Internet Tablets.
+ *
+ * Copyright (C) 2004-2010 Nokia Corporation
+ *
+ * Based on code written by Juha Yrjölä, David Weinehall, Mikko Ylinen and
+ * Felipe Balbi. Converted to I2C driver by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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

[PATCH 4/4] input: misc: introduce retu-pwrbutton

2012-09-03 Thread Aaro Koskinen
Add Retu power button driver.

Cc: linux-in...@vger.kernel.org
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/input/misc/Kconfig  |   10 +++
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/retu-pwrbutton.c |  127 +++
 3 files changed, 138 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/retu-pwrbutton.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7c0f1ec..e5be189 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -367,6 +367,16 @@ config INPUT_CM109
  To compile this driver as a module, choose M here: the module will be
  called cm109.
 
+config INPUT_RETU_PWRBUTTON
+   tristate Retu Power button Driver
+   depends on MFD_RETU
+   help
+ Say Y here if you want to enable power key reporting via the
+ Retu chips found in Nokia Internet Tablets (770, N800, N810).
+
+ To compile this driver as a module, choose M here. The module will
+ be called retu-pwrbutton.
+
 config INPUT_TWL4030_PWRBUTTON
tristate TWL4030 Power button Driver
depends on TWL4030_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 83fe6f5..4fbee0d 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)   += pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_POWERMATE)  += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)   += rb532_button.o
+obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SPARCSPKR)  += sparcspkr.o
diff --git a/drivers/input/misc/retu-pwrbutton.c 
b/drivers/input/misc/retu-pwrbutton.c
new file mode 100644
index 000..f802d4d
--- /dev/null
+++ b/drivers/input/misc/retu-pwrbutton.c
@@ -0,0 +1,127 @@
+/*
+ * Retu power button driver.
+ *
+ * Copyright (C) 2004-2010 Nokia Corporation
+ *
+ * Original code written by Ari Saastamoinen, Juha Yrjölä and Felipe Balbi.
+ * Converted to use to use Retu MFD driver by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/irq.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/input.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+
+#define RETU_STATUS_PWRONX (1  5)
+
+struct retu_pwrbutton {
+   struct input_dev*idev;
+   struct retu_dev *rdev;
+   struct device   *dev;
+   boolpressed;
+   int irq;
+};
+
+static irqreturn_t retu_pwrbutton_irq(int irq, void *_pwr)
+{
+   struct retu_pwrbutton *pwr = _pwr;
+   bool state;
+
+   state = !(retu_read(pwr-rdev, RETU_REG_STATUS)  RETU_STATUS_PWRONX);
+
+   if (pwr-pressed != state) {
+   input_report_key(pwr-idev, KEY_POWER, state);
+   input_sync(pwr-idev);
+   pwr-pressed = state;
+   }
+
+   return IRQ_HANDLED;
+}
+
+static int __devinit retu_pwrbutton_probe(struct platform_device *pdev)
+{
+   struct retu_dev *rdev = dev_get_drvdata(pdev-dev.parent);
+   struct retu_pwrbutton *pwr;
+   int ret;
+
+   pwr = kzalloc(sizeof(*pwr), GFP_KERNEL);
+   if (!pwr)
+   return -ENOMEM;
+
+   pwr-rdev = rdev;
+   pwr-dev  = pdev-dev;
+   pwr-irq  = platform_get_irq(pdev, 0);
+   platform_set_drvdata(pdev, pwr);
+
+   ret = request_threaded_irq(pwr-irq, NULL, retu_pwrbutton_irq, 0,
+  retu-pwrbutton, pwr);
+   if (ret  0)
+   goto error_irq;
+
+   pwr-idev = input_allocate_device();
+   if (!pwr-idev) {
+   ret = -ENOMEM;
+   goto error_input;
+   }
+
+   pwr-idev-evbit[0] = BIT_MASK(EV_KEY);
+   pwr-idev-keybit[BIT_WORD(KEY_POWER)]  = BIT_MASK(KEY_POWER);
+   pwr-idev-name = retu-pwrbutton;
+
+   ret = input_register_device(pwr-idev);
+   if (ret  0)
+   goto error_reg;
+
+   return 0;
+
+error_reg:
+   input_free_device(pwr-idev);
+error_input:
+   free_irq(pwr-irq, pwr);
+error_irq:
+   kfree(pwr);
+   return ret;
+}
+
+static int __devexit retu_pwrbutton_remove(struct platform_device *pdev)
+{
+   struct

[PATCH 2/4] mfd: introduce retu-mfd driver

2012-09-03 Thread Aaro Koskinen
Retu is a multi-function device found on Nokia Internet Tablets
implementing at least watchdog, RTC, headset detection and power button
functionality.

This patch implements minimum functionality providing register access,
IRQ handling and power off functions.

Cc: sa...@linux.intel.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/mfd/Kconfig  |8 +
 drivers/mfd/Makefile |1 +
 drivers/mfd/retu-mfd.c   |  347 ++
 include/linux/mfd/retu.h |   22 +++
 4 files changed, 378 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/retu-mfd.c
 create mode 100644 include/linux/mfd/retu.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b1a1462..7d4ce92 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1003,6 +1003,14 @@ config MFD_PALMAS
  If you say yes here you get support for the Palmas
  series of PMIC chips from Texas Instruments.
 
+config MFD_RETU
+   tristate Support for Retu multi-function device
+   select MFD_CORE
+   depends on I2C
+   help
+ Retu is a multi-function device found on Nokia Internet Tablets
+ (770, N800 and N810).
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 79dd22d..962ec9d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -132,3 +132,4 @@ obj-$(CONFIG_MFD_RC5T583)   += rc5t583.o rc5t583-irq.o
 obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o
 obj-$(CONFIG_MFD_ANATOP)   += anatop-mfd.o
 obj-$(CONFIG_MFD_LM3533)   += lm3533-core.o lm3533-ctrlbank.o
+obj-$(CONFIG_MFD_RETU) += retu-mfd.o
diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c
new file mode 100644
index 000..99059d3
--- /dev/null
+++ b/drivers/mfd/retu-mfd.c
@@ -0,0 +1,347 @@
+/*
+ * Retu MFD driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Juha Yrjölä, David Weinehall and Mikko Ylinen.
+ * Rewritten to MFD/I2C driver by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/err.h
+#include linux/i2c.h
+#include linux/irq.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/mutex.h
+#include linux/module.h
+#include linux/mfd/core.h
+#include linux/mfd/retu.h
+#include linux/interrupt.h
+#include linux/moduleparam.h
+
+/* Registers */
+#define RETU_REG_ASICR 0x00/* ASIC ID and revision */
+#define RETU_REG_ASICR_VILMA   (1  7)/* Bit indicating Vilma */
+#define RETU_REG_IDR   0x01/* Interrupt ID */
+#define RETU_REG_IMR   0x02/* Interrupt mask */
+
+/* Interrupt sources */
+#define RETU_INT_PWR   0   /* Power button */
+
+#define RETU_MAX_IRQ_HANDLERS  16
+
+struct retu_dev {
+   struct device   *dev;
+   struct i2c_client   *i2c;
+   struct mutexmutex;
+
+   struct irq_chip irq_chip;
+   int irq_base;
+   int irq_end;
+   int irq_mask;
+   boolirq_mask_pending;
+};
+
+static struct resource retu_pwrbutton_res[] = {
+   {
+   .name   = retu-pwrbutton,
+   .start  = RETU_INT_PWR,
+   .end= RETU_INT_PWR,
+   .flags = IORESOURCE_IRQ,
+   },
+};
+
+static struct mfd_cell retu_devs[] = {
+   {
+   .name   = retu-wdt
+   },
+   {
+   .name   = retu-pwrbutton,
+   .resources  = retu_pwrbutton_res[0],
+   .num_resources  = ARRAY_SIZE(retu_pwrbutton_res),
+   }
+};
+
+/* Retu device registered for the power off. */
+static struct retu_dev *retu_pm_power_off;
+
+int retu_read(struct retu_dev *rdev, u8 reg)
+{
+   int ret;
+
+   mutex_lock(rdev-mutex);
+   ret = i2c_smbus_read_word_data(rdev-i2c, reg);
+   mutex_unlock(rdev-mutex);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(retu_read);
+
+int retu_write(struct retu_dev *rdev, u8 reg, u16 data)
+{
+   int ret;
+
+   mutex_lock(rdev-mutex);
+   ret = i2c_smbus_write_word_data(rdev-i2c, reg, data);
+   mutex_unlock(rdev-mutex);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(retu_write);
+
+static void retu_power_off(void)
+{
+   struct retu_dev *rdev = retu_pm_power_off;
+   int reg;
+
+   mutex_lock(retu_pm_power_off-mutex);
+
+   /* Ignore power button state */
+   reg = i2c_smbus_read_word_data(rdev-i2c, RETU_REG_CC1

[PATCH 0/4] cbus/retu drivers to mainline

2012-09-03 Thread Aaro Koskinen
This patch set introduces drivers for CBUS access and Retu multifunction
chip found on Nokia Internet Tablets (770, N800, N810). It would be
nice get these patches applied as the functionality of these devices is
severely lacking without Retu. E.g. watchdog support is mandatory at
least on Nokia N800, you cannot currently run the mainline kernel for
longer than ~60 seconds (there is no way to disable the watchdog).

Drivers originate from linux-omap cbus branch and have been cleaned
up/rewritten around i2c and MFD core.

Patches have been tested on top of 3.6-rc4 with Nokia N800 (watchdog
feeding works, power off shuts down the device, power button triggers
IRQs and input events).

Changes since the RFC version
(http://marc.info/?l=linux-omapm=134618967116737w=2):
- added DT support for getting i2c-cbus GPIO pins
- merged n8x0 board file changes into i2c-cbus patch
- corrected typo in Kconfig for MFD_RETU
- added power off functionality to retu-mfd
- added IRQ functionality to retu-mfd
- added power button key driver
- some cleanups

Aaro Koskinen (4):
  i2c: introduce i2c-cbus driver
  mfd: introduce retu-mfd driver
  watchdog: introduce retu_wdt driver
  input: misc: introduce retu-pwrbutton

 arch/arm/mach-omap2/board-n8x0.c|   42 
 drivers/i2c/busses/Kconfig  |   10 +
 drivers/i2c/busses/Makefile |1 +
 drivers/i2c/busses/i2c-cbus.c   |  369 +++
 drivers/input/misc/Kconfig  |   10 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/retu-pwrbutton.c |  127 
 drivers/mfd/Kconfig |8 +
 drivers/mfd/Makefile|1 +
 drivers/mfd/retu-mfd.c  |  347 
 drivers/watchdog/Kconfig|   12 ++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/retu_wdt.c |  188 ++
 include/linux/i2c-cbus.h|   27 +++
 include/linux/mfd/retu.h|   22 ++
 15 files changed, 1166 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-cbus.c
 create mode 100644 drivers/input/misc/retu-pwrbutton.c
 create mode 100644 drivers/mfd/retu-mfd.c
 create mode 100644 drivers/watchdog/retu_wdt.c
 create mode 100644 include/linux/i2c-cbus.h
 create mode 100644 include/linux/mfd/retu.h

-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] watchdog: introduce retu_wdt driver

2012-09-03 Thread Aaro Koskinen
Introduce Retu watchdog driver.

Cc: linux-watch...@vger.kernel.org
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/Kconfig|   12 +++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/retu_wdt.c |  188 +++
 3 files changed, 201 insertions(+), 0 deletions(-)
 create mode 100644 drivers/watchdog/retu_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 53d7571..0526c7a 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -352,6 +352,18 @@ config IMX2_WDT
  To compile this driver as a module, choose M here: the
  module will be called imx2_wdt.
 
+config RETU_WATCHDOG
+   tristate Retu watchdog
+   depends on MFD_RETU
+   select WATCHDOG_CORE
+   help
+ Retu watchdog driver for Nokia Internet Tablets (700, N800,
+ N810). At least on N800 the watchdog cannot be disabled, so
+ this driver is essential and you should enable it.
+
+ To compile this driver as a module, choose M here: the
+ module will be called retu_wdt.
+
 # AVR32 Architecture
 
 config AT32AP700X_WDT
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 572b39b..d2f1c0c 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o
 obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
 obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
 obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
+obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o
 
 # AVR32 Architecture
 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c
new file mode 100644
index 000..da9750a
--- /dev/null
+++ b/drivers/watchdog/retu_wdt.c
@@ -0,0 +1,188 @@
+/*
+ * Retu watchdog driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Amit Kucheria and Michael Buesch. Rewritten
+ * to use Retu MFD driver and new watchdog core by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/device.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/watchdog.h
+#include linux/platform_device.h
+
+/* Watchdog timer values in seconds */
+#define RETU_WDT_MAX_TIMER 63
+
+struct retu_wdt_dev {
+   struct retu_dev *rdev;
+   struct device   *dev;
+   struct delayed_work ping_work;
+};
+
+/*
+ * Since Retu watchdog cannot be disabled in hardware, we must kick it
+ * with a timer until userspace watchdog software takes over. If
+ * CONFIG_WATCHDOG_NOWAYOUT is set, we never start the feeding.
+ */
+static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   schedule_delayed_work(wdev-ping_work,
+   round_jiffies_relative(RETU_WDT_MAX_TIMER * HZ / 2));
+}
+
+static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   cancel_delayed_work_sync(wdev-ping_work);
+}
+
+static void retu_wdt_ping_work(struct work_struct *work)
+{
+   struct retu_wdt_dev *wdev = container_of(to_delayed_work(work),
+   struct retu_wdt_dev, ping_work);
+   retu_wdt_ping_enable(wdev);
+}
+
+static int retu_wdt_start(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_disable(wdev);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_stop(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_enable(wdev);
+
+   return 0;
+}
+
+static int retu_wdt_ping(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_set_timeout(struct watchdog_device *wdog,
+   unsigned int timeout)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   wdog-timeout = timeout;
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static const struct watchdog_info retu_wdt_info = {
+   .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+   .identity = Retu watchdog,
+};
+
+static const

Re: [PATCH 1/4] i2c: introduce i2c-cbus driver

2012-09-04 Thread Aaro Koskinen
On Tue, Sep 04, 2012 at 12:05:07PM +0300, Felipe Balbi wrote:
  + * CBUS I2C driver for Nokia Internet Tablets.

[...]

 this version misses the entire IRQ handling we already had on linux-omap
 tree, so it's quite a regression.

There's no interrupts used in plain CBUS protocol/communication I think?

But Retu MFD supports the GPIO IRQ. I added the code for this set. And
the power button driver (patch 4/4) is using this functionality:

# cat /proc/interrupts
[...]
204: 29  GPIO  retu-mfd
224: 29  RETU  retu-pwrbutton

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] watchdog: omap_wdt: convert to new watchdog core

2012-09-04 Thread Aaro Koskinen
Convert omap_wdt to new watchdog core. On OMAP boards, there are usually
multiple watchdogs. Since the new watchdog core supports multiple
watchdogs, all watchdog drivers used on OMAP should be converted.

The legacy watchdog device node is still created, so this should not
break existing users.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/watchdog/Kconfig|1 +
 drivers/watchdog/omap_wdt.c |  268 ++-
 2 files changed, 115 insertions(+), 154 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 0526c7a..212b566 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -232,6 +232,7 @@ config EP93XX_WATCHDOG
 config OMAP_WATCHDOG
tristate OMAP Watchdog
depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS
+   select WATCHDOG_CORE
help
  Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog. 
 Say 'Y'
  here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 
watchdog timer.
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index fceec4f..a0c23ac 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -31,18 +31,14 @@
 #include linux/module.h
 #include linux/types.h
 #include linux/kernel.h
-#include linux/fs.h
 #include linux/mm.h
-#include linux/miscdevice.h
 #include linux/watchdog.h
 #include linux/reboot.h
 #include linux/init.h
 #include linux/err.h
 #include linux/platform_device.h
 #include linux/moduleparam.h
-#include linux/bitops.h
 #include linux/io.h
-#include linux/uaccess.h
 #include linux/slab.h
 #include linux/pm_runtime.h
 #include mach/hardware.h
@@ -50,24 +46,20 @@
 
 #include omap_wdt.h
 
-static struct platform_device *omap_wdt_dev;
-
 static unsigned timer_margin;
 module_param(timer_margin, uint, 0);
 MODULE_PARM_DESC(timer_margin, initial watchdog timeout (in seconds));
 
-static unsigned int wdt_trgr_pattern = 0x1234;
-static DEFINE_SPINLOCK(wdt_lock);
-
 struct omap_wdt_dev {
void __iomem*base;  /* physical */
struct device   *dev;
-   int omap_wdt_users;
+   boolomap_wdt_users;
struct resource *mem;
-   struct miscdevice omap_wdt_miscdev;
+   int wdt_trgr_pattern;
+   struct mutexlock;   /* to avoid races with PM */
 };
 
-static void omap_wdt_ping(struct omap_wdt_dev *wdev)
+static void __omap_wdt_ping(struct omap_wdt_dev *wdev)
 {
void __iomem*base = wdev-base;
 
@@ -75,8 +67,8 @@ static void omap_wdt_ping(struct omap_wdt_dev *wdev)
while ((__raw_readl(base + OMAP_WATCHDOG_WPS))  0x08)
cpu_relax();
 
-   wdt_trgr_pattern = ~wdt_trgr_pattern;
-   __raw_writel(wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
+   wdev-wdt_trgr_pattern = ~wdev-wdt_trgr_pattern;
+   __raw_writel(wdev-wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
 
/* wait for posted write to complete */
while ((__raw_readl(base + OMAP_WATCHDOG_WPS))  0x08)
@@ -84,7 +76,7 @@ static void omap_wdt_ping(struct omap_wdt_dev *wdev)
/* reloaded WCRR from WLDR */
 }
 
-static void omap_wdt_enable(struct omap_wdt_dev *wdev)
+static void __omap_wdt_enable(struct omap_wdt_dev *wdev)
 {
void __iomem *base = wdev-base;
 
@@ -98,7 +90,7 @@ static void omap_wdt_enable(struct omap_wdt_dev *wdev)
cpu_relax();
 }
 
-static void omap_wdt_disable(struct omap_wdt_dev *wdev)
+static void __omap_wdt_disable(struct omap_wdt_dev *wdev)
 {
void __iomem *base = wdev-base;
 
@@ -112,18 +104,10 @@ static void omap_wdt_disable(struct omap_wdt_dev *wdev)
cpu_relax();
 }
 
-static void omap_wdt_adjust_timeout(unsigned new_timeout)
-{
-   if (new_timeout  TIMER_MARGIN_MIN)
-   new_timeout = TIMER_MARGIN_DEFAULT;
-   if (new_timeout  TIMER_MARGIN_MAX)
-   new_timeout = TIMER_MARGIN_MAX;
-   timer_margin = new_timeout;
-}
-
-static void omap_wdt_set_timeout(struct omap_wdt_dev *wdev)
+static void __omap_wdt_set_timeout(struct omap_wdt_dev *wdev,
+  unsigned int timeout)
 {
-   u32 pre_margin = GET_WLDR_VAL(timer_margin);
+   u32 pre_margin = GET_WLDR_VAL(timeout);
void __iomem *base = wdev-base;
 
/* just count up at 32 KHz */
@@ -135,16 +119,14 @@ static void omap_wdt_set_timeout(struct omap_wdt_dev 
*wdev)
cpu_relax();
 }
 
-/*
- * Allow only one task to hold it open
- */
-static int omap_wdt_open(struct inode *inode, struct file *file)
+static int omap_wdt_start(struct watchdog_device *wdog)
 {
-   struct omap_wdt_dev *wdev = platform_get_drvdata(omap_wdt_dev);
+   struct omap_wdt_dev *wdev = watchdog_get_drvdata(wdog);
void __iomem *base = wdev-base;
 
-   if (test_and_set_bit(1, (unsigned long *)(wdev-omap_wdt_users)))
-   return -EBUSY;
+   mutex_lock(wdev-lock

[PATCH] regulator: twl-regulator: fix up VINTANA1/VINTANA2

2012-08-14 Thread Aaro Koskinen
It seems commit 2098e95ce9bb039ff2e7bf836df358d18a176139 (regulator: twl:
adapt twl-regulator driver to dt) accidentally deleted VINTANA1. Also
the same commit defines VINTANA2 twice with TWL4030_ADJUSTABLE_LDO and
TWL4030_FIXED_LDO. This patch changes the fixed one to be VINTANA1.

I noticed this when auditing my N900 boot logs. I could not notice any
change in device behaviour, though, except that the boot logs are now
like before:

...
[0.282928] VDAC: 1800 mV normal standby
[0.284027] VCSI: 1800 mV normal standby
[0.285400] VINTANA1: 1500 mV normal standby
[0.286865] VINTANA2: 2750 mV normal standby
[0.288208] VINTDIG: 1500 mV normal standby
[0.289978] VSDI_CSI: 1800 mV normal standby
...

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/regulator/twl-regulator.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/twl-regulator.c 
b/drivers/regulator/twl-regulator.c
index 242fe90..8168271 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -1037,7 +1037,7 @@ TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300);
 TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300);
 TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300);
 TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300);
-TWL4030_FIXED_LDO(VINTANA2, 0x3f, 1500, 11, 100, 0x08);
+TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08);
 TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08);
 TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08);
 TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08);
@@ -1117,7 +1117,7 @@ static const struct of_device_id twl_of_match[] 
__devinitconst = {
TWL6025_OF_MATCH(ti,twl6025-ldo6, LDO6),
TWL6025_OF_MATCH(ti,twl6025-ldoln, LDOLN),
TWL6025_OF_MATCH(ti,twl6025-ldousb, LDOUSB),
-   TWLFIXED_OF_MATCH(ti,twl4030-vintana2, VINTANA2),
+   TWLFIXED_OF_MATCH(ti,twl4030-vintana1, VINTANA1),
TWLFIXED_OF_MATCH(ti,twl4030-vintdig, VINTDIG),
TWLFIXED_OF_MATCH(ti,twl4030-vusb1v5, VUSB1V5),
TWLFIXED_OF_MATCH(ti,twl4030-vusb1v8, VUSB1V8),
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 11/31] arm64: IRQ handling

2012-08-14 Thread Aaro Koskinen
Hi,

On Tue, Aug 14, 2012 at 06:52:12PM +0100, Catalin Marinas wrote:
 +void handle_IRQ(unsigned int irq, struct pt_regs *regs)
 +{
 + struct pt_regs *old_regs = set_irq_regs(regs);
 +
 + irq_enter();
 +
 + /*
 +  * Some hardware gives randomly wrong interrupts.  Rather
 +  * than crashing, do something sensible.
 +  */
 + if (unlikely(irq = nr_irqs)) {
 + if (printk_ratelimit())
 + pr_warning(Bad IRQ%u\n, irq);

I guess pr_warn_ratelimited() should be used for new code.

(See include/linux/printk.h, Please don't use printk_ratelimit()...)

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] printk: add option to print cpu id

2012-08-03 Thread Aaro Koskinen
Hi,

On Fri, Aug 03, 2012 at 11:25:37AM -0700, Pandita, Vikram wrote:
  And really: Wasting 1/3 of the 80 character line is too much.
 
 You _WASTE_ 4 chars only if you are interested in this info by
 enabling: CONFIG_PRINTK_CPUID

I guess you waste 4 + 3 chars? You could optimize the length by checking
CONFIG_NR_CPUS?

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: dma-mapping: fix incorrect freeing of atomic allocations

2012-08-05 Thread Aaro Koskinen
Commit e9da6e9905e639b0f842a244bc770b48ad0523e9 (ARM: dma-mapping:
remove custom consistent dma region) changed the way atomic allocations
are handled. However, arm_dma_free() was not modified accordingly, and
as a result freeing of atomic allocations does not work correctly when
CMA is disabled. Memory is leaked and following WARNINGs are seen:

[   57.698911] [ cut here ]
[   57.753518] WARNING: at arch/arm/mm/dma-mapping.c:263 
arm_dma_free+0x88/0xe4()
[   57.811473] trying to free invalid coherent area: e0848000
[   57.867398] Modules linked in: sata_mv(-)
[   57.921373] [c000d270] (unwind_backtrace+0x0/0xf0) from [c0015430] 
(warn_slowpath_common+0x50/0x68)
[   58.033924] [c0015430] (warn_slowpath_common+0x50/0x68) from [c00154dc] 
(warn_slowpath_fmt+0x30/0x40)
[   58.152024] [c00154dc] (warn_slowpath_fmt+0x30/0x40) from [c000dc18] 
(arm_dma_free+0x88/0xe4)
[   58.219592] [c000dc18] (arm_dma_free+0x88/0xe4) from [c008fa30] 
(dma_pool_destroy+0x100/0x148)
[   58.345526] [c008fa30] (dma_pool_destroy+0x100/0x148) from [c019a64c] 
(release_nodes+0x144/0x218)
[   58.475782] [c019a64c] (release_nodes+0x144/0x218) from [c0197e10] 
(__device_release_driver+0x60/0xb8)
[   58.614260] [c0197e10] (__device_release_driver+0x60/0xb8) from 
[c0198608] (driver_detach+0xd8/0xec)
[   58.756527] [c0198608] (driver_detach+0xd8/0xec) from [c0197c54] 
(bus_remove_driver+0x7c/0xc4)
[   58.901648] [c0197c54] (bus_remove_driver+0x7c/0xc4) from [c004bfac] 
(sys_delete_module+0x19c/0x220)
[   59.051447] [c004bfac] (sys_delete_module+0x19c/0x220) from [c0009140] 
(ret_fast_syscall+0x0/0x2c)
[   59.207996] ---[ end trace 0745420412c0325a ]---
[   59.287110] [ cut here ]
[   59.366324] WARNING: at arch/arm/mm/dma-mapping.c:263 
arm_dma_free+0x88/0xe4()
[   59.450511] trying to free invalid coherent area: e0847000
[   59.534357] Modules linked in: sata_mv(-)
[   59.616785] [c000d270] (unwind_backtrace+0x0/0xf0) from [c0015430] 
(warn_slowpath_common+0x50/0x68)
[   59.790030] [c0015430] (warn_slowpath_common+0x50/0x68) from [c00154dc] 
(warn_slowpath_fmt+0x30/0x40)
[   59.972322] [c00154dc] (warn_slowpath_fmt+0x30/0x40) from [c000dc18] 
(arm_dma_free+0x88/0xe4)
[   60.070701] [c000dc18] (arm_dma_free+0x88/0xe4) from [c008fa30] 
(dma_pool_destroy+0x100/0x148)
[   60.256817] [c008fa30] (dma_pool_destroy+0x100/0x148) from [c019a64c] 
(release_nodes+0x144/0x218)
[   60.445201] [c019a64c] (release_nodes+0x144/0x218) from [c0197e10] 
(__device_release_driver+0x60/0xb8)
[   60.634148] [c0197e10] (__device_release_driver+0x60/0xb8) from 
[c0198608] (driver_detach+0xd8/0xec)
[   60.823623] [c0198608] (driver_detach+0xd8/0xec) from [c0197c54] 
(bus_remove_driver+0x7c/0xc4)
[   61.013268] [c0197c54] (bus_remove_driver+0x7c/0xc4) from [c004bfac] 
(sys_delete_module+0x19c/0x220)
[   61.203472] [c004bfac] (sys_delete_module+0x19c/0x220) from [c0009140] 
(ret_fast_syscall+0x0/0x2c)
[   61.393390] ---[ end trace 0745420412c0325b ]---

The patch fixes this.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/arm/mm/dma-mapping.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index c2cdf65..2cc77b7 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -648,12 +648,12 @@ void arm_dma_free(struct device *dev, size_t size, void 
*cpu_addr,
 
if (arch_is_coherent() || nommu()) {
__dma_free_buffer(page, size);
+   } else if (__free_from_pool(cpu_addr, size)) {
+   return;
} else if (!IS_ENABLED(CONFIG_CMA)) {
__dma_free_remap(cpu_addr, size);
__dma_free_buffer(page, size);
} else {
-   if (__free_from_pool(cpu_addr, size))
-   return;
/*
 * Non-atomic allocations cannot be freed with IRQs disabled
 */
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: dma-mapping: fix atomic allocation alignment

2012-08-05 Thread Aaro Koskinen
The alignment mask is calculated incorrectly. Fixing the calculation
makes strange hangs/lockups disappear during the boot with Amstrad E3
and 3.6-rc1 kernel.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/arm/mm/dma-mapping.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 2cc77b7..0e0466d 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -423,7 +423,7 @@ static void *__alloc_from_pool(size_t size, struct page 
**ret_page)
unsigned int pageno;
unsigned long flags;
void *ptr = NULL;
-   size_t align;
+   unsigned long align_mask;
 
if (!pool-vaddr) {
WARN(1, coherent pool not initialised!\n);
@@ -435,11 +435,11 @@ static void *__alloc_from_pool(size_t size, struct page 
**ret_page)
 * small, so align them to their order in pages, minimum is a page
 * size. This helps reduce fragmentation of the DMA space.
 */
-   align = PAGE_SIZE  get_order(size);
+   align_mask = (1  get_order(size)) - 1;
 
spin_lock_irqsave(pool-lock, flags);
pageno = bitmap_find_next_zero_area(pool-bitmap, pool-nr_pages,
-   0, count, (1  align) - 1);
+   0, count, align_mask);
if (pageno  pool-nr_pages) {
bitmap_set(pool-bitmap, pageno, count);
ptr = pool-vaddr + PAGE_SIZE * pageno;
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] spi: tsc2005: delete soon-obsolete e-mail address

2012-08-17 Thread Aaro Koskinen
Delete soon-obsolete e-mail address.

Signed-off-by: Aaro Koskinen aaro.koski...@nokia.com
---
 include/linux/spi/tsc2005.h |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/include/linux/spi/tsc2005.h b/include/linux/spi/tsc2005.h
index d9b0c84..8f721e4 100644
--- a/include/linux/spi/tsc2005.h
+++ b/include/linux/spi/tsc2005.h
@@ -3,8 +3,6 @@
  *
  * Copyright (C) 2009-2010 Nokia Corporation
  *
- * Contact: Aaro Koskinen aaro.koski...@nokia.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; either version 2 of the License, or
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] powerpc: dma-iommu: fix IOMMU window check

2012-08-18 Thread Aaro Koskinen
Checking for device mask to cover the whole IOMMU table is too strict.
IOMMU allocators should handle mask constraint properly for each
allocation.

The patch enables to use old AirPort Extreme cards on PowerMacs with
more than 1GB of memory; without the patch the driver init fails with:

  b43-pci-bridge 0001:01:01.0: Warning: IOMMU window too big for device mask
  b43-pci-bridge 0001:01:01.0: mask: 0x3fff, table end: 0x8000
  b43-phy0 ERROR: The machine/kernel does not support the required 30-bit DMA 
mask

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/powerpc/kernel/dma-iommu.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index 2d7bb8c..e489752 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -83,11 +83,10 @@ static int dma_iommu_dma_supported(struct device *dev, u64 
mask)
return 0;
}
 
-   if ((tbl-it_offset + tbl-it_size)  (mask  IOMMU_PAGE_SHIFT)) {
-   dev_info(dev, Warning: IOMMU window too big for device 
mask\n);
-   dev_info(dev, mask: 0x%08llx, table end: 0x%08lx\n,
-   mask, (tbl-it_offset + tbl-it_size) 
-   IOMMU_PAGE_SHIFT);
+   if (tbl-it_offset  (mask  IOMMU_PAGE_SHIFT)) {
+   dev_info(dev, Warning: IOMMU offset too big for device 
mask\n);
+   dev_info(dev, mask: 0x%08llx, table offset: 0x%08lx\n,
+   mask, tbl-it_offset  IOMMU_PAGE_SHIFT);
return 0;
} else
return 1;
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Documentation: talk about Cc: sta...@vger.kernel.org

2012-07-06 Thread Aaro Koskinen
Hi,

On Fri, Jul 06, 2012 at 05:38:50PM -0400, Theodore Ts'o wrote:
 I couldn't remember whether the canonical marking is sta...@kernel.org
 or sta...@vger.kernel.org, so I went looking, and discovered that it
 wasn't mentioned in the kernel sources.  You can find mention of it in
 Greg K-H's blog, but not everyone would necessarily find this blog
 entry.

It's documented in Documentation/stable_kernel_rules.txt.

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 03/19 v2] Staging: xgifb: Remove LCDA detection in xgifb_probe().

2012-07-09 Thread Aaro Koskinen
Hi,

On Mon, Jul 09, 2012 at 11:39:47AM -0700, Greg KH wrote:
 On Fri, Jul 06, 2012 at 12:40:38PM +0200, Miguel Gómez wrote:
  The piece of code that checks for LCDA in xgifb_probe() just checks for some
  register values but doesn't really do anything in response to them (the 
  actions
  that should be executed are commented).
  As nothing is really being done, the code can be safely removed.
 
 Are you sure?  Some devices (foolish ones that is) need registers read
 to work properly as that is part of their start-up logic.  Yeah, it
 doesn't seem to make sense, but hardware designers usually have good
 reasons for doing this type of thing.  Or at least they think they do :)

Those registers (CR 0x30..0x38) are scratch registers, so reading them
should have no side effects in the device side. I think it's safe to
delete that code.

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


3.8-rc1 build failure with MIPS/SPARSEMEM

2012-12-22 Thread Aaro Koskinen
Hi,

It looks like commit 816422ad76474fed8052b6f7b905a054d082e59a
(asm-generic, mm: pgtable: consolidate zero page helpers) broke
MIPS/SPARSEMEM build in 3.8-rc1:

  CHK include/generated/uapi/linux/version.h
  CHK include/generated/utsrelease.h
  Checking missing-syscalls for N32
  CC  arch/mips/kernel/asm-offsets.s
In file included from 
/home/aaro/git/linux/arch/mips/include/asm/pgtable.h:388:0,
 from include/linux/mm.h:44,
 from arch/mips/kernel/asm-offsets.c:14:
include/asm-generic/pgtable.h: In function 'my_zero_pfn':
include/asm-generic/pgtable.h:462:9: error: implicit declaration of function 
'page_to_section' [-Werror=implicit-function-declaration]
In file included from arch/mips/kernel/asm-offsets.c:14:0:
include/linux/mm.h: At top level:
include/linux/mm.h:708:29: error: conflicting types for 'page_to_section'
In file included from 
/home/aaro/git/linux/arch/mips/include/asm/pgtable.h:388:0,
 from include/linux/mm.h:44,
 from arch/mips/kernel/asm-offsets.c:14:
include/asm-generic/pgtable.h:462:9: note: previous implicit declaration of 
'page_to_section' was here
cc1: some warnings being treated as errors
make[1]: *** [arch/mips/kernel/asm-offsets.s] Error 1
make: *** [archprepare] Error 2

Reverting the patch helps.

My test config is below,

A.

#
# Automatically generated file; DO NOT EDIT.
# Linux/mips 3.8.0-rc1 Kernel Configuration
#
CONFIG_MIPS=y

#
# Machine selection
#
# CONFIG_MIPS_ALCHEMY is not set
# CONFIG_AR7 is not set
# CONFIG_ATH79 is not set
# CONFIG_BCM47XX is not set
# CONFIG_BCM63XX is not set
# CONFIG_MIPS_COBALT is not set
# CONFIG_MACH_DECSTATION is not set
# CONFIG_MACH_JAZZ is not set
# CONFIG_MACH_JZ4740 is not set
# CONFIG_LANTIQ is not set
# CONFIG_LASAT is not set
CONFIG_MACH_LOONGSON=y
# CONFIG_MACH_LOONGSON1 is not set
# CONFIG_MIPS_MALTA is not set
# CONFIG_MIPS_SEAD3 is not set
# CONFIG_NEC_MARKEINS is not set
# CONFIG_MACH_VR41XX is not set
# CONFIG_NXP_STB220 is not set
# CONFIG_NXP_STB225 is not set
# CONFIG_PNX8550_JBS is not set
# CONFIG_PNX8550_STB810 is not set
# CONFIG_PMC_MSP is not set
# CONFIG_POWERTV is not set
# CONFIG_SGI_IP22 is not set
# CONFIG_SGI_IP27 is not set
# CONFIG_SGI_IP28 is not set
# CONFIG_SGI_IP32 is not set
# CONFIG_SIBYTE_CRHINE is not set
# CONFIG_SIBYTE_CARMEL is not set
# CONFIG_SIBYTE_CRHONE is not set
# CONFIG_SIBYTE_RHONE is not set
# CONFIG_SIBYTE_SWARM is not set
# CONFIG_SIBYTE_LITTLESUR is not set
# CONFIG_SIBYTE_SENTOSA is not set
# CONFIG_SIBYTE_BIGSUR is not set
# CONFIG_SNI_RM is not set
# CONFIG_MACH_TX39XX is not set
# CONFIG_MACH_TX49XX is not set
# CONFIG_MIKROTIK_RB532 is not set
# CONFIG_WR_PPMC is not set
# CONFIG_CAVIUM_OCTEON_SIMULATOR is not set
# CONFIG_CAVIUM_OCTEON_REFERENCE_BOARD is not set
# CONFIG_NLM_XLR_BOARD is not set
# CONFIG_NLM_XLP_BOARD is not set
# CONFIG_ALCHEMY_GPIO_INDIRECT is not set
# CONFIG_LEMOTE_FULOONG2E is not set
CONFIG_LEMOTE_MACH2F=y
CONFIG_CS5536=y
CONFIG_CS5536_MFGPT=y
CONFIG_LOONGSON_SUSPEND=y
CONFIG_LOONGSON_UART_BASE=y
CONFIG_LOONGSON_MC146818=y
CONFIG_RWSEM_GENERIC_SPINLOCK=y
# CONFIG_ARCH_HAS_ILOG2_U32 is not set
# CONFIG_ARCH_HAS_ILOG2_U64 is not set
CONFIG_GENERIC_HWEIGHT=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_SCHED_OMIT_FRAME_POINTER=y
CONFIG_ARCH_DMA_ADDR_T_64BIT=y
CONFIG_DMA_NONCOHERENT=y
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_SYS_HAS_EARLY_PRINTK=y
CONFIG_I8259=y
# CONFIG_MIPS_MACHINE is not set
# CONFIG_NO_IOPORT is not set
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_ISA_DMA_SUPPORT_BROKEN=y
CONFIG_ISA_DMA_API=y
CONFIG_GENERIC_GPIO=y
CONFIG_CPU_LITTLE_ENDIAN=y
CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
CONFIG_SYS_SUPPORTS_HUGETLBFS=y
# CONFIG_MIPS_HUGE_TLB_SUPPORT is not set
CONFIG_IRQ_CPU=y
CONFIG_BOOT_ELF32=y
CONFIG_MIPS_L1_CACHE_SHIFT=5

#
# CPU selection
#
CONFIG_CPU_LOONGSON2F=y
CONFIG_CPU_NOP_WORKAROUNDS=y
CONFIG_CPU_JUMP_WORKAROUNDS=y
CONFIG_CPU_LOONGSON2F_WORKAROUNDS=y
CONFIG_SYS_SUPPORTS_ZBOOT=y
CONFIG_CPU_LOONGSON2=y
CONFIG_SYS_HAS_CPU_LOONGSON2F=y
CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
CONFIG_CPU_SUPPORTS_CPUFREQ=y
CONFIG_CPU_SUPPORTS_ADDRWINCFG=y
CONFIG_CPU_SUPPORTS_HUGEPAGES=y
CONFIG_CPU_SUPPORTS_UNCACHED_ACCELERATED=y

#
# Kernel type
#
# CONFIG_32BIT is not set
CONFIG_64BIT=y
CONFIG_PAGE_SIZE_16KB=y
# CONFIG_PAGE_SIZE_64KB is not set
CONFIG_FORCE_MAX_ZONEORDER=11
CONFIG_BOARD_SCACHE=y
CONFIG_CPU_GENERIC_DUMP_TLB=y
CONFIG_CPU_R4K_FPU=y
CONFIG_CPU_R4K_CACHE_TLB=y
CONFIG_MIPS_MT_DISABLED=y
# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
CONFIG_CPU_HAS_WB=y
CONFIG_CPU_HAS_SYNC=y
CONFIG_CPU_SUPPORTS_HIGHMEM=y
CONFIG_SYS_SUPPORTS_HIGHMEM=y
CONFIG_ARCH_SPARSEMEM_ENABLE=y
CONFIG_SELECT_MEMORY_MODEL=y
CONFIG_SPARSEMEM_MANUAL=y
CONFIG_SPARSEMEM=y
CONFIG_HAVE_MEMORY_PRESENT=y
CONFIG_SPARSEMEM_STATIC=y
CONFIG_HAVE_MEMBLOCK=y
CONFIG_HAVE_MEMBLOCK_NODE_MAP=y
CONFIG_ARCH_DISCARD_MEMBLOCK=y

Re: 3.8-rc1 build failure with MIPS/SPARSEMEM

2012-12-22 Thread Aaro Koskinen
Hi,

On Sat, Dec 22, 2012 at 03:10:23PM +0200, Kirill A. Shutemov wrote:
 On Sat, Dec 22, 2012 at 02:27:57PM +0200, Aaro Koskinen wrote:
  It looks like commit 816422ad76474fed8052b6f7b905a054d082e59a
  (asm-generic, mm: pgtable: consolidate zero page helpers) broke
  MIPS/SPARSEMEM build in 3.8-rc1:
 
 Could you try this:
 
 http://permalink.gmane.org/gmane.linux.kernel/1410981

It's not helping. And if you look at the error, it shows linux/mm.h is
already there?

[...]
In file included from 
/home/aaro/git/linux/arch/mips/include/asm/pgtable.h:388:0,
 from include/linux/mm.h:44,
 from arch/mips/kernel/asm-offsets.c:14:
[...]

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: 3.8-rc1 build failure with MIPS/SPARSEMEM

2012-12-27 Thread Aaro Koskinen
Hi,

On Wed, Dec 26, 2012 at 02:34:35AM +0200, Kirill A. Shutemov wrote:
 On MIPS if SPARSEMEM is enabled we've got this:
 
 In file included from 
 /home/kas/git/public/linux/arch/mips/include/asm/pgtable.h:552,
  from include/linux/mm.h:44,
  from arch/mips/kernel/asm-offsets.c:14:
 include/asm-generic/pgtable.h: In function ‘my_zero_pfn’:
 include/asm-generic/pgtable.h:466: error: implicit declaration of function 
 ‘page_to_section’
 In file included from arch/mips/kernel/asm-offsets.c:14:
 include/linux/mm.h: At top level:
 include/linux/mm.h:738: error: conflicting types for ‘page_to_section’
 include/asm-generic/pgtable.h:466: note: previous implicit declaration of 
 ‘page_to_section’ was here
 
 Due header files inter-dependencies, the only way I see to fix it is
 convert my_zero_pfn() for __HAVE_COLOR_ZERO_PAGE to macros.
 
 Signed-off-by: Kirill A. Shutemov kir...@shutemov.name

Thanks, this works.

Tested-by: Aaro Koskinen aaro.koski...@iki.fi

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 0/3] ARM: dts: omap: add dt data for MUSB

2012-12-27 Thread Aaro Koskinen
Hi,

On Thu, Sep 20, 2012 at 05:21:15AM +0200, Benoit Cousson wrote:
 On 09/19/2012 11:32 AM, Kishon Vijay Abraham I wrote:
  This patch series adds dt data to get MUSB working in omap4 and omap3
  
  Changes from v2:
  * Changes the subject of all the patches to include ARM: dts:
  * Added reg property and interrupt property for usb_otg_hs. Previously 
  these
were obtained from ti,hwmods property.
  * Rebased on
git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git 
  devel-dt
  
  Changes from v1:
  Just removed the omap-usb2 dt data and sent that as a separate patch.
  
  Kishon Vijay Abraham I (3):
ARM: dts: Add twl6030-usb data
ARM: dts: Add twl4030-usb data
ARM: dts: omap: Add usb_otg and glue data
 
 Thanks for the update. I've just pulled the series for 3.7.

I wonder what happened to the patch #3 (Add usb_otg and glue data)
of this series? Why was it dropped? I cannot see it in 3.7 or 3.8-rc1.

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5] watchdog: introduce retu_wdt driver

2012-12-27 Thread Aaro Koskinen
Introduce Retu watchdog driver.

Cc: linux-watch...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wim Van Sebroeck w...@iguana.be
---

v5: Deleted __dev* annotations.
Fixed a typo in Kconfig help text (Nokia 700 - 770).

For earlier history, see:
http://marc.info/?l=linux-kernelm=135325660302114w=2

 drivers/watchdog/Kconfig|   12 +++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/retu_wdt.c |  178 +++
 3 files changed, 191 insertions(+)
 create mode 100644 drivers/watchdog/retu_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 7f809fd..75afc76 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -364,6 +364,18 @@ config IMX2_WDT
  To compile this driver as a module, choose M here: the
  module will be called imx2_wdt.
 
+config RETU_WATCHDOG
+   tristate Retu watchdog
+   depends on MFD_RETU
+   select WATCHDOG_CORE
+   help
+ Retu watchdog driver for Nokia Internet Tablets (770, N800,
+ N810). At least on N800 the watchdog cannot be disabled, so
+ this driver is essential and you should enable it.
+
+ To compile this driver as a module, choose M here: the
+ module will be called retu_wdt.
+
 # AVR32 Architecture
 
 config AT32AP700X_WDT
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 97bbdb3a..157bc61 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o
 obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
 obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
 obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
+obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o
 
 # AVR32 Architecture
 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c
new file mode 100644
index 000..f53615d
--- /dev/null
+++ b/drivers/watchdog/retu_wdt.c
@@ -0,0 +1,178 @@
+/*
+ * Retu watchdog driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Amit Kucheria and Michael Buesch.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/device.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/watchdog.h
+#include linux/platform_device.h
+
+/* Watchdog timer values in seconds */
+#define RETU_WDT_MAX_TIMER 63
+
+struct retu_wdt_dev {
+   struct retu_dev *rdev;
+   struct device   *dev;
+   struct delayed_work ping_work;
+};
+
+/*
+ * Since Retu watchdog cannot be disabled in hardware, we must kick it
+ * with a timer until userspace watchdog software takes over. If
+ * CONFIG_WATCHDOG_NOWAYOUT is set, we never start the feeding.
+ */
+static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   schedule_delayed_work(wdev-ping_work,
+   round_jiffies_relative(RETU_WDT_MAX_TIMER * HZ / 2));
+}
+
+static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   cancel_delayed_work_sync(wdev-ping_work);
+}
+
+static void retu_wdt_ping_work(struct work_struct *work)
+{
+   struct retu_wdt_dev *wdev = container_of(to_delayed_work(work),
+   struct retu_wdt_dev, ping_work);
+   retu_wdt_ping_enable(wdev);
+}
+
+static int retu_wdt_start(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_disable(wdev);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_stop(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_enable(wdev);
+
+   return 0;
+}
+
+static int retu_wdt_ping(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_set_timeout(struct watchdog_device *wdog,
+   unsigned int timeout)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   wdog-timeout = timeout;
+   return retu_write

[RESEND PATCH] drm/nouveau: fix init with agpgart-uninorth

2012-12-30 Thread Aaro Koskinen
Check that the AGP aperture can be mapped. This follows a similar change
done for Radeon (commit 365048ff, drm/radeon: AGP memory is only I/O if
the aperture can be mapped by the CPU.).

The patch fixes the following error seen on G5 iMac:

nouveau E[ DRM] failed to create kernel channel, -12

Reviewed-by: Michel Dänzer mic...@daenzer.net
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/gpu/drm/nouveau/nouveau_bo.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 5614c89..69d7b1d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1276,7 +1276,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, 
struct ttm_mem_reg *mem)
if (drm-agp.stat == ENABLED) {
mem-bus.offset = mem-start  PAGE_SHIFT;
mem-bus.base = drm-agp.base;
-   mem-bus.is_iomem = true;
+   mem-bus.is_iomem = !dev-agp-cant_use_aperture;
}
 #endif
break;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RESEND PATCH v3 1/6] watchdog: omap_wdt: convert to new watchdog core

2012-12-13 Thread Aaro Koskinen
Hi,

On Fri, Dec 14, 2012 at 02:23:36AM +0100, Sebastian Reichel wrote:
 On Mon, Nov 12, 2012 at 02:47:03PM -0800, Tony Lindgren wrote:
  * Aaro Koskinen aaro.koski...@iki.fi [121112 10:49]:
   Convert omap_wdt to new watchdog core. On OMAP boards, there are usually
   multiple watchdogs. Since the new watchdog core supports multiple
   watchdogs, all watchdog drivers used on OMAP should be converted.
   
   The legacy watchdog device node is still created, so this should not
   break existing users.
   
   Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
   Tested-by: Jarkko Nikula jarkko.nik...@jollamobile.com
   Tested-by: Lokesh Vutla lokeshvu...@ti.com
   Cc: Wim Van Sebroeck w...@iguana.be
  
  Wim, looks like these will cause merge conflicts with what we
  have already queued in omap-for-v3.8/cleanup-prcm as patch
  watchdog: OMAP: use standard GETBOOTSTATUS interface; use
  platform_data fn ptr along with other ARM multiplatform
  related clean up. If these look ackable to you, I can queue
  these that's OK to you.
 
 What's the status of this patchset? If I'm not mistaken it is
 neither included in linux-omap, nor in linux-watchdog-next.

Since it's not in -next, then I guess it won't appear in 3.8. Once
the 3.8-rc1 is out, I will continue rebasing/retesting/resending the
patch set...

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] drm/nouveau: fix init with agpgart-uninorth

2012-11-16 Thread Aaro Koskinen
Check that the AGP aperture can be mapped. This follows a similar change
done for Radeon (commit 365048ff, drm/radeon: AGP memory is only I/O if
the aperture can be mapped by the CPU.).

The patch fixes the following error seen on G5 iMac:

nouveau E[ DRM] failed to create kernel channel, -12

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/gpu/drm/nouveau/nouveau_bo.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 35ac57f..5f0e7ef 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1279,7 +1279,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, 
struct ttm_mem_reg *mem)
if (drm-agp.stat == ENABLED) {
mem-bus.offset = mem-start  PAGE_SHIFT;
mem-bus.base = drm-agp.base;
-   mem-bus.is_iomem = true;
+   mem-bus.is_iomem = !dev-agp-cant_use_aperture;
}
 #endif
break;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/4] mfd: introduce retu-mfd driver

2012-11-18 Thread Aaro Koskinen
Retu is a multi-function device found on Nokia Internet Tablets
implementing at least watchdog, RTC, headset detection and power button
functionality.

This patch implements minimum functionality providing register access,
IRQ handling and power off functions.

Cc: Samuel Ortiz sa...@linux.intel.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/mfd/Kconfig  |9 ++
 drivers/mfd/Makefile |1 +
 drivers/mfd/retu-mfd.c   |  264 ++
 include/linux/mfd/retu.h |   22 
 4 files changed, 296 insertions(+)
 create mode 100644 drivers/mfd/retu-mfd.c
 create mode 100644 include/linux/mfd/retu.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index acab3ef..7528c5e 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1044,6 +1044,15 @@ config MFD_PALMAS
  If you say yes here you get support for the Palmas
  series of PMIC chips from Texas Instruments.
 
+config MFD_RETU
+   tristate Support for Retu multi-function device
+   select MFD_CORE
+   depends on I2C
+   select REGMAP_IRQ
+   help
+ Retu is a multi-function device found on Nokia Internet Tablets
+ (770, N800 and N810).
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index d8ccb63..ad7879f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -138,3 +138,4 @@ obj-$(CONFIG_MFD_RC5T583)   += rc5t583.o rc5t583-irq.o
 obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o
 obj-$(CONFIG_MFD_SYSCON)   += syscon.o
 obj-$(CONFIG_MFD_LM3533)   += lm3533-core.o lm3533-ctrlbank.o
+obj-$(CONFIG_MFD_RETU) += retu-mfd.o
diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c
new file mode 100644
index 000..7ff4a37
--- /dev/null
+++ b/drivers/mfd/retu-mfd.c
@@ -0,0 +1,264 @@
+/*
+ * Retu MFD driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Juha Yrjölä, David Weinehall and Mikko Ylinen.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/err.h
+#include linux/i2c.h
+#include linux/irq.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/mutex.h
+#include linux/module.h
+#include linux/regmap.h
+#include linux/mfd/core.h
+#include linux/mfd/retu.h
+#include linux/interrupt.h
+#include linux/moduleparam.h
+
+/* Registers */
+#define RETU_REG_ASICR 0x00/* ASIC ID and revision */
+#define RETU_REG_ASICR_VILMA   (1  7)/* Bit indicating Vilma */
+#define RETU_REG_IDR   0x01/* Interrupt ID */
+#define RETU_REG_IMR   0x02/* Interrupt mask */
+
+/* Interrupt sources */
+#define RETU_INT_PWR   0   /* Power button */
+
+struct retu_dev {
+   struct regmap   *regmap;
+   struct device   *dev;
+   struct mutexmutex;
+   struct regmap_irq_chip_data *irq_data;
+};
+
+static struct resource retu_pwrbutton_res[] = {
+   {
+   .name   = retu-pwrbutton,
+   .start  = RETU_INT_PWR,
+   .end= RETU_INT_PWR,
+   .flags  = IORESOURCE_IRQ,
+   },
+};
+
+static struct mfd_cell retu_devs[] = {
+   {
+   .name   = retu-wdt
+   },
+   {
+   .name   = retu-pwrbutton,
+   .resources  = retu_pwrbutton_res,
+   .num_resources  = ARRAY_SIZE(retu_pwrbutton_res),
+   }
+};
+
+static struct regmap_irq retu_irqs[] = {
+   [RETU_INT_PWR] = {
+   .mask = 1  RETU_INT_PWR,
+   }
+};
+
+static struct regmap_irq_chip retu_irq_chip = {
+   .name   = RETU,
+   .irqs   = retu_irqs,
+   .num_irqs   = ARRAY_SIZE(retu_irqs),
+   .num_regs   = 1,
+   .status_base= RETU_REG_IDR,
+   .mask_base  = RETU_REG_IMR,
+   .ack_base   = RETU_REG_IDR,
+};
+
+/* Retu device registered for the power off. */
+static struct retu_dev *retu_pm_power_off;
+
+int retu_read(struct retu_dev *rdev, u8 reg)
+{
+   int ret;
+   int value;
+
+   mutex_lock(rdev-mutex);
+   ret = regmap_read(rdev-regmap, reg, value);
+   mutex_unlock(rdev-mutex);
+
+   return ret ? ret : value;
+}
+EXPORT_SYMBOL_GPL(retu_read);
+
+int retu_write(struct retu_dev *rdev, u8 reg, u16 data)
+{
+   int ret;
+
+   mutex_lock(rdev-mutex);
+   ret = regmap_write(rdev-regmap, reg, data

[PATCH v4 0/4] cbus/retu drivers

2012-11-18 Thread Aaro Koskinen
This patch set introduces drivers for CBUS access and Retu multifunction
chip found on Nokia Internet Tablets (770, N800, N810). It would be
nice get these patches applied as the functionality of these devices is
severely lacking without Retu. E.g. watchdog support is mandatory at
least on Nokia N800, you cannot currently run the mainline kernel for
longer than ~60 seconds (there is no way to disable the watchdog).

Drivers originate from linux-omap cbus branch and have been cleaned
up/rewritten around i2c and MFD core.

Patches have been tested on top of 3.7-rc6 with Nokia N800 (watchdog
feeding works, power off shuts down the device, power button triggers
IRQs and input events, loading and unloading retu-pwrbutton module in a
loop while manically pressing the power button does not crash the kernel).

Changes since the third version (https://lkml.org/lkml/2012/11/12/338):
- i2c-cbus-gpio:
- driver renamed (i2c-cbus - i2c-cbus-gpio)
- added Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt

Changes since the second version (https://lkml.org/lkml/2012/10/31/520):
- i2c-cbus:
- move i2c-cbus.h under linux/platform_data
- retu-mfd
- replace retu_pwrbutton_res[0] expression with simpler
  retu_pwrbutton_res.
- retu-pwrbutton:
- eliminate struct retu_pwrbutton
- delete checks for duplicate events
- rework probe to avoid races
- disable IRQ before unregister in retu_pwrbutton_remove() to
  avoid races
- eliminate double free in retu_pwrbutton_remove()
- add .owner = THIS_MODULE

Changes since the first version (https://lkml.org/lkml/2012/9/3/265):
- i2c-cbus:
- use devres
- improve comments
- simplify and delete redundant code
- refactoring  bug fixes on error handling
- discard input parameter from cbus_send_bit/data()
- retu-mfd:
- use devres
- use regmap
- retu_wdt: use devres
- retu-pwrbutton: use devres

Changes since the RFC version
(http://marc.info/?l=linux-omapm=134618967116737w=2):
- added DT support for getting i2c-cbus GPIO pins
- merged n8x0 board file changes into i2c-cbus patch
- corrected typo in Kconfig for MFD_RETU
- added power off functionality to retu-mfd
- added IRQ functionality to retu-mfd
- added power button key driver
- some cleanups

Aaro Koskinen (4):
  i2c: introduce i2c-cbus-gpio driver
  mfd: introduce retu-mfd driver
  watchdog: introduce retu_wdt driver
  input: misc: introduce retu-pwrbutton

 .../devicetree/bindings/i2c/i2c-cbus-gpio.txt  |   27 ++
 arch/arm/mach-omap2/board-n8x0.c   |   42 +++
 drivers/i2c/busses/Kconfig |   10 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-cbus-gpio.c |  300 
 drivers/input/misc/Kconfig |   10 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/retu-pwrbutton.c|  102 +++
 drivers/mfd/Kconfig|9 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/retu-mfd.c |  264 +
 drivers/watchdog/Kconfig   |   12 +
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/retu_wdt.c|  178 
 include/linux/mfd/retu.h   |   22 ++
 include/linux/platform_data/i2c-cbus-gpio.h|   27 ++
 16 files changed, 1007 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
 create mode 100644 drivers/i2c/busses/i2c-cbus-gpio.c
 create mode 100644 drivers/input/misc/retu-pwrbutton.c
 create mode 100644 drivers/mfd/retu-mfd.c
 create mode 100644 drivers/watchdog/retu_wdt.c
 create mode 100644 include/linux/mfd/retu.h
 create mode 100644 include/linux/platform_data/i2c-cbus-gpio.h

-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 4/4] input: misc: introduce retu-pwrbutton

2012-11-18 Thread Aaro Koskinen
Add Retu power button driver.

Cc: linux-in...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Dmitry Torokhov dmitry.torok...@gmail.com
---
 drivers/input/misc/Kconfig  |   10 
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/retu-pwrbutton.c |  102 +++
 3 files changed, 113 insertions(+)
 create mode 100644 drivers/input/misc/retu-pwrbutton.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7c0f1ec..e5be189 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -367,6 +367,16 @@ config INPUT_CM109
  To compile this driver as a module, choose M here: the module will be
  called cm109.
 
+config INPUT_RETU_PWRBUTTON
+   tristate Retu Power button Driver
+   depends on MFD_RETU
+   help
+ Say Y here if you want to enable power key reporting via the
+ Retu chips found in Nokia Internet Tablets (770, N800, N810).
+
+ To compile this driver as a module, choose M here. The module will
+ be called retu-pwrbutton.
+
 config INPUT_TWL4030_PWRBUTTON
tristate TWL4030 Power button Driver
depends on TWL4030_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 83fe6f5..4fbee0d 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)   += pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_POWERMATE)  += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)   += rb532_button.o
+obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SPARCSPKR)  += sparcspkr.o
diff --git a/drivers/input/misc/retu-pwrbutton.c 
b/drivers/input/misc/retu-pwrbutton.c
new file mode 100644
index 000..043a12b
--- /dev/null
+++ b/drivers/input/misc/retu-pwrbutton.c
@@ -0,0 +1,102 @@
+/*
+ * Retu power button driver.
+ *
+ * Copyright (C) 2004-2010 Nokia Corporation
+ *
+ * Original code written by Ari Saastamoinen, Juha Yrjölä and Felipe Balbi.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/irq.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/input.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+
+#define RETU_STATUS_PWRONX (1  5)
+
+static irqreturn_t retu_pwrbutton_irq(int irq, void *_pwr)
+{
+   bool state;
+   struct input_dev *idev = _pwr;
+   struct retu_dev *rdev = input_get_drvdata(idev);
+
+   state = !(retu_read(rdev, RETU_REG_STATUS)  RETU_STATUS_PWRONX);
+   input_report_key(idev, KEY_POWER, state);
+   input_sync(idev);
+
+   return IRQ_HANDLED;
+}
+
+static int __devinit retu_pwrbutton_probe(struct platform_device *pdev)
+{
+   struct retu_dev *rdev = dev_get_drvdata(pdev-dev.parent);
+   struct input_dev *idev;
+   int ret;
+
+   idev = input_allocate_device();
+   if (!idev)
+   return -ENOMEM;
+
+   idev-evbit[0]  = BIT_MASK(EV_KEY);
+   idev-keybit[BIT_WORD(KEY_POWER)]   = BIT_MASK(KEY_POWER);
+   idev-name  = retu-pwrbutton;
+
+   platform_set_drvdata(pdev, idev);
+   input_set_drvdata(idev, rdev);
+
+   ret = input_register_device(idev);
+   if (ret  0) {
+   input_free_device(idev);
+   return ret;
+   }
+
+   ret = devm_request_threaded_irq(pdev-dev, platform_get_irq(pdev, 0),
+   NULL, retu_pwrbutton_irq, 0,
+   retu-pwrbutton, idev);
+   if (ret  0)
+   input_unregister_device(idev);
+
+   return ret;
+}
+
+static int __devexit retu_pwrbutton_remove(struct platform_device *pdev)
+{
+   struct input_dev *idev = platform_get_drvdata(pdev);
+
+   disable_irq(platform_get_irq(pdev, 0));
+   input_unregister_device(idev);
+
+   return 0;
+}
+
+static struct platform_driver retu_pwrbutton_driver = {
+   .probe  = retu_pwrbutton_probe,
+   .remove = __devexit_p(retu_pwrbutton_remove),
+   .driver = {
+   .name   = retu-pwrbutton,
+   .owner  = THIS_MODULE,
+   },
+};
+module_platform_driver

[PATCH v4 3/4] watchdog: introduce retu_wdt driver

2012-11-18 Thread Aaro Koskinen
Introduce Retu watchdog driver.

Cc: linux-watch...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wim Van Sebroeck w...@iguana.be
---
 drivers/watchdog/Kconfig|   12 +++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/retu_wdt.c |  178 +++
 3 files changed, 191 insertions(+)
 create mode 100644 drivers/watchdog/retu_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ad1bb93..c3a836d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -352,6 +352,18 @@ config IMX2_WDT
  To compile this driver as a module, choose M here: the
  module will be called imx2_wdt.
 
+config RETU_WATCHDOG
+   tristate Retu watchdog
+   depends on MFD_RETU
+   select WATCHDOG_CORE
+   help
+ Retu watchdog driver for Nokia Internet Tablets (700, N800,
+ N810). At least on N800 the watchdog cannot be disabled, so
+ this driver is essential and you should enable it.
+
+ To compile this driver as a module, choose M here: the
+ module will be called retu_wdt.
+
 # AVR32 Architecture
 
 config AT32AP700X_WDT
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 572b39b..d2f1c0c 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o
 obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
 obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
 obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
+obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o
 
 # AVR32 Architecture
 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c
new file mode 100644
index 000..aeb0f39
--- /dev/null
+++ b/drivers/watchdog/retu_wdt.c
@@ -0,0 +1,178 @@
+/*
+ * Retu watchdog driver
+ *
+ * Copyright (C) 2004, 2005 Nokia Corporation
+ *
+ * Based on code written by Amit Kucheria and Michael Buesch.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include linux/init.h
+#include linux/slab.h
+#include linux/errno.h
+#include linux/device.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mfd/retu.h
+#include linux/watchdog.h
+#include linux/platform_device.h
+
+/* Watchdog timer values in seconds */
+#define RETU_WDT_MAX_TIMER 63
+
+struct retu_wdt_dev {
+   struct retu_dev *rdev;
+   struct device   *dev;
+   struct delayed_work ping_work;
+};
+
+/*
+ * Since Retu watchdog cannot be disabled in hardware, we must kick it
+ * with a timer until userspace watchdog software takes over. If
+ * CONFIG_WATCHDOG_NOWAYOUT is set, we never start the feeding.
+ */
+static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   schedule_delayed_work(wdev-ping_work,
+   round_jiffies_relative(RETU_WDT_MAX_TIMER * HZ / 2));
+}
+
+static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev)
+{
+   retu_write(wdev-rdev, RETU_REG_WATCHDOG, RETU_WDT_MAX_TIMER);
+   cancel_delayed_work_sync(wdev-ping_work);
+}
+
+static void retu_wdt_ping_work(struct work_struct *work)
+{
+   struct retu_wdt_dev *wdev = container_of(to_delayed_work(work),
+   struct retu_wdt_dev, ping_work);
+   retu_wdt_ping_enable(wdev);
+}
+
+static int retu_wdt_start(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_disable(wdev);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_stop(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   retu_wdt_ping_enable(wdev);
+
+   return 0;
+}
+
+static int retu_wdt_ping(struct watchdog_device *wdog)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static int retu_wdt_set_timeout(struct watchdog_device *wdog,
+   unsigned int timeout)
+{
+   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+
+   wdog-timeout = timeout;
+   return retu_write(wdev-rdev, RETU_REG_WATCHDOG, wdog-timeout);
+}
+
+static const struct watchdog_info retu_wdt_info = {
+   .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+   .identity = Retu watchdog

[PATCH v4 1/4] i2c: introduce i2c-cbus-gpio driver

2012-11-18 Thread Aaro Koskinen
Add i2c driver to enable access to devices behind CBUS on Nokia Internet
Tablets.

The patch also adds CBUS I2C configuration for N8x0 which is one of the
users of this driver.

Cc: linux-...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wolfram Sang w.s...@pengutronix.de
---
 .../devicetree/bindings/i2c/i2c-cbus-gpio.txt  |   27 ++
 arch/arm/mach-omap2/board-n8x0.c   |   42 +++
 drivers/i2c/busses/Kconfig |   10 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-cbus-gpio.c |  300 
 include/linux/platform_data/i2c-cbus-gpio.h|   27 ++
 6 files changed, 407 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
 create mode 100644 drivers/i2c/busses/i2c-cbus-gpio.c
 create mode 100644 include/linux/platform_data/i2c-cbus-gpio.h

diff --git a/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt 
b/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
new file mode 100644
index 000..8ce9cd2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
@@ -0,0 +1,27 @@
+Device tree bindings for i2c-cbus-gpio driver
+
+Required properties:
+   - compatible = i2c-cbus-gpio;
+   - gpios: clk, dat, sel
+   - #address-cells = 1;
+   - #size-cells = 0;
+
+Optional properties:
+   - child nodes conforming to i2c bus binding
+
+Example:
+
+i2c@0 {
+   compatible = i2c-cbus-gpio;
+   gpios = gpio 66 0 /* clk */
+gpio 65 0 /* dat */
+gpio 64 0 /* sel */
+   ;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   retu-mfd: retu@1 {
+   compatible = retu-mfd;
+   reg = 0x1;
+   };
+};
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index d95f727..bbfd742 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -16,10 +16,12 @@
 #include linux/gpio.h
 #include linux/init.h
 #include linux/io.h
+#include linux/irq.h
 #include linux/stddef.h
 #include linux/i2c.h
 #include linux/spi/spi.h
 #include linux/usb/musb.h
+#include linux/platform_data/i2c-cbus-gpio.h
 #include linux/platform_data/spi-omap2-mcspi.h
 #include linux/platform_data/mtd-onenand-omap2.h
 #include sound/tlv320aic3x.h
@@ -39,6 +41,45 @@
 #define TUSB6010_GPIO_ENABLE   0
 #define TUSB6010_DMACHAN   0x3f
 
+#if defined(CONFIG_I2C_CBUS_GPIO) || defined(CONFIG_I2C_CBUS_GPIO_MODULE)
+static struct i2c_cbus_platform_data n8x0_cbus_data = {
+   .clk_gpio = 66,
+   .dat_gpio = 65,
+   .sel_gpio = 64,
+};
+
+static struct platform_device n8x0_cbus_device = {
+   .name   = i2c-cbus-gpio,
+   .id = 3,
+   .dev= {
+   .platform_data = n8x0_cbus_data,
+   },
+};
+
+static struct i2c_board_info n8x0_i2c_board_info_3[] __initdata = {
+   {
+   I2C_BOARD_INFO(retu-mfd, 0x01),
+   },
+};
+
+static void __init n8x0_cbus_init(void)
+{
+   const int retu_irq_gpio = 108;
+
+   if (gpio_request_one(retu_irq_gpio, GPIOF_IN, Retu IRQ))
+   return;
+   irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
+   n8x0_i2c_board_info_3[0].irq = gpio_to_irq(retu_irq_gpio);
+   i2c_register_board_info(3, n8x0_i2c_board_info_3,
+   ARRAY_SIZE(n8x0_i2c_board_info_3));
+   platform_device_register(n8x0_cbus_device);
+}
+#else /* CONFIG_I2C_CBUS_GPIO */
+static void __init n8x0_cbus_init(void)
+{
+}
+#endif /* CONFIG_I2C_CBUS_GPIO */
+
 #if defined(CONFIG_USB_MUSB_TUSB6010) || 
defined(CONFIG_USB_MUSB_TUSB6010_MODULE)
 /*
  * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
@@ -677,6 +718,7 @@ static void __init n8x0_init_machine(void)
gpmc_onenand_init(board_onenand_data);
n8x0_mmc_init();
n8x0_usb_init();
+   n8x0_cbus_init();
 }
 
 MACHINE_START(NOKIA_N800, Nokia N800)
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index e9df461..e949edf 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -337,6 +337,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
help
  The unit of the TWI clock is kHz.
 
+config I2C_CBUS_GPIO
+   tristate CBUS I2C driver
+   depends on GENERIC_GPIO
+   help
+ Support for CBUS access using I2C API. Mostly relevant for Nokia
+ Internet Tablets (770, N800 and N810).
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-cbus-gpio.
+
 config I2C_CPM
tristate Freescale CPM1 or CPM2 (MPC8xx/826x)
depends on (CPM1 || CPM2)  OF_I2C
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 395b516..f9e3e0b 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses

3.8-rc3: yet another MIPS build failure

2013-01-10 Thread Aaro Koskinen
Hi,

Commit d3ce88431892b703b04769566338a89eda6b0477 (MIPS: Fix modpost
error in modules attepting to use virt_addr_valid()) broke the 64-bit
MIPS build:

  LD  init/built-in.o
kernel/built-in.o: In function `memory_bm_free':
snapshot.c:(.text+0x3c76c): undefined reference to `__virt_addr_valid'
snapshot.c:(.text+0x3c800): undefined reference to `__virt_addr_valid'
kernel/built-in.o: In function `snapshot_write_next':
(.text+0x3e094): undefined reference to `__virt_addr_valid'
kernel/built-in.o: In function `snapshot_write_next':
(.text+0x3e468): undefined reference to `__virt_addr_valid'
make[4]: *** [vmlinux] Error 1

A quick workaround is to compile ioremap.c always, but it adds ~2KB
unused code for 64-bit-only kernels...

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Staging:xgifb:Fixed a warning of Space before semicolon

2013-08-04 Thread Aaro Koskinen
On Mon, Aug 05, 2013 at 12:11:02AM +0530, Kumar Gaurav wrote:
 Fixed issue by removing Space before semicolon
 
 Signed-off-by: Kumar Gaurav kumargauravgup...@gmail.com
 ---
  drivers/staging/xgifb/vb_setmode.h |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/staging/xgifb/vb_setmode.h 
 b/drivers/staging/xgifb/vb_setmode.h
 index 2c0a31c..679a822 100644
 --- a/drivers/staging/xgifb/vb_setmode.h
 +++ b/drivers/staging/xgifb/vb_setmode.h
 @@ -13,7 +13,7 @@ extern void XGI_GetVBType(struct vb_device_info *);
  extern void XGI_SenseCRT1(struct vb_device_info *);
  extern unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
  struct xgi_hw_device_info *HwDeviceExtension,
 -unsigned short ModeNo) ;
 +unsigned short ModeNo);

There's a similar issue in vb_table.h, line 1287. Maybe fix that also
at the same time?

Thanks,

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] cpufreq: loongson2: fix broken cpufreq

2013-08-05 Thread Aaro Koskinen
Commit 42913c799 (MIPS: Loongson2: Use clk API instead of direct
dereferences) broke the cpufreq functionality on Loongson2 boards:
clk_set_rate() is called before the CPU frequency table is initialized,
and therefore will always fail.

Fix by moving the clk_set_rate() after the table initialization.
Tested on Lemote FuLoong mini-PC.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Acked-by: Viresh Kumar viresh.ku...@linaro.org
Cc: sta...@vger.kernel.org
---

Changes since the first version
(http://marc.info/?l=linux-kernelm=137357177225034w=2):

- Changed the subject prefix. I guess this should be merged through
  the cpufreq/PM instead of MIPS tree?

- Added ACK from Viresh Kumar.

 drivers/cpufreq/loongson2_cpufreq.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/loongson2_cpufreq.c 
b/drivers/cpufreq/loongson2_cpufreq.c
index bb838b9..9536852 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -118,11 +118,6 @@ static int loongson2_cpufreq_cpu_init(struct 
cpufreq_policy *policy)
clk_put(cpuclk);
return -EINVAL;
}
-   ret = clk_set_rate(cpuclk, rate);
-   if (ret) {
-   clk_put(cpuclk);
-   return ret;
-   }
 
/* clock table init */
for (i = 2;
@@ -130,6 +125,12 @@ static int loongson2_cpufreq_cpu_init(struct 
cpufreq_policy *policy)
 i++)
loongson2_clockmod_table[i].frequency = (rate * i) / 8;
 
+   ret = clk_set_rate(cpuclk, rate);
+   if (ret) {
+   clk_put(cpuclk);
+   return ret;
+   }
+
policy-cur = loongson2_cpufreq_get(policy-cpu);
 
cpufreq_frequency_table_get_attr(loongson2_clockmod_table[0],
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


2.6.34.x longterm stable status

2013-08-05 Thread Aaro Koskinen
Hi,

There hasn't been 2.6.34.x stable tree releases for a
while. Also, in some mails you have mentioned EOLing this tree (e.g.
http://marc.info/?l=linux-docm=137393133817894w=2). I have two questions
concerning this:

- Will there be any more releases, or is it assumed that all users have
already migrated to newer releases and 2.6.34.14 is the final one?

- Shouldn't the EOL status be mentioned in the www.kernel.org front page?

Thanks,

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: v3.11-rc1 USB regressions

2013-07-24 Thread Aaro Koskinen
Hi,

On Wed, Jul 24, 2013 at 09:04:28PM +0200, Daniel Mack wrote:
 On 24.07.2013 20:51, Aaro Koskinen wrote:
  When I revert fe4cb0912f8e737f8e4b8b38b9e692f8062f5423 and
  8b125df5b24cfb0ec7fa1971e343cc0badc1827d, it works like before (3.10):
  
  I'm now running -rc2 with above fixes and reverts (the only way to get
  USB working). I'm seeing an additional issue, the following crash happens
  always on N900 when doing poweroff:
 
 Yes, with the mentioned patches reverted, musb_to_hcd() will return a
 faulty pointer. You can't easily revert them unfortunately.
 
 Your platform needs a real fix, I just have trouble understanding why a
 removed usb_add_hcd() would make the gadget code fail.
 
 Sorry for the trouble, but I don't currently have a board with musb in
 gadget mode to reproduce this issue.

If you have any ideas what to look for, I can maybe try to debug this
issue.

Below are some logs with additional DEBUGs enabled.

Broken:

[4.111480] udc musb-hdrc.0.auto: registering UDC driver [g_ether]
[4.136962] using random self ethernet address
[4.144134] using random host ethernet address
[4.151000] g_ether gadget: adding config #1 'CDC Ethernet (ECM)'/bf03f2c0
[4.160552] g_ether gadget: adding 'cdc_ethernet'/cef92e40 to config 'CDC 
Ethernet (ECM)'/bf03f2c0
[4.186828] usb0: HOST MAC f6:4a:86:02:5d:ec
[4.193939] usb0: MAC 26:e9:7c:49:4a:2e
[4.200256] g_ether gadget: CDC Ethernet: dual speed IN/ep1in OUT/ep1out 
NOTIFY/ep2in
[4.210906] g_ether gadget: cfg 1/bf03f2c0 speeds: high full
[4.219207] g_ether gadget:   interface 0 = cdc_ethernet/cef92e40
[4.227874] g_ether gadget:   interface 1 = cdc_ethernet/cef92e40
[4.236480] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
[4.245635] g_ether gadget: g_ether ready
[4.261627] twl4030_usb twl4030_usb: twl4030_phy_resume
[4.281433] usb0: eth_open
[4.560974] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb000d tx0001 
rx
[4.570983] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0xd
[4.579681] musb-hdrc musb-hdrc.0.auto: SUSPEND (b_idle) devctl 99
[4.588378] musb-hdrc musb-hdrc.0.auto: BUS RESET as b_peripheral
[4.596984] musb-hdrc musb-hdrc.0.auto: RX ep0 fifo fa0ab020 count 8 buf 
c0c55df0
[4.607055] musb-hdrc musb-hdrc.0.auto: TX ep0 fifo fa0ab020 count 18 buf 
cef1a000
[4.617248] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb0008 tx0001 
rx
[4.627044] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0x8
[4.728790] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb000c tx0001 
rx
[4.738616] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0xc
[4.747222] musb-hdrc musb-hdrc.0.auto: BUS RESET as b_peripheral
[4.755645] musb-hdrc musb-hdrc.0.auto: RX ep0 fifo fa0ab020 count 8 buf 
c0c55df0
[4.765533] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb0008 tx0001 
rx
[4.775207] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0x8
[4.784637] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb0008 tx0001 
rx
[4.794281] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0x8
[4.802703] musb-hdrc musb-hdrc.0.auto: RX ep0 fifo fa0ab020 count 8 buf 
c0c55df0
[4.812500] musb-hdrc musb-hdrc.0.auto: TX ep0 fifo fa0ab020 count 18 buf 
cef1a000
[4.822509] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb0008 tx0001 
rx
[4.832153] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0x8
[4.840576] musb-hdrc musb-hdrc.0.auto: RX ep0 fifo fa0ab020 count 8 buf 
c0c55dd0
[4.850372] musb-hdrc musb-hdrc.0.auto: TX ep0 fifo fa0ab020 count 9 buf 
cef1a000
[4.860198] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb0008 tx0001 
rx
[4.869781] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0x8
[4.878112] musb-hdrc musb-hdrc.0.auto: RX ep0 fifo fa0ab020 count 8 buf 
c0c55ce8
[4.887847] musb-hdrc musb-hdrc.0.auto: TX ep0 fifo fa0ab020 count 64 buf 
cef1a000
[4.897674] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb0008 tx0001 
rx
[4.907257] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0x8
[4.915588] musb-hdrc musb-hdrc.0.auto: TX ep0 fifo fa0ab020 count 24 buf 
cef1a040
[4.925506] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb0008 tx0001 
rx
[4.935089] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0x8
[4.943450] musb-hdrc musb-hdrc.0.auto: RX ep0 fifo fa0ab020 count 8 buf 
c0c55ce8
[4.953247] musb-hdrc musb-hdrc.0.auto: TX ep0 fifo fa0ab020 count 4 buf 
cef1a000
[4.963012] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb0008 tx0001 
rx
[4.972595] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0x8
[4.980926] musb-hdrc musb-hdrc.0.auto: RX ep0 fifo fa0ab020 count 8 buf 
c0c55ce8
[4.990692] musb-hdrc musb-hdrc.0.auto: TX ep0 fifo fa0ab020 count 32 buf 
cef1a000
[5.000549] musb-hdrc musb-hdrc.0.auto: ** IRQ peripheral usb0008 tx0001 
rx
[5.010101] musb-hdrc musb-hdrc.0.auto: == DevCtl=99, int_usb=0x8

Re: [PATCH] Change request_irq() to use struct net_device *dev-name

2013-07-25 Thread Aaro Koskinen
Hi,

On Thu, Jul 25, 2013 at 10:33:24PM +0400, Sergei Shtylyov wrote:
It's also called managed device API. In fact, I've never heard it
 named devres API.

Never read the documentation. :-)

$ head -1 Documentation/driver-model/devres.txt 
Devres - Managed Device Resource

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 076/133] ARM: update FIQ support for relocation of vectors

2013-08-18 Thread Aaro Koskinen
On Fri, Aug 16, 2013 at 03:33:38PM -0700, Kamal Mostafa wrote:
 3.8.13.7 -stable review patch.  If anyone has any objections, please let me 
 know.
 
 --
 
 From: Russell King rmk+ker...@arm.linux.org.uk
 
 commit e39e3f3ebfef03450cf7bfa7a974a8c61f7980c8 upstream.
 
 FIQ should no longer copy the FIQ code into the user visible vector
 page.  Instead, it should use the hidden page.  This change makes
 that happen.

FYI, this patch introduced regression (kernel crash) at least on Amstrad
E1 board (where FIQ is used for the keyboard). See the following thread:
http://marc.info/?t=13758316993r=1w=2

So any stable kernels where this patch was added should also take:

commit 2ba85e7af4c639d933c9a87a6d7363f2983d5ada
Author: Russell King rmk+ker...@arm.linux.org.uk
Date:   Thu Aug 8 11:51:21 2013 +0100

ARM: Fix FIQ code on VIVT CPUs

That patch fixes the regression.

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] MIPS: loongson2: cpufreq: fix broken cpufreq

2013-07-11 Thread Aaro Koskinen
Commit 42913c799 (MIPS: Loongson2: Use clk API instead of direct
dereferences) broke the cpufreq functionality on Loongson2 boards:
clk_set_rate() is called before the CPU frequency table is initialized,
and therefore will always fail.

Fix by moving the clk_set_rate() after the table initialization.
Tested on Lemote FuLoong mini-PC.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: sta...@vger.kernel.org
---
 drivers/cpufreq/loongson2_cpufreq.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/loongson2_cpufreq.c 
b/drivers/cpufreq/loongson2_cpufreq.c
index d539127..f92b02a 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -118,11 +118,6 @@ static int loongson2_cpufreq_cpu_init(struct 
cpufreq_policy *policy)
clk_put(cpuclk);
return -EINVAL;
}
-   ret = clk_set_rate(cpuclk, rate);
-   if (ret) {
-   clk_put(cpuclk);
-   return ret;
-   }
 
/* clock table init */
for (i = 2;
@@ -130,6 +125,12 @@ static int loongson2_cpufreq_cpu_init(struct 
cpufreq_policy *policy)
 i++)
loongson2_clockmod_table[i].frequency = (rate * i) / 8;
 
+   ret = clk_set_rate(cpuclk, rate);
+   if (ret) {
+   clk_put(cpuclk);
+   return ret;
+   }
+
policy-cur = loongson2_cpufreq_get(policy-cpu);
 
cpufreq_frequency_table_get_attr(loongson2_clockmod_table[0],
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] N900: add device tree

2013-07-14 Thread Aaro Koskinen
Hi,

On Sat, Jul 13, 2013 at 02:17:09PM +0200, Pavel Machek wrote:
 
 This adds device tree with neccessary support to boot with functional
 video (on both emulator and real N900 device).
 
 Signed-off-by: Pavel Machek pa...@ucw.cz

You can also add:

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi

Thanks,

A.

 
 ---
 
 From v1: Aaro wants just GPLv2, so I did that. I re-enabled parts that
 can be enabled on 3.10, and tested it on that kernel.
 
 diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
 index f0895c5..1950aed 100644
 --- a/arch/arm/boot/dts/Makefile
 +++ b/arch/arm/boot/dts/Makefile
 @@ -141,6 +141,7 @@ dtb-$(CONFIG_ARCH_OMAP2PLUS) += omap2420-h4.dtb \
   omap3-devkit8000.dtb \
   omap3-beagle-xm.dtb \
   omap3-evm.dtb \
 + omap3-n900.dtb \
   omap3-tobi.dtb \
   omap3-igep0020.dtb \
   omap3-igep0030.dtb \
 diff --git a/arch/arm/boot/dts/omap3-n900.dts 
 b/arch/arm/boot/dts/omap3-n900.dts
 new file mode 100644
 index 000..fb461bf
 --- /dev/null
 +++ b/arch/arm/boot/dts/omap3-n900.dts
 @@ -0,0 +1,92 @@
 +/*
 + * Copyright (C) 2013 Pavel Machek pa...@ucw.cz
 + * Copyright 2013 Aaro Koskinen aaro.koski...@iki.fi
 + *
 + * 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.
 + */
 +
 +/dts-v1/;
 +
 +/include/ omap34xx.dtsi
 +
 +/ {
 + model = Nokia N900;
 + compatible = nokia,omap3-n900, ti,omap3;
 +
 + cpus {
 + cpu@0 {
 + cpu0-supply = vcc;
 + };
 + };
 +
 + memory {
 + device_type = memory;
 + reg = 0x8000 0x1000; /* 256 MB */
 + };
 +
 +};
 +
 +i2c1 {
 + clock-frequency = 220;
 +
 + twl: twl@48 {
 + reg = 0x48;
 + interrupts = 7; /* SYS_NIRQ cascaded to intc */
 + interrupt-parent = intc;
 + };
 +};
 +
 +/include/ twl4030.dtsi
 +
 +twl_gpio {
 + ti,pullups  = 0x0;
 + ti,pulldowns= 0x03ff3f; /* BIT(0..5) | BIT(8..17) */
 +};
 +
 +i2c2 {
 + clock-frequency = 40;
 +};
 +
 +i2c3 {
 + clock-frequency = 10;
 +};
 +
 +mmc1 {
 + status = disabled;
 +};
 +
 +mmc2 {
 + status = disabled;
 +};
 +
 +mmc3 {
 + status = disabled;
 +};
 +
 +mcspi1 {
 + // For some reason, touchscreen is neccessary for screen to work at 
 + // all on real hw. It works well without it on emulator.
 + //
 + // Also... order in the device tree actually matters here.
 + tsc2005@0 {
 + compatible = tsc2005;
 + spi-max-frequency = 600;
 + reg = 0;
 + };
 + mipid@2 {
 + compatible = acx565akm;
 + spi-max-frequency = 600;
 + reg = 2;
 + // turbo_mode = 0,
 + // cs_per_word = 0
 + };
 +};
 +
 +usb_otg_hs {
 + interface-type = 0;
 + usb-phy = usb2_phy;
 + mode = 2;
 + power = 50;
 +};
 
 -- 
 (english) http://www.livejournal.com/~pavelmachek
 (cesky, pictures) 
 http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


v3.11-rc1 USB regressions

2013-07-15 Thread Aaro Koskinen
Hi,

I think USB tree introduced regressions in v3.11-rc1, at least for some
OMAP devices using legacy boot. I have only bisected these; I have no
idea what the real fixes are but the following reverts make Nokia OMAP2+
boards again usable for kernel development work (they need working USB
connection for interacting with the device):

1) USB peripheral mode (g_ether) is broken on Nokia N900, N950 and N9
   (USB_MUSB_OMAP2PLUS). To make it it work, I need to revert three
   commits:

09fc7d22b024692b2fe8a943b246de1af307132b
usb: musb: fix incorrect usage of resource pointer
(Reverting this fixes the g_ether probe failure couldn't find
 an available UDC)

fe4cb0912f8e737f8e4b8b38b9e692f8062f5423
usb: musb: gadget: remove hcd initialization
(Reverting this fixes error cdc_ether: probe of 4-1:1.0 failed
 with error -110 seen on the host side.)

8b125df5b24cfb0ec7fa1971e343cc0badc1827d
usb: musb: eliminate musb_to_hcd
(Reverting this fixes compilation error cause by the previous
 revert.)

2) USB peripheral mode (g_ether) is broken also on Nokia N800 and N810
   (USB_MUSB_TUSB6010). In addition to the above, I need to also revert
   the following:

b7e2e75a8c6062afe1dd88b0b299938e5d36dff8
usb: gadget: drop unused USB_GADGET_MUSB_HDRC

   (This commit is clearly incorrect - code checking for this still
   remain in the tree (see e.g. N8x0 board file), so it's not unused.)

A.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >