diff options
| author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-06-25 06:44:44 -0400 |
|---|---|---|
| committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-06-25 06:44:44 -0400 |
| commit | 76a9f26c9e40e9c0ed5dc8f0cedd74e733f0088d (patch) | |
| tree | 8e2db4ba9263e92d264ef469c7dac28078f63874 /arch | |
| parent | 9bf2aa129a107a0e9e2a5318d35aca731ae7e666 (diff) | |
| parent | dfd8317d3340f03bc06eba6b58f0ec0861da4a13 (diff) | |
Merge branch 'master' of /home/trondmy/kernel/linux-2.6/
Diffstat (limited to 'arch')
56 files changed, 4705 insertions, 1518 deletions
diff --git a/arch/arm/kernel/iwmmxt.S b/arch/arm/kernel/iwmmxt.S index af9e0ae952d5..a3bae95e536c 100644 --- a/arch/arm/kernel/iwmmxt.S +++ b/arch/arm/kernel/iwmmxt.S | |||
| @@ -273,7 +273,7 @@ ENTRY(iwmmxt_task_restore) | |||
| 273 | * | 273 | * |
| 274 | * r0 = previous task_struct pointer (must be preserved) | 274 | * r0 = previous task_struct pointer (must be preserved) |
| 275 | * r1 = previous thread_info pointer | 275 | * r1 = previous thread_info pointer |
| 276 | * r2 = next thread_info.cpu_domain pointer (must be preserved) | 276 | * r2 = next thread_info pointer (must be preserved) |
| 277 | * | 277 | * |
| 278 | * Called only from __switch_to with task preemption disabled. | 278 | * Called only from __switch_to with task preemption disabled. |
| 279 | * No need to care about preserving r4 and above. | 279 | * No need to care about preserving r4 and above. |
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index f094277485c8..1ce05ec086c6 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c | |||
| @@ -134,17 +134,6 @@ sys_sigaction(int sig, const struct old_sigaction __user *act, | |||
| 134 | 134 | ||
| 135 | #ifdef CONFIG_IWMMXT | 135 | #ifdef CONFIG_IWMMXT |
| 136 | 136 | ||
| 137 | /* iwmmxt_area is 0x98 bytes long, preceeded by 8 bytes of signature */ | ||
| 138 | #define IWMMXT_STORAGE_SIZE (0x98 + 8) | ||
| 139 | #define IWMMXT_MAGIC0 0x12ef842a | ||
| 140 | #define IWMMXT_MAGIC1 0x1c07ca71 | ||
| 141 | |||
| 142 | struct iwmmxt_sigframe { | ||
| 143 | unsigned long magic0; | ||
| 144 | unsigned long magic1; | ||
| 145 | unsigned long storage[0x98/4]; | ||
| 146 | }; | ||
| 147 | |||
| 148 | static int preserve_iwmmxt_context(struct iwmmxt_sigframe *frame) | 137 | static int preserve_iwmmxt_context(struct iwmmxt_sigframe *frame) |
| 149 | { | 138 | { |
| 150 | char kbuf[sizeof(*frame) + 8]; | 139 | char kbuf[sizeof(*frame) + 8]; |
| @@ -152,8 +141,8 @@ static int preserve_iwmmxt_context(struct iwmmxt_sigframe *frame) | |||
| 152 | 141 | ||
| 153 | /* the iWMMXt context must be 64 bit aligned */ | 142 | /* the iWMMXt context must be 64 bit aligned */ |
| 154 | kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7); | 143 | kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7); |
| 155 | kframe->magic0 = IWMMXT_MAGIC0; | 144 | kframe->magic = IWMMXT_MAGIC; |
| 156 | kframe->magic1 = IWMMXT_MAGIC1; | 145 | kframe->size = IWMMXT_STORAGE_SIZE; |
| 157 | iwmmxt_task_copy(current_thread_info(), &kframe->storage); | 146 | iwmmxt_task_copy(current_thread_info(), &kframe->storage); |
| 158 | return __copy_to_user(frame, kframe, sizeof(*frame)); | 147 | return __copy_to_user(frame, kframe, sizeof(*frame)); |
| 159 | } | 148 | } |
| @@ -167,8 +156,8 @@ static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame) | |||
| 167 | kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7); | 156 | kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7); |
| 168 | if (__copy_from_user(kframe, frame, sizeof(*frame))) | 157 | if (__copy_from_user(kframe, frame, sizeof(*frame))) |
| 169 | return -1; | 158 | return -1; |
| 170 | if (kframe->magic0 != IWMMXT_MAGIC0 || | 159 | if (kframe->magic != IWMMXT_MAGIC || |
| 171 | kframe->magic1 != IWMMXT_MAGIC1) | 160 | kframe->size != IWMMXT_STORAGE_SIZE) |
| 172 | return -1; | 161 | return -1; |
| 173 | iwmmxt_task_restore(current_thread_info(), &kframe->storage); | 162 | iwmmxt_task_restore(current_thread_info(), &kframe->storage); |
| 174 | return 0; | 163 | return 0; |
| @@ -177,70 +166,61 @@ static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame) | |||
| 177 | #endif | 166 | #endif |
| 178 | 167 | ||
| 179 | /* | 168 | /* |
| 180 | * Auxiliary signal frame. This saves stuff like FP state. | ||
| 181 | * The layout of this structure is not part of the user ABI. | ||
| 182 | */ | ||
| 183 | struct aux_sigframe { | ||
| 184 | #ifdef CONFIG_IWMMXT | ||
| 185 | struct iwmmxt_sigframe iwmmxt; | ||
| 186 | #endif | ||
| 187 | #ifdef CONFIG_VFP | ||
| 188 | union vfp_state vfp; | ||
| 189 | #endif | ||
| 190 | }; | ||
| 191 | |||
| 192 | /* | ||
| 193 | * Do a signal return; undo the signal stack. These are aligned to 64-bit. | 169 | * Do a signal return; undo the signal stack. These are aligned to 64-bit. |
| 194 | */ | 170 | */ |
| 195 | struct sigframe { | 171 | struct sigframe { |
| 196 | struct sigcontext sc; | 172 | struct ucontext uc; |
| 197 | unsigned long extramask[_NSIG_WORDS-1]; | ||
| 198 | unsigned long retcode[2]; | 173 | unsigned long retcode[2]; |
| 199 | struct aux_sigframe aux __attribute__((aligned(8))); | ||
| 200 | }; | 174 | }; |
| 201 | 175 | ||
| 202 | struct rt_sigframe { | 176 | struct rt_sigframe { |
| 203 | struct siginfo __user *pinfo; | ||
| 204 | void __user *puc; | ||
| 205 | struct siginfo info; | 177 | struct siginfo info; |
| 206 | struct ucontext uc; | 178 | struct sigframe sig; |
| 207 | unsigned long retcode[2]; | ||
| 208 | struct aux_sigframe aux __attribute__((aligned(8))); | ||
| 209 | }; | 179 | }; |
| 210 | 180 | ||
| 211 | static int | 181 | static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf) |
| 212 | restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, | ||
| 213 | struct aux_sigframe __user *aux) | ||
| 214 | { | 182 | { |
| 215 | int err = 0; | 183 | struct aux_sigframe __user *aux; |
| 184 | sigset_t set; | ||
| 185 | int err; | ||
| 186 | |||
| 187 | err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); | ||
| 188 | if (err == 0) { | ||
| 189 | sigdelsetmask(&set, ~_BLOCKABLE); | ||
| 190 | spin_lock_irq(¤t->sighand->siglock); | ||
| 191 | current->blocked = set; | ||
| 192 | recalc_sigpending(); | ||
| 193 | spin_unlock_irq(¤t->sighand->siglock); | ||
| 194 | } | ||
| 216 | 195 | ||
| 217 | __get_user_error(regs->ARM_r0, &sc->arm_r0, err); | 196 | __get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err); |
| 218 | __get_user_error(regs->ARM_r1, &sc->arm_r1, err); | 197 | __get_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err); |
| 219 | __get_user_error(regs->ARM_r2, &sc->arm_r2, err); | 198 | __get_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err); |
| 220 | __get_user_error(regs->ARM_r3, &sc->arm_r3, err); | 199 | __get_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err); |
| 221 | __get_user_error(regs->ARM_r4, &sc->arm_r4, err); | 200 | __get_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err); |
| 222 | __get_user_error(regs->ARM_r5, &sc->arm_r5, err); | 201 | __get_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err); |
| 223 | __get_user_error(regs->ARM_r6, &sc->arm_r6, err); | 202 | __get_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err); |
| 224 | __get_user_error(regs->ARM_r7, &sc->arm_r7, err); | 203 | __get_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err); |
| 225 | __get_user_error(regs->ARM_r8, &sc->arm_r8, err); | 204 | __get_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err); |
| 226 | __get_user_error(regs->ARM_r9, &sc->arm_r9, err); | 205 | __get_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err); |
| 227 | __get_user_error(regs->ARM_r10, &sc->arm_r10, err); | 206 | __get_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err); |
| 228 | __get_user_error(regs->ARM_fp, &sc->arm_fp, err); | 207 | __get_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err); |
| 229 | __get_user_error(regs->ARM_ip, &sc->arm_ip, err); | 208 | __get_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err); |
| 230 | __get_user_error(regs->ARM_sp, &sc->arm_sp, err); | 209 | __get_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err); |
| 231 | __get_user_error(regs->ARM_lr, &sc->arm_lr, err); | 210 | __get_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err); |
| 232 | __get_user_error(regs->ARM_pc, &sc->arm_pc, err); | 211 | __get_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err); |
| 233 | __get_user_error(regs->ARM_cpsr, &sc->arm_cpsr, err); | 212 | __get_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err); |
| 234 | 213 | ||
| 235 | err |= !valid_user_regs(regs); | 214 | err |= !valid_user_regs(regs); |
| 236 | 215 | ||
| 216 | aux = (struct aux_sigframe __user *) sf->uc.uc_regspace; | ||
| 237 | #ifdef CONFIG_IWMMXT | 217 | #ifdef CONFIG_IWMMXT |
| 238 | if (err == 0 && test_thread_flag(TIF_USING_IWMMXT)) | 218 | if (err == 0 && test_thread_flag(TIF_USING_IWMMXT)) |
| 239 | err |= restore_iwmmxt_context(&aux->iwmmxt); | 219 | err |= restore_iwmmxt_context(&aux->iwmmxt); |
| 240 | #endif | 220 | #endif |
| 241 | #ifdef CONFIG_VFP | 221 | #ifdef CONFIG_VFP |
| 242 | // if (err == 0) | 222 | // if (err == 0) |
| 243 | // err |= vfp_restore_state(&aux->vfp); | 223 | // err |= vfp_restore_state(&sf->aux.vfp); |
| 244 | #endif | 224 | #endif |
| 245 | 225 | ||
| 246 | return err; | 226 | return err; |
| @@ -249,7 +229,6 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, | |||
| 249 | asmlinkage int sys_sigreturn(struct pt_regs *regs) | 229 | asmlinkage int sys_sigreturn(struct pt_regs *regs) |
| 250 | { | 230 | { |
| 251 | struct sigframe __user *frame; | 231 | struct sigframe __user *frame; |
| 252 | sigset_t set; | ||
| 253 | 232 | ||
| 254 | /* Always make any pending restarted system calls return -EINTR */ | 233 | /* Always make any pending restarted system calls return -EINTR */ |
| 255 | current_thread_info()->restart_block.fn = do_no_restart_syscall; | 234 | current_thread_info()->restart_block.fn = do_no_restart_syscall; |
| @@ -266,19 +245,8 @@ asmlinkage int sys_sigreturn(struct pt_regs *regs) | |||
| 266 | 245 | ||
| 267 | if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) | 246 | if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) |
| 268 | goto badframe; | 247 | goto badframe; |
| 269 | if (__get_user(set.sig[0], &frame->sc.oldmask) | ||
| 270 | || (_NSIG_WORDS > 1 | ||
| 271 | && __copy_from_user(&set.sig[1], &frame->extramask, | ||
| 272 | sizeof(frame->extramask)))) | ||
| 273 | goto badframe; | ||
| 274 | |||
| 275 | sigdelsetmask(&set, ~_BLOCKABLE); | ||
| 276 | spin_lock_irq(¤t->sighand->siglock); | ||
| 277 | current->blocked = set; | ||
| 278 | recalc_sigpending(); | ||
| 279 | spin_unlock_irq(¤t->sighand->siglock); | ||
| 280 | 248 | ||
| 281 | if (restore_sigcontext(regs, &frame->sc, &frame->aux)) | 249 | if (restore_sigframe(regs, frame)) |
| 282 | goto badframe; | 250 | goto badframe; |
| 283 | 251 | ||
| 284 | /* Send SIGTRAP if we're single-stepping */ | 252 | /* Send SIGTRAP if we're single-stepping */ |
| @@ -297,7 +265,6 @@ badframe: | |||
| 297 | asmlinkage int sys_rt_sigreturn(struct pt_regs *regs) | 265 | asmlinkage int sys_rt_sigreturn(struct pt_regs *regs) |
| 298 | { | 266 | { |
| 299 | struct rt_sigframe __user *frame; | 267 | struct rt_sigframe __user *frame; |
| 300 | sigset_t set; | ||
| 301 | 268 | ||
| 302 | /* Always make any pending restarted system calls return -EINTR */ | 269 | /* Always make any pending restarted system calls return -EINTR */ |
| 303 | current_thread_info()->restart_block.fn = do_no_restart_syscall; | 270 | current_thread_info()->restart_block.fn = do_no_restart_syscall; |
| @@ -314,19 +281,11 @@ asmlinkage int sys_rt_sigreturn(struct pt_regs *regs) | |||
| 314 | 281 | ||
| 315 | if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) | 282 | if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) |
| 316 | goto badframe; | 283 | goto badframe; |
| 317 | if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) | ||
| 318 | goto badframe; | ||
| 319 | 284 | ||
| 320 | sigdelsetmask(&set, ~_BLOCKABLE); | 285 | if (restore_sigframe(regs, &frame->sig)) |
| 321 | spin_lock_irq(¤t->sighand->siglock); | ||
| 322 | current->blocked = set; | ||
| 323 | recalc_sigpending(); | ||
| 324 | spin_unlock_irq(¤t->sighand->siglock); | ||
| 325 | |||
| 326 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &frame->aux)) | ||
| 327 | goto badframe; | 286 | goto badframe; |
| 328 | 287 | ||
| 329 | if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->ARM_sp) == -EFAULT) | 288 | if (do_sigaltstack(&frame->sig.uc.uc_stack, NULL, regs->ARM_sp) == -EFAULT) |
| 330 | goto badframe; | 289 | goto badframe; |
| 331 | 290 | ||
| 332 | /* Send SIGTRAP if we're single-stepping */ | 291 | /* Send SIGTRAP if we're single-stepping */ |
| @@ -343,42 +302,46 @@ badframe: | |||
| 343 | } | 302 | } |
| 344 | 303 | ||
| 345 | static int | 304 | static int |
| 346 | setup_sigcontext(struct sigcontext __user *sc, struct aux_sigframe __user *aux, | 305 | setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set) |
| 347 | struct pt_regs *regs, unsigned long mask) | ||
| 348 | { | 306 | { |
| 307 | struct aux_sigframe __user *aux; | ||
| 349 | int err = 0; | 308 | int err = 0; |
| 350 | 309 | ||
| 351 | __put_user_error(regs->ARM_r0, &sc->arm_r0, err); | 310 | __put_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err); |
| 352 | __put_user_error(regs->ARM_r1, &sc->arm_r1, err); | 311 | __put_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err); |
| 353 | __put_user_error(regs->ARM_r2, &sc->arm_r2, err); | 312 | __put_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err); |
| 354 | __put_user_error(regs->ARM_r3, &sc->arm_r3, err); | 313 | __put_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err); |
| 355 | __put_user_error(regs->ARM_r4, &sc->arm_r4, err); | 314 | __put_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err); |
| 356 | __put_user_error(regs->ARM_r5, &sc->arm_r5, err); | 315 | __put_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err); |
| 357 | __put_user_error(regs->ARM_r6, &sc->arm_r6, err); | 316 | __put_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err); |
| 358 | __put_user_error(regs->ARM_r7, &sc->arm_r7, err); | 317 | __put_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err); |
| 359 | __put_user_error(regs->ARM_r8, &sc->arm_r8, err); | 318 | __put_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err); |
| 360 | __put_user_error(regs->ARM_r9, &sc->arm_r9, err); | 319 | __put_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err); |
| 361 | __put_user_error(regs->ARM_r10, &sc->arm_r10, err); | 320 | __put_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err); |
| 362 | __put_user_error(regs->ARM_fp, &sc->arm_fp, err); | 321 | __put_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err); |
| 363 | __put_user_error(regs->ARM_ip, &sc->arm_ip, err); | 322 | __put_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err); |
| 364 | __put_user_error(regs->ARM_sp, &sc->arm_sp, err); | 323 | __put_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err); |
| 365 | __put_user_error(regs->ARM_lr, &sc->arm_lr, err); | 324 | __put_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err); |
| 366 | __put_user_error(regs->ARM_pc, &sc->arm_pc, err); | 325 | __put_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err); |
| 367 | __put_user_error(regs->ARM_cpsr, &sc->arm_cpsr, err); | 326 | __put_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err); |
| 368 | 327 | ||
| 369 | __put_user_error(current->thread.trap_no, &sc->trap_no, err); | 328 | __put_user_error(current->thread.trap_no, &sf->uc.uc_mcontext.trap_no, err); |
| 370 | __put_user_error(current->thread.error_code, &sc->error_code, err); | 329 | __put_user_error(current->thread.error_code, &sf->uc.uc_mcontext.error_code, err); |
| 371 | __put_user_error(current->thread.address, &sc->fault_address, err); | 330 | __put_user_error(current->thread.address, &sf->uc.uc_mcontext.fault_address, err); |
| 372 | __put_user_error(mask, &sc->oldmask, err); | 331 | __put_user_error(set->sig[0], &sf->uc.uc_mcontext.oldmask, err); |
| 373 | 332 | ||
| 333 | err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); | ||
| 334 | |||
| 335 | aux = (struct aux_sigframe __user *) sf->uc.uc_regspace; | ||
| 374 | #ifdef CONFIG_IWMMXT | 336 | #ifdef CONFIG_IWMMXT |
| 375 | if (err == 0 && test_thread_flag(TIF_USING_IWMMXT)) | 337 | if (err == 0 && test_thread_flag(TIF_USING_IWMMXT)) |
| 376 | err |= preserve_iwmmxt_context(&aux->iwmmxt); | 338 | err |= preserve_iwmmxt_context(&aux->iwmmxt); |
| 377 | #endif | 339 | #endif |
| 378 | #ifdef CONFIG_VFP | 340 | #ifdef CONFIG_VFP |
| 379 | // if (err == 0) | 341 | // if (err == 0) |
| 380 | // err |= vfp_save_state(&aux->vfp); | 342 | // err |= vfp_save_state(&sf->aux.vfp); |
| 381 | #endif | 343 | #endif |
| 344 | __put_user_error(0, &aux->end_magic, err); | ||
| 382 | 345 | ||
| 383 | return err; | 346 | return err; |
| 384 | } | 347 | } |
| @@ -487,13 +450,12 @@ setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, struct pt_regs *reg | |||
| 487 | if (!frame) | 450 | if (!frame) |
| 488 | return 1; | 451 | return 1; |
| 489 | 452 | ||
| 490 | err |= setup_sigcontext(&frame->sc, &frame->aux, regs, set->sig[0]); | 453 | /* |
| 491 | 454 | * Set uc.uc_flags to a value which sc.trap_no would never have. | |
| 492 | if (_NSIG_WORDS > 1) { | 455 | */ |
| 493 | err |= __copy_to_user(frame->extramask, &set->sig[1], | 456 | __put_user_error(0x5ac3c35a, &frame->uc.uc_flags, err); |
| 494 | sizeof(frame->extramask)); | ||
| 495 | } | ||
| 496 | 457 | ||
| 458 | err |= setup_sigframe(frame, regs, set); | ||
| 497 | if (err == 0) | 459 | if (err == 0) |
| 498 | err = setup_return(regs, ka, frame->retcode, frame, usig); | 460 | err = setup_return(regs, ka, frame->retcode, frame, usig); |
| 499 | 461 | ||
| @@ -511,25 +473,20 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, | |||
| 511 | if (!frame) | 473 | if (!frame) |
| 512 | return 1; | 474 | return 1; |
| 513 | 475 | ||
| 514 | __put_user_error(&frame->info, &frame->pinfo, err); | ||
| 515 | __put_user_error(&frame->uc, &frame->puc, err); | ||
| 516 | err |= copy_siginfo_to_user(&frame->info, info); | 476 | err |= copy_siginfo_to_user(&frame->info, info); |
| 517 | 477 | ||
| 518 | __put_user_error(0, &frame->uc.uc_flags, err); | 478 | __put_user_error(0, &frame->sig.uc.uc_flags, err); |
| 519 | __put_user_error(NULL, &frame->uc.uc_link, err); | 479 | __put_user_error(NULL, &frame->sig.uc.uc_link, err); |
| 520 | 480 | ||
| 521 | memset(&stack, 0, sizeof(stack)); | 481 | memset(&stack, 0, sizeof(stack)); |
| 522 | stack.ss_sp = (void __user *)current->sas_ss_sp; | 482 | stack.ss_sp = (void __user *)current->sas_ss_sp; |
| 523 | stack.ss_flags = sas_ss_flags(regs->ARM_sp); | 483 | stack.ss_flags = sas_ss_flags(regs->ARM_sp); |
| 524 | stack.ss_size = current->sas_ss_size; | 484 | stack.ss_size = current->sas_ss_size; |
| 525 | err |= __copy_to_user(&frame->uc.uc_stack, &stack, sizeof(stack)); | 485 | err |= __copy_to_user(&frame->sig.uc.uc_stack, &stack, sizeof(stack)); |
| 526 | |||
| 527 | err |= setup_sigcontext(&frame->uc.uc_mcontext, &frame->aux, | ||
| 528 | regs, set->sig[0]); | ||
| 529 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | ||
| 530 | 486 | ||
| 487 | err |= setup_sigframe(&frame->sig, regs, set); | ||
| 531 | if (err == 0) | 488 | if (err == 0) |
| 532 | err = setup_return(regs, ka, frame->retcode, frame, usig); | 489 | err = setup_return(regs, ka, frame->sig.retcode, frame, usig); |
| 533 | 490 | ||
| 534 | if (err == 0) { | 491 | if (err == 0) { |
| 535 | /* | 492 | /* |
| @@ -538,7 +495,7 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, | |||
| 538 | * -- Peter Maydell <pmaydell@chiark.greenend.org.uk> 2000-12-06 | 495 | * -- Peter Maydell <pmaydell@chiark.greenend.org.uk> 2000-12-06 |
| 539 | */ | 496 | */ |
| 540 | regs->ARM_r1 = (unsigned long)&frame->info; | 497 | regs->ARM_r1 = (unsigned long)&frame->info; |
| 541 | regs->ARM_r2 = (unsigned long)&frame->uc; | 498 | regs->ARM_r2 = (unsigned long)&frame->sig.uc; |
| 542 | } | 499 | } |
| 543 | 500 | ||
| 544 | return err; | 501 | return err; |
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile index 5393af989e94..05a48a21038e 100644 --- a/arch/arm/mach-ep93xx/Makefile +++ b/arch/arm/mach-ep93xx/Makefile | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | # | 1 | # |
| 2 | # Makefile for the linux kernel. | 2 | # Makefile for the linux kernel. |
| 3 | # | 3 | # |
| 4 | obj-y := core.o | 4 | obj-y := core.o clock.o |
| 5 | obj-m := | 5 | obj-m := |
| 6 | obj-n := | 6 | obj-n := |
| 7 | obj- := | 7 | obj- := |
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c new file mode 100644 index 000000000000..08ad782c1649 --- /dev/null +++ b/arch/arm/mach-ep93xx/clock.c | |||
| @@ -0,0 +1,156 @@ | |||
| 1 | /* | ||
| 2 | * arch/arm/mach-ep93xx/clock.c | ||
| 3 | * Clock control for Cirrus EP93xx chips. | ||
| 4 | * | ||
| 5 | * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or (at | ||
| 10 | * your option) any later version. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/kernel.h> | ||
| 14 | #include <linux/clk.h> | ||
| 15 | #include <linux/err.h> | ||
| 16 | #include <linux/string.h> | ||
| 17 | #include <asm/div64.h> | ||
| 18 | #include <asm/hardware.h> | ||
| 19 | #include <asm/io.h> | ||
| 20 | |||
| 21 | struct clk { | ||
| 22 | char *name; | ||
| 23 | unsigned long rate; | ||
| 24 | int users; | ||
| 25 | u32 enable_reg; | ||
| 26 | u32 enable_mask; | ||
| 27 | }; | ||
| 28 | |||
| 29 | static struct clk clk_pll1 = { | ||
| 30 | .name = "pll1", | ||
| 31 | }; | ||
| 32 | static struct clk clk_f = { | ||
| 33 | .name = "fclk", | ||
| 34 | }; | ||
| 35 | static struct clk clk_h = { | ||
| 36 | .name = "hclk", | ||
| 37 | }; | ||
| 38 | static struct clk clk_p = { | ||
| 39 | .name = "pclk", | ||
| 40 | }; | ||
| 41 | static struct clk clk_pll2 = { | ||
| 42 | .name = "pll2", | ||
| 43 | }; | ||
| 44 | static struct clk clk_usb_host = { | ||
| 45 | .name = "usb_host", | ||
| 46 | .enable_reg = EP93XX_SYSCON_CLOCK_CONTROL, | ||
| 47 | .enable_mask = EP93XX_SYSCON_CLOCK_USH_EN, | ||
| 48 | }; | ||
| 49 | |||
| 50 | |||
| 51 | static struct clk *clocks[] = { | ||
| 52 | &clk_pll1, | ||
| 53 | &clk_f, | ||
| 54 | &clk_h, | ||
| 55 | &clk_p, | ||
| 56 | &clk_pll2, | ||
| 57 | &clk_usb_host, | ||
| 58 | }; | ||
| 59 | |||
| 60 | struct clk *clk_get(struct device *dev, const char *id) | ||
| 61 | { | ||
| 62 | int i; | ||
| 63 | |||
| 64 | for (i = 0; i < ARRAY_SIZE(clocks); i++) { | ||
| 65 | if (!strcmp(clocks[i]->name, id)) | ||
| 66 | return clocks[i]; | ||
| 67 | } | ||
| 68 | |||
| 69 | return ERR_PTR(-ENOENT); | ||
| 70 | } | ||
| 71 | |||
| 72 | int clk_enable(struct clk *clk) | ||
| 73 | { | ||
| 74 | if (!clk->users++ && clk->enable_reg) { | ||
| 75 | u32 value; | ||
| 76 | |||
| 77 | value = __raw_readl(clk->enable_reg); | ||
| 78 | __raw_writel(value | clk->enable_mask, clk->enable_reg); | ||
| 79 | } | ||
| 80 | |||
| 81 | return 0; | ||
| 82 | } | ||
| 83 | |||
| 84 | void clk_disable(struct clk *clk) | ||
| 85 | { | ||
| 86 | if (!--clk->users && clk->enable_reg) { | ||
| 87 | u32 value; | ||
| 88 | |||
| 89 | value = __raw_readl(clk->enable_reg); | ||
| 90 | __raw_writel(value & ~clk->enable_mask, clk->enable_reg); | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | unsigned long clk_get_rate(struct clk *clk) | ||
| 95 | { | ||
| 96 | return clk->rate; | ||
| 97 | } | ||
| 98 | |||
| 99 | void clk_put(struct clk *clk) | ||
| 100 | { | ||
| 101 | } | ||
| 102 | |||
| 103 | |||
| 104 | |||
| 105 | static char fclk_divisors[] = { 1, 2, 4, 8, 16, 1, 1, 1 }; | ||
| 106 | static char hclk_divisors[] = { 1, 2, 4, 5, 6, 8, 16, 32 }; | ||
| 107 | static char pclk_divisors[] = { 1, 2, 4, 8 }; | ||
| 108 | |||
| 109 | /* | ||
| 110 | * PLL rate = 14.7456 MHz * (X1FBD + 1) * (X2FBD + 1) / (X2IPD + 1) / 2^PS | ||
| 111 | */ | ||
| 112 | static unsigned long calc_pll_rate(u32 config_word) | ||
| 113 | { | ||
| 114 | unsigned long long rate; | ||
| 115 | int i; | ||
| 116 | |||
| 117 | rate = 14745600; | ||
| 118 | rate *= ((config_word >> 11) & 0x1f) + 1; /* X1FBD */ | ||
| 119 | rate *= ((config_word >> 5) & 0x3f) + 1; /* X2FBD */ | ||
| 120 | do_div(rate, (config_word & 0x1f) + 1); /* X2IPD */ | ||
| 121 | for (i = 0; i < ((config_word >> 16) & 3); i++) /* PS */ | ||
| 122 | rate >>= 1; | ||
| 123 | |||
| 124 | return (unsigned long)rate; | ||
| 125 | } | ||
| 126 | |||
| 127 | void ep93xx_clock_init(void) | ||
| 128 | { | ||
| 129 | u32 value; | ||
| 130 | |||
| 131 | value = __raw_readl(EP93XX_SYSCON_CLOCK_SET1); | ||
| 132 | if (!(value & 0x00800000)) { /* PLL1 bypassed? */ | ||
| 133 | clk_pll1.rate = 14745600; | ||
| 134 | } else { | ||
| 135 | clk_pll1.rate = calc_pll_rate(value); | ||
| 136 | } | ||
| 137 | clk_f.rate = clk_pll1.rate / fclk_divisors[(value >> 25) & 0x7]; | ||
| 138 | clk_h.rate = clk_pll1.rate / hclk_divisors[(value >> 20) & 0x7]; | ||
| 139 | clk_p.rate = clk_h.rate / pclk_divisors[(value >> 18) & 0x3]; | ||
| 140 | |||
| 141 | value = __raw_readl(EP93XX_SYSCON_CLOCK_SET2); | ||
| 142 | if (!(value & 0x00080000)) { /* PLL2 bypassed? */ | ||
| 143 | clk_pll2.rate = 14745600; | ||
| 144 | } else if (value & 0x00040000) { /* PLL2 enabled? */ | ||
| 145 | clk_pll2.rate = calc_pll_rate(value); | ||
| 146 | } else { | ||
| 147 | clk_pll2.rate = 0; | ||
| 148 | } | ||
| 149 | clk_usb_host.rate = clk_pll2.rate / (((value >> 28) & 0xf) + 1); | ||
| 150 | |||
| 151 | printk(KERN_INFO "ep93xx: PLL1 running at %ld MHz, PLL2 at %ld MHz\n", | ||
| 152 | clk_pll1.rate / 1000000, clk_pll2.rate / 1000000); | ||
| 153 | printk(KERN_INFO "ep93xx: FCLK %ld MHz, HCLK %ld MHz, PCLK %ld MHz\n", | ||
| 154 | clk_f.rate / 1000000, clk_h.rate / 1000000, | ||
| 155 | clk_p.rate / 1000000); | ||
| 156 | } | ||
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c index bf6bd71bdd08..1fe73c0a9d01 100644 --- a/arch/arm/mach-ep93xx/core.c +++ b/arch/arm/mach-ep93xx/core.c | |||
| @@ -433,10 +433,37 @@ static struct platform_device ep93xx_rtc_device = { | |||
| 433 | }; | 433 | }; |
| 434 | 434 | ||
| 435 | 435 | ||
| 436 | static struct resource ep93xx_ohci_resources[] = { | ||
| 437 | [0] = { | ||
| 438 | .start = EP93XX_USB_PHYS_BASE, | ||
| 439 | .end = EP93XX_USB_PHYS_BASE + 0x0fff, | ||
| 440 | .flags = IORESOURCE_MEM, | ||
| 441 | }, | ||
| 442 | [1] = { | ||
| 443 | .start = IRQ_EP93XX_USB, | ||
| 444 | .end = IRQ_EP93XX_USB, | ||
| 445 | .flags = IORESOURCE_IRQ, | ||
| 446 | }, | ||
| 447 | }; | ||
| 448 | |||
| 449 | static struct platform_device ep93xx_ohci_device = { | ||
| 450 | .name = "ep93xx-ohci", | ||
| 451 | .id = -1, | ||
| 452 | .dev = { | ||
| 453 | .dma_mask = (void *)0xffffffff, | ||
| 454 | .coherent_dma_mask = 0xffffffff, | ||
| 455 | }, | ||
| 456 | .num_resources = ARRAY_SIZE(ep93xx_ohci_resources), | ||
| 457 | .resource = ep93xx_ohci_resources, | ||
| 458 | }; | ||
| 459 | |||
| 460 | |||
| 436 | void __init ep93xx_init_devices(void) | 461 | void __init ep93xx_init_devices(void) |
| 437 | { | 462 | { |
| 438 | unsigned int v; | 463 | unsigned int v; |
| 439 | 464 | ||
| 465 | ep93xx_clock_init(); | ||
| 466 | |||
| 440 | /* | 467 | /* |
| 441 | * Disallow access to MaverickCrunch initially. | 468 | * Disallow access to MaverickCrunch initially. |
| 442 | */ | 469 | */ |
| @@ -450,4 +477,5 @@ void __init ep93xx_init_devices(void) | |||
| 450 | amba_device_register(&uart3_device, &iomem_resource); | 477 | amba_device_register(&uart3_device, &iomem_resource); |
| 451 | 478 | ||
| 452 | platform_device_register(&ep93xx_rtc_device); | 479 | platform_device_register(&ep93xx_rtc_device); |
| 480 | platform_device_register(&ep93xx_ohci_device); | ||
| 453 | } | 481 | } |
diff --git a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c index 186f632035b8..ebe4391dd7f9 100644 --- a/arch/arm/mach-ixp2000/core.c +++ b/arch/arm/mach-ixp2000/core.c | |||
| @@ -302,6 +302,7 @@ void gpio_line_config(int line, int direction) | |||
| 302 | } | 302 | } |
| 303 | local_irq_restore(flags); | 303 | local_irq_restore(flags); |
| 304 | } | 304 | } |
| 305 | EXPORT_SYMBOL(gpio_line_config); | ||
| 305 | 306 | ||
| 306 | 307 | ||
| 307 | /************************************************************************* | 308 | /************************************************************************* |
diff --git a/arch/arm/mach-s3c2410/Kconfig b/arch/arm/mach-s3c2410/Kconfig index 7b786d725636..f5d9cd498a5f 100644 --- a/arch/arm/mach-s3c2410/Kconfig +++ b/arch/arm/mach-s3c2410/Kconfig | |||
| @@ -81,6 +81,12 @@ config SMDK2440_CPU2442 | |||
| 81 | depends on ARCH_S3C2440 | 81 | depends on ARCH_S3C2440 |
| 82 | select CPU_S3C2442 | 82 | select CPU_S3C2442 |
| 83 | 83 | ||
| 84 | config MACH_SMDK2413 | ||
| 85 | bool "SMDK2413" | ||
| 86 | select CPU_S3C2412 | ||
| 87 | select MACH_SMDK | ||
| 88 | help | ||
| 89 | Say Y here if you are using an SMDK2413 | ||
| 84 | 90 | ||
| 85 | config MACH_VR1000 | 91 | config MACH_VR1000 |
| 86 | bool "Thorcom VR1000" | 92 | bool "Thorcom VR1000" |
| @@ -127,6 +133,20 @@ config CPU_S3C2410 | |||
| 127 | Support for S3C2410 and S3C2410A family from the S3C24XX line | 133 | Support for S3C2410 and S3C2410A family from the S3C24XX line |
| 128 | of Samsung Mobile CPUs. | 134 | of Samsung Mobile CPUs. |
| 129 | 135 | ||
| 136 | # internal node to signify if we are only dealing with an S3C2412 | ||
| 137 | |||
| 138 | config CPU_S3C2412_ONLY | ||
| 139 | bool | ||
| 140 | depends on ARCH_S3C2410 && !CPU_S3C2400 && !CPU_S3C2410 && \ | ||
| 141 | !CPU_S3C2440 && !CPU_S3C2442 && CPU_S3C2412 | ||
| 142 | default y if CPU_S3C2412 | ||
| 143 | |||
| 144 | config CPU_S3C2412 | ||
| 145 | bool | ||
| 146 | depends on ARCH_S3C2410 | ||
| 147 | help | ||
| 148 | Support for the S3C2412 and S3C2413 SoCs from the S3C24XX line | ||
| 149 | |||
| 130 | config CPU_S3C244X | 150 | config CPU_S3C244X |
| 131 | bool | 151 | bool |
| 132 | depends on ARCH_S3C2410 && (CPU_S3C2440 || CPU_S3C2442) | 152 | depends on ARCH_S3C2410 && (CPU_S3C2440 || CPU_S3C2442) |
diff --git a/arch/arm/mach-s3c2410/Makefile b/arch/arm/mach-s3c2410/Makefile index 372dbcea1434..0c7938645df6 100644 --- a/arch/arm/mach-s3c2410/Makefile +++ b/arch/arm/mach-s3c2410/Makefile | |||
| @@ -24,6 +24,11 @@ obj-$(CONFIG_S3C2410_DMA) += dma.o | |||
| 24 | obj-$(CONFIG_PM) += pm.o sleep.o | 24 | obj-$(CONFIG_PM) += pm.o sleep.o |
| 25 | obj-$(CONFIG_PM_SIMTEC) += pm-simtec.o | 25 | obj-$(CONFIG_PM_SIMTEC) += pm-simtec.o |
| 26 | 26 | ||
| 27 | # S3C2412 support | ||
| 28 | obj-$(CONFIG_CPU_S3C2412) += s3c2412.o | ||
| 29 | obj-$(CONFIG_CPU_S3C2412) += s3c2412-clock.o | ||
| 30 | |||
| 31 | # | ||
| 27 | # S3C244X support | 32 | # S3C244X support |
| 28 | 33 | ||
| 29 | obj-$(CONFIG_CPU_S3C244X) += s3c244x.o | 34 | obj-$(CONFIG_CPU_S3C244X) += s3c244x.o |
| @@ -57,6 +62,7 @@ obj-$(CONFIG_ARCH_BAST) += mach-bast.o usb-simtec.o | |||
| 57 | obj-$(CONFIG_ARCH_H1940) += mach-h1940.o | 62 | obj-$(CONFIG_ARCH_H1940) += mach-h1940.o |
| 58 | obj-$(CONFIG_MACH_N30) += mach-n30.o | 63 | obj-$(CONFIG_MACH_N30) += mach-n30.o |
| 59 | obj-$(CONFIG_ARCH_SMDK2410) += mach-smdk2410.o | 64 | obj-$(CONFIG_ARCH_SMDK2410) += mach-smdk2410.o |
| 65 | obj-$(CONFIG_MACH_SMDK2413) += mach-smdk2413.o | ||
| 60 | obj-$(CONFIG_ARCH_S3C2440) += mach-smdk2440.o | 66 | obj-$(CONFIG_ARCH_S3C2440) += mach-smdk2440.o |
| 61 | obj-$(CONFIG_MACH_VR1000) += mach-vr1000.o usb-simtec.o | 67 | obj-$(CONFIG_MACH_VR1000) += mach-vr1000.o usb-simtec.o |
| 62 | obj-$(CONFIG_MACH_RX3715) += mach-rx3715.o | 68 | obj-$(CONFIG_MACH_RX3715) += mach-rx3715.o |
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c index c5c93c333ac6..e13fb6778890 100644 --- a/arch/arm/mach-s3c2410/clock.c +++ b/arch/arm/mach-s3c2410/clock.c | |||
| @@ -213,7 +213,7 @@ EXPORT_SYMBOL(clk_set_parent); | |||
| 213 | 213 | ||
| 214 | /* base clocks */ | 214 | /* base clocks */ |
| 215 | 215 | ||
| 216 | static struct clk clk_xtal = { | 216 | struct clk clk_xtal = { |
| 217 | .name = "xtal", | 217 | .name = "xtal", |
| 218 | .id = -1, | 218 | .id = -1, |
| 219 | .rate = 0, | 219 | .rate = 0, |
| @@ -221,6 +221,11 @@ static struct clk clk_xtal = { | |||
| 221 | .ctrlbit = 0, | 221 | .ctrlbit = 0, |
| 222 | }; | 222 | }; |
| 223 | 223 | ||
| 224 | struct clk clk_mpll = { | ||
| 225 | .name = "mpll", | ||
| 226 | .id = -1, | ||
| 227 | }; | ||
| 228 | |||
| 224 | struct clk clk_upll = { | 229 | struct clk clk_upll = { |
| 225 | .name = "upll", | 230 | .name = "upll", |
| 226 | .id = -1, | 231 | .id = -1, |
| @@ -232,7 +237,7 @@ struct clk clk_f = { | |||
| 232 | .name = "fclk", | 237 | .name = "fclk", |
| 233 | .id = -1, | 238 | .id = -1, |
| 234 | .rate = 0, | 239 | .rate = 0, |
| 235 | .parent = NULL, | 240 | .parent = &clk_mpll, |
| 236 | .ctrlbit = 0, | 241 | .ctrlbit = 0, |
| 237 | }; | 242 | }; |
| 238 | 243 | ||
| @@ -263,14 +268,14 @@ struct clk clk_usb_bus = { | |||
| 263 | 268 | ||
| 264 | static int s3c24xx_dclk_enable(struct clk *clk, int enable) | 269 | static int s3c24xx_dclk_enable(struct clk *clk, int enable) |
| 265 | { | 270 | { |
| 266 | unsigned long dclkcon = __raw_readl(S3C2410_DCLKCON); | 271 | unsigned long dclkcon = __raw_readl(S3C24XX_DCLKCON); |
| 267 | 272 | ||
| 268 | if (enable) | 273 | if (enable) |
| 269 | dclkcon |= clk->ctrlbit; | 274 | dclkcon |= clk->ctrlbit; |
| 270 | else | 275 | else |
| 271 | dclkcon &= ~clk->ctrlbit; | 276 | dclkcon &= ~clk->ctrlbit; |
| 272 | 277 | ||
| 273 | __raw_writel(dclkcon, S3C2410_DCLKCON); | 278 | __raw_writel(dclkcon, S3C24XX_DCLKCON); |
| 274 | 279 | ||
| 275 | return 0; | 280 | return 0; |
| 276 | } | 281 | } |
| @@ -289,7 +294,7 @@ static int s3c24xx_dclk_setparent(struct clk *clk, struct clk *parent) | |||
| 289 | 294 | ||
| 290 | clk->parent = parent; | 295 | clk->parent = parent; |
| 291 | 296 | ||
| 292 | dclkcon = __raw_readl(S3C2410_DCLKCON); | 297 | dclkcon = __raw_readl(S3C24XX_DCLKCON); |
| 293 | 298 | ||
| 294 | if (clk->ctrlbit == S3C2410_DCLKCON_DCLK0EN) { | 299 | if (clk->ctrlbit == S3C2410_DCLKCON_DCLK0EN) { |
| 295 | if (uclk) | 300 | if (uclk) |
| @@ -303,7 +308,7 @@ static int s3c24xx_dclk_setparent(struct clk *clk, struct clk *parent) | |||
| 303 | dclkcon &= ~S3C2410_DCLKCON_DCLK1_UCLK; | 308 | dclkcon &= ~S3C2410_DCLKCON_DCLK1_UCLK; |
| 304 | } | 309 | } |
| 305 | 310 | ||
| 306 | __raw_writel(dclkcon, S3C2410_DCLKCON); | 311 | __raw_writel(dclkcon, S3C24XX_DCLKCON); |
| 307 | 312 | ||
| 308 | return 0; | 313 | return 0; |
| 309 | } | 314 | } |
| @@ -413,6 +418,7 @@ int __init s3c24xx_setup_clocks(unsigned long xtal, | |||
| 413 | clk_xtal.rate = xtal; | 418 | clk_xtal.rate = xtal; |
| 414 | clk_upll.rate = s3c2410_get_pll(__raw_readl(S3C2410_UPLLCON), xtal); | 419 | clk_upll.rate = s3c2410_get_pll(__raw_readl(S3C2410_UPLLCON), xtal); |
| 415 | 420 | ||
| 421 | clk_mpll.rate = fclk; | ||
| 416 | clk_h.rate = hclk; | 422 | clk_h.rate = hclk; |
| 417 | clk_p.rate = pclk; | 423 | clk_p.rate = pclk; |
| 418 | clk_f.rate = fclk; | 424 | clk_f.rate = fclk; |
| @@ -424,6 +430,9 @@ int __init s3c24xx_setup_clocks(unsigned long xtal, | |||
| 424 | if (s3c24xx_register_clock(&clk_xtal) < 0) | 430 | if (s3c24xx_register_clock(&clk_xtal) < 0) |
| 425 | printk(KERN_ERR "failed to register master xtal\n"); | 431 | printk(KERN_ERR "failed to register master xtal\n"); |
| 426 | 432 | ||
| 433 | if (s3c24xx_register_clock(&clk_mpll) < 0) | ||
| 434 | printk(KERN_ERR "failed to register mpll clock\n"); | ||
| 435 | |||
| 427 | if (s3c24xx_register_clock(&clk_upll) < 0) | 436 | if (s3c24xx_register_clock(&clk_upll) < 0) |
| 428 | printk(KERN_ERR "failed to register upll clock\n"); | 437 | printk(KERN_ERR "failed to register upll clock\n"); |
| 429 | 438 | ||
diff --git a/arch/arm/mach-s3c2410/clock.h b/arch/arm/mach-s3c2410/clock.h index 9456c81eb5d3..7f0ea03e1d49 100644 --- a/arch/arm/mach-s3c2410/clock.h +++ b/arch/arm/mach-s3c2410/clock.h | |||
| @@ -42,7 +42,9 @@ extern struct clk clk_usb_bus; | |||
| 42 | extern struct clk clk_f; | 42 | extern struct clk clk_f; |
| 43 | extern struct clk clk_h; | 43 | extern struct clk clk_h; |
| 44 | extern struct clk clk_p; | 44 | extern struct clk clk_p; |
| 45 | extern struct clk clk_mpll; | ||
| 45 | extern struct clk clk_upll; | 46 | extern struct clk clk_upll; |
| 47 | extern struct clk clk_xtal; | ||
| 46 | 48 | ||
| 47 | /* exports for arch/arm/mach-s3c2410 | 49 | /* exports for arch/arm/mach-s3c2410 |
| 48 | * | 50 | * |
diff --git a/arch/arm/mach-s3c2410/cpu.c b/arch/arm/mach-s3c2410/cpu.c index 52842e6e86e6..1c3c6adae6c4 100644 --- a/arch/arm/mach-s3c2410/cpu.c +++ b/arch/arm/mach-s3c2410/cpu.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | #include "clock.h" | 44 | #include "clock.h" |
| 45 | #include "s3c2400.h" | 45 | #include "s3c2400.h" |
| 46 | #include "s3c2410.h" | 46 | #include "s3c2410.h" |
| 47 | #include "s3c2412.h" | ||
| 47 | #include "s3c244x.h" | 48 | #include "s3c244x.h" |
| 48 | #include "s3c2440.h" | 49 | #include "s3c2440.h" |
| 49 | #include "s3c2442.h" | 50 | #include "s3c2442.h" |
| @@ -62,6 +63,7 @@ struct cpu_table { | |||
| 62 | 63 | ||
| 63 | static const char name_s3c2400[] = "S3C2400"; | 64 | static const char name_s3c2400[] = "S3C2400"; |
| 64 | static const char name_s3c2410[] = "S3C2410"; | 65 | static const char name_s3c2410[] = "S3C2410"; |
| 66 | static const char name_s3c2412[] = "S3C2412"; | ||
| 65 | static const char name_s3c2440[] = "S3C2440"; | 67 | static const char name_s3c2440[] = "S3C2440"; |
| 66 | static const char name_s3c2442[] = "S3C2442"; | 68 | static const char name_s3c2442[] = "S3C2442"; |
| 67 | static const char name_s3c2410a[] = "S3C2410A"; | 69 | static const char name_s3c2410a[] = "S3C2410A"; |
| @@ -114,6 +116,15 @@ static struct cpu_table cpu_ids[] __initdata = { | |||
| 114 | .name = name_s3c2442 | 116 | .name = name_s3c2442 |
| 115 | }, | 117 | }, |
| 116 | { | 118 | { |
| 119 | .idcode = 0x32412001, | ||
| 120 | .idmask = 0xffffffff, | ||
| 121 | .map_io = s3c2412_map_io, | ||
| 122 | .init_clocks = s3c2412_init_clocks, | ||
| 123 | .init_uarts = s3c2412_init_uarts, | ||
| 124 | .init = s3c2412_init, | ||
| 125 | .name = name_s3c2412, | ||
| 126 | }, | ||
| 127 | { | ||
| 117 | .idcode = 0x0, /* S3C2400 doesn't have an idcode */ | 128 | .idcode = 0x0, /* S3C2400 doesn't have an idcode */ |
| 118 | .idmask = 0xffffffff, | 129 | .idmask = 0xffffffff, |
| 119 | .map_io = s3c2400_map_io, | 130 | .map_io = s3c2400_map_io, |
| @@ -171,6 +182,24 @@ void s3c24xx_set_board(struct s3c24xx_board *b) | |||
| 171 | 182 | ||
| 172 | static struct cpu_table *cpu; | 183 | static struct cpu_table *cpu; |
| 173 | 184 | ||
| 185 | static unsigned long s3c24xx_read_idcode_v5(void) | ||
| 186 | { | ||
| 187 | #if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413) | ||
| 188 | return __raw_readl(S3C2412_GSTATUS1); | ||
| 189 | #else | ||
| 190 | return 1UL; /* don't look like an 2400 */ | ||
| 191 | #endif | ||
| 192 | } | ||
| 193 | |||
| 194 | static unsigned long s3c24xx_read_idcode_v4(void) | ||
| 195 | { | ||
| 196 | #ifndef CONFIG_CPU_S3C2400 | ||
| 197 | return __raw_readl(S3C2410_GSTATUS1); | ||
| 198 | #else | ||
| 199 | return 0UL; | ||
| 200 | #endif | ||
| 201 | } | ||
| 202 | |||
| 174 | void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) | 203 | void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) |
| 175 | { | 204 | { |
| 176 | unsigned long idcode = 0x0; | 205 | unsigned long idcode = 0x0; |
| @@ -178,9 +207,11 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) | |||
| 178 | /* initialise the io descriptors we need for initialisation */ | 207 | /* initialise the io descriptors we need for initialisation */ |
| 179 | iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); | 208 | iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); |
| 180 | 209 | ||
| 181 | #ifndef CONFIG_CPU_S3C2400 | 210 | if (cpu_architecture() >= CPU_ARCH_ARMv5) { |
| 182 | idcode = __raw_readl(S3C2410_GSTATUS1); | 211 | idcode = s3c24xx_read_idcode_v5(); |
| 183 | #endif | 212 | } else { |
| 213 | idcode = s3c24xx_read_idcode_v4(); | ||
| 214 | } | ||
| 184 | 215 | ||
| 185 | cpu = s3c_lookup_cpu(idcode); | 216 | cpu = s3c_lookup_cpu(idcode); |
| 186 | 217 | ||
diff --git a/arch/arm/mach-s3c2410/cpu.h b/arch/arm/mach-s3c2410/cpu.h index 21c62dc29bb2..b0ed9d2d141b 100644 --- a/arch/arm/mach-s3c2410/cpu.h +++ b/arch/arm/mach-s3c2410/cpu.h | |||
| @@ -74,5 +74,6 @@ extern struct sys_timer s3c24xx_timer; | |||
| 74 | /* system device classes */ | 74 | /* system device classes */ |
| 75 | 75 | ||
| 76 | extern struct sysdev_class s3c2410_sysclass; | 76 | extern struct sysdev_class s3c2410_sysclass; |
| 77 | extern struct sysdev_class s3c2412_sysclass; | ||
| 77 | extern struct sysdev_class s3c2440_sysclass; | 78 | extern struct sysdev_class s3c2440_sysclass; |
| 78 | extern struct sysdev_class s3c2442_sysclass; | 79 | extern struct sysdev_class s3c2442_sysclass; |
diff --git a/arch/arm/mach-s3c2410/irq.c b/arch/arm/mach-s3c2410/irq.c index 66d8c068e940..6822dc7f7799 100644 --- a/arch/arm/mach-s3c2410/irq.c +++ b/arch/arm/mach-s3c2410/irq.c | |||
| @@ -191,13 +191,9 @@ static struct irqchip s3c_irq_chip = { | |||
| 191 | .ack = s3c_irq_ack, | 191 | .ack = s3c_irq_ack, |
| 192 | .mask = s3c_irq_mask, | 192 | .mask = s3c_irq_mask, |
| 193 | .unmask = s3c_irq_unmask, | 193 | .unmask = s3c_irq_unmask, |
| 194 | .set_wake = s3c_irq_wake | 194 | .set_wake = s3c_irq_wake |
| 195 | }; | 195 | }; |
| 196 | 196 | ||
| 197 | /* S3C2410_EINTMASK | ||
| 198 | * S3C2410_EINTPEND | ||
| 199 | */ | ||
| 200 | |||
| 201 | static void | 197 | static void |
| 202 | s3c_irqext_mask(unsigned int irqno) | 198 | s3c_irqext_mask(unsigned int irqno) |
| 203 | { | 199 | { |
| @@ -205,9 +201,9 @@ s3c_irqext_mask(unsigned int irqno) | |||
| 205 | 201 | ||
| 206 | irqno -= EXTINT_OFF; | 202 | irqno -= EXTINT_OFF; |
| 207 | 203 | ||
| 208 | mask = __raw_readl(S3C2410_EINTMASK); | 204 | mask = __raw_readl(S3C24XX_EINTMASK); |
| 209 | mask |= ( 1UL << irqno); | 205 | mask |= ( 1UL << irqno); |
| 210 | __raw_writel(mask, S3C2410_EINTMASK); | 206 | __raw_writel(mask, S3C24XX_EINTMASK); |
| 211 | 207 | ||
| 212 | if (irqno <= (IRQ_EINT7 - EXTINT_OFF)) { | 208 | if (irqno <= (IRQ_EINT7 - EXTINT_OFF)) { |
| 213 | /* check to see if all need masking */ | 209 | /* check to see if all need masking */ |
| @@ -232,11 +228,11 @@ s3c_irqext_ack(unsigned int irqno) | |||
| 232 | bit = 1UL << (irqno - EXTINT_OFF); | 228 | bit = 1UL << (irqno - EXTINT_OFF); |
| 233 | 229 | ||
| 234 | 230 | ||
| 235 | mask = __raw_readl(S3C2410_EINTMASK); | 231 | mask = __raw_readl(S3C24XX_EINTMASK); |
| 236 | 232 | ||
| 237 | __raw_writel(bit, S3C2410_EINTPEND); | 233 | __raw_writel(bit, S3C24XX_EINTPEND); |
| 238 | 234 | ||
| 239 | req = __raw_readl(S3C2410_EINTPEND); | 235 | req = __raw_readl(S3C24XX_EINTPEND); |
| 240 | req &= ~mask; | 236 | req &= ~mask; |
| 241 | 237 | ||
| 242 | /* not sure if we should be acking the parent irq... */ | 238 | /* not sure if we should be acking the parent irq... */ |
| @@ -257,9 +253,9 @@ s3c_irqext_unmask(unsigned int irqno) | |||
| 257 | 253 | ||
| 258 | irqno -= EXTINT_OFF; | 254 | irqno -= EXTINT_OFF; |
| 259 | 255 | ||
| 260 | mask = __raw_readl(S3C2410_EINTMASK); | 256 | mask = __raw_readl(S3C24XX_EINTMASK); |
| 261 | mask &= ~( 1UL << irqno); | 257 | mask &= ~( 1UL << irqno); |
| 262 | __raw_writel(mask, S3C2410_EINTMASK); | 258 | __raw_writel(mask, S3C24XX_EINTMASK); |
| 263 | 259 | ||
| 264 | s3c_irq_unmask((irqno <= (IRQ_EINT7 - EXTINT_OFF)) ? IRQ_EINT4t7 : IRQ_EINT8t23); | 260 | s3c_irq_unmask((irqno <= (IRQ_EINT7 - EXTINT_OFF)) ? IRQ_EINT4t7 : IRQ_EINT8t23); |
| 265 | } | 261 | } |
| @@ -275,28 +271,28 @@ s3c_irqext_type(unsigned int irq, unsigned int type) | |||
| 275 | if ((irq >= IRQ_EINT0) && (irq <= IRQ_EINT3)) | 271 | if ((irq >= IRQ_EINT0) && (irq <= IRQ_EINT3)) |
| 276 | { | 272 | { |
| 277 | gpcon_reg = S3C2410_GPFCON; | 273 | gpcon_reg = S3C2410_GPFCON; |
| 278 | extint_reg = S3C2410_EXTINT0; | 274 | extint_reg = S3C24XX_EXTINT0; |
| 279 | gpcon_offset = (irq - IRQ_EINT0) * 2; | 275 | gpcon_offset = (irq - IRQ_EINT0) * 2; |
| 280 | extint_offset = (irq - IRQ_EINT0) * 4; | 276 | extint_offset = (irq - IRQ_EINT0) * 4; |
| 281 | } | 277 | } |
| 282 | else if ((irq >= IRQ_EINT4) && (irq <= IRQ_EINT7)) | 278 | else if ((irq >= IRQ_EINT4) && (irq <= IRQ_EINT7)) |
| 283 | { | 279 | { |
| 284 | gpcon_reg = S3C2410_GPFCON; | 280 | gpcon_reg = S3C2410_GPFCON; |
| 285 | extint_reg = S3C2410_EXTINT0; | 281 | extint_reg = S3C24XX_EXTINT0; |
| 286 | gpcon_offset = (irq - (EXTINT_OFF)) * 2; | 282 | gpcon_offset = (irq - (EXTINT_OFF)) * 2; |
| 287 | extint_offset = (irq - (EXTINT_OFF)) * 4; | 283 | extint_offset = (irq - (EXTINT_OFF)) * 4; |
| 288 | } | 284 | } |
| 289 | else if ((irq >= IRQ_EINT8) && (irq <= IRQ_EINT15)) | 285 | else if ((irq >= IRQ_EINT8) && (irq <= IRQ_EINT15)) |
| 290 | { | 286 | { |
| 291 | gpcon_reg = S3C2410_GPGCON; | 287 | gpcon_reg = S3C2410_GPGCON; |
| 292 | extint_reg = S3C2410_EXTINT1; | 288 | extint_reg = S3C24XX_EXTINT1; |
| 293 | gpcon_offset = (irq - IRQ_EINT8) * 2; | 289 | gpcon_offset = (irq - IRQ_EINT8) * 2; |
| 294 | extint_offset = (irq - IRQ_EINT8) * 4; | 290 | extint_offset = (irq - IRQ_EINT8) * 4; |
| 295 | } | 291 | } |
| 296 | else if ((irq >= IRQ_EINT16) && (irq <= IRQ_EINT23)) | 292 | else if ((irq >= IRQ_EINT16) && (irq <= IRQ_EINT23)) |
| 297 | { | 293 | { |
| 298 | gpcon_reg = S3C2410_GPGCON; | 294 | gpcon_reg = S3C2410_GPGCON; |
| 299 | extint_reg = S3C2410_EXTINT2; | 295 | extint_reg = S3C24XX_EXTINT2; |
| 300 | gpcon_offset = (irq - IRQ_EINT8) * 2; | 296 | gpcon_offset = (irq - IRQ_EINT8) * 2; |
| 301 | extint_offset = (irq - IRQ_EINT16) * 4; | 297 | extint_offset = (irq - IRQ_EINT16) * 4; |
| 302 | } else | 298 | } else |
| @@ -572,6 +568,23 @@ s3c_irq_demux_uart2(unsigned int irq, | |||
| 572 | s3c_irq_demux_uart(IRQ_S3CUART_RX2, regs); | 568 | s3c_irq_demux_uart(IRQ_S3CUART_RX2, regs); |
| 573 | } | 569 | } |
| 574 | 570 | ||
| 571 | static void | ||
| 572 | s3c_irq_demux_extint(unsigned int irq, | ||
| 573 | struct irqdesc *desc, | ||
| 574 | struct pt_regs *regs) | ||
| 575 | { | ||
| 576 | unsigned long eintpnd = __raw_readl(S3C24XX_EINTPEND); | ||
| 577 | unsigned long eintmsk = __raw_readl(S3C24XX_EINTMASK); | ||
| 578 | |||
| 579 | eintpnd &= ~eintmsk; | ||
| 580 | |||
| 581 | if (eintpnd) { | ||
| 582 | irq = fls(eintpnd); | ||
| 583 | irq += (IRQ_EINT4 - (4 + 1)); | ||
| 584 | |||
| 585 | desc_handle_irq(irq, irq_desc + irq, regs); | ||
| 586 | } | ||
| 587 | } | ||
| 575 | 588 | ||
| 576 | /* s3c24xx_init_irq | 589 | /* s3c24xx_init_irq |
| 577 | * | 590 | * |
| @@ -591,12 +604,12 @@ void __init s3c24xx_init_irq(void) | |||
| 591 | 604 | ||
| 592 | last = 0; | 605 | last = 0; |
| 593 | for (i = 0; i < 4; i++) { | 606 | for (i = 0; i < 4; i++) { |
| 594 | pend = __raw_readl(S3C2410_EINTPEND); | 607 | pend = __raw_readl(S3C24XX_EINTPEND); |
| 595 | 608 | ||
| 596 | if (pend == 0 || pend == last) | 609 | if (pend == 0 || pend == last) |
| 597 | break; | 610 | break; |
| 598 | 611 | ||
| 599 | __raw_writel(pend, S3C2410_EINTPEND); | 612 | __raw_writel(pend, S3C24XX_EINTPEND); |
| 600 | printk("irq: clearing pending ext status %08x\n", (int)pend); | 613 | printk("irq: clearing pending ext status %08x\n", (int)pend); |
| 601 | last = pend; | 614 | last = pend; |
| 602 | } | 615 | } |
| @@ -630,12 +643,14 @@ void __init s3c24xx_init_irq(void) | |||
| 630 | 643 | ||
| 631 | irqdbf("s3c2410_init_irq: registering s3c2410 interrupt handlers\n"); | 644 | irqdbf("s3c2410_init_irq: registering s3c2410 interrupt handlers\n"); |
| 632 | 645 | ||
| 633 | for (irqno = IRQ_BATT_FLT; irqno <= IRQ_ADCPARENT; irqno++) { | 646 | for (irqno = IRQ_EINT4t7; irqno <= IRQ_ADCPARENT; irqno++) { |
| 634 | /* set all the s3c2410 internal irqs */ | 647 | /* set all the s3c2410 internal irqs */ |
| 635 | 648 | ||
| 636 | switch (irqno) { | 649 | switch (irqno) { |
| 637 | /* deal with the special IRQs (cascaded) */ | 650 | /* deal with the special IRQs (cascaded) */ |
| 638 | 651 | ||
| 652 | case IRQ_EINT4t7: | ||
| 653 | case IRQ_EINT8t23: | ||
| 639 | case IRQ_UART0: | 654 | case IRQ_UART0: |
| 640 | case IRQ_UART1: | 655 | case IRQ_UART1: |
| 641 | case IRQ_UART2: | 656 | case IRQ_UART2: |
| @@ -659,12 +674,14 @@ void __init s3c24xx_init_irq(void) | |||
| 659 | 674 | ||
| 660 | /* setup the cascade irq handlers */ | 675 | /* setup the cascade irq handlers */ |
| 661 | 676 | ||
| 677 | set_irq_chained_handler(IRQ_EINT4t7, s3c_irq_demux_extint); | ||
| 678 | set_irq_chained_handler(IRQ_EINT8t23, s3c_irq_demux_extint); | ||
| 679 | |||
| 662 | set_irq_chained_handler(IRQ_UART0, s3c_irq_demux_uart0); | 680 | set_irq_chained_handler(IRQ_UART0, s3c_irq_demux_uart0); |
| 663 | set_irq_chained_handler(IRQ_UART1, s3c_irq_demux_uart1); | 681 | set_irq_chained_handler(IRQ_UART1, s3c_irq_demux_uart1); |
| 664 | set_irq_chained_handler(IRQ_UART2, s3c_irq_demux_uart2); | 682 | set_irq_chained_handler(IRQ_UART2, s3c_irq_demux_uart2); |
| 665 | set_irq_chained_handler(IRQ_ADCPARENT, s3c_irq_demux_adc); | 683 | set_irq_chained_handler(IRQ_ADCPARENT, s3c_irq_demux_adc); |
| 666 | 684 | ||
| 667 | |||
| 668 | /* external interrupts */ | 685 | /* external interrupts */ |
| 669 | 686 | ||
| 670 | for (irqno = IRQ_EINT0; irqno <= IRQ_EINT3; irqno++) { | 687 | for (irqno = IRQ_EINT0; irqno <= IRQ_EINT3; irqno++) { |
diff --git a/arch/arm/mach-s3c2410/mach-smdk2413.c b/arch/arm/mach-s3c2410/mach-smdk2413.c new file mode 100644 index 000000000000..b7ef7d3c54a9 --- /dev/null +++ b/arch/arm/mach-s3c2410/mach-smdk2413.c | |||
| @@ -0,0 +1,126 @@ | |||
| 1 | /* linux/arch/arm/mach-s3c2410/mach-smdk2413.c | ||
| 2 | * | ||
| 3 | * Copyright (c) 2006 Simtec Electronics | ||
| 4 | * Ben Dooks <ben@simtec.co.uk> | ||
| 5 | * | ||
| 6 | * Thanks to Dimity Andric (TomTom) and Steven Ryu (Samsung) for the | ||
| 7 | * loans of SMDK2413 to work with. | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License version 2 as | ||
| 11 | * published by the Free Software Foundation. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/kernel.h> | ||
| 15 | #include <linux/types.h> | ||
| 16 | #include <linux/interrupt.h> | ||
| 17 | #include <linux/list.h> | ||
| 18 | #include <linux/timer.h> | ||
| 19 | #include <linux/init.h> | ||
| 20 | #include <linux/platform_device.h> | ||
| 21 | |||
| 22 | #include <asm/mach/arch.h> | ||
| 23 | #include <asm/mach/map.h> | ||
| 24 | #include <asm/mach/irq.h> | ||
| 25 | |||
| 26 | #include <asm/hardware.h> | ||
| 27 | #include <asm/hardware/iomd.h> | ||
| 28 | #include <asm/setup.h> | ||
| 29 | #include <asm/io.h> | ||
| 30 | #include <asm/irq.h> | ||
| 31 | #include <asm/mach-types.h> | ||
| 32 | |||
| 33 | //#include <asm/debug-ll.h> | ||
| 34 | #include <asm/arch/regs-serial.h> | ||
| 35 | #include <asm/arch/regs-gpio.h> | ||
| 36 | #include <asm/arch/regs-lcd.h> | ||
| 37 | |||
| 38 | #include <asm/arch/idle.h> | ||
| 39 | #include <asm/arch/fb.h> | ||
| 40 | |||
| 41 | #include "s3c2410.h" | ||
| 42 | #include "s3c2412.h" | ||
| 43 | #include "clock.h" | ||
| 44 | #include "devs.h" | ||
| 45 | #include "cpu.h" | ||
| 46 | |||
| 47 | #include "common-smdk.h" | ||
| 48 | |||
| 49 | static struct map_desc smdk2413_iodesc[] __initdata = { | ||
| 50 | }; | ||
| 51 | |||
| 52 | static struct s3c2410_uartcfg smdk2413_uartcfgs[] __initdata = { | ||
| 53 | [0] = { | ||
| 54 | .hwport = 0, | ||
| 55 | .flags = 0, | ||
| 56 | .ucon = 0x3c5, | ||
| 57 | .ulcon = 0x03, | ||
| 58 | .ufcon = 0x51, | ||
| 59 | }, | ||
| 60 | [1] = { | ||
| 61 | .hwport = 1, | ||
| 62 | .flags = 0, | ||
| 63 | .ucon = 0x3c5, | ||
| 64 | .ulcon = 0x03, | ||
| 65 | .ufcon = 0x51, | ||
| 66 | }, | ||
| 67 | /* IR port */ | ||
| 68 | [2] = { | ||
| 69 | .hwport = 2, | ||
| 70 | .flags = 0, | ||
| 71 | .ucon = 0x3c5, | ||
| 72 | .ulcon = 0x43, | ||
| 73 | .ufcon = 0x51, | ||
| 74 | } | ||
| 75 | }; | ||
| 76 | |||
| 77 | static struct platform_device *smdk2413_devices[] __initdata = { | ||
| 78 | &s3c_device_usb, | ||
| 79 | //&s3c_device_lcd, | ||
| 80 | &s3c_device_wdt, | ||
| 81 | &s3c_device_i2c, | ||
| 82 | &s3c_device_iis, | ||
| 83 | }; | ||
| 84 | |||
| 85 | static struct s3c24xx_board smdk2413_board __initdata = { | ||
| 86 | .devices = smdk2413_devices, | ||
| 87 | .devices_count = ARRAY_SIZE(smdk2413_devices) | ||
| 88 | }; | ||
| 89 | |||
| 90 | static void __init smdk2413_fixup(struct machine_desc *desc, | ||
| 91 | struct tag *tags, char **cmdline, | ||
| 92 | struct meminfo *mi) | ||
| 93 | { | ||
| 94 | if (tags != phys_to_virt(S3C2410_SDRAM_PA + 0x100)) { | ||
| 95 | mi->nr_banks=1; | ||
| 96 | mi->bank[0].start = 0x30000000; | ||
| 97 | mi->bank[0].size = SZ_64M; | ||
| 98 | mi->bank[0].node = 0; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | static void __init smdk2413_map_io(void) | ||
| 103 | { | ||
| 104 | s3c24xx_init_io(smdk2413_iodesc, ARRAY_SIZE(smdk2413_iodesc)); | ||
| 105 | s3c24xx_init_clocks(12000000); | ||
| 106 | s3c24xx_init_uarts(smdk2413_uartcfgs, ARRAY_SIZE(smdk2413_uartcfgs)); | ||
| 107 | s3c24xx_set_board(&smdk2413_board); | ||
| 108 | } | ||
| 109 | |||
| 110 | static void __init smdk2413_machine_init(void) | ||
| 111 | { | ||
| 112 | smdk_machine_init(); | ||
| 113 | } | ||
| 114 | |||
| 115 | MACHINE_START(S3C2413, "SMDK2413") | ||
| 116 | /* Maintainer: Ben Dooks <ben@fluff.org> */ | ||
| 117 | .phys_io = S3C2410_PA_UART, | ||
| 118 | .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc, | ||
| 119 | .boot_params = S3C2410_SDRAM_PA + 0x100, | ||
| 120 | |||
| 121 | .fixup = smdk2413_fixup, | ||
| 122 | .init_irq = s3c24xx_init_irq, | ||
| 123 | .map_io = smdk2413_map_io, | ||
| 124 | .init_machine = smdk2413_machine_init, | ||
| 125 | .timer = &s3c24xx_timer, | ||
| 126 | MACHINE_END | ||
diff --git a/arch/arm/mach-s3c2410/pm-simtec.c b/arch/arm/mach-s3c2410/pm-simtec.c index 4c7ccef6c207..7b244566a436 100644 --- a/arch/arm/mach-s3c2410/pm-simtec.c +++ b/arch/arm/mach-s3c2410/pm-simtec.c | |||
| @@ -48,7 +48,8 @@ static __init int pm_simtec_init(void) | |||
| 48 | 48 | ||
| 49 | /* check which machine we are running on */ | 49 | /* check which machine we are running on */ |
| 50 | 50 | ||
| 51 | if (!machine_is_bast() && !machine_is_vr1000() && !machine_is_anubis()) | 51 | if (!machine_is_bast() && !machine_is_vr1000() && |
| 52 | !machine_is_anubis() && !machine_is_osiris()) | ||
| 52 | return 0; | 53 | return 0; |
| 53 | 54 | ||
| 54 | printk(KERN_INFO "Simtec Board Power Manangement" COPYRIGHT "\n"); | 55 | printk(KERN_INFO "Simtec Board Power Manangement" COPYRIGHT "\n"); |
diff --git a/arch/arm/mach-s3c2410/s3c2410-clock.c b/arch/arm/mach-s3c2410/s3c2410-clock.c index fd17c60e1132..99718663318e 100644 --- a/arch/arm/mach-s3c2410/s3c2410-clock.c +++ b/arch/arm/mach-s3c2410/s3c2410-clock.c | |||
| @@ -182,7 +182,15 @@ static struct clk init_clocks[] = { | |||
| 182 | .id = -1, | 182 | .id = -1, |
| 183 | .parent = &clk_p, | 183 | .parent = &clk_p, |
| 184 | .ctrlbit = 0, | 184 | .ctrlbit = 0, |
| 185 | } | 185 | }, { |
| 186 | .name = "usb-bus-host", | ||
| 187 | .id = -1, | ||
| 188 | .parent = &clk_usb_bus, | ||
| 189 | }, { | ||
| 190 | .name = "usb-bus-gadget", | ||
| 191 | .id = -1, | ||
| 192 | .parent = &clk_usb_bus, | ||
| 193 | }, | ||
| 186 | }; | 194 | }; |
| 187 | 195 | ||
| 188 | /* s3c2410_baseclk_add() | 196 | /* s3c2410_baseclk_add() |
diff --git a/arch/arm/mach-s3c2410/s3c2410-gpio.c b/arch/arm/mach-s3c2410/s3c2410-gpio.c index d5e1caea1d23..471a71490010 100644 --- a/arch/arm/mach-s3c2410/s3c2410-gpio.c +++ b/arch/arm/mach-s3c2410/s3c2410-gpio.c | |||
| @@ -18,9 +18,6 @@ | |||
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | * | ||
| 22 | * Changelog | ||
| 23 | * 15-Jan-2006 LCVR Splitted from gpio.c | ||
| 24 | */ | 21 | */ |
| 25 | 22 | ||
| 26 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
| @@ -38,7 +35,7 @@ | |||
| 38 | int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on, | 35 | int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on, |
| 39 | unsigned int config) | 36 | unsigned int config) |
| 40 | { | 37 | { |
| 41 | void __iomem *reg = S3C2410_EINFLT0; | 38 | void __iomem *reg = S3C24XX_EINFLT0; |
| 42 | unsigned long flags; | 39 | unsigned long flags; |
| 43 | unsigned long val; | 40 | unsigned long val; |
| 44 | 41 | ||
| @@ -47,7 +44,7 @@ int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on, | |||
| 47 | 44 | ||
| 48 | config &= 0xff; | 45 | config &= 0xff; |
| 49 | 46 | ||
| 50 | pin -= S3C2410_GPG8_EINT16; | 47 | pin -= S3C2410_GPG8; |
| 51 | reg += pin & ~3; | 48 | reg += pin & ~3; |
| 52 | 49 | ||
| 53 | local_irq_save(flags); | 50 | local_irq_save(flags); |
| @@ -61,10 +58,10 @@ int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on, | |||
| 61 | 58 | ||
| 62 | /* update filter enable */ | 59 | /* update filter enable */ |
| 63 | 60 | ||
| 64 | val = __raw_readl(S3C2410_EXTINT2); | 61 | val = __raw_readl(S3C24XX_EXTINT2); |
| 65 | val &= ~(1 << ((pin * 4) + 3)); | 62 | val &= ~(1 << ((pin * 4) + 3)); |
| 66 | val |= on << ((pin * 4) + 3); | 63 | val |= on << ((pin * 4) + 3); |
| 67 | __raw_writel(val, S3C2410_EXTINT2); | 64 | __raw_writel(val, S3C24XX_EXTINT2); |
| 68 | 65 | ||
| 69 | local_irq_restore(flags); | 66 | local_irq_restore(flags); |
| 70 | 67 | ||
| @@ -75,7 +72,7 @@ EXPORT_SYMBOL(s3c2410_gpio_irqfilter); | |||
| 75 | 72 | ||
| 76 | int s3c2410_gpio_getirq(unsigned int pin) | 73 | int s3c2410_gpio_getirq(unsigned int pin) |
| 77 | { | 74 | { |
| 78 | if (pin < S3C2410_GPF0 || pin > S3C2410_GPG15_EINT23) | 75 | if (pin < S3C2410_GPF0 || pin > S3C2410_GPG15) |
| 79 | return -1; /* not valid interrupts */ | 76 | return -1; /* not valid interrupts */ |
| 80 | 77 | ||
| 81 | if (pin < S3C2410_GPG0 && pin > S3C2410_GPF7) | 78 | if (pin < S3C2410_GPG0 && pin > S3C2410_GPF7) |
diff --git a/arch/arm/mach-s3c2410/s3c2412-clock.c b/arch/arm/mach-s3c2410/s3c2412-clock.c new file mode 100644 index 000000000000..c95ed3e18580 --- /dev/null +++ b/arch/arm/mach-s3c2410/s3c2412-clock.c | |||
| @@ -0,0 +1,711 @@ | |||
| 1 | /* linux/arch/arm/mach-s3c2410/s3c2412-clock.c | ||
| 2 | * | ||
| 3 | * Copyright (c) 2006 Simtec Electronics | ||
| 4 | * Ben Dooks <ben@simtec.co.uk> | ||
| 5 | * | ||
| 6 | * S3C2412,S3C2413 Clock control support | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License, or | ||
| 11 | * (at your option) any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License | ||
| 19 | * along with this program; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <linux/init.h> | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/kernel.h> | ||
| 26 | #include <linux/list.h> | ||
| 27 | #include <linux/errno.h> | ||
| 28 | #include <linux/err.h> | ||
| 29 | #include <linux/sysdev.h> | ||
| 30 | #include <linux/clk.h> | ||
| 31 | #include <linux/mutex.h> | ||
| 32 | #include <linux/delay.h> | ||
| 33 | |||
| 34 | #include <asm/hardware.h> | ||
| 35 | #include <asm/io.h> | ||
| 36 | |||
| 37 | #include <asm/arch/regs-clock.h> | ||
| 38 | #include <asm/arch/regs-gpio.h> | ||
| 39 | |||
| 40 | #include "clock.h" | ||
| 41 | #include "cpu.h" | ||
| 42 | |||
| 43 | /* We currently have to assume that the system is running | ||
| 44 | * from the XTPll input, and that all ***REFCLKs are being | ||
| 45 | * fed from it, as we cannot read the state of OM[4] from | ||
| 46 | * software. | ||
| 47 | * | ||
| 48 | * It would be possible for each board initialisation to | ||
| 49 | * set the correct muxing at initialisation | ||
| 50 | */ | ||
| 51 | |||
| 52 | int s3c2412_clkcon_enable(struct clk *clk, int enable) | ||
| 53 | { | ||
| 54 | unsigned int clocks = clk->ctrlbit; | ||
| 55 | unsigned long clkcon; | ||
| 56 | |||
| 57 | clkcon = __raw_readl(S3C2410_CLKCON); | ||
| 58 | |||
| 59 | if (enable) | ||
| 60 | clkcon |= clocks; | ||
| 61 | else | ||
| 62 | clkcon &= ~clocks; | ||
| 63 | |||
| 64 | __raw_writel(clkcon, S3C2410_CLKCON); | ||
| 65 | |||
| 66 | return 0; | ||
| 67 | } | ||
| 68 | |||
| 69 | static int s3c2412_upll_enable(struct clk *clk, int enable) | ||
| 70 | { | ||
| 71 | unsigned long upllcon = __raw_readl(S3C2410_UPLLCON); | ||
| 72 | unsigned long orig = upllcon; | ||
| 73 | |||
| 74 | if (!enable) | ||
| 75 | upllcon |= S3C2412_PLLCON_OFF; | ||
| 76 | else | ||
| 77 | upllcon &= ~S3C2412_PLLCON_OFF; | ||
| 78 | |||
| 79 | __raw_writel(upllcon, S3C2410_UPLLCON); | ||
| 80 | |||
| 81 | /* allow ~150uS for the PLL to settle and lock */ | ||
| 82 | |||
| 83 | if (enable && (orig & S3C2412_PLLCON_OFF)) | ||
| 84 | udelay(150); | ||
| 85 | |||
| 86 | return 0; | ||
| 87 | } | ||
| 88 | |||
| 89 | /* clock selections */ | ||
| 90 | |||
| 91 | /* CPU EXTCLK input */ | ||
| 92 | static struct clk clk_ext = { | ||
| 93 | .name = "extclk", | ||
| 94 | .id = -1, | ||
| 95 | }; | ||
| 96 | |||
| 97 | static struct clk clk_erefclk = { | ||
| 98 | .name = "erefclk", | ||
| 99 | .id = -1, | ||
| 100 | }; | ||
| 101 | |||
| 102 | static struct clk clk_urefclk = { | ||
| 103 | .name = "urefclk", | ||
| 104 | .id = -1, | ||
| 105 | }; | ||
| 106 | |||
| 107 | static int s3c2412_setparent_usysclk(struct clk *clk, struct clk *parent) | ||
| 108 | { | ||
| 109 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
| 110 | |||
| 111 | if (parent == &clk_urefclk) | ||
| 112 | clksrc &= ~S3C2412_CLKSRC_USYSCLK_UPLL; | ||
| 113 | else if (parent == &clk_upll) | ||
| 114 | clksrc |= S3C2412_CLKSRC_USYSCLK_UPLL; | ||
| 115 | else | ||
| 116 | return -EINVAL; | ||
| 117 | |||
| 118 | clk->parent = parent; | ||
| 119 | |||
| 120 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
| 121 | return 0; | ||
| 122 | } | ||
| 123 | |||
| 124 | static struct clk clk_usysclk = { | ||
| 125 | .name = "usysclk", | ||
| 126 | .id = -1, | ||
| 127 | .parent = &clk_xtal, | ||
| 128 | .set_parent = s3c2412_setparent_usysclk, | ||
| 129 | }; | ||
| 130 | |||
| 131 | static struct clk clk_mrefclk = { | ||
| 132 | .name = "mrefclk", | ||
| 133 | .parent = &clk_xtal, | ||
| 134 | .id = -1, | ||
| 135 | }; | ||
| 136 | |||
| 137 | static struct clk clk_mdivclk = { | ||
| 138 | .name = "mdivclk", | ||
| 139 | .parent = &clk_xtal, | ||
| 140 | .id = -1, | ||
| 141 | }; | ||
| 142 | |||
| 143 | static int s3c2412_setparent_usbsrc(struct clk *clk, struct clk *parent) | ||
| 144 | { | ||
| 145 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
| 146 | |||
| 147 | if (parent == &clk_usysclk) | ||
| 148 | clksrc &= ~S3C2412_CLKSRC_USBCLK_HCLK; | ||
| 149 | else if (parent == &clk_h) | ||
| 150 | clksrc |= S3C2412_CLKSRC_USBCLK_HCLK; | ||
| 151 | else | ||
| 152 | return -EINVAL; | ||
| 153 | |||
| 154 | clk->parent = parent; | ||
| 155 | |||
| 156 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
| 157 | return 0; | ||
| 158 | } | ||
| 159 | |||
| 160 | static unsigned long s3c2412_roundrate_usbsrc(struct clk *clk, | ||
| 161 | unsigned long rate) | ||
| 162 | { | ||
| 163 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
| 164 | int div; | ||
| 165 | |||
| 166 | if (rate > parent_rate) | ||
| 167 | return parent_rate; | ||
| 168 | |||
| 169 | div = parent_rate / rate; | ||
| 170 | if (div > 2) | ||
| 171 | div = 2; | ||
| 172 | |||
| 173 | return parent_rate / div; | ||
| 174 | } | ||
| 175 | |||
| 176 | static unsigned long s3c2412_getrate_usbsrc(struct clk *clk) | ||
| 177 | { | ||
| 178 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
| 179 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
| 180 | |||
| 181 | return parent_rate / ((div & S3C2412_CLKDIVN_USB48DIV) ? 2 : 1); | ||
| 182 | } | ||
| 183 | |||
| 184 | static int s3c2412_setrate_usbsrc(struct clk *clk, unsigned long rate) | ||
| 185 | { | ||
| 186 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
| 187 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
| 188 | |||
| 189 | rate = s3c2412_roundrate_usbsrc(clk, rate); | ||
| 190 | |||
| 191 | if ((parent_rate / rate) == 2) | ||
| 192 | clkdivn |= S3C2412_CLKDIVN_USB48DIV; | ||
| 193 | else | ||
| 194 | clkdivn &= ~S3C2412_CLKDIVN_USB48DIV; | ||
| 195 | |||
| 196 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
| 197 | return 0; | ||
| 198 | } | ||
| 199 | |||
| 200 | static struct clk clk_usbsrc = { | ||
| 201 | .name = "usbsrc", | ||
| 202 | .id = -1, | ||
| 203 | .get_rate = s3c2412_getrate_usbsrc, | ||
| 204 | .set_rate = s3c2412_setrate_usbsrc, | ||
| 205 | .round_rate = s3c2412_roundrate_usbsrc, | ||
| 206 | .set_parent = s3c2412_setparent_usbsrc, | ||
| 207 | }; | ||
| 208 | |||
| 209 | static int s3c2412_setparent_msysclk(struct clk *clk, struct clk *parent) | ||
| 210 | { | ||
| 211 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
| 212 | |||
| 213 | if (parent == &clk_mdivclk) | ||
| 214 | clksrc &= ~S3C2412_CLKSRC_MSYSCLK_MPLL; | ||
| 215 | else if (parent == &clk_upll) | ||
| 216 | clksrc |= S3C2412_CLKSRC_MSYSCLK_MPLL; | ||
| 217 | else | ||
| 218 | return -EINVAL; | ||
| 219 | |||
| 220 | clk->parent = parent; | ||
| 221 | |||
| 222 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
| 223 | return 0; | ||
| 224 | } | ||
| 225 | |||
| 226 | static struct clk clk_msysclk = { | ||
| 227 | .name = "msysclk", | ||
| 228 | .id = -1, | ||
| 229 | .set_parent = s3c2412_setparent_msysclk, | ||
| 230 | }; | ||
| 231 | |||
| 232 | /* these next clocks have an divider immediately after them, | ||
| 233 | * so we can register them with their divider and leave out the | ||
| 234 | * intermediate clock stage | ||
| 235 | */ | ||
| 236 | static unsigned long s3c2412_roundrate_clksrc(struct clk *clk, | ||
| 237 | unsigned long rate) | ||
| 238 | { | ||
| 239 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
| 240 | int div; | ||
| 241 | |||
| 242 | if (rate > parent_rate) | ||
| 243 | return parent_rate; | ||
| 244 | |||
| 245 | /* note, we remove the +/- 1 calculations as they cancel out */ | ||
| 246 | |||
| 247 | div = (rate / parent_rate); | ||
| 248 | |||
| 249 | if (div < 1) | ||
| 250 | div = 1; | ||
| 251 | else if (div > 16) | ||
| 252 | div = 16; | ||
| 253 | |||
| 254 | return parent_rate / div; | ||
| 255 | } | ||
| 256 | |||
| 257 | static int s3c2412_setparent_uart(struct clk *clk, struct clk *parent) | ||
| 258 | { | ||
| 259 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
| 260 | |||
| 261 | if (parent == &clk_erefclk) | ||
| 262 | clksrc &= ~S3C2412_CLKSRC_UARTCLK_MPLL; | ||
| 263 | else if (parent == &clk_mpll) | ||
| 264 | clksrc |= S3C2412_CLKSRC_UARTCLK_MPLL; | ||
| 265 | else | ||
| 266 | return -EINVAL; | ||
| 267 | |||
| 268 | clk->parent = parent; | ||
| 269 | |||
| 270 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
| 271 | return 0; | ||
| 272 | } | ||
| 273 | |||
| 274 | static unsigned long s3c2412_getrate_uart(struct clk *clk) | ||
| 275 | { | ||
| 276 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
| 277 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
| 278 | |||
| 279 | div &= S3C2412_CLKDIVN_UARTDIV_MASK; | ||
| 280 | div >>= S3C2412_CLKDIVN_UARTDIV_SHIFT; | ||
| 281 | |||
| 282 | return parent_rate / (div + 1); | ||
| 283 | } | ||
| 284 | |||
| 285 | static int s3c2412_setrate_uart(struct clk *clk, unsigned long rate) | ||
| 286 | { | ||
| 287 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
| 288 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
| 289 | |||
| 290 | rate = s3c2412_roundrate_clksrc(clk, rate); | ||
| 291 | |||
| 292 | clkdivn &= ~S3C2412_CLKDIVN_UARTDIV_MASK; | ||
| 293 | clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_UARTDIV_SHIFT; | ||
| 294 | |||
| 295 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
| 296 | return 0; | ||
| 297 | } | ||
| 298 | |||
| 299 | static struct clk clk_uart = { | ||
| 300 | .name = "uartclk", | ||
| 301 | .id = -1, | ||
| 302 | .get_rate = s3c2412_getrate_uart, | ||
| 303 | .set_rate = s3c2412_setrate_uart, | ||
| 304 | .set_parent = s3c2412_setparent_uart, | ||
| 305 | .round_rate = s3c2412_roundrate_clksrc, | ||
| 306 | }; | ||
| 307 | |||
| 308 | static int s3c2412_setparent_i2s(struct clk *clk, struct clk *parent) | ||
| 309 | { | ||
| 310 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
| 311 | |||
| 312 | if (parent == &clk_erefclk) | ||
| 313 | clksrc &= ~S3C2412_CLKSRC_I2SCLK_MPLL; | ||
| 314 | else if (parent == &clk_mpll) | ||
| 315 | clksrc |= S3C2412_CLKSRC_I2SCLK_MPLL; | ||
| 316 | else | ||
| 317 | return -EINVAL; | ||
| 318 | |||
| 319 | clk->parent = parent; | ||
| 320 | |||
| 321 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
| 322 | return 0; | ||
| 323 | } | ||
| 324 | |||
| 325 | static unsigned long s3c2412_getrate_i2s(struct clk *clk) | ||
| 326 | { | ||
| 327 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
| 328 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
| 329 | |||
| 330 | div &= S3C2412_CLKDIVN_I2SDIV_MASK; | ||
| 331 | div >>= S3C2412_CLKDIVN_I2SDIV_SHIFT; | ||
| 332 | |||
| 333 | return parent_rate / (div + 1); | ||
| 334 | } | ||
| 335 | |||
| 336 | static int s3c2412_setrate_i2s(struct clk *clk, unsigned long rate) | ||
| 337 | { | ||
| 338 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
| 339 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
| 340 | |||
| 341 | rate = s3c2412_roundrate_clksrc(clk, rate); | ||
| 342 | |||
| 343 | clkdivn &= ~S3C2412_CLKDIVN_I2SDIV_MASK; | ||
| 344 | clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_I2SDIV_SHIFT; | ||
| 345 | |||
| 346 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
| 347 | return 0; | ||
| 348 | } | ||
| 349 | |||
| 350 | static struct clk clk_i2s = { | ||
| 351 | .name = "i2sclk", | ||
| 352 | .id = -1, | ||
| 353 | .get_rate = s3c2412_getrate_i2s, | ||
| 354 | .set_rate = s3c2412_setrate_i2s, | ||
| 355 | .set_parent = s3c2412_setparent_i2s, | ||
| 356 | .round_rate = s3c2412_roundrate_clksrc, | ||
| 357 | }; | ||
| 358 | |||
| 359 | static int s3c2412_setparent_cam(struct clk *clk, struct clk *parent) | ||
| 360 | { | ||
| 361 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
| 362 | |||
| 363 | if (parent == &clk_usysclk) | ||
| 364 | clksrc &= ~S3C2412_CLKSRC_CAMCLK_HCLK; | ||
| 365 | else if (parent == &clk_h) | ||
| 366 | clksrc |= S3C2412_CLKSRC_CAMCLK_HCLK; | ||
| 367 | else | ||
| 368 | return -EINVAL; | ||
| 369 | |||
| 370 | clk->parent = parent; | ||
| 371 | |||
| 372 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
| 373 | return 0; | ||
| 374 | } | ||
| 375 | static unsigned long s3c2412_getrate_cam(struct clk *clk) | ||
| 376 | { | ||
| 377 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
| 378 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
| 379 | |||
| 380 | div &= S3C2412_CLKDIVN_CAMDIV_MASK; | ||
| 381 | div >>= S3C2412_CLKDIVN_CAMDIV_SHIFT; | ||
| 382 | |||
| 383 | return parent_rate / (div + 1); | ||
| 384 | } | ||
| 385 | |||
| 386 | static int s3c2412_setrate_cam(struct clk *clk, unsigned long rate) | ||
| 387 | { | ||
| 388 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
| 389 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
| 390 | |||
| 391 | rate = s3c2412_roundrate_clksrc(clk, rate); | ||
| 392 | |||
| 393 | clkdivn &= ~S3C2412_CLKDIVN_CAMDIV_MASK; | ||
| 394 | clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_CAMDIV_SHIFT; | ||
| 395 | |||
| 396 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
| 397 | return 0; | ||
| 398 | } | ||
| 399 | |||
| 400 | static struct clk clk_cam = { | ||
| 401 | .name = "camif-upll", /* same as 2440 name */ | ||
| 402 | .id = -1, | ||
| 403 | .get_rate = s3c2412_getrate_cam, | ||
| 404 | .set_rate = s3c2412_setrate_cam, | ||
| 405 | .set_parent = s3c2412_setparent_cam, | ||
| 406 | .round_rate = s3c2412_roundrate_clksrc, | ||
| 407 | }; | ||
| 408 | |||
| 409 | /* standard clock definitions */ | ||
| 410 | |||
| 411 | static struct clk init_clocks_disable[] = { | ||
| 412 | { | ||
| 413 | .name = "nand", | ||
| 414 | .id = -1, | ||
| 415 | .parent = &clk_h, | ||
| 416 | .enable = s3c2412_clkcon_enable, | ||
| 417 | .ctrlbit = S3C2412_CLKCON_NAND, | ||
| 418 | }, { | ||
| 419 | .name = "sdi", | ||
| 420 | .id = -1, | ||
| 421 | .parent = &clk_p, | ||
| 422 | .enable = s3c2412_clkcon_enable, | ||
| 423 | .ctrlbit = S3C2412_CLKCON_SDI, | ||
| 424 | }, { | ||
| 425 | .name = "adc", | ||
| 426 | .id = -1, | ||
| 427 | .parent = &clk_p, | ||
| 428 | .enable = s3c2412_clkcon_enable, | ||
| 429 | .ctrlbit = S3C2412_CLKCON_ADC, | ||
| 430 | }, { | ||
| 431 | .name = "i2c", | ||
| 432 | .id = -1, | ||
| 433 | .parent = &clk_p, | ||
| 434 | .enable = s3c2412_clkcon_enable, | ||
| 435 | .ctrlbit = S3C2412_CLKCON_IIC, | ||
| 436 | }, { | ||
| 437 | .name = "iis", | ||
| 438 | .id = -1, | ||
| 439 | .parent = &clk_p, | ||
| 440 | .enable = s3c2412_clkcon_enable, | ||
| 441 | .ctrlbit = S3C2412_CLKCON_IIS, | ||
| 442 | }, { | ||
| 443 | .name = "spi", | ||
| 444 | .id = -1, | ||
| 445 | .parent = &clk_p, | ||
| 446 | .enable = s3c2412_clkcon_enable, | ||
| 447 | .ctrlbit = S3C2412_CLKCON_SPI, | ||
| 448 | } | ||
| 449 | }; | ||
| 450 | |||
| 451 | static struct clk init_clocks[] = { | ||
| 452 | { | ||
| 453 | .name = "dma", | ||
| 454 | .id = 0, | ||
| 455 | .parent = &clk_h, | ||
| 456 | .enable = s3c2412_clkcon_enable, | ||
| 457 | .ctrlbit = S3C2412_CLKCON_DMA0, | ||
| 458 | }, { | ||
| 459 | .name = "dma", | ||
| 460 | .id = 1, | ||
| 461 | .parent = &clk_h, | ||
| 462 | .enable = s3c2412_clkcon_enable, | ||
| 463 | .ctrlbit = S3C2412_CLKCON_DMA1, | ||
| 464 | }, { | ||
| 465 | .name = "dma", | ||
| 466 | .id = 2, | ||
| 467 | .parent = &clk_h, | ||
| 468 | .enable = s3c2412_clkcon_enable, | ||
| 469 | .ctrlbit = S3C2412_CLKCON_DMA2, | ||
| 470 | }, { | ||
| 471 | .name = "dma", | ||
| 472 | .id = 3, | ||
| 473 | .parent = &clk_h, | ||
| 474 | .enable = s3c2412_clkcon_enable, | ||
| 475 | .ctrlbit = S3C2412_CLKCON_DMA3, | ||
| 476 | }, { | ||
| 477 | .name = "lcd", | ||
| 478 | .id = -1, | ||
| 479 | .parent = &clk_h, | ||
| 480 | .enable = s3c2412_clkcon_enable, | ||
| 481 | .ctrlbit = S3C2412_CLKCON_LCDC, | ||
| 482 | }, { | ||
| 483 | .name = "gpio", | ||
| 484 | .id = -1, | ||
| 485 | .parent = &clk_p, | ||
| 486 | .enable = s3c2412_clkcon_enable, | ||
| 487 | .ctrlbit = S3C2412_CLKCON_GPIO, | ||
| 488 | }, { | ||
| 489 | .name = "usb-host", | ||
| 490 | .id = -1, | ||
| 491 | .parent = &clk_h, | ||
| 492 | .enable = s3c2412_clkcon_enable, | ||
| 493 | .ctrlbit = S3C2412_CLKCON_USBH, | ||
| 494 | }, { | ||
| 495 | .name = "usb-device", | ||
| 496 | .id = -1, | ||
| 497 | .parent = &clk_h, | ||
| 498 | .enable = s3c2412_clkcon_enable, | ||
| 499 | .ctrlbit = S3C2412_CLKCON_USBD, | ||
| 500 | }, { | ||
| 501 | .name = "timers", | ||
| 502 | .id = -1, | ||
| 503 | .parent = &clk_p, | ||
| 504 | .enable = s3c2412_clkcon_enable, | ||
| 505 | .ctrlbit = S3C2412_CLKCON_PWMT, | ||
| 506 | }, { | ||
| 507 | .name = "uart", | ||
| 508 | .id = 0, | ||
| 509 | .parent = &clk_p, | ||
| 510 | .enable = s3c2412_clkcon_enable, | ||
| 511 | .ctrlbit = S3C2412_CLKCON_UART0, | ||
| 512 | }, { | ||
| 513 | .name = "uart", | ||
| 514 | .id = 1, | ||
| 515 | .parent = &clk_p, | ||
| 516 | .enable = s3c2412_clkcon_enable, | ||
| 517 | .ctrlbit = S3C2412_CLKCON_UART1, | ||
| 518 | }, { | ||
| 519 | .name = "uart", | ||
| 520 | .id = 2, | ||
| 521 | .parent = &clk_p, | ||
| 522 | .enable = s3c2412_clkcon_enable, | ||
| 523 | .ctrlbit = S3C2412_CLKCON_UART2, | ||
| 524 | }, { | ||
| 525 | .name = "rtc", | ||
| 526 | .id = -1, | ||
| 527 | .parent = &clk_p, | ||
| 528 | .enable = s3c2412_clkcon_enable, | ||
| 529 | .ctrlbit = S3C2412_CLKCON_RTC, | ||
| 530 | }, { | ||
| 531 | .name = "watchdog", | ||
| 532 | .id = -1, | ||
| 533 | .parent = &clk_p, | ||
| 534 | .ctrlbit = 0, | ||
| 535 | }, { | ||
| 536 | .name = "usb-bus-gadget", | ||
| 537 | .id = -1, | ||
| 538 | .parent = &clk_usb_bus, | ||
| 539 | .enable = s3c2412_clkcon_enable, | ||
| 540 | .ctrlbit = S3C2412_CLKCON_USB_DEV48, | ||
| 541 | }, { | ||
| 542 | .name = "usb-bus-host", | ||
| 543 | .id = -1, | ||
| 544 | .parent = &clk_usb_bus, | ||
| 545 | .enable = s3c2412_clkcon_enable, | ||
| 546 | .ctrlbit = S3C2412_CLKCON_USB_HOST48, | ||
| 547 | } | ||
| 548 | }; | ||
| 549 | |||
| 550 | /* clocks to add where we need to check their parentage */ | ||
| 551 | |||
| 552 | struct clk_init { | ||
| 553 | struct clk *clk; | ||
| 554 | unsigned int bit; | ||
| 555 | struct clk *src_0; | ||
| 556 | struct clk *src_1; | ||
| 557 | }; | ||
| 558 | |||
| 559 | struct clk_init clks_src[] __initdata = { | ||
| 560 | { | ||
| 561 | .clk = &clk_usysclk, | ||
| 562 | .bit = S3C2412_CLKSRC_USBCLK_HCLK, | ||
| 563 | .src_0 = &clk_urefclk, | ||
| 564 | .src_1 = &clk_upll, | ||
| 565 | }, { | ||
| 566 | .clk = &clk_i2s, | ||
| 567 | .bit = S3C2412_CLKSRC_I2SCLK_MPLL, | ||
| 568 | .src_0 = &clk_erefclk, | ||
| 569 | .src_1 = &clk_mpll, | ||
| 570 | }, { | ||
| 571 | .clk = &clk_cam, | ||
| 572 | .bit = S3C2412_CLKSRC_CAMCLK_HCLK, | ||
| 573 | .src_0 = &clk_usysclk, | ||
| 574 | .src_1 = &clk_h, | ||
| 575 | }, { | ||
| 576 | .clk = &clk_msysclk, | ||
| 577 | .bit = S3C2412_CLKSRC_MSYSCLK_MPLL, | ||
| 578 | .src_0 = &clk_mdivclk, | ||
| 579 | .src_1 = &clk_mpll, | ||
| 580 | }, { | ||
| 581 | .clk = &clk_uart, | ||
| 582 | .bit = S3C2412_CLKSRC_UARTCLK_MPLL, | ||
| 583 | .src_0 = &clk_erefclk, | ||
| 584 | .src_1 = &clk_mpll, | ||
| 585 | }, { | ||
| 586 | .clk = &clk_usbsrc, | ||
| 587 | .bit = S3C2412_CLKSRC_USBCLK_HCLK, | ||
| 588 | .src_0 = &clk_usysclk, | ||
| 589 | .src_1 = &clk_h, | ||
| 590 | }, | ||
| 591 | }; | ||
| 592 | |||
| 593 | /* s3c2412_clk_initparents | ||
| 594 | * | ||
| 595 | * Initialise the parents for the clocks that we get at start-time | ||
| 596 | */ | ||
| 597 | |||
| 598 | static void __init s3c2412_clk_initparents(void) | ||
| 599 | { | ||
| 600 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
| 601 | struct clk_init *cip = clks_src; | ||
| 602 | struct clk *src; | ||
| 603 | int ptr; | ||
| 604 | int ret; | ||
| 605 | |||
| 606 | for (ptr = 0; ptr < ARRAY_SIZE(clks_src); ptr++, cip++) { | ||
| 607 | ret = s3c24xx_register_clock(cip->clk); | ||
| 608 | if (ret < 0) { | ||
| 609 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
| 610 | cip->clk->name, ret); | ||
| 611 | } | ||
| 612 | |||
| 613 | src = (clksrc & cip->bit) ? cip->src_1 : cip->src_0; | ||
| 614 | |||
| 615 | printk(KERN_INFO "%s: parent %s\n", cip->clk->name, src->name); | ||
| 616 | clk_set_parent(cip->clk, src); | ||
| 617 | } | ||
| 618 | } | ||
| 619 | |||
| 620 | /* clocks to add straight away */ | ||
| 621 | |||
| 622 | struct clk *clks[] __initdata = { | ||
| 623 | &clk_ext, | ||
| 624 | &clk_usb_bus, | ||
| 625 | &clk_erefclk, | ||
| 626 | &clk_urefclk, | ||
| 627 | &clk_mrefclk, | ||
| 628 | }; | ||
| 629 | |||
| 630 | int __init s3c2412_baseclk_add(void) | ||
| 631 | { | ||
| 632 | unsigned long clkcon = __raw_readl(S3C2410_CLKCON); | ||
| 633 | struct clk *clkp; | ||
| 634 | int ret; | ||
| 635 | int ptr; | ||
| 636 | |||
| 637 | clk_upll.enable = s3c2412_upll_enable; | ||
| 638 | clk_usb_bus.parent = &clk_usbsrc; | ||
| 639 | clk_usb_bus.rate = 0x0; | ||
| 640 | |||
| 641 | s3c2412_clk_initparents(); | ||
| 642 | |||
| 643 | for (ptr = 0; ptr < ARRAY_SIZE(clks); ptr++) { | ||
| 644 | clkp = clks[ptr]; | ||
| 645 | |||
| 646 | ret = s3c24xx_register_clock(clkp); | ||
| 647 | if (ret < 0) { | ||
| 648 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
| 649 | clkp->name, ret); | ||
| 650 | } | ||
| 651 | } | ||
| 652 | |||
| 653 | /* ensure usb bus clock is within correct rate of 48MHz */ | ||
| 654 | |||
| 655 | if (clk_get_rate(&clk_usb_bus) != (48 * 1000 * 1000)) { | ||
| 656 | printk(KERN_INFO "Warning: USB bus clock not at 48MHz\n"); | ||
| 657 | |||
| 658 | /* for the moment, let's use the UPLL, and see if we can | ||
| 659 | * get 48MHz */ | ||
| 660 | |||
| 661 | clk_set_parent(&clk_usysclk, &clk_upll); | ||
| 662 | clk_set_parent(&clk_usbsrc, &clk_usysclk); | ||
| 663 | clk_set_rate(&clk_usbsrc, 48*1000*1000); | ||
| 664 | } | ||
| 665 | |||
| 666 | printk("S3C2412: upll %s, %ld.%03ld MHz, usb-bus %ld.%03ld MHz\n", | ||
| 667 | (__raw_readl(S3C2410_UPLLCON) & S3C2412_PLLCON_OFF) ? "off":"on", | ||
| 668 | print_mhz(clk_get_rate(&clk_upll)), | ||
| 669 | print_mhz(clk_get_rate(&clk_usb_bus))); | ||
| 670 | |||
| 671 | /* register clocks from clock array */ | ||
| 672 | |||
| 673 | clkp = init_clocks; | ||
| 674 | for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) { | ||
| 675 | /* ensure that we note the clock state */ | ||
| 676 | |||
| 677 | clkp->usage = clkcon & clkp->ctrlbit ? 1 : 0; | ||
| 678 | |||
| 679 | ret = s3c24xx_register_clock(clkp); | ||
| 680 | if (ret < 0) { | ||
| 681 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
| 682 | clkp->name, ret); | ||
| 683 | } | ||
| 684 | } | ||
| 685 | |||
| 686 | /* We must be careful disabling the clocks we are not intending to | ||
| 687 | * be using at boot time, as subsytems such as the LCD which do | ||
| 688 | * their own DMA requests to the bus can cause the system to lockup | ||
| 689 | * if they where in the middle of requesting bus access. | ||
| 690 | * | ||
| 691 | * Disabling the LCD clock if the LCD is active is very dangerous, | ||
| 692 | * and therefore the bootloader should be careful to not enable | ||
| 693 | * the LCD clock if it is not needed. | ||
| 694 | */ | ||
| 695 | |||
| 696 | /* install (and disable) the clocks we do not need immediately */ | ||
| 697 | |||
| 698 | clkp = init_clocks_disable; | ||
| 699 | for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) { | ||
| 700 | |||
| 701 | ret = s3c24xx_register_clock(clkp); | ||
| 702 | if (ret < 0) { | ||
| 703 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
| 704 | clkp->name, ret); | ||
| 705 | } | ||
| 706 | |||
| 707 | s3c2412_clkcon_enable(clkp, 0); | ||
| 708 | } | ||
| 709 | |||
| 710 | return 0; | ||
| 711 | } | ||
diff --git a/arch/arm/mach-s3c2410/s3c2412.c b/arch/arm/mach-s3c2410/s3c2412.c new file mode 100644 index 000000000000..e24ffd5e478b --- /dev/null +++ b/arch/arm/mach-s3c2410/s3c2412.c | |||
| @@ -0,0 +1,195 @@ | |||
| 1 | /* linux/arch/arm/mach-s3c2410/s3c2412.c | ||
| 2 | * | ||
| 3 | * Copyright (c) 2006 Simtec Electronics | ||
| 4 | * Ben Dooks <ben@simtec.co.uk> | ||
| 5 | * | ||
| 6 | * http://armlinux.simtec.co.uk/. | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License version 2 as | ||
| 10 | * published by the Free Software Foundation. | ||
| 11 | * | ||
| 12 | * Modifications: | ||
| 13 | * 16-May-2003 BJD Created initial version | ||
| 14 | * 16-Aug-2003 BJD Fixed header files and copyright, added URL | ||
| 15 | * 05-Sep-2003 BJD Moved to kernel v2.6 | ||
| 16 | * 18-Jan-2004 BJD Added serial port configuration | ||
| 17 | * 21-Aug-2004 BJD Added new struct s3c2410_board handler | ||
| 18 | * 28-Sep-2004 BJD Updates for new serial port bits | ||
| 19 | * 04-Nov-2004 BJD Updated UART configuration process | ||
| 20 | * 10-Jan-2005 BJD Removed s3c2410_clock_tick_rate | ||
| 21 | * 13-Aug-2005 DA Removed UART from initial I/O mappings | ||
| 22 | */ | ||
| 23 | |||
| 24 | #include <linux/kernel.h> | ||
| 25 | #include <linux/types.h> | ||
| 26 | #include <linux/interrupt.h> | ||
| 27 | #include <linux/list.h> | ||
| 28 | #include <linux/timer.h> | ||
| 29 | #include <linux/init.h> | ||
| 30 | #include <linux/sysdev.h> | ||
| 31 | #include <linux/platform_device.h> | ||
| 32 | |||
| 33 | #include <asm/mach/arch.h> | ||
| 34 | #include <asm/mach/map.h> | ||
| 35 | #include <asm/mach/irq.h> | ||
| 36 | |||
| 37 | #include <asm/hardware.h> | ||
| 38 | #include <asm/io.h> | ||
| 39 | #include <asm/irq.h> | ||
| 40 | |||
| 41 | #include <asm/arch/regs-clock.h> | ||
| 42 | #include <asm/arch/regs-serial.h> | ||
| 43 | #include <asm/arch/regs-gpio.h> | ||
| 44 | #include <asm/arch/regs-gpioj.h> | ||
| 45 | #include <asm/arch/regs-dsc.h> | ||
| 46 | |||
| 47 | #include "s3c2412.h" | ||
| 48 | #include "cpu.h" | ||
| 49 | #include "devs.h" | ||
| 50 | #include "clock.h" | ||
| 51 | #include "pm.h" | ||
| 52 | |||
| 53 | #ifndef CONFIG_CPU_S3C2412_ONLY | ||
| 54 | void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO; | ||
| 55 | #endif | ||
| 56 | |||
| 57 | /* Initial IO mappings */ | ||
| 58 | |||
| 59 | static struct map_desc s3c2412_iodesc[] __initdata = { | ||
| 60 | IODESC_ENT(CLKPWR), | ||
| 61 | IODESC_ENT(LCD), | ||
| 62 | IODESC_ENT(TIMER), | ||
| 63 | IODESC_ENT(ADC), | ||
| 64 | IODESC_ENT(WATCHDOG), | ||
| 65 | }; | ||
| 66 | |||
| 67 | /* uart registration process */ | ||
| 68 | |||
| 69 | void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no) | ||
| 70 | { | ||
| 71 | s3c24xx_init_uartdevs("s3c2412-uart", s3c2410_uart_resources, cfg, no); | ||
| 72 | |||
| 73 | /* rename devices that are s3c2412/s3c2413 specific */ | ||
| 74 | s3c_device_sdi.name = "s3c2412-sdi"; | ||
| 75 | s3c_device_nand.name = "s3c2412-nand"; | ||
| 76 | } | ||
| 77 | |||
| 78 | /* s3c2412_map_io | ||
| 79 | * | ||
| 80 | * register the standard cpu IO areas, and any passed in from the | ||
| 81 | * machine specific initialisation. | ||
| 82 | */ | ||
| 83 | |||
| 84 | void __init s3c2412_map_io(struct map_desc *mach_desc, int mach_size) | ||
| 85 | { | ||
| 86 | /* move base of IO */ | ||
| 87 | |||
| 88 | s3c24xx_va_gpio2 = S3C24XX_VA_GPIO + 0x10; | ||
| 89 | |||
| 90 | /* register our io-tables */ | ||
| 91 | |||
| 92 | iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc)); | ||
| 93 | iotable_init(mach_desc, mach_size); | ||
| 94 | } | ||
| 95 | |||
| 96 | void __init s3c2412_init_clocks(int xtal) | ||
| 97 | { | ||
| 98 | unsigned long tmp; | ||
| 99 | unsigned long fclk; | ||
| 100 | unsigned long hclk; | ||
| 101 | unsigned long pclk; | ||
| 102 | |||
| 103 | /* now we've got our machine bits initialised, work out what | ||
| 104 | * clocks we've got */ | ||
| 105 | |||
| 106 | fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), xtal*2); | ||
| 107 | |||
| 108 | tmp = __raw_readl(S3C2410_CLKDIVN); | ||
| 109 | |||
| 110 | /* work out clock scalings */ | ||
| 111 | |||
| 112 | hclk = fclk / ((tmp & S3C2412_CLKDIVN_HDIVN_MASK) + 1); | ||
| 113 | hclk /= ((tmp & S3C2421_CLKDIVN_ARMDIVN) ? 2 : 1); | ||
| 114 | pclk = hclk / ((tmp & S3C2412_CLKDIVN_PDIVN) ? 2 : 1); | ||
| 115 | |||
| 116 | /* print brieft summary of clocks, etc */ | ||
| 117 | |||
| 118 | printk("S3C2412: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n", | ||
| 119 | print_mhz(fclk), print_mhz(hclk), print_mhz(pclk)); | ||
| 120 | |||
| 121 | /* initialise the clocks here, to allow other things like the | ||
| 122 | * console to use them | ||
| 123 | */ | ||
| 124 | |||
| 125 | s3c24xx_setup_clocks(xtal, fclk, hclk, pclk); | ||
| 126 | s3c2412_baseclk_add(); | ||
| 127 | } | ||
| 128 | |||
| 129 | /* need to register class before we actually register the device, and | ||
| 130 | * we also need to ensure that it has been initialised before any of the | ||
| 131 | * drivers even try to use it (even if not on an s3c2412 based system) | ||
| 132 | * as a driver which may support both 2410 and 2440 may try and use it. | ||
| 133 | */ | ||
| 134 | |||
| 135 | #ifdef CONFIG_PM | ||
| 136 | static struct sleep_save s3c2412_sleep[] = { | ||
| 137 | SAVE_ITEM(S3C2412_DSC0), | ||
| 138 | SAVE_ITEM(S3C2412_DSC1), | ||
| 139 | SAVE_ITEM(S3C2413_GPJDAT), | ||
| 140 | SAVE_ITEM(S3C2413_GPJCON), | ||
| 141 | SAVE_ITEM(S3C2413_GPJUP), | ||
| 142 | |||
| 143 | /* save the sleep configuration anyway, just in case these | ||
| 144 | * get damaged during wakeup */ | ||
| 145 | |||
| 146 | SAVE_ITEM(S3C2412_GPBSLPCON), | ||
| 147 | SAVE_ITEM(S3C2412_GPCSLPCON), | ||
| 148 | SAVE_ITEM(S3C2412_GPDSLPCON), | ||
| 149 | SAVE_ITEM(S3C2412_GPESLPCON), | ||
| 150 | SAVE_ITEM(S3C2412_GPFSLPCON), | ||
| 151 | SAVE_ITEM(S3C2412_GPGSLPCON), | ||
| 152 | SAVE_ITEM(S3C2412_GPHSLPCON), | ||
| 153 | SAVE_ITEM(S3C2413_GPJSLPCON), | ||
| 154 | }; | ||
| 155 | |||
| 156 | static int s3c2412_suspend(struct sys_device *dev, pm_message_t state) | ||
| 157 | { | ||
| 158 | s3c2410_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); | ||
| 159 | return 0; | ||
| 160 | } | ||
| 161 | |||
| 162 | static int s3c2412_resume(struct sys_device *dev) | ||
| 163 | { | ||
| 164 | s3c2410_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); | ||
| 165 | return 0; | ||
| 166 | } | ||
| 167 | |||
| 168 | #else | ||
| 169 | #define s3c2412_suspend NULL | ||
| 170 | #define s3c2412_resume NULL | ||
| 171 | #endif | ||
| 172 | |||
| 173 | struct sysdev_class s3c2412_sysclass = { | ||
| 174 | set_kset_name("s3c2412-core"), | ||
| 175 | .suspend = s3c2412_suspend, | ||
| 176 | .resume = s3c2412_resume | ||
| 177 | }; | ||
| 178 | |||
| 179 | static int __init s3c2412_core_init(void) | ||
| 180 | { | ||
| 181 | return sysdev_class_register(&s3c2412_sysclass); | ||
| 182 | } | ||
| 183 | |||
| 184 | core_initcall(s3c2412_core_init); | ||
| 185 | |||
| 186 | static struct sys_device s3c2412_sysdev = { | ||
| 187 | .cls = &s3c2412_sysclass, | ||
| 188 | }; | ||
| 189 | |||
| 190 | int __init s3c2412_init(void) | ||
| 191 | { | ||
| 192 | printk("S3C2412: Initialising architecture\n"); | ||
| 193 | |||
| 194 | return sysdev_register(&s3c2412_sysdev); | ||
| 195 | } | ||
diff --git a/arch/arm/mach-s3c2410/s3c2412.h b/arch/arm/mach-s3c2410/s3c2412.h new file mode 100644 index 000000000000..c6e56032a6e7 --- /dev/null +++ b/arch/arm/mach-s3c2410/s3c2412.h | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | /* arch/arm/mach-s3c2410/s3c2412.h | ||
| 2 | * | ||
| 3 | * Copyright (c) 2006 Simtec Electronics | ||
| 4 | * Ben Dooks <ben@simtec.co.uk> | ||
| 5 | * | ||
| 6 | * Header file for s3c2412 cpu support | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License version 2 as | ||
| 10 | * published by the Free Software Foundation. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #ifdef CONFIG_CPU_S3C2412 | ||
| 14 | |||
| 15 | extern int s3c2412_init(void); | ||
| 16 | |||
| 17 | extern void s3c2412_map_io(struct map_desc *mach_desc, int size); | ||
| 18 | |||
| 19 | extern void s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no); | ||
| 20 | |||
| 21 | extern void s3c2412_init_clocks(int xtal); | ||
| 22 | |||
| 23 | extern int s3c2412_baseclk_add(void); | ||
| 24 | #else | ||
| 25 | #define s3c2412_init_clocks NULL | ||
| 26 | #define s3c2412_init_uarts NULL | ||
| 27 | #define s3c2412_map_io NULL | ||
| 28 | #define s3c2412_init NULL | ||
| 29 | #endif | ||
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig index 4221d054a1e9..ecf5e232a6fc 100644 --- a/arch/arm/mm/Kconfig +++ b/arch/arm/mm/Kconfig | |||
| @@ -61,9 +61,9 @@ config CPU_ARM720T | |||
| 61 | 61 | ||
| 62 | # ARM920T | 62 | # ARM920T |
| 63 | config CPU_ARM920T | 63 | config CPU_ARM920T |
| 64 | bool "Support ARM920T processor" if !ARCH_S3C2410 | 64 | bool "Support ARM920T processor" |
| 65 | depends on ARCH_EP93XX || ARCH_INTEGRATOR || ARCH_S3C2410 || ARCH_IMX || ARCH_AAEC2000 || ARCH_AT91RM9200 | 65 | depends on ARCH_EP93XX || ARCH_INTEGRATOR || CPU_S3C2410 || CPU_S3C2440 || CPU_S3C2442 || ARCH_IMX || ARCH_AAEC2000 || ARCH_AT91RM9200 |
| 66 | default y if ARCH_S3C2410 || ARCH_AT91RM9200 | 66 | default y if CPU_S3C2410 || CPU_S3C2440 || CPU_S3C2442 || ARCH_AT91RM9200 |
| 67 | select CPU_32v4 | 67 | select CPU_32v4 |
| 68 | select CPU_ABRT_EV4T | 68 | select CPU_ABRT_EV4T |
| 69 | select CPU_CACHE_V4WT | 69 | select CPU_CACHE_V4WT |
| @@ -121,8 +121,8 @@ config CPU_ARM925T | |||
| 121 | # ARM926T | 121 | # ARM926T |
| 122 | config CPU_ARM926T | 122 | config CPU_ARM926T |
| 123 | bool "Support ARM926T processor" | 123 | bool "Support ARM926T processor" |
| 124 | depends on ARCH_INTEGRATOR || ARCH_VERSATILE_PB || MACH_VERSATILE_AB || ARCH_OMAP730 || ARCH_OMAP16XX || MACH_REALVIEW_EB || ARCH_PNX4008 || ARCH_NETX | 124 | depends on ARCH_INTEGRATOR || ARCH_VERSATILE_PB || MACH_VERSATILE_AB || ARCH_OMAP730 || ARCH_OMAP16XX || MACH_REALVIEW_EB || ARCH_PNX4008 || ARCH_NETX || CPU_S3C2412 |
| 125 | default y if ARCH_VERSATILE_PB || MACH_VERSATILE_AB || ARCH_OMAP730 || ARCH_OMAP16XX || ARCH_PNX4008 || ARCH_NETX | 125 | default y if ARCH_VERSATILE_PB || MACH_VERSATILE_AB || ARCH_OMAP730 || ARCH_OMAP16XX || ARCH_PNX4008 || ARCH_NETX || CPU_S3C2412 |
| 126 | select CPU_32v5 | 126 | select CPU_32v5 |
| 127 | select CPU_ABRT_EV5TJ | 127 | select CPU_ABRT_EV5TJ |
| 128 | select CPU_CACHE_VIVT | 128 | select CPU_CACHE_VIVT |
diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S index 8831303a473f..7512f39c9f25 100644 --- a/arch/i386/kernel/vmlinux.lds.S +++ b/arch/i386/kernel/vmlinux.lds.S | |||
| @@ -37,6 +37,13 @@ SECTIONS | |||
| 37 | 37 | ||
| 38 | RODATA | 38 | RODATA |
| 39 | 39 | ||
| 40 | . = ALIGN(4); | ||
| 41 | __tracedata_start = .; | ||
| 42 | .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { | ||
| 43 | *(.tracedata) | ||
| 44 | } | ||
| 45 | __tracedata_end = .; | ||
| 46 | |||
| 40 | /* writeable */ | 47 | /* writeable */ |
| 41 | .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */ | 48 | .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */ |
| 42 | *(.data) | 49 | *(.data) |
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile index 1b83e21841b5..6616ee05c313 100644 --- a/arch/sparc/kernel/Makefile +++ b/arch/sparc/kernel/Makefile | |||
| @@ -12,7 +12,7 @@ obj-y := entry.o wof.o wuf.o etrap.o rtrap.o traps.o $(IRQ_OBJS) \ | |||
| 12 | sys_sparc.o sunos_asm.o systbls.o \ | 12 | sys_sparc.o sunos_asm.o systbls.o \ |
| 13 | time.o windows.o cpu.o devices.o sclow.o \ | 13 | time.o windows.o cpu.o devices.o sclow.o \ |
| 14 | tadpole.o tick14.o ptrace.o sys_solaris.o \ | 14 | tadpole.o tick14.o ptrace.o sys_solaris.o \ |
| 15 | unaligned.o muldiv.o semaphore.o | 15 | unaligned.o muldiv.o semaphore.o prom.o of_device.o |
| 16 | 16 | ||
| 17 | obj-$(CONFIG_PCI) += pcic.o | 17 | obj-$(CONFIG_PCI) += pcic.o |
| 18 | obj-$(CONFIG_SUN4) += sun4setup.o | 18 | obj-$(CONFIG_SUN4) += sun4setup.o |
diff --git a/arch/sparc/kernel/ebus.c b/arch/sparc/kernel/ebus.c index 5c3529ceb5d6..a7a4892956c8 100644 --- a/arch/sparc/kernel/ebus.c +++ b/arch/sparc/kernel/ebus.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <asm/ebus.h> | 20 | #include <asm/ebus.h> |
| 21 | #include <asm/io.h> | 21 | #include <asm/io.h> |
| 22 | #include <asm/oplib.h> | 22 | #include <asm/oplib.h> |
| 23 | #include <asm/prom.h> | ||
| 23 | #include <asm/bpp.h> | 24 | #include <asm/bpp.h> |
| 24 | 25 | ||
| 25 | struct linux_ebus *ebus_chain = NULL; | 26 | struct linux_ebus *ebus_chain = NULL; |
| @@ -83,79 +84,81 @@ int __init ebus_blacklist_irq(char *name) | |||
| 83 | return 0; | 84 | return 0; |
| 84 | } | 85 | } |
| 85 | 86 | ||
| 86 | void __init fill_ebus_child(int node, struct linux_prom_registers *preg, | 87 | void __init fill_ebus_child(struct device_node *dp, |
| 87 | struct linux_ebus_child *dev) | 88 | struct linux_ebus_child *dev) |
| 88 | { | 89 | { |
| 89 | int regs[PROMREG_MAX]; | 90 | int *regs; |
| 90 | int irqs[PROMREG_MAX]; | 91 | int *irqs; |
| 91 | char lbuf[128]; | ||
| 92 | int i, len; | 92 | int i, len; |
| 93 | 93 | ||
| 94 | dev->prom_node = node; | 94 | dev->prom_node = dp; |
| 95 | prom_getstring(node, "name", lbuf, sizeof(lbuf)); | 95 | regs = of_get_property(dp, "reg", &len); |
| 96 | strcpy(dev->prom_name, lbuf); | 96 | if (!regs) |
| 97 | 97 | len = 0; | |
| 98 | len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs)); | ||
| 99 | if (len == -1) len = 0; | ||
| 100 | dev->num_addrs = len / sizeof(regs[0]); | 98 | dev->num_addrs = len / sizeof(regs[0]); |
| 101 | 99 | ||
| 102 | for (i = 0; i < dev->num_addrs; i++) { | 100 | for (i = 0; i < dev->num_addrs; i++) { |
| 103 | if (regs[i] >= dev->parent->num_addrs) { | 101 | if (regs[i] >= dev->parent->num_addrs) { |
| 104 | prom_printf("UGH: property for %s was %d, need < %d\n", | 102 | prom_printf("UGH: property for %s was %d, need < %d\n", |
| 105 | dev->prom_name, len, dev->parent->num_addrs); | 103 | dev->prom_node->name, len, |
| 104 | dev->parent->num_addrs); | ||
| 106 | panic(__FUNCTION__); | 105 | panic(__FUNCTION__); |
| 107 | } | 106 | } |
| 108 | dev->resource[i].start = dev->parent->resource[regs[i]].start; /* XXX resource */ | 107 | |
| 108 | /* XXX resource */ | ||
| 109 | dev->resource[i].start = | ||
| 110 | dev->parent->resource[regs[i]].start; | ||
| 109 | } | 111 | } |
| 110 | 112 | ||
| 111 | for (i = 0; i < PROMINTR_MAX; i++) | 113 | for (i = 0; i < PROMINTR_MAX; i++) |
| 112 | dev->irqs[i] = PCI_IRQ_NONE; | 114 | dev->irqs[i] = PCI_IRQ_NONE; |
| 113 | 115 | ||
| 114 | if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_name)) != 0) { | 116 | if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) { |
| 115 | dev->num_irqs = 1; | 117 | dev->num_irqs = 1; |
| 116 | } else if ((len = prom_getproperty(node, "interrupts", | ||
| 117 | (char *)&irqs, sizeof(irqs))) == -1 || len == 0) { | ||
| 118 | dev->num_irqs = 0; | ||
| 119 | dev->irqs[0] = 0; | ||
| 120 | if (dev->parent->num_irqs != 0) { | ||
| 121 | dev->num_irqs = 1; | ||
| 122 | dev->irqs[0] = dev->parent->irqs[0]; | ||
| 123 | /* P3 */ /* printk("EBUS: dev %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */ | ||
| 124 | } | ||
| 125 | } else { | 118 | } else { |
| 126 | dev->num_irqs = len / sizeof(irqs[0]); | 119 | irqs = of_get_property(dp, "interrupts", &len); |
| 127 | if (irqs[0] == 0 || irqs[0] >= 8) { | 120 | if (!irqs) { |
| 128 | /* | ||
| 129 | * XXX Zero is a valid pin number... | ||
| 130 | * This works as long as Ebus is not wired to INTA#. | ||
| 131 | */ | ||
| 132 | printk("EBUS: %s got bad irq %d from PROM\n", | ||
| 133 | dev->prom_name, irqs[0]); | ||
| 134 | dev->num_irqs = 0; | 121 | dev->num_irqs = 0; |
| 135 | dev->irqs[0] = 0; | 122 | dev->irqs[0] = 0; |
| 123 | if (dev->parent->num_irqs != 0) { | ||
| 124 | dev->num_irqs = 1; | ||
| 125 | dev->irqs[0] = dev->parent->irqs[0]; | ||
| 126 | } | ||
| 136 | } else { | 127 | } else { |
| 137 | dev->irqs[0] = pcic_pin_to_irq(irqs[0], dev->prom_name); | 128 | dev->num_irqs = len / sizeof(irqs[0]); |
| 129 | if (irqs[0] == 0 || irqs[0] >= 8) { | ||
| 130 | /* | ||
| 131 | * XXX Zero is a valid pin number... | ||
| 132 | * This works as long as Ebus is not wired | ||
| 133 | * to INTA#. | ||
| 134 | */ | ||
| 135 | printk("EBUS: %s got bad irq %d from PROM\n", | ||
| 136 | dev->prom_node->name, irqs[0]); | ||
| 137 | dev->num_irqs = 0; | ||
| 138 | dev->irqs[0] = 0; | ||
| 139 | } else { | ||
| 140 | dev->irqs[0] = | ||
| 141 | pcic_pin_to_irq(irqs[0], | ||
| 142 | dev->prom_node->name); | ||
| 143 | } | ||
| 138 | } | 144 | } |
| 139 | } | 145 | } |
| 140 | } | 146 | } |
| 141 | 147 | ||
| 142 | void __init fill_ebus_device(int node, struct linux_ebus_device *dev) | 148 | void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *dev) |
| 143 | { | 149 | { |
| 144 | struct linux_prom_registers regs[PROMREG_MAX]; | 150 | struct linux_prom_registers *regs; |
| 145 | struct linux_ebus_child *child; | 151 | struct linux_ebus_child *child; |
| 146 | int irqs[PROMINTR_MAX]; | 152 | int *irqs; |
| 147 | char lbuf[128]; | ||
| 148 | int i, n, len; | 153 | int i, n, len; |
| 149 | unsigned long baseaddr; | 154 | unsigned long baseaddr; |
| 150 | 155 | ||
| 151 | dev->prom_node = node; | 156 | dev->prom_node = dp; |
| 152 | prom_getstring(node, "name", lbuf, sizeof(lbuf)); | ||
| 153 | strcpy(dev->prom_name, lbuf); | ||
| 154 | 157 | ||
| 155 | len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs)); | 158 | regs = of_get_property(dp, "reg", &len); |
| 156 | if (len % sizeof(struct linux_prom_registers)) { | 159 | if (len % sizeof(struct linux_prom_registers)) { |
| 157 | prom_printf("UGH: proplen for %s was %d, need multiple of %d\n", | 160 | prom_printf("UGH: proplen for %s was %d, need multiple of %d\n", |
| 158 | dev->prom_name, len, | 161 | dev->prom_node->name, len, |
| 159 | (int)sizeof(struct linux_prom_registers)); | 162 | (int)sizeof(struct linux_prom_registers)); |
| 160 | panic(__FUNCTION__); | 163 | panic(__FUNCTION__); |
| 161 | } | 164 | } |
| @@ -197,7 +200,7 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev) | |||
| 197 | if ((baseaddr = (unsigned long) ioremap(baseaddr, | 200 | if ((baseaddr = (unsigned long) ioremap(baseaddr, |
| 198 | regs[i].reg_size)) == 0) { | 201 | regs[i].reg_size)) == 0) { |
| 199 | panic("ebus: unable to remap dev %s", | 202 | panic("ebus: unable to remap dev %s", |
| 200 | dev->prom_name); | 203 | dev->prom_node->name); |
| 201 | } | 204 | } |
| 202 | } | 205 | } |
| 203 | dev->resource[i].start = baseaddr; /* XXX Unaligned */ | 206 | dev->resource[i].start = baseaddr; /* XXX Unaligned */ |
| @@ -206,29 +209,43 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev) | |||
| 206 | for (i = 0; i < PROMINTR_MAX; i++) | 209 | for (i = 0; i < PROMINTR_MAX; i++) |
| 207 | dev->irqs[i] = PCI_IRQ_NONE; | 210 | dev->irqs[i] = PCI_IRQ_NONE; |
| 208 | 211 | ||
| 209 | if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_name)) != 0) { | 212 | if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) { |
| 210 | dev->num_irqs = 1; | 213 | dev->num_irqs = 1; |
| 211 | } else if ((len = prom_getproperty(node, "interrupts", | ||
| 212 | (char *)&irqs, sizeof(irqs))) == -1 || len == 0) { | ||
| 213 | dev->num_irqs = 0; | ||
| 214 | if ((dev->irqs[0] = dev->bus->self->irq) != 0) { | ||
| 215 | dev->num_irqs = 1; | ||
| 216 | /* P3 */ /* printk("EBUS: child %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */ | ||
| 217 | } | ||
| 218 | } else { | 214 | } else { |
| 219 | dev->num_irqs = 1; /* dev->num_irqs = len / sizeof(irqs[0]); */ | 215 | irqs = of_get_property(dp, "interrupts", &len); |
| 220 | if (irqs[0] == 0 || irqs[0] >= 8) { | 216 | if (!irqs) { |
| 221 | /* See above for the parent. XXX */ | ||
| 222 | printk("EBUS: %s got bad irq %d from PROM\n", | ||
| 223 | dev->prom_name, irqs[0]); | ||
| 224 | dev->num_irqs = 0; | 217 | dev->num_irqs = 0; |
| 225 | dev->irqs[0] = 0; | 218 | if ((dev->irqs[0] = dev->bus->self->irq) != 0) { |
| 219 | dev->num_irqs = 1; | ||
| 220 | /* P3 */ /* printk("EBUS: child %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */ | ||
| 221 | } | ||
| 226 | } else { | 222 | } else { |
| 227 | dev->irqs[0] = pcic_pin_to_irq(irqs[0], dev->prom_name); | 223 | dev->num_irqs = 1; /* dev->num_irqs = len / sizeof(irqs[0]); */ |
| 224 | if (irqs[0] == 0 || irqs[0] >= 8) { | ||
| 225 | /* See above for the parent. XXX */ | ||
| 226 | printk("EBUS: %s got bad irq %d from PROM\n", | ||
| 227 | dev->prom_node->name, irqs[0]); | ||
| 228 | dev->num_irqs = 0; | ||
| 229 | dev->irqs[0] = 0; | ||
| 230 | } else { | ||
| 231 | dev->irqs[0] = | ||
| 232 | pcic_pin_to_irq(irqs[0], | ||
| 233 | dev->prom_node->name); | ||
| 234 | } | ||
| 228 | } | 235 | } |
| 229 | } | 236 | } |
| 230 | 237 | ||
| 231 | if ((node = prom_getchild(node))) { | 238 | dev->ofdev.node = dp; |
| 239 | dev->ofdev.dev.parent = &dev->bus->ofdev.dev; | ||
| 240 | dev->ofdev.dev.bus = &ebus_bus_type; | ||
| 241 | strcpy(dev->ofdev.dev.bus_id, dp->path_component_name); | ||
| 242 | |||
| 243 | /* Register with core */ | ||
| 244 | if (of_device_register(&dev->ofdev) != 0) | ||
| 245 | printk(KERN_DEBUG "ebus: device registration error for %s!\n", | ||
| 246 | dev->ofdev.dev.bus_id); | ||
| 247 | |||
| 248 | if ((dp = dp->child) != NULL) { | ||
| 232 | dev->children = (struct linux_ebus_child *) | 249 | dev->children = (struct linux_ebus_child *) |
| 233 | ebus_alloc(sizeof(struct linux_ebus_child)); | 250 | ebus_alloc(sizeof(struct linux_ebus_child)); |
| 234 | 251 | ||
| @@ -236,9 +253,9 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev) | |||
| 236 | child->next = NULL; | 253 | child->next = NULL; |
| 237 | child->parent = dev; | 254 | child->parent = dev; |
| 238 | child->bus = dev->bus; | 255 | child->bus = dev->bus; |
| 239 | fill_ebus_child(node, ®s[0], child); | 256 | fill_ebus_child(dp, child); |
| 240 | 257 | ||
| 241 | while ((node = prom_getsibling(node)) != 0) { | 258 | while ((dp = dp->sibling) != NULL) { |
| 242 | child->next = (struct linux_ebus_child *) | 259 | child->next = (struct linux_ebus_child *) |
| 243 | ebus_alloc(sizeof(struct linux_ebus_child)); | 260 | ebus_alloc(sizeof(struct linux_ebus_child)); |
| 244 | 261 | ||
| @@ -246,51 +263,49 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev) | |||
| 246 | child->next = NULL; | 263 | child->next = NULL; |
| 247 | child->parent = dev; | 264 | child->parent = dev; |
| 248 | child->bus = dev->bus; | 265 | child->bus = dev->bus; |
| 249 | fill_ebus_child(node, ®s[0], child); | 266 | fill_ebus_child(dp, child); |
| 250 | } | 267 | } |
| 251 | } | 268 | } |
| 252 | } | 269 | } |
| 253 | 270 | ||
| 254 | void __init ebus_init(void) | 271 | void __init ebus_init(void) |
| 255 | { | 272 | { |
| 256 | struct linux_prom_pci_registers regs[PROMREG_MAX]; | 273 | struct linux_prom_pci_registers *regs; |
| 257 | struct linux_pbm_info *pbm; | 274 | struct linux_pbm_info *pbm; |
| 258 | struct linux_ebus_device *dev; | 275 | struct linux_ebus_device *dev; |
| 259 | struct linux_ebus *ebus; | 276 | struct linux_ebus *ebus; |
| 260 | struct ebus_system_entry *sp; | 277 | struct ebus_system_entry *sp; |
| 261 | struct pci_dev *pdev; | 278 | struct pci_dev *pdev; |
| 262 | struct pcidev_cookie *cookie; | 279 | struct pcidev_cookie *cookie; |
| 263 | char lbuf[128]; | 280 | struct device_node *dp; |
| 264 | unsigned long addr, *base; | 281 | unsigned long addr, *base; |
| 265 | unsigned short pci_command; | 282 | unsigned short pci_command; |
| 266 | int nd, len, ebusnd; | 283 | int len, reg, nreg; |
| 267 | int reg, nreg; | ||
| 268 | int num_ebus = 0; | 284 | int num_ebus = 0; |
| 269 | 285 | ||
| 270 | prom_getstring(prom_root_node, "name", lbuf, sizeof(lbuf)); | 286 | dp = of_find_node_by_path("/"); |
| 271 | for (sp = ebus_blacklist; sp->esname != NULL; sp++) { | 287 | for (sp = ebus_blacklist; sp->esname != NULL; sp++) { |
| 272 | if (strcmp(lbuf, sp->esname) == 0) { | 288 | if (strcmp(dp->name, sp->esname) == 0) { |
| 273 | ebus_blackp = sp->ipt; | 289 | ebus_blackp = sp->ipt; |
| 274 | break; | 290 | break; |
| 275 | } | 291 | } |
| 276 | } | 292 | } |
| 277 | 293 | ||
| 278 | pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, NULL); | 294 | pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, NULL); |
| 279 | if (!pdev) { | 295 | if (!pdev) |
| 280 | return; | 296 | return; |
| 281 | } | 297 | |
| 282 | cookie = pdev->sysdata; | 298 | cookie = pdev->sysdata; |
| 283 | ebusnd = cookie->prom_node; | 299 | dp = cookie->prom_node; |
| 284 | 300 | ||
| 285 | ebus_chain = ebus = (struct linux_ebus *) | 301 | ebus_chain = ebus = (struct linux_ebus *) |
| 286 | ebus_alloc(sizeof(struct linux_ebus)); | 302 | ebus_alloc(sizeof(struct linux_ebus)); |
| 287 | ebus->next = NULL; | 303 | ebus->next = NULL; |
| 288 | 304 | ||
| 289 | while (ebusnd) { | 305 | while (dp) { |
| 306 | struct device_node *nd; | ||
| 290 | 307 | ||
| 291 | prom_getstring(ebusnd, "name", lbuf, sizeof(lbuf)); | 308 | ebus->prom_node = dp; |
| 292 | ebus->prom_node = ebusnd; | ||
| 293 | strcpy(ebus->prom_name, lbuf); | ||
| 294 | ebus->self = pdev; | 309 | ebus->self = pdev; |
| 295 | ebus->parent = pbm = cookie->pbm; | 310 | ebus->parent = pbm = cookie->pbm; |
| 296 | 311 | ||
| @@ -299,9 +314,8 @@ void __init ebus_init(void) | |||
| 299 | pci_command |= PCI_COMMAND_MASTER; | 314 | pci_command |= PCI_COMMAND_MASTER; |
| 300 | pci_write_config_word(pdev, PCI_COMMAND, pci_command); | 315 | pci_write_config_word(pdev, PCI_COMMAND, pci_command); |
| 301 | 316 | ||
| 302 | len = prom_getproperty(ebusnd, "reg", (void *)regs, | 317 | regs = of_get_property(dp, "reg", &len); |
| 303 | sizeof(regs)); | 318 | if (!regs) { |
| 304 | if (len == 0 || len == -1) { | ||
| 305 | prom_printf("%s: can't find reg property\n", | 319 | prom_printf("%s: can't find reg property\n", |
| 306 | __FUNCTION__); | 320 | __FUNCTION__); |
| 307 | prom_halt(); | 321 | prom_halt(); |
| @@ -317,7 +331,18 @@ void __init ebus_init(void) | |||
| 317 | *base++ = addr; | 331 | *base++ = addr; |
| 318 | } | 332 | } |
| 319 | 333 | ||
| 320 | nd = prom_getchild(ebusnd); | 334 | ebus->ofdev.node = dp; |
| 335 | ebus->ofdev.dev.parent = &pdev->dev; | ||
| 336 | ebus->ofdev.dev.bus = &ebus_bus_type; | ||
| 337 | strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name); | ||
| 338 | |||
| 339 | /* Register with core */ | ||
| 340 | if (of_device_register(&ebus->ofdev) != 0) | ||
| 341 | printk(KERN_DEBUG "ebus: device registration error for %s!\n", | ||
| 342 | ebus->ofdev.dev.bus_id); | ||
| 343 | |||
| 344 | |||
| 345 | nd = dp->child; | ||
| 321 | if (!nd) | 346 | if (!nd) |
| 322 | goto next_ebus; | 347 | goto next_ebus; |
| 323 | 348 | ||
| @@ -330,7 +355,7 @@ void __init ebus_init(void) | |||
| 330 | dev->bus = ebus; | 355 | dev->bus = ebus; |
| 331 | fill_ebus_device(nd, dev); | 356 | fill_ebus_device(nd, dev); |
| 332 | 357 | ||
| 333 | while ((nd = prom_getsibling(nd)) != 0) { | 358 | while ((nd = nd->sibling) != NULL) { |
| 334 | dev->next = (struct linux_ebus_device *) | 359 | dev->next = (struct linux_ebus_device *) |
| 335 | ebus_alloc(sizeof(struct linux_ebus_device)); | 360 | ebus_alloc(sizeof(struct linux_ebus_device)); |
| 336 | 361 | ||
| @@ -348,7 +373,7 @@ void __init ebus_init(void) | |||
| 348 | break; | 373 | break; |
| 349 | 374 | ||
| 350 | cookie = pdev->sysdata; | 375 | cookie = pdev->sysdata; |
| 351 | ebusnd = cookie->prom_node; | 376 | dp = cookie->prom_node; |
| 352 | 377 | ||
| 353 | ebus->next = (struct linux_ebus *) | 378 | ebus->next = (struct linux_ebus *) |
| 354 | ebus_alloc(sizeof(struct linux_ebus)); | 379 | ebus_alloc(sizeof(struct linux_ebus)); |
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c index f9ff29734848..ae4c667c906f 100644 --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c | |||
| @@ -39,6 +39,8 @@ | |||
| 39 | #include <asm/io.h> | 39 | #include <asm/io.h> |
| 40 | #include <asm/vaddrs.h> | 40 | #include <asm/vaddrs.h> |
| 41 | #include <asm/oplib.h> | 41 | #include <asm/oplib.h> |
| 42 | #include <asm/prom.h> | ||
| 43 | #include <asm/sbus.h> | ||
| 42 | #include <asm/page.h> | 44 | #include <asm/page.h> |
| 43 | #include <asm/pgalloc.h> | 45 | #include <asm/pgalloc.h> |
| 44 | #include <asm/dma.h> | 46 | #include <asm/dma.h> |
| @@ -224,10 +226,54 @@ static void _sparc_free_io(struct resource *res) | |||
| 224 | 226 | ||
| 225 | #ifdef CONFIG_SBUS | 227 | #ifdef CONFIG_SBUS |
| 226 | 228 | ||
| 227 | void sbus_set_sbus64(struct sbus_dev *sdev, int x) { | 229 | void sbus_set_sbus64(struct sbus_dev *sdev, int x) |
| 230 | { | ||
| 228 | printk("sbus_set_sbus64: unsupported\n"); | 231 | printk("sbus_set_sbus64: unsupported\n"); |
| 229 | } | 232 | } |
| 230 | 233 | ||
| 234 | extern unsigned int sun4d_build_irq(struct sbus_dev *sdev, int irq); | ||
| 235 | void __init sbus_fill_device_irq(struct sbus_dev *sdev) | ||
| 236 | { | ||
| 237 | struct linux_prom_irqs irqs[PROMINTR_MAX]; | ||
| 238 | int len; | ||
| 239 | |||
| 240 | len = prom_getproperty(sdev->prom_node, "intr", | ||
| 241 | (char *)irqs, sizeof(irqs)); | ||
| 242 | if (len != -1) { | ||
| 243 | sdev->num_irqs = len / 8; | ||
| 244 | if (sdev->num_irqs == 0) { | ||
| 245 | sdev->irqs[0] = 0; | ||
| 246 | } else if (sparc_cpu_model == sun4d) { | ||
| 247 | for (len = 0; len < sdev->num_irqs; len++) | ||
| 248 | sdev->irqs[len] = | ||
| 249 | sun4d_build_irq(sdev, irqs[len].pri); | ||
| 250 | } else { | ||
| 251 | for (len = 0; len < sdev->num_irqs; len++) | ||
| 252 | sdev->irqs[len] = irqs[len].pri; | ||
| 253 | } | ||
| 254 | } else { | ||
| 255 | int interrupts[PROMINTR_MAX]; | ||
| 256 | |||
| 257 | /* No "intr" node found-- check for "interrupts" node. | ||
| 258 | * This node contains SBus interrupt levels, not IPLs | ||
| 259 | * as in "intr", and no vector values. We convert | ||
| 260 | * SBus interrupt levels to PILs (platform specific). | ||
| 261 | */ | ||
| 262 | len = prom_getproperty(sdev->prom_node, "interrupts", | ||
| 263 | (char *)interrupts, sizeof(interrupts)); | ||
| 264 | if (len == -1) { | ||
| 265 | sdev->irqs[0] = 0; | ||
| 266 | sdev->num_irqs = 0; | ||
| 267 | } else { | ||
| 268 | sdev->num_irqs = len / sizeof(int); | ||
| 269 | for (len = 0; len < sdev->num_irqs; len++) { | ||
| 270 | sdev->irqs[len] = | ||
| 271 | sbint_to_irq(sdev, interrupts[len]); | ||
| 272 | } | ||
| 273 | } | ||
| 274 | } | ||
| 275 | } | ||
| 276 | |||
| 231 | /* | 277 | /* |
| 232 | * Allocate a chunk of memory suitable for DMA. | 278 | * Allocate a chunk of memory suitable for DMA. |
| 233 | * Typically devices use them for control blocks. | 279 | * Typically devices use them for control blocks. |
| @@ -414,6 +460,89 @@ void sbus_dma_sync_sg_for_device(struct sbus_dev *sdev, struct scatterlist *sg, | |||
| 414 | { | 460 | { |
| 415 | printk("sbus_dma_sync_sg_for_device: not implemented yet\n"); | 461 | printk("sbus_dma_sync_sg_for_device: not implemented yet\n"); |
| 416 | } | 462 | } |
| 463 | |||
| 464 | /* Support code for sbus_init(). */ | ||
| 465 | /* | ||
| 466 | * XXX This functions appears to be a distorted version of | ||
| 467 | * prom_sbus_ranges_init(), with all sun4d stuff cut away. | ||
| 468 | * Ask DaveM what is going on here, how is sun4d supposed to work... XXX | ||
| 469 | */ | ||
| 470 | /* added back sun4d patch from Thomas Bogendoerfer - should be OK (crn) */ | ||
| 471 | void __init sbus_arch_bus_ranges_init(struct device_node *pn, struct sbus_bus *sbus) | ||
| 472 | { | ||
| 473 | int parent_node = pn->node; | ||
| 474 | |||
| 475 | if (sparc_cpu_model == sun4d) { | ||
| 476 | struct linux_prom_ranges iounit_ranges[PROMREG_MAX]; | ||
| 477 | int num_iounit_ranges, len; | ||
| 478 | |||
| 479 | len = prom_getproperty(parent_node, "ranges", | ||
| 480 | (char *) iounit_ranges, | ||
| 481 | sizeof (iounit_ranges)); | ||
| 482 | if (len != -1) { | ||
| 483 | num_iounit_ranges = | ||
| 484 | (len / sizeof(struct linux_prom_ranges)); | ||
| 485 | prom_adjust_ranges(sbus->sbus_ranges, | ||
| 486 | sbus->num_sbus_ranges, | ||
| 487 | iounit_ranges, num_iounit_ranges); | ||
| 488 | } | ||
| 489 | } | ||
| 490 | } | ||
| 491 | |||
| 492 | void __init sbus_setup_iommu(struct sbus_bus *sbus, struct device_node *dp) | ||
| 493 | { | ||
| 494 | struct device_node *parent = dp->parent; | ||
| 495 | |||
| 496 | if (sparc_cpu_model != sun4d && | ||
| 497 | parent != NULL && | ||
| 498 | !strcmp(parent->name, "iommu")) { | ||
| 499 | extern void iommu_init(int iommu_node, struct sbus_bus *sbus); | ||
| 500 | |||
| 501 | iommu_init(parent->node, sbus); | ||
| 502 | } | ||
| 503 | |||
| 504 | if (sparc_cpu_model == sun4d) { | ||
| 505 | extern void iounit_init(int sbi_node, int iounit_node, | ||
| 506 | struct sbus_bus *sbus); | ||
| 507 | |||
| 508 | iounit_init(dp->node, parent->node, sbus); | ||
| 509 | } | ||
| 510 | } | ||
| 511 | |||
| 512 | void __init sbus_setup_arch_props(struct sbus_bus *sbus, struct device_node *dp) | ||
| 513 | { | ||
| 514 | if (sparc_cpu_model == sun4d) { | ||
| 515 | struct device_node *parent = dp->parent; | ||
| 516 | |||
| 517 | sbus->devid = of_getintprop_default(parent, "device-id", 0); | ||
| 518 | sbus->board = of_getintprop_default(parent, "board#", 0); | ||
| 519 | } | ||
| 520 | } | ||
| 521 | |||
| 522 | int __init sbus_arch_preinit(void) | ||
| 523 | { | ||
| 524 | extern void register_proc_sparc_ioport(void); | ||
| 525 | |||
| 526 | register_proc_sparc_ioport(); | ||
| 527 | |||
| 528 | #ifdef CONFIG_SUN4 | ||
| 529 | { | ||
| 530 | extern void sun4_dvma_init(void); | ||
| 531 | sun4_dvma_init(); | ||
| 532 | } | ||
| 533 | return 1; | ||
| 534 | #else | ||
| 535 | return 0; | ||
| 536 | #endif | ||
| 537 | } | ||
| 538 | |||
| 539 | void __init sbus_arch_postinit(void) | ||
| 540 | { | ||
| 541 | if (sparc_cpu_model == sun4d) { | ||
| 542 | extern void sun4d_init_sbi_irq(void); | ||
| 543 | sun4d_init_sbi_irq(); | ||
| 544 | } | ||
| 545 | } | ||
| 417 | #endif /* CONFIG_SBUS */ | 546 | #endif /* CONFIG_SBUS */ |
| 418 | 547 | ||
| 419 | #ifdef CONFIG_PCI | 548 | #ifdef CONFIG_PCI |
diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c new file mode 100644 index 000000000000..001b8673b4bd --- /dev/null +++ b/arch/sparc/kernel/of_device.c | |||
| @@ -0,0 +1,268 @@ | |||
| 1 | #include <linux/config.h> | ||
| 2 | #include <linux/string.h> | ||
| 3 | #include <linux/kernel.h> | ||
| 4 | #include <linux/init.h> | ||
| 5 | #include <linux/module.h> | ||
| 6 | #include <linux/mod_devicetable.h> | ||
| 7 | #include <linux/slab.h> | ||
| 8 | |||
| 9 | #include <asm/errno.h> | ||
| 10 | #include <asm/of_device.h> | ||
| 11 | |||
| 12 | /** | ||
| 13 | * of_match_device - Tell if an of_device structure has a matching | ||
| 14 | * of_match structure | ||
| 15 | * @ids: array of of device match structures to search in | ||
| 16 | * @dev: the of device structure to match against | ||
| 17 | * | ||
| 18 | * Used by a driver to check whether an of_device present in the | ||
| 19 | * system is in its list of supported devices. | ||
| 20 | */ | ||
| 21 | const struct of_device_id *of_match_device(const struct of_device_id *matches, | ||
| 22 | const struct of_device *dev) | ||
| 23 | { | ||
| 24 | if (!dev->node) | ||
| 25 | return NULL; | ||
| 26 | while (matches->name[0] || matches->type[0] || matches->compatible[0]) { | ||
| 27 | int match = 1; | ||
| 28 | if (matches->name[0]) | ||
| 29 | match &= dev->node->name | ||
| 30 | && !strcmp(matches->name, dev->node->name); | ||
| 31 | if (matches->type[0]) | ||
| 32 | match &= dev->node->type | ||
| 33 | && !strcmp(matches->type, dev->node->type); | ||
| 34 | if (matches->compatible[0]) | ||
| 35 | match &= of_device_is_compatible(dev->node, | ||
| 36 | matches->compatible); | ||
| 37 | if (match) | ||
| 38 | return matches; | ||
| 39 | matches++; | ||
| 40 | } | ||
| 41 | return NULL; | ||
| 42 | } | ||
| 43 | |||
| 44 | static int of_platform_bus_match(struct device *dev, struct device_driver *drv) | ||
| 45 | { | ||
| 46 | struct of_device * of_dev = to_of_device(dev); | ||
| 47 | struct of_platform_driver * of_drv = to_of_platform_driver(drv); | ||
| 48 | const struct of_device_id * matches = of_drv->match_table; | ||
| 49 | |||
| 50 | if (!matches) | ||
| 51 | return 0; | ||
| 52 | |||
| 53 | return of_match_device(matches, of_dev) != NULL; | ||
| 54 | } | ||
| 55 | |||
| 56 | struct of_device *of_dev_get(struct of_device *dev) | ||
| 57 | { | ||
| 58 | struct device *tmp; | ||
| 59 | |||
| 60 | if (!dev) | ||
| 61 | return NULL; | ||
| 62 | tmp = get_device(&dev->dev); | ||
| 63 | if (tmp) | ||
| 64 | return to_of_device(tmp); | ||
| 65 | else | ||
| 66 | return NULL; | ||
| 67 | } | ||
| 68 | |||
| 69 | void of_dev_put(struct of_device *dev) | ||
| 70 | { | ||
| 71 | if (dev) | ||
| 72 | put_device(&dev->dev); | ||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | static int of_device_probe(struct device *dev) | ||
| 77 | { | ||
| 78 | int error = -ENODEV; | ||
| 79 | struct of_platform_driver *drv; | ||
| 80 | struct of_device *of_dev; | ||
| 81 | const struct of_device_id *match; | ||
| 82 | |||
| 83 | drv = to_of_platform_driver(dev->driver); | ||
| 84 | of_dev = to_of_device(dev); | ||
| 85 | |||
| 86 | if (!drv->probe) | ||
| 87 | return error; | ||
| 88 | |||
| 89 | of_dev_get(of_dev); | ||
| 90 | |||
| 91 | match = of_match_device(drv->match_table, of_dev); | ||
| 92 | if (match) | ||
| 93 | error = drv->probe(of_dev, match); | ||
| 94 | if (error) | ||
| 95 | of_dev_put(of_dev); | ||
| 96 | |||
| 97 | return error; | ||
| 98 | } | ||
| 99 | |||
| 100 | static int of_device_remove(struct device *dev) | ||
| 101 | { | ||
| 102 | struct of_device * of_dev = to_of_device(dev); | ||
| 103 | struct of_platform_driver * drv = to_of_platform_driver(dev->driver); | ||
| 104 | |||
| 105 | if (dev->driver && drv->remove) | ||
| 106 | drv->remove(of_dev); | ||
| 107 | return 0; | ||
| 108 | } | ||
| 109 | |||
| 110 | static int of_device_suspend(struct device *dev, pm_message_t state) | ||
| 111 | { | ||
| 112 | struct of_device * of_dev = to_of_device(dev); | ||
| 113 | struct of_platform_driver * drv = to_of_platform_driver(dev->driver); | ||
| 114 | int error = 0; | ||
| 115 | |||
| 116 | if (dev->driver && drv->suspend) | ||
| 117 | error = drv->suspend(of_dev, state); | ||
| 118 | return error; | ||
| 119 | } | ||
| 120 | |||
| 121 | static int of_device_resume(struct device * dev) | ||
| 122 | { | ||
| 123 | struct of_device * of_dev = to_of_device(dev); | ||
| 124 | struct of_platform_driver * drv = to_of_platform_driver(dev->driver); | ||
| 125 | int error = 0; | ||
| 126 | |||
| 127 | if (dev->driver && drv->resume) | ||
| 128 | error = drv->resume(of_dev); | ||
| 129 | return error; | ||
| 130 | } | ||
| 131 | |||
| 132 | #ifdef CONFIG_PCI | ||
| 133 | struct bus_type ebus_bus_type = { | ||
| 134 | .name = "ebus", | ||
| 135 | .match = of_platform_bus_match, | ||
| 136 | .probe = of_device_probe, | ||
| 137 | .remove = of_device_remove, | ||
| 138 | .suspend = of_device_suspend, | ||
| 139 | .resume = of_device_resume, | ||
| 140 | }; | ||
| 141 | #endif | ||
| 142 | |||
| 143 | #ifdef CONFIG_SBUS | ||
| 144 | struct bus_type sbus_bus_type = { | ||
| 145 | .name = "sbus", | ||
| 146 | .match = of_platform_bus_match, | ||
| 147 | .probe = of_device_probe, | ||
| 148 | .remove = of_device_remove, | ||
| 149 | .suspend = of_device_suspend, | ||
| 150 | .resume = of_device_resume, | ||
| 151 | }; | ||
| 152 | #endif | ||
| 153 | |||
| 154 | static int __init of_bus_driver_init(void) | ||
| 155 | { | ||
| 156 | int err = 0; | ||
| 157 | |||
| 158 | #ifdef CONFIG_PCI | ||
| 159 | if (!err) | ||
| 160 | err = bus_register(&ebus_bus_type); | ||
| 161 | #endif | ||
| 162 | #ifdef CONFIG_SBUS | ||
| 163 | if (!err) | ||
| 164 | err = bus_register(&sbus_bus_type); | ||
| 165 | #endif | ||
| 166 | return 0; | ||
| 167 | } | ||
| 168 | |||
| 169 | postcore_initcall(of_bus_driver_init); | ||
| 170 | |||
| 171 | int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus) | ||
| 172 | { | ||
| 173 | /* initialize common driver fields */ | ||
| 174 | drv->driver.name = drv->name; | ||
| 175 | drv->driver.bus = bus; | ||
| 176 | |||
| 177 | /* register with core */ | ||
| 178 | return driver_register(&drv->driver); | ||
| 179 | } | ||
| 180 | |||
| 181 | void of_unregister_driver(struct of_platform_driver *drv) | ||
| 182 | { | ||
| 183 | driver_unregister(&drv->driver); | ||
| 184 | } | ||
| 185 | |||
| 186 | |||
| 187 | static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf) | ||
| 188 | { | ||
| 189 | struct of_device *ofdev; | ||
| 190 | |||
| 191 | ofdev = to_of_device(dev); | ||
| 192 | return sprintf(buf, "%s", ofdev->node->full_name); | ||
| 193 | } | ||
| 194 | |||
| 195 | static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); | ||
| 196 | |||
| 197 | /** | ||
| 198 | * of_release_dev - free an of device structure when all users of it are finished. | ||
| 199 | * @dev: device that's been disconnected | ||
| 200 | * | ||
| 201 | * Will be called only by the device core when all users of this of device are | ||
| 202 | * done. | ||
| 203 | */ | ||
| 204 | void of_release_dev(struct device *dev) | ||
| 205 | { | ||
| 206 | struct of_device *ofdev; | ||
| 207 | |||
| 208 | ofdev = to_of_device(dev); | ||
| 209 | |||
| 210 | kfree(ofdev); | ||
| 211 | } | ||
| 212 | |||
| 213 | int of_device_register(struct of_device *ofdev) | ||
| 214 | { | ||
| 215 | int rc; | ||
| 216 | |||
| 217 | BUG_ON(ofdev->node == NULL); | ||
| 218 | |||
| 219 | rc = device_register(&ofdev->dev); | ||
| 220 | if (rc) | ||
| 221 | return rc; | ||
| 222 | |||
| 223 | device_create_file(&ofdev->dev, &dev_attr_devspec); | ||
| 224 | |||
| 225 | return 0; | ||
| 226 | } | ||
| 227 | |||
| 228 | void of_device_unregister(struct of_device *ofdev) | ||
| 229 | { | ||
| 230 | device_remove_file(&ofdev->dev, &dev_attr_devspec); | ||
| 231 | device_unregister(&ofdev->dev); | ||
| 232 | } | ||
| 233 | |||
| 234 | struct of_device* of_platform_device_create(struct device_node *np, | ||
| 235 | const char *bus_id, | ||
| 236 | struct device *parent, | ||
| 237 | struct bus_type *bus) | ||
| 238 | { | ||
| 239 | struct of_device *dev; | ||
| 240 | |||
| 241 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); | ||
| 242 | if (!dev) | ||
| 243 | return NULL; | ||
| 244 | memset(dev, 0, sizeof(*dev)); | ||
| 245 | |||
| 246 | dev->dev.parent = parent; | ||
| 247 | dev->dev.bus = bus; | ||
| 248 | dev->dev.release = of_release_dev; | ||
| 249 | |||
| 250 | strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE); | ||
| 251 | |||
| 252 | if (of_device_register(dev) != 0) { | ||
| 253 | kfree(dev); | ||
| 254 | return NULL; | ||
| 255 | } | ||
| 256 | |||
| 257 | return dev; | ||
| 258 | } | ||
| 259 | |||
| 260 | EXPORT_SYMBOL(of_match_device); | ||
| 261 | EXPORT_SYMBOL(of_register_driver); | ||
| 262 | EXPORT_SYMBOL(of_unregister_driver); | ||
| 263 | EXPORT_SYMBOL(of_device_register); | ||
| 264 | EXPORT_SYMBOL(of_device_unregister); | ||
| 265 | EXPORT_SYMBOL(of_dev_get); | ||
| 266 | EXPORT_SYMBOL(of_dev_put); | ||
| 267 | EXPORT_SYMBOL(of_platform_device_create); | ||
| 268 | EXPORT_SYMBOL(of_release_dev); | ||
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index bcdf5ad0f035..bcfdddd0418a 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | 31 | ||
| 32 | #include <asm/irq.h> | 32 | #include <asm/irq.h> |
| 33 | #include <asm/oplib.h> | 33 | #include <asm/oplib.h> |
| 34 | #include <asm/prom.h> | ||
| 34 | #include <asm/pcic.h> | 35 | #include <asm/pcic.h> |
| 35 | #include <asm/timer.h> | 36 | #include <asm/timer.h> |
| 36 | #include <asm/uaccess.h> | 37 | #include <asm/uaccess.h> |
| @@ -665,7 +666,7 @@ void __init pcibios_fixup_bus(struct pci_bus *bus) | |||
| 665 | /* cookies */ | 666 | /* cookies */ |
| 666 | pcp = pci_devcookie_alloc(); | 667 | pcp = pci_devcookie_alloc(); |
| 667 | pcp->pbm = &pcic->pbm; | 668 | pcp->pbm = &pcic->pbm; |
| 668 | pcp->prom_node = node; | 669 | pcp->prom_node = of_find_node_by_phandle(node); |
| 669 | dev->sysdata = pcp; | 670 | dev->sysdata = pcp; |
| 670 | 671 | ||
| 671 | /* fixing I/O to look like memory */ | 672 | /* fixing I/O to look like memory */ |
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c new file mode 100644 index 000000000000..63b2b9bd778e --- /dev/null +++ b/arch/sparc/kernel/prom.c | |||
| @@ -0,0 +1,474 @@ | |||
| 1 | /* | ||
| 2 | * Procedures for creating, accessing and interpreting the device tree. | ||
| 3 | * | ||
| 4 | * Paul Mackerras August 1996. | ||
| 5 | * Copyright (C) 1996-2005 Paul Mackerras. | ||
| 6 | * | ||
| 7 | * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner. | ||
| 8 | * {engebret|bergner}@us.ibm.com | ||
| 9 | * | ||
| 10 | * Adapted for sparc32 by David S. Miller davem@davemloft.net | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or | ||
| 13 | * modify it under the terms of the GNU General Public License | ||
| 14 | * as published by the Free Software Foundation; either version | ||
| 15 | * 2 of the License, or (at your option) any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <linux/kernel.h> | ||
| 19 | #include <linux/types.h> | ||
| 20 | #include <linux/string.h> | ||
| 21 | #include <linux/mm.h> | ||
| 22 | #include <linux/bootmem.h> | ||
| 23 | #include <linux/module.h> | ||
| 24 | |||
| 25 | #include <asm/prom.h> | ||
| 26 | #include <asm/oplib.h> | ||
| 27 | |||
| 28 | static struct device_node *allnodes; | ||
| 29 | |||
| 30 | int of_device_is_compatible(struct device_node *device, const char *compat) | ||
| 31 | { | ||
| 32 | const char* cp; | ||
| 33 | int cplen, l; | ||
| 34 | |||
| 35 | cp = (char *) of_get_property(device, "compatible", &cplen); | ||
| 36 | if (cp == NULL) | ||
| 37 | return 0; | ||
| 38 | while (cplen > 0) { | ||
| 39 | if (strncmp(cp, compat, strlen(compat)) == 0) | ||
| 40 | return 1; | ||
| 41 | l = strlen(cp) + 1; | ||
| 42 | cp += l; | ||
| 43 | cplen -= l; | ||
| 44 | } | ||
| 45 | |||
| 46 | return 0; | ||
| 47 | } | ||
| 48 | EXPORT_SYMBOL(of_device_is_compatible); | ||
| 49 | |||
| 50 | struct device_node *of_get_parent(const struct device_node *node) | ||
| 51 | { | ||
| 52 | struct device_node *np; | ||
| 53 | |||
| 54 | if (!node) | ||
| 55 | return NULL; | ||
| 56 | |||
| 57 | np = node->parent; | ||
| 58 | |||
| 59 | return np; | ||
| 60 | } | ||
| 61 | EXPORT_SYMBOL(of_get_parent); | ||
| 62 | |||
| 63 | struct device_node *of_get_next_child(const struct device_node *node, | ||
| 64 | struct device_node *prev) | ||
| 65 | { | ||
| 66 | struct device_node *next; | ||
| 67 | |||
| 68 | next = prev ? prev->sibling : node->child; | ||
| 69 | for (; next != 0; next = next->sibling) { | ||
| 70 | break; | ||
| 71 | } | ||
| 72 | |||
| 73 | return next; | ||
| 74 | } | ||
| 75 | EXPORT_SYMBOL(of_get_next_child); | ||
| 76 | |||
| 77 | struct device_node *of_find_node_by_path(const char *path) | ||
| 78 | { | ||
| 79 | struct device_node *np = allnodes; | ||
| 80 | |||
| 81 | for (; np != 0; np = np->allnext) { | ||
| 82 | if (np->full_name != 0 && strcmp(np->full_name, path) == 0) | ||
| 83 | break; | ||
| 84 | } | ||
| 85 | |||
| 86 | return np; | ||
| 87 | } | ||
| 88 | EXPORT_SYMBOL(of_find_node_by_path); | ||
| 89 | |||
| 90 | struct device_node *of_find_node_by_phandle(phandle handle) | ||
| 91 | { | ||
| 92 | struct device_node *np; | ||
| 93 | |||
| 94 | for (np = allnodes; np != 0; np = np->allnext) | ||
| 95 | if (np->node == handle) | ||
| 96 | break; | ||
| 97 | |||
| 98 | return np; | ||
| 99 | } | ||
| 100 | EXPORT_SYMBOL(of_find_node_by_phandle); | ||
| 101 | |||
| 102 | struct device_node *of_find_node_by_name(struct device_node *from, | ||
| 103 | const char *name) | ||
| 104 | { | ||
| 105 | struct device_node *np; | ||
| 106 | |||
| 107 | np = from ? from->allnext : allnodes; | ||
| 108 | for (; np != NULL; np = np->allnext) | ||
| 109 | if (np->name != NULL && strcmp(np->name, name) == 0) | ||
| 110 | break; | ||
| 111 | |||
| 112 | return np; | ||
| 113 | } | ||
| 114 | EXPORT_SYMBOL(of_find_node_by_name); | ||
| 115 | |||
| 116 | struct device_node *of_find_node_by_type(struct device_node *from, | ||
| 117 | const char *type) | ||
| 118 | { | ||
| 119 | struct device_node *np; | ||
| 120 | |||
| 121 | np = from ? from->allnext : allnodes; | ||
| 122 | for (; np != 0; np = np->allnext) | ||
| 123 | if (np->type != 0 && strcmp(np->type, type) == 0) | ||
| 124 | break; | ||
| 125 | |||
| 126 | return np; | ||
| 127 | } | ||
| 128 | EXPORT_SYMBOL(of_find_node_by_type); | ||
| 129 | |||
| 130 | struct device_node *of_find_compatible_node(struct device_node *from, | ||
| 131 | const char *type, const char *compatible) | ||
| 132 | { | ||
| 133 | struct device_node *np; | ||
| 134 | |||
| 135 | np = from ? from->allnext : allnodes; | ||
| 136 | for (; np != 0; np = np->allnext) { | ||
| 137 | if (type != NULL | ||
| 138 | && !(np->type != 0 && strcmp(np->type, type) == 0)) | ||
| 139 | continue; | ||
| 140 | if (of_device_is_compatible(np, compatible)) | ||
| 141 | break; | ||
| 142 | } | ||
| 143 | |||
| 144 | return np; | ||
| 145 | } | ||
| 146 | EXPORT_SYMBOL(of_find_compatible_node); | ||
| 147 | |||
| 148 | struct property *of_find_property(struct device_node *np, const char *name, | ||
| 149 | int *lenp) | ||
| 150 | { | ||
| 151 | struct property *pp; | ||
| 152 | |||
| 153 | for (pp = np->properties; pp != 0; pp = pp->next) { | ||
| 154 | if (strcmp(pp->name, name) == 0) { | ||
| 155 | if (lenp != 0) | ||
| 156 | *lenp = pp->length; | ||
| 157 | break; | ||
| 158 | } | ||
| 159 | } | ||
| 160 | return pp; | ||
| 161 | } | ||
| 162 | EXPORT_SYMBOL(of_find_property); | ||
| 163 | |||
| 164 | /* | ||
| 165 | * Find a property with a given name for a given node | ||
| 166 | * and return the value. | ||
| 167 | */ | ||
| 168 | void *of_get_property(struct device_node *np, const char *name, int *lenp) | ||
| 169 | { | ||
| 170 | struct property *pp = of_find_property(np,name,lenp); | ||
| 171 | return pp ? pp->value : NULL; | ||
| 172 | } | ||
| 173 | EXPORT_SYMBOL(of_get_property); | ||
| 174 | |||
| 175 | int of_getintprop_default(struct device_node *np, const char *name, int def) | ||
| 176 | { | ||
| 177 | struct property *prop; | ||
| 178 | int len; | ||
| 179 | |||
| 180 | prop = of_find_property(np, name, &len); | ||
| 181 | if (!prop || len != 4) | ||
| 182 | return def; | ||
| 183 | |||
| 184 | return *(int *) prop->value; | ||
| 185 | } | ||
| 186 | EXPORT_SYMBOL(of_getintprop_default); | ||
| 187 | |||
| 188 | static unsigned int prom_early_allocated; | ||
| 189 | |||
| 190 | static void * __init prom_early_alloc(unsigned long size) | ||
| 191 | { | ||
| 192 | void *ret; | ||
| 193 | |||
| 194 | ret = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL); | ||
| 195 | if (ret != NULL) | ||
| 196 | memset(ret, 0, size); | ||
| 197 | |||
| 198 | prom_early_allocated += size; | ||
| 199 | |||
| 200 | return ret; | ||
| 201 | } | ||
| 202 | |||
| 203 | static int is_root_node(const struct device_node *dp) | ||
| 204 | { | ||
| 205 | if (!dp) | ||
| 206 | return 0; | ||
| 207 | |||
| 208 | return (dp->parent == NULL); | ||
| 209 | } | ||
| 210 | |||
| 211 | /* The following routines deal with the black magic of fully naming a | ||
| 212 | * node. | ||
| 213 | * | ||
| 214 | * Certain well known named nodes are just the simple name string. | ||
| 215 | * | ||
| 216 | * Actual devices have an address specifier appended to the base name | ||
| 217 | * string, like this "foo@addr". The "addr" can be in any number of | ||
| 218 | * formats, and the platform plus the type of the node determine the | ||
| 219 | * format and how it is constructed. | ||
| 220 | * | ||
| 221 | * For children of the ROOT node, the naming convention is fixed and | ||
| 222 | * determined by whether this is a sun4u or sun4v system. | ||
| 223 | * | ||
| 224 | * For children of other nodes, it is bus type specific. So | ||
| 225 | * we walk up the tree until we discover a "device_type" property | ||
| 226 | * we recognize and we go from there. | ||
| 227 | */ | ||
| 228 | static void __init sparc32_path_component(struct device_node *dp, char *tmp_buf) | ||
| 229 | { | ||
| 230 | struct linux_prom_registers *regs; | ||
| 231 | struct property *rprop; | ||
| 232 | |||
| 233 | rprop = of_find_property(dp, "reg", NULL); | ||
| 234 | if (!rprop) | ||
| 235 | return; | ||
| 236 | |||
| 237 | regs = rprop->value; | ||
| 238 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 239 | dp->name, | ||
| 240 | regs->which_io, regs->phys_addr); | ||
| 241 | } | ||
| 242 | |||
| 243 | /* "name@slot,offset" */ | ||
| 244 | static void __init sbus_path_component(struct device_node *dp, char *tmp_buf) | ||
| 245 | { | ||
| 246 | struct linux_prom_registers *regs; | ||
| 247 | struct property *prop; | ||
| 248 | |||
| 249 | prop = of_find_property(dp, "reg", NULL); | ||
| 250 | if (!prop) | ||
| 251 | return; | ||
| 252 | |||
| 253 | regs = prop->value; | ||
| 254 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 255 | dp->name, | ||
| 256 | regs->which_io, | ||
| 257 | regs->phys_addr); | ||
| 258 | } | ||
| 259 | |||
| 260 | /* "name@devnum[,func]" */ | ||
| 261 | static void __init pci_path_component(struct device_node *dp, char *tmp_buf) | ||
| 262 | { | ||
| 263 | struct linux_prom_pci_registers *regs; | ||
| 264 | struct property *prop; | ||
| 265 | unsigned int devfn; | ||
| 266 | |||
| 267 | prop = of_find_property(dp, "reg", NULL); | ||
| 268 | if (!prop) | ||
| 269 | return; | ||
| 270 | |||
| 271 | regs = prop->value; | ||
| 272 | devfn = (regs->phys_hi >> 8) & 0xff; | ||
| 273 | if (devfn & 0x07) { | ||
| 274 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 275 | dp->name, | ||
| 276 | devfn >> 3, | ||
| 277 | devfn & 0x07); | ||
| 278 | } else { | ||
| 279 | sprintf(tmp_buf, "%s@%x", | ||
| 280 | dp->name, | ||
| 281 | devfn >> 3); | ||
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 285 | /* "name@addrhi,addrlo" */ | ||
| 286 | static void __init ebus_path_component(struct device_node *dp, char *tmp_buf) | ||
| 287 | { | ||
| 288 | struct linux_prom_registers *regs; | ||
| 289 | struct property *prop; | ||
| 290 | |||
| 291 | prop = of_find_property(dp, "reg", NULL); | ||
| 292 | if (!prop) | ||
| 293 | return; | ||
| 294 | |||
| 295 | regs = prop->value; | ||
| 296 | |||
| 297 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 298 | dp->name, | ||
| 299 | regs->which_io, regs->phys_addr); | ||
| 300 | } | ||
| 301 | |||
| 302 | static void __init __build_path_component(struct device_node *dp, char *tmp_buf) | ||
| 303 | { | ||
| 304 | struct device_node *parent = dp->parent; | ||
| 305 | |||
| 306 | if (parent != NULL) { | ||
| 307 | if (!strcmp(parent->type, "pci") || | ||
| 308 | !strcmp(parent->type, "pciex")) | ||
| 309 | return pci_path_component(dp, tmp_buf); | ||
| 310 | if (!strcmp(parent->type, "sbus")) | ||
| 311 | return sbus_path_component(dp, tmp_buf); | ||
| 312 | if (!strcmp(parent->type, "ebus")) | ||
| 313 | return ebus_path_component(dp, tmp_buf); | ||
| 314 | |||
| 315 | /* "isa" is handled with platform naming */ | ||
| 316 | } | ||
| 317 | |||
| 318 | /* Use platform naming convention. */ | ||
| 319 | return sparc32_path_component(dp, tmp_buf); | ||
| 320 | } | ||
| 321 | |||
| 322 | static char * __init build_path_component(struct device_node *dp) | ||
| 323 | { | ||
| 324 | char tmp_buf[64], *n; | ||
| 325 | |||
| 326 | tmp_buf[0] = '\0'; | ||
| 327 | __build_path_component(dp, tmp_buf); | ||
| 328 | if (tmp_buf[0] == '\0') | ||
| 329 | strcpy(tmp_buf, dp->name); | ||
| 330 | |||
| 331 | n = prom_early_alloc(strlen(tmp_buf) + 1); | ||
| 332 | strcpy(n, tmp_buf); | ||
| 333 | |||
| 334 | return n; | ||
| 335 | } | ||
| 336 | |||
| 337 | static char * __init build_full_name(struct device_node *dp) | ||
| 338 | { | ||
| 339 | int len, ourlen, plen; | ||
| 340 | char *n; | ||
| 341 | |||
| 342 | plen = strlen(dp->parent->full_name); | ||
| 343 | ourlen = strlen(dp->path_component_name); | ||
| 344 | len = ourlen + plen + 2; | ||
| 345 | |||
| 346 | n = prom_early_alloc(len); | ||
| 347 | strcpy(n, dp->parent->full_name); | ||
| 348 | if (!is_root_node(dp->parent)) { | ||
| 349 | strcpy(n + plen, "/"); | ||
| 350 | plen++; | ||
| 351 | } | ||
| 352 | strcpy(n + plen, dp->path_component_name); | ||
| 353 | |||
| 354 | return n; | ||
| 355 | } | ||
| 356 | |||
| 357 | static struct property * __init build_one_prop(phandle node, char *prev) | ||
| 358 | { | ||
| 359 | static struct property *tmp = NULL; | ||
| 360 | struct property *p; | ||
| 361 | int len; | ||
| 362 | |||
| 363 | if (tmp) { | ||
| 364 | p = tmp; | ||
| 365 | memset(p, 0, sizeof(*p) + 32); | ||
| 366 | tmp = NULL; | ||
| 367 | } else | ||
| 368 | p = prom_early_alloc(sizeof(struct property) + 32); | ||
| 369 | |||
| 370 | p->name = (char *) (p + 1); | ||
| 371 | if (prev == NULL) { | ||
| 372 | prom_firstprop(node, p->name); | ||
| 373 | } else { | ||
| 374 | prom_nextprop(node, prev, p->name); | ||
| 375 | } | ||
| 376 | if (strlen(p->name) == 0) { | ||
| 377 | tmp = p; | ||
| 378 | return NULL; | ||
| 379 | } | ||
| 380 | p->length = prom_getproplen(node, p->name); | ||
| 381 | if (p->length <= 0) { | ||
| 382 | p->length = 0; | ||
| 383 | } else { | ||
| 384 | p->value = prom_early_alloc(p->length); | ||
| 385 | len = prom_getproperty(node, p->name, p->value, p->length); | ||
| 386 | } | ||
| 387 | return p; | ||
| 388 | } | ||
| 389 | |||
| 390 | static struct property * __init build_prop_list(phandle node) | ||
| 391 | { | ||
| 392 | struct property *head, *tail; | ||
| 393 | |||
| 394 | head = tail = build_one_prop(node, NULL); | ||
| 395 | while(tail) { | ||
| 396 | tail->next = build_one_prop(node, tail->name); | ||
| 397 | tail = tail->next; | ||
| 398 | } | ||
| 399 | |||
| 400 | return head; | ||
| 401 | } | ||
| 402 | |||
| 403 | static char * __init get_one_property(phandle node, char *name) | ||
| 404 | { | ||
| 405 | char *buf = "<NULL>"; | ||
| 406 | int len; | ||
| 407 | |||
| 408 | len = prom_getproplen(node, name); | ||
| 409 | if (len > 0) { | ||
| 410 | buf = prom_early_alloc(len); | ||
| 411 | len = prom_getproperty(node, name, buf, len); | ||
| 412 | } | ||
| 413 | |||
| 414 | return buf; | ||
| 415 | } | ||
| 416 | |||
| 417 | static struct device_node * __init create_node(phandle node) | ||
| 418 | { | ||
| 419 | struct device_node *dp; | ||
| 420 | |||
| 421 | if (!node) | ||
| 422 | return NULL; | ||
| 423 | |||
| 424 | dp = prom_early_alloc(sizeof(*dp)); | ||
| 425 | |||
| 426 | kref_init(&dp->kref); | ||
| 427 | |||
| 428 | dp->name = get_one_property(node, "name"); | ||
| 429 | dp->type = get_one_property(node, "device_type"); | ||
| 430 | dp->node = node; | ||
| 431 | |||
| 432 | /* Build interrupts later... */ | ||
| 433 | |||
| 434 | dp->properties = build_prop_list(node); | ||
| 435 | |||
| 436 | return dp; | ||
| 437 | } | ||
| 438 | |||
| 439 | static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp) | ||
| 440 | { | ||
| 441 | struct device_node *dp; | ||
| 442 | |||
| 443 | dp = create_node(node); | ||
| 444 | if (dp) { | ||
| 445 | *(*nextp) = dp; | ||
| 446 | *nextp = &dp->allnext; | ||
| 447 | |||
| 448 | dp->parent = parent; | ||
| 449 | dp->path_component_name = build_path_component(dp); | ||
| 450 | dp->full_name = build_full_name(dp); | ||
| 451 | |||
| 452 | dp->child = build_tree(dp, prom_getchild(node), nextp); | ||
| 453 | |||
| 454 | dp->sibling = build_tree(parent, prom_getsibling(node), nextp); | ||
| 455 | } | ||
| 456 | |||
| 457 | return dp; | ||
| 458 | } | ||
| 459 | |||
| 460 | void __init prom_build_devicetree(void) | ||
| 461 | { | ||
| 462 | struct device_node **nextp; | ||
| 463 | |||
| 464 | allnodes = create_node(prom_root_node); | ||
| 465 | allnodes->path_component_name = ""; | ||
| 466 | allnodes->full_name = "/"; | ||
| 467 | |||
| 468 | nextp = &allnodes->allnext; | ||
| 469 | allnodes->child = build_tree(allnodes, | ||
| 470 | prom_getchild(allnodes->node), | ||
| 471 | &nextp); | ||
| 472 | printk("PROM: Built device tree with %u bytes of memory.\n", | ||
| 473 | prom_early_allocated); | ||
| 474 | } | ||
diff --git a/arch/sparc/mm/init.c b/arch/sparc/mm/init.c index 898669732466..cfa7d3456634 100644 --- a/arch/sparc/mm/init.c +++ b/arch/sparc/mm/init.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include <asm/vaddrs.h> | 31 | #include <asm/vaddrs.h> |
| 32 | #include <asm/pgalloc.h> /* bug in asm-generic/tlb.h: check_pgt_cache */ | 32 | #include <asm/pgalloc.h> /* bug in asm-generic/tlb.h: check_pgt_cache */ |
| 33 | #include <asm/tlb.h> | 33 | #include <asm/tlb.h> |
| 34 | #include <asm/prom.h> | ||
| 34 | 35 | ||
| 35 | DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); | 36 | DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); |
| 36 | 37 | ||
| @@ -349,6 +350,7 @@ void __init paging_init(void) | |||
| 349 | protection_map[14] = PAGE_SHARED; | 350 | protection_map[14] = PAGE_SHARED; |
| 350 | protection_map[15] = PAGE_SHARED; | 351 | protection_map[15] = PAGE_SHARED; |
| 351 | btfixup(); | 352 | btfixup(); |
| 353 | prom_build_devicetree(); | ||
| 352 | device_scan(); | 354 | device_scan(); |
| 353 | } | 355 | } |
| 354 | 356 | ||
diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig index 9da75f89fe2c..b2f41147d0e4 100644 --- a/arch/sparc64/defconfig +++ b/arch/sparc64/defconfig | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | # | 1 | # |
| 2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
| 3 | # Linux kernel version: 2.6.17 | 3 | # Linux kernel version: 2.6.17 |
| 4 | # Tue Jun 20 01:26:43 2006 | 4 | # Fri Jun 23 23:17:09 2006 |
| 5 | # | 5 | # |
| 6 | CONFIG_SPARC=y | 6 | CONFIG_SPARC=y |
| 7 | CONFIG_SPARC64=y | 7 | CONFIG_SPARC64=y |
| @@ -286,6 +286,7 @@ CONFIG_STANDALONE=y | |||
| 286 | # CONFIG_PREVENT_FIRMWARE_BUILD is not set | 286 | # CONFIG_PREVENT_FIRMWARE_BUILD is not set |
| 287 | CONFIG_FW_LOADER=y | 287 | CONFIG_FW_LOADER=y |
| 288 | # CONFIG_DEBUG_DRIVER is not set | 288 | # CONFIG_DEBUG_DRIVER is not set |
| 289 | # CONFIG_SYS_HYPERVISOR is not set | ||
| 289 | 290 | ||
| 290 | # | 291 | # |
| 291 | # Connector - unified userspace <-> kernelspace linker | 292 | # Connector - unified userspace <-> kernelspace linker |
| @@ -434,6 +435,7 @@ CONFIG_ISCSI_TCP=m | |||
| 434 | # CONFIG_MEGARAID_LEGACY is not set | 435 | # CONFIG_MEGARAID_LEGACY is not set |
| 435 | # CONFIG_MEGARAID_SAS is not set | 436 | # CONFIG_MEGARAID_SAS is not set |
| 436 | # CONFIG_SCSI_SATA is not set | 437 | # CONFIG_SCSI_SATA is not set |
| 438 | # CONFIG_SCSI_HPTIOP is not set | ||
| 437 | # CONFIG_SCSI_DMX3191D is not set | 439 | # CONFIG_SCSI_DMX3191D is not set |
| 438 | # CONFIG_SCSI_FUTURE_DOMAIN is not set | 440 | # CONFIG_SCSI_FUTURE_DOMAIN is not set |
| 439 | # CONFIG_SCSI_IPS is not set | 441 | # CONFIG_SCSI_IPS is not set |
| @@ -733,6 +735,7 @@ CONFIG_I2C_ALGOBIT=y | |||
| 733 | # CONFIG_I2C_I810 is not set | 735 | # CONFIG_I2C_I810 is not set |
| 734 | # CONFIG_I2C_PIIX4 is not set | 736 | # CONFIG_I2C_PIIX4 is not set |
| 735 | # CONFIG_I2C_NFORCE2 is not set | 737 | # CONFIG_I2C_NFORCE2 is not set |
| 738 | # CONFIG_I2C_OCORES is not set | ||
| 736 | # CONFIG_I2C_PARPORT_LIGHT is not set | 739 | # CONFIG_I2C_PARPORT_LIGHT is not set |
| 737 | # CONFIG_I2C_PROSAVAGE is not set | 740 | # CONFIG_I2C_PROSAVAGE is not set |
| 738 | # CONFIG_I2C_SAVAGE4 is not set | 741 | # CONFIG_I2C_SAVAGE4 is not set |
| @@ -776,6 +779,7 @@ CONFIG_I2C_ALGOBIT=y | |||
| 776 | # | 779 | # |
| 777 | CONFIG_HWMON=y | 780 | CONFIG_HWMON=y |
| 778 | # CONFIG_HWMON_VID is not set | 781 | # CONFIG_HWMON_VID is not set |
| 782 | # CONFIG_SENSORS_ABITUGURU is not set | ||
| 779 | # CONFIG_SENSORS_ADM1021 is not set | 783 | # CONFIG_SENSORS_ADM1021 is not set |
| 780 | # CONFIG_SENSORS_ADM1025 is not set | 784 | # CONFIG_SENSORS_ADM1025 is not set |
| 781 | # CONFIG_SENSORS_ADM1026 is not set | 785 | # CONFIG_SENSORS_ADM1026 is not set |
| @@ -804,10 +808,12 @@ CONFIG_HWMON=y | |||
| 804 | # CONFIG_SENSORS_PC87360 is not set | 808 | # CONFIG_SENSORS_PC87360 is not set |
| 805 | # CONFIG_SENSORS_SIS5595 is not set | 809 | # CONFIG_SENSORS_SIS5595 is not set |
| 806 | # CONFIG_SENSORS_SMSC47M1 is not set | 810 | # CONFIG_SENSORS_SMSC47M1 is not set |
| 811 | # CONFIG_SENSORS_SMSC47M192 is not set | ||
| 807 | # CONFIG_SENSORS_SMSC47B397 is not set | 812 | # CONFIG_SENSORS_SMSC47B397 is not set |
| 808 | # CONFIG_SENSORS_VIA686A is not set | 813 | # CONFIG_SENSORS_VIA686A is not set |
| 809 | # CONFIG_SENSORS_VT8231 is not set | 814 | # CONFIG_SENSORS_VT8231 is not set |
| 810 | # CONFIG_SENSORS_W83781D is not set | 815 | # CONFIG_SENSORS_W83781D is not set |
| 816 | # CONFIG_SENSORS_W83791D is not set | ||
| 811 | # CONFIG_SENSORS_W83792D is not set | 817 | # CONFIG_SENSORS_W83792D is not set |
| 812 | # CONFIG_SENSORS_W83L785TS is not set | 818 | # CONFIG_SENSORS_W83L785TS is not set |
| 813 | # CONFIG_SENSORS_W83627HF is not set | 819 | # CONFIG_SENSORS_W83627HF is not set |
| @@ -1018,6 +1024,7 @@ CONFIG_USB_DEVICEFS=y | |||
| 1018 | CONFIG_USB_EHCI_HCD=m | 1024 | CONFIG_USB_EHCI_HCD=m |
| 1019 | # CONFIG_USB_EHCI_SPLIT_ISO is not set | 1025 | # CONFIG_USB_EHCI_SPLIT_ISO is not set |
| 1020 | # CONFIG_USB_EHCI_ROOT_HUB_TT is not set | 1026 | # CONFIG_USB_EHCI_ROOT_HUB_TT is not set |
| 1027 | # CONFIG_USB_EHCI_TT_NEWSCHED is not set | ||
| 1021 | # CONFIG_USB_ISP116X_HCD is not set | 1028 | # CONFIG_USB_ISP116X_HCD is not set |
| 1022 | CONFIG_USB_OHCI_HCD=y | 1029 | CONFIG_USB_OHCI_HCD=y |
| 1023 | # CONFIG_USB_OHCI_BIG_ENDIAN is not set | 1030 | # CONFIG_USB_OHCI_BIG_ENDIAN is not set |
| @@ -1097,10 +1104,12 @@ CONFIG_USB_HIDDEV=y | |||
| 1097 | # CONFIG_USB_LEGOTOWER is not set | 1104 | # CONFIG_USB_LEGOTOWER is not set |
| 1098 | # CONFIG_USB_LCD is not set | 1105 | # CONFIG_USB_LCD is not set |
| 1099 | # CONFIG_USB_LED is not set | 1106 | # CONFIG_USB_LED is not set |
| 1107 | # CONFIG_USB_CY7C63 is not set | ||
| 1100 | # CONFIG_USB_CYTHERM is not set | 1108 | # CONFIG_USB_CYTHERM is not set |
| 1101 | # CONFIG_USB_PHIDGETKIT is not set | 1109 | # CONFIG_USB_PHIDGETKIT is not set |
| 1102 | # CONFIG_USB_PHIDGETSERVO is not set | 1110 | # CONFIG_USB_PHIDGETSERVO is not set |
| 1103 | # CONFIG_USB_IDMOUSE is not set | 1111 | # CONFIG_USB_IDMOUSE is not set |
| 1112 | # CONFIG_USB_APPLEDISPLAY is not set | ||
| 1104 | # CONFIG_USB_SISUSBVGA is not set | 1113 | # CONFIG_USB_SISUSBVGA is not set |
| 1105 | # CONFIG_USB_LD is not set | 1114 | # CONFIG_USB_LD is not set |
| 1106 | # CONFIG_USB_TEST is not set | 1115 | # CONFIG_USB_TEST is not set |
| @@ -1198,6 +1207,7 @@ CONFIG_FS_POSIX_ACL=y | |||
| 1198 | # CONFIG_MINIX_FS is not set | 1207 | # CONFIG_MINIX_FS is not set |
| 1199 | # CONFIG_ROMFS_FS is not set | 1208 | # CONFIG_ROMFS_FS is not set |
| 1200 | CONFIG_INOTIFY=y | 1209 | CONFIG_INOTIFY=y |
| 1210 | CONFIG_INOTIFY_USER=y | ||
| 1201 | # CONFIG_QUOTA is not set | 1211 | # CONFIG_QUOTA is not set |
| 1202 | CONFIG_DNOTIFY=y | 1212 | CONFIG_DNOTIFY=y |
| 1203 | # CONFIG_AUTOFS_FS is not set | 1213 | # CONFIG_AUTOFS_FS is not set |
diff --git a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile index 6f6816488b04..86c9fe3f3e4a 100644 --- a/arch/sparc64/kernel/Makefile +++ b/arch/sparc64/kernel/Makefile | |||
| @@ -12,7 +12,7 @@ obj-y := process.o setup.o cpu.o idprom.o \ | |||
| 12 | irq.o ptrace.o time.o sys_sparc.o signal.o \ | 12 | irq.o ptrace.o time.o sys_sparc.o signal.o \ |
| 13 | unaligned.o central.o pci.o starfire.o semaphore.o \ | 13 | unaligned.o central.o pci.o starfire.o semaphore.o \ |
| 14 | power.o sbus.o iommu_common.o sparc64_ksyms.o chmc.o \ | 14 | power.o sbus.o iommu_common.o sparc64_ksyms.o chmc.o \ |
| 15 | visemul.o | 15 | visemul.o prom.o of_device.o |
| 16 | 16 | ||
| 17 | obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o pci_iommu.o \ | 17 | obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o pci_iommu.o \ |
| 18 | pci_psycho.o pci_sabre.o pci_schizo.o \ | 18 | pci_psycho.o pci_sabre.o pci_schizo.o \ |
diff --git a/arch/sparc64/kernel/auxio.c b/arch/sparc64/kernel/auxio.c index 8852c20c8d99..2c42894b188f 100644 --- a/arch/sparc64/kernel/auxio.c +++ b/arch/sparc64/kernel/auxio.c | |||
| @@ -110,43 +110,82 @@ void auxio_set_lte(int on) | |||
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | void __init auxio_probe(void) | 113 | static void __devinit auxio_report_dev(struct device_node *dp) |
| 114 | { | 114 | { |
| 115 | struct sbus_bus *sbus; | 115 | printk(KERN_INFO "AUXIO: Found device at %s\n", |
| 116 | struct sbus_dev *sdev = NULL; | 116 | dp->full_name); |
| 117 | 117 | } | |
| 118 | for_each_sbus(sbus) { | 118 | |
| 119 | for_each_sbusdev(sdev, sbus) { | 119 | static struct of_device_id auxio_match[] = { |
| 120 | if(!strcmp(sdev->prom_name, "auxio")) | 120 | { |
| 121 | goto found_sdev; | 121 | .name = "auxio", |
| 122 | } | 122 | }, |
| 123 | } | 123 | {}, |
| 124 | 124 | }; | |
| 125 | found_sdev: | 125 | |
| 126 | if (sdev) { | 126 | MODULE_DEVICE_TABLE(of, auxio_match); |
| 127 | auxio_devtype = AUXIO_TYPE_SBUS; | 127 | |
| 128 | auxio_register = sbus_ioremap(&sdev->resource[0], 0, | 128 | #ifdef CONFIG_SBUS |
| 129 | sdev->reg_addrs[0].reg_size, | 129 | static int __devinit auxio_sbus_probe(struct of_device *dev, const struct of_device_id *match) |
| 130 | "auxiliaryIO"); | 130 | { |
| 131 | } | 131 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); |
| 132 | |||
| 133 | auxio_devtype = AUXIO_TYPE_SBUS; | ||
| 134 | auxio_register = sbus_ioremap(&sdev->resource[0], 0, | ||
| 135 | sdev->reg_addrs[0].reg_size, | ||
| 136 | "auxiliaryIO"); | ||
| 137 | if (!auxio_register) | ||
| 138 | return -ENODEV; | ||
| 139 | |||
| 140 | auxio_report_dev(dev->node); | ||
| 141 | return 0; | ||
| 142 | } | ||
| 143 | |||
| 144 | static struct of_platform_driver auxio_sbus_driver = { | ||
| 145 | .name = "auxio", | ||
| 146 | .match_table = auxio_match, | ||
| 147 | .probe = auxio_sbus_probe, | ||
| 148 | }; | ||
| 149 | #endif | ||
| 150 | |||
| 132 | #ifdef CONFIG_PCI | 151 | #ifdef CONFIG_PCI |
| 133 | else { | 152 | static int __devinit auxio_ebus_probe(struct of_device *dev, const struct of_device_id *match) |
| 134 | struct linux_ebus *ebus; | 153 | { |
| 135 | struct linux_ebus_device *edev = NULL; | 154 | struct linux_ebus_device *edev = to_ebus_device(&dev->dev); |
| 136 | 155 | ||
| 137 | for_each_ebus(ebus) { | 156 | auxio_devtype = AUXIO_TYPE_EBUS; |
| 138 | for_each_ebusdev(edev, ebus) { | 157 | auxio_register = ioremap(edev->resource[0].start, sizeof(u32)); |
| 139 | if (!strcmp(edev->prom_name, "auxio")) | 158 | if (!auxio_register) |
| 140 | goto ebus_done; | 159 | return -ENODEV; |
| 141 | } | 160 | |
| 142 | } | 161 | auxio_report_dev(dev->node); |
| 143 | ebus_done: | 162 | |
| 144 | if (edev) { | ||
| 145 | auxio_devtype = AUXIO_TYPE_EBUS; | ||
| 146 | auxio_register = | ||
| 147 | ioremap(edev->resource[0].start, sizeof(u32)); | ||
| 148 | } | ||
| 149 | } | ||
| 150 | auxio_set_led(AUXIO_LED_ON); | 163 | auxio_set_led(AUXIO_LED_ON); |
| 164 | |||
| 165 | return 0; | ||
| 166 | } | ||
| 167 | |||
| 168 | static struct of_platform_driver auxio_ebus_driver = { | ||
| 169 | .name = "auxio", | ||
| 170 | .match_table = auxio_match, | ||
| 171 | .probe = auxio_ebus_probe, | ||
| 172 | }; | ||
| 151 | #endif | 173 | #endif |
| 174 | |||
| 175 | static int __init auxio_probe(void) | ||
| 176 | { | ||
| 177 | #ifdef CONFIG_SBUS | ||
| 178 | of_register_driver(&auxio_sbus_driver, &sbus_bus_type); | ||
| 179 | #endif | ||
| 180 | #ifdef CONFIG_PCI | ||
| 181 | of_register_driver(&auxio_ebus_driver, &ebus_bus_type); | ||
| 182 | #endif | ||
| 183 | |||
| 184 | return 0; | ||
| 152 | } | 185 | } |
| 186 | |||
| 187 | /* Must be after subsys_initcall() so that busses are probed. Must | ||
| 188 | * be before device_initcall() because things like the floppy driver | ||
| 189 | * need to use the AUXIO register. | ||
| 190 | */ | ||
| 191 | fs_initcall(auxio_probe); | ||
diff --git a/arch/sparc64/kernel/central.c b/arch/sparc64/kernel/central.c index 3d184a784968..b66336db00ee 100644 --- a/arch/sparc64/kernel/central.c +++ b/arch/sparc64/kernel/central.c | |||
| @@ -29,28 +29,34 @@ static void central_probe_failure(int line) | |||
| 29 | prom_halt(); | 29 | prom_halt(); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | static void central_ranges_init(int cnode, struct linux_central *central) | 32 | static void central_ranges_init(struct linux_central *central) |
| 33 | { | 33 | { |
| 34 | int success; | 34 | struct device_node *dp = central->prom_node; |
| 35 | void *pval; | ||
| 36 | int len; | ||
| 35 | 37 | ||
| 36 | central->num_central_ranges = 0; | 38 | central->num_central_ranges = 0; |
| 37 | success = prom_getproperty(central->prom_node, "ranges", | 39 | pval = of_get_property(dp, "ranges", &len); |
| 38 | (char *) central->central_ranges, | 40 | if (pval) { |
| 39 | sizeof (central->central_ranges)); | 41 | memcpy(central->central_ranges, pval, len); |
| 40 | if (success != -1) | 42 | central->num_central_ranges = |
| 41 | central->num_central_ranges = (success/sizeof(struct linux_prom_ranges)); | 43 | (len / sizeof(struct linux_prom_ranges)); |
| 44 | } | ||
| 42 | } | 45 | } |
| 43 | 46 | ||
| 44 | static void fhc_ranges_init(int fnode, struct linux_fhc *fhc) | 47 | static void fhc_ranges_init(struct linux_fhc *fhc) |
| 45 | { | 48 | { |
| 46 | int success; | 49 | struct device_node *dp = fhc->prom_node; |
| 50 | void *pval; | ||
| 51 | int len; | ||
| 47 | 52 | ||
| 48 | fhc->num_fhc_ranges = 0; | 53 | fhc->num_fhc_ranges = 0; |
| 49 | success = prom_getproperty(fhc->prom_node, "ranges", | 54 | pval = of_get_property(dp, "ranges", &len); |
| 50 | (char *) fhc->fhc_ranges, | 55 | if (pval) { |
| 51 | sizeof (fhc->fhc_ranges)); | 56 | memcpy(fhc->fhc_ranges, pval, len); |
| 52 | if (success != -1) | 57 | fhc->num_fhc_ranges = |
| 53 | fhc->num_fhc_ranges = (success/sizeof(struct linux_prom_ranges)); | 58 | (len / sizeof(struct linux_prom_ranges)); |
| 59 | } | ||
| 54 | } | 60 | } |
| 55 | 61 | ||
| 56 | /* Range application routines are exported to various drivers, | 62 | /* Range application routines are exported to various drivers, |
| @@ -112,15 +118,10 @@ static unsigned long prom_reg_to_paddr(struct linux_prom_registers *r) | |||
| 112 | 118 | ||
| 113 | static void probe_other_fhcs(void) | 119 | static void probe_other_fhcs(void) |
| 114 | { | 120 | { |
| 115 | struct linux_prom64_registers fpregs[6]; | 121 | struct device_node *dp; |
| 116 | char namebuf[128]; | 122 | struct linux_prom64_registers *fpregs; |
| 117 | int node; | ||
| 118 | 123 | ||
| 119 | node = prom_getchild(prom_root_node); | 124 | for_each_node_by_name(dp, "fhc") { |
| 120 | node = prom_searchsiblings(node, "fhc"); | ||
| 121 | if (node == 0) | ||
| 122 | central_probe_failure(__LINE__); | ||
| 123 | while (node) { | ||
| 124 | struct linux_fhc *fhc; | 125 | struct linux_fhc *fhc; |
| 125 | int board; | 126 | int board; |
| 126 | u32 tmp; | 127 | u32 tmp; |
| @@ -137,14 +138,12 @@ static void probe_other_fhcs(void) | |||
| 137 | /* Toplevel FHCs have no parent. */ | 138 | /* Toplevel FHCs have no parent. */ |
| 138 | fhc->parent = NULL; | 139 | fhc->parent = NULL; |
| 139 | 140 | ||
| 140 | fhc->prom_node = node; | 141 | fhc->prom_node = dp; |
| 141 | prom_getstring(node, "name", namebuf, sizeof(namebuf)); | 142 | fhc_ranges_init(fhc); |
| 142 | strcpy(fhc->prom_name, namebuf); | ||
| 143 | fhc_ranges_init(node, fhc); | ||
| 144 | 143 | ||
| 145 | /* Non-central FHC's have 64-bit OBP format registers. */ | 144 | /* Non-central FHC's have 64-bit OBP format registers. */ |
| 146 | if (prom_getproperty(node, "reg", | 145 | fpregs = of_get_property(dp, "reg", NULL); |
| 147 | (char *)&fpregs[0], sizeof(fpregs)) == -1) | 146 | if (!fpregs) |
| 148 | central_probe_failure(__LINE__); | 147 | central_probe_failure(__LINE__); |
| 149 | 148 | ||
| 150 | /* Only central FHC needs special ranges applied. */ | 149 | /* Only central FHC needs special ranges applied. */ |
| @@ -155,7 +154,7 @@ static void probe_other_fhcs(void) | |||
| 155 | fhc->fhc_regs.uregs = fpregs[4].phys_addr; | 154 | fhc->fhc_regs.uregs = fpregs[4].phys_addr; |
| 156 | fhc->fhc_regs.tregs = fpregs[5].phys_addr; | 155 | fhc->fhc_regs.tregs = fpregs[5].phys_addr; |
| 157 | 156 | ||
| 158 | board = prom_getintdefault(node, "board#", -1); | 157 | board = of_getintprop_default(dp, "board#", -1); |
| 159 | fhc->board = board; | 158 | fhc->board = board; |
| 160 | 159 | ||
| 161 | tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_JCTRL); | 160 | tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_JCTRL); |
| @@ -179,33 +178,33 @@ static void probe_other_fhcs(void) | |||
| 179 | tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_CTRL); | 178 | tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_CTRL); |
| 180 | tmp |= FHC_CONTROL_IXIST; | 179 | tmp |= FHC_CONTROL_IXIST; |
| 181 | upa_writel(tmp, fhc->fhc_regs.pregs + FHC_PREGS_CTRL); | 180 | upa_writel(tmp, fhc->fhc_regs.pregs + FHC_PREGS_CTRL); |
| 182 | |||
| 183 | /* Look for the next FHC. */ | ||
| 184 | node = prom_getsibling(node); | ||
| 185 | if (node == 0) | ||
| 186 | break; | ||
| 187 | node = prom_searchsiblings(node, "fhc"); | ||
| 188 | if (node == 0) | ||
| 189 | break; | ||
| 190 | } | 181 | } |
| 191 | } | 182 | } |
| 192 | 183 | ||
| 193 | static void probe_clock_board(struct linux_central *central, | 184 | static void probe_clock_board(struct linux_central *central, |
| 194 | struct linux_fhc *fhc, | 185 | struct linux_fhc *fhc, |
| 195 | int cnode, int fnode) | 186 | struct device_node *fp) |
| 196 | { | 187 | { |
| 197 | struct linux_prom_registers cregs[3]; | 188 | struct device_node *dp; |
| 198 | int clknode, nslots, tmp, nregs; | 189 | struct linux_prom_registers cregs[3], *pr; |
| 190 | int nslots, tmp, nregs; | ||
| 199 | 191 | ||
| 200 | clknode = prom_searchsiblings(prom_getchild(fnode), "clock-board"); | 192 | dp = fp->child; |
| 201 | if (clknode == 0 || clknode == -1) | 193 | while (dp) { |
| 194 | if (!strcmp(dp->name, "clock-board")) | ||
| 195 | break; | ||
| 196 | dp = dp->sibling; | ||
| 197 | } | ||
| 198 | if (!dp) | ||
| 202 | central_probe_failure(__LINE__); | 199 | central_probe_failure(__LINE__); |
| 203 | 200 | ||
| 204 | nregs = prom_getproperty(clknode, "reg", (char *)&cregs[0], sizeof(cregs)); | 201 | pr = of_get_property(dp, "reg", &nregs); |
| 205 | if (nregs == -1) | 202 | if (!pr) |
| 206 | central_probe_failure(__LINE__); | 203 | central_probe_failure(__LINE__); |
| 207 | 204 | ||
| 205 | memcpy(cregs, pr, nregs); | ||
| 208 | nregs /= sizeof(struct linux_prom_registers); | 206 | nregs /= sizeof(struct linux_prom_registers); |
| 207 | |||
| 209 | apply_fhc_ranges(fhc, &cregs[0], nregs); | 208 | apply_fhc_ranges(fhc, &cregs[0], nregs); |
| 210 | apply_central_ranges(central, &cregs[0], nregs); | 209 | apply_central_ranges(central, &cregs[0], nregs); |
| 211 | central->cfreg = prom_reg_to_paddr(&cregs[0]); | 210 | central->cfreg = prom_reg_to_paddr(&cregs[0]); |
| @@ -296,13 +295,13 @@ static void init_all_fhc_hw(void) | |||
| 296 | 295 | ||
| 297 | void central_probe(void) | 296 | void central_probe(void) |
| 298 | { | 297 | { |
| 299 | struct linux_prom_registers fpregs[6]; | 298 | struct linux_prom_registers fpregs[6], *pr; |
| 300 | struct linux_fhc *fhc; | 299 | struct linux_fhc *fhc; |
| 301 | char namebuf[128]; | 300 | struct device_node *dp, *fp; |
| 302 | int cnode, fnode, err; | 301 | int err; |
| 303 | 302 | ||
| 304 | cnode = prom_finddevice("/central"); | 303 | dp = of_find_node_by_name(NULL, "central"); |
| 305 | if (cnode == 0 || cnode == -1) { | 304 | if (!dp) { |
| 306 | if (this_is_starfire) | 305 | if (this_is_starfire) |
| 307 | starfire_cpu_setup(); | 306 | starfire_cpu_setup(); |
| 308 | return; | 307 | return; |
| @@ -321,31 +320,31 @@ void central_probe(void) | |||
| 321 | 320 | ||
| 322 | /* First init central. */ | 321 | /* First init central. */ |
| 323 | central_bus->child = fhc; | 322 | central_bus->child = fhc; |
| 324 | central_bus->prom_node = cnode; | 323 | central_bus->prom_node = dp; |
| 325 | 324 | central_ranges_init(central_bus); | |
| 326 | prom_getstring(cnode, "name", namebuf, sizeof(namebuf)); | ||
| 327 | strcpy(central_bus->prom_name, namebuf); | ||
| 328 | |||
| 329 | central_ranges_init(cnode, central_bus); | ||
| 330 | 325 | ||
| 331 | /* And then central's FHC. */ | 326 | /* And then central's FHC. */ |
| 332 | fhc->next = fhc_list; | 327 | fhc->next = fhc_list; |
| 333 | fhc_list = fhc; | 328 | fhc_list = fhc; |
| 334 | 329 | ||
| 335 | fhc->parent = central_bus; | 330 | fhc->parent = central_bus; |
| 336 | fnode = prom_searchsiblings(prom_getchild(cnode), "fhc"); | 331 | fp = dp->child; |
| 337 | if (fnode == 0 || fnode == -1) | 332 | while (fp) { |
| 333 | if (!strcmp(fp->name, "fhc")) | ||
| 334 | break; | ||
| 335 | fp = fp->sibling; | ||
| 336 | } | ||
| 337 | if (!fp) | ||
| 338 | central_probe_failure(__LINE__); | 338 | central_probe_failure(__LINE__); |
| 339 | 339 | ||
| 340 | fhc->prom_node = fnode; | 340 | fhc->prom_node = fp; |
| 341 | prom_getstring(fnode, "name", namebuf, sizeof(namebuf)); | 341 | fhc_ranges_init(fhc); |
| 342 | strcpy(fhc->prom_name, namebuf); | ||
| 343 | |||
| 344 | fhc_ranges_init(fnode, fhc); | ||
| 345 | 342 | ||
| 346 | /* Now, map in FHC register set. */ | 343 | /* Now, map in FHC register set. */ |
| 347 | if (prom_getproperty(fnode, "reg", (char *)&fpregs[0], sizeof(fpregs)) == -1) | 344 | pr = of_get_property(fp, "reg", NULL); |
| 345 | if (!pr) | ||
| 348 | central_probe_failure(__LINE__); | 346 | central_probe_failure(__LINE__); |
| 347 | memcpy(fpregs, pr, sizeof(fpregs)); | ||
| 349 | 348 | ||
| 350 | apply_central_ranges(central_bus, &fpregs[0], 6); | 349 | apply_central_ranges(central_bus, &fpregs[0], 6); |
| 351 | 350 | ||
| @@ -366,7 +365,7 @@ void central_probe(void) | |||
| 366 | fhc->jtag_master = 0; | 365 | fhc->jtag_master = 0; |
| 367 | 366 | ||
| 368 | /* Attach the clock board registers for CENTRAL. */ | 367 | /* Attach the clock board registers for CENTRAL. */ |
| 369 | probe_clock_board(central_bus, fhc, cnode, fnode); | 368 | probe_clock_board(central_bus, fhc, fp); |
| 370 | 369 | ||
| 371 | err = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_ID); | 370 | err = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_ID); |
| 372 | printk("FHC(board %d): Version[%x] PartID[%x] Manuf[%x] (CENTRAL)\n", | 371 | printk("FHC(board %d): Version[%x] PartID[%x] Manuf[%x] (CENTRAL)\n", |
diff --git a/arch/sparc64/kernel/chmc.c b/arch/sparc64/kernel/chmc.c index 97cf912f0853..259f37e516f5 100644 --- a/arch/sparc64/kernel/chmc.c +++ b/arch/sparc64/kernel/chmc.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <asm/spitfire.h> | 17 | #include <asm/spitfire.h> |
| 18 | #include <asm/chmctrl.h> | 18 | #include <asm/chmctrl.h> |
| 19 | #include <asm/oplib.h> | 19 | #include <asm/oplib.h> |
| 20 | #include <asm/prom.h> | ||
| 20 | #include <asm/io.h> | 21 | #include <asm/io.h> |
| 21 | 22 | ||
| 22 | #define CHMCTRL_NDGRPS 2 | 23 | #define CHMCTRL_NDGRPS 2 |
| @@ -67,7 +68,6 @@ struct bank_info { | |||
| 67 | struct mctrl_info { | 68 | struct mctrl_info { |
| 68 | struct list_head list; | 69 | struct list_head list; |
| 69 | int portid; | 70 | int portid; |
| 70 | int index; | ||
| 71 | 71 | ||
| 72 | struct obp_mem_layout layout_prop; | 72 | struct obp_mem_layout layout_prop; |
| 73 | int layout_size; | 73 | int layout_size; |
| @@ -339,12 +339,13 @@ static void fetch_decode_regs(struct mctrl_info *mp) | |||
| 339 | read_mcreg(mp, CHMCTRL_DECODE4)); | 339 | read_mcreg(mp, CHMCTRL_DECODE4)); |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | static int init_one_mctrl(int node, int index) | 342 | static int init_one_mctrl(struct device_node *dp) |
| 343 | { | 343 | { |
| 344 | struct mctrl_info *mp = kmalloc(sizeof(*mp), GFP_KERNEL); | 344 | struct mctrl_info *mp = kmalloc(sizeof(*mp), GFP_KERNEL); |
| 345 | int portid = prom_getintdefault(node, "portid", -1); | 345 | int portid = of_getintprop_default(dp, "portid", -1); |
| 346 | struct linux_prom64_registers p_reg_prop; | 346 | struct linux_prom64_registers *regs; |
| 347 | int t; | 347 | void *pval; |
| 348 | int len; | ||
| 348 | 349 | ||
| 349 | if (!mp) | 350 | if (!mp) |
| 350 | return -1; | 351 | return -1; |
| @@ -353,24 +354,21 @@ static int init_one_mctrl(int node, int index) | |||
| 353 | goto fail; | 354 | goto fail; |
| 354 | 355 | ||
| 355 | mp->portid = portid; | 356 | mp->portid = portid; |
| 356 | mp->layout_size = prom_getproplen(node, "memory-layout"); | 357 | pval = of_get_property(dp, "memory-layout", &len); |
| 357 | if (mp->layout_size < 0) | 358 | mp->layout_size = len; |
| 359 | if (!pval) | ||
| 358 | mp->layout_size = 0; | 360 | mp->layout_size = 0; |
| 359 | if (mp->layout_size > sizeof(mp->layout_prop)) | 361 | else { |
| 360 | goto fail; | 362 | if (mp->layout_size > sizeof(mp->layout_prop)) |
| 361 | 363 | goto fail; | |
| 362 | if (mp->layout_size > 0) | 364 | memcpy(&mp->layout_prop, pval, len); |
| 363 | prom_getproperty(node, "memory-layout", | 365 | } |
| 364 | (char *) &mp->layout_prop, | ||
| 365 | mp->layout_size); | ||
| 366 | 366 | ||
| 367 | t = prom_getproperty(node, "reg", | 367 | regs = of_get_property(dp, "reg", NULL); |
| 368 | (char *) &p_reg_prop, | 368 | if (!regs || regs->reg_size != 0x48) |
| 369 | sizeof(p_reg_prop)); | ||
| 370 | if (t < 0 || p_reg_prop.reg_size != 0x48) | ||
| 371 | goto fail; | 369 | goto fail; |
| 372 | 370 | ||
| 373 | mp->regs = ioremap(p_reg_prop.phys_addr, p_reg_prop.reg_size); | 371 | mp->regs = ioremap(regs->phys_addr, regs->reg_size); |
| 374 | if (mp->regs == NULL) | 372 | if (mp->regs == NULL) |
| 375 | goto fail; | 373 | goto fail; |
| 376 | 374 | ||
| @@ -384,13 +382,11 @@ static int init_one_mctrl(int node, int index) | |||
| 384 | 382 | ||
| 385 | fetch_decode_regs(mp); | 383 | fetch_decode_regs(mp); |
| 386 | 384 | ||
| 387 | mp->index = index; | ||
| 388 | |||
| 389 | list_add(&mp->list, &mctrl_list); | 385 | list_add(&mp->list, &mctrl_list); |
| 390 | 386 | ||
| 391 | /* Report the device. */ | 387 | /* Report the device. */ |
| 392 | printk(KERN_INFO "chmc%d: US3 memory controller at %p [%s]\n", | 388 | printk(KERN_INFO "%s: US3 memory controller at %p [%s]\n", |
| 393 | mp->index, | 389 | dp->full_name, |
| 394 | mp->regs, (mp->layout_size ? "ACTIVE" : "INACTIVE")); | 390 | mp->regs, (mp->layout_size ? "ACTIVE" : "INACTIVE")); |
| 395 | 391 | ||
| 396 | return 0; | 392 | return 0; |
| @@ -404,34 +400,19 @@ fail: | |||
| 404 | return -1; | 400 | return -1; |
| 405 | } | 401 | } |
| 406 | 402 | ||
| 407 | static int __init probe_for_string(char *name, int index) | ||
| 408 | { | ||
| 409 | int node = prom_getchild(prom_root_node); | ||
| 410 | |||
| 411 | while ((node = prom_searchsiblings(node, name)) != 0) { | ||
| 412 | int ret = init_one_mctrl(node, index); | ||
| 413 | |||
| 414 | if (!ret) | ||
| 415 | index++; | ||
| 416 | |||
| 417 | node = prom_getsibling(node); | ||
| 418 | if (!node) | ||
| 419 | break; | ||
| 420 | } | ||
| 421 | |||
| 422 | return index; | ||
| 423 | } | ||
| 424 | |||
| 425 | static int __init chmc_init(void) | 403 | static int __init chmc_init(void) |
| 426 | { | 404 | { |
| 427 | int index; | 405 | struct device_node *dp; |
| 428 | 406 | ||
| 429 | /* This driver is only for cheetah platforms. */ | 407 | /* This driver is only for cheetah platforms. */ |
| 430 | if (tlb_type != cheetah && tlb_type != cheetah_plus) | 408 | if (tlb_type != cheetah && tlb_type != cheetah_plus) |
| 431 | return -ENODEV; | 409 | return -ENODEV; |
| 432 | 410 | ||
| 433 | index = probe_for_string("memory-controller", 0); | 411 | for_each_node_by_name(dp, "memory-controller") |
| 434 | index = probe_for_string("mc-us3", index); | 412 | init_one_mctrl(dp); |
| 413 | |||
| 414 | for_each_node_by_name(dp, "mc-us3") | ||
| 415 | init_one_mctrl(dp); | ||
| 435 | 416 | ||
| 436 | return 0; | 417 | return 0; |
| 437 | } | 418 | } |
diff --git a/arch/sparc64/kernel/devices.c b/arch/sparc64/kernel/devices.c index 0dd95ae50e12..389301c95cb2 100644 --- a/arch/sparc64/kernel/devices.c +++ b/arch/sparc64/kernel/devices.c | |||
| @@ -33,7 +33,7 @@ extern void cpu_probe(void); | |||
| 33 | extern void central_probe(void); | 33 | extern void central_probe(void); |
| 34 | 34 | ||
| 35 | u32 sun4v_vdev_devhandle; | 35 | u32 sun4v_vdev_devhandle; |
| 36 | int sun4v_vdev_root; | 36 | struct device_node *sun4v_vdev_root; |
| 37 | 37 | ||
| 38 | struct vdev_intmap { | 38 | struct vdev_intmap { |
| 39 | unsigned int phys; | 39 | unsigned int phys; |
| @@ -50,102 +50,68 @@ struct vdev_intmask { | |||
| 50 | 50 | ||
| 51 | static struct vdev_intmap *vdev_intmap; | 51 | static struct vdev_intmap *vdev_intmap; |
| 52 | static int vdev_num_intmap; | 52 | static int vdev_num_intmap; |
| 53 | static struct vdev_intmask vdev_intmask; | 53 | static struct vdev_intmask *vdev_intmask; |
| 54 | 54 | ||
| 55 | static void __init sun4v_virtual_device_probe(void) | 55 | static void __init sun4v_virtual_device_probe(void) |
| 56 | { | 56 | { |
| 57 | struct linux_prom64_registers regs; | 57 | struct linux_prom64_registers *regs; |
| 58 | struct vdev_intmap *ip; | 58 | struct property *prop; |
| 59 | int node, sz, err; | 59 | struct device_node *dp; |
| 60 | int sz; | ||
| 60 | 61 | ||
| 61 | if (tlb_type != hypervisor) | 62 | if (tlb_type != hypervisor) |
| 62 | return; | 63 | return; |
| 63 | 64 | ||
| 64 | node = prom_getchild(prom_root_node); | 65 | dp = of_find_node_by_name(NULL, "virtual-devices"); |
| 65 | node = prom_searchsiblings(node, "virtual-devices"); | 66 | if (!dp) { |
| 66 | if (!node) { | ||
| 67 | prom_printf("SUN4V: Fatal error, no virtual-devices node.\n"); | 67 | prom_printf("SUN4V: Fatal error, no virtual-devices node.\n"); |
| 68 | prom_halt(); | 68 | prom_halt(); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | sun4v_vdev_root = node; | 71 | sun4v_vdev_root = dp; |
| 72 | 72 | ||
| 73 | prom_getproperty(node, "reg", (char *)®s, sizeof(regs)); | 73 | prop = of_find_property(dp, "reg", NULL); |
| 74 | sun4v_vdev_devhandle = (regs.phys_addr >> 32UL) & 0x0fffffff; | 74 | regs = prop->value; |
| 75 | sun4v_vdev_devhandle = (regs[0].phys_addr >> 32UL) & 0x0fffffff; | ||
| 75 | 76 | ||
| 76 | sz = prom_getproplen(node, "interrupt-map"); | 77 | prop = of_find_property(dp, "interrupt-map", &sz); |
| 77 | if (sz <= 0) { | 78 | vdev_intmap = prop->value; |
| 78 | prom_printf("SUN4V: Error, no vdev interrupt-map.\n"); | 79 | vdev_num_intmap = sz / sizeof(struct vdev_intmap); |
| 79 | prom_halt(); | ||
| 80 | } | ||
| 81 | |||
| 82 | if ((sz % sizeof(*ip)) != 0) { | ||
| 83 | prom_printf("SUN4V: Bogus interrupt-map property size %d\n", | ||
| 84 | sz); | ||
| 85 | prom_halt(); | ||
| 86 | } | ||
| 87 | |||
| 88 | vdev_intmap = ip = alloc_bootmem_low_pages(sz); | ||
| 89 | if (!vdev_intmap) { | ||
| 90 | prom_printf("SUN4V: Error, cannot allocate vdev_intmap.\n"); | ||
| 91 | prom_halt(); | ||
| 92 | } | ||
| 93 | |||
| 94 | err = prom_getproperty(node, "interrupt-map", (char *) ip, sz); | ||
| 95 | if (err == -1) { | ||
| 96 | prom_printf("SUN4V: Fatal error, no vdev interrupt-map.\n"); | ||
| 97 | prom_halt(); | ||
| 98 | } | ||
| 99 | if (err != sz) { | ||
| 100 | prom_printf("SUN4V: Inconsistent interrupt-map size, " | ||
| 101 | "proplen(%d) vs getprop(%d).\n", sz,err); | ||
| 102 | prom_halt(); | ||
| 103 | } | ||
| 104 | |||
| 105 | vdev_num_intmap = err / sizeof(*ip); | ||
| 106 | 80 | ||
| 107 | err = prom_getproperty(node, "interrupt-map-mask", | 81 | prop = of_find_property(dp, "interrupt-map-mask", NULL); |
| 108 | (char *) &vdev_intmask, | 82 | vdev_intmask = prop->value; |
| 109 | sizeof(vdev_intmask)); | ||
| 110 | if (err <= 0) { | ||
| 111 | prom_printf("SUN4V: Fatal error, no vdev " | ||
| 112 | "interrupt-map-mask.\n"); | ||
| 113 | prom_halt(); | ||
| 114 | } | ||
| 115 | if (err % sizeof(vdev_intmask)) { | ||
| 116 | prom_printf("SUN4V: Bogus interrupt-map-mask " | ||
| 117 | "property size %d\n", err); | ||
| 118 | prom_halt(); | ||
| 119 | } | ||
| 120 | 83 | ||
| 121 | printk("SUN4V: virtual-devices devhandle[%x]\n", | 84 | printk("%s: Virtual Device Bus devhandle[%x]\n", |
| 122 | sun4v_vdev_devhandle); | 85 | dp->full_name, sun4v_vdev_devhandle); |
| 123 | } | 86 | } |
| 124 | 87 | ||
| 125 | unsigned int sun4v_vdev_device_interrupt(unsigned int dev_node) | 88 | unsigned int sun4v_vdev_device_interrupt(struct device_node *dev_node) |
| 126 | { | 89 | { |
| 90 | struct property *prop; | ||
| 127 | unsigned int irq, reg; | 91 | unsigned int irq, reg; |
| 128 | int err, i; | 92 | int i; |
| 129 | 93 | ||
| 130 | err = prom_getproperty(dev_node, "interrupts", | 94 | prop = of_find_property(dev_node, "interrupts", NULL); |
| 131 | (char *) &irq, sizeof(irq)); | 95 | if (!prop) { |
| 132 | if (err <= 0) { | ||
| 133 | printk("VDEV: Cannot get \"interrupts\" " | 96 | printk("VDEV: Cannot get \"interrupts\" " |
| 134 | "property for OBP node %x\n", dev_node); | 97 | "property for OBP node %s\n", |
| 98 | dev_node->full_name); | ||
| 135 | return 0; | 99 | return 0; |
| 136 | } | 100 | } |
| 101 | irq = *(unsigned int *) prop->value; | ||
| 137 | 102 | ||
| 138 | err = prom_getproperty(dev_node, "reg", | 103 | prop = of_find_property(dev_node, "reg", NULL); |
| 139 | (char *) ®, sizeof(reg)); | 104 | if (!prop) { |
| 140 | if (err <= 0) { | ||
| 141 | printk("VDEV: Cannot get \"reg\" " | 105 | printk("VDEV: Cannot get \"reg\" " |
| 142 | "property for OBP node %x\n", dev_node); | 106 | "property for OBP node %s\n", |
| 107 | dev_node->full_name); | ||
| 143 | return 0; | 108 | return 0; |
| 144 | } | 109 | } |
| 110 | reg = *(unsigned int *) prop->value; | ||
| 145 | 111 | ||
| 146 | for (i = 0; i < vdev_num_intmap; i++) { | 112 | for (i = 0; i < vdev_num_intmap; i++) { |
| 147 | if (vdev_intmap[i].phys == (reg & vdev_intmask.phys) && | 113 | if (vdev_intmap[i].phys == (reg & vdev_intmask->phys) && |
| 148 | vdev_intmap[i].irq == (irq & vdev_intmask.interrupt)) { | 114 | vdev_intmap[i].irq == (irq & vdev_intmask->interrupt)) { |
| 149 | irq = vdev_intmap[i].cinterrupt; | 115 | irq = vdev_intmap[i].cinterrupt; |
| 150 | break; | 116 | break; |
| 151 | } | 117 | } |
| @@ -153,7 +119,7 @@ unsigned int sun4v_vdev_device_interrupt(unsigned int dev_node) | |||
| 153 | 119 | ||
| 154 | if (i == vdev_num_intmap) { | 120 | if (i == vdev_num_intmap) { |
| 155 | printk("VDEV: No matching interrupt map entry " | 121 | printk("VDEV: No matching interrupt map entry " |
| 156 | "for OBP node %x\n", dev_node); | 122 | "for OBP node %s\n", dev_node->full_name); |
| 157 | return 0; | 123 | return 0; |
| 158 | } | 124 | } |
| 159 | 125 | ||
| @@ -167,38 +133,44 @@ static const char *cpu_mid_prop(void) | |||
| 167 | return "portid"; | 133 | return "portid"; |
| 168 | } | 134 | } |
| 169 | 135 | ||
| 170 | static int get_cpu_mid(int prom_node) | 136 | static int get_cpu_mid(struct device_node *dp) |
| 171 | { | 137 | { |
| 138 | struct property *prop; | ||
| 139 | |||
| 172 | if (tlb_type == hypervisor) { | 140 | if (tlb_type == hypervisor) { |
| 173 | struct linux_prom64_registers reg; | 141 | struct linux_prom64_registers *reg; |
| 142 | int len; | ||
| 174 | 143 | ||
| 175 | if (prom_getproplen(prom_node, "cpuid") == 4) | 144 | prop = of_find_property(dp, "cpuid", &len); |
| 176 | return prom_getintdefault(prom_node, "cpuid", 0); | 145 | if (prop && len == 4) |
| 146 | return *(int *) prop->value; | ||
| 177 | 147 | ||
| 178 | prom_getproperty(prom_node, "reg", (char *) ®, sizeof(reg)); | 148 | prop = of_find_property(dp, "reg", NULL); |
| 179 | return (reg.phys_addr >> 32) & 0x0fffffffUL; | 149 | reg = prop->value; |
| 150 | return (reg[0].phys_addr >> 32) & 0x0fffffffUL; | ||
| 180 | } else { | 151 | } else { |
| 181 | const char *prop_name = cpu_mid_prop(); | 152 | const char *prop_name = cpu_mid_prop(); |
| 182 | 153 | ||
| 183 | return prom_getintdefault(prom_node, prop_name, 0); | 154 | prop = of_find_property(dp, prop_name, NULL); |
| 155 | if (prop) | ||
| 156 | return *(int *) prop->value; | ||
| 157 | return 0; | ||
| 184 | } | 158 | } |
| 185 | } | 159 | } |
| 186 | 160 | ||
| 187 | static int check_cpu_node(int nd, int *cur_inst, | 161 | static int check_cpu_node(struct device_node *dp, int *cur_inst, |
| 188 | int (*compare)(int, int, void *), void *compare_arg, | 162 | int (*compare)(struct device_node *, int, void *), |
| 189 | int *prom_node, int *mid) | 163 | void *compare_arg, |
| 164 | struct device_node **dev_node, int *mid) | ||
| 190 | { | 165 | { |
| 191 | char node_str[128]; | 166 | if (strcmp(dp->type, "cpu")) |
| 192 | |||
| 193 | prom_getstring(nd, "device_type", node_str, sizeof(node_str)); | ||
| 194 | if (strcmp(node_str, "cpu")) | ||
| 195 | return -ENODEV; | 167 | return -ENODEV; |
| 196 | 168 | ||
| 197 | if (!compare(nd, *cur_inst, compare_arg)) { | 169 | if (!compare(dp, *cur_inst, compare_arg)) { |
| 198 | if (prom_node) | 170 | if (dev_node) |
| 199 | *prom_node = nd; | 171 | *dev_node = dp; |
| 200 | if (mid) | 172 | if (mid) |
| 201 | *mid = get_cpu_mid(nd); | 173 | *mid = get_cpu_mid(dp); |
| 202 | return 0; | 174 | return 0; |
| 203 | } | 175 | } |
| 204 | 176 | ||
| @@ -207,25 +179,18 @@ static int check_cpu_node(int nd, int *cur_inst, | |||
| 207 | return -ENODEV; | 179 | return -ENODEV; |
| 208 | } | 180 | } |
| 209 | 181 | ||
| 210 | static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, | 182 | static int __cpu_find_by(int (*compare)(struct device_node *, int, void *), |
| 211 | int *prom_node, int *mid) | 183 | void *compare_arg, |
| 184 | struct device_node **dev_node, int *mid) | ||
| 212 | { | 185 | { |
| 213 | int nd, cur_inst, err; | 186 | struct device_node *dp; |
| 187 | int cur_inst; | ||
| 214 | 188 | ||
| 215 | nd = prom_root_node; | ||
| 216 | cur_inst = 0; | 189 | cur_inst = 0; |
| 217 | 190 | for_each_node_by_type(dp, "cpu") { | |
| 218 | err = check_cpu_node(nd, &cur_inst, | 191 | int err = check_cpu_node(dp, &cur_inst, |
| 219 | compare, compare_arg, | 192 | compare, compare_arg, |
| 220 | prom_node, mid); | 193 | dev_node, mid); |
| 221 | if (err == 0) | ||
| 222 | return 0; | ||
| 223 | |||
| 224 | nd = prom_getchild(nd); | ||
| 225 | while ((nd = prom_getsibling(nd)) != 0) { | ||
| 226 | err = check_cpu_node(nd, &cur_inst, | ||
| 227 | compare, compare_arg, | ||
| 228 | prom_node, mid); | ||
| 229 | if (err == 0) | 194 | if (err == 0) |
| 230 | return 0; | 195 | return 0; |
| 231 | } | 196 | } |
| @@ -233,7 +198,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, | |||
| 233 | return -ENODEV; | 198 | return -ENODEV; |
| 234 | } | 199 | } |
| 235 | 200 | ||
| 236 | static int cpu_instance_compare(int nd, int instance, void *_arg) | 201 | static int cpu_instance_compare(struct device_node *dp, int instance, void *_arg) |
| 237 | { | 202 | { |
| 238 | int desired_instance = (int) (long) _arg; | 203 | int desired_instance = (int) (long) _arg; |
| 239 | 204 | ||
| @@ -242,27 +207,27 @@ static int cpu_instance_compare(int nd, int instance, void *_arg) | |||
| 242 | return -ENODEV; | 207 | return -ENODEV; |
| 243 | } | 208 | } |
| 244 | 209 | ||
| 245 | int cpu_find_by_instance(int instance, int *prom_node, int *mid) | 210 | int cpu_find_by_instance(int instance, struct device_node **dev_node, int *mid) |
| 246 | { | 211 | { |
| 247 | return __cpu_find_by(cpu_instance_compare, (void *)(long)instance, | 212 | return __cpu_find_by(cpu_instance_compare, (void *)(long)instance, |
| 248 | prom_node, mid); | 213 | dev_node, mid); |
| 249 | } | 214 | } |
| 250 | 215 | ||
| 251 | static int cpu_mid_compare(int nd, int instance, void *_arg) | 216 | static int cpu_mid_compare(struct device_node *dp, int instance, void *_arg) |
| 252 | { | 217 | { |
| 253 | int desired_mid = (int) (long) _arg; | 218 | int desired_mid = (int) (long) _arg; |
| 254 | int this_mid; | 219 | int this_mid; |
| 255 | 220 | ||
| 256 | this_mid = get_cpu_mid(nd); | 221 | this_mid = get_cpu_mid(dp); |
| 257 | if (this_mid == desired_mid) | 222 | if (this_mid == desired_mid) |
| 258 | return 0; | 223 | return 0; |
| 259 | return -ENODEV; | 224 | return -ENODEV; |
| 260 | } | 225 | } |
| 261 | 226 | ||
| 262 | int cpu_find_by_mid(int mid, int *prom_node) | 227 | int cpu_find_by_mid(int mid, struct device_node **dev_node) |
| 263 | { | 228 | { |
| 264 | return __cpu_find_by(cpu_mid_compare, (void *)(long)mid, | 229 | return __cpu_find_by(cpu_mid_compare, (void *)(long)mid, |
| 265 | prom_node, NULL); | 230 | dev_node, NULL); |
| 266 | } | 231 | } |
| 267 | 232 | ||
| 268 | void __init device_scan(void) | 233 | void __init device_scan(void) |
| @@ -274,50 +239,47 @@ void __init device_scan(void) | |||
| 274 | 239 | ||
| 275 | #ifndef CONFIG_SMP | 240 | #ifndef CONFIG_SMP |
| 276 | { | 241 | { |
| 277 | int err, cpu_node, def; | 242 | struct device_node *dp; |
| 243 | int err, def; | ||
| 278 | 244 | ||
| 279 | err = cpu_find_by_instance(0, &cpu_node, NULL); | 245 | err = cpu_find_by_instance(0, &dp, NULL); |
| 280 | if (err) { | 246 | if (err) { |
| 281 | prom_printf("No cpu nodes, cannot continue\n"); | 247 | prom_printf("No cpu nodes, cannot continue\n"); |
| 282 | prom_halt(); | 248 | prom_halt(); |
| 283 | } | 249 | } |
| 284 | cpu_data(0).clock_tick = prom_getintdefault(cpu_node, | 250 | cpu_data(0).clock_tick = |
| 285 | "clock-frequency", | 251 | of_getintprop_default(dp, "clock-frequency", 0); |
| 286 | 0); | ||
| 287 | 252 | ||
| 288 | def = ((tlb_type == hypervisor) ? | 253 | def = ((tlb_type == hypervisor) ? |
| 289 | (8 * 1024) : | 254 | (8 * 1024) : |
| 290 | (16 * 1024)); | 255 | (16 * 1024)); |
| 291 | cpu_data(0).dcache_size = prom_getintdefault(cpu_node, | 256 | cpu_data(0).dcache_size = of_getintprop_default(dp, |
| 292 | "dcache-size", | 257 | "dcache-size", |
| 293 | def); | 258 | def); |
| 294 | 259 | ||
| 295 | def = 32; | 260 | def = 32; |
| 296 | cpu_data(0).dcache_line_size = | 261 | cpu_data(0).dcache_line_size = |
| 297 | prom_getintdefault(cpu_node, "dcache-line-size", | 262 | of_getintprop_default(dp, "dcache-line-size", def); |
| 298 | def); | ||
| 299 | 263 | ||
| 300 | def = 16 * 1024; | 264 | def = 16 * 1024; |
| 301 | cpu_data(0).icache_size = prom_getintdefault(cpu_node, | 265 | cpu_data(0).icache_size = of_getintprop_default(dp, |
| 302 | "icache-size", | 266 | "icache-size", |
| 303 | def); | 267 | def); |
| 304 | 268 | ||
| 305 | def = 32; | 269 | def = 32; |
| 306 | cpu_data(0).icache_line_size = | 270 | cpu_data(0).icache_line_size = |
| 307 | prom_getintdefault(cpu_node, "icache-line-size", | 271 | of_getintprop_default(dp, "icache-line-size", def); |
| 308 | def); | ||
| 309 | 272 | ||
| 310 | def = ((tlb_type == hypervisor) ? | 273 | def = ((tlb_type == hypervisor) ? |
| 311 | (3 * 1024 * 1024) : | 274 | (3 * 1024 * 1024) : |
| 312 | (4 * 1024 * 1024)); | 275 | (4 * 1024 * 1024)); |
| 313 | cpu_data(0).ecache_size = prom_getintdefault(cpu_node, | 276 | cpu_data(0).ecache_size = of_getintprop_default(dp, |
| 314 | "ecache-size", | 277 | "ecache-size", |
| 315 | def); | 278 | def); |
| 316 | 279 | ||
| 317 | def = 64; | 280 | def = 64; |
| 318 | cpu_data(0).ecache_line_size = | 281 | cpu_data(0).ecache_line_size = |
| 319 | prom_getintdefault(cpu_node, "ecache-line-size", | 282 | of_getintprop_default(dp, "ecache-line-size", def); |
| 320 | def); | ||
| 321 | printk("CPU[0]: Caches " | 283 | printk("CPU[0]: Caches " |
| 322 | "D[sz(%d):line_sz(%d)] " | 284 | "D[sz(%d):line_sz(%d)] " |
| 323 | "I[sz(%d):line_sz(%d)] " | 285 | "I[sz(%d):line_sz(%d)] " |
diff --git a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c index c69504aa638f..98e0a8cbeecd 100644 --- a/arch/sparc64/kernel/ebus.c +++ b/arch/sparc64/kernel/ebus.c | |||
| @@ -269,10 +269,6 @@ EXPORT_SYMBOL(ebus_dma_enable); | |||
| 269 | 269 | ||
| 270 | struct linux_ebus *ebus_chain = NULL; | 270 | struct linux_ebus *ebus_chain = NULL; |
| 271 | 271 | ||
| 272 | #ifdef CONFIG_SUN_AUXIO | ||
| 273 | extern void auxio_probe(void); | ||
| 274 | #endif | ||
| 275 | |||
| 276 | static inline void *ebus_alloc(size_t size) | 272 | static inline void *ebus_alloc(size_t size) |
| 277 | { | 273 | { |
| 278 | void *mem; | 274 | void *mem; |
| @@ -283,77 +279,55 @@ static inline void *ebus_alloc(size_t size) | |||
| 283 | return mem; | 279 | return mem; |
| 284 | } | 280 | } |
| 285 | 281 | ||
| 286 | static void __init ebus_ranges_init(struct linux_ebus *ebus) | ||
| 287 | { | ||
| 288 | int success; | ||
| 289 | |||
| 290 | ebus->num_ebus_ranges = 0; | ||
| 291 | success = prom_getproperty(ebus->prom_node, "ranges", | ||
| 292 | (char *)ebus->ebus_ranges, | ||
| 293 | sizeof(ebus->ebus_ranges)); | ||
| 294 | if (success != -1) | ||
| 295 | ebus->num_ebus_ranges = (success/sizeof(struct linux_prom_ebus_ranges)); | ||
| 296 | } | ||
| 297 | |||
| 298 | static void __init ebus_intmap_init(struct linux_ebus *ebus) | ||
| 299 | { | ||
| 300 | int success; | ||
| 301 | |||
| 302 | ebus->num_ebus_intmap = 0; | ||
| 303 | success = prom_getproperty(ebus->prom_node, "interrupt-map", | ||
| 304 | (char *)ebus->ebus_intmap, | ||
| 305 | sizeof(ebus->ebus_intmap)); | ||
| 306 | if (success == -1) | ||
| 307 | return; | ||
| 308 | |||
| 309 | ebus->num_ebus_intmap = (success/sizeof(struct linux_prom_ebus_intmap)); | ||
| 310 | |||
| 311 | success = prom_getproperty(ebus->prom_node, "interrupt-map-mask", | ||
| 312 | (char *)&ebus->ebus_intmask, | ||
| 313 | sizeof(ebus->ebus_intmask)); | ||
| 314 | if (success == -1) { | ||
| 315 | prom_printf("%s: can't get interrupt-map-mask\n", __FUNCTION__); | ||
| 316 | prom_halt(); | ||
| 317 | } | ||
| 318 | } | ||
| 319 | |||
| 320 | int __init ebus_intmap_match(struct linux_ebus *ebus, | 282 | int __init ebus_intmap_match(struct linux_ebus *ebus, |
| 321 | struct linux_prom_registers *reg, | 283 | struct linux_prom_registers *reg, |
| 322 | int *interrupt) | 284 | int *interrupt) |
| 323 | { | 285 | { |
| 286 | struct linux_prom_ebus_intmap *imap; | ||
| 287 | struct linux_prom_ebus_intmask *imask; | ||
| 324 | unsigned int hi, lo, irq; | 288 | unsigned int hi, lo, irq; |
| 325 | int i; | 289 | int i, len, n_imap; |
| 290 | |||
| 291 | imap = of_get_property(ebus->prom_node, "interrupt-map", &len); | ||
| 292 | if (!imap) | ||
| 293 | return 0; | ||
| 294 | n_imap = len / sizeof(imap[0]); | ||
| 326 | 295 | ||
| 327 | if (!ebus->num_ebus_intmap) | 296 | imask = of_get_property(ebus->prom_node, "interrupt-map-mask", NULL); |
| 297 | if (!imask) | ||
| 328 | return 0; | 298 | return 0; |
| 329 | 299 | ||
| 330 | hi = reg->which_io & ebus->ebus_intmask.phys_hi; | 300 | hi = reg->which_io & imask->phys_hi; |
| 331 | lo = reg->phys_addr & ebus->ebus_intmask.phys_lo; | 301 | lo = reg->phys_addr & imask->phys_lo; |
| 332 | irq = *interrupt & ebus->ebus_intmask.interrupt; | 302 | irq = *interrupt & imask->interrupt; |
| 333 | for (i = 0; i < ebus->num_ebus_intmap; i++) { | 303 | for (i = 0; i < n_imap; i++) { |
| 334 | if ((ebus->ebus_intmap[i].phys_hi == hi) && | 304 | if ((imap[i].phys_hi == hi) && |
| 335 | (ebus->ebus_intmap[i].phys_lo == lo) && | 305 | (imap[i].phys_lo == lo) && |
| 336 | (ebus->ebus_intmap[i].interrupt == irq)) { | 306 | (imap[i].interrupt == irq)) { |
| 337 | *interrupt = ebus->ebus_intmap[i].cinterrupt; | 307 | *interrupt = imap[i].cinterrupt; |
| 338 | return 0; | 308 | return 0; |
| 339 | } | 309 | } |
| 340 | } | 310 | } |
| 341 | return -1; | 311 | return -1; |
| 342 | } | 312 | } |
| 343 | 313 | ||
| 344 | void __init fill_ebus_child(int node, struct linux_prom_registers *preg, | 314 | void __init fill_ebus_child(struct device_node *dp, |
| 345 | struct linux_ebus_child *dev, int non_standard_regs) | 315 | struct linux_prom_registers *preg, |
| 316 | struct linux_ebus_child *dev, | ||
| 317 | int non_standard_regs) | ||
| 346 | { | 318 | { |
| 347 | int regs[PROMREG_MAX]; | 319 | int *regs; |
| 348 | int irqs[PROMREG_MAX]; | 320 | int *irqs; |
| 349 | int i, len; | 321 | int i, len; |
| 350 | 322 | ||
| 351 | dev->prom_node = node; | 323 | dev->prom_node = dp; |
| 352 | prom_getstring(node, "name", dev->prom_name, sizeof(dev->prom_name)); | 324 | printk(" (%s)", dp->name); |
| 353 | printk(" (%s)", dev->prom_name); | ||
| 354 | 325 | ||
| 355 | len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs)); | 326 | regs = of_get_property(dp, "reg", &len); |
| 356 | dev->num_addrs = len / sizeof(regs[0]); | 327 | if (!regs) |
| 328 | dev->num_addrs = 0; | ||
| 329 | else | ||
| 330 | dev->num_addrs = len / sizeof(regs[0]); | ||
| 357 | 331 | ||
| 358 | if (non_standard_regs) { | 332 | if (non_standard_regs) { |
| 359 | /* This is to handle reg properties which are not | 333 | /* This is to handle reg properties which are not |
| @@ -370,21 +344,21 @@ void __init fill_ebus_child(int node, struct linux_prom_registers *preg, | |||
| 370 | int rnum = regs[i]; | 344 | int rnum = regs[i]; |
| 371 | if (rnum >= dev->parent->num_addrs) { | 345 | if (rnum >= dev->parent->num_addrs) { |
| 372 | prom_printf("UGH: property for %s was %d, need < %d\n", | 346 | prom_printf("UGH: property for %s was %d, need < %d\n", |
| 373 | dev->prom_name, len, dev->parent->num_addrs); | 347 | dp->name, len, dev->parent->num_addrs); |
| 374 | panic(__FUNCTION__); | 348 | prom_halt(); |
| 375 | } | 349 | } |
| 376 | dev->resource[i].start = dev->parent->resource[i].start; | 350 | dev->resource[i].start = dev->parent->resource[i].start; |
| 377 | dev->resource[i].end = dev->parent->resource[i].end; | 351 | dev->resource[i].end = dev->parent->resource[i].end; |
| 378 | dev->resource[i].flags = IORESOURCE_MEM; | 352 | dev->resource[i].flags = IORESOURCE_MEM; |
| 379 | dev->resource[i].name = dev->prom_name; | 353 | dev->resource[i].name = dp->name; |
| 380 | } | 354 | } |
| 381 | } | 355 | } |
| 382 | 356 | ||
| 383 | for (i = 0; i < PROMINTR_MAX; i++) | 357 | for (i = 0; i < PROMINTR_MAX; i++) |
| 384 | dev->irqs[i] = PCI_IRQ_NONE; | 358 | dev->irqs[i] = PCI_IRQ_NONE; |
| 385 | 359 | ||
| 386 | len = prom_getproperty(node, "interrupts", (char *)&irqs, sizeof(irqs)); | 360 | irqs = of_get_property(dp, "interrupts", &len); |
| 387 | if ((len == -1) || (len == 0)) { | 361 | if (!irqs) { |
| 388 | dev->num_irqs = 0; | 362 | dev->num_irqs = 0; |
| 389 | /* | 363 | /* |
| 390 | * Oh, well, some PROMs don't export interrupts | 364 | * Oh, well, some PROMs don't export interrupts |
| @@ -392,8 +366,8 @@ void __init fill_ebus_child(int node, struct linux_prom_registers *preg, | |||
| 392 | * | 366 | * |
| 393 | * Be smart about PS/2 keyboard and mouse. | 367 | * Be smart about PS/2 keyboard and mouse. |
| 394 | */ | 368 | */ |
| 395 | if (!strcmp(dev->parent->prom_name, "8042")) { | 369 | if (!strcmp(dev->parent->prom_node->name, "8042")) { |
| 396 | if (!strcmp(dev->prom_name, "kb_ps2")) { | 370 | if (!strcmp(dev->prom_node->name, "kb_ps2")) { |
| 397 | dev->num_irqs = 1; | 371 | dev->num_irqs = 1; |
| 398 | dev->irqs[0] = dev->parent->irqs[0]; | 372 | dev->irqs[0] = dev->parent->irqs[0]; |
| 399 | } else { | 373 | } else { |
| @@ -423,32 +397,32 @@ void __init fill_ebus_child(int node, struct linux_prom_registers *preg, | |||
| 423 | 397 | ||
| 424 | static int __init child_regs_nonstandard(struct linux_ebus_device *dev) | 398 | static int __init child_regs_nonstandard(struct linux_ebus_device *dev) |
| 425 | { | 399 | { |
| 426 | if (!strcmp(dev->prom_name, "i2c") || | 400 | if (!strcmp(dev->prom_node->name, "i2c") || |
| 427 | !strcmp(dev->prom_name, "SUNW,lombus")) | 401 | !strcmp(dev->prom_node->name, "SUNW,lombus")) |
| 428 | return 1; | 402 | return 1; |
| 429 | return 0; | 403 | return 0; |
| 430 | } | 404 | } |
| 431 | 405 | ||
| 432 | void __init fill_ebus_device(int node, struct linux_ebus_device *dev) | 406 | void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *dev) |
| 433 | { | 407 | { |
| 434 | struct linux_prom_registers regs[PROMREG_MAX]; | 408 | struct linux_prom_registers *regs; |
| 435 | struct linux_ebus_child *child; | 409 | struct linux_ebus_child *child; |
| 436 | int irqs[PROMINTR_MAX]; | 410 | int *irqs; |
| 437 | int i, n, len; | 411 | int i, n, len; |
| 438 | 412 | ||
| 439 | dev->prom_node = node; | 413 | dev->prom_node = dp; |
| 440 | prom_getstring(node, "name", dev->prom_name, sizeof(dev->prom_name)); | 414 | |
| 441 | printk(" [%s", dev->prom_name); | 415 | printk(" [%s", dp->name); |
| 442 | 416 | ||
| 443 | len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs)); | 417 | regs = of_get_property(dp, "reg", &len); |
| 444 | if (len == -1) { | 418 | if (!regs) { |
| 445 | dev->num_addrs = 0; | 419 | dev->num_addrs = 0; |
| 446 | goto probe_interrupts; | 420 | goto probe_interrupts; |
| 447 | } | 421 | } |
| 448 | 422 | ||
| 449 | if (len % sizeof(struct linux_prom_registers)) { | 423 | if (len % sizeof(struct linux_prom_registers)) { |
| 450 | prom_printf("UGH: proplen for %s was %d, need multiple of %d\n", | 424 | prom_printf("UGH: proplen for %s was %d, need multiple of %d\n", |
| 451 | dev->prom_name, len, | 425 | dev->prom_node->name, len, |
| 452 | (int)sizeof(struct linux_prom_registers)); | 426 | (int)sizeof(struct linux_prom_registers)); |
| 453 | prom_halt(); | 427 | prom_halt(); |
| 454 | } | 428 | } |
| @@ -466,7 +440,7 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev) | |||
| 466 | dev->resource[i].end = | 440 | dev->resource[i].end = |
| 467 | (dev->resource[i].start + (unsigned long)regs[i].reg_size - 1UL); | 441 | (dev->resource[i].start + (unsigned long)regs[i].reg_size - 1UL); |
| 468 | dev->resource[i].flags = IORESOURCE_MEM; | 442 | dev->resource[i].flags = IORESOURCE_MEM; |
| 469 | dev->resource[i].name = dev->prom_name; | 443 | dev->resource[i].name = dev->prom_node->name; |
| 470 | request_resource(&dev->bus->self->resource[n], | 444 | request_resource(&dev->bus->self->resource[n], |
| 471 | &dev->resource[i]); | 445 | &dev->resource[i]); |
| 472 | } | 446 | } |
| @@ -475,8 +449,8 @@ probe_interrupts: | |||
| 475 | for (i = 0; i < PROMINTR_MAX; i++) | 449 | for (i = 0; i < PROMINTR_MAX; i++) |
| 476 | dev->irqs[i] = PCI_IRQ_NONE; | 450 | dev->irqs[i] = PCI_IRQ_NONE; |
| 477 | 451 | ||
| 478 | len = prom_getproperty(node, "interrupts", (char *)&irqs, sizeof(irqs)); | 452 | irqs = of_get_property(dp, "interrupts", &len); |
| 479 | if ((len == -1) || (len == 0)) { | 453 | if (!irqs) { |
| 480 | dev->num_irqs = 0; | 454 | dev->num_irqs = 0; |
| 481 | } else { | 455 | } else { |
| 482 | dev->num_irqs = len / sizeof(irqs[0]); | 456 | dev->num_irqs = len / sizeof(irqs[0]); |
| @@ -497,7 +471,18 @@ probe_interrupts: | |||
| 497 | } | 471 | } |
| 498 | } | 472 | } |
| 499 | 473 | ||
| 500 | if ((node = prom_getchild(node))) { | 474 | dev->ofdev.node = dp; |
| 475 | dev->ofdev.dev.parent = &dev->bus->ofdev.dev; | ||
| 476 | dev->ofdev.dev.bus = &ebus_bus_type; | ||
| 477 | strcpy(dev->ofdev.dev.bus_id, dp->path_component_name); | ||
| 478 | |||
| 479 | /* Register with core */ | ||
| 480 | if (of_device_register(&dev->ofdev) != 0) | ||
| 481 | printk(KERN_DEBUG "ebus: device registration error for %s!\n", | ||
| 482 | dev->ofdev.dev.bus_id); | ||
| 483 | |||
| 484 | dp = dp->child; | ||
| 485 | if (dp) { | ||
| 501 | printk(" ->"); | 486 | printk(" ->"); |
| 502 | dev->children = ebus_alloc(sizeof(struct linux_ebus_child)); | 487 | dev->children = ebus_alloc(sizeof(struct linux_ebus_child)); |
| 503 | 488 | ||
| @@ -505,18 +490,18 @@ probe_interrupts: | |||
| 505 | child->next = NULL; | 490 | child->next = NULL; |
| 506 | child->parent = dev; | 491 | child->parent = dev; |
| 507 | child->bus = dev->bus; | 492 | child->bus = dev->bus; |
| 508 | fill_ebus_child(node, ®s[0], | 493 | fill_ebus_child(dp, regs, child, |
| 509 | child, child_regs_nonstandard(dev)); | 494 | child_regs_nonstandard(dev)); |
| 510 | 495 | ||
| 511 | while ((node = prom_getsibling(node)) != 0) { | 496 | while ((dp = dp->sibling) != NULL) { |
| 512 | child->next = ebus_alloc(sizeof(struct linux_ebus_child)); | 497 | child->next = ebus_alloc(sizeof(struct linux_ebus_child)); |
| 513 | 498 | ||
| 514 | child = child->next; | 499 | child = child->next; |
| 515 | child->next = NULL; | 500 | child->next = NULL; |
| 516 | child->parent = dev; | 501 | child->parent = dev; |
| 517 | child->bus = dev->bus; | 502 | child->bus = dev->bus; |
| 518 | fill_ebus_child(node, ®s[0], | 503 | fill_ebus_child(dp, regs, child, |
| 519 | child, child_regs_nonstandard(dev)); | 504 | child_regs_nonstandard(dev)); |
| 520 | } | 505 | } |
| 521 | } | 506 | } |
| 522 | printk("]"); | 507 | printk("]"); |
| @@ -543,7 +528,8 @@ void __init ebus_init(void) | |||
| 543 | struct linux_ebus *ebus; | 528 | struct linux_ebus *ebus; |
| 544 | struct pci_dev *pdev; | 529 | struct pci_dev *pdev; |
| 545 | struct pcidev_cookie *cookie; | 530 | struct pcidev_cookie *cookie; |
| 546 | int nd, ebusnd, is_rio; | 531 | struct device_node *dp; |
| 532 | int is_rio; | ||
| 547 | int num_ebus = 0; | 533 | int num_ebus = 0; |
| 548 | 534 | ||
| 549 | pdev = find_next_ebus(NULL, &is_rio); | 535 | pdev = find_next_ebus(NULL, &is_rio); |
| @@ -553,20 +539,22 @@ void __init ebus_init(void) | |||
| 553 | } | 539 | } |
| 554 | 540 | ||
| 555 | cookie = pdev->sysdata; | 541 | cookie = pdev->sysdata; |
| 556 | ebusnd = cookie->prom_node; | 542 | dp = cookie->prom_node; |
| 557 | 543 | ||
| 558 | ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus)); | 544 | ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus)); |
| 559 | ebus->next = NULL; | 545 | ebus->next = NULL; |
| 560 | ebus->is_rio = is_rio; | 546 | ebus->is_rio = is_rio; |
| 561 | 547 | ||
| 562 | while (ebusnd) { | 548 | while (dp) { |
| 549 | struct device_node *child; | ||
| 550 | |||
| 563 | /* SUNW,pci-qfe uses four empty ebuses on it. | 551 | /* SUNW,pci-qfe uses four empty ebuses on it. |
| 564 | I think we should not consider them here, | 552 | I think we should not consider them here, |
| 565 | as they have half of the properties this | 553 | as they have half of the properties this |
| 566 | code expects and once we do PCI hot-plug, | 554 | code expects and once we do PCI hot-plug, |
| 567 | we'd have to tweak with the ebus_chain | 555 | we'd have to tweak with the ebus_chain |
| 568 | in the runtime after initialization. -jj */ | 556 | in the runtime after initialization. -jj */ |
| 569 | if (!prom_getchild (ebusnd)) { | 557 | if (!dp->child) { |
| 570 | pdev = find_next_ebus(pdev, &is_rio); | 558 | pdev = find_next_ebus(pdev, &is_rio); |
| 571 | if (!pdev) { | 559 | if (!pdev) { |
| 572 | if (ebus == ebus_chain) { | 560 | if (ebus == ebus_chain) { |
| @@ -578,22 +566,29 @@ void __init ebus_init(void) | |||
| 578 | } | 566 | } |
| 579 | ebus->is_rio = is_rio; | 567 | ebus->is_rio = is_rio; |
| 580 | cookie = pdev->sysdata; | 568 | cookie = pdev->sysdata; |
| 581 | ebusnd = cookie->prom_node; | 569 | dp = cookie->prom_node; |
| 582 | continue; | 570 | continue; |
| 583 | } | 571 | } |
| 584 | printk("ebus%d:", num_ebus); | 572 | printk("ebus%d:", num_ebus); |
| 585 | 573 | ||
| 586 | prom_getstring(ebusnd, "name", ebus->prom_name, sizeof(ebus->prom_name)); | ||
| 587 | ebus->index = num_ebus; | 574 | ebus->index = num_ebus; |
| 588 | ebus->prom_node = ebusnd; | 575 | ebus->prom_node = dp; |
| 589 | ebus->self = pdev; | 576 | ebus->self = pdev; |
| 590 | ebus->parent = pbm = cookie->pbm; | 577 | ebus->parent = pbm = cookie->pbm; |
| 591 | 578 | ||
| 592 | ebus_ranges_init(ebus); | 579 | ebus->ofdev.node = dp; |
| 593 | ebus_intmap_init(ebus); | 580 | ebus->ofdev.dev.parent = &pdev->dev; |
| 581 | ebus->ofdev.dev.bus = &ebus_bus_type; | ||
| 582 | strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name); | ||
| 594 | 583 | ||
| 595 | nd = prom_getchild(ebusnd); | 584 | /* Register with core */ |
| 596 | if (!nd) | 585 | if (of_device_register(&ebus->ofdev) != 0) |
| 586 | printk(KERN_DEBUG "ebus: device registration error for %s!\n", | ||
| 587 | ebus->ofdev.dev.bus_id); | ||
| 588 | |||
| 589 | |||
| 590 | child = dp->child; | ||
| 591 | if (!child) | ||
| 597 | goto next_ebus; | 592 | goto next_ebus; |
| 598 | 593 | ||
| 599 | ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device)); | 594 | ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device)); |
| @@ -602,16 +597,16 @@ void __init ebus_init(void) | |||
| 602 | dev->next = NULL; | 597 | dev->next = NULL; |
| 603 | dev->children = NULL; | 598 | dev->children = NULL; |
| 604 | dev->bus = ebus; | 599 | dev->bus = ebus; |
| 605 | fill_ebus_device(nd, dev); | 600 | fill_ebus_device(child, dev); |
| 606 | 601 | ||
| 607 | while ((nd = prom_getsibling(nd)) != 0) { | 602 | while ((child = child->sibling) != NULL) { |
| 608 | dev->next = ebus_alloc(sizeof(struct linux_ebus_device)); | 603 | dev->next = ebus_alloc(sizeof(struct linux_ebus_device)); |
| 609 | 604 | ||
| 610 | dev = dev->next; | 605 | dev = dev->next; |
| 611 | dev->next = NULL; | 606 | dev->next = NULL; |
| 612 | dev->children = NULL; | 607 | dev->children = NULL; |
| 613 | dev->bus = ebus; | 608 | dev->bus = ebus; |
| 614 | fill_ebus_device(nd, dev); | 609 | fill_ebus_device(child, dev); |
| 615 | } | 610 | } |
| 616 | 611 | ||
| 617 | next_ebus: | 612 | next_ebus: |
| @@ -622,7 +617,7 @@ void __init ebus_init(void) | |||
| 622 | break; | 617 | break; |
| 623 | 618 | ||
| 624 | cookie = pdev->sysdata; | 619 | cookie = pdev->sysdata; |
| 625 | ebusnd = cookie->prom_node; | 620 | dp = cookie->prom_node; |
| 626 | 621 | ||
| 627 | ebus->next = ebus_alloc(sizeof(struct linux_ebus)); | 622 | ebus->next = ebus_alloc(sizeof(struct linux_ebus)); |
| 628 | ebus = ebus->next; | 623 | ebus = ebus->next; |
| @@ -631,8 +626,4 @@ void __init ebus_init(void) | |||
| 631 | ++num_ebus; | 626 | ++num_ebus; |
| 632 | } | 627 | } |
| 633 | pci_dev_put(pdev); /* XXX for the case, when ebusnd is 0, is it OK? */ | 628 | pci_dev_put(pdev); /* XXX for the case, when ebusnd is 0, is it OK? */ |
| 634 | |||
| 635 | #ifdef CONFIG_SUN_AUXIO | ||
| 636 | auxio_probe(); | ||
| 637 | #endif | ||
| 638 | } | 629 | } |
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c index a8c9dc8d1958..31e0fbb0d82c 100644 --- a/arch/sparc64/kernel/irq.c +++ b/arch/sparc64/kernel/irq.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | #include <asm/iommu.h> | 34 | #include <asm/iommu.h> |
| 35 | #include <asm/upa.h> | 35 | #include <asm/upa.h> |
| 36 | #include <asm/oplib.h> | 36 | #include <asm/oplib.h> |
| 37 | #include <asm/prom.h> | ||
| 37 | #include <asm/timer.h> | 38 | #include <asm/timer.h> |
| 38 | #include <asm/smp.h> | 39 | #include <asm/smp.h> |
| 39 | #include <asm/starfire.h> | 40 | #include <asm/starfire.h> |
| @@ -635,23 +636,29 @@ static u64 prom_limit0, prom_limit1; | |||
| 635 | 636 | ||
| 636 | static void map_prom_timers(void) | 637 | static void map_prom_timers(void) |
| 637 | { | 638 | { |
| 638 | unsigned int addr[3]; | 639 | struct device_node *dp; |
| 639 | int tnode, err; | 640 | unsigned int *addr; |
| 640 | 641 | ||
| 641 | /* PROM timer node hangs out in the top level of device siblings... */ | 642 | /* PROM timer node hangs out in the top level of device siblings... */ |
| 642 | tnode = prom_finddevice("/counter-timer"); | 643 | dp = of_find_node_by_path("/"); |
| 644 | dp = dp->child; | ||
| 645 | while (dp) { | ||
| 646 | if (!strcmp(dp->name, "counter-timer")) | ||
| 647 | break; | ||
| 648 | dp = dp->sibling; | ||
| 649 | } | ||
| 643 | 650 | ||
| 644 | /* Assume if node is not present, PROM uses different tick mechanism | 651 | /* Assume if node is not present, PROM uses different tick mechanism |
| 645 | * which we should not care about. | 652 | * which we should not care about. |
| 646 | */ | 653 | */ |
| 647 | if (tnode == 0 || tnode == -1) { | 654 | if (!dp) { |
| 648 | prom_timers = (struct sun5_timer *) 0; | 655 | prom_timers = (struct sun5_timer *) 0; |
| 649 | return; | 656 | return; |
| 650 | } | 657 | } |
| 651 | 658 | ||
| 652 | /* If PROM is really using this, it must be mapped by him. */ | 659 | /* If PROM is really using this, it must be mapped by him. */ |
| 653 | err = prom_getproperty(tnode, "address", (char *)addr, sizeof(addr)); | 660 | addr = of_get_property(dp, "address", NULL); |
| 654 | if (err == -1) { | 661 | if (!addr) { |
| 655 | prom_printf("PROM does not have timer mapped, trying to continue.\n"); | 662 | prom_printf("PROM does not have timer mapped, trying to continue.\n"); |
| 656 | prom_timers = (struct sun5_timer *) 0; | 663 | prom_timers = (struct sun5_timer *) 0; |
| 657 | return; | 664 | return; |
diff --git a/arch/sparc64/kernel/isa.c b/arch/sparc64/kernel/isa.c index 30862abee611..6f16dee280a8 100644 --- a/arch/sparc64/kernel/isa.c +++ b/arch/sparc64/kernel/isa.c | |||
| @@ -15,23 +15,19 @@ static void __init fatal_err(const char *reason) | |||
| 15 | static void __init report_dev(struct sparc_isa_device *isa_dev, int child) | 15 | static void __init report_dev(struct sparc_isa_device *isa_dev, int child) |
| 16 | { | 16 | { |
| 17 | if (child) | 17 | if (child) |
| 18 | printk(" (%s)", isa_dev->prom_name); | 18 | printk(" (%s)", isa_dev->prom_node->name); |
| 19 | else | 19 | else |
| 20 | printk(" [%s", isa_dev->prom_name); | 20 | printk(" [%s", isa_dev->prom_node->name); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | static void __init isa_dev_get_resource(struct sparc_isa_device *isa_dev, | 23 | static struct linux_prom_registers * __init |
| 24 | struct linux_prom_registers *pregs, | 24 | isa_dev_get_resource(struct sparc_isa_device *isa_dev) |
| 25 | int pregs_size) | ||
| 26 | { | 25 | { |
| 26 | struct linux_prom_registers *pregs; | ||
| 27 | unsigned long base, len; | 27 | unsigned long base, len; |
| 28 | int prop_len; | 28 | int prop_len; |
| 29 | 29 | ||
| 30 | prop_len = prom_getproperty(isa_dev->prom_node, "reg", | 30 | pregs = of_get_property(isa_dev->prom_node, "reg", &prop_len); |
| 31 | (char *) pregs, pregs_size); | ||
| 32 | |||
| 33 | if (prop_len <= 0) | ||
| 34 | return; | ||
| 35 | 31 | ||
| 36 | /* Only the first one is interesting. */ | 32 | /* Only the first one is interesting. */ |
| 37 | len = pregs[0].reg_size; | 33 | len = pregs[0].reg_size; |
| @@ -42,10 +38,12 @@ static void __init isa_dev_get_resource(struct sparc_isa_device *isa_dev, | |||
| 42 | isa_dev->resource.start = base; | 38 | isa_dev->resource.start = base; |
| 43 | isa_dev->resource.end = (base + len - 1UL); | 39 | isa_dev->resource.end = (base + len - 1UL); |
| 44 | isa_dev->resource.flags = IORESOURCE_IO; | 40 | isa_dev->resource.flags = IORESOURCE_IO; |
| 45 | isa_dev->resource.name = isa_dev->prom_name; | 41 | isa_dev->resource.name = isa_dev->prom_node->name; |
| 46 | 42 | ||
| 47 | request_resource(&isa_dev->bus->parent->io_space, | 43 | request_resource(&isa_dev->bus->parent->io_space, |
| 48 | &isa_dev->resource); | 44 | &isa_dev->resource); |
| 45 | |||
| 46 | return pregs; | ||
| 49 | } | 47 | } |
| 50 | 48 | ||
| 51 | /* I can't believe they didn't put a real INO in the isa device | 49 | /* I can't believe they didn't put a real INO in the isa device |
| @@ -74,19 +72,30 @@ static struct { | |||
| 74 | static int __init isa_dev_get_irq_using_imap(struct sparc_isa_device *isa_dev, | 72 | static int __init isa_dev_get_irq_using_imap(struct sparc_isa_device *isa_dev, |
| 75 | struct sparc_isa_bridge *isa_br, | 73 | struct sparc_isa_bridge *isa_br, |
| 76 | int *interrupt, | 74 | int *interrupt, |
| 77 | struct linux_prom_registers *pregs) | 75 | struct linux_prom_registers *reg) |
| 78 | { | 76 | { |
| 77 | struct linux_prom_ebus_intmap *imap; | ||
| 78 | struct linux_prom_ebus_intmap *imask; | ||
| 79 | unsigned int hi, lo, irq; | 79 | unsigned int hi, lo, irq; |
| 80 | int i; | 80 | int i, len, n_imap; |
| 81 | 81 | ||
| 82 | hi = pregs->which_io & isa_br->isa_intmask.phys_hi; | 82 | imap = of_get_property(isa_br->prom_node, "interrupt-map", &len); |
| 83 | lo = pregs->phys_addr & isa_br->isa_intmask.phys_lo; | 83 | if (!imap) |
| 84 | irq = *interrupt & isa_br->isa_intmask.interrupt; | 84 | return 0; |
| 85 | for (i = 0; i < isa_br->num_isa_intmap; i++) { | 85 | n_imap = len / sizeof(imap[0]); |
| 86 | if ((isa_br->isa_intmap[i].phys_hi == hi) && | 86 | |
| 87 | (isa_br->isa_intmap[i].phys_lo == lo) && | 87 | imask = of_get_property(isa_br->prom_node, "interrupt-map-mask", NULL); |
| 88 | (isa_br->isa_intmap[i].interrupt == irq)) { | 88 | if (!imask) |
| 89 | *interrupt = isa_br->isa_intmap[i].cinterrupt; | 89 | return 0; |
| 90 | |||
| 91 | hi = reg->which_io & imask->phys_hi; | ||
| 92 | lo = reg->phys_addr & imask->phys_lo; | ||
| 93 | irq = *interrupt & imask->interrupt; | ||
| 94 | for (i = 0; i < n_imap; i++) { | ||
| 95 | if ((imap[i].phys_hi == hi) && | ||
| 96 | (imap[i].phys_lo == lo) && | ||
| 97 | (imap[i].interrupt == irq)) { | ||
| 98 | *interrupt = imap[i].cinterrupt; | ||
| 90 | return 0; | 99 | return 0; |
| 91 | } | 100 | } |
| 92 | } | 101 | } |
| @@ -98,8 +107,8 @@ static void __init isa_dev_get_irq(struct sparc_isa_device *isa_dev, | |||
| 98 | { | 107 | { |
| 99 | int irq_prop; | 108 | int irq_prop; |
| 100 | 109 | ||
| 101 | irq_prop = prom_getintdefault(isa_dev->prom_node, | 110 | irq_prop = of_getintprop_default(isa_dev->prom_node, |
| 102 | "interrupts", -1); | 111 | "interrupts", -1); |
| 103 | if (irq_prop <= 0) { | 112 | if (irq_prop <= 0) { |
| 104 | goto no_irq; | 113 | goto no_irq; |
| 105 | } else { | 114 | } else { |
| @@ -107,7 +116,8 @@ static void __init isa_dev_get_irq(struct sparc_isa_device *isa_dev, | |||
| 107 | struct pci_pbm_info *pbm; | 116 | struct pci_pbm_info *pbm; |
| 108 | int i; | 117 | int i; |
| 109 | 118 | ||
| 110 | if (isa_dev->bus->num_isa_intmap) { | 119 | if (of_find_property(isa_dev->bus->prom_node, |
| 120 | "interrupt-map", NULL)) { | ||
| 111 | if (!isa_dev_get_irq_using_imap(isa_dev, | 121 | if (!isa_dev_get_irq_using_imap(isa_dev, |
| 112 | isa_dev->bus, | 122 | isa_dev->bus, |
| 113 | &irq_prop, | 123 | &irq_prop, |
| @@ -141,16 +151,15 @@ no_irq: | |||
| 141 | 151 | ||
| 142 | static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev) | 152 | static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev) |
| 143 | { | 153 | { |
| 144 | int node = prom_getchild(parent_isa_dev->prom_node); | 154 | struct device_node *dp = parent_isa_dev->prom_node->child; |
| 145 | 155 | ||
| 146 | if (node == 0) | 156 | if (!dp) |
| 147 | return; | 157 | return; |
| 148 | 158 | ||
| 149 | printk(" ->"); | 159 | printk(" ->"); |
| 150 | while (node != 0) { | 160 | while (dp) { |
| 151 | struct linux_prom_registers regs[PROMREG_MAX]; | 161 | struct linux_prom_registers *regs; |
| 152 | struct sparc_isa_device *isa_dev; | 162 | struct sparc_isa_device *isa_dev; |
| 153 | int prop_len; | ||
| 154 | 163 | ||
| 155 | isa_dev = kmalloc(sizeof(*isa_dev), GFP_KERNEL); | 164 | isa_dev = kmalloc(sizeof(*isa_dev), GFP_KERNEL); |
| 156 | if (!isa_dev) { | 165 | if (!isa_dev) { |
| @@ -165,49 +174,46 @@ static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev) | |||
| 165 | parent_isa_dev->child = isa_dev; | 174 | parent_isa_dev->child = isa_dev; |
| 166 | 175 | ||
| 167 | isa_dev->bus = parent_isa_dev->bus; | 176 | isa_dev->bus = parent_isa_dev->bus; |
| 168 | isa_dev->prom_node = node; | 177 | isa_dev->prom_node = dp; |
| 169 | prop_len = prom_getproperty(node, "name", | ||
| 170 | (char *) isa_dev->prom_name, | ||
| 171 | sizeof(isa_dev->prom_name)); | ||
| 172 | if (prop_len <= 0) { | ||
| 173 | fatal_err("cannot get child isa_dev OBP node name"); | ||
| 174 | prom_halt(); | ||
| 175 | } | ||
| 176 | 178 | ||
| 177 | prop_len = prom_getproperty(node, "compatible", | 179 | regs = isa_dev_get_resource(isa_dev); |
| 178 | (char *) isa_dev->compatible, | ||
| 179 | sizeof(isa_dev->compatible)); | ||
| 180 | |||
| 181 | /* Not having this is OK. */ | ||
| 182 | if (prop_len <= 0) | ||
| 183 | isa_dev->compatible[0] = '\0'; | ||
| 184 | |||
| 185 | isa_dev_get_resource(isa_dev, regs, sizeof(regs)); | ||
| 186 | isa_dev_get_irq(isa_dev, regs); | 180 | isa_dev_get_irq(isa_dev, regs); |
| 187 | 181 | ||
| 188 | report_dev(isa_dev, 1); | 182 | report_dev(isa_dev, 1); |
| 189 | 183 | ||
| 190 | node = prom_getsibling(node); | 184 | dp = dp->sibling; |
| 191 | } | 185 | } |
| 192 | } | 186 | } |
| 193 | 187 | ||
| 194 | static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br) | 188 | static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br) |
| 195 | { | 189 | { |
| 196 | int node = prom_getchild(isa_br->prom_node); | 190 | struct device_node *dp = isa_br->prom_node->child; |
| 197 | 191 | ||
| 198 | while (node != 0) { | 192 | while (dp) { |
| 199 | struct linux_prom_registers regs[PROMREG_MAX]; | 193 | struct linux_prom_registers *regs; |
| 200 | struct sparc_isa_device *isa_dev; | 194 | struct sparc_isa_device *isa_dev; |
| 201 | int prop_len; | ||
| 202 | 195 | ||
| 203 | isa_dev = kmalloc(sizeof(*isa_dev), GFP_KERNEL); | 196 | isa_dev = kmalloc(sizeof(*isa_dev), GFP_KERNEL); |
| 204 | if (!isa_dev) { | 197 | if (!isa_dev) { |
| 205 | fatal_err("cannot allocate isa_dev"); | 198 | printk(KERN_DEBUG "ISA: cannot allocate isa_dev"); |
| 206 | prom_halt(); | 199 | return; |
| 207 | } | 200 | } |
| 208 | 201 | ||
| 209 | memset(isa_dev, 0, sizeof(*isa_dev)); | 202 | memset(isa_dev, 0, sizeof(*isa_dev)); |
| 210 | 203 | ||
| 204 | isa_dev->ofdev.node = dp; | ||
| 205 | isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev; | ||
| 206 | isa_dev->ofdev.dev.bus = &isa_bus_type; | ||
| 207 | strcpy(isa_dev->ofdev.dev.bus_id, dp->path_component_name); | ||
| 208 | |||
| 209 | /* Register with core */ | ||
| 210 | if (of_device_register(&isa_dev->ofdev) != 0) { | ||
| 211 | printk(KERN_DEBUG "isa: device registration error for %s!\n", | ||
| 212 | isa_dev->ofdev.dev.bus_id); | ||
| 213 | kfree(isa_dev); | ||
| 214 | goto next_sibling; | ||
| 215 | } | ||
| 216 | |||
| 211 | /* Link it in. */ | 217 | /* Link it in. */ |
| 212 | isa_dev->next = NULL; | 218 | isa_dev->next = NULL; |
| 213 | if (isa_br->devices == NULL) { | 219 | if (isa_br->devices == NULL) { |
| @@ -222,24 +228,9 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br) | |||
| 222 | } | 228 | } |
| 223 | 229 | ||
| 224 | isa_dev->bus = isa_br; | 230 | isa_dev->bus = isa_br; |
| 225 | isa_dev->prom_node = node; | 231 | isa_dev->prom_node = dp; |
| 226 | prop_len = prom_getproperty(node, "name", | ||
| 227 | (char *) isa_dev->prom_name, | ||
| 228 | sizeof(isa_dev->prom_name)); | ||
| 229 | if (prop_len <= 0) { | ||
| 230 | fatal_err("cannot get isa_dev OBP node name"); | ||
| 231 | prom_halt(); | ||
| 232 | } | ||
| 233 | |||
| 234 | prop_len = prom_getproperty(node, "compatible", | ||
| 235 | (char *) isa_dev->compatible, | ||
| 236 | sizeof(isa_dev->compatible)); | ||
| 237 | 232 | ||
| 238 | /* Not having this is OK. */ | 233 | regs = isa_dev_get_resource(isa_dev); |
| 239 | if (prop_len <= 0) | ||
| 240 | isa_dev->compatible[0] = '\0'; | ||
| 241 | |||
| 242 | isa_dev_get_resource(isa_dev, regs, sizeof(regs)); | ||
| 243 | isa_dev_get_irq(isa_dev, regs); | 234 | isa_dev_get_irq(isa_dev, regs); |
| 244 | 235 | ||
| 245 | report_dev(isa_dev, 0); | 236 | report_dev(isa_dev, 0); |
| @@ -248,7 +239,8 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br) | |||
| 248 | 239 | ||
| 249 | printk("]"); | 240 | printk("]"); |
| 250 | 241 | ||
| 251 | node = prom_getsibling(node); | 242 | next_sibling: |
| 243 | dp = dp->sibling; | ||
| 252 | } | 244 | } |
| 253 | } | 245 | } |
| 254 | 246 | ||
| @@ -266,7 +258,7 @@ void __init isa_init(void) | |||
| 266 | struct pcidev_cookie *pdev_cookie; | 258 | struct pcidev_cookie *pdev_cookie; |
| 267 | struct pci_pbm_info *pbm; | 259 | struct pci_pbm_info *pbm; |
| 268 | struct sparc_isa_bridge *isa_br; | 260 | struct sparc_isa_bridge *isa_br; |
| 269 | int prop_len; | 261 | struct device_node *dp; |
| 270 | 262 | ||
| 271 | pdev_cookie = pdev->sysdata; | 263 | pdev_cookie = pdev->sysdata; |
| 272 | if (!pdev_cookie) { | 264 | if (!pdev_cookie) { |
| @@ -275,15 +267,29 @@ void __init isa_init(void) | |||
| 275 | continue; | 267 | continue; |
| 276 | } | 268 | } |
| 277 | pbm = pdev_cookie->pbm; | 269 | pbm = pdev_cookie->pbm; |
| 270 | dp = pdev_cookie->prom_node; | ||
| 278 | 271 | ||
| 279 | isa_br = kmalloc(sizeof(*isa_br), GFP_KERNEL); | 272 | isa_br = kmalloc(sizeof(*isa_br), GFP_KERNEL); |
| 280 | if (!isa_br) { | 273 | if (!isa_br) { |
| 281 | fatal_err("cannot allocate sparc_isa_bridge"); | 274 | printk(KERN_DEBUG "isa: cannot allocate sparc_isa_bridge"); |
| 282 | prom_halt(); | 275 | return; |
| 283 | } | 276 | } |
| 284 | 277 | ||
| 285 | memset(isa_br, 0, sizeof(*isa_br)); | 278 | memset(isa_br, 0, sizeof(*isa_br)); |
| 286 | 279 | ||
| 280 | isa_br->ofdev.node = dp; | ||
| 281 | isa_br->ofdev.dev.parent = &pdev->dev; | ||
| 282 | isa_br->ofdev.dev.bus = &isa_bus_type; | ||
| 283 | strcpy(isa_br->ofdev.dev.bus_id, dp->path_component_name); | ||
| 284 | |||
| 285 | /* Register with core */ | ||
| 286 | if (of_device_register(&isa_br->ofdev) != 0) { | ||
| 287 | printk(KERN_DEBUG "isa: device registration error for %s!\n", | ||
| 288 | isa_br->ofdev.dev.bus_id); | ||
| 289 | kfree(isa_br); | ||
| 290 | return; | ||
| 291 | } | ||
| 292 | |||
| 287 | /* Link it in. */ | 293 | /* Link it in. */ |
| 288 | isa_br->next = isa_chain; | 294 | isa_br->next = isa_chain; |
| 289 | isa_chain = isa_br; | 295 | isa_chain = isa_br; |
| @@ -292,33 +298,6 @@ void __init isa_init(void) | |||
| 292 | isa_br->self = pdev; | 298 | isa_br->self = pdev; |
| 293 | isa_br->index = index++; | 299 | isa_br->index = index++; |
| 294 | isa_br->prom_node = pdev_cookie->prom_node; | 300 | isa_br->prom_node = pdev_cookie->prom_node; |
| 295 | strncpy(isa_br->prom_name, pdev_cookie->prom_name, | ||
| 296 | sizeof(isa_br->prom_name)); | ||
| 297 | |||
| 298 | prop_len = prom_getproperty(isa_br->prom_node, | ||
| 299 | "ranges", | ||
| 300 | (char *) isa_br->isa_ranges, | ||
| 301 | sizeof(isa_br->isa_ranges)); | ||
| 302 | if (prop_len <= 0) | ||
| 303 | isa_br->num_isa_ranges = 0; | ||
| 304 | else | ||
| 305 | isa_br->num_isa_ranges = | ||
| 306 | (prop_len / sizeof(struct linux_prom_isa_ranges)); | ||
| 307 | |||
| 308 | prop_len = prom_getproperty(isa_br->prom_node, | ||
| 309 | "interrupt-map", | ||
| 310 | (char *) isa_br->isa_intmap, | ||
| 311 | sizeof(isa_br->isa_intmap)); | ||
| 312 | if (prop_len <= 0) | ||
| 313 | isa_br->num_isa_intmap = 0; | ||
| 314 | else | ||
| 315 | isa_br->num_isa_intmap = | ||
| 316 | (prop_len / sizeof(struct linux_prom_isa_intmap)); | ||
| 317 | |||
| 318 | prop_len = prom_getproperty(isa_br->prom_node, | ||
| 319 | "interrupt-map-mask", | ||
| 320 | (char *) &(isa_br->isa_intmask), | ||
| 321 | sizeof(isa_br->isa_intmask)); | ||
| 322 | 301 | ||
| 323 | printk("isa%d:", isa_br->index); | 302 | printk("isa%d:", isa_br->index); |
| 324 | 303 | ||
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c new file mode 100644 index 000000000000..566aa343aa62 --- /dev/null +++ b/arch/sparc64/kernel/of_device.c | |||
| @@ -0,0 +1,279 @@ | |||
| 1 | #include <linux/config.h> | ||
| 2 | #include <linux/string.h> | ||
| 3 | #include <linux/kernel.h> | ||
| 4 | #include <linux/init.h> | ||
| 5 | #include <linux/module.h> | ||
| 6 | #include <linux/mod_devicetable.h> | ||
| 7 | #include <linux/slab.h> | ||
| 8 | |||
| 9 | #include <asm/errno.h> | ||
| 10 | #include <asm/of_device.h> | ||
| 11 | |||
| 12 | /** | ||
| 13 | * of_match_device - Tell if an of_device structure has a matching | ||
| 14 | * of_match structure | ||
| 15 | * @ids: array of of device match structures to search in | ||
| 16 | * @dev: the of device structure to match against | ||
| 17 | * | ||
| 18 | * Used by a driver to check whether an of_device present in the | ||
| 19 | * system is in its list of supported devices. | ||
| 20 | */ | ||
| 21 | const struct of_device_id *of_match_device(const struct of_device_id *matches, | ||
| 22 | const struct of_device *dev) | ||
| 23 | { | ||
| 24 | if (!dev->node) | ||
| 25 | return NULL; | ||
| 26 | while (matches->name[0] || matches->type[0] || matches->compatible[0]) { | ||
| 27 | int match = 1; | ||
| 28 | if (matches->name[0]) | ||
| 29 | match &= dev->node->name | ||
| 30 | && !strcmp(matches->name, dev->node->name); | ||
| 31 | if (matches->type[0]) | ||
| 32 | match &= dev->node->type | ||
| 33 | && !strcmp(matches->type, dev->node->type); | ||
| 34 | if (matches->compatible[0]) | ||
| 35 | match &= of_device_is_compatible(dev->node, | ||
| 36 | matches->compatible); | ||
| 37 | if (match) | ||
| 38 | return matches; | ||
| 39 | matches++; | ||
| 40 | } | ||
| 41 | return NULL; | ||
| 42 | } | ||
| 43 | |||
| 44 | static int of_platform_bus_match(struct device *dev, struct device_driver *drv) | ||
| 45 | { | ||
| 46 | struct of_device * of_dev = to_of_device(dev); | ||
| 47 | struct of_platform_driver * of_drv = to_of_platform_driver(drv); | ||
| 48 | const struct of_device_id * matches = of_drv->match_table; | ||
| 49 | |||
| 50 | if (!matches) | ||
| 51 | return 0; | ||
| 52 | |||
| 53 | return of_match_device(matches, of_dev) != NULL; | ||
| 54 | } | ||
| 55 | |||
| 56 | struct of_device *of_dev_get(struct of_device *dev) | ||
| 57 | { | ||
| 58 | struct device *tmp; | ||
| 59 | |||
| 60 | if (!dev) | ||
| 61 | return NULL; | ||
| 62 | tmp = get_device(&dev->dev); | ||
| 63 | if (tmp) | ||
| 64 | return to_of_device(tmp); | ||
| 65 | else | ||
| 66 | return NULL; | ||
| 67 | } | ||
| 68 | |||
| 69 | void of_dev_put(struct of_device *dev) | ||
| 70 | { | ||
| 71 | if (dev) | ||
| 72 | put_device(&dev->dev); | ||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | static int of_device_probe(struct device *dev) | ||
| 77 | { | ||
| 78 | int error = -ENODEV; | ||
| 79 | struct of_platform_driver *drv; | ||
| 80 | struct of_device *of_dev; | ||
| 81 | const struct of_device_id *match; | ||
| 82 | |||
| 83 | drv = to_of_platform_driver(dev->driver); | ||
| 84 | of_dev = to_of_device(dev); | ||
| 85 | |||
| 86 | if (!drv->probe) | ||
| 87 | return error; | ||
| 88 | |||
| 89 | of_dev_get(of_dev); | ||
| 90 | |||
| 91 | match = of_match_device(drv->match_table, of_dev); | ||
| 92 | if (match) | ||
| 93 | error = drv->probe(of_dev, match); | ||
| 94 | if (error) | ||
| 95 | of_dev_put(of_dev); | ||
| 96 | |||
| 97 | return error; | ||
| 98 | } | ||
| 99 | |||
| 100 | static int of_device_remove(struct device *dev) | ||
| 101 | { | ||
| 102 | struct of_device * of_dev = to_of_device(dev); | ||
| 103 | struct of_platform_driver * drv = to_of_platform_driver(dev->driver); | ||
| 104 | |||
| 105 | if (dev->driver && drv->remove) | ||
| 106 | drv->remove(of_dev); | ||
| 107 | return 0; | ||
| 108 | } | ||
| 109 | |||
| 110 | static int of_device_suspend(struct device *dev, pm_message_t state) | ||
| 111 | { | ||
| 112 | struct of_device * of_dev = to_of_device(dev); | ||
| 113 | struct of_platform_driver * drv = to_of_platform_driver(dev->driver); | ||
| 114 | int error = 0; | ||
| 115 | |||
| 116 | if (dev->driver && drv->suspend) | ||
| 117 | error = drv->suspend(of_dev, state); | ||
| 118 | return error; | ||
| 119 | } | ||
| 120 | |||
| 121 | static int of_device_resume(struct device * dev) | ||
| 122 | { | ||
| 123 | struct of_device * of_dev = to_of_device(dev); | ||
| 124 | struct of_platform_driver * drv = to_of_platform_driver(dev->driver); | ||
| 125 | int error = 0; | ||
| 126 | |||
| 127 | if (dev->driver && drv->resume) | ||
| 128 | error = drv->resume(of_dev); | ||
| 129 | return error; | ||
| 130 | } | ||
| 131 | |||
| 132 | #ifdef CONFIG_PCI | ||
| 133 | struct bus_type isa_bus_type = { | ||
| 134 | .name = "isa", | ||
| 135 | .match = of_platform_bus_match, | ||
| 136 | .probe = of_device_probe, | ||
| 137 | .remove = of_device_remove, | ||
| 138 | .suspend = of_device_suspend, | ||
| 139 | .resume = of_device_resume, | ||
| 140 | }; | ||
| 141 | |||
| 142 | struct bus_type ebus_bus_type = { | ||
| 143 | .name = "ebus", | ||
| 144 | .match = of_platform_bus_match, | ||
| 145 | .probe = of_device_probe, | ||
| 146 | .remove = of_device_remove, | ||
| 147 | .suspend = of_device_suspend, | ||
| 148 | .resume = of_device_resume, | ||
| 149 | }; | ||
| 150 | #endif | ||
| 151 | |||
| 152 | #ifdef CONFIG_SBUS | ||
| 153 | struct bus_type sbus_bus_type = { | ||
| 154 | .name = "sbus", | ||
| 155 | .match = of_platform_bus_match, | ||
| 156 | .probe = of_device_probe, | ||
| 157 | .remove = of_device_remove, | ||
| 158 | .suspend = of_device_suspend, | ||
| 159 | .resume = of_device_resume, | ||
| 160 | }; | ||
| 161 | #endif | ||
| 162 | |||
| 163 | static int __init of_bus_driver_init(void) | ||
| 164 | { | ||
| 165 | int err = 0; | ||
| 166 | |||
| 167 | #ifdef CONFIG_PCI | ||
| 168 | if (!err) | ||
| 169 | err = bus_register(&isa_bus_type); | ||
| 170 | if (!err) | ||
| 171 | err = bus_register(&ebus_bus_type); | ||
| 172 | #endif | ||
| 173 | #ifdef CONFIG_SBUS | ||
| 174 | if (!err) | ||
| 175 | err = bus_register(&sbus_bus_type); | ||
| 176 | #endif | ||
| 177 | return 0; | ||
| 178 | } | ||
| 179 | |||
| 180 | postcore_initcall(of_bus_driver_init); | ||
| 181 | |||
| 182 | int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus) | ||
| 183 | { | ||
| 184 | /* initialize common driver fields */ | ||
| 185 | drv->driver.name = drv->name; | ||
| 186 | drv->driver.bus = bus; | ||
| 187 | |||
| 188 | /* register with core */ | ||
| 189 | return driver_register(&drv->driver); | ||
| 190 | } | ||
| 191 | |||
| 192 | void of_unregister_driver(struct of_platform_driver *drv) | ||
| 193 | { | ||
| 194 | driver_unregister(&drv->driver); | ||
| 195 | } | ||
| 196 | |||
| 197 | |||
| 198 | static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf) | ||
| 199 | { | ||
| 200 | struct of_device *ofdev; | ||
| 201 | |||
| 202 | ofdev = to_of_device(dev); | ||
| 203 | return sprintf(buf, "%s", ofdev->node->full_name); | ||
| 204 | } | ||
| 205 | |||
| 206 | static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); | ||
| 207 | |||
| 208 | /** | ||
| 209 | * of_release_dev - free an of device structure when all users of it are finished. | ||
| 210 | * @dev: device that's been disconnected | ||
| 211 | * | ||
| 212 | * Will be called only by the device core when all users of this of device are | ||
| 213 | * done. | ||
| 214 | */ | ||
| 215 | void of_release_dev(struct device *dev) | ||
| 216 | { | ||
| 217 | struct of_device *ofdev; | ||
| 218 | |||
| 219 | ofdev = to_of_device(dev); | ||
| 220 | |||
| 221 | kfree(ofdev); | ||
| 222 | } | ||
| 223 | |||
| 224 | int of_device_register(struct of_device *ofdev) | ||
| 225 | { | ||
| 226 | int rc; | ||
| 227 | |||
| 228 | BUG_ON(ofdev->node == NULL); | ||
| 229 | |||
| 230 | rc = device_register(&ofdev->dev); | ||
| 231 | if (rc) | ||
| 232 | return rc; | ||
| 233 | |||
| 234 | device_create_file(&ofdev->dev, &dev_attr_devspec); | ||
| 235 | |||
| 236 | return 0; | ||
| 237 | } | ||
| 238 | |||
| 239 | void of_device_unregister(struct of_device *ofdev) | ||
| 240 | { | ||
| 241 | device_remove_file(&ofdev->dev, &dev_attr_devspec); | ||
| 242 | device_unregister(&ofdev->dev); | ||
| 243 | } | ||
| 244 | |||
| 245 | struct of_device* of_platform_device_create(struct device_node *np, | ||
| 246 | const char *bus_id, | ||
| 247 | struct device *parent, | ||
| 248 | struct bus_type *bus) | ||
| 249 | { | ||
| 250 | struct of_device *dev; | ||
| 251 | |||
| 252 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); | ||
| 253 | if (!dev) | ||
| 254 | return NULL; | ||
| 255 | memset(dev, 0, sizeof(*dev)); | ||
| 256 | |||
| 257 | dev->dev.parent = parent; | ||
| 258 | dev->dev.bus = bus; | ||
| 259 | dev->dev.release = of_release_dev; | ||
| 260 | |||
| 261 | strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE); | ||
| 262 | |||
| 263 | if (of_device_register(dev) != 0) { | ||
| 264 | kfree(dev); | ||
| 265 | return NULL; | ||
| 266 | } | ||
| 267 | |||
| 268 | return dev; | ||
| 269 | } | ||
| 270 | |||
| 271 | EXPORT_SYMBOL(of_match_device); | ||
| 272 | EXPORT_SYMBOL(of_register_driver); | ||
| 273 | EXPORT_SYMBOL(of_unregister_driver); | ||
| 274 | EXPORT_SYMBOL(of_device_register); | ||
| 275 | EXPORT_SYMBOL(of_device_unregister); | ||
| 276 | EXPORT_SYMBOL(of_dev_get); | ||
| 277 | EXPORT_SYMBOL(of_dev_put); | ||
| 278 | EXPORT_SYMBOL(of_platform_device_create); | ||
| 279 | EXPORT_SYMBOL(of_release_dev); | ||
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c index 9472580a4319..6c9e3e94abaa 100644 --- a/arch/sparc64/kernel/pci.c +++ b/arch/sparc64/kernel/pci.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <asm/irq.h> | 22 | #include <asm/irq.h> |
| 23 | #include <asm/ebus.h> | 23 | #include <asm/ebus.h> |
| 24 | #include <asm/isa.h> | 24 | #include <asm/isa.h> |
| 25 | #include <asm/prom.h> | ||
| 25 | 26 | ||
| 26 | unsigned long pci_memspace_mask = 0xffffffffUL; | 27 | unsigned long pci_memspace_mask = 0xffffffffUL; |
| 27 | 28 | ||
| @@ -177,16 +178,16 @@ void pci_config_write32(u32 *addr, u32 val) | |||
| 177 | } | 178 | } |
| 178 | 179 | ||
| 179 | /* Probe for all PCI controllers in the system. */ | 180 | /* Probe for all PCI controllers in the system. */ |
| 180 | extern void sabre_init(int, char *); | 181 | extern void sabre_init(struct device_node *, const char *); |
| 181 | extern void psycho_init(int, char *); | 182 | extern void psycho_init(struct device_node *, const char *); |
| 182 | extern void schizo_init(int, char *); | 183 | extern void schizo_init(struct device_node *, const char *); |
| 183 | extern void schizo_plus_init(int, char *); | 184 | extern void schizo_plus_init(struct device_node *, const char *); |
| 184 | extern void tomatillo_init(int, char *); | 185 | extern void tomatillo_init(struct device_node *, const char *); |
| 185 | extern void sun4v_pci_init(int, char *); | 186 | extern void sun4v_pci_init(struct device_node *, const char *); |
| 186 | 187 | ||
| 187 | static struct { | 188 | static struct { |
| 188 | char *model_name; | 189 | char *model_name; |
| 189 | void (*init)(int, char *); | 190 | void (*init)(struct device_node *, const char *); |
| 190 | } pci_controller_table[] __initdata = { | 191 | } pci_controller_table[] __initdata = { |
| 191 | { "SUNW,sabre", sabre_init }, | 192 | { "SUNW,sabre", sabre_init }, |
| 192 | { "pci108e,a000", sabre_init }, | 193 | { "pci108e,a000", sabre_init }, |
| @@ -204,7 +205,7 @@ static struct { | |||
| 204 | #define PCI_NUM_CONTROLLER_TYPES (sizeof(pci_controller_table) / \ | 205 | #define PCI_NUM_CONTROLLER_TYPES (sizeof(pci_controller_table) / \ |
| 205 | sizeof(pci_controller_table[0])) | 206 | sizeof(pci_controller_table[0])) |
| 206 | 207 | ||
| 207 | static int __init pci_controller_init(char *model_name, int namelen, int node) | 208 | static int __init pci_controller_init(const char *model_name, int namelen, struct device_node *dp) |
| 208 | { | 209 | { |
| 209 | int i; | 210 | int i; |
| 210 | 211 | ||
| @@ -212,18 +213,15 @@ static int __init pci_controller_init(char *model_name, int namelen, int node) | |||
| 212 | if (!strncmp(model_name, | 213 | if (!strncmp(model_name, |
| 213 | pci_controller_table[i].model_name, | 214 | pci_controller_table[i].model_name, |
| 214 | namelen)) { | 215 | namelen)) { |
| 215 | pci_controller_table[i].init(node, model_name); | 216 | pci_controller_table[i].init(dp, model_name); |
| 216 | return 1; | 217 | return 1; |
| 217 | } | 218 | } |
| 218 | } | 219 | } |
| 219 | printk("PCI: Warning unknown controller, model name [%s]\n", | ||
| 220 | model_name); | ||
| 221 | printk("PCI: Ignoring controller...\n"); | ||
| 222 | 220 | ||
| 223 | return 0; | 221 | return 0; |
| 224 | } | 222 | } |
| 225 | 223 | ||
| 226 | static int __init pci_is_controller(char *model_name, int namelen, int node) | 224 | static int __init pci_is_controller(const char *model_name, int namelen, struct device_node *dp) |
| 227 | { | 225 | { |
| 228 | int i; | 226 | int i; |
| 229 | 227 | ||
| @@ -237,36 +235,35 @@ static int __init pci_is_controller(char *model_name, int namelen, int node) | |||
| 237 | return 0; | 235 | return 0; |
| 238 | } | 236 | } |
| 239 | 237 | ||
| 240 | static int __init pci_controller_scan(int (*handler)(char *, int, int)) | 238 | static int __init pci_controller_scan(int (*handler)(const char *, int, struct device_node *)) |
| 241 | { | 239 | { |
| 242 | char namebuf[64]; | 240 | struct device_node *dp; |
| 243 | int node; | ||
| 244 | int count = 0; | 241 | int count = 0; |
| 245 | 242 | ||
| 246 | node = prom_getchild(prom_root_node); | 243 | for_each_node_by_name(dp, "pci") { |
| 247 | while ((node = prom_searchsiblings(node, "pci")) != 0) { | 244 | struct property *prop; |
| 248 | int len; | 245 | int len; |
| 249 | 246 | ||
| 250 | if ((len = prom_getproperty(node, "model", namebuf, sizeof(namebuf))) > 0 || | 247 | prop = of_find_property(dp, "model", &len); |
| 251 | (len = prom_getproperty(node, "compatible", namebuf, sizeof(namebuf))) > 0) { | 248 | if (!prop) |
| 249 | prop = of_find_property(dp, "compatible", &len); | ||
| 250 | |||
| 251 | if (prop) { | ||
| 252 | const char *model = prop->value; | ||
| 252 | int item_len = 0; | 253 | int item_len = 0; |
| 253 | 254 | ||
| 254 | /* Our value may be a multi-valued string in the | 255 | /* Our value may be a multi-valued string in the |
| 255 | * case of some compatible properties. For sanity, | 256 | * case of some compatible properties. For sanity, |
| 256 | * only try the first one. */ | 257 | * only try the first one. |
| 257 | 258 | */ | |
| 258 | while (namebuf[item_len] && len) { | 259 | while (model[item_len] && len) { |
| 259 | len--; | 260 | len--; |
| 260 | item_len++; | 261 | item_len++; |
| 261 | } | 262 | } |
| 262 | 263 | ||
| 263 | if (handler(namebuf, item_len, node)) | 264 | if (handler(model, item_len, dp)) |
| 264 | count++; | 265 | count++; |
| 265 | } | 266 | } |
| 266 | |||
| 267 | node = prom_getsibling(node); | ||
| 268 | if (!node) | ||
| 269 | break; | ||
| 270 | } | 267 | } |
| 271 | 268 | ||
| 272 | return count; | 269 | return count; |
| @@ -409,8 +406,14 @@ void pcibios_bus_to_resource(struct pci_dev *pdev, struct resource *res, | |||
| 409 | } | 406 | } |
| 410 | EXPORT_SYMBOL(pcibios_bus_to_resource); | 407 | EXPORT_SYMBOL(pcibios_bus_to_resource); |
| 411 | 408 | ||
| 409 | extern int pci_irq_verbose; | ||
| 410 | |||
| 412 | char * __init pcibios_setup(char *str) | 411 | char * __init pcibios_setup(char *str) |
| 413 | { | 412 | { |
| 413 | if (!strcmp(str, "irq_verbose")) { | ||
| 414 | pci_irq_verbose = 1; | ||
| 415 | return NULL; | ||
| 416 | } | ||
| 414 | return str; | 417 | return str; |
| 415 | } | 418 | } |
| 416 | 419 | ||
diff --git a/arch/sparc64/kernel/pci_common.c b/arch/sparc64/kernel/pci_common.c index 33dedb1aacd4..b06a2955bf5f 100644 --- a/arch/sparc64/kernel/pci_common.c +++ b/arch/sparc64/kernel/pci_common.c | |||
| @@ -9,6 +9,12 @@ | |||
| 9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
| 10 | 10 | ||
| 11 | #include <asm/pbm.h> | 11 | #include <asm/pbm.h> |
| 12 | #include <asm/prom.h> | ||
| 13 | |||
| 14 | #include "pci_impl.h" | ||
| 15 | |||
| 16 | /* Pass "pci=irq_verbose" on the kernel command line to enable this. */ | ||
| 17 | int pci_irq_verbose; | ||
| 12 | 18 | ||
| 13 | /* Fix self device of BUS and hook it into BUS->self. | 19 | /* Fix self device of BUS and hook it into BUS->self. |
| 14 | * The pci_scan_bus does not do this for the host bridge. | 20 | * The pci_scan_bus does not do this for the host bridge. |
| @@ -28,16 +34,14 @@ void __init pci_fixup_host_bridge_self(struct pci_bus *pbus) | |||
| 28 | prom_halt(); | 34 | prom_halt(); |
| 29 | } | 35 | } |
| 30 | 36 | ||
| 31 | /* Find the OBP PROM device tree node for a PCI device. | 37 | /* Find the OBP PROM device tree node for a PCI device. */ |
| 32 | * Return zero if not found. | 38 | static struct device_node * __init |
| 33 | */ | 39 | find_device_prom_node(struct pci_pbm_info *pbm, struct pci_dev *pdev, |
| 34 | static int __init find_device_prom_node(struct pci_pbm_info *pbm, | 40 | struct device_node *bus_node, |
| 35 | struct pci_dev *pdev, | 41 | struct linux_prom_pci_registers **pregs, |
| 36 | int bus_prom_node, | 42 | int *nregs) |
| 37 | struct linux_prom_pci_registers *pregs, | ||
| 38 | int *nregs) | ||
| 39 | { | 43 | { |
| 40 | int node; | 44 | struct device_node *dp; |
| 41 | 45 | ||
| 42 | *nregs = 0; | 46 | *nregs = 0; |
| 43 | 47 | ||
| @@ -54,24 +58,30 @@ static int __init find_device_prom_node(struct pci_pbm_info *pbm, | |||
| 54 | pdev->device == PCI_DEVICE_ID_SUN_TOMATILLO || | 58 | pdev->device == PCI_DEVICE_ID_SUN_TOMATILLO || |
| 55 | pdev->device == PCI_DEVICE_ID_SUN_SABRE || | 59 | pdev->device == PCI_DEVICE_ID_SUN_SABRE || |
| 56 | pdev->device == PCI_DEVICE_ID_SUN_HUMMINGBIRD)) | 60 | pdev->device == PCI_DEVICE_ID_SUN_HUMMINGBIRD)) |
| 57 | return bus_prom_node; | 61 | return bus_node; |
| 58 | 62 | ||
| 59 | node = prom_getchild(bus_prom_node); | 63 | dp = bus_node->child; |
| 60 | while (node != 0) { | 64 | while (dp) { |
| 61 | int err = prom_getproperty(node, "reg", | 65 | struct linux_prom_pci_registers *regs; |
| 62 | (char *)pregs, | 66 | struct property *prop; |
| 63 | sizeof(*pregs) * PROMREG_MAX); | 67 | int len; |
| 64 | if (err == 0 || err == -1) | 68 | |
| 69 | prop = of_find_property(dp, "reg", &len); | ||
| 70 | if (!prop) | ||
| 65 | goto do_next_sibling; | 71 | goto do_next_sibling; |
| 66 | if (((pregs[0].phys_hi >> 8) & 0xff) == pdev->devfn) { | 72 | |
| 67 | *nregs = err / sizeof(*pregs); | 73 | regs = prop->value; |
| 68 | return node; | 74 | if (((regs[0].phys_hi >> 8) & 0xff) == pdev->devfn) { |
| 75 | *pregs = regs; | ||
| 76 | *nregs = len / sizeof(struct linux_prom_pci_registers); | ||
| 77 | return dp; | ||
| 69 | } | 78 | } |
| 70 | 79 | ||
| 71 | do_next_sibling: | 80 | do_next_sibling: |
| 72 | node = prom_getsibling(node); | 81 | dp = dp->sibling; |
| 73 | } | 82 | } |
| 74 | return 0; | 83 | |
| 84 | return NULL; | ||
| 75 | } | 85 | } |
| 76 | 86 | ||
| 77 | /* Older versions of OBP on PCI systems encode 64-bit MEM | 87 | /* Older versions of OBP on PCI systems encode 64-bit MEM |
| @@ -128,15 +138,17 @@ static void __init fixup_obp_assignments(struct pci_dev *pdev, | |||
| 128 | */ | 138 | */ |
| 129 | static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm, | 139 | static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm, |
| 130 | struct pci_dev *pdev, | 140 | struct pci_dev *pdev, |
| 131 | int bus_prom_node) | 141 | struct device_node *bus_node) |
| 132 | { | 142 | { |
| 133 | struct linux_prom_pci_registers pregs[PROMREG_MAX]; | 143 | struct linux_prom_pci_registers *pregs = NULL; |
| 134 | struct pcidev_cookie *pcp; | 144 | struct pcidev_cookie *pcp; |
| 135 | int device_prom_node, nregs, err; | 145 | struct device_node *dp; |
| 146 | struct property *prop; | ||
| 147 | int nregs, len; | ||
| 136 | 148 | ||
| 137 | device_prom_node = find_device_prom_node(pbm, pdev, bus_prom_node, | 149 | dp = find_device_prom_node(pbm, pdev, bus_node, |
| 138 | pregs, &nregs); | 150 | &pregs, &nregs); |
| 139 | if (device_prom_node == 0) { | 151 | if (!dp) { |
| 140 | /* If it is not in the OBP device tree then | 152 | /* If it is not in the OBP device tree then |
| 141 | * there must be a damn good reason for it. | 153 | * there must be a damn good reason for it. |
| 142 | * | 154 | * |
| @@ -150,45 +162,43 @@ static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm, | |||
| 150 | return; | 162 | return; |
| 151 | } | 163 | } |
| 152 | 164 | ||
| 153 | pcp = kmalloc(sizeof(*pcp), GFP_ATOMIC); | 165 | pcp = kzalloc(sizeof(*pcp), GFP_ATOMIC); |
| 154 | if (pcp == NULL) { | 166 | if (pcp == NULL) { |
| 155 | prom_printf("PCI_COOKIE: Fatal malloc error, aborting...\n"); | 167 | prom_printf("PCI_COOKIE: Fatal malloc error, aborting...\n"); |
| 156 | prom_halt(); | 168 | prom_halt(); |
| 157 | } | 169 | } |
| 158 | pcp->pbm = pbm; | 170 | pcp->pbm = pbm; |
| 159 | pcp->prom_node = device_prom_node; | 171 | pcp->prom_node = dp; |
| 160 | memcpy(pcp->prom_regs, pregs, sizeof(pcp->prom_regs)); | 172 | memcpy(pcp->prom_regs, pregs, |
| 173 | nregs * sizeof(struct linux_prom_pci_registers)); | ||
| 161 | pcp->num_prom_regs = nregs; | 174 | pcp->num_prom_regs = nregs; |
| 162 | err = prom_getproperty(device_prom_node, "name", | 175 | |
| 163 | pcp->prom_name, sizeof(pcp->prom_name)); | 176 | /* We can't have the pcidev_cookie assignments be just |
| 164 | if (err > 0) | 177 | * direct pointers into the property value, since they |
| 165 | pcp->prom_name[err] = 0; | 178 | * are potentially modified by the probing process. |
| 166 | else | 179 | */ |
| 167 | pcp->prom_name[0] = 0; | 180 | prop = of_find_property(dp, "assigned-addresses", &len); |
| 168 | 181 | if (!prop) { | |
| 169 | err = prom_getproperty(device_prom_node, | ||
| 170 | "assigned-addresses", | ||
| 171 | (char *)pcp->prom_assignments, | ||
| 172 | sizeof(pcp->prom_assignments)); | ||
| 173 | if (err == 0 || err == -1) | ||
| 174 | pcp->num_prom_assignments = 0; | 182 | pcp->num_prom_assignments = 0; |
| 175 | else | 183 | } else { |
| 184 | memcpy(pcp->prom_assignments, prop->value, len); | ||
| 176 | pcp->num_prom_assignments = | 185 | pcp->num_prom_assignments = |
| 177 | (err / sizeof(pcp->prom_assignments[0])); | 186 | (len / sizeof(pcp->prom_assignments[0])); |
| 187 | } | ||
| 178 | 188 | ||
| 179 | if (strcmp(pcp->prom_name, "ebus") == 0) { | 189 | if (strcmp(dp->name, "ebus") == 0) { |
| 180 | struct linux_prom_ebus_ranges erng[PROM_PCIRNG_MAX]; | 190 | struct linux_prom_ebus_ranges *erng; |
| 181 | int iter; | 191 | int iter; |
| 182 | 192 | ||
| 183 | /* EBUS is special... */ | 193 | /* EBUS is special... */ |
| 184 | err = prom_getproperty(device_prom_node, "ranges", | 194 | prop = of_find_property(dp, "ranges", &len); |
| 185 | (char *)&erng[0], sizeof(erng)); | 195 | if (!prop) { |
| 186 | if (err == 0 || err == -1) { | ||
| 187 | prom_printf("EBUS: Fatal error, no range property\n"); | 196 | prom_printf("EBUS: Fatal error, no range property\n"); |
| 188 | prom_halt(); | 197 | prom_halt(); |
| 189 | } | 198 | } |
| 190 | err = (err / sizeof(erng[0])); | 199 | erng = prop->value; |
| 191 | for(iter = 0; iter < err; iter++) { | 200 | len = (len / sizeof(erng[0])); |
| 201 | for (iter = 0; iter < len; iter++) { | ||
| 192 | struct linux_prom_ebus_ranges *ep = &erng[iter]; | 202 | struct linux_prom_ebus_ranges *ep = &erng[iter]; |
| 193 | struct linux_prom_pci_registers *ap; | 203 | struct linux_prom_pci_registers *ap; |
| 194 | 204 | ||
| @@ -200,7 +210,7 @@ static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm, | |||
| 200 | ap->size_hi = 0; | 210 | ap->size_hi = 0; |
| 201 | ap->size_lo = ep->size; | 211 | ap->size_lo = ep->size; |
| 202 | } | 212 | } |
| 203 | pcp->num_prom_assignments = err; | 213 | pcp->num_prom_assignments = len; |
| 204 | } | 214 | } |
| 205 | 215 | ||
| 206 | fixup_obp_assignments(pdev, pcp); | 216 | fixup_obp_assignments(pdev, pcp); |
| @@ -210,7 +220,7 @@ static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm, | |||
| 210 | 220 | ||
| 211 | void __init pci_fill_in_pbm_cookies(struct pci_bus *pbus, | 221 | void __init pci_fill_in_pbm_cookies(struct pci_bus *pbus, |
| 212 | struct pci_pbm_info *pbm, | 222 | struct pci_pbm_info *pbm, |
| 213 | int prom_node) | 223 | struct device_node *dp) |
| 214 | { | 224 | { |
| 215 | struct pci_dev *pdev, *pdev_next; | 225 | struct pci_dev *pdev, *pdev_next; |
| 216 | struct pci_bus *this_pbus, *pbus_next; | 226 | struct pci_bus *this_pbus, *pbus_next; |
| @@ -218,7 +228,7 @@ void __init pci_fill_in_pbm_cookies(struct pci_bus *pbus, | |||
| 218 | /* This must be _safe because the cookie fillin | 228 | /* This must be _safe because the cookie fillin |
| 219 | routine can delete devices from the tree. */ | 229 | routine can delete devices from the tree. */ |
| 220 | list_for_each_entry_safe(pdev, pdev_next, &pbus->devices, bus_list) | 230 | list_for_each_entry_safe(pdev, pdev_next, &pbus->devices, bus_list) |
| 221 | pdev_cookie_fillin(pbm, pdev, prom_node); | 231 | pdev_cookie_fillin(pbm, pdev, dp); |
| 222 | 232 | ||
| 223 | list_for_each_entry_safe(this_pbus, pbus_next, &pbus->children, node) { | 233 | list_for_each_entry_safe(this_pbus, pbus_next, &pbus->children, node) { |
| 224 | struct pcidev_cookie *pcp = this_pbus->self->sysdata; | 234 | struct pcidev_cookie *pcp = this_pbus->self->sysdata; |
| @@ -241,7 +251,6 @@ static void __init bad_assignment(struct pci_dev *pdev, | |||
| 241 | if (res) | 251 | if (res) |
| 242 | prom_printf("PCI: RES[%016lx-->%016lx:(%lx)]\n", | 252 | prom_printf("PCI: RES[%016lx-->%016lx:(%lx)]\n", |
| 243 | res->start, res->end, res->flags); | 253 | res->start, res->end, res->flags); |
| 244 | prom_printf("Please email this information to davem@redhat.com\n"); | ||
| 245 | if (do_prom_halt) | 254 | if (do_prom_halt) |
| 246 | prom_halt(); | 255 | prom_halt(); |
| 247 | } | 256 | } |
| @@ -273,8 +282,7 @@ __init get_root_resource(struct linux_prom_pci_registers *ap, | |||
| 273 | return &pbm->mem_space; | 282 | return &pbm->mem_space; |
| 274 | 283 | ||
| 275 | default: | 284 | default: |
| 276 | printk("PCI: What is resource space %x? " | 285 | printk("PCI: What is resource space %x?\n", space); |
| 277 | "Tell davem@redhat.com about it!\n", space); | ||
| 278 | return NULL; | 286 | return NULL; |
| 279 | }; | 287 | }; |
| 280 | } | 288 | } |
| @@ -556,9 +564,10 @@ static inline unsigned int pci_slot_swivel(struct pci_pbm_info *pbm, | |||
| 556 | 564 | ||
| 557 | ret = ((interrupt - 1 + (PCI_SLOT(pdev->devfn) & 3)) & 3) + 1; | 565 | ret = ((interrupt - 1 + (PCI_SLOT(pdev->devfn) & 3)) & 3) + 1; |
| 558 | 566 | ||
| 559 | printk("%s: %s IRQ Swivel %s [%x:%x] -> [%x]\n", | 567 | if (pci_irq_verbose) |
| 560 | pbm->name, pci_name(toplevel_pdev), pci_name(pdev), | 568 | printk("%s: %s IRQ Swivel %s [%x:%x] -> [%x]\n", |
| 561 | interrupt, PCI_SLOT(pdev->devfn), ret); | 569 | pbm->name, pci_name(toplevel_pdev), pci_name(pdev), |
| 570 | interrupt, PCI_SLOT(pdev->devfn), ret); | ||
| 562 | 571 | ||
| 563 | return ret; | 572 | return ret; |
| 564 | } | 573 | } |
| @@ -568,58 +577,60 @@ static inline unsigned int pci_apply_intmap(struct pci_pbm_info *pbm, | |||
| 568 | struct pci_dev *pbus, | 577 | struct pci_dev *pbus, |
| 569 | struct pci_dev *pdev, | 578 | struct pci_dev *pdev, |
| 570 | unsigned int interrupt, | 579 | unsigned int interrupt, |
| 571 | unsigned int *cnode) | 580 | struct device_node **cnode) |
| 572 | { | 581 | { |
| 573 | struct linux_prom_pci_intmap imap[PROM_PCIIMAP_MAX]; | 582 | struct linux_prom_pci_intmap *imap; |
| 574 | struct linux_prom_pci_intmask imask; | 583 | struct linux_prom_pci_intmask *imask; |
| 575 | struct pcidev_cookie *pbus_pcp = pbus->sysdata; | 584 | struct pcidev_cookie *pbus_pcp = pbus->sysdata; |
| 576 | struct pcidev_cookie *pdev_pcp = pdev->sysdata; | 585 | struct pcidev_cookie *pdev_pcp = pdev->sysdata; |
| 577 | struct linux_prom_pci_registers *pregs = pdev_pcp->prom_regs; | 586 | struct linux_prom_pci_registers *pregs = pdev_pcp->prom_regs; |
| 587 | struct property *prop; | ||
| 578 | int plen, num_imap, i; | 588 | int plen, num_imap, i; |
| 579 | unsigned int hi, mid, lo, irq, orig_interrupt; | 589 | unsigned int hi, mid, lo, irq, orig_interrupt; |
| 580 | 590 | ||
| 581 | *cnode = pbus_pcp->prom_node; | 591 | *cnode = pbus_pcp->prom_node; |
| 582 | 592 | ||
| 583 | plen = prom_getproperty(pbus_pcp->prom_node, "interrupt-map", | 593 | prop = of_find_property(pbus_pcp->prom_node, "interrupt-map", &plen); |
| 584 | (char *) &imap[0], sizeof(imap)); | 594 | if (!prop || |
| 585 | if (plen <= 0 || | ||
| 586 | (plen % sizeof(struct linux_prom_pci_intmap)) != 0) { | 595 | (plen % sizeof(struct linux_prom_pci_intmap)) != 0) { |
| 587 | printk("%s: Device %s interrupt-map has bad len %d\n", | 596 | printk("%s: Device %s interrupt-map has bad len %d\n", |
| 588 | pbm->name, pci_name(pbus), plen); | 597 | pbm->name, pci_name(pbus), plen); |
| 589 | goto no_intmap; | 598 | goto no_intmap; |
| 590 | } | 599 | } |
| 600 | imap = prop->value; | ||
| 591 | num_imap = plen / sizeof(struct linux_prom_pci_intmap); | 601 | num_imap = plen / sizeof(struct linux_prom_pci_intmap); |
| 592 | 602 | ||
| 593 | plen = prom_getproperty(pbus_pcp->prom_node, "interrupt-map-mask", | 603 | prop = of_find_property(pbus_pcp->prom_node, "interrupt-map-mask", &plen); |
| 594 | (char *) &imask, sizeof(imask)); | 604 | if (!prop || |
| 595 | if (plen <= 0 || | ||
| 596 | (plen % sizeof(struct linux_prom_pci_intmask)) != 0) { | 605 | (plen % sizeof(struct linux_prom_pci_intmask)) != 0) { |
| 597 | printk("%s: Device %s interrupt-map-mask has bad len %d\n", | 606 | printk("%s: Device %s interrupt-map-mask has bad len %d\n", |
| 598 | pbm->name, pci_name(pbus), plen); | 607 | pbm->name, pci_name(pbus), plen); |
| 599 | goto no_intmap; | 608 | goto no_intmap; |
| 600 | } | 609 | } |
| 610 | imask = prop->value; | ||
| 601 | 611 | ||
| 602 | orig_interrupt = interrupt; | 612 | orig_interrupt = interrupt; |
| 603 | 613 | ||
| 604 | hi = pregs->phys_hi & imask.phys_hi; | 614 | hi = pregs->phys_hi & imask->phys_hi; |
| 605 | mid = pregs->phys_mid & imask.phys_mid; | 615 | mid = pregs->phys_mid & imask->phys_mid; |
| 606 | lo = pregs->phys_lo & imask.phys_lo; | 616 | lo = pregs->phys_lo & imask->phys_lo; |
| 607 | irq = interrupt & imask.interrupt; | 617 | irq = interrupt & imask->interrupt; |
| 608 | 618 | ||
| 609 | for (i = 0; i < num_imap; i++) { | 619 | for (i = 0; i < num_imap; i++) { |
| 610 | if (imap[i].phys_hi == hi && | 620 | if (imap[i].phys_hi == hi && |
| 611 | imap[i].phys_mid == mid && | 621 | imap[i].phys_mid == mid && |
| 612 | imap[i].phys_lo == lo && | 622 | imap[i].phys_lo == lo && |
| 613 | imap[i].interrupt == irq) { | 623 | imap[i].interrupt == irq) { |
| 614 | *cnode = imap[i].cnode; | 624 | *cnode = of_find_node_by_phandle(imap[i].cnode); |
| 615 | interrupt = imap[i].cinterrupt; | 625 | interrupt = imap[i].cinterrupt; |
| 616 | } | 626 | } |
| 617 | } | 627 | } |
| 618 | 628 | ||
| 619 | printk("%s: %s MAP BUS %s DEV %s [%x] -> [%x]\n", | 629 | if (pci_irq_verbose) |
| 620 | pbm->name, pci_name(toplevel_pdev), | 630 | printk("%s: %s MAP BUS %s DEV %s [%x] -> [%x]\n", |
| 621 | pci_name(pbus), pci_name(pdev), | 631 | pbm->name, pci_name(toplevel_pdev), |
| 622 | orig_interrupt, interrupt); | 632 | pci_name(pbus), pci_name(pdev), |
| 633 | orig_interrupt, interrupt); | ||
| 623 | 634 | ||
| 624 | no_intmap: | 635 | no_intmap: |
| 625 | return interrupt; | 636 | return interrupt; |
| @@ -633,21 +644,22 @@ no_intmap: | |||
| 633 | * all interrupt translations are complete, else we should use that node's | 644 | * all interrupt translations are complete, else we should use that node's |
| 634 | * "reg" property to apply the PBM's "interrupt-{map,mask}" to the interrupt. | 645 | * "reg" property to apply the PBM's "interrupt-{map,mask}" to the interrupt. |
| 635 | */ | 646 | */ |
| 636 | static unsigned int __init pci_intmap_match_to_root(struct pci_pbm_info *pbm, | 647 | static struct device_node * __init |
| 637 | struct pci_dev *pdev, | 648 | pci_intmap_match_to_root(struct pci_pbm_info *pbm, |
| 638 | unsigned int *interrupt) | 649 | struct pci_dev *pdev, |
| 650 | unsigned int *interrupt) | ||
| 639 | { | 651 | { |
| 640 | struct pci_dev *toplevel_pdev = pdev; | 652 | struct pci_dev *toplevel_pdev = pdev; |
| 641 | struct pcidev_cookie *toplevel_pcp = toplevel_pdev->sysdata; | 653 | struct pcidev_cookie *toplevel_pcp = toplevel_pdev->sysdata; |
| 642 | unsigned int cnode = toplevel_pcp->prom_node; | 654 | struct device_node *cnode = toplevel_pcp->prom_node; |
| 643 | 655 | ||
| 644 | while (pdev->bus->number != pbm->pci_first_busno) { | 656 | while (pdev->bus->number != pbm->pci_first_busno) { |
| 645 | struct pci_dev *pbus = pdev->bus->self; | 657 | struct pci_dev *pbus = pdev->bus->self; |
| 646 | struct pcidev_cookie *pcp = pbus->sysdata; | 658 | struct pcidev_cookie *pcp = pbus->sysdata; |
| 647 | int plen; | 659 | struct property *prop; |
| 648 | 660 | ||
| 649 | plen = prom_getproplen(pcp->prom_node, "interrupt-map"); | 661 | prop = of_find_property(pcp->prom_node, "interrupt-map", NULL); |
| 650 | if (plen <= 0) { | 662 | if (!prop) { |
| 651 | *interrupt = pci_slot_swivel(pbm, toplevel_pdev, | 663 | *interrupt = pci_slot_swivel(pbm, toplevel_pdev, |
| 652 | pdev, *interrupt); | 664 | pdev, *interrupt); |
| 653 | cnode = pcp->prom_node; | 665 | cnode = pcp->prom_node; |
| @@ -675,26 +687,29 @@ static int __init pci_intmap_match(struct pci_dev *pdev, unsigned int *interrupt | |||
| 675 | { | 687 | { |
| 676 | struct pcidev_cookie *dev_pcp = pdev->sysdata; | 688 | struct pcidev_cookie *dev_pcp = pdev->sysdata; |
| 677 | struct pci_pbm_info *pbm = dev_pcp->pbm; | 689 | struct pci_pbm_info *pbm = dev_pcp->pbm; |
| 678 | struct linux_prom_pci_registers reg[PROMREG_MAX]; | 690 | struct linux_prom_pci_registers *reg; |
| 691 | struct device_node *cnode; | ||
| 692 | struct property *prop; | ||
| 679 | unsigned int hi, mid, lo, irq; | 693 | unsigned int hi, mid, lo, irq; |
| 680 | int i, cnode, plen; | 694 | int i, plen; |
| 681 | 695 | ||
| 682 | cnode = pci_intmap_match_to_root(pbm, pdev, interrupt); | 696 | cnode = pci_intmap_match_to_root(pbm, pdev, interrupt); |
| 683 | if (cnode == pbm->prom_node) | 697 | if (cnode == pbm->prom_node) |
| 684 | goto success; | 698 | goto success; |
| 685 | 699 | ||
| 686 | plen = prom_getproperty(cnode, "reg", (char *) reg, sizeof(reg)); | 700 | prop = of_find_property(cnode, "reg", &plen); |
| 687 | if (plen <= 0 || | 701 | if (!prop || |
| 688 | (plen % sizeof(struct linux_prom_pci_registers)) != 0) { | 702 | (plen % sizeof(struct linux_prom_pci_registers)) != 0) { |
| 689 | printk("%s: OBP node %x reg property has bad len %d\n", | 703 | printk("%s: OBP node %s reg property has bad len %d\n", |
| 690 | pbm->name, cnode, plen); | 704 | pbm->name, cnode->full_name, plen); |
| 691 | goto fail; | 705 | goto fail; |
| 692 | } | 706 | } |
| 707 | reg = prop->value; | ||
| 693 | 708 | ||
| 694 | hi = reg[0].phys_hi & pbm->pbm_intmask.phys_hi; | 709 | hi = reg[0].phys_hi & pbm->pbm_intmask->phys_hi; |
| 695 | mid = reg[0].phys_mid & pbm->pbm_intmask.phys_mid; | 710 | mid = reg[0].phys_mid & pbm->pbm_intmask->phys_mid; |
| 696 | lo = reg[0].phys_lo & pbm->pbm_intmask.phys_lo; | 711 | lo = reg[0].phys_lo & pbm->pbm_intmask->phys_lo; |
| 697 | irq = *interrupt & pbm->pbm_intmask.interrupt; | 712 | irq = *interrupt & pbm->pbm_intmask->interrupt; |
| 698 | 713 | ||
| 699 | for (i = 0; i < pbm->num_pbm_intmap; i++) { | 714 | for (i = 0; i < pbm->num_pbm_intmap; i++) { |
| 700 | struct linux_prom_pci_intmap *intmap; | 715 | struct linux_prom_pci_intmap *intmap; |
| @@ -714,9 +729,11 @@ fail: | |||
| 714 | return 0; | 729 | return 0; |
| 715 | 730 | ||
| 716 | success: | 731 | success: |
| 717 | printk("PCI-IRQ: Routing bus[%2x] slot[%2x] to INO[%02x]\n", | 732 | if (pci_irq_verbose) |
| 718 | pdev->bus->number, PCI_SLOT(pdev->devfn), | 733 | printk("%s: Routing bus[%2x] slot[%2x] to INO[%02x]\n", |
| 719 | *interrupt); | 734 | pbm->name, |
| 735 | pdev->bus->number, PCI_SLOT(pdev->devfn), | ||
| 736 | *interrupt); | ||
| 720 | return 1; | 737 | return 1; |
| 721 | } | 738 | } |
| 722 | 739 | ||
| @@ -727,8 +744,8 @@ static void __init pdev_fixup_irq(struct pci_dev *pdev) | |||
| 727 | struct pci_controller_info *p = pbm->parent; | 744 | struct pci_controller_info *p = pbm->parent; |
| 728 | unsigned int portid = pbm->portid; | 745 | unsigned int portid = pbm->portid; |
| 729 | unsigned int prom_irq; | 746 | unsigned int prom_irq; |
| 730 | int prom_node = pcp->prom_node; | 747 | struct device_node *dp = pcp->prom_node; |
| 731 | int err; | 748 | struct property *prop; |
| 732 | 749 | ||
| 733 | /* If this is an empty EBUS device, sometimes OBP fails to | 750 | /* If this is an empty EBUS device, sometimes OBP fails to |
| 734 | * give it a valid fully specified interrupts property. | 751 | * give it a valid fully specified interrupts property. |
| @@ -739,17 +756,17 @@ static void __init pdev_fixup_irq(struct pci_dev *pdev) | |||
| 739 | */ | 756 | */ |
| 740 | if (pdev->vendor == PCI_VENDOR_ID_SUN && | 757 | if (pdev->vendor == PCI_VENDOR_ID_SUN && |
| 741 | pdev->device == PCI_DEVICE_ID_SUN_EBUS && | 758 | pdev->device == PCI_DEVICE_ID_SUN_EBUS && |
| 742 | !prom_getchild(prom_node)) { | 759 | !dp->child) { |
| 743 | pdev->irq = 0; | 760 | pdev->irq = 0; |
| 744 | return; | 761 | return; |
| 745 | } | 762 | } |
| 746 | 763 | ||
| 747 | err = prom_getproperty(prom_node, "interrupts", | 764 | prop = of_find_property(dp, "interrupts", NULL); |
| 748 | (char *)&prom_irq, sizeof(prom_irq)); | 765 | if (!prop) { |
| 749 | if (err == 0 || err == -1) { | ||
| 750 | pdev->irq = 0; | 766 | pdev->irq = 0; |
| 751 | return; | 767 | return; |
| 752 | } | 768 | } |
| 769 | prom_irq = *(unsigned int *) prop->value; | ||
| 753 | 770 | ||
| 754 | if (tlb_type != hypervisor) { | 771 | if (tlb_type != hypervisor) { |
| 755 | /* Fully specified already? */ | 772 | /* Fully specified already? */ |
diff --git a/arch/sparc64/kernel/pci_impl.h b/arch/sparc64/kernel/pci_impl.h index 6c3205962544..971e2bea30b4 100644 --- a/arch/sparc64/kernel/pci_impl.h +++ b/arch/sparc64/kernel/pci_impl.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
| 11 | #include <linux/spinlock.h> | 11 | #include <linux/spinlock.h> |
| 12 | #include <asm/io.h> | 12 | #include <asm/io.h> |
| 13 | #include <asm/prom.h> | ||
| 13 | 14 | ||
| 14 | extern struct pci_controller_info *pci_controller_root; | 15 | extern struct pci_controller_info *pci_controller_root; |
| 15 | 16 | ||
| @@ -19,7 +20,7 @@ extern int pci_num_controllers; | |||
| 19 | extern void pci_fixup_host_bridge_self(struct pci_bus *pbus); | 20 | extern void pci_fixup_host_bridge_self(struct pci_bus *pbus); |
| 20 | extern void pci_fill_in_pbm_cookies(struct pci_bus *pbus, | 21 | extern void pci_fill_in_pbm_cookies(struct pci_bus *pbus, |
| 21 | struct pci_pbm_info *pbm, | 22 | struct pci_pbm_info *pbm, |
| 22 | int prom_node); | 23 | struct device_node *prom_node); |
| 23 | extern void pci_record_assignments(struct pci_pbm_info *pbm, | 24 | extern void pci_record_assignments(struct pci_pbm_info *pbm, |
| 24 | struct pci_bus *pbus); | 25 | struct pci_bus *pbus); |
| 25 | extern void pci_assign_unassigned(struct pci_pbm_info *pbm, | 26 | extern void pci_assign_unassigned(struct pci_pbm_info *pbm, |
diff --git a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c index 24db22aa9728..5b2261ebda6f 100644 --- a/arch/sparc64/kernel/pci_psycho.c +++ b/arch/sparc64/kernel/pci_psycho.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <asm/iommu.h> | 17 | #include <asm/iommu.h> |
| 18 | #include <asm/irq.h> | 18 | #include <asm/irq.h> |
| 19 | #include <asm/starfire.h> | 19 | #include <asm/starfire.h> |
| 20 | #include <asm/prom.h> | ||
| 20 | 21 | ||
| 21 | #include "pci_impl.h" | 22 | #include "pci_impl.h" |
| 22 | #include "iommu_common.h" | 23 | #include "iommu_common.h" |
| @@ -1291,11 +1292,12 @@ static void psycho_pbm_strbuf_init(struct pci_controller_info *p, | |||
| 1291 | #define PSYCHO_MEMSPACE_SIZE 0x07fffffffUL | 1292 | #define PSYCHO_MEMSPACE_SIZE 0x07fffffffUL |
| 1292 | 1293 | ||
| 1293 | static void psycho_pbm_init(struct pci_controller_info *p, | 1294 | static void psycho_pbm_init(struct pci_controller_info *p, |
| 1294 | int prom_node, int is_pbm_a) | 1295 | struct device_node *dp, int is_pbm_a) |
| 1295 | { | 1296 | { |
| 1296 | unsigned int busrange[2]; | 1297 | unsigned int *busrange; |
| 1298 | struct property *prop; | ||
| 1297 | struct pci_pbm_info *pbm; | 1299 | struct pci_pbm_info *pbm; |
| 1298 | int err; | 1300 | int len; |
| 1299 | 1301 | ||
| 1300 | if (is_pbm_a) { | 1302 | if (is_pbm_a) { |
| 1301 | pbm = &p->pbm_A; | 1303 | pbm = &p->pbm_A; |
| @@ -1310,10 +1312,14 @@ static void psycho_pbm_init(struct pci_controller_info *p, | |||
| 1310 | } | 1312 | } |
| 1311 | 1313 | ||
| 1312 | pbm->chip_type = PBM_CHIP_TYPE_PSYCHO; | 1314 | pbm->chip_type = PBM_CHIP_TYPE_PSYCHO; |
| 1313 | pbm->chip_version = | 1315 | pbm->chip_version = 0; |
| 1314 | prom_getintdefault(prom_node, "version#", 0); | 1316 | prop = of_find_property(dp, "version#", NULL); |
| 1315 | pbm->chip_revision = | 1317 | if (prop) |
| 1316 | prom_getintdefault(prom_node, "module-revision#", 0); | 1318 | pbm->chip_version = *(int *) prop->value; |
| 1319 | pbm->chip_revision = 0; | ||
| 1320 | prop = of_find_property(dp, "module-revision#", NULL); | ||
| 1321 | if (prop) | ||
| 1322 | pbm->chip_revision = *(int *) prop->value; | ||
| 1317 | 1323 | ||
| 1318 | pbm->io_space.end = pbm->io_space.start + PSYCHO_IOSPACE_SIZE; | 1324 | pbm->io_space.end = pbm->io_space.start + PSYCHO_IOSPACE_SIZE; |
| 1319 | pbm->io_space.flags = IORESOURCE_IO; | 1325 | pbm->io_space.flags = IORESOURCE_IO; |
| @@ -1322,45 +1328,36 @@ static void psycho_pbm_init(struct pci_controller_info *p, | |||
| 1322 | pbm_register_toplevel_resources(p, pbm); | 1328 | pbm_register_toplevel_resources(p, pbm); |
| 1323 | 1329 | ||
| 1324 | pbm->parent = p; | 1330 | pbm->parent = p; |
| 1325 | pbm->prom_node = prom_node; | 1331 | pbm->prom_node = dp; |
| 1326 | prom_getstring(prom_node, "name", | 1332 | pbm->name = dp->full_name; |
| 1327 | pbm->prom_name, | 1333 | |
| 1328 | sizeof(pbm->prom_name)); | 1334 | printk("%s: PSYCHO PCI Bus Module ver[%x:%x]\n", |
| 1329 | 1335 | pbm->name, | |
| 1330 | err = prom_getproperty(prom_node, "ranges", | 1336 | pbm->chip_version, pbm->chip_revision); |
| 1331 | (char *)pbm->pbm_ranges, | 1337 | |
| 1332 | sizeof(pbm->pbm_ranges)); | 1338 | prop = of_find_property(dp, "ranges", &len); |
| 1333 | if (err != -1) | 1339 | if (prop) { |
| 1340 | pbm->pbm_ranges = prop->value; | ||
| 1334 | pbm->num_pbm_ranges = | 1341 | pbm->num_pbm_ranges = |
| 1335 | (err / sizeof(struct linux_prom_pci_ranges)); | 1342 | (len / sizeof(struct linux_prom_pci_ranges)); |
| 1336 | else | 1343 | } else { |
| 1337 | pbm->num_pbm_ranges = 0; | 1344 | pbm->num_pbm_ranges = 0; |
| 1345 | } | ||
| 1338 | 1346 | ||
| 1339 | err = prom_getproperty(prom_node, "interrupt-map", | 1347 | prop = of_find_property(dp, "interrupt-map", &len); |
| 1340 | (char *)pbm->pbm_intmap, | 1348 | if (prop) { |
| 1341 | sizeof(pbm->pbm_intmap)); | 1349 | pbm->pbm_intmap = prop->value; |
| 1342 | if (err != -1) { | 1350 | pbm->num_pbm_intmap = |
| 1343 | pbm->num_pbm_intmap = (err / sizeof(struct linux_prom_pci_intmap)); | 1351 | (len / sizeof(struct linux_prom_pci_intmap)); |
| 1344 | err = prom_getproperty(prom_node, "interrupt-map-mask", | 1352 | |
| 1345 | (char *)&pbm->pbm_intmask, | 1353 | prop = of_find_property(dp, "interrupt-map-mask", NULL); |
| 1346 | sizeof(pbm->pbm_intmask)); | 1354 | pbm->pbm_intmask = prop->value; |
| 1347 | if (err == -1) { | ||
| 1348 | prom_printf("PSYCHO-PBM: Fatal error, no " | ||
| 1349 | "interrupt-map-mask.\n"); | ||
| 1350 | prom_halt(); | ||
| 1351 | } | ||
| 1352 | } else { | 1355 | } else { |
| 1353 | pbm->num_pbm_intmap = 0; | 1356 | pbm->num_pbm_intmap = 0; |
| 1354 | memset(&pbm->pbm_intmask, 0, sizeof(pbm->pbm_intmask)); | ||
| 1355 | } | 1357 | } |
| 1356 | 1358 | ||
| 1357 | err = prom_getproperty(prom_node, "bus-range", | 1359 | prop = of_find_property(dp, "bus-range", NULL); |
| 1358 | (char *)&busrange[0], | 1360 | busrange = prop->value; |
| 1359 | sizeof(busrange)); | ||
| 1360 | if (err == 0 || err == -1) { | ||
| 1361 | prom_printf("PSYCHO-PBM: Fatal error, no bus-range.\n"); | ||
| 1362 | prom_halt(); | ||
| 1363 | } | ||
| 1364 | pbm->pci_first_busno = busrange[0]; | 1361 | pbm->pci_first_busno = busrange[0]; |
| 1365 | pbm->pci_last_busno = busrange[1]; | 1362 | pbm->pci_last_busno = busrange[1]; |
| 1366 | 1363 | ||
| @@ -1369,20 +1366,24 @@ static void psycho_pbm_init(struct pci_controller_info *p, | |||
| 1369 | 1366 | ||
| 1370 | #define PSYCHO_CONFIGSPACE 0x001000000UL | 1367 | #define PSYCHO_CONFIGSPACE 0x001000000UL |
| 1371 | 1368 | ||
| 1372 | void psycho_init(int node, char *model_name) | 1369 | void psycho_init(struct device_node *dp, char *model_name) |
| 1373 | { | 1370 | { |
| 1374 | struct linux_prom64_registers pr_regs[3]; | 1371 | struct linux_prom64_registers *pr_regs; |
| 1375 | struct pci_controller_info *p; | 1372 | struct pci_controller_info *p; |
| 1376 | struct pci_iommu *iommu; | 1373 | struct pci_iommu *iommu; |
| 1374 | struct property *prop; | ||
| 1377 | u32 upa_portid; | 1375 | u32 upa_portid; |
| 1378 | int is_pbm_a, err; | 1376 | int is_pbm_a; |
| 1379 | 1377 | ||
| 1380 | upa_portid = prom_getintdefault(node, "upa-portid", 0xff); | 1378 | upa_portid = 0xff; |
| 1379 | prop = of_find_property(dp, "upa-portid", NULL); | ||
| 1380 | if (prop) | ||
| 1381 | upa_portid = *(u32 *) prop->value; | ||
| 1381 | 1382 | ||
| 1382 | for(p = pci_controller_root; p; p = p->next) { | 1383 | for(p = pci_controller_root; p; p = p->next) { |
| 1383 | if (p->pbm_A.portid == upa_portid) { | 1384 | if (p->pbm_A.portid == upa_portid) { |
| 1384 | is_pbm_a = (p->pbm_A.prom_node == 0); | 1385 | is_pbm_a = (p->pbm_A.prom_node == NULL); |
| 1385 | psycho_pbm_init(p, node, is_pbm_a); | 1386 | psycho_pbm_init(p, dp, is_pbm_a); |
| 1386 | return; | 1387 | return; |
| 1387 | } | 1388 | } |
| 1388 | } | 1389 | } |
| @@ -1412,23 +1413,14 @@ void psycho_init(int node, char *model_name) | |||
| 1412 | p->resource_adjust = psycho_resource_adjust; | 1413 | p->resource_adjust = psycho_resource_adjust; |
| 1413 | p->pci_ops = &psycho_ops; | 1414 | p->pci_ops = &psycho_ops; |
| 1414 | 1415 | ||
| 1415 | err = prom_getproperty(node, "reg", | 1416 | prop = of_find_property(dp, "reg", NULL); |
| 1416 | (char *)&pr_regs[0], | 1417 | pr_regs = prop->value; |
| 1417 | sizeof(pr_regs)); | ||
| 1418 | if (err == 0 || err == -1) { | ||
| 1419 | prom_printf("PSYCHO: Fatal error, no reg property.\n"); | ||
| 1420 | prom_halt(); | ||
| 1421 | } | ||
| 1422 | 1418 | ||
| 1423 | p->pbm_A.controller_regs = pr_regs[2].phys_addr; | 1419 | p->pbm_A.controller_regs = pr_regs[2].phys_addr; |
| 1424 | p->pbm_B.controller_regs = pr_regs[2].phys_addr; | 1420 | p->pbm_B.controller_regs = pr_regs[2].phys_addr; |
| 1425 | printk("PCI: Found PSYCHO, control regs at %016lx\n", | ||
| 1426 | p->pbm_A.controller_regs); | ||
| 1427 | 1421 | ||
| 1428 | p->pbm_A.config_space = p->pbm_B.config_space = | 1422 | p->pbm_A.config_space = p->pbm_B.config_space = |
| 1429 | (pr_regs[2].phys_addr + PSYCHO_CONFIGSPACE); | 1423 | (pr_regs[2].phys_addr + PSYCHO_CONFIGSPACE); |
| 1430 | printk("PSYCHO: Shared PCI config space at %016lx\n", | ||
| 1431 | p->pbm_A.config_space); | ||
| 1432 | 1424 | ||
| 1433 | /* | 1425 | /* |
| 1434 | * Psycho's PCI MEM space is mapped to a 2GB aligned area, so | 1426 | * Psycho's PCI MEM space is mapped to a 2GB aligned area, so |
| @@ -1441,5 +1433,5 @@ void psycho_init(int node, char *model_name) | |||
| 1441 | psycho_iommu_init(p); | 1433 | psycho_iommu_init(p); |
| 1442 | 1434 | ||
| 1443 | is_pbm_a = ((pr_regs[0].phys_addr & 0x6000) == 0x2000); | 1435 | is_pbm_a = ((pr_regs[0].phys_addr & 0x6000) == 0x2000); |
| 1444 | psycho_pbm_init(p, node, is_pbm_a); | 1436 | psycho_pbm_init(p, dp, is_pbm_a); |
| 1445 | } | 1437 | } |
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c index b7d997b55f0a..26f194ce4400 100644 --- a/arch/sparc64/kernel/pci_sabre.c +++ b/arch/sparc64/kernel/pci_sabre.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <asm/irq.h> | 19 | #include <asm/irq.h> |
| 20 | #include <asm/smp.h> | 20 | #include <asm/smp.h> |
| 21 | #include <asm/oplib.h> | 21 | #include <asm/oplib.h> |
| 22 | #include <asm/prom.h> | ||
| 22 | 23 | ||
| 23 | #include "pci_impl.h" | 24 | #include "pci_impl.h" |
| 24 | #include "iommu_common.h" | 25 | #include "iommu_common.h" |
| @@ -1306,34 +1307,36 @@ static void pbm_register_toplevel_resources(struct pci_controller_info *p, | |||
| 1306 | &pbm->mem_space); | 1307 | &pbm->mem_space); |
| 1307 | } | 1308 | } |
| 1308 | 1309 | ||
| 1309 | static void sabre_pbm_init(struct pci_controller_info *p, int sabre_node, u32 dma_begin) | 1310 | static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp, u32 dma_begin) |
| 1310 | { | 1311 | { |
| 1311 | struct pci_pbm_info *pbm; | 1312 | struct pci_pbm_info *pbm; |
| 1312 | char namebuf[128]; | 1313 | struct device_node *node; |
| 1313 | u32 busrange[2]; | 1314 | struct property *prop; |
| 1314 | int node, simbas_found; | 1315 | u32 *busrange; |
| 1316 | int len, simbas_found; | ||
| 1315 | 1317 | ||
| 1316 | simbas_found = 0; | 1318 | simbas_found = 0; |
| 1317 | node = prom_getchild(sabre_node); | 1319 | node = dp->child; |
| 1318 | while ((node = prom_searchsiblings(node, "pci")) != 0) { | 1320 | while (node != NULL) { |
| 1319 | int err; | 1321 | if (strcmp(node->name, "pci")) |
| 1320 | |||
| 1321 | err = prom_getproperty(node, "model", namebuf, sizeof(namebuf)); | ||
| 1322 | if ((err <= 0) || strncmp(namebuf, "SUNW,simba", err)) | ||
| 1323 | goto next_pci; | 1322 | goto next_pci; |
| 1324 | 1323 | ||
| 1325 | err = prom_getproperty(node, "bus-range", | 1324 | prop = of_find_property(node, "model", NULL); |
| 1326 | (char *)&busrange[0], sizeof(busrange)); | 1325 | if (!prop || strncmp(prop->value, "SUNW,simba", prop->length)) |
| 1327 | if (err == 0 || err == -1) { | 1326 | goto next_pci; |
| 1328 | prom_printf("APB: Error, cannot get PCI bus-range.\n"); | ||
| 1329 | prom_halt(); | ||
| 1330 | } | ||
| 1331 | 1327 | ||
| 1332 | simbas_found++; | 1328 | simbas_found++; |
| 1329 | |||
| 1330 | prop = of_find_property(node, "bus-range", NULL); | ||
| 1331 | busrange = prop->value; | ||
| 1333 | if (busrange[0] == 1) | 1332 | if (busrange[0] == 1) |
| 1334 | pbm = &p->pbm_B; | 1333 | pbm = &p->pbm_B; |
| 1335 | else | 1334 | else |
| 1336 | pbm = &p->pbm_A; | 1335 | pbm = &p->pbm_A; |
| 1336 | |||
| 1337 | pbm->name = node->full_name; | ||
| 1338 | printk("%s: SABRE PCI Bus Module\n", pbm->name); | ||
| 1339 | |||
| 1337 | pbm->chip_type = PBM_CHIP_TYPE_SABRE; | 1340 | pbm->chip_type = PBM_CHIP_TYPE_SABRE; |
| 1338 | pbm->parent = p; | 1341 | pbm->parent = p; |
| 1339 | pbm->prom_node = node; | 1342 | pbm->prom_node = node; |
| @@ -1341,83 +1344,68 @@ static void sabre_pbm_init(struct pci_controller_info *p, int sabre_node, u32 dm | |||
| 1341 | pbm->pci_first_busno = busrange[0]; | 1344 | pbm->pci_first_busno = busrange[0]; |
| 1342 | pbm->pci_last_busno = busrange[1]; | 1345 | pbm->pci_last_busno = busrange[1]; |
| 1343 | 1346 | ||
| 1344 | prom_getstring(node, "name", pbm->prom_name, sizeof(pbm->prom_name)); | 1347 | prop = of_find_property(node, "ranges", &len); |
| 1345 | err = prom_getproperty(node, "ranges", | 1348 | if (prop) { |
| 1346 | (char *)pbm->pbm_ranges, | 1349 | pbm->pbm_ranges = prop->value; |
| 1347 | sizeof(pbm->pbm_ranges)); | ||
| 1348 | if (err != -1) | ||
| 1349 | pbm->num_pbm_ranges = | 1350 | pbm->num_pbm_ranges = |
| 1350 | (err / sizeof(struct linux_prom_pci_ranges)); | 1351 | (len / sizeof(struct linux_prom_pci_ranges)); |
| 1351 | else | 1352 | } else { |
| 1352 | pbm->num_pbm_ranges = 0; | 1353 | pbm->num_pbm_ranges = 0; |
| 1354 | } | ||
| 1353 | 1355 | ||
| 1354 | err = prom_getproperty(node, "interrupt-map", | 1356 | prop = of_find_property(node, "interrupt-map", &len); |
| 1355 | (char *)pbm->pbm_intmap, | 1357 | if (prop) { |
| 1356 | sizeof(pbm->pbm_intmap)); | 1358 | pbm->pbm_intmap = prop->value; |
| 1357 | if (err != -1) { | 1359 | pbm->num_pbm_intmap = |
| 1358 | pbm->num_pbm_intmap = (err / sizeof(struct linux_prom_pci_intmap)); | 1360 | (len / sizeof(struct linux_prom_pci_intmap)); |
| 1359 | err = prom_getproperty(node, "interrupt-map-mask", | 1361 | |
| 1360 | (char *)&pbm->pbm_intmask, | 1362 | prop = of_find_property(node, "interrupt-map-mask", |
| 1361 | sizeof(pbm->pbm_intmask)); | 1363 | NULL); |
| 1362 | if (err == -1) { | 1364 | pbm->pbm_intmask = prop->value; |
| 1363 | prom_printf("APB: Fatal error, no interrupt-map-mask.\n"); | ||
| 1364 | prom_halt(); | ||
| 1365 | } | ||
| 1366 | } else { | 1365 | } else { |
| 1367 | pbm->num_pbm_intmap = 0; | 1366 | pbm->num_pbm_intmap = 0; |
| 1368 | memset(&pbm->pbm_intmask, 0, sizeof(pbm->pbm_intmask)); | ||
| 1369 | } | 1367 | } |
| 1370 | 1368 | ||
| 1371 | pbm_register_toplevel_resources(p, pbm); | 1369 | pbm_register_toplevel_resources(p, pbm); |
| 1372 | 1370 | ||
| 1373 | next_pci: | 1371 | next_pci: |
| 1374 | node = prom_getsibling(node); | 1372 | node = node->sibling; |
| 1375 | if (!node) | ||
| 1376 | break; | ||
| 1377 | } | 1373 | } |
| 1378 | if (simbas_found == 0) { | 1374 | if (simbas_found == 0) { |
| 1379 | int err; | ||
| 1380 | |||
| 1381 | /* No APBs underneath, probably this is a hummingbird | 1375 | /* No APBs underneath, probably this is a hummingbird |
| 1382 | * system. | 1376 | * system. |
| 1383 | */ | 1377 | */ |
| 1384 | pbm = &p->pbm_A; | 1378 | pbm = &p->pbm_A; |
| 1385 | pbm->parent = p; | 1379 | pbm->parent = p; |
| 1386 | pbm->prom_node = sabre_node; | 1380 | pbm->prom_node = dp; |
| 1387 | pbm->pci_first_busno = p->pci_first_busno; | 1381 | pbm->pci_first_busno = p->pci_first_busno; |
| 1388 | pbm->pci_last_busno = p->pci_last_busno; | 1382 | pbm->pci_last_busno = p->pci_last_busno; |
| 1389 | 1383 | ||
| 1390 | prom_getstring(sabre_node, "name", pbm->prom_name, sizeof(pbm->prom_name)); | 1384 | prop = of_find_property(dp, "ranges", &len); |
| 1391 | err = prom_getproperty(sabre_node, "ranges", | 1385 | if (prop) { |
| 1392 | (char *) pbm->pbm_ranges, | 1386 | pbm->pbm_ranges = prop->value; |
| 1393 | sizeof(pbm->pbm_ranges)); | ||
| 1394 | if (err != -1) | ||
| 1395 | pbm->num_pbm_ranges = | 1387 | pbm->num_pbm_ranges = |
| 1396 | (err / sizeof(struct linux_prom_pci_ranges)); | 1388 | (len / sizeof(struct linux_prom_pci_ranges)); |
| 1397 | else | 1389 | } else { |
| 1398 | pbm->num_pbm_ranges = 0; | 1390 | pbm->num_pbm_ranges = 0; |
| 1391 | } | ||
| 1399 | 1392 | ||
| 1400 | err = prom_getproperty(sabre_node, "interrupt-map", | 1393 | prop = of_find_property(dp, "interrupt-map", &len); |
| 1401 | (char *) pbm->pbm_intmap, | 1394 | if (prop) { |
| 1402 | sizeof(pbm->pbm_intmap)); | 1395 | pbm->pbm_intmap = prop->value; |
| 1403 | 1396 | pbm->num_pbm_intmap = | |
| 1404 | if (err != -1) { | 1397 | (len / sizeof(struct linux_prom_pci_intmap)); |
| 1405 | pbm->num_pbm_intmap = (err / sizeof(struct linux_prom_pci_intmap)); | 1398 | |
| 1406 | err = prom_getproperty(sabre_node, "interrupt-map-mask", | 1399 | prop = of_find_property(dp, "interrupt-map-mask", |
| 1407 | (char *)&pbm->pbm_intmask, | 1400 | NULL); |
| 1408 | sizeof(pbm->pbm_intmask)); | 1401 | pbm->pbm_intmask = prop->value; |
| 1409 | if (err == -1) { | ||
| 1410 | prom_printf("Hummingbird: Fatal error, no interrupt-map-mask.\n"); | ||
| 1411 | prom_halt(); | ||
| 1412 | } | ||
| 1413 | } else { | 1402 | } else { |
| 1414 | pbm->num_pbm_intmap = 0; | 1403 | pbm->num_pbm_intmap = 0; |
| 1415 | memset(&pbm->pbm_intmask, 0, sizeof(pbm->pbm_intmask)); | ||
| 1416 | } | 1404 | } |
| 1417 | 1405 | ||
| 1406 | pbm->name = dp->full_name; | ||
| 1407 | printk("%s: SABRE PCI Bus Module\n", pbm->name); | ||
| 1418 | 1408 | ||
| 1419 | sprintf(pbm->name, "SABRE%d PBM%c", p->index, | ||
| 1420 | (pbm == &p->pbm_A ? 'A' : 'B')); | ||
| 1421 | pbm->io_space.name = pbm->mem_space.name = pbm->name; | 1409 | pbm->io_space.name = pbm->mem_space.name = pbm->name; |
| 1422 | 1410 | ||
| 1423 | /* Hack up top-level resources. */ | 1411 | /* Hack up top-level resources. */ |
| @@ -1443,14 +1431,15 @@ static void sabre_pbm_init(struct pci_controller_info *p, int sabre_node, u32 dm | |||
| 1443 | } | 1431 | } |
| 1444 | } | 1432 | } |
| 1445 | 1433 | ||
| 1446 | void sabre_init(int pnode, char *model_name) | 1434 | void sabre_init(struct device_node *dp, char *model_name) |
| 1447 | { | 1435 | { |
| 1448 | struct linux_prom64_registers pr_regs[2]; | 1436 | struct linux_prom64_registers *pr_regs; |
| 1449 | struct pci_controller_info *p; | 1437 | struct pci_controller_info *p; |
| 1450 | struct pci_iommu *iommu; | 1438 | struct pci_iommu *iommu; |
| 1451 | int tsbsize, err; | 1439 | struct property *prop; |
| 1452 | u32 busrange[2]; | 1440 | int tsbsize; |
| 1453 | u32 vdma[2]; | 1441 | u32 *busrange; |
| 1442 | u32 *vdma; | ||
| 1454 | u32 upa_portid, dma_mask; | 1443 | u32 upa_portid, dma_mask; |
| 1455 | u64 clear_irq; | 1444 | u64 clear_irq; |
| 1456 | 1445 | ||
| @@ -1458,22 +1447,21 @@ void sabre_init(int pnode, char *model_name) | |||
| 1458 | if (!strcmp(model_name, "pci108e,a001")) | 1447 | if (!strcmp(model_name, "pci108e,a001")) |
| 1459 | hummingbird_p = 1; | 1448 | hummingbird_p = 1; |
| 1460 | else if (!strcmp(model_name, "SUNW,sabre")) { | 1449 | else if (!strcmp(model_name, "SUNW,sabre")) { |
| 1461 | char compat[64]; | 1450 | prop = of_find_property(dp, "compatible", NULL); |
| 1451 | if (prop) { | ||
| 1452 | const char *compat = prop->value; | ||
| 1462 | 1453 | ||
| 1463 | if (prom_getproperty(pnode, "compatible", | 1454 | if (!strcmp(compat, "pci108e,a001")) |
| 1464 | compat, sizeof(compat)) > 0 && | 1455 | hummingbird_p = 1; |
| 1465 | !strcmp(compat, "pci108e,a001")) { | 1456 | } |
| 1466 | hummingbird_p = 1; | 1457 | if (!hummingbird_p) { |
| 1467 | } else { | 1458 | struct device_node *dp; |
| 1468 | int cpu_node; | ||
| 1469 | 1459 | ||
| 1470 | /* Of course, Sun has to encode things a thousand | 1460 | /* Of course, Sun has to encode things a thousand |
| 1471 | * different ways, inconsistently. | 1461 | * different ways, inconsistently. |
| 1472 | */ | 1462 | */ |
| 1473 | cpu_find_by_instance(0, &cpu_node, NULL); | 1463 | cpu_find_by_instance(0, &dp, NULL); |
| 1474 | if (prom_getproperty(cpu_node, "name", | 1464 | if (!strcmp(dp->name, "SUNW,UltraSPARC-IIe")) |
| 1475 | compat, sizeof(compat)) > 0 && | ||
| 1476 | !strcmp(compat, "SUNW,UltraSPARC-IIe")) | ||
| 1477 | hummingbird_p = 1; | 1465 | hummingbird_p = 1; |
| 1478 | } | 1466 | } |
| 1479 | } | 1467 | } |
| @@ -1491,7 +1479,10 @@ void sabre_init(int pnode, char *model_name) | |||
| 1491 | } | 1479 | } |
| 1492 | p->pbm_A.iommu = p->pbm_B.iommu = iommu; | 1480 | p->pbm_A.iommu = p->pbm_B.iommu = iommu; |
| 1493 | 1481 | ||
| 1494 | upa_portid = prom_getintdefault(pnode, "upa-portid", 0xff); | 1482 | upa_portid = 0xff; |
| 1483 | prop = of_find_property(dp, "upa-portid", NULL); | ||
| 1484 | if (prop) | ||
| 1485 | upa_portid = *(u32 *) prop->value; | ||
| 1495 | 1486 | ||
| 1496 | p->next = pci_controller_root; | 1487 | p->next = pci_controller_root; |
| 1497 | pci_controller_root = p; | 1488 | pci_controller_root = p; |
| @@ -1509,13 +1500,9 @@ void sabre_init(int pnode, char *model_name) | |||
| 1509 | /* | 1500 | /* |
| 1510 | * Map in SABRE register set and report the presence of this SABRE. | 1501 | * Map in SABRE register set and report the presence of this SABRE. |
| 1511 | */ | 1502 | */ |
| 1512 | err = prom_getproperty(pnode, "reg", | 1503 | |
| 1513 | (char *)&pr_regs[0], sizeof(pr_regs)); | 1504 | prop = of_find_property(dp, "reg", NULL); |
| 1514 | if(err == 0 || err == -1) { | 1505 | pr_regs = prop->value; |
| 1515 | prom_printf("SABRE: Error, cannot get U2P registers " | ||
| 1516 | "from PROM.\n"); | ||
| 1517 | prom_halt(); | ||
| 1518 | } | ||
| 1519 | 1506 | ||
| 1520 | /* | 1507 | /* |
| 1521 | * First REG in property is base of entire SABRE register space. | 1508 | * First REG in property is base of entire SABRE register space. |
| @@ -1523,9 +1510,6 @@ void sabre_init(int pnode, char *model_name) | |||
| 1523 | p->pbm_A.controller_regs = pr_regs[0].phys_addr; | 1510 | p->pbm_A.controller_regs = pr_regs[0].phys_addr; |
| 1524 | p->pbm_B.controller_regs = pr_regs[0].phys_addr; | 1511 | p->pbm_B.controller_regs = pr_regs[0].phys_addr; |
| 1525 | 1512 | ||
| 1526 | printk("PCI: Found SABRE, main regs at %016lx\n", | ||
| 1527 | p->pbm_A.controller_regs); | ||
| 1528 | |||
| 1529 | /* Clear interrupts */ | 1513 | /* Clear interrupts */ |
| 1530 | 1514 | ||
| 1531 | /* PCI first */ | 1515 | /* PCI first */ |
| @@ -1544,16 +1528,9 @@ void sabre_init(int pnode, char *model_name) | |||
| 1544 | /* Now map in PCI config space for entire SABRE. */ | 1528 | /* Now map in PCI config space for entire SABRE. */ |
| 1545 | p->pbm_A.config_space = p->pbm_B.config_space = | 1529 | p->pbm_A.config_space = p->pbm_B.config_space = |
| 1546 | (p->pbm_A.controller_regs + SABRE_CONFIGSPACE); | 1530 | (p->pbm_A.controller_regs + SABRE_CONFIGSPACE); |
| 1547 | printk("SABRE: Shared PCI config space at %016lx\n", | 1531 | |
| 1548 | p->pbm_A.config_space); | 1532 | prop = of_find_property(dp, "virtual-dma", NULL); |
| 1549 | 1533 | vdma = prop->value; | |
| 1550 | err = prom_getproperty(pnode, "virtual-dma", | ||
| 1551 | (char *)&vdma[0], sizeof(vdma)); | ||
| 1552 | if(err == 0 || err == -1) { | ||
| 1553 | prom_printf("SABRE: Error, cannot get virtual-dma property " | ||
| 1554 | "from PROM.\n"); | ||
| 1555 | prom_halt(); | ||
| 1556 | } | ||
| 1557 | 1534 | ||
| 1558 | dma_mask = vdma[0]; | 1535 | dma_mask = vdma[0]; |
| 1559 | switch(vdma[1]) { | 1536 | switch(vdma[1]) { |
| @@ -1577,21 +1554,13 @@ void sabre_init(int pnode, char *model_name) | |||
| 1577 | 1554 | ||
| 1578 | sabre_iommu_init(p, tsbsize, vdma[0], dma_mask); | 1555 | sabre_iommu_init(p, tsbsize, vdma[0], dma_mask); |
| 1579 | 1556 | ||
| 1580 | printk("SABRE: DVMA at %08x [%08x]\n", vdma[0], vdma[1]); | 1557 | prop = of_find_property(dp, "bus-range", NULL); |
| 1581 | 1558 | busrange = prop->value; | |
| 1582 | err = prom_getproperty(pnode, "bus-range", | ||
| 1583 | (char *)&busrange[0], sizeof(busrange)); | ||
| 1584 | if(err == 0 || err == -1) { | ||
| 1585 | prom_printf("SABRE: Error, cannot get PCI bus-range " | ||
| 1586 | " from PROM.\n"); | ||
| 1587 | prom_halt(); | ||
| 1588 | } | ||
| 1589 | |||
| 1590 | p->pci_first_busno = busrange[0]; | 1559 | p->pci_first_busno = busrange[0]; |
| 1591 | p->pci_last_busno = busrange[1]; | 1560 | p->pci_last_busno = busrange[1]; |
| 1592 | 1561 | ||
| 1593 | /* | 1562 | /* |
| 1594 | * Look for APB underneath. | 1563 | * Look for APB underneath. |
| 1595 | */ | 1564 | */ |
| 1596 | sabre_pbm_init(p, pnode, vdma[0]); | 1565 | sabre_pbm_init(p, dp, vdma[0]); |
| 1597 | } | 1566 | } |
diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c index cc662e915d32..f16449ccd7bc 100644 --- a/arch/sparc64/kernel/pci_schizo.c +++ b/arch/sparc64/kernel/pci_schizo.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <asm/irq.h> | 16 | #include <asm/irq.h> |
| 17 | #include <asm/upa.h> | 17 | #include <asm/upa.h> |
| 18 | #include <asm/pstate.h> | 18 | #include <asm/pstate.h> |
| 19 | #include <asm/prom.h> | ||
| 19 | 20 | ||
| 20 | #include "pci_impl.h" | 21 | #include "pci_impl.h" |
| 21 | #include "iommu_common.h" | 22 | #include "iommu_common.h" |
| @@ -1456,10 +1457,12 @@ static void __schizo_scan_bus(struct pci_controller_info *p, | |||
| 1456 | 1457 | ||
| 1457 | pbm_config_busmastering(&p->pbm_B); | 1458 | pbm_config_busmastering(&p->pbm_B); |
| 1458 | p->pbm_B.is_66mhz_capable = | 1459 | p->pbm_B.is_66mhz_capable = |
| 1459 | prom_getbool(p->pbm_B.prom_node, "66mhz-capable"); | 1460 | (of_find_property(p->pbm_B.prom_node, "66mhz-capable", NULL) |
| 1461 | != NULL); | ||
| 1460 | pbm_config_busmastering(&p->pbm_A); | 1462 | pbm_config_busmastering(&p->pbm_A); |
| 1461 | p->pbm_A.is_66mhz_capable = | 1463 | p->pbm_A.is_66mhz_capable = |
| 1462 | prom_getbool(p->pbm_A.prom_node, "66mhz-capable"); | 1464 | (of_find_property(p->pbm_A.prom_node, "66mhz-capable", NULL) |
| 1465 | != NULL); | ||
| 1463 | pbm_scan_bus(p, &p->pbm_B); | 1466 | pbm_scan_bus(p, &p->pbm_B); |
| 1464 | pbm_scan_bus(p, &p->pbm_A); | 1467 | pbm_scan_bus(p, &p->pbm_A); |
| 1465 | 1468 | ||
| @@ -1661,13 +1664,18 @@ static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm) | |||
| 1661 | { | 1664 | { |
| 1662 | struct pci_iommu *iommu = pbm->iommu; | 1665 | struct pci_iommu *iommu = pbm->iommu; |
| 1663 | unsigned long i, tagbase, database; | 1666 | unsigned long i, tagbase, database; |
| 1667 | struct property *prop; | ||
| 1664 | u32 vdma[2], dma_mask; | 1668 | u32 vdma[2], dma_mask; |
| 1665 | u64 control; | 1669 | u64 control; |
| 1666 | int err, tsbsize; | 1670 | int tsbsize; |
| 1667 | 1671 | ||
| 1668 | err = prom_getproperty(pbm->prom_node, "virtual-dma", | 1672 | prop = of_find_property(pbm->prom_node, "virtual-dma", NULL); |
| 1669 | (char *)&vdma[0], sizeof(vdma)); | 1673 | if (prop) { |
| 1670 | if (err == 0 || err == -1) { | 1674 | u32 *val = prop->value; |
| 1675 | |||
| 1676 | vdma[0] = val[0]; | ||
| 1677 | vdma[1] = val[1]; | ||
| 1678 | } else { | ||
| 1671 | /* No property, use default values. */ | 1679 | /* No property, use default values. */ |
| 1672 | vdma[0] = 0xc0000000; | 1680 | vdma[0] = 0xc0000000; |
| 1673 | vdma[1] = 0x40000000; | 1681 | vdma[1] = 0x40000000; |
| @@ -1778,6 +1786,7 @@ static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm) | |||
| 1778 | 1786 | ||
| 1779 | static void schizo_pbm_hw_init(struct pci_pbm_info *pbm) | 1787 | static void schizo_pbm_hw_init(struct pci_pbm_info *pbm) |
| 1780 | { | 1788 | { |
| 1789 | struct property *prop; | ||
| 1781 | u64 tmp; | 1790 | u64 tmp; |
| 1782 | 1791 | ||
| 1783 | schizo_write(pbm->pbm_regs + SCHIZO_PCI_IRQ_RETRY, 5); | 1792 | schizo_write(pbm->pbm_regs + SCHIZO_PCI_IRQ_RETRY, 5); |
| @@ -1791,7 +1800,8 @@ static void schizo_pbm_hw_init(struct pci_pbm_info *pbm) | |||
| 1791 | pbm->chip_version >= 0x2) | 1800 | pbm->chip_version >= 0x2) |
| 1792 | tmp |= 0x3UL << SCHIZO_PCICTRL_PTO_SHIFT; | 1801 | tmp |= 0x3UL << SCHIZO_PCICTRL_PTO_SHIFT; |
| 1793 | 1802 | ||
| 1794 | if (!prom_getbool(pbm->prom_node, "no-bus-parking")) | 1803 | prop = of_find_property(pbm->prom_node, "no-bus-parking", NULL); |
| 1804 | if (!prop) | ||
| 1795 | tmp |= SCHIZO_PCICTRL_PARK; | 1805 | tmp |= SCHIZO_PCICTRL_PARK; |
| 1796 | else | 1806 | else |
| 1797 | tmp &= ~SCHIZO_PCICTRL_PARK; | 1807 | tmp &= ~SCHIZO_PCICTRL_PARK; |
| @@ -1831,16 +1841,17 @@ static void schizo_pbm_hw_init(struct pci_pbm_info *pbm) | |||
| 1831 | } | 1841 | } |
| 1832 | 1842 | ||
| 1833 | static void schizo_pbm_init(struct pci_controller_info *p, | 1843 | static void schizo_pbm_init(struct pci_controller_info *p, |
| 1834 | int prom_node, u32 portid, | 1844 | struct device_node *dp, u32 portid, |
| 1835 | int chip_type) | 1845 | int chip_type) |
| 1836 | { | 1846 | { |
| 1837 | struct linux_prom64_registers pr_regs[4]; | 1847 | struct linux_prom64_registers *regs; |
| 1838 | unsigned int busrange[2]; | 1848 | struct property *prop; |
| 1849 | unsigned int *busrange; | ||
| 1839 | struct pci_pbm_info *pbm; | 1850 | struct pci_pbm_info *pbm; |
| 1840 | const char *chipset_name; | 1851 | const char *chipset_name; |
| 1841 | u32 ino_bitmap[2]; | 1852 | u32 *ino_bitmap; |
| 1842 | int is_pbm_a; | 1853 | int is_pbm_a; |
| 1843 | int err; | 1854 | int len; |
| 1844 | 1855 | ||
| 1845 | switch (chip_type) { | 1856 | switch (chip_type) { |
| 1846 | case PBM_CHIP_TYPE_TOMATILLO: | 1857 | case PBM_CHIP_TYPE_TOMATILLO: |
| @@ -1868,16 +1879,10 @@ static void schizo_pbm_init(struct pci_controller_info *p, | |||
| 1868 | * 3) PBM PCI config space | 1879 | * 3) PBM PCI config space |
| 1869 | * 4) Ichip regs | 1880 | * 4) Ichip regs |
| 1870 | */ | 1881 | */ |
| 1871 | err = prom_getproperty(prom_node, "reg", | 1882 | prop = of_find_property(dp, "reg", NULL); |
| 1872 | (char *)&pr_regs[0], | 1883 | regs = prop->value; |
| 1873 | sizeof(pr_regs)); | ||
| 1874 | if (err == 0 || err == -1) { | ||
| 1875 | prom_printf("%s: Fatal error, no reg property.\n", | ||
| 1876 | chipset_name); | ||
| 1877 | prom_halt(); | ||
| 1878 | } | ||
| 1879 | 1884 | ||
| 1880 | is_pbm_a = ((pr_regs[0].phys_addr & 0x00700000) == 0x00600000); | 1885 | is_pbm_a = ((regs[0].phys_addr & 0x00700000) == 0x00600000); |
| 1881 | 1886 | ||
| 1882 | if (is_pbm_a) | 1887 | if (is_pbm_a) |
| 1883 | pbm = &p->pbm_A; | 1888 | pbm = &p->pbm_A; |
| @@ -1886,92 +1891,62 @@ static void schizo_pbm_init(struct pci_controller_info *p, | |||
| 1886 | 1891 | ||
| 1887 | pbm->portid = portid; | 1892 | pbm->portid = portid; |
| 1888 | pbm->parent = p; | 1893 | pbm->parent = p; |
| 1889 | pbm->prom_node = prom_node; | 1894 | pbm->prom_node = dp; |
| 1890 | pbm->pci_first_slot = 1; | 1895 | pbm->pci_first_slot = 1; |
| 1891 | 1896 | ||
| 1892 | pbm->chip_type = chip_type; | 1897 | pbm->chip_type = chip_type; |
| 1893 | pbm->chip_version = | 1898 | pbm->chip_version = 0; |
| 1894 | prom_getintdefault(prom_node, "version#", 0); | 1899 | prop = of_find_property(dp, "version#", NULL); |
| 1895 | pbm->chip_revision = | 1900 | if (prop) |
| 1896 | prom_getintdefault(prom_node, "module-revision#", 0); | 1901 | pbm->chip_version = *(int *) prop->value; |
| 1897 | 1902 | pbm->chip_revision = 0; | |
| 1898 | pbm->pbm_regs = pr_regs[0].phys_addr; | 1903 | prop = of_find_property(dp, "module-revision#", NULL); |
| 1899 | pbm->controller_regs = pr_regs[1].phys_addr - 0x10000UL; | 1904 | if (prop) |
| 1905 | pbm->chip_revision = *(int *) prop->value; | ||
| 1906 | |||
| 1907 | pbm->pbm_regs = regs[0].phys_addr; | ||
| 1908 | pbm->controller_regs = regs[1].phys_addr - 0x10000UL; | ||
| 1900 | 1909 | ||
| 1901 | if (chip_type == PBM_CHIP_TYPE_TOMATILLO) | 1910 | if (chip_type == PBM_CHIP_TYPE_TOMATILLO) |
| 1902 | pbm->sync_reg = pr_regs[3].phys_addr + 0x1a18UL; | 1911 | pbm->sync_reg = regs[3].phys_addr + 0x1a18UL; |
| 1903 | 1912 | ||
| 1904 | sprintf(pbm->name, | 1913 | pbm->name = dp->full_name; |
| 1905 | (chip_type == PBM_CHIP_TYPE_TOMATILLO ? | ||
| 1906 | "TOMATILLO%d PBM%c" : | ||
| 1907 | "SCHIZO%d PBM%c"), | ||
| 1908 | p->index, | ||
| 1909 | (pbm == &p->pbm_A ? 'A' : 'B')); | ||
| 1910 | 1914 | ||
| 1911 | printk("%s: ver[%x:%x], portid %x, " | 1915 | printk("%s: %s PCI Bus Module ver[%x:%x]\n", |
| 1912 | "cregs[%lx] pregs[%lx]\n", | ||
| 1913 | pbm->name, | 1916 | pbm->name, |
| 1914 | pbm->chip_version, pbm->chip_revision, | 1917 | (chip_type == PBM_CHIP_TYPE_TOMATILLO ? |
| 1915 | pbm->portid, | 1918 | "TOMATILLO" : "SCHIZO"), |
| 1916 | pbm->controller_regs, | 1919 | pbm->chip_version, pbm->chip_revision); |
| 1917 | pbm->pbm_regs); | ||
| 1918 | 1920 | ||
| 1919 | schizo_pbm_hw_init(pbm); | 1921 | schizo_pbm_hw_init(pbm); |
| 1920 | 1922 | ||
| 1921 | prom_getstring(prom_node, "name", | 1923 | prop = of_find_property(dp, "ranges", &len); |
| 1922 | pbm->prom_name, | 1924 | pbm->pbm_ranges = prop->value; |
| 1923 | sizeof(pbm->prom_name)); | ||
| 1924 | |||
| 1925 | err = prom_getproperty(prom_node, "ranges", | ||
| 1926 | (char *) pbm->pbm_ranges, | ||
| 1927 | sizeof(pbm->pbm_ranges)); | ||
| 1928 | if (err == 0 || err == -1) { | ||
| 1929 | prom_printf("%s: Fatal error, no ranges property.\n", | ||
| 1930 | pbm->name); | ||
| 1931 | prom_halt(); | ||
| 1932 | } | ||
| 1933 | |||
| 1934 | pbm->num_pbm_ranges = | 1925 | pbm->num_pbm_ranges = |
| 1935 | (err / sizeof(struct linux_prom_pci_ranges)); | 1926 | (len / sizeof(struct linux_prom_pci_ranges)); |
| 1936 | 1927 | ||
| 1937 | schizo_determine_mem_io_space(pbm); | 1928 | schizo_determine_mem_io_space(pbm); |
| 1938 | pbm_register_toplevel_resources(p, pbm); | 1929 | pbm_register_toplevel_resources(p, pbm); |
| 1939 | 1930 | ||
| 1940 | err = prom_getproperty(prom_node, "interrupt-map", | 1931 | prop = of_find_property(dp, "interrupt-map", &len); |
| 1941 | (char *)pbm->pbm_intmap, | 1932 | if (prop) { |
| 1942 | sizeof(pbm->pbm_intmap)); | 1933 | pbm->pbm_intmap = prop->value; |
| 1943 | if (err != -1) { | 1934 | pbm->num_pbm_intmap = |
| 1944 | pbm->num_pbm_intmap = (err / sizeof(struct linux_prom_pci_intmap)); | 1935 | (len / sizeof(struct linux_prom_pci_intmap)); |
| 1945 | err = prom_getproperty(prom_node, "interrupt-map-mask", | 1936 | |
| 1946 | (char *)&pbm->pbm_intmask, | 1937 | prop = of_find_property(dp, "interrupt-map-mask", NULL); |
| 1947 | sizeof(pbm->pbm_intmask)); | 1938 | pbm->pbm_intmask = prop->value; |
| 1948 | if (err == -1) { | ||
| 1949 | prom_printf("%s: Fatal error, no " | ||
| 1950 | "interrupt-map-mask.\n", pbm->name); | ||
| 1951 | prom_halt(); | ||
| 1952 | } | ||
| 1953 | } else { | 1939 | } else { |
| 1954 | pbm->num_pbm_intmap = 0; | 1940 | pbm->num_pbm_intmap = 0; |
| 1955 | memset(&pbm->pbm_intmask, 0, sizeof(pbm->pbm_intmask)); | ||
| 1956 | } | 1941 | } |
| 1957 | 1942 | ||
| 1958 | err = prom_getproperty(prom_node, "ino-bitmap", | 1943 | prop = of_find_property(dp, "ino-bitmap", NULL); |
| 1959 | (char *) &ino_bitmap[0], | 1944 | ino_bitmap = prop->value; |
| 1960 | sizeof(ino_bitmap)); | ||
| 1961 | if (err == 0 || err == -1) { | ||
| 1962 | prom_printf("%s: Fatal error, no ino-bitmap.\n", pbm->name); | ||
| 1963 | prom_halt(); | ||
| 1964 | } | ||
| 1965 | pbm->ino_bitmap = (((u64)ino_bitmap[1] << 32UL) | | 1945 | pbm->ino_bitmap = (((u64)ino_bitmap[1] << 32UL) | |
| 1966 | ((u64)ino_bitmap[0] << 0UL)); | 1946 | ((u64)ino_bitmap[0] << 0UL)); |
| 1967 | 1947 | ||
| 1968 | err = prom_getproperty(prom_node, "bus-range", | 1948 | prop = of_find_property(dp, "bus-range", NULL); |
| 1969 | (char *)&busrange[0], | 1949 | busrange = prop->value; |
| 1970 | sizeof(busrange)); | ||
| 1971 | if (err == 0 || err == -1) { | ||
| 1972 | prom_printf("%s: Fatal error, no bus-range.\n", pbm->name); | ||
| 1973 | prom_halt(); | ||
| 1974 | } | ||
| 1975 | pbm->pci_first_busno = busrange[0]; | 1950 | pbm->pci_first_busno = busrange[0]; |
| 1976 | pbm->pci_last_busno = busrange[1]; | 1951 | pbm->pci_last_busno = busrange[1]; |
| 1977 | 1952 | ||
| @@ -1989,16 +1964,20 @@ static inline int portid_compare(u32 x, u32 y, int chip_type) | |||
| 1989 | return (x == y); | 1964 | return (x == y); |
| 1990 | } | 1965 | } |
| 1991 | 1966 | ||
| 1992 | static void __schizo_init(int node, char *model_name, int chip_type) | 1967 | static void __schizo_init(struct device_node *dp, char *model_name, int chip_type) |
| 1993 | { | 1968 | { |
| 1994 | struct pci_controller_info *p; | 1969 | struct pci_controller_info *p; |
| 1995 | struct pci_iommu *iommu; | 1970 | struct pci_iommu *iommu; |
| 1971 | struct property *prop; | ||
| 1996 | int is_pbm_a; | 1972 | int is_pbm_a; |
| 1997 | u32 portid; | 1973 | u32 portid; |
| 1998 | 1974 | ||
| 1999 | portid = prom_getintdefault(node, "portid", 0xff); | 1975 | portid = 0xff; |
| 1976 | prop = of_find_property(dp, "portid", NULL); | ||
| 1977 | if (prop) | ||
| 1978 | portid = *(u32 *) prop->value; | ||
| 2000 | 1979 | ||
| 2001 | for(p = pci_controller_root; p; p = p->next) { | 1980 | for (p = pci_controller_root; p; p = p->next) { |
| 2002 | struct pci_pbm_info *pbm; | 1981 | struct pci_pbm_info *pbm; |
| 2003 | 1982 | ||
| 2004 | if (p->pbm_A.prom_node && p->pbm_B.prom_node) | 1983 | if (p->pbm_A.prom_node && p->pbm_B.prom_node) |
| @@ -2009,8 +1988,8 @@ static void __schizo_init(int node, char *model_name, int chip_type) | |||
| 2009 | &p->pbm_B); | 1988 | &p->pbm_B); |
| 2010 | 1989 | ||
| 2011 | if (portid_compare(pbm->portid, portid, chip_type)) { | 1990 | if (portid_compare(pbm->portid, portid, chip_type)) { |
| 2012 | is_pbm_a = (p->pbm_A.prom_node == 0); | 1991 | is_pbm_a = (p->pbm_A.prom_node == NULL); |
| 2013 | schizo_pbm_init(p, node, portid, chip_type); | 1992 | schizo_pbm_init(p, dp, portid, chip_type); |
| 2014 | return; | 1993 | return; |
| 2015 | } | 1994 | } |
| 2016 | } | 1995 | } |
| @@ -2051,20 +2030,20 @@ static void __schizo_init(int node, char *model_name, int chip_type) | |||
| 2051 | /* Like PSYCHO we have a 2GB aligned area for memory space. */ | 2030 | /* Like PSYCHO we have a 2GB aligned area for memory space. */ |
| 2052 | pci_memspace_mask = 0x7fffffffUL; | 2031 | pci_memspace_mask = 0x7fffffffUL; |
| 2053 | 2032 | ||
| 2054 | schizo_pbm_init(p, node, portid, chip_type); | 2033 | schizo_pbm_init(p, dp, portid, chip_type); |
| 2055 | } | 2034 | } |
| 2056 | 2035 | ||
| 2057 | void schizo_init(int node, char *model_name) | 2036 | void schizo_init(struct device_node *dp, char *model_name) |
| 2058 | { | 2037 | { |
| 2059 | __schizo_init(node, model_name, PBM_CHIP_TYPE_SCHIZO); | 2038 | __schizo_init(dp, model_name, PBM_CHIP_TYPE_SCHIZO); |
| 2060 | } | 2039 | } |
| 2061 | 2040 | ||
| 2062 | void schizo_plus_init(int node, char *model_name) | 2041 | void schizo_plus_init(struct device_node *dp, char *model_name) |
| 2063 | { | 2042 | { |
| 2064 | __schizo_init(node, model_name, PBM_CHIP_TYPE_SCHIZO_PLUS); | 2043 | __schizo_init(dp, model_name, PBM_CHIP_TYPE_SCHIZO_PLUS); |
| 2065 | } | 2044 | } |
| 2066 | 2045 | ||
| 2067 | void tomatillo_init(int node, char *model_name) | 2046 | void tomatillo_init(struct device_node *dp, char *model_name) |
| 2068 | { | 2047 | { |
| 2069 | __schizo_init(node, model_name, PBM_CHIP_TYPE_TOMATILLO); | 2048 | __schizo_init(dp, model_name, PBM_CHIP_TYPE_TOMATILLO); |
| 2070 | } | 2049 | } |
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c index 5419480edf41..b69e2270a721 100644 --- a/arch/sparc64/kernel/pci_sun4v.c +++ b/arch/sparc64/kernel/pci_sun4v.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <asm/pstate.h> | 18 | #include <asm/pstate.h> |
| 19 | #include <asm/oplib.h> | 19 | #include <asm/oplib.h> |
| 20 | #include <asm/hypervisor.h> | 20 | #include <asm/hypervisor.h> |
| 21 | #include <asm/prom.h> | ||
| 21 | 22 | ||
| 22 | #include "pci_impl.h" | 23 | #include "pci_impl.h" |
| 23 | #include "iommu_common.h" | 24 | #include "iommu_common.h" |
| @@ -646,35 +647,37 @@ static int pdev_htab_add(u32 devhandle, unsigned int bus, unsigned int device, u | |||
| 646 | /* Recursively descend into the OBP device tree, rooted at toplevel_node, | 647 | /* Recursively descend into the OBP device tree, rooted at toplevel_node, |
| 647 | * looking for a PCI device matching bus and devfn. | 648 | * looking for a PCI device matching bus and devfn. |
| 648 | */ | 649 | */ |
| 649 | static int obp_find(struct linux_prom_pci_registers *pregs, int toplevel_node, unsigned int bus, unsigned int devfn) | 650 | static int obp_find(struct device_node *toplevel_node, unsigned int bus, unsigned int devfn) |
| 650 | { | 651 | { |
| 651 | toplevel_node = prom_getchild(toplevel_node); | 652 | toplevel_node = toplevel_node->child; |
| 652 | 653 | ||
| 653 | while (toplevel_node != 0) { | 654 | while (toplevel_node != NULL) { |
| 654 | int ret = obp_find(pregs, toplevel_node, bus, devfn); | 655 | struct linux_prom_pci_registers *regs; |
| 656 | struct property *prop; | ||
| 657 | int ret; | ||
| 655 | 658 | ||
| 659 | ret = obp_find(toplevel_node, bus, devfn); | ||
| 656 | if (ret != 0) | 660 | if (ret != 0) |
| 657 | return ret; | 661 | return ret; |
| 658 | 662 | ||
| 659 | ret = prom_getproperty(toplevel_node, "reg", (char *) pregs, | 663 | prop = of_find_property(toplevel_node, "reg", NULL); |
| 660 | sizeof(*pregs) * PROMREG_MAX); | 664 | if (!prop) |
| 661 | if (ret == 0 || ret == -1) | ||
| 662 | goto next_sibling; | 665 | goto next_sibling; |
| 663 | 666 | ||
| 664 | if (((pregs[0].phys_hi >> 16) & 0xff) == bus && | 667 | regs = prop->value; |
| 665 | ((pregs[0].phys_hi >> 8) & 0xff) == devfn) | 668 | if (((regs->phys_hi >> 16) & 0xff) == bus && |
| 669 | ((regs->phys_hi >> 8) & 0xff) == devfn) | ||
| 666 | break; | 670 | break; |
| 667 | 671 | ||
| 668 | next_sibling: | 672 | next_sibling: |
| 669 | toplevel_node = prom_getsibling(toplevel_node); | 673 | toplevel_node = toplevel_node->sibling; |
| 670 | } | 674 | } |
| 671 | 675 | ||
| 672 | return toplevel_node; | 676 | return toplevel_node != NULL; |
| 673 | } | 677 | } |
| 674 | 678 | ||
| 675 | static int pdev_htab_populate(struct pci_pbm_info *pbm) | 679 | static int pdev_htab_populate(struct pci_pbm_info *pbm) |
| 676 | { | 680 | { |
| 677 | struct linux_prom_pci_registers pr[PROMREG_MAX]; | ||
| 678 | u32 devhandle = pbm->devhandle; | 681 | u32 devhandle = pbm->devhandle; |
| 679 | unsigned int bus; | 682 | unsigned int bus; |
| 680 | 683 | ||
| @@ -685,7 +688,7 @@ static int pdev_htab_populate(struct pci_pbm_info *pbm) | |||
| 685 | unsigned int device = PCI_SLOT(devfn); | 688 | unsigned int device = PCI_SLOT(devfn); |
| 686 | unsigned int func = PCI_FUNC(devfn); | 689 | unsigned int func = PCI_FUNC(devfn); |
| 687 | 690 | ||
| 688 | if (obp_find(pr, pbm->prom_node, bus, devfn)) { | 691 | if (obp_find(pbm->prom_node, bus, devfn)) { |
| 689 | int err = pdev_htab_add(devhandle, bus, | 692 | int err = pdev_htab_add(devhandle, bus, |
| 690 | device, func); | 693 | device, func); |
| 691 | if (err) | 694 | if (err) |
| @@ -811,8 +814,7 @@ static void pbm_scan_bus(struct pci_controller_info *p, | |||
| 811 | pci_fixup_host_bridge_self(pbm->pci_bus); | 814 | pci_fixup_host_bridge_self(pbm->pci_bus); |
| 812 | pbm->pci_bus->self->sysdata = cookie; | 815 | pbm->pci_bus->self->sysdata = cookie; |
| 813 | #endif | 816 | #endif |
| 814 | pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, | 817 | pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node); |
| 815 | pbm->prom_node); | ||
| 816 | pci_record_assignments(pbm, pbm->pci_bus); | 818 | pci_record_assignments(pbm, pbm->pci_bus); |
| 817 | pci_assign_unassigned(pbm, pbm->pci_bus); | 819 | pci_assign_unassigned(pbm, pbm->pci_bus); |
| 818 | pci_fixup_irq(pbm, pbm->pci_bus); | 820 | pci_fixup_irq(pbm, pbm->pci_bus); |
| @@ -822,15 +824,18 @@ static void pbm_scan_bus(struct pci_controller_info *p, | |||
| 822 | 824 | ||
| 823 | static void pci_sun4v_scan_bus(struct pci_controller_info *p) | 825 | static void pci_sun4v_scan_bus(struct pci_controller_info *p) |
| 824 | { | 826 | { |
| 825 | if (p->pbm_A.prom_node) { | 827 | struct property *prop; |
| 826 | p->pbm_A.is_66mhz_capable = | 828 | struct device_node *dp; |
| 827 | prom_getbool(p->pbm_A.prom_node, "66mhz-capable"); | 829 | |
| 830 | if ((dp = p->pbm_A.prom_node) != NULL) { | ||
| 831 | prop = of_find_property(dp, "66mhz-capable", NULL); | ||
| 832 | p->pbm_A.is_66mhz_capable = (prop != NULL); | ||
| 828 | 833 | ||
| 829 | pbm_scan_bus(p, &p->pbm_A); | 834 | pbm_scan_bus(p, &p->pbm_A); |
| 830 | } | 835 | } |
| 831 | if (p->pbm_B.prom_node) { | 836 | if ((dp = p->pbm_B.prom_node) != NULL) { |
| 832 | p->pbm_B.is_66mhz_capable = | 837 | prop = of_find_property(dp, "66mhz-capable", NULL); |
| 833 | prom_getbool(p->pbm_B.prom_node, "66mhz-capable"); | 838 | p->pbm_B.is_66mhz_capable = (prop != NULL); |
| 834 | 839 | ||
| 835 | pbm_scan_bus(p, &p->pbm_B); | 840 | pbm_scan_bus(p, &p->pbm_B); |
| 836 | } | 841 | } |
| @@ -982,8 +987,13 @@ static unsigned long probe_existing_entries(struct pci_pbm_info *pbm, | |||
| 982 | HV_PCI_TSBID(0, i), | 987 | HV_PCI_TSBID(0, i), |
| 983 | &io_attrs, &ra); | 988 | &io_attrs, &ra); |
| 984 | if (ret == HV_EOK) { | 989 | if (ret == HV_EOK) { |
| 985 | cnt++; | 990 | if (page_in_phys_avail(ra)) { |
| 986 | __set_bit(i, arena->map); | 991 | pci_sun4v_iommu_demap(devhandle, |
| 992 | HV_PCI_TSBID(0, i), 1); | ||
| 993 | } else { | ||
| 994 | cnt++; | ||
| 995 | __set_bit(i, arena->map); | ||
| 996 | } | ||
| 987 | } | 997 | } |
| 988 | } | 998 | } |
| 989 | 999 | ||
| @@ -993,13 +1003,18 @@ static unsigned long probe_existing_entries(struct pci_pbm_info *pbm, | |||
| 993 | static void pci_sun4v_iommu_init(struct pci_pbm_info *pbm) | 1003 | static void pci_sun4v_iommu_init(struct pci_pbm_info *pbm) |
| 994 | { | 1004 | { |
| 995 | struct pci_iommu *iommu = pbm->iommu; | 1005 | struct pci_iommu *iommu = pbm->iommu; |
| 1006 | struct property *prop; | ||
| 996 | unsigned long num_tsb_entries, sz; | 1007 | unsigned long num_tsb_entries, sz; |
| 997 | u32 vdma[2], dma_mask, dma_offset; | 1008 | u32 vdma[2], dma_mask, dma_offset; |
| 998 | int err, tsbsize; | 1009 | int tsbsize; |
| 1010 | |||
| 1011 | prop = of_find_property(pbm->prom_node, "virtual-dma", NULL); | ||
| 1012 | if (prop) { | ||
| 1013 | u32 *val = prop->value; | ||
| 999 | 1014 | ||
| 1000 | err = prom_getproperty(pbm->prom_node, "virtual-dma", | 1015 | vdma[0] = val[0]; |
| 1001 | (char *)&vdma[0], sizeof(vdma)); | 1016 | vdma[1] = val[1]; |
| 1002 | if (err == 0 || err == -1) { | 1017 | } else { |
| 1003 | /* No property, use default values. */ | 1018 | /* No property, use default values. */ |
| 1004 | vdma[0] = 0x80000000; | 1019 | vdma[0] = 0x80000000; |
| 1005 | vdma[1] = 0x80000000; | 1020 | vdma[1] = 0x80000000; |
| @@ -1051,34 +1066,30 @@ static void pci_sun4v_iommu_init(struct pci_pbm_info *pbm) | |||
| 1051 | iommu->arena.limit = num_tsb_entries; | 1066 | iommu->arena.limit = num_tsb_entries; |
| 1052 | 1067 | ||
| 1053 | sz = probe_existing_entries(pbm, iommu); | 1068 | sz = probe_existing_entries(pbm, iommu); |
| 1054 | 1069 | if (sz) | |
| 1055 | printk("%s: TSB entries [%lu], existing mapings [%lu]\n", | 1070 | printk("%s: Imported %lu TSB entries from OBP\n", |
| 1056 | pbm->name, num_tsb_entries, sz); | 1071 | pbm->name, sz); |
| 1057 | } | 1072 | } |
| 1058 | 1073 | ||
| 1059 | static void pci_sun4v_get_bus_range(struct pci_pbm_info *pbm) | 1074 | static void pci_sun4v_get_bus_range(struct pci_pbm_info *pbm) |
| 1060 | { | 1075 | { |
| 1061 | unsigned int busrange[2]; | 1076 | struct property *prop; |
| 1062 | int prom_node = pbm->prom_node; | 1077 | unsigned int *busrange; |
| 1063 | int err; | 1078 | |
| 1064 | 1079 | prop = of_find_property(pbm->prom_node, "bus-range", NULL); | |
| 1065 | err = prom_getproperty(prom_node, "bus-range", | 1080 | |
| 1066 | (char *)&busrange[0], | 1081 | busrange = prop->value; |
| 1067 | sizeof(busrange)); | ||
| 1068 | if (err == 0 || err == -1) { | ||
| 1069 | prom_printf("%s: Fatal error, no bus-range.\n", pbm->name); | ||
| 1070 | prom_halt(); | ||
| 1071 | } | ||
| 1072 | 1082 | ||
| 1073 | pbm->pci_first_busno = busrange[0]; | 1083 | pbm->pci_first_busno = busrange[0]; |
| 1074 | pbm->pci_last_busno = busrange[1]; | 1084 | pbm->pci_last_busno = busrange[1]; |
| 1075 | 1085 | ||
| 1076 | } | 1086 | } |
| 1077 | 1087 | ||
| 1078 | static void pci_sun4v_pbm_init(struct pci_controller_info *p, int prom_node, u32 devhandle) | 1088 | static void pci_sun4v_pbm_init(struct pci_controller_info *p, struct device_node *dp, u32 devhandle) |
| 1079 | { | 1089 | { |
| 1080 | struct pci_pbm_info *pbm; | 1090 | struct pci_pbm_info *pbm; |
| 1081 | int err, i; | 1091 | struct property *prop; |
| 1092 | int len, i; | ||
| 1082 | 1093 | ||
| 1083 | if (devhandle & 0x40) | 1094 | if (devhandle & 0x40) |
| 1084 | pbm = &p->pbm_B; | 1095 | pbm = &p->pbm_B; |
| @@ -1086,32 +1097,19 @@ static void pci_sun4v_pbm_init(struct pci_controller_info *p, int prom_node, u32 | |||
| 1086 | pbm = &p->pbm_A; | 1097 | pbm = &p->pbm_A; |
| 1087 | 1098 | ||
| 1088 | pbm->parent = p; | 1099 | pbm->parent = p; |
| 1089 | pbm->prom_node = prom_node; | 1100 | pbm->prom_node = dp; |
| 1090 | pbm->pci_first_slot = 1; | 1101 | pbm->pci_first_slot = 1; |
| 1091 | 1102 | ||
| 1092 | pbm->devhandle = devhandle; | 1103 | pbm->devhandle = devhandle; |
| 1093 | 1104 | ||
| 1094 | sprintf(pbm->name, "SUN4V-PCI%d PBM%c", | 1105 | pbm->name = dp->full_name; |
| 1095 | p->index, (pbm == &p->pbm_A ? 'A' : 'B')); | ||
| 1096 | 1106 | ||
| 1097 | printk("%s: devhandle[%x] prom_node[%x:%x]\n", | 1107 | printk("%s: SUN4V PCI Bus Module\n", pbm->name); |
| 1098 | pbm->name, pbm->devhandle, | ||
| 1099 | pbm->prom_node, prom_getchild(pbm->prom_node)); | ||
| 1100 | |||
| 1101 | prom_getstring(prom_node, "name", | ||
| 1102 | pbm->prom_name, sizeof(pbm->prom_name)); | ||
| 1103 | |||
| 1104 | err = prom_getproperty(prom_node, "ranges", | ||
| 1105 | (char *) pbm->pbm_ranges, | ||
| 1106 | sizeof(pbm->pbm_ranges)); | ||
| 1107 | if (err == 0 || err == -1) { | ||
| 1108 | prom_printf("%s: Fatal error, no ranges property.\n", | ||
| 1109 | pbm->name); | ||
| 1110 | prom_halt(); | ||
| 1111 | } | ||
| 1112 | 1108 | ||
| 1109 | prop = of_find_property(dp, "ranges", &len); | ||
| 1110 | pbm->pbm_ranges = prop->value; | ||
| 1113 | pbm->num_pbm_ranges = | 1111 | pbm->num_pbm_ranges = |
| 1114 | (err / sizeof(struct linux_prom_pci_ranges)); | 1112 | (len / sizeof(struct linux_prom_pci_ranges)); |
| 1115 | 1113 | ||
| 1116 | /* Mask out the top 8 bits of the ranges, leaving the real | 1114 | /* Mask out the top 8 bits of the ranges, leaving the real |
| 1117 | * physical address. | 1115 | * physical address. |
| @@ -1122,24 +1120,13 @@ static void pci_sun4v_pbm_init(struct pci_controller_info *p, int prom_node, u32 | |||
| 1122 | pci_sun4v_determine_mem_io_space(pbm); | 1120 | pci_sun4v_determine_mem_io_space(pbm); |
| 1123 | pbm_register_toplevel_resources(p, pbm); | 1121 | pbm_register_toplevel_resources(p, pbm); |
| 1124 | 1122 | ||
| 1125 | err = prom_getproperty(prom_node, "interrupt-map", | 1123 | prop = of_find_property(dp, "interrupt-map", &len); |
| 1126 | (char *)pbm->pbm_intmap, | 1124 | pbm->pbm_intmap = prop->value; |
| 1127 | sizeof(pbm->pbm_intmap)); | 1125 | pbm->num_pbm_intmap = |
| 1128 | if (err == 0 || err == -1) { | 1126 | (len / sizeof(struct linux_prom_pci_intmap)); |
| 1129 | prom_printf("%s: Fatal error, no interrupt-map property.\n", | ||
| 1130 | pbm->name); | ||
| 1131 | prom_halt(); | ||
| 1132 | } | ||
| 1133 | 1127 | ||
| 1134 | pbm->num_pbm_intmap = (err / sizeof(struct linux_prom_pci_intmap)); | 1128 | prop = of_find_property(dp, "interrupt-map-mask", NULL); |
| 1135 | err = prom_getproperty(prom_node, "interrupt-map-mask", | 1129 | pbm->pbm_intmask = prop->value; |
| 1136 | (char *)&pbm->pbm_intmask, | ||
| 1137 | sizeof(pbm->pbm_intmask)); | ||
| 1138 | if (err == 0 || err == -1) { | ||
| 1139 | prom_printf("%s: Fatal error, no interrupt-map-mask.\n", | ||
| 1140 | pbm->name); | ||
| 1141 | prom_halt(); | ||
| 1142 | } | ||
| 1143 | 1130 | ||
| 1144 | pci_sun4v_get_bus_range(pbm); | 1131 | pci_sun4v_get_bus_range(pbm); |
| 1145 | pci_sun4v_iommu_init(pbm); | 1132 | pci_sun4v_iommu_init(pbm); |
| @@ -1147,16 +1134,19 @@ static void pci_sun4v_pbm_init(struct pci_controller_info *p, int prom_node, u32 | |||
| 1147 | pdev_htab_populate(pbm); | 1134 | pdev_htab_populate(pbm); |
| 1148 | } | 1135 | } |
| 1149 | 1136 | ||
| 1150 | void sun4v_pci_init(int node, char *model_name) | 1137 | void sun4v_pci_init(struct device_node *dp, char *model_name) |
| 1151 | { | 1138 | { |
| 1152 | struct pci_controller_info *p; | 1139 | struct pci_controller_info *p; |
| 1153 | struct pci_iommu *iommu; | 1140 | struct pci_iommu *iommu; |
| 1154 | struct linux_prom64_registers regs; | 1141 | struct property *prop; |
| 1142 | struct linux_prom64_registers *regs; | ||
| 1155 | u32 devhandle; | 1143 | u32 devhandle; |
| 1156 | int i; | 1144 | int i; |
| 1157 | 1145 | ||
| 1158 | prom_getproperty(node, "reg", (char *)®s, sizeof(regs)); | 1146 | prop = of_find_property(dp, "reg", NULL); |
| 1159 | devhandle = (regs.phys_addr >> 32UL) & 0x0fffffff; | 1147 | regs = prop->value; |
| 1148 | |||
| 1149 | devhandle = (regs->phys_addr >> 32UL) & 0x0fffffff; | ||
| 1160 | 1150 | ||
| 1161 | for (p = pci_controller_root; p; p = p->next) { | 1151 | for (p = pci_controller_root; p; p = p->next) { |
| 1162 | struct pci_pbm_info *pbm; | 1152 | struct pci_pbm_info *pbm; |
| @@ -1169,7 +1159,7 @@ void sun4v_pci_init(int node, char *model_name) | |||
| 1169 | &p->pbm_B); | 1159 | &p->pbm_B); |
| 1170 | 1160 | ||
| 1171 | if (pbm->devhandle == (devhandle ^ 0x40)) { | 1161 | if (pbm->devhandle == (devhandle ^ 0x40)) { |
| 1172 | pci_sun4v_pbm_init(p, node, devhandle); | 1162 | pci_sun4v_pbm_init(p, dp, devhandle); |
| 1173 | return; | 1163 | return; |
| 1174 | } | 1164 | } |
| 1175 | } | 1165 | } |
| @@ -1220,7 +1210,7 @@ void sun4v_pci_init(int node, char *model_name) | |||
| 1220 | */ | 1210 | */ |
| 1221 | pci_memspace_mask = 0x7fffffffUL; | 1211 | pci_memspace_mask = 0x7fffffffUL; |
| 1222 | 1212 | ||
| 1223 | pci_sun4v_pbm_init(p, node, devhandle); | 1213 | pci_sun4v_pbm_init(p, dp, devhandle); |
| 1224 | return; | 1214 | return; |
| 1225 | 1215 | ||
| 1226 | fatal_memory_error: | 1216 | fatal_memory_error: |
diff --git a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c index 30bcaf58e3ab..9496c7734014 100644 --- a/arch/sparc64/kernel/power.c +++ b/arch/sparc64/kernel/power.c | |||
| @@ -105,76 +105,25 @@ again: | |||
| 105 | return 0; | 105 | return 0; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | static int __init has_button_interrupt(unsigned int irq, int prom_node) | 108 | static int __init has_button_interrupt(unsigned int irq, struct device_node *dp) |
| 109 | { | 109 | { |
| 110 | if (irq == PCI_IRQ_NONE) | 110 | if (irq == PCI_IRQ_NONE) |
| 111 | return 0; | 111 | return 0; |
| 112 | if (!prom_node_has_property(prom_node, "button")) | 112 | if (!of_find_property(dp, "button", NULL)) |
| 113 | return 0; | 113 | return 0; |
| 114 | 114 | ||
| 115 | return 1; | 115 | return 1; |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | static int __init power_probe_ebus(struct resource **resp, unsigned int *irq_p, int *prom_node_p) | 118 | static void __devinit power_probe_common(struct of_device *dev, struct resource *res, unsigned int irq) |
| 119 | { | 119 | { |
| 120 | struct linux_ebus *ebus; | ||
| 121 | struct linux_ebus_device *edev; | ||
| 122 | |||
| 123 | for_each_ebus(ebus) { | ||
| 124 | for_each_ebusdev(edev, ebus) { | ||
| 125 | if (!strcmp(edev->prom_name, "power")) { | ||
| 126 | *resp = &edev->resource[0]; | ||
| 127 | *irq_p = edev->irqs[0]; | ||
| 128 | *prom_node_p = edev->prom_node; | ||
| 129 | return 0; | ||
| 130 | } | ||
| 131 | } | ||
| 132 | } | ||
| 133 | return -ENODEV; | ||
| 134 | } | ||
| 135 | |||
| 136 | static int __init power_probe_isa(struct resource **resp, unsigned int *irq_p, int *prom_node_p) | ||
| 137 | { | ||
| 138 | struct sparc_isa_bridge *isa_bus; | ||
| 139 | struct sparc_isa_device *isa_dev; | ||
| 140 | |||
| 141 | for_each_isa(isa_bus) { | ||
| 142 | for_each_isadev(isa_dev, isa_bus) { | ||
| 143 | if (!strcmp(isa_dev->prom_name, "power")) { | ||
| 144 | *resp = &isa_dev->resource; | ||
| 145 | *irq_p = isa_dev->irq; | ||
| 146 | *prom_node_p = isa_dev->prom_node; | ||
| 147 | return 0; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | } | ||
| 151 | return -ENODEV; | ||
| 152 | } | ||
| 153 | |||
| 154 | void __init power_init(void) | ||
| 155 | { | ||
| 156 | struct resource *res = NULL; | ||
| 157 | unsigned int irq; | ||
| 158 | int prom_node; | ||
| 159 | static int invoked; | ||
| 160 | |||
| 161 | if (invoked) | ||
| 162 | return; | ||
| 163 | invoked = 1; | ||
| 164 | |||
| 165 | if (!power_probe_ebus(&res, &irq, &prom_node)) | ||
| 166 | goto found; | ||
| 167 | |||
| 168 | if (!power_probe_isa(&res, &irq, &prom_node)) | ||
| 169 | goto found; | ||
| 170 | |||
| 171 | return; | ||
| 172 | |||
| 173 | found: | ||
| 174 | power_reg = ioremap(res->start, 0x4); | 120 | power_reg = ioremap(res->start, 0x4); |
| 121 | |||
| 175 | printk("power: Control reg at %p ... ", power_reg); | 122 | printk("power: Control reg at %p ... ", power_reg); |
| 123 | |||
| 176 | poweroff_method = machine_halt; /* able to use the standard halt */ | 124 | poweroff_method = machine_halt; /* able to use the standard halt */ |
| 177 | if (has_button_interrupt(irq, prom_node)) { | 125 | |
| 126 | if (has_button_interrupt(irq, dev->node)) { | ||
| 178 | if (kernel_thread(powerd, NULL, CLONE_FS) < 0) { | 127 | if (kernel_thread(powerd, NULL, CLONE_FS) < 0) { |
| 179 | printk("Failed to start power daemon.\n"); | 128 | printk("Failed to start power daemon.\n"); |
| 180 | return; | 129 | return; |
| @@ -188,4 +137,52 @@ found: | |||
| 188 | printk("not using powerd.\n"); | 137 | printk("not using powerd.\n"); |
| 189 | } | 138 | } |
| 190 | } | 139 | } |
| 140 | |||
| 141 | static struct of_device_id power_match[] = { | ||
| 142 | { | ||
| 143 | .name = "power", | ||
| 144 | }, | ||
| 145 | {}, | ||
| 146 | }; | ||
| 147 | |||
| 148 | static int __devinit ebus_power_probe(struct of_device *dev, const struct of_device_id *match) | ||
| 149 | { | ||
| 150 | struct linux_ebus_device *edev = to_ebus_device(&dev->dev); | ||
| 151 | struct resource *res = &edev->resource[0]; | ||
| 152 | unsigned int irq = edev->irqs[0]; | ||
| 153 | |||
| 154 | power_probe_common(dev, res,irq); | ||
| 155 | |||
| 156 | return 0; | ||
| 157 | } | ||
| 158 | |||
| 159 | static struct of_platform_driver ebus_power_driver = { | ||
| 160 | .name = "power", | ||
| 161 | .match_table = power_match, | ||
| 162 | .probe = ebus_power_probe, | ||
| 163 | }; | ||
| 164 | |||
| 165 | static int __devinit isa_power_probe(struct of_device *dev, const struct of_device_id *match) | ||
| 166 | { | ||
| 167 | struct sparc_isa_device *idev = to_isa_device(&dev->dev); | ||
| 168 | struct resource *res = &idev->resource; | ||
| 169 | unsigned int irq = idev->irq; | ||
| 170 | |||
| 171 | power_probe_common(dev, res,irq); | ||
| 172 | |||
| 173 | return 0; | ||
| 174 | } | ||
| 175 | |||
| 176 | static struct of_platform_driver isa_power_driver = { | ||
| 177 | .name = "power", | ||
| 178 | .match_table = power_match, | ||
| 179 | .probe = isa_power_probe, | ||
| 180 | }; | ||
| 181 | |||
| 182 | void __init power_init(void) | ||
| 183 | { | ||
| 184 | of_register_driver(&ebus_power_driver, &ebus_bus_type); | ||
| 185 | of_register_driver(&isa_power_driver, &isa_bus_type); | ||
| 186 | return; | ||
| 187 | } | ||
| 191 | #endif /* CONFIG_PCI */ | 188 | #endif /* CONFIG_PCI */ |
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c new file mode 100644 index 000000000000..e9d703eea806 --- /dev/null +++ b/arch/sparc64/kernel/prom.c | |||
| @@ -0,0 +1,650 @@ | |||
| 1 | /* | ||
| 2 | * Procedures for creating, accessing and interpreting the device tree. | ||
| 3 | * | ||
| 4 | * Paul Mackerras August 1996. | ||
| 5 | * Copyright (C) 1996-2005 Paul Mackerras. | ||
| 6 | * | ||
| 7 | * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner. | ||
| 8 | * {engebret|bergner}@us.ibm.com | ||
| 9 | * | ||
| 10 | * Adapted for sparc64 by David S. Miller davem@davemloft.net | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or | ||
| 13 | * modify it under the terms of the GNU General Public License | ||
| 14 | * as published by the Free Software Foundation; either version | ||
| 15 | * 2 of the License, or (at your option) any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <linux/kernel.h> | ||
| 19 | #include <linux/types.h> | ||
| 20 | #include <linux/string.h> | ||
| 21 | #include <linux/mm.h> | ||
| 22 | #include <linux/bootmem.h> | ||
| 23 | #include <linux/module.h> | ||
| 24 | |||
| 25 | #include <asm/prom.h> | ||
| 26 | #include <asm/oplib.h> | ||
| 27 | |||
| 28 | static struct device_node *allnodes; | ||
| 29 | |||
| 30 | int of_device_is_compatible(struct device_node *device, const char *compat) | ||
| 31 | { | ||
| 32 | const char* cp; | ||
| 33 | int cplen, l; | ||
| 34 | |||
| 35 | cp = (char *) of_get_property(device, "compatible", &cplen); | ||
| 36 | if (cp == NULL) | ||
| 37 | return 0; | ||
| 38 | while (cplen > 0) { | ||
| 39 | if (strncmp(cp, compat, strlen(compat)) == 0) | ||
| 40 | return 1; | ||
| 41 | l = strlen(cp) + 1; | ||
| 42 | cp += l; | ||
| 43 | cplen -= l; | ||
| 44 | } | ||
| 45 | |||
| 46 | return 0; | ||
| 47 | } | ||
| 48 | EXPORT_SYMBOL(of_device_is_compatible); | ||
| 49 | |||
| 50 | struct device_node *of_get_parent(const struct device_node *node) | ||
| 51 | { | ||
| 52 | struct device_node *np; | ||
| 53 | |||
| 54 | if (!node) | ||
| 55 | return NULL; | ||
| 56 | |||
| 57 | np = node->parent; | ||
| 58 | |||
| 59 | return np; | ||
| 60 | } | ||
| 61 | EXPORT_SYMBOL(of_get_parent); | ||
| 62 | |||
| 63 | struct device_node *of_get_next_child(const struct device_node *node, | ||
| 64 | struct device_node *prev) | ||
| 65 | { | ||
| 66 | struct device_node *next; | ||
| 67 | |||
| 68 | next = prev ? prev->sibling : node->child; | ||
| 69 | for (; next != 0; next = next->sibling) { | ||
| 70 | break; | ||
| 71 | } | ||
| 72 | |||
| 73 | return next; | ||
| 74 | } | ||
| 75 | EXPORT_SYMBOL(of_get_next_child); | ||
| 76 | |||
| 77 | struct device_node *of_find_node_by_path(const char *path) | ||
| 78 | { | ||
| 79 | struct device_node *np = allnodes; | ||
| 80 | |||
| 81 | for (; np != 0; np = np->allnext) { | ||
| 82 | if (np->full_name != 0 && strcmp(np->full_name, path) == 0) | ||
| 83 | break; | ||
| 84 | } | ||
| 85 | |||
| 86 | return np; | ||
| 87 | } | ||
| 88 | EXPORT_SYMBOL(of_find_node_by_path); | ||
| 89 | |||
| 90 | struct device_node *of_find_node_by_phandle(phandle handle) | ||
| 91 | { | ||
| 92 | struct device_node *np; | ||
| 93 | |||
| 94 | for (np = allnodes; np != 0; np = np->allnext) | ||
| 95 | if (np->node == handle) | ||
| 96 | break; | ||
| 97 | |||
| 98 | return np; | ||
| 99 | } | ||
| 100 | EXPORT_SYMBOL(of_find_node_by_phandle); | ||
| 101 | |||
| 102 | struct device_node *of_find_node_by_name(struct device_node *from, | ||
| 103 | const char *name) | ||
| 104 | { | ||
| 105 | struct device_node *np; | ||
| 106 | |||
| 107 | np = from ? from->allnext : allnodes; | ||
| 108 | for (; np != NULL; np = np->allnext) | ||
| 109 | if (np->name != NULL && strcmp(np->name, name) == 0) | ||
| 110 | break; | ||
| 111 | |||
| 112 | return np; | ||
| 113 | } | ||
| 114 | EXPORT_SYMBOL(of_find_node_by_name); | ||
| 115 | |||
| 116 | struct device_node *of_find_node_by_type(struct device_node *from, | ||
| 117 | const char *type) | ||
| 118 | { | ||
| 119 | struct device_node *np; | ||
| 120 | |||
| 121 | np = from ? from->allnext : allnodes; | ||
| 122 | for (; np != 0; np = np->allnext) | ||
| 123 | if (np->type != 0 && strcmp(np->type, type) == 0) | ||
| 124 | break; | ||
| 125 | |||
| 126 | return np; | ||
| 127 | } | ||
| 128 | EXPORT_SYMBOL(of_find_node_by_type); | ||
| 129 | |||
| 130 | struct device_node *of_find_compatible_node(struct device_node *from, | ||
| 131 | const char *type, const char *compatible) | ||
| 132 | { | ||
| 133 | struct device_node *np; | ||
| 134 | |||
| 135 | np = from ? from->allnext : allnodes; | ||
| 136 | for (; np != 0; np = np->allnext) { | ||
| 137 | if (type != NULL | ||
| 138 | && !(np->type != 0 && strcmp(np->type, type) == 0)) | ||
| 139 | continue; | ||
| 140 | if (of_device_is_compatible(np, compatible)) | ||
| 141 | break; | ||
| 142 | } | ||
| 143 | |||
| 144 | return np; | ||
| 145 | } | ||
| 146 | EXPORT_SYMBOL(of_find_compatible_node); | ||
| 147 | |||
| 148 | struct property *of_find_property(struct device_node *np, const char *name, | ||
| 149 | int *lenp) | ||
| 150 | { | ||
| 151 | struct property *pp; | ||
| 152 | |||
| 153 | for (pp = np->properties; pp != 0; pp = pp->next) { | ||
| 154 | if (strcmp(pp->name, name) == 0) { | ||
| 155 | if (lenp != 0) | ||
| 156 | *lenp = pp->length; | ||
| 157 | break; | ||
| 158 | } | ||
| 159 | } | ||
| 160 | return pp; | ||
| 161 | } | ||
| 162 | EXPORT_SYMBOL(of_find_property); | ||
| 163 | |||
| 164 | /* | ||
| 165 | * Find a property with a given name for a given node | ||
| 166 | * and return the value. | ||
| 167 | */ | ||
| 168 | void *of_get_property(struct device_node *np, const char *name, int *lenp) | ||
| 169 | { | ||
| 170 | struct property *pp = of_find_property(np,name,lenp); | ||
| 171 | return pp ? pp->value : NULL; | ||
| 172 | } | ||
| 173 | EXPORT_SYMBOL(of_get_property); | ||
| 174 | |||
| 175 | int of_getintprop_default(struct device_node *np, const char *name, int def) | ||
| 176 | { | ||
| 177 | struct property *prop; | ||
| 178 | int len; | ||
| 179 | |||
| 180 | prop = of_find_property(np, name, &len); | ||
| 181 | if (!prop || len != 4) | ||
| 182 | return def; | ||
| 183 | |||
| 184 | return *(int *) prop->value; | ||
| 185 | } | ||
| 186 | EXPORT_SYMBOL(of_getintprop_default); | ||
| 187 | |||
| 188 | static unsigned int prom_early_allocated; | ||
| 189 | |||
| 190 | static void * __init prom_early_alloc(unsigned long size) | ||
| 191 | { | ||
| 192 | void *ret; | ||
| 193 | |||
| 194 | ret = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL); | ||
| 195 | if (ret != NULL) | ||
| 196 | memset(ret, 0, size); | ||
| 197 | |||
| 198 | prom_early_allocated += size; | ||
| 199 | |||
| 200 | return ret; | ||
| 201 | } | ||
| 202 | |||
| 203 | static int is_root_node(const struct device_node *dp) | ||
| 204 | { | ||
| 205 | if (!dp) | ||
| 206 | return 0; | ||
| 207 | |||
| 208 | return (dp->parent == NULL); | ||
| 209 | } | ||
| 210 | |||
| 211 | /* The following routines deal with the black magic of fully naming a | ||
| 212 | * node. | ||
| 213 | * | ||
| 214 | * Certain well known named nodes are just the simple name string. | ||
| 215 | * | ||
| 216 | * Actual devices have an address specifier appended to the base name | ||
| 217 | * string, like this "foo@addr". The "addr" can be in any number of | ||
| 218 | * formats, and the platform plus the type of the node determine the | ||
| 219 | * format and how it is constructed. | ||
| 220 | * | ||
| 221 | * For children of the ROOT node, the naming convention is fixed and | ||
| 222 | * determined by whether this is a sun4u or sun4v system. | ||
| 223 | * | ||
| 224 | * For children of other nodes, it is bus type specific. So | ||
| 225 | * we walk up the tree until we discover a "device_type" property | ||
| 226 | * we recognize and we go from there. | ||
| 227 | * | ||
| 228 | * As an example, the boot device on my workstation has a full path: | ||
| 229 | * | ||
| 230 | * /pci@1e,600000/ide@d/disk@0,0:c | ||
| 231 | */ | ||
| 232 | static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf) | ||
| 233 | { | ||
| 234 | struct linux_prom64_registers *regs; | ||
| 235 | struct property *rprop; | ||
| 236 | u32 high_bits, low_bits, type; | ||
| 237 | |||
| 238 | rprop = of_find_property(dp, "reg", NULL); | ||
| 239 | if (!rprop) | ||
| 240 | return; | ||
| 241 | |||
| 242 | regs = rprop->value; | ||
| 243 | if (!is_root_node(dp->parent)) { | ||
| 244 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 245 | dp->name, | ||
| 246 | (unsigned int) (regs->phys_addr >> 32UL), | ||
| 247 | (unsigned int) (regs->phys_addr & 0xffffffffUL)); | ||
| 248 | return; | ||
| 249 | } | ||
| 250 | |||
| 251 | type = regs->phys_addr >> 60UL; | ||
| 252 | high_bits = (regs->phys_addr >> 32UL) & 0x0fffffffUL; | ||
| 253 | low_bits = (regs->phys_addr & 0xffffffffUL); | ||
| 254 | |||
| 255 | if (type == 0 || type == 8) { | ||
| 256 | const char *prefix = (type == 0) ? "m" : "i"; | ||
| 257 | |||
| 258 | if (low_bits) | ||
| 259 | sprintf(tmp_buf, "%s@%s%x,%x", | ||
| 260 | dp->name, prefix, | ||
| 261 | high_bits, low_bits); | ||
| 262 | else | ||
| 263 | sprintf(tmp_buf, "%s@%s%x", | ||
| 264 | dp->name, | ||
| 265 | prefix, | ||
| 266 | high_bits); | ||
| 267 | } else if (type == 12) { | ||
| 268 | sprintf(tmp_buf, "%s@%x", | ||
| 269 | dp->name, high_bits); | ||
| 270 | } | ||
| 271 | } | ||
| 272 | |||
| 273 | static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf) | ||
| 274 | { | ||
| 275 | struct linux_prom64_registers *regs; | ||
| 276 | struct property *prop; | ||
| 277 | |||
| 278 | prop = of_find_property(dp, "reg", NULL); | ||
| 279 | if (!prop) | ||
| 280 | return; | ||
| 281 | |||
| 282 | regs = prop->value; | ||
| 283 | if (!is_root_node(dp->parent)) { | ||
| 284 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 285 | dp->name, | ||
| 286 | (unsigned int) (regs->phys_addr >> 32UL), | ||
| 287 | (unsigned int) (regs->phys_addr & 0xffffffffUL)); | ||
| 288 | return; | ||
| 289 | } | ||
| 290 | |||
| 291 | prop = of_find_property(dp, "upa-portid", NULL); | ||
| 292 | if (!prop) | ||
| 293 | prop = of_find_property(dp, "portid", NULL); | ||
| 294 | if (prop) { | ||
| 295 | unsigned long mask = 0xffffffffUL; | ||
| 296 | |||
| 297 | if (tlb_type >= cheetah) | ||
| 298 | mask = 0x7fffff; | ||
| 299 | |||
| 300 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 301 | dp->name, | ||
| 302 | *(u32 *)prop->value, | ||
| 303 | (unsigned int) (regs->phys_addr & mask)); | ||
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 307 | /* "name@slot,offset" */ | ||
| 308 | static void __init sbus_path_component(struct device_node *dp, char *tmp_buf) | ||
| 309 | { | ||
| 310 | struct linux_prom_registers *regs; | ||
| 311 | struct property *prop; | ||
| 312 | |||
| 313 | prop = of_find_property(dp, "reg", NULL); | ||
| 314 | if (!prop) | ||
| 315 | return; | ||
| 316 | |||
| 317 | regs = prop->value; | ||
| 318 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 319 | dp->name, | ||
| 320 | regs->which_io, | ||
| 321 | regs->phys_addr); | ||
| 322 | } | ||
| 323 | |||
| 324 | /* "name@devnum[,func]" */ | ||
| 325 | static void __init pci_path_component(struct device_node *dp, char *tmp_buf) | ||
| 326 | { | ||
| 327 | struct linux_prom_pci_registers *regs; | ||
| 328 | struct property *prop; | ||
| 329 | unsigned int devfn; | ||
| 330 | |||
| 331 | prop = of_find_property(dp, "reg", NULL); | ||
| 332 | if (!prop) | ||
| 333 | return; | ||
| 334 | |||
| 335 | regs = prop->value; | ||
| 336 | devfn = (regs->phys_hi >> 8) & 0xff; | ||
| 337 | if (devfn & 0x07) { | ||
| 338 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 339 | dp->name, | ||
| 340 | devfn >> 3, | ||
| 341 | devfn & 0x07); | ||
| 342 | } else { | ||
| 343 | sprintf(tmp_buf, "%s@%x", | ||
| 344 | dp->name, | ||
| 345 | devfn >> 3); | ||
| 346 | } | ||
| 347 | } | ||
| 348 | |||
| 349 | /* "name@UPA_PORTID,offset" */ | ||
| 350 | static void __init upa_path_component(struct device_node *dp, char *tmp_buf) | ||
| 351 | { | ||
| 352 | struct linux_prom64_registers *regs; | ||
| 353 | struct property *prop; | ||
| 354 | |||
| 355 | prop = of_find_property(dp, "reg", NULL); | ||
| 356 | if (!prop) | ||
| 357 | return; | ||
| 358 | |||
| 359 | regs = prop->value; | ||
| 360 | |||
| 361 | prop = of_find_property(dp, "upa-portid", NULL); | ||
| 362 | if (!prop) | ||
| 363 | return; | ||
| 364 | |||
| 365 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 366 | dp->name, | ||
| 367 | *(u32 *) prop->value, | ||
| 368 | (unsigned int) (regs->phys_addr & 0xffffffffUL)); | ||
| 369 | } | ||
| 370 | |||
| 371 | /* "name@reg" */ | ||
| 372 | static void __init vdev_path_component(struct device_node *dp, char *tmp_buf) | ||
| 373 | { | ||
| 374 | struct property *prop; | ||
| 375 | u32 *regs; | ||
| 376 | |||
| 377 | prop = of_find_property(dp, "reg", NULL); | ||
| 378 | if (!prop) | ||
| 379 | return; | ||
| 380 | |||
| 381 | regs = prop->value; | ||
| 382 | |||
| 383 | sprintf(tmp_buf, "%s@%x", dp->name, *regs); | ||
| 384 | } | ||
| 385 | |||
| 386 | /* "name@addrhi,addrlo" */ | ||
| 387 | static void __init ebus_path_component(struct device_node *dp, char *tmp_buf) | ||
| 388 | { | ||
| 389 | struct linux_prom64_registers *regs; | ||
| 390 | struct property *prop; | ||
| 391 | |||
| 392 | prop = of_find_property(dp, "reg", NULL); | ||
| 393 | if (!prop) | ||
| 394 | return; | ||
| 395 | |||
| 396 | regs = prop->value; | ||
| 397 | |||
| 398 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 399 | dp->name, | ||
| 400 | (unsigned int) (regs->phys_addr >> 32UL), | ||
| 401 | (unsigned int) (regs->phys_addr & 0xffffffffUL)); | ||
| 402 | } | ||
| 403 | |||
| 404 | /* "name@bus,addr" */ | ||
| 405 | static void __init i2c_path_component(struct device_node *dp, char *tmp_buf) | ||
| 406 | { | ||
| 407 | struct property *prop; | ||
| 408 | u32 *regs; | ||
| 409 | |||
| 410 | prop = of_find_property(dp, "reg", NULL); | ||
| 411 | if (!prop) | ||
| 412 | return; | ||
| 413 | |||
| 414 | regs = prop->value; | ||
| 415 | |||
| 416 | /* This actually isn't right... should look at the #address-cells | ||
| 417 | * property of the i2c bus node etc. etc. | ||
| 418 | */ | ||
| 419 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 420 | dp->name, regs[0], regs[1]); | ||
| 421 | } | ||
| 422 | |||
| 423 | /* "name@reg0[,reg1]" */ | ||
| 424 | static void __init usb_path_component(struct device_node *dp, char *tmp_buf) | ||
| 425 | { | ||
| 426 | struct property *prop; | ||
| 427 | u32 *regs; | ||
| 428 | |||
| 429 | prop = of_find_property(dp, "reg", NULL); | ||
| 430 | if (!prop) | ||
| 431 | return; | ||
| 432 | |||
| 433 | regs = prop->value; | ||
| 434 | |||
| 435 | if (prop->length == sizeof(u32) || regs[1] == 1) { | ||
| 436 | sprintf(tmp_buf, "%s@%x", | ||
| 437 | dp->name, regs[0]); | ||
| 438 | } else { | ||
| 439 | sprintf(tmp_buf, "%s@%x,%x", | ||
| 440 | dp->name, regs[0], regs[1]); | ||
| 441 | } | ||
| 442 | } | ||
| 443 | |||
| 444 | /* "name@reg0reg1[,reg2reg3]" */ | ||
| 445 | static void __init ieee1394_path_component(struct device_node *dp, char *tmp_buf) | ||
| 446 | { | ||
| 447 | struct property *prop; | ||
| 448 | u32 *regs; | ||
| 449 | |||
| 450 | prop = of_find_property(dp, "reg", NULL); | ||
| 451 | if (!prop) | ||
| 452 | return; | ||
| 453 | |||
| 454 | regs = prop->value; | ||
| 455 | |||
| 456 | if (regs[2] || regs[3]) { | ||
| 457 | sprintf(tmp_buf, "%s@%08x%08x,%04x%08x", | ||
| 458 | dp->name, regs[0], regs[1], regs[2], regs[3]); | ||
| 459 | } else { | ||
| 460 | sprintf(tmp_buf, "%s@%08x%08x", | ||
| 461 | dp->name, regs[0], regs[1]); | ||
| 462 | } | ||
| 463 | } | ||
| 464 | |||
| 465 | static void __init __build_path_component(struct device_node *dp, char *tmp_buf) | ||
| 466 | { | ||
| 467 | struct device_node *parent = dp->parent; | ||
| 468 | |||
| 469 | if (parent != NULL) { | ||
| 470 | if (!strcmp(parent->type, "pci") || | ||
| 471 | !strcmp(parent->type, "pciex")) | ||
| 472 | return pci_path_component(dp, tmp_buf); | ||
| 473 | if (!strcmp(parent->type, "sbus")) | ||
| 474 | return sbus_path_component(dp, tmp_buf); | ||
| 475 | if (!strcmp(parent->type, "upa")) | ||
| 476 | return upa_path_component(dp, tmp_buf); | ||
| 477 | if (!strcmp(parent->type, "ebus")) | ||
| 478 | return ebus_path_component(dp, tmp_buf); | ||
| 479 | if (!strcmp(parent->name, "usb") || | ||
| 480 | !strcmp(parent->name, "hub")) | ||
| 481 | return usb_path_component(dp, tmp_buf); | ||
| 482 | if (!strcmp(parent->type, "i2c")) | ||
| 483 | return i2c_path_component(dp, tmp_buf); | ||
| 484 | if (!strcmp(parent->type, "firewire")) | ||
| 485 | return ieee1394_path_component(dp, tmp_buf); | ||
| 486 | if (!strcmp(parent->type, "virtual-devices")) | ||
| 487 | return vdev_path_component(dp, tmp_buf); | ||
| 488 | |||
| 489 | /* "isa" is handled with platform naming */ | ||
| 490 | } | ||
| 491 | |||
| 492 | /* Use platform naming convention. */ | ||
| 493 | if (tlb_type == hypervisor) | ||
| 494 | return sun4v_path_component(dp, tmp_buf); | ||
| 495 | else | ||
| 496 | return sun4u_path_component(dp, tmp_buf); | ||
| 497 | } | ||
| 498 | |||
| 499 | static char * __init build_path_component(struct device_node *dp) | ||
| 500 | { | ||
| 501 | char tmp_buf[64], *n; | ||
| 502 | |||
| 503 | tmp_buf[0] = '\0'; | ||
| 504 | __build_path_component(dp, tmp_buf); | ||
| 505 | if (tmp_buf[0] == '\0') | ||
| 506 | strcpy(tmp_buf, dp->name); | ||
| 507 | |||
| 508 | n = prom_early_alloc(strlen(tmp_buf) + 1); | ||
| 509 | strcpy(n, tmp_buf); | ||
| 510 | |||
| 511 | return n; | ||
| 512 | } | ||
| 513 | |||
| 514 | static char * __init build_full_name(struct device_node *dp) | ||
| 515 | { | ||
| 516 | int len, ourlen, plen; | ||
| 517 | char *n; | ||
| 518 | |||
| 519 | plen = strlen(dp->parent->full_name); | ||
| 520 | ourlen = strlen(dp->path_component_name); | ||
| 521 | len = ourlen + plen + 2; | ||
| 522 | |||
| 523 | n = prom_early_alloc(len); | ||
| 524 | strcpy(n, dp->parent->full_name); | ||
| 525 | if (!is_root_node(dp->parent)) { | ||
| 526 | strcpy(n + plen, "/"); | ||
| 527 | plen++; | ||
| 528 | } | ||
| 529 | strcpy(n + plen, dp->path_component_name); | ||
| 530 | |||
| 531 | return n; | ||
| 532 | } | ||
| 533 | |||
| 534 | static struct property * __init build_one_prop(phandle node, char *prev) | ||
| 535 | { | ||
| 536 | static struct property *tmp = NULL; | ||
| 537 | struct property *p; | ||
| 538 | |||
| 539 | if (tmp) { | ||
| 540 | p = tmp; | ||
| 541 | memset(p, 0, sizeof(*p) + 32); | ||
| 542 | tmp = NULL; | ||
| 543 | } else | ||
| 544 | p = prom_early_alloc(sizeof(struct property) + 32); | ||
| 545 | |||
| 546 | p->name = (char *) (p + 1); | ||
| 547 | if (prev == NULL) { | ||
| 548 | prom_firstprop(node, p->name); | ||
| 549 | } else { | ||
| 550 | prom_nextprop(node, prev, p->name); | ||
| 551 | } | ||
| 552 | if (strlen(p->name) == 0) { | ||
| 553 | tmp = p; | ||
| 554 | return NULL; | ||
| 555 | } | ||
| 556 | p->length = prom_getproplen(node, p->name); | ||
| 557 | if (p->length <= 0) { | ||
| 558 | p->length = 0; | ||
| 559 | } else { | ||
| 560 | p->value = prom_early_alloc(p->length); | ||
| 561 | prom_getproperty(node, p->name, p->value, p->length); | ||
| 562 | } | ||
| 563 | return p; | ||
| 564 | } | ||
| 565 | |||
| 566 | static struct property * __init build_prop_list(phandle node) | ||
| 567 | { | ||
| 568 | struct property *head, *tail; | ||
| 569 | |||
| 570 | head = tail = build_one_prop(node, NULL); | ||
| 571 | while(tail) { | ||
| 572 | tail->next = build_one_prop(node, tail->name); | ||
| 573 | tail = tail->next; | ||
| 574 | } | ||
| 575 | |||
| 576 | return head; | ||
| 577 | } | ||
| 578 | |||
| 579 | static char * __init get_one_property(phandle node, const char *name) | ||
| 580 | { | ||
| 581 | char *buf = "<NULL>"; | ||
| 582 | int len; | ||
| 583 | |||
| 584 | len = prom_getproplen(node, name); | ||
| 585 | if (len > 0) { | ||
| 586 | buf = prom_early_alloc(len); | ||
| 587 | prom_getproperty(node, name, buf, len); | ||
| 588 | } | ||
| 589 | |||
| 590 | return buf; | ||
| 591 | } | ||
| 592 | |||
| 593 | static struct device_node * __init create_node(phandle node) | ||
| 594 | { | ||
| 595 | struct device_node *dp; | ||
| 596 | |||
| 597 | if (!node) | ||
| 598 | return NULL; | ||
| 599 | |||
| 600 | dp = prom_early_alloc(sizeof(*dp)); | ||
| 601 | |||
| 602 | kref_init(&dp->kref); | ||
| 603 | |||
| 604 | dp->name = get_one_property(node, "name"); | ||
| 605 | dp->type = get_one_property(node, "device_type"); | ||
| 606 | dp->node = node; | ||
| 607 | |||
| 608 | /* Build interrupts later... */ | ||
| 609 | |||
| 610 | dp->properties = build_prop_list(node); | ||
| 611 | |||
| 612 | return dp; | ||
| 613 | } | ||
| 614 | |||
| 615 | static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp) | ||
| 616 | { | ||
| 617 | struct device_node *dp; | ||
| 618 | |||
| 619 | dp = create_node(node); | ||
| 620 | if (dp) { | ||
| 621 | *(*nextp) = dp; | ||
| 622 | *nextp = &dp->allnext; | ||
| 623 | |||
| 624 | dp->parent = parent; | ||
| 625 | dp->path_component_name = build_path_component(dp); | ||
| 626 | dp->full_name = build_full_name(dp); | ||
| 627 | |||
| 628 | dp->child = build_tree(dp, prom_getchild(node), nextp); | ||
| 629 | |||
| 630 | dp->sibling = build_tree(parent, prom_getsibling(node), nextp); | ||
| 631 | } | ||
| 632 | |||
| 633 | return dp; | ||
| 634 | } | ||
| 635 | |||
| 636 | void __init prom_build_devicetree(void) | ||
| 637 | { | ||
| 638 | struct device_node **nextp; | ||
| 639 | |||
| 640 | allnodes = create_node(prom_root_node); | ||
| 641 | allnodes->path_component_name = ""; | ||
| 642 | allnodes->full_name = "/"; | ||
| 643 | |||
| 644 | nextp = &allnodes->allnext; | ||
| 645 | allnodes->child = build_tree(allnodes, | ||
| 646 | prom_getchild(allnodes->node), | ||
| 647 | &nextp); | ||
| 648 | printk("PROM: Built device tree with %u bytes of memory.\n", | ||
| 649 | prom_early_allocated); | ||
| 650 | } | ||
diff --git a/arch/sparc64/kernel/sbus.c b/arch/sparc64/kernel/sbus.c index 8812417247d4..ac05e0f692ef 100644 --- a/arch/sparc64/kernel/sbus.c +++ b/arch/sparc64/kernel/sbus.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <asm/cache.h> | 19 | #include <asm/cache.h> |
| 20 | #include <asm/dma.h> | 20 | #include <asm/dma.h> |
| 21 | #include <asm/irq.h> | 21 | #include <asm/irq.h> |
| 22 | #include <asm/prom.h> | ||
| 22 | #include <asm/starfire.h> | 23 | #include <asm/starfire.h> |
| 23 | 24 | ||
| 24 | #include "iommu_common.h" | 25 | #include "iommu_common.h" |
| @@ -1098,24 +1099,25 @@ static void __init sysio_register_error_handlers(struct sbus_bus *sbus) | |||
| 1098 | } | 1099 | } |
| 1099 | 1100 | ||
| 1100 | /* Boot time initialization. */ | 1101 | /* Boot time initialization. */ |
| 1101 | void __init sbus_iommu_init(int prom_node, struct sbus_bus *sbus) | 1102 | static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus) |
| 1102 | { | 1103 | { |
| 1103 | struct linux_prom64_registers rprop; | 1104 | struct linux_prom64_registers *pr; |
| 1105 | struct device_node *dp; | ||
| 1104 | struct sbus_iommu *iommu; | 1106 | struct sbus_iommu *iommu; |
| 1105 | unsigned long regs, tsb_base; | 1107 | unsigned long regs, tsb_base; |
| 1106 | u64 control; | 1108 | u64 control; |
| 1107 | int err, i; | 1109 | int i; |
| 1110 | |||
| 1111 | dp = of_find_node_by_phandle(__node); | ||
| 1108 | 1112 | ||
| 1109 | sbus->portid = prom_getintdefault(sbus->prom_node, | 1113 | sbus->portid = of_getintprop_default(dp, "upa-portid", -1); |
| 1110 | "upa-portid", -1); | ||
| 1111 | 1114 | ||
| 1112 | err = prom_getproperty(prom_node, "reg", | 1115 | pr = of_get_property(dp, "reg", NULL); |
| 1113 | (char *)&rprop, sizeof(rprop)); | 1116 | if (!pr) { |
| 1114 | if (err < 0) { | ||
| 1115 | prom_printf("sbus_iommu_init: Cannot map SYSIO control registers.\n"); | 1117 | prom_printf("sbus_iommu_init: Cannot map SYSIO control registers.\n"); |
| 1116 | prom_halt(); | 1118 | prom_halt(); |
| 1117 | } | 1119 | } |
| 1118 | regs = rprop.phys_addr; | 1120 | regs = pr->phys_addr; |
| 1119 | 1121 | ||
| 1120 | iommu = kmalloc(sizeof(*iommu) + SMP_CACHE_BYTES, GFP_ATOMIC); | 1122 | iommu = kmalloc(sizeof(*iommu) + SMP_CACHE_BYTES, GFP_ATOMIC); |
| 1121 | if (iommu == NULL) { | 1123 | if (iommu == NULL) { |
| @@ -1225,3 +1227,50 @@ void __init sbus_iommu_init(int prom_node, struct sbus_bus *sbus) | |||
| 1225 | 1227 | ||
| 1226 | sysio_register_error_handlers(sbus); | 1228 | sysio_register_error_handlers(sbus); |
| 1227 | } | 1229 | } |
| 1230 | |||
| 1231 | void sbus_fill_device_irq(struct sbus_dev *sdev) | ||
| 1232 | { | ||
| 1233 | struct device_node *dp = of_find_node_by_phandle(sdev->prom_node); | ||
| 1234 | struct linux_prom_irqs *irqs; | ||
| 1235 | |||
| 1236 | irqs = of_get_property(dp, "interrupts", NULL); | ||
| 1237 | if (!irqs) { | ||
| 1238 | sdev->irqs[0] = 0; | ||
| 1239 | sdev->num_irqs = 0; | ||
| 1240 | } else { | ||
| 1241 | unsigned int pri = irqs[0].pri; | ||
| 1242 | |||
| 1243 | sdev->num_irqs = 1; | ||
| 1244 | if (pri < 0x20) | ||
| 1245 | pri += sdev->slot * 8; | ||
| 1246 | |||
| 1247 | sdev->irqs[0] = sbus_build_irq(sdev->bus, pri); | ||
| 1248 | } | ||
| 1249 | } | ||
| 1250 | |||
| 1251 | void __init sbus_arch_bus_ranges_init(struct device_node *pn, struct sbus_bus *sbus) | ||
| 1252 | { | ||
| 1253 | } | ||
| 1254 | |||
| 1255 | void __init sbus_setup_iommu(struct sbus_bus *sbus, struct device_node *dp) | ||
| 1256 | { | ||
| 1257 | sbus_iommu_init(dp->node, sbus); | ||
| 1258 | } | ||
| 1259 | |||
| 1260 | void __init sbus_setup_arch_props(struct sbus_bus *sbus, struct device_node *dp) | ||
| 1261 | { | ||
| 1262 | } | ||
| 1263 | |||
| 1264 | int __init sbus_arch_preinit(void) | ||
| 1265 | { | ||
| 1266 | return 0; | ||
| 1267 | } | ||
| 1268 | |||
| 1269 | void __init sbus_arch_postinit(void) | ||
| 1270 | { | ||
| 1271 | extern void firetruck_init(void); | ||
| 1272 | extern void clock_probe(void); | ||
| 1273 | |||
| 1274 | firetruck_init(); | ||
| 1275 | clock_probe(); | ||
| 1276 | } | ||
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c index 9cf1c88cd774..a6a7d8168346 100644 --- a/arch/sparc64/kernel/setup.c +++ b/arch/sparc64/kernel/setup.c | |||
| @@ -376,12 +376,12 @@ void __init setup_arch(char **cmdline_p) | |||
| 376 | } | 376 | } |
| 377 | #endif | 377 | #endif |
| 378 | 378 | ||
| 379 | smp_setup_cpu_possible_map(); | ||
| 380 | |||
| 381 | /* Get boot processor trap_block[] setup. */ | 379 | /* Get boot processor trap_block[] setup. */ |
| 382 | init_cur_cpu_trap(current_thread_info()); | 380 | init_cur_cpu_trap(current_thread_info()); |
| 383 | 381 | ||
| 384 | paging_init(); | 382 | paging_init(); |
| 383 | |||
| 384 | smp_setup_cpu_possible_map(); | ||
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | static int __init set_preferred_console(void) | 387 | static int __init set_preferred_console(void) |
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c index f03d52d0b88d..f62bf3a2de1a 100644 --- a/arch/sparc64/kernel/smp.c +++ b/arch/sparc64/kernel/smp.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include <asm/starfire.h> | 39 | #include <asm/starfire.h> |
| 40 | #include <asm/tlb.h> | 40 | #include <asm/tlb.h> |
| 41 | #include <asm/sections.h> | 41 | #include <asm/sections.h> |
| 42 | #include <asm/prom.h> | ||
| 42 | 43 | ||
| 43 | extern void calibrate_delay(void); | 44 | extern void calibrate_delay(void); |
| 44 | 45 | ||
| @@ -76,41 +77,42 @@ void smp_bogo(struct seq_file *m) | |||
| 76 | 77 | ||
| 77 | void __init smp_store_cpu_info(int id) | 78 | void __init smp_store_cpu_info(int id) |
| 78 | { | 79 | { |
| 79 | int cpu_node, def; | 80 | struct device_node *dp; |
| 81 | int def; | ||
| 80 | 82 | ||
| 81 | /* multiplier and counter set by | 83 | /* multiplier and counter set by |
| 82 | smp_setup_percpu_timer() */ | 84 | smp_setup_percpu_timer() */ |
| 83 | cpu_data(id).udelay_val = loops_per_jiffy; | 85 | cpu_data(id).udelay_val = loops_per_jiffy; |
| 84 | 86 | ||
| 85 | cpu_find_by_mid(id, &cpu_node); | 87 | cpu_find_by_mid(id, &dp); |
| 86 | cpu_data(id).clock_tick = prom_getintdefault(cpu_node, | 88 | cpu_data(id).clock_tick = |
| 87 | "clock-frequency", 0); | 89 | of_getintprop_default(dp, "clock-frequency", 0); |
| 88 | 90 | ||
| 89 | def = ((tlb_type == hypervisor) ? (8 * 1024) : (16 * 1024)); | 91 | def = ((tlb_type == hypervisor) ? (8 * 1024) : (16 * 1024)); |
| 90 | cpu_data(id).dcache_size = prom_getintdefault(cpu_node, "dcache-size", | 92 | cpu_data(id).dcache_size = |
| 91 | def); | 93 | of_getintprop_default(dp, "dcache-size", def); |
| 92 | 94 | ||
| 93 | def = 32; | 95 | def = 32; |
| 94 | cpu_data(id).dcache_line_size = | 96 | cpu_data(id).dcache_line_size = |
| 95 | prom_getintdefault(cpu_node, "dcache-line-size", def); | 97 | of_getintprop_default(dp, "dcache-line-size", def); |
| 96 | 98 | ||
| 97 | def = 16 * 1024; | 99 | def = 16 * 1024; |
| 98 | cpu_data(id).icache_size = prom_getintdefault(cpu_node, "icache-size", | 100 | cpu_data(id).icache_size = |
| 99 | def); | 101 | of_getintprop_default(dp, "icache-size", def); |
| 100 | 102 | ||
| 101 | def = 32; | 103 | def = 32; |
| 102 | cpu_data(id).icache_line_size = | 104 | cpu_data(id).icache_line_size = |
| 103 | prom_getintdefault(cpu_node, "icache-line-size", def); | 105 | of_getintprop_default(dp, "icache-line-size", def); |
| 104 | 106 | ||
| 105 | def = ((tlb_type == hypervisor) ? | 107 | def = ((tlb_type == hypervisor) ? |
| 106 | (3 * 1024 * 1024) : | 108 | (3 * 1024 * 1024) : |
| 107 | (4 * 1024 * 1024)); | 109 | (4 * 1024 * 1024)); |
| 108 | cpu_data(id).ecache_size = prom_getintdefault(cpu_node, "ecache-size", | 110 | cpu_data(id).ecache_size = |
| 109 | def); | 111 | of_getintprop_default(dp, "ecache-size", def); |
| 110 | 112 | ||
| 111 | def = 64; | 113 | def = 64; |
| 112 | cpu_data(id).ecache_line_size = | 114 | cpu_data(id).ecache_line_size = |
| 113 | prom_getintdefault(cpu_node, "ecache-line-size", def); | 115 | of_getintprop_default(dp, "ecache-line-size", def); |
| 114 | 116 | ||
| 115 | printk("CPU[%d]: Caches " | 117 | printk("CPU[%d]: Caches " |
| 116 | "D[sz(%d):line_sz(%d)] " | 118 | "D[sz(%d):line_sz(%d)] " |
| @@ -342,10 +344,10 @@ static int __devinit smp_boot_one_cpu(unsigned int cpu) | |||
| 342 | 344 | ||
| 343 | prom_startcpu_cpuid(cpu, entry, cookie); | 345 | prom_startcpu_cpuid(cpu, entry, cookie); |
| 344 | } else { | 346 | } else { |
| 345 | int cpu_node; | 347 | struct device_node *dp; |
| 346 | 348 | ||
| 347 | cpu_find_by_mid(cpu, &cpu_node); | 349 | cpu_find_by_mid(cpu, &dp); |
| 348 | prom_startcpu(cpu_node, entry, cookie); | 350 | prom_startcpu(dp->node, entry, cookie); |
| 349 | } | 351 | } |
| 350 | 352 | ||
| 351 | for (timeout = 0; timeout < 5000000; timeout++) { | 353 | for (timeout = 0; timeout < 5000000; timeout++) { |
| @@ -1289,7 +1291,8 @@ int setup_profiling_timer(unsigned int multiplier) | |||
| 1289 | 1291 | ||
| 1290 | static void __init smp_tune_scheduling(void) | 1292 | static void __init smp_tune_scheduling(void) |
| 1291 | { | 1293 | { |
| 1292 | int instance, node; | 1294 | struct device_node *dp; |
| 1295 | int instance; | ||
| 1293 | unsigned int def, smallest = ~0U; | 1296 | unsigned int def, smallest = ~0U; |
| 1294 | 1297 | ||
| 1295 | def = ((tlb_type == hypervisor) ? | 1298 | def = ((tlb_type == hypervisor) ? |
| @@ -1297,10 +1300,10 @@ static void __init smp_tune_scheduling(void) | |||
| 1297 | (4 * 1024 * 1024)); | 1300 | (4 * 1024 * 1024)); |
| 1298 | 1301 | ||
| 1299 | instance = 0; | 1302 | instance = 0; |
| 1300 | while (!cpu_find_by_instance(instance, &node, NULL)) { | 1303 | while (!cpu_find_by_instance(instance, &dp, NULL)) { |
| 1301 | unsigned int val; | 1304 | unsigned int val; |
| 1302 | 1305 | ||
| 1303 | val = prom_getintdefault(node, "ecache-size", def); | 1306 | val = of_getintprop_default(dp, "ecache-size", def); |
| 1304 | if (val < smallest) | 1307 | if (val < smallest) |
| 1305 | smallest = val; | 1308 | smallest = val; |
| 1306 | 1309 | ||
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index 0f00a99927e9..348b82035561 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c | |||
| @@ -48,6 +48,7 @@ | |||
| 48 | #include <asm/sections.h> | 48 | #include <asm/sections.h> |
| 49 | #include <asm/cpudata.h> | 49 | #include <asm/cpudata.h> |
| 50 | #include <asm/uaccess.h> | 50 | #include <asm/uaccess.h> |
| 51 | #include <asm/prom.h> | ||
| 51 | 52 | ||
| 52 | DEFINE_SPINLOCK(mostek_lock); | 53 | DEFINE_SPINLOCK(mostek_lock); |
| 53 | DEFINE_SPINLOCK(rtc_lock); | 54 | DEFINE_SPINLOCK(rtc_lock); |
| @@ -755,24 +756,200 @@ retry: | |||
| 755 | return -EOPNOTSUPP; | 756 | return -EOPNOTSUPP; |
| 756 | } | 757 | } |
| 757 | 758 | ||
| 758 | void __init clock_probe(void) | 759 | static int __init clock_model_matches(char *model) |
| 759 | { | 760 | { |
| 760 | struct linux_prom_registers clk_reg[2]; | 761 | if (strcmp(model, "mk48t02") && |
| 761 | char model[128]; | 762 | strcmp(model, "mk48t08") && |
| 762 | int node, busnd = -1, err; | 763 | strcmp(model, "mk48t59") && |
| 763 | unsigned long flags; | 764 | strcmp(model, "m5819") && |
| 764 | struct linux_central *cbus; | 765 | strcmp(model, "m5819p") && |
| 766 | strcmp(model, "m5823") && | ||
| 767 | strcmp(model, "ds1287")) | ||
| 768 | return 0; | ||
| 769 | |||
| 770 | return 1; | ||
| 771 | } | ||
| 772 | |||
| 773 | static void __init __clock_assign_common(void __iomem *addr, char *model) | ||
| 774 | { | ||
| 775 | if (model[5] == '0' && model[6] == '2') { | ||
| 776 | mstk48t02_regs = addr; | ||
| 777 | } else if(model[5] == '0' && model[6] == '8') { | ||
| 778 | mstk48t08_regs = addr; | ||
| 779 | mstk48t02_regs = mstk48t08_regs + MOSTEK_48T08_48T02; | ||
| 780 | } else { | ||
| 781 | mstk48t59_regs = addr; | ||
| 782 | mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; | ||
| 783 | } | ||
| 784 | } | ||
| 785 | |||
| 786 | static void __init clock_assign_clk_reg(struct linux_prom_registers *clk_reg, | ||
| 787 | char *model) | ||
| 788 | { | ||
| 789 | unsigned long addr; | ||
| 790 | |||
| 791 | addr = ((unsigned long) clk_reg[0].phys_addr | | ||
| 792 | (((unsigned long) clk_reg[0].which_io) << 32UL)); | ||
| 793 | |||
| 794 | __clock_assign_common((void __iomem *) addr, model); | ||
| 795 | } | ||
| 796 | |||
| 797 | static int __init clock_probe_central(void) | ||
| 798 | { | ||
| 799 | struct linux_prom_registers clk_reg[2], *pr; | ||
| 800 | struct device_node *dp; | ||
| 801 | char *model; | ||
| 802 | |||
| 803 | if (!central_bus) | ||
| 804 | return 0; | ||
| 805 | |||
| 806 | /* Get Central FHC's prom node. */ | ||
| 807 | dp = central_bus->child->prom_node; | ||
| 808 | |||
| 809 | /* Then get the first child device below it. */ | ||
| 810 | dp = dp->child; | ||
| 811 | |||
| 812 | while (dp) { | ||
| 813 | model = of_get_property(dp, "model", NULL); | ||
| 814 | if (!model || !clock_model_matches(model)) | ||
| 815 | goto next_sibling; | ||
| 816 | |||
| 817 | pr = of_get_property(dp, "reg", NULL); | ||
| 818 | memcpy(clk_reg, pr, sizeof(clk_reg)); | ||
| 819 | |||
| 820 | apply_fhc_ranges(central_bus->child, clk_reg, 1); | ||
| 821 | apply_central_ranges(central_bus, clk_reg, 1); | ||
| 822 | |||
| 823 | clock_assign_clk_reg(clk_reg, model); | ||
| 824 | return 1; | ||
| 825 | |||
| 826 | next_sibling: | ||
| 827 | dp = dp->sibling; | ||
| 828 | } | ||
| 829 | |||
| 830 | return 0; | ||
| 831 | } | ||
| 832 | |||
| 765 | #ifdef CONFIG_PCI | 833 | #ifdef CONFIG_PCI |
| 766 | struct linux_ebus *ebus = NULL; | 834 | static void __init clock_isa_ebus_assign_regs(struct resource *res, char *model) |
| 767 | struct sparc_isa_bridge *isa_br = NULL; | 835 | { |
| 836 | if (!strcmp(model, "ds1287") || | ||
| 837 | !strcmp(model, "m5819") || | ||
| 838 | !strcmp(model, "m5819p") || | ||
| 839 | !strcmp(model, "m5823")) { | ||
| 840 | ds1287_regs = res->start; | ||
| 841 | } else { | ||
| 842 | mstk48t59_regs = (void __iomem *) res->start; | ||
| 843 | mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; | ||
| 844 | } | ||
| 845 | } | ||
| 846 | |||
| 847 | static int __init clock_probe_one_ebus_dev(struct linux_ebus_device *edev) | ||
| 848 | { | ||
| 849 | struct device_node *dp = edev->prom_node; | ||
| 850 | char *model; | ||
| 851 | |||
| 852 | model = of_get_property(dp, "model", NULL); | ||
| 853 | if (!clock_model_matches(model)) | ||
| 854 | return 0; | ||
| 855 | |||
| 856 | clock_isa_ebus_assign_regs(&edev->resource[0], model); | ||
| 857 | |||
| 858 | return 1; | ||
| 859 | } | ||
| 860 | |||
| 861 | static int __init clock_probe_ebus(void) | ||
| 862 | { | ||
| 863 | struct linux_ebus *ebus; | ||
| 864 | |||
| 865 | for_each_ebus(ebus) { | ||
| 866 | struct linux_ebus_device *edev; | ||
| 867 | |||
| 868 | for_each_ebusdev(edev, ebus) { | ||
| 869 | if (clock_probe_one_ebus_dev(edev)) | ||
| 870 | return 1; | ||
| 871 | } | ||
| 872 | } | ||
| 873 | |||
| 874 | return 0; | ||
| 875 | } | ||
| 876 | |||
| 877 | static int __init clock_probe_one_isa_dev(struct sparc_isa_device *idev) | ||
| 878 | { | ||
| 879 | struct device_node *dp = idev->prom_node; | ||
| 880 | char *model; | ||
| 881 | |||
| 882 | model = of_get_property(dp, "model", NULL); | ||
| 883 | if (!clock_model_matches(model)) | ||
| 884 | return 0; | ||
| 885 | |||
| 886 | clock_isa_ebus_assign_regs(&idev->resource, model); | ||
| 887 | |||
| 888 | return 1; | ||
| 889 | } | ||
| 890 | |||
| 891 | static int __init clock_probe_isa(void) | ||
| 892 | { | ||
| 893 | struct sparc_isa_bridge *isa_br; | ||
| 894 | |||
| 895 | for_each_isa(isa_br) { | ||
| 896 | struct sparc_isa_device *isa_dev; | ||
| 897 | |||
| 898 | for_each_isadev(isa_dev, isa_br) { | ||
| 899 | if (clock_probe_one_isa_dev(isa_dev)) | ||
| 900 | return 1; | ||
| 901 | } | ||
| 902 | } | ||
| 903 | |||
| 904 | return 0; | ||
| 905 | } | ||
| 906 | #endif /* CONFIG_PCI */ | ||
| 907 | |||
| 908 | #ifdef CONFIG_SBUS | ||
| 909 | static int __init clock_probe_one_sbus_dev(struct sbus_bus *sbus, struct sbus_dev *sdev) | ||
| 910 | { | ||
| 911 | struct resource *res; | ||
| 912 | char model[64]; | ||
| 913 | void __iomem *addr; | ||
| 914 | |||
| 915 | prom_getstring(sdev->prom_node, "model", model, sizeof(model)); | ||
| 916 | if (!clock_model_matches(model)) | ||
| 917 | return 0; | ||
| 918 | |||
| 919 | res = &sdev->resource[0]; | ||
| 920 | addr = sbus_ioremap(res, 0, 0x800UL, "eeprom"); | ||
| 921 | |||
| 922 | __clock_assign_common(addr, model); | ||
| 923 | |||
| 924 | return 1; | ||
| 925 | } | ||
| 926 | |||
| 927 | static int __init clock_probe_sbus(void) | ||
| 928 | { | ||
| 929 | struct sbus_bus *sbus; | ||
| 930 | |||
| 931 | for_each_sbus(sbus) { | ||
| 932 | struct sbus_dev *sdev; | ||
| 933 | |||
| 934 | for_each_sbusdev(sdev, sbus) { | ||
| 935 | if (clock_probe_one_sbus_dev(sbus, sdev)) | ||
| 936 | return 1; | ||
| 937 | } | ||
| 938 | } | ||
| 939 | |||
| 940 | return 0; | ||
| 941 | } | ||
| 768 | #endif | 942 | #endif |
| 943 | |||
| 944 | void __init clock_probe(void) | ||
| 945 | { | ||
| 769 | static int invoked; | 946 | static int invoked; |
| 947 | unsigned long flags; | ||
| 770 | 948 | ||
| 771 | if (invoked) | 949 | if (invoked) |
| 772 | return; | 950 | return; |
| 773 | invoked = 1; | 951 | invoked = 1; |
| 774 | 952 | ||
| 775 | |||
| 776 | if (this_is_starfire) { | 953 | if (this_is_starfire) { |
| 777 | xtime.tv_sec = starfire_get_time(); | 954 | xtime.tv_sec = starfire_get_time(); |
| 778 | xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ); | 955 | xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ); |
| @@ -788,183 +965,27 @@ void __init clock_probe(void) | |||
| 788 | return; | 965 | return; |
| 789 | } | 966 | } |
| 790 | 967 | ||
| 791 | local_irq_save(flags); | ||
| 792 | |||
| 793 | cbus = central_bus; | ||
| 794 | if (cbus != NULL) | ||
| 795 | busnd = central_bus->child->prom_node; | ||
| 796 | |||
| 797 | /* Check FHC Central then EBUSs then ISA bridges then SBUSs. | 968 | /* Check FHC Central then EBUSs then ISA bridges then SBUSs. |
| 798 | * That way we handle the presence of multiple properly. | 969 | * That way we handle the presence of multiple properly. |
| 799 | * | 970 | * |
| 800 | * As a special case, machines with Central must provide the | 971 | * As a special case, machines with Central must provide the |
| 801 | * timer chip there. | 972 | * timer chip there. |
| 802 | */ | 973 | */ |
| 974 | if (!clock_probe_central() && | ||
| 803 | #ifdef CONFIG_PCI | 975 | #ifdef CONFIG_PCI |
| 804 | if (ebus_chain != NULL) { | 976 | !clock_probe_ebus() && |
| 805 | ebus = ebus_chain; | 977 | !clock_probe_isa() && |
| 806 | if (busnd == -1) | ||
| 807 | busnd = ebus->prom_node; | ||
| 808 | } | ||
| 809 | if (isa_chain != NULL) { | ||
| 810 | isa_br = isa_chain; | ||
| 811 | if (busnd == -1) | ||
| 812 | busnd = isa_br->prom_node; | ||
| 813 | } | ||
| 814 | #endif | ||
| 815 | if (sbus_root != NULL && busnd == -1) | ||
| 816 | busnd = sbus_root->prom_node; | ||
| 817 | |||
| 818 | if (busnd == -1) { | ||
| 819 | prom_printf("clock_probe: problem, cannot find bus to search.\n"); | ||
| 820 | prom_halt(); | ||
| 821 | } | ||
| 822 | |||
| 823 | node = prom_getchild(busnd); | ||
| 824 | |||
| 825 | while (1) { | ||
| 826 | if (!node) | ||
| 827 | model[0] = 0; | ||
| 828 | else | ||
| 829 | prom_getstring(node, "model", model, sizeof(model)); | ||
| 830 | if (strcmp(model, "mk48t02") && | ||
| 831 | strcmp(model, "mk48t08") && | ||
| 832 | strcmp(model, "mk48t59") && | ||
| 833 | strcmp(model, "m5819") && | ||
| 834 | strcmp(model, "m5819p") && | ||
| 835 | strcmp(model, "m5823") && | ||
| 836 | strcmp(model, "ds1287")) { | ||
| 837 | if (cbus != NULL) { | ||
| 838 | prom_printf("clock_probe: Central bus lacks timer chip.\n"); | ||
| 839 | prom_halt(); | ||
| 840 | } | ||
| 841 | |||
| 842 | if (node != 0) | ||
| 843 | node = prom_getsibling(node); | ||
| 844 | #ifdef CONFIG_PCI | ||
| 845 | while ((node == 0) && ebus != NULL) { | ||
| 846 | ebus = ebus->next; | ||
| 847 | if (ebus != NULL) { | ||
| 848 | busnd = ebus->prom_node; | ||
| 849 | node = prom_getchild(busnd); | ||
| 850 | } | ||
| 851 | } | ||
| 852 | while ((node == 0) && isa_br != NULL) { | ||
| 853 | isa_br = isa_br->next; | ||
| 854 | if (isa_br != NULL) { | ||
| 855 | busnd = isa_br->prom_node; | ||
| 856 | node = prom_getchild(busnd); | ||
| 857 | } | ||
| 858 | } | ||
| 859 | #endif | 978 | #endif |
| 860 | if (node == 0) { | 979 | #ifdef CONFIG_SBUS |
| 861 | prom_printf("clock_probe: Cannot find timer chip\n"); | 980 | !clock_probe_sbus() |
| 862 | prom_halt(); | ||
| 863 | } | ||
| 864 | continue; | ||
| 865 | } | ||
| 866 | |||
| 867 | err = prom_getproperty(node, "reg", (char *)clk_reg, | ||
| 868 | sizeof(clk_reg)); | ||
| 869 | if(err == -1) { | ||
| 870 | prom_printf("clock_probe: Cannot get Mostek reg property\n"); | ||
| 871 | prom_halt(); | ||
| 872 | } | ||
| 873 | |||
| 874 | if (cbus != NULL) { | ||
| 875 | apply_fhc_ranges(central_bus->child, clk_reg, 1); | ||
| 876 | apply_central_ranges(central_bus, clk_reg, 1); | ||
| 877 | } | ||
| 878 | #ifdef CONFIG_PCI | ||
| 879 | else if (ebus != NULL) { | ||
| 880 | struct linux_ebus_device *edev; | ||
| 881 | |||
| 882 | for_each_ebusdev(edev, ebus) | ||
| 883 | if (edev->prom_node == node) | ||
| 884 | break; | ||
| 885 | if (edev == NULL) { | ||
| 886 | if (isa_chain != NULL) | ||
| 887 | goto try_isa_clock; | ||
| 888 | prom_printf("%s: Mostek not probed by EBUS\n", | ||
| 889 | __FUNCTION__); | ||
| 890 | prom_halt(); | ||
| 891 | } | ||
| 892 | |||
| 893 | if (!strcmp(model, "ds1287") || | ||
| 894 | !strcmp(model, "m5819") || | ||
| 895 | !strcmp(model, "m5819p") || | ||
| 896 | !strcmp(model, "m5823")) { | ||
| 897 | ds1287_regs = edev->resource[0].start; | ||
| 898 | } else { | ||
| 899 | mstk48t59_regs = (void __iomem *) | ||
| 900 | edev->resource[0].start; | ||
| 901 | mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; | ||
| 902 | } | ||
| 903 | break; | ||
| 904 | } | ||
| 905 | else if (isa_br != NULL) { | ||
| 906 | struct sparc_isa_device *isadev; | ||
| 907 | |||
| 908 | try_isa_clock: | ||
| 909 | for_each_isadev(isadev, isa_br) | ||
| 910 | if (isadev->prom_node == node) | ||
| 911 | break; | ||
| 912 | if (isadev == NULL) { | ||
| 913 | prom_printf("%s: Mostek not probed by ISA\n"); | ||
| 914 | prom_halt(); | ||
| 915 | } | ||
| 916 | if (!strcmp(model, "ds1287") || | ||
| 917 | !strcmp(model, "m5819") || | ||
| 918 | !strcmp(model, "m5819p") || | ||
| 919 | !strcmp(model, "m5823")) { | ||
| 920 | ds1287_regs = isadev->resource.start; | ||
| 921 | } else { | ||
| 922 | mstk48t59_regs = (void __iomem *) | ||
| 923 | isadev->resource.start; | ||
| 924 | mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; | ||
| 925 | } | ||
| 926 | break; | ||
| 927 | } | ||
| 928 | #endif | 981 | #endif |
| 929 | else { | 982 | ) { |
| 930 | if (sbus_root->num_sbus_ranges) { | 983 | printk(KERN_WARNING "No clock chip found.\n"); |
| 931 | int nranges = sbus_root->num_sbus_ranges; | 984 | return; |
| 932 | int rngc; | ||
| 933 | |||
| 934 | for (rngc = 0; rngc < nranges; rngc++) | ||
| 935 | if (clk_reg[0].which_io == | ||
| 936 | sbus_root->sbus_ranges[rngc].ot_child_space) | ||
| 937 | break; | ||
| 938 | if (rngc == nranges) { | ||
| 939 | prom_printf("clock_probe: Cannot find ranges for " | ||
| 940 | "clock regs.\n"); | ||
| 941 | prom_halt(); | ||
| 942 | } | ||
| 943 | clk_reg[0].which_io = | ||
| 944 | sbus_root->sbus_ranges[rngc].ot_parent_space; | ||
| 945 | clk_reg[0].phys_addr += | ||
| 946 | sbus_root->sbus_ranges[rngc].ot_parent_base; | ||
| 947 | } | ||
| 948 | } | ||
| 949 | |||
| 950 | if(model[5] == '0' && model[6] == '2') { | ||
| 951 | mstk48t02_regs = (void __iomem *) | ||
| 952 | (((u64)clk_reg[0].phys_addr) | | ||
| 953 | (((u64)clk_reg[0].which_io)<<32UL)); | ||
| 954 | } else if(model[5] == '0' && model[6] == '8') { | ||
| 955 | mstk48t08_regs = (void __iomem *) | ||
| 956 | (((u64)clk_reg[0].phys_addr) | | ||
| 957 | (((u64)clk_reg[0].which_io)<<32UL)); | ||
| 958 | mstk48t02_regs = mstk48t08_regs + MOSTEK_48T08_48T02; | ||
| 959 | } else { | ||
| 960 | mstk48t59_regs = (void __iomem *) | ||
| 961 | (((u64)clk_reg[0].phys_addr) | | ||
| 962 | (((u64)clk_reg[0].which_io)<<32UL)); | ||
| 963 | mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; | ||
| 964 | } | ||
| 965 | break; | ||
| 966 | } | 985 | } |
| 967 | 986 | ||
| 987 | local_irq_save(flags); | ||
| 988 | |||
| 968 | if (mstk48t02_regs != NULL) { | 989 | if (mstk48t02_regs != NULL) { |
| 969 | /* Report a low battery voltage condition. */ | 990 | /* Report a low battery voltage condition. */ |
| 970 | if (has_low_battery()) | 991 | if (has_low_battery()) |
| @@ -983,12 +1004,14 @@ try_isa_clock: | |||
| 983 | /* This is gets the master TICK_INT timer going. */ | 1004 | /* This is gets the master TICK_INT timer going. */ |
| 984 | static unsigned long sparc64_init_timers(void) | 1005 | static unsigned long sparc64_init_timers(void) |
| 985 | { | 1006 | { |
| 1007 | struct device_node *dp; | ||
| 1008 | struct property *prop; | ||
| 986 | unsigned long clock; | 1009 | unsigned long clock; |
| 987 | int node; | ||
| 988 | #ifdef CONFIG_SMP | 1010 | #ifdef CONFIG_SMP |
| 989 | extern void smp_tick_init(void); | 1011 | extern void smp_tick_init(void); |
| 990 | #endif | 1012 | #endif |
| 991 | 1013 | ||
| 1014 | dp = of_find_node_by_path("/"); | ||
| 992 | if (tlb_type == spitfire) { | 1015 | if (tlb_type == spitfire) { |
| 993 | unsigned long ver, manuf, impl; | 1016 | unsigned long ver, manuf, impl; |
| 994 | 1017 | ||
| @@ -999,18 +1022,17 @@ static unsigned long sparc64_init_timers(void) | |||
| 999 | if (manuf == 0x17 && impl == 0x13) { | 1022 | if (manuf == 0x17 && impl == 0x13) { |
| 1000 | /* Hummingbird, aka Ultra-IIe */ | 1023 | /* Hummingbird, aka Ultra-IIe */ |
| 1001 | tick_ops = &hbtick_operations; | 1024 | tick_ops = &hbtick_operations; |
| 1002 | node = prom_root_node; | 1025 | prop = of_find_property(dp, "stick-frequency", NULL); |
| 1003 | clock = prom_getint(node, "stick-frequency"); | ||
| 1004 | } else { | 1026 | } else { |
| 1005 | tick_ops = &tick_operations; | 1027 | tick_ops = &tick_operations; |
| 1006 | cpu_find_by_instance(0, &node, NULL); | 1028 | cpu_find_by_instance(0, &dp, NULL); |
| 1007 | clock = prom_getint(node, "clock-frequency"); | 1029 | prop = of_find_property(dp, "clock-frequency", NULL); |
| 1008 | } | 1030 | } |
| 1009 | } else { | 1031 | } else { |
| 1010 | tick_ops = &stick_operations; | 1032 | tick_ops = &stick_operations; |
| 1011 | node = prom_root_node; | 1033 | prop = of_find_property(dp, "stick-frequency", NULL); |
| 1012 | clock = prom_getint(node, "stick-frequency"); | ||
| 1013 | } | 1034 | } |
| 1035 | clock = *(unsigned int *) prop->value; | ||
| 1014 | timer_tick_offset = clock / HZ; | 1036 | timer_tick_offset = clock / HZ; |
| 1015 | 1037 | ||
| 1016 | #ifdef CONFIG_SMP | 1038 | #ifdef CONFIG_SMP |
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c index 5059cbd4feee..1ff34b019f3f 100644 --- a/arch/sparc64/kernel/traps.c +++ b/arch/sparc64/kernel/traps.c | |||
| @@ -42,6 +42,7 @@ | |||
| 42 | #ifdef CONFIG_KMOD | 42 | #ifdef CONFIG_KMOD |
| 43 | #include <linux/kmod.h> | 43 | #include <linux/kmod.h> |
| 44 | #endif | 44 | #endif |
| 45 | #include <asm/prom.h> | ||
| 45 | 46 | ||
| 46 | ATOMIC_NOTIFIER_HEAD(sparc64die_chain); | 47 | ATOMIC_NOTIFIER_HEAD(sparc64die_chain); |
| 47 | 48 | ||
| @@ -807,7 +808,8 @@ extern unsigned int cheetah_deferred_trap_vector[], cheetah_deferred_trap_vector | |||
| 807 | void __init cheetah_ecache_flush_init(void) | 808 | void __init cheetah_ecache_flush_init(void) |
| 808 | { | 809 | { |
| 809 | unsigned long largest_size, smallest_linesize, order, ver; | 810 | unsigned long largest_size, smallest_linesize, order, ver; |
| 810 | int node, i, instance; | 811 | struct device_node *dp; |
| 812 | int i, instance, sz; | ||
| 811 | 813 | ||
| 812 | /* Scan all cpu device tree nodes, note two values: | 814 | /* Scan all cpu device tree nodes, note two values: |
| 813 | * 1) largest E-cache size | 815 | * 1) largest E-cache size |
| @@ -817,14 +819,14 @@ void __init cheetah_ecache_flush_init(void) | |||
| 817 | smallest_linesize = ~0UL; | 819 | smallest_linesize = ~0UL; |
| 818 | 820 | ||
| 819 | instance = 0; | 821 | instance = 0; |
| 820 | while (!cpu_find_by_instance(instance, &node, NULL)) { | 822 | while (!cpu_find_by_instance(instance, &dp, NULL)) { |
| 821 | unsigned long val; | 823 | unsigned long val; |
| 822 | 824 | ||
| 823 | val = prom_getintdefault(node, "ecache-size", | 825 | val = of_getintprop_default(dp, "ecache-size", |
| 824 | (2 * 1024 * 1024)); | 826 | (2 * 1024 * 1024)); |
| 825 | if (val > largest_size) | 827 | if (val > largest_size) |
| 826 | largest_size = val; | 828 | largest_size = val; |
| 827 | val = prom_getintdefault(node, "ecache-line-size", 64); | 829 | val = of_getintprop_default(dp, "ecache-line-size", 64); |
| 828 | if (val < smallest_linesize) | 830 | if (val < smallest_linesize) |
| 829 | smallest_linesize = val; | 831 | smallest_linesize = val; |
| 830 | instance++; | 832 | instance++; |
| @@ -849,16 +851,16 @@ void __init cheetah_ecache_flush_init(void) | |||
| 849 | } | 851 | } |
| 850 | 852 | ||
| 851 | /* Now allocate error trap reporting scoreboard. */ | 853 | /* Now allocate error trap reporting scoreboard. */ |
| 852 | node = NR_CPUS * (2 * sizeof(struct cheetah_err_info)); | 854 | sz = NR_CPUS * (2 * sizeof(struct cheetah_err_info)); |
| 853 | for (order = 0; order < MAX_ORDER; order++) { | 855 | for (order = 0; order < MAX_ORDER; order++) { |
| 854 | if ((PAGE_SIZE << order) >= node) | 856 | if ((PAGE_SIZE << order) >= sz) |
| 855 | break; | 857 | break; |
| 856 | } | 858 | } |
| 857 | cheetah_error_log = (struct cheetah_err_info *) | 859 | cheetah_error_log = (struct cheetah_err_info *) |
| 858 | __get_free_pages(GFP_KERNEL, order); | 860 | __get_free_pages(GFP_KERNEL, order); |
| 859 | if (!cheetah_error_log) { | 861 | if (!cheetah_error_log) { |
| 860 | prom_printf("cheetah_ecache_flush_init: Failed to allocate " | 862 | prom_printf("cheetah_ecache_flush_init: Failed to allocate " |
| 861 | "error logging scoreboard (%d bytes).\n", node); | 863 | "error logging scoreboard (%d bytes).\n", sz); |
| 862 | prom_halt(); | 864 | prom_halt(); |
| 863 | } | 865 | } |
| 864 | memset(cheetah_error_log, 0, PAGE_SIZE << order); | 866 | memset(cheetah_error_log, 0, PAGE_SIZE << order); |
diff --git a/arch/sparc64/kernel/unaligned.c b/arch/sparc64/kernel/unaligned.c index 001e8518331f..bb2d68577855 100644 --- a/arch/sparc64/kernel/unaligned.c +++ b/arch/sparc64/kernel/unaligned.c | |||
| @@ -279,12 +279,21 @@ static void kernel_mna_trap_fault(void) | |||
| 279 | 279 | ||
| 280 | asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn) | 280 | asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn) |
| 281 | { | 281 | { |
| 282 | static unsigned long count, last_time; | ||
| 282 | enum direction dir = decode_direction(insn); | 283 | enum direction dir = decode_direction(insn); |
| 283 | int size = decode_access_size(insn); | 284 | int size = decode_access_size(insn); |
| 284 | 285 | ||
| 285 | current_thread_info()->kern_una_regs = regs; | 286 | current_thread_info()->kern_una_regs = regs; |
| 286 | current_thread_info()->kern_una_insn = insn; | 287 | current_thread_info()->kern_una_insn = insn; |
| 287 | 288 | ||
| 289 | if (jiffies - last_time > 5 * HZ) | ||
| 290 | count = 0; | ||
| 291 | if (count < 5) { | ||
| 292 | last_time = jiffies; | ||
| 293 | count++; | ||
| 294 | printk("Kernel unaligned access at TPC[%lx]\n", regs->tpc); | ||
| 295 | } | ||
| 296 | |||
| 288 | if (!ok_for_kernel(insn) || dir == both) { | 297 | if (!ok_for_kernel(insn) || dir == both) { |
| 289 | printk("Unsupported unaligned load/store trap for kernel " | 298 | printk("Unsupported unaligned load/store trap for kernel " |
| 290 | "at <%016lx>.\n", regs->tpc); | 299 | "at <%016lx>.\n", regs->tpc); |
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c index 1539a8362b6f..513993414747 100644 --- a/arch/sparc64/mm/init.c +++ b/arch/sparc64/mm/init.c | |||
| @@ -42,6 +42,7 @@ | |||
| 42 | #include <asm/sections.h> | 42 | #include <asm/sections.h> |
| 43 | #include <asm/tsb.h> | 43 | #include <asm/tsb.h> |
| 44 | #include <asm/hypervisor.h> | 44 | #include <asm/hypervisor.h> |
| 45 | #include <asm/prom.h> | ||
| 45 | 46 | ||
| 46 | extern void device_scan(void); | 47 | extern void device_scan(void); |
| 47 | 48 | ||
| @@ -101,8 +102,6 @@ static void __init read_obp_memory(const char *property, | |||
| 101 | prom_halt(); | 102 | prom_halt(); |
| 102 | } | 103 | } |
| 103 | 104 | ||
| 104 | *num_ents = ents; | ||
| 105 | |||
| 106 | /* Sanitize what we got from the firmware, by page aligning | 105 | /* Sanitize what we got from the firmware, by page aligning |
| 107 | * everything. | 106 | * everything. |
| 108 | */ | 107 | */ |
| @@ -124,6 +123,25 @@ static void __init read_obp_memory(const char *property, | |||
| 124 | regs[i].phys_addr = base; | 123 | regs[i].phys_addr = base; |
| 125 | regs[i].reg_size = size; | 124 | regs[i].reg_size = size; |
| 126 | } | 125 | } |
| 126 | |||
| 127 | for (i = 0; i < ents; i++) { | ||
| 128 | if (regs[i].reg_size == 0UL) { | ||
| 129 | int j; | ||
| 130 | |||
| 131 | for (j = i; j < ents - 1; j++) { | ||
| 132 | regs[j].phys_addr = | ||
| 133 | regs[j+1].phys_addr; | ||
| 134 | regs[j].reg_size = | ||
| 135 | regs[j+1].reg_size; | ||
| 136 | } | ||
| 137 | |||
| 138 | ents--; | ||
| 139 | i--; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | *num_ents = ents; | ||
| 144 | |||
| 127 | sort(regs, ents, sizeof(struct linux_prom64_registers), | 145 | sort(regs, ents, sizeof(struct linux_prom64_registers), |
| 128 | cmp_p64, NULL); | 146 | cmp_p64, NULL); |
| 129 | } | 147 | } |
| @@ -1339,6 +1357,8 @@ void __init paging_init(void) | |||
| 1339 | 1357 | ||
| 1340 | kernel_physical_mapping_init(); | 1358 | kernel_physical_mapping_init(); |
| 1341 | 1359 | ||
| 1360 | prom_build_devicetree(); | ||
| 1361 | |||
| 1342 | { | 1362 | { |
| 1343 | unsigned long zones_size[MAX_NR_ZONES]; | 1363 | unsigned long zones_size[MAX_NR_ZONES]; |
| 1344 | unsigned long zholes_size[MAX_NR_ZONES]; | 1364 | unsigned long zholes_size[MAX_NR_ZONES]; |
| @@ -1376,7 +1396,7 @@ static void __init taint_real_pages(void) | |||
| 1376 | while (old_start < old_end) { | 1396 | while (old_start < old_end) { |
| 1377 | int n; | 1397 | int n; |
| 1378 | 1398 | ||
| 1379 | for (n = 0; pavail_rescan_ents; n++) { | 1399 | for (n = 0; n < pavail_rescan_ents; n++) { |
| 1380 | unsigned long new_start, new_end; | 1400 | unsigned long new_start, new_end; |
| 1381 | 1401 | ||
| 1382 | new_start = pavail_rescan[n].phys_addr; | 1402 | new_start = pavail_rescan[n].phys_addr; |
| @@ -1398,6 +1418,32 @@ static void __init taint_real_pages(void) | |||
| 1398 | } | 1418 | } |
| 1399 | } | 1419 | } |
| 1400 | 1420 | ||
| 1421 | int __init page_in_phys_avail(unsigned long paddr) | ||
| 1422 | { | ||
| 1423 | int i; | ||
| 1424 | |||
| 1425 | paddr &= PAGE_MASK; | ||
| 1426 | |||
| 1427 | for (i = 0; i < pavail_rescan_ents; i++) { | ||
| 1428 | unsigned long start, end; | ||
| 1429 | |||
| 1430 | start = pavail_rescan[i].phys_addr; | ||
| 1431 | end = start + pavail_rescan[i].reg_size; | ||
| 1432 | |||
| 1433 | if (paddr >= start && paddr < end) | ||
| 1434 | return 1; | ||
| 1435 | } | ||
| 1436 | if (paddr >= kern_base && paddr < (kern_base + kern_size)) | ||
| 1437 | return 1; | ||
| 1438 | #ifdef CONFIG_BLK_DEV_INITRD | ||
| 1439 | if (paddr >= __pa(initrd_start) && | ||
| 1440 | paddr < __pa(PAGE_ALIGN(initrd_end))) | ||
| 1441 | return 1; | ||
| 1442 | #endif | ||
| 1443 | |||
| 1444 | return 0; | ||
| 1445 | } | ||
| 1446 | |||
| 1401 | void __init mem_init(void) | 1447 | void __init mem_init(void) |
| 1402 | { | 1448 | { |
| 1403 | unsigned long codepages, datapages, initpages; | 1449 | unsigned long codepages, datapages, initpages; |
diff --git a/arch/sparc64/solaris/misc.c b/arch/sparc64/solaris/misc.c index 5284996780a7..719c90905a1e 100644 --- a/arch/sparc64/solaris/misc.c +++ b/arch/sparc64/solaris/misc.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include <asm/oplib.h> | 23 | #include <asm/oplib.h> |
| 24 | #include <asm/idprom.h> | 24 | #include <asm/idprom.h> |
| 25 | #include <asm/smp.h> | 25 | #include <asm/smp.h> |
| 26 | #include <asm/prom.h> | ||
| 26 | 27 | ||
| 27 | #include "conv.h" | 28 | #include "conv.h" |
| 28 | 29 | ||
| @@ -194,14 +195,17 @@ static char *machine(void) | |||
| 194 | } | 195 | } |
| 195 | } | 196 | } |
| 196 | 197 | ||
| 197 | static char *platform(char *buffer) | 198 | static char *platform(char *buffer, int sz) |
| 198 | { | 199 | { |
| 200 | struct device_node *dp = of_find_node_by_path("/"); | ||
| 199 | int len; | 201 | int len; |
| 200 | 202 | ||
| 201 | *buffer = 0; | 203 | *buffer = 0; |
| 202 | len = prom_getproperty(prom_root_node, "name", buffer, 256); | 204 | len = strlen(dp->name); |
| 203 | if(len > 0) | 205 | if (len > sz) |
| 204 | buffer[len] = 0; | 206 | len = sz; |
| 207 | memcpy(buffer, dp->name, len); | ||
| 208 | buffer[len] = 0; | ||
| 205 | if (*buffer) { | 209 | if (*buffer) { |
| 206 | char *p; | 210 | char *p; |
| 207 | 211 | ||
| @@ -213,16 +217,22 @@ static char *platform(char *buffer) | |||
| 213 | return "sun4u"; | 217 | return "sun4u"; |
| 214 | } | 218 | } |
| 215 | 219 | ||
| 216 | static char *serial(char *buffer) | 220 | static char *serial(char *buffer, int sz) |
| 217 | { | 221 | { |
| 218 | int node = prom_getchild(prom_root_node); | 222 | struct device_node *dp = of_find_node_by_path("/options"); |
| 219 | int len; | 223 | int len; |
| 220 | 224 | ||
| 221 | node = prom_searchsiblings(node, "options"); | ||
| 222 | *buffer = 0; | 225 | *buffer = 0; |
| 223 | len = prom_getproperty(node, "system-board-serial#", buffer, 256); | 226 | if (dp) { |
| 224 | if(len > 0) | 227 | char *val = of_get_property(dp, "system-board-serial#", &len); |
| 225 | buffer[len] = 0; | 228 | |
| 229 | if (val && len > 0) { | ||
| 230 | if (len > sz) | ||
| 231 | len = sz; | ||
| 232 | memcpy(buffer, val, len); | ||
| 233 | buffer[len] = 0; | ||
| 234 | } | ||
| 235 | } | ||
| 226 | if (!*buffer) | 236 | if (!*buffer) |
| 227 | return "4512348717234"; | 237 | return "4512348717234"; |
| 228 | else | 238 | else |
| @@ -305,8 +315,8 @@ asmlinkage int solaris_sysinfo(int cmd, u32 buf, s32 count) | |||
| 305 | case SI_MACHINE: r = machine(); break; | 315 | case SI_MACHINE: r = machine(); break; |
| 306 | case SI_ARCHITECTURE: r = "sparc"; break; | 316 | case SI_ARCHITECTURE: r = "sparc"; break; |
| 307 | case SI_HW_PROVIDER: r = "Sun_Microsystems"; break; | 317 | case SI_HW_PROVIDER: r = "Sun_Microsystems"; break; |
| 308 | case SI_HW_SERIAL: r = serial(buffer); break; | 318 | case SI_HW_SERIAL: r = serial(buffer, sizeof(buffer)); break; |
| 309 | case SI_PLATFORM: r = platform(buffer); break; | 319 | case SI_PLATFORM: r = platform(buffer, sizeof(buffer)); break; |
| 310 | case SI_SRPC_DOMAIN: r = ""; break; | 320 | case SI_SRPC_DOMAIN: r = ""; break; |
| 311 | case SI_VERSION: r = "Generic"; break; | 321 | case SI_VERSION: r = "Generic"; break; |
| 312 | default: return -EINVAL; | 322 | default: return -EINVAL; |
