[PATCHv2 1/2] pwm: vt8500: Register write busy test performed incorrectly
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 --- 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(va
[PATCH 4/4] video: vt8500: Update descriptions in video/Kconfig
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 --- 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=. 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
From: Julia Lawall 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/): // @@ expression x,e; @@ x = devm_kzalloc(...) ... when != x = e ?-kfree(x,...); // 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 Signed-off-by: Tony Prisk --- 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(>dev, sizeof(struct wm8505fb_info) + sizeof(u32) * 16, GFP_KERNEL); if (!fbi) { dev_err(>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(>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(>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(>dev, "failed to map I/O memory\n"); - ret = -EBUSY; - goto failed_free_res; - } + fbi->regbase = devm_request_and_ioremap(>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", ); 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(>dev, fb_mem_len, _mem_phys, + fb_mem_virt = dmam_alloc_coherent(>dev, fb_mem_len, _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 @@ st
[PATCH 3/4] video: vt8500: Remove unused platform_data/video-vt8500lcdfb.h
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 --- 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 #include -#include - #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 #include -#include - #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 - * - * 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 - -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
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 --- 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 #include "vt8500lcdfb.h" + +#ifdef CONFIG_FB_WMT_GE_ROPS #include "wmt_ge_rops.h" +#endif #ifdef CONFIG_OF #include @@ -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 #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
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 --- 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(>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, >dev); - if (!of_id) { - dev_err(>dev, "Failed to find gpio controller\n"); + if (!np) { + dev_err(>dev, "GPIO node missing in devicetree\n"); return -ENODEV; } - np = pdev->dev.of_node; - if (!np) { - dev_err(>dev, "Missing GPIO description in devicetree\n"); - return -EFAULT; + if (!of_id) { + dev_err(>dev, "No matching driver data\n"); + return -ENODEV; } gpio_base = of_iomap(np, 0); if (!gpio_base) { dev_err(>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, >dev); + + data = of_id->data; + + for (i = 0; i < data->num_banks; i++) { + ret = gpiochip_remove([i].chip); + if (ret) + dev_warn(>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
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 CC: Thomas Gleixner 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
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 --- CC: John Stultz CC: Thomas Gleixner 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 -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 - * Copyright (C) 2010 Alexey Charkov - * - * 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 -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#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_t
[PATCH 2/2] irqchip: vt8500: Move irq code to drivers/irqchip
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 --- CC: Thomas Gleixner 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 -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 - * Copyright (C) 2010 Alexey Charkov - * - * 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 -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#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)); - writel(status, stat_reg); - } else { - dctr = readb(base + VT8500_ICDC + d->hwirq); - dctr &= ~VT8500_INT_ENABLE; -
Re: [PATCH 2/2] irqchip: vt8500: Move irq code to drivers/irqchip
On Wed, 2013-01-02 at 22:38 -0600, Rob Herring wrote: > > CC: Thomas Gleixner > > 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/
[PATCH 4/4 v3] serial: tty: Cleanup code using devm_ function
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 --- 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(>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(>dev, "failed to get clock\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } ret = clk_prepare_enable(vt8500_port->clk); if (ret) { dev_err(>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(_uart_driver, _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 1/4 v3] serial: vt8500: Fix range-checking on vt8500_uart_ports
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 --- 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 v3] Fixes/cleanup for vt8500 serial
Hi Greg, This should be the final pull request for this series, unless there are other review comments. Changelog included. v2: 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. v3: Corrected the commit message for patch 3 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/cleanup for arch-vt8500 serial 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 2/4 v3] serial: vt8500: ioremap'd resource is never freed
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 -EADDRNOTAVAIL rather than -ENOMEM. Signed-off-by: Tony Prisk --- 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(>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 3/4 v3] serial: vt8500: UART uses gated clock rather than 24Mhz reference
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 --- 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 = <>; + enable-reg = <0x250>; + enable-bit = <1>; + }; + + clkuart1: uart1 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <>; + enable-reg = <0x250>; + enable-bit = <2>; + }; + + clkuart2: uart2 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <>; + enable-reg = <0x250>; + enable-bit = <3>; + }; + + clkuart3: uart3 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <>; + enable-reg = <0x250>; + enable-bit = <4>; + }; }; }; @@ -83,28 +115,28 @@ compatible = "via,vt8500-uart"; reg = <0xd820 0x1040>; interrupts = <32>; - clocks = <>; + clocks = <>; }; uart@d82b { compatible = "via,vt8500-uart"; reg = <0xd82b 0x1040>; interrupts = <33>; - clocks = <>; + clocks = <>; }; uart@d821 { compatible = "via,vt8500-uart"; reg = <0xd821 0x1040>; interrupts = <47>; - clocks = <>; + clocks = <>; }; uart@d82c { compatible = "via,vt8500-uart"; reg = <0xd82c 0x1040>; interrupts = <50>; - clocks = <>; + clocks = <>; }; 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 = <>; +
Re: [PATCH] tty: serial/vt8500_serial.c: fix bug caused by missing "{}"
On Wed, 2013-01-16 at 23:25 +0100, Cong Ding wrote: > It is obviously here should be braced by "{}" in the "if" branch (more than 1 > line in the "if" branch), and by the > coding style document of the kernel I also add "{}" to the else branch. > > Signed-off-by: Cong Ding > --- > drivers/tty/serial/vt8500_serial.c |5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/vt8500_serial.c > b/drivers/tty/serial/vt8500_serial.c > index 8fd1814..ac46a6e 100644 > --- a/drivers/tty/serial/vt8500_serial.c > +++ b/drivers/tty/serial/vt8500_serial.c > @@ -567,12 +567,13 @@ static int vt8500_serial_probe(struct platform_device > *pdev) > if (!mmres || !irqres) > return -ENODEV; > > - if (np) > + if (np) { > port = of_alias_get_id(np, "serial"); > if (port > VT8500_MAX_PORTS) > port = -1; > - else > + } else { > port = -1; > + } > > if (port < 0) { > /* calculate the port id */ Correct. This patch is good but unnecessary now as the patch series I pushed out removes this code anyway. It should be applied if the series I sent out is not accepted in this merge windows. 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 3/4 v4] serial: vt8500: UART uses gated clock rather than 24Mhz reference
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 --- 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 = <>; + enable-reg = <0x250>; + enable-bit = <1>; + }; + + clkuart1: uart1 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <>; + enable-reg = <0x250>; + enable-bit = <2>; + }; + + clkuart2: uart2 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <>; + enable-reg = <0x250>; + enable-bit = <3>; + }; + + clkuart3: uart3 { + #clock-cells = <0>; + compatible = "via,vt8500-device-clock"; + clocks = <>; + enable-reg = <0x250>; + enable-bit = <4>; + }; }; }; @@ -83,28 +115,28 @@ compatible = "via,vt8500-uart"; reg = <0xd820 0x1040>; interrupts = <32>; - clocks = <>; + clocks = <>; }; uart@d82b { compatible = "via,vt8500-uart"; reg = <0xd82b 0x1040>; interrupts = <33>; - clocks = <>; + clocks = <>; }; uart@d821 { compatible = "via,vt8500-uart"; reg = <0xd821 0x1040>; interrupts = <47>; - clocks = <>; + clocks = <>; }; uart@d82c { compatible = "via,vt8500-uart"; reg = <0xd82c 0x1040>; interrupts = <50>; - clocks = <>; + clocks = <>; }; 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 = <>; +
[PATCH RESEND] Fixes/Cleanup for vt8500 serial driver
Apologies Greg, Stupid mistake. This is a resend of the two patches you sent back as 'me being useless'. Tidied up now. 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 4/4 v4] serial: tty: Cleanup code using devm_ function
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 --- 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 1061e57..b834d99 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(>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(>dev, "failed to get clock\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } ret = clk_prepare_enable(vt8500_port->clk); if (ret) { dev_err(>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(_uart_driver, _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 v3] gpio: vt8500: memory cleanup missing
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 so the function is added. Signed-off-by: Tony Prisk --- v2: Remove global vtchip and store pointer in platform_data - As pointed out by Russell King. v3: Following problems pointed out by Grant Likely: 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(>dev, + priv = devm_kzalloc(>dev, sizeof(struct vt8500_data), GFP_KERNEL); + if (!priv) { + dev_err(>dev, "failed to allocate memory\n"); + return -ENOMEM; + } + + priv->chip = devm_kzalloc(>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(>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 = >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, >dev); if (!of_id) { - dev_err(>dev, "Failed to find gpio controller\n"); + dev_err(>dev, "No matching driver data\n"); return -ENODEV; } - np = pdev->dev.of_node; - if (!np) { - dev_err(>dev, "Missing GPIO description in devicetree\n"); - return -EFAULT; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(>dev, "Unable to get IO resource\n"); + return -ENODEV; } - gpio_base = of_iomap(np, 0); + gpio_base = devm_request_and_ioremap(>dev, res); if (!gpio_base) { dev_err(>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([i].chip); + if (ret) + dev_warn(>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",
Re: [PATCH 5/7] clk: vt8500: Use common of_clk_init() function
On Fri, 2013-01-18 at 09:56 -0800, Mike Turquette wrote: > Quoting Prashant Gaikwad (2013-01-03 23:00:56) > > Use common of_clk_init() function for clock initialization. > > > > Signed-off-by: Prashant Gaikwad > > Tony, > > Can I get a Tested-by from you before I take this in? > Tested-by: Tony Prisk FYI: This will need another patch to complete as we added another set of clocks to this clk-vt8500.c for 3.9. > Thanks, > Mike > > > --- > > drivers/clk/clk-vt8500.c | 15 --- > > 1 files changed, 4 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c > > index fe25570..3ce1c3e 100644 > > --- a/drivers/clk/clk-vt8500.c > > +++ b/drivers/clk/clk-vt8500.c > > @@ -272,7 +272,7 @@ static __init void vtwm_device_clk_init(struct > > device_node *node) > > rc = of_clk_add_provider(node, of_clk_src_simple_get, clk); > > clk_register_clkdev(clk, clk_name, NULL); > > } > > - > > +CLK_OF_DECLARE(vt8500_device, "via,vt8500-device-clock", > > vtwm_device_clk_init); > > > > /* PLL clock related functions */ > > > > @@ -502,20 +502,13 @@ static void __init vt8500_pll_init(struct device_node > > *node) > > { > > vtwm_pll_clk_init(node, PLL_TYPE_VT8500); > > } > > +CLK_OF_DECLARE(vt8500_pll, "via,vt8500-pll-clock", vt8500_pll_init); > > > > static void __init wm8650_pll_init(struct device_node *node) > > { > > vtwm_pll_clk_init(node, PLL_TYPE_WM8650); > > } > > - > > -static const __initconst struct of_device_id clk_match[] = { > > - { .compatible = "fixed-clock", .data = of_fixed_clk_setup, }, > > - { .compatible = "via,vt8500-pll-clock", .data = vt8500_pll_init, }, > > - { .compatible = "wm,wm8650-pll-clock", .data = wm8650_pll_init, }, > > - { .compatible = "via,vt8500-device-clock", > > - .data = vtwm_device_clk_init, }, > > - { /* sentinel */ } > > -}; > > +CLK_OF_DECLARE(wm8650_pll, "wm,wm8650-pll-clock", wm8650_pll_init); > > > > void __init vtwm_clk_init(void __iomem *base) > > { > > @@ -524,5 +517,5 @@ void __init vtwm_clk_init(void __iomem *base) > > > > pmc_base = base; > > > > - of_clk_init(clk_match); > > + of_clk_init(NULL); > > } > > -- > > 1.7.4.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/
[PATCH 3/4] video: vt8500: Remove unused platform_data/video-vt8500lcdfb.h
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 --- 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 d8cc1f6..1c34821 100644 --- a/drivers/video/vt8500lcdfb.c +++ b/drivers/video/vt8500lcdfb.c @@ -30,8 +30,6 @@ #include #include -#include - #include "vt8500lcdfb.h" #ifdef CONFIG_FB_WMT_GE_ROPS diff --git a/drivers/video/wm8505fb.c b/drivers/video/wm8505fb.c index dd28c26..8c8c129 100644 --- a/drivers/video/wm8505fb.c +++ b/drivers/video/wm8505fb.c @@ -32,8 +32,6 @@ #include #include -#include - #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 - * - * 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 - -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
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 --- 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 aa2579c..d8cc1f6 100644 --- a/drivers/video/vt8500lcdfb.c +++ b/drivers/video/vt8500lcdfb.c @@ -33,7 +33,10 @@ #include #include "vt8500lcdfb.h" + +#ifdef CONFIG_FB_WMT_GE_ROPS #include "wmt_ge_rops.h" +#endif #ifdef CONFIG_OF #include @@ -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 ddf78fc..dd28c26 100644 --- a/drivers/video/wm8505fb.c +++ b/drivers/video/wm8505fb.c @@ -35,7 +35,10 @@ #include #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 4/4] video: vt8500: Update descriptions in video/Kconfig
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 --- 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=. 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/
[GIT PULL] video: vt8500: Cleanup for 3.9
Hi Florian, This is a series of patches for the vt8500 framebuffer driver. Mostly cleanup stuff. Non-cleanup: video: vt8500: Make wmt_ge_rops optional - This patch makes hardware accelerated raster ops optional as it doesn't work on the newly added WM8850 (yet). Regards Tony Prisk The following changes since commit 7d1f9aeff1ee4a20b1aeb377dd0f579fe9647619: Linux 3.8-rc4 (2013-01-17 19:25:45 -0800) are available in the git repository at: git://server.prisktech.co.nz/git/linuxwmt.git tags/vt8500/video-3.9 for you to fetch changes up to 9167fe967de331a9457e1b4d4fc211857ba3b6ab: video: vt8500: Update descriptions in video/Kconfig (2013-01-19 18:52:28 +1300) video: vt8500: Cleanup for 3.9 Julia Lawall (1): drivers/video/wm8505fb.c: use devm_ functions Tony Prisk (3): video: vt8500: Make wmt_ge_rops optional video: vt8500: Remove unused platform_data/video-vt8500lcdfb.h video: vt8500: Update descriptions in video/Kconfig drivers/video/Kconfig | 32 drivers/video/vt8500lcdfb.c | 17 +++- drivers/video/wm8505fb.c| 95 --- include/linux/platform_data/video-vt8500lcdfb.h | 31 4 files changed, 67 insertions(+), 108 deletions(-) delete mode 100644 include/linux/platform_data/video-vt8500lcdfb.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 1/4] drivers/video/wm8505fb.c: use devm_ functions
From: Julia Lawall 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/): // @@ expression x,e; @@ x = devm_kzalloc(...) ... when != x = e ?-kfree(x,...); // 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 Signed-off-by: Tony Prisk --- 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 4dd0580..ddf78fc 100644 --- a/drivers/video/wm8505fb.c +++ b/drivers/video/wm8505fb.c @@ -274,15 +274,11 @@ static int wm8505fb_probe(struct platform_device *pdev) unsigned long fb_mem_len; void *fb_mem_virt; - ret = -ENOMEM; - fbi = NULL; - fbi = devm_kzalloc(>dev, sizeof(struct wm8505fb_info) + sizeof(u32) * 16, GFP_KERNEL); if (!fbi) { dev_err(>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 wm8505fb_probe(struct platform_device *pdev) fbi->fb.pseudo_palette = addr; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res == NULL) { - dev_err(>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(>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(>dev, "failed to map I/O memory\n"); - ret = -EBUSY; - goto failed_free_res; - } + fbi->regbase = devm_request_and_ioremap(>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 wm8505fb_probe(struct platform_device *pdev) ret |= of_property_read_u32(np, "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 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(>dev, fb_mem_len, _mem_phys, + fb_mem_virt = dmam_alloc_coherent(>dev, fb_mem_len, _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 wm8505fb_probe(struct platform_device *pdev)
[PATCH] rtc: vt8500: Fix year field in vt8500_rtc_set_time
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 Signed-off-by: Tony Prisk --- Hi Andrew, This patch has been floating around since -rc1, but looks like it may have been missed. I have rebased it onto -rc4 to make applying it easier. Trivial fix. Regards Tony P 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 00c930f..2730533 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 + 1) << DATE_MONTH_S) | (bin2bcd(tm->tm_mday)) | ((tm->tm_year >= 200) << DATE_CENTURY_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] dts: vt8500: Add initial dts support for WM8850
This patch adds a soc dtsi for the Wondermedia WM8850. A board dts file is also included for the W70v2 tablet, with support for all the drivers currently in mainline. Signed-off-by: Tony Prisk --- Hi Olof, Sorry this is a bit late. Regards Tony P arch/arm/boot/dts/Makefile |3 +- arch/arm/boot/dts/wm8850-w70v2.dts | 47 arch/arm/boot/dts/wm8850.dtsi | 224 3 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 arch/arm/boot/dts/wm8850-w70v2.dts create mode 100644 arch/arm/boot/dts/wm8850.dtsi diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index 5ebb44f..8a75991 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -151,7 +151,8 @@ dtb-$(CONFIG_ARCH_VEXPRESS) += vexpress-v2p-ca5s.dtb \ xenvm-4.2.dtb dtb-$(CONFIG_ARCH_VT8500) += vt8500-bv07.dtb \ wm8505-ref.dtb \ - wm8650-mid.dtb + wm8650-mid.dtb \ + wm8850-w70v2.dtb dtb-$(CONFIG_ARCH_ZYNQ) += zynq-zc702.dtb targets += dtbs diff --git a/arch/arm/boot/dts/wm8850-w70v2.dts b/arch/arm/boot/dts/wm8850-w70v2.dts new file mode 100644 index 000..fcc660c --- /dev/null +++ b/arch/arm/boot/dts/wm8850-w70v2.dts @@ -0,0 +1,47 @@ +/* + * wm8850-w70v2.dts + * - Device tree file for Wondermedia WM8850 Tablet + * - 'W70-V2' mainboard + * - HongLianYing 'HLY070ML268-21A' 7" LCD panel + * + * Copyright (C) 2012 Tony Prisk + * + * Licensed under GPLv2 or later + */ + +/dts-v1/; +/include/ "wm8850.dtsi" + +/ { + model = "Wondermedia WM8850-W70v2 Tablet"; + + /* +* Display node is based on Sascha Hauer's patch on dri-devel. +* Added a bpp property to calculate the size of the framebuffer +* until the binding is formalized. +*/ + display: display@0 { + modes { + mode0: mode@0 { + hactive = <800>; + vactive = <480>; + hback-porch = <88>; + hfront-porch = <40>; + hsync-len = <0>; + vback-porch = <32>; + vfront-porch = <11>; + vsync-len = <1>; + clock = <0>;/* unused but required */ + bpp = <16>; /* non-standard but required */ + }; + }; + }; + + backlight { + compatible = "pwm-backlight"; + pwms = < 0 5 1>;/* duty inverted */ + + brightness-levels = <0 40 60 80 100 130 190 255>; + default-brightness-level = <5>; + }; +}; diff --git a/arch/arm/boot/dts/wm8850.dtsi b/arch/arm/boot/dts/wm8850.dtsi new file mode 100644 index 000..2dbc39c --- /dev/null +++ b/arch/arm/boot/dts/wm8850.dtsi @@ -0,0 +1,224 @@ +/* + * wm8850.dtsi - Device tree file for Wondermedia WM8850 SoC + * + * Copyright (C) 2012 Tony Prisk + * + * Licensed under GPLv2 or later + */ + +/include/ "skeleton.dtsi" + +/ { + compatible = "wm,wm8850"; + + aliases { + serial0 = + serial1 = + serial2 = + serial3 = + }; + + soc { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges; + interrupt-parent = <>; + + intc0: interrupt-controller@d814 { + compatible = "via,vt8500-intc"; + interrupt-controller; + reg = <0xd814 0x1>; + #interrupt-cells = <1>; + }; + + /* Secondary IC cascaded to intc0 */ + intc1: interrupt-controller@d815 { + compatible = "via,vt8500-intc"; + interrupt-controller; + #interrupt-cells = <1>; + reg = <0xD815 0x1>; + interrupts = <56 57 58 59 60 61 62 63>; + }; + + gpio: gpio-controller@d811 { + compatible = "wm,wm8650-gpio"; + gpio-controller; + reg = <0xd811 0x1>; + #gpio-cells = <3>; + }; + + pmc@d813 { + compatible = "via,vt8500-pmc"; + reg = <0xd813 0x1000>; + + clocks { + #address-cells = <1>; + #size-cel
[RFC PATCH] Add pin control driver for Wondermedia SoCS
Before I get all carried away and start filling in all the data for this driver, I was hoping someone (or a few people) could review the basic design in case it requires changes to the data structures. This driver is based on pinctrl-bcm2835.c as it seems to be similar in design. The pin controller on Wondermedia SoC's only allows each pin to either be a GPIO or to be its 'alternate' function. Functions cannot be remapped to any other pin. I have seperated out the data from the code as there are several SoC's to support and each has it's own variation of registers / pin layout. I borrowed this part of the design from the Tegra pinctrl driver. Regards Tony Prisk Tony Prisk (1): pinctrl: gpio: vt8500: Add pin control driver for Wondermedia SoCs arch/arm/Kconfig |4 +- arch/arm/boot/dts/wm8850-w70v2.dts | 15 + arch/arm/boot/dts/wm8850.dtsi |7 +- arch/arm/mach-vt8500/Kconfig |1 + drivers/pinctrl/Kconfig| 10 + drivers/pinctrl/Makefile |2 + drivers/pinctrl/pinctrl-wm8850.c | 166 +++ drivers/pinctrl/pinctrl-wmt.c | 565 drivers/pinctrl/pinctrl-wmt.h | 73 + 9 files changed, 840 insertions(+), 3 deletions(-) create mode 100644 drivers/pinctrl/pinctrl-wm8850.c create mode 100644 drivers/pinctrl/pinctrl-wmt.c create mode 100644 drivers/pinctrl/pinctrl-wmt.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] pinctrl: gpio: vt8500: Add pin control driver for Wondermedia SoCs
Signed-off-by: Tony Prisk --- arch/arm/Kconfig |4 +- arch/arm/boot/dts/wm8850-w70v2.dts | 15 + arch/arm/boot/dts/wm8850.dtsi |7 +- arch/arm/mach-vt8500/Kconfig |1 + drivers/pinctrl/Kconfig| 10 + drivers/pinctrl/Makefile |2 + drivers/pinctrl/pinctrl-wm8850.c | 166 +++ drivers/pinctrl/pinctrl-wmt.c | 565 drivers/pinctrl/pinctrl-wmt.h | 73 + 9 files changed, 840 insertions(+), 3 deletions(-) create mode 100644 drivers/pinctrl/pinctrl-wm8850.c create mode 100644 drivers/pinctrl/pinctrl-wmt.c create mode 100644 drivers/pinctrl/pinctrl-wmt.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 31fe86d..0240340 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1618,10 +1618,10 @@ config LOCAL_TIMERS config ARCH_NR_GPIO int default 1024 if ARCH_SHMOBILE || ARCH_TEGRA + default 512 if SOC_OMAP5 default 355 if ARCH_U8500 + default 352 if ARCH_VT8500 default 264 if MACH_H4700 - default 512 if SOC_OMAP5 - default 288 if ARCH_VT8500 default 0 help Maximum number of GPIOs in the system. diff --git a/arch/arm/boot/dts/wm8850-w70v2.dts b/arch/arm/boot/dts/wm8850-w70v2.dts index d7d5a1d..64b6c6b 100644 --- a/arch/arm/boot/dts/wm8850-w70v2.dts +++ b/arch/arm/boot/dts/wm8850-w70v2.dts @@ -52,3 +52,18 @@ keymap = <116>; /* KEY_POWER */ }; }; + + { + pinctrl-names = "default"; + pinctrl-0 = < >; + + i2c: i2c { + wm,pins = <168 169 170 171 172 173>; + wm,function = <2>; /* alt */ + }; + + sdmmc: sdmmc { + wm,pins = <113 114 115 116 117 118 119>; + wm,function = <2>; /* alt */ + }; +}; diff --git a/arch/arm/boot/dts/wm8850.dtsi b/arch/arm/boot/dts/wm8850.dtsi index ba85056..add9e6f 100644 --- a/arch/arm/boot/dts/wm8850.dtsi +++ b/arch/arm/boot/dts/wm8850.dtsi @@ -39,13 +39,18 @@ reg = <0xD815 0x1>; interrupts = <56 57 58 59 60 61 62 63>; }; - +/* gpio: gpio-controller@d811 { compatible = "wm,wm8650-gpio"; gpio-controller; reg = <0xd811 0x1>; #gpio-cells = <3>; }; +*/ + pinmux: pinmux@d811 { + compatible = "wm,wm8850-gpio"; + reg = <0xd811 0x1>; + }; pmc@d813 { compatible = "via,vt8500-pmc"; diff --git a/arch/arm/mach-vt8500/Kconfig b/arch/arm/mach-vt8500/Kconfig index 747aa14..06ee9a3 100644 --- a/arch/arm/mach-vt8500/Kconfig +++ b/arch/arm/mach-vt8500/Kconfig @@ -29,5 +29,6 @@ config ARCH_WM8850 depends on ARCH_MULTI_V7 select ARCH_VT8500 select CPU_V7 + select PINCTRL help Support for WonderMedia WM8850 System-on-Chip. diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index a5f3c8c..7ad3669 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -170,6 +170,16 @@ config PINCTRL_U300 select PINMUX select GENERIC_PINCONF +config PINCTRL_WMT + bool + select PINMUX + select PINCONF + +config PINCTRL_WM8850 + bool "Wondermedia WM8850 pin controller driver" + depends on ARCH_VT8500 + select PINCTRL_WMT + config PINCTRL_COH901 bool "ST-Ericsson U300 COH 901 335/571 GPIO" depends on GPIOLIB && ARCH_U300 && PINCTRL_U300 diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile index 6e87e52..a983ba4 100644 --- a/drivers/pinctrl/Makefile +++ b/drivers/pinctrl/Makefile @@ -34,6 +34,8 @@ obj-$(CONFIG_PINCTRL_TEGRA) += pinctrl-tegra.o obj-$(CONFIG_PINCTRL_TEGRA20) += pinctrl-tegra20.o obj-$(CONFIG_PINCTRL_TEGRA30) += pinctrl-tegra30.o obj-$(CONFIG_PINCTRL_U300) += pinctrl-u300.o +obj-$(CONFIG_PINCTRL_WMT) += pinctrl-wmt.o +obj-$(CONFIG_PINCTRL_WM8850) += pinctrl-wm8850.o obj-$(CONFIG_PINCTRL_COH901) += pinctrl-coh901.o obj-$(CONFIG_PINCTRL_SAMSUNG) += pinctrl-samsung.o obj-$(CONFIG_PINCTRL_EXYNOS) += pinctrl-exynos.o diff --git a/drivers/pinctrl/pinctrl-wm8850.c b/drivers/pinctrl/pinctrl-wm8850.c new file mode 100644 index 000..eec3277 --- /dev/null +++ b/drivers/pinctrl/pinctrl-wm8850.c @@ -0,0 +1,166 @@ +/* + * Pinctrl data for WM8850 SoC + * + * Copyright (c) 2013 Tony Prisk + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in
Re: [PATCH] arm, vt8500, LLVMLlinux: Use mcr instead of mcr% for mach-vt8500
On 24/09/14 21:16, Arnd Bergmann wrote: On Tuesday 23 September 2014 20:44:44 Behan Webster wrote: The ASM below does not compile with clang and is not the way that the mcr command is used in other parts of the kernel. arch/arm/mach-vt8500/vt8500.c:72:11: error: invalid % escape in inline assembly string asm("mcr%? p15, 0, %0, c7, c0, 4" : : "r" (0)); ~^~~~ 1 error generated. There are other forms that are supported on different ARM instruction sets but generally the kernel just uses mcr as it is supported in all ARM instruction sets. Just for confirm: both forms are actually correct and we don't need this backported for stable, right? Signed-off-by: Behan Webster Reviewed-by: Mark Charlebois Acked-by: Will Deacon Acked-by: Arnd Bergmann Tony, would you like to pick this one up and send it in a pull request to arm-soc, or should we apply it to fixes-non-critical directly? Arnd Arnd, You can apply it directly to fixes-non-critical if that's ok. 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
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 --- .../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 : 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 = <>; + 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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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_MODE
[PATCH v3] i2c: vt8500: Add support for I2C bus on Wondermedia SoCs
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 --- 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 : 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 = <>; + 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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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
Re: [PATCH] pinctrl: vt8500: Ensure value reg is updated when setting direction
On 30/04/14 07:42, Alexey Charkov wrote: Current code only touches the direction register when setting direction to output, which breaks logic like echo high > /sys/class/gpio/gpio0/direction which is expected to also set the value. This patch also adds a call to update the value register when setting direction to output. Signed-off-by: Alexey Charkov --- drivers/pinctrl/vt8500/pinctrl-wmt.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c index 9802b67..2c61281 100644 --- a/drivers/pinctrl/vt8500/pinctrl-wmt.c +++ b/drivers/pinctrl/vt8500/pinctrl-wmt.c @@ -523,17 +523,6 @@ static int wmt_gpio_get_direction(struct gpio_chip *chip, unsigned offset) return GPIOF_DIR_IN; } -static int wmt_gpio_direction_input(struct gpio_chip *chip, unsigned offset) -{ - return pinctrl_gpio_direction_input(chip->base + offset); -} - -static int wmt_gpio_direction_output(struct gpio_chip *chip, unsigned offset, -int value) -{ - return pinctrl_gpio_direction_output(chip->base + offset); -} - static int wmt_gpio_get_value(struct gpio_chip *chip, unsigned offset) { struct wmt_pinctrl_data *data = dev_get_drvdata(chip->dev); @@ -568,6 +557,18 @@ static void wmt_gpio_set_value(struct gpio_chip *chip, unsigned offset, wmt_clearbits(data, reg_data_out, BIT(bit)); } +static int wmt_gpio_direction_input(struct gpio_chip *chip, unsigned offset) +{ + return pinctrl_gpio_direction_input(chip->base + offset); +} + +static int wmt_gpio_direction_output(struct gpio_chip *chip, unsigned offset, +int value) +{ + wmt_gpio_set_value(chip, offset, value); + return pinctrl_gpio_direction_output(chip->base + offset); +} + static struct gpio_chip wmt_gpio_chip = { .label = "gpio-wmt", .owner = THIS_MODULE, Acked-by: Tony Prisk Didn't notice that this was an option in the gpio documentation but it makes obvious sense. 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/