Commit a8e82cc7 authored by Yoichi Yuasa's avatar Yoichi Yuasa Committed by Linus Torvalds

[PATCH] mips: update CMU

This patch updates cmu.c to get the resource by standard method.
Signed-off-by: default avatarYoichi Yuasa <yuasa@hh.iij4u.or.jp>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ce4ddcb1
...@@ -288,4 +288,4 @@ static int __init vr41xx_pciu_init(void) ...@@ -288,4 +288,4 @@ static int __init vr41xx_pciu_init(void)
return 0; return 0;
} }
early_initcall(vr41xx_pciu_init); arch_initcall(vr41xx_pciu_init);
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (C) 2001-2002 MontaVista Software Inc. * Copyright (C) 2001-2002 MontaVista Software Inc.
* Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
* Copuright (C) 2003-2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> * Copuright (C) 2003-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
* *
* 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
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
* - Added support for NEC VR4133. * - Added support for NEC VR4133.
*/ */
#include <linux/init.h> #include <linux/init.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -37,8 +39,16 @@ ...@@ -37,8 +39,16 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/vr41xx/vr41xx.h> #include <asm/vr41xx/vr41xx.h>
#define CMUCLKMSK_TYPE1 KSEG1ADDR(0x0b000060) #define CMU_TYPE1_BASE 0x0b000060UL
#define CMUCLKMSK_TYPE2 KSEG1ADDR(0x0f000060) #define CMU_TYPE1_SIZE 0x4
#define CMU_TYPE2_BASE 0x0f000060UL
#define CMU_TYPE2_SIZE 0x4
#define CMU_TYPE3_BASE 0x0f000060UL
#define CMU_TYPE3_SIZE 0x8
#define CMUCLKMSK 0x0
#define MSKPIU 0x0001 #define MSKPIU 0x0001
#define MSKSIU 0x0002 #define MSKSIU 0x0002
#define MSKAIU 0x0004 #define MSKAIU 0x0004
...@@ -52,19 +62,17 @@ ...@@ -52,19 +62,17 @@
#define MSKFFIR 0x0400 #define MSKFFIR 0x0400
#define MSKSCSI 0x1000 #define MSKSCSI 0x1000
#define MSKPPCIU 0x2000 #define MSKPPCIU 0x2000
#define CMUCLKMSK2 KSEG1ADDR(0x0f000064) #define CMUCLKMSK2 0x4
#define MSKCEU 0x0001 #define MSKCEU 0x0001
#define MSKMAC0 0x0002 #define MSKMAC0 0x0002
#define MSKMAC1 0x0004 #define MSKMAC1 0x0004
static uint32_t cmu_base; static void __iomem *cmu_base;
static uint16_t cmuclkmsk, cmuclkmsk2; static uint16_t cmuclkmsk, cmuclkmsk2;
static spinlock_t cmu_lock; static spinlock_t cmu_lock;
#define read_cmuclkmsk() readw(cmu_base) #define cmu_read(offset) readw(cmu_base + (offset))
#define read_cmuclkmsk2() readw(CMUCLKMSK2) #define cmu_write(offset, value) writew((value), cmu_base + (offset))
#define write_cmuclkmsk() writew(cmuclkmsk, cmu_base)
#define write_cmuclkmsk2() writew(cmuclkmsk2, CMUCLKMSK2)
void vr41xx_supply_clock(vr41xx_clock_t clock) void vr41xx_supply_clock(vr41xx_clock_t clock)
{ {
...@@ -120,13 +128,15 @@ void vr41xx_supply_clock(vr41xx_clock_t clock) ...@@ -120,13 +128,15 @@ void vr41xx_supply_clock(vr41xx_clock_t clock)
if (clock == CEU_CLOCK || clock == ETHER0_CLOCK || if (clock == CEU_CLOCK || clock == ETHER0_CLOCK ||
clock == ETHER1_CLOCK) clock == ETHER1_CLOCK)
write_cmuclkmsk2(); cmu_write(CMUCLKMSK2, cmuclkmsk2);
else else
write_cmuclkmsk(); cmu_write(CMUCLKMSK, cmuclkmsk);
spin_unlock_irq(&cmu_lock); spin_unlock_irq(&cmu_lock);
} }
EXPORT_SYMBOL_GPL(vr41xx_supply_clock);
void vr41xx_mask_clock(vr41xx_clock_t clock) void vr41xx_mask_clock(vr41xx_clock_t clock)
{ {
spin_lock_irq(&cmu_lock); spin_lock_irq(&cmu_lock);
...@@ -193,38 +203,55 @@ void vr41xx_mask_clock(vr41xx_clock_t clock) ...@@ -193,38 +203,55 @@ void vr41xx_mask_clock(vr41xx_clock_t clock)
if (clock == CEU_CLOCK || clock == ETHER0_CLOCK || if (clock == CEU_CLOCK || clock == ETHER0_CLOCK ||
clock == ETHER1_CLOCK) clock == ETHER1_CLOCK)
write_cmuclkmsk2(); cmu_write(CMUCLKMSK2, cmuclkmsk2);
else else
write_cmuclkmsk(); cmu_write(CMUCLKMSK, cmuclkmsk);
spin_unlock_irq(&cmu_lock); spin_unlock_irq(&cmu_lock);
} }
EXPORT_SYMBOL_GPL(vr41xx_mask_clock);
static int __init vr41xx_cmu_init(void) static int __init vr41xx_cmu_init(void)
{ {
unsigned long start, size;
switch (current_cpu_data.cputype) { switch (current_cpu_data.cputype) {
case CPU_VR4111: case CPU_VR4111:
case CPU_VR4121: case CPU_VR4121:
cmu_base = CMUCLKMSK_TYPE1; start = CMU_TYPE1_BASE;
size = CMU_TYPE1_SIZE;
break; break;
case CPU_VR4122: case CPU_VR4122:
case CPU_VR4131: case CPU_VR4131:
cmu_base = CMUCLKMSK_TYPE2; start = CMU_TYPE2_BASE;
size = CMU_TYPE2_SIZE;
break; break;
case CPU_VR4133: case CPU_VR4133:
cmu_base = CMUCLKMSK_TYPE2; start = CMU_TYPE3_BASE;
cmuclkmsk2 = read_cmuclkmsk2(); size = CMU_TYPE3_SIZE;
break; break;
default: default:
panic("Unexpected CPU of NEC VR4100 series"); panic("Unexpected CPU of NEC VR4100 series");
break; break;
} }
cmuclkmsk = read_cmuclkmsk(); if (request_mem_region(start, size, "CMU") == NULL)
return -EBUSY;
cmu_base = ioremap(start, size);
if (cmu_base == NULL) {
release_mem_region(start, size);
return -EBUSY;
}
cmuclkmsk = cmu_read(CMUCLKMSK);
if (current_cpu_data.cputype == CPU_VR4133)
cmuclkmsk2 = cmu_read(CMUCLKMSK2);
spin_lock_init(&cmu_lock); spin_lock_init(&cmu_lock);
return 0; return 0;
} }
early_initcall(vr41xx_cmu_init); core_initcall(vr41xx_cmu_init);
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