All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] generic clk API implementation for MIPS
@ 2007-06-25 16:14 Atsushi Nemoto
  2007-06-26  9:37 ` Franck Bui-Huu
  0 siblings, 1 reply; 34+ messages in thread
From: Atsushi Nemoto @ 2007-06-25 16:14 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

The clock framework (clk_get(), etc.) would be useful to provide some
clock values to platform devices or so.

This MIPS implementation is derived (and stripped) from the SH
implementation.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 arch/mips/lib/Makefile   |    2 +-
 arch/mips/lib/clock.c    |  189 ++++++++++++++++++++++++++++++++++++++++++++++
 include/asm-mips/clock.h |   39 ++++++++++
 3 files changed, 229 insertions(+), 1 deletions(-)

diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index a960c05..ecea595 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -3,7 +3,7 @@
 #
 
 lib-y	+= csum_partial.o memcpy.o memcpy-inatomic.o memset.o strlen_user.o \
-	   strncpy_user.o strnlen_user.o uncached.o
+	   strncpy_user.o strnlen_user.o uncached.o clock.o
 
 obj-y			+= iomap.o
 obj-$(CONFIG_PCI)	+= iomap-pci.o
diff --git a/arch/mips/lib/clock.c b/arch/mips/lib/clock.c
new file mode 100644
index 0000000..059294d
--- /dev/null
+++ b/arch/mips/lib/clock.c
@@ -0,0 +1,189 @@
+/*
+ * arch/mips/lib/clock.c - MIPS clock framework
+ *
+ * This clock framework is derived from the SH version by:
+ *
+ *  Copyright (C) 2005, 2006  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/list.h>
+#include <linux/kref.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <asm/clock.h>
+
+static LIST_HEAD(clock_list);
+static DEFINE_SPINLOCK(clock_lock);
+static DEFINE_MUTEX(clock_list_lock);
+
+static int __clk_enable(struct clk *clk)
+{
+	/*
+	 * See if this is the first time we're enabling the clock, some
+	 * clocks that are always enabled still require "special"
+	 * initialization. This is especially true if the clock mode
+	 * changes and the clock needs to hunt for the proper set of
+	 * divisors to use before it can effectively recalc.
+	 */
+	if (unlikely(atomic_read(&clk->kref.refcount) == 1))
+		if (clk->ops && clk->ops->init)
+			clk->ops->init(clk);
+
+	if (clk->flags & CLK_ALWAYS_ENABLED)
+		return 0;
+
+	if (likely(clk->ops && clk->ops->enable))
+		clk->ops->enable(clk);
+
+	kref_get(&clk->kref);
+	return 0;
+}
+
+int clk_enable(struct clk *clk)
+{
+	unsigned long flags;
+	int ret;
+
+	spin_lock_irqsave(&clock_lock, flags);
+	ret = __clk_enable(clk);
+	spin_unlock_irqrestore(&clock_lock, flags);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(clk_enable);
+
+static void clk_kref_release(struct kref *kref)
+{
+	/* Nothing to do */
+}
+
+static void __clk_disable(struct clk *clk)
+{
+	if (clk->flags & CLK_ALWAYS_ENABLED)
+		return;
+
+	kref_put(&clk->kref, clk_kref_release);
+}
+
+void clk_disable(struct clk *clk)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&clock_lock, flags);
+	__clk_disable(clk);
+	spin_unlock_irqrestore(&clock_lock, flags);
+}
+EXPORT_SYMBOL_GPL(clk_disable);
+
+int clk_register(struct clk *clk)
+{
+	mutex_lock(&clock_list_lock);
+
+	list_add(&clk->node, &clock_list);
+	kref_init(&clk->kref);
+
+	mutex_unlock(&clock_list_lock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(clk_register);
+
+void clk_unregister(struct clk *clk)
+{
+	mutex_lock(&clock_list_lock);
+	list_del(&clk->node);
+	mutex_unlock(&clock_list_lock);
+}
+EXPORT_SYMBOL_GPL(clk_unregister);
+
+unsigned long clk_get_rate(struct clk *clk)
+{
+	return clk->rate;
+}
+EXPORT_SYMBOL_GPL(clk_get_rate);
+
+int clk_set_rate(struct clk *clk, unsigned long rate)
+{
+	int ret = -EOPNOTSUPP;
+
+	if (likely(clk->ops && clk->ops->set_rate)) {
+		unsigned long flags;
+
+		spin_lock_irqsave(&clock_lock, flags);
+		ret = clk->ops->set_rate(clk, rate);
+		spin_unlock_irqrestore(&clock_lock, flags);
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(clk_set_rate);
+
+/*
+ * Returns a clock. Note that we first try to use device id on the bus
+ * and clock name. If this fails, we try to use clock name only.
+ */
+struct clk *clk_get(struct device *dev, const char *id)
+{
+	struct clk *p, *clk = ERR_PTR(-ENOENT);
+	int idno;
+
+	if (dev == NULL || dev->bus != &platform_bus_type)
+		idno = -1;
+	else
+		idno = to_platform_device(dev)->id;
+
+	mutex_lock(&clock_list_lock);
+	list_for_each_entry(p, &clock_list, node) {
+		if (p->id == idno &&
+		    strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
+			clk = p;
+			goto found;
+		}
+	}
+
+	list_for_each_entry(p, &clock_list, node) {
+		if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
+			clk = p;
+			break;
+		}
+	}
+
+found:
+	mutex_unlock(&clock_list_lock);
+
+	return clk;
+}
+EXPORT_SYMBOL_GPL(clk_get);
+
+void clk_put(struct clk *clk)
+{
+	if (clk && !IS_ERR(clk))
+		module_put(clk->owner);
+}
+EXPORT_SYMBOL_GPL(clk_put);
+
+long clk_round_rate(struct clk *clk, unsigned long rate)
+{
+	return rate;
+}
+EXPORT_SYMBOL_GPL(clk_round_rate);
+
+int clk_set_parent(struct clk *clk, struct clk *parent)
+{
+	clk->parent = parent;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(clk_set_parent);
+
+struct clk *clk_get_parent(struct clk *clk)
+{
+	return clk->parent ?: ERR_PTR(-ENODEV);
+}
+EXPORT_SYMBOL_GPL(clk_get_parent);
diff --git a/include/asm-mips/clock.h b/include/asm-mips/clock.h
new file mode 100644
index 0000000..6170f31
--- /dev/null
+++ b/include/asm-mips/clock.h
@@ -0,0 +1,39 @@
+#ifndef __ASM_MIPS_CLOCK_H
+#define __ASM_MIPS_CLOCK_H
+
+/* generic clk API implementation --- derived from include/asm-sh/clock.h */
+
+#include <linux/kref.h>
+#include <linux/list.h>
+#include <linux/clk.h>
+
+struct clk;
+
+struct clk_ops {
+	void (*init)(struct clk *clk);
+	void (*enable)(struct clk *clk);
+	void (*disable)(struct clk *clk);
+	int (*set_rate)(struct clk *clk, unsigned long rate);
+};
+
+struct clk {
+	struct list_head	node;
+	const char		*name;
+	int			id;
+	struct module		*owner;
+
+	struct clk		*parent;
+	struct clk_ops		*ops;
+
+	struct kref		kref;
+
+	unsigned long		rate;
+	unsigned long		flags;
+};
+
+#define CLK_ALWAYS_ENABLED	(1 << 0)
+
+int clk_register(struct clk *);
+void clk_unregister(struct clk *);
+
+#endif /* __ASM_MIPS_CLOCK_H */

^ permalink raw reply related	[flat|nested] 34+ messages in thread
* gdbserver
@ 2002-03-12 19:22 Lanny DeVaney
  2002-03-12 20:45 ` gdbserver Johannes Stezenbach
  2002-03-12 22:10 ` gdbserver Daniel Jacobowitz
  0 siblings, 2 replies; 34+ messages in thread
From: Lanny DeVaney @ 2002-03-12 19:22 UTC (permalink / raw)
  To: linux-mips

I've looked back through the archives and find some references to 
problems configuring and/or building gdbserver for mips-linux.

I'm attempting to build gdb/gdbserver with --target=mips-linux as well, 
using gdb-5.1.1.  Have the earlier issues (they looked to be 1-2 years 
old) been resolved or am I still looking at a "manual build" process? 
 I'm getting lots of errors with the build, although the configure seems 
to go OK.  x86 host, linux-mips target.

Thanks for any help you can provide,
Lanny DeVaney
Red Hat, Inc.

^ permalink raw reply	[flat|nested] 34+ messages in thread
* gdbserver
@ 2002-01-25 10:20 Kristberg Karlsson
  0 siblings, 0 replies; 34+ messages in thread
From: Kristberg Karlsson @ 2002-01-25 10:20 UTC (permalink / raw)
  To: linux-kernel

Hello out there.
I've heard about a program for remote debugging called gdbserver.
Does anyone know how to get hold of it.

Agust Karlsson
Pallas Informatik A/S
Allerod Stationsvej 2D
DK-3450 Allerod
DENMARK



Sent með Frípósti frá Vísir.is

^ permalink raw reply	[flat|nested] 34+ messages in thread
* gdbserver
@ 2000-01-22  3:20 dony
  2000-01-22 10:27 ` gdbserver Jesper Skov
  0 siblings, 1 reply; 34+ messages in thread
From: dony @ 2000-01-22  3:20 UTC (permalink / raw)
  To: linuxppc-embed


Hello,

       Now I want to use gdbserver to debug my test app.
      Running "gdbserver :6666 ./mytest" on the target (Powerpc 860)
show a message:
                    Process ./mytest created :pid=8
      But I don't know how to run gdb on the host (X86). The README
doesn't seem to explain
clearly . It says first running "gdb mytest" on the host and then
"target remote mytarget:6666".
But I don't understand something about "gdb mytest" . At this time
should I run a x86 "gdb" or something like "powerpc-linux-gdb"? And the
"mytest"? Is it compiled with x86 gcc or cross-compiled with
"powerpc-linux-gcc"? Really I am very confused at this point:-((
       Do you have any experience to share with me about how to build
and run gdbserver?
Or do you have any other debug tools which can be used in embedded-linux
environment?
        The README for gdbserver is written by Stu Grossman and Fred
Fish.
        Does someone know their email address?
Thank you very much:-)
dony


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 34+ messages in thread
* Re: gdbserver
@ 2000-01-21 12:38 kd
  0 siblings, 0 replies; 34+ messages in thread
From: kd @ 2000-01-21 12:38 UTC (permalink / raw)
  To: dony; +Cc: jlewis, linuxppc-embedded



Hi,

No I did not solve this. I put it on hold for a while since I can still
able to do development on my i386 system.
But soon I  will have to tackle this again since I will have to start
running the firmware on the final target.
Actually I think I might just insert more memory and run the whole gdb on
the target hardware.....

K.D.



dony wrote:


How do you solve all the above problems?
Thank you very much.
dony


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 34+ messages in thread
* gdbserver
@ 1999-12-21 14:35 kd
  1999-12-21 16:05 ` gdbserver Jim Lewis
  2000-01-21  7:25 ` gdbserver dony
  0 siblings, 2 replies; 34+ messages in thread
From: kd @ 1999-12-21 14:35 UTC (permalink / raw)
  To: linuxppc-embedded


Hi,

I am trying to get gdbserver to run on my mpc823 board. (The precompiled
gdbserver is not working for me, it does not seem to get argc and argv
correctly into main() and always terminates with "usage info".

Using the vanilla gdb-4.18 is of no use, since it has not support for ppc.
Using the gdbserver source that Dan posted here a few weeks back results in
the
the following undefined symbols,
PTRACE_POKEUSR
PTRACE_PEEKUSR
KERNEL_U_ADDR
when compiling low-linux.c
If I define these symbols to 6, 3 and 0 respectively, everything compiles
fine, but the linker fails with the error,
undefined referenve to REGISTER_U_ADDR in function register_addr.

These are defined (for some of the other targets) in directory gdb/config/.
Any idea what is missing?

K.D.


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2007-06-29  2:26 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-25 16:14 [PATCH] generic clk API implementation for MIPS Atsushi Nemoto
2007-06-26  9:37 ` Franck Bui-Huu
2007-06-26 14:33   ` Atsushi Nemoto
2007-06-26 15:20     ` Franck Bui-Huu
2007-06-26 16:33       ` Atsushi Nemoto
2007-06-26 20:02         ` Franck Bui-Huu
2007-06-27  7:51           ` Atsushi Nemoto
2007-06-27 15:39         ` Christoph Hellwig
2007-06-28  2:22           ` Atsushi Nemoto
2007-06-28  8:37             ` Christoph Hellwig
2007-06-28  9:26               ` Atsushi Nemoto
2007-06-28 20:45               ` gdbserver Ratin Rahman (mratin)
2007-06-28 20:45                 ` gdbserver Ratin Rahman (mratin)
2007-06-28 21:41                 ` gdbserver David Daney
2007-06-28 22:19                   ` gdbserver Ratin Rahman (mratin)
2007-06-28 22:19                     ` gdbserver Ratin Rahman (mratin)
2007-06-29  1:26                   ` upgrading glibc for mipsel Ratin Rahman (mratin)
2007-06-29  1:26                     ` Ratin Rahman (mratin)
2007-06-29  2:03                     ` David Daney
2007-06-29  2:26                       ` Jason Talley
  -- strict thread matches above, loose matches on Subject: below --
2002-03-12 19:22 gdbserver Lanny DeVaney
2002-03-12 20:45 ` gdbserver Johannes Stezenbach
2002-03-12 21:46   ` gdbserver Lanny DeVaney
2002-03-12 22:10 ` gdbserver Daniel Jacobowitz
2002-03-12 22:16   ` gdbserver Lanny DeVaney
2002-01-25 10:20 gdbserver Kristberg Karlsson
2000-01-22  3:20 gdbserver dony
2000-01-22 10:27 ` gdbserver Jesper Skov
2000-01-24  1:51   ` gdbserver dony
2000-01-24  8:20     ` gdbserver Jesper Skov
2000-01-21 12:38 gdbserver kd
1999-12-21 14:35 gdbserver kd
1999-12-21 16:05 ` gdbserver Jim Lewis
2000-01-21  7:25 ` gdbserver dony

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.