Trailing whitespacediff -r1.25 -r1.25.30.1 src/sys/arch/arm/broadcom/bcm53xx_board.c
(skrll)
--- src/sys/arch/arm/broadcom/bcm53xx_board.c 2018/07/31 06:46:25 1.25
+++ src/sys/arch/arm/broadcom/bcm53xx_board.c 2024/02/16 12:07:07 1.25.30.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bcm53xx_board.c,v 1.25 2018/07/31 06:46:25 skrll Exp $ */ | 1 | /* $NetBSD: bcm53xx_board.c,v 1.25.30.1 2024/02/16 12:07:07 skrll Exp $ */ | |
2 | /*- | 2 | /*- | |
3 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | 3 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * This code is derived from software contributed to The NetBSD Foundation | 6 | * This code is derived from software contributed to The NetBSD Foundation | |
7 | * by Matt Thomas of 3am Software Foundry. | 7 | * by Matt Thomas of 3am Software Foundry. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
28 | * POSSIBILITY OF SUCH DAMAGE. | 28 | * POSSIBILITY OF SUCH DAMAGE. | |
29 | */ | 29 | */ | |
30 | 30 | |||
31 | #include "opt_arm_debug.h" | 31 | #include "opt_arm_debug.h" | |
32 | #include "opt_broadcom.h" | 32 | #include "opt_broadcom.h" | |
33 | #include "arml2cc.h" | 33 | #include "arml2cc.h" | |
34 | 34 | |||
35 | #define _ARM32_BUS_DMA_PRIVATE | 35 | #define _ARM32_BUS_DMA_PRIVATE | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | 38 | |||
39 | __KERNEL_RCSID(1, "$NetBSD: bcm53xx_board.c,v 1.25 2018/07/31 06:46:25 skrll Exp $"); | 39 | __KERNEL_RCSID(1, "$NetBSD: bcm53xx_board.c,v 1.25.30.1 2024/02/16 12:07:07 skrll Exp $"); | |
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/bus.h> | 42 | #include <sys/bus.h> | |
43 | #include <sys/cpu.h> | 43 | #include <sys/cpu.h> | |
44 | #include <sys/device.h> | 44 | #include <sys/device.h> | |
45 | 45 | |||
46 | #include <prop/proplib.h> | 46 | #include <prop/proplib.h> | |
47 | 47 | |||
48 | #include <net/if.h> | 48 | #include <net/if.h> | |
49 | #include <net/if_ether.h> | 49 | #include <net/if_ether.h> | |
50 | 50 | |||
51 | #define CCA_PRIVATE | 51 | #define CCA_PRIVATE | |
52 | #define CRU_PRIVATE | 52 | #define CRU_PRIVATE | |
@@ -318,66 +318,66 @@ bcm53xx_lcpll_clock_init(struct bcm53xx_ | @@ -318,66 +318,66 @@ bcm53xx_lcpll_clock_init(struct bcm53xx_ | |||
318 | clk->clk_sdio = clk->clk_lcpll / ch1_mdiv; // LCPLL CH1 | 318 | clk->clk_sdio = clk->clk_lcpll / ch1_mdiv; // LCPLL CH1 | |
319 | clk->clk_ddr_ref = clk->clk_lcpll / ch2_mdiv; // LCPLL CH2 | 319 | clk->clk_ddr_ref = clk->clk_lcpll / ch2_mdiv; // LCPLL CH2 | |
320 | clk->clk_axi = clk->clk_lcpll / ch3_mdiv; // LCPLL CH3 | 320 | clk->clk_axi = clk->clk_lcpll / ch3_mdiv; // LCPLL CH3 | |
321 | } | 321 | } | |
322 | 322 | |||
323 | static void | 323 | static void | |
324 | bcm53xx_usb_clock_init(struct bcm53xx_clock_info *clk, uint32_t usb2_control) | 324 | bcm53xx_usb_clock_init(struct bcm53xx_clock_info *clk, uint32_t usb2_control) | |
325 | { | 325 | { | |
326 | const uint32_t pdiv = bcm53xx_value_wrap(usb2_control, | 326 | const uint32_t pdiv = bcm53xx_value_wrap(usb2_control, | |
327 | USB2_CONTROL_PDIV); | 327 | USB2_CONTROL_PDIV); | |
328 | const uint32_t ndiv = bcm53xx_value_wrap(usb2_control, | 328 | const uint32_t ndiv = bcm53xx_value_wrap(usb2_control, | |
329 | USB2_CONTROL_NDIV_INT); | 329 | USB2_CONTROL_NDIV_INT); | |
330 | 330 | |||
331 | uint32_t usb_ref = (clk->clk_usb2 / pdiv) * ndiv; | 331 | uint32_t usb_ref = (clk->clk_usb2 / pdiv) * ndiv; | |
332 | if (usb_ref != USB2_REF_CLK) { | 332 | if (usb_ref != USB2_REF_CLK) { | |
333 | /* | 333 | /* | |
334 | * USB Reference Clock isn't 1.92GHz. So we need to modify | 334 | * USB Reference Clock isn't 1.92GHz. So we need to modify | |
335 | * USB2_CONTROL to produce it. | 335 | * USB2_CONTROL to produce it. | |
336 | */ | 336 | */ | |
337 | uint32_t new_ndiv = (USB2_REF_CLK / clk->clk_usb2) * pdiv; | 337 | uint32_t new_ndiv = (USB2_REF_CLK / clk->clk_usb2) * pdiv; | |
338 | usb2_control &= ~USB2_CONTROL_NDIV_INT; | 338 | usb2_control &= ~USB2_CONTROL_NDIV_INT; | |
339 | usb2_control |= __SHIFTIN(new_ndiv, USB2_CONTROL_NDIV_INT); | 339 | usb2_control |= __SHIFTIN(new_ndiv, USB2_CONTROL_NDIV_INT); | |
340 | 340 | |||
341 | // Allow Clocks to be modified | 341 | // Allow Clocks to be modified | |
342 | bus_space_write_4(bcm53xx_ioreg_bst, bcm53xx_ioreg_bsh, | 342 | bus_space_write_4(bcm53xx_ioreg_bst, bcm53xx_ioreg_bsh, | |
343 | CRU_BASE + CRU_CLKSET_KEY, CRU_CLKSET_KEY_MAGIC); | 343 | CRU_BASE + CRU_CLKSET_KEY, CRU_CLKSET_KEY_MAGIC); | |
344 | 344 | |||
345 | // Update USB2 clock generator | 345 | // Update USB2 clock generator | |
346 | bus_space_write_4(bcm53xx_ioreg_bst, bcm53xx_ioreg_bsh, | 346 | bus_space_write_4(bcm53xx_ioreg_bst, bcm53xx_ioreg_bsh, | |
347 | CRU_BASE + CRU_USB2_CONTROL, usb2_control); | 347 | CRU_BASE + CRU_USB2_CONTROL, usb2_control); | |
348 | 348 | |||
349 | // Prevent Clock modification | 349 | // Prevent Clock modification | |
350 | bus_space_write_4(bcm53xx_ioreg_bst, bcm53xx_ioreg_bsh, | 350 | bus_space_write_4(bcm53xx_ioreg_bst, bcm53xx_ioreg_bsh, | |
351 | CRU_BASE + CRU_CLKSET_KEY, 0); | 351 | CRU_BASE + CRU_CLKSET_KEY, 0); | |
352 | 352 | |||
353 | usb_ref = (clk->clk_usb2 / pdiv) * new_ndiv; | 353 | usb_ref = (clk->clk_usb2 / pdiv) * new_ndiv; | |
354 | } | 354 | } | |
355 | 355 | |||
356 | clk->clk_usb_ref = usb_ref; | 356 | clk->clk_usb_ref = usb_ref; | |
357 | } | 357 | } | |
358 | 358 | |||
359 | 359 | |||
360 | static void | 360 | static void | |
361 | bcm53xx_clock_init(struct bcm53xx_clock_info *clk) | 361 | bcm53xx_clock_init(struct bcm53xx_clock_info *clk) | |
362 | { | 362 | { | |
363 | clk->clk_ref = BCM53XX_REF_CLK; | 363 | clk->clk_ref = BCM53XX_REF_CLK; | |
364 | clk->clk_sys = 8*clk->clk_ref; | 364 | clk->clk_sys = 8*clk->clk_ref; | |
365 | } | 365 | } | |
366 | 366 | |||
367 | /* | 367 | /* | |
368 | * F(ddr) = ((1 / pdiv) * ndiv * CH2) / (post_div * 2) | 368 | * F(ddr) = ((1 / pdiv) * ndiv * CH2) / (post_div * 2) | |
369 | */ | 369 | */ | |
370 | static void | 370 | static void | |
371 | bcm53xx_get_ddr_freq(struct bcm53xx_clock_info *clk, uint32_t pll_status, | 371 | bcm53xx_get_ddr_freq(struct bcm53xx_clock_info *clk, uint32_t pll_status, | |
372 | uint32_t pll_dividers) | 372 | uint32_t pll_dividers) | |
373 | { | 373 | { | |
374 | const bool clocking_4x = (pll_status & PLL_STATUS_CLOCKING_4X) != 0; | 374 | const bool clocking_4x = (pll_status & PLL_STATUS_CLOCKING_4X) != 0; | |
375 | u_int post_div = __SHIFTOUT(pll_dividers, PLL_DIVIDERS_POST_DIV); | 375 | u_int post_div = __SHIFTOUT(pll_dividers, PLL_DIVIDERS_POST_DIV); | |
376 | u_int pdiv = __SHIFTOUT(pll_dividers, PLL_DIVIDERS_PDIV); | 376 | u_int pdiv = __SHIFTOUT(pll_dividers, PLL_DIVIDERS_PDIV); | |
377 | u_int ndiv = __SHIFTOUT(pll_dividers, PLL_DIVIDERS_NDIV); | 377 | u_int ndiv = __SHIFTOUT(pll_dividers, PLL_DIVIDERS_NDIV); | |
378 | 378 | |||
379 | pdiv = ((pdiv - (clocking_4x ? 1 : 5)) & 7) + 1; | 379 | pdiv = ((pdiv - (clocking_4x ? 1 : 5)) & 7) + 1; | |
380 | 380 | |||
381 | clk->clk_ddr_mhz = __SHIFTOUT(pll_status, PLL_STATUS_MHZ); | 381 | clk->clk_ddr_mhz = __SHIFTOUT(pll_status, PLL_STATUS_MHZ); | |
382 | clk->clk_ddr = (clk->clk_ddr_ref / pdiv) * ndiv / (2 + post_div); | 382 | clk->clk_ddr = (clk->clk_ddr_ref / pdiv) * ndiv / (2 + post_div); | |
383 | } | 383 | } | |
@@ -392,27 +392,27 @@ bcm53xx_get_cpu_freq(struct bcm53xx_cloc | @@ -392,27 +392,27 @@ bcm53xx_get_cpu_freq(struct bcm53xx_cloc | |||
392 | policy = __SHIFTOUT(policy, CLK_POLICY_FREQ_POLICY2); | 392 | policy = __SHIFTOUT(policy, CLK_POLICY_FREQ_POLICY2); | |
393 | 393 | |||
394 | if (policy == CLK_POLICY_REF_CLK) { | 394 | if (policy == CLK_POLICY_REF_CLK) { | |
395 | clk->clk_cpu = clk->clk_ref; | 395 | clk->clk_cpu = clk->clk_ref; | |
396 | clk->clk_apb = clk->clk_cpu; | 396 | clk->clk_apb = clk->clk_cpu; | |
397 | return; | 397 | return; | |
398 | } | 398 | } | |
399 | 399 | |||
400 | if (policy == CLK_POLICY_SYS_CLK) { | 400 | if (policy == CLK_POLICY_SYS_CLK) { | |
401 | clk->clk_cpu = clk->clk_sys; | 401 | clk->clk_cpu = clk->clk_sys; | |
402 | clk->clk_apb = clk->clk_cpu / 4; | 402 | clk->clk_apb = clk->clk_cpu / 4; | |
403 | return; | 403 | return; | |
404 | } | 404 | } | |
405 | 405 | |||
406 | const u_int pdiv = bcm53xx_value_wrap(pllarma, CLK_PLLARMA_PDIV); | 406 | const u_int pdiv = bcm53xx_value_wrap(pllarma, CLK_PLLARMA_PDIV); | |
407 | const u_int ndiv_int = bcm53xx_value_wrap(pllarma, CLK_PLLARMA_NDIV_INT); | 407 | const u_int ndiv_int = bcm53xx_value_wrap(pllarma, CLK_PLLARMA_NDIV_INT); | |
408 | const u_int ndiv_frac = __SHIFTOUT(pllarmb, CLK_PLLARMB_NDIV_FRAC); | 408 | const u_int ndiv_frac = __SHIFTOUT(pllarmb, CLK_PLLARMB_NDIV_FRAC); | |
409 | // const u_int apb_clk_div = __SHIFTOUT(apb_clk_div, CLK_APB_DIV_VALUE)+1; | 409 | // const u_int apb_clk_div = __SHIFTOUT(apb_clk_div, CLK_APB_DIV_VALUE)+1; | |
410 | 410 | |||
411 | const u_int cpu_div = (policy == CLK_POLICY_ARM_PLL_CH0) ? 4 : 2; | 411 | const u_int cpu_div = (policy == CLK_POLICY_ARM_PLL_CH0) ? 4 : 2; | |
412 | 412 | |||
413 | clk->clk_cpu = bcm53xx_freq_calc(clk, pdiv, ndiv_int, ndiv_frac) / cpu_div; | 413 | clk->clk_cpu = bcm53xx_freq_calc(clk, pdiv, ndiv_int, ndiv_frac) / cpu_div; | |
414 | clk->clk_apb = clk->clk_cpu / 4; | 414 | clk->clk_apb = clk->clk_cpu / 4; | |
415 | } | 415 | } | |
416 | 416 | |||
417 | struct bcm53xx_chip_state { | 417 | struct bcm53xx_chip_state { | |
418 | uint32_t bcs_lcpll_control1; | 418 | uint32_t bcs_lcpll_control1; | |
@@ -595,33 +595,33 @@ bcm53xx_cpu_hatch(struct cpu_info *ci) | @@ -595,33 +595,33 @@ bcm53xx_cpu_hatch(struct cpu_info *ci) | |||
595 | #endif | 595 | #endif | |
596 | 596 | |||
597 | void | 597 | void | |
598 | bcm53xx_device_register(device_t self, void *aux) | 598 | bcm53xx_device_register(device_t self, void *aux) | |
599 | { | 599 | { | |
600 | prop_dictionary_t dict = device_properties(self); | 600 | prop_dictionary_t dict = device_properties(self); | |
601 | 601 | |||
602 | if (device_is_a(self, "armperiph") | 602 | if (device_is_a(self, "armperiph") | |
603 | && device_is_a(device_parent(self), "mainbus")) { | 603 | && device_is_a(device_parent(self), "mainbus")) { | |
604 | /* | 604 | /* | |
605 | * XXX KLUDGE ALERT XXX | 605 | * XXX KLUDGE ALERT XXX | |
606 | * The iot mainbus supplies is completely wrong since it scales | 606 | * The iot mainbus supplies is completely wrong since it scales | |
607 | * addresses by 2. The simplest remedy is to replace with our | 607 | * addresses by 2. The simplest remedy is to replace with our | |
608 | * bus space used for the armcore registers (which armperiph uses). | 608 | * bus space used for the armcore registers (which armperiph uses). | |
609 | */ | 609 | */ | |
610 | struct mainbus_attach_args * const mb = aux; | 610 | struct mainbus_attach_args * const mb = aux; | |
611 | mb->mb_iot = bcm53xx_armcore_bst; | 611 | mb->mb_iot = bcm53xx_armcore_bst; | |
612 | return; | 612 | return; | |
613 | } | 613 | } | |
614 | 614 | |||
615 | /* | 615 | /* | |
616 | * We need to tell the A9 Global/Watchdog Timer | 616 | * We need to tell the A9 Global/Watchdog Timer | |
617 | * what frequency it runs at. | 617 | * what frequency it runs at. | |
618 | */ | 618 | */ | |
619 | if (device_is_a(self, "arma9tmr") || device_is_a(self, "a9wdt")) { | 619 | if (device_is_a(self, "arma9tmr") || device_is_a(self, "a9wdt")) { | |
620 | /* | 620 | /* | |
621 | * This clock always runs at (arm_clk div 2) and only goes | 621 | * This clock always runs at (arm_clk div 2) and only goes | |
622 | * to timers that are part of the A9 MP core subsystem. | 622 | * to timers that are part of the A9 MP core subsystem. | |
623 | */ | 623 | */ | |
624 | prop_dictionary_set_uint32(dict, "frequency", | 624 | prop_dictionary_set_uint32(dict, "frequency", | |
625 | cpu_softc.cpu_clk.clk_cpu / 2); | 625 | cpu_softc.cpu_clk.clk_cpu / 2); | |
626 | return; | 626 | return; | |
627 | } | 627 | } | |
@@ -639,28 +639,28 @@ bcm53xx_device_register(device_t self, v | @@ -639,28 +639,28 @@ bcm53xx_device_register(device_t self, v | |||
639 | } | 639 | } | |
640 | prop_object_release(pd); | 640 | prop_object_release(pd); | |
641 | } | 641 | } | |
642 | } | 642 | } | |
643 | 643 | |||
644 | #ifdef SRAB_BASE | 644 | #ifdef SRAB_BASE | |
645 | static kmutex_t srab_lock __cacheline_aligned; | 645 | static kmutex_t srab_lock __cacheline_aligned; | |
646 | 646 | |||
647 | void | 647 | void | |
648 | bcm53xx_srab_init(void) | 648 | bcm53xx_srab_init(void) | |
649 | { | 649 | { | |
650 | mutex_init(&srab_lock, MUTEX_DEFAULT, IPL_VM); | 650 | mutex_init(&srab_lock, MUTEX_DEFAULT, IPL_VM); | |
651 | 651 | |||
652 | bcm53xx_srab_write_4(0x0079, 0x90); // reset switch | 652 | bcm53xx_srab_write_4(0x0079, 0x90); // reset switch | |
653 | for (u_int port = 0; port < 8; port++) { | 653 | for (u_int port = 0; port < 8; port++) { | |
654 | /* per port control: no stp */ | 654 | /* per port control: no stp */ | |
655 | bcm53xx_srab_write_4(port, 0x00); | 655 | bcm53xx_srab_write_4(port, 0x00); | |
656 | } | 656 | } | |
657 | bcm53xx_srab_write_4(0x0008, 0x1c); // IMP port (enab UC/MC/BC) | 657 | bcm53xx_srab_write_4(0x0008, 0x1c); // IMP port (enab UC/MC/BC) | |
658 | bcm53xx_srab_write_4(0x000e, 0xbb); // IMP port force-link 1G | 658 | bcm53xx_srab_write_4(0x000e, 0xbb); // IMP port force-link 1G | |
659 | bcm53xx_srab_write_4(0x005d, 0x7b); // port5 force-link 1G | 659 | bcm53xx_srab_write_4(0x005d, 0x7b); // port5 force-link 1G | |
660 | bcm53xx_srab_write_4(0x005f, 0x7b); // port7 force-link 1G | 660 | bcm53xx_srab_write_4(0x005f, 0x7b); // port7 force-link 1G | |
661 | bcm53xx_srab_write_4(0x000b, 0x7); // management mode | 661 | bcm53xx_srab_write_4(0x000b, 0x7); // management mode | |
662 | bcm53xx_srab_write_4(0x0203, 0x0); // disable BRCM tag | 662 | bcm53xx_srab_write_4(0x0203, 0x0); // disable BRCM tag | |
663 | bcm53xx_srab_write_4(0x0200, 0x80); // enable IMP=port8 | 663 | bcm53xx_srab_write_4(0x0200, 0x80); // enable IMP=port8 | |
664 | } | 664 | } | |
665 | 665 | |||
666 | static inline void | 666 | static inline void |
--- src/sys/arch/arm/broadcom/bcm53xx_cca.c 2022/03/03 06:26:28 1.5
+++ src/sys/arch/arm/broadcom/bcm53xx_cca.c 2024/02/16 12:07:07 1.5.4.1
@@ -33,27 +33,27 @@ | @@ -33,27 +33,27 @@ | |||
33 | #include "gpio.h" | 33 | #include "gpio.h" | |
34 | #include "bcmcca.h" | 34 | #include "bcmcca.h" | |
35 | 35 | |||
36 | #define CCA_PRIVATE | 36 | #define CCA_PRIVATE | |
37 | #define CRU_PRIVATE | 37 | #define CRU_PRIVATE | |
38 | #define IDM_PRIVATE | 38 | #define IDM_PRIVATE | |
39 | 39 | |||
40 | #if NCOM == 0 | 40 | #if NCOM == 0 | |
41 | #error no console configured | 41 | #error no console configured | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
44 | #include <sys/cdefs.h> | 44 | #include <sys/cdefs.h> | |
45 | 45 | |||
46 | __KERNEL_RCSID(1, "$NetBSD: bcm53xx_cca.c,v 1.5 2022/03/03 06:26:28 riastradh Exp $"); | 46 | __KERNEL_RCSID(1, "$NetBSD: bcm53xx_cca.c,v 1.5.4.1 2024/02/16 12:07:07 skrll Exp $"); | |
47 | 47 | |||
48 | #include <sys/param.h> | 48 | #include <sys/param.h> | |
49 | #include <sys/bus.h> | 49 | #include <sys/bus.h> | |
50 | #include <sys/device.h> | 50 | #include <sys/device.h> | |
51 | #include <sys/intr.h> | 51 | #include <sys/intr.h> | |
52 | #include <sys/systm.h> | 52 | #include <sys/systm.h> | |
53 | #include <sys/time.h> | 53 | #include <sys/time.h> | |
54 | #include <sys/termios.h> | 54 | #include <sys/termios.h> | |
55 | 55 | |||
56 | #include <dev/ic/comreg.h> | 56 | #include <dev/ic/comreg.h> | |
57 | #include <dev/ic/comvar.h> | 57 | #include <dev/ic/comvar.h> | |
58 | 58 | |||
59 | #include <arm/mainbus/mainbus.h> | 59 | #include <arm/mainbus/mainbus.h> | |
@@ -133,27 +133,27 @@ bcmcca_intr(void *arg) | @@ -133,27 +133,27 @@ bcmcca_intr(void *arg) | |||
133 | int rv = 0; | 133 | int rv = 0; | |
134 | 134 | |||
135 | uint32_t v = bcmcca_read_4(sc, MISC_INTSTATUS); | 135 | uint32_t v = bcmcca_read_4(sc, MISC_INTSTATUS); | |
136 | if (v & INTSTATUS_UARTINT) { | 136 | if (v & INTSTATUS_UARTINT) { | |
137 | if (sc->sc_com_softc[0] != NULL) | 137 | if (sc->sc_com_softc[0] != NULL) | |
138 | rv = comintr(sc->sc_com_softc[0]); | 138 | rv = comintr(sc->sc_com_softc[0]); | |
139 | if (sc->sc_com_softc[1] != NULL) { | 139 | if (sc->sc_com_softc[1] != NULL) { | |
140 | int rv0 = comintr(sc->sc_com_softc[1]); | 140 | int rv0 = comintr(sc->sc_com_softc[1]); | |
141 | if (rv) | 141 | if (rv) | |
142 | rv = rv0; | 142 | rv = rv0; | |
143 | } | 143 | } | |
144 | } | 144 | } | |
145 | if (v & INTSTATUS_GPIOINT) { | 145 | if (v & INTSTATUS_GPIOINT) { | |
146 | 146 | |||
147 | } | 147 | } | |
148 | return rv; | 148 | return rv; | |
149 | } | 149 | } | |
150 | 150 | |||
151 | static void | 151 | static void | |
152 | bcmcca_mainbus_attach(device_t parent, device_t self, void *aux) | 152 | bcmcca_mainbus_attach(device_t parent, device_t self, void *aux) | |
153 | { | 153 | { | |
154 | struct bcmcca_softc * const sc = &bcmcca_sc; | 154 | struct bcmcca_softc * const sc = &bcmcca_sc; | |
155 | 155 | |||
156 | sc->sc_dev = self; | 156 | sc->sc_dev = self; | |
157 | device_set_private(self, sc); | 157 | device_set_private(self, sc); | |
158 | 158 | |||
159 | sc->sc_bst = bcm53xx_ioreg_bst; | 159 | sc->sc_bst = bcm53xx_ioreg_bst; |
--- src/sys/arch/arm/broadcom/bcm53xx_idm.c 2012/12/12 00:01:28 1.3
+++ src/sys/arch/arm/broadcom/bcm53xx_idm.c 2024/02/16 12:07:08 1.3.70.1
@@ -25,51 +25,51 @@ | @@ -25,51 +25,51 @@ | |||
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "opt_broadcom.h" | 30 | #include "opt_broadcom.h" | |
31 | #include "locators.h" | 31 | #include "locators.h" | |
32 | 32 | |||
33 | #define CRU_PRIVATE | 33 | #define CRU_PRIVATE | |
34 | #define IDM_PRIVATE | 34 | #define IDM_PRIVATE | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | 37 | |||
38 | __KERNEL_RCSID(1, "$NetBSD: bcm53xx_idm.c,v 1.3 2012/12/12 00:01:28 matt Exp $"); | 38 | __KERNEL_RCSID(1, "$NetBSD: bcm53xx_idm.c,v 1.3.70.1 2024/02/16 12:07:08 skrll Exp $"); | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/bus.h> | 41 | #include <sys/bus.h> | |
42 | #include <sys/device.h> | 42 | #include <sys/device.h> | |
43 | #include <sys/intr.h> | 43 | #include <sys/intr.h> | |
44 | #include <sys/systm.h> | 44 | #include <sys/systm.h> | |
45 | 45 | |||
46 | #include <arm/mainbus/mainbus.h> | 46 | #include <arm/mainbus/mainbus.h> | |
47 | 47 | |||
48 | #include <arm/broadcom/bcm53xx_reg.h> | 48 | #include <arm/broadcom/bcm53xx_reg.h> | |
49 | #include <arm/broadcom/bcm53xx_var.h> | 49 | #include <arm/broadcom/bcm53xx_var.h> | |
50 | 50 | |||
51 | struct idm_info { | 51 | struct idm_info { | |
52 | bus_size_t idm_offset; | 52 | bus_size_t idm_offset; | |
53 | const char *idm_name; | 53 | const char *idm_name; | |
54 | int idm_port; | 54 | int idm_port; | |
55 | bool (*idm_unreset)(bus_space_tag_t, bus_space_handle_t, | 55 | bool (*idm_unreset)(bus_space_tag_t, bus_space_handle_t, | |
56 | const struct idm_info *); | 56 | const struct idm_info *); | |
57 | }; | 57 | }; | |
58 | 58 | |||
59 | static bool | 59 | static bool | |
60 | bcmeth_unreset(bus_space_tag_t bst, bus_space_handle_t bsh, | 60 | bcmeth_unreset(bus_space_tag_t bst, bus_space_handle_t bsh, | |
61 | const struct idm_info *idm) | 61 | const struct idm_info *idm) | |
62 | { | 62 | { | |
63 | /* | 63 | /* | |
64 | * To enable any GMAC, we must enable all off them. | 64 | * To enable any GMAC, we must enable all off them. | |
65 | */ | 65 | */ | |
66 | static const bus_size_t regoff[] = { | 66 | static const bus_size_t regoff[] = { | |
67 | IDM_BASE + IDM_AMAC0_BASE, | 67 | IDM_BASE + IDM_AMAC0_BASE, | |
68 | IDM_BASE + IDM_AMAC1_BASE, | 68 | IDM_BASE + IDM_AMAC1_BASE, | |
69 | IDM_BASE + IDM_AMAC2_BASE, | 69 | IDM_BASE + IDM_AMAC2_BASE, | |
70 | IDM_BASE + IDM_AMAC3_BASE, | 70 | IDM_BASE + IDM_AMAC3_BASE, | |
71 | }; | 71 | }; | |
72 | static bool bcmeth_init_done; | 72 | static bool bcmeth_init_done; | |
73 | if (!bcmeth_init_done) { | 73 | if (!bcmeth_init_done) { | |
74 | for (size_t idx = 0; idx < __arraycount(regoff); idx++) { | 74 | for (size_t idx = 0; idx < __arraycount(regoff); idx++) { | |
75 | const bus_size_t off = regoff[idx]; | 75 | const bus_size_t off = regoff[idx]; |
--- src/sys/arch/arm/broadcom/bcm53xx_pax.c 2021/08/07 16:18:43 1.22
+++ src/sys/arch/arm/broadcom/bcm53xx_pax.c 2024/02/16 12:07:08 1.22.6.1
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #define _ARM32_BUS_DMA_PRIVATE | 30 | #define _ARM32_BUS_DMA_PRIVATE | |
31 | #define PCIE_PRIVATE | 31 | #define PCIE_PRIVATE | |
32 | 32 | |||
33 | #include "locators.h" | 33 | #include "locators.h" | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | 36 | |||
37 | __KERNEL_RCSID(1, "$NetBSD: bcm53xx_pax.c,v 1.22 2021/08/07 16:18:43 thorpej Exp $"); | 37 | __KERNEL_RCSID(1, "$NetBSD: bcm53xx_pax.c,v 1.22.6.1 2024/02/16 12:07:08 skrll Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/bus.h> | 40 | #include <sys/bus.h> | |
41 | #include <sys/device.h> | 41 | #include <sys/device.h> | |
42 | #include <sys/intr.h> | 42 | #include <sys/intr.h> | |
43 | #include <sys/kmem.h> | 43 | #include <sys/kmem.h> | |
44 | #include <sys/systm.h> | 44 | #include <sys/systm.h> | |
45 | 45 | |||
46 | #include <dev/pci/pcireg.h> | 46 | #include <dev/pci/pcireg.h> | |
47 | #include <dev/pci/pcivar.h> | 47 | #include <dev/pci/pcivar.h> | |
48 | #include <dev/pci/pciconf.h> | 48 | #include <dev/pci/pciconf.h> | |
49 | 49 | |||
50 | #include <arm/locore.h> | 50 | #include <arm/locore.h> | |
@@ -261,58 +261,58 @@ bcmpax_ccb_attach(device_t parent, devic | @@ -261,58 +261,58 @@ bcmpax_ccb_attach(device_t parent, devic | |||
261 | sc->sc_pba_flags |= PCI_FLAGS_MRL_OKAY; | 261 | sc->sc_pba_flags |= PCI_FLAGS_MRL_OKAY; | |
262 | sc->sc_pba_flags |= PCI_FLAGS_MRM_OKAY; | 262 | sc->sc_pba_flags |= PCI_FLAGS_MRM_OKAY; | |
263 | sc->sc_pba_flags |= PCI_FLAGS_MWI_OKAY; | 263 | sc->sc_pba_flags |= PCI_FLAGS_MWI_OKAY; | |
264 | // sc->sc_pba_flags |= PCI_FLAGS_MSI_OKAY; | 264 | // sc->sc_pba_flags |= PCI_FLAGS_MSI_OKAY; | |
265 | // sc->sc_pba_flags |= PCI_FLAGS_MSIX_OKAY; | 265 | // sc->sc_pba_flags |= PCI_FLAGS_MSIX_OKAY; | |
266 | 266 | |||
267 | for (size_t i = 0; i < loc->loc_nintrs; i++) { | 267 | for (size_t i = 0; i < loc->loc_nintrs; i++) { | |
268 | sc->sc_ih[i] = intr_establish(loc->loc_intrs[0] + i, IPL_VM, | 268 | sc->sc_ih[i] = intr_establish(loc->loc_intrs[0] + i, IPL_VM, | |
269 | IST_LEVEL, bcmpax_intr, sc); | 269 | IST_LEVEL, bcmpax_intr, sc); | |
270 | if (sc->sc_ih[i] == NULL) { | 270 | if (sc->sc_ih[i] == NULL) { | |
271 | aprint_error_dev(self, | 271 | aprint_error_dev(self, | |
272 | "failed to establish interrupt #%zu (%zu)\n", i, | 272 | "failed to establish interrupt #%zu (%zu)\n", i, | |
273 | loc->loc_intrs[0] + i); | 273 | loc->loc_intrs[0] + i); | |
274 | while (i-- > 0) { | 274 | while (i-- > 0) { | |
275 | intr_disestablish(sc->sc_ih[i]); | 275 | intr_disestablish(sc->sc_ih[i]); | |
276 | } | 276 | } | |
277 | return; | 277 | return; | |
278 | } | 278 | } | |
279 | } | 279 | } | |
280 | aprint_normal_dev(self, "interrupting on irqs %d-%d\n", | 280 | aprint_normal_dev(self, "interrupting on irqs %d-%d\n", | |
281 | loc->loc_intrs[0], loc->loc_intrs[0] + loc->loc_nintrs - 1); | 281 | loc->loc_intrs[0], loc->loc_intrs[0] + loc->loc_nintrs - 1); | |
282 | 282 | |||
283 | /* | 283 | /* | |
284 | * Enable INTA-INTD | 284 | * Enable INTA-INTD | |
285 | */ | 285 | */ | |
286 | bcmpax_write_4(sc, PCIE_SYS_RC_INTX_EN, 0x0f); | 286 | bcmpax_write_4(sc, PCIE_SYS_RC_INTX_EN, 0x0f); | |
287 | 287 | |||
288 | int offset; | 288 | int offset; | |
289 | const bool ok = pci_get_capability(&sc->sc_pc, 0, PCI_CAP_PCIEXPRESS, | 289 | const bool ok = pci_get_capability(&sc->sc_pc, 0, PCI_CAP_PCIEXPRESS, | |
290 | &offset, NULL); | 290 | &offset, NULL); | |
291 | KASSERT(ok); | 291 | KASSERT(ok); | |
292 | 292 | |||
293 | /* | 293 | /* | |
294 | * This will force the device to negotiate to a max of gen1. | 294 | * This will force the device to negotiate to a max of gen1. | |
295 | */ | 295 | */ | |
296 | if (cf->cf_flags & 1) { | 296 | if (cf->cf_flags & 1) { | |
297 | bcmpax_conf_write(sc, 0, offset + PCIE_LCSR2, 1); | 297 | bcmpax_conf_write(sc, 0, offset + PCIE_LCSR2, 1); | |
298 | } | 298 | } | |
299 | 299 | |||
300 | /* | 300 | /* | |
301 | * Now we wait (.25 sec) for the link to come up. | 301 | * Now we wait (.25 sec) for the link to come up. | |
302 | */ | 302 | */ | |
303 | offset += PCIE_LCSR; | 303 | offset += PCIE_LCSR; | |
304 | for (size_t timo = 0;; timo++) { | 304 | for (size_t timo = 0;; timo++) { | |
305 | const pcireg_t lcsr = bcmpax_conf_read(sc, 0, offset); | 305 | const pcireg_t lcsr = bcmpax_conf_read(sc, 0, offset); | |
306 | sc->sc_linkup = __SHIFTOUT(lcsr, PCIE_LCSR_NLW) != 0 | 306 | sc->sc_linkup = __SHIFTOUT(lcsr, PCIE_LCSR_NLW) != 0 | |
307 | && (1 || (lcsr & PCIE_LCSR_DLACTIVE) != 0); | 307 | && (1 || (lcsr & PCIE_LCSR_DLACTIVE) != 0); | |
308 | if (sc->sc_linkup || timo == 250) { | 308 | if (sc->sc_linkup || timo == 250) { | |
309 | aprint_debug_dev(self, | 309 | aprint_debug_dev(self, | |
310 | "lcsr=%#x nlw=%jd linkup=%d, timo=%zu\n", | 310 | "lcsr=%#x nlw=%jd linkup=%d, timo=%zu\n", | |
311 | lcsr, __SHIFTOUT(lcsr, PCIE_LCSR_NLW), | 311 | lcsr, __SHIFTOUT(lcsr, PCIE_LCSR_NLW), | |
312 | sc->sc_linkup, timo); | 312 | sc->sc_linkup, timo); | |
313 | break; | 313 | break; | |
314 | } | 314 | } | |
315 | DELAY(1000); | 315 | DELAY(1000); | |
316 | } | 316 | } | |
317 | 317 | |||
318 | if (sc->sc_linkup) { | 318 | if (sc->sc_linkup) { | |
@@ -350,27 +350,27 @@ bcmpax_ccb_attach(device_t parent, devic | @@ -350,27 +350,27 @@ bcmpax_ccb_attach(device_t parent, devic | |||
350 | base, size); | 350 | base, size); | |
351 | error = pci_configure_bus(&sc->sc_pc, pcires, | 351 | error = pci_configure_bus(&sc->sc_pc, pcires, | |
352 | 0, arm_pcache.dcache_line_size); | 352 | 0, arm_pcache.dcache_line_size); | |
353 | pciconf_resource_fini(pcires); | 353 | pciconf_resource_fini(pcires); | |
354 | 354 | |||
355 | if (error) { | 355 | if (error) { | |
356 | aprint_normal_dev(self, "configuration failed\n"); | 356 | aprint_normal_dev(self, "configuration failed\n"); | |
357 | return; | 357 | return; | |
358 | } | 358 | } | |
359 | } | 359 | } | |
360 | 360 | |||
361 | struct pcibus_attach_args pba; | 361 | struct pcibus_attach_args pba; | |
362 | memset(&pba, 0, sizeof(pba)); | 362 | memset(&pba, 0, sizeof(pba)); | |
363 | 363 | |||
364 | pba.pba_flags = sc->sc_pba_flags; | 364 | pba.pba_flags = sc->sc_pba_flags; | |
365 | pba.pba_flags |= PCI_FLAGS_MEM_OKAY; | 365 | pba.pba_flags |= PCI_FLAGS_MEM_OKAY; | |
366 | pba.pba_memt = sc->sc_bst; | 366 | pba.pba_memt = sc->sc_bst; | |
367 | pba.pba_dmat = sc->sc_dmat; | 367 | pba.pba_dmat = sc->sc_dmat; | |
368 | pba.pba_pc = &sc->sc_pc; | 368 | pba.pba_pc = &sc->sc_pc; | |
369 | pba.pba_bus = 0; | 369 | pba.pba_bus = 0; | |
370 | 370 | |||
371 | config_found(self, &pba, pcibusprint, CFARGS_NONE); | 371 | config_found(self, &pba, pcibusprint, CFARGS_NONE); | |
372 | } | 372 | } | |
373 | 373 | |||
374 | static void | 374 | static void | |
375 | bcmpax_attach_hook(device_t parent, device_t self, | 375 | bcmpax_attach_hook(device_t parent, device_t self, | |
376 | struct pcibus_attach_args *pba) | 376 | struct pcibus_attach_args *pba) | |
@@ -387,54 +387,54 @@ bcmpax_bus_maxdevs(void *v, int bus) | @@ -387,54 +387,54 @@ bcmpax_bus_maxdevs(void *v, int bus) | |||
387 | 387 | |||
388 | return bus ? 0 : 1; | 388 | return bus ? 0 : 1; | |
389 | } | 389 | } | |
390 | 390 | |||
391 | static void | 391 | static void | |
392 | bcmpax_decompose_tag(void *v, pcitag_t tag, int *busp, int *devp, int *funcp) | 392 | bcmpax_decompose_tag(void *v, pcitag_t tag, int *busp, int *devp, int *funcp) | |
393 | { | 393 | { | |
394 | if (busp) | 394 | if (busp) | |
395 | *busp = __SHIFTOUT(tag, CFG_ADDR_BUS); | 395 | *busp = __SHIFTOUT(tag, CFG_ADDR_BUS); | |
396 | if (devp) | 396 | if (devp) | |
397 | *devp = __SHIFTOUT(tag, CFG_ADDR_DEV); | 397 | *devp = __SHIFTOUT(tag, CFG_ADDR_DEV); | |
398 | if (funcp) | 398 | if (funcp) | |
399 | *funcp = __SHIFTOUT(tag, CFG_ADDR_FUNC); | 399 | *funcp = __SHIFTOUT(tag, CFG_ADDR_FUNC); | |
400 | } | 400 | } | |
401 | 401 | |||
402 | static pcitag_t | 402 | static pcitag_t | |
403 | bcmpax_make_tag(void *v, int bus, int dev, int func) | 403 | bcmpax_make_tag(void *v, int bus, int dev, int func) | |
404 | { | 404 | { | |
405 | return __SHIFTIN(bus, CFG_ADDR_BUS) | 405 | return __SHIFTIN(bus, CFG_ADDR_BUS) | |
406 | | __SHIFTIN(dev, CFG_ADDR_DEV) | 406 | | __SHIFTIN(dev, CFG_ADDR_DEV) | |
407 | | __SHIFTIN(func, CFG_ADDR_FUNC) | 407 | | __SHIFTIN(func, CFG_ADDR_FUNC) | |
408 | | (bus == 0 ? CFG_ADDR_TYPE0 : CFG_ADDR_TYPE1); | 408 | | (bus == 0 ? CFG_ADDR_TYPE0 : CFG_ADDR_TYPE1); | |
409 | } | 409 | } | |
410 | 410 | |||
411 | static inline bus_size_t | 411 | static inline bus_size_t | |
412 | bcmpax_conf_addr_write(struct bcmpax_softc *sc, pcitag_t tag) | 412 | bcmpax_conf_addr_write(struct bcmpax_softc *sc, pcitag_t tag) | |
413 | { | 413 | { | |
414 | if ((tag & (CFG_ADDR_BUS|CFG_ADDR_DEV)) == 0) { | 414 | if ((tag & (CFG_ADDR_BUS|CFG_ADDR_DEV)) == 0) { | |
415 | uint32_t reg = __SHIFTOUT(tag, CFG_ADDR_REG); | 415 | uint32_t reg = __SHIFTOUT(tag, CFG_ADDR_REG); | |
416 | uint32_t func = __SHIFTOUT(tag, CFG_ADDR_FUNC); | 416 | uint32_t func = __SHIFTOUT(tag, CFG_ADDR_FUNC); | |
417 | bcmpax_write_4(sc, PCIE_CFG_IND_ADDR, | 417 | bcmpax_write_4(sc, PCIE_CFG_IND_ADDR, | |
418 | __SHIFTIN(func, CFG_IND_ADDR_FUNC) | 418 | __SHIFTIN(func, CFG_IND_ADDR_FUNC) | |
419 | | __SHIFTIN(reg, CFG_IND_ADDR_REG)); | 419 | | __SHIFTIN(reg, CFG_IND_ADDR_REG)); | |
420 | dsb(sy); | 420 | dsb(sy); | |
421 | return PCIE_CFG_IND_DATA; | 421 | return PCIE_CFG_IND_DATA; | |
422 | } | 422 | } | |
423 | if (sc->sc_linkup) { | 423 | if (sc->sc_linkup) { | |
424 | bcmpax_write_4(sc, PCIE_CFG_ADDR, tag); | 424 | bcmpax_write_4(sc, PCIE_CFG_ADDR, tag); | |
425 | dsb(sy); | 425 | dsb(sy); | |
426 | return PCIE_CFG_DATA; | 426 | return PCIE_CFG_DATA; | |
427 | } | 427 | } | |
428 | return 0; | 428 | return 0; | |
429 | } | 429 | } | |
430 | 430 | |||
431 | static pcireg_t | 431 | static pcireg_t | |
432 | bcmpax_conf_read(void *v, pcitag_t tag, int reg) | 432 | bcmpax_conf_read(void *v, pcitag_t tag, int reg) | |
433 | { | 433 | { | |
434 | struct bcmpax_softc * const sc = v; | 434 | struct bcmpax_softc * const sc = v; | |
435 | 435 | |||
436 | if ((unsigned int)reg >= PCI_CONF_SIZE) | 436 | if ((unsigned int)reg >= PCI_CONF_SIZE) | |
437 | return 0xffffffff; | 437 | return 0xffffffff; | |
438 | 438 | |||
439 | /* | 439 | /* | |
440 | * Even in RC mode, the PCI Express Root Complex return itself | 440 | * Even in RC mode, the PCI Express Root Complex return itself |
--- src/sys/arch/arm/broadcom/bcm53xx_reg.h 2022/03/24 08:08:04 1.19
+++ src/sys/arch/arm/broadcom/bcm53xx_reg.h 2024/02/16 12:07:08 1.19.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bcm53xx_reg.h,v 1.19 2022/03/24 08:08:04 andvar Exp $ */ | 1 | /* $NetBSD: bcm53xx_reg.h,v 1.19.4.1 2024/02/16 12:07:08 skrll Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Matt Thomas of 3am Software Foundry. | 8 | * by Matt Thomas of 3am Software Foundry. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -328,37 +328,37 @@ | @@ -328,37 +328,37 @@ | |||
328 | #define CRUCTL_QSPI_CLK_SEL __BITS(2,1) | 328 | #define CRUCTL_QSPI_CLK_SEL __BITS(2,1) | |
329 | #define QSPI_CLK_25MHZ 0 // iproc_ref_clk | 329 | #define QSPI_CLK_25MHZ 0 // iproc_ref_clk | |
330 | #define QSPI_CLK_50MHZ 1 // iproc_sdio_clk / 4 | 330 | #define QSPI_CLK_50MHZ 1 // iproc_sdio_clk / 4 | |
331 | #define QSPI_CLK_31dot25MHZ 2 // iproc_clk250 / 8 | 331 | #define QSPI_CLK_31dot25MHZ 2 // iproc_clk250 / 8 | |
332 | #define QSPI_CLK_62dot5MHZ 3 // iproc_clk250 / 4 | 332 | #define QSPI_CLK_62dot5MHZ 3 // iproc_clk250 / 4 | |
333 | #define CRUCTL_SW_RESET __BIT(0) | 333 | #define CRUCTL_SW_RESET __BIT(0) | |
334 | 334 | |||
335 | #define CRU_GENPLL_CONTROL5 0x1154 | 335 | #define CRU_GENPLL_CONTROL5 0x1154 | |
336 | #define GENPLL_CONTROL5_NDIV_INT __BITS(29,20) // = (n ? n : 1024) | 336 | #define GENPLL_CONTROL5_NDIV_INT __BITS(29,20) // = (n ? n : 1024) | |
337 | #define GENPLL_CONTROL5_NDIV_FRAC __BITS(19,0) // = 1 / n | 337 | #define GENPLL_CONTROL5_NDIV_FRAC __BITS(19,0) // = 1 / n | |
338 | #define CRU_GENPLL_CONTROL6 0x1158 | 338 | #define CRU_GENPLL_CONTROL6 0x1158 | |
339 | #define GENPLL_CONTROL6_PDIV __BITS(26,24) // = (n ? n : 8) | 339 | #define GENPLL_CONTROL6_PDIV __BITS(26,24) // = (n ? n : 8) | |
340 | #define GENPLL_CONTROL6_CH0_MDIV __BITS(23,16) // = (n ? n : 256), clk_mac | 340 | #define GENPLL_CONTROL6_CH0_MDIV __BITS(23,16) // = (n ? n : 256), clk_mac | |
341 | #define GENPLL_CONTROL6_CH1_MDIV __BITS(15,8) // = (n ? n : 256), clk_robo | 341 | #define GENPLL_CONTROL6_CH1_MDIV __BITS(15,8) // = (n ? n : 256), clk_robo | |
342 | #define GENPLL_CONTROL6_CH2_MDIV __BITS(7,0) // = (n ? n : 256), clf_usb2 | 342 | #define GENPLL_CONTROL6_CH2_MDIV __BITS(7,0) // = (n ? n : 256), clf_usb2 | |
343 | #define CRU_GENPLL_CONTROL7 0x115c | 343 | #define CRU_GENPLL_CONTROL7 0x115c | |
344 | #define GENPLL_CONTROL7_CH3_MDIV __BITS(23,16) // = (n ? n : 256), clk_iproc | 344 | #define GENPLL_CONTROL7_CH3_MDIV __BITS(23,16) // = (n ? n : 256), clk_iproc | |
345 | 345 | |||
346 | #define USB2_REF_CLK (1920*1000*1000) | 346 | #define USB2_REF_CLK (1920*1000*1000) | |
347 | #define CRU_USB2_CONTROL 0x1164 | 347 | #define CRU_USB2_CONTROL 0x1164 | |
348 | #define USB2_CONTROL_KA __BITS(24,22) | 348 | #define USB2_CONTROL_KA __BITS(24,22) | |
349 | #define USB2_CONTROL_KI __BITS(31,19) | 349 | #define USB2_CONTROL_KI __BITS(31,19) | |
350 | #define USB2_CONTROL_KP __BITS(18,15) | 350 | #define USB2_CONTROL_KP __BITS(18,15) | |
351 | #define USB2_CONTROL_PDIV __BITS(14,12) // = (n ? n : 8) | 351 | #define USB2_CONTROL_PDIV __BITS(14,12) // = (n ? n : 8) | |
352 | #define USB2_CONTROL_NDIV_INT __BITS(11,2) // = (n ? n : 1024) | 352 | #define USB2_CONTROL_NDIV_INT __BITS(11,2) // = (n ? n : 1024) | |
353 | #define USB2_CONTROL_PLL_PCIEUSB3_RESET __BIT(1) // inverted 1=normal | 353 | #define USB2_CONTROL_PLL_PCIEUSB3_RESET __BIT(1) // inverted 1=normal | |
354 | #define USB2_CONTROL_PLL_USB2_RESET __BIT(0) // inverted 1=normal | 354 | #define USB2_CONTROL_PLL_USB2_RESET __BIT(0) // inverted 1=normal | |
355 | 355 | |||
356 | #define CRU_CLKSET_KEY 0x1180 | 356 | #define CRU_CLKSET_KEY 0x1180 | |
357 | #define CRU_CLKSET_KEY_MAGIC 0xea68 | 357 | #define CRU_CLKSET_KEY_MAGIC 0xea68 | |
358 | 358 | |||
359 | #define CRU_GPIO_SELECT 0x11c0 // CRU GPIO Select | 359 | #define CRU_GPIO_SELECT 0x11c0 // CRU GPIO Select | |
360 | #define CRU_GPIO_DRIVE_SEL2 0x11c4 | 360 | #define CRU_GPIO_DRIVE_SEL2 0x11c4 | |
361 | #define CRU_GPIO_DRIVE_SEL1 0x11c8 | 361 | #define CRU_GPIO_DRIVE_SEL1 0x11c8 | |
362 | #define CRU_GPIO_DRIVE_SEL0 0x11cc | 362 | #define CRU_GPIO_DRIVE_SEL0 0x11cc | |
363 | #define CRU_GPIO_INPUT_DISABLE 0x11d0 | 363 | #define CRU_GPIO_INPUT_DISABLE 0x11d0 | |
364 | #define CRU_GPIO_HYSTERESIS 0x11d4 | 364 | #define CRU_GPIO_HYSTERESIS 0x11d4 | |
@@ -376,36 +376,36 @@ | @@ -376,36 +376,36 @@ | |||
376 | #define STRAP_PCIE0_MODE __BIT(5) | 376 | #define STRAP_PCIE0_MODE __BIT(5) | |
377 | #define STRAP_USB3_SEL __BIT(4) | 377 | #define STRAP_USB3_SEL __BIT(4) | |
378 | #define STRAP_EX_EXTCLK __BIT(3) | 378 | #define STRAP_EX_EXTCLK __BIT(3) | |
379 | #define STRAP_HW_FWDG_EN __BIT(2) | 379 | #define STRAP_HW_FWDG_EN __BIT(2) | |
380 | #define STRAP_LED_SERIAL_MODE __BIT(1) | 380 | #define STRAP_LED_SERIAL_MODE __BIT(1) | |
381 | #define STRAP_BISR_BYPASS_AUTOLOAD __BIT(0) | 381 | #define STRAP_BISR_BYPASS_AUTOLOAD __BIT(0) | |
382 | 382 | |||
383 | #endif /* CRU_PRIVATE */ | 383 | #endif /* CRU_PRIVATE */ | |
384 | 384 | |||
385 | #ifdef DMU_PRIVATE | 385 | #ifdef DMU_PRIVATE | |
386 | 386 | |||
387 | #define DMU_LCPLL_CONTROL0 0x100 | 387 | #define DMU_LCPLL_CONTROL0 0x100 | |
388 | #define DMU_LCPLL_CONTROL1 0x104 | 388 | #define DMU_LCPLL_CONTROL1 0x104 | |
389 | #define LCPLL_CONTROL1_PDIV __BITS(30,28) // = (n ? n : 8) | 389 | #define LCPLL_CONTROL1_PDIV __BITS(30,28) // = (n ? n : 8) | |
390 | #define LCPLL_CONTROL1_NDIV_INT __BITS(27,20) // = (n ? n : 256) | 390 | #define LCPLL_CONTROL1_NDIV_INT __BITS(27,20) // = (n ? n : 256) | |
391 | #define LCPLL_CONTROL1_NDIV_FRAC __BITS(19,0) // = 1 / n | 391 | #define LCPLL_CONTROL1_NDIV_FRAC __BITS(19,0) // = 1 / n | |
392 | /* | 392 | /* | |
393 | * SYS_CLK = (1 / pdiv) * (ndiv_int + (ndiv_frac / 0x40000000)) x F(ref) | 393 | * SYS_CLK = (1 / pdiv) * (ndiv_int + (ndiv_frac / 0x40000000)) x F(ref) | |
394 | */ | 394 | */ | |
395 | #define DMU_LCPLL_CONTROL2 0x108 | 395 | #define DMU_LCPLL_CONTROL2 0x108 | |
396 | #define LCPLL_CONTROL2_CH0_MDIV __BITS(31,24) // = (n ? n : 256), clk_pcie_ref | 396 | #define LCPLL_CONTROL2_CH0_MDIV __BITS(31,24) // = (n ? n : 256), clk_pcie_ref | |
397 | #define LCPLL_CONTROL2_CH1_MDIV __BITS(23,16) // = (n ? n : 256), clk_sdio | 397 | #define LCPLL_CONTROL2_CH1_MDIV __BITS(23,16) // = (n ? n : 256), clk_sdio | |
398 | #define LCPLL_CONTROL2_CH2_MDIV __BITS(15,8) // = (n ? n : 256), clk_ddr | 398 | #define LCPLL_CONTROL2_CH2_MDIV __BITS(15,8) // = (n ? n : 256), clk_ddr | |
399 | #define LCPLL_CONTROL2_CH3_MDIV __BITS(7,0) // = (n ? n : 256), clf_dft | 399 | #define LCPLL_CONTROL2_CH3_MDIV __BITS(7,0) // = (n ? n : 256), clf_dft | |
400 | 400 | |||
401 | #define DMU_CRU_RESET 0x200 | 401 | #define DMU_CRU_RESET 0x200 | |
402 | #define DMU_CRU_RESET_IPROC __BIT(1) | 402 | #define DMU_CRU_RESET_IPROC __BIT(1) | |
403 | #define DMU_CRU_RESET_CMICD __BIT(0) | 403 | #define DMU_CRU_RESET_CMICD __BIT(0) | |
404 | 404 | |||
405 | #endif /* DMU_PRIVATE */ | 405 | #endif /* DMU_PRIVATE */ | |
406 | 406 | |||
407 | #ifdef DDR_PRIVATE | 407 | #ifdef DDR_PRIVATE | |
408 | /* | 408 | /* | |
409 | * DDR CTL register has such inspired names. | 409 | * DDR CTL register has such inspired names. | |
410 | */ | 410 | */ | |
411 | #define DDR_CTL_01 0x004 | 411 | #define DDR_CTL_01 0x004 | |
@@ -641,27 +641,27 @@ | @@ -641,27 +641,27 @@ | |||
641 | #define CLK_POLICY_SYS_CLK 1 // sys clk (200MHZ) | 641 | #define CLK_POLICY_SYS_CLK 1 // sys clk (200MHZ) | |
642 | #define CLK_POLICY_ARM_PLL_CH0 6 // slow clock | 642 | #define CLK_POLICY_ARM_PLL_CH0 6 // slow clock | |
643 | #define CLK_POLICY_ARM_PLL_CH1 7 // fast clock | 643 | #define CLK_POLICY_ARM_PLL_CH1 7 // fast clock | |
644 | 644 | |||
645 | #define ARMCORE_CLK_APB_DIV 0xa10 | 645 | #define ARMCORE_CLK_APB_DIV 0xa10 | |
646 | #define CLK_APB_DIV_PRIVED __BIT(31) | 646 | #define CLK_APB_DIV_PRIVED __BIT(31) | |
647 | #define CLK_APB_DIV_VALUE __BITS(1,0) // n = n + 1 | 647 | #define CLK_APB_DIV_VALUE __BITS(1,0) // n = n + 1 | |
648 | 648 | |||
649 | #define ARMCORE_CLK_APB_DIV_TRIGGER 0xa10 | 649 | #define ARMCORE_CLK_APB_DIV_TRIGGER 0xa10 | |
650 | #define CLK_APB_DIV_TRIGGER_PRIVED __BIT(31) | 650 | #define CLK_APB_DIV_TRIGGER_PRIVED __BIT(31) | |
651 | #define CLK_APB_DIV_TRIGGER_OVERRIDE __BIT(0) | 651 | #define CLK_APB_DIV_TRIGGER_OVERRIDE __BIT(0) | |
652 | 652 | |||
653 | #define ARMCORE_CLK_PLLARMA 0xc00 | 653 | #define ARMCORE_CLK_PLLARMA 0xc00 | |
654 | #define CLK_PLLARMA_PDIV __BITS(26,24) // = (n ? n : 16(?)) | 654 | #define CLK_PLLARMA_PDIV __BITS(26,24) // = (n ? n : 16(?)) | |
655 | #define CLK_PLLARMA_NDIV_INT __BITS(17,8) // = (n ? n : 1024) | 655 | #define CLK_PLLARMA_NDIV_INT __BITS(17,8) // = (n ? n : 1024) | |
656 | 656 | |||
657 | #define ARMCORE_CLK_PLLARMB 0xc04 | 657 | #define ARMCORE_CLK_PLLARMB 0xc04 | |
658 | #define CLK_PLLARMB_NDIV_FRAC __BITS(19,0) // = 1 / n | 658 | #define CLK_PLLARMB_NDIV_FRAC __BITS(19,0) // = 1 / n | |
659 | 659 | |||
660 | #endif | 660 | #endif | |
661 | 661 | |||
662 | #ifdef IDM_PRIVATE | 662 | #ifdef IDM_PRIVATE | |
663 | 663 | |||
664 | #define IDM_ARMCORE_M0_BASE 0x00000 | 664 | #define IDM_ARMCORE_M0_BASE 0x00000 | |
665 | #define IDM_PCIE_M0_BASE 0x01000 | 665 | #define IDM_PCIE_M0_BASE 0x01000 | |
666 | #define IDM_PCIE_M1_BASE 0x02000 | 666 | #define IDM_PCIE_M1_BASE 0x02000 | |
667 | #define IDM_PCIE_M2_BASE 0x03000 | 667 | #define IDM_PCIE_M2_BASE 0x03000 | |
@@ -767,27 +767,27 @@ struct gmac_rxdb { | @@ -767,27 +767,27 @@ struct gmac_rxdb { | |||
767 | #define RXC_DRNG __BITS(17,16) | 767 | #define RXC_DRNG __BITS(17,16) | |
768 | #define TXQ_FLUSH __BIT(8) | 768 | #define TXQ_FLUSH __BIT(8) | |
769 | #define NWAY_AUTO_POLL_EN __BIT(7) | 769 | #define NWAY_AUTO_POLL_EN __BIT(7) | |
770 | #define FLOW_CTRL_MODE __BITS(6,5) | 770 | #define FLOW_CTRL_MODE __BITS(6,5) | |
771 | #define MIB_RD_RESET_EN __BIT(4) | 771 | #define MIB_RD_RESET_EN __BIT(4) | |
772 | #define RGMII_LINK_STATUS_SEL __BIT(3) | 772 | #define RGMII_LINK_STATUS_SEL __BIT(3) | |
773 | #define CPU_FLOW_CTRL_ON __BIT(2) | 773 | #define CPU_FLOW_CTRL_ON __BIT(2) | |
774 | #define RXQ_OVERFLOW_CTRL_SEL __BIT(1) | 774 | #define RXQ_OVERFLOW_CTRL_SEL __BIT(1) | |
775 | #define TXARB_STRICT_MODE __BIT(0) | 775 | #define TXARB_STRICT_MODE __BIT(0) | |
776 | #define GMAC_DEVSTATUS 0x004 | 776 | #define GMAC_DEVSTATUS 0x004 | |
777 | #define GMAC_BISTSTATUS 0x00c | 777 | #define GMAC_BISTSTATUS 0x00c | |
778 | #define GMAC_INTSTATUS 0x020 | 778 | #define GMAC_INTSTATUS 0x020 | |
779 | #define GMAC_INTMASK 0x024 | 779 | #define GMAC_INTMASK 0x024 | |
780 | #define TXQECCUNCORRECTED __BIT(31) | 780 | #define TXQECCUNCORRECTED __BIT(31) | |
781 | #define TXQECCCORRECTED __BIT(30) | 781 | #define TXQECCCORRECTED __BIT(30) | |
782 | #define RXQECCUNCORRECTED __BIT(29) | 782 | #define RXQECCUNCORRECTED __BIT(29) | |
783 | #define RXQECCCORRECTED __BIT(28) | 783 | #define RXQECCCORRECTED __BIT(28) | |
784 | #define XMTINT_3 __BIT(27) | 784 | #define XMTINT_3 __BIT(27) | |
785 | #define XMTINT_2 __BIT(26) | 785 | #define XMTINT_2 __BIT(26) | |
786 | #define XMTINT_1 __BIT(25) | 786 | #define XMTINT_1 __BIT(25) | |
787 | #define XMTINT_0 __BIT(24) | 787 | #define XMTINT_0 __BIT(24) | |
788 | #define RCVINT __BIT(16) | 788 | #define RCVINT __BIT(16) | |
789 | #define XMTUF __BIT(15) | 789 | #define XMTUF __BIT(15) | |
790 | #define RCVFIFOOF __BIT(14) | 790 | #define RCVFIFOOF __BIT(14) | |
791 | #define RCVDESCUF __BIT(13) | 791 | #define RCVDESCUF __BIT(13) | |
792 | #define DESCPROTOERR __BIT(12) | 792 | #define DESCPROTOERR __BIT(12) | |
793 | #define DATAERR __BIT(11) | 793 | #define DATAERR __BIT(11) | |
@@ -894,38 +894,38 @@ struct gmac_rxdb { | @@ -894,38 +894,38 @@ struct gmac_rxdb { | |||
894 | #define CNTRL_FRM_ENA __BIT(23) | 894 | #define CNTRL_FRM_ENA __BIT(23) | |
895 | #define ENA_EXT_CONFIG __BIT(22) | 895 | #define ENA_EXT_CONFIG __BIT(22) | |
896 | #define EN_INTERNAL_TX_CRS __BIT(21) | 896 | #define EN_INTERNAL_TX_CRS __BIT(21) | |
897 | #define SW_OVERRIDE_RX __BIT(18) | 897 | #define SW_OVERRIDE_RX __BIT(18) | |
898 | #define SW_OVERRIDE_TX __BIT(17) | 898 | #define SW_OVERRIDE_TX __BIT(17) | |
899 | #define MAC_LOOP_CON __BIT(16) | 899 | #define MAC_LOOP_CON __BIT(16) | |
900 | #define LOOP_ENA __BIT(15) | 900 | #define LOOP_ENA __BIT(15) | |
901 | #define RCS_CORRUPT_URUN_EN __BIT(14) | 901 | #define RCS_CORRUPT_URUN_EN __BIT(14) | |
902 | #define SW_RESET __BIT(13) | 902 | #define SW_RESET __BIT(13) | |
903 | #define OVERFLOW_EN __BIT(12) | 903 | #define OVERFLOW_EN __BIT(12) | |
904 | #define RX_LOW_LATENCY_EN __BIT(11) | 904 | #define RX_LOW_LATENCY_EN __BIT(11) | |
905 | #define HD_ENA __BIT(10) | 905 | #define HD_ENA __BIT(10) | |
906 | #define TX_ADDR_INS __BIT(9) | 906 | #define TX_ADDR_INS __BIT(9) | |
907 | #define PAUSE_IGNORE __BIT(8) | 907 | #define PAUSE_IGNORE __BIT(8) | |
908 | #define PAUSE_FWD __BIT(7) | 908 | #define PAUSE_FWD __BIT(7) | |
909 | #define CRC_FWD __BIT(6) | 909 | #define CRC_FWD __BIT(6) | |
910 | #define PAD_EN __BIT(5) | 910 | #define PAD_EN __BIT(5) | |
911 | #define PROMISC_EN __BIT(4) | 911 | #define PROMISC_EN __BIT(4) | |
912 | #define ETH_SPEED __BITS(3,2) | 912 | #define ETH_SPEED __BITS(3,2) | |
913 | #define ETH_SPEED_10 0 | 913 | #define ETH_SPEED_10 0 | |
914 | #define ETH_SPEED_100 1 | 914 | #define ETH_SPEED_100 1 | |
915 | #define ETH_SPEED_1000 2 | 915 | #define ETH_SPEED_1000 2 | |
916 | #define ETH_SPEED_2500 3 | 916 | #define ETH_SPEED_2500 3 | |
917 | #define RX_ENA __BIT(1) | 917 | #define RX_ENA __BIT(1) | |
918 | #define TX_ENA __BIT(0) | 918 | #define TX_ENA __BIT(0) | |
919 | #define UNIMAC_MAC_0 0x80c // bits 16:47 of macaddr | 919 | #define UNIMAC_MAC_0 0x80c // bits 16:47 of macaddr | |
920 | #define UNIMAC_MAC_1 0x810 // bits 0:15 of macaddr | 920 | #define UNIMAC_MAC_1 0x810 // bits 0:15 of macaddr | |
921 | #define UNIMAC_FRAME_LEN 0x814 | 921 | #define UNIMAC_FRAME_LEN 0x814 | |
922 | #define UNIMAC_PAUSE_QUANTA 0x818 | 922 | #define UNIMAC_PAUSE_QUANTA 0x818 | |
923 | #define UNIMAC_TX_TS_SEQ_ID 0x83c | 923 | #define UNIMAC_TX_TS_SEQ_ID 0x83c | |
924 | #define UNIMAC_MAC_MODE 0x844 | 924 | #define UNIMAC_MAC_MODE 0x844 | |
925 | #define UNIMAC_TAG_0 0x848 | 925 | #define UNIMAC_TAG_0 0x848 | |
926 | #define UNIMAC_TAG_1 0x84c | 926 | #define UNIMAC_TAG_1 0x84c | |
927 | #define UNIMAC_RX_PAUSE_QUANTA_SCALE 0x850 | 927 | #define UNIMAC_RX_PAUSE_QUANTA_SCALE 0x850 | |
928 | #define UNIMAC_TX_PREAMBLE 0x854 | 928 | #define UNIMAC_TX_PREAMBLE 0x854 | |
929 | #define UNIMAC_TX_IPG_LENGTH 0x85c | 929 | #define UNIMAC_TX_IPG_LENGTH 0x85c | |
930 | #define UNIMAC_PRF_XOFF_TIMER 0x860 | 930 | #define UNIMAC_PRF_XOFF_TIMER 0x860 | |
931 | #define UNIMAC_UMAC_EEE_CTRL 0x864 | 931 | #define UNIMAC_UMAC_EEE_CTRL 0x864 |