Re: CVS commit: src/sys/arch/arm/sunxi

2021-01-20 Thread Martin Husemann
On Tue, Jan 19, 2021 at 07:19:51PM +0100, Martin Husemann wrote:
> On Tue, Jan 19, 2021 at 12:35:10AM +, Jason R Thorpe wrote:
> > Module Name:src
> > Committed By:   thorpej
> > Date:   Tue Jan 19 00:35:10 UTC 2021
> > 
> > Modified Files:
> > src/sys/arch/arm/sunxi: sunxi_sramc.c
> > 
> > Log Message:
> > Use device_compatible_entry / of_search_compatible() rather than matching
> > against multiple sets of compatibility strings.
> > 
> > 
> > To generate a diff of this commit:
> > cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_sramc.c
> 
> This breaks cubietruck (fdt is: sun7i-a20-cubietruck.dtb):

And it was fixed with

$NetBSD: sunxi_sramc.c,v 1.7 2021/01/20 00:48:49 jmcneill Exp $

Martin


Re: CVS commit: src/sys/arch/arm/sunxi

2021-01-19 Thread Martin Husemann
On Tue, Jan 19, 2021 at 12:35:10AM +, Jason R Thorpe wrote:
> Module Name:  src
> Committed By: thorpej
> Date: Tue Jan 19 00:35:10 UTC 2021
> 
> Modified Files:
>   src/sys/arch/arm/sunxi: sunxi_sramc.c
> 
> Log Message:
> Use device_compatible_entry / of_search_compatible() rather than matching
> against multiple sets of compatibility strings.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_sramc.c

This breaks cubietruck (fdt is: sun7i-a20-cubietruck.dtb):


[   1.000] fclock0 at simplebus2: 2500 Hz fixed clock (mii_phy_tx)
[   1.000] fclock1 at simplebus2: 12500 Hz fixed clock (gmac_int_tx)
[   1.000] fclock2 at simplebus2: 2400 Hz fixed clock (osc24M)
[   1.000] fclock3 at simplebus2: 32768 Hz fixed clock (osc32k)
[   1.000] gtmr0 at simplebus0: Generic Timer
[   1.000] gtmr0: interrupting on GIC irq 27
[   1.000] armgtmr0 at gtmr0: Generic Timer (24000 kHz, virtual)
[   1.030] sun4ia10ccu0 at simplebus1: A20 CCU
[   1.030] sunxinmi0 at simplebus1: NMI
[   1.030] sunxigmacclk0 at simplebus2: GMAC MII/RGMII clock mux
[   1.030] sunxigpio0 at simplebus1: PIO
[   1.030] gpio0 at sunxigpio0: 175 pins
[   1.030] sunxigpio0: interrupting on GIC irq 60
[   1.030] sun4idma0 at simplebus1: DMA controller
[   1.030] sun4idma0: interrupting on GIC irq 59
[   1.030] sunxisramc0 at simplebus1: SRAM Controller

[   1.030] uvm_fault(0x80b92d68, 0, 1) -> e
[   1.030] Fatal kernel mode data abort: 'Translation Fault (S)'
[   1.030] trapframe: 0x80bc8cf0
[   1.030] FSR=0005, FAR=, spsr=6353
[   1.030] r0 =92cfd200, r1 =806b0910, r2 =, r3 =
[   1.030] r4 =92a0cd00, r5 =10c4, r6 =92cfd200, r7 =0dd0
[   1.030] r8 =806b0910, r9 =114c, r10=80634a80, r11=80bc8d94
[   1.030] r12=92cf3988, ssp=80bc8d40, slr=804bc688, pc =80061fac

Stopped in pid 0.0 (system) at  netbsd:sunxi_sramc_attach+0x16c:ldr 
r2, [r2]


(gdb) list *(sunxi_sramc_attach+0x16c)
0x80061fac is in sunxi_sramc_attach 
(../../../../arch/arm/sunxi/sunxi_sramc.c:135).
130 if (dce != NULL) {
131 node = kmem_alloc(sizeof(*node), KM_SLEEP);
132 node->phandle = child;
133 node->area = dce->data;
134 TAILQ_INSERT_TAIL(>sc_nodes, node, nodes);
135 aprint_verbose_dev(sc->sc_dev, "area: %s\n",
136 node->area->desc);
137 }
138 }
139 }


With the change backed out it boots fine (dmesg below).

Martin

--8<--

Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
2018, 2019, 2020, 2021 The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.  All rights reserved.

NetBSD 9.99.78 (GENERIC) #117: Tue Jan 19 19:14:10 CET 2021

mar...@seven-days-to-the-wolves.aprisoft.de:/work/src/sys/arch/evbarm/compile/GENERIC
total memory = 2045 MB
avail memory = 1989 MB
entropy: no seed from bootloader
timecounter: Timecounters tick every 10.000 msec
Kernelized RAIDframe activated
armfdt0 (root)
simplebus0 at armfdt0: Cubietech Cubietruck
simplebus1 at simplebus0
cpus0 at simplebus0
simplebus2 at simplebus0
simplebus3 at simplebus0
cpu0 at cpus0: Cortex-A7 r0p4 (Cortex V7A core)
cpu0: DC enabled IC enabled WB enabled LABT branch prediction enabled
cpu0: 32KB/32B 2-way L1 VIPT Instruction cache
cpu0: 32KB/64B 4-way write-back-locking-C L1 PIPT Data cache
cpu0: 256KB/64B 8-way write-through L2 PIPT Unified cache
vfp0 at cpu0: NEON MPE (VFP 3.0+), rounding, NaN propagation, denormals
cpufreqdt0 at cpu0
cpu1 at cpus0
cpufreqdt1 at cpu1
gic0 at simplebus1: GIC
armgic0 at gic0: Generic Interrupt Controller, 160 sources (150 valid)
armgic0: 16 Priorities, 128 SPIs, 7 PPIs, 15 SGIs
fclock0 at simplebus2: 2500 Hz fixed clock (mii_phy_tx)
fclock1 at simplebus2: 12500 Hz fixed clock (gmac_int_tx)
fclock2 at simplebus2: 2400 Hz fixed clock (osc24M)
fclock3 at simplebus2: 32768 Hz fixed clock (osc32k)
gtmr0 at simplebus0: Generic Timer
gtmr0: interrupting on GIC irq 27
armgtmr0 at gtmr0: Generic Timer (24000 kHz, virtual)
timecounter: Timecounter "armgtmr0" frequency 2400 Hz quality 500
sun4ia10ccu0 at simplebus1: A20 CCU
sunxinmi0 at simplebus1: NMI
sunxigmacclk0 at simplebus2: GMAC MII/RGMII clock mux
sunxigpio0 at simplebus1: PIO
gpio0 at sunxigpio0: 175 pins
sunxigpio0: interrupting on GIC irq 60
sun4idma0 at simplebus1: DMA controller
sun4idma0: interrupting on GIC irq 59
sunxisramc0 at simplebus1: SRAM Controller
sunxisramc0: area: SRAM A3/A4
sunxisramc0: area: SRAM D
sunxidebe0 at simplebus1: Display Engine Backend (display-backend@1e6)

Re: CVS commit: src/sys/arch/arm/rockchip

2021-01-01 Thread Jared McNeill
Oops. The change was to make sure that a devicetree node with a 
"rockchip,grf" property on a device type that doesn't provide a config 
struct doesn't deref a NULL ptr.


On Fri, 1 Jan 2021, Jared D. McNeill wrote:


Module Name:src
Committed By:   jmcneill
Date:   Fri Jan  1 11:44:41 UTC 2021

Modified Files:
src/sys/arch/arm/rockchip: rk_i2s.c

Log Message:
rk_i2s.c


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

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




Re: CVS commit: src/sys/arch/arm/arm32

2020-11-21 Thread Rin Okuyama

Excellent! Thank you so much for finding out and fixing this!

Full ATF successfully completed for Raspberry Pi 2b, which formerly
crashed due to "anon != NULL && anon->an_ref != 0" panic.

Now, ATF is running on Cubietruck and Raspberry Pi Zero W.

Thanks,
rin

On 2020/11/22 4:44, Nick Hudson wrote:

Module Name:src
Committed By:   skrll
Date:   Sat Nov 21 19:44:52 UTC 2020

Modified Files:
src/sys/arch/arm/arm32: cpuswitch.S

Log Message:
Ensure that r5 contains curlwp before DO_AST_AND_RESTORE_ALIGNMENT_FAULTS
in lwp_trampoline as required by the move to make ASTs operate per-LWP
rather than per-CPU.

Thanks to martin@ for bisecting the amap corruption he was seeing and
testing this fix.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/arm/arm32/cpuswitch.S

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


Re: CVS commit: src/sys/arch/arm/arm

2020-11-11 Thread Rin Okuyama

On 2020/11/12 6:52, matthew green wrote:

"Rin Okuyama" writes:

Module Name:src
Committed By:   rin
Date:   Tue Nov 10 21:40:07 UTC 2020

Modified Files:
src/sys/arch/arm/arm: cpu_exec.c

Log Message:
Test (epp->ep_esch->es_emul != _netbsd) instead of


nice, this is a step forward.

an optimisation on it could be to remove this test entirely
if neither MODULAR or COMAPT_NETBSD32 are set, as it will
always be false there.


Ah, yes. I will commit after some test. Thanks!

rin


re: CVS commit: src/sys/arch/arm/arm

2020-11-11 Thread matthew green
"Rin Okuyama" writes:
> Module Name:  src
> Committed By: rin
> Date: Tue Nov 10 21:40:07 UTC 2020
>
> Modified Files:
>   src/sys/arch/arm/arm: cpu_exec.c
>
> Log Message:
> Test (epp->ep_esch->es_emul != _netbsd) instead of

nice, this is a step forward.

an optimisation on it could be to remove this test entirely
if neither MODULAR or COMAPT_NETBSD32 are set, as it will
always be false there.

thanks.


.mrg.


Re: CVS commit: src/sys/arch/arm/sociox

2020-03-20 Thread Jared McNeill

Great work! One small remark:

+static int
+ave_fdt_match(device_t parent, cfdata_t cf, void *aux)
+{
+   static const char * compatible[] = {
+#ifdef _LP64
+   "socionext,unifier-ld20-ave4",
+#else
+   "socionext,unifier-pro4-ave4",
+   "socionext,unifier-pxs2-ave4",
+   "socionext,unifier-ld11-ave4",
+   "socionext,unifier-pxs3-ave4",
+#endif
+   NULL
+   };

Please do not use #ifdef here. Compatible strings are meant to describe 
which hardware device the driver is compatible with, and can be shared 
across multiple SoCs. In the case of IP licensing, possibly not even in 
the same SoC family! Consider a hypothetical where Socionext could release 
a new 32-bit SoC with an ave(4) that is functionally identical to the one 
found in their previous 64-bit chip.


Re: CVS commit: src/sys/arch/arm/sociox

2020-03-18 Thread Jared McNeill

Hi --

Is there really a need for all of this fdt stuff for SCA2A11? I would 
expect that the board can be fully supported in ACPI mode.


Thanks,
Jared


On Wed, 18 Mar 2020, Tohru Nishimura wrote:


Module Name:src
Committed By:   nisimura
Date:   Wed Mar 18 08:49:51 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: files.sociox

Log Message:
add SynQuacer EXIU external IRQ unit driver desciption


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sociox/files.sociox

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




Re: CVS commit: src/sys/arch/arm/arm32

2020-02-22 Thread Nick Hudson

On 21/02/2020 23:27, Maya Rashish wrote:
[...]


Index: src/sys/arch/arm/arm32/bus_dma.c
diff -u src/sys/arch/arm/arm32/bus_dma.c:1.118 
src/sys/arch/arm/arm32/bus_dma.c:1.119
--- src/sys/arch/arm/arm32/bus_dma.c:1.118  Tue Nov  5 10:21:31 2019
+++ src/sys/arch/arm/arm32/bus_dma.cFri Feb 21 23:27:06 2020

[...]


@@ -404,7 +404,7 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
  #ifdef DEBUG_DMA
printf("dmamap_create:map=%p\n", map);
  #endif/* DEBUG_DMA */
-   return 0;
+   return error;
  }

  /*



This isn't correct for the case where _ARM32_NEED_BUS_DMA_BOUNCE isn't
defined.

I'll fix it.

Nick


Re: CVS commit: src/sys/arch/arm

2020-02-04 Thread Nick Hudson

On 05/02/2020 07:37, Nick Hudson wrote:

Module Name:src
Committed By:   skrll
Date:   Wed Feb  5 07:37:36 UTC 2020

Modified Files:
src/sys/arch/arm/arm: cpufunc.c
src/sys/arch/arm/arm32: armv7_generic_space.c pmap.c
src/sys/arch/arm/conf: Makefile.arm
src/sys/arch/arm/include/arm32: pmap.h

Log Message:
Fix the armv[67] memory attributes for uncached memory.  Previously it was
mapped as strongly-ordered which meant that unaligned accesses would fault.

armv7_generic_bs_map now maps pages with PMAP_DEV which is treated as SO

bus_dma continues to use PMAP_NOCACHE as appropriate, but this now get
mapped to the correct memory attribute bits for armv[67]

DEVMAP_ENTRY usees a new flag PTE_DEV.

The workaround for the unaligned access faults is now removed.

XXX Other armv[67] boards bus_space implementations should be checked.
XXX There is scope to reduce the difference to aarch64


I should have added...

Thanks to Rin Okuyama for doing a lot of testing of this.

Nick


Re: MAX_PAGE_SIZE for m68k (Re: CVS commit: src/sys/arch/arm/include/arm32)

2020-01-13 Thread Christos Zoulas
In article <20200113163830.e7a6317f...@rebar.astron.com>,
Christos Zoulas  wrote:
>| 
>| Probably this is the same reason of recent arm build failures:
>|  https://releng.netbsd.org/builds/HEAD/202001130720Z/
>|  https://releng.netbsd.org/builds/HEAD/202001130720Z/evbarm-earm.build.failed
>| ---
>| /tmp/genassym.Lq8h9d/assym.c:57:1: error: asm operand 0 probably
>doesn't match constraints [-Werror]
>|  __asm("XYZZY VM_MIN_ADDRESS %0" : : "n" (VM_MIN_ADDRESS));
>|  ^
>| /tmp/genassym.Lq8h9d/assym.c:58:1: error: asm operand 0 probably
>doesn't match constraints [-Werror]
>|  __asm("XYZZY VM_MAXUSER_ADDRESS %0" : : "n" (VM_MAXUSER_ADDRESS));
>|  ^
>| /tmp/genassym.Lq8h9d/assym.c:97:1: error: asm operand 0 probably
>doesn't match constraints [-Werror]
>|  __asm("XYZZY PAGE_MASK %0" : : "n" (PAGE_MASK));
>|  ^
>| /tmp/genassym.Lq8h9d/assym.c:98:1: error: asm operand 0 probably
>doesn't match constraints [-Werror]
>|  __asm("XYZZY PAGE_SIZE %0" : : "n" (PAGE_SIZE));
>|  ^
>| ---
>| 
>| Should we prepare independent constant for
>| "possible pagesize value among different MACHINE with the same MACHINE_ARCH"
>| for jemalloc(3)?
>
>Ouch, this hurts. Sure, perhaps MALLOC_PAGE_SIZE?

Talking to myself:

The arm PAGE_SIZE_{MIN,MAX} should go away after nick eliminates the
need for the 8K pages. This leaves us with m68k to deal with...
Do modules work on m68k? Should modules be shared between kernels with
different page sizes? Then perhaps we don't need a new constant?

christos



Re: MAX_PAGE_SIZE for m68k (Re: CVS commit: src/sys/arch/arm/include/arm32)

2020-01-13 Thread Jason Thorpe



> On Jan 13, 2020, at 8:15 AM, Izumi Tsutsui  wrote:
> 
> christos@ wrote:
> 
>>> Now I get the following erro during local tests of
>>> "build.sh -U -m hp300 release" on NetBSD/i386 9.0_RC1 host:
>>> 
>>> ---
>>> #create  compat_util/compat_exec.d
> :
>>> In file included from /s/cvs/src/sys/sys/param.h:149:0,
>>>from /s/cvs/src/sys/compat/common/compat_exec.c:41:
>>> ./m68k/pmap_motorola.h:165:5: error: operator '*' has no left operand
>>> #if PAGE_SIZE == 8192 /* NBPG / (SG4_LEV1SIZE * sizeof(st_entry_t)) */
>>>^
>>> nbmkdep: compile failed.
>>> *** [compat_exec.d] Error code 1
>> 
>> try cc -E?
> 
> It turns out the problem is more complicated.
> 
>  has the following definitions:
> 
> https://nxr.netbsd.org/xref/src/sys/uvm/uvm_param.h?r=1.38#135

I would suggest a possible workaround for this could be to define an additional:

#define __HAVE_FIXED_PAGE_SIZE

...at could also be tested here... the kernel truly does have a fixed page 
size, but userland not necessarily so.

> ---
>135  * If MIN_PAGE_SIZE and MAX_PAGE_SIZE are not equal, then we must use
>136  * non-constant PAGE_SIZE, et al for LKMs.
>137  */
>138 #if (MIN_PAGE_SIZE != MAX_PAGE_SIZE)
>139 #define__uvmexp_pagesize
>140 #if defined(_LKM) || defined(_MODULE)
>141 #undef PAGE_SIZE
>142 #undef PAGE_MASK
>143 #undef PAGE_SHIFT
>144 #endif
>145 #endif
>146 
>147 /*
>148  * Now provide PAGE_SIZE, PAGE_MASK, and PAGE_SHIFT if we do not
>149  * have ones that are compile-time constants.
>150  */
>151 #if !defined(PAGE_SIZE)
>152 extern const int *const uvmexp_pagesize;
>153 extern const int *const uvmexp_pagemask;
>154 extern const int *const uvmexp_pageshift;
>155 #definePAGE_SIZE   (*uvmexp_pagesize)  /* size of page 
> */
>156 #definePAGE_MASK   (*uvmexp_pagemask)  /* size of page 
> - 1 */
>157 #definePAGE_SHIFT  (*uvmexp_pageshift) /* bits to 
> shift for pages */
>158 #endif /* PAGE_SIZE */
> ---
> 
> I.e.  assumes PAGE_SIZE is not compile time constant
> for MODULEs if (MIN_PAGE_SIZE != MAX_PAGE_SIZE).
> 
> Probably this is the same reason of recent arm build failures:
> https://releng.netbsd.org/builds/HEAD/202001130720Z/
> https://releng.netbsd.org/builds/HEAD/202001130720Z/evbarm-earm.build.failed
> ---
> /tmp/genassym.Lq8h9d/assym.c:57:1: error: asm operand 0 probably doesn't 
> match constraints [-Werror]
> __asm("XYZZY VM_MIN_ADDRESS %0" : : "n" (VM_MIN_ADDRESS));
> ^
> /tmp/genassym.Lq8h9d/assym.c:58:1: error: asm operand 0 probably doesn't 
> match constraints [-Werror]
> __asm("XYZZY VM_MAXUSER_ADDRESS %0" : : "n" (VM_MAXUSER_ADDRESS));
> ^
> /tmp/genassym.Lq8h9d/assym.c:97:1: error: asm operand 0 probably doesn't 
> match constraints [-Werror]
> __asm("XYZZY PAGE_MASK %0" : : "n" (PAGE_MASK));
> ^
> /tmp/genassym.Lq8h9d/assym.c:98:1: error: asm operand 0 probably doesn't 
> match constraints [-Werror]
> __asm("XYZZY PAGE_SIZE %0" : : "n" (PAGE_SIZE));
> ^
> ---
> 
> Should we prepare independent constant for
> "possible pagesize value among different MACHINE with the same MACHINE_ARCH"
> for jemalloc(3)?
> 
> ---
> Izumi Tsutsui

-- thorpej



Re: MAX_PAGE_SIZE for m68k (Re: CVS commit: src/sys/arch/arm/include/arm32)

2020-01-13 Thread Christos Zoulas
On Jan 14,  1:15am, tsut...@ceres.dti.ne.jp (Izumi Tsutsui) wrote:
-- Subject: Re: MAX_PAGE_SIZE for m68k (Re: CVS commit: src/sys/arch/arm/incl

| christos@ wrote:
| 
| > >Now I get the following erro during local tests of
| > >"build.sh -U -m hp300 release" on NetBSD/i386 9.0_RC1 host:
| > >
| > >---
| > >#create  compat_util/compat_exec.d
|  :
| > >In file included from /s/cvs/src/sys/sys/param.h:149:0,
| > > from /s/cvs/src/sys/compat/common/compat_exec.c:41:
| > >./m68k/pmap_motorola.h:165:5: error: operator '*' has no left operand
| > > #if PAGE_SIZE == 8192 /* NBPG / (SG4_LEV1SIZE * sizeof(st_entry_t)) */
| > > ^
| > >nbmkdep: compile failed.
| > >*** [compat_exec.d] Error code 1
| > 
| > try cc -E?
| 
| It turns out the problem is more complicated.
| 
|  has the following definitions:
| 
| https://nxr.netbsd.org/xref/src/sys/uvm/uvm_param.h?r=1.38#135
| ---
| 135  * If MIN_PAGE_SIZE and MAX_PAGE_SIZE are not equal, then we must use
| 136  * non-constant PAGE_SIZE, et al for LKMs.
| 137  */
| 138 #if (MIN_PAGE_SIZE != MAX_PAGE_SIZE)
| 139 #define   __uvmexp_pagesize
| 140 #if defined(_LKM) || defined(_MODULE)
| 141 #undef PAGE_SIZE
| 142 #undef PAGE_MASK
| 143 #undef PAGE_SHIFT
| 144 #endif
| 145 #endif
| 146 
| 147 /*
| 148  * Now provide PAGE_SIZE, PAGE_MASK, and PAGE_SHIFT if we do not
| 149  * have ones that are compile-time constants.
| 150  */
| 151 #if !defined(PAGE_SIZE)
| 152 extern const int *const uvmexp_pagesize;
| 153 extern const int *const uvmexp_pagemask;
| 154 extern const int *const uvmexp_pageshift;
| 155 #define   PAGE_SIZE   (*uvmexp_pagesize)  /* size of page 
*/
| 156 #define   PAGE_MASK   (*uvmexp_pagemask)  /* size of page 
- 1 */
| 157 #define   PAGE_SHIFT  (*uvmexp_pageshift) /* bits to 
shift for pages */
| 158 #endif /* PAGE_SIZE */
| ---
| 
| I.e.  assumes PAGE_SIZE is not compile time constant
| for MODULEs if (MIN_PAGE_SIZE != MAX_PAGE_SIZE).
| 
| Probably this is the same reason of recent arm build failures:
|  https://releng.netbsd.org/builds/HEAD/202001130720Z/
|  https://releng.netbsd.org/builds/HEAD/202001130720Z/evbarm-earm.build.failed
| ---
| /tmp/genassym.Lq8h9d/assym.c:57:1: error: asm operand 0 probably doesn't 
match constraints [-Werror]
|  __asm("XYZZY VM_MIN_ADDRESS %0" : : "n" (VM_MIN_ADDRESS));
|  ^
| /tmp/genassym.Lq8h9d/assym.c:58:1: error: asm operand 0 probably doesn't 
match constraints [-Werror]
|  __asm("XYZZY VM_MAXUSER_ADDRESS %0" : : "n" (VM_MAXUSER_ADDRESS));
|  ^
| /tmp/genassym.Lq8h9d/assym.c:97:1: error: asm operand 0 probably doesn't 
match constraints [-Werror]
|  __asm("XYZZY PAGE_MASK %0" : : "n" (PAGE_MASK));
|  ^
| /tmp/genassym.Lq8h9d/assym.c:98:1: error: asm operand 0 probably doesn't 
match constraints [-Werror]
|  __asm("XYZZY PAGE_SIZE %0" : : "n" (PAGE_SIZE));
|  ^
| ---
| 
| Should we prepare independent constant for
| "possible pagesize value among different MACHINE with the same MACHINE_ARCH"
| for jemalloc(3)?

Ouch, this hurts. Sure, perhaps MALLOC_PAGE_SIZE?

christos


Re: MAX_PAGE_SIZE for m68k (Re: CVS commit: src/sys/arch/arm/include/arm32)

2020-01-13 Thread Izumi Tsutsui
christos@ wrote:

> >Now I get the following erro during local tests of
> >"build.sh -U -m hp300 release" on NetBSD/i386 9.0_RC1 host:
> >
> >---
> >#create  compat_util/compat_exec.d
 :
> >In file included from /s/cvs/src/sys/sys/param.h:149:0,
> > from /s/cvs/src/sys/compat/common/compat_exec.c:41:
> >./m68k/pmap_motorola.h:165:5: error: operator '*' has no left operand
> > #if PAGE_SIZE == 8192 /* NBPG / (SG4_LEV1SIZE * sizeof(st_entry_t)) */
> > ^
> >nbmkdep: compile failed.
> >*** [compat_exec.d] Error code 1
> 
> try cc -E?

It turns out the problem is more complicated.

 has the following definitions:

https://nxr.netbsd.org/xref/src/sys/uvm/uvm_param.h?r=1.38#135
---
135  * If MIN_PAGE_SIZE and MAX_PAGE_SIZE are not equal, then we must use
136  * non-constant PAGE_SIZE, et al for LKMs.
137  */
138 #if (MIN_PAGE_SIZE != MAX_PAGE_SIZE)
139 #define __uvmexp_pagesize
140 #if defined(_LKM) || defined(_MODULE)
141 #undef PAGE_SIZE
142 #undef PAGE_MASK
143 #undef PAGE_SHIFT
144 #endif
145 #endif
146 
147 /*
148  * Now provide PAGE_SIZE, PAGE_MASK, and PAGE_SHIFT if we do not
149  * have ones that are compile-time constants.
150  */
151 #if !defined(PAGE_SIZE)
152 extern const int *const uvmexp_pagesize;
153 extern const int *const uvmexp_pagemask;
154 extern const int *const uvmexp_pageshift;
155 #define PAGE_SIZE   (*uvmexp_pagesize)  /* size of page */
156 #define PAGE_MASK   (*uvmexp_pagemask)  /* size of page - 1 */
157 #define PAGE_SHIFT  (*uvmexp_pageshift) /* bits to shift for 
pages */
158 #endif /* PAGE_SIZE */
---

I.e.  assumes PAGE_SIZE is not compile time constant
for MODULEs if (MIN_PAGE_SIZE != MAX_PAGE_SIZE).

Probably this is the same reason of recent arm build failures:
 https://releng.netbsd.org/builds/HEAD/202001130720Z/
 https://releng.netbsd.org/builds/HEAD/202001130720Z/evbarm-earm.build.failed
---
/tmp/genassym.Lq8h9d/assym.c:57:1: error: asm operand 0 probably doesn't match 
constraints [-Werror]
 __asm("XYZZY VM_MIN_ADDRESS %0" : : "n" (VM_MIN_ADDRESS));
 ^
/tmp/genassym.Lq8h9d/assym.c:58:1: error: asm operand 0 probably doesn't match 
constraints [-Werror]
 __asm("XYZZY VM_MAXUSER_ADDRESS %0" : : "n" (VM_MAXUSER_ADDRESS));
 ^
/tmp/genassym.Lq8h9d/assym.c:97:1: error: asm operand 0 probably doesn't match 
constraints [-Werror]
 __asm("XYZZY PAGE_MASK %0" : : "n" (PAGE_MASK));
 ^
/tmp/genassym.Lq8h9d/assym.c:98:1: error: asm operand 0 probably doesn't match 
constraints [-Werror]
 __asm("XYZZY PAGE_SIZE %0" : : "n" (PAGE_SIZE));
 ^
---

Should we prepare independent constant for
"possible pagesize value among different MACHINE with the same MACHINE_ARCH"
for jemalloc(3)?

---
Izumi Tsutsui


Re: MAX_PAGE_SIZE for m68k (Re: CVS commit: src/sys/arch/arm/include/arm32)

2020-01-13 Thread Christos Zoulas
In article <200114002918.m0108...@mirage.ceres.dti.ne.jp>,
Izumi Tsutsui   wrote:
>christos@ wrote:
>
>> LGTM too.
>
>> >> thorpej@ wrote:
> :
>> >> How about the attached diff? (untested, just for review)
>> > 
>> > This looks good to me.
>
>Now I get the following erro during local tests of
>"build.sh -U -m hp300 release" on NetBSD/i386 9.0_RC1 host:
>
>---
>#create  compat_util/compat_exec.d
>CC=/s/cvs/src/obj.hp300/tooldir.NetBSD-9.0_RC1-i386/bin/m68k--netbsdelf-gcc
>/s/cvs/src/obj.hp300/tooldir.NetBSD-9.0_RC1-i386/bin/nbmkdep -f
>compat_exec.d.tmp  --   -std=gnu99   -I/s/cvs/src/common/include
>-DDIAGNOSTIC --sysroot=/s/cvs/src/obj.hp300/destdir.hp300
>-I/s/cvs/src/common/include -DDIAGNOSTIC -nostdinc -I.
>-I/s/cvs/src/sys/modules/compat_util -isystem /s/cvs/src/sys -isystem
>/s/cvs/src/sys/arch -isystem /s/cvs/src/sys/../common/include -D_KERNEL
>-D_LKM -D_MODULE -DSYSCTL_INCLUDE_DESCR
>/s/cvs/src/sys/compat/common/compat_exec.c &&  mv -f compat_exec.d.tmp
>compat_exec.d
>In file included from /s/cvs/src/sys/sys/param.h:149:0,
> from /s/cvs/src/sys/compat/common/compat_exec.c:41:
>./m68k/pmap_motorola.h:165:5: error: operator '*' has no left operand
> #if PAGE_SIZE == 8192 /* NBPG / (SG4_LEV1SIZE * sizeof(st_entry_t)) */
> ^
>nbmkdep: compile failed.
>*** [compat_exec.d] Error code 1
>
>---
>
>I'm not sure why my  change causes this error,
>but I also wonder if we should use "PGSHIFT == 13" rather than
>"PAGE_SIZE == 8192" in ..

try cc -E?

christos



MAX_PAGE_SIZE for m68k (Re: CVS commit: src/sys/arch/arm/include/arm32)

2020-01-13 Thread Izumi Tsutsui
christos@ wrote:

> LGTM too.

> >> thorpej@ wrote:
 :
> >> How about the attached diff? (untested, just for review)
> > 
> > This looks good to me.

Now I get the following erro during local tests of
"build.sh -U -m hp300 release" on NetBSD/i386 9.0_RC1 host:

---
#create  compat_util/compat_exec.d
CC=/s/cvs/src/obj.hp300/tooldir.NetBSD-9.0_RC1-i386/bin/m68k--netbsdelf-gcc 
/s/cvs/src/obj.hp300/tooldir.NetBSD-9.0_RC1-i386/bin/nbmkdep -f 
compat_exec.d.tmp  --   -std=gnu99   -I/s/cvs/src/common/include -DDIAGNOSTIC 
--sysroot=/s/cvs/src/obj.hp300/destdir.hp300 -I/s/cvs/src/common/include 
-DDIAGNOSTIC -nostdinc -I. -I/s/cvs/src/sys/modules/compat_util -isystem 
/s/cvs/src/sys -isystem /s/cvs/src/sys/arch -isystem 
/s/cvs/src/sys/../common/include -D_KERNEL -D_LKM -D_MODULE 
-DSYSCTL_INCLUDE_DESCR /s/cvs/src/sys/compat/common/compat_exec.c &&  mv -f 
compat_exec.d.tmp compat_exec.d
In file included from /s/cvs/src/sys/sys/param.h:149:0,
 from /s/cvs/src/sys/compat/common/compat_exec.c:41:
./m68k/pmap_motorola.h:165:5: error: operator '*' has no left operand
 #if PAGE_SIZE == 8192 /* NBPG / (SG4_LEV1SIZE * sizeof(st_entry_t)) */
 ^
nbmkdep: compile failed.
*** [compat_exec.d] Error code 1

---

I'm not sure why my  change causes this error,
but I also wonder if we should use "PGSHIFT == 13" rather than
"PAGE_SIZE == 8192" in ..

---
Izumi Tsutsui


Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-12 Thread Christos Zoulas
LGTM too.

christos

> On Jan 12, 2020, at 10:09 AM, Jason Thorpe  wrote:
> 
> 
> 
>> On Jan 11, 2020, at 10:47 PM, Izumi Tsutsui  wrote:
>> 
>> thorpej@ wrote:
>> 
 PGSHIFT is defined in  and
 PAGE_SHIFT and PAGE_SIZE is in ,
 but there is no common .
>>> 
>>> Make a common  that all of the platforms can #include, and 
>>> just put these common definitions in it (for now)?
>> 
>> How about the attached diff? (untested, just for review)
> 
> This looks good to me.
> 
> -- thorpej



signature.asc
Description: Message signed with OpenPGP


Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-12 Thread Jason Thorpe



> On Jan 11, 2020, at 10:47 PM, Izumi Tsutsui  wrote:
> 
> thorpej@ wrote:
> 
>>> PGSHIFT is defined in  and
>>> PAGE_SHIFT and PAGE_SIZE is in ,
>>> but there is no common .
>> 
>> Make a common  that all of the platforms can #include, and 
>> just put these common definitions in it (for now)?
> 
> How about the attached diff? (untested, just for review)

This looks good to me.

-- thorpej



Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-11 Thread Izumi Tsutsui
thorpej@ wrote:

> > PGSHIFT is defined in  and
> > PAGE_SHIFT and PAGE_SIZE is in ,
> > but there is no common .
> 
> Make a common  that all of the platforms can #include, and 
> just put these common definitions in it (for now)?

How about the attached diff? (untested, just for review)

- Only sun3 use immediate "13" (not PGSHIFT) for PG_SHIFT,
  but sun3/include/param.h also has "#define PGSHIFT 13".
- For now I'll leave evbcf as is. (I doubt its MACHINE_ARCH is m68k)

--- /dev/null   2020-01-12 15:11:38.258153018 +0900
+++ m68k/include/vmparam.h  2020-01-12 15:29:21.866107854 +0900
@@ -0,0 +1,65 @@
+/* $NetBSD$*/
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: Utah $Hdr: vmparam.h 1.16 91/01/18$
+ *
+ * @(#)vmparam.h   8.2 (Berkeley) 4/19/94
+ */
+
+#ifndef _M68K_VMPARAM_H_
+#define_M68K_VMPARAM_H_
+
+/*
+ * Common constants for m68k ports
+ */
+
+/*
+ * hp300 pmap derived m68k ports can use 4K or 8K pages.
+ * (except HPMMU machines)
+ * sun3 and sun3x use 8K pages.
+ * The page size is specified by PGSHIFT in .
+ * Override the PAGE_* definitions to be compile-time constants.
+ */
+#definePAGE_SHIFT  PGSHIFT
+#definePAGE_SIZE   (1 << PAGE_SHIFT)
+#definePAGE_MASK   (PAGE_SIZE - 1)
+
+/* Some implemantations like jemalloc(3) require physical page size details. */
+#defineMIN_PAGE_SHIFT  12
+#defineMAX_PAGE_SHIFT  13
+#defineMIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
+#defineMAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)
+
+#endif /* _M68K_VMPARAM_H_ */

Index: amiga/include/vmparam.h
===
RCS file: /cvsroot/src/sys/arch/amiga/include/vmparam.h,v
retrieving revision 1.47
diff -u -p -d -r1.47 vmparam.h
--- amiga/include/vmparam.h 27 Mar 2019 17:15:29 -  1.47
+++ amiga/include/vmparam.h 12 Jan 2020 06:29:56 -
@@ -46,12 +46,9 @@
  */
 
 /*
- * We use 8K pages on the Amiga.  Override the PAGE_* definitions
- * to be compie-time constants.
+ * Use common m68k definitions to define PAGE_SIZE and related constants.
  */
-#definePAGE_SHIFT  PGSHIFT
-#definePAGE_SIZE   (1 << PAGE_SHIFT)
-#definePAGE_MASK   (PAGE_SIZE - 1)
+#include 
 
 /*
  * USRSTACK is the top (end) of the user stack.
Index: atari/include/vmparam.h
===
RCS file: /cvsroot/src/sys/arch/atari/include/vmparam.h,v
retrieving revision 1.33
diff -u -p -d -r1.33 vmparam.h
--- atari/include/vmparam.h 27 Mar 2019 17:15:29 -  1.33
+++ atari/include/vmparam.h 12 Jan 2020 06:29:56 -
@@ -46,12 +46,9 @@
  */
 
 /*
- * We use 8K pages on the Atari.  Override the PAGE_* definitions
- * to be compile-time constants.
+ * Use common m68k definitions to define PAGE_SIZE and related constants.
  */
-#definePAGE_SHIFT  PGSHIFT
-#definePAGE_SIZE   (1 << PAGE_SHIFT)
-#definePAGE_MASK   (PAGE_SIZE - 1)
+#include 
 
 /*
  * USRSTACK is the top (end) of the user stack.
Index: cesfic/include/vmparam.h
===
RCS file: 

Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-11 Thread Jason Thorpe



> On Jan 11, 2020, at 8:32 PM, Izumi Tsutsui  wrote:
> 
> PGSHIFT is defined in  and
> PAGE_SHIFT and PAGE_SIZE is in ,
> but there is no common .

Make a common  that all of the platforms can #include, and just 
put these common definitions in it (for now)?

-- thorpej



Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-11 Thread Izumi Tsutsui
> >m68k also needs this? (currently no common  though)
> 
> Good catch. Yup, looks like it:
 :
> 
> #define   MIN_PAGE_SHIFT  11  /* sun2 */
> #define   MAX_PAGE_SHIFT  13  /* amiga,atari,sun3 */
> #define   MIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
> #define   MAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)

sun2 is different MACHINE_ARCH (m68000) from other m68k ports,
so MIN_PAGE_SHIFT should be 12.

> Should I take care of it or can you?

I just wonder which header file these definitions should be in.
Is  ok?

PGSHIFT is defined in  and
PAGE_SHIFT and PAGE_SIZE is in ,
but there is no common .

---
Izumi Tsutsui


Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-11 Thread Christos Zoulas
In article <200112121414.m0101...@mirage.ceres.dti.ne.jp>,
Izumi Tsutsui   wrote:
>> Module Name: src
>> Committed By:christos
>> Date:Sat Jan 11 19:06:35 UTC 2020
>> 
>> Modified Files:
>>  src/sys/arch/arm/include/arm32: vmparam.h
>> 
>> Log Message:
>> Define the min and max page size supported for the benefit of jemalloc
>> 
>> 
>> To generate a diff of this commit:
>> cvs rdiff -u -r1.45 -r1.46 src/sys/arch/arm/include/arm32/vmparam.h
>
>--- src/sys/arch/arm/include/arm32/vmparam.h:1.45  Wed Jun 19 09:54:42 2019
>+++ src/sys/arch/arm/include/arm32/vmparam.h   Sat Jan 11 19:06:34 2020
>@@ -84,6 +84,11 @@
> #define   PAGE_SIZE   (1 << PAGE_SHIFT)
> #define   PAGE_MASK   (PAGE_SIZE - 1)
> 
>+#define   MIN_PAGE_SHIFT  12  /* normal */
>+#define   MAX_PAGE_SHIFT  13  /* _ARM_ARCH_6 */
>+#define   MIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
>+#define   MAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)
>+
> /*
>  * Mach derived constants
>  */
>
>---
>
>m68k also needs this? (currently no common  though)

Good catch. Yup, looks like it:

$ fgrep PGSHIFT 
{amiga,atari,hp300,luna68k,mac68k,mvme68k,next68k,sun2,sun3,x68k}/
param.h
amiga/include/param.h:#define   PGSHIFT 13  /* LOG2(NBPG) */
atari/include/param.h:#define   PGSHIFT 13  /* LOG2(NBPG) */
hp300/include/param.h:#define   PGSHIFT 12  /* LOG2(NBPG) */
luna68k/include/param.h:#define PGSHIFT 12  /* LOG2(NBPG) */
mac68k/include/param.h:#define  PGSHIFT 12  /* LOG2(NBPG) */
mvme68k/include/param.h:#define PGSHIFT 12  /* LOG2(NBPG) */
next68k/include/param.h:#define PGSHIFT 12  /* LOG2(NBPG) */
sun2/include/param.h:#define PGSHIFT11  /* LOG2(NBPG) */
sun3/include/param.h:#definePGSHIFT 13  /* LOG2(NBPG) */
x68k/include/param.h:#definePGSHIFT 12  /* LOG2(NBPG) */

...

#define   MIN_PAGE_SHIFT  11  /* sun2 */
#define   MAX_PAGE_SHIFT  13  /* amiga,atari,sun3 */
#define   MIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
#define   MAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)

Should I take care of it or can you?

christos



Re: CVS commit: src/sys/arch/arm/include/arm32

2020-01-11 Thread Izumi Tsutsui
> Module Name:  src
> Committed By: christos
> Date: Sat Jan 11 19:06:35 UTC 2020
> 
> Modified Files:
>   src/sys/arch/arm/include/arm32: vmparam.h
> 
> Log Message:
> Define the min and max page size supported for the benefit of jemalloc
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.45 -r1.46 src/sys/arch/arm/include/arm32/vmparam.h

--- src/sys/arch/arm/include/arm32/vmparam.h:1.45   Wed Jun 19 09:54:42 2019
+++ src/sys/arch/arm/include/arm32/vmparam.hSat Jan 11 19:06:34 2020
@@ -84,6 +84,11 @@
 #definePAGE_SIZE   (1 << PAGE_SHIFT)
 #definePAGE_MASK   (PAGE_SIZE - 1)
 
+#defineMIN_PAGE_SHIFT  12  /* normal */
+#defineMAX_PAGE_SHIFT  13  /* _ARM_ARCH_6 */
+#defineMIN_PAGE_SIZE   (1 << MIN_PAGE_SHIFT)
+#defineMAX_PAGE_SIZE   (1 << MAX_PAGE_SHIFT)
+
 /*
  * Mach derived constants
  */

---

m68k also needs this? (currently no common  though)

---
Izumi Tsutsui


CVS commit: src/sys/arch/arm/ti

2019-11-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 29 20:54:00 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_wdt.c

Log Message:
Add TI OMAP watchdog timer driver.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_wdt.c

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



CVS commit: src/sys/arch/arm/ti

2019-11-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 29 20:54:00 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_wdt.c

Log Message:
Add TI OMAP watchdog timer driver.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_wdt.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/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.11 src/sys/arch/arm/ti/am3_prcm.c:1.12
--- src/sys/arch/arm/ti/am3_prcm.c:1.11	Wed Nov 27 23:02:54 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Fri Nov 29 20:54:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.12 2019/11/29 20:54:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.12 2019/11/29 20:54:00 jmcneill Exp $");
 
 #include 
 #include 
@@ -169,6 +169,8 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("timer6", 0xf0, "FIXED_24MHZ"),
 	AM3_PRCM_HWMOD_PER("timer7", 0x7c, "FIXED_24MHZ"),
 
+	AM3_PRCM_HWMOD_WKUP("wd_timer2", 0xd4, "FIXED_32K"),
+
 	AM3_PRCM_HWMOD_PER("mmc1", 0x3c, "MMC_CLK"),
 	AM3_PRCM_HWMOD_PER("mmc2", 0xf4, "MMC_CLK"),
 	AM3_PRCM_HWMOD_PER("mmc3", 0xf8, "MMC_CLK"),

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.20 src/sys/arch/arm/ti/files.ti:1.21
--- src/sys/arch/arm/ti/files.ti:1.20	Sun Nov  3 22:59:06 2019
+++ src/sys/arch/arm/ti/files.ti	Fri Nov 29 20:54:00 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.20 2019/11/03 22:59:06 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.21 2019/11/29 20:54:00 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_cpufreq.c	soc_ti
@@ -131,6 +131,11 @@ device	omapnand: nandbus
 attach	omapnand at fdt
 file	arch/arm/ti/omap2_nand.c	omapnand
 
+# Watchdog timer
+device	tiwdt: sysmon_wdog
+attach	tiwdt at fdt with ti_wdt
+file	arch/arm/ti/ti_wdt.c		ti_wdt
+
 # SOC parameters
 defflag	opt_soc.h			SOC_TI
 defflag	opt_soc.h			SOC_AM33XX: SOC_TI

Added files:

Index: src/sys/arch/arm/ti/ti_wdt.c
diff -u /dev/null src/sys/arch/arm/ti/ti_wdt.c:1.1
--- /dev/null	Fri Nov 29 20:54:00 2019
+++ src/sys/arch/arm/ti/ti_wdt.c	Fri Nov 29 20:54:00 2019
@@ -0,0 +1,259 @@
+/* $NetBSD: ti_wdt.c,v 1.1 2019/11/29 20:54:00 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2019 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: ti_wdt.c,v 1.1 2019/11/29 20:54:00 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+
+#define	WDT_WDSC		0x10
+#define	 WDSC_SOFTRESET		__BIT(1)
+#define	WDT_WDST		0x14
+#define	WDT_WISR		0x18
+#define	WDT_WIER		0x1c
+#define	WDT_WCLR		0x24
+#define	 WCLR_PRE		__BIT(5)
+#define	 WCLR_PTV		__BITS(4,2)
+#define	WDT_WCRR		0x28
+#define	WDT_WLDR		0x2c
+#define	WDT_WTGR		0x30
+#define	WDT_WWPS		0x34
+#define	 WWPS_W_PEND_WDLY	__BIT(5)
+#define	 WWPS_W_PEND_WSPR	__BIT(4)
+#define	 WWPS_W_PEND_WTGR	__BIT(3)
+#define	 WWPS_W_PEND_WLDR	__BIT(2)
+#define	 WWPS_W_PEND_WCRR	__BIT(1)
+#define	 WWPS_W_PEND_WCLR	__BIT(0)
+#define	 WWPS_W_PEND_MASK	__BITS(5,0)
+#define	WDT_WDLY		0x44
+#define	WDT_WSPR		0x48
+#define	WDT_WIRQSTATRAW		0x54
+#define	WDT_WIRQSTAT		0x58
+#define	WDT_WIRQENSET		0x5c
+#define	WDT_WIRQENCLR		0x60
+#define	 WIRQ_EVENT_DLY		__BIT(1)
+#define	 WIRQ_EVENT_OVF		__BIT(0)
+
+#define	

CVS commit: src/sys/arch/arm/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:19 UTC 2019

Modified Files:
src/sys/arch/arm/include: lock.h

Log Message:
Nix mb_* on arm.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/include/lock.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/arm/include/lock.h
diff -u src/sys/arch/arm/include/lock.h:1.33 src/sys/arch/arm/include/lock.h:1.34
--- src/sys/arch/arm/include/lock.h:1.33	Sun Sep 17 00:01:07 2017
+++ src/sys/arch/arm/include/lock.h	Fri Nov 29 20:05:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.33 2017/09/17 00:01:07 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.34 2019/11/29 20:05:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -66,11 +66,8 @@ __cpu_simple_lock_set(__cpu_simple_lock_
 }
 
 #ifdef _KERNEL
+/* XXX Formerly included for obsolete mb_* API, maybe no longer needed.  */
 #include 
-
-#define	mb_read		drain_writebuf		/* in cpufunc.h */
-#define	mb_write	drain_writebuf		/* in cpufunc.h */
-#define	mb_memory	drain_writebuf		/* in cpufunc.h */
 #endif
 
 #ifdef _ARM_ARCH_6



CVS commit: src/sys/arch/arm/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:19 UTC 2019

Modified Files:
src/sys/arch/arm/include: lock.h

Log Message:
Nix mb_* on arm.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/include/lock.h

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



CVS commit: src/sys/arch/arm/broadcom

2019-11-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Nov 29 17:44:27 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_intr.c

Log Message:
Account for the IRQ offset on the bcm2836.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/broadcom/bcm2835_intr.c

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



CVS commit: src/sys/arch/arm/broadcom

2019-11-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Nov 29 17:44:27 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_intr.c

Log Message:
Account for the IRQ offset on the bcm2836.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/broadcom/bcm2835_intr.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/arm/broadcom/bcm2835_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.26 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.27
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.26	Thu Nov 28 15:35:51 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Fri Nov 29 17:44:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.26 2019/11/28 15:35:51 thorpej Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.27 2019/11/29 17:44:27 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.26 2019/11/28 15:35:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.27 2019/11/29 17:44:27 thorpej Exp $");
 
 #define _INTR_PRIVATE
 
@@ -467,15 +467,16 @@ bcm2835_icu_fdt_establish(device_t dev, 
 	struct bcm2835icu_irq *firq;
 	struct bcm2835icu_irqhandler *firqh;
 	int iflags = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0;
-	int irq;
+	int irq, irqidx;
 
 	irq = bcm2835_icu_fdt_decode_irq(specifier);
 	if (irq == -1)
 		return NULL;
+	irqidx = irq - BCM2835_INT_BASE;
 
-	KASSERT(irq < BCM2835_NIRQ);
+	KASSERT(irqidx < BCM2835_NIRQ);
 
-	firq = sc->sc_irq[irq];
+	firq = sc->sc_irq[irqidx];
 	if (firq == NULL) {
 		firq = kmem_alloc(sizeof(*firq), KM_SLEEP);
 		firq->intr_sc = sc;
@@ -496,7 +497,7 @@ bcm2835_icu_fdt_establish(device_t dev, 
 			kmem_free(firq, sizeof(*firq));
 			return NULL;
 		}
-		sc->sc_irq[irq] = firq;
+		sc->sc_irq[irqidx] = firq;
 	} else {
 		if (firq->intr_arg == NULL || arg == NULL) {
 			device_printf(dev,
@@ -549,6 +550,7 @@ bcm2835_icu_fdt_disestablish(device_t de
 			continue;
 
 		KASSERT(firq->intr_refcnt > 0);
+		KASSERT(n == (firq->intr_irq - BCM2835_INT_BASE));
 
 		/* XXX see above */
 		if (firq->intr_refcnt > 1)
@@ -560,7 +562,7 @@ bcm2835_icu_fdt_disestablish(device_t de
 		TAILQ_REMOVE(>intr_handlers, firqh, ih_next);
 		kmem_free(firqh, sizeof(*firqh));
 
-		sc->sc_irq[firq->intr_irq] = NULL;
+		sc->sc_irq[n] = NULL;
 		kmem_free(firq, sizeof(*firq));
 
 		return;



CVS commit: src/sys/arch/arm/arm32

2019-11-29 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Nov 29 17:33:43 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: fault.c

Log Message:
if Thumb-32 bit instruction located on a page boundariy, also need to consider 
the pc + 2 address.

Fix PR/54720. more detail and PoC are descrived in the PR.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/arm/arm32/fault.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/arm/arm32/fault.c
diff -u src/sys/arch/arm/arm32/fault.c:1.108 src/sys/arch/arm/arm32/fault.c:1.109
--- src/sys/arch/arm/arm32/fault.c:1.108	Sat Apr  6 03:06:25 2019
+++ src/sys/arch/arm/arm32/fault.c	Fri Nov 29 17:33:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: fault.c,v 1.108 2019/04/06 03:06:25 thorpej Exp $	*/
+/*	$NetBSD: fault.c,v 1.109 2019/11/29 17:33:43 ryo Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -81,7 +81,7 @@
 #include "opt_kgdb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.108 2019/04/06 03:06:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.109 2019/11/29 17:33:43 ryo Exp $");
 
 #include 
 #include 
@@ -838,6 +838,9 @@ prefetch_abort_handler(trapframe_t *tf)
 	UVMHIST_LOG(maphist, " (pc=0x%jx, l=0x%#jx, tf=0x%#jx)",
 	fault_pc, (uintptr_t)l, (uintptr_t)tf, 0);
 
+#ifdef THUMB_CODE
+ recheck:
+#endif
 	/* Ok validate the address, can only execute in USER space */
 	if (__predict_false(fault_pc >= VM_MAXUSER_ADDRESS ||
 	(fault_pc < VM_MIN_ADDRESS && vector_page == ARM_VECTORS_LOW))) {
@@ -897,6 +900,18 @@ do_trapsignal:
 	call_trapsignal(l, tf, );
 
 out:
+
+#ifdef THUMB_CODE
+#define THUMB_32BIT(hi) (((hi) & 0xe000) == 0xe000 && ((hi) & 0x1800))
+	/* thumb-32 instruction was located on page boundary? */
+	if ((tf->tf_spsr & PSR_T_bit) &&
+	((fault_pc & PAGE_MASK) == (PAGE_SIZE - THUMB_INSN_SIZE)) &&
+	THUMB_32BIT(*(uint16_t *)tf->tf_pc)) {
+		fault_pc = tf->tf_pc + THUMB_INSN_SIZE;
+		goto recheck;
+	}
+#endif /* THUMB_CODE */
+
 	KASSERT(!TRAP_USERMODE(tf) || VALID_R15_PSR(tf->tf_pc, tf->tf_spsr));
 	userret(l);
 }



CVS commit: src/sys/arch/arm/arm32

2019-11-29 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Nov 29 17:33:43 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: fault.c

Log Message:
if Thumb-32 bit instruction located on a page boundariy, also need to consider 
the pc + 2 address.

Fix PR/54720. more detail and PoC are descrived in the PR.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/arm/arm32/fault.c

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



CVS commit: src/sys/arch/arm/imx

2019-11-29 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Nov 29 17:20:30 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet.c

Log Message:
set the multicast filter properly.

don't always IFF_ALLMULTI if multicast is configured.
fix the handling of GAUR and GALR.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/imx/if_enet.c

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



CVS commit: src/sys/arch/arm/imx

2019-11-29 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Nov 29 17:20:30 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet.c

Log Message:
set the multicast filter properly.

don't always IFF_ALLMULTI if multicast is configured.
fix the handling of GAUR and GALR.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/imx/if_enet.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/arm/imx/if_enet.c
diff -u src/sys/arch/arm/imx/if_enet.c:1.28 src/sys/arch/arm/imx/if_enet.c:1.29
--- src/sys/arch/arm/imx/if_enet.c:1.28	Tue Nov 12 05:09:29 2019
+++ src/sys/arch/arm/imx/if_enet.c	Fri Nov 29 17:20:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet.c,v 1.28 2019/11/12 05:09:29 hkenken Exp $	*/
+/*	$NetBSD: if_enet.c,v 1.29 2019/11/29 17:20:30 ryo Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.28 2019/11/12 05:09:29 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.29 2019/11/29 17:20:30 ryo Exp $");
 
 #include "vlan.h"
 
@@ -714,15 +714,14 @@ enet_setmulti(struct enet_softc *sc)
 	struct ifnet *ifp = >ec_if;
 	struct ether_multi *enm;
 	struct ether_multistep step;
-	int promisc;
-	uint32_t crc;
+	uint32_t crc, hashidx;
 	uint32_t gaddr[2];
 
-	promisc = 0;
-	if ((ifp->if_flags & IFF_PROMISC) || ec->ec_multicnt > 0) {
-		ifp->if_flags |= IFF_ALLMULTI;
-		if (ifp->if_flags & IFF_PROMISC)
-			promisc = 1;
+	if (ifp->if_flags & IFF_PROMISC) {
+		/* receive all unicast packet */
+		ENET_REG_WRITE(sc, ENET_IAUR, 0x);
+		ENET_REG_WRITE(sc, ENET_IALR, 0x);
+		/* receive all multicast packet */
 		gaddr[0] = gaddr[1] = 0x;
 	} else {
 		gaddr[0] = gaddr[1] = 0;
@@ -730,25 +729,38 @@ enet_setmulti(struct enet_softc *sc)
 		ETHER_LOCK(ec);
 		ETHER_FIRST_MULTI(step, ec, enm);
 		while (enm != NULL) {
+			if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
+			ETHER_ADDR_LEN)) {
+/*
+ * if specified by range, give up setting hash,
+ * and fallback to allmulti.
+ */
+gaddr[0] = gaddr[1] = 0x;
+break;
+			}
+
 			crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
-			gaddr[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+			hashidx = __SHIFTOUT(crc, __BITS(30,26));
+			gaddr[__SHIFTOUT(crc, __BIT(31))] |= __BIT(hashidx);
+
 			ETHER_NEXT_MULTI(step, enm);
 		}
 		ETHER_UNLOCK(ec);
-	}
-
-	ENET_REG_WRITE(sc, ENET_GAUR, gaddr[0]);
-	ENET_REG_WRITE(sc, ENET_GALR, gaddr[1]);
 
-	if (promisc) {
-		/* match all packet */
-		ENET_REG_WRITE(sc, ENET_IAUR, 0x);
-		ENET_REG_WRITE(sc, ENET_IALR, 0x);
-	} else {
-		/* don't match any packet */
+		/* dont't receive any unicast packet (except own address) */
 		ENET_REG_WRITE(sc, ENET_IAUR, 0);
 		ENET_REG_WRITE(sc, ENET_IALR, 0);
 	}
+
+	if (gaddr[0] == 0x && gaddr[1] == 0x)
+		ifp->if_flags |= IFF_ALLMULTI;
+	else
+		ifp->if_flags &= ~IFF_ALLMULTI;
+
+	/* receive multicast packets according to multicast filter */
+	ENET_REG_WRITE(sc, ENET_GAUR, gaddr[1]);
+	ENET_REG_WRITE(sc, ENET_GALR, gaddr[0]);
+
 }
 
 static void



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:24:22 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
add RK3399 DisplayPort clocks


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/rockchip/rk3399_cru.c

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



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:24:22 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
add RK3399 DisplayPort clocks


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/rockchip/rk3399_cru.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/arm/rockchip/rk3399_cru.c
diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.15 src/sys/arch/arm/rockchip/rk3399_cru.c:1.16
--- src/sys/arch/arm/rockchip/rk3399_cru.c:1.15	Fri Nov 29 15:20:28 2019
+++ src/sys/arch/arm/rockchip/rk3399_cru.c	Fri Nov 29 15:24:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_cru.c,v 1.15 2019/11/29 15:20:28 jakllsch Exp $ */
+/* $NetBSD: rk3399_cru.c,v 1.16 2019/11/29 15:24:21 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.15 2019/11/29 15:20:28 jakllsch Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.16 2019/11/29 15:24:21 jakllsch Exp $");
 
 #include 
 #include 
@@ -353,6 +353,7 @@ static const char * mux_pll_src_cpll_gpl
 static const char * mux_pll_src_cpll_gpll_upll_parents[] = { "cpll", "gpll", "upll" };
 static const char * mux_pll_src_cpll_gpll_npll_24m_parents[] = { "cpll", "gpll", "npll", "xin24m" };
 static const char * mux_pll_src_cpll_gpll_npll_ppll_upll_24m_parents[] = { "cpll", "gpll", "npll", "ppll", "upll", "xin24m" };
+static const char * mux_pll_src_npll_cpll_gpll_parents[] = { "npll", "cpll", "gpll" };
 static const char * mux_pll_src_vpll_cpll_gpll_parents[] = { "vpll", "cpll", "gpll" };
 static const char * mux_pll_src_vpll_cpll_gpll_npll_parents[] = { "vpll", "cpll", "gpll", "npll" };
 static const char * mux_aclk_perilp0_parents[] = { "cpll_aclk_perilp0_src", "gpll_aclk_perilp0_src" };
@@ -1005,6 +1006,15 @@ static struct rk_cru_clk rk3399_cru_clks
 	RK_GATE(RK3399_PCLK_EDP_NOC, "pclk_edp_noc", "pclk_edp", CLKGATE_CON(32), 12),
 	RK_GATE(RK3399_PCLK_EDP_CTRL, "pclk_edp_ctrl", "pclk_edp", CLKGATE_CON(32), 13),
 
+	RK_COMPOSITE(RK3399_SCLK_DP_CORE, "clk_dp_core", mux_pll_src_npll_cpll_gpll_parents,
+		 CLKSEL_CON(46),	/* muxdiv_reg */
+		 __BITS(7,6),	/* mux_mask */
+		 __BITS(4,0),	/* div_mask */
+		 CLKGATE_CON(11),	/* gate_reg */
+		 __BIT(8),		/* gate_mask */
+		 0),
+	RK_GATE(RK3399_PCLK_DP_CTRL, "pclk_dp_ctrl", "pclk_hdcp", CLKGATE_CON(29), 7),
+
 };
 
 static const struct rk3399_init_param {



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:20:28 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
add RK3399 eDP clocks


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/rockchip/rk3399_cru.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/arm/rockchip/rk3399_cru.c
diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.14 src/sys/arch/arm/rockchip/rk3399_cru.c:1.15
--- src/sys/arch/arm/rockchip/rk3399_cru.c:1.14	Fri Nov 29 15:00:20 2019
+++ src/sys/arch/arm/rockchip/rk3399_cru.c	Fri Nov 29 15:20:28 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_cru.c,v 1.14 2019/11/29 15:00:20 jakllsch Exp $ */
+/* $NetBSD: rk3399_cru.c,v 1.15 2019/11/29 15:20:28 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.14 2019/11/29 15:00:20 jakllsch Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.15 2019/11/29 15:20:28 jakllsch Exp $");
 
 #include 
 #include 
@@ -993,6 +993,18 @@ static struct rk_cru_clk rk3399_cru_clks
 		 CLKGATE_CON(8),	/* gate_reg */
 		 __BIT(12),		/* gate_mask */
 		 RK_COMPOSITE_SET_RATE_PARENT),
+
+	/* eDP */
+	RK_COMPOSITE(RK3399_PCLK_EDP, "pclk_edp", mux_pll_src_cpll_gpll_parents,
+		 CLKSEL_CON(44),	/* muxdiv_reg */
+		 __BIT(15),		/* mux_mask */
+		 __BITS(13,8),	/* div_mask */
+		 CLKGATE_CON(11),	/* gate_reg */
+		 __BIT(11),		/* gate_mask */
+		 0),
+	RK_GATE(RK3399_PCLK_EDP_NOC, "pclk_edp_noc", "pclk_edp", CLKGATE_CON(32), 12),
+	RK_GATE(RK3399_PCLK_EDP_CTRL, "pclk_edp_ctrl", "pclk_edp", CLKGATE_CON(32), 13),
+
 };
 
 static const struct rk3399_init_param {



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:20:28 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
add RK3399 eDP clocks


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/rockchip/rk3399_cru.c

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



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:00:20 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
fix copy/paste error in mux_pll_src_cpll_gpll_ppll_parents[]


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/rockchip/rk3399_cru.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/arm/rockchip/rk3399_cru.c
diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.13 src/sys/arch/arm/rockchip/rk3399_cru.c:1.14
--- src/sys/arch/arm/rockchip/rk3399_cru.c:1.13	Sat Nov 16 13:23:13 2019
+++ src/sys/arch/arm/rockchip/rk3399_cru.c	Fri Nov 29 15:00:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_cru.c,v 1.13 2019/11/16 13:23:13 jmcneill Exp $ */
+/* $NetBSD: rk3399_cru.c,v 1.14 2019/11/29 15:00:20 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.13 2019/11/16 13:23:13 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.14 2019/11/29 15:00:20 jakllsch Exp $");
 
 #include 
 #include 
@@ -349,7 +349,7 @@ static const char * armclkb_parents[] = 
 static const char * mux_clk_tsadc_parents[] = { "xin24m", "xin32k" };
 static const char * mux_pll_src_cpll_gpll_parents[] = { "cpll", "gpll" };
 static const char * mux_pll_src_cpll_gpll_npll_parents[] = { "cpll", "gpll", "npll" };
-static const char * mux_pll_src_cpll_gpll_ppll_parents[] = { "cpll", "gpll", "npll" };
+static const char * mux_pll_src_cpll_gpll_ppll_parents[] = { "cpll", "gpll", "ppll" };
 static const char * mux_pll_src_cpll_gpll_upll_parents[] = { "cpll", "gpll", "upll" };
 static const char * mux_pll_src_cpll_gpll_npll_24m_parents[] = { "cpll", "gpll", "npll", "xin24m" };
 static const char * mux_pll_src_cpll_gpll_npll_ppll_upll_24m_parents[] = { "cpll", "gpll", "npll", "ppll", "upll", "xin24m" };



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:00:20 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
fix copy/paste error in mux_pll_src_cpll_gpll_ppll_parents[]


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/rockchip/rk3399_cru.c

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



Re: CVS commit: src/sys/arch/arm/broadcom

2019-11-28 Thread Jared McNeill
On Nov 27, 2019, at 9:08 PM, Jason R Thorpe wrote:
> 
> + firqh = kmem_alloc(sizeof(*firqh), KM_SLEEP);
> + firqh->ih_irq = firq;
> + firqh->ih_fn = func;
> + firqh->ih_arg = arg;
> + TAILQ_INSERT_TAIL(>intr_handlers, firqh, ih_next);
> +
> + return firqh;

I should have commented the code in gicv3 so that you would have realized it 
was “unnecessarily complicated” for a reason :)

The interrupt_distribute(9) API makes an assumption that the return value of 
anything_intr_establish can be used as input for the MD interrupt_distribute 
implementation. For arm pic, struct intrsource * made most sense. It is a bit 
of a hassle for fdtbus and really shows the need for an MI interrupt API.

So where this breaks things is if you have something in the kernel do:

  Ih = fdtbus_intr_establish(…)
  interrupt_distribute(ih, target, NULL)

Currently the only place where this can happen is arch/arm/fdt/pmu_fdt.c but 
IMHO the code is perfectly valid and could appear in other places in the future.

CVS commit: src/sys/arch/arm/rockchip

2019-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 29 00:36:22 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_pcie.c

Log Message:
Do not crash if the optional vpcie3v3-supply property is missing or the
regulator can not be found.


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

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



CVS commit: src/sys/arch/arm/rockchip

2019-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 29 00:36:22 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_pcie.c

Log Message:
Do not crash if the optional vpcie3v3-supply property is missing or the
regulator can not be found.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/rockchip/rk3399_pcie.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/arm/rockchip/rk3399_pcie.c
diff -u src/sys/arch/arm/rockchip/rk3399_pcie.c:1.6 src/sys/arch/arm/rockchip/rk3399_pcie.c:1.7
--- src/sys/arch/arm/rockchip/rk3399_pcie.c:1.6	Sun Jun 23 16:15:43 2019
+++ src/sys/arch/arm/rockchip/rk3399_pcie.c	Fri Nov 29 00:36:22 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_pcie.c,v 1.6 2019/06/23 16:15:43 jmcneill Exp $ */
+/* $NetBSD: rk3399_pcie.c,v 1.7 2019/11/29 00:36:22 jmcneill Exp $ */
 /*
  * Copyright (c) 2018 Mark Kettenis 
  *
@@ -17,7 +17,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_pcie.c,v 1.6 2019/06/23 16:15:43 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_pcie.c,v 1.7 2019/11/29 00:36:22 jmcneill Exp $");
 
 #include 
 #include 
@@ -241,8 +241,10 @@ rkpcie_attach(device_t parent, device_t 
 
 	struct fdtbus_regulator *regulator;
 	regulator = fdtbus_regulator_acquire(phandle, "vpcie3v3-supply");
-	fdtbus_regulator_enable(regulator);
-	fdtbus_regulator_release(regulator);
+	if (regulator != NULL) {
+		fdtbus_regulator_enable(regulator);
+		fdtbus_regulator_release(regulator);
+	}
 		
 	fdtbus_clock_assign(phandle);
 	clock_enable_all(phandle);



CVS commit: src/sys/arch/arm/ti

2019-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Nov 28 23:57:09 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_sdhc.c

Log Message:
Support 1-bit mode and force all xfers to bounce to workaround a transfer error 
issue for now


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/ti_sdhc.c

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



CVS commit: src/sys/arch/arm/ti

2019-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Nov 28 23:57:09 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_sdhc.c

Log Message:
Support 1-bit mode and force all xfers to bounce to workaround a transfer error 
issue for now


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/ti_sdhc.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/arm/ti/ti_sdhc.c
diff -u src/sys/arch/arm/ti/ti_sdhc.c:1.4 src/sys/arch/arm/ti/ti_sdhc.c:1.5
--- src/sys/arch/arm/ti/ti_sdhc.c:1.4	Wed Nov 27 23:03:24 2019
+++ src/sys/arch/arm/ti/ti_sdhc.c	Thu Nov 28 23:57:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $	*/
+/*	$NetBSD: ti_sdhc.c,v 1.5 2019/11/28 23:57:09 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.5 2019/11/28 23:57:09 jmcneill Exp $");
 
 #include 
 #include 
@@ -428,15 +428,21 @@ static int
 ti_sdhc_bus_width(struct sdhc_softc *sc, int width)
 {
 	struct ti_sdhc_softc *hmsc = (struct ti_sdhc_softc *)sc;
-	uint32_t con;
+	uint32_t con, hctl;
 
 	con = bus_space_read_4(hmsc->sc_bst, hmsc->sc_bsh, MMCHS_CON);
+	hctl = SDHC_READ(hmsc, SDHC_HOST_CTL);
 	if (width == 8) {
 		con |= CON_DW8;
+	} else if (width == 4) {
+		con &= ~CON_DW8;
+		hctl |= SDHC_4BIT_MODE;
 	} else {
 		con &= ~CON_DW8;
+		hctl &= ~SDHC_4BIT_MODE;
 	}
 	bus_space_write_4(hmsc->sc_bst, hmsc->sc_bsh, MMCHS_CON, con);
+	SDHC_WRITE(hmsc, SDHC_HOST_CTL, hctl);
 
 	return 0;
 }
@@ -487,6 +493,13 @@ ti_sdhc_edma_init(struct ti_sdhc_softc *
 		error);
 		return error;
 	}
+	error = bus_dmamap_load(sc->sc.sc_dmat, sc->sc_edma_dmamap,
+	sc->sc_edma_bbuf, MAXPHYS, NULL, BUS_DMA_WAITOK);
+	if (error) {
+		device_printf(sc->sc.sc_dev, "couldn't load dmamap: %d\n",
+		error);
+		return error;
+	}
 
 	return error;
 }
@@ -496,24 +509,23 @@ ti_sdhc_edma_xfer_data(struct sdhc_softc
 {
 	struct ti_sdhc_softc *sc = device_private(sdhc_sc->sc_dev);
 	const bus_dmamap_t map = cmd->c_dmamap;
-	int seg, error;
 	bool bounce;
+	int error;
 
-	for (bounce = false, seg = 0; seg < cmd->c_dmamap->dm_nsegs; seg++) {
-		if ((cmd->c_dmamap->dm_segs[seg].ds_addr & 0x1f) != 0) {
+#if notyet
+	bounce = false;
+	for (int seg = 0; seg < cmd->c_dmamap->dm_nsegs; seg++) {
+		if ((cmd->c_dmamap->dm_segs[seg].ds_addr & 0x1f) != 0 ||
+		(cmd->c_dmamap->dm_segs[seg].ds_len & 3) != 0) {
 			bounce = true;
 			break;
 		}
 	}
+#else
+	bounce = true;
+#endif
 
 	if (bounce) {
-		error = bus_dmamap_load(sc->sc.sc_dmat, sc->sc_edma_dmamap,
-		sc->sc_edma_bbuf, MAXPHYS, NULL, BUS_DMA_WAITOK);
-		if (error) {
-			device_printf(sc->sc.sc_dev,
-			"[bounce] bus_dmamap_load failed: %d\n", error);
-			return error;
-		}
 		if (ISSET(cmd->c_flags, SCF_CMD_READ)) {
 			bus_dmamap_sync(sc->sc.sc_dmat, sc->sc_edma_dmamap, 0,
 			MAXPHYS, BUS_DMASYNC_PREREAD);
@@ -536,7 +548,6 @@ ti_sdhc_edma_xfer_data(struct sdhc_softc
 			bus_dmamap_sync(sc->sc.sc_dmat, sc->sc_edma_dmamap, 0,
 			MAXPHYS, BUS_DMASYNC_POSTWRITE);
 		}
-		bus_dmamap_unload(sc->sc.sc_dmat, sc->sc_edma_dmamap);
 		if (ISSET(cmd->c_flags, SCF_CMD_READ) && error == 0) {
 			memcpy(cmd->c_data, sc->sc_edma_bbuf, cmd->c_datalen);
 		}



CVS commit: src/sys/arch/arm/broadcom

2019-11-28 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Nov 28 15:35:51 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_intr.c

Log Message:
Jared points out that interrupt_distribute(9) assumes that any interrupt
handle can be used as an input to the MD interrupt_distribute implementation
so we are forced to return the handle we got back from intr_establish().
Upshot is that the input to bcm2835_icu_fdt_disestablish() is ambiguous for
shared IRQs, rendering them un-disestablishable.

While here, make sure to actually bump the intr_refcnt, and add an
assertion on the value we get back from bcm2835_icu_fdt_decode_irq().


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/broadcom/bcm2835_intr.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/arm/broadcom/bcm2835_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.25 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.26
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.25	Thu Nov 28 01:08:06 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Thu Nov 28 15:35:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.25 2019/11/28 01:08:06 thorpej Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.26 2019/11/28 15:35:51 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.25 2019/11/28 01:08:06 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.26 2019/11/28 15:35:51 thorpej Exp $");
 
 #define _INTR_PRIVATE
 
@@ -473,6 +473,8 @@ bcm2835_icu_fdt_establish(device_t dev, 
 	if (irq == -1)
 		return NULL;
 
+	KASSERT(irq < BCM2835_NIRQ);
+
 	firq = sc->sc_irq[irq];
 	if (firq == NULL) {
 		firq = kmem_alloc(sizeof(*firq), KM_SLEEP);
@@ -517,31 +519,54 @@ bcm2835_icu_fdt_establish(device_t dev, 
 	firqh->ih_irq = firq;
 	firqh->ih_fn = func;
 	firqh->ih_arg = arg;
+
+	firq->intr_refcnt++;
 	TAILQ_INSERT_TAIL(>intr_handlers, firqh, ih_next);
 
-	return firqh;
+	/*
+	 * XXX interrupt_distribute(9) assumes that any interrupt
+	 * handle can be used as an input to the MD interrupt_distribute
+	 * implementationm, so we are forced to return the handle
+	 * we got back from intr_establish().  Upshot is that the
+	 * input to bcm2835_icu_fdt_disestablish() is ambiguous for
+	 * shared IRQs, rendering them un-disestablishable.
+	 */
+
+	return firq->intr_ih;
 }
 
 static void
 bcm2835_icu_fdt_disestablish(device_t dev, void *ih)
 {
 	struct bcm2835icu_softc * const sc = device_private(dev);
-	struct bcm2835icu_irqhandler *firqh = ih;
-	struct bcm2835icu_irq *firq = firqh->ih_irq;
+	struct bcm2835icu_irqhandler *firqh;
+	struct bcm2835icu_irq *firq;
+	u_int n;
 
-	KASSERT(firq->intr_refcnt > 0);
+	for (n = 0; n < BCM2835_NIRQ; n++) {
+		firq = sc->sc_irq[n];
+		if (firq == NULL || firq->intr_ih != ih)
+			continue;
+
+		KASSERT(firq->intr_refcnt > 0);
+
+		/* XXX see above */
+		if (firq->intr_refcnt > 1)
+			panic("%s: cannot disestablish shared irq", __func__);
 
-	/* XXX */
-	if (firq->intr_refcnt > 1)
-		panic("%s: cannot disestablish shared irq", __func__);
+		intr_disestablish(firq->intr_ih);
 
-	intr_disestablish(firq->intr_ih);
+		firqh = TAILQ_FIRST(>intr_handlers);
+		TAILQ_REMOVE(>intr_handlers, firqh, ih_next);
+		kmem_free(firqh, sizeof(*firqh));
 
-	TAILQ_REMOVE(>intr_handlers, firqh, ih_next);
-	kmem_free(firqh, sizeof(*firqh));
+		sc->sc_irq[firq->intr_irq] = NULL;
+		kmem_free(firq, sizeof(*firq));
+
+		return;
+	}
 
-	sc->sc_irq[firq->intr_irq] = NULL;
-	kmem_free(firq, sizeof(*firq));
+	panic("%s: interrupt not established", __func__);
 }
 
 static int



CVS commit: src/sys/arch/arm/broadcom

2019-11-28 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Nov 28 15:35:51 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_intr.c

Log Message:
Jared points out that interrupt_distribute(9) assumes that any interrupt
handle can be used as an input to the MD interrupt_distribute implementation
so we are forced to return the handle we got back from intr_establish().
Upshot is that the input to bcm2835_icu_fdt_disestablish() is ambiguous for
shared IRQs, rendering them un-disestablishable.

While here, make sure to actually bump the intr_refcnt, and add an
assertion on the value we get back from bcm2835_icu_fdt_decode_irq().


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/broadcom/bcm2835_intr.c

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



Re: CVS commit: src/sys/arch/arm/broadcom

2019-11-28 Thread Jason Thorpe


> On Nov 28, 2019, at 2:21 AM, Jared McNeill  wrote:
> 
> I should have commented the code in gicv3 so that you would have realized it 
> was “unnecessarily complicated” for a reason :)

Ok, I'll fix and add a comment.

> 
> The interrupt_distribute(9) API makes an assumption that the return value of 
> anything_intr_establish can be used as input for the MD interrupt_distribute 
> implementation. For arm pic, struct intrsource * made most sense. It is a bit 
> of a hassle for fdtbus and really shows the need for an MI interrupt API.
> 
> So where this breaks things is if you have something in the kernel do:
> 
>   Ih = fdtbus_intr_establish(…)
>   interrupt_distribute(ih, target, NULL)
> 
> Currently the only place where this can happen is arch/arm/fdt/pmu_fdt.c but 
> IMHO the code is perfectly valid and could appear in other places in the 
> future.

-- thorpej



CVS commit: src/sys/arch/arm/imx/fdt

2019-11-28 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Nov 28 14:13:37 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_com.c

Log Message:
Remove FDT_INTR_MPSAFE flag.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_com.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/arm/imx/fdt/imx6_com.c
diff -u src/sys/arch/arm/imx/fdt/imx6_com.c:1.1 src/sys/arch/arm/imx/fdt/imx6_com.c:1.2
--- src/sys/arch/arm/imx/fdt/imx6_com.c:1.1	Wed Jul 24 13:12:33 2019
+++ src/sys/arch/arm/imx/fdt/imx6_com.c	Thu Nov 28 14:13:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_com.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $	*/
+/*	$NetBSD: imx6_com.c,v 1.2 2019/11/28 14:13:37 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_com.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_com.c,v 1.2 2019/11/28 14:13:37 hkenken Exp $");
 
 #include "opt_fdt.h"
 #include "opt_imxuart.h"
@@ -99,9 +99,11 @@ imx6_com_attach(device_t parent, device_
 	}
 
 	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_SERIAL,
-	FDT_INTR_MPSAFE, imxuintr, sc);
-	if (sc->sc_ih == NULL)
+	0, imxuintr, sc);
+	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt\n");
+		return;
+	}
 
 	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 



CVS commit: src/sys/arch/arm/imx/fdt

2019-11-28 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Nov 28 14:13:37 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_com.c

Log Message:
Remove FDT_INTR_MPSAFE flag.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_com.c

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



CVS commit: src/sys/arch/arm/broadcom

2019-11-27 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Nov 28 01:08:06 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_intr.c

Log Message:
There are some devices on the bcm283x that share IRQs (notably, the i2c
controllers), but the generic ARM PIC code doesn't support this.  Add a
workaround inspired by the GICv3 driver (thanks Jared for pointint it out).


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/broadcom/bcm2835_intr.c

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



CVS commit: src/sys/arch/arm/broadcom

2019-11-27 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Nov 28 01:08:06 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_intr.c

Log Message:
There are some devices on the bcm283x that share IRQs (notably, the i2c
controllers), but the generic ARM PIC code doesn't support this.  Add a
workaround inspired by the GICv3 driver (thanks Jared for pointint it out).


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/broadcom/bcm2835_intr.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/arm/broadcom/bcm2835_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.24 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.25
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.24	Wed Sep 25 16:57:10 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Thu Nov 28 01:08:06 2019
@@ -1,7 +1,7 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.24 2019/09/25 16:57:10 skrll Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.25 2019/11/28 01:08:06 thorpej Exp $	*/
 
 /*-
- * Copyright (c) 2012, 2015 The NetBSD Foundation, Inc.
+ * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.24 2019/09/25 16:57:10 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.25 2019/11/28 01:08:06 thorpej Exp $");
 
 #define _INTR_PRIVATE
 
@@ -87,6 +87,8 @@ static void *bcm2835_icu_fdt_establish(d
 static void bcm2835_icu_fdt_disestablish(device_t, void *);
 static bool bcm2835_icu_fdt_intrstr(device_t, u_int *, char *, size_t);
 
+static int bcm2835_icu_intr(void *);
+
 static int bcm2836mp_icu_fdt_decode_irq(u_int *);
 static void *bcm2836mp_icu_fdt_establish(device_t, u_int *, int, int,
 int (*)(void *), void *);
@@ -162,11 +164,35 @@ struct bcm2836mp_interrupt {
 static TAILQ_HEAD(, bcm2836mp_interrupt) bcm2836mp_interrupts =
 TAILQ_HEAD_INITIALIZER(bcm2836mp_interrupts);
 
+struct bcm2835icu_irqhandler;
+struct bcm2835icu_irq;
+struct bcm2835icu_softc;
+
+struct bcm2835icu_irqhandler {
+	struct bcm2835icu_irq	*ih_irq;
+	int			(*ih_fn)(void *);
+	void			*ih_arg;
+	TAILQ_ENTRY(bcm2835icu_irqhandler) ih_next;
+};
+
+struct bcm2835icu_irq {
+	struct bcm2835icu_softc	*intr_sc;
+	void			*intr_ih;
+	void			*intr_arg;
+	int			intr_refcnt;
+	int			intr_ipl;
+	int			intr_irq;
+	int			intr_mpsafe;
+	TAILQ_HEAD(, bcm2835icu_irqhandler) intr_handlers;
+};
+
 struct bcm2835icu_softc {
 	device_t		sc_dev;
 	bus_space_tag_t		sc_iot;
 	bus_space_handle_t	sc_ioh;
 
+	struct bcm2835icu_irq	*sc_irq[BCM2835_NIRQ];
+
 	int sc_phandle;
 };
 
@@ -437,6 +463,9 @@ static void *
 bcm2835_icu_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags,
 int (*func)(void *), void *arg)
 {
+	struct bcm2835icu_softc * const sc = device_private(dev);
+	struct bcm2835icu_irq *firq;
+	struct bcm2835icu_irqhandler *firqh;
 	int iflags = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0;
 	int irq;
 
@@ -444,13 +473,89 @@ bcm2835_icu_fdt_establish(device_t dev, 
 	if (irq == -1)
 		return NULL;
 
-	return intr_establish(irq, ipl, IST_LEVEL | iflags, func, arg);
+	firq = sc->sc_irq[irq];
+	if (firq == NULL) {
+		firq = kmem_alloc(sizeof(*firq), KM_SLEEP);
+		firq->intr_sc = sc;
+		firq->intr_refcnt = 0;
+		firq->intr_arg = arg;
+		firq->intr_ipl = ipl;
+		firq->intr_mpsafe = iflags;
+		firq->intr_irq = irq;
+		TAILQ_INIT(>intr_handlers);
+		if (arg == NULL) {
+			firq->intr_ih = intr_establish(irq, ipl,
+			IST_LEVEL | iflags, func, NULL);
+		} else {
+			firq->intr_ih = intr_establish(irq, ipl,
+			IST_LEVEL | iflags, bcm2835_icu_intr, firq);
+		}
+		if (firq->intr_ih == NULL) {
+			kmem_free(firq, sizeof(*firq));
+			return NULL;
+		}
+		sc->sc_irq[irq] = firq;
+	} else {
+		if (firq->intr_arg == NULL || arg == NULL) {
+			device_printf(dev,
+			"cannot share irq with NULL-arg handler\n");
+			return NULL;
+		}
+		if (firq->intr_ipl != ipl) {
+			device_printf(dev,
+			"cannot share irq with different ipl\n");
+			return NULL;
+		}
+		if (firq->intr_mpsafe != iflags) {
+			device_printf(dev,
+			"cannot share irq between mpsafe/non-mpsafe\n");
+			return NULL;
+		}
+	}
+
+	firqh = kmem_alloc(sizeof(*firqh), KM_SLEEP);
+	firqh->ih_irq = firq;
+	firqh->ih_fn = func;
+	firqh->ih_arg = arg;
+	TAILQ_INSERT_TAIL(>intr_handlers, firqh, ih_next);
+
+	return firqh;
 }
 
 static void
 bcm2835_icu_fdt_disestablish(device_t dev, void *ih)
 {
-	intr_disestablish(ih);
+	struct bcm2835icu_softc * const sc = device_private(dev);
+	struct bcm2835icu_irqhandler *firqh = ih;
+	struct bcm2835icu_irq *firq = firqh->ih_irq;
+
+	KASSERT(firq->intr_refcnt > 0);
+
+	/* XXX */
+	if (firq->intr_refcnt > 1)
+		panic("%s: cannot disestablish shared irq", __func__);
+
+	intr_disestablish(firq->intr_ih);
+
+	TAILQ_REMOVE(>intr_handlers, firqh, ih_next);
+	

CVS commit: src/sys/arch/arm/ti

2019-11-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 27 23:03:24 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_sdhc.c

Log Message:
Fix inverted ti,needs-special-hs-handling property logic and enable EDMA support


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_sdhc.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/arm/ti/ti_sdhc.c
diff -u src/sys/arch/arm/ti/ti_sdhc.c:1.3 src/sys/arch/arm/ti/ti_sdhc.c:1.4
--- src/sys/arch/arm/ti/ti_sdhc.c:1.3	Tue Oct 29 22:19:13 2019
+++ src/sys/arch/arm/ti/ti_sdhc.c	Wed Nov 27 23:03:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_sdhc.c,v 1.3 2019/10/29 22:19:13 jmcneill Exp $	*/
+/*	$NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.3 2019/10/29 22:19:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $");
 
 #include 
 #include 
@@ -180,7 +180,6 @@ ti_sdhc_attach(device_t parent, device_t
 	sc->sc_addr = addr;
 	sc->sc_bst = faa->faa_bst;
 
-#if notyet
 	/* XXX use fdtbus_dma API */
 	int len;
 	const u_int *dmas = fdtbus_get_prop(phandle, "dmas", );
@@ -198,10 +197,6 @@ ti_sdhc_attach(device_t parent, device_t
 		sc->sc_edma_chan[EDMA_CHAN_RX] = -1;
 		break;
 	}
-#else
-	sc->sc_edma_chan[EDMA_CHAN_TX] = -1;
-	sc->sc_edma_chan[EDMA_CHAN_RX] = -1;
-#endif
 
 	if (bus_space_map(sc->sc_bst, addr, size, 0, >sc_bsh) != 0) {
 		aprint_error(": couldn't map registers\n");
@@ -219,7 +214,7 @@ ti_sdhc_attach(device_t parent, device_t
 		sc->sc.sc_flags |= SDHC_FLAG_8BIT_MODE;
 	if (of_hasprop(phandle, "ti,needs-special-reset"))
 		sc->sc.sc_flags |= SDHC_FLAG_WAIT_RESET;
-	if (of_hasprop(phandle, "ti,needs-special-hs-handling"))
+	if (!of_hasprop(phandle, "ti,needs-special-hs-handling"))
 		sc->sc.sc_flags |= SDHC_FLAG_NO_HS_BIT;
 	if (of_hasprop(phandle, "ti,dual-volt"))
 		sc->sc.sc_caps = SDHC_VOLTAGE_SUPP_3_0V;



CVS commit: src/sys/arch/arm/ti

2019-11-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 27 23:03:24 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_sdhc.c

Log Message:
Fix inverted ti,needs-special-hs-handling property logic and enable EDMA support


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

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



CVS commit: src/sys/arch/arm/ti

2019-11-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 27 23:02:54 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c

Log Message:
Fix mmc and timer indexes.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/ti/am3_prcm.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/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.10 src/sys/arch/arm/ti/am3_prcm.c:1.11
--- src/sys/arch/arm/ti/am3_prcm.c:1.10	Mon Nov  4 09:37:51 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Wed Nov 27 23:02:54 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.10 2019/11/04 09:37:51 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.10 2019/11/04 09:37:51 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $");
 
 #include 
 #include 
@@ -161,7 +161,7 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("gpio3", 0xb0, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("gpio4", 0xb4, "PERIPH_CLK"),
 
-	AM3_PRCM_HWMOD_WKUP("timer0", 0x10, "FIXED_32K"),
+	AM3_PRCM_HWMOD_WKUP("timer1", 0x10, "FIXED_32K"),
 	AM3_PRCM_HWMOD_PER("timer2", 0x80, "FIXED_24MHZ"),
 	AM3_PRCM_HWMOD_PER("timer3", 0x84, "FIXED_24MHZ"),
 	AM3_PRCM_HWMOD_PER("timer4", 0x88, "FIXED_24MHZ"),
@@ -169,9 +169,9 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("timer6", 0xf0, "FIXED_24MHZ"),
 	AM3_PRCM_HWMOD_PER("timer7", 0x7c, "FIXED_24MHZ"),
 
-	AM3_PRCM_HWMOD_PER("mmc0", 0x3c, "MMC_CLK"),
-	AM3_PRCM_HWMOD_PER("mmc1", 0xf4, "MMC_CLK"),
-	AM3_PRCM_HWMOD_PER("mmc2", 0xf8, "MMC_CLK"),
+	AM3_PRCM_HWMOD_PER("mmc1", 0x3c, "MMC_CLK"),
+	AM3_PRCM_HWMOD_PER("mmc2", 0xf4, "MMC_CLK"),
+	AM3_PRCM_HWMOD_PER("mmc3", 0xf8, "MMC_CLK"),
 
 	AM3_PRCM_HWMOD_PER("tpcc", 0xbc, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("tptc0", 0x24, "PERIPH_CLK"),



CVS commit: src/sys/arch/arm/ti

2019-11-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 27 23:02:54 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c

Log Message:
Fix mmc and timer indexes.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/ti/am3_prcm.c

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



CVS commit: src/sys/arch/arm/imx

2019-11-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Nov 25 00:54:47 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet_imx6.c

Log Message:
Fixed bug.

* typo


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

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



CVS commit: src/sys/arch/arm/imx

2019-11-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Nov 25 00:54:47 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet_imx6.c

Log Message:
Fixed bug.

* typo


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/if_enet_imx6.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/arm/imx/if_enet_imx6.c
diff -u src/sys/arch/arm/imx/if_enet_imx6.c:1.7 src/sys/arch/arm/imx/if_enet_imx6.c:1.8
--- src/sys/arch/arm/imx/if_enet_imx6.c:1.7	Tue Nov 12 05:09:29 2019
+++ src/sys/arch/arm/imx/if_enet_imx6.c	Mon Nov 25 00:54:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx6.c,v 1.7 2019/11/12 05:09:29 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx6.c,v 1.8 2019/11/25 00:54:47 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.7 2019/11/12 05:09:29 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.8 2019/11/25 00:54:47 hkenken Exp $");
 
 #include "locators.h"
 #include "imxccm.h"
@@ -132,7 +132,7 @@ enet_attach(device_t parent, device_t se
 	}
 
 	sc->sc_clk_ipg = imx6_get_clock("enet");
-	if (sc->sc_clk_enet == NULL) {
+	if (sc->sc_clk_ipg == NULL) {
 		aprint_error(": couldn't get clock ipg\n");
 		return;
 	}



CVS commit: src/sys/arch/arm/sunxi

2019-11-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 24 12:21:14 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_drm.c

Log Message:
Reclaim bootloader FB memory for CMA pool.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_drm.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/arm/sunxi/sunxi_drm.c
diff -u src/sys/arch/arm/sunxi/sunxi_drm.c:1.8 src/sys/arch/arm/sunxi/sunxi_drm.c:1.9
--- src/sys/arch/arm/sunxi/sunxi_drm.c:1.8	Tue Nov  5 23:31:23 2019
+++ src/sys/arch/arm/sunxi/sunxi_drm.c	Sun Nov 24 12:21:14 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_drm.c,v 1.8 2019/11/05 23:31:23 jmcneill Exp $ */
+/* $NetBSD: sunxi_drm.c,v 1.9 2019/11/24 12:21:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.8 2019/11/05 23:31:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.9 2019/11/24 12:21:14 jmcneill Exp $");
 
 #include 
 #include 
@@ -296,6 +296,27 @@ static struct drm_mode_config_funcs sunx
 };
 
 static int
+sunxi_drm_simplefb_lookup(bus_addr_t *paddr, bus_size_t *psize)
+{
+	static const char * compat[] = { "simple-framebuffer", NULL };
+	int chosen, child;
+
+	chosen = OF_finddevice("/chosen");
+	if (chosen == -1)
+		return ENOENT;
+
+	for (child = OF_child(chosen); child; child = OF_peer(child)) {
+		if (!fdtbus_status_okay(child))
+			continue;
+		if (!of_match_compatible(child, compat))
+			continue;
+		return fdtbus_get_reg(child, 0, paddr, psize);
+	}
+
+	return ENOENT;
+}
+
+static int
 sunxi_drm_fb_probe(struct drm_fb_helper *helper, struct drm_fb_helper_surface_size *sizes)
 {
 	struct sunxi_drm_softc * const sc = sunxi_drm_private(helper->dev);
@@ -303,6 +324,8 @@ sunxi_drm_fb_probe(struct drm_fb_helper 
 	struct sunxi_drm_framebuffer *sfb = to_sunxi_drm_framebuffer(helper->fb);
 	struct drm_framebuffer *fb = helper->fb;
 	struct sunxi_drmfb_attach_args sfa;
+	bus_addr_t sfb_addr;
+	bus_size_t sfb_size;
 	size_t cma_size;
 	int error;
 
@@ -312,14 +335,31 @@ sunxi_drm_fb_probe(struct drm_fb_helper 
 
 	const size_t size = roundup(height * pitch, PAGE_SIZE);
 
-	/* Reserve enough memory for the FB console plus a 4K plane, rounded to 1MB */
-	cma_size = size;
-	cma_size += (SUNXI_DRM_MAX_WIDTH * SUNXI_DRM_MAX_HEIGHT * 4);
+	if (sunxi_drm_simplefb_lookup(_addr, _size) != 0)
+		sfb_size = 0;
+
+	/* Reserve enough memory for a 4K plane, rounded to 1MB */
+	cma_size = (SUNXI_DRM_MAX_WIDTH * SUNXI_DRM_MAX_HEIGHT * 4);
+	if (sfb_size == 0) {
+		/* Add memory for FB console if we cannot reclaim bootloader memory */
+		cma_size += size;
+	}
 	cma_size = roundup(cma_size, 1024 * 1024);
 	sc->sc_ddev->cma_pool = sunxi_drm_alloc_cma_pool(sc->sc_ddev, cma_size);
-	if (sc->sc_ddev->cma_pool != NULL)
-		aprint_normal_dev(sc->sc_dev, "reserved %u MB DRAM for CMA\n",
-		(u_int)(cma_size / (1024 * 1024)));
+	if (sc->sc_ddev->cma_pool != NULL) {
+		if (sfb_size != 0) {
+			error = vmem_add(sc->sc_ddev->cma_pool, sfb_addr,
+			sfb_size, VM_SLEEP);
+			if (error != 0)
+sfb_size = 0;
+		}
+		aprint_normal_dev(sc->sc_dev, "reserved %u MB DRAM for CMA",
+		(u_int)((cma_size + sfb_size) / (1024 * 1024)));
+		if (sfb_size != 0)
+			aprint_normal(" (%u MB reclaimed from bootloader)",
+			(u_int)(sfb_size / (1024 * 1024)));
+		aprint_normal("\n");
+	}
 
 	sfb->obj = drm_gem_cma_create(ddev, size);
 	if (sfb->obj == NULL) {



CVS commit: src/sys/arch/arm/sunxi

2019-11-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 24 12:21:14 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_drm.c

Log Message:
Reclaim bootloader FB memory for CMA pool.


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

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



CVS commit: src/sys/arch/arm/fdt

2019-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 24 11:10:13 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c

Log Message:
Remove unnecessary cast and wrap a long line.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/fdt/gic_fdt.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/arm/fdt/gic_fdt.c
diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.17 src/sys/arch/arm/fdt/gic_fdt.c:1.18
--- src/sys/arch/arm/fdt/gic_fdt.c:1.17	Fri Jul 19 12:14:15 2019
+++ src/sys/arch/arm/fdt/gic_fdt.c	Sun Nov 24 11:10:12 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_fdt.c,v 1.17 2019/07/19 12:14:15 hkenken Exp $ */
+/* $NetBSD: gic_fdt.c,v 1.18 2019/11/24 11:10:12 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.17 2019/07/19 12:14:15 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.18 2019/11/24 11:10:12 skrll Exp $");
 
 #include 
 #include 
@@ -226,9 +226,9 @@ gic_fdt_attach_v2m(struct gic_fdt_softc 
 	if (gic_v2m_init(frame, sc->sc_gicdev, sc->sc_v2m_count++) != 0) {
 		aprint_error_dev(sc->sc_gicdev, "failed to initialize GICv2m\n");
 	} else {
-		aprint_normal_dev(sc->sc_gicdev, "GICv2m @ %#" PRIx64 ", SPIs %u-%u\n",
-		(uint64_t)frame->frame_reg, frame->frame_base,
-		frame->frame_base + frame->frame_count);
+		aprint_normal_dev(sc->sc_gicdev, "GICv2m @ %#" PRIx64
+		", SPIs %u-%u\n", frame->frame_reg,
+		frame->frame_base, frame->frame_base + frame->frame_count);
 	}
 }
 #endif



CVS commit: src/sys/arch/arm/fdt

2019-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 24 11:10:13 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c

Log Message:
Remove unnecessary cast and wrap a long line.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/fdt/gic_fdt.c

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



CVS commit: src/sys/arch/arm/imx

2019-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 24 11:07:19 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_usbphy.c
src/sys/arch/arm/imx/fdt: imx6_gpio.c imx6_sdhc.c imx6_usb.c
imx6_usbphy.c

Log Message:
Use PRIxBUSADDR


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imx6_usbphy.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/fdt/imx6_gpio.c \
src/sys/arch/arm/imx/fdt/imx6_usb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/fdt/imx6_sdhc.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_usbphy.c

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



CVS commit: src/sys/arch/arm/imx

2019-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 24 11:07:19 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_usbphy.c
src/sys/arch/arm/imx/fdt: imx6_gpio.c imx6_sdhc.c imx6_usb.c
imx6_usbphy.c

Log Message:
Use PRIxBUSADDR


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imx6_usbphy.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/fdt/imx6_gpio.c \
src/sys/arch/arm/imx/fdt/imx6_usb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/fdt/imx6_sdhc.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_usbphy.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/arm/imx/imx6_usbphy.c
diff -u src/sys/arch/arm/imx/imx6_usbphy.c:1.2 src/sys/arch/arm/imx/imx6_usbphy.c:1.3
--- src/sys/arch/arm/imx/imx6_usbphy.c:1.2	Thu Jun 20 08:16:19 2019
+++ src/sys/arch/arm/imx/imx6_usbphy.c	Sun Nov 24 11:07:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_usbphy.c,v 1.2 2019/06/20 08:16:19 hkenken Exp $	*/
+/*	$NetBSD: imx6_usbphy.c,v 1.3 2019/11/24 11:07:19 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017  Genetec Corporation.  All rights reserved.
@@ -32,7 +32,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: imx6_usbphy.c,v 1.2 2019/06/20 08:16:19 hkenken Exp $");
+__KERNEL_RCSID(1, "$NetBSD: imx6_usbphy.c,v 1.3 2019/11/24 11:07:19 skrll Exp $");
 
 #include 
 #include 
@@ -144,8 +144,8 @@ imx6_usbphy_attach(device_t parent, devi
 
 	error = bus_space_map(sc->sc_bst, addr, size, 0, >sc_bsh);
 	if (error) {
-		aprint_error(": couldn't map %#llx: %d",
-		(uint64_t)addr, error);
+		aprint_error(": couldn't map %#" PRIxBUSADDR ": %d",
+		addr, error);
 		return;
 	}
 

Index: src/sys/arch/arm/imx/fdt/imx6_gpio.c
diff -u src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.2 src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.3
--- src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.2	Mon Aug 19 03:45:51 2019
+++ src/sys/arch/arm/imx/fdt/imx6_gpio.c	Sun Nov 24 11:07:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_gpio.c,v 1.2 2019/08/19 03:45:51 hkenken Exp $	*/
+/*	$NetBSD: imx6_gpio.c,v 1.3 2019/11/24 11:07:19 skrll Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_gpio.c,v 1.2 2019/08/19 03:45:51 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_gpio.c,v 1.3 2019/11/24 11:07:19 skrll Exp $");
 
 #include "opt_fdt.h"
 #include "gpio.h"
@@ -107,7 +107,7 @@ imxgpio_attach(device_t parent, device_t
 
 	error = bus_space_map(faa->faa_bst, addr, size, 0, );
 	if (error) {
-		aprint_error(": couldn't map %#llx: %d", (uint64_t)addr, error);
+		aprint_error(": couldn't map %#" PRIxBUSADDR ": %d", addr, error);
 		return;
 	}
 
Index: src/sys/arch/arm/imx/fdt/imx6_usb.c
diff -u src/sys/arch/arm/imx/fdt/imx6_usb.c:1.2 src/sys/arch/arm/imx/fdt/imx6_usb.c:1.3
--- src/sys/arch/arm/imx/fdt/imx6_usb.c:1.2	Mon Aug 19 03:45:51 2019
+++ src/sys/arch/arm/imx/fdt/imx6_usb.c	Sun Nov 24 11:07:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_usb.c,v 1.2 2019/08/19 03:45:51 hkenken Exp $	*/
+/*	$NetBSD: imx6_usb.c,v 1.3 2019/11/24 11:07:19 skrll Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_usb.c,v 1.2 2019/08/19 03:45:51 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_usb.c,v 1.3 2019/11/24 11:07:19 skrll Exp $");
 
 #include "opt_fdt.h"
 
@@ -111,7 +111,7 @@ imx6_usb_attach(device_t parent, device_
 
 	error = bus_space_map(bst, addr, size, 0, );
 	if (error) {
-		aprint_error(": couldn't map %#llx: %d", (uint64_t)addr, error);
+		aprint_error(": couldn't map %#" PRIxBUSADDR ": %d", addr, error);
 		return;
 	}
 

Index: src/sys/arch/arm/imx/fdt/imx6_sdhc.c
diff -u src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.4 src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.5
--- src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.4	Wed Oct 23 05:20:52 2019
+++ src/sys/arch/arm/imx/fdt/imx6_sdhc.c	Sun Nov 24 11:07:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_sdhc.c,v 1.4 2019/10/23 05:20:52 hkenken Exp $	*/
+/*	$NetBSD: imx6_sdhc.c,v 1.5 2019/11/24 11:07:19 skrll Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_sdhc.c,v 1.4 2019/10/23 05:20:52 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_sdhc.c,v 1.5 2019/11/24 11:07:19 skrll Exp $");
 
 #include "opt_fdt.h"
 
@@ -133,7 +133,7 @@ imx6_sdhc_attach(device_t parent, device
 	sc->sc_bst = faa->faa_bst;
 	error = bus_space_map(sc->sc_bst, addr, size, 0, >sc_bsh);
 	if (error) {
-		aprint_error(": couldn't map %#llx: %d", (uint64_t)addr, error);
+		aprint_error(": couldn't map %#" PRIxBUSADDR ": %d", 

CVS commit: src/sys/arch/arm/sunxi

2019-11-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 24 10:27:37 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c sunxi_dwhdmi.c
sunxi_platform.c

Log Message:
Try to avoid changing hardware settings when the "nomodeset" kernel arg
is present.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/arm/sunxi/sunxi_platform.c

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 24 10:27:37 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c sunxi_dwhdmi.c
sunxi_platform.c

Log Message:
Try to avoid changing hardware settings when the "nomodeset" kernel arg
is present.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/arm/sunxi/sunxi_platform.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/arm/sunxi/sun50i_a64_ccu.c
diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.19 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.20
--- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.19	Sat Nov 23 22:46:53 2019
+++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c	Sun Nov 24 10:27:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_ccu.c,v 1.20 2019/11/24 10:27:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.20 2019/11/24 10:27:37 jmcneill Exp $");
 
 #include 
 #include 
@@ -601,6 +601,8 @@ sun50i_a64_ccu_attach(device_t parent, d
 {
 	struct sunxi_ccu_softc * const sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
+	prop_dictionary_t prop = device_properties(self);
+	bool nomodeset;
 
 	sc->sc_dev = self;
 	sc->sc_phandle = faa->faa_phandle;
@@ -618,19 +620,23 @@ sun50i_a64_ccu_attach(device_t parent, d
 	aprint_naive("\n");
 	aprint_normal(": A64 CCU\n");
 
-	/* Set DE parent to PLL_DE */
-	clk_set_parent(>sc_clks[A64_CLK_DE].base, >sc_clks[A64_CLK_PLL_DE].base);
-	clk_set_rate(>sc_clks[A64_CLK_PLL_DE].base, 42000);
-
-	/* Set video PLLs to 297 MHz */
-	clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO0].base, 29700);
-	clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO1].base, 29700);
-
-	/* Set TCON1 parent to PLL_VIDEO1(1X) */
-	clk_set_parent(>sc_clks[A64_CLK_TCON1].base, >sc_clks[A64_CLK_PLL_VIDEO1].base);
-
-	/* Set HDMI parent to PLL_VIDEO1(1X) */
-	clk_set_parent(>sc_clks[A64_CLK_HDMI].base, >sc_clks[A64_CLK_PLL_VIDEO1].base);
+	nomodeset = false;
+	prop_dictionary_get_bool(prop, "nomodeset", );
+	if (!nomodeset) {
+		/* Set DE parent to PLL_DE */
+		clk_set_parent(>sc_clks[A64_CLK_DE].base, >sc_clks[A64_CLK_PLL_DE].base);
+		clk_set_rate(>sc_clks[A64_CLK_PLL_DE].base, 42000);
+
+		/* Set video PLLs to 297 MHz */
+		clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO0].base, 29700);
+		clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO1].base, 29700);
+
+		/* Set TCON1 parent to PLL_VIDEO1(1X) */
+		clk_set_parent(>sc_clks[A64_CLK_TCON1].base, >sc_clks[A64_CLK_PLL_VIDEO1].base);
+
+		/* Set HDMI parent to PLL_VIDEO1(1X) */
+		clk_set_parent(>sc_clks[A64_CLK_HDMI].base, >sc_clks[A64_CLK_PLL_VIDEO1].base);
+	}
 
 	sunxi_ccu_print(sc);
 }

Index: src/sys/arch/arm/sunxi/sunxi_dwhdmi.c
diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.7 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.8
--- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.7	Sat Nov 23 18:55:08 2019
+++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c	Sun Nov 24 10:27:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $ */
+/* $NetBSD: sunxi_dwhdmi.c,v 1.8 2019/11/24 10:27:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.8 2019/11/24 10:27:37 jmcneill Exp $");
 
 #include 
 #include 
@@ -228,12 +228,20 @@ sunxi_dwhdmi_attach(device_t parent, dev
 {
 	struct sunxi_dwhdmi_softc * const sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
+	prop_dictionary_t prop = device_properties(self);
 	const int phandle = faa->faa_phandle;
 	struct clk *clk_iahb, *clk_isfr, *clk_tmds;
 	struct fdtbus_reset *rst;
+	bool is_disabled;
 	bus_addr_t addr;
 	bus_size_t size;
 
+	if (prop_dictionary_get_bool(prop, "disabled", _disabled) && is_disabled) {
+		aprint_naive("\n");
+		aprint_normal(": HDMI TX (disabled)\n");
+		return;
+	}
+
 	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
 		aprint_error(": couldn't get registers\n");
 		return;

Index: src/sys/arch/arm/sunxi/sunxi_platform.c
diff -u src/sys/arch/arm/sunxi/sunxi_platform.c:1.37 src/sys/arch/arm/sunxi/sunxi_platform.c:1.38
--- src/sys/arch/arm/sunxi/sunxi_platform.c:1.37	Mon Jun 17 05:27:01 2019
+++ src/sys/arch/arm/sunxi/sunxi_platform.c	Sun Nov 24 10:27:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_platform.c,v 1.37 2019/06/17 05:27:01 mrg Exp $ */
+/* $NetBSD: sunxi_platform.c,v 1.38 2019/11/24 10:27:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -31,7 

CVS commit: src/sys/arch/arm/ti

2019-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 24 09:37:05 UTC 2019

Modified Files:
src/sys/arch/arm/ti: if_cpsw.c

Log Message:
Fix KERNHIST build (and simplify)


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

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



CVS commit: src/sys/arch/arm/ti

2019-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 24 09:37:05 UTC 2019

Modified Files:
src/sys/arch/arm/ti: if_cpsw.c

Log Message:
Fix KERNHIST build (and simplify)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/if_cpsw.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/arm/ti/if_cpsw.c
diff -u src/sys/arch/arm/ti/if_cpsw.c:1.8 src/sys/arch/arm/ti/if_cpsw.c:1.9
--- src/sys/arch/arm/ti/if_cpsw.c:1.8	Sun Nov  3 10:09:04 2019
+++ src/sys/arch/arm/ti/if_cpsw.c	Sun Nov 24 09:37:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cpsw.c,v 1.8 2019/11/03 10:09:04 jmcneill Exp $	*/
+/*	$NetBSD: if_cpsw.c,v 1.9 2019/11/24 09:37:05 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.8 2019/11/03 10:09:04 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.9 2019/11/24 09:37:05 skrll Exp $");
 
 #include 
 #include 
@@ -174,19 +174,14 @@ static int cpsw_ale_update_addresses(str
 CFATTACH_DECL_NEW(cpsw, sizeof(struct cpsw_softc),
 cpsw_match, cpsw_attach, cpsw_detach, NULL);
 
-#undef KERNHIST
 #include 
 KERNHIST_DEFINE(cpswhist);
 
-#ifdef KERNHIST
-#define KERNHIST_CALLED_5(NAME, i, j, k, l) \
-do { \
-	_kernhist_call = atomic_inc_uint_nv(&_kernhist_cnt); \
-	KERNHIST_LOG(NAME, "called! %x %x %x %x", i, j, k, l); \
-} while (/*CONSTCOND*/ 0)
-#else
-#define KERNHIST_CALLED_5(NAME, i, j, k, l)
-#endif
+#define CPSWHIST_CALLARGS(A,B,C,D)	do {	\
+	KERNHIST_CALLARGS(cpswhist, "%jx %jx %jx %jx",			\
+		(uintptr_t)(A), (uintptr_t)(B), (uintptr_t)(C), (uintptr_t)(D));\
+	} while (0)
+
 
 static inline u_int
 cpsw_txdesc_adjust(u_int x, int y)
@@ -219,7 +214,7 @@ cpsw_set_txdesc_next(struct cpsw_softc *
 	const bus_size_t o = sizeof(struct cpsw_cpdma_bd) * i + 0;
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, n, 0);
+	CPSWHIST_CALLARGS(sc, i, n, 0);
 
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh_txdescs, o, n);
 }
@@ -230,7 +225,7 @@ cpsw_set_rxdesc_next(struct cpsw_softc *
 	const bus_size_t o = sizeof(struct cpsw_cpdma_bd) * i + 0;
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, n, 0);
+	CPSWHIST_CALLARGS(sc, i, n, 0);
 
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh_rxdescs, o, n);
 }
@@ -244,7 +239,7 @@ cpsw_get_txdesc(struct cpsw_softc * cons
 	const bus_size_t c = __arraycount(bdp->word);
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
+	CPSWHIST_CALLARGS(sc, i, bdp, 0);
 
 	bus_space_read_region_4(sc->sc_bst, sc->sc_bsh_txdescs, o, dp, c);
 	KERNHIST_LOG(cpswhist, "%08x %08x %08x %08x\n",
@@ -260,7 +255,7 @@ cpsw_set_txdesc(struct cpsw_softc * cons
 	const bus_size_t c = __arraycount(bdp->word);
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
+	CPSWHIST_CALLARGS(sc, i, bdp, 0);
 	KERNHIST_LOG(cpswhist, "%08x %08x %08x %08x\n",
 	dp[0], dp[1], dp[2], dp[3]);
 
@@ -276,7 +271,7 @@ cpsw_get_rxdesc(struct cpsw_softc * cons
 	const bus_size_t c = __arraycount(bdp->word);
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
+	CPSWHIST_CALLARGS(sc, i, bdp, 0);
 
 	bus_space_read_region_4(sc->sc_bst, sc->sc_bsh_rxdescs, o, dp, c);
 
@@ -293,7 +288,7 @@ cpsw_set_rxdesc(struct cpsw_softc * cons
 	const bus_size_t c = __arraycount(bdp->word);
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
+	CPSWHIST_CALLARGS(sc, i, bdp, 0);
 	KERNHIST_LOG(cpswhist, "%08x %08x %08x %08x\n",
 	dp[0], dp[1], dp[2], dp[3]);
 
@@ -607,7 +602,7 @@ cpsw_start(struct ifnet *ifp)
 	u_int mlen;
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, 0, 0, 0);
+	CPSWHIST_CALLARGS(sc, 0, 0, 0);
 
 	if (__predict_false((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) !=
 	IFF_RUNNING)) {
@@ -1140,7 +1135,7 @@ cpsw_rxintr(void *arg)
 	u_int len, off;
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, 0, 0, 0);
+	CPSWHIST_CALLARGS(sc, 0, 0, 0);
 
 	for (;;) {
 		KASSERT(sc->sc_rxhead < CPSW_NRXDESCS);
@@ -1225,7 +1220,7 @@ cpsw_txintr(void *arg)
 	u_int cpi;
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, 0, 0, 0);
+	CPSWHIST_CALLARGS(sc, 0, 0, 0);
 
 	KASSERT(sc->sc_txrun);
 



CVS commit: src/sys/arch/arm/dts

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 24 02:06:16 UTC 2019

Modified Files:
src/sys/arch/arm/dts: sun50i-a64-pinebook.dts

Log Message:
Enable HDMI and HDMI audio


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/dts/sun50i-a64-pinebook.dts

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



CVS commit: src/sys/arch/arm/dts

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 24 02:06:16 UTC 2019

Modified Files:
src/sys/arch/arm/dts: sun50i-a64-pinebook.dts

Log Message:
Enable HDMI and HDMI audio


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/dts/sun50i-a64-pinebook.dts

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/arm/dts/sun50i-a64-pinebook.dts
diff -u src/sys/arch/arm/dts/sun50i-a64-pinebook.dts:1.16 src/sys/arch/arm/dts/sun50i-a64-pinebook.dts:1.17
--- src/sys/arch/arm/dts/sun50i-a64-pinebook.dts:1.16	Thu Jun  6 23:19:45 2019
+++ src/sys/arch/arm/dts/sun50i-a64-pinebook.dts	Sun Nov 24 02:06:16 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i-a64-pinebook.dts,v 1.16 2019/06/06 23:19:45 jmcneill Exp $ */
+/* $NetBSD: sun50i-a64-pinebook.dts,v 1.17 2019/11/24 02:06:16 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017-2019 Jared McNeill 
@@ -54,6 +54,17 @@
 	sound_spdif {
 		status = "disabled";
 	};
+
+	hdmi-connector {
+		compatible = "hdmi-connector";
+		type = "c";
+
+		port {
+			hdmi_con_in: endpoint {
+remote-endpoint = <_out_con>;
+			};
+		};
+	};
 };
 
  {
@@ -151,3 +162,28 @@
 		};
 	};
 };
+
+_dldo1 {
+	regulator-min-microvolt = <330>;
+	regulator-max-microvolt = <330>;
+	regulator-name = "vcc-hdmi";
+};
+
+ {
+	hvcc-supply = <_dldo1>;
+	status = "okay";
+};
+
+_out {
+	hdmi_out_con: endpoint {
+		remote-endpoint = <_con_in>;
+	};
+};
+
+ {
+	status = "okay";
+};
+
+_hdmi {
+	status = "okay";
+};



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 23:47:57 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_mixer.c

Log Message:
Do not assume the cursor pitch is the same as the primary fb


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_mixer.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/arm/sunxi/sunxi_mixer.c
diff -u src/sys/arch/arm/sunxi/sunxi_mixer.c:1.9 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.10
--- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.9	Sat Nov 23 21:40:57 2019
+++ src/sys/arch/arm/sunxi/sunxi_mixer.c	Sat Nov 23 23:47:57 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $ */
+/* $NetBSD: sunxi_mixer.c,v 1.10 2019/11/23 23:47:57 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.10 2019/11/23 23:47:57 jmcneill Exp $");
 
 #include 
 #include 
@@ -373,7 +373,7 @@ sunxi_mixer_cursor_set(struct drm_crtc *
 	/* Set UI overlay offset */
 	OVL_UI_WRITE(sc, 1, OVL_UI_COOR(0), offset);
 	/* Set UI overlay line size */
-	OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), crtc->primary->fb->pitches[0]);
+	OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), width * 4);
 	/* Set UI overlay window size */
 	OVL_UI_WRITE(sc, 1, OVL_UI_SIZE, crtc_size);
 



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 23:47:57 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_mixer.c

Log Message:
Do not assume the cursor pitch is the same as the primary fb


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_mixer.c

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 22:46:53 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c

Log Message:
Set video PLLs to 297MHz


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 22:46:53 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c

Log Message:
Set video PLLs to 297MHz


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/sunxi/sun50i_a64_ccu.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/arm/sunxi/sun50i_a64_ccu.c
diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.18 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.19
--- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.18	Sat Nov 23 18:57:36 2019
+++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c	Sat Nov 23 22:46:53 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $");
 
 #include 
 #include 
@@ -622,9 +622,15 @@ sun50i_a64_ccu_attach(device_t parent, d
 	clk_set_parent(>sc_clks[A64_CLK_DE].base, >sc_clks[A64_CLK_PLL_DE].base);
 	clk_set_rate(>sc_clks[A64_CLK_PLL_DE].base, 42000);
 
+	/* Set video PLLs to 297 MHz */
+	clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO0].base, 29700);
+	clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO1].base, 29700);
+
 	/* Set TCON1 parent to PLL_VIDEO1(1X) */
 	clk_set_parent(>sc_clks[A64_CLK_TCON1].base, >sc_clks[A64_CLK_PLL_VIDEO1].base);
-	clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO1].base, 29700);
+
+	/* Set HDMI parent to PLL_VIDEO1(1X) */
+	clk_set_parent(>sc_clks[A64_CLK_HDMI].base, >sc_clks[A64_CLK_PLL_VIDEO1].base);
 
 	sunxi_ccu_print(sc);
 }



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 21:40:58 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_mixer.c

Log Message:
Support non-zero fb start pixels.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_mixer.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/arm/sunxi/sunxi_mixer.c
diff -u src/sys/arch/arm/sunxi/sunxi_mixer.c:1.8 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.9
--- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.8	Sat Nov 23 20:24:12 2019
+++ src/sys/arch/arm/sunxi/sunxi_mixer.c	Sat Nov 23 21:40:57 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $ */
+/* $NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $");
 
 #include 
 #include 
@@ -252,6 +252,9 @@ sunxi_mixer_mode_do_set_base(struct drm_
 
 	uint64_t paddr = (uint64_t)sfb->obj->dmamap->dm_segs[0].ds_addr;
 
+	paddr += y * sfb->base.pitches[0];
+	paddr += x * drm_format_plane_cpp(sfb->base.pixel_format, 0);
+
 	uint32_t haddr = (paddr >> 32) & OVL_UI_TOP_HADD_LAYER0;
 	uint32_t laddr = paddr & 0x;
 
@@ -461,7 +464,6 @@ sunxi_mixer_mode_set(struct drm_crtc *cr
 
 	const uint32_t size = ((adjusted_mode->vdisplay - 1) << 16) |
 			  (adjusted_mode->hdisplay - 1);
-	const uint32_t offset = (y << 16) | x;
 
 	/* Set global size */
 	GLB_WRITE(sc, GLB_SIZE, size);
@@ -474,7 +476,7 @@ sunxi_mixer_mode_set(struct drm_crtc *cr
 	/* Set blender 0 input size */
 	BLD_WRITE(sc, BLD_CH_ISIZE(0), size);
 	/* Set blender 0 offset */
-	BLD_WRITE(sc, BLD_CH_OFFSET(0), offset);
+	BLD_WRITE(sc, BLD_CH_OFFSET(0), 0);
 	/* Route channel 1 to pipe 0 */
 	val = BLD_READ(sc, BLD_CH_RTCTL);
 	val &= ~BLD_CH_RTCTL_P0;
@@ -493,7 +495,7 @@ sunxi_mixer_mode_set(struct drm_crtc *cr
 	/* Set UI overlay layer size */
 	OVL_UI_WRITE(sc, 0, OVL_UI_MBSIZE(0), size);
 	/* Set UI overlay offset */
-	OVL_UI_WRITE(sc, 0, OVL_UI_COOR(0), offset);
+	OVL_UI_WRITE(sc, 0, OVL_UI_COOR(0), 0);
 	/* Set UI overlay window size */
 	OVL_UI_WRITE(sc, 0, OVL_UI_SIZE, size);
 



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 21:40:58 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_mixer.c

Log Message:
Support non-zero fb start pixels.


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

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 21:30:41 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c

Log Message:
Set pre-divider M to 0 in fractional mode, as noted in user manual. Spotted by 
jak.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.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/arm/sunxi/sunxi_ccu_fractional.c
diff -u src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.5 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.6
--- src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.5	Sat Nov 23 18:52:09 2019
+++ src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c	Sat Nov 23 21:30:41 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu_fractional.c,v 1.6 2019/11/23 21:30:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.6 2019/11/23 21:30:41 jmcneill Exp $");
 
 #include 
 #include 
@@ -137,6 +137,7 @@ sunxi_ccu_fractional_set_rate(struct sun
 
 	for (i = 0; i < __arraycount(fractional->frac); i++) {
 		if (fractional->frac[i] == new_rate) {
+			val &= ~fractional->prediv;
 			val &= ~fractional->div_en;
 			val &= ~fractional->frac_sel;
 			val |= __SHIFTIN(i, fractional->frac_sel);



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 21:30:41 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c

Log Message:
Set pre-divider M to 0 in fractional mode, as noted in user manual. Spotted by 
jak.


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

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 20:28:04 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_lcdc.c

Log Message:
Use actual hw mode, not proposed mode.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_lcdc.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/arm/sunxi/sunxi_lcdc.c
diff -u src/sys/arch/arm/sunxi/sunxi_lcdc.c:1.6 src/sys/arch/arm/sunxi/sunxi_lcdc.c:1.7
--- src/sys/arch/arm/sunxi/sunxi_lcdc.c:1.6	Sat Jul  6 00:23:38 2019
+++ src/sys/arch/arm/sunxi/sunxi_lcdc.c	Sat Nov 23 20:28:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_lcdc.c,v 1.6 2019/07/06 00:23:38 jmcneill Exp $ */
+/* $NetBSD: sunxi_lcdc.c,v 1.7 2019/11/23 20:28:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_lcdc.c,v 1.6 2019/07/06 00:23:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_lcdc.c,v 1.7 2019/11/23 20:28:04 jmcneill Exp $");
 
 #include 
 #include 
@@ -81,7 +81,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_lcdc.c
 #define	TCON1_CTL_REG		0x090
 #define	 TCON1_CTL_TCON1_EN			__BIT(31)
 #define	 TCON1_CTL_START_DELAY			__BITS(8,4)
-#define	 TCON1_CTL_TCON1_SRC_SEL		__BIT(1)
+#define	 TCON1_CTL_TCON1_SRC_SEL		__BITS(1,0)
 #define	TCON1_BASIC0_REG	0x094
 #define	TCON1_BASIC1_REG	0x098
 #define	TCON1_BASIC2_REG	0x09c
@@ -185,6 +185,7 @@ sunxi_lcdc_tcon0_prepare(struct drm_enco
 
 	val = TCON_READ(sc, TCON_GCTL_REG);
 	val |= TCON_GCTL_TCON_EN;
+	val &= ~TCON_GCTL_IO_MAP_SEL;
 	TCON_WRITE(sc, TCON_GCTL_REG, val);
 
 	TCON_WRITE(sc, TCON0_IO_TRI_REG, 0);
@@ -215,20 +216,20 @@ sunxi_lcdc_tcon0_commit(struct drm_encod
 	int error;
 
 	const u_int interlace_p = (mode->flags & DRM_MODE_FLAG_INTERLACE) != 0;
-	const u_int hspw = mode->hsync_end - mode->hsync_start;
-	const u_int hbp = mode->htotal - mode->hsync_start;
-	const u_int vspw = mode->vsync_end - mode->vsync_start;
-	const u_int vbp = mode->vtotal - mode->vsync_start;
-	const u_int vblank_len = (mode->vtotal - mode->vdisplay) >> interlace_p;
+	const u_int hspw = mode->crtc_hsync_end - mode->crtc_hsync_start;
+	const u_int hbp = mode->crtc_htotal - mode->crtc_hsync_start;
+	const u_int vspw = mode->crtc_vsync_end - mode->crtc_vsync_start;
+	const u_int vbp = mode->crtc_vtotal - mode->crtc_vsync_start;
+	const u_int vblank_len = (mode->crtc_vtotal - mode->crtc_vdisplay) >> interlace_p;
 	const u_int start_delay = uimin(vblank_len, 30);
 
 	val = TCON0_CTL_TCON0_EN |
 	  __SHIFTIN(start_delay, TCON0_CTL_START_DELAY);
 	TCON_WRITE(sc, TCON0_CTL_REG, val);
 
-	TCON_WRITE(sc, TCON0_BASIC0_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
-	TCON_WRITE(sc, TCON0_BASIC1_REG, ((mode->htotal - 1) << 16) | (hbp - 1));
-	TCON_WRITE(sc, TCON0_BASIC2_REG, ((mode->vtotal * 2) << 16) | (vbp - 1));
+	TCON_WRITE(sc, TCON0_BASIC0_REG, ((mode->crtc_hdisplay - 1) << 16) | (mode->crtc_vdisplay - 1));
+	TCON_WRITE(sc, TCON0_BASIC1_REG, ((mode->crtc_htotal - 1) << 16) | (hbp - 1));
+	TCON_WRITE(sc, TCON0_BASIC2_REG, ((mode->crtc_vtotal * 2) << 16) | (vbp - 1));
 	TCON_WRITE(sc, TCON0_BASIC3_REG, ((hspw - 1) << 16) | (vspw - 1));
 
 	val = TCON_READ(sc, TCON0_IO_POL_REG);
@@ -268,24 +269,22 @@ sunxi_lcdc_tcon1_commit(struct drm_encod
 	int error;
 
 	const u_int interlace_p = (mode->flags & DRM_MODE_FLAG_INTERLACE) != 0;
-	const u_int hspw = mode->hsync_end - mode->hsync_start;
-	const u_int hbp = mode->htotal - mode->hsync_start;
-	const u_int vspw = mode->vsync_end - mode->vsync_start;
-	const u_int vbp = mode->vtotal - mode->vsync_start;
-	const u_int vblank_len =
-	((mode->vtotal << interlace_p) >> 1) - mode->vdisplay - 2;
-	const u_int start_delay =
-	vblank_len >= 32 ? 30 : vblank_len - 2;
+	const u_int hspw = mode->crtc_hsync_end - mode->crtc_hsync_start;
+	const u_int hbp = mode->crtc_htotal - mode->crtc_hsync_start;
+	const u_int vspw = mode->crtc_vsync_end - mode->crtc_vsync_start;
+	const u_int vbp = mode->crtc_vtotal - mode->crtc_vsync_start;
+	const u_int vblank_len = ((mode->crtc_vtotal - mode->crtc_vdisplay) >> interlace_p) - 2;
+	const u_int start_delay = uimin(vblank_len, 30);
 
 	val = TCON1_CTL_TCON1_EN |
 	  __SHIFTIN(start_delay, TCON1_CTL_START_DELAY);
 	TCON_WRITE(sc, TCON1_CTL_REG, val);
 
-	TCON_WRITE(sc, TCON1_BASIC0_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
-	TCON_WRITE(sc, TCON1_BASIC1_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
-	TCON_WRITE(sc, TCON1_BASIC2_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
-	TCON_WRITE(sc, TCON1_BASIC3_REG, ((mode->htotal - 1) << 16) | (hbp - 1));
-	TCON_WRITE(sc, TCON1_BASIC4_REG, ((mode->vtotal * 2) << 16) | (vbp - 1));
+	TCON_WRITE(sc, TCON1_BASIC0_REG, ((mode->crtc_hdisplay - 1) << 16) | (mode->crtc_vdisplay - 1));
+	TCON_WRITE(sc, TCON1_BASIC1_REG, ((mode->crtc_hdisplay - 1) << 16) | 

CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 20:28:04 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_lcdc.c

Log Message:
Use actual hw mode, not proposed mode.


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

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 20:24:12 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_mixer.c

Log Message:
Do not assume that an fb's pitch is width * 4 bytes.


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

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 20:24:12 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_mixer.c

Log Message:
Do not assume that an fb's pitch is width * 4 bytes.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_mixer.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/arm/sunxi/sunxi_mixer.c
diff -u src/sys/arch/arm/sunxi/sunxi_mixer.c:1.7 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.8
--- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.7	Sat Feb 16 16:20:50 2019
+++ src/sys/arch/arm/sunxi/sunxi_mixer.c	Sat Nov 23 20:24:12 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_mixer.c,v 1.7 2019/02/16 16:20:50 jmcneill Exp $ */
+/* $NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.7 2019/02/16 16:20:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $");
 
 #include 
 #include 
@@ -255,6 +255,9 @@ sunxi_mixer_mode_do_set_base(struct drm_
 	uint32_t haddr = (paddr >> 32) & OVL_UI_TOP_HADD_LAYER0;
 	uint32_t laddr = paddr & 0x;
 
+	/* Set UI overlay line size */
+	OVL_UI_WRITE(sc, 0, OVL_UI_PITCH(0), sfb->base.pitches[0]);
+
 	/* Framebuffer start address */
 	val = OVL_UI_READ(sc, 0, OVL_UI_TOP_HADD);
 	val &= ~OVL_UI_TOP_HADD_LAYER0;
@@ -367,7 +370,7 @@ sunxi_mixer_cursor_set(struct drm_crtc *
 	/* Set UI overlay offset */
 	OVL_UI_WRITE(sc, 1, OVL_UI_COOR(0), offset);
 	/* Set UI overlay line size */
-	OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), width * 4);
+	OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), crtc->primary->fb->pitches[0]);
 	/* Set UI overlay window size */
 	OVL_UI_WRITE(sc, 1, OVL_UI_SIZE, crtc_size);
 
@@ -491,8 +494,6 @@ sunxi_mixer_mode_set(struct drm_crtc *cr
 	OVL_UI_WRITE(sc, 0, OVL_UI_MBSIZE(0), size);
 	/* Set UI overlay offset */
 	OVL_UI_WRITE(sc, 0, OVL_UI_COOR(0), offset);
-	/* Set UI overlay line size */
-	OVL_UI_WRITE(sc, 0, OVL_UI_PITCH(0), adjusted_mode->hdisplay * 4);
 	/* Set UI overlay window size */
 	OVL_UI_WRITE(sc, 0, OVL_UI_SIZE, size);
 



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 18:57:36 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c

Log Message:
Set TCON1 parent to PLL_VIDEO1(1X)


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/sunxi/sun50i_a64_ccu.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/arm/sunxi/sun50i_a64_ccu.c
diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.17 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.18
--- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.17	Sat Nov 23 12:29:20 2019
+++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c	Sat Nov 23 18:57:36 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $");
 
 #include 
 #include 
@@ -622,5 +622,9 @@ sun50i_a64_ccu_attach(device_t parent, d
 	clk_set_parent(>sc_clks[A64_CLK_DE].base, >sc_clks[A64_CLK_PLL_DE].base);
 	clk_set_rate(>sc_clks[A64_CLK_PLL_DE].base, 42000);
 
+	/* Set TCON1 parent to PLL_VIDEO1(1X) */
+	clk_set_parent(>sc_clks[A64_CLK_TCON1].base, >sc_clks[A64_CLK_PLL_VIDEO1].base);
+	clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO1].base, 29700);
+
 	sunxi_ccu_print(sc);
 }



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 18:57:36 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c

Log Message:
Set TCON1 parent to PLL_VIDEO1(1X)


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 18:55:08 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_dwhdmi.c

Log Message:
Set pixel clock on mode set


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_dwhdmi.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/arm/sunxi/sunxi_dwhdmi.c
diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.6 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.7
--- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.6	Sat Nov 23 12:30:45 2019
+++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c	Sat Nov 23 18:55:08 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $ */
+/* $NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $");
 
 #include 
 #include 
@@ -62,6 +62,7 @@ struct sunxi_dwhdmi_softc {
 	int			sc_phandle;
 	struct fdtbus_phy	*sc_phy;
 	struct fdtbus_regulator	*sc_regulator;
+	struct clk		*sc_clk;
 
 	struct fdt_device_ports	sc_ports;
 	struct drm_display_mode	sc_curmode;
@@ -186,6 +187,15 @@ sunxi_dwhdmi_mode_set(struct dwhdmi_soft
 struct drm_display_mode *adjusted_mode)
 {
 	struct sunxi_dwhdmi_softc * const sc = to_sunxi_dwhdmi_softc(dsc);
+	int error;
+
+	if (sc->sc_clk != NULL) {
+		error = clk_set_rate(sc->sc_clk, adjusted_mode->clock * 1000);
+		if (error != 0)
+			device_printf(sc->sc_base.sc_dev,
+			"couldn't set pixel clock to %u Hz: %d\n",
+			adjusted_mode->clock * 1000, error);
+	}
 
 	sc->sc_curmode = *adjusted_mode;
 }
@@ -229,12 +239,6 @@ sunxi_dwhdmi_attach(device_t parent, dev
 		return;
 	}
 
-	rst = fdtbus_reset_get(phandle, "ctrl");
-	if (rst == NULL || fdtbus_reset_deassert(rst) != 0) {
-		aprint_error(": couldn't de-assert reset\n");
-		return;
-	}
-
 	clk_iahb = fdtbus_clock_get(phandle, "iahb");
 	if (clk_iahb == NULL || clk_enable(clk_iahb) != 0) {
 		aprint_error(": couldn't enable iahb clock\n");
@@ -267,6 +271,7 @@ sunxi_dwhdmi_attach(device_t parent, dev
 	sc->sc_base.sc_scl_hcnt = 0xd8;
 	sc->sc_base.sc_scl_lcnt = 0xfe;
 	sc->sc_phandle = faa->faa_phandle;
+	sc->sc_clk = clk_tmds;
 
 	aprint_naive("\n");
 	aprint_normal(": HDMI TX\n");
@@ -281,6 +286,12 @@ sunxi_dwhdmi_attach(device_t parent, dev
 		return;
 	}
 
+	rst = fdtbus_reset_get(phandle, "ctrl");
+	if (rst == NULL || fdtbus_reset_deassert(rst) != 0) {
+		aprint_error_dev(self, "couldn't de-assert reset\n");
+		return;
+	}
+
 	sunxi_hdmiphy_init(sc->sc_phy);
 
 	if (dwhdmi_attach(>sc_base) != 0) {



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 18:55:08 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_dwhdmi.c

Log Message:
Set pixel clock on mode set


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

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 18:54:26 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_hdmiphy.c

Log Message:
Need to initialize the PHY before HPD sense and DDC will work


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_hdmiphy.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/arm/sunxi/sunxi_hdmiphy.c
diff -u src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.3 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.4
--- src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.3	Sat Nov 23 12:30:45 2019
+++ src/sys/arch/arm/sunxi/sunxi_hdmiphy.c	Sat Nov 23 18:54:26 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $ */
+/* $NetBSD: sunxi_hdmiphy.c,v 1.4 2019/11/23 18:54:26 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.4 2019/11/23 18:54:26 jmcneill Exp $");
 
 #include 
 #include 
@@ -128,6 +128,7 @@ struct sunxi_hdmiphy_softc {
 
 	const struct sunxi_hdmiphy_data *sc_data;
 
+	struct fdtbus_reset	*sc_rst;
 	struct clk		*sc_clk_bus;
 	struct clk		*sc_clk_mod;
 	struct clk		*sc_clk_pll0;
@@ -173,14 +174,6 @@ sunxi_hdmiphy_release(device_t dev, void
 static int
 sunxi_hdmiphy_enable(device_t dev, void *priv, bool enable)
 {
-	struct sunxi_hdmiphy_softc * const sc = priv;
-
-	if (enable) {
-		sc->sc_data->init(sc);
-	} else {
-		sc->sc_data->config(sc, 0);
-	}
-
 	return 0;
 }
 
@@ -421,11 +414,10 @@ sunxi_hdmiphy_attach(device_t parent, de
 	}
 
 	rst = fdtbus_reset_get(phandle, "phy");
-	if (rst == NULL || fdtbus_reset_deassert(rst) != 0) {
-		aprint_error(": couldn't de-assert reset\n");
+	if (rst == NULL) {
+		aprint_error(": couldn't get reset\n");
 		return;
 	}
-
 	clk_bus = fdtbus_clock_get(phandle, "bus");
 	clk_mod = fdtbus_clock_get(phandle, "mod");
 	clk_pll0 = fdtbus_clock_get(phandle, "pll-0");
@@ -441,6 +433,7 @@ sunxi_hdmiphy_attach(device_t parent, de
 		aprint_error(": couldn't map registers\n");
 		return;
 	}
+	sc->sc_rst = rst;
 	sc->sc_clk_bus = clk_bus;
 	sc->sc_clk_mod = clk_mod;
 	sc->sc_clk_pll0 = clk_pll0;
@@ -461,6 +454,10 @@ sunxi_hdmiphy_init(struct fdtbus_phy *ph
 	clk_enable(sc->sc_clk_mod);
 	clk_enable(sc->sc_clk_pll0);
 
+	fdtbus_reset_deassert(sc->sc_rst);
+
+	sc->sc_data->init(sc);
+
 	PHY_WRITE(sc, READ_EN, READ_EN_MAGIC);
 	PHY_WRITE(sc, UNSCRAMBLE, UNSCRAMBLE_MAGIC);
 



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 18:54:26 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_hdmiphy.c

Log Message:
Need to initialize the PHY before HPD sense and DDC will work


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

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 18:52:09 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c

Log Message:
Honour SUNXI_CCU_FRACTIONAL_SET_ENABLE in fractional mode


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.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/arm/sunxi/sunxi_ccu_fractional.c
diff -u src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.4 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.5
--- src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.4	Wed Jan 30 01:24:00 2019
+++ src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c	Sat Nov 23 18:52:09 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu_fractional.c,v 1.4 2019/01/30 01:24:00 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.4 2019/01/30 01:24:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $");
 
 #include 
 #include 
@@ -140,6 +140,8 @@ sunxi_ccu_fractional_set_rate(struct sun
 			val &= ~fractional->div_en;
 			val &= ~fractional->frac_sel;
 			val |= __SHIFTIN(i, fractional->frac_sel);
+			if (fractional->flags & SUNXI_CCU_FRACTIONAL_SET_ENABLE)
+val |= fractional->enable;
 			CCU_WRITE(sc, fractional->reg, val);
 			return 0;
 		}



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 18:52:09 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c

Log Message:
Honour SUNXI_CCU_FRACTIONAL_SET_ENABLE in fractional mode


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 12:30:45 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_dwhdmi.c sunxi_hdmiphy.c sunxi_hdmiphy.h

Log Message:
HDMI PHY and TX share the same clocks. Do not enable clocks until both
reset resources have been deasserted. Explicitly set DDC clock dividers.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_hdmiphy.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/arm/sunxi/sunxi_dwhdmi.c
diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.5 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.6
--- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.5	Fri Nov 22 19:48:58 2019
+++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c	Sat Nov 23 12:30:45 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $ */
+/* $NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $");
 
 #include 
 #include 
@@ -101,13 +101,6 @@ sunxi_dwhdmi_ep_activate(device_t dev, s
 	if (encoder == NULL)
 		return EINVAL;
 
-	sc->sc_phy = fdtbus_phy_get(sc->sc_phandle, "hdmi-phy");
-	if (sc->sc_phy == NULL) {
-		device_printf(dev, "couldn't find hdmi-phy\n");
-		return ENXIO;
-	}
-
-	sc->sc_regulator = fdtbus_regulator_acquire(sc->sc_phandle, "hvcc-supply");
 	if (sc->sc_regulator != NULL) {
 		error = fdtbus_regulator_enable(sc->sc_regulator);
 		if (error != 0) {
@@ -271,11 +264,25 @@ sunxi_dwhdmi_attach(device_t parent, dev
 	sc->sc_base.sc_enable = sunxi_dwhdmi_enable;
 	sc->sc_base.sc_disable = sunxi_dwhdmi_disable;
 	sc->sc_base.sc_mode_set = sunxi_dwhdmi_mode_set;
+	sc->sc_base.sc_scl_hcnt = 0xd8;
+	sc->sc_base.sc_scl_lcnt = 0xfe;
 	sc->sc_phandle = faa->faa_phandle;
 
 	aprint_naive("\n");
 	aprint_normal(": HDMI TX\n");
 
+	sc->sc_regulator = fdtbus_regulator_acquire(sc->sc_phandle, "hvcc-supply");
+
+	sc->sc_phy = fdtbus_phy_get(sc->sc_phandle, "hdmi-phy");
+	if (sc->sc_phy == NULL)
+		sc->sc_phy = fdtbus_phy_get(sc->sc_phandle, "phy");
+	if (sc->sc_phy == NULL) {
+		device_printf(self, "couldn't find PHY\n");
+		return;
+	}
+
+	sunxi_hdmiphy_init(sc->sc_phy);
+
 	if (dwhdmi_attach(>sc_base) != 0) {
 		aprint_error_dev(self, "failed to attach driver\n");
 		return;

Index: src/sys/arch/arm/sunxi/sunxi_hdmiphy.c
diff -u src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.2 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.3
--- src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.2	Thu Jan 31 01:49:28 2019
+++ src/sys/arch/arm/sunxi/sunxi_hdmiphy.c	Sat Nov 23 12:30:45 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_hdmiphy.c,v 1.2 2019/01/31 01:49:28 jmcneill Exp $ */
+/* $NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.2 2019/01/31 01:49:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $");
 
 #include 
 #include 
@@ -128,6 +128,8 @@ struct sunxi_hdmiphy_softc {
 
 	const struct sunxi_hdmiphy_data *sc_data;
 
+	struct clk		*sc_clk_bus;
+	struct clk		*sc_clk_mod;
 	struct clk		*sc_clk_pll0;
 
 	u_int			sc_rcalib;
@@ -425,20 +427,10 @@ sunxi_hdmiphy_attach(device_t parent, de
 	}
 
 	clk_bus = fdtbus_clock_get(phandle, "bus");
-	if (clk_bus == NULL || clk_enable(clk_bus) != 0) {
-		aprint_error(": couldn't enable bus clock\n");
-		return;
-	}
-
 	clk_mod = fdtbus_clock_get(phandle, "mod");
-	if (clk_mod == NULL || clk_enable(clk_mod) != 0) {
-		aprint_error(": couldn't enable mod clock\n");
-		return;
-	}
-
 	clk_pll0 = fdtbus_clock_get(phandle, "pll-0");
-	if (clk_pll0 == NULL || clk_enable(clk_pll0) != 0) {
-		aprint_error(": couldn't enable pll-0 clock\n");
+	if (clk_bus == NULL || clk_mod == NULL || clk_pll0 == NULL) {
+		aprint_error(": couldn't get clocks\n");
 		return;
 	}
 
@@ -449,12 +441,25 @@ sunxi_hdmiphy_attach(device_t parent, de
 		aprint_error(": couldn't map registers\n");
 		return;
 	}
+	sc->sc_clk_bus = clk_bus;
+	sc->sc_clk_mod = clk_mod;
 	sc->sc_clk_pll0 = clk_pll0;
 
 	aprint_naive("\n");
 	aprint_normal(": HDMI PHY\n");
 
 	fdtbus_register_phy_controller(self, phandle, _hdmiphy_funcs);
+}
+
+void
+sunxi_hdmiphy_init(struct fdtbus_phy *phy)
+{
+	device_t dev = fdtbus_phy_device(phy);
+	struct sunxi_hdmiphy_softc * const sc = device_private(dev);
+
+	clk_enable(sc->sc_clk_bus);
+	clk_enable(sc->sc_clk_mod);
+	clk_enable(sc->sc_clk_pll0);
 
 	PHY_WRITE(sc, READ_EN, READ_EN_MAGIC);
 	PHY_WRITE(sc, UNSCRAMBLE, UNSCRAMBLE_MAGIC);

Index: 

CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 12:30:45 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_dwhdmi.c sunxi_hdmiphy.c sunxi_hdmiphy.h

Log Message:
HDMI PHY and TX share the same clocks. Do not enable clocks until both
reset resources have been deasserted. Explicitly set DDC clock dividers.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_hdmiphy.h

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 12:29:20 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c

Log Message:
Add TCON0 clock


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 12:29:20 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c

Log Message:
Add TCON0 clock


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/sunxi/sun50i_a64_ccu.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/arm/sunxi/sun50i_a64_ccu.c
diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.16 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.17
--- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.16	Fri Nov 22 19:46:38 2019
+++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c	Sat Nov 23 12:29:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $");
 
 #include 
 #include 
@@ -69,6 +69,7 @@ __KERNEL_RCSID(1, "$NetBSD: sun50i_a64_c
 #define	DRAM_CFG_REG		0x0f4
 #define	MBUS_RST_REG		0x0fc
 #define	DE_CLK_REG		0x104
+#define	TCON0_CLK_REG		0x118
 #define	TCON1_CLK_REG		0x11c
 #define	AC_DIG_CLK_REG		0x140
 #define	HDMI_CLK_REG		0x150
@@ -161,6 +162,7 @@ static const char *de_parents[] = { "pll
 static const char *hdmi_parents[] = { "pll_video0", "pll_video1" };
 static const char *i2s_parents[] = { "pll_audio_8x", "pll_audio_4x", "pll_audio_2x", "pll_audio" };
 static const char *spi_parents[] = { "hosc", "pll_periph0", "pll_periph1", NULL };
+static const char *tcon0_parents[] = { "pll_mipi", NULL, "pll_video0_2x", NULL };
 static const char *tcon1_parents[] = { "pll_video0", NULL, "pll_video1", NULL };
 static const char *gpu_parents[] = { "pll_gpu" };
 
@@ -459,6 +461,13 @@ static struct sunxi_ccu_clk sun50i_a64_c
 	__BIT(31),		/* enable */
 	SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN),
 
+	SUNXI_CCU_DIV_GATE(A64_CLK_TCON0, "tcon0", tcon0_parents,
+	TCON0_CLK_REG,	/* reg */
+	0,			/* div */
+	__BITS(26,24),	/* sel */
+	__BIT(31),		/* enable */
+	0),
+
 	SUNXI_CCU_DIV_GATE(A64_CLK_TCON1, "tcon1", tcon1_parents,
 	TCON1_CLK_REG,	/* reg */
 	__BITS(3,0),	/* div */



CVS commit: src/sys/arch/arm/sunxi

2019-11-22 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Nov 23 03:59:39 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_ccu.h

Log Message:
Store the flags passed to SUNXI_CCU_FRACTIONAL macro.

Previously the macro dropped the flags argument entirely, and did not
initialize the structure with it.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/sunxi/sunxi_ccu.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/arm/sunxi/sunxi_ccu.h
diff -u src/sys/arch/arm/sunxi/sunxi_ccu.h:1.21 src/sys/arch/arm/sunxi/sunxi_ccu.h:1.22
--- src/sys/arch/arm/sunxi/sunxi_ccu.h:1.21	Wed Jan 30 01:24:00 2019
+++ src/sys/arch/arm/sunxi/sunxi_ccu.h	Sat Nov 23 03:59:39 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu.h,v 1.21 2019/01/30 01:24:00 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu.h,v 1.22 2019/11/23 03:59:39 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -405,6 +405,7 @@ const char *sunxi_ccu_fractional_get_par
 		.u.fractional.frac[0] = (_frac0),			\
 		.u.fractional.frac[1] = (_frac1),			\
 		.u.fractional.enable = (_enable),			\
+		.u.fractional.flags = (_flags),\
 		.enable = sunxi_ccu_fractional_enable,			\
 		.get_rate = sunxi_ccu_fractional_get_rate,		\
 		.set_rate = sunxi_ccu_fractional_set_rate,		\



CVS commit: src/sys/arch/arm/sunxi

2019-11-22 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Nov 23 03:59:39 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_ccu.h

Log Message:
Store the flags passed to SUNXI_CCU_FRACTIONAL macro.

Previously the macro dropped the flags argument entirely, and did not
initialize the structure with it.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/sunxi/sunxi_ccu.h

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 22 19:48:58 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_dwhdmi.c

Log Message:
Enable TMDS clock


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_dwhdmi.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/arm/sunxi/sunxi_dwhdmi.c
diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.4 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.5
--- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.4	Sun Nov 17 17:33:34 2019
+++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c	Fri Nov 22 19:48:58 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_dwhdmi.c,v 1.4 2019/11/17 17:33:34 jmcneill Exp $ */
+/* $NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.4 2019/11/17 17:33:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $");
 
 #include 
 #include 
@@ -226,7 +226,7 @@ sunxi_dwhdmi_attach(device_t parent, dev
 	struct sunxi_dwhdmi_softc * const sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
 	const int phandle = faa->faa_phandle;
-	struct clk *clk_iahb, *clk_isfr;
+	struct clk *clk_iahb, *clk_isfr, *clk_tmds;
 	struct fdtbus_reset *rst;
 	bus_addr_t addr;
 	bus_size_t size;
@@ -254,6 +254,12 @@ sunxi_dwhdmi_attach(device_t parent, dev
 		return;
 	}
 
+	clk_tmds = fdtbus_clock_get(phandle, "tmds");
+	if (clk_tmds == NULL || clk_enable(clk_tmds) != 0) {
+		aprint_error(": couldn't enable tmds clock\n");
+		return;
+	}
+
 	sc->sc_base.sc_dev = self;
 	sc->sc_base.sc_reg_width = 1;
 	sc->sc_base.sc_bst = faa->faa_bst;



CVS commit: src/sys/arch/arm/sunxi

2019-11-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 22 19:48:58 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_dwhdmi.c

Log Message:
Enable TMDS clock


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c

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



CVS commit: src/sys/arch/arm/sunxi

2019-11-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 22 19:46:38 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c

Log Message:
Fix CLK_BUS_HDMI bit


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sunxi/sun50i_a64_ccu.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/arm/sunxi/sun50i_a64_ccu.c
diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.15 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.16
--- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.15	Sun Nov 17 19:51:12 2019
+++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c	Fri Nov 22 19:46:38 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $");
 
 #include 
 #include 
@@ -521,7 +521,7 @@ static struct sunxi_ccu_clk sun50i_a64_c
 	SUNXI_CCU_GATE(A64_CLK_BUS_CSI, "bus-csi", "ahb1",
 	BUS_CLK_GATING_REG1, 8),
 	SUNXI_CCU_GATE(A64_CLK_BUS_HDMI, "bus-hdmi", "ahb1",
-	BUS_CLK_GATING_REG1, 10),
+	BUS_CLK_GATING_REG1, 11),
 	SUNXI_CCU_GATE(A64_CLK_BUS_DE, "bus-de", "ahb1",
 	BUS_CLK_GATING_REG1, 12),
 	SUNXI_CCU_GATE(A64_CLK_BUS_GPU, "bus-gpu", "ahb1",



CVS commit: src/sys/arch/arm/sunxi

2019-11-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 17 19:51:12 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c

Log Message:
Add SPI clocks


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun50i_a64_ccu.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/arm/sunxi/sun50i_a64_ccu.c
diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.14 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.15
--- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.14	Sun Nov 17 17:33:17 2019
+++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c	Sun Nov 17 19:51:12 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_ccu.c,v 1.14 2019/11/17 17:33:17 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.14 2019/11/17 17:33:17 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $");
 
 #include 
 #include 
@@ -60,6 +60,8 @@ __KERNEL_RCSID(1, "$NetBSD: sun50i_a64_c
 #define	SDMMC0_CLK_REG		0x088
 #define	SDMMC1_CLK_REG		0x08c
 #define	SDMMC2_CLK_REG		0x090
+#define	SPI0_CLK_REG		0x0a0
+#define	SPI1_CLK_REG		0x0a4
 #define	I2SPCM0_CLK_REG		0x0b0
 #define	I2SPCM1_CLK_REG		0x0b4
 #define	I2SPCM2_CLK_REG		0x0b8
@@ -158,6 +160,7 @@ static const char *ths_parents[] = { "ho
 static const char *de_parents[] = { "pll_periph0_2x", "pll_de" };
 static const char *hdmi_parents[] = { "pll_video0", "pll_video1" };
 static const char *i2s_parents[] = { "pll_audio_8x", "pll_audio_4x", "pll_audio_2x", "pll_audio" };
+static const char *spi_parents[] = { "hosc", "pll_periph0", "pll_periph1", NULL };
 static const char *tcon1_parents[] = { "pll_video0", NULL, "pll_video1", NULL };
 static const char *gpu_parents[] = { "pll_gpu" };
 
@@ -260,6 +263,16 @@ static struct sunxi_ccu_clk sun50i_a64_c
 	SUNXI_CCU_NKMP_DIVIDE_BY_TWO),
 	SUNXI_CCU_FIXED_FACTOR(A64_CLK_PLL_PERIPH0_2X, "pll_periph0_2x", "pll_periph0", 1, 2),
 
+	SUNXI_CCU_NKMP(A64_CLK_PLL_PERIPH1, "pll_periph1", "hosc",
+	PLL_PERIPH1_CTRL_REG,	/* reg */
+	__BITS(12,8),		/* n */
+	__BITS(5,4), 		/* k */
+	0,/* m */
+	__BITS(17,16),		/* p */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NKMP_DIVIDE_BY_TWO),
+	SUNXI_CCU_FIXED_FACTOR(A64_CLK_PLL_PERIPH1_2X, "pll_periph1_2x", "pll_periph1", 1, 2),
+
 	SUNXI_CCU_NKMP_TABLE(A64_CLK_PLL_AUDIO_BASE, "pll_audio_base", "hosc",
 	PLL_AUDIO_CTRL_REG,		/* reg */
 	__BITS(14,8),		/* n */
@@ -430,6 +443,21 @@ static struct sunxi_ccu_clk sun50i_a64_c
 	__BIT(31),		/* enable */
 	0),
 
+	SUNXI_CCU_NM(A64_CLK_SPI0, "spi0", spi_parents,
+	SPI0_CLK_REG,	/* reg */
+	__BITS(17,16),	/* n */
+	__BITS(3,0),	/* m */
+	__BITS(25,24),	/* sel */
+	__BIT(31),		/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN),
+
+	SUNXI_CCU_NM(A64_CLK_SPI1, "spi1", spi_parents,
+	SPI1_CLK_REG,	/* reg */
+	__BITS(17,16),	/* n */
+	__BITS(3,0),	/* m */
+	__BITS(25,24),	/* sel */
+	__BIT(31),		/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN),
 
 	SUNXI_CCU_DIV_GATE(A64_CLK_TCON1, "tcon1", tcon1_parents,
 	TCON1_CLK_REG,	/* reg */



CVS commit: src/sys/arch/arm/sunxi

2019-11-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 17 19:51:12 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_ccu.c

Log Message:
Add SPI clocks


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c

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



  1   2   3   4   5   6   7   8   >