Commit 6082d88e authored by Stephen Boyd's avatar Stephen Boyd

Merge branch 'v4.3-rc3-clk' of https://github.com/jamesjjliao/linux into clk-next

Pull mediatek clock support and fixes from James Liao:

"This is a collection of new Mediatek clocks support and fixes.
These patches come from Joe and me, including clock support for
subsystems, GPT and some minor fixes."

* 'v4.3-rc3-clk' of https://github.com/jamesjjliao/linux:
  clk: mediatek: Add USB clock support in MT8173 APMIXEDSYS
  clk: mediatek: Add subsystem clocks of MT8173
  dt-bindings: ARM: Mediatek: Document devicetree bindings for clock controllers
  clk: mediatek: Fix rate and dependency of MT8173 clocks
  clk: mediatek: Add fixed clocks support for Mediatek SoC.
  clk: mediatek: Add __initdata and __init for data and functions
  clk: mediatek: Remove unused code from MT8173.
  clk: mediatek: Removed unused dpi_ck clock from MT8173
  clk: mediatek: add 13mhz clock for MT8173
parents 12b5aa61 cdb2bab7
Mediatek imgsys controller
============================
The Mediatek imgsys controller provides various clocks to the system.
Required Properties:
- compatible: Should be:
- "mediatek,mt8173-imgsys", "syscon"
- #clock-cells: Must be 1
The imgsys controller uses the common clk binding from
Documentation/devicetree/bindings/clock/clock-bindings.txt
The available clocks are defined in dt-bindings/clock/mt*-clk.h.
Example:
imgsys: clock-controller@15000000 {
compatible = "mediatek,mt8173-imgsys", "syscon";
reg = <0 0x15000000 0 0x1000>;
#clock-cells = <1>;
};
Mediatek mmsys controller
============================
The Mediatek mmsys controller provides various clocks to the system.
Required Properties:
- compatible: Should be:
- "mediatek,mt8173-mmsys", "syscon"
- #clock-cells: Must be 1
The mmsys controller uses the common clk binding from
Documentation/devicetree/bindings/clock/clock-bindings.txt
The available clocks are defined in dt-bindings/clock/mt*-clk.h.
Example:
mmsys: clock-controller@14000000 {
compatible = "mediatek,mt8173-mmsys", "syscon";
reg = <0 0x14000000 0 0x1000>;
#clock-cells = <1>;
};
Mediatek vdecsys controller
============================
The Mediatek vdecsys controller provides various clocks to the system.
Required Properties:
- compatible: Should be:
- "mediatek,mt8173-vdecsys", "syscon"
- #clock-cells: Must be 1
The vdecsys controller uses the common clk binding from
Documentation/devicetree/bindings/clock/clock-bindings.txt
The available clocks are defined in dt-bindings/clock/mt*-clk.h.
Example:
vdecsys: clock-controller@16000000 {
compatible = "mediatek,mt8173-vdecsys", "syscon";
reg = <0 0x16000000 0 0x1000>;
#clock-cells = <1>;
};
Mediatek vencltsys controller
============================
The Mediatek vencltsys controller provides various clocks to the system.
Required Properties:
- compatible: Should be:
- "mediatek,mt8173-vencltsys", "syscon"
- #clock-cells: Must be 1
The vencltsys controller uses the common clk binding from
Documentation/devicetree/bindings/clock/clock-bindings.txt
The available clocks are defined in dt-bindings/clock/mt*-clk.h.
Example:
vencltsys: clock-controller@19000000 {
compatible = "mediatek,mt8173-vencltsys", "syscon";
reg = <0 0x19000000 0 0x1000>;
#clock-cells = <1>;
};
Mediatek vencsys controller
============================
The Mediatek vencsys controller provides various clocks to the system.
Required Properties:
- compatible: Should be:
- "mediatek,mt8173-vencsys", "syscon"
- #clock-cells: Must be 1
The vencsys controller uses the common clk binding from
Documentation/devicetree/bindings/clock/clock-bindings.txt
The available clocks are defined in dt-bindings/clock/mt*-clk.h.
Example:
vencsys: clock-controller@18000000 {
compatible = "mediatek,mt8173-vencsys", "syscon";
reg = <0 0x18000000 0 0x1000>;
#clock-cells = <1>;
};
obj-y += clk-mtk.o clk-pll.o clk-gate.o obj-y += clk-mtk.o clk-pll.o clk-gate.o clk-apmixed.o
obj-$(CONFIG_RESET_CONTROLLER) += reset.o obj-$(CONFIG_RESET_CONTROLLER) += reset.o
obj-y += clk-mt8135.o obj-y += clk-mt8135.o
obj-y += clk-mt8173.o obj-y += clk-mt8173.o
/*
* Copyright (c) 2015 MediaTek Inc.
* Author: James Liao <jamesjj.liao@mediatek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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/delay.h>
#include <linux/of_address.h>
#include <linux/slab.h>
#include "clk-mtk.h"
#define REF2USB_TX_EN BIT(0)
#define REF2USB_TX_LPF_EN BIT(1)
#define REF2USB_TX_OUT_EN BIT(2)
#define REF2USB_EN_MASK (REF2USB_TX_EN | REF2USB_TX_LPF_EN | \
REF2USB_TX_OUT_EN)
struct mtk_ref2usb_tx {
struct clk_hw hw;
void __iomem *base_addr;
};
static inline struct mtk_ref2usb_tx *to_mtk_ref2usb_tx(struct clk_hw *hw)
{
return container_of(hw, struct mtk_ref2usb_tx, hw);
}
static int mtk_ref2usb_tx_is_prepared(struct clk_hw *hw)
{
struct mtk_ref2usb_tx *tx = to_mtk_ref2usb_tx(hw);
return (readl(tx->base_addr) & REF2USB_EN_MASK) == REF2USB_EN_MASK;
}
static int mtk_ref2usb_tx_prepare(struct clk_hw *hw)
{
struct mtk_ref2usb_tx *tx = to_mtk_ref2usb_tx(hw);
u32 val;
val = readl(tx->base_addr);
val |= REF2USB_TX_EN;
writel(val, tx->base_addr);
udelay(100);
val |= REF2USB_TX_LPF_EN;
writel(val, tx->base_addr);
val |= REF2USB_TX_OUT_EN;
writel(val, tx->base_addr);
return 0;
}
static void mtk_ref2usb_tx_unprepare(struct clk_hw *hw)
{
struct mtk_ref2usb_tx *tx = to_mtk_ref2usb_tx(hw);
u32 val;
val = readl(tx->base_addr);
val &= ~REF2USB_EN_MASK;
writel(val, tx->base_addr);
}
static const struct clk_ops mtk_ref2usb_tx_ops = {
.is_prepared = mtk_ref2usb_tx_is_prepared,
.prepare = mtk_ref2usb_tx_prepare,
.unprepare = mtk_ref2usb_tx_unprepare,
};
struct clk * __init mtk_clk_register_ref2usb_tx(const char *name,
const char *parent_name, void __iomem *reg)
{
struct mtk_ref2usb_tx *tx;
struct clk_init_data init = {};
struct clk *clk;
tx = kzalloc(sizeof(*tx), GFP_KERNEL);
if (!tx)
return ERR_PTR(-ENOMEM);
tx->base_addr = reg;
tx->hw.init = &init;
init.name = name;
init.ops = &mtk_ref2usb_tx_ops;
init.parent_names = &parent_name;
init.num_parents = 1;
clk = clk_register(NULL, &tx->hw);
if (IS_ERR(clk)) {
pr_err("Failed to register clk %s: %ld\n", name, PTR_ERR(clk));
kfree(tx);
}
return clk;
}
...@@ -97,7 +97,7 @@ const struct clk_ops mtk_clk_gate_ops_setclr_inv = { ...@@ -97,7 +97,7 @@ const struct clk_ops mtk_clk_gate_ops_setclr_inv = {
.disable = mtk_cg_disable_inv, .disable = mtk_cg_disable_inv,
}; };
struct clk *mtk_clk_register_gate( struct clk * __init mtk_clk_register_gate(
const char *name, const char *name,
const char *parent_name, const char *parent_name,
struct regmap *regmap, struct regmap *regmap,
......
This diff is collapsed.
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "clk-mtk.h" #include "clk-mtk.h"
#include "clk-gate.h" #include "clk-gate.h"
struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num) struct clk_onecell_data * __init mtk_alloc_clk_data(unsigned int clk_num)
{ {
int i; int i;
struct clk_onecell_data *clk_data; struct clk_onecell_data *clk_data;
...@@ -49,8 +49,31 @@ struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num) ...@@ -49,8 +49,31 @@ struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num)
return NULL; return NULL;
} }
void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, void __init mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks,
struct clk_onecell_data *clk_data) int num, struct clk_onecell_data *clk_data)
{
int i;
struct clk *clk;
for (i = 0; i < num; i++) {
const struct mtk_fixed_clk *rc = &clks[i];
clk = clk_register_fixed_rate(NULL, rc->name, rc->parent,
rc->parent ? 0 : CLK_IS_ROOT, rc->rate);
if (IS_ERR(clk)) {
pr_err("Failed to register clk %s: %ld\n",
rc->name, PTR_ERR(clk));
continue;
}
if (clk_data)
clk_data->clks[rc->id] = clk;
}
}
void __init mtk_clk_register_factors(const struct mtk_fixed_factor *clks,
int num, struct clk_onecell_data *clk_data)
{ {
int i; int i;
struct clk *clk; struct clk *clk;
...@@ -72,7 +95,8 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, ...@@ -72,7 +95,8 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num,
} }
} }
int mtk_clk_register_gates(struct device_node *node, const struct mtk_gate *clks, int __init mtk_clk_register_gates(struct device_node *node,
const struct mtk_gate *clks,
int num, struct clk_onecell_data *clk_data) int num, struct clk_onecell_data *clk_data)
{ {
int i; int i;
...@@ -111,7 +135,7 @@ int mtk_clk_register_gates(struct device_node *node, const struct mtk_gate *clks ...@@ -111,7 +135,7 @@ int mtk_clk_register_gates(struct device_node *node, const struct mtk_gate *clks
return 0; return 0;
} }
struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, struct clk * __init mtk_clk_register_composite(const struct mtk_composite *mc,
void __iomem *base, spinlock_t *lock) void __iomem *base, spinlock_t *lock)
{ {
struct clk *clk; struct clk *clk;
...@@ -196,7 +220,7 @@ struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, ...@@ -196,7 +220,7 @@ struct clk *mtk_clk_register_composite(const struct mtk_composite *mc,
return ERR_PTR(ret); return ERR_PTR(ret);
} }
void mtk_clk_register_composites(const struct mtk_composite *mcs, void __init mtk_clk_register_composites(const struct mtk_composite *mcs,
int num, void __iomem *base, spinlock_t *lock, int num, void __iomem *base, spinlock_t *lock,
struct clk_onecell_data *clk_data) struct clk_onecell_data *clk_data)
{ {
......
...@@ -26,6 +26,23 @@ struct clk; ...@@ -26,6 +26,23 @@ struct clk;
#define MHZ (1000 * 1000) #define MHZ (1000 * 1000)
struct mtk_fixed_clk {
int id;
const char *name;
const char *parent;
unsigned long rate;
};
#define FIXED_CLK(_id, _name, _parent, _rate) { \
.id = _id, \
.name = _name, \
.parent = _parent, \
.rate = _rate, \
}
void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks,
int num, struct clk_onecell_data *clk_data);
struct mtk_fixed_factor { struct mtk_fixed_factor {
int id; int id;
const char *name; const char *name;
...@@ -42,7 +59,7 @@ struct mtk_fixed_factor { ...@@ -42,7 +59,7 @@ struct mtk_fixed_factor {
.div = _div, \ .div = _div, \
} }
extern void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,
int num, struct clk_onecell_data *clk_data); int num, struct clk_onecell_data *clk_data);
struct mtk_composite { struct mtk_composite {
...@@ -159,10 +176,13 @@ struct mtk_pll_data { ...@@ -159,10 +176,13 @@ struct mtk_pll_data {
const struct mtk_pll_div_table *div_table; const struct mtk_pll_div_table *div_table;
}; };
void __init mtk_clk_register_plls(struct device_node *node, void mtk_clk_register_plls(struct device_node *node,
const struct mtk_pll_data *plls, int num_plls, const struct mtk_pll_data *plls, int num_plls,
struct clk_onecell_data *clk_data); struct clk_onecell_data *clk_data);
struct clk *mtk_clk_register_ref2usb_tx(const char *name,
const char *parent_name, void __iomem *reg);
#ifdef CONFIG_RESET_CONTROLLER #ifdef CONFIG_RESET_CONTROLLER
void mtk_register_reset_controller(struct device_node *np, void mtk_register_reset_controller(struct device_node *np,
unsigned int num_regs, int regofs); unsigned int num_regs, int regofs);
......
...@@ -317,7 +317,7 @@ void __init mtk_clk_register_plls(struct device_node *node, ...@@ -317,7 +317,7 @@ void __init mtk_clk_register_plls(struct device_node *node,
const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *clk_data) const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *clk_data)
{ {
void __iomem *base; void __iomem *base;
int r, i; int i;
struct clk *clk; struct clk *clk;
base = of_iomap(node, 0); base = of_iomap(node, 0);
...@@ -339,9 +339,4 @@ void __init mtk_clk_register_plls(struct device_node *node, ...@@ -339,9 +339,4 @@ void __init mtk_clk_register_plls(struct device_node *node,
clk_data->clks[pll->id] = clk; clk_data->clks[pll->id] = clk;
} }
r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
if (r)
pr_err("%s(): could not register clock provider: %d\n",
__func__, r);
} }
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
/* TOPCKGEN */ /* TOPCKGEN */
#define CLK_TOP_CLKPH_MCK_O 1 #define CLK_TOP_CLKPH_MCK_O 1
#define CLK_TOP_DPI 2
#define CLK_TOP_USB_SYSPLL_125M 3 #define CLK_TOP_USB_SYSPLL_125M 3
#define CLK_TOP_HDMITX_DIG_CTS 4 #define CLK_TOP_HDMITX_DIG_CTS 4
#define CLK_TOP_ARMCA7PLL_754M 5 #define CLK_TOP_ARMCA7PLL_754M 5
...@@ -154,7 +153,11 @@ ...@@ -154,7 +153,11 @@
#define CLK_TOP_I2S2_M_SEL 135 #define CLK_TOP_I2S2_M_SEL 135
#define CLK_TOP_I2S3_M_SEL 136 #define CLK_TOP_I2S3_M_SEL 136
#define CLK_TOP_I2S3_B_SEL 137 #define CLK_TOP_I2S3_B_SEL 137
#define CLK_TOP_NR_CLK 138 #define CLK_TOP_DSI0_DIG 138
#define CLK_TOP_DSI1_DIG 139
#define CLK_TOP_LVDS_PXL 140
#define CLK_TOP_LVDS_CTS 141
#define CLK_TOP_NR_CLK 142
/* APMIXED_SYS */ /* APMIXED_SYS */
...@@ -172,7 +175,8 @@ ...@@ -172,7 +175,8 @@
#define CLK_APMIXED_APLL2 12 #define CLK_APMIXED_APLL2 12
#define CLK_APMIXED_LVDSPLL 13 #define CLK_APMIXED_LVDSPLL 13
#define CLK_APMIXED_MSDCPLL2 14 #define CLK_APMIXED_MSDCPLL2 14
#define CLK_APMIXED_NR_CLK 15 #define CLK_APMIXED_REF2USB_TX 15
#define CLK_APMIXED_NR_CLK 16
/* INFRA_SYS */ /* INFRA_SYS */
...@@ -187,7 +191,8 @@ ...@@ -187,7 +191,8 @@
#define CLK_INFRA_CEC 9 #define CLK_INFRA_CEC 9
#define CLK_INFRA_PMICSPI 10 #define CLK_INFRA_PMICSPI 10
#define CLK_INFRA_PMICWRAP 11 #define CLK_INFRA_PMICWRAP 11
#define CLK_INFRA_NR_CLK 12 #define CLK_INFRA_CLK_13M 12
#define CLK_INFRA_NR_CLK 13
/* PERI_SYS */ /* PERI_SYS */
...@@ -232,4 +237,91 @@ ...@@ -232,4 +237,91 @@
#define CLK_PERI_UART3_SEL 39 #define CLK_PERI_UART3_SEL 39
#define CLK_PERI_NR_CLK 40 #define CLK_PERI_NR_CLK 40
/* IMG_SYS */
#define CLK_IMG_LARB2_SMI 1
#define CLK_IMG_CAM_SMI 2
#define CLK_IMG_CAM_CAM 3
#define CLK_IMG_SEN_TG 4
#define CLK_IMG_SEN_CAM 5
#define CLK_IMG_CAM_SV 6
#define CLK_IMG_FD 7
#define CLK_IMG_NR_CLK 8
/* MM_SYS */
#define CLK_MM_SMI_COMMON 1
#define CLK_MM_SMI_LARB0 2
#define CLK_MM_CAM_MDP 3
#define CLK_MM_MDP_RDMA0 4
#define CLK_MM_MDP_RDMA1 5
#define CLK_MM_MDP_RSZ0 6
#define CLK_MM_MDP_RSZ1 7
#define CLK_MM_MDP_RSZ2 8
#define CLK_MM_MDP_TDSHP0 9
#define CLK_MM_MDP_TDSHP1 10
#define CLK_MM_MDP_WDMA 11
#define CLK_MM_MDP_WROT0 12
#define CLK_MM_MDP_WROT1 13
#define CLK_MM_FAKE_ENG 14
#define CLK_MM_MUTEX_32K 15
#define CLK_MM_DISP_OVL0 16
#define CLK_MM_DISP_OVL1 17
#define CLK_MM_DISP_RDMA0 18
#define CLK_MM_DISP_RDMA1 19
#define CLK_MM_DISP_RDMA2 20
#define CLK_MM_DISP_WDMA0 21
#define CLK_MM_DISP_WDMA1 22
#define CLK_MM_DISP_COLOR0 23
#define CLK_MM_DISP_COLOR1 24
#define CLK_MM_DISP_AAL 25
#define CLK_MM_DISP_GAMMA 26
#define CLK_MM_DISP_UFOE 27
#define CLK_MM_DISP_SPLIT0 28
#define CLK_MM_DISP_SPLIT1 29
#define CLK_MM_DISP_MERGE 30
#define CLK_MM_DISP_OD 31
#define CLK_MM_DISP_PWM0MM 32
#define CLK_MM_DISP_PWM026M 33
#define CLK_MM_DISP_PWM1MM 34
#define CLK_MM_DISP_PWM126M 35
#define CLK_MM_DSI0_ENGINE 36
#define CLK_MM_DSI0_DIGITAL 37
#define CLK_MM_DSI1_ENGINE 38
#define CLK_MM_DSI1_DIGITAL 39
#define CLK_MM_DPI_PIXEL 40
#define CLK_MM_DPI_ENGINE 41
#define CLK_MM_DPI1_PIXEL 42
#define CLK_MM_DPI1_ENGINE 43
#define CLK_MM_HDMI_PIXEL 44
#define CLK_MM_HDMI_PLLCK 45
#define CLK_MM_HDMI_AUDIO 46
#define CLK_MM_HDMI_SPDIF 47
#define CLK_MM_LVDS_PIXEL 48
#define CLK_MM_LVDS_CTS 49
#define CLK_MM_SMI_LARB4 50
#define CLK_MM_HDMI_HDCP 51
#define CLK_MM_HDMI_HDCP24M 52
#define CLK_MM_NR_CLK 53
/* VDEC_SYS */
#define CLK_VDEC_CKEN 1
#define CLK_VDEC_LARB_CKEN 2
#define CLK_VDEC_NR_CLK 3
/* VENC_SYS */
#define CLK_VENC_CKE0 1
#define CLK_VENC_CKE1 2
#define CLK_VENC_CKE2 3
#define CLK_VENC_CKE3 4
#define CLK_VENC_NR_CLK 5
/* VENCLT_SYS */
#define CLK_VENCLT_CKE0 1
#define CLK_VENCLT_CKE1 2
#define CLK_VENCLT_NR_CLK 3
#endif /* _DT_BINDINGS_CLK_MT8173_H */ #endif /* _DT_BINDINGS_CLK_MT8173_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment