1 /* linux/arch/arm/mach-s5pv310/setup-mali.c
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
6 * Inki Dae <inki.dae@samsung.com>
8 * clock configuration for MALI
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
16 #include <linux/clk.h>
17 #include <linux/err.h>
18 #include <linux/kernel.h>
19 #include <linux/types.h>
20 #include <linux/device.h>
21 #include <linux/regulator/consumer.h>
23 #include <plat/mali.h>
25 #include <mach/regs-clock.h>
27 struct mali_platform_data mali_pd = {
28 .g3d_clk_name = "g3d",
29 .ppmug3d_clk_name = "ppmug3d"
32 int universal_mali_power_on(unsigned int enable)
34 struct regulator *regulator;
37 regulator = regulator_get(NULL, "vg3d_1.2v_c210");
38 if (IS_ERR(regulator)) {
39 printk("failed to get vg3d_1.2v_c210.\n");
42 regulator_enable(regulator);
43 regulator_put(regulator);
45 regulator = regulator_get(NULL, "vg3d_1.2v_c210");
46 if (IS_ERR(regulator)) {
47 printk("failed to get vg3d_1.2v_c210.\n");
50 if (regulator_is_enabled(regulator))
51 regulator_force_disable(regulator);
52 regulator_put(regulator);
58 int universal_mali_power_domain_on(unsigned int enable)
63 /* G3D_CONFIGURATION. */
64 writel(0x7, S5P_G3D_CONFIGURATION);
65 /* check power mode. */
66 while(!(readl(S5P_G3D_STATUS) & 0x7));
68 /* CLK_GATE_BLOCK(g3d to pass). */
69 reg = readl(S5P_CLKGATE_BLOCK);
72 writel(reg, S5P_CLKGATE_BLOCK);
74 /* CLK_GATE_BLOCK(g3d to pass). */
75 reg = readl(S5P_CLKGATE_BLOCK);
78 writel(reg, S5P_CLKGATE_BLOCK);
80 /* G3D_CONFIGURATION. */
81 writel(0x0, S5P_G3D_CONFIGURATION);
82 /* check power mode. */
83 while(((readl(S5P_G3D_STATUS) & 0x7) != 0));
89 int universal_mali_setup_clock(const char *sclk_name, const char *pclk_name,
92 struct clk *sclk = NULL;
93 struct clk *pclk = NULL;
95 sclk = clk_get(NULL, sclk_name);
97 dev_err(NULL, "failed to get %s clock.\n", sclk_name);
101 pclk = clk_get(NULL, pclk_name);
103 dev_err(NULL, "failed to get %s clock.\n", pclk_name);
107 clk_set_parent(sclk, pclk);
110 clk_set_rate(sclk, rate);
112 dev_dbg(NULL, "set parent clock of %s to %s\n", sclk_name, pclk_name);