Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: sunxi-ng: v3s: add Allwinner V3 support

Allwinner V3 has the same main die with V3s, but with more pins wired.
There's a I2S bus on V3 that is not available on V3s.

Add the V3-only peripheral's clocks and reset to the V3s CCU driver,
bound to a new V3 compatible string. The driver name is not changed
because it's part of the device tree binding (the header file name).

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>

authored by

Icenowy Zheng and committed by
Maxime Ripard
0ed4c252 72009960

+234 -3
+226 -2
drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
··· 235 235 0x068, BIT(0), 0); 236 236 static SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb1", 237 237 0x068, BIT(5), 0); 238 + static SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb1", 239 + 0x068, BIT(12), 0); 238 240 239 241 static SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2", 240 242 0x06c, BIT(0), 0); ··· 307 305 24, 2, /* mux */ 308 306 BIT(31), /* gate */ 309 307 0); 308 + 309 + static const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x", 310 + "pll-audio-2x", "pll-audio" }; 311 + static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents, 312 + 0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 310 313 311 314 static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M", 312 315 0x0cc, BIT(8), 0); ··· 450 443 &pll_audio_base_clk.common.hw 451 444 }; 452 445 446 + static struct ccu_common *sun8i_v3_ccu_clks[] = { 447 + &pll_cpu_clk.common, 448 + &pll_audio_base_clk.common, 449 + &pll_video_clk.common, 450 + &pll_ve_clk.common, 451 + &pll_ddr0_clk.common, 452 + &pll_periph0_clk.common, 453 + &pll_isp_clk.common, 454 + &pll_periph1_clk.common, 455 + &pll_ddr1_clk.common, 456 + &cpu_clk.common, 457 + &axi_clk.common, 458 + &ahb1_clk.common, 459 + &apb1_clk.common, 460 + &apb2_clk.common, 461 + &ahb2_clk.common, 462 + &bus_ce_clk.common, 463 + &bus_dma_clk.common, 464 + &bus_mmc0_clk.common, 465 + &bus_mmc1_clk.common, 466 + &bus_mmc2_clk.common, 467 + &bus_dram_clk.common, 468 + &bus_emac_clk.common, 469 + &bus_hstimer_clk.common, 470 + &bus_spi0_clk.common, 471 + &bus_otg_clk.common, 472 + &bus_ehci0_clk.common, 473 + &bus_ohci0_clk.common, 474 + &bus_ve_clk.common, 475 + &bus_tcon0_clk.common, 476 + &bus_csi_clk.common, 477 + &bus_de_clk.common, 478 + &bus_codec_clk.common, 479 + &bus_pio_clk.common, 480 + &bus_i2s0_clk.common, 481 + &bus_i2c0_clk.common, 482 + &bus_i2c1_clk.common, 483 + &bus_uart0_clk.common, 484 + &bus_uart1_clk.common, 485 + &bus_uart2_clk.common, 486 + &bus_ephy_clk.common, 487 + &bus_dbg_clk.common, 488 + &mmc0_clk.common, 489 + &mmc0_sample_clk.common, 490 + &mmc0_output_clk.common, 491 + &mmc1_clk.common, 492 + &mmc1_sample_clk.common, 493 + &mmc1_output_clk.common, 494 + &mmc2_clk.common, 495 + &mmc2_sample_clk.common, 496 + &mmc2_output_clk.common, 497 + &ce_clk.common, 498 + &spi0_clk.common, 499 + &i2s0_clk.common, 500 + &usb_phy0_clk.common, 501 + &usb_ohci0_clk.common, 502 + &dram_clk.common, 503 + &dram_ve_clk.common, 504 + &dram_csi_clk.common, 505 + &dram_ohci_clk.common, 506 + &dram_ehci_clk.common, 507 + &de_clk.common, 508 + &tcon_clk.common, 509 + &csi_misc_clk.common, 510 + &csi0_mclk_clk.common, 511 + &csi1_sclk_clk.common, 512 + &csi1_mclk_clk.common, 513 + &ve_clk.common, 514 + &ac_dig_clk.common, 515 + &avs_clk.common, 516 + &mbus_clk.common, 517 + &mipi_csi_clk.common, 518 + }; 519 + 453 520 /* We hardcode the divider to 4 for now */ 454 521 static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio", 455 522 clk_parent_pll_audio, ··· 621 540 .num = CLK_NUMBER, 622 541 }; 623 542 543 + static struct clk_hw_onecell_data sun8i_v3_hw_clks = { 544 + .hws = { 545 + [CLK_PLL_CPU] = &pll_cpu_clk.common.hw, 546 + [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw, 547 + [CLK_PLL_AUDIO] = &pll_audio_clk.hw, 548 + [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw, 549 + [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw, 550 + [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw, 551 + [CLK_PLL_VIDEO] = &pll_video_clk.common.hw, 552 + [CLK_PLL_VE] = &pll_ve_clk.common.hw, 553 + [CLK_PLL_DDR0] = &pll_ddr0_clk.common.hw, 554 + [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw, 555 + [CLK_PLL_PERIPH0_2X] = &pll_periph0_2x_clk.hw, 556 + [CLK_PLL_ISP] = &pll_isp_clk.common.hw, 557 + [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw, 558 + [CLK_PLL_DDR1] = &pll_ddr1_clk.common.hw, 559 + [CLK_CPU] = &cpu_clk.common.hw, 560 + [CLK_AXI] = &axi_clk.common.hw, 561 + [CLK_AHB1] = &ahb1_clk.common.hw, 562 + [CLK_APB1] = &apb1_clk.common.hw, 563 + [CLK_APB2] = &apb2_clk.common.hw, 564 + [CLK_AHB2] = &ahb2_clk.common.hw, 565 + [CLK_BUS_CE] = &bus_ce_clk.common.hw, 566 + [CLK_BUS_DMA] = &bus_dma_clk.common.hw, 567 + [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw, 568 + [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw, 569 + [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw, 570 + [CLK_BUS_DRAM] = &bus_dram_clk.common.hw, 571 + [CLK_BUS_EMAC] = &bus_emac_clk.common.hw, 572 + [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw, 573 + [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw, 574 + [CLK_BUS_OTG] = &bus_otg_clk.common.hw, 575 + [CLK_BUS_EHCI0] = &bus_ehci0_clk.common.hw, 576 + [CLK_BUS_OHCI0] = &bus_ohci0_clk.common.hw, 577 + [CLK_BUS_VE] = &bus_ve_clk.common.hw, 578 + [CLK_BUS_TCON0] = &bus_tcon0_clk.common.hw, 579 + [CLK_BUS_CSI] = &bus_csi_clk.common.hw, 580 + [CLK_BUS_DE] = &bus_de_clk.common.hw, 581 + [CLK_BUS_CODEC] = &bus_codec_clk.common.hw, 582 + [CLK_BUS_PIO] = &bus_pio_clk.common.hw, 583 + [CLK_BUS_I2S0] = &bus_i2s0_clk.common.hw, 584 + [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw, 585 + [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw, 586 + [CLK_BUS_UART0] = &bus_uart0_clk.common.hw, 587 + [CLK_BUS_UART1] = &bus_uart1_clk.common.hw, 588 + [CLK_BUS_UART2] = &bus_uart2_clk.common.hw, 589 + [CLK_BUS_EPHY] = &bus_ephy_clk.common.hw, 590 + [CLK_BUS_DBG] = &bus_dbg_clk.common.hw, 591 + [CLK_MMC0] = &mmc0_clk.common.hw, 592 + [CLK_MMC0_SAMPLE] = &mmc0_sample_clk.common.hw, 593 + [CLK_MMC0_OUTPUT] = &mmc0_output_clk.common.hw, 594 + [CLK_MMC1] = &mmc1_clk.common.hw, 595 + [CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw, 596 + [CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw, 597 + [CLK_MMC2] = &mmc2_clk.common.hw, 598 + [CLK_MMC2_SAMPLE] = &mmc2_sample_clk.common.hw, 599 + [CLK_MMC2_OUTPUT] = &mmc2_output_clk.common.hw, 600 + [CLK_CE] = &ce_clk.common.hw, 601 + [CLK_SPI0] = &spi0_clk.common.hw, 602 + [CLK_I2S0] = &i2s0_clk.common.hw, 603 + [CLK_USB_PHY0] = &usb_phy0_clk.common.hw, 604 + [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw, 605 + [CLK_DRAM] = &dram_clk.common.hw, 606 + [CLK_DRAM_VE] = &dram_ve_clk.common.hw, 607 + [CLK_DRAM_CSI] = &dram_csi_clk.common.hw, 608 + [CLK_DRAM_EHCI] = &dram_ehci_clk.common.hw, 609 + [CLK_DRAM_OHCI] = &dram_ohci_clk.common.hw, 610 + [CLK_DE] = &de_clk.common.hw, 611 + [CLK_TCON0] = &tcon_clk.common.hw, 612 + [CLK_CSI_MISC] = &csi_misc_clk.common.hw, 613 + [CLK_CSI0_MCLK] = &csi0_mclk_clk.common.hw, 614 + [CLK_CSI1_SCLK] = &csi1_sclk_clk.common.hw, 615 + [CLK_CSI1_MCLK] = &csi1_mclk_clk.common.hw, 616 + [CLK_VE] = &ve_clk.common.hw, 617 + [CLK_AC_DIG] = &ac_dig_clk.common.hw, 618 + [CLK_AVS] = &avs_clk.common.hw, 619 + [CLK_MBUS] = &mbus_clk.common.hw, 620 + [CLK_MIPI_CSI] = &mipi_csi_clk.common.hw, 621 + }, 622 + .num = CLK_NUMBER, 623 + }; 624 + 624 625 static struct ccu_reset_map sun8i_v3s_ccu_resets[] = { 625 626 [RST_USB_PHY0] = { 0x0cc, BIT(0) }, 626 627 ··· 738 575 [RST_BUS_UART2] = { 0x2d8, BIT(18) }, 739 576 }; 740 577 578 + static struct ccu_reset_map sun8i_v3_ccu_resets[] = { 579 + [RST_USB_PHY0] = { 0x0cc, BIT(0) }, 580 + 581 + [RST_MBUS] = { 0x0fc, BIT(31) }, 582 + 583 + [RST_BUS_CE] = { 0x2c0, BIT(5) }, 584 + [RST_BUS_DMA] = { 0x2c0, BIT(6) }, 585 + [RST_BUS_MMC0] = { 0x2c0, BIT(8) }, 586 + [RST_BUS_MMC1] = { 0x2c0, BIT(9) }, 587 + [RST_BUS_MMC2] = { 0x2c0, BIT(10) }, 588 + [RST_BUS_DRAM] = { 0x2c0, BIT(14) }, 589 + [RST_BUS_EMAC] = { 0x2c0, BIT(17) }, 590 + [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) }, 591 + [RST_BUS_SPI0] = { 0x2c0, BIT(20) }, 592 + [RST_BUS_OTG] = { 0x2c0, BIT(24) }, 593 + [RST_BUS_EHCI0] = { 0x2c0, BIT(26) }, 594 + [RST_BUS_OHCI0] = { 0x2c0, BIT(29) }, 595 + 596 + [RST_BUS_VE] = { 0x2c4, BIT(0) }, 597 + [RST_BUS_TCON0] = { 0x2c4, BIT(4) }, 598 + [RST_BUS_CSI] = { 0x2c4, BIT(8) }, 599 + [RST_BUS_DE] = { 0x2c4, BIT(12) }, 600 + [RST_BUS_DBG] = { 0x2c4, BIT(31) }, 601 + 602 + [RST_BUS_EPHY] = { 0x2c8, BIT(2) }, 603 + 604 + [RST_BUS_CODEC] = { 0x2d0, BIT(0) }, 605 + [RST_BUS_I2S0] = { 0x2d0, BIT(12) }, 606 + 607 + [RST_BUS_I2C0] = { 0x2d8, BIT(0) }, 608 + [RST_BUS_I2C1] = { 0x2d8, BIT(1) }, 609 + [RST_BUS_UART0] = { 0x2d8, BIT(16) }, 610 + [RST_BUS_UART1] = { 0x2d8, BIT(17) }, 611 + [RST_BUS_UART2] = { 0x2d8, BIT(18) }, 612 + }; 613 + 741 614 static const struct sunxi_ccu_desc sun8i_v3s_ccu_desc = { 742 615 .ccu_clks = sun8i_v3s_ccu_clks, 743 616 .num_ccu_clks = ARRAY_SIZE(sun8i_v3s_ccu_clks), ··· 784 585 .num_resets = ARRAY_SIZE(sun8i_v3s_ccu_resets), 785 586 }; 786 587 787 - static void __init sun8i_v3s_ccu_setup(struct device_node *node) 588 + static const struct sunxi_ccu_desc sun8i_v3_ccu_desc = { 589 + .ccu_clks = sun8i_v3_ccu_clks, 590 + .num_ccu_clks = ARRAY_SIZE(sun8i_v3_ccu_clks), 591 + 592 + .hw_clks = &sun8i_v3_hw_clks, 593 + 594 + .resets = sun8i_v3_ccu_resets, 595 + .num_resets = ARRAY_SIZE(sun8i_v3_ccu_resets), 596 + }; 597 + 598 + static void __init sun8i_v3_v3s_ccu_init(struct device_node *node, 599 + const struct sunxi_ccu_desc *ccu_desc) 788 600 { 789 601 void __iomem *reg; 790 602 u32 val; ··· 811 601 val &= ~GENMASK(19, 16); 812 602 writel(val | (3 << 16), reg + SUN8I_V3S_PLL_AUDIO_REG); 813 603 814 - sunxi_ccu_probe(node, reg, &sun8i_v3s_ccu_desc); 604 + sunxi_ccu_probe(node, reg, ccu_desc); 815 605 } 606 + 607 + static void __init sun8i_v3s_ccu_setup(struct device_node *node) 608 + { 609 + sun8i_v3_v3s_ccu_init(node, &sun8i_v3s_ccu_desc); 610 + } 611 + 612 + static void __init sun8i_v3_ccu_setup(struct device_node *node) 613 + { 614 + sun8i_v3_v3s_ccu_init(node, &sun8i_v3_ccu_desc); 615 + } 616 + 816 617 CLK_OF_DECLARE(sun8i_v3s_ccu, "allwinner,sun8i-v3s-ccu", 817 618 sun8i_v3s_ccu_setup); 619 + 620 + CLK_OF_DECLARE(sun8i_v3_ccu, "allwinner,sun8i-v3-ccu", 621 + sun8i_v3_ccu_setup);
+1 -1
drivers/clk/sunxi-ng/ccu-sun8i-v3s.h
··· 51 51 52 52 #define CLK_PLL_DDR1 74 53 53 54 - #define CLK_NUMBER (CLK_PLL_DDR1 + 1) 54 + #define CLK_NUMBER (CLK_I2S0 + 1) 55 55 56 56 #endif /* _CCU_SUN8I_H3_H_ */
+4
include/dt-bindings/clock/sun8i-v3s-ccu.h
··· 104 104 105 105 #define CLK_MIPI_CSI 73 106 106 107 + /* Clocks not available on V3s */ 108 + #define CLK_BUS_I2S0 75 109 + #define CLK_I2S0 76 110 + 107 111 #endif /* _DT_BINDINGS_CLK_SUN8I_V3S_H_ */
+3
include/dt-bindings/reset/sun8i-v3s-ccu.h
··· 75 75 #define RST_BUS_UART1 50 76 76 #define RST_BUS_UART2 51 77 77 78 + /* Reset lines not available on V3s */ 79 + #define RST_BUS_I2S0 52 80 + 78 81 #endif /* _DT_BINDINGS_RST_SUN8I_H3_H_ */