Skip to contentSkip to conversation

powerpc/5200: add general purpose timer API for the MPC5200

RFC Superseded Grant Likely 2 participants 4 messages Mar 6, 2009

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

RFC 1/2 powerpc/5200: add general purpose timer API for the MPC5200

From: Grant Likely <[email protected]>

This patch adds an interface for controlling the timer function of the MPC5200 GPT devices.

---

This probably isn't complete, but I wanted to get it out there and reviewed before I commit to the design. Comments appreciated.

g.

 arch/powerpc/include/asm/mpc52xx.h        |    7 ++
 arch/powerpc/platforms/52xx/mpc52xx_gpt.c |  132 +++++++++++++++++++++++++++--
 2 files changed, 129 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/mpc52xx.h +7 -0
index 81a2393..8273357 100644
@@ -275,6 +275,13 @@ extern void mpc52xx_map_common_devices(void);
 extern int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv);
 extern void mpc52xx_restart(char *cmd);
 
+/* mpc52xx_gpt.c */
+struct mpc52xx_gpt_priv;
+extern struct mpc52xx_gpt_priv *mpc52xx_gpt_from_irq(int irq);
+extern int mpc52xx_gpt_start_timer(struct mpc52xx_gpt_priv *gpt, int period,
+                            int continuous);
+extern void mpc52xx_gpt_stop_timer(struct mpc52xx_gpt_priv *gpt);
+
 /* mpc52xx_pic.c */
 extern void mpc52xx_init_irq(void);
 extern unsigned int mpc52xx_get_irq(void);
arch/powerpc/platforms/52xx/mpc52xx_gpt.c +122 -10

205 lines not on this page · raw message

#1 lore raw

RFC 2/2 powerpc/5200: add LocalPlus bus FIFO device driver

From: Grant Likely <[email protected]>

This is a driver for the LocalPlus bus FIFO device

---

This also isn't complete, but I wanted to get it out there and reviewed before I commit to the design. Comments appreciated.

g.

 arch/powerpc/include/asm/mpc52xx.h            |   11 +
 arch/powerpc/platforms/52xx/Kconfig           |    4 
 arch/powerpc/platforms/52xx/Makefile          |    1 
 arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c |  282 +++++++++++++++++++++++++
 4 files changed, 298 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c
arch/powerpc/include/asm/mpc52xx.h +11 -0
index 8273357..7ec34ea 100644
@@ -282,6 +282,17 @@ extern int mpc52xx_gpt_start_timer(struct mpc52xx_gpt_priv *gpt, int period,
                             int continuous);
 extern void mpc52xx_gpt_stop_timer(struct mpc52xx_gpt_priv *gpt);
 
+/* mpc52xx_lpbfifo.c */
+extern int mpc52xx_lpbfifo_write(void *src, unsigned int cs,
+				 size_t offset, size_t size, int flags,
+				 void (*callback)(void *, size_t, int),
+				 void *callback_data);
+extern int mpc52xx_lpbfifo_read(void *dest, unsigned int cs,
+				size_t offset, size_t size, int flags,
+				void (*callback)(void *, size_t, int),
+				void *callback_data);
+extern void mpc52xx_lpbfifo_abort(void *callback_data);
+
 /* mpc52xx_pic.c */
 extern void mpc52xx_init_irq(void);
 extern unsigned int mpc52xx_get_irq(void);
arch/powerpc/platforms/52xx/Kconfig +4 -0
index 0465e5b..f117e23 100644
@@ -61,3 +61,7 @@ config PPC_MPC5200_GPIO
 	select GENERIC_GPIO
 	help
 	  Enable gpiolib support for mpc5200 based boards
+
+config PPC_MPC5200_LPBFIFO
+	tristate "MPC5200 LocalPlus bus FIFO driver"
+	depends on PPC_MPC52xx
arch/powerpc/platforms/52xx/Makefile +1 -0
index bfd4f52..2bc8cd0 100644
@@ -15,3 +15,4 @@ ifeq ($(CONFIG_PPC_LITE5200),y)
 endif
 
 obj-$(CONFIG_PPC_MPC5200_GPIO)	+= mpc52xx_gpio.o
+obj-$(CONFIG_PPC_MPC5200_LPBFIFO)	+= mpc52xx_lpbfifo.o
arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c new file +282 -0

282 lines not on this page · raw message

#2 lore raw
In reply to Grant Likely

I'm using a GPT pin in input capture mode to implement IR. I attached my GPT driver code. I can convert to your API. That's a really cheap way to do IR, just IR sensor, resistor and a cap.

I also have an in-kernel IR system but Christoph (lirc maintainer) won't consider it. He is a microkernel type - he wants everything in user space. My in-kernel version is tiny, less than 10K. It turns IR events into keystrokes on a virtual keyboard device.

This is my old device tree, what should the new one look like?

		ir0@670 { /* General Purpose Timer 6 in Input mode */
			compatible = "gpt-ir";
			cell-index = <7>;
			reg = <0x670 0x10>;
			interrupts = <0x1 0x10 0x0>;
			interrupt-parent = <&mpc5200_pic>;
		};
Signature · 2 lines
Jon Smirl
[email protected]
#3 lore raw
Quoted 3 lines · Jon Smirl

I'm using a GPT pin in input capture mode to implement IR. I attached my GPT driver code. I can convert to your API. That's a really cheap way to do IR, just IR sensor, resistor and a cap.

The driver I posted can't do input capture mode yet, but it shouldn't be too difficult to add. Just another api function for setting the mode I think. I don't have a use for that yet, so I haven't thought much about it. Feel free to suggest what you think the API should look like.

Quoted 3 lines

This is my old device tree, what should the new one look like?

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ir0@670 { /* General Purpose Timer 6 in In=

put mode */

Quoted 4 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compatible =3D "gpt-ir"; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cell-index =3D <7>; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0x670 0x10>; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D <0x1 0x10 0=

x0>;

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-parent =3D <&mpc=

5200_pic>;

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0};

You'd want a node for the IR device which uses the GPT node as its interrupt controller.

so:

    gpt7: gpt@670 {
        compatible =3D "fsl,mpc5200b-gpt"
        reg =3D <0x670 0x10>;
        interrupt =3D <1 16 0>;
        interrupt-controller;
        #interrupt-cells =3D <1>;
    };

Then elsewhere:
ir {
compatible =3D "digispeaker,ir"; // or whatever best matches your =
board
interrupt-parent =3D <&gpt>;
interrupts =3D <0>; // IIRC, '0' means irq on both edges for
the GPT irq controller

    };

g.

--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.