16 #include <linux/kernel.h>
19 #include <linux/serial.h>
20 #include <linux/tty.h>
22 #include <linux/serial_core.h>
24 #include <linux/bitops.h>
25 #include <linux/time.h>
26 #include <linux/timex.h>
30 #include <linux/export.h>
34 #include <mach/hardware.h>
36 #include <asm/uaccess.h>
37 #include <asm/pgtable.h>
41 #include <asm/system_misc.h>
47 static void __init ixp4xx_clocksource_init(
void);
48 static void __init ixp4xx_clockevent_init(
void);
49 static struct clock_event_device clockevent_ixp4xx;
96 static unsigned long long ixp4xx_irq_edge = 0;
101 static signed char irq2gpio[32] = {
102 -1, -1, -1, -1, -1, -1, 0, 1,
103 -1, -1, -1, -1, -1, -1, -1, -1,
104 -1, -1, -1, 2, 3, 4, 5, 6,
105 7, 8, 9, 10, 11, 12, -1, -1,
108 static int ixp4xx_gpio_to_irq(
struct gpio_chip *
chip,
unsigned gpio)
112 for (irq = 0; irq < 32; irq++) {
113 if (irq2gpio[irq] == gpio)
121 int gpio = (irq < 32) ? irq2gpio[irq] : -
EINVAL;
130 static int ixp4xx_set_irq_type(
struct irq_data *
d,
unsigned int type)
135 volatile u32 *int_reg;
169 ixp4xx_irq_edge |= (1 << d->
irq);
171 ixp4xx_irq_edge &= ~(1 << d->
irq);
195 static void ixp4xx_irq_mask(
struct irq_data *d)
203 static void ixp4xx_irq_ack(
struct irq_data *d)
205 int line = (d->
irq < 32) ? irq2gpio[d->
irq] : -1;
215 static void ixp4xx_irq_unmask(
struct irq_data *d)
217 if (!(ixp4xx_irq_edge & (1 << d->
irq)))
226 static struct irq_chip ixp4xx_irq_chip = {
228 .irq_ack = ixp4xx_irq_ack,
229 .irq_mask = ixp4xx_irq_mask,
230 .irq_unmask = ixp4xx_irq_unmask,
231 .irq_set_type = ixp4xx_set_irq_type,
260 irq_set_chip_and_handler(i, &ixp4xx_irq_chip,
280 evt->event_handler(evt);
285 static struct irqaction ixp4xx_timer_irq = {
288 .handler = ixp4xx_timer_interrupt,
289 .dev_id = &clockevent_ixp4xx,
306 ixp4xx_clocksource_init();
307 ixp4xx_clockevent_init();
318 memcpy(&ixp4xx_udc_info, info,
sizeof *info);
321 static struct resource ixp4xx_udc_resources[] = {
339 .name =
"pxa25x-udc",
342 .resource = ixp4xx_udc_resources,
344 .platform_data = &ixp4xx_udc_info,
352 static struct resource ixp46x_i2c_resources[] = {
370 .name =
"IOP3xx-I2C",
373 .resource = ixp46x_i2c_resources
377 &ixp46x_i2c_controller
383 static int ixp4xx_gpio_direction_input(
struct gpio_chip *chip,
unsigned gpio)
390 static int ixp4xx_gpio_direction_output(
struct gpio_chip *chip,
unsigned gpio,
399 static int ixp4xx_gpio_get_value(
struct gpio_chip *chip,
unsigned gpio)
408 static void ixp4xx_gpio_set_value(
struct gpio_chip *chip,
unsigned gpio,
414 static struct gpio_chip ixp4xx_gpio_chip = {
415 .label =
"IXP4XX_GPIO_CHIP",
416 .direction_input = ixp4xx_gpio_direction_input,
417 .direction_output = ixp4xx_gpio_direction_output,
418 .get = ixp4xx_gpio_get_value,
419 .set = ixp4xx_gpio_set_value,
420 .to_irq = ixp4xx_gpio_to_irq,
427 ixp4xx_exp_bus_size =
SZ_16M;
439 for (region = 0; region < 7; region++) {
441 ixp4xx_exp_bus_size =
SZ_32M;
447 printk(
"IXP4xx: Using %luMiB expansion bus window size\n",
448 ixp4xx_exp_bus_size >> 20);
454 static u32 notrace ixp4xx_read_sched_clock(
void)
470 static void __init ixp4xx_clocksource_init(
void)
475 ixp4xx_clocksource_read);
481 static int ixp4xx_set_next_event(
unsigned long evt,
482 struct clock_event_device *
unused)
491 static void ixp4xx_set_mode(
enum clock_event_mode
mode,
492 struct clock_event_device *evt)
495 unsigned long osrt = *
IXP4XX_OSRT1 & ~IXP4XX_OST_RELOAD_MASK;
498 case CLOCK_EVT_MODE_PERIODIC:
499 osrt =
LATCH & ~IXP4XX_OST_RELOAD_MASK;
502 case CLOCK_EVT_MODE_ONESHOT:
507 case CLOCK_EVT_MODE_SHUTDOWN:
510 case CLOCK_EVT_MODE_RESUME:
513 case CLOCK_EVT_MODE_UNUSED:
522 static struct clock_event_device clockevent_ixp4xx = {
523 .name =
"ixp4xx timer1",
524 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
527 .set_mode = ixp4xx_set_mode,
528 .set_next_event = ixp4xx_set_next_event,
531 static void __init ixp4xx_clockevent_init(
void)
534 clockevent_ixp4xx.shift);
535 clockevent_ixp4xx.max_delta_ns =
537 clockevent_ixp4xx.min_delta_ns =
546 if ( 1 && mode ==
's') {
564 #ifdef CONFIG_IXP4XX_INDIRECT_PCI
572 static void __iomem *ixp4xx_ioremap_caller(
unsigned long addr,
size_t size,
573 unsigned int mtype,
void *
caller)
575 if (!is_pci_memory(addr))
581 static void ixp4xx_iounmap(
void __iomem *addr)