MIPS: BCM63XX: add and use clkdev lookup support
Subsystems (4)
v2 cover MIPS: BCM63XX: add and use clkdev lookup support
This patchset adds support for clckdev lookup support to name input clocks in various drivers more closely to their functions, or simplify their usage.
Since most of these patches touch arch/mips, it probably makes most sense to go through the MIPS tree.
The HSSPI driver was already updated previously to support a "pll" input with ff18e1ef04e2 ("spi/bcm63xx-hsspi: allow providing clock rate through a second clock"), so there is no need to touch it.
This patch series is part of an effort to modernize BCM63XX and clean up its drivers to eventually make them usable with BMIPS and device tree.
Changes V1 -> V2:
* Drop the bcm63xx_enet patch, it will be sent again once the clkdev lookup is actually applied.
* Added a patch to fix refcounting in the secondary switch clocks.
* Slightly reordered patches to be ordered thematically.
* Added collected Acks / Reviews to their respective patches.
Due to none of the patches having changed between V1 and V2 I did not add individual changelogs. These will be added if the code or commit log text changes.
Jonas Gorski (8):
MIPS: BCM63XX: add clkdev lookup support
MIPS: BCM63XX: provide periph clock as refclk for uart tty/bcm63xx_uart: use refclk for the expected clock name tty/bcm63xx_uart: allow naming clock in device tree
MIPS: BMIPS: name the refclk clock for uart
MIPS: BCM63XX: move the HSSPI PLL HZ into its own clock
MIPS: BCM63XX: provide enet clocks as "enet" to the ethernet devices
MIPS: BCM63XX: split out swpkt_sar/usb clocks
.../bindings/serial/brcm,bcm6345-uart.txt | 6 + arch/mips/Kconfig | 1 + arch/mips/bcm63xx/clk.c | 242 +++++++++++++++++---- arch/mips/boot/dts/brcm/bcm3368.dtsi | 2 + arch/mips/boot/dts/brcm/bcm63268.dtsi | 2 + arch/mips/boot/dts/brcm/bcm6328.dtsi | 2 + arch/mips/boot/dts/brcm/bcm6358.dtsi | 2 + arch/mips/boot/dts/brcm/bcm6362.dtsi | 2 + arch/mips/boot/dts/brcm/bcm6368.dtsi | 2 + drivers/tty/serial/bcm63xx_uart.c | 6 +- 10 files changed, 218 insertions(+), 49 deletions(-)
Signature · 1 line
2.13.2
PATCH v2 1/8 MIPS: BCM63XX: add clkdev lookup support
Enable clkdev lookup support to allow us providing clocks under different names to devices more easily, so we don't need to care about clock name clashes anymore.
--- arch/mips/Kconfig | 1 + arch/mips/bcm63xx/clk.c | 150 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 116 insertions(+), 35 deletions(-)
arch/mips/Kconfig +1 -0
@@ -275,6 +275,7 @@ config BCM63XX select GPIOLIB select HAVE_CLK select MIPS_L1_CACHE_SHIFT_4 + select CLKDEV_LOOKUP help Support for BCM63XX based boards
arch/mips/bcm63xx/clk.c +115 -35
176 lines not on this page · raw message
Signature · 1 line
2.13.2
PATCH v2 2/8 MIPS: BCM63XX: provide periph clock as refclk for uart
In reply to Jonas GorskiAdd a lookup as "refclk" to describe its function for the uarts.
--- arch/mips/bcm63xx/clk.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/mips/bcm63xx/clk.c +13 -0
@@ -363,6 +363,8 @@ EXPORT_SYMBOL_GPL(clk_round_rate);static struct clk_lookup bcm3368_clks[] = {/* fixed rate clocks */ CLKDEV_INIT (NULL ,"periph" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.0" ,"refclk" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.1" ,"refclk" , &clk_periph),/* gated clocks */ CLKDEV_INIT (NULL ,"enet0" , &clk_enet0),CLKDEV_INIT (NULL ,"enet1" , &clk_enet1),
@@ -376,6 +378,8 @@ static struct clk_lookup bcm3368_clks[] = {static struct clk_lookup bcm6328_clks[] = {/* fixed rate clocks */ CLKDEV_INIT (NULL ,"periph" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.0" ,"refclk" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.1" ,"refclk" , &clk_periph),/* gated clocks */ CLKDEV_INIT (NULL ,"enetsw" , &clk_enetsw),CLKDEV_INIT (NULL ,"usbh" , &clk_usbh),
@@ -387,6 +391,7 @@ static struct clk_lookup bcm6328_clks[] = {static struct clk_lookup bcm6338_clks[] = {/* fixed rate clocks */ CLKDEV_INIT (NULL ,"periph" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.0" ,"refclk" , &clk_periph),/* gated clocks */ CLKDEV_INIT (NULL ,"enet0" , &clk_enet0),CLKDEV_INIT (NULL ,"enet1" , &clk_enet1),
@@ -399,6 +404,7 @@ static struct clk_lookup bcm6338_clks[] = {static struct clk_lookup bcm6345_clks[] = {/* fixed rate clocks */ CLKDEV_INIT (NULL ,"periph" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.0" ,"refclk" , &clk_periph),/* gated clocks */ CLKDEV_INIT (NULL ,"enet0" , &clk_enet0),CLKDEV_INIT (NULL ,"enet1" , &clk_enet1),
@@ -411,6 +417,7 @@ static struct clk_lookup bcm6345_clks[] = {static struct clk_lookup bcm6348_clks[] = {/* fixed rate clocks */ CLKDEV_INIT (NULL ,"periph" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.0" ,"refclk" , &clk_periph),/* gated clocks */ CLKDEV_INIT (NULL ,"enet0" , &clk_enet0),CLKDEV_INIT (NULL ,"enet1" , &clk_enet1),
@@ -423,6 +430,8 @@ static struct clk_lookup bcm6348_clks[] = {static struct clk_lookup bcm6358_clks[] = {/* fixed rate clocks */ CLKDEV_INIT (NULL ,"periph" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.0" ,"refclk" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.1" ,"refclk" , &clk_periph),/* gated clocks */ CLKDEV_INIT (NULL ,"enet0" , &clk_enet0),CLKDEV_INIT (NULL ,"enet1" , &clk_enet1),
@@ -436,6 +445,8 @@ static struct clk_lookup bcm6358_clks[] = {static struct clk_lookup bcm6362_clks[] = {/* fixed rate clocks */ CLKDEV_INIT (NULL ,"periph" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.0" ,"refclk" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.1" ,"refclk" , &clk_periph),/* gated clocks */ CLKDEV_INIT (NULL ,"enetsw" , &clk_enetsw),CLKDEV_INIT (NULL ,"usbh" , &clk_usbh),
@@ -449,6 +460,8 @@ static struct clk_lookup bcm6362_clks[] = {static struct clk_lookup bcm6368_clks[] = {/* fixed rate clocks */ CLKDEV_INIT (NULL ,"periph" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.0" ,"refclk" , &clk_periph), +CLKDEV_INIT ("bcm63xx_uart.1" ,"refclk" , &clk_periph),/* gated clocks */ CLKDEV_INIT (NULL ,"enetsw" , &clk_enetsw),CLKDEV_INIT (NULL ,"usbh" , &clk_usbh),
Signature · 1 line
2.13.2
PATCH v2 3/8 tty/bcm63xx_uart: use refclk for the expected clock name
In reply to Jonas GorskiWe now have the clock available under refclk, so use that.
--- drivers/tty/serial/bcm63xx_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/bcm63xx_uart.c +1 -1
@@ -842,7 +842,7 @@ static int bcm_uart_probe(struct platform_device *pdev)return -ENODEV ; clk = pdev->dev.of_node ?of_clk_get (pdev->dev.of_node,0 ) : -clk_get (&pdev->dev,"periph" ); +clk_get (&pdev->dev,"refclk" );if (IS_ERR (clk))return -ENODEV ;
Signature · 1 line
2.13.2
PATCH v2 4/8 tty/bcm63xx_uart: allow naming clock in device tree
In reply to Jonas GorskiCodify using a named clock for the refclk of the uart. This makes it easier if we might need to add a gating clock (like present on the BCM6345).
--- Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.txt | 6 ++++++ drivers/tty/serial/bcm63xx_uart.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.txt +6 -0
@@ -11,6 +11,11 @@ Required properties: - clocks: Clock driving the hardware; used to figure out the baud rate divisor. + +Optional properties: + +- clock-names: Should be "refclk". + Example: uart0: serial at 14e00520 {
@@ -19,6 +24,7 @@ Example: interrupt-parent = <&periph_intc>; interrupts = <2>; clocks = <&periph_clk>; + clock-names = "refclk"; }; clocks {
drivers/tty/serial/bcm63xx_uart.c +4 -2
@@ -841,8 +841,10 @@ static int bcm_uart_probe(struct platform_device *pdev)if (!res_irq)return -ENODEV ; - clk = pdev->dev.of_node ?of_clk_get (pdev->dev.of_node,0 ) : -clk_get (&pdev->dev,"refclk" ); + clk =clk_get (&pdev->dev,"refclk" ); +if (IS_ERR (clk) && pdev->dev.of_node) + clk =of_clk_get (pdev->dev.of_node,0 ); +if (IS_ERR (clk))return -ENODEV ;
Signature · 1 line
2.13.2
PATCH v2 5/8 MIPS: BMIPS: name the refclk clock for uart
In reply to Jonas GorskiAdd the clock name to the uart nodes, to name the input clock properly.
--- arch/mips/boot/dts/brcm/bcm3368.dtsi | 2 ++ arch/mips/boot/dts/brcm/bcm63268.dtsi | 2 ++ arch/mips/boot/dts/brcm/bcm6328.dtsi | 2 ++ arch/mips/boot/dts/brcm/bcm6358.dtsi | 2 ++ arch/mips/boot/dts/brcm/bcm6362.dtsi | 2 ++ arch/mips/boot/dts/brcm/bcm6368.dtsi | 2 ++ 6 files changed, 12 insertions(+)
arch/mips/boot/dts/brcm/bcm3368.dtsi +2 -0
@@ -82,6 +82,7 @@ interrupts = <2>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
@@ -94,6 +95,7 @@ interrupts = <3>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
arch/mips/boot/dts/brcm/bcm63268.dtsi +2 -0
@@ -83,6 +83,7 @@ interrupts = <5>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
@@ -95,6 +96,7 @@ interrupts = <34>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
arch/mips/boot/dts/brcm/bcm6328.dtsi +2 -0
@@ -68,6 +68,7 @@ interrupt-parent = <&periph_intc>; interrupts = <28>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
@@ -77,6 +78,7 @@ interrupt-parent = <&periph_intc>; interrupts = <39>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
arch/mips/boot/dts/brcm/bcm6358.dtsi +2 -0
@@ -92,6 +92,7 @@ interrupts = <2>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
@@ -104,6 +105,7 @@ interrupts = <3>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
arch/mips/boot/dts/brcm/bcm6362.dtsi +2 -0
@@ -83,6 +83,7 @@ interrupts = <3>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
@@ -95,6 +96,7 @@ interrupts = <4>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
arch/mips/boot/dts/brcm/bcm6368.dtsi +2 -0
@@ -89,6 +89,7 @@ interrupt-parent = <&periph_intc>; interrupts = <2>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
@@ -98,6 +99,7 @@ interrupt-parent = <&periph_intc>; interrupts = <3>; clocks = <&periph_clk>; + clock-names = "refclk"; status = "disabled"; };
Signature · 1 line
2.13.2
PATCH v2 6/8 MIPS: BCM63XX: move the HSSPI PLL HZ into its own clock
In reply to Jonas GorskiSplit up the HSSPL clock into rate and a gate clock, to more closely match the actual hardware.
--- arch/mips/bcm63xx/clk.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/mips/bcm63xx/clk.c +8 -2
@@ -248,6 +248,10 @@ static struct clk clk_hsspi = { .set = hsspi_set, }; +/* +* HSSPI PLL +*/ +static struct clk clk_hsspi_pll;/* * XTM clock
@@ -380,6 +384,7 @@ static struct clk_lookup bcm6328_clks[] = {CLKDEV_INIT (NULL ,"periph" , &clk_periph),CLKDEV_INIT ("bcm63xx_uart.0" ,"refclk" , &clk_periph),CLKDEV_INIT ("bcm63xx_uart.1" ,"refclk" , &clk_periph), +CLKDEV_INIT ("bcm63xx-hsspi.0" ,"pll" , &clk_hsspi_pll),/* gated clocks */ CLKDEV_INIT (NULL ,"enetsw" , &clk_enetsw), CLKDEV_INIT(NULL, "usbh", &clk_usbh),
@@ -447,6 +452,7 @@ static struct clk_lookup bcm6362_clks[] = {CLKDEV_INIT (NULL ,"periph" , &clk_periph),CLKDEV_INIT ("bcm63xx_uart.0" ,"refclk" , &clk_periph),CLKDEV_INIT ("bcm63xx_uart.1" ,"refclk" , &clk_periph), +CLKDEV_INIT ("bcm63xx-hsspi.0" ,"pll" , &clk_hsspi_pll),/* gated clocks */ CLKDEV_INIT (NULL ,"enetsw" , &clk_enetsw), CLKDEV_INIT(NULL, "usbh", &clk_usbh),
@@ -481,7 +487,7 @@ static int __init bcm63xx_clk_init(void)clkdev_add_table (bcm3368_clks,ARRAY_SIZE (bcm3368_clks));break ;case BCM6328_CPU_ID : - clk_hsspi.rate =HSSPI_PLL_HZ_6328 ; + clk_hsspi_pll.rate =HSSPI_PLL_HZ_6328 ;clkdev_add_table (bcm6328_clks,ARRAY_SIZE (bcm6328_clks));break ;case BCM6338_CPU_ID :
@@ -497,7 +503,7 @@ static int __init bcm63xx_clk_init(void)clkdev_add_table (bcm6358_clks,ARRAY_SIZE (bcm6358_clks));break ;case BCM6362_CPU_ID : - clk_hsspi.rate =HSSPI_PLL_HZ_6362 ; + clk_hsspi_pll.rate =HSSPI_PLL_HZ_6362 ;clkdev_add_table (bcm6362_clks,ARRAY_SIZE (bcm6362_clks));break ;case BCM6368_CPU_ID :
Signature · 1 line
2.13.2
PATCH v2 7/8 MIPS: BCM63XX: provide enet clocks as "enet" to the ethernet devices
In reply to Jonas GorskiAdd lookups to provide the appropriate enetX clocks as just "enet" to the ethernet devices.
--- arch/mips/bcm63xx/clk.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/mips/bcm63xx/clk.c +8 -0
@@ -377,6 +377,8 @@ static struct clk_lookup bcm3368_clks[] = {CLKDEV_INIT (NULL ,"usbd" , &clk_usbd),CLKDEV_INIT (NULL ,"spi" , &clk_spi),CLKDEV_INIT (NULL ,"pcm" , &clk_pcm), +CLKDEV_INIT ("bcm63xx_enet.0" ,"enet" , &clk_enet0), + CLKDEV_INIT("bcm63xx_enet.1", "enet", &clk_enet1), }; static struct clk_lookup bcm6328_clks[] = {
@@ -404,6 +406,7 @@ static struct clk_lookup bcm6338_clks[] = {CLKDEV_INIT (NULL ,"usbh" , &clk_usbh),CLKDEV_INIT (NULL ,"usbd" , &clk_usbd),CLKDEV_INIT (NULL ,"spi" , &clk_spi), + CLKDEV_INIT("bcm63xx_enet.0", "enet", &clk_enet_misc), }; static struct clk_lookup bcm6345_clks[] = {
@@ -417,6 +420,7 @@ static struct clk_lookup bcm6345_clks[] = {CLKDEV_INIT (NULL ,"usbh" , &clk_usbh),CLKDEV_INIT (NULL ,"usbd" , &clk_usbd),CLKDEV_INIT (NULL ,"spi" , &clk_spi), + CLKDEV_INIT("bcm63xx_enet.0", "enet", &clk_enet_misc), }; static struct clk_lookup bcm6348_clks[] = {
@@ -430,6 +434,8 @@ static struct clk_lookup bcm6348_clks[] = {CLKDEV_INIT (NULL ,"usbh" , &clk_usbh),CLKDEV_INIT (NULL ,"usbd" , &clk_usbd),CLKDEV_INIT (NULL ,"spi" , &clk_spi), +CLKDEV_INIT ("bcm63xx_enet.0" ,"enet" , &clk_enet_misc), + CLKDEV_INIT("bcm63xx_enet.1", "enet", &clk_enet_misc), }; static struct clk_lookup bcm6358_clks[] = {
@@ -445,6 +451,8 @@ static struct clk_lookup bcm6358_clks[] = {CLKDEV_INIT (NULL ,"usbd" , &clk_usbd),CLKDEV_INIT (NULL ,"spi" , &clk_spi),CLKDEV_INIT (NULL ,"pcm" , &clk_pcm), +CLKDEV_INIT ("bcm63xx_enet.0" ,"enet" , &clk_enet0), + CLKDEV_INIT("bcm63xx_enet.1", "enet", &clk_enet1), }; static struct clk_lookup bcm6362_clks[] = {
Signature · 1 line
2.13.2
PATCH v2 8/8 MIPS: BCM63XX: split out swpkt_sar/usb clocks
In reply to Jonas GorskiMake the secondary switch clocks their own clocks. This allows proper enable reference counting between SAR/XTM and the main switch clocks, and controlling them individually from drivers.
--- arch/mips/bcm63xx/clk.c | 61 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 10 deletions(-)
arch/mips/bcm63xx/clk.c +51 -10
@@ -122,21 +122,56 @@ static struct clk clk_ephy = { };/* +* Ethernet switch SAR clock +*/ +static void swpkt_sar_set (struct clk *clk,int enable) +{ +if (BCMCPU_IS_6368 ()) +bcm_hwclock_set (CKCTL_6368_SWPKT_SAR_EN , enable); +else +return ; +} + +static struct clk clk_swpkt_sar = { + .set = swpkt_sar_set, +}; + +/* +* Ethernet switch USB clock +*/ +static void swpkt_usb_set (struct clk *clk,int enable) +{ +if (BCMCPU_IS_6368 ()) +bcm_hwclock_set (CKCTL_6368_SWPKT_USB_EN , enable); +else +return ; +} + +static struct clk clk_swpkt_usb = { + .set = swpkt_usb_set, +}; + +/* * Ethernet switch clock */ static void enetsw_set (struct clk *clk,int enable) { -if (BCMCPU_IS_6328 ()) +if (BCMCPU_IS_6328 ()) {bcm_hwclock_set (CKCTL_6328_ROBOSW_EN , enable); -else if (BCMCPU_IS_6362 ()) + }else if (BCMCPU_IS_6362 ()) {bcm_hwclock_set (CKCTL_6362_ROBOSW_EN , enable); -else if (BCMCPU_IS_6368 ()) -bcm_hwclock_set (CKCTL_6368_ROBOSW_EN | -CKCTL_6368_SWPKT_USB_EN | -CKCTL_6368_SWPKT_SAR_EN , - enable); -else + }else if (BCMCPU_IS_6368 ()) { +if (enable) { +clk_enable_unlocked (&clk_swpkt_sar); +clk_enable_unlocked (&clk_swpkt_usb); + }else { +clk_disable_unlocked (&clk_swpkt_usb); +clk_disable_unlocked (&clk_swpkt_sar); + } +bcm_hwclock_set (CKCTL_6368_ROBOSW_EN , enable); + }else {return ; + }if (enable) {/* reset switch core afer clock change */
@@ -261,8 +296,12 @@ static void xtm_set(struct clk *clk, int enable)if (!BCMCPU_IS_6368 ())return ; -bcm_hwclock_set (CKCTL_6368_SAR_EN | -CKCTL_6368_SWPKT_SAR_EN , enable); +if (enable) +clk_enable_unlocked (&clk_swpkt_sar); +else +clk_disable_unlocked (&clk_swpkt_sar); + +bcm_hwclock_set (CKCTL_6368_SAR_EN , enable);if (enable) {/* reset sar core afer clock change */
@@ -451,6 +490,8 @@ static struct clk_lookup bcm6358_clks[] = {CLKDEV_INIT (NULL ,"usbd" , &clk_usbd),CLKDEV_INIT (NULL ,"spi" , &clk_spi),CLKDEV_INIT (NULL ,"pcm" , &clk_pcm), +CLKDEV_INIT (NULL ,"swpkt_sar" , &clk_swpkt_sar), +CLKDEV_INIT (NULL ,"swpkt_usb" , &clk_swpkt_usb),CLKDEV_INIT ("bcm63xx_enet.0" ,"enet" , &clk_enet0), CLKDEV_INIT("bcm63xx_enet.1", "enet", &clk_enet1), };
Signature · 1 line
2.13.2