-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'depends/clk-rk3368' into next/arm64
Merge in dependent stable branch with clk driver for RK3368, needed for the dt binding header files. * depends/clk-rk3368: clk: rockchip: add rk3368 clock controller clk: rockchip: add missing include guards clk: rockchip: add dt-binding header for rk3368 dt-bindings: add documentation of rk3668 clock controller clk: rockchip: define the inverters of rk3066/rk3188 and rk3288 clk: rockchip: fix issues in the mmc-phase clock clk: rockchip: add support for phase inverters clk: rockchip: add COMPOSITE_NOGATE_DIVTBL variant clk: rockchip: protect register macros against multipart values clk: rockchip: fix faulty vip parent name on rk3288 clk: rockchip: rk3288: add CLK_SET_RATE_PARENT to sclk_mac Signed-off-by: Olof Johansson <olof@lixom.net>
- Loading branch information
Showing
14 changed files
with
1,555 additions
and
16 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
Documentation/devicetree/bindings/clock/rockchip,rk3368-cru.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
* Rockchip RK3368 Clock and Reset Unit | ||
|
||
The RK3368 clock controller generates and supplies clock to various | ||
controllers within the SoC and also implements a reset controller for SoC | ||
peripherals. | ||
|
||
Required Properties: | ||
|
||
- compatible: should be "rockchip,rk3368-cru" | ||
- reg: physical base address of the controller and length of memory mapped | ||
region. | ||
- #clock-cells: should be 1. | ||
- #reset-cells: should be 1. | ||
|
||
Optional Properties: | ||
|
||
- rockchip,grf: phandle to the syscon managing the "general register files" | ||
If missing, pll rates are not changeable, due to the missing pll lock status. | ||
|
||
Each clock is assigned an identifier and client nodes can use this identifier | ||
to specify the clock which they consume. All available clocks are defined as | ||
preprocessor macros in the dt-bindings/clock/rk3368-cru.h headers and can be | ||
used in device tree sources. Similar macros exist for the reset sources in | ||
these files. | ||
|
||
External clocks: | ||
|
||
There are several clocks that are generated outside the SoC. It is expected | ||
that they are defined using standard clock bindings with following | ||
clock-output-names: | ||
- "xin24m" - crystal input - required, | ||
- "xin32k" - rtc clock - optional, | ||
- "ext_i2s" - external I2S clock - optional, | ||
- "ext_gmac" - external GMAC clock - optional | ||
- "ext_hsadc" - external HSADC clock - optional, | ||
- "ext_isp" - external ISP clock - optional, | ||
- "ext_jtag" - external JTAG clock - optional | ||
- "ext_vip" - external VIP clock - optional, | ||
- "usbotg_out" - output clock of the pll in the otg phy | ||
|
||
Example: Clock controller node: | ||
|
||
cru: clock-controller@ff760000 { | ||
compatible = "rockchip,rk3368-cru"; | ||
reg = <0x0 0xff760000 0x0 0x1000>; | ||
rockchip,grf = <&grf>; | ||
#clock-cells = <1>; | ||
#reset-cells = <1>; | ||
}; | ||
|
||
Example: UART controller node that consumes the clock generated by the clock | ||
controller: | ||
|
||
uart0: serial@10124000 { | ||
compatible = "snps,dw-apb-uart"; | ||
reg = <0x10124000 0x400>; | ||
interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>; | ||
reg-shift = <2>; | ||
reg-io-width = <1>; | ||
clocks = <&cru SCLK_UART0>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
* Copyright 2015 Heiko Stuebner <heiko@sntech.de> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
#include <linux/slab.h> | ||
#include <linux/clk-provider.h> | ||
#include <linux/io.h> | ||
#include <linux/spinlock.h> | ||
#include <linux/kernel.h> | ||
#include "clk.h" | ||
|
||
struct rockchip_inv_clock { | ||
struct clk_hw hw; | ||
void __iomem *reg; | ||
int shift; | ||
int flags; | ||
spinlock_t *lock; | ||
}; | ||
|
||
#define to_inv_clock(_hw) container_of(_hw, struct rockchip_inv_clock, hw) | ||
|
||
#define INVERTER_MASK 0x1 | ||
|
||
static int rockchip_inv_get_phase(struct clk_hw *hw) | ||
{ | ||
struct rockchip_inv_clock *inv_clock = to_inv_clock(hw); | ||
u32 val; | ||
|
||
val = readl(inv_clock->reg) >> inv_clock->shift; | ||
val &= INVERTER_MASK; | ||
return val ? 180 : 0; | ||
} | ||
|
||
static int rockchip_inv_set_phase(struct clk_hw *hw, int degrees) | ||
{ | ||
struct rockchip_inv_clock *inv_clock = to_inv_clock(hw); | ||
u32 val; | ||
|
||
if (degrees % 180 == 0) { | ||
val = !!degrees; | ||
} else { | ||
pr_err("%s: unsupported phase %d for %s\n", | ||
__func__, degrees, __clk_get_name(hw->clk)); | ||
return -EINVAL; | ||
} | ||
|
||
if (inv_clock->flags & ROCKCHIP_INVERTER_HIWORD_MASK) { | ||
writel(HIWORD_UPDATE(val, INVERTER_MASK, inv_clock->shift), | ||
inv_clock->reg); | ||
} else { | ||
unsigned long flags; | ||
u32 reg; | ||
|
||
spin_lock_irqsave(inv_clock->lock, flags); | ||
|
||
reg = readl(inv_clock->reg); | ||
reg &= ~BIT(inv_clock->shift); | ||
reg |= val; | ||
writel(reg, inv_clock->reg); | ||
|
||
spin_unlock_irqrestore(inv_clock->lock, flags); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static const struct clk_ops rockchip_inv_clk_ops = { | ||
.get_phase = rockchip_inv_get_phase, | ||
.set_phase = rockchip_inv_set_phase, | ||
}; | ||
|
||
struct clk *rockchip_clk_register_inverter(const char *name, | ||
const char *const *parent_names, u8 num_parents, | ||
void __iomem *reg, int shift, int flags, | ||
spinlock_t *lock) | ||
{ | ||
struct clk_init_data init; | ||
struct rockchip_inv_clock *inv_clock; | ||
struct clk *clk; | ||
|
||
inv_clock = kmalloc(sizeof(*inv_clock), GFP_KERNEL); | ||
if (!inv_clock) | ||
return NULL; | ||
|
||
init.name = name; | ||
init.num_parents = num_parents; | ||
init.flags = CLK_SET_RATE_PARENT; | ||
init.parent_names = parent_names; | ||
init.ops = &rockchip_inv_clk_ops; | ||
|
||
inv_clock->hw.init = &init; | ||
inv_clock->reg = reg; | ||
inv_clock->shift = shift; | ||
inv_clock->flags = flags; | ||
inv_clock->lock = lock; | ||
|
||
clk = clk_register(NULL, &inv_clock->hw); | ||
if (IS_ERR(clk)) | ||
goto err_free; | ||
|
||
return clk; | ||
|
||
err_free: | ||
kfree(inv_clock); | ||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.