2013-08-28 16:13:51

by Mateusz Krawczuk

[permalink] [raw]
Subject: [PATCH v3 0/6] ARM: S5PV210: move to common clk framework

This patch series is the new s5pv210 clock implementation
(using common clk framework).

This implementation is compatible with device tree definition and board files.

This patch series is based on linux-next and has been tested on goni and aquila
boards using board file.

This patch series require adding new registration method
for PLL45xx and PLL46xx, which is included in this patch series:
clk: samsung: pll: Use new registration method for PLL46xx
http://www.mail-archive.com/[email protected]/msg21653.html
clk: samsung: pll: Use new registration method for PLL45xx
http://www.mail-archive.com/[email protected]/msg21652.html
clk: samsung: exynos4: Rename exynos4_plls to exynos4x12_plls
http://www.spinics.net/lists/arm-kernel/msg268486.html

Mateusz Krawczuk (6):
media: s5p-tv: Replace mxr_ macro by default dev_
media: s5p-tv: Restore vpll clock rate
media: s5p-tv: Fix sdo driver to work with CCF
media: s5p-tv: Fix mixer driver to work with CCF
clk: samsung: Add clock driver for s5pc110/s5pv210
ARM: s5pv210: Migrate clock handling to Common Clock Framework

.../bindings/clock/samsung,s5pv210-clock.txt | 72 ++
arch/arm/mach-s5pv210/Kconfig | 9 +
arch/arm/mach-s5pv210/Makefile | 4 +-
arch/arm/mach-s5pv210/common.c | 17 +
arch/arm/mach-s5pv210/common.h | 13 +
arch/arm/mach-s5pv210/mach-aquila.c | 1 +
arch/arm/mach-s5pv210/mach-goni.c | 3 +-
arch/arm/mach-s5pv210/mach-smdkc110.c | 1 +
arch/arm/mach-s5pv210/mach-smdkv210.c | 1 +
arch/arm/mach-s5pv210/mach-torbreck.c | 1 +
arch/arm/plat-samsung/Kconfig | 2 +-
arch/arm/plat-samsung/init.c | 2 -
drivers/clk/samsung/Makefile | 3 +
drivers/clk/samsung/clk-s5pv210.c | 732 +++++++++++++++++++++
drivers/media/platform/s5p-tv/mixer.h | 12 -
drivers/media/platform/s5p-tv/mixer_drv.c | 80 ++-
drivers/media/platform/s5p-tv/mixer_grp_layer.c | 2 +-
drivers/media/platform/s5p-tv/mixer_reg.c | 6 +-
drivers/media/platform/s5p-tv/mixer_video.c | 100 +--
drivers/media/platform/s5p-tv/mixer_vp_layer.c | 2 +-
drivers/media/platform/s5p-tv/sdo_drv.c | 45 +-
include/dt-bindings/clock/samsung,s5pv210-clock.h | 221 +++++++
22 files changed, 1216 insertions(+), 113 deletions(-)
create mode 100644 Documentation/devicetree/bindings/clock/samsung,s5pv210-clock.txt
create mode 100644 drivers/clk/samsung/clk-s5pv210.c
create mode 100644 include/dt-bindings/clock/samsung,s5pv210-clock.h

--
1.8.1.2


2013-08-28 16:14:29

by Mateusz Krawczuk

[permalink] [raw]
Subject: [PATCH v3 1/6] media: s5p-tv: Replace mxr_ macro by default dev_

Replace mxr_dbg, mxr_info and mxr_warn by generic solution.

Signed-off-by: Mateusz Krawczuk <[email protected]>
---
drivers/media/platform/s5p-tv/mixer.h | 12 ---
drivers/media/platform/s5p-tv/mixer_drv.c | 47 ++++++-----
drivers/media/platform/s5p-tv/mixer_grp_layer.c | 2 +-
drivers/media/platform/s5p-tv/mixer_reg.c | 6 +-
drivers/media/platform/s5p-tv/mixer_video.c | 100 ++++++++++++------------
drivers/media/platform/s5p-tv/mixer_vp_layer.c | 2 +-
6 files changed, 78 insertions(+), 91 deletions(-)

diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
index 04e6490..c054106 100644
--- a/drivers/media/platform/s5p-tv/mixer.h
+++ b/drivers/media/platform/s5p-tv/mixer.h
@@ -327,18 +327,6 @@ void mxr_streamer_put(struct mxr_device *mdev);
void mxr_get_mbus_fmt(struct mxr_device *mdev,
struct v4l2_mbus_framefmt *mbus_fmt);

-/* Debug */
-
-#define mxr_err(mdev, fmt, ...) dev_err(mdev->dev, fmt, ##__VA_ARGS__)
-#define mxr_warn(mdev, fmt, ...) dev_warn(mdev->dev, fmt, ##__VA_ARGS__)
-#define mxr_info(mdev, fmt, ...) dev_info(mdev->dev, fmt, ##__VA_ARGS__)
-
-#ifdef CONFIG_VIDEO_SAMSUNG_S5P_MIXER_DEBUG
- #define mxr_dbg(mdev, fmt, ...) dev_dbg(mdev->dev, fmt, ##__VA_ARGS__)
-#else
- #define mxr_dbg(mdev, fmt, ...) do { (void) mdev; } while (0)
-#endif
-
/* accessing Mixer's and Video Processor's registers */

void mxr_vsync_set_update(struct mxr_device *mdev, int en);
diff --git a/drivers/media/platform/s5p-tv/mixer_drv.c b/drivers/media/platform/s5p-tv/mixer_drv.c
index 51805a5..8ce7c3e 100644
--- a/drivers/media/platform/s5p-tv/mixer_drv.c
+++ b/drivers/media/platform/s5p-tv/mixer_drv.c
@@ -59,7 +59,7 @@ void mxr_streamer_get(struct mxr_device *mdev)
{
mutex_lock(&mdev->mutex);
++mdev->n_streamer;
- mxr_dbg(mdev, "%s(%d)\n", __func__, mdev->n_streamer);
+ dev_dbg(mdev->dev, "%s(%d)\n", __func__, mdev->n_streamer);
if (mdev->n_streamer == 1) {
struct v4l2_subdev *sd = to_outsd(mdev);
struct v4l2_mbus_framefmt mbus_fmt;
@@ -91,7 +91,7 @@ void mxr_streamer_put(struct mxr_device *mdev)
{
mutex_lock(&mdev->mutex);
--mdev->n_streamer;
- mxr_dbg(mdev, "%s(%d)\n", __func__, mdev->n_streamer);
+ dev_dbg(mdev->dev, "%s(%d)\n", __func__, mdev->n_streamer);
if (mdev->n_streamer == 0) {
int ret;
struct v4l2_subdev *sd = to_outsd(mdev);
@@ -113,7 +113,7 @@ void mxr_output_get(struct mxr_device *mdev)
{
mutex_lock(&mdev->mutex);
++mdev->n_output;
- mxr_dbg(mdev, "%s(%d)\n", __func__, mdev->n_output);
+ dev_dbg(mdev->dev, "%s(%d)\n", __func__, mdev->n_output);
/* turn on auxiliary driver */
if (mdev->n_output == 1)
v4l2_subdev_call(to_outsd(mdev), core, s_power, 1);
@@ -124,7 +124,7 @@ void mxr_output_put(struct mxr_device *mdev)
{
mutex_lock(&mdev->mutex);
--mdev->n_output;
- mxr_dbg(mdev, "%s(%d)\n", __func__, mdev->n_output);
+ dev_dbg(mdev->dev, "%s(%d)\n", __func__, mdev->n_output);
/* turn on auxiliary driver */
if (mdev->n_output == 0)
v4l2_subdev_call(to_outsd(mdev), core, s_power, 0);
@@ -159,42 +159,42 @@ static int mxr_acquire_plat_resources(struct mxr_device *mdev,

res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mxr");
if (res == NULL) {
- mxr_err(mdev, "get memory resource failed.\n");
+ dev_err(mdev->dev, "get memory resource failed.\n");
ret = -ENXIO;
goto fail;
}

mdev->res.mxr_regs = ioremap(res->start, resource_size(res));
if (mdev->res.mxr_regs == NULL) {
- mxr_err(mdev, "register mapping failed.\n");
+ dev_err(mdev->dev, "register mapping failed.\n");
ret = -ENXIO;
goto fail;
}

res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vp");
if (res == NULL) {
- mxr_err(mdev, "get memory resource failed.\n");
+ dev_err(mdev->dev, "get memory resource failed.\n");
ret = -ENXIO;
goto fail_mxr_regs;
}

mdev->res.vp_regs = ioremap(res->start, resource_size(res));
if (mdev->res.vp_regs == NULL) {
- mxr_err(mdev, "register mapping failed.\n");
+ dev_err(mdev->dev, "register mapping failed.\n");
ret = -ENXIO;
goto fail_mxr_regs;
}

res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq");
if (res == NULL) {
- mxr_err(mdev, "get interrupt resource failed.\n");
+ dev_err(mdev->dev, "get interrupt resource failed.\n");
ret = -ENXIO;
goto fail_vp_regs;
}

ret = request_irq(res->start, mxr_irq_handler, 0, "s5p-mixer", mdev);
if (ret) {
- mxr_err(mdev, "request interrupt failed.\n");
+ dev_err(mdev->dev, "request interrupt failed.\n");
goto fail_vp_regs;
}
mdev->res.irq = res->start;
@@ -252,27 +252,27 @@ static int mxr_acquire_clocks(struct mxr_device *mdev)

res->mixer = clk_get(dev, "mixer");
if (IS_ERR(res->mixer)) {
- mxr_err(mdev, "failed to get clock 'mixer'\n");
+ dev_err(mdev->dev, "failed to get clock 'mixer'\n");
goto fail;
}
res->vp = clk_get(dev, "vp");
if (IS_ERR(res->vp)) {
- mxr_err(mdev, "failed to get clock 'vp'\n");
+ dev_err(mdev->dev, "failed to get clock 'vp'\n");
goto fail;
}
res->sclk_mixer = clk_get(dev, "sclk_mixer");
if (IS_ERR(res->sclk_mixer)) {
- mxr_err(mdev, "failed to get clock 'sclk_mixer'\n");
+ dev_err(mdev->dev, "failed to get clock 'sclk_mixer'\n");
goto fail;
}
res->sclk_hdmi = clk_get(dev, "sclk_hdmi");
if (IS_ERR(res->sclk_hdmi)) {
- mxr_err(mdev, "failed to get clock 'sclk_hdmi'\n");
+ dev_err(mdev->dev, "failed to get clock 'sclk_hdmi'\n");
goto fail;
}
res->sclk_dac = clk_get(dev, "sclk_dac");
if (IS_ERR(res->sclk_dac)) {
- mxr_err(mdev, "failed to get clock 'sclk_dac'\n");
+ dev_err(mdev->dev, "failed to get clock 'sclk_dac'\n");
goto fail;
}

@@ -295,13 +295,13 @@ static int mxr_acquire_resources(struct mxr_device *mdev,
if (ret)
goto fail_plat;

- mxr_info(mdev, "resources acquired\n");
+ dev_info(mdev->dev, "resources acquired\n");
return 0;

fail_plat:
mxr_release_plat_resources(mdev);
fail:
- mxr_err(mdev, "resources acquire failed\n");
+ dev_err(mdev->dev, "resources acquire failed\n");
return ret;
}

@@ -330,7 +330,7 @@ static int mxr_acquire_layers(struct mxr_device *mdev,
mdev->layer[2] = mxr_vp_layer_create(mdev, 0);

if (!mdev->layer[0] || !mdev->layer[1] || !mdev->layer[2]) {
- mxr_err(mdev, "failed to acquire layers\n");
+ dev_err(mdev->dev, "failed to acquire layers\n");
goto fail;
}

@@ -348,7 +348,7 @@ static int mxr_runtime_resume(struct device *dev)
struct mxr_device *mdev = to_mdev(dev);
struct mxr_resources *res = &mdev->res;

- mxr_dbg(mdev, "resume - start\n");
+ dev_dbg(mdev->dev, "resume - start\n");
mutex_lock(&mdev->mutex);
/* turn clocks on */
clk_enable(res->mixer);
@@ -356,7 +356,7 @@ static int mxr_runtime_resume(struct device *dev)
clk_enable(res->sclk_mixer);
/* apply default configuration */
mxr_reg_reset(mdev);
- mxr_dbg(mdev, "resume - finished\n");
+ dev_dbg(mdev->dev, "resume - finished\n");

mutex_unlock(&mdev->mutex);
return 0;
@@ -366,14 +366,14 @@ static int mxr_runtime_suspend(struct device *dev)
{
struct mxr_device *mdev = to_mdev(dev);
struct mxr_resources *res = &mdev->res;
- mxr_dbg(mdev, "suspend - start\n");
+ dev_dbg(mdev->dev, "suspend - start\n");
mutex_lock(&mdev->mutex);
/* turn clocks off */
clk_disable(res->sclk_mixer);
clk_disable(res->vp);
clk_disable(res->mixer);
mutex_unlock(&mdev->mutex);
- mxr_dbg(mdev, "suspend - finished\n");
+ dev_dbg(mdev->dev, "suspend - finished\n");
return 0;
}

@@ -391,7 +391,6 @@ static int mxr_probe(struct platform_device *pdev)
struct mxr_device *mdev;
int ret;

- /* mdev does not exist yet so no mxr_dbg is used */
dev_info(dev, "probe start\n");

mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
@@ -426,7 +425,7 @@ static int mxr_probe(struct platform_device *pdev)

pm_runtime_enable(dev);

- mxr_info(mdev, "probe successful\n");
+ dev_info(mdev->dev, "probe successful\n");
return 0;

fail_video:
diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
index b93a21f..24a2355 100644
--- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
+++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
@@ -248,7 +248,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)

layer = mxr_base_layer_create(mdev, idx, name, &ops);
if (layer == NULL) {
- mxr_err(mdev, "failed to initialize layer(%d) base\n", idx);
+ dev_err(mdev->dev, "failed to initialize layer(%d) base\n", idx);
goto fail;
}

diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
index b713403..37b0221 100644
--- a/drivers/media/platform/s5p-tv/mixer_reg.c
+++ b/drivers/media/platform/s5p-tv/mixer_reg.c
@@ -368,7 +368,7 @@ int mxr_reg_wait4vsync(struct mxr_device *mdev)
return 0;
if (ret < 0)
return ret;
- mxr_warn(mdev, "no vsync detected - timeout\n");
+ dev_warn(mdev->dev, "no vsync detected - timeout\n");
return -ETIME;
}

@@ -481,7 +481,7 @@ static void mxr_reg_mxr_dump(struct mxr_device *mdev)
{
#define DUMPREG(reg_id) \
do { \
- mxr_dbg(mdev, #reg_id " = %08x\n", \
+ dev_dbg(mdev->dev, #reg_id " = %08x\n", \
(u32)readl(mdev->res.mxr_regs + reg_id)); \
} while (0)

@@ -513,7 +513,7 @@ static void mxr_reg_vp_dump(struct mxr_device *mdev)
{
#define DUMPREG(reg_id) \
do { \
- mxr_dbg(mdev, #reg_id " = %08x\n", \
+ dev_dbg(mdev->dev, #reg_id " = %08x\n", \
(u32) readl(mdev->res.vp_regs + reg_id)); \
} while (0)

diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
index 641b1f0..726bdcb 100644
--- a/drivers/media/platform/s5p-tv/mixer_video.c
+++ b/drivers/media/platform/s5p-tv/mixer_video.c
@@ -42,20 +42,20 @@ static struct v4l2_subdev *find_and_register_subdev(
/* TODO: add waiting until probe is finished */
drv = driver_find(module_name, &platform_bus_type);
if (!drv) {
- mxr_warn(mdev, "module %s is missing\n", module_name);
+ dev_warn(mdev->dev, "module %s is missing\n", module_name);
return NULL;
}
/* driver refcnt is increased, it is safe to iterate over devices */
ret = driver_for_each_device(drv, NULL, &sd, find_reg_callback);
/* ret == 0 means that find_reg_callback was never executed */
if (sd == NULL) {
- mxr_warn(mdev, "module %s provides no subdev!\n", module_name);
+ dev_warn(mdev->dev, "module %s provides no subdev!\n", module_name);
goto done;
}
/* v4l2_device_register_subdev detects if sd is NULL */
ret = v4l2_device_register_subdev(&mdev->v4l2_dev, sd);
if (ret) {
- mxr_warn(mdev, "failed to register subdev %s\n", sd->name);
+ dev_warn(mdev->dev, "failed to register subdev %s\n", sd->name);
sd = NULL;
}

@@ -76,13 +76,13 @@ int mxr_acquire_video(struct mxr_device *mdev,
/* prepare context for V4L2 device */
ret = v4l2_device_register(dev, v4l2_dev);
if (ret) {
- mxr_err(mdev, "could not register v4l2 device.\n");
+ dev_err(mdev->dev, "could not register v4l2 device.\n");
goto fail;
}

mdev->alloc_ctx = vb2_dma_contig_init_ctx(mdev->dev);
if (IS_ERR(mdev->alloc_ctx)) {
- mxr_err(mdev, "could not acquire vb2 allocator\n");
+ dev_err(mdev->dev, "could not acquire vb2 allocator\n");
ret = PTR_ERR(mdev->alloc_ctx);
goto fail_v4l2_dev;
}
@@ -99,7 +99,7 @@ int mxr_acquire_video(struct mxr_device *mdev,
continue;
out = kzalloc(sizeof(*out), GFP_KERNEL);
if (out == NULL) {
- mxr_err(mdev, "no memory for '%s'\n",
+ dev_err(mdev->dev, "no memory for '%s'\n",
conf->output_name);
ret = -ENOMEM;
/* registered subdevs are removed in fail_v4l2_dev */
@@ -109,7 +109,7 @@ int mxr_acquire_video(struct mxr_device *mdev,
out->sd = sd;
out->cookie = conf->cookie;
mdev->output[mdev->output_cnt++] = out;
- mxr_info(mdev, "added output '%s' from module '%s'\n",
+ dev_info(mdev->dev, "added output '%s' from module '%s'\n",
conf->output_name, conf->module_name);
/* checking if maximal number of outputs is reached */
if (mdev->output_cnt >= MXR_MAX_OUTPUTS)
@@ -117,7 +117,7 @@ int mxr_acquire_video(struct mxr_device *mdev,
}

if (mdev->output_cnt == 0) {
- mxr_err(mdev, "failed to register any output\n");
+ dev_err(mdev->dev, "failed to register any output\n");
ret = -ENODEV;
/* skipping fail_output because there is nothing to free */
goto fail_vb2_allocator;
@@ -160,7 +160,7 @@ static int mxr_querycap(struct file *file, void *priv,
{
struct mxr_layer *layer = video_drvdata(file);

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);

strlcpy(cap->driver, MXR_DRIVER_NAME, sizeof(cap->driver));
strlcpy(cap->card, layer->vfd.name, sizeof(cap->card));
@@ -173,19 +173,19 @@ static int mxr_querycap(struct file *file, void *priv,

static void mxr_geometry_dump(struct mxr_device *mdev, struct mxr_geometry *geo)
{
- mxr_dbg(mdev, "src.full_size = (%u, %u)\n",
+ dev_dbg(mdev->dev, "src.full_size = (%u, %u)\n",
geo->src.full_width, geo->src.full_height);
- mxr_dbg(mdev, "src.size = (%u, %u)\n",
+ dev_dbg(mdev->dev, "src.size = (%u, %u)\n",
geo->src.width, geo->src.height);
- mxr_dbg(mdev, "src.offset = (%u, %u)\n",
+ dev_dbg(mdev->dev, "src.offset = (%u, %u)\n",
geo->src.x_offset, geo->src.y_offset);
- mxr_dbg(mdev, "dst.full_size = (%u, %u)\n",
+ dev_dbg(mdev->dev, "dst.full_size = (%u, %u)\n",
geo->dst.full_width, geo->dst.full_height);
- mxr_dbg(mdev, "dst.size = (%u, %u)\n",
+ dev_dbg(mdev->dev, "dst.size = (%u, %u)\n",
geo->dst.width, geo->dst.height);
- mxr_dbg(mdev, "dst.offset = (%u, %u)\n",
+ dev_dbg(mdev->dev, "dst.offset = (%u, %u)\n",
geo->dst.x_offset, geo->dst.y_offset);
- mxr_dbg(mdev, "ratio = (%u, %u)\n",
+ dev_dbg(mdev->dev, "ratio = (%u, %u)\n",
geo->x_ratio, geo->y_ratio);
}

@@ -245,7 +245,7 @@ static int mxr_enum_fmt(struct file *file, void *priv,
struct mxr_device *mdev = layer->mdev;
const struct mxr_format *fmt;

- mxr_dbg(mdev, "%s\n", __func__);
+ dev_dbg(mdev->dev, "%s\n", __func__);
fmt = find_format_by_index(layer, f->index);
if (fmt == NULL)
return -EINVAL;
@@ -300,7 +300,7 @@ static int mxr_g_fmt(struct file *file, void *priv,
struct mxr_layer *layer = video_drvdata(file);
struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp;

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);

pix->width = layer->geo.src.full_width;
pix->height = layer->geo.src.full_height;
@@ -321,12 +321,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
struct mxr_device *mdev = layer->mdev;
struct mxr_geometry *geo = &layer->geo;

- mxr_dbg(mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(mdev->dev, "%s:%d\n", __func__, __LINE__);

pix = &f->fmt.pix_mp;
fmt = find_format_by_fourcc(layer, pix->pixelformat);
if (fmt == NULL) {
- mxr_warn(mdev, "not recognized fourcc: %08x\n",
+ dev_warn(mdev->dev, "not recognized fourcc: %08x\n",
pix->pixelformat);
return -EINVAL;
}
@@ -362,7 +362,7 @@ static int mxr_g_selection(struct file *file, void *fh,
struct mxr_layer *layer = video_drvdata(file);
struct mxr_geometry *geo = &layer->geo;

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);

if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
@@ -429,7 +429,7 @@ static int mxr_s_selection(struct file *file, void *fh,

memset(&res, 0, sizeof(res));

- mxr_dbg(layer->mdev, "%s: rect: %dx%d@%d,%d\n", __func__,
+ dev_dbg(layer->mdev->dev, "%s: rect: %dx%d@%d,%d\n", __func__,
s->r.width, s->r.height, s->r.left, s->r.top);

if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
@@ -664,7 +664,7 @@ static int mxr_s_output(struct file *file, void *fh, unsigned int i)
/* update layers geometry */
mxr_layer_update_output(layer);

- mxr_dbg(mdev, "tvnorms = %08llx\n", vfd->tvnorms);
+ dev_dbg(mdev->dev, "tvnorms = %08llx\n", vfd->tvnorms);

return 0;
}
@@ -686,7 +686,7 @@ static int mxr_reqbufs(struct file *file, void *priv,
{
struct mxr_layer *layer = video_drvdata(file);

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);
return vb2_reqbufs(&layer->vb_queue, p);
}

@@ -694,7 +694,7 @@ static int mxr_querybuf(struct file *file, void *priv, struct v4l2_buffer *p)
{
struct mxr_layer *layer = video_drvdata(file);

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);
return vb2_querybuf(&layer->vb_queue, p);
}

@@ -702,7 +702,7 @@ static int mxr_qbuf(struct file *file, void *priv, struct v4l2_buffer *p)
{
struct mxr_layer *layer = video_drvdata(file);

- mxr_dbg(layer->mdev, "%s:%d(%d)\n", __func__, __LINE__, p->index);
+ dev_dbg(layer->mdev->dev, "%s:%d(%d)\n", __func__, __LINE__, p->index);
return vb2_qbuf(&layer->vb_queue, p);
}

@@ -710,7 +710,7 @@ static int mxr_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
{
struct mxr_layer *layer = video_drvdata(file);

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);
return vb2_dqbuf(&layer->vb_queue, p, file->f_flags & O_NONBLOCK);
}

@@ -719,7 +719,7 @@ static int mxr_expbuf(struct file *file, void *priv,
{
struct mxr_layer *layer = video_drvdata(file);

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);
return vb2_expbuf(&layer->vb_queue, eb);
}

@@ -727,7 +727,7 @@ static int mxr_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
{
struct mxr_layer *layer = video_drvdata(file);

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);
return vb2_streamon(&layer->vb_queue, i);
}

@@ -735,7 +735,7 @@ static int mxr_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
{
struct mxr_layer *layer = video_drvdata(file);

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);
return vb2_streamoff(&layer->vb_queue, i);
}

@@ -777,7 +777,7 @@ static int mxr_video_open(struct file *file)
struct mxr_device *mdev = layer->mdev;
int ret = 0;

- mxr_dbg(mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(mdev->dev, "%s:%d\n", __func__, __LINE__);
if (mutex_lock_interruptible(&layer->mutex))
return -ERESTARTSYS;
/* assure device probe is finished */
@@ -785,7 +785,7 @@ static int mxr_video_open(struct file *file)
/* creating context for file descriptor */
ret = v4l2_fh_open(file);
if (ret) {
- mxr_err(mdev, "v4l2_fh_open failed\n");
+ dev_err(mdev->dev, "v4l2_fh_open failed\n");
goto unlock;
}

@@ -796,13 +796,13 @@ static int mxr_video_open(struct file *file)
/* FIXME: should power be enabled on open? */
ret = mxr_power_get(mdev);
if (ret) {
- mxr_err(mdev, "power on failed\n");
+ dev_err(mdev->dev, "power on failed\n");
goto fail_fh_open;
}

ret = vb2_queue_init(&layer->vb_queue);
if (ret != 0) {
- mxr_err(mdev, "failed to initialize vb2 queue\n");
+ dev_err(mdev->dev, "failed to initialize vb2 queue\n");
goto fail_power;
}
/* set default format, first on the list */
@@ -831,7 +831,7 @@ mxr_video_poll(struct file *file, struct poll_table_struct *wait)
struct mxr_layer *layer = video_drvdata(file);
unsigned int res;

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);

mutex_lock(&layer->mutex);
res = vb2_poll(&layer->vb_queue, file, wait);
@@ -844,7 +844,7 @@ static int mxr_video_mmap(struct file *file, struct vm_area_struct *vma)
struct mxr_layer *layer = video_drvdata(file);
int ret;

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);

if (mutex_lock_interruptible(&layer->mutex))
return -ERESTARTSYS;
@@ -857,7 +857,7 @@ static int mxr_video_release(struct file *file)
{
struct mxr_layer *layer = video_drvdata(file);

- mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__);
+ dev_dbg(layer->mdev->dev, "%s:%d\n", __func__, __LINE__);
mutex_lock(&layer->mutex);
if (v4l2_fh_is_singular_file(file)) {
vb2_queue_release(&layer->vb_queue);
@@ -887,11 +887,11 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *pfmt,
struct mxr_device *mdev = layer->mdev;
struct v4l2_plane_pix_format planes[3];

- mxr_dbg(mdev, "%s\n", __func__);
+ dev_dbg(mdev->dev, "%s\n", __func__);
/* checking if format was configured */
if (fmt == NULL)
return -EINVAL;
- mxr_dbg(mdev, "fmt = %s\n", fmt->name);
+ dev_dbg(mdev->dev, "fmt = %s\n", fmt->name);
mxr_mplane_fill(planes, fmt, layer->geo.src.full_width,
layer->geo.src.full_height);

@@ -899,7 +899,7 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *pfmt,
for (i = 0; i < fmt->num_subframes; ++i) {
alloc_ctxs[i] = layer->mdev->alloc_ctx;
sizes[i] = planes[i].sizeimage;
- mxr_dbg(mdev, "size[%d] = %08x\n", i, sizes[i]);
+ dev_dbg(mdev->dev, "size[%d] = %08x\n", i, sizes[i]);
}

if (*nbuffers == 0)
@@ -919,14 +919,14 @@ static void buf_queue(struct vb2_buffer *vb)
list_add_tail(&buffer->list, &layer->enq_list);
spin_unlock_irqrestore(&layer->enq_slock, flags);

- mxr_dbg(mdev, "queuing buffer\n");
+ dev_dbg(mdev->dev, "queuing buffer\n");
}

static void wait_lock(struct vb2_queue *vq)
{
struct mxr_layer *layer = vb2_get_drv_priv(vq);

- mxr_dbg(layer->mdev, "%s\n", __func__);
+ dev_dbg(layer->mdev->dev, "%s\n", __func__);
mutex_lock(&layer->mutex);
}

@@ -934,7 +934,7 @@ static void wait_unlock(struct vb2_queue *vq)
{
struct mxr_layer *layer = vb2_get_drv_priv(vq);

- mxr_dbg(layer->mdev, "%s\n", __func__);
+ dev_dbg(layer->mdev->dev, "%s\n", __func__);
mutex_unlock(&layer->mutex);
}

@@ -944,10 +944,10 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
struct mxr_device *mdev = layer->mdev;
unsigned long flags;

- mxr_dbg(mdev, "%s\n", __func__);
+ dev_dbg(mdev->dev, "%s\n", __func__);

if (count == 0) {
- mxr_dbg(mdev, "no output buffers queued\n");
+ dev_dbg(mdev->dev, "no output buffers queued\n");
return -EINVAL;
}

@@ -973,7 +973,7 @@ static void mxr_watchdog(unsigned long arg)
struct mxr_device *mdev = layer->mdev;
unsigned long flags;

- mxr_err(mdev, "watchdog fired for layer %s\n", layer->vfd.name);
+ dev_err(mdev->dev, "watchdog fired for layer %s\n", layer->vfd.name);

spin_lock_irqsave(&layer->enq_slock, flags);

@@ -998,7 +998,7 @@ static int stop_streaming(struct vb2_queue *vq)
struct timer_list watchdog;
struct mxr_buffer *buf, *buf_tmp;

- mxr_dbg(mdev, "%s\n", __func__);
+ dev_dbg(mdev->dev, "%s\n", __func__);

spin_lock_irqsave(&layer->enq_slock, flags);

@@ -1056,9 +1056,9 @@ int mxr_base_layer_register(struct mxr_layer *layer)

ret = video_register_device(&layer->vfd, VFL_TYPE_GRABBER, -1);
if (ret)
- mxr_err(mdev, "failed to register video device\n");
+ dev_err(mdev->dev, "failed to register video device\n");
else
- mxr_info(mdev, "registered layer %s as /dev/video%d\n",
+ dev_info(mdev->dev, "registered layer %s as /dev/video%d\n",
layer->vfd.name, layer->vfd.num);
return ret;
}
@@ -1091,7 +1091,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,

layer = kzalloc(sizeof(*layer), GFP_KERNEL);
if (layer == NULL) {
- mxr_err(mdev, "not enough memory for layer.\n");
+ dev_err(mdev->dev, "not enough memory for layer.\n");
goto fail;
}

diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
index 3d13a63..38b216e 100644
--- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
+++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
@@ -219,7 +219,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)

layer = mxr_base_layer_create(mdev, idx, name, &ops);
if (layer == NULL) {
- mxr_err(mdev, "failed to initialize layer(%d) base\n", idx);
+ dev_err(mdev->dev, "failed to initialize layer(%d) base\n", idx);
goto fail;
}

--
1.8.1.2

2013-08-28 16:14:39

by Mateusz Krawczuk

[permalink] [raw]
Subject: [PATCH v3 2/6] media: s5p-tv: Restore vpll clock rate

Restore vpll clock rate if start stream fail or stream is off.

Signed-off-by: Mateusz Krawczuk <[email protected]>
---
drivers/media/platform/s5p-tv/sdo_drv.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c b/drivers/media/platform/s5p-tv/sdo_drv.c
index 0afa90f..9dbdfe6 100644
--- a/drivers/media/platform/s5p-tv/sdo_drv.c
+++ b/drivers/media/platform/s5p-tv/sdo_drv.c
@@ -55,6 +55,8 @@ struct sdo_device {
struct clk *dacphy;
/** clock for control of VPLL */
struct clk *fout_vpll;
+ /** vpll rate before sdo stream was on */
+ int vpll_rate;
/** regulator for SDO IP power */
struct regulator *vdac;
/** regulator for SDO plug detection */
@@ -193,17 +195,34 @@ static int sdo_s_power(struct v4l2_subdev *sd, int on)

static int sdo_streamon(struct sdo_device *sdev)
{
+ int ret;
+
/* set proper clock for Timing Generator */
- clk_set_rate(sdev->fout_vpll, 54000000);
+ sdev->vpll_rate = clk_get_rate(sdev->fout_vpll);
+ ret = clk_set_rate(sdev->fout_vpll, 54000000);
+ if (ret < 0) {
+ dev_err(sdev->dev,
+ "Failed to set vpll rate!\n");
+ return ret;
+ }
dev_info(sdev->dev, "fout_vpll.rate = %lu\n",
clk_get_rate(sdev->fout_vpll));
/* enable clock in SDO */
sdo_write_mask(sdev, SDO_CLKCON, ~0, SDO_TVOUT_CLOCK_ON);
- clk_enable(sdev->dacphy);
+ ret = clk_enable(sdev->dacphy);
+ if (ret < 0) {
+ dev_err(sdev->dev,
+ "clk_enable(dacphy) failed !\n");
+ goto fail;
+ }
/* enable DAC */
sdo_write_mask(sdev, SDO_DAC, ~0, SDO_POWER_ON_DAC);
sdo_reg_debug(sdev);
return 0;
+fail:
+ sdo_write_mask(sdev, SDO_CLKCON, 0, SDO_TVOUT_CLOCK_ON);
+ clk_set_rate(sdev->fout_vpll, sdev->vpll_rate);
+ return ret;
}

static int sdo_streamoff(struct sdo_device *sdev)
@@ -220,6 +239,7 @@ static int sdo_streamoff(struct sdo_device *sdev)
}
if (tries == 0)
dev_err(sdev->dev, "failed to stop streaming\n");
+ clk_set_rate(sdev->fout_vpll, sdev->vpll_rate);
return tries ? 0 : -EIO;
}

--
1.8.1.2

2013-08-28 16:14:57

by Mateusz Krawczuk

[permalink] [raw]
Subject: [PATCH v3 3/6] media: s5p-tv: Fix sdo driver to work with CCF

Replace clk_enable by clock_enable_prepare and clk_disable with clk_disable_unprepare.
Clock prepare is required by Clock Common Framework, and old clock driver didn`t support it.
Without it Common Clock Framework prints a warning.

Signed-off-by: Mateusz Krawczuk <[email protected]>
---
drivers/media/platform/s5p-tv/sdo_drv.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c b/drivers/media/platform/s5p-tv/sdo_drv.c
index 9dbdfe6..a79e620 100644
--- a/drivers/media/platform/s5p-tv/sdo_drv.c
+++ b/drivers/media/platform/s5p-tv/sdo_drv.c
@@ -209,10 +209,10 @@ static int sdo_streamon(struct sdo_device *sdev)
clk_get_rate(sdev->fout_vpll));
/* enable clock in SDO */
sdo_write_mask(sdev, SDO_CLKCON, ~0, SDO_TVOUT_CLOCK_ON);
- ret = clk_enable(sdev->dacphy);
+ ret = clk_prepare_enable(sdev->dacphy);
if (ret < 0) {
dev_err(sdev->dev,
- "clk_enable(dacphy) failed !\n");
+ "clk_prepare_enable(dacphy) failed !\n");
goto fail;
}
/* enable DAC */
@@ -230,7 +230,7 @@ static int sdo_streamoff(struct sdo_device *sdev)
int tries;

sdo_write_mask(sdev, SDO_DAC, 0, SDO_POWER_ON_DAC);
- clk_disable(sdev->dacphy);
+ clk_disable_unprepare(sdev->dacphy);
sdo_write_mask(sdev, SDO_CLKCON, 0, SDO_TVOUT_CLOCK_ON);
for (tries = 100; tries; --tries) {
if (sdo_read(sdev, SDO_CLKCON) & SDO_TVOUT_CLOCK_READY)
@@ -274,7 +274,7 @@ static int sdo_runtime_suspend(struct device *dev)
dev_info(dev, "suspend\n");
regulator_disable(sdev->vdet);
regulator_disable(sdev->vdac);
- clk_disable(sdev->sclk_dac);
+ clk_disable_unprepare(sdev->sclk_dac);
return 0;
}

@@ -286,7 +286,7 @@ static int sdo_runtime_resume(struct device *dev)

dev_info(dev, "resume\n");

- ret = clk_enable(sdev->sclk_dac);
+ ret = clk_prepare_enable(sdev->sclk_dac);
if (ret < 0)
return ret;

@@ -319,7 +319,7 @@ static int sdo_runtime_resume(struct device *dev)
vdac_r_dis:
regulator_disable(sdev->vdac);
dac_clk_dis:
- clk_disable(sdev->sclk_dac);
+ clk_disable_unprepare(sdev->sclk_dac);
return ret;
}

@@ -333,7 +333,7 @@ static int sdo_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct sdo_device *sdev;
struct resource *res;
- int ret = 0;
+ int ret;
struct clk *sclk_vpll;

dev_info(dev, "probe start\n");
@@ -425,8 +425,13 @@ static int sdo_probe(struct platform_device *pdev)
}

/* enable gate for dac clock, because mixer uses it */
- clk_enable(sdev->dac);
-
+ ret = clk_prepare_enable(sdev->dac);
+ if (ret < 0) {
+ dev_err(dev,
+ "clk_prepare_enable_enable(dac) failed !\n");
+ ret = PTR_ERR(sdev->dac);
+ goto fail_fout_vpll;
+ }
/* configure power management */
pm_runtime_enable(dev);

@@ -464,7 +469,7 @@ static int sdo_remove(struct platform_device *pdev)
struct sdo_device *sdev = sd_to_sdev(sd);

pm_runtime_disable(&pdev->dev);
- clk_disable(sdev->dac);
+ clk_disable_unprepare(sdev->dac);
clk_put(sdev->fout_vpll);
clk_put(sdev->dacphy);
clk_put(sdev->dac);
--
1.8.1.2

2013-08-28 16:15:13

by Mateusz Krawczuk

[permalink] [raw]
Subject: [PATCH v3 4/6] media: s5p-tv: Fix mixer driver to work with CCF

Replace clk_enable by clock_enable_prepare and clk_disable with clk_disable_unprepare.
Clock prepare is required by Clock Common Framework, and old clock driver didn`t support it.
Without it Common Clock Framework prints a warning.

Signed-off-by: Mateusz Krawczuk <[email protected]>
---
drivers/media/platform/s5p-tv/mixer_drv.c | 35 ++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/s5p-tv/mixer_drv.c b/drivers/media/platform/s5p-tv/mixer_drv.c
index 8ce7c3e..3b2b305 100644
--- a/drivers/media/platform/s5p-tv/mixer_drv.c
+++ b/drivers/media/platform/s5p-tv/mixer_drv.c
@@ -347,19 +347,40 @@ static int mxr_runtime_resume(struct device *dev)
{
struct mxr_device *mdev = to_mdev(dev);
struct mxr_resources *res = &mdev->res;
+ int ret;

dev_dbg(mdev->dev, "resume - start\n");
mutex_lock(&mdev->mutex);
/* turn clocks on */
- clk_enable(res->mixer);
- clk_enable(res->vp);
- clk_enable(res->sclk_mixer);
+ ret = clk_prepare_enable(res->mixer);
+ if (ret < 0) {
+ dev_err(mdev->dev, "clk_prepare_enable(mixer) failed\n");
+ goto fail;
+ }
+ ret = clk_prepare_enable(res->vp);
+ if (ret < 0) {
+ dev_err(mdev->dev, "clk_prepare_enable(vp) failed\n");
+ goto fail_mixer;
+ }
+ ret = clk_prepare_enable(res->sclk_mixer);
+ if (ret < 0) {
+ dev_err(mdev->dev, "clk_prepare_enable(sclk_mixer) failed\n");
+ goto fail_vp;
+ }
/* apply default configuration */
mxr_reg_reset(mdev);
- dev_dbg(mdev->dev, "resume - finished\n");

mutex_unlock(&mdev->mutex);
+ dev_dbg(mdev->dev, "resume - finished\n");
return 0;
+fail_vp:
+ clk_disable_unprepare(res->vp);
+fail_mixer:
+ clk_disable_unprepare(res->mixer);
+fail:
+ mutex_unlock(&mdev->mutex);
+ dev_info(mdev->dev, "resume failed\n");
+ return ret;
}

static int mxr_runtime_suspend(struct device *dev)
@@ -369,9 +390,9 @@ static int mxr_runtime_suspend(struct device *dev)
dev_dbg(mdev->dev, "suspend - start\n");
mutex_lock(&mdev->mutex);
/* turn clocks off */
- clk_disable(res->sclk_mixer);
- clk_disable(res->vp);
- clk_disable(res->mixer);
+ clk_disable_unprepare(res->sclk_mixer);
+ clk_disable_unprepare(res->vp);
+ clk_disable_unprepare(res->mixer);
mutex_unlock(&mdev->mutex);
dev_dbg(mdev->dev, "suspend - finished\n");
return 0;
--
1.8.1.2

2013-08-28 16:15:38

by Mateusz Krawczuk

[permalink] [raw]
Subject: [PATCH v3 5/6] clk: samsung: Add clock driver for s5pc110/s5pv210

This patch adds new, Common Clock Framework-based clock driver for Samsung
S5PV210 SoCs. The driver is just added, without enabling it yet.

Signed-off-by: Mateusz Krawczuk <[email protected]>
---
.../bindings/clock/samsung,s5pv210-clock.txt | 72 ++
drivers/clk/samsung/Makefile | 3 +
drivers/clk/samsung/clk-s5pv210.c | 732 +++++++++++++++++++++
include/dt-bindings/clock/samsung,s5pv210-clock.h | 221 +++++++
4 files changed, 1028 insertions(+)
create mode 100644 Documentation/devicetree/bindings/clock/samsung,s5pv210-clock.txt
create mode 100644 drivers/clk/samsung/clk-s5pv210.c
create mode 100644 include/dt-bindings/clock/samsung,s5pv210-clock.h

diff --git a/Documentation/devicetree/bindings/clock/samsung,s5pv210-clock.txt b/Documentation/devicetree/bindings/clock/samsung,s5pv210-clock.txt
new file mode 100644
index 0000000..753c8f9
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/samsung,s5pv210-clock.txt
@@ -0,0 +1,72 @@
+* Samsung S5PC110/S5PV210 Clock Controller
+
+The S5PV210 clock controller generates and supplies clock to various controllers
+within the SoC. The clock binding described here is applicable to all SoCs in
+the S5PC110/S5PV210 family.
+
+Required Properties:
+
+- compatible: should be one of the following.
+ - "samsung,s5pv210-clock" - controller compatible with S5PC110/S5PV210 SoC.
+
+- reg: physical base address of the controller and length of memory mapped
+ region.
+
+- #clock-cells: should be 1.
+
+Each clock is assigned an identifier and client nodes can use this identifier
+to specify the clock which they consume. Some of the clocks are available only
+on a particular S5PC110/S5PV210 SoC and this is specified where applicable.
+
+All available clocks are defined as preprocessor macros in
+dt-bindings/clock/samsung,s5pv210-clock.h header and can be used in device
+tree sources.
+
+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:
+ - "xxti" - xtal - required
+ - "xusbxti" - USB xtal - required,
+
+
+Example: Clock controller node:
+
+ clock: clock-controller@7e00f000 {
+ compatible = "samsung,s5pv210-clock";
+ reg = <0x7e00f000 0x1000>;
+ #clock-cells = <1>;
+ };
+
+Example: Required external clocks:
+
+ fin_pll: clock-xxti {
+ compatible = "fixed-clock";
+ clock-output-names = "xxti";
+ clock-frequency = <12000000>;
+ #clock-cells = <0>;
+ };
+
+ xusbxti: clock-xusbxti {
+ compatible = "fixed-clock";
+ clock-output-names = "xusbxti";
+ clock-frequency = <48000000>;
+ #clock-cells = <0>;
+ };
+
+Example: UART controller node that consumes the clock generated by the clock
+ controller (refer to the standard clock bindings for information about
+ "clocks" and "clock-names" properties):
+
+ uart0: serial@7f005000 {
+ compatible = "samsung,s5pv210-uart";
+ reg = <0x7f005000 0x100>;
+ interrupt-parent = <&vic1>;
+ interrupts = <5>;
+ clock-names = "uart", "clk_uart_baud2",
+ "clk_uart_baud3";
+ clocks = <&clock PCLK_UART0>, <&clocks PCLK_UART0>,
+ <&clock SCLK_UART>;
+ status = "disabled";
+ };
\ No newline at end of file
diff --git a/drivers/clk/samsung/Makefile b/drivers/clk/samsung/Makefile
index 8eb4799..e08c45e 100644
--- a/drivers/clk/samsung/Makefile
+++ b/drivers/clk/samsung/Makefile
@@ -9,3 +9,6 @@ obj-$(CONFIG_SOC_EXYNOS5420) += clk-exynos5420.o
obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o
obj-$(CONFIG_ARCH_EXYNOS) += clk-exynos-audss.o
obj-$(CONFIG_ARCH_S3C64XX) += clk-s3c64xx.o
+ifeq ($(CONFIG_COMMON_CLK), y)
+obj-$(CONFIG_ARCH_S5PV210) += clk-s5pv210.o
+endif
\ No newline at end of file
diff --git a/drivers/clk/samsung/clk-s5pv210.c b/drivers/clk/samsung/clk-s5pv210.c
new file mode 100644
index 0000000..1c5ea5c
--- /dev/null
+++ b/drivers/clk/samsung/clk-s5pv210.c
@@ -0,0 +1,732 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * Author: Mateusz Krawczuk <[email protected]>
+ *
+ * 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.
+ *
+ * Common Clock Framework support for all S5PC110/S5PV210 SoCs.
+*/
+
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/clk-provider.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <mach/regs-clock.h>
+
+#include "clk.h"
+#include "clk-pll.h"
+
+#include <dt-bindings/clock/samsung,s5pv210-clock.h>
+
+/* S5PC110/S5PV210 clock controller register offsets */
+#define APLL_LOCK 0x0000
+#define MPLL_LOCK 0x0008
+#define EPLL_LOCK 0x0010
+#define VPLL_LOCK 0x0020
+#define APLL_CON0 0x0100
+#define APLL_CON1 0x0104
+#define MPLL_CON 0x0108
+#define EPLL_CON0 0x0110
+#define EPLL_CON1 0x0114
+#define VPLL_CON0 0x0120
+#define CLK_SRC0 0x0200
+#define CLK_SRC1 0x0204
+#define CLK_SRC2 0x0208
+#define CLK_SRC3 0x020c
+#define CLK_SRC4 0x0210
+#define CLK_SRC5 0x0214
+#define CLK_SRC6 0x0218
+#define CLK_SRC_MASK0 0x0280
+#define CLK_SRC_MASK1 0x0284
+#define CLK_DIV0 0x0300
+#define CLK_DIV1 0x0304
+#define CLK_DIV2 0x0308
+#define CLK_DIV3 0x030c
+#define CLK_DIV4 0x0310
+#define CLK_DIV5 0x0314
+#define CLK_DIV6 0x0318
+#define CLK_DIV7 0x031c
+#define CLK_GATE_SCLK 0x0444
+#define CLK_GATE_IP0 0x0460
+#define CLK_GATE_IP1 0x0464
+#define CLK_GATE_IP2 0x0468
+#define CLK_GATE_IP3 0x046c
+#define CLK_GATE_IP4 0x0470
+#define CLK_GATE_BLOCK 0x0480
+#define CLK_GATE_IP5 0x0484
+#define DAC_CONTROL 0xe810
+
+/* Helper macros to define clock arrays. */
+#define FIXED_RATE_CLOCKS(name) \
+ static struct samsung_fixed_rate_clock name[]
+#define MUX_CLOCKS(name) \
+ static struct samsung_mux_clock name[]
+#define DIV_CLOCKS(name) \
+ static struct samsung_div_clock name[]
+#define GATE_CLOCKS(name) \
+ static struct samsung_gate_clock name[]
+
+/* Helper macros for gate types present on S5PC110/S5PV210. */
+#define GATE_BUS(_id, cname, pname, o, b) \
+ GATE(_id, cname, pname, o, b, 0, 0)
+#define GATE_SCLK(_id, cname, pname, o, b) \
+ GATE(_id, cname, pname, o, b, CLK_SET_RATE_PARENT, 0)
+#define GATE_ON(_id, cname, pname, o, b) \
+ GATE(_id, cname, pname, o, b, CLK_IGNORE_UNUSED, 0)
+
+enum s5pv210_plls {
+ apll, mpll, epll, vpll,
+};
+
+static unsigned long s5pv210_clk_regs[] __initdata = {
+ CLK_SRC0,
+ CLK_SRC1,
+ CLK_SRC2,
+ CLK_SRC3,
+ CLK_SRC4,
+ CLK_SRC5,
+ CLK_SRC6,
+ CLK_DIV0,
+ CLK_DIV1,
+ CLK_DIV2,
+ CLK_DIV3,
+ CLK_DIV4,
+ CLK_DIV5,
+ CLK_DIV6,
+ CLK_DIV7,
+ CLK_GATE_SCLK,
+ CLK_GATE_IP0,
+ CLK_GATE_IP1,
+ CLK_GATE_IP2,
+ CLK_GATE_IP3,
+ CLK_GATE_IP4,
+ CLK_GATE_IP5,
+ CLK_SRC_MASK0,
+ CLK_SRC_MASK1,
+ APLL_CON0,
+ MPLL_CON,
+ EPLL_CON0,
+ VPLL_CON0,
+ APLL_LOCK,
+ MPLL_LOCK,
+ EPLL_LOCK,
+ VPLL_LOCK,
+};
+
+/* List of parent clocks common for all S5PC110 SoCs. */
+PNAME(mout_apll_p) = {
+ "fin_pll",
+ "fout_apll"
+};
+
+PNAME(mout_mpll_p) = {
+ "fin_pll",
+ "fout_mpll"
+};
+
+PNAME(mout_epll_p) = {
+ "fin_pll",
+ "fout_epll"
+};
+
+PNAME(mout_vpllsrc_p) = {
+ "fin_pll",
+ "sclk_hdmi27m"
+};
+
+PNAME(mout_vpll_p) = {
+ "fin_pll",
+ "fout_vpll"
+};
+
+PNAME(mout_group1_p) = {
+ "dout_a2m",
+ "mout_mpll",
+ "mout_epll",
+ "mout_vpll"
+};
+
+PNAME(mout_group2_p) = {
+ "xxti",
+ "xusbxti",
+ "sclk_hdmi27m",
+ "sclk_usbphy0",
+ "sclk_usbphy1",
+ "sclk_hdmiphy",
+ "mout_mpll",
+ "mout_epll",
+ "mout_vpll",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none"
+};
+
+PNAME(mout_audio0_p) = {
+ "xxti",
+ "pcmcdclk0",
+ "sclk_hdmi27m",
+ "sclk_usbphy0",
+ "sclk_usbphy1",
+ "sclk_hdmiphy",
+ "mout_mpll",
+ "mout_epll",
+ "mout_vpll",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none"
+};
+
+PNAME(mout_audio1_p) = {
+ "i2scdclk1",
+ "pcmcdclk1",
+ "sclk_hdmi27m",
+ "sclk_usbphy0",
+ "sclk_usbphy1",
+ "sclk_hdmiphy",
+ "mout_mpll",
+ "mout_epll",
+ "mout_vpll",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none"
+};
+
+PNAME(mout_audio2_p) = {
+ "i2scdclk2",
+ "pcmcdclk2",
+ "sclk_hdmi27m",
+ "sclk_usbphy0",
+ "sclk_usbphy1",
+ "sclk_hdmiphy",
+ "mout_mpll",
+ "mout_epll",
+ "mout_vpll",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none",
+ "none"
+};
+
+PNAME(mout_spdif_p) = {
+ "dout_audio0",
+ "dout_audio1",
+ "dout_audio3",
+ "none"
+};
+
+PNAME(mout_group3_p) = {
+ "mout_apll",
+ "mout_mpll"
+};
+PNAME(mout_group4_p) = {
+ "mout_mpll",
+ "dout_a2m"
+};
+
+PNAME(mout_flash_p) = {
+ "dout_hclkd",
+ "dout_hclkp"
+};
+
+PNAME(mout_dac_p) = {
+ "mout_vpll",
+ "sclk_hdmiphy"
+};
+
+PNAME(mout_hdmi_p) = {
+ "sclk_hdmiphy",
+ "dout_tblk"
+
+};
+
+PNAME(mout_mixer_p) = {
+ "mout_dac",
+ "mout_hdmi"
+};
+
+/* register S5PC110/S5PV210 clocks */
+MUX_CLOCKS(s5pv210_mux_clks) __initdata = {
+ MUX(MOUT_FLASH, "mout_flash", mout_flash_p, CLK_SRC0, 28, 1),
+ MUX(MOUT_PSYS, "mout_psys", mout_group4_p, CLK_SRC0, 24, 1),
+ MUX(MOUT_DSYS, "mout_dsys", mout_group4_p, CLK_SRC0, 20, 1),
+ MUX(MOUT_MSYS, "mout_msys", mout_group3_p, CLK_SRC0, 16, 1),
+ MUX(MOUT_VPLL, "mout_vpll", mout_vpll_p, CLK_SRC0, 12, 1),
+ MUX(MOUT_EPLL, "mout_epll", mout_epll_p, CLK_SRC0, 8, 1),
+ MUX(MOUT_MPLL, "mout_mpll", mout_mpll_p, CLK_SRC0, 4, 1),
+ MUX(MOUT_APLL, "mout_apll", mout_apll_p, CLK_SRC0, 0, 1),
+
+ MUX(MOUT_VPLLSRC, "mout_vpllsrc", mout_vpllsrc_p, CLK_SRC1, 28, 1),
+ MUX(MOUT_CSIS, "mout_csis", mout_group2_p, CLK_SRC1, 24, 4),
+ MUX(MOUT_FIMD, "mout_fimd", mout_group2_p, CLK_SRC1, 20, 4),
+ MUX(MOUT_CAM1, "mout_cam1", mout_group2_p, CLK_SRC1, 16, 4),
+ MUX(MOUT_CAM0, "mout_cam0", mout_group2_p, CLK_SRC1, 12, 4),
+ MUX(MOUT_DAC, "mout_dac", mout_dac_p, CLK_SRC1, 8, 1),
+ MUX(MOUT_MIXER, "mout_mixer", mout_mixer_p, CLK_SRC1, 4, 1),
+
+ MUX(MOUT_HDMI, "mout_hdmi", mout_hdmi_p, CLK_SRC1, 0, 1),
+ MUX(MOUT_G2D, "mout_g2d", mout_group1_p, CLK_SRC2, 8, 2),
+ MUX(MOUT_MFC, "mout_mfc", mout_group1_p, CLK_SRC2, 4, 2),
+ MUX(MOUT_G3D, "mout_g3d", mout_group1_p, CLK_SRC2, 0, 2),
+
+ MUX(MOUT_FIMC2, "mout_fimc2", mout_group2_p, CLK_SRC3, 20, 4),
+ MUX(MOUT_FIMC1, "mout_fimc1", mout_group2_p, CLK_SRC3, 16, 4),
+ MUX(MOUT_FIMC0, "mout_fimc0", mout_group2_p, CLK_SRC3, 12, 4),
+
+ MUX(MOUT_UART3, "mout_uart3", mout_group2_p, CLK_SRC4, 28, 4),
+ MUX(MOUT_UART2, "mout_uart2", mout_group2_p, CLK_SRC4, 24, 4),
+ MUX(MOUT_UART1, "mout_uart1", mout_group2_p, CLK_SRC4, 20, 4),
+ MUX(MOUT_UART0, "mout_uart0", mout_group2_p, CLK_SRC4, 16, 4),
+ MUX(MOUT_MMC3, "mout_mmc3", mout_group2_p, CLK_SRC4, 12, 4),
+ MUX(MOUT_MMC2, "mout_mmc2", mout_group2_p, CLK_SRC4, 8, 4),
+ MUX(MOUT_MMC1, "mout_mmc1", mout_group2_p, CLK_SRC4, 4, 4),
+ MUX(MOUT_MMC0, "mout_mmc0", mout_group2_p, CLK_SRC4, 0, 4),
+
+ MUX(MOUT_PWM, "mout_pwm", mout_group2_p, CLK_SRC5, 12, 4),
+ MUX(MOUT_SPI1, "mout_spi1", mout_group2_p, CLK_SRC5, 4, 4),
+ MUX(MOUT_SPI0, "mout_spi0", mout_group2_p, CLK_SRC5, 0, 4),
+
+ MUX(MOUT_DMC0, "mout_dmc0", mout_group1_p, CLK_SRC6, 24, 2),
+ MUX(MOUT_PWI, "mout_pwi", mout_group2_p, CLK_SRC6, 20, 4),
+ MUX(MOUT_HPM, "mout_hpm", mout_group3_p, CLK_SRC6, 16, 1),
+ MUX(MOUT_SPDIF, "mout_spdif", mout_spdif_p, CLK_SRC6, 12, 2),
+ MUX(MOUT_AUDIO2, "mout_audio2", mout_audio2_p, CLK_SRC6, 8, 4),
+ MUX(MOUT_AUDIO1, "mout_audio1", mout_audio1_p, CLK_SRC6, 4, 4),
+ MUX(MOUT_AUDIO0, "mout_audio0", mout_audio0_p, CLK_SRC6, 0, 4)
+};
+
+/* Fixed rate clocks generated outside the soc */
+FIXED_RATE_CLOCKS(s5pv210_fixed_rate_ext_clks) __initdata = {
+ FRATE(0, "xxti", NULL, CLK_IS_ROOT, 0),
+ FRATE(0, "xusbxti", NULL, CLK_IS_ROOT, 0),
+};
+
+/* Fixed rate clocks generated inside the soc */
+FIXED_RATE_CLOCKS(s5pv210_fixed_rate_clks) __initdata = {
+ FRATE(0, "sclk_hdmi27m", NULL, CLK_IS_ROOT, 27000000),
+ FRATE(0, "sclk_hdmiphy", NULL, CLK_IS_ROOT, 27000000),
+ FRATE(0, "sclk_usbphy0", NULL, CLK_IS_ROOT, 48000000),
+ FRATE(0, "sclk_usbphy1", NULL, CLK_IS_ROOT, 48000000),
+};
+
+/* list of divider clocks supported in all S5PC110/S5PV210 soc's */
+DIV_CLOCKS(s5pv210_div_clks) __initdata = {
+ DIV(DOUT_PCLKP, "dout_pclkp", "dout_hclkp", CLK_DIV0, 28, 3),
+ DIV(DOUT_HCLKP, "dout_hclkp", "mout_psys", CLK_DIV0, 24, 4),
+ DIV(DOUT_PCLKD, "dout_pclkd", "dout_hclkd", CLK_DIV0, 20, 3),
+ DIV(DOUT_HCLKD, "dout_hclkd", "mout_dsys", CLK_DIV0, 16, 4),
+ DIV(DOUT_PCLKM, "dout_pclkm", "dout_hclkm", CLK_DIV0, 12, 3),
+ DIV(DOUT_HCLKM, "dout_hclkm", "dout_apll", CLK_DIV0, 8, 3),
+ DIV(DOUT_A2M, "dout_a2m", "mout_apll", CLK_DIV0, 4, 3),
+ DIV(DOUT_APLL, "dout_apll", "mout_msys", CLK_DIV0, 0, 3),
+
+ DIV(DOUT_CSIS, "dout_csis", "mout_csis", CLK_DIV1, 28, 4),
+ DIV(DOUT_FIMD, "dout_fimd", "mout_fimd", CLK_DIV1, 20, 4),
+ DIV(DOUT_CAM1, "dout_cam1", "mout_cam1", CLK_DIV1, 16, 4),
+ DIV(DOUT_CAM0, "dout_cam0", "mout_cam0", CLK_DIV1, 12, 4),
+ DIV(DOUT_TBLK, "dout_tblk", "mout_vpll", CLK_DIV1, 0, 4),
+
+ DIV(DOUT_G2D, "dout_g2d", "mout_g2d", CLK_DIV2, 8, 4),
+ DIV(DOUT_MFC, "dout_mfc", "mout_mfc", CLK_DIV2, 4, 4),
+ DIV(DOUT_G3D, "dout_g3d", "mout_g3d", CLK_DIV2, 0, 4),
+
+ DIV(DOUT_FIMC2, "dout_fimc2", "mout_fimc2", CLK_DIV3, 20, 4),
+ DIV(DOUT_FIMC1, "dout_fimc1", "mout_fimc1", CLK_DIV3, 16, 4),
+ DIV(DOUT_FIMC0, "dout_fimc0", "mout_fimc0", CLK_DIV3, 12, 4),
+
+ DIV(DOUT_UART3, "dout_uart3", "mout_uart3", CLK_DIV4, 28, 4),
+ DIV(DOUT_UART2, "dout_uart2", "mout_uart2", CLK_DIV4, 24, 4),
+ DIV(DOUT_UART1, "dout_uart1", "mout_uart1", CLK_DIV4, 20, 4),
+ DIV(DOUT_UART0, "dout_uart0", "mout_uart0", CLK_DIV4, 16, 4),
+
+ DIV(DOUT_MMC3, "dout_mmc3", "mout_mmc3", CLK_DIV4, 12, 4),
+ DIV(DOUT_MMC2, "dout_mmc2", "mout_mmc2", CLK_DIV4, 8, 4),
+ DIV(DOUT_MMC1, "dout_mmc1", "mout_mmc1", CLK_DIV4, 4, 4),
+ DIV(DOUT_MMC0, "dout_mmc0", "mout_mmc0", CLK_DIV4, 0, 4),
+
+ DIV(DOUT_PWM, "dout_pwm", "mout_pwm", CLK_DIV5, 12, 4),
+ DIV(DOUT_SPI1, "dout_spi1", "mout_spi1", CLK_DIV5, 4, 4),
+ DIV(DOUT_SPI0, "dout_spi0", "mout_spi0", CLK_DIV5, 0, 4),
+
+ DIV(DOUT_DMC0, "dout_dmc0", "mout_dmc0", CLK_DIV6, 28, 4),
+ DIV(DOUT_PWI, "dout_pwi", "mout_pwi", CLK_DIV6, 24, 4),
+ DIV(DOUT_HPM, "dout_hpm", "dout_copy", CLK_DIV6, 20, 3),
+ DIV(DOUT_COPY, "dout_copy", "mout_hpm", CLK_DIV6, 16, 3),
+ DIV(DOUT_FLASH, "dout_flash", "mout_flash", CLK_DIV6, 12, 3),
+ DIV(DOUT_AUDIO2, "dout_audio2", "mout_audio2", CLK_DIV6, 8, 4),
+ DIV(DOUT_AUDIO1, "dout_audio1", "mout_audio1", CLK_DIV6, 4, 4),
+ DIV(DOUT_AUDIO0, "dout_audio0", "mout_audio0", CLK_DIV6, 0, 4),
+
+ DIV(DOUT_DPM, "dout_dpm", "dout_pclkp", CLK_DIV7, 8, 7),
+ DIV(DOUT_DVSEM, "dout_dvsem", "dout_pclkp", CLK_DIV7, 0, 7),
+};
+
+/* list of gate clocks supported in all S5PC110/S5PV210 soc's */
+struct samsung_gate_clock s5pv210_gate_clks[] __initdata = {
+
+ GATE(CSIS, "clk_csis", "dout_hclkd", CLK_GATE_IP0, 31, 0, 0),
+ GATE(ROTATOR, "rotator", "dout_hclkd", CLK_GATE_IP0, 29, 0, 0),
+
+ GATE(MFC, "mfc", "dout_hclkm", CLK_GATE_IP0, 16, 0, 0),
+ GATE(G2D, "g2d", "dout_hclkd", CLK_GATE_IP0, 12, 0, 0),
+ GATE(G3D, "g3d", "dout_hclkm",
+ CLK_GATE_IP0, 8, CLK_SET_RATE_PARENT, 0),
+ GATE(IMEM, "imem", "dout_hclkm", CLK_GATE_IP0, 5, 0, 0),
+ GATE(PDMA1, "pdma1", "dout_hclkp", CLK_GATE_IP0, 4, 0, 0),
+ GATE(PDMA0, "pdma0", "dout_hclkp", CLK_GATE_IP0, 3, 0, 0),
+ GATE(MDMA, "mdma", "dout_hclkd", CLK_GATE_IP0, 2, 0, 0),
+
+ GATE(NFCON, "nfcon", "dout_hclkp", CLK_GATE_IP1, 28, 0, 0),
+ GATE(SROMC, "sromc", "dout_hclkp", CLK_GATE_IP1, 26, 0, 0),
+ GATE(CFCON, "cfcon", "dout_hclkp", CLK_GATE_IP1, 25, 0, 0),
+ GATE(NANDXL, "nandxl", "dout_hclkp", CLK_GATE_IP1, 24, 0, 0),
+ GATE(USB_HOST, "usb_host", "dout_hclkp", CLK_GATE_IP1, 17, 0, 0),
+ GATE(USB_OTG, "usb_otg", "dout_hclkp", CLK_GATE_IP1, 16, 0, 0),
+ GATE(HDMI, "hdmi", "dout_hclkd", CLK_GATE_IP1, 11, 0, 0),
+ GATE(TVENC, "tvenc", "dout_hclkd", CLK_GATE_IP1, 10, 0, 0),
+ GATE(MIXER, "mixer", "dout_hclkd", CLK_GATE_IP1, 9, 0, 0),
+ GATE(VP, "vp", "dout_hclkd", CLK_GATE_IP1, 8, 0, 0),
+ GATE(DSIM, "dsim", "dout_pclkd", CLK_GATE_IP1, 2, 0, 0),
+ GATE(FIMD, "fimd", "dout_hclkd", CLK_GATE_IP1, 0, 0, 0),
+
+ GATE(TZIC3, "tzic3", "dout_hclkm", CLK_GATE_IP2, 31, 0, 0),
+ GATE(TZIC2, "tzic2", "dout_hclkm", CLK_GATE_IP2, 30, 0, 0),
+ GATE(TZIC1, "tzic1", "dout_hclkm", CLK_GATE_IP2, 29, 0, 0),
+ GATE(TZIC0, "tzic0", "dout_hclkm", CLK_GATE_IP2, 28, 0, 0),
+ GATE(TSI, "tsi", "dout_hclkd", CLK_GATE_IP2, 20, 0, 0),
+ GATE(HSMMC3, "hsmmc3", "dout_hclkp", CLK_GATE_IP2, 19, 0, 0),
+ GATE(HSMMC2, "hsmmc2", "dout_hclkp", CLK_GATE_IP2, 18, 0, 0),
+ GATE(HSMMC1, "hsmmc1", "dout_hclkp", CLK_GATE_IP2, 17, 0, 0),
+ GATE(HSMMC0, "hsmmc0", "dout_hclkp", CLK_GATE_IP2, 16, 0, 0),
+ GATE(JTAG, "jtag", "dout_hclkp", CLK_GATE_IP2, 11, 0, 0),
+ GATE(MODEMIF, "modemif", "dout_hclkp", CLK_GATE_IP2, 9, 0, 0),
+ GATE(CORESIGHT, "coresight", "dout_pclkp", CLK_GATE_IP2, 8, 0, 0),
+ GATE(SDM, "sdm", "dout_pclkm", CLK_GATE_IP2, 1, 0, 0),
+ GATE(SECSS, "secss", "dout_hclkp", CLK_GATE_IP2, 0, 0, 0),
+
+ GATE(PCM2, "pcm2", "dout_pclkp", CLK_GATE_IP3, 30, 0, 0),
+ GATE(PCM1, "pcm1", "dout_pclkp", CLK_GATE_IP3, 29, 0, 0),
+ GATE(PCM0, "pcm0", "dout_pclkp", CLK_GATE_IP3, 28, 0, 0),
+ GATE(TSADC, "tsadc", "dout_pclkp", CLK_GATE_IP3, 24, 0, 0),
+ GATE(PWM, "pwm", "dout_pclkp", CLK_GATE_IP3, 23, 0, 0),
+ GATE(WDT, "watchdog", "dout_pclkp", CLK_GATE_IP3, 22, 0, 0),
+ GATE(KEYIF, "keyif", "dout_pclkp", CLK_GATE_IP3, 21, 0, 0),
+ GATE(UART3, "uart3", "dout_pclkp", CLK_GATE_IP3, 20, 0, 0),
+ GATE(UART2, "uart2", "dout_pclkp", CLK_GATE_IP3, 19, 0, 0),
+ GATE(UART1, "uart1", "dout_pclkp", CLK_GATE_IP3, 18, 0, 0),
+ GATE(UART0, "uart0", "dout_pclkp", CLK_GATE_IP3, 17, 0, 0),
+ GATE(SYSTIMER, "systimer", "dout_pclkp", CLK_GATE_IP3, 16, 0, 0),
+ GATE(RTC, "rtc", "dout_pclkp", CLK_GATE_IP3, 15, 0, 0),
+ GATE(SPI1, "spi1", "dout_pclkp", CLK_GATE_IP3, 13, 0, 0),
+ GATE(SPI0, "spi0", "dout_pclkp", CLK_GATE_IP3, 12, 0, 0),
+ GATE(I2C_HDMI_PHY, "i2c_hdmi_phy", "dout_pclkd",
+ CLK_GATE_IP3, 11, 0, 0),
+ GATE(I2C_HDMI_CEC, "i2c_hdmi_cec", "dout_pclkd",
+ CLK_GATE_IP3, 10, 0, 0),
+ GATE(I2C2, "i2c2", "dout_pclkp", CLK_GATE_IP3, 9, 0, 0),
+ GATE(I2C0, "i2c0", "dout_pclkp", CLK_GATE_IP3, 7, 0, 0),
+ GATE(I2S1, "i2s1", "dout_pclkp", CLK_GATE_IP3, 6, 0, 0),
+ GATE(I2S2, "i2s2", "dout_pclkp", CLK_GATE_IP3, 5, 0, 0),
+ GATE(I2S0, "i2s0", "dout_pclkp", CLK_GATE_IP3, 4, 0, 0),
+ GATE(AC97, "ac97", "dout_pclkp", CLK_GATE_IP3, 1, 0, 0),
+ GATE(SPDIF, "spdif", "dout_pclkp", CLK_GATE_IP3, 0, 0, 0),
+
+ GATE(TZPC3, "tzpc.3", "dout_pclkd", CLK_GATE_IP4, 8, 0, 0),
+ GATE(TZPC2, "tzpc.2", "dout_pclkd", CLK_GATE_IP4, 7, 0, 0),
+ GATE(TZPC1, "tzpc.1", "dout_pclkp", CLK_GATE_IP4, 6, 0, 0),
+ GATE(TZPC0, "tzpc.0", "dout_pclkm", CLK_GATE_IP4, 5, 0, 0),
+ GATE(SECKEY, "seckey", "dout_pclkp", CLK_GATE_IP4, 3, 0, 0),
+ GATE(IEM_APC, "iem_apc", "dout_pclkp", CLK_GATE_IP4, 2, 0, 0),
+ GATE(IEM_IEC, "iem_iec", "dout_pclkp", CLK_GATE_IP4, 1, 0, 0),
+ GATE(CHIPID, "chipid", "dout_pclkp", CLK_GATE_IP4, 0, 0, 0),
+
+ GATE(JPEG, "jpeg", "dout_hclkd", CLK_GATE_IP5, 29, 0, 0),
+
+ GATE(SCLK_SPDIF, "sclk_spdif", "mout_spdif", CLK_SRC_MASK0, 27,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_AUDIO2, "sclk_audio2", "dout_audio2", CLK_SRC_MASK0, 26,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_AUDIO1, "sclk_audio1", "dout_audio1", CLK_SRC_MASK0, 25,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_AUDIO0, "sclk_audio0", "dout_audio0", CLK_SRC_MASK0, 24,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_PWM, "sclk_pwm", "dout_pwm", CLK_SRC_MASK0, 19,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_SPI1, "sclk_spi1", "dout_spi1", CLK_SRC_MASK0, 17,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_SPI0, "sclk_spi0", "dout_spi0", CLK_SRC_MASK0, 16,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_UART3, "sclk_uart3", "dout_uart3", CLK_SRC_MASK0, 15,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_UART2, "sclk_uart2", "dout_uart2", CLK_SRC_MASK0, 14,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_UART1, "sclk_uart1", "dout_uart1", CLK_SRC_MASK0, 13,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_UART0, "sclk_uart0", "dout_uart0", CLK_SRC_MASK0, 12,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_MMC3, "sclk_mmc3", "dout_mmc3", CLK_SRC_MASK0, 11,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_MMC2, "sclk_mmc2", "dout_mmc2", CLK_SRC_MASK0, 10,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_MMC1, "sclk_mmc1", "dout_mmc1", CLK_SRC_MASK0, 9,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_MMC0, "sclk_mmc0", "dout_mmc0", CLK_SRC_MASK0, 8,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_CSIS, "sclk_csis", "dout_csis", CLK_SRC_MASK0, 6,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_FIMD, "sclk_fimd", "dout_fimd", CLK_SRC_MASK0, 5,
+ CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
+ GATE(SCLK_CAM1, "sclk_cam1", "dout_cam1", CLK_SRC_MASK0, 4,
+ CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
+ GATE(SCLK_CAM0, "sclk_cam0", "dout_cam0", CLK_SRC_MASK0, 3,
+ CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
+ GATE(SCLK_DAC, "sclk_dac", "mout_dac", CLK_SRC_MASK0, 2, 0, 0),
+ GATE(SCLK_MIXER, "sclk_mixer", "mout_mixer", CLK_SRC_MASK0, 1, 0, 0),
+ GATE(SCLK_HDMI, "sclk_hdmi", "mout_hdmi", CLK_SRC_MASK0, 0, 0, 0),
+
+ GATE(SCLK_FIMC2, "sclk_fimc2", "dout_fimc2", CLK_SRC_MASK1, 4,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_FIMC1, "sclk_fimc1", "dout_fimc1", CLK_SRC_MASK1, 3,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(SCLK_FIMC0, "sclk_fimc0", "dout_fimc0", CLK_SRC_MASK1, 2,
+ CLK_SET_RATE_PARENT, 0),
+ GATE(FIMC2, "fimc2", "dout_hclkd", CLK_GATE_IP0, 26, 0, 0),
+ GATE(FIMC1, "fimc1", "dout_hclkd", CLK_GATE_IP0, 25, 0, 0),
+ GATE(FIMC0, "fimc0", "dout_hclkd", CLK_GATE_IP0, 24, 0, 0),
+
+ /*HACK dacphy isn`t real clock*/
+ GATE(DACPHY, "dacphy", "dout_hclkd", DAC_CONTROL, 0, 0, 0),
+};
+
+/* list of all parent clock list */
+static struct samsung_clock_alias s5pv210_clock_aliases[] = {
+ ALIAS(FIMC0, "s5pv210-fimc.0", "fimc"),
+ ALIAS(FIMC1, "s5pv210-fimc.1", "fimc"),
+ ALIAS(FIMC2, "s5pv210-fimc.2", "fimc"),
+ ALIAS(MOUT_FIMC2, NULL, "mout_fimc2"),
+ ALIAS(MOUT_FIMC1, NULL, "mout_fimc1"),
+ ALIAS(MOUT_FIMC0, NULL, "mout_fimc0"),
+ ALIAS(SCLK_FIMC0, "s5pv210-fimc.0", "sclk_fimc"),
+ ALIAS(SCLK_FIMC1, "s5pv210-fimc.1", "sclk_fimc"),
+ ALIAS(SCLK_FIMC2, "s5pv210-fimc.2", "sclk_fimc"),
+
+ ALIAS(MOUT_APLL, NULL, "mout_apll"),
+ ALIAS(MOUT_MPLL, NULL, "mout_mpll"),
+ ALIAS(MOUT_EPLL, NULL, "mout_epll"),
+ ALIAS(MOUT_VPLL, NULL, "mout_vpll"),
+ ALIAS(UART0, "s5pv210-uart.0", "uart"),
+ ALIAS(UART1, "s5pv210-uart.1", "uart"),
+ ALIAS(UART2, "s5pv210-uart.2", "uart"),
+ ALIAS(UART3, "s5pv210-uart.3", "uart"),
+ ALIAS(UART0, "s5pv210-uart.0", "clk_uart_baud0"),
+ ALIAS(UART1, "s5pv210-uart.1", "clk_uart_baud0"),
+ ALIAS(UART2, "s5pv210-uart.2", "clk_uart_baud0"),
+ ALIAS(UART3, "s5pv210-uart.3", "clk_uart_baud0"),
+ ALIAS(SCLK_UART0, "s5pv210-uart.0", "clk_uart_baud1"),
+ ALIAS(SCLK_UART1, "s5pv210-uart.1", "clk_uart_baud1"),
+ ALIAS(SCLK_UART2, "s5pv210-uart.2", "clk_uart_baud1"),
+ ALIAS(SCLK_UART3, "s5pv210-uart.3", "clk_uart_baud1"),
+ ALIAS(HSMMC0, "s3c-sdhci.0", "hsmmc"),
+ ALIAS(HSMMC1, "s3c-sdhci.1", "hsmmc"),
+ ALIAS(HSMMC2, "s3c-sdhci.2", "hsmmc"),
+ ALIAS(HSMMC3, "s3c-sdhci.3", "hsmmc"),
+ ALIAS(HSMMC0, "s3c-sdhci.0", "mmc_busclk.0"),
+ ALIAS(HSMMC1, "s3c-sdhci.1", "mmc_busclk.0"),
+ ALIAS(HSMMC2, "s3c-sdhci.2", "mmc_busclk.0"),
+ ALIAS(HSMMC3, "s3c-sdhci.3", "mmc_busclk.0"),
+ ALIAS(SCLK_MMC0, "s3c-sdhci.0", "mmc_busclk.2"),
+ ALIAS(SCLK_MMC1, "s3c-sdhci.1", "mmc_busclk.2"),
+ ALIAS(SCLK_MMC2, "s3c-sdhci.2", "mmc_busclk.2"),
+ ALIAS(SCLK_MMC3, "s3c-sdhci.3", "mmc_busclk.2"),
+ ALIAS(SPI0, "s5pv210-spi.0", "spi_busclk0"),
+ ALIAS(SPI1, "s5pv210-spi.1", "spi_busclk0"),
+ ALIAS(SCLK_SPI0, "s5pv210-spi.0", "spi_busclk1"),
+ ALIAS(SCLK_SPI1, "s5pv210-spi.1", "spi_busclk1"),
+ ALIAS(PDMA0, "dma-pl330.0", "apb_pclk"),
+ ALIAS(PDMA1, "dma-pl330.1", "apb_pclk"),
+ ALIAS(PWM, NULL, "timers"),
+
+ ALIAS(JPEG, NULL, "jpeg"),
+ ALIAS(MFC, "s5p-mfc", "mfc"),
+ ALIAS(TVENC, "s5p-sdo", "dac"),
+ ALIAS(MIXER, "s5p-mixer", "mixer"),
+ ALIAS(VP, "s5p-mixer", "vp"),
+ ALIAS(HDMI, "s5p-hdmi", "hdmi"),
+ ALIAS(SCLK_HDMI, "s5p-hdmi", "hdmiphy"),
+
+ ALIAS(SCLK_DAC, NULL, "sclk_dac"),
+ ALIAS(DACPHY, "s5p-sdo", "dacphy"),
+ ALIAS(USB_OTG, NULL, "usbotg"),
+ ALIAS(USB_OTG, NULL, "otg"),
+ ALIAS(USB_HOST, NULL, "usb-host"),
+ ALIAS(USB_HOST, NULL, "usbhost"),
+ ALIAS(FIMD, "s5pv210-fb", "lcd"),
+ ALIAS(CFCON, NULL, "cfcon"),
+ ALIAS(SYSTIMER, NULL, "systimer"),
+ ALIAS(WDT, NULL, "watchdog"),
+ ALIAS(RTC, NULL, "rtc"),
+ ALIAS(I2C0, "s3c2440-i2c.0", "i2c"),
+ ALIAS(I2C_HDMI_CEC, "s3c2440-i2c.1", "i2c"),
+ ALIAS(I2C2, "s3c2440-i2c.2", "i2c"),
+ ALIAS(I2C_HDMI_PHY, "s3c2440-hdmiphy-i2c", "i2c"),
+ ALIAS(TSADC, NULL, "adc"),
+ ALIAS(KEYIF, "s5pv210-keypad", "keypad"),
+ ALIAS(I2S0, "samsung-i2s.0", "iis"),
+ ALIAS(I2S1, "samsung-i2s.1", "iis"),
+ ALIAS(I2S2, "samsung-i2s.2", "iis"),
+ ALIAS(SPDIF, NULL, "spdif"),
+ ALIAS(ROTATOR, NULL, "rot"),
+ ALIAS(DOUT_APLL, NULL, "armclk"),
+ ALIAS(SCLK_AUDIO0, "soc-audio.0", "sclk_audio"),
+ ALIAS(SCLK_AUDIO1, "soc-audio.1", "sclk_audio"),
+ ALIAS(SCLK_AUDIO2, "soc-audio.2", "sclk_audio"),
+
+ ALIAS(MFC, "s5p-mfc", "sclk_mfc"),
+ ALIAS(SCLK_CAM0, NULL, "sclk_cam0"),
+ ALIAS(SCLK_CAM1, NULL, "sclk_cam1"),
+ ALIAS(G2D, "s5p-g2d", "fimg2d"),
+ ALIAS(DOUT_G2D, "s5p-g2d", "sclk_fimg2d"),
+ ALIAS(CSIS, "s5p-mipi-csis", "csis"),
+ ALIAS(SCLK_CSIS, "s5p-mipi-csis", "sclk_csis"),
+ ALIAS(SCLK_PWM, "samsung-pwm", "pwm-tclk0"),
+ ALIAS(SCLK_PWM, "samsung-pwm", "pwm-tclk1"),
+ ALIAS(SCLK_FIMD, NULL, "sclk_fimd"),
+ ALIAS(MOUT_CAM0, NULL, "mout_cam0"),
+ ALIAS(MOUT_CAM1, NULL, "mout_cam1"),
+
+ ALIAS(MOUT_CSIS, NULL, "mout_csis"),
+ ALIAS(MOUT_VPLL, NULL, "sclk_vpll"),
+ ALIAS(SCLK_MIXER, NULL, "sclk_mixer"),
+ ALIAS(SCLK_HDMI, NULL, "sclk_hdmi"),
+};
+
+static unsigned long __init s5pv210_get_xom(void)
+{
+ unsigned long xom = 1;
+ struct device_node *np;
+
+ np = of_find_compatible_node(NULL, NULL, "samsung,s5pv210-chipid");
+ if (np) {
+ void __iomem *chipid_base = of_iomap(np, 0);
+
+ if (!chipid_base)
+ panic("%s: failed to map chipid\n", __func__);
+ else {
+ xom = readl(chipid_base + 8);
+ iounmap(chipid_base);
+ }
+ }
+
+ return xom;
+}
+
+static void __init s5pv210_clk_register_finpll(unsigned long xom)
+{
+ struct samsung_fixed_rate_clock fclk;
+ struct clk *clk;
+ unsigned long finpll_f = 24000000;
+ char *parent_name;
+
+ parent_name = xom & 1 ? "xusbxti" : "xxti";
+ clk = clk_get(NULL, parent_name);
+ if (IS_ERR(clk))
+ pr_err("%s: failed to lookup parent clock %s, assuming fin_pll clock frequency is 24MHz\n",
+ __func__, parent_name);
+ else
+ finpll_f = clk_get_rate(clk);
+
+ fclk.id = FIN_PLL;
+ fclk.name = "fin_pll";
+ fclk.parent_name = NULL;
+ fclk.flags = CLK_IS_ROOT;
+ fclk.fixed_rate = finpll_f;
+ samsung_clk_register_fixed_rate(&fclk, 1);
+}
+
+static void __init s5pv210_clk_register_fixed_ext(unsigned long xxti_f,
+ unsigned long xusbxti_f)
+{
+ s5pv210_fixed_rate_ext_clks[0].fixed_rate = xxti_f;
+ s5pv210_fixed_rate_ext_clks[1].fixed_rate = xusbxti_f;
+ samsung_clk_register_fixed_rate(s5pv210_fixed_rate_ext_clks,
+ ARRAY_SIZE(s5pv210_fixed_rate_ext_clks));
+}
+
+static struct samsung_pll_clock s5pv210_pll_clks[] __initdata = {
+ [apll] = PLL(pll_4508, FOUT_APLL, "fout_apll", "fin_pll",
+ APLL_LOCK, APLL_CON0, NULL),
+ [mpll] = PLL(pll_4502, FOUT_MPLL, "fout_mpll", "fin_pll",
+ MPLL_LOCK, MPLL_CON, NULL),
+ [epll] = PLL(pll_4600, FOUT_EPLL, "fout_epll", "fin_pll",
+ EPLL_LOCK, EPLL_CON0, NULL),
+ [vpll] = PLL(pll_4502, FOUT_VPLL, "fout_vpll", "mout_vpllsrc",
+ VPLL_LOCK, VPLL_CON0, NULL),
+};
+
+void __init s5pv210_clk_init(struct device_node *np, unsigned long xxti_f,
+ unsigned long xusbxti_f, void __iomem *reg_base)
+{
+ unsigned long xom = s5pv210_get_xom();
+
+ if (np) {
+ reg_base = of_iomap(np, 0);
+ if (!reg_base)
+ panic("%s: failed to map registers\n", __func__);
+ }
+
+ samsung_clk_init(np, reg_base, NR_CLKS, s5pv210_clk_regs,
+ ARRAY_SIZE(s5pv210_clk_regs), NULL, 0);
+
+ /* Register external clocks. */
+ if (!np)
+ s5pv210_clk_register_fixed_ext(xxti_f, xusbxti_f);
+
+ s5pv210_clk_register_finpll(xom);
+
+ /* Register PLLs. */
+ samsung_clk_register_pll(s5pv210_pll_clks,
+ ARRAY_SIZE(s5pv210_pll_clks), reg_base);
+
+ samsung_clk_register_fixed_rate(s5pv210_fixed_rate_clks,
+ ARRAY_SIZE(s5pv210_fixed_rate_clks));
+
+
+ samsung_clk_register_mux(s5pv210_mux_clks,
+ ARRAY_SIZE(s5pv210_mux_clks));
+
+ samsung_clk_register_div(s5pv210_div_clks,
+ ARRAY_SIZE(s5pv210_div_clks));
+
+ samsung_clk_register_gate(s5pv210_gate_clks,
+ ARRAY_SIZE(s5pv210_gate_clks));
+
+ samsung_clk_register_alias(s5pv210_clock_aliases,
+ ARRAY_SIZE(s5pv210_clock_aliases));
+
+ pr_info("S5PC110/S5PV210 clocks: mout_apll = %ld, mout_mpll = %ld\n"
+ "\tmout_epll = %ld, mout_vpll = %ld\n",
+ _get_rate("mout_apll"), _get_rate("mout_mpll"),
+ _get_rate("mout_epll"), _get_rate("mout_vpll"));
+}
+static void __init s5pv210_clk_dt_init(struct device_node *np)
+{
+ s5pv210_clk_init(np, 0, 0, NULL);
+}
+CLK_OF_DECLARE(s5pv210_clk, "samsung,s5pv210-clock", s5pv210_clk_dt_init);
diff --git a/include/dt-bindings/clock/samsung,s5pv210-clock.h b/include/dt-bindings/clock/samsung,s5pv210-clock.h
new file mode 100644
index 0000000..b06ac55
--- /dev/null
+++ b/include/dt-bindings/clock/samsung,s5pv210-clock.h
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * Author: Mateusz Krawczuk <[email protected]>
+ *
+ * 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.
+ *
+ * Device Tree binding constants for Samsung S5PV210 clock controller.
+*/
+
+#ifndef _DT_BINDINGS_CLOCK_SAMSUNG_S5PV210_CLOCK_H
+#define _DT_BINDINGS_CLOCK_SAMSUNG_S5PV210_CLOCK_H
+
+/* Core clocks. */
+#define FIN_PLL 1
+#define FOUT_APLL 2
+#define FOUT_MPLL 3
+#define FOUT_EPLL 4
+#define FOUT_VPLL 5
+
+/* Muxes. */
+#define MOUT_FLASH 6
+#define MOUT_PSYS 7
+#define MOUT_DSYS 8
+#define MOUT_MSYS 9
+#define MOUT_VPLL 10
+#define MOUT_EPLL 11
+#define MOUT_MPLL 12
+#define MOUT_APLL 13
+#define MOUT_VPLLSRC 14
+#define MOUT_CSIS 15
+#define MOUT_FIMD 16
+#define MOUT_CAM1 17
+#define MOUT_CAM0 18
+#define MOUT_DAC 19
+#define MOUT_MIXER 20
+#define MOUT_HDMI 21
+#define MOUT_G2D 22
+#define MOUT_MFC 23
+#define MOUT_G3D 24
+#define MOUT_FIMC2 25
+#define MOUT_FIMC1 26
+#define MOUT_FIMC0 27
+#define MOUT_UART3 28
+#define MOUT_UART2 29
+#define MOUT_UART1 30
+#define MOUT_UART0 31
+#define MOUT_MMC3 32
+#define MOUT_MMC2 33
+#define MOUT_MMC1 34
+#define MOUT_MMC0 35
+#define MOUT_PWM 36
+#define MOUT_SPI0 37
+#define MOUT_SPI1 38
+#define MOUT_DMC0 39
+#define MOUT_PWI 40
+#define MOUT_HPM 41
+#define MOUT_SPDIF 42
+#define MOUT_AUDIO2 43
+#define MOUT_AUDIO1 44
+#define MOUT_AUDIO0 45
+
+/* Dividers. */
+#define DOUT_PCLKP 46
+#define DOUT_HCLKP 47
+#define DOUT_PCLKD 48
+#define DOUT_HCLKD 49
+#define DOUT_PCLKM 50
+#define DOUT_HCLKM 51
+#define DOUT_A2M 52
+#define DOUT_APLL 53
+#define DOUT_CSIS 54
+#define DOUT_FIMD 55
+#define DOUT_CAM1 56
+#define DOUT_CAM0 57
+#define DOUT_TBLK 58
+#define DOUT_G2D 59
+#define DOUT_MFC 60
+#define DOUT_G3D 61
+#define DOUT_FIMC2 62
+#define DOUT_FIMC1 63
+#define DOUT_FIMC0 64
+#define DOUT_UART3 65
+#define DOUT_UART2 66
+#define DOUT_UART1 67
+#define DOUT_UART0 68
+#define DOUT_MMC3 69
+#define DOUT_MMC2 70
+#define DOUT_MMC1 71
+#define DOUT_MMC0 72
+#define DOUT_PWM 73
+#define DOUT_SPI1 74
+#define DOUT_SPI0 75
+#define DOUT_DMC0 76
+#define DOUT_PWI 77
+#define DOUT_HPM 78
+#define DOUT_COPY 79
+#define DOUT_FLASH 80
+#define DOUT_AUDIO2 81
+#define DOUT_AUDIO1 82
+#define DOUT_AUDIO0 83
+#define DOUT_DPM 84
+#define DOUT_DVSEM 85
+
+/* Gates */
+#define SCLK_FIMC 86
+#define CSIS 87
+#define ROTATOR 88
+#define FIMC2 89
+#define FIMC1 90
+#define FIMC0 91
+#define MFC 92
+#define G2D 93
+#define G3D 94
+#define IMEM 95
+#define PDMA1 96
+#define PDMA0 97
+#define MDMA 98
+#define DMC1 99
+#define DMC0 100
+#define NFCON 101
+#define SROMC 102
+#define CFCON 103
+#define NANDXL 104
+#define USB_HOST 105
+#define USB_OTG 106
+#define HDMI 107
+#define TVENC 108
+#define MIXER 109
+#define VP 110
+#define DSIM 111
+#define FIMD 112
+#define TZIC3 113
+#define TZIC2 114
+#define TZIC1 115
+#define TZIC0 116
+#define VIC3 117
+#define VIC2 118
+#define VIC1 119
+#define VIC0 120
+#define TSI 121
+#define HSMMC3 122
+#define HSMMC2 123
+#define HSMMC1 124
+#define HSMMC0 125
+#define JTAG 126
+#define MODEMIF 127
+#define CORESIGHT 128
+#define SDM 129
+#define SECSS 130
+#define PCM2 131
+#define PCM1 132
+#define PCM0 133
+#define SYSCON 134
+#define GPIO 135
+#define TSADC 136
+#define PWM 137
+#define WDT 138
+#define KEYIF 139
+#define UART3 140
+#define UART2 141
+#define UART1 142
+#define UART0 143
+#define SYSTIMER 144
+#define RTC 145
+#define SPI1 146
+#define SPI0 147
+#define I2C_HDMI_PHY 148
+#define I2C_HDMI_CEC 149
+#define I2C2 150
+#define I2C0 151
+#define I2S1 152
+#define I2S2 153
+#define I2S0 154
+#define AC97 155
+#define SPDIF 156
+#define TZPC3 157
+#define TZPC2 158
+#define TZPC1 159
+#define TZPC0 160
+#define SECKEY 161
+#define IEM_APC 162
+#define IEM_IEC 163
+#define CHIPID 164
+#define JPEG 163
+
+/* Special clocks*/
+#define SCLK_PWI 164
+#define SCLK_SPDIF 165
+#define SCLK_AUDIO2 166
+#define SCLK_AUDIO1 167
+#define SCLK_AUDIO0 168
+#define SCLK_PWM 169
+#define SCLK_SPI1 170
+#define SCLK_SPI0 171
+#define SCLK_UART3 172
+#define SCLK_UART2 173
+#define SCLK_UART1 174
+#define SCLK_UART0 175
+#define SCLK_MMC3 176
+#define SCLK_MMC2 177
+#define SCLK_MMC1 178
+#define SCLK_MMC0 179
+#define SCLK_FINVPLL 180
+#define SCLK_CSIS 181
+#define SCLK_FIMD 182
+#define SCLK_CAM1 183
+#define SCLK_CAM0 184
+#define SCLK_DAC 185
+#define SCLK_MIXER 186
+#define SCLK_HDMI 187
+#define SCLK_FIMC2 188
+#define SCLK_FIMC1 189
+#define SCLK_FIMC0 190
+#define DACPHY 191
+
+/* Total number of clocks. */
+#define NR_CLKS (DACPHY + 1)
+
+#endif /* _DT_BINDINGS_CLOCK_SAMSUNG_S5PV210_CLOCK_H */
--
1.8.1.2

2013-08-28 16:15:56

by Mateusz Krawczuk

[permalink] [raw]
Subject: [PATCH v3 6/6] ARM: s5pv210: Migrate clock handling to Common Clock Framework

This patch migrates the s5pv210 platform to use new clock driver
using Common Clock Framework.

Signed-off-by: Mateusz Krawczuk <[email protected]>
---
arch/arm/mach-s5pv210/Kconfig | 9 +++++++++
arch/arm/mach-s5pv210/Makefile | 4 ++--
arch/arm/mach-s5pv210/common.c | 17 +++++++++++++++++
arch/arm/mach-s5pv210/common.h | 13 +++++++++++++
arch/arm/mach-s5pv210/mach-aquila.c | 1 +
arch/arm/mach-s5pv210/mach-goni.c | 3 ++-
arch/arm/mach-s5pv210/mach-smdkc110.c | 1 +
arch/arm/mach-s5pv210/mach-smdkv210.c | 1 +
arch/arm/mach-s5pv210/mach-torbreck.c | 1 +
arch/arm/plat-samsung/Kconfig | 2 +-
arch/arm/plat-samsung/init.c | 2 --
11 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-s5pv210/Kconfig b/arch/arm/mach-s5pv210/Kconfig
index caaedaf..ad4546e 100644
--- a/arch/arm/mach-s5pv210/Kconfig
+++ b/arch/arm/mach-s5pv210/Kconfig
@@ -15,6 +15,7 @@ config CPU_S5PV210
select S5P_PM if PM
select S5P_SLEEP if PM
select SAMSUNG_DMADEV
+ select S5P_CLOCK if !COMMON_CLK
help
Enable S5PV210 CPU support

@@ -69,6 +70,14 @@ config S5PV210_SETUP_USB_PHY
help
Common setup code for USB PHY controller

+config COMMON_CLK_S5PV210
+ bool "Common Clock Framework support"
+ default y
+ select COMMON_CLK
+ help
+ Enable this option to use new clock driver
+ based on Common Clock Framework.
+
menu "S5PC110 Machines"

config MACH_AQUILA
diff --git a/arch/arm/mach-s5pv210/Makefile b/arch/arm/mach-s5pv210/Makefile
index 1c4e419..0c67fe2 100644
--- a/arch/arm/mach-s5pv210/Makefile
+++ b/arch/arm/mach-s5pv210/Makefile
@@ -12,8 +12,8 @@ obj- :=

# Core

-obj-y += common.o clock.o
-
+obj-y += common.o
+obj-$(CONFIG_S5P_CLOCK) += clock.o
obj-$(CONFIG_PM) += pm.o

obj-y += dma.o
diff --git a/arch/arm/mach-s5pv210/common.c b/arch/arm/mach-s5pv210/common.c
index 26027a2..a1d86a1 100644
--- a/arch/arm/mach-s5pv210/common.c
+++ b/arch/arm/mach-s5pv210/common.c
@@ -34,7 +34,13 @@
#include <mach/regs-clock.h>

#include <plat/cpu.h>
+
+#ifdef CONFIG_S5P_CLOCK
#include <plat/clock.h>
+#else
+#include <linux/clk-provider.h>
+#endif
+
#include <plat/devs.h>
#include <plat/sdhci.h>
#include <plat/adc-core.h>
@@ -50,6 +56,14 @@

#include "common.h"

+/* External clock frequency */
+static unsigned long xusbxti_f, xxti_f;
+
+void __init s5pv210_set_xusbxti_freq(unsigned long freq)
+{
+ xusbxti_f = freq;
+}
+
static const char name_s5pv210[] = "S5PV210/S5PC110";

static struct cpu_table cpu_ids[] __initdata = {
@@ -229,12 +243,14 @@ void __init s5pv210_map_io(void)

void __init s5pv210_init_clocks(int xtal)
{
+#ifdef CONFIG_S5P_CLOCK
printk(KERN_DEBUG "%s: initializing clocks\n", __func__);

s3c24xx_register_baseclocks(xtal);
s5p_register_clocks(xtal);
s5pv210_register_clocks();
s5pv210_setup_clocks();
+#endif
}

void __init s5pv210_init_irq(void)
@@ -248,6 +264,7 @@ void __init s5pv210_init_irq(void)
vic[3] = ~0;

s5p_init_irq(vic, ARRAY_SIZE(vic));
+ s5pv210_clk_init(NULL, xxti_f, xusbxti_f, S3C_VA_SYS);
}

struct bus_type s5pv210_subsys = {
diff --git a/arch/arm/mach-s5pv210/common.h b/arch/arm/mach-s5pv210/common.h
index fe1beb5..2db2a15 100644
--- a/arch/arm/mach-s5pv210/common.h
+++ b/arch/arm/mach-s5pv210/common.h
@@ -14,6 +14,19 @@

#include <linux/reboot.h>

+void s5pv210_set_xxti_freq(unsigned long freq);
+void s5pv210_set_xusbxti_freq(unsigned long freq);
+
+#ifdef CONFIG_COMMON_CLK_S5PV210
+void s5pv210_clk_init(struct device_node *np,
+ unsigned long xxti_f, unsigned long xusbxti_f,
+ void __iomem *reg_base);
+#else
+static inline void s5pv210_clk_init(struct device_node *np,
+ unsigned long xxti_f, unsigned long xusbxti_f,
+ void __iomem *reg_base) {}
+#endif
+
void s5pv210_init_io(struct map_desc *mach_desc, int size);
void s5pv210_init_irq(void);

diff --git a/arch/arm/mach-s5pv210/mach-aquila.c b/arch/arm/mach-s5pv210/mach-aquila.c
index ad40ab0..e37a311 100644
--- a/arch/arm/mach-s5pv210/mach-aquila.c
+++ b/arch/arm/mach-s5pv210/mach-aquila.c
@@ -646,6 +646,7 @@ static void __init aquila_map_io(void)
{
s5pv210_init_io(NULL, 0);
s3c24xx_init_clocks(24000000);
+ s5pv210_set_xusbxti_freq(24000000);
s3c24xx_init_uarts(aquila_uartcfgs, ARRAY_SIZE(aquila_uartcfgs));
samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
}
diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c
index 282d714..a1955e9 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -966,7 +966,8 @@ static void __init goni_sound_init(void)
static void __init goni_map_io(void)
{
s5pv210_init_io(NULL, 0);
- s3c24xx_init_clocks(clk_xusbxti.rate);
+ s3c24xx_init_clocks(24000000);
+ s5pv210_set_xusbxti_freq(24000000);
s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs));
samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
}
diff --git a/arch/arm/mach-s5pv210/mach-smdkc110.c b/arch/arm/mach-s5pv210/mach-smdkc110.c
index 7c0ed07..89563ed 100644
--- a/arch/arm/mach-s5pv210/mach-smdkc110.c
+++ b/arch/arm/mach-s5pv210/mach-smdkc110.c
@@ -119,6 +119,7 @@ static void __init smdkc110_map_io(void)
{
s5pv210_init_io(NULL, 0);
s3c24xx_init_clocks(24000000);
+ s5pv210_set_xusbxti_freq(24000000);
s3c24xx_init_uarts(smdkv210_uartcfgs, ARRAY_SIZE(smdkv210_uartcfgs));
samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
}
diff --git a/arch/arm/mach-s5pv210/mach-smdkv210.c b/arch/arm/mach-s5pv210/mach-smdkv210.c
index 6d72bb99..ff4a470 100644
--- a/arch/arm/mach-s5pv210/mach-smdkv210.c
+++ b/arch/arm/mach-s5pv210/mach-smdkv210.c
@@ -285,6 +285,7 @@ static void __init smdkv210_map_io(void)
{
s5pv210_init_io(NULL, 0);
s3c24xx_init_clocks(clk_xusbxti.rate);
+ s5pv210_set_xusbxti_freq(24000000);
s3c24xx_init_uarts(smdkv210_uartcfgs, ARRAY_SIZE(smdkv210_uartcfgs));
samsung_set_timer_source(SAMSUNG_PWM2, SAMSUNG_PWM4);
}
diff --git a/arch/arm/mach-s5pv210/mach-torbreck.c b/arch/arm/mach-s5pv210/mach-torbreck.c
index 579afe8..c131cd2 100644
--- a/arch/arm/mach-s5pv210/mach-torbreck.c
+++ b/arch/arm/mach-s5pv210/mach-torbreck.c
@@ -105,6 +105,7 @@ static void __init torbreck_map_io(void)
{
s5pv210_init_io(NULL, 0);
s3c24xx_init_clocks(24000000);
+ s5pv210_set_xusbxti_freq(24000000);
s3c24xx_init_uarts(torbreck_uartcfgs, ARRAY_SIZE(torbreck_uartcfgs));
samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
}
diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
index 7dfba93..2a98613 100644
--- a/arch/arm/plat-samsung/Kconfig
+++ b/arch/arm/plat-samsung/Kconfig
@@ -91,7 +91,7 @@ config SAMSUNG_CLKSRC
used by newer systems such as the S3C64XX.

config S5P_CLOCK
- def_bool (ARCH_S5P64X0 || ARCH_S5PC100 || ARCH_S5PV210)
+ def_bool (ARCH_S5P64X0 || ARCH_S5PC100)
help
Support common clock part for ARCH_S5P and ARCH_EXYNOS SoCs

diff --git a/arch/arm/plat-samsung/init.c b/arch/arm/plat-samsung/init.c
index aa9511b..f0f818e 100644
--- a/arch/arm/plat-samsung/init.c
+++ b/arch/arm/plat-samsung/init.c
@@ -69,7 +69,6 @@ void __init s3c_init_cpu(unsigned long idcode,
if (cpu->map_io)
cpu->map_io();
}
-
/* s3c24xx_init_clocks
*
* Initialise the clock subsystem and associated information from the
@@ -92,7 +91,6 @@ void __init s3c24xx_init_clocks(int xtal)
else
(cpu->init_clocks)(xtal);
}
-
/* uart management */
#if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
static int nr_uarts __initdata = 0;
--
1.8.1.2

2013-08-29 10:14:26

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH v3 1/6] media: s5p-tv: Replace mxr_ macro by default dev_

Hi Mateusz,

On Wednesday 28 of August 2013 18:12:59 Mateusz Krawczuk wrote:
> Replace mxr_dbg, mxr_info and mxr_warn by generic solution.
>
> Signed-off-by: Mateusz Krawczuk <[email protected]>
> ---
> drivers/media/platform/s5p-tv/mixer.h | 12 ---
> drivers/media/platform/s5p-tv/mixer_drv.c | 47 ++++++-----
> drivers/media/platform/s5p-tv/mixer_grp_layer.c | 2 +-
> drivers/media/platform/s5p-tv/mixer_reg.c | 6 +-
> drivers/media/platform/s5p-tv/mixer_video.c | 100
> ++++++++++++------------ drivers/media/platform/s5p-tv/mixer_vp_layer.c
> | 2 +-
> 6 files changed, 78 insertions(+), 91 deletions(-)

Although, this is a valid patch, I don't think it is related by any way to
migration of S5PV210 to common clock framework. So, IMHO, this patch should
be send separately, not as a part of this series.

Best regards,
Tomasz

2013-08-29 13:08:01

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH v3 2/6] media: s5p-tv: Restore vpll clock rate

Hi Mateusz,

Generally this patch looks good, but I have some minor nitpicks, that I
would like to be fixed.

On Wednesday 28 of August 2013 18:13:00 Mateusz Krawczuk wrote:
> Restore vpll clock rate if start stream fail or stream is off.
>
> Signed-off-by: Mateusz Krawczuk <[email protected]>
> ---
> drivers/media/platform/s5p-tv/sdo_drv.c | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c
> b/drivers/media/platform/s5p-tv/sdo_drv.c index 0afa90f..9dbdfe6 100644
> --- a/drivers/media/platform/s5p-tv/sdo_drv.c
> +++ b/drivers/media/platform/s5p-tv/sdo_drv.c
> @@ -55,6 +55,8 @@ struct sdo_device {
> struct clk *dacphy;
> /** clock for control of VPLL */
> struct clk *fout_vpll;
> + /** vpll rate before sdo stream was on */
> + int vpll_rate;

Clock frequency should be stored in an unsigned long. (See the return type
of clk_get_rate().)

> /** regulator for SDO IP power */
> struct regulator *vdac;
> /** regulator for SDO plug detection */
> @@ -193,17 +195,34 @@ static int sdo_s_power(struct v4l2_subdev *sd, int
> on)
>
> static int sdo_streamon(struct sdo_device *sdev)
> {
> + int ret;
> +
> /* set proper clock for Timing Generator */
> - clk_set_rate(sdev->fout_vpll, 54000000);
> + sdev->vpll_rate = clk_get_rate(sdev->fout_vpll);
> + ret = clk_set_rate(sdev->fout_vpll, 54000000);
> + if (ret < 0) {
> + dev_err(sdev->dev,
> + "Failed to set vpll rate!\n");
> + return ret;
> + }
> dev_info(sdev->dev, "fout_vpll.rate = %lu\n",
> clk_get_rate(sdev->fout_vpll));
> /* enable clock in SDO */
> sdo_write_mask(sdev, SDO_CLKCON, ~0, SDO_TVOUT_CLOCK_ON);
> - clk_enable(sdev->dacphy);
> + ret = clk_enable(sdev->dacphy);
> + if (ret < 0) {
> + dev_err(sdev->dev,
> + "clk_enable(dacphy) failed !\n");
> + goto fail;
> + }
> /* enable DAC */
> sdo_write_mask(sdev, SDO_DAC, ~0, SDO_POWER_ON_DAC);
> sdo_reg_debug(sdev);
> return 0;

nit: Please insert a blank line here.

Best regards,
Tomasz

> +fail:
> + sdo_write_mask(sdev, SDO_CLKCON, 0, SDO_TVOUT_CLOCK_ON);
> + clk_set_rate(sdev->fout_vpll, sdev->vpll_rate);
> + return ret;
> }
>
> static int sdo_streamoff(struct sdo_device *sdev)
> @@ -220,6 +239,7 @@ static int sdo_streamoff(struct sdo_device *sdev)
> }
> if (tries == 0)
> dev_err(sdev->dev, "failed to stop streaming\n");
> + clk_set_rate(sdev->fout_vpll, sdev->vpll_rate);
> return tries ? 0 : -EIO;
> }

2013-08-29 13:14:54

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH v3 3/6] media: s5p-tv: Fix sdo driver to work with CCF

Hi Mateusz,

On Wednesday 28 of August 2013 18:13:01 Mateusz Krawczuk wrote:
> Replace clk_enable by clock_enable_prepare and clk_disable with
> clk_disable_unprepare. Clock prepare is required by Clock Common
> Framework, and old clock driver didn`t support it. Without it Common
> Clock Framework prints a warning.
>
> Signed-off-by: Mateusz Krawczuk <[email protected]>
> ---
> drivers/media/platform/s5p-tv/sdo_drv.c | 25 +++++++++++++++----------
> 1 file changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c
> b/drivers/media/platform/s5p-tv/sdo_drv.c index 9dbdfe6..a79e620 100644
> --- a/drivers/media/platform/s5p-tv/sdo_drv.c
> +++ b/drivers/media/platform/s5p-tv/sdo_drv.c
> @@ -209,10 +209,10 @@ static int sdo_streamon(struct sdo_device *sdev)
> clk_get_rate(sdev->fout_vpll));
> /* enable clock in SDO */
> sdo_write_mask(sdev, SDO_CLKCON, ~0, SDO_TVOUT_CLOCK_ON);
> - ret = clk_enable(sdev->dacphy);
> + ret = clk_prepare_enable(sdev->dacphy);
> if (ret < 0) {
> dev_err(sdev->dev,
> - "clk_enable(dacphy) failed !\n");
> + "clk_prepare_enable(dacphy) failed !\n");

nit: I haven't noticed this when reviewing previous patch, but please tone
down those errors messages a bit, by removing the exclamation mark (and the
space before it). We shouldn't be shouting at users. ;)

> goto fail;
> }
> /* enable DAC */
> @@ -230,7 +230,7 @@ static int sdo_streamoff(struct sdo_device *sdev)
> int tries;
>
> sdo_write_mask(sdev, SDO_DAC, 0, SDO_POWER_ON_DAC);
> - clk_disable(sdev->dacphy);
> + clk_disable_unprepare(sdev->dacphy);
> sdo_write_mask(sdev, SDO_CLKCON, 0, SDO_TVOUT_CLOCK_ON);
> for (tries = 100; tries; --tries) {
> if (sdo_read(sdev, SDO_CLKCON) & SDO_TVOUT_CLOCK_READY)
> @@ -274,7 +274,7 @@ static int sdo_runtime_suspend(struct device *dev)
> dev_info(dev, "suspend\n");
> regulator_disable(sdev->vdet);
> regulator_disable(sdev->vdac);
> - clk_disable(sdev->sclk_dac);
> + clk_disable_unprepare(sdev->sclk_dac);
> return 0;
> }
>
> @@ -286,7 +286,7 @@ static int sdo_runtime_resume(struct device *dev)
>
> dev_info(dev, "resume\n");
>
> - ret = clk_enable(sdev->sclk_dac);
> + ret = clk_prepare_enable(sdev->sclk_dac);
> if (ret < 0)
> return ret;
>
> @@ -319,7 +319,7 @@ static int sdo_runtime_resume(struct device *dev)
> vdac_r_dis:
> regulator_disable(sdev->vdac);
> dac_clk_dis:
> - clk_disable(sdev->sclk_dac);
> + clk_disable_unprepare(sdev->sclk_dac);
> return ret;
> }
>
> @@ -333,7 +333,7 @@ static int sdo_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct sdo_device *sdev;
> struct resource *res;
> - int ret = 0;
> + int ret;

Hmm, this change doesn't look like belonging to this patch.

> struct clk *sclk_vpll;
>
> dev_info(dev, "probe start\n");
> @@ -425,8 +425,13 @@ static int sdo_probe(struct platform_device *pdev)
> }
>
> /* enable gate for dac clock, because mixer uses it */
> - clk_enable(sdev->dac);
> -
> + ret = clk_prepare_enable(sdev->dac);
> + if (ret < 0) {
> + dev_err(dev,
> + "clk_prepare_enable_enable(dac) failed !\n");
> + ret = PTR_ERR(sdev->dac);

Hmm, ret already contains the error value returned by clk_prepare_enable()
here, so this looks like a copy paste error.

Best regards,
Tomasz

> + goto fail_fout_vpll;
> + }
> /* configure power management */
> pm_runtime_enable(dev);
>
> @@ -464,7 +469,7 @@ static int sdo_remove(struct platform_device *pdev)
> struct sdo_device *sdev = sd_to_sdev(sd);
>
> pm_runtime_disable(&pdev->dev);
> - clk_disable(sdev->dac);
> + clk_disable_unprepare(sdev->dac);
> clk_put(sdev->fout_vpll);
> clk_put(sdev->dacphy);
> clk_put(sdev->dac);

2013-08-29 13:17:32

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH v3 4/6] media: s5p-tv: Fix mixer driver to work with CCF

On Wednesday 28 of August 2013 18:13:02 Mateusz Krawczuk wrote:
> Replace clk_enable by clock_enable_prepare and clk_disable with
> clk_disable_unprepare. Clock prepare is required by Clock Common
> Framework, and old clock driver didn`t support it. Without it Common
> Clock Framework prints a warning.
>
> Signed-off-by: Mateusz Krawczuk <[email protected]>
> ---
> drivers/media/platform/s5p-tv/mixer_drv.c | 35
> ++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7
> deletions(-)
>
> diff --git a/drivers/media/platform/s5p-tv/mixer_drv.c
> b/drivers/media/platform/s5p-tv/mixer_drv.c index 8ce7c3e..3b2b305
> 100644
> --- a/drivers/media/platform/s5p-tv/mixer_drv.c
> +++ b/drivers/media/platform/s5p-tv/mixer_drv.c
> @@ -347,19 +347,40 @@ static int mxr_runtime_resume(struct device *dev)
> {
> struct mxr_device *mdev = to_mdev(dev);
> struct mxr_resources *res = &mdev->res;
> + int ret;
>
> dev_dbg(mdev->dev, "resume - start\n");
> mutex_lock(&mdev->mutex);
> /* turn clocks on */
> - clk_enable(res->mixer);
> - clk_enable(res->vp);
> - clk_enable(res->sclk_mixer);
> + ret = clk_prepare_enable(res->mixer);
> + if (ret < 0) {
> + dev_err(mdev->dev, "clk_prepare_enable(mixer) failed\n");
> + goto fail;
> + }
> + ret = clk_prepare_enable(res->vp);
> + if (ret < 0) {
> + dev_err(mdev->dev, "clk_prepare_enable(vp) failed\n");
> + goto fail_mixer;
> + }
> + ret = clk_prepare_enable(res->sclk_mixer);
> + if (ret < 0) {
> + dev_err(mdev->dev, "clk_prepare_enable(sclk_mixer) failed\n");
> + goto fail_vp;
> + }
> /* apply default configuration */
> mxr_reg_reset(mdev);
> - dev_dbg(mdev->dev, "resume - finished\n");
>
> mutex_unlock(&mdev->mutex);
> + dev_dbg(mdev->dev, "resume - finished\n");

Why is this line moved in this patch?

> return 0;

nit: A blank line would look good here.

> +fail_vp:
> + clk_disable_unprepare(res->vp);
> +fail_mixer:
> + clk_disable_unprepare(res->mixer);
> +fail:
> + mutex_unlock(&mdev->mutex);
> + dev_info(mdev->dev, "resume failed\n");

dev_err?

Best regards,
Tomasz

> + return ret;
> }
>
> static int mxr_runtime_suspend(struct device *dev)
> @@ -369,9 +390,9 @@ static int mxr_runtime_suspend(struct device *dev)
> dev_dbg(mdev->dev, "suspend - start\n");
> mutex_lock(&mdev->mutex);
> /* turn clocks off */
> - clk_disable(res->sclk_mixer);
> - clk_disable(res->vp);
> - clk_disable(res->mixer);
> + clk_disable_unprepare(res->sclk_mixer);
> + clk_disable_unprepare(res->vp);
> + clk_disable_unprepare(res->mixer);
> mutex_unlock(&mdev->mutex);
> dev_dbg(mdev->dev, "suspend - finished\n");
> return 0;

2013-08-29 14:40:04

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH v3 5/6] clk: samsung: Add clock driver for s5pc110/s5pv210

Hi Mateusz,

On Wednesday 28 of August 2013 18:13:03 Mateusz Krawczuk wrote:
> This patch adds new, Common Clock Framework-based clock driver for
> Samsung S5PV210 SoCs. The driver is just added, without enabling it yet.
>
> Signed-off-by: Mateusz Krawczuk <[email protected]>
> ---
> .../bindings/clock/samsung,s5pv210-clock.txt | 72 ++
> drivers/clk/samsung/Makefile | 3 +
> drivers/clk/samsung/clk-s5pv210.c | 732
> +++++++++++++++++++++ include/dt-bindings/clock/samsung,s5pv210-clock.h
> | 221 +++++++ 4 files changed, 1028 insertions(+)
> create mode 100644
> Documentation/devicetree/bindings/clock/samsung,s5pv210-clock.txt create
> mode 100644 drivers/clk/samsung/clk-s5pv210.c
> create mode 100644 include/dt-bindings/clock/samsung,s5pv210-clock.h
>
> diff --git
> a/Documentation/devicetree/bindings/clock/samsung,s5pv210-clock.txt
> b/Documentation/devicetree/bindings/clock/samsung,s5pv210-clock.txt new
> file mode 100644
> index 0000000..753c8f9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/clock/samsung,s5pv210-clock.txt
> @@ -0,0 +1,72 @@
> +* Samsung S5PC110/S5PV210 Clock Controller
> +
> +The S5PV210 clock controller generates and supplies clock to various
> controllers +within the SoC. The clock binding described here is
> applicable to all SoCs in +the S5PC110/S5PV210 family.
> +
> +Required Properties:
> +
> +- compatible: should be one of the following.
> + - "samsung,s5pv210-clock" - controller compatible with S5PC110/S5PV210
> SoC. +
> +- reg: physical base address of the controller and length of memory
> mapped + region.
> +
> +- #clock-cells: should be 1.
> +
> +Each clock is assigned an identifier and client nodes can use this
> identifier +to specify the clock which they consume. Some of the clocks
> are available only +on a particular S5PC110/S5PV210 SoC and this is
> specified where applicable. +
> +All available clocks are defined as preprocessor macros in
> +dt-bindings/clock/samsung,s5pv210-clock.h header and can be used in
> device +tree sources.
> +
> +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:
> + - "xxti" - xtal - required
> + - "xusbxti" - USB xtal - required,

Hmm, I'm not sure if all the boards must always provide both of them.
Actually it looks like the correct statement here would be "At least one of
the above clocks should be specified.".

> +
> +
> +Example: Clock controller node:
> +
> + clock: clock-controller@7e00f000 {
> + compatible = "samsung,s5pv210-clock";
> + reg = <0x7e00f000 0x1000>;
> + #clock-cells = <1>;
> + };
> +
> +Example: Required external clocks:
> +
> + fin_pll: clock-xxti {
> + compatible = "fixed-clock";
> + clock-output-names = "xxti";
> + clock-frequency = <12000000>;
> + #clock-cells = <0>;
> + };
> +
> + xusbxti: clock-xusbxti {
> + compatible = "fixed-clock";
> + clock-output-names = "xusbxti";
> + clock-frequency = <48000000>;
> + #clock-cells = <0>;
> + };
> +
> +Example: UART controller node that consumes the clock generated by the
> clock + controller (refer to the standard clock bindings for
> information about + "clocks" and "clock-names" properties):
> +
> + uart0: serial@7f005000 {
> + compatible = "samsung,s5pv210-uart";
> + reg = <0x7f005000 0x100>;
> + interrupt-parent = <&vic1>;
> + interrupts = <5>;
> + clock-names = "uart", "clk_uart_baud2",
> + "clk_uart_baud3";
> + clocks = <&clock PCLK_UART0>, <&clocks PCLK_UART0>,
> + <&clock SCLK_UART>;
> + status = "disabled";
> + };
> \ No newline at end of file
> diff --git a/drivers/clk/samsung/Makefile b/drivers/clk/samsung/Makefile
> index 8eb4799..e08c45e 100644
> --- a/drivers/clk/samsung/Makefile
> +++ b/drivers/clk/samsung/Makefile
> @@ -9,3 +9,6 @@ obj-$(CONFIG_SOC_EXYNOS5420) += clk-exynos5420.o
> obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o
> obj-$(CONFIG_ARCH_EXYNOS) += clk-exynos-audss.o
> obj-$(CONFIG_ARCH_S3C64XX) += clk-s3c64xx.o
> +ifeq ($(CONFIG_COMMON_CLK), y)
> +obj-$(CONFIG_ARCH_S5PV210) += clk-s5pv210.o
> +endif
> \ No newline at end of file
> diff --git a/drivers/clk/samsung/clk-s5pv210.c
> b/drivers/clk/samsung/clk-s5pv210.c new file mode 100644
> index 0000000..1c5ea5c
> --- /dev/null
> +++ b/drivers/clk/samsung/clk-s5pv210.c
> @@ -0,0 +1,732 @@
> +/*
> + * Copyright (c) 2013 Samsung Electronics Co., Ltd.
> + * Author: Mateusz Krawczuk <[email protected]>
> + *
> + * 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.
> + *
> + * Common Clock Framework support for all S5PC110/S5PV210 SoCs.
> +*/
> +
> +#include <linux/clk.h>
> +#include <linux/clkdev.h>
> +#include <linux/clk-provider.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <mach/regs-clock.h>

NAK.

Please don't use headers from mach/ or plat/ directories in drivers, as
this will break future enablement of multiplatform support for S5PV210.

> +
> +#include "clk.h"
> +#include "clk-pll.h"
> +
> +#include <dt-bindings/clock/samsung,s5pv210-clock.h>
> +
> +/* S5PC110/S5PV210 clock controller register offsets */
> +#define APLL_LOCK 0x0000
> +#define MPLL_LOCK 0x0008
> +#define EPLL_LOCK 0x0010
> +#define VPLL_LOCK 0x0020
> +#define APLL_CON0 0x0100
> +#define APLL_CON1 0x0104
> +#define MPLL_CON 0x0108
> +#define EPLL_CON0 0x0110
> +#define EPLL_CON1 0x0114
> +#define VPLL_CON0 0x0120
> +#define CLK_SRC0 0x0200
> +#define CLK_SRC1 0x0204
> +#define CLK_SRC2 0x0208
> +#define CLK_SRC3 0x020c
> +#define CLK_SRC4 0x0210
> +#define CLK_SRC5 0x0214
> +#define CLK_SRC6 0x0218
> +#define CLK_SRC_MASK0 0x0280
> +#define CLK_SRC_MASK1 0x0284
> +#define CLK_DIV0 0x0300
> +#define CLK_DIV1 0x0304
> +#define CLK_DIV2 0x0308
> +#define CLK_DIV3 0x030c
> +#define CLK_DIV4 0x0310
> +#define CLK_DIV5 0x0314
> +#define CLK_DIV6 0x0318
> +#define CLK_DIV7 0x031c
> +#define CLK_GATE_SCLK 0x0444
> +#define CLK_GATE_IP0 0x0460
> +#define CLK_GATE_IP1 0x0464
> +#define CLK_GATE_IP2 0x0468
> +#define CLK_GATE_IP3 0x046c
> +#define CLK_GATE_IP4 0x0470
> +#define CLK_GATE_BLOCK 0x0480
> +#define CLK_GATE_IP5 0x0484
> +#define DAC_CONTROL 0xe810
> +
> +/* Helper macros to define clock arrays. */
> +#define FIXED_RATE_CLOCKS(name) \
> + static struct samsung_fixed_rate_clock name[]
> +#define MUX_CLOCKS(name) \
> + static struct samsung_mux_clock name[]
> +#define DIV_CLOCKS(name) \
> + static struct samsung_div_clock name[]
> +#define GATE_CLOCKS(name) \
> + static struct samsung_gate_clock name[]
> +
> +/* Helper macros for gate types present on S5PC110/S5PV210. */
> +#define GATE_BUS(_id, cname, pname, o, b) \
> + GATE(_id, cname, pname, o, b, 0, 0)
> +#define GATE_SCLK(_id, cname, pname, o, b) \
> + GATE(_id, cname, pname, o, b, CLK_SET_RATE_PARENT, 0)
> +#define GATE_ON(_id, cname, pname, o, b) \
> + GATE(_id, cname, pname, o, b, CLK_IGNORE_UNUSED, 0)

These three macros above does not seem to be used anywhere in this driver.
You can either remove them or change the driver to use them, as I can see
several places they would be appropriate. See below.

> +enum s5pv210_plls {
> + apll, mpll, epll, vpll,
> +};
> +
> +static unsigned long s5pv210_clk_regs[] __initdata = {
> + CLK_SRC0,
> + CLK_SRC1,
> + CLK_SRC2,
> + CLK_SRC3,
> + CLK_SRC4,
> + CLK_SRC5,
> + CLK_SRC6,
> + CLK_DIV0,
> + CLK_DIV1,
> + CLK_DIV2,
> + CLK_DIV3,
> + CLK_DIV4,
> + CLK_DIV5,
> + CLK_DIV6,
> + CLK_DIV7,
> + CLK_GATE_SCLK,
> + CLK_GATE_IP0,
> + CLK_GATE_IP1,
> + CLK_GATE_IP2,
> + CLK_GATE_IP3,
> + CLK_GATE_IP4,
> + CLK_GATE_IP5,
> + CLK_SRC_MASK0,
> + CLK_SRC_MASK1,
> + APLL_CON0,
> + MPLL_CON,
> + EPLL_CON0,
> + VPLL_CON0,
> + APLL_LOCK,
> + MPLL_LOCK,
> + EPLL_LOCK,
> + VPLL_LOCK,
> +};
> +
> +/* List of parent clocks common for all S5PC110 SoCs. */
> +PNAME(mout_apll_p) = {
> + "fin_pll",
> + "fout_apll"
> +};
> +
> +PNAME(mout_mpll_p) = {
> + "fin_pll",
> + "fout_mpll"
> +};
> +
> +PNAME(mout_epll_p) = {
> + "fin_pll",
> + "fout_epll"
> +};
> +
> +PNAME(mout_vpllsrc_p) = {
> + "fin_pll",
> + "sclk_hdmi27m"
> +};
> +
> +PNAME(mout_vpll_p) = {
> + "fin_pll",
> + "fout_vpll"
> +};
> +
> +PNAME(mout_group1_p) = {
> + "dout_a2m",
> + "mout_mpll",
> + "mout_epll",
> + "mout_vpll"
> +};
> +
> +PNAME(mout_group2_p) = {
> + "xxti",
> + "xusbxti",
> + "sclk_hdmi27m",
> + "sclk_usbphy0",
> + "sclk_usbphy1",
> + "sclk_hdmiphy",
> + "mout_mpll",
> + "mout_epll",
> + "mout_vpll",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none"
> +};
> +
> +PNAME(mout_audio0_p) = {
> + "xxti",
> + "pcmcdclk0",
> + "sclk_hdmi27m",
> + "sclk_usbphy0",
> + "sclk_usbphy1",
> + "sclk_hdmiphy",
> + "mout_mpll",
> + "mout_epll",
> + "mout_vpll",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none"
> +};
> +
> +PNAME(mout_audio1_p) = {
> + "i2scdclk1",
> + "pcmcdclk1",
> + "sclk_hdmi27m",
> + "sclk_usbphy0",
> + "sclk_usbphy1",
> + "sclk_hdmiphy",
> + "mout_mpll",
> + "mout_epll",
> + "mout_vpll",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none"
> +};
> +
> +PNAME(mout_audio2_p) = {
> + "i2scdclk2",
> + "pcmcdclk2",
> + "sclk_hdmi27m",
> + "sclk_usbphy0",
> + "sclk_usbphy1",
> + "sclk_hdmiphy",
> + "mout_mpll",
> + "mout_epll",
> + "mout_vpll",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none",
> + "none"
> +};
> +
> +PNAME(mout_spdif_p) = {
> + "dout_audio0",
> + "dout_audio1",
> + "dout_audio3",
> + "none"
> +};
> +
> +PNAME(mout_group3_p) = {
> + "mout_apll",
> + "mout_mpll"
> +};
> +PNAME(mout_group4_p) = {
> + "mout_mpll",
> + "dout_a2m"
> +};
> +
> +PNAME(mout_flash_p) = {
> + "dout_hclkd",
> + "dout_hclkp"
> +};
> +
> +PNAME(mout_dac_p) = {
> + "mout_vpll",
> + "sclk_hdmiphy"
> +};
> +
> +PNAME(mout_hdmi_p) = {
> + "sclk_hdmiphy",
> + "dout_tblk"
> +
> +};
> +
> +PNAME(mout_mixer_p) = {
> + "mout_dac",
> + "mout_hdmi"
> +};
> +
> +/* register S5PC110/S5PV210 clocks */
> +MUX_CLOCKS(s5pv210_mux_clks) __initdata = {
> + MUX(MOUT_FLASH, "mout_flash", mout_flash_p, CLK_SRC0, 28, 1),
> + MUX(MOUT_PSYS, "mout_psys", mout_group4_p, CLK_SRC0, 24, 1),
> + MUX(MOUT_DSYS, "mout_dsys", mout_group4_p, CLK_SRC0, 20, 1),
> + MUX(MOUT_MSYS, "mout_msys", mout_group3_p, CLK_SRC0, 16, 1),
> + MUX(MOUT_VPLL, "mout_vpll", mout_vpll_p, CLK_SRC0, 12, 1),
> + MUX(MOUT_EPLL, "mout_epll", mout_epll_p, CLK_SRC0, 8, 1),
> + MUX(MOUT_MPLL, "mout_mpll", mout_mpll_p, CLK_SRC0, 4, 1),
> + MUX(MOUT_APLL, "mout_apll", mout_apll_p, CLK_SRC0, 0, 1),
> +
> + MUX(MOUT_VPLLSRC, "mout_vpllsrc", mout_vpllsrc_p, CLK_SRC1, 28, 1),
> + MUX(MOUT_CSIS, "mout_csis", mout_group2_p, CLK_SRC1, 24, 4),
> + MUX(MOUT_FIMD, "mout_fimd", mout_group2_p, CLK_SRC1, 20, 4),
> + MUX(MOUT_CAM1, "mout_cam1", mout_group2_p, CLK_SRC1, 16, 4),
> + MUX(MOUT_CAM0, "mout_cam0", mout_group2_p, CLK_SRC1, 12, 4),
> + MUX(MOUT_DAC, "mout_dac", mout_dac_p, CLK_SRC1, 8, 1),
> + MUX(MOUT_MIXER, "mout_mixer", mout_mixer_p, CLK_SRC1, 4, 1),
> +
> + MUX(MOUT_HDMI, "mout_hdmi", mout_hdmi_p, CLK_SRC1, 0, 1),
> + MUX(MOUT_G2D, "mout_g2d", mout_group1_p, CLK_SRC2, 8, 2),
> + MUX(MOUT_MFC, "mout_mfc", mout_group1_p, CLK_SRC2, 4, 2),
> + MUX(MOUT_G3D, "mout_g3d", mout_group1_p, CLK_SRC2, 0, 2),
> +
> + MUX(MOUT_FIMC2, "mout_fimc2", mout_group2_p, CLK_SRC3, 20, 4),
> + MUX(MOUT_FIMC1, "mout_fimc1", mout_group2_p, CLK_SRC3, 16, 4),
> + MUX(MOUT_FIMC0, "mout_fimc0", mout_group2_p, CLK_SRC3, 12, 4),
> +
> + MUX(MOUT_UART3, "mout_uart3", mout_group2_p, CLK_SRC4, 28, 4),
> + MUX(MOUT_UART2, "mout_uart2", mout_group2_p, CLK_SRC4, 24, 4),
> + MUX(MOUT_UART1, "mout_uart1", mout_group2_p, CLK_SRC4, 20, 4),
> + MUX(MOUT_UART0, "mout_uart0", mout_group2_p, CLK_SRC4, 16, 4),
> + MUX(MOUT_MMC3, "mout_mmc3", mout_group2_p, CLK_SRC4, 12, 4),
> + MUX(MOUT_MMC2, "mout_mmc2", mout_group2_p, CLK_SRC4, 8, 4),
> + MUX(MOUT_MMC1, "mout_mmc1", mout_group2_p, CLK_SRC4, 4, 4),
> + MUX(MOUT_MMC0, "mout_mmc0", mout_group2_p, CLK_SRC4, 0, 4),
> +
> + MUX(MOUT_PWM, "mout_pwm", mout_group2_p, CLK_SRC5, 12, 4),
> + MUX(MOUT_SPI1, "mout_spi1", mout_group2_p, CLK_SRC5, 4, 4),
> + MUX(MOUT_SPI0, "mout_spi0", mout_group2_p, CLK_SRC5, 0, 4),
> +
> + MUX(MOUT_DMC0, "mout_dmc0", mout_group1_p, CLK_SRC6, 24, 2),
> + MUX(MOUT_PWI, "mout_pwi", mout_group2_p, CLK_SRC6, 20, 4),
> + MUX(MOUT_HPM, "mout_hpm", mout_group3_p, CLK_SRC6, 16, 1),
> + MUX(MOUT_SPDIF, "mout_spdif", mout_spdif_p, CLK_SRC6, 12, 2),
> + MUX(MOUT_AUDIO2, "mout_audio2", mout_audio2_p, CLK_SRC6, 8, 4),
> + MUX(MOUT_AUDIO1, "mout_audio1", mout_audio1_p, CLK_SRC6, 4, 4),
> + MUX(MOUT_AUDIO0, "mout_audio0", mout_audio0_p, CLK_SRC6, 0, 4)
> +};
> +
> +/* Fixed rate clocks generated outside the soc */
> +FIXED_RATE_CLOCKS(s5pv210_fixed_rate_ext_clks) __initdata = {
> + FRATE(0, "xxti", NULL, CLK_IS_ROOT, 0),
> + FRATE(0, "xusbxti", NULL, CLK_IS_ROOT, 0),
> +};
> +
> +/* Fixed rate clocks generated inside the soc */
> +FIXED_RATE_CLOCKS(s5pv210_fixed_rate_clks) __initdata = {
> + FRATE(0, "sclk_hdmi27m", NULL, CLK_IS_ROOT, 27000000),
> + FRATE(0, "sclk_hdmiphy", NULL, CLK_IS_ROOT, 27000000),
> + FRATE(0, "sclk_usbphy0", NULL, CLK_IS_ROOT, 48000000),
> + FRATE(0, "sclk_usbphy1", NULL, CLK_IS_ROOT, 48000000),

I think the four fixed rate clocks above should be assigned IDs too, to
allow referencing them from device tree. The external fixed rate clocks are
an exception to this, because they are specified in device tree using
separate nodes.

> +};
> +
> +/* list of divider clocks supported in all S5PC110/S5PV210 soc's */
> +DIV_CLOCKS(s5pv210_div_clks) __initdata = {
> + DIV(DOUT_PCLKP, "dout_pclkp", "dout_hclkp", CLK_DIV0, 28, 3),
> + DIV(DOUT_HCLKP, "dout_hclkp", "mout_psys", CLK_DIV0, 24, 4),
> + DIV(DOUT_PCLKD, "dout_pclkd", "dout_hclkd", CLK_DIV0, 20, 3),
> + DIV(DOUT_HCLKD, "dout_hclkd", "mout_dsys", CLK_DIV0, 16, 4),
> + DIV(DOUT_PCLKM, "dout_pclkm", "dout_hclkm", CLK_DIV0, 12, 3),
> + DIV(DOUT_HCLKM, "dout_hclkm", "dout_apll", CLK_DIV0, 8, 3),
> + DIV(DOUT_A2M, "dout_a2m", "mout_apll", CLK_DIV0, 4, 3),
> + DIV(DOUT_APLL, "dout_apll", "mout_msys", CLK_DIV0, 0, 3),
> +
> + DIV(DOUT_CSIS, "dout_csis", "mout_csis", CLK_DIV1, 28, 4),
> + DIV(DOUT_FIMD, "dout_fimd", "mout_fimd", CLK_DIV1, 20, 4),
> + DIV(DOUT_CAM1, "dout_cam1", "mout_cam1", CLK_DIV1, 16, 4),
> + DIV(DOUT_CAM0, "dout_cam0", "mout_cam0", CLK_DIV1, 12, 4),
> + DIV(DOUT_TBLK, "dout_tblk", "mout_vpll", CLK_DIV1, 0, 4),
> +
> + DIV(DOUT_G2D, "dout_g2d", "mout_g2d", CLK_DIV2, 8, 4),
> + DIV(DOUT_MFC, "dout_mfc", "mout_mfc", CLK_DIV2, 4, 4),
> + DIV(DOUT_G3D, "dout_g3d", "mout_g3d", CLK_DIV2, 0, 4),
> +
> + DIV(DOUT_FIMC2, "dout_fimc2", "mout_fimc2", CLK_DIV3, 20, 4),
> + DIV(DOUT_FIMC1, "dout_fimc1", "mout_fimc1", CLK_DIV3, 16, 4),
> + DIV(DOUT_FIMC0, "dout_fimc0", "mout_fimc0", CLK_DIV3, 12, 4),
> +
> + DIV(DOUT_UART3, "dout_uart3", "mout_uart3", CLK_DIV4, 28, 4),
> + DIV(DOUT_UART2, "dout_uart2", "mout_uart2", CLK_DIV4, 24, 4),
> + DIV(DOUT_UART1, "dout_uart1", "mout_uart1", CLK_DIV4, 20, 4),
> + DIV(DOUT_UART0, "dout_uart0", "mout_uart0", CLK_DIV4, 16, 4),
> +
> + DIV(DOUT_MMC3, "dout_mmc3", "mout_mmc3", CLK_DIV4, 12, 4),
> + DIV(DOUT_MMC2, "dout_mmc2", "mout_mmc2", CLK_DIV4, 8, 4),
> + DIV(DOUT_MMC1, "dout_mmc1", "mout_mmc1", CLK_DIV4, 4, 4),
> + DIV(DOUT_MMC0, "dout_mmc0", "mout_mmc0", CLK_DIV4, 0, 4),
> +
> + DIV(DOUT_PWM, "dout_pwm", "mout_pwm", CLK_DIV5, 12, 4),
> + DIV(DOUT_SPI1, "dout_spi1", "mout_spi1", CLK_DIV5, 4, 4),
> + DIV(DOUT_SPI0, "dout_spi0", "mout_spi0", CLK_DIV5, 0, 4),
> +
> + DIV(DOUT_DMC0, "dout_dmc0", "mout_dmc0", CLK_DIV6, 28, 4),
> + DIV(DOUT_PWI, "dout_pwi", "mout_pwi", CLK_DIV6, 24, 4),
> + DIV(DOUT_HPM, "dout_hpm", "dout_copy", CLK_DIV6, 20, 3),
> + DIV(DOUT_COPY, "dout_copy", "mout_hpm", CLK_DIV6, 16, 3),
> + DIV(DOUT_FLASH, "dout_flash", "mout_flash", CLK_DIV6, 12, 3),
> + DIV(DOUT_AUDIO2, "dout_audio2", "mout_audio2", CLK_DIV6, 8, 4),
> + DIV(DOUT_AUDIO1, "dout_audio1", "mout_audio1", CLK_DIV6, 4, 4),
> + DIV(DOUT_AUDIO0, "dout_audio0", "mout_audio0", CLK_DIV6, 0, 4),
> +
> + DIV(DOUT_DPM, "dout_dpm", "dout_pclkp", CLK_DIV7, 8, 7),
> + DIV(DOUT_DVSEM, "dout_dvsem", "dout_pclkp", CLK_DIV7, 0, 7),
> +};
> +
> +/* list of gate clocks supported in all S5PC110/S5PV210 soc's */
> +struct samsung_gate_clock s5pv210_gate_clks[] __initdata = {
> +

nit: Stray blank line.

> + GATE(CSIS, "clk_csis", "dout_hclkd", CLK_GATE_IP0, 31, 0, 0),
> + GATE(ROTATOR, "rotator", "dout_hclkd", CLK_GATE_IP0, 29, 0, 0),
> +
> + GATE(MFC, "mfc", "dout_hclkm", CLK_GATE_IP0, 16, 0, 0),
> + GATE(G2D, "g2d", "dout_hclkd", CLK_GATE_IP0, 12, 0, 0),
> + GATE(G3D, "g3d", "dout_hclkm",
> + CLK_GATE_IP0, 8, CLK_SET_RATE_PARENT, 0),

This CLK_SET_RATE_PARENT flag doesn't look correctly. Why should it be able
to set rate of dout_hclkm, which is shared by multiple peripherals?

> + GATE(IMEM, "imem", "dout_hclkm", CLK_GATE_IP0, 5, 0, 0),
> + GATE(PDMA1, "pdma1", "dout_hclkp", CLK_GATE_IP0, 4, 0, 0),
> + GATE(PDMA0, "pdma0", "dout_hclkp", CLK_GATE_IP0, 3, 0, 0),
> + GATE(MDMA, "mdma", "dout_hclkd", CLK_GATE_IP0, 2, 0, 0),
> +
> + GATE(NFCON, "nfcon", "dout_hclkp", CLK_GATE_IP1, 28, 0, 0),
> + GATE(SROMC, "sromc", "dout_hclkp", CLK_GATE_IP1, 26, 0, 0),
> + GATE(CFCON, "cfcon", "dout_hclkp", CLK_GATE_IP1, 25, 0, 0),
> + GATE(NANDXL, "nandxl", "dout_hclkp", CLK_GATE_IP1, 24, 0, 0),
> + GATE(USB_HOST, "usb_host", "dout_hclkp", CLK_GATE_IP1, 17, 0, 0),
> + GATE(USB_OTG, "usb_otg", "dout_hclkp", CLK_GATE_IP1, 16, 0, 0),
> + GATE(HDMI, "hdmi", "dout_hclkd", CLK_GATE_IP1, 11, 0, 0),
> + GATE(TVENC, "tvenc", "dout_hclkd", CLK_GATE_IP1, 10, 0, 0),
> + GATE(MIXER, "mixer", "dout_hclkd", CLK_GATE_IP1, 9, 0, 0),
> + GATE(VP, "vp", "dout_hclkd", CLK_GATE_IP1, 8, 0, 0),
> + GATE(DSIM, "dsim", "dout_pclkd", CLK_GATE_IP1, 2, 0, 0),
> + GATE(FIMD, "fimd", "dout_hclkd", CLK_GATE_IP1, 0, 0, 0),
> +
> + GATE(TZIC3, "tzic3", "dout_hclkm", CLK_GATE_IP2, 31, 0, 0),
> + GATE(TZIC2, "tzic2", "dout_hclkm", CLK_GATE_IP2, 30, 0, 0),
> + GATE(TZIC1, "tzic1", "dout_hclkm", CLK_GATE_IP2, 29, 0, 0),
> + GATE(TZIC0, "tzic0", "dout_hclkm", CLK_GATE_IP2, 28, 0, 0),
> + GATE(TSI, "tsi", "dout_hclkd", CLK_GATE_IP2, 20, 0, 0),
> + GATE(HSMMC3, "hsmmc3", "dout_hclkp", CLK_GATE_IP2, 19, 0, 0),
> + GATE(HSMMC2, "hsmmc2", "dout_hclkp", CLK_GATE_IP2, 18, 0, 0),
> + GATE(HSMMC1, "hsmmc1", "dout_hclkp", CLK_GATE_IP2, 17, 0, 0),
> + GATE(HSMMC0, "hsmmc0", "dout_hclkp", CLK_GATE_IP2, 16, 0, 0),
> + GATE(JTAG, "jtag", "dout_hclkp", CLK_GATE_IP2, 11, 0, 0),
> + GATE(MODEMIF, "modemif", "dout_hclkp", CLK_GATE_IP2, 9, 0, 0),
> + GATE(CORESIGHT, "coresight", "dout_pclkp", CLK_GATE_IP2, 8, 0, 0),
> + GATE(SDM, "sdm", "dout_pclkm", CLK_GATE_IP2, 1, 0, 0),
> + GATE(SECSS, "secss", "dout_hclkp", CLK_GATE_IP2, 0, 0, 0),
> +
> + GATE(PCM2, "pcm2", "dout_pclkp", CLK_GATE_IP3, 30, 0, 0),
> + GATE(PCM1, "pcm1", "dout_pclkp", CLK_GATE_IP3, 29, 0, 0),
> + GATE(PCM0, "pcm0", "dout_pclkp", CLK_GATE_IP3, 28, 0, 0),
> + GATE(TSADC, "tsadc", "dout_pclkp", CLK_GATE_IP3, 24, 0, 0),
> + GATE(PWM, "pwm", "dout_pclkp", CLK_GATE_IP3, 23, 0, 0),
> + GATE(WDT, "watchdog", "dout_pclkp", CLK_GATE_IP3, 22, 0, 0),
> + GATE(KEYIF, "keyif", "dout_pclkp", CLK_GATE_IP3, 21, 0, 0),
> + GATE(UART3, "uart3", "dout_pclkp", CLK_GATE_IP3, 20, 0, 0),
> + GATE(UART2, "uart2", "dout_pclkp", CLK_GATE_IP3, 19, 0, 0),
> + GATE(UART1, "uart1", "dout_pclkp", CLK_GATE_IP3, 18, 0, 0),
> + GATE(UART0, "uart0", "dout_pclkp", CLK_GATE_IP3, 17, 0, 0),
> + GATE(SYSTIMER, "systimer", "dout_pclkp", CLK_GATE_IP3, 16, 0, 0),
> + GATE(RTC, "rtc", "dout_pclkp", CLK_GATE_IP3, 15, 0, 0),
> + GATE(SPI1, "spi1", "dout_pclkp", CLK_GATE_IP3, 13, 0, 0),
> + GATE(SPI0, "spi0", "dout_pclkp", CLK_GATE_IP3, 12, 0, 0),
> + GATE(I2C_HDMI_PHY, "i2c_hdmi_phy", "dout_pclkd",
> + CLK_GATE_IP3, 11, 0, 0),
> + GATE(I2C_HDMI_CEC, "i2c_hdmi_cec", "dout_pclkd",
> + CLK_GATE_IP3, 10, 0, 0),
> + GATE(I2C2, "i2c2", "dout_pclkp", CLK_GATE_IP3, 9, 0, 0),
> + GATE(I2C0, "i2c0", "dout_pclkp", CLK_GATE_IP3, 7, 0, 0),
> + GATE(I2S1, "i2s1", "dout_pclkp", CLK_GATE_IP3, 6, 0, 0),
> + GATE(I2S2, "i2s2", "dout_pclkp", CLK_GATE_IP3, 5, 0, 0),
> + GATE(I2S0, "i2s0", "dout_pclkp", CLK_GATE_IP3, 4, 0, 0),
> + GATE(AC97, "ac97", "dout_pclkp", CLK_GATE_IP3, 1, 0, 0),
> + GATE(SPDIF, "spdif", "dout_pclkp", CLK_GATE_IP3, 0, 0, 0),
> +
> + GATE(TZPC3, "tzpc.3", "dout_pclkd", CLK_GATE_IP4, 8, 0, 0),
> + GATE(TZPC2, "tzpc.2", "dout_pclkd", CLK_GATE_IP4, 7, 0, 0),
> + GATE(TZPC1, "tzpc.1", "dout_pclkp", CLK_GATE_IP4, 6, 0, 0),
> + GATE(TZPC0, "tzpc.0", "dout_pclkm", CLK_GATE_IP4, 5, 0, 0),
> + GATE(SECKEY, "seckey", "dout_pclkp", CLK_GATE_IP4, 3, 0, 0),
> + GATE(IEM_APC, "iem_apc", "dout_pclkp", CLK_GATE_IP4, 2, 0, 0),
> + GATE(IEM_IEC, "iem_iec", "dout_pclkp", CLK_GATE_IP4, 1, 0, 0),
> + GATE(CHIPID, "chipid", "dout_pclkp", CLK_GATE_IP4, 0, 0, 0),
> +
> + GATE(JPEG, "jpeg", "dout_hclkd", CLK_GATE_IP5, 29, 0, 0),
> +

You can use GATE_SCLK() macro for all the SCLK gates below.

> + GATE(SCLK_SPDIF, "sclk_spdif", "mout_spdif", CLK_SRC_MASK0, 27,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_AUDIO2, "sclk_audio2", "dout_audio2", CLK_SRC_MASK0, 26,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_AUDIO1, "sclk_audio1", "dout_audio1", CLK_SRC_MASK0, 25,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_AUDIO0, "sclk_audio0", "dout_audio0", CLK_SRC_MASK0, 24,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_PWM, "sclk_pwm", "dout_pwm", CLK_SRC_MASK0, 19,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_SPI1, "sclk_spi1", "dout_spi1", CLK_SRC_MASK0, 17,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_SPI0, "sclk_spi0", "dout_spi0", CLK_SRC_MASK0, 16,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_UART3, "sclk_uart3", "dout_uart3", CLK_SRC_MASK0, 15,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_UART2, "sclk_uart2", "dout_uart2", CLK_SRC_MASK0, 14,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_UART1, "sclk_uart1", "dout_uart1", CLK_SRC_MASK0, 13,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_UART0, "sclk_uart0", "dout_uart0", CLK_SRC_MASK0, 12,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_MMC3, "sclk_mmc3", "dout_mmc3", CLK_SRC_MASK0, 11,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_MMC2, "sclk_mmc2", "dout_mmc2", CLK_SRC_MASK0, 10,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_MMC1, "sclk_mmc1", "dout_mmc1", CLK_SRC_MASK0, 9,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_MMC0, "sclk_mmc0", "dout_mmc0", CLK_SRC_MASK0, 8,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_CSIS, "sclk_csis", "dout_csis", CLK_SRC_MASK0, 6,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_FIMD, "sclk_fimd", "dout_fimd", CLK_SRC_MASK0, 5,
> + CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
> + GATE(SCLK_CAM1, "sclk_cam1", "dout_cam1", CLK_SRC_MASK0, 4,
> + CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
> + GATE(SCLK_CAM0, "sclk_cam0", "dout_cam0", CLK_SRC_MASK0, 3,
> + CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),

This CLK_IGNORE_UNUSED in the three clocks above does not look correct to
me. It should be responsibility of the driver to claim the clock and
control it. CLK_IGNORE_UNUSED should be rather used as last resort, for
example if there is no driver yet, but the clock must be kept enabled.

> + GATE(SCLK_DAC, "sclk_dac", "mout_dac", CLK_SRC_MASK0, 2, 0, 0),
> + GATE(SCLK_MIXER, "sclk_mixer", "mout_mixer", CLK_SRC_MASK0, 1, 0, 0),
> + GATE(SCLK_HDMI, "sclk_hdmi", "mout_hdmi", CLK_SRC_MASK0, 0, 0, 0),
> +
> + GATE(SCLK_FIMC2, "sclk_fimc2", "dout_fimc2", CLK_SRC_MASK1, 4,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_FIMC1, "sclk_fimc1", "dout_fimc1", CLK_SRC_MASK1, 3,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(SCLK_FIMC0, "sclk_fimc0", "dout_fimc0", CLK_SRC_MASK1, 2,
> + CLK_SET_RATE_PARENT, 0),
> + GATE(FIMC2, "fimc2", "dout_hclkd", CLK_GATE_IP0, 26, 0, 0),
> + GATE(FIMC1, "fimc1", "dout_hclkd", CLK_GATE_IP0, 25, 0, 0),
> + GATE(FIMC0, "fimc0", "dout_hclkd", CLK_GATE_IP0, 24, 0, 0),
> +
> + /*HACK dacphy isn`t real clock*/
> + GATE(DACPHY, "dacphy", "dout_hclkd", DAC_CONTROL, 0, 0, 0),

You should be careful with this kind of hack, because the DACPHY index
introduced here, when first used in DT, would become an ABI, support for
which would have to be kept in future.

There are three possible ways to deal with this:
1) remove this and thus break DAC support (does any existing board file
use it?),
2) implement this hack only for board files, without assigning a clock
specifier index for this clock and thus making it unavailable for DT.
3) implement this properly,

While option 3 would be the best one, I understand that it would require a
significant amount of work, so other choices might better for now. Option
1, if there are board files that have working DAC, will introduce a
regression, so it isn't really good. I guess we could go with 2) for now.

> +};
> +
> +/* list of all parent clock list */
> +static struct samsung_clock_alias s5pv210_clock_aliases[] = {
> + ALIAS(FIMC0, "s5pv210-fimc.0", "fimc"),
> + ALIAS(FIMC1, "s5pv210-fimc.1", "fimc"),
> + ALIAS(FIMC2, "s5pv210-fimc.2", "fimc"),
> + ALIAS(MOUT_FIMC2, NULL, "mout_fimc2"),
> + ALIAS(MOUT_FIMC1, NULL, "mout_fimc1"),
> + ALIAS(MOUT_FIMC0, NULL, "mout_fimc0"),

These aliases should not have NULL here. I belive this is to allow looking
these clocks up from board files, but this can be done using clk_get_sys()
and passing appropriate device name to the function.

This would also make the X in mout_fimcX redundant, so the clocks could be
specified as follows:

ALIAS(MOUT_FIMC2, "s5pv210-fimc.0", "mout_fimc"),
ALIAS(MOUT_FIMC1, "s5pv210-fimc.1", "mout_fimc"),
ALIAS(MOUT_FIMC0, "s5pv210-fimc.2", "mout_fimc"),

> + ALIAS(SCLK_FIMC0, "s5pv210-fimc.0", "sclk_fimc"),
> + ALIAS(SCLK_FIMC1, "s5pv210-fimc.1", "sclk_fimc"),
> + ALIAS(SCLK_FIMC2, "s5pv210-fimc.2", "sclk_fimc"),
> +
> + ALIAS(MOUT_APLL, NULL, "mout_apll"),
> + ALIAS(MOUT_MPLL, NULL, "mout_mpll"),
> + ALIAS(MOUT_EPLL, NULL, "mout_epll"),
> + ALIAS(MOUT_VPLL, NULL, "mout_vpll"),

Hmm. This is a bit problematic. I believe the reason for exporting this is
exactly the same as for mout_fimcX. Am I right?

I believe there should be some way to do this kind of lookup from platform
code, without the need to add fake aliases for the clocks. Mike, do you
have any suggestsions?

> + ALIAS(UART0, "s5pv210-uart.0", "uart"),
> + ALIAS(UART1, "s5pv210-uart.1", "uart"),
> + ALIAS(UART2, "s5pv210-uart.2", "uart"),
> + ALIAS(UART3, "s5pv210-uart.3", "uart"),
> + ALIAS(UART0, "s5pv210-uart.0", "clk_uart_baud0"),
> + ALIAS(UART1, "s5pv210-uart.1", "clk_uart_baud0"),
> + ALIAS(UART2, "s5pv210-uart.2", "clk_uart_baud0"),
> + ALIAS(UART3, "s5pv210-uart.3", "clk_uart_baud0"),
> + ALIAS(SCLK_UART0, "s5pv210-uart.0", "clk_uart_baud1"),
> + ALIAS(SCLK_UART1, "s5pv210-uart.1", "clk_uart_baud1"),
> + ALIAS(SCLK_UART2, "s5pv210-uart.2", "clk_uart_baud1"),
> + ALIAS(SCLK_UART3, "s5pv210-uart.3", "clk_uart_baud1"),
> + ALIAS(HSMMC0, "s3c-sdhci.0", "hsmmc"),
> + ALIAS(HSMMC1, "s3c-sdhci.1", "hsmmc"),
> + ALIAS(HSMMC2, "s3c-sdhci.2", "hsmmc"),
> + ALIAS(HSMMC3, "s3c-sdhci.3", "hsmmc"),
> + ALIAS(HSMMC0, "s3c-sdhci.0", "mmc_busclk.0"),
> + ALIAS(HSMMC1, "s3c-sdhci.1", "mmc_busclk.0"),
> + ALIAS(HSMMC2, "s3c-sdhci.2", "mmc_busclk.0"),
> + ALIAS(HSMMC3, "s3c-sdhci.3", "mmc_busclk.0"),
> + ALIAS(SCLK_MMC0, "s3c-sdhci.0", "mmc_busclk.2"),
> + ALIAS(SCLK_MMC1, "s3c-sdhci.1", "mmc_busclk.2"),
> + ALIAS(SCLK_MMC2, "s3c-sdhci.2", "mmc_busclk.2"),
> + ALIAS(SCLK_MMC3, "s3c-sdhci.3", "mmc_busclk.2"),
> + ALIAS(SPI0, "s5pv210-spi.0", "spi_busclk0"),
> + ALIAS(SPI1, "s5pv210-spi.1", "spi_busclk0"),
> + ALIAS(SCLK_SPI0, "s5pv210-spi.0", "spi_busclk1"),
> + ALIAS(SCLK_SPI1, "s5pv210-spi.1", "spi_busclk1"),
> + ALIAS(PDMA0, "dma-pl330.0", "apb_pclk"),
> + ALIAS(PDMA1, "dma-pl330.1", "apb_pclk"),
> + ALIAS(PWM, NULL, "timers"),

This one if fine, as the PWM clocksource driver does not have a struct
device bound to it. (Generally speaking, this should be fixed by using
clk_get_sys() in that driver, but this is a material for separate patches.)

> +
> + ALIAS(JPEG, NULL, "jpeg"),

This one should have a device name as well.

> + ALIAS(MFC, "s5p-mfc", "mfc"),
> + ALIAS(TVENC, "s5p-sdo", "dac"),
> + ALIAS(MIXER, "s5p-mixer", "mixer"),
> + ALIAS(VP, "s5p-mixer", "vp"),
> + ALIAS(HDMI, "s5p-hdmi", "hdmi"),
> + ALIAS(SCLK_HDMI, "s5p-hdmi", "hdmiphy"),
> +
> + ALIAS(SCLK_DAC, NULL, "sclk_dac"),

Ditto.

> + ALIAS(DACPHY, "s5p-sdo", "dacphy"),
> + ALIAS(USB_OTG, NULL, "usbotg"),
> + ALIAS(USB_OTG, NULL, "otg"),
> + ALIAS(USB_HOST, NULL, "usb-host"),
> + ALIAS(USB_HOST, NULL, "usbhost"),

4 x Ditto.

Also why these clocks have two aliases? What are their users?

> + ALIAS(FIMD, "s5pv210-fb", "lcd"),
> + ALIAS(CFCON, NULL, "cfcon"),

Does anything even use this alias?

> + ALIAS(SYSTIMER, NULL, "systimer"),

Does anything use this alias?

> + ALIAS(WDT, NULL, "watchdog"),
> + ALIAS(RTC, NULL, "rtc"),

Device names x 2.

> + ALIAS(I2C0, "s3c2440-i2c.0", "i2c"),
> + ALIAS(I2C_HDMI_CEC, "s3c2440-i2c.1", "i2c"),
> + ALIAS(I2C2, "s3c2440-i2c.2", "i2c"),
> + ALIAS(I2C_HDMI_PHY, "s3c2440-hdmiphy-i2c", "i2c"),
> + ALIAS(TSADC, NULL, "adc"),

Ditto.

> + ALIAS(KEYIF, "s5pv210-keypad", "keypad"),
> + ALIAS(I2S0, "samsung-i2s.0", "iis"),
> + ALIAS(I2S1, "samsung-i2s.1", "iis"),
> + ALIAS(I2S2, "samsung-i2s.2", "iis"),
> + ALIAS(SPDIF, NULL, "spdif"),
> + ALIAS(ROTATOR, NULL, "rot"),

Device names x 2. (Although I'm not sure if something really uses the "rot"
alias.)

> + ALIAS(DOUT_APLL, NULL, "armclk"),

This one is needed by s5pv210-cpufreq indeed, but it also needs sclk_dmc0
and hclk_msys, which don't seem to have aliases defined in this driver.
However I also believe that s5pv210-cpufreq should be fixed to use
clk_get_sys(), with some made up device name, e.g. "s5pv210-cpufreq".

> + ALIAS(SCLK_AUDIO0, "soc-audio.0", "sclk_audio"),
> + ALIAS(SCLK_AUDIO1, "soc-audio.1", "sclk_audio"),
> + ALIAS(SCLK_AUDIO2, "soc-audio.2", "sclk_audio"),
> +
> + ALIAS(MFC, "s5p-mfc", "sclk_mfc"),
> + ALIAS(SCLK_CAM0, NULL, "sclk_cam0"),
> + ALIAS(SCLK_CAM1, NULL, "sclk_cam1"),

Device names. x2

> + ALIAS(G2D, "s5p-g2d", "fimg2d"),
> + ALIAS(DOUT_G2D, "s5p-g2d", "sclk_fimg2d"),
> + ALIAS(CSIS, "s5p-mipi-csis", "csis"),
> + ALIAS(SCLK_CSIS, "s5p-mipi-csis", "sclk_csis"),
> + ALIAS(SCLK_PWM, "samsung-pwm", "pwm-tclk0"),
> + ALIAS(SCLK_PWM, "samsung-pwm", "pwm-tclk1"),
> + ALIAS(SCLK_FIMD, NULL, "sclk_fimd"),
> + ALIAS(MOUT_CAM0, NULL, "mout_cam0"),
> + ALIAS(MOUT_CAM1, NULL, "mout_cam1"),
> +
> + ALIAS(MOUT_CSIS, NULL, "mout_csis"),
> + ALIAS(MOUT_VPLL, NULL, "sclk_vpll"),
> + ALIAS(SCLK_MIXER, NULL, "sclk_mixer"),
> + ALIAS(SCLK_HDMI, NULL, "sclk_hdmi"),

Device names. x7

> +};
> +
> +static unsigned long __init s5pv210_get_xom(void)
> +{
> + unsigned long xom = 1;
> + struct device_node *np;
> +
> + np = of_find_compatible_node(NULL, NULL, "samsung,s5pv210-chipid");
> + if (np) {

Instead of moving the successful path under the if, what about calling
panic() if the node couldn't be found?

> + void __iomem *chipid_base = of_iomap(np, 0);
> +
> + if (!chipid_base)
> + panic("%s: failed to map chipid\n", __func__);
> + else {

Coding style: Braces should be used consistently, i.e. if used for "if"
clause, then should be used for "else" clause as well and vice versa.

Also you don't even need this else, because panic() does not return.

> + xom = readl(chipid_base + 8);
> + iounmap(chipid_base);
> + }
> + }
> +
> + return xom;
> +}
> +
> +static void __init s5pv210_clk_register_finpll(unsigned long xom)
> +{
> + struct samsung_fixed_rate_clock fclk;
> + struct clk *clk;
> + unsigned long finpll_f = 24000000;
> + char *parent_name;
> +
> + parent_name = xom & 1 ? "xusbxti" : "xxti";
> + clk = clk_get(NULL, parent_name);
> + if (IS_ERR(clk))
> + pr_err("%s: failed to lookup parent clock %s, assuming fin_pll clock
> frequency is 24MHz\n", + __func__, parent_name);
> + else
> + finpll_f = clk_get_rate(clk);

Hmm, I wonder if it's the right assumption. Maybe it would be better to
simply fail here? I'd like to hear other opinions on this.

> +
> + fclk.id = FIN_PLL;
> + fclk.name = "fin_pll";
> + fclk.parent_name = NULL;
> + fclk.flags = CLK_IS_ROOT;
> + fclk.fixed_rate = finpll_f;
> + samsung_clk_register_fixed_rate(&fclk, 1);

Also if you could register here a fixed factor clock with 1:1 factor that
would just have the right parent clock set, instead of fixed rate clock,
the clock tree would be closer to reality.

> +}
> +
> +static void __init s5pv210_clk_register_fixed_ext(unsigned long xxti_f,
> + unsigned long xusbxti_f)
> +{
> + s5pv210_fixed_rate_ext_clks[0].fixed_rate = xxti_f;
> + s5pv210_fixed_rate_ext_clks[1].fixed_rate = xusbxti_f;
> + samsung_clk_register_fixed_rate(s5pv210_fixed_rate_ext_clks,
> + ARRAY_SIZE(s5pv210_fixed_rate_ext_clks));
> +}
> +
> +static struct samsung_pll_clock s5pv210_pll_clks[] __initdata = {
> + [apll] = PLL(pll_4508, FOUT_APLL, "fout_apll", "fin_pll",
> + APLL_LOCK, APLL_CON0, NULL),
> + [mpll] = PLL(pll_4502, FOUT_MPLL, "fout_mpll", "fin_pll",
> + MPLL_LOCK, MPLL_CON, NULL),
> + [epll] = PLL(pll_4600, FOUT_EPLL, "fout_epll", "fin_pll",
> + EPLL_LOCK, EPLL_CON0, NULL),
> + [vpll] = PLL(pll_4502, FOUT_VPLL, "fout_vpll", "mout_vpllsrc",
> + VPLL_LOCK, VPLL_CON0, NULL),
> +};
> +
> +void __init s5pv210_clk_init(struct device_node *np, unsigned long
> xxti_f, + unsigned long xusbxti_f, void __iomem *reg_base)
> +{
> + unsigned long xom = s5pv210_get_xom();

What about XOM value when booting without device tree? Shouldn't you have
some way to read XOM value in platform code and pass it here, like it was
done in Exynos4 clock driver before we dropped non-DT support for Exynos?

Otherwise looks good.

Best regards,
Tomasz

2013-08-29 14:45:56

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH v3 6/6] ARM: s5pv210: Migrate clock handling to Common Clock Framework

Hi Mateusz,

On Wednesday 28 of August 2013 18:13:04 Mateusz Krawczuk wrote:
> This patch migrates the s5pv210 platform to use new clock driver
> using Common Clock Framework.
>
> Signed-off-by: Mateusz Krawczuk <[email protected]>
> ---
> arch/arm/mach-s5pv210/Kconfig | 9 +++++++++
> arch/arm/mach-s5pv210/Makefile | 4 ++--
> arch/arm/mach-s5pv210/common.c | 17 +++++++++++++++++
> arch/arm/mach-s5pv210/common.h | 13 +++++++++++++
> arch/arm/mach-s5pv210/mach-aquila.c | 1 +
> arch/arm/mach-s5pv210/mach-goni.c | 3 ++-
> arch/arm/mach-s5pv210/mach-smdkc110.c | 1 +
> arch/arm/mach-s5pv210/mach-smdkv210.c | 1 +
> arch/arm/mach-s5pv210/mach-torbreck.c | 1 +
> arch/arm/plat-samsung/Kconfig | 2 +-
> arch/arm/plat-samsung/init.c | 2 --
> 11 files changed, 48 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/mach-s5pv210/Kconfig
> b/arch/arm/mach-s5pv210/Kconfig index caaedaf..ad4546e 100644
> --- a/arch/arm/mach-s5pv210/Kconfig
> +++ b/arch/arm/mach-s5pv210/Kconfig
> @@ -15,6 +15,7 @@ config CPU_S5PV210
> select S5P_PM if PM
> select S5P_SLEEP if PM
> select SAMSUNG_DMADEV
> + select S5P_CLOCK if !COMMON_CLK
> help
> Enable S5PV210 CPU support
>
> @@ -69,6 +70,14 @@ config S5PV210_SETUP_USB_PHY
> help
> Common setup code for USB PHY controller
>
> +config COMMON_CLK_S5PV210
> + bool "Common Clock Framework support"
> + default y
> + select COMMON_CLK
> + help
> + Enable this option to use new clock driver
> + based on Common Clock Framework.
> +
> menu "S5PC110 Machines"
>
> config MACH_AQUILA
> diff --git a/arch/arm/mach-s5pv210/Makefile
> b/arch/arm/mach-s5pv210/Makefile index 1c4e419..0c67fe2 100644
> --- a/arch/arm/mach-s5pv210/Makefile
> +++ b/arch/arm/mach-s5pv210/Makefile
> @@ -12,8 +12,8 @@ obj- :=
>
> # Core
>
> -obj-y += common.o clock.o
> -
> +obj-y += common.o
> +obj-$(CONFIG_S5P_CLOCK) += clock.o
> obj-$(CONFIG_PM) += pm.o
>
> obj-y += dma.o
> diff --git a/arch/arm/mach-s5pv210/common.c
> b/arch/arm/mach-s5pv210/common.c index 26027a2..a1d86a1 100644
> --- a/arch/arm/mach-s5pv210/common.c
> +++ b/arch/arm/mach-s5pv210/common.c
> @@ -34,7 +34,13 @@
> #include <mach/regs-clock.h>
>
> #include <plat/cpu.h>
> +
> +#ifdef CONFIG_S5P_CLOCK
> #include <plat/clock.h>
> +#else
> +#include <linux/clk-provider.h>
> +#endif
> +
> #include <plat/devs.h>
> #include <plat/sdhci.h>
> #include <plat/adc-core.h>
> @@ -50,6 +56,14 @@
>
> #include "common.h"
>
> +/* External clock frequency */
> +static unsigned long xusbxti_f, xxti_f;

If the xxti_f variable is not being changed anywhere, it might be a good
idea to drop it completely and pass a constant zero to s5pv210_clk_init().

> +
> +void __init s5pv210_set_xusbxti_freq(unsigned long freq)
> +{
> + xusbxti_f = freq;
> +}
> +
> static const char name_s5pv210[] = "S5PV210/S5PC110";
>
> static struct cpu_table cpu_ids[] __initdata = {
> @@ -229,12 +243,14 @@ void __init s5pv210_map_io(void)
>
> void __init s5pv210_init_clocks(int xtal)
> {
> +#ifdef CONFIG_S5P_CLOCK
> printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
>
> s3c24xx_register_baseclocks(xtal);
> s5p_register_clocks(xtal);
> s5pv210_register_clocks();
> s5pv210_setup_clocks();
> +#endif
> }
>
> void __init s5pv210_init_irq(void)
> @@ -248,6 +264,7 @@ void __init s5pv210_init_irq(void)
> vic[3] = ~0;
>
> s5p_init_irq(vic, ARRAY_SIZE(vic));
> + s5pv210_clk_init(NULL, xxti_f, xusbxti_f, S3C_VA_SYS);
> }
>
> struct bus_type s5pv210_subsys = {
> diff --git a/arch/arm/mach-s5pv210/common.h
> b/arch/arm/mach-s5pv210/common.h index fe1beb5..2db2a15 100644
> --- a/arch/arm/mach-s5pv210/common.h
> +++ b/arch/arm/mach-s5pv210/common.h
> @@ -14,6 +14,19 @@
>
> #include <linux/reboot.h>
>
> +void s5pv210_set_xxti_freq(unsigned long freq);

This function is no longer present in common.c, so should be removed here
as well.

> +void s5pv210_set_xusbxti_freq(unsigned long freq);
> +
> +#ifdef CONFIG_COMMON_CLK_S5PV210
> +void s5pv210_clk_init(struct device_node *np,
> + unsigned long xxti_f, unsigned long xusbxti_f,
> + void __iomem *reg_base);
> +#else
> +static inline void s5pv210_clk_init(struct device_node *np,
> + unsigned long xxti_f, unsigned long xusbxti_f,
> + void __iomem *reg_base) {}
> +#endif
> +
> void s5pv210_init_io(struct map_desc *mach_desc, int size);
> void s5pv210_init_irq(void);
>
> diff --git a/arch/arm/mach-s5pv210/mach-aquila.c
> b/arch/arm/mach-s5pv210/mach-aquila.c index ad40ab0..e37a311 100644
> --- a/arch/arm/mach-s5pv210/mach-aquila.c
> +++ b/arch/arm/mach-s5pv210/mach-aquila.c
> @@ -646,6 +646,7 @@ static void __init aquila_map_io(void)
> {
> s5pv210_init_io(NULL, 0);
> s3c24xx_init_clocks(24000000);
> + s5pv210_set_xusbxti_freq(24000000);
> s3c24xx_init_uarts(aquila_uartcfgs, ARRAY_SIZE(aquila_uartcfgs));
> samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
> }
> diff --git a/arch/arm/mach-s5pv210/mach-goni.c
> b/arch/arm/mach-s5pv210/mach-goni.c index 282d714..a1955e9 100644
> --- a/arch/arm/mach-s5pv210/mach-goni.c
> +++ b/arch/arm/mach-s5pv210/mach-goni.c
> @@ -966,7 +966,8 @@ static void __init goni_sound_init(void)
> static void __init goni_map_io(void)
> {
> s5pv210_init_io(NULL, 0);
> - s3c24xx_init_clocks(clk_xusbxti.rate);
> + s3c24xx_init_clocks(24000000);
> + s5pv210_set_xusbxti_freq(24000000);
> s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs));
> samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
> }
> diff --git a/arch/arm/mach-s5pv210/mach-smdkc110.c
> b/arch/arm/mach-s5pv210/mach-smdkc110.c index 7c0ed07..89563ed 100644
> --- a/arch/arm/mach-s5pv210/mach-smdkc110.c
> +++ b/arch/arm/mach-s5pv210/mach-smdkc110.c
> @@ -119,6 +119,7 @@ static void __init smdkc110_map_io(void)
> {
> s5pv210_init_io(NULL, 0);
> s3c24xx_init_clocks(24000000);
> + s5pv210_set_xusbxti_freq(24000000);
> s3c24xx_init_uarts(smdkv210_uartcfgs, ARRAY_SIZE(smdkv210_uartcfgs));
> samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
> }
> diff --git a/arch/arm/mach-s5pv210/mach-smdkv210.c
> b/arch/arm/mach-s5pv210/mach-smdkv210.c index 6d72bb99..ff4a470 100644
> --- a/arch/arm/mach-s5pv210/mach-smdkv210.c
> +++ b/arch/arm/mach-s5pv210/mach-smdkv210.c
> @@ -285,6 +285,7 @@ static void __init smdkv210_map_io(void)
> {
> s5pv210_init_io(NULL, 0);
> s3c24xx_init_clocks(clk_xusbxti.rate);

This won't compile with common clk enabled, since it would reference a non-
existent clk_xusbxti symbol. Shouldn't this be changed in the same way as
mach-goni?

> + s5pv210_set_xusbxti_freq(24000000);
> s3c24xx_init_uarts(smdkv210_uartcfgs, ARRAY_SIZE(smdkv210_uartcfgs));
> samsung_set_timer_source(SAMSUNG_PWM2, SAMSUNG_PWM4);
> }
> diff --git a/arch/arm/mach-s5pv210/mach-torbreck.c
> b/arch/arm/mach-s5pv210/mach-torbreck.c index 579afe8..c131cd2 100644
> --- a/arch/arm/mach-s5pv210/mach-torbreck.c
> +++ b/arch/arm/mach-s5pv210/mach-torbreck.c
> @@ -105,6 +105,7 @@ static void __init torbreck_map_io(void)
> {
> s5pv210_init_io(NULL, 0);
> s3c24xx_init_clocks(24000000);
> + s5pv210_set_xusbxti_freq(24000000);
> s3c24xx_init_uarts(torbreck_uartcfgs, ARRAY_SIZE(torbreck_uartcfgs));
> samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
> }
> diff --git a/arch/arm/plat-samsung/Kconfig
> b/arch/arm/plat-samsung/Kconfig index 7dfba93..2a98613 100644
> --- a/arch/arm/plat-samsung/Kconfig
> +++ b/arch/arm/plat-samsung/Kconfig
> @@ -91,7 +91,7 @@ config SAMSUNG_CLKSRC
> used by newer systems such as the S3C64XX.
>
> config S5P_CLOCK
> - def_bool (ARCH_S5P64X0 || ARCH_S5PC100 || ARCH_S5PV210)
> + def_bool (ARCH_S5P64X0 || ARCH_S5PC100)
> help
> Support common clock part for ARCH_S5P and ARCH_EXYNOS SoCs
>
> diff --git a/arch/arm/plat-samsung/init.c b/arch/arm/plat-samsung/init.c
> index aa9511b..f0f818e 100644
> --- a/arch/arm/plat-samsung/init.c
> +++ b/arch/arm/plat-samsung/init.c
> @@ -69,7 +69,6 @@ void __init s3c_init_cpu(unsigned long idcode,
> if (cpu->map_io)
> cpu->map_io();
> }
> -

This change doesn't belong to this patch.

> /* s3c24xx_init_clocks
> *
> * Initialise the clock subsystem and associated information from the
> @@ -92,7 +91,6 @@ void __init s3c24xx_init_clocks(int xtal)
> else
> (cpu->init_clocks)(xtal);
> }
> -

Ditto.

Otherwise looks good.

Best regards,
Tomasz