[PATCH] i2c: vt8500: Add support for Wondermedia I2C master-mode

2012-12-27 Thread Tony Prisk
This patch adds support for the I2C controller found on Wondermedia
SoCs.

Due to the lack of pinmux support, GPIO pin alternate functions are
configured by machine's compatible property, as are pullups.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 .../devicetree/bindings/i2c/i2c-vt8500.txt |   24 +
 drivers/i2c/busses/Kconfig |7 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-wmt.c   |  636 
 4 files changed, 668 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-vt8500.txt
 create mode 100644 drivers/i2c/busses/i2c-wmt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt 
b/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt
new file mode 100644
index 000..94a425e
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt
@@ -0,0 +1,24 @@
+* Wondermedia I2C Controller
+
+Required properties :
+
+ - compatible : should be wm,wm8505-i2c
+ - reg : Offset and length of the register set for the device
+ - interrupts : IRQ where IRQ is the interrupt number
+ - clocks : phandle to the I2C clock source
+
+Optional properties :
+
+ - clock-frequency : desired I2C bus clock frequency in Hz.
+   Valid values are 10 and 40.
+   Default to 10 if not specified, or invalid value.
+
+Example :
+
+   i2c_0: i2c@d828 {
+   compatible = wm,wm8505-i2c;
+   reg = 0xd828 0x1000;
+   interrupts = 19;
+   clocks = clki2c0;
+   clock-frequency = 40;
+   };
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index bdca511..41270fa 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -700,6 +700,13 @@ config I2C_VERSATILE
  This driver can also be built as a module.  If so, the module
  will be called i2c-versatile.
 
+config I2C_WMT
+   tristate Wondermedia I2C Controller support
+   depends on ARCH_VT8500
+   help
+ If you say yes to this option, support will be included for the
+ I2C controllers found in Wondermedia SoCs.
+
 config I2C_OCTEON
tristate Cavium OCTEON I2C bus support
depends on CPU_CAVIUM_OCTEON
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 6181f3f..dce6299 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_I2C_SIRF)+= i2c-sirf.o
 obj-$(CONFIG_I2C_STU300)   += i2c-stu300.o
 obj-$(CONFIG_I2C_TEGRA)+= i2c-tegra.o
 obj-$(CONFIG_I2C_VERSATILE)+= i2c-versatile.o
+obj-$(CONFIG_I2C_WMT)  += i2c-wmt.o
 obj-$(CONFIG_I2C_OCTEON)   += i2c-octeon.o
 obj-$(CONFIG_I2C_XILINX)   += i2c-xiic.o
 obj-$(CONFIG_I2C_XLR)  += i2c-xlr.o
diff --git a/drivers/i2c/busses/i2c-wmt.c b/drivers/i2c/busses/i2c-wmt.c
new file mode 100644
index 000..07d86e3
--- /dev/null
+++ b/drivers/i2c/busses/i2c-wmt.c
@@ -0,0 +1,636 @@
+/*
+ *  Wondermedia I2C Master Mode Driver
+ *
+ *  Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
+ *
+ *  Derived from GPL licensed source:
+ *  - Copyright (C) 2008 WonderMedia Technologies, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/i2c.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_i2c.h
+#include linux/of_irq.h
+#include linux/platform_device.h
+
+#define REG_CR 0x00
+#define REG_TCR0x02
+#define REG_CSR0x04
+#define REG_ISR0x06
+#define REG_IMR0x08
+#define REG_CDR0x0A
+#define REG_TR 0x0C
+#define REG_MCR0x0E
+#define REG_SLAVE_CR   0x10
+#define REG_SLAVE_SR   0x12
+#define REG_SLAVE_ISR  0x14
+#define REG_SLAVE_IMR  0x16
+#define REG_SLAVE_DR   0x18
+#define REG_SLAVE_TR   0x1A
+
+/* REG_CR Bit fields */
+#define CR_TX_NEXT_ACK 0x
+#define CR_ENABLE  0x0001
+#define CR_TX_NEXT_NO_ACK  0x0002
+#define CR_TX_END  0x0004
+#define CR_CPU_RDY 0x0008
+#define SLAV_MODE_SEL  0x8000
+
+/* REG_TCR Bit fields */
+#define TCR_STANDARD_MODE  0x
+#define TCR_MASTER_WRITE   0x
+#define TCR_HS_MODE0x2000
+#define TCR_MASTER_READ0x4000
+#define TCR_FAST_MODE  0x8000
+#define TCR_SLAVE_ADDR_MASK0x007F
+
+/* REG_ISR Bit fields */
+#define ISR_NACK_ADDR  0x0001
+#define ISR_BYTE_END   0x0002
+#define ISR_SCL_TIMEOUT0x0004
+#define ISR_WRITE_ALL  0x0007
+
+/* REG_IMR Bit fields */
+#define

[PATCH 3/4 v2] arm: vt8500: Convert debug-macro.S to be multiplatform friendly

2012-12-28 Thread Tony Prisk
This patch moves debug-macro.S from arm/mach-vt8500/include/mach to
arm/include/debug/vt8500.S to provide multiplatform support.

Minor style changes in code for readability.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
Patch resend due to missing arch/arm/include/debug/vt8500.S

 arch/arm/Kconfig.debug  |8 +
 arch/arm/include/debug/vt8500.S |   37 +++
 arch/arm/mach-vt8500/include/mach/debug-macro.S |   31 ---
 3 files changed, 45 insertions(+), 31 deletions(-)
 create mode 100644 arch/arm/include/debug/vt8500.S
 delete mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 661030d..bbb0a67 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -412,6 +412,13 @@ choice
  of the tiles using the RS1 memory map, including all new 
A-class
  core tiles, FPGA-based SMMs and software models.
 
+   config DEBUG_VT8500_UART0
+   bool Use UART0 on VIA/Wondermedia SoCs
+   depends on ARCH_VT8500
+   help
+ This option selects UART0 on VIA/Wondermedia System-on-a-chip
+ devices, including VT8500, WM8505, WM8650 and WM8850.
+
config DEBUG_LL_UART_NONE
bool No low-level debugging UART
depends on !ARCH_MULTIPLATFORM
@@ -506,6 +513,7 @@ config DEBUG_LL_INCLUDE
default debug/sunxi.S if DEBUG_SUNXI_UART0 || DEBUG_SUNXI_UART1
default debug/vexpress.S if DEBUG_VEXPRESS_UART0_DETECT || \
DEBUG_VEXPRESS_UART0_CA9 || DEBUG_VEXPRESS_UART0_RS1
+   default debug/vt8500.S if DEBUG_VT8500_UART0
default debug/tegra.S if DEBUG_TEGRA_UART
default debug/zynq.S if DEBUG_ZYNQ_UART0 || DEBUG_ZYNQ_UART1
default mach/debug-macro.S
diff --git a/arch/arm/include/debug/vt8500.S b/arch/arm/include/debug/vt8500.S
new file mode 100644
index 000..0e0ca08
--- /dev/null
+++ b/arch/arm/include/debug/vt8500.S
@@ -0,0 +1,37 @@
+/* 
+ * Debugging macro include header
+ *
+ *  Copyright (C) 2010 Alexey Charkov alch...@gmail.com
+ *Moved from arch/arm/mach-vt8500/include/mach/debug-macro.S
+ *Minor changes for readability.
+ *
+ * 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.
+ */
+
+#define DEBUG_LL_PHYS_BASE 0xD800
+#define DEBUG_LL_VIRT_BASE 0xF800
+#define DEBUG_LL_UART_OFFSET   0x0020
+
+#if defined(CONFIG_DEBUG_VT8500_UART0)
+   .macro  addruart, rp, rv, tmp
+   mov \rp,  #DEBUG_LL_UART_OFFSET
+   orr \rv, \rp, #DEBUG_LL_VIRT_BASE
+   orr \rp, \rp, #DEBUG_LL_PHYS_BASE
+   .endm
+
+   .macro  senduart,rd,rx
+   strb\rd, [\rx, #0]
+   .endm
+
+   .macro  busyuart,rd,rx
+1001:  ldr \rd, [\rx, #0x1c]
+   ands\rd, \rd, #0x2
+   bne 1001b
+   .endm
+
+   .macro  waituart,rd,rx
+   .endm
+
+#endif
diff --git a/arch/arm/mach-vt8500/include/mach/debug-macro.S 
b/arch/arm/mach-vt8500/include/mach/debug-macro.S
deleted file mode 100644
index ca292f2..000
--- a/arch/arm/mach-vt8500/include/mach/debug-macro.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * arch/arm/mach-vt8500/include/mach/debug-macro.S
- *
- *  Copyright (C) 2010 Alexey Charkov alch...@gmail.com
- *
- * Debugging macro include header
- *
- * 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.
- *
-*/
-
-   .macro  addruart, rp, rv, tmp
-   mov \rp,  #0x0020
-   orr \rv, \rp, #0xf800
-   orr \rp, \rp, #0xd800
-   .endm
-
-   .macro  senduart,rd,rx
-   strb\rd, [\rx, #0]
-   .endm
-
-   .macro  busyuart,rd,rx
-1001:  ldr \rd, [\rx, #0x1c]
-   ands\rd, \rd, #0x2
-   bne 1001b
-   .endm
-
-   .macro  waituart,rd,rx
-   .endm
-- 
1.7.9.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 3/4] arm: vt8500: Convert debug-macro.S to be multiplatform friendly

2012-12-28 Thread Tony Prisk
On Fri, 2012-12-28 at 10:21 +0600, Alexey Charkov wrote:
 
 On Dec 28, 2012 3:21 AM, Tony Prisk li...@prisktech.co.nz wrote:
 
  This patch moves debug-macro.S from arm/mach-vt8500/include/mach to
  arm/include/debug/vt8500.S to provide multiplatform support.
 
 Hi Tony!
 
 Looks like you haven't included the new file.
 
 Best,
 Alexey
 

Thanks Alexey,
Resent as 3/4 v2.

Regards
Tony P

--
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] rtc: vt8500: Fix handling of data passed in struct rtc_time

2012-12-29 Thread Tony Prisk
tm_mon is 0..11, whereas vt8500 expects 1..12 for the month field,
causing invalid date errors for January, and causing the day field
to roll over incorrectly.

The century flag is only handled in vt8500_rtc_read_time, but not
set in vt8500_rtc_set_time. This patch corrects the behaviour of the
century flag.

Signed-off-by: Edgar Toernig fro...@gmx.de
Signed-off-by: Tony Prisk li...@prisktech.co.nz
---

This patch is based on 3.8rc1 with the previous fix applied:

Previous patch: 77cdf96a0654cb45b4dd530f3393c6a8f2fa1e0b
rtc: vt8500: Correct handling of CR_24H bitfield

 drivers/rtc/rtc-vt8500.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c
index 387edf6..2448f2a 100644
--- a/drivers/rtc/rtc-vt8500.c
+++ b/drivers/rtc/rtc-vt8500.c
@@ -119,7 +119,7 @@ static int vt8500_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
tm-tm_min = bcd2bin((time  TIME_MIN_MASK)  TIME_MIN_S);
tm-tm_hour = bcd2bin((time  TIME_HOUR_MASK)  TIME_HOUR_S);
tm-tm_mday = bcd2bin(date  DATE_DAY_MASK);
-   tm-tm_mon = bcd2bin((date  DATE_MONTH_MASK)  DATE_MONTH_S);
+   tm-tm_mon = bcd2bin((date  DATE_MONTH_MASK)  DATE_MONTH_S) - 1;
tm-tm_year = bcd2bin((date  DATE_YEAR_MASK)  DATE_YEAR_S)
+ ((date  DATE_CENTURY_S)  1 ? 200 : 100);
tm-tm_wday = (time  TIME_DOW_MASK)  TIME_DOW_S;
@@ -138,8 +138,9 @@ static int vt8500_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
}
 
writel((bin2bcd(tm-tm_year - 100)  DATE_YEAR_S)
-   | (bin2bcd(tm-tm_mon)  DATE_MONTH_S)
-   | (bin2bcd(tm-tm_mday)),
+   | (bin2bcd(tm-tm_mon + 1)  DATE_MONTH_S)
+   | (bin2bcd(tm-tm_mday))
+   | ((tm-tm_year = 200)  DATE_CENTURY_S),
vt8500_rtc-regbase + VT8500_RTC_DS);
writel((bin2bcd(tm-tm_wday)  TIME_DOW_S)
| (bin2bcd(tm-tm_hour)  TIME_HOUR_S)
-- 
1.7.9.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] rtc: vt8500: Fix year field in vt8500_rtc_set_time

2012-12-30 Thread Tony Prisk
year field is incorrectly masked when setting the date. If the year
is beyond 2099, the year field will be incorrectly updated in hardware.

This patch masks the year field correctly.

Signed-off-by: Edgar Toernig fro...@gmx.de
Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
Patch based on 3.8-rc1

 drivers/rtc/rtc-vt8500.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c
index 14e2d8c..37b42a4 100644
--- a/drivers/rtc/rtc-vt8500.c
+++ b/drivers/rtc/rtc-vt8500.c
@@ -137,7 +137,7 @@ static int vt8500_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
return -EINVAL;
}
 
-   writel((bin2bcd(tm-tm_year - 100)  DATE_YEAR_S)
+   writel((bin2bcd(tm-tm_year % 100)  DATE_YEAR_S)
| (bin2bcd(tm-tm_mon)  DATE_MONTH_S)
| (bin2bcd(tm-tm_mday)),
vt8500_rtc-regbase + VT8500_RTC_DS);
-- 
1.7.9.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 1/2] pwm: vt8500: Register write busy test performed incorrectly

2012-12-30 Thread Tony Prisk
Correct operation for register writes is to perform a busy-wait
after writing the register. Currently the busy wait it performed
before, meaning subsequent register writes to bitfields may occur
before the previous field has been updated.

Also, all registers are defined as 32-bit read/write. Change
pwm_busy_wait() to use readl rather than readb.

Improve readability of code with defines for registers and bitfields.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
Thierry,

This patch is a fix but it can go to 3.9 rather than 3.8 (if you prefer)
as the incorrect behaviour doesn't seem to cause a problem on current
hardware.

 drivers/pwm/pwm-vt8500.c |   62 +++---
 1 file changed, 48 insertions(+), 14 deletions(-)

diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c
index b0ba2d4..27ed0f4 100644
--- a/drivers/pwm/pwm-vt8500.c
+++ b/drivers/pwm/pwm-vt8500.c
@@ -36,6 +36,25 @@
  */
 #define VT8500_NR_PWMS 2
 
+#define REG_CTRL(pwm)  (pwm  4) + 0x00
+#define REG_SCALAR(pwm)(pwm  4) + 0x04
+#define REG_PERIOD(pwm)(pwm  4) + 0x08
+#define REG_DUTY(pwm)  (pwm  4) + 0x0C
+#define REG_STATUS 0x40
+
+#define CTRL_ENABLEBIT(0)
+#define CTRL_INVERTBIT(1)
+#define CTRL_AUTOLOAD  BIT(2)
+#define CTRL_STOP_IMM  BIT(3)
+#define CTRL_LOAD_PRESCALE BIT(4)
+#define CTRL_LOAD_PERIOD   BIT(5)
+
+#define STATUS_CTRL_UPDATE BIT(0)
+#define STATUS_SCALAR_UPDATE   BIT(1)
+#define STATUS_PERIOD_UPDATE   BIT(2)
+#define STATUS_DUTY_UPDATE BIT(3)
+#define STATUS_ALL_UPDATE  0x0F
+
 struct vt8500_chip {
struct pwm_chip chip;
void __iomem *base;
@@ -45,15 +64,17 @@ struct vt8500_chip {
 #define to_vt8500_chip(chip)   container_of(chip, struct vt8500_chip, chip)
 
 #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
-static inline void pwm_busy_wait(void __iomem *reg, u8 bitmask)
+static inline void pwm_busy_wait(struct vt8500_chip *vt8500, int nr, u8 
bitmask)
 {
int loops = msecs_to_loops(10);
-   while ((readb(reg)  bitmask)  --loops)
+   u32 mask = bitmask  (nr  8);
+
+   while ((readl(vt8500-base + REG_STATUS)  mask)  --loops)
cpu_relax();
 
if (unlikely(!loops))
pr_warn(Waiting for status bits 0x%x to clear timed out\n,
-  bitmask);
+  mask);
 }
 
 static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
@@ -63,6 +84,7 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct 
pwm_device *pwm,
unsigned long long c;
unsigned long period_cycles, prescale, pv, dc;
int err;
+   u32 val;
 
err = clk_enable(vt8500-clk);
if (err  0) {
@@ -91,14 +113,19 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct 
pwm_device *pwm,
do_div(c, period_ns);
dc = c;
 
-   pwm_busy_wait(vt8500-base + 0x40 + pwm-hwpwm, (1  1));
-   writel(prescale, vt8500-base + 0x4 + (pwm-hwpwm  4));
+   writel(prescale, vt8500-base + REG_SCALAR(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_SCALAR_UPDATE);
+
+   writel(pv, vt8500-base + REG_PERIOD(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_PERIOD_UPDATE);
 
-   pwm_busy_wait(vt8500-base + 0x40 + pwm-hwpwm, (1  2));
-   writel(pv, vt8500-base + 0x8 + (pwm-hwpwm  4));
+   writel(dc, vt8500-base + REG_DUTY(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_DUTY_UPDATE);
 
-   pwm_busy_wait(vt8500-base + 0x40 + pwm-hwpwm, (1  3));
-   writel(dc, vt8500-base + 0xc + (pwm-hwpwm  4));
+   val = readl(vt8500-base + REG_CTRL(pwm-hwpwm));
+   val |= CTRL_AUTOLOAD;
+   writel(val, vt8500-base + REG_CTRL(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_CTRL_UPDATE);
 
clk_disable(vt8500-clk);
return 0;
@@ -106,8 +133,9 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct 
pwm_device *pwm,
 
 static int vt8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-   int err;
struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
+   int err;
+   u32 val;
 
err = clk_enable(vt8500-clk);
if (err  0) {
@@ -115,17 +143,23 @@ static int vt8500_pwm_enable(struct pwm_chip *chip, 
struct pwm_device *pwm)
return err;
}
 
-   pwm_busy_wait(vt8500-base + 0x40 + pwm-hwpwm, (1  0));
-   writel(5, vt8500-base + (pwm-hwpwm  4));
+   val = readl(vt8500-base + REG_CTRL(pwm-hwpwm));
+   val |= CTRL_ENABLE;
+   writel(val, vt8500-base + REG_CTRL(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_CTRL_UPDATE);
+
return 0;
 }
 
 static void vt8500_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
+   u32 val;
 
-   pwm_busy_wait(vt8500-base + 0x40 + pwm

[PATCH 2/2] pwm: vt8500: Add support for .set_polarity

2012-12-30 Thread Tony Prisk
Add support to set polarity on pwm devices, allowing for inverted
duty cycles.

Also update the binding document to #pwm-cells = 3 to allow
passing the flags from devicetree.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 .../devicetree/bindings/pwm/vt8500-pwm.txt |7 ---
 drivers/pwm/pwm-vt8500.c   |   21 
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt 
b/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt
index bcc6367..f71cc8d 100644
--- a/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt
+++ b/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt
@@ -3,14 +3,15 @@ VIA/Wondermedia VT8500/WM8xxx series SoC PWM controller
 Required properties:
 - compatible: should be via,vt8500-pwm
 - reg: physical base address and length of the controller's registers
-- #pwm-cells: should be 2.  The first cell specifies the per-chip index
-  of the PWM to use and the second cell is the period in nanoseconds.
+- #pwm-cells: should be 3.  The first cell specifies the per-chip index
+  of the PWM to use, the second cell is the period in nanoseconds, and the
+  third cell is for flags.
 - clocks: phandle to the PWM source clock
 
 Example:
 
 pwm1: pwm@d822 {
-   #pwm-cells = 2;
+   #pwm-cells = 3;
compatible = via,vt8500-pwm;
reg = 0xd822 0x1000;
clocks = clkpwm;
diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c
index 27ed0f4..9abf561 100644
--- a/drivers/pwm/pwm-vt8500.c
+++ b/drivers/pwm/pwm-vt8500.c
@@ -164,10 +164,31 @@ static void vt8500_pwm_disable(struct pwm_chip *chip, 
struct pwm_device *pwm)
clk_disable(vt8500-clk);
 }
 
+static int vt8500_pwm_set_polarity(struct pwm_chip *chip,
+  struct pwm_device *pwm,
+  enum pwm_polarity polarity)
+{
+   struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
+   u32 val;
+
+   val = readl(vt8500-base + REG_CTRL(pwm-hwpwm));
+
+   if (polarity == PWM_POLARITY_INVERSED)
+   val |= CTRL_INVERT;
+   else
+   val = ~CTRL_INVERT;
+
+   writel(val, vt8500-base + REG_CTRL(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_CTRL_UPDATE);
+
+   return 0;
+}
+
 static struct pwm_ops vt8500_pwm_ops = {
.enable = vt8500_pwm_enable,
.disable = vt8500_pwm_disable,
.config = vt8500_pwm_config,
+   .set_polarity = vt8500_pwm_set_polarity,
.owner = THIS_MODULE,
 };
 
-- 
1.7.9.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] gpio: vt8500: Export dedicated GPIO before multifunction pins.

2012-12-30 Thread Tony Prisk
The vendor does not provide numbering for gpio pins. Vendor source
exports dedicated gpio pins first, followed by multifunction pins.
As this is what end users expect, this patch changes vt8500 and wm8505
to do the same.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/gpio/gpio-vt8500.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-vt8500.c b/drivers/gpio/gpio-vt8500.c
index b53320a..9a7c434 100644
--- a/drivers/gpio/gpio-vt8500.c
+++ b/drivers/gpio/gpio-vt8500.c
@@ -73,19 +73,20 @@ struct vt8500_gpio_data {
 static struct vt8500_gpio_data vt8500_data = {
.num_banks  = 7,
.banks  = {
+   VT8500_BANK(NO_REG, 0x3C, 0x5C, 0x7C, 9),
VT8500_BANK(0x00, 0x20, 0x40, 0x60, 26),
VT8500_BANK(0x04, 0x24, 0x44, 0x64, 28),
VT8500_BANK(0x08, 0x28, 0x48, 0x68, 31),
VT8500_BANK(0x0C, 0x2C, 0x4C, 0x6C, 19),
VT8500_BANK(0x10, 0x30, 0x50, 0x70, 19),
VT8500_BANK(0x14, 0x34, 0x54, 0x74, 23),
-   VT8500_BANK(NO_REG, 0x3C, 0x5C, 0x7C, 9),
},
 };
 
 static struct vt8500_gpio_data wm8505_data = {
.num_banks  = 10,
.banks  = {
+   VT8500_BANK(0x64, 0x8C, 0xB4, 0xDC, 22),
VT8500_BANK(0x40, 0x68, 0x90, 0xB8, 8),
VT8500_BANK(0x44, 0x6C, 0x94, 0xBC, 32),
VT8500_BANK(0x48, 0x70, 0x98, 0xC0, 6),
@@ -95,7 +96,6 @@ static struct vt8500_gpio_data wm8505_data = {
VT8500_BANK(0x58, 0x80, 0xA8, 0xD0, 5),
VT8500_BANK(0x5C, 0x84, 0xAC, 0xD4, 12),
VT8500_BANK(0x60, 0x88, 0xB0, 0xD8, 16),
-   VT8500_BANK(0x64, 0x8C, 0xB4, 0xDC, 22),
VT8500_BANK(0x500, 0x504, 0x508, 0x50C, 6),
},
 };
-- 
1.7.9.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] mtd: vt8500: Add support for Wondermedia Serial Flash Controller

2012-12-30 Thread Tony Prisk
This patch adds support for the Wondermedia serial flash controller
found on WM8505, WM8650 and WM8850 SoCs.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/mtd/devices/Kconfig  |7 +
 drivers/mtd/devices/Makefile |3 +-
 drivers/mtd/devices/wmt_sflash.c |  614 ++
 3 files changed, 623 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/devices/wmt_sflash.c

diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index 27f80cd..6c4bbd4 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -128,6 +128,13 @@ config MTD_BCM47XXSFLASH
  registered by bcma as platform devices. This enables driver for
  serial flash memories (only read-only mode is implemented).
 
+config MTD_WMT_SFLASH
+   tristate WonderMedia Serial Flash Support
+   depends on MTD
+   help
+ Enable this option to provide support for the Wondermedia SoC serial
+ flash controller.
+
 config MTD_SLRAM
tristate Uncached system RAM
help
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile
index 395733a..10b8bec 100644
--- a/drivers/mtd/devices/Makefile
+++ b/drivers/mtd/devices/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_DATAFLASH)   += mtd_dataflash.o
 obj-$(CONFIG_MTD_M25P80)   += m25p80.o
 obj-$(CONFIG_MTD_SPEAR_SMI)+= spear_smi.o
 obj-$(CONFIG_MTD_SST25L)   += sst25l.o
+obj-$(CONFIG_MTD_WMT_SFLASH)   += wmt_sflash.o
 obj-$(CONFIG_MTD_BCM47XXSFLASH)+= bcm47xxsflash.o
 
-CFLAGS_docg3.o += -I$(src)
\ No newline at end of file
+CFLAGS_docg3.o += -I$(src)
diff --git a/drivers/mtd/devices/wmt_sflash.c b/drivers/mtd/devices/wmt_sflash.c
new file mode 100644
index 000..f6b5a15
--- /dev/null
+++ b/drivers/mtd/devices/wmt_sflash.c
@@ -0,0 +1,614 @@
+/*
+ * Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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/clk.h
+#include linux/errno.h
+#include linux/module.h
+#include linux/platform_device.h
+
+#include linux/of.h
+#include linux/of_device.h
+#include linux/of_address.h
+
+#include linux/mtd/mtd.h
+
+/* controller only supports erase size of 64KB */
+#define WMT_ERASESIZE  0x1
+
+/* Serial Flash controller register offsets */
+#define SF_CHIP_SEL_0_CFG  0x000
+#define SF_CHIP_SEL_1_CFG  0x008
+#define SF_SPI_INTF_CFG0x040
+#define SF_SPI_RD_WR_CTR   0x050
+#define SF_SPI_WR_EN_CTR   0x060
+#define SF_SPI_ER_CTR  0x070
+#define SF_SPI_ER_START_ADDR   0x074
+#define SF_SPI_ERROR_STATUS0x080
+#define SF_SPI_MEM_0_SR_ACC0x100
+#define SF_SPI_MEM_1_SR_ACC0x110
+#define SF_SPI_PDWN_CTR_0  0x180
+#define SF_SPI_PDWN_CTR_1  0x190
+#define SF_SPI_PROG_CMD_CTR0x200
+#define SF_SPI_USER_CMD_VAL0x210
+#define SF_SPI_PROG_CMD_WBF0x300   /* 64 bytes */
+#define SF_SPI_PROG_CMD_RBF0x380   /* 64 bytes */
+
+/* SF_SPI_WR_EN_CTR bit fields */
+#define SF_CS0_WR_EN   BIT(0)
+#define SF_CS1_WR_EN   BIT(1)
+
+/* SF_SPI_ER_CTR bit fields */
+#define SF_SEC_ER_EN   BIT(31)
+
+/* SF_SPI_ERROR_STATUS bit fields */
+#define SF_ERR_TIMEOUT BIT(31)
+#define SF_ERR_WR_PROT_ERR BIT(5)
+#define SF_ERR_MEM_REGION_ERR  BIT(4)
+#define SF_ERR_PWR_DWN_ACC_ERR BIT(3)
+#define SF_ERR_PCMD_OP_ERR BIT(2)
+#define SF_ERR_PCMD_ACC_ERRBIT(1)
+#define SF_ERR_MASLOCK_ERR BIT(0)
+
+/*
+ * Serial Flash device manufacturers
+ * Please keep sorted by manufacturers ID
+ */
+#define MFR_SPANSION   0x01
+#define MFR_EON0x1C
+#define MFR_ATMEL  0x1F
+#define MFR_NUMONYX0x20
+#define MFR_FUDAN  0xA1
+#define MFR_SST0xBF
+#define MFR_MXIC   0xC2
+#define MFR_WINBOND0xEF
+
+/*
+ * SF Device Models
+ * Please keep in the same order as the manufacturers table
+ */
+
+/* Spansion */
+#define SPAN_FL016A0x0214 /* 2 MB */
+#define SPAN_FL064A0x0216 /* 8 MB */
+
+/* Eon */
+#define EON_25P16  0x2015 /* 2 MB */
+#define EON_25P64  0x2017 /* 8 MB */
+#define EON_25F40  0x3113 /* 512 KB */
+#define EON_25F16  0x3115 /* 2 MB

[PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller

2012-12-30 Thread Tony Prisk
This patch adds support for the Wondermedia serial flash controller
found on WM8505, WM8650 and WM8850 SoCs.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
v2: Whitespace tidyup

 drivers/mtd/devices/Kconfig  |7 +
 drivers/mtd/devices/Makefile |3 +-
 drivers/mtd/devices/wmt_sflash.c |  614 ++
 3 files changed, 623 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/devices/wmt_sflash.c

diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index 27f80cd..6c4bbd4 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -128,6 +128,13 @@ config MTD_BCM47XXSFLASH
  registered by bcma as platform devices. This enables driver for
  serial flash memories (only read-only mode is implemented).
 
+config MTD_WMT_SFLASH
+   tristate WonderMedia Serial Flash Support
+   depends on MTD
+   help
+ Enable this option to provide support for the Wondermedia SoC serial
+ flash controller.
+
 config MTD_SLRAM
tristate Uncached system RAM
help
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile
index 395733a..10b8bec 100644
--- a/drivers/mtd/devices/Makefile
+++ b/drivers/mtd/devices/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_DATAFLASH)   += mtd_dataflash.o
 obj-$(CONFIG_MTD_M25P80)   += m25p80.o
 obj-$(CONFIG_MTD_SPEAR_SMI)+= spear_smi.o
 obj-$(CONFIG_MTD_SST25L)   += sst25l.o
+obj-$(CONFIG_MTD_WMT_SFLASH)   += wmt_sflash.o
 obj-$(CONFIG_MTD_BCM47XXSFLASH)+= bcm47xxsflash.o
 
-CFLAGS_docg3.o += -I$(src)
\ No newline at end of file
+CFLAGS_docg3.o += -I$(src)
diff --git a/drivers/mtd/devices/wmt_sflash.c b/drivers/mtd/devices/wmt_sflash.c
new file mode 100644
index 000..49359ea
--- /dev/null
+++ b/drivers/mtd/devices/wmt_sflash.c
@@ -0,0 +1,614 @@
+/*
+ * Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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/clk.h
+#include linux/errno.h
+#include linux/module.h
+#include linux/platform_device.h
+
+#include linux/of.h
+#include linux/of_device.h
+#include linux/of_address.h
+
+#include linux/mtd/mtd.h
+
+/* controller only supports erase size of 64KB */
+#define WMT_ERASESIZE  0x1
+
+/* Serial Flash controller register offsets */
+#define SF_CHIP_SEL_0_CFG  0x000
+#define SF_CHIP_SEL_1_CFG  0x008
+#define SF_SPI_INTF_CFG0x040
+#define SF_SPI_RD_WR_CTR   0x050
+#define SF_SPI_WR_EN_CTR   0x060
+#define SF_SPI_ER_CTR  0x070
+#define SF_SPI_ER_START_ADDR   0x074
+#define SF_SPI_ERROR_STATUS0x080
+#define SF_SPI_MEM_0_SR_ACC0x100
+#define SF_SPI_MEM_1_SR_ACC0x110
+#define SF_SPI_PDWN_CTR_0  0x180
+#define SF_SPI_PDWN_CTR_1  0x190
+#define SF_SPI_PROG_CMD_CTR0x200
+#define SF_SPI_USER_CMD_VAL0x210
+#define SF_SPI_PROG_CMD_WBF0x300   /* 64 bytes */
+#define SF_SPI_PROG_CMD_RBF0x380   /* 64 bytes */
+
+/* SF_SPI_WR_EN_CTR bit fields */
+#define SF_CS0_WR_EN   BIT(0)
+#define SF_CS1_WR_EN   BIT(1)
+
+/* SF_SPI_ER_CTR bit fields */
+#define SF_SEC_ER_EN   BIT(31)
+
+/* SF_SPI_ERROR_STATUS bit fields */
+#define SF_ERR_TIMEOUT BIT(31)
+#define SF_ERR_WR_PROT_ERR BIT(5)
+#define SF_ERR_MEM_REGION_ERR  BIT(4)
+#define SF_ERR_PWR_DWN_ACC_ERR BIT(3)
+#define SF_ERR_PCMD_OP_ERR BIT(2)
+#define SF_ERR_PCMD_ACC_ERRBIT(1)
+#define SF_ERR_MASLOCK_ERR BIT(0)
+
+/*
+ * Serial Flash device manufacturers
+ * Please keep sorted by manufacturers ID
+ */
+#define MFR_SPANSION   0x01
+#define MFR_EON0x1C
+#define MFR_ATMEL  0x1F
+#define MFR_NUMONYX0x20
+#define MFR_FUDAN  0xA1
+#define MFR_SST0xBF
+#define MFR_MXIC   0xC2
+#define MFR_WINBOND0xEF
+
+/*
+ * SF Device Models
+ * Please keep in the same order as the manufacturers table
+ */
+
+/* Spansion */
+#define SPAN_FL016A0x0214 /* 2 MB */
+#define SPAN_FL064A0x0216 /* 8 MB */
+
+/* Eon */
+#define EON_25P16  0x2015 /* 2 MB */
+#define EON_25P64  0x2017 /* 8 MB */
+#define EON_25F40  0x3113 /* 512 KB */
+#define EON_25F16

[PATCH] input: vt8500: Add power button keypad driver

2012-12-30 Thread Tony Prisk
This patch adds support for the Power Button keypad found on
Wondermedia netbooks/tablets.

A keymap property is exposed to allowing defining the key
event to be generated when the power button is pressed.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 .../bindings/input/vt8500-power-keypad.txt |   17 ++
 drivers/input/keyboard/Kconfig |   10 ++
 drivers/input/keyboard/Makefile|1 +
 drivers/input/keyboard/wmt_power_keypad.c  |  174 
 4 files changed, 202 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/vt8500-power-keypad.txt
 create mode 100644 drivers/input/keyboard/wmt_power_keypad.c

diff --git a/Documentation/devicetree/bindings/input/vt8500-power-keypad.txt 
b/Documentation/devicetree/bindings/input/vt8500-power-keypad.txt
new file mode 100644
index 000..bae6228
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/vt8500-power-keypad.txt
@@ -0,0 +1,17 @@
+* Wondermedia Power Keypad device tree bindings
+
+Wondermedia SoCs have a single irq-driven power button attached to
+the power management controller.
+
+Required SoC Specific Properties:
+- compatible: should be one of the following
+   - wm,power-keypad: For all Wondermedia 8xxx-series SoCs.
+- interrupts: should be the power management controller wakeup interrupt.
+- keymap: linux keycode to generate when power button pressed.
+
+Example:
+   powerkey: pwrkey@0 {
+   compatible = wm,power-keypad;
+   interrupts = 22;
+   keymap = 116; /* KEY_POWER */
+   };
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 5a240c6..c270f27 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -595,6 +595,16 @@ config KEYBOARD_TWL4030
  To compile this driver as a module, choose M here: the
  module will be called twl4030_keypad.
 
+config KEYBOARD_WMT_POWER_KEYPAD
+   tristate Wondermedia Power keypad support
+   depends on ARCH_VT8500
+   help
+ Say Y here to enable support for the power button keypad
+ on Wondermedia 8xxx-series SoCs.
+
+ To compile this driver as a module, choose M here: the
+ module will be called wmt_power_keypad.
+
 config KEYBOARD_XTKBD
tristate XT keyboard
select SERIO
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 44e7600..eea31af 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -52,5 +52,6 @@ obj-$(CONFIG_KEYBOARD_TC3589X)+= 
tc3589x-keypad.o
 obj-$(CONFIG_KEYBOARD_TEGRA)   += tegra-kbc.o
 obj-$(CONFIG_KEYBOARD_TNETV107X)   += tnetv107x-keypad.o
 obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o
+obj-$(CONFIG_KEYBOARD_WMT_POWER_KEYPAD)+= wmt_power_keypad.o
 obj-$(CONFIG_KEYBOARD_XTKBD)   += xtkbd.o
 obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o
diff --git a/drivers/input/keyboard/wmt_power_keypad.c 
b/drivers/input/keyboard/wmt_power_keypad.c
new file mode 100644
index 000..ce8aa9a
--- /dev/null
+++ b/drivers/input/keyboard/wmt_power_keypad.c
@@ -0,0 +1,174 @@
+/* Wondermedia Power Keypad
+ *
+ * Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/input.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+#include linux/bitops.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/of_device.h
+
+static void __iomem *pmc_base;
+static struct input_dev *kpad_power;
+static spinlock_t kpad_power_lock;
+static int power_button_pressed;
+static struct timer_list kpad_power_timer;
+static unsigned int kpad_power_code;
+
+static inline void kpad_power_timeout(unsigned long fcontext)
+{
+   u32 status;
+   unsigned long flags;
+
+   spin_lock_irqsave(kpad_power_lock, flags);
+
+   status = readl(pmc_base + 0x14);
+
+   if (power_button_pressed) {
+   input_report_key(kpad_power, kpad_power_code, 0);
+   input_sync(kpad_power);
+   power_button_pressed = 0;
+   }
+
+   spin_unlock_irqrestore(kpad_power_lock, flags);
+}
+
+static irqreturn_t kpad_power_isr(int irq_num, void *data)
+{
+   u32 status;
+   unsigned long flags;
+
+   spin_lock_irqsave(kpad_power_lock, flags);
+
+   status = readl(pmc_base + 0x14

[RFC PATCH] Add support for devicetree to i8042 serio driver

2012-12-30 Thread Tony Prisk
Since this patch may adversely affect a lot of users, I thought I'd post this
as an RFC first. I don't think the changes should affect any existing i8042
implementations, but can never be certain.

Limitations:

This patch does not overcome the problem of only being able to select
a single i8042 platform at compile-time. If compiling for a multiplatform
kernel, all platforms must use the DT version or only one platform
can have i8042 support.

The DT version assumes memory-mapped i8042 registers. It can not handle
IO-mapped modules (eg. x86)

Tony Prisk (1):
  input: i8042: Add support for devicetree to i8042 serio driver

 .../devicetree/bindings/input/intel-8042.txt   |   29 +
 drivers/input/serio/Kconfig|   10 +-
 drivers/input/serio/i8042-dt.h |  127 
 drivers/input/serio/i8042.c|   15 ++-
 drivers/input/serio/i8042.h|4 +-
 5 files changed, 181 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/intel-8042.txt
 create mode 100644 drivers/input/serio/i8042-dt.h

-- 
1.7.9.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/


[RFC PATCH] input: i8042: Add support for devicetree to i8042 serio driver

2012-12-30 Thread Tony Prisk
This patch adds basic devicetree support for the i8042 controller
driver.

Simple properties to specify the register offsets.
Optional properties to specify the linux device descriptions.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 .../devicetree/bindings/input/intel-8042.txt   |   29 +
 drivers/input/serio/Kconfig|   10 +-
 drivers/input/serio/i8042-dt.h |  127 
 drivers/input/serio/i8042.c|   15 ++-
 drivers/input/serio/i8042.h|4 +-
 5 files changed, 181 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/intel-8042.txt
 create mode 100644 drivers/input/serio/i8042-dt.h

diff --git a/Documentation/devicetree/bindings/input/intel-8042.txt 
b/Documentation/devicetree/bindings/input/intel-8042.txt
new file mode 100644
index 000..68f6fa2
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/intel-8042.txt
@@ -0,0 +1,29 @@
+* Intel 8042 Keyboard controller
+
+Required properties:
+- compatible: should be intel,8042
+- regs: memory for keyboard controller
+- interrupts: two interrupts should be specified (keyboard and aux).
+- command-reg: offset in memory for command register
+- status-reg: offset in memory for status register
+- data-reg: offset in memory for data register
+
+Optional properties:
+- init-reset: Controller should be reset on init and cleanup
+
+Optional linux specific properties:
+- linux,kbd_phys_desc: defaults to i8042/serio0
+- linux,aux_phys_desc: defaults to i8042/serio1
+- linux,mux_phys_desc: defaults to i8042/serio%d
+
+
+Example:
+   keyboard@d8008800 {
+   compatible = intel,8042;
+   reg = 0xD8008800 0x100;
+   interrupts = 23 4;
+   command-reg = 0x04;
+   status-reg = 0x04;
+   data-reg = 0x00;
+   mux-ports = 2;
+   };
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index 4a4e182..26e97a3 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -21,8 +21,9 @@ if SERIO
 config SERIO_I8042
tristate i8042 PC Keyboard controller if EXPERT || !X86
default y
-   depends on !PARISC  (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST)  \
-  (!SUPERH || SH_CAYMAN)  !M68K  !BLACKFIN
+   depends on (!PARISC  (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST)  \
+  (!SUPERH || SH_CAYMAN)  !M68K  !BLACKFIN) || \
+  (SERIO_I8042_DT)
help
  i8042 is the chip over which the standard AT keyboard and PS/2
  mouse are connected to the computer. If you use these devices,
@@ -33,6 +34,11 @@ config SERIO_I8042
  To compile this driver as a module, choose M here: the
  module will be called i8042.
 
+config SERIO_I8042_DT
+   tristate i8042 Keyboard controller DT support if EXPERT || !X86
+   depends on USE_OF
+   select SERIO_I8042
+
 config SERIO_SERPORT
tristate Serial port line discipline
default y
diff --git a/drivers/input/serio/i8042-dt.h b/drivers/input/serio/i8042-dt.h
new file mode 100644
index 000..3875c90
--- /dev/null
+++ b/drivers/input/serio/i8042-dt.h
@@ -0,0 +1,127 @@
+#ifndef _I8042_DT_H
+#define _I8042_DT_H
+
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+
+/*
+ * 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.
+ */
+
+static void __iomem *dt_base;
+static const char *dt_kbd_phys_desc;
+static const char *dt_aux_phys_desc;
+static const char *dt_mux_phys_desc;
+static int dt_kbd_irq;
+static int dt_aux_irq;
+static unsigned int dt_command_reg;
+static unsigned int dt_status_reg;
+static unsigned int dt_data_reg;
+
+#define I8042_KBD_PHYS_DESCdt_kbd_phys_desc
+#define I8042_AUX_PHYS_DESCdt_aux_phys_desc
+#define I8042_MUX_PHYS_DESCdt_mux_phys_desc
+
+#define I8042_KBD_IRQ  (dt_kbd_irq)
+#define I8042_AUX_IRQ  (dt_aux_irq)
+
+#define I8042_COMMAND_REG  (dt_command_reg)
+#define I8042_STATUS_REG   (dt_status_reg)
+#define I8042_DATA_REG (dt_data_reg)
+
+
+static inline int i8042_read_data(void)
+{
+   return readb(dt_base + dt_data_reg);
+}
+
+static inline int i8042_read_status(void)
+{
+   return readb(dt_base + dt_status_reg);
+}
+
+static inline void i8042_write_data(int val)
+{
+   writeb(val, dt_base + dt_data_reg);
+}
+
+static inline void i8042_write_command(int val)
+{
+   writeb(val, dt_base + dt_command_reg);
+}
+
+static inline int dt_parse_node(struct device_node *np)
+{
+   int ret;
+
+   dt_base = of_iomap(np, 0);
+   if (!dt_base)
+   return -ENOMEM;
+
+   ret = of_property_read_u32(np, command-reg, dt_command_reg);
+   if (ret) {
+   pr_err(i8042-dt: command-reg missing

Re: [PATCH] input: vt8500: Add power button keypad driver

2012-12-30 Thread Tony Prisk
  +Example:
  +   powerkey: pwrkey@0 {
  +   compatible = wm,power-keypad;
  +   interrupts = 22;
  +   keymap = 116; /* KEY_POWER */
 
 Do we really need this in DT? I'd say just having it manageable from
 userspace is enough.

Just seemed easier this way. Will be changed.

  +config KEYBOARD_WMT_POWER_KEYPAD
  +   tristate Wondermedia Power keypad support
  +   depends on ARCH_VT8500
 
 I'd feel safer if we added depends on OF as well.
ARCH_VT8500 always selects USE_OF, but I can add it as well if you think
its necessary.

  +
  +static void __iomem *pmc_base;
  +static struct input_dev *kpad_power;
  +static spinlock_t kpad_power_lock;
  +static int power_button_pressed;
  +static struct timer_list kpad_power_timer;
  +static unsigned int kpad_power_code;
 
 Maybe wrap it in a structure?
Will do.

 
  +
  +static inline void kpad_power_timeout(unsigned long fcontext)
 
 Why inline? It can't be inlined anyway since its address is used.
 
Umm, no idea why this is inline. Will remove.

  +{
  +   u32 status;
  +   unsigned long flags;
  +
  +   spin_lock_irqsave(kpad_power_lock, flags);
  +
  +   status = readl(pmc_base + 0x14);
  +
  +   if (power_button_pressed) {
 
 This check is useless, you won't ever get here if button hasn't been
 pressed.
 
Hmm, correct. Will fix.

  +   status = readl(pmc_base + 0x14);
  +   udelay(100);
  +   writel(status, pmc_base + 0x14);
  +
  +   if (status  BIT(14)) {
  +   if (!power_button_pressed) {
 
 No need to do this check.
 
The hardware generates multiple interrupts when the button is held.
Without the !power_button_pressed, it will generate multiple pressed
events without releases, because the timer doesn't get to finish.

The interrupt is non-maskable.


  +static int vt8500_pwr_kpad_probe(struct platform_device *pdev)
  +{
  +   struct device_node *np;
  +   u32 status;
  +   int err;
  +   int irq;
  +
  +   np = of_find_compatible_node(NULL, NULL, via,vt8500-pmc);
  +   if (!np) {
  +   dev_err(pdev-dev, pmc node not found\n);
  +   return -EINVAL;
  +   }
  +
  +   pmc_base = of_iomap(np, 0);
  +   if (!pmc_base) {
  +   dev_err(pdev-dev, unable to map pmc memory\n);
  +   return -ENOMEM;
  +   }
  +
  +   np = pdev-dev.of_node;
  +   if (!np) {
  +   dev_err(pdev-dev, devicenode not found\n);
  +   return -ENODEV;
  +   }
  +
  +   err = of_property_read_u32(np, keymap, kpad_power_code);
  +   if (err) {
  +   dev_warn(pdev-dev, defaulting to KEY_POWER\n);
  +   kpad_power_code = KEY_POWER;
  +   }
  +
  +   /* set power button to soft-power */
  +   status = readl(pmc_base + 0x54);
  +   writel(status | 1, pmc_base + 0x54);
  +
  +   /* clear any pending interrupts */
  +   status = readl(pmc_base + 0x14);
  +   writel(status, pmc_base + 0x14);
  +
  +   kpad_power = input_allocate_device();
  +   if (!kpad_power) {
  +   dev_err(pdev-dev, failed to allocate input device\n);
  +   return -ENOMEM;
  +   }
  +
  +   spin_lock_init(kpad_power_lock);
  +   setup_timer(kpad_power_timer, kpad_power_timeout,
  +  (unsigned long)kpad_power);
  +
  +   irq = irq_of_parse_and_map(np, 0);
  +   err = request_irq(irq, kpad_power_isr, 0, pwrbtn, NULL);
  +   if (err  0) {
  +   dev_err(pdev-dev, failed to request irq\n);
  +   return err;
  +   }
  +
  +   kpad_power-evbit[0] = BIT_MASK(EV_KEY);
  +   set_bit(kpad_power_code, kpad_power-keybit);
  +
  +   kpad_power-name = wmt_power_keypad;
  +   kpad_power-phys = wmt_power_keypad;
  +   kpad_power-keycode = kpad_power_code;
  +   kpad_power-keycodesize = sizeof(unsigned int);
  +   kpad_power-keycodemax = 1;
  +
  +   err = input_register_device(kpad_power);
  +   if (err  0) {
  +   dev_err(pdev-dev, failed to register input device\n);
 
 You either need to use managed resources or clean up after yourself;
 leaking memory and other resources is not nice. Given that you are using
 timer, which needs to be canceled, and I am not sure if your device
 allows enabling/disabling generating interrupts while keeping the
 interrupt handler registered, manual cleanup looks like the only option
 for you.
 
 BTW, where is your remove() method?
Eeek. Too much turkey :) I will tidy this up and resubmit.

Thanks for the quick review.

Regards
Tony P

--
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] input: vt8500: Add power button keypad driver

2012-12-30 Thread Tony Prisk
This patch adds support for the Power Button keypad found on
Wondermedia netbooks/tablets.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
v2:
Remove devicetree binding for keycode
Add dependency on OF in Kconfig
Move static variables in a struct
Remove redundant inline modifier from kpad_power_timeout()
Remove unneccessary checks against power_button_pressed. Drop variable.
Cleanup the fail path code and add a .remove function.
Change the button behaviour so that a key-released event is only generated once
the key is released, not after timeout.
*Changes tested on WM8650 tablet.

 .../bindings/input/vt8500-power-keypad.txt |   15 ++
 drivers/input/keyboard/Kconfig |   10 +
 drivers/input/keyboard/Makefile|1 +
 drivers/input/keyboard/wmt_power_keypad.c  |  198 
 4 files changed, 224 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/vt8500-power-keypad.txt
 create mode 100644 drivers/input/keyboard/wmt_power_keypad.c

diff --git a/Documentation/devicetree/bindings/input/vt8500-power-keypad.txt 
b/Documentation/devicetree/bindings/input/vt8500-power-keypad.txt
new file mode 100644
index 000..63f170b
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/vt8500-power-keypad.txt
@@ -0,0 +1,15 @@
+* Wondermedia Power Keypad device tree bindings
+
+Wondermedia SoCs have a single irq-driven power button attached to
+the power management controller.
+
+Required SoC Specific Properties:
+- compatible: should be one of the following
+   - wm,power-keypad: For all Wondermedia 8xxx-series SoCs.
+- interrupts: should be the power management controller wakeup interrupt.
+
+Example:
+   powerkey: pwrkey@0 {
+   compatible = wm,power-keypad;
+   interrupts = 22;
+   };
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 5a240c6..bb1e04f 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -595,6 +595,16 @@ config KEYBOARD_TWL4030
  To compile this driver as a module, choose M here: the
  module will be called twl4030_keypad.
 
+config KEYBOARD_WMT_POWER_KEYPAD
+   tristate Wondermedia Power keypad support
+   depends on (OF  ARCH_VT8500)
+   help
+ Say Y here to enable support for the power button keypad
+ on Wondermedia 8xxx-series SoCs.
+
+ To compile this driver as a module, choose M here: the
+ module will be called wmt_power_keypad.
+
 config KEYBOARD_XTKBD
tristate XT keyboard
select SERIO
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 44e7600..eea31af 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -52,5 +52,6 @@ obj-$(CONFIG_KEYBOARD_TC3589X)+= 
tc3589x-keypad.o
 obj-$(CONFIG_KEYBOARD_TEGRA)   += tegra-kbc.o
 obj-$(CONFIG_KEYBOARD_TNETV107X)   += tnetv107x-keypad.o
 obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o
+obj-$(CONFIG_KEYBOARD_WMT_POWER_KEYPAD)+= wmt_power_keypad.o
 obj-$(CONFIG_KEYBOARD_XTKBD)   += xtkbd.o
 obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o
diff --git a/drivers/input/keyboard/wmt_power_keypad.c 
b/drivers/input/keyboard/wmt_power_keypad.c
new file mode 100644
index 000..f3b24d8
--- /dev/null
+++ b/drivers/input/keyboard/wmt_power_keypad.c
@@ -0,0 +1,198 @@
+/* Wondermedia Power Keypad
+ *
+ * Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/input.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+#include linux/bitops.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/of_device.h
+
+struct kpad_pwr_data {
+   struct input_dev*kpad_power;
+   void __iomem*pmc_base;
+   int irq;
+   struct timer_list   timer;
+   spinlock_t  lock;
+   unsigned intkeycode;
+};
+
+static void kpad_power_timeout(unsigned long fcontext)
+{
+   struct kpad_pwr_data *data = (struct kpad_pwr_data *)fcontext;
+   u32 status;
+   unsigned long flags;
+
+   spin_lock_irqsave(data-lock, flags);
+
+   status = readl(data-pmc_base + 0x14);
+   if (status  BIT(14)) {
+   /* Button isn't release so check again in 50ms */
+   mod_timer(data-timer

Re: [PATCH v2] input: vt8500: Add power button keypad driver

2012-12-31 Thread Tony Prisk
On Mon, 2012-12-31 at 12:37 -0800, Dmitry Torokhov wrote:
 Hi Tony,
 
 On Mon, Dec 31, 2012 at 03:04:59PM +1300, Tony Prisk wrote:
  This patch adds support for the Power Button keypad found on
  Wondermedia netbooks/tablets.
  
  Signed-off-by: Tony Prisk li...@prisktech.co.nz
  ---
  v2:
  Remove devicetree binding for keycode
  Add dependency on OF in Kconfig
  Move static variables in a struct
  Remove redundant inline modifier from kpad_power_timeout()
  Remove unneccessary checks against power_button_pressed. Drop variable.
  Cleanup the fail path code and add a .remove function.
  Change the button behaviour so that a key-released event is only generated 
  once
  the key is released, not after timeout.
  *Changes tested on WM8650 tablet.
 
 
 Thank you for making the requested changes, unfortunately there is some
 more...
It's never unfortunate to get it right :)
 
  
  +   status = readl(data-pmc_base + 0x14);
  +   if (status  BIT(14)) {
  +   /* Button isn't release so check again in 50ms */
  +   mod_timer(data-timer, jiffies + msecs_to_jiffies(50));
 
 I do not think you need to do this: your ISR does mod_timer which
 means that the timer expiration gets extended every time there is
 interrupt, so as long as the button is pressed the timer will not run.
 So I'd just report the button as released here and be done with it.
Will fix.

  +
  +   np = of_find_compatible_node(NULL, NULL, via,vt8500-pmc);
  +   if (!np) {
  +   dev_err(pdev-dev, pmc node not found\n);
  +   return -EINVAL;
  +   }
 
 Hmm, why are we looking up another device? What is it is not there yet?
 Can we have all resources contained in this device DT description?

This driver uses registers in the power management controller. It didn't
seem right to declare the memory space for this device as well as the PM
controller, but I don't think there is any reason why it couldn't - just
seemed a bit backward to me.

  +   data-pmc_base = of_iomap(np, 0);
  +   if (!data-pmc_base) {
  +   dev_err(pdev-dev, unable to map pmc memory\n);
  +   return -ENOMEM;
  +   }
  +
  +   np = pdev-dev.of_node;
  +   if (!np) {
  +   dev_err(pdev-dev, devicenode not found\n);
 
 Your error handling is still incomplete, you need to unmap the memory
 you just mapped above.
Will do.
 
 I happened to peek at other vt8500 drivers and the lack of proper error
 handling and absence of remove() methods is a common theme among them.
Will put this on my list of things to look into. Thanks for pointing it
out.
 
  +
  +   data-kpad_power-evbit[0] = BIT_MASK(EV_KEY);
  +   set_bit(data-keycode, data-kpad_power-keybit);
 
 Make it:
 
   input_set_capability(data-kpad_power, EV_KEY, data-keycode);
OK.
 
  +
  +   data-kpad_power-name = wmt_power_keypad;
  +   data-kpad_power-phys = wmt_power_keypad;
 
 You can have more human name in name field, you do not have to have
 underscores. Also if you want to use phys it is common to have it in
 form of parent device/input0 so something like vt8500-pmic/input0.
Thanks.
 
  +   data-kpad_power-keycode = data-keycode;
  +   data-kpad_power-keycodesize = sizeof(unsigned int);
  +   data-kpad_power-keycodemax = 1;
  +
  +   err = input_register_device(data-kpad_power);
  +   if (err  0) {
  +   dev_err(pdev-dev, failed to register input device\n);
  +   goto cleanup_input;
  +   }
  +
 
 I'd recommend registering input device after you request irq as it
 simplifies error path (it is OK for ISR to use allocated but not
 registered input device).
Sounds good.
 
  +
  +static int vt8500_pwr_kpad_remove(struct platform_device *pdev)
  +
  +{
  +   struct kpad_pwr_data *data = platform_get_drvdata(pdev);
  +
  +   free_irq(data-irq, data);
  +   del_timer(data-timer);
 
 This should be del_timer_sync().
OK.
 
  +   input_unregister_device(data-kpad_power);
  +   input_free_device(data-kpad_power);
 
 input_free_device() after input_unregister_device() will result in
 double-free. The rule is use input_free_device() if device has not been
 registered, otherwise use input_unregister_device().
That seems a little unintuitive given the functions seemed to be paired.
Will fix. Thanks.
 
 You also need to unmap the mapped region.
Will do.



Regards
Tony P

--
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] input: vt8500: Add power button keypad driver

2012-12-31 Thread Tony Prisk
This patch adds support for the Power Button keypad found on
Wondermedia netbooks/tablets.

A keymap property is exposed to allowing defining the key
event to be generated when the power button is pressed.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
CC: linux-kernel@vger.kernel.org
CC: linux-arm-ker...@lists.infradead.org
CC: vt8500-wm8505-linux-ker...@googlegroups.com
CC: linux-in...@vger.kernel.org

v2:
Remove devicetree binding for keycode
Add dependency on OF in Kconfig
Move static variables in a struct
Remove redundant inline modifier from kpad_power_timeout()
Remove unneccessary checks against power_button_pressed. Drop variable.
Cleanup the fail path code and add a .remove function.
Change the button behaviour so that a key-released event is only generated once
the key is released, not after timeout.
*Changes tested on WM8650 tablet.

v3:
Remove dependency on PMC node, and change binding document accordingly.
Remove mod_timer call in kpad_power_timeout()
Unmap io memory in fail path and .remove
Update name  phys fields to be more meaningful
Use del_timer_sync rather than del_timer
Fix usage of input_unregister_device/input_free_device

 .../bindings/input/vt8500-power-keypad.txt |   17 ++
 drivers/input/keyboard/Kconfig |   10 ++
 drivers/input/keyboard/Makefile|1 +
 drivers/input/keyboard/wmt_power_keypad.c  |  182 
 4 files changed, 210 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/vt8500-power-keypad.txt
 create mode 100644 drivers/input/keyboard/wmt_power_keypad.c

diff --git a/Documentation/devicetree/bindings/input/vt8500-power-keypad.txt 
b/Documentation/devicetree/bindings/input/vt8500-power-keypad.txt
new file mode 100644
index 000..f6996d5
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/vt8500-power-keypad.txt
@@ -0,0 +1,17 @@
+* Wondermedia Power Keypad device tree bindings
+
+Wondermedia SoCs have a single irq-driven power button attached to
+the power management controller.
+
+Required SoC Specific Properties:
+- compatible: should be one of the following
+   - wm,power-keypad: For all Wondermedia 8xxx-series SoCs.
+- reg : Should contain the register range of the Power Mgmt controller
+- interrupts: should be the power management controller wakeup interrupt.
+
+Example:
+   powerkey: pwrkey@0 {
+   compatible = wm,power-keypad;
+   reg = 0xd813 0x1000;
+   interrupts = 22;
+   };
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 5a240c6..bb1e04f 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -595,6 +595,16 @@ config KEYBOARD_TWL4030
  To compile this driver as a module, choose M here: the
  module will be called twl4030_keypad.
 
+config KEYBOARD_WMT_POWER_KEYPAD
+   tristate Wondermedia Power keypad support
+   depends on (OF  ARCH_VT8500)
+   help
+ Say Y here to enable support for the power button keypad
+ on Wondermedia 8xxx-series SoCs.
+
+ To compile this driver as a module, choose M here: the
+ module will be called wmt_power_keypad.
+
 config KEYBOARD_XTKBD
tristate XT keyboard
select SERIO
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 44e7600..eea31af 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -52,5 +52,6 @@ obj-$(CONFIG_KEYBOARD_TC3589X)+= 
tc3589x-keypad.o
 obj-$(CONFIG_KEYBOARD_TEGRA)   += tegra-kbc.o
 obj-$(CONFIG_KEYBOARD_TNETV107X)   += tnetv107x-keypad.o
 obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o
+obj-$(CONFIG_KEYBOARD_WMT_POWER_KEYPAD)+= wmt_power_keypad.o
 obj-$(CONFIG_KEYBOARD_XTKBD)   += xtkbd.o
 obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o
diff --git a/drivers/input/keyboard/wmt_power_keypad.c 
b/drivers/input/keyboard/wmt_power_keypad.c
new file mode 100644
index 000..383b73e
--- /dev/null
+++ b/drivers/input/keyboard/wmt_power_keypad.c
@@ -0,0 +1,182 @@
+/* Wondermedia Power Keypad
+ *
+ * Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/input.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+#include linux/bitops.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux

[PATCH] mmc: vt8500: Remove __devexit attribute on .remove

2013-01-01 Thread Tony Prisk
With the changes to HOTPLUG merged for 3.8, this attribute is
no longer required and results in a warning at compile time.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/mmc/host/wmt-sdmmc.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c
index 5ba4605..3a7ce57 100644
--- a/drivers/mmc/host/wmt-sdmmc.c
+++ b/drivers/mmc/host/wmt-sdmmc.c
@@ -892,7 +892,7 @@ fail1:
return ret;
 }
 
-static int __devexit wmt_mci_remove(struct platform_device *pdev)
+static int wmt_mci_remove(struct platform_device *pdev)
 {
struct mmc_host *mmc;
struct wmt_mci_priv *priv;
@@ -1012,7 +1012,7 @@ static const struct dev_pm_ops wmt_mci_pm = {
 
 static struct platform_driver wmt_mci_driver = {
.probe = wmt_mci_probe,
-   .remove = __exit_p(wmt_mci_remove),
+   .remove = wmt_mci_remove,
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
-- 
1.7.9.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 RESEND 6/6] clk: s5p-g2d: Fix incorrect usage of IS_ERR_OR_NULL

2013-01-01 Thread Tony Prisk
On Wed, 2013-01-02 at 08:10 +0300, Dan Carpenter wrote:
 clk_get() returns NULL if CONFIG_HAVE_CLK is disabled.
 
 I told Tony about this but everyone has been gone with end of year
 holidays so it hasn't been addressed.
 
 Tony, please fix it so people don't apply these patches until
 clk_get() is updated to not return NULL.  It sucks to have to revert
 patches.
 
 regards,
 dan carpenter

I posted the query to Mike Turquette, linux-kernel and linux-arm-kernel
mailing lists, regarding the return of NULL when HAVE_CLK is undefined.

Short Answer: A return value of NULL is valid and not an error therefore
we should be using IS_ERR, not IS_ERR_OR_NULL on clk_get results.

I see the obvious problem this creates, and asked this question:

If the driver can't operate with a NULL clk, it should use a
IS_ERR_OR_NULL test to test for failure, rather than IS_ERR.


And Russell's answer:

Why should a _consumer_ of a clock care?  It is _very_ important that
people get this idea - to a consumer, the struct clk is just an opaque
cookie.  The fact that it appears to be a pointer does _not_ mean that
the driver can do any kind of dereferencing on that pointer - it should
never do so.

Thread can be viewed here:
https://lkml.org/lkml/2012/12/20/105


Regards
Tony Prisk

--
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/


[PATCHv2 2/2] pwm: vt8500: Add polarity support

2013-01-02 Thread Tony Prisk
Add support to set polarity on PWM devices, allowing for inverted
duty cycles.

Also update the binding document to #pwm-cells = 3 to allow
passing the flags from devicetree.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
v2:
Change binding document to detail flags usage.
Add missing .of_xlate function
Add missing .of_pwm_n_cells

 .../devicetree/bindings/pwm/vt8500-pwm.txt |9 +---
 drivers/pwm/pwm-vt8500.c   |   23 
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt 
b/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt
index bcc6367..d21d82d 100644
--- a/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt
+++ b/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt
@@ -3,14 +3,17 @@ VIA/Wondermedia VT8500/WM8xxx series SoC PWM controller
 Required properties:
 - compatible: should be via,vt8500-pwm
 - reg: physical base address and length of the controller's registers
-- #pwm-cells: should be 2.  The first cell specifies the per-chip index
-  of the PWM to use and the second cell is the period in nanoseconds.
+- #pwm-cells: Should be 3. Number of cells being used to specify PWM property.
+  First cell specifies the per-chip index of the PWM to use, the second
+  cell is the period in nanoseconds and bit 0 in the third cell is used to
+  encode the polarity of PWM output. Set bit 0 of the third in PWM specifier
+  to 1 for inverse polarity  set to 0 for normal polarity.
 - clocks: phandle to the PWM source clock
 
 Example:
 
 pwm1: pwm@d822 {
-   #pwm-cells = 2;
+   #pwm-cells = 3;
compatible = via,vt8500-pwm;
reg = 0xd822 0x1000;
clocks = clkpwm;
diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c
index bbc3750..98d79e9 100644
--- a/drivers/pwm/pwm-vt8500.c
+++ b/drivers/pwm/pwm-vt8500.c
@@ -164,10 +164,31 @@ static void vt8500_pwm_disable(struct pwm_chip *chip, 
struct pwm_device *pwm)
clk_disable(vt8500-clk);
 }
 
+static int vt8500_pwm_set_polarity(struct pwm_chip *chip,
+  struct pwm_device *pwm,
+  enum pwm_polarity polarity)
+{
+   struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
+   u32 val;
+
+   val = readl(vt8500-base + REG_CTRL(pwm-hwpwm));
+
+   if (polarity == PWM_POLARITY_INVERSED)
+   val |= CTRL_INVERT;
+   else
+   val = ~CTRL_INVERT;
+
+   writel(val, vt8500-base + REG_CTRL(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_CTRL_UPDATE);
+
+   return 0;
+}
+
 static struct pwm_ops vt8500_pwm_ops = {
.enable = vt8500_pwm_enable,
.disable = vt8500_pwm_disable,
.config = vt8500_pwm_config,
+   .set_polarity = vt8500_pwm_set_polarity,
.owner = THIS_MODULE,
 };
 
@@ -197,6 +218,8 @@ static int vt8500_pwm_probe(struct platform_device *pdev)
 
chip-chip.dev = pdev-dev;
chip-chip.ops = vt8500_pwm_ops;
+   chip-chip.of_xlate = of_pwm_xlate_with_flags;
+   chip-chip.of_pwm_n_cells = 3;
chip-chip.base = -1;
chip-chip.npwm = VT8500_NR_PWMS;
 
-- 
1.7.9.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/


[PATCHv2 1/2] pwm: vt8500: Register write busy test performed incorrectly

2013-01-02 Thread Tony Prisk
Correct operation for register writes is to perform a busy-wait
after writing the register. Currently the busy wait it performed
before, meaning subsequent register writes to bitfields may occur
before the previous field has been updated.

Also, all registers are defined as 32-bit read/write. Change
pwm_busy_wait() to use readl rather than readb.

Improve readability of code with defines for registers and bitfields.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
v2:
Change parenthesis around defines
Replace pr_warn with dev_warn in pwm_busy_wait()

 drivers/pwm/pwm-vt8500.c |   64 +++---
 1 file changed, 49 insertions(+), 15 deletions(-)

diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c
index b0ba2d4..bbc3750 100644
--- a/drivers/pwm/pwm-vt8500.c
+++ b/drivers/pwm/pwm-vt8500.c
@@ -36,6 +36,25 @@
  */
 #define VT8500_NR_PWMS 2
 
+#define REG_CTRL(pwm)  (((pwm)  4) + 0x00)
+#define REG_SCALAR(pwm)(((pwm)  4) + 0x04)
+#define REG_PERIOD(pwm)(((pwm)  4) + 0x08)
+#define REG_DUTY(pwm)  (((pwm)  4) + 0x0C)
+#define REG_STATUS 0x40
+
+#define CTRL_ENABLEBIT(0)
+#define CTRL_INVERTBIT(1)
+#define CTRL_AUTOLOAD  BIT(2)
+#define CTRL_STOP_IMM  BIT(3)
+#define CTRL_LOAD_PRESCALE BIT(4)
+#define CTRL_LOAD_PERIOD   BIT(5)
+
+#define STATUS_CTRL_UPDATE BIT(0)
+#define STATUS_SCALAR_UPDATE   BIT(1)
+#define STATUS_PERIOD_UPDATE   BIT(2)
+#define STATUS_DUTY_UPDATE BIT(3)
+#define STATUS_ALL_UPDATE  0x0F
+
 struct vt8500_chip {
struct pwm_chip chip;
void __iomem *base;
@@ -45,15 +64,17 @@ struct vt8500_chip {
 #define to_vt8500_chip(chip)   container_of(chip, struct vt8500_chip, chip)
 
 #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
-static inline void pwm_busy_wait(void __iomem *reg, u8 bitmask)
+static inline void pwm_busy_wait(struct vt8500_chip *vt8500, int nr, u8 
bitmask)
 {
int loops = msecs_to_loops(10);
-   while ((readb(reg)  bitmask)  --loops)
+   u32 mask = bitmask  (nr  8);
+
+   while ((readl(vt8500-base + REG_STATUS)  mask)  --loops)
cpu_relax();
 
if (unlikely(!loops))
-   pr_warn(Waiting for status bits 0x%x to clear timed out\n,
-  bitmask);
+   dev_warn(vt8500-chip.dev, Waiting for status bits 0x%x to 
clear timed out\n,
+mask);
 }
 
 static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
@@ -63,6 +84,7 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct 
pwm_device *pwm,
unsigned long long c;
unsigned long period_cycles, prescale, pv, dc;
int err;
+   u32 val;
 
err = clk_enable(vt8500-clk);
if (err  0) {
@@ -91,14 +113,19 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct 
pwm_device *pwm,
do_div(c, period_ns);
dc = c;
 
-   pwm_busy_wait(vt8500-base + 0x40 + pwm-hwpwm, (1  1));
-   writel(prescale, vt8500-base + 0x4 + (pwm-hwpwm  4));
+   writel(prescale, vt8500-base + REG_SCALAR(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_SCALAR_UPDATE);
+
+   writel(pv, vt8500-base + REG_PERIOD(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_PERIOD_UPDATE);
 
-   pwm_busy_wait(vt8500-base + 0x40 + pwm-hwpwm, (1  2));
-   writel(pv, vt8500-base + 0x8 + (pwm-hwpwm  4));
+   writel(dc, vt8500-base + REG_DUTY(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_DUTY_UPDATE);
 
-   pwm_busy_wait(vt8500-base + 0x40 + pwm-hwpwm, (1  3));
-   writel(dc, vt8500-base + 0xc + (pwm-hwpwm  4));
+   val = readl(vt8500-base + REG_CTRL(pwm-hwpwm));
+   val |= CTRL_AUTOLOAD;
+   writel(val, vt8500-base + REG_CTRL(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_CTRL_UPDATE);
 
clk_disable(vt8500-clk);
return 0;
@@ -106,8 +133,9 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct 
pwm_device *pwm,
 
 static int vt8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-   int err;
struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
+   int err;
+   u32 val;
 
err = clk_enable(vt8500-clk);
if (err  0) {
@@ -115,17 +143,23 @@ static int vt8500_pwm_enable(struct pwm_chip *chip, 
struct pwm_device *pwm)
return err;
}
 
-   pwm_busy_wait(vt8500-base + 0x40 + pwm-hwpwm, (1  0));
-   writel(5, vt8500-base + (pwm-hwpwm  4));
+   val = readl(vt8500-base + REG_CTRL(pwm-hwpwm));
+   val |= CTRL_ENABLE;
+   writel(val, vt8500-base + REG_CTRL(pwm-hwpwm));
+   pwm_busy_wait(vt8500, pwm-hwpwm, STATUS_CTRL_UPDATE);
+
return 0;
 }
 
 static void vt8500_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
+   u32 val

[PATCH 4/4] video: vt8500: Update descriptions in video/Kconfig

2013-01-02 Thread Tony Prisk
This patch updates the descriptions for the VIA VT8500 and
Wondermedia WM8xxx-series framebuffer drivers to correctly reflect
which hardware they support.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/video/Kconfig |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 6678daf..3bbb3c1 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1767,7 +1767,7 @@ config FB_AU1200
  option au1200fb:panel=name.
 
 config FB_VT8500
-   bool VT8500 LCD Driver
+   bool VIA VT8500 Framebuffer Driver
depends on (FB = y)  ARM  ARCH_VT8500
select FB_SYS_FILLRECT if (!FB_WMT_GE_ROPS)
select FB_SYS_COPYAREA if (!FB_WMT_GE_ROPS)
@@ -1777,14 +1777,15 @@ config FB_VT8500
  controller.
 
 config FB_WM8505
-   bool WM8505 frame buffer support
+   bool Wondermedia WM8xxx-series framebuffer support
depends on (FB = y)  ARM  ARCH_VT8500
select FB_SYS_FILLRECT if (!FB_WMT_GE_ROPS)
select FB_SYS_COPYAREA if (!FB_WMT_GE_ROPS)
select FB_SYS_IMAGEBLIT
help
- This is the framebuffer driver for WonderMedia WM8505/WM8650
- integrated LCD controller.
+ This is the framebuffer driver for WonderMedia WM8xxx-series
+ integrated LCD controller. This driver covers the WM8505, WM8650
+ and WM8850 SoCs.
 
 config FB_WMT_GE_ROPS
bool VT8500/WM8xxx accelerated raster ops support
-- 
1.7.9.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 1/4] drivers/video/wm8505fb.c: use devm_ functions

2013-01-02 Thread Tony Prisk
From: Julia Lawall julia.law...@lip6.fr

The various devm_ functions allocate memory that is released when a driver
detaches.  This patch uses these functions for data that is allocated in
the probe function of a platform device and is only freed in the remove
function.

The patch makes some other cleanups.  First, the original code used
devm_kzalloc, but kfree.  This would lead to a double free.  The problem
was found using the following semantic match (http://coccinelle.lip6.fr/):

// smpl
@@
expression x,e;
@@
x = devm_kzalloc(...)
... when != x = e
?-kfree(x,...);
// /smpl

The error-handing code of devm_request_and_ioremap does not print any
warning message, because devm_request_and_ioremap does this.

The call to dma_alloc_coherent is converted to its devm equivalent,
dmam_alloc_coherent.  This implicitly introduces a call to
dmam_free_coherent, which was completly missing in the original code.

A semicolon is removed at the end of the error-handling code for the call
to dma_alloc_coherent.

The block of code calling fb_alloc_cmap is moved below the block of code
calling wm8505fb_set_par, so that the error-handing code of the call to
wm8505fb_set_par can just return ret.  This way there is only one block of
error-handling code that needs to call fb_dealloc_cmap, and so this is
moved up to the place where it is needed, eliminating the need for all
gotos and labels in the function.  This was suggested by Tony Prisk.

The initializations of fbi and ret at the beginning of the function are not
necessary and are removed.  The call platform_set_drvdata(pdev, NULL); at
the end of the function is also removed.

Signed-off-by: Julia Lawall julia.law...@lip6.fr
Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/video/wm8505fb.c |   78 +++---
 1 file changed, 19 insertions(+), 59 deletions(-)

diff --git a/drivers/video/wm8505fb.c b/drivers/video/wm8505fb.c
index 77539c1..1c3ce2c 100644
--- a/drivers/video/wm8505fb.c
+++ b/drivers/video/wm8505fb.c
@@ -274,15 +274,11 @@ static int __devinit wm8505fb_probe(struct 
platform_device *pdev)
unsigned long fb_mem_len;
void *fb_mem_virt;
 
-   ret = -ENOMEM;
-   fbi = NULL;
-
fbi = devm_kzalloc(pdev-dev, sizeof(struct wm8505fb_info) +
sizeof(u32) * 16, GFP_KERNEL);
if (!fbi) {
dev_err(pdev-dev, Failed to initialize framebuffer 
device\n);
-   ret = -ENOMEM;
-   goto failed;
+   return -ENOMEM;
}
 
strcpy(fbi-fb.fix.id, DRIVER_NAME);
@@ -308,31 +304,15 @@ static int __devinit wm8505fb_probe(struct 
platform_device *pdev)
fbi-fb.pseudo_palette  = addr;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (res == NULL) {
-   dev_err(pdev-dev, no I/O memory resource defined\n);
-   ret = -ENODEV;
-   goto failed_fbi;
-   }
-
-   res = request_mem_region(res-start, resource_size(res), DRIVER_NAME);
-   if (res == NULL) {
-   dev_err(pdev-dev, failed to request I/O memory\n);
-   ret = -EBUSY;
-   goto failed_fbi;
-   }
 
-   fbi-regbase = ioremap(res-start, resource_size(res));
-   if (fbi-regbase == NULL) {
-   dev_err(pdev-dev, failed to map I/O memory\n);
-   ret = -EBUSY;
-   goto failed_free_res;
-   }
+   fbi-regbase = devm_request_and_ioremap(pdev-dev, res);
+   if (fbi-regbase == NULL)
+   return -EBUSY;
 
np = of_parse_phandle(pdev-dev.of_node, default-mode, 0);
if (!np) {
pr_err(%s: No display description in Device Tree\n, __func__);
-   ret = -EINVAL;
-   goto failed_free_res;
+   return -EINVAL;
}
 
/*
@@ -351,7 +331,7 @@ static int __devinit wm8505fb_probe(struct platform_device 
*pdev)
ret |= of_property_read_u32(np, bpp, bpp);
if (ret) {
pr_err(%s: Unable to read display properties\n, __func__);
-   goto failed_free_res;
+   return ret;
}
 
of_mode.vmode = FB_VMODE_NONINTERLACED;
@@ -365,12 +345,12 @@ static int __devinit wm8505fb_probe(struct 
platform_device *pdev)
 
/* try allocating the framebuffer */
fb_mem_len = of_mode.xres * of_mode.yres * 2 * (bpp / 8);
-   fb_mem_virt = dma_alloc_coherent(pdev-dev, fb_mem_len, fb_mem_phys,
+   fb_mem_virt = dmam_alloc_coherent(pdev-dev, fb_mem_len, fb_mem_phys,
GFP_KERNEL);
if (!fb_mem_virt) {
pr_err(%s: Failed to allocate framebuffer\n, __func__);
return -ENOMEM;
-   };
+   }
 
fbi-fb.var.xres_virtual= of_mode.xres;
fbi-fb.var.yres_virtual= of_mode.yres * 2;
@@ -381,28 +361,29 @@ static int __devinit wm8505fb_probe(struct 
platform_device *pdev)
fbi

[PATCH 3/4] video: vt8500: Remove unused platform_data/video-vt8500lcdfb.h

2013-01-02 Thread Tony Prisk
With the conversion to devicetree only for arch-vt8500, this
header is no longer required. This patch removes the #include
from the two framebuffer drivers that used it, and the header file.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/video/vt8500lcdfb.c |2 --
 drivers/video/wm8505fb.c|2 --
 include/linux/platform_data/video-vt8500lcdfb.h |   31 ---
 3 files changed, 35 deletions(-)
 delete mode 100644 include/linux/platform_data/video-vt8500lcdfb.h

diff --git a/drivers/video/vt8500lcdfb.c b/drivers/video/vt8500lcdfb.c
index e8853ac..b1fbe20 100644
--- a/drivers/video/vt8500lcdfb.c
+++ b/drivers/video/vt8500lcdfb.c
@@ -30,8 +30,6 @@
 #include linux/platform_device.h
 #include linux/wait.h
 
-#include linux/platform_data/video-vt8500lcdfb.h
-
 #include vt8500lcdfb.h
 
 #ifdef CONFIG_FB_WMT_GE_ROPS
diff --git a/drivers/video/wm8505fb.c b/drivers/video/wm8505fb.c
index a990708..f0185cd 100644
--- a/drivers/video/wm8505fb.c
+++ b/drivers/video/wm8505fb.c
@@ -32,8 +32,6 @@
 #include linux/of_fdt.h
 #include linux/memblock.h
 
-#include linux/platform_data/video-vt8500lcdfb.h
-
 #include wm8505fb_regs.h
 
 #ifdef CONFIG_FB_WMT_GE_ROPS
diff --git a/include/linux/platform_data/video-vt8500lcdfb.h 
b/include/linux/platform_data/video-vt8500lcdfb.h
deleted file mode 100644
index 7f399c3..000
--- a/include/linux/platform_data/video-vt8500lcdfb.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *  VT8500/WM8505 Frame Buffer platform data definitions
- *
- *  Copyright (C) 2010 Ed Spiridonov edo@gmail.com
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- */
-
-#ifndef _VT8500FB_H
-#define _VT8500FB_H
-
-#include linux/fb.h
-
-struct vt8500fb_platform_data {
-   struct fb_videomode mode;
-   u32 xres_virtual;
-   u32 yres_virtual;
-   u32 bpp;
-   unsigned long   video_mem_phys;
-   void*video_mem_virt;
-   unsigned long   video_mem_len;
-};
-
-#endif /* _VT8500FB_H */
-- 
1.7.9.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 2/4] video: vt8500: Make wmt_ge_rops optional

2013-01-02 Thread Tony Prisk
At the moment, accelerated raster ops are always enabled on VT8500
and WM8xxx series SoCs. This patch makes them optional.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/video/Kconfig   |   23 +--
 drivers/video/vt8500lcdfb.c |   15 +++
 drivers/video/wm8505fb.c|   15 +++
 3 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index e7068c5..6678daf 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -190,14 +190,6 @@ config FB_SYS_FOPS
depends on FB
default n
 
-config FB_WMT_GE_ROPS
-   tristate
-   depends on FB
-   default n
-   ---help---
- Include functions for accelerated rectangle filling and area
- copying using WonderMedia Graphics Engine operations.
-
 config FB_DEFERRED_IO
bool
depends on FB
@@ -1777,7 +1769,8 @@ config FB_AU1200
 config FB_VT8500
bool VT8500 LCD Driver
depends on (FB = y)  ARM  ARCH_VT8500
-   select FB_WMT_GE_ROPS
+   select FB_SYS_FILLRECT if (!FB_WMT_GE_ROPS)
+   select FB_SYS_COPYAREA if (!FB_WMT_GE_ROPS)
select FB_SYS_IMAGEBLIT
help
  This is the framebuffer driver for VIA VT8500 integrated LCD
@@ -1786,12 +1779,22 @@ config FB_VT8500
 config FB_WM8505
bool WM8505 frame buffer support
depends on (FB = y)  ARM  ARCH_VT8500
-   select FB_WMT_GE_ROPS
+   select FB_SYS_FILLRECT if (!FB_WMT_GE_ROPS)
+   select FB_SYS_COPYAREA if (!FB_WMT_GE_ROPS)
select FB_SYS_IMAGEBLIT
help
  This is the framebuffer driver for WonderMedia WM8505/WM8650
  integrated LCD controller.
 
+config FB_WMT_GE_ROPS
+   bool VT8500/WM8xxx accelerated raster ops support
+   depends on (FB = y)  (FB_VT8500 || FB_WM8505)
+   default n
+   help
+ This adds support for accelerated raster operations on the
+ VIA VT8500 and Wondermedia 8xxx series SoCs.
+
+
 source drivers/video/geode/Kconfig
 
 config FB_HIT
diff --git a/drivers/video/vt8500lcdfb.c b/drivers/video/vt8500lcdfb.c
index 9af8da7..e8853ac 100644
--- a/drivers/video/vt8500lcdfb.c
+++ b/drivers/video/vt8500lcdfb.c
@@ -33,7 +33,10 @@
 #include linux/platform_data/video-vt8500lcdfb.h
 
 #include vt8500lcdfb.h
+
+#ifdef CONFIG_FB_WMT_GE_ROPS
 #include wmt_ge_rops.h
+#endif
 
 #ifdef CONFIG_OF
 #include linux/of.h
@@ -249,12 +252,24 @@ static int vt8500lcd_blank(int blank, struct fb_info 
*info)
return 0;
 }
 
+#ifndef CONFIG_FB_WMT_GE_ROPS
+static int wmt_ge_sync(struct fb_info *p)
+{
+   return 0;
+}
+#endif
+
 static struct fb_ops vt8500lcd_ops = {
.owner  = THIS_MODULE,
.fb_set_par = vt8500lcd_set_par,
.fb_setcolreg   = vt8500lcd_setcolreg,
+#ifdef CONFIG_FB_WMT_GE_ROPS
.fb_fillrect= wmt_ge_fillrect,
.fb_copyarea= wmt_ge_copyarea,
+#else
+   .fb_fillrect= sys_fillrect,
+   .fb_copyarea= sys_copyarea,
+#endif
.fb_imageblit   = sys_imageblit,
.fb_sync= wmt_ge_sync,
.fb_ioctl   = vt8500lcd_ioctl,
diff --git a/drivers/video/wm8505fb.c b/drivers/video/wm8505fb.c
index 77539c1..a990708 100644
--- a/drivers/video/wm8505fb.c
+++ b/drivers/video/wm8505fb.c
@@ -35,7 +35,10 @@
 #include linux/platform_data/video-vt8500lcdfb.h
 
 #include wm8505fb_regs.h
+
+#ifdef CONFIG_FB_WMT_GE_ROPS
 #include wmt_ge_rops.h
+#endif
 
 #define DRIVER_NAME wm8505-fb
 
@@ -248,12 +251,24 @@ static int wm8505fb_blank(int blank, struct fb_info *info)
return 0;
 }
 
+#ifndef CONFIG_FB_WMT_GE_ROPS
+static int wmt_ge_sync(struct fb_info *p)
+{
+   return 0;
+}
+#endif
+
 static struct fb_ops wm8505fb_ops = {
.owner  = THIS_MODULE,
.fb_set_par = wm8505fb_set_par,
.fb_setcolreg   = wm8505fb_setcolreg,
+#ifdef CONFIG_FB_WMT_GE_ROPS
.fb_fillrect= wmt_ge_fillrect,
.fb_copyarea= wmt_ge_copyarea,
+#else
+   .fb_fillrect= sys_fillrect,
+   .fb_copyarea= sys_copyarea,
+#endif
.fb_imageblit   = sys_imageblit,
.fb_sync= wmt_ge_sync,
.fb_pan_display = wm8505fb_pan_display,
-- 
1.7.9.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] gpio: vt8500: memory cleanup missing

2013-01-02 Thread Tony Prisk
This driver is missing a .remove callback, and the fail path on
probe is incomplete.

If an error occurs in vt8500_add_chips, gpio_base is not unmapped.
The driver is also ignoring the return value from this function so
if a chip fails to register it completes as successful.

Replaced pr_err with dev_err in vt8500_add_chips since the device is
available.

There is also no .remove callback defined. To allow removing the
registered chips, I have moved *vtchip to be a static global.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/gpio/gpio-vt8500.c |   53 ++--
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/drivers/gpio/gpio-vt8500.c b/drivers/gpio/gpio-vt8500.c
index b53320a..a147b33 100644
--- a/drivers/gpio/gpio-vt8500.c
+++ b/drivers/gpio/gpio-vt8500.c
@@ -122,11 +122,13 @@ static struct vt8500_gpio_data wm8650_data = {
 
 struct vt8500_gpio_chip {
struct gpio_chipchip;
-
const struct vt8500_gpio_bank_regoffsets *regs;
void __iomem*base;
 };
 
+/* Pointer to our array of chips */
+static struct vt8500_gpio_chip *vtchip;
+
 
 #define to_vt8500(__chip) container_of(__chip, struct vt8500_gpio_chip, chip)
 
@@ -224,7 +226,6 @@ static int vt8500_of_xlate(struct gpio_chip *gc,
 static int vt8500_add_chips(struct platform_device *pdev, void __iomem *base,
const struct vt8500_gpio_data *data)
 {
-   struct vt8500_gpio_chip *vtchip;
struct gpio_chip *chip;
int i;
int pin_cnt = 0;
@@ -233,7 +234,7 @@ static int vt8500_add_chips(struct platform_device *pdev, 
void __iomem *base,
sizeof(struct vt8500_gpio_chip) * data-num_banks,
GFP_KERNEL);
if (!vtchip) {
-   pr_err(%s: failed to allocate chip memory\n, __func__);
+   dev_err(pdev-dev, failed to allocate chip memory\n);
return -ENOMEM;
}
 
@@ -261,6 +262,7 @@ static int vt8500_add_chips(struct platform_device *pdev, 
void __iomem *base,
 
gpiochip_add(chip);
}
+
return 0;
 }
 
@@ -273,36 +275,63 @@ static struct of_device_id vt8500_gpio_dt_ids[] = {
 
 static int vt8500_gpio_probe(struct platform_device *pdev)
 {
+   int ret;
void __iomem *gpio_base;
-   struct device_node *np;
+   struct device_node *np = pdev-dev.of_node;
const struct of_device_id *of_id =
of_match_device(vt8500_gpio_dt_ids, pdev-dev);
 
-   if (!of_id) {
-   dev_err(pdev-dev, Failed to find gpio controller\n);
+   if (!np) {
+   dev_err(pdev-dev, GPIO node missing in devicetree\n);
return -ENODEV;
}
 
-   np = pdev-dev.of_node;
-   if (!np) {
-   dev_err(pdev-dev, Missing GPIO description in devicetree\n);
-   return -EFAULT;
+   if (!of_id) {
+   dev_err(pdev-dev, No matching driver data\n);
+   return -ENODEV;
}
 
gpio_base = of_iomap(np, 0);
if (!gpio_base) {
dev_err(pdev-dev, Unable to map GPIO registers\n);
-   of_node_put(np);
return -ENOMEM;
}
 
-   vt8500_add_chips(pdev, gpio_base, of_id-data);
+   ret = vt8500_add_chips(pdev, gpio_base, of_id-data);
+   if (ret) {
+   iounmap(gpio_base);
+   return ret;
+   }
+
+   return 0;
+}
+
+static int vt8500_gpio_remove(struct platform_device *pdev)
+{
+   int i;
+   int ret;
+   const struct vt8500_gpio_data *data;
+   void __iomem *gpio_base = vtchip[0].base;
+   const struct of_device_id *of_id =
+   of_match_device(vt8500_gpio_dt_ids, pdev-dev);
+
+   data = of_id-data;
+
+   for (i = 0; i  data-num_banks; i++) {
+   ret = gpiochip_remove(vtchip[i].chip);
+   if (ret)
+   dev_warn(pdev-dev, gpiochip_remove returned %d\n,
+ret);
+   }
+
+   iounmap(gpio_base);
 
return 0;
 }
 
 static struct platform_driver vt8500_gpio_driver = {
.probe  = vt8500_gpio_probe,
+   .remove = vt8500_gpio_remove,
.driver = {
.name   = vt8500-gpio,
.owner  = THIS_MODULE,
-- 
1.7.9.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 0/2] Move some mach-vt8500 functions to new directories

2013-01-02 Thread Tony Prisk
These two patches move the irq and clocksource code out of mach-vt8500
and into drivers/irqchip and drivers/clocksource respectively.

Because they affect the same files in mach-vt8500 I thought it may be
easier if it goes through arm-soc, but I note Thomas is the maintainer for
both irqchip and clocksource so maybe he wants to take both.

CC: John Stultz johns...@us.ibm.com
CC: Thomas Gleixner t...@linutronix.de

Tony Prisk (2):
  timer: vt8500: Move system timer to clocksource
  irqchip: vt8500: Move irq code to drivers/irqchip

 arch/arm/mach-vt8500/Kconfig   |1 +
 arch/arm/mach-vt8500/Makefile  |2 +-
 arch/arm/mach-vt8500/common.h  |   12 +-
 arch/arm/mach-vt8500/irq.c |  253 
 arch/arm/mach-vt8500/timer.c   |  184 --
 arch/arm/mach-vt8500/vt8500.c  |4 -
 drivers/clocksource/Kconfig|3 +
 drivers/clocksource/Makefile   |1 +
 drivers/clocksource/vt8500_timer.c |  187 ++
 drivers/irqchip/Makefile   |1 +
 drivers/irqchip/irq-vt8500.c   |  253 
 11 files changed, 454 insertions(+), 447 deletions(-)
 delete mode 100644 arch/arm/mach-vt8500/irq.c
 delete mode 100644 arch/arm/mach-vt8500/timer.c
 create mode 100644 drivers/clocksource/vt8500_timer.c
 create mode 100644 drivers/irqchip/irq-vt8500.c

-- 
1.7.9.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 1/2] timer: vt8500: Move system timer to clocksource

2013-01-02 Thread Tony Prisk
Move mach-vt8500/timer.c to drivers/clocksource/vt8500_timer.c
and make necessary changes to Kconfig and Makefile.

vt8500_timer is moved from vt8500.c to clocksource/vt8500_timer.c
and added to common.h for reference from the board descriptor.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
CC: John Stultz johns...@us.ibm.com
CC: Thomas Gleixner t...@linutronix.de

 arch/arm/mach-vt8500/Kconfig   |1 +
 arch/arm/mach-vt8500/Makefile  |2 +-
 arch/arm/mach-vt8500/common.h  |5 +-
 arch/arm/mach-vt8500/timer.c   |  184 ---
 arch/arm/mach-vt8500/vt8500.c  |4 -
 drivers/clocksource/Kconfig|3 +
 drivers/clocksource/Makefile   |1 +
 drivers/clocksource/vt8500_timer.c |  187 
 8 files changed, 197 insertions(+), 190 deletions(-)
 delete mode 100644 arch/arm/mach-vt8500/timer.c
 create mode 100644 drivers/clocksource/vt8500_timer.c

diff --git a/arch/arm/mach-vt8500/Kconfig b/arch/arm/mach-vt8500/Kconfig
index 2ed0b7d..570a801 100644
--- a/arch/arm/mach-vt8500/Kconfig
+++ b/arch/arm/mach-vt8500/Kconfig
@@ -8,5 +8,6 @@ config ARCH_VT8500
select GENERIC_CLOCKEVENTS
select GENERIC_GPIO
select HAVE_CLK
+   select VT8500_TIMER
help
  Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip.
diff --git a/arch/arm/mach-vt8500/Makefile b/arch/arm/mach-vt8500/Makefile
index e035251..92ceb24 100644
--- a/arch/arm/mach-vt8500/Makefile
+++ b/arch/arm/mach-vt8500/Makefile
@@ -1 +1 @@
-obj-$(CONFIG_ARCH_VT8500) += irq.o timer.o vt8500.o
+obj-$(CONFIG_ARCH_VT8500) += irq.o vt8500.o
diff --git a/arch/arm/mach-vt8500/common.h b/arch/arm/mach-vt8500/common.h
index 6f2b843..5d37a4f 100644
--- a/arch/arm/mach-vt8500/common.h
+++ b/arch/arm/mach-vt8500/common.h
@@ -18,7 +18,6 @@
 
 #include linux/of.h
 
-void __init vt8500_timer_init(void);
 int __init vt8500_irq_init(struct device_node *node,
struct device_node *parent);
 
@@ -28,4 +27,8 @@ void __init vtwm_clk_init(void __iomem *pmc_base);
 /* defined in irq.c */
 asmlinkage void vt8500_handle_irq(struct pt_regs *regs);
 
+/* defined in drivers/clocksource/vt8500_timer.c */
+extern struct sys_timer vt8500_timer;
+void __init vt8500_timer_init(void);
+
 #endif
diff --git a/arch/arm/mach-vt8500/timer.c b/arch/arm/mach-vt8500/timer.c
deleted file mode 100644
index 3dd21a4..000
--- a/arch/arm/mach-vt8500/timer.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- *  arch/arm/mach-vt8500/timer.c
- *
- *  Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
- *  Copyright (C) 2010 Alexey Charkov alch...@gmail.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
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*
- * This file is copied and modified from the original timer.c provided by
- * Alexey Charkov. Minor changes have been made for Device Tree Support.
- */
-
-#include linux/io.h
-#include linux/irq.h
-#include linux/interrupt.h
-#include linux/clocksource.h
-#include linux/clockchips.h
-#include linux/delay.h
-#include asm/mach/time.h
-
-#include linux/of.h
-#include linux/of_address.h
-#include linux/of_irq.h
-
-#define VT8500_TIMER_OFFSET0x0100
-#define VT8500_TIMER_HZ300
-#define TIMER_MATCH_VAL0x
-#define TIMER_COUNT_VAL0x0010
-#define TIMER_STATUS_VAL   0x0014
-#define TIMER_IER_VAL  0x001c  /* interrupt enable */
-#define TIMER_CTRL_VAL 0x0020
-#define TIMER_AS_VAL   0x0024  /* access status */
-#define TIMER_COUNT_R_ACTIVE   (1  5)/* not ready for read */
-#define TIMER_COUNT_W_ACTIVE   (1  4)/* not ready for write */
-#define TIMER_MATCH_W_ACTIVE   (1  0)/* not ready for write */
-
-#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
-
-static void __iomem *regbase;
-
-static cycle_t vt8500_timer_read(struct clocksource *cs)
-{
-   int loops = msecs_to_loops(10);
-   writel(3, regbase + TIMER_CTRL_VAL);
-   while ((readl((regbase + TIMER_AS_VAL))  TIMER_COUNT_R_ACTIVE)
---loops)
-   cpu_relax();
-   return readl(regbase + TIMER_COUNT_VAL);
-}
-
-static struct clocksource clocksource = {
-   .name   = vt8500_timer,
-   .rating

[PATCH 2/2] irqchip: vt8500: Move irq code to drivers/irqchip

2013-01-02 Thread Tony Prisk
Move mach-vt8500/irq.c to drivers/irqchip/irq-vt8500.c and make
necessary Makefile changes. No code changes required.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
CC: Thomas Gleixner t...@linutronix.de
 arch/arm/mach-vt8500/Makefile |2 +-
 arch/arm/mach-vt8500/common.h |7 +-
 arch/arm/mach-vt8500/irq.c|  253 -
 drivers/irqchip/Makefile  |1 +
 drivers/irqchip/irq-vt8500.c  |  253 +
 5 files changed, 258 insertions(+), 258 deletions(-)
 delete mode 100644 arch/arm/mach-vt8500/irq.c
 create mode 100644 drivers/irqchip/irq-vt8500.c

diff --git a/arch/arm/mach-vt8500/Makefile b/arch/arm/mach-vt8500/Makefile
index 92ceb24..4c8a846 100644
--- a/arch/arm/mach-vt8500/Makefile
+++ b/arch/arm/mach-vt8500/Makefile
@@ -1 +1 @@
-obj-$(CONFIG_ARCH_VT8500) += irq.o vt8500.o
+obj-$(CONFIG_ARCH_VT8500) += vt8500.o
diff --git a/arch/arm/mach-vt8500/common.h b/arch/arm/mach-vt8500/common.h
index 5d37a4f..b198a81 100644
--- a/arch/arm/mach-vt8500/common.h
+++ b/arch/arm/mach-vt8500/common.h
@@ -18,13 +18,12 @@
 
 #include linux/of.h
 
-int __init vt8500_irq_init(struct device_node *node,
-   struct device_node *parent);
-
 /* defined in drivers/clk/clk-vt8500.c */
 void __init vtwm_clk_init(void __iomem *pmc_base);
 
-/* defined in irq.c */
+/* defined in drivers/irqchip/irq.c */
+int __init vt8500_irq_init(struct device_node *node,
+   struct device_node *parent);
 asmlinkage void vt8500_handle_irq(struct pt_regs *regs);
 
 /* defined in drivers/clocksource/vt8500_timer.c */
diff --git a/arch/arm/mach-vt8500/irq.c b/arch/arm/mach-vt8500/irq.c
deleted file mode 100644
index b9cf5ce..000
--- a/arch/arm/mach-vt8500/irq.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- *  arch/arm/mach-vt8500/irq.c
- *
- *  Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
- *  Copyright (C) 2010 Alexey Charkov alch...@gmail.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
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*
- * This file is copied and modified from the original irq.c provided by
- * Alexey Charkov. Minor changes have been made for Device Tree Support.
- */
-
-#include linux/slab.h
-#include linux/io.h
-#include linux/irq.h
-#include linux/irqdomain.h
-#include linux/interrupt.h
-#include linux/bitops.h
-
-#include linux/of.h
-#include linux/of_irq.h
-#include linux/of_address.h
-
-#include asm/irq.h
-#include asm/exception.h
-
-#define VT8500_ICPC_IRQ0x20
-#define VT8500_ICPC_FIQ0x24
-#define VT8500_ICDC0x40/* Destination Control 64*u32 */
-#define VT8500_ICIS0x80/* Interrupt status, 16*u32 */
-
-/* ICPC */
-#define ICPC_MASK  0x3F
-#define ICPC_ROTATEBIT(6)
-
-/* IC_DCTR */
-#define ICDC_IRQ   0x00
-#define ICDC_FIQ   0x01
-#define ICDC_DSS0  0x02
-#define ICDC_DSS1  0x03
-#define ICDC_DSS2  0x04
-#define ICDC_DSS3  0x05
-#define ICDC_DSS4  0x06
-#define ICDC_DSS5  0x07
-
-#define VT8500_INT_DISABLE 0
-#define VT8500_INT_ENABLE  BIT(3)
-
-#define VT8500_TRIGGER_HIGH0
-#define VT8500_TRIGGER_RISING  BIT(5)
-#define VT8500_TRIGGER_FALLING BIT(6)
-#define VT8500_EDGE( VT8500_TRIGGER_RISING \
-   | VT8500_TRIGGER_FALLING)
-
-/* vt8500 has 1 intc, wm8505 and wm8650 have 2 */
-#define VT8500_INTC_MAX2
-
-struct vt8500_irq_data {
-   void __iomem*base;  /* IO Memory base address */
-   struct irq_domain   *domain;/* Domain for this controller */
-};
-
-/* Global variable for accessing io-mem addresses */
-static struct vt8500_irq_data intc[VT8500_INTC_MAX];
-static u32 active_cnt = 0;
-
-static void vt8500_irq_mask(struct irq_data *d)
-{
-   struct vt8500_irq_data *priv = d-domain-host_data;
-   void __iomem *base = priv-base;
-   void __iomem *stat_reg = base + VT8500_ICIS + (d-hwirq  32 ? 0 : 4);
-   u8 edge, dctr;
-   u32 status;
-
-   edge = readb(base + VT8500_ICDC + d-hwirq)  VT8500_EDGE;
-   if (edge) {
-   status = readl(stat_reg);
-
-   status |= (1  (d-hwirq  0x1f

Re: [PATCH 2/2] irqchip: vt8500: Move irq code to drivers/irqchip

2013-01-02 Thread Tony Prisk
On Wed, 2013-01-02 at 22:38 -0600, Rob Herring wrote:
  CC: Thomas Gleixner t...@linutronix.de
   arch/arm/mach-vt8500/Makefile |2 +-
   arch/arm/mach-vt8500/common.h |7 +-
   arch/arm/mach-vt8500/irq.c|  253 
  -
   drivers/irqchip/Makefile  |1 +
   drivers/irqchip/irq-vt8500.c  |  253 
  +
 
 It's easy to forget, but please post using the -M option so only real
 changes are shown.

Ok.

  -/* defined in irq.c */
  +/* defined in drivers/irqchip/irq.c */
  +int __init vt8500_irq_init(struct device_node *node,
  +   struct device_node *parent);
   asmlinkage void vt8500_handle_irq(struct pt_regs *regs);
 
 These should go away with irqchip infrastructure Thomas and I have been
 working on. I plan to post updated version in the next day.
 
 Rob

Do you want me to rebase this patch on the new infrastructure once it's
in a tree somewhere, or was this a heads-up that it will need another
patch at some point?

I only ask because if these patches need to be separated it will created
merge-conflicts with arm-soc later on.

Regards
Tony P

--
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/


pwm_backlight/general pwm issue.

2012-11-16 Thread Tony Prisk
Hi Thierry,

Looking a little feedback regarding a problem introduced with the pwm
patch I sent converting the vt8500 pwm driver to devicetree.

One of the recommendations you made was to enable/disable the pwm clock
in pwm_enable/pwm_disable, rather than at driver probe, to reduce power
usage. Unfortunately, when the last pwm is disabled, the clock is
disabled which prevents the pwm module from responding to register
read/writes. This would be fine if pwm_enable was called before any
other functions.

The pwm_backlight driver calls pwm_config before pwm_enable, which
doesn't work because the pwm module has been disabled. I can appreciate
that no one wants to enable a pwm before it's configured so I don't
think this is particularly a driver issue.


My recommendation is the re-enable the previous behaviour which was to
enable the clock during driver probe, and disable during driver unload.

Looking for your thoughts (or anyone else that wants to chime in).

Regards
Tony Prisk

--
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] arm: vt8500: Add support for Wondermedia WM8750/WM8850

2013-01-10 Thread Tony Prisk
On Thu, 2013-01-10 at 10:21 +, Arnd Bergmann wrote:
 On Thursday 10 January 2013, Tony Prisk wrote:
  On Wed, 2013-01-09 at 21:27 +, Arnd Bergmann wrote:
   
Should patches in pull-requests have Ack'd lines already?
  
  This is what I thought - and the reason I haven't sent a pull-request
  for the patch's - I haven't had any Ack's :)
  
 
 Sorry, I think I misunderstood the question then. I meant that if
 you received an Acked-by statement, it should be part of the
 changeset comment by the time you send a pull request.
 
 There is also the rule that patches need to be reviewed on the
 mailing list before you submit them for inclusion. Like all
 rules, this can be bent a little for patches that are obvious
 correct bug fixes, especially when you are the platform
 maintainer. What you can do here is send the patches out to the
 mailing list without any additional Acks and send the pull
 request as the [PATCH 0/X] mail. We can then look at the
 patches if necessary or just pull in the branch straight away.
 
   Arnd
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


All makes sense now - thanks.

Regards
Tony P

--
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] gpio: vt8500: Export dedicated GPIO before multifunction pins.

2013-01-10 Thread Tony Prisk
On Thu, 2013-01-10 at 11:49 +0100, Linus Walleij wrote:
 On Sun, Dec 30, 2012 at 9:29 PM, Tony Prisk li...@prisktech.co.nz wrote:
 
  The vendor does not provide numbering for gpio pins. Vendor source
  exports dedicated gpio pins first, followed by multifunction pins.
  As this is what end users expect, this patch changes vt8500 and wm8505
  to do the same.
 
  Signed-off-by: Tony Prisk li...@prisktech.co.nz
 
 So how many existing userspace applications does this patch
 break? Has this system been widely deployed so a kernel
 upgrade will cause problems for people?
 
 But applied anyway, unless someone screams about it real
 soon now. That seems to be the only way to get people to tell
 us about their use cases.
 
 Could you consider adding names to the exported GPIO pins
 on the vt8500 series please? Then userspace can atleast
 try to locate the right pin.
 
 Yours,
 Linus Walleij

In terms of userspace apps, my best guess would be 'I dunno'. This was
requested by the only end-user to ask a question since mainline support
was added - He couldn't find the external GPIO's in the 200+ that were
listed.

This also makes all the platforms the same now - external GPIO's are now
exported first (0..x) which is better in the long term for userspace.

The names is a bit of a problem, but I will try my best. We have limited
datasheets etc from the vendor, so knowing what things do is a bit of a
mystery sometimes.

Regards
Tony P

--
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] gpio: vt8500: memory cleanup missing

2013-01-10 Thread Tony Prisk
On Thu, 2013-01-10 at 13:02 +0100, Linus Walleij wrote:
 On Thu, Jan 10, 2013 at 11:57 AM, Russell King - ARM Linux
 li...@arm.linux.org.uk wrote:
  On Thu, Jan 03, 2013 at 10:47:20AM +1300, Tony Prisk wrote:
 
  +static int vt8500_gpio_remove(struct platform_device *pdev)
  +{
  + int i;
  + int ret;
  + const struct vt8500_gpio_data *data;
  + void __iomem *gpio_base = vtchip[0].base;
  + const struct of_device_id *of_id =
  + of_match_device(vt8500_gpio_dt_ids, 
  pdev-dev);
  +
 
  You can get at the vtchip pointer if you put it into the platform device's
  driver data pointer.  That way, you're not artificially limiting this
  driver to just one device, and, with your changes it will go wrong if DT
  ever lists more than one device.
 
 Good point, I'm sloppy today :-(
 
 Patch dropped.
 
 Tony pls proceed as indicated by Russell.
 
 Yours,
 Linus Walleij

I must have been having a 'stupid' day to not realise that. Will fix.
Thanks Russell.

Regards
Tony P

--
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] gpio: vt8500: memory cleanup missing

2013-01-10 Thread Tony Prisk
This driver is missing a .remove callback, and the fail path on
probe is incomplete.

If an error occurs in vt8500_add_chips, gpio_base is not unmapped.
The driver is also ignoring the return value from this function so
if a chip fails to register it completes as successful.

Replaced pr_err with dev_err in vt8500_add_chips since the device is
available.

There is also no .remove callback defined. To allow removing the
registered chips, I have moved *vtchip to be a static global.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
v2:
Remove global variable and use platform_set_drvdata instead.

 drivers/gpio/gpio-vt8500.c |   51 +++-
 1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-vt8500.c b/drivers/gpio/gpio-vt8500.c
index b53320a..87e59b5 100644
--- a/drivers/gpio/gpio-vt8500.c
+++ b/drivers/gpio/gpio-vt8500.c
@@ -233,10 +233,12 @@ static int vt8500_add_chips(struct platform_device *pdev, 
void __iomem *base,
sizeof(struct vt8500_gpio_chip) * data-num_banks,
GFP_KERNEL);
if (!vtchip) {
-   pr_err(%s: failed to allocate chip memory\n, __func__);
+   dev_err(pdev-dev, failed to allocate chip memory\n);
return -ENOMEM;
}
 
+   platform_set_drvdata(pdev, vtchip);
+
for (i = 0; i  data-num_banks; i++) {
vtchip[i].base = base;
vtchip[i].regs = data-banks[i];
@@ -261,6 +263,7 @@ static int vt8500_add_chips(struct platform_device *pdev, 
void __iomem *base,
 
gpiochip_add(chip);
}
+
return 0;
 }
 
@@ -273,36 +276,64 @@ static struct of_device_id vt8500_gpio_dt_ids[] = {
 
 static int vt8500_gpio_probe(struct platform_device *pdev)
 {
+   int ret;
void __iomem *gpio_base;
-   struct device_node *np;
+   struct device_node *np = pdev-dev.of_node;
const struct of_device_id *of_id =
of_match_device(vt8500_gpio_dt_ids, pdev-dev);
 
-   if (!of_id) {
-   dev_err(pdev-dev, Failed to find gpio controller\n);
+   if (!np) {
+   dev_err(pdev-dev, GPIO node missing in devicetree\n);
return -ENODEV;
}
 
-   np = pdev-dev.of_node;
-   if (!np) {
-   dev_err(pdev-dev, Missing GPIO description in devicetree\n);
-   return -EFAULT;
+   if (!of_id) {
+   dev_err(pdev-dev, No matching driver data\n);
+   return -ENODEV;
}
 
gpio_base = of_iomap(np, 0);
if (!gpio_base) {
dev_err(pdev-dev, Unable to map GPIO registers\n);
-   of_node_put(np);
return -ENOMEM;
}
 
-   vt8500_add_chips(pdev, gpio_base, of_id-data);
+   ret = vt8500_add_chips(pdev, gpio_base, of_id-data);
+   if (ret) {
+   iounmap(gpio_base);
+   return ret;
+   }
+
+   return 0;
+}
+
+static int vt8500_gpio_remove(struct platform_device *pdev)
+{
+   int i;
+   int ret;
+   const struct vt8500_gpio_data *data;
+   struct vt8500_gpio_chip *vtchip = platform_get_drvdata(pdev);
+   void __iomem *gpio_base = vtchip[0].base;
+   const struct of_device_id *of_id =
+   of_match_device(vt8500_gpio_dt_ids, pdev-dev);
+
+   data = of_id-data;
+
+   for (i = 0; i  data-num_banks; i++) {
+   ret = gpiochip_remove(vtchip[i].chip);
+   if (ret)
+   dev_warn(pdev-dev, gpiochip_remove returned %d\n,
+ret);
+   }
+
+   iounmap(gpio_base);
 
return 0;
 }
 
 static struct platform_driver vt8500_gpio_driver = {
.probe  = vt8500_gpio_probe,
+   .remove = vt8500_gpio_remove,
.driver = {
.name   = vt8500-gpio,
.owner  = THIS_MODULE,
-- 
1.7.9.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 1/4] arm: vt8500: Add support for Wondermedia WM8750/WM8850

2013-01-11 Thread Tony Prisk
This patch adds support for the WM8750 (ARMv6) and WM8850 (ARMv7).

Common features across all SoCs are split into ARCH_VT8500 and
unique features are specified by each SoC option.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 Documentation/devicetree/bindings/arm/vt8500.txt |8 ++
 arch/arm/Kconfig |   17 +++
 arch/arm/mach-vt8500/Kconfig |   33 --
 arch/arm/mach-vt8500/vt8500.c|2 ++
 4 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/vt8500.txt 
b/Documentation/devicetree/bindings/arm/vt8500.txt
index d657832..87dc1dd 100644
--- a/Documentation/devicetree/bindings/arm/vt8500.txt
+++ b/Documentation/devicetree/bindings/arm/vt8500.txt
@@ -12,3 +12,11 @@ compatible = wm,wm8505;
 Boards with the Wondermedia WM8650 SoC shall have the following properties:
 Required root node property:
 compatible = wm,wm8650;
+
+Boards with the Wondermedia WM8750 SoC shall have the following properties:
+Required root node property:
+compatible = wm,wm8750;
+
+Boards with the Wondermedia WM8850 SoC shall have the following properties:
+Required root node property:
+compatible = wm,wm8850;
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f95ba14..fbb9492 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -952,20 +952,25 @@ config ARCH_OMAP
 
 config ARCH_VT8500_SINGLE
bool VIA/WonderMedia 85xx
-   select ARCH_HAS_CPUFREQ
-   select ARCH_REQUIRE_GPIOLIB
-   select CLKDEV_LOOKUP
+   select ARCH_VT8500
select COMMON_CLK
select CPU_ARM926T
-   select GENERIC_CLOCKEVENTS
-   select GENERIC_GPIO
-   select HAVE_CLK
select MULTI_IRQ_HANDLER
select SPARSE_IRQ
select USE_OF
help
  Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip.
 
+config ARCH_WM8750_SINGLE
+   bool WonderMedia WM8750/WM8850
+   select ARCH_VT8500
+   select COMMON_CLK
+   select MULTI_IRQ_HANDLER
+   select SPARSE_IRQ
+   select USE_OF
+   help
+ Support for WonderMedia WM8750/WM8850 System-on-Chip.
+
 endchoice
 
 menu Multiple platform selection
diff --git a/arch/arm/mach-vt8500/Kconfig b/arch/arm/mach-vt8500/Kconfig
index 2ed0b7d..d67c7fa 100644
--- a/arch/arm/mach-vt8500/Kconfig
+++ b/arch/arm/mach-vt8500/Kconfig
@@ -1,12 +1,39 @@
 config ARCH_VT8500
-   bool VIA/WonderMedia 85xx if ARCH_MULTI_V5
-   default ARCH_VT8500_SINGLE
+   bool
select ARCH_HAS_CPUFREQ
select ARCH_REQUIRE_GPIOLIB
select CLKDEV_LOOKUP
-   select CPU_ARM926T
select GENERIC_CLOCKEVENTS
select GENERIC_GPIO
select HAVE_CLK
+
+config ARCH_WM8505
+   bool VIA/WonderMedia 85xx if !ARCH_VT8500_SINGLE
+   depends on ARCH_MULTI_V5
+   default ARCH_VT8500_SINGLE
+   select ARCH_VT8500
+   select CPU_ARM926T
help
  Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip.
+
+config ARCH_WM8750
+   bool WonderMedia WM8750
+   depends on ARCH_MULTI_V6 || ARCH_WM8750_SINGLE
+   select ARCH_VT8500
+   select CPU_V6
+   help
+ Support for WonderMedia WM8750 System-on-Chip.
+
+config ARCH_WM8850
+   bool WonderMedia WM8850
+   depends on ARCH_MULTI_V7 || ARCH_WM8750_SINGLE
+   select ARCH_VT8500
+   select CPU_V7
+   help
+ Support for WonderMedia WM8850 System-on-Chip.
+
+# ensure that ARCH_WM8850 is on if ARCH_WM8750 is off
+config ARCH_WM8850_AUTO
+  def_bool y
+  depends on ARCH_WM8750_SINGLE  !ARCH_WM8750
+  select ARCH_WM8850
diff --git a/arch/arm/mach-vt8500/vt8500.c b/arch/arm/mach-vt8500/vt8500.c
index 3c66d48..55162ab 100644
--- a/arch/arm/mach-vt8500/vt8500.c
+++ b/arch/arm/mach-vt8500/vt8500.c
@@ -183,6 +183,8 @@ static const char * const vt8500_dt_compat[] = {
via,vt8500,
wm,wm8650,
wm,wm8505,
+   wm,wm8750,
+   wm,wm8850,
 };
 
 DT_MACHINE_START(WMT_DT, VIA/Wondermedia SoC (Device Tree Support))
-- 
1.7.9.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 0/4] arm: vt8500: Add support for Wondermedia WM8750/WM8850

2013-01-11 Thread Tony Prisk
The following changes since commit a49f0d1ea3ec94fc7cf33a7c36a16343b74bd565:

  Linux 3.8-rc1 (2012-12-21 17:19:00 -0800)

are available in the git repository at:

  git://server.prisktech.co.nz/git/linuxwmt.git tags/armsoc-3.9

for you to fetch changes up to 82c8f175662873f7f7f4c7869ee963d7d967:

  arm: vt8500: Remove remaining mach includes (2012-12-28 21:05:19 +1300)


arm: vt8500: Add support for WM8750/WM8850. Cleanup multiplatform changes

This patchset adds support for the WM8750 (ARMv6) and WM8850 (ARMv7), and
cleans up changes for multiplatform configuration.

Single platform Kconfig options are removed, along with the remaining
mach/includes.

The debug-macro.s is moved to arm/include/debug/ to allow DEBUG_LL on
multi-platform.

Signed-off-by: Tony Prisk li...@prisktech.co.nz


Tony Prisk (4):
  arm: vt8500: Add support for Wondermedia WM8750/WM8850
  arm: vt8500: Remove single platform Kconfig options
  arm: vt8500: Convert debug-macro.S to be multiplatform friendly
  arm: vt8500: Remove remaining mach includes

 Documentation/devicetree/bindings/arm/vt8500.txt   |8 +
 arch/arm/Kconfig   |   16 -
 arch/arm/Kconfig.debug |8 +
 .../mach/debug-macro.S = include/debug/vt8500.S}  |   24 -
 arch/arm/mach-vt8500/Kconfig   |   26 --
 arch/arm/mach-vt8500/include/mach/timex.h  |   26 --
 arch/arm/mach-vt8500/include/mach/uncompress.h |   37 
 arch/arm/mach-vt8500/vt8500.c  |2 ++
 8 files changed, 56 insertions(+), 91 deletions(-)
 rename arch/arm/{mach-vt8500/include/mach/debug-macro.S = 
include/debug/vt8500.S} (56%)
 delete mode 100644 arch/arm/mach-vt8500/include/mach/timex.h
 delete mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h
--
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 2/4] arm: vt8500: Remove single platform Kconfig options

2013-01-11 Thread Tony Prisk
This patch completes the move of arch-vt8500 to multiplatform only.

The remaining single-image Kconfig options are removed from
arch/arm/Kconfig and the options in arch/arm/mach-vt8500/Kconfig
are updated.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 arch/arm/Kconfig |   21 -
 arch/arm/mach-vt8500/Kconfig |   13 +++--
 2 files changed, 3 insertions(+), 31 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fbb9492..76efd43 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -950,27 +950,6 @@ config ARCH_OMAP
help
  Support for TI's OMAP platform (OMAP1/2/3/4).
 
-config ARCH_VT8500_SINGLE
-   bool VIA/WonderMedia 85xx
-   select ARCH_VT8500
-   select COMMON_CLK
-   select CPU_ARM926T
-   select MULTI_IRQ_HANDLER
-   select SPARSE_IRQ
-   select USE_OF
-   help
- Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip.
-
-config ARCH_WM8750_SINGLE
-   bool WonderMedia WM8750/WM8850
-   select ARCH_VT8500
-   select COMMON_CLK
-   select MULTI_IRQ_HANDLER
-   select SPARSE_IRQ
-   select USE_OF
-   help
- Support for WonderMedia WM8750/WM8850 System-on-Chip.
-
 endchoice
 
 menu Multiple platform selection
diff --git a/arch/arm/mach-vt8500/Kconfig b/arch/arm/mach-vt8500/Kconfig
index d67c7fa..f466b58 100644
--- a/arch/arm/mach-vt8500/Kconfig
+++ b/arch/arm/mach-vt8500/Kconfig
@@ -8,9 +8,8 @@ config ARCH_VT8500
select HAVE_CLK
 
 config ARCH_WM8505
-   bool VIA/WonderMedia 85xx if !ARCH_VT8500_SINGLE
+   bool VIA/WonderMedia 85xx
depends on ARCH_MULTI_V5
-   default ARCH_VT8500_SINGLE
select ARCH_VT8500
select CPU_ARM926T
help
@@ -18,7 +17,7 @@ config ARCH_WM8505
 
 config ARCH_WM8750
bool WonderMedia WM8750
-   depends on ARCH_MULTI_V6 || ARCH_WM8750_SINGLE
+   depends on ARCH_MULTI_V6
select ARCH_VT8500
select CPU_V6
help
@@ -26,14 +25,8 @@ config ARCH_WM8750
 
 config ARCH_WM8850
bool WonderMedia WM8850
-   depends on ARCH_MULTI_V7 || ARCH_WM8750_SINGLE
+   depends on ARCH_MULTI_V7
select ARCH_VT8500
select CPU_V7
help
  Support for WonderMedia WM8850 System-on-Chip.
-
-# ensure that ARCH_WM8850 is on if ARCH_WM8750 is off
-config ARCH_WM8850_AUTO
-  def_bool y
-  depends on ARCH_WM8750_SINGLE  !ARCH_WM8750
-  select ARCH_WM8850
-- 
1.7.9.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 4/4] arm: vt8500: Remove remaining mach includes

2013-01-11 Thread Tony Prisk
Remove the last two mach-vt8500/include/mach headers as they are
no longer required with multiplatform-only configuration.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 arch/arm/mach-vt8500/include/mach/timex.h  |   26 -
 arch/arm/mach-vt8500/include/mach/uncompress.h |   37 
 2 files changed, 63 deletions(-)
 delete mode 100644 arch/arm/mach-vt8500/include/mach/timex.h
 delete mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h

diff --git a/arch/arm/mach-vt8500/include/mach/timex.h 
b/arch/arm/mach-vt8500/include/mach/timex.h
deleted file mode 100644
index 8487e4c..000
--- a/arch/arm/mach-vt8500/include/mach/timex.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *  arch/arm/mach-vt8500/include/mach/timex.h
- *
- *  Copyright (C) 2010 Alexey Charkov alch...@gmail.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
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef MACH_TIMEX_H
-#define MACH_TIMEX_H
-
-#define CLOCK_TICK_RATE(300)
-
-#endif /* MACH_TIMEX_H */
diff --git a/arch/arm/mach-vt8500/include/mach/uncompress.h 
b/arch/arm/mach-vt8500/include/mach/uncompress.h
deleted file mode 100644
index e6e81fd..000
--- a/arch/arm/mach-vt8500/include/mach/uncompress.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* arch/arm/mach-vt8500/include/mach/uncompress.h
- *
- * Copyright (C) 2010 Alexey Charkov alch...@gmail.com
- *
- * Based on arch/arm/mach-dove/include/mach/uncompress.h
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#define UART0_PHYS 0xd820
-#define UART0_ADDR(x)  *(volatile unsigned char *)(UART0_PHYS + x)
-
-static void putc(const char c)
-{
-   while (UART0_ADDR(0x1c)  0x2)
-   /* Tx busy, wait and poll */;
-
-   UART0_ADDR(0) = c;
-}
-
-static void flush(void)
-{
-}
-
-/*
- * nothing to do
- */
-#define arch_decomp_setup()
-#define arch_decomp_wdog()
-- 
1.7.9.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] arm: vt8500: Convert debug-macro.S to be multiplatform friendly

2013-01-11 Thread Tony Prisk
This patch moves debug-macro.S from arm/mach-vt8500/include/mach to
arm/include/debug/vt8500.S to provide multiplatform support.

Minor style changes in code for readability.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 arch/arm/Kconfig.debug  |8 +
 arch/arm/include/debug/vt8500.S |   37 +++
 arch/arm/mach-vt8500/include/mach/debug-macro.S |   31 ---
 3 files changed, 45 insertions(+), 31 deletions(-)
 create mode 100644 arch/arm/include/debug/vt8500.S
 delete mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 661030d..bbb0a67 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -412,6 +412,13 @@ choice
  of the tiles using the RS1 memory map, including all new 
A-class
  core tiles, FPGA-based SMMs and software models.
 
+   config DEBUG_VT8500_UART0
+   bool Use UART0 on VIA/Wondermedia SoCs
+   depends on ARCH_VT8500
+   help
+ This option selects UART0 on VIA/Wondermedia System-on-a-chip
+ devices, including VT8500, WM8505, WM8650 and WM8850.
+
config DEBUG_LL_UART_NONE
bool No low-level debugging UART
depends on !ARCH_MULTIPLATFORM
@@ -506,6 +513,7 @@ config DEBUG_LL_INCLUDE
default debug/sunxi.S if DEBUG_SUNXI_UART0 || DEBUG_SUNXI_UART1
default debug/vexpress.S if DEBUG_VEXPRESS_UART0_DETECT || \
DEBUG_VEXPRESS_UART0_CA9 || DEBUG_VEXPRESS_UART0_RS1
+   default debug/vt8500.S if DEBUG_VT8500_UART0
default debug/tegra.S if DEBUG_TEGRA_UART
default debug/zynq.S if DEBUG_ZYNQ_UART0 || DEBUG_ZYNQ_UART1
default mach/debug-macro.S
diff --git a/arch/arm/include/debug/vt8500.S b/arch/arm/include/debug/vt8500.S
new file mode 100644
index 000..0e0ca08
--- /dev/null
+++ b/arch/arm/include/debug/vt8500.S
@@ -0,0 +1,37 @@
+/* 
+ * Debugging macro include header
+ *
+ *  Copyright (C) 2010 Alexey Charkov alch...@gmail.com
+ *Moved from arch/arm/mach-vt8500/include/mach/debug-macro.S
+ *Minor changes for readability.
+ *
+ * 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.
+ */
+
+#define DEBUG_LL_PHYS_BASE 0xD800
+#define DEBUG_LL_VIRT_BASE 0xF800
+#define DEBUG_LL_UART_OFFSET   0x0020
+
+#if defined(CONFIG_DEBUG_VT8500_UART0)
+   .macro  addruart, rp, rv, tmp
+   mov \rp,  #DEBUG_LL_UART_OFFSET
+   orr \rv, \rp, #DEBUG_LL_VIRT_BASE
+   orr \rp, \rp, #DEBUG_LL_PHYS_BASE
+   .endm
+
+   .macro  senduart,rd,rx
+   strb\rd, [\rx, #0]
+   .endm
+
+   .macro  busyuart,rd,rx
+1001:  ldr \rd, [\rx, #0x1c]
+   ands\rd, \rd, #0x2
+   bne 1001b
+   .endm
+
+   .macro  waituart,rd,rx
+   .endm
+
+#endif
diff --git a/arch/arm/mach-vt8500/include/mach/debug-macro.S 
b/arch/arm/mach-vt8500/include/mach/debug-macro.S
deleted file mode 100644
index ca292f2..000
--- a/arch/arm/mach-vt8500/include/mach/debug-macro.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * arch/arm/mach-vt8500/include/mach/debug-macro.S
- *
- *  Copyright (C) 2010 Alexey Charkov alch...@gmail.com
- *
- * Debugging macro include header
- *
- * 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.
- *
-*/
-
-   .macro  addruart, rp, rv, tmp
-   mov \rp,  #0x0020
-   orr \rv, \rp, #0xf800
-   orr \rp, \rp, #0xd800
-   .endm
-
-   .macro  senduart,rd,rx
-   strb\rd, [\rx, #0]
-   .endm
-
-   .macro  busyuart,rd,rx
-1001:  ldr \rd, [\rx, #0x1c]
-   ands\rd, \rd, #0x2
-   bne 1001b
-   .endm
-
-   .macro  waituart,rd,rx
-   .endm
-- 
1.7.9.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 0/4] arm: vt8500: Add support for Wondermedia WM8750/WM8850

2013-01-11 Thread Tony Prisk
 I suggest that you split off the last three (and rebase them to be
 independent), and apply them to a multiplatform branch for vt8500. Then the
 last one is a soc branch that goes on top of the multiplatform branch (i.e. 
 you
 build it on top of multiplatform). That way we can pull in the multiplatform
 changes together with those for other platforms, and then take the wm8{7,8}50
 branch goes in with the other new-soc support from other platforms.
 
 Does that make sense? I'll be happy to provide more explanation if it doesn't.
 
 -Olof

I think I understand - pull requests to follow.

Tony P

--
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 0/4] arm: vt8500: Add support for Wondermedia WM8750/WM8850

2013-01-11 Thread Tony Prisk
The following changes since commit
d1c3ed669a2d452cacfb48c2d171a1f364dae2ed:

  Linux 3.8-rc2 (2013-01-02 18:13:21 -0800)

are available in the git repository at:

  git://server.prisktech.co.nz/git/linuxwmt.git
tags/vt8500-multiplatform-3.9

for you to fetch changes up to ce3f386fdf10d79eaf6ebd63bb7adbd95f08f9f0:

  arm: vt8500: Remove remaining mach includes (2013-01-12 15:47:39
+1300)


arm: vt8500: Convert arch-vt8500 to multiplatform only.


Tony Prisk (3):
  arm: vt8500: Remove single platform Kconfig options
  arm: vt8500: Convert debug-macro.S to be multiplatform friendly
  arm: vt8500: Remove remaining mach includes

 arch/arm/Kconfig   |   16 -
 arch/arm/Kconfig.debug |8 +
 .../mach/debug-macro.S = include/debug/vt8500.S}  |   24 -
 arch/arm/mach-vt8500/Kconfig   |   11 --
 arch/arm/mach-vt8500/include/mach/timex.h  |   26
--
 arch/arm/mach-vt8500/include/mach/uncompress.h |   37

 6 files changed, 31 insertions(+), 91 deletions(-)
 rename arch/arm/{mach-vt8500/include/mach/debug-macro.S =
include/debug/vt8500.S} (56%)
 delete mode 100644 arch/arm/mach-vt8500/include/mach/timex.h
 delete mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h

--
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 0/4] arm: vt8500: Add support for Wondermedia WM8750/WM8850

2013-01-11 Thread Tony Prisk
The following changes since commit
ce3f386fdf10d79eaf6ebd63bb7adbd95f08f9f0:

  arm: vt8500: Remove remaining mach includes (2013-01-12 15:47:39
+1300)

are available in the git repository at:

  git://server.prisktech.co.nz/git/linuxwmt.git tags/armsoc-3.9

for you to fetch changes up to 8d31bfa551b9a1a61119e6d8fde08d0fa8cdfafb:

  arm: vt8500: Add support for Wondermedia WM8750/WM8850 (2013-01-12
15:51:24 +1300)


arm: vt8500: Add support for WM8750 and WM8850 SoCs.

This pull should be on top of:
git://server.prisktech.co.nz/git/linuxwmt.git
tags/vt8500-multiplatform-3.9


Tony Prisk (1):
  arm: vt8500: Add support for Wondermedia WM8750/WM8850

 Documentation/devicetree/bindings/arm/vt8500.txt |8 
 arch/arm/mach-vt8500/Kconfig |   16

 arch/arm/mach-vt8500/vt8500.c|2 ++
 3 files changed, 26 insertions(+)

--
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/


[GIT PULL] clk: vt8500: Clock fixes for 3.8

2013-01-11 Thread Tony Prisk
Hi Mike,


The following changes since commit
a49f0d1ea3ec94fc7cf33a7c36a16343b74bd565:

  Linux 3.8-rc1 (2012-12-21 17:19:00 -0800)

are available in the git repository at:

  git://server.prisktech.co.nz/git/linuxwmt.git tags/clk-fixes-3.8

for you to fetch changes up to a3c2b58889440dcc6de92d04f09e8fcaf6bf7e2e:

  clk: vt8500: Fix division-by-0 when requested rate=0 (2012-12-27
13:07:23 +1300)


clk: vt8500: Clock fixes for v3.8

Small series of fixes for clocks on vt8500.

Signed-off-by: Tony Prisk li...@prisktech.co.nz


Tony Prisk (3):
  clk: vt8500: Fix error in PLL calculations on non-exact match.
  clk: vt8500: Fix device clock divisor calculations
  clk: vt8500: Fix division-by-0 when requested rate=0

 drivers/clk/clk-vt8500.c |   28 +++-
 1 file changed, 23 insertions(+), 5 deletions(-)

--
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] mmc: vt8500: Remove erroneous __exitp in wmt_mci_driver

2013-01-12 Thread Tony Prisk
With the __devinit/__devexit attributes having been removed, this
__exitp attribute causes an unused function warning and should be
removed as well.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/mmc/host/wmt-sdmmc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c
index 154f0e8..c6d0015 100644
--- a/drivers/mmc/host/wmt-sdmmc.c
+++ b/drivers/mmc/host/wmt-sdmmc.c
@@ -1012,7 +1012,7 @@ static const struct dev_pm_ops wmt_mci_pm = {
 
 static struct platform_driver wmt_mci_driver = {
.probe = wmt_mci_probe,
-   .remove = __exit_p(wmt_mci_remove),
+   .remove = wmt_mci_remove,
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
-- 
1.7.9.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] serial: vt8500: UART uses gated clock rather than 24Mhz reference

2013-01-13 Thread Tony Prisk
UART modules on Wondermedia SoCs are connected via a gated clock
source, rather than directly to the 24Mhz reference clock. While
uboot enables UART0 for debugging, other UART ports are unavailable
until the clock is enabled.

This patch checks that a valid clock is actually passed from devicetree,
enables the clock in probe. This change removes the fallback when a
clock was not specified as it doesn't apply any longer (and would only
work if the UART clock was already enabled).

DTSI files are updated for VT8500, WM8505 and WM8650.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 arch/arm/boot/dts/vt8500.dtsi  |   40 +---
 arch/arm/boot/dts/wm8505.dtsi  |   60 
 arch/arm/boot/dts/wm8650.dtsi  |   20 ++--
 drivers/tty/serial/vt8500_serial.c |   17 ++
 4 files changed, 119 insertions(+), 18 deletions(-)

diff --git a/arch/arm/boot/dts/vt8500.dtsi b/arch/arm/boot/dts/vt8500.dtsi
index d8645e9..cf31ced 100644
--- a/arch/arm/boot/dts/vt8500.dtsi
+++ b/arch/arm/boot/dts/vt8500.dtsi
@@ -45,6 +45,38 @@
compatible = fixed-clock;
clock-frequency = 2400;
};
+
+   clkuart0: uart0 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock;
+   clocks = ref24;
+   enable-reg = 0x250;
+   enable-bit = 1;
+   };
+
+   clkuart1: uart1 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock;
+   clocks = ref24;
+   enable-reg = 0x250;
+   enable-bit = 2;
+   };
+
+   clkuart2: uart2 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock;
+   clocks = ref24;
+   enable-reg = 0x250;
+   enable-bit = 3;
+   };
+
+   clkuart3: uart3 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock;
+   clocks = ref24;
+   enable-reg = 0x250;
+   enable-bit = 4;
+   };
};
};
 
@@ -83,28 +115,28 @@
compatible = via,vt8500-uart;
reg = 0xd820 0x1040;
interrupts = 32;
-   clocks = ref24;
+   clocks = clkuart0;
};
 
uart@d82b {
compatible = via,vt8500-uart;
reg = 0xd82b 0x1040;
interrupts = 33;
-   clocks = ref24;
+   clocks = clkuart1;
};
 
uart@d821 {
compatible = via,vt8500-uart;
reg = 0xd821 0x1040;
interrupts = 47;
-   clocks = ref24;
+   clocks = clkuart2;
};
 
uart@d82c {
compatible = via,vt8500-uart;
reg = 0xd82c 0x1040;
interrupts = 50;
-   clocks = ref24;
+   clocks = clkuart3;
};
 
rtc@d810 {
diff --git a/arch/arm/boot/dts/wm8505.dtsi b/arch/arm/boot/dts/wm8505.dtsi
index 330f833..e74a1c0 100644
--- a/arch/arm/boot/dts/wm8505.dtsi
+++ b/arch/arm/boot/dts/wm8505.dtsi
@@ -59,6 +59,54 @@
compatible = fixed-clock;
clock-frequency = 2400;
};
+
+   clkuart0: uart0 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock;
+   clocks = ref24;
+   enable-reg = 0x250;
+   enable-bit = 1;
+   };
+
+   clkuart1: uart1 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock

[PATCH 4/4] serial: tty: Cleanup code using devm_ function

2013-01-13 Thread Tony Prisk
Convert the last memory allocation (vt8500_port) to use devm_kzalloc
and remove the fail path cleanup code from vt8500_serial_probe.

Reorder iomem mapping above clk_enable to simplify fail code. The
clock is only enabled if all other resources are available.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/tty/serial/vt8500_serial.c |   23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c 
b/drivers/tty/serial/vt8500_serial.c
index 7de279a..1ddae81 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -589,7 +589,8 @@ static int vt8500_serial_probe(struct platform_device *pdev)
return -EBUSY;
}
 
-   vt8500_port = kzalloc(sizeof(struct vt8500_port), GFP_KERNEL);
+   vt8500_port = devm_kzalloc(pdev-dev, sizeof(struct vt8500_port),
+  GFP_KERNEL);
if (!vt8500_port)
return -ENOMEM;
 
@@ -603,28 +604,25 @@ static int vt8500_serial_probe(struct platform_device 
*pdev)
vt8500_port-uart.dev = pdev-dev;
vt8500_port-uart.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
 
+   vt8500_port-uart.membase = devm_request_and_ioremap(pdev-dev, mmres);
+   if (!vt8500_port-uart.membase)
+   return -EBUSY;
+
vt8500_port-clk = of_clk_get(pdev-dev.of_node, 0);
if (IS_ERR(vt8500_port-clk)) {
dev_err(pdev-dev, failed to get clock\n);
-   ret = -EINVAL;
-   goto err;
+   return -EINVAL;
}
 
ret = clk_prepare_enable(vt8500_port-clk);
if (ret) {
dev_err(pdev-dev, failed to enable clock\n);
-   goto err;
+   return ret;
}
 
snprintf(vt8500_port-name, sizeof(vt8500_port-name),
 VT8500 UART%d, pdev-id);
 
-   vt8500_port-uart.membase = devm_request_and_ioremap(pdev-dev, mmres);
-   if (!vt8500_port-uart.membase) {
-   ret = -EBUSY;
-   goto err;
-   }
-
vt8500_uart_ports[port] = vt8500_port;
 
uart_add_one_port(vt8500_uart_driver, vt8500_port-uart);
@@ -632,10 +630,6 @@ static int vt8500_serial_probe(struct platform_device 
*pdev)
platform_set_drvdata(pdev, vt8500_port);
 
return 0;
-
-err:
-   kfree(vt8500_port);
-   return ret;
 }
 
 static int vt8500_serial_remove(struct platform_device *pdev)
@@ -645,7 +639,6 @@ static int vt8500_serial_remove(struct platform_device 
*pdev)
platform_set_drvdata(pdev, NULL);
clk_disable_unprepare(vt8500_port-clk);
uart_remove_one_port(vt8500_uart_driver, vt8500_port-uart);
-   kfree(vt8500_port);
 
return 0;
 }
-- 
1.7.9.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 2/4] serial: vt8500: ioremap'd resource is never freed

2013-01-13 Thread Tony Prisk
Memory mapped via ioremap call is never released. Rather than add an
iounmap call, change allocation function to devm_request_and_ioremap.

Also, change the error on failure for this call to -EBUSY rather than
-ENOMEM.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/tty/serial/vt8500_serial.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c 
b/drivers/tty/serial/vt8500_serial.c
index 4c4a58d..8865afd 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -615,9 +615,9 @@ static int vt8500_serial_probe(struct platform_device *pdev)
snprintf(vt8500_port-name, sizeof(vt8500_port-name),
 VT8500 UART%d, pdev-id);
 
-   vt8500_port-uart.membase = ioremap(mmres-start, resource_size(mmres));
+   vt8500_port-uart.membase = devm_request_and_ioremap(pdev-dev, mmres);
if (!vt8500_port-uart.membase) {
-   ret = -ENOMEM;
+   ret = -EBUSY;
goto err;
}
 
-- 
1.7.9.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/


[GIT PULL] Fixes/cleanup for vt8500 serial driver

2013-01-13 Thread Tony Prisk
Hi Greg,

This is a series of fixes/cleanup for the vt8500 serial/uart driver.

I'm not sure how you want to handle these.

Arguably #1, #2 and #3 are bug fixes which could go into 3.8. None of
them cause immediate problems, but potentially could.

#4 is definately a cleanup for 3.9.

Let me know if you would rather I split them up and how.

Regards
Tony P


The following changes since commit 9931faca02c604c22335f5a935a501bb2ace6e20:

  Linux 3.8-rc3 (2013-01-09 18:59:55 -0800)

are available in the git repository at:

  git://server.prisktech.co.nz/git/linuxwmt.git tags/vt8500-serial-fixes

for you to fetch changes up to 55df4e19676ca7674bcdc5831036ed3f708050e8:

  serial: tty: Cleanup code using devm_ function (2013-01-14 05:39:17 +1300)


Series of fixes/cleanups for vt8500 serial/UART driver.


Tony Prisk (4):
  serial: vt8500: Fix range-checking on vt8500_uart_ports
  serial: vt8500: ioremap'd resource is never freed
  serial: vt8500: UART uses gated clock rather than 24Mhz reference
  serial: tty: Cleanup code using devm_ function

 arch/arm/boot/dts/vt8500.dtsi  |   40 +---
 arch/arm/boot/dts/wm8505.dtsi  |   60 
 arch/arm/boot/dts/wm8650.dtsi  |   20 ++--
 drivers/tty/serial/vt8500_serial.c |   38 +++
 4 files changed, 126 insertions(+), 32 deletions(-)
--
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] serial: vt8500: Fix range-checking on vt8500_uart_ports

2013-01-13 Thread Tony Prisk
Fix two instances where the index to vt8500_uart_ports is tested
against  VT8500_MAX_PORTS. Correct usage should be = VT8500_MAX_PORTS.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/tty/serial/vt8500_serial.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c 
b/drivers/tty/serial/vt8500_serial.c
index 8fd1814..4c4a58d 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -569,7 +569,7 @@ static int vt8500_serial_probe(struct platform_device *pdev)
 
if (np)
port = of_alias_get_id(np, serial);
-   if (port  VT8500_MAX_PORTS)
+   if (port = VT8500_MAX_PORTS)
port = -1;
else
port = -1;
@@ -580,7 +580,7 @@ static int vt8500_serial_probe(struct platform_device *pdev)
sizeof(vt8500_ports_in_use));
}
 
-   if (port  VT8500_MAX_PORTS)
+   if (port = VT8500_MAX_PORTS)
return -ENODEV;
 
/* reserve the port id */
-- 
1.7.9.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] timer: vt8500: Move timer code to drivers/clocksource

2013-01-13 Thread Tony Prisk
This patch moves arch-vt8500/timer.c into drivers/clocksource and
updates the necessary Kconfig/Makefile options.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 arch/arm/mach-vt8500/Kconfig   |1 +
 arch/arm/mach-vt8500/Makefile  |2 +-
 arch/arm/mach-vt8500/common.h  |1 -
 arch/arm/mach-vt8500/timer.c   |  184 
 arch/arm/mach-vt8500/vt8500.c  |1 +
 drivers/clocksource/Kconfig|3 +
 drivers/clocksource/Makefile   |1 +
 drivers/clocksource/vt8500_timer.c |  184 
 include/linux/vt8500_timer.h   |   22 +
 9 files changed, 213 insertions(+), 186 deletions(-)
 delete mode 100644 arch/arm/mach-vt8500/timer.c
 create mode 100644 drivers/clocksource/vt8500_timer.c
 create mode 100644 include/linux/vt8500_timer.h

diff --git a/arch/arm/mach-vt8500/Kconfig b/arch/arm/mach-vt8500/Kconfig
index 2ed0b7d..570a801 100644
--- a/arch/arm/mach-vt8500/Kconfig
+++ b/arch/arm/mach-vt8500/Kconfig
@@ -8,5 +8,6 @@ config ARCH_VT8500
select GENERIC_CLOCKEVENTS
select GENERIC_GPIO
select HAVE_CLK
+   select VT8500_TIMER
help
  Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip.
diff --git a/arch/arm/mach-vt8500/Makefile b/arch/arm/mach-vt8500/Makefile
index e035251..92ceb24 100644
--- a/arch/arm/mach-vt8500/Makefile
+++ b/arch/arm/mach-vt8500/Makefile
@@ -1 +1 @@
-obj-$(CONFIG_ARCH_VT8500) += irq.o timer.o vt8500.o
+obj-$(CONFIG_ARCH_VT8500) += irq.o vt8500.o
diff --git a/arch/arm/mach-vt8500/common.h b/arch/arm/mach-vt8500/common.h
index 6f2b843..77611a6 100644
--- a/arch/arm/mach-vt8500/common.h
+++ b/arch/arm/mach-vt8500/common.h
@@ -18,7 +18,6 @@
 
 #include linux/of.h
 
-void __init vt8500_timer_init(void);
 int __init vt8500_irq_init(struct device_node *node,
struct device_node *parent);
 
diff --git a/arch/arm/mach-vt8500/timer.c b/arch/arm/mach-vt8500/timer.c
deleted file mode 100644
index 3dd21a4..000
--- a/arch/arm/mach-vt8500/timer.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- *  arch/arm/mach-vt8500/timer.c
- *
- *  Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
- *  Copyright (C) 2010 Alexey Charkov alch...@gmail.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
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*
- * This file is copied and modified from the original timer.c provided by
- * Alexey Charkov. Minor changes have been made for Device Tree Support.
- */
-
-#include linux/io.h
-#include linux/irq.h
-#include linux/interrupt.h
-#include linux/clocksource.h
-#include linux/clockchips.h
-#include linux/delay.h
-#include asm/mach/time.h
-
-#include linux/of.h
-#include linux/of_address.h
-#include linux/of_irq.h
-
-#define VT8500_TIMER_OFFSET0x0100
-#define VT8500_TIMER_HZ300
-#define TIMER_MATCH_VAL0x
-#define TIMER_COUNT_VAL0x0010
-#define TIMER_STATUS_VAL   0x0014
-#define TIMER_IER_VAL  0x001c  /* interrupt enable */
-#define TIMER_CTRL_VAL 0x0020
-#define TIMER_AS_VAL   0x0024  /* access status */
-#define TIMER_COUNT_R_ACTIVE   (1  5)/* not ready for read */
-#define TIMER_COUNT_W_ACTIVE   (1  4)/* not ready for write */
-#define TIMER_MATCH_W_ACTIVE   (1  0)/* not ready for write */
-
-#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
-
-static void __iomem *regbase;
-
-static cycle_t vt8500_timer_read(struct clocksource *cs)
-{
-   int loops = msecs_to_loops(10);
-   writel(3, regbase + TIMER_CTRL_VAL);
-   while ((readl((regbase + TIMER_AS_VAL))  TIMER_COUNT_R_ACTIVE)
---loops)
-   cpu_relax();
-   return readl(regbase + TIMER_COUNT_VAL);
-}
-
-static struct clocksource clocksource = {
-   .name   = vt8500_timer,
-   .rating = 200,
-   .read   = vt8500_timer_read,
-   .mask   = CLOCKSOURCE_MASK(32),
-   .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
-static int vt8500_timer_set_next_event(unsigned long cycles,
-   struct clock_event_device *evt)
-{
-   int loops = msecs_to_loops(10);
-   cycle_t alarm = clocksource.read(clocksource) + cycles

[GIT PULL] timer: vt8500: Move timer code to drivers/clocksource

2013-01-13 Thread Tony Prisk
Hi Olof,

Not sure if I have done this correctly but this is the patch to move the
vt8500/timer.c code into drivers/clocksource.

I based it on timer/cleanup from armsoc (hopefully this is right - if not, a
few pointers in the right direction would be appreciated).

Regards
Tony P


The following changes since commit 1c2584c3a1c882fec729147a46d822522552e38c:

  ARM: sunxi: fix struct sys_timer removal (2013-01-08 10:50:43 -0800)

are available in the git repository at:

  git://server.prisktech.co.nz/git/linuxwmt.git tags/vt8500/timer

for you to fetch changes up to ff7ec345f0ece9ddbb28538b70ba0c7f0acc17dc:

  timer: vt8500: Move timer code to drivers/clocksource (2013-01-14 17:58:21 
+1300)


Move arch-vt8500/timer.c to drivers/clocksource/vt8500-timer.c


Tony Prisk (1):
  timer: vt8500: Move timer code to drivers/clocksource

 arch/arm/mach-vt8500/Kconfig   |1 +
 arch/arm/mach-vt8500/Makefile  |2 +-
 arch/arm/mach-vt8500/common.h  |1 -
 arch/arm/mach-vt8500/vt8500.c  |1 +
 drivers/clocksource/Kconfig|3 +++
 drivers/clocksource/Makefile   |1 +
 .../timer.c = drivers/clocksource/vt8500_timer.c  |0
 include/linux/vt8500_timer.h   |   22 
 8 files changed, 29 insertions(+), 2 deletions(-)
 rename arch/arm/mach-vt8500/timer.c = drivers/clocksource/vt8500_timer.c 
(100%)
 create mode 100644 include/linux/vt8500_timer.h
--
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: [Bulk] [PATCH] timer: vt8500: Move timer code to drivers/clocksource

2013-01-13 Thread Tony Prisk
On Mon, 2013-01-14 at 18:09 +1300, Tony Prisk wrote:
 This patch moves arch-vt8500/timer.c into drivers/clocksource and
 updates the necessary Kconfig/Makefile options.
 
 Signed-off-by: Tony Prisk li...@prisktech.co.nz
 ---
  arch/arm/mach-vt8500/Kconfig   |1 +
  arch/arm/mach-vt8500/Makefile  |2 +-
  arch/arm/mach-vt8500/common.h  |1 -
  arch/arm/mach-vt8500/timer.c   |  184 
 
  arch/arm/mach-vt8500/vt8500.c  |1 +
  drivers/clocksource/Kconfig|3 +
  drivers/clocksource/Makefile   |1 +
  drivers/clocksource/vt8500_timer.c |  184 
 
  include/linux/vt8500_timer.h   |   22 +
  9 files changed, 213 insertions(+), 186 deletions(-)
  delete mode 100644 arch/arm/mach-vt8500/timer.c
  create mode 100644 drivers/clocksource/vt8500_timer.c
  create mode 100644 include/linux/vt8500_timer.h

Darn.. forgot the -m again. I'll await your feedback regarding the
basing of the patch first (and any other feedback), then I'll redo it
with the correct stats.

Regards
Tony P

--
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: [Bulk] [PATCH] timer: vt8500: Move timer code to drivers/clocksource

2013-01-13 Thread Tony Prisk
On Mon, 2013-01-14 at 18:13 +1300, Tony Prisk wrote:
 On Mon, 2013-01-14 at 18:09 +1300, Tony Prisk wrote:
  This patch moves arch-vt8500/timer.c into drivers/clocksource and
  updates the necessary Kconfig/Makefile options.
  
  Signed-off-by: Tony Prisk li...@prisktech.co.nz
  ---
   arch/arm/mach-vt8500/Kconfig   |1 +
   arch/arm/mach-vt8500/Makefile  |2 +-
   arch/arm/mach-vt8500/common.h  |1 -
   arch/arm/mach-vt8500/timer.c   |  184 
  
   arch/arm/mach-vt8500/vt8500.c  |1 +
   drivers/clocksource/Kconfig|3 +
   drivers/clocksource/Makefile   |1 +
   drivers/clocksource/vt8500_timer.c |  184 
  
   include/linux/vt8500_timer.h   |   22 +
   9 files changed, 213 insertions(+), 186 deletions(-)
   delete mode 100644 arch/arm/mach-vt8500/timer.c
   create mode 100644 drivers/clocksource/vt8500_timer.c
   create mode 100644 include/linux/vt8500_timer.h
 
 Darn.. forgot the -m again. I'll await your feedback regarding the
 basing of the patch first (and any other feedback), then I'll redo it
 with the correct stats.
 
 Regards
 Tony P

Oh grr.. forget this completely. It doesn't take into account the
patches I already sent for WM8850.

I guess it needs to be based on timer/cleanup + vt8500/wm8x50.

Need a little advise on how to handle this one please :)

Regards
Tony P

--
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: [Bulk] [PATCH] timer: vt8500: Move timer code to drivers/clocksource

2013-01-13 Thread Tony Prisk
 Oh grr.. forget this completely. It doesn't take into account the
 patches I already sent for WM8850.
 
 I guess it needs to be based on timer/cleanup + vt8500/wm8x50.
 
 Need a little advise on how to handle this one please :)
 
 Regards
 Tony P

Turns out the original patch applies cleanly on timer/cleanup +
vt8500/wm8x50 anyway so maybe it doesn't need to be rebased.

Let me know if I need to do anything (other than the -m to cleanup the
stats).

Regards
Tony P

--
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] gpio: vt8500: memory cleanup missing

2013-01-14 Thread Tony Prisk
This driver is missing a .remove callback, and the fail path on
probe is incomplete.

If an error occurs in vt8500_add_chips, gpio_base is not unmapped.
The driver is also ignoring the return value from this function so
if a chip fails to register it completes as successful.

Replaced pr_err with dev_err in vt8500_add_chips since the device is
available.

There is also no .remove callback defined. To allow removing the
registered chips, I have moved *vtchip to be a static global.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
Hi Grant,

Let me know what you think of these changes.

v2:
Removed unnecessary whitespace change.
Removed test against pdev-dev.of_node (np). Replaced code with a
  devm_request_and_ioremap so np is now unneccessary. This also removes the need
  for cleanup in the fail path.
Move struct vt8500_gpio_chip within vt8500_data and store the iobase and
  num_banks in vt8500_data.


 drivers/gpio/gpio-vt8500.c |   61 +++-
 1 file changed, 49 insertions(+), 12 deletions(-)

diff --git a/drivers/gpio/gpio-vt8500.c b/drivers/gpio/gpio-vt8500.c
index b53320a..5c8cd7c 100644
--- a/drivers/gpio/gpio-vt8500.c
+++ b/drivers/gpio/gpio-vt8500.c
@@ -127,6 +127,12 @@ struct vt8500_gpio_chip {
void __iomem*base;
 };
 
+struct vt8500_data {
+   struct vt8500_gpio_chip *chip;
+   void __iomem *iobase;
+   int num_banks;
+};
+
 
 #define to_vt8500(__chip) container_of(__chip, struct vt8500_gpio_chip, chip)
 
@@ -224,19 +230,32 @@ static int vt8500_of_xlate(struct gpio_chip *gc,
 static int vt8500_add_chips(struct platform_device *pdev, void __iomem *base,
const struct vt8500_gpio_data *data)
 {
+   struct vt8500_data *priv;
struct vt8500_gpio_chip *vtchip;
struct gpio_chip *chip;
int i;
int pin_cnt = 0;
 
-   vtchip = devm_kzalloc(pdev-dev,
+   priv = devm_kzalloc(pdev-dev, sizeof(struct vt8500_data), GFP_KERNEL);
+   if (!priv) {
+   dev_err(pdev-dev, failed to allocate memory\n);
+   return -ENOMEM;
+   }
+
+   priv-chip = devm_kzalloc(pdev-dev,
sizeof(struct vt8500_gpio_chip) * data-num_banks,
GFP_KERNEL);
-   if (!vtchip) {
-   pr_err(%s: failed to allocate chip memory\n, __func__);
+   if (!priv-chip) {
+   dev_err(pdev-dev, failed to allocate chip memory\n);
return -ENOMEM;
}
 
+   priv-iobase = base;
+   priv-num_banks = data-num_banks;
+   platform_set_drvdata(pdev, priv);
+
+   vtchip = priv-chip;
+
for (i = 0; i  data-num_banks; i++) {
vtchip[i].base = base;
vtchip[i].regs = data-banks[i];
@@ -273,36 +292,54 @@ static struct of_device_id vt8500_gpio_dt_ids[] = {
 
 static int vt8500_gpio_probe(struct platform_device *pdev)
 {
+   int ret;
void __iomem *gpio_base;
-   struct device_node *np;
+   struct resource *res;
const struct of_device_id *of_id =
of_match_device(vt8500_gpio_dt_ids, pdev-dev);
 
if (!of_id) {
-   dev_err(pdev-dev, Failed to find gpio controller\n);
+   dev_err(pdev-dev, No matching driver data\n);
return -ENODEV;
}
 
-   np = pdev-dev.of_node;
-   if (!np) {
-   dev_err(pdev-dev, Missing GPIO description in devicetree\n);
-   return -EFAULT;
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res) {
+   dev_err(pdev-dev, Unable to get IO resource\n);
+   return -ENODEV;
}
 
-   gpio_base = of_iomap(np, 0);
+   gpio_base = devm_request_and_ioremap(pdev-dev, res);
if (!gpio_base) {
dev_err(pdev-dev, Unable to map GPIO registers\n);
-   of_node_put(np);
return -ENOMEM;
}
 
-   vt8500_add_chips(pdev, gpio_base, of_id-data);
+   ret = vt8500_add_chips(pdev, gpio_base, of_id-data);
+
+   return ret;
+}
+
+static int vt8500_gpio_remove(struct platform_device *pdev)
+{
+   int i;
+   int ret;
+   struct vt8500_data *priv = platform_get_drvdata(pdev);
+   struct vt8500_gpio_chip *vtchip = priv-chip;
+
+   for (i = 0; i  priv-num_banks; i++) {
+   ret = gpiochip_remove(vtchip[i].chip);
+   if (ret)
+   dev_warn(pdev-dev, gpiochip_remove returned %d\n,
+ret);
+   }
 
return 0;
 }
 
 static struct platform_driver vt8500_gpio_driver = {
.probe  = vt8500_gpio_probe,
+   .remove = vt8500_gpio_remove,
.driver = {
.name   = vt8500-gpio,
.owner  = THIS_MODULE,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org

Re: [Bulk] [PATCH] timer: vt8500: Move timer code to drivers/clocksource

2013-01-14 Thread Tony Prisk
On Mon, 2013-01-14 at 12:07 -0800, Olof Johansson wrote:
 On Mon, Jan 14, 2013 at 06:47:35PM +1300, Tony Prisk wrote:
  On Mon, 2013-01-14 at 18:13 +1300, Tony Prisk wrote:
   On Mon, 2013-01-14 at 18:09 +1300, Tony Prisk wrote:
This patch moves arch-vt8500/timer.c into drivers/clocksource and
updates the necessary Kconfig/Makefile options.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 arch/arm/mach-vt8500/Kconfig   |1 +
 arch/arm/mach-vt8500/Makefile  |2 +-
 arch/arm/mach-vt8500/common.h  |1 -
 arch/arm/mach-vt8500/timer.c   |  184 

 arch/arm/mach-vt8500/vt8500.c  |1 +
 drivers/clocksource/Kconfig|3 +
 drivers/clocksource/Makefile   |1 +
 drivers/clocksource/vt8500_timer.c |  184 

 include/linux/vt8500_timer.h   |   22 +
 9 files changed, 213 insertions(+), 186 deletions(-)
 delete mode 100644 arch/arm/mach-vt8500/timer.c
 create mode 100644 drivers/clocksource/vt8500_timer.c
 create mode 100644 include/linux/vt8500_timer.h
   
   Darn.. forgot the -m again. I'll await your feedback regarding the
   basing of the patch first (and any other feedback), then I'll redo it
   with the correct stats.
   
   Regards
   Tony P
  
  Oh grr.. forget this completely. It doesn't take into account the
  patches I already sent for WM8850.
  
  I guess it needs to be based on timer/cleanup + vt8500/wm8x50.
  
  Need a little advise on how to handle this one please :)
 
 The normal way to handle these kind of dependencies is to base them on merges
 of the needed branches. Based on the later email, you only seem to need
 timer/cleanup, but if you would have needed the other one, then you'd merge
 that on top of timer/cleanup, and then add your patches.
 
 Of course, ideally you would do the cleanup, then add the wm8x50 features,
 but in reality work doesn't always pan out that way, so you end up with
 cleanups that depend on including new features in the same (sweeping)
 cleanup since they have already been merged. That's when things sometimes
 get hairy, and we need to start a second cleanup branch that's after
 the feature branch in the sequence of topics. But it should be rare,
 and in your case it seems like it wasn't needed.
 
 
 -Olof
 

Just to clarify what I did (and to make sure it was as you understood
it):

#1) I wrote the patch on top of timer/cleanup. This is the branch the
patch was written for.

#2) I then pulled timer/cleanup and merged vt8500/wm8x50 on top, then
reapplied the patch from #1 - it applied cleanly.

What I have just realised is that you might?? get a conflict when you
merge vt8500/wm8x50 on top of wherever this patch ends up due to the few
lines at the top of arch-vt8500/Kconfig having changed (the addition of
SELECT VT8500_TIMER). This should be trivial to fix (I assume).

Regards
Tony P

--
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] timer: vt8500: Move timer code to drivers/clocksource

2013-01-14 Thread Tony Prisk
On Mon, 2013-01-14 at 09:34 -0700, Stephen Warren wrote:
 On 01/13/2013 10:09 PM, Tony Prisk wrote:
  This patch moves arch-vt8500/timer.c into drivers/clocksource and
  updates the necessary Kconfig/Makefile options.
 
  diff --git a/include/linux/vt8500_timer.h b/include/linux/vt8500_timer.h
 
  +#ifndef __VT8500_TIMER_H
  +#define __VT8500_TIMER_H
  +
  +#include asm/mach/time.h
  +
  +void vt8500_timer_init(void);
  +
  +#endif
 
 Is VT8500 DT-only? If so, it'd be nice not to add this header, but
 instead use CLOCKSOURCE_OF_DECLARE() inside the driver C file.

Agreed - I didn't like the header when I added it but I didn't know of
another way and based in on the sunxi code.

Unfortunately Olof already pulled it into arm-soc, so I will try get
another patch done to undo it :)

Regards
Tony P

--
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 2/4] serial: vt8500: ioremap'd resource is never freed

2013-01-14 Thread Tony Prisk
Memory mapped via ioremap call is never released. Rather than add an
iounmap call, change allocation function to devm_request_and_ioremap.

Also, change the error on failure for this call to -EBUSY rather than
-EADDRNOTAVAIL.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/tty/serial/vt8500_serial.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c 
b/drivers/tty/serial/vt8500_serial.c
index 4c4a58d..3e76dff 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -615,9 +615,9 @@ static int vt8500_serial_probe(struct platform_device *pdev)
snprintf(vt8500_port-name, sizeof(vt8500_port-name),
 VT8500 UART%d, pdev-id);
 
-   vt8500_port-uart.membase = ioremap(mmres-start, resource_size(mmres));
+   vt8500_port-uart.membase = devm_request_and_ioremap(pdev-dev, mmres);
if (!vt8500_port-uart.membase) {
-   ret = -ENOMEM;
+   ret = -EADDRNOTAVAIL;
goto err;
}
 
-- 
1.7.9.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 1/4] serial: vt8500: Fix range-checking on vt8500_uart_ports

2013-01-14 Thread Tony Prisk
Fix two instances where the index to vt8500_uart_ports is tested
against  VT8500_MAX_PORTS. Correct usage should be = VT8500_MAX_PORTS.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/tty/serial/vt8500_serial.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c 
b/drivers/tty/serial/vt8500_serial.c
index 8fd1814..4c4a58d 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -569,7 +569,7 @@ static int vt8500_serial_probe(struct platform_device *pdev)
 
if (np)
port = of_alias_get_id(np, serial);
-   if (port  VT8500_MAX_PORTS)
+   if (port = VT8500_MAX_PORTS)
port = -1;
else
port = -1;
@@ -580,7 +580,7 @@ static int vt8500_serial_probe(struct platform_device *pdev)
sizeof(vt8500_ports_in_use));
}
 
-   if (port  VT8500_MAX_PORTS)
+   if (port = VT8500_MAX_PORTS)
return -ENODEV;
 
/* reserve the port id */
-- 
1.7.9.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/


[GIT PULL v2] Fixes/cleanup for vt8500 serial driver

2013-01-14 Thread Tony Prisk
Hi Greg,

This is a series of fixes/cleanup for the vt8500 serial/uart driver.

I'm not sure how you want to handle these.

Arguably #1, #2 and #3 are bug fixes which could go into 3.8. None of
them cause immediate problems, but potentially could.

#4 is definately a cleanup for 3.9.

Let me know if you would rather I split them up and how.

Regards
Tony P

v2 Changes:
Restore the setting of vt8500_port-uart.uartclk which was dropped in v1.
Corrected the return-on-fail of devm_request_and_ioremap to -EADDRNOTAVAIL.


The following changes since commit 9931faca02c604c22335f5a935a501bb2ace6e20:

  Linux 3.8-rc3 (2013-01-09 18:59:55 -0800)

are available in the git repository at:

  git://server.prisktech.co.nz/git/linuxwmt.git tags/vt8500-serial-fixes

for you to fetch changes up to 08bab1720e19e4f980e9e93536add4a7e497b38e:

  serial: tty: Cleanup code using devm_ function (2013-01-15 17:36:50 +1300)


Series of fixes/cleanups for vt8500 serial/UART driver


Tony Prisk (4):
  serial: vt8500: Fix range-checking on vt8500_uart_ports
  serial: vt8500: ioremap'd resource is never freed
  serial: vt8500: UART uses gated clock rather than 24Mhz reference
  serial: tty: Cleanup code using devm_ function

 arch/arm/boot/dts/vt8500.dtsi  |   40 +---
 arch/arm/boot/dts/wm8505.dtsi  |   60 
 arch/arm/boot/dts/wm8650.dtsi  |   20 ++--
 drivers/tty/serial/vt8500_serial.c |   45 +--
 4 files changed, 130 insertions(+), 35 deletions(-)
--
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 4/4] serial: tty: Cleanup code using devm_ function

2013-01-14 Thread Tony Prisk
Convert the last memory allocation (vt8500_port) to use devm_kzalloc
and remove the fail path cleanup code from vt8500_serial_probe.

Reorder iomem mapping above clk_enable to simplify fail code. The
clock is only enabled if all other resources are available.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/tty/serial/vt8500_serial.c |   13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c 
b/drivers/tty/serial/vt8500_serial.c
index 7f9e578..1fc6f3d 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -589,7 +589,8 @@ static int vt8500_serial_probe(struct platform_device *pdev)
return -EBUSY;
}
 
-   vt8500_port = kzalloc(sizeof(struct vt8500_port), GFP_KERNEL);
+   vt8500_port = devm_kzalloc(pdev-dev, sizeof(struct vt8500_port),
+  GFP_KERNEL);
if (!vt8500_port)
return -ENOMEM;
 
@@ -600,14 +601,13 @@ static int vt8500_serial_probe(struct platform_device 
*pdev)
vt8500_port-clk = of_clk_get(pdev-dev.of_node, 0);
if (IS_ERR(vt8500_port-clk)) {
dev_err(pdev-dev, failed to get clock\n);
-   ret = -EINVAL;
-   goto err;
+   return  -EINVAL;
}
 
ret = clk_prepare_enable(vt8500_port-clk);
if (ret) {
dev_err(pdev-dev, failed to enable clock\n);
-   goto err;
+   return ret;
}
 
vt8500_port-uart.type = PORT_VT8500;
@@ -631,10 +631,6 @@ static int vt8500_serial_probe(struct platform_device 
*pdev)
platform_set_drvdata(pdev, vt8500_port);
 
return 0;
-
-err:
-   kfree(vt8500_port);
-   return ret;
 }
 
 static int vt8500_serial_remove(struct platform_device *pdev)
@@ -644,7 +640,6 @@ static int vt8500_serial_remove(struct platform_device 
*pdev)
platform_set_drvdata(pdev, NULL);
clk_disable_unprepare(vt8500_port-clk);
uart_remove_one_port(vt8500_uart_driver, vt8500_port-uart);
-   kfree(vt8500_port);
 
return 0;
 }
-- 
1.7.9.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] serial: vt8500: UART uses gated clock rather than 24Mhz reference

2013-01-14 Thread Tony Prisk
UART modules on Wondermedia SoCs are connected via a gated clock
source, rather than directly to the 24Mhz reference clock. While
uboot enables UART0 for debugging, other UART ports are unavailable
until the clock is enabled.

This patch checks that a valid clock is actually passed from devicetree,
enables the clock in probe. This change removes the fallback when a
clock was not specified as it doesn't apply any longer (and would only
work if the UART clock was already enabled).

DTSI files are updated for VT8500, WM8505 and WM8650.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 arch/arm/boot/dts/vt8500.dtsi  |   40 +---
 arch/arm/boot/dts/wm8505.dtsi  |   60 
 arch/arm/boot/dts/wm8650.dtsi  |   20 ++--
 drivers/tty/serial/vt8500_serial.c |   34 +++-
 4 files changed, 127 insertions(+), 27 deletions(-)

diff --git a/arch/arm/boot/dts/vt8500.dtsi b/arch/arm/boot/dts/vt8500.dtsi
index d8645e9..cf31ced 100644
--- a/arch/arm/boot/dts/vt8500.dtsi
+++ b/arch/arm/boot/dts/vt8500.dtsi
@@ -45,6 +45,38 @@
compatible = fixed-clock;
clock-frequency = 2400;
};
+
+   clkuart0: uart0 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock;
+   clocks = ref24;
+   enable-reg = 0x250;
+   enable-bit = 1;
+   };
+
+   clkuart1: uart1 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock;
+   clocks = ref24;
+   enable-reg = 0x250;
+   enable-bit = 2;
+   };
+
+   clkuart2: uart2 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock;
+   clocks = ref24;
+   enable-reg = 0x250;
+   enable-bit = 3;
+   };
+
+   clkuart3: uart3 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock;
+   clocks = ref24;
+   enable-reg = 0x250;
+   enable-bit = 4;
+   };
};
};
 
@@ -83,28 +115,28 @@
compatible = via,vt8500-uart;
reg = 0xd820 0x1040;
interrupts = 32;
-   clocks = ref24;
+   clocks = clkuart0;
};
 
uart@d82b {
compatible = via,vt8500-uart;
reg = 0xd82b 0x1040;
interrupts = 33;
-   clocks = ref24;
+   clocks = clkuart1;
};
 
uart@d821 {
compatible = via,vt8500-uart;
reg = 0xd821 0x1040;
interrupts = 47;
-   clocks = ref24;
+   clocks = clkuart2;
};
 
uart@d82c {
compatible = via,vt8500-uart;
reg = 0xd82c 0x1040;
interrupts = 50;
-   clocks = ref24;
+   clocks = clkuart3;
};
 
rtc@d810 {
diff --git a/arch/arm/boot/dts/wm8505.dtsi b/arch/arm/boot/dts/wm8505.dtsi
index 330f833..e74a1c0 100644
--- a/arch/arm/boot/dts/wm8505.dtsi
+++ b/arch/arm/boot/dts/wm8505.dtsi
@@ -59,6 +59,54 @@
compatible = fixed-clock;
clock-frequency = 2400;
};
+
+   clkuart0: uart0 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock;
+   clocks = ref24;
+   enable-reg = 0x250;
+   enable-bit = 1;
+   };
+
+   clkuart1: uart1 {
+   #clock-cells = 0;
+   compatible = via,vt8500-device-clock

Re: [PATCH 2/4] serial: vt8500: ioremap'd resource is never freed

2013-01-14 Thread Tony Prisk
On Tue, 2013-01-15 at 17:58 +1300, Tony Prisk wrote:
 Memory mapped via ioremap call is never released. Rather than add an
 iounmap call, change allocation function to devm_request_and_ioremap.
 
 Also, change the error on failure for this call to -EBUSY rather than
 -EADDRNOTAVAIL.

Grr.. I thought I fixed this typo before I sent the patch.
I'll send another version but I'll wait for feedback on the series
first.

Regards
Tony P

--
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] gpio: vt8500: memory cleanup missing

2013-01-14 Thread Tony Prisk
On Tue, 2013-01-15 at 07:37 +1300, Tony Prisk wrote:
 This driver is missing a .remove callback, and the fail path on
 probe is incomplete.
 
 If an error occurs in vt8500_add_chips, gpio_base is not unmapped.
 The driver is also ignoring the return value from this function so
 if a chip fails to register it completes as successful.
 
 Replaced pr_err with dev_err in vt8500_add_chips since the device is
 available.
 
 There is also no .remove callback defined. To allow removing the
 registered chips, I have moved *vtchip to be a static global.
 
 Signed-off-by: Tony Prisk li...@prisktech.co.nz
 ---
 Hi Grant,
 
 Let me know what you think of these changes.
 
 v2:
 Removed unnecessary whitespace change.
 Removed test against pdev-dev.of_node (np). Replaced code with a
   devm_request_and_ioremap so np is now unneccessary. This also removes the 
 need
   for cleanup in the fail path.
 Move struct vt8500_gpio_chip within vt8500_data and store the iobase and
   num_banks in vt8500_data.
 

Grant,

If there are no further changes for this patch, would you mind
correcting the commit message when you merge it?

-There is also no .remove callback defined. To allow removing the
-Registered chips, I have moved *vtchip to be a static global.
+ There is also no .remove callback defined.

Otherwise, I will fix it along with whatever other comments come in.

Regards
Tony P

--
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] timer: vt8500: Convert vt8500 to use CLKSRC_OF

2013-01-14 Thread Tony Prisk
This patch converts arch-vt8500 to make use of CLKSRC_OF. Doing so
removes the need for include/linux/vt8500_timer.h as vt8500_timer_init
no longer needs to be visible outside vt8500_timer.c

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
Hi Olof,

Here is the fix as requested by Stephen Warren, based on vt8500/timer.

 arch/arm/mach-vt8500/Kconfig   |1 +
 arch/arm/mach-vt8500/vt8500.c  |4 ++--
 drivers/clocksource/vt8500_timer.c |3 ++-
 include/linux/vt8500_timer.h   |   22 --
 4 files changed, 5 insertions(+), 25 deletions(-)
 delete mode 100644 include/linux/vt8500_timer.h

diff --git a/arch/arm/mach-vt8500/Kconfig b/arch/arm/mach-vt8500/Kconfig
index 570a801..d1cbda6 100644
--- a/arch/arm/mach-vt8500/Kconfig
+++ b/arch/arm/mach-vt8500/Kconfig
@@ -4,6 +4,7 @@ config ARCH_VT8500
select ARCH_HAS_CPUFREQ
select ARCH_REQUIRE_GPIOLIB
select CLKDEV_LOOKUP
+   select CLKSRC_OF
select CPU_ARM926T
select GENERIC_CLOCKEVENTS
select GENERIC_GPIO
diff --git a/arch/arm/mach-vt8500/vt8500.c b/arch/arm/mach-vt8500/vt8500.c
index b9fd9d3..fe99b70 100644
--- a/arch/arm/mach-vt8500/vt8500.c
+++ b/arch/arm/mach-vt8500/vt8500.c
@@ -18,9 +18,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include linux/clocksource.h
 #include linux/io.h
 #include linux/pm.h
-#include linux/vt8500_timer.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -186,8 +186,8 @@ DT_MACHINE_START(WMT_DT, VIA/Wondermedia SoC (Device Tree 
Support))
.dt_compat  = vt8500_dt_compat,
.map_io = vt8500_map_io,
.init_irq   = vt8500_init_irq,
-   .init_time  = vt8500_timer_init,
.init_machine   = vt8500_init,
+   .init_time  = clocksource_of_init,
.restart= vt8500_restart,
.handle_irq = vt8500_handle_irq,
 MACHINE_END
diff --git a/drivers/clocksource/vt8500_timer.c 
b/drivers/clocksource/vt8500_timer.c
index 3dd21a4..b75b8e3 100644
--- a/drivers/clocksource/vt8500_timer.c
+++ b/drivers/clocksource/vt8500_timer.c
@@ -134,7 +134,7 @@ static struct of_device_id vt8500_timer_ids[] = {
{ }
 };
 
-void __init vt8500_timer_init(void)
+static void __init vt8500_timer_init(void)
 {
struct device_node *np;
int timer_irq;
@@ -182,3 +182,4 @@ void __init vt8500_timer_init(void)
clockevents_register_device(clockevent);
 }
 
+CLOCKSOURCE_OF_DECLARE(vt8500, via,vt8500-timer, vt8500_timer_init)
diff --git a/include/linux/vt8500_timer.h b/include/linux/vt8500_timer.h
deleted file mode 100644
index 33b0ee8..000
--- a/include/linux/vt8500_timer.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2012 Tony Prisk li...@prisktech.co.nz
- *
- * 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
- * (at your option) any later version.
- *
- * 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.
- */
-
-#ifndef __VT8500_TIMER_H
-#define __VT8500_TIMER_H
-
-#include asm/mach/time.h
-
-void vt8500_timer_init(void);
-
-#endif
-- 
1.7.9.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/


rtc: vt8500: Fix year field in vt8500_rtc_set_time

2013-01-14 Thread Tony Prisk
Alessandro,

This patch was sent out at the same time as two other RTC fixes for
vt8500 but this one seems to have stopped somewhere along the way while
the other two have been accepted.

The patch is showing in the RTC patch system along with the other two:
http://patchwork.ozlabs.org/patch/208756/


Greg,
How did the first two patches find their way to you - did you pick them
up off one of the lists?

patch 1 - rtc: vt8500: Fix handling of data passed in struct rtc_time
patch 2 - [fix-3.8] rtc: vt8500: Correct handling of CR_24H bitfield

Hope this is enough information to help you figure out what I'm talking
about :)


Regards
Tony P

--
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] mtd: vt8500: Add support for Wondermedia Serial Flash Controller

2013-01-15 Thread Tony Prisk
On Tue, 2013-01-15 at 16:55 +0200, Artem Bityutskiy wrote:
 On Mon, 2012-12-31 at 10:00 +1300, Tony Prisk wrote:
  This patch adds support for the Wondermedia serial flash controller
  found on WM8505, WM8650 and WM8850 SoCs.
  
  Signed-off-by: Tony Prisk li...@prisktech.co.nz
  ---
  v2: Whitespace tidyup
 
 Hi, would you please take a look at these warings, identified by aiaiai:
 
 Successfully built configuration x86_64_defconfig,x86_64,, results:
 
 --- before_patching.log
 +++ after_patching.log
 @@ @@
 +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_read’:
 +drivers/mtd/devices/wmt_sflash.c:425:9: warning: format ‘%d’ expects 
 argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat]
 +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_sector_write’:
 +drivers/mtd/devices/wmt_sflash.c:442:16: warning: cast from pointer to 
 integer of different size [-Wpointer-to-int-cast]
 +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address space 
 of expression [sparse]
 +drivers/mtd/devices/wmt_sflash.c:458:16: warning: cast to pointer from 
 integer of different size [-Wint-to-pointer-cast]
 +drivers/mtd/devices/wmt_sflash.c:458:31: warning: incorrect type in argument 
 1 (different address spaces) [sparse]
 +drivers/mtd/devices/wmt_sflash.c:458:31:expected void volatile [noderef] 
 asn:2*dst [sparse]
 +drivers/mtd/devices/wmt_sflash.c:458:31:got unsigned char [usertype] 
 *noident [sparse]
 +drivers/mtd/devices/wmt_sflash.c:465:17: warning: cast to pointer from 
 integer of different size [-Wint-to-pointer-cast]
 +drivers/mtd/devices/wmt_sflash.c:465:39: warning: incorrect type in argument 
 1 (different address spaces) [sparse]
 +drivers/mtd/devices/wmt_sflash.c:465:39:expected void volatile [noderef] 
 asn:2*dst [sparse]
 +drivers/mtd/devices/wmt_sflash.c:465:39:got unsigned char [usertype] 
 *noident [sparse]
 

Apologies - This driver shouldn't be selectable for x86_64.
It is an ARM driver for an embedded device. Will fix.

Regards
Tony P

--
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] mtd: vt8500: Add support for Wondermedia Serial Flash Controller

2013-01-15 Thread Tony Prisk
This patch adds support for the Wondermedia serial flash controller
found on WM8505, WM8650 and WM8850 SoCs.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
v2:
Change Kconfig depends to ARCH_VT8500 as this driver can't be used on other
platforms.

 drivers/mtd/devices/Kconfig  |7 +
 drivers/mtd/devices/Makefile |3 +-
 drivers/mtd/devices/wmt_sflash.c |  614 ++
 3 files changed, 623 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/devices/wmt_sflash.c

diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index 27f80cd..0233b37 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -128,6 +128,13 @@ config MTD_BCM47XXSFLASH
  registered by bcma as platform devices. This enables driver for
  serial flash memories (only read-only mode is implemented).
 
+config MTD_WMT_SFLASH
+   tristate WonderMedia Serial Flash Support
+   depends on ARCH_VT8500
+   help
+ Enable this option to provide support for the Wondermedia SoC serial
+ flash controller.
+
 config MTD_SLRAM
tristate Uncached system RAM
help
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile
index 395733a..10b8bec 100644
--- a/drivers/mtd/devices/Makefile
+++ b/drivers/mtd/devices/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_DATAFLASH)   += mtd_dataflash.o
 obj-$(CONFIG_MTD_M25P80)   += m25p80.o
 obj-$(CONFIG_MTD_SPEAR_SMI)+= spear_smi.o
 obj-$(CONFIG_MTD_SST25L)   += sst25l.o
+obj-$(CONFIG_MTD_WMT_SFLASH)   += wmt_sflash.o
 obj-$(CONFIG_MTD_BCM47XXSFLASH)+= bcm47xxsflash.o
 
-CFLAGS_docg3.o += -I$(src)
\ No newline at end of file
+CFLAGS_docg3.o += -I$(src)
diff --git a/drivers/mtd/devices/wmt_sflash.c b/drivers/mtd/devices/wmt_sflash.c
new file mode 100644
index 000..49359ea
--- /dev/null
+++ b/drivers/mtd/devices/wmt_sflash.c
@@ -0,0 +1,614 @@
+/*
+ * Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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/clk.h
+#include linux/errno.h
+#include linux/module.h
+#include linux/platform_device.h
+
+#include linux/of.h
+#include linux/of_device.h
+#include linux/of_address.h
+
+#include linux/mtd/mtd.h
+
+/* controller only supports erase size of 64KB */
+#define WMT_ERASESIZE  0x1
+
+/* Serial Flash controller register offsets */
+#define SF_CHIP_SEL_0_CFG  0x000
+#define SF_CHIP_SEL_1_CFG  0x008
+#define SF_SPI_INTF_CFG0x040
+#define SF_SPI_RD_WR_CTR   0x050
+#define SF_SPI_WR_EN_CTR   0x060
+#define SF_SPI_ER_CTR  0x070
+#define SF_SPI_ER_START_ADDR   0x074
+#define SF_SPI_ERROR_STATUS0x080
+#define SF_SPI_MEM_0_SR_ACC0x100
+#define SF_SPI_MEM_1_SR_ACC0x110
+#define SF_SPI_PDWN_CTR_0  0x180
+#define SF_SPI_PDWN_CTR_1  0x190
+#define SF_SPI_PROG_CMD_CTR0x200
+#define SF_SPI_USER_CMD_VAL0x210
+#define SF_SPI_PROG_CMD_WBF0x300   /* 64 bytes */
+#define SF_SPI_PROG_CMD_RBF0x380   /* 64 bytes */
+
+/* SF_SPI_WR_EN_CTR bit fields */
+#define SF_CS0_WR_EN   BIT(0)
+#define SF_CS1_WR_EN   BIT(1)
+
+/* SF_SPI_ER_CTR bit fields */
+#define SF_SEC_ER_EN   BIT(31)
+
+/* SF_SPI_ERROR_STATUS bit fields */
+#define SF_ERR_TIMEOUT BIT(31)
+#define SF_ERR_WR_PROT_ERR BIT(5)
+#define SF_ERR_MEM_REGION_ERR  BIT(4)
+#define SF_ERR_PWR_DWN_ACC_ERR BIT(3)
+#define SF_ERR_PCMD_OP_ERR BIT(2)
+#define SF_ERR_PCMD_ACC_ERRBIT(1)
+#define SF_ERR_MASLOCK_ERR BIT(0)
+
+/*
+ * Serial Flash device manufacturers
+ * Please keep sorted by manufacturers ID
+ */
+#define MFR_SPANSION   0x01
+#define MFR_EON0x1C
+#define MFR_ATMEL  0x1F
+#define MFR_NUMONYX0x20
+#define MFR_FUDAN  0xA1
+#define MFR_SST0xBF
+#define MFR_MXIC   0xC2
+#define MFR_WINBOND0xEF
+
+/*
+ * SF Device Models
+ * Please keep in the same order as the manufacturers table
+ */
+
+/* Spansion */
+#define SPAN_FL016A0x0214 /* 2 MB */
+#define SPAN_FL064A0x0216 /* 8 MB */
+
+/* Eon */
+#define EON_25P16  0x2015 /* 2 MB */
+#define EON_25P64  0x2017 /* 8 MB */
+#define

Re: [PATCH 1/4] arm: vt8500: Add support for Wondermedia WM8750/WM8850

2013-01-08 Thread Tony Prisk
On Fri, 2012-12-28 at 12:20 +1300, Tony Prisk wrote:
 This patch adds support for the WM8750 (ARMv6) and WM8850 (ARMv7).
 
 Common features across all SoCs are split into ARCH_VT8500 and
 unique features are specified by each SoC option.
 
 Signed-off-by: Tony Prisk li...@prisktech.co.nz


Hi Arnd, Olof,

Haven't heard anything re: this patch series. Problem?

Regards
Tony P

--
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] arm: vt8500: Add support for Wondermedia WM8750/WM8850

2013-01-09 Thread Tony Prisk
On Tue, 2013-01-08 at 22:30 -0800, Olof Johansson wrote:
 On Tue, Jan 8, 2013 at 10:13 PM, Tony Prisk li...@prisktech.co.nz wrote:
  On Fri, 2012-12-28 at 12:20 +1300, Tony Prisk wrote:
  This patch adds support for the WM8750 (ARMv6) and WM8850 (ARMv7).
 
  Common features across all SoCs are split into ARCH_VT8500 and
  unique features are specified by each SoC option.
 
  Signed-off-by: Tony Prisk li...@prisktech.co.nz
 
 
  Hi Arnd, Olof,
 
  Haven't heard anything re: this patch series. Problem?
 
 Nope, just wasn't sure if you would send a git pull request or if you
 wanted them applied.
 
 I'm out of time for tonight, but I'll look closer at them (and apply
 them if all OK) tomorrow.
 
 
 -Olof

I'm quite happy to send a pull request if that's what you prefer.

Generally people have just taken the patches straight from email, so
everytime I've done a pull-request I get a reply back saying the patches
have already been applied.

Is there some 'rule' around pull-requests vs emailed patches?
Should patches in pull-requests have Ack'd lines already?

Regards
Tony P

--
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] arm: vt8500: Add support for Wondermedia WM8750/WM8850

2013-01-09 Thread Tony Prisk
On Wed, 2013-01-09 at 21:27 +, Arnd Bergmann wrote:
 On Wednesday 09 January 2013, Tony Prisk wrote:
  I'm quite happy to send a pull request if that's what you prefer.
  
  Generally people have just taken the patches straight from email, so
  everytime I've done a pull-request I get a reply back saying the patches
  have already been applied.
  
  Is there some 'rule' around pull-requests vs emailed patches?
 
 Generally, pull requests tend to be less work for us, so I prefer
 them. In particular, when you add a tag description or a signed
 tag, that gives automatically puts  nice text into the merge
 changeset.
 
  Should patches in pull-requests have Ack'd lines already?
 
 Yes.
 
   Arnd

This is what I thought - and the reason I haven't sent a pull-request
for the patch's - I haven't had any Ack's :)

Regards
Tony P

--
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] dts: wandboard: Add support for SDIO bcm4329

2013-07-27 Thread Tony Prisk
The wandboard has a Broadcom 4329 WiFi connected via SDIO. This patch
sets the required pins to enable the wifi module.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 arch/arm/boot/dts/imx6qdl-wandboard.dtsi |   11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl-wandboard.dtsi 
b/arch/arm/boot/dts/imx6qdl-wandboard.dtsi
index 7a46f64..2fb0e9b 100644
--- a/arch/arm/boot/dts/imx6qdl-wandboard.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-wandboard.dtsi
@@ -73,9 +73,14 @@
hog {
pinctrl_hog: hoggrp {
fsl,pins = 
-   MX6QDL_PAD_GPIO_0__CCM_CLKO10x130b0
-   MX6QDL_PAD_GPIO_2__GPIO1_IO02   0x8000
-   MX6QDL_PAD_EIM_DA9__GPIO3_IO09  0x8000
+   MX6QDL_PAD_GPIO_0__CCM_CLKO1 0x130b0
+   MX6QDL_PAD_GPIO_2__GPIO1_IO020x8000
+   MX6QDL_PAD_EIM_DA9__GPIO3_IO09   0x8000
+   MX6QDL_PAD_EIM_EB1__GPIO2_IO29   0x8000 /* 
WL_REF_ON */
+   MX6QDL_PAD_EIM_A25__GPIO5_IO02   0x8000 /* 
WL_RST_N */
+   MX6QDL_PAD_ENET_RXD1__GPIO1_IO26 0x8000 /* 
WL_REG_ON */
+   MX6QDL_PAD_ENET_TXD1__GPIO1_IO29 0x8000 /* 
WL_HOST_WAKE */
+   MX6QDL_PAD_ENET_TXD0__GPIO1_IO30 0x8000 /* 
WL_WAKE */
;
};
};
-- 
1.7.9.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 07/26] clk: vt8500: parse pmc_base from clock driver

2013-09-19 Thread Tony Prisk

On 19/09/13 05:53, Sebastian Hesselbarth wrote:

Currently, clock providers for vt8500 depend on machine_init providing
pmc_base address before calling of_clk_init. With upcoming arch-wide
.time_init calling of_clk_init, we should make clock providers independent
of mach code. This adds a pmc_base parsing helper to current clock provider
that gets called if there is no pmc_base set, yet.

Signed-off-by: Sebastian Hesselbarth sebastian.hesselba...@gmail.com
---
Cc: Olof Johansson o...@lixom.net
Cc: Arnd Bergmann a...@arndb.de
Cc: Tony Prisk li...@prisktech.co.nz
Cc: Mike Turquette mturque...@linaro.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
  drivers/clk/clk-vt8500.c |   21 +
  1 file changed, 21 insertions(+)

diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
index 82306f5..a5ee01c 100644
--- a/drivers/clk/clk-vt8500.c
+++ b/drivers/clk/clk-vt8500.c
@@ -15,11 +15,14 @@
  
  #include linux/io.h

  #include linux/of.h
+#include linux/of_address.h
  #include linux/slab.h
  #include linux/bitops.h
  #include linux/clkdev.h
  #include linux/clk-provider.h
  
+#define LEGACY_PMC_BASE		0xD813

+
  /* All clocks share the same lock as none can be changed concurrently */
  static DEFINE_SPINLOCK(_lock);
  
@@ -626,6 +629,21 @@ const struct clk_ops vtwm_pll_ops = {

.recalc_rate = vtwm_pll_recalc_rate,
  };
  
+static __init void vtwm_set_pmc_base(void)

+{
+   struct device_node *np =
+   of_find_compatible_node(NULL, NULL, via,vt8500-pmc);
+
+   if (np)
+   pmc_base = of_iomap(np, 0);
+   else
+   pmc_base = ioremap(LEGACY_PMC_BASE, 0x1000);
+   of_node_put(np);
+
+   if (!pmc_base)
+   pr_err(%s:of_iomap(pmc) failed\n, __func__);
+}
+
  static __init void vtwm_pll_clk_init(struct device_node *node, int pll_type)
  {
u32 reg;
@@ -636,6 +654,9 @@ static __init void vtwm_pll_clk_init(struct device_node 
*node, int pll_type)
struct clk_init_data init;
int rc;
  
+	if (!pmc_base)

+   vtwm_set_pmc_base();
+
rc = of_property_read_u32(node, reg, reg);
if (WARN_ON(rc))
return;
What happens if the first clock registered is a 'device clock' rather 
than a 'pll'?


static __init void vtwm_device_clk_init(struct device_node *node)
{
u32 en_reg, div_reg;
struct clk *clk;
struct clk_device *dev_clk;
const char *clk_name = node-name;
const char *parent_name;
struct clk_init_data init;
int rc;
int clk_init_flags = 0;

dev_clk = kzalloc(sizeof(*dev_clk), GFP_KERNEL);
if (WARN_ON(!dev_clk))
return;

dev_clk-lock = _lock;

rc = of_property_read_u32(node, enable-reg, en_reg);
if (!rc) {
dev_clk-en_reg = pmc_base + en_reg;
...
}
CLK_OF_DECLARE(vt8500_device, via,vt8500-device-clock, 
vtwm_device_clk_init);


If a device clock is initialized first, pmc_base will be null and 
dev_clk-en_reg (+ other register offsets) will be incorrect.



Regards
Tony Prisk
--
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 07/26] clk: vt8500: parse pmc_base from clock driver

2013-09-19 Thread Tony Prisk

On 20/09/13 07:12, Sebastian Hesselbarth wrote:

On 09/19/2013 09:02 PM, Tony Prisk wrote:

On 19/09/13 05:53, Sebastian Hesselbarth wrote:

Currently, clock providers for vt8500 depend on machine_init providing
pmc_base address before calling of_clk_init. With upcoming arch-wide
.time_init calling of_clk_init, we should make clock providers
independent
of mach code. This adds a pmc_base parsing helper to current clock
provider
that gets called if there is no pmc_base set, yet.

Signed-off-by: Sebastian Hesselbarth sebastian.hesselba...@gmail.com
---
Cc: Olof Johansson o...@lixom.net
Cc: Arnd Bergmann a...@arndb.de
Cc: Tony Prisk li...@prisktech.co.nz
Cc: Mike Turquette mturque...@linaro.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
  drivers/clk/clk-vt8500.c |   21 +
  1 file changed, 21 insertions(+)

diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
index 82306f5..a5ee01c 100644
--- a/drivers/clk/clk-vt8500.c
+++ b/drivers/clk/clk-vt8500.c
@@ -15,11 +15,14 @@
  #include linux/io.h
  #include linux/of.h
+#include linux/of_address.h
  #include linux/slab.h
  #include linux/bitops.h
  #include linux/clkdev.h
  #include linux/clk-provider.h
+#define LEGACY_PMC_BASE0xD813
+
  /* All clocks share the same lock as none can be changed
concurrently */
  static DEFINE_SPINLOCK(_lock);
@@ -626,6 +629,21 @@ const struct clk_ops vtwm_pll_ops = {
  .recalc_rate = vtwm_pll_recalc_rate,
  };
+static __init void vtwm_set_pmc_base(void)
+{
+struct device_node *np =
+of_find_compatible_node(NULL, NULL, via,vt8500-pmc);
+
+if (np)
+pmc_base = of_iomap(np, 0);
+else
+pmc_base = ioremap(LEGACY_PMC_BASE, 0x1000);
+of_node_put(np);
+
+if (!pmc_base)
+pr_err(%s:of_iomap(pmc) failed\n, __func__);
+}
+
  static __init void vtwm_pll_clk_init(struct device_node *node, int
pll_type)
  {
  u32 reg;
@@ -636,6 +654,9 @@ static __init void vtwm_pll_clk_init(struct
device_node *node, int pll_type)
  struct clk_init_data init;
  int rc;
+if (!pmc_base)
+vtwm_set_pmc_base();
+
  rc = of_property_read_u32(node, reg, reg);
  if (WARN_ON(rc))
  return;

What happens if the first clock registered is a 'device clock' rather
than a 'pll'?

static __init void vtwm_device_clk_init(struct device_node *node)
{
 u32 en_reg, div_reg;
 struct clk *clk;
 struct clk_device *dev_clk;
 const char *clk_name = node-name;
 const char *parent_name;
 struct clk_init_data init;
 int rc;
 int clk_init_flags = 0;

 dev_clk = kzalloc(sizeof(*dev_clk), GFP_KERNEL);
 if (WARN_ON(!dev_clk))
 return;

 dev_clk-lock = _lock;

 rc = of_property_read_u32(node, enable-reg, en_reg);
 if (!rc) {
 dev_clk-en_reg = pmc_base + en_reg;
...
}
CLK_OF_DECLARE(vt8500_device, via,vt8500-device-clock,
vtwm_device_clk_init);

If a device clock is initialized first, pmc_base will be null and
dev_clk-en_reg (+ other register offsets) will be incorrect.


Tony,

looks like I just missed to add the same check for !pmc_base to
vtwm_device_clk_init. If you are ok with the general approach,
I send v2 for this patch shortly.

Optionally, you can also choose to take care of clk-vt8500 yourself,
as mach-vt8500 has its own .init_time callback and will be unaffected
by the arch-wide default callback. If so, I will drop vt8500 to not
stall this series too much now.

Sebastian
I have no issue with the concept - just pointing out the missing bit. If 
you can fix that small issue for v2 then you can also add my:


Acked-by: Tony Prisk li...@prisktech.co.nz

Regards
Tony P
--
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 4/7] ECHI Platform: Merge ppc-of EHCI driver into the ehci-platform driver

2014-02-21 Thread Tony Prisk


On 22/02/14 00:48, Mark Rutland wrote:

[Adding Tony Prisk to Cc]

On Fri, Feb 21, 2014 at 06:31:30AM +, Alistair Popple wrote:

Currently the ppc-of driver uses the compatibility string
usb-ehci. This means platforms that use device-tree and implement an
EHCI compatible interface have to either use the ppc-of driver or add
a compatible line to the ehci-platform driver. It would be more
appropriate for the platform driver to be compatible with usb-ehci
as non-powerpc platforms are also beginning to utilise device-tree.

This patch merges the device tree property parsing from ehci-ppc-of
into the platform driver and adds a usb-ehci compatibility
string. The existing ehci-ppc-of driver is removed and the 440EPX
specific quirks are added to the ehci-platform driver.

Signed-off-by: Alistair Popple alist...@popple.id.au
---
  drivers/usb/host/Kconfig |7 +-
  drivers/usb/host/ehci-hcd.c  |5 -
  drivers/usb/host/ehci-platform.c |   87 +-
  drivers/usb/host/ehci-ppc-of.c   |  238 --
  4 files changed, 89 insertions(+), 248 deletions(-)
  delete mode 100644 drivers/usb/host/ehci-ppc-of.c

Please use of_property_read_bool for these.

This driver already handles via,vt8500-ehci and wm,prizm-ehci which
aren't documented to handle these properties, but now gain support for
them. It might be worth unifying the binding documents if there's
nothing special about those two host controllers.

We seem to have two binding documents for via,vt8500-ehci, so some
cleanup is definitely in order.

Tony, you seem to have written both documents judging by 95e9fd10f06c
and 8ad551d150e3. Do you have any issue with merging both of these into
a common usb-ehci document?

..

Cheers,
Mark.


I'm not sure how we ended up with two bindings for the driver anyway. I 
think this was an error on my part somewhere.


None of the in-tree dts files use wm,prizm-ehci.

I have no issue with merging all the documentation into a single 
usb-ehci binding.


Regards
Tony Prisk
--
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] i2c: vt8500: Add support for I2C bus on Wondermedia SoCs

2013-06-12 Thread Tony Prisk
This patch adds support for the I2C bus controllers found on Wondermedia
8xxx-series SoCs. Only master-mode is supported.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 .../devicetree/bindings/i2c/i2c-vt8500.txt |   24 +
 MAINTAINERS|1 +
 drivers/i2c/busses/Kconfig |   10 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-wmt.c   |  483 
 5 files changed, 519 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-vt8500.txt
 create mode 100644 drivers/i2c/busses/i2c-wmt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt 
b/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt
new file mode 100644
index 000..94a425e
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt
@@ -0,0 +1,24 @@
+* Wondermedia I2C Controller
+
+Required properties :
+
+ - compatible : should be wm,wm8505-i2c
+ - reg : Offset and length of the register set for the device
+ - interrupts : IRQ where IRQ is the interrupt number
+ - clocks : phandle to the I2C clock source
+
+Optional properties :
+
+ - clock-frequency : desired I2C bus clock frequency in Hz.
+   Valid values are 10 and 40.
+   Default to 10 if not specified, or invalid value.
+
+Example :
+
+   i2c_0: i2c@d828 {
+   compatible = wm,wm8505-i2c;
+   reg = 0xd828 0x1000;
+   interrupts = 19;
+   clocks = clki2c0;
+   clock-frequency = 40;
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index 3d7782b..44ea994 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1285,6 +1285,7 @@ S:Maintained
 F: arch/arm/mach-vt8500/
 F: drivers/clocksource/vt8500_timer.c
 F: drivers/gpio/gpio-vt8500.c
+F: drivers/i2c/busses/i2c-wmt.c
 F: drivers/mmc/host/wmt-sdmmc.c
 F: drivers/pwm/pwm-vt8500.c
 F: drivers/rtc/rtc-vt8500.c
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 631736e..89e7ec2 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -724,6 +724,16 @@ config I2C_VERSATILE
  This driver can also be built as a module.  If so, the module
  will be called i2c-versatile.
 
+config I2C_WMT
+   tristate Wondermedia WM8xxx SoC I2C bus support
+   depends on ARCH_VT8500
+   help
+ Say yes if you want to support the I2C bus on Wondermedia 8xxx-series
+ SoCs.
+
+ This driver can also be built as a module. If so, the module will be
+ called i2c-wmt.
+
 config I2C_OCTEON
tristate Cavium OCTEON I2C bus support
depends on CPU_CAVIUM_OCTEON
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 8f4fc23..3ba94a9 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -71,6 +71,7 @@ obj-$(CONFIG_I2C_SIRF)+= i2c-sirf.o
 obj-$(CONFIG_I2C_STU300)   += i2c-stu300.o
 obj-$(CONFIG_I2C_TEGRA)+= i2c-tegra.o
 obj-$(CONFIG_I2C_VERSATILE)+= i2c-versatile.o
+obj-$(CONFIG_I2C_WMT)  += i2c-wmt.o
 obj-$(CONFIG_I2C_OCTEON)   += i2c-octeon.o
 obj-$(CONFIG_I2C_XILINX)   += i2c-xiic.o
 obj-$(CONFIG_I2C_XLR)  += i2c-xlr.o
diff --git a/drivers/i2c/busses/i2c-wmt.c b/drivers/i2c/busses/i2c-wmt.c
new file mode 100644
index 000..2bbac9b
--- /dev/null
+++ b/drivers/i2c/busses/i2c-wmt.c
@@ -0,0 +1,483 @@
+/*
+ *  Wondermedia I2C Master Mode Driver
+ *
+ *  Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
+ *
+ *  Derived from GPLv2+ licensed source:
+ *  - Copyright (C) 2008 WonderMedia Technologies, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2, or
+ *  (at your option) any later version. as published by the Free Software
+ *  Foundation
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/i2c.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_i2c.h
+#include linux/of_irq.h
+#include linux/platform_device.h
+
+#define REG_CR 0x00
+#define REG_TCR0x02
+#define REG_CSR0x04
+#define REG_ISR0x06
+#define REG_IMR0x08
+#define REG_CDR0x0A
+#define REG_TR 0x0C
+#define REG_MCR0x0E
+#define REG_SLAVE_CR   0x10
+#define REG_SLAVE_SR   0x12
+#define REG_SLAVE_ISR  0x14
+#define REG_SLAVE_IMR  0x16
+#define REG_SLAVE_DR   0x18
+#define REG_SLAVE_TR   0x1A
+
+/* REG_CR Bit fields */
+#define CR_TX_NEXT_ACK 0x
+#define CR_ENABLE  0x0001
+#define CR_TX_NEXT_NO_ACK  0x0002
+#define CR_TX_END  0x0004
+#define CR_CPU_RDY 0x0008
+#define SLAV_MODE_SEL  0x8000

[PATCH v3] i2c: vt8500: Add support for I2C bus on Wondermedia SoCs

2013-06-14 Thread Tony Prisk
This patch adds support for the I2C bus controllers found on Wondermedia
8xxx-series SoCs. Only master-mode is supported.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
v3 changes:
Included the v2 changes for clarity.
Tidy up the I2C_NO_START code properly.
Remove the alias handling and allow the core to do it.
Change MODULE_LICENSE to GPL as per module.h comments.

v2 changes:
Rewrite wmt_i2c_wait_bus_not_busy() as per Wolfram/Russell.
Fix init_completion and INIT_COMPLETION usages.
Remove magic value in wmt_i2c_reset_hardware().
Remove test for (!np) in wmt_i2c_probe() as we only support devicetree anyway.
Remove reference to -class = I2C_CLASS_HWMON.

 .../devicetree/bindings/i2c/i2c-vt8500.txt |   24 +
 MAINTAINERS|1 +
 drivers/i2c/busses/Kconfig |   10 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-wmt.c   |  479 
 5 files changed, 515 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-vt8500.txt
 create mode 100644 drivers/i2c/busses/i2c-wmt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt 
b/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt
new file mode 100644
index 000..94a425e
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt
@@ -0,0 +1,24 @@
+* Wondermedia I2C Controller
+
+Required properties :
+
+ - compatible : should be wm,wm8505-i2c
+ - reg : Offset and length of the register set for the device
+ - interrupts : IRQ where IRQ is the interrupt number
+ - clocks : phandle to the I2C clock source
+
+Optional properties :
+
+ - clock-frequency : desired I2C bus clock frequency in Hz.
+   Valid values are 10 and 40.
+   Default to 10 if not specified, or invalid value.
+
+Example :
+
+   i2c_0: i2c@d828 {
+   compatible = wm,wm8505-i2c;
+   reg = 0xd828 0x1000;
+   interrupts = 19;
+   clocks = clki2c0;
+   clock-frequency = 40;
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index 3d7782b..44ea994 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1285,6 +1285,7 @@ S:Maintained
 F: arch/arm/mach-vt8500/
 F: drivers/clocksource/vt8500_timer.c
 F: drivers/gpio/gpio-vt8500.c
+F: drivers/i2c/busses/i2c-wmt.c
 F: drivers/mmc/host/wmt-sdmmc.c
 F: drivers/pwm/pwm-vt8500.c
 F: drivers/rtc/rtc-vt8500.c
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 631736e..89e7ec2 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -724,6 +724,16 @@ config I2C_VERSATILE
  This driver can also be built as a module.  If so, the module
  will be called i2c-versatile.
 
+config I2C_WMT
+   tristate Wondermedia WM8xxx SoC I2C bus support
+   depends on ARCH_VT8500
+   help
+ Say yes if you want to support the I2C bus on Wondermedia 8xxx-series
+ SoCs.
+
+ This driver can also be built as a module. If so, the module will be
+ called i2c-wmt.
+
 config I2C_OCTEON
tristate Cavium OCTEON I2C bus support
depends on CPU_CAVIUM_OCTEON
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 8f4fc23..3ba94a9 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -71,6 +71,7 @@ obj-$(CONFIG_I2C_SIRF)+= i2c-sirf.o
 obj-$(CONFIG_I2C_STU300)   += i2c-stu300.o
 obj-$(CONFIG_I2C_TEGRA)+= i2c-tegra.o
 obj-$(CONFIG_I2C_VERSATILE)+= i2c-versatile.o
+obj-$(CONFIG_I2C_WMT)  += i2c-wmt.o
 obj-$(CONFIG_I2C_OCTEON)   += i2c-octeon.o
 obj-$(CONFIG_I2C_XILINX)   += i2c-xiic.o
 obj-$(CONFIG_I2C_XLR)  += i2c-xlr.o
diff --git a/drivers/i2c/busses/i2c-wmt.c b/drivers/i2c/busses/i2c-wmt.c
new file mode 100644
index 000..19f6f35
--- /dev/null
+++ b/drivers/i2c/busses/i2c-wmt.c
@@ -0,0 +1,479 @@
+/*
+ *  Wondermedia I2C Master Mode Driver
+ *
+ *  Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz
+ *
+ *  Derived from GPLv2+ licensed source:
+ *  - Copyright (C) 2008 WonderMedia Technologies, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2, or
+ *  (at your option) any later version. as published by the Free Software
+ *  Foundation
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/i2c.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_i2c.h
+#include linux/of_irq.h
+#include linux/platform_device.h
+
+#define REG_CR 0x00
+#define REG_TCR0x02
+#define REG_CSR0x04
+#define REG_ISR0x06
+#define REG_IMR0x08
+#define REG_CDR0x0A
+#define

Re: [PATCH v3] i2c: vt8500: Add support for I2C bus on Wondermedia SoCs

2013-06-15 Thread Tony Prisk

On 15/06/13 23:18, Wolfram Sang wrote:

On Sat, Jun 15, 2013 at 09:52:16AM +1200, Tony Prisk wrote:

This patch adds support for the I2C bus controllers found on Wondermedia
8xxx-series SoCs. Only master-mode is supported.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---

...


+/* REG_TR */
+#define SCL_TIMEOUT(x) (((x)  0xFF)  16)

I assume this should be  8 since all regs are 16 bit wide.

Fixed it locally and ready to apply. Please confirm or send a proper
fix. Rest looks fine.

Thanks for the submission!


It should be  8. Please apply your locally corrected version.

Regards
Tony Prisk
--
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] pinctrl: establish pull-up/pull-down terminology

2013-06-16 Thread Tony Prisk

On 16/06/13 22:45, Linus Walleij wrote:

From: Linus Walleij linus.wall...@linaro.org

It is counter-intuitive to have 0 mean disable in a boolean
manner for electronic properties of pins such as pull-up and
pull-down. Therefore, define that a pull-up/pull-down argument
of 0 to such a generic option means that the pin is
short-circuited to VDD or GROUND. Pull disablement shall be
done using PIN_CONFIG_BIAS_DISABLE.

Cc: Heiko St�bner he...@sntech.de
Cc: James Hogan james.ho...@imgtec.com
Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Linus Walleij linus.wall...@linaro.org
---
  include/linux/pinctrl/pinconf-generic.h | 13 +++--
  1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/linux/pinctrl/pinconf-generic.h 
b/include/linux/pinctrl/pinconf-generic.h
index d414a77..67780f5 100644
--- a/include/linux/pinctrl/pinconf-generic.h
+++ b/include/linux/pinctrl/pinconf-generic.h
@@ -36,14 +36,15 @@
   *tristate. The argument is ignored.
   * @PIN_CONFIG_BIAS_PULL_UP: the pin will be pulled up (usually with high
   *impedance to VDD). If the argument is != 0 pull-up is enabled,
- * if it is 0, pull-up is disabled.
+ * if it is 0, pull-up it total, i.e. the pin is connected to VDD.

s/it/is

   * @PIN_CONFIG_BIAS_PULL_DOWN: the pin will be pulled down (usually with high
   *impedance to GROUND). If the argument is != 0 pull-down is enabled,
- * if it is 0, pull-down is disabled.
+ * if it is 0, pull-down is total, i.e. the pin is connected to GROUND.
   * @PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: the pin will be pulled up or down based
   *on embedded knowledge of the controller, like current mux function.
- * If the argument is != 0 pull up/down is enabled, if it is 0,
- * the pull is disabled.
+ * If the argument is != 0 pull up/down is enabled, if it is 0, the
+ * configuration is ignored. The proper way to disable it is to use
+ * @PIN_CONFIG_BIAS_DISABLE.
   * @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and
   *low, this is the most typical case and is typically achieved with two
   *active transistors on the output. Setting this config will enable
@@ -72,8 +73,8 @@
   *supplies, the argument to this parameter (on a custom format) tells
   *the driver which alternative power source to use.
   * @PIN_CONFIG_SLEW_RATE: if the pin can select slew rate, the argument to
- * this parameter (on a custom format) tells the driver which alternative
- * slew rate to use.
+ * this parameter (on a custom format) tells the driver which alternative
+ * slew rate to use.
   * @PIN_CONFIG_LOW_POWER_MODE: this will configure the pin for low power
   *operation, if several modes of operation are supported these can be
   *passed in the argument on a custom form, else just use argument 1


___
linux-arm-kernel mailing list
linux-arm-ker...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


--
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/


[PATCHv2 0/3] Add support for velocity network driver on platform devices

2013-04-29 Thread Tony Prisk
v2 changes:
Drop patch #1 as requested by David Miller.
Correct the PHYID_ICPLUS_IP101A MII bits - should be ON, rather than OFF.
Read the platform rev_id from the correct register [regs-rev_id]. It's possible
this would work for the PCI version as well and would remove the need for the
'if (pci)' test to set vptr-rev_id.

v1:
The first three patches are general tidyup.

[DROPPED] Patch ## just alphabetizes the #includes to make it easier to read.

Patch #1 replaces vptr-dev with vptr-netdev, in preparation of adding a
struct device *dev in Patch #3

Patch #2 replaces the pci dma functions with the generic versions.

I have build tested these patches but don't have a PCI velocity to run-test it.
I can't see that they should introduce any problems as it is all renames and
function swapping.

Patch #3 adds support for the velocity driver on devicetree platform devices.
Binding document included. This patch is compile-tested for PCI, and boot
tested on a VIA APC8750.

I think it would be pertinent to get some tested-by's for PCI users.

Regards
Tony Prisk

Tony Prisk (3):
  net: velocity: Rename vptr-dev to vptr-netdev
  net: velocity: Convert to generic dma functions
  net: velocity: Add platform device support to VIA velocity driver

 .../devicetree/bindings/net/via-velocity.txt   |   20 +
 drivers/net/ethernet/via/Kconfig   |3 +-
 drivers/net/ethernet/via/via-velocity.c|  564 ++--
 drivers/net/ethernet/via/via-velocity.h|   35 +-
 4 files changed, 456 insertions(+), 166 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt

-- 
1.7.9.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/


[PATCHv2 2/3] net: velocity: Convert to generic dma functions

2013-04-29 Thread Tony Prisk
Remove the pci_* dma functions and replace with the more generic
versions.

In preparation of adding platform support, a new struct device *dev
is added to struct velocity_info which can be used by both the pci
and platform code.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/net/ethernet/via/via-velocity.c |   51 +++
 drivers/net/ethernet/via/via-velocity.h |1 +
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index 9a408b1..e2c4887 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -46,6 +46,7 @@
 #include linux/types.h
 #include linux/bitops.h
 #include linux/init.h
+#include linux/dma-mapping.h
 #include linux/mm.h
 #include linux/errno.h
 #include linux/ioport.h
@@ -1457,7 +1458,6 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
struct velocity_opt *opt = vptr-options;
const unsigned int rx_ring_size = opt-numrx * sizeof(struct rx_desc);
const unsigned int tx_ring_size = opt-numtx * sizeof(struct tx_desc);
-   struct pci_dev *pdev = vptr-pdev;
dma_addr_t pool_dma;
void *pool;
unsigned int i;
@@ -1465,13 +1465,13 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
/*
 * Allocate all RD/TD rings a single pool.
 *
-* pci_alloc_consistent() fulfills the requirement for 64 bytes
+* dma_alloc_coherent() fulfills the requirement for 64 bytes
 * alignment
 */
-   pool = pci_alloc_consistent(pdev, tx_ring_size * vptr-tx.numq +
-   rx_ring_size, pool_dma);
+   pool = dma_alloc_coherent(vptr-dev, tx_ring_size * vptr-tx.numq +
+   rx_ring_size, pool_dma, GFP_ATOMIC);
if (!pool) {
-   dev_err(pdev-dev, %s : DMA memory allocation failed.\n,
+   dev_err(vptr-dev, %s : DMA memory allocation failed.\n,
vptr-netdev-name);
return -ENOMEM;
}
@@ -1522,8 +1522,8 @@ static int velocity_alloc_rx_buf(struct velocity_info 
*vptr, int idx)
 */
skb_reserve(rd_info-skb,
64 - ((unsigned long) rd_info-skb-data  63));
-   rd_info-skb_dma = pci_map_single(vptr-pdev, rd_info-skb-data,
-   vptr-rx.buf_sz, PCI_DMA_FROMDEVICE);
+   rd_info-skb_dma = dma_map_single(vptr-dev, rd_info-skb-data,
+   vptr-rx.buf_sz, DMA_FROM_DEVICE);
 
/*
 *  Fill in the descriptor to match
@@ -1586,8 +1586,8 @@ static void velocity_free_rd_ring(struct velocity_info 
*vptr)
 
if (!rd_info-skb)
continue;
-   pci_unmap_single(vptr-pdev, rd_info-skb_dma, vptr-rx.buf_sz,
-PCI_DMA_FROMDEVICE);
+   dma_unmap_single(vptr-dev, rd_info-skb_dma, vptr-rx.buf_sz,
+DMA_FROM_DEVICE);
rd_info-skb_dma = 0;
 
dev_kfree_skb(rd_info-skb);
@@ -1668,7 +1668,7 @@ static void velocity_free_dma_rings(struct velocity_info 
*vptr)
const int size = vptr-options.numrx * sizeof(struct rx_desc) +
vptr-options.numtx * sizeof(struct tx_desc) * vptr-tx.numq;
 
-   pci_free_consistent(vptr-pdev, size, vptr-rx.ring, vptr-rx.pool_dma);
+   dma_free_coherent(vptr-dev, size, vptr-rx.ring, vptr-rx.pool_dma);
 }
 
 static int velocity_init_rings(struct velocity_info *vptr, int mtu)
@@ -1725,8 +1725,8 @@ static void velocity_free_tx_buf(struct velocity_info 
*vptr,
pktlen = max_t(size_t, pktlen,
td-td_buf[i].size  ~TD_QUEUE);
 
-   pci_unmap_single(vptr-pdev, tdinfo-skb_dma[i],
-   le16_to_cpu(pktlen), PCI_DMA_TODEVICE);
+   dma_unmap_single(vptr-dev, tdinfo-skb_dma[i],
+   le16_to_cpu(pktlen), DMA_TO_DEVICE);
}
}
dev_kfree_skb_irq(skb);
@@ -1748,8 +1748,8 @@ static void velocity_free_td_ring_entry(struct 
velocity_info *vptr,
if (td_info-skb) {
for (i = 0; i  td_info-nskb_dma; i++) {
if (td_info-skb_dma[i]) {
-   pci_unmap_single(vptr-pdev, 
td_info-skb_dma[i],
-   td_info-skb-len, PCI_DMA_TODEVICE);
+   dma_unmap_single(vptr-dev, td_info-skb_dma[i],
+   td_info-skb-len, DMA_TO_DEVICE);
td_info-skb_dma[i] = 0;
}
}
@@ -2027,7 +2027,6 @@ static inline void velocity_iph_realign(struct 
velocity_info *vptr,
  */
 static int

[PATCHv2 1/3] net: velocity: Rename vptr-dev to vptr-netdev

2013-04-29 Thread Tony Prisk
Improve the clarity of the code in preparation for converting the
dma functions to generic versions, which require a struct device *.

This makes it possible to store a 'struct device *dev' in the
velocity_info structure.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/net/ethernet/via/via-velocity.c |   66 +++
 drivers/net/ethernet/via/via-velocity.h |4 +-
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index 1bc7f9fd..9a408b1 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -996,9 +996,9 @@ static void velocity_print_link_status(struct velocity_info 
*vptr)
 {
 
if (vptr-mii_status  VELOCITY_LINK_FAIL) {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: failed to detect 
cable link\n, vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: failed to detect 
cable link\n, vptr-netdev-name);
} else if (vptr-options.spd_dpx == SPD_DPX_AUTO) {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link 
auto-negotiation, vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link 
auto-negotiation, vptr-netdev-name);
 
if (vptr-mii_status  VELOCITY_SPEED_1000)
VELOCITY_PRT(MSG_LEVEL_INFO,  speed 1000M bps);
@@ -1012,7 +1012,7 @@ static void velocity_print_link_status(struct 
velocity_info *vptr)
else
VELOCITY_PRT(MSG_LEVEL_INFO,  half duplex\n);
} else {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link forced, 
vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link forced, 
vptr-netdev-name);
switch (vptr-options.spd_dpx) {
case SPD_DPX_1000_FULL:
VELOCITY_PRT(MSG_LEVEL_INFO,  speed 1000M bps full 
duplex\n);
@@ -1317,7 +1317,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
case VELOCITY_INIT_RESET:
case VELOCITY_INIT_WOL:
 
-   netif_stop_queue(vptr-dev);
+   netif_stop_queue(vptr-netdev);
 
/*
 *  Reset RX to prevent RX pointer not on the 4X location
@@ -1330,7 +1330,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
if (velocity_set_media_mode(vptr, mii_status) != 
VELOCITY_LINK_CHANGE) {
velocity_print_link_status(vptr);
if (!(vptr-mii_status  VELOCITY_LINK_FAIL))
-   netif_wake_queue(vptr-dev);
+   netif_wake_queue(vptr-netdev);
}
 
enable_flow_control_ability(vptr);
@@ -1352,7 +1352,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
 
mac_eeprom_reload(regs);
for (i = 0; i  6; i++)
-   writeb(vptr-dev-dev_addr[i], (regs-PAR[i]));
+   writeb(vptr-netdev-dev_addr[i], (regs-PAR[i]));
 
/*
 *  clear Pre_ACPI bit.
@@ -1375,7 +1375,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
/*
 *  Set packet filter: Receive directed and broadcast 
address
 */
-   velocity_set_multi(vptr-dev);
+   velocity_set_multi(vptr-netdev);
 
/*
 *  Enable MII auto-polling
@@ -1402,14 +1402,14 @@ static void velocity_init_registers(struct 
velocity_info *vptr,
writel((CR0_DPOLL | CR0_TXON | CR0_RXON | CR0_STRT), 
regs-CR0Set);
 
mii_status = velocity_get_opt_media_mode(vptr);
-   netif_stop_queue(vptr-dev);
+   netif_stop_queue(vptr-netdev);
 
mii_init(vptr, mii_status);
 
if (velocity_set_media_mode(vptr, mii_status) != 
VELOCITY_LINK_CHANGE) {
velocity_print_link_status(vptr);
if (!(vptr-mii_status  VELOCITY_LINK_FAIL))
-   netif_wake_queue(vptr-dev);
+   netif_wake_queue(vptr-netdev);
}
 
enable_flow_control_ability(vptr);
@@ -1472,7 +1472,7 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
rx_ring_size, pool_dma);
if (!pool) {
dev_err(pdev-dev, %s : DMA memory allocation failed.\n,
-   vptr-dev-name);
+   vptr-netdev-name);
return -ENOMEM;
}
 
@@ -1512,7 +1512,7 @@ static int velocity_alloc_rx_buf(struct velocity_info 
*vptr, int idx)
struct rx_desc *rd = (vptr-rx.ring[idx]);
struct velocity_rd_info *rd_info = (vptr-rx.info[idx]);
 
-   rd_info-skb = netdev_alloc_skb(vptr-dev

[PATCHv2 3/3] net: velocity: Add platform device support to VIA velocity driver

2013-04-29 Thread Tony Prisk
Add support for the VIA Velocity network driver to be bound to a
OF created platform device.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 .../devicetree/bindings/net/via-velocity.txt   |   20 +
 drivers/net/ethernet/via/Kconfig   |3 +-
 drivers/net/ethernet/via/via-velocity.c|  453 +++-
 drivers/net/ethernet/via/via-velocity.h|   30 +-
 4 files changed, 398 insertions(+), 108 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt

diff --git a/Documentation/devicetree/bindings/net/via-velocity.txt 
b/Documentation/devicetree/bindings/net/via-velocity.txt
new file mode 100644
index 000..b3db469
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/via-velocity.txt
@@ -0,0 +1,20 @@
+* VIA Velocity 10/100/1000 Network Controller
+
+Required properties:
+- compatible : Should be via,velocity-vt6110
+- reg : Address and length of the io space
+- interrupts : Should contain the controller interrupt line
+
+Optional properties:
+- no-eeprom : PCI network cards use an external EEPROM to store data. Embedded
+   devices quite often set this data in uboot and do not provide an eeprom.
+   Specify this option if you have no external eeprom.
+
+Examples:
+
+eth0@d8004000 {
+   compatible = via,velocity-vt6110;
+   reg = 0xd8004000 0x400;
+   interrupts = 10;
+   no-eeprom;
+};
diff --git a/drivers/net/ethernet/via/Kconfig b/drivers/net/ethernet/via/Kconfig
index 68a9ba6..6a87097 100644
--- a/drivers/net/ethernet/via/Kconfig
+++ b/drivers/net/ethernet/via/Kconfig
@@ -5,7 +5,6 @@
 config NET_VENDOR_VIA
bool VIA devices
default y
-   depends on PCI
---help---
  If you have a network (Ethernet) card belonging to this class, say Y
  and read the Ethernet-HOWTO, available from
@@ -45,7 +44,7 @@ config VIA_RHINE_MMIO
 
 config VIA_VELOCITY
tristate VIA Velocity support
-   depends on PCI
+   depends on (PCI || USE_OF)
select CRC32
select CRC_CCITT
select NET_CORE
diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index e2c4887..03cc3ed 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -65,7 +65,11 @@
 #include linux/if.h
 #include linux/uaccess.h
 #include linux/proc_fs.h
+#include linux/of_address.h
+#include linux/of_device.h
+#include linux/of_irq.h
 #include linux/inetdevice.h
+#include linux/platform_device.h
 #include linux/reboot.h
 #include linux/ethtool.h
 #include linux/mii.h
@@ -84,6 +88,16 @@
 static int velocity_nics;
 static int msglevel = MSG_LEVEL_INFO;
 
+static void velocity_set_power_state(struct velocity_info *vptr, char state)
+{
+   void *addr = vptr-mac_regs;
+
+   if (vptr-bustype == BUS_PCI)
+   pci_set_power_state(vptr-pdev, state);
+   else
+   writeb(state, addr + 0x154);
+}
+
 /**
  * mac_get_cam_mask-   Read a CAM mask
  * @regs: register block for this velocity
@@ -362,12 +376,24 @@ static struct velocity_info_tbl chip_info_table[] = {
  * Describe the PCI device identifiers that we support in this
  * device driver. Used for hotplug autoloading.
  */
-static DEFINE_PCI_DEVICE_TABLE(velocity_id_table) = {
+#ifdef CONFIG_PCI
+static DEFINE_PCI_DEVICE_TABLE(velocity_pci_id_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) },
{ }
 };
 
-MODULE_DEVICE_TABLE(pci, velocity_id_table);
+MODULE_DEVICE_TABLE(pci, velocity_pci_id_table);
+#endif
+
+/**
+ * Describe the OF device identifiers that we support in this
+ * device driver. Used for devicetree nodes.
+ */
+static struct of_device_id velocity_of_ids[] = {
+   { .compatible = via,velocity-vt6110, .data = chip_info_table[0] },
+   { /* Sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, velocity_of_ids);
 
 /**
  * get_chip_name   -   identifier to name
@@ -386,29 +412,6 @@ static const char *get_chip_name(enum chip_type chip_id)
 }
 
 /**
- * velocity_remove1-   device unplug
- * @pdev: PCI device being removed
- *
- * Device unload callback. Called on an unplug or on module
- * unload for each active device that is present. Disconnects
- * the device from the network layer and frees all the resources
- */
-static void velocity_remove1(struct pci_dev *pdev)
-{
-   struct net_device *dev = pci_get_drvdata(pdev);
-   struct velocity_info *vptr = netdev_priv(dev);
-
-   unregister_netdev(dev);
-   iounmap(vptr-mac_regs);
-   pci_release_regions(pdev);
-   pci_disable_device(pdev);
-   pci_set_drvdata(pdev, NULL);
-   free_netdev(dev);
-
-   velocity_nics--;
-}
-
-/**
  * velocity_set_int_opt-   parser for integer options
  * @opt: pointer to option value
  * @val: value the user requested (or -1 for default)
@@ -1179,6 +1182,14 @@ static

Re: [PATCHv2 0/3] Add support for velocity network driver on platform devices

2013-04-29 Thread Tony Prisk

On 30/04/13 07:15, David Miller wrote:

You prepared these patches against a net-next tree which is at least
a week old, I know this because that's when the NETIF_F_* flags for
VLAN offloading changed their names which causes your third patch
to fail to apply.

Do not do this, net-next changes every day and rapidly, don't take
the chance that the driver you're touching is unpopular and thus
hasn't had changes to it recently.  Tree-wide interface changes
happen all the time.

Apologies - I didn't realise. These patches are based against 3.8-rc8.
I will rebase against net-next and resend.

Regards
Tony P
--
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/


[PATCHv3 1/3] net: velocity: Rename vptr-dev to vptr-netdev

2013-04-29 Thread Tony Prisk
Improve the clarity of the code in preparation for converting the
dma functions to generic versions, which require a struct device *.

This makes it possible to store a 'struct device *dev' in the
velocity_info structure.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/net/ethernet/via/via-velocity.c |   66 +++
 drivers/net/ethernet/via/via-velocity.h |4 +-
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index fb62489..187eef3 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -998,9 +998,9 @@ static void velocity_print_link_status(struct velocity_info 
*vptr)
 {
 
if (vptr-mii_status  VELOCITY_LINK_FAIL) {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: failed to detect 
cable link\n, vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: failed to detect 
cable link\n, vptr-netdev-name);
} else if (vptr-options.spd_dpx == SPD_DPX_AUTO) {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link 
auto-negotiation, vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link 
auto-negotiation, vptr-netdev-name);
 
if (vptr-mii_status  VELOCITY_SPEED_1000)
VELOCITY_PRT(MSG_LEVEL_INFO,  speed 1000M bps);
@@ -1014,7 +1014,7 @@ static void velocity_print_link_status(struct 
velocity_info *vptr)
else
VELOCITY_PRT(MSG_LEVEL_INFO,  half duplex\n);
} else {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link forced, 
vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link forced, 
vptr-netdev-name);
switch (vptr-options.spd_dpx) {
case SPD_DPX_1000_FULL:
VELOCITY_PRT(MSG_LEVEL_INFO,  speed 1000M bps full 
duplex\n);
@@ -1319,7 +1319,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
case VELOCITY_INIT_RESET:
case VELOCITY_INIT_WOL:
 
-   netif_stop_queue(vptr-dev);
+   netif_stop_queue(vptr-netdev);
 
/*
 *  Reset RX to prevent RX pointer not on the 4X location
@@ -1332,7 +1332,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
if (velocity_set_media_mode(vptr, mii_status) != 
VELOCITY_LINK_CHANGE) {
velocity_print_link_status(vptr);
if (!(vptr-mii_status  VELOCITY_LINK_FAIL))
-   netif_wake_queue(vptr-dev);
+   netif_wake_queue(vptr-netdev);
}
 
enable_flow_control_ability(vptr);
@@ -1354,7 +1354,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
 
mac_eeprom_reload(regs);
for (i = 0; i  6; i++)
-   writeb(vptr-dev-dev_addr[i], (regs-PAR[i]));
+   writeb(vptr-netdev-dev_addr[i], (regs-PAR[i]));
 
/*
 *  clear Pre_ACPI bit.
@@ -1377,7 +1377,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
/*
 *  Set packet filter: Receive directed and broadcast 
address
 */
-   velocity_set_multi(vptr-dev);
+   velocity_set_multi(vptr-netdev);
 
/*
 *  Enable MII auto-polling
@@ -1404,14 +1404,14 @@ static void velocity_init_registers(struct 
velocity_info *vptr,
writel((CR0_DPOLL | CR0_TXON | CR0_RXON | CR0_STRT), 
regs-CR0Set);
 
mii_status = velocity_get_opt_media_mode(vptr);
-   netif_stop_queue(vptr-dev);
+   netif_stop_queue(vptr-netdev);
 
mii_init(vptr, mii_status);
 
if (velocity_set_media_mode(vptr, mii_status) != 
VELOCITY_LINK_CHANGE) {
velocity_print_link_status(vptr);
if (!(vptr-mii_status  VELOCITY_LINK_FAIL))
-   netif_wake_queue(vptr-dev);
+   netif_wake_queue(vptr-netdev);
}
 
enable_flow_control_ability(vptr);
@@ -1474,7 +1474,7 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
rx_ring_size, pool_dma);
if (!pool) {
dev_err(pdev-dev, %s : DMA memory allocation failed.\n,
-   vptr-dev-name);
+   vptr-netdev-name);
return -ENOMEM;
}
 
@@ -1514,7 +1514,7 @@ static int velocity_alloc_rx_buf(struct velocity_info 
*vptr, int idx)
struct rx_desc *rd = (vptr-rx.ring[idx]);
struct velocity_rd_info *rd_info = (vptr-rx.info[idx]);
 
-   rd_info-skb = netdev_alloc_skb(vptr-dev

[PATCHv3 3/3] net: velocity: Add platform device support to VIA velocity driver

2013-04-29 Thread Tony Prisk
Add support for the VIA Velocity network driver to be bound to a
OF created platform device.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 .../devicetree/bindings/net/via-velocity.txt   |   20 +
 drivers/net/ethernet/via/Kconfig   |3 +-
 drivers/net/ethernet/via/via-velocity.c|  452 +++-
 drivers/net/ethernet/via/via-velocity.h|   30 +-
 4 files changed, 396 insertions(+), 109 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt

diff --git a/Documentation/devicetree/bindings/net/via-velocity.txt 
b/Documentation/devicetree/bindings/net/via-velocity.txt
new file mode 100644
index 000..b3db469
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/via-velocity.txt
@@ -0,0 +1,20 @@
+* VIA Velocity 10/100/1000 Network Controller
+
+Required properties:
+- compatible : Should be via,velocity-vt6110
+- reg : Address and length of the io space
+- interrupts : Should contain the controller interrupt line
+
+Optional properties:
+- no-eeprom : PCI network cards use an external EEPROM to store data. Embedded
+   devices quite often set this data in uboot and do not provide an eeprom.
+   Specify this option if you have no external eeprom.
+
+Examples:
+
+eth0@d8004000 {
+   compatible = via,velocity-vt6110;
+   reg = 0xd8004000 0x400;
+   interrupts = 10;
+   no-eeprom;
+};
diff --git a/drivers/net/ethernet/via/Kconfig b/drivers/net/ethernet/via/Kconfig
index 68a9ba6..6a87097 100644
--- a/drivers/net/ethernet/via/Kconfig
+++ b/drivers/net/ethernet/via/Kconfig
@@ -5,7 +5,6 @@
 config NET_VENDOR_VIA
bool VIA devices
default y
-   depends on PCI
---help---
  If you have a network (Ethernet) card belonging to this class, say Y
  and read the Ethernet-HOWTO, available from
@@ -45,7 +44,7 @@ config VIA_RHINE_MMIO
 
 config VIA_VELOCITY
tristate VIA Velocity support
-   depends on PCI
+   depends on (PCI || USE_OF)
select CRC32
select CRC_CCITT
select NET_CORE
diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index 5996cee..3a87f13 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -65,7 +65,11 @@
 #include linux/if.h
 #include linux/uaccess.h
 #include linux/proc_fs.h
+#include linux/of_address.h
+#include linux/of_device.h
+#include linux/of_irq.h
 #include linux/inetdevice.h
+#include linux/platform_device.h
 #include linux/reboot.h
 #include linux/ethtool.h
 #include linux/mii.h
@@ -84,6 +88,16 @@
 static int velocity_nics;
 static int msglevel = MSG_LEVEL_INFO;
 
+static void velocity_set_power_state(struct velocity_info *vptr, char state)
+{
+   void *addr = vptr-mac_regs;
+
+   if (vptr-bustype == BUS_PCI)
+   pci_set_power_state(vptr-pdev, state);
+   else
+   writeb(state, addr + 0x154);
+}
+
 /**
  * mac_get_cam_mask-   Read a CAM mask
  * @regs: register block for this velocity
@@ -362,12 +376,24 @@ static struct velocity_info_tbl chip_info_table[] = {
  * Describe the PCI device identifiers that we support in this
  * device driver. Used for hotplug autoloading.
  */
-static DEFINE_PCI_DEVICE_TABLE(velocity_id_table) = {
+#ifdef CONFIG_PCI
+static DEFINE_PCI_DEVICE_TABLE(velocity_pci_id_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) },
{ }
 };
 
-MODULE_DEVICE_TABLE(pci, velocity_id_table);
+MODULE_DEVICE_TABLE(pci, velocity_pci_id_table);
+#endif
+
+/**
+ * Describe the OF device identifiers that we support in this
+ * device driver. Used for devicetree nodes.
+ */
+static struct of_device_id velocity_of_ids[] = {
+   { .compatible = via,velocity-vt6110, .data = chip_info_table[0] },
+   { /* Sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, velocity_of_ids);
 
 /**
  * get_chip_name   -   identifier to name
@@ -386,29 +412,6 @@ static const char *get_chip_name(enum chip_type chip_id)
 }
 
 /**
- * velocity_remove1-   device unplug
- * @pdev: PCI device being removed
- *
- * Device unload callback. Called on an unplug or on module
- * unload for each active device that is present. Disconnects
- * the device from the network layer and frees all the resources
- */
-static void velocity_remove1(struct pci_dev *pdev)
-{
-   struct net_device *dev = pci_get_drvdata(pdev);
-   struct velocity_info *vptr = netdev_priv(dev);
-
-   unregister_netdev(dev);
-   iounmap(vptr-mac_regs);
-   pci_release_regions(pdev);
-   pci_disable_device(pdev);
-   pci_set_drvdata(pdev, NULL);
-   free_netdev(dev);
-
-   velocity_nics--;
-}
-
-/**
  * velocity_set_int_opt-   parser for integer options
  * @opt: pointer to option value
  * @val: value the user requested (or -1 for default)
@@ -1181,6 +1184,14 @@ static

[PATCHv3 2/3] net: velocity: Convert to generic dma functions

2013-04-29 Thread Tony Prisk
Remove the pci_* dma functions and replace with the more generic
versions.

In preparation of adding platform support, a new struct device *dev
is added to struct velocity_info which can be used by both the pci
and platform code.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/net/ethernet/via/via-velocity.c |   51 +++
 drivers/net/ethernet/via/via-velocity.h |1 +
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index 187eef3..5996cee 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -46,6 +46,7 @@
 #include linux/types.h
 #include linux/bitops.h
 #include linux/init.h
+#include linux/dma-mapping.h
 #include linux/mm.h
 #include linux/errno.h
 #include linux/ioport.h
@@ -1459,7 +1460,6 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
struct velocity_opt *opt = vptr-options;
const unsigned int rx_ring_size = opt-numrx * sizeof(struct rx_desc);
const unsigned int tx_ring_size = opt-numtx * sizeof(struct tx_desc);
-   struct pci_dev *pdev = vptr-pdev;
dma_addr_t pool_dma;
void *pool;
unsigned int i;
@@ -1467,13 +1467,13 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
/*
 * Allocate all RD/TD rings a single pool.
 *
-* pci_alloc_consistent() fulfills the requirement for 64 bytes
+* dma_alloc_coherent() fulfills the requirement for 64 bytes
 * alignment
 */
-   pool = pci_alloc_consistent(pdev, tx_ring_size * vptr-tx.numq +
-   rx_ring_size, pool_dma);
+   pool = dma_alloc_coherent(vptr-dev, tx_ring_size * vptr-tx.numq +
+   rx_ring_size, pool_dma, GFP_ATOMIC);
if (!pool) {
-   dev_err(pdev-dev, %s : DMA memory allocation failed.\n,
+   dev_err(vptr-dev, %s : DMA memory allocation failed.\n,
vptr-netdev-name);
return -ENOMEM;
}
@@ -1524,8 +1524,8 @@ static int velocity_alloc_rx_buf(struct velocity_info 
*vptr, int idx)
 */
skb_reserve(rd_info-skb,
64 - ((unsigned long) rd_info-skb-data  63));
-   rd_info-skb_dma = pci_map_single(vptr-pdev, rd_info-skb-data,
-   vptr-rx.buf_sz, PCI_DMA_FROMDEVICE);
+   rd_info-skb_dma = dma_map_single(vptr-dev, rd_info-skb-data,
+   vptr-rx.buf_sz, DMA_FROM_DEVICE);
 
/*
 *  Fill in the descriptor to match
@@ -1588,8 +1588,8 @@ static void velocity_free_rd_ring(struct velocity_info 
*vptr)
 
if (!rd_info-skb)
continue;
-   pci_unmap_single(vptr-pdev, rd_info-skb_dma, vptr-rx.buf_sz,
-PCI_DMA_FROMDEVICE);
+   dma_unmap_single(vptr-dev, rd_info-skb_dma, vptr-rx.buf_sz,
+DMA_FROM_DEVICE);
rd_info-skb_dma = 0;
 
dev_kfree_skb(rd_info-skb);
@@ -1670,7 +1670,7 @@ static void velocity_free_dma_rings(struct velocity_info 
*vptr)
const int size = vptr-options.numrx * sizeof(struct rx_desc) +
vptr-options.numtx * sizeof(struct tx_desc) * vptr-tx.numq;
 
-   pci_free_consistent(vptr-pdev, size, vptr-rx.ring, vptr-rx.pool_dma);
+   dma_free_coherent(vptr-dev, size, vptr-rx.ring, vptr-rx.pool_dma);
 }
 
 static int velocity_init_rings(struct velocity_info *vptr, int mtu)
@@ -1727,8 +1727,8 @@ static void velocity_free_tx_buf(struct velocity_info 
*vptr,
pktlen = max_t(size_t, pktlen,
td-td_buf[i].size  ~TD_QUEUE);
 
-   pci_unmap_single(vptr-pdev, tdinfo-skb_dma[i],
-   le16_to_cpu(pktlen), PCI_DMA_TODEVICE);
+   dma_unmap_single(vptr-dev, tdinfo-skb_dma[i],
+   le16_to_cpu(pktlen), DMA_TO_DEVICE);
}
}
dev_kfree_skb_irq(skb);
@@ -1750,8 +1750,8 @@ static void velocity_free_td_ring_entry(struct 
velocity_info *vptr,
if (td_info-skb) {
for (i = 0; i  td_info-nskb_dma; i++) {
if (td_info-skb_dma[i]) {
-   pci_unmap_single(vptr-pdev, 
td_info-skb_dma[i],
-   td_info-skb-len, PCI_DMA_TODEVICE);
+   dma_unmap_single(vptr-dev, td_info-skb_dma[i],
+   td_info-skb-len, DMA_TO_DEVICE);
td_info-skb_dma[i] = 0;
}
}
@@ -2029,7 +2029,6 @@ static inline void velocity_iph_realign(struct 
velocity_info *vptr,
  */
 static int

[PATCHv3 0/3] Add support for velocity network driver on platform devices

2013-04-29 Thread Tony Prisk
v3 changes:
Rebased against net-next.
Fix errors in pm code.

v2 changes:
Drop patch #1 as requested by David Miller.
Correct the PHYID_ICPLUS_IP101A MII bits - should be ON, rather than OFF.
Read the platform rev_id from the correct register [regs-rev_id]. It's possible
this would work for the PCI version as well and would remove the need for the
'if (pci)' test to set vptr-rev_id.

v1:
The first three patches are general tidyup.

[DROPPED] Patch ## just alphabetizes the #includes to make it easier to read.

Patch #1 replaces vptr-dev with vptr-netdev, in preparation of adding a
struct device *dev in Patch #3

Patch #2 replaces the pci dma functions with the generic versions.

I have build tested these patches but don't have a PCI velocity to run-test it.
I can't see that they should introduce any problems as it is all renames and
function swapping.

Patch #3 adds support for the velocity driver on devicetree platform devices.
Binding document included. This patch is compile-tested for PCI, and boot
tested on a VIA APC8750.

I think it would be pertinent to get some tested-by's for PCI users.

Regards
Tony Prisk

Tony Prisk (3):
  net: velocity: Rename vptr-dev to vptr-netdev
  net: velocity: Convert to generic dma functions
  net: velocity: Add platform device support to VIA velocity driver

 .../devicetree/bindings/net/via-velocity.txt   |   20 +
 drivers/net/ethernet/via/Kconfig   |3 +-
 drivers/net/ethernet/via/via-velocity.c|  563 ++--
 drivers/net/ethernet/via/via-velocity.h|   35 +-
 4 files changed, 454 insertions(+), 167 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt

-- 
1.7.9.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/


[PATCHv4 2/3] net: velocity: Convert to generic dma functions

2013-04-30 Thread Tony Prisk
Remove the pci_* dma functions and replace with the more generic
versions.

In preparation of adding platform support, a new struct device *dev
is added to struct velocity_info which can be used by both the pci
and platform code.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/net/ethernet/via/via-velocity.c |   51 +++
 drivers/net/ethernet/via/via-velocity.h |1 +
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index 187eef3..5996cee 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -46,6 +46,7 @@
 #include linux/types.h
 #include linux/bitops.h
 #include linux/init.h
+#include linux/dma-mapping.h
 #include linux/mm.h
 #include linux/errno.h
 #include linux/ioport.h
@@ -1459,7 +1460,6 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
struct velocity_opt *opt = vptr-options;
const unsigned int rx_ring_size = opt-numrx * sizeof(struct rx_desc);
const unsigned int tx_ring_size = opt-numtx * sizeof(struct tx_desc);
-   struct pci_dev *pdev = vptr-pdev;
dma_addr_t pool_dma;
void *pool;
unsigned int i;
@@ -1467,13 +1467,13 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
/*
 * Allocate all RD/TD rings a single pool.
 *
-* pci_alloc_consistent() fulfills the requirement for 64 bytes
+* dma_alloc_coherent() fulfills the requirement for 64 bytes
 * alignment
 */
-   pool = pci_alloc_consistent(pdev, tx_ring_size * vptr-tx.numq +
-   rx_ring_size, pool_dma);
+   pool = dma_alloc_coherent(vptr-dev, tx_ring_size * vptr-tx.numq +
+   rx_ring_size, pool_dma, GFP_ATOMIC);
if (!pool) {
-   dev_err(pdev-dev, %s : DMA memory allocation failed.\n,
+   dev_err(vptr-dev, %s : DMA memory allocation failed.\n,
vptr-netdev-name);
return -ENOMEM;
}
@@ -1524,8 +1524,8 @@ static int velocity_alloc_rx_buf(struct velocity_info 
*vptr, int idx)
 */
skb_reserve(rd_info-skb,
64 - ((unsigned long) rd_info-skb-data  63));
-   rd_info-skb_dma = pci_map_single(vptr-pdev, rd_info-skb-data,
-   vptr-rx.buf_sz, PCI_DMA_FROMDEVICE);
+   rd_info-skb_dma = dma_map_single(vptr-dev, rd_info-skb-data,
+   vptr-rx.buf_sz, DMA_FROM_DEVICE);
 
/*
 *  Fill in the descriptor to match
@@ -1588,8 +1588,8 @@ static void velocity_free_rd_ring(struct velocity_info 
*vptr)
 
if (!rd_info-skb)
continue;
-   pci_unmap_single(vptr-pdev, rd_info-skb_dma, vptr-rx.buf_sz,
-PCI_DMA_FROMDEVICE);
+   dma_unmap_single(vptr-dev, rd_info-skb_dma, vptr-rx.buf_sz,
+DMA_FROM_DEVICE);
rd_info-skb_dma = 0;
 
dev_kfree_skb(rd_info-skb);
@@ -1670,7 +1670,7 @@ static void velocity_free_dma_rings(struct velocity_info 
*vptr)
const int size = vptr-options.numrx * sizeof(struct rx_desc) +
vptr-options.numtx * sizeof(struct tx_desc) * vptr-tx.numq;
 
-   pci_free_consistent(vptr-pdev, size, vptr-rx.ring, vptr-rx.pool_dma);
+   dma_free_coherent(vptr-dev, size, vptr-rx.ring, vptr-rx.pool_dma);
 }
 
 static int velocity_init_rings(struct velocity_info *vptr, int mtu)
@@ -1727,8 +1727,8 @@ static void velocity_free_tx_buf(struct velocity_info 
*vptr,
pktlen = max_t(size_t, pktlen,
td-td_buf[i].size  ~TD_QUEUE);
 
-   pci_unmap_single(vptr-pdev, tdinfo-skb_dma[i],
-   le16_to_cpu(pktlen), PCI_DMA_TODEVICE);
+   dma_unmap_single(vptr-dev, tdinfo-skb_dma[i],
+   le16_to_cpu(pktlen), DMA_TO_DEVICE);
}
}
dev_kfree_skb_irq(skb);
@@ -1750,8 +1750,8 @@ static void velocity_free_td_ring_entry(struct 
velocity_info *vptr,
if (td_info-skb) {
for (i = 0; i  td_info-nskb_dma; i++) {
if (td_info-skb_dma[i]) {
-   pci_unmap_single(vptr-pdev, 
td_info-skb_dma[i],
-   td_info-skb-len, PCI_DMA_TODEVICE);
+   dma_unmap_single(vptr-dev, td_info-skb_dma[i],
+   td_info-skb-len, DMA_TO_DEVICE);
td_info-skb_dma[i] = 0;
}
}
@@ -2029,7 +2029,6 @@ static inline void velocity_iph_realign(struct 
velocity_info *vptr,
  */
 static int

[PATCHv4 0/3] Add support for velocity network driver on platform devices

2013-04-30 Thread Tony Prisk
v4 changes:
Code tidyup as requested by Francois Romieu
Removed '#ifdef PCI' around PCI code. Compile tested on (!)PCI and (!)PM.

v3 changes:
Rebased against net-next.
Fix errors in pm code.

v2 changes:
Drop patch #1 as requested by David Miller.
Correct the PHYID_ICPLUS_IP101A MII bits - should be ON, rather than OFF.
Read the platform rev_id from the correct register [regs-rev_id]. It's possible
this would work for the PCI version as well and would remove the need for the
'if (pci)' test to set vptr-rev_id.

v1:
The first three patches are general tidyup.

[DROPPED] Patch ## just alphabetizes the #includes to make it easier to read.

Patch #1 replaces vptr-dev with vptr-netdev, in preparation of adding a
struct device *dev in Patch #3

Patch #2 replaces the pci dma functions with the generic versions.

I have build tested these patches but don't have a PCI velocity to run-test it.
I can't see that they should introduce any problems as it is all renames and
function swapping.

Patch #3 adds support for the velocity driver on devicetree platform devices.
Binding document included. This patch is compile-tested for PCI, and boot
tested on a VIA APC8750.

I think it would be pertinent to get some tested-by's for PCI users.

Regards
Tony Prisk

Tony Prisk (3):
  net: velocity: Rename vptr-dev to vptr-netdev
  net: velocity: Convert to generic dma functions
  net: velocity: Add platform device support to VIA velocity driver

 .../devicetree/bindings/net/via-velocity.txt   |   20 +
 drivers/net/ethernet/via/Kconfig   |3 +-
 drivers/net/ethernet/via/via-velocity.c|  546 ++--
 drivers/net/ethernet/via/via-velocity.h|   40 +-
 4 files changed, 438 insertions(+), 171 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt

-- 
1.7.9.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/


[PATCHv4 1/3] net: velocity: Rename vptr-dev to vptr-netdev

2013-04-30 Thread Tony Prisk
Improve the clarity of the code in preparation for converting the
dma functions to generic versions, which require a struct device *.

This makes it possible to store a 'struct device *dev' in the
velocity_info structure.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/net/ethernet/via/via-velocity.c |   66 +++
 drivers/net/ethernet/via/via-velocity.h |4 +-
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index fb62489..187eef3 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -998,9 +998,9 @@ static void velocity_print_link_status(struct velocity_info 
*vptr)
 {
 
if (vptr-mii_status  VELOCITY_LINK_FAIL) {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: failed to detect 
cable link\n, vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: failed to detect 
cable link\n, vptr-netdev-name);
} else if (vptr-options.spd_dpx == SPD_DPX_AUTO) {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link 
auto-negotiation, vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link 
auto-negotiation, vptr-netdev-name);
 
if (vptr-mii_status  VELOCITY_SPEED_1000)
VELOCITY_PRT(MSG_LEVEL_INFO,  speed 1000M bps);
@@ -1014,7 +1014,7 @@ static void velocity_print_link_status(struct 
velocity_info *vptr)
else
VELOCITY_PRT(MSG_LEVEL_INFO,  half duplex\n);
} else {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link forced, 
vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link forced, 
vptr-netdev-name);
switch (vptr-options.spd_dpx) {
case SPD_DPX_1000_FULL:
VELOCITY_PRT(MSG_LEVEL_INFO,  speed 1000M bps full 
duplex\n);
@@ -1319,7 +1319,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
case VELOCITY_INIT_RESET:
case VELOCITY_INIT_WOL:
 
-   netif_stop_queue(vptr-dev);
+   netif_stop_queue(vptr-netdev);
 
/*
 *  Reset RX to prevent RX pointer not on the 4X location
@@ -1332,7 +1332,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
if (velocity_set_media_mode(vptr, mii_status) != 
VELOCITY_LINK_CHANGE) {
velocity_print_link_status(vptr);
if (!(vptr-mii_status  VELOCITY_LINK_FAIL))
-   netif_wake_queue(vptr-dev);
+   netif_wake_queue(vptr-netdev);
}
 
enable_flow_control_ability(vptr);
@@ -1354,7 +1354,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
 
mac_eeprom_reload(regs);
for (i = 0; i  6; i++)
-   writeb(vptr-dev-dev_addr[i], (regs-PAR[i]));
+   writeb(vptr-netdev-dev_addr[i], (regs-PAR[i]));
 
/*
 *  clear Pre_ACPI bit.
@@ -1377,7 +1377,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
/*
 *  Set packet filter: Receive directed and broadcast 
address
 */
-   velocity_set_multi(vptr-dev);
+   velocity_set_multi(vptr-netdev);
 
/*
 *  Enable MII auto-polling
@@ -1404,14 +1404,14 @@ static void velocity_init_registers(struct 
velocity_info *vptr,
writel((CR0_DPOLL | CR0_TXON | CR0_RXON | CR0_STRT), 
regs-CR0Set);
 
mii_status = velocity_get_opt_media_mode(vptr);
-   netif_stop_queue(vptr-dev);
+   netif_stop_queue(vptr-netdev);
 
mii_init(vptr, mii_status);
 
if (velocity_set_media_mode(vptr, mii_status) != 
VELOCITY_LINK_CHANGE) {
velocity_print_link_status(vptr);
if (!(vptr-mii_status  VELOCITY_LINK_FAIL))
-   netif_wake_queue(vptr-dev);
+   netif_wake_queue(vptr-netdev);
}
 
enable_flow_control_ability(vptr);
@@ -1474,7 +1474,7 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
rx_ring_size, pool_dma);
if (!pool) {
dev_err(pdev-dev, %s : DMA memory allocation failed.\n,
-   vptr-dev-name);
+   vptr-netdev-name);
return -ENOMEM;
}
 
@@ -1514,7 +1514,7 @@ static int velocity_alloc_rx_buf(struct velocity_info 
*vptr, int idx)
struct rx_desc *rd = (vptr-rx.ring[idx]);
struct velocity_rd_info *rd_info = (vptr-rx.info[idx]);
 
-   rd_info-skb = netdev_alloc_skb(vptr-dev

[PATCHv4 3/3] net: velocity: Add platform device support to VIA velocity driver

2013-04-30 Thread Tony Prisk
Add support for the VIA Velocity network driver to be bound to a
OF created platform device.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 .../devicetree/bindings/net/via-velocity.txt   |   20 +
 drivers/net/ethernet/via/Kconfig   |3 +-
 drivers/net/ethernet/via/via-velocity.c|  435 +++-
 drivers/net/ethernet/via/via-velocity.h|   35 +-
 4 files changed, 380 insertions(+), 113 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt

diff --git a/Documentation/devicetree/bindings/net/via-velocity.txt 
b/Documentation/devicetree/bindings/net/via-velocity.txt
new file mode 100644
index 000..b3db469
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/via-velocity.txt
@@ -0,0 +1,20 @@
+* VIA Velocity 10/100/1000 Network Controller
+
+Required properties:
+- compatible : Should be via,velocity-vt6110
+- reg : Address and length of the io space
+- interrupts : Should contain the controller interrupt line
+
+Optional properties:
+- no-eeprom : PCI network cards use an external EEPROM to store data. Embedded
+   devices quite often set this data in uboot and do not provide an eeprom.
+   Specify this option if you have no external eeprom.
+
+Examples:
+
+eth0@d8004000 {
+   compatible = via,velocity-vt6110;
+   reg = 0xd8004000 0x400;
+   interrupts = 10;
+   no-eeprom;
+};
diff --git a/drivers/net/ethernet/via/Kconfig b/drivers/net/ethernet/via/Kconfig
index 68a9ba6..6a87097 100644
--- a/drivers/net/ethernet/via/Kconfig
+++ b/drivers/net/ethernet/via/Kconfig
@@ -5,7 +5,6 @@
 config NET_VENDOR_VIA
bool VIA devices
default y
-   depends on PCI
---help---
  If you have a network (Ethernet) card belonging to this class, say Y
  and read the Ethernet-HOWTO, available from
@@ -45,7 +44,7 @@ config VIA_RHINE_MMIO
 
 config VIA_VELOCITY
tristate VIA Velocity support
-   depends on PCI
+   depends on (PCI || USE_OF)
select CRC32
select CRC_CCITT
select NET_CORE
diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index 5996cee..aa0789f 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -65,7 +65,11 @@
 #include linux/if.h
 #include linux/uaccess.h
 #include linux/proc_fs.h
+#include linux/of_address.h
+#include linux/of_device.h
+#include linux/of_irq.h
 #include linux/inetdevice.h
+#include linux/platform_device.h
 #include linux/reboot.h
 #include linux/ethtool.h
 #include linux/mii.h
@@ -84,6 +88,16 @@
 static int velocity_nics;
 static int msglevel = MSG_LEVEL_INFO;
 
+static void velocity_set_power_state(struct velocity_info *vptr, char state)
+{
+   void *addr = vptr-mac_regs;
+
+   if (vptr-bustype == BUS_PCI)
+   pci_set_power_state(vptr-pdev.pcidev, state);
+   else
+   writeb(state, addr + 0x154);
+}
+
 /**
  * mac_get_cam_mask-   Read a CAM mask
  * @regs: register block for this velocity
@@ -362,12 +376,23 @@ static struct velocity_info_tbl chip_info_table[] = {
  * Describe the PCI device identifiers that we support in this
  * device driver. Used for hotplug autoloading.
  */
-static DEFINE_PCI_DEVICE_TABLE(velocity_id_table) = {
+
+static DEFINE_PCI_DEVICE_TABLE(velocity_pci_id_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) },
{ }
 };
 
-MODULE_DEVICE_TABLE(pci, velocity_id_table);
+MODULE_DEVICE_TABLE(pci, velocity_pci_id_table);
+
+/**
+ * Describe the OF device identifiers that we support in this
+ * device driver. Used for devicetree nodes.
+ */
+static struct of_device_id velocity_of_ids[] = {
+   { .compatible = via,velocity-vt6110, .data = chip_info_table[0] },
+   { /* Sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, velocity_of_ids);
 
 /**
  * get_chip_name   -   identifier to name
@@ -386,29 +411,6 @@ static const char *get_chip_name(enum chip_type chip_id)
 }
 
 /**
- * velocity_remove1-   device unplug
- * @pdev: PCI device being removed
- *
- * Device unload callback. Called on an unplug or on module
- * unload for each active device that is present. Disconnects
- * the device from the network layer and frees all the resources
- */
-static void velocity_remove1(struct pci_dev *pdev)
-{
-   struct net_device *dev = pci_get_drvdata(pdev);
-   struct velocity_info *vptr = netdev_priv(dev);
-
-   unregister_netdev(dev);
-   iounmap(vptr-mac_regs);
-   pci_release_regions(pdev);
-   pci_disable_device(pdev);
-   pci_set_drvdata(pdev, NULL);
-   free_netdev(dev);
-
-   velocity_nics--;
-}
-
-/**
  * velocity_set_int_opt-   parser for integer options
  * @opt: pointer to option value
  * @val: value the user requested (or -1 for default)
@@ -1181,6 +1183,17 @@ static void mii_init(struct

Re: [PATCHv4 0/3] Add support for velocity network driver on platform devices

2013-05-01 Thread Tony Prisk

On 02/05/13 06:52, David Miller wrote:

From: Tony Prisk li...@prisktech.co.nz
Date: Tue, 30 Apr 2013 18:16:57 +1200


I think it would be pertinent to get some tested-by's for PCI users.

Tony, this came in a bit late, and there hasn't been any PCI test
reports so I have to defer this to the next merge window, sorry.

No problems - I didn't honestly expect it to go in for 3.10 any way.
I was trying to get in nice and earlier for 3.11 to give people plenty 
of time to test.


Regards
Tony P
--
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 29/30] rtc: rtc-vt8500: use devm_rtc_device_register()

2013-05-02 Thread Tony Prisk
I realise this is a rather trivial series but it would be nice if the 
listed maintainers for the drivers had been notified as well.


Regards
Tony Prisk
--
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/


[PATCHv5 0/3] Add support for velocity network driver on platform devices

2013-05-02 Thread Tony Prisk
v5 changes:
Remove velocity_info union. Change velocity_info-pdev back to struct pci_dev.
Remove more 'if (pci)' sections.
Remove 'void *pdev' function parameters.
Pass correct variable to velocity_choose_state()

v4 changes:
Code tidyup as requested by Francois Romieu
Removed '#ifdef PCI' around PCI code. Compile tested on (!)PCI and (!)PM.

v3 changes:
Rebased against net-next.
Fix errors in pm code.

v2 changes:
Drop patch #1 as requested by David Miller.
Correct the PHYID_ICPLUS_IP101A MII bits - should be ON, rather than OFF.
Read the platform rev_id from the correct register [regs-rev_id]. It's possible
this would work for the PCI version as well and would remove the need for the
'if (pci)' test to set vptr-rev_id.

v1:
The first three patches are general tidyup.

[DROPPED] Patch ## just alphabetizes the #includes to make it easier to read.

Patch #1 replaces vptr-dev with vptr-netdev, in preparation of adding a
struct device *dev in Patch #3

Patch #2 replaces the pci dma functions with the generic versions.

I have build tested these patches but don't have a PCI velocity to run-test it.
I can't see that they should introduce any problems as it is all renames and
function swapping.

Patch #3 adds support for the velocity driver on devicetree platform devices.
Binding document included. This patch is compile-tested for PCI, and boot
tested on a VIA APC8750.

I think it would be pertinent to get some tested-by's for PCI users.

Regards
Tony Prisk

Tony Prisk (3):
  net: velocity: Rename vptr-dev to vptr-netdev
  net: velocity: Convert to generic dma functions
  net: velocity: Add platform device support to VIA velocity driver

 .../devicetree/bindings/net/via-velocity.txt   |   20 +
 drivers/net/ethernet/via/Kconfig   |3 +-
 drivers/net/ethernet/via/via-velocity.c|  543 +---
 drivers/net/ethernet/via/via-velocity.h|   35 +-
 4 files changed, 419 insertions(+), 182 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt

-- 
1.7.9.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/


[PATCHv5 2/3] net: velocity: Convert to generic dma functions

2013-05-02 Thread Tony Prisk
Remove the pci_* dma functions and replace with the more generic
versions.

In preparation of adding platform support, a new struct device *dev
is added to struct velocity_info which can be used by both the pci
and platform code.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/net/ethernet/via/via-velocity.c |   51 +++
 drivers/net/ethernet/via/via-velocity.h |1 +
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index 187eef3..5996cee 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -46,6 +46,7 @@
 #include linux/types.h
 #include linux/bitops.h
 #include linux/init.h
+#include linux/dma-mapping.h
 #include linux/mm.h
 #include linux/errno.h
 #include linux/ioport.h
@@ -1459,7 +1460,6 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
struct velocity_opt *opt = vptr-options;
const unsigned int rx_ring_size = opt-numrx * sizeof(struct rx_desc);
const unsigned int tx_ring_size = opt-numtx * sizeof(struct tx_desc);
-   struct pci_dev *pdev = vptr-pdev;
dma_addr_t pool_dma;
void *pool;
unsigned int i;
@@ -1467,13 +1467,13 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
/*
 * Allocate all RD/TD rings a single pool.
 *
-* pci_alloc_consistent() fulfills the requirement for 64 bytes
+* dma_alloc_coherent() fulfills the requirement for 64 bytes
 * alignment
 */
-   pool = pci_alloc_consistent(pdev, tx_ring_size * vptr-tx.numq +
-   rx_ring_size, pool_dma);
+   pool = dma_alloc_coherent(vptr-dev, tx_ring_size * vptr-tx.numq +
+   rx_ring_size, pool_dma, GFP_ATOMIC);
if (!pool) {
-   dev_err(pdev-dev, %s : DMA memory allocation failed.\n,
+   dev_err(vptr-dev, %s : DMA memory allocation failed.\n,
vptr-netdev-name);
return -ENOMEM;
}
@@ -1524,8 +1524,8 @@ static int velocity_alloc_rx_buf(struct velocity_info 
*vptr, int idx)
 */
skb_reserve(rd_info-skb,
64 - ((unsigned long) rd_info-skb-data  63));
-   rd_info-skb_dma = pci_map_single(vptr-pdev, rd_info-skb-data,
-   vptr-rx.buf_sz, PCI_DMA_FROMDEVICE);
+   rd_info-skb_dma = dma_map_single(vptr-dev, rd_info-skb-data,
+   vptr-rx.buf_sz, DMA_FROM_DEVICE);
 
/*
 *  Fill in the descriptor to match
@@ -1588,8 +1588,8 @@ static void velocity_free_rd_ring(struct velocity_info 
*vptr)
 
if (!rd_info-skb)
continue;
-   pci_unmap_single(vptr-pdev, rd_info-skb_dma, vptr-rx.buf_sz,
-PCI_DMA_FROMDEVICE);
+   dma_unmap_single(vptr-dev, rd_info-skb_dma, vptr-rx.buf_sz,
+DMA_FROM_DEVICE);
rd_info-skb_dma = 0;
 
dev_kfree_skb(rd_info-skb);
@@ -1670,7 +1670,7 @@ static void velocity_free_dma_rings(struct velocity_info 
*vptr)
const int size = vptr-options.numrx * sizeof(struct rx_desc) +
vptr-options.numtx * sizeof(struct tx_desc) * vptr-tx.numq;
 
-   pci_free_consistent(vptr-pdev, size, vptr-rx.ring, vptr-rx.pool_dma);
+   dma_free_coherent(vptr-dev, size, vptr-rx.ring, vptr-rx.pool_dma);
 }
 
 static int velocity_init_rings(struct velocity_info *vptr, int mtu)
@@ -1727,8 +1727,8 @@ static void velocity_free_tx_buf(struct velocity_info 
*vptr,
pktlen = max_t(size_t, pktlen,
td-td_buf[i].size  ~TD_QUEUE);
 
-   pci_unmap_single(vptr-pdev, tdinfo-skb_dma[i],
-   le16_to_cpu(pktlen), PCI_DMA_TODEVICE);
+   dma_unmap_single(vptr-dev, tdinfo-skb_dma[i],
+   le16_to_cpu(pktlen), DMA_TO_DEVICE);
}
}
dev_kfree_skb_irq(skb);
@@ -1750,8 +1750,8 @@ static void velocity_free_td_ring_entry(struct 
velocity_info *vptr,
if (td_info-skb) {
for (i = 0; i  td_info-nskb_dma; i++) {
if (td_info-skb_dma[i]) {
-   pci_unmap_single(vptr-pdev, 
td_info-skb_dma[i],
-   td_info-skb-len, PCI_DMA_TODEVICE);
+   dma_unmap_single(vptr-dev, td_info-skb_dma[i],
+   td_info-skb-len, DMA_TO_DEVICE);
td_info-skb_dma[i] = 0;
}
}
@@ -2029,7 +2029,6 @@ static inline void velocity_iph_realign(struct 
velocity_info *vptr,
  */
 static int

[PATCHv5 1/3] net: velocity: Rename vptr-dev to vptr-netdev

2013-05-02 Thread Tony Prisk
Improve the clarity of the code in preparation for converting the
dma functions to generic versions, which require a struct device *.

This makes it possible to store a 'struct device *dev' in the
velocity_info structure.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 drivers/net/ethernet/via/via-velocity.c |   66 +++
 drivers/net/ethernet/via/via-velocity.h |4 +-
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index fb62489..187eef3 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -998,9 +998,9 @@ static void velocity_print_link_status(struct velocity_info 
*vptr)
 {
 
if (vptr-mii_status  VELOCITY_LINK_FAIL) {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: failed to detect 
cable link\n, vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: failed to detect 
cable link\n, vptr-netdev-name);
} else if (vptr-options.spd_dpx == SPD_DPX_AUTO) {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link 
auto-negotiation, vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link 
auto-negotiation, vptr-netdev-name);
 
if (vptr-mii_status  VELOCITY_SPEED_1000)
VELOCITY_PRT(MSG_LEVEL_INFO,  speed 1000M bps);
@@ -1014,7 +1014,7 @@ static void velocity_print_link_status(struct 
velocity_info *vptr)
else
VELOCITY_PRT(MSG_LEVEL_INFO,  half duplex\n);
} else {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link forced, 
vptr-dev-name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE %s: Link forced, 
vptr-netdev-name);
switch (vptr-options.spd_dpx) {
case SPD_DPX_1000_FULL:
VELOCITY_PRT(MSG_LEVEL_INFO,  speed 1000M bps full 
duplex\n);
@@ -1319,7 +1319,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
case VELOCITY_INIT_RESET:
case VELOCITY_INIT_WOL:
 
-   netif_stop_queue(vptr-dev);
+   netif_stop_queue(vptr-netdev);
 
/*
 *  Reset RX to prevent RX pointer not on the 4X location
@@ -1332,7 +1332,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
if (velocity_set_media_mode(vptr, mii_status) != 
VELOCITY_LINK_CHANGE) {
velocity_print_link_status(vptr);
if (!(vptr-mii_status  VELOCITY_LINK_FAIL))
-   netif_wake_queue(vptr-dev);
+   netif_wake_queue(vptr-netdev);
}
 
enable_flow_control_ability(vptr);
@@ -1354,7 +1354,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
 
mac_eeprom_reload(regs);
for (i = 0; i  6; i++)
-   writeb(vptr-dev-dev_addr[i], (regs-PAR[i]));
+   writeb(vptr-netdev-dev_addr[i], (regs-PAR[i]));
 
/*
 *  clear Pre_ACPI bit.
@@ -1377,7 +1377,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
/*
 *  Set packet filter: Receive directed and broadcast 
address
 */
-   velocity_set_multi(vptr-dev);
+   velocity_set_multi(vptr-netdev);
 
/*
 *  Enable MII auto-polling
@@ -1404,14 +1404,14 @@ static void velocity_init_registers(struct 
velocity_info *vptr,
writel((CR0_DPOLL | CR0_TXON | CR0_RXON | CR0_STRT), 
regs-CR0Set);
 
mii_status = velocity_get_opt_media_mode(vptr);
-   netif_stop_queue(vptr-dev);
+   netif_stop_queue(vptr-netdev);
 
mii_init(vptr, mii_status);
 
if (velocity_set_media_mode(vptr, mii_status) != 
VELOCITY_LINK_CHANGE) {
velocity_print_link_status(vptr);
if (!(vptr-mii_status  VELOCITY_LINK_FAIL))
-   netif_wake_queue(vptr-dev);
+   netif_wake_queue(vptr-netdev);
}
 
enable_flow_control_ability(vptr);
@@ -1474,7 +1474,7 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
rx_ring_size, pool_dma);
if (!pool) {
dev_err(pdev-dev, %s : DMA memory allocation failed.\n,
-   vptr-dev-name);
+   vptr-netdev-name);
return -ENOMEM;
}
 
@@ -1514,7 +1514,7 @@ static int velocity_alloc_rx_buf(struct velocity_info 
*vptr, int idx)
struct rx_desc *rd = (vptr-rx.ring[idx]);
struct velocity_rd_info *rd_info = (vptr-rx.info[idx]);
 
-   rd_info-skb = netdev_alloc_skb(vptr-dev

[PATCHv5 3/3] net: velocity: Add platform device support to VIA velocity driver

2013-05-02 Thread Tony Prisk
Add support for the VIA Velocity network driver to be bound to a
OF created platform device.

Signed-off-by: Tony Prisk li...@prisktech.co.nz
---
 .../devicetree/bindings/net/via-velocity.txt   |   20 +
 drivers/net/ethernet/via/Kconfig   |3 +-
 drivers/net/ethernet/via/via-velocity.c|  432 ++--
 drivers/net/ethernet/via/via-velocity.h|   32 +-
 4 files changed, 362 insertions(+), 125 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt

diff --git a/Documentation/devicetree/bindings/net/via-velocity.txt 
b/Documentation/devicetree/bindings/net/via-velocity.txt
new file mode 100644
index 000..b3db469
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/via-velocity.txt
@@ -0,0 +1,20 @@
+* VIA Velocity 10/100/1000 Network Controller
+
+Required properties:
+- compatible : Should be via,velocity-vt6110
+- reg : Address and length of the io space
+- interrupts : Should contain the controller interrupt line
+
+Optional properties:
+- no-eeprom : PCI network cards use an external EEPROM to store data. Embedded
+   devices quite often set this data in uboot and do not provide an eeprom.
+   Specify this option if you have no external eeprom.
+
+Examples:
+
+eth0@d8004000 {
+   compatible = via,velocity-vt6110;
+   reg = 0xd8004000 0x400;
+   interrupts = 10;
+   no-eeprom;
+};
diff --git a/drivers/net/ethernet/via/Kconfig b/drivers/net/ethernet/via/Kconfig
index 68a9ba6..6a87097 100644
--- a/drivers/net/ethernet/via/Kconfig
+++ b/drivers/net/ethernet/via/Kconfig
@@ -5,7 +5,6 @@
 config NET_VENDOR_VIA
bool VIA devices
default y
-   depends on PCI
---help---
  If you have a network (Ethernet) card belonging to this class, say Y
  and read the Ethernet-HOWTO, available from
@@ -45,7 +44,7 @@ config VIA_RHINE_MMIO
 
 config VIA_VELOCITY
tristate VIA Velocity support
-   depends on PCI
+   depends on (PCI || USE_OF)
select CRC32
select CRC_CCITT
select NET_CORE
diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index 5996cee..cd4bf87 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -65,7 +65,11 @@
 #include linux/if.h
 #include linux/uaccess.h
 #include linux/proc_fs.h
+#include linux/of_address.h
+#include linux/of_device.h
+#include linux/of_irq.h
 #include linux/inetdevice.h
+#include linux/platform_device.h
 #include linux/reboot.h
 #include linux/ethtool.h
 #include linux/mii.h
@@ -84,6 +88,16 @@
 static int velocity_nics;
 static int msglevel = MSG_LEVEL_INFO;
 
+static void velocity_set_power_state(struct velocity_info *vptr, char state)
+{
+   void *addr = vptr-mac_regs;
+
+   if (vptr-bustype == BUS_PCI)
+   pci_set_power_state(vptr-pdev, state);
+   else
+   writeb(state, addr + 0x154);
+}
+
 /**
  * mac_get_cam_mask-   Read a CAM mask
  * @regs: register block for this velocity
@@ -362,12 +376,23 @@ static struct velocity_info_tbl chip_info_table[] = {
  * Describe the PCI device identifiers that we support in this
  * device driver. Used for hotplug autoloading.
  */
-static DEFINE_PCI_DEVICE_TABLE(velocity_id_table) = {
+
+static DEFINE_PCI_DEVICE_TABLE(velocity_pci_id_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) },
{ }
 };
 
-MODULE_DEVICE_TABLE(pci, velocity_id_table);
+MODULE_DEVICE_TABLE(pci, velocity_pci_id_table);
+
+/**
+ * Describe the OF device identifiers that we support in this
+ * device driver. Used for devicetree nodes.
+ */
+static struct of_device_id velocity_of_ids[] = {
+   { .compatible = via,velocity-vt6110, .data = chip_info_table[0] },
+   { /* Sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, velocity_of_ids);
 
 /**
  * get_chip_name   -   identifier to name
@@ -386,29 +411,6 @@ static const char *get_chip_name(enum chip_type chip_id)
 }
 
 /**
- * velocity_remove1-   device unplug
- * @pdev: PCI device being removed
- *
- * Device unload callback. Called on an unplug or on module
- * unload for each active device that is present. Disconnects
- * the device from the network layer and frees all the resources
- */
-static void velocity_remove1(struct pci_dev *pdev)
-{
-   struct net_device *dev = pci_get_drvdata(pdev);
-   struct velocity_info *vptr = netdev_priv(dev);
-
-   unregister_netdev(dev);
-   iounmap(vptr-mac_regs);
-   pci_release_regions(pdev);
-   pci_disable_device(pdev);
-   pci_set_drvdata(pdev, NULL);
-   free_netdev(dev);
-
-   velocity_nics--;
-}
-
-/**
  * velocity_set_int_opt-   parser for integer options
  * @opt: pointer to option value
  * @val: value the user requested (or -1 for default)
@@ -1181,6 +1183,17 @@ static void mii_init(struct

Re: [PATCH 38/42] rtc: rtc-vt8500: remove unnecessary platform_set_drvdata()

2013-05-03 Thread Tony Prisk

On 03/05/13 18:38, Jingoo Han wrote:

The driver core clears the driver data to NULL after device_release
or on probe failure, since commit 0998d0631001288a5974afc0b2a5f568bcdecb4d
(device-core: Ensure drvdata = NULL when no driver is bound).
Thus, it is not needed to manually clear the device driver data to NULL.

Signed-off-by: Jingoo Han jg1@samsung.com
---
  drivers/rtc/rtc-vt8500.c |2 --
  1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c
index d89efee..c2d6331 100644
--- a/drivers/rtc/rtc-vt8500.c
+++ b/drivers/rtc/rtc-vt8500.c
@@ -282,8 +282,6 @@ static int vt8500_rtc_remove(struct platform_device *pdev)
/* Disable alarm matching */
writel(0, vt8500_rtc-regbase + VT8500_RTC_IS);
  
-	platform_set_drvdata(pdev, NULL);

-
return 0;
  }
  

Acked-by: Tony Prisk li...@prisktech.co.nz
--
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   >