aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/jz4740
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2011-03-23 17:08:53 -0400
committerRalf Baechle <ralf@linux-mips.org>2011-03-25 13:45:16 -0400
commit42b64f388c171a7a1a8962d93d9bae2c04da7738 (patch)
tree9a5633124bc37814f09e5c60f3a14012fbe1583c /arch/mips/jz4740
parentdb00bed4baa8951b579519e90d8d7f215db2827a (diff)
MIPS: JZ4740: Convert to new irq functions
Convert the JZ4740 intc and gpio irq chips to use newstyle irq functions. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> To: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/2181/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/jz4740')
-rw-r--r--arch/mips/jz4740/gpio.c93
-rw-r--r--arch/mips/jz4740/irq.c32
2 files changed, 67 insertions, 58 deletions
diff --git a/arch/mips/jz4740/gpio.c b/arch/mips/jz4740/gpio.c
index 88e6aeda5bf1..1e28b758de1f 100644
--- a/arch/mips/jz4740/gpio.c
+++ b/arch/mips/jz4740/gpio.c
@@ -102,9 +102,9 @@ static inline struct jz_gpio_chip *gpio_chip_to_jz_gpio_chip(struct gpio_chip *g
102 return container_of(gpio_chip, struct jz_gpio_chip, gpio_chip); 102 return container_of(gpio_chip, struct jz_gpio_chip, gpio_chip);
103} 103}
104 104
105static inline struct jz_gpio_chip *irq_to_jz_gpio_chip(unsigned int irq) 105static inline struct jz_gpio_chip *irq_to_jz_gpio_chip(struct irq_data *data)
106{ 106{
107 return get_irq_chip_data(irq); 107 return irq_data_get_irq_chip_data(data);
108} 108}
109 109
110static inline void jz_gpio_write_bit(unsigned int gpio, unsigned int reg) 110static inline void jz_gpio_write_bit(unsigned int gpio, unsigned int reg)
@@ -325,62 +325,63 @@ static void jz_gpio_irq_demux_handler(unsigned int irq, struct irq_desc *desc)
325 generic_handle_irq(gpio_irq); 325 generic_handle_irq(gpio_irq);
326}; 326};
327 327
328static inline void jz_gpio_set_irq_bit(unsigned int irq, unsigned int reg) 328static inline void jz_gpio_set_irq_bit(struct irq_data *data, unsigned int reg)
329{ 329{
330 struct jz_gpio_chip *chip = irq_to_jz_gpio_chip(irq); 330 struct jz_gpio_chip *chip = irq_to_jz_gpio_chip(data);
331 writel(IRQ_TO_BIT(irq), chip->base + reg); 331 writel(IRQ_TO_BIT(data->irq), chip->base + reg);
332} 332}
333 333
334static void jz_gpio_irq_mask(unsigned int irq) 334static void jz_gpio_irq_mask(struct irq_data *data)
335{ 335{
336 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_MASK_SET); 336 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_MASK_SET);
337}; 337};
338 338
339static void jz_gpio_irq_unmask(unsigned int irq) 339static void jz_gpio_irq_unmask(struct irq_data *data)
340{ 340{
341 struct jz_gpio_chip *chip = irq_to_jz_gpio_chip(irq); 341 struct jz_gpio_chip *chip = irq_to_jz_gpio_chip(data);
342 342
343 jz_gpio_check_trigger_both(chip, irq); 343 jz_gpio_check_trigger_both(chip, data->irq);
344 344
345 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_MASK_CLEAR); 345 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_MASK_CLEAR);
346}; 346};
347 347
348/* TODO: Check if function is gpio */ 348/* TODO: Check if function is gpio */
349static unsigned int jz_gpio_irq_startup(unsigned int irq) 349static unsigned int jz_gpio_irq_startup(struct irq_data *data)
350{ 350{
351 struct irq_desc *desc = irq_to_desc(irq); 351 struct irq_desc *desc = irq_to_desc(data->irq);
352 352
353 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_SELECT_SET); 353 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_SELECT_SET);
354 354
355 desc->status &= ~IRQ_MASKED; 355 desc->status &= ~IRQ_MASKED;
356 jz_gpio_irq_unmask(irq); 356 jz_gpio_irq_unmask(data);
357 357
358 return 0; 358 return 0;
359} 359}
360 360
361static void jz_gpio_irq_shutdown(unsigned int irq) 361static void jz_gpio_irq_shutdown(struct irq_data *data)
362{ 362{
363 struct irq_desc *desc = irq_to_desc(irq); 363 struct irq_desc *desc = irq_to_desc(data->irq);
364 364
365 jz_gpio_irq_mask(irq); 365 jz_gpio_irq_mask(data);
366 desc->status |= IRQ_MASKED; 366 desc->status |= IRQ_MASKED;
367 367
368 /* Set direction to input */ 368 /* Set direction to input */
369 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_DIRECTION_CLEAR); 369 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_DIRECTION_CLEAR);
370 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_SELECT_CLEAR); 370 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_SELECT_CLEAR);
371} 371}
372 372
373static void jz_gpio_irq_ack(unsigned int irq) 373static void jz_gpio_irq_ack(struct irq_data *data)
374{ 374{
375 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_FLAG_CLEAR); 375 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_FLAG_CLEAR);
376}; 376};
377 377
378static int jz_gpio_irq_set_type(unsigned int irq, unsigned int flow_type) 378static int jz_gpio_irq_set_type(struct irq_data *data, unsigned int flow_type)
379{ 379{
380 struct jz_gpio_chip *chip = irq_to_jz_gpio_chip(irq); 380 struct jz_gpio_chip *chip = irq_to_jz_gpio_chip(data);
381 struct irq_desc *desc = irq_to_desc(irq); 381 struct irq_desc *desc = irq_to_desc(data->irq);
382 unsigned int irq = data->irq;
382 383
383 jz_gpio_irq_mask(irq); 384 jz_gpio_irq_mask(data);
384 385
385 if (flow_type == IRQ_TYPE_EDGE_BOTH) { 386 if (flow_type == IRQ_TYPE_EDGE_BOTH) {
386 uint32_t value = readl(chip->base + JZ_REG_GPIO_PIN); 387 uint32_t value = readl(chip->base + JZ_REG_GPIO_PIN);
@@ -395,39 +396,39 @@ static int jz_gpio_irq_set_type(unsigned int irq, unsigned int flow_type)
395 396
396 switch (flow_type) { 397 switch (flow_type) {
397 case IRQ_TYPE_EDGE_RISING: 398 case IRQ_TYPE_EDGE_RISING:
398 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_DIRECTION_SET); 399 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_DIRECTION_SET);
399 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_TRIGGER_SET); 400 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_TRIGGER_SET);
400 break; 401 break;
401 case IRQ_TYPE_EDGE_FALLING: 402 case IRQ_TYPE_EDGE_FALLING:
402 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_DIRECTION_CLEAR); 403 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_DIRECTION_CLEAR);
403 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_TRIGGER_SET); 404 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_TRIGGER_SET);
404 break; 405 break;
405 case IRQ_TYPE_LEVEL_HIGH: 406 case IRQ_TYPE_LEVEL_HIGH:
406 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_DIRECTION_SET); 407 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_DIRECTION_SET);
407 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_TRIGGER_CLEAR); 408 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_TRIGGER_CLEAR);
408 break; 409 break;
409 case IRQ_TYPE_LEVEL_LOW: 410 case IRQ_TYPE_LEVEL_LOW:
410 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_DIRECTION_CLEAR); 411 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_DIRECTION_CLEAR);
411 jz_gpio_set_irq_bit(irq, JZ_REG_GPIO_TRIGGER_CLEAR); 412 jz_gpio_set_irq_bit(data, JZ_REG_GPIO_TRIGGER_CLEAR);
412 break; 413 break;
413 default: 414 default:
414 return -EINVAL; 415 return -EINVAL;
415 } 416 }
416 417
417 if (!(desc->status & IRQ_MASKED)) 418 if (!(desc->status & IRQ_MASKED))
418 jz_gpio_irq_unmask(irq); 419 jz_gpio_irq_unmask(data);
419 420
420 return 0; 421 return 0;
421} 422}
422 423
423static int jz_gpio_irq_set_wake(unsigned int irq, unsigned int on) 424static int jz_gpio_irq_set_wake(struct irq_data *data, unsigned int on)
424{ 425{
425 struct jz_gpio_chip *chip = irq_to_jz_gpio_chip(irq); 426 struct jz_gpio_chip *chip = irq_to_jz_gpio_chip(data);
426 spin_lock(&chip->lock); 427 spin_lock(&chip->lock);
427 if (on) 428 if (on)
428 chip->wakeup |= IRQ_TO_BIT(irq); 429 chip->wakeup |= IRQ_TO_BIT(data->irq);
429 else 430 else
430 chip->wakeup &= ~IRQ_TO_BIT(irq); 431 chip->wakeup &= ~IRQ_TO_BIT(data->irq);
431 spin_unlock(&chip->lock); 432 spin_unlock(&chip->lock);
432 433
433 set_irq_wake(chip->irq, on); 434 set_irq_wake(chip->irq, on);
@@ -454,13 +455,13 @@ static struct lock_class_key gpio_lock_class;
454 }, \ 455 }, \
455 .irq_chip = { \ 456 .irq_chip = { \
456 .name = "GPIO Bank " # _bank, \ 457 .name = "GPIO Bank " # _bank, \
457 .mask = jz_gpio_irq_mask, \ 458 .irq_mask = jz_gpio_irq_mask, \
458 .unmask = jz_gpio_irq_unmask, \ 459 .irq_unmask = jz_gpio_irq_unmask, \
459 .ack = jz_gpio_irq_ack, \ 460 .irq_ack = jz_gpio_irq_ack, \
460 .startup = jz_gpio_irq_startup, \ 461 .irq_startup = jz_gpio_irq_startup, \
461 .shutdown = jz_gpio_irq_shutdown, \ 462 .irq_shutdown = jz_gpio_irq_shutdown, \
462 .set_type = jz_gpio_irq_set_type, \ 463 .irq_set_type = jz_gpio_irq_set_type, \
463 .set_wake = jz_gpio_irq_set_wake, \ 464 .irq_set_wake = jz_gpio_irq_set_wake, \
464 }, \ 465 }, \
465} 466}
466 467
diff --git a/arch/mips/jz4740/irq.c b/arch/mips/jz4740/irq.c
index 7d33ff83580f..dcc5593a9389 100644
--- a/arch/mips/jz4740/irq.c
+++ b/arch/mips/jz4740/irq.c
@@ -43,32 +43,37 @@ static uint32_t jz_intc_saved;
43 43
44#define IRQ_BIT(x) BIT((x) - JZ4740_IRQ_BASE) 44#define IRQ_BIT(x) BIT((x) - JZ4740_IRQ_BASE)
45 45
46static void intc_irq_unmask(unsigned int irq) 46static inline unsigned long intc_irq_bit(struct irq_data *data)
47{ 47{
48 writel(IRQ_BIT(irq), jz_intc_base + JZ_REG_INTC_CLEAR_MASK); 48 return (unsigned long)irq_data_get_irq_chip_data(data);
49} 49}
50 50
51static void intc_irq_mask(unsigned int irq) 51static void intc_irq_unmask(struct irq_data *data)
52{ 52{
53 writel(IRQ_BIT(irq), jz_intc_base + JZ_REG_INTC_SET_MASK); 53 writel(intc_irq_bit(data), jz_intc_base + JZ_REG_INTC_CLEAR_MASK);
54} 54}
55 55
56static int intc_irq_set_wake(unsigned int irq, unsigned int on) 56static void intc_irq_mask(struct irq_data *data)
57{
58 writel(intc_irq_bit(data), jz_intc_base + JZ_REG_INTC_SET_MASK);
59}
60
61static int intc_irq_set_wake(struct irq_data *data, unsigned int on)
57{ 62{
58 if (on) 63 if (on)
59 jz_intc_wakeup |= IRQ_BIT(irq); 64 jz_intc_wakeup |= intc_irq_bit(data);
60 else 65 else
61 jz_intc_wakeup &= ~IRQ_BIT(irq); 66 jz_intc_wakeup &= ~intc_irq_bit(data);
62 67
63 return 0; 68 return 0;
64} 69}
65 70
66static struct irq_chip intc_irq_type = { 71static struct irq_chip intc_irq_type = {
67 .name = "INTC", 72 .name = "INTC",
68 .mask = intc_irq_mask, 73 .irq_mask = intc_irq_mask,
69 .mask_ack = intc_irq_mask, 74 .irq_mask_ack = intc_irq_mask,
70 .unmask = intc_irq_unmask, 75 .irq_unmask = intc_irq_unmask,
71 .set_wake = intc_irq_set_wake, 76 .irq_set_wake = intc_irq_set_wake,
72}; 77};
73 78
74static irqreturn_t jz4740_cascade(int irq, void *data) 79static irqreturn_t jz4740_cascade(int irq, void *data)
@@ -95,8 +100,11 @@ void __init arch_init_irq(void)
95 100
96 jz_intc_base = ioremap(JZ4740_INTC_BASE_ADDR, 0x14); 101 jz_intc_base = ioremap(JZ4740_INTC_BASE_ADDR, 0x14);
97 102
103 /* Mask all irqs */
104 writel(0xffffffff, jz_intc_base + JZ_REG_INTC_SET_MASK);
105
98 for (i = JZ4740_IRQ_BASE; i < JZ4740_IRQ_BASE + 32; i++) { 106 for (i = JZ4740_IRQ_BASE; i < JZ4740_IRQ_BASE + 32; i++) {
99 intc_irq_mask(i); 107 set_irq_chip_data(i, (void *)IRQ_BIT(i));
100 set_irq_chip_and_handler(i, &intc_irq_type, handle_level_irq); 108 set_irq_chip_and_handler(i, &intc_irq_type, handle_level_irq);
101 } 109 }
102 110