All of lore.kernel.org
 help / color / mirror / Atom feed
From: monstr@monstr.eu (Michal Simek)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 05/10] arm: zynq: Move slcr initialization to separate file
Date: Mon, 25 Mar 2013 17:37:34 +0100	[thread overview]
Message-ID: <51507D4E.5010403@monstr.eu> (raw)
In-Reply-To: <20130325161902.GF27739@pengutronix.de>

On 03/25/2013 05:19 PM, Steffen Trumtrar wrote:
> On Mon, Mar 25, 2013 at 02:53:11PM +0100, Michal Simek wrote:
>> Create separate slcr driver instead of pollute common code.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>   arch/arm/mach-zynq/Makefile |    2 +-
>>   arch/arm/mach-zynq/common.c |   10 +------
>>   arch/arm/mach-zynq/common.h |    3 ++
>>   arch/arm/mach-zynq/slcr.c   |   69 +++++++++++++++++++++++++++++++++++++++++++
>>   4 files changed, 74 insertions(+), 10 deletions(-)
>>   create mode 100644 arch/arm/mach-zynq/slcr.c
>>
>> diff --git a/arch/arm/mach-zynq/Makefile b/arch/arm/mach-zynq/Makefile
>> index 320faed..13ee09b 100644
>> --- a/arch/arm/mach-zynq/Makefile
>> +++ b/arch/arm/mach-zynq/Makefile
>> @@ -3,4 +3,4 @@
>>   #
>>
>>   # Common support
>> -obj-y				:= common.o
>> +obj-y				:= common.o slcr.o
>> diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
>> index 13f9d8b..2734bd6 100644
>> --- a/arch/arm/mach-zynq/common.c
>> +++ b/arch/arm/mach-zynq/common.c
>> @@ -61,15 +61,7 @@ static void __init xilinx_init_machine(void)
>>
>>   static void __init xilinx_zynq_timer_init(void)
>>   {
>> -	struct device_node *np;
>> -	void __iomem *slcr;
>> -
>> -	np = of_find_compatible_node(NULL, NULL, "xlnx,zynq-slcr");
>> -	slcr = of_iomap(np, 0);
>> -	WARN_ON(!slcr);
>> -
>> -	xilinx_zynq_clocks_init(slcr);
>> -
>> +	slcr_init();
>>   	clocksource_of_init();
>>   }
>>
>> diff --git a/arch/arm/mach-zynq/common.h b/arch/arm/mach-zynq/common.h
>> index 38727a2..e30898a 100644
>> --- a/arch/arm/mach-zynq/common.h
>> +++ b/arch/arm/mach-zynq/common.h
>> @@ -17,6 +17,9 @@
>>   #ifndef __MACH_ZYNQ_COMMON_H__
>>   #define __MACH_ZYNQ_COMMON_H__
>>
>> +extern int slcr_init(void);
>> +
>> +extern void __iomem *zynq_slcr_base;
>>   extern void __iomem *scu_base;
>>
>>   #endif
>> diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
>> new file mode 100644
>> index 0000000..1883b70
>> --- /dev/null
>> +++ b/arch/arm/mach-zynq/slcr.c
>> @@ -0,0 +1,69 @@
>> +/*
>> + * Xilinx SLCR driver
>> + *
>> + * Copyright (c) 2011-2013 Xilinx Inc.
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public License
>> + * as published by the Free Software Foundation; either version
>> + * 2 of the License, or (at your option) any later version.
>> + *
>> + * You should have received a copy of the GNU General Public
>> + * License along with this program; if not, write to the Free
>> + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
>> + * 02139, USA.
>> + */
>> +
>> +#include <linux/export.h>
>> +#include <linux/io.h>
>> +#include <linux/fs.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/init.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/of_address.h>
>> +#include <linux/uaccess.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/slab.h>
>> +#include <linux/string.h>
>> +#include <linux/clk/zynq.h>
>> +#include "common.h"
>> +
>> +#define SLCR_UNLOCK_MAGIC		0xDF0D
>> +#define SLCR_UNLOCK			0x8   /* SCLR unlock register */
> --------------------------------------------------^ small typo
>> +
>> +void __iomem *zynq_slcr_base;
>> +
>> +/**
>> + * xslcr_init()
>> + * Returns 0 on success, negative errno otherwise.
>> + *
>> + * Called early during boot from platform code to remap SLCR area.
>> + */
>> +int __init slcr_init(void)
>> +{
>> +	struct device_node *np;
>> +
>> +	np = of_find_compatible_node(NULL, NULL, "xlnx,zynq-slcr");
>> +	if (!np) {
>> +		pr_err("%s: no slcr node found\n", __func__);
>> +		BUG();
>> +	}
>> +
>> +	zynq_slcr_base = of_iomap(np, 0);
>> +	if (!zynq_slcr_base) {
>> +		pr_err("%s: Unable to map I/O memory\n", __func__);
>> +		BUG();
>> +	}
>> +
>> +	/* unlock the SLCR so that registers can be changed */
>> +	writel(SLCR_UNLOCK_MAGIC, zynq_slcr_base + SLCR_UNLOCK);
>> +
>> +	pr_info("%s mapped to %p\n", np->name, zynq_slcr_base);
>> +
>> +	xilinx_zynq_clocks_init(zynq_slcr_base);
>> +
>> +	of_node_put(np);
>> +
>> +	return 0;
>> +}
>
> The slcr should definitely get it's own driver. I like that.
> But wouldn't it be better to call this in the map_io call and then, for the time
> being, assume that the slcr is unlocked and put the clocks_init-call in
> zynq_timer_init?

map_io can work with static mapping. Dynamic mapping only doesn't work in that time.
That's why it must be done later.
The reason why I call xilinx_zynq_clocks_init() from this code is
that slcr IP contains almost everything and clocks are logical subnode of this device.

Thanks,
Michal
-- 
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

  reply	other threads:[~2013-03-25 16:37 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25 13:53 [PATCH 01/10] arm: zynq: Use standard timer binding Michal Simek
2013-03-25 13:53 ` [PATCH 02/10] arm: zynq: Move timer to clocksource interface Michal Simek
2013-03-25 13:53 ` [PATCH 03/10] arm: zynq: Move timer to generic location Michal Simek
2013-03-25 16:01   ` Steffen Trumtrar
2013-03-25 16:24     ` Michal Simek
2013-03-25 13:53 ` [PATCH 04/10] arm: zynq: Load scu baseaddress at run time Michal Simek
2013-03-25 14:06   ` Rob Herring
2013-03-25 14:51     ` Michal Simek
2013-03-25 15:37       ` Rob Herring
2013-03-25 16:07         ` Michal Simek
2013-03-25 22:34           ` Rob Herring
2013-03-26 10:45             ` Michal Simek
2013-03-26 12:28               ` Rob Herring
2013-03-26 12:33                 ` Michal Simek
2013-04-02 16:40           ` Pawel Moll
     [not found]             ` <CAHTX3dKD4G0E8qoxTR2HnJVdagoeOerM+TiZzkJUPjcGwYdX_Q@mail.gmail.com>
2013-04-03  7:25               ` Steffen Trumtrar
2013-04-03 16:06               ` Pawel Moll
     [not found]                 ` <CAHTX3dJMpp+E2u-cAeYbqtxC1WAYWpCeRx6W7G=dWDcgzUz5DA@mail.gmail.com>
2013-04-03 17:11                   ` Pawel Moll
2013-03-25 13:53 ` [PATCH 05/10] arm: zynq: Move slcr initialization to separate file Michal Simek
2013-03-25 16:19   ` Steffen Trumtrar
2013-03-25 16:37     ` Michal Simek [this message]
2013-03-25 13:53 ` [PATCH 06/10] arm: zynq: Add support for system reset Michal Simek
2013-03-25 13:53 ` [PATCH 07/10] arm: zynq: Add support for pmu Michal Simek
2013-03-25 13:53 ` [PATCH 08/10] arm: zynq: Add smp support Michal Simek
2013-03-25 14:16   ` Rob Herring
2013-03-25 16:31     ` Michal Simek
2013-03-25 22:10       ` Rob Herring
2013-03-26  7:42         ` Michal Simek
2013-04-01 22:40           ` Rob Herring
2013-04-03  6:44             ` Michal Simek
2013-03-25 13:53 ` [PATCH 09/10] arm: zynq: Add hotplug support Michal Simek
2013-03-25 13:53 ` [PATCH 10/10] arm: zynq: Add cpuidle support Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51507D4E.5010403@monstr.eu \
    --to=monstr@monstr.eu \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.