CVS commit: src/sys/arch/macppc/macppc

2021-02-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Feb 11 19:06:24 UTC 2021

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
remove unused/useless #ifdef block


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/macppc/macppc/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.74 src/sys/arch/macppc/macppc/locore.S:1.75
--- src/sys/arch/macppc/macppc/locore.S:1.74	Fri Oct 11 21:56:55 2019
+++ src/sys/arch/macppc/macppc/locore.S	Thu Feb 11 19:06:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.74 2019/10/11 21:56:55 macallan Exp $	*/
+/*	$NetBSD: locore.S,v 1.75 2021/02/11 19:06:24 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -90,11 +90,6 @@ __start:
 #ifndef FIRMWORKSBUGS
 	mtmsr	0			/* Disable FPU/MMU/exceptions */
 #endif
-#if defined(PMAP_OEA64_BRIDGE)
-	mfmsr	0			/* Clear SF and ISF bits */
-	clrldi	0,0,3
-	mtmsrd	0
-#endif /* PMAP_OEA64_BRIDGE */
 	isync
 
 /* compute end of kernel memory */



CVS commit: src/sys/arch/macppc/macppc

2021-02-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Feb 13 01:11:58 UTC 2021

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
Call cpu_model_init() after clearing the MSR.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/macppc/macppc/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.75 src/sys/arch/macppc/macppc/locore.S:1.76
--- src/sys/arch/macppc/macppc/locore.S:1.75	Thu Feb 11 19:06:24 2021
+++ src/sys/arch/macppc/macppc/locore.S	Sat Feb 13 01:11:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.75 2021/02/11 19:06:24 macallan Exp $	*/
+/*	$NetBSD: locore.S,v 1.76 2021/02/13 01:11:58 thorpej Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -82,9 +82,6 @@ _C_LABEL(kernel_text):
 	.globl	__start
 __start:
 	bl	_C_LABEL(ofwinit)		/* init OF */
-	mr	13,6
-	mr	14,7
-	bl	_C_LABEL(cpu_model_init)	/* init oeacpufeat */
 
 	li	0,0
 #ifndef FIRMWORKSBUGS
@@ -92,6 +89,10 @@ __start:
 #endif
 	isync
 
+	mr	13,6
+	mr	14,7
+	bl	_C_LABEL(cpu_model_init)	/* init oeacpufeat */
+
 /* compute end of kernel memory */
 	lis	4,_C_LABEL(end)@ha
 	addi	4,4,_C_LABEL(end)@l



CVS commit: src/sys/arch/macppc/macppc

2021-02-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Feb 13 02:17:02 UTC 2021

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
Improve readability of this file by adding register prefixes.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/macppc/macppc/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.76 src/sys/arch/macppc/macppc/locore.S:1.77
--- src/sys/arch/macppc/macppc/locore.S:1.76	Sat Feb 13 01:11:58 2021
+++ src/sys/arch/macppc/macppc/locore.S	Sat Feb 13 02:17:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.76 2021/02/13 01:11:58 thorpej Exp $	*/
+/*	$NetBSD: locore.S,v 1.77 2021/02/13 02:17:02 thorpej Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -83,64 +83,64 @@ _C_LABEL(kernel_text):
 __start:
 	bl	_C_LABEL(ofwinit)		/* init OF */
 
-	li	0,0
+	li	%r0,0
 #ifndef FIRMWORKSBUGS
-	mtmsr	0			/* Disable FPU/MMU/exceptions */
+	mtmsr	%r0			/* Disable FPU/MMU/exceptions */
 #endif
 	isync
 
-	mr	13,6
-	mr	14,7
+	mr	%r13,%r6
+	mr	%r14,%r7
 	bl	_C_LABEL(cpu_model_init)	/* init oeacpufeat */
 
 /* compute end of kernel memory */
-	lis	4,_C_LABEL(end)@ha
-	addi	4,4,_C_LABEL(end)@l
+	lis	%r4,_C_LABEL(end)@ha
+	addi	%r4,%r4,_C_LABEL(end)@l
 #if NKSYMS || defined(DDB) || defined(MODULAR)
 	/* skip symbol table */
-	mr	6,13
-	mr	7,14
-	cmpwi	6,0
+	mr	%r6,%r13
+	mr	%r7,%r14
+	cmpwi	%r6,0
 	beq	1f
-	add	9,6,7			/* r9 = args + l */
-	lwz	9,-8(9)			/* esym */
-	cmpwi	9,0
+	add	%r9,%r6,%r7		/* r9 = args + l */
+	lwz	%r9,-8(%r9)		/* esym */
+	cmpwi	%r9,0
 	beq	1f
-	mr	4,9
+	mr	%r4,%r9
 1:
 #endif
 
 #if defined (PMAC_G5) || defined (MAMBO)
 	 /* and clear HID5 DCBZ bits (56/57), need to do this early */
-	mfspr	11,SPR_HID5
-	rldimi	11,0,6,56
+	mfspr	%r11,SPR_HID5
+	rldimi	%r11,%r0,6,56
 	sync
-	mtspr	SPR_HID5,11
+	mtspr	SPR_HID5,%r11
 	isync
 	sync
 
 	/* Setup HID1 features, prefetch + i-cacheability controlled by PTE */
-	mfspr	0,SPR_HID1
-	li	11,0x1200
-	sldi	11,11,44
-	or	0,0,11
-	mtspr	SPR_HID1,0
+	mfspr	%r0,SPR_HID1
+	li	%r11,0x1200
+	sldi	%r11,%r11,44
+	or	%r0,%r0,%r11
+	mtspr	SPR_HID1,%r0
 	isync
 	sync
 
 	/* Restore r0 */
-	li	0,0
+	li	%r0,0
 #endif /* PMAC_G5 */
 
 
 	/*
 	 * Initialize cpu_info[0]
 	 */
-	INIT_CPUINFO(4,1,9,0)
+	INIT_CPUINFO(%r4,%r1,%r9,%r0)
 
-	lis	3,__start@ha
-	addi	3,3,__start@l
-	mr	5,6			/* args string */
+	lis	%r3,__start@ha
+	addi	%r3,%r3,__start@l
+	mr	%r5,%r6			/* args string */
 	bl	_C_LABEL(initppc)
 	bl	_C_LABEL(main)
 	b	_C_LABEL(OF_exit)
@@ -150,17 +150,17 @@ __start:
 	.text
 	.globl _C_LABEL(mfhid4)
 _C_LABEL(mfhid4):
-	mfspr	4, SPR_HID4 
-	std	4, 0(3)
+	mfspr	%r4, SPR_HID4 
+	std	%r4, 0(%r3)
 	blr
 
 /* Set all 64 bits of HID4 */
 	.text
 	.globl _C_LABEL(mthid4)
 _C_LABEL(mthid4):
-	ld 4, 0(3)
+	ld %r4, 0(%r3)
 	sync
-	mtspr SPR_HID4, 4 
+	mtspr SPR_HID4, %r4 
 	isync 
 	isync
 	blr
@@ -168,11 +168,11 @@ _C_LABEL(mthid4):
 	.text
 	.globl _C_LABEL(change_hid4)
 _C_LABEL(change_hid4):
-	mfspr 6, SPR_HID4
-	rldicl 5, 6, 32, 0 
-	ori 5, 5, 0x100
-	rldicl 5, 5, 32, 0 
-	std 5, 0(3)
+	mfspr %r6, SPR_HID4
+	rldicl %r5, %r6, 32, 0 
+	ori %r5, %r5, 0x100
+	rldicl %r5, %r5, 32, 0 
+	std %r5, 0(%r3)
 	blr
 #endif
 



CVS commit: src/sys/arch/macppc/macppc

2021-03-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Mar  6 07:29:05 UTC 2021

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
Change pic_name from "openpic" to "u3_ht" so that it can be
distinguishable with generic OpenPIC driver.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/macppc/macppc/pic_u3_ht.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.11 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.12
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.11	Fri Mar  5 07:15:53 2021
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Sat Mar  6 07:29:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_u3_ht.c,v 1.11 2021/03/05 07:15:53 rin Exp $	*/
+/*	$NetBSD: pic_u3_ht.c,v 1.12 2021/03/06 07:29:05 rin Exp $	*/
 /*-
  * Copyright (c) 2013 Phileas Fogg
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.11 2021/03/05 07:15:53 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.12 2021/03/06 07:29:05 rin Exp $");
 
 #include "opt_openpic.h"
 #include "opt_interrupt.h"
@@ -229,7 +229,7 @@ setup_u3_ht(uint32_t addr, uint32_t len,
 	pic->pic_ack_irq = u3_ht_ack_irq;
 	pic->pic_establish_irq = u3_ht_establish_irq;
 	pic->pic_finish_setup = u3_ht_finish_setup;
-	strcpy(pic->pic_name, "openpic");
+	strcpy(pic->pic_name, "u3_ht");
 	pic_add(pic);
 
 	u3_ht_set_priority(u3_ht, 0, 15);



CVS commit: src/sys/arch/macppc/macppc

2021-03-10 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Mar 10 19:45:41 UTC 2021

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
switch G5 iMacs to full speed


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.173 src/sys/arch/macppc/macppc/machdep.c:1.174
--- src/sys/arch/macppc/macppc/machdep.c:1.173	Sat Feb 27 02:52:48 2021
+++ src/sys/arch/macppc/macppc/machdep.c	Wed Mar 10 19:45:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.173 2021/02/27 02:52:48 thorpej Exp $	*/
+/*	$NetBSD: machdep.c,v 1.174 2021/03/10 19:45:41 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.173 2021/02/27 02:52:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.174 2021/03/10 19:45:41 macallan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -145,6 +145,14 @@ initppc(u_int startkernel, u_int endkern
 		int clock_ih = OF_open("/u3/i2c/i2c-hwclock");
 		if (clock_ih != 0) {
 			OF_call_method_1("slew-high", clock_ih, 0);
+			OF_close(clock_ih);
+		}
+	}
+	if  (strncmp(model_name, "PowerMac8,", 10) == 0) {
+		int smu_ih = OF_open("/smu");
+		if (smu_ih != 0) {
+			OF_call_method_1("smu-powertune-hi", smu_ih, 0);
+			OF_close(smu_ih);
 		}
 	}
 
@@ -360,7 +368,7 @@ copy_disp_props(device_t dev, int node, 
 	}
 	if (!of_to_uint32_prop(dict, node, "address", "address")) {
 		uint32_t fbaddr = 0;
-			OF_interpret("frame-buffer-adr", 0, 1, &fbaddr);
+		OF_interpret("frame-buffer-adr", 0, 1, &fbaddr);
 		if (fbaddr != 0)
 			prop_dictionary_set_uint32(dict, "address", fbaddr);
 	}



CVS commit: src/sys/arch/macppc/macppc

2017-06-16 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun 16 18:48:22 UTC 2017

Modified Files:
src/sys/arch/macppc/macppc: pic_heathrow.c pic_ohare.c

Log Message:
- read IRQs from state, not level register in *_reenable_irq() so we get
  edge triggered ones too
- kmem_alloc() -> kmem_zalloc() for paranoia


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/macppc/macppc/pic_heathrow.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/macppc/macppc/pic_ohare.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_heathrow.c
diff -u src/sys/arch/macppc/macppc/pic_heathrow.c:1.10 src/sys/arch/macppc/macppc/pic_heathrow.c:1.11
--- src/sys/arch/macppc/macppc/pic_heathrow.c:1.10	Thu Jun  1 02:45:06 2017
+++ src/sys/arch/macppc/macppc/pic_heathrow.c	Fri Jun 16 18:48:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_heathrow.c,v 1.10 2017/06/01 02:45:06 chs Exp $ */
+/*	$NetBSD: pic_heathrow.c,v 1.11 2017/06/16 18:48:22 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.10 2017/06/01 02:45:06 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.11 2017/06/16 18:48:22 macallan Exp $");
 
 #include "opt_interrupt.h"
 
@@ -107,7 +107,7 @@ setup_heathrow(uint32_t addr)
 	struct heathrow_ops *heathrow;
 	struct pic_ops *pic;
 
-	heathrow = kmem_alloc(sizeof(struct heathrow_ops), KM_SLEEP);
+	heathrow = kmem_zalloc(sizeof(struct heathrow_ops), KM_SLEEP);
 	pic = &heathrow->pic;
 
 	pic->pic_numintrs = 64;
@@ -160,7 +160,7 @@ heathrow_reenable_irq(struct pic_ops *pi
 	if (irq & 0x20) {
 		heathrow->enable_mask_h |= mask;
 		out32rb(INT_ENABLE_REG_H, heathrow->enable_mask_h);
-		levels = in32rb(INT_LEVEL_REG_H);
+		levels = in32rb(INT_STATE_REG_H);
 		if (levels & mask) {
 			pic_mark_pending(pic->pic_intrbase + irq);
 			out32rb(INT_CLEAR_REG_H, mask);
@@ -168,7 +168,7 @@ heathrow_reenable_irq(struct pic_ops *pi
 	} else {
 		heathrow->enable_mask_l |= mask;
 		out32rb(INT_ENABLE_REG_L, heathrow->enable_mask_l);
-		levels = in32rb(INT_LEVEL_REG_L);
+		levels = in32rb(INT_STATE_REG_L);
 		if (levels & mask) {
 			pic_mark_pending(pic->pic_intrbase + irq);
 			out32rb(INT_CLEAR_REG_L, mask);

Index: src/sys/arch/macppc/macppc/pic_ohare.c
diff -u src/sys/arch/macppc/macppc/pic_ohare.c:1.14 src/sys/arch/macppc/macppc/pic_ohare.c:1.15
--- src/sys/arch/macppc/macppc/pic_ohare.c:1.14	Thu Jun  1 02:45:06 2017
+++ src/sys/arch/macppc/macppc/pic_ohare.c	Fri Jun 16 18:48:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_ohare.c,v 1.14 2017/06/01 02:45:06 chs Exp $ */
+/*	$NetBSD: pic_ohare.c,v 1.15 2017/06/16 18:48:22 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.14 2017/06/01 02:45:06 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.15 2017/06/16 18:48:22 macallan Exp $");
 
 #include "opt_interrupt.h"
 
@@ -116,7 +116,7 @@ setup_ohare(uint32_t addr, int is_gc)
 	struct pic_ops *pic;
 	int i;
 
-	ohare = kmem_alloc(sizeof(struct ohare_ops), KM_SLEEP);
+	ohare = kmem_zalloc(sizeof(struct ohare_ops), KM_SLEEP);
 	pic = &ohare->pic;
 
 	pic->pic_numintrs = OHARE_NIRQ;
@@ -179,7 +179,7 @@ ohare_reenable_irq(struct pic_ops *pic, 
 
 	ohare->enable_mask |= mask;
 	out32rb(INT_ENABLE_REG, ohare->enable_mask);
-	levels = in32rb(INT_LEVEL_REG);
+	levels = in32rb(INT_STATE_REG);
 	if (levels & mask) {
 		pic_mark_pending(pic->pic_intrbase + irq);
 		out32rb(INT_CLEAR_REG, mask);



CVS commit: src/sys/arch/macppc/macppc

2017-07-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jul 14 21:36:19 UTC 2017

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
- use smu for shutdown and reboot
- disable pallet control on G5, for some reason we crash in OF_call_method_1


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.164 src/sys/arch/macppc/macppc/machdep.c:1.165
--- src/sys/arch/macppc/macppc/machdep.c:1.164	Tue Dec 11 03:00:00 2012
+++ src/sys/arch/macppc/macppc/machdep.c	Fri Jul 14 21:36:19 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.164 2012/12/11 03:00:00 macallan Exp $	*/
+/*	$NetBSD: machdep.c,v 1.165 2017/07/14 21:36:19 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.164 2012/12/11 03:00:00 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.165 2017/07/14 21:36:19 macallan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -97,12 +97,14 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
 #include "ksyms.h"
 #include "pmu.h"
 #include "cuda.h"
+#include "smu.h"
 
 struct genfb_colormap_callback gfb_cb;
 struct genfb_parameter_callback gpc_backlight, gpc_brightness;
@@ -211,6 +213,9 @@ cpu_reboot(int howto, char *what)
 		adb_poweroff();
 		printf("WARNING: powerdown failed!\n");
 #endif
+#if NSMU > 0
+		smu_poweroff();
+#endif
 	}
 
 	if (howto & RB_HALT) {
@@ -253,6 +258,9 @@ cpu_reboot(int howto, char *what)
 #if NADB > 0
 	adb_restart();	/* not return */
 #endif
+#if NSMU > 0
+	smu_restart();
+#endif
 	ppc_exit();
 }
 
@@ -274,8 +282,11 @@ copy_disp_props(device_t dev, int node, 
 	uint32_t temp;
 	uint64_t cmap_cb, backlight_cb, brightness_cb;
 	int have_backlight = 0;
+#ifdef PMAC_G5
+	int have_palette = 0;
+#else
 	int have_palette = 1;
-
+#endif
 	if (node != console_node) {
 		/*
 		 * see if any child matches since OF attaches nodes for
@@ -350,7 +361,7 @@ copy_disp_props(device_t dev, int node, 
 		prop_dictionary_set_uint64(dict, "cmap_callback", cmap_cb);
 	}
 
-	/* not let's look for backlight control */
+	/* now let's look for backlight control */
 	have_backlight = 0;
 	if (OF_getprop(node, "backlight-control", &temp, sizeof(temp)) == 4) {
 		have_backlight = 1;



CVS commit: src/sys/arch/macppc/macppc

2018-03-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Mar 22 15:23:43 UTC 2018

Modified Files:
src/sys/arch/macppc/macppc: cpu.c

Log Message:
mapiodev() the CPU reset GPIOs instead of blindly assuming that everything
is BAT-mapped
Now the 2nd CPU on my PowerMac7,3 wakes up and says hi.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/macppc/macppc/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.60 src/sys/arch/macppc/macppc/cpu.c:1.61
--- src/sys/arch/macppc/macppc/cpu.c:1.60	Wed Mar 26 17:45:16 2014
+++ src/sys/arch/macppc/macppc/cpu.c	Thu Mar 22 15:23:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.60 2014/03/26 17:45:16 christos Exp $	*/
+/*	$NetBSD: cpu.c,v 1.61 2018/03/22 15:23:43 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.60 2014/03/26 17:45:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.61 2018/03/22 15:23:43 macallan Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -209,7 +209,7 @@ md_setup_trampoline(volatile struct cpu_
 {
 #ifdef OPENPIC
 	if (openpic_base) {
-		uint32_t kl_base = 0x8000;	/* XXX */
+		uint32_t kl_base = (uint32_t)mapiodev(0x8000, 0x1000, 0);
 		uint32_t gpio = kl_base + 0x5c;	/* XXX */
 		u_int node, off;
 		char cpupath[32];



CVS commit: src/sys/arch/macppc/macppc

2018-03-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Mar 22 21:28:59 UTC 2018

Modified Files:
src/sys/arch/macppc/macppc: cpu.c interrupts.c

Log Message:
sprinkle oea_mapiodev()


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/macppc/macppc/cpu.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/macppc/macppc/interrupts.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.61 src/sys/arch/macppc/macppc/cpu.c:1.62
--- src/sys/arch/macppc/macppc/cpu.c:1.61	Thu Mar 22 15:23:43 2018
+++ src/sys/arch/macppc/macppc/cpu.c	Thu Mar 22 21:28:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.61 2018/03/22 15:23:43 macallan Exp $	*/
+/*	$NetBSD: cpu.c,v 1.62 2018/03/22 21:28:58 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.61 2018/03/22 15:23:43 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.62 2018/03/22 21:28:58 macallan Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -209,7 +209,7 @@ md_setup_trampoline(volatile struct cpu_
 {
 #ifdef OPENPIC
 	if (openpic_base) {
-		uint32_t kl_base = (uint32_t)mapiodev(0x8000, 0x1000, 0);
+		uint32_t kl_base = oea_mapiodev(0x8000, 0x1000);
 		uint32_t gpio = kl_base + 0x5c;	/* XXX */
 		u_int node, off;
 		char cpupath[32];

Index: src/sys/arch/macppc/macppc/interrupts.c
diff -u src/sys/arch/macppc/macppc/interrupts.c:1.5 src/sys/arch/macppc/macppc/interrupts.c:1.6
--- src/sys/arch/macppc/macppc/interrupts.c:1.5	Thu Apr 18 16:42:46 2013
+++ src/sys/arch/macppc/macppc/interrupts.c	Thu Mar 22 21:28:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: interrupts.c,v 1.5 2013/04/18 16:42:46 macallan Exp $ */
+/*	$NetBSD: interrupts.c,v 1.6 2018/03/22 21:28:58 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.5 2013/04/18 16:42:46 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.6 2018/03/22 21:28:58 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: interrupts.c
 #include 
 #include 
 #include 
+#include 
 
 #include "opt_interrupt.h"
 #include "pic_openpic.h"
@@ -100,7 +101,7 @@ init_openpic(int pass_through)
 	aprint_debug("pic-base: %08x\n", pic_base);
 
 	aprint_normal("found openpic PIC at %08x\n", pic_base);
-	setup_openpic((void *)pic_base, pass_through);
+	setup_openpic(oea_mapiodev(pic_base, 0x4), pass_through);
 
 	return TRUE;
 }



CVS commit: src/sys/arch/macppc/macppc

2017-10-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Oct 18 12:55:14 UTC 2017

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
do what freebsd does:
- when disabling an interrupt, disable it on the HT PIC as well
- when establishing an interrupt, don't enable it right away
- program IRQs 0-3 as level, like freebsd does
Now svwsata is almost usable. We still get an interrupt storm but it doesn't
eat up all CPU cycles anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/macppc/pic_u3_ht.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.2 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.3
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.2	Thu Jun  1 02:45:06 2017
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Wed Oct 18 12:55:14 2017
@@ -43,6 +43,12 @@
 #include 
 #include 
 
+#ifdef U3_HT_PIC_DEPUG
+#define DPRINTF aprint_error
+#else
+#define DPRINTF if (0) printf
+#endif
+
 struct u3_ht_irqmap {
 	int im_index;
 	int im_level;
@@ -78,6 +84,7 @@ static void u3_ht_finish_setup(struct pi
 static int u3_ht_is_ht_irq(struct u3_ht_ops *, int);
 static void u3_ht_establish_ht_irq(struct u3_ht_ops *, int, int);
 static void u3_ht_enable_ht_irq(struct u3_ht_ops *, int);
+static void u3_ht_disable_ht_irq(struct u3_ht_ops *, int);
 static void u3_ht_ack_ht_irq(struct u3_ht_ops *, int);
 
 static void u3_ht_set_priority(struct u3_ht_ops *, int, int);
@@ -206,7 +213,7 @@ setup_u3_ht(uint32_t addr, uint32_t len,
 
 	u3_ht_set_priority(u3_ht, 0, 15);
 
-	for (irq = 0; irq < pic->pic_numintrs; irq++) {
+	for (irq = 0; irq < 4; irq++) {
 		x = irq;
 		x |= OPENPIC_IMASK;
 		x |= OPENPIC_POLARITY_NEGATIVE;
@@ -215,6 +222,15 @@ setup_u3_ht(uint32_t addr, uint32_t len,
 		u3_ht_write(u3_ht, OPENPIC_SRC_VECTOR(irq), x);
 		u3_ht_write(u3_ht, OPENPIC_IDEST(irq), 1 << 0);
 	}
+	for (irq = 4; irq < pic->pic_numintrs; irq++) {
+		x = irq;
+		x |= OPENPIC_IMASK;
+		x |= OPENPIC_POLARITY_NEGATIVE;
+		x |= OPENPIC_SENSE_EDGE;
+		x |= 8 << OPENPIC_PRIORITY_SHIFT;
+		u3_ht_write(u3_ht, OPENPIC_SRC_VECTOR(irq), x);
+		u3_ht_write(u3_ht, OPENPIC_IDEST(irq), 1 << 0);
+	}
 
 	x = u3_ht_read(u3_ht, OPENPIC_CONFIG);
 	x |= OPENPIC_CONFIG_8259_PASSTHRU_DISABLE;
@@ -253,6 +269,8 @@ setup_u3_ht_workarounds(struct u3_ht_ops
 	ht_reg = mapiodev(reg[1], reg[2], false);
 	KASSERT(ht_reg != NULL);
 
+	memset(irqmap, 0, sizeof(u3_ht->ht_irqmap));
+
 	for (child = OF_child(parent); child != 0; child = OF_peer(child)) {
 		if (OF_getprop(child, "reg", reg, 4) != 4) 
 			continue;
@@ -284,6 +302,8 @@ setup_u3_ht_workarounds(struct u3_ht_ops
 		nirq = in32rb(base + 0x04);
 		nirq = (nirq >> 16) & 0xff;
 
+		DPRINTF("dev %08x nirq %d pos %08x\n", (uint32_t)base, nirq, (uint32_t)pos);
+		DPRINTF("devreg %08x\n", in32rb(dev_reg + PCI_ID_REG));
 		for (i = 0; i <= nirq; i++) {
 			out8rb(base + 0x02, 0x10 + (i << 1));
 			tmp = in32rb(base + 0x04);
@@ -333,6 +353,9 @@ u3_ht_disable_irq(struct pic_ops *pic, i
  	x = u3_ht_read(u3_ht, OPENPIC_SRC_VECTOR(irq));
  	x |= OPENPIC_IMASK;
  	u3_ht_write(u3_ht, OPENPIC_SRC_VECTOR(irq), x);
+
+	if (u3_ht_is_ht_irq(u3_ht, irq))
+		u3_ht_disable_ht_irq(u3_ht, irq);
 }
 
 static int
@@ -385,8 +408,8 @@ u3_ht_establish_irq(struct pic_ops *pic,
 	if (u3_ht_is_ht_irq(u3_ht, irq))
 		u3_ht_establish_ht_irq(u3_ht, irq, type);
 
-	aprint_debug("%s: setting IRQ %d to priority %d\n", __func__, irq,
-	realpri);
+	aprint_error("%s: setting IRQ %d %d to priority %d %x\n", __func__, irq,
+	type, realpri, x);
 }
 
 static void
@@ -422,10 +445,15 @@ u3_ht_establish_ht_irq(struct u3_ht_ops 
 	out8rb(irqmap->im_base + 0x02, 0x10 + (irqmap->im_index << 1));
 
 	x = in32rb(irqmap->im_base + 0x04);
-	x &= ~0x23;
+	/* mask interrupt */
+	out32rb(irqmap->im_base + 0x04, x | 1);
+
+	/* mask out EOI and LEVEL bits */
+	x &= ~0x22;
 
 	if (type == IST_LEVEL_HIGH || type == IST_LEVEL_LOW) {
 		irqmap->im_level = 1;
+		DPRINTF("level\n");
 		x |= 0x22;
 	} else {
 		irqmap->im_level = 0;
@@ -449,6 +477,18 @@ u3_ht_enable_ht_irq(struct u3_ht_ops *u3
 }
 
 static void
+u3_ht_disable_ht_irq(struct u3_ht_ops *u3_ht, int irq)
+{
+	struct u3_ht_irqmap *irqmap = &u3_ht->ht_irqmap[irq];
+	u_int x;
+
+	out8rb(irqmap->im_base + 0x02, 0x10 + (irqmap->im_index << 1));
+	x = in32rb(irqmap->im_base + 0x04);
+	x |= 0x01;
+	out32rb(irqmap->im_base + 0x04, x);
+}
+
+static void
 u3_ht_ack_ht_irq(struct u3_ht_ops *u3_ht, int irq)
 {
 	struct u3_ht_irqmap *irqmap = &u3_ht->ht_irqmap[irq];



CVS commit: src/sys/arch/macppc/macppc

2019-12-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Dec 13 23:01:41 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: cpu.c

Log Message:
call cpu_topology_set() with adjustments for 970MP CPUs


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/macppc/macppc/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.67 src/sys/arch/macppc/macppc/cpu.c:1.68
--- src/sys/arch/macppc/macppc/cpu.c:1.67	Thu May 17 19:08:51 2018
+++ src/sys/arch/macppc/macppc/cpu.c	Fri Dec 13 23:01:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.67 2018/05/17 19:08:51 macallan Exp $	*/
+/*	$NetBSD: cpu.c,v 1.68 2019/12/13 23:01:41 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.67 2018/05/17 19:08:51 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.68 2019/12/13 23:01:41 macallan Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.67
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -159,12 +160,23 @@ cpuattach(device_t parent, device_t self
 {
 	struct cpu_info *ci;
 	struct confargs *ca = aux;
-	int id = ca->ca_reg[0];
+	int id = ca->ca_reg[0], vers, package, core;
 
 	ci = cpu_attach_common(self, id);
 	if (ci == NULL)
 		return;
 
+	package = id;
+	core = 0;
+
+	vers = (mfpvr() >> 16) & 0x;
+	
+	if (vers == IBM970MP) {
+		core = package & 1;
+		package >>= 1;
+	}
+	cpu_topology_set(ci, package, core, 0);
+
 	if (ci->ci_khz == 0) {
 		cpu_OFgetspeed(self, ci);
 	}



CVS commit: src/sys/arch/macppc/macppc

2020-02-09 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb  9 09:30:37 UTC 2020

Modified Files:
src/sys/arch/macppc/macppc: cpu.c

Log Message:
Traiing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/macppc/macppc/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.70 src/sys/arch/macppc/macppc/cpu.c:1.71
--- src/sys/arch/macppc/macppc/cpu.c:1.70	Thu Jan  9 16:35:03 2020
+++ src/sys/arch/macppc/macppc/cpu.c	Sun Feb  9 09:30:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.70 2020/01/09 16:35:03 ad Exp $	*/
+/*	$NetBSD: cpu.c,v 1.71 2020/02/09 09:30:37 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.70 2020/01/09 16:35:03 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.71 2020/02/09 09:30:37 skrll Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -170,7 +170,7 @@ cpuattach(device_t parent, device_t self
 	core = 0;
 
 	vers = (mfpvr() >> 16) & 0x;
-	
+
 	if (vers == IBM970MP) {
 		core = package & 1;
 		package >>= 1;
@@ -348,7 +348,7 @@ md_setup_interrupts(void)
 	if (openpic_base) {
 		openpic_set_priority(cpu_number(), 0);
 	} else if (have_u3_ht()) {
-		__u3_ht_set_priority(cpu_number(), 0);		
+		__u3_ht_set_priority(cpu_number(), 0);
 	} else
 #endif /* OPENPIC */
 		out32(HH_INTR_SECONDARY, ~0);	/* Reset interrupt. */



CVS commit: src/sys/arch/macppc/macppc

2020-07-12 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Jul 12 23:58:30 UTC 2020

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
Fix typo; U3_HT_PIC_DE*P*UG ---> U3_HT_PIC_DEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/macppc/macppc/pic_u3_ht.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.7 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.8
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.7	Mon Sep  3 16:29:25 2018
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Sun Jul 12 23:58:30 2020
@@ -45,7 +45,7 @@
 #include 
 #include 
 
-#ifdef U3_HT_PIC_DEPUG
+#ifdef U3_HT_PIC_DEBUG
 #define DPRINTF aprint_error
 #else
 #define DPRINTF if (0) printf



CVS commit: src/sys/arch/macppc/macppc

2020-07-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul 14 08:55:07 UTC 2020

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
Adapt to new proplib API


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.170 src/sys/arch/macppc/macppc/machdep.c:1.171
--- src/sys/arch/macppc/macppc/machdep.c:1.170	Tue Jul  7 02:33:54 2020
+++ src/sys/arch/macppc/macppc/machdep.c	Tue Jul 14 08:55:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.170 2020/07/07 02:33:54 rin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.171 2020/07/14 08:55:07 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.170 2020/07/07 02:33:54 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.171 2020/07/14 08:55:07 martin Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -417,14 +417,14 @@ add_model_specifics(prop_dictionary_t di
 	if (of_compatible(node, clamshell) != -1) {
 		prop_data_t edid;
 
-		edid = prop_data_create_data(edid_clamshell, sizeof(edid_clamshell));
+		edid = prop_data_create_nocopy(edid_clamshell, sizeof(edid_clamshell));
 		prop_dictionary_set(dict, "EDID", edid);
 		prop_object_release(edid);
 	}
 	if (of_compatible(node, pismo) != -1) {
 		prop_data_t edid;
 
-		edid = prop_data_create_data(edid_pismo, sizeof(edid_pismo));
+		edid = prop_data_create_nocopy(edid_pismo, sizeof(edid_pismo));
 		prop_dictionary_set(dict, "EDID", edid);
 		prop_object_release(edid);
 	}



CVS commit: src/sys/arch/macppc/macppc

2020-07-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jul 15 09:58:34 UTC 2020

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
Add NetBSD RCSID. No functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/macppc/pic_u3_ht.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.8 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.9
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.8	Sun Jul 12 23:58:30 2020
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Wed Jul 15 09:58:34 2020
@@ -1,3 +1,4 @@
+/*	$NetBSD: pic_u3_ht.c,v 1.9 2020/07/15 09:58:34 rin Exp $	*/
 /*-
  * Copyright (c) 2013 Phileas Fogg
  * All rights reserved.
@@ -25,6 +26,7 @@
  */
 
 #include 
+__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.9 2020/07/15 09:58:34 rin Exp $");
 
 #include "opt_openpic.h"
 #include "opt_interrupt.h"



CVS commit: src/sys/arch/macppc/macppc

2018-05-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri May 11 22:48:38 UTC 2018

Modified Files:
src/sys/arch/macppc/macppc: cpu.c interrupts.c pic_u3_ht.c

Log Message:
deal with IPIs on U3/HT machines, only install OpenPIC IPI goop on actual
OpenPIC hardware


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/macppc/macppc/cpu.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/macppc/macppc/interrupts.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/macppc/macppc/pic_u3_ht.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.63 src/sys/arch/macppc/macppc/cpu.c:1.64
--- src/sys/arch/macppc/macppc/cpu.c:1.63	Thu Mar 29 16:19:46 2018
+++ src/sys/arch/macppc/macppc/cpu.c	Fri May 11 22:48:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.63 2018/03/29 16:19:46 macallan Exp $	*/
+/*	$NetBSD: cpu.c,v 1.64 2018/05/11 22:48:38 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.63 2018/03/29 16:19:46 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.64 2018/05/11 22:48:38 macallan Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -204,11 +204,14 @@ ohare_init(void)
 
 #ifdef MULTIPROCESSOR
 
+extern int have_u3_ht(void);
+extern void __u3_ht_set_priority(int, int);
+
 int
 md_setup_trampoline(volatile struct cpu_hatch_data *h, struct cpu_info *ci)
 {
 #ifdef OPENPIC
-	if (openpic_base) {
+	if ((openpic_base != NULL) || have_u3_ht()) {
 		uint32_t kl_base = (uint32_t)oea_mapiodev(0x8000, 0x1000);
 		uint32_t gpio = kl_base + 0x5c;	/* XXX */
 		u_int node, off;
@@ -253,7 +256,7 @@ void
 md_presync_timebase(volatile struct cpu_hatch_data *h)
 {
 #ifdef OPENPIC
-	if (openpic_base) {
+	if ((openpic_base != NULL) || have_u3_ht()) {
 		uint64_t tb;
 
 		/* Sync timebase. */
@@ -283,7 +286,7 @@ md_start_timebase(volatile struct cpu_ha
 {
 	int i;
 #ifdef OPENPIC
-	if (!openpic_base) {
+	if (!((openpic_base != NULL) || have_u3_ht())) {
 #endif
 		/*
 		 * wait for secondary spin up (1.5ms @ 604/200MHz)
@@ -306,7 +309,7 @@ void
 md_sync_timebase(volatile struct cpu_hatch_data *h)
 {
 #ifdef OPENPIC
-	if (openpic_base) {
+	if ((openpic_base != NULL) || have_u3_ht()) {
 		/* Sync timebase. */
 		u_int tbu = h->hatch_tbu;
 		u_int tbl = h->hatch_tbl;
@@ -324,9 +327,11 @@ void
 md_setup_interrupts(void)
 {
 #ifdef OPENPIC
-	if (openpic_base)
+	if (openpic_base) {
 		openpic_set_priority(cpu_number(), 0);
-	else
+	} else if (have_u3_ht()) {
+		__u3_ht_set_priority(cpu_number(), 0);		
+	} else
 #endif /* OPENPIC */
 		out32(HH_INTR_SECONDARY, ~0);	/* Reset interrupt. */
 }

Index: src/sys/arch/macppc/macppc/interrupts.c
diff -u src/sys/arch/macppc/macppc/interrupts.c:1.6 src/sys/arch/macppc/macppc/interrupts.c:1.7
--- src/sys/arch/macppc/macppc/interrupts.c:1.6	Thu Mar 22 21:28:58 2018
+++ src/sys/arch/macppc/macppc/interrupts.c	Fri May 11 22:48:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: interrupts.c,v 1.6 2018/03/22 21:28:58 macallan Exp $ */
+/*	$NetBSD: interrupts.c,v 1.7 2018/05/11 22:48:38 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.6 2018/03/22 21:28:58 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.7 2018/05/11 22:48:38 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -126,19 +126,21 @@ init_interrupt(void)
 		goto done;
 #endif
 #if NPIC_OPENPIC > 0
-	if (init_openpic(0))
+	if (init_openpic(0)) {
+#ifdef MULTIPROCESSOR
+		setup_openpic_ipi();
+#endif
 		goto done;
+	}
 #endif
 	panic("%s: no supported interrupt controller found", __func__);
 done:
 	oea_install_extint(pic_ext_intr);
 
 #ifdef MULTIPROCESSOR
-#if NPIC_OPENPIC > 0
-	setup_openpic_ipi();
-#else /*NPIC_OPENPIC*/
+#if (NPIC_OHARE + NPIC_HEATHROW) > 0
 	if (OF_finddevice("/hammerhead") != -1)
 		setup_hammerhead_ipi();
-#endif /*NPIC_OPENPIC*/
+#endif
 #endif /*MULTIPROCESSOR*/
 }

Index: src/sys/arch/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.4 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.5
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.4	Wed Jan 31 21:09:53 2018
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Fri May 11 22:48:38 2018
@@ -32,6 +32,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -92,6 +94,7 @@ static void u3_ht_disable_ht_irq(struct 
 static void u3_ht_ack_ht_irq(struct u3_ht_ops *, int);
 
 static void u3_ht_set_priority(struct u3_ht_ops *, int, int);
+void __u3_ht_set_priority(int, int);
 static int u3_ht_read_irq(struct u3_ht_ops *, int);
 static void u3_ht_eoi(struct u3_ht_ops *, int);
 
@@ -112,6 +115,17 @@ const char *pic_compat[] = {
 	NULL
 };
 
+static struct u3_ht_ops *u3ht0 = NULL;
+int have_u3_ht(void);
+
+#ifdef MULTIPROCESSOR
+
+extern struct ipi_ops ip

CVS commit: src/sys/arch/macppc/macppc

2018-05-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 13 14:55:35 UTC 2018

Modified Files:
src/sys/arch/macppc/macppc: cpu.c

Log Message:
make this compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/macppc/macppc/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.64 src/sys/arch/macppc/macppc/cpu.c:1.65
--- src/sys/arch/macppc/macppc/cpu.c:1.64	Fri May 11 18:48:38 2018
+++ src/sys/arch/macppc/macppc/cpu.c	Sun May 13 10:55:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.64 2018/05/11 22:48:38 macallan Exp $	*/
+/*	$NetBSD: cpu.c,v 1.65 2018/05/13 14:55:35 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.64 2018/05/11 22:48:38 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.65 2018/05/13 14:55:35 christos Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -204,8 +204,13 @@ ohare_init(void)
 
 #ifdef MULTIPROCESSOR
 
+#if NPIC_U3_HT > 0
 extern int have_u3_ht(void);
 extern void __u3_ht_set_priority(int, int);
+#else
+#define have_u3_ht() 0
+#define __u3_ht_set_priority(a, b)
+#define 
 
 int
 md_setup_trampoline(volatile struct cpu_hatch_data *h, struct cpu_info *ci)



CVS commit: src/sys/arch/macppc/macppc

2018-05-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun May 13 16:03:25 UTC 2018

Modified Files:
src/sys/arch/macppc/macppc: cpu.c

Log Message:
fix the fix


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/macppc/macppc/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.65 src/sys/arch/macppc/macppc/cpu.c:1.66
--- src/sys/arch/macppc/macppc/cpu.c:1.65	Sun May 13 14:55:35 2018
+++ src/sys/arch/macppc/macppc/cpu.c	Sun May 13 16:03:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.65 2018/05/13 14:55:35 christos Exp $	*/
+/*	$NetBSD: cpu.c,v 1.66 2018/05/13 16:03:25 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.65 2018/05/13 14:55:35 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.66 2018/05/13 16:03:25 macallan Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -210,7 +210,7 @@ extern void __u3_ht_set_priority(int, in
 #else
 #define have_u3_ht() 0
 #define __u3_ht_set_priority(a, b)
-#define 
+#endif
 
 int
 md_setup_trampoline(volatile struct cpu_hatch_data *h, struct cpu_info *ci)



CVS commit: src/sys/arch/macppc/macppc

2018-05-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu May 17 19:08:51 UTC 2018

Modified Files:
src/sys/arch/macppc/macppc: cpu.c

Log Message:
really fix the fix


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/macppc/macppc/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.66 src/sys/arch/macppc/macppc/cpu.c:1.67
--- src/sys/arch/macppc/macppc/cpu.c:1.66	Sun May 13 16:03:25 2018
+++ src/sys/arch/macppc/macppc/cpu.c	Thu May 17 19:08:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.66 2018/05/13 16:03:25 macallan Exp $	*/
+/*	$NetBSD: cpu.c,v 1.67 2018/05/17 19:08:51 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.66 2018/05/13 16:03:25 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.67 2018/05/17 19:08:51 macallan Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -68,6 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.66
 #include 
 
 #include "pic_openpic.h"
+#include "pic_u3_ht.h"
 
 #ifndef OPENPIC
 #if NPIC_OPENPIC > 0



CVS commit: src/sys/arch/macppc/macppc

2018-06-07 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jun  7 17:02:12 UTC 2018

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
reduce debug spam, use IPI_VECTOR


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/macppc/macppc/pic_u3_ht.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.5 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.6
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.5	Fri May 11 22:48:38 2018
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Thu Jun  7 17:02:12 2018
@@ -218,7 +218,7 @@ setup_u3_ht(uint32_t addr, uint32_t len,
 	x & 0xff, ((x & 0x1f00) >> 8) + 1, ((x & 0x07ff) >> 16) + 1);
 
 	/* up to 128 interrupt sources, plus IPI */
-	pic->pic_numintrs = 129;
+	pic->pic_numintrs = IPI_VECTOR + 1;
 	pic->pic_cookie = (void *) addr;
 	pic->pic_enable_irq = u3_ht_enable_irq;
 	pic->pic_reenable_irq = u3_ht_enable_irq;
@@ -437,7 +437,7 @@ u3_ht_establish_irq(struct pic_ops *pic,
 	if (u3_ht_is_ht_irq(u3_ht, irq))
 		u3_ht_establish_ht_irq(u3_ht, irq, type);
 
-	aprint_error("%s: setting IRQ %d %d to priority %d %x\n", __func__, irq,
+	DPRINTF("%s: setting IRQ %d %d to priority %d %x\n", __func__, irq,
 	type, realpri, x);
 }
 



CVS commit: src/sys/arch/macppc/macppc

2019-01-27 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Jan 28 02:25:02 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: machdep.c static_edid.c static_edid.h

Log Message:
Fake the EDID info for the clamshell iBook G3 so X11 works out of the box.
Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen
also.

[93.906] (II) R128(0): I2C bus "VGA-0" initialized.
[93.907] (II) got 128 bytes worth of EDID from wsdisplay
[93.908] (II) R128(0): EDID for output LVDS
[93.908] (II) R128(0): Manufacturer: APP  Model: 9c05  Serial#: 16843009
[93.908] (II) R128(0): Year: 1999  Week: 9
[93.908] (II) R128(0): EDID Version: 1.1
[93.908] (II) R128(0): Digital Display Input
[93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24  vert.: 18
[93.908] (II) R128(0): Gamma: 2.28
[93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off
[93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4
[93.909] (II) R128(0): redX: 0.594 redY: 0.345   greenX: 0.317 greenY: 0.494
[93.909] (II) R128(0): blueX: 0.155 blueY: 0.146   whiteX: 0.312 whiteY: 
0.328
[93.909] (II) R128(0): Supported established timings:
[93.909] (II) R128(0): 800x600@60Hz
[93.909] (II) R128(0): Manufacturer's mask: 0
[93.910] (II) R128(0): Supported detailed timing:
[93.910] (II) R128(0): clock: 60.0 MHz   Image Size:  275 x 199 mm
[93.910] (II) R128(0): h_active: 800  h_sync: 840  h_sync_end 968 
h_blank_end 1056 h_border: 0
[93.910] (II) R128(0): v_active: 600  v_sync: 601  v_sync_end 605 
v_blanking: 628 v_border: 0
[93.910] (II) R128(0):  LT121SU-121
[93.910] (II) R128(0):  LT121SU-121
[93.910] (II) R128(0): Monitor name: Color LCD
[93.910] (II) R128(0): EDID (in hex):
[93.910] (II) R128(0):  00000610059c01010101
[93.910] (II) R128(0):  09090101a8181280e816e09858517e27
[93.910] (II) R128(0):  2550540101010101010101010101
[93.911] (II) R128(0):  0101010101017017200031581c202880
[93.911] (II) R128(0):  140013c7101800fe004c5431
[93.911] (II) R128(0):  323153552d3132310a2000fe004c
[93.911] (II) R128(0):  5431323153552d3132310a2000fc
[93.911] (II) R128(0):  00436f6c6f72204c43440a2020200037
[93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/sys/arch/macppc/macppc/machdep.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/macppc/static_edid.c \
src/sys/arch/macppc/macppc/static_edid.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.168 src/sys/arch/macppc/macppc/machdep.c:1.169
--- src/sys/arch/macppc/macppc/machdep.c:1.168	Sun Jul 15 05:16:43 2018
+++ src/sys/arch/macppc/macppc/machdep.c	Mon Jan 28 02:25:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.168 2018/07/15 05:16:43 maxv Exp $	*/
+/*	$NetBSD: machdep.c,v 1.169 2019/01/28 02:25:01 sevan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.168 2018/07/15 05:16:43 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.169 2019/01/28 02:25:01 sevan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -389,6 +389,8 @@ add_model_specifics(prop_dictionary_t di
 {
 	const char *bl_rev_models[] = {
 		"PowerBook4,3", "PowerBook6,3", "PowerBook6,5", NULL};
+	const char *clamshell[] = {
+		"PowerBook2,1", "PowerBook2,2", NULL};
 	const char *pismo[] = {
 		"PowerBook3,1", NULL};
 	const char *mini1[] = {
@@ -402,6 +404,13 @@ add_model_specifics(prop_dictionary_t di
 	if (of_compatible(node, bl_rev_models) != -1) {
 		prop_dictionary_set_bool(dict, "backlight_level_reverted", 1);
 	}
+	if (of_compatible(node, clamshell) != -1) {
+		prop_data_t edid;
+
+		edid = prop_data_create_data(edid_clamshell, sizeof(edid_clamshell));
+		prop_dictionary_set(dict, "EDID", edid);
+		prop_object_release(edid);
+	}
 	if (of_compatible(node, pismo) != -1) {
 		prop_data_t edid;
 

Index: src/sys/arch/macppc/macppc/static_edid.c
diff -u src/sys/arch/macppc/macppc/static_edid.c:1.1 src/sys/arch/macppc/macppc/static_edid.c:1.2
--- src/sys/arch/macppc/macppc/static_edid.c:1.1	Wed Jul 13 22:54:33 2011
+++ src/sys/arch/macppc/macppc/static_edid.c	Mon Jan 28 02:25:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: static_edid.c,v 1.1 2011/07/13 22:54:33 macallan Exp $ */
+/*	$NetBSD: static_edid.c,v 1.2 2019/01/28 02:25:01 sevan Exp $ */
 
 /*-
  * Copyright (c) 2011 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: static_edid.c,v 1.1 2011/07/13 22:54:33 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: static_edid.c,v 1.2 2019/01/28 02:25:01 sevan Exp $");
 #include 
 
 /* EDID blocks for some known hardware tha

CVS commit: src/sys/arch/macppc/macppc

2019-01-27 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Jan 28 02:45:13 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: static_edid.c

Log Message:
Add a description


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/macppc/static_edid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/static_edid.c
diff -u src/sys/arch/macppc/macppc/static_edid.c:1.2 src/sys/arch/macppc/macppc/static_edid.c:1.3
--- src/sys/arch/macppc/macppc/static_edid.c:1.2	Mon Jan 28 02:25:01 2019
+++ src/sys/arch/macppc/macppc/static_edid.c	Mon Jan 28 02:45:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: static_edid.c,v 1.2 2019/01/28 02:25:01 sevan Exp $ */
+/*	$NetBSD: static_edid.c,v 1.3 2019/01/28 02:45:13 sevan Exp $ */
 
 /*-
  * Copyright (c) 2011 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: static_edid.c,v 1.2 2019/01/28 02:25:01 sevan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: static_edid.c,v 1.3 2019/01/28 02:45:13 sevan Exp $");
 #include 
 
 /* EDID blocks for some known hardware that doesn't provide its own */
@@ -55,6 +55,10 @@ uint8_t edid_pismo[128] = {
 /* 78 */	0x43, 0x44, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x52
 };
 
+/*
+ * iBook G3 Clamshell, obtained from the 2nd revision (firewire).
+ * Should work on the 1st revision.
+ */
 uint8_t edid_clamshell[128] = {
 /* 00 */	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
 /* 08 */	0x06, 0x10, 0x05, 0x9c, 0x01, 0x01, 0x01, 0x01,



CVS commit: src/sys/arch/macppc/macppc

2017-08-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Aug 11 22:55:49 UTC 2017

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
set properties to signal Mac Mini video output wiring to radeonfb


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.165 src/sys/arch/macppc/macppc/machdep.c:1.166
--- src/sys/arch/macppc/macppc/machdep.c:1.165	Fri Jul 14 21:36:19 2017
+++ src/sys/arch/macppc/macppc/machdep.c	Fri Aug 11 22:55:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.165 2017/07/14 21:36:19 macallan Exp $	*/
+/*	$NetBSD: machdep.c,v 1.166 2017/08/11 22:55:49 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.165 2017/07/14 21:36:19 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.166 2017/08/11 22:55:49 macallan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -396,6 +396,10 @@ add_model_specifics(prop_dictionary_t di
 		"PowerBook4,3", "PowerBook6,3", "PowerBook6,5", NULL};
 	const char *pismo[] = {
 		"PowerBook3,1", NULL};
+	const char *mini1[] = {
+		"PowerMac10,1", NULL};
+	const char *mini2[] = {
+		"PowerMac10,2", NULL};
 	int node;
 
 	node = OF_finddevice("/");
@@ -410,6 +414,12 @@ add_model_specifics(prop_dictionary_t di
 		prop_dictionary_set(dict, "EDID", edid);
 		prop_object_release(edid);
 	}
+	if (of_compatible(node, mini1) != -1) {
+		prop_dictionary_set_bool(dict, "dvi-internal", 1);
+	}
+	if (of_compatible(node, mini2) != -1) {
+		prop_dictionary_set_bool(dict, "dvi-external", 1);
+	}
 }
 
 static void



CVS commit: src/sys/arch/macppc/macppc

2017-09-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Sep  6 03:10:09 UTC 2017

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
downgrade some debug spam to aprint_debug() where it belongs


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.166 src/sys/arch/macppc/macppc/machdep.c:1.167
--- src/sys/arch/macppc/macppc/machdep.c:1.166	Fri Aug 11 22:55:49 2017
+++ src/sys/arch/macppc/macppc/machdep.c	Wed Sep  6 03:10:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.166 2017/08/11 22:55:49 macallan Exp $	*/
+/*	$NetBSD: machdep.c,v 1.167 2017/09/06 03:10:09 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.166 2017/08/11 22:55:49 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.167 2017/09/06 03:10:09 macallan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -331,14 +331,14 @@ copy_disp_props(device_t dev, int node, 
 			prop_dictionary_set_uint32(dict, "address", fbaddr);
 	}
 	if (of_to_dataprop(dict, node, "EDID", "EDID")) {
-		aprint_verbose("found EDID property...\n");
+		aprint_debug("found EDID property...\n");
 	} else if (of_to_dataprop(dict, node, "EDID,A", "EDID")) {
-		aprint_verbose("found EDID,A\n");
+		aprint_debug("found EDID,A\n");
 	} else if (of_to_dataprop(dict, node, "EDID,B", "EDID")) {
 		memset(name, 0, sizeof(name));
 		OF_getprop(node, "name", name, sizeof(name));
 		if (strcmp(name, "NVDA,NVMac") == 0) {
-			aprint_verbose("found EDID,B on nvidia - assuming digital output\n");
+			aprint_debug("found EDID,B on nvidia - assuming digital output\n");
 			prop_dictionary_set_bool(dict, "no_palette_control", 1);
 			have_palette = 0;
 		}



CVS commit: src/sys/arch/macppc/macppc

2018-01-31 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan 31 21:09:53 UTC 2018

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
- do some magic number reduction
- MPIC doesn't have the OPENPIC_POLARITY_* bit, so don't pretend to


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/macppc/pic_u3_ht.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.3 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.4
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.3	Wed Oct 18 12:55:14 2017
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Wed Jan 31 21:09:53 2018
@@ -49,6 +49,10 @@
 #define DPRINTF if (0) printf
 #endif
 
+#define HTAPIC_REQUEST_EOI	0x20
+#define HTAPIC_TRIGGER_LEVEL	0x02
+#define HTAPIC_MASK		0x01
+
 struct u3_ht_irqmap {
 	int im_index;
 	int im_level;
@@ -216,7 +220,6 @@ setup_u3_ht(uint32_t addr, uint32_t len,
 	for (irq = 0; irq < 4; irq++) {
 		x = irq;
 		x |= OPENPIC_IMASK;
-		x |= OPENPIC_POLARITY_NEGATIVE;
 		x |= OPENPIC_SENSE_LEVEL;
 		x |= 8 << OPENPIC_PRIORITY_SHIFT;
 		u3_ht_write(u3_ht, OPENPIC_SRC_VECTOR(irq), x);
@@ -225,7 +228,6 @@ setup_u3_ht(uint32_t addr, uint32_t len,
 	for (irq = 4; irq < pic->pic_numintrs; irq++) {
 		x = irq;
 		x |= OPENPIC_IMASK;
-		x |= OPENPIC_POLARITY_NEGATIVE;
 		x |= OPENPIC_SENSE_EDGE;
 		x |= 8 << OPENPIC_PRIORITY_SHIFT;
 		u3_ht_write(u3_ht, OPENPIC_SRC_VECTOR(irq), x);
@@ -308,7 +310,7 @@ setup_u3_ht_workarounds(struct u3_ht_ops
 			out8rb(base + 0x02, 0x10 + (i << 1));
 			tmp = in32rb(base + 0x04);
 			irq = (tmp >> 16) & 0xff;
-			tmp |= 0x01;
+			tmp |= HTAPIC_MASK;
 			out32rb(base + 0x04, tmp);
 
 			irqmap[irq].im_index = i;
@@ -388,14 +390,8 @@ u3_ht_establish_irq(struct pic_ops *pic,
 	x |= OPENPIC_IMASK;
 
 	if (u3_ht_is_ht_irq(u3_ht, irq)) {
-		x |= OPENPIC_POLARITY_POSITIVE |
-		OPENPIC_SENSE_EDGE;
+		x |= OPENPIC_SENSE_EDGE;
 	} else {
-		if (irq == 0 || type == IST_EDGE_RISING || type == IST_LEVEL_HIGH)
-			x |= OPENPIC_POLARITY_POSITIVE;
-		else
-			x |= OPENPIC_POLARITY_NEGATIVE;
-
 		if (type == IST_EDGE_FALLING || type == IST_EDGE_RISING)
 			x |= OPENPIC_SENSE_EDGE;
 		else
@@ -446,15 +442,15 @@ u3_ht_establish_ht_irq(struct u3_ht_ops 
 
 	x = in32rb(irqmap->im_base + 0x04);
 	/* mask interrupt */
-	out32rb(irqmap->im_base + 0x04, x | 1);
+	out32rb(irqmap->im_base + 0x04, x | HTAPIC_MASK);
 
 	/* mask out EOI and LEVEL bits */
-	x &= ~0x22;
+	x &= ~(HTAPIC_TRIGGER_LEVEL | HTAPIC_REQUEST_EOI);
 
 	if (type == IST_LEVEL_HIGH || type == IST_LEVEL_LOW) {
 		irqmap->im_level = 1;
 		DPRINTF("level\n");
-		x |= 0x22;
+		x |= HTAPIC_TRIGGER_LEVEL | HTAPIC_REQUEST_EOI;
 	} else {
 		irqmap->im_level = 0;
 	}
@@ -470,7 +466,7 @@ u3_ht_enable_ht_irq(struct u3_ht_ops *u3
 
 	out8rb(irqmap->im_base + 0x02, 0x10 + (irqmap->im_index << 1));
 	x = in32rb(irqmap->im_base + 0x04);
-	x &= ~0x01;
+	x &= ~HTAPIC_MASK;
 	out32rb(irqmap->im_base + 0x04, x);
 
 	u3_ht_ack_ht_irq(u3_ht, irq);
@@ -484,7 +480,7 @@ u3_ht_disable_ht_irq(struct u3_ht_ops *u
 
 	out8rb(irqmap->im_base + 0x02, 0x10 + (irqmap->im_index << 1));
 	x = in32rb(irqmap->im_base + 0x04);
-	x |= 0x01;
+	x |= HTAPIC_MASK;
 	out32rb(irqmap->im_base + 0x04, x);
 }
 



CVS commit: src/sys/arch/macppc/macppc

2016-06-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 15 14:32:03 UTC 2016

Modified Files:
src/sys/arch/macppc/macppc: pic_ohare.c

Log Message:
g/c some leftovers from when we had static assignments of edge or level
triggers


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/macppc/macppc/pic_ohare.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_ohare.c
diff -u src/sys/arch/macppc/macppc/pic_ohare.c:1.12 src/sys/arch/macppc/macppc/pic_ohare.c:1.13
--- src/sys/arch/macppc/macppc/pic_ohare.c:1.12	Sun Apr 21 15:42:11 2013
+++ src/sys/arch/macppc/macppc/pic_ohare.c	Wed Jun 15 14:32:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_ohare.c,v 1.12 2013/04/21 15:42:11 kiyohara Exp $ */
+/*	$NetBSD: pic_ohare.c,v 1.13 2016/06/15 14:32:03 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.12 2013/04/21 15:42:11 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.13 2016/06/15 14:32:03 macallan Exp $");
 
 #include "opt_interrupt.h"
 
@@ -68,8 +68,6 @@ static inline void ohare_read_events(str
 #define INT_ENABLE_REG	((uint32_t)pic->pic_cookie + 0x24)
 #define INT_CLEAR_REG	((uint32_t)pic->pic_cookie + 0x28)
 #define INT_LEVEL_REG	((uint32_t)pic->pic_cookie + 0x2c)
-#define INT_LEVEL_MASK_OHARE	0x1ff0
-#define INT_LEVEL_MASK_GC	0x3ff0
 
 int init_ohare(void)
 {
@@ -135,12 +133,12 @@ setup_ohare(uint32_t addr, int is_gc)
 	if (is_gc) {
 	
 		strcpy(pic->pic_name, "gc");
-		ohare->level_mask = 0;
 	} else {
 
 		strcpy(pic->pic_name, "ohare");
-		ohare->level_mask = 0;
 	}
+	ohare->level_mask = 0;
+
 	for (i = 0; i < OHARE_NIRQ; i++)
 		ohare->priority_masks[i] = 0;
 	for (i = 0; i < NIPL; i++)



CVS commit: src/sys/arch/macppc/macppc

2012-03-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Mar 13 17:26:05 UTC 2012

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
we don't need malloc.h here


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.162 src/sys/arch/macppc/macppc/machdep.c:1.163
--- src/sys/arch/macppc/macppc/machdep.c:1.162	Thu Jul 28 15:29:52 2011
+++ src/sys/arch/macppc/macppc/machdep.c	Tue Mar 13 17:26:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.162 2011/07/28 15:29:52 macallan Exp $	*/
+/*	$NetBSD: machdep.c,v 1.163 2012/03/13 17:26:05 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.162 2011/07/28 15:29:52 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.163 2012/03/13 17:26:05 macallan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -52,7 +52,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/arch/macppc/macppc

2012-03-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Mar 13 18:24:54 UTC 2012

Modified Files:
src/sys/arch/macppc/macppc: pic_heathrow.c pic_ohare.c

Log Message:
malloc() -> kmem_alloc()


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/macppc/macppc/pic_heathrow.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/macppc/macppc/pic_ohare.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_heathrow.c
diff -u src/sys/arch/macppc/macppc/pic_heathrow.c:1.7 src/sys/arch/macppc/macppc/pic_heathrow.c:1.8
--- src/sys/arch/macppc/macppc/pic_heathrow.c:1.7	Thu Jul  7 01:26:37 2011
+++ src/sys/arch/macppc/macppc/pic_heathrow.c	Tue Mar 13 18:24:54 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_heathrow.c,v 1.7 2011/07/07 01:26:37 mrg Exp $ */
+/*	$NetBSD: pic_heathrow.c,v 1.8 2012/03/13 18:24:54 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,12 +27,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.7 2011/07/07 01:26:37 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.8 2012/03/13 18:24:54 macallan Exp $");
 
 #include "opt_interrupt.h"
 
 #include 
-#include 
+#include 
 #include 
 
 #include 
@@ -108,7 +108,7 @@ setup_heathrow(uint32_t addr)
 	struct heathrow_ops *heathrow;
 	struct pic_ops *pic;
 
-	heathrow = malloc(sizeof(struct heathrow_ops), M_DEVBUF, M_NOWAIT);
+	heathrow = kmem_alloc(sizeof(struct heathrow_ops), KM_SLEEP);
 	KASSERT(heathrow != NULL);
 	pic = &heathrow->pic;
 

Index: src/sys/arch/macppc/macppc/pic_ohare.c
diff -u src/sys/arch/macppc/macppc/pic_ohare.c:1.10 src/sys/arch/macppc/macppc/pic_ohare.c:1.11
--- src/sys/arch/macppc/macppc/pic_ohare.c:1.10	Thu Jul  7 01:26:37 2011
+++ src/sys/arch/macppc/macppc/pic_ohare.c	Tue Mar 13 18:24:54 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_ohare.c,v 1.10 2011/07/07 01:26:37 mrg Exp $ */
+/*	$NetBSD: pic_ohare.c,v 1.11 2012/03/13 18:24:54 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,12 +27,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.10 2011/07/07 01:26:37 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.11 2012/03/13 18:24:54 macallan Exp $");
 
 #include "opt_interrupt.h"
 
 #include 
-#include 
+#include 
 #include 
 
 #include 
@@ -118,7 +118,7 @@ setup_ohare(uint32_t addr, int is_gc)
 	struct pic_ops *pic;
 	int i;
 
-	ohare = malloc(sizeof(struct ohare_ops), M_DEVBUF, M_NOWAIT);
+	ohare = kmem_alloc(sizeof(struct ohare_ops), KM_SLEEP);
 	KASSERT(ohare != NULL);
 	pic = &ohare->pic;
 
@@ -238,6 +238,7 @@ ohare_get_irq(struct pic_ops *pic, int m
 
 	bit = 31 - __builtin_clz(ohare->pending_events);
 	mask = 1 << bit;
+
 	if ((ohare->pending_events & ~mask) == 0) {
 
 		ohare->pending_events = 0;
@@ -265,8 +266,14 @@ ohare_get_irq(struct pic_ops *pic, int m
 	evt = ohare->pending_events & ohare->irqs[lvl];
 
 	if (evt == 0) {
+#ifdef OHARE_DEBUG
 		aprint_verbose("%s: spurious interrupt\n", 
 		ohare->pic.pic_name);
+		printf("levels: %08x\n", in32rb(INT_LEVEL_REG));
+		printf("states: %08x\n", in32rb(INT_STATE_REG));
+		printf("enable: %08x\n", in32rb(INT_ENABLE_REG));
+		printf("events: %08x\n", ohare->pending_events);
+#endif
 		evt = ohare->pending_events;
 	}
 



CVS commit: src/sys/arch/macppc/macppc

2012-05-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed May  2 00:55:26 UTC 2012

Modified Files:
src/sys/arch/macppc/macppc: pic_heathrow.c

Log Message:
remove some commented out / unused junk


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/macppc/pic_heathrow.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_heathrow.c
diff -u src/sys/arch/macppc/macppc/pic_heathrow.c:1.8 src/sys/arch/macppc/macppc/pic_heathrow.c:1.9
--- src/sys/arch/macppc/macppc/pic_heathrow.c:1.8	Tue Mar 13 18:24:54 2012
+++ src/sys/arch/macppc/macppc/pic_heathrow.c	Wed May  2 00:55:26 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_heathrow.c,v 1.8 2012/03/13 18:24:54 macallan Exp $ */
+/*	$NetBSD: pic_heathrow.c,v 1.9 2012/05/02 00:55:26 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.8 2012/03/13 18:24:54 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.9 2012/05/02 00:55:26 macallan Exp $");
 
 #include "opt_interrupt.h"
 
@@ -70,7 +70,6 @@ static inline void heathrow_read_events(
 #define INT_ENABLE_REG_L	((uint32_t)pic->pic_cookie + 0x24)
 #define INT_CLEAR_REG_L		((uint32_t)pic->pic_cookie + 0x28)
 #define INT_LEVEL_REG_L		((uint32_t)pic->pic_cookie + 0x2c)
-#define INT_LEVEL_MASK_HEATHROW	0x1ff0
 
 static const char *compat[] = {
 	"heathrow",
@@ -201,10 +200,10 @@ heathrow_read_events(struct heathrow_ops
 
 	/* first the low 32 IRQs */
 	irqs = in32rb(INT_STATE_REG_L);
-	events = irqs & ~heathrow->level_mask_l/*INT_LEVEL_MASK_HEATHROW*/;
+	events = irqs & ~heathrow->level_mask_l;
 
 	levels = in32rb(INT_LEVEL_REG_L) & heathrow->enable_mask_l;
-	events |= levels & heathrow->level_mask_l/*INT_LEVEL_MASK_HEATHROW*/;
+	events |= levels & heathrow->level_mask_l;
 	out32rb(INT_CLEAR_REG_L, events | irqs);
 	heathrow->pending_events_l |= events;
 



CVS commit: src/sys/arch/macppc/macppc

2012-12-10 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Dec 11 03:00:00 UTC 2012

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
work around a bug in some (all?) nvidia OF ROMs:
the color! method always changes only the palette registers associated with the
first, usually analog head, even if the monitor in use is on port 2, usually
DVI or ADC.
Don't enable cmap_callback when we find out we're on port 2 of an nvidia card,
that way genfb won't try to use R3G3B2 colours and assume something resembling
an ANSI palette which will at least gives us something usable, as opposed to
black on mostly black.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.163 src/sys/arch/macppc/macppc/machdep.c:1.164
--- src/sys/arch/macppc/macppc/machdep.c:1.163	Tue Mar 13 17:26:05 2012
+++ src/sys/arch/macppc/macppc/machdep.c	Tue Dec 11 03:00:00 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.163 2012/03/13 17:26:05 macallan Exp $	*/
+/*	$NetBSD: machdep.c,v 1.164 2012/12/11 03:00:00 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.163 2012/03/13 17:26:05 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.164 2012/12/11 03:00:00 macallan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -112,6 +112,7 @@ struct genfb_parameter_callback gpc_back
  * state so we assume the backlight is on and about 4/5 up which seems 
  * reasonable for most laptops
  */
+
 int backlight_state = 1;
 int brightness_level = 200;
 
@@ -269,9 +270,11 @@ callback(void *p)
 void
 copy_disp_props(device_t dev, int node, prop_dictionary_t dict)
 {
+	char name[32];
 	uint32_t temp;
 	uint64_t cmap_cb, backlight_cb, brightness_cb;
 	int have_backlight = 0;
+	int have_palette = 1;
 
 	if (node != console_node) {
 		/*
@@ -316,7 +319,19 @@ copy_disp_props(device_t dev, int node, 
 		if (fbaddr != 0)
 			prop_dictionary_set_uint32(dict, "address", fbaddr);
 	}
-	of_to_dataprop(dict, node, "EDID", "EDID");
+	if (of_to_dataprop(dict, node, "EDID", "EDID")) {
+		aprint_verbose("found EDID property...\n");
+	} else if (of_to_dataprop(dict, node, "EDID,A", "EDID")) {
+		aprint_verbose("found EDID,A\n");
+	} else if (of_to_dataprop(dict, node, "EDID,B", "EDID")) {
+		memset(name, 0, sizeof(name));
+		OF_getprop(node, "name", name, sizeof(name));
+		if (strcmp(name, "NVDA,NVMac") == 0) {
+			aprint_verbose("found EDID,B on nvidia - assuming digital output\n");
+			prop_dictionary_set_bool(dict, "no_palette_control", 1);
+			have_palette = 0;
+		}
+	}
 	add_model_specifics(dict);
 
 	temp = 0;
@@ -328,10 +343,12 @@ copy_disp_props(device_t dev, int node, 
 	if (temp != 0)
 		prop_dictionary_set_uint32(dict, "refclk", temp / 10);
 
-	gfb_cb.gcc_cookie = (void *)console_instance;
-	gfb_cb.gcc_set_mapreg = of_set_palette;
-	cmap_cb = (uint64_t)(uintptr_t)&gfb_cb;
-	prop_dictionary_set_uint64(dict, "cmap_callback", cmap_cb);
+	if (have_palette) {
+		gfb_cb.gcc_cookie = (void *)console_instance;
+		gfb_cb.gcc_set_mapreg = of_set_palette;
+		cmap_cb = (uint64_t)(uintptr_t)&gfb_cb;
+		prop_dictionary_set_uint64(dict, "cmap_callback", cmap_cb);
+	}
 
 	/* not let's look for backlight control */
 	have_backlight = 0;
@@ -342,6 +359,7 @@ copy_disp_props(device_t dev, int node, 
 		have_backlight = 1;
 	}
 	if (have_backlight) {
+
 		gpc_backlight.gpc_cookie = (void *)console_instance;
 		gpc_backlight.gpc_set_parameter = of_set_backlight;
 		gpc_backlight.gpc_get_parameter = of_get_backlight;



CVS commit: src/sys/arch/macppc/macppc

2012-01-24 Thread Hauke Fath
Module Name:src
Committed By:   hauke
Date:   Tue Jan 24 15:24:55 UTC 2012

Modified Files:
src/sys/arch/macppc/macppc: disksubr.c

Log Message:
Add support for BSD disklabels, scanning the beginning of the disk
in four-byte strides, like disklabel(8) does it.

Since the netbsd-6 branch is around the corner, this is a
minimally-intrusive addition.

Note there is no write support, for good reasons.
Note also that disksubr.c is in dire need of re-structuring.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/macppc/macppc/disksubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/disksubr.c
diff -u src/sys/arch/macppc/macppc/disksubr.c:1.47 src/sys/arch/macppc/macppc/disksubr.c:1.48
--- src/sys/arch/macppc/macppc/disksubr.c:1.47	Mon Mar 16 23:11:12 2009
+++ src/sys/arch/macppc/macppc/disksubr.c	Tue Jan 24 15:24:55 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: disksubr.c,v 1.47 2009/03/16 23:11:12 dsl Exp $	*/
+/*	$NetBSD: disksubr.c,v 1.48 2012/01/24 15:24:55 hauke Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -106,7 +106,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.47 2009/03/16 23:11:12 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.48 2012/01/24 15:24:55 hauke Exp $");
 
 #include 
 #include 
@@ -137,6 +137,8 @@ static const char *read_mac_label(dev_t,
 		struct disklabel *, struct cpu_disklabel *);
 static const char *read_dos_label(dev_t, void (*)(struct buf *),
 		struct disklabel *, struct cpu_disklabel *);
+static const char *read_bsd_label(dev_t, void (*)(struct buf *),
+		struct disklabel *, struct cpu_disklabel *);
 static int get_netbsd_label(dev_t, void (*)(struct buf *),
 		struct disklabel *, struct cpu_disklabel *);
 
@@ -387,6 +389,78 @@ done:
 	return msg;
 }
 
+/*
+ * Scan the disk buffer in four byte strides for a native BSD
+ * disklabel (different ports have variably-sized bootcode before
+ * the label)
+ */
+static const char *
+read_bsd_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
+struct cpu_disklabel *osdep)
+{
+	struct disklabel *dlp;
+	struct buf *bp;
+	const char *msg;
+	struct disklabel *blk_start, *blk_end;
+	int size, match;
+	
+	msg = NULL;
+
+	/* 
+	 * Read in the first #(NUM_PARTS + 1) blocks of the disk.
+	 * The native Macintosh partition table starts at 
+	 * sector #1, but we want #0 too for the BSD label.
+	 */
+	size = roundup((NUM_PARTS + 1) << DEV_BSHIFT, lp->d_secsize);
+	bp = geteblk(size);
+
+	bp->b_dev = dev;
+	bp->b_blkno = 0;
+	bp->b_resid = 0;
+	bp->b_bcount = size;
+	bp->b_flags |= B_READ;
+	bp->b_cylinder = 1 / lp->d_secpercyl;
+	(*strat)(bp);
+
+	match = 0;
+	
+	if (biowait(bp)) {
+		msg = "I/O error reading BSD disklabel";
+	} else {
+		/*
+		 * Hunt the label, starting at the beginning of the disk.
+		 * When we find an inconsistent label, report and continue.
+		 */
+		blk_start = (struct disklabel *)bp->b_data;
+		blk_end = (struct disklabel *)((char *)bp->b_data +
+		(NUM_PARTS << DEV_BSHIFT) - sizeof(struct disklabel));
+
+		for (dlp = blk_start; dlp <= blk_end; 
+		 dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
+			if (dlp->d_magic == DISKMAGIC &&
+			dlp->d_magic2 == DISKMAGIC) {
+/* Sanity check */
+if (dlp->d_npartitions <= MAXPARTITIONS && 
+dkcksum(dlp) == 0) {
+	*lp = *dlp;
+	match = -1;
+	break;
+#ifdef DIAGNOSTIC
+} else {
+	printf("read_bsd_label() found "
+	"damaged disklabel starting at "
+	"0x0%p, ignore\n", dlp);
+#endif /* DIAGNOSTIC */
+}
+			}
+		}
+		if (!match)
+			msg = "BSD disklabel not found";
+	}
+	brelse(bp, 0);
+	return msg;
+}
+
 /* Read MS-DOS partition table.
  *
  * XXX -
@@ -597,8 +671,9 @@ readdisklabel(dev_t dev, void (*strat)(s
 			if (!msg)
 osdep->cd_start = 0;
 		} else {
-			msg = "no disk label -- NetBSD or Macintosh";
-			osdep->cd_start = 0;	/* XXX for now */
+			msg = read_bsd_label(dev, strat, lp, osdep);
+			if (!msg)
+osdep->cd_start = 0;	/* XXX for now */
 		}
 	}
 



CVS commit: src/sys/arch/macppc/macppc

2011-06-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jun 16 02:44:38 UTC 2011

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
we need powerpc/intr.h n order to see __HAVE_FAST_SOFTINTS


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/macppc/macppc/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.66 src/sys/arch/macppc/macppc/locore.S:1.67
--- src/sys/arch/macppc/macppc/locore.S:1.66	Mon Jan 17 08:23:55 2011
+++ src/sys/arch/macppc/macppc/locore.S	Thu Jun 16 02:44:38 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.66 2011/01/17 08:23:55 matt Exp $	*/
+/*	$NetBSD: locore.S,v 1.67 2011/06/16 02:44:38 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -53,6 +53,7 @@
 
 #include 
 #include 
+#include 
 
 /*
  * Some instructions gas doesn't understand (yet?)



CVS commit: src/sys/arch/macppc/macppc

2011-07-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jul  7 01:26:17 UTC 2011

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
add some (uintptr_t) between pointer and uint64_t casts


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.158 src/sys/arch/macppc/macppc/machdep.c:1.159
--- src/sys/arch/macppc/macppc/machdep.c:1.158	Mon Jun 20 07:18:06 2011
+++ src/sys/arch/macppc/macppc/machdep.c	Thu Jul  7 01:26:16 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.158 2011/06/20 07:18:06 matt Exp $	*/
+/*	$NetBSD: machdep.c,v 1.159 2011/07/07 01:26:16 mrg Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.158 2011/06/20 07:18:06 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.159 2011/07/07 01:26:16 mrg Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -324,7 +324,7 @@
 
 	gfb_cb.gcc_cookie = (void *)console_instance;
 	gfb_cb.gcc_set_mapreg = of_set_palette;
-	cmap_cb = (uint64_t)&gfb_cb;
+	cmap_cb = (uint64_t)(uintptr_t)&gfb_cb;
 	prop_dictionary_set_uint64(dict, "cmap_callback", cmap_cb);
 
 	/* not let's look for backlight control */
@@ -339,7 +339,7 @@
 		gpc.gpc_cookie = (void *)console_instance;
 		gpc.gpc_set_parameter = of_set_backlight;
 		gpc.gpc_get_parameter = of_get_backlight;
-		backlight_cb = (uint64_t)&gpc;
+		backlight_cb = (uint64_t)(uintptr_t)&gpc;
 		prop_dictionary_set_uint64(dict, "backlight_callback", 
 		backlight_cb);
 		/*



CVS commit: src/sys/arch/macppc/macppc

2011-07-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jul  7 01:26:37 UTC 2011

Modified Files:
src/sys/arch/macppc/macppc: pic_heathrow.c pic_ohare.c

Log Message:
mark heathrow_read_events() and ohare_read_events() static.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/macppc/macppc/pic_heathrow.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/macppc/macppc/pic_ohare.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_heathrow.c
diff -u src/sys/arch/macppc/macppc/pic_heathrow.c:1.6 src/sys/arch/macppc/macppc/pic_heathrow.c:1.7
--- src/sys/arch/macppc/macppc/pic_heathrow.c:1.6	Sun Jun 19 07:59:47 2011
+++ src/sys/arch/macppc/macppc/pic_heathrow.c	Thu Jul  7 01:26:37 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_heathrow.c,v 1.6 2011/06/19 07:59:47 matt Exp $ */
+/*	$NetBSD: pic_heathrow.c,v 1.7 2011/07/07 01:26:37 mrg Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.6 2011/06/19 07:59:47 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.7 2011/07/07 01:26:37 mrg Exp $");
 
 #include "opt_interrupt.h"
 
@@ -60,7 +60,7 @@
 };
 
 static struct heathrow_ops *setup_heathrow(uint32_t);
-inline void heathrow_read_events(struct heathrow_ops *);
+static inline void heathrow_read_events(struct heathrow_ops *);
 
 #define INT_STATE_REG_H		((uint32_t)pic->pic_cookie + 0x10)
 #define INT_ENABLE_REG_H	((uint32_t)pic->pic_cookie + 0x14)
@@ -193,7 +193,7 @@
 	}
 }
 
-inline void
+static inline void
 heathrow_read_events(struct heathrow_ops *heathrow)
 {
 	struct pic_ops *pic = &heathrow->pic;

Index: src/sys/arch/macppc/macppc/pic_ohare.c
diff -u src/sys/arch/macppc/macppc/pic_ohare.c:1.9 src/sys/arch/macppc/macppc/pic_ohare.c:1.10
--- src/sys/arch/macppc/macppc/pic_ohare.c:1.9	Sun Jun 19 07:59:47 2011
+++ src/sys/arch/macppc/macppc/pic_ohare.c	Thu Jul  7 01:26:37 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_ohare.c,v 1.9 2011/06/19 07:59:47 matt Exp $ */
+/*	$NetBSD: pic_ohare.c,v 1.10 2011/07/07 01:26:37 mrg Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.9 2011/06/19 07:59:47 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.10 2011/07/07 01:26:37 mrg Exp $");
 
 #include "opt_interrupt.h"
 
@@ -62,7 +62,7 @@
 
 static struct ohare_ops *setup_ohare(uint32_t, int);
 static void setup_ohare2(uint32_t, int);
-inline void ohare_read_events(struct ohare_ops *);
+static inline void ohare_read_events(struct ohare_ops *);
 
 #define INT_STATE_REG	((uint32_t)pic->pic_cookie + 0x20)
 #define INT_ENABLE_REG	((uint32_t)pic->pic_cookie + 0x24)
@@ -199,7 +199,7 @@
 	out32rb(INT_ENABLE_REG, ohare->enable_mask); 
 }
 
-inline void
+static inline void
 ohare_read_events(struct ohare_ops *ohare)
 {
 	struct pic_ops *pic = &ohare->pic;



CVS commit: src/sys/arch/macppc/macppc

2011-07-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 13 22:50:11 UTC 2011

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
follow genfb changes in backlight control


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.159 src/sys/arch/macppc/macppc/machdep.c:1.160
--- src/sys/arch/macppc/macppc/machdep.c:1.159	Thu Jul  7 01:26:16 2011
+++ src/sys/arch/macppc/macppc/machdep.c	Wed Jul 13 22:50:11 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.159 2011/07/07 01:26:16 mrg Exp $	*/
+/*	$NetBSD: machdep.c,v 1.160 2011/07/13 22:50:11 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.159 2011/07/07 01:26:16 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.160 2011/07/13 22:50:11 macallan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -104,18 +104,23 @@
 #include "cuda.h"
 
 struct genfb_colormap_callback gfb_cb;
-struct genfb_parameter_callback gpc;
+struct genfb_parameter_callback gpc_backlight, gpc_brightness;
 
 /*
- * this is bogus - we need to read the actual default from the PMU and then
- * put it here
+ * OpenFirmware gives us no way to check the brightness level or the backlight
+ * state so we assume the backlight is on and about 4/5 up which seems 
+ * reasonable for most laptops
  */
-int backlight_level = 200;
+int backlight_state = 1;
+int brightness_level = 200;
 
 static void of_set_palette(void *, int, int, int, int);
 static void add_model_specifics(prop_dictionary_t);
-static void of_set_backlight(void *, int);
-static int of_get_backlight(void *);
+static int of_get_backlight(void *, int *);
+static int of_set_backlight(void *, int);
+static int of_get_brightness(void *, int *);
+static int of_set_brightness(void *, int);
+static int of_upd_brightness(void *, int);
 
 void
 initppc(u_int startkernel, u_int endkernel, char *args)
@@ -264,7 +269,7 @@
 copy_disp_props(device_t dev, int node, prop_dictionary_t dict)
 {
 	uint32_t temp;
-	uint64_t cmap_cb, backlight_cb;
+	uint64_t cmap_cb, backlight_cb, brightness_cb;
 	int have_backlight = 0;
 
 	if (node != console_node) {
@@ -336,19 +341,21 @@
 		have_backlight = 1;
 	}
 	if (have_backlight) {
-		gpc.gpc_cookie = (void *)console_instance;
-		gpc.gpc_set_parameter = of_set_backlight;
-		gpc.gpc_get_parameter = of_get_backlight;
-		backlight_cb = (uint64_t)(uintptr_t)&gpc;
-		prop_dictionary_set_uint64(dict, "backlight_callback", 
+		gpc_backlight.gpc_cookie = (void *)console_instance;
+		gpc_backlight.gpc_set_parameter = of_set_backlight;
+		gpc_backlight.gpc_get_parameter = of_get_backlight;
+		gpc_backlight.gpc_upd_parameter = NULL;
+		backlight_cb = (uint64_t)&gpc_backlight;
+		prop_dictionary_set_uint64(dict, "backlight_callback",
 		backlight_cb);
-		/*
-		 * since we don't know how to read the backlight level without
-		 * access to the PMU we just set it to the default defined
-		 * above so the hotkeys work as expected
-		 */
-		OF_call_method_1("set-contrast", console_instance, 1, 
-		backlight_level);
+
+		gpc_brightness.gpc_cookie = (void *)console_instance;
+		gpc_brightness.gpc_set_parameter = of_set_brightness;
+		gpc_brightness.gpc_get_parameter = of_get_brightness;
+		gpc_brightness.gpc_upd_parameter = of_upd_brightness;
+		brightness_cb = (uint64_t)&gpc_brightness;
+		prop_dictionary_set_uint64(dict, "brightness_callback",
+		brightness_cb);
 	}
 }
 
@@ -374,25 +381,70 @@
 	OF_call_method_1("color!", ih, 4, r, g, b, index);
 }
 
-static void
-of_set_backlight(void *cookie, int level)
+static int
+of_get_backlight(void *cookie, int *state)
+{
+	if (backlight_state < 0)
+		return ENODEV;
+	*state = backlight_state;
+	return 0;
+}
+
+static int
+of_set_backlight(void *cookie, int state)
 {
 	int ih = (int)cookie;
 
-	if (level < 0) level = 0;
-	if (level > 255) level = 255;
-	backlight_level = level;
-	OF_call_method_1("set-contrast", ih, 1, level);
+	KASSERT(state >= 0 && state <= 1);
+
+	backlight_state = state;
+	if (state)
+		OF_call_method_1("backlight-on", ih, 0);
+	else
+		OF_call_method_1("backlight-off", ih, 0);
+
+	return 0;	/* XXX or use return value of OF_call_method_1? */
 }
 
 static int
-of_get_backlight(void *cookie)
+of_get_brightness(void *cookie, int *level)
 {
-
 	/*
-	 * we don't know how to read the backlight level from OF alone - we
-	 * should read the default from the PMU and then just cache whatever
-	 * we set last
+	 * We don't know how to read the brightness level from OF alone - we
+	 * should read the value from the PMU.  Here, we just return whatever
+	 * we set last (if any).
 	 */
-	return backlight_level;
+	if (brightness_level < 0)
+		return ENODEV;

CVS commit: src/sys/arch/macppc/macppc

2010-04-26 Thread KIYOHARA Takashi
Module Name:src
Committed By:   kiyohara
Date:   Tue Apr 27 05:27:59 UTC 2010

Modified Files:
src/sys/arch/macppc/macppc: pic_ohare.c

Log Message:
Use OHARE_NIRQ instead of NIRQ.
  NIRQ defined in powerpc/intr.h sinse 'Support 64-bit imask for powerpc/pic.'


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/macppc/macppc/pic_ohare.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/pic_ohare.c
diff -u src/sys/arch/macppc/macppc/pic_ohare.c:1.6 src/sys/arch/macppc/macppc/pic_ohare.c:1.7
--- src/sys/arch/macppc/macppc/pic_ohare.c:1.6	Thu May  8 01:27:43 2008
+++ src/sys/arch/macppc/macppc/pic_ohare.c	Tue Apr 27 05:27:59 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_ohare.c,v 1.6 2008/05/08 01:27:43 macallan Exp $ */
+/*	$NetBSD: pic_ohare.c,v 1.7 2010/04/27 05:27:59 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.6 2008/05/08 01:27:43 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.7 2010/04/27 05:27:59 kiyohara Exp $");
 
 #include "opt_interrupt.h"
 
@@ -51,15 +51,15 @@
 static void ohare_ack_irq(struct pic_ops *, int);
 static void ohare_establish_irq(struct pic_ops *, int, int, int);
 
-#define NIRQ 32
+#define OHARE_NIRQ 32
 
 struct ohare_ops {
 	struct pic_ops pic;
 	uint32_t pending_events;
 	uint32_t enable_mask;
 	uint32_t level_mask;
-	uint32_t irqs[NIPL];		/* per priority level */
-	uint32_t priority_masks[NIRQ];	/* per IRQ */
+	uint32_t irqs[NIPL];			/* per priority level */
+	uint32_t priority_masks[OHARE_NIRQ];	/* per IRQ */
 };
 
 static struct ohare_ops *setup_ohare(uint32_t, int);
@@ -124,7 +124,7 @@
 	KASSERT(ohare != NULL);
 	pic = &ohare->pic;
 
-	pic->pic_numintrs = NIRQ;
+	pic->pic_numintrs = OHARE_NIRQ;
 	pic->pic_cookie = (void *)addr;
 	pic->pic_enable_irq = ohare_enable_irq;
 	pic->pic_reenable_irq = ohare_reenable_irq;
@@ -143,7 +143,7 @@
 		strcpy(pic->pic_name, "ohare");
 		ohare->level_mask = 0;
 	}
-	for (i = 0; i < NIRQ; i++)
+	for (i = 0; i < OHARE_NIRQ; i++)
 		ohare->priority_masks[i] = 0;
 	for (i = 0; i < NIPL; i++)
 		ohare->irqs[i] = 0;
@@ -291,7 +291,7 @@
 	int realpri = min(NIPL, max(0, pri)), i;
 	uint32_t level = 1 << realpri;
 
-	KASSERT((irq >= 0) && (irq < NIRQ));
+	KASSERT((irq >= 0) && (irq < OHARE_NIRQ));
 
 	if (type == IST_LEVEL) {
 
@@ -305,7 +305,7 @@
 	for (i = 0; i < NIPL; i++)
 		ohare->irqs[i] = 0;
 		
-	for (i = 0; i < NIRQ; i++) {
+	for (i = 0; i < OHARE_NIRQ; i++) {
 		if (ohare->priority_masks[i] == 0)
 			continue;
 		level = 31 - cntlzw(ohare->priority_masks[i]);



CVS commit: src/sys/arch/macppc/macppc

2010-10-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Oct  6 02:27:25 UTC 2010

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
add support for backlight control with genfb via OF
Tested on a PowerBook Pismo only so far, it should work on all OF3 *Books
though. Support for older PowerBooks is trickier since they control their
backlight using PMU commands which have no OF equivalent.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.153 src/sys/arch/macppc/macppc/machdep.c:1.154
--- src/sys/arch/macppc/macppc/machdep.c:1.153	Fri Nov 27 03:23:11 2009
+++ src/sys/arch/macppc/macppc/machdep.c	Wed Oct  6 02:27:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.153 2009/11/27 03:23:11 rmind Exp $	*/
+/*	$NetBSD: machdep.c,v 1.154 2010/10/06 02:27:25 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.153 2009/11/27 03:23:11 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.154 2010/10/06 02:27:25 macallan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -107,9 +107,18 @@
 #endif
 
 struct genfb_colormap_callback gfb_cb;
+struct genfb_parameter_callback gpc;
+
+/*
+ * this is bogus - we need to read the actual default from the PMU and then
+ * put it here
+ */
+int backlight_level = 200;
 
 static void of_set_palette(void *, int, int, int, int);
 static void add_model_specifics(prop_dictionary_t);
+static void of_set_backlight(void *, int);
+static int of_get_backlight(void *);
 
 void
 initppc(u_int startkernel, u_int endkernel, char *args)
@@ -258,7 +267,8 @@
 copy_disp_props(struct device *dev, int node, prop_dictionary_t dict)
 {
 	uint32_t temp;
-	uint64_t cmap_cb;
+	uint64_t cmap_cb, backlight_cb;
+	int have_backlight = 0;
 
 	if (node != console_node) {
 		/*
@@ -319,6 +329,30 @@
 	gfb_cb.gcc_set_mapreg = of_set_palette;
 	cmap_cb = (uint64_t)&gfb_cb;
 	prop_dictionary_set_uint64(dict, "cmap_callback", cmap_cb);
+
+	/* not let's look for backlight control */
+	have_backlight = 0;
+	if (OF_getprop(node, "backlight-control", &temp, sizeof(temp)) == 4) {
+		have_backlight = 1;
+	} else if (OF_getprop(OF_parent(node), "backlight-control", &temp, 
+		sizeof(temp)) == 4) {
+		have_backlight = 1;
+	}
+	if (have_backlight) {
+		gpc.gpc_cookie = (void *)console_instance;
+		gpc.gpc_set_parameter = of_set_backlight;
+		gpc.gpc_get_parameter = of_get_backlight;
+		backlight_cb = (uint64_t)&gpc;
+		prop_dictionary_set_uint64(dict, "backlight_callback", 
+		backlight_cb);
+		/*
+		 * since we don't know how to read the backlight level without
+		 * access to the PMU we just set it to the default defined
+		 * above so the hotkeys work as expected
+		 */
+		OF_call_method_1("set-contrast", console_instance, 1, 
+		backlight_level);
+	}
 }
 
 static void
@@ -342,3 +376,26 @@
 
 	OF_call_method_1("color!", ih, 4, r, g, b, index);
 }
+
+static void
+of_set_backlight(void *cookie, int level)
+{
+	int ih = (int)cookie;
+
+	if (level < 0) level = 0;
+	if (level > 255) level = 255;
+	backlight_level = level;
+	OF_call_method_1("set-contrast", ih, 1, level);
+}
+
+static int
+of_get_backlight(void *cookie)
+{
+
+	/*
+	 * we don't know how to read the backlight level from OF alone - we
+	 * should read the default from the PMU and then just cache whatever
+	 * we set last
+	 */
+	return backlight_level;
+}



CVS commit: src/sys/arch/macppc/macppc

2011-07-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jul 28 15:29:52 UTC 2011

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
appease gcc 4.5


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/arch/macppc/macppc/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.161 src/sys/arch/macppc/macppc/machdep.c:1.162
--- src/sys/arch/macppc/macppc/machdep.c:1.161	Wed Jul 13 22:54:33 2011
+++ src/sys/arch/macppc/macppc/machdep.c	Thu Jul 28 15:29:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.161 2011/07/13 22:54:33 macallan Exp $	*/
+/*	$NetBSD: machdep.c,v 1.162 2011/07/28 15:29:52 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.161 2011/07/13 22:54:33 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.162 2011/07/28 15:29:52 macallan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -347,7 +347,7 @@
 		gpc_backlight.gpc_set_parameter = of_set_backlight;
 		gpc_backlight.gpc_get_parameter = of_get_backlight;
 		gpc_backlight.gpc_upd_parameter = NULL;
-		backlight_cb = (uint64_t)&gpc_backlight;
+		backlight_cb = (uint64_t)(uintptr_t)&gpc_backlight;
 		prop_dictionary_set_uint64(dict, "backlight_callback",
 		backlight_cb);
 
@@ -355,7 +355,7 @@
 		gpc_brightness.gpc_set_parameter = of_set_brightness;
 		gpc_brightness.gpc_get_parameter = of_get_brightness;
 		gpc_brightness.gpc_upd_parameter = of_upd_brightness;
-		brightness_cb = (uint64_t)&gpc_brightness;
+		brightness_cb = (uint64_t)(uintptr_t)&gpc_brightness;
 		prop_dictionary_set_uint64(dict, "brightness_callback",
 		brightness_cb);
 	}



CVS commit: src/sys/arch/macppc/macppc

2014-03-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 26 17:45:16 UTC 2014

Modified Files:
src/sys/arch/macppc/macppc: cpu.c

Log Message:
kill sprintf


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/macppc/macppc/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.59 src/sys/arch/macppc/macppc/cpu.c:1.60
--- src/sys/arch/macppc/macppc/cpu.c:1.59	Sat Oct 27 13:18:00 2012
+++ src/sys/arch/macppc/macppc/cpu.c	Wed Mar 26 13:45:16 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.59 2012/10/27 17:18:00 chs Exp $	*/
+/*	$NetBSD: cpu.c,v 1.60 2014/03/26 17:45:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.59 2012/10/27 17:18:00 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.60 2014/03/26 17:45:16 christos Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -221,7 +221,7 @@ md_setup_trampoline(volatile struct cpu_
 		h->hatch_running = -1;
 
 		/* see if there's an OF property for the reset register */
-		sprintf(cpupath, "/cpus/@%x", ci->ci_cpuid);
+		snprintf(cpupath, sizeof(cpupath), "/cpus/@%x", ci->ci_cpuid);
 		node = OF_finddevice(cpupath);
 		if (node == -1) {
 			printf(": no OF node for CPU %d?\n", ci->ci_cpuid);



CVS commit: src/sys/arch/macppc/macppc

2013-04-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 11 18:36:44 UTC 2013

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
more OEA64_BRIDGE support
from Phileas Fogg


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/macppc/macppc/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.70 src/sys/arch/macppc/macppc/locore.S:1.71
--- src/sys/arch/macppc/macppc/locore.S:1.70	Mon Jun 20 19:56:12 2011
+++ src/sys/arch/macppc/macppc/locore.S	Thu Apr 11 18:36:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.70 2011/06/20 19:56:12 matt Exp $	*/
+/*	$NetBSD: locore.S,v 1.71 2013/04/11 18:36:44 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -87,6 +87,11 @@ __start:
 
 	li	0,0
 	mtmsr	0			/* Disable FPU/MMU/exceptions */
+#if defined(PMAP_OEA64_BRIDGE)
+	mfmsr	0			/* Clear SF and ISF bits */
+	clrldi	0,0,3
+	mtmsrd	0
+#endif /* PMAP_OEA64_BRIDGE */
 	isync
 
 /* compute end of kernel memory */