ARM: Add basic architecture support for VIA/WonderMedia 85xx SoC's
Subsystems (10)
Alexey Charkov
maintainerPATCH v2 1/6 ARM: Add basic architecture support for VIA/WonderMedia 85xx SoC's
This adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505. Suitable code is selected (if compiled in) at early initialization time by reading a platform-specific identification register, as current bootloaders do not provide any reliable machine id to the kernel.
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
---
Please review and (if appropriate) commit to a relevant git tree for further integration in 2.6.38.
Compared to the previous submissions, this code introduces boot-time determintaion of SoC version (instead of just compile-time preselection), boot-argument override for the LCD panel size (used when preallocating frame buffer memory), better guesses for PCI I/O space configuration (thanks to Arnd Bergmann for suggestions), as well as a rebase against the latest changes introduced in 2.6.37 merge window.
Due credits go to the community for providing feedback, advice and testing for the code in this patch and follow-ups.
arch/arm/Kconfig | 14 + arch/arm/Makefile | 1 + arch/arm/boot/compressed/Makefile | 4 + arch/arm/boot/compressed/head-vt8500.S | 46 +++ arch/arm/mach-vt8500/Kconfig | 65 ++++ arch/arm/mach-vt8500/Makefile | 6 + arch/arm/mach-vt8500/Makefile.boot | 3 + arch/arm/mach-vt8500/bv07.c | 70 ++++ arch/arm/mach-vt8500/devices.c | 429 +++++++++++++++++++++++ arch/arm/mach-vt8500/devices.h | 43 +++ arch/arm/mach-vt8500/gpio.c | 230 ++++++++++++ arch/arm/mach-vt8500/include/mach/debug-macro.S | 31 ++ arch/arm/mach-vt8500/include/mach/entry-macro.S | 32 ++ arch/arm/mach-vt8500/include/mach/gpio.h | 6 + arch/arm/mach-vt8500/include/mach/hardware.h | 12 + arch/arm/mach-vt8500/include/mach/io.h | 28 ++ arch/arm/mach-vt8500/include/mach/irq_defs.h | 124 +++++++ arch/arm/mach-vt8500/include/mach/irqs.h | 22 ++ arch/arm/mach-vt8500/include/mach/memory.h | 28 ++ arch/arm/mach-vt8500/include/mach/mmio_regs.h | 90 +++++ arch/arm/mach-vt8500/include/mach/system.h | 18 + arch/arm/mach-vt8500/include/mach/timex.h | 26 ++ arch/arm/mach-vt8500/include/mach/uncompress.h | 37 ++ arch/arm/mach-vt8500/include/mach/vmalloc.h | 20 + arch/arm/mach-vt8500/include/mach/vt8500fb.h | 31 ++ arch/arm/mach-vt8500/irq.c | 168 +++++++++ arch/arm/mach-vt8500/irq_defs.c | 173 +++++++++ arch/arm/mach-vt8500/mmio_regs.c | 118 +++++++ arch/arm/mach-vt8500/pwm.c | 254 ++++++++++++++ arch/arm/mach-vt8500/timer.c | 166 +++++++++ arch/arm/mach-vt8500/wm8505_7in.c | 69 ++++ 31 files changed, 2364 insertions(+), 0 deletions(-) create mode 100644 arch/arm/boot/compressed/head-vt8500.S create mode 100644 arch/arm/mach-vt8500/Kconfig create mode 100644 arch/arm/mach-vt8500/Makefile create mode 100644 arch/arm/mach-vt8500/Makefile.boot create mode 100644 arch/arm/mach-vt8500/bv07.c create mode 100644 arch/arm/mach-vt8500/devices.c create mode 100644 arch/arm/mach-vt8500/devices.h create mode 100644 arch/arm/mach-vt8500/gpio.c create mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/entry-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/gpio.h create mode 100644 arch/arm/mach-vt8500/include/mach/hardware.h create mode 100644 arch/arm/mach-vt8500/include/mach/io.h create mode 100644 arch/arm/mach-vt8500/include/mach/irq_defs.h create mode 100644 arch/arm/mach-vt8500/include/mach/irqs.h create mode 100644 arch/arm/mach-vt8500/include/mach/memory.h create mode 100644 arch/arm/mach-vt8500/include/mach/mmio_regs.h create mode 100644 arch/arm/mach-vt8500/include/mach/system.h create mode 100644 arch/arm/mach-vt8500/include/mach/timex.h create mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h create mode 100644 arch/arm/mach-vt8500/include/mach/vmalloc.h create mode 100644 arch/arm/mach-vt8500/include/mach/vt8500fb.h create mode 100644 arch/arm/mach-vt8500/irq.c create mode 100644 arch/arm/mach-vt8500/irq_defs.c create mode 100644 arch/arm/mach-vt8500/mmio_regs.c create mode 100644 arch/arm/mach-vt8500/pwm.c create mode 100644 arch/arm/mach-vt8500/timer.c create mode 100644 arch/arm/mach-vt8500/wm8505_7in.c
arch/arm/Kconfig +14 -0
@@ -843,6 +843,18 @@ config PLAT_SPEAR help Support for ST's SPEAr platform (SPEAr3xx, SPEAr6xx and SPEAr13xx). +config ARCH_VT8500 + bool "VIA/WonderMedia 85xx" + select CPU_ARM926T + select GENERIC_GPIO + select ARCH_HAS_CPUFREQ + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select HAVE_CLK + select HAVE_PWM + help + Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. endchoice #
@@ -973,6 +985,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vexpress/Kconfig" +source "arch/arm/mach-vt8500/Kconfig" + source "arch/arm/mach-w90x900/Kconfig" # Definitions to make life easier
arch/arm/Makefile +1 -0
@@ -189,6 +189,7 @@ machine-$(CONFIG_ARCH_U300) := u300 machine-$(CONFIG_ARCH_U8500) := ux500 machine-$(CONFIG_ARCH_VERSATILE) := versatile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress +machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x machine-$(CONFIG_FOOTBRIDGE) := footbridge
arch/arm/boot/compressed/Makefile +4 -0
@@ -29,6 +29,10 @@ ifeq ($(CONFIG_ARCH_SA1100),y) OBJS += head-sa1100.o endif +ifeq ($(CONFIG_ARCH_VT8500),y) +OBJS += head-vt8500.o +endif + ifeq ($(CONFIG_CPU_XSCALE),y) OBJS += head-xscale.o endif
arch/arm/boot/compressed/head-vt8500.S new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/Kconfig new file +65 -0
65 lines not on this page · raw message
arch/arm/mach-vt8500/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +obj-y += devices.o gpio.o irq.o irq_defs.o mmio_regs.o timer.o + +obj-$(CONFIG_MACH_BV07) += bv07.o +obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o + +obj-$(CONFIG_HAVE_PWM) += pwm.o
arch/arm/mach-vt8500/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x01000000
arch/arm/mach-vt8500/bv07.c new file +70 -0
70 lines not on this page · raw message
arch/arm/mach-vt8500/devices.c new file +429 -0
429 lines not on this page · raw message
arch/arm/mach-vt8500/devices.h new file +43 -0
43 lines not on this page · raw message
arch/arm/mach-vt8500/gpio.c new file +230 -0
230 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/debug-macro.S new file +31 -0
@@ -0,0 +1,31 @@ +/* + * arch/arm/mach-vt8500/include/mach/debug-macro.S + * + * Copyright (C) 2010 Alexey Charkov <[email protected]> + * + * 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 + mov \rp, #0x00200000 + orr \rv, \rp, #0xf8000000 + orr \rp, \rp, #0xd8000000 + .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
arch/arm/mach-vt8500/include/mach/entry-macro.S new file +32 -0
@@ -0,0 +1,32 @@ +/* + * arch/arm/mach-vt8500/include/mach/entry-macro.S + * + * Low-level IRQ helper macros for VIA VT8500 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_preamble, base, tmp + @ physical 0xd8140000 is virtual 0xf8140000 + mov \base, #0xf8000000 + orr \base, \base, #0x00140000 + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #63 @ may be false positive, check interrupt status + bne 1001f + ldr \irqstat, [\base, #0x84] + ands \irqstat, #0x80000000 + moveq \irqnr, #0 +1001: + .endm +
arch/arm/mach-vt8500/include/mach/gpio.h new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm-generic/gpio.h> + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq __gpio_to_irq
arch/arm/mach-vt8500/include/mach/hardware.h new file +12 -0
@@ -0,0 +1,12 @@ +/* arch/arm/mach-vt8500/include/mach/hardware.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. +* +*/
arch/arm/mach-vt8500/include/mach/io.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/io.h +* +* 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 +*/ +#ifndef __ASM_ARM_ARCH_IO_H +#define __ASM_ARM_ARCH_IO_H + +#define IO_SPACE_LIMIT 0xffff + +#define __io (a) ((void __iomem *)((a) + 0xf0000000)) +#define __mem_pci (a) (a) + +#endif
arch/arm/mach-vt8500/include/mach/irq_defs.h new file +124 -0
124 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/irqs.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* arch/arm/mach-vt8500/include/mach/irqs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 value is just to make the core happy, never used otherwise */ +#define NR_IRQS 128
arch/arm/mach-vt8500/include/mach/memory.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/memory.h +* +* Copyright (C) 2003 ARM Limited +* +* 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 __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET UL(0x00000000) + +#endif
arch/arm/mach-vt8500/include/mach/mmio_regs.h new file +90 -0
90 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/system.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* arch/arm/mach-vt8500/include/mach/system.h +* +*/ +#include <asm/io.h> + +/* PM Software Reset request register */ +#define VT8500_PMSR 0xd8130060 + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +writel (1 ,ioremap (VT8500_PMSR ,4 )); +}
arch/arm/mach-vt8500/include/mach/timex.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* arch/arm/mach-vt8500/include/mach/timex.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 (3000000) + +#endif /* MACH_TIMEX_H */
arch/arm/mach-vt8500/include/mach/uncompress.h new file +37 -0
@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 0xd8200000 +#include <asm/io.h> + +static void putc (const char c) +{ +while (readb (UART0_PHYS +0x1c ) &0x2 ) +/* Tx busy, wait and poll */ ; + +writeb (c,UART0_PHYS ); +} + +static void flush (void ) +{ +} + +/* +* nothing to do +*/ +#define arch_decomp_setup () +#define arch_decomp_wdog ()
arch/arm/mach-vt8500/include/mach/vmalloc.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/vmalloc.h +* +* Copyright (C) 2000 Russell King. +* +* 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 +*/ +#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* VT8500/WM8505 Frame Buffer platform data definitions +* +* Copyright (C) 2010 Ed Spiridonov <[email protected]> +* +* 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 */
arch/arm/mach-vt8500/irq.c new file +168 -0
168 lines not on this page · raw message
arch/arm/mach-vt8500/irq_defs.c new file +173 -0
173 lines not on this page · raw message
arch/arm/mach-vt8500/mmio_regs.c new file +118 -0
118 lines not on this page · raw message
arch/arm/mach-vt8500/pwm.c new file +254 -0
254 lines not on this page · raw message
arch/arm/mach-vt8500/timer.c new file +166 -0
166 lines not on this page · raw message
arch/arm/mach-vt8500/wm8505_7in.c new file +69 -0
69 lines not on this page · raw message
Signature · 1 line
1.7.3.2
Alexey Charkov
maintainerPATCH v2 2/6 serial: Add support for UART on VIA VT8500 and compatibles
This adds a driver for the serial ports found in VIA and WonderMedia Systems-on-Chip. Interrupt-driven FIFO operation is implemented. The hardware also supports pure register-based operation (which is slower) and DMA-based FIFO operation. As the FIFOs are only 16 bytes long, DMA operation is probably not worth the hassle.
---
Please review and (if appropriate) commit to a relevant git tree for further integration in 2.6.38.
Compared to the previous submission, this code just contains a rebase against the latest changes introduced in 2.6.37 merge window.
Relevant platform definitions are introduced by PATCH 1/6 in this series, so one would need that to make use of this code.
Due credits go to the community for providing feedback, advice and testing.
drivers/serial/Kconfig | 10 + drivers/serial/Makefile | 1 + drivers/serial/vt8500_serial.c | 637 ++++++++++++++++++++++++++++++++++++++++ include/linux/serial_core.h | 3 + 4 files changed, 651 insertions(+), 0 deletions(-) create mode 100644 drivers/serial/vt8500_serial.c
drivers/serial/Kconfig +10 -0
@@ -1381,6 +1381,16 @@ config SERIAL_MSM_CONSOLE depends on SERIAL_MSM=y select SERIAL_CORE_CONSOLE +config SERIAL_VT8500 + bool "VIA VT8500 on-chip serial port support" + depends on ARM && ARCH_VT8500 + select SERIAL_CORE + +config SERIAL_VT8500_CONSOLE + bool "VIA VT8500 serial console support" + depends on SERIAL_VT8500=y + select SERIAL_CORE_CONSOLE + config SERIAL_NETX tristate "NetX serial port support" depends on ARM && ARCH_NETX
drivers/serial/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-$(CONFIG_SERIAL_TIMBERDALE) += timbuart.o obj-$(CONFIG_SERIAL_GRLIB_GAISLER_APBUART) += apbuart.o obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o +obj-$(CONFIG_SERIAL_VT8500) += vt8500_serial.o obj-$(CONFIG_SERIAL_MRST_MAX3110) += mrst_max3110.o obj-$(CONFIG_SERIAL_MFD_HSU) += mfd.o obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
drivers/serial/vt8500_serial.c new file +637 -0
637 lines not on this page · raw message
include/linux/serial_core.h +3 -0
@@ -199,6 +199,9 @@/* TI OMAP-UART */ #define PORT_OMAP 96 +/* VIA VT8500 SoC */ +#define PORT_VT8500 97 +#ifdef __KERNEL__#include <linux/compiler.h>
Signature · 1 line
1.7.3.2
Re: [PATCH 2/6 v2] serial: Add support for UART on VIA VT8500 and compatibles
drivers/serial/vt8500_serial.c line 131
Quoted 5 lines
drivers/serial/vt8500_serial.c new file +3
-0+static void handle_rx (struct uart_port *port) +{ +struct tty_struct *tty = port->state->port.tty;
What is your locking for this versus a hangup ? - tty can go NULL ?
(use tty_port_tty_get/tty_kref_put)
drivers/serial/vt8500_serial.c line 280
Quoted 13 lines
+static int
vt8500_set_baud_rate(struct uart_port *port, unsigned int baud)+{drivers/serial/vt8500_serial.c new file +11
-0+unsigned long div; + + div =vt8500_read (port,VT8500_URDIV ) & ~(0x3ff ); + +if (unlikely ((baud <900 ) || (baud >921600 ))) + div |=7 ; +else + div |= (921600 / baud) -1 ; + +while (vt8500_read (port,VT8500_URUSR ) & (1 <<5 )) + ;
cpu_relax() and needs a timeout ideally ?
Quoted 7 lines
drivers/serial/vt8500_serial.c new file +7
-0+ lcr =vt8500_read (&vt8500_port->uart,VT8500_URLCR ); + lcr &= ~((1 <<5 ) | (1 <<4 )); +if (termios->c_cflag &PARENB ) { + lcr |= (1 <<4 ); +if (termios->c_cflag &PARODD ) + lcr |= (1 <<5 ); + }
drivers/serial/vt8500_serial.c line 352
Quoted 10 lines
drivers/serial/vt8500_serial.c new file +10
-0+ +/* calculate bits per char */ + lcr &= ~(1 <<2 ); +switch (termios->c_cflag &CSIZE ) { +case CS7 : +break ; +case CS8 : +default : + lcr |= (1 <<2 ); +break ;
If you don't support other CS values then also do
termios->c_flag &=~CSIZE; termios->c_cflag |= CS8;
here.. so the app knows,
likewise if you don't support mark/space (CMSPAR) then clear the CMSPAR bit
drivers/serial/vt8500_serial.c line 373
Quoted 3 lines
drivers/serial/vt8500_serial.c new file +3
-0+vt8500_write (&vt8500_port->uart,0x88c ,VT8500_URFCR ); +while (vt8500_read (&vt8500_port->uart,VT8500_URFCR ) &0xc ) +/* Wait for the reset to complete */ ;
cpu_relax/timeout
drivers/serial/vt8500_serial.c line 492
Quoted 2 lines
drivers/serial/vt8500_serial.c new file +2
-0+static struct console vt8500_console = { + .name ="ttyS" ,
ttyS is the 8250 style devices
drivers/serial/vt8500_serial.c line 531
Quoted 3 lines
drivers/serial/vt8500_serial.c new file +3
-0+ .dev_name = "ttyS", + .major = 4, + .minor = 64,
These major/minors belong to an existing device - use new ones, or in fact unless they must be fixed use dynamic ones.
If they need fixed ones then we probably want to assign four from the range for small ports.
);
drivers/serial/vt8500_serial.c line 618
Quoted 5 lines
drivers/serial/vt8500_serial.c new file +5
-0+ +if (unlikely (ret)) +uart_unregister_driver (&vt8500_uart_driver); + +printk (KERN_INFO "vt8500_serial: driver initialized\n" );
The world really doesn't need to know about each driver being loaded. pr_debug() should be fine
Looks pretty good.
Alexey Charkov
maintainerPATCH v3 2/6 serial: Add support for UART on VIA VT8500 and compatibles
This adds a driver for the serial ports found in VIA and WonderMedia Systems-on-Chip. Interrupt-driven FIFO operation is implemented. The hardware also supports pure register-based operation (which is slower) and DMA-based FIFO operation. As the FIFOs are only 16 bytes long, DMA operation is probably not worth the hassle.
---
Thanks for the comments, Alan! Hopefully, I've fixed the issues in a right way.
Best regards,
Alexey
drivers/serial/Kconfig | 10 + drivers/serial/Makefile | 1 + drivers/serial/vt8500_serial.c | 647 ++++++++++++++++++++++++++++++++++++++++ include/linux/serial_core.h | 3 + 4 files changed, 661 insertions(+), 0 deletions(-) create mode 100644 drivers/serial/vt8500_serial.c
drivers/serial/Kconfig +10 -0
@@ -1381,6 +1381,16 @@ config SERIAL_MSM_CONSOLE depends on SERIAL_MSM=y select SERIAL_CORE_CONSOLE +config SERIAL_VT8500 + bool "VIA VT8500 on-chip serial port support" + depends on ARM && ARCH_VT8500 + select SERIAL_CORE + +config SERIAL_VT8500_CONSOLE + bool "VIA VT8500 serial console support" + depends on SERIAL_VT8500=y + select SERIAL_CORE_CONSOLE + config SERIAL_NETX tristate "NetX serial port support" depends on ARM && ARCH_NETX
drivers/serial/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-$(CONFIG_SERIAL_TIMBERDALE) += timbuart.o obj-$(CONFIG_SERIAL_GRLIB_GAISLER_APBUART) += apbuart.o obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o +obj-$(CONFIG_SERIAL_VT8500) += vt8500_serial.o obj-$(CONFIG_SERIAL_MRST_MAX3110) += mrst_max3110.o obj-$(CONFIG_SERIAL_MFD_HSU) += mfd.o obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
drivers/serial/vt8500_serial.c new file +647 -0
647 lines not on this page · raw message
include/linux/serial_core.h +3 -0
@@ -199,6 +199,9 @@/* TI OMAP-UART */ #define PORT_OMAP 96 +/* VIA VT8500 SoC */ +#define PORT_VT8500 97 +#ifdef __KERNEL__#include <linux/compiler.h>
Signature · 1 line
1.7.3.2
Re: [PATCH 2/6 v3] serial: Add support for UART on VIA VT8500 and compatibles
drivers/serial/vt8500_serial.c line 507
Quoted 3 lines
drivers/serial/vt8500_serial.c new file +2
-0+static struct console vt8500_console = { + .name ="ttyS" ,
You missed a ttyS
Otherwise looks great.
Alan
Alexey Charkov
maintainerPATCH v4 2/6 serial: Add support for UART on VIA VT8500 and compatibles
This adds a driver for the serial ports found in VIA and WonderMedia Systems-on-Chip. Interrupt-driven FIFO operation is implemented. The hardware also supports pure register-based operation (which is slower) and DMA-based FIFO operation. As the FIFOs are only 16 bytes long, DMA operation is probably not worth the hassle.
---
This fixes the last remaining "ttyS" mentioned by Alan and also adds 6 as the number of UARTs (which is the case for WM8505, VT8500 has 4).
drivers/serial/Kconfig | 10 + drivers/serial/Makefile | 1 + drivers/serial/vt8500_serial.c | 648 ++++++++++++++++++++++++++++++++++++++++ include/linux/serial_core.h | 3 + 4 files changed, 662 insertions(+), 0 deletions(-) create mode 100644 drivers/serial/vt8500_serial.c
drivers/serial/Kconfig +10 -0
@@ -1381,6 +1381,16 @@ config SERIAL_MSM_CONSOLE depends on SERIAL_MSM=y select SERIAL_CORE_CONSOLE +config SERIAL_VT8500 + bool "VIA VT8500 on-chip serial port support" + depends on ARM && ARCH_VT8500 + select SERIAL_CORE + +config SERIAL_VT8500_CONSOLE + bool "VIA VT8500 serial console support" + depends on SERIAL_VT8500=y + select SERIAL_CORE_CONSOLE + config SERIAL_NETX tristate "NetX serial port support" depends on ARM && ARCH_NETX
drivers/serial/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-$(CONFIG_SERIAL_TIMBERDALE) += timbuart.o obj-$(CONFIG_SERIAL_GRLIB_GAISLER_APBUART) += apbuart.o obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o +obj-$(CONFIG_SERIAL_VT8500) += vt8500_serial.o obj-$(CONFIG_SERIAL_MRST_MAX3110) += mrst_max3110.o obj-$(CONFIG_SERIAL_MFD_HSU) += mfd.o obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
drivers/serial/vt8500_serial.c new file +648 -0
648 lines not on this page · raw message
include/linux/serial_core.h +3 -0
@@ -199,6 +199,9 @@/* TI OMAP-UART */ #define PORT_OMAP 96 +/* VIA VT8500 SoC */ +#define PORT_VT8500 97 +#ifdef __KERNEL__#include <linux/compiler.h>
Signature · 1 line
1.7.3.2
Alexey Charkov
maintainerPATCH v2 3/6 input: Add support for VIA VT8500 and compatibles in i8042
In reply to Alexey CharkovVIA and WonderMedia Systems-on-Chip feature a standard i8042-compatible keyboard and mouse controller. This adds necessary glue to enable use of the standard driver with these systems.
---
Please review and (if appropriate) commit to a relevant git tree for further integration in 2.6.38.
Previous version of this code was 'Acked-by: Dmitry Torokhov <[email protected]>' This one only differs by using runtime-selected IRQ definitions instead of static compile-time preprocessor macros.
Relevant register and interrupt definitions are provided by PATCH 1/6 in this series, so one would need that to make use of this code.
drivers/input/serio/Kconfig | 3 +- drivers/input/serio/i8042-vt8500.h | 74 ++++++++++++++++++++++++++++++++++++ drivers/input/serio/i8042.h | 2 + 3 files changed, 78 insertions(+), 1 deletions(-) create mode 100644 drivers/input/serio/i8042-vt8500.h
drivers/input/serio/Kconfig +2 -1
@@ -21,7 +21,8 @@ if SERIO config SERIO_I8042 tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86 default y - depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && \ + depends on !PARISC && \ + (!ARM || ARCH_SHARK || ARCH_VT8500 || FOOTBRIDGE_HOST) && \ (!SUPERH || SH_CAYMAN) && !M68K && !BLACKFIN help i8042 is the chip over which the standard AT keyboard and PS/2
drivers/input/serio/i8042-vt8500.h new file +74 -0
74 lines not on this page · raw message
drivers/input/serio/i8042.h +2 -0
@@ -16,6 +16,8 @@#if defined(CONFIG_MACH_JAZZ )#include "i8042-jazzio.h" +#elif defined(CONFIG_ARCH_VT8500 ) +#include "i8042-vt8500.h" #elif defined(CONFIG_SGI_HAS_I8042 )#include "i8042-ip22io.h" #elif defined(CONFIG_SNI_RM )
Signature · 1 line
1.7.3.2
Alexey Charkov
maintainerRe: [PATCH 3/6 v2] input: Add support for VIA VT8500 and compatibles in i8042
2010/11/7 Alexey Charkov <[email protected]>:
Quoted 127 lines
VIA and WonderMedia Systems-on-Chip feature a standard i8042-compatible keyboard and mouse controller. This adds necessary glue to enable use of the standard driver with these systems.
Signed-off-by Alexey Charkov <[email protected]>---
Please review and (if appropriate) commit to a relevant git tree for further integration in 2.6.38.
Previous version of this code was 'Acked-by: Dmitry Torokhov <[email protected]>' This one only differs by using runtime-selected IRQ definitions instead of static compile-time preprocessor macros.
Relevant register and interrupt definitions are provided by PATCH 1/6 in this series, so one would need that to make use of this code.
?drivers/input/serio/Kconfig ? ? ? ?| ? ?3 +- ?drivers/input/serio/i8042-vt8500.h | ? 74 ++++++++++++++++++++++++++++++++++++ ?drivers/input/serio/i8042.h ? ? ? ?| ? ?2 +?3 files changed, 78 insertions(+), 1 deletions(-) ?create mode 100644
drivers/input/serio/i8042-vt8500.hdrivers/input/serio/Kconfig +0
-0@@ -21,7 +21,8 @@ if SERIO?config
SERIO_I8042
? ? ? ?tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86 ? ? ? ?default y
- ? ? ? depends on !PARISC && (!ARM ||ARCH_SHARK||FOOTBRIDGE_HOST) && \
+ ? ? ? depends on !PARISC && \
+ ? ? ? ? ? ? ? ? (!ARM ||ARCH_SHARK||ARCH_VT8500||FOOTBRIDGE_HOST) && \
? ? ? ? ? ? ? ? ? (!SUPERH ||SH_CAYMAN) && !M68K && !BLACKFIN
? ? ? ?help
? ? ? ? ?i8042 is the chip over which the standard AT keyboard and PS/2drivers/input/serio/i8042-vt8500.h new file +74
-0@@ -0,0 +1,74 @@ +#ifndef _I8042_VT8500_H +#define _I8042_VT8500_H + +#include <mach/mmio_regs.h> +#include <mach/irq_defs.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 *regbase; + +/* +* Names. +*/ + +#define I8042_KBD_PHYS_DESC "vt8500ps2/serio0" +#define I8042_AUX_PHYS_DESC "vt8500ps2/serio1" +#define I8042_MUX_PHYS_DESC "vt8500ps2/serio%d" + +/* +* IRQs. +*/ + +#define I8042_KBD_IRQ ?(wmt_current_irqs->ps2kbd) +#define I8042_AUX_IRQ ?(wmt_current_irqs->ps2mouse) + + +/* +* Register numbers. +*/ + +#define I8042_COMMAND_REG ? ? ?(regbase + 0x4) +#define I8042_STATUS_REG ? ? ? (regbase + 0x4) +#define I8042_DATA_REG ? ? ? ? (regbase + 0x0) + +static inline int i8042_read_data (void ) +{ + ? ? ? return readl(I8042_DATA_REG); +} + +static inline int i8042_read_status (void ) +{ + ? ? ? return readl(I8042_STATUS_REG); +} + +static inline void i8042_write_data (int val) +{ + ? ? ? writel(val, I8042_DATA_REG); +} + +static inline void i8042_write_command (int val) +{ + ? ? ? writel(val, I8042_COMMAND_REG); +} + +static inline int i8042_platform_init (void ) +{ + ? ? ? i8042_reset = true; + ? ? ? regbase = ioremap(wmt_current_regs->ps2, SZ_1K); + ? ? ? if (!regbase) + ? ? ? ? ? ? ? return -ENODEV; + + ? ? ? return 0; +} + +static inline void i8042_platform_exit (void ) +{ + ? ? ? iounmap(regbase); +} + +#endif /* _I8042_VT8500_H */ drivers/input/serio/i8042.h +0
-0@@ -16,6 +16,8 @@ ?#if defined(CONFIG_MACH_JAZZ)?#include "
i8042-jazzio.h"drivers/input/serio/i8042.h +2
-0+#elif defined(CONFIG_ARCH_VT8500 ) +#include "i8042-vt8500.h"
Quoted 7 lines
?#elif
defined(CONFIG_SGI_HAS_I8042)
?#include "i8042-ip22io.h"
?#elifdefined(CONFIG_SNI_RM)
--
1.7.3.2
Any comments about this?
Thanks,
Alexey
Dmitry Torokhov
maintainerRe: [PATCH 3/6 v2] input: Add support for VIA VT8500 and compatibles in i8042
Quoted 124 lines · Alexey Charkov
2010/11/7 Alexey Charkov <[email protected]>:
Quoted 123 lines
VIA and WonderMedia Systems-on-Chip feature a standard i8042-compatible keyboard and mouse controller. This adds necessary glue to enable use of the standard driver with these systems.
Signed-off-by Alexey Charkov <[email protected]>---
Please review and (if appropriate) commit to a relevant git tree for further integration in 2.6.38.
Previous version of this code was 'Acked-by: Dmitry Torokhov <[email protected]>' This one only differs by using runtime-selected IRQ definitions instead of static compile-time preprocessor macros.
Relevant register and interrupt definitions are provided by PATCH 1/6 in this series, so one would need that to make use of this code.
?drivers/input/serio/Kconfig ? ? ? ?| ? ?3 +- ?drivers/input/serio/i8042-vt8500.h | ? 74 ++++++++++++++++++++++++++++++++++++ ?drivers/input/serio/i8042.h ? ? ? ?| ? ?2 +?3 files changed, 78 insertions(+), 1 deletions(-) ?create mode 100644
drivers/input/serio/i8042-vt8500.hdrivers/input/serio/Kconfig +0
-0@@ -21,7 +21,8 @@ if SERIO?config
SERIO_I8042
? ? ? ?tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86 ? ? ? ?default y
- ? ? ? depends on !PARISC && (!ARM ||ARCH_SHARK||FOOTBRIDGE_HOST) && \
+ ? ? ? depends on !PARISC && \
+ ? ? ? ? ? ? ? ? (!ARM ||ARCH_SHARK||ARCH_VT8500||FOOTBRIDGE_HOST) && \
? ? ? ? ? ? ? ? ? (!SUPERH ||SH_CAYMAN) && !M68K && !BLACKFIN
? ? ? ?help
? ? ? ? ?i8042 is the chip over which the standard AT keyboard and PS/2drivers/input/serio/i8042-vt8500.h new file +74
-0@@ -0,0 +1,74 @@ +#ifndef _I8042_VT8500_H +#define _I8042_VT8500_H + +#include <mach/mmio_regs.h> +#include <mach/irq_defs.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 *regbase; + +/* +* Names. +*/ + +#define I8042_KBD_PHYS_DESC "vt8500ps2/serio0" +#define I8042_AUX_PHYS_DESC "vt8500ps2/serio1" +#define I8042_MUX_PHYS_DESC "vt8500ps2/serio%d" + +/* +* IRQs. +*/ + +#define I8042_KBD_IRQ ?(wmt_current_irqs->ps2kbd) +#define I8042_AUX_IRQ ?(wmt_current_irqs->ps2mouse) + + +/* +* Register numbers. +*/ + +#define I8042_COMMAND_REG ? ? ?(regbase + 0x4) +#define I8042_STATUS_REG ? ? ? (regbase + 0x4) +#define I8042_DATA_REG ? ? ? ? (regbase + 0x0) + +static inline int i8042_read_data (void ) +{ + ? ? ? return readl(I8042_DATA_REG); +} + +static inline int i8042_read_status (void ) +{ + ? ? ? return readl(I8042_STATUS_REG); +} + +static inline void i8042_write_data (int val) +{ + ? ? ? writel(val, I8042_DATA_REG); +} + +static inline void i8042_write_command (int val) +{ + ? ? ? writel(val, I8042_COMMAND_REG); +} + +static inline int i8042_platform_init (void ) +{ + ? ? ? i8042_reset = true; + ? ? ? regbase = ioremap(wmt_current_regs->ps2, SZ_1K); + ? ? ? if (!regbase) + ? ? ? ? ? ? ? return -ENODEV; + + ? ? ? return 0; +} + +static inline void i8042_platform_exit (void ) +{ + ? ? ? iounmap(regbase); +} + +#endif /* _I8042_VT8500_H */ drivers/input/serio/i8042.h +0
-0@@ -16,6 +16,8 @@
Quoted 14 lines
Quoted 11 lines
drivers/input/serio/i8042.h +0
-0?#if defined(CONFIG_MACH_JAZZ)?#include "
i8042-jazzio.h"drivers/input/serio/i8042.h +2
-0+#elif defined(CONFIG_ARCH_VT8500 ) +#include "i8042-vt8500.h" ?#elif
defined(CONFIG_SGI_HAS_I8042)
?#include "i8042-ip22io.h"
?#elifdefined(CONFIG_SNI_RM)
--
1.7.3.2Any comments about this?
Looks good to me (ignoring the fact that whole i8042 initialization needs to be reworked and pushed into arch/board code which is out of scope of these series).
I expect it will be merged with the rest of VT8500 patches through whatever tree takes them.
Thanks.
Signature · 1 line
Dmitry
Alexey Charkov
maintainerRe: [PATCH 3/6 v2] input: Add support for VIA VT8500 and compatibles in i8042
2010/11/13 Dmitry Torokhov <[email protected]>:
Quoted 6 lines
Looks good to me (ignoring the fact that whole i8042 initialization needs to be reworked and pushed into
arch/boardcode which is out of scope of these series).I expect it will be merged with the rest of VT8500 patches through whatever tree takes them.
Thanks, Dmitry!
Best regards,
Alexey
Alexey Charkov
maintainerPATCH v3 3/6 input: Add support for VIA VT8500 and compatibles in i8042
In reply to Dmitry TorokhovVIA and WonderMedia Systems-on-Chip feature a standard i8042-compatible keyboard and mouse controller. This adds necessary glue to enable use of the standard driver with these systems.
---
This version of the patch introduces yet another trivial update to follow changes in arch code (namely variables that hold the register and interrupt numbers). Otherwise it is identical to v2.
Best regards,
Alexey
drivers/input/serio/Kconfig | 3 +- drivers/input/serio/i8042-vt8500.h | 73 ++++++++++++++++++++++++++++++++++++ drivers/input/serio/i8042.h | 2 + 3 files changed, 77 insertions(+), 1 deletions(-) create mode 100644 drivers/input/serio/i8042-vt8500.h
drivers/input/serio/Kconfig +2 -1
@@ -21,7 +21,8 @@ if SERIO config SERIO_I8042 tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86 default y - depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && \ + depends on !PARISC && \ + (!ARM || ARCH_SHARK || ARCH_VT8500 || FOOTBRIDGE_HOST) && \ (!SUPERH || SH_CAYMAN) && !M68K && !BLACKFIN help i8042 is the chip over which the standard AT keyboard and PS/2
drivers/input/serio/i8042-vt8500.h new file +73 -0
73 lines not on this page · raw message
drivers/input/serio/i8042.h +2 -0
@@ -16,6 +16,8 @@#if defined(CONFIG_MACH_JAZZ )#include "i8042-jazzio.h" +#elif defined(CONFIG_ARCH_VT8500 ) +#include "i8042-vt8500.h" #elif defined(CONFIG_SGI_HAS_I8042 )#include "i8042-ip22io.h" #elif defined(CONFIG_SNI_RM )
Signature · 1 line
1.7.3.4
Alexey Charkov
maintainerPATCH v2 4/6 usb: Add support for VIA VT8500 and compatibles in EHCI HCD
In reply to Alexey CharkovVIA and WonderMedia Systems-on-Chip feature a standard EHCI host controller. This adds necessary glue to use the standard driver with these systems.
---
Please review and (if appropriate) commit to a relevant git tree for further integration in 2.6.38.
Compared to the previous submission, this code just contains a rebase against the latest changes introduced in 2.6.37 merge window.
Relevant platform definitions are introduced by PATCH 1/6 in this series, so one would need that to make use of this code.
Due credits go to the community for providing feedback, advice and testing.
drivers/usb/Kconfig | 1 + drivers/usb/host/ehci-hcd.c | 5 + drivers/usb/host/ehci-vt8500.c | 172 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 178 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/host/ehci-vt8500.c
drivers/usb/Kconfig +1 -0
@@ -66,6 +66,7 @@ config USB_ARCH_HAS_EHCI default y if ARCH_AT91SAM9G45 default y if ARCH_MXC default y if ARCH_OMAP3 + default y if ARCH_VT8500 default PCI # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
drivers/usb/host/ehci-hcd.c +5 -0
@@ -1216,6 +1216,11 @@ MODULE_LICENSE ("GPL");#define PLATFORM_DRIVER ehci_octeon_driver#endif +#ifdef CONFIG_ARCH_VT8500 +#include "ehci-vt8500.c" +#define PLATFORM_DRIVER vt8500_ehci_driver +#endif +#if !defined(PCI_DRIVER ) && !defined(PLATFORM_DRIVER ) && \ !defined(PS3_SYSTEM_BUS_DRIVER ) && !defined(OF_PLATFORM_DRIVER ) && \ !defined(XILINX_OF_PLATFORM_DRIVER )
drivers/usb/host/ehci-vt8500.c new file +172 -0
172 lines not on this page · raw message
Signature · 1 line
1.7.3.2
Alexey Charkov
maintainerPATCH v2 5/6 rtc: Add support for the RTC in VIA VT8500 and compatibles
In reply to Alexey CharkovThis adds a driver for the RTC devices in VIA and WonderMedia Systems-on-Chip. Alarm, 1Hz interrupts, reading and setting time are supported.
---
Please review and (if appropriate) commit to a relevant git tree for further integration in 2.6.38.
Compared to the previous submission, this code just contains a rebase against the latest changes introduced in 2.6.37 merge window.
Relevant platform definitions are introduced by PATCH 1/6 in this series, so one would need that to make use of this code.
Due credits go to the community for providing feedback, advice and testing.
drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-vt8500.c | 363 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 371 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-vt8500.c
drivers/rtc/Kconfig +7 -0
@@ -865,6 +865,13 @@ config RTC_DRV_PXA This RTC driver uses PXA RTC registers available since pxa27x series (RDxR, RYxR) instead of legacy RCNR, RTAR. +config RTC_DRV_VT8500 + tristate "VIA/WonderMedia 85xx SoC RTC" + depends on ARCH_VT8500 + help + If you say Y here you will get access to the real time clock + built into your VIA VT8500 SoC or its relatives. + config RTC_DRV_SUN4V bool "SUN4V Hypervisor RTC"
drivers/rtc/Makefile +1 -0
@@ -97,6 +97,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o +obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
drivers/rtc/rtc-vt8500.c new file +363 -0
363 lines not on this page · raw message
Signature · 1 line
1.7.3.2
Alexey Charkov
maintainerRe: [PATCH 5/6 v2] rtc: Add support for the RTC in VIA VT8500 and compatibles
2010/11/7 Alexey Charkov <[email protected]>:
Quoted 425 lines
This adds a driver for the RTC devices in VIA and WonderMedia Systems-on-Chip. Alarm, 1Hz interrupts, reading and setting time are supported.
Signed-off-by Alexey Charkov <[email protected]>---
Please review and (if appropriate) commit to a relevant git tree for further integration in 2.6.38.
Compared to the previous submission, this code just contains a rebase against the latest changes introduced in 2.6.37 merge window.
Relevant platform definitions are introduced by PATCH 1/6 in this series, so one would need that to make use of this code.
Due credits go to the community for providing feedback, advice and testing.
?drivers/rtc/Kconfig ? ? ?| ? ?7 + ?drivers/rtc/Makefile ? ? | ? ?1 + ?drivers/rtc/rtc-vt8500.c | ?363 ++++++++++++++++++++++++++++++++++++++++++++++?3 files changed, 371 insertions(+), 0 deletions(-) ?create mode 100644
drivers/rtc/rtc-vt8500.cdrivers/rtc/Kconfig +0
-0@@ -865,6 +865,13 @@ config RTC_DRV_PXA? ? ? ? ?This RTC driver uses PXA RTC registers available since pxa27x ? ? ? ? ?series (RDxR, RYxR) instead of legacy RCNR, RTAR.
drivers/rtc/Kconfig +7
-0+config RTC_DRV_VT8500 + ? ? ? tristate "VIA/WonderMedia 85xx SoC RTC" + ? ? ? depends on ARCH_VT8500 + ? ? ? help + ? ? ? ? If you say Y here you will get access to the real time clock + ? ? ? ? built into your VIA VT8500 SoC or its relatives. +?config
RTC_DRV_SUN4V
? ? ? ?bool "SUN4V Hypervisor RTC"drivers/rtc/Makefile +0
-0@@ -97,6 +97,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o?obj-$(CONFIG_RTC_DRV_TX4939) ? += rtc-tx4939.o
?obj-$(CONFIG_RTC_DRV_V3020) ? ?+= rtc-v3020.o
?obj-$(CONFIG_RTC_DRV_VR41XX) ? += rtc-vr41xx.o
+obj-$(CONFIG_RTC_DRV_VT8500) ? += rtc-vt8500.o
?obj-$(CONFIG_RTC_DRV_WM831X) ? += rtc-wm831x.o
?obj-$(CONFIG_RTC_DRV_WM8350) ? += rtc-wm8350.o
?obj-$(CONFIG_RTC_DRV_X1205) ? ?+= rtc-x1205.odrivers/rtc/rtc-vt8500.c new file +363
-1@@ -0,0 +1,363 @@ +/* +* drivers/rtc/rtc-vt8500.c +* +* ?Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* Based on rtc-pxa.c +* +* 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/rtc.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/bcd.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +/* +* Register definitions +*/ +#define VT8500_RTC_TS ? ? ? ? ?0x00 ? ?/* Time set */ +#define VT8500_RTC_DS ? ? ? ? ?0x04 ? ?/* Date set */ +#define VT8500_RTC_AS ? ? ? ? ?0x08 ? ?/* Alarm set */ +#define VT8500_RTC_CR ? ? ? ? ?0x0c ? ?/* Control */ +#define VT8500_RTC_TR ? ? ? ? ?0x10 ? ?/* Time read */ +#define VT8500_RTC_DR ? ? ? ? ?0x14 ? ?/* Date read */ +#define VT8500_RTC_WS ? ? ? ? ?0x18 ? ?/* Write status */ +#define VT8500_RTC_CL ? ? ? ? ?0x20 ? ?/* Calibration */ +#define VT8500_RTC_IS ? ? ? ? ?0x24 ? ?/* Interrupt status */ +#define VT8500_RTC_ST ? ? ? ? ?0x28 ? ?/* Status */ + +#define INVALID_TIME_BIT ? ? ? (1 << 31) + +#define DATE_CENTURY_S ? ? ? ? 19 +#define DATE_YEAR_S ? ? ? ? ? ?11 +#define DATE_YEAR_MASK ? ? ? ? (0xff << DATE_YEAR_S) +#define DATE_MONTH_S ? ? ? ? ? 6 +#define DATE_MONTH_MASK ? ? ? ? ? ? ? ?(0x1f << DATE_MONTH_S) +#define DATE_DAY_MASK ? ? ? ? ?0x3f + +#define TIME_DOW_S ? ? ? ? ? ? 20 +#define TIME_DOW_MASK ? ? ? ? ?(0x07 << TIME_DOW_S) +#define TIME_HOUR_S ? ? ? ? ? ?14 +#define TIME_HOUR_MASK ? ? ? ? (0x3f << TIME_HOUR_S) +#define TIME_MIN_S ? ? ? ? ? ? 7 +#define TIME_MIN_MASK ? ? ? ? ?(0x7f << TIME_MIN_S) +#define TIME_SEC_MASK ? ? ? ? ?0x7f + +#define ALARM_DAY_S ? ? ? ? ? ?20 +#define ALARM_DAY_MASK ? ? ? ? (0x3f << ALARM_DAY_S) + +#define ALARM_DAY_BIT ? ? ? ? ?(1 << 29) +#define ALARM_HOUR_BIT ? ? ? ? (1 << 28) +#define ALARM_MIN_BIT ? ? ? ? ?(1 << 27) +#define ALARM_SEC_BIT ? ? ? ? ?(1 << 26) + +#define ALARM_ENABLE_MASK ? ? ?(ALARM_DAY_BIT \ + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ALARM_HOUR_BIT \ + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ALARM_MIN_BIT \ + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ALARM_SEC_BIT) + +struct vt8500_rtc { + ? ? ? void __iomem ? ? ? ? ? ?*regbase; + ? ? ? int ? ? ? ? ? ? ? ? ? ? irq_alarm; + ? ? ? int ? ? ? ? ? ? ? ? ? ? irq_hz; + ? ? ? struct rtc_device ? ? ? *rtc; + ? ? ? spinlock_t ? ? ? ? ? ? ?lock; ? ? ? ? ? /* Protects this structure */ + ? ? ? struct rtc_time ? ? ? ? rtc_alarm; +}; + +static irqreturn_t vt8500_rtc_irq (int irq,void *dev_id) +{ + ? ? ? struct platform_device *pdev = to_platform_device(dev_id); + ? ? ? struct vt8500_rtc *vt8500_rtc = platform_get_drvdata(pdev); + ? ? ? u32 isr; + ? ? ? unsigned long events = 0; + + ? ? ? spin_lock(&vt8500_rtc->lock); + + ? ? ? /* clear interrupt sources */ + ? ? ? isr = readl(vt8500_rtc->regbase + VT8500_RTC_IS); + ? ? ? writel(isr, vt8500_rtc->regbase + VT8500_RTC_IS); + + ? ? ? if (isr & 1) + ? ? ? ? ? ? ? events |= RTC_AF | RTC_IRQF; + + ? ? ? /* Only second/minute interrupts are supported */ + ? ? ? if (isr & 2) + ? ? ? ? ? ? ? events |= RTC_UF | RTC_IRQF; + + ? ? ? rtc_update_irq(vt8500_rtc->rtc, 1, events); + + ? ? ? spin_unlock(&vt8500_rtc->lock); + ? ? ? return IRQ_HANDLED; +} + +static int vt8500_rtc_open (struct device *dev) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + ? ? ? int ret; + + ? ? ? ret = request_irq(vt8500_rtc->irq_hz, vt8500_rtc_irq, IRQF_DISABLED, + ? ? ? ? ? ? ? ? ? ? ? ? "rtc 1Hz", dev); + ? ? ? if (ret < 0) { + ? ? ? ? ? ? ? dev_err(dev, "can't get irq %i, err %d\n", vt8500_rtc->irq_hz, + ? ? ? ? ? ? ? ? ? ? ? ret); + ? ? ? ? ? ? ? goto err_irq_hz; + ? ? ? } + ? ? ? ret = request_irq(vt8500_rtc->irq_alarm, vt8500_rtc_irq, IRQF_DISABLED, + ? ? ? ? ? ? ? ? ? ? ? ? "rtc alarm", dev); + ? ? ? if (ret < 0) { + ? ? ? ? ? ? ? dev_err(dev, "can't get irq %i, err %d\n", + ? ? ? ? ? ? ? ? ? ? ? vt8500_rtc->irq_alarm, ret); + ? ? ? ? ? ? ? goto err_irq_alarm; + ? ? ? } + ? ? ? return 0; + +err_irq_alarm: + ? ? ? free_irq(vt8500_rtc->irq_hz, dev); +err_irq_hz: + ? ? ? return ret; +} + +static void vt8500_rtc_release (struct device *dev) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + + ? ? ? spin_lock_irq(&vt8500_rtc->lock); + ? ? ? /* Disable alarm matching */ + ? ? ? writel(0, vt8500_rtc->regbase + VT8500_RTC_IS); + ? ? ? spin_unlock_irq(&vt8500_rtc->lock); + + ? ? ? free_irq(vt8500_rtc->irq_alarm, dev); + ? ? ? free_irq(vt8500_rtc->irq_hz, dev); +} + +static int vt8500_rtc_read_time (struct device *dev,struct rtc_time *tm) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + ? ? ? u32 date, time; + + ? ? ? date = readl(vt8500_rtc->regbase + VT8500_RTC_DR); + ? ? ? time = readl(vt8500_rtc->regbase + VT8500_RTC_TR); + + ? ? ? tm->tm_sec = bcd2bin(time & TIME_SEC_MASK); + ? ? ? 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_year = bcd2bin((date & DATE_YEAR_MASK) >> DATE_YEAR_S); + ? ? ? tm->tm_wday = (time & TIME_DOW_MASK) >> TIME_DOW_S; + + ? ? ? return 0; +} + +static int vt8500_rtc_set_time (struct device *dev,struct rtc_time *tm) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + + ? ? ? writel((bin2bcd(tm->tm_year) << DATE_YEAR_S) + ? ? ? ? ? ? ? | (bin2bcd(tm->tm_mon) << DATE_MONTH_S) + ? ? ? ? ? ? ? | (bin2bcd(tm->tm_mday)), + ? ? ? ? ? ? ? vt8500_rtc->regbase + VT8500_RTC_DS); + ? ? ? writel((bin2bcd(tm->tm_wday) << TIME_DOW_S) + ? ? ? ? ? ? ? | (bin2bcd(tm->tm_hour) << TIME_HOUR_S) + ? ? ? ? ? ? ? | (bin2bcd(tm->tm_min) << TIME_MIN_S) + ? ? ? ? ? ? ? | (bin2bcd(tm->tm_sec)), + ? ? ? ? ? ? ? vt8500_rtc->regbase + VT8500_RTC_TS); + + ? ? ? return 0; +} + +static int vt8500_rtc_read_alarm (struct device *dev,struct rtc_wkalrm *alrm) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + ? ? ? u32 isr, alarm; + + ? ? ? alarm = readl(vt8500_rtc->regbase + VT8500_RTC_AS); + ? ? ? isr = readl(vt8500_rtc->regbase + VT8500_RTC_IS); + + ? ? ? alrm->time.tm_mday = bcd2bin((alarm & ALARM_DAY_MASK) >> ALARM_DAY_S); + ? ? ? alrm->time.tm_hour = bcd2bin((alarm & TIME_HOUR_MASK) >> TIME_HOUR_S); + ? ? ? alrm->time.tm_min = bcd2bin((alarm & TIME_MIN_MASK) >> TIME_MIN_S); + ? ? ? alrm->time.tm_sec = bcd2bin((alarm & TIME_SEC_MASK)); + + ? ? ? alrm->enabled = (alarm & ALARM_ENABLE_MASK) ? 1 : 0; + + ? ? ? alrm->pending = (isr & 1) ? 1 : 0; + ? ? ? return 0; +} + +static int vt8500_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alrm) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + + ? ? ? writel((alrm->enabled ? ALARM_ENABLE_MASK : 0) + ? ? ? ? ? ? ? | (bin2bcd(alrm->time.tm_mday) << ALARM_DAY_S) + ? ? ? ? ? ? ? | (bin2bcd(alrm->time.tm_hour) << TIME_HOUR_S) + ? ? ? ? ? ? ? | (bin2bcd(alrm->time.tm_min) << TIME_MIN_S) + ? ? ? ? ? ? ? | (bin2bcd(alrm->time.tm_sec)), + ? ? ? ? ? ? ? vt8500_rtc->regbase + VT8500_RTC_AS); + + ? ? ? return 0; +} + +static int vt8500_rtc_ioctl (struct device *dev,unsigned int cmd, + ? ? ? ? ? ? ? unsigned long arg) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + ? ? ? int ret = 0; + ? ? ? unsigned long tmp; + + ? ? ? spin_lock_irq(&vt8500_rtc->lock); + ? ? ? switch (cmd) { + ? ? ? case RTC_AIE_OFF: + ? ? ? ? ? ? ? tmp = readl(vt8500_rtc->regbase + VT8500_RTC_AS); + ? ? ? ? ? ? ? writel(tmp & ~ALARM_ENABLE_MASK, + ? ? ? ? ? ? ? ? ? ? ?vt8500_rtc->regbase + VT8500_RTC_AS); + ? ? ? ? ? ? ? break; + ? ? ? case RTC_AIE_ON: + ? ? ? ? ? ? ? tmp = readl(vt8500_rtc->regbase + VT8500_RTC_AS); + ? ? ? ? ? ? ? writel(tmp | ALARM_ENABLE_MASK, + ? ? ? ? ? ? ? ? ? ? ?vt8500_rtc->regbase + VT8500_RTC_AS); + ? ? ? ? ? ? ? break; + ? ? ? case RTC_UIE_OFF: + ? ? ? ? ? ? ? tmp = readl(vt8500_rtc->regbase + VT8500_RTC_CR); + ? ? ? ? ? ? ? writel(tmp & ~(1 << 2), + ? ? ? ? ? ? ? ? ? ? ?vt8500_rtc->regbase + VT8500_RTC_CR); + ? ? ? ? ? ? ? break; + ? ? ? case RTC_UIE_ON: + ? ? ? ? ? ? ? tmp = readl(vt8500_rtc->regbase + VT8500_RTC_CR); + ? ? ? ? ? ? ? writel(tmp | ((1 << 3) | (1 << 2)), + ? ? ? ? ? ? ? ? ? ? ?vt8500_rtc->regbase + VT8500_RTC_CR); + ? ? ? ? ? ? ? break; + ? ? ? default: + ? ? ? ? ? ? ? ret = -ENOIOCTLCMD; + ? ? ? } + + ? ? ? spin_unlock_irq(&vt8500_rtc->lock); + ? ? ? return ret; +} + +static const struct rtc_class_ops vt8500_rtc_ops = { + ? ? ? .open = vt8500_rtc_open, + ? ? ? .release = vt8500_rtc_release, + ? ? ? .ioctl = vt8500_rtc_ioctl, + ? ? ? .read_time = vt8500_rtc_read_time, + ? ? ? .set_time = vt8500_rtc_set_time, + ? ? ? .read_alarm = vt8500_rtc_read_alarm, + ? ? ? .set_alarm = vt8500_rtc_set_alarm, +}; + +static int __init vt8500_rtc_probe (struct platform_device *pdev) +{ + ? ? ? struct device *dev = &pdev->dev; + ? ? ? struct vt8500_rtc *vt8500_rtc; + ? ? ? struct resource *res; + ? ? ? int ret; + + ? ? ? vt8500_rtc = kzalloc(sizeof(struct vt8500_rtc), GFP_KERNEL); + ? ? ? if (!vt8500_rtc) + ? ? ? ? ? ? ? return -ENOMEM; + + ? ? ? spin_lock_init(&vt8500_rtc->lock); + ? ? ? platform_set_drvdata(pdev, vt8500_rtc); + + ? ? ? ret = -ENXIO; + ? ? ? res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + ? ? ? if (!res) { + ? ? ? ? ? ? ? dev_err(dev, "No I/O memory resource defined\n"); + ? ? ? ? ? ? ? goto err_map; + ? ? ? } + + ? ? ? vt8500_rtc->irq_alarm = platform_get_irq(pdev, 0); + ? ? ? if (vt8500_rtc->irq_alarm < 0) { + ? ? ? ? ? ? ? dev_err(dev, "No alarm IRQ resource defined\n"); + ? ? ? ? ? ? ? goto err_map; + ? ? ? } + + ? ? ? vt8500_rtc->irq_hz = platform_get_irq(pdev, 1); + ? ? ? if (vt8500_rtc->irq_hz < 0) { + ? ? ? ? ? ? ? dev_err(dev, "No 1Hz IRQ resource defined\n"); + ? ? ? ? ? ? ? goto err_map; + ? ? ? } + + ? ? ? ret = -ENOMEM; + ? ? ? vt8500_rtc->regbase = ioremap(res->start, resource_size(res)); + ? ? ? if (!vt8500_rtc->regbase) { + ? ? ? ? ? ? ? dev_err(&pdev->dev, "Unable to map RTC I/O memory\n"); + ? ? ? ? ? ? ? goto err_map; + ? ? ? } + + ? ? ? /* Enable the second/minute interrupt generation and enable RTC */ + ? ? ? writel((1 << 3) | (1 << 2) | 1, vt8500_rtc->regbase + VT8500_RTC_CR); + + ? ? ? vt8500_rtc->rtc = rtc_device_register("vt8500-rtc", &pdev->dev, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &vt8500_rtc_ops, THIS_MODULE); + ? ? ? ret = PTR_ERR(vt8500_rtc->rtc); + ? ? ? if (IS_ERR(vt8500_rtc->rtc)) { + ? ? ? ? ? ? ? dev_err(dev, "Failed to register RTC device -> %d\n", ret); + ? ? ? ? ? ? ? goto err_rtc_reg; + ? ? ? } + + ? ? ? device_init_wakeup(dev, 1); + + ? ? ? return 0; + +err_rtc_reg: + ? ? ? iounmap(vt8500_rtc->regbase); +err_map: + ? ? ? kfree(vt8500_rtc); + ? ? ? return ret; +} + +static int __exit vt8500_rtc_remove(struct platform_device *pdev) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = platform_get_drvdata(pdev); + + ? ? ? rtc_device_unregister(vt8500_rtc->rtc); + + ? ? ? spin_lock_irq(&vt8500_rtc->lock); + ? ? ? iounmap(vt8500_rtc->regbase); + ? ? ? spin_unlock_irq(&vt8500_rtc->lock); + + ? ? ? kfree(vt8500_rtc); + + ? ? ? return 0; +} + +static struct platform_driver vt8500_rtc_driver = { + ? ? ? .probe ? ? ? ? ?= vt8500_rtc_probe, + ? ? ? .remove ? ? ? ? = __exit_p(vt8500_rtc_remove), + ? ? ? .driver ? ? ? ? = { + ? ? ? ? ? ? ? .name ? = "vt8500-rtc" + ? ? ? }, +}; + +static int __init vt8500_rtc_init (void ) +{ + ? ? ? return platform_driver_register(&vt8500_rtc_driver); +} + +static void __exit vt8500_rtc_exit(void) +{ + ? ? ? platform_driver_unregister(&vt8500_rtc_driver); +} + +module_init (vt8500_rtc_init); +module_exit (vt8500_rtc_exit); + +MODULE_AUTHOR ("Alexey Charkov <[email protected]>" ); +MODULE_DESCRIPTION ("VIA VT8500 SoC Realtime Clock Driver (RTC)" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:vt8500-rtc" ); --
Quoted 3 lines
1.7.3.2
Any comments about this?
Thanks,
Alexey
Re: [PATCH 5/6 v2] rtc: Add support for the RTC in VIA VT8500 and compatibles
In reply to Alexey CharkovQuoted 128 lines · Alexey Charkov
This adds a driver for the RTC devices in VIA and WonderMedia Systems-on-Chip. Alarm, 1Hz interrupts, reading and setting time are supported.
Signed-off-by Alexey Charkov <[email protected]>---
Please review and (if appropriate) commit to a relevant git tree for further integration in 2.6.38.
Compared to the previous submission, this code just contains a rebase against the latest changes introduced in 2.6.37 merge window.
Relevant platform definitions are introduced by PATCH 1/6 in this series, so one would need that to make use of this code.
Due credits go to the community for providing feedback, advice and testing.
drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-vt8500.c | 363 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 371 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-vt8500.cdrivers/rtc/Kconfig +7
-0@@ -865,6 +865,13 @@ config RTC_DRV_PXA This RTC driver uses PXA RTC registers available since pxa27x series (RDxR, RYxR) instead of legacy RCNR, RTAR. +config RTC_DRV_VT8500 + tristate "VIA/WonderMedia 85xx SoC RTC" + depends on ARCH_VT8500 + help + If you say Y here you will get access to the real time clock + built into your VIA VT8500 SoC or its relatives. + config RTC_DRV_SUN4V bool "SUN4V Hypervisor RTC"drivers/rtc/Makefile +1
-0@@ -97,6 +97,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o +obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.odrivers/rtc/rtc-vt8500.c new file +67
-0@@ -0,0 +1,363 @@ +/* +* drivers/rtc/rtc-vt8500.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* Based on rtc-pxa.c +* +* 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/rtc.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/bcd.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +/* +* Register definitions +*/ +#define VT8500_RTC_TS 0x00/* Time set */ +#define VT8500_RTC_DS 0x04/* Date set */ +#define VT8500_RTC_AS 0x08/* Alarm set */ +#define VT8500_RTC_CR 0x0c/* Control */ +#define VT8500_RTC_TR 0x10/* Time read */ +#define VT8500_RTC_DR 0x14/* Date read */ +#define VT8500_RTC_WS 0x18/* Write status */ +#define VT8500_RTC_CL 0x20/* Calibration */ +#define VT8500_RTC_IS 0x24/* Interrupt status */ +#define VT8500_RTC_ST 0x28/* Status */ + +#define INVALID_TIME_BIT (1 << 31) + +#define DATE_CENTURY_S 19 +#define DATE_YEAR_S 11 +#define DATE_YEAR_MASK (0xff << DATE_YEAR_S) +#define DATE_MONTH_S 6 +#define DATE_MONTH_MASK (0x1f << DATE_MONTH_S) +#define DATE_DAY_MASK 0x3f + +#define TIME_DOW_S 20 +#define TIME_DOW_MASK (0x07 << TIME_DOW_S) +#define TIME_HOUR_S 14 +#define TIME_HOUR_MASK (0x3f << TIME_HOUR_S) +#define TIME_MIN_S 7 +#define TIME_MIN_MASK (0x7f << TIME_MIN_S) +#define TIME_SEC_MASK 0x7f + +#define ALARM_DAY_S 20 +#define ALARM_DAY_MASK (0x3f << ALARM_DAY_S) + +#define ALARM_DAY_BIT (1 << 29) +#define ALARM_HOUR_BIT (1 << 28) +#define ALARM_MIN_BIT (1 << 27) +#define ALARM_SEC_BIT (1 << 26) + +#define ALARM_ENABLE_MASK (ALARM_DAY_BIT \ + | ALARM_HOUR_BIT \
drivers/rtc/rtc-vt8500.c line 77
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+ | ALARM_MIN_BIT \ + | ALARM_SEC_BIT) + +struct vt8500_rtc { +void __iomem *regbase; +int irq_alarm; +int irq_hz; +struct rtc_device *rtc; +spinlock_t lock;/* Protects this structure */ +struct rtc_time rtc_alarm;
This field is unused.
drivers/rtc/rtc-vt8500.c line 83
Quoted 6 lines
drivers/rtc/rtc-vt8500.c new file +6
-0+}; + +static irqreturn_t vt8500_rtc_irq (int irq,void *dev_id) +{ +struct platform_device *pdev =to_platform_device (dev_id); +struct vt8500_rtc *vt8500_rtc =platform_get_drvdata (pdev);
Wouldn't it be better to pass the vt8500_rtc struct as dev_id to request_irq?
drivers/rtc/rtc-vt8500.c line 91
Quoted 8 lines
drivers/rtc/rtc-vt8500.c new file +8
-0+u32 isr; +unsigned long events =0 ; + +spin_lock (&vt8500_rtc->lock); + +/* clear interrupt sources */ + isr =readl (vt8500_rtc->regbase +VT8500_RTC_IS ); +writel (isr, vt8500_rtc->regbase +VT8500_RTC_IS );
You only have to hold the lock until here.
Quoted 11 lines
drivers/rtc/rtc-vt8500.c new file +11
-0+ +if (isr &1 ) + events |=RTC_AF |RTC_IRQF ; + +/* Only second/minute interrupts are supported */ +if (isr &2 ) + events |=RTC_UF |RTC_IRQF ; + +rtc_update_irq (vt8500_rtc->rtc,1 , events); + +spin_unlock (&vt8500_rtc->lock);
drivers/rtc/rtc-vt8500.c line 112
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+return IRQ_HANDLED ; +} + +static int vt8500_rtc_open (struct device *dev) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +int ret; + + ret =request_irq (vt8500_rtc->irq_hz, vt8500_rtc_irq,IRQF_DISABLED , +"rtc 1Hz" , dev);
IRQF_DISABLED is deprecapted and a NOOP right now. You shouldn't add new code using it.
drivers/rtc/rtc-vt8500.c line 125
Quoted 13 lines
drivers/rtc/rtc-vt8500.c new file +13
-0+if (ret <0 ) { +dev_err (dev,"can't get irq %i, err %d\n" , vt8500_rtc->irq_hz, + ret); + goto err_irq_hz; + } + ret =request_irq (vt8500_rtc->irq_alarm, vt8500_rtc_irq,IRQF_DISABLED , +"rtc alarm" , dev); +if (ret <0 ) { +dev_err (dev,"can't get irq %i, err %d\n" , + vt8500_rtc->irq_alarm, ret); + goto err_irq_alarm; + } +return 0 ;
Is there any specific reason why you don't keep the irq requested for the lifetime of the device?
You wont be able to provide wakeup functionallity this way.
Quoted 27 lines
drivers/rtc/rtc-vt8500.c new file +27
-0+ +err_irq_alarm: +free_irq (vt8500_rtc->irq_hz, dev); +err_irq_hz: +return ret; +} + +static void vt8500_rtc_release (struct device *dev) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); + +spin_lock_irq (&vt8500_rtc->lock); +/* Disable alarm matching */ +writel (0 , vt8500_rtc->regbase +VT8500_RTC_IS ); +spin_unlock_irq (&vt8500_rtc->lock); + +free_irq (vt8500_rtc->irq_alarm, dev); +free_irq (vt8500_rtc->irq_hz, dev); +} + +static int vt8500_rtc_read_time (struct device *dev,struct rtc_time *tm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +u32 date, time; + + date =readl (vt8500_rtc->regbase +VT8500_RTC_DR ); + time =readl (vt8500_rtc->regbase +VT8500_RTC_TR );
drivers/rtc/rtc-vt8500.c line 162
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+ + tm->tm_sec =bcd2bin (time &TIME_SEC_MASK ); + 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_year =bcd2bin ((date &DATE_YEAR_MASK ) >>DATE_YEAR_S ); + tm->tm_wday = (time &TIME_DOW_MASK ) >>TIME_DOW_S ; + +return 0 ;
return rtc_valid_tm(tm);
Quoted 26 lines
drivers/rtc/rtc-vt8500.c new file +26
-0+} + +static int vt8500_rtc_set_time (struct device *dev,struct rtc_time *tm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); + +writel ((bin2bcd (tm->tm_year) <<DATE_YEAR_S ) + | (bin2bcd (tm->tm_mon) <<DATE_MONTH_S ) + | (bin2bcd (tm->tm_mday)), + vt8500_rtc->regbase +VT8500_RTC_DS ); +writel ((bin2bcd (tm->tm_wday) <<TIME_DOW_S ) + | (bin2bcd (tm->tm_hour) <<TIME_HOUR_S ) + | (bin2bcd (tm->tm_min) <<TIME_MIN_S ) + | (bin2bcd (tm->tm_sec)), + vt8500_rtc->regbase +VT8500_RTC_TS ); + +return 0 ; +} + +static int vt8500_rtc_read_alarm (struct device *dev,struct rtc_wkalrm *alrm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +u32 isr, alarm; + + alarm =readl (vt8500_rtc->regbase +VT8500_RTC_AS ); + isr =readl (vt8500_rtc->regbase +VT8500_RTC_IS );
drivers/rtc/rtc-vt8500.c line 198
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+ + alrm->time.tm_mday =bcd2bin ((alarm &ALARM_DAY_MASK ) >>ALARM_DAY_S ); + alrm->time.tm_hour =bcd2bin ((alarm &TIME_HOUR_MASK ) >>TIME_HOUR_S ); + alrm->time.tm_min =bcd2bin ((alarm &TIME_MIN_MASK ) >>TIME_MIN_S ); + alrm->time.tm_sec =bcd2bin ((alarm &TIME_SEC_MASK )); + + alrm->enabled = (alarm &ALARM_ENABLE_MASK ) ?1 :0 ; + + alrm->pending = (isr &1 ) ?1 :0 ; +return 0 ;
return rtc_valid_tm(&alrm->time);
Quoted 29 lines
drivers/rtc/rtc-vt8500.c new file +29
-0+} + +static int vt8500_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alrm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); + +writel ((alrm->enabled ?ALARM_ENABLE_MASK :0 ) + | (bin2bcd (alrm->time.tm_mday) <<ALARM_DAY_S ) + | (bin2bcd (alrm->time.tm_hour) <<TIME_HOUR_S ) + | (bin2bcd (alrm->time.tm_min) <<TIME_MIN_S ) + | (bin2bcd (alrm->time.tm_sec)), + vt8500_rtc->regbase +VT8500_RTC_AS ); + +return 0 ; +} + +static int vt8500_rtc_ioctl (struct device *dev,unsigned int cmd, +unsigned long arg) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +int ret =0 ; +unsigned long tmp; + +spin_lock_irq (&vt8500_rtc->lock); +switch (cmd) { +case RTC_AIE_OFF : + tmp =readl (vt8500_rtc->regbase +VT8500_RTC_AS ); +writel (tmp & ~ALARM_ENABLE_MASK , + vt8500_rtc->regbase +VT8500_RTC_AS );
drivers/rtc/rtc-vt8500.c line 237
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+break ; +case RTC_AIE_ON : + tmp =readl (vt8500_rtc->regbase +VT8500_RTC_AS ); +writel (tmp |ALARM_ENABLE_MASK , + vt8500_rtc->regbase +VT8500_RTC_AS ); +break ; +case RTC_UIE_OFF : + tmp =readl (vt8500_rtc->regbase +VT8500_RTC_CR ); +writel (tmp & ~(1 <<2 ), + vt8500_rtc->regbase +VT8500_RTC_CR );
It would be better if you added descriptive defines for the bits of the CR register. Makes reading the driver easier.
drivers/rtc/rtc-vt8500.c line 245
Quoted 8 lines
drivers/rtc/rtc-vt8500.c new file +8
-0+break ; +case RTC_UIE_ON : + tmp =readl (vt8500_rtc->regbase +VT8500_RTC_CR ); +writel (tmp | ((1 <<3 ) | (1 <<2 )), + vt8500_rtc->regbase +VT8500_RTC_CR ); +break ; +default : + ret = -ENOIOCTLCMD ;
You should rather implement these by providing the update_irq_enable and alarm_irq_enable callbacks of your rtc_class_ops instead of handling the ioctls yourself.
Quoted 7 lines
drivers/rtc/rtc-vt8500.c new file +7
-0+ } + +spin_unlock_irq (&vt8500_rtc->lock); +return ret; +} + +static const struct rtc_class_ops vt8500_rtc_ops = {
drivers/rtc/rtc-vt8500.c line 262
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+ .open = vt8500_rtc_open, + .release = vt8500_rtc_release, + .ioctl = vt8500_rtc_ioctl, + .read_time = vt8500_rtc_read_time, + .set_time = vt8500_rtc_set_time, + .read_alarm = vt8500_rtc_read_alarm, + .set_alarm = vt8500_rtc_set_alarm, +}; + +static int __init vt8500_rtc_probe (struct platform_device *pdev)
__devinit
Quoted 21 lines
drivers/rtc/rtc-vt8500.c new file +21
-0+{ +struct device *dev = &pdev->dev; +struct vt8500_rtc *vt8500_rtc; +struct resource *res; +int ret; + + vt8500_rtc =kzalloc (sizeof (struct vt8500_rtc ),GFP_KERNEL ); +if (!vt8500_rtc) +return -ENOMEM ; + +spin_lock_init (&vt8500_rtc->lock); +platform_set_drvdata (pdev, vt8500_rtc); + + ret = -ENXIO ; + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (dev,"No I/O memory resource defined\n" ); + goto err_map; + } + + vt8500_rtc->irq_alarm =platform_get_irq (pdev,0 );
drivers/rtc/rtc-vt8500.c line 293
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+if (vt8500_rtc->irq_alarm <0 ) { +dev_err (dev,"No alarm IRQ resource defined\n" ); + goto err_map; + } + + vt8500_rtc->irq_hz =platform_get_irq (pdev,1 ); +if (vt8500_rtc->irq_hz <0 ) { +dev_err (dev,"No 1Hz IRQ resource defined\n" ); + goto err_map; + }
You should first request the memory region before ioremapping it
drivers/rtc/rtc-vt8500.c line 295
Quoted 2 lines
drivers/rtc/rtc-vt8500.c new file +2
-0+ + ret = -ENOMEM ;
Move the assignment inside the if statement.
drivers/rtc/rtc-vt8500.c line 307
Quoted 12 lines
drivers/rtc/rtc-vt8500.c new file +12
-0+ vt8500_rtc->regbase =ioremap (res->start,resource_size (res)); +if (!vt8500_rtc->regbase) { +dev_err (&pdev->dev,"Unable to map RTC I/O memory\n" ); + goto err_map; + } + +/* Enable the second/minute interrupt generation and enable RTC */ +writel ((1 <<3 ) | (1 <<2 ) |1 , vt8500_rtc->regbase +VT8500_RTC_CR ); + + vt8500_rtc->rtc =rtc_device_register ("vt8500-rtc" , &pdev->dev, + &vt8500_rtc_ops,THIS_MODULE ); + ret =PTR_ERR (vt8500_rtc->rtc);
Move the assignment inside the if statement.
drivers/rtc/rtc-vt8500.c line 313
Quoted 6 lines
drivers/rtc/rtc-vt8500.c new file +6
-0+if (IS_ERR (vt8500_rtc->rtc)) { +dev_err (dev,"Failed to register RTC device -> %d\n" , ret); + goto err_rtc_reg; + } + +device_init_wakeup (dev,1 );
As far as I can see your driver does not provide any wakeup functionality.
drivers/rtc/rtc-vt8500.c line 324
Quoted 11 lines
drivers/rtc/rtc-vt8500.c new file +11
-0+ +return 0 ; + +err_rtc_reg: +iounmap (vt8500_rtc->regbase); +err_map: +kfree (vt8500_rtc); +return ret; +} + +static int __exit vt8500_rtc_remove(struct platform_device *pdev)
__devexit
Quoted 7 lines
drivers/rtc/rtc-vt8500.c new file +7
-0+{ +struct vt8500_rtc *vt8500_rtc =platform_get_drvdata (pdev); + +rtc_device_unregister (vt8500_rtc->rtc); + +spin_lock_irq (&vt8500_rtc->lock); +iounmap (vt8500_rtc->regbase);
drivers/rtc/rtc-vt8500.c line 341
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+spin_unlock_irq (&vt8500_rtc->lock); + +kfree (vt8500_rtc); + +return 0 ; +} + +static struct platform_driver vt8500_rtc_driver = { + .probe = vt8500_rtc_probe, + .remove =__exit_p (vt8500_rtc_remove),
__devexit_p
drivers/rtc/rtc-vt8500.c line 343
Quoted 2 lines
drivers/rtc/rtc-vt8500.c new file +2
-0+ .driver = { + .name ="vt8500-rtc"
.owner = THIS_MODULE,
Quoted 5 lines
drivers/rtc/rtc-vt8500.c new file +5
-0+ }, +}; + +static int __init vt8500_rtc_init (void ) +{
drivers/rtc/rtc-vt8500.c line 358
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+return platform_driver_register (&vt8500_rtc_driver); +} + +static void __exit vt8500_rtc_exit(void) +{ +platform_driver_unregister (&vt8500_rtc_driver); +} + +module_init (vt8500_rtc_init); +module_exit (vt8500_rtc_exit);
module_{init,exit} should go right beneath the function they reference.
drivers/rtc/rtc-vt8500.c line 363
Quoted 5 lines
drivers/rtc/rtc-vt8500.c new file +5
-0+ +MODULE_AUTHOR ("Alexey Charkov <[email protected]>" ); +MODULE_DESCRIPTION ("VIA VT8500 SoC Realtime Clock Driver (RTC)" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:vt8500-rtc" );
- Lars
Alexey Charkov
maintainerPATCH v3 5/6 rtc: Add support for the RTC in VIA VT8500 and compatibles
This adds a driver for the RTC devices in VIA and WonderMedia Systems-on-Chip. Alarm, 1Hz interrupts, reading and setting time are supported.
---
This implements the suggestions made by Lars. Reference to wakeup was removed, as currently other code does not yet provide any support for that.
It now also checks the status register for indication of a valid time value before trying to read date/time registers.
Thanks,
Alexey
drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-vt8500.c | 365 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 373 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-vt8500.c
drivers/rtc/Kconfig +7 -0
@@ -865,6 +865,13 @@ config RTC_DRV_PXA This RTC driver uses PXA RTC registers available since pxa27x series (RDxR, RYxR) instead of legacy RCNR, RTAR. +config RTC_DRV_VT8500 + tristate "VIA/WonderMedia 85xx SoC RTC" + depends on ARCH_VT8500 + help + If you say Y here you will get access to the real time clock + built into your VIA VT8500 SoC or its relatives. + config RTC_DRV_SUN4V bool "SUN4V Hypervisor RTC"
drivers/rtc/Makefile +1 -0
@@ -97,6 +97,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o +obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
drivers/rtc/rtc-vt8500.c new file +365 -0
365 lines not on this page · raw message
Signature · 1 line
1.7.3.2
Re: [PATCH 5/6 v3] rtc: Add support for the RTC in VIA VT8500 and compatibles
Quoted 11 lines · Alexey Charkov
This adds a driver for the RTC devices in VIA and WonderMedia Systems-on-Chip. Alarm, 1Hz interrupts, reading and setting time are supported.
Signed-off-by Alexey Charkov <[email protected]>---
This implements the suggestions made by Lars. Reference to wakeup was removed, as currently other code does not yet provide any support for that.
Quoted 5 lines
It now also checks the status register for indication of a valid time value before trying to read date/time registers.
Thanks,
Alexey
Hi
Looks good to me now, except for the drivers release function. And some minor stylistic issues. Comments are inline.
- Lars
Quoted 230 lines
drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-vt8500.c | 365 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 373 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-vt8500.cdrivers/rtc/Kconfig +7
-0@@ -865,6 +865,13 @@ config RTC_DRV_PXA This RTC driver uses PXA RTC registers available since pxa27x series (RDxR, RYxR) instead of legacy RCNR, RTAR. +config RTC_DRV_VT8500 + tristate "VIA/WonderMedia 85xx SoC RTC" + depends on ARCH_VT8500 + help + If you say Y here you will get access to the real time clock + built into your VIA VT8500 SoC or its relatives. + config RTC_DRV_SUN4V bool "SUN4V Hypervisor RTC"drivers/rtc/Makefile +1
-0@@ -97,6 +97,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o +obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.odrivers/rtc/rtc-vt8500.c new file +187
-0@@ -0,0 +1,365 @@ +/* +* drivers/rtc/rtc-vt8500.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* Based on rtc-pxa.c +* +* 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/rtc.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/bcd.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +/* +* Register definitions +*/ +#define VT8500_RTC_TS 0x00/* Time set */ +#define VT8500_RTC_DS 0x04/* Date set */ +#define VT8500_RTC_AS 0x08/* Alarm set */ +#define VT8500_RTC_CR 0x0c/* Control */ +#define VT8500_RTC_TR 0x10/* Time read */ +#define VT8500_RTC_DR 0x14/* Date read */ +#define VT8500_RTC_WS 0x18/* Write status */ +#define VT8500_RTC_CL 0x20/* Calibration */ +#define VT8500_RTC_IS 0x24/* Interrupt status */ +#define VT8500_RTC_ST 0x28/* Status */ + +#define INVALID_TIME_BIT (1 << 31) + +#define DATE_CENTURY_S 19 +#define DATE_YEAR_S 11 +#define DATE_YEAR_MASK (0xff << DATE_YEAR_S) +#define DATE_MONTH_S 6 +#define DATE_MONTH_MASK (0x1f << DATE_MONTH_S) +#define DATE_DAY_MASK 0x3f + +#define TIME_DOW_S 20 +#define TIME_DOW_MASK (0x07 << TIME_DOW_S) +#define TIME_HOUR_S 14 +#define TIME_HOUR_MASK (0x3f << TIME_HOUR_S) +#define TIME_MIN_S 7 +#define TIME_MIN_MASK (0x7f << TIME_MIN_S) +#define TIME_SEC_MASK 0x7f + +#define ALARM_DAY_S 20 +#define ALARM_DAY_MASK (0x3f << ALARM_DAY_S) + +#define ALARM_DAY_BIT (1 << 29) +#define ALARM_HOUR_BIT (1 << 28) +#define ALARM_MIN_BIT (1 << 27) +#define ALARM_SEC_BIT (1 << 26) + +#define ALARM_ENABLE_MASK (ALARM_DAY_BIT \ + | ALARM_HOUR_BIT \ + | ALARM_MIN_BIT \ + | ALARM_SEC_BIT) + +#define VT8500_RTC_CR_ENABLE (1 << 0)/* Enable RTC */ +#define VT8500_RTC_CR_24H (1 << 1)/* 24h time format */ +#define VT8500_RTC_CR_SM_ENABLE (1 << 2)/* Enable periodic irqs */ +#define VT8500_RTC_CR_SM_SEC (1 << 3)/* 0: 1Hz/60, 1: 1Hz */ +#define VT8500_RTC_CR_CALIB (1 << 4)/* Enable calibration */ + +struct vt8500_rtc { +void __iomem *regbase; +int irq_alarm; +int irq_hz; +struct rtc_device *rtc; +spinlock_t lock;/* Protects this structure */ +}; + +static irqreturn_t vt8500_rtc_irq (int irq,void *dev_id) +{ +struct vt8500_rtc *vt8500_rtc = dev_id; +u32 isr; +unsigned long events =0 ; + +spin_lock (&vt8500_rtc->lock); + +/* clear interrupt sources */ + isr =readl (vt8500_rtc->regbase +VT8500_RTC_IS ); +writel (isr, vt8500_rtc->regbase +VT8500_RTC_IS ); + +spin_unlock (&vt8500_rtc->lock); + +if (isr &1 ) + events |=RTC_AF |RTC_IRQF ; + +/* Only second/minute interrupts are supported */ +if (isr &2 ) + events |=RTC_UF |RTC_IRQF ; + +rtc_update_irq (vt8500_rtc->rtc,1 , events); + +return IRQ_HANDLED ; +} + +static int vt8500_rtc_read_time (struct device *dev,struct rtc_time *tm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +u32 date, time; + +if (!readl (vt8500_rtc->regbase +VT8500_RTC_ST )) { +dev_info (dev,"Clock not set!" ); +return -EINVAL ; + } + date =readl (vt8500_rtc->regbase +VT8500_RTC_DR ); + time =readl (vt8500_rtc->regbase +VT8500_RTC_TR ); + + tm->tm_sec =bcd2bin (time &TIME_SEC_MASK ); + 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_year =bcd2bin ((date &DATE_YEAR_MASK ) >>DATE_YEAR_S ); + tm->tm_wday = (time &TIME_DOW_MASK ) >>TIME_DOW_S ; + +return rtc_valid_tm (tm); +} + +static int vt8500_rtc_set_time (struct device *dev,struct rtc_time *tm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); + +writel ((bin2bcd (tm->tm_year) <<DATE_YEAR_S ) + | (bin2bcd (tm->tm_mon) <<DATE_MONTH_S ) + | (bin2bcd (tm->tm_mday)), + vt8500_rtc->regbase +VT8500_RTC_DS ); +writel ((bin2bcd (tm->tm_wday) <<TIME_DOW_S ) + | (bin2bcd (tm->tm_hour) <<TIME_HOUR_S ) + | (bin2bcd (tm->tm_min) <<TIME_MIN_S ) + | (bin2bcd (tm->tm_sec)), + vt8500_rtc->regbase +VT8500_RTC_TS ); + +return 0 ; +} + +static int vt8500_rtc_read_alarm (struct device *dev,struct rtc_wkalrm *alrm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +u32 isr, alarm; + + alarm =readl (vt8500_rtc->regbase +VT8500_RTC_AS ); + isr =readl (vt8500_rtc->regbase +VT8500_RTC_IS ); + + alrm->time.tm_mday =bcd2bin ((alarm &ALARM_DAY_MASK ) >>ALARM_DAY_S ); + alrm->time.tm_hour =bcd2bin ((alarm &TIME_HOUR_MASK ) >>TIME_HOUR_S ); + alrm->time.tm_min =bcd2bin ((alarm &TIME_MIN_MASK ) >>TIME_MIN_S ); + alrm->time.tm_sec =bcd2bin ((alarm &TIME_SEC_MASK )); + + alrm->enabled = (alarm &ALARM_ENABLE_MASK ) ?1 :0 ; + + alrm->pending = (isr &1 ) ?1 :0 ; +return rtc_valid_tm (&alrm->time); +} + +static int vt8500_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alrm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); + +writel ((alrm->enabled ?ALARM_ENABLE_MASK :0 ) + | (bin2bcd (alrm->time.tm_mday) <<ALARM_DAY_S ) + | (bin2bcd (alrm->time.tm_hour) <<TIME_HOUR_S ) + | (bin2bcd (alrm->time.tm_min) <<TIME_MIN_S ) + | (bin2bcd (alrm->time.tm_sec)), + vt8500_rtc->regbase +VT8500_RTC_AS ); + +return 0 ; +} + +static int vt8500_alarm_irq_enable (struct device *dev,unsigned int enabled) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +unsigned long tmp;
drivers/rtc/rtc-vt8500.c line 197
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+ +if (enabled) { + tmp =readl (vt8500_rtc->regbase +VT8500_RTC_AS ); +writel (tmp |ALARM_ENABLE_MASK , + vt8500_rtc->regbase +VT8500_RTC_AS ); + }else { + tmp =readl (vt8500_rtc->regbase +VT8500_RTC_AS ); +writel (tmp & ~ALARM_ENABLE_MASK , + vt8500_rtc->regbase +VT8500_RTC_AS ); + }
In my opinion it would be a good idea to move the read and write of the register outside of if-else statement and just modify tmp in there. That should make the code more readable.
Quoted 7 lines
drivers/rtc/rtc-vt8500.c new file +7
-0+return 0 ; +} + +static int vt8500_update_irq_enable (struct device *dev,unsigned int enabled) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +unsigned long tmp;
drivers/rtc/rtc-vt8500.c line 214
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+ +if (enabled) { + tmp =readl (vt8500_rtc->regbase +VT8500_RTC_CR ); +writel (tmp |VT8500_RTC_CR_SM_SEC |VT8500_RTC_CR_SM_ENABLE , + vt8500_rtc->regbase +VT8500_RTC_CR ); + }else { + tmp =readl (vt8500_rtc->regbase +VT8500_RTC_CR ); +writel (tmp & ~VT8500_RTC_CR_SM_ENABLE , + vt8500_rtc->regbase +VT8500_RTC_CR ); + }
Same here
Quoted 47 lines
drivers/rtc/rtc-vt8500.c new file +47
-0+return 0 ; +} + +static const struct rtc_class_ops vt8500_rtc_ops = { + .read_time = vt8500_rtc_read_time, + .set_time = vt8500_rtc_set_time, + .read_alarm = vt8500_rtc_read_alarm, + .set_alarm = vt8500_rtc_set_alarm, + .alarm_irq_enable = vt8500_alarm_irq_enable, + .update_irq_enable = vt8500_update_irq_enable, +}; + +static int __devinit vt8500_rtc_probe (struct platform_device *pdev) +{ +struct vt8500_rtc *vt8500_rtc; +struct resource *res; +int ret; + + vt8500_rtc =kzalloc (sizeof (struct vt8500_rtc ),GFP_KERNEL ); +if (!vt8500_rtc) +return -ENOMEM ; + +spin_lock_init (&vt8500_rtc->lock); +platform_set_drvdata (pdev, vt8500_rtc); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (&pdev->dev,"No I/O memory resource defined\n" ); + ret = -ENXIO ; + goto err_free; + } + + vt8500_rtc->irq_alarm =platform_get_irq (pdev,0 ); +if (vt8500_rtc->irq_alarm <0 ) { +dev_err (&pdev->dev,"No alarm IRQ resource defined\n" ); + ret = -ENXIO ; + goto err_free; + } + + vt8500_rtc->irq_hz =platform_get_irq (pdev,1 ); +if (vt8500_rtc->irq_hz <0 ) { +dev_err (&pdev->dev,"No 1Hz IRQ resource defined\n" ); + ret = -ENXIO ; + goto err_free; + } + + res =request_mem_region (res->start,resource_size (res),"vt8500-rtc" );
drivers/rtc/rtc-vt8500.c line 271
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+if (res ==NULL ) { +dev_err (&pdev->dev,"failed to request I/O memory\n" ); + ret = -EBUSY ; + goto err_free; + } + + vt8500_rtc->regbase =ioremap (res->start,resource_size (res)); +if (!vt8500_rtc->regbase) { +dev_err (&pdev->dev,"Unable to map RTC I/O memory\n" ); + ret = -ENOMEM ;
I think this should be -EBUSY as well.
drivers/rtc/rtc-vt8500.c line 282
Quoted 11 lines
drivers/rtc/rtc-vt8500.c new file +11
-0+ goto err_release; + } + +/* Enable the second/minute interrupt generation and enable RTC */ +writel (VT8500_RTC_CR_ENABLE |VT8500_RTC_CR_24H + |VT8500_RTC_CR_SM_ENABLE |VT8500_RTC_CR_SM_SEC , + vt8500_rtc->regbase +VT8500_RTC_CR ); + + vt8500_rtc->rtc =rtc_device_register ("vt8500-rtc" , &pdev->dev, + &vt8500_rtc_ops,THIS_MODULE ); + ret =PTR_ERR (vt8500_rtc->rtc);
Move the assignment inside the if statement...
drivers/rtc/rtc-vt8500.c line 286
Quoted 4 lines
drivers/rtc/rtc-vt8500.c new file +4
-0+if (IS_ERR (vt8500_rtc->rtc)) { +dev_err (&pdev->dev, +"Failed to register RTC device -> %d\n" , ret); + ret = -ENXIO ;
... and drop this one.
Quoted 35 lines
drivers/rtc/rtc-vt8500.c new file +35
-0+ goto err_unmap; + } + + ret =request_irq (vt8500_rtc->irq_hz, vt8500_rtc_irq,0 , +"rtc 1Hz" , vt8500_rtc); +if (ret <0 ) { +dev_err (&pdev->dev,"can't get irq %i, err %d\n" , + vt8500_rtc->irq_hz, ret); + goto err_unreg; + } + + ret =request_irq (vt8500_rtc->irq_alarm, vt8500_rtc_irq,0 , +"rtc alarm" , vt8500_rtc); +if (ret <0 ) { +dev_err (&pdev->dev,"can't get irq %i, err %d\n" , + vt8500_rtc->irq_alarm, ret); + goto err_free_hz; + } + +return 0 ; + +err_free_hz: +free_irq (vt8500_rtc->irq_hz, vt8500_rtc); +err_unreg: +rtc_device_unregister (vt8500_rtc->rtc); +err_unmap: +iounmap (vt8500_rtc->regbase); +err_release: +release_mem_region (res->start,resource_size (res)); +err_free: +kfree (vt8500_rtc); +return ret; +} + +static int __devexit vt8500_rtc_remove(struct platform_device *pdev)
drivers/rtc/rtc-vt8500.c line 331
Quoted 10 lines
drivers/rtc/rtc-vt8500.c new file +10
-0+{ +struct vt8500_rtc *vt8500_rtc =platform_get_drvdata (pdev); + +rtc_device_unregister (vt8500_rtc->rtc); + +spin_lock_irq (&vt8500_rtc->lock); +/* Disable alarm matching */ +writel (0 , vt8500_rtc->regbase +VT8500_RTC_IS ); +iounmap (vt8500_rtc->regbase); +spin_unlock_irq (&vt8500_rtc->lock);
I don't think you need to lock here.
And you need to release the mem region here, too.
drivers/rtc/rtc-vt8500.c line 334
Quoted 3 lines
drivers/rtc/rtc-vt8500.c new file +3
-0+ +free_irq (vt8500_rtc->irq_alarm, vt8500_rtc); +free_irq (vt8500_rtc->irq_hz, vt8500_rtc);
You should free the irqs before you unregister the rtc device, otherwise it might be possible that the irq handler tries to report an interrupt to the already unregistered rtc device.
drivers/rtc/rtc-vt8500.c line 336
Quoted 2 lines
drivers/rtc/rtc-vt8500.c new file +2
-0+ +kfree (vt8500_rtc);
platform_set_drvdata(pdev, NULL);
Quoted 29 lines
drivers/rtc/rtc-vt8500.c new file +29
-0+ +return 0 ; +} + +static struct platform_driver vt8500_rtc_driver = { + .probe = vt8500_rtc_probe, + .remove =__devexit_p (vt8500_rtc_remove), + .driver = { + .name ="vt8500-rtc" , + .owner =THIS_MODULE , + }, +}; + +static int __init vt8500_rtc_init (void ) +{ +return platform_driver_register (&vt8500_rtc_driver); +} +module_init (vt8500_rtc_init); + +static void __exit vt8500_rtc_exit(void) +{ +platform_driver_unregister (&vt8500_rtc_driver); +} +module_exit (vt8500_rtc_exit); + +MODULE_AUTHOR ("Alexey Charkov <[email protected]>" ); +MODULE_DESCRIPTION ("VIA VT8500 SoC Realtime Clock Driver (RTC)" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:vt8500-rtc" );
Alexey Charkov
maintainerPATCH v4 5/6 rtc: Add support for the RTC in VIA VT8500 and compatibles
This adds a driver for the RTC devices in VIA and WonderMedia Systems-on-Chip. Alarm, 1Hz interrupts, reading and setting time are supported.
---
Thanks for the comments, Lars! This version implements the latest ones as well.
Best regards,
Alexey
drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-vt8500.c | 359 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 367 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-vt8500.c
drivers/rtc/Kconfig +7 -0
@@ -865,6 +865,13 @@ config RTC_DRV_PXA This RTC driver uses PXA RTC registers available since pxa27x series (RDxR, RYxR) instead of legacy RCNR, RTAR. +config RTC_DRV_VT8500 + tristate "VIA/WonderMedia 85xx SoC RTC" + depends on ARCH_VT8500 + help + If you say Y here you will get access to the real time clock + built into your VIA VT8500 SoC or its relatives. + config RTC_DRV_SUN4V bool "SUN4V Hypervisor RTC"
drivers/rtc/Makefile +1 -0
@@ -97,6 +97,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o +obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
drivers/rtc/rtc-vt8500.c new file +359 -0
359 lines not on this page · raw message
Signature · 1 line
1.7.3.2
Alexey Charkov
maintainerRe: [PATCH 5/6 v4] rtc: Add support for the RTC in VIA VT8500 and compatibles
2010/11/14 Alexey Charkov <[email protected]>:
Quoted 415 lines
This adds a driver for the RTC devices in VIA and WonderMedia Systems-on-Chip. Alarm, 1Hz interrupts, reading and setting time are supported.
Signed-off-by Alexey Charkov <[email protected]>---
Thanks for the comments, Lars! This version implements the latest ones as well.
Best regards,
Alexey?drivers/rtc/Kconfig ? ? ?| ? ?7 + ?drivers/rtc/Makefile ? ? | ? ?1 + ?drivers/rtc/rtc-vt8500.c | ?359 ++++++++++++++++++++++++++++++++++++++++++++++?3 files changed, 367 insertions(+), 0 deletions(-) ?create mode 100644
drivers/rtc/rtc-vt8500.cdrivers/rtc/Kconfig +0
-0@@ -865,6 +865,13 @@ config RTC_DRV_PXA? ? ? ? ?This RTC driver uses PXA RTC registers available since pxa27x ? ? ? ? ?series (RDxR, RYxR) instead of legacy RCNR, RTAR.
drivers/rtc/Kconfig +7
-0+config RTC_DRV_VT8500 + ? ? ? tristate "VIA/WonderMedia 85xx SoC RTC" + ? ? ? depends on ARCH_VT8500 + ? ? ? help + ? ? ? ? If you say Y here you will get access to the real time clock + ? ? ? ? built into your VIA VT8500 SoC or its relatives. +?config
RTC_DRV_SUN4V
? ? ? ?bool "SUN4V Hypervisor RTC"drivers/rtc/Makefile +0
-0@@ -97,6 +97,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o?obj-$(CONFIG_RTC_DRV_TX4939) ? += rtc-tx4939.o
?obj-$(CONFIG_RTC_DRV_V3020) ? ?+= rtc-v3020.o
?obj-$(CONFIG_RTC_DRV_VR41XX) ? += rtc-vr41xx.o
+obj-$(CONFIG_RTC_DRV_VT8500) ? += rtc-vt8500.o
?obj-$(CONFIG_RTC_DRV_WM831X) ? += rtc-wm831x.o
?obj-$(CONFIG_RTC_DRV_WM8350) ? += rtc-wm8350.o
?obj-$(CONFIG_RTC_DRV_X1205) ? ?+= rtc-x1205.odrivers/rtc/rtc-vt8500.c new file +359
-1@@ -0,0 +1,359 @@ +/* +* drivers/rtc/rtc-vt8500.c +* +* ?Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* Based on rtc-pxa.c +* +* 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/rtc.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/bcd.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +/* +* Register definitions +*/ +#define VT8500_RTC_TS ? ? ? ? ?0x00 ? ?/* Time set */ +#define VT8500_RTC_DS ? ? ? ? ?0x04 ? ?/* Date set */ +#define VT8500_RTC_AS ? ? ? ? ?0x08 ? ?/* Alarm set */ +#define VT8500_RTC_CR ? ? ? ? ?0x0c ? ?/* Control */ +#define VT8500_RTC_TR ? ? ? ? ?0x10 ? ?/* Time read */ +#define VT8500_RTC_DR ? ? ? ? ?0x14 ? ?/* Date read */ +#define VT8500_RTC_WS ? ? ? ? ?0x18 ? ?/* Write status */ +#define VT8500_RTC_CL ? ? ? ? ?0x20 ? ?/* Calibration */ +#define VT8500_RTC_IS ? ? ? ? ?0x24 ? ?/* Interrupt status */ +#define VT8500_RTC_ST ? ? ? ? ?0x28 ? ?/* Status */ + +#define INVALID_TIME_BIT ? ? ? (1 << 31) + +#define DATE_CENTURY_S ? ? ? ? 19 +#define DATE_YEAR_S ? ? ? ? ? ?11 +#define DATE_YEAR_MASK ? ? ? ? (0xff << DATE_YEAR_S) +#define DATE_MONTH_S ? ? ? ? ? 6 +#define DATE_MONTH_MASK ? ? ? ? ? ? ? ?(0x1f << DATE_MONTH_S) +#define DATE_DAY_MASK ? ? ? ? ?0x3f + +#define TIME_DOW_S ? ? ? ? ? ? 20 +#define TIME_DOW_MASK ? ? ? ? ?(0x07 << TIME_DOW_S) +#define TIME_HOUR_S ? ? ? ? ? ?14 +#define TIME_HOUR_MASK ? ? ? ? (0x3f << TIME_HOUR_S) +#define TIME_MIN_S ? ? ? ? ? ? 7 +#define TIME_MIN_MASK ? ? ? ? ?(0x7f << TIME_MIN_S) +#define TIME_SEC_MASK ? ? ? ? ?0x7f + +#define ALARM_DAY_S ? ? ? ? ? ?20 +#define ALARM_DAY_MASK ? ? ? ? (0x3f << ALARM_DAY_S) + +#define ALARM_DAY_BIT ? ? ? ? ?(1 << 29) +#define ALARM_HOUR_BIT ? ? ? ? (1 << 28) +#define ALARM_MIN_BIT ? ? ? ? ?(1 << 27) +#define ALARM_SEC_BIT ? ? ? ? ?(1 << 26) + +#define ALARM_ENABLE_MASK ? ? ?(ALARM_DAY_BIT \ + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ALARM_HOUR_BIT \ + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ALARM_MIN_BIT \ + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ALARM_SEC_BIT) + +#define VT8500_RTC_CR_ENABLE ? (1 << 0) ? ? ? ?/* Enable RTC */ +#define VT8500_RTC_CR_24H ? ? ?(1 << 1) ? ? ? ?/* 24h time format */ +#define VT8500_RTC_CR_SM_ENABLE ? ? ? ?(1 << 2) ? ? ? ?/* Enable periodic irqs */ +#define VT8500_RTC_CR_SM_SEC ? (1 << 3) ? ? ? ?/* 0: 1Hz/60, 1: 1Hz */ +#define VT8500_RTC_CR_CALIB ? ?(1 << 4) ? ? ? ?/* Enable calibration */ + +struct vt8500_rtc { + ? ? ? void __iomem ? ? ? ? ? ?*regbase; + ? ? ? int ? ? ? ? ? ? ? ? ? ? irq_alarm; + ? ? ? int ? ? ? ? ? ? ? ? ? ? irq_hz; + ? ? ? struct rtc_device ? ? ? *rtc; + ? ? ? spinlock_t ? ? ? ? ? ? ?lock; ? ? ? ? ? /* Protects this structure */ +}; + +static irqreturn_t vt8500_rtc_irq (int irq,void *dev_id) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_id; + ? ? ? u32 isr; + ? ? ? unsigned long events = 0; + + ? ? ? spin_lock(&vt8500_rtc->lock); + + ? ? ? /* clear interrupt sources */ + ? ? ? isr = readl(vt8500_rtc->regbase + VT8500_RTC_IS); + ? ? ? writel(isr, vt8500_rtc->regbase + VT8500_RTC_IS); + + ? ? ? spin_unlock(&vt8500_rtc->lock); + + ? ? ? if (isr & 1) + ? ? ? ? ? ? ? events |= RTC_AF | RTC_IRQF; + + ? ? ? /* Only second/minute interrupts are supported */ + ? ? ? if (isr & 2) + ? ? ? ? ? ? ? events |= RTC_UF | RTC_IRQF; + + ? ? ? rtc_update_irq(vt8500_rtc->rtc, 1, events); + + ? ? ? return IRQ_HANDLED; +} + +static int vt8500_rtc_read_time (struct device *dev,struct rtc_time *tm) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + ? ? ? u32 date, time; + + ? ? ? if (!readl(vt8500_rtc->regbase + VT8500_RTC_ST)) { + ? ? ? ? ? ? ? dev_info(dev, "Clock not set!"); + ? ? ? ? ? ? ? return -EINVAL; + ? ? ? } + ? ? ? date = readl(vt8500_rtc->regbase + VT8500_RTC_DR); + ? ? ? time = readl(vt8500_rtc->regbase + VT8500_RTC_TR); + + ? ? ? tm->tm_sec = bcd2bin(time & TIME_SEC_MASK); + ? ? ? 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_year = bcd2bin((date & DATE_YEAR_MASK) >> DATE_YEAR_S); + ? ? ? tm->tm_wday = (time & TIME_DOW_MASK) >> TIME_DOW_S; + + ? ? ? return rtc_valid_tm(tm); +} + +static int vt8500_rtc_set_time (struct device *dev,struct rtc_time *tm) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + + ? ? ? writel((bin2bcd(tm->tm_year) << DATE_YEAR_S) + ? ? ? ? ? ? ? | (bin2bcd(tm->tm_mon) << DATE_MONTH_S) + ? ? ? ? ? ? ? | (bin2bcd(tm->tm_mday)), + ? ? ? ? ? ? ? vt8500_rtc->regbase + VT8500_RTC_DS); + ? ? ? writel((bin2bcd(tm->tm_wday) << TIME_DOW_S) + ? ? ? ? ? ? ? | (bin2bcd(tm->tm_hour) << TIME_HOUR_S) + ? ? ? ? ? ? ? | (bin2bcd(tm->tm_min) << TIME_MIN_S) + ? ? ? ? ? ? ? | (bin2bcd(tm->tm_sec)), + ? ? ? ? ? ? ? vt8500_rtc->regbase + VT8500_RTC_TS); + + ? ? ? return 0; +} + +static int vt8500_rtc_read_alarm (struct device *dev,struct rtc_wkalrm *alrm) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + ? ? ? u32 isr, alarm; + + ? ? ? alarm = readl(vt8500_rtc->regbase + VT8500_RTC_AS); + ? ? ? isr = readl(vt8500_rtc->regbase + VT8500_RTC_IS); + + ? ? ? alrm->time.tm_mday = bcd2bin((alarm & ALARM_DAY_MASK) >> ALARM_DAY_S); + ? ? ? alrm->time.tm_hour = bcd2bin((alarm & TIME_HOUR_MASK) >> TIME_HOUR_S); + ? ? ? alrm->time.tm_min = bcd2bin((alarm & TIME_MIN_MASK) >> TIME_MIN_S); + ? ? ? alrm->time.tm_sec = bcd2bin((alarm & TIME_SEC_MASK)); + + ? ? ? alrm->enabled = (alarm & ALARM_ENABLE_MASK) ? 1 : 0; + + ? ? ? alrm->pending = (isr & 1) ? 1 : 0; + ? ? ? return rtc_valid_tm(&alrm->time); +} + +static int vt8500_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alrm) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + + ? ? ? writel((alrm->enabled ? ALARM_ENABLE_MASK : 0) + ? ? ? ? ? ? ? | (bin2bcd(alrm->time.tm_mday) << ALARM_DAY_S) + ? ? ? ? ? ? ? | (bin2bcd(alrm->time.tm_hour) << TIME_HOUR_S) + ? ? ? ? ? ? ? | (bin2bcd(alrm->time.tm_min) << TIME_MIN_S) + ? ? ? ? ? ? ? | (bin2bcd(alrm->time.tm_sec)), + ? ? ? ? ? ? ? vt8500_rtc->regbase + VT8500_RTC_AS); + + ? ? ? return 0; +} + +static int vt8500_alarm_irq_enable (struct device *dev,unsigned int enabled) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + ? ? ? unsigned long tmp = readl(vt8500_rtc->regbase + VT8500_RTC_AS); + + ? ? ? if (enabled) + ? ? ? ? ? ? ? tmp |= ALARM_ENABLE_MASK; + ? ? ? else + ? ? ? ? ? ? ? tmp &= ~ALARM_ENABLE_MASK; + + ? ? ? writel(tmp, vt8500_rtc->regbase + VT8500_RTC_AS); + ? ? ? return 0; +} + +static int vt8500_update_irq_enable (struct device *dev,unsigned int enabled) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + ? ? ? unsigned long tmp = readl(vt8500_rtc->regbase + VT8500_RTC_CR); + + ? ? ? if (enabled) + ? ? ? ? ? ? ? tmp |= VT8500_RTC_CR_SM_SEC | VT8500_RTC_CR_SM_ENABLE; + ? ? ? else + ? ? ? ? ? ? ? tmp &= ~VT8500_RTC_CR_SM_ENABLE; + + ? ? ? writel(tmp, vt8500_rtc->regbase + VT8500_RTC_CR); + ? ? ? return 0; +} + +static const struct rtc_class_ops vt8500_rtc_ops = { + ? ? ? .read_time = vt8500_rtc_read_time, + ? ? ? .set_time = vt8500_rtc_set_time, + ? ? ? .read_alarm = vt8500_rtc_read_alarm, + ? ? ? .set_alarm = vt8500_rtc_set_alarm, + ? ? ? .alarm_irq_enable = vt8500_alarm_irq_enable, + ? ? ? .update_irq_enable = vt8500_update_irq_enable, +}; + +static int __devinit vt8500_rtc_probe (struct platform_device *pdev) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc; + ? ? ? struct resource *res; + ? ? ? int ret; + + ? ? ? vt8500_rtc = kzalloc(sizeof(struct vt8500_rtc), GFP_KERNEL); + ? ? ? if (!vt8500_rtc) + ? ? ? ? ? ? ? return -ENOMEM; + + ? ? ? spin_lock_init(&vt8500_rtc->lock); + ? ? ? platform_set_drvdata(pdev, vt8500_rtc); + + ? ? ? res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + ? ? ? if (!res) { + ? ? ? ? ? ? ? dev_err(&pdev->dev, "No I/O memory resource defined\n"); + ? ? ? ? ? ? ? ret = -ENXIO; + ? ? ? ? ? ? ? goto err_free; + ? ? ? } + + ? ? ? vt8500_rtc->irq_alarm = platform_get_irq(pdev, 0); + ? ? ? if (vt8500_rtc->irq_alarm < 0) { + ? ? ? ? ? ? ? dev_err(&pdev->dev, "No alarm IRQ resource defined\n"); + ? ? ? ? ? ? ? ret = -ENXIO; + ? ? ? ? ? ? ? goto err_free; + ? ? ? } + + ? ? ? vt8500_rtc->irq_hz = platform_get_irq(pdev, 1); + ? ? ? if (vt8500_rtc->irq_hz < 0) { + ? ? ? ? ? ? ? dev_err(&pdev->dev, "No 1Hz IRQ resource defined\n"); + ? ? ? ? ? ? ? ret = -ENXIO; + ? ? ? ? ? ? ? goto err_free; + ? ? ? } + + ? ? ? res = request_mem_region(res->start, resource_size(res), "vt8500-rtc"); + ? ? ? if (res == NULL) { + ? ? ? ? ? ? ? dev_err(&pdev->dev, "failed to request I/O memory\n"); + ? ? ? ? ? ? ? ret = -EBUSY; + ? ? ? ? ? ? ? goto err_free; + ? ? ? } + + ? ? ? vt8500_rtc->regbase = ioremap(res->start, resource_size(res)); + ? ? ? if (!vt8500_rtc->regbase) { + ? ? ? ? ? ? ? dev_err(&pdev->dev, "Unable to map RTC I/O memory\n"); + ? ? ? ? ? ? ? ret = -EBUSY; + ? ? ? ? ? ? ? goto err_release; + ? ? ? } + + ? ? ? /* Enable the second/minute interrupt generation and enable RTC */ + ? ? ? writel(VT8500_RTC_CR_ENABLE | VT8500_RTC_CR_24H + ? ? ? ? ? ? ? | VT8500_RTC_CR_SM_ENABLE | VT8500_RTC_CR_SM_SEC, + ? ? ? ? ? ? ?vt8500_rtc->regbase + VT8500_RTC_CR); + + ? ? ? vt8500_rtc->rtc = rtc_device_register("vt8500-rtc", &pdev->dev, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &vt8500_rtc_ops, THIS_MODULE); + ? ? ? if (IS_ERR(vt8500_rtc->rtc)) { + ? ? ? ? ? ? ? ret = PTR_ERR(vt8500_rtc->rtc); + ? ? ? ? ? ? ? dev_err(&pdev->dev, + ? ? ? ? ? ? ? ? ? ? ? "Failed to register RTC device -> %d\n", ret); + ? ? ? ? ? ? ? goto err_unmap; + ? ? ? } + + ? ? ? ret = request_irq(vt8500_rtc->irq_hz, vt8500_rtc_irq, 0, + ? ? ? ? ? ? ? ? ? ? ? ? "rtc 1Hz", vt8500_rtc); + ? ? ? if (ret < 0) { + ? ? ? ? ? ? ? dev_err(&pdev->dev, "can't get irq %i, err %d\n", + ? ? ? ? ? ? ? ? ? ? ? vt8500_rtc->irq_hz, ret); + ? ? ? ? ? ? ? goto err_unreg; + ? ? ? } + + ? ? ? ret = request_irq(vt8500_rtc->irq_alarm, vt8500_rtc_irq, 0, + ? ? ? ? ? ? ? ? ? ? ? ? "rtc alarm", vt8500_rtc); + ? ? ? if (ret < 0) { + ? ? ? ? ? ? ? dev_err(&pdev->dev, "can't get irq %i, err %d\n", + ? ? ? ? ? ? ? ? ? ? ? vt8500_rtc->irq_alarm, ret); + ? ? ? ? ? ? ? goto err_free_hz; + ? ? ? } + + ? ? ? return 0; + +err_free_hz: + ? ? ? free_irq(vt8500_rtc->irq_hz, vt8500_rtc); +err_unreg: + ? ? ? rtc_device_unregister(vt8500_rtc->rtc); +err_unmap: + ? ? ? iounmap(vt8500_rtc->regbase); +err_release: + ? ? ? release_mem_region(res->start, resource_size(res)); +err_free: + ? ? ? kfree(vt8500_rtc); + ? ? ? return ret; +} + +static int __devexit vt8500_rtc_remove(struct platform_device *pdev) +{ + ? ? ? struct vt8500_rtc *vt8500_rtc = platform_get_drvdata(pdev); + ? ? ? struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + ? ? ? free_irq(vt8500_rtc->irq_alarm, vt8500_rtc); + ? ? ? free_irq(vt8500_rtc->irq_hz, vt8500_rtc); + + ? ? ? rtc_device_unregister(vt8500_rtc->rtc); + + ? ? ? /* Disable alarm matching */ + ? ? ? writel(0, vt8500_rtc->regbase + VT8500_RTC_IS); + ? ? ? iounmap(vt8500_rtc->regbase); + ? ? ? release_mem_region(res->start, resource_size(res)); + + ? ? ? kfree(vt8500_rtc); + ? ? ? platform_set_drvdata(pdev, NULL); + + ? ? ? return 0; +} + +static struct platform_driver vt8500_rtc_driver = { + ? ? ? .probe ? ? ? ? ?= vt8500_rtc_probe, + ? ? ? .remove ? ? ? ? = __devexit_p(vt8500_rtc_remove), + ? ? ? .driver ? ? ? ? = { + ? ? ? ? ? ? ? .name ? = "vt8500-rtc", + ? ? ? ? ? ? ? .owner ?= THIS_MODULE, + ? ? ? }, +}; + +static int __init vt8500_rtc_init (void ) +{ + ? ? ? return platform_driver_register(&vt8500_rtc_driver); +} +module_init (vt8500_rtc_init); + +static void __exit vt8500_rtc_exit(void) +{ + ? ? ? platform_driver_unregister(&vt8500_rtc_driver); +} +module_exit (vt8500_rtc_exit); + +MODULE_AUTHOR ("Alexey Charkov <[email protected]>" ); +MODULE_DESCRIPTION ("VIA VT8500 SoC Realtime Clock Driver (RTC)" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:vt8500-rtc" ); --
Quoted 3 lines
1.7.3.2
Any further comments about this code? Could it be merged now?
Lars, sorry for double-posting this (forgot to CC the lists and others last time).
Thanks,
Alexey
Lars-Peter Clausen
Reviewed-byRe: [PATCH 5/6 v4] rtc: Add support for the RTC in VIA VT8500 and compatibles
Quoted 422 lines · Alexey Charkov
2010/11/14 Alexey Charkov <[email protected]>:
Quoted 415 lines
This adds a driver for the RTC devices in VIA and WonderMedia Systems-on-Chip. Alarm, 1Hz interrupts, reading and setting time are supported.
Signed-off-by Alexey Charkov <[email protected]>---
Thanks for the comments, Lars! This version implements the latest ones as well.
Best regards,
Alexeydrivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-vt8500.c | 359 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 367 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-vt8500.cdrivers/rtc/Kconfig +7
-0@@ -865,6 +865,13 @@ config RTC_DRV_PXA This RTC driver uses PXA RTC registers available since pxa27x series (RDxR, RYxR) instead of legacy RCNR, RTAR. +config RTC_DRV_VT8500 + tristate "VIA/WonderMedia 85xx SoC RTC" + depends on ARCH_VT8500 + help + If you say Y here you will get access to the real time clock + built into your VIA VT8500 SoC or its relatives. + config RTC_DRV_SUN4V bool "SUN4V Hypervisor RTC"drivers/rtc/Makefile +1
-0@@ -97,6 +97,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o +obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.odrivers/rtc/rtc-vt8500.c new file +359
-1@@ -0,0 +1,359 @@ +/* +* drivers/rtc/rtc-vt8500.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* Based on rtc-pxa.c +* +* 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/rtc.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/bcd.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +/* +* Register definitions +*/ +#define VT8500_RTC_TS 0x00/* Time set */ +#define VT8500_RTC_DS 0x04/* Date set */ +#define VT8500_RTC_AS 0x08/* Alarm set */ +#define VT8500_RTC_CR 0x0c/* Control */ +#define VT8500_RTC_TR 0x10/* Time read */ +#define VT8500_RTC_DR 0x14/* Date read */ +#define VT8500_RTC_WS 0x18/* Write status */ +#define VT8500_RTC_CL 0x20/* Calibration */ +#define VT8500_RTC_IS 0x24/* Interrupt status */ +#define VT8500_RTC_ST 0x28/* Status */ + +#define INVALID_TIME_BIT (1 << 31) + +#define DATE_CENTURY_S 19 +#define DATE_YEAR_S 11 +#define DATE_YEAR_MASK (0xff << DATE_YEAR_S) +#define DATE_MONTH_S 6 +#define DATE_MONTH_MASK (0x1f << DATE_MONTH_S) +#define DATE_DAY_MASK 0x3f + +#define TIME_DOW_S 20 +#define TIME_DOW_MASK (0x07 << TIME_DOW_S) +#define TIME_HOUR_S 14 +#define TIME_HOUR_MASK (0x3f << TIME_HOUR_S) +#define TIME_MIN_S 7 +#define TIME_MIN_MASK (0x7f << TIME_MIN_S) +#define TIME_SEC_MASK 0x7f + +#define ALARM_DAY_S 20 +#define ALARM_DAY_MASK (0x3f << ALARM_DAY_S) + +#define ALARM_DAY_BIT (1 << 29) +#define ALARM_HOUR_BIT (1 << 28) +#define ALARM_MIN_BIT (1 << 27) +#define ALARM_SEC_BIT (1 << 26) + +#define ALARM_ENABLE_MASK (ALARM_DAY_BIT \ + | ALARM_HOUR_BIT \ + | ALARM_MIN_BIT \ + | ALARM_SEC_BIT) + +#define VT8500_RTC_CR_ENABLE (1 << 0)/* Enable RTC */ +#define VT8500_RTC_CR_24H (1 << 1)/* 24h time format */ +#define VT8500_RTC_CR_SM_ENABLE (1 << 2)/* Enable periodic irqs */ +#define VT8500_RTC_CR_SM_SEC (1 << 3)/* 0: 1Hz/60, 1: 1Hz */ +#define VT8500_RTC_CR_CALIB (1 << 4)/* Enable calibration */ + +struct vt8500_rtc { +void __iomem *regbase; +int irq_alarm; +int irq_hz; +struct rtc_device *rtc; +spinlock_t lock;/* Protects this structure */ +}; + +static irqreturn_t vt8500_rtc_irq (int irq,void *dev_id) +{ +struct vt8500_rtc *vt8500_rtc = dev_id; +u32 isr; +unsigned long events =0 ; + +spin_lock (&vt8500_rtc->lock); + +/* clear interrupt sources */ + isr =readl (vt8500_rtc->regbase +VT8500_RTC_IS ); +writel (isr, vt8500_rtc->regbase +VT8500_RTC_IS ); + +spin_unlock (&vt8500_rtc->lock); + +if (isr &1 ) + events |=RTC_AF |RTC_IRQF ; + +/* Only second/minute interrupts are supported */ +if (isr &2 ) + events |=RTC_UF |RTC_IRQF ; + +rtc_update_irq (vt8500_rtc->rtc,1 , events); + +return IRQ_HANDLED ; +} + +static int vt8500_rtc_read_time (struct device *dev,struct rtc_time *tm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +u32 date, time; + +if (!readl (vt8500_rtc->regbase +VT8500_RTC_ST )) { +dev_info (dev,"Clock not set!" ); +return -EINVAL ; + } + date =readl (vt8500_rtc->regbase +VT8500_RTC_DR ); + time =readl (vt8500_rtc->regbase +VT8500_RTC_TR ); + + tm->tm_sec =bcd2bin (time &TIME_SEC_MASK ); + 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_year =bcd2bin ((date &DATE_YEAR_MASK ) >>DATE_YEAR_S ); + tm->tm_wday = (time &TIME_DOW_MASK ) >>TIME_DOW_S ; + +return rtc_valid_tm (tm); +} + +static int vt8500_rtc_set_time (struct device *dev,struct rtc_time *tm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); + +writel ((bin2bcd (tm->tm_year) <<DATE_YEAR_S ) + | (bin2bcd (tm->tm_mon) <<DATE_MONTH_S ) + | (bin2bcd (tm->tm_mday)), + vt8500_rtc->regbase +VT8500_RTC_DS ); +writel ((bin2bcd (tm->tm_wday) <<TIME_DOW_S ) + | (bin2bcd (tm->tm_hour) <<TIME_HOUR_S ) + | (bin2bcd (tm->tm_min) <<TIME_MIN_S ) + | (bin2bcd (tm->tm_sec)), + vt8500_rtc->regbase +VT8500_RTC_TS ); + +return 0 ; +} + +static int vt8500_rtc_read_alarm (struct device *dev,struct rtc_wkalrm *alrm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +u32 isr, alarm; + + alarm =readl (vt8500_rtc->regbase +VT8500_RTC_AS ); + isr =readl (vt8500_rtc->regbase +VT8500_RTC_IS ); + + alrm->time.tm_mday =bcd2bin ((alarm &ALARM_DAY_MASK ) >>ALARM_DAY_S ); + alrm->time.tm_hour =bcd2bin ((alarm &TIME_HOUR_MASK ) >>TIME_HOUR_S ); + alrm->time.tm_min =bcd2bin ((alarm &TIME_MIN_MASK ) >>TIME_MIN_S ); + alrm->time.tm_sec =bcd2bin ((alarm &TIME_SEC_MASK )); + + alrm->enabled = (alarm &ALARM_ENABLE_MASK ) ?1 :0 ; + + alrm->pending = (isr &1 ) ?1 :0 ; +return rtc_valid_tm (&alrm->time); +} + +static int vt8500_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alrm) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); + +writel ((alrm->enabled ?ALARM_ENABLE_MASK :0 ) + | (bin2bcd (alrm->time.tm_mday) <<ALARM_DAY_S ) + | (bin2bcd (alrm->time.tm_hour) <<TIME_HOUR_S ) + | (bin2bcd (alrm->time.tm_min) <<TIME_MIN_S ) + | (bin2bcd (alrm->time.tm_sec)), + vt8500_rtc->regbase +VT8500_RTC_AS ); + +return 0 ; +} + +static int vt8500_alarm_irq_enable (struct device *dev,unsigned int enabled) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +unsigned long tmp =readl (vt8500_rtc->regbase +VT8500_RTC_AS ); + +if (enabled) + tmp |=ALARM_ENABLE_MASK ; +else + tmp &= ~ALARM_ENABLE_MASK ; + +writel (tmp, vt8500_rtc->regbase +VT8500_RTC_AS ); +return 0 ; +} + +static int vt8500_update_irq_enable (struct device *dev,unsigned int enabled) +{ +struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); +unsigned long tmp =readl (vt8500_rtc->regbase +VT8500_RTC_CR ); + +if (enabled) + tmp |=VT8500_RTC_CR_SM_SEC |VT8500_RTC_CR_SM_ENABLE ; +else + tmp &= ~VT8500_RTC_CR_SM_ENABLE ; + +writel (tmp, vt8500_rtc->regbase +VT8500_RTC_CR ); +return 0 ; +} + +static const struct rtc_class_ops vt8500_rtc_ops = { + .read_time = vt8500_rtc_read_time, + .set_time = vt8500_rtc_set_time, + .read_alarm = vt8500_rtc_read_alarm, + .set_alarm = vt8500_rtc_set_alarm, + .alarm_irq_enable = vt8500_alarm_irq_enable, + .update_irq_enable = vt8500_update_irq_enable, +}; + +static int __devinit vt8500_rtc_probe (struct platform_device *pdev) +{ +struct vt8500_rtc *vt8500_rtc; +struct resource *res; +int ret; + + vt8500_rtc =kzalloc (sizeof (struct vt8500_rtc ),GFP_KERNEL ); +if (!vt8500_rtc) +return -ENOMEM ; + +spin_lock_init (&vt8500_rtc->lock); +platform_set_drvdata (pdev, vt8500_rtc); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (&pdev->dev,"No I/O memory resource defined\n" ); + ret = -ENXIO ; + goto err_free; + } + + vt8500_rtc->irq_alarm =platform_get_irq (pdev,0 ); +if (vt8500_rtc->irq_alarm <0 ) { +dev_err (&pdev->dev,"No alarm IRQ resource defined\n" ); + ret = -ENXIO ; + goto err_free; + } + + vt8500_rtc->irq_hz =platform_get_irq (pdev,1 ); +if (vt8500_rtc->irq_hz <0 ) { +dev_err (&pdev->dev,"No 1Hz IRQ resource defined\n" ); + ret = -ENXIO ; + goto err_free; + } + + res =request_mem_region (res->start,resource_size (res),"vt8500-rtc" ); +if (res ==NULL ) { +dev_err (&pdev->dev,"failed to request I/O memory\n" ); + ret = -EBUSY ; + goto err_free; + } + + vt8500_rtc->regbase =ioremap (res->start,resource_size (res)); +if (!vt8500_rtc->regbase) { +dev_err (&pdev->dev,"Unable to map RTC I/O memory\n" ); + ret = -EBUSY ; + goto err_release; + } + +/* Enable the second/minute interrupt generation and enable RTC */ +writel (VT8500_RTC_CR_ENABLE |VT8500_RTC_CR_24H + |VT8500_RTC_CR_SM_ENABLE |VT8500_RTC_CR_SM_SEC , + vt8500_rtc->regbase +VT8500_RTC_CR ); + + vt8500_rtc->rtc =rtc_device_register ("vt8500-rtc" , &pdev->dev, + &vt8500_rtc_ops,THIS_MODULE ); +if (IS_ERR (vt8500_rtc->rtc)) { + ret =PTR_ERR (vt8500_rtc->rtc); +dev_err (&pdev->dev, +"Failed to register RTC device -> %d\n" , ret); + goto err_unmap; + } + + ret =request_irq (vt8500_rtc->irq_hz, vt8500_rtc_irq,0 , +"rtc 1Hz" , vt8500_rtc); +if (ret <0 ) { +dev_err (&pdev->dev,"can't get irq %i, err %d\n" , + vt8500_rtc->irq_hz, ret); + goto err_unreg; + } + + ret =request_irq (vt8500_rtc->irq_alarm, vt8500_rtc_irq,0 , +"rtc alarm" , vt8500_rtc); +if (ret <0 ) { +dev_err (&pdev->dev,"can't get irq %i, err %d\n" , + vt8500_rtc->irq_alarm, ret); + goto err_free_hz; + } + +return 0 ; + +err_free_hz: +free_irq (vt8500_rtc->irq_hz, vt8500_rtc); +err_unreg: +rtc_device_unregister (vt8500_rtc->rtc); +err_unmap: +iounmap (vt8500_rtc->regbase); +err_release: +release_mem_region (res->start,resource_size (res)); +err_free: +kfree (vt8500_rtc); +return ret; +} + +static int __devexit vt8500_rtc_remove(struct platform_device *pdev) +{ +struct vt8500_rtc *vt8500_rtc =platform_get_drvdata (pdev); +struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + +free_irq (vt8500_rtc->irq_alarm, vt8500_rtc); +free_irq (vt8500_rtc->irq_hz, vt8500_rtc); + +rtc_device_unregister (vt8500_rtc->rtc); + +/* Disable alarm matching */ +writel (0 , vt8500_rtc->regbase +VT8500_RTC_IS ); +iounmap (vt8500_rtc->regbase); +release_mem_region (res->start,resource_size (res)); + +kfree (vt8500_rtc); +platform_set_drvdata (pdev,NULL ); + +return 0 ; +} + +static struct platform_driver vt8500_rtc_driver = { + .probe = vt8500_rtc_probe, + .remove =__devexit_p (vt8500_rtc_remove), + .driver = { + .name ="vt8500-rtc" , + .owner =THIS_MODULE , + }, +}; + +static int __init vt8500_rtc_init (void ) +{ +return platform_driver_register (&vt8500_rtc_driver); +} +module_init (vt8500_rtc_init); + +static void __exit vt8500_rtc_exit(void) +{ +platform_driver_unregister (&vt8500_rtc_driver); +} +module_exit (vt8500_rtc_exit); + +MODULE_AUTHOR ("Alexey Charkov <[email protected]>" ); +MODULE_DESCRIPTION ("VIA VT8500 SoC Realtime Clock Driver (RTC)" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:vt8500-rtc" ); --Quoted 3 lines
1.7.3.2
Any further comments about this code? Could it be merged now?
Quoted 2 lines
Lars, sorry for double-posting this (forgot to CC the lists and others last time).
Looks good to me, except one small thing: request_mem_region allocates the resource struct it returns. You should pass the same struct to release_mem_region to free it again.
When that is fixed feel free to add a
Quoted 3 lines
Thanks,
Alexey
Alexey Charkov
maintainerPATCH v5 5/6 rtc: Add support for the RTC in VIA VT8500 and compatibles
This adds a driver for the RTC devices in VIA and WonderMedia Systems-on-Chip. Alarm, 1Hz interrupts, reading and setting time are supported.
---
This fixes the issue with releasing the resource mentioned by Lars.
In addition, I've fixed the years range to reflect what the hardware seems to actually expect (2000-2199 instead of 1900-... as implied by prior code). In the process, it turned out that using rtc_valid_tm() when reading time precludes any obvious recovery path if for some reason the hardware contains garbage at kernel initialization: hwclock -w tries to read time before updating, and fails. However, bad time values are handled gracefully by the userspace, so I just put in 'return 0' there. In-kernel hctosys also checks the returned time, so this seems to be valid behaviour.
Reading alarm values still returns through rtc_valid_tm().
Thanks,
Alexey
drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-vt8500.c | 366 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 374 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-vt8500.c
drivers/rtc/Kconfig +7 -0
@@ -865,6 +865,13 @@ config RTC_DRV_PXA This RTC driver uses PXA RTC registers available since pxa27x series (RDxR, RYxR) instead of legacy RCNR, RTAR. +config RTC_DRV_VT8500 + tristate "VIA/WonderMedia 85xx SoC RTC" + depends on ARCH_VT8500 + help + If you say Y here you will get access to the real time clock + built into your VIA VT8500 SoC or its relatives. + config RTC_DRV_SUN4V bool "SUN4V Hypervisor RTC"
drivers/rtc/Makefile +1 -0
@@ -97,6 +97,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o +obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
drivers/rtc/rtc-vt8500.c new file +366 -0
366 lines not on this page · raw message
Signature · 1 line
1.7.3.2
Alexey Charkov
maintainerPATCH v2 6/6 ARM: Add support for the display controllers in VT8500 and WM8505
In reply to Alexey CharkovThis adds drivers for the LCD controller found in VIA VT8500 SoC, GOVR display controller found in WonderMedia WM8505 SoC and for the Graphics Engine present in both of them that provides hardware accelerated raster operations (used for copyarea and fillrect).
---
Please review and (if appropriate) commit to a relevant git tree for further integration in 2.6.38.
Compared to the previous submission, this code just contains a rebase against the latest changes introduced in 2.6.37 merge window.
Relevant platform definitions are introduced by PATCH 1/6 in this series, so one would need that to make use of this code.
Due credits go to the community for providing feedback, advice and testing. Driver for WM8505 is by Ed Spiridonov, as stated in the relevant copyright header, parts modified by myself.
Invaluable work wrt the Graphics Engine documentation has been done by Giuseppe Gatta aka nextvolume. Also special thanks go to Angus Gratton aka projectgus for convincing VIA to partly release GPL kernel sources for the vendor-provided images, which greatly helped in understanding some parts of WM8505's complex video handling chain.
drivers/video/Kconfig | 26 +++ drivers/video/Makefile | 3 + drivers/video/vt8500lcdfb.c | 452 +++++++++++++++++++++++++++++++++++++++++ drivers/video/vt8500lcdfb.h | 34 +++ drivers/video/wm8505fb.c | 438 +++++++++++++++++++++++++++++++++++++++ drivers/video/wm8505fb_regs.h | 76 +++++++ drivers/video/wmt_ge_rops.c | 186 +++++++++++++++++ drivers/video/wmt_ge_rops.h | 5 + 8 files changed, 1220 insertions(+), 0 deletions(-) create mode 100644 drivers/video/vt8500lcdfb.c create mode 100644 drivers/video/vt8500lcdfb.h create mode 100644 drivers/video/wm8505fb.c create mode 100644 drivers/video/wm8505fb_regs.h create mode 100644 drivers/video/wmt_ge_rops.c create mode 100644 drivers/video/wmt_ge_rops.h
drivers/video/Kconfig +26 -0
@@ -186,6 +186,14 @@ 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
@@ -1722,6 +1730,24 @@ config FB_AU1200 various panels and CRTs by passing in kernel cmd line option au1200fb:panel=<name>. +config FB_VT8500 + bool "VT8500 LCD Driver" + depends on (FB = y) && ARM && ARCH_VT8500 && VTWM_VERSION_VT8500 + select FB_WMT_GE_ROPS + select FB_SYS_IMAGEBLIT + help + This is the framebuffer driver for VIA VT8500 integrated LCD + controller. + +config FB_WM8505 + bool "WM8505 frame buffer support" + depends on (FB = y) && ARM && ARCH_VT8500 && VTWM_VERSION_WM8505 + select FB_WMT_GE_ROPS + select FB_SYS_IMAGEBLIT + help + This is the framebuffer driver for WonderMedia WM8505 + integrated LCD controller. + source "drivers/video/geode/Kconfig" config FB_HIT
drivers/video/Makefile +3 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_FB_SVGALIB) += svgalib.o obj-$(CONFIG_FB_MACMODES) += macmodes.o obj-$(CONFIG_FB_DDC) += fb_ddc.o obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o +obj-$(CONFIG_FB_WMT_GE_ROPS) += wmt_ge_rops.o # Hardware specific drivers go first obj-$(CONFIG_FB_AMIGA) += amifb.o c2p_planar.o
@@ -104,6 +105,8 @@ obj-$(CONFIG_FB_W100) += w100fb.o obj-$(CONFIG_FB_TMIO) += tmiofb.o obj-$(CONFIG_FB_AU1100) += au1100fb.o obj-$(CONFIG_FB_AU1200) += au1200fb.o +obj-$(CONFIG_FB_VT8500) += vt8500lcdfb.o +obj-$(CONFIG_FB_WM8505) += wm8505fb.o obj-$(CONFIG_FB_PMAG_AA) += pmag-aa-fb.o obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o
drivers/video/vt8500lcdfb.c new file +452 -0
452 lines not on this page · raw message
drivers/video/vt8500lcdfb.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* linux/drivers/video/vt8500lcdfb.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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. +*/ + +struct vt8500lcd_info { +struct fb_info fb; +void __iomem *regbase; +void __iomem *palette_cpu; +dma_addr_t palette_phys; +size_t palette_size; +wait_queue_head_t wait; +}; + +static int bpp_values[] = { +1 , +2 , +4 , +8 , +12 , +16 , +18 , +24 , +};
drivers/video/wm8505fb.c new file +438 -0
438 lines not on this page · raw message
drivers/video/wm8505fb_regs.h new file +76 -0
76 lines not on this page · raw message
drivers/video/wmt_ge_rops.c new file +186 -0
186 lines not on this page · raw message
drivers/video/wmt_ge_rops.h new file +5 -0
@@ -0,0 +1,5 @@ +extern void wmt_ge_fillrect (struct fb_info *info, +const struct fb_fillrect *rect); +extern void wmt_ge_copyarea (struct fb_info *info, +const struct fb_copyarea *area); +extern int wmt_ge_sync (struct fb_info *info);
Signature · 1 line
1.7.3.2
Re: [PATCH 6/6 v2] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 2 lines · Alexey Charkov
drivers/video/vt8500lcdfb.c new file +2
-0+static int __devinit vt8500lcd_probe (struct platform_device *pdev) +{
...
Quoted 4 lines
drivers/video/vt8500lcdfb.c new file +4
-0+ addr = fbi; + addr = addr +sizeof (struct vt8500lcd_info ); + fbi->fb.pseudo_palette = addr; +
...
drivers/video/vt8500lcdfb.c line 328
Quoted 11 lines
drivers/video/vt8500lcdfb.c new file +11
-0+ fbi->palette_size =PAGE_ALIGN (512 ); + fbi->palette_cpu =dma_alloc_coherent (&pdev->dev, + fbi->palette_size, + &fbi->palette_phys, +GFP_KERNEL ); +if (fbi->fb.pseudo_palette ==NULL ) { +dev_err (&pdev->dev,"Failed to allocate palette buffer\n" ); + ret = -ENOMEM ; + goto failed_free_io; + } +
This looks like a bogus test, you've already allocated enough space for the pseudo_palette and will have bailed out on the kmalloc() failing well before this. You also don't have any error handling for fbi->palette_cpu, which is presumably what you intended to do here.
Quoted 11 lines
drivers/video/vt8500lcdfb.c new file +11
-0+static int __devexit vt8500lcd_remove(struct platform_device *pdev) +{ +struct vt8500lcd_info *fbi =platform_get_drvdata (pdev); +struct resource *res; +int irq; + +if (!fbi) +return 0 ; + +unregister_framebuffer (&fbi->fb); +
drivers/video/vt8500lcdfb.c line 420
Quoted 10 lines
drivers/video/vt8500lcdfb.c new file +10
-0+writel (0 , fbi->regbase); + +if (fbi->fb.cmap.len) +fb_dealloc_cmap (&fbi->fb.cmap); + + irq =platform_get_irq (pdev,0 ); +free_irq (irq, fbi); + +iounmap (fbi->regbase); +
You're also missing a dma_free_coherent() here.
Quoted 5 lines
drivers/video/wm8505fb.c new file +5
-0+static int __devinit wm8505fb_probe (struct platform_device *pdev) +{ + fbi->fb.screen_base = pdata->video_mem_virt; + fbi->fb.screen_size = pdata->video_mem_len; +
...
Review
Quoted 2 lines
(quoted diff) +2
-0+failed_free_mem: + free_pages_exact(fbi->fb.screen_base, fbi->fb.screen_size);
...
What in the name of all that is holy are you doing here? If you need to have your platform deal with virtual address allocation and freeing then you should pass in callbacks for that and hide the instrumentation details there. Presently this is tying you down to an alloc_pages_exact() interface buried in the board setup, which isn't going to mesh well with other platforms that may wish to go about this an alternate way (like memblock reservations).
drivers/video/wmt_ge_rops.c
Quoted 7 lines
drivers/video/wmt_ge_rops.c new file +2
-0+void __iomem *regbase; +
Uhm, no. If this is only used in this driver then just make it static. Given that you are using the driver model here though and could theoretically support multiple rop engines, you're much better off making this private data and burying it under the appropriate per-device data structures.
drivers/video/wmt_ge_rops.c line 126
Quoted 9 lines
drivers/video/wmt_ge_rops.c new file +9
-0+int wmt_ge_sync (struct fb_info *p) +{ +while (readl (regbase +GE_STATUS_OFF ) &4 ) +/* busy wait */ ; + +return 0 ; +} +EXPORT_SYMBOL (wmt_ge_sync); +
While I admire your optimism in your hardware, experience suggests you really want a timeout here. You may also wish to insert a cpu_relax() here.
Alexey Charkov
maintainerRe: [PATCH 6/6 v2] ARM: Add support for the display controllers in VT8500 and WM8505
2010/11/8 Paul Mundt <[email protected]>:
Quoted 23 lines · Alexey Charkov
Quoted 2 lines
drivers/video/vt8500lcdfb.c new file +2
-0+static int __devinit vt8500lcd_probe (struct platform_device *pdev) +{...
Quoted 4 lines
+ ? ? addr = fbi;
+ ? ? addr = addr +sizeof(struct vt8500lcd_info);
+ ? ?fbi->fb.pseudo_palette?= addr;
+...
Quoted 11 lines
+ ? ?
fbi->palette_size? ? ? =PAGE_ALIGN(512);
+ ? ?fbi->palette_cpu? ? ? ?= dma_alloc_coherent(&pdev->dev,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?fbi->palette_size,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?&fbi->palette_phys,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GFP_KERNEL);
+ ? ? if (fbi->fb.pseudo_palette== NULL) {
+ ? ? ? ? ? ?dev_err(&pdev->dev, "Failed to allocate palette buffer\n");
+ ? ? ? ? ? ? ret =-ENOMEM;
+ ? ? ? ? ? ? gotofailed_free_io;
+ ? ? }
+
Quoted 5 lines
This looks like a bogus test, you've already allocated enough space for the
pseudo_paletteand will have bailed out on thekmalloc()failing well before this. You also don't have any error handling forfbi->palette_cpu, which is presumably what you intended to do here.
True, this has to be corrected (old copy-paste error left unnoticed somehow). It's also deallocated wrongly in the error path, which I have just noticed.
Quoted 15 lines
Quoted 15 lines
(quoted diff) +15
-0+static int __devexit vt8500lcd_remove(struct platform_device *pdev) +{ + ? ? struct vt8500lcd_info *fbi = platform_get_drvdata(pdev); + ? ? struct resource *res; + ? ? int irq; + + ? ? if (!fbi) + ? ? ? ? ? ? return 0; + + ? ? unregister_framebuffer(&fbi->fb); + + ? ? writel(0, fbi->regbase); + + ? ? if (fbi->fb.cmap.len) + ? ? ? ? ? ? fb_dealloc_cmap(&fbi->fb.cmap);
Quoted 9 lines
drivers/video/vt8500lcdfb.c line 34
Quoted 6 lines
drivers/video/vt8500lcdfb.c new file +6
-0+ + ? ? irq = platform_get_irq(pdev, 0); + ? ? free_irq(irq, fbi); + + ? ? iounmap(fbi->regbase); +You're also missing a
dma_free_coherent()here.
True, will be fixed.
Quoted 12 lines
Quoted 5 lines
drivers/video/wm8505fb.c new file +5
-0+static int __devinit wm8505fb_probe (struct platform_device *pdev) +{ + ? ? fbi->fb.screen_base ? ? = pdata->video_mem_virt; + ? ? fbi->fb.screen_size ? ? = pdata->video_mem_len; +...
Quoted 2 lines
+failed_free_mem:
+ ? ?free_pages_exact(fbi->fb.screen_base, fbi->fb.screen_size);...
Quoted 8 lines
What in the name of all that is holy are you doing here? If you need to have your platform deal with virtual address allocation and freeing then you should pass in callbacks for that and hide the instrumentation details there. Presently this is tying you down to an
alloc_pages_exact()interface buried in the board setup, which isn't going to mesh well with other platforms that may wish to go about this an alternate way (like memblock reservations).
Actually, this is a leftover from a previous implementation with alloc_pages_exact(), which could not work for larger screen sizes (due to the framebuffer growing over 4MB). Now memory is reserved via memblock, so this should have probably been just dropped.
Quoted 4 lines
Quoted 4 lines
drivers/video/wmt_ge_rops.c new file +0
-1--- /dev/null
Quoted 9 lines
drivers/video/wmt_ge_rops.c
Quoted 3 lines
+++
b/drivers/video/wmt_ge_rops.cdrivers/video/wmt_ge_rops.c new file +2
-0+void __iomem *regbase; +Uhm, no. If this is only used in this driver then just make it static. Given that you are using the driver model here though and could theoretically support multiple rop engines, you're much better off making this private data and burying it under the appropriate per-device data structures.
Is that platform_{set,get}_drvdata() what you are talking about? Using multiple engines seems extremely unlikely, though :)
Quoted 4 lines
Quoted 4 lines
drivers/video/wmt_ge_rops.c new file +4
-0+int wmt_ge_sync (struct fb_info *p) +{ + ? ? while (readl(regbase + GE_STATUS_OFF) & 4) + ? ? ? ? ? ? /* busy wait */;
Quoted 9 lines
drivers/video/wmt_ge_rops.c line 126
Quoted 5 lines
drivers/video/wmt_ge_rops.c new file +5
-0+ + ? ? return 0; +} +EXPORT_SYMBOL (wmt_ge_sync); +While I admire your optimism in your hardware, experience suggests you really want a timeout here. You may also wish to insert a
cpu_relax()here.
I wonder if this callback is allowed to sleep? In principle, the hardware seems to support interrupt generation on operation completion, so maybe wait_event_interruptible_timeout() could be used here to remove the busy wait altogether?
Thank you for the comments, Paul!
Best regards,
Alexey
Alexey Charkov
maintainerPATCH v3 6/6 ARM: Add support for the display controllers in VT8500 and WM8505
In reply to Paul MundtThis adds drivers for the LCD controller found in VIA VT8500 SoC, GOVR display controller found in WonderMedia WM8505 SoC and for the Graphics Engine present in both of them that provides hardware accelerated raster operations (used for copyarea and fillrect).
---
This incorporates fixes to the issues that Paul has identified. MMIO register pointer in wmt_ge_rops was just made static, as I could not find any immediately obvious way to pass drvdata around (the whole functionality of this driver is in exported functions that are called from a display driver context, which does not know about the rop engine specific data structures).
fb_sync callback has just received a (pretty large) timeout. This seems to work fine in my use cases (fbcon on 800x480 panel).
drivers/video/Kconfig | 26 +++ drivers/video/Makefile | 3 + drivers/video/vt8500lcdfb.c | 455 +++++++++++++++++++++++++++++++++++++++++ drivers/video/vt8500lcdfb.h | 34 +++ drivers/video/wm8505fb.c | 434 +++++++++++++++++++++++++++++++++++++++ drivers/video/wm8505fb_regs.h | 76 +++++++ drivers/video/wmt_ge_rops.c | 186 +++++++++++++++++ drivers/video/wmt_ge_rops.h | 5 + 8 files changed, 1219 insertions(+), 0 deletions(-) create mode 100644 drivers/video/vt8500lcdfb.c create mode 100644 drivers/video/vt8500lcdfb.h create mode 100644 drivers/video/wm8505fb.c create mode 100644 drivers/video/wm8505fb_regs.h create mode 100644 drivers/video/wmt_ge_rops.c create mode 100644 drivers/video/wmt_ge_rops.h
drivers/video/Kconfig +26 -0
@@ -186,6 +186,14 @@ 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
@@ -1722,6 +1730,24 @@ config FB_AU1200 various panels and CRTs by passing in kernel cmd line option au1200fb:panel=<name>. +config FB_VT8500 + bool "VT8500 LCD Driver" + depends on (FB = y) && ARM && ARCH_VT8500 && VTWM_VERSION_VT8500 + select FB_WMT_GE_ROPS + select FB_SYS_IMAGEBLIT + help + This is the framebuffer driver for VIA VT8500 integrated LCD + controller. + +config FB_WM8505 + bool "WM8505 frame buffer support" + depends on (FB = y) && ARM && ARCH_VT8500 && VTWM_VERSION_WM8505 + select FB_WMT_GE_ROPS + select FB_SYS_IMAGEBLIT + help + This is the framebuffer driver for WonderMedia WM8505 + integrated LCD controller. + source "drivers/video/geode/Kconfig" config FB_HIT
drivers/video/Makefile +3 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_FB_SVGALIB) += svgalib.o obj-$(CONFIG_FB_MACMODES) += macmodes.o obj-$(CONFIG_FB_DDC) += fb_ddc.o obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o +obj-$(CONFIG_FB_WMT_GE_ROPS) += wmt_ge_rops.o # Hardware specific drivers go first obj-$(CONFIG_FB_AMIGA) += amifb.o c2p_planar.o
@@ -104,6 +105,8 @@ obj-$(CONFIG_FB_W100) += w100fb.o obj-$(CONFIG_FB_TMIO) += tmiofb.o obj-$(CONFIG_FB_AU1100) += au1100fb.o obj-$(CONFIG_FB_AU1200) += au1200fb.o +obj-$(CONFIG_FB_VT8500) += vt8500lcdfb.o +obj-$(CONFIG_FB_WM8505) += wm8505fb.o obj-$(CONFIG_FB_PMAG_AA) += pmag-aa-fb.o obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o
drivers/video/vt8500lcdfb.c new file +455 -0
455 lines not on this page · raw message
drivers/video/vt8500lcdfb.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* linux/drivers/video/vt8500lcdfb.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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. +*/ + +struct vt8500lcd_info { +struct fb_info fb; +void __iomem *regbase; +void __iomem *palette_cpu; +dma_addr_t palette_phys; +size_t palette_size; +wait_queue_head_t wait; +}; + +static int bpp_values[] = { +1 , +2 , +4 , +8 , +12 , +16 , +18 , +24 , +};
drivers/video/wm8505fb.c new file +434 -0
434 lines not on this page · raw message
drivers/video/wm8505fb_regs.h new file +76 -0
76 lines not on this page · raw message
drivers/video/wmt_ge_rops.c new file +186 -0
186 lines not on this page · raw message
drivers/video/wmt_ge_rops.h new file +5 -0
@@ -0,0 +1,5 @@ +extern void wmt_ge_fillrect (struct fb_info *info, +const struct fb_fillrect *rect); +extern void wmt_ge_copyarea (struct fb_info *info, +const struct fb_copyarea *area); +extern int wmt_ge_sync (struct fb_info *info);
Signature · 1 line
1.7.3.2
Re: [PATCH 6/6 v3] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 7 lines · Alexey Charkov
This incorporates fixes to the issues that Paul has identified. MMIO register pointer in
wmt_ge_ropswas just made static, as I could not find any immediately obvious way to pass drvdata around (the whole functionality of this driver is in exported functions that are called from a display driver context, which does not know about the rop engine specific data structures).
Looking better.. just a few minor things left.
drivers/video/vt8500lcdfb.c
Quoted 7 lines
drivers/video/vt8500lcdfb.c new file +2
-0+#include <asm/irq.h> +
linux/irq.h is preferred here.
drivers/video/wm8505fb.c
Quoted 7 lines
drivers/video/wm8505fb.c new file +2
-0+#include <asm/irq.h> +
Likewise.
drivers/video/wm8505fb.c line 220
Quoted 7 lines
drivers/video/wm8505fb.c new file +7
-0+static int wm8505fb_pan_display (struct fb_var_screeninfo *var, +struct fb_info *info) +{ +struct wm8505fb_info *fbi =container_of (info, + struct wm8505fb_info, + fb); +
Sice you are open-coding this container_of() all over the place you may simply want to make a wrapper for this. ie,
#define to_wm8505fb_info(info) container_of(info, struct wm8505fb_info, fb)
and then just doing struct wm855fb_info *fbi = to_wm8505fb_info(info);
This wiwll also save you from having that ugly multi-line split in the container_of() and keep you well within 80 characters.
Quoted 2 lines
drivers/video/wm8505fb.c new file +2
-0+static int __devinit wm8505fb_probe (struct platform_device *pdev) +{
...
Quoted 13 lines
drivers/video/wm8505fb.c new file +13
-0+ ret =register_framebuffer (&fbi->fb); +if (ret <0 ) { +dev_err (&pdev->dev, +"Failed to register framebuffer device: %d\n" , ret); + goto failed_free_cmap; + } + + ret =device_create_file (&pdev->dev, &dev_attr_contrast); +if (ret <0 ) { +printk (KERN_WARNING "fb%d: failed to register attributes (%d)\n" , + fbi->fb.node, ret); + } +
...
drivers/video/wm8505fb.c line 393
Quoted 10 lines
drivers/video/wm8505fb.c new file +10
-0+} + +static int __devexit wm8505fb_remove(struct platform_device *pdev) +{ +struct wm8505fb_info *fbi =platform_get_drvdata (pdev); +struct resource *res; + +if (!fbi) +return 0 ; +
I would kill this test as well. If this ever triggers, something horribly wrong has happened and you likely have bigger things to worry about.
drivers/video/wm8505fb.c
Quoted 2 lines
drivers/video/wm8505fb.c new file +2
-0+unregister_framebuffer (&fbi->fb); +
You're missing a device_remove_file().
drivers/video/wm8505fb.c line 413
Quoted 3 lines
drivers/video/wm8505fb.c new file +3
-0+static struct platform_driver wm8505fb_driver = { + .probe = wm8505fb_probe, + .remove = wm8505fb_remove,
As your remove function is flagged devexit, this ought to be wrapped with __devexit_p(). This will save you a bit of space as the kernel will discard the remove function outright if you're not using this as a module or with hotplug. The same applies to your other remove functions too.
drivers/video/wmt_ge_rops.c line 126
Quoted 9 lines
drivers/video/wmt_ge_rops.c new file +4
-0+EXPORT_SYMBOL (wmt_ge_fillrect); +EXPORT_SYMBOL (wmt_ge_copyarea); +EXPORT_SYMBOL (wmt_ge_sync); +
...
Is there a particular reason why you are favouring EXPORT_SYMBOL? In general we prefer that new infrastructure patches and the like stick with EXPORT_SYMBOL_GPL, as this discourages use by non-GPLed modules going forward.
Quoted 2 lines
drivers/video/wmt_ge_rops.c new file +2
-0+static int __devinit wmt_ge_rops_probe (struct platform_device *pdev) +{
...
drivers/video/wmt_ge_rops.c line 145
Quoted 7 lines
drivers/video/wmt_ge_rops.c new file +7
-0+ regbase =ioremap (res->start,resource_size (res)); +if (regbase ==NULL ) { +dev_err (&pdev->dev,"failed to map I/O memory\n" ); + ret = -EBUSY ; + goto error; + } +
You might also want to do something like:
/* Only one ROP engine is presently supported. */
if (unlikely(regbase)) {
WARN_ON(1);
return -EBUSY;
}
regbase = ioremap(...);
...Quoted 5 lines
drivers/video/wmt_ge_rops.c new file +5
-0+writel (1 , regbase +GE_ENABLE_OFF ); +printk (KERN_INFO "Enabled support for WMT GE raster acceleration\n" ); + +return 0 ; +
drivers/video/wmt_ge_rops.c line 160
Quoted 10 lines
drivers/video/wmt_ge_rops.c new file +10
-0+error: +return ret; +} + +static int __devexit wmt_ge_rops_remove(struct platform_device *pdev) +{ +iounmap (regbase); +return 0 ; +} +
You're missing a:
writel(0, regbase + GE_ENABLE_OFF);
here?
drivers/video/wmt_ge_rops.c line 186
Quoted 4 lines
drivers/video/wmt_ge_rops.c new file +4
-0+MODULE_AUTHOR ("Alexey Charkov <[email protected]" ); +MODULE_DESCRIPTION ("Accelerators for raster operations using " +"WonderMedia Graphics Engine" ); +MODULE_LICENSE ("GPL" );
Your other drivers appear to be lacking AUTHOR and DESCRIPTION definitions.
Alexey Charkov
maintainerRe: [PATCH 6/6 v3] ARM: Add support for the display controllers in VT8500 and WM8505
2010/11/8 Paul Mundt <[email protected]>:
Quoted 19 lines · Alexey Charkov
Quoted 7 lines
This incorporates fixes to the issues that Paul has identified. MMIO register pointer in
wmt_ge_ropswas just made static, as I could not find any immediately obvious way to pass drvdata around (the whole functionality of this driver is in exported functions that are called from a display driver context, which does not know about the rop engine specific data structures).Looking better.. just a few minor things left.
drivers/video/vt8500lcdfb.c
Quoted 7 lines
drivers/video/vt8500lcdfb.c new file +2
-0+#include <asm/irq.h> +
linux/irq.his preferred here.
Quoted 9 lines
drivers/video/wm8505fb.c
Quoted 7 lines
drivers/video/wm8505fb.c new file +2
-0+#include <asm/irq.h> +Likewise.
Ok.
Quoted 10 lines
drivers/video/wm8505fb.c
Quoted 7 lines
drivers/video/wm8505fb.c new file +7
-0+static int wm8505fb_pan_display (struct fb_var_screeninfo *var, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct fb_info *info) +{ + ? ? struct wm8505fb_info *fbi = container_of(info, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct wm8505fb_info, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? fb); +Sice you are open-coding this
container_of()all over the place you may simply want to make a wrapper for this. ie,
Quoted 7 lines
#define
to_wm8505fb_info(info)?container_of(info, structwm8505fb_info, fb)and then just doing struct
wm855fb_info*fbi =to_wm8505fb_info(info);This wiwll also save you from having that ugly multi-line split in the
container_of()and keep you well within 80 characters.
That's true, thanks.
Quoted 18 lines
Quoted 2 lines
drivers/video/wm8505fb.c new file +2
-0+static int __devinit wm8505fb_probe (struct platform_device *pdev) +{...
Quoted 13 lines
+ ? ? ret =
register_framebuffer(&fbi->fb);
+ ? ? if (ret < 0) {
+ ? ? ? ? ? ? dev_err(&pdev->dev,
+ ? ? ? ? ? ? ? ? ? ? "Failed to register framebuffer device: %d\n", ret);
+ ? ? ? ? ? ? gotofailed_free_cmap;
+ ? ? }drivers/video/wm8505fb.c new file +7
-0+ + ? ? ret = device_create_file(&pdev->dev, &dev_attr_contrast); + ? ? if (ret < 0) { + ? ? ? ? ? ? printk(KERN_WARNING "fb%d: failed to register attributes (%d)\n", + ? ? ? ? ? ? ? ? ? ? fbi->fb.node, ret); + ? ? } +...
Quoted 13 lines
drivers/video/wm8505fb.c line 393
Quoted 10 lines
drivers/video/wm8505fb.c new file +10
-0+} + +static int __devexit wm8505fb_remove(struct platform_device *pdev) +{ + ? ? struct wm8505fb_info *fbi = platform_get_drvdata(pdev); + ? ? struct resource *res; + + ? ? if (!fbi) + ? ? ? ? ? ? return 0; +I would kill this test as well. If this ever triggers, something horribly wrong has happened and you likely have bigger things to worry about.
But a couple of extra instructions for error handling to hold in the kernel binary should not hurt, should they? Are there benefits aside from code compaction?
Quoted 4 lines
Quoted 2 lines
+ ? ?
unregister_framebuffer(&fbi->fb);
+You're missing a
device_remove_file().
True, will be fixed.
Quoted 9 lines
Quoted 3 lines
+static struct
platform_driverwm8505fb_driver= {
+ ? ? .probe ? ? ? ? ?=wm8505fb_probe,
+ ? ? .remove ? ? ? ? =wm8505fb_remove,As your remove function is flagged devexit, this ought to be wrapped with
__devexit_p(). This will save you a bit of space as the kernel will discard the remove function outright if you're not using this as a module or with hotplug. The same applies to your other remove functions too.
Ok, thanks for pointing out!
Quoted 11 lines
Quoted 9 lines
drivers/video/wmt_ge_rops.c new file +4
-0+EXPORT_SYMBOL (wmt_ge_fillrect); +EXPORT_SYMBOL (wmt_ge_copyarea); +EXPORT_SYMBOL (wmt_ge_sync); +...
Quoted 5 lines
Is there a particular reason why you are favouring
EXPORT_SYMBOL? In general we prefer that new infrastructure patches and the like stick withEXPORT_SYMBOL_GPL, as this discourages use by non-GPLed modules going forward.
Well, I have no personal preference towards these, so I just took what was in cfb*.c as a guidance. If the *_GPL variant is more welcome, it can be changed.
Quoted 12 lines
Quoted 2 lines
drivers/video/wmt_ge_rops.c new file +2
-0+static int __devinit wmt_ge_rops_probe (struct platform_device *pdev) +{...
Quoted 7 lines
+ ? ? regbase =
ioremap(res->start, resource_size(res));
+ ? ? if (regbase == NULL) {
+ ? ? ? ? ? ?dev_err(&pdev->dev, "failed to map I/O memory\n");
+ ? ? ? ? ? ? ret =-EBUSY;
+ ? ? ? ? ? ? goto error;
+ ? ? }
+You might also want to do something like:
Quoted 9 lines
? ? ? ?/* Only one ROP engine is presently supported. */ ? ? ? ?if (unlikely(regbase)) {
? ? ? ? ? ? ? ?WARN_ON(1);
? ? ? ? ? ? ? ?return-EBUSY;
? ? ? ?}? ? ? ?regbase = ioremap(...);
? ? ? ?...
But for that I'd have to initialize regbase to NULL (so as not to use an uninitialized variable), wouldn't I? checkpatch.pl complains on that...
Quoted 17 lines
Quoted 5 lines
+ ? ?
writel(1, regbase + GE_ENABLE_OFF);
+ ? ?printk(KERN_INFO "Enabled support for WMT GE raster acceleration\n");drivers/video/wmt_ge_rops.c new file +3
-0+ + ? ? return 0; +drivers/video/wmt_ge_rops.c line 160
Quoted 10 lines
drivers/video/wmt_ge_rops.c new file +10
-0+error: + ? ? return ret; +} + +static int __devexit wmt_ge_rops_remove(struct platform_device *pdev) +{ + ? ? iounmap(regbase); + ? ? return 0; +} +You're missing a:
Quoted 4 lines
? ? ? ?writel(0, regbase +
GE_ENABLE_OFF);here?
In fact, this module only uses a subset of GE functions, so I'm somewhat reluctant to disable the hardware altogether when unloading the module. And should the hardware really be disabled when the driver is removed?
Quoted 8 lines
drivers/video/wmt_ge_rops.c line 186
Quoted 4 lines
drivers/video/wmt_ge_rops.c new file +4
-0+MODULE_AUTHOR ("Alexey Charkov <[email protected]" ); +MODULE_DESCRIPTION ("Accelerators for raster operations using " + ? ? ? ? ? ? ? ?"WonderMedia Graphics Engine"); +MODULE_LICENSE ("GPL" );Your other drivers appear to be lacking AUTHOR and DESCRIPTION definitions.
Will be fixed.
Thanks,
Alexey
Re: [PATCH 6/6 v3] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 11 lines · Alexey Charkov
2010/11/8 Paul Mundt <[email protected]>:
Quoted 5 lines
Quoted 3 lines
+ ?? ?? if (!fbi)
+ ?? ?? ?? ?? ?? ?? return 0;
+I would kill this test as well. If this ever triggers, something horribly wrong has happened and you likely have bigger things to worry about.
But a couple of extra instructions for error handling to hold in the kernel binary should not hurt, should they? Are there benefits aside from code compaction?
It's not a realistic situation. The only way this would trigger is if the pointer you got handed is one that didn't go through the probe path or was otherwise corrupted. If it was corrupted, you're going to notice regardless. The driver core does sensible refcounting already, there's no need to second guess it.
Quoted 17 lines
Quoted 11 lines
Quoted 9 lines
drivers/video/wmt_ge_rops.c new file +4
-0+EXPORT_SYMBOL (wmt_ge_fillrect); +EXPORT_SYMBOL (wmt_ge_copyarea); +EXPORT_SYMBOL (wmt_ge_sync); +...
Quoted 5 lines
Is there a particular reason why you are favouring
EXPORT_SYMBOL? In general we prefer that new infrastructure patches and the like stick withEXPORT_SYMBOL_GPL, as this discourages use by non-GPLed modules going forward.
Quoted 4 lines
Well, I have no personal preference towards these, so I just took what was in cfb*.c as a guidance. If the
*_GPLvariant is more welcome, it can be changed.
Those exports go back a ways. The idea with the _GPL exports was not to change symbol export behaviour retroactively, so the old ones stay the way they were and newer stuff can choose which way it wants to go. If you are not using this driver with an out-of-tree non-GPLed module then you are advised to use the GPL variants so others don't either.
Quoted 18 lines
Quoted 18 lines
Quoted 2 lines
drivers/video/wmt_ge_rops.c new file +2
-0+static int __devinit wmt_ge_rops_probe (struct platform_device *pdev) +{...
Quoted 7 lines
+ ?? ?? regbase =
ioremap(res->start, resource_size(res));
+ ?? ?? if (regbase == NULL) {
+ ?? ?? ?? ?? ?? ??dev_err(&pdev->dev, "failed to map I/O memory\n");
+ ?? ?? ?? ?? ?? ?? ret =-EBUSY;
+ ?? ?? ?? ?? ?? ?? goto error;
+ ?? ?? }
+You might also want to do something like:
?? ?? ?? ??/* Only one ROP engine is presently supported. */ ?? ?? ?? ??if (unlikely(regbase)) {
?? ?? ?? ?? ?? ?? ?? ??WARN_ON(1);
?? ?? ?? ?? ?? ?? ?? ??return-EBUSY;
?? ?? ?? ??}
Quoted 8 lines
Quoted 3 lines
?? ?? ?? ??regbase = ioremap(...);
?? ?? ?? ??...But for that I'd have to initialize regbase to NULL (so as not to use an uninitialized variable), wouldn't I? checkpatch.pl complains on that...
No, regbase is BSS initialized, so it will already be cleared.
Quoted 10 lines
Quoted 10 lines
drivers/video/wmt_ge_rops.c line 160
Quoted 6 lines
drivers/video/wmt_ge_rops.c new file +6
-0+static int __devexit wmt_ge_rops_remove(struct platform_device *pdev) +{ + ?? ?? iounmap(regbase); + ?? ?? return 0; +} +You're missing a:
?? ?? ?? ??writel(0, regbase +
GE_ENABLE_OFF);
Quoted 8 lines
Quoted 2 lines
here?
In fact, this module only uses a subset of GE functions, so I'm somewhat reluctant to disable the hardware altogether when unloading the module. And should the hardware really be disabled when the driver is removed?
You're the only one who can answer that. I just noticed in your other drivers that this is the pattern that you opted for, so I thought that perhaps this was an oversight in the rop engine code.
Having said that, the general expectation is that a remove will balance out the probe. If the probe is enabling random blocks then the remove should be disabling them. If this driver is primarily used as a client by the other drivers and you're concerned from it being ripped out underneath them, then a bit more thinking and refcounting is needed. This is however something that can be done later if its a direction you wish to head in.
Alexey Charkov
maintainerPATCH v4 6/6 ARM: Add support for the display controllers in VT8500 and WM8505
Re: [PATCH 6/6 v4] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 15 lines · Alexey Charkov
From
95942cc0cd0909d700c236ba63d3488ec9fccf1aMon Sep 17 00:00:00 2001
From: Alexey Charkov <[email protected]>
Date: Tue, 9 Nov 2010 02:25:40 +0300
Subject: [PATCH 3/3] ARM: Add support for the display controllers in VT8500 and WM8505This adds drivers for the LCD controller found in VIA VT8500 SoC, GOVR display controller found in WonderMedia WM8505 SoC and for the Graphics Engine present in both of them that provides hardware accelerated raster operations (used for copyarea and fillrect).
Signed-off-by Alexey Charkov <[email protected]>---
This incorporates fixes to the issues last mentioned by Paul.
Quoted 8 lines
I just dropped <
asm/irq.h>, as that seems to be not used at all currently (must have been some old cut-and-paste as well). As for the Graphics Engine, I decided not to disable it for now at device exit time, at least until we reach a conclusion on how or whether to implement support for its alpha-mixing capabilities. Unlike with display drivers, this should have no user-visible consequences. This can be changed later, when time comes for device clocks and power management support.
Looks good to me!
Alexey Charkov
maintainerRe: [PATCH 6/6 v4] ARM: Add support for the display controllers in VT8500 and WM8505
2010/11/8 Paul Mundt <[email protected]>:
Quoted 24 lines · Alexey Charkov
Quoted 15 lines
From
95942cc0cd0909d700c236ba63d3488ec9fccf1aMon Sep 17 00:00:00 2001
From: Alexey Charkov <[email protected]>
Date: Tue, 9 Nov 2010 02:25:40 +0300
Subject: [PATCH 3/3] ARM: Add support for the display controllers in VT8500 and WM8505This adds drivers for the LCD controller found in VIA VT8500 SoC, GOVR display controller found in WonderMedia WM8505 SoC and for the Graphics Engine present in both of them that provides hardware accelerated raster operations (used for copyarea and fillrect).
Signed-off-by Alexey Charkov <[email protected]>---
This incorporates fixes to the issues last mentioned by Paul.
Quoted 8 lines
I just dropped <
asm/irq.h>, as that seems to be not used at all currently (must have been some old cut-and-paste as well). As for the Graphics Engine, I decided not to disable it for now at device exit time, at least until we reach a conclusion on how or whether to implement support for its alpha-mixing capabilities. Unlike with display drivers, this should have no user-visible consequences. This can be changed later, when time comes for device clocks and power management support.
Quoted 4 lines
Looks good to me!
Reviewed-by Paul Mundt <[email protected]>
Thanks, Paul!
Is there anybody I should address specifically to get this merged?
Best regards,
Alexey
Re: [PATCH 6/6 v4] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 25 lines · Alexey Charkov
2010/11/8 Paul Mundt <[email protected]>:
Quoted 24 lines · Alexey Charkov
Quoted 23 lines
From
95942cc0cd0909d700c236ba63d3488ec9fccf1aMon Sep 17 00:00:00 2001
From: Alexey Charkov <[email protected]>
Date: Tue, 9 Nov 2010 02:25:40 +0300
Subject: [PATCH 3/3] ARM: Add support for the display controllers in VT8500 and WM8505This adds drivers for the LCD controller found in VIA VT8500 SoC, GOVR display controller found in WonderMedia WM8505 SoC and for the Graphics Engine present in both of them that provides hardware accelerated raster operations (used for copyarea and fillrect).
Signed-off-by Alexey Charkov <[email protected]>---
This incorporates fixes to the issues last mentioned by Paul.
I just dropped <
asm/irq.h>, as that seems to be not used at all currently (must have been some old cut-and-paste as well). As for the Graphics Engine, I decided not to disable it for now at device exit time, at least until we reach a conclusion on how or whether to implement support for its alpha-mixing capabilities. Unlike with display drivers, this should have no user-visible consequences. This can be changed later, when time comes for device clocks and power management support.
Quoted 8 lines
Quoted 4 lines
Looks good to me!
Reviewed-by Paul Mundt <[email protected]>Thanks, Paul!
Is there anybody I should address specifically to get this merged?
In the absence of a fbdev maintainer, such patches, as long as they don't touch the core, apart from the obvious and trivial Makefile and Kconfig hunks, they normally get mainlined via respective arch trees, i.e., you can just push them the same way as your other SoC patches. OTOH you can also ask Andrew Morton to pull them.
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
Re: [PATCH 6/6 v4] ARM: Add support for the display controllers in VT8500 and WM8505
In reply to Alexey CharkovQuoted 2 lines · Alexey Charkov
Is there anybody I should address specifically to get this merged?
I've set up an fbdev tree now, so I'll just take this through there. It looks like the ordering shouldn't be important, so this can be applied independent of the rest, and it simply won't show up until the other bits have settled in .38.
Alexey Charkov
maintainerRe: [PATCH 6/6 v4] ARM: Add support for the display controllers in VT8500 and WM8505
2010/11/9 Paul Mundt <[email protected]>:
Quoted 8 lines · Alexey Charkov
Quoted 2 lines
Is there anybody I should address specifically to get this merged?
I've set up an fbdev tree now, so I'll just take this through there. It looks like the ordering shouldn't be important, so this can be applied independent of the rest, and it simply won't show up until the other bits have settled in .38.
Yes, the different parts of the patch series are completely independent, apart from the corresponding platform definitions and memblock reservations that take place in PATCH 1/6 (which contains basic board code).
Thanks,
Alexey
Re: [PATCH 6/6 v3] ARM: Add support for the display controllers in VT8500 and WM8505
In reply to Paul MundtQuoted 8 lines · Paul Mundt
drivers/video/vt8500lcdfb.c
Quoted 7 lines
drivers/video/vt8500lcdfb.c new file +2
-0+#include <asm/irq.h> +
linux/irq.his preferred here.
I assume you've read the comment at the top of linux/irq.h ?
Re: [PATCH 6/6 v3] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 11 lines · Russell King - ARM Linux
Quoted 8 lines · Paul Mundt
drivers/video/vt8500lcdfb.c
Quoted 7 lines
drivers/video/vt8500lcdfb.c new file +2
-0+#include <asm/irq.h> +
linux/irq.his preferred here.I assume you've read the comment at the top of
linux/irq.h?
I had forgotten about that. This comment predates git, so I'm unaware of what the context is, could you elaborate on it?
I'm aware this won't work for s390, but as that has NO_IOMEM in the first place it's a non-issue. I assume this was added at a time before ARM selected GENERIC_HARDIRQS, but this is no longer the case.
The odd ones out that do support iomem are m68k and sparc32, both of which are being converted. Given that and that s390 remains special cased for now, what exactly is the concern?
There is a reasonable expectation that we will start to see irq_data references in drivers, so it's not entirely obvious that the assertion made by the comment will remain true (all of the stragglers have work in progress patches already, as far as I'm aware).
Re: [PATCH 6/6 v3] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 11 lines · Paul Mundt
Quoted 10 lines · Russell King - ARM Linux
Quoted 8 lines · Paul Mundt
drivers/video/vt8500lcdfb.c
Quoted 7 lines
drivers/video/vt8500lcdfb.c new file +2
-0+#include <asm/irq.h> +
linux/irq.his preferred here.
Quoted 4 lines
Quoted 1 line
I assume you've read the comment at the top of
linux/irq.h?I had forgotten about that. This comment predates git, so I'm unaware of what the context is, could you elaborate on it?
It's from a time when we didn't have generic irq (and as I understand, generic irq is still optional.)
When you didn't have generic irq support for an arch, having drivers include linux/irq.h resulted in build errors, caused by nothing more than "use linux/foo.h rather than asm/foo.h" - as those architectures won't provide an asm/hw_irq.h.
It looks to me like the only arch in the kernel which doesn't support generic irq is sh.
Re: [PATCH 6/6 v3] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 20 lines · Russell King - ARM Linux
Quoted 11 lines · Paul Mundt
Quoted 10 lines · Russell King - ARM Linux
Quoted 8 lines · Paul Mundt
drivers/video/vt8500lcdfb.c
Quoted 7 lines
drivers/video/vt8500lcdfb.c new file +2
-0+#include <asm/irq.h> +
linux/irq.his preferred here.Quoted 4 lines
Quoted 1 line
I assume you've read the comment at the top of
linux/irq.h?I had forgotten about that. This comment predates git, so I'm unaware of what the context is, could you elaborate on it?
It's from a time when we didn't have generic irq (and as I understand, generic irq is still optional.)
Quoted 7 lines
When you didn't have generic irq support for an arch, having drivers include
linux/irq.hresulted in build errors, caused by nothing more than "uselinux/foo.hrather thanasm/foo.h" - as those architectures won't provide anasm/hw_irq.h.It looks to me like the only arch in the kernel which doesn't support generic irq is sh.
IIRC, m68k, sparc32, and s390.
Gr{oetje,eeting}s,
? ? ? ? ? ? ? ? ? ? ? ? Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ?? -- Linus Torvalds
Re: [PATCH 6/6 v3] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 5 lines · Geert Uytterhoeven
Quoted 3 lines
It looks to me like the only arch in the kernel which doesn't support generic irq is sh.
IIRC, m68k, sparc32, and s390.
Yes, and among those, no driver in s390 should need asm/irq.h either because they do not have interrupt numbers -- every device on s390 has an implicit interrupt.
Arnd
Re: [PATCH 6/6 v3] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 11 lines · Arnd Bergmann
Quoted 5 lines · Geert Uytterhoeven
Quoted 3 lines
It looks to me like the only arch in the kernel which doesn't support generic irq is sh.
IIRC, m68k, sparc32, and s390.
Yes, and among those, no driver in s390 should need
asm/irq.heither because they do not have interrupt numbers -- every device on s390 has an implicit interrupt.
Which is exactly what I stated in my original response. Moving along then..
Re: [PATCH 6/6 v2] ARM: Add support for the display controllers in VT8500 and WM8505
In reply to Alexey CharkovQuoted 10 lines · Alexey Charkov
drivers/video/Kconfig | 26 +++ drivers/video/Makefile | 3 + drivers/video/vt8500lcdfb.c | 452 +++++++++++++++++++++++++++++++++++++++++ drivers/video/vt8500lcdfb.h | 34 +++ drivers/video/wm8505fb.c | 438 +++++++++++++++++++++++++++++++++++++++ drivers/video/wm8505fb_regs.h | 76 +++++++ drivers/video/wmt_ge_rops.c | 186 +++++++++++++++++ drivers/video/wmt_ge_rops.h | 5 +From a very brief look, the two drivers look rather similar. What is the
reason to have separate drivers instead of just one?
Could you perhaps take the common parts and move them into a third module that exports symbols to be used by the two drivers?
Arnd
Alexey Charkov
maintainerRe: [PATCH 6/6 v2] ARM: Add support for the display controllers in VT8500 and WM8505
2010/11/8 Arnd Bergmann <[email protected]>:
Quoted 10 lines · Alexey Charkov
Quoted 8 lines
?drivers/video/Kconfig ? ? ? ? | ? 26 +++ ?drivers/video/Makefile ? ? ? ?| ? ?3 + ?drivers/video/vt8500lcdfb.c ? | ?452 +++++++++++++++++++++++++++++++++++++++++ ?drivers/video/vt8500lcdfb.h ? | ? 34 +++ ?drivers/video/wm8505fb.c ? ? ?| ?438 +++++++++++++++++++++++++++++++++++++++ ?drivers/video/wm8505fb_regs.h | ? 76 +++++++ ?drivers/video/wmt_ge_rops.c ? | ?186 +++++++++++++++++ ?drivers/video/wmt_ge_rops.h ? | ? ?5 +
Quoted 6 lines
From a very brief look, the two drivers look rather similar. What is the reason to have separate drivers instead of just one?
Could you perhaps take the common parts and move them into a third module that exports symbols to be used by the two drivers?
Quite frankly, I would say that all SoC framebuffer drivers are quite similar ;-) Register offsets, timing formats, accepted pixel formats, buffer alignment requirements are all different, so I do not really believe that there'd be much benefit from introducing another abstraction level. This is open to debate, of course.
Alexey
Re: [PATCH 6/6 v2] ARM: Add support for the display controllers in VT8500 and WM8505
Quoted 5 lines · Alexey Charkov
Quite frankly, I would say that all SoC framebuffer drivers are quite similar ;-) Register offsets, timing formats, accepted pixel formats, buffer alignment requirements are all different, so I do not really believe that there'd be much benefit from introducing another abstraction level. This is open to debate, of course.
Ok, I took a more detailed look at the code now. You're absolutely right here.
Arnd
Quoted 9 lines · Alexey Charkov
arch/arm/mach-vt8500/devices.c new file +9
-0+static inline void preallocate_fb (struct vt8500fb_platform_data *p, +unsigned long align) { + p->video_mem_len = (p->xres_virtual * p->yres_virtual *4 ) >> + (p->bpp >16 ?0 : (p->bpp >8 ?1 : + (8 / p->bpp) +1 )); + p->video_mem_phys = (unsigned long )memblock_alloc (p->video_mem_len, + align); + p->video_mem_virt =phys_to_virt (p->video_mem_phys); +}
...
Quoted 12 lines
arch/arm/mach-vt8500/devices.c new file +12
-0+void __init vt8500_map_io (void ) +{ + wmt_current_regs = &wmt_regmaps[VT8500_INDEX ]; + wmt_current_irqs = &wmt_irqs[VT8500_INDEX ]; +set_data (); +#ifdef CONFIG_FB_VT8500 + panels[current_panel_idx].bpp =16 ;/* Always use RGB565 */ +preallocate_fb (&panels[current_panel_idx],SZ_4M ); + vt8500_device_lcdc.dev.platform_data = &panels[current_panel_idx]; +#endif +iotable_init (vt8500_io_desc,ARRAY_SIZE (vt8500_io_desc)); +}
...
arch/arm/mach-vt8500/devices.c line 429
Quoted 12 lines
arch/arm/mach-vt8500/devices.c new file +12
-0+void __init wm8505_map_io (void ) +{ + wmt_current_regs = &wmt_regmaps[WM8505_INDEX ]; + wmt_current_irqs = &wmt_irqs[WM8505_INDEX ]; +set_data (); +#ifdef CONFIG_FB_WM8505 + panels[current_panel_idx].bpp =32 ;/* Always use RGB888 */ +preallocate_fb (&panels[current_panel_idx],32 ); + vt8500_device_wm8505_fb.dev.platform_data = &panels[current_panel_idx]; +#endif +iotable_init (vt8500_io_desc,ARRAY_SIZE (vt8500_io_desc)); +}
I'd much prefer that the allocation of memblock memory is done via the 'reserve' machine callback, rather than trying to group it into the IO mapping callback. Is there a reason it can't be?
Alexey Charkov
maintainer2010/11/7 Russell King - ARM Linux <[email protected]>:
Quoted 24 lines · Alexey Charkov
Quoted 9 lines
(quoted diff) +9
-0+static inline void preallocate_fb(struct vt8500fb_platform_data *p, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned long align) { + ? ? p->video_mem_len = (p->xres_virtual * p->yres_virtual * 4) >> + ? ? ? ? ? ? ? ? ? ? (p->bpp > 16 ? 0 : (p->bpp > 8 ? 1 : + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (8 / p->bpp) + 1)); + ? ? p->video_mem_phys = (unsigned long)memblock_alloc(p->video_mem_len, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? align); + ? ? p->video_mem_virt = phys_to_virt(p->video_mem_phys); +}...
Quoted 12 lines
(quoted diff) +12
-0+void __init vt8500_map_io(void) +{ + ? ? wmt_current_regs = &wmt_regmaps[VT8500_INDEX]; + ? ? wmt_current_irqs = &wmt_irqs[VT8500_INDEX]; + ? ? set_data(); +#ifdef CONFIG_FB_VT8500 + ? ? panels[current_panel_idx].bpp = 16; /* Always use RGB565 */ + ? ? preallocate_fb(&panels[current_panel_idx], SZ_4M); + ? ? vt8500_device_lcdc.dev.platform_data = &panels[current_panel_idx]; +#endif + ? ? iotable_init(vt8500_io_desc, ARRAY_SIZE(vt8500_io_desc)); +}...
Quoted 17 lines
Review
Quoted 12 lines
(quoted diff) +12
-0+void __init wm8505_map_io(void) +{ + ? ? wmt_current_regs = &wmt_regmaps[WM8505_INDEX]; + ? ? wmt_current_irqs = &wmt_irqs[WM8505_INDEX]; + ? ? set_data(); +#ifdef CONFIG_FB_WM8505 + ? ? panels[current_panel_idx].bpp = 32; /* Always use RGB888 */ + ? ? preallocate_fb(&panels[current_panel_idx], 32); + ? ? vt8500_device_wm8505_fb.dev.platform_data = &panels[current_panel_idx]; +#endif + ? ? iotable_init(vt8500_io_desc, ARRAY_SIZE(vt8500_io_desc)); +}I'd much prefer that the allocation of memblock memory is done via the 'reserve' machine callback, rather than trying to group it into the IO mapping callback. ?Is there a reason it can't be?
I believe it can. Thanks for the info, I just didn't know about that. Will fix this shortly.
Is it OK to leave resources assignment in map_io or is there a better place to do that as well?
Quoted 5 lines · Alexey Charkov
I believe it can. Thanks for the info, I just didn't know about that. Will fix this shortly.
Is it OK to leave resources assignment in
map_ioor is there a better place to do that as well?
Well, surely resources don't need to be set this early, because they're not going to be used before their associated devices are registered - which presumably happens in your init_machine callback. So, can you not call a function from the init_machine callbacks to setup these resources?
Alexey Charkov
maintainerPATCH v3 1/6 ARM: Add basic architecture support for VIA/WonderMedia 85xx SoC's
This adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505. Suitable code is selected (if compiled in) at early initialization time by reading a platform-specific identification register, as current bootloaders do not provide any reliable machine id to the kernel.
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
---
This incorporates fixes for the issue that Russel has just identified, namely reserving memblock memory from the appropriate callback, checking ioremap return values for errors in all instances and not specifying the unneeded 'default n' in Kconfig.
arch/arm/Kconfig | 14 + arch/arm/Makefile | 1 + arch/arm/boot/compressed/Makefile | 4 + arch/arm/boot/compressed/head-vt8500.S | 46 +++ arch/arm/mach-vt8500/Kconfig | 63 ++++ arch/arm/mach-vt8500/Makefile | 6 + arch/arm/mach-vt8500/Makefile.boot | 3 + arch/arm/mach-vt8500/bv07.c | 81 ++++ arch/arm/mach-vt8500/devices.c | 442 +++++++++++++++++++++++ arch/arm/mach-vt8500/devices.h | 46 +++ arch/arm/mach-vt8500/gpio.c | 230 ++++++++++++ arch/arm/mach-vt8500/include/mach/debug-macro.S | 31 ++ arch/arm/mach-vt8500/include/mach/entry-macro.S | 32 ++ arch/arm/mach-vt8500/include/mach/gpio.h | 6 + arch/arm/mach-vt8500/include/mach/hardware.h | 12 + arch/arm/mach-vt8500/include/mach/io.h | 28 ++ arch/arm/mach-vt8500/include/mach/irq_defs.h | 124 +++++++ arch/arm/mach-vt8500/include/mach/irqs.h | 22 ++ arch/arm/mach-vt8500/include/mach/memory.h | 28 ++ arch/arm/mach-vt8500/include/mach/mmio_regs.h | 90 +++++ arch/arm/mach-vt8500/include/mach/system.h | 20 + arch/arm/mach-vt8500/include/mach/timex.h | 26 ++ arch/arm/mach-vt8500/include/mach/uncompress.h | 37 ++ arch/arm/mach-vt8500/include/mach/vmalloc.h | 20 + arch/arm/mach-vt8500/include/mach/vt8500fb.h | 31 ++ arch/arm/mach-vt8500/irq.c | 178 +++++++++ arch/arm/mach-vt8500/irq_defs.c | 173 +++++++++ arch/arm/mach-vt8500/mmio_regs.c | 118 ++++++ arch/arm/mach-vt8500/pwm.c | 254 +++++++++++++ arch/arm/mach-vt8500/timer.c | 166 +++++++++ arch/arm/mach-vt8500/wm8505_7in.c | 80 ++++ 31 files changed, 2412 insertions(+), 0 deletions(-) create mode 100644 arch/arm/boot/compressed/head-vt8500.S create mode 100644 arch/arm/mach-vt8500/Kconfig create mode 100644 arch/arm/mach-vt8500/Makefile create mode 100644 arch/arm/mach-vt8500/Makefile.boot create mode 100644 arch/arm/mach-vt8500/bv07.c create mode 100644 arch/arm/mach-vt8500/devices.c create mode 100644 arch/arm/mach-vt8500/devices.h create mode 100644 arch/arm/mach-vt8500/gpio.c create mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/entry-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/gpio.h create mode 100644 arch/arm/mach-vt8500/include/mach/hardware.h create mode 100644 arch/arm/mach-vt8500/include/mach/io.h create mode 100644 arch/arm/mach-vt8500/include/mach/irq_defs.h create mode 100644 arch/arm/mach-vt8500/include/mach/irqs.h create mode 100644 arch/arm/mach-vt8500/include/mach/memory.h create mode 100644 arch/arm/mach-vt8500/include/mach/mmio_regs.h create mode 100644 arch/arm/mach-vt8500/include/mach/system.h create mode 100644 arch/arm/mach-vt8500/include/mach/timex.h create mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h create mode 100644 arch/arm/mach-vt8500/include/mach/vmalloc.h create mode 100644 arch/arm/mach-vt8500/include/mach/vt8500fb.h create mode 100644 arch/arm/mach-vt8500/irq.c create mode 100644 arch/arm/mach-vt8500/irq_defs.c create mode 100644 arch/arm/mach-vt8500/mmio_regs.c create mode 100644 arch/arm/mach-vt8500/pwm.c create mode 100644 arch/arm/mach-vt8500/timer.c create mode 100644 arch/arm/mach-vt8500/wm8505_7in.c
arch/arm/Kconfig +14 -0
@@ -843,6 +843,18 @@ config PLAT_SPEAR help Support for ST's SPEAr platform (SPEAr3xx, SPEAr6xx and SPEAr13xx). +config ARCH_VT8500 + bool "VIA/WonderMedia 85xx" + select CPU_ARM926T + select GENERIC_GPIO + select ARCH_HAS_CPUFREQ + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select HAVE_CLK + select HAVE_PWM + help + Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. endchoice #
@@ -973,6 +985,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vexpress/Kconfig" +source "arch/arm/mach-vt8500/Kconfig" + source "arch/arm/mach-w90x900/Kconfig" # Definitions to make life easier
arch/arm/Makefile +1 -0
@@ -189,6 +189,7 @@ machine-$(CONFIG_ARCH_U300) := u300 machine-$(CONFIG_ARCH_U8500) := ux500 machine-$(CONFIG_ARCH_VERSATILE) := versatile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress +machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x machine-$(CONFIG_FOOTBRIDGE) := footbridge
arch/arm/boot/compressed/Makefile +4 -0
@@ -29,6 +29,10 @@ ifeq ($(CONFIG_ARCH_SA1100),y) OBJS += head-sa1100.o endif +ifeq ($(CONFIG_ARCH_VT8500),y) +OBJS += head-vt8500.o +endif + ifeq ($(CONFIG_CPU_XSCALE),y) OBJS += head-xscale.o endif
arch/arm/boot/compressed/head-vt8500.S new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/Kconfig new file +63 -0
63 lines not on this page · raw message
arch/arm/mach-vt8500/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +obj-y += devices.o gpio.o irq.o irq_defs.o mmio_regs.o timer.o + +obj-$(CONFIG_MACH_BV07) += bv07.o +obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o + +obj-$(CONFIG_HAVE_PWM) += pwm.o
arch/arm/mach-vt8500/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x01000000
arch/arm/mach-vt8500/bv07.c new file +81 -0
81 lines not on this page · raw message
arch/arm/mach-vt8500/devices.c new file +442 -0
442 lines not on this page · raw message
arch/arm/mach-vt8500/devices.h new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/gpio.c new file +230 -0
230 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/debug-macro.S new file +31 -0
@@ -0,0 +1,31 @@ +/* + * arch/arm/mach-vt8500/include/mach/debug-macro.S + * + * Copyright (C) 2010 Alexey Charkov <[email protected]> + * + * 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 + mov \rp, #0x00200000 + orr \rv, \rp, #0xf8000000 + orr \rp, \rp, #0xd8000000 + .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
arch/arm/mach-vt8500/include/mach/entry-macro.S new file +32 -0
@@ -0,0 +1,32 @@ +/* + * arch/arm/mach-vt8500/include/mach/entry-macro.S + * + * Low-level IRQ helper macros for VIA VT8500 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_preamble, base, tmp + @ physical 0xd8140000 is virtual 0xf8140000 + mov \base, #0xf8000000 + orr \base, \base, #0x00140000 + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #63 @ may be false positive, check interrupt status + bne 1001f + ldr \irqstat, [\base, #0x84] + ands \irqstat, #0x80000000 + moveq \irqnr, #0 +1001: + .endm +
arch/arm/mach-vt8500/include/mach/gpio.h new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm-generic/gpio.h> + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq __gpio_to_irq
arch/arm/mach-vt8500/include/mach/hardware.h new file +12 -0
@@ -0,0 +1,12 @@ +/* arch/arm/mach-vt8500/include/mach/hardware.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. +* +*/
arch/arm/mach-vt8500/include/mach/io.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/io.h +* +* 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 +*/ +#ifndef __ASM_ARM_ARCH_IO_H +#define __ASM_ARM_ARCH_IO_H + +#define IO_SPACE_LIMIT 0xffff + +#define __io (a) ((void __iomem *)((a) + 0xf0000000)) +#define __mem_pci (a) (a) + +#endif
arch/arm/mach-vt8500/include/mach/irq_defs.h new file +124 -0
124 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/irqs.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* arch/arm/mach-vt8500/include/mach/irqs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 value is just to make the core happy, never used otherwise */ +#define NR_IRQS 128
arch/arm/mach-vt8500/include/mach/memory.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/memory.h +* +* Copyright (C) 2003 ARM Limited +* +* 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 __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET UL(0x00000000) + +#endif
arch/arm/mach-vt8500/include/mach/mmio_regs.h new file +90 -0
90 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/system.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/system.h +* +*/ +#include <asm/io.h> + +/* PM Software Reset request register */ +#define VT8500_PMSR 0xd8130060 + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +void __iomem *pmsr =ioremap (VT8500_PMSR ,4 ); +if (pmsr) +writel (1 , pmsr); +}
arch/arm/mach-vt8500/include/mach/timex.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* arch/arm/mach-vt8500/include/mach/timex.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 (3000000) + +#endif /* MACH_TIMEX_H */
arch/arm/mach-vt8500/include/mach/uncompress.h new file +37 -0
@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 0xd8200000 +#include <asm/io.h> + +static void putc (const char c) +{ +while (readb (UART0_PHYS +0x1c ) &0x2 ) +/* Tx busy, wait and poll */ ; + +writeb (c,UART0_PHYS ); +} + +static void flush (void ) +{ +} + +/* +* nothing to do +*/ +#define arch_decomp_setup () +#define arch_decomp_wdog ()
arch/arm/mach-vt8500/include/mach/vmalloc.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/vmalloc.h +* +* Copyright (C) 2000 Russell King. +* +* 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 +*/ +#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* VT8500/WM8505 Frame Buffer platform data definitions +* +* Copyright (C) 2010 Ed Spiridonov <[email protected]> +* +* 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 */
arch/arm/mach-vt8500/irq.c new file +178 -0
178 lines not on this page · raw message
arch/arm/mach-vt8500/irq_defs.c new file +173 -0
173 lines not on this page · raw message
arch/arm/mach-vt8500/mmio_regs.c new file +118 -0
118 lines not on this page · raw message
arch/arm/mach-vt8500/pwm.c new file +254 -0
254 lines not on this page · raw message
arch/arm/mach-vt8500/timer.c new file +166 -0
166 lines not on this page · raw message
arch/arm/mach-vt8500/wm8505_7in.c new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
1.7.3.2
Alexey Charkov
maintainerPATCH v4 1/6 ARM: Add basic architecture support for VIA/WonderMedia 85xx SoC's
In reply to Russell King - ARM LinuxThis adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505. Suitable code is selected (if compiled in) at early initialization time by reading a platform-specific identification register, as current bootloaders do not provide any reliable machine id to the kernel.
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
---
In addition to the fixes in v3 of this patch (to those issues that Russell has identified above), this iteration also brings in timeouts and cpu_relax() in busy waits (PWM and timer), according to what was suggested for device drivers in the related sub-threads.
It also incorporates a fix to the misspelling of Russell's name introduced in the comment to v3, for which I beg his pardon :-)
arch/arm/Kconfig | 14 + arch/arm/Makefile | 1 + arch/arm/boot/compressed/Makefile | 4 + arch/arm/boot/compressed/head-vt8500.S | 46 +++ arch/arm/mach-vt8500/Kconfig | 63 ++++ arch/arm/mach-vt8500/Makefile | 6 + arch/arm/mach-vt8500/Makefile.boot | 3 + arch/arm/mach-vt8500/bv07.c | 81 ++++ arch/arm/mach-vt8500/devices.c | 442 +++++++++++++++++++++++ arch/arm/mach-vt8500/devices.h | 46 +++ arch/arm/mach-vt8500/gpio.c | 230 ++++++++++++ arch/arm/mach-vt8500/include/mach/debug-macro.S | 31 ++ arch/arm/mach-vt8500/include/mach/entry-macro.S | 32 ++ arch/arm/mach-vt8500/include/mach/gpio.h | 6 + arch/arm/mach-vt8500/include/mach/hardware.h | 12 + arch/arm/mach-vt8500/include/mach/io.h | 28 ++ arch/arm/mach-vt8500/include/mach/irq_defs.h | 124 +++++++ arch/arm/mach-vt8500/include/mach/irqs.h | 22 ++ arch/arm/mach-vt8500/include/mach/memory.h | 28 ++ arch/arm/mach-vt8500/include/mach/mmio_regs.h | 90 +++++ arch/arm/mach-vt8500/include/mach/system.h | 20 + arch/arm/mach-vt8500/include/mach/timex.h | 26 ++ arch/arm/mach-vt8500/include/mach/uncompress.h | 37 ++ arch/arm/mach-vt8500/include/mach/vmalloc.h | 20 + arch/arm/mach-vt8500/include/mach/vt8500fb.h | 31 ++ arch/arm/mach-vt8500/irq.c | 179 +++++++++ arch/arm/mach-vt8500/irq_defs.c | 173 +++++++++ arch/arm/mach-vt8500/mmio_regs.c | 118 ++++++ arch/arm/mach-vt8500/pwm.c | 254 +++++++++++++ arch/arm/mach-vt8500/timer.c | 170 +++++++++ arch/arm/mach-vt8500/wm8505_7in.c | 80 ++++ 31 files changed, 2417 insertions(+), 0 deletions(-) create mode 100644 arch/arm/boot/compressed/head-vt8500.S create mode 100644 arch/arm/mach-vt8500/Kconfig create mode 100644 arch/arm/mach-vt8500/Makefile create mode 100644 arch/arm/mach-vt8500/Makefile.boot create mode 100644 arch/arm/mach-vt8500/bv07.c create mode 100644 arch/arm/mach-vt8500/devices.c create mode 100644 arch/arm/mach-vt8500/devices.h create mode 100644 arch/arm/mach-vt8500/gpio.c create mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/entry-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/gpio.h create mode 100644 arch/arm/mach-vt8500/include/mach/hardware.h create mode 100644 arch/arm/mach-vt8500/include/mach/io.h create mode 100644 arch/arm/mach-vt8500/include/mach/irq_defs.h create mode 100644 arch/arm/mach-vt8500/include/mach/irqs.h create mode 100644 arch/arm/mach-vt8500/include/mach/memory.h create mode 100644 arch/arm/mach-vt8500/include/mach/mmio_regs.h create mode 100644 arch/arm/mach-vt8500/include/mach/system.h create mode 100644 arch/arm/mach-vt8500/include/mach/timex.h create mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h create mode 100644 arch/arm/mach-vt8500/include/mach/vmalloc.h create mode 100644 arch/arm/mach-vt8500/include/mach/vt8500fb.h create mode 100644 arch/arm/mach-vt8500/irq.c create mode 100644 arch/arm/mach-vt8500/irq_defs.c create mode 100644 arch/arm/mach-vt8500/mmio_regs.c create mode 100644 arch/arm/mach-vt8500/pwm.c create mode 100644 arch/arm/mach-vt8500/timer.c create mode 100644 arch/arm/mach-vt8500/wm8505_7in.c
arch/arm/Kconfig +14 -0
@@ -843,6 +843,18 @@ config PLAT_SPEAR help Support for ST's SPEAr platform (SPEAr3xx, SPEAr6xx and SPEAr13xx). +config ARCH_VT8500 + bool "VIA/WonderMedia 85xx" + select CPU_ARM926T + select GENERIC_GPIO + select ARCH_HAS_CPUFREQ + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select HAVE_CLK + select HAVE_PWM + help + Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. endchoice #
@@ -973,6 +985,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vexpress/Kconfig" +source "arch/arm/mach-vt8500/Kconfig" + source "arch/arm/mach-w90x900/Kconfig" # Definitions to make life easier
arch/arm/Makefile +1 -0
@@ -189,6 +189,7 @@ machine-$(CONFIG_ARCH_U300) := u300 machine-$(CONFIG_ARCH_U8500) := ux500 machine-$(CONFIG_ARCH_VERSATILE) := versatile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress +machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x machine-$(CONFIG_FOOTBRIDGE) := footbridge
arch/arm/boot/compressed/Makefile +4 -0
@@ -29,6 +29,10 @@ ifeq ($(CONFIG_ARCH_SA1100),y) OBJS += head-sa1100.o endif +ifeq ($(CONFIG_ARCH_VT8500),y) +OBJS += head-vt8500.o +endif + ifeq ($(CONFIG_CPU_XSCALE),y) OBJS += head-xscale.o endif
arch/arm/boot/compressed/head-vt8500.S new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/Kconfig new file +63 -0
63 lines not on this page · raw message
arch/arm/mach-vt8500/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +obj-y += devices.o gpio.o irq.o irq_defs.o mmio_regs.o timer.o + +obj-$(CONFIG_MACH_BV07) += bv07.o +obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o + +obj-$(CONFIG_HAVE_PWM) += pwm.o
arch/arm/mach-vt8500/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x01000000
arch/arm/mach-vt8500/bv07.c new file +81 -0
81 lines not on this page · raw message
arch/arm/mach-vt8500/devices.c new file +442 -0
442 lines not on this page · raw message
arch/arm/mach-vt8500/devices.h new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/gpio.c new file +230 -0
230 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/debug-macro.S new file +31 -0
@@ -0,0 +1,31 @@ +/* + * arch/arm/mach-vt8500/include/mach/debug-macro.S + * + * Copyright (C) 2010 Alexey Charkov <[email protected]> + * + * 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 + mov \rp, #0x00200000 + orr \rv, \rp, #0xf8000000 + orr \rp, \rp, #0xd8000000 + .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
arch/arm/mach-vt8500/include/mach/entry-macro.S new file +32 -0
@@ -0,0 +1,32 @@ +/* + * arch/arm/mach-vt8500/include/mach/entry-macro.S + * + * Low-level IRQ helper macros for VIA VT8500 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_preamble, base, tmp + @ physical 0xd8140000 is virtual 0xf8140000 + mov \base, #0xf8000000 + orr \base, \base, #0x00140000 + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #63 @ may be false positive, check interrupt status + bne 1001f + ldr \irqstat, [\base, #0x84] + ands \irqstat, #0x80000000 + moveq \irqnr, #0 +1001: + .endm +
arch/arm/mach-vt8500/include/mach/gpio.h new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm-generic/gpio.h> + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq __gpio_to_irq
arch/arm/mach-vt8500/include/mach/hardware.h new file +12 -0
@@ -0,0 +1,12 @@ +/* arch/arm/mach-vt8500/include/mach/hardware.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. +* +*/
arch/arm/mach-vt8500/include/mach/io.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/io.h +* +* 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 +*/ +#ifndef __ASM_ARM_ARCH_IO_H +#define __ASM_ARM_ARCH_IO_H + +#define IO_SPACE_LIMIT 0xffff + +#define __io (a) ((void __iomem *)((a) + 0xf0000000)) +#define __mem_pci (a) (a) + +#endif
arch/arm/mach-vt8500/include/mach/irq_defs.h new file +124 -0
124 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/irqs.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* arch/arm/mach-vt8500/include/mach/irqs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 value is just to make the core happy, never used otherwise */ +#define NR_IRQS 128
arch/arm/mach-vt8500/include/mach/memory.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/memory.h +* +* Copyright (C) 2003 ARM Limited +* +* 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 __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET UL(0x00000000) + +#endif
arch/arm/mach-vt8500/include/mach/mmio_regs.h new file +90 -0
90 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/system.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/system.h +* +*/ +#include <asm/io.h> + +/* PM Software Reset request register */ +#define VT8500_PMSR 0xd8130060 + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +void __iomem *pmsr =ioremap (VT8500_PMSR ,4 ); +if (pmsr) +writel (1 , pmsr); +}
arch/arm/mach-vt8500/include/mach/timex.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* arch/arm/mach-vt8500/include/mach/timex.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 (3000000) + +#endif /* MACH_TIMEX_H */
arch/arm/mach-vt8500/include/mach/uncompress.h new file +37 -0
@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 0xd8200000 +#include <asm/io.h> + +static void putc (const char c) +{ +while (readb (UART0_PHYS +0x1c ) &0x2 ) +/* Tx busy, wait and poll */ ; + +writeb (c,UART0_PHYS ); +} + +static void flush (void ) +{ +} + +/* +* nothing to do +*/ +#define arch_decomp_setup () +#define arch_decomp_wdog ()
arch/arm/mach-vt8500/include/mach/vmalloc.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/vmalloc.h +* +* Copyright (C) 2000 Russell King. +* +* 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 +*/ +#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* VT8500/WM8505 Frame Buffer platform data definitions +* +* Copyright (C) 2010 Ed Spiridonov <[email protected]> +* +* 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 */
arch/arm/mach-vt8500/irq.c new file +179 -0
179 lines not on this page · raw message
arch/arm/mach-vt8500/irq_defs.c new file +173 -0
173 lines not on this page · raw message
arch/arm/mach-vt8500/mmio_regs.c new file +118 -0
118 lines not on this page · raw message
arch/arm/mach-vt8500/pwm.c new file +254 -0
254 lines not on this page · raw message
arch/arm/mach-vt8500/timer.c new file +170 -0
170 lines not on this page · raw message
arch/arm/mach-vt8500/wm8505_7in.c new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
1.7.3.2
arch/arm/mach-vt8500/include/mach/uncompress.h line 5
Quoted 11 lines
arch/arm/mach-vt8500/include/mach/uncompress.h new file +5
-0@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* Based on arch/arm/mach-dove/include/mach/uncompress.h
please replace dove with vt8500
saeed
Quoted 4 lines · saeed bishara
Quoted 4 lines
arch/arm/mach-vt8500/include/mach/uncompress.h new file +0
-1--- /dev/null
Quoted 8 lines
arch/arm/mach-vt8500/include/mach/uncompress.h line 5
Quoted 7 lines
+++
b/arch/arm/mach-vt8500/include/mach/uncompress.harch/arm/mach-vt8500/include/mach/uncompress.h new file +5
-0@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* Based on arch/arm/mach-dove/include/mach/uncompress.h please replace dove with vt8500
That doesn't make sense - how can a file be created, based upon itself?
Quoted 14 lines · Russell King - ARM Linux
Quoted 4 lines · saeed bishara
Quoted 4 lines
arch/arm/mach-vt8500/include/mach/uncompress.h new file +0
-1--- /dev/nullQuoted 8 lines
arch/arm/mach-vt8500/include/mach/uncompress.h line 5
Quoted 7 lines
+++
b/arch/arm/mach-vt8500/include/mach/uncompress.harch/arm/mach-vt8500/include/mach/uncompress.h new file +5
-0@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* Based on arch/arm/mach-dove/include/mach/uncompress.h please ?replace dove with vt8500
Quoted 1 line
That doesn't make sense - how can a file be created, based upon itself?
your are right, please ignore my comment.
saeed
Alexey Charkov
maintainerPATCH v5 1/6 ARM: Add basic architecture support for VIA/WonderMedia 85xx SoC's
In reply to Alexey CharkovThis adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505. Suitable code is selected (if compiled in) at early initialization time by reading a platform-specific identification register, as current bootloaders do not provide any reliable machine id to the kernel.
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
---
I decided to drop the override for sched_clock and just use the default implementation instead. As the hardware timer has quite a significant overhead when read (due to the necessity of busy-waiting for hardware synchronization), the default implementation turns out to perform much better (4s kernel initialization time vs. 14s on my device), and the code is simpler.
Please consider this version instead of the previous ones.
Best regards,
Alexey
arch/arm/Kconfig | 14 + arch/arm/Makefile | 1 + arch/arm/boot/compressed/Makefile | 4 + arch/arm/boot/compressed/head-vt8500.S | 46 +++ arch/arm/mach-vt8500/Kconfig | 63 ++++ arch/arm/mach-vt8500/Makefile | 6 + arch/arm/mach-vt8500/Makefile.boot | 3 + arch/arm/mach-vt8500/bv07.c | 81 ++++ arch/arm/mach-vt8500/devices.c | 442 +++++++++++++++++++++++ arch/arm/mach-vt8500/devices.h | 46 +++ arch/arm/mach-vt8500/gpio.c | 230 ++++++++++++ arch/arm/mach-vt8500/include/mach/debug-macro.S | 31 ++ arch/arm/mach-vt8500/include/mach/entry-macro.S | 32 ++ arch/arm/mach-vt8500/include/mach/gpio.h | 6 + arch/arm/mach-vt8500/include/mach/hardware.h | 12 + arch/arm/mach-vt8500/include/mach/io.h | 28 ++ arch/arm/mach-vt8500/include/mach/irq_defs.h | 124 +++++++ arch/arm/mach-vt8500/include/mach/irqs.h | 22 ++ arch/arm/mach-vt8500/include/mach/memory.h | 28 ++ arch/arm/mach-vt8500/include/mach/mmio_regs.h | 90 +++++ arch/arm/mach-vt8500/include/mach/system.h | 20 + arch/arm/mach-vt8500/include/mach/timex.h | 26 ++ arch/arm/mach-vt8500/include/mach/uncompress.h | 37 ++ arch/arm/mach-vt8500/include/mach/vmalloc.h | 20 + arch/arm/mach-vt8500/include/mach/vt8500fb.h | 31 ++ arch/arm/mach-vt8500/irq.c | 179 +++++++++ arch/arm/mach-vt8500/irq_defs.c | 173 +++++++++ arch/arm/mach-vt8500/mmio_regs.c | 118 ++++++ arch/arm/mach-vt8500/pwm.c | 254 +++++++++++++ arch/arm/mach-vt8500/timer.c | 154 ++++++++ arch/arm/mach-vt8500/wm8505_7in.c | 80 ++++ 31 files changed, 2401 insertions(+), 0 deletions(-) create mode 100644 arch/arm/boot/compressed/head-vt8500.S create mode 100644 arch/arm/mach-vt8500/Kconfig create mode 100644 arch/arm/mach-vt8500/Makefile create mode 100644 arch/arm/mach-vt8500/Makefile.boot create mode 100644 arch/arm/mach-vt8500/bv07.c create mode 100644 arch/arm/mach-vt8500/devices.c create mode 100644 arch/arm/mach-vt8500/devices.h create mode 100644 arch/arm/mach-vt8500/gpio.c create mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/entry-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/gpio.h create mode 100644 arch/arm/mach-vt8500/include/mach/hardware.h create mode 100644 arch/arm/mach-vt8500/include/mach/io.h create mode 100644 arch/arm/mach-vt8500/include/mach/irq_defs.h create mode 100644 arch/arm/mach-vt8500/include/mach/irqs.h create mode 100644 arch/arm/mach-vt8500/include/mach/memory.h create mode 100644 arch/arm/mach-vt8500/include/mach/mmio_regs.h create mode 100644 arch/arm/mach-vt8500/include/mach/system.h create mode 100644 arch/arm/mach-vt8500/include/mach/timex.h create mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h create mode 100644 arch/arm/mach-vt8500/include/mach/vmalloc.h create mode 100644 arch/arm/mach-vt8500/include/mach/vt8500fb.h create mode 100644 arch/arm/mach-vt8500/irq.c create mode 100644 arch/arm/mach-vt8500/irq_defs.c create mode 100644 arch/arm/mach-vt8500/mmio_regs.c create mode 100644 arch/arm/mach-vt8500/pwm.c create mode 100644 arch/arm/mach-vt8500/timer.c create mode 100644 arch/arm/mach-vt8500/wm8505_7in.c
arch/arm/Kconfig +14 -0
@@ -843,6 +843,18 @@ config PLAT_SPEAR help Support for ST's SPEAr platform (SPEAr3xx, SPEAr6xx and SPEAr13xx). +config ARCH_VT8500 + bool "VIA/WonderMedia 85xx" + select CPU_ARM926T + select GENERIC_GPIO + select ARCH_HAS_CPUFREQ + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select HAVE_CLK + select HAVE_PWM + help + Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. endchoice #
@@ -973,6 +985,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vexpress/Kconfig" +source "arch/arm/mach-vt8500/Kconfig" + source "arch/arm/mach-w90x900/Kconfig" # Definitions to make life easier
arch/arm/Makefile +1 -0
@@ -189,6 +189,7 @@ machine-$(CONFIG_ARCH_U300) := u300 machine-$(CONFIG_ARCH_U8500) := ux500 machine-$(CONFIG_ARCH_VERSATILE) := versatile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress +machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x machine-$(CONFIG_FOOTBRIDGE) := footbridge
arch/arm/boot/compressed/Makefile +4 -0
@@ -29,6 +29,10 @@ ifeq ($(CONFIG_ARCH_SA1100),y) OBJS += head-sa1100.o endif +ifeq ($(CONFIG_ARCH_VT8500),y) +OBJS += head-vt8500.o +endif + ifeq ($(CONFIG_CPU_XSCALE),y) OBJS += head-xscale.o endif
arch/arm/boot/compressed/head-vt8500.S new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/Kconfig new file +63 -0
63 lines not on this page · raw message
arch/arm/mach-vt8500/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +obj-y += devices.o gpio.o irq.o irq_defs.o mmio_regs.o timer.o + +obj-$(CONFIG_MACH_BV07) += bv07.o +obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o + +obj-$(CONFIG_HAVE_PWM) += pwm.o
arch/arm/mach-vt8500/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x01000000
arch/arm/mach-vt8500/bv07.c new file +81 -0
81 lines not on this page · raw message
arch/arm/mach-vt8500/devices.c new file +442 -0
442 lines not on this page · raw message
arch/arm/mach-vt8500/devices.h new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/gpio.c new file +230 -0
230 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/debug-macro.S new file +31 -0
@@ -0,0 +1,31 @@ +/* + * arch/arm/mach-vt8500/include/mach/debug-macro.S + * + * Copyright (C) 2010 Alexey Charkov <[email protected]> + * + * 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 + mov \rp, #0x00200000 + orr \rv, \rp, #0xf8000000 + orr \rp, \rp, #0xd8000000 + .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
arch/arm/mach-vt8500/include/mach/entry-macro.S new file +32 -0
@@ -0,0 +1,32 @@ +/* + * arch/arm/mach-vt8500/include/mach/entry-macro.S + * + * Low-level IRQ helper macros for VIA VT8500 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_preamble, base, tmp + @ physical 0xd8140000 is virtual 0xf8140000 + mov \base, #0xf8000000 + orr \base, \base, #0x00140000 + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #63 @ may be false positive, check interrupt status + bne 1001f + ldr \irqstat, [\base, #0x84] + ands \irqstat, #0x80000000 + moveq \irqnr, #0 +1001: + .endm +
arch/arm/mach-vt8500/include/mach/gpio.h new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm-generic/gpio.h> + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq __gpio_to_irq
arch/arm/mach-vt8500/include/mach/hardware.h new file +12 -0
@@ -0,0 +1,12 @@ +/* arch/arm/mach-vt8500/include/mach/hardware.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. +* +*/
arch/arm/mach-vt8500/include/mach/io.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/io.h +* +* 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 +*/ +#ifndef __ASM_ARM_ARCH_IO_H +#define __ASM_ARM_ARCH_IO_H + +#define IO_SPACE_LIMIT 0xffff + +#define __io (a) ((void __iomem *)((a) + 0xf0000000)) +#define __mem_pci (a) (a) + +#endif
arch/arm/mach-vt8500/include/mach/irq_defs.h new file +124 -0
124 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/irqs.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* arch/arm/mach-vt8500/include/mach/irqs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 value is just to make the core happy, never used otherwise */ +#define NR_IRQS 128
arch/arm/mach-vt8500/include/mach/memory.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/memory.h +* +* Copyright (C) 2003 ARM Limited +* +* 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 __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET UL(0x00000000) + +#endif
arch/arm/mach-vt8500/include/mach/mmio_regs.h new file +90 -0
90 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/system.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/system.h +* +*/ +#include <asm/io.h> + +/* PM Software Reset request register */ +#define VT8500_PMSR 0xd8130060 + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +void __iomem *pmsr =ioremap (VT8500_PMSR ,4 ); +if (pmsr) +writel (1 , pmsr); +}
arch/arm/mach-vt8500/include/mach/timex.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* arch/arm/mach-vt8500/include/mach/timex.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 (3000000) + +#endif /* MACH_TIMEX_H */
arch/arm/mach-vt8500/include/mach/uncompress.h new file +37 -0
@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 0xd8200000 +#include <asm/io.h> + +static void putc (const char c) +{ +while (readb (UART0_PHYS +0x1c ) &0x2 ) +/* Tx busy, wait and poll */ ; + +writeb (c,UART0_PHYS ); +} + +static void flush (void ) +{ +} + +/* +* nothing to do +*/ +#define arch_decomp_setup () +#define arch_decomp_wdog ()
arch/arm/mach-vt8500/include/mach/vmalloc.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/vmalloc.h +* +* Copyright (C) 2000 Russell King. +* +* 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 +*/ +#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* VT8500/WM8505 Frame Buffer platform data definitions +* +* Copyright (C) 2010 Ed Spiridonov <[email protected]> +* +* 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 */
arch/arm/mach-vt8500/irq.c new file +179 -0
179 lines not on this page · raw message
arch/arm/mach-vt8500/irq_defs.c new file +173 -0
173 lines not on this page · raw message
arch/arm/mach-vt8500/mmio_regs.c new file +118 -0
118 lines not on this page · raw message
arch/arm/mach-vt8500/pwm.c new file +254 -0
254 lines not on this page · raw message
arch/arm/mach-vt8500/timer.c new file +154 -0
154 lines not on this page · raw message
arch/arm/mach-vt8500/wm8505_7in.c new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
1.7.3.2
The good news is that it's getting harder to find things wrong... Only three points follow below.
Quoted 20 lines · Alexey Charkov
arch/arm/mach-vt8500/bv07.c new file +14
-0@@ -0,0 +1,81 @@ +/* +* arch/arm/mach-vt8500/bv07.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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.
arch/arm/mach-vt8500/bv07.c line 24
Quoted 10 lines
arch/arm/mach-vt8500/bv07.c new file +10
-0+* +* 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 +*/ + +#include <asm/mach-types.h> +#include <asm/mach/arch.h> +#include <linux/io.h> +#include <linux/pm.h>
asm/ includes after linux/ includes please (applies to multiple files).
Quoted 16 lines
arch/arm/mach-vt8500/gpio.c new file +10
-0@@ -0,0 +1,230 @@ +/* linux/arch/arm/mach-vt8500/gpio.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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
arch/arm/mach-vt8500/gpio.c line 20
Quoted 10 lines
arch/arm/mach-vt8500/gpio.c new file +10
-0+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <linux/init.h> +#include <linux/irq.h> +#include <linux/io.h> + +#include <mach/gpio.h>
linux/gpio.h please.
Quoted 21 lines
arch/arm/mach-vt8500/gpio.c new file +21
-0+static int vt8500_irq_set_type (unsigned int irq,unsigned int flow_type) +{ +void __iomem *base = ic_regbase; +unsigned int orig_irq = irq; +if (irq >=64 ) { + base = sic_regbase; + irq -=64 ; + } +switch (flow_type) { +case IRQF_TRIGGER_LOW : +return -EINVAL ; +case IRQF_TRIGGER_HIGH : +writeb ((readb (base + +VT8500_IC_DCTR + irq) & ~(3 <<4 )) + |VT8500_TRIGGER_HIGH , base + +VT8500_IC_DCTR + irq); +set_irq_handler (orig_irq, handle_level_irq); +break ; +case IRQF_TRIGGER_FALLING : +writeb ((readb (base + + VT8500_IC_DCTR + irq) & ~(3 << 4))
arch/arm/mach-vt8500/gpio.c line 51
Quoted 10 lines
arch/arm/mach-vt8500/gpio.c new file +10
-0+ | VT8500_TRIGGER_FALLING, base + + VT8500_IC_DCTR + irq); +set_irq_handler (orig_irq, handle_edge_irq); +break ; +case IRQF_TRIGGER_RISING : +writeb ((readb (base + +VT8500_IC_DCTR + irq) & ~(3 <<4 )) + |VT8500_TRIGGER_RISING , base + +VT8500_IC_DCTR + irq); +set_irq_handler (orig_irq, handle_edge_irq);
These set_irq_handler's probably warn if you have spinlock debugging enabled.
Alexey Charkov
maintainerPATCH v6 1/6 ARM: Add basic architecture support for VIA/WonderMedia 85xx SoC's
This adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505. Suitable code is selected (if compiled in) at early initialization time by reading a platform-specific identification register, as current bootloaders do not provide any reliable machine id to the kernel.
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
---
This fixes asm/ versus linux/ includes ordering and changes <mach/gpio.h> to <linux/gpio.h> as Russell has requested.
Russell, could you please elaborate on your comment regarding spinlocks and irq handlers? I always compile my kernel with all kinds of lock debugging, and have not run into any associated warnings. Is there anything suspicious specifically?
Thanks,
Alexey
arch/arm/Kconfig | 14 + arch/arm/Makefile | 1 + arch/arm/boot/compressed/Makefile | 4 + arch/arm/boot/compressed/head-vt8500.S | 46 +++ arch/arm/mach-vt8500/Kconfig | 63 ++++ arch/arm/mach-vt8500/Makefile | 6 + arch/arm/mach-vt8500/Makefile.boot | 3 + arch/arm/mach-vt8500/bv07.c | 82 +++++ arch/arm/mach-vt8500/devices.c | 442 +++++++++++++++++++++++ arch/arm/mach-vt8500/devices.h | 46 +++ arch/arm/mach-vt8500/gpio.c | 230 ++++++++++++ arch/arm/mach-vt8500/include/mach/debug-macro.S | 31 ++ arch/arm/mach-vt8500/include/mach/entry-macro.S | 32 ++ arch/arm/mach-vt8500/include/mach/gpio.h | 6 + arch/arm/mach-vt8500/include/mach/hardware.h | 12 + arch/arm/mach-vt8500/include/mach/io.h | 28 ++ arch/arm/mach-vt8500/include/mach/irq_defs.h | 124 +++++++ arch/arm/mach-vt8500/include/mach/irqs.h | 22 ++ arch/arm/mach-vt8500/include/mach/memory.h | 28 ++ arch/arm/mach-vt8500/include/mach/mmio_regs.h | 90 +++++ arch/arm/mach-vt8500/include/mach/system.h | 20 + arch/arm/mach-vt8500/include/mach/timex.h | 26 ++ arch/arm/mach-vt8500/include/mach/uncompress.h | 37 ++ arch/arm/mach-vt8500/include/mach/vmalloc.h | 20 + arch/arm/mach-vt8500/include/mach/vt8500fb.h | 31 ++ arch/arm/mach-vt8500/irq.c | 179 +++++++++ arch/arm/mach-vt8500/irq_defs.c | 173 +++++++++ arch/arm/mach-vt8500/mmio_regs.c | 118 ++++++ arch/arm/mach-vt8500/pwm.c | 254 +++++++++++++ arch/arm/mach-vt8500/timer.c | 154 ++++++++ arch/arm/mach-vt8500/wm8505_7in.c | 81 ++++ 31 files changed, 2403 insertions(+), 0 deletions(-) create mode 100644 arch/arm/boot/compressed/head-vt8500.S create mode 100644 arch/arm/mach-vt8500/Kconfig create mode 100644 arch/arm/mach-vt8500/Makefile create mode 100644 arch/arm/mach-vt8500/Makefile.boot create mode 100644 arch/arm/mach-vt8500/bv07.c create mode 100644 arch/arm/mach-vt8500/devices.c create mode 100644 arch/arm/mach-vt8500/devices.h create mode 100644 arch/arm/mach-vt8500/gpio.c create mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/entry-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/gpio.h create mode 100644 arch/arm/mach-vt8500/include/mach/hardware.h create mode 100644 arch/arm/mach-vt8500/include/mach/io.h create mode 100644 arch/arm/mach-vt8500/include/mach/irq_defs.h create mode 100644 arch/arm/mach-vt8500/include/mach/irqs.h create mode 100644 arch/arm/mach-vt8500/include/mach/memory.h create mode 100644 arch/arm/mach-vt8500/include/mach/mmio_regs.h create mode 100644 arch/arm/mach-vt8500/include/mach/system.h create mode 100644 arch/arm/mach-vt8500/include/mach/timex.h create mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h create mode 100644 arch/arm/mach-vt8500/include/mach/vmalloc.h create mode 100644 arch/arm/mach-vt8500/include/mach/vt8500fb.h create mode 100644 arch/arm/mach-vt8500/irq.c create mode 100644 arch/arm/mach-vt8500/irq_defs.c create mode 100644 arch/arm/mach-vt8500/mmio_regs.c create mode 100644 arch/arm/mach-vt8500/pwm.c create mode 100644 arch/arm/mach-vt8500/timer.c create mode 100644 arch/arm/mach-vt8500/wm8505_7in.c
arch/arm/Kconfig +14 -0
@@ -843,6 +843,18 @@ config PLAT_SPEAR help Support for ST's SPEAr platform (SPEAr3xx, SPEAr6xx and SPEAr13xx). +config ARCH_VT8500 + bool "VIA/WonderMedia 85xx" + select CPU_ARM926T + select GENERIC_GPIO + select ARCH_HAS_CPUFREQ + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select HAVE_CLK + select HAVE_PWM + help + Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. endchoice #
@@ -973,6 +985,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vexpress/Kconfig" +source "arch/arm/mach-vt8500/Kconfig" + source "arch/arm/mach-w90x900/Kconfig" # Definitions to make life easier
arch/arm/Makefile +1 -0
@@ -189,6 +189,7 @@ machine-$(CONFIG_ARCH_U300) := u300 machine-$(CONFIG_ARCH_U8500) := ux500 machine-$(CONFIG_ARCH_VERSATILE) := versatile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress +machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x machine-$(CONFIG_FOOTBRIDGE) := footbridge
arch/arm/boot/compressed/Makefile +4 -0
@@ -29,6 +29,10 @@ ifeq ($(CONFIG_ARCH_SA1100),y) OBJS += head-sa1100.o endif +ifeq ($(CONFIG_ARCH_VT8500),y) +OBJS += head-vt8500.o +endif + ifeq ($(CONFIG_CPU_XSCALE),y) OBJS += head-xscale.o endif
arch/arm/boot/compressed/head-vt8500.S new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/Kconfig new file +63 -0
63 lines not on this page · raw message
arch/arm/mach-vt8500/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +obj-y += devices.o gpio.o irq.o irq_defs.o mmio_regs.o timer.o + +obj-$(CONFIG_MACH_BV07) += bv07.o +obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o + +obj-$(CONFIG_HAVE_PWM) += pwm.o
arch/arm/mach-vt8500/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x01000000
arch/arm/mach-vt8500/bv07.c new file +82 -0
82 lines not on this page · raw message
arch/arm/mach-vt8500/devices.c new file +442 -0
442 lines not on this page · raw message
arch/arm/mach-vt8500/devices.h new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/gpio.c new file +230 -0
230 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/debug-macro.S new file +31 -0
@@ -0,0 +1,31 @@ +/* + * arch/arm/mach-vt8500/include/mach/debug-macro.S + * + * Copyright (C) 2010 Alexey Charkov <[email protected]> + * + * 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 + mov \rp, #0x00200000 + orr \rv, \rp, #0xf8000000 + orr \rp, \rp, #0xd8000000 + .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
arch/arm/mach-vt8500/include/mach/entry-macro.S new file +32 -0
@@ -0,0 +1,32 @@ +/* + * arch/arm/mach-vt8500/include/mach/entry-macro.S + * + * Low-level IRQ helper macros for VIA VT8500 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_preamble, base, tmp + @ physical 0xd8140000 is virtual 0xf8140000 + mov \base, #0xf8000000 + orr \base, \base, #0x00140000 + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #63 @ may be false positive, check interrupt status + bne 1001f + ldr \irqstat, [\base, #0x84] + ands \irqstat, #0x80000000 + moveq \irqnr, #0 +1001: + .endm +
arch/arm/mach-vt8500/include/mach/gpio.h new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm-generic/gpio.h> + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq __gpio_to_irq
arch/arm/mach-vt8500/include/mach/hardware.h new file +12 -0
@@ -0,0 +1,12 @@ +/* arch/arm/mach-vt8500/include/mach/hardware.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. +* +*/
arch/arm/mach-vt8500/include/mach/io.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/io.h +* +* 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 +*/ +#ifndef __ASM_ARM_ARCH_IO_H +#define __ASM_ARM_ARCH_IO_H + +#define IO_SPACE_LIMIT 0xffff + +#define __io (a) ((void __iomem *)((a) + 0xf0000000)) +#define __mem_pci (a) (a) + +#endif
arch/arm/mach-vt8500/include/mach/irq_defs.h new file +124 -0
124 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/irqs.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* arch/arm/mach-vt8500/include/mach/irqs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 value is just to make the core happy, never used otherwise */ +#define NR_IRQS 128
arch/arm/mach-vt8500/include/mach/memory.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/memory.h +* +* Copyright (C) 2003 ARM Limited +* +* 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 __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET UL(0x00000000) + +#endif
arch/arm/mach-vt8500/include/mach/mmio_regs.h new file +90 -0
90 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/system.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/system.h +* +*/ +#include <asm/io.h> + +/* PM Software Reset request register */ +#define VT8500_PMSR 0xd8130060 + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +void __iomem *pmsr =ioremap (VT8500_PMSR ,4 ); +if (pmsr) +writel (1 , pmsr); +}
arch/arm/mach-vt8500/include/mach/timex.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* arch/arm/mach-vt8500/include/mach/timex.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 (3000000) + +#endif /* MACH_TIMEX_H */
arch/arm/mach-vt8500/include/mach/uncompress.h new file +37 -0
@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 0xd8200000 +#include <asm/io.h> + +static void putc (const char c) +{ +while (readb (UART0_PHYS +0x1c ) &0x2 ) +/* Tx busy, wait and poll */ ; + +writeb (c,UART0_PHYS ); +} + +static void flush (void ) +{ +} + +/* +* nothing to do +*/ +#define arch_decomp_setup () +#define arch_decomp_wdog ()
arch/arm/mach-vt8500/include/mach/vmalloc.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/vmalloc.h +* +* Copyright (C) 2000 Russell King. +* +* 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 +*/ +#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* VT8500/WM8505 Frame Buffer platform data definitions +* +* Copyright (C) 2010 Ed Spiridonov <[email protected]> +* +* 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 */
arch/arm/mach-vt8500/irq.c new file +179 -0
179 lines not on this page · raw message
arch/arm/mach-vt8500/irq_defs.c new file +173 -0
173 lines not on this page · raw message
arch/arm/mach-vt8500/mmio_regs.c new file +118 -0
118 lines not on this page · raw message
arch/arm/mach-vt8500/pwm.c new file +254 -0
254 lines not on this page · raw message
arch/arm/mach-vt8500/timer.c new file +154 -0
154 lines not on this page · raw message
arch/arm/mach-vt8500/wm8505_7in.c new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
1.7.3.2
Alexey Charkov
maintainerQuoted 4 lines
Russell, could you please elaborate on your comment regarding spinlocks and irq handlers? I always compile my kernel with all kinds of lock debugging, and have not run into any associated warnings. Is there anything suspicious specifically?
My fault: actually, those were not all lock debugging functions. It really prints errors when lock correctness proving is enabled. I thus decided to just assign the callback functions directly to irq_desc struct fields, as it is done in mach-msm.
There is, however, another error showing up: it complains about my use of ioremap inside arch_reset(). Is it fine to just hardcode the virtual address of the respective register and use that directly in this case? Something along the lines of:
/* PM Software Reset request register */
#define VT8500_PMSR_VIRT 0xf8130060
static inline void arch_reset(char mode, const char *cmd)
{
writel(1, VT8500_PMSR_VIRT);
}Thanks,
Alexey
Alexey Charkov
maintainerPATCH v7 1/6 ARM: Add basic architecture support for VIA/WonderMedia 85xx SoC's
In reply to Russell King - ARM LinuxThis adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505. Suitable code is selected (if compiled in) at early initialization time by reading a platform-specific identification register, as current bootloaders do not provide any reliable machine id to the kernel.
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
---
There were no further comments on v6 of this patch, so this just introduces direct assignment of handler callbacks to irq_desc fields to avoid spinlock problems. For the same reason, the ioremap call in arch_reset() was removed and replaced with a direct write to the relevant virtual memory address.
Please review and, if possible, merge this for inclusion in 2.6.38 together with the input-related code [1], which Dmitry Torokhov acks and expects to be merged together with the arch code [2].
Serial, USB and fbdev-related parts have already been merged to their respective trees, and RTC is awaiting maintainer's resolution after having implemented the suggestions.
Thanks,
Alexey
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2010-November/030782.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2010-November/031358.html
arch/arm/Kconfig | 14 + arch/arm/Makefile | 1 + arch/arm/boot/compressed/Makefile | 4 + arch/arm/boot/compressed/head-vt8500.S | 46 +++ arch/arm/mach-vt8500/Kconfig | 63 ++++ arch/arm/mach-vt8500/Makefile | 6 + arch/arm/mach-vt8500/Makefile.boot | 3 + arch/arm/mach-vt8500/bv07.c | 82 +++++ arch/arm/mach-vt8500/devices.c | 442 +++++++++++++++++++++++ arch/arm/mach-vt8500/devices.h | 46 +++ arch/arm/mach-vt8500/gpio.c | 230 ++++++++++++ arch/arm/mach-vt8500/include/mach/debug-macro.S | 31 ++ arch/arm/mach-vt8500/include/mach/entry-macro.S | 32 ++ arch/arm/mach-vt8500/include/mach/gpio.h | 6 + arch/arm/mach-vt8500/include/mach/hardware.h | 12 + arch/arm/mach-vt8500/include/mach/io.h | 28 ++ arch/arm/mach-vt8500/include/mach/irq_defs.h | 124 +++++++ arch/arm/mach-vt8500/include/mach/irqs.h | 22 ++ arch/arm/mach-vt8500/include/mach/memory.h | 28 ++ arch/arm/mach-vt8500/include/mach/mmio_regs.h | 90 +++++ arch/arm/mach-vt8500/include/mach/system.h | 18 + arch/arm/mach-vt8500/include/mach/timex.h | 26 ++ arch/arm/mach-vt8500/include/mach/uncompress.h | 37 ++ arch/arm/mach-vt8500/include/mach/vmalloc.h | 20 + arch/arm/mach-vt8500/include/mach/vt8500fb.h | 31 ++ arch/arm/mach-vt8500/irq.c | 179 +++++++++ arch/arm/mach-vt8500/irq_defs.c | 173 +++++++++ arch/arm/mach-vt8500/mmio_regs.c | 118 ++++++ arch/arm/mach-vt8500/pwm.c | 254 +++++++++++++ arch/arm/mach-vt8500/timer.c | 154 ++++++++ arch/arm/mach-vt8500/wm8505_7in.c | 81 ++++ 31 files changed, 2401 insertions(+), 0 deletions(-) create mode 100644 arch/arm/boot/compressed/head-vt8500.S create mode 100644 arch/arm/mach-vt8500/Kconfig create mode 100644 arch/arm/mach-vt8500/Makefile create mode 100644 arch/arm/mach-vt8500/Makefile.boot create mode 100644 arch/arm/mach-vt8500/bv07.c create mode 100644 arch/arm/mach-vt8500/devices.c create mode 100644 arch/arm/mach-vt8500/devices.h create mode 100644 arch/arm/mach-vt8500/gpio.c create mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/entry-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/gpio.h create mode 100644 arch/arm/mach-vt8500/include/mach/hardware.h create mode 100644 arch/arm/mach-vt8500/include/mach/io.h create mode 100644 arch/arm/mach-vt8500/include/mach/irq_defs.h create mode 100644 arch/arm/mach-vt8500/include/mach/irqs.h create mode 100644 arch/arm/mach-vt8500/include/mach/memory.h create mode 100644 arch/arm/mach-vt8500/include/mach/mmio_regs.h create mode 100644 arch/arm/mach-vt8500/include/mach/system.h create mode 100644 arch/arm/mach-vt8500/include/mach/timex.h create mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h create mode 100644 arch/arm/mach-vt8500/include/mach/vmalloc.h create mode 100644 arch/arm/mach-vt8500/include/mach/vt8500fb.h create mode 100644 arch/arm/mach-vt8500/irq.c create mode 100644 arch/arm/mach-vt8500/irq_defs.c create mode 100644 arch/arm/mach-vt8500/mmio_regs.c create mode 100644 arch/arm/mach-vt8500/pwm.c create mode 100644 arch/arm/mach-vt8500/timer.c create mode 100644 arch/arm/mach-vt8500/wm8505_7in.c
arch/arm/Kconfig +14 -0
@@ -843,6 +843,18 @@ config PLAT_SPEAR help Support for ST's SPEAr platform (SPEAr3xx, SPEAr6xx and SPEAr13xx). +config ARCH_VT8500 + bool "VIA/WonderMedia 85xx" + select CPU_ARM926T + select GENERIC_GPIO + select ARCH_HAS_CPUFREQ + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select HAVE_CLK + select HAVE_PWM + help + Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. endchoice #
@@ -973,6 +985,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vexpress/Kconfig" +source "arch/arm/mach-vt8500/Kconfig" + source "arch/arm/mach-w90x900/Kconfig" # Definitions to make life easier
arch/arm/Makefile +1 -0
@@ -189,6 +189,7 @@ machine-$(CONFIG_ARCH_U300) := u300 machine-$(CONFIG_ARCH_U8500) := ux500 machine-$(CONFIG_ARCH_VERSATILE) := versatile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress +machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x machine-$(CONFIG_FOOTBRIDGE) := footbridge
arch/arm/boot/compressed/Makefile +4 -0
@@ -29,6 +29,10 @@ ifeq ($(CONFIG_ARCH_SA1100),y) OBJS += head-sa1100.o endif +ifeq ($(CONFIG_ARCH_VT8500),y) +OBJS += head-vt8500.o +endif + ifeq ($(CONFIG_CPU_XSCALE),y) OBJS += head-xscale.o endif
arch/arm/boot/compressed/head-vt8500.S new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/Kconfig new file +63 -0
63 lines not on this page · raw message
arch/arm/mach-vt8500/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +obj-y += devices.o gpio.o irq.o irq_defs.o mmio_regs.o timer.o + +obj-$(CONFIG_MACH_BV07) += bv07.o +obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o + +obj-$(CONFIG_HAVE_PWM) += pwm.o
arch/arm/mach-vt8500/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x01000000
arch/arm/mach-vt8500/bv07.c new file +82 -0
82 lines not on this page · raw message
arch/arm/mach-vt8500/devices.c new file +442 -0
442 lines not on this page · raw message
arch/arm/mach-vt8500/devices.h new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/gpio.c new file +230 -0
230 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/debug-macro.S new file +31 -0
@@ -0,0 +1,31 @@ +/* + * arch/arm/mach-vt8500/include/mach/debug-macro.S + * + * Copyright (C) 2010 Alexey Charkov <[email protected]> + * + * 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 + mov \rp, #0x00200000 + orr \rv, \rp, #0xf8000000 + orr \rp, \rp, #0xd8000000 + .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
arch/arm/mach-vt8500/include/mach/entry-macro.S new file +32 -0
@@ -0,0 +1,32 @@ +/* + * arch/arm/mach-vt8500/include/mach/entry-macro.S + * + * Low-level IRQ helper macros for VIA VT8500 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_preamble, base, tmp + @ physical 0xd8140000 is virtual 0xf8140000 + mov \base, #0xf8000000 + orr \base, \base, #0x00140000 + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #63 @ may be false positive, check interrupt status + bne 1001f + ldr \irqstat, [\base, #0x84] + ands \irqstat, #0x80000000 + moveq \irqnr, #0 +1001: + .endm +
arch/arm/mach-vt8500/include/mach/gpio.h new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm-generic/gpio.h> + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq __gpio_to_irq
arch/arm/mach-vt8500/include/mach/hardware.h new file +12 -0
@@ -0,0 +1,12 @@ +/* arch/arm/mach-vt8500/include/mach/hardware.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. +* +*/
arch/arm/mach-vt8500/include/mach/io.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/io.h +* +* 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 +*/ +#ifndef __ASM_ARM_ARCH_IO_H +#define __ASM_ARM_ARCH_IO_H + +#define IO_SPACE_LIMIT 0xffff + +#define __io (a) ((void __iomem *)((a) + 0xf0000000)) +#define __mem_pci (a) (a) + +#endif
arch/arm/mach-vt8500/include/mach/irq_defs.h new file +124 -0
124 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/irqs.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* arch/arm/mach-vt8500/include/mach/irqs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 value is just to make the core happy, never used otherwise */ +#define NR_IRQS 128
arch/arm/mach-vt8500/include/mach/memory.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/memory.h +* +* Copyright (C) 2003 ARM Limited +* +* 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 __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET UL(0x00000000) + +#endif
arch/arm/mach-vt8500/include/mach/mmio_regs.h new file +90 -0
90 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/system.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* arch/arm/mach-vt8500/include/mach/system.h +* +*/ +#include <asm/io.h> + +/* PM Software Reset request register */ +#define VT8500_PMSR_VIRT 0xf8130060 + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +writel (1 ,VT8500_PMSR_VIRT ); +}
arch/arm/mach-vt8500/include/mach/timex.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* arch/arm/mach-vt8500/include/mach/timex.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 (3000000) + +#endif /* MACH_TIMEX_H */
arch/arm/mach-vt8500/include/mach/uncompress.h new file +37 -0
@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 0xd8200000 +#include <asm/io.h> + +static void putc (const char c) +{ +while (readb (UART0_PHYS +0x1c ) &0x2 ) +/* Tx busy, wait and poll */ ; + +writeb (c,UART0_PHYS ); +} + +static void flush (void ) +{ +} + +/* +* nothing to do +*/ +#define arch_decomp_setup () +#define arch_decomp_wdog ()
arch/arm/mach-vt8500/include/mach/vmalloc.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/vmalloc.h +* +* Copyright (C) 2000 Russell King. +* +* 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 +*/ +#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* VT8500/WM8505 Frame Buffer platform data definitions +* +* Copyright (C) 2010 Ed Spiridonov <[email protected]> +* +* 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 */
arch/arm/mach-vt8500/irq.c new file +179 -0
179 lines not on this page · raw message
arch/arm/mach-vt8500/irq_defs.c new file +173 -0
173 lines not on this page · raw message
arch/arm/mach-vt8500/mmio_regs.c new file +118 -0
118 lines not on this page · raw message
arch/arm/mach-vt8500/pwm.c new file +254 -0
254 lines not on this page · raw message
arch/arm/mach-vt8500/timer.c new file +154 -0
154 lines not on this page · raw message
arch/arm/mach-vt8500/wm8505_7in.c new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
1.7.3.2
Alexey Charkov
maintainerPATCH v8 1/6 ARM: Add basic architecture support for VIA/WonderMedia 85xx SoC's
In reply to Russell King - ARM LinuxThis adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505. Suitable code is selected (if compiled in) at early initialization time by reading a platform-specific identification register, as current bootloaders do not provide any reliable machine id to the kernel.
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
---
Compared to the previous submission, this version contains a definition for 1024x576 panels (courtesy of John Mitchell) and slight adjustments for other panel timings. Also, the reservation callback is now assigned above the map_io one, and the Kconfig reference to CLK is dropped for now (as there is no code for that yet, and the framework is changing, as far as I could see).
Russell, are there any outstanding issues with this code that I should fix before you could take it to your tree? The merge window is approaching, so I'm getting a bit anxious :-)
Best regards,
Alexey
arch/arm/Kconfig | 13 + arch/arm/Makefile | 1 + arch/arm/boot/compressed/Makefile | 4 + arch/arm/boot/compressed/head-vt8500.S | 46 +++ arch/arm/mach-vt8500/Kconfig | 73 ++++ arch/arm/mach-vt8500/Makefile | 6 + arch/arm/mach-vt8500/Makefile.boot | 3 + arch/arm/mach-vt8500/bv07.c | 82 ++++ arch/arm/mach-vt8500/devices.c | 460 +++++++++++++++++++++++ arch/arm/mach-vt8500/devices.h | 46 +++ arch/arm/mach-vt8500/gpio.c | 230 +++++++++++ arch/arm/mach-vt8500/include/mach/debug-macro.S | 31 ++ arch/arm/mach-vt8500/include/mach/entry-macro.S | 32 ++ arch/arm/mach-vt8500/include/mach/gpio.h | 6 + arch/arm/mach-vt8500/include/mach/hardware.h | 12 + arch/arm/mach-vt8500/include/mach/io.h | 28 ++ arch/arm/mach-vt8500/include/mach/irq_defs.h | 124 ++++++ arch/arm/mach-vt8500/include/mach/irqs.h | 22 ++ arch/arm/mach-vt8500/include/mach/memory.h | 28 ++ arch/arm/mach-vt8500/include/mach/mmio_regs.h | 90 +++++ arch/arm/mach-vt8500/include/mach/system.h | 18 + arch/arm/mach-vt8500/include/mach/timex.h | 26 ++ arch/arm/mach-vt8500/include/mach/uncompress.h | 37 ++ arch/arm/mach-vt8500/include/mach/vmalloc.h | 20 + arch/arm/mach-vt8500/include/mach/vt8500fb.h | 31 ++ arch/arm/mach-vt8500/irq.c | 179 +++++++++ arch/arm/mach-vt8500/irq_defs.c | 173 +++++++++ arch/arm/mach-vt8500/mmio_regs.c | 118 ++++++ arch/arm/mach-vt8500/pwm.c | 254 +++++++++++++ arch/arm/mach-vt8500/timer.c | 154 ++++++++ arch/arm/mach-vt8500/wm8505_7in.c | 81 ++++ 31 files changed, 2428 insertions(+), 0 deletions(-) create mode 100644 arch/arm/boot/compressed/head-vt8500.S create mode 100644 arch/arm/mach-vt8500/Kconfig create mode 100644 arch/arm/mach-vt8500/Makefile create mode 100644 arch/arm/mach-vt8500/Makefile.boot create mode 100644 arch/arm/mach-vt8500/bv07.c create mode 100644 arch/arm/mach-vt8500/devices.c create mode 100644 arch/arm/mach-vt8500/devices.h create mode 100644 arch/arm/mach-vt8500/gpio.c create mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/entry-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/gpio.h create mode 100644 arch/arm/mach-vt8500/include/mach/hardware.h create mode 100644 arch/arm/mach-vt8500/include/mach/io.h create mode 100644 arch/arm/mach-vt8500/include/mach/irq_defs.h create mode 100644 arch/arm/mach-vt8500/include/mach/irqs.h create mode 100644 arch/arm/mach-vt8500/include/mach/memory.h create mode 100644 arch/arm/mach-vt8500/include/mach/mmio_regs.h create mode 100644 arch/arm/mach-vt8500/include/mach/system.h create mode 100644 arch/arm/mach-vt8500/include/mach/timex.h create mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h create mode 100644 arch/arm/mach-vt8500/include/mach/vmalloc.h create mode 100644 arch/arm/mach-vt8500/include/mach/vt8500fb.h create mode 100644 arch/arm/mach-vt8500/irq.c create mode 100644 arch/arm/mach-vt8500/irq_defs.c create mode 100644 arch/arm/mach-vt8500/mmio_regs.c create mode 100644 arch/arm/mach-vt8500/pwm.c create mode 100644 arch/arm/mach-vt8500/timer.c create mode 100644 arch/arm/mach-vt8500/wm8505_7in.c
arch/arm/Kconfig +13 -0
@@ -863,6 +863,17 @@ config PLAT_SPEAR help Support for ST's SPEAr platform (SPEAr3xx, SPEAr6xx and SPEAr13xx). +config ARCH_VT8500 + bool "VIA/WonderMedia 85xx" + select CPU_ARM926T + select GENERIC_GPIO + select ARCH_HAS_CPUFREQ + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select HAVE_PWM + help + Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. endchoice #
@@ -993,6 +1004,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vexpress/Kconfig" +source "arch/arm/mach-vt8500/Kconfig" + source "arch/arm/mach-w90x900/Kconfig" # Definitions to make life easier
arch/arm/Makefile +1 -0
@@ -189,6 +189,7 @@ machine-$(CONFIG_ARCH_U300) := u300 machine-$(CONFIG_ARCH_U8500) := ux500 machine-$(CONFIG_ARCH_VERSATILE) := versatile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress +machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x machine-$(CONFIG_FOOTBRIDGE) := footbridge
arch/arm/boot/compressed/Makefile +4 -0
@@ -29,6 +29,10 @@ ifeq ($(CONFIG_ARCH_SA1100),y) OBJS += head-sa1100.o endif +ifeq ($(CONFIG_ARCH_VT8500),y) +OBJS += head-vt8500.o +endif + ifeq ($(CONFIG_CPU_XSCALE),y) OBJS += head-xscale.o endif
arch/arm/boot/compressed/head-vt8500.S new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/Kconfig new file +73 -0
73 lines not on this page · raw message
arch/arm/mach-vt8500/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +obj-y += devices.o gpio.o irq.o irq_defs.o mmio_regs.o timer.o + +obj-$(CONFIG_MACH_BV07) += bv07.o +obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o + +obj-$(CONFIG_HAVE_PWM) += pwm.o
arch/arm/mach-vt8500/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x01000000
arch/arm/mach-vt8500/bv07.c new file +82 -0
82 lines not on this page · raw message
arch/arm/mach-vt8500/devices.c new file +460 -0
460 lines not on this page · raw message
arch/arm/mach-vt8500/devices.h new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/gpio.c new file +230 -0
230 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/debug-macro.S new file +31 -0
@@ -0,0 +1,31 @@ +/* + * arch/arm/mach-vt8500/include/mach/debug-macro.S + * + * Copyright (C) 2010 Alexey Charkov <[email protected]> + * + * 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 + mov \rp, #0x00200000 + orr \rv, \rp, #0xf8000000 + orr \rp, \rp, #0xd8000000 + .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
arch/arm/mach-vt8500/include/mach/entry-macro.S new file +32 -0
@@ -0,0 +1,32 @@ +/* + * arch/arm/mach-vt8500/include/mach/entry-macro.S + * + * Low-level IRQ helper macros for VIA VT8500 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_preamble, base, tmp + @ physical 0xd8140000 is virtual 0xf8140000 + mov \base, #0xf8000000 + orr \base, \base, #0x00140000 + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #63 @ may be false positive, check interrupt status + bne 1001f + ldr \irqstat, [\base, #0x84] + ands \irqstat, #0x80000000 + moveq \irqnr, #0 +1001: + .endm +
arch/arm/mach-vt8500/include/mach/gpio.h new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm-generic/gpio.h> + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq __gpio_to_irq
arch/arm/mach-vt8500/include/mach/hardware.h new file +12 -0
@@ -0,0 +1,12 @@ +/* arch/arm/mach-vt8500/include/mach/hardware.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. +* +*/
arch/arm/mach-vt8500/include/mach/io.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/io.h +* +* 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 +*/ +#ifndef __ASM_ARM_ARCH_IO_H +#define __ASM_ARM_ARCH_IO_H + +#define IO_SPACE_LIMIT 0xffff + +#define __io (a) ((void __iomem *)((a) + 0xf0000000)) +#define __mem_pci (a) (a) + +#endif
arch/arm/mach-vt8500/include/mach/irq_defs.h new file +124 -0
124 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/irqs.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* arch/arm/mach-vt8500/include/mach/irqs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 value is just to make the core happy, never used otherwise */ +#define NR_IRQS 128
arch/arm/mach-vt8500/include/mach/memory.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/memory.h +* +* Copyright (C) 2003 ARM Limited +* +* 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 __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET UL(0x00000000) + +#endif
arch/arm/mach-vt8500/include/mach/mmio_regs.h new file +90 -0
90 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/system.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* arch/arm/mach-vt8500/include/mach/system.h +* +*/ +#include <asm/io.h> + +/* PM Software Reset request register */ +#define VT8500_PMSR_VIRT 0xf8130060 + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +writel (1 ,VT8500_PMSR_VIRT ); +}
arch/arm/mach-vt8500/include/mach/timex.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* arch/arm/mach-vt8500/include/mach/timex.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 (3000000) + +#endif /* MACH_TIMEX_H */
arch/arm/mach-vt8500/include/mach/uncompress.h new file +37 -0
@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 0xd8200000 +#include <asm/io.h> + +static void putc (const char c) +{ +while (readb (UART0_PHYS +0x1c ) &0x2 ) +/* Tx busy, wait and poll */ ; + +writeb (c,UART0_PHYS ); +} + +static void flush (void ) +{ +} + +/* +* nothing to do +*/ +#define arch_decomp_setup () +#define arch_decomp_wdog ()
arch/arm/mach-vt8500/include/mach/vmalloc.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/vmalloc.h +* +* Copyright (C) 2000 Russell King. +* +* 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 +*/ +#define VMALLOC_END 0xd0000000UL
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* VT8500/WM8505 Frame Buffer platform data definitions +* +* Copyright (C) 2010 Ed Spiridonov <[email protected]> +* +* 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 */
arch/arm/mach-vt8500/irq.c new file +179 -0
179 lines not on this page · raw message
arch/arm/mach-vt8500/irq_defs.c new file +173 -0
173 lines not on this page · raw message
arch/arm/mach-vt8500/mmio_regs.c new file +118 -0
118 lines not on this page · raw message
arch/arm/mach-vt8500/pwm.c new file +254 -0
254 lines not on this page · raw message
arch/arm/mach-vt8500/timer.c new file +154 -0
154 lines not on this page · raw message
arch/arm/mach-vt8500/wm8505_7in.c new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
1.7.3.3
Quoted 9 lines · On Sunday 19 December 2010 18:40:17 Alexey Charkov wrote:
This adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505. Suitable code is selected (if compiled in) at early initialization time by reading a platform-specific identification register, as current bootloaders do not provide any reliable machine id to the kernel.
Quoted 7 lines
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
Signed-off-by Alexey Charkov <[email protected]>
Looks good to me, thanks for addressing all my previous concerns.
arch/arm/Kconfig config PLAT_SPEAR · line 871
Quoted 6 lines · Alexey Charkov
arch/arm/Kconfig +6
-0+config ARCH_VT8500 + bool "VIA/WonderMedia 85xx" + select CPU_ARM926T + select GENERIC_GPIO + select ARCH_HAS_CPUFREQ + select GENERIC_TIME
Everything looks good, except for the above. You don't need to select GENERIC_TIME - it doesn't exist anymore.
It's also good to see that you've picked up on registering clocksources with the _hz/_khz functions.
Alexey Charkov
maintainer2010/12/20 Russell King - ARM Linux <[email protected]>:
Quoted 10 lines · Alexey Charkov
Quoted 6 lines
+config
ARCH_VT8500
+ ? ? bool "VIA/WonderMedia 85xx"
+ ? ? selectCPU_ARM926T
+ ? ? selectGENERIC_GPIO
+ ? ? selectARCH_HAS_CPUFREQ
+ ? ? selectGENERIC_TIMEEverything looks good, except for the above. ?You don't need to select
GENERIC_TIME- it doesn't exist anymore.
Ok, that was an old copy-paste. Will resubmit a revised version in a moment.
Quoted 2 lines
It's also good to see that you've picked up on registering clocksources with the _hz/_khz functions.
Yes, these are quite handy. I will also check if my previously spotted performance issues with sched_clock are relieved with the latest clocksource-related instrumentary in 'devel': maybe it wasn't all due to evil busy-waiting on counter-to-bus synchronization. However, that would probably be worth a separate small patch.
Thanks,
Alexey
Alexey Charkov
maintainerPATCH v9 1/6 ARM: Add basic architecture support for VIA/WonderMedia 85xx SoC's
In reply to Russell King - ARM LinuxThis adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505, selectable by a configuration switch at kernel build time.
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
---
Dropped GENERIC_TIME selection from Kconfig. No further changes compared to v8.
This is against current Linus' 'master' branch.
Best regards,
Alexey
arch/arm/Kconfig | 12 + arch/arm/Makefile | 1 + arch/arm/boot/compressed/Makefile | 4 + arch/arm/boot/compressed/head-vt8500.S | 46 +++ arch/arm/mach-vt8500/Kconfig | 73 ++++ arch/arm/mach-vt8500/Makefile | 6 + arch/arm/mach-vt8500/Makefile.boot | 3 + arch/arm/mach-vt8500/bv07.c | 82 ++++ arch/arm/mach-vt8500/devices.c | 460 +++++++++++++++++++++++ arch/arm/mach-vt8500/devices.h | 46 +++ arch/arm/mach-vt8500/gpio.c | 230 +++++++++++ arch/arm/mach-vt8500/include/mach/debug-macro.S | 31 ++ arch/arm/mach-vt8500/include/mach/entry-macro.S | 32 ++ arch/arm/mach-vt8500/include/mach/gpio.h | 6 + arch/arm/mach-vt8500/include/mach/hardware.h | 12 + arch/arm/mach-vt8500/include/mach/io.h | 28 ++ arch/arm/mach-vt8500/include/mach/irq_defs.h | 124 ++++++ arch/arm/mach-vt8500/include/mach/irqs.h | 22 ++ arch/arm/mach-vt8500/include/mach/memory.h | 28 ++ arch/arm/mach-vt8500/include/mach/mmio_regs.h | 90 +++++ arch/arm/mach-vt8500/include/mach/system.h | 18 + arch/arm/mach-vt8500/include/mach/timex.h | 26 ++ arch/arm/mach-vt8500/include/mach/uncompress.h | 37 ++ arch/arm/mach-vt8500/include/mach/vmalloc.h | 20 + arch/arm/mach-vt8500/include/mach/vt8500fb.h | 31 ++ arch/arm/mach-vt8500/irq.c | 179 +++++++++ arch/arm/mach-vt8500/irq_defs.c | 173 +++++++++ arch/arm/mach-vt8500/mmio_regs.c | 118 ++++++ arch/arm/mach-vt8500/pwm.c | 254 +++++++++++++ arch/arm/mach-vt8500/timer.c | 154 ++++++++ arch/arm/mach-vt8500/wm8505_7in.c | 81 ++++ 31 files changed, 2427 insertions(+), 0 deletions(-) create mode 100644 arch/arm/boot/compressed/head-vt8500.S create mode 100644 arch/arm/mach-vt8500/Kconfig create mode 100644 arch/arm/mach-vt8500/Makefile create mode 100644 arch/arm/mach-vt8500/Makefile.boot create mode 100644 arch/arm/mach-vt8500/bv07.c create mode 100644 arch/arm/mach-vt8500/devices.c create mode 100644 arch/arm/mach-vt8500/devices.h create mode 100644 arch/arm/mach-vt8500/gpio.c create mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/entry-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/gpio.h create mode 100644 arch/arm/mach-vt8500/include/mach/hardware.h create mode 100644 arch/arm/mach-vt8500/include/mach/io.h create mode 100644 arch/arm/mach-vt8500/include/mach/irq_defs.h create mode 100644 arch/arm/mach-vt8500/include/mach/irqs.h create mode 100644 arch/arm/mach-vt8500/include/mach/memory.h create mode 100644 arch/arm/mach-vt8500/include/mach/mmio_regs.h create mode 100644 arch/arm/mach-vt8500/include/mach/system.h create mode 100644 arch/arm/mach-vt8500/include/mach/timex.h create mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h create mode 100644 arch/arm/mach-vt8500/include/mach/vmalloc.h create mode 100644 arch/arm/mach-vt8500/include/mach/vt8500fb.h create mode 100644 arch/arm/mach-vt8500/irq.c create mode 100644 arch/arm/mach-vt8500/irq_defs.c create mode 100644 arch/arm/mach-vt8500/mmio_regs.c create mode 100644 arch/arm/mach-vt8500/pwm.c create mode 100644 arch/arm/mach-vt8500/timer.c create mode 100644 arch/arm/mach-vt8500/wm8505_7in.c
arch/arm/Kconfig +12 -0
@@ -843,6 +843,16 @@ config PLAT_SPEAR help Support for ST's SPEAr platform (SPEAr3xx, SPEAr6xx and SPEAr13xx). +config ARCH_VT8500 + bool "VIA/WonderMedia 85xx" + select CPU_ARM926T + select GENERIC_GPIO + select ARCH_HAS_CPUFREQ + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select HAVE_PWM + help + Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. endchoice #
@@ -973,6 +983,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vexpress/Kconfig" +source "arch/arm/mach-vt8500/Kconfig" + source "arch/arm/mach-w90x900/Kconfig" # Definitions to make life easier
arch/arm/Makefile +1 -0
@@ -189,6 +189,7 @@ machine-$(CONFIG_ARCH_U300) := u300 machine-$(CONFIG_ARCH_U8500) := ux500 machine-$(CONFIG_ARCH_VERSATILE) := versatile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress +machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x machine-$(CONFIG_FOOTBRIDGE) := footbridge
arch/arm/boot/compressed/Makefile +4 -0
@@ -29,6 +29,10 @@ ifeq ($(CONFIG_ARCH_SA1100),y) OBJS += head-sa1100.o endif +ifeq ($(CONFIG_ARCH_VT8500),y) +OBJS += head-vt8500.o +endif + ifeq ($(CONFIG_CPU_XSCALE),y) OBJS += head-xscale.o endif
arch/arm/boot/compressed/head-vt8500.S new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/Kconfig new file +73 -0
73 lines not on this page · raw message
arch/arm/mach-vt8500/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +obj-y += devices.o gpio.o irq.o irq_defs.o mmio_regs.o timer.o + +obj-$(CONFIG_MACH_BV07) += bv07.o +obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o + +obj-$(CONFIG_HAVE_PWM) += pwm.o
arch/arm/mach-vt8500/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x01000000
arch/arm/mach-vt8500/bv07.c new file +82 -0
82 lines not on this page · raw message
arch/arm/mach-vt8500/devices.c new file +460 -0
460 lines not on this page · raw message
arch/arm/mach-vt8500/devices.h new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-vt8500/gpio.c new file +230 -0
230 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/debug-macro.S new file +31 -0
@@ -0,0 +1,31 @@ +/* + * arch/arm/mach-vt8500/include/mach/debug-macro.S + * + * Copyright (C) 2010 Alexey Charkov <[email protected]> + * + * 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 + mov \rp, #0x00200000 + orr \rv, \rp, #0xf8000000 + orr \rp, \rp, #0xd8000000 + .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
arch/arm/mach-vt8500/include/mach/entry-macro.S new file +32 -0
@@ -0,0 +1,32 @@ +/* + * arch/arm/mach-vt8500/include/mach/entry-macro.S + * + * Low-level IRQ helper macros for VIA VT8500 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_preamble, base, tmp + @ physical 0xd8140000 is virtual 0xf8140000 + mov \base, #0xf8000000 + orr \base, \base, #0x00140000 + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #63 @ may be false positive, check interrupt status + bne 1001f + ldr \irqstat, [\base, #0x84] + ands \irqstat, #0x80000000 + moveq \irqnr, #0 +1001: + .endm +
arch/arm/mach-vt8500/include/mach/gpio.h new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm-generic/gpio.h> + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq __gpio_to_irq
arch/arm/mach-vt8500/include/mach/hardware.h new file +12 -0
@@ -0,0 +1,12 @@ +/* arch/arm/mach-vt8500/include/mach/hardware.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. +* +*/
arch/arm/mach-vt8500/include/mach/io.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/io.h +* +* 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 +*/ +#ifndef __ASM_ARM_ARCH_IO_H +#define __ASM_ARM_ARCH_IO_H + +#define IO_SPACE_LIMIT 0xffff + +#define __io (a) ((void __iomem *)((a) + 0xf0000000)) +#define __mem_pci (a) (a) + +#endif
arch/arm/mach-vt8500/include/mach/irq_defs.h new file +124 -0
124 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/irqs.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* arch/arm/mach-vt8500/include/mach/irqs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 value is just to make the core happy, never used otherwise */ +#define NR_IRQS 128
arch/arm/mach-vt8500/include/mach/memory.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/memory.h +* +* Copyright (C) 2003 ARM Limited +* +* 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 __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET UL(0x00000000) + +#endif
arch/arm/mach-vt8500/include/mach/mmio_regs.h new file +90 -0
90 lines not on this page · raw message
arch/arm/mach-vt8500/include/mach/system.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* arch/arm/mach-vt8500/include/mach/system.h +* +*/ +#include <asm/io.h> + +/* PM Software Reset request register */ +#define VT8500_PMSR_VIRT 0xf8130060 + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +writel (1 ,VT8500_PMSR_VIRT ); +}
arch/arm/mach-vt8500/include/mach/timex.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* arch/arm/mach-vt8500/include/mach/timex.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 (3000000) + +#endif /* MACH_TIMEX_H */
arch/arm/mach-vt8500/include/mach/uncompress.h new file +37 -0
@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 0xd8200000 +#include <asm/io.h> + +static void putc (const char c) +{ +while (readb (UART0_PHYS +0x1c ) &0x2 ) +/* Tx busy, wait and poll */ ; + +writeb (c,UART0_PHYS ); +} + +static void flush (void ) +{ +} + +/* +* nothing to do +*/ +#define arch_decomp_setup () +#define arch_decomp_wdog ()
arch/arm/mach-vt8500/include/mach/vmalloc.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/vmalloc.h +* +* Copyright (C) 2000 Russell King. +* +* 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 +*/ +#define VMALLOC_END 0xd0000000UL
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* VT8500/WM8505 Frame Buffer platform data definitions +* +* Copyright (C) 2010 Ed Spiridonov <[email protected]> +* +* 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 */
arch/arm/mach-vt8500/irq.c new file +179 -0
179 lines not on this page · raw message
arch/arm/mach-vt8500/irq_defs.c new file +173 -0
173 lines not on this page · raw message
arch/arm/mach-vt8500/mmio_regs.c new file +118 -0
118 lines not on this page · raw message
arch/arm/mach-vt8500/pwm.c new file +254 -0
254 lines not on this page · raw message
arch/arm/mach-vt8500/timer.c new file +154 -0
154 lines not on this page · raw message
arch/arm/mach-vt8500/wm8505_7in.c new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
1.7.3.4
Quoted 7 lines · Alexey Charkov
This adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505, selectable by a configuration switch at kernel build time.
Quoted 7 lines
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
Signed-off-by Alexey Charkov <[email protected]>
Hi Alexey,
Quick review below.
~Ryan
Quoted 516 lines
---
Dropped
GENERIC_TIMEselection fromKconfig. No further changes compared to v8.This is against current Linus' 'master' branch.
Best regards,
Alexeyarch/arm/Kconfig | 12 + arch/arm/Makefile | 1 + arch/arm/boot/compressed/Makefile | 4 + arch/arm/boot/compressed/head-vt8500.S | 46 +++ arch/arm/mach-vt8500/Kconfig | 73 ++++ arch/arm/mach-vt8500/Makefile | 6 + arch/arm/mach-vt8500/Makefile.boot | 3 + arch/arm/mach-vt8500/bv07.c | 82 ++++ arch/arm/mach-vt8500/devices.c | 460 +++++++++++++++++++++++ arch/arm/mach-vt8500/devices.h | 46 +++ arch/arm/mach-vt8500/gpio.c | 230 +++++++++++ arch/arm/mach-vt8500/include/mach/debug-macro.S | 31 ++ arch/arm/mach-vt8500/include/mach/entry-macro.S | 32 ++ arch/arm/mach-vt8500/include/mach/gpio.h | 6 + arch/arm/mach-vt8500/include/mach/hardware.h | 12 + arch/arm/mach-vt8500/include/mach/io.h | 28 ++ arch/arm/mach-vt8500/include/mach/irq_defs.h | 124 ++++++ arch/arm/mach-vt8500/include/mach/irqs.h | 22 ++ arch/arm/mach-vt8500/include/mach/memory.h | 28 ++ arch/arm/mach-vt8500/include/mach/mmio_regs.h | 90 +++++ arch/arm/mach-vt8500/include/mach/system.h | 18 + arch/arm/mach-vt8500/include/mach/timex.h | 26 ++ arch/arm/mach-vt8500/include/mach/uncompress.h | 37 ++ arch/arm/mach-vt8500/include/mach/vmalloc.h | 20 + arch/arm/mach-vt8500/include/mach/vt8500fb.h | 31 ++ arch/arm/mach-vt8500/irq.c | 179 +++++++++ arch/arm/mach-vt8500/irq_defs.c | 173 +++++++++ arch/arm/mach-vt8500/mmio_regs.c | 118 ++++++ arch/arm/mach-vt8500/pwm.c | 254 +++++++++++++ arch/arm/mach-vt8500/timer.c | 154 ++++++++ arch/arm/mach-vt8500/wm8505_7in.c | 81 ++++ 31 files changed, 2427 insertions(+), 0 deletions(-) create mode 100644 arch/arm/boot/compressed/head-vt8500.S create mode 100644 arch/arm/mach-vt8500/Kconfig create mode 100644 arch/arm/mach-vt8500/Makefile create mode 100644 arch/arm/mach-vt8500/Makefile.boot create mode 100644 arch/arm/mach-vt8500/bv07.c create mode 100644 arch/arm/mach-vt8500/devices.c create mode 100644 arch/arm/mach-vt8500/devices.h create mode 100644 arch/arm/mach-vt8500/gpio.c create mode 100644 arch/arm/mach-vt8500/include/mach/debug-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/entry-macro.S create mode 100644 arch/arm/mach-vt8500/include/mach/gpio.h create mode 100644 arch/arm/mach-vt8500/include/mach/hardware.h create mode 100644 arch/arm/mach-vt8500/include/mach/io.h create mode 100644 arch/arm/mach-vt8500/include/mach/irq_defs.h create mode 100644 arch/arm/mach-vt8500/include/mach/irqs.h create mode 100644 arch/arm/mach-vt8500/include/mach/memory.h create mode 100644 arch/arm/mach-vt8500/include/mach/mmio_regs.h create mode 100644 arch/arm/mach-vt8500/include/mach/system.h create mode 100644 arch/arm/mach-vt8500/include/mach/timex.h create mode 100644 arch/arm/mach-vt8500/include/mach/uncompress.h create mode 100644 arch/arm/mach-vt8500/include/mach/vmalloc.h create mode 100644 arch/arm/mach-vt8500/include/mach/vt8500fb.h create mode 100644 arch/arm/mach-vt8500/irq.c create mode 100644 arch/arm/mach-vt8500/irq_defs.c create mode 100644 arch/arm/mach-vt8500/mmio_regs.c create mode 100644 arch/arm/mach-vt8500/pwm.c create mode 100644 arch/arm/mach-vt8500/timer.c create mode 100644 arch/arm/mach-vt8500/wm8505_7in.carch/arm/Kconfig +12
-0@@ -843,6 +843,16 @@ config PLAT_SPEAR help Support for ST's SPEAr platform (SPEAr3xx, SPEAr6xx and SPEAr13xx). +config ARCH_VT8500 + bool "VIA/WonderMedia 85xx" + select CPU_ARM926T + select GENERIC_GPIO + select ARCH_HAS_CPUFREQ + select GENERIC_CLOCKEVENTS + select ARCH_REQUIRE_GPIOLIB + select HAVE_PWM + help + Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. endchoice #@@ -973,6 +983,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vexpress/Kconfig" +source "arch/arm/mach-vt8500/Kconfig" + source "arch/arm/mach-w90x900/Kconfig" # Definitions to make life easierarch/arm/Makefile +1
-0@@ -189,6 +189,7 @@ machine-$(CONFIG_ARCH_U300) := u300 machine-$(CONFIG_ARCH_U8500) := ux500 machine-$(CONFIG_ARCH_VERSATILE) := versatile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress +machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x machine-$(CONFIG_FOOTBRIDGE) := footbridgearch/arm/boot/compressed/Makefile +4
-0@@ -29,6 +29,10 @@ ifeq ($(CONFIG_ARCH_SA1100),y) OBJS += head-sa1100.o endif +ifeq ($(CONFIG_ARCH_VT8500),y) +OBJS += head-vt8500.o +endif + ifeq ($(CONFIG_CPU_XSCALE),y) OBJS += head-xscale.o endifarch/arm/boot/compressed/head-vt8500.S new file +46
-0@@ -0,0 +1,46 @@ +/* + * linux/arch/arm/boot/compressed/head-vt8500.S + * + * Copyright (C) 2010 Alexey Charkov <[email protected]> + * + * VIA VT8500 specific tweaks. This is merged into head.S by the linker. + * + */ + +#include <linux/linkage.h> +#include <asm/mach-types.h> + + .section ".start", "ax" + +__VT8500_start: + @ Compare the SCC ID register against a list of known values + ldr r1, .SCCID + ldr r3, [r1] + + @ VT8500 override + ldr r4, .VT8500SCC + cmp r3, r4 + ldreq r7, .ID_BV07 + beq .Lendvt8500 + + @ WM8505 override + ldr r4, .WM8505SCC + cmp r3, r4 + ldreq r7, .ID_8505 + beq .Lendvt8500 + + @ Otherwise, leave the bootloader's machine id untouched + +.SCCID: + .word 0xd8120000 +.VT8500SCC: + .word 0x34000102 +.WM8505SCC: + .word 0x34260103 + +.ID_BV07: + .word MACH_TYPE_BV07 +.ID_8505: + .word MACH_TYPE_WM8505_7IN_NETBOOK + +.Lendvt8500:arch/arm/mach-vt8500/Kconfig new file +73
-0@@ -0,0 +1,73 @@ +if ARCH_VT8500 + +config VTWM_VERSION_VT8500 + bool + +config VTWM_VERSION_WM8505 + bool + +config MACH_BV07 + bool "Benign BV07-8500 Mini Netbook" + depends on ARCH_VT8500 + select VTWM_VERSION_VT8500 + help + Add support for the inexpensive 7-inch netbooks sold by many + Chinese distributors under various names. Note that there are + many hardware implementations in identical exterior, make sure + that yours is indeed based on a VIA VT8500 chip. + +config MACH_WM8505_7IN_NETBOOK + bool "WM8505 7-inch generic netbook" + depends on ARCH_VT8500 + select VTWM_VERSION_WM8505 + help + Add support for the inexpensive 7-inch netbooks sold by many + Chinese distributors under various names. Note that there are + many hardware implementations in identical exterior, make sure + that yours is indeed based on a WonderMedia WM8505 chip. + +comment "LCD panel size" + +config WMT_PANEL_800X480 + bool "7-inch with 800x480 resolution" + depends on (FB_VT8500 || FB_WM8505) + default y + help + These are found in most of the netbooks in generic cases, as + well as in Eken M001 tablets and possibly elsewhere. + + To select this panel at runtime, say y here and append + 'panel=800x480' to your kernel command line. Otherwise, the + largest one available will be used. + +config WMT_PANEL_800X600 + bool "8-inch with 800x600 resolution" + depends on (FB_VT8500 || FB_WM8505) + help + These are found in Eken M003 tablets and possibly elsewhere. + + To select this panel at runtime, say y here and append + 'panel=800x600' to your kernel command line. Otherwise, the + largest one available will be used. + +config WMT_PANEL_1024X576 + bool "10-inch with 1024x576 resolution" + depends on (FB_VT8500 || FB_WM8505) + help + These are found in CherryPal netbooks and possibly elsewhere. + + To select this panel at runtime, say y here and append + 'panel=1024x576' to your kernel command line. Otherwise, the + largest one available will be used. + +config WMT_PANEL_1024X600 + bool "10-inch with 1024x600 resolution" + depends on (FB_VT8500 || FB_WM8505) + help + These are found in Eken M006 tablets and possibly elsewhere. + + To select this panel at runtime, say y here and append + 'panel=1024x600' to your kernel command line. Otherwise, the + largest one available will be used. + +endifarch/arm/mach-vt8500/Makefile new file +6
-0@@ -0,0 +1,6 @@ +obj-y += devices.o gpio.o irq.o irq_defs.o mmio_regs.o timer.o + +obj-$(CONFIG_MACH_BV07) += bv07.o +obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o + +obj-$(CONFIG_HAVE_PWM) += pwm.oarch/arm/mach-vt8500/Makefile.boot new file +3
-0@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x01000000arch/arm/mach-vt8500/bv07.c new file +82
-0@@ -0,0 +1,82 @@ +/* +* arch/arm/mach-vt8500/bv07.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 +*/ + +#include <linux/io.h> +#include <linux/pm.h> + +#include <asm/mach-types.h> +#include <asm/mach/arch.h> + +#include <mach/mmio_regs.h> +#include <mach/irq_defs.h> +#include "devices.h" + +static void __iomem *pmc_hiber; + +static struct platform_device *devices[]__initdata = { + &vt8500_device_uart0, + &vt8500_device_lcdc, + &vt8500_device_ehci, + &vt8500_device_ge_rops, + &vt8500_device_pwm, + &vt8500_device_pwmbl, + &vt8500_device_rtc, +}; + +static void vt8500_power_off (void ) +{ +local_irq_disable (); +writew (5 , pmc_hiber); + asm("mcr%? p15, 0, %0, c7, c0, 4" : :"r" (0 )); +} + +void __init bv07_init (void ) +{ +#ifdef CONFIG_FB_VT8500 +void __iomem *gpio_mux_reg =ioremap (wmt_current_regs->gpio + +0x200 ,4 ); +if (gpio_mux_reg) { +writel (readl (gpio_mux_reg) |1 , gpio_mux_reg); +iounmap (gpio_mux_reg); + }else { +printk (KERN_ERR "Could not remap the GPIO mux register, " +"display may not work properly!\n" ); + } +#endif + pmc_hiber =ioremap (wmt_current_regs->pmc +0x12 ,2 ); +if (pmc_hiber) + pm_power_off = &vt8500_power_off; +else +printk (KERN_ERR "PMC Hibernation register could not be " +"remapped, not enabling power off!\n" ); + +wmt_set_resources (); +platform_add_devices (devices,ARRAY_SIZE (devices)); +vt8500_gpio_init (); +} + +MACHINE_START (BV07 ,"Benign BV07 Mini Netbook" ) + .boot_params = 0x00000100, + .reserve = vt8500_reserve_mem, + .map_io = vt8500_map_io, + .init_irq = vt8500_init_irq, + .timer = &vt8500_timer, + .init_machine = bv07_init, +MACHINE_END arch/arm/mach-vt8500/devices.c new file +142
-0@@ -0,0 +1,460 @@ +/* linux/arch/arm/mach-vt8500/devices.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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/kernel.h> +#include <linux/io.h> +#include <linux/device.h> +#include <linux/dma-mapping.h> +#include <linux/platform_device.h> +#include <linux/pwm_backlight.h> +#include <linux/memblock.h> + +#include <asm/mach/arch.h> +#include <asm/mach/map.h> + +#include <mach/mmio_regs.h> +#include <mach/irq_defs.h> +#include <mach/vt8500fb.h> +#include "devices.h" + +static struct resource resources_lcdc[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .flags =IORESOURCE_IRQ , + }, +}; + +static u64 fb_dma_mask =DMA_BIT_MASK (32 ); + +struct platform_device vt8500_device_lcdc = { + .name ="vt8500-lcd" , + .id =0 , + .dev = { + .dma_mask = &fb_dma_mask, + .coherent_dma_mask =DMA_BIT_MASK (32 ), + }, + .num_resources =ARRAY_SIZE (resources_lcdc), + .resource = resources_lcdc, +}; + +static struct resource resources_wm8505_fb[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + } +}; + +struct platform_device vt8500_device_wm8505_fb = { + .name ="wm8505-fb" , + .id =0 , + .num_resources =ARRAY_SIZE (resources_wm8505_fb), + .resource = resources_wm8505_fb, +}; + +/* Smallest to largest */ +static struct vt8500fb_platform_data panels[] = { +#ifdef CONFIG_WMT_PANEL_800X480 +{ + .xres_virtual = 800, + .yres_virtual = 480 * 2, + .mode = { + .name = "800x480", + .xres = 800, + .yres = 480, + .left_margin = 88, + .right_margin = 40, + .upper_margin = 32, + .lower_margin = 11, + .hsync_len = 0, + .vsync_len = 1, + .vmode = FB_VMODE_NONINTERLACED, + }, +}, +#endif +#ifdef CONFIG_WMT_PANEL_800X600 +{ + .xres_virtual = 800, + .yres_virtual = 600 * 2, + .mode = { + .name = "800x600", + .xres = 800, + .yres = 600, + .left_margin = 88, + .right_margin = 40, + .upper_margin = 32, + .lower_margin = 11, + .hsync_len = 0, + .vsync_len = 1, + .vmode = FB_VMODE_NONINTERLACED, + }, +}, +#endif +#ifdef CONFIG_WMT_PANEL_1024X576 +{ + .xres_virtual = 1024, + .yres_virtual = 576 * 2, + .mode = { + .name = "1024x576", + .xres = 1024, + .yres = 576, + .left_margin = 40, + .right_margin = 24, + .upper_margin = 32, + .lower_margin = 11, + .hsync_len = 96, + .vsync_len = 2, + .vmode = FB_VMODE_NONINTERLACED, + }, +}, +#endif +#ifdef CONFIG_WMT_PANEL_1024X600 +{ + .xres_virtual = 1024, + .yres_virtual = 600 * 2, + .mode = { + .name = "1024x600", + .xres = 1024, + .yres = 600, + .left_margin = 66, + .right_margin = 2, + .upper_margin = 19, + .lower_margin = 1, + .hsync_len = 23, + .vsync_len = 8, + .vmode = FB_VMODE_NONINTERLACED, + }, +}, +#endif +}; +
arch/arm/mach-vt8500/devices.c line 152
Quoted 10 lines
arch/arm/mach-vt8500/devices.c new file +10
-0+static int current_panel_idx__initdata =ARRAY_SIZE (panels) -1 ; + +static int __init panel_setup (char *str) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (panels); i++) { +int len =strlen (panels[i].mode.name); + +if (memcmp (panels[i].mode.name, str, len) ==0 ) {
Should be strcmp. If the length of str is less than panels[i].mode.name then you will buffer overrun.
Quoted 17 lines
arch/arm/mach-vt8500/devices.c new file +17
-0+ current_panel_idx = i; +break ; + } + } +return 0 ; +} + +early_param ("panel" , panel_setup); + +static inline void preallocate_fb (struct vt8500fb_platform_data *p, +unsigned long align) { + p->video_mem_len = (p->xres_virtual * p->yres_virtual *4 ) >> + (p->bpp >16 ?0 : (p->bpp >8 ?1 : + (8 / p->bpp) +1 )); + p->video_mem_phys = (unsigned long )memblock_alloc (p->video_mem_len, + align); + p->video_mem_virt =phys_to_virt (p->video_mem_phys);
arch/arm/mach-vt8500/devices.c line 179
Quoted 10 lines
arch/arm/mach-vt8500/devices.c new file +10
-0+} + +static struct resource resources_uart0[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .flags =IORESOURCE_IRQ , + }, +};
What's happening here? Does something else fill these in? If so, there should be a comment to that effect.
Quoted 179 lines
arch/arm/mach-vt8500/devices.c new file +179
-0+static struct resource resources_uart1[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .flags =IORESOURCE_IRQ , + }, +}; + +static struct resource resources_uart2[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .flags =IORESOURCE_IRQ , + }, +}; + +static struct resource resources_uart3[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .flags =IORESOURCE_IRQ , + }, +}; + +static struct resource resources_uart4[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .flags =IORESOURCE_IRQ , + }, +}; + +static struct resource resources_uart5[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .flags =IORESOURCE_IRQ , + }, +}; + +struct platform_device vt8500_device_uart0 = { + .name ="vt8500_serial" , + .id =0 , + .num_resources =ARRAY_SIZE (resources_uart0), + .resource = resources_uart0, +}; + +struct platform_device vt8500_device_uart1 = { + .name ="vt8500_serial" , + .id =1 , + .num_resources =ARRAY_SIZE (resources_uart1), + .resource = resources_uart1, +}; + +struct platform_device vt8500_device_uart2 = { + .name ="vt8500_serial" , + .id =2 , + .num_resources =ARRAY_SIZE (resources_uart2), + .resource = resources_uart2, +}; + +struct platform_device vt8500_device_uart3 = { + .name ="vt8500_serial" , + .id =3 , + .num_resources =ARRAY_SIZE (resources_uart3), + .resource = resources_uart3, +}; + +struct platform_device vt8500_device_uart4 = { + .name ="vt8500_serial" , + .id =4 , + .num_resources =ARRAY_SIZE (resources_uart4), + .resource = resources_uart4, +}; + +struct platform_device vt8500_device_uart5 = { + .name ="vt8500_serial" , + .id =5 , + .num_resources =ARRAY_SIZE (resources_uart5), + .resource = resources_uart5, +}; + +static struct resource resources_ehci[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .flags =IORESOURCE_IRQ , + } +}; + +static u64 ehci_dma_mask =DMA_BIT_MASK (32 ); + +struct platform_device vt8500_device_ehci = { + .name ="vt8500-ehci" , + .id =0 , + .dev = { + .dma_mask = &ehci_dma_mask, + .coherent_dma_mask =DMA_BIT_MASK (32 ), + }, + .num_resources =ARRAY_SIZE (resources_ehci), + .resource = resources_ehci, +}; + +static struct resource resources_ge_rops[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + } +}; + +struct platform_device vt8500_device_ge_rops = { + .name ="wmt_ge_rops" , + .id =0 , + .num_resources =ARRAY_SIZE (resources_ge_rops), + .resource = resources_ge_rops, +}; + +static struct resource resources_pwm[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + }, +}; + +struct platform_device vt8500_device_pwm = { + .name ="vt8500-pwm" , + .id =0 , + .resource = resources_pwm, + .num_resources =ARRAY_SIZE (resources_pwm), +}; + +static struct platform_pwm_backlight_data vt8500_pwmbl_data = { + .pwm_id =0 , + .max_brightness =128 , + .dft_brightness =70 , + .pwm_period_ns =250000 ,/* revisit when clocks are implemented */ +}; + +struct platform_device vt8500_device_pwmbl = { + .name ="pwm-backlight" , + .id =0 , + .dev = { + .platform_data = &vt8500_pwmbl_data, + }, +}; + +static struct resource resources_rtc[] = { + [0 ] = { + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .flags =IORESOURCE_IRQ , + }, + [2 ] = { + .flags =IORESOURCE_IRQ , + }, +}; + +struct platform_device vt8500_device_rtc = { + .name ="vt8500-rtc" , + .id =0 , + .resource = resources_rtc, + .num_resources =ARRAY_SIZE (resources_rtc), +}; + +static struct map_desc vt8500_io_desc[]__initdata = { +/* SoC MMIO registers, to be filled in later */ + [0 ] = { + .type =MT_DEVICE + }, +/* PCI I/O space, numbers tied to those in <mach/io.h> */ + [1 ] = { + .virtual =0xf0000000 , + .pfn =__phys_to_pfn (0xc0000000 ), + .length =SZ_64K ,
arch/arm/mach-vt8500/devices.c line 369
Quoted 10 lines
arch/arm/mach-vt8500/devices.c new file +10
-0+ .type = MT_DEVICE + }, +}; + +void __init wmt_set_resources (void ) +{ + resources_lcdc[0 ].start = wmt_current_regs->lcdc; + resources_lcdc[0 ].end = wmt_current_regs->lcdc +SZ_1K -1 ; + resources_lcdc[1 ].start = wmt_current_irqs->lcdc; + resources_lcdc[1 ].end = wmt_current_irqs->lcdc;
Ah, this makes more sense. But why have all the indirection? The wmt_regmaps table could just be replaced with #defines and then have separate device files for the VT8500 and the WM8505. This would also make clearer which variants have which peripherals.
Quoted 22 lines
arch/arm/mach-vt8500/devices.c new file +22
-0+ resources_wm8505_fb[0 ].start = wmt_current_regs->govr; + resources_wm8505_fb[0 ].end = wmt_current_regs->govr +512 -1 ; + + resources_uart0[0 ].start = wmt_current_regs->uart0; + resources_uart0[0 ].end = wmt_current_regs->uart0 +0x103f ; + resources_uart0[1 ].start = wmt_current_irqs->uart0; + resources_uart0[1 ].end = wmt_current_irqs->uart0; + resources_uart1[0 ].start = wmt_current_regs->uart1; + resources_uart1[0 ].end = wmt_current_regs->uart1 +0x103f ; + resources_uart1[1 ].start = wmt_current_irqs->uart1; + resources_uart1[1 ].end = wmt_current_irqs->uart1; + resources_uart2[0 ].start = wmt_current_regs->uart2; + resources_uart2[0 ].end = wmt_current_regs->uart2 +0x103f ; + resources_uart2[1 ].start = wmt_current_irqs->uart2; + resources_uart2[1 ].end = wmt_current_irqs->uart2; + resources_uart3[0 ].start = wmt_current_regs->uart3; + resources_uart3[0 ].end = wmt_current_regs->uart3 +0x103f ; + resources_uart3[1 ].start = wmt_current_irqs->uart3; + resources_uart3[1 ].end = wmt_current_irqs->uart3; + resources_uart4[0 ].start = wmt_current_regs->uart4; + resources_uart4[0 ].end = wmt_current_regs->uart4 +0x103f ; + resources_uart4[1 ].start = wmt_current_irqs->uart4;
arch/arm/mach-vt8500/devices.c line 402
Quoted 10 lines
arch/arm/mach-vt8500/devices.c new file +10
-0+ resources_uart4[1 ].end = wmt_current_irqs->uart4; + resources_uart5[0 ].start = wmt_current_regs->uart5; + resources_uart5[0 ].end = wmt_current_regs->uart5 +0x103f ; + resources_uart5[1 ].start = wmt_current_irqs->uart5; + resources_uart5[1 ].end = wmt_current_irqs->uart5; + + resources_ehci[0 ].start = wmt_current_regs->ehci; + resources_ehci[0 ].end = wmt_current_regs->ehci +512 -1 ; + resources_ehci[1 ].start = wmt_current_irqs->ehci; + resources_ehci[1 ].end = wmt_current_irqs->ehci;
There is a mix of hex and decimal constants here and exact sizes and sizes with 1 subtracted. Please be consistent.
Quoted 29 lines
arch/arm/mach-vt8500/devices.c new file +29
-0+ resources_ge_rops[0 ].start = wmt_current_regs->ge; + resources_ge_rops[0 ].end = wmt_current_regs->ge +0xff ; + + resources_pwm[0 ].start = wmt_current_regs->pwm; + resources_pwm[0 ].end = wmt_current_regs->pwm +0x43 ; + + resources_rtc[0 ].start = wmt_current_regs->rtc; + resources_rtc[0 ].end = wmt_current_regs->rtc +0x2c -1 ; + resources_rtc[1 ].start = wmt_current_irqs->rtc; + resources_rtc[1 ].end = wmt_current_irqs->rtc; + resources_rtc[2 ].start = wmt_current_irqs->rtc_hz; + resources_rtc[2 ].end = wmt_current_irqs->rtc_hz; +} + +void __init vt8500_map_io (void ) +{ + wmt_current_regs = &wmt_regmaps[VT8500_INDEX ]; + wmt_current_irqs = &wmt_irqs[VT8500_INDEX ]; + + vt8500_io_desc[0 ].virtual = wmt_current_regs->mmio_regs_virt; + vt8500_io_desc[0 ].pfn = +__phys_to_pfn (wmt_current_regs->mmio_regs_start); + vt8500_io_desc[0 ].length = wmt_current_regs->mmio_regs_length; + +iotable_init (vt8500_io_desc,ARRAY_SIZE (vt8500_io_desc)); +} + +void __init wm8505_map_io (void ) +{
arch/arm/mach-vt8500/devices.c line 442
Quoted 10 lines
arch/arm/mach-vt8500/devices.c new file +10
-0+ wmt_current_regs = &wmt_regmaps[WM8505_INDEX ]; + wmt_current_irqs = &wmt_irqs[WM8505_INDEX ]; + + vt8500_io_desc[0 ].virtual = wmt_current_regs->mmio_regs_virt; + vt8500_io_desc[0 ].pfn = +__phys_to_pfn (wmt_current_regs->mmio_regs_start); + vt8500_io_desc[0 ].length = wmt_current_regs->mmio_regs_length; + +iotable_init (vt8500_io_desc,ARRAY_SIZE (vt8500_io_desc)); +}
Separate files. If more variants get added, this file will become unwieldy very quickly.
arch/arm/mach-vt8500/devices.c line 451
Quoted 9 lines
arch/arm/mach-vt8500/devices.c new file +9
-0+ +void __init vt8500_reserve_mem (void ) +{ +#ifdef CONFIG_FB_VT8500 + panels[current_panel_idx].bpp =16 ;/* Always use RGB565 */ +preallocate_fb (&panels[current_panel_idx],SZ_4M ); + vt8500_device_lcdc.dev.platform_data = &panels[current_panel_idx]; +#endif +}
Not sure if this should exist in the platform code or the framebuffer driver. In the latter case it would automatically be CONFIG_FB_VT8500 and the platform_data can still be set in the platform code. Is there a reason for this not to be in the framebuffer driver?
Quoted 50 lines
arch/arm/mach-vt8500/devices.c new file +9
-0+ +void __init wm8505_reserve_mem (void ) +{ +#if definedCONFIG_FB_WM8505 + panels[current_panel_idx].bpp =32 ;/* Always use RGB888 */ +preallocate_fb (&panels[current_panel_idx],32 ); + vt8500_device_wm8505_fb.dev.platform_data = &panels[current_panel_idx]; +#endif +}arch/arm/mach-vt8500/devices.h new file +35
-0@@ -0,0 +1,46 @@ +/* linux/arch/arm/mach-vt8500/devices.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 __ARCH_ARM_MACH_VT8500_DEVICES_H +#define __ARCH_ARM_MACH_VT8500_DEVICES_H + +#include <linux/platform_device.h> + +void __init vt8500_init_irq (void ); +void __init wm8505_init_irq (void ); +void __init vt8500_map_io (void ); +void __init wm8505_map_io (void ); +void __init vt8500_reserve_mem (void ); +void __init wm8505_reserve_mem (void ); +void __init wmt_set_resources (void ); +void __init vt8500_gpio_init (void ); + +extern struct sys_timer vt8500_timer; + +extern struct platform_device vt8500_device_uart0; +extern struct platform_device vt8500_device_uart1; +extern struct platform_device vt8500_device_uart2; +extern struct platform_device vt8500_device_uart3;
arch/arm/mach-vt8500/devices.h line 45
Quoted 10 lines
arch/arm/mach-vt8500/devices.h new file +10
-0+extern struct platform_device vt8500_device_uart4; +extern struct platform_device vt8500_device_uart5; + +extern struct platform_device vt8500_device_lcdc; +extern struct platform_device vt8500_device_wm8505_fb; +extern struct platform_device vt8500_device_ehci; +extern struct platform_device vt8500_device_ge_rops; +extern struct platform_device vt8500_device_pwm; +extern struct platform_device vt8500_device_pwmbl; +extern struct platform_device vt8500_device_rtc;
This could all disappear if you had separate files for the vt8500/wm8505 peripherals since the platform_devices could all be static.
Quoted 40 lines
arch/arm/mach-vt8500/devices.h new file +1
-0+#endif arch/arm/mach-vt8500/gpio.c new file +33
-0@@ -0,0 +1,230 @@ +/* linux/arch/arm/mach-vt8500/gpio.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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/gpio.h> +#include <linux/init.h> +#include <linux/irq.h> +#include <linux/io.h> + +#include <mach/mmio_regs.h> +#include <mach/irq_defs.h> + +#define to_vt8500 (__chip) container_of(__chip, struct vt8500_gpio_chip, chip) + +static void __iomem *regbase; + +struct vt8500_gpio_chip { +struct gpio_chip chip; +unsigned int shift; +unsigned int regoff; +}; +
arch/arm/mach-vt8500/gpio.c line 43
Quoted 10 lines
arch/arm/mach-vt8500/gpio.c new file +10
-0+static int gpio_to_irq_map[8 ]; + +static int vt8500_muxed_gpio_request (struct gpio_chip *chip, +unsigned offset) +{ +struct vt8500_gpio_chip *vt8500_chip =to_vt8500 (chip); + +writel (readl (regbase + vt8500_chip->regoff) | + (1 << vt8500_chip->shift << offset), + regbase + vt8500_chip->regoff);
This would be more readable as:
unsigned val; val = readl(regbase + vt8500_chop->regoff); val |= 1 << vt8500_chop->shift << offset; writel(val, regbase + vt8500_chip->regoff);
It's much clearer what is actually being done. Same goes for other functions in this file.
Quoted 81 lines
arch/arm/mach-vt8500/gpio.c new file +81
-0+ +return 0 ; +} + +static void vt8500_muxed_gpio_free (struct gpio_chip *chip, +unsigned offset) +{ +struct vt8500_gpio_chip *vt8500_chip =to_vt8500 (chip); + +writel (readl (regbase + vt8500_chip->regoff) & + ~(1 << vt8500_chip->shift << offset), + regbase + vt8500_chip->regoff); +} + +static int vt8500_muxed_gpio_direction_input (struct gpio_chip *chip, +unsigned offset) +{ +struct vt8500_gpio_chip *vt8500_chip =to_vt8500 (chip); + +writel (readl (regbase +0x20 + vt8500_chip->regoff) & + ~(1 << vt8500_chip->shift << offset), + regbase +0x20 + vt8500_chip->regoff); + +return 0 ; +} + +static int vt8500_muxed_gpio_direction_output (struct gpio_chip *chip, +unsigned offset,int value) +{ +struct vt8500_gpio_chip *vt8500_chip =to_vt8500 (chip); + +writel (readl (regbase +0x20 + vt8500_chip->regoff) | + (1 << vt8500_chip->shift << offset), + regbase +0x20 + vt8500_chip->regoff); + +if (value) +writel (readl (regbase +0x40 + vt8500_chip->regoff) | + (1 << vt8500_chip->shift << offset), + regbase +0x40 + vt8500_chip->regoff); +return 0 ; +} + +static int vt8500_muxed_gpio_get_value (struct gpio_chip *chip, +unsigned offset) +{ +struct vt8500_gpio_chip *vt8500_chip =to_vt8500 (chip); + +return (readl (regbase +0x60 + vt8500_chip->regoff) + >> vt8500_chip->shift >> offset) &1 ; +} + +static void vt8500_muxed_gpio_set_value (struct gpio_chip *chip, +unsigned offset,int value) +{ +struct vt8500_gpio_chip *vt8500_chip =to_vt8500 (chip); + +if (value) +writel (readl (regbase +0x40 + vt8500_chip->regoff) | + (1 << vt8500_chip->shift << offset), + regbase +0x40 + vt8500_chip->regoff); +else +writel (readl (regbase +0x40 + vt8500_chip->regoff) & + ~(1 << vt8500_chip->shift << offset), + regbase +0x40 + vt8500_chip->regoff); +} + +#define VT8500_GPIO_BANK (__name, __shift, __off, __base, __num) \ +{ \ + .chip = { \ + .label = __name, \ + .request = vt8500_muxed_gpio_request, \ + .free = vt8500_muxed_gpio_free, \ + .direction_input = vt8500_muxed_gpio_direction_input, \ + .direction_output = vt8500_muxed_gpio_direction_output, \ + .get = vt8500_muxed_gpio_get_value, \ + .set = vt8500_muxed_gpio_set_value, \ + .can_sleep = 0, \ + .base = __base, \ + .ngpio = __num, \ + }, \ + .shift = __shift, \
arch/arm/mach-vt8500/gpio.c line 134
Quoted 10 lines
arch/arm/mach-vt8500/gpio.c new file +10
-0+ .regoff = __off, \ +} + +static struct vt8500_gpio_chip vt8500_muxed_gpios[] = { +VT8500_GPIO_BANK ("uart0" ,0 ,0x0 ,8 ,4 ), +VT8500_GPIO_BANK ("uart1" ,4 ,0x0 ,12 ,4 ), +VT8500_GPIO_BANK ("spi0" ,8 ,0x0 ,16 ,4 ), +VT8500_GPIO_BANK ("spi1" ,12 ,0x0 ,20 ,4 ), +VT8500_GPIO_BANK ("spi2" ,16 ,0x0 ,24 ,4 ), +VT8500_GPIO_BANK ("pwmout" ,24 ,0x0 ,28 ,2 ),
Nitpick: Line up the columns to make these mpore readable.
Quoted 222 lines
arch/arm/mach-vt8500/gpio.c new file +96
-0+ +VT8500_GPIO_BANK ("sdmmc" ,0 ,0x4 ,30 ,11 ), +VT8500_GPIO_BANK ("ms" ,16 ,0x4 ,41 ,7 ), +VT8500_GPIO_BANK ("i2c0" ,24 ,0x4 ,48 ,2 ), +VT8500_GPIO_BANK ("i2c1" ,26 ,0x4 ,50 ,2 ), + +VT8500_GPIO_BANK ("mii" ,0 ,0x8 ,52 ,20 ), +VT8500_GPIO_BANK ("see" ,20 ,0x8 ,72 ,4 ), +VT8500_GPIO_BANK ("ide" ,24 ,0x8 ,76 ,7 ), + +VT8500_GPIO_BANK ("ccir" ,0 ,0xc ,83 ,19 ), + +VT8500_GPIO_BANK ("ts" ,8 ,0x10 ,102 ,11 ), + + VT8500_GPIO_BANK("lcd", 0, 0x14, 113, 23), +}; + +static int vt8500_gpio_direction_input (struct gpio_chip *chip, +unsigned offset) +{ +writel (readl (regbase +0x3c ) & ~(1 << offset), regbase +0x3c ); +return 0 ; +} + +static int vt8500_gpio_direction_output (struct gpio_chip *chip, +unsigned offset,int value) +{ +writel (readl (regbase +0x3c ) | (1 << offset), regbase +0x3c ); + +if (value) +writel (readl (regbase +0x5c ) | (1 << offset), + regbase +0x5c ); +return 0 ; +} + +static int vt8500_gpio_get_value (struct gpio_chip *chip, +unsigned offset) +{ +return (readl (regbase +0x7c ) >> offset) &1 ; +} + +static void vt8500_gpio_set_value (struct gpio_chip *chip, +unsigned offset,int value) +{ +if (value) +writel (readl (regbase +0x5c ) | (1 << offset), + regbase +0x5c ); +else +writel (readl (regbase +0x5c ) & ~(1 << offset), + regbase +0x5c ); +} + +static int vt8500_gpio_to_irq (struct gpio_chip *chip,unsigned offset) +{ +if (offset >7 ) +return -EINVAL ; + +return gpio_to_irq_map[offset]; +} + +static struct gpio_chip vt8500_external_gpios = { + .label ="extgpio" , + .direction_input = vt8500_gpio_direction_input, + .direction_output = vt8500_gpio_direction_output, + .get = vt8500_gpio_get_value, + .set = vt8500_gpio_set_value, + .to_irq = vt8500_gpio_to_irq, + .can_sleep =0 , + .base =0 , + .ngpio =8 , +}; + +void __init vt8500_gpio_init (void ) +{ +int i; + + gpio_to_irq_map[0 ] = wmt_current_irqs->ext0; + gpio_to_irq_map[1 ] = wmt_current_irqs->ext1; + gpio_to_irq_map[2 ] = wmt_current_irqs->ext2; + gpio_to_irq_map[3 ] = wmt_current_irqs->ext3; + gpio_to_irq_map[4 ] = wmt_current_irqs->ext4; + gpio_to_irq_map[5 ] = wmt_current_irqs->ext5; + gpio_to_irq_map[6 ] = wmt_current_irqs->ext6; + gpio_to_irq_map[7 ] = wmt_current_irqs->ext7; + + regbase =ioremap (wmt_current_regs->gpio,SZ_64K ); +if (!regbase) { +printk (KERN_ERR "Failed to map MMIO registers for GPIO\n" ); +return ; + } + +gpiochip_add (&vt8500_external_gpios); + +for (i =0 ; i <ARRAY_SIZE (vt8500_muxed_gpios); i++) +gpiochip_add (&vt8500_muxed_gpios[i].chip); +}arch/arm/mach-vt8500/include/mach/debug-macro.S new file +31
-0@@ -0,0 +1,31 @@ +/* + * arch/arm/mach-vt8500/include/mach/debug-macro.S + * + * Copyright (C) 2010 Alexey Charkov <[email protected]> + * + * 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 + mov \rp, #0x00200000 + orr \rv, \rp, #0xf8000000 + orr \rp, \rp, #0xd8000000 + .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 + .endmarch/arm/mach-vt8500/include/mach/entry-macro.S new file +32
-0@@ -0,0 +1,32 @@ +/* + * arch/arm/mach-vt8500/include/mach/entry-macro.S + * + * Low-level IRQ helper macros for VIA VT8500 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + + .macro disable_fiq + .endm + + .macro get_irqnr_preamble, base, tmp + @ physical 0xd8140000 is virtual 0xf8140000 + mov \base, #0xf8000000 + orr \base, \base, #0x00140000 + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #63 @ may be false positive, check interrupt status + bne 1001f + ldr \irqstat, [\base, #0x84] + ands \irqstat, #0x80000000 + moveq \irqnr, #0 +1001: + .endm +arch/arm/mach-vt8500/include/mach/gpio.h new file +6
-0@@ -0,0 +1,6 @@ +#include <asm-generic/gpio.h> + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq __gpio_to_irqarch/arm/mach-vt8500/include/mach/hardware.h new file +12
-0@@ -0,0 +1,12 @@ +/* arch/arm/mach-vt8500/include/mach/hardware.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. +* +*/ arch/arm/mach-vt8500/include/mach/io.h new file +15
-0@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/io.h +* +* 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. +*
arch/arm/mach-vt8500/include/mach/io.h line 25
Quoted 10 lines
arch/arm/mach-vt8500/include/mach/io.h new file +10
-0+* 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 __ASM_ARM_ARCH_IO_H +#define __ASM_ARM_ARCH_IO_H + +#define IO_SPACE_LIMIT 0xffff + +#define __io (a) ((void __iomem *)((a) + 0xf0000000))
Should use __typesafe_io.
Quoted 183 lines
arch/arm/mach-vt8500/include/mach/io.h new file +3
-0+#define __mem_pci (a) (a) + +#endif arch/arm/mach-vt8500/include/mach/irq_defs.h new file +124
-0@@ -0,0 +1,124 @@ +/* +* arch/arm/mach-vt8500/include/mach/irq_defs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 VT8500_IRQ_DEFS_H +#define VT8500_IRQ_DEFS_H + +#include <linux/types.h> + +struct wmt_irq_srcs { +u8 nr_irqs; +u8 jpegenc; +u8 jpegdec; +u8 pata; +u8 dma; +u8 ext0; +u8 ext1; +u8 ext2; +u8 ext3; +u8 ext4; +u8 ext5; +u8 ext6; +u8 ext7; +u8 ether; +u8 mpegts; +u8 ge; +u8 gov; +u8 lcdc; +u8 lcdf; +u8 vpp; +u8 vpu; +u8 vid; +u8 spu; +u8 pip; +u8 dvo; +u8 govw; +u8 govrsdscd; +u8 govrsdmif; +u8 govrhdscd; +u8 govrhdmif; +u8 cipher; +u8 i2c0; +u8 i2c1; +u8 sdmmc; +u8 sdmmc_dma; +u8 pmc_wu; +u8 spi0; +u8 spi1; +u8 spi2; +u8 nand; +u8 nand_dma; +u8 nor; +u8 memstick; +u8 memstick_dma; +u8 uart0; +u8 uart1; +u8 uart2; +u8 uart3; +u8 uart4; +u8 uart5; +u8 i2s; +u8 pcm; +u8 ac97; +u8 timer_match0; +u8 timer_match1; +u8 timer_match2; +u8 timer_match3; +u8 ehci; +u8 uhci; +u8 udc; +u8 udc_dma; +u8 keypad; +u8 ps2mouse; +u8 ps2kbd; +u8 rtc; +u8 rtc_hz; +u8 adc; +u8 cir; +u8 dma0; +u8 dma1; +u8 dma2; +u8 dma3; +u8 dma4; +u8 dma5; +u8 dma6; +u8 dma7; +u8 dma8; +u8 dma9; +u8 dma10; +u8 dma11; +u8 dma12; +u8 dma13; +u8 dma14; +u8 dma15; +u8 irq0; +u8 irq1; +u8 irq2; +u8 irq3; +u8 irq4; +u8 irq5; +u8 irq6; +u8 irq7; +u8 sae; +}; + +extern struct wmt_irq_srcs wmt_irqs[]__initdata ; +extern struct wmt_irq_srcs *wmt_current_irqs__initdata ; + +#endif arch/arm/mach-vt8500/include/mach/irqs.h new file +22
-0@@ -0,0 +1,22 @@ +/* +* arch/arm/mach-vt8500/include/mach/irqs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 value is just to make the core happy, never used otherwise */ +#define NR_IRQS 128arch/arm/mach-vt8500/include/mach/memory.h new file +16
-0@@ -0,0 +1,28 @@ +/* +* arch/arm/mach-vt8500/include/mach/memory.h +* +* Copyright (C) 2003 ARM Limited +* +* 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
arch/arm/mach-vt8500/include/mach/memory.h line 26
Quoted 10 lines
arch/arm/mach-vt8500/include/mach/memory.h new file +10
-0+* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET UL(0x00000000)
If you renamed this to PHYS_DRAM_OFFSET you wouldn't need the comment :-).
Quoted 244 lines
arch/arm/mach-vt8500/include/mach/memory.h new file +2
-0+ +#endif arch/arm/mach-vt8500/include/mach/mmio_regs.h new file +90
-0@@ -0,0 +1,90 @@ +/* +* arch/arm/mach-vt8500/include/mach/mmio_regs.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 __ASM_ARM_ARCH_MMIO_REGS_H +#define __ASM_ARM_ARCH_MMIO_REGS_H + +#include <linux/init.h> + +struct wmt_mmio_regs { +unsigned long mmio_regs_start; +unsigned long mmio_regs_length; +unsigned long mmio_regs_virt; +unsigned long ddr; +unsigned long dma; +unsigned long vdma; +unsigned long sflash; +unsigned long ether; +unsigned long cipher; +unsigned long ehci; +unsigned long uhci; +unsigned long pata; +unsigned long ps2; +unsigned long nand; +unsigned long nor; +unsigned long sdmmc; +unsigned long memstick; +unsigned long lcdc; +unsigned long vpu; +unsigned long gov; +unsigned long ge; +unsigned long govr; +unsigned long scl; +unsigned long lcdf; +unsigned long vid; +unsigned long vpp; +unsigned long tsbk; +unsigned long jpegdec; +unsigned long jpegenc; +unsigned long rtc; +unsigned long gpio; +unsigned long scc; +unsigned long pmc; +unsigned long ic0; +unsigned long ic1; +unsigned long uart0; +unsigned long uart1; +unsigned long uart2; +unsigned long uart3; +unsigned long uart4; +unsigned long uart5; +unsigned long pwm; +unsigned long spi0; +unsigned long spi1; +unsigned long spi2; +unsigned long cir; +unsigned long i2c0; +unsigned long i2c1; +unsigned long ac97; +unsigned long pcm; +unsigned long i2s; +unsigned long adc; +unsigned long keypad; +}; + +enum { +VT8500_INDEX , +WM8505_INDEX , +}; + +extern struct wmt_mmio_regs wmt_regmaps[]__initdata ; +extern struct wmt_mmio_regs *wmt_current_regs__initdata ; + +#endif +arch/arm/mach-vt8500/include/mach/system.h new file +18
-0@@ -0,0 +1,18 @@ +/* +* arch/arm/mach-vt8500/include/mach/system.h +* +*/ +#include <asm/io.h> + +/* PM Software Reset request register */ +#define VT8500_PMSR_VIRT 0xf8130060 + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +writel (1 ,VT8500_PMSR_VIRT ); +}arch/arm/mach-vt8500/include/mach/timex.h new file +26
-0@@ -0,0 +1,26 @@ +/* +* arch/arm/mach-vt8500/include/mach/timex.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 (3000000) + +#endif /* MACH_TIMEX_H */ arch/arm/mach-vt8500/include/mach/uncompress.h new file +37
-0@@ -0,0 +1,37 @@ +/* arch/arm/mach-vt8500/include/mach/uncompress.h +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 0xd8200000 +#include <asm/io.h> + +static void putc (const char c) +{ +while (readb (UART0_PHYS +0x1c ) &0x2 ) +/* Tx busy, wait and poll */ ; + +writeb (c,UART0_PHYS ); +} + +static void flush (void ) +{ +} + +/* +* nothing to do +*/ +#define arch_decomp_setup () +#define arch_decomp_wdog ()arch/arm/mach-vt8500/include/mach/vmalloc.h new file +20
-0@@ -0,0 +1,20 @@ +/* +* arch/arm/mach-vt8500/include/mach/vmalloc.h +* +* Copyright (C) 2000 Russell King. +* +* 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 +*/ +#define VMALLOC_END 0xd0000000ULarch/arm/mach-vt8500/include/mach/vt8500fb.h new file +15
-0@@ -0,0 +1,31 @@ +/* +* VT8500/WM8505 Frame Buffer platform data definitions +* +* Copyright (C) 2010 Ed Spiridonov <[email protected]> +* +* 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. +*/ +
arch/arm/mach-vt8500/include/mach/vt8500fb.h line 25
Quoted 10 lines
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +10
-0+#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;
Is this struct exported to user space? If not, use u32 rather than __u32.
Quoted 46 lines
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +6
-0+unsigned long video_mem_phys; +void *video_mem_virt; + unsigned long video_mem_len; +}; + +#endif /* _VT8500FB_H */ arch/arm/mach-vt8500/irq.c new file +34
-0@@ -0,0 +1,179 @@ +/* +* arch/arm/mach-vt8500/irq.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 +*/ + +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/interrupt.h> + +#include <asm/irq.h> + +#include <mach/mmio_regs.h> +#include <mach/irq_defs.h> + +#define VT8500_IC_DCTR 0x40/* Destination control +register, 64*u8 */ +#define VT8500_INT_ENABLE (1 << 3) +#define VT8500_TRIGGER_HIGH (0 << 4) +#define VT8500_TRIGGER_RISING (1 << 4)
arch/arm/mach-vt8500/irq.c line 44
Quoted 10 lines
arch/arm/mach-vt8500/irq.c new file +10
-0+#define VT8500_TRIGGER_FALLING (2 << 4) +#define VT8500_IC_STATUS 0x80/* Interrupt status, 2*u32 */ + +static void __iomem *ic_regbase; +static void __iomem *sic_regbase; + +static void vt8500_irq_mask (unsigned int irq) +{ +void __iomem *base = ic_regbase; +u8 edge;
Nitpick: blank line between variable declarations and code.
arch/arm/mach-vt8500/irq.c line 49
Quoted 5 lines
arch/arm/mach-vt8500/irq.c new file +5
-0+if (irq >=64 ) { + base = sic_regbase; + irq -=64 ; + } + edge =readb (base +VT8500_IC_DCTR + irq) & (3 <<4 );
What is (3 << 4)? Replace with a #define.
arch/arm/mach-vt8500/irq.c line 54
Quoted 5 lines
arch/arm/mach-vt8500/irq.c new file +5
-0+if (edge) +writel (readl (base + +VT8500_IC_STATUS + (irq <32 ?0 :4 )) + | (1 << (irq &0x1f )), base + +VT8500_IC_STATUS + (irq &0x20 ?4 :0 ));
More unexplained magic numbers.
Quoted 12 lines
arch/arm/mach-vt8500/irq.c new file +12
-0+else +writeb (readb (base + +VT8500_IC_DCTR + irq) & ~VT8500_INT_ENABLE , + base +VT8500_IC_DCTR + irq); +} + +static void vt8500_irq_unmask (unsigned int irq) +{ +void __iomem *base = ic_regbase; +if (irq >=64 ) { + base = sic_regbase; + irq -=64 ;
arch/arm/mach-vt8500/irq.c line 76
Quoted 10 lines
arch/arm/mach-vt8500/irq.c new file +10
-0+ } +writeb (readb (base + +VT8500_IC_DCTR + irq) |VT8500_INT_ENABLE , + base +VT8500_IC_DCTR + irq); +} + +static int vt8500_irq_set_wake (unsigned int irq,unsigned int on) +{ +return -EINVAL ; +}
You don't have to provide this function.
Quoted 33 lines
arch/arm/mach-vt8500/irq.c new file +33
-0+static int vt8500_irq_set_type (unsigned int irq,unsigned int flow_type) +{ +void __iomem *base = ic_regbase; +unsigned int orig_irq = irq; +if (irq >=64 ) { + base = sic_regbase; + irq -=64 ; + } +switch (flow_type) { +case IRQF_TRIGGER_LOW : +return -EINVAL ; +case IRQF_TRIGGER_HIGH : +writeb ((readb (base + +VT8500_IC_DCTR + irq) & ~(3 <<4 )) + |VT8500_TRIGGER_HIGH , base + +VT8500_IC_DCTR + irq); + irq_desc[orig_irq].handle_irq = handle_level_irq; +break ; +case IRQF_TRIGGER_FALLING : +writeb ((readb (base + +VT8500_IC_DCTR + irq) & ~(3 <<4 )) + |VT8500_TRIGGER_FALLING , base + +VT8500_IC_DCTR + irq); + irq_desc[orig_irq].handle_irq = handle_edge_irq; +break ; +case IRQF_TRIGGER_RISING : +writeb ((readb (base + +VT8500_IC_DCTR + irq) & ~(3 <<4 )) + |VT8500_TRIGGER_RISING , base + +VT8500_IC_DCTR + irq); + irq_desc[orig_irq].handle_irq = handle_edge_irq; +break ; + }
arch/arm/mach-vt8500/irq.c line 120
Quoted 10 lines
arch/arm/mach-vt8500/irq.c new file +10
-0+ +return 0 ; +} + +static struct irq_chip vt8500_irq_chip = { + .name ="vt8500" , + .ack = vt8500_irq_mask, + .mask = vt8500_irq_mask, + .unmask = vt8500_irq_unmask, + .set_wake = vt8500_irq_set_wake,
Remove .set_wake.
Quoted 15 lines
arch/arm/mach-vt8500/irq.c new file +15
-0+ .set_type = vt8500_irq_set_type, +}; + +void __init vt8500_init_irq (void ) +{ +unsigned int i; + + ic_regbase =ioremap (wmt_current_regs->ic0,SZ_64K ); + +if (ic_regbase) { +/* Enable rotating priority for IRQ */ +writel ((1 <<6 ), ic_regbase +0x20 ); +writel (0 , ic_regbase +0x24 ); + +for (i =0 ; i < wmt_current_irqs->nr_irqs; i++) {
arch/arm/mach-vt8500/irq.c line 145
Quoted 10 lines
arch/arm/mach-vt8500/irq.c new file +10
-0+/* Disable all interrupts and route them to IRQ */ +writeb (0x00 , ic_regbase +VT8500_IC_DCTR + i); + +set_irq_chip (i, &vt8500_irq_chip); +set_irq_handler (i, handle_level_irq); +set_irq_flags (i,IRQF_VALID ); + } + }else { +printk (KERN_ERR "Unable to remap the Interrupt Controller " +"registers, not enabling IRQs!\n" );
printk strings should be on a single line (can be > 80 columns) to make grepping easier. You could also use the pr_ macros with pr_fmt set.
arch/arm/mach-vt8500/pwm.c
Quoted 342 lines
arch/arm/mach-vt8500/irq.c new file +34
-0+ } +} + +void __init wm8505_init_irq (void ) +{ +unsigned int i; + + ic_regbase =ioremap (wmt_current_regs->ic0,SZ_64K ); + sic_regbase =ioremap (wmt_current_regs->ic1,SZ_64K ); + +if (ic_regbase && sic_regbase) { +/* Enable rotating priority for IRQ */ +writel ((1 <<6 ), ic_regbase +0x20 ); +writel (0 , ic_regbase +0x24 ); +writel ((1 <<6 ), sic_regbase +0x20 ); +writel (0 , sic_regbase +0x24 ); + +for (i =0 ; i < wmt_current_irqs->nr_irqs; i++) { +/* Disable all interrupts and route them to IRQ */ +if (i <64 ) +writeb (0x00 , ic_regbase +VT8500_IC_DCTR + i); +else +writeb (0x00 , sic_regbase +VT8500_IC_DCTR + + i -64 ); + +set_irq_chip (i, &vt8500_irq_chip); +set_irq_handler (i, handle_level_irq); +set_irq_flags (i,IRQF_VALID ); + } + }else { +printk (KERN_ERR "Unable to remap the Interrupt Controller " +"registers, not enabling IRQs!\n" ); + } +}arch/arm/mach-vt8500/irq_defs.c new file +173
-0@@ -0,0 +1,173 @@ +/* linux/arch/arm/mach-vt8500/irq_defs.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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/init.h> + +#include <mach/irq_defs.h> +#include <mach/mmio_regs.h> + +struct wmt_irq_srcs *wmt_current_irqs__initdata ; + +struct wmt_irq_srcs wmt_irqs[]__initdata = { + [VT8500_INDEX ] = { + .jpegenc =0 , + .jpegdec =1 , + .pata =3 , + .dma =5 , + .ext0 =6 , + .ext1 =7 , + .ge =8 , + .gov =9 , + .ether =10 , + .mpegts =11 , + .lcdc =12 , + .ext2 =13 , + .ext3 =14 , + .ext4 =15 , + .cipher =16 , + .vpp =17 , + .i2c1 =18 , + .i2c0 =19 , + .sdmmc =20 , + .sdmmc_dma =21 , + .pmc_wu =22 , + .spi0 =24 , + .spi1 =25 , + .spi2 =26 , + .lcdf =27 , + .nand =28 , + .nand_dma =29 , + .memstick =30 , + .memstick_dma =31 , + .uart0 =32 , + .uart1 =33 , + .i2s =34 , + .pcm =35 , + .timer_match0 =36 , + .timer_match1 =37 , + .timer_match2 =38 , + .timer_match3 =39 , + .vpu =40 , + .vid =41 , + .ac97 =42 , + .ehci =43 , + .nor =44 , + .ps2mouse =45 , + .ps2kbd =46 , + .uart2 =47 , + .rtc =48 , + .rtc_hz =49 , + .uart3 =50 , + .adc =51 , + .ext5 =52 , + .ext6 =53 , + .ext7 =54 , + .cir =55 , + .dma0 =56 , + .dma1 =57 , + .dma2 =58 , + .dma3 =59 , + .dma4 =60 , + .dma5 =61 , + .dma6 =62 , + .dma7 =63 , + .nr_irqs =64 , + }, + [WM8505_INDEX ] = { + .uhci =0 , + .ehci =1 , + .udc_dma =2 , + .ps2mouse =4 , + .udc =5 , + .ext0 =6 , + .ext1 =7 , + .keypad =8 , + .dma =9 , + .ether =10 , + .ext2 =13 , + .ext3 =14 , + .ext4 =15 , + .dma0 =17 , + .i2c1 =18 , + .i2c0 =19 , + .sdmmc =20 , + .sdmmc_dma =21 , + .pmc_wu =22 , + .ps2kbd =23 , + .spi0 =24 , + .spi1 =25 , + .spi2 =26 , + .dma1 =27 , + .nand =28 , + .nand_dma =29 , + .uart5 =30 , + .uart4 =31 , + .uart0 =32 , + .uart1 =33 , + .dma2 =34 , + .i2s =35 , + .timer_match0 =36 , + .timer_match1 =37 , + .timer_match2 =38 , + .timer_match3 =39 , + .dma3 =40 , + .dma4 =41 , + .ac97 =42 , + .nor =44 , + .dma5 =45 , + .dma6 =46 , + .uart2 =47 , + .rtc =48 , + .rtc_hz =49 , + .uart3 =50 , + .dma7 =51 , + .ext5 =52 , + .ext6 =53 , + .ext7 =54 , + .cir =55 , + .irq0 =56 , + .irq1 =57 , + .irq2 =58 , + .irq3 =59 , + .irq4 =60 , + .irq5 =61 , + .irq6 =62 , + .irq7 =63 , + .jpegdec =65 , + .sae =66 , + .vpu =79 , + .vpp =80 , + .vid =81 , + .spu =82 , + .pip =83 , + .ge =84 , + .gov =85 , + .dvo =86 , + .dma8 =92 , + .dma9 =93 , + .dma10 =94 , + .dma11 =95 , + .dma12 =96 , + .dma13 =97 , + .dma14 =98 , + .dma15 =99 , + .govw =111 , + .govrsdscd =112 , + .govrsdmif =113 , + .govrhdscd =114 , + .govrhdmif =115 , + .nr_irqs =116 , + }, +};arch/arm/mach-vt8500/mmio_regs.c new file +118
-0@@ -0,0 +1,118 @@ +/* linux/arch/arm/mach-vt8500/mmio_regs.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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/init.h> + +#include <mach/mmio_regs.h> + +struct wmt_mmio_regs *wmt_current_regs__initdata ; + +struct wmt_mmio_regs wmt_regmaps[]__initdata = { + [VT8500_INDEX ] = { + .mmio_regs_start =0xd8000000 , + .mmio_regs_length =0x00350000 , + .mmio_regs_virt =0xf8000000 , + .ddr =0xd8000000 , + .dma =0xd8001000 , + .sflash =0xd8002000 , + .ether =0xd8004000 , + .cipher =0xd8006000 , + .ehci =0xd8007900 , + .uhci =0xd8007b01 , + .pata =0xd8008000 , + .ps2 =0xd8008800 , + .nand =0xd8009000 , + .nor =0xd8009400 , + .sdmmc =0xd800a000 , + .memstick =0xd800b400 , + .lcdc =0xd800e400 , + .vpu =0xd8050000 , + .gov =0xd8050300 , + .ge =0xd8050400 , + .lcdf =0xd8050900 , + .vid =0xd8050a00 , + .vpp =0xd8050b00 , + .tsbk =0xd80f4000 , + .jpegdec =0xd80fe000 , + .jpegenc =0xd80ff000 , + .rtc =0xd8100000 , + .gpio =0xd8110000 , + .scc =0xd8120000 , + .pmc =0xd8130000 , + .ic0 =0xd8140000 , + .uart0 =0xd8200000 , + .uart2 =0xd8210000 , + .pwm =0xd8220000 , + .spi0 =0xd8240000 , + .spi1 =0xd8250000 , + .cir =0xd8270000 , + .i2c0 =0xd8280000 , + .ac97 =0xd8290000 , + .spi2 =0xd82a0000 , + .uart1 =0xd82b0000 , + .uart3 =0xd82c0000 , + .pcm =0xd82d0000 , + .i2c1 =0xd8320000 , + .i2s =0xd8330000 , + .adc =0xd8340000 , + }, + [WM8505_INDEX ] = { + .mmio_regs_start =0xd8000000 , + .mmio_regs_length =0x00390000 , + .mmio_regs_virt =0xf8000000 , + .ddr =0xd8000400 , + .dma =0xd8001800 , + .vdma =0xd8001c00 , + .sflash =0xd8002000 , + .ether =0xd8004000 , + .cipher =0xd8006000 , + .ehci =0xd8007100 , + .uhci =0xd8007301 , + .ps2 =0xd8008800 , + .nand =0xd8009000 , + .nor =0xd8009400 , + .sdmmc =0xd800a000 , + .vpu =0xd8050000 , + .gov =0xd8050300 , + .ge =0xd8050400 , + .govr =0xd8050800 , + .vid =0xd8050a00 , + .scl =0xd8050d00 , + .vpp =0xd8050f00 , + .jpegdec =0xd80fe000 , + .rtc =0xd8100000 , + .gpio =0xd8110000 , + .scc =0xd8120000 , + .pmc =0xd8130000 , + .ic0 =0xd8140000 , + .ic1 =0xd8150000 , + .uart0 =0xd8200000 , + .uart2 =0xd8210000 , + .pwm =0xd8220000 , + .spi0 =0xd8240000 , + .spi1 =0xd8250000 , + .keypad =0xd8260000 , + .cir =0xd8270000 , + .i2c0 =0xd8280000 , + .ac97 =0xd8290000 , + .spi2 =0xd82a0000 , + .uart1 =0xd82b0000 , + .uart3 =0xd82c0000 , + .i2c1 =0xd8320000 , + .i2s =0xd8330000 , + .uart4 =0xd8370000 , + .uart5 =0xd8380000 , + }, +};arch/arm/mach-vt8500/pwm.c new file +0
-0
I'm not sure what the state of the various efforts to provide a common pwm framework are, but you may want to check.
Quoted 35 lines
arch/arm/mach-vt8500/pwm.c new file +34
-0@@ -0,0 +1,254 @@ +/* +* arch/arm/mach-vt8500/pwm.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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/kernel.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/pwm.h> + +#include <asm/div64.h> + +#define VT8500_NR_PWMS 4 + +struct pwm_device { +struct list_head node; +struct platform_device *pdev; + +const char *label; + +void __iomem *regbase;
arch/arm/mach-vt8500/pwm.c line 44
Quoted 10 lines
arch/arm/mach-vt8500/pwm.c new file +10
-0+ +unsigned int use_count; +unsigned int pwm_id; +}; + +static inline void pwm_busy_wait (void __iomem *reg,u8 bitmask) +{ +int loops =1000 ; +while ((readb (reg) & bitmask) && --loops) +cpu_relax ();
Ugh. If you are going to busy wait, can't you delay for a known amount of time? Even better, can this be replaced with wait_event or some equivalent?
Quoted 4 lines
arch/arm/mach-vt8500/pwm.c new file +4
-0+} + +int pwm_config (struct pwm_device *pwm,int duty_ns,int period_ns) +{
arch/arm/mach-vt8500/pwm.c line 58
Quoted 10 lines
arch/arm/mach-vt8500/pwm.c new file +10
-0+unsigned long long c; +unsigned long period_cycles, prescale, pv, dc; + +if (pwm ==NULL || period_ns ==0 || duty_ns > period_ns) +return -EINVAL ; + + c =25000000 /2 ;/* wild guess --- need to implement clocks */ + c = c * period_ns; +do_div (c,1000000000 ); + period_cycles = c;
This looks like it could be reworked to remove the do_div call.
Quoted 33 lines
arch/arm/mach-vt8500/pwm.c new file +33
-0+ +if (period_cycles <1 ) + period_cycles =1 ; + prescale = (period_cycles -1 ) /4096 ; + pv = period_cycles / (prescale +1 ) -1 ; +if (pv >4095 ) + pv =4095 ; + +if (prescale >1023 ) +return -EINVAL ; + + dc = pv * duty_ns / period_ns; + +pwm_busy_wait (pwm->regbase +0x40 + pwm->pwm_id, (1 <<1 )); +writel (prescale, pwm->regbase +0x4 + (pwm->pwm_id <<4 )); + +pwm_busy_wait (pwm->regbase +0x40 + pwm->pwm_id, (1 <<2 )); +writel (pv, pwm->regbase +0x8 + (pwm->pwm_id <<4 )); + +pwm_busy_wait (pwm->regbase +0x40 + pwm->pwm_id, (1 <<3 )); +writel (dc, pwm->regbase +0xc + (pwm->pwm_id <<4 )); + +return 0 ; +} +EXPORT_SYMBOL (pwm_config); + +int pwm_enable (struct pwm_device *pwm) +{ +pwm_busy_wait (pwm->regbase +0x40 + pwm->pwm_id, (1 <<0 )); +writel (5 , pwm->regbase + (pwm->pwm_id <<4 )); +return 0 ; +} +EXPORT_SYMBOL (pwm_enable);
arch/arm/mach-vt8500/pwm.c line 101
Quoted 10 lines
arch/arm/mach-vt8500/pwm.c new file +10
-0+ +void pwm_disable (struct pwm_device *pwm) +{ +pwm_busy_wait (pwm->regbase +0x40 + pwm->pwm_id, (1 <<0 )); +writel (0 , pwm->regbase + (pwm->pwm_id <<4 )); +} +EXPORT_SYMBOL (pwm_disable); + +static DEFINE_MUTEX (pwm_lock); +static LIST_HEAD (pwm_list);
These should be at the top of the file.
Quoted 16 lines
arch/arm/mach-vt8500/pwm.c new file +16
-0+struct pwm_device *pwm_request (int pwm_id,const char *label) +{ +struct pwm_device *pwm; +int found =0 ; + +mutex_lock (&pwm_lock); + +list_for_each_entry (pwm, &pwm_list, node) { +if (pwm->pwm_id == pwm_id) { + found =1 ; +break ; + } + } + +if (found) { +if (pwm->use_count ==0 ) {
arch/arm/mach-vt8500/pwm.c line 128
Quoted 10 lines
arch/arm/mach-vt8500/pwm.c new file +10
-0+ pwm->use_count++; + pwm->label = label; + }else + pwm =ERR_PTR (-EBUSY ); + }else + pwm =ERR_PTR (-ENOENT ); + +mutex_unlock (&pwm_lock); +return pwm; +}
Maybe a bit clearer and more concise like this? Also replaces -ENOENT (No such file or directory) with -ENODEV (No such device):
pwm = ERR_PTR(-ENODEV);
mutex_lock(&pwm_lock);
list_for_each_entry(pwm, &pwm_list, node) {
if (pwm->pwm_id == pwm_id) {
if (pwm->use_count != 0) {
pwm = ERR_PTR(-EBUSY);
break;
}
pwm->use_count++;
pwm->label = label;
break;
}
}
mutex_unlock(&pwm_lock);
return pwm; arch/arm/mach-vt8500/pwm.c line 140
Quoted 12 lines
arch/arm/mach-vt8500/pwm.c new file +12
-0+EXPORT_SYMBOL (pwm_request); + +void pwm_free (struct pwm_device *pwm) +{ +mutex_lock (&pwm_lock); + +if (pwm->use_count) { + pwm->use_count--; + pwm->label =NULL ; + }else +pr_warning ("PWM device already freed\n" ); +
Nitpick: Single line else should have braces if the if has braces
Quoted 13 lines
arch/arm/mach-vt8500/pwm.c new file +13
-0+mutex_unlock (&pwm_lock); +} +EXPORT_SYMBOL (pwm_free); + +static inline void __add_pwm (struct pwm_device *pwm) +{ +mutex_lock (&pwm_lock); +list_add_tail (&pwm->node, &pwm_list); +mutex_unlock (&pwm_lock); +} + +static int __devinit pwm_probe (struct platform_device *pdev) +{
arch/arm/mach-vt8500/pwm.c line 163
Quoted 10 lines
arch/arm/mach-vt8500/pwm.c new file +10
-0+struct pwm_device *pwms; +struct resource *r; +int ret =0 ; +int i; + + pwms =kzalloc (sizeof (struct pwm_device ) *VT8500_NR_PWMS ,GFP_KERNEL ); +if (pwms ==NULL ) { +dev_err (&pdev->dev,"failed to allocate memory\n" ); +return -ENOMEM ; + }
Devices should ideally be a single entity, so one platform device per pwm.
Quoted 139 lines
arch/arm/mach-vt8500/pwm.c new file +91
-0+ +for (i =0 ; i <VT8500_NR_PWMS ; i++) { + pwms[i].use_count =0 ; + pwms[i].pwm_id = i; + pwms[i].pdev = pdev; + } + + r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (r ==NULL ) { +dev_err (&pdev->dev,"no memory resource defined\n" ); + ret = -ENODEV ; + goto err_free; + } + + r =request_mem_region (r->start,resource_size (r), pdev->name); +if (r ==NULL ) { +dev_err (&pdev->dev,"failed to request memory resource\n" ); + ret = -EBUSY ; + goto err_free; + } + + pwms[0 ].regbase =ioremap (r->start,resource_size (r)); +if (pwms[0 ].regbase ==NULL ) { +dev_err (&pdev->dev,"failed to ioremap() registers\n" ); + ret = -ENODEV ; + goto err_free_mem; + } + +for (i =1 ; i <VT8500_NR_PWMS ; i++) + pwms[i].regbase = pwms[0 ].regbase; + +for (i =0 ; i <VT8500_NR_PWMS ; i++) +__add_pwm (&pwms[i]); + +platform_set_drvdata (pdev, pwms); +return 0 ; + +err_free_mem: +release_mem_region (r->start,resource_size (r)); +err_free: +kfree (pwms); +return ret; +} + +static int __devexit pwm_remove(struct platform_device *pdev) +{ +struct pwm_device *pwms; +struct resource *r; +int i; + + pwms =platform_get_drvdata (pdev); +if (pwms ==NULL ) +return -ENODEV ; + +mutex_lock (&pwm_lock); + +for (i =0 ; i <VT8500_NR_PWMS ; i++) +list_del (&pwms[i].node); +mutex_unlock (&pwm_lock); + +iounmap (pwms[0 ].regbase); + + r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +release_mem_region (r->start,resource_size (r)); + +kfree (pwms); +return 0 ; +} + +static struct platform_driver pwm_driver = { + .driver = { + .name ="vt8500-pwm" , + .owner =THIS_MODULE , + }, + .probe = pwm_probe, + .remove =__devexit_p (pwm_remove), +}; + +static int __init pwm_init (void ) +{ +return platform_driver_register (&pwm_driver); +} +arch_initcall (pwm_init); + +static void __exit pwm_exit(void) +{ +platform_driver_unregister (&pwm_driver); +} +module_exit (pwm_exit); + +MODULE_LICENSE ("GPL" );arch/arm/mach-vt8500/timer.c new file +42
-0@@ -0,0 +1,154 @@ +/* +* arch/arm/mach-vt8500/timer.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 +*/ + +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/interrupt.h> +#include <linux/clocksource.h> +#include <linux/clockchips.h> + +#include <asm/mach/time.h> + +#include <mach/mmio_regs.h> +#include <mach/irq_defs.h> + +#define VT8500_TIMER_OFFSET 0x0100 +#define TIMER_MATCH_VAL 0x0000 +#define TIMER_COUNT_VAL 0x0010 +#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 VT8500_TIMER_HZ 3000000
arch/arm/mach-vt8500/timer.c line 52
Quoted 10 lines
arch/arm/mach-vt8500/timer.c new file +10
-0+ +static void __iomem *regbase; + +static cycle_t vt8500_timer_read (struct clocksource *cs) +{ +int loops =1000 ; +writel (3 , regbase +TIMER_CTRL_VAL ); +while ((readl ((regbase +TIMER_AS_VAL )) &TIMER_COUNT_R_ACTIVE ) + && --loops) +cpu_relax ();
More loop counting? Surely there is a better solution?
Quoted 142 lines
arch/arm/mach-vt8500/timer.c new file +102
-0+return readl (regbase +TIMER_COUNT_VAL ); +} + +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 =1000 ; +cycle_t alarm = clocksource.read (&clocksource) + cycles; +while ((readl (regbase +TIMER_AS_VAL ) &TIMER_MATCH_W_ACTIVE ) + && --loops) +cpu_relax (); +writel ((unsigned long )alarm, regbase +TIMER_MATCH_VAL ); + +if ((signed )(alarm - clocksource.read (&clocksource)) <=16 ) +return -ETIME ; + +writel (1 , regbase +TIMER_IER_VAL ); + +return 0 ; +} + +static void vt8500_timer_set_mode (enum clock_event_mode mode, +struct clock_event_device *evt) +{ +switch (mode) { +case CLOCK_EVT_MODE_RESUME : +case CLOCK_EVT_MODE_PERIODIC : +break ; +case CLOCK_EVT_MODE_ONESHOT : +case CLOCK_EVT_MODE_UNUSED : +case CLOCK_EVT_MODE_SHUTDOWN : +writel (readl (regbase +TIMER_CTRL_VAL ) |1 , + regbase +TIMER_CTRL_VAL ); +writel (0 , regbase +TIMER_IER_VAL ); +break ; + } +} + +struct clock_event_device clockevent = { + .name ="vt8500_timer" , + .features =CLOCK_EVT_FEAT_ONESHOT , + .rating =200 , + .set_next_event = vt8500_timer_set_next_event, + .set_mode = vt8500_timer_set_mode, +}; + +static irqreturn_t vt8500_timer_interrupt (int irq,void *dev_id) +{ +struct clock_event_device *evt = dev_id; +writel (0xf , regbase +TIMER_STATUS_VAL ); + evt->event_handler (evt); + +return IRQ_HANDLED ; +} + +struct irqaction irq = { + .name ="vt8500_timer" , + .flags =IRQF_DISABLED |IRQF_TIMER |IRQF_IRQPOLL , + .handler = vt8500_timer_interrupt, + .dev_id = &clockevent, +}; + +static void __init vt8500_timer_init (void ) +{ + regbase =ioremap (wmt_current_regs->pmc +VT8500_TIMER_OFFSET ,0x28 ); +if (!regbase) +printk (KERN_ERR "vt8500_timer_init: failed to map MMIO " +"registers\n" ); + +writel (1 , regbase +TIMER_CTRL_VAL ); +writel (0xf , regbase +TIMER_STATUS_VAL ); +writel (~0 , regbase +TIMER_MATCH_VAL ); + +if (clocksource_register_hz (&clocksource,VT8500_TIMER_HZ )) +printk (KERN_ERR "vt8500_timer_init: clocksource_register " +"failed for %s\n" , clocksource.name); + +clockevents_calc_mult_shift (&clockevent,VT8500_TIMER_HZ ,4 ); + +/* copy-pasted from mach-msm; no idea */ + clockevent.max_delta_ns = +clockevent_delta2ns (0xf0000000 , &clockevent); + clockevent.min_delta_ns =clockevent_delta2ns (4 , &clockevent); + clockevent.cpumask =cpumask_of (0 ); + +if (setup_irq (wmt_current_irqs->timer_match0, &irq)) +printk (KERN_ERR "vt8500_timer_init: setup_irq " +"failed for %s\n" , clockevent.name); +clockevents_register_device (&clockevent); +} + +struct sys_timer vt8500_timer = { + .init = vt8500_timer_init +};arch/arm/mach-vt8500/wm8505_7in.c new file +34
-0@@ -0,0 +1,81 @@ +/* +* arch/arm/mach-vt8500/wm8505_7in.c +* +* Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 +*/ + +#include <linux/io.h> +#include <linux/pm.h> + +#include <asm/mach-types.h> +#include <asm/mach/arch.h> + +#include <mach/mmio_regs.h> +#include "devices.h" + +static void __iomem *pmc_hiber; + +static struct platform_device *devices[]__initdata = { + &vt8500_device_uart0, + &vt8500_device_ehci,
arch/arm/mach-vt8500/wm8505_7in.c line 44
Quoted 10 lines
arch/arm/mach-vt8500/wm8505_7in.c new file +10
-0+ &vt8500_device_wm8505_fb, + &vt8500_device_ge_rops, + &vt8500_device_pwm, + &vt8500_device_pwmbl, + &vt8500_device_rtc, +}; + +static void vt8500_power_off (void ) +{ +local_irq_disable ();
Is this necessary?
Quoted 27 lines
arch/arm/mach-vt8500/wm8505_7in.c new file +27
-0+writew (5 , pmc_hiber); + asm("mcr%? p15, 0, %0, c7, c0, 4" : :"r" (0 )); +} + +void __init wm8505_7in_init (void ) +{ +#ifdef CONFIG_FB_WM8505 +void __iomem *gpio_mux_reg =ioremap (wmt_current_regs->gpio + +0x200 ,4 ); +if (gpio_mux_reg) { +writel (readl (gpio_mux_reg) |0x80000000 , gpio_mux_reg); +iounmap (gpio_mux_reg); + }else { +printk (KERN_ERR "Could not remap the GPIO mux register, " +"display may not work properly!\n" ); + } +#endif + pmc_hiber =ioremap (wmt_current_regs->pmc +0x12 ,2 ); +if (pmc_hiber) + pm_power_off = &vt8500_power_off; +else +printk (KERN_ERR "PMC Hibernation register could not be " +"remapped, not enabling power off!\n" ); + +wmt_set_resources (); +platform_add_devices (devices,ARRAY_SIZE (devices)); +vt8500_gpio_init ();
arch/arm/mach-vt8500/wm8505_7in.c line 81
Quoted 10 lines
arch/arm/mach-vt8500/wm8505_7in.c new file +10
-0+} + +MACHINE_START (WM8505_7IN_NETBOOK ,"WM8505 7-inch generic netbook" ) + .boot_params = 0x00000100, + .reserve = wm8505_reserve_mem, + .map_io = wm8505_map_io, + .init_irq = wm8505_init_irq, + .timer = &vt8500_timer, + .init_machine = wm8505_7in_init, +MACHINE_END
~Ryan
Signature · 7 lines
Bluewater Systems Ltd - ARM Technology Solution Centre Ryan Mallon 5 Amuri Park, 404 Barbadoes St [email protected] PO Box 13 889, Christchurch 8013 http://www.bluewatersys.com New Zealand Phone: +64 3 3779127 Freecall: Australia 1800 148 751 Fax: +64 3 3779135 USA 1800 261 2934
Alexey Charkov
maintainer2010/12/20 Ryan Mallon <[email protected]>:
Quoted 22 lines · Alexey Charkov
Quoted 7 lines
This adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505, selectable by a configuration switch at kernel build time.
Quoted 7 lines
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
Signed-off-by Alexey Charkov <[email protected]>Hi Alexey,
Quick review below.
~Ryan
<snip>
Quoted 12 lines
arch/arm/mach-vt8500/devices.c
Quoted 8 lines
arch/arm/mach-vt8500/devices.c new file +8
-0+static int __init panel_setup (char *str) +{ + ? ? int i; + + ? ? for (i = 0; i < ARRAY_SIZE(panels); i++) { + ? ? ? ? ? ? int len = strlen(panels[i].mode.name); + + ? ? ? ? ? ? if (memcmp(panels[i].mode.name, str, len) == 0) {Should be strcmp. If the length of str is less than panels[i].mode.name then you will buffer overrun.
Ok, will change this.
Quoted 22 lines
Quoted 22 lines
+ ? ? ? ? ? ? ? ? ? ?
current_panel_idx= i;
+ ? ? ? ? ? ? ? ? ? ? break;
+ ? ? ? ? ? ? }
+ ? ? }
+ ? ? return 0;(quoted diff) +17
-0+} + +early_param("panel", panel_setup); + +static inline void preallocate_fb(struct vt8500fb_platform_data *p, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned long align) { + ? ? p->video_mem_len = (p->xres_virtual * p->yres_virtual * 4) >> + ? ? ? ? ? ? ? ? ? ? (p->bpp > 16 ? 0 : (p->bpp > 8 ? 1 : + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (8 / p->bpp) + 1)); + ? ? p->video_mem_phys = (unsigned long)memblock_alloc(p->video_mem_len, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? align); + ? ? p->video_mem_virt = phys_to_virt(p->video_mem_phys); +} + +static struct resource resources_uart0[] = { + ? ? [0] = { + ? ? ? ? ? ? .flags ?= IORESOURCE_MEM,
Quoted 9 lines
Quoted 5 lines
+ ? ? },
+ ? ? [1] = {
+ ? ? ? ? ? ? .flags ?=IORESOURCE_IRQ,
+ ? ? },
+};What's happening here? Does something else fill these in? If so, there should be a comment to that effect.
Ok, will add a comment.
<snip>
Quoted 12 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+void __init wmt_set_resources(void) +{ + ? ? resources_lcdc[0].start = wmt_current_regs->lcdc; + ? ? resources_lcdc[0].end = wmt_current_regs->lcdc + SZ_1K - 1; + ? ? resources_lcdc[1].start = wmt_current_irqs->lcdc; + ? ? resources_lcdc[1].end = wmt_current_irqs->lcdc;Ah, this makes more sense. But why have all the indirection? The
wmt_regmapstable could just be replaced with #defines and then have separate device files for the VT8500 and the WM8505. This would also make clearer which variants have which peripherals.
This was the way I implemented it originally. However, Arnd made quite a valid suggestion to allow runtime selection of the chip variant, thus registers and interrupts need to be held in an indexed data type instead of just compile-time macros. In addition, there is now some overall movement towards unification of binary kernel images for different ARM variants (as far as I can see), so this would be required in any case.
Furthermore, as with many unbranded Chinese products, it's somewhat difficult to reliably determine the exact chip version used in your netbook without disassembling it. Reading a hardware register for identification is easier :)
Quoted 27 lines
Quoted 27 lines
+ ? ? resources_wm8505_fb[0].start =
wmt_current_regs->govr;
+ ? ? resources_wm8505_fb[0].end =wmt_current_regs->govr+ 512 - 1; +
+ ? ? resources_uart0[0].start =wmt_current_regs->uart0;
+ ? ? resources_uart0[0].end =wmt_current_regs->uart0+0x103f;
+ ? ? resources_uart0[1].start =wmt_current_irqs->uart0;
+ ? ? resources_uart0[1].end =wmt_current_irqs->uart0;
+ ? ? resources_uart1[0].start =wmt_current_regs->uart1;
+ ? ? resources_uart1[0].end =wmt_current_regs->uart1+0x103f;
+ ? ? resources_uart1[1].start =wmt_current_irqs->uart1;
+ ? ? resources_uart1[1].end =wmt_current_irqs->uart1;
+ ? ? resources_uart2[0].start =wmt_current_regs->uart2;
+ ? ? resources_uart2[0].end =wmt_current_regs->uart2+0x103f;
+ ? ? resources_uart2[1].start =wmt_current_irqs->uart2;
+ ? ? resources_uart2[1].end =wmt_current_irqs->uart2;
+ ? ? resources_uart3[0].start =wmt_current_regs->uart3;
+ ? ? resources_uart3[0].end =wmt_current_regs->uart3+0x103f;
+ ? ? resources_uart3[1].start =wmt_current_irqs->uart3;
+ ? ? resources_uart3[1].end =wmt_current_irqs->uart3;
+ ? ? resources_uart4[0].start =wmt_current_regs->uart4;
+ ? ? resources_uart4[0].end =wmt_current_regs->uart4+0x103f;
+ ? ? resources_uart4[1].start =wmt_current_irqs->uart4;
+ ? ? resources_uart4[1].end =wmt_current_irqs->uart4;
+ ? ? resources_uart5[0].start =wmt_current_regs->uart5;
+ ? ? resources_uart5[0].end =wmt_current_regs->uart5+0x103f;
+ ? ? resources_uart5[1].start =wmt_current_irqs->uart5;
+ ? ? resources_uart5[1].end =wmt_current_irqs->uart5;
Quoted 9 lines
Quoted 5 lines
+
+ ? ? resources_ehci[0].start =wmt_current_regs->ehci;
+ ? ? resources_ehci[0].end =wmt_current_regs->ehci+ 512 - 1;
+ ? ? resources_ehci[1].start =wmt_current_irqs->ehci;
+ ? ? resources_ehci[1].end =wmt_current_irqs->ehci;There is a mix of hex and decimal constants here and exact sizes and sizes with 1 subtracted. Please be consistent.
Ok, will convert to hex with exact sizes.
Quoted 34 lines
Quoted 34 lines
+ ? ? resources_ge_rops[0].start =
wmt_current_regs->ge;
+ ? ? resources_ge_rops[0].end =wmt_current_regs->ge+0xff;(quoted diff) +32
-0+ + ? ? resources_pwm[0].start = wmt_current_regs->pwm; + ? ? resources_pwm[0].end = wmt_current_regs->pwm + 0x43; + + ? ? resources_rtc[0].start = wmt_current_regs->rtc; + ? ? resources_rtc[0].end = wmt_current_regs->rtc + 0x2c - 1; + ? ? resources_rtc[1].start = wmt_current_irqs->rtc; + ? ? resources_rtc[1].end = wmt_current_irqs->rtc; + ? ? resources_rtc[2].start = wmt_current_irqs->rtc_hz; + ? ? resources_rtc[2].end = wmt_current_irqs->rtc_hz; +} + +void __init vt8500_map_io(void) +{ + ? ? wmt_current_regs = &wmt_regmaps[VT8500_INDEX]; + ? ? wmt_current_irqs = &wmt_irqs[VT8500_INDEX]; + + ? ? vt8500_io_desc[0].virtual = wmt_current_regs->mmio_regs_virt; + ? ? vt8500_io_desc[0].pfn = + ? ? ? ? ? ? ? ? ? ? __phys_to_pfn(wmt_current_regs->mmio_regs_start); + ? ? vt8500_io_desc[0].length = wmt_current_regs->mmio_regs_length; + + ? ? iotable_init(vt8500_io_desc, ARRAY_SIZE(vt8500_io_desc)); +} + +void __init wm8505_map_io(void) +{ + ? ? wmt_current_regs = &wmt_regmaps[WM8505_INDEX]; + ? ? wmt_current_irqs = &wmt_irqs[WM8505_INDEX]; + + ? ? vt8500_io_desc[0].virtual = wmt_current_regs->mmio_regs_virt; + ? ? vt8500_io_desc[0].pfn =
Quoted 9 lines
arch/arm/mach-vt8500/bv07.c line 48
Quoted 5 lines
+ ? ? ? ? ? ? ? ? ? ?
__phys_to_pfn(wmt_current_regs->mmio_regs_start);
+ ? ? vt8500_io_desc[0].length =wmt_current_regs->mmio_regs_length;arch/arm/mach-vt8500/bv07.c new file +3
-0+ + ? ? iotable_init(vt8500_io_desc, ARRAY_SIZE(vt8500_io_desc)); +}Separate files. If more variants get added, this file will become unwieldy very quickly.
Is it really worthwhile to create separate files for single 12-line functions? After all, WonderMedia does not release new chips every now and then :)
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-vt8500/devices.c new file +6
-0+ +void __init vt8500_reserve_mem (void ) +{ +#ifdef CONFIG_FB_VT8500 + ? ? panels[current_panel_idx].bpp = 16; /* Always use RGB565 */ + ? ? preallocate_fb(&panels[current_panel_idx], SZ_4M);
Quoted 9 lines
Review
Quoted 3 lines
+ ? ? vt8500_device_lcdc.dev.platform_data = &panels[current_panel_idx];
(quoted diff) +2
-0+#endif +}Not sure if this should exist in the platform code or the framebuffer driver. In the latter case it would automatically be
CONFIG_FB_VT8500and theplatform_datacan still be set in the platform code. Is there a reason for this not to be in the framebuffer driver?
I can't reserve memory via memblock from the driver, and usual runtime allocation functions can't handle it (need alignment to 4 megabytes in 8500, framebuffer sizes exceed 4 megabytes in 8505).
<snip>
Quoted 11 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+static int vt8500_muxed_gpio_request(struct gpio_chip *chip, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned offset) +{ + ? ? struct vt8500_gpio_chip *vt8500_chip = to_vt8500(chip); + + ? ? writel(readl(regbase + vt8500_chip->regoff) | + ? ? ? ? ? ? (1 << vt8500_chip->shift << offset), + ? ? ? ? ? ? regbase + vt8500_chip->regoff);This would be more readable as:
Quoted 9 lines
? ? ? ?unsigned val;
? ? ? ?val ?=
readl(regbase + vt8500_chop->regoff); ? ? ? ?val |= 1 <<vt8500_chop->shift<< offset; ? ? ? ?writel(val, regbase +vt8500_chip->regoff);It's much clearer what is actually being done. Same goes for other functions in this file.
Ok.
<snip>
Quoted 10 lines
Quoted 7 lines
+static struct
vt8500_gpio_chipvt8500_muxed_gpios[] = {
+ ? ?VT8500_GPIO_BANK("uart0", 0, 0x0, 8, 4),
+ ? ?VT8500_GPIO_BANK("uart1", 4, 0x0, 12, 4),
+ ? ?VT8500_GPIO_BANK("spi0", 8, 0x0, 16, 4),
+ ? ?VT8500_GPIO_BANK("spi1", 12, 0x0, 20, 4),
+ ? ?VT8500_GPIO_BANK("spi2", 16, 0x0, 24, 4),
+ ? ?VT8500_GPIO_BANK("pwmout", 24, 0x0, 28, 2),Nitpick: Line up the columns to make these mpore readable.
That's true, will use tabs instead.
<snip>
Quoted 25 lines
Quoted 25 lines
arch/arm/mach-vt8500/include/mach/io.h new file +19
-0@@ -0,0 +1,28 @@ +/* +* ?arch/arm/mach-vt8500/include/mach/io.h +* +* ?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 +*/
Quoted 9 lines
arch/arm/mach-vt8500/include/mach/io.h
Quoted 6 lines
arch/arm/mach-vt8500/include/mach/io.h new file +6
-0+#ifndef __ASM_ARM_ARCH_IO_H +#define __ASM_ARM_ARCH_IO_H + +#define IO_SPACE_LIMIT 0xffff + +#define __io (a) ? ? ? ? ? ? ?((void __iomem *)((a) + 0xf0000000))Should use
__typesafe_io.
Ok.
<snip>
Quoted 26 lines
Quoted 26 lines
arch/arm/mach-vt8500/include/mach/memory.h new file +20
-0@@ -0,0 +1,28 @@ +/* +* ?arch/arm/mach-vt8500/include/mach/memory.h +* +* ?Copyright (C) 2003 ARM Limited +* +* 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 __ASM_ARCH_MEMORY_H
Quoted 9 lines
arch/arm/mach-vt8500/include/mach/memory.h
Quoted 6 lines
arch/arm/mach-vt8500/include/mach/memory.h new file +6
-0+#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET ?UL(0x00000000)If you renamed this to
PHYS_DRAM_OFFSETyou wouldn't need the comment :-).
I'm not the one who chooses :)
<snip>
Quoted 25 lines
Quoted 25 lines
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +19
-0@@ -0,0 +1,31 @@ +/* +* ?VT8500/WM8505 Frame Buffer platform data definitions +* +* ?Copyright (C) 2010 Ed Spiridonov <[email protected]> +* +* 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>
Quoted 9 lines
arch/arm/mach-vt8500/include/mach/vt8500fb.h line 25
Quoted 6 lines
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +6
-0+ +struct vt8500fb_platform_data { + ? ? struct fb_videomode ? ? mode; + ? ? __u32 ? ? ? ? ? ? ? ? ? xres_virtual; + ? ? __u32 ? ? ? ? ? ? ? ? ? yres_virtual; + ? ? __u32 ? ? ? ? ? ? ? ? ? bpp;Is this struct exported to user space? If not, use u32 rather than
__u32.
No it's not, will change.
Quoted 50 lines
Quoted 50 lines
arch/arm/mach-vt8500/include/mach/vt8500fb.h new file +6
-0+ ? ? unsigned long ? ? ? ? ? video_mem_phys; + ? ? void ? ? ? ? ? ? ? ? ? ?*video_mem_virt; + ? ? unsigned long ? ? ? ? ? video_mem_len; +}; + +#endif /* _VT8500FB_H */ arch/arm/mach-vt8500/irq.c new file +38
-0@@ -0,0 +1,179 @@ +/* +* ?arch/arm/mach-vt8500/irq.c +* +* ?Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 +*/ + +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/interrupt.h> + +#include <asm/irq.h> + +#include <mach/mmio_regs.h> +#include <mach/irq_defs.h> + +#define VT8500_IC_DCTR ? ? ? ? ? ? ? 0x40 ? ? ? ? ? ?/* Destination control +? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? register, 64*u8 */ +#define VT8500_INT_ENABLE ? ?(1 << 3) +#define VT8500_TRIGGER_HIGH ?(0 << 4) +#define VT8500_TRIGGER_RISING ? ? ? ?(1 << 4) +#define VT8500_TRIGGER_FALLING ? ? ? (2 << 4) +#define VT8500_IC_STATUS ? ? 0x80 ? ? ? ? ? ?/* Interrupt status, 2*u32 */ + +static void __iomem *ic_regbase;
Quoted 9 lines
arch/arm/mach-vt8500/irq.c
Quoted 6 lines
arch/arm/mach-vt8500/irq.c new file +6
-0+static void __iomem *sic_regbase; + +static void vt8500_irq_mask (unsigned int irq) +{ + ? ? void __iomem *base = ic_regbase; + ? ? u8 edge;Nitpick: blank line between variable declarations and code.
Ok.
Quoted 8 lines
arch/arm/mach-vt8500/irq.c line 49
Quoted 5 lines
arch/arm/mach-vt8500/irq.c new file +5
-0+ ? ? if (irq >= 64) { + ? ? ? ? ? ? base = sic_regbase; + ? ? ? ? ? ? irq -= 64; + ? ? } + ? ? edge = readb(base + VT8500_IC_DCTR + irq) & (3 << 4);What is (3 << 4)? Replace with a #define.
Quoted 8 lines
arch/arm/mach-vt8500/irq.c line 54
Quoted 5 lines
arch/arm/mach-vt8500/irq.c new file +5
-0+ ? ? if (edge) + ? ? ? ? ? ? writel(readl(base + ? ? ? ? ? ? ? ? ? ? + VT8500_IC_STATUS + (irq < 32 ? 0 : 4)) + ? ? ? ? ? ? ? ? ? ? | (1 << (irq & 0x1f)), base + ? ? ? ? ? ? ? ? ? ? + VT8500_IC_STATUS + (irq & 0x20 ? 4 : 0));More unexplained magic numbers.
Ok, will add macros.
Quoted 16 lines
Quoted 16 lines
arch/arm/mach-vt8500/irq.c new file +16
-0+ ? ? else + ? ? ? ? ? ? writeb(readb(base + ? ? ? ? ? ? ? ? ? ? + VT8500_IC_DCTR + irq) & ~VT8500_INT_ENABLE, + ? ? ? ? ? ? ? ? ? ? base + VT8500_IC_DCTR + irq); +} + +static void vt8500_irq_unmask (unsigned int irq) +{ + ? ? void __iomem *base = ic_regbase; + ? ? if (irq >= 64) { + ? ? ? ? ? ? base = sic_regbase; + ? ? ? ? ? ? irq -= 64; + ? ? } + ? ? writeb(readb(base + ? ? ? ? ? ? + VT8500_IC_DCTR + irq) | VT8500_INT_ENABLE, + ? ? ? ? ? ? base + VT8500_IC_DCTR + irq);
Quoted 9 lines
arch/arm/mach-vt8500/irq.c line 76
Quoted 6 lines
arch/arm/mach-vt8500/irq.c new file +6
-0+} + +static int vt8500_irq_set_wake (unsigned int irq,unsigned int on) +{ + ? ? return -EINVAL; +}You don't have to provide this function.
In fact, there is some wakeup functionality, but it's not yet implemented. I could re-add the functions when some useful code appears, though.
Quoted 37 lines
Quoted 37 lines
arch/arm/mach-vt8500/irq.c new file +37
-0+static int vt8500_irq_set_type (unsigned int irq,unsigned int flow_type) +{ + ? ? void __iomem *base = ic_regbase; + ? ? unsigned int orig_irq = irq; + ? ? if (irq >= 64) { + ? ? ? ? ? ? base = sic_regbase; + ? ? ? ? ? ? irq -= 64; + ? ? } + ? ? switch (flow_type) { + ? ? case IRQF_TRIGGER_LOW: + ? ? ? ? ? ? return -EINVAL; + ? ? case IRQF_TRIGGER_HIGH: + ? ? ? ? ? ? writeb((readb(base + ? ? ? ? ? ? ? ? ? ? + VT8500_IC_DCTR + irq) & ~(3 << 4)) + ? ? ? ? ? ? ? ? ? ? | VT8500_TRIGGER_HIGH, base + ? ? ? ? ? ? ? ? ? ? + VT8500_IC_DCTR + irq); + ? ? ? ? ? ? irq_desc[orig_irq].handle_irq = handle_level_irq; + ? ? ? ? ? ? break; + ? ? case IRQF_TRIGGER_FALLING: + ? ? ? ? ? ? writeb((readb(base + ? ? ? ? ? ? ? ? ? ? + VT8500_IC_DCTR + irq) & ~(3 << 4)) + ? ? ? ? ? ? ? ? ? ? | VT8500_TRIGGER_FALLING, base + ? ? ? ? ? ? ? ? ? ? + VT8500_IC_DCTR + irq); + ? ? ? ? ? ? irq_desc[orig_irq].handle_irq = handle_edge_irq; + ? ? ? ? ? ? break; + ? ? case IRQF_TRIGGER_RISING: + ? ? ? ? ? ? writeb((readb(base + ? ? ? ? ? ? ? ? ? ? + VT8500_IC_DCTR + irq) & ~(3 << 4)) + ? ? ? ? ? ? ? ? ? ? | VT8500_TRIGGER_RISING, base + ? ? ? ? ? ? ? ? ? ? + VT8500_IC_DCTR + irq); + ? ? ? ? ? ? irq_desc[orig_irq].handle_irq = handle_edge_irq; + ? ? ? ? ? ? break; + ? ? } + + ? ? return 0; +} +
Quoted 9 lines
arch/arm/mach-vt8500/irq.c line 119
Quoted 6 lines
arch/arm/mach-vt8500/irq.c new file +6
-0+static struct irq_chip vt8500_irq_chip = { + ? ? .name ? ? ?= "vt8500", + ? ? .ack ? ? ? = vt8500_irq_mask, + ? ? .mask ? ? ?= vt8500_irq_mask, + ? ? .unmask ? ?= vt8500_irq_unmask, + ? ? .set_wake ?= vt8500_irq_set_wake,Remove .set_wake.
Ok.
Quoted 20 lines
Quoted 20 lines
arch/arm/mach-vt8500/irq.c new file +20
-0+ ? ? .set_type ?= vt8500_irq_set_type, +}; + +void __init vt8500_init_irq (void ) +{ + ? ? unsigned int i; + + ? ? ic_regbase = ioremap(wmt_current_regs->ic0, SZ_64K); + + ? ? if (ic_regbase) { + ? ? ? ? ? ? /* Enable rotating priority for IRQ */ + ? ? ? ? ? ? writel((1 << 6), ic_regbase + 0x20); + ? ? ? ? ? ? writel(0, ic_regbase + 0x24); + + ? ? ? ? ? ? for (i = 0; i < wmt_current_irqs->nr_irqs; i++) { + ? ? ? ? ? ? ? ? ? ? /* Disable all interrupts and route them to IRQ */ + ? ? ? ? ? ? ? ? ? ? writeb(0x00, ic_regbase + VT8500_IC_DCTR + i); + + ? ? ? ? ? ? ? ? ? ? set_irq_chip(i, &vt8500_irq_chip); + ? ? ? ? ? ? ? ? ? ? set_irq_handler(i, handle_level_irq);
Quoted 9 lines
arch/arm/mach-vt8500/irq.c line 144
Quoted 5 lines
arch/arm/mach-vt8500/irq.c new file +5
-0+ ? ? ? ? ? ? ? ? ? ? set_irq_flags(i, IRQF_VALID); + ? ? ? ? ? ? } + ? ? } else { + ? ? ? ? ? ? printk(KERN_ERR "Unable to remap the Interrupt Controller " + ? ? ? ? ? ? ? ? ? ? ? ? ? ? "registers, not enabling IRQs!\n");printk strings should be on a single line (can be > 80 columns) to make grepping easier. You could also use the
pr_macros withpr_fmtset.
Well, checkpatch.pl complained about that in the first place, so I split the line. Should I merge them back in all instances?
<snip>
Quoted 9 lines
arch/arm/mach-vt8500/pwm.c
Quoted 5 lines
arch/arm/mach-vt8500/pwm.c new file +0
-0I'm not sure what the state of the various efforts to provide a common pwm framework are, but you may want to check.
I did before starting to write this code, found nothing.
Quoted 41 lines
Quoted 41 lines
arch/arm/mach-vt8500/pwm.c new file +40
-0@@ -0,0 +1,254 @@ +/* +* arch/arm/mach-vt8500/pwm.c +* +* ?Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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/kernel.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/pwm.h> + +#include <asm/div64.h> + +#define VT8500_NR_PWMS 4 + +struct pwm_device { + ? ? struct list_head ? ? ? ?node; + ? ? struct platform_device ?*pdev; + + ? ? const char ? ? ?*label; + + ? ? void __iomem ? ?*regbase; + + ? ? unsigned int ? ?use_count; + ? ? unsigned int ? ?pwm_id; +}; + +static inline void pwm_busy_wait (void __iomem *reg,u8 bitmask)
Quoted 9 lines
arch/arm/mach-vt8500/pwm.c line 44
Quoted 4 lines
arch/arm/mach-vt8500/pwm.c new file +4
-0+{ + ? ? int loops = 1000; + ? ? while ((readb(reg) & bitmask) && --loops) + ? ? ? ? ? ? cpu_relax();Ugh. If you are going to busy wait, can't you delay for a known amount of time? Even better, can this be replaced with
wait_eventor some equivalent?
The delay should be on the order of several bus cycles, where udelay actually busy-waits, too. wait_event would be longer than that to set up, and there is no associated interrupt.
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-vt8500/pwm.c new file +8
-0+} + +int pwm_config (struct pwm_device *pwm,int duty_ns,int period_ns) +{ + ? ? unsigned long long c; + ? ? unsigned long period_cycles, prescale, pv, dc; + + ? ? if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
Quoted 9 lines
arch/arm/mach-vt8500/pwm.c line 58
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+ ? ? ? ? ? ? return -EINVAL; + + ? ? c = 25000000/2; /* wild guess --- need to implement clocks */ + ? ? c = c * period_ns; + ? ? do_div(c, 1000000000); + ? ? period_cycles = c;This looks like it could be reworked to remove the
do_divcall.
I just followed PXA implementation in this regard. Are there any specific suggestions? Note that c should not be a complie-time constant eventually, as this is the guessed PWM base frequency (should be read from the hardware, but the code for clocks is not yet in).
Quoted 37 lines
Quoted 37 lines
arch/arm/mach-vt8500/pwm.c new file +37
-0+ + ? ? if (period_cycles < 1) + ? ? ? ? ? ? period_cycles = 1; + ? ? prescale = (period_cycles - 1) / 4096; + ? ? pv = period_cycles / (prescale + 1) - 1; + ? ? if (pv > 4095) + ? ? ? ? ? ? pv = 4095; + + ? ? if (prescale > 1023) + ? ? ? ? ? ? return -EINVAL; + + ? ? dc = pv * duty_ns / period_ns; + + ? ? pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 1)); + ? ? writel(prescale, pwm->regbase + 0x4 + (pwm->pwm_id << 4)); + + ? ? pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 2)); + ? ? writel(pv, pwm->regbase + 0x8 + (pwm->pwm_id << 4)); + + ? ? pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 3)); + ? ? writel(dc, pwm->regbase + 0xc + (pwm->pwm_id << 4)); + + ? ? return 0; +} +EXPORT_SYMBOL (pwm_config); + +int pwm_enable (struct pwm_device *pwm) +{ + ? ? pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 0)); + ? ? writel(5, pwm->regbase + (pwm->pwm_id << 4)); + ? ? return 0; +} +EXPORT_SYMBOL (pwm_enable); + +void pwm_disable (struct pwm_device *pwm) +{ + ? ? pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 0));
Quoted 9 lines
arch/arm/mach-vt8500/pwm.c line 101
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+ ? ? writel(0, pwm->regbase + (pwm->pwm_id << 4)); +} +EXPORT_SYMBOL (pwm_disable); + +static DEFINE_MUTEX (pwm_lock); +static LIST_HEAD (pwm_list);These should be at the top of the file.
Ok.
Quoted 40 lines
Quoted 16 lines
arch/arm/mach-vt8500/pwm.c new file +16
-0+struct pwm_device *pwm_request (int pwm_id,const char *label) +{ + ? ? struct pwm_device *pwm; + ? ? int found = 0; + + ? ? mutex_lock(&pwm_lock); + + ? ? list_for_each_entry(pwm, &pwm_list, node) { + ? ? ? ? ? ? if (pwm->pwm_id == pwm_id) { + ? ? ? ? ? ? ? ? ? ? found = 1; + ? ? ? ? ? ? ? ? ? ? break; + ? ? ? ? ? ? } + ? ? } + + ? ? if (found) { + ? ? ? ? ? ? if (pwm->use_count == 0) {arch/arm/mach-vt8500/pwm.c line 127
Quoted 10 lines
arch/arm/mach-vt8500/pwm.c new file +10
-0+ ? ? ? ? ? ? ? ? ? ? pwm->use_count++; + ? ? ? ? ? ? ? ? ? ? pwm->label = label; + ? ? ? ? ? ? } else + ? ? ? ? ? ? ? ? ? ? pwm = ERR_PTR(-EBUSY); + ? ? } else + ? ? ? ? ? ? pwm = ERR_PTR(-ENOENT); + + ? ? mutex_unlock(&pwm_lock); + ? ? return pwm; +}Maybe a bit clearer and more concise like this? Also replaces
-ENOENT(No such file or directory) with-ENODEV(No such device):? ? ? ?pwm =
ERR_PTR(-ENODEV);
? ? ? ?mutex_lock(&pwm_lock);? ? ? ?list_for_each_entry(pwm,
&pwm_list, node) { ? ? ? ? ? ? ? ?if (pwm->pwm_id==pwm_id) {
? ? ? ? ? ? ? ? ? ? ? ?if (pwm->use_count!= 0) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?pwm =ERR_PTR(-EBUSY); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ? ? ? ? ?}
Quoted 9 lines
? ? ? ? ? ? ? ? ? ? ? ?pwm->use_count++;
? ? ? ? ? ? ? ? ? ? ? ?pwm->label = label;
? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ?}
? ? ? ?}? ? ? ?mutex_unlock(&pwm_lock);
? ? ? ?return pwm;
Isn't pwm overwritten inside the loop? -ENODEV will then be lost with this layout.
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+EXPORT_SYMBOL (pwm_request); + +void pwm_free (struct pwm_device *pwm) +{ + ? ? mutex_lock(&pwm_lock); +
Quoted 9 lines
arch/arm/mach-vt8500/pwm.c line 139
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+ ? ? if (pwm->use_count) { + ? ? ? ? ? ? pwm->use_count--; + ? ? ? ? ? ? pwm->label = NULL; + ? ? } else + ? ? ? ? ? ? pr_warning("PWM device already freed\n"); +Nitpick: Single line else should have braces if the if has braces
Ok.
Quoted 17 lines
Quoted 17 lines
arch/arm/mach-vt8500/pwm.c new file +17
-0+ ? ? mutex_unlock(&pwm_lock); +} +EXPORT_SYMBOL (pwm_free); + +static inline void __add_pwm (struct pwm_device *pwm) +{ + ? ? mutex_lock(&pwm_lock); + ? ? list_add_tail(&pwm->node, &pwm_list); + ? ? mutex_unlock(&pwm_lock); +} + +static int __devinit pwm_probe (struct platform_device *pdev) +{ + ? ? struct pwm_device *pwms; + ? ? struct resource *r; + ? ? int ret = 0; + ? ? int i;
Quoted 9 lines
arch/arm/mach-vt8500/pwm.c line 162
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+ + ? ? pwms = kzalloc(sizeof(struct pwm_device) * VT8500_NR_PWMS, GFP_KERNEL); + ? ? if (pwms == NULL) { + ? ? ? ? ? ? dev_err(&pdev->dev, "failed to allocate memory\n"); + ? ? ? ? ? ? return -ENOMEM; + ? ? }Devices should ideally be a single entity, so one platform device per pwm.
We have 4 pwm outputs that share status registers, so they are not really separable.
<snip>
Quoted 52 lines
Quoted 52 lines
arch/arm/mach-vt8500/timer.c new file +46
-0@@ -0,0 +1,154 @@ +/* +* ?arch/arm/mach-vt8500/timer.c +* +* ?Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 +*/ + +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/interrupt.h> +#include <linux/clocksource.h> +#include <linux/clockchips.h> + +#include <asm/mach/time.h> + +#include <mach/mmio_regs.h> +#include <mach/irq_defs.h> + +#define VT8500_TIMER_OFFSET ?0x0100 +#define TIMER_MATCH_VAL ? ? ? ? ? ? ?0x0000 +#define TIMER_COUNT_VAL ? ? ? ? ? ? ?0x0010 +#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 VT8500_TIMER_HZ ? ? ? ? ? ? ?3000000 + +static void __iomem *regbase; + +static cycle_t vt8500_timer_read (struct clocksource *cs)
Quoted 9 lines
arch/arm/mach-vt8500/timer.c line 52
Quoted 6 lines
arch/arm/mach-vt8500/timer.c new file +6
-0+{ + ? ? int loops = 1000; + ? ? writel(3, regbase + TIMER_CTRL_VAL); + ? ? while ((readl((regbase + TIMER_AS_VAL)) & TIMER_COUNT_R_ACTIVE) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? && --loops) + ? ? ? ? ? ? cpu_relax();More loop counting? Surely there is a better solution?
None that I could come up with. Again, the delay should be on the order of several bus cycles.
<snip>
Quoted 44 lines
Quoted 44 lines
arch/arm/mach-vt8500/wm8505_7in.c new file +38
-0@@ -0,0 +1,81 @@ +/* +* ?arch/arm/mach-vt8500/wm8505_7in.c +* +* ?Copyright (C) 2010 Alexey Charkov <[email protected]> +* +* 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 +*/ + +#include <linux/io.h> +#include <linux/pm.h> + +#include <asm/mach-types.h> +#include <asm/mach/arch.h> + +#include <mach/mmio_regs.h> +#include "devices.h" + +static void __iomem *pmc_hiber; + +static struct platform_device *devices[]__initdata = { + ? ? &vt8500_device_uart0, + ? ? &vt8500_device_ehci, + ? ? &vt8500_device_wm8505_fb, + ? ? &vt8500_device_ge_rops, + ? ? &vt8500_device_pwm, + ? ? &vt8500_device_pwmbl,
Quoted 9 lines
arch/arm/mach-vt8500/wm8505_7in.c line 44
Quoted 6 lines
arch/arm/mach-vt8500/wm8505_7in.c new file +6
-0+ ? ? &vt8500_device_rtc, +}; + +static void vt8500_power_off (void ) +{ + ? ? local_irq_disable();Is this necessary?
Vendor's code disables interrupts. I believe my device refused to actually switch off without this.
Thanks for the comments, Ryan!
Best regards,
Alexey
Quoted 43 lines · Alexey Charkov
2010/12/20 Ryan Mallon <[email protected]>:
Quoted 19 lines · Alexey Charkov
Quoted 7 lines
This adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505, selectable by a configuration switch at kernel build time.
Quoted 7 lines
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
Signed-off-by Alexey Charkov <[email protected]>Hi Alexey,
Quick review below.
<snip>
Quoted 12 lines
arch/arm/mach-vt8500/devices.c line 369
Quoted 6 lines
arch/arm/mach-vt8500/devices.c new file +6
-0+void __init wmt_set_resources (void ) +{ + resources_lcdc[0 ].start = wmt_current_regs->lcdc; + resources_lcdc[0 ].end = wmt_current_regs->lcdc +SZ_1K -1 ; + resources_lcdc[1 ].start = wmt_current_irqs->lcdc; + resources_lcdc[1 ].end = wmt_current_irqs->lcdc;Ah, this makes more sense. But why have all the indirection? The
wmt_regmapstable could just be replaced with #defines and then have separate device files for the VT8500 and the WM8505. This would also make clearer which variants have which peripherals.This was the way I implemented it originally. However, Arnd made quite a valid suggestion to allow runtime selection of the chip variant, thus registers and interrupts need to be held in an indexed data type instead of just compile-time macros. In addition, there is now some overall movement towards unification of binary kernel images for different ARM variants (as far as I can see), so this would be required in any case.
Quoted 4 lines
Furthermore, as with many unbranded Chinese products, it's somewhat difficult to reliably determine the exact chip version used in your netbook without disassembling it. Reading a hardware register for identification is easier :)
Okay, that makes sense. I still think there must be a better way than having a massive indirect table with all the values. Why not detect the variant in the core code and then have something like:
int init_devices(void)
{
int board_type = detect_board_type();
switch (board_type) {
case BOARD_TYPE_VT8500:
return vt8500_init_devices();
case BOARD_TYPE_WM8505:
return wm8500_init_devices();
}
pr_err("Unknown board type\n");
BUG(); /* panic()? */
while (1)
;
}Then you can have the peripheral setup for each of the variants in their own files and use #defines. It may get tricky in a couple of places if you need to be able to access some value directly which is different on each of the variants, but that can be handled on a case by case basis. The majority of the numbers will be passed into drivers via the resource structs.
Quoted 31 lines
Quoted 21 lines
Quoted 21 lines
arch/arm/mach-vt8500/devices.c new file +21
-0+ +void __init vt8500_map_io (void ) +{ + wmt_current_regs = &wmt_regmaps[VT8500_INDEX ]; + wmt_current_irqs = &wmt_irqs[VT8500_INDEX ]; + + vt8500_io_desc[0 ].virtual = wmt_current_regs->mmio_regs_virt; + vt8500_io_desc[0 ].pfn = +__phys_to_pfn (wmt_current_regs->mmio_regs_start); + vt8500_io_desc[0 ].length = wmt_current_regs->mmio_regs_length; + +iotable_init (vt8500_io_desc,ARRAY_SIZE (vt8500_io_desc)); +} + +void __init wm8505_map_io (void ) +{ + wmt_current_regs = &wmt_regmaps[WM8505_INDEX ]; + wmt_current_irqs = &wmt_irqs[WM8505_INDEX ]; + + vt8500_io_desc[0 ].virtual = wmt_current_regs->mmio_regs_virt; + vt8500_io_desc[0].pfn =Quoted 9 lines
arch/arm/mach-vt8500/devices.c line 429
Quoted 5 lines
arch/arm/mach-vt8500/devices.c new file +5
-0+__phys_to_pfn (wmt_current_regs->mmio_regs_start); + vt8500_io_desc[0 ].length = wmt_current_regs->mmio_regs_length; + +iotable_init (vt8500_io_desc,ARRAY_SIZE (vt8500_io_desc)); +}Separate files. If more variants get added, this file will become unwieldy very quickly.
Quoted 3 lines
Is it really worthwhile to create separate files for single 12-line functions? After all, WonderMedia does not release new chips every now and then :)
I meant if you have the full peripheral initialisation for each variant in its own file.
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-vt8500/devices.c new file +6
-0+ +void __init vt8500_reserve_mem (void ) +{ +#ifdef CONFIG_FB_VT8500 + panels[current_panel_idx].bpp =16 ;/* Always use RGB565 */ +preallocate_fb (&panels[current_panel_idx],SZ_4M );Quoted 9 lines
arch/arm/mach-vt8500/devices.c line 451
Quoted 3 lines
arch/arm/mach-vt8500/devices.c new file +3
-0+ vt8500_device_lcdc.dev.platform_data = &panels[current_panel_idx]; +#endif +}Not sure if this should exist in the platform code or the framebuffer driver. In the latter case it would automatically be
CONFIG_FB_VT8500and theplatform_datacan still be set in the platform code. Is there a reason for this not to be in the framebuffer driver?
Quoted 3 lines
I can't reserve memory via memblock from the driver, and usual runtime allocation functions can't handle it (need alignment to 4 megabytes in 8500, framebuffer sizes exceed 4 megabytes in 8505).
Can you use one of the initcalls from a driver to to the memblock reserve? I don't know much about how memblock works. There are also the various large page allocators in the works, but I don't think anything has hit mainline yet.
Quoted 11 lines
Quoted 10 lines
arch/arm/mach-vt8500/include/mach/memory.h line 26
Quoted 7 lines
arch/arm/mach-vt8500/include/mach/memory.h new file +7
-0+#ifndef __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +/* +* Physical DRAM offset. +*/ +#define PHYS_OFFSET UL(0x00000000)If you renamed this to
PHYS_DRAM_OFFSETyou wouldn't need the comment :-).
Quoted 1 line
I'm not the one who chooses :)
Oops, missed that :-).
Quoted 27 lines
Quoted 17 lines
Quoted 17 lines
arch/arm/mach-vt8500/irq.c new file +17
-0+void __init vt8500_init_irq (void ) +{ +unsigned int i; + + ic_regbase =ioremap (wmt_current_regs->ic0,SZ_64K ); + +if (ic_regbase) { +/* Enable rotating priority for IRQ */ +writel ((1 <<6 ), ic_regbase +0x20 ); +writel (0 , ic_regbase +0x24 ); + +for (i =0 ; i < wmt_current_irqs->nr_irqs; i++) { +/* Disable all interrupts and route them to IRQ */ +writeb (0x00 , ic_regbase +VT8500_IC_DCTR + i); + +set_irq_chip (i, &vt8500_irq_chip); +set_irq_handler (i, handle_level_irq);Quoted 9 lines
arch/arm/mach-vt8500/irq.c line 145
Quoted 5 lines
arch/arm/mach-vt8500/irq.c new file +5
-0+set_irq_flags (i,IRQF_VALID ); + } + }else { +printk (KERN_ERR "Unable to remap the Interrupt Controller " +"registers, not enabling IRQs!\n" );printk strings should be on a single line (can be > 80 columns) to make grepping easier. You could also use the
pr_macros withpr_fmtset.
Quoted 2 lines
Well, checkpatch.pl complained about that in the first place, so I split the line. Should I merge them back in all instances?
Yes. I think checkpatch has been changed to warn about spitting printk strings across lines now.
Quoted 12 lines
<snip>
Quoted 9 lines
arch/arm/mach-vt8500/pwm.c
Quoted 5 lines
arch/arm/mach-vt8500/pwm.c new file +0
-0I'm not sure what the state of the various efforts to provide a common pwm framework are, but you may want to check.
Quoted 1 line
I did before starting to write this code, found nothing.
Fair enough.
Quoted 12 lines
Quoted 11 lines
arch/arm/mach-vt8500/pwm.c line 44
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+ +static inline void pwm_busy_wait (void __iomem *reg,u8 bitmask) +{ +int loops =1000 ; +while ((readb (reg) & bitmask) && --loops) +cpu_relax ();Ugh. If you are going to busy wait, can't you delay for a known amount of time? Even better, can this be replaced with
wait_eventor some equivalent?
Quoted 3 lines
The delay should be on the order of several bus cycles, where udelay actually busy-waits, too.
wait_eventwould be longer than that to set up, and there is no associated interrupt.
I meant if the hardware has some specific maximum wait time then you could just delay that long. If there is no interrupt then wait_event and friends probably aren't going to work.
Maybe convert this to a timed loop (i.e. 1 second timeout) using jiffies. That way you are never dependent on cpu speed. You should probably also emit a warning if the timeout is reached and the device still claims to be busy.
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-vt8500/pwm.c new file +8
-0+} + +int pwm_config (struct pwm_device *pwm,int duty_ns,int period_ns) +{ +unsigned long long c; +unsigned long period_cycles, prescale, pv, dc; + +if (pwm ==NULL || period_ns ==0 || duty_ns > period_ns)Quoted 9 lines
arch/arm/mach-vt8500/pwm.c line 58
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+return -EINVAL ; + + c =25000000 /2 ;/* wild guess --- need to implement clocks */ + c = c * period_ns; +do_div (c,1000000000 ); + period_cycles = c;This looks like it could be reworked to remove the
do_divcall.
Quoted 4 lines
I just followed PXA implementation in this regard. Are there any specific suggestions? Note that c should not be a complie-time constant eventually, as this is the guessed PWM base frequency (should be read from the hardware, but the code for clocks is not yet in).
I didn't have a particular solution in mind, but often by changing the units used and rearranging the math a bit you can often avoid having to do horrible multiplies and divides.
For now at least you could avoid the do_div by assigning period_cycles directly.
Quoted 46 lines
Quoted 46 lines
Quoted 16 lines
arch/arm/mach-vt8500/pwm.c new file +16
-0+struct pwm_device *pwm_request (int pwm_id,const char *label) +{ +struct pwm_device *pwm; +int found =0 ; + +mutex_lock (&pwm_lock); + +list_for_each_entry (pwm, &pwm_list, node) { +if (pwm->pwm_id == pwm_id) { + found =1 ; +break ; + } + } + +if (found) { +if (pwm->use_count ==0 ) {arch/arm/mach-vt8500/pwm.c line 128
Quoted 10 lines
arch/arm/mach-vt8500/pwm.c new file +10
-0+ pwm->use_count++; + pwm->label = label; + }else + pwm =ERR_PTR (-EBUSY ); + }else + pwm =ERR_PTR (-ENOENT ); + +mutex_unlock (&pwm_lock); +return pwm; +}Maybe a bit clearer and more concise like this? Also replaces
-ENOENT(No such file or directory) with-ENODEV(No such device):pwm = ERR_PTR(-ENODEV); mutex_lock(&pwm_lock); list_for_each_entry(pwm, &pwm_list, node) { if (pwm->pwm_id == pwm_id) { if (pwm->use_count != 0) { pwm = ERR_PTR(-EBUSY); break; } pwm->use_count++; pwm->label = label; break; } }
Quoted 6 lines
Quoted 3 lines
mutex_unlock(&pwm_lock); return pwm;Isn't pwm overwritten inside the loop?
-ENODEVwill then be lost with this layout.
Oops, yes. You would need a second temporary pwm for the list iterator. It's not a big deal anyway, just though it could be made more concise by having all the code inside the loop.
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+static int __devinit pwm_probe (struct platform_device *pdev) +{ +struct pwm_device *pwms; +struct resource *r; +int ret =0 ; +int i;Quoted 9 lines
arch/arm/mach-vt8500/pwm.c line 163
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+ + pwms =kzalloc (sizeof (struct pwm_device ) *VT8500_NR_PWMS ,GFP_KERNEL ); +if (pwms ==NULL ) { +dev_err (&pdev->dev,"failed to allocate memory\n" ); +return -ENOMEM ; + }Devices should ideally be a single entity, so one platform device per pwm.
Quoted 2 lines
We have 4 pwm outputs that share status registers, so they are not really separable.
Okay.
<snip>
Quoted 9 lines
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c
Quoted 3 lines
arch/arm/mach-vt8500/pwm.c new file +3
-0+static void vt8500_power_off (void ) +{ +local_irq_disable ();Is this necessary?
Vendor's code disables interrupts. I believe my device refused to actually switch off without this.
Okay, fair enough.
Quoted 1 line
Thanks for the comments, Ryan!
No problem.
~Ryan
Signature · 7 lines
Bluewater Systems Ltd - ARM Technology Solution Centre Ryan Mallon 5 Amuri Park, 404 Barbadoes St [email protected] PO Box 13 889, Christchurch 8013 http://www.bluewatersys.com New Zealand Phone: +64 3 3779127 Freecall: Australia 1800 148 751 Fax: +64 3 3779135 USA 1800 261 2934
Alexey Charkov
maintainer2010/12/21 Ryan Mallon <[email protected]>:
Quoted 71 lines · Alexey Charkov
Quoted 43 lines
2010/12/20 Ryan Mallon <[email protected]>:
Quoted 19 lines · Alexey Charkov
Quoted 7 lines
This adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505, selectable by a configuration switch at kernel build time.
Quoted 7 lines
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
Signed-off-by Alexey Charkov <[email protected]>Hi Alexey,
Quick review below.
<snip>
Quoted 12 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+void __init wmt_set_resources(void) +{ + ? ? resources_lcdc[0].start = wmt_current_regs->lcdc; + ? ? resources_lcdc[0].end = wmt_current_regs->lcdc + SZ_1K - 1; + ? ? resources_lcdc[1].start = wmt_current_irqs->lcdc; + ? ? resources_lcdc[1].end = wmt_current_irqs->lcdc;Ah, this makes more sense. But why have all the indirection? The
wmt_regmapstable could just be replaced with #defines and then have separate device files for the VT8500 and the WM8505. This would also make clearer which variants have which peripherals.This was the way I implemented it originally. However, Arnd made quite a valid suggestion to allow runtime selection of the chip variant, thus registers and interrupts need to be held in an indexed data type instead of just compile-time macros. In addition, there is now some overall movement towards unification of binary kernel images for different ARM variants (as far as I can see), so this would be required in any case.
Quoted 4 lines
Furthermore, as with many unbranded Chinese products, it's somewhat difficult to reliably determine the exact chip version used in your netbook without disassembling it. Reading a hardware register for identification is easier :)
Okay, that makes sense. I still think there must be a better way than having a massive indirect table with all the values. Why not detect the variant in the core code and then have something like:
int
init_devices(void)
{
? ? ? ?intboard_type=detect_board_type();? ? ? ?switch (
board_type) {
? ? ? ?caseBOARD_TYPE_VT8500:
? ? ? ? ? ? ? ?returnvt8500_init_devices();? ? ? ?case
BOARD_TYPE_WM8505:
? ? ? ? ? ? ? ?returnwm8500_init_devices();
? ? ? ?}? ? ? ?pr_err("Unknown board type\n");
? ? ? ?BUG(); /*panic()? */
? ? ? ?while (1)
? ? ? ? ? ? ? ?;
}
Quoted 7 lines
Then you can have the peripheral setup for each of the variants in their own files and use #defines. It may get tricky in a couple of places if you need to be able to access some value directly which is different on each of the variants, but that can be handled on a case by case basis. The majority of the numbers will be passed into drivers via the resource structs.
This is more or less what I'm doing right now - except for the separation between different files. I tried to avoid duplication of similar things here. Is the indirect table really a big issue? I'm a bit reluctant to copy about the whole devices.c for each chip variant, which would be otherwise required. Further, it would add more complexity to the timer, irq, gpio, i8042 and probably some other places.
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
arch/arm/mach-vt8500/devices.c line 451
Quoted 9 lines
arch/arm/mach-vt8500/devices.c new file +9
-0+ +void __init vt8500_reserve_mem (void ) +{ +#ifdef CONFIG_FB_VT8500 + ? ? panels[current_panel_idx].bpp = 16; /* Always use RGB565 */ + ? ? preallocate_fb(&panels[current_panel_idx], SZ_4M); + ? ? vt8500_device_lcdc.dev.platform_data = &panels[current_panel_idx]; +#endif +}Not sure if this should exist in the platform code or the framebuffer driver. In the latter case it would automatically be
CONFIG_FB_VT8500and theplatform_datacan still be set in the platform code. Is there a reason for this not to be in the framebuffer driver?
Quoted 9 lines
Quoted 3 lines
I can't reserve memory via memblock from the driver, and usual runtime allocation functions can't handle it (need alignment to 4 megabytes in 8500, framebuffer sizes exceed 4 megabytes in 8505).
Can you use one of the initcalls from a driver to to the memblock reserve? I don't know much about how memblock works. There are also the various large page allocators in the works, but I don't think anything has hit mainline yet.
No, drivers are initialized too late, even if compiled statically. Memblock can only be reserved through the designated machine callback, as far as I have understood.
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 12 lines
(quoted diff) +12
-0+void __init vt8500_init_irq(void) +{ + ? ? unsigned int i; + + ? ? ic_regbase = ioremap(wmt_current_regs->ic0, SZ_64K); + + ? ? if (ic_regbase) { + ? ? ? ? ? ? /* Enable rotating priority for IRQ */ + ? ? ? ? ? ? writel((1 << 6), ic_regbase + 0x20); + ? ? ? ? ? ? writel(0, ic_regbase + 0x24); + + ? ? ? ? ? ? for (i = 0; i < wmt_current_irqs->nr_irqs; i++) {Review
Quoted 10 lines
(quoted diff) +10
-0+ ? ? ? ? ? ? ? ? ? ? /* Disable all interrupts and route them to IRQ */ + ? ? ? ? ? ? ? ? ? ? writeb(0x00, ic_regbase + VT8500_IC_DCTR + i); + + ? ? ? ? ? ? ? ? ? ? set_irq_chip(i, &vt8500_irq_chip); + ? ? ? ? ? ? ? ? ? ? set_irq_handler(i, handle_level_irq); + ? ? ? ? ? ? ? ? ? ? set_irq_flags(i, IRQF_VALID); + ? ? ? ? ? ? } + ? ? } else { + ? ? ? ? ? ? printk(KERN_ERR "Unable to remap the Interrupt Controller " + ? ? ? ? ? ? ? ? ? ? ? ? ? ? "registers, not enabling IRQs!\n");printk strings should be on a single line (can be > 80 columns) to make grepping easier. You could also use the
pr_macros withpr_fmtset.
Quoted 6 lines
Quoted 2 lines
Well, checkpatch.pl complained about that in the first place, so I split the line. Should I merge them back in all instances?
Yes. I think checkpatch has been changed to warn about spitting printk strings across lines now.
Ok, will then merge strings.
Quoted 16 lines
Quoted 12 lines
Quoted 11 lines
arch/arm/mach-vt8500/pwm.c
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+ +static inline void pwm_busy_wait (void __iomem *reg,u8 bitmask) +{ + ? ? int loops = 1000; + ? ? while ((readb(reg) & bitmask) && --loops) + ? ? ? ? ? ? cpu_relax();Ugh. If you are going to busy wait, can't you delay for a known amount of time? Even better, can this be replaced with
wait_eventor some equivalent?Quoted 3 lines
The delay should be on the order of several bus cycles, where udelay actually busy-waits, too.
wait_eventwould be longer than that to set up, and there is no associated interrupt.
Quoted 9 lines
I meant if the hardware has some specific maximum wait time then you could just delay that long. If there is no interrupt then
wait_eventand friends probably aren't going to work.Maybe convert this to a timed loop (i.e. 1 second timeout) using jiffies. That way you are never dependent on cpu speed. You should probably also emit a warning if the timeout is reached and the device still claims to be busy.
Agreed, will look into that. There is no definite maximum wait time, though (at least none that I know about).
Quoted 23 lines
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-vt8500/pwm.c new file +8
-0+} + +int pwm_config (struct pwm_device *pwm,int duty_ns,int period_ns) +{ + ? ? unsigned long long c; + ? ? unsigned long period_cycles, prescale, pv, dc; + + ? ? if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)Quoted 9 lines
Quoted 6 lines
+ ? ? ? ? ? ? return
-EINVAL;
+
+ ? ? c = 25000000/2; /* wild guess --- need to implement clocks */
+ ? ? c = c *period_ns;
+ ? ?do_div(c, 1000000000);
+ ? ?period_cycles= c;This looks like it could be reworked to remove the
do_divcall.Quoted 4 lines
I just followed PXA implementation in this regard. Are there any specific suggestions? Note that c should not be a complie-time constant eventually, as this is the guessed PWM base frequency (should be read from the hardware, but the code for clocks is not yet in).
Quoted 7 lines
I didn't have a particular solution in mind, but often by changing the units used and rearranging the math a bit you can often avoid having to do horrible multiplies and divides.
For now at least you could avoid the
do_divby assigningperiod_cyclesdirectly.
It depends on period_ns, which is passed in as an argument from whatever uses PWM, so I'm not sure it can be assigned directly.
Thanks,
Alexey
Quoted 80 lines · Alexey Charkov
2010/12/21 Ryan Mallon <[email protected]>:
Quoted 71 lines · Alexey Charkov
Quoted 43 lines
2010/12/20 Ryan Mallon <[email protected]>:
Quoted 19 lines · Alexey Charkov
Quoted 7 lines
This adds support for the family of Systems-on-Chip produced initially by VIA and now its subsidiary WonderMedia that have recently become widespread in lower-end Chinese ARM-based tablets and netbooks.
Support is included for both VT8500 and WM8505, selectable by a configuration switch at kernel build time.
Quoted 7 lines
Included are basic machine initialization files, register and interrupt definitions, support for the on-chip interrupt controller, high-precision OS timer, GPIO lines, necessary macros for early debug, pulse-width-modulated outputs control, as well as platform device configurations for the specific drivers implemented elsewhere.
Signed-off-by Alexey Charkov <[email protected]>Hi Alexey,
Quick review below.
<snip>
Quoted 12 lines
arch/arm/mach-vt8500/devices.c line 369
Quoted 6 lines
arch/arm/mach-vt8500/devices.c new file +6
-0+void __init wmt_set_resources (void ) +{ + resources_lcdc[0 ].start = wmt_current_regs->lcdc; + resources_lcdc[0 ].end = wmt_current_regs->lcdc +SZ_1K -1 ; + resources_lcdc[1 ].start = wmt_current_irqs->lcdc; + resources_lcdc[1 ].end = wmt_current_irqs->lcdc;Ah, this makes more sense. But why have all the indirection? The
wmt_regmapstable could just be replaced with #defines and then have separate device files for the VT8500 and the WM8505. This would also make clearer which variants have which peripherals.This was the way I implemented it originally. However, Arnd made quite a valid suggestion to allow runtime selection of the chip variant, thus registers and interrupts need to be held in an indexed data type instead of just compile-time macros. In addition, there is now some overall movement towards unification of binary kernel images for different ARM variants (as far as I can see), so this would be required in any case.
Quoted 4 lines
Furthermore, as with many unbranded Chinese products, it's somewhat difficult to reliably determine the exact chip version used in your netbook without disassembling it. Reading a hardware register for identification is easier :)
Okay, that makes sense. I still think there must be a better way than having a massive indirect table with all the values. Why not detect the variant in the core code and then have something like:
int
init_devices(void){ int board_type = detect_board_type(); switch (board_type) { case BOARD_TYPE_VT8500: return vt8500_init_devices(); case BOARD_TYPE_WM8505: return wm8500_init_devices(); } pr_err("Unknown board type\n"); BUG(); /* panic()? */ while (1) ; }Quoted 7 lines
Then you can have the peripheral setup for each of the variants in their own files and use #defines. It may get tricky in a couple of places if you need to be able to access some value directly which is different on each of the variants, but that can be handled on a case by case basis. The majority of the numbers will be passed into drivers via the resource structs.
Quoted 7 lines
This is more or less what I'm doing right now - except for the separation between different files. I tried to avoid duplication of similar things here. Is the indirect table really a big issue? I'm a bit reluctant to copy about the whole
devices.cfor each chip variant, which would be otherwise required. Further, it would add more complexity to the timer, irq, gpio, i8042 and probably some other places.
Yeah, agreed about the duplication. My approach would require the common peripherals to be defined for each variant. I'm not entirely against the indirect table (and am even starting to think it may be the best overall solution), it's just that it can be a bit difficult to follow because to add a device you need to do the following:
- Add a partially empty resource/platform_device struct
- Add resource entries to the resource table definition
- Add resource values to the resource table
- Add assignment of resource values to device init code
The indirection also makes it harder to quickly determine the IRQ number of memory address of a peripheral.
The current solution using the indirect table is okay, but it would be nice to find a solution which reduces some of this effort.
Quoted 26 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
arch/arm/mach-vt8500/devices.c line 451
Quoted 9 lines
arch/arm/mach-vt8500/devices.c new file +9
-0+ +void __init vt8500_reserve_mem (void ) +{ +#ifdef CONFIG_FB_VT8500 + panels[current_panel_idx].bpp =16 ;/* Always use RGB565 */ +preallocate_fb (&panels[current_panel_idx],SZ_4M ); + vt8500_device_lcdc.dev.platform_data = &panels[current_panel_idx]; +#endif +}Not sure if this should exist in the platform code or the framebuffer driver. In the latter case it would automatically be
CONFIG_FB_VT8500and theplatform_datacan still be set in the platform code. Is there a reason for this not to be in the framebuffer driver?Quoted 9 lines
Quoted 3 lines
I can't reserve memory via memblock from the driver, and usual runtime allocation functions can't handle it (need alignment to 4 megabytes in 8500, framebuffer sizes exceed 4 megabytes in 8505).
Can you use one of the initcalls from a driver to to the memblock reserve? I don't know much about how memblock works. There are also the various large page allocators in the works, but I don't think anything has hit mainline yet.
Quoted 3 lines
No, drivers are initialized too late, even if compiled statically. Memblock can only be reserved through the designated machine callback, as far as I have understood.
Okay.
Quoted 27 lines
Quoted 27 lines
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-vt8500/pwm.c new file +8
-0+} + +int pwm_config (struct pwm_device *pwm,int duty_ns,int period_ns) +{ +unsigned long long c; +unsigned long period_cycles, prescale, pv, dc; + +if (pwm ==NULL || period_ns ==0 || duty_ns > period_ns)Quoted 9 lines
arch/arm/mach-vt8500/pwm.c line 58
Quoted 6 lines
arch/arm/mach-vt8500/pwm.c new file +6
-0+return -EINVAL ; + + c =25000000 /2 ;/* wild guess --- need to implement clocks */ + c = c * period_ns; +do_div (c,1000000000 ); + period_cycles = c;This looks like it could be reworked to remove the
do_divcall.Quoted 4 lines
I just followed PXA implementation in this regard. Are there any specific suggestions? Note that c should not be a complie-time constant eventually, as this is the guessed PWM base frequency (should be read from the hardware, but the code for clocks is not yet in).
I didn't have a particular solution in mind, but often by changing the units used and rearranging the math a bit you can often avoid having to do horrible multiplies and divides.
Quoted 6 lines
Quoted 3 lines
For now at least you could avoid the
do_divby assigningperiod_cyclesdirectly.It depends on
period_ns, which is passed in as an argument from whatever uses PWM, so I'm not sure it can be assigned directly.
Ah. How big a number is period_ns? Can you do something like this instead?
period_cycles = ((250 / 2) * period_ns) / 10000;
and still safely avoid overflows?
~Ryan
Signature · 7 lines
Bluewater Systems Ltd - ARM Technology Solution Centre Ryan Mallon 5 Amuri Park, 404 Barbadoes St [email protected] PO Box 13 889, Christchurch 8013 http://www.bluewatersys.com New Zealand Phone: +64 3 3779127 Freecall: Australia 1800 148 751 Fax: +64 3 3779135 USA 1800 261 2934