Commit 2631182b authored by Russell King's avatar Russell King Committed by Russell King

Merge branch 'w90x900' into devel

parents 0aacfe1d cc63262f
...@@ -478,6 +478,9 @@ config ARCH_NS9XXX ...@@ -478,6 +478,9 @@ config ARCH_NS9XXX
config ARCH_W90X900 config ARCH_W90X900
bool "Nuvoton W90X900 CPU" bool "Nuvoton W90X900 CPU"
select CPU_ARM926T select CPU_ARM926T
select ARCH_REQUIRE_GPIOLIB
select GENERIC_GPIO
select COMMON_CLKDEV
help help
Support for Nuvoton (Winbond logic dept.) ARM9 processor,You Support for Nuvoton (Winbond logic dept.) ARM9 processor,You
can login www.mcuos.com or www.nuvoton.com to know more. can login www.mcuos.com or www.nuvoton.com to know more.
......
This diff is collapsed.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Object file lists. # Object file lists.
obj-y := irq.o time.o obj-y := irq.o time.o mfp-w90p910.o gpio.o clock.o
# W90X900 CPU support files # W90X900 CPU support files
......
/*
* linux/arch/arm/mach-w90x900/clock.c
*
* Copyright (c) 2008 Nuvoton technology corporation
*
* Wan ZongShun <mcuos.com@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/string.h>
#include <linux/clk.h>
#include <linux/spinlock.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <mach/hardware.h>
#include "clock.h"
static DEFINE_SPINLOCK(clocks_lock);
int clk_enable(struct clk *clk)
{
unsigned long flags;
spin_lock_irqsave(&clocks_lock, flags);
if (clk->enabled++ == 0)
(clk->enable)(clk, 1);
spin_unlock_irqrestore(&clocks_lock, flags);
return 0;
}
EXPORT_SYMBOL(clk_enable);
void clk_disable(struct clk *clk)
{
unsigned long flags;
WARN_ON(clk->enabled == 0);
spin_lock_irqsave(&clocks_lock, flags);
if (--clk->enabled == 0)
(clk->enable)(clk, 0);
spin_unlock_irqrestore(&clocks_lock, flags);
}
EXPORT_SYMBOL(clk_disable);
void w90x900_clk_enable(struct clk *clk, int enable)
{
unsigned int clocks = clk->cken;
unsigned long clken;
clken = __raw_readl(W90X900_VA_CLKPWR);
if (enable)
clken |= clocks;
else
clken &= ~clocks;
__raw_writel(clken, W90X900_VA_CLKPWR);
}
void clks_register(struct clk_lookup *clks, size_t num)
{
int i;
for (i = 0; i < num; i++)
clkdev_add(&clks[i]);
}
/*
* linux/arch/arm/mach-w90x900/clock.h
*
* Copyright (c) 2008 Nuvoton technology corporation
*
* Wan ZongShun <mcuos.com@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
*/
#include <asm/clkdev.h>
void w90x900_clk_enable(struct clk *clk, int enable);
void clks_register(struct clk_lookup *clks, size_t num);
struct clk {
unsigned long cken;
unsigned int enabled;
void (*enable)(struct clk *, int enable);
};
#define DEFINE_CLK(_name, _ctrlbit) \
struct clk clk_##_name = { \
.enable = w90x900_clk_enable, \
.cken = (1 << _ctrlbit), \
}
#define DEF_CLKLOOK(_clk, _devname, _conname) \
{ \
.clk = _clk, \
.dev_id = _devname, \
.con_id = _conname, \
}
...@@ -41,7 +41,7 @@ struct sys_timer; ...@@ -41,7 +41,7 @@ struct sys_timer;
extern void w90x900_init_irq(void); extern void w90x900_init_irq(void);
extern void w90p910_init_io(struct map_desc *mach_desc, int size); extern void w90p910_init_io(struct map_desc *mach_desc, int size);
extern void w90p910_init_uarts(struct w90x900_uartcfg *cfg, int no); extern void w90p910_init_uarts(struct w90x900_uartcfg *cfg, int no);
extern void w90p910_init_clocks(int xtal); extern void w90p910_init_clocks(void);
extern void w90p910_map_io(struct map_desc *mach_desc, int size); extern void w90p910_map_io(struct map_desc *mach_desc, int size);
extern struct platform_device w90p910_serial_device; extern struct platform_device w90p910_serial_device;
extern struct sys_timer w90x900_timer; extern struct sys_timer w90x900_timer;
......
/*
* linux/arch/arm/mach-w90p910/gpio.c
*
* Generic w90p910 GPIO handling
*
* Wan ZongShun <mcuos.com@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/clk.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/io.h>
#include <linux/gpio.h>
#include <mach/hardware.h>
#define GPIO_BASE (W90X900_VA_GPIO)
#define GPIO_DIR (0x04)
#define GPIO_OUT (0x08)
#define GPIO_IN (0x0C)
#define GROUPINERV (0x10)
#define GPIO_GPIO(Nb) (0x00000001 << (Nb))
#define to_w90p910_gpio_chip(c) container_of(c, struct w90p910_gpio_chip, chip)
#define W90P910_GPIO_CHIP(name, base_gpio, nr_gpio) \
{ \
.chip = { \
.label = name, \
.direction_input = w90p910_dir_input, \
.direction_output = w90p910_dir_output, \
.get = w90p910_gpio_get, \
.set = w90p910_gpio_set, \
.base = base_gpio, \
.ngpio = nr_gpio, \
} \
}
struct w90p910_gpio_chip {
struct gpio_chip chip;
void __iomem *regbase; /* Base of group register*/
spinlock_t gpio_lock;
};
static int w90p910_gpio_get(struct gpio_chip *chip, unsigned offset)
{
struct w90p910_gpio_chip *w90p910_gpio = to_w90p910_gpio_chip(chip);
void __iomem *pio = w90p910_gpio->regbase + GPIO_IN;
unsigned int regval;
regval = __raw_readl(pio);
regval &= GPIO_GPIO(offset);
return (regval != 0);
}
static void w90p910_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
{
struct w90p910_gpio_chip *w90p910_gpio = to_w90p910_gpio_chip(chip);
void __iomem *pio = w90p910_gpio->regbase + GPIO_OUT;
unsigned int regval;
unsigned long flags;
spin_lock_irqsave(&w90p910_gpio->gpio_lock, flags);
regval = __raw_readl(pio);
if (val)
regval |= GPIO_GPIO(offset);
else
regval &= ~GPIO_GPIO(offset);
__raw_writel(regval, pio);
spin_unlock_irqrestore(&w90p910_gpio->gpio_lock, flags);
}
static int w90p910_dir_input(struct gpio_chip *chip, unsigned offset)
{
struct w90p910_gpio_chip *w90p910_gpio = to_w90p910_gpio_chip(chip);
void __iomem *pio = w90p910_gpio->regbase + GPIO_DIR;
unsigned int regval;
unsigned long flags;
spin_lock_irqsave(&w90p910_gpio->gpio_lock, flags);
regval = __raw_readl(pio);
regval &= ~GPIO_GPIO(offset);
__raw_writel(regval, pio);
spin_unlock_irqrestore(&w90p910_gpio->gpio_lock, flags);
return 0;
}
static int w90p910_dir_output(struct gpio_chip *chip, unsigned offset, int val)
{
struct w90p910_gpio_chip *w90p910_gpio = to_w90p910_gpio_chip(chip);
void __iomem *outreg = w90p910_gpio->regbase + GPIO_OUT;
void __iomem *pio = w90p910_gpio->regbase + GPIO_DIR;
unsigned int regval;
unsigned long flags;
spin_lock_irqsave(&w90p910_gpio->gpio_lock, flags);
regval = __raw_readl(pio);
regval |= GPIO_GPIO(offset);
__raw_writel(regval, pio);
regval = __raw_readl(outreg);
if (val)
regval |= GPIO_GPIO(offset);
else
regval &= ~GPIO_GPIO(offset);
__raw_writel(regval, outreg);
spin_unlock_irqrestore(&w90p910_gpio->gpio_lock, flags);
return 0;
}
static struct w90p910_gpio_chip w90p910_gpio[] = {
W90P910_GPIO_CHIP("GROUPC", 0, 16),
W90P910_GPIO_CHIP("GROUPD", 16, 10),
W90P910_GPIO_CHIP("GROUPE", 26, 14),
W90P910_GPIO_CHIP("GROUPF", 40, 10),
W90P910_GPIO_CHIP("GROUPG", 50, 17),
W90P910_GPIO_CHIP("GROUPH", 67, 8),
W90P910_GPIO_CHIP("GROUPI", 75, 17),
};
void __init w90p910_init_gpio(int nr_group)
{
unsigned i;
struct w90p910_gpio_chip *gpio_chip;
for (i = 0; i < nr_group; i++) {
gpio_chip = &w90p910_gpio[i];
spin_lock_init(&gpio_chip->gpio_lock);
gpio_chip->regbase = GPIO_BASE + i * GROUPINERV;
gpiochip_add(&gpio_chip->chip);
}
}
#ifndef __ASM_MACH_CLKDEV_H
#define __ASM_MACH_CLKDEV_H
#define __clk_get(clk) ({ 1; })
#define __clk_put(clk) do { } while (0)
#endif
/*
* linux/arch/arm/mach-w90p910/include/mach/gpio.h
*
* Generic w90p910 GPIO handling
*
* Wan ZongShun <mcuos.com@gmail.com>
*
* 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.
*/
#ifndef __ASM_ARCH_W90P910_GPIO_H
#define __ASM_ARCH_W90P910_GPIO_H
#include <mach/hardware.h>
#include <asm/irq.h>
#include <asm-generic/gpio.h>
#define gpio_get_value __gpio_get_value
#define gpio_set_value __gpio_set_value
#define gpio_cansleep __gpio_cansleep
static inline int gpio_to_irq(unsigned gpio)
{
return gpio;
}
static inline int irq_to_gpio(unsigned irq)
{
return irq;
}
#endif
/* /*
* arch/arm/mach-w90x900/include/mach/irqs.h * arch/arm/mach-w90x900/include/mach/irqs.h
* *
* Copyright (c) 2008 Nuvoton technology corporation * Copyright (c) 2008 Nuvoton technology corporation.
* All rights reserved.
* *
* Wan ZongShun <mcuos.com@gmail.com> * Wan ZongShun <mcuos.com@gmail.com>
* *
...@@ -10,8 +9,7 @@ ...@@ -10,8 +9,7 @@
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation;version 2 of the License.
* (at your option) any later version.
* *
*/ */
...@@ -31,6 +29,11 @@ ...@@ -31,6 +29,11 @@
/* Main cpu interrupts */ /* Main cpu interrupts */
#define IRQ_WDT W90X900_IRQ(1) #define IRQ_WDT W90X900_IRQ(1)
#define IRQ_GROUP0 W90X900_IRQ(2)
#define IRQ_GROUP1 W90X900_IRQ(3)
#define IRQ_ACTL W90X900_IRQ(4)
#define IRQ_LCD W90X900_IRQ(5)
#define IRQ_RTC W90X900_IRQ(6)
#define IRQ_UART0 W90X900_IRQ(7) #define IRQ_UART0 W90X900_IRQ(7)
#define IRQ_UART1 W90X900_IRQ(8) #define IRQ_UART1 W90X900_IRQ(8)
#define IRQ_UART2 W90X900_IRQ(9) #define IRQ_UART2 W90X900_IRQ(9)
...@@ -39,7 +42,45 @@ ...@@ -39,7 +42,45 @@
#define IRQ_TIMER0 W90X900_IRQ(12) #define IRQ_TIMER0 W90X900_IRQ(12)
#define IRQ_TIMER1 W90X900_IRQ(13) #define IRQ_TIMER1 W90X900_IRQ(13)
#define IRQ_T_INT_GROUP W90X900_IRQ(14) #define IRQ_T_INT_GROUP W90X900_IRQ(14)
#define IRQ_USBH W90X900_IRQ(15)
#define IRQ_EMCTX W90X900_IRQ(16)
#define IRQ_EMCRX W90X900_IRQ(17)
#define IRQ_GDMAGROUP W90X900_IRQ(18)
#define IRQ_DMAC W90X900_IRQ(19)
#define IRQ_FMI W90X900_IRQ(20)
#define IRQ_USBD W90X900_IRQ(21)
#define IRQ_ATAPI W90X900_IRQ(22)
#define IRQ_G2D W90X900_IRQ(23)
#define IRQ_PCI W90X900_IRQ(24)
#define IRQ_SCGROUP W90X900_IRQ(25)
#define IRQ_I2CGROUP W90X900_IRQ(26)
#define IRQ_SSP W90X900_IRQ(27)
#define IRQ_PWM W90X900_IRQ(28)
#define IRQ_KPI W90X900_IRQ(29)
#define IRQ_P2SGROUP W90X900_IRQ(30)
#define IRQ_ADC W90X900_IRQ(31) #define IRQ_ADC W90X900_IRQ(31)
#define NR_IRQS (IRQ_ADC+1) #define NR_IRQS (IRQ_ADC+1)
/*for irq group*/
#define IRQ_PS2_PORT0 0x10000000
#define IRQ_PS2_PORT1 0x20000000
#define IRQ_I2C_LINE0 0x04000000
#define IRQ_I2C_LINE1 0x08000000
#define IRQ_SC_CARD0 0x01000000
#define IRQ_SC_CARD1 0x02000000
#define IRQ_GDMA_CH0 0x00100000
#define IRQ_GDMA_CH1 0x00200000
#define IRQ_TIMER2 0x00010000
#define IRQ_TIMER3 0x00020000
#define IRQ_TIMER4 0x00040000
#define IRQ_GROUP0_IRQ0 0x00000001
#define IRQ_GROUP0_IRQ1 0x00000002
#define IRQ_GROUP0_IRQ2 0x00000004
#define IRQ_GROUP0_IRQ3 0x00000008
#define IRQ_GROUP1_IRQ4 0x00000010
#define IRQ_GROUP1_IRQ5 0x00000020
#define IRQ_GROUP1_IRQ6 0x00000040
#define IRQ_GROUP1_IRQ7 0x00000080
#endif /* __ASM_ARCH_IRQ_H */ #endif /* __ASM_ARCH_IRQ_H */
/* /*
* arch/arm/mach-w90x900/include/mach/map.h * arch/arm/mach-w90x900/include/mach/map.h
* *
* Copyright (c) 2008 Nuvoton technology corporation * Copyright (c) 2008 Nuvoton technology corporation.
* All rights reserved.
* *
* Wan ZongShun <mcuos.com@gmail.com> * Wan ZongShun <mcuos.com@gmail.com>
* *
...@@ -10,8 +9,7 @@ ...@@ -10,8 +9,7 @@
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation;version 2 of the License.
* (at your option) any later version.
* *
*/ */
...@@ -34,7 +32,6 @@ ...@@ -34,7 +32,6 @@
* interrupt controller is the first thing we put in, to make * interrupt controller is the first thing we put in, to make
* the assembly code for the irq detection easier * the assembly code for the irq detection easier
*/ */
#define W90X900_VA_IRQ W90X900_ADDR(0x00000000) #define W90X900_VA_IRQ W90X900_ADDR(0x00000000)
#define W90X900_PA_IRQ (0xB8002000) #define W90X900_PA_IRQ (0xB8002000)
#define W90X900_SZ_IRQ SZ_4K #define W90X900_SZ_IRQ SZ_4K
...@@ -44,33 +41,117 @@ ...@@ -44,33 +41,117 @@
#define W90X900_SZ_GCR SZ_4K #define W90X900_SZ_GCR SZ_4K
/* Clock and Power management */ /* Clock and Power management */
#define W90X900_VA_CLKPWR (W90X900_VA_GCR+0x200) #define W90X900_VA_CLKPWR (W90X900_VA_GCR+0x200)
#define W90X900_PA_CLKPWR (0xB0000200) #define W90X900_PA_CLKPWR (0xB0000200)
#define W90X900_SZ_CLKPWR SZ_4K #define W90X900_SZ_CLKPWR SZ_4K
/* EBI management */ /* EBI management */
#define W90X900_VA_EBI W90X900_ADDR(0x00001000) #define W90X900_VA_EBI W90X900_ADDR(0x00001000)
#define W90X900_PA_EBI (0xB0001000) #define W90X900_PA_EBI (0xB0001000)
#define W90X900_SZ_EBI SZ_4K #define W90X900_SZ_EBI SZ_4K
/* UARTs */ /* UARTs */
#define W90X900_VA_UART W90X900_ADDR(0x08000000) #define W90X900_VA_UART W90X900_ADDR(0x08000000)
#define W90X900_PA_UART (0xB8000000) #define W90X900_PA_UART (0xB8000000)
#define W90X900_SZ_UART SZ_4K #define W90X900_SZ_UART SZ_4K
/* Timers */ /* Timers */
#define W90X900_VA_TIMER W90X900_ADDR(0x08001000) #define W90X900_VA_TIMER W90X900_ADDR(0x08001000)
#define W90X900_PA_TIMER (0xB8001000) #define W90X900_PA_TIMER (0xB8001000)
#define W90X900_SZ_TIMER SZ_4K #define W90X900_SZ_TIMER SZ_4K
/* GPIO ports */ /* GPIO ports */
#define W90X900_VA_GPIO W90X900_ADDR(0x08003000) #define W90X900_VA_GPIO W90X900_ADDR(0x08003000)
#define W90X900_PA_GPIO (0xB8003000) #define W90X900_PA_GPIO (0xB8003000)
#define W90X900_SZ_GPIO SZ_4K #define W90X900_SZ_GPIO SZ_4K
/* GDMA control */
#define W90X900_VA_GDMA W90X900_ADDR(0x00004000)
#define W90X900_PA_GDMA (0xB0004000)
#define W90X900_SZ_GDMA SZ_4K
/* USB host controller*/
#define W90X900_VA_USBEHCIHOST W90X900_ADDR(0x00005000)
#define W90X900_PA_USBEHCIHOST (0xB0005000)
#define W90X900_SZ_USBEHCIHOST SZ_4K
#define W90X900_VA_USBOHCIHOST W90X900_ADDR(0x00007000)
#define W90X900_PA_USBOHCIHOST (0xB0007000)
#define W90X900_SZ_USBOHCIHOST SZ_4K
/* I2C hardware controller */
#define W90X900_VA_I2C W90X900_ADDR(0x08006000)
#define W90X900_PA_I2C (0xB8006000)
#define W90X900_SZ_I2C SZ_4K
/* Keypad Interface*/
#define W90X900_VA_KPI W90X900_ADDR(0x08008000)
#define W90X900_PA_KPI (0xB8008000)
#define W90X900_SZ_KPI SZ_4K
/* Smart card host*/
#define W90X900_VA_SC W90X900_ADDR(0x08005000)
#define W90X900_PA_SC (0xB8005000)
#define W90X900_SZ_SC SZ_4K
/* LCD controller*/
#define W90X900_VA_LCD W90X900_ADDR(0x00008000)
#define W90X900_PA_LCD (0xB0008000)
#define W90X900_SZ_LCD SZ_4K
/* 2D controller*/
#define W90X900_VA_GE W90X900_ADDR(0x0000B000)
#define W90X900_PA_GE (0xB000B000)
#define W90X900_SZ_GE SZ_4K
/* ATAPI */
#define W90X900_VA_ATAPI W90X900_ADDR(0x0000A000)
#define W90X900_PA_ATAPI (0xB000A000)
#define W90X900_SZ_ATAPI SZ_4K
/* ADC */
#define W90X900_VA_ADC W90X900_ADDR(0x0800A000)
#define W90X900_PA_ADC (0xB800A000)
#define W90X900_SZ_ADC SZ_4K
/* PS2 Interface*/
#define W90X900_VA_PS2 W90X900_ADDR(0x08009000)
#define W90X900_PA_PS2 (0xB8009000)
#define W90X900_SZ_PS2 SZ_4K
/* RTC */
#define W90X900_VA_RTC W90X900_ADDR(0x08004000)
#define W90X900_PA_RTC (0xB8004000)
#define W90X900_SZ_RTC SZ_4K
/* Pulse Width Modulation(PWM) Registers */
#define W90X900_VA_PWM W90X900_ADDR(0x08007000)
#define W90X900_PA_PWM (0xB8007000)
#define W90X900_SZ_PWM SZ_4K
/* Audio Controller controller */
#define W90X900_VA_ACTL W90X900_ADDR(0x00009000)
#define W90X900_PA_ACTL (0xB0009000)
#define W90X900_SZ_ACTL SZ_4K
/* DMA controller */
#define W90X900_VA_DMA W90X900_ADDR(0x0000c000)
#define W90X900_PA_DMA (0xB000c000)
#define W90X900_SZ_DMA SZ_4K
/* FMI controller */
#define W90X900_VA_FMI W90X900_ADDR(0x0000d000)
#define W90X900_PA_FMI (0xB000d000)
#define W90X900_SZ_FMI SZ_4K
/* USB Device port */
#define W90X900_VA_USBDEV W90X900_ADDR(0x00006000)
#define W90X900_PA_USBDEV (0xB0006000)
#define W90X900_SZ_USBDEV SZ_4K
/* External MAC control*/
#define W90X900_VA_EMC W90X900_ADDR(0x00003000)
#define W90X900_PA_EMC (0xB0003000)
#define W90X900_SZ_EMC SZ_4K
#endif /* __ASM_ARCH_MAP_H */ #endif /* __ASM_ARCH_MAP_H */
/*
* arch/arm/mach-w90x900/include/mach/regs-clock.h
*
* Copyright (c) 2008 Nuvoton technology corporation.
*
* Wan ZongShun <mcuos.com@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;version 2 of the License.
*
*/
#ifndef __ASM_ARCH_REGS_CLOCK_H
#define __ASM_ARCH_REGS_CLOCK_H
/* Clock Control Registers */
#define CLK_BA W90X900_VA_CLKPWR
#define REG_CLKEN (CLK_BA + 0x00)
#define REG_CLKSEL (CLK_BA + 0x04)
#define REG_CLKDIV (CLK_BA + 0x08)
#define REG_PLLCON0 (CLK_BA + 0x0C)
#define REG_PLLCON1 (CLK_BA + 0x10)
#define REG_PMCON (CLK_BA + 0x14)
#define REG_IRQWAKECON (CLK_BA + 0x18)
#define REG_IRQWAKEFLAG (CLK_BA + 0x1C)
#define REG_IPSRST (CLK_BA + 0x20)
#define REG_CLKEN1 (CLK_BA + 0x24)
#define REG_CLKDIV1 (CLK_BA + 0x28)
#endif /* __ASM_ARCH_REGS_CLOCK_H */
/*
* arch/arm/mach-w90x900/include/mach/regs-usb.h
*
* Copyright (c) 2008 Nuvoton technology corporation.
*
* Wan ZongShun <mcuos.com@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;version 2 of the License.
*
*/
#ifndef __ASM_ARCH_REGS_USB_H
#define __ASM_ARCH_REGS_USB_H
/* usb Control Registers */
#define USBH_BA W90X900_VA_USBEHCIHOST
#define USBD_BA W90X900_VA_USBDEV
#define USBO_BA W90X900_VA_USBOHCIHOST
/* USB Host Control Registers */
#define REG_UPSCR0 (USBH_BA+0x064)
#define REG_UPSCR1 (USBH_BA+0x068)
#define REG_USBPCR0 (USBH_BA+0x0C4)
#define REG_USBPCR1 (USBH_BA+0x0C8)
/* USBH OHCI Control Registers */
#define REG_OpModEn (USBO_BA+0x204)
/*This bit controls the polarity of over
*current flag from external power IC.
*/
#define OCALow 0x08
#endif /* __ASM_ARCH_REGS_USB_H */
...@@ -3,15 +3,13 @@ ...@@ -3,15 +3,13 @@
* *
* Based on mach-s3c2410/mach-smdk2410.c by Jonas Dietsche * Based on mach-s3c2410/mach-smdk2410.c by Jonas Dietsche
* *
* Copyright (C) 2008 Nuvoton technology corporation * Copyright (C) 2008 Nuvoton technology corporation.
* All rights reserved.
* *
* Wan ZongShun <mcuos.com@gmail.com> * Wan ZongShun <mcuos.com@gmail.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation;version 2 of the License.
* the License, or (at your option) any later version.
* *
*/ */
...@@ -80,6 +78,156 @@ static struct platform_device w90p910_flash_device = { ...@@ -80,6 +78,156 @@ static struct platform_device w90p910_flash_device = {
.num_resources = ARRAY_SIZE(w90p910_flash_resources), .num_resources = ARRAY_SIZE(w90p910_flash_resources),
}; };
/* USB EHCI Host Controller */
static struct resource w90x900_usb_ehci_resource[] = {
[0] = {
.start = W90X900_PA_USBEHCIHOST,
.end = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_USBH,
.end = IRQ_USBH,
.flags = IORESOURCE_IRQ,
}
};
static u64 w90x900_device_usb_ehci_dmamask = 0xffffffffUL;
struct platform_device w90x900_device_usb_ehci = {
.name = "w90x900-ehci",
.id = -1,
.num_resources = ARRAY_SIZE(w90x900_usb_ehci_resource),
.resource = w90x900_usb_ehci_resource,
.dev = {
.dma_mask = &w90x900_device_usb_ehci_dmamask,
.coherent_dma_mask = 0xffffffffUL
}
};
EXPORT_SYMBOL(w90x900_device_usb_ehci);
/* USB OHCI Host Controller */
static struct resource w90x900_usb_ohci_resource[] = {
[0] = {
.start = W90X900_PA_USBOHCIHOST,
.end = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_USBH,
.end = IRQ_USBH,
.flags = IORESOURCE_IRQ,
}
};
static u64 w90x900_device_usb_ohci_dmamask = 0xffffffffUL;
struct platform_device w90x900_device_usb_ohci = {
.name = "w90x900-ohci",
.id = -1,
.num_resources = ARRAY_SIZE(w90x900_usb_ohci_resource),
.resource = w90x900_usb_ohci_resource,
.dev = {
.dma_mask = &w90x900_device_usb_ohci_dmamask,
.coherent_dma_mask = 0xffffffffUL
}
};
EXPORT_SYMBOL(w90x900_device_usb_ohci);
/*TouchScreen controller*/
static struct resource w90x900_ts_resource[] = {
[0] = {
.start = W90X900_PA_ADC,
.end = W90X900_PA_ADC + W90X900_SZ_ADC-1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_ADC,
.end = IRQ_ADC,
.flags = IORESOURCE_IRQ,
},
};
struct platform_device w90x900_device_ts = {
.name = "w90x900-ts",
.id = -1,
.resource = w90x900_ts_resource,
.num_resources = ARRAY_SIZE(w90x900_ts_resource),
};
EXPORT_SYMBOL(w90x900_device_ts);
/* RTC controller*/
static struct resource w90x900_rtc_resource[] = {
[0] = {
.start = W90X900_PA_RTC,
.end = W90X900_PA_RTC + 0xff,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_RTC,
.end = IRQ_RTC,
.flags = IORESOURCE_IRQ,
},
};
struct platform_device w90x900_device_rtc = {
.name = "w90x900-rtc",
.id = -1,
.num_resources = ARRAY_SIZE(w90x900_rtc_resource),
.resource = w90x900_rtc_resource,
};
EXPORT_SYMBOL(w90x900_device_rtc);
/* KPI controller*/
static struct resource w90x900_kpi_resource[] = {
[0] = {
.start = W90X900_PA_KPI,
.end = W90X900_PA_KPI + W90X900_SZ_KPI - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_KPI,
.end = IRQ_KPI,
.flags = IORESOURCE_IRQ,
}
};
struct platform_device w90x900_device_kpi = {
.name = "w90x900-kpi",
.id = -1,
.num_resources = ARRAY_SIZE(w90x900_kpi_resource),
.resource = w90x900_kpi_resource,
};
EXPORT_SYMBOL(w90x900_device_kpi);
/* USB Device (Gadget)*/
static struct resource w90x900_usbgadget_resource[] = {
[0] = {
.start = W90X900_PA_USBDEV,
.end = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_USBD,
.end = IRQ_USBD,
.flags = IORESOURCE_IRQ,
}
};
struct platform_device w90x900_device_usbgadget = {
.name = "w90x900-usbgadget",
.id = -1,
.num_resources = ARRAY_SIZE(w90x900_usbgadget_resource),
.resource = w90x900_usbgadget_resource,
};
EXPORT_SYMBOL(w90x900_device_usbgadget);
static struct map_desc w90p910_iodesc[] __initdata = { static struct map_desc w90p910_iodesc[] __initdata = {
}; };
...@@ -88,12 +236,18 @@ static struct map_desc w90p910_iodesc[] __initdata = { ...@@ -88,12 +236,18 @@ static struct map_desc w90p910_iodesc[] __initdata = {
static struct platform_device *w90p910evb_dev[] __initdata = { static struct platform_device *w90p910evb_dev[] __initdata = {
&w90p910_serial_device, &w90p910_serial_device,
&w90p910_flash_device, &w90p910_flash_device,
&w90x900_device_usb_ehci,
&w90x900_device_usb_ohci,
&w90x900_device_ts,
&w90x900_device_rtc,
&w90x900_device_kpi,
&w90x900_device_usbgadget,
}; };
static void __init w90p910evb_map_io(void) static void __init w90p910evb_map_io(void)
{ {
w90p910_map_io(w90p910_iodesc, ARRAY_SIZE(w90p910_iodesc)); w90p910_map_io(w90p910_iodesc, ARRAY_SIZE(w90p910_iodesc));
w90p910_init_clocks(0); w90p910_init_clocks();
} }
static void __init w90p910evb_init(void) static void __init w90p910evb_init(void)
......
/*
* linux/arch/arm/mach-w90x900/mfp-w90p910.c
*
* Copyright (c) 2008 Nuvoton technology corporation
*
* Wan ZongShun <mcuos.com@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;version 2 of the License.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/string.h>
#include <linux/clk.h>
#include <linux/mutex.h>
#include <linux/io.h>
#include <mach/hardware.h>
#define REG_MFSEL (W90X900_VA_GCR + 0xC)
#define GPSELF (0x01 << 1)
#define GPSELC (0x03 << 2)
#define ENKPI (0x02 << 2)
#define ENNAND (0x01 << 2)
#define GPSELEI0 (0x01 << 26)
#define GPSELEI1 (0x01 << 27)
static DECLARE_MUTEX(mfp_sem);
void mfp_set_groupf(struct device *dev)
{
unsigned long mfpen;
const char *dev_id;
BUG_ON(!dev);
down(&mfp_sem);
dev_id = dev_name(dev);
mfpen = __raw_readl(REG_MFSEL);
if (strcmp(dev_id, "w90p910-emc") == 0)
mfpen |= GPSELF;/*enable mac*/
else
mfpen &= ~GPSELF;/*GPIOF[9:0]*/
__raw_writel(mfpen, REG_MFSEL);
up(&mfp_sem);
}
EXPORT_SYMBOL(mfp_set_groupf);
void mfp_set_groupc(struct device *dev)
{
unsigned long mfpen;
const char *dev_id;
BUG_ON(!dev);
down(&mfp_sem);
dev_id = dev_name(dev);
mfpen = __raw_readl(REG_MFSEL);
if (strcmp(dev_id, "w90p910-lcd") == 0)
mfpen |= GPSELC;/*enable lcd*/
else if (strcmp(dev_id, "w90p910-kpi") == 0) {
mfpen &= (~GPSELC);/*enable kpi*/
mfpen |= ENKPI;
} else if (strcmp(dev_id, "w90p910-nand") == 0) {
mfpen &= (~GPSELC);/*enable nand*/
mfpen |= ENNAND;
} else
mfpen &= (~GPSELC);/*GPIOC[14:0]*/
__raw_writel(mfpen, REG_MFSEL);
up(&mfp_sem);
}
EXPORT_SYMBOL(mfp_set_groupc);
void mfp_set_groupi(struct device *dev, int gpio)
{
unsigned long mfpen;
const char *dev_id;
BUG_ON(!dev);
down(&mfp_sem);
dev_id = dev_name(dev);
mfpen = __raw_readl(REG_MFSEL);
if (strcmp(dev_id, "w90p910-wdog") == 0)
mfpen |= GPSELEI1;/*enable wdog*/
else if (strcmp(dev_id, "w90p910-atapi") == 0)
mfpen |= GPSELEI0;/*enable atapi*/
__raw_writel(mfpen, REG_MFSEL);
up(&mfp_sem);
}
EXPORT_SYMBOL(mfp_set_groupi);
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
* *
* Based on linux/arch/arm/plat-s3c24xx/s3c244x.c by Ben Dooks * Based on linux/arch/arm/plat-s3c24xx/s3c244x.c by Ben Dooks
* *
* Copyright (c) 2008 Nuvoton technology corporation * Copyright (c) 2008 Nuvoton technology corporation.
* All rights reserved.
* *
* Wan ZongShun <mcuos.com@gmail.com> * Wan ZongShun <mcuos.com@gmail.com>
* *
...@@ -12,8 +11,7 @@ ...@@ -12,8 +11,7 @@
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation;version 2 of the License.
* (at your option) any later version.
* *
*/ */
...@@ -36,6 +34,7 @@ ...@@ -36,6 +34,7 @@
#include <mach/regs-serial.h> #include <mach/regs-serial.h>
#include "cpu.h" #include "cpu.h"
#include "clock.h"
/* Initial IO mappings */ /* Initial IO mappings */
...@@ -45,9 +44,52 @@ static struct map_desc w90p910_iodesc[] __initdata = { ...@@ -45,9 +44,52 @@ static struct map_desc w90p910_iodesc[] __initdata = {
IODESC_ENT(UART), IODESC_ENT(UART),
IODESC_ENT(TIMER), IODESC_ENT(TIMER),
IODESC_ENT(EBI), IODESC_ENT(EBI),
IODESC_ENT(USBEHCIHOST),
IODESC_ENT(USBOHCIHOST),
IODESC_ENT(ADC),
IODESC_ENT(RTC),
IODESC_ENT(KPI),
IODESC_ENT(USBDEV),
/*IODESC_ENT(LCD),*/ /*IODESC_ENT(LCD),*/
}; };
/* Initial clock declarations. */
static DEFINE_CLK(lcd, 0);
static DEFINE_CLK(audio, 1);
static DEFINE_CLK(fmi, 4);
static DEFINE_CLK(dmac, 5);
static DEFINE_CLK(atapi, 6);
static DEFINE_CLK(emc, 7);
static DEFINE_CLK(usbd, 8);
static DEFINE_CLK(usbh, 9);
static DEFINE_CLK(g2d, 10);;
static DEFINE_CLK(pwm, 18);
static DEFINE_CLK(ps2, 24);
static DEFINE_CLK(kpi, 25);
static DEFINE_CLK(wdt, 26);
static DEFINE_CLK(gdma, 27);
static DEFINE_CLK(adc, 28);
static DEFINE_CLK(usi, 29);
static struct clk_lookup w90p910_clkregs[] = {
DEF_CLKLOOK(&clk_lcd, "w90p910-lcd", NULL),
DEF_CLKLOOK(&clk_audio, "w90p910-audio", NULL),
DEF_CLKLOOK(&clk_fmi, "w90p910-fmi", NULL),
DEF_CLKLOOK(&clk_dmac, "w90p910-dmac", NULL),
DEF_CLKLOOK(&clk_atapi, "w90p910-atapi", NULL),
DEF_CLKLOOK(&clk_emc, "w90p910-emc", NULL),
DEF_CLKLOOK(&clk_usbd, "w90p910-usbd", NULL),
DEF_CLKLOOK(&clk_usbh, "w90p910-usbh", NULL),
DEF_CLKLOOK(&clk_g2d, "w90p910-g2d", NULL),
DEF_CLKLOOK(&clk_pwm, "w90p910-pwm", NULL),
DEF_CLKLOOK(&clk_ps2, "w90p910-ps2", NULL),
DEF_CLKLOOK(&clk_kpi, "w90p910-kpi", NULL),
DEF_CLKLOOK(&clk_wdt, "w90p910-wdt", NULL),
DEF_CLKLOOK(&clk_gdma, "w90p910-gdma", NULL),
DEF_CLKLOOK(&clk_adc, "w90p910-adc", NULL),
DEF_CLKLOOK(&clk_usi, "w90p910-usi", NULL),
};
/* Initial serial platform data */ /* Initial serial platform data */
struct plat_serial8250_port w90p910_uart_data[] = { struct plat_serial8250_port w90p910_uart_data[] = {
...@@ -77,8 +119,9 @@ void __init w90p910_map_io(struct map_desc *mach_desc, int mach_size) ...@@ -77,8 +119,9 @@ void __init w90p910_map_io(struct map_desc *mach_desc, int mach_size)
/*Init W90P910 clock*/ /*Init W90P910 clock*/
void __init w90p910_init_clocks(int xtal) void __init w90p910_init_clocks(void)
{ {
clks_register(w90p910_clkregs, ARRAY_SIZE(w90p910_clkregs));
} }
static int __init w90p910_init_cpu(void) static int __init w90p910_init_cpu(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment