| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de> |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 6 | | - * published by the Free Software Foundation. |
|---|
| 7 | 4 | * |
|---|
| 8 | 5 | * Common Clock Framework support for s3c24xx external clock output. |
|---|
| 9 | 6 | */ |
|---|
| .. | .. |
|---|
| 12 | 9 | #include <linux/slab.h> |
|---|
| 13 | 10 | #include <linux/clk.h> |
|---|
| 14 | 11 | #include <linux/clk-provider.h> |
|---|
| 12 | +#include <linux/io.h> |
|---|
| 15 | 13 | #include <linux/platform_device.h> |
|---|
| 14 | +#include <linux/platform_data/clk-s3c2410.h> |
|---|
| 16 | 15 | #include <linux/module.h> |
|---|
| 17 | 16 | #include "clk.h" |
|---|
| 18 | | - |
|---|
| 19 | | -/* legacy access to misccr, until dt conversion is finished */ |
|---|
| 20 | | -#include <mach/hardware.h> |
|---|
| 21 | | -#include <mach/regs-gpio.h> |
|---|
| 22 | 17 | |
|---|
| 23 | 18 | #define MUX_DCLK0 0 |
|---|
| 24 | 19 | #define MUX_DCLK1 1 |
|---|
| .. | .. |
|---|
| 54 | 49 | struct clk_hw hw; |
|---|
| 55 | 50 | u32 mask; |
|---|
| 56 | 51 | u8 shift; |
|---|
| 52 | + unsigned int (*modify_misccr)(unsigned int clr, unsigned int chg); |
|---|
| 57 | 53 | }; |
|---|
| 58 | 54 | |
|---|
| 59 | 55 | #define to_s3c24xx_clkout(_hw) container_of(_hw, struct s3c24xx_clkout, hw) |
|---|
| .. | .. |
|---|
| 64 | 60 | int num_parents = clk_hw_get_num_parents(hw); |
|---|
| 65 | 61 | u32 val; |
|---|
| 66 | 62 | |
|---|
| 67 | | - val = readl_relaxed(S3C24XX_MISCCR) >> clkout->shift; |
|---|
| 63 | + val = clkout->modify_misccr(0, 0) >> clkout->shift; |
|---|
| 68 | 64 | val >>= clkout->shift; |
|---|
| 69 | 65 | val &= clkout->mask; |
|---|
| 70 | 66 | |
|---|
| .. | .. |
|---|
| 78 | 74 | { |
|---|
| 79 | 75 | struct s3c24xx_clkout *clkout = to_s3c24xx_clkout(hw); |
|---|
| 80 | 76 | |
|---|
| 81 | | - s3c2410_modify_misccr((clkout->mask << clkout->shift), |
|---|
| 77 | + clkout->modify_misccr((clkout->mask << clkout->shift), |
|---|
| 82 | 78 | (index << clkout->shift)); |
|---|
| 83 | 79 | |
|---|
| 84 | 80 | return 0; |
|---|
| .. | .. |
|---|
| 94 | 90 | const char *name, const char **parent_names, u8 num_parents, |
|---|
| 95 | 91 | u8 shift, u32 mask) |
|---|
| 96 | 92 | { |
|---|
| 93 | + struct s3c2410_clk_platform_data *pdata = dev_get_platdata(dev); |
|---|
| 97 | 94 | struct s3c24xx_clkout *clkout; |
|---|
| 98 | | - struct clk_init_data init = {}; |
|---|
| 95 | + struct clk_init_data init; |
|---|
| 99 | 96 | int ret; |
|---|
| 97 | + |
|---|
| 98 | + if (!pdata) |
|---|
| 99 | + return ERR_PTR(-EINVAL); |
|---|
| 100 | 100 | |
|---|
| 101 | 101 | /* allocate the clkout */ |
|---|
| 102 | 102 | clkout = kzalloc(sizeof(*clkout), GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 105 | 105 | |
|---|
| 106 | 106 | init.name = name; |
|---|
| 107 | 107 | init.ops = &s3c24xx_clkout_ops; |
|---|
| 108 | | - init.flags = CLK_IS_BASIC; |
|---|
| 108 | + init.flags = 0; |
|---|
| 109 | 109 | init.parent_names = parent_names; |
|---|
| 110 | 110 | init.num_parents = num_parents; |
|---|
| 111 | 111 | |
|---|
| 112 | 112 | clkout->shift = shift; |
|---|
| 113 | 113 | clkout->mask = mask; |
|---|
| 114 | 114 | clkout->hw.init = &init; |
|---|
| 115 | + clkout->modify_misccr = pdata->modify_misccr; |
|---|
| 115 | 116 | |
|---|
| 116 | 117 | ret = clk_hw_register(dev, &clkout->hw); |
|---|
| 117 | 118 | if (ret) |
|---|
| .. | .. |
|---|
| 240 | 241 | static int s3c24xx_dclk_probe(struct platform_device *pdev) |
|---|
| 241 | 242 | { |
|---|
| 242 | 243 | struct s3c24xx_dclk *s3c24xx_dclk; |
|---|
| 243 | | - struct resource *mem; |
|---|
| 244 | 244 | struct s3c24xx_dclk_drv_data *dclk_variant; |
|---|
| 245 | 245 | struct clk_hw **clk_table; |
|---|
| 246 | 246 | int ret, i; |
|---|
| .. | .. |
|---|
| 259 | 259 | platform_set_drvdata(pdev, s3c24xx_dclk); |
|---|
| 260 | 260 | spin_lock_init(&s3c24xx_dclk->dclk_lock); |
|---|
| 261 | 261 | |
|---|
| 262 | | - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 263 | | - s3c24xx_dclk->base = devm_ioremap_resource(&pdev->dev, mem); |
|---|
| 262 | + s3c24xx_dclk->base = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 264 | 263 | if (IS_ERR(s3c24xx_dclk->base)) |
|---|
| 265 | 264 | return PTR_ERR(s3c24xx_dclk->base); |
|---|
| 266 | 265 | |
|---|